LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Alexandre Courbot <acourbot@chromium.org>
To: Tiffany Lin <tiffany.lin@mediatek.com>,
	Andrew-CT Chen <andrew-ct.chen@mediatek.com>,
	Rui Wang <gtk_ruiwang@mediatek.com>,
	Yunfei Dong <yunfei.dong@mediatek.com>,
	Pi-Hsun Shih <pihsun@chromium.org>,
	Maoguang Meng <maoguang.meng@mediatek.com>
Cc: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Alexandre Courbot <acourbot@chromium.org>
Subject: [PATCH v2 18/18] media: mtk-vcodec: venc: fix invalid time per frame in S_PARM
Date: Fri, 26 Jun 2020 17:04:42 +0900
Message-ID: <20200626080442.292309-19-acourbot@chromium.org> (raw)
In-Reply-To: <20200626080442.292309-1-acourbot@chromium.org>

v4l2-compliance expects the driver to adjust the time per frame if it is
invalid (numerator or denominator set to 0). Adjust it to the default
value in these cases.

Signed-off-by: Alexandre Courbot <acourbot@chromium.org>
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
index c9756a4748ef..1b4be2493aa5 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
@@ -201,14 +201,18 @@ static int vidioc_venc_s_parm(struct file *file, void *priv,
 			      struct v4l2_streamparm *a)
 {
 	struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
+	struct v4l2_fract *timeperframe = &a->parm.output.timeperframe;
 
 	if (a->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
 		return -ENOTTY;
 
-	ctx->enc_params.framerate_num =
-			a->parm.output.timeperframe.denominator;
-	ctx->enc_params.framerate_denom =
-			a->parm.output.timeperframe.numerator;
+	if (timeperframe->numerator == 0 || timeperframe->denominator == 0) {
+		timeperframe->numerator = MTK_DEFAULT_FRAMERATE_NUM;
+		timeperframe->denominator = MTK_DEFAULT_FRAMERATE_DENOM;
+	}
+
+	ctx->enc_params.framerate_num = timeperframe->denominator;
+	ctx->enc_params.framerate_denom = timeperframe->numerator;
 	ctx->param_change |= MTK_ENCODE_PARAM_FRAMERATE;
 
 	a->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
-- 
2.27.0.212.ge8ba1cc988-goog


      parent reply index

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26  8:04 [PATCH v2 00/18] media: mtk-vcodec: venc: support for MT8183 and v4l2-compliance fixes Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 01/18] media: mtk-vcodec: abstract firmware interface Alexandre Courbot
2020-07-01  3:19   ` Tiffany Lin
2020-06-26  8:04 ` [PATCH v2 02/18] media: mtk-vcodec: add SCP firmware ops Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 03/18] media: mtk-vcodec: venc: support SCP firmware Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 04/18] media: mtk-vcodec: venc: handle firmware version field Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 05/18] media: mtk-vcodec: venc: specify bitrate range per-chip Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 06/18] media: mtk-vcodec: venc: specify supported formats per-chip Alexandre Courbot
2020-07-01  3:15   ` Tiffany Lin
2020-06-26  8:04 ` [PATCH v2 07/18] media: mtk-vcodec: add support for MT8183 encoder Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 08/18] media: dt-bindings: mtk-vcodec: specify SCP node Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 09/18] media: dt-bindings: mtk-vcodec: document mediatek,mt8183-vcodec-enc Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 10/18] Revert "media: mtk-vcodec: Remove extra area allocation in an input buffer on encoding" Alexandre Courbot
2020-07-01  3:30   ` Tiffany Lin
2020-06-26  8:04 ` [PATCH v2 11/18] media: mtk-vcodec: venc support MIN_OUTPUT_BUFFERS control Alexandre Courbot
2020-07-01  3:30   ` Tiffany Lin
2020-06-26  8:04 ` [PATCH v2 12/18] media: mtk-vcodec: venc: set OUTPUT buffers field to V4L2_FIELD_NONE Alexandre Courbot
2020-07-01  3:46   ` Tiffany Lin
2020-06-26  8:04 ` [PATCH v2 13/18] media: mtk-vcodec: venc: use platform data for ENUM_FRAMESIZES Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 14/18] media: mtk-vcodec: venc: support ENUM_FRAMESIZES on OUTPUT formats Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 15/18] media: mtk-vcodec: venc: support G_PARM on CAPTURE queue Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 16/18] media: mtk-vcodec: venc: make S_PARM return -ENOTTY for " Alexandre Courbot
2020-07-03  8:30   ` Hans Verkuil
2020-07-04 12:36     ` Alexandre Courbot
2020-07-06 12:41       ` Hans Verkuil
2020-07-07  4:44         ` Alexandre Courbot
2020-06-26  8:04 ` [PATCH v2 17/18] media: mtk-vcodec: venc: set default time per frame Alexandre Courbot
2020-06-26  8:04 ` Alexandre Courbot [this message]

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=20200626080442.292309-19-acourbot@chromium.org \
    --to=acourbot@chromium.org \
    --cc=andrew-ct.chen@mediatek.com \
    --cc=gtk_ruiwang@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=maoguang.meng@mediatek.com \
    --cc=pihsun@chromium.org \
    --cc=tiffany.lin@mediatek.com \
    --cc=yunfei.dong@mediatek.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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git