Skip to contentSkip to conversation

Add the cat24c208 EDID EEPROM driver + new EDID capability

PATCH In review Erling Ljunggren 3 participants 11 messages Nov 11, 2022 – Nov 18, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover Add the cat24c208 EDID EEPROM driver + new EDID capability

This series adds support for the standalone cat24c208 EDID EEPROM i2c device. Usually EDID support is part of an HDMI receiver, but this is a standalone EEPROM.

Note that EEPROMs for EDIDs are not regular EEPROM devices, these are dual port devices that follow the VESA E-DDC standard.

Since this is a standalone device that does not capture any video a new V4L2_CAP_EDID capability is introduced to represent such devices. Note that such a device doesn't have to be an EEPROM, it can also be implemented using a microcontroller, for example.

v4:
- update driver and bindings to support a video input connector phandle
- use connector phandle to get HPD gpio and input label

v3:
- use old V4L2_CAP_ASYNCIO (0x02000000) capability bit
- validate physical address of edid in driver
- handle empty edid in driver
- add cec notifier support to driver
- update driver and bindings with hpd gpio support
- removed references to "memory" in capability and docs
- associate ioctls based on device direction

v2:
- fix dt binding example
- rename i2c client variables in data struct
- fix include: of_device.h -> mod_devicetable.h
- sorted makefile
- used define EDID_OFFSET_EXT_FLAG instead of magic number
- removed of_match_ptr
- added bus_info
- remove unneeded headers
- add depends on OF to Kconfig

Erling Ljunggren (4):
media: videodev2.h: add V4L2_CAP_EDID
media: docs: Add V4L2_CAP_EDID
dt-bindings: media: add cat24c208 bindings
media: v4l2-dev: handle V4L2_CAP_EDID

Jonathan Selnes (1):
media: i2c: cat24c208: driver for the cat24c208 EDID EEPROM

 .../bindings/media/i2c/onnn,cat24c208.yaml    |  46 ++
 .../userspace-api/media/v4l/biblio.rst        |  11 +
 .../media/v4l/vidioc-querycap.rst             |  11 +
 .../media/videodev2.h.rst.exceptions          |   1 +
 MAINTAINERS                                   |   7 +
 drivers/media/i2c/Kconfig                     |   9 +
 drivers/media/i2c/Makefile                    |   1 +
 drivers/media/i2c/cat24c208.c                 | 499 ++++++++++++++++++
 drivers/media/v4l2-core/v4l2-dev.c            |  15 +
 include/uapi/linux/videodev2.h                |   1 +
 10 files changed, 601 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
 create mode 100644 drivers/media/i2c/cat24c208.c
Signature · 1 line
2.38.0
#1 lore raw

PATCH v4 1/5 media: videodev2.h: add V4L2_CAP_EDID

Add capability flag to indicate that the device is an EDID-only device.

---
 include/uapi/linux/videodev2.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/videodev2.h +1 -0
