drm/omap: change supported_modes to an array
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 4 May 2017 07:27:53 +0000 (10:27 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 2 Jun 2017 07:57:23 +0000 (10:57 +0300)
enum omap_color_mode is a bitmask, so at the moment we present the
supported color modes as mask. To be able to move to fourccs, we need to
use an array to present the supported color modes.

As a first step towards fourccs, this patch changes the code to use an
array to store the enums.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/gpu/drm/omapdrm/dss/dispc.c
drivers/gpu/drm/omapdrm/dss/dss_features.c
drivers/gpu/drm/omapdrm/dss/dss_features.h
drivers/gpu/drm/omapdrm/dss/omapdss.h
drivers/gpu/drm/omapdrm/omap_drv.h
drivers/gpu/drm/omapdrm/omap_fb.c

index ee874129b2025c834a6140fd7092067b544a165a..5836756a23a989783666ee5fea9a74cbba8a671d 100644 (file)
@@ -1140,7 +1140,7 @@ static u32 dispc_ovl_get_burst_size(enum omap_plane_id plane)
        return unit * 8;
 }
 
-static enum omap_color_mode dispc_ovl_get_color_modes(enum omap_plane_id plane)
+static const enum omap_color_mode *dispc_ovl_get_color_modes(enum omap_plane_id plane)
 {
        return dss_feat_get_supported_color_modes(plane);
 }
index bdac1d645ef01b2804e8f67c950ba87ab7f4209f..f9b0324cc263d545f3141f44c6b8d7683f16b154 100644 (file)
@@ -47,7 +47,7 @@ struct omap_dss_features {
        const int num_ovls;
        const enum omap_display_type *supported_displays;
        const enum omap_dss_output_id *supported_outputs;
-       const enum omap_color_mode *supported_color_modes;
+       const enum omap_color_mode **supported_color_modes;
        const enum omap_overlay_caps *overlay_caps;
        const struct dss_param_range *dss_params;
 
@@ -229,90 +229,104 @@ static const enum omap_dss_output_id omap5_dss_supported_outputs[] = {
        OMAP_DSS_OUTPUT_DSI2,
 };
 
-static const enum omap_color_mode omap2_dss_supported_color_modes[] = {
+#define COLOR_ARRAY(arr...) (const enum omap_color_mode[]) { arr, 0 }
+
+static const enum omap_color_mode *omap2_dss_supported_color_modes[] = {
+
        /* OMAP_DSS_GFX */
-       OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
-       OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_RGB16,
+       OMAP_DSS_COLOR_RGB24U, OMAP_DSS_COLOR_RGB24P),
 
        /* OMAP_DSS_VIDEO1 */
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
-       OMAP_DSS_COLOR_UYVY,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2,
+       OMAP_DSS_COLOR_UYVY),
 
        /* OMAP_DSS_VIDEO2 */
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
-       OMAP_DSS_COLOR_UYVY,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2,
+       OMAP_DSS_COLOR_UYVY),
 };
 
-static const enum omap_color_mode omap3_dss_supported_color_modes[] = {
+static const enum omap_color_mode *omap3_dss_supported_color_modes[] = {
        /* OMAP_DSS_GFX */
-       OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
-       OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16,
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_ARGB32,
+       OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32),
 
        /* OMAP_DSS_VIDEO1 */
-       OMAP_DSS_COLOR_RGB24U | OMAP_DSS_COLOR_RGB24P |
-       OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_RGB16 |
-       OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_UYVY,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB24U, OMAP_DSS_COLOR_RGB24P,
+       OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_RGB16,
+       OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_UYVY),
 
        /* OMAP_DSS_VIDEO2 */
-       OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_YUV2 |
-       OMAP_DSS_COLOR_UYVY | OMAP_DSS_COLOR_ARGB32 |
-       OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16,
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_YUV2,
+       OMAP_DSS_COLOR_UYVY, OMAP_DSS_COLOR_ARGB32,
+       OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32),
 };
 
-static const enum omap_color_mode omap4_dss_supported_color_modes[] = {
+static const enum omap_color_mode *omap4_dss_supported_color_modes[] = {
        /* OMAP_DSS_GFX */
-       OMAP_DSS_COLOR_RGB12U | OMAP_DSS_COLOR_ARGB16 |
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_ARGB32 |
-       OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_RGBX32 |
-       OMAP_DSS_COLOR_ARGB16_1555 | OMAP_DSS_COLOR_RGBX16 |
-       OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_XRGB16_1555,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB12U, OMAP_DSS_COLOR_ARGB16,
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_ARGB32,
+       OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_RGBX32,
+       OMAP_DSS_COLOR_ARGB16_1555, OMAP_DSS_COLOR_RGBX16,
+       OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_XRGB16_1555),
 
        /* OMAP_DSS_VIDEO1 */
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
-       OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
-       OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
-       OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
-       OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
-       OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
-       OMAP_DSS_COLOR_RGBX32,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U,
+       OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555,
+       OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12,
+       OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY,
+       OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555,
+       OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16,
+       OMAP_DSS_COLOR_RGBX32),
 
        /* OMAP_DSS_VIDEO2 */
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
-       OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
-       OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
-       OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
-       OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
-       OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
-       OMAP_DSS_COLOR_RGBX32,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U,
+       OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555,
+       OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12,
+       OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY,
+       OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555,
+       OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16,
+       OMAP_DSS_COLOR_RGBX32),
 
        /* OMAP_DSS_VIDEO3 */
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
-       OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
-       OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
-       OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
-       OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
-       OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
-       OMAP_DSS_COLOR_RGBX32,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U,
+       OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555,
+       OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12,
+       OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY,
+       OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555,
+       OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16,
+       OMAP_DSS_COLOR_RGBX32),
 
        /* OMAP_DSS_WB */
