drivers/gpu/drm/tiny/panel-mipi-dbi.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tiny/panel-mipi-dbi.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/tiny/panel-mipi-dbi.c
Extension
.c
Size
15952 bytes
Lines
566
Domain
Driver Families
Bucket
drivers/gpu
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 panel_mipi_dbi_format {
	const char *name;
	u32 fourcc;
	unsigned int bpp;
};

static const struct panel_mipi_dbi_format panel_mipi_dbi_formats[] = {
	{ "r5g6b5", DRM_FORMAT_RGB565, 16 },
	{ "b6x2g6x2r6x2", DRM_FORMAT_RGB888, 24 },
};

static int panel_mipi_dbi_get_format(struct device *dev, u32 *formats, unsigned int *bpp)
{
	const char *format_name;
	unsigned int i;
	int ret;

	formats[1] = DRM_FORMAT_XRGB8888;

	ret = device_property_read_string(dev, "format", &format_name);
	if (ret) {
		/* Old Device Trees don't have this property */
		formats[0] = DRM_FORMAT_RGB565;
		*bpp = 16;
		return 0;
	}

	for (i = 0; i < ARRAY_SIZE(panel_mipi_dbi_formats); i++) {
		const struct panel_mipi_dbi_format *format = &panel_mipi_dbi_formats[i];

		if (strcmp(format_name, format->name))
			continue;

		formats[0] = format->fourcc;
		*bpp = format->bpp;
		return 0;
	}

	dev_err(dev, "Pixel format is not supported: '%s'\n", format_name);

	return -EINVAL;
}

static const u8 panel_mipi_dbi_magic[15] = { 'M', 'I', 'P', 'I', ' ', 'D', 'B', 'I',
					     0, 0, 0, 0, 0, 0, 0 };

/*
 * The display controller configuration is stored in a firmware file.
 * The Device Tree 'compatible' property value with a '.bin' suffix is passed
 * to request_firmware() to fetch this file.
 */
struct panel_mipi_dbi_config {
	/* Magic string: panel_mipi_dbi_magic */
	u8 magic[15];

	/* Config file format version */
	u8 file_format_version;

	/*
	 * MIPI commands to execute when the display pipeline is enabled.
	 * This is used to configure the display controller.
	 *
	 * The commands are stored in a byte array with the format:
	 *     command, num_parameters, [ parameter, ...], command, ...
	 *
	 * Some commands require a pause before the next command can be received.
	 * Inserting a delay in the command sequence is done by using the NOP command with one
	 * parameter: delay in miliseconds (the No Operation command is part of the MIPI Display
	 * Command Set where it has no parameters).
	 *
	 * Example:
	 *     command 0x11
	 *     sleep 120ms
	 *     command 0xb1 parameters 0x01, 0x2c, 0x2d
	 *     command 0x29
	 *
	 * Byte sequence:
	 *     0x11 0x00
	 *     0x00 0x01 0x78
	 *     0xb1 0x03 0x01 0x2c 0x2d
	 *     0x29 0x00
	 */
	u8 commands[];
};

struct panel_mipi_dbi_commands {
	const u8 *buf;
	size_t len;
};

Annotation

Implementation Notes