Skip to contentSkip to conversation

Add Sony IMX471 camera sensor driver

PATCH Superseded Kate Hsuan 5 participants 17 messages Jun 24 – Jun 25

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Kate Hsuan

author maintainer
#0 lore raw

v5 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 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 (3):
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
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           | 971 +++++++++++++++++++++++++++
 drivers/media/pci/intel/ipu-bridge.c |  41 ++
 5 files changed, 1029 insertions(+)
 create mode 100644 drivers/media/i2c/imx471.c

--
2.54.0

author maintainer
#1 lore raw

PATCH v5 1/3 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 v5 2/3 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 v5 3/3 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 | 971 +++++++++++++++++++++++++++++++++++++
 4 files changed, 988 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 +971 -0

971 lines not on this page · raw message

Signature · 1 line
2.54.0
Reviewed-by on v5 3/3
#4 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Kate,

Quoted 11 lines

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.

---

...

drivers/media/i2c/imx471.c line 132

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+static const char * const imx471_supply_name[] = {
+       "avdd",
+};

As we discussed in the last revision, this should be "vana" instead of "avdd". Better to use the regulator name as defined in the datasheet.

Other than that, the driver looks good to me.

Best Regards,
Tarang

author maintainer
#5 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Tarang,

Thank you for reviewing.

Quoted 15 lines · Tarang Raval

Hi Kate,

Quoted 11 lines

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.

---

Quoted 8 lines

...

drivers/media/i2c/imx471.c line 132

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+static const char * const imx471_supply_name[] = {
+       "avdd",
+};

As we discussed in the last revision, this should be "vana" instead of "avdd". Better to use the regulator name as defined in the datasheet.

"avdd" is exposed by INT3472. If it was changed to "vana", the driver complained

[  205.839599] imx471 i2c-SONY471A:00: supply vana not found, using
dummy regulator
[  205.854821] imx471 i2c-SONY471A:00: Error reading reg 0x0016: -121
[  205.854830] imx471 i2c-SONY471A:00: error -EREMOTEIO: failed to read chip id
[  205.854834] imx471 i2c-SONY471A:00: error -EREMOTEIO: failed to
find sensor: -121
[  205.855354] imx471 i2c-SONY471A:00: probe with driver imx471 failed

with error -121

So, avdd is necessary.

Quoted 8 lines

Other than that, the driver looks good to me.

Best Regards,
Tarang

Signature · 2 lines
BR,
Kate
#6 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi kate,

Quoted 34 lines
Quoted 15 lines · Tarang Raval

Hi Kate,

Quoted 11 lines

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.

---

Quoted 8 lines

...

drivers/media/i2c/imx471.c line 132

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+static const char * const imx471_supply_name[] = {
+       "avdd",
+};

As we discussed in the last revision, this should be "vana" instead of "avdd". Better to use the regulator name as defined in the datasheet.

"avdd" is exposed by INT3472. If it was changed to "vana", the driver complained

[  205.839599] imx471 i2c-SONY471A:00: supply vana not found, using
dummy regulator
[  205.854821] imx471 i2c-SONY471A:00: Error reading reg 0x0016: -121
[  205.854830] imx471 i2c-SONY471A:00: error -EREMOTEIO: failed to read chip id
[  205.854834] imx471 i2c-SONY471A:00: error -EREMOTEIO: failed to
find sensor: -121
[  205.855354] imx471 i2c-SONY471A:00: probe with driver imx471 failed
Quoted 3 lines

with error -121

So, avdd is necessary.

Could you please try adding a mapping for SONY471A in int3472_gpio_map[] in drivers/platform/x86/intel/int3472/discrete.c?

Not fully sure, I have to check, but hopefully it will work.

Best Regards,
Tarang

maintainer
#7 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Quoted 6 lines · Tarang Raval
Quoted 1 line

So, avdd is necessary.

Could you please try adding a mapping for SONY471A in int3472_gpio_map[] in drivers/platform/x86/intel/int3472/discrete.c?

Not fully sure, I have to check, but hopefully it will work.

That's the intent, yes.

Signature · 1 line
Sakari Ailus
author maintainer
#8 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Sakari and Tarang,

Quoted 7 lines · Sakari Ailus
Quoted 5 lines · Tarang Raval
Quoted 1 line

So, avdd is necessary.

Could you please try adding a mapping for SONY471A in int3472_gpio_map[] in drivers/platform/x86/intel/int3472/discrete.c?

Quoted 7 lines
Quoted 1 line

