libcamera: libipa: camera_sensor: Add Himax HM1246 sensor properties
diff mbox series

Message ID 20250912-hm1246-v1-1-58c814f52a26@emfend.at
State New
Headers show
Series
  • libcamera: libipa: camera_sensor: Add Himax HM1246 sensor properties
Related show

Commit Message

Matthias Fend Sept. 12, 2025, 9:13 a.m. UTC
Provide the Himax HM1246 camera sensor properties and registration with
libipa for the gain code helpers.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
---
The Himax HM1246-AWD is a 1/3.7-Inch CMOS image sensor SoC with an active
array size of 1296 x 976 and parallell interface. The sensor has an
integrated ISP that is not supported by the kernel driver. The sensor is
therefore operated like a normal sensor in raw mode.

The kernel driver required for this is currently under review [1].
[1] https://lore.kernel.org/r/20250912-hm1246-v3-0-3b89f47dfa43@emfend.at
---
 src/ipa/libipa/camera_sensor_helper.cpp           | 10 +++++++
 src/libcamera/sensor/camera_sensor_properties.cpp | 32 +++++++++++++++++++++++
 2 files changed, 42 insertions(+)


---
base-commit: b8d332cdcc130c27232f61369e7bab2d954e7ac6
change-id: 20250912-hm1246-5550b4d5d16e

Best regards,

Comments

Kieran Bingham Sept. 12, 2025, 9:45 a.m. UTC | #1
Quoting Matthias Fend (2025-09-12 10:13:25)
> Provide the Himax HM1246 camera sensor properties and registration with
> libipa for the gain code helpers.
> 
> Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
> ---
> The Himax HM1246-AWD is a 1/3.7-Inch CMOS image sensor SoC with an active
> array size of 1296 x 976 and parallell interface. The sensor has an
> integrated ISP that is not supported by the kernel driver. The sensor is
> therefore operated like a normal sensor in raw mode.
> 
> The kernel driver required for this is currently under review [1].
> [1] https://lore.kernel.org/r/20250912-hm1246-v3-0-3b89f47dfa43@emfend.at

Public driver makes the sensor helpers eligible to merge!

Wait - the datasheet is public from himax themselves!

https://www.himax.com.tw/wp-content/uploads/2024/03/HM1246-AWD_DS_v01.pdf

Excellent...

✓ Pixel Size and Technology 3.0µm x 3.0µm
✓ Analog gain = X = (ANALOG_GLOBAL_GAIN [7:0] + 16) / 16

