drivers/gpu/drm/panel/panel-sony-td4353-jdi.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
Extension
.c
Size
7137 bytes
Lines
260
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 sony_td4353_jdi {
	struct drm_panel panel;
	struct mipi_dsi_device *dsi;
	struct regulator_bulk_data supplies[3];
	struct gpio_desc *panel_reset_gpio;
	struct gpio_desc *touch_reset_gpio;
	int type;
};

static inline struct sony_td4353_jdi *to_sony_td4353_jdi(struct drm_panel *panel)
{
	return container_of(panel, struct sony_td4353_jdi, panel);
}

static int sony_td4353_jdi_on(struct sony_td4353_jdi *ctx)
{
	struct mipi_dsi_device *dsi = ctx->dsi;
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };

	dsi->mode_flags |= MIPI_DSI_MODE_LPM;

	mipi_dsi_dcs_set_column_address_multi(&dsi_ctx, 0x0000, 1080 - 1);
	mipi_dsi_dcs_set_page_address_multi(&dsi_ctx, 0x0000, 2160 - 1);
	mipi_dsi_dcs_set_tear_scanline_multi(&dsi_ctx, 0);
	mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_SET_ADDRESS_MODE, 0x00);

	mipi_dsi_dcs_set_pixel_format_multi(&dsi_ctx, 0x77);
	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_SET_PARTIAL_ROWS,
				     0x00, 0x00, 0x08, 0x6f);

	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 70);
	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_MEMORY_START);
	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);

	return dsi_ctx.accum_err;
}

static void sony_td4353_jdi_off(struct sony_td4353_jdi *ctx)
{
	struct mipi_dsi_device *dsi = ctx->dsi;
	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };

	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;

	mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 22);
	mipi_dsi_dcs_set_tear_off_multi(&dsi_ctx);
	mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
	mipi_dsi_msleep(&dsi_ctx, 80);
}

static void sony_td4353_assert_reset_gpios(struct sony_td4353_jdi *ctx, int mode)
{
	gpiod_set_value_cansleep(ctx->touch_reset_gpio, mode);
	gpiod_set_value_cansleep(ctx->panel_reset_gpio, mode);
	usleep_range(5000, 5100);
}

static int sony_td4353_jdi_prepare(struct drm_panel *panel)
{
	struct sony_td4353_jdi *ctx = to_sony_td4353_jdi(panel);
	int ret;

	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
	if (ret < 0)
		return ret;

	msleep(100);

	sony_td4353_assert_reset_gpios(ctx, 1);

	ret = sony_td4353_jdi_on(ctx);
	if (ret < 0) {
		sony_td4353_assert_reset_gpios(ctx, 0);
		regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
		return ret;
	}

	return 0;
}

static int sony_td4353_jdi_unprepare(struct drm_panel *panel)
{
	struct sony_td4353_jdi *ctx = to_sony_td4353_jdi(panel);

	sony_td4353_jdi_off(ctx);

	sony_td4353_assert_reset_gpios(ctx, 0);

Annotation

Implementation Notes