* [PATCH v11 0/4] Panel rotation patches
@ 2020-06-17 23:18 Dmitry Osipenko
2020-06-17 23:18 ` [PATCH v11 2/4] drm/panel: Read panel orientation for BOE TV101WUM-NL6 Dmitry Osipenko
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Dmitry Osipenko @ 2020-06-17 23:18 UTC (permalink / raw)
To: Thierry Reding, Thomas Zimmermann, Derek Basehore, Sam Ravnborg,
Laurent Pinchart, Sean Paul, Daniel Vetter,
Ville Syrjälä, Emil Velikov, Daniel Stone
Cc: dri-devel, linux-tegra, linux-kernel
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-3-digetx@gmail.com/
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/28eb20a3959bbe5bc3a3b67e55977093fd5114ca
[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(+)
--
2.26.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v11 2/4] drm/panel: Read panel orientation for BOE TV101WUM-NL6 2020-06-17 23:18 [PATCH v11 0/4] Panel rotation patches Dmitry Osipenko @ 2020-06-17 23:18 ` Dmitry Osipenko 2020-06-17 23:18 ` [PATCH v11 3/4] drm/panel: lvds: Read panel orientation Dmitry Osipenko [not found] ` <20200617231842.30671-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2 siblings, 0 replies; 7+ messages in thread From: Dmitry Osipenko @ 2020-06-17 23:18 UTC (permalink / raw) To: Thierry Reding, Thomas Zimmermann, Derek Basehore, Sam Ravnborg, Laurent Pinchart, Sean Paul, Daniel Vetter, Ville Syrjälä, Emil Velikov, Daniel Stone Cc: dri-devel, linux-tegra, linux-kernel 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) -- 2.26.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v11 3/4] drm/panel: lvds: Read panel orientation 2020-06-17 23:18 [PATCH v11 0/4] Panel rotation patches Dmitry Osipenko 2020-06-17 23:18 ` [PATCH v11 2/4] drm/panel: Read panel orientation for BOE TV101WUM-NL6 Dmitry Osipenko @ 2020-06-17 23:18 ` Dmitry Osipenko [not found] ` <20200617231842.30671-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2 siblings, 0 replies; 7+ messages in thread From: Dmitry Osipenko @ 2020-06-17 23:18 UTC (permalink / raw) To: Thierry Reding, Thomas Zimmermann, Derek Basehore, Sam Ravnborg, Laurent Pinchart, Sean Paul, Daniel Vetter, Ville Syrjälä, Emil Velikov, Daniel Stone Cc: dri-devel, linux-tegra, linux-kernel 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", -- 2.26.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <20200617231842.30671-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* [PATCH v11 1/4] drm/panel: Add helper for reading DT rotation [not found] ` <20200617231842.30671-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2020-06-17 23:18 ` Dmitry Osipenko [not found] ` <20200617231842.30671-2-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2020-06-17 23:18 ` [PATCH v11 4/4] drm/panel-simple: Read panel orientation Dmitry Osipenko 2020-07-17 14:59 ` [PATCH v11 0/4] Panel rotation patches Dmitry Osipenko 2 siblings, 1 reply; 7+ messages in thread From: Dmitry Osipenko @ 2020-06-17 23:18 UTC (permalink / raw) To: Thierry Reding, Thomas Zimmermann, Derek Basehore, Sam Ravnborg, Laurent Pinchart, Sean Paul, Daniel Vetter, Ville Syrjälä, Emil Velikov, Daniel Stone Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA From: Derek Basehore <dbasehore-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> This adds a helper function for reading the rotation (panel orientation) from the device tree. Signed-off-by: Derek Basehore <dbasehore-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> Reviewed-by: Sam Ravnborg <sam-uyr5N9Q2VtJg9hUCZPvPmw@public.gmane.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) || \ -- 2.26.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
[parent not found: <20200617231842.30671-2-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH v11 1/4] drm/panel: Add helper for reading DT rotation [not found] ` <20200617231842.30671-2-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2020-06-20 14:25 ` Dmitry Osipenko 0 siblings, 0 replies; 7+ messages in thread From: Dmitry Osipenko @ 2020-06-20 14:25 UTC (permalink / raw) To: Thierry Reding, Thomas Zimmermann, Derek Basehore, Sam Ravnborg, Laurent Pinchart, Sean Paul, Daniel Vetter, Ville Syrjälä, Emil Velikov, Daniel Stone Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA 18.06.2020 02:18, Dmitry Osipenko пишет: > From: Derek Basehore <dbasehore-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > > This adds a helper function for reading the rotation (panel > orientation) from the device tree. > > Signed-off-by: Derek Basehore <dbasehore-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> > Reviewed-by: Sam Ravnborg <sam-uyr5N9Q2VtJg9hUCZPvPmw@public.gmane.org> > --- My t-b accidentally got lost after rebase, here it is: Tested-by: Dmitry Osipenko <digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v11 4/4] drm/panel-simple: Read panel orientation [not found] ` <20200617231842.30671-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2020-06-17 23:18 ` [PATCH v11 1/4] drm/panel: Add helper for reading DT rotation Dmitry Osipenko @ 2020-06-17 23:18 ` Dmitry Osipenko 2020-07-17 14:59 ` [PATCH v11 0/4] Panel rotation patches Dmitry Osipenko 2 siblings, 0 replies; 7+ messages in thread From: Dmitry Osipenko @ 2020-06-17 23:18 UTC (permalink / raw) To: Thierry Reding, Thomas Zimmermann, Derek Basehore, Sam Ravnborg, Laurent Pinchart, Sean Paul, Daniel Vetter, Ville Syrjälä, Emil Velikov, Daniel Stone Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --- 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); -- 2.26.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v11 0/4] Panel rotation patches [not found] ` <20200617231842.30671-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2020-06-17 23:18 ` [PATCH v11 1/4] drm/panel: Add helper for reading DT rotation Dmitry Osipenko 2020-06-17 23:18 ` [PATCH v11 4/4] drm/panel-simple: Read panel orientation Dmitry Osipenko @ 2020-07-17 14:59 ` Dmitry Osipenko 2 siblings, 0 replies; 7+ messages in thread From: Dmitry Osipenko @ 2020-07-17 14:59 UTC (permalink / raw) To: Thierry Reding, Thomas Zimmermann, Derek Basehore, Sam Ravnborg, Laurent Pinchart, Sean Paul, Daniel Vetter, Ville Syrjälä, Emil Velikov, Daniel Stone Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, linux-tegra-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA 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-3-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org/ > > 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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org/ > [4] https://github.com/grate-driver/xf86-video-opentegra/commit/28eb20a3959bbe5bc3a3b67e55977093fd5114ca > [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! ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-07-17 14:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-17 23:18 [PATCH v11 0/4] Panel rotation patches Dmitry Osipenko
2020-06-17 23:18 ` [PATCH v11 2/4] drm/panel: Read panel orientation for BOE TV101WUM-NL6 Dmitry Osipenko
2020-06-17 23:18 ` [PATCH v11 3/4] drm/panel: lvds: Read panel orientation Dmitry Osipenko
[not found] ` <20200617231842.30671-1-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-06-17 23:18 ` [PATCH v11 1/4] drm/panel: Add helper for reading DT rotation Dmitry Osipenko
[not found] ` <20200617231842.30671-2-digetx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2020-06-20 14:25 ` Dmitry Osipenko
2020-06-17 23:18 ` [PATCH v11 4/4] drm/panel-simple: Read panel orientation Dmitry Osipenko
2020-07-17 14:59 ` [PATCH v11 0/4] Panel rotation patches Dmitry Osipenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox