// SPDX-License-Identifier: GPL-2.0-only
/*
* Generated with linux-mdss-dsi-panel-driver-generator from vendor device tree.
* Copyright (c) 2024 Luca Weiss <luca.weiss@fairphone.com>
*/
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/regulator/consumer.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>
#include <drm/drm_panel.h>
#include <drm/drm_probe_helper.h>
/* Manufacturer specific DSI commands */
#define HX83112A_SETPOWER1 0 xb1
#define HX83112A_SETDISP 0 xb2
#define HX83112A_SETDRV 0 xb4
#define HX83112A_SETEXTC 0 xb9
#define HX83112A_SETBANK 0 xbd
#define HX83112A_SETPTBA 0 xbf
#define HX83112A_SETDGCLUT 0 xc1
#define HX83112A_SETTCON 0 xc7
#define HX83112A_SETCLOCK 0 xcb
#define HX83112A_SETPANEL 0 xcc
#define HX83112A_SETPOWER2 0 xd2
#define HX83112A_SETGIP0 0 xd3
#define HX83112A_SETGIP1 0 xd5
#define HX83112A_SETGIP2 0 xd6
#define HX83112A_SETGIP3 0 xd8
#define HX83112A_SETTP1 0 xe7
#define HX83112A_UNKNOWN1 0 xe9
struct hx83112a_panel {
struct drm_panel panel;
struct mipi_dsi_device *dsi;
struct regulator_bulk_data supplies[3 ];
struct gpio_desc *reset_gpio;
};
static inline struct hx83112a_panel *to_hx83112a_panel(struct drm_panel *panel)
{
return container_of(panel, struct hx83112a_panel, panel);
}
static void hx83112a_reset(struct hx83112a_panel *ctx)
{
gpiod_set_value_cansleep(ctx->reset_gpio, 0 );
msleep(20 );
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
msleep(20 );
gpiod_set_value_cansleep(ctx->reset_gpio, 0 );
msleep(50 );
}
static int hx83112a_on(struct mipi_dsi_device *dsi)
{
struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
dsi->mode_flags |= MIPI_DSI_MODE_LPM;
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETEXTC, 0 x83, 0 x11, 0 x2a);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETPOWER1,
0 x08, 0 x28, 0 x28, 0 x83, 0 x83, 0 x4c, 0 x4f, 0 x33);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETDISP,
0 x00, 0 x02, 0 x00, 0 x90, 0 x24, 0 x00, 0 x08, 0 x19,
0 xea, 0 x11, 0 x11, 0 x00, 0 x11, 0 xa3);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETDRV,
0 x58, 0 x68, 0 x58, 0 x68, 0 x0f, 0 xef, 0 x0b, 0 xc0,
0 x0b, 0 xc0, 0 x0b, 0 xc0, 0 x00, 0 xff, 0 x00, 0 xff,
0 x00, 0 x00, 0 x14, 0 x15, 0 x00, 0 x29, 0 x11, 0 x07,
0 x12, 0 x00, 0 x29);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x02);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETDRV,
0 x00, 0 x12, 0 x12, 0 x11, 0 x88, 0 x12, 0 x12, 0 x00,
0 x53);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x00);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x03);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETDGCLUT,
0 xff, 0 xfe, 0 xfb, 0 xf8, 0 xf4, 0 xf1, 0 xed, 0 xe6,
0 xe2, 0 xde, 0 xdb, 0 xd6, 0 xd3, 0 xcf, 0 xca, 0 xc6,
0 xc2, 0 xbe, 0 xb9, 0 xb0, 0 xa7, 0 x9e, 0 x96, 0 x8d,
0 x84, 0 x7c, 0 x74, 0 x6b, 0 x62, 0 x5a, 0 x51, 0 x49,
0 x41, 0 x39, 0 x31, 0 x29, 0 x21, 0 x19, 0 x12, 0 x0a,
0 x06, 0 x05, 0 x02, 0 x01, 0 x00, 0 x00, 0 xc9, 0 xb3,
0 x08, 0 x0e, 0 xf2, 0 xe1, 0 x59, 0 xf4, 0 x22, 0 xad,
0 x40);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x02);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETDGCLUT,
0 xff, 0 xfe, 0 xfb, 0 xf8, 0 xf4, 0 xf1, 0 xed, 0 xe6,
0 xe2, 0 xde, 0 xdb, 0 xd6, 0 xd3, 0 xcf, 0 xca, 0 xc6,
0 xc2, 0 xbe, 0 xb9, 0 xb0, 0 xa7, 0 x9e, 0 x96, 0 x8d,
0 x84, 0 x7c, 0 x74, 0 x6b, 0 x62, 0 x5a, 0 x51, 0 x49,
0 x41, 0 x39, 0 x31, 0 x29, 0 x21, 0 x19, 0 x12, 0 x0a,
0 x06, 0 x05, 0 x02, 0 x01, 0 x00, 0 x00, 0 xc9, 0 xb3,
0 x08, 0 x0e, 0 xf2, 0 xe1, 0 x59, 0 xf4, 0 x22, 0 xad,
0 x40);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x01);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETDGCLUT,
0 xff, 0 xfe, 0 xfb, 0 xf8, 0 xf4, 0 xf1, 0 xed, 0 xe6,
0 xe2, 0 xde, 0 xdb, 0 xd6, 0 xd3, 0 xcf, 0 xca, 0 xc6,
0 xc2, 0 xbe, 0 xb9, 0 xb0, 0 xa7, 0 x9e, 0 x96, 0 x8d,
0 x84, 0 x7c, 0 x74, 0 x6b, 0 x62, 0 x5a, 0 x51, 0 x49,
0 x41, 0 x39, 0 x31, 0 x29, 0 x21, 0 x19, 0 x12, 0 x0a,
0 x06, 0 x05, 0 x02, 0 x01, 0 x00, 0 x00, 0 xc9, 0 xb3,
0 x08, 0 x0e, 0 xf2, 0 xe1, 0 x59, 0 xf4, 0 x22, 0 xad,
0 x40);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x00);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETDGCLUT, 0 x01);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETTCON,
0 x70, 0 x00, 0 x04, 0 xe0, 0 x33, 0 x00);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETPANEL, 0 x08);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETPOWER2, 0 x2b, 0 x2b);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP0,
0 x80, 0 x00, 0 x00, 0 x00, 0 x00, 0 x01, 0 x00, 0 x08,
0 x08, 0 x03, 0 x03, 0 x22, 0 x18, 0 x07, 0 x07, 0 x07,
0 x07, 0 x32, 0 x10, 0 x06, 0 x00, 0 x06, 0 x32, 0 x10,
0 x07, 0 x00, 0 x07, 0 x32, 0 x19, 0 x31, 0 x09, 0 x31,
0 x00, 0 x00, 0 x05, 0 x00, 0 x00, 0 x00, 0 x00, 0 x08,
0 x09, 0 x30, 0 x00, 0 x00, 0 x00, 0 x06, 0 x0d, 0 x00,
0 x0f);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x01);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP0,
0 x00, 0 x00, 0 x19, 0 x10, 0 x00, 0 x0a, 0 x00, 0 x81);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x00);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP1,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 xc0, 0 xc0, 0 x18, 0 x18, 0 x19, 0 x19, 0 x18, 0 x18,
0 x40, 0 x40, 0 x18, 0 x18, 0 x18, 0 x18, 0 x3f, 0 x3f,
0 x28, 0 x28, 0 x24, 0 x24, 0 x02, 0 x03, 0 x02, 0 x03,
0 x00, 0 x01, 0 x00, 0 x01, 0 x31, 0 x31, 0 x31, 0 x31,
0 x30, 0 x30, 0 x30, 0 x30, 0 x2f, 0 x2f, 0 x2f, 0 x2f);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP2,
0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18, 0 x18,
0 x40, 0 x40, 0 x18, 0 x18, 0 x18, 0 x18, 0 x19, 0 x19,
0 x40, 0 x40, 0 x18, 0 x18, 0 x18, 0 x18, 0 x3f, 0 x3f,
0 x24, 0 x24, 0 x28, 0 x28, 0 x01, 0 x00, 0 x01, 0 x00,
0 x03, 0 x02, 0 x03, 0 x02, 0 x31, 0 x31, 0 x31, 0 x31,
0 x30, 0 x30, 0 x30, 0 x30, 0 x2f, 0 x2f, 0 x2f, 0 x2f);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP3,
0 xaa, 0 xea, 0 xaa, 0 xaa, 0 xaa, 0 xaa, 0 xaa, 0 xea,
0 xaa, 0 xaa, 0 xaa, 0 xaa, 0 xaa, 0 xea, 0 xab, 0 xaa,
0 xaa, 0 xaa, 0 xaa, 0 xea, 0 xab, 0 xaa, 0 xaa, 0 xaa);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x01);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP3,
0 xaa, 0 x2e, 0 x28, 0 x00, 0 x00, 0 x00, 0 xaa, 0 x2e,
0 x28, 0 x00, 0 x00, 0 x00, 0 xaa, 0 xee, 0 xaa, 0 xaa,
0 xaa, 0 xaa, 0 xaa, 0 xee, 0 xaa, 0 xaa, 0 xaa, 0 xaa);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x02);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP3,
0 xaa, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff, 0 xaa, 0 xff,
0 xff, 0 xff, 0 xff, 0 xff);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x03);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETGIP3,
0 xaa, 0 xaa, 0 xea, 0 xaa, 0 xaa, 0 xaa, 0 xaa, 0 xaa,
0 xea, 0 xaa, 0 xaa, 0 xaa, 0 xaa, 0 xff, 0 xff, 0 xff,
0 xff, 0 xff, 0 xaa, 0 xff, 0 xff, 0 xff, 0 xff, 0 xff);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x00);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETTP1,
0 x0e, 0 x0e, 0 x1e, 0 x65, 0 x1c, 0 x65, 0 x00, 0 x50,
0 x20, 0 x20, 0 x00, 0 x00, 0 x02, 0 x02, 0 x02, 0 x05,
0 x14, 0 x14, 0 x32, 0 xb9, 0 x23, 0 xb9, 0 x08);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x01);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETTP1,
0 x02, 0 x00, 0 xa8, 0 x01, 0 xa8, 0 x0d, 0 xa4, 0 x0e);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x02);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETTP1,
0 x00, 0 x00, 0 x08, 0 x00, 0 x01, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00,
0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x00, 0 x04, 0 x00,
0 x00, 0 x00, 0 x00, 0 x02, 0 x00);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETBANK, 0 x00);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_UNKNOWN1, 0 xc3);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETCLOCK, 0 xd1, 0 xd6);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_UNKNOWN1, 0 x3f);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_UNKNOWN1, 0 xc6);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_SETPTBA, 0 x37);
mipi_dsi_dcs_write_seq_multi(&dsi_ctx, HX83112A_UNKNOWN1, 0 x3f);
mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
mipi_dsi_msleep(&dsi_ctx, 150 );
mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
mipi_dsi_msleep(&dsi_ctx, 50 );
return dsi_ctx.accum_err;
}
static int hx83112a_disable(struct drm_panel *panel)
{
struct hx83112a_panel *ctx = to_hx83112a_panel(panel);
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, 20 );
mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
mipi_dsi_msleep(&dsi_ctx, 120 );
return dsi_ctx.accum_err;
}
static int hx83112a_prepare(struct drm_panel *panel)
{
struct hx83112a_panel *ctx = to_hx83112a_panel(panel);
int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
if (ret < 0 )
return ret;
hx83112a_reset(ctx);
ret = hx83112a_on(ctx->dsi);
if (ret < 0 ) {
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
}
return ret;
}
static int hx83112a_unprepare(struct drm_panel *panel)
{
struct hx83112a_panel *ctx = to_hx83112a_panel(panel);
gpiod_set_value_cansleep(ctx->reset_gpio, 1 );
regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
return 0 ;
}
static const struct drm_display_mode hx83112a_mode = {
.clock = (1080 + 28 + 8 + 8 ) * (2340 + 27 + 5 + 5 ) * 60 / 1000 ,
.hdisplay = 1080 ,
.hsync_start = 1080 + 28 ,
.hsync_end = 1080 + 28 + 8 ,
.htotal = 1080 + 28 + 8 + 8 ,
.vdisplay = 2340 ,
.vsync_start = 2340 + 27 ,
.vsync_end = 2340 + 27 + 5 ,
.vtotal = 2340 + 27 + 5 + 5 ,
.width_mm = 67 ,
.height_mm = 145 ,
.type = DRM_MODE_TYPE_DRIVER,
};
static int hx83112a_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
return drm_connector_helper_get_modes_fixed(connector, &hx83112a_mode);
}
static const struct drm_panel_funcs hx83112a_panel_funcs = {
.prepare = hx83112a_prepare,
.unprepare = hx83112a_unprepare,
.disable = hx83112a_disable,
.get_modes = hx83112a_get_modes,
};
static int hx83112a_probe(struct mipi_dsi_device *dsi)
{
struct device *dev = &dsi->dev;
struct hx83112a_panel *ctx;
int ret;
ctx = devm_drm_panel_alloc(dev, struct hx83112a_panel, panel,
&hx83112a_panel_funcs,
DRM_MODE_CONNECTOR_DSI);
if (IS_ERR(ctx))
return PTR_ERR(ctx);
ctx->supplies[0 ].supply = "vdd1" ;
ctx->supplies[1 ].supply = "vsn" ;
ctx->supplies[2 ].supply = "vsp" ;
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
ctx->supplies);
if (ret < 0 )
return dev_err_probe(dev, ret, "Failed to get regulators\n" );
ctx->reset_gpio = devm_gpiod_get(dev, "reset" , GPIOD_OUT_HIGH);
if (IS_ERR(ctx->reset_gpio))
return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
"Failed to get reset-gpios\n" );
ctx->dsi = dsi;
mipi_dsi_set_drvdata(dsi, ctx);
dsi->lanes = 4 ;
dsi->format = MIPI_DSI_FMT_RGB888;
dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_BURST |
MIPI_DSI_MODE_VIDEO_HSE |
MIPI_DSI_CLOCK_NON_CONTINUOUS;
ctx->panel.prepare_prev_first = true ;
ret = drm_panel_of_backlight(&ctx->panel);
if (ret)
return dev_err_probe(dev, ret, "Failed to get backlight\n" );
drm_panel_add(&ctx->panel);
ret = mipi_dsi_attach(dsi);
if (ret < 0 ) {
dev_err_probe(dev, ret, "Failed to attach to DSI host\n" );
drm_panel_remove(&ctx->panel);
return ret;
}
return 0 ;
}
static void hx83112a_remove(struct mipi_dsi_device *dsi)
{
struct hx83112a_panel *ctx = mipi_dsi_get_drvdata(dsi);
int ret;
ret = mipi_dsi_detach(dsi);
if (ret < 0 )
dev_err(&dsi->dev, "Failed to detach from DSI host: %d\n" , ret);
drm_panel_remove(&ctx->panel);
}
static const struct of_device_id hx83112a_of_match[] = {
{ .compatible = "djn,9a-3r063-1102b" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, hx83112a_of_match);
static struct mipi_dsi_driver hx83112a_driver = {
.probe = hx83112a_probe,
.remove = hx83112a_remove,
.driver = {
.name = "panel-himax-hx83112a" ,
.of_match_table = hx83112a_of_match,
},
};
module_mipi_dsi_driver(hx83112a_driver);
MODULE_DESCRIPTION("DRM driver for hx83112a-equipped DSI panels" );
MODULE_LICENSE("GPL" );
Messung V0.5 in Prozent C=95 H=98 G=96
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland