mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
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>
This commit is contained in:
parent
a90bd3baff
commit
04b4e39a14
|
|
@ -379,7 +379,7 @@ enum {
|
|||
|
||||
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;
|
||||
|
|
@ -388,15 +388,15 @@ struct dw_dp_output_format {
|
|||
#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)
|
||||
|
|
@ -1091,22 +1091,22 @@ static int dw_dp_send_vsc_sdp(struct dw_dp *dp)
|
|||
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 {
|
||||
|
|
@ -1148,14 +1148,15 @@ static bool dw_dp_video_need_vsc_sdp(struct dw_dp *dp)
|
|||
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;
|
||||
|
||||
|
|
@ -1163,16 +1164,16 @@ static int dw_dp_video_set_msa(struct dw_dp *dp, u8 color_format, u8 bpc,
|
|||
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;
|
||||
|
|
@ -1304,9 +1305,9 @@ static int dw_dp_video_enable(struct dw_dp *dp)
|
|||
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;
|
||||
|
|
@ -1318,7 +1319,7 @@ static int dw_dp_video_enable(struct dw_dp *dp)
|
|||
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)
|
||||
|
|
@ -1328,13 +1329,13 @@ static int dw_dp_video_enable(struct dw_dp *dp)
|
|||
}
|
||||
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
|
||||
|
|
@ -1344,7 +1345,7 @@ static int dw_dp_video_enable(struct dw_dp *dp)
|
|||
}
|
||||
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
|
||||
|
|
@ -1354,7 +1355,7 @@ static int dw_dp_video_enable(struct dw_dp *dp)
|
|||
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;
|
||||
|
|
@ -1574,13 +1575,13 @@ static enum drm_mode_status dw_dp_bridge_mode_valid(struct drm_bridge *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;
|
||||
|
|
@ -1777,14 +1778,14 @@ static u32 *dw_dp_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
|
|||
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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user