diff mbox

[v3,6/7] efifb: Set info->fbcon_rotate_hint based on drm_get_panel_orientation_quirk

Message ID 20171023071425.5090-7-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hans de Goede Oct. 23, 2017, 7:14 a.m. UTC
On some hardware the LCD panel is not mounted upright in the casing,
but rotated by 90 degrees. In this case we want the console to
automatically be rotated to compensate.

The drm subsys has a quirk table for this, use the
drm_get_panel_orientation_quirk function to get the panel orientation
and set info->fbcon_rotate_hint based on this, so that the fbcon console
on top of efifb gets automatically rotated to compensate for the panel
orientation.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/video/fbdev/Kconfig |  1 +
 drivers/video/fbdev/efifb.c | 21 ++++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

Comments

Daniel Vetter Oct. 30, 2017, 9:53 a.m. UTC | #1
On Mon, Oct 23, 2017 at 09:14:24AM +0200, Hans de Goede wrote:
> On some hardware the LCD panel is not mounted upright in the casing,
> but rotated by 90 degrees. In this case we want the console to
> automatically be rotated to compensate.
> 
> The drm subsys has a quirk table for this, use the
> drm_get_panel_orientation_quirk function to get the panel orientation
> and set info->fbcon_rotate_hint based on this, so that the fbcon console
> on top of efifb gets automatically rotated to compensate for the panel
> orientation.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/video/fbdev/Kconfig |  1 +
>  drivers/video/fbdev/efifb.c | 21 ++++++++++++++++++++-
>  2 files changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
> index 5e58f5ec0a28..c4a90c497839 100644
> --- a/drivers/video/fbdev/Kconfig
> +++ b/drivers/video/fbdev/Kconfig
> @@ -772,6 +772,7 @@ config FB_VESA
>  config FB_EFI
>  	bool "EFI-based Framebuffer Support"
>  	depends on (FB = y) && !IA64 && EFI
> +	select DRM_PANEL_ORIENTATION_QUIRKS
>  	select FB_CFB_FILLRECT
>  	select FB_CFB_COPYAREA
>  	select FB_CFB_IMAGEBLIT
> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
> index 3a010641f630..8c7f6aeee205 100644
> --- a/drivers/video/fbdev/efifb.c
> +++ b/drivers/video/fbdev/efifb.c
> @@ -15,6 +15,8 @@
>  #include <linux/screen_info.h>
>  #include <video/vga.h>
>  #include <asm/efi.h>
> +#include <drm/drm_utils.h> /* For drm_get_panel_orientation_quirk */
> +#include <drm/drm_mode.h>  /* For DRM_MODE_PANEL_ORIENTATION_* */
>  
>  static bool request_mem_succeeded = false;
>  static bool nowc = false;
> @@ -156,7 +158,7 @@ static u64 bar_offset;
>  static int efifb_probe(struct platform_device *dev)
>  {
>  	struct fb_info *info;
> -	int err;
> +	int err, orientation;
>  	unsigned int size_vmode;
>  	unsigned int size_remap;
>  	unsigned int size_total;
> @@ -328,6 +330,23 @@ static int efifb_probe(struct platform_device *dev)
>  	info->fix = efifb_fix;
>  	info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE;
>  
> +	orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
> +						      efifb_defined.yres);

Oh right, that's the reason for the separate function. Still ugh.

Maybe add a comment in the kernel-doc for why it is what it is ...
-Daniel

