staging: drm/omap: get supported color formats from ovl
authorRob Clark <rob@ti.com>
Mon, 5 Mar 2012 16:48:31 +0000 (10:48 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Mar 2012 21:38:06 +0000 (13:38 -0800)
Get the supported formats for a plane from ovl's supported_modes
bitmask.

Signed-off-by: Rob Clark <rob@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/omapdrm/omap_drv.h
drivers/staging/omapdrm/omap_fb.c
drivers/staging/omapdrm/omap_plane.c

index 61fe022dda5b8f67c5629ce4e9bcad6625f8f4fc..d924c95c769ec37080169e7b58b7dfa95e1ffad5 100644 (file)
@@ -92,6 +92,8 @@ void omap_connector_mode_set(struct drm_connector *connector,
 void omap_connector_flush(struct drm_connector *connector,
                int x, int y, int w, int h);
 
+uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats,
+               uint32_t max_formats, enum omap_color_mode supported_modes);
 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
                struct drm_file *file, struct drm_mode_fb_cmd2 *mode_cmd);
 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
index d021a7ec58dfca6575df127a734bc6923bbc751d..116a8ff315aca8d4ace903979f9a627de4c38a5c 100644 (file)
@@ -59,6 +59,20 @@ static const struct format formats[] = {
        { OMAP_DSS_COLOR_UYVY,        DRM_FORMAT_UYVY,     {{2, 1}}, true },
 };
 
+/* convert from overlay's pixel formats bitmask to an array of fourcc's */
+uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats,
+               uint32_t max_formats, enum omap_color_mode supported_modes)
+{
+       uint32_t nformats = 0;
+       int i = 0;
+
+       for (i = 0; i < ARRAY_SIZE(formats) && nformats < max_formats; i++)
+               if (formats[i].dss_format & supported_modes)
+                       pixel_formats[nformats++] = formats[i].pixel_format;
+
+       return nformats;
+}
+
 /* per-plane info for the fb: */
 struct plane {
        struct drm_gem_object *bo;
index 97909124a1fedabf525ad55a6ea3314f4fbad0e3..c5625e3461bb14649ad8e5c613c4b7e97090eb35 100644 (file)
@@ -43,8 +43,10 @@ struct omap_plane {
 
        /* last fb that we pinned: */
        struct drm_framebuffer *pinned_fb;
-};
 
+       uint32_t nformats;
+       uint32_t formats[32];
+};
 
 /* push changes down to dss2 */
 static int commit(struct drm_plane *plane)
@@ -271,24 +273,6 @@ static const struct drm_plane_funcs omap_plane_funcs = {
                .destroy = omap_plane_destroy,
 };
 
-static const uint32_t formats[] = {
-               DRM_FORMAT_RGB565,
-               DRM_FORMAT_RGBX4444,
-               DRM_FORMAT_XRGB4444,
-               DRM_FORMAT_RGBA4444,
-               DRM_FORMAT_ABGR4444,
-               DRM_FORMAT_XRGB1555,
-               DRM_FORMAT_ARGB1555,
-               DRM_FORMAT_RGB888,
-               DRM_FORMAT_RGBX8888,
-               DRM_FORMAT_XRGB8888,
-               DRM_FORMAT_RGBA8888,
-               DRM_FORMAT_ARGB8888,
-               DRM_FORMAT_NV12,
-               DRM_FORMAT_YUYV,
-               DRM_FORMAT_UYVY,
-};
-
 /* initialize plane */
 struct drm_plane *omap_plane_init(struct drm_device *dev,
                struct omap_overlay *ovl, unsigned int possible_crtcs,
@@ -306,11 +290,14 @@ struct drm_plane *omap_plane_init(struct drm_device *dev,
                goto fail;
        }
 
+       omap_plane->nformats = omap_framebuffer_get_formats(
+                       omap_plane->formats, ARRAY_SIZE(omap_plane->formats),
+                       ovl->supported_modes);
        omap_plane->ovl = ovl;
        plane = &omap_plane->base;
 
        drm_plane_init(dev, plane, possible_crtcs, &omap_plane_funcs,
-                       formats, ARRAY_SIZE(formats), priv);
+                       omap_plane->formats, omap_plane->nformats, priv);
 
        /* get our starting configuration, set defaults for parameters
         * we don't currently use, etc: