From 14cae363630d9ff4f10f926bbcc12305abb04ec6 Mon Sep 17 00:00:00 2001 From: Sandy Huang Date: Tue, 23 Jun 2020 17:18:02 +0800 Subject: [PATCH] drm/rockchip: rk3399 vop: add support more color space add support following color space: V4L2_COLORSPACE_SMPTE240M V4L2_COLORSPACE_470_SYSTEM_M V4L2_COLORSPACE_470_SYSTEM_BG now can support following color space: bt601 limit: V4L2_COLORSPACE_SMPTE170M V4L2_COLORSPACE_470_SYSTEM_M V4L2_COLORSPACE_470_SYSTEM_BG bt601 full: V4L2_COLORSPACE_JPEG bt709 limit: V4L2_COLORSPACE_SMPTE240M V4L2_COLORSPACE_REC709 V4L2_COLORSPACE_DEFAULT bt2020: V4L2_COLORSPACE_BT2020 Change-Id: Ia51b7aa9959f69efdd8bad3371395b2fceaccaaa Signed-off-by: Sandy Huang --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 21 +++++++++++++++++---- drivers/gpu/drm/rockchip/rockchip_vop_reg.c | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index d5c144630496..5f54a0171eb1 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -951,8 +951,11 @@ static int to_vop_csc_mode(int csc_mode) { switch (csc_mode) { case V4L2_COLORSPACE_SMPTE170M: + case V4L2_COLORSPACE_470_SYSTEM_M: + case V4L2_COLORSPACE_470_SYSTEM_BG: return CSC_BT601L; case V4L2_COLORSPACE_REC709: + case V4L2_COLORSPACE_SMPTE240M: case V4L2_COLORSPACE_DEFAULT: return CSC_BT709L; case V4L2_COLORSPACE_JPEG: @@ -1041,10 +1044,15 @@ static int vop_setup_csc_table(const struct vop_csc_table *csc_table, *r2r_table = csc_table->r2r_bt2020_to_bt709; if (!is_input_yuv || *y2r_table) { if (output_csc == V4L2_COLORSPACE_REC709 || + output_csc == V4L2_COLORSPACE_SMPTE240M || output_csc == V4L2_COLORSPACE_DEFAULT) *r2y_table = csc_table->r2y_bt709; + else if (output_csc == V4L2_COLORSPACE_SMPTE170M || + output_csc == V4L2_COLORSPACE_470_SYSTEM_M || + output_csc == V4L2_COLORSPACE_470_SYSTEM_BG) + *r2y_table = csc_table->r2y_bt601_12_235; /* bt601 limit */ else - *r2y_table = csc_table->r2y_bt601; + *r2y_table = csc_table->r2y_bt601; /* bt601 full */ } } } else { @@ -1059,11 +1067,16 @@ static int vop_setup_csc_table(const struct vop_csc_table *csc_table, if (input_csc == V4L2_COLORSPACE_BT2020) *y2r_table = csc_table->y2r_bt2020; - else if ((input_csc == V4L2_COLORSPACE_REC709) || - (input_csc == V4L2_COLORSPACE_DEFAULT)) + else if (input_csc == V4L2_COLORSPACE_REC709 || + input_csc == V4L2_COLORSPACE_SMPTE240M || + input_csc == V4L2_COLORSPACE_DEFAULT) *y2r_table = csc_table->y2r_bt709; + else if (input_csc == V4L2_COLORSPACE_SMPTE170M || + input_csc == V4L2_COLORSPACE_470_SYSTEM_M || + input_csc == V4L2_COLORSPACE_470_SYSTEM_BG) + *y2r_table = csc_table->y2r_bt601_12_235; /* bt601 limit */ else - *y2r_table = csc_table->y2r_bt601; + *y2r_table = csc_table->y2r_bt601; /* bt601 full */ if (input_csc == V4L2_COLORSPACE_BT2020) /* diff --git a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c index cdfcb2b19afd..66972216d6ae 100644 --- a/drivers/gpu/drm/rockchip/rockchip_vop_reg.c +++ b/drivers/gpu/drm/rockchip/rockchip_vop_reg.c @@ -506,7 +506,7 @@ static const struct vop_data rk3366_vop = { static const uint32_t vop_csc_y2r_bt601[] = { 0x00000400, 0x0400059c, 0xfd25fea0, 0x07170400, - 0x00000000, 0xfffecab4, 0x00087932, 0xfff1d4f2, + 0x00000000, 0xfff4cab4, 0x00087932, 0xfff1d4f2, }; static const uint32_t vop_csc_y2r_bt601_12_235[] = {