media: rockchip: vicap: toisp mode add memory compact config

if isp work in isp_unit mode and hdr mode and online mode,
buffer addr for half frame of right side must 16 byte align,
otherwise, the buffer to ddr need config to uncompact

Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
Change-Id: I29792f2fbeed410d0c640b8bee27f741915086be
This commit is contained in:
Zefa Chen
2022-12-07 19:09:36 +08:00
committed by Tao Huang
parent b93d530269
commit 34ea3eb483
5 changed files with 41 additions and 13 deletions

View File

@@ -765,8 +765,8 @@ set_default:
return NULL;
}
static const struct
cif_output_fmt *find_output_fmt(struct rkcif_stream *stream, u32 pixelfmt)
const struct
cif_output_fmt *rkcif_find_output_fmt(struct rkcif_stream *stream, u32 pixelfmt)
{
const struct cif_output_fmt *fmt;
u32 i;
@@ -2770,7 +2770,7 @@ static int rkcif_csi_channel_init(struct rkcif_stream *stream,
if (dev->sditf_cnt > 1 && dev->sditf_cnt <= RKCIF_MAX_SDITF)
channel->height *= dev->sditf_cnt;
fmt = find_output_fmt(stream, stream->pixm.pixelformat);
fmt = rkcif_find_output_fmt(stream, stream->pixm.pixelformat);
if (!fmt) {
v4l2_err(&dev->v4l2_dev, "can not find output format: 0x%x",
stream->pixm.pixelformat);
@@ -3838,6 +3838,10 @@ int rkcif_init_rx_buf(struct rkcif_stream *stream, int buf_num)
buf->dbufs.type = frm_type;
list_add_tail(&buf->list, &stream->rx_buf_head);
dummy->is_free = false;
if (stream->is_compact)
buf->dbufs.is_uncompact = false;
else
buf->dbufs.is_uncompact = true;
if (priv && priv->mode.rdbk_mode == RKISP_VICAP_ONLINE && i == 0) {
buf->dbufs.is_first = true;
rkcif_s_rx_buffer(dev, &buf->dbufs);
@@ -4908,7 +4912,7 @@ static int rkcif_stream_start(struct rkcif_stream *stream, unsigned int mode)
if (dev->chip_id >= CHIP_RK3588_CIF) {
val = stream->pixm.plane_fmt[0].bytesperline;
} else {
fmt = find_output_fmt(stream, stream->pixm.pixelformat);
fmt = rkcif_find_output_fmt(stream, stream->pixm.pixelformat);
if (fmt->fmt_type == CIF_FMT_TYPE_RAW &&
fmt->csi_fmt_val == CSI_WRDDR_TYPE_RAW8)
val = ALIGN(stream->pixm.width * fmt->raw_bpp / 8, 256);
@@ -5350,7 +5354,7 @@ int rkcif_set_fmt(struct rkcif_stream *stream,
for (i = 0; i < RKCIF_MAX_PLANE; i++)
memset(&pixm->plane_fmt[i], 0, sizeof(struct v4l2_plane_pix_format));
fmt = find_output_fmt(stream, pixm->pixelformat);
fmt = rkcif_find_output_fmt(stream, pixm->pixelformat);
if (!fmt)
fmt = &out_fmts[0];
@@ -5703,7 +5707,7 @@ static int rkcif_enum_framesizes(struct file *file, void *prov,
if (fsize->index != 0)
return -EINVAL;
if (!find_output_fmt(stream, fsize->pixel_format))
if (!rkcif_find_output_fmt(stream, fsize->pixel_format))
return -EINVAL;
input_rect.width = RKCIF_DEFAULT_WIDTH;
@@ -7051,7 +7055,7 @@ static void rkcif_cal_csi_crop_width_vwidth(struct rkcif_stream *stream,
const struct cif_output_fmt *fmt;
u32 fourcc;
fmt = find_output_fmt(stream, stream->pixm.pixelformat);
fmt = rkcif_find_output_fmt(stream, stream->pixm.pixelformat);
if (!fmt) {
v4l2_err(&dev->v4l2_dev, "can not find output format: 0x%x",
stream->pixm.pixelformat);
@@ -7152,7 +7156,7 @@ static void rkcif_dynamic_crop(struct rkcif_stream *stream)
crop_y << CIF_CROP_Y_SHIFT | crop_x);
if (stream->cif_fmt_in->fmt_type == CIF_FMT_TYPE_RAW) {
fmt = find_output_fmt(stream, stream->pixm.pixelformat);
fmt = rkcif_find_output_fmt(stream, stream->pixm.pixelformat);
crop_vwidth = raw_width * rkcif_cal_raw_vir_line_ratio(stream, fmt);
}
rkcif_write_register(cif_dev, CIF_REG_DVP_VIR_LINE_WIDTH, crop_vwidth);

View File

@@ -112,7 +112,7 @@ static u32 rkcif_scale_align_bits_per_pixel(struct rkcif_device *cif_dev,
static const struct
cif_output_fmt *find_output_fmt(u32 pixelfmt)
cif_output_fmt *rkcif_scale_find_output_fmt(u32 pixelfmt)
{
const struct cif_output_fmt *fmt;
u32 i;
@@ -169,7 +169,7 @@ static int rkcif_scale_set_fmt(struct rkcif_scale_vdev *scale_vdev,
scale_vdev->src_res.width = fmt_src.format.width;
scale_vdev->src_res.height = fmt_src.format.height;
}
fmt = find_output_fmt(pixm->pixelformat);
fmt = rkcif_scale_find_output_fmt(pixm->pixelformat);
if (fmt == NULL) {
v4l2_err(&scale_vdev->cifdev->v4l2_dev,
"format of source channel are not bayer raw, not support scale\n");
@@ -355,7 +355,7 @@ static int rkcif_scale_enum_framesizes(struct file *file, void *prov,
if (fsize->index >= RKCIF_SCALE_ENUM_SIZE_MAX)
return -EINVAL;
if (!find_output_fmt(fsize->pixel_format))
if (!rkcif_scale_find_output_fmt(fsize->pixel_format))
return -EINVAL;
input_rect.width = RKCIF_DEFAULT_WIDTH;

View File

@@ -150,7 +150,7 @@ static int rkcif_tools_g_fmt_vid_cap_mplane(struct file *file, void *priv,
}
static const struct
cif_output_fmt *find_output_fmt(u32 pixelfmt)
cif_output_fmt *rkcif_tools_find_output_fmt(u32 pixelfmt)
{
const struct cif_output_fmt *fmt;
u32 i;
@@ -293,7 +293,7 @@ static int rkcif_tools_enum_framesizes(struct file *file, void *prov,
if (fsize->index >= ARRAY_SIZE(tools_out_fmts))
return -EINVAL;
if (!find_output_fmt(fsize->pixel_format))
if (!rkcif_tools_find_output_fmt(fsize->pixel_format))
return -EINVAL;
input_rect.width = RKCIF_DEFAULT_WIDTH;

View File

@@ -904,4 +904,7 @@ struct rkcif_rx_buffer *to_cif_rx_buf(struct rkisp_rx_buf *dbufs);
int rkcif_clr_unready_dev(void);
const struct
cif_output_fmt *rkcif_find_output_fmt(struct rkcif_stream *stream, u32 pixelfmt);
#endif

View File

@@ -126,7 +126,9 @@ static int sditf_get_set_fmt(struct v4l2_subdev *sd,
struct rkcif_device *cif_dev = priv->cif_dev;
struct v4l2_subdev_selection input_sel;
struct v4l2_pix_format_mplane pixm;
const struct cif_output_fmt *out_fmt;
int ret = -EINVAL;
bool is_uncompact = false;
if (!cif_dev->terminal_sensor.sd)
rkcif_update_sensor_info(&cif_dev->stream[0]);
@@ -157,6 +159,10 @@ static int sditf_get_set_fmt(struct v4l2_subdev *sd,
pixm.pixelformat = rkcif_mbus_pixelcode_to_v4l2(fmt->format.code);
pixm.width = priv->cap_info.width;
pixm.height = priv->cap_info.height;
out_fmt = rkcif_find_output_fmt(NULL, pixm.pixelformat);
if (priv->toisp_inf.link_mode == TOISP_UNITE &&
((pixm.width / 2 - RKMOUDLE_UNITE_EXTEND_PIXEL) * out_fmt->raw_bpp / 8) & 0xf)
is_uncompact = true;
v4l2_dbg(3, rkcif_debug, &cif_dev->v4l2_dev,
"%s, width %d, height %d, hdr mode %d\n",
__func__, fmt->format.width, fmt->format.height, priv->hdr_cfg.hdr_mode);
@@ -164,9 +170,24 @@ static int sditf_get_set_fmt(struct v4l2_subdev *sd,
priv->hdr_cfg.hdr_mode == HDR_COMPR) {
rkcif_set_fmt(&cif_dev->stream[0], &pixm, false);
} else if (priv->hdr_cfg.hdr_mode == HDR_X2) {
if (is_uncompact) {
cif_dev->stream[0].is_compact = false;
cif_dev->stream[0].is_high_align = true;
} else {
cif_dev->stream[0].is_compact = true;
}
rkcif_set_fmt(&cif_dev->stream[0], &pixm, false);
rkcif_set_fmt(&cif_dev->stream[1], &pixm, false);
} else if (priv->hdr_cfg.hdr_mode == HDR_X3) {
if (is_uncompact) {
cif_dev->stream[0].is_compact = false;
cif_dev->stream[0].is_high_align = true;
cif_dev->stream[1].is_compact = false;
cif_dev->stream[1].is_high_align = true;
} else {
cif_dev->stream[0].is_compact = true;
cif_dev->stream[1].is_compact = true;
}
rkcif_set_fmt(&cif_dev->stream[0], &pixm, false);
rkcif_set_fmt(&cif_dev->stream[1], &pixm, false);
rkcif_set_fmt(&cif_dev->stream[2], &pixm, false);