From patchwork Tue Jan 5 15:28:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 357179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 499D5C433E0 for ; Tue, 5 Jan 2021 15:34:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2265C22B45 for ; Tue, 5 Jan 2021 15:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728149AbhAEPeG (ORCPT ); Tue, 5 Jan 2021 10:34:06 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:38064 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728142AbhAEPeG (ORCPT ); Tue, 5 Jan 2021 10:34:06 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DB07D9E6; Tue, 5 Jan 2021 16:29:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1609860593; bh=+90f5oOY8Y7wm7MLcjLDdl0bmpMpZHDpcLA2Mo7xWWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g9aOjhhRwnOr9DwXEgD5hIojXNaAlprCEuAg7QpExKs7jg/uzY/Zb5a8nfAswQVW6 vtUfVkh7yTeFmU09yb5t9Zl4pyBe65pPnUYD/mac7sxUZP7snqjXJEmVGBCAQITG+E Vi/kzWk84Bf2h62XwdM5+3InTEUhanPxcEHfe1Pg= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Ezequiel Garcia Subject: [PATCH 27/75] media: imx: capture: Simplify __capture_legacy_try_fmt() Date: Tue, 5 Jan 2021 17:28:04 +0200 Message-Id: <20210105152852.5733-28-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210105152852.5733-1-laurent.pinchart@ideasonboard.com> References: <20210105152852.5733-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The __capture_legacy_try_fmt() function returns two values through pointer arguments. One is a compose rectangle, which duplicates informationr returned through the subdev format argument, and can thus be removed. The other is the imx_media_pixfmt, which can be returned by value instead. Simplify the implementation of __capture_legacy_try_fmt() by dropping the retcc and compose arguments, and returning the imx_media_pixfmt by value. Signed-off-by: Laurent Pinchart Reviewed-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-capture.c | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index 8f3c0da371d3..9a8e1a1400a2 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -251,17 +251,16 @@ static int capture_legacy_enum_fmt_vid_cap(struct file *file, void *fh, return 0; } -static int __capture_legacy_try_fmt(struct capture_priv *priv, - struct v4l2_subdev_format *fmt_src, - struct v4l2_pix_format *pixfmt, - const struct imx_media_pixfmt **retcc, - struct v4l2_rect *compose) +static const struct imx_media_pixfmt * +__capture_legacy_try_fmt(struct capture_priv *priv, + struct v4l2_subdev_format *fmt_src, + struct v4l2_pix_format *pixfmt) { const struct imx_media_pixfmt *cc; cc = capture_find_format(fmt_src->format.code, pixfmt->pixelformat); if (WARN_ON(!cc)) - return -EINVAL; + return NULL; /* allow IDMAC interweave but enforce field order from source */ if (V4L2_FIELD_IS_INTERLACED(pixfmt->field)) { @@ -279,17 +278,7 @@ static int __capture_legacy_try_fmt(struct capture_priv *priv, imx_media_mbus_fmt_to_pix_fmt(pixfmt, &fmt_src->format, cc); - if (retcc) - *retcc = cc; - - if (compose) { - compose->left = 0; - compose->top = 0; - compose->width = fmt_src->format.width; - compose->height = fmt_src->format.height; - } - - return 0; + return cc; } static int capture_legacy_try_fmt_vid_cap(struct file *file, void *fh, @@ -305,8 +294,10 @@ static int capture_legacy_try_fmt_vid_cap(struct file *file, void *fh, if (ret) return ret; - return __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix, NULL, - NULL); + if (!__capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix)) + return -EINVAL; + + return 0; } static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, @@ -314,6 +305,7 @@ static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, { struct capture_priv *priv = video_drvdata(file); struct v4l2_subdev_format fmt_src; + const struct imx_media_pixfmt *cc; int ret; if (vb2_is_busy(&priv->q)) { @@ -327,12 +319,14 @@ static int capture_legacy_s_fmt_vid_cap(struct file *file, void *fh, if (ret) return ret; - ret = __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix, - &priv->vdev.cc, &priv->vdev.compose); - if (ret) - return ret; + cc = __capture_legacy_try_fmt(priv, &fmt_src, &f->fmt.pix); + if (!cc) + return -EINVAL; + priv->vdev.cc = cc; priv->vdev.fmt = f->fmt.pix; + priv->vdev.compose.width = fmt_src.format.width; + priv->vdev.compose.height = fmt_src.format.height; return 0; }