2020-11-11 14:43:05

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v2 0/8] Venus stateful encoder compliance

Hello,

Here is v2 of the subject patchset.

The patchset starts with few small preparation and fix patches, 1/8 to 5/8.
6/8 is redesigned Dikshita's patch and 7/8 add Reset encoder state handling.
The last 8/8 just delete not needed helper function.

The major changes are:
* An attempt to reuse m2m helpers for drain and reset state in 6/8 and 7/8.
* Use null encoder buffer to signal end-of-stream in 6/8.

Comments are welcome!

regards,
Stan

Dikshita Agarwal (1):
venus: venc: add handling for VIDIOC_ENCODER_CMD

Stanimir Varbanov (7):
venus: hfi: Use correct state in unload resources
venus: helpers: Add a new helper for buffer processing
venus: hfi_cmds: Allow null buffer address on encoder input
venus: helpers: Calculate properly compressed buffer size
venus: pm_helpers: Check instance state when calculate instance
frequency
venus: venc: Handle reset encoder state
venus: helpers: Delete unused stop streaming helper

drivers/media/platform/qcom/venus/helpers.c | 65 ++---
drivers/media/platform/qcom/venus/helpers.h | 2 +-
drivers/media/platform/qcom/venus/hfi.c | 2 +-
drivers/media/platform/qcom/venus/hfi.h | 1 -
drivers/media/platform/qcom/venus/hfi_cmds.c | 2 +-
.../media/platform/qcom/venus/pm_helpers.c | 3 +
drivers/media/platform/qcom/venus/venc.c | 232 +++++++++++++++---
7 files changed, 226 insertions(+), 81 deletions(-)

--
2.17.1


2020-11-11 14:43:48

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v2 4/8] venus: helpers: Calculate properly compressed buffer size

For resolutions below 720p the size of the compressed buffer must
be bigger. Correct this by checking the resolution when calculating
buffer size and multiply by four.

Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/helpers.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index 688e3e3e8362..490c026b58a3 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -986,6 +986,8 @@ u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height)

if (compressed) {
sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2 / 2;
+ if (width < 1280 || height < 720)
+ sz *= 8;
return ALIGN(sz, SZ_4K);
}

--
2.17.1

2020-11-11 14:43:52

by Stanimir Varbanov

[permalink] [raw]
Subject: [PATCH v2 2/8] venus: helpers: Add a new helper for buffer processing

The new helper will be used from encoder and decoder drivers
to enqueue buffers for processing by firmware.

Signed-off-by: Stanimir Varbanov <[email protected]>
---
drivers/media/platform/qcom/venus/helpers.c | 20 ++++++++++++++++++++
drivers/media/platform/qcom/venus/helpers.h | 1 +
2 files changed, 21 insertions(+)

diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
index efa2781d6f55..688e3e3e8362 100644
--- a/drivers/media/platform/qcom/venus/helpers.c
+++ b/drivers/media/platform/qcom/venus/helpers.c
@@ -1369,6 +1369,26 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb)
}
EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue);

+void venus_helper_process_buf(struct vb2_buffer *vb)
+{
+ struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
+ struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue);
+ int ret;
+
+ cache_payload(inst, vb);
+
+ if (vb2_start_streaming_called(vb->vb2_queue)) {
+ ret = is_buf_refed(inst, vbuf);
+ if (ret)
+ return;
+
+ ret = session_process_buf(inst, vbuf);
+ if (ret)
+ return_buf_error(inst, vbuf);
+ }
+}
+EXPORT_SYMBOL_GPL(venus_helper_process_buf);
+
void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type,
enum vb2_buffer_state state)
{
diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
index f36c9f717798..231af29667e7 100644
--- a/drivers/media/platform/qcom/venus/helpers.h
+++ b/drivers/media/platform/qcom/venus/helpers.h
@@ -19,6 +19,7 @@ void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type,
int venus_helper_vb2_buf_init(struct vb2_buffer *vb);
int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb);
void venus_helper_vb2_buf_queue(struct vb2_buffer *vb);
+void venus_helper_process_buf(struct vb2_buffer *vb);
void venus_helper_vb2_stop_streaming(struct vb2_queue *q);
int venus_helper_vb2_start_streaming(struct venus_inst *inst);
void venus_helper_m2m_device_run(void *priv);
--
2.17.1

