dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Gerald Loacker <gerald.loacker@wolfvision.net>
To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Gerald Loacker <gerald.loacker@wolfvision.net>,
	Sam Ravnborg <sam@ravnborg.org>, Rob Herring <robh+dt@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Michael Riesch <michael.riesch@wolfvision.net>
Subject: [PATCH 2/7] drm/panel: sitronix-st7789v: add panel orientation support
Date: Tue, 14 Mar 2023 12:56:39 +0100	[thread overview]
Message-ID: <20230314115644.3775169-3-gerald.loacker@wolfvision.net> (raw)
In-Reply-To: <20230314115644.3775169-1-gerald.loacker@wolfvision.net>

From: Michael Riesch <michael.riesch@wolfvision.net>

Determine the orientation of the display based on the device tree and
propagate it.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Gerald Loacker <gerald.loacker@wolfvision.net>
---
 .../gpu/drm/panel/panel-sitronix-st7789v.c    | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
index 9535437271d3..5d4542c12f44 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
@@ -117,6 +117,7 @@ struct st7789v {
 	struct spi_device *spi;
 	struct gpio_desc *reset;
 	struct regulator *power;
+	enum drm_panel_orientation orientation;
 };
 
 enum st7789v_prefix {
@@ -171,6 +172,7 @@ static const struct drm_display_mode default_mode = {
 static int st7789v_get_modes(struct drm_panel *panel,
 			     struct drm_connector *connector)
 {
+	struct st7789v *ctx = panel_to_st7789v(panel);
 	struct drm_display_mode *mode;
 	u32 bus_format = MEDIA_BUS_FMT_RGB666_1X18;
 
@@ -193,9 +195,22 @@ static int st7789v_get_modes(struct drm_panel *panel,
 	drm_display_info_set_bus_formats(&connector->display_info, &bus_format,
 					 1);
 
+	/*
+	 * TODO: Remove once all drm drivers call
+	 * drm_connector_set_orientation_from_panel()
+	 */
+	drm_connector_set_panel_orientation(connector, ctx->orientation);
+
 	return 1;
 }
 
+static enum drm_panel_orientation st7789v_get_orientation(struct drm_panel *p)
+{
+	struct st7789v *ctx = panel_to_st7789v(p);
+
+	return ctx->orientation;
+}
+
 static int st7789v_prepare(struct drm_panel *panel)
 {
 	struct st7789v *ctx = panel_to_st7789v(panel);
@@ -351,11 +366,12 @@ static int st7789v_unprepare(struct drm_panel *panel)
 }
 
 static const struct drm_panel_funcs st7789v_drm_funcs = {
-	.disable	= st7789v_disable,
-	.enable		= st7789v_enable,
-	.get_modes	= st7789v_get_modes,
-	.prepare	= st7789v_prepare,
-	.unprepare	= st7789v_unprepare,
+	.disable = st7789v_disable,
+	.enable = st7789v_enable,
+	.get_modes = st7789v_get_modes,
+	.get_orientation = st7789v_get_orientation,
+	.prepare = st7789v_prepare,
+	.unprepare = st7789v_unprepare,
 };
 
 static int st7789v_probe(struct spi_device *spi)
@@ -387,6 +403,8 @@ static int st7789v_probe(struct spi_device *spi)
 	if (ret)
 		return ret;
 
+	of_drm_get_panel_orientation(spi->dev.of_node, &ctx->orientation);
+
 	drm_panel_add(&ctx->panel);
 
 	return 0;
-- 
2.37.2


  parent reply	other threads:[~2023-03-14 11:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 11:56 [PATCH 0/7] Add timing override to sitronix,st7789v Gerald Loacker
2023-03-14 11:56 ` [PATCH 1/7] drm/panel: sitronix-st7789v: propagate RGB666 format Gerald Loacker
2023-03-14 11:56 ` Gerald Loacker [this message]
2023-03-14 11:56 ` [PATCH 3/7] drm/panel: sitronix-st7789v: propagate h/v-sync polarity Gerald Loacker
2023-03-14 11:56 ` [PATCH 4/7] drm/panel: sitronix-st7789v: add bus_flags to connector Gerald Loacker
2023-03-14 11:56 ` [PATCH 5/7] drm/panel: sitronix-st7789v: parse device tree to override timing mode Gerald Loacker
2023-03-14 11:56 ` [PATCH 6/7] dt-bindings: display: add rotation property to sitronix, st7789v Gerald Loacker
2023-03-15  7:51   ` [PATCH 6/7] dt-bindings: display: add rotation property to sitronix,st7789v Krzysztof Kozlowski
2023-03-14 11:56 ` [PATCH 7/7] dt-bindings: display: add panel-timing property to sitronix, st7789v Gerald Loacker
2023-03-15  7:51   ` [PATCH 7/7] dt-bindings: display: add panel-timing property to sitronix,st7789v Krzysztof Kozlowski
2023-03-16 21:57   ` Rob Herring
2023-03-16 22:29     ` Michael Riesch
2023-03-29  9:16       ` Maxime Ripard
2023-03-29 10:08         ` Michael Riesch
2023-03-30 14:58           ` Maxime Ripard
2023-03-31  9:36             ` Michael Riesch
2023-04-04 16:04               ` Maxime Ripard
2023-04-04 16:26                 ` Michael Riesch
2023-04-05 15:01                   ` Maxime Ripard
2023-03-29  8:43 ` [PATCH 0/7] Add timing override " Gerald Loacker
2023-03-31  9:49 ` Michael Riesch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230314115644.3775169-3-gerald.loacker@wolfvision.net \
    --to=gerald.loacker@wolfvision.net \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.riesch@wolfvision.net \
    --cc=robh+dt@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).