Skip to contentSkip to conversation

Add Sony IMX471 camera sensor driver

PATCH In review Kate Hsuan 4 participants 18 messages Jun 29 – Jul 8

Subsystems (5)
lore
Share & tools
lore

Kate Hsuan

author maintainer
#0 lore raw

v6 cover Add Sony IMX471 camera sensor driver

This patchset adds the Sony IMX471 camera sensor driver to the Linux kernel and resolves the IPU7 camera can't work issueon Lenovo X9 laptops [1].

The patchset contains two patches:
1. Add DMI information of Lenovo X9 to the image upside-down list
2. Add Sony IMX471 image sensor driver

The IMX471 driver can be found in the Intel ipu6-drivers repository [2]. To comply with the sensor driver implementation, the clean-up work includes:

1. Use CCI register helpers.

2. Enable and disable streams using enable_streams and disable_streams functions in struct v4l2_subdev_pad_ops. Invoke v4l2_subdev_s_stream_helper() to manage the streaming state.

3. Get rotation information from fwnode properties using v4l2_fwnode_device_parse().

4. Finalizes the initialization of the subdev, including allocation of the active state using v4l2_subdev_init_finalize().

5. Add the IMX471 driver to the Makefile and Kconfig file.

6. The mutex lock is managed by the V4l2 core.

7. Replace the supported link frequency with v4l2_link_freq_to_bitmap().

8. Drop unused codes.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=2454119
[2] https://github.com/intel/ipu6-drivers/commits/master/drivers/media/i2c/imx471.c

Changes in v6:
1. Add the con_id "vana" for the power enable to the int3472_gpio_map table.
2. Drop unnecessary macros.
3. Name the registers.

Changes in v5:
1. Add a description for the DMI_BOARD_NAME in the ipu-bridge driver.
2. Check the numbers of MIPI lanes. The driver only support 4 lanes mode.
3. Fix many rumetime PM issues.
4. Drop pixel_rate control variable.
5. Drop unnecessary comments.
6. Name the registers.
7. Fix a leak in imx471_init_controls().

Changes in v4:
1. Add TBE20A0 (found on Lenovo X1 Carbon G14) to the supported sensors list.
2. Revert the sensor upside-down list to v1.
3. Decrease the max analog gain to 800 to mitigate the image flickering problem.
4. Return the error value when __v4l2_ctrl_modify_range() fails.
5. Fix indentation issue in Kconfig.
6. Fix the cci error value issue.
7. Drop unnecessary comments.
8. Drop unused link_freq control variable.

Changes in v3:
1. Naming the register addresses and set up the value with the correct value length.
2. Implement the .get_selection().
3. Drop "identified" field from struct imx471.
4. Drop "streaming" field from struct imx471 and use the __v4l2_ctrl_grab() instead.
5. Moreover, The naming for the register can be found in a seperated patch. If we agree with the patch, I will squash it into one patch.

Changes in v2:
1. Change the Bayer format setting according to the vertical and horizontal flip settings.
2. Replace the self-owned mutex with the v4l2 subdev state.
3. Rework the flip control.
4. Manage the regulators using devm_regulator_bulk_get|disable|enbale API
5. Invoke devm_v4l2_sensor_clk_get to get clock-frequency

Kate Hsuan (4):
media: ipu-bridge: Add DMI information of Lenovo X9 to the image
upside-down list
media: ipu-bridge: Add Sony IMX471 for Lenovo X1 Carbon G14
platform: int3472: discrete: con_id vana for Sony IMX471 as power
enable
media: i2c: imx471: Add Sony IMX471 image sensor driver

 MAINTAINERS                                   |   6 +
 drivers/media/i2c/Kconfig                     |  10 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/imx471.c                    | 957 ++++++++++++++++++
 drivers/media/pci/intel/ipu-bridge.c          |  41 +
 drivers/platform/x86/intel/int3472/discrete.c |  18 +
 6 files changed, 1033 insertions(+)
 create mode 100644 drivers/media/i2c/imx471.c
Signature · 1 line
2.54.0
author maintainer
#1 lore raw

PATCH v6 1/4 media: ipu-bridge: Add DMI information of Lenovo X9 to the image upside-down list

The Lenovo X9 has an upside-down-mounted Sony IMX471 sensor so the image was displayed upside-down. Add the DMI information of Lenovo X9 to resolve the issue.

---
 drivers/media/pci/intel/ipu-bridge.c | 39 ++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +39 -0
index 88581a4c081d..2474452b3015 100644
@@ -134,6 +134,45 @@ static const struct dmi_system_id upside_down_sensor_dmi_ids[] = {
 		},
 		.driver_data = "OVTI02C1",
 	},
