Skip to content

Commit 517fe1f

Browse files
authored
Waveshare dsi 2609 (#7)
* drm/panel: panel-waveshare-dsi: Drop auto-detection on 10.1inch DSI LCD (E) The automatic panel detection introduced in a previous merge turned out to be unfriendly for customer use after some hands-on testing. Remove the extra detection and rotation handling and keep only the default landscape configuration. Expose the 10.1inch E panel as explicit 4-lane (60fps) and 2-lane (30fps) variants instead. Signed-off-by: Goodwill <646689853@qq.com> * dts: overlays: vc4-kms-dsi-waveshare-panel: Replace auto_detect with 10.1inch E variants The automatic detection overlay parameter turned out to be unfriendly for customer use. Replace it with explicit 10_1_inchE_4lane and 10_1_inchE_2lane parameters matching the new driver compatible strings, keeping only the default landscape orientation. Signed-off-by: Goodwill <646689853@qq.com> --------- Signed-off-by: Goodwill <646689853@qq.com>
1 parent d9e1735 commit 517fe1f

3 files changed

Lines changed: 34 additions & 110 deletions

File tree

‎arch/arm/boot/dts/overlays/README‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6195,8 +6195,8 @@ Params: 2_8_inch 2.8" 480x640
61956195
11_9_inch 11.9" 320x1480
61966196
13_3_inch_4lane 13.3" 1920x1080 4lane
61976197
13_3_inch_2lane 13.3" 1920x1080 2lane
6198-
auto_detect Automatic panel detection (1200x1920 or
6199-
1920x1200 at 30fps/60fps)
6198+
10_1_inchE_4lane 10.1" E 1920x1200 60fps 4lane
6199+
10_1_inchE_2lane 10.1" E 1920x1200 30fps 2lane
62006200
i2c1 Use i2c-1 with jumper wires from GPIOs 2&3
62016201
disable_touch Disable the touch controller
62026202
rotation Set the panel orientation property

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@
136136
7_0_inchH = <&panel>, "compatible=waveshare,7.0inch-h-panel",
137137
<&touch>, "touchscreen-swapped-x-y?",
138138
<&touch>, "touchscreen-inverted-x?";
139-
auto_detect = <&panel>, "compatible=waveshare,automatic-detection-panel",
139+
10_1_inchE_4lane = <&panel>, "compatible=waveshare,10.1inch-e-4lane-panel",
140+
<&touch>, "touchscreen-swapped-x-y?",
141+
<&touch>, "touchscreen-inverted-x?";
142+
10_1_inchE_2lane = <&panel>, "compatible=waveshare,10.1inch-e-2lane-panel",
140143
<&touch>, "touchscreen-swapped-x-y?",
141144
<&touch>, "touchscreen-inverted-x?";
142145
i2c1 = <&i2c_frag>, "target:0=",<&i2c1>,

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

Lines changed: 28 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ struct ws_panel {
3030
struct i2c_client *i2c;
3131
const struct drm_display_mode *mode;
3232
enum drm_panel_orientation orientation;
33-
int lanes;
3433
};
3534

3635
struct ws_panel_data {
@@ -349,30 +348,6 @@ static const struct ws_panel_data ws_panel_7_0_h_data = {
349348
/* 10.1inch DSI LCD (E)
350349
* https://www.waveshare.com/10.1inch-dsi-lcd-e.htm
351350
*/
352-
static const struct drm_display_mode ws_panel_1200x1920_60fps_mode = {
353-
.clock = 166666,
354-
.hdisplay = 1200,
355-
.hsync_start = 1200 + 28,
356-
.hsync_end = 1200 + 28 + 10,
357-
.htotal = 1200 + 28 + 10 + 30,
358-
.vdisplay = 1920,
359-
.vsync_start = 1920 + 238,
360-
.vsync_end = 1920 + 238 + 4,
361-
.vtotal = 1920 + 238 + 4 + 28,
362-
};
363-
364-
static const struct drm_display_mode ws_panel_1200x1920_30fps_mode = {
365-
.clock = 83333,
366-
.hdisplay = 1200,
367-
.hsync_start = 1200 + 28,
368-
.hsync_end = 1200 + 28 + 10,
369-
.htotal = 1200 + 28 + 10 + 30,
370-
.vdisplay = 1920,
371-
.vsync_start = 1920 + 238,
372-
.vsync_end = 1920 + 238 + 4,
373-
.vtotal = 1920 + 238 + 4 + 28,
374-
};
375-
376351
static const struct drm_display_mode ws_panel_1920x1200_60fps_mode = {
377352
.clock = 166666,
378353
.hdisplay = 1920,
@@ -397,9 +372,15 @@ static const struct drm_display_mode ws_panel_1920x1200_30fps_mode = {
397372
.vtotal = 1200 + 28 + 10 + 30,
398373
};
399374

400-
static const struct ws_panel_data ws_panel_automatic_data = {
401-
.mode = NULL,
402-
.lanes = 0,
375+
static const struct ws_panel_data ws_panel_10_1_e_4lane_data = {
376+
.mode = &ws_panel_1920x1200_60fps_mode,
377+
.lanes = 4,
378+
.mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
379+
};
380+
381+
static const struct ws_panel_data ws_panel_10_1_e_2lane_data = {
382+
.mode = &ws_panel_1920x1200_30fps_mode,
383+
.lanes = 2,
403384
.mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
404385
};
405386

@@ -417,68 +398,6 @@ static void ws_panel_i2c_write(struct ws_panel *ts, u8 reg, u8 val)
417398
dev_err(&ts->i2c->dev, "I2C write failed: %d\n", ret);
418399
}
419400

420-
static int ws_panel_i2c_read(struct ws_panel *ts, u8 reg)
421-
{
422-
int ret;
423-
424-
ret = i2c_smbus_read_byte_data(ts->i2c, reg);
425-
if (ret < 0)
426-
dev_err(&ts->i2c->dev, "read reg 0x%02x failed %d\n", reg, ret);
427-
return ret;
428-
}
429-
430-
static int ws_panel_auto_detect(struct ws_panel *ts)
431-
{
432-
int screen_type;
433-
int rotate;
434-
int fps;
435-
436-
fps = ws_panel_i2c_read(ts, 0xd0);
437-
if (fps < 0)
438-
return fps;
439-
440-
rotate = ws_panel_i2c_read(ts, 0xd1);
441-
if (rotate < 0)
442-
return rotate;
443-
444-
screen_type = ws_panel_i2c_read(ts, 0xd3);
445-
if (screen_type < 0)
446-
return screen_type;
447-
448-
dev_info(&ts->i2c->dev,
449-
"automatic panel detect screen_type=0x%x rotate=0x%x fps=0x%x\n",
450-
screen_type, rotate, fps);
451-
452-
if (screen_type == 0x01) {
453-
switch (rotate) {
454-
case 0:
455-
case 2:
456-
dev_info(&ts->i2c->dev, "select 1200x1920 panel\n");
457-
ts->mode = fps == 60 ?
458-
&ws_panel_1200x1920_60fps_mode :
459-
&ws_panel_1200x1920_30fps_mode;
460-
break;
461-
case 1:
462-
case 3:
463-
dev_info(&ts->i2c->dev, "select 1920x1200 panel\n");
464-
ts->mode = fps == 60 ?
465-
&ws_panel_1920x1200_60fps_mode :
466-
&ws_panel_1920x1200_30fps_mode;
467-
break;
468-
default:
469-
dev_err(&ts->i2c->dev, "unknown rotate value %d\n", rotate);
470-
return -EINVAL;
471-
}
472-
if (fps == 60)
473-
ts->lanes = 4;
474-
else
475-
ts->lanes = 2;
476-
return 0;
477-
}
478-
dev_err(&ts->i2c->dev, "unsupported panel D3=0x%x\n", screen_type);
479-
return -EINVAL;
480-
}
481-
482401
static int ws_panel_disable(struct drm_panel *panel)
483402
{
484403
struct ws_panel *ts = panel_to_ts(panel);
@@ -603,6 +522,8 @@ static int ws_panel_probe(struct i2c_client *i2c)
603522
};
604523
const struct ws_panel_data *_ws_panel_data;
605524
int ret;
525+
bool is_10_1_e_4lane = false;
526+
bool is_10_1_e_2lane = false;
606527

607528
ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
608529
if (!ts)
@@ -612,24 +533,21 @@ static int ws_panel_probe(struct i2c_client *i2c)
612533
if (!_ws_panel_data)
613534
return -EINVAL;
614535

615-
ts->i2c = i2c;
616-
i2c_set_clientdata(i2c, ts);
617-
ts->lanes = _ws_panel_data->lanes;
618-
619-
/* For automatic detection panels, mode is NULL - detect via I2C */
620-
if (!_ws_panel_data->mode) {
621-
ret = ws_panel_auto_detect(ts);
622-
if (ret) {
623-
dev_err(dev, "panel auto detect failed\n");
624-
return ret;
625-
}
626-
} else {
627-
ts->mode = _ws_panel_data->mode;
628-
}
536+
ts->mode = _ws_panel_data->mode;
629537

630538
if (!ts->mode)
631539
return -EINVAL;
632540

541+
i2c_set_clientdata(i2c, ts);
542+
543+
ts->i2c = i2c;
544+
is_10_1_e_4lane = of_device_is_compatible(dev->of_node,
545+
"waveshare,10.1inch-e-4lane-panel");
546+
is_10_1_e_2lane = of_device_is_compatible(dev->of_node,
547+
"waveshare,10.1inch-e-2lane-panel");
548+
if (is_10_1_e_4lane || is_10_1_e_2lane)
549+
ws_panel_i2c_write(ts, 0xd0, is_10_1_e_4lane ? 60 : 30);
550+
633551
ws_panel_i2c_write(ts, 0xc0, 0x01);
634552
ws_panel_i2c_write(ts, 0xc2, 0x01);
635553
ws_panel_i2c_write(ts, 0xac, 0x01);
@@ -686,7 +604,7 @@ static int ws_panel_probe(struct i2c_client *i2c)
686604

687605
ts->dsi->mode_flags = _ws_panel_data->mode_flags;
688606
ts->dsi->format = MIPI_DSI_FMT_RGB888;
689-
ts->dsi->lanes = ts->lanes;
607+
ts->dsi->lanes = _ws_panel_data->lanes;
690608

691609
ret = devm_mipi_dsi_attach(dev, ts->dsi);
692610

@@ -775,8 +693,11 @@ static const struct of_device_id ws_panel_of_ids[] = {
775693
.compatible = "waveshare,7.0inch-h-panel",
776694
.data = &ws_panel_7_0_h_data,
777695
}, {
778-
.compatible = "waveshare,automatic-detection-panel",
779-
.data = &ws_panel_automatic_data,
696+
.compatible = "waveshare,10.1inch-e-4lane-panel",
697+
.data = &ws_panel_10_1_e_4lane_data,
698+
}, {
699+
.compatible = "waveshare,10.1inch-e-2lane-panel",
700+
.data = &ws_panel_10_1_e_2lane_data,
780701
}, {
781702
/* sentinel */
782703
}

0 commit comments

Comments
 (0)