drivers/gpu/drm/panel/panel-lg-lb035q02.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-lg-lb035q02.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-lg-lb035q02.c
Extension
.c
Size
5447 bytes
Lines
241
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 lb035q02_device {
	struct drm_panel panel;

	struct spi_device *spi;
	struct gpio_desc *enable_gpio;
};

#define to_lb035q02_device(p) container_of(p, struct lb035q02_device, panel)

static int lb035q02_write(struct lb035q02_device *lcd, u16 reg, u16 val)
{
	struct spi_message msg;
	struct spi_transfer index_xfer = {
		.len		= 3,
		.cs_change	= 1,
	};
	struct spi_transfer value_xfer = {
		.len		= 3,
	};
	u8	buffer[16];

	spi_message_init(&msg);

	/* register index */
	buffer[0] = 0x70;
	buffer[1] = 0x00;
	buffer[2] = reg & 0x7f;
	index_xfer.tx_buf = buffer;
	spi_message_add_tail(&index_xfer, &msg);

	/* register value */
	buffer[4] = 0x72;
	buffer[5] = val >> 8;
	buffer[6] = val;
	value_xfer.tx_buf = buffer + 4;
	spi_message_add_tail(&value_xfer, &msg);

	return spi_sync(lcd->spi, &msg);
}

static int lb035q02_init(struct lb035q02_device *lcd)
{
	/* Init sequence from page 28 of the lb035q02 spec. */
	static const struct {
		u16 index;
		u16 value;
	} init_data[] = {
		{ 0x01, 0x6300 },
		{ 0x02, 0x0200 },
		{ 0x03, 0x0177 },
		{ 0x04, 0x04c7 },
		{ 0x05, 0xffc0 },
		{ 0x06, 0xe806 },
		{ 0x0a, 0x4008 },
		{ 0x0b, 0x0000 },
		{ 0x0d, 0x0030 },
		{ 0x0e, 0x2800 },
		{ 0x0f, 0x0000 },
		{ 0x16, 0x9f80 },
		{ 0x17, 0x0a0f },
		{ 0x1e, 0x00c1 },
		{ 0x30, 0x0300 },
		{ 0x31, 0x0007 },
		{ 0x32, 0x0000 },
		{ 0x33, 0x0000 },
		{ 0x34, 0x0707 },
		{ 0x35, 0x0004 },
		{ 0x36, 0x0302 },
		{ 0x37, 0x0202 },
		{ 0x3a, 0x0a0d },
		{ 0x3b, 0x0806 },
	};

	unsigned int i;
	int ret;

	for (i = 0; i < ARRAY_SIZE(init_data); ++i) {
		ret = lb035q02_write(lcd, init_data[i].index,
				     init_data[i].value);
		if (ret < 0)
			return ret;
	}

	return 0;
}

static int lb035q02_disable(struct drm_panel *panel)
{
	struct lb035q02_device *lcd = to_lb035q02_device(panel);

Annotation

Implementation Notes