+	/*
+	 * The first four characters of DMI_BOARD_NAME identify the Lenovo
+	 * machine type/model. For example, a DMI_BOARD_NAME starting with
+	 * "21Q6" indicates a ThinkPad X9-15.
+	 *
+	 * Reference: https://psref.lenovo.com/
+	 */
+	{
+		/* Lenovo X9-14 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_BOARD_NAME, "21QA"),
+		},
+		.driver_data = "SONY471A",
+	},
+	{
+		/* Lenovo X9-14 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_BOARD_NAME, "21QB"),
+		},
+		.driver_data = "SONY471A",
+	},
+	{
+		/* Lenovo X9-15 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_BOARD_NAME, "21Q6"),
+		},
+		.driver_data = "SONY471A",
+	},
+	{
+		/* Lenovo X9-15 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+			DMI_MATCH(DMI_BOARD_NAME, "21Q7"),
+		},
+		.driver_data = "SONY471A",
+	},
 	{} /* Terminating entry */
 };
 
Signature · 1 line
2.54.0
author maintainer
#2 lore raw

PATCH v6 2/4 media: ipu-bridge: Add Sony IMX471 for Lenovo X1 Carbon G14

In reply to Kate Hsuan

The HID for Sony IMX471 is TBE20A0 on Lenovo X1 Carbon G14.

---
 drivers/media/pci/intel/ipu-bridge.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/pci/intel/ipu-bridge.c +2 -0
index 2474452b3015..8ddfab357922 100644
@@ -97,6 +97,8 @@ static const struct ipu_sensor_config ipu_supported_sensors[] = {
 	IPU_SENSOR_CONFIG("OVTI8856", 3, 180000000, 360000000, 720000000),
 	/* Sony IMX471 */
 	IPU_SENSOR_CONFIG("SONY471A", 1, 200000000),
+	/* Sony IMX471 (found on Lenovo X1 Carbon G14) */
+	IPU_SENSOR_CONFIG("TBE20A0", 1, 200000000),
 	/* Toshiba T4KA3 */
 	IPU_SENSOR_CONFIG("XMCC0003", 1, 321468000),
 };
Signature · 1 line
2.54.0
author maintainer
#3 lore raw

PATCH v6 3/4 platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

In reply to Kate Hsuan

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

---
 drivers/platform/x86/intel/int3472/discrete.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/platform/x86/intel/int3472/discrete.c +18 -0
index 115bb37577a1..adff564bf3fd 100644
@@ -164,6 +164,24 @@ static const struct int3472_gpio_map int3472_gpio_map[] = {
 		.con_id = "dvdd",
 		.enable_time_us = 45 * USEC_PER_MSEC,
 	},
