drivers/gpu/drm/panel/panel-focaltech-ota7290b.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-focaltech-ota7290b.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-focaltech-ota7290b.c
Extension
.c
Size
5517 bytes
Lines
226
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 ota7290b {
	struct drm_panel panel;
	struct mipi_dsi_device *dsi;

	struct regulator *power;
	struct gpio_desc *reset;
	struct regulator *avdd;
	struct regulator *vdd;
	struct regulator *vcc;

	enum drm_panel_orientation orientation;
};

static inline struct ota7290b *panel_to_ota(struct drm_panel *panel)
{
	return container_of(panel, struct ota7290b, panel);
}

static int ota7290b_prepare(struct drm_panel *panel)
{
	struct ota7290b *ctx = panel_to_ota(panel);
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
	int ret;

	if (ctx->vcc) {
		ret = regulator_enable(ctx->vcc);
		if (ret)
			dev_err(panel->dev, "failed to enable VCC regulator: %d\n", ret);
	}

	if (ctx->reset) {
		gpiod_set_value_cansleep(ctx->reset, 0);
		msleep(60);
		gpiod_set_value_cansleep(ctx->reset, 1);
		msleep(60);
	}

	if (ctx->vdd) {
		ret = regulator_enable(ctx->vdd);
		if (ret)
			dev_err(panel->dev, "failed to enable VDD regulator: %d\n", ret);
	}

	if (ctx->reset) {
		gpiod_set_value_cansleep(ctx->reset, 0);
		msleep(60);
	}

	if (ctx->avdd) {
		ret = regulator_enable(ctx->avdd);
		if (ret)
			dev_err(panel->dev, "failed to enable AVDD regulator: %d\n", ret);
	}

	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 120);
	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 50);

	if (dsi_ctx.accum_err < 0)
		dev_err(panel->dev, "failed to init panel: %d\n", dsi_ctx.accum_err);

	return dsi_ctx.accum_err;
}

static int ota7290b_unprepare(struct drm_panel *panel)
{
	struct ota7290b *ctx = panel_to_ota(panel);
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };

	mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
	mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);

	if (ctx->avdd)
		regulator_disable(ctx->avdd);

	if (ctx->reset) {
		gpiod_set_value_cansleep(ctx->reset, 1);
		msleep(5);
	}

	if (ctx->vdd)
		regulator_disable(ctx->vdd);

	if (ctx->vcc)
		regulator_disable(ctx->vcc);

	return 0;
}

Annotation

Implementation Notes