Not fully sure, I have to check, but hopefully it will work.

That's the intent, yes.

--
Sakari Ailus

I'll propose a change for it.

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

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

In reply to Kate Hsuan

Hi Kate,

Thanks for the update.

On Wed, Jun 24, 2026 at 11:35:08AM +0800, Kate Hsuan wrote:
...

Quoted 38 lines
drivers/media/i2c/imx471.c new file +38 -0
+static int imx471_set_pad_format(struct v4l2_subdev *sd,
+				 struct v4l2_subdev_state *sd_state,
+				 struct v4l2_subdev_format *fmt)
+{
+	struct imx471 *sensor = to_imx471(sd);
+	const struct imx471_mode *mode;
+	int h_blank, ret;
+
+	mode = v4l2_find_nearest_size(imx471_modes, ARRAY_SIZE(imx471_modes),
+				      width, height, fmt->format.width,
+				      fmt->format.height);
+
+	imx471_update_pad_format(sensor, mode, fmt);
+
+	*v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+
+	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
+		return 0;
+
+	if (media_entity_is_streaming(&sensor->sd.entity))
+		return -EBUSY;
+
+	ret = __v4l2_ctrl_modify_range(sensor->vblank,
+				       mode->fll_min - mode->height,
+				       IMX471_FLL_MAX - mode->height,
+				       1,
+				       mode->fll_def - mode->height);
+	if (ret)
+		return ret;
+
+	h_blank = mode->llp - mode->width;
+	/*
+	 * Currently hblank is not changeable.
+	 * So FPS control is done only by vblank.
+	 */
+	return __v4l2_ctrl_modify_range(sensor->hblank, h_blank,
+					h_blank, 1, h_blank);
+}

...

drivers/media/i2c/imx471.c line 503

Quoted 6 lines
drivers/media/i2c/imx471.c new file +6 -0
+
+static int imx471_init_state(struct v4l2_subdev *sd,
+			     struct v4l2_subdev_state *sd_state)
+{
+	struct v4l2_subdev_format fmt = {
+		.which = V4L2_SUBDEV_FORMAT_ACTIVE,

The purpose of the init_state op is to initialise the provided state only, it's not allowed to change the sensor configuration.

Quoted 9 lines
drivers/media/i2c/imx471.c new file +9 -0
+		.format = {
+			.code = MEDIA_BUS_FMT_SRGGB10_1X10,
+			.width = imx471_modes[0].width,
+			.height = imx471_modes[0].height,
+		},
+	};
+
+	return imx471_set_pad_format(sd, sd_state, &fmt);
+}
Signature · 3 lines
Kind regards,

Sakari Ailus
author maintainer
#10 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Sakari,

Thank you for reviewing.

Quoted 49 lines · Sakari Ailus

Hi Kate,

Thanks for the update.

On Wed, Jun 24, 2026 at 11:35:08AM +0800, Kate Hsuan wrote:
...

Quoted 38 lines
drivers/media/i2c/imx471.c new file +38 -0
+static int imx471_set_pad_format(struct v4l2_subdev *sd,
+                              struct v4l2_subdev_state *sd_state,
+                              struct v4l2_subdev_format *fmt)
+{
+     struct imx471 *sensor = to_imx471(sd);
+     const struct imx471_mode *mode;
+     int h_blank, ret;
+
+     mode = v4l2_find_nearest_size(imx471_modes, ARRAY_SIZE(imx471_modes),
+                                   width, height, fmt->format.width,
+                                   fmt->format.height);
+
+     imx471_update_pad_format(sensor, mode, fmt);
+
+     *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+
+     if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
+             return 0;
+
+     if (media_entity_is_streaming(&sensor->sd.entity))
+             return -EBUSY;
+
+     ret = __v4l2_ctrl_modify_range(sensor->vblank,
+                                    mode->fll_min - mode->height,
+                                    IMX471_FLL_MAX - mode->height,
+                                    1,
+                                    mode->fll_def - mode->height);
+     if (ret)
+             return ret;
+
+     h_blank = mode->llp - mode->width;
+     /*
+      * Currently hblank is not changeable.
+      * So FPS control is done only by vblank.
+      */
+     return __v4l2_ctrl_modify_range(sensor->hblank, h_blank,
+                                     h_blank, 1, h_blank);
+}

...

Quoted 9 lines

drivers/media/i2c/imx471.c line 503

