drm/panel: sitronix-st7789v: add panel orientation support
authorMichael Riesch <michael.riesch@wolfvision.net>
Fri, 4 Aug 2023 11:23:09 +0000 (13:23 +0200)
committerNeil Armstrong <neil.armstrong@linaro.org>
Fri, 4 Aug 2023 11:56:11 +0000 (13:56 +0200)
Determine the orientation of the display based on the device tree and
propagate it.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Reviewed-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230718-feature-st7789v-v3-2-157d68fb63e2@wolfvision.net
drivers/gpu/drm/panel/panel-sitronix-st7789v.c

index bc8df51224de01e8f43626de76f3ac9f3dcb1581..0ded72ed2fcdf809eff9ca39e95248260127f968 100644 (file)
@@ -126,6 +126,7 @@ struct st7789v {
        struct spi_device *spi;
        struct gpio_desc *reset;
        struct regulator *power;
+       enum drm_panel_orientation orientation;
 };
 
 enum st7789v_prefix {
@@ -325,9 +326,22 @@ static int st7789v_get_modes(struct drm_panel *panel,
        drm_display_info_set_bus_formats(&connector->display_info,
                                         &ctx->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);
@@ -522,6 +536,7 @@ static const struct drm_panel_funcs st7789v_drm_funcs = {
        .disable = st7789v_disable,
        .enable = st7789v_enable,
        .get_modes = st7789v_get_modes,
+       .get_orientation = st7789v_get_orientation,
        .prepare = st7789v_prepare,
        .unprepare = st7789v_unprepare,
 };
@@ -563,6 +578,8 @@ static int st7789v_probe(struct spi_device *spi)
        if (ret)
                return dev_err_probe(dev, ret, "Failed to get backlight\n");
 
+       of_drm_get_panel_orientation(spi->dev.of_node, &ctx->orientation);
+
        drm_panel_add(&ctx->panel);
 
        return 0;