drivers/gpu/drm/vkms/vkms_composer.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vkms/vkms_composer.c
Extension
.c
Size
23069 bytes
Lines
736
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

switch (colorop_state->curve_1d_type) {
		case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF:
			pixel->r = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->r, LUT_RED);
			pixel->g = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->g, LUT_GREEN);
			pixel->b = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->b, LUT_BLUE);
			break;
		case DRM_COLOROP_1D_CURVE_SRGB_EOTF:
			pixel->r = apply_lut_to_channel_value(&srgb_eotf, pixel->r, LUT_RED);
			pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);
			pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);
			break;
		default:
			drm_WARN_ONCE(dev, true,
				      "unknown colorop 1D curve type %d\n",
				      colorop_state->curve_1d_type);
			break;
		}
	} else if (colorop->type == DRM_COLOROP_CTM_3X4) {
		if (colorop_state->data)
			apply_3x4_matrix(pixel,
					 (struct drm_color_ctm_3x4 *)colorop_state->data->data);
	}
}

static void pre_blend_color_transform(const struct vkms_plane_state *plane_state,
				      struct line_buffer *output_buffer)
{
	struct pixel_argb_s32 pixel;

	for (size_t x = 0; x < output_buffer->n_pixels; x++) {
		struct drm_colorop *colorop = plane_state->base.base.color_pipeline;

		/*
		 * Some operations, such as applying a BT709 encoding matrix,
		 * followed by a decoding matrix, require that we preserve
		 * values above 1.0 and below 0.0 until the end of the pipeline.
		 *
		 * Pack the 16-bit UNORM values into s32 to give us head-room to
		 * avoid clipping until we're at the end of the pipeline. Clip
		 * intentionally at the end of the pipeline before packing
		 * UNORM values back into u16.
		 */
		pixel.a = output_buffer->pixels[x].a;
		pixel.r = output_buffer->pixels[x].r;
		pixel.g = output_buffer->pixels[x].g;
		pixel.b = output_buffer->pixels[x].b;

		while (colorop) {
			struct drm_colorop_state *colorop_state;

			colorop_state = colorop->state;

			if (!colorop_state)
				return;

			if (!colorop_state->bypass)
				apply_colorop(&pixel, colorop);

			colorop = colorop->next;
		}

		/* clamp values */
		output_buffer->pixels[x].a = clamp_val(pixel.a, 0, 0xffff);
		output_buffer->pixels[x].r = clamp_val(pixel.r, 0, 0xffff);
		output_buffer->pixels[x].g = clamp_val(pixel.g, 0, 0xffff);
		output_buffer->pixels[x].b = clamp_val(pixel.b, 0, 0xffff);
	}
}

/**
 * direction_for_rotation() - Get the correct reading direction for a given rotation
 *
 * @rotation: Rotation to analyze. It correspond the field @frame_info.rotation.
 *
 * This function will use the @rotation setting of a source plane to compute the reading
 * direction in this plane which correspond to a "left to right writing" in the CRTC.
 * For example, if the buffer is reflected on X axis, the pixel must be read from right to left
 * to be written from left to right on the CRTC.
 */
static enum pixel_read_direction direction_for_rotation(unsigned int rotation)
{
	struct drm_rect tmp_a, tmp_b;
	int x, y;

	/*
	 * Points A and B are depicted as zero-size rectangles on the CRTC.
	 * The CRTC writing direction is from A to B. The plane reading direction
	 * is discovered by inverse-transforming A and B.
	 * The reading direction is computed by rotating the vector AB (top-left to top-right) in a
	 * 1x1 square.

Annotation

Implementation Notes