drivers/gpu/drm/panel/panel-samsung-ltl106hl02.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-samsung-ltl106hl02.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-samsung-ltl106hl02.c
Extension
.c
Size
4873 bytes
Lines
180
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 samsung_ltl106hl02 {
	struct drm_panel panel;
	struct mipi_dsi_device *dsi;

	struct regulator *supply;
	struct gpio_desc *reset_gpio;
};

static inline struct samsung_ltl106hl02 *to_samsung_ltl106hl02(struct drm_panel *panel)
{
	return container_of(panel, struct samsung_ltl106hl02, panel);
}

static void samsung_ltl106hl02_reset(struct samsung_ltl106hl02 *ctx)
{
	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
	usleep_range(10000, 11000);
	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
	usleep_range(2000, 3000);
}

static int samsung_ltl106hl02_prepare(struct drm_panel *panel)
{
	struct samsung_ltl106hl02 *ctx = to_samsung_ltl106hl02(panel);
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
	struct device *dev = &ctx->dsi->dev;
	int ret;

	ret = regulator_enable(ctx->supply);
	if (ret < 0) {
		dev_err(dev, "failed to enable power supply %d\n", ret);
		return ret;
	}

	if (ctx->reset_gpio)
		samsung_ltl106hl02_reset(ctx);

	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 70);

	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 5);

	return dsi_ctx.accum_err;
}

static int samsung_ltl106hl02_unprepare(struct drm_panel *panel)
{
	struct samsung_ltl106hl02 *ctx = to_samsung_ltl106hl02(panel);
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };

	mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 50);
	mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 150);

	if (ctx->reset_gpio)
		gpiod_set_value_cansleep(ctx->reset_gpio, 1);

	regulator_disable(ctx->supply);

	return 0;
}

static const struct drm_display_mode samsung_ltl106hl02_mode = {
	.clock = (1920 + 32 + 32 + 64) * (1080 + 6 + 3 + 22) * 60 / 1000,
	.hdisplay = 1920,
	.hsync_start = 1920 + 32,
	.hsync_end = 1920 + 32 + 32,
	.htotal = 1920 + 32 + 32 + 64,
	.vdisplay = 1080,
	.vsync_start = 1080 + 6,
	.vsync_end = 1080 + 6 + 3,
	.vtotal = 1080 + 6 + 3 + 22,
	.width_mm = 235,
	.height_mm = 132,
	.type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
};

static int samsung_ltl106hl02_get_modes(struct drm_panel *panel,
					struct drm_connector *connector)
{
	return drm_connector_helper_get_modes_fixed(connector, &samsung_ltl106hl02_mode);
}

static const struct drm_panel_funcs samsung_ltl106hl02_panel_funcs = {
	.prepare = samsung_ltl106hl02_prepare,
	.unprepare = samsung_ltl106hl02_unprepare,
	.get_modes = samsung_ltl106hl02_get_modes,
};

Annotation

Implementation Notes