Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/bridge: synopsys: dw-dp: Convert to drm_output_color_format

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 <jani.nikula@intel.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260305-drm-rework-color-formats-v3-8-f3935f6db579@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>

+36 -35
+36 -35
drivers/gpu/drm/bridge/synopsys/dw-dp.c
··· 379 379 380 380 struct dw_dp_output_format { 381 381 u32 bus_format; 382 - u32 color_format; 382 + enum drm_output_color_format color_format; 383 383 u8 video_mapping; 384 384 u8 bpc; 385 385 u8 bpp; ··· 388 388 #define to_dw_dp_bridge_state(s) container_of(s, struct dw_dp_bridge_state, base) 389 389 390 390 static const struct dw_dp_output_format dw_dp_output_formats[] = { 391 - { MEDIA_BUS_FMT_RGB101010_1X30, DRM_COLOR_FORMAT_RGB444, DW_DP_RGB_10BIT, 10, 30 }, 392 - { MEDIA_BUS_FMT_RGB888_1X24, DRM_COLOR_FORMAT_RGB444, DW_DP_RGB_8BIT, 8, 24 }, 393 - { MEDIA_BUS_FMT_YUV10_1X30, DRM_COLOR_FORMAT_YCBCR444, DW_DP_YCBCR444_10BIT, 10, 30 }, 394 - { MEDIA_BUS_FMT_YUV8_1X24, DRM_COLOR_FORMAT_YCBCR444, DW_DP_YCBCR444_8BIT, 8, 24}, 395 - { MEDIA_BUS_FMT_YUYV10_1X20, DRM_COLOR_FORMAT_YCBCR422, DW_DP_YCBCR422_10BIT, 10, 20 }, 396 - { MEDIA_BUS_FMT_YUYV8_1X16, DRM_COLOR_FORMAT_YCBCR422, DW_DP_YCBCR422_8BIT, 8, 16 }, 397 - { MEDIA_BUS_FMT_UYYVYY10_0_5X30, DRM_COLOR_FORMAT_YCBCR420, DW_DP_YCBCR420_10BIT, 10, 15 }, 398 - { MEDIA_BUS_FMT_UYYVYY8_0_5X24, DRM_COLOR_FORMAT_YCBCR420, DW_DP_YCBCR420_8BIT, 8, 12 }, 399 - { MEDIA_BUS_FMT_RGB666_1X24_CPADHI, DRM_COLOR_FORMAT_RGB444, DW_DP_RGB_6BIT, 6, 18 }, 391 + { MEDIA_BUS_FMT_RGB101010_1X30, DRM_OUTPUT_COLOR_FORMAT_RGB444, DW_DP_RGB_10BIT, 10, 30 }, 392 + { MEDIA_BUS_FMT_RGB888_1X24, DRM_OUTPUT_COLOR_FORMAT_RGB444, DW_DP_RGB_8BIT, 8, 24 }, 393 + { MEDIA_BUS_FMT_YUV10_1X30, DRM_OUTPUT_COLOR_FORMAT_YCBCR444, DW_DP_YCBCR444_10BIT, 10, 30 }, 394 + { MEDIA_BUS_FMT_YUV8_1X24, DRM_OUTPUT_COLOR_FORMAT_YCBCR444, DW_DP_YCBCR444_8BIT, 8, 24}, 395 + { MEDIA_BUS_FMT_YUYV10_1X20, DRM_OUTPUT_COLOR_FORMAT_YCBCR422, DW_DP_YCBCR422_10BIT, 10, 20 }, 396 + { MEDIA_BUS_FMT_YUYV8_1X16, DRM_OUTPUT_COLOR_FORMAT_YCBCR422, DW_DP_YCBCR422_8BIT, 8, 16 }, 397 + { MEDIA_BUS_FMT_UYYVYY10_0_5X30, DRM_OUTPUT_COLOR_FORMAT_YCBCR420, DW_DP_YCBCR420_10BIT, 10, 15 }, 398 + { MEDIA_BUS_FMT_UYYVYY8_0_5X24, DRM_OUTPUT_COLOR_FORMAT_YCBCR420, DW_DP_YCBCR420_8BIT, 8, 12 }, 399 + { MEDIA_BUS_FMT_RGB666_1X24_CPADHI, DRM_OUTPUT_COLOR_FORMAT_RGB444, DW_DP_RGB_6BIT, 6, 18 }, 400 400 }; 401 401 402 402 static const struct dw_dp_output_format *dw_dp_get_output_format(u32 bus_format) ··· 1091 1091 sdp.flags = DW_DP_SDP_VERTICAL_INTERVAL; 1092 1092 1093 1093 switch (state->color_format) { 1094 - case DRM_COLOR_FORMAT_YCBCR444: 1094 + case DRM_OUTPUT_COLOR_FORMAT_YCBCR444: 1095 1095 vsc.pixelformat = DP_PIXELFORMAT_YUV444; 1096 1096 break; 1097 - case DRM_COLOR_FORMAT_YCBCR420: 1097 + case DRM_OUTPUT_COLOR_FORMAT_YCBCR420: 1098 1098 vsc.pixelformat = DP_PIXELFORMAT_YUV420; 1099 1099 break; 1100 - case DRM_COLOR_FORMAT_YCBCR422: 1100 + case DRM_OUTPUT_COLOR_FORMAT_YCBCR422: 1101 1101 vsc.pixelformat = DP_PIXELFORMAT_YUV422; 1102 1102 break; 1103 - case DRM_COLOR_FORMAT_RGB444: 1103 + case DRM_OUTPUT_COLOR_FORMAT_RGB444: 1104 1104 default: 1105 1105 vsc.pixelformat = DP_PIXELFORMAT_RGB; 1106 1106 break; 1107 1107 } 1108 1108 1109 - if (state->color_format == DRM_COLOR_FORMAT_RGB444) { 1109 + if (state->color_format == DRM_OUTPUT_COLOR_FORMAT_RGB444) { 1110 1110 vsc.colorimetry = DP_COLORIMETRY_DEFAULT; 1111 1111 vsc.dynamic_range = DP_DYNAMIC_RANGE_VESA; 1112 1112 } else { ··· 1148 1148 if (!link->vsc_sdp_supported) 1149 1149 return false; 1150 1150 1151 - if (state->color_format == DRM_COLOR_FORMAT_YCBCR420) 1151 + if (state->color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420) 1152 1152 return true; 1153 1153 1154 1154 return false; 1155 1155 } 1156 1156 1157 - static int dw_dp_video_set_msa(struct dw_dp *dp, u8 color_format, u8 bpc, 1158 - u16 vstart, u16 hstart) 1157 + static int dw_dp_video_set_msa(struct dw_dp *dp, 1158 + enum drm_output_color_format color_format, 1159 + u8 bpc, u16 vstart, u16 hstart) 1159 1160 { 1160 1161 u16 misc = 0; 1161 1162 ··· 1164 1163 misc |= DP_MSA_MISC_COLOR_VSC_SDP; 1165 1164 1166 1165 switch (color_format) { 1167 - case DRM_COLOR_FORMAT_RGB444: 1166 + case DRM_OUTPUT_COLOR_FORMAT_RGB444: 1168 1167 misc |= DP_MSA_MISC_COLOR_RGB; 1169 1168 break; 1170 - case DRM_COLOR_FORMAT_YCBCR444: 1169 + case DRM_OUTPUT_COLOR_FORMAT_YCBCR444: 1171 1170 misc |= DP_MSA_MISC_COLOR_YCBCR_444_BT709; 1172 1171 break; 1173 - case DRM_COLOR_FORMAT_YCBCR422: 1172 + case DRM_OUTPUT_COLOR_FORMAT_YCBCR422: 1174 1173 misc |= DP_MSA_MISC_COLOR_YCBCR_422_BT709; 1175 1174 break; 1176 - case DRM_COLOR_FORMAT_YCBCR420: 1175 + case DRM_OUTPUT_COLOR_FORMAT_YCBCR420: 1177 1176 break; 1178 1177 default: 1179 1178 return -EINVAL; ··· 1305 1304 if (dp->pixel_mode == DW_DP_MP_SINGLE_PIXEL) { 1306 1305 if (average_bytes_per_tu < 6) 1307 1306 init_threshold = 32; 1308 - else if (hblank <= 80 && color_format != DRM_COLOR_FORMAT_YCBCR420) 1307 + else if (hblank <= 80 && color_format != DRM_OUTPUT_COLOR_FORMAT_YCBCR420) 1309 1308 init_threshold = 12; 1310 - else if (hblank <= 40 && color_format == DRM_COLOR_FORMAT_YCBCR420) 1309 + else if (hblank <= 40 && color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420) 1311 1310 init_threshold = 3; 1312 1311 else 1313 1312 init_threshold = 16; ··· 1319 1318 t1 = (4 * 1000 / 9) * link->lanes; 1320 1319 break; 1321 1320 case 8: 1322 - if (color_format == DRM_COLOR_FORMAT_YCBCR422) { 1321 + if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR422) { 1323 1322 t1 = (1000 / 2) * link->lanes; 1324 1323 } else { 1325 1324 if (dp->pixel_mode == DW_DP_MP_DUAL_PIXEL) ··· 1329 1328 } 1330 1329 break; 1331 1330 case 10: 1332 - if (color_format == DRM_COLOR_FORMAT_YCBCR422) 1331 + if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR422) 1333 1332 t1 = (2000 / 5) * link->lanes; 1334 1333 else 1335 1334 t1 = (4000 / 15) * link->lanes; 1336 1335 break; 1337 1336 case 12: 1338 - if (color_format == DRM_COLOR_FORMAT_YCBCR422) { 1337 + if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR422) { 1339 1338 if (dp->pixel_mode == DW_DP_MP_DUAL_PIXEL) 1340 1339 t1 = (1000 / 6) * link->lanes; 1341 1340 else ··· 1345 1344 } 1346 1345 break; 1347 1346 case 16: 1348 - if (color_format != DRM_COLOR_FORMAT_YCBCR422 && 1347 + if (color_format != DRM_OUTPUT_COLOR_FORMAT_YCBCR422 && 1349 1348 dp->pixel_mode == DW_DP_MP_DUAL_PIXEL) 1350 1349 t1 = (1000 / 6) * link->lanes; 1351 1350 else ··· 1355 1354 return -EINVAL; 1356 1355 } 1357 1356 1358 - if (color_format == DRM_COLOR_FORMAT_YCBCR420) 1357 + if (color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420) 1359 1358 t2 = (link->rate / 4) * 1000 / (mode->clock / 2); 1360 1359 else 1361 1360 t2 = (link->rate / 4) * 1000 / mode->clock; ··· 1575 1574 struct dw_dp_link *link = &dp->link; 1576 1575 u32 min_bpp; 1577 1576 1578 - if (info->color_formats & DRM_COLOR_FORMAT_YCBCR420 && 1577 + if (info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420) && 1579 1578 link->vsc_sdp_supported && 1580 1579 (drm_mode_is_420_only(info, mode) || drm_mode_is_420_also(info, mode))) 1581 1580 min_bpp = 12; 1582 - else if (info->color_formats & DRM_COLOR_FORMAT_YCBCR422) 1581 + else if (info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422)) 1583 1582 min_bpp = 16; 1584 - else if (info->color_formats & DRM_COLOR_FORMAT_RGB444) 1583 + else if (info->color_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444)) 1585 1584 min_bpp = 18; 1586 1585 else 1587 1586 min_bpp = 24; ··· 1778 1777 if (fmt->bpc > conn_state->max_bpc) 1779 1778 continue; 1780 1779 1781 - if (!(fmt->color_format & di->color_formats)) 1780 + if (!(BIT(fmt->color_format) & di->color_formats)) 1782 1781 continue; 1783 1782 1784 - if (fmt->color_format == DRM_COLOR_FORMAT_YCBCR420 && 1783 + if (fmt->color_format == DRM_OUTPUT_COLOR_FORMAT_YCBCR420 && 1785 1784 !link->vsc_sdp_supported) 1786 1785 continue; 1787 1786 1788 - if (fmt->color_format != DRM_COLOR_FORMAT_YCBCR420 && 1787 + if (fmt->color_format != DRM_OUTPUT_COLOR_FORMAT_YCBCR420 && 1789 1788 drm_mode_is_420_only(di, &mode)) 1790 1789 continue; 1791 1790