Skip to content

Commit d69c6e4

Browse files
committed
drm/panel-simple: Fix handling of panel-dsi
There was a significant rework of the handling of panel-dpi with 6.16. panel-dsi was partially derived from panel-dpi, but wasn't fully fixed to handle this rework. Update panel-dsi so that it works correctly. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 01f7332 commit d69c6e4

1 file changed

Lines changed: 102 additions & 123 deletions

File tree

drivers/gpu/drm/panel/panel-simple.c

Lines changed: 102 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,90 @@ static struct panel_desc *panel_dpi_probe(struct device *dev)
469469
return desc;
470470
}
471471

472+
static struct panel_desc *panel_dsi_probe(struct device *dev)
473+
{
474+
const struct device_node *np = dev->of_node;
475+
struct panel_desc_dsi *desc_dsi;
476+
struct panel_desc *desc;
477+
const char *dsi_color_format;
478+
const char *dsi_mode_flags;
479+
struct property *prop;
480+
int dsi_lanes;
481+
482+
desc = panel_dpi_probe(dev);
483+
if (IS_ERR(desc)) {
484+
pr_err("Failed panel_dpi_probe\n");
485+
return desc;
486+
}
487+
488+
desc->connector_type = DRM_MODE_CONNECTOR_DSI;
489+
490+
desc_dsi = devm_kzalloc(dev, sizeof(*desc_dsi), GFP_KERNEL);
491+
if (!desc_dsi)
492+
return ERR_PTR(-ENOMEM);
493+
494+
desc_dsi->desc = *desc;
495+
devm_kfree(dev, desc);
496+
497+
desc = &desc_dsi->desc;
498+
499+
dsi_lanes = drm_of_get_data_lanes_count_ep(np, 0, 0, 1, 4);
500+
501+
if (dsi_lanes < 0) {
502+
dev_err(dev, "%pOF: no or too many data-lanes defined", np);
503+
return ERR_PTR(dsi_lanes);
504+
}
505+
506+
desc_dsi->lanes = dsi_lanes;
507+
508+
of_property_read_string(np, "dsi-color-format", &dsi_color_format);
509+
if (!strcmp(dsi_color_format, "RGB888")) {
510+
desc_dsi->format = MIPI_DSI_FMT_RGB888;
511+
desc_dsi->desc.bpc = 8;
512+
} else if (!strcmp(dsi_color_format, "RGB565")) {
513+
desc_dsi->format = MIPI_DSI_FMT_RGB565;
514+
desc_dsi->desc.bpc = 6;
515+
} else if (!strcmp(dsi_color_format, "RGB666")) {
516+
desc_dsi->format = MIPI_DSI_FMT_RGB666;
517+
desc_dsi->desc.bpc = 6;
518+
} else if (!strcmp(dsi_color_format, "RGB666_PACKED")) {
519+
desc_dsi->format = MIPI_DSI_FMT_RGB666_PACKED;
520+
desc_dsi->desc.bpc = 6;
521+
} else {
522+
dev_err(dev, "%pOF: no valid dsi-color-format defined", np);
523+
return ERR_PTR(-EINVAL);
524+
}
525+
526+
of_property_for_each_string(np, "mode", prop, dsi_mode_flags) {
527+
if (!strcmp(dsi_mode_flags, "MODE_VIDEO"))
528+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO;
529+
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_BURST"))
530+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_BURST;
531+
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_SYNC_PULSE"))
532+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
533+
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_AUTO_VERT"))
534+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_AUTO_VERT;
535+
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_HSE"))
536+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_HSE;
537+
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HFP"))
538+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HFP;
539+
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HBP"))
540+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HBP;
541+
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HSA"))
542+
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HSA;
543+
else if (!strcmp(dsi_mode_flags, "MODE_NO_EOT_PACKET"))
544+
desc_dsi->flags |= MIPI_DSI_MODE_NO_EOT_PACKET;
545+
else if (!strcmp(dsi_mode_flags, "CLOCK_NON_CONTINUOUS"))
546+
desc_dsi->flags |= MIPI_DSI_CLOCK_NON_CONTINUOUS;
547+
else if (!strcmp(dsi_mode_flags, "MODE_LPM"))
548+
desc_dsi->flags |= MIPI_DSI_MODE_LPM;
549+
else if (!strcmp(dsi_mode_flags, "HS_PKT_END_ALIGNED"))
550+
desc_dsi->flags |= MIPI_DSI_HS_PKT_END_ALIGNED;
551+
}
552+
553+
return &desc_dsi->desc;
554+
}
555+
472556
#define PANEL_SIMPLE_BOUNDS_CHECK(to_check, bounds, field) \
473557
(to_check->field.typ >= bounds->field.min && \
474558
to_check->field.typ <= bounds->field.max)
@@ -568,8 +652,17 @@ static const struct panel_desc *panel_simple_get_desc(struct device *dev)
568652
const struct panel_desc_dsi *dsi_desc;
569653