2020-11-29 06:06:37

by Fritz Koenig

[permalink] [raw]
Subject: Re: [PATCH v2 2/8] venus: helpers: Add a new helper for buffer processing

On Wed, Nov 11, 2020 at 6:38 AM Stanimir Varbanov
<[email protected]> wrote:
>
> The new helper will be used from encoder and decoder drivers
> to enqueue buffers for processing by firmware.
>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> drivers/media/platform/qcom/venus/helpers.c | 20 ++++++++++++++++++++
> drivers/media/platform/qcom/venus/helpers.h | 1 +
> 2 files changed, 21 insertions(+)
>
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index efa2781d6f55..688e3e3e8362 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -1369,6 +1369,26 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb)
> }
> EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue);
>
> +void venus_helper_process_buf(struct vb2_buffer *vb)
> +{
> + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
> + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue);
> + int ret;
> +
> + cache_payload(inst, vb);
> +
> + if (vb2_start_streaming_called(vb->vb2_queue)) {
> + ret = is_buf_refed(inst, vbuf);
> + if (ret)
> + return;
> +
> + ret = session_process_buf(inst, vbuf);
> + if (ret)
> + return_buf_error(inst, vbuf);
> + }
> +}
> +EXPORT_SYMBOL_GPL(venus_helper_process_buf);
> +
> void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type,
> enum vb2_buffer_state state)
> {
> diff --git a/drivers/media/platform/qcom/venus/helpers.h b/drivers/media/platform/qcom/venus/helpers.h
> index f36c9f717798..231af29667e7 100644
> --- a/drivers/media/platform/qcom/venus/helpers.h
> +++ b/drivers/media/platform/qcom/venus/helpers.h
> @@ -19,6 +19,7 @@ void venus_helper_buffers_done(struct venus_inst *inst, unsigned int type,
> int venus_helper_vb2_buf_init(struct vb2_buffer *vb);
> int venus_helper_vb2_buf_prepare(struct vb2_buffer *vb);
> void venus_helper_vb2_buf_queue(struct vb2_buffer *vb);
> +void venus_helper_process_buf(struct vb2_buffer *vb);
> void venus_helper_vb2_stop_streaming(struct vb2_queue *q);
> int venus_helper_vb2_start_streaming(struct venus_inst *inst);
> void venus_helper_m2m_device_run(void *priv);
> --
> 2.17.1
>

Reviewed-by: Fritz Koenig <[email protected]>

2020-11-29 06:10:43

by Fritz Koenig

[permalink] [raw]
Subject: Re: [PATCH v2 4/8] venus: helpers: Calculate properly compressed buffer size

On Wed, Nov 11, 2020 at 6:38 AM Stanimir Varbanov
<[email protected]> wrote:
>
> For resolutions below 720p the size of the compressed buffer must
> be bigger. Correct this by checking the resolution when calculating
> buffer size and multiply by four.

I'm confused because the commit message doesn't appear to line up with
the code. It says multiply by four here, but the code has by eight.

>
> Signed-off-by: Stanimir Varbanov <[email protected]>
> ---
> drivers/media/platform/qcom/venus/helpers.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
> index 688e3e3e8362..490c026b58a3 100644
> --- a/drivers/media/platform/qcom/venus/helpers.c
> +++ b/drivers/media/platform/qcom/venus/helpers.c
> @@ -986,6 +986,8 @@ u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height)
>
> if (compressed) {
> sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2 / 2;
> + if (width < 1280 || height < 720)
> + sz *= 8;
> return ALIGN(sz, SZ_4K);
> }
>
> --
> 2.17.1
>

2020-11-29 19:20:43

by Fritz Koenig

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] Venus stateful encoder compliance

Since this patchset adds support for V4L2_ENC_CMD_STOP and
VENUS_ENC_STATE_ENCODING it should also add support for
VIDIOC_TRY_ENCODER_CMD so that those commands are discoverable. I've
made an attempt at that here:
https://www.spinics.net/lists/linux-media/msg182319.html

