Skip to content

Commit 01e869e

Browse files
Dikshita Agarwalmchehab
authored andcommitted
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: Dikshita Agarwal <[email protected]> Signed-off-by: Stanimir Varbanov <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent a76f43a commit 01e869e

File tree

5 files changed

+59
-13
lines changed

5 files changed

+59
-13
lines changed

drivers/media/platform/qcom/venus/helpers.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,3 +1662,21 @@ int venus_helper_get_out_fmts(struct venus_inst *inst, u32 v4l2_fmt,
16621662
return -EINVAL;
16631663
}
16641664
EXPORT_SYMBOL_GPL(venus_helper_get_out_fmts);
1665+
1666+
int venus_helper_set_stride(struct venus_inst *inst,
1667+
unsigned int width, unsigned int height)
1668+
{
1669+
const u32 ptype = HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO;
1670+
1671+
struct hfi_uncompressed_plane_actual_info plane_actual_info;
1672+
1673+
plane_actual_info.buffer_type = HFI_BUFFER_INPUT;
1674+
plane_actual_info.num_planes = 2;
1675+
plane_actual_info.plane_format[0].actual_stride = width;
1676+
plane_actual_info.plane_format[0].actual_plane_buffer_height = height;
1677+
plane_actual_info.plane_format[1].actual_stride = width;
1678+
plane_actual_info.plane_format[1].actual_plane_buffer_height = height / 2;
1679+
1680+
return hfi_session_set_property(inst, ptype, &plane_actual_info);
1681+
}
1682+
EXPORT_SYMBOL_GPL(venus_helper_set_stride);

drivers/media/platform/qcom/venus/helpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ void venus_helper_get_ts_metadata(struct venus_inst *inst, u64 timestamp_us,
6363
struct vb2_v4l2_buffer *vbuf);
6464
int venus_helper_get_profile_level(struct venus_inst *inst, u32 *profile, u32 *level);
6565
int venus_helper_set_profile_level(struct venus_inst *inst, u32 profile, u32 level);
66+
int venus_helper_set_stride(struct venus_inst *inst, unsigned int aligned_width,
67+
unsigned int aligned_height);
6668
#endif

drivers/media/platform/qcom/venus/hfi_cmds.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,18 @@ pkt_session_set_property_4xx(struct hfi_session_set_property_pkt *pkt,
12051205
pkt->shdr.hdr.size += sizeof(u32) + sizeof(*cu);
12061206
break;
12071207
}
1208+
case HFI_PROPERTY_PARAM_UNCOMPRESSED_PLANE_ACTUAL_INFO: {
1209+
struct hfi_uncompressed_plane_actual_info *in = pdata;
1210+
struct hfi_uncompressed_plane_actual_info *info = prop_data;
1211+
1212+
info->buffer_type = in->buffer_type;
1213+
info->num_planes = in->num_planes;
1214+
info->plane_format[0] = in->plane_format[0];
1215+
if (in->num_planes > 1)
1216+
info->plane_format[1] = in->plane_format[1];
1217+
pkt->shdr.hdr.size += sizeof(u32) + sizeof(*info);
1218+
break;
1219+
}
12081220
case HFI_PROPERTY_CONFIG_VENC_MAX_BITRATE:
12091221
case HFI_PROPERTY_CONFIG_VDEC_POST_LOOP_DEBLOCKER:
12101222
case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE:

drivers/media/platform/qcom/venus/hfi_helper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,13 +926,13 @@ struct hfi_uncompressed_plane_actual {
926926
struct hfi_uncompressed_plane_actual_info {
927927
u32 buffer_type;
928928
u32 num_planes;
929-
struct hfi_uncompressed_plane_actual plane_format[1];
929+
struct hfi_uncompressed_plane_actual plane_format[2];
930930
};
931931

932932
struct hfi_uncompressed_plane_actual_constraints_info {
933933
u32 buffer_type;
934934
u32 num_planes;
935-
struct hfi_uncompressed_plane_constraints plane_format[1];
935+
struct hfi_uncompressed_plane_constraints plane_format[2];
936936
};
937937

938938
struct hfi_codec_supported {

drivers/media/platform/qcom/venus/venc.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ venc_try_fmt_common(struct venus_inst *inst, struct v4l2_format *f)
190190
pixmp->height = clamp(pixmp->height, frame_height_min(inst),
191191
frame_height_max(inst));
192192

193-
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
193+
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
194+
pixmp->width = ALIGN(pixmp->width, 128);
194195
pixmp->height = ALIGN(pixmp->height, 32);
196+
}
195197

196198
pixmp->width = ALIGN(pixmp->width, 2);
197199
pixmp->height = ALIGN(pixmp->height, 2);
@@ -335,13 +337,13 @@ venc_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
335337
switch (s->target) {
336338
case V4L2_SEL_TGT_CROP_DEFAULT:
337339
case V4L2_SEL_TGT_CROP_BOUNDS:
338-
s->r.width = inst->width;
339-
s->r.height = inst->height;
340-
break;
341-
case V4L2_SEL_TGT_CROP:
342340
s->r.width = inst->out_width;
343341
s->r.height = inst->out_height;
344342
break;
343+
case V4L2_SEL_TGT_CROP:
344+
s->r.width = inst->width;
345+
s->r.height = inst->height;
346+
break;
345347
default:
346348
return -EINVAL;
347349
}
@@ -360,12 +362,19 @@ venc_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
360362
if (s->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
361363
return -EINVAL;
362364

365+
if (s->r.width > inst->out_width ||
366+
s->r.height > inst->out_height)
367+
return -EINVAL;
368+
369+
s->r.width = ALIGN(s->r.width, 2);
370+
s->r.height = ALIGN(s->r.height, 2);
371+
363372
switch (s->target) {
364373
case V4L2_SEL_TGT_CROP:
365-
if (s->r.width != inst->out_width ||
366-
s->r.height != inst->out_height ||
367-
s->r.top != 0 || s->r.left != 0)
368-
return -EINVAL;
374+
s->r.top = 0;
375+
s->r.left = 0;
376+
inst->width = s->r.width;
377+
inst->height = s->r.height;
369378
break;
370379
default:
371380
return -EINVAL;
@@ -741,6 +750,11 @@ static int venc_init_session(struct venus_inst *inst)
741750
else if (ret)
742751
return ret;
743752

753+
ret = venus_helper_set_stride(inst, inst->out_width,
754+
inst->out_height);
755+
if (ret)
756+
goto deinit;
757+
744758
ret = venus_helper_set_input_resolution(inst, inst->width,
745759
inst->height);
746760
if (ret)
@@ -828,8 +842,8 @@ static int venc_queue_setup(struct vb2_queue *q,
828842
inst->num_input_bufs = *num_buffers;
829843

830844
sizes[0] = venus_helper_get_framesz(inst->fmt_out->pixfmt,
831-
inst->width,
832-
inst->height);
845+
inst->out_width,
846+
inst->out_height);
833847
inst->input_buf_size = sizes[0];
834848
break;
835849
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:

0 commit comments

Comments
 (0)