570654
dsi_desc = of_device_get_match_data(dev);
571-
if (!dsi_desc)
572-
return ERR_PTR(-ENODEV);
655+
if (!dsi_desc) {
656+
/*
657+
* panel-dsi probes without a descriptor and
658+
* panel_dsi_probe() will initialize one for us
659+
* based on the device tree.
660+
*/
661+
if (of_device_is_compatible(dev->of_node, "panel-dsi"))
662+
return panel_dsi_probe(dev);
663+
else
664+
return ERR_PTR(-ENODEV);
665+
}
573666

574667
return &dsi_desc->desc;
575668
}
@@ -689,7 +782,8 @@ static struct panel_simple *panel_simple_probe(struct device *dev)
689782
return ERR_PTR(-EPROBE_DEFER);
690783
}
691784

692-
if (!of_device_is_compatible(dev->of_node, "panel-dpi") &&
785+
if (!(of_device_is_compatible(dev->of_node, "panel-dpi") ||
786+
of_device_is_compatible(dev->of_node, "panel-dsi")) &&
693787
!of_get_display_timing(dev->of_node, "panel-timing", &dt))
694788
panel_simple_parse_panel_timing_node(dev, panel, &dt);
695789

@@ -5782,9 +5876,6 @@ static const struct panel_desc_dsi osd101t2045_53ts = {
57825876
.lanes = 4,
57835877
};
57845878

5785-
// for panels using generic panel-dsi binding
5786-
static struct panel_desc_dsi panel_dsi;
5787-
57885879
static const struct of_device_id dsi_of_match[] = {
57895880
{
57905881
.compatible = "auo,b080uan01",
@@ -5810,139 +5901,27 @@ static const struct of_device_id dsi_of_match[] = {
58105901
}, {
58115902
/* Must be the last entry */
58125903
.compatible = "panel-dsi",
5813-
.data = &panel_dsi,
58145904
}, {
58155905
/* sentinel */
58165906
}
58175907
};
58185908
MODULE_DEVICE_TABLE(of, dsi_of_match);
58195909

5820-
5821-
/* Checks for DSI panel definition in device-tree, analog to panel_dpi */
5822-
static int panel_dsi_dt_probe(struct device *dev,
5823-
struct panel_desc_dsi *desc_dsi)
5824-
{
5825-
struct panel_desc *desc;
5826-
struct display_timing *timing;
5827-
const struct device_node *np;
5828-
const char *dsi_color_format;
5829-
const char *dsi_mode_flags;
5830-
struct property *prop;
5831-
int dsi_lanes, ret;
5832-
5833-
np = dev->of_node;
5834-
5835-
desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
5836-
if (!desc)
5837-
return -ENOMEM;
5838-
5839-
timing = devm_kzalloc(dev, sizeof(*timing), GFP_KERNEL);
5840-
if (!timing)
5841-
return -ENOMEM;
5842-
5843-
ret = of_get_display_timing(np, "panel-timing", timing);
5844-
if (ret < 0) {
5845-
dev_err(dev, "%pOF: no panel-timing node found for \"panel-dsi\" binding\n",
5846-
np);
5847-
return ret;
5848-
}
5849-
5850-
desc->timings = timing;
5851-
desc->num_timings = 1;
5852-
5853-
of_property_read_u32(np, "width-mm", &desc->size.width);
5854-
of_property_read_u32(np, "height-mm", &desc->size.height);
5855-
5856-
dsi_lanes = drm_of_get_data_lanes_count_ep(np, 0, 0, 1, 4);
5857-
5858-
if (dsi_lanes < 0) {
5859-
dev_err(dev, "%pOF: no or too many data-lanes defined", np);
5860-
return dsi_lanes;
5861-
}
5862-
5863-
desc_dsi->lanes = dsi_lanes;
5864-
5865-
of_property_read_string(np, "dsi-color-format", &dsi_color_format);
5866-
if (!strcmp(dsi_color_format, "RGB888")) {
5867-
desc_dsi->format = MIPI_DSI_FMT_RGB888;
5868-
desc->bpc = 8;
5869-
} else if (!strcmp(dsi_color_format, "RGB565")) {
5870-
desc_dsi->format = MIPI_DSI_FMT_RGB565;
5871-
desc->bpc = 6;
5872-
} else if (!strcmp(dsi_color_format, "RGB666")) {
5873-
desc_dsi->format = MIPI_DSI_FMT_RGB666;
5874-
desc->bpc = 6;
5875-
} else if (!strcmp(dsi_color_format, "RGB666_PACKED")) {
5876-
desc_dsi->format = MIPI_DSI_FMT_RGB666_PACKED;
5877-
desc->bpc = 6;
5878-
} else {
5879-
dev_err(dev, "%pOF: no valid dsi-color-format defined", np);
5880-
return -EINVAL;
5881-
}
5882-
5883-
5884-
of_property_for_each_string(np, "mode", prop, dsi_mode_flags) {
5885-
if (!strcmp(dsi_mode_flags, "MODE_VIDEO"))
5886-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO;
5887-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_BURST"))
5888-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_BURST;
5889-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_SYNC_PULSE"))
5890-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
5891-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_AUTO_VERT"))
5892-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_AUTO_VERT;
5893-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_HSE"))
5894-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_HSE;
5895-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HFP"))
5896-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HFP;
5897-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HBP"))
5898-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HBP;
5899-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HSA"))
5900-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HSA;
5901-
else if (!strcmp(dsi_mode_flags, "MODE_NO_EOT_PACKET"))
5902-
desc_dsi->flags |= MIPI_DSI_MODE_NO_EOT_PACKET;
5903-
else if (!strcmp(dsi_mode_flags, "CLOCK_NON_CONTINUOUS"))
5904-
desc_dsi->flags |= MIPI_DSI_CLOCK_NON_CONTINUOUS;
5905-
else if (!strcmp(dsi_mode_flags, "MODE_LPM"))
5906-
desc_dsi->flags |= MIPI_DSI_MODE_LPM;
5907-
else if (!strcmp(dsi_mode_flags, "HS_PKT_END_ALIGNED"))
5908-
desc_dsi->flags |= MIPI_DSI_HS_PKT_END_ALIGNED;
5909-
}
5910-
5911-
desc->connector_type = DRM_MODE_CONNECTOR_DSI;
5912-
desc_dsi->desc = *desc;
5913-
5914-
return 0;
5915-
}
5916-
59175910
static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
59185911
{
5919-
const struct panel_desc_dsi *desc;
5912+
const struct panel_desc_dsi *dsi_desc;
59205913
struct panel_simple *panel;
59215914
int err;
59225915

59235916
panel = panel_simple_probe(&dsi->dev);
59245917
if (IS_ERR(panel))
59255918
return PTR_ERR(panel);
59265919

5927-
desc = container_of(panel->desc, struct panel_desc_dsi, desc);
5928-
5929-
if (desc == &panel_dsi) {
5930-
/* Handle the generic panel-dsi binding */
5931-
struct panel_desc_dsi *dt_desc;
5932-
dt_desc = devm_kzalloc(&dsi->dev, sizeof(*dt_desc), GFP_KERNEL);
5933-
if (!dt_desc)
5934-
return -ENOMEM;
5935-
5936-
err = panel_dsi_dt_probe(&dsi->dev, dt_desc);
5937-
if (err < 0)
5938-
return err;
5939-
5940-
desc = dt_desc;
5941-
}
5920+
dsi_desc = container_of(panel->desc, struct panel_desc_dsi, desc);
59425921

5943-
dsi->mode_flags = desc->flags;
5944-
dsi->format = desc->format;
5945-
dsi->lanes = desc->lanes;
5922+
dsi->mode_flags = dsi_desc->flags;
5923+
dsi->format = dsi_desc->format;
5924+
dsi->lanes = dsi_desc->lanes;
59465925

59475926
err = mipi_dsi_attach(dsi);
59485927
if (err) {

0 commit comments

Comments
 (0)