On Wed, Nov 11, 2020 at 6:38 AM Stanimir Varbanov
<[email protected]> wrote:
>
> Hello,
>
> Here is v2 of the subject patchset.
>
> The patchset starts with few small preparation and fix patches, 1/8 to 5/8.
> 6/8 is redesigned Dikshita's patch and 7/8 add Reset encoder state handling.
> The last 8/8 just delete not needed helper function.
>
> The major changes are:
> * An attempt to reuse m2m helpers for drain and reset state in 6/8 and 7/8.
> * Use null encoder buffer to signal end-of-stream in 6/8.
>
> Comments are welcome!
>
> regards,
> Stan
>
> Dikshita Agarwal (1):
> venus: venc: add handling for VIDIOC_ENCODER_CMD
>
> Stanimir Varbanov (7):
> venus: hfi: Use correct state in unload resources
> venus: helpers: Add a new helper for buffer processing
> venus: hfi_cmds: Allow null buffer address on encoder input
> venus: helpers: Calculate properly compressed buffer size
> venus: pm_helpers: Check instance state when calculate instance
> frequency
> venus: venc: Handle reset encoder state
> venus: helpers: Delete unused stop streaming helper
>
> drivers/media/platform/qcom/venus/helpers.c | 65 ++---
> drivers/media/platform/qcom/venus/helpers.h | 2 +-
> drivers/media/platform/qcom/venus/hfi.c | 2 +-
> drivers/media/platform/qcom/venus/hfi.h | 1 -
> drivers/media/platform/qcom/venus/hfi_cmds.c | 2 +-
> .../media/platform/qcom/venus/pm_helpers.c | 3 +
> drivers/media/platform/qcom/venus/venc.c | 232 +++++++++++++++---
> 7 files changed, 226 insertions(+), 81 deletions(-)
>
> --
> 2.17.1
>

2020-11-30 07:54:55

by Stanimir Varbanov

[permalink] [raw]
Subject: Re: [PATCH v2 4/8] venus: helpers: Calculate properly compressed buffer size



On 11/29/20 8:07 AM, Fritz Koenig wrote:
> On Wed, Nov 11, 2020 at 6:38 AM Stanimir Varbanov
> <[email protected]> wrote:
>>
>> For resolutions below 720p the size of the compressed buffer must
>> be bigger. Correct this by checking the resolution when calculating
>> buffer size and multiply by four.
>
> I'm confused because the commit message doesn't appear to line up with
> the code. It says multiply by four here, but the code has by eight.

Yes, it is confusing. I will correct it in next version.

>
>>
>> Signed-off-by: Stanimir Varbanov <[email protected]>
>> ---
>> drivers/media/platform/qcom/venus/helpers.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c
>> index 688e3e3e8362..490c026b58a3 100644
>> --- a/drivers/media/platform/qcom/venus/helpers.c
>> +++ b/drivers/media/platform/qcom/venus/helpers.c
>> @@ -986,6 +986,8 @@ u32 venus_helper_get_framesz(u32 v4l2_fmt, u32 width, u32 height)
>>
>> if (compressed) {
>> sz = ALIGN(height, 32) * ALIGN(width, 32) * 3 / 2 / 2;
>> + if (width < 1280 || height < 720)
>> + sz *= 8;
>> return ALIGN(sz, SZ_4K);
>> }
>>
>> --
>> 2.17.1
>>

--
regards,
Stan

2020-11-30 07:57:56

by Stanimir Varbanov

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] Venus stateful encoder compliance

Hi Fritz,

On 11/29/20 9:17 PM, Fritz Koenig wrote:
> Since this patchset adds support for V4L2_ENC_CMD_STOP and
> VENUS_ENC_STATE_ENCODING it should also add support for
> VIDIOC_TRY_ENCODER_CMD so that those commands are discoverable. I've

6/8 is adding it:

+ .vidioc_try_encoder_cmd = v4l2_m2m_ioctl_try_encoder_cmd,

