media: intel-cio2-bridge: Add shared intel-cio2-bridge code, rework VCM instantiation
Subsystems (7)
cover media: intel-cio2-bridge: Add shared intel-cio2-bridge code, rework VCM instantiation
Hi All,
While working on adding (proper) VCM support to the atomisp code I found myself copying yet more code from drivers/media/pci/intel/ipu3/cio2-bridge.c into the atomisp code.
So I decided that it really was time to factor out the common code (most of the code) from intel/ipu3/cio2-bridge.c into its own helper library and then share it between the atomisp and IPU3 code.
This will hopefully also be useful for the ongoing work to upstream IPU6 input system support which also needs this functionality and currently contains a 3th copy of this code in the out of tree driver.
This set consists of the following parts:
Patch 1 A bugfix for a recent change to the cio2-bridge code
Patches 2-8 Cleanup / preparation patches
Patch 9 Move the main body of the cio2-bridge.c code into
a new shared intel-cio2-bridge module
Patch 10 Drop cio2-bridge code copy from atomisp, switching to
the shared intel-cio2-bridge module
Patch 11 Rework how VCM client instantiation is done so that
a device-link can be added from VCM to sensor to fix issues with the VCM power-state being tied to the sensor power state
Patch 12 Example patch to show how patch 11 avoids the need
for hacks in VCM drivers caused by the shared power state (not intended for merging)
Regards,
Hans
Hans de Goede (12):
media: ipu3-cio2: Do not use on stack memory for software_node.name
field
media: ipu3-cio2: Move initialization of node_names.vcm to
cio2_bridge_init_swnode_names()
media: ipu3-cio2: Make cio2_bridge_init() take a regular struct device
as argument
media: ipu3-cio2: Store dev pointer in struct cio2_bridge
media: ipu3-cio2: Only keep PLD around while parsing
media: ipu3-cio2: Add a cio2_bridge_parse_sensor_fwnode() helper
function
media: ipu3-cio2: Add a parse_sensor_fwnode callback to
cio2_bridge_init()
media: ipu3-cio2: Add supported_sensors parameter to
cio2_bridge_init() media: ipu3-cio2: Move cio2_bridge_init() code into a new shared
intel-cio2-bridge.ko
media: atomisp: csi2-bridge: Switch to new common cio2_bridge_init()
media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and
sensor
[RFC] media: dw9719: Drop hack to enable "vsio" regulator
MAINTAINERS | 9 + drivers/media/common/Kconfig | 4 + drivers/media/common/Makefile | 1 + drivers/media/common/intel-cio2-bridge.c | 464 ++++++++++++++++++ drivers/media/i2c/dw9719.c | 27 +- drivers/media/pci/intel/ipu3/Kconfig | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 464 +++--------------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 146 ------ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 7 +- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 7 +- drivers/staging/media/atomisp/Kconfig | 2 + .../staging/media/atomisp/pci/atomisp_csi2.h | 67 --- .../media/atomisp/pci/atomisp_csi2_bridge.c | 307 ++---------- include/media/intel-cio2-bridge.h | 105 ++++ 14 files changed, 723 insertions(+), 888 deletions(-) create mode 100644 drivers/media/common/intel-cio2-bridge.c delete mode 100644 drivers/media/pci/intel/ipu3/cio2-bridge.h create mode 100644 include/media/intel-cio2-bridge.h
Signature · 1 line
2.41.0
PATCH 1/12 media: ipu3-cio2: Do not use on stack memory for software_node.name field
Commit 567f97bd381f ("media: ipu3-cio2: support multiple sensors and VCMs with same HID") introduced an on stack vcm_name and then uses this for the name field of the software_node struct used for the vcm.
But the software_node struct is much longer lived then the current stack-frame, so this is no good.
Instead extend the cio2_node_names struct with an extra field to store the vcm software_node name and use that.
Note this also changes the length of the allocated buffer from ACPI_ID_LEN + 4 to 16. the name is filled with "<cio2_vcm_types[x]>-%u" where cio2_vcm_types[x] is not an ACPI_ID. The maximum length of the strings in the cio2_vcm_types[] array is 11 + 5 bytes for "-255\0" means 16 bytes are needed in the worst case scenario.
--- drivers/media/pci/intel/ipu3/cio2-bridge.c | 7 +++---- drivers/media/pci/intel/ipu3/cio2-bridge.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +3 -4
@@ -220,7 +220,6 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge, struct cio2_sensor *sensor) {struct software_node *nodes = sensor->swnodes; -char vcm_name[ACPI_ID_LEN +4 ];cio2_bridge_init_swnode_names (sensor);
@@ -240,10 +239,10 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge, sensor->cio2_properties);if (sensor->ssdb.vcmtype) {/* append ssdb.link to distinguish VCM nodes with same HID */ -snprintf (vcm_name,sizeof (vcm_name),"%s-%u" , - cio2_vcm_types[sensor->ssdb.vcmtype -1 ], +snprintf (sensor->node_names.vcm,sizeof (sensor->node_names.vcm), +"%s-%u" , cio2_vcm_types[sensor->ssdb.vcmtype -1 ], sensor->ssdb.link); - nodes[SWNODE_VCM ] =NODE_VCM (vcm_name); + nodes[SWNODE_VCM ] =NODE_VCM (sensor->node_names.vcm); }cio2_bridge_init_swnode_group (sensor);
drivers/media/pci/intel/ipu3/cio2-bridge.h +1 -0
@@ -104,6 +104,7 @@ struct cio2_node_names {char port[7 ];char endpoint[11 ];char remote_port[7 ]; +char vcm[16 ]; };struct cio2_sensor_config {
Signature · 1 line
2.41.0
PATCH 2/12 media: ipu3-cio2: Move initialization of node_names.vcm to cio2_bridge_init_swnode_names()
In reply to Hans de GoedeMove initialization of node_names.vcm to cio2_bridge_init_swnode_names() where it belongs.
And make the initialization of nodes[SWNODE_VCM] unconditional, cio2_bridge_init_swnode_group() takes care of not registering it when there is no VCM.
--- drivers/media/pci/intel/ipu3/cio2-bridge.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +7 -7
@@ -201,6 +201,12 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)snprintf (sensor->node_names.endpoint,sizeof (sensor->node_names.endpoint),SWNODE_GRAPH_ENDPOINT_NAME_FMT ,0 );/* And endpoint 0 */ +if (sensor->ssdb.vcmtype) { +/* append ssdb.link to distinguish nodes with same model VCM */ +snprintf (sensor->node_names.vcm,sizeof (sensor->node_names.vcm), +"%s-%u" , cio2_vcm_types[sensor->ssdb.vcmtype -1 ], + sensor->ssdb.link); + } }static void cio2_bridge_init_swnode_group (struct cio2_sensor *sensor)
@@ -237,13 +243,7 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge, sensor->node_names.endpoint, &nodes[SWNODE_CIO2_PORT ], sensor->cio2_properties); -if (sensor->ssdb.vcmtype) { -/* append ssdb.link to distinguish VCM nodes with same HID */ -snprintf (sensor->node_names.vcm,sizeof (sensor->node_names.vcm), -"%s-%u" , cio2_vcm_types[sensor->ssdb.vcmtype -1 ], - sensor->ssdb.link); - nodes[SWNODE_VCM ] =NODE_VCM (sensor->node_names.vcm); - } + nodes[SWNODE_VCM ] =NODE_VCM (sensor->node_names.vcm);cio2_bridge_init_swnode_group (sensor); }
Signature · 1 line
2.41.0
PATCH 3/12 media: ipu3-cio2: Make cio2_bridge_init() take a regular struct device as argument
In reply to Hans de GoedeMake cio2_bridge_init() take a regular struct device, rather then a pci_dev as argument.
This is a preparation patch for making the cio2-bridge code more generic so that it can be shared with the atomisp driver.
--- drivers/media/pci/intel/ipu3/cio2-bridge.c | 16 +++++++--------- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 2 +- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +7 -9
@@ -4,7 +4,6 @@#include <linux/acpi.h> #include <linux/device.h> #include <linux/i2c.h> -#include <linux/pci.h> #include <linux/property.h> #include <media/v4l2-fwnode.h>
@@ -288,7 +287,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)static int cio2_bridge_connect_sensor (const struct cio2_sensor_config *cfg,struct cio2_bridge *bridge, -struct pci_dev *cio2) +struct device *dev) {struct fwnode_handle *fwnode, *primary;struct cio2_sensor *sensor;
@@ -302,7 +301,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,if (bridge->n_sensors >=CIO2_NUM_PORTS ) {acpi_dev_put (adev); -dev_err (&cio2->dev,"Exceeded available CIO2 ports\n" ); +dev_err (dev,"Exceeded available CIO2 ports\n" );return -EINVAL ; }
@@ -357,7 +356,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,cio2_bridge_instantiate_vcm_i2c_client (sensor); -dev_info (&cio2->dev,"Found supported sensor %s\n" , +dev_info (dev,"Found supported sensor %s\n" ,acpi_dev_name (adev)); bridge->n_sensors++;
@@ -375,7 +374,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, }static int cio2_bridge_connect_sensors (struct cio2_bridge *bridge, -struct pci_dev *cio2) +struct device *dev) {unsigned int i;int ret;
@@ -384,7 +383,7 @@ static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge,const struct cio2_sensor_config *cfg = &cio2_supported_sensors[i]; - ret =cio2_bridge_connect_sensor (cfg, bridge, cio2); + ret =cio2_bridge_connect_sensor (cfg, bridge, dev);if (ret) goto err_unregister_sensors; }
@@ -430,9 +429,8 @@ static int cio2_bridge_sensors_are_ready(void)return ready; } -int cio2_bridge_init (struct pci_dev *cio2) +int cio2_bridge_init (struct device *dev) { -struct device *dev = &cio2->dev;struct fwnode_handle *fwnode;struct cio2_bridge *bridge;unsigned int i;
@@ -465,7 +463,7 @@ int cio2_bridge_init(struct pci_dev *cio2)for (i =0 ; i <CIO2_MAX_LANES ; i++) bridge->data_lanes[i] = i +1 ; - ret =cio2_bridge_connect_sensors (bridge, cio2); + ret =cio2_bridge_connect_sensors (bridge, dev);if (ret || bridge->n_sensors ==0 ) goto err_unregister_cio2;
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +1 -1
@@ -1724,7 +1724,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,return -EINVAL ; } - r =cio2_bridge_init (pci_dev); + r =cio2_bridge_init (dev);if (r)return r; }
drivers/media/pci/intel/ipu3/ipu3-cio2.h +2 -2
@@ -460,9 +460,9 @@ static inline struct cio2_queue *vb2q_to_cio2_queue(struct vb2_queue *vq) }#if IS_ENABLED (CONFIG_CIO2_BRIDGE ) -int cio2_bridge_init (struct pci_dev *cio2); +int cio2_bridge_init (struct device *dev);#else -static inline int cio2_bridge_init (struct pci_dev *cio2) {return 0 ; } +static inline int cio2_bridge_init (struct device *dev) {return 0 ; }#endif #endif
Signature · 1 line
2.41.0
PATCH 4/12 media: ipu3-cio2: Store dev pointer in struct cio2_bridge
In reply to Hans de GoedeStore the dev pointer in struct cio2_bridge instead of passing it around 3 levels deep.
This takes up slightly more memory but further patches in this series add more data which needs to be passed around making passing everything as arguments cumbersome and those further patches also add data to struct cio2_bridge.
To be consistent with these upcoming patches also add the dev pointer to struct cio2_bridge.
--- drivers/media/pci/intel/ipu3/cio2-bridge.c | 15 +++++++-------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 1 + 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +7 -8
@@ -286,8 +286,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge) }static int cio2_bridge_connect_sensor (const struct cio2_sensor_config *cfg, -struct cio2_bridge *bridge, -struct device *dev) +struct cio2_bridge *bridge) {struct fwnode_handle *fwnode, *primary;struct cio2_sensor *sensor;
@@ -301,7 +300,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,if (bridge->n_sensors >=CIO2_NUM_PORTS ) {acpi_dev_put (adev); -dev_err (dev,"Exceeded available CIO2 ports\n" ); +dev_err (bridge->dev,"Exceeded available CIO2 ports\n" );return -EINVAL ; }
@@ -356,7 +355,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,cio2_bridge_instantiate_vcm_i2c_client (sensor); -dev_info (dev,"Found supported sensor %s\n" , +dev_info (bridge->dev,"Found supported sensor %s\n" ,acpi_dev_name (adev)); bridge->n_sensors++;
@@ -373,8 +372,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,return ret; } -static int cio2_bridge_connect_sensors (struct cio2_bridge *bridge, -struct device *dev) +static int cio2_bridge_connect_sensors (struct cio2_bridge *bridge) {unsigned int i;int ret;
@@ -383,7 +381,7 @@ static int cio2_bridge_connect_sensors(struct cio2_bridge *bridge,const struct cio2_sensor_config *cfg = &cio2_supported_sensors[i]; - ret =cio2_bridge_connect_sensor (cfg, bridge, dev); + ret =cio2_bridge_connect_sensor (cfg, bridge);if (ret) goto err_unregister_sensors; }
@@ -446,6 +444,7 @@ int cio2_bridge_init(struct device *dev)strscpy (bridge->cio2_node_name,CIO2_HID ,sizeof (bridge->cio2_node_name)); bridge->cio2_hid_node.name = bridge->cio2_node_name; + bridge->dev = dev; ret =software_node_register (&bridge->cio2_hid_node);if (ret <0 ) {
@@ -463,7 +462,7 @@ int cio2_bridge_init(struct device *dev)for (i =0 ; i <CIO2_MAX_LANES ; i++) bridge->data_lanes[i] = i +1 ; - ret =cio2_bridge_connect_sensors (bridge, dev); + ret =cio2_bridge_connect_sensors (bridge);if (ret || bridge->n_sensors ==0 ) goto err_unregister_cio2;
drivers/media/pci/intel/ipu3/cio2-bridge.h +1 -0
@@ -137,6 +137,7 @@ struct cio2_sensor { };struct cio2_bridge { +struct device *dev;char cio2_node_name[ACPI_ID_LEN ];struct software_node cio2_hid_node;u32 data_lanes[4 ];
Signature · 1 line
2.41.0
PATCH 5/12 media: ipu3-cio2: Only keep PLD around while parsing
In reply to Hans de GoedeThere is no need to keep a reference to the PLD struct around, it is only used once the get the sensor orientation.
Rename cio2_bridge_parse_orientation() to cio2_bridge_get_orientation() and make it also get + put the PLD.
This is a preparation patch for making the cio2-bridge code more generic so that it can be shared with the atomisp driver.
--- drivers/media/pci/intel/ipu3/cio2-bridge.c | 51 ++++++++++++---------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 2 +- 2 files changed, 30 insertions(+), 23 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +29 -22
@@ -112,23 +112,40 @@ static u32 cio2_bridge_parse_rotation(struct cio2_sensor *sensor) } } -static enum v4l2_fwnode_orientation cio2_bridge_parse_orientation (struct cio2_sensor *sensor) +static enum v4l2_fwnode_orientation +cio2_bridge_get_orientation (struct acpi_device *adev) { -switch (sensor->pld->panel) { +enum v4l2_fwnode_orientation orientation; +struct acpi_pld_info *pld; +acpi_status status; + + status =acpi_get_physical_device_location (adev->handle, &pld); +if (ACPI_FAILURE (status)) { +dev_warn (&adev->dev,"_PLD call failed using unknown orientation\n" ); +return V4L2_FWNODE_ORIENTATION_EXTERNAL ; + } + +switch (pld->panel) {case ACPI_PLD_PANEL_FRONT : -return V4L2_FWNODE_ORIENTATION_FRONT ; + orientation =V4L2_FWNODE_ORIENTATION_FRONT ; +break ;case ACPI_PLD_PANEL_BACK : -return V4L2_FWNODE_ORIENTATION_BACK ; + orientation =V4L2_FWNODE_ORIENTATION_BACK ; +break ;case ACPI_PLD_PANEL_TOP :case ACPI_PLD_PANEL_LEFT :case ACPI_PLD_PANEL_RIGHT :case ACPI_PLD_PANEL_UNKNOWN : -return V4L2_FWNODE_ORIENTATION_EXTERNAL ; + orientation =V4L2_FWNODE_ORIENTATION_EXTERNAL ; +break ;default : -dev_warn (&sensor->adev->dev,"Unknown _PLD panel value %d\n" , - sensor->pld->panel); -return V4L2_FWNODE_ORIENTATION_EXTERNAL ; +dev_warn (&adev->dev,"Unknown _PLD panel val %d\n" , pld->panel); + orientation =V4L2_FWNODE_ORIENTATION_EXTERNAL ; +break ; } + +ACPI_FREE (pld); +return orientation; } static void cio2_bridge_create_fwnode_properties(
@@ -137,10 +154,8 @@ static void cio2_bridge_create_fwnode_properties( const struct cio2_sensor_config *cfg) {u32 rotation; -enum v4l2_fwnode_orientation orientation; rotation =cio2_bridge_parse_rotation (sensor); - orientation =cio2_bridge_parse_orientation (sensor); sensor->prop_names = prop_names;
@@ -155,7 +170,7 @@ static void cio2_bridge_create_fwnode_properties( rotation); sensor->dev_properties[2 ] =PROPERTY_ENTRY_U32 ( sensor->prop_names.orientation, - orientation); + sensor->orientation);if (sensor->ssdb.vcmtype) { sensor->vcm_ref[0 ] =SOFTWARE_NODE_REFERENCE (&sensor->swnodes[SWNODE_VCM ]);
@@ -279,7 +294,6 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)for (i =0 ; i < bridge->n_sensors; i++) { sensor = &bridge->sensors[i];software_node_unregister_node_group (sensor->group); -ACPI_FREE (sensor->pld);acpi_dev_put (sensor->adev);i2c_unregister_device (sensor->vcm_i2c_client); }
@@ -291,7 +305,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,struct fwnode_handle *fwnode, *primary;struct cio2_sensor *sensor;struct acpi_device *adev; -acpi_status status;int ret;for_each_acpi_dev_match (adev, cfg->hid,NULL ,-1 ) {
@@ -321,17 +334,13 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, sensor->ssdb.vcmtype =0 ; } - status =acpi_get_physical_device_location (adev->handle, &sensor->pld); -if (ACPI_FAILURE (status)) { - ret = -ENODEV ; - goto err_put_adev; - } + sensor->orientation =cio2_bridge_get_orientation (adev);if (sensor->ssdb.lanes >CIO2_MAX_LANES ) {dev_err (&adev->dev,"Number of lanes in SSDB is invalid\n" ); ret = -EINVAL ; - goto err_free_pld; + goto err_put_adev; }cio2_bridge_create_fwnode_properties (sensor, bridge, cfg);
@@ -339,7 +348,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, ret =software_node_register_node_group (sensor->group);if (ret) - goto err_free_pld; + goto err_put_adev; fwnode =software_node_fwnode (&sensor->swnodes[SWNODE_SENSOR_HID ]);
@@ -365,8 +374,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, err_free_swnodes:software_node_unregister_node_group (sensor->group); -err_free_pld: -ACPI_FREE (sensor->pld); err_put_adev:acpi_dev_put (adev);return ret;
drivers/media/pci/intel/ipu3/cio2-bridge.h +1 -1
@@ -125,7 +125,7 @@ struct cio2_sensor {struct cio2_node_names node_names;struct cio2_sensor_ssdb ssdb; -struct acpi_pld_info *pld; +enum v4l2_fwnode_orientation orientation;struct cio2_property_names prop_names;struct property_entry ep_properties[5 ];
Signature · 1 line
2.41.0
PATCH 6/12 media: ipu3-cio2: Add a cio2_bridge_parse_sensor_fwnode() helper function
In reply to Hans de GoedeThe code to go from ACPI sensor info to a fwnode-tree with connector nodes and endpoint properties is 99% the same for the atomisp2 and the IPU3.
The main difference is that atomisp2 devices do not have a SSDB table with various info.
Abstract out the parsing of the sensor's ACPI fwnode into a helper function and store the parsed results, rather then the raw SSDB in struct cio2_sensor.
This is a preparation patch for making the cio2-bridge code more generic so that it can be shared with the atomisp driver.
--- drivers/media/pci/intel/ipu3/cio2-bridge.c | 94 ++++++++++++---------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 6 +- 2 files changed, 56 insertions(+), 44 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +51 -43
@@ -97,17 +97,18 @@ static int cio2_bridge_read_acpi_buffer(struct acpi_device *adev, char *id,return ret; } -static u32 cio2_bridge_parse_rotation (struct cio2_sensor *sensor) +static u32 cio2_bridge_parse_rotation (struct acpi_device *adev, +struct cio2_sensor_ssdb *ssdb) { -switch (sensor->ssdb.degree) { +switch (ssdb->degree) {case CIO2_SENSOR_ROTATION_NORMAL :return 0 ;case CIO2_SENSOR_ROTATION_INVERTED :return 180 ;default : -dev_warn (&sensor->adev->dev, +dev_warn (&adev->dev,"Unknown rotation %d. Assume 0 degree rotation\n" , - sensor->ssdb.degree); + ssdb->degree);return 0 ; } }
@@ -148,15 +149,43 @@ cio2_bridge_get_orientation(struct acpi_device *adev)return orientation; } +static int cio2_bridge_parse_sensor_fwnode (struct acpi_device *adev, +struct cio2_sensor *sensor) +{ +struct cio2_sensor_ssdb ssdb = {}; +int ret; + + ret =cio2_bridge_read_acpi_buffer (adev,"SSDB" , &ssdb,sizeof (ssdb)); +if (ret) +return ret; + +if (ssdb.vcmtype >ARRAY_SIZE (cio2_vcm_types)) { +dev_warn (&adev->dev,"Unknown VCM type %d\n" , ssdb.vcmtype); + ssdb.vcmtype =0 ; + } + +if (ssdb.lanes >CIO2_MAX_LANES ) { +dev_err (&adev->dev,"Number of lanes in SSDB is invalid\n" ); +return -EINVAL ; + } + + sensor->link = ssdb.link; + sensor->lanes = ssdb.lanes; + sensor->mclkspeed = ssdb.mclkspeed; + sensor->rotation =cio2_bridge_parse_rotation (adev, &ssdb); + sensor->orientation =cio2_bridge_get_orientation (adev); + +if (ssdb.vcmtype) + sensor->vcm_type = cio2_vcm_types[ssdb.vcmtype -1 ]; + +return 0 ; +} +static void cio2_bridge_create_fwnode_properties (struct cio2_sensor *sensor,struct cio2_bridge *bridge,const struct cio2_sensor_config *cfg) { -u32 rotation; - - rotation =cio2_bridge_parse_rotation (sensor); - sensor->prop_names = prop_names; sensor->local_ref[0 ] =SOFTWARE_NODE_REFERENCE (&sensor->swnodes[SWNODE_CIO2_ENDPOINT ]);
@@ -164,14 +193,14 @@ static void cio2_bridge_create_fwnode_properties( sensor->dev_properties[0 ] =PROPERTY_ENTRY_U32 ( sensor->prop_names.clock_frequency, - sensor->ssdb.mclkspeed); + sensor->mclkspeed); sensor->dev_properties[1 ] =PROPERTY_ENTRY_U32 ( sensor->prop_names.rotation, - rotation); + sensor->rotation); sensor->dev_properties[2 ] =PROPERTY_ENTRY_U32 ( sensor->prop_names.orientation, sensor->orientation); -if (sensor->ssdb.vcmtype) { +if (sensor->vcm_type) { sensor->vcm_ref[0 ] =SOFTWARE_NODE_REFERENCE (&sensor->swnodes[SWNODE_VCM ]); sensor->dev_properties[3] =
@@ -183,8 +212,7 @@ static void cio2_bridge_create_fwnode_properties( V4L2_FWNODE_BUS_TYPE_CSI2_DPHY); sensor->ep_properties[1 ] =PROPERTY_ENTRY_U32_ARRAY_LEN ( sensor->prop_names.data_lanes, - bridge->data_lanes, - sensor->ssdb.lanes); + bridge->data_lanes, sensor->lanes); sensor->ep_properties[2 ] =PROPERTY_ENTRY_REF_ARRAY ( sensor->prop_names.remote_endpoint, sensor->local_ref);
@@ -197,8 +225,7 @@ static void cio2_bridge_create_fwnode_properties( sensor->cio2_properties[0 ] =PROPERTY_ENTRY_U32_ARRAY_LEN ( sensor->prop_names.data_lanes, - bridge->data_lanes, - sensor->ssdb.lanes); + bridge->data_lanes, sensor->lanes); sensor->cio2_properties[1 ] =PROPERTY_ENTRY_REF_ARRAY ( sensor->prop_names.remote_endpoint, sensor->remote_ref);
@@ -208,18 +235,17 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor) {snprintf (sensor->node_names.remote_port,sizeof (sensor->node_names.remote_port), -SWNODE_GRAPH_PORT_NAME_FMT , sensor->ssdb.link); +SWNODE_GRAPH_PORT_NAME_FMT , sensor->link);snprintf (sensor->node_names.port,sizeof (sensor->node_names.port),SWNODE_GRAPH_PORT_NAME_FMT ,0 );/* Always port 0 */ snprintf (sensor->node_names.endpoint,sizeof (sensor->node_names.endpoint),SWNODE_GRAPH_ENDPOINT_NAME_FMT ,0 );/* And endpoint 0 */ -if (sensor->ssdb.vcmtype) { -/* append ssdb.link to distinguish nodes with same model VCM */ +if (sensor->vcm_type) { +/* append link to distinguish nodes with same model VCM */ snprintf (sensor->node_names.vcm,sizeof (sensor->node_names.vcm), -"%s-%u" , cio2_vcm_types[sensor->ssdb.vcmtype -1 ], - sensor->ssdb.link); +"%s-%u" , sensor->vcm_type, sensor->link); } }
@@ -232,7 +258,7 @@ static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor) sensor->group[SWNODE_SENSOR_ENDPOINT ] = &nodes[SWNODE_SENSOR_ENDPOINT ]; sensor->group[SWNODE_CIO2_PORT ] = &nodes[SWNODE_CIO2_PORT ]; sensor->group[SWNODE_CIO2_ENDPOINT ] = &nodes[SWNODE_CIO2_ENDPOINT ]; -if (sensor->ssdb.vcmtype) +if (sensor->vcm_type) sensor->group[SWNODE_VCM ] = &nodes[SWNODE_VCM ]; }
@@ -267,13 +293,12 @@ static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)struct i2c_board_info board_info = { };char name[16 ]; -if (!sensor->ssdb.vcmtype) +if (!sensor->vcm_type)return ;snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); board_info.dev_name = name; -strscpy (board_info.type, cio2_vcm_types[sensor->ssdb.vcmtype -1 ], -ARRAY_SIZE (board_info.type)); +strscpy (board_info.type, sensor->vcm_type,ARRAY_SIZE (board_info.type)); board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; sensor->vcm_i2c_client =
@@ -319,29 +344,12 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, sensor = &bridge->sensors[bridge->n_sensors]; - ret =cio2_bridge_read_acpi_buffer (adev,"SSDB" , - &sensor->ssdb, -sizeof (sensor->ssdb)); + ret =cio2_bridge_parse_sensor_fwnode (adev, sensor);if (ret) goto err_put_adev;snprintf (sensor->name,sizeof (sensor->name),"%s-%u" , - cfg->hid, sensor->ssdb.link); - -if (sensor->ssdb.vcmtype >ARRAY_SIZE (cio2_vcm_types)) { -dev_warn (&adev->dev,"Unknown VCM type %d\n" , - sensor->ssdb.vcmtype); - sensor->ssdb.vcmtype =0 ; - } - - sensor->orientation =cio2_bridge_get_orientation (adev); - -if (sensor->ssdb.lanes >CIO2_MAX_LANES ) { -dev_err (&adev->dev, -"Number of lanes in SSDB is invalid\n" ); - ret = -EINVAL ; - goto err_put_adev; - } + cfg->hid, sensor->link);cio2_bridge_create_fwnode_properties (sensor, bridge, cfg);cio2_bridge_create_connection_swnodes (bridge, sensor);
drivers/media/pci/intel/ipu3/cio2-bridge.h +5 -1
@@ -124,8 +124,12 @@ struct cio2_sensor {struct software_node swnodes[SWNODE_COUNT ];struct cio2_node_names node_names; -struct cio2_sensor_ssdb ssdb; +u8 link; +u8 lanes; +u32 mclkspeed; +u32 rotation;enum v4l2_fwnode_orientation orientation; +const char *vcm_type;struct cio2_property_names prop_names;struct property_entry ep_properties[5 ];
Signature · 1 line
2.41.0
Andy Shevchenko
maintainerRe: [PATCH 06/12] media: ipu3-cio2: Add a cio2_bridge_parse_sensor_fwnode() helper function
Quoted 13 lines · Hans de Goede
The code to go from ACPI sensor info to a fwnode-tree with connector nodes and endpoint properties is 99% the same for the atomisp2 and the IPU3.
The main difference is that atomisp2 devices do not have a SSDB table with various info.
Abstract out the parsing of the sensor's ACPI fwnode into a helper function and store the parsed results, rather then the raw SSDB in struct
cio2_sensor.This is a preparation patch for making the cio2-bridge code more generic so that it can be shared with the atomisp driver.
...
drivers/media/pci/intel/ipu3/cio2-bridge.c cio2_bridge_get_orientation(struct acpi_device *adev) · line 165
Quoted 4 lines
drivers/media/pci/intel/ipu3/cio2-bridge.c +4
-0+if (ssdb.vcmtype >ARRAY_SIZE (cio2_vcm_types)) { +dev_warn (&adev->dev,"Unknown VCM type %d\n" , ssdb.vcmtype); + ssdb.vcmtype =0 ; + }
I'm wondering if we actually can add the first entry in the types as UNKNOWN or so, and hence
if (ssdb.vcmtype >= ARRAY_SIZE(cio2_vcm_types)) {
...
}drivers/media/pci/intel/ipu3/cio2-bridge.c cio2_bridge_get_orientation(struct acpi_device *adev) · line 179
Quoted 2 lines
drivers/media/pci/intel/ipu3/cio2-bridge.c +2
-0+if (ssdb.vcmtype) + sensor->vcm_type = cio2_vcm_types[ssdb.vcmtype -1 ];
...and here the conditional can be dropped.
sensor->vcm_type = cio2_vcm_types[ssdb.vcmtype];
Maybe it's a material for a separate change... Dunno.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 7/12 media: ipu3-cio2: Add a parse_sensor_fwnode callback to cio2_bridge_init()
In reply to Hans de GoedeAdd a parse_sensor_fwnode callback to cio2_bridge_init(), so that cio2_bridge_init() can be used with other sensor fwnode parse functions then just cio2_bridge_parse_sensor_fwnode.
This is a preparation patch for making the cio2-bridge code more generic so that it can be shared with the atomisp driver.
---
Note to reviewers the wrapped __cio2_bridge_init() function goes away (becomes a generic shared helper) later in this series
--- drivers/media/pci/intel/ipu3/cio2-bridge.c | 17 ++++++++++++++--- drivers/media/pci/intel/ipu3/cio2-bridge.h | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +14 -3
@@ -150,7 +150,8 @@ cio2_bridge_get_orientation(struct acpi_device *adev) }static int cio2_bridge_parse_sensor_fwnode (struct acpi_device *adev, -struct cio2_sensor *sensor) +struct cio2_sensor *sensor, +const struct cio2_sensor_config *cfg) {struct cio2_sensor_ssdb ssdb = {};int ret;
@@ -344,7 +345,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, sensor = &bridge->sensors[bridge->n_sensors]; - ret =cio2_bridge_parse_sensor_fwnode (adev, sensor); + ret = bridge->parse_sensor_fwnode (adev, sensor, cfg);if (ret) goto err_put_adev;
@@ -442,7 +443,11 @@ static int cio2_bridge_sensors_are_ready(void)return ready; } -int cio2_bridge_init (struct device *dev) +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)) {struct fwnode_handle *fwnode;struct cio2_bridge *bridge;
@@ -460,6 +465,7 @@ int cio2_bridge_init(struct device *dev) sizeof(bridge->cio2_node_name)); bridge->cio2_hid_node.name = bridge->cio2_node_name; bridge->dev = dev; + bridge->parse_sensor_fwnode = parse_sensor_fwnode; ret =software_node_register (&bridge->cio2_hid_node);if (ret <0 ) {
@@ -503,3 +509,8 @@ int cio2_bridge_init(struct device *dev)return ret; } + +int cio2_bridge_init (struct device *dev) +{ +return __cio2_bridge_init (dev, cio2_bridge_parse_sensor_fwnode); +}
drivers/media/pci/intel/ipu3/cio2-bridge.h +3 -0
@@ -142,6 +142,9 @@ struct cio2_sensor {struct cio2_bridge {struct device *dev; +int (*parse_sensor_fwnode)(struct acpi_device *adev, +struct cio2_sensor *sensor, +const struct cio2_sensor_config *cfg);char cio2_node_name[ACPI_ID_LEN ];struct software_node cio2_hid_node;u32 data_lanes[4 ];
Signature · 1 line
2.41.0
PATCH 8/12 media: ipu3-cio2: Add supported_sensors parameter to cio2_bridge_init()
In reply to Hans de GoedeAdd 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.
--- 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(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +13 -9
@@ -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); }
drivers/media/pci/intel/ipu3/cio2-bridge.h +1 -0
@@ -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 ];
Signature · 1 line
2.41.0
PATCH 9/12 media: ipu3-cio2: Move cio2_bridge_init() code into a new shared intel-cio2-bridge.ko
In reply to Hans de GoedeMove all the code implementing cio2_bridge_init() into a new shared intel-cio2-bridge.ko, so that it can be reused by the atomisp driver (and maybe also by the future IPU6 CSI2 driver).
Note this just moves a bunch of stuff around prefixes some symbols / defines with intel_ / INTEL_ no functional changes.
---
MAINTAINERS | 9 +
drivers/media/common/Kconfig | 4 +
drivers/media/common/Makefile | 1 +
.../intel-cio2-bridge.c} | 228 +++------
drivers/media/pci/intel/ipu3/Kconfig | 1 +
drivers/media/pci/intel/ipu3/cio2-bridge.c | 438 +++---------------
drivers/media/pci/intel/ipu3/cio2-bridge.h | 156 -------
include/media/intel-cio2-bridge.h | 104 +++++
8 files changed, 237 insertions(+), 704 deletions(-)
copy drivers/media/{pci/intel/ipu3/cio2-bridge.c => common/intel-cio2-bridge.c} (66%)
delete mode 100644 drivers/media/pci/intel/ipu3/cio2-bridge.h
create mode 100644 include/media/intel-cio2-bridge.hMAINTAINERS +9 -0
@@ -10325,6 +10325,15 @@ S: Supported T: git git://git.code.sf.net/p/intel-sas/isci F: drivers/scsi/isci/ +INTEL CIO2 ACPI SENSOR BRIDGE +M: Dan Scally <[email protected]> +M: Hans de Goede <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media_tree.git +F: drivers/media/common/intel-cio2-bridge.c +F: include/media/intel-cio2-bridge.h + INTEL CPU family model numbers M: Tony Luck <[email protected]> M: [email protected]
drivers/media/common/Kconfig +4 -0
@@ -10,6 +10,10 @@ config CYPRESS_FIRMWARE tristate depends on USB +config INTEL_CIO2_BRIDGE + tristate + depends on ACPI && I2C + config TTPCI_EEPROM tristate depends on I2C
drivers/media/common/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-y += b2c2/ saa7146/ siano/ v4l2-tpg/ videobuf2/ # Please keep it alphabetically sorted by Kconfig name # (e. g. LC_ALL=C sort Makefile) obj-$(CONFIG_CYPRESS_FIRMWARE) += cypress_firmware.o +obj-$(CONFIG_INTEL_CIO2_BRIDGE) += intel-cio2-bridge.o obj-$(CONFIG_TTPCI_EEPROM) += ttpci-eeprom.o obj-$(CONFIG_UVC_COMMON) += uvc.o obj-$(CONFIG_VIDEO_CX2341X) += cx2341x.o
drivers/media/common/intel-cio2-bridge.c renamed from drivers/media/pci/intel/ipu3/cio2-bridge.c +65 -163
353 lines not on this page · raw message
drivers/media/pci/intel/ipu3/Kconfig +1 -0
@@ -8,6 +8,7 @@ config VIDEO_IPU3_CIO2 select VIDEO_V4L2_SUBDEV_API select V4L2_FWNODE select VIDEOBUF2_DMA_SG + select INTEL_CIO2_BRIDGE if CIO2_BRIDGE help This is the Intel IPU3 CIO2 CSI-2 receiver unit, found in Intel
drivers/media/pci/intel/ipu3/cio2-bridge.c +53 -385
482 lines not on this page · raw message
drivers/media/pci/intel/ipu3/cio2-bridge.h deleted +0 -156
156 lines not on this page · raw message
include/media/intel-cio2-bridge.h new file +104 -0
104 lines not on this page · raw message
Signature · 1 line
2.41.0
Andy Shevchenko
maintainerRe: [PATCH 09/12] media: ipu3-cio2: Move cio2_bridge_init() code into a new shared intel-cio2-bridge.ko
Quoted 6 lines · Hans de Goede
Move all the code implementing
cio2_bridge_init()into a new shared intel-cio2-bridge.ko, so that it can be reused by the atomisp driver (and maybe also by the future IPU6 CSI2 driver).Note this just moves a bunch of stuff around prefixes some symbols / defines with
intel_/INTEL_no functional changes.
...
Quoted 1 line
+EXPORT_SYMBOL(intel_cio2_bridge_init);
Why not GPL?
Perhaps namespace?
...
Seems to me that name CIO2 in AtomISP case sounds a bit weird. Maybe ipu/isp should be used instead?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Dan Scally
maintainerRe: [PATCH 09/12] media: ipu3-cio2: Move cio2_bridge_init() code into a new shared intel-cio2-bridge.ko
Hello all
Quoted 9 lines · Andy Shevchenko
Quoted 6 lines · Hans de Goede
Move all the code implementing
cio2_bridge_init()into a new shared intel-cio2-bridge.ko, so that it can be reused by the atomisp driver (and maybe also by the future IPU6 CSI2 driver).Note this just moves a bunch of stuff around prefixes some symbols / defines with
intel_/INTEL_no functional changes....
Quoted 8 lines
Quoted 1 line
+EXPORT_SYMBOL(intel_cio2_bridge_init);
Why not GPL?
Perhaps namespace?...
Seems to me that name CIO2 in AtomISP case sounds a bit weird. Maybe ipu/isp should be used instead?
I agree here, since it's a specific device. But there's already some picked patches to turn the cio2-bridge into the ipu-bridge, so probably this needs to rebase on top of that work.
PATCH 10/12 media: atomisp: csi2-bridge: Switch to new common cio2_bridge_init()
In reply to Hans de GoedeRemove the duplicate csi2/cio2 ACPI bridge code and use the new common cio2_bridge_init() functionality.
--- drivers/staging/media/atomisp/Kconfig | 2 + .../staging/media/atomisp/pci/atomisp_csi2.h | 67 ---- .../media/atomisp/pci/atomisp_csi2_bridge.c | 307 +++--------------- include/media/intel-cio2-bridge.h | 1 + 4 files changed, 43 insertions(+), 334 deletions(-)
drivers/staging/media/atomisp/Kconfig +2 -0
@@ -13,10 +13,12 @@ config VIDEO_ATOMISP tristate "Intel Atom Image Signal Processor Driver" depends on VIDEO_DEV && INTEL_ATOMISP depends on PMIC_OPREGION + depends on I2C select V4L2_FWNODE select IOSF_MBI select VIDEOBUF2_VMALLOC select VIDEO_V4L2_SUBDEV_API + select INTEL_CIO2_BRIDGE help Say Y here if your platform supports Intel Atom SoC camera imaging subsystem.
drivers/staging/media/atomisp/pci/atomisp_csi2.h +0 -67
79 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp_csi2_bridge.c +40 -267
367 lines not on this page · raw message
include/media/intel-cio2-bridge.h +1 -0
@@ -47,6 +47,7 @@ struct intel_cio2_node_names {struct intel_cio2_sensor_config {const char *hid; +const u8 default_lanes;const u8 nr_link_freqs;const u64 link_freqs[INTEL_CIO2_MAX_NUM_LINK_FREQS ]; };
Signature · 1 line
2.41.0
PATCH 11/12 media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
In reply to Hans de GoedeIn most cases when a VCM is used there is a single integrated module with the sensor + VCM + lens. This means that the sensor and VCM often share regulators and possibly also something like a powerdown pin.
In the ACPI tables this is modelled as a single ACPI device with multiple I2cSerialBus resources.
On atomisp devices the regulators and clks are modelled as ACPI power-resources, which are controlled by the (ACPI) power state of the sensor. So the sensor must be in D0 power state for the VCM to work.
To make this work add a device-link with DL_FLAG_PM_RUNTIME flag so that the sensor will automatically be runtime-resumed whenever the VCM is runtime-resumed.
This requires the probing of the VCM and thus the creation of the VCM I2C-client to be delayed till after the sensor driver has bound.
Move the instantiation of the VCM I2C-client to the v4l2_async_notifier bound op, so that it is done after the sensor driver has bound; and add code to add the device-link.
This fixes the problem with the shared ACPI power-resources on atomisp2 and this avoids the need for VCM related workarounds on IPU3.
E.g. until now the dw9719 driver needed to get and control a Vsio (V sensor IO) regulator since that needs to be enabled to enable I2C pass-through on the PMIC on the sensor module. So the driver was controlling this regulator even though the actual dw9719 chip has no Vsio pin / power-plane.
This also removes the need for intel_cio2_bridge_init() to return -EPROBE_DEFER since the VCM is now instantiated later.
--- drivers/media/common/intel-cio2-bridge.c | 160 +++++++++++------- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 5 + drivers/media/pci/intel/ipu3/ipu3-cio2.h | 3 + include/media/intel-cio2-bridge.h | 4 +- 4 files changed, 111 insertions(+), 61 deletions(-)
drivers/media/common/intel-cio2-bridge.c +101 -59
@@ -5,7 +5,9 @@#include <linux/acpi.h> #include <linux/device.h> #include <linux/i2c.h> +#include <linux/pm_runtime.h> #include <linux/property.h> +#include <linux/workqueue.h> #include <media/intel-cio2-bridge.h> #include <media/v4l2-fwnode.h>
@@ -189,30 +191,111 @@ static void cio2_bridge_create_connection_swnodes(cio2_bridge_init_swnode_group (sensor); } -static void cio2_bridge_instantiate_vcm_i2c_client ( -struct intel_cio2_sensor *sensor) -{ -struct i2c_board_info board_info = { }; +/* +* The actual instantiation must be done from a workqueue to avoid +* a deadlock on taking list_lock from v4l2-async twice. +*/ +struct intel_cio2_bridge_instantiate_vcm_work_data { +struct work_struct work; +struct device *sensor;char name[16 ]; +struct i2c_board_info board_info; +}; -if (!sensor->vcm_type) -return ; +static void intel_cio2_bridge_instantiate_vcm_work (struct work_struct *_work) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work = +container_of (_work, + struct intel_cio2_bridge_instantiate_vcm_work_data, + work); +struct acpi_device *adev =ACPI_COMPANION (work->sensor); +struct i2c_client *vcm_client; +bool put_fwnode = true; +int ret; -snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); - board_info.dev_name = name; -strscpy (board_info.type, sensor->vcm_type,ARRAY_SIZE (board_info.type)); - board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; - - sensor->vcm_i2c_client = -i2c_acpi_new_device_by_fwnode (acpi_fwnode_handle (sensor->adev), -1 , &board_info); -if (IS_ERR (sensor->vcm_i2c_client)) { -dev_warn (&sensor->adev->dev,"Error instantiation VCM i2c-client: %ld\n" , -PTR_ERR (sensor->vcm_i2c_client)); - sensor->vcm_i2c_client =NULL ; +/* +* The client may get probed before the device_link gets added below +* make sure the sensor is powered-up during probe. +*/ + ret =pm_runtime_get_sync (work->sensor); +if (ret <0 ) { +dev_err (work->sensor,"Error %d runtime-resuming sensor, cannot instantiate VCM\n" , + ret); + goto out; } + +/* +* Note the client is created only once and then kept around +* even after a rmmod, just like the software-nodes. +*/ + vcm_client =i2c_acpi_new_device_by_fwnode (acpi_fwnode_handle (adev), +1 , &work->board_info); +if (IS_ERR (vcm_client)) { +dev_err (work->sensor,"Error instantiating VCM client: %ld\n" , +PTR_ERR (vcm_client)); + goto out; + } + +device_link_add (&vcm_client->dev, work->sensor,DL_FLAG_PM_RUNTIME ); + +dev_info (work->sensor,"Instantiated %s VCM\n" , work->board_info.type); + put_fwnode = false;/* Ownership has passed to the i2c-client */ + +out: +pm_runtime_put (work->sensor); +put_device (work->sensor); +if (put_fwnode) +fwnode_handle_put (work->board_info.fwnode); +kfree (work); } +int intel_cio2_bridge_instantiate_vcm (struct device *sensor) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work; +struct acpi_device *adev =ACPI_COMPANION (sensor); +struct fwnode_handle *vcm_fwnode; +struct i2c_client *vcm_client; +char *sep; + +if (!adev) +return 0 ; + + vcm_fwnode =fwnode_find_reference (dev_fwnode (sensor),"lens-focus" ,0 ); +if (IS_ERR (vcm_fwnode)) +return 0 ; + +/* When reloading modules the client will already exist */ + vcm_client =i2c_find_device_by_fwnode (vcm_fwnode); +if (vcm_client) { +fwnode_handle_put (vcm_fwnode); +put_device (&vcm_client->dev); +return 0 ; + } + + work =kzalloc (sizeof (*work),GFP_KERNEL ); +if (!work) { +fwnode_handle_put (vcm_fwnode); +return -ENOMEM ; + } + +INIT_WORK (&work->work, intel_cio2_bridge_instantiate_vcm_work); + work->sensor =get_device (sensor); +snprintf (work->name,sizeof (work->name),"%s-VCM" , +acpi_dev_name (adev)); + work->board_info.dev_name = work->name; + work->board_info.fwnode = vcm_fwnode; +strscpy (work->board_info.type,fwnode_get_name (vcm_fwnode), +I2C_NAME_SIZE ); +/* Strip "-<link>" postfix */ + sep =strchrnul (work->board_info.type,'-' ); + *sep =0 ; + +queue_work (system_long_wq, &work->work); + +return 0 ; +} +EXPORT_SYMBOL (intel_cio2_bridge_instantiate_vcm); +static void cio2_bridge_unregister_sensors (struct intel_cio2_bridge *bridge) {struct intel_cio2_sensor *sensor;
@@ -222,7 +305,6 @@ static void cio2_bridge_unregister_sensors(struct intel_cio2_bridge *bridge) sensor = &bridge->sensors[i];software_node_unregister_node_group (sensor->group);acpi_dev_put (sensor->adev); -i2c_unregister_device (sensor->vcm_i2c_client); } }
@@ -273,8 +355,6 @@ static int cio2_bridge_connect_sensor( primary =acpi_fwnode_handle (adev); primary->secondary = fwnode; -cio2_bridge_instantiate_vcm_i2c_client (sensor); -dev_info (bridge->dev,"Found supported sensor %s\n" ,acpi_dev_name (adev));
@@ -311,41 +391,6 @@ static int cio2_bridge_connect_sensors(struct intel_cio2_bridge *bridge)return ret; } -/* -* The VCM cannot be probed until the PMIC is completely setup. We cannot rely -* on -EPROBE_DEFER for this, since the consumer<->supplier relations between -* the VCM and regulators/clks are not described in ACPI, instead they are -* passed as board-data to the PMIC drivers. Since -PROBE_DEFER does not work -* for the clks/regulators the VCM i2c-clients must not be instantiated until -* the PMIC is fully setup. -* -* The sensor/VCM ACPI device has an ACPI _DEP on the PMIC, check this using the -* acpi_dev_ready_for_enumeration() helper, like the i2c-core-acpi code does -* for the sensors. -*/ -static int cio2_bridge_sensors_are_ready ( -const struct intel_cio2_sensor_config *supported_sensors) -{ -struct acpi_device *adev; -bool ready = true; -unsigned int i; - -for (i =0 ; supported_sensors[i].hid; i++) { -const struct intel_cio2_sensor_config *cfg = - &supported_sensors[i]; - -for_each_acpi_dev_match (adev, cfg->hid,NULL ,-1 ) { -if (!adev->status.enabled) -continue ; - -if (!acpi_dev_ready_for_enumeration (adev)) - ready = false; - } - } - -return ready; -} - int intel_cio2_bridge_init( struct device *dev, int (*parse_sensor_fwnode)(struct acpi_device *adev,
@@ -358,9 +403,6 @@ int intel_cio2_bridge_init(unsigned int i;int ret; -if (!cio2_bridge_sensors_are_ready (supported_sensors)) -return -EPROBE_DEFER ; - bridge =kzalloc (sizeof (*bridge),GFP_KERNEL );if (!bridge)return -ENOMEM ;
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +5 -0
@@ -1386,10 +1386,15 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,struct cio2_device *cio2 =to_cio2_device (notifier);struct sensor_async_subdev *s_asd =to_sensor_asd (asd);struct cio2_queue *q; +int ret;if (cio2->queue[s_asd->csi2.port].sensor)return -EBUSY ; + ret =intel_cio2_bridge_instantiate_vcm (sd->dev); +if (ret) +return ret; + q = &cio2->queue[s_asd->csi2.port]; q->csi2 = s_asd->csi2;
drivers/media/pci/intel/ipu3/ipu3-cio2.h +3 -0
@@ -12,6 +12,7 @@#include <asm/page.h> +#include <media/intel-cio2-bridge.h> #include <media/media-device.h> #include <media/media-entity.h> #include <media/v4l2-async.h>
@@ -463,6 +464,8 @@ static inline struct cio2_queue *vb2q_to_cio2_queue(struct vb2_queue *vq)int cio2_bridge_init (struct device *dev);#else static inline int cio2_bridge_init (struct device *dev) {return 0 ; } +static inline int +intel_cio2_bridge_instantiate_vcm (struct device *dev) {return 0 ; }#endif #endif
include/media/intel-cio2-bridge.h +2 -2
@@ -10,7 +10,6 @@#include <media/v4l2-fwnode.h> struct acpi_device ; -struct i2c_client ;#define INTEL_CIO2_HID "INT343E"#define INTEL_CIO2_MAX_LANES 4
@@ -56,7 +55,6 @@ struct intel_cio2_sensor {/* append link(u8) in "-%u" format as suffix of HID */ char name[ACPI_ID_LEN +4 ];struct acpi_device *adev; -struct i2c_client *vcm_i2c_client;/* SWNODE_COUNT + 1 for terminating NULL */ const struct software_node *group[SWNODE_COUNT +1 ];
@@ -99,6 +97,8 @@ int intel_cio2_bridge_init( const struct intel_cio2_sensor_config *cfg), const struct intel_cio2_sensor_config *supported_sensors); +int intel_cio2_bridge_instantiate_vcm (struct device *sensor); +enum v4l2_fwnode_orientation intel_cio2_bridge_get_orientation (struct acpi_device *adev);
Signature · 1 line
2.41.0
Andy Shevchenko
maintainerRe: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Quoted 34 lines · Hans de Goede
In most cases when a VCM is used there is a single integrated module with the sensor + VCM + lens. This means that the sensor and VCM often share regulators and possibly also something like a powerdown pin.
In the ACPI tables this is modelled as a single ACPI device with multiple I2cSerialBus resources.
On atomisp devices the regulators and clks are modelled as ACPI power-resources, which are controlled by the (ACPI) power state of the sensor. So the sensor must be in D0 power state for the VCM to work.
To make this work add a device-link with
DL_FLAG_PM_RUNTIMEflag so that the sensor will automatically be runtime-resumed whenever the VCM is runtime-resumed.This requires the probing of the VCM and thus the creation of the VCM I2C-client to be delayed till after the sensor driver has bound.
Move the instantiation of the VCM I2C-client to the
v4l2_async_notifierbound op, so that it is done after the sensor driver has bound; and add code to add the device-link.This fixes the problem with the shared ACPI power-resources on atomisp2 and this avoids the need for VCM related workarounds on IPU3.
E.g. until now the dw9719 driver needed to get and control a Vsio (V sensor IO) regulator since that needs to be enabled to enable I2C pass-through on the PMIC on the sensor module. So the driver was controlling this regulator even though the actual dw9719 chip has no Vsio pin / power-plane.
This also removes the need for
intel_cio2_bridge_init()to return -EPROBE_DEFER since the VCM is now instantiated later.
...
Quoted 1 line
+struct
intel_cio2_bridge_instantiate_vcm_work_data{
Hmm... A bit long name :-)
Quoted 5 lines
drivers/media/common/intel-cio2-bridge.c +4
-0+struct work_struct work; +struct device *sensor;char name[16 ]; +struct i2c_board_info board_info; +};
...
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 234
Quoted 2 lines
drivers/media/common/intel-cio2-bridge.c +2
-0+if (IS_ERR (vcm_client)) { + dev_err(work->sensor, "Error instantiating VCM client: %ld\n",
or even %pe
Quoted 1 line
drivers/media/common/intel-cio2-bridge.c +1
-0+ PTR_ERR(vcm_client));
...
Quoted 1 line
+out:
out_put_pm: ?
Quoted 5 lines
drivers/media/common/intel-cio2-bridge.c +5
-0+pm_runtime_put (work->sensor); +put_device (work->sensor); +if (put_fwnode) +fwnode_handle_put (work->board_info.fwnode); +kfree (work);
...
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 258
Quoted 7 lines
drivers/media/common/intel-cio2-bridge.c +7
-0+int intel_cio2_bridge_instantiate_vcm (struct device *sensor) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work; +struct acpi_device *adev =ACPI_COMPANION (sensor); +struct fwnode_handle *vcm_fwnode; +struct i2c_client *vcm_client; +char *sep;
I would rather split assignment, so below won't look a bit puzzling.
struct acpi_device *adev; ... adev = ACPI_COMPANION(sensor);
Quoted 37 lines
drivers/media/common/intel-cio2-bridge.c +37
-0+if (!adev) +return 0 ; + + vcm_fwnode =fwnode_find_reference (dev_fwnode (sensor),"lens-focus" ,0 ); +if (IS_ERR (vcm_fwnode)) +return 0 ; + +/* When reloading modules the client will already exist */ + vcm_client =i2c_find_device_by_fwnode (vcm_fwnode); +if (vcm_client) { +fwnode_handle_put (vcm_fwnode); +put_device (&vcm_client->dev); +return 0 ; + } + + work =kzalloc (sizeof (*work),GFP_KERNEL ); +if (!work) { +fwnode_handle_put (vcm_fwnode); +return -ENOMEM ; + } + +INIT_WORK (&work->work, intel_cio2_bridge_instantiate_vcm_work); + work->sensor =get_device (sensor); +snprintf (work->name,sizeof (work->name),"%s-VCM" , +acpi_dev_name (adev)); + work->board_info.dev_name = work->name; + work->board_info.fwnode = vcm_fwnode; +strscpy (work->board_info.type,fwnode_get_name (vcm_fwnode), +I2C_NAME_SIZE ); +/* Strip "-<link>" postfix */ + sep =strchrnul (work->board_info.type,'-' ); + *sep =0 ; + +queue_work (system_long_wq, &work->work); + +return 0 ; +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
In reply to Hans de GoedeHans,
Quoted 101 lines · Hans de Goede
In most cases when a VCM is used there is a single integrated module with the sensor + VCM + lens. This means that the sensor and VCM often share regulators and possibly also something like a powerdown pin.
In the ACPI tables this is modelled as a single ACPI device with multiple I2cSerialBus resources.
On atomisp devices the regulators and clks are modelled as ACPI power-resources, which are controlled by the (ACPI) power state of the sensor. So the sensor must be in D0 power state for the VCM to work.
To make this work add a device-link with
DL_FLAG_PM_RUNTIMEflag so that the sensor will automatically be runtime-resumed whenever the VCM is runtime-resumed.This requires the probing of the VCM and thus the creation of the VCM I2C-client to be delayed till after the sensor driver has bound.
Move the instantiation of the VCM I2C-client to the
v4l2_async_notifierbound op, so that it is done after the sensor driver has bound; and add code to add the device-link.This fixes the problem with the shared ACPI power-resources on atomisp2 and this avoids the need for VCM related workarounds on IPU3.
E.g. until now the dw9719 driver needed to get and control a Vsio (V sensor IO) regulator since that needs to be enabled to enable I2C pass-through on the PMIC on the sensor module. So the driver was controlling this regulator even though the actual dw9719 chip has no Vsio pin / power-plane.
This also removes the need for
intel_cio2_bridge_init()to return -EPROBE_DEFER since the VCM is now instantiated later.Signed-off-by Hans de Goede <[email protected]>--- drivers/media/common/intel-cio2-bridge.c | 160 +++++++++++------- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 5 + drivers/media/pci/intel/ipu3/ipu3-cio2.h | 3 + include/media/intel-cio2-bridge.h | 4 +- 4 files changed, 111 insertions(+), 61 deletions(-)drivers/media/common/intel-cio2-bridge.c +21
-18@@ -5,7 +5,9 @@#include <linux/acpi.h> #include <linux/device.h> #include <linux/i2c.h> +#include <linux/pm_runtime.h> #include <linux/property.h> +#include <linux/workqueue.h> #include <media/intel-cio2-bridge.h> #include <media/v4l2-fwnode.h> @@ -189,30 +191,111 @@ static void cio2_bridge_create_connection_swnodes(cio2_bridge_init_swnode_group (sensor); } -static void cio2_bridge_instantiate_vcm_i2c_client ( -struct intel_cio2_sensor *sensor) -{ -struct i2c_board_info board_info = { }; +/* +* The actual instantiation must be done from a workqueue to avoid +* a deadlock on taking list_lock from v4l2-async twice. +*/ +struct intel_cio2_bridge_instantiate_vcm_work_data { +struct work_struct work; +struct device *sensor;char name[16 ]; +struct i2c_board_info board_info; +}; -if (!sensor->vcm_type) -return ; +static void intel_cio2_bridge_instantiate_vcm_work (struct work_struct *_work) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work = +container_of (_work, + struct intel_cio2_bridge_instantiate_vcm_work_data, + work); +struct acpi_device *adev =ACPI_COMPANION (work->sensor); +struct i2c_client *vcm_client; +bool put_fwnode = true; +int ret; -snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); - board_info.dev_name = name; -strscpy (board_info.type, sensor->vcm_type,ARRAY_SIZE (board_info.type)); - board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; - - sensor->vcm_i2c_client = -i2c_acpi_new_device_by_fwnode (acpi_fwnode_handle (sensor->adev), -1 , &board_info); -if (IS_ERR (sensor->vcm_i2c_client)) { -dev_warn (&sensor->adev->dev,"Error instantiation VCM i2c-client: %ld\n" , -PTR_ERR (sensor->vcm_i2c_client)); - sensor->vcm_i2c_client =NULL ;
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 225
Quoted 10 lines
drivers/media/common/intel-cio2-bridge.c +9
-0+/* +* The client may get probed before the device_link gets added below +* make sure the sensor is powered-up during probe. +*/ + ret =pm_runtime_get_sync (work->sensor); +if (ret <0 ) { +dev_err (work->sensor,"Error %d runtime-resuming sensor, cannot instantiate VCM\n" , + ret); + goto out; }
One question here: how do we make sure that the runtime PM of the sensor is enabled during the .bound callback? Or is it a mandatory requirement of driver of such camera sensors?
Quoted 216 lines
drivers/media/common/intel-cio2-bridge.c +71
-41+ +/* +* Note the client is created only once and then kept around +* even after a rmmod, just like the software-nodes. +*/ + vcm_client =i2c_acpi_new_device_by_fwnode (acpi_fwnode_handle (adev), +1 , &work->board_info); +if (IS_ERR (vcm_client)) { +dev_err (work->sensor,"Error instantiating VCM client: %ld\n" , +PTR_ERR (vcm_client)); + goto out; + } + +device_link_add (&vcm_client->dev, work->sensor,DL_FLAG_PM_RUNTIME ); + +dev_info (work->sensor,"Instantiated %s VCM\n" , work->board_info.type); + put_fwnode = false;/* Ownership has passed to the i2c-client */ + +out: +pm_runtime_put (work->sensor); +put_device (work->sensor); +if (put_fwnode) +fwnode_handle_put (work->board_info.fwnode); +kfree (work); } +int intel_cio2_bridge_instantiate_vcm (struct device *sensor) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work; +struct acpi_device *adev =ACPI_COMPANION (sensor); +struct fwnode_handle *vcm_fwnode; +struct i2c_client *vcm_client; +char *sep; + +if (!adev) +return 0 ; + + vcm_fwnode =fwnode_find_reference (dev_fwnode (sensor),"lens-focus" ,0 ); +if (IS_ERR (vcm_fwnode)) +return 0 ; + +/* When reloading modules the client will already exist */ + vcm_client =i2c_find_device_by_fwnode (vcm_fwnode); +if (vcm_client) { +fwnode_handle_put (vcm_fwnode); +put_device (&vcm_client->dev); +return 0 ; + } + + work =kzalloc (sizeof (*work),GFP_KERNEL ); +if (!work) { +fwnode_handle_put (vcm_fwnode); +return -ENOMEM ; + } + +INIT_WORK (&work->work, intel_cio2_bridge_instantiate_vcm_work); + work->sensor =get_device (sensor); +snprintf (work->name,sizeof (work->name),"%s-VCM" , +acpi_dev_name (adev)); + work->board_info.dev_name = work->name; + work->board_info.fwnode = vcm_fwnode; +strscpy (work->board_info.type,fwnode_get_name (vcm_fwnode), +I2C_NAME_SIZE ); +/* Strip "-<link>" postfix */ + sep =strchrnul (work->board_info.type,'-' ); + *sep =0 ; + +queue_work (system_long_wq, &work->work); + +return 0 ; +} +EXPORT_SYMBOL (intel_cio2_bridge_instantiate_vcm); +static void cio2_bridge_unregister_sensors (struct intel_cio2_bridge *bridge) {struct intel_cio2_sensor *sensor;@@ -222,7 +305,6 @@ static void cio2_bridge_unregister_sensors(struct intel_cio2_bridge *bridge) sensor = &bridge->sensors[i];software_node_unregister_node_group (sensor->group);acpi_dev_put (sensor->adev); -i2c_unregister_device (sensor->vcm_i2c_client); } }@@ -273,8 +355,6 @@ static int cio2_bridge_connect_sensor( primary =acpi_fwnode_handle (adev); primary->secondary = fwnode; -cio2_bridge_instantiate_vcm_i2c_client (sensor); -dev_info (bridge->dev,"Found supported sensor %s\n" ,acpi_dev_name (adev));@@ -311,41 +391,6 @@ static int cio2_bridge_connect_sensors(struct intel_cio2_bridge *bridge)return ret; } -/* -* The VCM cannot be probed until the PMIC is completely setup. We cannot rely -* on -EPROBE_DEFER for this, since the consumer<->supplier relations between -* the VCM and regulators/clks are not described in ACPI, instead they are -* passed as board-data to the PMIC drivers. Since -PROBE_DEFER does not work -* for the clks/regulators the VCM i2c-clients must not be instantiated until -* the PMIC is fully setup. -* -* The sensor/VCM ACPI device has an ACPI _DEP on the PMIC, check this using the -* acpi_dev_ready_for_enumeration() helper, like the i2c-core-acpi code does -* for the sensors. -*/ -static int cio2_bridge_sensors_are_ready ( -const struct intel_cio2_sensor_config *supported_sensors) -{ -struct acpi_device *adev; -bool ready = true; -unsigned int i; - -for (i =0 ; supported_sensors[i].hid; i++) { -const struct intel_cio2_sensor_config *cfg = - &supported_sensors[i]; - -for_each_acpi_dev_match (adev, cfg->hid,NULL ,-1 ) { -if (!adev->status.enabled) -continue ; - -if (!acpi_dev_ready_for_enumeration (adev)) - ready = false; - } - } - -return ready; -} - int intel_cio2_bridge_init( struct device *dev, int (*parse_sensor_fwnode)(struct acpi_device *adev,@@ -358,9 +403,6 @@ int intel_cio2_bridge_init(unsigned int i;int ret; -if (!cio2_bridge_sensors_are_ready (supported_sensors)) -return -EPROBE_DEFER ; - bridge =kzalloc (sizeof (*bridge),GFP_KERNEL );if (!bridge)return -ENOMEM ;drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +5
-0@@ -1386,10 +1386,15 @@ static int cio2_notifier_bound(struct v4l2_async_notifier *notifier,struct cio2_device *cio2 =to_cio2_device (notifier);struct sensor_async_subdev *s_asd =to_sensor_asd (asd);struct cio2_queue *q; +int ret;if (cio2->queue[s_asd->csi2.port].sensor)return -EBUSY ; + ret =intel_cio2_bridge_instantiate_vcm (sd->dev); +if (ret) +return ret; + q = &cio2->queue[s_asd->csi2.port]; q->csi2 = s_asd->csi2;drivers/media/pci/intel/ipu3/ipu3-cio2.h +3
-0@@ -12,6 +12,7 @@#include <asm/page.h> +#include <media/intel-cio2-bridge.h> #include <media/media-device.h> #include <media/media-entity.h> #include <media/v4l2-async.h> @@ -463,6 +464,8 @@ static inline struct cio2_queue *vb2q_to_cio2_queue(struct vb2_queue *vq)int cio2_bridge_init (struct device *dev);#else static inline int cio2_bridge_init (struct device *dev) {return 0 ; } +static inline int +intel_cio2_bridge_instantiate_vcm (struct device *dev) {return 0 ; }#endif #endif include/media/intel-cio2-bridge.h +2
-2@@ -10,7 +10,6 @@#include <media/v4l2-fwnode.h> struct acpi_device ; -struct i2c_client ;#define INTEL_CIO2_HID "INT343E"#define INTEL_CIO2_MAX_LANES 4@@ -56,7 +55,6 @@ struct intel_cio2_sensor {/* append link(u8) in "-%u" format as suffix of HID */ char name[ACPI_ID_LEN +4 ];struct acpi_device *adev; -struct i2c_client *vcm_i2c_client;/* SWNODE_COUNT + 1 for terminating NULL */ const struct software_node *group[SWNODE_COUNT +1 ];@@ -99,6 +97,8 @@ int intel_cio2_bridge_init( const struct intel_cio2_sensor_config *cfg), const struct intel_cio2_sensor_config *supported_sensors); +int intel_cio2_bridge_instantiate_vcm (struct device *sensor); +enum v4l2_fwnode_orientation intel_cio2_bridge_get_orientation (struct acpi_device *adev);
Signature · 2 lines
Best regards, Bingbu Cao
Sakari Ailus
maintainerRe: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Hi Bingbu,
Quoted 29 lines · Bingbu Cao
Quoted 29 lines
drivers/media/common/intel-cio2-bridge.c +16
-12+static void intel_cio2_bridge_instantiate_vcm_work (struct work_struct *_work) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work = +container_of (_work, + struct intel_cio2_bridge_instantiate_vcm_work_data, + work); +struct acpi_device *adev =ACPI_COMPANION (work->sensor); +struct i2c_client *vcm_client; +bool put_fwnode = true; +int ret; -snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); - board_info.dev_name = name; -strscpy (board_info.type, sensor->vcm_type,ARRAY_SIZE (board_info.type)); - board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; - - sensor->vcm_i2c_client = -i2c_acpi_new_device_by_fwnode (acpi_fwnode_handle (sensor->adev), -1 , &board_info); -if (IS_ERR (sensor->vcm_i2c_client)) { -dev_warn (&sensor->adev->dev,"Error instantiation VCM i2c-client: %ld\n" , -PTR_ERR (sensor->vcm_i2c_client)); - sensor->vcm_i2c_client =NULL ; +/* +* The client may get probed before the device_link gets added below +* make sure the sensor is powered-up during probe. +*/ + ret =pm_runtime_get_sync (work->sensor); +if (ret <0 ) {
Quoted 8 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 225
Quoted 4 lines
drivers/media/common/intel-cio2-bridge.c +3
-0+dev_err (work->sensor,"Error %d runtime-resuming sensor, cannot instantiate VCM\n" , + ret); + goto out; }One question here: how do we make sure that the runtime PM of the sensor is enabled during the .bound callback? Or is it a mandatory requirement of driver of such camera sensors?
The sensor driver needs to enable runtime PM in probe, otherwise this won't work. But I don't see why a driver wouldn't? Of course otherwise it wouldn't be a hard requirement.
This function gets called after the upstream notifier (CIO2 in this case) driver's bound is called, the sensor's probe function has been run by this time so this part should be fine.
Signature · 3 lines
Regards, Sakari Ailus
Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Hi,
Quoted 41 lines · Sakari Ailus
Hi Bingbu,
Quoted 29 lines · Bingbu Cao
Quoted 29 lines
drivers/media/common/intel-cio2-bridge.c +16
-12+static void intel_cio2_bridge_instantiate_vcm_work (struct work_struct *_work) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work = +container_of (_work, + struct intel_cio2_bridge_instantiate_vcm_work_data, + work); +struct acpi_device *adev =ACPI_COMPANION (work->sensor); +struct i2c_client *vcm_client; +bool put_fwnode = true; +int ret; -snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); - board_info.dev_name = name; -strscpy (board_info.type, sensor->vcm_type,ARRAY_SIZE (board_info.type)); - board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; - - sensor->vcm_i2c_client = -i2c_acpi_new_device_by_fwnode (acpi_fwnode_handle (sensor->adev), -1 , &board_info); -if (IS_ERR (sensor->vcm_i2c_client)) { -dev_warn (&sensor->adev->dev,"Error instantiation VCM i2c-client: %ld\n" , -PTR_ERR (sensor->vcm_i2c_client)); - sensor->vcm_i2c_client =NULL ; +/* +* The client may get probed before the device_link gets added below +* make sure the sensor is powered-up during probe. +*/ + ret =pm_runtime_get_sync (work->sensor); +if (ret <0 ) {Quoted 8 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 225
Quoted 4 lines
drivers/media/common/intel-cio2-bridge.c +3
-0+dev_err (work->sensor,"Error %d runtime-resuming sensor, cannot instantiate VCM\n" , + ret); + goto out; }One question here: how do we make sure that the runtime PM of the sensor is enabled during the .bound callback? Or is it a mandatory requirement of driver of such camera sensors?
Quoted 3 lines
The sensor driver needs to enable runtime PM in probe, otherwise this won't work. But I don't see why a driver wouldn't? Of course otherwise it wouldn't be a hard requirement.
Right. I believe that having runtime pm support is more or less a hard requirement for sensor drivers used on x86. This is also necessary in cases where the power on/off sequence is (partially) implemented in ACPI AML code in the _PS0 and _PS3 methods of the sensor's ACPI device.
This happens on [atom]ISP2 based devices and AFAIK also on ChromeOS devices.
So I think it is safe to assume that sensor drivers implement runtime pm support and in cases where the driver does not we need to fix the driver.
Regards,
Hans
Sakari Ailus
maintainerRe: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Hi Hans,
Quoted 47 lines · Hans de Goede
Hi,
Quoted 44 lines · Sakari Ailus
Hi Bingbu,
Quoted 29 lines · Bingbu Cao
Quoted 29 lines
drivers/media/common/intel-cio2-bridge.c +16
-12+static void intel_cio2_bridge_instantiate_vcm_work (struct work_struct *_work) +{ +struct intel_cio2_bridge_instantiate_vcm_work_data *work = +container_of (_work, + struct intel_cio2_bridge_instantiate_vcm_work_data, + work); +struct acpi_device *adev =ACPI_COMPANION (work->sensor); +struct i2c_client *vcm_client; +bool put_fwnode = true; +int ret; -snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); - board_info.dev_name = name; -strscpy (board_info.type, sensor->vcm_type,ARRAY_SIZE (board_info.type)); - board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; - - sensor->vcm_i2c_client = -i2c_acpi_new_device_by_fwnode (acpi_fwnode_handle (sensor->adev), -1 , &board_info); -if (IS_ERR (sensor->vcm_i2c_client)) { -dev_warn (&sensor->adev->dev,"Error instantiation VCM i2c-client: %ld\n" , -PTR_ERR (sensor->vcm_i2c_client)); - sensor->vcm_i2c_client =NULL ; +/* +* The client may get probed before the device_link gets added below +* make sure the sensor is powered-up during probe. +*/ + ret =pm_runtime_get_sync (work->sensor); +if (ret <0 ) {Quoted 8 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 225
Quoted 4 lines
drivers/media/common/intel-cio2-bridge.c +3
-0+dev_err (work->sensor,"Error %d runtime-resuming sensor, cannot instantiate VCM\n" , + ret); + goto out; }One question here: how do we make sure that the runtime PM of the sensor is enabled during the .bound callback? Or is it a mandatory requirement of driver of such camera sensors?
The sensor driver needs to enable runtime PM in probe, otherwise this won't work. But I don't see why a driver wouldn't? Of course otherwise it wouldn't be a hard requirement.
I meant to write "wasn't earlier a hard requirement". This could also be documented, I can write a patch for this.
Quoted 11 lines
Right. I believe that having runtime pm support is more or less a hard requirement for sensor drivers used on x86. This is also necessary in cases where the power on/off sequence is (partially) implemented in ACPI AML code in the
_PS0and_PS3methods of the sensor's ACPI device.This happens on [atom]ISP2 based devices and AFAIK also on ChromeOS devices.
So I think it is safe to assume that sensor drivers implement runtime pm support and in cases where the driver does not we need to fix the driver.
I agree.
Signature · 3 lines
Regards, Sakari Ailus
RE: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Sakari and Hans,
------------------------------------------------------------------------
BRs,
Bingbu Cao
Quoted 64 lines
-----Original Message-----
From: Sakari Ailus <[email protected]>
Sent: Monday, October 30, 2023 5:24 PM
To: Hans de Goede <[email protected]>
Cc: Bingbu Cao <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Cao, Bingbu <[email protected]>; [email protected]
Subject: Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensorHi Hans,
Quoted 11 lines · Hans de Goede
Hi,
Quoted 8 lines · Sakari Ailus
Hi Bingbu,
Quoted 5 lines · Bingbu Cao
Review
Quoted 5 lines
(quoted diff) +5
-0+static void intel_cio2_bridge_instantiate_vcm_work(struct +work_struct *_work) { + struct intel_cio2_bridge_instantiate_vcm_work_data *work = + container_of(_work, + struct
intel_cio2_bridge_instantiate_vcm_work_data,Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c +5
-3+ work); +struct acpi_device *adev =ACPI_COMPANION (work->sensor); +struct i2c_client *vcm_client; +bool put_fwnode = true; +int ret; -snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); - board_info.dev_name = name; - strscpy(board_info.type, sensor->vcm_type,
ARRAY_SIZE(board_info.type));Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 4 lines
drivers/media/common/intel-cio2-bridge.c +0
-4- board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; - - sensor->vcm_i2c_client = - i2c_acpi_new_device_by_fwnode(acpi_fwnode_handle(sensor-adev),
Quoted 3 lines
Quoted 3 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 3 lines
drivers/media/common/intel-cio2-bridge.c +0
-3- 1, &board_info); -if (IS_ERR (sensor->vcm_i2c_client)) { - dev_warn(&sensor->adev->dev, "Error instantiation VCM i2c-client: %ld\n",
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c +7
-2- PTR_ERR(sensor->vcm_i2c_client)); - sensor->vcm_i2c_client =NULL ; +/* +* The client may get probed before the device_link gets added below +* make sure the sensor is powered-up during probe. +*/ + ret =pm_runtime_get_sync (work->sensor); +if (ret <0 ) { + dev_err(work->sensor, "Error %d runtime-resuming sensor,cannot instantiate VCM\n",
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 225
Quoted 3 lines
drivers/media/common/intel-cio2-bridge.c +2
-0+ ret); + goto out; }One question here: how do we make sure that the runtime PM of the sensor is enabled during the .bound callback? Or is it a mandatory requirement of driver of such camera sensors?
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
The sensor driver needs to enable runtime PM in probe, otherwise this won't work. But I don't see why a driver wouldn't? Of course otherwise it wouldn't be a hard requirement.
I meant to write "wasn't earlier a hard requirement". This could also be documented, I can write a patch for this.
The problem here is that some driver doesn't enable the runtime PM before v4l2_async_register_subdev_sensor(), that may cause race condition and VCM instantiation failure as the runtime PM is not enabled yet. Then there is no chance for VCM instantiation to succeed.
Does this 'requirement' or limit really make sense?
Quoted 20 lines
Quoted 7 lines
Right. I believe that having runtime pm support is more or less a hard requirement for sensor drivers used on x86. This is also necessary in cases where the power on/off sequence is (partially) implemented in ACPI AML code in the
_PS0and_PS3methods of the sensor's ACPI device.Quoted 5 lines
This happens on [atom]ISP2 based devices and AFAIK also on ChromeOS devices.
So I think it is safe to assume that sensor drivers implement runtime pm support and in cases where the driver does not we need to fix the
driver.
I agree.
--
Regards,Sakari Ailus
Sakari Ailus
maintainerRe: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Hi Bingbu,
Quoted 74 lines · Bingbu
Sakari and Hans,
------------------------------------------------------------------------
BRs,
Bingbu CaoQuoted 68 lines
-----Original Message-----
From: Sakari Ailus <[email protected]>
Sent: Monday, October 30, 2023 5:24 PM
To: Hans de Goede <[email protected]>
Cc: Bingbu Cao <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Cao, Bingbu <[email protected]>; [email protected]
Subject: Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensorHi Hans,
Quoted 11 lines · Hans de Goede
Hi,
Quoted 8 lines · Sakari Ailus
Hi Bingbu,
Quoted 5 lines · Bingbu Cao
Review
Quoted 5 lines
(quoted diff) +5
-0+static void intel_cio2_bridge_instantiate_vcm_work(struct +work_struct *_work) { + struct intel_cio2_bridge_instantiate_vcm_work_data *work = + container_of(_work, + struct
intel_cio2_bridge_instantiate_vcm_work_data,Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c +5
-3+ work); +struct acpi_device *adev =ACPI_COMPANION (work->sensor); +struct i2c_client *vcm_client; +bool put_fwnode = true; +int ret; -snprintf (name,sizeof (name),"%s-VCM" ,acpi_dev_name (sensor->adev)); - board_info.dev_name = name; - strscpy(board_info.type, sensor->vcm_type,
ARRAY_SIZE(board_info.type));Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 4 lines
drivers/media/common/intel-cio2-bridge.c +0
-4- board_info.swnode = &sensor->swnodes[SWNODE_VCM ]; - - sensor->vcm_i2c_client = - i2c_acpi_new_device_by_fwnode(acpi_fwnode_handle(sensor-adev),
Quoted 3 lines
Quoted 3 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 3 lines
drivers/media/common/intel-cio2-bridge.c +0
-3- 1, &board_info); -if (IS_ERR (sensor->vcm_i2c_client)) { - dev_warn(&sensor->adev->dev, "Error instantiation VCM i2c-client: %ld\n",
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes(
Quoted 9 lines
drivers/media/common/intel-cio2-bridge.c +7
-2- PTR_ERR(sensor->vcm_i2c_client)); - sensor->vcm_i2c_client =NULL ; +/* +* The client may get probed before the device_link gets added below +* make sure the sensor is powered-up during probe. +*/ + ret =pm_runtime_get_sync (work->sensor); +if (ret <0 ) { + dev_err(work->sensor, "Error %d runtime-resuming sensor,cannot instantiate VCM\n",
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
drivers/media/common/intel-cio2-bridge.c static void cio2_bridge_create_connection_swnodes( · line 225
Quoted 3 lines
drivers/media/common/intel-cio2-bridge.c +2
-0+ ret); + goto out; }One question here: how do we make sure that the runtime PM of the sensor is enabled during the .bound callback? Or is it a mandatory requirement of driver of such camera sensors?
The sensor driver needs to enable runtime PM in probe, otherwise this won't work. But I don't see why a driver wouldn't? Of course otherwise it wouldn't be a hard requirement.
Quoted 7 lines
Quoted 2 lines
I meant to write "wasn't earlier a hard requirement". This could also be documented, I can write a patch for this.
The problem here is that some driver doesn't enable the runtime PM before
v4l2_async_register_subdev_sensor(), that may cause race condition and VCM instantiation failure as the runtime PM is not enabled yet. Then there is no chance for VCM instantiation to succeed.
These drivers need to be fixed.
All initialisation needs to complete by the time the async sub-device is registered as this is when the sensor may be bound to a notifier and also accessible via the UAPI.
In most of the cases the rest of the probe completes even if runtime PM is enabled after registering the sub-device (without IPU bridge) but it's still not correct.
Quoted 2 lines
Does this 'requirement' or limit really make sense?
Signature · 3 lines
Regards, Sakari Ailus
RE: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Sakari,
------------------------------------------------------------------------
BRs,
Bingbu Cao
Quoted 105 lines
-----Original Message-----
From: Sakari Ailus <[email protected]>
Sent: Wednesday, November 1, 2023 3:12 PM
To: Cao, Bingbu <[email protected]>
Cc: Hans de Goede <[email protected]>; Bingbu Cao <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; linux- [email protected]
Subject: Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensorHi Bingbu,
Quoted 43 lines · Bingbu
Sakari and Hans,
----------------------------------------------------------------------
--
BRs,
Bingbu CaoQuoted 28 lines
-----Original Message-----
From: Sakari Ailus <[email protected]>
Sent: Monday, October 30, 2023 5:24 PM
To: Hans de Goede <[email protected]>
Cc: Bingbu Cao <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Cao, Bingbu <[email protected]>; [email protected]
Subject: Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensorHi Hans,
Quoted 11 lines · Hans de Goede
Hi,
Quoted 8 lines · Sakari Ailus
Hi Bingbu,
Quoted 5 lines · Bingbu Cao
Review
Quoted 5 lines
(quoted diff) +5
-0+static void intel_cio2_bridge_instantiate_vcm_work(struct +work_struct *_work) { + struct intel_cio2_bridge_instantiate_vcm_work_data *work = + container_of(_work, + struct
intel_cio2_bridge_instantiate_vcm_work_data,Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Review
Quoted 7 lines
(quoted diff) +5
-1+ work); + struct acpi_device *adev = ACPI_COMPANION(work->sensor); + struct i2c_client *vcm_client; + bool put_fwnode = true; + int ret; - snprintf(name, sizeof(name), "%s-VCM", acpi_dev_name(sensor-adev));
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-2- board_info.dev_name = name; - strscpy(board_info.type, sensor->vcm_type,
ARRAY_SIZE(board_info.type));Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +0
-4- board_info.swnode = &sensor->swnodes[SWNODE_VCM]; - - sensor->vcm_i2c_client = -i2c_acpi_new_device_by_fwnode(acpi_fwnode_handle(sensor-
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
adev),
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +0
-3- 1, &board_info); - if (IS_ERR(sensor->vcm_i2c_client)) { - dev_warn(&sensor->adev->dev, "Error instantiation VCMi2c-
Quoted 5 lines
Quoted 5 lines
client: %ld\n",
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Review
Quoted 4 lines
(quoted diff) +2
-2- PTR_ERR(sensor->vcm_i2c_client)); - sensor->vcm_i2c_client = NULL; + /* + * The client may get probed before the device_link getsadded below
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ * make sure the sensor is powered-up during probe. + */ + ret = pm_runtime_get_sync(work->sensor); + if (ret < 0) { + dev_err(work->sensor, "Error %d runtime-resumingsensor,
Quoted 13 lines
Quoted 13 lines
cannot instantiate VCM\n",
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ ret); + goto out; }One question here: how do we make sure that the runtime PM of the sensor is enabled during the .bound callback? Or is it a mandatory requirement of driver of such camera sensors?
The sensor driver needs to enable runtime PM in probe, otherwise this won't work. But I don't see why a driver wouldn't? Of course otherwise it wouldn't be a hard requirement.
Quoted 7 lines
Quoted 2 lines
I meant to write "wasn't earlier a hard requirement". This could also be documented, I can write a patch for this.
The problem here is that some driver doesn't enable the runtime PM before
v4l2_async_register_subdev_sensor(), that may cause race condition and VCM instantiation failure as the runtime PM is not enabled yet. Then there is no chance for VCM instantiation to succeed.
Quoted 5 lines
These drivers need to be fixed.
All initialisation needs to complete by the time the async sub-device is registered as this is when the sensor may be bound to a notifier and also accessible via the UAPI.
Ack. Thanks!
Quoted 12 lines
In most of the cases the rest of the probe completes even if runtime PM is enabled after registering the sub-device (without IPU bridge) but it's still not correct.
Quoted 2 lines
Does this 'requirement' or limit really make sense?
--
Regards,Sakari Ailus
Andy Shevchenko
maintainerRe: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
On Wed, Nov 01, 2023 at 07:38:24AM +0000, Cao, Bingbu wrote:
Side note: Can you please Cc me in your v2, I believe I have some comments, but let's see a new version for them?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Hi Andy,
Quoted 4 lines · Andy Shevchenko
On Wed, Nov 01, 2023 at 07:38:24AM +0000, Cao, Bingbu wrote:
Side note: Can you please Cc me in your v2, I believe I have some comments, but let's see a new version for them?
I'm a bit confused, this is a series written by me not Bingbu and this series has been merged for a while now...
Regards,
Hans
Re: [PATCH 11/12] media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and sensor
Hans,
Quoted 10 lines · Hans de Goede
Hi Andy,
Quoted 4 lines · Andy Shevchenko
On Wed, Nov 01, 2023 at 07:38:24AM +0000, Cao, Bingbu wrote:
Side note: Can you please Cc me in your v2, I believe I have some comments, but let's see a new version for them?
I'm a bit confused, this is a series written by me not Bingbu and this series has been merged for a while now...
Yes and sorry. :)
I just borrow this thread to discuss more following your patch.
Quoted 8 lines
Regards,
Hans
Signature · 2 lines
Best regards, Bingbu Cao
RFC PATCH 12/12 media: dw9719: Drop hack to enable "vsio" regulator
In reply to Hans de GoedeDrop the hack where the driver is getting + enabling a "vsio" regulator even though the dw9719 does not have a vsio pin / power-plane at all.
Now that drivers/media/common/intel-cio2-bridge.c adds device-link making the VCM a consumer of the sensor this hack is no longer necessary.
---
Note to reviewers, the dw9719 driver is not upstream yet (I plan to resubmit it soon with this squashed in). This patch is only included in this patch-set to illustrate how the VCM -> sensor device-link avoids the need for hacks like this.
--- drivers/media/i2c/dw9719.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
drivers/media/i2c/dw9719.c +7 -20
@@ -35,14 +35,12 @@#define DW9719_DEFAULT_VCM_FREQ 0x60#define DW9719_ENABLE_RINGING 0x02 -#define NUM_REGULATORS 2 -#define to_dw9719_device (x) container_of(x, struct dw9719_device, sd) struct dw9719_device { struct device *dev; struct i2c_client *client; - struct regulator_bulk_data regulators[NUM_REGULATORS]; + struct regulator *regulator; struct v4l2_subdev sd; struct dw9719_v4l2_ctrls {
@@ -131,14 +129,14 @@ static int dw9719_detect(struct dw9719_device *dw9719)static int dw9719_power_down (struct dw9719_device *dw9719) { -return regulator_bulk_disable (NUM_REGULATORS , dw9719->regulators); +return regulator_disable (dw9719->regulator); }static int dw9719_power_up (struct dw9719_device *dw9719) {int ret; - ret =regulator_bulk_enable (NUM_REGULATORS , dw9719->regulators); + ret =regulator_enable (dw9719->regulator);if (ret)return ret;
@@ -315,21 +313,10 @@ static int dw9719_probe(struct i2c_client *client) dw9719->client = client; dw9719->dev = &client->dev; - dw9719->regulators[0 ].supply ="vdd" ; -/* -* The DW9719 has only the 1 VDD voltage input, but some PMICs such as -* the TPS68470 PMIC have I2C passthrough capability, to disconnect the -* sensor's I2C pins from the I2C bus when the sensors VSIO (Sensor-IO) -* is off, because some sensors then short these pins to ground; -* and the DW9719 might sit behind this passthrough, this it needs to -* enable VSIO as that will also enable the I2C passthrough. -*/ - dw9719->regulators[1 ].supply ="vsio" ; - - ret =devm_regulator_bulk_get (&client->dev,NUM_REGULATORS , - dw9719->regulators); -if (ret) -return dev_err_probe (&client->dev, ret,"getting regulators\n" ); + dw9719->regulator =devm_regulator_get (&client->dev,"vdd" ); +if (IS_ERR (dw9719->regulator)) +return dev_err_probe (&client->dev,PTR_ERR (dw9719->regulator), +"getting regulator\n" );v4l2_i2c_subdev_init (&dw9719->sd, client, &dw9719_ops); dw9719->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ;
Signature · 1 line
2.41.0
Quoted 6 lines · Hans de Goede
Hi All,
While working on adding (proper) VCM support to the atomisp code I found myself copying yet more code from
drivers/media/pci/intel/ipu3/cio2-bridge.cinto the atomisp code.
Quoted 7 lines
So I decided that it really was time to factor out the common code (most of the code) from
intel/ipu3/cio2-bridge.cinto its own helper library and then share it between the atomisp and IPU3 code.This will hopefully also be useful for the ongoing work to upstream IPU6 input system support which also needs this functionality and currently contains a 3th copy of this code in the out of tree driver.
I like the idea.
Some nit-picks here and there, but in general
Quoted 65 lines
This set consists of the following parts:
Patch 1 A bugfix for a recent change to the cio2-bridge code
Patches 2-8 Cleanup / preparation patches
Patch 9 Move the main body of thecio2-bridge.ccode into
a new shared intel-cio2-bridge module
Patch 10 Drop cio2-bridge code copy from atomisp, switching to
the shared intel-cio2-bridge module
Patch 11 Rework how VCM client instantiation is done so that
a device-link can be added from VCM to sensor to fix issues with the VCM power-state being tied to the sensor power state
Patch 12 Example patch to show how patch 11 avoids the need
for hacks in VCM drivers caused by the shared power state (not intended for merging)Regards,
Hans
Hans de Goede (12):
media: ipu3-cio2: Do not use on stack memory for software_node.name
field
media: ipu3-cio2: Move initialization of node_names.vcm to
cio2_bridge_init_swnode_names()
media: ipu3-cio2: Makecio2_bridge_init()take a regular struct device
as argument
media: ipu3-cio2: Store dev pointer in structcio2_bridge
media: ipu3-cio2: Only keep PLD around while parsing
media: ipu3-cio2: Add acio2_bridge_parse_sensor_fwnode()helper
function
media: ipu3-cio2: Add aparse_sensor_fwnodecallback tocio2_bridge_init() media: ipu3-cio2: Add supported_sensors parameter to cio2_bridge_init()media: ipu3-cio2: Move
cio2_bridge_init()code into a new shared
intel-cio2-bridge.ko
media: atomisp: csi2-bridge: Switch to new commoncio2_bridge_init()
media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and
sensor
[RFC] media: dw9719: Drop hack to enable "vsio" regulatorMAINTAINERS | 9 + drivers/media/common/Kconfig | 4 + drivers/media/common/Makefile | 1 + drivers/media/common/intel-cio2-bridge.c | 464 ++++++++++++++++++ drivers/media/i2c/dw9719.c | 27 +- drivers/media/pci/intel/ipu3/Kconfig | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 464 +++--------------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 146 ------ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 7 +- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 7 +- drivers/staging/media/atomisp/Kconfig | 2 + .../staging/media/atomisp/pci/atomisp_csi2.h | 67 --- .../media/atomisp/pci/atomisp_csi2_bridge.c | 307 ++---------- include/media/intel-cio2-bridge.h | 105 ++++ 14 files changed, 723 insertions(+), 888 deletions(-) create mode 100644 drivers/media/common/intel-cio2-bridge.c delete mode 100644 drivers/media/pci/intel/ipu3/cio2-bridge.h create mode 100644 include/media/intel-cio2-bridge.hSignature · 1 line
2.41.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hans,
Thanks for your patch.
------------------------------------------------------------------------
BRs,
Bingbu Cao
Quoted 27 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Wednesday, June 28, 2023 01:57
To: Sakari Ailus <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>
Cc: Hans de Goede <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Yao, Hao <[email protected]>; Cao, Bingbu <[email protected]>; [email protected]
Subject: [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2- bridge code, rework VCM instantiationHi All,
While working on adding (proper) VCM support to the atomisp code I found myself copying yet more code from
drivers/media/pci/intel/ipu3/cio2-bridge.cinto the atomisp code.So I decided that it really was time to factor out the common code (most of the code) from
intel/ipu3/cio2-bridge.cinto its own helper library and then share it between the atomisp and IPU3 code.This will hopefully also be useful for the ongoing work to upstream IPU6 input system support which also needs this functionality and currently contains a 3th copy of this code in the out of tree driver.
Quoted 6 lines
This set consists of the following parts:
Patch 1 A bugfix for a recent change to the cio2-bridge code
Patches 2-8 Cleanup / preparation patches
Patch 9 Move the main body of thecio2-bridge.ccode into
a new shared intel-cio2-bridge module
Another cio2-bridge patch - https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
I remember Sakari include it in the latest pull request.
Quoted 58 lines
Patch 10 Drop cio2-bridge code copy from atomisp, switching to
the shared intel-cio2-bridge module
Patch 11 Rework how VCM client instantiation is done so that
a device-link can be added from VCM to sensor to fix issues with the VCM power-state being tied to the sensor power state
Patch 12 Example patch to show how patch 11 avoids the need
for hacks in VCM drivers caused by the shared power state (not intended for merging)Regards,
Hans
Hans de Goede (12):
media: ipu3-cio2: Do not use on stack memory for software_node.name
field
media: ipu3-cio2: Move initialization of node_names.vcm to
cio2_bridge_init_swnode_names()
media: ipu3-cio2: Makecio2_bridge_init()take a regular struct device
as argument
media: ipu3-cio2: Store dev pointer in structcio2_bridge
media: ipu3-cio2: Only keep PLD around while parsing
media: ipu3-cio2: Add acio2_bridge_parse_sensor_fwnode()helper
function
media: ipu3-cio2: Add aparse_sensor_fwnodecallback to
cio2_bridge_init()
media: ipu3-cio2: Addsupported_sensorsparameter to
cio2_bridge_init()
media: ipu3-cio2: Movecio2_bridge_init()code into a new shared
intel-cio2-bridge.ko
media: atomisp: csi2-bridge: Switch to new commoncio2_bridge_init()
media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and
sensor
[RFC] media: dw9719: Drop hack to enable "vsio" regulatorMAINTAINERS | 9 + drivers/media/common/Kconfig | 4 + drivers/media/common/Makefile | 1 + drivers/media/common/intel-cio2-bridge.c | 464 ++++++++++++++++++ drivers/media/i2c/dw9719.c | 27 +- drivers/media/pci/intel/ipu3/Kconfig | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 464 +++--------------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 146 ------ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 7 +- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 7 +- drivers/staging/media/atomisp/Kconfig | 2 + .../staging/media/atomisp/pci/atomisp_csi2.h | 67 --- .../media/atomisp/pci/atomisp_csi2_bridge.c | 307 ++---------- include/media/intel-cio2-bridge.h | 105 ++++ 14 files changed, 723 insertions(+), 888 deletions(-) create mode 100644
drivers/media/common/intel-cio2-bridge.c
delete mode 100644drivers/media/pci/intel/ipu3/cio2-bridge.hcreate mode 100644include/media/intel-cio2-bridge.h--
2.41.0
Hi Bingbu,
Quoted 37 lines · Bingbu
Hans,
Thanks for your patch.
------------------------------------------------------------------------
BRs,
Bingbu CaoQuoted 29 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Wednesday, June 28, 2023 01:57
To: Sakari Ailus <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>
Cc: Hans de Goede <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Yao, Hao <[email protected]>; Cao, Bingbu <[email protected]>; [email protected]
Subject: [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2- bridge code, rework VCM instantiationHi All,
While working on adding (proper) VCM support to the atomisp code I found myself copying yet more code from
drivers/media/pci/intel/ipu3/cio2-bridge.cinto the atomisp code.So I decided that it really was time to factor out the common code (most of the code) from
intel/ipu3/cio2-bridge.cinto its own helper library and then share it between the atomisp and IPU3 code.This will hopefully also be useful for the ongoing work to upstream IPU6 input system support which also needs this functionality and currently contains a 3th copy of this code in the out of tree driver.
This set consists of the following parts:
Quoted 7 lines
Quoted 4 lines
Patch 1 A bugfix for a recent change to the cio2-bridge code
Patches 2-8 Cleanup / preparation patches
Patch 9 Move the main body of thecio2-bridge.ccode into
a new shared intel-cio2-bridge moduleAnother cio2-bridge patch - https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
I remember Sakari include it in the latest pull request.
Ah, yes looks like I need to rebase this on top of that patch, as Dan also mentioned in another reply.
But I don't see this patch in media-staging yet:
https://git.linuxtv.org/media_stage.git/log/
Is there a branch for the pull-request on which I can rebase this available somewhere ?
Regards,
Hans
Quoted 60 lines
Quoted 59 lines
Patch 10 Drop cio2-bridge code copy from atomisp, switching to
the shared intel-cio2-bridge module
Patch 11 Rework how VCM client instantiation is done so that
a device-link can be added from VCM to sensor to fix issues with the VCM power-state being tied to the sensor power state
Patch 12 Example patch to show how patch 11 avoids the need
for hacks in VCM drivers caused by the shared power state (not intended for merging)Regards,
Hans
Hans de Goede (12):
media: ipu3-cio2: Do not use on stack memory for software_node.name
field
media: ipu3-cio2: Move initialization of node_names.vcm to
cio2_bridge_init_swnode_names()
media: ipu3-cio2: Makecio2_bridge_init()take a regular struct device
as argument
media: ipu3-cio2: Store dev pointer in structcio2_bridge
media: ipu3-cio2: Only keep PLD around while parsing
media: ipu3-cio2: Add acio2_bridge_parse_sensor_fwnode()helper
function
media: ipu3-cio2: Add aparse_sensor_fwnodecallback to
cio2_bridge_init()
media: ipu3-cio2: Addsupported_sensorsparameter to
cio2_bridge_init()
media: ipu3-cio2: Movecio2_bridge_init()code into a new shared
intel-cio2-bridge.ko
media: atomisp: csi2-bridge: Switch to new commoncio2_bridge_init()
media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and
sensor
[RFC] media: dw9719: Drop hack to enable "vsio" regulatorMAINTAINERS | 9 + drivers/media/common/Kconfig | 4 + drivers/media/common/Makefile | 1 + drivers/media/common/intel-cio2-bridge.c | 464 ++++++++++++++++++ drivers/media/i2c/dw9719.c | 27 +- drivers/media/pci/intel/ipu3/Kconfig | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 464 +++--------------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 146 ------ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 7 +- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 7 +- drivers/staging/media/atomisp/Kconfig | 2 + .../staging/media/atomisp/pci/atomisp_csi2.h | 67 --- .../media/atomisp/pci/atomisp_csi2_bridge.c | 307 ++---------- include/media/intel-cio2-bridge.h | 105 ++++ 14 files changed, 723 insertions(+), 888 deletions(-) create mode 100644
drivers/media/common/intel-cio2-bridge.c
delete mode 100644drivers/media/pci/intel/ipu3/cio2-bridge.hcreate mode 100644include/media/intel-cio2-bridge.h--
2.41.0
Hans,
------------------------------------------------------------------------
BRs,
Bingbu Cao
Quoted 65 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Wednesday, June 28, 2023 21:57
To: Cao, Bingbu <[email protected]>; Sakari Ailus <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Yao, Hao <[email protected]>; [email protected]
Subject: Re: [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2- bridge code, rework VCM instantiationHi Bingbu,
Quoted 44 lines · Bingbu
Hans,
Thanks for your patch.
----------------------------------------------------------------------
--
BRs,
Bingbu CaoQuoted 28 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Wednesday, June 28, 2023 01:57
To: Sakari Ailus <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>
Cc: Hans de Goede <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Yao, Hao <[email protected]>; Cao, Bingbu <[email protected]>; [email protected]
Subject: [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2- bridge code, rework VCM instantiationHi All,
While working on adding (proper) VCM support to the atomisp code I found myself copying yet more code from
drivers/media/pci/intel/ipu3/cio2-bridge.cinto the atomisp code.So I decided that it really was time to factor out the common code (most of the code) from
intel/ipu3/cio2-bridge.cinto its own helper library and then share it between the atomisp and IPU3 code.This will hopefully also be useful for the ongoing work to upstream IPU6 input system support which also needs this functionality and currently contains a 3th copy of this code in the out of tree driver.
Quoted 6 lines
This set consists of the following parts:
Patch 1 A bugfix for a recent change to the cio2-bridge code
Patches 2-8 Cleanup / preparation patches
Patch 9 Move the main body of thecio2-bridge.ccode into
a new shared intel-cio2-bridge moduleQuoted 4 lines
Another cio2-bridge patch -
https://patchwork.kernel.org/project/linux-media/patch/20230517103004.
[email protected]/ I remember Sakari include it in the latest pull request.
Quoted 8 lines
Ah, yes looks like I need to rebase this on top of that patch, as Dan also mentioned in another reply.
But I don't see this patch in media-staging yet:
https://git.linuxtv.org/media_stage.git/log/Is there a branch for the pull-request on which I can rebase this available somewhere ?
I see they are in Sakari's repo -
https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-6.6-1.4-signed
Quoted 68 lines
Regards,
Hans
Quoted 60 lines
Quoted 59 lines
Patch 10 Drop cio2-bridge code copy from atomisp, switching to
the shared intel-cio2-bridge module
Patch 11 Rework how VCM client instantiation is done so that
a device-link can be added from VCM to sensor to fix issues with the VCM power-state being tied to the sensor power state
Patch 12 Example patch to show how patch 11 avoids the need
for hacks in VCM drivers caused by the shared power state (not intended for merging)Regards,
Hans
Hans de Goede (12):
media: ipu3-cio2: Do not use on stack memory for software_node.name
field
media: ipu3-cio2: Move initialization of node_names.vcm to
cio2_bridge_init_swnode_names()
media: ipu3-cio2: Makecio2_bridge_init()take a regular struct device
as argument
media: ipu3-cio2: Store dev pointer in structcio2_bridge
media: ipu3-cio2: Only keep PLD around while parsing
media: ipu3-cio2: Add acio2_bridge_parse_sensor_fwnode()helper
function
media: ipu3-cio2: Add aparse_sensor_fwnodecallback to
cio2_bridge_init()
media: ipu3-cio2: Addsupported_sensorsparameter to
cio2_bridge_init()
media: ipu3-cio2: Movecio2_bridge_init()code into a new shared
intel-cio2-bridge.ko
media: atomisp: csi2-bridge: Switch to new commoncio2_bridge_init()
media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and
sensor
[RFC] media: dw9719: Drop hack to enable "vsio" regulatorMAINTAINERS | 9 + drivers/media/common/Kconfig | 4 + drivers/media/common/Makefile | 1 + drivers/media/common/intel-cio2-bridge.c | 464 ++++++++++++++++++ drivers/media/i2c/dw9719.c | 27 +- drivers/media/pci/intel/ipu3/Kconfig | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 464 +++--------------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 146 ------ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 7 +- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 7 +- drivers/staging/media/atomisp/Kconfig | 2 + .../staging/media/atomisp/pci/atomisp_csi2.h | 67 --- .../media/atomisp/pci/atomisp_csi2_bridge.c | 307 ++---------- include/media/intel-cio2-bridge.h | 105 ++++ 14 files changed, 723 insertions(+), 888 deletions(-) create mode100644
drivers/media/common/intel-cio2-bridge.cdelete mode 100644drivers/media/pci/intel/ipu3/cio2-bridge.hcreate mode 100644include/media/intel-cio2-bridge.h--
2.41.0
Hi,
Quoted 75 lines · Bingbu
Hans,
------------------------------------------------------------------------
BRs,
Bingbu CaoQuoted 68 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Wednesday, June 28, 2023 21:57
To: Cao, Bingbu <[email protected]>; Sakari Ailus <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Yao, Hao <[email protected]>; [email protected]
Subject: Re: [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2- bridge code, rework VCM instantiationHi Bingbu,
Quoted 44 lines · Bingbu
Hans,
Thanks for your patch.
----------------------------------------------------------------------
--
BRs,
Bingbu CaoQuoted 28 lines
-----Original Message-----
From: Hans de Goede <[email protected]>
Sent: Wednesday, June 28, 2023 01:57
To: Sakari Ailus <[email protected]>; Laurent Pinchart <[email protected]>; Daniel Scally <[email protected]>
Cc: Hans de Goede <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Andy Shevchenko <[email protected]>; Kate Hsuan <[email protected]>; Yao, Hao <[email protected]>; Cao, Bingbu <[email protected]>; [email protected]
Subject: [PATCH 00/12] media: intel-cio2-bridge: Add shared intel-cio2- bridge code, rework VCM instantiationHi All,
While working on adding (proper) VCM support to the atomisp code I found myself copying yet more code from
drivers/media/pci/intel/ipu3/cio2-bridge.cinto the atomisp code.So I decided that it really was time to factor out the common code (most of the code) from
intel/ipu3/cio2-bridge.cinto its own helper library and then share it between the atomisp and IPU3 code.This will hopefully also be useful for the ongoing work to upstream IPU6 input system support which also needs this functionality and currently contains a 3th copy of this code in the out of tree driver.
Quoted 6 lines
This set consists of the following parts:
Patch 1 A bugfix for a recent change to the cio2-bridge code
Patches 2-8 Cleanup / preparation patches
Patch 9 Move the main body of thecio2-bridge.ccode into
a new shared intel-cio2-bridge moduleQuoted 4 lines
Another cio2-bridge patch -
https://patchwork.kernel.org/project/linux-media/patch/20230517103004.
[email protected]/ I remember Sakari include it in the latest pull request.Ah, yes looks like I need to rebase this on top of that patch, as Dan also mentioned in another reply.
Quoted 8 lines
Quoted 5 lines
But I don't see this patch in media-staging yet:
https://git.linuxtv.org/media_stage.git/log/Is there a branch for the pull-request on which I can rebase this available somewhere ?
I see they are in Sakari's repo -
https://git.linuxtv.org/sailus/media_tree.git/log/?h=for-6.6-1.4-signed
Thank you.
I'll rebase and send out a new version.
Regards,
Hans
Quoted 60 lines
Quoted 59 lines
Quoted 59 lines
Quoted 58 lines
Patch 10 Drop cio2-bridge code copy from atomisp, switching to
the shared intel-cio2-bridge module
Patch 11 Rework how VCM client instantiation is done so that
a device-link can be added from VCM to sensor to fix issues with the VCM power-state being tied to the sensor power state
Patch 12 Example patch to show how patch 11 avoids the need
for hacks in VCM drivers caused by the shared power state (not intended for merging)Regards,
Hans
Hans de Goede (12):
media: ipu3-cio2: Do not use on stack memory for software_node.name
field
media: ipu3-cio2: Move initialization of node_names.vcm to
cio2_bridge_init_swnode_names()
media: ipu3-cio2: Makecio2_bridge_init()take a regular struct device
as argument
media: ipu3-cio2: Store dev pointer in structcio2_bridge
media: ipu3-cio2: Only keep PLD around while parsing
media: ipu3-cio2: Add acio2_bridge_parse_sensor_fwnode()helper
function
media: ipu3-cio2: Add aparse_sensor_fwnodecallback to
cio2_bridge_init()
media: ipu3-cio2: Addsupported_sensorsparameter to
cio2_bridge_init()
media: ipu3-cio2: Movecio2_bridge_init()code into a new shared
intel-cio2-bridge.ko
media: atomisp: csi2-bridge: Switch to new commoncio2_bridge_init()
media: intel-cio2-bridge: Add a runtime-pm device-link between VCM and
sensor
[RFC] media: dw9719: Drop hack to enable "vsio" regulatorMAINTAINERS | 9 + drivers/media/common/Kconfig | 4 + drivers/media/common/Makefile | 1 + drivers/media/common/intel-cio2-bridge.c | 464 ++++++++++++++++++ drivers/media/i2c/dw9719.c | 27 +- drivers/media/pci/intel/ipu3/Kconfig | 1 + drivers/media/pci/intel/ipu3/cio2-bridge.c | 464 +++--------------- drivers/media/pci/intel/ipu3/cio2-bridge.h | 146 ------ drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 7 +- drivers/media/pci/intel/ipu3/ipu3-cio2.h | 7 +- drivers/staging/media/atomisp/Kconfig | 2 + .../staging/media/atomisp/pci/atomisp_csi2.h | 67 --- .../media/atomisp/pci/atomisp_csi2_bridge.c | 307 ++---------- include/media/intel-cio2-bridge.h | 105 ++++ 14 files changed, 723 insertions(+), 888 deletions(-) create mode100644
drivers/media/common/intel-cio2-bridge.cdelete mode 100644drivers/media/pci/intel/ipu3/cio2-bridge.hcreate mode 100644include/media/intel-cio2-bridge.h--
2.41.0
Sakari Ailus
maintainerHi Hans,
Quoted 10 lines · Hans de Goede
Hi All,
While working on adding (proper) VCM support to the atomisp code I found myself copying yet more code from
drivers/media/pci/intel/ipu3/cio2-bridge.cinto the atomisp code.So I decided that it really was time to factor out the common code (most of the code) from
intel/ipu3/cio2-bridge.cinto its own helper library and then share it between the atomisp and IPU3 code.
Quoted 5 lines
This will hopefully also be useful for the ongoing work to upstream IPU6 input system support which also needs this functionality and currently contains a 3th copy of this code in the out of tree driver.
This set consists of the following parts:
Thanks for the set.
It's indeed being renamed. Wentong wrote a patch to add IVSC support, it should go in after these.
Signature · 3 lines
Regards, Sakari Ailus