aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_fourcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_fourcc.c')
-rw-r--r--drivers/gpu/drm/drm_fourcc.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
index be1d6aaef651..90a1c846fc25 100644
--- a/drivers/gpu/drm/drm_fourcc.c
+++ b/drivers/gpu/drm/drm_fourcc.c
@@ -96,6 +96,41 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth)
96EXPORT_SYMBOL(drm_mode_legacy_fb_format); 96EXPORT_SYMBOL(drm_mode_legacy_fb_format);
97 97
98/** 98/**
99 * drm_driver_legacy_fb_format - compute drm fourcc code from legacy description
100 * @bpp: bits per pixels
101 * @depth: bit depth per pixel
102 * @native: use host native byte order
103 *
104 * Computes a drm fourcc pixel format code for the given @bpp/@depth values.
105 * Unlike drm_mode_legacy_fb_format() this looks at the drivers mode_config,
106 * and depending on the quirk_addfb_prefer_host_byte_order flag it returns
107 * little endian byte order or host byte order framebuffer formats.
108 */
109uint32_t drm_driver_legacy_fb_format(struct drm_device *dev,
110 uint32_t bpp, uint32_t depth)
111{
112 uint32_t fmt = drm_mode_legacy_fb_format(bpp, depth);
113
114 if (dev->mode_config.quirk_addfb_prefer_host_byte_order) {
115 if (fmt == DRM_FORMAT_XRGB8888)
116 fmt = DRM_FORMAT_HOST_XRGB8888;
117 if (fmt == DRM_FORMAT_ARGB8888)
118 fmt = DRM_FORMAT_HOST_ARGB8888;
119 if (fmt == DRM_FORMAT_RGB565)
120 fmt = DRM_FORMAT_HOST_RGB565;
121 if (fmt == DRM_FORMAT_XRGB1555)
122 fmt = DRM_FORMAT_HOST_XRGB1555;
123 }
124
125 if (dev->mode_config.quirk_addfb_prefer_xbgr_30bpp &&
126 fmt == DRM_FORMAT_XRGB2101010)
127 fmt = DRM_FORMAT_XBGR2101010;
128
129 return fmt;
130}
131EXPORT_SYMBOL(drm_driver_legacy_fb_format);
132
133/**
99 * drm_get_format_name - fill a string with a drm fourcc format's name 134 * drm_get_format_name - fill a string with a drm fourcc format's name
100 * @format: format to compute name of 135 * @format: format to compute name of
101 * @buf: caller-supplied buffer 136 * @buf: caller-supplied buffer