Quoted 6 lines
drivers/media/i2c/imx471.c new file +6 -0
+
+static int imx471_init_state(struct v4l2_subdev *sd,
+                          struct v4l2_subdev_state *sd_state)
+{
+     struct v4l2_subdev_format fmt = {
+             .which = V4L2_SUBDEV_FORMAT_ACTIVE,

The purpose of the init_state op is to initialise the provided state only, it's not allowed to change the sensor configuration.

The input parameter sd_state could initialise it. I'll change this as follows .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;

Quoted 16 lines

drivers/media/i2c/imx471.c line 512

Quoted 10 lines
drivers/media/i2c/imx471.c new file +9 -0
+             .format = {
+                     .code = MEDIA_BUS_FMT_SRGGB10_1X10,
+                     .width = imx471_modes[0].width,
+                     .height = imx471_modes[0].height,
+             },
+     };
+
+     return imx471_set_pad_format(sd, sd_state, &fmt);
+}

--
Kind regards,

Sakari Ailus

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

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Kate,

Quoted 65 lines · Kate Hsuan

Hi Sakari,

Thank you for reviewing.

Quoted 49 lines · Sakari Ailus

Hi Kate,

Thanks for the update.

On Wed, Jun 24, 2026 at 11:35:08AM +0800, Kate Hsuan wrote:
...

Quoted 38 lines
drivers/media/i2c/imx471.c new file +38 -0
+static int imx471_set_pad_format(struct v4l2_subdev *sd,
+                              struct v4l2_subdev_state *sd_state,
+                              struct v4l2_subdev_format *fmt)
+{
+     struct imx471 *sensor = to_imx471(sd);
+     const struct imx471_mode *mode;
+     int h_blank, ret;
+
+     mode = v4l2_find_nearest_size(imx471_modes, ARRAY_SIZE(imx471_modes),
+                                   width, height, fmt->format.width,
+                                   fmt->format.height);
+
+     imx471_update_pad_format(sensor, mode, fmt);
+
+     *v4l2_subdev_state_get_format(sd_state, fmt->pad) = fmt->format;
+
+     if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
+             return 0;
+
+     if (media_entity_is_streaming(&sensor->sd.entity))
+             return -EBUSY;
+
+     ret = __v4l2_ctrl_modify_range(sensor->vblank,
+                                    mode->fll_min - mode->height,
+                                    IMX471_FLL_MAX - mode->height,
+                                    1,
+                                    mode->fll_def - mode->height);
+     if (ret)
+             return ret;
+
+     h_blank = mode->llp - mode->width;
+     /*
+      * Currently hblank is not changeable.
+      * So FPS control is done only by vblank.
+      */
+     return __v4l2_ctrl_modify_range(sensor->hblank, h_blank,
+                                     h_blank, 1, h_blank);
+}

...

Quoted 9 lines

drivers/media/i2c/imx471.c line 503