Sometime soon I hope we'll have a camera calibration tool to be able to
validate the helpers or support creating them even without datasheets.
Particularly on the delays which are harder to interpret. But I think
this is fine to merge, as I anticipate you've been testing this on
i.MX8MP so if the delays were wrong you would have seen already.


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> ---
>  src/ipa/libipa/camera_sensor_helper.cpp           | 10 +++++++
>  src/libcamera/sensor/camera_sensor_properties.cpp | 32 +++++++++++++++++++++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
> index dcd69d9f2bbb39feabfefe41cee8b45f0f958127..df93c0fdeb9c5ae2c3e3dc51dabc62ba4082c0d7 100644
> --- a/src/ipa/libipa/camera_sensor_helper.cpp
> +++ b/src/ipa/libipa/camera_sensor_helper.cpp
> @@ -497,6 +497,16 @@ public:
>  };
>  REGISTER_CAMERA_SENSOR_HELPER("gc08a3", CameraSensorHelperGc08a3)
>  
> +class CameraSensorHelperHm1246 : public CameraSensorHelper
> +{
> +public:
> +       CameraSensorHelperHm1246()
> +       {
> +               gain_ = AnalogueGainLinear{ 1, 16, 0, 16 };

And I've validated this against the datasheet with:

https://git.uk.ideasonboard.com/kbingham/octave-gains/pulls/1



> +       }
> +};
> +REGISTER_CAMERA_SENSOR_HELPER("hm1246", CameraSensorHelperHm1246)
> +
>  class CameraSensorHelperImx214 : public CameraSensorHelper
>  {
>  public:
> diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp
> index f2da8205372baabca58416e2c0f9da64e722fe02..810f0199d41f0582e120687b304c3ff549a19bc8 100644
> --- a/src/libcamera/sensor/camera_sensor_properties.cpp
> +++ b/src/libcamera/sensor/camera_sensor_properties.cpp
> @@ -151,6 +151,38 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
>                         },
>                         .sensorDelays = { },
>                 } },
> +               { "hm1246", {
> +                       .unitCellSize = { 3000, 3000 },
> +                       .testPatternModes =  {
> +                               { controls::draft::TestPatternModeOff, 0 },
> +                               /* Solid white. */
> +                               { controls::draft::TestPatternModeSolidColor, 6 },
> +                               /* The six vertical bars (left-to-right) are as follows: black,
> +                                * blue, red, magenta, green and cyan.
> +                                */
> +                               { controls::draft::TestPatternModeCustom1, 5 },
> +                               /*
> +                                * No corresponding test pattern mode for:
> +                                *  1: "Checkboard"
> +                                *  2: "Ramp"
> +                                *  3: "Moving ones"
> +                                *  4: "Blending color bars"
> +                                *  7: "Solid black"
> +                                *  8: "Solid red"
> +                                *  9: "Solid green"
> +                                * 10: "Solid blue"
> +                                *
> +                                * Even though the sensor supports color bars and faded color bars as test patterns, these are
> +                                * not offered because these patterns do not meet the expected properties.
> +                                */
> +                       },
> +                       .sensorDelays = {
> +                               .exposureDelay = 2,
> +                               .gainDelay = 2,
> +                               .vblankDelay = 2,
> +                               .hblankDelay = 2
> +                       },
> +               } },
>                 { "imx214", {
>                         .unitCellSize = { 1120, 1120 },
>                         .testPatternModes = {
> 
> ---
> base-commit: b8d332cdcc130c27232f61369e7bab2d954e7ac6
> change-id: 20250912-hm1246-5550b4d5d16e
> 
> Best regards,
> -- 
> Matthias Fend <matthias.fend@emfend.at>
>
Matthias Fend Sept. 12, 2025, 12:37 p.m. UTC | #2
Hi Kieran,

thank you for your review and for checking the gain parameters.

Am 12.09.2025 um 11:45 schrieb Kieran Bingham:
> Quoting Matthias Fend (2025-09-12 10:13:25)
>> Provide the Himax HM1246 camera sensor properties and registration with
>> libipa for the gain code helpers.
>>
>> Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
>> ---
>> The Himax HM1246-AWD is a 1/3.7-Inch CMOS image sensor SoC with an active
>> array size of 1296 x 976 and parallell interface. The sensor has an
>> integrated ISP that is not supported by the kernel driver. The sensor is
>> therefore operated like a normal sensor in raw mode.
>>
>> The kernel driver required for this is currently under review [1].
>> [1] https://lore.kernel.org/r/20250912-hm1246-v3-0-3b89f47dfa43@emfend.at
> 
> Public driver makes the sensor helpers eligible to merge!
> 
> Wait - the datasheet is public from himax themselves!
> 
> https://www.himax.com.tw/wp-content/uploads/2024/03/HM1246-AWD_DS_v01.pdf
> 
> Excellent...
> 
> ✓ Pixel Size and Technology 3.0µm x 3.0µm
> ✓ Analog gain = X = (ANALOG_GLOBAL_GAIN [7:0] + 16) / 16
> 
> Sometime soon I hope we'll have a camera calibration tool to be able to
> validate the helpers or support creating them even without datasheets.
> Particularly on the delays which are harder to interpret. But I think
> this is fine to merge, as I anticipate you've been testing this on
> i.MX8MP so if the delays were wrong you would have seen already.

Yes, that would be really great. I would also be interested to know how 
others check these settings in practice.

IMHO the most interesting settings are exposure and gain. I usually 
check these by alternating between pairs of values that should result in 
the same image brightness. If the brightness does not change and there 
is no flickering, the delays and gain calculation are most likely correct.

I have done this in a semi-manual process so far, but I think it could 
also be automated to a certain extent.

> 
> 
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> 
> 
>> ---
>>   src/ipa/libipa/camera_sensor_helper.cpp           | 10 +++++++
>>   src/libcamera/sensor/camera_sensor_properties.cpp | 32 +++++++++++++++++++++++
>>   2 files changed, 42 insertions(+)
>>
>> diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
>> index dcd69d9f2bbb39feabfefe41cee8b45f0f958127..df93c0fdeb9c5ae2c3e3dc51dabc62ba4082c0d7 100644
>> --- a/src/ipa/libipa/camera_sensor_helper.cpp
>> +++ b/src/ipa/libipa/camera_sensor_helper.cpp
>> @@ -497,6 +497,16 @@ public:
>>   };
>>   REGISTER_CAMERA_SENSOR_HELPER("gc08a3", CameraSensorHelperGc08a3)
>>   
>> +class CameraSensorHelperHm1246 : public CameraSensorHelper
>> +{
>> +public:
>> +       CameraSensorHelperHm1246()
>> +       {
>> +               gain_ = AnalogueGainLinear{ 1, 16, 0, 16 };
> 
> And I've validated this against the datasheet with:
> 
> https://git.uk.ideasonboard.com/kbingham/octave-gains/pulls/1

Thanks for your efforts!

~Matthias

> 
> 
> 
>> +       }
>> +};
>> +REGISTER_CAMERA_SENSOR_HELPER("hm1246", CameraSensorHelperHm1246)
>> +
>>   class CameraSensorHelperImx214 : public CameraSensorHelper
>>   {
>>   public:
>> diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp
>> index f2da8205372baabca58416e2c0f9da64e722fe02..810f0199d41f0582e120687b304c3ff549a19bc8 100644
>> --- a/src/libcamera/sensor/camera_sensor_properties.cpp
>> +++ b/src/libcamera/sensor/camera_sensor_properties.cpp
>> @@ -151,6 +151,38 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
>>                          },
>>                          .sensorDelays = { },
>>                  } },
>> +               { "hm1246", {
>> +                       .unitCellSize = { 3000, 3000 },
>> +                       .testPatternModes =  {
>> +                               { controls::draft::TestPatternModeOff, 0 },
>> +                               /* Solid white. */
>> +                               { controls::draft::TestPatternModeSolidColor, 6 },
>> +                               /* The six vertical bars (left-to-right) are as follows: black,
>> +                                * blue, red, magenta, green and cyan.
>> +                                */
>> +                               { controls::draft::TestPatternModeCustom1, 5 },
>> +                               /*
>> +                                * No corresponding test pattern mode for:
>> +                                *  1: "Checkboard"
>> +                                *  2: "Ramp"
>> +                                *  3: "Moving ones"
>> +                                *  4: "Blending color bars"
>> +                                *  7: "Solid black"
>> +                                *  8: "Solid red"
>> +                                *  9: "Solid green"
>> +                                * 10: "Solid blue"
>> +                                *
>> +                                * Even though the sensor supports color bars and faded color bars as test patterns, these are
>> +                                * not offered because these patterns do not meet the expected properties.
>> +                                */
>> +                       },
>> +                       .sensorDelays = {
>> +                               .exposureDelay = 2,
>> +                               .gainDelay = 2,
>> +                               .vblankDelay = 2,
>> +                               .hblankDelay = 2
>> +                       },
>> +               } },
>>                  { "imx214", {
>>                          .unitCellSize = { 1120, 1120 },
>>                          .testPatternModes = {
>>
>> ---
>> base-commit: b8d332cdcc130c27232f61369e7bab2d954e7ac6
>> change-id: 20250912-hm1246-5550b4d5d16e
>>
>> Best regards,
>> -- 
>> Matthias Fend <matthias.fend@emfend.at>
>>

Patch
diff mbox series

diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
index dcd69d9f2bbb39feabfefe41cee8b45f0f958127..df93c0fdeb9c5ae2c3e3dc51dabc62ba4082c0d7 100644
--- a/src/ipa/libipa/camera_sensor_helper.cpp
+++ b/src/ipa/libipa/camera_sensor_helper.cpp
@@ -497,6 +497,16 @@  public:
 };
 REGISTER_CAMERA_SENSOR_HELPER("gc08a3", CameraSensorHelperGc08a3)
 
+class CameraSensorHelperHm1246 : public CameraSensorHelper
+{
+public:
+	CameraSensorHelperHm1246()
+	{
+		gain_ = AnalogueGainLinear{ 1, 16, 0, 16 };
+	}
+};
+REGISTER_CAMERA_SENSOR_HELPER("hm1246", CameraSensorHelperHm1246)
+
 class CameraSensorHelperImx214 : public CameraSensorHelper
 {
 public:
diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp
index f2da8205372baabca58416e2c0f9da64e722fe02..810f0199d41f0582e120687b304c3ff549a19bc8 100644
--- a/src/libcamera/sensor/camera_sensor_properties.cpp
+++ b/src/libcamera/sensor/camera_sensor_properties.cpp
@@ -151,6 +151,38 @@  const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
 			},
 			.sensorDelays = { },
 		} },