+	{	/* imx471 expects "vana" as con_id for power enable */
+		.hid = "SONY471A",
+		.type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
+		.type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
+		.con_id = "vana",
+		.enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
+	},
+	{
+		/*
+		 * imx471 (on Lenovo ThinkPads X1 G14) expects "vana" as con_id
+		 * for power enable
+		 */
+		.hid = "TBE20A0",
+		.type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
+		.type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
+		.con_id = "vana",
+		.enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
+	},
 };
 
 static void int3472_get_con_id_and_polarity(struct int3472_discrete_device *int3472, u8 *type,
Signature · 1 line
2.54.0
Reviewed-by on v6 3/4
#4 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Kate,

Quoted 6 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Thanks, looks good.

Best Regards,
Tarang

Quoted 35 lines
---
 drivers/platform/x86/intel/int3472/discrete.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/platform/x86/intel/int3472/discrete.c +18 -1
index 115bb37577a1..adff564bf3fd 100644
@@ -164,6 +164,24 @@ static const struct int3472_gpio_map int3472_gpio_map[] = {
                .con_id = "dvdd",
                .enable_time_us = 45 * USEC_PER_MSEC,
        },
+       {       /* imx471 expects "vana" as con_id for power enable */
+               .hid = "SONY471A",
+               .type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .con_id = "vana",
+               .enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
+       },
+       {
+               /*
+                * imx471 (on Lenovo ThinkPads X1 G14) expects "vana" as con_id
+                * for power enable
+                */
+               .hid = "TBE20A0",
+               .type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .con_id = "vana",
+               .enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
+       },
 };
 
 static void int3472_get_con_id_and_polarity(struct int3472_discrete_device *int3472, u8 *type,
--

2.54.0

maintainer
#5 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi All,

Quoted 7 lines · Tarang Raval

Hi Kate,

Quoted 5 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Quoted 5 lines
Quoted 1 line

Thanks, looks good.

Hmm, the imx471 driver is still pending upstream:

https://lore.kernel.org/linux-media/[email protected]/

As part of this series.

Please just use the standardized "avdd" in that driver instead of "vana" (which also seems to refer to the analog supply vdd, which is what avdd stands for).

Then this whole patch is unnecessary and can be dropped from this series.

Regards,

Hans

Quoted 35 lines
Quoted 35 lines
---
 drivers/platform/x86/intel/int3472/discrete.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/platform/x86/intel/int3472/discrete.c +18 -1
index 115bb37577a1..adff564bf3fd 100644
@@ -164,6 +164,24 @@ static const struct int3472_gpio_map int3472_gpio_map[] = {
                .con_id = "dvdd",
                .enable_time_us = 45 * USEC_PER_MSEC,
        },
+       {       /* imx471 expects "vana" as con_id for power enable */
+               .hid = "SONY471A",
+               .type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .con_id = "vana",
+               .enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
+       },
+       {
+               /*
+                * imx471 (on Lenovo ThinkPads X1 G14) expects "vana" as con_id
+                * for power enable
+                */
+               .hid = "TBE20A0",
+               .type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
+               .con_id = "vana",
+               .enable_time_us = GPIO_REGULATOR_ENABLE_TIME,
+       },
 };
 
 static void int3472_get_con_id_and_polarity(struct int3472_discrete_device *int3472, u8 *type,
--

2.54.0

#6 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Hans,

Quoted 18 lines · Tarang Raval
Quoted 7 lines

Hi Kate,

Quoted 5 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Quoted 5 lines
Quoted 1 line

Thanks, looks good.

Hmm, the imx471 driver is still pending upstream:

https://lore.kernel.org/linux-media/[email protected]/

Quoted 8 lines

As part of this series.

Please just use the standardized "avdd" in that driver instead of "vana" (which also seems to refer to the analog supply vdd, which is what avdd stands for).

Then this whole patch is unnecessary and can be dropped from this series.

The regulator name "vana" comes directly from the Sony IMX471 sensor datasheet, which typically refers to the analog supply voltage. Using the datasheet name helps keep the driver consistent with the hardware documentation and makes it easier to cross-reference.

as per my understanding, the more standardized way is to use the regulator name as per the sensor datasheet. Therefore, I respectfully disagree with your suggestion.

Best Regards,
Tarang

maintainer
#7 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi,

Quoted 29 lines · Tarang Raval

Hi Hans,

Quoted 18 lines · Tarang Raval
Quoted 7 lines

Hi Kate,

Quoted 5 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Quoted 5 lines
Quoted 1 line

Thanks, looks good.

Hmm, the imx471 driver is still pending upstream:

https://lore.kernel.org/linux-media/[email protected]/

Quoted 8 lines

As part of this series.

Please just use the standardized "avdd" in that driver instead of "vana" (which also seems to refer to the analog supply vdd, which is what avdd stands for).

Then this whole patch is unnecessary and can be dropped from this series.

Quoted 8 lines

The regulator name "vana" comes directly from the Sony IMX471 sensor datasheet, which typically refers to the analog supply voltage. Using the datasheet name helps keep the driver consistent with the hardware documentation and makes it easier to cross-reference.

as per my understanding, the more standardized way is to use the regulator name as per the sensor datasheet. Therefore, I respectfully disagree with your suggestion.

As shown by the need for this patch on x86 at least because there is no devicetree it greatly helps if all Linux sensor drivers use standardized names for their regulators rather then using the exact name from the datasheet which often is not very consistent.

And "avdd" is the name we've standardized on for this, so lets use that:

hans@shalem:~/projects/linux$ grep -l '"vana"' drivers/media/i2c/*.c | wc -l
4
hans@shalem:~/projects/linux$ grep -l '"avdd"' drivers/media/i2c/*.c | wc -l
36

The alternative is needing to add more and more quirks as different sensors are used, which is not great.

Regards,

Hans

maintainer
#8 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Hans,

Quoted 48 lines · Hans de Goede

Hi,

Quoted 29 lines · Tarang Raval

Hi Hans,

Quoted 18 lines · Tarang Raval
Quoted 7 lines

Hi Kate,

Quoted 5 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Quoted 5 lines
Quoted 1 line

Thanks, looks good.

Hmm, the imx471 driver is still pending upstream:

https://lore.kernel.org/linux-media/[email protected]/

Quoted 8 lines

As part of this series.

Please just use the standardized "avdd" in that driver instead of "vana" (which also seems to refer to the analog supply vdd, which is what avdd stands for).

Then this whole patch is unnecessary and can be dropped from this series.

Quoted 8 lines

The regulator name "vana" comes directly from the Sony IMX471 sensor datasheet, which typically refers to the analog supply voltage. Using the datasheet name helps keep the driver consistent with the hardware documentation and makes it easier to cross-reference.

as per my understanding, the more standardized way is to use the regulator name as per the sensor datasheet. Therefore, I respectfully disagree with your suggestion.

As shown by the need for this patch on x86 at least because there is no devicetree it greatly helps if all Linux sensor drivers use standardized names for their regulators rather then using the exact name from the datasheet which often is not very consistent.

And "avdd" is the name we've standardized on for this, so lets use that:

Quoted 7 lines
hans@shalem:~/projects/linux$ grep -l '"vana"' drivers/media/i2c/*.c | wc -l
4
hans@shalem:~/projects/linux$ grep -l '"avdd"' drivers/media/i2c/*.c | wc -l
36

The alternative is needing to add more and more quirks as different sensors are used, which is not great.

I do agree that having a constant name for the regulators would be beneficial for the int3472 driver. Still, if, and presumably, when that sensor gets DT support, the bindings will use the regulator name from the datasheet.

Let's just use the datasheet name now and add the few lines needed to the int3472 driver and avoid the churn in the future. There's a limited number of sensor drivers that need this after all.

I'd be more concerned of what's going on in tps68470_board_data.c for instance.

Signature · 3 lines
Kind regards,

Sakari Ailus
#9 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Hans, Sakari

Quoted 62 lines · Hans de Goede
Quoted 48 lines

Hi,

Quoted 29 lines · Tarang Raval

Hi Hans,

Quoted 18 lines · Tarang Raval
Quoted 7 lines

Hi Kate,

Quoted 5 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Quoted 5 lines
Quoted 1 line

Thanks, looks good.

Hmm, the imx471 driver is still pending upstream:

https://lore.kernel.org/linux-media/[email protected]/

Quoted 8 lines

As part of this series.

Please just use the standardized "avdd" in that driver instead of "vana" (which also seems to refer to the analog supply vdd, which is what avdd stands for).

Then this whole patch is unnecessary and can be dropped from this series.

Quoted 8 lines

The regulator name "vana" comes directly from the Sony IMX471 sensor datasheet, which typically refers to the analog supply voltage. Using the datasheet name helps keep the driver consistent with the hardware documentation and makes it easier to cross-reference.

as per my understanding, the more standardized way is to use the regulator name as per the sensor datasheet. Therefore, I respectfully disagree with your suggestion.

As shown by the need for this patch on x86 at least because there is no devicetree it greatly helps if all Linux sensor drivers use standardized names for their regulators rather then using the exact name from the datasheet which often is not very consistent.

And "avdd" is the name we've standardized on for this, so lets use that:

Quoted 7 lines
hans@shalem:~/projects/linux$ grep -l '"vana"' drivers/media/i2c/*.c | wc -l
4
hans@shalem:~/projects/linux$ grep -l '"avdd"' drivers/media/i2c/*.c | wc -l
36

The alternative is needing to add more and more quirks as different sensors are used, which is not great.

I do agree that having a constant name for the regulators would be beneficial for the int3472 driver. Still, if, and presumably, when that sensor gets DT support, the bindings will use the regulator name from the datasheet.

Quoted 6 lines

Let's just use the datasheet name now and add the few lines needed to the int3472 driver and avoid the churn in the future. There's a limited number of sensor drivers that need this after all.

I'd be more concerned of what's going on in tps68470_board_data.c for instance.

I went through the INT3472 driver and would like to propose a generic approach that satisfies both sides without per-HID quirks or sensor driver changes.

The problem is:
- INT3472 standardizes on "avdd" internally
- Sony IMX sensor drivers use "vana" per datasheet, and all existing Sony DT bindings (imx219, imx290, imx415) already use vana-supply
- Changing imx471 to "avdd" now will create inconsistency with those bindings, or require a rename later

Instead of fixing this per-sensor (either by changing the driver or adding a per-HID entry to int3472_gpio_map), we can add a small vendor alias table inside skl_int3472_register_regulator().

Currently that function registers two consumer supply entries per sensor:
lowercase ("avdd") and uppercase ("AVDD"). We can extend it to also register vendor datasheet aliases from a static table, e.g.:

avdd -> vana (Sony IMX series: imx219, imx290, imx415, imx471, ...)

This way, when a sensor driver requests "vana", the regulator framework finds it in the supply map without any extra quirks.

Best Regards,
Tarang

maintainer
#10 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi,

Quoted 75 lines · Tarang Raval

Hi Hans, Sakari

Quoted 62 lines · Hans de Goede
Quoted 48 lines

Hi,

Quoted 29 lines · Tarang Raval

Hi Hans,

Quoted 18 lines · Tarang Raval
Quoted 7 lines

Hi Kate,

Quoted 5 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Quoted 5 lines
Quoted 1 line

Thanks, looks good.

Hmm, the imx471 driver is still pending upstream:

https://lore.kernel.org/linux-media/[email protected]/

Quoted 8 lines

As part of this series.

Please just use the standardized "avdd" in that driver instead of "vana" (which also seems to refer to the analog supply vdd, which is what avdd stands for).

Then this whole patch is unnecessary and can be dropped from this series.

Quoted 8 lines

The regulator name "vana" comes directly from the Sony IMX471 sensor datasheet, which typically refers to the analog supply voltage. Using the datasheet name helps keep the driver consistent with the hardware documentation and makes it easier to cross-reference.

as per my understanding, the more standardized way is to use the regulator name as per the sensor datasheet. Therefore, I respectfully disagree with your suggestion.

As shown by the need for this patch on x86 at least because there is no devicetree it greatly helps if all Linux sensor drivers use standardized names for their regulators rather then using the exact name from the datasheet which often is not very consistent.

And "avdd" is the name we've standardized on for this, so lets use that:

Quoted 7 lines
hans@shalem:~/projects/linux$ grep -l '"vana"' drivers/media/i2c/*.c | wc -l
4
hans@shalem:~/projects/linux$ grep -l '"avdd"' drivers/media/i2c/*.c | wc -l
36

The alternative is needing to add more and more quirks as different sensors are used, which is not great.

I do agree that having a constant name for the regulators would be beneficial for the int3472 driver. Still, if, and presumably, when that sensor gets DT support, the bindings will use the regulator name from the datasheet.

Quoted 6 lines

Let's just use the datasheet name now and add the few lines needed to the int3472 driver and avoid the churn in the future. There's a limited number of sensor drivers that need this after all.

I'd be more concerned of what's going on in tps68470_board_data.c for instance.

I went through the INT3472 driver and would like to propose a generic approach that satisfies both sides without per-HID quirks or sensor driver changes.

Quoted 6 lines

The problem is:
- INT3472 standardizes on "avdd" internally
- Sony IMX sensor drivers use "vana" per datasheet, and all existing Sony DT bindings (imx219, imx290, imx415) already use vana-supply
- Changing imx471 to "avdd" now will create inconsistency with those bindings, or require a rename later

Ack, as mentioned in my reply to Sakari from 1 minute ago I'm ok with sticking with vana for the imx* case,

Quoted 4 lines

Instead of fixing this per-sensor (either by changing the driver or adding a per-HID entry to int3472_gpio_map), we can add a small vendor alias table inside skl_int3472_register_regulator().

Quoted 8 lines

Currently that function registers two consumer supply entries per sensor:
lowercase ("avdd") and uppercase ("AVDD"). We can extend it to also register vendor datasheet aliases from a static table, e.g.:

avdd -> vana (Sony IMX series: imx219, imx290, imx415, imx471, ...)

This way, when a sensor driver requests "vana", the regulator framework finds it in the supply map without any extra quirks.

Interesting proposal. For now I think just going with the quirk from this patch is fine. But if we get more Sony sensors doing what you suggests might make sense.

IIRC currently all regulators get an upper-cased alias to avoid needing quirks just for the case where drivers only differ in case.

Special casing avdd is going to require adding special code to the generic bits. Or maybe just an alt_name parameter ? Either way I think for just the one sensor the quirk is fine. But if we get more (which is somewhat likely) then your suggestion is probably a good idea.

Regards,

Hans

maintainer
#11 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Hans, Tarang,

Quoted 11 lines · Hans de Goede
Quoted 10 lines

I went through the INT3472 driver and would like to propose a generic approach that satisfies both sides without per-HID quirks or sensor driver changes.

The problem is:
- INT3472 standardizes on "avdd" internally
- Sony IMX sensor drivers use "vana" per datasheet, and all existing Sony DT bindings (imx219, imx290, imx415) already use vana-supply
- Changing imx471 to "avdd" now will create inconsistency with those bindings, or require a rename later

Quoted 2 lines

Ack, as mentioned in my reply to Sakari from 1 minute ago I'm ok with sticking with vana for the imx* case,

At least some Sony sensors use "INT" PnP vendor prefix and so telling them apart from the rest doesn't work at least this way. There could also be other prefixes as well, they're not all "SONY". Right now there is one with INT prefix and three with SONY prefix.

If we start having lots of devices with the same quirk, we could also introduce a pointer to an array of IDs to avoid repeating the same quirk over and over.

Kate's patch adds two quirks so this could be already considered (and only one of these IDs is using SONY prefix).

Signature · 3 lines
Regards,

Sakari Ailus
#12 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Sakari,

Quoted 20 lines · Hans de Goede
Quoted 11 lines
Quoted 10 lines

I went through the INT3472 driver and would like to propose a generic approach that satisfies both sides without per-HID quirks or sensor driver changes.

The problem is:
- INT3472 standardizes on "avdd" internally
- Sony IMX sensor drivers use "vana" per datasheet, and all existing Sony DT bindings (imx219, imx290, imx415) already use vana-supply
- Changing imx471 to "avdd" now will create inconsistency with those bindings, or require a rename later

Quoted 2 lines

Ack, as mentioned in my reply to Sakari from 1 minute ago I'm ok with sticking with vana for the imx* case,

At least some Sony sensors use "INT" PnP vendor prefix and so telling them apart from the rest doesn't work at least this way. There could also be other prefixes as well, they're not all "SONY". Right now there is one with INT prefix and three with SONY prefix.

Quoted 6 lines

If we start having lots of devices with the same quirk, we could also introduce a pointer to an array of IDs to avoid repeating the same quirk over and over.

Kate's patch adds two quirks so this could be already considered (and only one of these IDs is using SONY prefix).

The HID prefix is not actually a concern for the alias idea, because the alias table triggers on supply_name not on HID. Since INT3472 always assigns "avdd" to any POWER_ENABLE GPIO regardless of HID prefix, the alias would work the same for SONY471A, TBE20A0 or any future INTXXXXX prefix.

However there is a different problem with the alias idea: it would register both avdd and vana for every sensor that has a POWER_ENABLE GPIO, not just Sony IMX sensors. So I agree this is not a good approach.

The NULL-terminated HID array is the correct approach, the mapping is explicit and only applied to hid we explicitly list.

I can send a patch implementing this on top of Kate's patch.

Best Regards,
Tarang

author maintainer
#13 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Hans, Sakari and Tarang,

Thank you for your comments.

Quoted 29 lines · Tarang Raval

Hi Sakari,

Quoted 26 lines · Hans de Goede
Quoted 11 lines
Quoted 10 lines

I went through the INT3472 driver and would like to propose a generic approach that satisfies both sides without per-HID quirks or sensor driver changes.

The problem is:
- INT3472 standardizes on "avdd" internally
- Sony IMX sensor drivers use "vana" per datasheet, and all existing Sony DT bindings (imx219, imx290, imx415) already use vana-supply
- Changing imx471 to "avdd" now will create inconsistency with those bindings, or require a rename later

Quoted 2 lines

Ack, as mentioned in my reply to Sakari from 1 minute ago I'm ok with sticking with vana for the imx* case,

At least some Sony sensors use "INT" PnP vendor prefix and so telling them apart from the rest doesn't work at least this way. There could also be other prefixes as well, they're not all "SONY". Right now there is one with INT prefix and three with SONY prefix.

If we start having lots of devices with the same quirk, we could also introduce a pointer to an array of IDs to avoid repeating the same quirk over and over.

Kate's patch adds two quirks so this could be already considered (and only one of these IDs is using SONY prefix).

The idea may look like

const char *sony_hids [] = {
"SONY471A",
"TBE20A0,
NULL
};

{ /* imx471 expects "vana" as con_id for power enable */

     .hid = sony_hids,   <--- A ponter to sony_hids
     .type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
     .type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
     .con_id = "vana",
     .enable_time_us = GPIO_REGULATOR_ENABLE_TIME,

},

