drivers/gpu/drm/panel/panel-lxd-m9189a.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-lxd-m9189a.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-lxd-m9189a.c
Extension
.c
Size
6354 bytes
Lines
245
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 m9189_panel {
	struct drm_panel panel;
	struct mipi_dsi_device *dsi;
	struct regulator *supply;
	struct gpio_desc *reset_gpio;
	struct gpio_desc *standby_gpio;
};

static inline struct m9189_panel *to_m9189_panel(struct drm_panel *panel)
{
	return container_of(panel, struct m9189_panel, panel);
}

static void m9189_reset(struct m9189_panel *m9189)
{
	gpiod_set_value_cansleep(m9189->reset_gpio, 0);
	msleep(20);
	gpiod_set_value_cansleep(m9189->reset_gpio, 1);
	msleep(30);
	gpiod_set_value_cansleep(m9189->reset_gpio, 0);
	msleep(55);
}

static int m9189_on(struct m9189_panel *m9189)
{
	struct mipi_dsi_multi_context ctx = { .dsi = m9189->dsi };

	ctx.dsi->mode_flags |= MIPI_DSI_MODE_LPM;

	/* Gamma 2.2 */
	mipi_dsi_dcs_write_seq_multi(&ctx, EK79007AD3_GAMMA1, 0x48);
	mipi_dsi_dcs_write_seq_multi(&ctx, EK79007AD3_GAMMA2, 0xB8);
	mipi_dsi_dcs_write_seq_multi(&ctx, EK79007AD3_GAMMA3, 0x88);
	mipi_dsi_dcs_write_seq_multi(&ctx, EK79007AD3_GAMMA4, 0x88);
	mipi_dsi_dcs_write_seq_multi(&ctx, EK79007AD3_GAMMA5, 0x58);
	mipi_dsi_dcs_write_seq_multi(&ctx, EK79007AD3_GAMMA6, 0xD2);
	mipi_dsi_dcs_write_seq_multi(&ctx, EK79007AD3_GAMMA7, 0x88);
	mipi_dsi_msleep(&ctx, 50);

	/* 4 Lanes */
	mipi_dsi_generic_write_multi(&ctx, (u8[]){ EK79007AD3_PANEL_CTRL3, 0x70 }, 2);

	mipi_dsi_dcs_exit_sleep_mode_multi(&ctx);
	mipi_dsi_msleep(&ctx, 120);

	mipi_dsi_dcs_set_display_on_multi(&ctx);
	mipi_dsi_msleep(&ctx, 120);

	return ctx.accum_err;
}

static int m9189_disable(struct drm_panel *panel)
{
	struct m9189_panel *m9189 = to_m9189_panel(panel);
	struct mipi_dsi_multi_context ctx = { .dsi = m9189->dsi };

	ctx.dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;

	mipi_dsi_dcs_enter_sleep_mode_multi(&ctx);
	mipi_dsi_msleep(&ctx, 120);

	gpiod_set_value_cansleep(m9189->standby_gpio, 1);

	return ctx.accum_err;
}

static int m9189_prepare(struct drm_panel *panel)
{
	struct m9189_panel *m9189 = to_m9189_panel(panel);
	struct device *dev = &m9189->dsi->dev;
	int ret;

	ret = regulator_enable(m9189->supply);
	if (ret < 0) {
		dev_err(dev, "Failed to enable regulators: %d\n", ret);
		return ret;
	}

	gpiod_set_value_cansleep(m9189->standby_gpio, 0);
	msleep(20);
	m9189_reset(m9189);

	ret = m9189_on(m9189);
	if (ret < 0) {
		dev_err(dev, "Failed to initialize panel: %d\n", ret);
		gpiod_set_value_cansleep(m9189->reset_gpio, 1);
		regulator_disable(m9189->supply);
		return ret;
	}

Annotation

Implementation Notes