media: venus: vdec: get required input buffers as well

Rework and rename vdec_cap_num_buffers() to get the number of
input buffers too.

Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
Stanimir Varbanov 2018-07-05 09:03:56 -04:00 committed by Mauro Carvalho Chehab
parent 130c0117e8
commit 7094af54c5
1 changed files with 24 additions and 17 deletions

View File

@ -601,19 +601,32 @@ deinit:
return ret;
}
static int vdec_cap_num_buffers(struct venus_inst *inst, unsigned int *num)
static int vdec_num_buffers(struct venus_inst *inst, unsigned int *in_num,
unsigned int *out_num)
{
enum hfi_version ver = inst->core->res->hfi_version;
struct hfi_buffer_requirements bufreq;
int ret;
*in_num = *out_num = 0;
ret = vdec_init_session(inst);
if (ret)
return ret;
ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq);
if (ret)
goto deinit;
*in_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
if (ret)
goto deinit;
*num = bufreq.count_actual;
*out_num = HFI_BUFREQ_COUNT_MIN(&bufreq, ver);
deinit:
hfi_session_deinit(inst);
return ret;
@ -624,7 +637,7 @@ static int vdec_queue_setup(struct vb2_queue *q,
unsigned int sizes[], struct device *alloc_devs[])
{
struct venus_inst *inst = vb2_get_drv_priv(q);
unsigned int p, num;
unsigned int p, in_num, out_num;
int ret = 0;
if (*num_planes) {
@ -647,35 +660,29 @@ static int vdec_queue_setup(struct vb2_queue *q,
return 0;
}
ret = vdec_num_buffers(inst, &in_num, &out_num);
if (ret)
return ret;
switch (q->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
*num_planes = inst->fmt_out->num_planes;
sizes[0] = get_framesize_compressed(inst->out_width,
inst->out_height);
inst->input_buf_size = sizes[0];
*num_buffers = max(*num_buffers, in_num);
inst->num_input_bufs = *num_buffers;
ret = vdec_cap_num_buffers(inst, &num);
if (ret)
break;
inst->num_output_bufs = num;
inst->num_output_bufs = out_num;
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
*num_planes = inst->fmt_cap->num_planes;
ret = vdec_cap_num_buffers(inst, &num);
if (ret)
break;
*num_buffers = max(*num_buffers, num);
for (p = 0; p < *num_planes; p++)
sizes[p] = get_framesize_uncompressed(p, inst->width,
inst->height);
inst->num_output_bufs = *num_buffers;
inst->output_buf_size = sizes[0];
*num_buffers = max(*num_buffers, out_num);
inst->num_output_bufs = *num_buffers;
break;
default:
ret = -EINVAL;