and
and the following functions need to be changed.
Do I understand it correctly?

Sakari, do you want to implement this approach or could Tarang and I do that?

Quoted 7 lines

The HID prefix is not actually a concern for the alias idea, because the alias table triggers on supply_name not on HID. Since INT3472 always assigns "avdd" to any POWER_ENABLE GPIO regardless of HID prefix, the alias would work the same for SONY471A, TBE20A0 or any future INTXXXXX prefix.

Quoted 8 lines

However there is a different problem with the alias idea: it would register both avdd and vana for every sensor that has a POWER_ENABLE GPIO, not just Sony IMX sensors. So I agree this is not a good approach.

The NULL-terminated HID array is the correct approach, the mapping is explicit and only applied to hid we explicitly list.

I can send a patch implementing this on top of Kate's patch.

Sounds good.
If Sakari agree with that, I can include your patch in my series.

Thank you :)

Quoted 4 lines

Best Regards,
Tarang

Signature · 2 lines
BR,
Kate
maintainer
#14 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Kate,

Quoted 33 lines · Kate Hsuan

Hi Hans, Sakari and Tarang,

Thank you for your comments.

Quoted 27 lines · Tarang Raval

Hi Sakari,

Quoted 24 lines · Hans de Goede
Quoted 11 lines
Quoted 10 lines

