video: rockchip: rga3: fix check err when enable R2Y & Y2R

Fixes: 9e5cbd33fc ("video: rockchip: rga3: add check_csc")

Signed-off-by: Yu Qiaowei <cerf.yu@rock-chips.com>
Change-Id: Id374afe218d5aea57105a4761d2d78ccf2560de6
This commit is contained in:
Yu Qiaowei
2025-04-02 17:56:13 +08:00
committed by Tao Huang
parent 98e67d8722
commit dd79e039dc
2 changed files with 48 additions and 35 deletions

View File

@@ -69,6 +69,17 @@
RGA_MODE_X_MIRROR | \
RGA_MODE_Y_MIRROR)
enum rga_csc_mode {
RGA_Y2R_BT601_LIMIT = 0x1 << 0,
RGA_Y2R_BT601_FULL = 0x2 << 0,
RGA_Y2R_BT709_LIMIT = 0x3 << 0,
RGA_Y2R_MASK = 0x3 << 0,
RGA_R2Y_BT601_LIMIT = 0x2 << 0,
RGA_R2Y_BT601_FULL = 0x1 << 0,
RGA_R2Y_BT709_LIMIT = 0x3 << 0,
RGA_R2Y_MASK = 0x3 << 0,
};
enum rga_memory_type {
RGA_DMA_BUFFER = 0,
RGA_VIRTUAL_ADDRESS,

View File

@@ -44,50 +44,52 @@ static int rga_set_feature(struct rga_req *rga_base)
return feature;
}
static bool rga_check_csc_constant(const struct rga_hw_data *data, struct rga_req *rga_base,
uint32_t mode, uint32_t flag)
{
if (mode & flag)
return true;
if ((rga_base->full_csc.flag & 0x1) && (data->feature & RGA_FULL_CSC))
return true;
return false;
}
static bool rga_check_csc(const struct rga_hw_data *data, struct rga_req *rga_base)
{
switch (rga_base->yuv2rgb_mode) {
case 0x1:
return rga_check_csc_constant(data, rga_base,
data->csc_y2r_mode, RGA_MODE_CSC_BT601L);
case 0x2:
return rga_check_csc_constant(data, rga_base,
data->csc_y2r_mode, RGA_MODE_CSC_BT601F);
case 0x3:
return rga_check_csc_constant(data, rga_base,
data->csc_y2r_mode, RGA_MODE_CSC_BT709);
case 0x1 << 2:
return rga_check_csc_constant(data, rga_base,
data->csc_r2y_mode, RGA_MODE_CSC_BT601F);
case 0x2 << 2:
return rga_check_csc_constant(data, rga_base,
data->csc_r2y_mode, RGA_MODE_CSC_BT601L);
case 0x3 << 2:
return rga_check_csc_constant(data, rga_base,
data->csc_r2y_mode, RGA_MODE_CSC_BT709);
switch (rga_base->yuv2rgb_mode & RGA_Y2R_MASK) {
case RGA_Y2R_BT601_LIMIT:
if (!(data->csc_y2r_mode & RGA_MODE_CSC_BT601L))
return false;
break;
case RGA_Y2R_BT601_FULL:
if (!(data->csc_y2r_mode & RGA_MODE_CSC_BT601F))
return false;
break;
case RGA_Y2R_BT709_LIMIT:
if (!(data->csc_y2r_mode & RGA_MODE_CSC_BT709))
return false;
break;
default:
break;
}
if ((rga_base->full_csc.flag & 0x1)) {
if (data->feature & RGA_FULL_CSC)
return true;
else
switch (rga_base->yuv2rgb_mode & RGA_R2Y_MASK) {
case RGA_R2Y_BT601_LIMIT:
if (!(data->csc_r2y_mode & RGA_MODE_CSC_BT601L))
return false;
break;
case RGA_R2Y_BT601_FULL:
if (!(data->csc_r2y_mode & RGA_MODE_CSC_BT601F))
return false;
break;
case RGA_R2Y_BT709_LIMIT:
if (!(data->csc_r2y_mode & RGA_MODE_CSC_BT709))
return false;
break;
default:
break;
}
if ((rga_base->full_csc.flag & 0x1) && !(data->feature & RGA_FULL_CSC))
return false;
return true;
}