linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/3] Add imx577 and imx477 compatible to imx412
@ 2022-09-16 14:02 Bryan O'Donoghue
  2022-09-16 14:02 ` [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings Bryan O'Donoghue
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2022-09-16 14:02 UTC (permalink / raw)
  To: sakari.ailus, dave.stevenson, jacopo, paul.j.murphy,
	daniele.alessandrelli, mchehab, linux-media
  Cc: bryan.odonoghue

v4:
- Squashes dt-bindings addition - Sakari
- Squashes compat string addition to driver - Sakari
- Drops checking fwnode(&client->dev), checks for !name - Sakari
- Retains imx477 compat
  I think we have established that imx477 and imx577 do have additional
  settings and modes over the imx412 which, we can and hopefully will add
  in as time goes by. What we have upstream will work for all three parts.

v3:
To really get to the bottom of what was going on with the imx412, imx477
and imx577 I got a Nvida Nano with both sensors from Leopard imaging.

Interestingly the shipped driver from Leopard is called "imx477" and is
keyed to work with imx412, imx477 and imx577 with predictably the same
register init sequence.

For me aside from the physical size difference in the modules the only
discerable difference is the imx577 has a "green tinge" which is exactly
the same experience I have with the imx577 on the Qualcomm RB5 - with both
the downstream driver stack and the usptream driver.

With the modules shipped from Leopard both the imx412 and imx577 report the
same chip id of 0x0577.

I dumped the first 32 registers on both modules using the Nvidia/Leopard
stack and as expected - all of the register values match.

So I've confirmed as far as my investigation has gone, there's no
clear register we can interrogate to differentiate the parts.

- Drops renaming of the driver to imx577.c
  I continue to think this is the right thing to do but, I'm happy to
  leave that on the back burner for another time.
- Add in compatible strings for imx477 and imx577 into the dt-bindings
- Extend the imx412 per Sakari's comment re: media device naming
  https://patchwork.kernel.org/project/linux-media/patch/20220607134057.2427663-3-bryan.odonoghue@linaro.org/#24894500
- Add imx477 and imx577 with supporting code to drive media device name

Depending then if the compat string is imx412, imx477 or imx577 the media
name of the device will be imx412, imx477 or imx577 e.g. I use the
following media-ctl command depending on the specified compatible.

media-ctl -v -d /dev/media0 -V '"imx577 '22-001a'"...
media-ctl -v -d /dev/media0 -V '"imx412 '22-001a'"...

v2:
Sakari wasn't especially satisfied with the answer imx412 and imx577 have
the same init sequence but, suggested setting the string for imx577 as is
done in the ccs driver.

https://lore.kernel.org/all/20220607134057.2427663-3-bryan.odonoghue@xxxxxxxxxx/t/

I went to look at that and asked myself "how would I tell the difference
between the two silicon parts". The obvious answer is a chip identifier.

Luckily this class of IMX sensor has a chip identifier at offset 0x0016.

That looks like this for imx258, imx319 and imx355

drivers/media/i2c/imx258.c:#define IMX258_REG_CHIP_ID    0x0016
drivers/media/i2c/imx258.c:#define IMX258_CHIP_ID        0x0258

drivers/media/i2c/imx319.c:#define IMX319_REG_CHIP_ID    0x0016
drivers/media/i2c/imx319.c:#define IMX319_CHIP_ID        0x0319

drivers/media/i2c/imx355.c:#define IMX355_REG_CHIP_ID    0x0016
drivers/media/i2c/imx355.c:#define IMX355_CHIP_ID        0x0355

but then looks like this for imx412.

drivers/media/i2c/imx412.c:#define IMX412_REG_ID         0x0016
drivers/media/i2c/imx412.c:#define IMX412_ID             0x577

This made no sense at all to me, why is the imx412 driver not named imx577 ?

I went and dug into the Qualcomm camx/chi-cdk sources to find that a file
called cmk_imx577_sensor.xml has a property called sensorId which is
constrained to 0x0577.

In the Qualcomm stack this pairing of filename and identifier is
maintained for imx258, imx376, imx476, imx576, imx519, imx362, imx481,
imx318 imx334 and imx386.

Every single example I can find of a Sony IMX sensor which returns a chip
identifier at offset 0x0016 matches the driver name to the returned sensor
id both here upstream in Linux and in Qualcomm's camx stack.

The conclusion I draw from this is that imx412.c is inappropriately named.

I think the right thing to do is to rename imx412 to imx577. It is
confusing and I think wrong to pair imx412.c with a chip which identifies
as 0x0577.

v1:
Right now the imx412 and imx577 are code and pin compatible however, they
are distinct pieces of silicon.

Document imx577 as a compatible enum and add the compat string to imx412.c.
This allows us to differentiate these chips in DTS and potentially to apply
any future imx412 or imx577 specific changes appropriately.


Bryan O'Donoghue (3):
  media: dt-bindings: imx412: Extend compatible strings
  media: i2c: imx412: Assign v4l2 device subname based on compat string
  media: i2c: imx412: Add new compatible strings

 .../devicetree/bindings/media/i2c/sony,imx412.yaml     |  6 +++++-
 drivers/media/i2c/imx412.c                             | 10 +++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings
  2022-09-16 14:02 [PATCH v4 0/3] Add imx577 and imx477 compatible to imx412 Bryan O'Donoghue
@ 2022-09-16 14:02 ` Bryan O'Donoghue
  2022-09-21 19:03   ` Sakari Ailus
  2022-09-16 14:02 ` [PATCH v4 2/3] media: i2c: imx412: Assign v4l2 device subname based on compat string Bryan O'Donoghue
  2022-09-16 14:02 ` [PATCH v4 3/3] media: i2c: imx412: Add new compatible strings Bryan O'Donoghue
  2 siblings, 1 reply; 7+ messages in thread
From: Bryan O'Donoghue @ 2022-09-16 14:02 UTC (permalink / raw)
  To: sakari.ailus, dave.stevenson, jacopo, paul.j.murphy,
	daniele.alessandrelli, mchehab, linux-media
  Cc: bryan.odonoghue

Add compatible bindings for imx477 and imx577 both of which use the
same silicon enabling reference code from Sony in the available examples
provided.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 .../devicetree/bindings/media/i2c/sony,imx412.yaml          | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml b/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml
index 26d1807d0bb6..ebb649c5e4c5 100644
--- a/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/sony,imx412.yaml
@@ -19,7 +19,11 @@ description:
 
 properties:
   compatible:
-    const: sony,imx412
+    items:
+      - enum:
+          - sony,imx412
+          - sony,imx477
+          - sony,imx577
   reg:
     description: I2C address
     maxItems: 1
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 2/3] media: i2c: imx412: Assign v4l2 device subname based on compat string
  2022-09-16 14:02 [PATCH v4 0/3] Add imx577 and imx477 compatible to imx412 Bryan O'Donoghue
  2022-09-16 14:02 ` [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings Bryan O'Donoghue
@ 2022-09-16 14:02 ` Bryan O'Donoghue
  2022-09-16 14:02 ` [PATCH v4 3/3] media: i2c: imx412: Add new compatible strings Bryan O'Donoghue
  2 siblings, 0 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2022-09-16 14:02 UTC (permalink / raw)
  To: sakari.ailus, dave.stevenson, jacopo, paul.j.murphy,
	daniele.alessandrelli, mchehab, linux-media
  Cc: bryan.odonoghue

imx412, imx477 and imx577 all return the same chip-id when interrogated via
i2c. I've confirmed this myself by

- Looking at the code in Qcom and Nvidia stacks
- Running the upstream imx412 driver on imx577 with a Qcom sm8250 RB5
- Running the downstream Qcom stack on the same hardware. This uses a
  commercial licensed stack with a driver/userspace pair that make no
  differentiation between imx412, imx477 and imx577.
- Running the imx412 and imx577 on a Nvidia Nano with cameras from Leopard
  Imaging. Again this is a commercial non-upstream user-space/kernel-space
  pairing and again the same imx driver, works for both parts.

Sakari suggested we should add a new compat but that the compat string
should also set the media entity name also

https://patchwork.kernel.org/project/linux-media/patch/20220607134057.2427663-3-bryan.odonoghue@linaro.org/#24894500

Set up the .data parameter of of_device_id to pass a string which
we use to set the media entity name. Once done we can add in imx477 and
imx577 as compatible chips with the media names reflecting the directed
compat string.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/i2c/imx412.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c
index a1394d6c1432..9f854a1a4c2f 100644
--- a/drivers/media/i2c/imx412.c
+++ b/drivers/media/i2c/imx412.c
@@ -1172,6 +1172,7 @@ static int imx412_init_controls(struct imx412 *imx412)
 static int imx412_probe(struct i2c_client *client)
 {
 	struct imx412 *imx412;
+	const char *name;
 	int ret;
 
 	imx412 = devm_kzalloc(&client->dev, sizeof(*imx412), GFP_KERNEL);
@@ -1179,6 +1180,9 @@ static int imx412_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	imx412->dev = &client->dev;
+	name = device_get_match_data(&client->dev);
+	if (!name)
+		return -ENODEV;
 
 	/* Initialize subdev */
 	v4l2_i2c_subdev_init(&imx412->sd, client, &imx412_subdev_ops);
@@ -1218,6 +1222,8 @@ static int imx412_probe(struct i2c_client *client)
 	imx412->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 	imx412->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 
+	v4l2_i2c_subdev_set_name(&imx412->sd, client, name, NULL);
+
 	/* Initialize source pad */
 	imx412->pad.flags = MEDIA_PAD_FL_SOURCE;
 	ret = media_entity_pads_init(&imx412->sd.entity, 1, &imx412->pad);
@@ -1281,7 +1287,7 @@ static const struct dev_pm_ops imx412_pm_ops = {
 };
 
 static const struct of_device_id imx412_of_match[] = {
-	{ .compatible = "sony,imx412" },
+	{ .compatible = "sony,imx412", .data = "imx412" },
 	{ }
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v4 3/3] media: i2c: imx412: Add new compatible strings
  2022-09-16 14:02 [PATCH v4 0/3] Add imx577 and imx477 compatible to imx412 Bryan O'Donoghue
  2022-09-16 14:02 ` [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings Bryan O'Donoghue
  2022-09-16 14:02 ` [PATCH v4 2/3] media: i2c: imx412: Assign v4l2 device subname based on compat string Bryan O'Donoghue
@ 2022-09-16 14:02 ` Bryan O'Donoghue
  2 siblings, 0 replies; 7+ messages in thread
From: Bryan O'Donoghue @ 2022-09-16 14:02 UTC (permalink / raw)
  To: sakari.ailus, dave.stevenson, jacopo, paul.j.murphy,
	daniele.alessandrelli, mchehab, linux-media
  Cc: bryan.odonoghue

The Sony imx477 and imx577 use the same silicon enabling reference code
from Sony in the available examples provided as the imx412.

Add in compatible strings to differentiate the parts.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/media/i2c/imx412.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c
index 9f854a1a4c2f..93f362e3b132 100644
--- a/drivers/media/i2c/imx412.c
+++ b/drivers/media/i2c/imx412.c
@@ -1288,6 +1288,8 @@ static const struct dev_pm_ops imx412_pm_ops = {
 
 static const struct of_device_id imx412_of_match[] = {
 	{ .compatible = "sony,imx412", .data = "imx412" },
+	{ .compatible = "sony,imx477", .data = "imx477" },
+	{ .compatible = "sony,imx577", .data = "imx577" },
 	{ }
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings
  2022-09-16 14:02 ` [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings Bryan O'Donoghue
@ 2022-09-21 19:03   ` Sakari Ailus
  2022-09-21 19:04     ` Bryan O'Donoghue
  0 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2022-09-21 19:03 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: dave.stevenson, jacopo, paul.j.murphy, daniele.alessandrelli,
	mchehab, linux-media

Hi Brian,

On Fri, Sep 16, 2022 at 03:02:11PM +0100, Bryan O'Donoghue wrote:
> Add compatible bindings for imx477 and imx577 both of which use the
> same silicon enabling reference code from Sony in the available examples
> provided.
> 
> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

The patch looks good to me and I was waiting for an ack from the DT folks.
They aren't cc'd. Could you resend the patch, cc'ing the devicetree list
and Krzysztof Kozlowski, please?

-- 
Kind regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings
  2022-09-21 19:03   ` Sakari Ailus
@ 2022-09-21 19:04     ` Bryan O'Donoghue
  2022-09-21 19:06       ` Sakari Ailus
  0 siblings, 1 reply; 7+ messages in thread
From: Bryan O'Donoghue @ 2022-09-21 19:04 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: dave.stevenson, jacopo, paul.j.murphy, daniele.alessandrelli,
	mchehab, linux-media

On 21/09/2022 20:03, Sakari Ailus wrote:
> Hi Brian,
> 
> On Fri, Sep 16, 2022 at 03:02:11PM +0100, Bryan O'Donoghue wrote:
>> Add compatible bindings for imx477 and imx577 both of which use the
>> same silicon enabling reference code from Sony in the available examples
>> provided.
>>
>> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> 
> The patch looks good to me and I was waiting for an ack from the DT folks.
> They aren't cc'd. Could you resend the patch, cc'ing the devicetree list
> and Krzysztof Kozlowski, please?
> 
np

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings
  2022-09-21 19:04     ` Bryan O'Donoghue
@ 2022-09-21 19:06       ` Sakari Ailus
  0 siblings, 0 replies; 7+ messages in thread
From: Sakari Ailus @ 2022-09-21 19:06 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: dave.stevenson, jacopo, paul.j.murphy, daniele.alessandrelli,
	mchehab, linux-media

On Wed, Sep 21, 2022 at 08:04:42PM +0100, Bryan O'Donoghue wrote:
> On 21/09/2022 20:03, Sakari Ailus wrote:
> > Hi Brian,
> > 
> > On Fri, Sep 16, 2022 at 03:02:11PM +0100, Bryan O'Donoghue wrote:
> > > Add compatible bindings for imx477 and imx577 both of which use the
> > > same silicon enabling reference code from Sony in the available examples
> > > provided.
> > > 
> > > Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> > 
> > The patch looks good to me and I was waiting for an ack from the DT folks.
> > They aren't cc'd. Could you resend the patch, cc'ing the devicetree list
> > and Krzysztof Kozlowski, please?
> > 
> np

I actually think it's better to resend the entire set.

-- 
Sakari Ailus

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-21 19:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 14:02 [PATCH v4 0/3] Add imx577 and imx477 compatible to imx412 Bryan O'Donoghue
2022-09-16 14:02 ` [PATCH v4 1/3] media: dt-bindings: imx412: Extend compatible strings Bryan O'Donoghue
2022-09-21 19:03   ` Sakari Ailus
2022-09-21 19:04     ` Bryan O'Donoghue
2022-09-21 19:06       ` Sakari Ailus
2022-09-16 14:02 ` [PATCH v4 2/3] media: i2c: imx412: Assign v4l2 device subname based on compat string Bryan O'Donoghue
2022-09-16 14:02 ` [PATCH v4 3/3] media: i2c: imx412: Add new compatible strings Bryan O'Donoghue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).