Skip to contentSkip to conversation

media: Add t4ka3 camera sensor driver

PATCH New Kate Hsuan 1 participant 1 message Mar 25

Subsystems (2)
lore
Share & tools
lore

Kate Hsuan

author maintainer
#0 lore raw

PATCH v13 1/1 media: Add t4ka3 camera sensor driver

Add the t4ka3 driver from:
https://github.com/kitakar5525/surface3-atomisp-cameras.git

With many cleanups / changes (almost a full rewrite) to make it suitable for upstream:

* Remove the VCM and VCM-OTP support, the mainline kernel models VCMs and calibration data eeproms as separate v4l2-subdev-s.

* Remove the integration-factor t4ka3_get_intg_factor() support and IOCTL, this provided info to userspace through an atomisp private IOCTL.

* Turn atomisp specific exposure/gain IOCTL into standard v4l2 controls.

* Use normal ACPI power-management in combination with runtime-pm support instead of atomisp specific GMIN power-management code.

* Turn into a standard V4L2 sensor driver using
v4l2_async_register_subdev_sensor().

* Add vblank, hblank, and link-freq controls; drop get_frame_interval().

* Use CCI register helpers.

* Calculate values for modes instead of using fixed register-value lists, allowing arbritrary modes.

* Add get_selection() and set_selection() support

* Add a CSI2 bus configuration check

This was tested on a Xiaomi Mipad2 tablet which has a T4KA3 sensor with DW9761 VCM as back sensor.

---
Changes in v13:
1. Update the MAINTAINERS file.
2. Remove a duplicated if section in t4ka3_set_pad_format().
3. Remove a redundant T4KA3_REG_FRAME_LENGTH_LINES register write. T4KA3_REG_PIXELS_PER_LINE was kept since it wasn't used in t4ka3_s_ctrl().
4. Check non-zero return value from v4l2_link_freq_to_bitmap().

Changes in v12:
1. Drop t4ka3_get_active_format() helper.
2. Drop t4ka3_get_active_crop() helper.
3. If the caller has v4l2_subdev_state and v4l2_mbus_framefmt, pass them to the functions instead of calling v4l2_subdev_lock_and_get_active_state().
4. Fix the format and style issues addressed by reviewers.
5. Update the copyright year.
6. Drop error handling after calling fwnode_graph_get_next_endpoint().
7. Drop unnecessary error logs after calling v4l2_link_freq_to_bitmap().
8. Power off the sensor if t4ka3_detect() fails.
9. Fix the errors reported by

   $ ./scripts/checkpatch.pl --strict --max-line-length=80.
10. Replace link_freq in the struct t4ka3_data with a const array
    link_freq_menu_items.
11. Switch to_t4ka3_sensor and ctrl_to_t4ka3 to macros.
12. Keep struct t4ka3_ctrls since it is used in the driver, including gain.

Changes in v11:
1. Rebase on the latest next branch.

Changes in v10:
1. Fix the format settings.
2. Fix the hblank range calculation.
3. In t4ka3_enable_stream(), powerdown when pm_runtime_get_sync() fails.
4. Fix the clean up call sequence when removing the driver.
5. Fix the error handling in t4ka3_probe().

Changes in v9:
1. Apply Hans' fix patch to fix the lock issue and squash it into this patch.
https://lore.kernel.org/linux-media/[email protected]/

Changes in v8:
1. Drop the local mutex lock and v4l2-core manages all the locking.
2. __t4ka3_get_pad_format() and __t4ka3_get_pad_crop() are replaced with v4l2_subdev_state_get_format() and v4l2_subdev_state_get_crop().
3. The deprecated s_stream was replaced with enable_streams() and disable_streams().
4. Drop unused functions.
5. t4ka3_get_active_format() helper is used to get the active format.
6. v4l2_link_freq_to_bitmap() is used to check and get the supported link frequency.

Changes in v7:
1. Add pixel_rate control.

Changes in v6:
1. t4ka3_s_config() was removed.
2. The unused macros were removed.
3. The runtime pm initial flow was improved.
4. In remove(), if the device is not in the "suspend" state, the device will be manually turned off.

Changes in v5:
1. Improved Kconfig help description.

Changes in v4:
1. Another CI issue fixes.

Changes in v3:
1. Fix the issues reported by the CI system.

Changes in v2:
1. The regmap information was obtained before configuring runtime PM so probe() can return without disabling runtime PM.
2. In t4ka3_s_stream(), return -EBUSY when the streaming is enabled.

---
 MAINTAINERS                |    6 +
 drivers/media/i2c/Kconfig  |   12 +
 drivers/media/i2c/Makefile |    1 +
 drivers/media/i2c/t4ka3.c  | 1064 ++++++++++++++++++++++++++++++++++++
 4 files changed, 1083 insertions(+)
 create mode 100644 drivers/media/i2c/t4ka3.c
MAINTAINERS +6 -0
index 237397f18f07..0c77d5cd70bb 100644
@@ -26726,6 +26726,12 @@ F:	drivers/char/toshiba.c
 F:	include/linux/toshiba.h
 F:	include/uapi/linux/toshiba.h
 
+TOSHIBA T4KA3 CAMERA SENSOR DRIVER
+M:	Kate Hsuan <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/media/i2c/t4ka3.c
+
 TOSHIBA TC358743 DRIVER
 M:	Hans Verkuil <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +12 -0
index 20482be35f26..6344defdbb51 100644
@@ -790,6 +790,18 @@ config VIDEO_S5KJN1
 	  To compile this driver as a module, choose M here: the
 	  module will be called s5kjn1.
 
+config VIDEO_T4KA3
+	tristate "Toshiba T4KA3 sensor support"
+	depends on ACPI || COMPILE_TEST
+	depends on GPIOLIB
+	select V4L2_CCI_I2C
+	help
+	  This is a Video4Linux2 sensor driver for the Toshiba T4KA3 8 MP
+	  camera sensor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called t4ka3.
+
 config VIDEO_VD55G1
 	tristate "ST VD55G1 sensor support"
 	select V4L2_CCI_I2C
drivers/media/i2c/Makefile +1 -0
index a3a6396df3c4..64c0c7964998 100644
@@ -139,6 +139,7 @@ obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o
 obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o
 obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_ST_MIPID02) += st-mipid02.o
+obj-$(CONFIG_VIDEO_T4KA3) += t4ka3.o
 obj-$(CONFIG_VIDEO_TC358743) += tc358743.o
 obj-$(CONFIG_VIDEO_TC358746) += tc358746.o
 obj-$(CONFIG_VIDEO_TDA1997X) += tda1997x.o
drivers/media/i2c/t4ka3.c new file +1064 -0

1,064 lines not on this page · raw message

Signature · 1 line
2.53.0