mbox series

[0/3] Venus dynamic resolution change fixes

Message ID 20200928164431.21884-1-stanimir.varbanov@linaro.org
Headers show
Series Venus dynamic resolution change fixes | expand

Message

Stanimir Varbanov Sept. 28, 2020, 4:44 p.m. UTC
Hi all,

Those three patches are needed to fix setting of LAST buffer flag during
dynamic-resolution-change state.

The first patch in this series fix the LAST buffer flag setting, the second
unify the driver behavior no matter the event from firmware is sufficient or
insufficient resources and the third one is moving the locking from buf_queue
helper function to encoder and decoder buf_queue vb2 ops.

Comments are welcome!

Stanimir Varbanov (3):
  venus: vdec: Fix non reliable setting of LAST flag
  venus: vdec: Make decoder return LAST flag for sufficient event
  venus: helpers: Lock outside of buffer queue helper

 drivers/media/platform/qcom/venus/core.h    |  5 +-
 drivers/media/platform/qcom/venus/helpers.c | 15 ++--
 drivers/media/platform/qcom/venus/vdec.c    | 92 +++++++++++++--------
 drivers/media/platform/qcom/venus/venc.c    | 11 ++-
 4 files changed, 76 insertions(+), 47 deletions(-)

Comments

Vikash Garodia Oct. 7, 2020, 7:53 p.m. UTC | #1
Hi Stan,

On 2020-09-28 22:14, Stanimir Varbanov wrote:
> This makes the decoder to behaives equally for sufficient and
behaves

