Message ID | 20230705213010.390849-11-hdegoede@redhat.com |
---|---|
State | Accepted |
Commit | 998af18082fe4e318bafa090a5f0aaf3c88992d6 |
Headers | show |
Series | media: ipu-bridge: Shared with atomisp, rework VCM instantiation | expand |
On Wed, Jul 05, 2023 at 11:30:02PM +0200, Hans de Goede wrote: > Add a parse_sensor_fwnode() callback to ipu_bridge_init(), so that > ipu_bridge_init() can be used with other sensor fwnode parse functions > then just ipu_bridge_parse_ssdb(). > > This will allow the ipu3-bridge code to also be used by the atomisp > driver. Reviewed-by: Andy Shevchenko <andy@kernel.org> > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > Changes in v3: > - Add ipu_parse_sensor_fwnode_t type for the callback function > --- > drivers/media/pci/intel/ipu-bridge.c | 10 ++++++---- > drivers/media/pci/intel/ipu-bridge.h | 11 +++++++++-- > drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- > 3 files changed, 16 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c > index 1f01f2c8b8a6..db67a75ae1b7 100644 > --- a/drivers/media/pci/intel/ipu-bridge.c > +++ b/drivers/media/pci/intel/ipu-bridge.c > @@ -148,8 +148,7 @@ static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct acpi_dev > return orientation; > } > > -static int ipu_bridge_parse_ssdb(struct acpi_device *adev, > - struct ipu_sensor *sensor) > +int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor) > { > struct ipu_sensor_ssdb ssdb = {}; > int ret; > @@ -179,6 +178,7 @@ static int ipu_bridge_parse_ssdb(struct acpi_device *adev, > > return 0; > } > +EXPORT_SYMBOL_NS_GPL(ipu_bridge_parse_ssdb, INTEL_IPU_BRIDGE); > > static void ipu_bridge_create_fwnode_properties( > struct ipu_sensor *sensor, > @@ -343,7 +343,7 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, > > sensor = &bridge->sensors[bridge->n_sensors]; > > - ret = ipu_bridge_parse_ssdb(adev, sensor); > + ret = bridge->parse_sensor_fwnode(adev, sensor); > if (ret) > goto err_put_adev; > > @@ -441,7 +441,8 @@ static int ipu_bridge_sensors_are_ready(void) > return ready; > } > > -int ipu_bridge_init(struct device *dev) > +int ipu_bridge_init(struct device *dev, > + ipu_parse_sensor_fwnode_t parse_sensor_fwnode) > { > struct fwnode_handle *fwnode; > struct ipu_bridge *bridge; > @@ -459,6 +460,7 @@ int ipu_bridge_init(struct device *dev) > sizeof(bridge->ipu_node_name)); > bridge->ipu_hid_node.name = bridge->ipu_node_name; > bridge->dev = dev; > + bridge->parse_sensor_fwnode = parse_sensor_fwnode; > > ret = software_node_register(&bridge->ipu_hid_node); > if (ret < 0) { > diff --git a/drivers/media/pci/intel/ipu-bridge.h b/drivers/media/pci/intel/ipu-bridge.h > index a8b89c4b95bc..7d84b22b2111 100644 > --- a/drivers/media/pci/intel/ipu-bridge.h > +++ b/drivers/media/pci/intel/ipu-bridge.h > @@ -140,8 +140,12 @@ struct ipu_sensor { > struct software_node_ref_args vcm_ref[1]; > }; > > +typedef int (*ipu_parse_sensor_fwnode_t)(struct acpi_device *adev, > + struct ipu_sensor *sensor); > + > struct ipu_bridge { > struct device *dev; > + ipu_parse_sensor_fwnode_t parse_sensor_fwnode; > char ipu_node_name[ACPI_ID_LEN]; > struct software_node ipu_hid_node; > u32 data_lanes[4]; > @@ -150,9 +154,12 @@ struct ipu_bridge { > }; > > #if IS_ENABLED(CONFIG_IPU_BRIDGE) > -int ipu_bridge_init(struct device *dev); > +int ipu_bridge_init(struct device *dev, > + ipu_parse_sensor_fwnode_t parse_sensor_fwnode); > +int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor); > #else > -static inline int ipu_bridge_init(struct device *dev) { return 0; } > +/* Use a define to avoid the @parse_sensor_fwnode argument getting evaluated */ > +#define ipu_bridge_init(dev, parse_sensor_fwnode) (0) > #endif > > #endif > diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > index 4068fa0a5ecf..26c4c1375990 100644 > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > @@ -1725,7 +1725,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, > return -EINVAL; > } > > - r = ipu_bridge_init(dev); > + r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb); > if (r) > return r; > } > -- > 2.41.0 >
diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c index 1f01f2c8b8a6..db67a75ae1b7 100644 --- a/drivers/media/pci/intel/ipu-bridge.c +++ b/drivers/media/pci/intel/ipu-bridge.c @@ -148,8 +148,7 @@ static enum v4l2_fwnode_orientation ipu_bridge_parse_orientation(struct acpi_dev return orientation; } -static int ipu_bridge_parse_ssdb(struct acpi_device *adev, - struct ipu_sensor *sensor) +int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor) { struct ipu_sensor_ssdb ssdb = {}; int ret; @@ -179,6 +178,7 @@ static int ipu_bridge_parse_ssdb(struct acpi_device *adev, return 0; } +EXPORT_SYMBOL_NS_GPL(ipu_bridge_parse_ssdb, INTEL_IPU_BRIDGE); static void ipu_bridge_create_fwnode_properties( struct ipu_sensor *sensor, @@ -343,7 +343,7 @@ static int ipu_bridge_connect_sensor(const struct ipu_sensor_config *cfg, sensor = &bridge->sensors[bridge->n_sensors]; - ret = ipu_bridge_parse_ssdb(adev, sensor); + ret = bridge->parse_sensor_fwnode(adev, sensor); if (ret) goto err_put_adev; @@ -441,7 +441,8 @@ static int ipu_bridge_sensors_are_ready(void) return ready; } -int ipu_bridge_init(struct device *dev) +int ipu_bridge_init(struct device *dev, + ipu_parse_sensor_fwnode_t parse_sensor_fwnode) { struct fwnode_handle *fwnode; struct ipu_bridge *bridge; @@ -459,6 +460,7 @@ int ipu_bridge_init(struct device *dev) sizeof(bridge->ipu_node_name)); bridge->ipu_hid_node.name = bridge->ipu_node_name; bridge->dev = dev; + bridge->parse_sensor_fwnode = parse_sensor_fwnode; ret = software_node_register(&bridge->ipu_hid_node); if (ret < 0) { diff --git a/drivers/media/pci/intel/ipu-bridge.h b/drivers/media/pci/intel/ipu-bridge.h index a8b89c4b95bc..7d84b22b2111 100644 --- a/drivers/media/pci/intel/ipu-bridge.h +++ b/drivers/media/pci/intel/ipu-bridge.h @@ -140,8 +140,12 @@ struct ipu_sensor { struct software_node_ref_args vcm_ref[1]; }; +typedef int (*ipu_parse_sensor_fwnode_t)(struct acpi_device *adev, + struct ipu_sensor *sensor); + struct ipu_bridge { struct device *dev; + ipu_parse_sensor_fwnode_t parse_sensor_fwnode; char ipu_node_name[ACPI_ID_LEN]; struct software_node ipu_hid_node; u32 data_lanes[4]; @@ -150,9 +154,12 @@ struct ipu_bridge { }; #if IS_ENABLED(CONFIG_IPU_BRIDGE) -int ipu_bridge_init(struct device *dev); +int ipu_bridge_init(struct device *dev, + ipu_parse_sensor_fwnode_t parse_sensor_fwnode); +int ipu_bridge_parse_ssdb(struct acpi_device *adev, struct ipu_sensor *sensor); #else -static inline int ipu_bridge_init(struct device *dev) { return 0; } +/* Use a define to avoid the @parse_sensor_fwnode argument getting evaluated */ +#define ipu_bridge_init(dev, parse_sensor_fwnode) (0) #endif #endif diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 4068fa0a5ecf..26c4c1375990 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -1725,7 +1725,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, return -EINVAL; } - r = ipu_bridge_init(dev); + r = ipu_bridge_init(dev, ipu_bridge_parse_ssdb); if (r) return r; }
Add a parse_sensor_fwnode() callback to ipu_bridge_init(), so that ipu_bridge_init() can be used with other sensor fwnode parse functions then just ipu_bridge_parse_ssdb(). This will allow the ipu3-bridge code to also be used by the atomisp driver. Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- Changes in v3: - Add ipu_parse_sensor_fwnode_t type for the callback function --- drivers/media/pci/intel/ipu-bridge.c | 10 ++++++---- drivers/media/pci/intel/ipu-bridge.h | 11 +++++++++-- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-)