aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-05-04 04:29:58 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-06-02 03:57:25 -0400
commitc2e52e32049c0e94aa35a0635a2b150478ef3b2a (patch)
tree4700e8ccdffa0dce7b9c67559e0e8f13c3e35a3b
parenteecad4371d986f38b66202817e2b461ac3c64139 (diff)
drm/omap: cleanup formats array
omap_fb.c has a table with DSS and DRM formats, used to convert between them. This is no longer needed, so we can change the array to a plain array of DRM_FORMAT_* values which contain all possible pixel formats supported by any DSS IP version. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--drivers/gpu/drm/omapdrm/omap_fb.c49
1 files changed, 20 insertions, 29 deletions
diff --git a/drivers/gpu/drm/omapdrm/omap_fb.c b/drivers/gpu/drm/omapdrm/omap_fb.c
index 489d17ce8f11..16b510dcee2f 100644
--- a/drivers/gpu/drm/omapdrm/omap_fb.c
+++ b/drivers/gpu/drm/omapdrm/omap_fb.c
@@ -29,30 +29,26 @@
29 * framebuffer funcs 29 * framebuffer funcs
30 */ 30 */
31 31
32/* DSS to DRM formats mapping */ 32static const u32 formats[] = {
33static const struct {
34 u32 dss_format;
35 uint32_t pixel_format;
36} formats[] = {
37 /* 16bpp [A]RGB: */ 33 /* 16bpp [A]RGB: */
38 { DRM_FORMAT_RGB565, DRM_FORMAT_RGB565 }, /* RGB16-565 */ 34 DRM_FORMAT_RGB565, /* RGB16-565 */
39 { DRM_FORMAT_RGBX4444, DRM_FORMAT_RGBX4444 }, /* RGB12x-4444 */ 35 DRM_FORMAT_RGBX4444, /* RGB12x-4444 */
40 { DRM_FORMAT_XRGB4444, DRM_FORMAT_XRGB4444 }, /* xRGB12-4444 */ 36 DRM_FORMAT_XRGB4444, /* xRGB12-4444 */
41 { DRM_FORMAT_RGBA4444, DRM_FORMAT_RGBA4444 }, /* RGBA12-4444 */ 37 DRM_FORMAT_RGBA4444, /* RGBA12-4444 */
42 { DRM_FORMAT_ARGB4444, DRM_FORMAT_ARGB4444 }, /* ARGB16-4444 */ 38 DRM_FORMAT_ARGB4444, /* ARGB16-4444 */
43 { DRM_FORMAT_XRGB1555, DRM_FORMAT_XRGB1555 }, /* xRGB15-1555 */ 39 DRM_FORMAT_XRGB1555, /* xRGB15-1555 */
44 { DRM_FORMAT_ARGB1555, DRM_FORMAT_ARGB1555 }, /* ARGB16-1555 */ 40 DRM_FORMAT_ARGB1555, /* ARGB16-1555 */
45 /* 24bpp RGB: */ 41 /* 24bpp RGB: */
46 { DRM_FORMAT_RGB888, DRM_FORMAT_RGB888 }, /* RGB24-888 */ 42 DRM_FORMAT_RGB888, /* RGB24-888 */
47 /* 32bpp [A]RGB: */ 43 /* 32bpp [A]RGB: */
48 { DRM_FORMAT_RGBX8888, DRM_FORMAT_RGBX8888 }, /* RGBx24-8888 */ 44 DRM_FORMAT_RGBX8888, /* RGBx24-8888 */
49 { DRM_FORMAT_XRGB8888, DRM_FORMAT_XRGB8888 }, /* xRGB24-8888 */ 45 DRM_FORMAT_XRGB8888, /* xRGB24-8888 */
50 { DRM_FORMAT_RGBA8888, DRM_FORMAT_RGBA8888 }, /* RGBA32-8888 */ 46 DRM_FORMAT_RGBA8888, /* RGBA32-8888 */
51 { DRM_FORMAT_ARGB8888, DRM_FORMAT_ARGB8888 }, /* ARGB32-8888 */ 47 DRM_FORMAT_ARGB8888, /* ARGB32-8888 */
52 /* YUV: */ 48 /* YUV: */
53 { DRM_FORMAT_NV12, DRM_FORMAT_NV12 }, 49 DRM_FORMAT_NV12,
54 { DRM_FORMAT_YUYV, DRM_FORMAT_YUYV }, 50 DRM_FORMAT_YUYV,
55 { DRM_FORMAT_UYVY, DRM_FORMAT_UYVY }, 51 DRM_FORMAT_UYVY,
56}; 52};
57 53
58/* per-plane info for the fb: */ 54/* per-plane info for the fb: */
@@ -69,7 +65,6 @@ struct omap_framebuffer {
69 struct drm_framebuffer base; 65 struct drm_framebuffer base;
70 int pin_count; 66 int pin_count;
71 const struct drm_format_info *format; 67 const struct drm_format_info *format;
72 u32 dss_format;
73 struct plane planes[2]; 68 struct plane planes[2];
74 /* lock for pinning (pin_count and planes.dma_addr) */ 69 /* lock for pinning (pin_count and planes.dma_addr) */
75 struct mutex lock; 70 struct mutex lock;
@@ -137,7 +132,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
137 struct plane *plane = &omap_fb->planes[0]; 132 struct plane *plane = &omap_fb->planes[0];
138 uint32_t x, y, orient = 0; 133 uint32_t x, y, orient = 0;
139 134
140 info->color_mode = omap_fb->dss_format; 135 info->color_mode = fb->format->format;
141 136
142 info->pos_x = win->crtc_x; 137 info->pos_x = win->crtc_x;
143 info->pos_y = win->crtc_y; 138 info->pos_y = win->crtc_y;
@@ -214,7 +209,7 @@ void omap_framebuffer_update_scanout(struct drm_framebuffer *fb,
214 /* convert to pixels: */ 209 /* convert to pixels: */
215 info->screen_width /= format->cpp[0]; 210 info->screen_width /= format->cpp[0];
216 211
217 if (omap_fb->dss_format == DRM_FORMAT_NV12) { 212 if (fb->format->format == DRM_FORMAT_NV12) {
218 plane = &omap_fb->planes[1]; 213 plane = &omap_fb->planes[1];
219 214
220 if (info->rotation_type == OMAP_DSS_ROT_TILER) { 215 if (info->rotation_type == OMAP_DSS_ROT_TILER) {
@@ -373,7 +368,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
373 const struct drm_format_info *format = NULL; 368 const struct drm_format_info *format = NULL;
374 struct omap_framebuffer *omap_fb = NULL; 369 struct omap_framebuffer *omap_fb = NULL;
375 struct drm_framebuffer *fb = NULL; 370 struct drm_framebuffer *fb = NULL;
376 u32 dss_format = 0;
377 unsigned int pitch = mode_cmd->pitches[0]; 371 unsigned int pitch = mode_cmd->pitches[0];
378 int ret, i; 372 int ret, i;
379 373
@@ -384,13 +378,11 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
384 format = drm_format_info(mode_cmd->pixel_format); 378 format = drm_format_info(mode_cmd->pixel_format);
385 379
386 for (i = 0; i < ARRAY_SIZE(formats); i++) { 380 for (i = 0; i < ARRAY_SIZE(formats); i++) {
387 if (formats[i].pixel_format == mode_cmd->pixel_format) { 381 if (formats[i] == mode_cmd->pixel_format)
388 dss_format = formats[i].dss_format;
389 break; 382 break;
390 }
391 } 383 }
392 384
393 if (!format || !dss_format) { 385 if (!format || i == ARRAY_SIZE(formats)) {
394 dev_dbg(dev->dev, "unsupported pixel format: %4.4s\n", 386 dev_dbg(dev->dev, "unsupported pixel format: %4.4s\n",
395 (char *)&mode_cmd->pixel_format); 387 (char *)&mode_cmd->pixel_format);
396 ret = -EINVAL; 388 ret = -EINVAL;
@@ -405,7 +397,6 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
405 397
406 fb = &omap_fb->base; 398 fb = &omap_fb->base;
407 omap_fb->format = format; 399 omap_fb->format = format;
408 omap_fb->dss_format = dss_format;
409 mutex_init(&omap_fb->lock); 400 mutex_init(&omap_fb->lock);
410 401
411 /* 402 /*