[2/2] libcamera: camera_sensor: Add Sony IMX363 sensor properties and helper
diff mbox series

Message ID 20260908084544.274613-2-sam.legros@gmail.com
State New
Headers show
Series
  • [1/2] libcamera: camera_sensor: Fix IMX355 test pattern mode mapping
Related show

Commit Message

Samuel LEGROS Sept. 8, 2026, 8:45 a.m. UTC
Add the camera sensor properties and camera sensor helper entries for the
Sony IMX363, the rear sensor of the Google Pixel 3 and Pixel 3a.

Values were taken from the driver and confirmed on a Pixel 3a running
postmarketOS (imx363 3-001a):

- The pixel array is 4032x3024 within a 4048x3168 native area, and the
  sensor is a 12.2 MP type 1/2.55" part, giving a 1.4 um pixel pitch
  (4032 * 1.4 um = 5.64 mm across).

- The driver exposes the same test pattern menu as the IMX258 and the
  IMX355:

      static const char * const imx363_test_pattern_menu[] = {
              "Disabled",
              "Solid Colour",
              "Eight Vertical Colour Bars",
              "Colour Bars With Fade to Grey",
              "Pseudorandom Sequence (PN9)",
      };

- Analogue gain is written to ANALOG_GAIN_GLOBAL (0x0204) and ranges from
  0 to 480, the same limit as the IMX258, which corresponds to the
  512/(512 - x) gain model and a 16x maximum. The IMX355 uses the same
  formula scaled to 1024 with a limit of 960.

- The black level follows the value documented for the sibling sensors,
  0x40 at 10 bits.

Signed-off-by: Samuel LEGROS <sam.legros@gmail.com>
---
 src/ipa/libipa/camera_sensor_helper.cpp          | 12 ++++++++++++
 .../sensor/camera_sensor_properties.cpp          | 16 ++++++++++++++++
 2 files changed, 28 insertions(+)

Comments

Kieran Bingham Sept. 8, 2026, 10:25 a.m. UTC | #1
Hi Samuel,


Quoting Samuel LEGROS (2026-09-08 09:45:44)
> Add the camera sensor properties and camera sensor helper entries for the
> Sony IMX363, the rear sensor of the Google Pixel 3 and Pixel 3a.
> 
> Values were taken from the driver and confirmed on a Pixel 3a running
> postmarketOS (imx363 3-001a):


I don't see any driver support for the imx363 in the linux kernel:

 https://lore.kernel.org/all/?q=imx363

has some close matches for some dt additions but not the driver work.

Is there work in progress to get this driver upstream?

--
Regards

Kieran

