From patchwork Mon Feb 21 11:04:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 544557 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 EB59DC433EF for ; Mon, 21 Feb 2022 11:19:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356117AbiBULTl (ORCPT ); Mon, 21 Feb 2022 06:19:41 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356113AbiBULTb (ORCPT ); Mon, 21 Feb 2022 06:19:31 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6025E82 for ; Mon, 21 Feb 2022 03:05:08 -0800 (PST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id C284240016; Mon, 21 Feb 2022 11:05:03 +0000 (UTC) From: Jacopo Mondi To: aford173@gmail.com, slongerbeam@gmail.com, p.zabel@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, martin.kepplinger@puri.sm, rmfrfs@gmail.com, xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com, dorota.czaplejewicz@puri.sm Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jacopo Mondi Subject: [PATCH v3 1/7] media: imx: De-stage imx7-mipi-csis Date: Mon, 21 Feb 2022 12:04:30 +0100 Message-Id: <20220221110436.45419-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220221110436.45419-1-jacopo@jmondi.org> References: <20220221110436.45419-1-jacopo@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The imx7-mipi-csis driver is in a good state and can be destaged. Move the imx7-mipi-csis.c driver to the newly created drivers/media/platform/imx directory and plumb the related options in Kconfig and in Makefile. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- MAINTAINERS | 2 +- drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/imx/Kconfig | 24 +++++++++++++++++++ drivers/media/platform/imx/Makefile | 1 + .../platform}/imx/imx7-mipi-csis.c | 0 drivers/staging/media/imx/Makefile | 1 - 7 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 drivers/media/platform/imx/Kconfig create mode 100644 drivers/media/platform/imx/Makefile rename drivers/{staging/media => media/platform}/imx/imx7-mipi-csis.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index 83d27b57016f..5bdb8c881b0b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11891,8 +11891,8 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/admin-guide/media/imx7.rst F: Documentation/devicetree/bindings/media/nxp,imx7-csi.yaml F: Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.yaml +F: drivers/media/platform/imx/imx7-mipi-csis.c F: drivers/staging/media/imx/imx7-media-csi.c -F: drivers/staging/media/imx/imx7-mipi-csis.c MEDIA DRIVERS FOR HELENE M: Abylay Ospan diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig index 9fbdba0fd1e7..d9eeccffea69 100644 --- a/drivers/media/platform/Kconfig +++ b/drivers/media/platform/Kconfig @@ -171,6 +171,7 @@ source "drivers/media/platform/xilinx/Kconfig" source "drivers/media/platform/rcar-vin/Kconfig" source "drivers/media/platform/atmel/Kconfig" source "drivers/media/platform/sunxi/Kconfig" +source "drivers/media/platform/imx/Kconfig" config VIDEO_TI_CAL tristate "TI CAL (Camera Adaptation Layer) driver" diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile index 28eb4aadbf45..a9466c854610 100644 --- a/drivers/media/platform/Makefile +++ b/drivers/media/platform/Makefile @@ -20,6 +20,7 @@ obj-y += ti-vpe/ obj-$(CONFIG_VIDEO_MX2_EMMAPRP) += mx2_emmaprp.o obj-$(CONFIG_VIDEO_CODA) += coda/ +obj-$(CONFIG_VIDEO_IMX) += imx/ obj-$(CONFIG_VIDEO_IMX_PXP) += imx-pxp.o obj-$(CONFIG_VIDEO_IMX8_JPEG) += imx-jpeg/ diff --git a/drivers/media/platform/imx/Kconfig b/drivers/media/platform/imx/Kconfig new file mode 100644 index 000000000000..683863572c20 --- /dev/null +++ b/drivers/media/platform/imx/Kconfig @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: GPL-2.0-only + +menuconfig VIDEO_IMX + bool "V4L2 capture drivers for NXP i.MX devices" + depends on ARCH_MXC || COMPILE_TEST + depends on VIDEO_DEV && VIDEO_V4L2 + help + Say yes here to enable support for capture drivers on i.MX SoCs. + Support for the single SoC features are selectable in the sub-menu + options. + +if VIDEO_IMX + +config VIDEO_IMX_MIPI_CSIS + tristate "MIPI CSI-2 CSIS receiver found on i.MX7 and i.MX8 models" + select MEDIA_CONTROLLER + select V4L2_FWNODE + select VIDEO_V4L2_SUBDEV_API + default n + help + Video4Linux2 sub-device driver for the MIPI CSI-2 CSIS receiver + v3.3/v3.6.3 found on some i.MX7 and i.MX8 SoCs. + +endif # VIDEO_IMX diff --git a/drivers/media/platform/imx/Makefile b/drivers/media/platform/imx/Makefile new file mode 100644 index 000000000000..ee272234c8d7 --- /dev/null +++ b/drivers/media/platform/imx/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_VIDEO_IMX_MIPI_CSIS) += imx7-mipi-csis.o diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/media/platform/imx/imx7-mipi-csis.c similarity index 100% rename from drivers/staging/media/imx/imx7-mipi-csis.c rename to drivers/media/platform/imx/imx7-mipi-csis.c diff --git a/drivers/staging/media/imx/Makefile b/drivers/staging/media/imx/Makefile index 19c2fc54d424..d82be898145b 100644 --- a/drivers/staging/media/imx/Makefile +++ b/drivers/staging/media/imx/Makefile @@ -15,5 +15,4 @@ obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-media-csi.o obj-$(CONFIG_VIDEO_IMX_CSI) += imx6-mipi-csi2.o obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-media-csi.o -obj-$(CONFIG_VIDEO_IMX7_CSI) += imx7-mipi-csis.o obj-$(CONFIG_VIDEO_IMX7_CSI) += imx8mq-mipi-csi2.o From patchwork Mon Feb 21 11:04:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 544554 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 68379C433FE for ; Mon, 21 Feb 2022 11:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355947AbiBULUD (ORCPT ); Mon, 21 Feb 2022 06:20:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356122AbiBULTb (ORCPT ); Mon, 21 Feb 2022 06:19:31 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2203E9C for ; Mon, 21 Feb 2022 03:05:14 -0800 (PST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 79F3840010; Mon, 21 Feb 2022 11:05:07 +0000 (UTC) From: Jacopo Mondi To: aford173@gmail.com, slongerbeam@gmail.com, p.zabel@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, martin.kepplinger@puri.sm, rmfrfs@gmail.com, xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com, dorota.czaplejewicz@puri.sm Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jacopo Mondi Subject: [PATCH v3 2/7] media: imx: Rename imx7-mipi-csis.c to imx-mipi-csis.c Date: Mon, 21 Feb 2022 12:04:31 +0100 Message-Id: <20220221110436.45419-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220221110436.45419-1-jacopo@jmondi.org> References: <20220221110436.45419-1-jacopo@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Rename the imx7-mipi-csis.c driver to remove the reference to i.MX7. The driver is for an IP core found on i.MX7 and i.MX8 SoC, so do not specify a SoC version number in the driver name. Remove the references to the i.MX7 SoC in the driver symbols and expand the driver's header with more information about the IP core the driver controls. Also rename the associated bindings documentation. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- Documentation/admin-guide/media/imx7.rst | 2 +- ...{nxp,imx7-mipi-csi2.yaml => nxp,imx-mipi-csi2.yaml} | 2 +- MAINTAINERS | 4 ++-- drivers/media/platform/imx/Makefile | 2 +- .../platform/imx/{imx7-mipi-csis.c => imx-mipi-csis.c} | 10 +++++++--- 5 files changed, 12 insertions(+), 8 deletions(-) rename Documentation/devicetree/bindings/media/{nxp,imx7-mipi-csi2.yaml => nxp,imx-mipi-csi2.yaml} (98%) rename drivers/media/platform/imx/{imx7-mipi-csis.c => imx-mipi-csis.c} (99%) diff --git a/Documentation/admin-guide/media/imx7.rst b/Documentation/admin-guide/media/imx7.rst index 4785ae8ac978..2fa27718f52a 100644 --- a/Documentation/admin-guide/media/imx7.rst +++ b/Documentation/admin-guide/media/imx7.rst @@ -33,7 +33,7 @@ reference manual [#f1]_. Entities -------- -imx7-mipi-csi2 +imx-mipi-csi2 -------------- This is the MIPI CSI-2 receiver entity. It has one sink pad to receive the pixel diff --git a/Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.yaml b/Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml similarity index 98% rename from Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.yaml rename to Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml index e2e6e9aa0fe6..36b135bf9f2a 100644 --- a/Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.yaml +++ b/Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml @@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 --- -$id: http://devicetree.org/schemas/media/nxp,imx7-mipi-csi2.yaml# +$id: http://devicetree.org/schemas/media/nxp,imx-mipi-csi2.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: NXP i.MX7 and i.MX8 MIPI CSI-2 receiver diff --git a/MAINTAINERS b/MAINTAINERS index 5bdb8c881b0b..d919ea3ed250 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11889,9 +11889,9 @@ L: linux-media@vger.kernel.org S: Maintained T: git git://linuxtv.org/media_tree.git F: Documentation/admin-guide/media/imx7.rst +F: Documentation/devicetree/bindings/media/nxp,imx-mipi-csi2.yaml F: Documentation/devicetree/bindings/media/nxp,imx7-csi.yaml -F: Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.yaml -F: drivers/media/platform/imx/imx7-mipi-csis.c +F: drivers/media/platform/imx/imx-mipi-csis.c F: drivers/staging/media/imx/imx7-media-csi.c MEDIA DRIVERS FOR HELENE diff --git a/drivers/media/platform/imx/Makefile b/drivers/media/platform/imx/Makefile index ee272234c8d7..f72bdbe8e6ef 100644 --- a/drivers/media/platform/imx/Makefile +++ b/drivers/media/platform/imx/Makefile @@ -1 +1 @@ -obj-$(CONFIG_VIDEO_IMX_MIPI_CSIS) += imx7-mipi-csis.o +obj-$(CONFIG_VIDEO_IMX_MIPI_CSIS) += imx-mipi-csis.o diff --git a/drivers/media/platform/imx/imx7-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c similarity index 99% rename from drivers/media/platform/imx/imx7-mipi-csis.c rename to drivers/media/platform/imx/imx-mipi-csis.c index a22d0e6b3d44..3e7efcf43a5f 100644 --- a/drivers/media/platform/imx/imx7-mipi-csis.c +++ b/drivers/media/platform/imx/imx-mipi-csis.c @@ -1,6 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Freescale i.MX7 SoC series MIPI-CSI V3.3 receiver driver + * Samsung CSIS MIPI CSI-2 receiver driver. + * + * The Samsung CSIS IP is a MIPI CSI-2 receiver found in various NXP i.MX7 and + * i.MX8 SoCs. The i.MX7 features version 3.3 of the IP, while i.MX8 features + * version 3.6.3. * * Copyright (C) 2019 Linaro Ltd * Copyright (C) 2015-2016 Freescale Semiconductor, Inc. All Rights Reserved. @@ -31,7 +35,7 @@ #include #include -#define CSIS_DRIVER_NAME "imx7-mipi-csis" +#define CSIS_DRIVER_NAME "imx-mipi-csis" #define CSIS_PAD_SINK 0 #define CSIS_PAD_SOURCE 1 @@ -1515,4 +1519,4 @@ module_platform_driver(mipi_csis_driver); MODULE_DESCRIPTION("i.MX7 & i.MX8 MIPI CSI-2 receiver driver"); MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:imx7-mipi-csi2"); +MODULE_ALIAS("platform:imx-mipi-csi2"); From patchwork Mon Feb 21 11:04:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 545797 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 E2B5BC4332F for ; Mon, 21 Feb 2022 11:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356061AbiBULUF (ORCPT ); Mon, 21 Feb 2022 06:20:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356121AbiBULTb (ORCPT ); Mon, 21 Feb 2022 06:19:31 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41704F18 for ; Mon, 21 Feb 2022 03:05:18 -0800 (PST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 72CE040014; Mon, 21 Feb 2022 11:05:13 +0000 (UTC) From: Jacopo Mondi To: aford173@gmail.com, slongerbeam@gmail.com, p.zabel@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, martin.kepplinger@puri.sm, rmfrfs@gmail.com, xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com, dorota.czaplejewicz@puri.sm Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jacopo Mondi Subject: [PATCH v3 3/7] media: imx: imx7-media-csi: Use dual sampling for YUV 1X16 Date: Mon, 21 Feb 2022 12:04:32 +0100 Message-Id: <20220221110436.45419-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220221110436.45419-1-jacopo@jmondi.org> References: <20220221110436.45419-1-jacopo@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The CSI bridge should operate in dual components mode when it is connected to a pixel transmitter that transfers two components at a time in YUV 422 formats (16 bits, Y + U/V). Use the image format variants to determine if single or dual component mode should be used. Add a note to the TODO file to record that the list of supported formats should be restricted to the SoC model the CSI bridge is integrated on to avoid potential pipeline mis-configurations. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/staging/media/imx/TODO | 25 +++++++++++++++ drivers/staging/media/imx/imx7-media-csi.c | 37 +++++++++++++++++++--- 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/TODO b/drivers/staging/media/imx/TODO index 06c94f20ecf8..5d3a337c8702 100644 --- a/drivers/staging/media/imx/TODO +++ b/drivers/staging/media/imx/TODO @@ -27,3 +27,28 @@ - i.MX7: all of the above, since it uses the imx media core - i.MX7: use Frame Interval Monitor + +- imx7-media-csi: Restrict the supported formats list to the SoC version. + + The imx7 CSI bridge can be configured to sample pixel components from the Rx + queue in single (8bpp) or double (16bpp) component modes. Image format + variants with different sample sizes (ie YUYV_2X8 vs YUYV_1X16) determine the + pixel components sampling size per each clock cycle and their packing mode + (see imx7_csi_configure() for details). + + As the imx7 CSI bridge can be interfaced with different IP blocks depending on + the SoC model it is integrated on, the Rx queue sampling size should match + the size of the samples transferred by the transmitting IP block. + + To avoid mis-configurations of the capture pipeline, the enumeration of the + supported formats should be restricted to match the pixel source transmitting + mode. + + Example: i.MX8MM SoC integrates the CSI bridge with the Samsung CSIS CSI-2 + receiver which operates in dual pixel sampling mode. The CSI bridge should + only expose the 1X16 formats variant which instructs it to operate in dual + pixel sampling mode. When the CSI bridge is instead integrated on an i.MX7, + which supports both serial and parallel input, it should expose both variants. + + This currently only applies to YUYV formats, but other formats might need + to be handled in the same way. diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 32311fc0e2a4..cf57157872b0 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -498,16 +498,45 @@ static void imx7_csi_configure(struct imx7_csi *csi) cr3 |= BIT_TWO_8BIT_SENSOR; cr18 |= BIT_MIPI_DATA_FORMAT_RAW14; break; + /* - * CSI-2 sources are supposed to use the 1X16 formats, but not - * all of them comply. Support both variants. + * The CSI bridge has a 16-bit input bus. Depending on + * the connected source, data may be transmitted with 8 + * or 10 bits per clock sample (in bits [9:2] or [9:0] + * respectively) or with 16 bits per clock sample (in + * bits [15:0]). The data is then packed into a 32-bit + * FIFO (as shown in figure 13-11 of the i.MX8MM + * reference manual rev. 3). + * + * The data packing in a 32-bit FIFO input word is + * controlled by the CR3 TWO_8BIT_SENSOR field (also + * known as SENSOR_16BITS in the i.MX8MM reference + * manual). When set to 0, data packing groups four + * 8-bit input samples (bits [9:2]). When set to 1, data + * packing groups two 16-bit input samples (bits + * [15:0]). + * + * The register field CR18 MIPI_DOUBLE_CMPNT also needs + * to be configured according to the input format for + * YUV 4:2:2 data. The field controls the gasket between + * the CSI-2 receiver and the CSI bridge. On i.MX7 and + * i.MX8MM, the field must be set to 1 when the CSIS + * outputs 16-bit samples. On i.MX8MQ, the gasket + * ignores the MIPI_DOUBLE_CMPNT bit and YUV 4:2:2 + * always uses 16-bit samples. Setting MIPI_DOUBLE_CMPNT + * in that case has no effect, but doesn't cause any + * issue. */ case MEDIA_BUS_FMT_UYVY8_2X8: - case MEDIA_BUS_FMT_UYVY8_1X16: case MEDIA_BUS_FMT_YUYV8_2X8: - case MEDIA_BUS_FMT_YUYV8_1X16: cr18 |= BIT_MIPI_DATA_FORMAT_YUV422_8B; break; + case MEDIA_BUS_FMT_UYVY8_1X16: + case MEDIA_BUS_FMT_YUYV8_1X16: + cr3 |= BIT_TWO_8BIT_SENSOR; + cr18 |= BIT_MIPI_DATA_FORMAT_YUV422_8B | + BIT_MIPI_DOUBLE_CMPNT; + break; } } From patchwork Mon Feb 21 11:04:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 544556 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 08AFCC433F5 for ; Mon, 21 Feb 2022 11:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356017AbiBULTr (ORCPT ); Mon, 21 Feb 2022 06:19:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356123AbiBULTb (ORCPT ); Mon, 21 Feb 2022 06:19:31 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11239F1C for ; Mon, 21 Feb 2022 03:05:21 -0800 (PST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 0E2B940005; Mon, 21 Feb 2022 11:05:16 +0000 (UTC) From: Jacopo Mondi To: aford173@gmail.com, slongerbeam@gmail.com, p.zabel@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, martin.kepplinger@puri.sm, rmfrfs@gmail.com, xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com, dorota.czaplejewicz@puri.sm Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jacopo Mondi Subject: [PATCH v3 4/7] media: imx: imx-mipi-csis: Set PIXEL_MODE for YUV422 Date: Mon, 21 Feb 2022 12:04:33 +0100 Message-Id: <20220221110436.45419-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220221110436.45419-1-jacopo@jmondi.org> References: <20220221110436.45419-1-jacopo@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Bits 13 and 12 of the ISP_CONFIGn register configure the PIXEL_MODE which specifies the sampling size, in pixel component units, on the CSI-2 output data interface when data are transferred to memory. The register description in the chip manual specifies that DUAL mode should be used for YUV422 data. Signed-off-by: Jacopo Mondi Signed-off-by: Xavier Roumegue Reviewed-by: Laurent Pinchart --- drivers/media/platform/imx/imx-mipi-csis.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c index 3e7efcf43a5f..9d5034759987 100644 --- a/drivers/media/platform/imx/imx-mipi-csis.c +++ b/drivers/media/platform/imx/imx-mipi-csis.c @@ -173,6 +173,7 @@ #define MIPI_CSIS_ISPCFG_PIXEL_MODE_SINGLE (0 << 12) #define MIPI_CSIS_ISPCFG_PIXEL_MODE_DUAL (1 << 12) #define MIPI_CSIS_ISPCFG_PIXEL_MODE_QUAD (2 << 12) /* i.MX8M[MNP] only */ +#define MIPI_CSIS_ISPCFG_PIXEL_MASK (3 << 12) #define MIPI_CSIS_ISPCFG_ALIGN_32BIT BIT(11) #define MIPI_CSIS_ISPCFG_FMT(fmt) ((fmt) << 2) #define MIPI_CSIS_ISPCFG_FMT_MASK (0x3f << 2) @@ -506,7 +507,25 @@ static void __mipi_csis_set_format(struct csi_state *state) /* Color format */ val = mipi_csis_read(state, MIPI_CSIS_ISP_CONFIG_CH(0)); - val &= ~(MIPI_CSIS_ISPCFG_ALIGN_32BIT | MIPI_CSIS_ISPCFG_FMT_MASK); + val &= ~(MIPI_CSIS_ISPCFG_ALIGN_32BIT | MIPI_CSIS_ISPCFG_FMT_MASK + | MIPI_CSIS_ISPCFG_PIXEL_MASK); + + /* + * YUV 4:2:2 can be transferred with 8 or 16 bits per clock sample + * (referred to in the documentation as single and dual pixel modes + * respectively, although the 8-bit mode transfers half a pixel per + * clock sample and the 16-bit mode one pixel). While both mode work + * when the CSIS is connected to a receiver that supports either option, + * single pixel mode requires clock rates twice as high. As all SoCs + * that integrate the CSIS can operate in 16-bit bit mode, and some do + * not support 8-bit mode (this is the case of the i.MX8MP), use dual + * pixel mode unconditionally. + * + * TODO: Verify which other formats require DUAL (or QUAD) modes. + */ + if (state->csis_fmt->data_type == MIPI_CSI2_DATA_TYPE_YUV422_8) + val |= MIPI_CSIS_ISPCFG_PIXEL_MODE_DUAL; + val |= MIPI_CSIS_ISPCFG_FMT(state->csis_fmt->data_type); mipi_csis_write(state, MIPI_CSIS_ISP_CONFIG_CH(0), val); From patchwork Mon Feb 21 11:04:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 545799 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 231CFC433FE for ; Mon, 21 Feb 2022 11:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356005AbiBULTv (ORCPT ); Mon, 21 Feb 2022 06:19:51 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356129AbiBULTc (ORCPT ); Mon, 21 Feb 2022 06:19:32 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576FFF71 for ; Mon, 21 Feb 2022 03:05:24 -0800 (PST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 9986D4000D; Mon, 21 Feb 2022 11:05:20 +0000 (UTC) From: Jacopo Mondi To: aford173@gmail.com, slongerbeam@gmail.com, p.zabel@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, martin.kepplinger@puri.sm, rmfrfs@gmail.com, xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com, dorota.czaplejewicz@puri.sm Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jacopo Mondi Subject: [PATCH v3 5/7] media: imx: imx-mipi-csis: Add RGB565_1X16 Date: Mon, 21 Feb 2022 12:04:34 +0100 Message-Id: <20220221110436.45419-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220221110436.45419-1-jacopo@jmondi.org> References: <20220221110436.45419-1-jacopo@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add RGB565_1X16 to the enumeration of supported image formats. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/platform/imx/imx-mipi-csis.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c index 9d5034759987..46055b5f8412 100644 --- a/drivers/media/platform/imx/imx-mipi-csis.c +++ b/drivers/media/platform/imx/imx-mipi-csis.c @@ -360,6 +360,12 @@ static const struct csis_pix_format mipi_csis_formats[] = { .data_type = MIPI_CSI2_DATA_TYPE_YUV422_8, .width = 16, }, + /* RGB formats. */ + { + .code = MEDIA_BUS_FMT_RGB565_1X16, + .data_type = MIPI_CSI2_DATA_TYPE_RGB565, + .width = 16, + }, /* RAW (Bayer and greyscale) formats. */ { .code = MEDIA_BUS_FMT_SBGGR8_1X8, From patchwork Mon Feb 21 11:04:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 544555 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 3969EC433F5 for ; Mon, 21 Feb 2022 11:19:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356054AbiBULTy (ORCPT ); Mon, 21 Feb 2022 06:19:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356134AbiBULTc (ORCPT ); Mon, 21 Feb 2022 06:19:32 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78B06F73 for ; Mon, 21 Feb 2022 03:05:28 -0800 (PST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 0A9A540002; Mon, 21 Feb 2022 11:05:23 +0000 (UTC) From: Jacopo Mondi To: aford173@gmail.com, slongerbeam@gmail.com, p.zabel@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, martin.kepplinger@puri.sm, rmfrfs@gmail.com, xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com, dorota.czaplejewicz@puri.sm Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jacopo Mondi Subject: [PATCH v3 6/7] media: imx: imx-mipi-csis: Add BGR888 Date: Mon, 21 Feb 2022 12:04:35 +0100 Message-Id: <20220221110436.45419-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220221110436.45419-1-jacopo@jmondi.org> References: <20220221110436.45419-1-jacopo@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add support for the BGR888_1X24 image formats. No existing media bus codes describe exactly the way data is transferred on the CSI-2 bus. This is not a new issue, the CSI-2 YUV422 8-bit format is described by MEDIA_BUS_FMT_UYVY8_1X16 which is an arbitrary convention and not an exact match. Use the MEDIA_BUS_FMT_BGR888_1X24 to follow the same convention, based on the order in which bits are transmitted over the CSI-2 bus. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/platform/imx/imx-mipi-csis.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c index 46055b5f8412..a05ab151bebc 100644 --- a/drivers/media/platform/imx/imx-mipi-csis.c +++ b/drivers/media/platform/imx/imx-mipi-csis.c @@ -365,6 +365,10 @@ static const struct csis_pix_format mipi_csis_formats[] = { .code = MEDIA_BUS_FMT_RGB565_1X16, .data_type = MIPI_CSI2_DATA_TYPE_RGB565, .width = 16, + }, { + .code = MEDIA_BUS_FMT_BGR888_1X24, + .data_type = MIPI_CSI2_DATA_TYPE_RGB888, + .width = 24, }, /* RAW (Bayer and greyscale) formats. */ { From patchwork Mon Feb 21 11:04:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 545798 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 1F704C433F5 for ; Mon, 21 Feb 2022 11:19:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355844AbiBULT6 (ORCPT ); Mon, 21 Feb 2022 06:19:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:48050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356137AbiBULTc (ORCPT ); Mon, 21 Feb 2022 06:19:32 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB90BFD0 for ; Mon, 21 Feb 2022 03:05:31 -0800 (PST) Received: (Authenticated sender: jacopo@jmondi.org) by mail.gandi.net (Postfix) with ESMTPSA id 63C8F40011; Mon, 21 Feb 2022 11:05:27 +0000 (UTC) From: Jacopo Mondi To: aford173@gmail.com, slongerbeam@gmail.com, p.zabel@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, martin.kepplinger@puri.sm, rmfrfs@gmail.com, xavier.roumegue@oss.nxp.com, alexander.stein@ew.tq-group.com, dorota.czaplejewicz@puri.sm Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Jacopo Mondi Subject: [PATCH v3 7/7] media: imx: imx-mipi-csis: Add output format Date: Mon, 21 Feb 2022 12:04:36 +0100 Message-Id: <20220221110436.45419-8-jacopo@jmondi.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220221110436.45419-1-jacopo@jmondi.org> References: <20220221110436.45419-1-jacopo@jmondi.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Due to how pixel components are transmitted on the CSI-2 serial bus and how they are deserialized by the CSI-2 receiver, the component ordering might change and the image formats on the sink and source pads of the receiver should reflect it. For RGB24, in example, the component ordering on the wire as described by the CSI-2 specification matches the BGR888 format, while once deserialized by the CSIS receiver it matches the RGB888 format. Add an additional .output field to struct csis_pix_format to allow propagating the correct format to the source pad after a format configuration on the sink. The change is only relevant for RGB24 but paves the way for further format translations in future. Signed-off-by: Jacopo Mondi --- drivers/media/platform/imx/imx-mipi-csis.c | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c index a05ab151bebc..6f975b3702bc 100644 --- a/drivers/media/platform/imx/imx-mipi-csis.c +++ b/drivers/media/platform/imx/imx-mipi-csis.c @@ -349,6 +349,7 @@ struct csi_state { struct csis_pix_format { u32 code; + u32 output; u32 data_type; u8 width; }; @@ -357,94 +358,116 @@ static const struct csis_pix_format mipi_csis_formats[] = { /* YUV formats. */ { .code = MEDIA_BUS_FMT_UYVY8_1X16, + .output = MEDIA_BUS_FMT_UYVY8_1X16, .data_type = MIPI_CSI2_DATA_TYPE_YUV422_8, .width = 16, }, /* RGB formats. */ { .code = MEDIA_BUS_FMT_RGB565_1X16, + .output = MEDIA_BUS_FMT_RGB565_1X16, .data_type = MIPI_CSI2_DATA_TYPE_RGB565, .width = 16, }, { .code = MEDIA_BUS_FMT_BGR888_1X24, + .output = MEDIA_BUS_FMT_RGB888_1X24, .data_type = MIPI_CSI2_DATA_TYPE_RGB888, .width = 24, }, /* RAW (Bayer and greyscale) formats. */ { .code = MEDIA_BUS_FMT_SBGGR8_1X8, + .output = MEDIA_BUS_FMT_SBGGR8_1X8, .data_type = MIPI_CSI2_DATA_TYPE_RAW8, .width = 8, }, { .code = MEDIA_BUS_FMT_SGBRG8_1X8, + .output = MEDIA_BUS_FMT_SGBRG8_1X8, .data_type = MIPI_CSI2_DATA_TYPE_RAW8, .width = 8, }, { .code = MEDIA_BUS_FMT_SGRBG8_1X8, + .output = MEDIA_BUS_FMT_SGRBG8_1X8, .data_type = MIPI_CSI2_DATA_TYPE_RAW8, .width = 8, }, { .code = MEDIA_BUS_FMT_SRGGB8_1X8, + .output = MEDIA_BUS_FMT_SRGGB8_1X8, .data_type = MIPI_CSI2_DATA_TYPE_RAW8, .width = 8, }, { .code = MEDIA_BUS_FMT_Y8_1X8, + .output = MEDIA_BUS_FMT_Y8_1X8, .data_type = MIPI_CSI2_DATA_TYPE_RAW8, .width = 8, }, { .code = MEDIA_BUS_FMT_SBGGR10_1X10, + .output = MEDIA_BUS_FMT_SBGGR10_1X10, .data_type = MIPI_CSI2_DATA_TYPE_RAW10, .width = 10, }, { .code = MEDIA_BUS_FMT_SGBRG10_1X10, + .output = MEDIA_BUS_FMT_SGBRG10_1X10, .data_type = MIPI_CSI2_DATA_TYPE_RAW10, .width = 10, }, { .code = MEDIA_BUS_FMT_SGRBG10_1X10, + .output = MEDIA_BUS_FMT_SGRBG10_1X10, .data_type = MIPI_CSI2_DATA_TYPE_RAW10, .width = 10, }, { .code = MEDIA_BUS_FMT_SRGGB10_1X10, + .output = MEDIA_BUS_FMT_SRGGB10_1X10, .data_type = MIPI_CSI2_DATA_TYPE_RAW10, .width = 10, }, { .code = MEDIA_BUS_FMT_Y10_1X10, + .output = MEDIA_BUS_FMT_Y10_1X10, .data_type = MIPI_CSI2_DATA_TYPE_RAW10, .width = 10, }, { .code = MEDIA_BUS_FMT_SBGGR12_1X12, + .output = MEDIA_BUS_FMT_SBGGR12_1X12, .data_type = MIPI_CSI2_DATA_TYPE_RAW12, .width = 12, }, { .code = MEDIA_BUS_FMT_SGBRG12_1X12, + .output = MEDIA_BUS_FMT_SGBRG12_1X12, .data_type = MIPI_CSI2_DATA_TYPE_RAW12, .width = 12, }, { .code = MEDIA_BUS_FMT_SGRBG12_1X12, + .output = MEDIA_BUS_FMT_SGRBG12_1X12, .data_type = MIPI_CSI2_DATA_TYPE_RAW12, .width = 12, }, { .code = MEDIA_BUS_FMT_SRGGB12_1X12, + .output = MEDIA_BUS_FMT_SRGGB12_1X12, .data_type = MIPI_CSI2_DATA_TYPE_RAW12, .width = 12, }, { .code = MEDIA_BUS_FMT_Y12_1X12, + .output = MEDIA_BUS_FMT_Y12_1X12, .data_type = MIPI_CSI2_DATA_TYPE_RAW12, .width = 12, }, { .code = MEDIA_BUS_FMT_SBGGR14_1X14, + .output = MEDIA_BUS_FMT_SBGGR14_1X14, .data_type = MIPI_CSI2_DATA_TYPE_RAW14, .width = 14, }, { .code = MEDIA_BUS_FMT_SGBRG14_1X14, + .output = MEDIA_BUS_FMT_SGBRG14_1X14, .data_type = MIPI_CSI2_DATA_TYPE_RAW14, .width = 14, }, { .code = MEDIA_BUS_FMT_SGRBG14_1X14, + .output = MEDIA_BUS_FMT_SGRBG14_1X14, .data_type = MIPI_CSI2_DATA_TYPE_RAW14, .width = 14, }, { .code = MEDIA_BUS_FMT_SRGGB14_1X14, + .output = MEDIA_BUS_FMT_SRGGB14_1X14, .data_type = MIPI_CSI2_DATA_TYPE_RAW14, .width = 14, } @@ -1103,6 +1126,9 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd, CSIS_PAD_SOURCE); *fmt = sdformat->format; + /* The format on the source pad might change due to unpacking. */ + fmt->code = csis_fmt->output; + /* Store the CSIS format descriptor for active formats. */ if (sdformat->which == V4L2_SUBDEV_FORMAT_ACTIVE) state->csis_fmt = csis_fmt;