Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp745279ybh; Sun, 12 Jul 2020 23:11:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAZVOa2u80FWiDMkMSTEcx1DEsVMIv4on+lJsLxU7QDT0ItwLIUxrMWKvEi3oweuJYfG4f X-Received: by 2002:a05:6402:1c0f:: with SMTP id ck15mr85961696edb.155.1594620666440; Sun, 12 Jul 2020 23:11:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594620666; cv=none; d=google.com; s=arc-20160816; b=MBghC6vU6rAutLW1WQjPTX8cBZHrp5uMLfZBUHdcMz8Z8+Dt4kQBc1pAuOfR64JpIb njYJJ5i6XTGCWjmLsQZWSX3svrNgGP1HSJ2yuo+Hnq6YOQQ2zsDjAC/JJolbAwCwTbiU RlUZdH2ghZv2zgIOq4ITvHwI1VmJTZt92nwsM/yUXyoDy/VvZMov4aO3d1rINQtPBir2 wLpoBsl7X10mkDPlrfrkWoSfMsQMslqquDJd8Cha/ofLtINmk0jO2/gsbEgTY10qePsK kj3TmalvZN36Jnt1SSvx6zJQBqbgGyhSCOqWaUoyxUnyHS10r2XU87WpbHoNwF8ax2F/ KBRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gB83jD2FpTYfBDRkUJH8DvVVofs2yRFQbXc2yeSZvmk=; b=T3DXDYBB4KYFXC2mZ0oOAs/t4pU0BsceJbscChBcJrALZ6ANujIKIcGx5jkz5s3Qg6 Zy980hUoXMyOma9unDoN23y4YcWl7gWUKolnofO0g+sPvbie6WnbiwQuQ+VTRfTgi8NS 8sEKujjpanohISR5M0NnVtsnIJm7U97+6cerROL/ytJR3fTkKNcjuoASpRz94DphPozz ZY53IhFYpyYfW42mIgxL2pSW/o85op+mzBys7CollGR8pTLijmC58/A+Smx1wbFspkOd h5iHI/quP98Yo7mN+iCN9C5uWWQItqhTIijDsChrv5aI+EwPdE66nKd8SFMZnfHfyN/J 1OPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mQneNRTv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si8674300edp.72.2020.07.12.23.10.44; Sun, 12 Jul 2020 23:11:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mQneNRTv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729421AbgGMGKC (ORCPT + 99 others); Mon, 13 Jul 2020 02:10:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729410AbgGMGKA (ORCPT ); Mon, 13 Jul 2020 02:10:00 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7480CC08C5DD for ; Sun, 12 Jul 2020 23:10:00 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id e18so5584406pgn.7 for ; Sun, 12 Jul 2020 23:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gB83jD2FpTYfBDRkUJH8DvVVofs2yRFQbXc2yeSZvmk=; b=mQneNRTvRh7TEV8oSckX8BzrplvT9JWTPgTge++Ykp1B5RphqvW7GoZJ7CuLCG5NUG ALY50gHRt/NcNRLiQoXmQFstFkEHgQkNYkl7cQQe6wc1diyCVsgb0FDopMACd33C9vqe SGZDpkH8trEfdC9w/dw0KWhHA4PTUTO9iYCas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gB83jD2FpTYfBDRkUJH8DvVVofs2yRFQbXc2yeSZvmk=; b=F15U7A+NNei0IOHM7XzDftcYvl3VTxVLU5CjZ6gFO1bdmecXD3lc/JLDDlwpQina4x y7T5ARS50opDPdWYDpYCWocBmAMvF/PZm/GHx+dwm8NHANMHiBoGuSkoL5Hrlaj0/N0b Nit93qj9ukyOL99GGcZMS1vVcQRkeJnYBVaJpqnbWpnHn61cirhZ6WjhrW3Sd3CpU60Z pE0IQCI6gXwNTXj/6oxArlJX6XsNbmq3BDZ9z+K6CN18VxIDZzhcaS/2uFZyLh0TA+Ip l0S0Ge9VFQv3gm7A0keOmpDcCMLd7W1vTWT/aoW/+kLTQ8sxzTnYpat6ew2lcjIzbsoc ESQg== X-Gm-Message-State: AOAM531OV65a9/4IDN/0mjnGMjklW+ErFH2O4zEqmPWOJDUSAekJ3PEt 3FPbbFG5s6Rnv8spLLcloFd8Og== X-Received: by 2002:a63:fe0a:: with SMTP id p10mr66187991pgh.255.1594620600025; Sun, 12 Jul 2020 23:10:00 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:8f:203:eeb1:d7ff:fe57:b7e5]) by smtp.gmail.com with ESMTPSA id c134sm13134934pfc.115.2020.07.12.23.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2020 23:09:59 -0700 (PDT) From: Alexandre Courbot To: Tiffany Lin , Andrew-CT Chen , Hans Verkuil , Yunfei Dong , Maoguang Meng Cc: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Courbot Subject: [PATCH v3 16/16] media: mtk-vcodec: venc: fix invalid time per frame in S_PARM Date: Mon, 13 Jul 2020 15:08:42 +0900 Message-Id: <20200713060842.471356-17-acourbot@chromium.org> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200713060842.471356-1-acourbot@chromium.org> References: <20200713060842.471356-1-acourbot@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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 09baac2dbc36..82b04714f750 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -200,14 +200,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 -EINVAL; - 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.383.g050319c2ae-goog