drivers/gpu/drm/panel/panel-chipwealth-ch13726a.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-chipwealth-ch13726a.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-chipwealth-ch13726a.c
Extension
.c
Size
8389 bytes
Lines
334
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 ch13726a_panel {
	struct drm_panel panel;
	struct mipi_dsi_device *dsi;
	struct regulator_bulk_data *supplies;
	struct gpio_desc *reset_gpio;
	struct ch13726a_desc *desc;
	enum drm_panel_orientation orientation;
};

struct ch13726a_desc {
	unsigned int width_mm;
	unsigned int height_mm;
	unsigned int bpc;

	const struct drm_display_mode *modes;
	unsigned int num_modes;
};

static inline struct ch13726a_panel *to_ch13726a_panel(struct drm_panel *panel)
{
	return container_of(panel, struct ch13726a_panel, panel);
}

static void ch13726a_reset(struct ch13726a_panel *ctx)
{
	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
	usleep_range(10000, 11000);
	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
	usleep_range(10000, 11000);
	gpiod_set_value_cansleep(ctx->reset_gpio, 0);
	usleep_range(10000, 11000);
}

static int ch13726a_on(struct ch13726a_panel *ctx)
{
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };

	ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM;

	mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xf0, 0x50);
	mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xb9, 0x00);

	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);

	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);

	return dsi_ctx.accum_err;
}

static int ch13726a_disable(struct drm_panel *panel)
{
	struct ch13726a_panel *ctx = to_ch13726a_panel(panel);
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };

	ctx->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;

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

	return dsi_ctx.accum_err;
}

static int ch13726a_prepare(struct drm_panel *panel)
{
	struct ch13726a_panel *ctx = to_ch13726a_panel(panel);
	struct device *dev = &ctx->dsi->dev;
	int ret;

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

	ch13726a_reset(ctx);

	ret = ch13726a_on(ctx);
	if (ret < 0) {
		dev_err(dev, "Failed to initialize panel: %d\n", ret);
		gpiod_set_value_cansleep(ctx->reset_gpio, 1);
		regulator_bulk_disable(ARRAY_SIZE(ch13726a_supplies), ctx->supplies);
		return ret;
	}

	msleep(28);

	return 0;
}

Annotation

Implementation Notes