Skip to content

Commit 273bfdc

Browse files
6by9popcornmix
authored andcommitted
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 8c844aa commit 273bfdc

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

@@ -6010,9 +6104,6 @@ static const struct panel_desc_dsi osd101t2045_53ts = {
60106104
.lanes = 4,
60116105
};
60126106

6013-
// for panels using generic panel-dsi binding
6014-
static struct panel_desc_dsi panel_dsi;
6015-
60166107
static const struct of_device_id dsi_of_match[] = {
60176108
{
60186109
.compatible = "auo,b080uan01",
@@ -6035,139 +6126,27 @@ static const struct of_device_id dsi_of_match[] = {
60356126
}, {
60366127
/* Must be the last entry */
60376128
.compatible = "panel-dsi",
6038-
.data = &panel_dsi,
60396129
}, {
60406130
/* sentinel */
60416131
}
60426132
};
60436133
MODULE_DEVICE_TABLE(of, dsi_of_match);
60446134

6045-
6046-
/* Checks for DSI panel definition in device-tree, analog to panel_dpi */
6047-
static int panel_dsi_dt_probe(struct device *dev,
6048-
struct panel_desc_dsi *desc_dsi)
6049-
{
6050-
struct panel_desc *desc;
6051-
struct display_timing *timing;
6052-
const struct device_node *np;
6053-
const char *dsi_color_format;
6054-
const char *dsi_mode_flags;
6055-
struct property *prop;
6056-
int dsi_lanes, ret;
6057-
6058-
np = dev->of_node;
6059-
6060-
desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL);
6061-
if (!desc)
6062-
return -ENOMEM;
6063-
6064-
timing = devm_kzalloc(dev, sizeof(*timing), GFP_KERNEL);
6065-
if (!timing)
6066-
return -ENOMEM;
6067-
6068-
ret = of_get_display_timing(np, "panel-timing", timing);
6069-
if (ret < 0) {
6070-
dev_err(dev, "%pOF: no panel-timing node found for \"panel-dsi\" binding\n",
6071-
np);
6072-
return ret;
6073-
}
6074-
6075-
desc->timings = timing;
6076-
desc->num_timings = 1;
6077-
6078-
of_property_read_u32(np, "width-mm", &desc->size.width);
6079-
of_property_read_u32(np, "height-mm", &desc->size.height);
6080-
6081-
dsi_lanes = drm_of_get_data_lanes_count_ep(np, 0, 0, 1, 4);
6082-
6083-
if (dsi_lanes < 0) {
6084-
dev_err(dev, "%pOF: no or too many data-lanes defined", np);
6085-
return dsi_lanes;
6086-
}
6087-
6088-
desc_dsi->lanes = dsi_lanes;
6089-
6090-
of_property_read_string(np, "dsi-color-format", &dsi_color_format);
6091-
if (!strcmp(dsi_color_format, "RGB888")) {
6092-
desc_dsi->format = MIPI_DSI_FMT_RGB888;
6093-
desc->bpc = 8;
6094-
} else if (!strcmp(dsi_color_format, "RGB565")) {
6095-
desc_dsi->format = MIPI_DSI_FMT_RGB565;
6096-
desc->bpc = 6;
6097-
} else if (!strcmp(dsi_color_format, "RGB666")) {
6098-
desc_dsi->format = MIPI_DSI_FMT_RGB666;
6099-
desc->bpc = 6;
6100-
} else if (!strcmp(dsi_color_format, "RGB666_PACKED")) {
6101-
desc_dsi->format = MIPI_DSI_FMT_RGB666_PACKED;
6102-
desc->bpc = 6;
6103-
} else {
6104-
dev_err(dev, "%pOF: no valid dsi-color-format defined", np);
6105-
return -EINVAL;
6106-
}
6107-
6108-
6109-
of_property_for_each_string(np, "mode", prop, dsi_mode_flags) {
6110-
if (!strcmp(dsi_mode_flags, "MODE_VIDEO"))
6111-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO;
6112-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_BURST"))
6113-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_BURST;
6114-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_SYNC_PULSE"))
6115-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
6116-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_AUTO_VERT"))
6117-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_AUTO_VERT;
6118-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_HSE"))
6119-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_HSE;
6120-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HFP"))
6121-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HFP;
6122-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HBP"))
6123-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HBP;
6124-
else if (!strcmp(dsi_mode_flags, "MODE_VIDEO_NO_HSA"))
6125-
desc_dsi->flags |= MIPI_DSI_MODE_VIDEO_NO_HSA;
6126-
else if (!strcmp(dsi_mode_flags, "MODE_NO_EOT_PACKET"))
6127-
desc_dsi->flags |= MIPI_DSI_MODE_NO_EOT_PACKET;
6128-
else if (!strcmp(dsi_mode_flags, "CLOCK_NON_CONTINUOUS"))
6129-
desc_dsi->flags |= MIPI_DSI_CLOCK_NON_CONTINUOUS;
6130-
else if (!strcmp(dsi_mode_flags, "MODE_LPM"))
6131-
desc_dsi->flags |= MIPI_DSI_MODE_LPM;
6132-
else if (!strcmp(dsi_mode_flags, "HS_PKT_END_ALIGNED"))
6133-
desc_dsi->flags |= MIPI_DSI_HS_PKT_END_ALIGNED;
6134-
}
6135-
6136-
desc->connector_type = DRM_MODE_CONNECTOR_DSI;
6137-
desc_dsi->desc = *desc;
6138-
6139-
return 0;
6140-
}
6141-
61426135
static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
61436136
{
6144-
const struct panel_desc_dsi *desc;
6137+
const struct panel_desc_dsi *dsi_desc;
61456138
struct panel_simple *panel;
61466139
int err;
61476140

61486141
panel = panel_simple_probe(&dsi->dev);
61496142
if (IS_ERR(panel))
61506143
return PTR_ERR(panel);
61516144

6152-
desc = container_of(panel->desc, struct panel_desc_dsi, desc);
6153-
6154-
if (desc == &panel_dsi) {
6155-
/* Handle the generic panel-dsi binding */
6156-
struct panel_desc_dsi *dt_desc;
6157-
dt_desc = devm_kzalloc(&dsi->dev, sizeof(*dt_desc), GFP_KERNEL);
6158-
if (!dt_desc)
6159-
return -ENOMEM;
6160-
6161-
err = panel_dsi_dt_probe(&dsi->dev, dt_desc);
6162-
if (err < 0)
6163-
return err;
6164-
6165-
desc = dt_desc;
6166-
}
6145+
dsi_desc = container_of(panel->desc, struct panel_desc_dsi, desc);
61676146

6168-
dsi->mode_flags = desc->flags;
6169-
dsi->format = desc->format;
6170-
dsi->lanes = desc->lanes;
6147+
dsi->mode_flags = dsi_desc->flags;
6148+
dsi->format = dsi_desc->format;
6149+
dsi->lanes = dsi_desc->lanes;
61716150

61726151
err = mipi_dsi_attach(dsi);
61736152
if (err) {

0 commit comments

Comments
 (0)