Skip to content

Commit 5717aaa

Browse files
authored
Waveshare dsi (#5)
* drm/panel: waveshare: Add automatic panel detection support Add support for Waveshare automatic detection DSI panels which identify themselves at runtime via I2C registers. The driver reads screen type, rotation and refresh rate from registers 0xd0-0xd3 to select the appropriate display mode and DSI lane configuration. Supported configurations include 1200x1920 and 1920x1200 panels at both 30fps (2 lanes) and 60fps (4 lanes) refresh rates. Signed-off-by: Goodwill <646689853@qq.com> * ARM: dts: overlays: waveshare-dsi: Add auto_detect panel option Add the auto_detect overlay parameter to select the automatic detection panel compatible string (waveshare,automatic-detection-panel). This enables runtime panel detection via I2C for Waveshare DSI displays that support automatic identification. Signed-off-by: Goodwill <646689853@qq.com> --------- Signed-off-by: Goodwill <646689853@qq.com>
1 parent 63338cb commit 5717aaa

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

arch/arm/boot/dts/overlays/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6069,7 +6069,7 @@ Params: 2_8_inch 2.8" 480x640
60696069
11_9_inch 11.9" 320x1480
60706070
13_3_inch_4lane 13.3" 1920x1080 4lane
60716071
13_3_inch_2lane 13.3" 1920x1080 2lane
6072-
auto_rec Automatic panel recognition (1200x1920 or
6072+
auto_detect Automatic panel detection (1200x1920 or
60736073
1920x1200 at 30fps/60fps)
60746074
i2c1 Use i2c-1 with jumper wires from GPIOs 2&3
60756075
disable_touch Disable the touch controller

arch/arm/boot/dts/overlays/vc4-kms-dsi-waveshare-panel-overlay.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
7_0_inchH = <&panel>, "compatible=waveshare,7.0inch-h-panel",
137137
<&touch>, "touchscreen-swapped-x-y?",
138138
<&touch>, "touchscreen-inverted-x?";
139-
auto_rec = <&panel>, "compatible=waveshare,automatic-recognition-panel",
139+
auto_detect = <&panel>, "compatible=waveshare,automatic-detection-panel",
140140
<&touch>, "touchscreen-swapped-x-y?",
141141
<&touch>, "touchscreen-inverted-x?";
142142
i2c1 = <&i2c_frag>, "target:0=",<&i2c1>,

drivers/gpu/drm/panel/panel-waveshare-dsi.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,9 @@ static int ws_panel_probe(struct i2c_client *i2c)
615615
ts->i2c = i2c;
616616
i2c_set_clientdata(i2c, ts);
617617
ts->lanes = _ws_panel_data->lanes;
618-
/*
619-
* automatic recognition panel
620-
*/
621-
if (of_device_is_compatible(dev->of_node, "waveshare,automatic-recognition-panel")) {
618+
619+
/* For automatic detection panels, mode is NULL - detect via I2C */
620+
if (!_ws_panel_data->mode) {
622621
ret = ws_panel_auto_detect(ts);
623622
if (ret) {
624623
dev_err(dev, "panel auto detect failed\n");
@@ -701,10 +700,18 @@ static int ws_panel_probe(struct i2c_client *i2c)
701700
return -ENODEV;
702701
}
703702

703+
static void ws_panel_reset(struct drm_panel *panel)
704+
{
705+
struct ws_panel *ts = panel_to_ts(panel);
706+
707+
ws_panel_i2c_write(ts, 0xd2, 0x5a);
708+
}
709+
704710
static void ws_panel_remove(struct i2c_client *i2c)
705711
{
706712
struct ws_panel *ts = i2c_get_clientdata(i2c);
707713

714+
ws_panel_reset(&ts->base);
708715
ws_panel_disable(&ts->base);
709716

710717
drm_panel_remove(&ts->base);
@@ -714,7 +721,7 @@ static void ws_panel_shutdown(struct i2c_client *i2c)
714721
{
715722
struct ws_panel *ts = i2c_get_clientdata(i2c);
716723

717-
ws_panel_i2c_write(ts, 0xd2, 0x5a);
724+
ws_panel_reset(&ts->base);
718725
ws_panel_disable(&ts->base);
719726
}
720727

@@ -768,7 +775,7 @@ static const struct of_device_id ws_panel_of_ids[] = {
768775
.compatible = "waveshare,7.0inch-h-panel",
769776
.data = &ws_panel_7_0_h_data,
770777
}, {
771-
.compatible = "waveshare,automatic-recognition-panel",
778+
.compatible = "waveshare,automatic-detection-panel",
772779
.data = &ws_panel_automatic_data,
773780
}, {
774781
/* sentinel */

0 commit comments

Comments
 (0)