index 054fc8bbdb22..2ea95639f441 100644
@@ -480,6 +480,7 @@ struct v4l2_capability {
 #define V4L2_CAP_META_CAPTURE		0x00800000  /* Is a metadata capture device */
 
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
+#define V4L2_CAP_EDID			0x02000000  /* Is an EDID-only device */
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
 #define V4L2_CAP_META_OUTPUT		0x08000000  /* Is a metadata output device */
 
Signature · 1 line
2.38.0
#2 lore raw

PATCH v4 2/5 media: docs: Add V4L2_CAP_EDID

In reply to Erling Ljunggren

Add documentation for the new edid capability.

---
 Documentation/userspace-api/media/v4l/biblio.rst      | 11 +++++++++++
 .../userspace-api/media/v4l/vidioc-querycap.rst       | 11 +++++++++++
 .../userspace-api/media/videodev2.h.rst.exceptions    |  1 +
 3 files changed, 23 insertions(+)
Documentation/userspace-api/media/v4l/biblio.rst +11 -0
index 9cd18c153d19..5cbe41877a63 100644
@@ -334,6 +334,17 @@ VESA DMT
 
 :author:    Video Electronics Standards Association (http://www.vesa.org)
 
+.. _vesaeddc:
+
+E-DDC
+====
+
+
+:title:     VESA Enhanced Display Data Channel (E-DDC) Standard
+:subtitle:  Version 1.3
+
+:author:    Video Electronics Standards Association (http://www.vesa.org)
+
 .. _vesaedid:
 
 EDID
Documentation/userspace-api/media/v4l/vidioc-querycap.rst +11 -0
index 6c57b8428356..3d11d86d9cbf 100644
@@ -244,6 +244,17 @@ specification the ioctl returns an ``EINVAL`` error code.
       - 0x01000000
       - The device supports the :c:func:`read()` and/or
 	:c:func:`write()` I/O methods.
+    * - ``V4L2_CAP_EDID``
+      - 0x02000000
+      - The device stores the EDID for a video input, or retrieves the EDID for a video
+        output. It is a standalone EDID device, so no video streaming etc. will take place.
+
+        For a video input this is typically an eeprom that supports the
+        :ref:`VESA Enhanced Display Data Channel Standard <vesaeddc>`. It can be something
+        else as well, for example a micro controller.
+
+        For a video output this is typically read from an external device such as an
+        HDMI splitter accessed by a serial port.
     * - ``V4L2_CAP_STREAMING``
       - 0x04000000
       - The device supports the :ref:`streaming <mmap>` I/O method.
Documentation/userspace-api/media/videodev2.h.rst.exceptions +1 -0
index 9cbb7a0c354a..b1b1127d278c 100644
@@ -185,6 +185,7 @@ replace define V4L2_CAP_META_OUTPUT device-capabilities
 replace define V4L2_CAP_DEVICE_CAPS device-capabilities
 replace define V4L2_CAP_TOUCH device-capabilities
 replace define V4L2_CAP_IO_MC device-capabilities
+replace define V4L2_CAP_EDID device-capabilities
 
 # V4L2 pix flags
 replace define V4L2_PIX_FMT_PRIV_MAGIC :c:type:`v4l2_pix_format`
Signature · 1 line
2.38.0
#3 lore raw

PATCH v4 3/5 dt-bindings: media: add cat24c208 bindings

In reply to Erling Ljunggren

Add devicetree bindings for new cat24c208 EDID EEPROM driver.

---
 .../bindings/media/i2c/onnn,cat24c208.yaml    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +46 -0
new file mode 100644
index 000000000000..492eecb3ab7c
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,cat24c208.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor CAT24C208 EDID EEPROM driver
+
+maintainers:
+  - Hans Verkuil <[email protected]>
+
+description: |
+  CAT24C208 is a dual port i2c EEPROM designed for EDID storage.
+
+properties:
+  compatible:
+    const: onnn,cat24c208
+
+  reg:
+    maxItems: 1
+
+  input-connector:
+    description: |
+      Phandle to the video input connector, used to find
+      the HPD gpio and the connector label, both optional.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+required:
+  - compatible
+  - reg
+  - input-connector
+
+additionalProperties: false
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        cat24c208@31 {
+            compatible = "onnn,cat24c208";
+            reg = <0x31>;
+            input-connector = <&hdmi_connector_in>;
+        };
+    };
Signature · 1 line
2.38.0
maintainer
#4 lore raw

Re: [PATCH v4 3/5] dt-bindings: media: add cat24c208 bindings

Quoted 30 lines · Erling Ljunggren

Add devicetree bindings for new cat24c208 EDID EEPROM driver.

---
 .../bindings/media/i2c/onnn,cat24c208.yaml    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +16 -0
new file mode 100644
index 000000000000..492eecb3ab7c
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,cat24c208.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor CAT24C208 EDID EEPROM driver
+
+maintainers:
+  - Hans Verkuil <[email protected]>
+
+description: |
+  CAT24C208 is a dual port i2c EEPROM designed for EDID storage.
+
+properties:
+  compatible:

Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml line 26

Quoted 10 lines
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +10 -0
+    const: onnn,cat24c208
+
+  reg:
+    maxItems: 1
+
+  input-connector:
+    description: |
+      Phandle to the video input connector, used to find
+      the HPD gpio and the connector label, both optional.
+    $ref: /schemas/types.yaml#/definitions/phandle

The binding and driver feel the wrong way around to me. It seems like you should have a driver for the connector and it needs HPD GPIO, label, and EEPROM. The driver instead looks mostly like an EEPROM driver that hooks into a few connector properties.

Reading the datasheet, I don't see anything special about accessing the EEPROM from the host (DSP) side. Wouldn't the default at24 driver work? It exposes regmap and nvmem.

Rob

#5 lore raw

Re: [PATCH v4 3/5] dt-bindings: media: add cat24c208 bindings

Quoted 38 lines · Rob Herring
Quoted 37 lines · Erling Ljunggren

Add devicetree bindings for new cat24c208 EDID EEPROM driver.

---
 .../bindings/media/i2c/onnn,cat24c208.yaml    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +23 -0
new file mode 100644
index 000000000000..492eecb3ab7c
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,cat24c208.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor CAT24C208 EDID EEPROM driver
+
+maintainers:
+  - Hans Verkuil <[email protected]>
+
+description: |
+  CAT24C208 is a dual port i2c EEPROM designed for EDID storage.
+
+properties:
+  compatible:
+    const: onnn,cat24c208
+
+  reg:
+    maxItems: 1
+
+  input-connector:
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml line 26

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +3 -0
+      Phandle to the video input connector, used to find
+      the HPD gpio and the connector label, both optional.
+    $ref: /schemas/types.yaml#/definitions/phandle

The binding and driver feel the wrong way around to me. It seems like you should have a driver for the connector and it needs HPD GPIO, label, and EEPROM. The driver instead looks mostly like an EEPROM driver that hooks into a few connector properties.

A device like this is typically used next to an HDMI receiver: the DDC lines and the HPD line are connected to the EDID EEPROM, and the video is handled by the HDMI receiver.

Most HDMI receivers will have the EDID part integrated into the chip itself (see e.g. the adv7604 driver), but that doesn't have to be the case. The EDID can be completely separate, it doesn't matter for the receiver part.

In our specific use-case there isn't even an HDMI receiver since the HDMI video is passed through and this EDID EEPROM is used to help debug HDMI issues by presenting custom EDIDs, similar to something like this:

https://www.amazon.com/dp/B0722NVQHX

The HPD line is controlled by the EDID part since it has to be low if there is no EDID or pulled low for at least 100ms if the EDID is being modified.

Quoted 4 lines

Reading the datasheet, I don't see anything special about accessing the EEPROM from the host (DSP) side. Wouldn't the default at24 driver work? It exposes regmap and nvmem.

No. It is not a regular EEPROM, it is dedicated to store EDIDs. It has to correctly toggle the HPD line and inform other drivers (specifically HDMI CEC) of EDID updates.

I don't see how the at24 could work: besides the eeprom i2c address it has to deal with two additional i2c devices: the segment address and the config address of the device itself. Writing to the eeprom from the host side requires a write to the segment address followed by a write to the eeprom part itself, and that's not something the at24 can do. And it is also something very specific to the VESA E-DDC standard (freely downloadable from vesa.org).

Note that historically the first EDID EEPROMs most likely did work like the at24, but as EDID sizes grew beyond 256 bytes the E-DDC standard was created and that departed from the normal EEPROMs.

Regards,

Hans

Quoted 2 lines

Rob

maintainer
#6 lore raw

Re: [PATCH v4 3/5] dt-bindings: media: add cat24c208 bindings

+Bartosz

Quoted 57 lines · Hans Verkuil
Quoted 38 lines · Rob Herring
Quoted 37 lines · Erling Ljunggren

Add devicetree bindings for new cat24c208 EDID EEPROM driver.

---
 .../bindings/media/i2c/onnn,cat24c208.yaml    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +23 -0
new file mode 100644
index 000000000000..492eecb3ab7c
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,cat24c208.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor CAT24C208 EDID EEPROM driver
+
+maintainers:
+  - Hans Verkuil <[email protected]>
+
+description: |
+  CAT24C208 is a dual port i2c EEPROM designed for EDID storage.
+
+properties:
+  compatible:
+    const: onnn,cat24c208
+
+  reg:
+    maxItems: 1
+
+  input-connector:
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml line 26

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +3 -0
+      Phandle to the video input connector, used to find
+      the HPD gpio and the connector label, both optional.
+    $ref: /schemas/types.yaml#/definitions/phandle

The binding and driver feel the wrong way around to me. It seems like you should have a driver for the connector and it needs HPD GPIO, label, and EEPROM. The driver instead looks mostly like an EEPROM driver that hooks into a few connector properties.

A device like this is typically used next to an HDMI receiver: the DDC lines and the HPD line are connected to the EDID EEPROM, and the video is handled by the HDMI receiver.

Most HDMI receivers will have the EDID part integrated into the chip itself (see e.g. the adv7604 driver), but that doesn't have to be the case. The EDID can be completely separate, it doesn't matter for the receiver part.

Quoted 8 lines

In our specific use-case there isn't even an HDMI receiver since the HDMI video is passed through and this EDID EEPROM is used to help debug HDMI issues by presenting custom EDIDs, similar to something like this:

https://www.amazon.com/dp/B0722NVQHX

The HPD line is controlled by the EDID part since it has to be low if there is no EDID or pulled low for at least 100ms if the EDID is being modified.

There is no HPD control on the EEPROM itself. So HPD does not belong in the EEPROM node. That is the fundamental problem with the binding.

We've always started bindings without connector nodes and just shove properties into whatever node we do have. Then things evolve to be more complicated with different h/w and that doesn't work. Start with a connector even if you think it is overkill.

Quoted 8 lines
Quoted 3 lines

Reading the datasheet, I don't see anything special about accessing the EEPROM from the host (DSP) side. Wouldn't the default at24 driver work? It exposes regmap and nvmem.

No. It is not a regular EEPROM, it is dedicated to store EDIDs. It has to correctly toggle the HPD line and inform other drivers (specifically HDMI CEC) of EDID updates.

Quoted 6 lines

I don't see how the at24 could work: besides the eeprom i2c address it has to deal with two additional i2c devices: the segment address and the config address of the device itself. Writing to the eeprom from the host side requires a write to the segment address followed by a write to the eeprom part itself, and that's not something the at24 can do. And it is also something very specific to the VESA E-DDC standard (freely downloadable from vesa.org).

The addressing is different on the DSP (as the datasheet calls it) side compared to the DDC side which has the EDID_SEL signal. Linux only sees the DSP side, right? Looking at it a bit more, it looks like the segment addressing is different from at24 which uses an i2c address per segment. It is similar to ee1004 SPD where the segment is selected by a write to a 2nd i2c address.

Quoted 3 lines

Note that historically the first EDID EEPROMs most likely did work like the at24, but as EDID sizes grew beyond 256 bytes the E-DDC standard was created and that departed from the normal EEPROMs.

What happens if/when you have more than 1 part to support? Why not provide a regmap or nvmem to the EDID storage and then the backend device can be anything. I could imagine we could have a s/w implementation.

Anyways, I don't really care if you do any of that now, but I still think the binding is backwards. It's the connector you are managing, not just an EEPROM, so you should bind to the connector and from there gather all the resources you need to do that (EEPROM, HPD).

Rob

#7 lore raw

Re: [PATCH v4 3/5] dt-bindings: media: add cat24c208 bindings

Quoted 64 lines · Rob Herring

+Bartosz

Quoted 61 lines · Hans Verkuil
Quoted 38 lines · Rob Herring
Quoted 37 lines · Erling Ljunggren

Add devicetree bindings for new cat24c208 EDID EEPROM driver.

---
 .../bindings/media/i2c/onnn,cat24c208.yaml    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +23 -0
new file mode 100644
index 000000000000..492eecb3ab7c
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,cat24c208.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor CAT24C208 EDID EEPROM driver
+
+maintainers:
+  - Hans Verkuil <[email protected]>
+
+description: |
+  CAT24C208 is a dual port i2c EEPROM designed for EDID storage.
+
+properties:
+  compatible:
+    const: onnn,cat24c208
+
+  reg:
+    maxItems: 1
+
+  input-connector:
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml line 26

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +3 -0
+      Phandle to the video input connector, used to find
+      the HPD gpio and the connector label, both optional.
+    $ref: /schemas/types.yaml#/definitions/phandle

The binding and driver feel the wrong way around to me. It seems like you should have a driver for the connector and it needs HPD GPIO, label, and EEPROM. The driver instead looks mostly like an EEPROM driver that hooks into a few connector properties.

A device like this is typically used next to an HDMI receiver: the DDC lines and the HPD line are connected to the EDID EEPROM, and the video is handled by the HDMI receiver.

Most HDMI receivers will have the EDID part integrated into the chip itself (see e.g. the adv7604 driver), but that doesn't have to be the case. The EDID can be completely separate, it doesn't matter for the receiver part.

In our specific use-case there isn't even an HDMI receiver since the HDMI video is passed through and this EDID EEPROM is used to help debug HDMI issues by presenting custom EDIDs, similar to something like this:

Quoted 7 lines
Quoted 4 lines

https://www.amazon.com/dp/B0722NVQHX

The HPD line is controlled by the EDID part since it has to be low if there is no EDID or pulled low for at least 100ms if the EDID is being modified.

There is no HPD control on the EEPROM itself. So HPD does not belong in the EEPROM node. That is the fundamental problem with the binding.

Perhaps there is a terminology issue here: the input-connector phandle points to a connector (an hdmi-connector in our case, but it can also be a dvi-connector for example). The driver gets the HPD gpio from the connector node. Perhaps the example should be extended with the hdmi-connector node?

Or do you mean that the hdmi-connector node should point to the EDID driver? In other words, a new property has to be added there to support a reference to an EDID device (the hdmi connector bindings are currently written for HDMI output and never used with HDMI input drivers).

Regards,

Hans

Quoted 43 lines

We've always started bindings without connector nodes and just shove properties into whatever node we do have. Then things evolve to be more complicated with different h/w and that doesn't work. Start with a connector even if you think it is overkill.

Quoted 8 lines
Quoted 3 lines

Reading the datasheet, I don't see anything special about accessing the EEPROM from the host (DSP) side. Wouldn't the default at24 driver work? It exposes regmap and nvmem.

No. It is not a regular EEPROM, it is dedicated to store EDIDs. It has to correctly toggle the HPD line and inform other drivers (specifically HDMI CEC) of EDID updates.

Quoted 6 lines

I don't see how the at24 could work: besides the eeprom i2c address it has to deal with two additional i2c devices: the segment address and the config address of the device itself. Writing to the eeprom from the host side requires a write to the segment address followed by a write to the eeprom part itself, and that's not something the at24 can do. And it is also something very specific to the VESA E-DDC standard (freely downloadable from vesa.org).

The addressing is different on the DSP (as the datasheet calls it) side compared to the DDC side which has the EDID_SEL signal. Linux only sees the DSP side, right? Looking at it a bit more, it looks like the segment addressing is different from at24 which uses an i2c address per segment. It is similar to ee1004 SPD where the segment is selected by a write to a 2nd i2c address.

Quoted 3 lines

Note that historically the first EDID EEPROMs most likely did work like the at24, but as EDID sizes grew beyond 256 bytes the E-DDC standard was created and that departed from the normal EEPROMs.

What happens if/when you have more than 1 part to support? Why not provide a regmap or nvmem to the EDID storage and then the backend device can be anything. I could imagine we could have a s/w implementation.

Anyways, I don't really care if you do any of that now, but I still think the binding is backwards. It's the connector you are managing, not just an EEPROM, so you should bind to the connector and from there gather all the resources you need to do that (EEPROM, HPD).

Rob

maintainer
#8 lore raw

Re: [PATCH v4 3/5] dt-bindings: media: add cat24c208 bindings

Quoted 71 lines · Hans Verkuil
Quoted 69 lines · Rob Herring

+Bartosz

Quoted 65 lines · Hans Verkuil
Quoted 38 lines · Rob Herring
Quoted 37 lines · Erling Ljunggren

Add devicetree bindings for new cat24c208 EDID EEPROM driver.

---
 .../bindings/media/i2c/onnn,cat24c208.yaml    | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +23 -0
new file mode 100644
index 000000000000..492eecb3ab7c
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/i2c/onnn,cat24c208.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor CAT24C208 EDID EEPROM driver
+
+maintainers:
+  - Hans Verkuil <[email protected]>
+
+description: |
+  CAT24C208 is a dual port i2c EEPROM designed for EDID storage.
+
+properties:
+  compatible:
+    const: onnn,cat24c208
+
+  reg:
+    maxItems: 1
+
+  input-connector:
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml line 26

Quoted 3 lines
Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml new file +3 -0
+      Phandle to the video input connector, used to find
+      the HPD gpio and the connector label, both optional.
+    $ref: /schemas/types.yaml#/definitions/phandle

The binding and driver feel the wrong way around to me. It seems like you should have a driver for the connector and it needs HPD GPIO, label, and EEPROM. The driver instead looks mostly like an EEPROM driver that hooks into a few connector properties.

A device like this is typically used next to an HDMI receiver: the DDC lines and the HPD line are connected to the EDID EEPROM, and the video is handled by the HDMI receiver.

Most HDMI receivers will have the EDID part integrated into the chip itself (see e.g. the adv7604 driver), but that doesn't have to be the case. The EDID can be completely separate, it doesn't matter for the receiver part.

In our specific use-case there isn't even an HDMI receiver since the HDMI video is passed through and this EDID EEPROM is used to help debug HDMI issues by presenting custom EDIDs, similar to something like this:

https://www.amazon.com/dp/B0722NVQHX

The HPD line is controlled by the EDID part since it has to be low if there is no EDID or pulled low for at least 100ms if the EDID is being modified.

Quoted 8 lines
Quoted 2 lines

There is no HPD control on the EEPROM itself. So HPD does not belong in the EEPROM node. That is the fundamental problem with the binding.

Perhaps there is a terminology issue here: the input-connector phandle points to a connector (an hdmi-connector in our case, but it can also be a dvi-connector for example). The driver gets the HPD gpio from the connector node. Perhaps the example should be extended with the hdmi-connector node?

You do need to define a connector node. But 'hdmi-connector' is taken and means an hdmi output (though maybe it got used by someone for an input?). The input side has and does different things, so we should define a new compatible rather than complicate our lives trying to reuse and extend the current one. So you need 'hdmi-in-connector' compatible or something like that. You can possibly add this to the existing hdmi-connector schema depending on how much the existing properties may apply. For example, ddc-i2c-bus points to an i2c slave for a s/w EDID?

Quoted 2 lines

Or do you mean that the hdmi-connector node should point to the EDID driver?

DT does not have drivers, but yes, the HDMI connector node should point to the EEPROM h/w device.

Rob

#9 lore raw

PATCH v4 4/5 media: i2c: cat24c208: driver for the cat24c208 EDID EEPROM

In reply to Erling Ljunggren

From: Jonathan Selnes <[email protected]>

Support reading and writing the EDID EEPROM through the v4l2 API.

---
 MAINTAINERS                   |   7 +
 drivers/media/i2c/Kconfig     |   9 +
 drivers/media/i2c/Makefile    |   1 +
 drivers/media/i2c/cat24c208.c | 499 ++++++++++++++++++++++++++++++++++
 4 files changed, 516 insertions(+)
 create mode 100644 drivers/media/i2c/cat24c208.c
MAINTAINERS +7 -0
index 7d9490a5c15a..407d76c42bab 100644
@@ -14912,6 +14912,13 @@ S:	Maintained
 T:	git git://linuxtv.org/media_tree.git
 F:	drivers/media/i2c/ov9734.c
 
+ON SEMICONDUCTOR CAT24C208 EDID EEPROM DRIVER
+M:	Hans Verkuil <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/media/i2c/onnn,cat24c208.yaml
+F:	drivers/media/i2c/cat24c208*
+
 ONENAND FLASH DRIVER
 M:	Kyungmin Park <[email protected]>
 L:	[email protected]
drivers/media/i2c/Kconfig +9 -0
index 2b20aa6c37b1..2f5f9f058b48 100644
@@ -1530,6 +1530,15 @@ endmenu
 menu "Miscellaneous helper chips"
 	visible if !MEDIA_HIDE_ANCILLARY_SUBDRV
 
+config VIDEO_CAT24C208
+	tristate "ON Semiconductor cat24c208 EDID EEPROM"
+	depends on VIDEO_DEV && I2C && OF
+	help
+	  Support for the ON Semiconductor CAT24C208 Dual Port EDID EEPROM.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called cat24c208.
+
 config VIDEO_I2C
 	tristate "I2C transport video support"
 	depends on VIDEO_DEV && I2C
drivers/media/i2c/Makefile +1 -0
index 3e1696963e7f..70e4360a21ba 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_VIDEO_APTINA_PLL) += aptina-pll.o
 obj-$(CONFIG_VIDEO_BT819) += bt819.o
 obj-$(CONFIG_VIDEO_BT856) += bt856.o
 obj-$(CONFIG_VIDEO_BT866) += bt866.o
+obj-$(CONFIG_VIDEO_CAT24C208) += cat24c208.o
 obj-$(CONFIG_VIDEO_CCS) += ccs/
 obj-$(CONFIG_VIDEO_CCS_PLL) += ccs-pll.o
 obj-$(CONFIG_VIDEO_CS3308) += cs3308.o
drivers/media/i2c/cat24c208.c new file +499 -0

499 lines not on this page · raw message

Signature · 1 line
2.38.0
#10 lore raw

PATCH v4 5/5 media: v4l2-dev: handle V4L2_CAP_EDID

In reply to Erling Ljunggren

When the V4L2_CAP_EDID capability flag is set,
ioctls for enum inputs/outputs and get/set edid are automatically set.

---
 drivers/media/v4l2-core/v4l2-dev.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/media/v4l2-core/v4l2-dev.c +15 -0
index d00237ee4cae..e8222b9835e6 100644
@@ -556,6 +556,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
 	bool is_rx = vdev->vfl_dir != VFL_DIR_TX;
 	bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
 	bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC;
+	bool is_edid =  vdev->device_caps & V4L2_CAP_EDID;
 
 	bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE);
 
