All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: hantro: Empty encoder capture buffers by default
@ 2022-03-31  8:49 ` Chen-Yu Tsai
  0 siblings, 0 replies; 4+ messages in thread
From: Chen-Yu Tsai @ 2022-03-31  8:49 UTC (permalink / raw)
  To: Ezequiel Garcia, Philipp Zabel, Mauro Carvalho Chehab,
	Greg Kroah-Hartman, Hans Verkuil
  Cc: Chen-Yu Tsai, Nicolas Dufresne, linux-media, linux-rockchip,
	linux-staging, linux-kernel

The payload size for encoder capture buffers is set by the driver upon
finishing encoding each frame, based on the encoded length returned from
hardware, and whatever header and padding length used. Setting a
non-zero default serves no real purpose, and also causes issues if the
capture buffer is returned to userspace unused, confusing the
application.

Instead, always set the payload size to 0 for encoder capture buffers
when preparing them.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Fixes: 082aaecff35f ("media: hantro: Fix .buf_prepare")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---

This was previously incorrectly squashed into my Hantro encoder cmd
patch [1].

[1] https://lore.kernel.org/linux-media/20220301042225.1540019-1-wenst@chromium.org/

 drivers/staging/media/hantro/hantro_v4l2.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c
index 67148ba346f5..261beb0c40f6 100644
--- a/drivers/staging/media/hantro/hantro_v4l2.c
+++ b/drivers/staging/media/hantro/hantro_v4l2.c
@@ -733,8 +733,12 @@ static int hantro_buf_prepare(struct vb2_buffer *vb)
 	 * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets
 	 * it to buffer length).
 	 */
-	if (V4L2_TYPE_IS_CAPTURE(vq->type))
-		vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
+	if (V4L2_TYPE_IS_CAPTURE(vq->type)) {
+		if (ctx->is_encoder)
+			vb2_set_plane_payload(vb, 0, 0);
+		else
+			vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
+	}
 
 	return 0;
 }
-- 
2.35.1.1021.g381101b075-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] media: hantro: Empty encoder capture buffers by default
@ 2022-03-31  8:49 ` Chen-Yu Tsai
  0 siblings, 0 replies; 4+ messages in thread
From: Chen-Yu Tsai @ 2022-03-31  8:49 UTC (permalink / raw)
  To: Ezequiel Garcia, Philipp Zabel, Mauro Carvalho Chehab,
	Greg Kroah-Hartman, Hans Verkuil
  Cc: Chen-Yu Tsai, Nicolas Dufresne, linux-media, linux-rockchip,
	linux-staging, linux-kernel

The payload size for encoder capture buffers is set by the driver upon
finishing encoding each frame, based on the encoded length returned from
hardware, and whatever header and padding length used. Setting a
non-zero default serves no real purpose, and also causes issues if the
capture buffer is returned to userspace unused, confusing the
application.

Instead, always set the payload size to 0 for encoder capture buffers
when preparing them.

Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
Fixes: 082aaecff35f ("media: hantro: Fix .buf_prepare")
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---

This was previously incorrectly squashed into my Hantro encoder cmd
patch [1].

[1] https://lore.kernel.org/linux-media/20220301042225.1540019-1-wenst@chromium.org/

 drivers/staging/media/hantro/hantro_v4l2.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c
index 67148ba346f5..261beb0c40f6 100644
--- a/drivers/staging/media/hantro/hantro_v4l2.c
+++ b/drivers/staging/media/hantro/hantro_v4l2.c
@@ -733,8 +733,12 @@ static int hantro_buf_prepare(struct vb2_buffer *vb)
 	 * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets
 	 * it to buffer length).
 	 */
-	if (V4L2_TYPE_IS_CAPTURE(vq->type))
-		vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
+	if (V4L2_TYPE_IS_CAPTURE(vq->type)) {
+		if (ctx->is_encoder)
+			vb2_set_plane_payload(vb, 0, 0);
+		else
+			vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
+	}
 
 	return 0;
 }
-- 
2.35.1.1021.g381101b075-goog


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: hantro: Empty encoder capture buffers by default
  2022-03-31  8:49 ` Chen-Yu Tsai
@ 2022-03-31 20:15   ` Ezequiel Garcia
  -1 siblings, 0 replies; 4+ messages in thread
From: Ezequiel Garcia @ 2022-03-31 20:15 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Philipp Zabel, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	Hans Verkuil, Nicolas Dufresne, linux-media, linux-rockchip,
	linux-staging, linux-kernel

