All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] [media] coda: extend GOP size range
@ 2017-07-07  9:58 Philipp Zabel
  2017-07-07  9:58 ` [PATCH 2/5] [media] coda: set field of destination buffers Philipp Zabel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-07-07  9:58 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Philipp Zabel

CodaDx6 only accepts GOP sizes up to 60 frames, but CODA960 can handle
up to 99 frames. If we disable automatic I frame generation altogether
by setting GOP size to 0, we can let an application produce arbitrarily
large I frame intervals using the V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME
control.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-bit.c    | 5 +++--
 drivers/media/platform/coda/coda-common.c | 4 +++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index bba1eb43b5d83..50eed636830f8 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1006,7 +1006,7 @@ static int coda_start_encoding(struct coda_ctx *ctx)
 			break;
 		}
 		coda_write(dev, value, CODA_CMD_ENC_SEQ_SLICE_MODE);
-		value = ctx->params.gop_size & CODA_GOP_SIZE_MASK;
+		value = ctx->params.gop_size;
 		coda_write(dev, value, CODA_CMD_ENC_SEQ_GOP_SIZE);
 	}
 
@@ -1250,7 +1250,8 @@ static int coda_prepare_encode(struct coda_ctx *ctx)
 	force_ipicture = ctx->params.force_ipicture;
 	if (force_ipicture)
 		ctx->params.force_ipicture = false;
-	else if ((src_buf->sequence % ctx->params.gop_size) == 0)
+	else if (ctx->params.gop_size != 0 &&
+		 (src_buf->sequence % ctx->params.gop_size) == 0)
 		force_ipicture = 1;
 
 	/*
diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c
index 829c7895a98a2..218d778a9c45a 100644
--- a/drivers/media/platform/coda/coda-common.c
+++ b/drivers/media/platform/coda/coda-common.c
@@ -1734,10 +1734,12 @@ static const struct v4l2_ctrl_ops coda_ctrl_ops = {
 
 static void coda_encode_ctrls(struct coda_ctx *ctx)
 {
+	int max_gop_size = (ctx->dev->devtype->product == CODA_DX6) ? 60 : 99;
+
 	v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
 		V4L2_CID_MPEG_VIDEO_BITRATE, 0, 32767000, 1000, 0);
 	v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
-		V4L2_CID_MPEG_VIDEO_GOP_SIZE, 1, 60, 1, 16);
+		V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, max_gop_size, 1, 16);
 	v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
 		V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP, 0, 51, 1, 25);
 	v4l2_ctrl_new_std(&ctx->ctrls, &coda_ctrl_ops,
-- 
2.11.0

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

* [PATCH 2/5] [media] coda: set field of destination buffers
  2017-07-07  9:58 [PATCH 1/5] [media] coda: extend GOP size range Philipp Zabel
@ 2017-07-07  9:58 ` Philipp Zabel
  2017-07-07  9:58 ` [PATCH 3/5] [media] coda: align internal mpeg4 framebuffers to 16x16 macroblocks Philipp Zabel
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-07-07  9:58 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Philipp Zabel

Set the field of destination buffers properly.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-bit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 50eed636830f8..a4abeabfa5377 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1412,6 +1412,7 @@ static void coda_finish_encode(struct coda_ctx *ctx)
 	}
 
 	dst_buf->vb2_buf.timestamp = src_buf->vb2_buf.timestamp;
+	dst_buf->field = src_buf->field;
 	dst_buf->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
 	dst_buf->flags |=
 		src_buf->flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
@@ -2154,6 +2155,7 @@ static void coda_finish_decode(struct coda_ctx *ctx)
 		dst_buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
 		dst_buf->sequence = ctx->osequence++;
 
+		dst_buf->field = V4L2_FIELD_NONE;
 		dst_buf->flags &= ~(V4L2_BUF_FLAG_KEYFRAME |
 					     V4L2_BUF_FLAG_PFRAME |
 					     V4L2_BUF_FLAG_BFRAME);
-- 
2.11.0

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

* [PATCH 3/5] [media] coda: align internal mpeg4 framebuffers to 16x16 macroblocks
  2017-07-07  9:58 [PATCH 1/5] [media] coda: extend GOP size range Philipp Zabel
  2017-07-07  9:58 ` [PATCH 2/5] [media] coda: set field of destination buffers Philipp Zabel
