public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Daniel Scally <dan.scally@ideasonboard.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Andy Shevchenko <andy@kernel.org>, Kate Hsuan <hpa@redhat.com>,
	Hao Yao <hao.yao@intel.com>, Bingbu Cao <bingbu.cao@intel.com>,
	linux-media@vger.kernel.org
Subject: [PATCH 08/12] media: ipu3-cio2: Add supported_sensors parameter to cio2_bridge_init()
Date: Tue, 27 Jun 2023 19:56:38 +0200	[thread overview]
Message-ID: <20230627175643.114778-9-hdegoede@redhat.com> (raw)
In-Reply-To: <20230627175643.114778-1-hdegoede@redhat.com>

Add a supported_sensors parameter to cio2_bridge_init(), so that
cio2_bridge_init() can be used with other bridges which have been
tested with / support a different set of sensors.

This is a preparation patch for making the cio2-bridge code more generic
so that it can be shared with the atomisp driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 22 +++++++++++++---------
 drivers/media/pci/intel/ipu3/cio2-bridge.h |  1 +
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
index b799053f4934..9da0f003af7b 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
@@ -36,6 +36,7 @@ static const struct cio2_sensor_config cio2_supported_sensors[] = {
 	CIO2_SENSOR_CONFIG("INT3537", 1, 437000000),
 	/* Omnivision ov13b10 */
 	CIO2_SENSOR_CONFIG("OVTIDB10", 1, 560000000),
+	{}
 };
 
 static const struct cio2_property_names prop_names = {
@@ -393,9 +394,9 @@ static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge)
 	unsigned int i;
 	int ret;
 
