All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
@ 2021-11-04 12:24 ` Yunfei Dong
  0 siblings, 0 replies; 9+ messages in thread
From: Yunfei Dong @ 2021-11-04 12:24 UTC (permalink / raw)
  To: Steve Cho, Yunfei Dong, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard,
	Daniel Vetter, dri-devel, Irui Wang, linux-media, devicetree,
	linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, Nicolas Dufresne,
	Steve Cho

Width and height need to 64 bytes aligned when setting the format.
Need to make sure all is 64 bytes align when use width and height to
calculate buffer size.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Steve Cho <stevecho@chromium.org>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
index e30806c1faea..66cd6d2242c3 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
@@ -11,6 +11,7 @@
 #include <media/videobuf2-core.h>
 #include <media/v4l2-mem2mem.h>
 
+#define VCODEC_DEC_ALIGNED_64 64
 #define VCODEC_CAPABILITY_4K_DISABLED	0x10
 #define VCODEC_DEC_4K_CODED_WIDTH	4096U
 #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
index d402fc4bda69..e1a3011772a9 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
@@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
 {
 	struct mtk_vcodec_ctx *ctx = inst->ctx;
 
-	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
-	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
+	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
+	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
 	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
 	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
 	inst->vsi_ctx.dec.cap_num_planes =
-- 
2.25.1


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

* [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
@ 2021-11-04 12:24 ` Yunfei Dong
  0 siblings, 0 replies; 9+ messages in thread
From: Yunfei Dong @ 2021-11-04 12:24 UTC (permalink / raw)
  To: Steve Cho, Yunfei Dong, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard,
	Daniel Vetter, dri-devel, Irui Wang, linux-media, devicetree,
	linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, Nicolas Dufresne,
	Steve Cho

Width and height need to 64 bytes aligned when setting the format.
Need to make sure all is 64 bytes align when use width and height to
calculate buffer size.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Steve Cho <stevecho@chromium.org>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
index e30806c1faea..66cd6d2242c3 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
@@ -11,6 +11,7 @@
 #include <media/videobuf2-core.h>
 #include <media/v4l2-mem2mem.h>
 
+#define VCODEC_DEC_ALIGNED_64 64
 #define VCODEC_CAPABILITY_4K_DISABLED	0x10
 #define VCODEC_DEC_4K_CODED_WIDTH	4096U
 #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