-       OMAP_DSS_COLOR_RGB16 | OMAP_DSS_COLOR_RGB12U |
-       OMAP_DSS_COLOR_YUV2 | OMAP_DSS_COLOR_ARGB16_1555 |
-       OMAP_DSS_COLOR_RGBA32 | OMAP_DSS_COLOR_NV12 |
-       OMAP_DSS_COLOR_RGBA16 | OMAP_DSS_COLOR_RGB24U |
-       OMAP_DSS_COLOR_RGB24P | OMAP_DSS_COLOR_UYVY |
-       OMAP_DSS_COLOR_ARGB16 | OMAP_DSS_COLOR_XRGB16_1555 |
-       OMAP_DSS_COLOR_ARGB32 | OMAP_DSS_COLOR_RGBX16 |
-       OMAP_DSS_COLOR_RGBX32,
+       COLOR_ARRAY(
+       OMAP_DSS_COLOR_RGB16, OMAP_DSS_COLOR_RGB12U,
+       OMAP_DSS_COLOR_YUV2, OMAP_DSS_COLOR_ARGB16_1555,
+       OMAP_DSS_COLOR_RGBA32, OMAP_DSS_COLOR_NV12,
+       OMAP_DSS_COLOR_RGBA16, OMAP_DSS_COLOR_RGB24U,
+       OMAP_DSS_COLOR_RGB24P, OMAP_DSS_COLOR_UYVY,
+       OMAP_DSS_COLOR_ARGB16, OMAP_DSS_COLOR_XRGB16_1555,
+       OMAP_DSS_COLOR_ARGB32, OMAP_DSS_COLOR_RGBX16,
+       OMAP_DSS_COLOR_RGBX32),
 };
 
 static const enum omap_overlay_caps omap2_dss_overlay_caps[] = {
@@ -783,7 +797,7 @@ enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel
        return omap_current_dss_features->supported_outputs[channel];
 }
 
-enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane_id plane)
+const enum omap_color_mode *dss_feat_get_supported_color_modes(enum omap_plane_id plane)
 {
        return omap_current_dss_features->supported_color_modes[plane];
 }
@@ -796,8 +810,17 @@ enum omap_overlay_caps dss_feat_get_overlay_caps(enum omap_plane_id plane)
 bool dss_feat_color_mode_supported(enum omap_plane_id plane,
                enum omap_color_mode color_mode)
 {
-       return omap_current_dss_features->supported_color_modes[plane] &
-                       color_mode;
+       const enum omap_color_mode *modes;
+       unsigned int i;
+
+       modes = omap_current_dss_features->supported_color_modes[plane];
+
+       for (i = 0; modes[i]; ++i) {
+               if (modes[i] == color_mode)
+                       return true;
+       }
+
+       return false;
 }
 
 u32 dss_feat_get_buffer_size_unit(void)
index 6f262887502d73b4f7d71a1ac2663f0ed02724b2..190cf62537b0e16139171ae2caffd67305ade87c 100644 (file)
@@ -104,6 +104,6 @@ enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel
 
 int dss_feat_get_num_mgrs(void);
 int dss_feat_get_num_ovls(void);
-enum omap_color_mode dss_feat_get_supported_color_modes(enum omap_plane_id plane);
+const enum omap_color_mode *dss_feat_get_supported_color_modes(enum omap_plane_id plane);
 
 #endif
index e12cfaeb5b24ffdf49fc2b0e38e6533c48ece8bf..83be1f57fdb5557084c0eff332e5966a8f2f9043 100644 (file)
@@ -734,7 +734,7 @@ struct dispc_ops {
                        const struct videomode *vm, bool mem_to_mem,
                        enum omap_channel channel);
 
-       enum omap_color_mode (*ovl_get_color_modes)(enum omap_plane_id plane);
+       const enum omap_color_mode *(*ovl_get_color_modes)(enum omap_plane_id plane);
 };
 
 void dispc_set_ops(const struct dispc_ops *o);
index ea3f575931c344c74c36a94f2c352d14e35b42c9..ef061a53e2319ef34c3ba43b5b89603312c039f1 100644 (file)
@@ -151,7 +151,7 @@ struct drm_encoder *omap_connector_attached_encoder(
 bool omap_connector_get_hdmi_mode(struct drm_connector *connector);
 
 uint32_t omap_framebuffer_get_formats(uint32_t *pixel_formats,
-               uint32_t max_formats, enum omap_color_mode supported_modes);
+               uint32_t max_formats, const enum omap_color_mode *supported_modes);
 struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
                struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd);
 struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
index 1d2a94df7054ce9c29ee4fc3d6211b61e633a19c..6fb25d35bc0a07f6a90344029525fa61ccc268a0 100644 (file)
@@ -57,14 +57,22 @@ static const struct {
 
 /* 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 max_formats, const 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)
+       for (i = 0; i < ARRAY_SIZE(formats) && nformats < max_formats; i++) {
+               unsigned int t;
+
+               for (t = 0; supported_modes[t]; ++t) {
+                       if (supported_modes[t] != formats[i].dss_format)
+                               continue;
+
                        pixel_formats[nformats++] = formats[i].pixel_format;
+                       break;
+               }
+       }
 
        return nformats;
 }