drivers/gpu/drm/vkms/vkms_formats.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vkms/vkms_formats.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vkms/vkms_formats.c
Extension
.c
Size
34174 bytes
Lines
972
Domain
Driver Families
Bucket
drivers/gpu
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 (direction == READ_LEFT_TO_RIGHT) {
			restart_bit_offset = 8 - bits_per_pixel;
			step_bit_offset = -bits_per_pixel;
		} else {
			restart_bit_offset = 0;
			step_bit_offset = bits_per_pixel;
		}

		while (out_pixel < end) {
			u8 val = ((*src_pixels) >> bit_offset) & mask;

			*out_pixel = argb_u16_from_grayu16((int)val * lum_per_level);

			bit_offset += step_bit_offset;
			if (bit_offset < 0 || 8 <= bit_offset) {
				bit_offset = restart_bit_offset;
				src_pixels += step;
			}
			out_pixel += 1;
		}
	} else if (direction == READ_TOP_TO_BOTTOM || direction == READ_BOTTOM_TO_TOP) {
		while (out_pixel < end) {
			u8 val = (*src_pixels >> bit_offset) & mask;
			*out_pixel = argb_u16_from_grayu16((int)val * lum_per_level);
			src_pixels += step;
			out_pixel += 1;
		}
	}
}

static void R1_read_line(const struct vkms_plane_state *plane, int x_start,
			 int y_start, enum pixel_read_direction direction, int count,
			 struct pixel_argb_u16 out_pixel[])
{
	Rx_read_line(plane, x_start, y_start, direction, count, out_pixel);
}

static void R2_read_line(const struct vkms_plane_state *plane, int x_start,
			 int y_start, enum pixel_read_direction direction, int count,
			 struct pixel_argb_u16 out_pixel[])
{
	Rx_read_line(plane, x_start, y_start, direction, count, out_pixel);
}

static void R4_read_line(const struct vkms_plane_state *plane, int x_start,
			 int y_start, enum pixel_read_direction direction, int count,
			 struct pixel_argb_u16 out_pixel[])
{
	Rx_read_line(plane, x_start, y_start, direction, count, out_pixel);
}


READ_LINE_ARGB8888(XRGB8888_read_line, px, 0xFF, px[2], px[1], px[0])
READ_LINE_ARGB8888(XBGR8888_read_line, px, 0xFF, px[0], px[1], px[2])

READ_LINE_ARGB8888(ARGB8888_read_line, px, px[3], px[2], px[1], px[0])
READ_LINE_ARGB8888(ABGR8888_read_line, px, px[3], px[0], px[1], px[2])
READ_LINE_ARGB8888(RGBA8888_read_line, px, px[0], px[3], px[2], px[1])
READ_LINE_ARGB8888(BGRA8888_read_line, px, px[0], px[1], px[2], px[3])

READ_LINE_ARGB8888(RGB888_read_line, px, 0xFF, px[2], px[1], px[0])
READ_LINE_ARGB8888(BGR888_read_line, px, 0xFF, px[0], px[1], px[2])

READ_LINE_le16161616(ARGB16161616_read_line, px, px[3], px[2], px[1], px[0])
READ_LINE_le16161616(ABGR16161616_read_line, px, px[3], px[0], px[1], px[2])
READ_LINE_le16161616(XRGB16161616_read_line, px, cpu_to_le16(0xFFFF), px[2], px[1], px[0])
READ_LINE_le16161616(XBGR16161616_read_line, px, cpu_to_le16(0xFFFF), px[0], px[1], px[2])

READ_LINE(RGB565_read_line, px, __le16, argb_u16_from_RGB565, px)
READ_LINE(BGR565_read_line, px, __le16, argb_u16_from_BGR565, px)

READ_LINE(R8_read_line, px, u8, argb_u16_from_gray8, *px)

/*
 * This callback can be used for YUV formats where U and V values are
 * stored in the same plane (often called semi-planar formats). It will
 * correctly handle subsampling as described in the drm_format_info of the plane.
 *
 * The conversion matrix stored in the @plane is used to:
 * - Apply the correct color range and encoding
 * - Convert YUV and YVU with the same function (a column swap is needed when setting up
 * plane->conversion_matrix)
 */

/**
 * READ_LINE_YUV_SEMIPLANAR() - Generic generator for a read_line function which can be used for yuv
 * formats with two planes and block_w == block_h == 1.
 *
 * @function_name: Function name to generate
 * @pixel_1_name: temporary pixel name for the first plane used in the @__VA_ARGS__ parameters

Annotation

Implementation Notes