On Thu, Mar 31, 2022 at 04:49:06PM +0800, Chen-Yu Tsai wrote:
> The payload size for encoder capture buffers is set by the driver upon
> finishing encoding each frame, based on the encoded length returned from
> hardware, and whatever header and padding length used. Setting a
> non-zero default serves no real purpose, and also causes issues if the
> capture buffer is returned to userspace unused, confusing the
> application.
> 
> Instead, always set the payload size to 0 for encoder capture buffers
> when preparing them.
> 
> Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
> Fixes: 082aaecff35f ("media: hantro: Fix .buf_prepare")
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

> ---
> 
> This was previously incorrectly squashed into my Hantro encoder cmd
> patch [1].
> 
> [1] https://lore.kernel.org/linux-media/20220301042225.1540019-1-wenst@chromium.org/
> 
>  drivers/staging/media/hantro/hantro_v4l2.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c
> index 67148ba346f5..261beb0c40f6 100644
> --- a/drivers/staging/media/hantro/hantro_v4l2.c
> +++ b/drivers/staging/media/hantro/hantro_v4l2.c
> @@ -733,8 +733,12 @@ static int hantro_buf_prepare(struct vb2_buffer *vb)
>  	 * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets
>  	 * it to buffer length).
>  	 */
> -	if (V4L2_TYPE_IS_CAPTURE(vq->type))
> -		vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
> +	if (V4L2_TYPE_IS_CAPTURE(vq->type)) {
> +		if (ctx->is_encoder)
> +			vb2_set_plane_payload(vb, 0, 0);
> +		else
> +			vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
> +	}
>  
>  	return 0;
>  }
> -- 
> 2.35.1.1021.g381101b075-goog
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: hantro: Empty encoder capture buffers by default
@ 2022-03-31 20:15   ` Ezequiel Garcia
  0 siblings, 0 replies; 4+ messages in thread
From: Ezequiel Garcia @ 2022-03-31 20:15 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Philipp Zabel, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	Hans Verkuil, Nicolas Dufresne, linux-media, linux-rockchip,
	linux-staging, linux-kernel

On Thu, Mar 31, 2022 at 04:49:06PM +0800, Chen-Yu Tsai wrote:
> The payload size for encoder capture buffers is set by the driver upon
> finishing encoding each frame, based on the encoded length returned from
> hardware, and whatever header and padding length used. Setting a
> non-zero default serves no real purpose, and also causes issues if the
> capture buffer is returned to userspace unused, confusing the
> application.
> 
> Instead, always set the payload size to 0 for encoder capture buffers
> when preparing them.
> 
> Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver")
> Fixes: 082aaecff35f ("media: hantro: Fix .buf_prepare")
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>

Reviewed-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>

> ---
> 
> This was previously incorrectly squashed into my Hantro encoder cmd
> patch [1].
> 
> [1] https://lore.kernel.org/linux-media/20220301042225.1540019-1-wenst@chromium.org/
> 
>  drivers/staging/media/hantro/hantro_v4l2.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/hantro/hantro_v4l2.c b/drivers/staging/media/hantro/hantro_v4l2.c
> index 67148ba346f5..261beb0c40f6 100644
> --- a/drivers/staging/media/hantro/hantro_v4l2.c
> +++ b/drivers/staging/media/hantro/hantro_v4l2.c
> @@ -733,8 +733,12 @@ static int hantro_buf_prepare(struct vb2_buffer *vb)
>  	 * (for OUTPUT buffers, if userspace passes 0 bytesused, v4l2-core sets
>  	 * it to buffer length).
>  	 */
> -	if (V4L2_TYPE_IS_CAPTURE(vq->type))
> -		vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
> +	if (V4L2_TYPE_IS_CAPTURE(vq->type)) {
> +		if (ctx->is_encoder)
> +			vb2_set_plane_payload(vb, 0, 0);
> +		else
> +			vb2_set_plane_payload(vb, 0, pix_fmt->plane_fmt[0].sizeimage);
> +	}
>  
>  	return 0;
>  }
> -- 
> 2.35.1.1021.g381101b075-goog
> 

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-31 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31  8:49 [PATCH] media: hantro: Empty encoder capture buffers by default Chen-Yu Tsai
2022-03-31  8:49 ` Chen-Yu Tsai
2022-03-31 20:15 ` Ezequiel Garcia
2022-03-31 20:15   ` Ezequiel Garcia

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.