2020-04-22 04:02:29

by Samuel Holland

[permalink] [raw]
Subject: [PATCH v2 1/2] media: cedrus: Program output format during each run

Previously, the output format was programmed as part of the ioctl()
handler. However, this has two problems:

1) If there are multiple active streams with different output
formats, the hardware will use whichever format was set last
for both streams. Similary, an ioctl() done in an inactive
context will wrongly affect other active contexts.
2) The registers are written while the device is not actively
streaming. To enable runtime PM tied to the streaming state,
all hardware access needs to be moved inside cedrus_device_run().

The call to cedrus_dst_format_set() is now placed just before the
codec-specific callback that programs the hardware.

Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")
Suggested-by: Jernej Škrabec <[email protected]>
Suggested-by: Paul Kocialkowski <[email protected]>
Signed-off-by: Samuel Holland <[email protected]>
---

v2: added patch

---
drivers/staging/media/sunxi/cedrus/cedrus_dec.c | 2 ++
drivers/staging/media/sunxi/cedrus/cedrus_video.c | 3 ---
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
index 4a2fc33a1d79..58c48e4fdfe9 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
@@ -74,6 +74,8 @@ void cedrus_device_run(void *priv)

v4l2_m2m_buf_copy_metadata(run.src, run.dst, true);

+ cedrus_dst_format_set(dev, &ctx->dst_fmt);
+
dev->dec_ops[ctx->current_codec]->setup(ctx, &run);

/* Complete request(s) controls if needed. */
diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
index 15cf1f10221b..ed3f511f066f 100644
--- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
+++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
@@ -273,7 +273,6 @@ static int cedrus_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
struct cedrus_ctx *ctx = cedrus_file2ctx(file);
- struct cedrus_dev *dev = ctx->dev;
struct vb2_queue *vq;
int ret;

@@ -287,8 +286,6 @@ static int cedrus_s_fmt_vid_cap(struct file *file, void *priv,

ctx->dst_fmt = f->fmt.pix;

- cedrus_dst_format_set(dev, &ctx->dst_fmt);
-
return 0;
}

--
2.24.1


2020-04-23 17:43:27

by Jernej Škrabec

[permalink] [raw]
Subject: Re: [linux-sunxi] [PATCH v2 1/2] media: cedrus: Program output format during each run

Dne sreda, 22. april 2020 ob 06:04:09 CEST je Samuel Holland napisal(a):
> Previously, the output format was programmed as part of the ioctl()
> handler. However, this has two problems:
>
> 1) If there are multiple active streams with different output
> formats, the hardware will use whichever format was set last
> for both streams. Similary, an ioctl() done in an inactive
> context will wrongly affect other active contexts.
> 2) The registers are written while the device is not actively
> streaming. To enable runtime PM tied to the streaming state,
> all hardware access needs to be moved inside cedrus_device_run().
>
> The call to cedrus_dst_format_set() is now placed just before the
> codec-specific callback that programs the hardware.
>
> Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")
> Suggested-by: Jernej Škrabec <[email protected]>
> Suggested-by: Paul Kocialkowski <[email protected]>
> Signed-off-by: Samuel Holland <[email protected]>

For what is worth:
Tested-by: Jernej Skrabec <[email protected]>
Reviewed-by: Jernej Skrabec <[email protected]>

Best regards,
Jernej



2020-05-05 12:48:04

by Ezequiel Garcia

[permalink] [raw]
Subject: Re: [linux-sunxi] [PATCH v2 1/2] media: cedrus: Program output format during each run

On Wed, 22 Apr 2020 at 01:00, Samuel Holland <[email protected]> wrote:
>
> Previously, the output format was programmed as part of the ioctl()
> handler. However, this has two problems:
>
> 1) If there are multiple active streams with different output
> formats, the hardware will use whichever format was set last
> for both streams. Similary, an ioctl() done in an inactive
> context will wrongly affect other active contexts.
> 2) The registers are written while the device is not actively
> streaming. To enable runtime PM tied to the streaming state,
> all hardware access needs to be moved inside cedrus_device_run().
>
> The call to cedrus_dst_format_set() is now placed just before the
> codec-specific callback that programs the hardware.
>

Cc: <[email protected]>

> Fixes: 50e761516f2b ("media: platform: Add Cedrus VPU decoder driver")
> Suggested-by: Jernej Škrabec <[email protected]>
> Suggested-by: Paul Kocialkowski <[email protected]>
> Signed-off-by: Samuel Holland <[email protected]>

Reviewed-by: Ezequiel Garcia <[email protected]>

Thanks,
Ezequiel

> ---
>
> v2: added patch
>
> ---
> drivers/staging/media/sunxi/cedrus/cedrus_dec.c | 2 ++
> drivers/staging/media/sunxi/cedrus/cedrus_video.c | 3 ---
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> index 4a2fc33a1d79..58c48e4fdfe9 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_dec.c
> @@ -74,6 +74,8 @@ void cedrus_device_run(void *priv)
>
> v4l2_m2m_buf_copy_metadata(run.src, run.dst, true);
>
> + cedrus_dst_format_set(dev, &ctx->dst_fmt);
> +
> dev->dec_ops[ctx->current_codec]->setup(ctx, &run);
>
> /* Complete request(s) controls if needed. */
> diff --git a/drivers/staging/media/sunxi/cedrus/cedrus_video.c b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> index 15cf1f10221b..ed3f511f066f 100644
> --- a/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> +++ b/drivers/staging/media/sunxi/cedrus/cedrus_video.c
> @@ -273,7 +273,6 @@ static int cedrus_s_fmt_vid_cap(struct file *file, void *priv,
> struct v4l2_format *f)
> {
> struct cedrus_ctx *ctx = cedrus_file2ctx(file);
> - struct cedrus_dev *dev = ctx->dev;
> struct vb2_queue *vq;
> int ret;
>
> @@ -287,8 +286,6 @@ static int cedrus_s_fmt_vid_cap(struct file *file, void *priv,
>
> ctx->dst_fmt = f->fmt.pix;
>
> - cedrus_dst_format_set(dev, &ctx->dst_fmt);
> -
> return 0;
> }
>
> --
> 2.24.1
>
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20200422040410.6251-1-samuel%40sholland.org.