drivers/video/screen_info_generic.c

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

File Facts

System
Linux kernel
Corpus path
drivers/video/screen_info_generic.c
Extension
.c
Size
6365 bytes
Lines
238
Domain
Driver Families
Bucket
drivers/video
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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

if (num > 1) {
			if (__screen_info_has_ega_gfx(si->orig_video_mode))
				resource_init_mem_named(pos++, 0xa0000, 0x10000, "ega");
			else
				resource_init_mem_named(pos++, 0xb8000, 0x8000, "ega");
		}
		break;
	case VIDEO_TYPE_VGAC:
		if (num > 0)
			resource_init_io_named(pos++, 0x3c0, 0x20, "vga+");
		if (num > 1) {
			if (__screen_info_has_vga_gfx(si->orig_video_mode))
				resource_init_mem_named(pos++, 0xa0000, 0x10000, "vga+");
			else
				resource_init_mem_named(pos++, 0xb8000, 0x8000, "vga+");
		}
		break;
	case VIDEO_TYPE_VLFB:
	case VIDEO_TYPE_EFI:
		base = __screen_info_lfb_base(si);
		if (!base)
			break;
		size = __screen_info_lfb_size(si, type);
		if (!size)
			break;
		if (num > 0)
			resource_init_mem_named(pos++, base, size, "lfb");
		break;
	case VIDEO_TYPE_PICA_S3:
	case VIDEO_TYPE_MIPS_G364:
	case VIDEO_TYPE_SGI:
	case VIDEO_TYPE_TGAC:
	case VIDEO_TYPE_SUN:
	case VIDEO_TYPE_SUNPCI:
	case VIDEO_TYPE_PMAC:
	default:
		/* not supported */
		return -EINVAL;
	}

	return pos - r;
}
EXPORT_SYMBOL(screen_info_resources);

/*
 * The meaning of depth and bpp for direct-color formats is
 * inconsistent:
 *
 *  - DRM format info specifies depth as the number of color
 *    bits; including alpha, but not including filler bits.
 *  - Linux' EFI platform code computes lfb_depth from the
 *    individual color channels, including the reserved bits.
 *  - VBE 1.1 defines lfb_depth for XRGB1555 as 16, but later
 *    versions use 15.
 *  - On the kernel command line, 'bpp' of 32 is usually
 *    XRGB8888 including the filler bits, but 15 is XRGB1555
 *    not including the filler bit.
 *
 * It is not easily possible to fix this in struct screen_info,
 * as this could break UAPI. The best solution is to compute
 * bits_per_pixel from the color bits, reserved bits and
 * reported lfb_depth, whichever is highest.
 */

u32 __screen_info_lfb_bits_per_pixel(const struct screen_info *si)
{
	u32 bits_per_pixel = si->lfb_depth;

	if (bits_per_pixel > 8) {
		bits_per_pixel = max(max3(si->red_size + si->red_pos,
					  si->green_size + si->green_pos,
					  si->blue_size + si->blue_pos),
				     si->rsvd_size + si->rsvd_pos);
		bits_per_pixel = max_t(u32, bits_per_pixel, si->lfb_depth);
	}

	return bits_per_pixel;
}
EXPORT_SYMBOL(__screen_info_lfb_bits_per_pixel);

static int __screen_info_lfb_pixel_format(const struct screen_info *si, struct pixel_format *f)
{
	u32 bits_per_pixel = __screen_info_lfb_bits_per_pixel(si);

	if (bits_per_pixel > U8_MAX)
		return -EINVAL;

	f->bits_per_pixel = bits_per_pixel;

	if (si->lfb_depth > 8) {

Annotation

Implementation Notes