diff mbox series

[RESEND,v0,4/5] wave5: Use the bitstream buffer size from host.

Message ID 20240131013046.15687-5-jackson.lee@chipsnmedia.com (mailing list archive)
State New, archived
Headers show
Series wave5 codec driver | expand

Commit Message

Jackson.lee Jan. 31, 2024, 1:30 a.m. UTC
In V4L2 spec, Host can set the bitstream buffer size.
Allow the larger size between default size and input size.

Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
---
 drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Andrew Davis Jan. 31, 2024, 5:36 p.m. UTC | #1
On 1/30/24 7:30 PM, jackson.lee wrote:
> In V4L2 spec, Host can set the bitstream buffer size.
> Allow the larger size between default size and input size.
> 
> Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
> ---
>   drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> index ff73d69de41c..19018ace41b6 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> @@ -11,6 +11,10 @@
>   #define VPU_ENC_DEV_NAME "C&M Wave5 VPU encoder"
>   #define VPU_ENC_DRV_NAME "wave5-enc"
>   
> +#define DEFAULT_SRC_SIZE(width, height) ({			\
> +	(width) * (height) / 8 * 3;					\

These "\" are tabbed out way to far, and not to the same amount..
Why have this in {;} brackets?
Why multiple lines?
Just:

#define DEFAULT_SRC_SIZE(width, height) ((width) * (height) / 8 * 3)

Andrew

> +})
> +
>   static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = {
>   	[VPU_FMT_TYPE_CODEC] = {
>   		{
> @@ -193,7 +197,8 @@ static void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, unsigned
>   		pix_mp->width = width;
>   		pix_mp->height = height;
>   		pix_mp->plane_fmt[0].bytesperline = 0;
> -		pix_mp->plane_fmt[0].sizeimage = width * height / 8 * 3;
> +		pix_mp->plane_fmt[0].sizeimage = max(DEFAULT_SRC_SIZE(width, height),
> +						     pix_mp->plane_fmt[0].sizeimage);
>   		break;
>   	}
>   }
Jackson.lee Feb. 2, 2024, 1:55 a.m. UTC | #2
Hello Andrew

I will update it to one line you suggested.

Thanks.

> -----Original Message-----
> From: Andrew Davis <afd@ti.com>
> Sent: Thursday, February 1, 2024 2:37 AM
> To: jackson.lee <jackson.lee@chipsnmedia.com>; mchehab@kernel.org; linux-
> media@vger.kernel.org; linux-kernel@vger.kernel.org; Nas Chung
> <nas.chung@chipsnmedia.com>
> Cc: lafley.kim <lafley.kim@chipsnmedia.com>; b-brnich@ti.com
> Subject: Re: [RESEND PATCH v0 4/5] wave5: Use the bitstream buffer size
> from host.
> 
> On 1/30/24 7:30 PM, jackson.lee wrote:
> > In V4L2 spec, Host can set the bitstream buffer size.
> > Allow the larger size between default size and input size.
> >
> > Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
> > Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
> > ---
> >   drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c | 7 ++++++-
> >   1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> > index ff73d69de41c..19018ace41b6 100644
> > --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
> > @@ -11,6 +11,10 @@
> >   #define VPU_ENC_DEV_NAME "C&M Wave5 VPU encoder"
> >   #define VPU_ENC_DRV_NAME "wave5-enc"
> >
> > +#define DEFAULT_SRC_SIZE(width, height) ({			\
> > +	(width) * (height) / 8 * 3;					\
> 
> These "\" are tabbed out way to far, and not to the same amount..
> Why have this in {;} brackets?
> Why multiple lines?
> Just:
> 
> #define DEFAULT_SRC_SIZE(width, height) ((width) * (height) / 8 * 3)
> 
> Andrew
> 
> > +})
> > +
> >   static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = {
> >   	[VPU_FMT_TYPE_CODEC] = {
> >   		{
> > @@ -193,7 +197,8 @@ static void wave5_update_pix_fmt(struct
> v4l2_pix_format_mplane *pix_mp, unsigned
> >   		pix_mp->width = width;
> >   		pix_mp->height = height;
> >   		pix_mp->plane_fmt[0].bytesperline = 0;
> > -		pix_mp->plane_fmt[0].sizeimage = width * height / 8 * 3;
> > +		pix_mp->plane_fmt[0].sizeimage = max(DEFAULT_SRC_SIZE(width,
> height),
> > +						     pix_mp-
> >plane_fmt[0].sizeimage);
> >   		break;
> >   	}
> >   }
diff mbox series

Patch

diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
index ff73d69de41c..19018ace41b6 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-enc.c
@@ -11,6 +11,10 @@ 
 #define VPU_ENC_DEV_NAME "C&M Wave5 VPU encoder"
 #define VPU_ENC_DRV_NAME "wave5-enc"
 
+#define DEFAULT_SRC_SIZE(width, height) ({			\
+	(width) * (height) / 8 * 3;					\
+})
+
 static const struct vpu_format enc_fmt_list[FMT_TYPES][MAX_FMTS] = {
 	[VPU_FMT_TYPE_CODEC] = {
 		{
@@ -193,7 +197,8 @@  static void wave5_update_pix_fmt(struct v4l2_pix_format_mplane *pix_mp, unsigned
 		pix_mp->width = width;
 		pix_mp->height = height;
 		pix_mp->plane_fmt[0].bytesperline = 0;
-		pix_mp->plane_fmt[0].sizeimage = width * height / 8 * 3;
+		pix_mp->plane_fmt[0].sizeimage = max(DEFAULT_SRC_SIZE(width, height),
+						     pix_mp->plane_fmt[0].sizeimage);
 		break;
 	}
 }