diff mbox series

[v2,2/3] drm/panel: sitronix-st7789v: add panel orientation support

Message ID 20230718-feature-st7789v-v2-2-207cb1baea0f@wolfvision.net (mailing list archive)
State New, archived
Headers show
Series drm/panel: sitronix-st7789v: add panel orientation support | expand

Commit Message

Michael Riesch Aug. 3, 2023, 8:13 p.m. UTC
Determine the orientation of the display based on the device tree and
propagate it.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
---
 drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Comments

Sebastian Reichel Aug. 4, 2023, 3:03 a.m. UTC | #1
Hi,

On Thu, Aug 03, 2023 at 10:13:49PM +0200, Michael Riesch wrote:
> Determine the orientation of the display based on the device tree and
> propagate it.
> 
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
> ---

Reviewed-by: Sebastian Reichel <sre@kernel.org>

-- Sebastian

>  drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
> index c7cbfe6ca82c..6575f07d49e3 100644
> --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
> +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
> @@ -116,6 +116,7 @@ struct st7789v {
>  	struct spi_device *spi;
>  	struct gpio_desc *reset;
>  	struct regulator *power;
> +	enum drm_panel_orientation orientation;
>  };
>  
>  enum st7789v_prefix {
> @@ -170,6 +171,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;
>  
>  	mode = drm_mode_duplicate(connector->dev, &default_mode);
> @@ -188,9 +190,22 @@ static int st7789v_get_modes(struct drm_panel *panel,
>  	connector->display_info.width_mm = 61;
>  	connector->display_info.height_mm = 103;
>  
> +	/*
> +	 * 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);
> @@ -349,6 +364,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,
>  };
> @@ -382,6 +398,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
>
Neil Armstrong Aug. 4, 2023, 8:40 a.m. UTC | #2
Hi,

On 03/08/2023 22:13, Michael Riesch wrote:
> Determine the orientation of the display based on the device tree and
> propagate it.
> 
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
> ---
>   drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
> index c7cbfe6ca82c..6575f07d49e3 100644
> --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
> +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
> @@ -116,6 +116,7 @@ struct st7789v {
>   	struct spi_device *spi;
>   	struct gpio_desc *reset;
>   	struct regulator *power;
> +	enum drm_panel_orientation orientation;
>   };
>   
>   enum st7789v_prefix {
> @@ -170,6 +171,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;
>   
>   	mode = drm_mode_duplicate(connector->dev, &default_mode);
> @@ -188,9 +190,22 @@ static int st7789v_get_modes(struct drm_panel *panel,
>   	connector->display_info.width_mm = 61;
>   	connector->display_info.height_mm = 103;
>   
> +	/*
> +	 * 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);
> @@ -349,6 +364,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,
>   };
> @@ -382,6 +398,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;
> 

This patch doesn't apply clean on drm-misc-next, could you rebase and resend ?

Thanks,
Neil
Michael Riesch Aug. 4, 2023, 11:24 a.m. UTC | #3
Hi Neil,

On 8/4/23 10:40, Neil Armstrong wrote:
> Hi,
> 
> On 03/08/2023 22:13, Michael Riesch wrote:
>> Determine the orientation of the display based on the device tree and
>> propagate it.
>>
>> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
>> Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
>> ---
>>   drivers/gpu/drm/panel/panel-sitronix-st7789v.c | 18 ++++++++++++++++++
>>   1 file changed, 18 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
>> b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
>> index c7cbfe6ca82c..6575f07d49e3 100644
>> --- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
>> +++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
>> @@ -116,6 +116,7 @@ struct st7789v {
>>       struct spi_device *spi;
>>       struct gpio_desc *reset;
>>       struct regulator *power;
>> +    enum drm_panel_orientation orientation;
>>   };
>>     enum st7789v_prefix {
>> @@ -170,6 +171,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;
>>         mode = drm_mode_duplicate(connector->dev, &default_mode);
>> @@ -188,9 +190,22 @@ static int st7789v_get_modes(struct drm_panel
>> *panel,
>>       connector->display_info.width_mm = 61;
>>       connector->display_info.height_mm = 103;
>>   +    /*
>> +     * 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);
>> @@ -349,6 +364,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,
>>   };
>> @@ -382,6 +398,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;
>>
> 
> This patch doesn't apply clean on drm-misc-next, could you rebase and
> resend ?

Sure! v3 is out.

Best regards,
Michael

> 
> Thanks,
> Neil
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
index c7cbfe6ca82c..6575f07d49e3 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7789v.c
@@ -116,6 +116,7 @@  struct st7789v {
 	struct spi_device *spi;
 	struct gpio_desc *reset;
 	struct regulator *power;
+	enum drm_panel_orientation orientation;
 };
 
 enum st7789v_prefix {
@@ -170,6 +171,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;
 
 	mode = drm_mode_duplicate(connector->dev, &default_mode);
@@ -188,9 +190,22 @@  static int st7789v_get_modes(struct drm_panel *panel,
 	connector->display_info.width_mm = 61;
 	connector->display_info.height_mm = 103;
 
+	/*
+	 * 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);
@@ -349,6 +364,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,
 };
@@ -382,6 +398,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;