@@ -778,6 +779,20 @@ static void determine_valid_ioctls(struct video_device *vdev)
 		SET_VALID_IOCTL(ops, VIDIOC_S_TUNER, vidioc_s_tuner);
 		SET_VALID_IOCTL(ops, VIDIOC_S_HW_FREQ_SEEK, vidioc_s_hw_freq_seek);
 	}
+	if (is_edid) {
+		SET_VALID_IOCTL(ops, VIDIOC_G_EDID, vidioc_g_edid);
+		if (is_tx) {
+			SET_VALID_IOCTL(ops, VIDIOC_G_OUTPUT, vidioc_g_output);
+			SET_VALID_IOCTL(ops, VIDIOC_S_OUTPUT, vidioc_s_output);
+			SET_VALID_IOCTL(ops, VIDIOC_ENUMOUTPUT, vidioc_enum_output);
+		}
+		if (is_rx) {
+			SET_VALID_IOCTL(ops, VIDIOC_ENUMINPUT, vidioc_enum_input);
+			SET_VALID_IOCTL(ops, VIDIOC_G_INPUT, vidioc_g_input);
+			SET_VALID_IOCTL(ops, VIDIOC_S_INPUT, vidioc_s_input);
+			SET_VALID_IOCTL(ops, VIDIOC_S_EDID, vidioc_s_edid);
+		}
+	}
 
 	bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls,
 			BASE_VIDIOC_PRIVATE);
Signature · 1 line
2.38.0