From: Kamil Debski <kamil@wypas.org>
To: Smitha T Murthy <smitha.t@samsung.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Kyungmin Park <kyungmin.park@samsung.com>,
jtp.park@samsung.com, a.hajda@samsung.com, mchehab@kernel.org,
pankaj.dubey@samsung.com, krzk@kernel.org,
Marek Szyprowski <m.szyprowski@samsung.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: Re: [Patch v5 04/12] [media] s5p-mfc: Support MFCv10.10 buffer requirements
Date: Tue, 27 Jun 2017 22:30:29 +0200 [thread overview]
Message-ID: <CAP3TMiE=gCDJ3q8G1JKiziAdfd33ca59koRaOz3myz6M-KLbvA@mail.gmail.com> (raw)
In-Reply-To: <1497849055-26583-5-git-send-email-smitha.t@samsung.com>
Hi,
Please find my comments inline.
On 19 June 2017 at 07:10, Smitha T Murthy <smitha.t@samsung.com> wrote:
> Aligning the luma_dpb_size, chroma_dpb_size, mv_size and me_buffer_size
> for MFCv10.10.
>
> Signed-off-by: Smitha T Murthy <smitha.t@samsung.com>
> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
> drivers/media/platform/s5p-mfc/regs-mfc-v10.h | 19 +++++
> drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 95 +++++++++++++++++++------
> drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h | 2 +
> 3 files changed, 95 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
> index 1ca09d6..3f0dab3 100644
> --- a/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
> +++ b/drivers/media/platform/s5p-mfc/regs-mfc-v10.h
> @@ -32,5 +32,24 @@
> #define MFC_VERSION_V10 0xA0
> #define MFC_NUM_PORTS_V10 1
>
> +/* MFCv10 codec defines*/
> +#define S5P_FIMV_CODEC_HEVC_ENC 26
> +
> +/* Encoder buffer size for MFC v10.0 */
> +#define ENC_V100_BASE_SIZE(x, y) \
> + (((x + 3) * (y + 3) * 8) \
> + + ((y * 64) + 1280) * DIV_ROUND_UP(x, 8))
> +
> +#define ENC_V100_H264_ME_SIZE(x, y) \
> + (ENC_V100_BASE_SIZE(x, y) \
> + + (DIV_ROUND_UP(x * y, 64) * 32))
> +
> +#define ENC_V100_MPEG4_ME_SIZE(x, y) \
> + (ENC_V100_BASE_SIZE(x, y) \
> + + (DIV_ROUND_UP(x * y, 128) * 16))
> +
> +#define ENC_V100_VP8_ME_SIZE(x, y) \
> + ENC_V100_BASE_SIZE(x, y)
> +
> #endif /*_REGS_MFC_V10_H*/
>
> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
> index f1a8c53..83ea733 100644
> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c
> @@ -64,6 +64,7 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
> {
> struct s5p_mfc_dev *dev = ctx->dev;
> unsigned int mb_width, mb_height;
> + unsigned int lcu_width = 0, lcu_height = 0;
> int ret;
>
> mb_width = MB_WIDTH(ctx->img_width);
> @@ -74,7 +75,9 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
> ctx->luma_size, ctx->chroma_size, ctx->mv_size);
> mfc_debug(2, "Totals bufs: %d\n", ctx->total_dpb_count);
> } else if (ctx->type == MFCINST_ENCODER) {
> - if (IS_MFCV8_PLUS(dev))
> + if (IS_MFCV10(dev)) {IZE_V10 (15 * SZ_1K)
> + ctx->tmv_buffer_size = 0;
It would look much better to surround the above with braces, even
though it's only a single line.
> + } else if (IS_MFCV8_PLUS(dev))
> ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
> ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V8(mb_width, mb_height),
> S5P_FIMV_TMV_BUFFER_ALIGN_V6);
> @@ -82,13 +85,36 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
> ctx->tmv_buffer_size = S5P_FIMV_NUM_TMV_BUFFERS_V6 *
> ALIGN(S5P_FIMV_TMV_BUFFER_SIZE_V6(mb_width, mb_height),
> S5P_FIMV_TMV_BUFFER_ALIGN_V6);
> -
> - ctx->luma_dpb_size = ALIGN((mb_width * mb_height) *
> - S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
> - S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
> - ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
> - S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,
> - S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6);
> + if (IS_MFCV10(dev)) {
> + lcu_width = enc_lcu_width(ctx->img_width);
> + lcu_height = enc_lcu_height(ctx->img_height);
> + if (ctx->codec_mode != S5P_FIMV_CODEC_HEVC_ENC) {
> + ctx->luma_dpb_size =
> + ALIGN((mb_width * 16), 64)
> + * ALIGN((mb_height * 16), 32)
> + + 64;
> + ctx->chroma_dpb_size =
> + ALIGN((mb_width * 16), 64)
> + * (mb_height * 8)
> + + 64;
> + } else {
> + ctx->luma_dpb_size =
> + ALIGN((lcu_width * 32), 64)
> + * ALIGN((lcu_height * 32), 32)
> + + 64;
> + ctx->chroma_dpb_size =
> + ALIGN((lcu_width * 32), 64)
> + * (lcu_height * 16)
> + + 64;
> + }
> + } else {
> + ctx->luma_dpb_size = ALIGN((mb_width * mb_height) *
> + S5P_FIMV_LUMA_MB_TO_PIXEL_V6,
> + S5P_FIMV_LUMA_DPB_BUFFER_ALIGN_V6);
> + ctx->chroma_dpb_size = ALIGN((mb_width * mb_height) *
> + S5P_FIMV_CHROMA_MB_TO_PIXEL_V6,
> + S5P_FIMV_CHROMA_DPB_BUFFER_ALIGN_V6);
> + }
> if (IS_MFCV8_PLUS(dev))
> ctx->me_buffer_size = ALIGN(S5P_FIMV_ME_BUFFER_SIZE_V8(
> ctx->img_width, ctx->img_height,
> @@ -197,6 +223,8 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
> case S5P_MFC_CODEC_H264_ENC:
> if (IS_MFCV10(dev)) {
> mfc_debug(2, "Use min scratch buffer size\n");
> + ctx->me_buffer_size =
> + ALIGN(ENC_V100_H264_ME_SIZE(mb_width, mb_height), 16);
> } else if (IS_MFCV8_PLUS(dev))
> ctx->scratch_buf_size =
> S5P_FIMV_SCRATCH_BUF_SIZE_H264_ENC_V8(
> @@ -219,6 +247,9 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
> case S5P_MFC_CODEC_H263_ENC:
> if (IS_MFCV10(dev)) {
> mfc_debug(2, "Use min scratch buffer size\n");
> + ctx->me_buffer_size =
> + ALIGN(ENC_V100_MPEG4_ME_SIZE(mb_width,
> + mb_height), 16);
> } else
> ctx->scratch_buf_size =
> S5P_FIMV_SCRATCH_BUF_SIZE_MPEG4_ENC_V6(
> @@ -235,7 +266,10 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx)
> case S5P_MFC_CODEC_VP8_ENC:
> if (IS_MFCV10(dev)) {
> mfc_debug(2, "Use min scratch buffer size\n");
> - } else if (IS_MFCV8_PLUS(dev))
> + ctx->me_buffer_size =
> + ALIGN(ENC_V100_VP8_ME_SIZE(mb_width, mb_height),
> + 16);
> + } else if (IS_MFCV8_PLUS(dev))
> ctx->scratch_buf_size =
> S5P_FIMV_SCRATCH_BUF_SIZE_VP8_ENC_V8(
> mb_width,
> @@ -393,13 +427,13 @@ static void s5p_mfc_dec_calc_dpb_size_v6(struct s5p_mfc_ctx *ctx)
>
> if (ctx->codec_mode == S5P_MFC_CODEC_H264_DEC ||
> ctx->codec_mode == S5P_MFC_CODEC_H264_MVC_DEC) {
> - if (IS_MFCV10(dev))
> + if (IS_MFCV10(dev)) {
> ctx->mv_size = S5P_MFC_DEC_MV_SIZE_V10(ctx->img_width,
> ctx->img_height);
> - else
> + } else {
> ctx->mv_size = S5P_MFC_DEC_MV_SIZE_V6(ctx->img_width,
> ctx->img_height);
> - ctx->mv_size = ALIGN(ctx->mv_size, 16);
> + }
> } else {
> ctx->mv_size = 0;
> }
> @@ -596,15 +630,34 @@ static int s5p_mfc_set_enc_ref_buffer_v6(struct s5p_mfc_ctx *ctx)
>
> mfc_debug(2, "Buf1: %p (%d)\n", (void *)buf_addr1, buf_size1);
>
> - for (i = 0; i < ctx->pb_count; i++) {
> - writel(buf_addr1, mfc_regs->e_luma_dpb + (4 * i));
> - buf_addr1 += ctx->luma_dpb_size;
> - writel(buf_addr1, mfc_regs->e_chroma_dpb + (4 * i));
> - buf_addr1 += ctx->chroma_dpb_size;
> - writel(buf_addr1, mfc_regs->e_me_buffer + (4 * i));
> - buf_addr1 += ctx->me_buffer_size;
> - buf_size1 -= (ctx->luma_dpb_size + ctx->chroma_dpb_size +
> - ctx->me_buffer_size);
> + if (IS_MFCV10(dev)) {
> + /* start address of per buffer is aligned */
> + for (i = 0; i < ctx->pb_count; i++) {
> + writel(buf_addr1, mfc_regs->e_luma_dpb + (4 * i));
> + buf_addr1 += ctx->luma_dpb_size;
> + buf_size1 -= ctx->luma_dpb_size;
> + }
> + for (i = 0; i < ctx->pb_count; i++) {
> + writel(buf_addr1, mfc_regs->e_chroma_dpb + (4 * i));
> + buf_addr1 += ctx->chroma_dpb_size;
> + buf_size1 -= ctx->chroma_dpb_size;
> + }
> + for (i = 0; i < ctx->pb_count; i++) {
> + writel(buf_addr1, mfc_regs->e_me_buffer + (4 * i));
> + buf_addr1 += ctx->me_buffer_size;
> + buf_size1 -= ctx->me_buffer_size;
> + }
> + } else {
> + for (i = 0; i < ctx->pb_count; i++) {
> + writel(buf_addr1, mfc_regs->e_luma_dpb + (4 * i));
> + buf_addr1 += ctx->luma_dpb_size;
> + writel(buf_addr1, mfc_regs->e_chroma_dpb + (4 * i));
> + buf_addr1 += ctx->chroma_dpb_size;
> + writel(buf_addr1, mfc_regs->e_me_buffer + (4 * i));
> + buf_addr1 += ctx->me_buffer_size;
> + buf_size1 -= (ctx->luma_dpb_size + ctx->chroma_dpb_size
> + + ctx->me_buffer_size);
> + }
> }
>
> writel(buf_addr1, mfc_regs->e_scratch_buffer_addr);
> diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h
> index 021b8db..975bbc5 100644
> --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h
> +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.h
> @@ -26,6 +26,8 @@
> (((MB_HEIGHT(y)+1)/2)*2) * 64 + 128)
> #define S5P_MFC_DEC_MV_SIZE_V10(x, y) (MB_WIDTH(x) * \
> (((MB_HEIGHT(y)+1)/2)*2) * 64 + 512)
> +#define enc_lcu_width(x_size) DIV_ROUND_UP(x_size, 32)
> +#define enc_lcu_height(y_size) DIV_ROUND_UP(y_size, 32)
Why is this in lower case? Maybe S5P_MFC_LCU_WIDTH/HEIGHT would be better?
>
> /* Definition */
> #define ENC_MULTI_SLICE_MB_MAX ((1 << 30) - 1)
> --
> 2.7.4
>
Apart from the above, it looks good to me.
Acked-by: Kamil Debski <kamil@wypas.org>
Best wishes,
Kamil Debski
next prev parent reply other threads:[~2017-06-27 20:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20170619052453epcas1p426ebca32768cee57390f39b53d835e81@epcas1p4.samsung.com>
2017-06-19 5:10 ` [Patch v5 00/12] Add MFC v10.10 support Smitha T Murthy
[not found] ` <CGME20170619052455epcas5p3b0c71e840af3b9022bf69d1058cc94e5@epcas5p3.samsung.com>
2017-06-19 5:10 ` [Patch v5 01/12] [media] s5p-mfc: Rename IS_MFCV8 macro Smitha T Murthy
[not found] ` <CGME20170619052458epcas5p3ffbe45cb390e87df6bb11980cd7498aa@epcas5p3.samsung.com>
2017-06-19 5:10 ` [Patch v5 02/12] [media] s5p-mfc: Adding initial support for MFC v10.10 Smitha T Murthy
[not found] ` <CGME20170619052500epcas1p477df788aee11a5a0d3e2defac97e9ae3@epcas1p4.samsung.com>
2017-06-19 5:10 ` [Patch v5 03/12] [media] s5p-mfc: Use min scratch buffer size as provided by F/W Smitha T Murthy
[not found] ` <CGME20170619052502epcas1p41e0ba072755ca63278f2d4cfdc03ed06@epcas1p4.samsung.com>
2017-06-19 5:10 ` [Patch v5 04/12] [media] s5p-mfc: Support MFCv10.10 buffer requirements Smitha T Murthy
2017-06-27 20:30 ` Kamil Debski [this message]
2017-06-28 5:06 ` Smitha T Murthy
[not found] ` <CGME20170619052505epcas5p33a78ee709263cc9ae33cd9383794ca06@epcas5p3.samsung.com>
2017-06-19 5:10 ` [Patch v5 05/12] [media] videodev2.h: Add v4l2 definition for HEVC Smitha T Murthy
2017-07-07 14:56 ` Stanimir Varbanov
2017-07-17 11:12 ` Smitha T Murthy
2017-07-20 13:07 ` Hans Verkuil
2017-07-24 4:29 ` Smitha T Murthy
[not found] ` <CGME20170619052507epcas1p406fa9f6d84baa9c11050b1998021788a@epcas1p4.samsung.com>
2017-06-19 5:10 ` [Patch v5 06/12] [media] v4l2-ioctl: add HEVC format description Smitha T Murthy
2017-07-20 13:07 ` Hans Verkuil
2017-07-24 4:28 ` Smitha T Murthy
[not found] ` <CGME20170619052509epcas1p4841f9c3733280a232d35c8624fe80576@epcas1p4.samsung.com>
2017-06-19 5:10 ` [Patch v5 07/12] Documentation: v4l: Documentation for HEVC v4l2 definition Smitha T Murthy
[not found] ` <CGME20170619052511epcas1p4e79efd3c9f0f8062eeac1ab4884b709e@epcas1p4.samsung.com>
2017-06-19 5:10 ` [Patch v5 08/12] [media] s5p-mfc: Add support for HEVC decoder Smitha T Murthy
[not found] ` <CGME20170619052514epcas1p45d4b590d673a0ff2a3cf0117d55e656a@epcas1p4.samsung.com>
2017-06-19 5:10 ` [Patch v5 09/12] [media] s5p-mfc: Add VP9 decoder support Smitha T Murthy
[not found] ` <CGME20170619052516epcas5p349b080cc6c242444d2db1f3c0e1c6f68@epcas5p3.samsung.com>
2017-06-19 5:10 ` [Patch v5 10/12] [media] v4l2: Add v4l2 control IDs for HEVC encoder Smitha T Murthy
2017-07-20 13:13 ` Hans Verkuil
2017-07-24 4:30 ` Smitha T Murthy
[not found] ` <CGME20170619052519epcas5p3bacba6c01bf2f135e5cd628226f8d24b@epcas5p3.samsung.com>
2017-06-19 5:10 ` [Patch v5 11/12] [media] s5p-mfc: Add support " Smitha T Murthy
2017-07-20 13:32 ` Hans Verkuil
2017-07-24 4:40 ` Smitha T Murthy
[not found] ` <CGME20170619052521epcas5p36a0bc384d10809dcfe775e6da87ed37b@epcas5p3.samsung.com>
2017-06-19 5:10 ` [Patch v5 12/12] Documention: v4l: Documentation for HEVC CIDs Smitha T Murthy
2017-06-28 20:04 ` Kamil Debski
2017-06-30 3:24 ` Smitha T Murthy
2017-07-07 14:59 ` Stanimir Varbanov
2017-07-17 11:18 ` Smitha T Murthy
2017-07-20 15:46 ` Stanimir Varbanov
2017-07-25 4:53 ` Smitha T Murthy
2017-08-17 14:43 ` Stanimir Varbanov
2017-07-20 14:50 ` Hans Verkuil
2017-07-25 4:48 ` Smitha T Murthy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP3TMiE=gCDJ3q8G1JKiziAdfd33ca59koRaOz3myz6M-KLbvA@mail.gmail.com' \
--to=kamil@wypas.org \
--cc=a.hajda@samsung.com \
--cc=jtp.park@samsung.com \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mchehab@kernel.org \
--cc=pankaj.dubey@samsung.com \
--cc=s.nawrocki@samsung.com \
--cc=smitha.t@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).