@ 2017-07-07  9:58 ` Philipp Zabel
  2017-07-07  9:58 ` [PATCH 4/5] [media] coda: set MPEG-4 encoder class register Philipp Zabel
  2017-07-07  9:58 ` [PATCH 5/5] [media] coda: mark CODA960 firmware versions 2.3.10 and 3.1.1 as supported Philipp Zabel
  3 siblings, 0 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-07-07  9:58 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Philipp Zabel

This fixes visual artifacts in the first macroblock row of encoded
MPEG-4 video output caused by 8 additional lines of luma data leaking
into the chroma planes of the internal reference framebuffers: the
buffer size is rounded up to a multiple of 16x16 macroblock size, same
as for the h.264 encoder.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-bit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index a4abeabfa5377..2f31c672aba04 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -394,7 +394,8 @@ static int coda_alloc_framebuffers(struct coda_ctx *ctx,
 	int i;
 
 	if (ctx->codec->src_fourcc == V4L2_PIX_FMT_H264 ||
-	    ctx->codec->dst_fourcc == V4L2_PIX_FMT_H264) {
+	    ctx->codec->dst_fourcc == V4L2_PIX_FMT_H264 ||
+	    ctx->codec->dst_fourcc == V4L2_PIX_FMT_MPEG4) {
 		width = round_up(q_data->width, 16);
 		height = round_up(q_data->height, 16);
 	} else {
-- 
2.11.0

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

* [PATCH 4/5] [media] coda: set MPEG-4 encoder class register
  2017-07-07  9:58 [PATCH 1/5] [media] coda: extend GOP size range Philipp Zabel
  2017-07-07  9:58 ` [PATCH 2/5] [media] coda: set field of destination buffers Philipp Zabel
  2017-07-07  9:58 ` [PATCH 3/5] [media] coda: align internal mpeg4 framebuffers to 16x16 macroblocks Philipp Zabel
@ 2017-07-07  9:58 ` Philipp Zabel
  2017-07-07  9:58 ` [PATCH 5/5] [media] coda: mark CODA960 firmware versions 2.3.10 and 3.1.1 as supported Philipp Zabel
  3 siblings, 0 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-07-07  9:58 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Philipp Zabel

Explicitly set MPEG-4 encoder class register instead of relying on the
default value of 0.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-bit.c  | 4 ++++
 drivers/media/platform/coda/coda_regs.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 2f31c672aba04..2a8e13c53f2e1 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -1655,6 +1655,10 @@ static int __coda_start_decoding(struct coda_ctx *ctx)
 		ctx->params.codec_mode_aux = CODA_MP4_AUX_MPEG4;
 	else
 		ctx->params.codec_mode_aux = 0;
+	if (src_fourcc == V4L2_PIX_FMT_MPEG4) {
+		coda_write(dev, CODA_MP4_CLASS_MPEG4,
+			   CODA_CMD_DEC_SEQ_MP4_ASP_CLASS);
+	}
 	if (src_fourcc == V4L2_PIX_FMT_H264) {
 		if (dev->devtype->product == CODA_7541) {
 			coda_write(dev, ctx->psbuf.paddr,
diff --git a/drivers/media/platform/coda/coda_regs.h b/drivers/media/platform/coda/coda_regs.h
index 77ee46a934272..38df5fd9a2fa7 100644
--- a/drivers/media/platform/coda/coda_regs.h
+++ b/drivers/media/platform/coda/coda_regs.h
@@ -158,6 +158,7 @@
 #define CODA_CMD_DEC_SEQ_PS_BB_START		0x194
 #define CODA_CMD_DEC_SEQ_PS_BB_SIZE		0x198
 #define CODA_CMD_DEC_SEQ_MP4_ASP_CLASS		0x19c
+#define		CODA_MP4_CLASS_MPEG4			0
 #define CODA_CMD_DEC_SEQ_X264_MV_EN		0x19c
 #define CODA_CMD_DEC_SEQ_SPP_CHUNK_SIZE		0x1a0
 
-- 
2.11.0

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

* [PATCH 5/5] [media] coda: mark CODA960 firmware versions 2.3.10 and 3.1.1 as supported
  2017-07-07  9:58 [PATCH 1/5] [media] coda: extend GOP size range Philipp Zabel
                   ` (2 preceding siblings ...)
  2017-07-07  9:58 ` [PATCH 4/5] [media] coda: set MPEG-4 encoder class register Philipp Zabel
@ 2017-07-07  9:58 ` Philipp Zabel
  3 siblings, 0 replies; 5+ messages in thread
From: Philipp Zabel @ 2017-07-07  9:58 UTC (permalink / raw)
  To: linux-media; +Cc: kernel, Philipp Zabel

Firmware versions 2.3.10 revision 40778 and 3.1.1 revision 46072 are
contained in the i.MX firmware download archives provided by NXP at
http://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-3.5.7-1.0.0.bin
and http://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-5.4.bin,
respectively.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/coda/coda-bit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/coda/coda-bit.c b/drivers/media/platform/coda/coda-bit.c
index 2a8e13c53f2e1..95e4b74d5dd01 100644
--- a/drivers/media/platform/coda/coda-bit.c
+++ b/drivers/media/platform/coda/coda-bit.c
@@ -703,6 +703,8 @@ static u32 coda_supported_firmwares[] = {
 	CODA_FIRMWARE_VERNUM(CODA_DX6, 2, 2, 5),
 	CODA_FIRMWARE_VERNUM(CODA_7541, 1, 4, 50),
 	CODA_FIRMWARE_VERNUM(CODA_960, 2, 1, 5),
+	CODA_FIRMWARE_VERNUM(CODA_960, 2, 3, 10),
+	CODA_FIRMWARE_VERNUM(CODA_960, 3, 1, 1),
 };
 
 static bool coda_firmware_supported(u32 vernum)
-- 
2.11.0

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

end of thread, other threads:[~2017-07-07  9:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-07  9:58 [PATCH 1/5] [media] coda: extend GOP size range Philipp Zabel
2017-07-07  9:58 ` [PATCH 2/5] [media] coda: set field of destination buffers Philipp Zabel
2017-07-07  9:58 ` [PATCH 3/5] [media] coda: align internal mpeg4 framebuffers to 16x16 macroblocks Philipp Zabel
2017-07-07  9:58 ` [PATCH 4/5] [media] coda: set MPEG-4 encoder class register Philipp Zabel
2017-07-07  9:58 ` [PATCH 5/5] [media] coda: mark CODA960 firmware versions 2.3.10 and 3.1.1 as supported Philipp Zabel

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.