From patchwork Fri Jun 26 08:04:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 11627143 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33ABD913 for ; Fri, 26 Jun 2020 10:47:39 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08DB9206B7 for ; Fri, 26 Jun 2020 10:47:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SnzXqtdi"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="RZSRuHcg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08DB9206B7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BrTpoVfN/Ik7V8r09D4VcUoCSvXpspVW4Is0qRw6rZE=; b=SnzXqtdiFdT/RhVX3+WzhQovE Q29BPXkYMHv7/wtdMh/GICxvYeE8431dUwVCUyEaYdYnfvrvf8uw72yL54BinSwTZnIhcc83FQnBn Ps20fqLh7E7xYENTjMGmtrOYkOqs5MZjK3qs69R/L39Pkyp+nsHQVi/WlB34twTpw+f6LW45fsGfD awKFQOQeVzXQyEGW58ta8KZhz5mZ/NdXk5ZiI7DbdOlsxNA/ustpdr9p0EBIs7y/+tdRqwAzEYRZl 5ICW+qCDt0RlLGd+/vn/SHAevbATS32ebWJ88yXlYja5ZVFLHkgg0GWUZutt86VHBsx4pc0HNOXvV m7i1nDEsw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1joltR-0004dA-TI; Fri, 26 Jun 2020 10:47:37 +0000 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1joltI-0004Zj-BP for linux-mediatek@lists.infradead.org; Fri, 26 Jun 2020 10:47:36 +0000 Received: by mail-pj1-x1044.google.com with SMTP id k71so1344881pje.0 for ; Fri, 26 Jun 2020 03:47:27 -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=NbohQFHY7x95L6QCxTobEstXc6fGTf3rPXBo2gDeR+4=; b=RZSRuHcg+fqMQQA3O2GKclz3AMt+0iakFG324G+yuOcaJSx1C2zvSZd7p3mh+isy0W fMrml0vILtGCti3TW2EGJrSE+2sMayf1xKMNfjGU2C7HO843sEKamFIG9eJ+bvLtiw/O U9A4K3YIbFGUboPjcnjlqNVcXfWMuih/PpKJM= 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=NbohQFHY7x95L6QCxTobEstXc6fGTf3rPXBo2gDeR+4=; b=gkZsF3JGgSVl2VLsbV/fF+MgL1rfCba2Tr87UcRC2BJa1Pnj7Ce5F+eqaOeUiaVqjH ERsAGuc/YYLLvv4bmI/PURRkz5LFTnQxw3u2CxD8tA0PkyJCsXTeum5ezbQfQt+10ZH0 WjCmjppaKTXhtcH96lV2PYG9VeMqafiqKJtSoWFzjkhSYyZJ0TGErErOkJZ2J8UWoYRe +ifZmDLO8vVsF1bK7usxluDJfRkmpRR/S7K07wxvtjx8g06mQ1xh2m+3DmznRpyh5ELB jL7kQSq5LCXYjsFK+HF+ssw0jgJxr9sIG7ENV9/hBlKiDXNWuW4q5D22SJKgi7ZEm9av SOfg== X-Gm-Message-State: AOAM530Rsho4q++NU2s4SXFna/jGg5j+dW4+irx1OH4gIhrGIK8gg81E F04sEgcOuxDNGZHcBaapusGuvOCt/VLPQw== X-Google-Smtp-Source: ABdhPJyo/eKnP9Mj39RkYn10v03lQbOGvoSfYy+bk02mQFN2DxVBCFGSYeL/vgwY7Jx0BX/7YKIjuw== X-Received: by 2002:a17:902:aa97:: with SMTP id d23mr1663416plr.128.1593158774621; Fri, 26 Jun 2020 01:06:14 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:8f:203:93d9:de4d:e834:3086]) by smtp.gmail.com with ESMTPSA id 137sm21809843pgg.72.2020.06.26.01.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 01:06:13 -0700 (PDT) From: Alexandre Courbot To: Tiffany Lin , Andrew-CT Chen , Rui Wang , Yunfei Dong , Pi-Hsun Shih , Maoguang Meng Subject: [PATCH v2 14/18] media: mtk-vcodec: venc: support ENUM_FRAMESIZES on OUTPUT formats Date: Fri, 26 Jun 2020 17:04:38 +0900 Message-Id: <20200626080442.292309-15-acourbot@chromium.org> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog In-Reply-To: <20200626080442.292309-1-acourbot@chromium.org> References: <20200626080442.292309-1-acourbot@chromium.org> MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1044 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Courbot , linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org v4l2-compliance requires ENUM_FRAMESIZES to support OUTPUT formats. Reuse mtk_venc_find_format() to make sure both queues are considered when serving an ENUM_FRAMESIZES. Signed-off-by: Alexandre Courbot --- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 72 +++++++++---------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index f8d4fbe927f9..6cef61cb7883 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -123,28 +123,45 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, return 0; } +static const struct mtk_video_fmt *mtk_venc_find_format(u32 fourcc, + const struct mtk_vcodec_enc_pdata *pdata) +{ + const struct mtk_video_fmt *fmt; + unsigned int k; + + for (k = 0; k < pdata->num_capture_formats; k++) { + fmt = &pdata->capture_formats[k]; + if (fmt->fourcc == fourcc) + return fmt; + } + + for (k = 0; k < pdata->num_output_formats; k++) { + fmt = &pdata->output_formats[k]; + if (fmt->fourcc == fourcc) + return fmt; + } + + return NULL; +} + + static int vidioc_enum_framesizes(struct file *file, void *fh, struct v4l2_frmsizeenum *fsize) { - const struct mtk_vcodec_enc_pdata *pdata = - fh_to_ctx(fh)->dev->venc_pdata; - int i = 0; + const struct mtk_video_fmt *fmt; if (fsize->index != 0) return -EINVAL; - for (i = 0; i < pdata->num_capture_formats; ++i) { - const struct mtk_video_fmt *fmt = &pdata->capture_formats[i]; - - if (fsize->pixel_format != fmt->fourcc) - continue; + fmt = mtk_venc_find_format(fsize->pixel_format, + fh_to_ctx(fh)->dev->venc_pdata); + if (!fmt) + return -EINVAL; - fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; - fsize->stepwise = mtk_venc_framesizes; - return 0; - } + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + fsize->stepwise = mtk_venc_framesizes; - return -EINVAL; + return 0; } static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, @@ -222,27 +239,6 @@ static struct mtk_q_data *mtk_venc_get_q_data(struct mtk_vcodec_ctx *ctx, return &ctx->q_data[MTK_Q_DATA_DST]; } -static const struct mtk_video_fmt *mtk_venc_find_format(struct v4l2_format *f, - const struct mtk_vcodec_enc_pdata *pdata) -{ - const struct mtk_video_fmt *fmt; - unsigned int k; - - for (k = 0; k < pdata->num_capture_formats; k++) { - fmt = &pdata->capture_formats[k]; - if (fmt->fourcc == f->fmt.pix.pixelformat) - return fmt; - } - - for (k = 0; k < pdata->num_output_formats; k++) { - fmt = &pdata->output_formats[k]; - if (fmt->fourcc == f->fmt.pix.pixelformat) - return fmt; - } - - return NULL; -} - /* V4L2 specification suggests the driver corrects the format struct if any of * the dimensions is unsupported */ @@ -403,7 +399,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv, return -EINVAL; } - fmt = mtk_venc_find_format(f, pdata); + fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata); if (!fmt) { fmt = &ctx->dev->venc_pdata->capture_formats[0]; f->fmt.pix.pixelformat = fmt->fourcc; @@ -467,7 +463,7 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv, return -EINVAL; } - fmt = mtk_venc_find_format(f, pdata); + fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata); if (!fmt) { fmt = &ctx->dev->venc_pdata->output_formats[0]; f->fmt.pix.pixelformat = fmt->fourcc; @@ -550,7 +546,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv, struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv); const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata; - fmt = mtk_venc_find_format(f, pdata); + fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata); if (!fmt) { fmt = &ctx->dev->venc_pdata->capture_formats[0]; f->fmt.pix.pixelformat = fmt->fourcc; @@ -570,7 +566,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv); const struct mtk_vcodec_enc_pdata *pdata = ctx->dev->venc_pdata; - fmt = mtk_venc_find_format(f, pdata); + fmt = mtk_venc_find_format(f->fmt.pix.pixelformat, pdata); if (!fmt) { fmt = &ctx->dev->venc_pdata->output_formats[0]; f->fmt.pix.pixelformat = fmt->fourcc;