From patchwork Thu Dec 23 19:16:02 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527609
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 DAC59C433F5
for ; Thu, 23 Dec 2021 19:16:39 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1349947AbhLWTQd (ORCPT );
Thu, 23 Dec 2021 14:16:33 -0500
Received: from fllv0016.ext.ti.com ([198.47.19.142]:51806 "EHLO
fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S244821AbhLWTQc (ORCPT
);
Thu, 23 Dec 2021 14:16:32 -0500
Received: from fllv0035.itg.ti.com ([10.64.41.0])
by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGPeX116813;
Thu, 23 Dec 2021 13:16:25 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640286985;
bh=nwwld5OgWWX2rCypcvfqeWC/in7Aq4Ky8XkQKe0QcxY=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=O/mv/BM3UDRuUtfj4Iig9MZkRfn8RyixpD0MhfIHNnmGzcn7vSwpg8K84dDGOAPyg
N+Hm5wmEjTnC6Zs59qSrRB/o9ZMlChls42hwBOpXgHLHv8d9pge2c99auuldogwOQ3
ne7A3dI9JeJnD5WkRPPQa/ivhhEAG558SjHSxaGE=
Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25])
by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGPlG017955
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:25 -0600
Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE114.ent.ti.com
(157.170.170.25) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:24 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE115.ent.ti.com
(157.170.170.26) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:24 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQO006164;
Thu, 23 Dec 2021 13:16:21 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 01/14] media: cadence: csi2rx: Unregister v4l2 async
notifier
Date: Fri, 24 Dec 2021 00:46:02 +0530
Message-ID: <20211223191615.17803-2-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
The notifier is added to the global notifier list when registered. When
the module is removed, the struct csi2rx_priv in which the notifier is
embedded, is destroyed. As a result the notifier list has a reference to
a notifier that no longer exists. This causes invalid memory accesses
when the list is iterated over. Similar for when the probe fails.
Unregister and clean up the notifier to avoid this.
Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver")
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- Cleanup notifier in csi2rx_parse_dt() after the call to
v4l2_async_nf_add_fwnode_remote().
Changes in v3:
- New in v3.
drivers/media/platform/cadence/cdns-csi2rx.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index cc3ebb0d96f6..2a23da6a0b8e 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -404,8 +404,10 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx)
asd = v4l2_async_nf_add_fwnode_remote(&csi2rx->notifier, fwh,
struct v4l2_async_subdev);
of_node_put(ep);
- if (IS_ERR(asd))
+ if (IS_ERR(asd)) {
+ v4l2_async_nf_cleanup(&csi2rx->notifier);
return PTR_ERR(asd);
+ }
csi2rx->notifier.ops = &csi2rx_notifier_ops;
@@ -467,6 +469,7 @@ static int csi2rx_probe(struct platform_device *pdev)
return 0;
err_cleanup:
+ v4l2_async_nf_unregister(&csi2rx->notifier);
v4l2_async_nf_cleanup(&csi2rx->notifier);
err_free_priv:
kfree(csi2rx);
@@ -477,6 +480,8 @@ static int csi2rx_remove(struct platform_device *pdev)
{
struct csi2rx_priv *csi2rx = platform_get_drvdata(pdev);
+ v4l2_async_nf_unregister(&csi2rx->notifier);
+ v4l2_async_nf_cleanup(&csi2rx->notifier);
v4l2_async_unregister_subdev(&csi2rx->subdev);
kfree(csi2rx);
From patchwork Thu Dec 23 19:16:03 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527608
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 0F71FC433FE
for ; Thu, 23 Dec 2021 19:16:46 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1349986AbhLWTQn (ORCPT );
Thu, 23 Dec 2021 14:16:43 -0500
Received: from lelv0142.ext.ti.com ([198.47.23.249]:47550 "EHLO
lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1349976AbhLWTQl (ORCPT
);
Thu, 23 Dec 2021 14:16:41 -0500
Received: from lelv0265.itg.ti.com ([10.180.67.224])
by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGTsX029332;
Thu, 23 Dec 2021 13:16:29 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640286989;
bh=tf7QjMy6/O08JUi4bDn00cAzmkD9YB4PSicvbkyMLic=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=H95qSyxwiVWFYKKAOEveGnflnM6heDkrH2dByBVBtO041R6vweWMA62p3W056CjFR
VCweWPB/Vb8XiyIyYUCmslth072keC8es91gfFr/QfrPsw1F77K7Cp14SVuPoKT5L7
OLsY09hFCr/UsQ3rLupIlELqmdexXMyq/LB/uayo=
Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25])
by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGTGg079679
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:29 -0600
Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE114.ent.ti.com
(157.170.170.25) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:28 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE115.ent.ti.com
(157.170.170.26) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:28 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQP006164;
Thu, 23 Dec 2021 13:16:25 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 02/14] media: cadence: csi2rx: Cleanup media entity properly
Date: Fri, 24 Dec 2021 00:46:03 +0530
Message-ID: <20211223191615.17803-3-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
Call media_entity_cleanup() in probe error path and remove to make sure
the media entity is cleaned up properly.
Suggested-by: Laurent Pinchart
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- New in v5.
drivers/media/platform/cadence/cdns-csi2rx.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 2a23da6a0b8e..2547903f2e8e 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -471,6 +471,7 @@ static int csi2rx_probe(struct platform_device *pdev)
err_cleanup:
v4l2_async_nf_unregister(&csi2rx->notifier);
v4l2_async_nf_cleanup(&csi2rx->notifier);
+ media_entity_cleanup(&csi2rx->subdev.entity);
err_free_priv:
kfree(csi2rx);
return ret;
@@ -483,6 +484,7 @@ static int csi2rx_remove(struct platform_device *pdev)
v4l2_async_nf_unregister(&csi2rx->notifier);
v4l2_async_nf_cleanup(&csi2rx->notifier);
v4l2_async_unregister_subdev(&csi2rx->subdev);
+ media_entity_cleanup(&csi2rx->subdev.entity);
kfree(csi2rx);
return 0;
From patchwork Thu Dec 23 19:16:04 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527861
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 1C474C433FE
for ; Thu, 23 Dec 2021 19:16:40 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1349971AbhLWTQi (ORCPT );
Thu, 23 Dec 2021 14:16:38 -0500
Received: from lelv0143.ext.ti.com ([198.47.23.248]:48564 "EHLO
lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1349967AbhLWTQh (ORCPT
);
Thu, 23 Dec 2021 14:16:37 -0500
Received: from lelv0266.itg.ti.com ([10.180.67.225])
by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGX9F031716;
Thu, 23 Dec 2021 13:16:33 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640286993;
bh=FcWD7n6VkAN+74nl1acWQBFr0n0exn0pGopGVCbNxng=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=vQICtSgRuIrFVlNkL3w7xgj3Oy4AX71ygMDqYvmopbtJiPlssYjo6Qb7gk8dCrBe+
/I1IbGxOVG30TOTj+fzGs1Zw8YMioC56cA9NmoM7dKhAw9Ma/ykquQDpyFWH5qNiss
aLQu1kyj1Q0CW/psJ0+GRnCsekbge41lxR5KLcYY=
Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41])
by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGXqq124430
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:33 -0600
Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE109.ent.ti.com
(157.170.170.41) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:32 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE107.ent.ti.com
(157.170.170.37) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:32 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQQ006164;
Thu, 23 Dec 2021 13:16:29 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 03/14] media: cadence: csi2rx: Add get_fmt and set_fmt pad
ops
Date: Fri, 24 Dec 2021 00:46:04 +0530
Message-ID: <20211223191615.17803-4-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
The format is needed to calculate the link speed for the external DPHY
configuration. It is not right to query the format from the source
subdev. Add get_fmt and set_fmt pad operations so that the format can be
configured and correct bpp be selected.
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- Use YUV 1X16 formats instead of 2X8.
- New in v5.
drivers/media/platform/cadence/cdns-csi2rx.c | 137 +++++++++++++++++++
1 file changed, 137 insertions(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 2547903f2e8e..4a2a5a9d019b 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -54,6 +54,11 @@ enum csi2rx_pads {
CSI2RX_PAD_MAX,
};
+struct csi2rx_fmt {
+ u32 code;
+ u8 bpp;
+};
+
struct csi2rx_priv {
struct device *dev;
unsigned int count;
@@ -79,12 +84,43 @@ struct csi2rx_priv {
struct v4l2_subdev subdev;
struct v4l2_async_notifier notifier;
struct media_pad pads[CSI2RX_PAD_MAX];
+ struct v4l2_mbus_framefmt fmt;
/* Remote source */
struct v4l2_subdev *source_subdev;
int source_pad;
};
+static const struct csi2rx_fmt formats[] = {
+ {
+ .code = MEDIA_BUS_FMT_YUYV8_1X16,
+ .bpp = 16,
+ },
+ {
+ .code = MEDIA_BUS_FMT_UYVY8_1X16,
+ .bpp = 16,
+ },
+ {
+ .code = MEDIA_BUS_FMT_YVYU8_1X16,
+ .bpp = 16,
+ },
+ {
+ .code = MEDIA_BUS_FMT_VYUY8_1X16,
+ .bpp = 16,
+ },
+};
+
+static const struct csi2rx_fmt *csi2rx_get_fmt_by_code(u32 code)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE(formats); i++)
+ if (formats[i].code == code)
+ return &formats[i];
+
+ return NULL;
+}
+
static inline
struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
{
@@ -236,12 +272,109 @@ static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
return ret;
}
+static struct v4l2_mbus_framefmt *
+csi2rx_get_pad_format(struct csi2rx_priv *csi2rx,
+ struct v4l2_subdev_state *state,
+ unsigned int pad, u32 which)
+{
+ switch (which) {
+ case V4L2_SUBDEV_FORMAT_TRY:
+ return v4l2_subdev_get_try_format(&csi2rx->subdev, state, pad);
+ case V4L2_SUBDEV_FORMAT_ACTIVE:
+ return &csi2rx->fmt;
+ default:
+ return NULL;
+ }
+}
+
+static int csi2rx_get_fmt(struct v4l2_subdev *subdev,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_format *format)
+{
+ struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev);
+ struct v4l2_mbus_framefmt *framefmt;
+
+ mutex_lock(&csi2rx->lock);
+
+ framefmt = csi2rx_get_pad_format(csi2rx, state, format->pad,
+ format->which);
+ mutex_unlock(&csi2rx->lock);
+
+ if (!framefmt)
+ return -EINVAL;
+
+ format->format = *framefmt;
+
+ return 0;
+}
+
+static int csi2rx_set_fmt(struct v4l2_subdev *subdev,
+ struct v4l2_subdev_state *state,
+ struct v4l2_subdev_format *format)
+{
+ struct csi2rx_priv *csi2rx = v4l2_subdev_to_csi2rx(subdev);
+ struct v4l2_mbus_framefmt *framefmt;
+ const struct csi2rx_fmt *fmt;
+
+ /* No transcoding, source and sink formats must match. */
+ if (format->pad != CSI2RX_PAD_SINK)
+ return csi2rx_get_fmt(subdev, state, format);
+
+ fmt = csi2rx_get_fmt_by_code(format->format.code);
+ if (!fmt)
+ return -EOPNOTSUPP;
+
+ format->format.field = V4L2_FIELD_NONE;
+
+ mutex_lock(&csi2rx->lock);
+ framefmt = csi2rx_get_pad_format(csi2rx, state, format->pad,
+ format->which);
+ if (!framefmt) {
+ mutex_unlock(&csi2rx->lock);
+ return -EINVAL;
+ }
+
+ *framefmt = format->format;
+ mutex_unlock(&csi2rx->lock);
+
+ return 0;
+}
+
+static int csi2rx_init_cfg(struct v4l2_subdev *subdev,
+ struct v4l2_subdev_state *state)
+{
+ struct v4l2_subdev_format format = {
+ .which = state ? V4L2_SUBDEV_FORMAT_TRY
+ : V4L2_SUBDEV_FORMAT_ACTIVE,
+ .pad = CSI2RX_PAD_SINK,
+ .format = {
+ .width = 640,
+ .height = 480,
+ .code = MEDIA_BUS_FMT_UYVY8_1X16,
+ .field = V4L2_FIELD_NONE,
+ .colorspace = V4L2_COLORSPACE_SRGB,
+ .ycbcr_enc = V4L2_YCBCR_ENC_601,
+ .quantization = V4L2_QUANTIZATION_LIM_RANGE,
+ .xfer_func = V4L2_XFER_FUNC_SRGB,
+ },
+ };
+
+ return csi2rx_set_fmt(subdev, state, &format);
+}
+
+static const struct v4l2_subdev_pad_ops csi2rx_pad_ops = {
+ .get_fmt = csi2rx_get_fmt,
+ .set_fmt = csi2rx_set_fmt,
+ .init_cfg = csi2rx_init_cfg,
+};
+
static const struct v4l2_subdev_video_ops csi2rx_video_ops = {
.s_stream = csi2rx_s_stream,
};
static const struct v4l2_subdev_ops csi2rx_subdev_ops = {
.video = &csi2rx_video_ops,
+ .pad = &csi2rx_pad_ops,
};
static int csi2rx_async_bound(struct v4l2_async_notifier *notifier,
@@ -457,6 +590,10 @@ static int csi2rx_probe(struct platform_device *pdev)
if (ret)
goto err_cleanup;
+ ret = csi2rx_init_cfg(&csi2rx->subdev, NULL);
+ if (ret)
+ goto err_cleanup;
+
ret = v4l2_async_register_subdev(&csi2rx->subdev);
if (ret < 0)
goto err_cleanup;
From patchwork Thu Dec 23 19:16:05 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527605
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 846E6C433F5
for ; Thu, 23 Dec 2021 19:17:09 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1350030AbhLWTQ7 (ORCPT );
Thu, 23 Dec 2021 14:16:59 -0500
Received: from lelv0143.ext.ti.com ([198.47.23.248]:48618 "EHLO
lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1350037AbhLWTQ5 (ORCPT
);
Thu, 23 Dec 2021 14:16:57 -0500
Received: from fllv0034.itg.ti.com ([10.64.40.246])
by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGbxH031731;
Thu, 23 Dec 2021 13:16:37 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640286997;
bh=WkoZc2a2gk1txwTl3OXBZp8HVwX+d+ozeJF+A2BoGBQ=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=wafi04jXLZr6kxug6+nxQ0uxBvcpbI62JxSo8WHCLmAQ57isjO/0Zwes98lEL6z5G
2m4m0b8WQ6lcERqVgMLS29iaOMO7/n9uAw9pLhCLl/Gpp3ydG89vStvs3VdvDdE8tR
WoyM5x0YT0c8+s2/vg6D8UYsv/6MH5Y7ryN0Bft0=
Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33])
by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGbSw006581
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:37 -0600
Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE112.ent.ti.com
(10.64.6.33) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:36 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE101.ent.ti.com
(10.64.6.22) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:36 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQR006164;
Thu, 23 Dec 2021 13:16:33 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 04/14] media: cadence: csi2rx: Add external DPHY support
Date: Fri, 24 Dec 2021 00:46:05 +0530
Message-ID: <20211223191615.17803-5-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
Some platforms like TI's J721E can have the CSI2RX paired with an
external DPHY. Add support to enable and configure the DPHY using the
generic PHY framework.
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- Only error out when phy_pm_runtime_get_sync() returns a negative
value. A positive value can be returned if the phy was already
resumed.
- Do not query the source subdev for format. Use the newly added
internal format instead.
Changes in v4:
- Drop the call to set PHY submode. It is now being done via compatible
on the DPHY side.
Changes in v3:
- Use v4l2_get_link_freq() to calculate pixel clock.
Changes in v2:
- Use phy_pm_runtime_get_sync() and phy_pm_runtime_put() before making
calls to set PHY mode, etc. to make sure it is ready.
drivers/media/platform/cadence/cdns-csi2rx.c | 98 ++++++++++++++++++--
1 file changed, 88 insertions(+), 10 deletions(-)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 4a2a5a9d019b..afd4a0da8235 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -30,6 +30,12 @@
#define CSI2RX_STATIC_CFG_DLANE_MAP(llane, plane) ((plane) << (16 + (llane) * 4))
#define CSI2RX_STATIC_CFG_LANES_MASK GENMASK(11, 8)
+#define CSI2RX_DPHY_LANE_CTRL_REG 0x40
+#define CSI2RX_DPHY_CL_RST BIT(16)
+#define CSI2RX_DPHY_DL_RST(i) BIT((i) + 12)
+#define CSI2RX_DPHY_CL_EN BIT(4)
+#define CSI2RX_DPHY_DL_EN(i) BIT(i)
+
#define CSI2RX_STREAM_BASE(n) (((n) + 1) * 0x100)
#define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000)
@@ -137,6 +143,57 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx)
writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
}
+static int csi2rx_configure_external_dphy(struct csi2rx_priv *csi2rx)
+{
+ union phy_configure_opts opts = { };
+ struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy;
+ const struct csi2rx_fmt *fmt;
+ s64 pixel_clock;
+ int ret;
+ u8 bpp;
+ bool got_pm = true;
+
+ fmt = csi2rx_get_fmt_by_code(csi2rx->fmt.code);
+ bpp = fmt->bpp;
+
+ /*
+ * Do not divide by the number of lanes here. That will be done by
+ * phy_mipi_dphy_get_default_config().
+ */
+ pixel_clock = v4l2_get_link_freq(csi2rx->source_subdev->ctrl_handler,
+ 1, 2);
+ if (pixel_clock < 0)
+ return pixel_clock;
+
+ ret = phy_mipi_dphy_get_default_config(pixel_clock, bpp,
+ csi2rx->num_lanes, cfg);
+ if (ret)
+ return ret;
+
+ ret = phy_pm_runtime_get_sync(csi2rx->dphy);
+ if (ret == -ENOTSUPP)
+ got_pm = false;
+ else if (ret < 0)
+ return ret;
+
+ ret = phy_power_on(csi2rx->dphy);
+ if (ret)
+ goto out;
+
+ ret = phy_configure(csi2rx->dphy, &opts);
+ if (ret) {
+ /* Can't do anything if it fails. Ignore the return value. */
+ phy_power_off(csi2rx->dphy);
+ goto out;
+ }
+
+out:
+ if (got_pm)
+ phy_pm_runtime_put(csi2rx->dphy);
+
+ return ret;
+}
+
static int csi2rx_start(struct csi2rx_priv *csi2rx)
{
unsigned int i;
@@ -175,6 +232,17 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
if (ret)
goto err_disable_pclk;
+ /* Enable DPHY clk and data lanes. */
+ if (csi2rx->dphy) {
+ reg = CSI2RX_DPHY_CL_EN | CSI2RX_DPHY_CL_RST;
+ for (i = 0; i < csi2rx->num_lanes; i++) {
+ reg |= CSI2RX_DPHY_DL_EN(csi2rx->lanes[i] - 1);
+ reg |= CSI2RX_DPHY_DL_RST(csi2rx->lanes[i] - 1);
+ }
+
+ writel(reg, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+ }
+
/*
* Create a static mapping between the CSI virtual channels
* and the output stream.
@@ -205,10 +273,21 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
if (ret)
goto err_disable_pixclk;
+ if (csi2rx->dphy) {
+ ret = csi2rx_configure_external_dphy(csi2rx);
+ if (ret) {
+ dev_err(csi2rx->dev,
+ "Failed to configure external DPHY: %d\n", ret);
+ goto err_disable_sysclk;
+ }
+ }
+
clk_disable_unprepare(csi2rx->p_clk);
return 0;
+err_disable_sysclk:
+ clk_disable_unprepare(csi2rx->sys_clk);
err_disable_pixclk:
for (; i > 0; i--)
clk_disable_unprepare(csi2rx->pixel_clk[i - 1]);
@@ -236,6 +315,13 @@ static void csi2rx_stop(struct csi2rx_priv *csi2rx)
if (v4l2_subdev_call(csi2rx->source_subdev, video, s_stream, false))
dev_warn(csi2rx->dev, "Couldn't disable our subdev\n");
+
+ if (csi2rx->dphy) {
+ writel(0, csi2rx->base + CSI2RX_DPHY_LANE_CTRL_REG);
+
+ if (phy_power_off(csi2rx->dphy))
+ dev_warn(csi2rx->dev, "Couldn't power off DPHY\n");
+ }
}
static int csi2rx_s_stream(struct v4l2_subdev *subdev, int enable)
@@ -438,15 +524,6 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
return PTR_ERR(csi2rx->dphy);
}
- /*
- * FIXME: Once we'll have external D-PHY support, the check
- * will need to be removed.
- */
- if (csi2rx->dphy) {
- dev_err(&pdev->dev, "External D-PHY not supported yet\n");
- return -EINVAL;
- }
-
ret = clk_prepare_enable(csi2rx->p_clk);
if (ret) {
dev_err(&pdev->dev, "Couldn't prepare and enable P clock\n");
@@ -476,7 +553,7 @@ static int csi2rx_get_resources(struct csi2rx_priv *csi2rx,
* FIXME: Once we'll have internal D-PHY support, the check
* will need to be removed.
*/
- if (csi2rx->has_internal_dphy) {
+ if (!csi2rx->dphy && csi2rx->has_internal_dphy) {
dev_err(&pdev->dev, "Internal D-PHY not supported yet\n");
return -EINVAL;
}
@@ -601,6 +678,7 @@ static int csi2rx_probe(struct platform_device *pdev)
dev_info(&pdev->dev,
"Probed CSI2RX with %u/%u lanes, %u streams, %s D-PHY\n",
csi2rx->num_lanes, csi2rx->max_lanes, csi2rx->max_streams,
+ csi2rx->dphy ? "external" :
csi2rx->has_internal_dphy ? "internal" : "no");
return 0;
From patchwork Thu Dec 23 19:16:06 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527860
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 BE00BC433FE
for ; Thu, 23 Dec 2021 19:16:49 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1350001AbhLWTQr (ORCPT );
Thu, 23 Dec 2021 14:16:47 -0500
Received: from lelv0143.ext.ti.com ([198.47.23.248]:48584 "EHLO
lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1349984AbhLWTQq (ORCPT
);
Thu, 23 Dec 2021 14:16:46 -0500
Received: from lelv0266.itg.ti.com ([10.180.67.225])
by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGfdt031738;
Thu, 23 Dec 2021 13:16:41 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640287001;
bh=UOBoBf5jPZmq44GOkxtvSQRyD77EhLUs4Xa2ASMj/QI=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=IrLNwhyEpfSX8nToCy2oSsmwhwDRZw8DFM2g2w5HTKQXOxjNKIvq7w7azHAL6Cay2
eBQTPPEQ4jYsrnjSkqNfPg2s9cwFy8AjKHcrZfTTQwiLp3kRL/sqM5lE34Vh44+E3p
UbnuWRCZ5VkQ3eewBQLrfiS1vB4utSoyNkO3ePUo=
Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30])
by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGfdC124494
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:41 -0600
Received: from DFLE106.ent.ti.com (10.64.6.27) by DFLE109.ent.ti.com
(10.64.6.30) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:40 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE106.ent.ti.com
(10.64.6.27) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:40 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQS006164;
Thu, 23 Dec 2021 13:16:37 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 05/14] media: cadence: csi2rx: Soft reset the streams
before starting capture
Date: Fri, 24 Dec 2021 00:46:06 +0530
Message-ID: <20211223191615.17803-6-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
This resets the stream state machines and FIFOs, giving them a clean
slate. On J721E if the streams are not reset before starting the
capture, the captured frame gets wrapped around vertically on every run
after the first.
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- Make i unsigned.
- Add Laurent's R-by.
drivers/media/platform/cadence/cdns-csi2rx.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index afd4a0da8235..baf8ec649a25 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -39,6 +39,7 @@
#define CSI2RX_STREAM_BASE(n) (((n) + 1) * 0x100)
#define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000)
+#define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4)
#define CSI2RX_STREAM_CTRL_START BIT(0)
#define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008)
@@ -135,12 +136,22 @@ struct csi2rx_priv *v4l2_subdev_to_csi2rx(struct v4l2_subdev *subdev)
static void csi2rx_reset(struct csi2rx_priv *csi2rx)
{
+ unsigned int i;
+
writel(CSI2RX_SOFT_RESET_PROTOCOL | CSI2RX_SOFT_RESET_FRONT,
csi2rx->base + CSI2RX_SOFT_RESET_REG);
udelay(10);
writel(0, csi2rx->base + CSI2RX_SOFT_RESET_REG);
+
+ /* Reset individual streams. */
+ for (i = 0; i < csi2rx->max_streams; i++) {
+ writel(CSI2RX_STREAM_CTRL_SOFT_RST,
+ csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
+ usleep_range(10, 20);
+ writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
+ }
}
static int csi2rx_configure_external_dphy(struct csi2rx_priv *csi2rx)
From patchwork Thu Dec 23 19:16:07 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527607
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 3A01AC433FE
for ; Thu, 23 Dec 2021 19:16:53 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1349998AbhLWTQv (ORCPT );
Thu, 23 Dec 2021 14:16:51 -0500
Received: from lelv0142.ext.ti.com ([198.47.23.249]:47578 "EHLO
lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1349965AbhLWTQu (ORCPT
);
Thu, 23 Dec 2021 14:16:50 -0500
Received: from fllv0034.itg.ti.com ([10.64.40.246])
by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGjL9029367;
Thu, 23 Dec 2021 13:16:45 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640287005;
bh=hugen2iF9pOeMe2j/Up7HEzH64lhEKNpA6zbe/IDWdY=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=cX4J+0PjZsvPnFONO2i7b4MWXWd6qkloDWMKEm9FPXs3u9i3eUTC4qKY1oMcVuUZ6
70HXpVrg0arUWRxt0y8Ut+zyaH7ww3A152z2j+n63v5QbIBK4kbiXyPu8Zzl2KsYsu
vtKIws/1eD/dTihuv0ft6rNxl9g8yyocZuZPd5YA=
Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41])
by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGjBf006692
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:45 -0600
Received: from DLEE114.ent.ti.com (157.170.170.25) by DLEE109.ent.ti.com
(157.170.170.41) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:44 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE114.ent.ti.com
(157.170.170.25) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:44 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQT006164;
Thu, 23 Dec 2021 13:16:41 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 06/14] media: cadence: csi2rx: Set the STOP bit when
stopping a stream
Date: Fri, 24 Dec 2021 00:46:07 +0530
Message-ID: <20211223191615.17803-7-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
The stream stop procedure says that the STOP bit should be set when the
stream is to be stopped, and then the ready bit in stream status
register polled to make sure the STOP operation is finished.
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- Change %d to %u
- Add Laurent's R-by.
drivers/media/platform/cadence/cdns-csi2rx.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index baf8ec649a25..86546074c555 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -40,8 +41,12 @@
#define CSI2RX_STREAM_CTRL_REG(n) (CSI2RX_STREAM_BASE(n) + 0x000)
#define CSI2RX_STREAM_CTRL_SOFT_RST BIT(4)
+#define CSI2RX_STREAM_CTRL_STOP BIT(1)
#define CSI2RX_STREAM_CTRL_START BIT(0)
+#define CSI2RX_STREAM_STATUS_REG(n) (CSI2RX_STREAM_BASE(n) + 0x004)
+#define CSI2RX_STREAM_STATUS_RDY BIT(31)
+
#define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008)
#define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31)
#define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16)
@@ -312,12 +317,23 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
static void csi2rx_stop(struct csi2rx_priv *csi2rx)
{
unsigned int i;
+ u32 val;
+ int ret;
clk_prepare_enable(csi2rx->p_clk);
clk_disable_unprepare(csi2rx->sys_clk);
for (i = 0; i < csi2rx->max_streams; i++) {
- writel(0, csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
+ writel(CSI2RX_STREAM_CTRL_STOP,
+ csi2rx->base + CSI2RX_STREAM_CTRL_REG(i));
+
+ ret = readl_relaxed_poll_timeout(csi2rx->base +
+ CSI2RX_STREAM_STATUS_REG(i),
+ val,
+ (val & CSI2RX_STREAM_STATUS_RDY),
+ 10, 10000);
+ if (ret)
+ dev_warn(csi2rx->dev, "Failed to stop stream%u\n", i);
clk_disable_unprepare(csi2rx->pixel_clk[i]);
}
From patchwork Thu Dec 23 19:16:08 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527859
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 66372C433EF
for ; Thu, 23 Dec 2021 19:16:56 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1350013AbhLWTQz (ORCPT );
Thu, 23 Dec 2021 14:16:55 -0500
Received: from lelv0143.ext.ti.com ([198.47.23.248]:48612 "EHLO
lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1349977AbhLWTQy (ORCPT
);
Thu, 23 Dec 2021 14:16:54 -0500
Received: from fllv0035.itg.ti.com ([10.64.41.0])
by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGnOu031761;
Thu, 23 Dec 2021 13:16:49 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640287009;
bh=OSQuwq//Vs8MTA0KTE5GLEpuuS5RIXRBdpuQ/dmjfAc=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=A/QhsM4soEf8griv/O1kvFSOHpQwGOjm/SK5QzpGbWUJF6sMninSywXTN/0UsobzZ
Dfw6Oyptidw6FGNLrzIxquz1JpjY2FETC/Jsw5K1RSPWcdya4R6RopDrKmvxLH/77P
lNe+OfQg9f+mkIbMS+LHcdw0dRa6JUgYRo34RxCE=
Received: from DLEE107.ent.ti.com (dlee107.ent.ti.com [157.170.170.37])
by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGn3F018311
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:49 -0600
Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE107.ent.ti.com
(157.170.170.37) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:48 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE107.ent.ti.com
(157.170.170.37) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:48 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQU006164;
Thu, 23 Dec 2021 13:16:45 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 07/14] media: cadence: csi2rx: Fix stream data configuration
Date: Fri, 24 Dec 2021 00:46:08 +0530
Message-ID: <20211223191615.17803-8-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
Firstly, there is no VC_EN bit present in the STREAM_DATA_CFG register.
Bit 31 is part of the VL_SELECT field. Remove it completely.
Secondly, it makes little sense to enable ith virtual channel for ith
stream. Sure, there might be a use-case that demands it. But there might
also be a use case that demands all streams to use the 0th virtual
channel. Prefer this case over the former because it is less arbitrary
and also makes it very clear what the limitations of the current driver
is instead of giving a false impression that multiple virtual channels
are supported.
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
(no changes since v1)
drivers/media/platform/cadence/cdns-csi2rx.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 86546074c555..e3ce0bfdd96e 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -48,7 +48,6 @@
#define CSI2RX_STREAM_STATUS_RDY BIT(31)
#define CSI2RX_STREAM_DATA_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x008)
-#define CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT BIT(31)
#define CSI2RX_STREAM_DATA_CFG_VC_SELECT(n) BIT((n) + 16)
#define CSI2RX_STREAM_CFG_REG(n) (CSI2RX_STREAM_BASE(n) + 0x00c)
@@ -277,8 +276,11 @@ static int csi2rx_start(struct csi2rx_priv *csi2rx)
writel(CSI2RX_STREAM_CFG_FIFO_MODE_LARGE_BUF,
csi2rx->base + CSI2RX_STREAM_CFG_REG(i));
- writel(CSI2RX_STREAM_DATA_CFG_EN_VC_SELECT |
- CSI2RX_STREAM_DATA_CFG_VC_SELECT(i),
+ /*
+ * Enable one virtual channel. When multiple virtual channels
+ * are supported this will have to be changed.
+ */
+ writel(CSI2RX_STREAM_DATA_CFG_VC_SELECT(0),
csi2rx->base + CSI2RX_STREAM_DATA_CFG_REG(i));
writel(CSI2RX_STREAM_CTRL_START,
From patchwork Thu Dec 23 19:16:09 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527606
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 30B74C433FE
for ; Thu, 23 Dec 2021 19:17:01 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1350046AbhLWTRA (ORCPT );
Thu, 23 Dec 2021 14:17:00 -0500
Received: from fllv0016.ext.ti.com ([198.47.19.142]:51910 "EHLO
fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1350008AbhLWTQ5 (ORCPT
);
Thu, 23 Dec 2021 14:16:57 -0500
Received: from fllv0035.itg.ti.com ([10.64.41.0])
by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGqGY116966;
Thu, 23 Dec 2021 13:16:52 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640287013;
bh=nSdE39BmQIXaUe8GpgYvwzsFw/+qhUpe/lON1AWbi1c=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=m+hVa7kBo4VE9UTM5PGiHWUEk3DzN+/Qx0GA86FjgIZtYFDqKHF5MWSCs5FXrmtia
ogUc69gZbyH+UWxSSKVsnvhRxWhiMcSYkKgD/oIGniYN3xGvuiqtKoulZNA6OEL5Z2
t2tD2ejLl1F6WW3MQHPTy6ayX6GcZDe+eijZojis=
Received: from DFLE106.ent.ti.com (dfle106.ent.ti.com [10.64.6.27])
by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGq5a018344
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:52 -0600
Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE106.ent.ti.com
(10.64.6.27) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:52 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE101.ent.ti.com
(10.64.6.22) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:52 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQV006164;
Thu, 23 Dec 2021 13:16:49 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 08/14] media: cadence: csi2rx: Populate subdev devnode
Date: Fri, 24 Dec 2021 00:46:09 +0530
Message-ID: <20211223191615.17803-9-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
The devnode can be used by media-ctl and other userspace tools to
perform configurations on the subdev. Without it, media-ctl returns
ENOENT when setting format on the sensor subdev.
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- Add Laurent's R-by.
Changes in v2:
- New in v2.
drivers/media/platform/cadence/cdns-csi2rx.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index e3ce0bfdd96e..53659776a906 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -690,6 +690,7 @@ static int csi2rx_probe(struct platform_device *pdev)
csi2rx->pads[CSI2RX_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++)
csi2rx->pads[i].flags = MEDIA_PAD_FL_SOURCE;
+ csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX,
csi2rx->pads);
From patchwork Thu Dec 23 19:16:10 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527858
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 4A0E6C433FE
for ; Thu, 23 Dec 2021 19:17:07 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1350069AbhLWTRD (ORCPT );
Thu, 23 Dec 2021 14:17:03 -0500
Received: from lelv0142.ext.ti.com ([198.47.23.249]:47606 "EHLO
lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1350051AbhLWTRB (ORCPT
);
Thu, 23 Dec 2021 14:17:01 -0500
Received: from lelv0265.itg.ti.com ([10.180.67.224])
by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGuYu029389;
Thu, 23 Dec 2021 13:16:56 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640287017;
bh=GhdMeUU0MDNpTPESfpgGY/7A/kMeZbWC9DeYjW298TE=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=LqiNrsq50A6dsAf8+k1dpyOVvQM4YtGEsm3fas445CexTLQTT2XKeYjO1ELVnqYeK
Bra6CXOcNY7+3y40y9e45+c1A3DSKf6I15bMCd/6JysEdUVt/nVsLIiR4EV++rcsxh
ilBtizhtjyrnxO4Z72KA6DFGngIlDpLxfhZw8Xi8=
Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33])
by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJGusd079999
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:16:56 -0600
Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE112.ent.ti.com
(10.64.6.33) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:16:56 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE114.ent.ti.com
(10.64.6.35) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:16:56 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQW006164;
Thu, 23 Dec 2021 13:16:53 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 09/14] media: cadence: csi2rx: Add link validation
Date: Fri, 24 Dec 2021 00:46:10 +0530
Message-ID: <20211223191615.17803-10-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
Add media link validation to make sure incorrectly configured pipelines
are caught. Since there is no support for transcoding, rely on the
default link validation function to make sure formats across source and
sink pads are the same.
Signed-off-by: Pratyush Yadav
Reviewed-by: Laurent Pinchart
---
Changes in v5:
- New in v5.
drivers/media/platform/cadence/cdns-csi2rx.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index 53659776a906..119c7540c75a 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -492,6 +492,10 @@ static const struct v4l2_subdev_ops csi2rx_subdev_ops = {
.pad = &csi2rx_pad_ops,
};
+static struct media_entity_operations csi2rx_media_ops = {
+ .link_validate = v4l2_subdev_link_validate,
+};
+
static int csi2rx_async_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *s_subdev,
struct v4l2_async_subdev *asd)
@@ -691,6 +695,7 @@ static int csi2rx_probe(struct platform_device *pdev)
for (i = CSI2RX_PAD_SOURCE_STREAM0; i < CSI2RX_PAD_MAX; i++)
csi2rx->pads[i].flags = MEDIA_PAD_FL_SOURCE;
csi2rx->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ csi2rx->subdev.entity.ops = &csi2rx_media_ops;
ret = media_entity_pads_init(&csi2rx->subdev.entity, CSI2RX_PAD_MAX,
csi2rx->pads);
From patchwork Thu Dec 23 19:16:11 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527857
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 A01F9C433EF
for ; Thu, 23 Dec 2021 19:17:13 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1350080AbhLWTRM (ORCPT );
Thu, 23 Dec 2021 14:17:12 -0500
Received: from fllv0016.ext.ti.com ([198.47.19.142]:51924 "EHLO
fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1350078AbhLWTRF (ORCPT
);
Thu, 23 Dec 2021 14:17:05 -0500
Received: from lelv0265.itg.ti.com ([10.180.67.224])
by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJH0Ja116980;
Thu, 23 Dec 2021 13:17:00 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640287020;
bh=QIRk9ky66i0l/47EYbX9zuqS4WVNoPhKK5v5XZuiyGw=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=UB4f+nQRt46l2i4IlL15do+2CDPxJgtsB1kk2Pi2Dd1UM108qQxjELtMbwKAZXKBc
IE90Oe/heSEgeUUT92XU41mZMVqhdqRtrz9ustFSSkAhuAPTRyt4U1OshlSgby4zRi
37Fm63yzgB7OkFm6eHTLXwNndbD99CTxoQhM9lp8=
Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36])
by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJH0H2080048
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:17:00 -0600
Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE115.ent.ti.com
(10.64.6.36) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:17:00 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE103.ent.ti.com
(10.64.6.24) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:17:00 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQX006164;
Thu, 23 Dec 2021 13:16:57 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring ,
Sakari Ailus , =?utf-8?q?Niklas_S=C3=B6derlun?=
=?utf-8?q?d?= ,
, ,
Subject: [PATCH v5 10/14] media: Re-structure TI platform drivers
Date: Fri, 24 Dec 2021 00:46:11 +0530
Message-ID: <20211223191615.17803-11-p.yadav@ti.com>
X-Mailer: git-send-email 2.33.1.835.ge9e5ba39a7
In-Reply-To: <20211223191615.17803-1-p.yadav@ti.com>
References: <20211223191615.17803-1-p.yadav@ti.com>
MIME-Version: 1.0
X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180
Precedence: bulk
List-ID:
X-Mailing-List: linux-media@vger.kernel.org
The ti-vpe/ sub-directory does not only contain the VPE-specific things.
It also contains the CAL driver, which is a completely different
subsystem. This is also not a good place to add new drivers for other TI
platforms since they will all get mixed up.
Separate the VPE and CAL parts into different sub-directories and rename
the ti-vpe/ sub-directory to ti/. This is now the place where new TI
platform drivers can be added.
Signed-off-by: Pratyush Yadav
Reviewed-by: Tomi Valkeinen
Reviewed-by: Laurent Pinchart
---
Compile tested only. There should be no functional change.
Changes in v5:
- Add Laurent's R-by.
Changes in v3:
- Add Tomi's R-by.
Changes in v2:
- New in v2.
MAINTAINERS | 3 ++-
drivers/media/platform/Makefile | 2 +-
drivers/media/platform/ti/Makefile | 3 +++
drivers/media/platform/ti/cal/Makefile | 3 +++
drivers/media/platform/{ti-vpe => ti/cal}/cal-camerarx.c | 0
drivers/media/platform/{ti-vpe => ti/cal}/cal-video.c | 0
drivers/media/platform/{ti-vpe => ti/cal}/cal.c | 0
drivers/media/platform/{ti-vpe => ti/cal}/cal.h | 0
drivers/media/platform/{ti-vpe => ti/cal}/cal_regs.h | 0
drivers/media/platform/{ti-vpe => ti/vpe}/Makefile | 4 ----
drivers/media/platform/{ti-vpe => ti/vpe}/csc.c | 0
drivers/media/platform/{ti-vpe => ti/vpe}/csc.h | 0
drivers/media/platform/{ti-vpe => ti/vpe}/sc.c | 0
drivers/media/platform/{ti-vpe => ti/vpe}/sc.h | 0
drivers/media/platform/{ti-vpe => ti/vpe}/sc_coeff.h | 0
drivers/media/platform/{ti-vpe => ti/vpe}/vpdma.c | 0
drivers/media/platform/{ti-vpe => ti/vpe}/vpdma.h | 0
drivers/media/platform/{ti-vpe => ti/vpe}/vpdma_priv.h | 0
drivers/media/platform/{ti-vpe => ti/vpe}/vpe.c | 0
drivers/media/platform/{ti-vpe => ti/vpe}/vpe_regs.h | 0
20 files changed, 9 insertions(+), 6 deletions(-)
create mode 100644 drivers/media/platform/ti/Makefile
create mode 100644 drivers/media/platform/ti/cal/Makefile
rename drivers/media/platform/{ti-vpe => ti/cal}/cal-camerarx.c (100%)
rename drivers/media/platform/{ti-vpe => ti/cal}/cal-video.c (100%)
rename drivers/media/platform/{ti-vpe => ti/cal}/cal.c (100%)
rename drivers/media/platform/{ti-vpe => ti/cal}/cal.h (100%)
rename drivers/media/platform/{ti-vpe => ti/cal}/cal_regs.h (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/Makefile (78%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/csc.c (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/csc.h (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/sc.c (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/sc.h (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/sc_coeff.h (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/vpdma.c (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/vpdma.h (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/vpdma_priv.h (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/vpe.c (100%)
rename drivers/media/platform/{ti-vpe => ti/vpe}/vpe_regs.h (100%)
diff --git a/MAINTAINERS b/MAINTAINERS
index 16bc8cdc1492..3b8fa4e5047f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -19299,7 +19299,8 @@ W: http://linuxtv.org/
Q: http://patchwork.linuxtv.org/project/linux-media/list/
F: Documentation/devicetree/bindings/media/ti,cal.yaml
F: Documentation/devicetree/bindings/media/ti,vpe.yaml
-F: drivers/media/platform/ti-vpe/
+F: drivers/media/platform/ti/cal/
+F: drivers/media/platform/ti/vpe/
TI WILINK WIRELESS DRIVERS
L: linux-wireless@vger.kernel.org
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 19bcbced7382..ba9405ab2490 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -15,7 +15,7 @@ obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o
obj-$(CONFIG_VIDEO_VIU) += fsl-viu.o
-obj-y += ti-vpe/
+obj-y += ti/
obj-$(CONFIG_VIDEO_MX2_EMMAPRP) += mx2_emmaprp.o
obj-$(CONFIG_VIDEO_CODA) += coda/
diff --git a/drivers/media/platform/ti/Makefile b/drivers/media/platform/ti/Makefile
new file mode 100644
index 000000000000..bbc737ccbbea
--- /dev/null
+++ b/drivers/media/platform/ti/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-y += cal/
+obj-y += vpe/
diff --git a/drivers/media/platform/ti/cal/Makefile b/drivers/media/platform/ti/cal/Makefile
new file mode 100644
index 000000000000..45ac35585f0b
--- /dev/null
+++ b/drivers/media/platform/ti/cal/Makefile
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_VIDEO_TI_CAL) += ti-cal.o
+ti-cal-y := cal.o cal-camerarx.o cal-video.o
diff --git a/drivers/media/platform/ti-vpe/cal-camerarx.c b/drivers/media/platform/ti/cal/cal-camerarx.c
similarity index 100%
rename from drivers/media/platform/ti-vpe/cal-camerarx.c
rename to drivers/media/platform/ti/cal/cal-camerarx.c
diff --git a/drivers/media/platform/ti-vpe/cal-video.c b/drivers/media/platform/ti/cal/cal-video.c
similarity index 100%
rename from drivers/media/platform/ti-vpe/cal-video.c
rename to drivers/media/platform/ti/cal/cal-video.c
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti/cal/cal.c
similarity index 100%
rename from drivers/media/platform/ti-vpe/cal.c
rename to drivers/media/platform/ti/cal/cal.c
diff --git a/drivers/media/platform/ti-vpe/cal.h b/drivers/media/platform/ti/cal/cal.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/cal.h
rename to drivers/media/platform/ti/cal/cal.h
diff --git a/drivers/media/platform/ti-vpe/cal_regs.h b/drivers/media/platform/ti/cal/cal_regs.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/cal_regs.h
rename to drivers/media/platform/ti/cal/cal_regs.h
diff --git a/drivers/media/platform/ti-vpe/Makefile b/drivers/media/platform/ti/vpe/Makefile
similarity index 78%
rename from drivers/media/platform/ti-vpe/Makefile
rename to drivers/media/platform/ti/vpe/Makefile
index ad624056e039..3fadfe084f87 100644
--- a/drivers/media/platform/ti-vpe/Makefile
+++ b/drivers/media/platform/ti/vpe/Makefile
@@ -10,7 +10,3 @@ ti-sc-y := sc.o
ti-csc-y := csc.o
ccflags-$(CONFIG_VIDEO_TI_VPE_DEBUG) += -DDEBUG
-
-obj-$(CONFIG_VIDEO_TI_CAL) += ti-cal.o
-
-ti-cal-y := cal.o cal-camerarx.o cal-video.o
diff --git a/drivers/media/platform/ti-vpe/csc.c b/drivers/media/platform/ti/vpe/csc.c
similarity index 100%
rename from drivers/media/platform/ti-vpe/csc.c
rename to drivers/media/platform/ti/vpe/csc.c
diff --git a/drivers/media/platform/ti-vpe/csc.h b/drivers/media/platform/ti/vpe/csc.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/csc.h
rename to drivers/media/platform/ti/vpe/csc.h
diff --git a/drivers/media/platform/ti-vpe/sc.c b/drivers/media/platform/ti/vpe/sc.c
similarity index 100%
rename from drivers/media/platform/ti-vpe/sc.c
rename to drivers/media/platform/ti/vpe/sc.c
diff --git a/drivers/media/platform/ti-vpe/sc.h b/drivers/media/platform/ti/vpe/sc.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/sc.h
rename to drivers/media/platform/ti/vpe/sc.h
diff --git a/drivers/media/platform/ti-vpe/sc_coeff.h b/drivers/media/platform/ti/vpe/sc_coeff.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/sc_coeff.h
rename to drivers/media/platform/ti/vpe/sc_coeff.h
diff --git a/drivers/media/platform/ti-vpe/vpdma.c b/drivers/media/platform/ti/vpe/vpdma.c
similarity index 100%
rename from drivers/media/platform/ti-vpe/vpdma.c
rename to drivers/media/platform/ti/vpe/vpdma.c
diff --git a/drivers/media/platform/ti-vpe/vpdma.h b/drivers/media/platform/ti/vpe/vpdma.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/vpdma.h
rename to drivers/media/platform/ti/vpe/vpdma.h
diff --git a/drivers/media/platform/ti-vpe/vpdma_priv.h b/drivers/media/platform/ti/vpe/vpdma_priv.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/vpdma_priv.h
rename to drivers/media/platform/ti/vpe/vpdma_priv.h
diff --git a/drivers/media/platform/ti-vpe/vpe.c b/drivers/media/platform/ti/vpe/vpe.c
similarity index 100%
rename from drivers/media/platform/ti-vpe/vpe.c
rename to drivers/media/platform/ti/vpe/vpe.c
diff --git a/drivers/media/platform/ti-vpe/vpe_regs.h b/drivers/media/platform/ti/vpe/vpe_regs.h
similarity index 100%
rename from drivers/media/platform/ti-vpe/vpe_regs.h
rename to drivers/media/platform/ti/vpe/vpe_regs.h
From patchwork Thu Dec 23 19:16:12 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pratyush Yadav
X-Patchwork-Id: 527603
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 D8BB8C4332F
for ; Thu, 23 Dec 2021 19:17:26 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S1350102AbhLWTRW (ORCPT );
Thu, 23 Dec 2021 14:17:22 -0500
Received: from fllv0015.ext.ti.com ([198.47.19.141]:39040 "EHLO
fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S1350007AbhLWTRS (ORCPT
);
Thu, 23 Dec 2021 14:17:18 -0500
Received: from fllv0035.itg.ti.com ([10.64.41.0])
by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJH5SW129020;
Thu, 23 Dec 2021 13:17:05 -0600
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com;
s=ti-com-17Q1; t=1640287025;
bh=08noh/w35pjirv+jUsyNsL1gfviar0kXzKrye0AQtGY=;
h=From:To:CC:Subject:Date:In-Reply-To:References;
b=nitIGb/5ujNScdBhbqYmzKhmaEyrLtycAG5rB182m/FK/2q095bm+QJmIDIOUOH9H
wLp46o7JhvXQPhyT1T+3A6wImvKnMSWMBM6s2acEMBxeDXAwHTvfupJUuKSwnlsmHB
O1iCm4ALXqyY8E+MdRxJxrX1OvmK0XlUoVq9NCqA=
Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36])
by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 1BNJH58c019049
(version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL);
Thu, 23 Dec 2021 13:17:05 -0600
Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE115.ent.ti.com
(10.64.6.36) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Thu, 23
Dec 2021 13:17:04 -0600
Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE114.ent.ti.com
(10.64.6.35) with Microsoft SMTP Server (version=TLS1_2,
cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via
Frontend Transport; Thu, 23 Dec 2021 13:17:04 -0600
Received: from pratyush-OptiPlex-790.dhcp.ti.com (ileax41-snat.itg.ti.com
[10.172.224.153])
by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 1BNJGGQY006164;
Thu, 23 Dec 2021 13:17:01 -0600
From: Pratyush Yadav
To: Mauro Carvalho Chehab
CC: Pratyush Yadav ,
Laurent Pinchart ,
Nikhil Devshatwar ,
Tomi Valkeinen ,
Vignesh Raghavendra , Benoit Parrot ,
Maxime Ripard , Rob Herring