+		{ "hm1246", {
+			.unitCellSize = { 3000, 3000 },
+			.testPatternModes =  {
+				{ controls::draft::TestPatternModeOff, 0 },
+				/* Solid white. */
+				{ controls::draft::TestPatternModeSolidColor, 6 },
+				/* The six vertical bars (left-to-right) are as follows: black,
+				 * blue, red, magenta, green and cyan.
+				 */
+				{ controls::draft::TestPatternModeCustom1, 5 },
+				/*
+				 * No corresponding test pattern mode for:
+				 *  1: "Checkboard"
+				 *  2: "Ramp"
+				 *  3: "Moving ones"
+				 *  4: "Blending color bars"
+				 *  7: "Solid black"
+				 *  8: "Solid red"
+				 *  9: "Solid green"
+				 * 10: "Solid blue"
+				 *
+				 * Even though the sensor supports color bars and faded color bars as test patterns, these are
+				 * not offered because these patterns do not meet the expected properties.
+				 */
+			},
+			.sensorDelays = {
+				.exposureDelay = 2,
+				.gainDelay = 2,
+				.vblankDelay = 2,
+				.hblankDelay = 2
+			},
+		} },
 		{ "imx214", {
 			.unitCellSize = { 1120, 1120 },
 			.testPatternModes = {