media: Add Himax HM1092 mono NIR sensor driver
v6 cover media: Add Himax HM1092 mono NIR sensor driver
This adds a V4L2 subdev driver and DT binding for the Himax HM1092, a 1 megapixel monochrome near-infrared image sensor. On laptops it sits behind the IR camera used for face unlock. It speaks a single MIPI CSI-2 data lane and outputs 10-bit RAW at 560x360.
The driver exposes that one fixed mode, test patterns, exposure, analogue gain and digital gain controls, pixel-array selection targets and the standard fwnode properties. It has been tested on an ASUS Zenbook A14:
the sensor probes, streams, changes brightness across the full exposure and analogue gain ranges, accepts digital gain endpoint updates while streaming, and returns to runtime suspend after capture.
The exposure default is 500 lines, selected from unstretched illuminated captures on the ASUS system. The init sequence programs the same value so the sensor state and V4L2 control default remain consistent.
The register programming was extracted from com.qti.sensormodule.hm1092.bin in the Qualcomm camera stack shipped for the ASUS system. Jake Steinman independently identified the exposure, analogue gain, digital gain and group-hold registers from Dell's hm1092.sys. The available documentation does not identify the test-pattern modes, so their menu names are based on output observed during hardware testing.
The ASUS Windows configuration supplies a 24 MHz external clock. The programmed PLL divide-by-12 pre-divider and multiply-by-90 multiplier give a 180 MHz CSI-2 DDR link frequency, a 360 Mbit/s lane rate and a 36 MHz pixel rate. With HTS 1616 and VTS 750, the resulting frame rate is approximately 29.7 frames per second. The driver reports the 1296x736 native pixel array, the 1280x720 active array and the mode's 1150x718 crop.
The sensor driver and its binding are SoC-neutral, so they are sent on their own through the media tree. The board-level device tree and PHY work that wires this camera up on the ASUS Zenbook A14 will be sent as its own series.
---
Changes in v6:
- dt-bindings: update the example to the PLL-derived 180 MHz link frequency.
- hm1092: replace the inconsistent 400 MHz link frequency and derived
80 MHz pixel rate with 180 MHz and 36 MHz. The new values are derived from the ASUS Windows configuration's 24 MHz external clock and the sensor PLL dividers.
- hm1092: report the 1296x736 native array, 1280x720 active array and 1150x718 mode crop as distinct selection targets.
- hm1092: add exposure, analogue gain and digital gain controls using the register map supplied by Jake Steinman. Keep multi-byte controls as separate writes, use group hold, derive the exposure maximum from VTS, and program the hardware-tested 500-line exposure default in both the init table and control. Hardware-test the controls on the 560x360 mode.
- hm1092: do not power the sensor on in probe(). There is no I2C access during probe, so leave it suspended and let runtime PM power it for streaming.
- Link to v5: https://patch.msgid.link/[email protected]
Changes in v5:
- dt-bindings: drop the data-lanes property entirely; the fixed
single-lane wiring is not configurable, so it does not belong in DT.
- hm1092: implement the get_selection pad op (CROP, CROP_DEFAULT, CROP_BOUNDS and NATIVE_SIZE) reporting the sensor's pixel-array
geometry, as required by libcamera.
- Link to v4: https://patch.msgid.link/[email protected]
Changes in v4:
- dt-bindings: make data-lanes optional for the fixed single-lane sensor, constrain explicit values to <1>, and omit it from the example.
- hm1092: add the copyright notice.
- hm1092: replace the private register representation and write helper
with CCI register sequences and direct CCI writes.
- hm1092: use descriptive test-pattern names based on hardware captures; the available documentation does not identify these modes.
- hm1092: parse fwnode properties before creating controls and set read-only flags after validating control creation.
- hm1092: use the generic get_fmt callback for the fixed sensor mode.
- hm1092: initialize endpoint parsing with the fixed one-lane default, reject other lane configurations, and remove the redundant endpoint presence check.
- hm1092: use fsleep() and null-safe GPIO calls, and apply the requested declaration, brace, return-value and error-path formatting cleanups.
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- dt-bindings: add the Reviewed-by tag from Conor Dooley.
- hm1092: initialize RAW colorimetry fields in the pad format helper so userspace values cannot leak into subdevice state.
- hm1092: return -ENXIO when the required firmware graph endpoint is
absent instead of deferring probe indefinitely.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- hm1092: use pm_ptr() instead of pm_sleep_ptr() for the dev_pm_ops pointer. The ops come from DEFINE_RUNTIME_DEV_PM_OPS(), so gating them
on CONFIG_PM_SLEEP dropped runtime PM on a CONFIG_PM=y, PM_SLEEP=n
build.
- hm1092: free the control handler on the error paths in hm1092_init_controls(); the fwnode-parse and ctrl_hdlr->error returns leaked the handler.
- Link to v1: https://patch.msgid.link/[email protected]
---
Ramshouriesh R (2):
media: dt-bindings: Add Himax HM1092 NIR sensor
media: i2c: hm1092: add Himax HM1092 mono NIR sensor driver
.../bindings/media/i2c/himax,hm1092.yaml | 101 +++ MAINTAINERS | 7 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/hm1092.c | 863 +++++++++++++++++++++ 5 files changed, 983 insertions(+)
---
base-commit: be5c93fa674f0fc3c8f359c2143abce6bbb422e6
change-id: 20260618-hm1092-driver-a6f2aaddf201
Best regards,
Signature · 1 line
Ramshouriesh R <[email protected]>
PATCH v6 1/2 media: dt-bindings: Add Himax HM1092 NIR sensor
Add a dt-binding schema for the Himax HM1092, a 1 megapixel monochrome near-infrared CMOS image sensor used as the face-authentication IR camera on laptops. The sensor streams 10-bit RAW over a single MIPI CSI-2 data lane.
--- .../bindings/media/i2c/himax,hm1092.yaml | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+)
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml new file +101 -0
@@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/himax,hm1092.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Himax HM1092 Monochrome NIR Sensor + +maintainers: + - Ramshouriesh R <[email protected]> + +description: + The Himax HM1092 is a 1 megapixel monochrome near-infrared CMOS image + sensor with a MIPI CSI-2 interface, commonly used as the IR camera for + face authentication on laptops. It outputs 10-bit RAW over a single + MIPI CSI-2 data lane. + +allOf: + - $ref: /schemas/media/video-interface-devices.yaml# + +properties: + compatible: + const: himax,hm1092 + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + avdd-supply: + description: Analogue circuit voltage supply. + + dovdd-supply: + description: I/O circuit voltage supply. + + dvdd-supply: + description: Digital circuit voltage supply. + + reset-gpios: + maxItems: 1 + description: Active low GPIO connected to the XSHUTDOWN pad. + + port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + required: + - link-frequencies + +required: + - compatible + - reg + - clocks + - avdd-supply + - dovdd-supply + - dvdd-supply + - port + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + camera@24 { + compatible = "himax,hm1092"; + reg = <0x24>; + + reset-gpios = <&tlmm 109 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&cam_ir_default>; + + clocks = <&camcc 1>; + assigned-clocks = <&camcc 1>; + assigned-clock-rates = <24000000>; + + orientation = <0>; + + avdd-supply = <&vreg_l7m_2p9>; + dvdd-supply = <&vreg_l7m_2p9>; + dovdd-supply = <&vreg_l4m_1p8>; + + port { + hm1092_ep: endpoint { + link-frequencies = /bits/ 64 <180000000>; + remote-endpoint = <&camss_csiphy0_inep>; + }; + }; + }; + }; +...
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v6 1/2] media: dt-bindings: Add Himax HM1092 NIR sensor
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The schema fails to restrict the `data-lanes` property to a single lane, allowing physically…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The schema fails to restrict the data-lanes property to a single lane, allowing physically invalid device tree configurations to silently pass validation. --
--- Patch [1]: [PATCH v6 1/2] media: dt-bindings: Add Himax HM1092 NIR sensor --- commit ee5879a0923ec6b56edc74d8a66ff697b111ae09
Author: Ramshouriesh R <[email protected]>
media: dt-bindings: Add Himax HM1092 NIR sensor
This commit adds a device tree binding schema for the Himax HM1092, a 1 megapixel monochrome near-infrared CMOS image sensor. The sensor is described as outputting 10-bit RAW data over a single MIPI CSI-2 data lane.
Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml new file +0
-0
[ ... ]
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml line 54
Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml new file +11
-0+ port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + required: + - link-frequencies
[Severity: Medium]
The commit message mentions the sensor outputs over a single MIPI CSI-2 data lane, but does this schema restrict the data-lanes property to a single lane?
Without explicitly defining a data-lanes property constraint (such as
maxItems: 1 or items: - const: 1) in this endpoint block, the schema inherits the permissive defaults from video-interfaces.yaml. This would allow device trees specifying physically impossible multi-lane configurations (e.g., data-lanes = <1 2>;) to silently pass schema validation.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Rob Herring
maintainerRe: [PATCH v6 1/2] media: dt-bindings: Add Himax HM1092 NIR sensor
Quoted 35 lines · On Sat, Aug 01, 2026 at 01:01:49PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The schema fails to restrict thedata-lanesproperty to a single lane, allowing physically invalid device tree configurations to silently pass validation. ----- Patch [1]: [PATCH v6 1/2] media: dt-bindings: Add Himax HM1092 NIR sensor --- commit
ee5879a0923ec6b56edc74d8a66ff697b111ae09
Author: Ramshouriesh R <[email protected]>media: dt-bindings: Add Himax HM1092 NIR sensor
This commit adds a device tree binding schema for the Himax HM1092, a 1 megapixel monochrome near-infrared CMOS image sensor. The sensor is described as outputting 10-bit RAW data over a single MIPI CSI-2 data lane.
Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml new file +0
-0[ ... ]
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml line 54
Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml new file +11
-0+ port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + required: + - link-frequencies[Severity: Medium]
The commit message mentions the sensor outputs over a single MIPI CSI-2 data lane, but does this schema restrict the data-lanes property to a single lane?
Quoted 5 lines
Without explicitly defining a data-lanes property constraint (such as
maxItems: 1 or items: - const: 1) in this endpoint block, the schema inherits the permissive defaults fromvideo-interfaces.yaml. This would allow device trees specifying physically impossible multi-lane configurations (e.g., data-lanes = <1 2>;) to silently pass schema validation.
data-lanes should not be present, but that's probably an issue on a number of bindings. There's not a great way to so this other than using 'additionalProperties' instead and listing all the properties used from video-interfaces.yaml. But then you have to list 'remote-endpoint' everywhere which is not great either. I'd rather just allow the property even if it doesn't make sense for the h/w.
Rob
Re: [PATCH v6 1/2] media: dt-bindings: Add Himax HM1092 NIR sensor
Quoted 43 lines · Rob Herring
Quoted 35 lines · On Sat, Aug 01, 2026 at 01:01:49PM +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The schema fails to restrict thedata-lanesproperty to a single lane, allowing physically invalid device tree configurations to silently pass validation. ----- Patch [1]: [PATCH v6 1/2] media: dt-bindings: Add Himax HM1092 NIR sensor --- commit
ee5879a0923ec6b56edc74d8a66ff697b111ae09
Author: Ramshouriesh R <[email protected]>media: dt-bindings: Add Himax HM1092 NIR sensor
This commit adds a device tree binding schema for the Himax HM1092, a 1 megapixel monochrome near-infrared CMOS image sensor. The sensor is described as outputting 10-bit RAW data over a single MIPI CSI-2 data lane.
Quoted 4 lines
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml new file +0
-0[ ... ]
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml line 54
Quoted 11 lines
Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml new file +11
-0+ port: + $ref: /schemas/graph.yaml#/$defs/port-base + additionalProperties: false + + properties: + endpoint: + $ref: /schemas/media/video-interfaces.yaml# + unevaluatedProperties: false + + required: + - link-frequencies[Severity: Medium]
The commit message mentions the sensor outputs over a single MIPI CSI-2 data lane, but does this schema restrict the data-lanes property to a single lane?Quoted 5 lines
Without explicitly defining a data-lanes property constraint (such as
maxItems: 1 or items: - const: 1) in this endpoint block, the schema inherits the permissive defaults fromvideo-interfaces.yaml. This would allow device trees specifying physically impossible multi-lane configurations (e.g., data-lanes = <1 2>;) to silently pass schema validation.
Quoted 8 lines
data-lanes should not be present, but that's probably an issue on a number of bindings. There's not a great way to so this other than using 'additionalProperties' instead and listing all the properties used from
video-interfaces.yaml. But then you have to list 'remote-endpoint' everywhere which is not great either. I'd rather just allow the property even if it doesn't make sense for the h/w.Rob
Thanks for the clarification. I’ll leave the binding as-is and won’t add the data-lanes constraint suggested by Sashiko.
Regards,
Ramshouriesh
PATCH v6 2/2 media: i2c: hm1092: add Himax HM1092 mono NIR sensor driver
In reply to Ramshouriesh RAdd a V4L2 subdev driver for the Himax HM1092, a 1 megapixel monochrome near-infrared image sensor with a single-lane MIPI CSI-2 interface, typically used as the face-authentication IR camera on laptops.
The driver supports the sensor's 560x360 10-bit mono mode, test patterns, exposure, analogue gain and digital gain controls, and the standard fwnode properties (orientation and rotation). It also reports the 1296x736 native pixel array, the 1280x720 active array and the mode's 1150x718 crop.
The vendor Windows configuration supplies a 24 MHz external clock and programs the MIPI PLL with a divide-by-12 pre-divider and a multiply-by-90 multiplier. This gives a 180 MHz CSI-2 DDR link frequency, a 360 Mbit/s single-lane bit rate and a 36 MHz pixel rate. With HTS 1616 and VTS 750, the resulting frame rate is approximately 29.7 frames per second.
The exposure, analogue gain and digital gain register layout was independently identified by Jake Steinman. Program multi-byte controls as separate high- and low-byte writes, and bracket exposure and gain updates with the sensor's group hold. The exposure default is 500 lines, selected from illuminated captures on an ASUS Zenbook A14 and programmed by the init sequence so the hardware and control states agree. The controls were exercised on that system, including full-range exposure and analogue gain tests and digital gain endpoint updates while streaming.
--- MAINTAINERS | 7 + drivers/media/i2c/Kconfig | 11 + drivers/media/i2c/Makefile | 1 + drivers/media/i2c/hm1092.c | 863 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 882 insertions(+)
MAINTAINERS +7 -0
@@ -11652,6 +11652,13 @@ L: [email protected] S: Maintained F: drivers/misc/hisi_hikey_usb.c +HIMAX HM1092 SENSOR DRIVER +M: Ramshouriesh R <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/media/i2c/himax,hm1092.yaml +F: drivers/media/i2c/hm1092.c + HIMAX HX83112B TOUCHSCREEN SUPPORT M: Job Noorman <[email protected]> L: [email protected]
drivers/media/i2c/Kconfig +11 -0
@@ -137,6 +137,17 @@ config VIDEO_HI847 To compile this driver as a module, choose M here: the module will be called hi847. +config VIDEO_HM1092 + tristate "Himax HM1092 sensor support" + select V4L2_CCI_I2C + help + This is a Video4Linux2 sensor driver for the Himax HM1092 + monochrome near-infrared CMOS image sensor, used as the + face-authentication IR camera on laptops. + + To compile this driver as a module, choose M here: the + module will be called hm1092. + config VIDEO_IMX111 tristate "Sony IMX111 sensor support" select V4L2_CCI_I2C
drivers/media/i2c/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_VIDEO_GC2145) += gc2145.o obj-$(CONFIG_VIDEO_HI556) += hi556.o obj-$(CONFIG_VIDEO_HI846) += hi846.o obj-$(CONFIG_VIDEO_HI847) += hi847.o +obj-$(CONFIG_VIDEO_HM1092) += hm1092.o obj-$(CONFIG_VIDEO_I2C) += video-i2c.o obj-$(CONFIG_VIDEO_IMX111) += imx111.o obj-$(CONFIG_VIDEO_IMX208) += imx208.o
drivers/media/i2c/hm1092.c new file +863 -0
863 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v6 2/2] media: i2c: hm1092: add Himax HM1092 mono NIR sensor driver
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Incorrect evaluation of `pm_runtime_get_if_in_use()` ignores negative error codes, leading to…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect evaluation of pm_runtime_get_if_in_use() ignores negative error codes, leading to unbalanced pm_runtime_put() and unprotected I2C writes. --
--- Patch [2]: [PATCH v6 2/2] media: i2c: hm1092: add Himax HM1092 mono NIR sensor driver --- commit 5fe0ced142caf11a45ab013b94529b5d66c8da00
Author: Ramshouriesh R <[email protected]>
media: i2c: hm1092: add Himax HM1092 mono NIR sensor driver
Add a V4L2 subdev driver for the Himax HM1092, a 1 megapixel monochrome near-infrared image sensor with a single-lane MIPI CSI-2 interface, typically used as the face-authentication IR camera on laptops.
Quoted 5 lines
drivers/media/i2c/hm1092.c new file +0
-0
[ ... ]
Quoted 4 lines
drivers/media/i2c/hm1092.c new file +3
-0@@ -0,0 +1,863 @@ +static int hm1092_set_ctrl (struct v4l2_ctrl *ctrl) +{ + struct hm1092 *hm1092 = container_of(ctrl->handler, struct hm1092,
drivers/media/i2c/hm1092.c line 13
Quoted 10 lines
drivers/media/i2c/hm1092.c new file +10
-0+ ctrl_handler); +int release_ret; +int ret =0 ; + +/* +* The control value is cached by the framework and (re)applied from +* hm1092_enable_streams() once the device is powered up for streaming. +*/ +if (pm_runtime_get_if_in_use (hm1092->dev) ==0 ) +return 0 ;
[Severity: Medium]
Does this code handle negative error codes properly?
If pm_runtime_get_if_in_use() returns a negative error code (like -EINVAL when runtime PM is disabled), the strict == 0 check will evaluate to false and allow the code to fall through. This could cause the driver to execute I2C writes to a potentially unpowered device.
Quoted 3 lines
drivers/media/i2c/hm1092.c new file +3
-0+ +switch (ctrl->id) { +case V4L2_CID_EXPOSURE :
[ ... ]
drivers/media/i2c/hm1092.c line 389
Quoted 10 lines
drivers/media/i2c/hm1092.c new file +10
-0+case V4L2_CID_TEST_PATTERN : + ret =cci_write (hm1092->regmap,HM1092_REG_TEST_PATTERN , + ctrl->val,NULL ); +break ; +default : + ret = -EINVAL ; +break ; + } + +pm_runtime_put (hm1092->dev);
[Severity: Medium]
Will this unconditional pm_runtime_put() cause a usage counter underflow regression?
Because the prior pm_runtime_get_if_in_use() call does not increment the counter when returning a negative error code, calling pm_runtime_put() here will cause an underflow and trigger a warning from the PM core.
Quoted 3 lines
drivers/media/i2c/hm1092.c new file +3
-0+ +return ret; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Hi Jake,
Are you still planning to send the x86/ACPI support for HM1092 on top of v6? I have a Dell Latitude 7350 with this sensor (running your out-of-tree driver right now) and I'm happy to test any patches on it.
Thanks,
Eduard
cover media: hm1092: Intel IPU (ACPI) support on top of v6
In reply to Ramshouriesh RHi Ramshouriesh, Sakari,
These two patches make the HM1092 usable on Intel IPU laptops, where the sensor is described in ACPI as HIMX1092. They apply on top of "[PATCH v6 0/2] media: Add Himax HM1092 mono NIR sensor driver".
Patch 1 is for the sensor driver. v6 cannot bind on x86: there is no ACPI match table, the 19.2 MHz clock these machines supply is rejected, and the only mode is the 24 MHz one. The patch selects the configuration from the clock rate and adds the 19.2 MHz / 648x368 / 180.48 MHz one. The 24 MHz path is functionally unchanged. Ramshouriesh, feel free to fold it into a v7 if you prefer that to a follow-up.
Patch 2 is independent of the sensor. The IPU7 capture nodes have no pixel format for MEDIA_BUS_FMT_Y10_1X10, so no monochrome sensor can be captured, whatever its driver.
Tested together on a Dell XPS 16 DA16260 (Panther Lake), kernel 7.3-rc5, with the ipu-bridge entry that is already in media/next:
intel_ipu7_isys.isys intel_ipu7.isys.40: bind hm1092 17-0024 nlanes is 1 port is 2
link_frequency 180480000 pixel_rate 36096000 exposure min=2 max=719 default=360
Y10 648x368, 1344 bytes per line, 10 frames, 4945920 bytes
Y10P 648x368, 832 bytes per line, 10 frames, 3061760 bytes
exposure 100: mean level 59
exposure 700: mean level 198
Two things worth knowing when reviewing patch 1:
- The 19.2 MHz configuration reads X 0..1293 and Y 0..733, which is the full 1296x736 array including the dummy border. That is what the vendor sequence programs, so the crop rectangle reports it as is, and it lies outside the 1280x720 crop bounds v6 defines. I left the bounds alone. Say if you would rather have them widened.
- The 24 MHz configuration is compile-tested only here. I have no devicetree hardware with this sensor.
Regards,
Jake
Jake Steinman (2):
media: i2c: hm1092: Add ACPI enumeration and the 19.2 MHz
configuration
media: staging/ipu7: Add 10-bit greyscale capture formats
drivers/media/i2c/hm1092.c | 363 ++++++++++++++++--- drivers/staging/media/ipu7/ipu7-isys-video.c | 4 + 2 files changed, 321 insertions(+), 46 deletions(-)
Signature · 1 line
2.56.0
PATCH 1/2 media: i2c: hm1092: Add ACPI enumeration and the 19.2 MHz configuration
The HM1092 is also the IR camera of Intel IPU6/IPU7 laptops. There it is enumerated through ACPI as HIMX1092 and clocked at 19.2 MHz rather than 24 MHz. The driver cannot bind on those machines: it has no ACPI match table and probe rejects any external clock other than 24 MHz.
Turn the single fixed mode into a table of configurations selected by the external clock rate, each with its own init sequence, link frequency, timings, readout window and exposure default. Add the configuration the vendor Windows driver uses on the Intel platforms:
648x368, HTS 1620, VTS 740, with the PLL pre-divider at 10 and the multiplier at 94, giving 19200000 * 94 / 10 = 180480000 Hz.
ipu-bridge lists both 180000000 and 180480000 for this sensor, so matching any menu entry against the endpoint is no longer enough. Check that the endpoint offers the link frequency of the selected configuration.
The 24 MHz configuration is unchanged: same init sequence, timings, controls and defaults.
Tested on a Dell XPS 16 DA16260 (Panther Lake, IPU7, 19.2 MHz clock from INT3472): the sensor binds on CSI-2 port 2, streams 648x368 at link frequency 180480000 and the exposure control changes the image level. The 24 MHz configuration is compile-tested only.
--- drivers/media/i2c/hm1092.c | 363 ++++++++++++++++++++++++++++++++----- 1 file changed, 317 insertions(+), 46 deletions(-)
drivers/media/i2c/hm1092.c +317 -46
@@ -9,6 +9,7 @@#include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/i2c.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/pm_runtime.h> #include <linux/regulator/consumer.h>
@@ -20,15 +21,19 @@/* * CSI-2 D-PHY link frequency (DDR, i.e. half the per-lane bit rate). * -* The vendor Windows configuration supplies a 24 MHz EXTCLK and programs the -* MIPI PLL pre-divider to 12 (0x030d = 0x0c) and multiplier to 90 -* (0x030f = 0x5a): -* link freq = 24000000 * 90 / 12 = 180000000 -* bit rate = link freq * 2 = 360000000 bps -* pixel_rate = bit rate * 1 lane / 10 bpp = 36000000 pixels/s +* Two vendor Windows configurations are known. Each pairs an EXTCLK rate with +* its own MIPI PLL pre-divider (0x030d) and multiplier (0x030f): +* +* 24 MHz EXTCLK, pre-divider 12, multiplier 90 (Qualcomm): +* link freq = 24000000 * 90 / 12 = 180000000 +* pixel_rate = link freq * 2 * 1 lane / 10 = 36000000 pixels/s +* +* 19.2 MHz EXTCLK, pre-divider 10, multiplier 94 (Intel IPU): +* link freq = 19200000 * 94 / 10 = 180480000 +* pixel_rate = link freq * 2 * 1 lane / 10 = 36096000 pixels/s */ -#define HM1092_LINK_FREQ 180000000ULL -#define HM1092_MCLK 24000000 +#define HM1092_LINK_FREQ_180MHZ 180000000ULL +#define HM1092_LINK_FREQ_180P48MHZ 180480000ULL#define HM1092_BITS_PER_SAMPLE 10#define HM1092_REG_STREAM CCI_REG8(0x0100)
@@ -41,16 +46,14 @@/* * Exposure is a 16-bit value in lines and analogue gain an 8-bit register. * The register layout is not documented publicly; it was recovered from the -* vendor Windows driver. The exposure default (500) was selected from -* illuminated hardware tests and is also programmed by the init sequence at -* 0x0202/0x0203. +* vendor Windows driver. The exposure default is per mode and matches what +* that mode's init sequence programs at 0x0202/0x0203. */ #define HM1092_REG_EXPOSURE_H CCI_REG8(0x0202)#define HM1092_REG_EXPOSURE_L CCI_REG8(0x0203)#define HM1092_EXPOSURE_MIN 2#define HM1092_EXPOSURE_MARGIN 21#define HM1092_EXPOSURE_STEP 1 -#define HM1092_EXPOSURE_DEFAULT 500#define HM1092_REG_ANALOGUE_GAIN CCI_REG8(0x0205)#define HM1092_ANALOGUE_GAIN_MIN 0
@@ -72,9 +75,9 @@/* * Pixel array geometry. The vendor specifies a 1280x720 active array; the * full array including the surrounding dummy/optical-black pixels is 1296x736 -* (8 pixels of margin on each side). The single fixed mode reads a window out -* of the active array (X_ADDR [0x0030..0x04ad], Y_ADDR [0x0008..0x02d5]); -* subsequent internal processing produces the 560x360 output. +* (8 pixels of margin on each side). Each mode reads a fixed window out of +* the array (X_ADDR/Y_ADDR registers 0x0344..0x034b, reported as the crop +* rectangle); subsequent internal processing produces the output size. */ #define HM1092_NATIVE_WIDTH 1296U#define HM1092_NATIVE_HEIGHT 736U
@@ -82,12 +85,8 @@#define HM1092_ACTIVE_TOP 8U#define HM1092_ACTIVE_WIDTH 1280U#define HM1092_ACTIVE_HEIGHT 720U -#define HM1092_CROP_LEFT 48U -#define HM1092_CROP_TOP 8U -#define HM1092_CROP_WIDTH 1150U -#define HM1092_CROP_HEIGHT 718U -static const struct cci_reg_sequence hm1092_init_regs[] = { +static const struct cci_reg_sequence hm1092_560x360_regs[] = { {CCI_REG8 (0x0103 ),0x00 }, {CCI_REG8 (0x030a ),0x05 }, {CCI_REG8 (0x030d ),0x0c },
@@ -275,18 +274,265 @@ static const struct cci_reg_sequence hm1092_init_regs[] = { { CCI_REG8(0x0037), 0x30 }, }; +/* +* Init sequence used with a 19.2 MHz EXTCLK, as found on Intel IPU laptops +* where the sensor is described in ACPI as HIMX1092. Recovered from the +* vendor Windows driver for those platforms; kept in the order that driver +* issues it, including its repeated writes. +*/ +static const struct cci_reg_sequence hm1092_648x368_regs[] = { + {CCI_REG8 (0x0100 ),0x00 }, + {CCI_REG8 (0x0103 ),0x00 }, + {CCI_REG8 (0x0000 ),0x00 }, + {CCI_REG8 (0x0101 ),0x00 }, + {CCI_REG8 (0x0202 ),0x02 }, + {CCI_REG8 (0x0203 ),0xe5 }, + {CCI_REG8 (0x0307 ),0x00 }, + {CCI_REG8 (0x0309 ),0x01 }, + {CCI_REG8 (0x030a ),0x05 }, + {CCI_REG8 (0x030d ),0x0a }, + {CCI_REG8 (0x030f ),0x5e }, + {CCI_REG8 (0x0310 ),0x00 }, + {CCI_REG8 (0x0340 ),0x03 }, + {CCI_REG8 (0x0341 ),0x1e }, + {CCI_REG8 (0x0342 ),0x05 }, + {CCI_REG8 (0x0343 ),0xe4 }, + {CCI_REG8 (0x0350 ),0x53 }, + {CCI_REG8 (0x0387 ),0x01 }, + {CCI_REG8 (0x3110 ),0x02 }, + {CCI_REG8 (0x3735 ),0xe2 }, + {CCI_REG8 (0x3704 ),0x04 }, + {CCI_REG8 (0x4001 ),0x00 }, + {CCI_REG8 (0x4002 ),0x2b }, + {CCI_REG8 (0x4024 ),0x40 }, + {CCI_REG8 (0x4131 ),0x01 }, + {CCI_REG8 (0x4132 ),0x20 }, + {CCI_REG8 (0x4265 ),0x02 }, + {CCI_REG8 (0x4b04 ),0x01 }, + {CCI_REG8 (0x4b0e ),0x0e }, + {CCI_REG8 (0x4b18 ),0x00 }, + {CCI_REG8 (0x4b20 ),0x9e }, + {CCI_REG8 (0x4b31 ),0x06 }, + {CCI_REG8 (0x4b3b ),0x02 }, + {CCI_REG8 (0x4b3e ),0x00 }, + {CCI_REG8 (0x4b44 ),0x0c }, + {CCI_REG8 (0x4b45 ),0x01 }, + {CCI_REG8 (0x4b47 ),0x00 }, + {CCI_REG8 (0x5004 ),0x40 }, + {CCI_REG8 (0x5005 ),0x28 }, + {CCI_REG8 (0x5006 ),0x40 }, + {CCI_REG8 (0x5007 ),0x28 }, + {CCI_REG8 (0x5010 ),0x20 }, + {CCI_REG8 (0x5011 ),0x00 }, + {CCI_REG8 (0x5013 ),0x03 }, + {CCI_REG8 (0x5015 ),0xb3 }, + {CCI_REG8 (0x501d ),0x4c }, + {CCI_REG8 (0x5098 ),0x00 }, + {CCI_REG8 (0x5099 ),0x11 }, + {CCI_REG8 (0x509b ),0x03 }, + {CCI_REG8 (0x50a0 ),0x30 }, + {CCI_REG8 (0x50a2 ),0x0b }, + {CCI_REG8 (0x50a6 ),0x00 }, + {CCI_REG8 (0x50a7 ),0x00 }, + {CCI_REG8 (0x50aa ),0x22 }, + {CCI_REG8 (0x50ab ),0x07 }, + {CCI_REG8 (0x50ac ),0x24 }, + {CCI_REG8 (0x50ad ),0x07 }, + {CCI_REG8 (0x50ae ),0x20 }, + {CCI_REG8 (0x50af ),0x40 }, + {CCI_REG8 (0x50b3 ),0x04 }, + {CCI_REG8 (0x50b4 ),0x00 }, + {CCI_REG8 (0x50b7 ),0x00 }, + {CCI_REG8 (0x50b8 ),0x70 }, + {CCI_REG8 (0x50b9 ),0xff }, + {CCI_REG8 (0x50ba ),0xff }, + {CCI_REG8 (0x50bb ),0x14 }, + {CCI_REG8 (0x50cb ),0x21 }, + {CCI_REG8 (0x50d5 ),0xe0 }, + {CCI_REG8 (0x50d7 ),0x12 }, + {CCI_REG8 (0x50dd ),0x00 }, + {CCI_REG8 (0x50e8 ),0x00 }, + {CCI_REG8 (0x50ea ),0x74 }, + {CCI_REG8 (0x50fa ),0x02 }, + {CCI_REG8 (0x5100 ),0x03 }, + {CCI_REG8 (0x5101 ),0x13 }, + {CCI_REG8 (0x5102 ),0x23 }, + {CCI_REG8 (0x5103 ),0x33 }, + {CCI_REG8 (0x5104 ),0x43 }, + {CCI_REG8 (0x5105 ),0x42 }, + {CCI_REG8 (0x5106 ),0x40 }, + {CCI_REG8 (0x5118 ),0x00 }, + {CCI_REG8 (0x5119 ),0x00 }, + {CCI_REG8 (0x511a ),0x00 }, + {CCI_REG8 (0x511b ),0x00 }, + {CCI_REG8 (0x511c ),0x00 }, + {CCI_REG8 (0x511d ),0x00 }, + {CCI_REG8 (0x511e ),0x00 }, + {CCI_REG8 (0x5130 ),0x13 }, + {CCI_REG8 (0x5131 ),0x23 }, + {CCI_REG8 (0x5132 ),0x33 }, + {CCI_REG8 (0x5133 ),0x43 }, + {CCI_REG8 (0x5134 ),0x42 }, + {CCI_REG8 (0x5135 ),0x40 }, + {CCI_REG8 (0x5136 ),0x40 }, + {CCI_REG8 (0x5148 ),0x01 }, + {CCI_REG8 (0x5149 ),0x01 }, + {CCI_REG8 (0x514a ),0x01 }, + {CCI_REG8 (0x514b ),0x01 }, + {CCI_REG8 (0x514c ),0x01 }, + {CCI_REG8 (0x514d ),0x01 }, + {CCI_REG8 (0x514e ),0x01 }, + {CCI_REG8 (0x51c0 ),0x00 }, + {CCI_REG8 (0x51c1 ),0x81 }, + {CCI_REG8 (0x51c2 ),0xec }, + {CCI_REG8 (0x51c3 ),0x00 }, + {CCI_REG8 (0x51c4 ),0x55 }, + {CCI_REG8 (0x51c5 ),0x44 }, + {CCI_REG8 (0x51c6 ),0x00 }, + {CCI_REG8 (0x51c7 ),0x81 }, + {CCI_REG8 (0x51c8 ),0xec }, + {CCI_REG8 (0x51c9 ),0x00 }, + {CCI_REG8 (0x51ca ),0x55 }, + {CCI_REG8 (0x51cb ),0x24 }, + {CCI_REG8 (0x51cc ),0x00 }, + {CCI_REG8 (0x51cd ),0x81 }, + {CCI_REG8 (0x51ce ),0xec }, + {CCI_REG8 (0x51cf ),0x00 }, + {CCI_REG8 (0x51d0 ),0x54 }, + {CCI_REG8 (0x51d1 ),0x24 }, + {CCI_REG8 (0x51d2 ),0x00 }, + {CCI_REG8 (0x51d3 ),0x81 }, + {CCI_REG8 (0x51d4 ),0xec }, + {CCI_REG8 (0x51d5 ),0x00 }, + {CCI_REG8 (0x51d6 ),0x53 }, + {CCI_REG8 (0x51d7 ),0x14 }, + {CCI_REG8 (0x51d8 ),0x00 }, + {CCI_REG8 (0x51d9 ),0x81 }, + {CCI_REG8 (0x51da ),0xec }, + {CCI_REG8 (0x51db ),0x00 }, + {CCI_REG8 (0x51dc ),0x53 }, + {CCI_REG8 (0x51dd ),0x14 }, + {CCI_REG8 (0x51e0 ),0x09 }, + {CCI_REG8 (0x51e1 ),0x03 }, + {CCI_REG8 (0x51e2 ),0x04 }, + {CCI_REG8 (0x51e3 ),0x03 }, + {CCI_REG8 (0x51e4 ),0x08 }, + {CCI_REG8 (0x51e5 ),0x07 }, + {CCI_REG8 (0x51e6 ),0x08 }, + {CCI_REG8 (0x51e7 ),0x07 }, + {CCI_REG8 (0x51e8 ),0x04 }, + {CCI_REG8 (0x51e9 ),0x46 }, + {CCI_REG8 (0x51ea ),0x43 }, + {CCI_REG8 (0x51eb ),0x62 }, + {CCI_REG8 (0x51ec ),0x61 }, + {CCI_REG8 (0x51ed ),0x00 }, + {CCI_REG8 (0x51ee ),0x00 }, + {CCI_REG8 (0x5200 ),0x60 }, + {CCI_REG8 (0x5201 ),0x80 }, + {CCI_REG8 (0x5202 ),0x00 }, + {CCI_REG8 (0x5203 ),0x01 }, + {CCI_REG8 (0x5206 ),0x80 }, + {CCI_REG8 (0x5208 ),0x0b }, + {CCI_REG8 (0x5209 ),0x0c }, + {CCI_REG8 (0x520c ),0x15 }, + {CCI_REG8 (0x520d ),0x40 }, + {CCI_REG8 (0x5214 ),0x28 }, + {CCI_REG8 (0x5215 ),0x04 }, + {CCI_REG8 (0x5216 ),0x02 }, + {CCI_REG8 (0x5217 ),0x01 }, + {CCI_REG8 (0x5218 ),0x07 }, + {CCI_REG8 (0x521e ),0x01 }, + {CCI_REG8 (0x5282 ),0xff }, + {CCI_REG8 (0x5283 ),0x03 }, + {CCI_REG8 (0x0202 ),0x01 }, + {CCI_REG8 (0x0203 ),0x68 }, + {CCI_REG8 (0x0340 ),0x02 }, + {CCI_REG8 (0x0341 ),0xe4 }, + {CCI_REG8 (0x0342 ),0x06 }, + {CCI_REG8 (0x0343 ),0x54 }, + {CCI_REG8 (0x0344 ),0x00 }, + {CCI_REG8 (0x0345 ),0x00 }, + {CCI_REG8 (0x0346 ),0x00 }, + {CCI_REG8 (0x0347 ),0x00 }, + {CCI_REG8 (0x0348 ),0x05 }, + {CCI_REG8 (0x0349 ),0x0d }, + {CCI_REG8 (0x034a ),0x02 }, + {CCI_REG8 (0x034b ),0xdd }, + {CCI_REG8 (0x034c ),0x02 }, + {CCI_REG8 (0x034d ),0x88 }, + {CCI_REG8 (0x034e ),0x01 }, + {CCI_REG8 (0x034f ),0x70 }, + {CCI_REG8 (0x0383 ),0x00 }, + {CCI_REG8 (0x0387 ),0x10 }, + {CCI_REG8 (0x0390 ),0x03 }, + {CCI_REG8 (0x4800 ),0xac }, + {CCI_REG8 (0x0104 ),0x01 }, + {CCI_REG8 (0x0104 ),0x00 }, + {CCI_REG8 (0x4801 ),0xae }, + {CCI_REG8 (0x4b20 ),0x9e }, + {CCI_REG8 (0x0101 ),0x03 }, +}; + +/** +* struct hm1092_mode - sensor configuration, selected by the EXTCLK rate +* @mclk: EXTCLK rate the init sequence programs the PLL for +* @link_freq_index: index into hm1092_link_freq_menu +* @width: output width +* @height: output height +* @hts: horizontal total size, 0x0342/0x0343 +* @vts: vertical total size, 0x0340/0x0341 +* @exposure_def: exposure programmed by the init sequence +* @crop: readout window on the pixel array +* @regs: init sequence +* @num_regs: number of entries in @regs +*/ struct hm1092_mode { +unsigned long mclk; +unsigned int link_freq_index;u32 width;u32 height;u32 hts;u32 vts; +u32 exposure_def; +struct v4l2_rect crop; +const struct cci_reg_sequence *regs; +unsigned int num_regs; }; -static const struct hm1092_mode hm1092_mode_560x360 = { - .width =560 , - .height =360 , - .hts =0x0650 , - .vts =0x02ee , +static const struct hm1092_mode hm1092_modes[] = { + { + .mclk =24000000 , + .link_freq_index =0 , + .width =560 , + .height =360 , + .hts =0x0650 , + .vts =0x02ee , + .exposure_def =500 , + .crop = { + .left =48 , + .top =8 , + .width =1150 , + .height =718 , + }, + .regs = hm1092_560x360_regs, + .num_regs =ARRAY_SIZE (hm1092_560x360_regs), + }, { + .mclk =19200000 , + .link_freq_index =1 , + .width =648 , + .height =368 , + .hts =0x0654 , + .vts =0x02e4 , + .exposure_def =360 , + .crop = { + .left =0 , + .top =0 , + .width =1294 , + .height =734 , + }, + .regs = hm1092_648x368_regs, + .num_regs =ARRAY_SIZE (hm1092_648x368_regs), + }, }; static const char * const hm1092_supply_names[] = {
@@ -309,7 +555,8 @@ static const char * const hm1092_test_pattern_menu[] = { };static const s64 hm1092_link_freq_menu[] = { -HM1092_LINK_FREQ , +HM1092_LINK_FREQ_180MHZ , +HM1092_LINK_FREQ_180P48MHZ , };struct hm1092 {
@@ -326,6 +573,7 @@ struct hm1092 {struct v4l2_ctrl *hblank;struct v4l2_ctrl *vblank;struct v4l2_ctrl *exposure; +const struct hm1092_mode *mode;u8 mipi_lanes; };
@@ -398,7 +646,7 @@ static const struct v4l2_ctrl_ops hm1092_ctrl_ops = {static int hm1092_init_controls (struct hm1092 *hm1092) {struct v4l2_ctrl_handler *ctrl_hdlr = &hm1092->ctrl_handler; -const struct hm1092_mode *mode = &hm1092_mode_560x360; +const struct hm1092_mode *mode = hm1092->mode;struct v4l2_fwnode_device_properties props;s64 hblank, pixel_rate;int ret;
@@ -412,11 +660,12 @@ static int hm1092_init_controls(struct hm1092 *hm1092) hm1092->link_freq =v4l2_ctrl_new_int_menu (ctrl_hdlr, &hm1092_ctrl_ops,V4L2_CID_LINK_FREQ , -0 ,0 , +ARRAY_SIZE (hm1092_link_freq_menu) -1 , + mode->link_freq_index, hm1092_link_freq_menu); - pixel_rate =div_u64 (HM1092_LINK_FREQ *2 * hm1092->mipi_lanes, -HM1092_BITS_PER_SAMPLE ); + pixel_rate =div_u64 (hm1092_link_freq_menu[mode->link_freq_index] *2 * + hm1092->mipi_lanes,HM1092_BITS_PER_SAMPLE ); hm1092->pixel_rate =v4l2_ctrl_new_std (ctrl_hdlr, &hm1092_ctrl_ops,V4L2_CID_PIXEL_RATE ,0 , pixel_rate,1 , pixel_rate);
@@ -438,7 +687,7 @@ static int hm1092_init_controls(struct hm1092 *hm1092) mode->vts -HM1092_EXPOSURE_MARGIN ,HM1092_EXPOSURE_STEP , - HM1092_EXPOSURE_DEFAULT); + mode->exposure_def); v4l2_ctrl_new_std(ctrl_hdlr, &hm1092_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
@@ -480,10 +729,11 @@ err_free:return ret; } -static void hm1092_update_pad_format (struct v4l2_mbus_framefmt *fmt) +static void hm1092_update_pad_format (const struct hm1092_mode *mode, +struct v4l2_mbus_framefmt *fmt) { - fmt->width = hm1092_mode_560x360.width; - fmt->height = hm1092_mode_560x360.height; + fmt->width = mode->width; + fmt->height = mode->height; fmt->code =MEDIA_BUS_FMT_Y10_1X10 ; fmt->field =V4L2_FIELD_NONE ; fmt->colorspace =V4L2_COLORSPACE_RAW ;
@@ -503,8 +753,8 @@ static int hm1092_enable_streams(struct v4l2_subdev *sd,if (ret)return ret; - ret =cci_multi_reg_write (hm1092->regmap, hm1092_init_regs, -ARRAY_SIZE (hm1092_init_regs),NULL ); + ret =cci_multi_reg_write (hm1092->regmap, hm1092->mode->regs, + hm1092->mode->num_regs,NULL );if (ret) {dev_err (hm1092->dev,"failed to write init registers\n" ); goto out;
@@ -556,16 +806,18 @@ static int hm1092_enum_frame_size(struct v4l2_subdev *sd,struct v4l2_subdev_state *state, struct v4l2_subdev_frame_size_enum *fse) { + const struct hm1092_mode *mode = to_hm1092(sd)->mode; +if (fse->index)return -EINVAL ;if (fse->code !=MEDIA_BUS_FMT_Y10_1X10 )return -EINVAL ; - fse->min_width = hm1092_mode_560x360.width; - fse->max_width = hm1092_mode_560x360.width; - fse->min_height = hm1092_mode_560x360.height; - fse->max_height = hm1092_mode_560x360.height; + fse->min_width = mode->width; + fse->max_width = mode->width; + fse->min_height = mode->height; + fse->max_height = mode->height;return 0 ; }
@@ -576,10 +828,7 @@ static int hm1092_get_selection(struct v4l2_subdev *sd, {switch (sel->target) {case V4L2_SEL_TGT_CROP : - sel->r.left =HM1092_CROP_LEFT ; - sel->r.top =HM1092_CROP_TOP ; - sel->r.width =HM1092_CROP_WIDTH ; - sel->r.height =HM1092_CROP_HEIGHT ; + sel->r =to_hm1092 (sd)->mode->crop;return 0 ;case V4L2_SEL_TGT_CROP_DEFAULT :case V4L2_SEL_TGT_CROP_BOUNDS :
@@ -602,7 +851,8 @@ static int hm1092_get_selection(struct v4l2_subdev *sd,static int hm1092_init_state (struct v4l2_subdev *sd,struct v4l2_subdev_state *state) { -hm1092_update_pad_format (v4l2_subdev_state_get_format (state,0 )); +hm1092_update_pad_format (to_hm1092 (sd)->mode, +v4l2_subdev_state_get_format (state,0 ));return 0 ; }
@@ -663,6 +913,14 @@ static int hm1092_check_hwcfg(struct hm1092 *hm1092)if (ret) goto out; +if (!(link_freq_bitmap &BIT (hm1092->mode->link_freq_index))) { + ret =dev_err_probe (dev, -EINVAL , +"link frequency %lld not available for a %lu Hz external clock\n" , + hm1092_link_freq_menu[hm1092->mode->link_freq_index], + hm1092->mode->mclk); + goto out; + } +if (bus_cfg.bus.mipi_csi2.num_data_lanes !=1 ) { ret = dev_err_probe(dev, -EINVAL, "only 1 data lane is supported, got %u\n",
@@ -775,7 +1033,13 @@ static int hm1092_probe(struct i2c_client *client) "failed to get imaging clock\n"); freq =clk_get_rate (hm1092->img_clk); -if (freq !=HM1092_MCLK ) +for (unsigned int i =0 ; i <ARRAY_SIZE (hm1092_modes); i++) { +if (hm1092_modes[i].mclk == freq) { + hm1092->mode = &hm1092_modes[i]; +break ; + } + } +if (!hm1092->mode)return dev_err_probe (hm1092->dev, -EINVAL ,"external clock %lu is not supported\n" , freq);
@@ -841,6 +1105,12 @@ err_ctrls: static DEFINE_RUNTIME_DEV_PM_OPS(hm1092_pm_ops, hm1092_power_off, hm1092_power_on, NULL); +static const struct acpi_device_id hm1092_acpi_ids[] = { + {"HIMX1092" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (acpi, hm1092_acpi_ids); +static const struct of_device_id hm1092_of_match[] = { { .compatible ="himax,hm1092" }, {/* sentinel */ }
@@ -851,6 +1121,7 @@ static struct i2c_driver hm1092_i2c_driver = { .driver = { .name = "hm1092", .pm = pm_ptr(&hm1092_pm_ops), + .acpi_match_table = hm1092_acpi_ids, .of_match_table = hm1092_of_match, }, .probe = hm1092_probe,
Signature · 1 line
2.56.0
Re: [PATCH 1/2] media: i2c: hm1092: Add ACPI enumeration and the 19.2 MHz configuration
Hi Jake,
Tested v6 plus this patch on a Dell Latitude 7350 (Meteor Lake, IPU6), kernel 7.2.3, with an out-of-tree ipu-bridge that has the HIMX1092 entry. Patch 2 is not needed there, IPU6 already has Y10.
The sensor binds as hm1092 i2c-HIMX1092:00 and streams Y10 648x368 (1344 bytes per line) through IPU6 CSI2 4 at link frequency 180480000.
- v4l2-compliance 1.32.0 on the subdev: 46 tests, 0 failures, 0 warnings
- 300 frames at 30.11 fps, 20 start/stop cycles without errors
- runtime PM: suspended when idle, active while streaming
- streams again after s2idle suspend/resume
- exposure and analogue gain behave as expected (analogue gain 0/32/64/128/255 gives mean levels 16/31/45/73/113)
- IR flood LED (INT3472) off/on/off at exposure 700: mean levels 9/117/9, clean IR image with the LED on
- the crop rectangle reads (0,0)/1294x734 against bounds (8,8)/1280x720, as you described
One issue, which I think comes from v6 rather than this patch:digital_gain is advertised as 256..4095, but only the low 10 bits seem to take effect. At exposure 100:
256 -> 15 1024 -> 8 (black frame) 512 -> 22 1280 -> 15 768 -> 29 2048 -> 8 (black frame) 1023 -> 36 4095 -> 35
So 1024 behaves like 0 and 1280 like 256. Perhaps the maximum should be 0x3ff, but I don't have the datasheet to confirm.
Thanks a lot for your work on this. If you need anything else tested on this machine, feel free to contact me.
Regards,
Eduard
Re: [PATCH 1/2] media: i2c: hm1092: Add ACPI enumeration and the 19.2 MHz configuration
In reply to Jake SteinmanHello,
Quoted 2 lines · Jake Steinman
#include <
linux/i2c.h>
+#include <linux/mod_devicetable.h>
Please don't add new usages of <linux/mod_devicetable.h>. The subsystem headers provide their respective *_device_id structures already. So <linux/i2c.h> already provides i2c_device_id (and of_device_id). If you still think you need a specific header for these structures, please use <linux/device-id/$subsystem.h>.
Best regards
Uwe
Re: [PATCH 1/2] media: i2c: hm1092: Add ACPI enumeration and the 19.2 MHz configuration
Hi Uwe,
Quoted 2 lines · Uwe Kleine-König
Please don't add new usages of <
linux/mod_devicetable.h>. The subsystem headers provide their respective*_device_idstructures already.
Thanks. I will drop the include in v2, <linux/i2c.h> is enough here.
Jake
PATCH 2/2 media: staging/ipu7: Add 10-bit greyscale capture formats
In reply to Jake SteinmanThe CSI-2 receiver sub-device accepts MEDIA_BUS_FMT_Y10_1X10, but the capture nodes have no pixel format that maps to it. Link validation between the receiver and the capture node therefore always fails for a monochrome sensor and nothing can be captured from it.
Add V4L2_PIX_FMT_Y10 and V4L2_PIX_FMT_Y10P. They use the same firmware frame formats as the unpacked and packed 10-bit Bayer formats, as the ipu6 driver already does.
Tested on Panther Lake with a Himax HM1092: both formats capture 648x368 frames, with 1344 and 832 bytes per line.
--- drivers/staging/media/ipu7/ipu7-isys-video.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/staging/media/ipu7/ipu7-isys-video.c +4 -0
@@ -54,6 +54,8 @@ const struct ipu7_isys_pixelformat ipu7_isys_pfmts[] = { IPU_INSYS_FRAME_FORMAT_RAW16}, {V4L2_PIX_FMT_SRGGB10 ,16 ,10 ,MEDIA_BUS_FMT_SRGGB10_1X10 , IPU_INSYS_FRAME_FORMAT_RAW16}, + {V4L2_PIX_FMT_Y10, 16, 10, MEDIA_BUS_FMT_Y10_1X10, + IPU_INSYS_FRAME_FORMAT_RAW16}, {V4L2_PIX_FMT_SBGGR8, 8, 8, MEDIA_BUS_FMT_SBGGR8_1X8, IPU_INSYS_FRAME_FORMAT_RAW8}, {V4L2_PIX_FMT_SGBRG8, 8, 8, MEDIA_BUS_FMT_SGBRG8_1X8,
@@ -78,6 +80,8 @@ const struct ipu7_isys_pixelformat ipu7_isys_pfmts[] = { IPU_INSYS_FRAME_FORMAT_RAW10}, {V4L2_PIX_FMT_SRGGB10P ,10 ,10 ,MEDIA_BUS_FMT_SRGGB10_1X10 , IPU_INSYS_FRAME_FORMAT_RAW10}, + {V4L2_PIX_FMT_Y10P, 10, 10, MEDIA_BUS_FMT_Y10_1X10, + IPU_INSYS_FRAME_FORMAT_RAW10}, {V4L2_PIX_FMT_UYVY, 16, 16, MEDIA_BUS_FMT_UYVY8_1X16, IPU_INSYS_FRAME_FORMAT_UYVY}, {V4L2_PIX_FMT_YUYV, 16, 16, MEDIA_BUS_FMT_YUYV8_1X16,
Signature · 1 line
2.56.0
Sakari Ailus
maintainerRe: [PATCH 2/2] media: staging/ipu7: Add 10-bit greyscale capture formats
Hi Jake,
Quoted 9 lines · Jake Steinman
The CSI-2 receiver sub-device accepts
MEDIA_BUS_FMT_Y10_1X10, but the capture nodes have no pixel format that maps to it. Link validation between the receiver and the capture node therefore always fails for a monochrome sensor and nothing can be captured from it.Add
V4L2_PIX_FMT_Y10andV4L2_PIX_FMT_Y10P. They use the same firmware frame formats as the unpacked and packed 10-bit Bayer formats, as the ipu6 driver already does.
Quoted 7 lines
Tested on Panther Lake with a Himax HM1092: both formats capture 648x368 frames, with 1344 and 832 bytes per line.
Assisted-by Claude:claude-opus-5-5Signed-off-by Jake Steinman <[email protected]>--- drivers/staging/media/ipu7/ipu7-isys-video.c | 4 ++++
We're about to remove the ipu7 staging driver, therefore I'm not taking non-fix patches to it. Can you se the ipu6 driver instead?
Signature · 3 lines
Regards, Sakari Ailus
Re: [PATCH 2/2] media: staging/ipu7: Add 10-bit greyscale capture formats
Hi Sakari,
Quoted 2 lines · Sakari Ailus
We're about to remove the ipu7 staging driver, therefore I'm not taking non-fix patches to it. Can you se the ipu6 driver instead?
Understood, I will drop this patch. The ipu6 driver already has Y10 and Y10P, so nothing is needed there. I will retest the sensor patch on Panther Lake with the ipu6 driver from media/next and send v2 with the result.
Jake
PATCH v2 1/1 media: i2c: hm1092: Add ACPI enumeration and the 19.2 MHz configuration
In reply to Ramshouriesh RThe HM1092 is also the IR camera of Intel IPU6/IPU7 laptops. There it is enumerated through ACPI as HIMX1092 and clocked at 19.2 MHz rather than 24 MHz. The driver cannot bind on those machines: it has no ACPI match table and probe rejects any external clock other than 24 MHz.
Turn the single fixed mode into a table of configurations selected by the external clock rate, each with its own init sequence, link frequency, timings, readout window and exposure default. Add the configuration the vendor Windows driver uses on the Intel platforms:
648x368, HTS 1620, VTS 740, with the PLL pre-divider at 10 and the multiplier at 94, giving 19200000 * 94 / 10 = 180480000 Hz.
ipu-bridge lists both 180000000 and 180480000 for this sensor, so matching any menu entry against the endpoint is no longer enough. Check that the endpoint offers the link frequency of the selected configuration.
The 24 MHz configuration is unchanged: same init sequence, timings, controls and defaults.
Tested on a Dell XPS 16 DA16260 (Panther Lake, IPU7.5, 19.2 MHz clock from INT3472) with the ipu6 driver on v7.4-rc1: the sensor binds on CSI-2 port 2, streams 648x368 Y10 at link frequency 180480000 and is used daily for IR face authentication. The 24 MHz configuration is compile-tested only.
---
Changes in v2:
- Drop <linux/mod_devicetable.h>, <linux/i2c.h> already provides the match table types (Uwe).
- Drop the staging ipu7 Y10 patch; the ipu6 driver already has Y10 and Y10P (Sakari). Retested with the ipu6 driver as described above.
v1: https://lore.kernel.org/linux-media/[email protected]/
Note for v6: on v7.4-rc1 the v6 driver needs its set_fmt and get_selection pad ops updated for the struct v4l2_subdev_client_info argument added by commit 7eef49c16461 ("media: v4l2-subdev: Add struct v4l2_subdev_client_info pointer to pad ops"). I tested with that adjustment applied locally; it is not part of this patch.
drivers/media/i2c/hm1092.c | 362 ++++++++++++++++++++++++++++++++----- 1 file changed, 316 insertions(+), 46 deletions(-)
drivers/media/i2c/hm1092.c +316 -46
@@ -20,15 +20,19 @@/* * CSI-2 D-PHY link frequency (DDR, i.e. half the per-lane bit rate). * -* The vendor Windows configuration supplies a 24 MHz EXTCLK and programs the -* MIPI PLL pre-divider to 12 (0x030d = 0x0c) and multiplier to 90 -* (0x030f = 0x5a): -* link freq = 24000000 * 90 / 12 = 180000000 -* bit rate = link freq * 2 = 360000000 bps -* pixel_rate = bit rate * 1 lane / 10 bpp = 36000000 pixels/s +* Two vendor Windows configurations are known. Each pairs an EXTCLK rate with +* its own MIPI PLL pre-divider (0x030d) and multiplier (0x030f): +* +* 24 MHz EXTCLK, pre-divider 12, multiplier 90 (Qualcomm): +* link freq = 24000000 * 90 / 12 = 180000000 +* pixel_rate = link freq * 2 * 1 lane / 10 = 36000000 pixels/s +* +* 19.2 MHz EXTCLK, pre-divider 10, multiplier 94 (Intel IPU): +* link freq = 19200000 * 94 / 10 = 180480000 +* pixel_rate = link freq * 2 * 1 lane / 10 = 36096000 pixels/s */ -#define HM1092_LINK_FREQ 180000000ULL -#define HM1092_MCLK 24000000 +#define HM1092_LINK_FREQ_180MHZ 180000000ULL +#define HM1092_LINK_FREQ_180P48MHZ 180480000ULL#define HM1092_BITS_PER_SAMPLE 10#define HM1092_REG_STREAM CCI_REG8(0x0100)
@@ -41,16 +45,14 @@/* * Exposure is a 16-bit value in lines and analogue gain an 8-bit register. * The register layout is not documented publicly; it was recovered from the -* vendor Windows driver. The exposure default (500) was selected from -* illuminated hardware tests and is also programmed by the init sequence at -* 0x0202/0x0203. +* vendor Windows driver. The exposure default is per mode and matches what +* that mode's init sequence programs at 0x0202/0x0203. */ #define HM1092_REG_EXPOSURE_H CCI_REG8(0x0202)#define HM1092_REG_EXPOSURE_L CCI_REG8(0x0203)#define HM1092_EXPOSURE_MIN 2#define HM1092_EXPOSURE_MARGIN 21#define HM1092_EXPOSURE_STEP 1 -#define HM1092_EXPOSURE_DEFAULT 500#define HM1092_REG_ANALOGUE_GAIN CCI_REG8(0x0205)#define HM1092_ANALOGUE_GAIN_MIN 0
@@ -72,9 +74,9 @@/* * Pixel array geometry. The vendor specifies a 1280x720 active array; the * full array including the surrounding dummy/optical-black pixels is 1296x736 -* (8 pixels of margin on each side). The single fixed mode reads a window out -* of the active array (X_ADDR [0x0030..0x04ad], Y_ADDR [0x0008..0x02d5]); -* subsequent internal processing produces the 560x360 output. +* (8 pixels of margin on each side). Each mode reads a fixed window out of +* the array (X_ADDR/Y_ADDR registers 0x0344..0x034b, reported as the crop +* rectangle); subsequent internal processing produces the output size. */ #define HM1092_NATIVE_WIDTH 1296U#define HM1092_NATIVE_HEIGHT 736U
@@ -82,12 +84,8 @@#define HM1092_ACTIVE_TOP 8U#define HM1092_ACTIVE_WIDTH 1280U#define HM1092_ACTIVE_HEIGHT 720U -#define HM1092_CROP_LEFT 48U -#define HM1092_CROP_TOP 8U -#define HM1092_CROP_WIDTH 1150U -#define HM1092_CROP_HEIGHT 718U -static const struct cci_reg_sequence hm1092_init_regs[] = { +static const struct cci_reg_sequence hm1092_560x360_regs[] = { {CCI_REG8 (0x0103 ),0x00 }, {CCI_REG8 (0x030a ),0x05 }, {CCI_REG8 (0x030d ),0x0c },
@@ -275,18 +273,265 @@ static const struct cci_reg_sequence hm1092_init_regs[] = { { CCI_REG8(0x0037), 0x30 }, }; +/* +* Init sequence used with a 19.2 MHz EXTCLK, as found on Intel IPU laptops +* where the sensor is described in ACPI as HIMX1092. Recovered from the +* vendor Windows driver for those platforms; kept in the order that driver +* issues it, including its repeated writes. +*/ +static const struct cci_reg_sequence hm1092_648x368_regs[] = { + {CCI_REG8 (0x0100 ),0x00 }, + {CCI_REG8 (0x0103 ),0x00 }, + {CCI_REG8 (0x0000 ),0x00 }, + {CCI_REG8 (0x0101 ),0x00 }, + {CCI_REG8 (0x0202 ),0x02 }, + {CCI_REG8 (0x0203 ),0xe5 }, + {CCI_REG8 (0x0307 ),0x00 }, + {CCI_REG8 (0x0309 ),0x01 }, + {CCI_REG8 (0x030a ),0x05 }, + {CCI_REG8 (0x030d ),0x0a }, + {CCI_REG8 (0x030f ),0x5e }, + {CCI_REG8 (0x0310 ),0x00 }, + {CCI_REG8 (0x0340 ),0x03 }, + {CCI_REG8 (0x0341 ),0x1e }, + {CCI_REG8 (0x0342 ),0x05 }, + {CCI_REG8 (0x0343 ),0xe4 }, + {CCI_REG8 (0x0350 ),0x53 }, + {CCI_REG8 (0x0387 ),0x01 }, + {CCI_REG8 (0x3110 ),0x02 }, + {CCI_REG8 (0x3735 ),0xe2 }, + {CCI_REG8 (0x3704 ),0x04 }, + {CCI_REG8 (0x4001 ),0x00 }, + {CCI_REG8 (0x4002 ),0x2b }, + {CCI_REG8 (0x4024 ),0x40 }, + {CCI_REG8 (0x4131 ),0x01 }, + {CCI_REG8 (0x4132 ),0x20 }, + {CCI_REG8 (0x4265 ),0x02 }, + {CCI_REG8 (0x4b04 ),0x01 }, + {CCI_REG8 (0x4b0e ),0x0e }, + {CCI_REG8 (0x4b18 ),0x00 }, + {CCI_REG8 (0x4b20 ),0x9e }, + {CCI_REG8 (0x4b31 ),0x06 }, + {CCI_REG8 (0x4b3b ),0x02 }, + {CCI_REG8 (0x4b3e ),0x00 }, + {CCI_REG8 (0x4b44 ),0x0c }, + {CCI_REG8 (0x4b45 ),0x01 }, + {CCI_REG8 (0x4b47 ),0x00 }, + {CCI_REG8 (0x5004 ),0x40 }, + {CCI_REG8 (0x5005 ),0x28 }, + {CCI_REG8 (0x5006 ),0x40 }, + {CCI_REG8 (0x5007 ),0x28 }, + {CCI_REG8 (0x5010 ),0x20 }, + {CCI_REG8 (0x5011 ),0x00 }, + {CCI_REG8 (0x5013 ),0x03 }, + {CCI_REG8 (0x5015 ),0xb3 }, + {CCI_REG8 (0x501d ),0x4c }, + {CCI_REG8 (0x5098 ),0x00 }, + {CCI_REG8 (0x5099 ),0x11 }, + {CCI_REG8 (0x509b ),0x03 }, + {CCI_REG8 (0x50a0 ),0x30 }, + {CCI_REG8 (0x50a2 ),0x0b }, + {CCI_REG8 (0x50a6 ),0x00 }, + {CCI_REG8 (0x50a7 ),0x00 }, + {CCI_REG8 (0x50aa ),0x22 }, + {CCI_REG8 (0x50ab ),0x07 }, + {CCI_REG8 (0x50ac ),0x24 }, + {CCI_REG8 (0x50ad ),0x07 }, + {CCI_REG8 (0x50ae ),0x20 }, + {CCI_REG8 (0x50af ),0x40 }, + {CCI_REG8 (0x50b3 ),0x04 }, + {CCI_REG8 (0x50b4 ),0x00 }, + {CCI_REG8 (0x50b7 ),0x00 }, + {CCI_REG8 (0x50b8 ),0x70 }, + {CCI_REG8 (0x50b9 ),0xff }, + {CCI_REG8 (0x50ba ),0xff }, + {CCI_REG8 (0x50bb ),0x14 }, + {CCI_REG8 (0x50cb ),0x21 }, + {CCI_REG8 (0x50d5 ),0xe0 }, + {CCI_REG8 (0x50d7 ),0x12 }, + {CCI_REG8 (0x50dd ),0x00 }, + {CCI_REG8 (0x50e8 ),0x00 }, + {CCI_REG8 (0x50ea ),0x74 }, + {CCI_REG8 (0x50fa ),0x02 }, + {CCI_REG8 (0x5100 ),0x03 }, + {CCI_REG8 (0x5101 ),0x13 }, + {CCI_REG8 (0x5102 ),0x23 }, + {CCI_REG8 (0x5103 ),0x33 }, + {CCI_REG8 (0x5104 ),0x43 }, + {CCI_REG8 (0x5105 ),0x42 }, + {CCI_REG8 (0x5106 ),0x40 }, + {CCI_REG8 (0x5118 ),0x00 }, + {CCI_REG8 (0x5119 ),0x00 }, + {CCI_REG8 (0x511a ),0x00 }, + {CCI_REG8 (0x511b ),0x00 }, + {CCI_REG8 (0x511c ),0x00 }, + {CCI_REG8 (0x511d ),0x00 }, + {CCI_REG8 (0x511e ),0x00 }, + {CCI_REG8 (0x5130 ),0x13 }, + {CCI_REG8 (0x5131 ),0x23 }, + {CCI_REG8 (0x5132 ),0x33 }, + {CCI_REG8 (0x5133 ),0x43 }, + {CCI_REG8 (0x5134 ),0x42 }, + {CCI_REG8 (0x5135 ),0x40 }, + {CCI_REG8 (0x5136 ),0x40 }, + {CCI_REG8 (0x5148 ),0x01 }, + {CCI_REG8 (0x5149 ),0x01 }, + {CCI_REG8 (0x514a ),0x01 }, + {CCI_REG8 (0x514b ),0x01 }, + {CCI_REG8 (0x514c ),0x01 }, + {CCI_REG8 (0x514d ),0x01 }, + {CCI_REG8 (0x514e ),0x01 }, + {CCI_REG8 (0x51c0 ),0x00 }, + {CCI_REG8 (0x51c1 ),0x81 }, + {CCI_REG8 (0x51c2 ),0xec }, + {CCI_REG8 (0x51c3 ),0x00 }, + {CCI_REG8 (0x51c4 ),0x55 }, + {CCI_REG8 (0x51c5 ),0x44 }, + {CCI_REG8 (0x51c6 ),0x00 }, + {CCI_REG8 (0x51c7 ),0x81 }, + {CCI_REG8 (0x51c8 ),0xec }, + {CCI_REG8 (0x51c9 ),0x00 }, + {CCI_REG8 (0x51ca ),0x55 }, + {CCI_REG8 (0x51cb ),0x24 }, + {CCI_REG8 (0x51cc ),0x00 }, + {CCI_REG8 (0x51cd ),0x81 }, + {CCI_REG8 (0x51ce ),0xec }, + {CCI_REG8 (0x51cf ),0x00 }, + {CCI_REG8 (0x51d0 ),0x54 }, + {CCI_REG8 (0x51d1 ),0x24 }, + {CCI_REG8 (0x51d2 ),0x00 }, + {CCI_REG8 (0x51d3 ),0x81 }, + {CCI_REG8 (0x51d4 ),0xec }, + {CCI_REG8 (0x51d5 ),0x00 }, + {CCI_REG8 (0x51d6 ),0x53 }, + {CCI_REG8 (0x51d7 ),0x14 }, + {CCI_REG8 (0x51d8 ),0x00 }, + {CCI_REG8 (0x51d9 ),0x81 }, + {CCI_REG8 (0x51da ),0xec }, + {CCI_REG8 (0x51db ),0x00 }, + {CCI_REG8 (0x51dc ),0x53 }, + {CCI_REG8 (0x51dd ),0x14 }, + {CCI_REG8 (0x51e0 ),0x09 }, + {CCI_REG8 (0x51e1 ),0x03 }, + {CCI_REG8 (0x51e2 ),0x04 }, + {CCI_REG8 (0x51e3 ),0x03 }, + {CCI_REG8 (0x51e4 ),0x08 }, + {CCI_REG8 (0x51e5 ),0x07 }, + {CCI_REG8 (0x51e6 ),0x08 }, + {CCI_REG8 (0x51e7 ),0x07 }, + {CCI_REG8 (0x51e8 ),0x04 }, + {CCI_REG8 (0x51e9 ),0x46 }, + {CCI_REG8 (0x51ea ),0x43 }, + {CCI_REG8 (0x51eb ),0x62 }, + {CCI_REG8 (0x51ec ),0x61 }, + {CCI_REG8 (0x51ed ),0x00 }, + {CCI_REG8 (0x51ee ),0x00 }, + {CCI_REG8 (0x5200 ),0x60 }, + {CCI_REG8 (0x5201 ),0x80 }, + {CCI_REG8 (0x5202 ),0x00 }, + {CCI_REG8 (0x5203 ),0x01 }, + {CCI_REG8 (0x5206 ),0x80 }, + {CCI_REG8 (0x5208 ),0x0b }, + {CCI_REG8 (0x5209 ),0x0c }, + {CCI_REG8 (0x520c ),0x15 }, + {CCI_REG8 (0x520d ),0x40 }, + {CCI_REG8 (0x5214 ),0x28 }, + {CCI_REG8 (0x5215 ),0x04 }, + {CCI_REG8 (0x5216 ),0x02 }, + {CCI_REG8 (0x5217 ),0x01 }, + {CCI_REG8 (0x5218 ),0x07 }, + {CCI_REG8 (0x521e ),0x01 }, + {CCI_REG8 (0x5282 ),0xff }, + {CCI_REG8 (0x5283 ),0x03 }, + {CCI_REG8 (0x0202 ),0x01 }, + {CCI_REG8 (0x0203 ),0x68 }, + {CCI_REG8 (0x0340 ),0x02 }, + {CCI_REG8 (0x0341 ),0xe4 }, + {CCI_REG8 (0x0342 ),0x06 }, + {CCI_REG8 (0x0343 ),0x54 }, + {CCI_REG8 (0x0344 ),0x00 }, + {CCI_REG8 (0x0345 ),0x00 }, + {CCI_REG8 (0x0346 ),0x00 }, + {CCI_REG8 (0x0347 ),0x00 }, + {CCI_REG8 (0x0348 ),0x05 }, + {CCI_REG8 (0x0349 ),0x0d }, + {CCI_REG8 (0x034a ),0x02 }, + {CCI_REG8 (0x034b ),0xdd }, + {CCI_REG8 (0x034c ),0x02 }, + {CCI_REG8 (0x034d ),0x88 }, + {CCI_REG8 (0x034e ),0x01 }, + {CCI_REG8 (0x034f ),0x70 }, + {CCI_REG8 (0x0383 ),0x00 }, + {CCI_REG8 (0x0387 ),0x10 }, + {CCI_REG8 (0x0390 ),0x03 }, + {CCI_REG8 (0x4800 ),0xac }, + {CCI_REG8 (0x0104 ),0x01 }, + {CCI_REG8 (0x0104 ),0x00 }, + {CCI_REG8 (0x4801 ),0xae }, + {CCI_REG8 (0x4b20 ),0x9e }, + {CCI_REG8 (0x0101 ),0x03 }, +}; + +/** +* struct hm1092_mode - sensor configuration, selected by the EXTCLK rate +* @mclk: EXTCLK rate the init sequence programs the PLL for +* @link_freq_index: index into hm1092_link_freq_menu +* @width: output width +* @height: output height +* @hts: horizontal total size, 0x0342/0x0343 +* @vts: vertical total size, 0x0340/0x0341 +* @exposure_def: exposure programmed by the init sequence +* @crop: readout window on the pixel array +* @regs: init sequence +* @num_regs: number of entries in @regs +*/ struct hm1092_mode { +unsigned long mclk; +unsigned int link_freq_index;u32 width;u32 height;u32 hts;u32 vts; +u32 exposure_def; +struct v4l2_rect crop; +const struct cci_reg_sequence *regs; +unsigned int num_regs; }; -static const struct hm1092_mode hm1092_mode_560x360 = { - .width =560 , - .height =360 , - .hts =0x0650 , - .vts =0x02ee , +static const struct hm1092_mode hm1092_modes[] = { + { + .mclk =24000000 , + .link_freq_index =0 , + .width =560 , + .height =360 , + .hts =0x0650 , + .vts =0x02ee , + .exposure_def =500 , + .crop = { + .left =48 , + .top =8 , + .width =1150 , + .height =718 , + }, + .regs = hm1092_560x360_regs, + .num_regs =ARRAY_SIZE (hm1092_560x360_regs), + }, { + .mclk =19200000 , + .link_freq_index =1 , + .width =648 , + .height =368 , + .hts =0x0654 , + .vts =0x02e4 , + .exposure_def =360 , + .crop = { + .left =0 , + .top =0 , + .width =1294 , + .height =734 , + }, + .regs = hm1092_648x368_regs, + .num_regs =ARRAY_SIZE (hm1092_648x368_regs), + }, }; static const char * const hm1092_supply_names[] = {
@@ -309,7 +554,8 @@ static const char * const hm1092_test_pattern_menu[] = { };static const s64 hm1092_link_freq_menu[] = { -HM1092_LINK_FREQ , +HM1092_LINK_FREQ_180MHZ , +HM1092_LINK_FREQ_180P48MHZ , };struct hm1092 {
@@ -326,6 +572,7 @@ struct hm1092 {struct v4l2_ctrl *hblank;struct v4l2_ctrl *vblank;struct v4l2_ctrl *exposure; +const struct hm1092_mode *mode;u8 mipi_lanes; };
@@ -398,7 +645,7 @@ static const struct v4l2_ctrl_ops hm1092_ctrl_ops = {static int hm1092_init_controls (struct hm1092 *hm1092) {struct v4l2_ctrl_handler *ctrl_hdlr = &hm1092->ctrl_handler; -const struct hm1092_mode *mode = &hm1092_mode_560x360; +const struct hm1092_mode *mode = hm1092->mode;struct v4l2_fwnode_device_properties props;s64 hblank, pixel_rate;int ret;
@@ -412,11 +659,12 @@ static int hm1092_init_controls(struct hm1092 *hm1092) hm1092->link_freq =v4l2_ctrl_new_int_menu (ctrl_hdlr, &hm1092_ctrl_ops,V4L2_CID_LINK_FREQ , -0 ,0 , +ARRAY_SIZE (hm1092_link_freq_menu) -1 , + mode->link_freq_index, hm1092_link_freq_menu); - pixel_rate =div_u64 (HM1092_LINK_FREQ *2 * hm1092->mipi_lanes, -HM1092_BITS_PER_SAMPLE ); + pixel_rate =div_u64 (hm1092_link_freq_menu[mode->link_freq_index] *2 * + hm1092->mipi_lanes,HM1092_BITS_PER_SAMPLE ); hm1092->pixel_rate =v4l2_ctrl_new_std (ctrl_hdlr, &hm1092_ctrl_ops,V4L2_CID_PIXEL_RATE ,0 , pixel_rate,1 , pixel_rate);
@@ -438,7 +686,7 @@ static int hm1092_init_controls(struct hm1092 *hm1092) mode->vts -HM1092_EXPOSURE_MARGIN ,HM1092_EXPOSURE_STEP , - HM1092_EXPOSURE_DEFAULT); + mode->exposure_def); v4l2_ctrl_new_std(ctrl_hdlr, &hm1092_ctrl_ops, V4L2_CID_ANALOGUE_GAIN,
@@ -480,10 +728,11 @@ err_free:return ret; } -static void hm1092_update_pad_format (struct v4l2_mbus_framefmt *fmt) +static void hm1092_update_pad_format (const struct hm1092_mode *mode, +struct v4l2_mbus_framefmt *fmt) { - fmt->width = hm1092_mode_560x360.width; - fmt->height = hm1092_mode_560x360.height; + fmt->width = mode->width; + fmt->height = mode->height; fmt->code =MEDIA_BUS_FMT_Y10_1X10 ; fmt->field =V4L2_FIELD_NONE ; fmt->colorspace =V4L2_COLORSPACE_RAW ;
@@ -503,8 +752,8 @@ static int hm1092_enable_streams(struct v4l2_subdev *sd,if (ret)return ret; - ret =cci_multi_reg_write (hm1092->regmap, hm1092_init_regs, -ARRAY_SIZE (hm1092_init_regs),NULL ); + ret =cci_multi_reg_write (hm1092->regmap, hm1092->mode->regs, + hm1092->mode->num_regs,NULL );if (ret) {dev_err (hm1092->dev,"failed to write init registers\n" ); goto out;
@@ -556,16 +805,18 @@ static int hm1092_enum_frame_size(struct v4l2_subdev *sd,struct v4l2_subdev_state *state, struct v4l2_subdev_frame_size_enum *fse) { + const struct hm1092_mode *mode = to_hm1092(sd)->mode; +if (fse->index)return -EINVAL ;if (fse->code !=MEDIA_BUS_FMT_Y10_1X10 )return -EINVAL ; - fse->min_width = hm1092_mode_560x360.width; - fse->max_width = hm1092_mode_560x360.width; - fse->min_height = hm1092_mode_560x360.height; - fse->max_height = hm1092_mode_560x360.height; + fse->min_width = mode->width; + fse->max_width = mode->width; + fse->min_height = mode->height; + fse->max_height = mode->height;return 0 ; }
@@ -576,10 +827,7 @@ static int hm1092_get_selection(struct v4l2_subdev *sd, {switch (sel->target) {case V4L2_SEL_TGT_CROP : - sel->r.left =HM1092_CROP_LEFT ; - sel->r.top =HM1092_CROP_TOP ; - sel->r.width =HM1092_CROP_WIDTH ; - sel->r.height =HM1092_CROP_HEIGHT ; + sel->r =to_hm1092 (sd)->mode->crop;return 0 ;case V4L2_SEL_TGT_CROP_DEFAULT :case V4L2_SEL_TGT_CROP_BOUNDS :
@@ -602,7 +850,8 @@ static int hm1092_get_selection(struct v4l2_subdev *sd,static int hm1092_init_state (struct v4l2_subdev *sd,struct v4l2_subdev_state *state) { -hm1092_update_pad_format (v4l2_subdev_state_get_format (state,0 )); +hm1092_update_pad_format (to_hm1092 (sd)->mode, +v4l2_subdev_state_get_format (state,0 ));return 0 ; }
@@ -663,6 +912,14 @@ static int hm1092_check_hwcfg(struct hm1092 *hm1092)if (ret) goto out; +if (!(link_freq_bitmap &BIT (hm1092->mode->link_freq_index))) { + ret =dev_err_probe (dev, -EINVAL , +"link frequency %lld not available for a %lu Hz external clock\n" , + hm1092_link_freq_menu[hm1092->mode->link_freq_index], + hm1092->mode->mclk); + goto out; + } +if (bus_cfg.bus.mipi_csi2.num_data_lanes !=1 ) { ret = dev_err_probe(dev, -EINVAL, "only 1 data lane is supported, got %u\n",
@@ -775,7 +1032,13 @@ static int hm1092_probe(struct i2c_client *client) "failed to get imaging clock\n"); freq =clk_get_rate (hm1092->img_clk); -if (freq !=HM1092_MCLK ) +for (unsigned int i =0 ; i <ARRAY_SIZE (hm1092_modes); i++) { +if (hm1092_modes[i].mclk == freq) { + hm1092->mode = &hm1092_modes[i]; +break ; + } + } +if (!hm1092->mode)return dev_err_probe (hm1092->dev, -EINVAL ,"external clock %lu is not supported\n" , freq);
@@ -841,6 +1104,12 @@ err_ctrls: static DEFINE_RUNTIME_DEV_PM_OPS(hm1092_pm_ops, hm1092_power_off, hm1092_power_on, NULL); +static const struct acpi_device_id hm1092_acpi_ids[] = { + {"HIMX1092" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (acpi, hm1092_acpi_ids); +static const struct of_device_id hm1092_of_match[] = { { .compatible ="himax,hm1092" }, {/* sentinel */ }
@@ -851,6 +1120,7 @@ static struct i2c_driver hm1092_i2c_driver = { .driver = { .name = "hm1092", .pm = pm_ptr(&hm1092_pm_ops), + .acpi_match_table = hm1092_acpi_ids, .of_match_table = hm1092_of_match, }, .probe = hm1092_probe,
Signature · 1 line
2.56.0