I went through the INT3472 driver and would like to propose a generic approach that satisfies both sides without per-HID quirks or sensor driver changes.

The problem is:
- INT3472 standardizes on "avdd" internally
- Sony IMX sensor drivers use "vana" per datasheet, and all existing Sony DT bindings (imx219, imx290, imx415) already use vana-supply
- Changing imx471 to "avdd" now will create inconsistency with those bindings, or require a rename later

Quoted 2 lines

Ack, as mentioned in my reply to Sakari from 1 minute ago I'm ok with sticking with vana for the imx* case,

At least some Sony sensors use "INT" PnP vendor prefix and so telling them apart from the rest doesn't work at least this way. There could also be other prefixes as well, they're not all "SONY". Right now there is one with INT prefix and three with SONY prefix.

If we start having lots of devices with the same quirk, we could also introduce a pointer to an array of IDs to avoid repeating the same quirk over and over.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Kate's patch adds two quirks so this could be already considered (and only one of these IDs is using SONY prefix).

The idea may look like

const char *sony_hids [] = {

I'd call this "power_enable_hids_vana" as other bindings than Sony are also using vana regulator, e.g. ST and Toshiba.

Quoted 30 lines

"SONY471A",
"TBE20A0,
NULL
};

{ /* imx471 expects "vana" as con_id for power enable */

     .hid = sony_hids,   <--- A ponter to sony_hids
     .type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
     .type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
     .con_id = "vana",
     .enable_time_us = GPIO_REGULATOR_ENABLE_TIME,

},

