drivers/gpu/drm/panel/panel-synaptics-tddi.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-synaptics-tddi.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-synaptics-tddi.c
Extension
.c
Size
7346 bytes
Lines
278
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 tddi_panel_data {
	u8 lanes;
	/* wait timings for panel enable */
	u8 delay_ms_sleep_exit;
	u8 delay_ms_display_on;
	/* wait timings for panel disable */
	u8 delay_ms_display_off;
	u8 delay_ms_sleep_enter;
};

struct tddi_ctx {
	struct drm_panel panel;
	struct mipi_dsi_device *dsi;
	struct drm_display_mode mode;
	struct backlight_device *backlight;
	const struct tddi_panel_data *data;
	struct regulator_bulk_data *supplies;
	struct gpio_desc *reset_gpio;
	struct gpio_desc *backlight_gpio;
};

static const struct regulator_bulk_data tddi_supplies[] = {
	{ .supply = "vio" },
	{ .supply = "vsn" },
	{ .supply = "vsp" },
};

static inline struct tddi_ctx *to_tddi_ctx(struct drm_panel *panel)
{
	return container_of(panel, struct tddi_ctx, panel);
}

static int tddi_update_status(struct backlight_device *backlight)
{
	struct tddi_ctx *ctx = bl_get_data(backlight);
	struct mipi_dsi_multi_context dsi = { .dsi = ctx->dsi };
	u8 brightness = backlight_get_brightness(backlight);

	if (!ctx->panel.enabled)
		return 0;

	mipi_dsi_dcs_set_display_brightness_multi(&dsi, brightness);

	return dsi.accum_err;
}

static int tddi_prepare(struct drm_panel *panel)
{
	struct tddi_ctx *ctx = to_tddi_ctx(panel);
	struct device *dev = &ctx->dsi->dev;
	int ret;

	ret = regulator_bulk_enable(ARRAY_SIZE(tddi_supplies), ctx->supplies);
	if (ret < 0) {
		dev_err(dev, "failed to enable regulators: %d\n", ret);
		return ret;
	}

	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
	usleep_range(5000, 6000);
	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
	usleep_range(5000, 6000);
	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
	usleep_range(10000, 11000);

	gpiod_set_value_cansleep(ctx->backlight_gpio, 0);
	usleep_range(5000, 6000);

	return 0;
}

static int tddi_unprepare(struct drm_panel *panel)
{
	struct tddi_ctx *ctx = to_tddi_ctx(panel);

	gpiod_set_value_cansleep(ctx->backlight_gpio, 1);
	usleep_range(5000, 6000);

	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
	usleep_range(5000, 6000);

	regulator_bulk_disable(ARRAY_SIZE(tddi_supplies), ctx->supplies);

	return 0;
}

static int tddi_enable(struct drm_panel *panel)
{
	struct tddi_ctx *ctx = to_tddi_ctx(panel);
	struct mipi_dsi_multi_context dsi = { .dsi = ctx->dsi };

Annotation

Implementation Notes