Now that we introduced a new drm_output_color_format enum to represent
what DRM_COLOR_FORMAT_* bits were representing, we can switch to the new
enum.

The main difference is that while DRM_COLOR_FORMAT_ was a bitmask,
drm_output_color_format is a proper enum. However, the enum was done is
such a way than DRM_COLOR_FORMAT_X = BIT(DRM_OUTPUT_COLOR_FORMAT_X) so
the transitition is easier.

The only thing we need to consider is if the original code meant to use
that value as a bitmask, in which case we do need to keep the bit shift,
or as a discriminant in which case we don't.

Acked-by: Jani Nikula <[email protected]>
Signed-off-by: Maxime Ripard <[email protected]>
---
 drivers/gpu/drm/bridge/synopsys/dw-dp.c | 71 +++++++++++++++++----------------
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c 
b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
index 
8d2ab81d4a740a3efef27d0b479a604782b4b2a1..b05ac7bfb05bb7fadf451fd05ca561c4328584b0
 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
@@ -377,28 +377,28 @@ enum {
        DW_DP_PHY_PATTERN_CP2520_2,
 };
 
 struct dw_dp_output_format {
        u32 bus_format;
-       u32 color_format;
+       enum drm_output_color_format color_format;
        u8 video_mapping;
        u8 bpc;
        u8 bpp;
 };
 
 #define to_dw_dp_bridge_state(s) container_of(s, struct dw_dp_bridge_state, 
