drivers/gpu/drm/panel/panel-novatek-nt35950.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panel/panel-novatek-nt35950.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/panel/panel-novatek-nt35950.c
Extension
.c
Size
16409 bytes
Lines
609
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 nt35950 {
	struct drm_panel panel;
	struct drm_connector *connector;
	struct mipi_dsi_device *dsi[2];
	struct regulator_bulk_data vregs[NT35950_VREG_MAX];
	struct gpio_desc *reset_gpio;
	const struct nt35950_panel_desc *desc;

	int cur_mode;
	u8 last_page;
};

struct nt35950_panel_mode {
	const struct drm_display_mode mode;

	bool enable_sram;
	bool is_video_mode;
	u8 scaler_on;
	u8 scaler_mode;
	u8 compression;
	u8 spr_en;
	u8 spr_mode;
};

struct nt35950_panel_desc {
	const char *model_name;
	const struct mipi_dsi_device_info dsi_info;
	const struct nt35950_panel_mode *mode_data;

	bool is_dual_dsi;
	u8 num_lanes;
	u8 num_modes;
};

static inline struct nt35950 *to_nt35950(struct drm_panel *panel)
{
	return container_of(panel, struct nt35950, panel);
}

static void nt35950_reset(struct nt35950 *nt)
{
	gpiod_set_value_cansleep(nt->reset_gpio, 1);
	usleep_range(12000, 13000);
	gpiod_set_value_cansleep(nt->reset_gpio, 0);
	usleep_range(300, 400);
	gpiod_set_value_cansleep(nt->reset_gpio, 1);
	usleep_range(12000, 13000);
}

/*
 * nt35950_set_cmd2_page - Select manufacturer control (CMD2) page
 * @dsi_ctx: context for mipi_dsi functions
 * @nt:   Main driver structure
 * @page: Page number (0-7)
 */
static void nt35950_set_cmd2_page(struct mipi_dsi_multi_context *dsi_ctx,
				  struct nt35950 *nt, u8 page)
{
	const u8 mauc_cmd2_page[] = { MCS_CMD_MAUCCTR, 0x55, 0xaa, 0x52,
				      0x08, page };

	mipi_dsi_dcs_write_buffer_multi(dsi_ctx, mauc_cmd2_page,
					ARRAY_SIZE(mauc_cmd2_page));
	if (!dsi_ctx->accum_err)
		nt->last_page = page;
}

/*
 * nt35950_set_data_compression - Set data compression mode
 * @dsi_ctx: context for mipi_dsi functions
 * @nt:        Main driver structure
 * @comp_mode: Compression mode
 */
static void nt35950_set_data_compression(struct mipi_dsi_multi_context *dsi_ctx,
					 struct nt35950 *nt, u8 comp_mode)
{
	u8 cmd_data_compression[] = { MCS_PARAM_DATA_COMPRESSION, comp_mode };
	u8 cmd_vesa_dsc_on[] = { MCS_PARAM_VESA_DSC_ON, !!comp_mode };
	u8 cmd_vesa_dsc_setting[] = { MCS_PARAM_VESA_DSC_SETTING, 0x03 };
	u8 last_page = nt->last_page;

	/* Set CMD2 Page 0 if we're not there yet */
	if (last_page != 0)
		nt35950_set_cmd2_page(dsi_ctx, nt, 0);

	mipi_dsi_dcs_write_buffer_multi(dsi_ctx, cmd_data_compression,
					ARRAY_SIZE(cmd_data_compression));
	mipi_dsi_dcs_write_buffer_multi(dsi_ctx, cmd_vesa_dsc_on,
					ARRAY_SIZE(cmd_vesa_dsc_on));

Annotation

Implementation Notes