> +	switch (orientation) {
> +	default:
> +		info->fbcon_rotate_hint = FB_ROTATE_UR;
> +		break;
> +	case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
> +		info->fbcon_rotate_hint = FB_ROTATE_UD;
> +		break;
> +	case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
> +		info->fbcon_rotate_hint = FB_ROTATE_CCW;
> +		break;
> +	case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
> +		info->fbcon_rotate_hint = FB_ROTATE_CW;
> +		break;
> +	}
> +
>  	err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
>  	if (err) {
>  		pr_err("efifb: cannot add sysfs attrs\n");
> -- 
> 2.14.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hans de Goede Oct. 30, 2017, 11:10 a.m. UTC | #2
Hi,

On 30-10-17 10:53, Daniel Vetter wrote:
> On Mon, Oct 23, 2017 at 09:14:24AM +0200, Hans de Goede wrote:
>> On some hardware the LCD panel is not mounted upright in the casing,
>> but rotated by 90 degrees. In this case we want the console to
>> automatically be rotated to compensate.
>>
>> The drm subsys has a quirk table for this, use the
>> drm_get_panel_orientation_quirk function to get the panel orientation
>> and set info->fbcon_rotate_hint based on this, so that the fbcon console
>> on top of efifb gets automatically rotated to compensate for the panel
>> orientation.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   drivers/video/fbdev/Kconfig |  1 +
>>   drivers/video/fbdev/efifb.c | 21 ++++++++++++++++++++-
>>   2 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
>> index 5e58f5ec0a28..c4a90c497839 100644
>> --- a/drivers/video/fbdev/Kconfig
>> +++ b/drivers/video/fbdev/Kconfig
>> @@ -772,6 +772,7 @@ config FB_VESA
>>   config FB_EFI
>>   	bool "EFI-based Framebuffer Support"
>>   	depends on (FB = y) && !IA64 && EFI
>> +	select DRM_PANEL_ORIENTATION_QUIRKS
>>   	select FB_CFB_FILLRECT
>>   	select FB_CFB_COPYAREA
>>   	select FB_CFB_IMAGEBLIT
>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>> index 3a010641f630..8c7f6aeee205 100644
>> --- a/drivers/video/fbdev/efifb.c
>> +++ b/drivers/video/fbdev/efifb.c
>> @@ -15,6 +15,8 @@
>>   #include <linux/screen_info.h>
>>   #include <video/vga.h>
>>   #include <asm/efi.h>
>> +#include <drm/drm_utils.h> /* For drm_get_panel_orientation_quirk */
>> +#include <drm/drm_mode.h>  /* For DRM_MODE_PANEL_ORIENTATION_* */
>>   
>>   static bool request_mem_succeeded = false;
>>   static bool nowc = false;
>> @@ -156,7 +158,7 @@ static u64 bar_offset;
>>   static int efifb_probe(struct platform_device *dev)
>>   {
>>   	struct fb_info *info;
>> -	int err;
>> +	int err, orientation;
>>   	unsigned int size_vmode;
>>   	unsigned int size_remap;
>>   	unsigned int size_total;
>> @@ -328,6 +330,23 @@ static int efifb_probe(struct platform_device *dev)
>>   	info->fix = efifb_fix;
>>   	info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE;
>>   
>> +	orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
>> +						      efifb_defined.yres);
> 
> Oh right, that's the reason for the separate function. Still ugh.

Ack.

> Maybe add a comment in the kernel-doc for why it is what it is ...

Ok I will add a comment to the kernel-doc for drm_get_panel_orientation_quirk()
in v4 of this patch-set.

Regards,

Hans



> -Daniel
> 
>> +	switch (orientation) {
>> +	default:
>> +		info->fbcon_rotate_hint = FB_ROTATE_UR;
>> +		break;
>> +	case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
>> +		info->fbcon_rotate_hint = FB_ROTATE_UD;
>> +		break;
>> +	case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
>> +		info->fbcon_rotate_hint = FB_ROTATE_CCW;
>> +		break;
>> +	case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
>> +		info->fbcon_rotate_hint = FB_ROTATE_CW;
>> +		break;
>> +	}
>> +
>>   	err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
>>   	if (err) {
>>   		pr_err("efifb: cannot add sysfs attrs\n");
>> -- 
>> 2.14.2
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
Hans de Goede Nov. 4, 2017, 1:13 p.m. UTC | #3
Hi,

On 30-10-17 10:53, Daniel Vetter wrote:
> On Mon, Oct 23, 2017 at 09:14:24AM +0200, Hans de Goede wrote:
>> On some hardware the LCD panel is not mounted upright in the casing,
>> but rotated by 90 degrees. In this case we want the console to
>> automatically be rotated to compensate.
>>
>> The drm subsys has a quirk table for this, use the
>> drm_get_panel_orientation_quirk function to get the panel orientation
>> and set info->fbcon_rotate_hint based on this, so that the fbcon console
>> on top of efifb gets automatically rotated to compensate for the panel
>> orientation.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>   drivers/video/fbdev/Kconfig |  1 +
>>   drivers/video/fbdev/efifb.c | 21 ++++++++++++++++++++-
>>   2 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
>> index 5e58f5ec0a28..c4a90c497839 100644
>> --- a/drivers/video/fbdev/Kconfig
>> +++ b/drivers/video/fbdev/Kconfig
>> @@ -772,6 +772,7 @@ config FB_VESA
>>   config FB_EFI
>>   	bool "EFI-based Framebuffer Support"
>>   	depends on (FB = y) && !IA64 && EFI
>> +	select DRM_PANEL_ORIENTATION_QUIRKS
>>   	select FB_CFB_FILLRECT
>>   	select FB_CFB_COPYAREA
>>   	select FB_CFB_IMAGEBLIT
>> diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
>> index 3a010641f630..8c7f6aeee205 100644
>> --- a/drivers/video/fbdev/efifb.c
>> +++ b/drivers/video/fbdev/efifb.c
>> @@ -15,6 +15,8 @@
>>   #include <linux/screen_info.h>
>>   #include <video/vga.h>
>>   #include <asm/efi.h>
>> +#include <drm/drm_utils.h> /* For drm_get_panel_orientation_quirk */
>> +#include <drm/drm_mode.h>  /* For DRM_MODE_PANEL_ORIENTATION_* */
>>   
>>   static bool request_mem_succeeded = false;
>>   static bool nowc = false;
>> @@ -156,7 +158,7 @@ static u64 bar_offset;
>>   static int efifb_probe(struct platform_device *dev)
>>   {
>>   	struct fb_info *info;
>> -	int err;
>> +	int err, orientation;
>>   	unsigned int size_vmode;
>>   	unsigned int size_remap;
>>   	unsigned int size_total;
>> @@ -328,6 +330,23 @@ static int efifb_probe(struct platform_device *dev)
>>   	info->fix = efifb_fix;
>>   	info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE;
>>   
>> +	orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
>> +						      efifb_defined.yres);
> 
> Oh right, that's the reason for the separate function. Still ugh.
> 
> Maybe add a comment in the kernel-doc for why it is what it is ...

Actually the drm_get_panel_orientation_quirk() function was missing
a kernel-doc comment documenting it altogether. For v5 of this
patch-set I've added a kernel-doc comment and I've added this bit
to that kernel-doc comment to explain why drm_get_panel_orientation_quirk()
lives in a separate .ko target:

  * Note this function is also used outside of the drm-subsys, by for example
  * the efifb code. Because of this this function gets compiled into its own
  * kernel-module when built as a module.

Regards,

Hans



> -Daniel
> 
>> +	switch (orientation) {
>> +	default:
>> +		info->fbcon_rotate_hint = FB_ROTATE_UR;
>> +		break;
>> +	case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
>> +		info->fbcon_rotate_hint = FB_ROTATE_UD;
>> +		break;
>> +	case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
>> +		info->fbcon_rotate_hint = FB_ROTATE_CCW;
>> +		break;
>> +	case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
>> +		info->fbcon_rotate_hint = FB_ROTATE_CW;
>> +		break;
>> +	}
>> +
>>   	err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
>>   	if (err) {
>>   		pr_err("efifb: cannot add sysfs attrs\n");
>> -- 
>> 2.14.2
>>
>> _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
diff mbox

Patch

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 5e58f5ec0a28..c4a90c497839 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -772,6 +772,7 @@  config FB_VESA
 config FB_EFI
 	bool "EFI-based Framebuffer Support"
 	depends on (FB = y) && !IA64 && EFI
+	select DRM_PANEL_ORIENTATION_QUIRKS
 	select FB_CFB_FILLRECT
 	select FB_CFB_COPYAREA
 	select FB_CFB_IMAGEBLIT
diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c
index 3a010641f630..8c7f6aeee205 100644
--- a/drivers/video/fbdev/efifb.c
+++ b/drivers/video/fbdev/efifb.c
@@ -15,6 +15,8 @@ 
 #include <linux/screen_info.h>
 #include <video/vga.h>
 #include <asm/efi.h>
+#include <drm/drm_utils.h> /* For drm_get_panel_orientation_quirk */
+#include <drm/drm_mode.h>  /* For DRM_MODE_PANEL_ORIENTATION_* */
 
 static bool request_mem_succeeded = false;
 static bool nowc = false;
@@ -156,7 +158,7 @@  static u64 bar_offset;
 static int efifb_probe(struct platform_device *dev)
 {
 	struct fb_info *info;
-	int err;
+	int err, orientation;
 	unsigned int size_vmode;
 	unsigned int size_remap;
 	unsigned int size_total;
@@ -328,6 +330,23 @@  static int efifb_probe(struct platform_device *dev)
 	info->fix = efifb_fix;
 	info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE;
 
+	orientation = drm_get_panel_orientation_quirk(efifb_defined.xres,
+						      efifb_defined.yres);
+	switch (orientation) {
+	default:
+		info->fbcon_rotate_hint = FB_ROTATE_UR;
+		break;
+	case DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP:
+		info->fbcon_rotate_hint = FB_ROTATE_UD;
+		break;
+	case DRM_MODE_PANEL_ORIENTATION_LEFT_UP:
+		info->fbcon_rotate_hint = FB_ROTATE_CCW;
+		break;
+	case DRM_MODE_PANEL_ORIENTATION_RIGHT_UP:
+		info->fbcon_rotate_hint = FB_ROTATE_CW;
+		break;
+	}
+
 	err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
 	if (err) {
 		pr_err("efifb: cannot add sysfs attrs\n");