and
and the following functions need to be changed.
Do I understand it correctly?

Sakari, do you want to implement this approach or could Tarang and I do that?

Quoted 11 lines

The HID prefix is not actually a concern for the alias idea, because the alias table triggers on supply_name not on HID. Since INT3472 always assigns "avdd" to any POWER_ENABLE GPIO regardless of HID prefix, the alias would work the same for SONY471A, TBE20A0 or any future INTXXXXX prefix.

However there is a different problem with the alias idea: it would register both avdd and vana for every sensor that has a POWER_ENABLE GPIO, not just Sony IMX sensors. So I agree this is not a good approach.

Quoted 6 lines
Quoted 4 lines

The NULL-terminated HID array is the correct approach, the mapping is explicit and only applied to hid we explicitly list.

I can send a patch implementing this on top of Kate's patch.

Sounds good.
If Sakari agree with that, I can include your patch in my series.

Feel free to write a patch. Looks like this series is fine for merging so I'll pick it later today.

Quoted 2 lines

Thank you :)

Thank you for the series!

Signature · 3 lines
Kind regards,

Sakari Ailus
#15 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

Hi Sakari, Kate.

Quoted 77 lines · Kate Hsuan
Quoted 33 lines

Hi Hans, Sakari and Tarang,

Thank you for your comments.