base)
 
 static const struct dw_dp_output_format dw_dp_output_formats[] = {
-       { MEDIA_BUS_FMT_RGB101010_1X30, DRM_COLOR_FORMAT_RGB444, 
DW_DP_RGB_10BIT, 10, 30 },
-       { MEDIA_BUS_FMT_RGB888_1X24, DRM_COLOR_FORMAT_RGB444, DW_DP_RGB_8BIT, 
8, 24 },
-       { MEDIA_BUS_FMT_YUV10_1X30, DRM_COLOR_FORMAT_YCBCR444, 
DW_DP_YCBCR444_10BIT, 10, 30 },
-       { MEDIA_BUS_FMT_YUV8_1X24, DRM_COLOR_FORMAT_YCBCR444, 
DW_DP_YCBCR444_8BIT, 8, 24},
-       { MEDIA_BUS_FMT_YUYV10_1X20, DRM_COLOR_FORMAT_YCBCR422, 
DW_DP_YCBCR422_10BIT, 10, 20 },
-       { MEDIA_BUS_FMT_YUYV8_1X16, DRM_COLOR_FORMAT_YCBCR422, 
DW_DP_YCBCR422_8BIT, 8, 16 },
-       { MEDIA_BUS_FMT_UYYVYY10_0_5X30, DRM_COLOR_FORMAT_YCBCR420, 
DW_DP_YCBCR420_10BIT, 10, 15 },
-       { MEDIA_BUS_FMT_UYYVYY8_0_5X24, DRM_COLOR_FORMAT_YCBCR420, 
DW_DP_YCBCR420_8BIT, 8, 12 },
-       { MEDIA_BUS_FMT_RGB666_1X24_CPADHI, DRM_COLOR_FORMAT_RGB444, 
DW_DP_RGB_6BIT, 6, 18 },
+       { MEDIA_BUS_FMT_RGB101010_1X30, DRM_OUTPUT_COLOR_FORMAT_RGB444, 
DW_DP_RGB_10BIT, 10, 30 },
+       { MEDIA_BUS_FMT_RGB888_1X24, DRM_OUTPUT_COLOR_FORMAT_RGB444, 
DW_DP_RGB_8BIT, 8, 24 },
+       { MEDIA_BUS_FMT_YUV10_1X30, DRM_OUTPUT_COLOR_FORMAT_YCBCR444, 
DW_DP_YCBCR444_10BIT, 10, 30 },
+       { MEDIA_BUS_FMT_YUV8_1X24, DRM_OUTPUT_COLOR_FORMAT_YCBCR444, 
DW_DP_YCBCR444_8BIT, 8, 24},
+       { MEDIA_BUS_FMT_YUYV10_1X20, DRM_OUTPUT_COLOR_FORMAT_YCBCR422, 
DW_DP_YCBCR422_10BIT, 10, 20 },
+       { MEDIA_BUS_FMT_YUYV8_1X16, DRM_OUTPUT_COLOR_FORMAT_YCBCR422, 
DW_DP_YCBCR422_8BIT, 8, 16 },
+       { MEDIA_BUS_FMT_UYYVYY10_0_5X30, DRM_OUTPUT_COLOR_FORMAT_YCBCR420, 
DW_DP_YCBCR420_10BIT, 10, 15 },
+       { MEDIA_BUS_FMT_UYYVYY8_0_5X24, DRM_OUTPUT_COLOR_FORMAT_YCBCR420, 
DW_DP_YCBCR420_8BIT, 8, 12 },
+       { MEDIA_BUS_FMT_RGB666_1X24_CPADHI, DRM_OUTPUT_COLOR_FORMAT_RGB444, 
DW_DP_RGB_6BIT, 6, 18 },
 };
 
 static const struct dw_dp_output_format *dw_dp_get_output_format(u32 
bus_format)
 {
        unsigned int i;
@@ -1089,26 +1089,26 @@ static int dw_dp_send_vsc_sdp(struct dw_dp *dp)
        vsc.content_type = DP_CONTENT_TYPE_NOT_DEFINED;
 
        sdp.flags = DW_DP_SDP_VERTICAL_INTERVAL;
 
        switch (state->color_format) {
-       case DRM_COLOR_FORMAT_YCBCR444:
+       case DRM_OUTPUT_COLOR_FORMAT_YCBCR444:
                vsc.pixelformat = DP_PIXELFORMAT_YUV444;
                break;
-       case DRM_COLOR_FORMAT_YCBCR420:
+       case DRM_OUTPUT_COLOR_FORMAT_YCBCR420:
                vsc.pixelformat = DP_PIXELFORMAT_YUV420;
                break;
-       case DRM_COLOR_FORMAT_YCBCR422:
+       case DRM_OUTPUT_COLOR_FORMAT_YCBCR422:
                vsc.pixelformat = DP_PIXELFORMAT_YUV422;
                break;
-       case DRM_COLOR_FORMAT_RGB444:
+       case DRM_OUTPUT_COLOR_FORMAT_RGB444:
        default:
                vsc.pixelformat = DP_PIXELFORMAT_RGB;
                break;
        }
 
-       if (state->color_format == DRM_COLOR_FORMAT_RGB444) {
+       if (state->color_format == DRM_OUTPUT_COLOR_FORMAT_RGB444) {
                vsc.colorimetry = DP_COLORIMETRY_DEFAULT;
                vsc.dynamic_range = DP_DYNAMIC_RANGE_VESA;
        } else {
                vsc.colorimetry = DP_COLORIMETRY_BT709_YCC;
                vsc.dynamic_range = DP_DYNAMIC_RANGE_CTA;
@@ -1146,35 +1146,36 @@ static bool dw_dp_video_need_vsc_sdp(struct dw_dp *dp)
                return -EINVAL;
 
        if (!link->vsc_sdp_supported)
                return false;
 
-       if (state->color_format == DRM_COLOR_FORMAT_YCBCR420)
+       if (state->color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420)
                return true;
 
        return false;
 }
 
-static int dw_dp_video_set_msa(struct dw_dp *dp, u8 color_format, u8 bpc,
-                              u16 vstart, u16 hstart)
+static int dw_dp_video_set_msa(struct dw_dp *dp,
+                              enum drm_output_color_format color_format,
+                              u8 bpc, u16 vstart, u16 hstart)
 {
        u16 misc = 0;
 
        if (dw_dp_video_need_vsc_sdp(dp))
                misc |= DP_MSA_MISC_COLOR_VSC_SDP;
 
        switch (color_format) {
-       case DRM_COLOR_FORMAT_RGB444:
+       case DRM_OUTPUT_COLOR_FORMAT_RGB444:
                misc |= DP_MSA_MISC_COLOR_RGB;
                break;
-       case DRM_COLOR_FORMAT_YCBCR444:
+       case DRM_OUTPUT_COLOR_FORMAT_YCBCR444:
                misc |= DP_MSA_MISC_COLOR_YCBCR_444_BT709;
                break;
-       case DRM_COLOR_FORMAT_YCBCR422:
+       case DRM_OUTPUT_COLOR_FORMAT_YCBCR422:
                misc |= DP_MSA_MISC_COLOR_YCBCR_422_BT709;
                break;
-       case DRM_COLOR_FORMAT_YCBCR420:
+       case DRM_OUTPUT_COLOR_FORMAT_YCBCR420:
                break;
        default:
                return -EINVAL;
        }
 
@@ -1302,13 +1303,13 @@ static int dw_dp_video_enable(struct dw_dp *dp)
        average_bytes_per_tu = ts / 1000;
        average_bytes_per_tu_frac = ts / 100 - average_bytes_per_tu * 10;
        if (dp->pixel_mode == DW_DP_MP_SINGLE_PIXEL) {
                if (average_bytes_per_tu < 6)
                        init_threshold = 32;
-               else if (hblank <= 80 && color_format != 
DRM_COLOR_FORMAT_YCBCR420)
+               else if (hblank <= 80 && color_format != 
DRM_OUTPUT_COLOR_FORMAT_YCBCR420)
                        init_threshold = 12;
-               else if (hblank <= 40 && color_format == 
DRM_COLOR_FORMAT_YCBCR420)
+               else if (hblank <= 40 && color_format == 
DRM_OUTPUT_COLOR_FORMAT_YCBCR420)
                        init_threshold = 3;
                else
                        init_threshold = 16;
        } else {
                u32 t1 = 0, t2 = 0, t3 = 0;
@@ -1316,47 +1317,47 @@ static int dw_dp_video_enable(struct dw_dp *dp)
                switch (bpc) {
                case 6:
                        t1 = (4 * 1000 / 9) * link->lanes;
                        break;
                case 8:
-                       if (color_format == DRM_COLOR_FORMAT_YCBCR422) {
+                       if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR422) {
                                t1 = (1000 / 2) * link->lanes;
                        } else {
                                if (dp->pixel_mode == DW_DP_MP_DUAL_PIXEL)
                                        t1 = (1000 / 3) * link->lanes;
                                else
                                        t1 = (3000 / 16) * link->lanes;
                        }
                        break;
                case 10:
-                       if (color_format == DRM_COLOR_FORMAT_YCBCR422)
+                       if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR422)
                                t1 = (2000 / 5) * link->lanes;
                        else
                                t1 = (4000 / 15) * link->lanes;
                        break;
                case 12:
-                       if (color_format == DRM_COLOR_FORMAT_YCBCR422) {
+                       if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR422) {
                                if (dp->pixel_mode == DW_DP_MP_DUAL_PIXEL)
                                        t1 = (1000 / 6) * link->lanes;
                                else
                                        t1 = (1000 / 3) * link->lanes;
                        } else {
                                t1 = (2000 / 9) * link->lanes;
                        }
                        break;
                case 16:
-                       if (color_format != DRM_COLOR_FORMAT_YCBCR422 &&
+                       if (color_format != DRM_OUTPUT_COLOR_FORMAT_YCBCR422 &&
                            dp->pixel_mode == DW_DP_MP_DUAL_PIXEL)
                                t1 = (1000 / 6) * link->lanes;
                        else
                                t1 = (1000 / 4) * link->lanes;
                        break;
                default:
                        return -EINVAL;
                }
 
-               if (color_format == DRM_COLOR_FORMAT_YCBCR420)
+               if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420)
                        t2 = (link->rate / 4) * 1000 / (mode->clock / 2);
                else
                        t2 = (link->rate / 4) * 1000 / mode->clock;
 
                if (average_bytes_per_tu_frac)
@@ -1572,17 +1573,17 @@ static enum drm_mode_status 
dw_dp_bridge_mode_valid(struct drm_bridge *bridge,
 {
        struct dw_dp *dp = bridge_to_dp(bridge);
        struct dw_dp_link *link = &dp->link;
        u32 min_bpp;
 
-       if (info->color_formats & DRM_COLOR_FORMAT_YCBCR420 &&
+       if (info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420) &&
            link->vsc_sdp_supported &&
            (drm_mode_is_420_only(info, mode) || drm_mode_is_420_also(info, 
mode)))
                min_bpp = 12;
-       else if (info->color_formats & DRM_COLOR_FORMAT_YCBCR422)
+       else if (info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422))
                min_bpp = 16;
-       else if (info->color_formats & DRM_COLOR_FORMAT_RGB444)
+       else if (info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444))
                min_bpp = 18;
        else
                min_bpp = 24;
 
        if (!link->vsc_sdp_supported &&
@@ -1775,18 +1776,18 @@ static u32 
*dw_dp_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
                fmt = &dw_dp_output_formats[i];
 
                if (fmt->bpc > conn_state->max_bpc)
                        continue;
 
-               if (!(fmt->color_format & di->color_formats))
+               if (!(BIT(fmt->color_format) & di->color_formats))
                        continue;
 
-               if (fmt->color_format == DRM_COLOR_FORMAT_YCBCR420 &&
+               if (fmt->color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420 &&
                    !link->vsc_sdp_supported)
                        continue;
 
-               if (fmt->color_format != DRM_COLOR_FORMAT_YCBCR420 &&
+               if (fmt->color_format != DRM_OUTPUT_COLOR_FORMAT_YCBCR420 &&
                    drm_mode_is_420_only(di, &mode))
                        continue;
 
                if (!dw_dp_bandwidth_ok(dp, &mode, fmt->bpp, link->lanes, 
link->rate))
                        continue;

-- 
2.53.0

Reply via email to