> made an attempt at that here:
> https://www.spinics.net/lists/linux-media/msg182319.html
>
> On Wed, Nov 11, 2020 at 6:38 AM Stanimir Varbanov
> <[email protected]> wrote:
>>
>> Hello,
>>
>> Here is v2 of the subject patchset.
>>
>> The patchset starts with few small preparation and fix patches, 1/8 to 5/8.
>> 6/8 is redesigned Dikshita's patch and 7/8 add Reset encoder state handling.
>> The last 8/8 just delete not needed helper function.
>>
>> The major changes are:
>> * An attempt to reuse m2m helpers for drain and reset state in 6/8 and 7/8.
>> * Use null encoder buffer to signal end-of-stream in 6/8.
>>
>> Comments are welcome!
>>
>> regards,
>> Stan
>>
>> Dikshita Agarwal (1):
>> venus: venc: add handling for VIDIOC_ENCODER_CMD
>>
>> Stanimir Varbanov (7):
>> venus: hfi: Use correct state in unload resources
>> venus: helpers: Add a new helper for buffer processing
>> venus: hfi_cmds: Allow null buffer address on encoder input
>> venus: helpers: Calculate properly compressed buffer size
>> venus: pm_helpers: Check instance state when calculate instance
>> frequency
>> venus: venc: Handle reset encoder state
>> venus: helpers: Delete unused stop streaming helper
>>
>> drivers/media/platform/qcom/venus/helpers.c | 65 ++---
>> drivers/media/platform/qcom/venus/helpers.h | 2 +-
>> drivers/media/platform/qcom/venus/hfi.c | 2 +-
>> drivers/media/platform/qcom/venus/hfi.h | 1 -
>> drivers/media/platform/qcom/venus/hfi_cmds.c | 2 +-
>> .../media/platform/qcom/venus/pm_helpers.c | 3 +
>> drivers/media/platform/qcom/venus/venc.c | 232 +++++++++++++++---
>> 7 files changed, 226 insertions(+), 81 deletions(-)
>>
>> --
>> 2.17.1
>>

--
regards,
Stan

2020-11-30 17:30:58

by Fritz Koenig

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] Venus stateful encoder compliance

On Sun, Nov 29, 2020 at 11:55 PM Stanimir Varbanov
<[email protected]> wrote:
>
> Hi Fritz,
>
> On 11/29/20 9:17 PM, Fritz Koenig wrote:
> > Since this patchset adds support for V4L2_ENC_CMD_STOP and
> > VENUS_ENC_STATE_ENCODING it should also add support for
> > VIDIOC_TRY_ENCODER_CMD so that those commands are discoverable. I've
>
> 6/8 is adding it:
>
> + .vidioc_try_encoder_cmd = v4l2_m2m_ioctl_try_encoder_cmd,
>

Ahh, thanks. I need to work on my reading comprehension.

> > made an attempt at that here:
> > https://www.spinics.net/lists/linux-media/msg182319.html
> >
> > On Wed, Nov 11, 2020 at 6:38 AM Stanimir Varbanov
> > <[email protected]> wrote:
> >>
> >> Hello,
> >>
> >> Here is v2 of the subject patchset.
> >>
> >> The patchset starts with few small preparation and fix patches, 1/8 to 5/8.
> >> 6/8 is redesigned Dikshita's patch and 7/8 add Reset encoder state handling.
> >> The last 8/8 just delete not needed helper function.
> >>
> >> The major changes are:
> >> * An attempt to reuse m2m helpers for drain and reset state in 6/8 and 7/8.
> >> * Use null encoder buffer to signal end-of-stream in 6/8.
> >>
> >> Comments are welcome!
> >>
> >> regards,
> >> Stan
> >>
> >> Dikshita Agarwal (1):
> >> venus: venc: add handling for VIDIOC_ENCODER_CMD
> >>
> >> Stanimir Varbanov (7):
> >> venus: hfi: Use correct state in unload resources
> >> venus: helpers: Add a new helper for buffer processing
> >> venus: hfi_cmds: Allow null buffer address on encoder input
> >> venus: helpers: Calculate properly compressed buffer size
> >> venus: pm_helpers: Check instance state when calculate instance
> >> frequency
> >> venus: venc: Handle reset encoder state
> >> venus: helpers: Delete unused stop streaming helper
> >>
> >> drivers/media/platform/qcom/venus/helpers.c | 65 ++---
> >> drivers/media/platform/qcom/venus/helpers.h | 2 +-
> >> drivers/media/platform/qcom/venus/hfi.c | 2 +-
> >> drivers/media/platform/qcom/venus/hfi.h | 1 -
> >> drivers/media/platform/qcom/venus/hfi_cmds.c | 2 +-
> >> .../media/platform/qcom/venus/pm_helpers.c | 3 +
> >> drivers/media/platform/qcom/venus/venc.c | 232 +++++++++++++++---
> >> 7 files changed, 226 insertions(+), 81 deletions(-)
> >>
> >> --
> >> 2.17.1
> >>
>
> --
> regards,
> Stan