summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/panel/panel-edp.c
diff options
context:
space:
mode:
authorDouglas Anderson <dianders@chromium.org>2022-01-26 00:54:09 +0300
committerDouglas Anderson <dianders@chromium.org>2022-02-01 19:35:28 +0300
commit363c4c3811db330dee9ce27dd3cee6f590d44e4c (patch)
tree96642790306f34962580a133a9421a91eeb1a002 /drivers/gpu/drm/panel/panel-edp.c
parentb5c84a9edcd418cd055becad6a22439e7c5e3bf8 (diff)
downloadlinux-363c4c3811db330dee9ce27dd3cee6f590d44e4c.tar.xz
drm/panel-edp: Allow querying the detected panel via sysfs
Recently we added generic "edp-panel"s probed by EDID. To support panels in this way we look at the panel ID in the EDID and look up the panel in a table that has power sequence timings. If we find a panel that's not in the table we will still attempt to use it but we'll use conservative timings. While it's likely that these conservative timings will work for most nearly all panels, the performance of turning the panel off and on suffers. We'd like to be able to reliably detect the case that we're using the hardcoded timings without relying on parsing dmesg. This allows us to implement tests that ensure that no devices get shipped that are relying on the conservative timings. Let's add a new sysfs entry to panel devices. It will have one of: * UNKNOWN - We tried to detect a panel but it wasn't in our table. * HARDCODED - We're not using generic "edp-panel" probed by EDID. * A panel name - This is the name of the panel from our table. Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220125135406.1.I62322abf81dbc1a1b72392a093be0c767da9bf51@changeid
Diffstat (limited to 'drivers/gpu/drm/panel/panel-edp.c')
-rw-r--r--drivers/gpu/drm/panel/panel-edp.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c
index a394a15dc3fb..23da4040e263 100644
--- a/drivers/gpu/drm/panel/panel-edp.c
+++ b/drivers/gpu/drm/panel/panel-edp.c
@@ -222,6 +222,8 @@ struct panel_edp {
struct gpio_desc *enable_gpio;
struct gpio_desc *hpd_gpio;
+ const struct edp_panel_entry *detected_panel;
+
struct edid *edid;
struct drm_display_mode override_mode;
@@ -666,7 +668,6 @@ static const struct edp_panel_entry *find_edp_panel(u32 panel_id);
static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel)
{
- const struct edp_panel_entry *edp_panel;
struct panel_desc *desc;
u32 panel_id;
char vend[4];
@@ -705,14 +706,14 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel)
}
drm_edid_decode_panel_id(panel_id, vend, &product_id);
- edp_panel = find_edp_panel(panel_id);
+ panel->detected_panel = find_edp_panel(panel_id);
/*
* We're using non-optimized timings and want it really obvious that
* someone needs to add an entry to the table, so we'll do a WARN_ON
* splat.
*/
- if (WARN_ON(!edp_panel)) {
+ if (WARN_ON(!panel->detected_panel)) {
dev_warn(dev,
"Unknown panel %s %#06x, using conservative timings\n",
vend, product_id);
@@ -734,12 +735,14 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel)
*/
desc->delay.unprepare = 2000;
desc->delay.enable = 200;
+
+ panel->detected_panel = ERR_PTR(-EINVAL);
} else {
dev_info(dev, "Detected %s %s (%#06x)\n",
- vend, edp_panel->name, product_id);
+ vend, panel->detected_panel->name, product_id);
/* Update the delay; everything else comes from EDID */
- desc->delay = *edp_panel->delay;
+ desc->delay = *panel->detected_panel->delay;
}
ret = 0;
@@ -750,6 +753,28 @@ exit:
return ret;
}
+static ssize_t detected_panel_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct panel_edp *p = dev_get_drvdata(dev);
+
+ if (IS_ERR(p->detected_panel))
+ return sysfs_emit(buf, "UNKNOWN\n");
+ else if (!p->detected_panel)
+ return sysfs_emit(buf, "HARDCODED\n");
+ else
+ return sysfs_emit(buf, "%s\n", p->detected_panel->name);
+}
+
+static const DEVICE_ATTR_RO(detected_panel);
+
+static void edp_panel_remove_detected_panel(void *data)
+{
+ struct panel_edp *p = data;
+
+ device_remove_file(p->base.dev, &dev_attr_detected_panel);
+}
+
static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,
struct drm_dp_aux *aux)
{
@@ -849,6 +874,10 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc,
drm_panel_add(&panel->base);
+ err = device_create_file(dev, &dev_attr_detected_panel);
+ if (!err)
+ devm_add_action_or_reset(dev, edp_panel_remove_detected_panel, panel);
+
return 0;
err_finished_pm_runtime: