From patchwork Tue May 10 11:51:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15888 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 380D9C327E for ; Tue, 10 May 2022 11:52:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2515656AB; Tue, 10 May 2022 13:52:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183566; bh=7n8of1MXRoPvO3JeUjedG56zxX0gutOm/D21RqQZXt4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=bKU2n3qfhSOZ5p1vnh9Bld1krjmDufCvKgEOkAMgBft+aWndMbwGCRks4dc+a9S16 mTms+aDrIjsI/IvAdV2EyLR6AbOi54NRCauIkKUJ1VM2A1EsUyvwGToG/d4RTtdNC1 SzN8eVELcIceUvFgu8u287MZkcCmTWBAWDnCfFSRauoa97DDVeFiP0tRYROFCQ1iBk CYGd8jxxji1sLmBnGnRZcCciwEo1hZKyeDU0d0GV65tw3TysgJksJEo808fM5e5SE4 OTLyQs8RyhlbqG6jJ4bbrPhKE6OoMVdXurOmoQetS0q6XI5i/MX1NVlD0yCl9mvVTe hEuac61z1d60g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D5DA656B4 for ; Tue, 10 May 2022 13:52:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="at/UC7Gv"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 22FBAB9A; Tue, 10 May 2022 13:52:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183557; bh=7n8of1MXRoPvO3JeUjedG56zxX0gutOm/D21RqQZXt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=at/UC7Gvq23CNRSgW5N5LvJFd7FiDBATlYtU5Vj5GRlCggDZSQ+OTlRVaF+0MpK1y LY1HRF27lbidJW0UrlzpTD3J1tBYweQkNVakfw68JtsT2x+MQucXF6A/giYRiklFO6 kKvAH3oSve/2rEtm+P4u7lIvJNgyhuj5JSPCPtbA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:45 +0300 Message-Id: <20220510115147.19360-49-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 48/50] staging: media: imx: imx7-media-csi: Inline imx7_csi_enum_pixel_formats() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Inline the imx7_csi_enum_pixel_formats() function in its only caller. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 84 +++++++++------------- 1 file changed, 34 insertions(+), 50 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 8be6f40588af..0bf69933f1bd 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -954,54 +954,6 @@ static const struct imx7_csi_pixfmt *imx7_csi_find_mbus_format(u32 code) return NULL; } -/* - * Enumerate entries in the pixel_formats[] array that match the - * requested selection criteria. Return the fourcc that matches the - * selection criteria at the requested match index. - * - * @fourcc: The returned fourcc that matches the search criteria at - * the requested match index. - * @index: The requested match index. - * @code: If non-zero, only include in the enumeration entries matching this - * media bus code. - */ -static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, u32 code) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { - const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - - /* - * If a media bus code is specified, only consider formats that - * match it. - */ - if (code) { - unsigned int j; - - if (!fmt->codes) - continue; - - for (j = 0; fmt->codes[j]; j++) { - if (code == fmt->codes[j]) - break; - } - - if (!fmt->codes[j]) - continue; - } - - if (index == 0) { - *fourcc = fmt->fourcc; - return 0; - } - - index--; - } - - return -EINVAL; -} - /* * Enumerate entries in the pixel_formats[] array that match the * requested search criteria. Return the media-bus code that matches @@ -1088,8 +1040,40 @@ static int imx7_csi_video_querycap(struct file *file, void *fh, static int imx7_csi_video_enum_fmt_vid_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { - return imx7_csi_enum_pixel_formats(&f->pixelformat, f->index, - f->mbus_code); + unsigned int index = f->index; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { + const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; + + /* + * If a media bus code is specified, only consider formats that + * match it. + */ + if (f->mbus_code) { + unsigned int j; + + if (!fmt->codes) + continue; + + for (j = 0; fmt->codes[j]; j++) { + if (f->mbus_code == fmt->codes[j]) + break; + } + + if (!fmt->codes[j]) + continue; + } + + if (index == 0) { + f->pixelformat = fmt->fourcc; + return 0; + } + + index--; + } + + return -EINVAL; } static int imx7_csi_video_enum_framesizes(struct file *file, void *fh,