Quoted 6 lines
drivers/media/i2c/imx471.c new file +6 -0
+
+static int imx471_init_state(struct v4l2_subdev *sd,
+                          struct v4l2_subdev_state *sd_state)
+{
+     struct v4l2_subdev_format fmt = {
+             .which = V4L2_SUBDEV_FORMAT_ACTIVE,

The purpose of the init_state op is to initialise the provided state only, it's not allowed to change the sensor configuration.

Quoted 2 lines

The input parameter sd_state could initialise it. I'll change this as follows .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;

sd_state is supposed to be always non-NULL. So you can use FORMAT_TRY always.

Signature · 3 lines
Regards,

Sakari Ailus
#12 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

In reply to Kate Hsuan
Quoted 10 lines · 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.

Please find a few minor nitpicks below.

Quoted 69 lines
---
  MAINTAINERS                |   6 +
  drivers/media/i2c/Kconfig  |  10 +
  drivers/media/i2c/Makefile |   1 +
  drivers/media/i2c/imx471.c | 971 +++++++++++++++++++++++++++++++++++++
  4 files changed, 988 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 +5 -0
new file mode 100644
index 000000000000..1e1bff69ea3d
@@ -0,0 +1,971 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * imx471.c - imx471 sensor driver
+ *
+ * Copyright (C) 2025 Intel Corporation

drivers/media/i2c/imx471.c line 15

Quoted 10 lines
drivers/media/i2c/imx471.c new file +10 -0
+ * Copyright (C) 2026 Kate Hsuan <[email protected]>
+ */
+
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
+#include <linux/unaligned.h>

No declarations coming from linux/unaligned.h header are used in the driver.

drivers/media/i2c/imx471.c line 18

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+#include <media/v4l2-cci.h>
+#include <media/v4l2-ctrls.h>
+#include <media/v4l2-device.h>

No declarations coming from media/v4l-event.h header are used in the driver, likely it's intended to include media/v4l2-subdev.h instead.

drivers/media/i2c/imx471.c line 19

Quoted 1 line
drivers/media/i2c/imx471.c new file +1 -0
+#include <media/v4l2-event.h>

No declarations coming from media/v4l-event.h header are used in the driver.

Quoted 32 lines
drivers/media/i2c/imx471.c new file +32 -0
+#include <media/v4l2-fwnode.h>
+
+#define IMX471_REG_MODE_SELECT			CCI_REG8(0x0100)
+#define IMX471_MODE_STANDBY			0x00
+#define IMX471_MODE_STREAMING			0x01
+
+/* Chip ID */
+#define IMX471_REG_CHIP_ID			CCI_REG16(0x0016)
+#define IMX471_CHIP_ID				0x0471
+
+/* V_TIMING internal */
+#define IMX471_REG_FLL				CCI_REG16(0x0340)
+#define IMX471_FLL_MAX				0xffff
+
+/* Exposure control */
+#define IMX471_REG_EXPOSURE			CCI_REG16(0x0202)
+#define IMX471_EXPOSURE_MIN			1
+#define IMX471_EXPOSURE_STEP			1
+#define IMX471_EXPOSURE_DEFAULT			1270
+
+/* Default exposure margin */
+#define IMX471_EXPOSURE_MARGIN			18
+
+/* Analog gain control */
+#define IMX471_REG_ANALOG_GAIN			CCI_REG16(0x0204)
+#define IMX471_ANA_GAIN_MIN			0
+#define IMX471_ANA_GAIN_MAX			800
+#define IMX471_ANA_GAIN_STEP			1
+#define IMX471_ANA_GAIN_DEFAULT			0
+
+/* Digital gain control */
+#define IMX471_REG_DPGA_USE_GLOBAL_GAIN		CCI_REG16(0x3ff9)

drivers/media/i2c/imx471.c line 61

Quoted 10 lines
drivers/media/i2c/imx471.c new file +10 -0
+#define IMX471_REG_DIG_GAIN_GLOBAL		CCI_REG16(0x020e)
+#define IMX471_DGTL_GAIN_MIN			256
+#define IMX471_DGTL_GAIN_MAX			4095
+#define IMX471_DGTL_GAIN_STEP			1
+#define IMX471_DGTL_GAIN_DEFAULT		256
+
+/* HFLIP and VFLIP control */
+#define IMX471_REG_ORIENTATION			CCI_REG8(0x0101)
+#define IMX471_HFLIP_BIT			BIT(0)
+#define IMX471_VFLIP_BIT			BIT(1)

IMX471_HFLIP_BIT and IMX471_VFLIP_BIT macro do not have any users in the driver.

drivers/media/i2c/imx471.c line 69

Quoted 8 lines
drivers/media/i2c/imx471.c new file +8 -0
+
+/* Test Pattern Control */
+#define IMX471_REG_TEST_PATTERN			CCI_REG8(0x0600)
+#define IMX471_TEST_PATTERN_DISABLED		0
+#define IMX471_TEST_PATTERN_SOLID_COLOR		1
+#define IMX471_TEST_PATTERN_COLOR_BARS		2
+#define IMX471_TEST_PATTERN_GRAY_COLOR_BARS	3
+#define IMX471_TEST_PATTERN_PN9			4

IMX471_TEST_PATTERN_* macro do not have any users in the driver.

drivers/media/i2c/imx471.c line 74

Quoted 5 lines
drivers/media/i2c/imx471.c new file +5 -0
+
+/* default link frequency and external clock */
+#define IMX471_LINK_FREQ_DEFAULT		200000000LL
+#define IMX471_EXT_CLK				19200000
+#define IMX471_LINK_FREQ_INDEX			0

Please drop IMX471_LINK_FREQ_INDEX macro along with .link_freq_index from struct imx471_mode.

Signature · 2 lines
Best wishes,
Vladimir
author maintainer
#13 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Vladimir,

Thank you for reviewing.

Quoted 104 lines · Vladimir Zapolskiy
Quoted 10 lines · 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.

Please find a few minor nitpicks below.

Quoted 69 lines
---
  MAINTAINERS                |   6 +
  drivers/media/i2c/Kconfig  |  10 +
  drivers/media/i2c/Makefile |   1 +
  drivers/media/i2c/imx471.c | 971 +++++++++++++++++++++++++++++++++++++
  4 files changed, 988 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 +5 -0
new file mode 100644
index 000000000000..1e1bff69ea3d
@@ -0,0 +1,971 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * imx471.c - imx471 sensor driver
+ *
+ * Copyright (C) 2025 Intel Corporation

drivers/media/i2c/imx471.c line 15

Quoted 10 lines
drivers/media/i2c/imx471.c new file +10 -0
+ * Copyright (C) 2026 Kate Hsuan <[email protected]>
+ */
+
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
+#include <linux/unaligned.h>

No declarations coming from linux/unaligned.h header are used in the driver.

drivers/media/i2c/imx471.c line 18

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+#include <media/v4l2-cci.h>
+#include <media/v4l2-ctrls.h>
+#include <media/v4l2-device.h>

No declarations coming from media/v4l-event.h header are used in the driver, likely it's intended to include media/v4l2-subdev.h instead.

Quoted 3 lines

drivers/media/i2c/imx471.c line 19

Quoted 1 line
drivers/media/i2c/imx471.c new file +1 -0
+#include <media/v4l2-event.h>

No declarations coming from media/v4l-event.h header are used in the driver.

I'll drop them.

Quoted 37 lines
Quoted 37 lines
drivers/media/i2c/imx471.c new file +36 -0
+#include <media/v4l2-fwnode.h>
+
+#define IMX471_REG_MODE_SELECT                       CCI_REG8(0x0100)
+#define IMX471_MODE_STANDBY                  0x00
+#define IMX471_MODE_STREAMING                        0x01
+
+/* Chip ID */
+#define IMX471_REG_CHIP_ID                   CCI_REG16(0x0016)
+#define IMX471_CHIP_ID                               0x0471
+
+/* V_TIMING internal */
+#define IMX471_REG_FLL                               CCI_REG16(0x0340)
+#define IMX471_FLL_MAX                               0xffff
+
+/* Exposure control */
+#define IMX471_REG_EXPOSURE                  CCI_REG16(0x0202)
+#define IMX471_EXPOSURE_MIN                  1
+#define IMX471_EXPOSURE_STEP                 1
+#define IMX471_EXPOSURE_DEFAULT                      1270
+
+/* Default exposure margin */
+#define IMX471_EXPOSURE_MARGIN                       18
+
+/* Analog gain control */
+#define IMX471_REG_ANALOG_GAIN                       CCI_REG16(0x0204)
+#define IMX471_ANA_GAIN_MIN                  0
+#define IMX471_ANA_GAIN_MAX                  800
+#define IMX471_ANA_GAIN_STEP                 1
+#define IMX471_ANA_GAIN_DEFAULT                      0
+
+/* Digital gain control */
+#define IMX471_REG_DPGA_USE_GLOBAL_GAIN              CCI_REG16(0x3ff9)
+#define IMX471_REG_DIG_GAIN_GLOBAL           CCI_REG16(0x020e)
+#define IMX471_DGTL_GAIN_MIN                 256
+#define IMX471_DGTL_GAIN_MAX                 4095
+#define IMX471_DGTL_GAIN_STEP                        1
Quoted 8 lines

drivers/media/i2c/imx471.c line 61

Quoted 6 lines
drivers/media/i2c/imx471.c new file +6 -0
+#define IMX471_DGTL_GAIN_DEFAULT             256
+
+/* HFLIP and VFLIP control */
+#define IMX471_REG_ORIENTATION                       CCI_REG8(0x0101)
+#define IMX471_HFLIP_BIT                     BIT(0)
+#define IMX471_VFLIP_BIT                     BIT(1)

IMX471_HFLIP_BIT and IMX471_VFLIP_BIT macro do not have any users in the driver.

I'll drop them.

Quoted 11 lines

drivers/media/i2c/imx471.c line 69

Quoted 9 lines
drivers/media/i2c/imx471.c new file +8 -0
+
+/* Test Pattern Control */
+#define IMX471_REG_TEST_PATTERN                      CCI_REG8(0x0600)
+#define IMX471_TEST_PATTERN_DISABLED         0
+#define IMX471_TEST_PATTERN_SOLID_COLOR              1
+#define IMX471_TEST_PATTERN_COLOR_BARS               2
+#define IMX471_TEST_PATTERN_GRAY_COLOR_BARS  3
+#define IMX471_TEST_PATTERN_PN9                      4

IMX471_TEST_PATTERN_* macro do not have any users in the driver.

I'll drop them.

Quoted 9 lines

drivers/media/i2c/imx471.c line 74

Quoted 6 lines
drivers/media/i2c/imx471.c new file +5 -0
+
+/* default link frequency and external clock */
+#define IMX471_LINK_FREQ_DEFAULT             200000000LL
+#define IMX471_EXT_CLK                               19200000
+#define IMX471_LINK_FREQ_INDEX                       0

Please drop IMX471_LINK_FREQ_INDEX macro along with .link_freq_index from struct imx471_mode.

Okay

Quoted 5 lines

--
Best wishes,
Vladimir

Signature · 2 lines
BR,
Kate
#14 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

In reply to Kate Hsuan

Hi Kate,

Quoting Kate Hsuan (2026-06-24 04:35:08)

Quoted 11 lines

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.

---

... <snip>

Quoted 3 lines
drivers/media/i2c/imx471.c new file +2 -0
+#define IMX471_REG_EXCK_FREQ                   CCI_REG16(0x0136)
+#define IMX471_EXCK_FREQ(n)                    ((n) * 256)     /* n in MHz */

<snip>

drivers/media/i2c/imx471.c line 171

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+
+static const struct cci_reg_sequence imx471_global_regs[] = {
+       { IMX471_REG_EXCK_FREQ, IMX471_EXCK_FREQ(19.2) },

Does this work? Is this a compile time constant multiplying floating point with the compiler, or something happening in the kernel?

I'll be happy if it does, but it catches my attention as something I thought we couldn't do.

--
Kieran

#15 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Kieran,

Quoted 26 lines

Quoting Kate Hsuan (2026-06-24 04:35:08)

Quoted 11 lines

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.

---

... <snip>

Quoted 3 lines
drivers/media/i2c/imx471.c new file +2 -0
+#define IMX471_REG_EXCK_FREQ                   CCI_REG16(0x0136)           
+#define IMX471_EXCK_FREQ(n)                    ((n) * 256)     /* n in MHz */

<snip>

drivers/media/i2c/imx471.c line 171

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+                                                                           
+static const struct cci_reg_sequence imx471_global_regs[] = {              
+       { IMX471_REG_EXCK_FREQ, IMX471_EXCK_FREQ(19.2) },                   
Quoted 5 lines

Does this work? Is this a compile time constant multiplying floating point with the compiler, or something happening in the kernel?

I'll be happy if it does, but it catches my attention as something I thought we couldn't do.

I tested this with GCC. It evaluates the expression at compile time and folds it into the integer constant 4915. The generated assembly/object file contains .quad 4915 in the initialized data and no floating-point instructions are emitted, so the kernel only ever sees the integer value.

Best Regards,
Tarang

author maintainer
#16 lore raw

Re: [PATCH v5 3/3] media: i2c: imx471: Add Sony IMX471 image sensor driver

Hi Kieran and Tarang,

Thank you for reviewing.

Quoted 32 lines · Tarang Raval

Hi Kieran,

Quoted 29 lines

Quoting Kate Hsuan (2026-06-24 04:35:08)

Quoted 11 lines

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.

---

... <snip>

Quoted 3 lines
drivers/media/i2c/imx471.c new file +2 -0
+#define IMX471_REG_EXCK_FREQ                   CCI_REG16(0x0136)
+#define IMX471_EXCK_FREQ(n)                    ((n) * 256)     /* n in MHz */

<snip>

drivers/media/i2c/imx471.c line 171

Quoted 3 lines
drivers/media/i2c/imx471.c new file +3 -0
+
+static const struct cci_reg_sequence imx471_global_regs[] = {
+       { IMX471_REG_EXCK_FREQ, IMX471_EXCK_FREQ(19.2) },

Does this work? Is this a compile time constant multiplying floating point with the compiler, or something happening in the kernel?

Quoted 7 lines
Quoted 2 lines

I'll be happy if it does, but it catches my attention as something I thought we couldn't do.

I tested this with GCC. It evaluates the expression at compile time and folds it into the integer constant 4915. The generated assembly/object file contains .quad 4915 in the initialized data and no floating-point instructions are emitted, so the kernel only ever sees the integer value.

The compiler didn't complain anything and covert it to a integer but putting a floating point here is not a good way.
I focued on finding a register value without noticing that it is a floating point
I'll set a value IMX471_REG_EXCK_FREQ directly and drop IMX471_EXCK_FREQ.

Quoted 4 lines

Best Regards,
Tarang

Signature · 2 lines
BR,
Kate