> 
> - The pixel array is 4032x3024 within a 4048x3168 native area, and the
>   sensor is a 12.2 MP type 1/2.55" part, giving a 1.4 um pixel pitch
>   (4032 * 1.4 um = 5.64 mm across).
> 
> - The driver exposes the same test pattern menu as the IMX258 and the
>   IMX355:
> 
>       static const char * const imx363_test_pattern_menu[] = {
>               "Disabled",
>               "Solid Colour",
>               "Eight Vertical Colour Bars",
>               "Colour Bars With Fade to Grey",
>               "Pseudorandom Sequence (PN9)",
>       };
> 
> - Analogue gain is written to ANALOG_GAIN_GLOBAL (0x0204) and ranges from
>   0 to 480, the same limit as the IMX258, which corresponds to the
>   512/(512 - x) gain model and a 16x maximum. The IMX355 uses the same
>   formula scaled to 1024 with a limit of 960.
> 
> - The black level follows the value documented for the sibling sensors,
>   0x40 at 10 bits.
> 
> Signed-off-by: Samuel LEGROS <sam.legros@gmail.com>
> ---
>  src/ipa/libipa/camera_sensor_helper.cpp          | 12 ++++++++++++
>  .../sensor/camera_sensor_properties.cpp          | 16 ++++++++++++++++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
> index 82bf255..c3ae412 100644
> --- a/src/ipa/libipa/camera_sensor_helper.cpp
> +++ b/src/ipa/libipa/camera_sensor_helper.cpp
> @@ -629,6 +629,18 @@ public:
>  };
>  REGISTER_CAMERA_SENSOR_HELPER("imx355", CameraSensorHelperImx355)
>  
> +class CameraSensorHelperImx363 : public CameraSensorHelper
> +{
> +public:
> +       CameraSensorHelperImx363()
> +       {
> +               /* From datasheet: 0x40 at 10bits. */
> +               blackLevel_ = 4096;
> +               gain_ = AnalogueGainLinear{ 0, 512, -1, 512 };
> +       }
> +};
> +REGISTER_CAMERA_SENSOR_HELPER("imx363", CameraSensorHelperImx363)
> +
>  class CameraSensorHelperImx415 : public CameraSensorHelper
>  {
>  public:
> diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp
> index ecf523c..10095f2 100644
> --- a/src/libcamera/sensor/camera_sensor_properties.cpp
> +++ b/src/libcamera/sensor/camera_sensor_properties.cpp
> @@ -281,6 +281,22 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
>                                 .hblankDelay = 2
>                         },
>                 } },
> +               { "imx363", {
> +                       .unitCellSize = { 1400, 1400 },
> +                       .testPatternModes = {
> +                               { controls::draft::TestPatternModeOff, 0 },
> +                               { controls::draft::TestPatternModeSolidColor, 1 },
> +                               { controls::draft::TestPatternModeColorBars, 2 },
> +                               { controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
> +                               { controls::draft::TestPatternModePn9, 4 },
> +                       },
> +                       .sensorDelays = {
> +                               .exposureDelay = 2,
> +                               .gainDelay = 2,
> +                               .vblankDelay = 2,
> +                               .hblankDelay = 2
> +                       },
> +               } },
>                 { "imx415", {
>                         .unitCellSize = { 1450, 1450 },
>                         .testPatternModes = {},
> -- 
> 2.53.0
>

Patch
diff mbox series

diff --git a/src/ipa/libipa/camera_sensor_helper.cpp b/src/ipa/libipa/camera_sensor_helper.cpp
index 82bf255..c3ae412 100644
--- a/src/ipa/libipa/camera_sensor_helper.cpp
+++ b/src/ipa/libipa/camera_sensor_helper.cpp
@@ -629,6 +629,18 @@  public:
 };
 REGISTER_CAMERA_SENSOR_HELPER("imx355", CameraSensorHelperImx355)
 
+class CameraSensorHelperImx363 : public CameraSensorHelper
+{
+public:
+	CameraSensorHelperImx363()
+	{
+		/* From datasheet: 0x40 at 10bits. */
+		blackLevel_ = 4096;
+		gain_ = AnalogueGainLinear{ 0, 512, -1, 512 };
+	}
+};
+REGISTER_CAMERA_SENSOR_HELPER("imx363", CameraSensorHelperImx363)
+
 class CameraSensorHelperImx415 : public CameraSensorHelper
 {
 public:
diff --git a/src/libcamera/sensor/camera_sensor_properties.cpp b/src/libcamera/sensor/camera_sensor_properties.cpp
index ecf523c..10095f2 100644
--- a/src/libcamera/sensor/camera_sensor_properties.cpp
+++ b/src/libcamera/sensor/camera_sensor_properties.cpp
@@ -281,6 +281,22 @@  const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen
 				.hblankDelay = 2
 			},
 		} },
+		{ "imx363", {
+			.unitCellSize = { 1400, 1400 },
+			.testPatternModes = {
+				{ controls::draft::TestPatternModeOff, 0 },
+				{ controls::draft::TestPatternModeSolidColor, 1 },
+				{ controls::draft::TestPatternModeColorBars, 2 },
+				{ controls::draft::TestPatternModeColorBarsFadeToGray, 3 },
+				{ controls::draft::TestPatternModePn9, 4 },
+			},
+			.sensorDelays = {
+				.exposureDelay = 2,
+				.gainDelay = 2,
+				.vblankDelay = 2,
+				.hblankDelay = 2
+			},
+		} },
 		{ "imx415", {
 			.unitCellSize = { 1450, 1450 },
 			.testPatternModes = {},