Quoted 27 lines · Tarang Raval

Hi Sakari,

Quoted 24 lines · Hans de Goede
Quoted 11 lines
Quoted 10 lines

I went through the INT3472 driver and would like to propose a generic approach that satisfies both sides without per-HID quirks or sensor driver changes.

The problem is:
- INT3472 standardizes on "avdd" internally
- Sony IMX sensor drivers use "vana" per datasheet, and all existing Sony DT bindings (imx219, imx290, imx415) already use vana-supply
- Changing imx471 to "avdd" now will create inconsistency with those bindings, or require a rename later

Quoted 2 lines

Ack, as mentioned in my reply to Sakari from 1 minute ago I'm ok with sticking with vana for the imx* case,

At least some Sony sensors use "INT" PnP vendor prefix and so telling them apart from the rest doesn't work at least this way. There could also be other prefixes as well, they're not all "SONY". Right now there is one with INT prefix and three with SONY prefix.

If we start having lots of devices with the same quirk, we could also introduce a pointer to an array of IDs to avoid repeating the same quirk over and over.

Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Kate's patch adds two quirks so this could be already considered (and only one of these IDs is using SONY prefix).

The idea may look like

const char *sony_hids [] = {

I'd call this "power_enable_hids_vana" as other bindings than Sony are also using vana regulator, e.g. ST and Toshiba.

Quoted 33 lines

"SONY471A",
"TBE20A0,
NULL
};

{ /* imx471 expects "vana" as con_id for power enable */

     .hid = sony_hids,   <--- A ponter to sony_hids
     .type_from = INT3472_GPIO_TYPE_POWER_ENABLE,
     .type_to = INT3472_GPIO_TYPE_POWER_ENABLE,
     .con_id = "vana",
     .enable_time_us = GPIO_REGULATOR_ENABLE_TIME,

},

and
and the following functions need to be changed.
Do I understand it correctly?

Sakari, do you want to implement this approach or could Tarang and I do that?

Quoted 14 lines

The HID prefix is not actually a concern for the alias idea, because the alias table triggers on supply_name not on HID. Since INT3472 always assigns "avdd" to any POWER_ENABLE GPIO regardless of HID prefix, the alias would work the same for SONY471A, TBE20A0 or any future INTXXXXX prefix.

However there is a different problem with the alias idea: it would register both avdd and vana for every sensor that has a POWER_ENABLE GPIO, not just Sony IMX sensors. So I agree this is not a good approach.

The NULL-terminated HID array is the correct approach, the mapping is explicit and only applied to hid we explicitly list.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I can send a patch implementing this on top of Kate's patch.

Sounds good.
If Sakari agree with that, I can include your patch in my series.

Feel free to write a patch. Looks like this series is fine for merging so I'll pick it later today.

Okay, I'll send a separate follow-up patch.

Best Regards,
Tarang

maintainer
#16 lore raw

Re: [PATCH v6 3/4] platform: int3472: discrete: con_id vana for Sony IMX471 as power enable

In reply to Sakari Ailus

Hi,

Quoted 59 lines · Sakari Ailus

Hi Hans,

Quoted 48 lines · Hans de Goede

Hi,

Quoted 29 lines · Tarang Raval

Hi Hans,

Quoted 18 lines · Tarang Raval
Quoted 7 lines

Hi Kate,

Quoted 5 lines

