drivers/video/logo/pnmtologo.c

Source file repositories/reference/linux-study-clean/drivers/video/logo/pnmtologo.c

File Facts

System
Linux kernel
Corpus path
drivers/video/logo/pnmtologo.c
Extension
.c
Size
11286 bytes
Lines
509
Domain
Driver Families
Bucket
drivers/video
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct color {
	unsigned char red;
	unsigned char green;
	unsigned char blue;
};

static const struct color clut_vga16[16] = {
	{ 0x00, 0x00, 0x00 },
	{ 0x00, 0x00, 0xaa },
	{ 0x00, 0xaa, 0x00 },
	{ 0x00, 0xaa, 0xaa },
	{ 0xaa, 0x00, 0x00 },
	{ 0xaa, 0x00, 0xaa },
	{ 0xaa, 0x55, 0x00 },
	{ 0xaa, 0xaa, 0xaa },
	{ 0x55, 0x55, 0x55 },
	{ 0x55, 0x55, 0xff },
	{ 0x55, 0xff, 0x55 },
	{ 0x55, 0xff, 0xff },
	{ 0xff, 0x55, 0x55 },
	{ 0xff, 0x55, 0xff },
	{ 0xff, 0xff, 0x55 },
	{ 0xff, 0xff, 0xff },
};


static int logo_type = LINUX_LOGO_CLUT224;
static unsigned int logo_width;
static unsigned int logo_height;
static struct color **logo_data;
static struct color logo_clut[MAX_LINUX_LOGO_COLORS];
static unsigned int logo_clutsize;
static int is_plain_pbm = 0;

static void die(const char *fmt, ...)
__attribute__((noreturn)) __attribute((format (printf, 1, 2)));
static void usage(void) __attribute((noreturn));


static unsigned int get_number(FILE *fp)
{
	int c, val;

	/* Skip leading whitespace */
	do {
		c = fgetc(fp);
		if (c == EOF)
			die("%s: end of file\n", filename);
		if (c == '#') {
			/* Ignore comments 'till end of line */
			do {
				c = fgetc(fp);
				if (c == EOF)
					die("%s: end of file\n", filename);
			} while (c != '\n');
		}
	} while (isspace(c));

	/* Parse decimal number */
	val = 0;
	while (isdigit(c)) {
		val = 10*val+c-'0';
		/* some PBM are 'broken'; GiMP for example exports a PBM without space
		 * between the digits. This is Ok cause we know a PBM can only have a '1'
		 * or a '0' for the digit.
		 */
		if (is_plain_pbm)
			break;
		c = fgetc(fp);
		if (c == EOF)
			die("%s: end of file\n", filename);
	}
	return val;
}

static unsigned int get_number255(FILE *fp, unsigned int maxval)
{
	unsigned int val = get_number(fp);

	return (255*val+maxval/2)/maxval;
}

static void read_image(void)
{
	FILE *fp;
	unsigned int i, j;
	int magic;
	unsigned int maxval;

	/* open image file */

Annotation

Implementation Notes