From patchwork Fri Jan 6 19:40:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Pigg X-Patchwork-Id: 13091734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4165C3DA7A for ; Fri, 6 Jan 2023 19:40:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231690AbjAFTku (ORCPT ); Fri, 6 Jan 2023 14:40:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbjAFTkt (ORCPT ); Fri, 6 Jan 2023 14:40:49 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4E1471897 for ; Fri, 6 Jan 2023 11:40:46 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id bn26so2251246wrb.0 for ; Fri, 06 Jan 2023 11:40:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=TlIQMwTCvjZ8+X4/qPPH7+cIVsXNFRlJGbKFunxAzLw=; b=o/g4z2lntL7zEG9PJVE3gYds3qoD6yHVCpTzgJSJH9K938KB3yl6hrj0+SxYuTzBP0 FuNGjEvOBsa3MglxR8nA6pxUM9BUWiSnfmvU9v1lakObsr+nXBVM/8ScOVA+jmkTvU+L BdSgjqeqZYSZDxSZ/5tjXK5jKzj5rAOphrBGQ71UZWFb10+vhMlCKtY60oX6QRbSjgER zxvNGTltPbPVskMrXBipP0itVYCICHerrZz+4kIl1DFOm5gBfg2hznJ0aSp6OMA8OSYn 9lR6h5Q5GD1ViWOVOB0UUYwOIz4qmla4lhR0OwlD9GaubLWjnju5L+x5u5/FCqTwz9gx cKKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TlIQMwTCvjZ8+X4/qPPH7+cIVsXNFRlJGbKFunxAzLw=; b=777hzjYLMEeTlkUEAuH1e/wQXhHRJUzbX2FdZw3nRE4+ZtMeeN27AcHuvhhp6376dA QE+c77g+432qXzTSAxF8KDBbKkybU6yaf+uUgW0GgVpxl0pyLzYFbQ4dT6yE8eiBjrPh r1IBMYdnkpWj3uUrM2W7zrFiLh1wV0iB/4HTWiJVumEtNvHowY64cg0ZE3dyCjXU5rNy MPaQVyqji8rd8sVp3uVY6r00oE9PRYfZ9h9lH0//d1+6aRL7h5oJyHlBsw41IGQTPYW3 q/Ph3afKVvIxvnQ6xZ7pbEJwBr0WO0zFahWcunWU9Dj8L56avr4qSQVONM6sy1zKwMyY QCRg== X-Gm-Message-State: AFqh2krqt3Uf9HwvI9YilUSZDiK60pQvIudvDhVl4a3p7KisOwidjtl1 LK9CczWdF1JvSTUiPUP1cUmAaG7zK/syTg== X-Google-Smtp-Source: AMrXdXt189ewVc2u/45hJm1MqIAPuynGmhZoe0fum4ytnWzbBFYsNcU1+ly4SPZltOihz0jVO+LQTQ== X-Received: by 2002:adf:f606:0:b0:28c:1ae0:e67f with SMTP id t6-20020adff606000000b0028c1ae0e67fmr18051554wrp.55.1673034045282; Fri, 06 Jan 2023 11:40:45 -0800 (PST) Received: from localhost.localdomain ([90.242.19.250]) by smtp.gmail.com with ESMTPSA id bx9-20020a5d5b09000000b0023662245d3csm1968650wrb.95.2023.01.06.11.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 11:40:44 -0800 (PST) Sender: Adam Pigg From: adam@piggz.co.uk To: linux-media@vger.kernel.org Cc: yong.deng@magewell.com, mchehab@kernel.org, linux-sunxi@lists.linux.dev, paul.kocialkowski@bootlin.com, laurent.pinchart@ideasonboard.com, Adam Pigg Subject: [PATCH 1/3] media: sun6i-csi: merge sun6i_csi_formats and sun6i_csi_formats_match Date: Fri, 6 Jan 2023 19:40:36 +0000 Message-Id: <20230106194038.16018-2-adam@piggz.co.uk> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106194038.16018-1-adam@piggz.co.uk> References: <20230106194038.16018-1-adam@piggz.co.uk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Adam Pigg Merged the two format arrays into sun6i_csi_capture_formats as a pre-requisite to implementing V4L2_CAP_IO_MC Signed-off-by: Adam Pigg --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 155 +++++------------- .../sunxi/sun6i-csi/sun6i_csi_capture.h | 6 +- 2 files changed, 46 insertions(+), 115 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 03d4adec054c..69578075421c 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -22,6 +22,8 @@ /* Helpers */ +#define SUN6I_BUS_FMTS(fmt...) (const u32[]) {fmt, 0} + void sun6i_csi_capture_dimensions(struct sun6i_csi_device *csi_dev, unsigned int *width, unsigned int *height) { @@ -49,72 +51,86 @@ static const struct sun6i_csi_capture_format sun6i_csi_capture_formats[] = { .pixelformat = V4L2_PIX_FMT_SBGGR8, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_8, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SBGGR8_1X8), }, { .pixelformat = V4L2_PIX_FMT_SGBRG8, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_8, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SGBRG8_1X8), }, { .pixelformat = V4L2_PIX_FMT_SGRBG8, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_8, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SGRBG8_1X8), }, { .pixelformat = V4L2_PIX_FMT_SRGGB8, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_8, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SRGGB8_1X8), }, { .pixelformat = V4L2_PIX_FMT_SBGGR10, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_10, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_10, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SBGGR10_1X10), }, { .pixelformat = V4L2_PIX_FMT_SGBRG10, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_10, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_10, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SGBRG10_1X10), }, { .pixelformat = V4L2_PIX_FMT_SGRBG10, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_10, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_10, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SGRBG10_1X10), }, { .pixelformat = V4L2_PIX_FMT_SRGGB10, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_10, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_10, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SRGGB10_1X10), }, { .pixelformat = V4L2_PIX_FMT_SBGGR12, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_12, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_12, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SBGGR12_1X12), }, { .pixelformat = V4L2_PIX_FMT_SGBRG12, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_12, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_12, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SGBRG12_1X12), }, { .pixelformat = V4L2_PIX_FMT_SGRBG12, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_12, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_12, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SGRBG12_1X12), }, { .pixelformat = V4L2_PIX_FMT_SRGGB12, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_12, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_12, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_SRGGB12_1X12), }, /* RGB */ { .pixelformat = V4L2_PIX_FMT_RGB565, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RGB565, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RGB565, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_RGB565_2X8_LE), }, { .pixelformat = V4L2_PIX_FMT_RGB565X, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RGB565, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RGB565, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_RGB565_2X8_BE), }, /* YUV422 */ { @@ -123,6 +139,8 @@ static const struct sun6i_csi_capture_format sun6i_csi_capture_formats[] = { .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, .input_format_raw = true, .hsize_len_factor = 2, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_YUYV8_2X8, + MEDIA_BUS_FMT_YUYV8_1X16), }, { .pixelformat = V4L2_PIX_FMT_YVYU, @@ -130,6 +148,8 @@ static const struct sun6i_csi_capture_format sun6i_csi_capture_formats[] = { .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, .input_format_raw = true, .hsize_len_factor = 2, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_YVYU8_2X8, + MEDIA_BUS_FMT_YVYU8_1X16), }, { .pixelformat = V4L2_PIX_FMT_UYVY, @@ -137,6 +157,8 @@ static const struct sun6i_csi_capture_format sun6i_csi_capture_formats[] = { .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, .input_format_raw = true, .hsize_len_factor = 2, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_UYVY8_2X8, + MEDIA_BUS_FMT_UYVY8_1X16), }, { .pixelformat = V4L2_PIX_FMT_VYUY, @@ -144,57 +166,68 @@ static const struct sun6i_csi_capture_format sun6i_csi_capture_formats[] = { .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, .input_format_raw = true, .hsize_len_factor = 2, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_VYUY8_2X8, + MEDIA_BUS_FMT_VYUY8_1X16), }, { .pixelformat = V4L2_PIX_FMT_NV16, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV422SP, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV422SP, + .mbus_codes = 0, }, { .pixelformat = V4L2_PIX_FMT_NV61, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV422SP, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV422SP, .input_yuv_seq_invert = true, + .mbus_codes = 0, }, { .pixelformat = V4L2_PIX_FMT_YUV422P, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV422P, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV422P, + .mbus_codes = 0, }, /* YUV420 */ { .pixelformat = V4L2_PIX_FMT_NV12_16L16, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV420MB, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV420MB, + .mbus_codes = 0, }, { .pixelformat = V4L2_PIX_FMT_NV12, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV420SP, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV420SP, + .mbus_codes = 0, }, { .pixelformat = V4L2_PIX_FMT_NV21, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV420SP, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV420SP, .input_yuv_seq_invert = true, + .mbus_codes = 0, }, { .pixelformat = V4L2_PIX_FMT_YUV420, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV420P, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV420P, + .mbus_codes = 0, }, { .pixelformat = V4L2_PIX_FMT_YVU420, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_YUV420P, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_YUV420P, .input_yuv_seq_invert = true, + .mbus_codes = 0, }, /* Compressed */ { .pixelformat = V4L2_PIX_FMT_JPEG, .output_format_frame = SUN6I_CSI_OUTPUT_FMT_FRAME_RAW_8, .output_format_field = SUN6I_CSI_OUTPUT_FMT_FIELD_RAW_8, + .mbus_codes = SUN6I_BUS_FMTS(MEDIA_BUS_FMT_JPEG_1X8), }, }; @@ -210,118 +243,20 @@ struct sun6i_csi_capture_format *sun6i_csi_capture_format_find(u32 pixelformat) return NULL; } -/* RAW formats need an exact match between pixel and mbus formats. */ -static const -struct sun6i_csi_capture_format_match sun6i_csi_capture_format_matches[] = { - /* YUV420 */ - { - .pixelformat = V4L2_PIX_FMT_YUYV, - .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, - }, - { - .pixelformat = V4L2_PIX_FMT_YUYV, - .mbus_code = MEDIA_BUS_FMT_YUYV8_1X16, - }, - { - .pixelformat = V4L2_PIX_FMT_YVYU, - .mbus_code = MEDIA_BUS_FMT_YVYU8_2X8, - }, - { - .pixelformat = V4L2_PIX_FMT_YVYU, - .mbus_code = MEDIA_BUS_FMT_YVYU8_1X16, - }, - { - .pixelformat = V4L2_PIX_FMT_UYVY, - .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, - }, - { - .pixelformat = V4L2_PIX_FMT_UYVY, - .mbus_code = MEDIA_BUS_FMT_UYVY8_1X16, - }, - { - .pixelformat = V4L2_PIX_FMT_VYUY, - .mbus_code = MEDIA_BUS_FMT_VYUY8_2X8, - }, - { - .pixelformat = V4L2_PIX_FMT_VYUY, - .mbus_code = MEDIA_BUS_FMT_VYUY8_1X16, - }, - /* RGB */ - { - .pixelformat = V4L2_PIX_FMT_RGB565, - .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE, - }, - { - .pixelformat = V4L2_PIX_FMT_RGB565X, - .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_BE, - }, - /* Bayer */ - { - .pixelformat = V4L2_PIX_FMT_SBGGR8, - .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, - }, - { - .pixelformat = V4L2_PIX_FMT_SGBRG8, - .mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8, - }, - { - .pixelformat = V4L2_PIX_FMT_SGRBG8, - .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8, - }, - { - .pixelformat = V4L2_PIX_FMT_SRGGB8, - .mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8, - }, - { - .pixelformat = V4L2_PIX_FMT_SBGGR10, - .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, - }, - { - .pixelformat = V4L2_PIX_FMT_SGBRG10, - .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10, - }, - { - .pixelformat = V4L2_PIX_FMT_SGRBG10, - .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, - }, - { - .pixelformat = V4L2_PIX_FMT_SRGGB10, - .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10, - }, - { - .pixelformat = V4L2_PIX_FMT_SBGGR12, - .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12, - }, - { - .pixelformat = V4L2_PIX_FMT_SGBRG12, - .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12, - }, - { - .pixelformat = V4L2_PIX_FMT_SGRBG12, - .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, - }, - { - .pixelformat = V4L2_PIX_FMT_SRGGB12, - .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12, - }, - /* Compressed */ - { - .pixelformat = V4L2_PIX_FMT_JPEG, - .mbus_code = MEDIA_BUS_FMT_JPEG_1X8, - }, -}; - static bool sun6i_csi_capture_format_match(u32 pixelformat, u32 mbus_code) { - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_format_matches); i++) { - const struct sun6i_csi_capture_format_match *match = - &sun6i_csi_capture_format_matches[i]; - - if (match->pixelformat == pixelformat && - match->mbus_code == mbus_code) - return true; + unsigned int i, j; + + for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_formats); i++) { + const struct sun6i_csi_capture_format *format = + &sun6i_csi_capture_formats[i]; + + if (format->pixelformat == pixelformat) { + for (j = 0; format->mbus_codes[j]; j++) { + if (mbus_code == format->mbus_codes[j]) + return true; + } + } } return false; diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h index 3ee5ccefbd10..0484942834e3 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.h @@ -27,11 +27,7 @@ struct sun6i_csi_capture_format { bool input_yuv_seq_invert; bool input_format_raw; u32 hsize_len_factor; -}; - -struct sun6i_csi_capture_format_match { - u32 pixelformat; - u32 mbus_code; + const u32 *mbus_codes; }; #undef current From patchwork Fri Jan 6 19:40:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Pigg X-Patchwork-Id: 13091735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABFB8C61DB3 for ; Fri, 6 Jan 2023 19:40:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbjAFTkv (ORCPT ); Fri, 6 Jan 2023 14:40:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231459AbjAFTku (ORCPT ); Fri, 6 Jan 2023 14:40:50 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC0086245 for ; Fri, 6 Jan 2023 11:40:48 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id d17so2235906wrs.2 for ; Fri, 06 Jan 2023 11:40:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=AsW+m3ul5OQdcVnmzwNhWTuRKTcC+JZAol0W+lGLwXk=; b=q00azvJz0ZDXV7IZ3WIisHnygM9r4eoV9ffFzYogNUeqW6COjpVbmUXQD1HcER46Wv A6JOlNhmLiSu9wQZLHwVMMauoPwy0KDHaCkxhLU9RCW4gNvgxcWdWeTW7Y2quA8tbUam d9wkydX2qZxezAxzKqHF+fUzu2AKHPIp3hornqmB79WHW1xs5IZ1uO6oUq+SurKUiEc2 hxiyNf+dLKy9EoLa3tg/B2tHzA5NUB/qgXwNFz3OhOVrDzutxeU1F5oAd9dnilBgKtlu MNT6xlpWgI+6BK5djZ/+UvHFZDaE+Ts9kvIrIlB5lZrH1XBw2OHQsegJWpYqyC/k2+ng E0+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=AsW+m3ul5OQdcVnmzwNhWTuRKTcC+JZAol0W+lGLwXk=; b=1JqGnVnHZFxqE1v1DJusSmVd60lCRpWy43XWU4IltuCZDMRndxf04BswgXZCg7etAu N+e0saZbfpD1QhZXqHn5rhwdZ1M+B/nxv6J/IsL0jv3MTWRERZUaz+5ao0wOiiiTvX+m BEY3euUAn2FvX+GM0Apu5b68IAB8yVQIQdHENgHpLHPwUHtuKu3rnfjNRVHqZukRJw4B CpFTbEKHMm4TpTUJjHadZyyrQw/Y/HqhS3H3ke/PD8xGwjwBrYg66udavKm853fLJWrP 6ZWuOaMiOHVVxKNboiC1IJrPLXVVY7lbicvLTJA79RjD8ekMMix0V8tB5CcZ6Nui3gYN 3CXw== X-Gm-Message-State: AFqh2krMR+tjsRcdEc8egOETbVsDWEEKNM0fKTS049/AiejDVFuWeWL4 T0feQolyWoq3GbOdleqEifpFW4wurDFdiQ== X-Google-Smtp-Source: AMrXdXv1yiO0KMkIhb11kmOe9UwhRGrUnDUzUMhysGvmoSAuv42gax0gvOWnRmIvbxOwN5QGQiTTgA== X-Received: by 2002:adf:d4c7:0:b0:241:bc33:b188 with SMTP id w7-20020adfd4c7000000b00241bc33b188mr38980470wrk.18.1673034047147; Fri, 06 Jan 2023 11:40:47 -0800 (PST) Received: from localhost.localdomain ([90.242.19.250]) by smtp.gmail.com with ESMTPSA id bx9-20020a5d5b09000000b0023662245d3csm1968650wrb.95.2023.01.06.11.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 11:40:46 -0800 (PST) Sender: Adam Pigg From: adam@piggz.co.uk To: linux-media@vger.kernel.org Cc: yong.deng@magewell.com, mchehab@kernel.org, linux-sunxi@lists.linux.dev, paul.kocialkowski@bootlin.com, laurent.pinchart@ideasonboard.com, Adam Pigg Subject: [PATCH 2/3] media: sun6i-csi: implement V4L2_CAP_IO_MC Date: Fri, 6 Jan 2023 19:40:37 +0000 Message-Id: <20230106194038.16018-3-adam@piggz.co.uk> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106194038.16018-1-adam@piggz.co.uk> References: <20230106194038.16018-1-adam@piggz.co.uk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Adam Pigg modify sun6i_csi_capture_enum_fmt to check the mbus_codes from the pixel format array for the supplied format Signed-off-by: Adam Pigg Reviewed-by: Laurent Pinchart --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 69578075421c..54beba4d2b2f 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -666,13 +666,43 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *private, struct v4l2_fmtdesc *fmtdesc) { u32 index = fmtdesc->index; + unsigned int i; if (index >= ARRAY_SIZE(sun6i_csi_capture_formats)) return -EINVAL; - fmtdesc->pixelformat = sun6i_csi_capture_formats[index].pixelformat; + for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_formats); i++) { + const struct sun6i_csi_capture_format *format = + &sun6i_csi_capture_formats[i]; - return 0; + /* + * If a media bus code is specified, only consider formats that + * match it. + */ + if (fmtdesc->mbus_code) { + unsigned int j; + + if (!format->mbus_codes) + continue; + + for (j = 0; format->mbus_codes[j]; j++) { + if (fmtdesc->mbus_code == format->mbus_codes[j]) + break; + } + + if (!format->mbus_codes[j]) + continue; + } + + if (index == 0) { + fmtdesc->pixelformat = format->pixelformat; + return 0; + } + + index--; + } + + return -EINVAL; } static int sun6i_csi_capture_g_fmt(struct file *file, void *private, @@ -978,7 +1008,7 @@ int sun6i_csi_capture_setup(struct sun6i_csi_device *csi_dev) strscpy(video_dev->name, SUN6I_CSI_CAPTURE_NAME, sizeof(video_dev->name)); - video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | V4L2_CAP_IO_MC; video_dev->vfl_dir = VFL_DIR_RX; video_dev->release = video_device_release_empty; video_dev->fops = &sun6i_csi_capture_fops; From patchwork Fri Jan 6 19:40:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Pigg X-Patchwork-Id: 13091736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A35CBC54EBD for ; Fri, 6 Jan 2023 19:40:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235598AbjAFTkz (ORCPT ); Fri, 6 Jan 2023 14:40:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234327AbjAFTkw (ORCPT ); Fri, 6 Jan 2023 14:40:52 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB26534D6D for ; Fri, 6 Jan 2023 11:40:49 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id bn26so2251396wrb.0 for ; Fri, 06 Jan 2023 11:40:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Latrb+MylXKpijKJpBSX+i5hbxF05MEWVlFc7jwtP/8=; b=YKctH5fjqcumY5lCDtSZvEB+l0daLNKgaN/gGuIAxKyiKTeAFvwYFuomDIaC3l6aad yisgmxL1Grfg0sgROu/hfu+di7RJVSlJLl46D9rvGhzudtXydCDByjlgChGlg3kCuNRy gk6S2LsElk0RQMXHyEEnWIhWWEpqik8i02fsnuiUTzI4Fm7K99hJ5Pskw1cl7/eyiPsz pPjLbCL+piZQdZuVzpmZJqnhwdWKIo+o9Kx7VK9gdCa95lsnDLXabPXrlpodXLK5jxCe R2ncpnaDz8etsBzyEwwM97LTo0x8F8d4a8gDsLN65N0rtR5Qja99zGpyyLriV00ZTDPU Ftbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Latrb+MylXKpijKJpBSX+i5hbxF05MEWVlFc7jwtP/8=; b=IjFvG4oReim+meuQCs5haOglwR/cWXiZlX+N7ahTnPUZHErEkJ2eGsDWjCeNPy6FWu KgFQATuSnCgLA5ddVblnIOV5edLMhqqC9qqpbG9mbr7QrG5oh31Dh24itrN3EB7y0NRy iVQg9UT8/Kqtvz0bs14Yo+df3+I7+y7zsUg0BxB4KhSjr2P+EgLdOAQIxonbntaUZ3zo fvg+o9OKoZS+BvsJfhVh85gsm9yfD2IGXXg9b/DmYmpsq2QtlOKmH71J+EwErpbOAXWK N06rHU5Od4hv7xxkZdqzxnweL7HLg55RJmeKWSJc6tF0dG9/5FzhXwmzLGwQ4LVLoBpR Irgw== X-Gm-Message-State: AFqh2kr0nVqvxCq2eR6jfLt7hailEXopQcSPXh3n8Hm5oaX477RByDy0 z/BxPjClXLnuS5jgfNq4NLGn2nbXEnd6rA== X-Google-Smtp-Source: AMrXdXs19AD5nkwy9gvXfhwBvkwr2YNqDNswO1U8o9FlnL9V9B9zvOCLbPWOLuYPGUIYAaY7sdGYKw== X-Received: by 2002:adf:ec0e:0:b0:2bb:3219:9bfc with SMTP id x14-20020adfec0e000000b002bb32199bfcmr1190256wrn.50.1673034049168; Fri, 06 Jan 2023 11:40:49 -0800 (PST) Received: from localhost.localdomain ([90.242.19.250]) by smtp.gmail.com with ESMTPSA id bx9-20020a5d5b09000000b0023662245d3csm1968650wrb.95.2023.01.06.11.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 11:40:48 -0800 (PST) Sender: Adam Pigg From: adam@piggz.co.uk To: linux-media@vger.kernel.org Cc: yong.deng@magewell.com, mchehab@kernel.org, linux-sunxi@lists.linux.dev, paul.kocialkowski@bootlin.com, laurent.pinchart@ideasonboard.com, Adam Pigg Subject: [PATCH 3/3] media: sun6i-csi: implement vidioc_enum_framesizes Date: Fri, 6 Jan 2023 19:40:38 +0000 Message-Id: <20230106194038.16018-4-adam@piggz.co.uk> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106194038.16018-1-adam@piggz.co.uk> References: <20230106194038.16018-1-adam@piggz.co.uk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Adam Pigg Create sun6i_csi_capture_enum_framesizes which defines the min and max frame sizes Signed-off-by: Adam Pigg Reviewed-by: Laurent Pinchart --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 54beba4d2b2f..2be761e6b650 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -739,6 +739,29 @@ static int sun6i_csi_capture_try_fmt(struct file *file, void *private, return 0; } +static int sun6i_csi_capture_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *fsize) +{ + const struct sun6i_csi_capture_format *format; + + if (fsize->index > 0) + return -EINVAL; + + format = sun6i_csi_capture_format_find(fsize->pixel_format); + if (!format) + return -EINVAL; + + fsize->type = V4L2_FRMSIZE_TYPE_CONTINUOUS; + fsize->stepwise.min_width = SUN6I_CSI_CAPTURE_WIDTH_MIN; + fsize->stepwise.max_width = SUN6I_CSI_CAPTURE_WIDTH_MAX; + fsize->stepwise.min_height = SUN6I_CSI_CAPTURE_HEIGHT_MIN; + fsize->stepwise.max_height = SUN6I_CSI_CAPTURE_HEIGHT_MAX; + fsize->stepwise.step_width = 1; + fsize->stepwise.step_height = 1; + + return 0; +} + static int sun6i_csi_capture_enum_input(struct file *file, void *private, struct v4l2_input *input) { @@ -775,6 +798,7 @@ static const struct v4l2_ioctl_ops sun6i_csi_capture_ioctl_ops = { .vidioc_g_fmt_vid_cap = sun6i_csi_capture_g_fmt, .vidioc_s_fmt_vid_cap = sun6i_csi_capture_s_fmt, .vidioc_try_fmt_vid_cap = sun6i_csi_capture_try_fmt, + .vidioc_enum_framesizes = sun6i_csi_capture_enum_framesizes, .vidioc_enum_input = sun6i_csi_capture_enum_input, .vidioc_g_input = sun6i_csi_capture_g_input,