Commit 01e869e7 authored by Dikshita Agarwal's avatar Dikshita Agarwal Committed by Mauro Carvalho Chehab

media: venus: venc: fix handlig of S_SELECTION and G_SELECTION

- return correct width and height for G_SELECTION
- update capture port wxh with rectangle wxh.
- add support for HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO
  to set stride info and chroma offset to FW.
Signed-off-by: default avatarDikshita Agarwal <dikshita@codeaurora.org>
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent a76f43a4
...@@ -1662,3 +1662,21 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt, ...@@ -1662,3 +1662,21 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt,
return -EINVAL; return -EINVAL;
} }
EXPORT_SYMBOL_GPL(venus_helper_get_out_fmts); EXPORT_SYMBOL_GPL(venus_helper_get_out_fmts);
int venus_helper_set_stride(struct venus_inst *inst,
unsigned int width, unsigned int height)
{
const u32 ptype = HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO;
struct hfi_uncompressed_plane_actual_info plane_actual_info;
plane_actual_info.buffer_type = HFI_BUFFER_INPUT;
plane_actual_info.num_planes = 2;
plane_actual_info.plane_format[0].actual_stride = width;
plane_actual_info.plane_format[0].actual_plane_buffer_height = height;
plane_actual_info.plane_format[1].actual_stride = width;
plane_actual_info.plane_format[1].actual_plane_buffer_height = height / 2;
return hfi_session_set_property(inst, ptype, &plane_actual_info);
}
EXPORT_SYMBOL_GPL(venus_helper_set_stride);
...@@ -63,4 +63,6 @@ void venus_helper_get_ts_metadata(struct venus_inst *inst, u64 timestamp_us, ...@@ -63,4 +63,6 @@ void venus_helper_get_ts_metadata(struct venus_inst *inst, u64 timestamp_us,
struct vb2_v4l2_buffer *vbuf); struct vb2_v4l2_buffer *vbuf);
int venus_helper_get_profile_level(struct venus_inst *inst, u32 *profile, u32 *level); int venus_helper_get_profile_level(struct venus_inst *inst, u32 *profile, u32 *level);
int venus_helper_set_profile_level(struct venus_inst *inst, u32 profile, u32 level); int venus_helper_set_profile_level(struct venus_inst *inst, u32 profile, u32 level);
int venus_helper_set_stride(struct venus_inst *inst, unsigned int aligned_width,
unsigned int aligned_height);
#endif #endif
...@@ -1205,6 +1205,18 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt, ...@@ -1205,6 +1205,18 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu); pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu);
break; break;
} }
case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: {
struct hfi_uncompressed_plane_actual_info *in = pdata;
struct hfi_uncompressed_plane_actual_info *info = prop_data;
info->buffer_type = in->buffer_type;
info->num_planes = in->num_planes;
info->plane_format[0] = in->plane_format[0];
if (in->num_planes > 1)
info->plane_format[1] = in->plane_format[1];
pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info);
break;
}
case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE: case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER: case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE: case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:
......
...@@ -926,13 +926,13 @@ struct hfi_uncompressed_plane_actual { ...@@ -926,13 +926,13 @@ struct hfi_uncompressed_plane_actual {
struct hfi_uncompressed_plane_actual_info { struct hfi_uncompressed_plane_actual_info {
u32 buffer_type; u32 buffer_type;
u32 num_planes; u32 num_planes;
struct hfi_uncompressed_plane_actual plane_format[1]; struct hfi_uncompressed_plane_actual plane_format[2];
}; };
struct hfi_uncompressed_plane_actual_constraints_info { struct hfi_uncompressed_plane_actual_constraints_info {
u32 buffer_type; u32 buffer_type;
u32 num_planes; u32 num_planes;
struct hfi_uncompressed_plane_constraints plane_format[1]; struct hfi_uncompressed_plane_constraints plane_format[2];
}; };
struct hfi_codec_supported { struct hfi_codec_supported {
......
...@@ -190,8 +190,10 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f) ...@@ -190,8 +190,10 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
pixmp->height = clamp(pixmp->height, frame_height_min(inst), pixmp->height = clamp(pixmp->height, frame_height_min(inst),
frame_height_max(inst)); frame_height_max(inst));
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
pixmp->width = ALIGN(pixmp->width, 128);
pixmp->height = ALIGN(pixmp->height, 32); pixmp->height = ALIGN(pixmp->height, 32);
}
pixmp->width = ALIGN(pixmp->width, 2); pixmp->width = ALIGN(pixmp->width, 2);
pixmp->height = ALIGN(pixmp->height, 2); pixmp->height = ALIGN(pixmp->height, 2);
...@@ -335,13 +337,13 @@ venc_g_selection(struct file *file, void *fh, struct v4l2_selection *s) ...@@ -335,13 +337,13 @@ venc_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
switch (s->target) { switch (s->target) {
case V4L2_SEL_TGT_CROP_DEFAULT: case V4L2_SEL_TGT_CROP_DEFAULT:
case V4L2_SEL_TGT_CROP_BOUNDS: case V4L2_SEL_TGT_CROP_BOUNDS:
s->r.width = inst->width;
s->r.height = inst->height;
break;
case V4L2_SEL_TGT_CROP:
s->r.width = inst->out_width; s->r.width = inst->out_width;
s->r.height = inst->out_height; s->r.height = inst->out_height;
break; break;
case V4L2_SEL_TGT_CROP:
s->r.width = inst->width;
s->r.height = inst->height;
break;
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -360,12 +362,19 @@ venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s) ...@@ -360,12 +362,19 @@ venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
return -EINVAL; return -EINVAL;
if (s->r.width > inst->out_width ||
s->r.height > inst->out_height)
return -EINVAL;
s->r.width = ALIGN(s->r.width, 2);
s->r.height = ALIGN(s->r.height, 2);
switch (s->target) { switch (s->target) {
case V4L2_SEL_TGT_CROP: case V4L2_SEL_TGT_CROP:
if (s->r.width != inst->out_width || s->r.top = 0;
s->r.height != inst->out_height || s->r.left = 0;
s->r.top != 0 || s->r.left != 0) inst->width = s->r.width;
return -EINVAL; inst->height = s->r.height;
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -741,6 +750,11 @@ static int venc_init_session(struct venus_inst *inst) ...@@ -741,6 +750,11 @@ static int venc_init_session(struct venus_inst *inst)
else if (ret) else if (ret)
return ret; return ret;
ret = venus_helper_set_stride(inst, inst->out_width,
inst->out_height);
if (ret)
goto deinit;
ret = venus_helper_set_input_resolution(inst, inst->width, ret = venus_helper_set_input_resolution(inst, inst->width,
inst->height); inst->height);
if (ret) if (ret)
...@@ -828,8 +842,8 @@ static int venc_queue_setup(struct vb2_queue *q, ...@@ -828,8 +842,8 @@ static int venc_queue_setup(struct vb2_queue *q,
inst->num_input_bufs = *num_buffers; inst->num_input_bufs = *num_buffers;
sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt, sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt,
inst->width, inst->out_width,
inst->height); inst->out_height);
inst->input_buf_size = sizes[0]; inst->input_buf_size = sizes[0];
break; break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment