drivers/gpu/drm/panel/panel-samsung-s6e8aa5x01-ams561ra01.c

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

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-samsung-s6e8aa5x01-ams561ra01.c
Extension
.c
Size
28890 bytes
Lines
982
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 s6e8aa5x01_ams561ra01_ctx {
	struct drm_panel panel;
	struct mipi_dsi_device *dsi;
	struct backlight_device *bl;
	struct gpio_desc *reset_gpio;
	struct regulator_bulk_data *supplies;
	u32 nr_supplies;
};

static const struct regulator_bulk_data s6e8aa5x01_ams561ra01_supplies[] = {
	{ .supply = "vdd" },
	{ .supply = "vci" },
};

static inline struct s6e8aa5x01_ams561ra01_ctx *to_ctx(struct drm_panel *panel)
{
	return container_of(panel, struct s6e8aa5x01_ams561ra01_ctx, panel);
}

static int s6e8aa5x01_ams561ra01_update_status(struct backlight_device *bl)
{
	struct s6e8aa5x01_ams561ra01_ctx *ctx = bl_get_data(bl);
	struct mipi_dsi_multi_context dsi = { .dsi = ctx->dsi };
	u16 lvl = backlight_get_brightness(bl);

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

	mipi_dsi_dcs_write_seq_multi(&dsi, MCS_ACCESSPROT, 0x5a, 0x5a);

	mipi_dsi_dcs_write_buffer_multi(&dsi,
					s6e8aa5x01_ams561ra01_cmds[lvl].gamma,
					GAMMA_CMD_LEN);
	mipi_dsi_dcs_write_buffer_multi(&dsi,
					s6e8aa5x01_ams561ra01_cmds[lvl].aid,
					AID_CMD_LEN);
	mipi_dsi_dcs_write_seq_multi(&dsi, MCS_GAMMAUPD, 0x03);

	mipi_dsi_dcs_write_seq_multi(&dsi, MCS_ACCESSPROT, 0xa5, 0xa5);

	return dsi.accum_err;
}

static int s6e8aa5x01_ams561ra01_prepare(struct drm_panel *panel)
{
	struct s6e8aa5x01_ams561ra01_ctx *ctx = to_ctx(panel);
	struct device *dev = &ctx->dsi->dev;
	int ret;

	ret = regulator_bulk_enable(ctx->nr_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);

	return 0;
}

static int s6e8aa5x01_ams561ra01_unprepare(struct drm_panel *panel)
{
	struct s6e8aa5x01_ams561ra01_ctx *ctx = to_ctx(panel);

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

	regulator_bulk_disable(ctx->nr_supplies, ctx->supplies);

	return 0;
}

static int s6e8aa5x01_ams561ra01_enable(struct drm_panel *panel)
{
	struct s6e8aa5x01_ams561ra01_ctx *ctx = to_ctx(panel);
	struct mipi_dsi_multi_context dsi = { .dsi = ctx->dsi };

	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi);
	mipi_dsi_msleep(&dsi, 100);

	mipi_dsi_dcs_write_seq_multi(&dsi, MCS_ACCESSPROT, 0x5a, 0x5a);

	mipi_dsi_dcs_write_seq_multi(&dsi, MCS_PENTILE, 0xd8, 0xd8, 0x00);
	mipi_dsi_dcs_write_seq_multi(&dsi, MCS_PCD, 0x5c);
	mipi_dsi_dcs_write_seq_multi(&dsi, MCS_ERRFLAG, 0xed, 0xc7, 0x23, 0x67);

Annotation

Implementation Notes