lkml.org 
[lkml]   [2017]   [Apr]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/6] drm: fourcc byteorder: add bigendian support to drm_mode_legacy_fb_format
Date
Return correct fourcc codes on bigendian.  Drivers must be adapted to
this change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
drivers/gpu/drm/drm_fourcc.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index adb3ff59a4..28401d3745 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -42,11 +42,34 @@ static char printable_char(int c)
*
* Computes a drm fourcc pixel format code for the given @bpp/@depth values.
* Useful in fbdev emulation code, since that deals in those values.
+ *
+ * DRM_FORMAT_* are little endian, we'll pick cpu endian here, therefore we
+ * results differ depending on byte order.
*/
uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
{
uint32_t fmt;

+#ifdef __BIG_ENDIAN
+ switch (bpp) {
+ case 8:
+ fmt = DRM_FORMAT_C8;
+ break;
+ case 24:
+ fmt = DRM_FORMAT_BGR888;
+ break;
+ case 32:
+ if (depth == 24)
+ fmt = DRM_FORMAT_BGRX8888;
+ else
+ fmt = DRM_FORMAT_BGRA8888;
+ break;
+ default:
+ DRM_ERROR("bad bpp, assuming b8g8r8x8 pixel format\n");
+ fmt = DRM_FORMAT_BGRX8888;
+ break;
+ }
+#else
switch (bpp) {
case 8:
fmt = DRM_FORMAT_C8;
@@ -73,6 +96,7 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
fmt = DRM_FORMAT_XRGB8888;
break;
}
+#endif

return fmt;
}
--
2.9.3
\
 
 \ /
  Last update: 2017-04-24 08:27    [W:0.282 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site