Update the con_id for the Sony IMX471 sensor to "vana" to serve as the power enable. Additionally, the HID values SONY471A and TBE20A0, both associated with the IMX471 image sensor, have been identified on Lenovo laptops.

Quoted 5 lines
Quoted 1 line

Thanks, looks good.

Hmm, the imx471 driver is still pending upstream:

https://lore.kernel.org/linux-media/[email protected]/

Quoted 8 lines

As part of this series.

Please just use the standardized "avdd" in that driver instead of "vana" (which also seems to refer to the analog supply vdd, which is what avdd stands for).

Then this whole patch is unnecessary and can be dropped from this series.

Quoted 8 lines

The regulator name "vana" comes directly from the Sony IMX471 sensor datasheet, which typically refers to the analog supply voltage. Using the datasheet name helps keep the driver consistent with the hardware documentation and makes it easier to cross-reference.

as per my understanding, the more standardized way is to use the regulator name as per the sensor datasheet. Therefore, I respectfully disagree with your suggestion.

As shown by the need for this patch on x86 at least because there is no devicetree it greatly helps if all Linux sensor drivers use standardized names for their regulators rather then using the exact name from the datasheet which often is not very consistent.

And "avdd" is the name we've standardized on for this, so lets use that:

Quoted 7 lines
hans@shalem:~/projects/linux$ grep -l '"vana"' drivers/media/i2c/*.c | wc -l
4
hans@shalem:~/projects/linux$ grep -l '"avdd"' drivers/media/i2c/*.c | wc -l
36

The alternative is needing to add more and more quirks as different sensors are used, which is not great.

Quoted 8 lines

I do agree that having a constant name for the regulators would be beneficial for the int3472 driver. Still, if, and presumably, when that sensor gets DT support, the bindings will use the regulator name from the datasheet.

Let's just use the datasheet name now and add the few lines needed to the int3472 driver and avoid the churn in the future. There's a limited number of sensor drivers that need this after all.

Ok, if your happy with using "vana" + an int3472 quirk, that works for me.

Regards,

Hans

author maintainer
#17 lore raw

PATCH v6 4/4 media: i2c: imx471: Add Sony IMX471 image sensor driver

In reply to Kate Hsuan

Add a new driver for Sony imx471 camera sensor. It is based on Jimmy Su <[email protected]> implementation and the driver can be found in the following URL.
https://github.com/intel/ipu6-drivers/commits/master/drivers/media/i2c/imx471.c

This sensor can be found on Lenovo X1 Carbon G14, X9-14 and X9-15 laptops and it is a part of IPU7 solution. The driver was tested on Lenovo X1 Carbon G14, X9-14 and X9-15 laptops.

---
 MAINTAINERS                |   6 +
 drivers/media/i2c/Kconfig  |  10 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/imx471.c | 957 +++++++++++++++++++++++++++++++++++++
 4 files changed, 974 insertions(+)
 create mode 100644 drivers/media/i2c/imx471.c
MAINTAINERS +6 -0
index 6b4560681b51..586958b1816d 100644
@@ -25219,6 +25219,12 @@ T:	git git://linuxtv.org/media.git
 F:	Documentation/devicetree/bindings/media/i2c/sony,imx415.yaml
 F:	drivers/media/i2c/imx415.c
 
+SONY IMX471 SENSOR DRIVER
+M:	Kate Hsuan <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/media/i2c/imx471.c
+
 SONY MEMORYSTICK SUBSYSTEM
 M:	Maxim Levitsky <[email protected]>
 M:	Alex Dubov <[email protected]>
drivers/media/i2c/Kconfig +10 -0
index 5d173e0ecf42..b7199f9f5a0c 100644
@@ -287,6 +287,16 @@ config VIDEO_IMX415
 	  To compile this driver as a module, choose M here: the
 	  module will be called imx415.
 
+config VIDEO_IMX471
+	tristate "Sony IMX471 sensor support"
+	select V4L2_CCI_I2C
+	help
+	  This is a Video4Linux2 sensor driver for the Sony
+	  IMX471 camera.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called imx471.
+
 config VIDEO_MAX9271_LIB
 	tristate
 
drivers/media/i2c/Makefile +1 -0
index e45359efe0e4..acbd321fc12e 100644
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_IMX335) += imx335.o
 obj-$(CONFIG_VIDEO_IMX355) += imx355.o
 obj-$(CONFIG_VIDEO_IMX412) += imx412.o
 obj-$(CONFIG_VIDEO_IMX415) += imx415.o
+obj-$(CONFIG_VIDEO_IMX471) += imx471.o
 obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o
 obj-$(CONFIG_VIDEO_ISL7998X) += isl7998x.o
 obj-$(CONFIG_VIDEO_KS0127) += ks0127.o
drivers/media/i2c/imx471.c new file +957 -0

957 lines not on this page · raw message

Signature · 1 line
2.54.0