drivers/gpu/drm/panel/panel-abt-y030xx067a.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-abt-y030xx067a.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-abt-y030xx067a.c
Extension
.c
Size
9995 bytes
Lines
384
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 y030xx067a_info {
	const struct drm_display_mode *display_modes;
	unsigned int num_modes;
	u16 width_mm, height_mm;
	u32 bus_format, bus_flags;
};

struct y030xx067a {
	struct drm_panel panel;
	struct spi_device *spi;
	struct regmap *map;

	const struct y030xx067a_info *panel_info;

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

static inline struct y030xx067a *to_y030xx067a(struct drm_panel *panel)
{
	return container_of(panel, struct y030xx067a, panel);
}

static const struct reg_sequence y030xx067a_init_sequence[] = {
	{ 0x00, REG00_VBRT_CTRL(0x7f) },
	{ 0x01, REG01_COM_DC(0x3c) },
	{ 0x02, REG02_VESA_SEL(0x3) | REG02_DA_CONTRAST(0x1f) },
	{ 0x03, REG03_VPOSITION(0x0a) },
	{ 0x04, REG04_HPOSITION1(0xd2) },
	{ 0x05, REG05_CLIP | REG05_NVM_VREFRESH | REG05_SLBRCHARGE(0x2) },
	{ 0x06, REG06_NT },
	{ 0x07, 0 },
	{ 0x08, REG08_PANEL(0x1) | REG08_CLOCK_DIV(0x2) },
	{ 0x09, REG09_SUB_BRIGHT_R(0x20) },
	{ 0x0a, REG0A_SUB_BRIGHT_B(0x20) },
	{ 0x0b, REG0B_HD_FREERUN | REG0B_VD_FREERUN },
	{ 0x0c, REG0C_CONTRAST_R(0x00) },
	{ 0x0d, REG0D_CONTRAST_G(0x00) },
	{ 0x0e, REG0E_CONTRAST_B(0x10) },
	{ 0x0f, 0 },
	{ 0x10, REG10_BRIGHT(0x7f) },
	{ 0x11, REG11_SIGC_CNTL | REG11_SIG_GAIN(0x3f) },
	{ 0x12, REG12_COLOR(0x20) | REG12_PWCKSEL(0x1) },
	{ 0x13, REG13_4096LEVEL_CNTL(0x8) },
	{ 0x14, 0 },
	{ 0x15, 0 },
};

static int y030xx067a_prepare(struct drm_panel *panel)
{
	struct y030xx067a *priv = to_y030xx067a(panel);
	struct device *dev = &priv->spi->dev;
	int err;

	err = regulator_enable(priv->supply);
	if (err) {
		dev_err(dev, "Failed to enable power supply: %d\n", err);
		return err;
	}

	/* Reset the chip */
	gpiod_set_value_cansleep(priv->reset_gpio, 1);
	usleep_range(1000, 20000);
	gpiod_set_value_cansleep(priv->reset_gpio, 0);
	usleep_range(1000, 20000);

	err = regmap_multi_reg_write(priv->map, y030xx067a_init_sequence,
				     ARRAY_SIZE(y030xx067a_init_sequence));
	if (err) {
		dev_err(dev, "Failed to init registers: %d\n", err);
		goto err_disable_regulator;
	}

	return 0;

err_disable_regulator:
	regulator_disable(priv->supply);
	return err;
}

static int y030xx067a_unprepare(struct drm_panel *panel)
{
	struct y030xx067a *priv = to_y030xx067a(panel);

	gpiod_set_value_cansleep(priv->reset_gpio, 1);
	regulator_disable(priv->supply);

	return 0;
}

Annotation

Implementation Notes