From patchwork Wed Jun 15 19:26:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 582119 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 6B777C43334 for ; Wed, 15 Jun 2022 19:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346446AbiFOT01 (ORCPT ); Wed, 15 Jun 2022 15:26:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346274AbiFOT00 (ORCPT ); Wed, 15 Jun 2022 15:26:26 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D704C42E for ; Wed, 15 Jun 2022 12:26:25 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 415F36BE; Wed, 15 Jun 2022 21:26:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655321182; bh=X6Bpa83mlbM05Ahsn9pbAKy7J8VGVgVBir46V1Ef+S0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OW6XAVWj1WSqfHwKC68ip1N/zVnim2U/Q0IHTqfxpcqNPchx206lAFBgFn4D9HFlB 6MP8Wdsxn66Aeo9x8ESmcOV0VrcJ7fAHZybS+ZE4i84ujESfnCQ7QjReBztge9lkWd LEqNrrP0xglbsXAHcopSX7OIzxtTsZ3fm4GS9Ol4= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Jacopo Mondi , Paul Elder , Rui Miguel Silva , kernel@pengutronix.de, linux-imx@nxp.com Subject: [PATCH 2/4] media: imx: imx-mipi-csis: Add version register Date: Wed, 15 Jun 2022 22:26:00 +0300 Message-Id: <20220615192602.25472-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220615192602.25472-1-laurent.pinchart@ideasonboard.com> References: <20220615192602.25472-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Register at offset 0x00 isn't documented, but the NXP BSP imx8-mipi-csi2-sam driver defines it as a version register. Tests on i.MX7D and i.MX8MP have confirmed this, with values matching the version of the IP core specified in the respective reference manuals. This commit doesn't make use of the version register at runtime as the compatible strings are enough to identify the IP core version. Nonetheless, capturing the information in register definitions that don't affect the code negatively is useful for future development. Signed-off-by: Laurent Pinchart Reviewed-by: Rui Miguel Silva --- drivers/media/platform/nxp/imx-mipi-csis.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index 09a220c1bfe8..8674aaad5fa0 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -46,6 +46,11 @@ /* Register map definition */ +/* CSIS version */ +#define MIPI_CSIS_VERSION 0x00 +#define MIPI_CSIS_VERSION_IMX7D 0x03030505 +#define MIPI_CSIS_VERSION_IMX8MP 0x03060301 + /* CSIS common control */ #define MIPI_CSIS_CMN_CTRL 0x04 #define MIPI_CSIS_CMN_CTRL_UPDATE_SHADOW BIT(16) From patchwork Wed Jun 15 19:26:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 582118 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 F0CBDCCA473 for ; Wed, 15 Jun 2022 19:26:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346383AbiFOT0g (ORCPT ); Wed, 15 Jun 2022 15:26:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346472AbiFOT01 (ORCPT ); Wed, 15 Jun 2022 15:26:27 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF44053A77 for ; Wed, 15 Jun 2022 12:26:26 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E27546C7; Wed, 15 Jun 2022 21:26:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655321183; bh=ckZv0oL7PD1JjoYTV9oFCZLhKmgIhrSF+TXgNbDaNkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Irwow8yZeq/3Z9SN/wXJs0fzG8KKDZpJyYd2FpChNVbQyf/5+M8V5QSAQ2WAiDgpA LOgvcxkw10Iv5KwsZKM6OSf8uKVAKpmKrHZtOOc3NuuPBLmXTInD98CC+5R5PkRic5 sEmdhnxlzaTyBPKwJg9Tryam1O0YhVVoCBGABHUU= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Jacopo Mondi , Paul Elder , Rui Miguel Silva , kernel@pengutronix.de, linux-imx@nxp.com Subject: [PATCH 3/4] media: imx: imx-mipi-csis: Implement the .get_frame_desc() operation Date: Wed, 15 Jun 2022 22:26:01 +0300 Message-Id: <20220615192602.25472-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220615192602.25472-1-laurent.pinchart@ideasonboard.com> References: <20220615192602.25472-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The CSIS is connected to its sink through an SoC-specific gasket that needs to be configured. Depending on the platform, the gasket configuration requires knowing the CSI-2 DT. To provide the needed information, implement the .get_frame_desc() operation. Signed-off-by: Laurent Pinchart --- drivers/media/platform/nxp/imx-mipi-csis.c | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index 8674aaad5fa0..905072871ed2 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1160,6 +1160,32 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd, return 0; } +static int mipi_csis_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, + struct v4l2_mbus_frame_desc *fd) +{ + struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd); + struct v4l2_mbus_frame_desc_entry *entry = &fd->entry[0]; + + if (pad != CSIS_PAD_SOURCE) + return -EINVAL; + + fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL; + fd->num_entries = 1; + + memset(entry, 0, sizeof(*entry)); + + mutex_lock(&csis->lock); + + entry->flags = 0; + entry->pixelcode = csis->csis_fmt->code; + entry->bus.csi2.vc = 0; + entry->bus.csi2.dt = csis->csis_fmt->data_type; + + mutex_unlock(&csis->lock); + + return 0; +} + static int mipi_csis_log_status(struct v4l2_subdev *sd) { struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd); @@ -1184,6 +1210,7 @@ static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = { .enum_mbus_code = mipi_csis_enum_mbus_code, .get_fmt = mipi_csis_get_fmt, .set_fmt = mipi_csis_set_fmt, + .get_frame_desc = mipi_csis_get_frame_desc, }; static const struct v4l2_subdev_ops mipi_csis_subdev_ops = {