Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp950632pxj; Fri, 21 May 2021 03:02:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLgeZTgTL/PqBNGF0HBPAwiYFc88ebwGMTzQ8P3V3M/zDF95R0VzrCKL2ToDXa4YZ59dfN X-Received: by 2002:a17:906:a103:: with SMTP id t3mr9473080ejy.334.1621591334255; Fri, 21 May 2021 03:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621591334; cv=none; d=google.com; s=arc-20160816; b=G+QgnCbz+eRM7xN9YLn0xiQZTQf9Jq7240mgACf/0JsssXu9qVGPIZf+g+4fzfPUUE MCEvnNmd5oguECRcMq6P9wKWxkq5hMZaOx3knRLYSmMiTjbE1ptNcyKM5AECkdU3gnb7 +YXzqkQ8C6VvEeK62KLe4UnhzpMJpFoYG5XO7UZNqzhBXLpPKJZ58nGgwlqr1N7vl+yC XPuNqEogTOQ6hP2nGY5acZiK7JqEtzSAnaC2ol0DN57Gfoai0uL6Yhc/UPETi3dl+X5G zfPqx47umCETtdf1LeVeEXccqnIXcBHACWncIAm4XHqltRl58XzQRIBbZU4780IG9Q30 w/QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=bliawEzEY91TFce8wh2Q+g/QI5fGl1tCrrW6nibAXQo=; b=nzYkgrmRjYu6OqO9W3sMFotCVaZllcCHMu636yVPsuclH/5R1Nbc5yXTbhEXDl4+Lm e37cS8/VAuBK03Tj0VtKbg2dmdQvwNJH83Y0waqGPXUGpP+RoXb570j8zIYzW6RT/+ou /+ezeRSNsdrGfwKuy247ZEoB7Jh9RjtKkJoXvwtfFshCngLSTvH8K5Sjs7n6jtsjL4aT T152ibLLacg5IIxQoSPhC8LDJ/e4r96ZxxmbfP8R/qDYxlUIA1CDkyNgCPuAl0mxe9Yu RB+l+ae/D1jaL40b6MJoaTpNswkSTi0emMXdE+0EJgajBS4qbSCjtrYYqVMIHWGCWiGP euyQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si1809328ejp.314.2021.05.21.03.01.48; Fri, 21 May 2021 03:02:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234693AbhEUHDX (ORCPT + 99 others); Fri, 21 May 2021 03:03:23 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:50761 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230257AbhEUHDX (ORCPT ); Fri, 21 May 2021 03:03:23 -0400 X-UUID: 26a130d21e47499fb308f8c0efedd29b-20210521 X-UUID: 26a130d21e47499fb308f8c0efedd29b-20210521 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1377951267; Fri, 21 May 2021 15:01:56 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 21 May 2021 15:01:54 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 21 May 2021 15:01:53 +0800 From: Irui Wang To: Alexandre Courbot , Hans Verkuil , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Tomasz Figa , Hsin-Yi Wang , Maoguang Meng , Longfei Wang , Yong Wu CC: Yunfei Dong , Fritz Koenig , Tzung-Bi Shih , Irui Wang , , , , , , , Subject: [PATCH v4,1/6] media: mtk-vcodec: venc: remove redundant code Date: Fri, 21 May 2021 15:01:34 +0800 Message-ID: <20210521070139.20644-2-irui.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210521070139.20644-1-irui.wang@mediatek.com> References: <20210521070139.20644-1-irui.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandre Courbot vidioc_try_fmt() does clamp height and width when called on the OUTPUT queue, so clamping them prior to calling this function is redundant. Set the queue's parameters after calling vidioc_try_fmt() so we can use the values it computed. Signed-off-by: Alexandre Courbot --- .../media/platform/mtk-vcodec/mtk_vcodec_enc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index 4831052f475d..42ff13867940 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -443,7 +443,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv, struct mtk_q_data *q_data; int ret, i; const struct mtk_video_fmt *fmt; - struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); if (!vq) { @@ -468,20 +467,13 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv, f->fmt.pix.pixelformat = fmt->fourcc; } - pix_fmt_mp->height = clamp(pix_fmt_mp->height, - MTK_VENC_MIN_H, - MTK_VENC_MAX_H); - pix_fmt_mp->width = clamp(pix_fmt_mp->width, - MTK_VENC_MIN_W, - MTK_VENC_MAX_W); - - q_data->visible_width = f->fmt.pix_mp.width; - q_data->visible_height = f->fmt.pix_mp.height; - q_data->fmt = fmt; - ret = vidioc_try_fmt(f, q_data->fmt); + ret = vidioc_try_fmt(f, fmt); if (ret) return ret; + q_data->fmt = fmt; + q_data->visible_width = f->fmt.pix_mp.width; + q_data->visible_height = f->fmt.pix_mp.height; q_data->coded_width = f->fmt.pix_mp.width; q_data->coded_height = f->fmt.pix_mp.height; -- 2.18.0