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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ctype.herrno.hstdarg.hstdio.hstdlib.hstring.hunistd.h
Detected Declarations
struct colorfunction get_numberfunction get_number255function read_imagefunction is_blackfunction is_whitefunction is_grayfunction is_equalfunction write_headerfunction write_footerfunction write_hexfunction write_logo_monofunction write_logo_vga16function write_logo_clut224function write_logo_gray256function diefunction usagefunction main
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
- Immediate include surface: `ctype.h`, `errno.h`, `stdarg.h`, `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`.
- Detected declarations: `struct color`, `function get_number`, `function get_number255`, `function read_image`, `function is_black`, `function is_white`, `function is_gray`, `function is_equal`, `function write_header`, `function write_footer`.
- Atlas domain: Driver Families / drivers/video.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.