index d402fc4bda69..e1a3011772a9 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
@@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
 {
 	struct mtk_vcodec_ctx *ctx = inst->ctx;
 
-	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
-	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
+	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
+	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
 	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
 	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
 	inst->vsi_ctx.dec.cap_num_planes =
-- 
2.25.1


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

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

* [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
@ 2021-11-04 12:24 ` Yunfei Dong
  0 siblings, 0 replies; 9+ messages in thread
From: Yunfei Dong @ 2021-11-04 12:24 UTC (permalink / raw)
  To: Steve Cho, Yunfei Dong, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Irui Wang, Benjamin Gaignard, srv_heupstream, devicetree,
	linux-kernel, dri-devel, Project_Global_Chrome_Upstream_Group,
	linux-mediatek, Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld,
	Steve Cho, Nicolas Dufresne, linux-arm-kernel, linux-media

Width and height need to 64 bytes aligned when setting the format.
Need to make sure all is 64 bytes align when use width and height to
calculate buffer size.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Steve Cho <stevecho@chromium.org>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
index e30806c1faea..66cd6d2242c3 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
@@ -11,6 +11,7 @@
 #include <media/videobuf2-core.h>
 #include <media/v4l2-mem2mem.h>
 
+#define VCODEC_DEC_ALIGNED_64 64
 #define VCODEC_CAPABILITY_4K_DISABLED	0x10
 #define VCODEC_DEC_4K_CODED_WIDTH	4096U
 #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
index d402fc4bda69..e1a3011772a9 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
@@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
 {
 	struct mtk_vcodec_ctx *ctx = inst->ctx;
 
-	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
-	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
+	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
+	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
 	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
 	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
 	inst->vsi_ctx.dec.cap_num_planes =
-- 
2.25.1


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

* [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
@ 2021-11-04 12:24 ` Yunfei Dong
  0 siblings, 0 replies; 9+ messages in thread
From: Yunfei Dong @ 2021-11-04 12:24 UTC (permalink / raw)
  To: Steve Cho, Yunfei Dong, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Hsin-Yi Wang, Fritz Koenig, Dafna Hirschfeld, Benjamin Gaignard,
	Daniel Vetter, dri-devel, Irui Wang, linux-media, devicetree,
	linux-kernel, linux-arm-kernel, srv_heupstream, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, Nicolas Dufresne,
	Steve Cho

Width and height need to 64 bytes aligned when setting the format.
Need to make sure all is 64 bytes align when use width and height to
calculate buffer size.

Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Tested-by: Steve Cho <stevecho@chromium.org>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
 drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
index e30806c1faea..66cd6d2242c3 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
@@ -11,6 +11,7 @@
 #include <media/videobuf2-core.h>
 #include <media/v4l2-mem2mem.h>
 
+#define VCODEC_DEC_ALIGNED_64 64
 #define VCODEC_CAPABILITY_4K_DISABLED	0x10
 #define VCODEC_DEC_4K_CODED_WIDTH	4096U
 #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
index d402fc4bda69..e1a3011772a9 100644
--- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
@@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
 {
 	struct mtk_vcodec_ctx *ctx = inst->ctx;
 
-	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
-	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
+	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
+	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
 	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
 	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
 	inst->vsi_ctx.dec.cap_num_planes =
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
  2021-11-04 12:24 ` Yunfei Dong
  (?)
  (?)
@ 2021-11-22  7:11   ` Dafna Hirschfeld
  -1 siblings, 0 replies; 9+ messages in thread
From: Dafna Hirschfeld @ 2021-11-22  7:11 UTC (permalink / raw)
  To: Yunfei Dong, Steve Cho, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Hsin-Yi Wang, Fritz Koenig, Benjamin Gaignard, Daniel Vetter,
	dri-devel, Irui Wang, linux-media, devicetree, linux-kernel,
	linux-arm-kernel, srv_heupstream, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, Nicolas Dufresne,
	Steve Cho



On 04.11.21 14:24, Yunfei Dong wrote:
> Width and height need to 64 bytes aligned when setting the format.
> Need to make sure all is 64 bytes align when use width and height to
> calculate buffer size.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Steve Cho <stevecho@chromium.org>
> ---
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
>   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index e30806c1faea..66cd6d2242c3 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -11,6 +11,7 @@
>   #include <media/videobuf2-core.h>
>   #include <media/v4l2-mem2mem.h>
>   
> +#define VCODEC_DEC_ALIGNED_64 64

This define is a bit useless, it doesn't improve readability,
if you do ALIGN(x, 64) it is already clear enough.

Thank,
Dafna

>   #define VCODEC_CAPABILITY_4K_DISABLED	0x10
>   #define VCODEC_DEC_4K_CODED_WIDTH	4096U
>   #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> index d402fc4bda69..e1a3011772a9 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> @@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
>   {
>   	struct mtk_vcodec_ctx *ctx = inst->ctx;
>   
> -	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
> -	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
> +	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
> +	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
>   	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
>   	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
>   	inst->vsi_ctx.dec.cap_num_planes =
> 

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

* Re: [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
@ 2021-11-22  7:11   ` Dafna Hirschfeld
  0 siblings, 0 replies; 9+ messages in thread
From: Dafna Hirschfeld @ 2021-11-22  7:11 UTC (permalink / raw)
  To: Yunfei Dong, Steve Cho, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Irui Wang, Benjamin Gaignard, srv_heupstream, devicetree,
	linux-kernel, dri-devel, Project_Global_Chrome_Upstream_Group,
	linux-mediatek, Hsin-Yi Wang, Fritz Koenig, Steve Cho,
	Nicolas Dufresne, linux-arm-kernel, linux-media



On 04.11.21 14:24, Yunfei Dong wrote:
> Width and height need to 64 bytes aligned when setting the format.
> Need to make sure all is 64 bytes align when use width and height to
> calculate buffer size.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Steve Cho <stevecho@chromium.org>
> ---
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
>   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index e30806c1faea..66cd6d2242c3 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -11,6 +11,7 @@
>   #include <media/videobuf2-core.h>
>   #include <media/v4l2-mem2mem.h>
>   
> +#define VCODEC_DEC_ALIGNED_64 64

This define is a bit useless, it doesn't improve readability,
if you do ALIGN(x, 64) it is already clear enough.

Thank,
Dafna

>   #define VCODEC_CAPABILITY_4K_DISABLED	0x10
>   #define VCODEC_DEC_4K_CODED_WIDTH	4096U
>   #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> index d402fc4bda69..e1a3011772a9 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> @@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
>   {
>   	struct mtk_vcodec_ctx *ctx = inst->ctx;
>   
> -	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
> -	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
> +	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
> +	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
>   	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
>   	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
>   	inst->vsi_ctx.dec.cap_num_planes =
> 

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

* Re: [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
@ 2021-11-22  7:11   ` Dafna Hirschfeld
  0 siblings, 0 replies; 9+ messages in thread
From: Dafna Hirschfeld @ 2021-11-22  7:11 UTC (permalink / raw)
  To: Yunfei Dong, Steve Cho, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Hsin-Yi Wang, Fritz Koenig, Benjamin Gaignard, Daniel Vetter,
	dri-devel, Irui Wang, linux-media, devicetree, linux-kernel,
	linux-arm-kernel, srv_heupstream, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, Nicolas Dufresne,
	Steve Cho



On 04.11.21 14:24, Yunfei Dong wrote:
> Width and height need to 64 bytes aligned when setting the format.
> Need to make sure all is 64 bytes align when use width and height to
> calculate buffer size.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Steve Cho <stevecho@chromium.org>
> ---
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
>   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index e30806c1faea..66cd6d2242c3 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -11,6 +11,7 @@
>   #include <media/videobuf2-core.h>
>   #include <media/v4l2-mem2mem.h>
>   
> +#define VCODEC_DEC_ALIGNED_64 64

This define is a bit useless, it doesn't improve readability,
if you do ALIGN(x, 64) it is already clear enough.

Thank,
Dafna

>   #define VCODEC_CAPABILITY_4K_DISABLED	0x10
>   #define VCODEC_DEC_4K_CODED_WIDTH	4096U
>   #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> index d402fc4bda69..e1a3011772a9 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> @@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
>   {
>   	struct mtk_vcodec_ctx *ctx = inst->ctx;
>   
> -	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
> -	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
> +	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
> +	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
>   	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
>   	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
>   	inst->vsi_ctx.dec.cap_num_planes =
> 

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

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

* Re: [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
@ 2021-11-22  7:11   ` Dafna Hirschfeld
  0 siblings, 0 replies; 9+ messages in thread
From: Dafna Hirschfeld @ 2021-11-22  7:11 UTC (permalink / raw)
  To: Yunfei Dong, Steve Cho, Alexandre Courbot, Hans Verkuil,
	Tzung-Bi Shih, Tiffany Lin, Andrew-CT Chen,
	Mauro Carvalho Chehab, Rob Herring, Matthias Brugger,
	Tomasz Figa
  Cc: Hsin-Yi Wang, Fritz Koenig, Benjamin Gaignard, Daniel Vetter,
	dri-devel, Irui Wang, linux-media, devicetree, linux-kernel,
	linux-arm-kernel, srv_heupstream, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, Nicolas Dufresne,
	Steve Cho



On 04.11.21 14:24, Yunfei Dong wrote:
> Width and height need to 64 bytes aligned when setting the format.
> Need to make sure all is 64 bytes align when use width and height to
> calculate buffer size.
> 
> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> Tested-by: Steve Cho <stevecho@chromium.org>
> ---
>   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
>   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> index e30806c1faea..66cd6d2242c3 100644
> --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> @@ -11,6 +11,7 @@
>   #include <media/videobuf2-core.h>
>   #include <media/v4l2-mem2mem.h>
>   
> +#define VCODEC_DEC_ALIGNED_64 64

This define is a bit useless, it doesn't improve readability,
if you do ALIGN(x, 64) it is already clear enough.

Thank,
Dafna

>   #define VCODEC_CAPABILITY_4K_DISABLED	0x10
>   #define VCODEC_DEC_4K_CODED_WIDTH	4096U
>   #define VCODEC_DEC_4K_CODED_HEIGHT	2304U
> diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> index d402fc4bda69..e1a3011772a9 100644
> --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> @@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst *inst,
>   {
>   	struct mtk_vcodec_ctx *ctx = inst->ctx;
>   
> -	ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
> -	ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
> +	ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w, VCODEC_DEC_ALIGNED_64);
> +	ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h, VCODEC_DEC_ALIGNED_64);
>   	ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
>   	ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
>   	inst->vsi_ctx.dec.cap_num_planes =
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes
  2021-11-22  7:11   ` Dafna Hirschfeld
                     ` (2 preceding siblings ...)
  (?)
@ 2021-11-22 18:25   ` Steve Cho
  -1 siblings, 0 replies; 9+ messages in thread
From: Steve Cho @ 2021-11-22 18:25 UTC (permalink / raw)
  To: Dafna Hirschfeld
  Cc: Andrew-CT Chen, Steve Cho, Yunfei Dong, dri-devel, Irui Wang,
	Tiffany Lin, Benjamin Gaignard,
	Project_Global_Chrome_Upstream_Group, Fritz Koenig, linux-media,
	devicetree, Tzung-Bi Shih, Tomasz Figa, Rob Herring,
	linux-mediatek, Hsin-Yi Wang, Matthias Brugger,
	Mauro Carvalho Chehab, linux-arm-kernel, Alexandre Courbot,
	srv_heupstream, linux-kernel, Hans Verkuil, Nicolas Dufresne

[-- Attachment #1: Type: text/plain, Size: 2807 bytes --]

Thank you Dafna for providing the feedback.

Yes, I agree that ALIGN(x, 64) is clear enough.
I forgot the history, but I think it was probably one of my comment before.
For this case, it is also only used in one place, so not much benefit in
that sense as well.
(Unless it is planned to be used in many other places.)

Yunfei, either way is fine with me.
Wasn't this change was already merged in media stage though?

Thanks,
Steve

On Sun, Nov 21, 2021 at 11:11 PM Dafna Hirschfeld <
dafna.hirschfeld@collabora.com> wrote:

>
>
> On 04.11.21 14:24, Yunfei Dong wrote:
> > Width and height need to 64 bytes aligned when setting the format.
> > Need to make sure all is 64 bytes align when use width and height to
> > calculate buffer size.
> >
> > Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
> > Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> > Tested-by: Steve Cho <stevecho@chromium.org>
> > ---
> >   drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h        | 1 +
> >   drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c | 4 ++--
> >   2 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> > index e30806c1faea..66cd6d2242c3 100644
> > --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> > +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
> > @@ -11,6 +11,7 @@
> >   #include <media/videobuf2-core.h>
> >   #include <media/v4l2-mem2mem.h>
> >
> > +#define VCODEC_DEC_ALIGNED_64 64
>
> This define is a bit useless, it doesn't improve readability,
> if you do ALIGN(x, 64) it is already clear enough.
>
> Thank,
> Dafna
>
> >   #define VCODEC_CAPABILITY_4K_DISABLED       0x10
> >   #define VCODEC_DEC_4K_CODED_WIDTH   4096U
> >   #define VCODEC_DEC_4K_CODED_HEIGHT  2304U
> > diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> > index d402fc4bda69..e1a3011772a9 100644
> > --- a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> > +++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_if.c
> > @@ -562,8 +562,8 @@ static void get_pic_info(struct vdec_h264_slice_inst
> *inst,
> >   {
> >       struct mtk_vcodec_ctx *ctx = inst->ctx;
> >
> > -     ctx->picinfo.buf_w = (ctx->picinfo.pic_w + 15) & 0xFFFFFFF0;
> > -     ctx->picinfo.buf_h = (ctx->picinfo.pic_h + 31) & 0xFFFFFFE0;
> > +     ctx->picinfo.buf_w = ALIGN(ctx->picinfo.pic_w,
> VCODEC_DEC_ALIGNED_64);
> > +     ctx->picinfo.buf_h = ALIGN(ctx->picinfo.pic_h,
> VCODEC_DEC_ALIGNED_64);
> >       ctx->picinfo.fb_sz[0] = ctx->picinfo.buf_w * ctx->picinfo.buf_h;
> >       ctx->picinfo.fb_sz[1] = ctx->picinfo.fb_sz[0] >> 1;
> >       inst->vsi_ctx.dec.cap_num_planes =
> >
>

[-- Attachment #2: Type: text/html, Size: 3971 bytes --]

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

end of thread, other threads:[~2021-11-22 18:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-04 12:24 [PATCH v3] media: mtk-vcodec: Align width and height to 64 bytes Yunfei Dong
2021-11-04 12:24 ` Yunfei Dong
2021-11-04 12:24 ` Yunfei Dong
2021-11-04 12:24 ` Yunfei Dong
2021-11-22  7:11 ` Dafna Hirschfeld
2021-11-22  7:11   ` Dafna Hirschfeld
2021-11-22  7:11   ` Dafna Hirschfeld
2021-11-22  7:11   ` Dafna Hirschfeld
2021-11-22 18:25   ` Steve Cho

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.