-	for (i = 0; i < ARRAY_SIZE(cio2_supported_sensors); i++) {
+	for (i = 0; bridge->supported_sensors[i].hid; i++) {
 		const struct cio2_sensor_config *cfg =
-			&cio2_supported_sensors[i];
+			&bridge->supported_sensors[i];
 
 		ret = cio2_bridge_connect_sensor(cfg, bridge);
 		if (ret)
@@ -421,15 +422,15 @@ static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge)
  * acpi_dev_ready_for_enumeration() helper, like the i2c-core-acpi code does
  * for the sensors.
  */
-static int cio2_bridge_sensors_are_ready(void)
+static int cio2_bridge_sensors_are_ready(
+	const struct cio2_sensor_config *supported_sensors)
 {
 	struct acpi_device *adev;
 	bool ready = true;
 	unsigned int i;
 
-	for (i = 0; i < ARRAY_SIZE(cio2_supported_sensors); i++) {
-		const struct cio2_sensor_config *cfg =
-			&cio2_supported_sensors[i];
+	for (i = 0; supported_sensors[i].hid; i++) {
+		const struct cio2_sensor_config *cfg = &supported_sensors[i];
 
 		for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
 			if (!adev->status.enabled)
@@ -447,14 +448,15 @@ static int __cio2_bridge_init(
 	struct device *dev,
 	int (*parse_sensor_fwnode)(struct acpi_device *adev,
 				   struct cio2_sensor *sensor,
-				   const struct cio2_sensor_config *cfg))
+				   const struct cio2_sensor_config *cfg),
+	const struct cio2_sensor_config *supported_sensors)
 {
 	struct fwnode_handle *fwnode;
 	struct cio2_bridge *bridge;
 	unsigned int i;
 	int ret;
 
-	if (!cio2_bridge_sensors_are_ready())
+	if (!cio2_bridge_sensors_are_ready(supported_sensors))
 		return -EPROBE_DEFER;
 
 	bridge = kzalloc(sizeof(*bridge), GFP_KERNEL);
@@ -466,6 +468,7 @@ static int __cio2_bridge_init(
 	bridge->cio2_hid_node.name = bridge->cio2_node_name;
 	bridge->dev = dev;
 	bridge->parse_sensor_fwnode = parse_sensor_fwnode;
+	bridge->supported_sensors = supported_sensors;
 
 	ret = software_node_register(&bridge->cio2_hid_node);
 	if (ret < 0) {
@@ -512,5 +515,6 @@ static int __cio2_bridge_init(
 
 int cio2_bridge_init(struct device *dev)
 {
-	return __cio2_bridge_init(dev, cio2_bridge_parse_sensor_fwnode);
+	return __cio2_bridge_init(dev, cio2_bridge_parse_sensor_fwnode,
+				  cio2_supported_sensors);
 }
diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h
index b596fae2dc1b..e646cb17ab20 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.h
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h
@@ -145,6 +145,7 @@ struct cio2_bridge {
 	int (*parse_sensor_fwnode)(struct acpi_device *adev,
 				   struct cio2_sensor *sensor,
 				   const struct cio2_sensor_config *cfg);
+	const struct cio2_sensor_config *supported_sensors;
 	char cio2_node_name[ACPI_ID_LEN];
 	struct software_node cio2_hid_node;
 	u32 data_lanes[4];
-- 
2.41.0


  parent reply	other threads:[~2023-06-27 17:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 17:56 [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2-bridge code, rework VCM instantiation Hans de Goede
2023-06-27 17:56 ` [PATCH 01/12] media: ipu3-cio2: Do not use on stack memory for software_node.name field Hans de Goede
2023-06-27 17:56 ` [PATCH 02/12] media: ipu3-cio2: Move initialization of node_names.vcm to cio2_bridge_init_swnode_names() Hans de Goede
2023-06-27 17:56 ` [PATCH 03/12] media: ipu3-cio2: Make cio2_bridge_init() take a regular struct device as argument Hans de Goede
2023-06-27 17:56 ` [PATCH 04/12] media: ipu3-cio2: Store dev pointer in struct cio2_bridge Hans de Goede
2023-06-27 17:56 ` [PATCH 05/12] media: ipu3-cio2: Only keep PLD around while parsing Hans de Goede
2023-06-27 17:56 ` [PATCH 06/12] media: ipu3-cio2: Add a cio2_bridge_parse_sensor_fwnode() helper function Hans de Goede
2023-06-27 20:39   ` Andy Shevchenko
2023-06-27 17:56 ` [PATCH 07/12] media: ipu3-cio2: Add a parse_sensor_fwnode callback to cio2_bridge_init() Hans de Goede
2023-06-27 17:56 ` Hans de Goede [this message]
2023-06-27 17:56 ` [PATCH 09/12] media: ipu3-cio2: Move cio2_bridge_init() code into a new shared intel-cio2-bridge.ko Hans de Goede
2023-06-27 20:55   ` Andy Shevchenko
2023-06-28 12:53     ` Dan Scally
2023-06-27 17:56 ` [PATCH 10/12] media: atomisp: csi2-bridge: Switch to new common cio2_bridge_init() Hans de Goede
2023-06-27 17:56 ` [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor Hans de Goede
2023-06-27 21:03   ` Andy Shevchenko
2023-10-30  8:30   ` Bingbu Cao
2023-10-30  8:55     ` Sakari Ailus
2023-10-30  8:58       ` Hans de Goede
2023-10-30  9:23         ` Sakari Ailus
2023-11-01  6:26           ` Cao, Bingbu
2023-11-01  7:12             ` Sakari Ailus
2023-11-01  7:38               ` Cao, Bingbu
2023-11-02 13:35                 ` Andy Shevchenko
2023-11-02 13:54                   ` Hans de Goede
2023-11-03  2:01                     ` Bingbu Cao
2023-06-27 17:56 ` [PATCH 12/12] [RFC] media: dw9719: Drop hack to enable "vsio" regulator Hans de Goede
2023-06-27 21:04 ` [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2-bridge code, rework VCM instantiation Andy Shevchenko
2023-06-28  1:19 ` Cao, Bingbu
2023-06-28 13:57   ` Hans de Goede
2023-06-29  8:22     ` Cao, Bingbu
2023-06-29 20:45       ` Hans de Goede
2023-06-30  9:07 ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230627175643.114778-9-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@kernel.org \
    --cc=bingbu.cao@intel.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=hao.yao@intel.com \
    --cc=hpa@redhat.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox