Skip to content

Commit fc1e985

Browse files
committed
drm/imx: ipuv3-plane: add color encoding and range properties
Add COLOR_ENCODING and COLOR_RANGE plane properties and use them to control the DP CSC matrix. Signed-off-by: Philipp Zabel <[email protected]>
1 parent 4618cb7 commit fc1e985

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

drivers/gpu/drm/imx/ipuv3-plane.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ static void ipu_plane_state_reset(struct drm_plane *plane)
313313
__drm_atomic_helper_plane_reset(plane, &ipu_state->base);
314314
ipu_state->base.zpos = zpos;
315315
ipu_state->base.normalized_zpos = zpos;
316+
ipu_state->base.color_encoding = DRM_COLOR_YCBCR_BT601;
317+
ipu_state->base.color_range = DRM_COLOR_YCBCR_LIMITED_RANGE;
316318
}
317319
}
318320

@@ -632,6 +634,25 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
632634
fb->modifier, &eba);
633635
}
634636

637+
if (!old_state->fb ||
638+
old_state->fb->format->format != fb->format->format ||
639+
old_state->color_encoding != new_state->color_encoding ||
640+
old_state->color_range != new_state->color_range) {
641+
ics = ipu_drm_fourcc_to_colorspace(fb->format->format);
642+
switch (ipu_plane->dp_flow) {
643+
case IPU_DP_FLOW_SYNC_BG:
644+
ipu_dp_setup_channel(ipu_plane->dp, new_state->color_encoding,
645+
new_state->color_range, ics,
646+
IPUV3_COLORSPACE_RGB);
647+
break;
648+
case IPU_DP_FLOW_SYNC_FG:
649+
ipu_dp_setup_channel(ipu_plane->dp, new_state->color_encoding,
650+
new_state->color_range, ics,
651+
IPUV3_COLORSPACE_UNKNOWN);
652+
break;
653+
}
654+
}
655+
635656
if (old_state->fb && !drm_atomic_crtc_needs_modeset(crtc_state)) {
636657
/* nothing to do if PRE is used */
637658
if (ipu_state->use_pre)
@@ -662,7 +683,7 @@ static void ipu_plane_atomic_update(struct drm_plane *plane,
662683
break;
663684
}
664685

665-
ipu_dmfc_config_wait4eot(ipu_plane->dmfc, ALIGN(drm_rect_width(dst), 8));
686+
ipu_dmfc_config_wait4eot(ipu_plane->dmfc, drm_rect_width(dst));
666687

667688
width = ipu_src_rect_width(new_state);
668689
height = drm_rect_height(&new_state->src) >> 16;
@@ -911,6 +932,15 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
911932
if (ret)
912933
return ERR_PTR(ret);
913934

935+
ret = drm_plane_create_color_properties(&ipu_plane->base,
936+
BIT(DRM_COLOR_YCBCR_BT601) |
937+
BIT(DRM_COLOR_YCBCR_BT709),
938+
BIT(DRM_COLOR_YCBCR_LIMITED_RANGE),
939+
DRM_COLOR_YCBCR_BT601,
940+
DRM_COLOR_YCBCR_LIMITED_RANGE);
941+
if (ret)
942+
return ERR_PTR(ret);
943+
914944
ret = ipu_plane_get_resources(dev, ipu_plane);
915945
if (ret) {
916946
DRM_ERROR("failed to get %s plane resources: %pe\n",

0 commit comments

Comments
 (0)