mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-07 18:37:58 -04:00
drm/panel: visionox-rm69299: add plumbing to support panel variants
In order to support a panel variant, add plumbing code to pass init sequence and mode as compatible data. Reviewed-by: Jessica Zhang <quic_jesszhan@quicinc.com> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://lore.kernel.org/r/20250509-topic-misc-shift6-panel-v2-2-c2c2d52abd51@linaro.org
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
@@ -15,11 +16,22 @@
|
||||
#include <drm/drm_modes.h>
|
||||
#include <drm/drm_panel.h>
|
||||
|
||||
struct visionox_rm69299_panel_desc {
|
||||
const struct drm_display_mode *mode;
|
||||
const u8 *init_seq;
|
||||
unsigned int init_seq_len;
|
||||
};
|
||||
|
||||
struct visionox_rm69299 {
|
||||
struct drm_panel panel;
|
||||
struct regulator_bulk_data supplies[2];
|
||||
struct gpio_desc *reset_gpio;
|
||||
struct mipi_dsi_device *dsi;
|
||||
const struct visionox_rm69299_panel_desc *desc;
|
||||
};
|
||||
|
||||
static const u8 visionox_rm69299_1080x2248_60hz_init_seq[][2] = {
|
||||
{ 0xfe, 0x00 }, { 0xc2, 0x08 }, { 0x35, 0x00 }, { 0x51, 0xff },
|
||||
};
|
||||
|
||||
static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel)
|
||||
@@ -84,7 +96,7 @@ static int visionox_rm69299_unprepare(struct drm_panel *panel)
|
||||
static int visionox_rm69299_prepare(struct drm_panel *panel)
|
||||
{
|
||||
struct visionox_rm69299 *ctx = panel_to_ctx(panel);
|
||||
int ret;
|
||||
int ret, i;
|
||||
|
||||
ret = visionox_rm69299_power_on(ctx);
|
||||
if (ret < 0)
|
||||
@@ -92,28 +104,12 @@ static int visionox_rm69299_prepare(struct drm_panel *panel)
|
||||
|
||||
ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM;
|
||||
|
||||
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0xfe, 0x00 }, 2);
|
||||
if (ret < 0) {
|
||||
dev_err(ctx->panel.dev, "cmd set tx 0 failed, ret = %d\n", ret);
|
||||
goto power_off;
|
||||
}
|
||||
|
||||
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0xc2, 0x08 }, 2);
|
||||
if (ret < 0) {
|
||||
dev_err(ctx->panel.dev, "cmd set tx 1 failed, ret = %d\n", ret);
|
||||
goto power_off;
|
||||
}
|
||||
|
||||
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0x35, 0x00 }, 2);
|
||||
if (ret < 0) {
|
||||
dev_err(ctx->panel.dev, "cmd set tx 2 failed, ret = %d\n", ret);
|
||||
goto power_off;
|
||||
}
|
||||
|
||||
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0x51, 0xff }, 2);
|
||||
if (ret < 0) {
|
||||
dev_err(ctx->panel.dev, "cmd set tx 3 failed, ret = %d\n", ret);
|
||||
goto power_off;
|
||||
for (i = 0; i < ctx->desc->init_seq_len; i++) {
|
||||
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, &ctx->desc->init_seq[i * 2], 2);
|
||||
if (ret < 0) {
|
||||
dev_err(ctx->panel.dev, "cmd tx failed, ret = %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0);
|
||||
@@ -160,8 +156,7 @@ static int visionox_rm69299_get_modes(struct drm_panel *panel,
|
||||
struct visionox_rm69299 *ctx = panel_to_ctx(panel);
|
||||
struct drm_display_mode *mode;
|
||||
|
||||
mode = drm_mode_duplicate(connector->dev,
|
||||
&visionox_rm69299_1080x2248_60hz);
|
||||
mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
|
||||
if (!mode) {
|
||||
dev_err(ctx->panel.dev, "failed to create a new display mode\n");
|
||||
return 0;
|
||||
@@ -193,6 +188,10 @@ static int visionox_rm69299_probe(struct mipi_dsi_device *dsi)
|
||||
if (IS_ERR(ctx))
|
||||
return PTR_ERR(ctx);
|
||||
|
||||
ctx->desc = device_get_match_data(dev);
|
||||
if (!ctx->desc)
|
||||
return -EINVAL;
|
||||
|
||||
mipi_dsi_set_drvdata(dsi, ctx);
|
||||
|
||||
ctx->dsi = dsi;
|
||||
@@ -239,8 +238,15 @@ static void visionox_rm69299_remove(struct mipi_dsi_device *dsi)
|
||||
drm_panel_remove(&ctx->panel);
|
||||
}
|
||||
|
||||
const struct visionox_rm69299_panel_desc visionox_rm69299_1080p_display_desc = {
|
||||
.mode = &visionox_rm69299_1080x2248_60hz,
|
||||
.init_seq = (const u8 *)visionox_rm69299_1080x2248_60hz_init_seq,
|
||||
.init_seq_len = ARRAY_SIZE(visionox_rm69299_1080x2248_60hz_init_seq),
|
||||
};
|
||||
|
||||
static const struct of_device_id visionox_rm69299_of_match[] = {
|
||||
{ .compatible = "visionox,rm69299-1080p-display", },
|
||||
{ .compatible = "visionox,rm69299-1080p-display",
|
||||
.data = &visionox_rm69299_1080p_display_desc },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match);
|
||||
|
||||
Reference in New Issue
Block a user