Hello!
This series adds support for display panel's DT rotation property. It's a continuation of the work that was initially started by Derek Basehore for the panel driver that is used by some Mediatek device [1]. I picked up the Derek's patches and added my t-b and r-b tags to them, I also added rotation support to the panel-lvds and panel-simple drivers.
We need the rotation support for the Nexus 7 tablet device which is pending to become supported by upstream kernel, the device has display panel mounted upside-down and it uses panel-lvds [2].
[1] https://lkml.org/lkml/2020/3/5/1119 [2] https://patchwork.ozlabs.org/project/linux-tegra/patch/20200607154327.18589-...
Changelog:
v11: - This series is factored out from this patchset [3] because these patches do not have hard dependency on the Tegra DRM patches and it should be nicer to review and apply the properly grouped patches.
- Initially [3] only touched the panel-lvds driver and Emil Velikov suggested that it will be better to support more panels in the review comments to [3]. So I included the Derek's patch for the BOE panel and added rotation support to the panel-simple driver. I tested that panel-lvds and panel-simple work properly with the rotated panel using the Opentegra Xorg driver [4] and Wayland Weston [5].
- The panel-lvds driver now prints a error message if rotation property fails to be parsed.
[3] https://lore.kernel.org/lkml/20200614200121.14147-1-digetx@gmail.com/ [4] https://github.com/grate-driver/xf86-video-opentegra/commit/28eb20a3959bbe5b... [5] https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/315
Derek Basehore (2): drm/panel: Add helper for reading DT rotation drm/panel: Read panel orientation for BOE TV101WUM-NL6
Dmitry Osipenko (2): drm/panel: lvds: Read panel orientation drm/panel-simple: Read panel orientation
drivers/gpu/drm/drm_panel.c | 43 +++++++++++++++++++ .../gpu/drm/panel/panel-boe-tv101wum-nl6.c | 6 +++ drivers/gpu/drm/panel/panel-lvds.c | 10 +++++ drivers/gpu/drm/panel/panel-simple.c | 11 +++++ include/drm/drm_panel.h | 9 ++++ 5 files changed, 79 insertions(+)
From: Derek Basehore dbasehore@chromium.org
This adds a helper function for reading the rotation (panel orientation) from the device tree.
Signed-off-by: Derek Basehore dbasehore@chromium.org Reviewed-by: Sam Ravnborg sam@ravnborg.org --- drivers/gpu/drm/drm_panel.c | 43 +++++++++++++++++++++++++++++++++++++ include/drm/drm_panel.h | 9 ++++++++ 2 files changed, 52 insertions(+)
diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c index 8c7bac85a793..5557c75301f1 100644 --- a/drivers/gpu/drm/drm_panel.c +++ b/drivers/gpu/drm/drm_panel.c @@ -300,6 +300,49 @@ struct drm_panel *of_drm_find_panel(const struct device_node *np) return ERR_PTR(-EPROBE_DEFER); } EXPORT_SYMBOL(of_drm_find_panel); + +/** + * of_drm_get_panel_orientation - look up the orientation of the panel through + * the "rotation" binding from a device tree node + * @np: device tree node of the panel + * @orientation: orientation enum to be filled in + * + * Looks up the rotation of a panel in the device tree. The orientation of the + * panel is expressed as a property name "rotation" in the device tree. The + * rotation in the device tree is counter clockwise. + * + * Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the + * rotation property doesn't exist. -EERROR otherwise. + */ +int of_drm_get_panel_orientation(const struct device_node *np, + enum drm_panel_orientation *orientation) +{ + int rotation, ret; + + ret = of_property_read_u32(np, "rotation", &rotation); + if (ret == -EINVAL) { + /* Don't return an error if there's no rotation property. */ + *orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + return 0; + } + + if (ret < 0) + return ret; + + if (rotation == 0) + *orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; + else if (rotation == 90) + *orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP; + else if (rotation == 180) + *orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; + else if (rotation == 270) + *orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP; + else + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL(of_drm_get_panel_orientation); #endif
#if IS_REACHABLE(CONFIG_BACKLIGHT_CLASS_DEVICE) diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h index 6193cb555acc..781c735f0f9b 100644 --- a/include/drm/drm_panel.h +++ b/include/drm/drm_panel.h @@ -35,6 +35,8 @@ struct drm_device; struct drm_panel; struct display_timing;
+enum drm_panel_orientation; + /** * struct drm_panel_funcs - perform operations on a given panel * @@ -191,11 +193,18 @@ int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector
#if defined(CONFIG_OF) && defined(CONFIG_DRM_PANEL) struct drm_panel *of_drm_find_panel(const struct device_node *np); +int of_drm_get_panel_orientation(const struct device_node *np, + enum drm_panel_orientation *orientation); #else static inline struct drm_panel *of_drm_find_panel(const struct device_node *np) { return ERR_PTR(-ENODEV); } +static inline int of_drm_get_panel_orientation(const struct device_node *np, + enum drm_panel_orientation *orientation) +{ + return -ENODEV; +} #endif
#if IS_ENABLED(CONFIG_DRM_PANEL) && (IS_BUILTIN(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
18.06.2020 02:18, Dmitry Osipenko пишет:
From: Derek Basehore dbasehore@chromium.org
This adds a helper function for reading the rotation (panel orientation) from the device tree.
Signed-off-by: Derek Basehore dbasehore@chromium.org Reviewed-by: Sam Ravnborg sam@ravnborg.org
My t-b accidentally got lost after rebase, here it is:
Tested-by: Dmitry Osipenko digetx@gmail.com
From: Derek Basehore dbasehore@chromium.org
This reads the DT setting for the panel rotation to set the panel orientation in the get_modes callback.
Reviewed-by: Dmitry Osipenko digetx@gmail.com Signed-off-by: Derek Basehore dbasehore@chromium.org --- drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c index db5b866357f2..4bd9397972e8 100644 --- a/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c +++ b/drivers/gpu/drm/panel/panel-boe-tv101wum-nl6.c @@ -11,6 +11,7 @@ #include <linux/of_device.h> #include <linux/regulator/consumer.h>
+#include <drm/drm_connector.h> #include <drm/drm_crtc.h> #include <drm/drm_mipi_dsi.h> #include <drm/drm_panel.h> @@ -43,6 +44,7 @@ struct boe_panel {
const struct panel_desc *desc;
+ enum drm_panel_orientation orientation; struct regulator *pp1800; struct regulator *avee; struct regulator *avdd; @@ -740,6 +742,7 @@ static int boe_panel_get_modes(struct drm_panel *panel, connector->display_info.width_mm = boe->desc->size.width_mm; connector->display_info.height_mm = boe->desc->size.height_mm; connector->display_info.bpc = boe->desc->bpc; + drm_connector_set_panel_orientation(connector, boe->orientation);
return 1; } @@ -779,6 +782,9 @@ static int boe_panel_add(struct boe_panel *boe)
drm_panel_init(&boe->base, dev, &boe_panel_funcs, DRM_MODE_CONNECTOR_DSI); + err = of_drm_get_panel_orientation(dev->of_node, &boe->orientation); + if (err < 0) + return err;
err = drm_panel_of_backlight(&boe->base); if (err)
The panel orientation needs to parsed from a device-tree and assigned to the panel's connector in order to make orientation property available to userspace. That's what this patch does for the generic LVDS panel.
Signed-off-by: Dmitry Osipenko digetx@gmail.com --- drivers/gpu/drm/panel/panel-lvds.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-lvds.c b/drivers/gpu/drm/panel/panel-lvds.c index 5ce3f4a2b7a1..f62227059090 100644 --- a/drivers/gpu/drm/panel/panel-lvds.c +++ b/drivers/gpu/drm/panel/panel-lvds.c @@ -37,6 +37,8 @@ struct panel_lvds {
struct gpio_desc *enable_gpio; struct gpio_desc *reset_gpio; + + enum drm_panel_orientation orientation; };
static inline struct panel_lvds *to_panel_lvds(struct drm_panel *panel) @@ -99,6 +101,7 @@ static int panel_lvds_get_modes(struct drm_panel *panel, connector->display_info.bus_flags = lvds->data_mirror ? DRM_BUS_FLAG_DATA_LSB_TO_MSB : DRM_BUS_FLAG_DATA_MSB_TO_LSB; + drm_connector_set_panel_orientation(connector, lvds->orientation);
return 1; } @@ -116,6 +119,13 @@ static int panel_lvds_parse_dt(struct panel_lvds *lvds) const char *mapping; int ret;
+ ret = of_drm_get_panel_orientation(np, &lvds->orientation); + if (ret < 0) { + dev_err(lvds->dev, "%pOF: problems parsing rotation (%d)\n", + np, ret); + return ret; + } + ret = of_get_display_timing(np, "panel-timing", &timing); if (ret < 0) { dev_err(lvds->dev, "%pOF: problems parsing panel-timing (%d)\n",
The panel orientation needs to parsed from a device-tree and assigned to the panel's connector in order to make orientation property available to userspace. That's what this patch does for the panel-simple driver.
Signed-off-by: Dmitry Osipenko digetx@gmail.com --- drivers/gpu/drm/panel/panel-simple.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 6764ac630e22..2dee1320216c 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -112,6 +112,8 @@ struct panel_simple { struct gpio_desc *hpd_gpio;
struct drm_display_mode override_mode; + + enum drm_panel_orientation orientation; };
static inline struct panel_simple *to_panel_simple(struct drm_panel *panel) @@ -371,6 +373,9 @@ static int panel_simple_get_modes(struct drm_panel *panel, /* add hard-coded panel modes */ num += panel_simple_get_non_edid_modes(p, connector);
+ /* set up connector's "panel orientation" property */ + drm_connector_set_panel_orientation(connector, p->orientation); + return num; }
@@ -530,6 +535,12 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) return err; }
+ err = of_drm_get_panel_orientation(dev->of_node, &panel->orientation); + if (err) { + dev_err(dev, "failed to parse rotation property: %d\n", err); + return err; + } + ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0); if (ddc) { panel->ddc = of_find_i2c_adapter_by_node(ddc);
18.06.2020 02:18, Dmitry Osipenko пишет:
Hello!
This series adds support for display panel's DT rotation property. It's a continuation of the work that was initially started by Derek Basehore for the panel driver that is used by some Mediatek device [1]. I picked up the Derek's patches and added my t-b and r-b tags to them, I also added rotation support to the panel-lvds and panel-simple drivers.
We need the rotation support for the Nexus 7 tablet device which is pending to become supported by upstream kernel, the device has display panel mounted upside-down and it uses panel-lvds [2].
[1] https://lkml.org/lkml/2020/3/5/1119 [2] https://patchwork.ozlabs.org/project/linux-tegra/patch/20200607154327.18589-...
Changelog:
v11: - This series is factored out from this patchset [3] because these patches do not have hard dependency on the Tegra DRM patches and it should be nicer to review and apply the properly grouped patches.
- Initially [3] only touched the panel-lvds driver and Emil Velikov suggested that it will be better to support more panels in the review comments to [3]. So I included the Derek's patch for the BOE panel and added rotation support to the panel-simple driver. I tested that panel-lvds and panel-simple work properly with the rotated panel using the Opentegra Xorg driver [4] and Wayland Weston [5]. - The panel-lvds driver now prints a error message if rotation property fails to be parsed.
[3] https://lore.kernel.org/lkml/20200614200121.14147-1-digetx@gmail.com/ [4] https://github.com/grate-driver/xf86-video-opentegra/commit/28eb20a3959bbe5b... [5] https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/315
Derek Basehore (2): drm/panel: Add helper for reading DT rotation drm/panel: Read panel orientation for BOE TV101WUM-NL6
Dmitry Osipenko (2): drm/panel: lvds: Read panel orientation drm/panel-simple: Read panel orientation
drivers/gpu/drm/drm_panel.c | 43 +++++++++++++++++++ .../gpu/drm/panel/panel-boe-tv101wum-nl6.c | 6 +++ drivers/gpu/drm/panel/panel-lvds.c | 10 +++++ drivers/gpu/drm/panel/panel-simple.c | 11 +++++ include/drm/drm_panel.h | 9 ++++ 5 files changed, 79 insertions(+)
Hi! Does anyone have any comments to this patchset? Will be nice if it could get into 5.9 :) Thanks in advance!
dri-devel@lists.freedesktop.org