From patchwork Tue May 10 11:51:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15881 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 5BC15C3279 for ; Tue, 10 May 2022 11:52:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C5C706569B; Tue, 10 May 2022 13:52:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183561; bh=acBHI4Cc+IejSUvtpcxUVa16XO7kLHAsl0OGhtOqMnE=; 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=O2QKBtfBK7hXcb1JtRLALUK9uMbEFjtLvew/o8EiffyF2ceLLIeefn6Uszxj+VIEc TAhDzl4aS1TxPzjfNhJglZUqcDaJwUfd7Wl8OMn/tdIXQopp78Stl9hlyqUIE59wUg GcJ8BBYO+f6sLhRCUiwqruQautjmMzy/+FEOwS6kivwURiRlQxDckzFQK93+rBFxQq 2GitsfWAzpbJl9oaSL7p52ZwWC1KXE6GNDcy2hWxWKP4kX5BRU8NhTHXiWL7xlhPDQ lu5OEOxm8fai93VN2/JzMnh/40XDNwflEisj5NGk3oVnI803uMzj7iuCb0SJ57n+yG eMinqVkibiwRQ== 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 1D3316569A for ; Tue, 10 May 2022 13:52:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TnIBQLrW"; 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 3544A1248; Tue, 10 May 2022 13:52:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183551; bh=acBHI4Cc+IejSUvtpcxUVa16XO7kLHAsl0OGhtOqMnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TnIBQLrWlhlauYKtGH75HeTdLv8YpjdM2qUGgbfZ2lz04PioadeuDEU7qbjUuh69x bs7bP+ahHTypdVRHXhmZf5rWMGwt+vI8o0Oxf/0dTrQanMha78ECzsTuRZ61RMnfty F0T2bhABoxY1J/kiRNe0u/CJt7Q5rl2aGgPkC9/Y= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:38 +0300 Message-Id: <20220510115147.19360-42-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 41/50] staging: media: imx: imx7-media-csi: Drop YUV/RGB/BAYER format selectors 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" All the format lookup functions are called with a ANY selector, drop selector support. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 105 +++++---------------- 1 file changed, 22 insertions(+), 83 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index f3b9ce03318f..ab101d82c253 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -809,17 +809,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) #define IMX_BUS_FMTS(fmt...) (const u32[]) {fmt, 0} -enum imx7_csi_pixfmt_sel { - IMX7_CSI_PIXFMT_SEL_YUV = BIT(0), /* select YUV formats */ - IMX7_CSI_PIXFMT_SEL_RGB = BIT(1), /* select RGB formats */ - IMX7_CSI_PIXFMT_SEL_BAYER = BIT(2), /* select BAYER formats */ - IMX7_CSI_PIXFMT_SEL_YUV_RGB = IMX7_CSI_PIXFMT_SEL_YUV - | IMX7_CSI_PIXFMT_SEL_RGB, - IMX7_CSI_PIXFMT_SEL_ANY = IMX7_CSI_PIXFMT_SEL_YUV - | IMX7_CSI_PIXFMT_SEL_RGB - | IMX7_CSI_PIXFMT_SEL_BAYER, -}; - /* * List of supported pixel formats for the subdevs. */ @@ -927,25 +916,16 @@ static const struct imx7_csi_pixfmt pixel_formats[] = { /* * Search in the pixel_formats[] array for an entry with the given fourcc - * that matches the requested selection criteria and return it. - * - * @fourcc: Search for an entry with the given fourcc pixel format. - * @fmt_sel: Allow entries only with the given selection criteria. + * return it. */ -static const struct imx7_csi_pixfmt * -imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) +static const struct imx7_csi_pixfmt *imx7_csi_find_pixel_format(u32 fourcc) { unsigned int i; for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - enum imx7_csi_pixfmt_sel sel; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if ((fmt_sel & sel) && fmt->fourcc == fourcc) + if (fmt->fourcc == fourcc) return fmt; } @@ -954,26 +934,17 @@ imx7_csi_find_pixel_format(u32 fourcc, enum imx7_csi_pixfmt_sel fmt_sel) /* * Search in the pixel_formats[] array for an entry with the given media - * bus code that matches the requested selection criteria and return it. - * - * @code: Search for an entry with the given media-bus code. - * @fmt_sel: Allow entries only with the given selection criteria. + * bus code and return it. */ -static const struct imx7_csi_pixfmt * -imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) +static const struct imx7_csi_pixfmt *imx7_csi_find_mbus_format(u32 code) { unsigned int i; for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - enum imx7_csi_pixfmt_sel sel; unsigned int j; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if (!(fmt_sel & sel) || !fmt->codes) + if (!fmt->codes) continue; for (j = 0; fmt->codes[j]; j++) { @@ -993,27 +964,15 @@ imx7_csi_find_mbus_format(u32 code, enum imx7_csi_pixfmt_sel fmt_sel) * @fourcc: The returned fourcc that matches the search criteria at * the requested match index. * @index: The requested match index. - * @fmt_sel: Include in the enumeration entries with the given selection - * criteria. * @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, - enum imx7_csi_pixfmt_sel fmt_sel, - u32 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]; - enum imx7_csi_pixfmt_sel sel; - - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if (!(fmt_sel & sel)) - continue; /* * If a media bus code is specified, only consider formats that @@ -1053,24 +1012,16 @@ static int imx7_csi_enum_pixel_formats(u32 *fourcc, u32 index, * @code: The returned media-bus code that matches the search criteria at * the requested match index. * @index: The requested match index. - * @fmt_sel: Include in the enumeration entries with the given selection - * criteria. */ -static int imx7_csi_enum_mbus_formats(u32 *code, u32 index, - enum imx7_csi_pixfmt_sel fmt_sel) +static int imx7_csi_enum_mbus_formats(u32 *code, u32 index) { unsigned int i; for (i = 0; i < ARRAY_SIZE(pixel_formats); i++) { const struct imx7_csi_pixfmt *fmt = &pixel_formats[i]; - enum imx7_csi_pixfmt_sel sel; unsigned int j; - sel = fmt->bayer ? IMX7_CSI_PIXFMT_SEL_BAYER - : (fmt->yuv ? IMX7_CSI_PIXFMT_SEL_YUV : - IMX7_CSI_PIXFMT_SEL_RGB); - - if (!(fmt_sel & sel) || !fmt->codes) + if (!fmt->codes) continue; for (j = 0; fmt->codes[j]; j++) { @@ -1099,7 +1050,7 @@ static int imx7_csi_init_mbus_fmt(struct v4l2_mbus_framefmt *mbus, if (code == 0) code = IMX7_CSI_DEF_MBUS_CODE; - lcc = imx7_csi_find_mbus_format(code, IMX7_CSI_PIXFMT_SEL_ANY); + lcc = imx7_csi_find_mbus_format(code); if (!lcc) return -EINVAL; @@ -1127,8 +1078,7 @@ static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix, u32 stride; if (!cc) { - cc = imx7_csi_find_mbus_format(mbus->code, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_mbus_format(mbus->code); if (!cc) return -EINVAL; } @@ -1178,7 +1128,6 @@ 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, - IMX7_CSI_PIXFMT_SEL_ANY, f->mbus_code); } @@ -1190,8 +1139,7 @@ static int imx7_csi_video_enum_framesizes(struct file *file, void *fh, if (fsize->index > 0) return -EINVAL; - cc = imx7_csi_find_pixel_format(fsize->pixel_format, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_pixel_format(fsize->pixel_format); if (!cc) return -EINVAL; @@ -1232,13 +1180,10 @@ __imx7_csi_video_try_fmt(struct v4l2_pix_format *pixfmt, * Find the pixel format, default to the first supported format if not * found. */ - cc = imx7_csi_find_pixel_format(pixfmt->pixelformat, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); if (!cc) { - imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, - IMX7_CSI_PIXFMT_SEL_ANY, 0); - cc = imx7_csi_find_pixel_format(pixfmt->pixelformat, - IMX7_CSI_PIXFMT_SEL_ANY); + imx7_csi_enum_pixel_formats(&pixfmt->pixelformat, 0, 0); + cc = imx7_csi_find_pixel_format(pixfmt->pixelformat); } /* Allow IDMAC interweave but enforce field order from source. */ @@ -1463,8 +1408,7 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) * Verify that the media bus code is compatible with the pixel format * set on the video node. */ - cc = imx7_csi_find_mbus_format(fmt_src.format.code, - IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_mbus_format(fmt_src.format.code); if (!cc || csi->vdev_cc->yuv != cc->yuv) return -EPIPE; @@ -1638,8 +1582,7 @@ static int imx7_csi_video_init_format(struct imx7_csi *csi) csi->vdev_compose.width = fmt_src.format.width; csi->vdev_compose.height = fmt_src.format.height; - csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat, - IMX7_CSI_PIXFMT_SEL_ANY); + csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat); return 0; } @@ -1846,8 +1789,7 @@ static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd, switch (code->pad) { case IMX7_CSI_PAD_SINK: - ret = imx7_csi_enum_mbus_formats(&code->code, code->index, - IMX7_CSI_PIXFMT_SEL_ANY); + ret = imx7_csi_enum_mbus_formats(&code->code, code->index); break; case IMX7_CSI_PAD_SRC: if (code->index != 0) { @@ -1904,7 +1846,7 @@ static void imx7_csi_try_colorimetry(struct v4l2_mbus_framefmt *tryfmt) const struct imx7_csi_pixfmt *cc; bool is_rgb = false; - cc = imx7_csi_find_mbus_format(tryfmt->code, IMX7_CSI_PIXFMT_SEL_ANY); + cc = imx7_csi_find_mbus_format(tryfmt->code); if (cc && !cc->yuv) is_rgb = true; @@ -1954,8 +1896,7 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, switch (sdformat->pad) { case IMX7_CSI_PAD_SRC: - in_cc = imx7_csi_find_mbus_format(in_fmt->code, - IMX7_CSI_PIXFMT_SEL_ANY); + in_cc = imx7_csi_find_mbus_format(in_fmt->code); sdformat->format.width = in_fmt->width; sdformat->format.height = in_fmt->height; @@ -1969,12 +1910,10 @@ static int imx7_csi_try_fmt(struct imx7_csi *csi, sdformat->format.ycbcr_enc = in_fmt->ycbcr_enc; break; case IMX7_CSI_PAD_SINK: - *cc = imx7_csi_find_mbus_format(sdformat->format.code, - IMX7_CSI_PIXFMT_SEL_ANY); + *cc = imx7_csi_find_mbus_format(sdformat->format.code); if (!*cc) { code = IMX7_CSI_DEF_MBUS_CODE; - *cc = imx7_csi_find_mbus_format(code, - IMX7_CSI_PIXFMT_SEL_ANY); + *cc = imx7_csi_find_mbus_format(code); sdformat->format.code = code; }