> insufficient events. After this change the LAST buffer flag will be set
> when the new resolution (in dynamic-resolution-change state) is smaller
> then the old bitstream resolution.
> 
> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
> ---
>  drivers/media/platform/qcom/venus/vdec.c | 41 ++++++++++++++++--------
>  1 file changed, 27 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/vdec.c
> b/drivers/media/platform/qcom/venus/vdec.c
> index c11bdf3ca21b..c006401255dc 100644
> --- a/drivers/media/platform/qcom/venus/vdec.c
> +++ b/drivers/media/platform/qcom/venus/vdec.c
> @@ -634,6 +634,7 @@ static int vdec_output_conf(struct venus_inst 
> *inst)
>  {
>  	struct venus_core *core = inst->core;
>  	struct hfi_enable en = { .enable = 1 };
> +	struct hfi_buffer_requirements bufreq;
>  	u32 width = inst->out_width;
>  	u32 height = inst->out_height;
>  	u32 out_fmt, out2_fmt;
> @@ -709,6 +710,22 @@ static int vdec_output_conf(struct venus_inst 
> *inst)
>  	}
> 
>  	if (IS_V3(core) || IS_V4(core)) {
> +		ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
> +		if (ret)
> +			return ret;
> +
> +		if (bufreq.size > inst->output_buf_size)
> +			return -EINVAL;
> +
> +		if (inst->dpb_fmt) {
> +			ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT2, &bufreq);
> +			if (ret)
> +				return ret;
> +
> +			if (bufreq.size > inst->output2_buf_size)
> +				return -EINVAL;
> +		}
> +
>  		if (inst->output2_buf_size) {
>  			ret = venus_helper_set_bufsize(inst,
>  						       inst->output2_buf_size,
> @@ -1327,19 +1344,15 @@ static void vdec_event_change(struct venus_inst 
> *inst,
>  	dev_dbg(dev, VDBGM "event %s sufficient resources (%ux%u)\n",
>  		sufficient ? "" : "not", ev_data->width, ev_data->height);
> 
> -	if (sufficient) {
> -		hfi_session_continue(inst);
> -	} else {
> -		switch (inst->codec_state) {
> -		case VENUS_DEC_STATE_INIT:
> -			inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
> -			break;
> -		case VENUS_DEC_STATE_DECODING:
> -			inst->codec_state = VENUS_DEC_STATE_DRC;
> -			break;
> -		default:
> -			break;
> -		}
> +	switch (inst->codec_state) {
> +	case VENUS_DEC_STATE_INIT:
> +		inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
> +		break;
> +	case VENUS_DEC_STATE_DECODING:
> +		inst->codec_state = VENUS_DEC_STATE_DRC;

Video firmware would raise reconfig event to driver even for cases like
interlace detection, color space change in the bitstream. If not with 
this patch,
we can optimize by sending reconfig event only for resolution and 
bitdepth update,
in a followup patch.

> +		break;
> +	default:
> +		break;
>  	}
> 
>  	/*
> @@ -1348,7 +1361,7 @@ static void vdec_event_change(struct venus_inst 
> *inst,
>  	 * itself doesn't mark the last decoder output buffer with HFI EOS 
> flag.
>  	 */
> 
> -	if (!sufficient && inst->codec_state == VENUS_DEC_STATE_DRC) {
> +	if (inst->codec_state == VENUS_DEC_STATE_DRC) {
>  		struct vb2_v4l2_buffer *last;
>  		int ret;
Vikash Garodia Oct. 7, 2020, 8:03 p.m. UTC | #2
Hi Stan,

On 2020-09-28 22:14, Stanimir Varbanov wrote:
> Hi all,
> 
> Those three patches are needed to fix setting of LAST buffer flag 
> during
> dynamic-resolution-change state.
> 
> The first patch in this series fix the LAST buffer flag setting, the 
> second
> unify the driver behavior no matter the event from firmware is 
> sufficient or
> insufficient resources and the third one is moving the locking from 
> buf_queue
> helper function to encoder and decoder buf_queue vb2 ops.
> 
> Comments are welcome!
> 
> Stanimir Varbanov (3):
>   venus: vdec: Fix non reliable setting of LAST flag
>   venus: vdec: Make decoder return LAST flag for sufficient event
>   venus: helpers: Lock outside of buffer queue helper
> 
>  drivers/media/platform/qcom/venus/core.h    |  5 +-
>  drivers/media/platform/qcom/venus/helpers.c | 15 ++--
>  drivers/media/platform/qcom/venus/vdec.c    | 92 +++++++++++++--------
>  drivers/media/platform/qcom/venus/venc.c    | 11 ++-
>  4 files changed, 76 insertions(+), 47 deletions(-)

I have made some comments which are more towards optimizing the reconfig 
event
handling in the driver. I would leave that up to you to either update in 
this series
or take it separately. Either way, i am good with this series.

Reviewed-by: Vikash Garodia <vgarodia@codeaurora.org>
Stanimir Varbanov Oct. 10, 2020, 1:21 a.m. UTC | #3
Hi Vikash,

On 10/7/20 10:53 PM, vgarodia@codeaurora.org wrote:
> Hi Stan,
> 
> On 2020-09-28 22:14, Stanimir Varbanov wrote:
>> This makes the decoder to behaives equally for sufficient and
> behaves
> 
>> insufficient events. After this change the LAST buffer flag will be set
>> when the new resolution (in dynamic-resolution-change state) is smaller
>> then the old bitstream resolution.
>>
>> Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
>> ---
>>  drivers/media/platform/qcom/venus/vdec.c | 41 ++++++++++++++++--------
>>  1 file changed, 27 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/media/platform/qcom/venus/vdec.c
>> b/drivers/media/platform/qcom/venus/vdec.c
>> index c11bdf3ca21b..c006401255dc 100644
>> --- a/drivers/media/platform/qcom/venus/vdec.c
>> +++ b/drivers/media/platform/qcom/venus/vdec.c
>> @@ -634,6 +634,7 @@ static int vdec_output_conf(struct venus_inst *inst)
>>  {
>>      struct venus_core *core = inst->core;
>>      struct hfi_enable en = { .enable = 1 };
>> +    struct hfi_buffer_requirements bufreq;
>>      u32 width = inst->out_width;
>>      u32 height = inst->out_height;
>>      u32 out_fmt, out2_fmt;
>> @@ -709,6 +710,22 @@ static int vdec_output_conf(struct venus_inst *inst)
>>      }
>>
>>      if (IS_V3(core) || IS_V4(core)) {
>> +        ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq);
>> +        if (ret)
>> +            return ret;
>> +
>> +        if (bufreq.size > inst->output_buf_size)
>> +            return -EINVAL;
>> +
>> +        if (inst->dpb_fmt) {
>> +            ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT2,
>> &bufreq);
>> +            if (ret)
>> +                return ret;
>> +
>> +            if (bufreq.size > inst->output2_buf_size)
>> +                return -EINVAL;
>> +        }
>> +
>>          if (inst->output2_buf_size) {
>>              ret = venus_helper_set_bufsize(inst,
>>                                 inst->output2_buf_size,
>> @@ -1327,19 +1344,15 @@ static void vdec_event_change(struct
>> venus_inst *inst,
>>      dev_dbg(dev, VDBGM "event %s sufficient resources (%ux%u)\n",
>>          sufficient ? "" : "not", ev_data->width, ev_data->height);
>>
>> -    if (sufficient) {
>> -        hfi_session_continue(inst);
>> -    } else {
>> -        switch (inst->codec_state) {
>> -        case VENUS_DEC_STATE_INIT:
>> -            inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
>> -            break;
>> -        case VENUS_DEC_STATE_DECODING:
>> -            inst->codec_state = VENUS_DEC_STATE_DRC;
>> -            break;
>> -        default:
>> -            break;
>> -        }
>> +    switch (inst->codec_state) {
>> +    case VENUS_DEC_STATE_INIT:
>> +        inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP;
>> +        break;
>> +    case VENUS_DEC_STATE_DECODING:
>> +        inst->codec_state = VENUS_DEC_STATE_DRC;
> 
> Video firmware would raise reconfig event to driver even for cases like
> interlace detection, color space change in the bitstream. If not with
> this patch,
> we can optimize by sending reconfig event only for resolution and
> bitdepth update,
> in a followup patch.

Good point. Sure, I can do that in this series as separate patch.

> 
>> +        break;
>> +    default:
>> +        break;
>>      }
>>
>>      /*
>> @@ -1348,7 +1361,7 @@ static void vdec_event_change(struct venus_inst
>> *inst,
>>       * itself doesn't mark the last decoder output buffer with HFI
>> EOS flag.
>>       */
>>
>> -    if (!sufficient && inst->codec_state == VENUS_DEC_STATE_DRC) {
>> +    if (inst->codec_state == VENUS_DEC_STATE_DRC) {
>>          struct vb2_v4l2_buffer *last;
>>          int ret;