Skip to contentSkip to conversation

media: cec: add support for the Extron DA HD 4K Plus HDMI Splitter

PATCH In review Hans Verkuil 4 participants 18 messages Aug 9, 2024 – Aug 29, 2024

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

cover media: cec: add support for the Extron DA HD 4K Plus HDMI Splitter

This series adds support for the Extron DA HD 4K Plus HDMI Splitter:

https://www.extron.com/product/dahd4kplusseries

This HDMI Splitter supports CEC and reading (HDMI outputs) and writing (HDMI input) of EDIDs.

This driver adds support for this device, allowing full control of the CEC functionality (each HDMI input or output has its own /dev/cecX device) and EDIDs (each HDMI input or output has its own /dev/videoX device).

By using module options you can configure the driver to be fully transparent, i.e. it will pass on CEC messages between input and outputs and automatically configure EDIDs based on the detected displays, or leave it in manual mode, requiring userspace to configure everything manually.

Since the V4L2 API is only used to read/write the EDID and no video streaming takes place (that's all handled by the HDMI Splitter), a new capability CAP_EDID is added (first three patches). Next SERIO_EXTRON_DA_HD_PLUS is added to serio.h (this driver uses the USB serial port of the Extron device to control it). Then a small patch for the cec framework is applied that makes it possible for the extron driver to use the cec_get/put_device() functions. And finally the driver itself is added.

Note: this requires an update to the inputattach utility as well, once the SERIO_EXTRON_DA_HD_PLUS is added. There will also be a v4l2-compliance patch to test the new capability. I hope to post that in 1-2 weeks (it needs a bit more testing).

Note that I placed most of the generic CEC handling in cec-splitter.c. While this is currently part of this driver, it can be moved to media/cec/core if support for other HDMI Splitters is ever added, so it can be reused.

Regards,

Hans

Erling Ljunggren (3):
media: videodev2.h: add V4L2_CAP_EDID
media: v4l2-dev: handle V4L2_CAP_EDID
media: docs: Add V4L2_CAP_EDID

Hans Verkuil (3):
input: serio.h: add SERIO_EXTRON_DA_HD_PLUS
media: cec: move cec_get/put_device to header
media: cec: extron-da-hd-4k-plus: add the Extron DA HD 4K Plus CEC
driver

 Documentation/admin-guide/media/cec.rst       |   87 +
 .../userspace-api/media/v4l/biblio.rst        |   11 +
 .../media/v4l/vidioc-querycap.rst             |   11 +
 .../media/videodev2.h.rst.exceptions          |    1 +
 MAINTAINERS                                   |    7 +
 drivers/media/cec/core/cec-api.c              |    4 +-
 drivers/media/cec/core/cec-core.c             |   29 -
 drivers/media/cec/core/cec-priv.h             |    2 -
 drivers/media/cec/usb/Kconfig                 |    1 +
 drivers/media/cec/usb/Makefile                |    1 +
 .../cec/usb/extron-da-hd-4k-plus/Kconfig      |   14 +
 .../cec/usb/extron-da-hd-4k-plus/Makefile     |    8 +
 .../usb/extron-da-hd-4k-plus/cec-splitter.c   |  657 ++++++
 .../usb/extron-da-hd-4k-plus/cec-splitter.h   |   51 +
 .../extron-da-hd-4k-plus.c                    | 1836 +++++++++++++++++
 .../extron-da-hd-4k-plus.h                    |  118 ++
 drivers/media/v4l2-core/v4l2-dev.c            |   15 +
 include/media/cec.h                           |   31 +
 include/uapi/linux/serio.h                    |    1 +
 include/uapi/linux/videodev2.h                |    1 +
 20 files changed, 2853 insertions(+), 33 deletions(-)
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/Kconfig
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/Makefile
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/cec-splitter.c
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/cec-splitter.h
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.h
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/6 media: videodev2.h: add V4L2_CAP_EDID

From: Erling Ljunggren <[email protected]>

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 4e91362da6da..987c821aed79 100644
@@ -502,6 +502,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.43.0
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] media: videodev2.h: add V4L2_CAP_EDID

Hello,

Quoted 6 lines · Hans Verkuil

From: Erling Ljunggren <[email protected]>

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

Regards,
Sebastian

Quoted 20 lines

---
include/uapi/linux/videodev2.h | 1 +

1 file changed, 1 insertion(+)
include/uapi/linux/videodev2.h +1 -0
index 4e91362da6da..987c821aed79 100644
@@ -502,6 +502,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.43.0
#3 lore raw

Re: [PATCH 1/6] media: videodev2.h: add V4L2_CAP_EDID

In reply to Hans Verkuil

Hi Hans

Quoted 16 lines · Hans Verkuil

From: Erling Ljunggren <[email protected]>

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 +0 -0
index 4e91362da6da..987c821aed79 100644

include/uapi/linux/videodev2.h struct v4l2_capability { · line 505

Quoted 4 lines
include/uapi/linux/videodev2.h +1 -0
@@ -502,6 +502,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 */

Would it make sense to add a check for "EDID-only", I mean, if the driver sets this cap, then it should not set V4L2_CAP_STREAMING or others.

The test could be in the core or even in v4l2-compliance.

Regards!

Quoted 7 lines
include/uapi/linux/videodev2.h +0 -1
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
 #define V4L2_CAP_META_OUTPUT           0x08000000  /* Is a metadata output device */
 
--

2.43.0

--
Ricardo Ribalda

#4 lore raw

Re: [PATCH 1/6] media: videodev2.h: add V4L2_CAP_EDID

Quoted 21 lines · Ricardo Ribalda Delgado

Hi Hans

Quoted 18 lines · Hans Verkuil

From: Erling Ljunggren <[email protected]>

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 +0 -0
index 4e91362da6da..987c821aed79 100644
@@ -502,6 +502,7 @@ struct v4l2_capability {
 #define V4L2_CAP_META_CAPTURE          0x00800000  /* Is a metadata capture device */
 
Quoted 7 lines

include/uapi/linux/videodev2.h struct v4l2_capability { · line 505

Quoted 2 lines
include/uapi/linux/videodev2.h +1 -0
 #define V4L2_CAP_READWRITE              0x01000000  /* read/write systemcalls */
+#define V4L2_CAP_EDID                  0x02000000  /* Is an EDID-only device */

Would it make sense to add a check for "EDID-only", I mean, if the driver sets this cap, then it should not set V4L2_CAP_STREAMING or others.

The test could be in the core or even in v4l2-compliance.

Good point. It is easy to add this to v4l2-compliance.

I noticed that the v4l2 core doesn't check for invalid caps combinations. It is left to v4l2-compliance to check that. So I think I'll keep the check there.

Regards,

Hans

Quoted 16 lines

Regards!

Quoted 7 lines
include/uapi/linux/videodev2.h +0 -1
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
 #define V4L2_CAP_META_OUTPUT           0x08000000  /* Is a metadata output device */
 
--

2.43.0

--
Ricardo Ribalda

Reviewed-by Ricardo Ribalda
#5 lore raw

Re: [PATCH 1/6] media: videodev2.h: add V4L2_CAP_EDID

Quoted 29 lines · Hans Verkuil
Quoted 27 lines · Ricardo Ribalda Delgado

Hi Hans

Quoted 16 lines · Hans Verkuil

From: Erling Ljunggren <[email protected]>

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 +0 -0
index 4e91362da6da..987c821aed79 100644

include/uapi/linux/videodev2.h struct v4l2_capability { · line 505

Quoted 4 lines
include/uapi/linux/videodev2.h +1 -0
@@ -502,6 +502,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 */

Would it make sense to add a check for "EDID-only", I mean, if the driver sets this cap, then it should not set V4L2_CAP_STREAMING or others.

Quoted 6 lines
Quoted 1 line

The test could be in the core or even in v4l2-compliance.

Good point. It is easy to add this to v4l2-compliance.

I noticed that the v4l2 core doesn't check for invalid caps combinations. It is left to v4l2-compliance to check that. So I think I'll keep the check there.

cool! Thanks

Quoted 22 lines

Regards,

Hans

Quoted 16 lines

Regards!

Quoted 7 lines
include/uapi/linux/videodev2.h +0 -1
 #define V4L2_CAP_STREAMING              0x04000000  /* streaming I/O ioctls */
 #define V4L2_CAP_META_OUTPUT           0x08000000  /* Is a metadata output device */
 
--

2.43.0

--
Ricardo Ribalda

Signature · 1 line
Ricardo Ribalda
#6 lore raw

PATCH 2/6 media: v4l2-dev: handle V4L2_CAP_EDID

In reply to Hans Verkuil

From: Erling Ljunggren <[email protected]>

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 be2ba7ca5de2..570ba00e00b3 100644
@@ -557,6 +557,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
 	bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
 	bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC;
 	bool has_streaming = vdev->device_caps & V4L2_CAP_STREAMING;
+	bool is_edid =  vdev->device_caps & V4L2_CAP_EDID;
 
 	bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE);
 
@@ -784,6 +785,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.43.0
Reviewed-by on v1 2/6
#7 lore raw

Re: [PATCH 2/6] media: v4l2-dev: handle V4L2_CAP_EDID

Hello,

Quoted 7 lines · Hans Verkuil

From: Erling Ljunggren <[email protected]>

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

Regards,
Sebastian

Quoted 41 lines

---
drivers/media/v4l2-core/v4l2-dev.c | 15 +++++++++++++++

1 file changed, 15 insertions(+)
drivers/media/v4l2-core/v4l2-dev.c +15 -0
index be2ba7ca5de2..570ba00e00b3 100644
@@ -557,6 +557,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
 	bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
 	bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC;
 	bool has_streaming = vdev->device_caps & V4L2_CAP_STREAMING;
+	bool is_edid =  vdev->device_caps & V4L2_CAP_EDID;
 
 	bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE);
 
@@ -784,6 +785,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.43.0
Reviewed-by Ricardo Ribalda
#8 lore raw

Re: [PATCH 2/6] media: v4l2-dev: handle V4L2_CAP_EDID

Quoted 6 lines · Sebastian Fricke

Hello,

Quoted 2 lines · Hans Verkuil

From: Erling Ljunggren <[email protected]>

Quoted 7 lines
Quoted 5 lines

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

Quoted 45 lines

Regards,
Sebastian

Quoted 41 lines

---
drivers/media/v4l2-core/v4l2-dev.c | 15 +++++++++++++++

1 file changed, 15 insertions(+)
drivers/media/v4l2-core/v4l2-dev.c +15 -1
index be2ba7ca5de2..570ba00e00b3 100644
@@ -557,6 +557,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
      bool is_tx = vdev->vfl_dir != VFL_DIR_RX;
      bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC;
      bool has_streaming = vdev->device_caps & V4L2_CAP_STREAMING;
+      bool is_edid =  vdev->device_caps & V4L2_CAP_EDID;
 
      bitmap_zero(valid_ioctls, BASE_VIDIOC_PRIVATE);
 
@@ -784,6 +785,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);
--

2.43.0

Signature · 1 line
Ricardo Ribalda
#9 lore raw

PATCH 3/6 media: docs: Add V4L2_CAP_EDID

In reply to Hans Verkuil

From: Erling Ljunggren <[email protected]>

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 72aef1759b60..35674eeae20d 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 bdc628e8c1d6..d67fd4038d22 100644
@@ -197,6 +197,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.43.0
Reviewed-by on v1 3/6
#10 lore raw

Re: [PATCH 3/6] media: docs: Add V4L2_CAP_EDID

Hello,

Quoted 6 lines · Hans Verkuil

From: Erling Ljunggren <[email protected]>

Add documentation for the new edid capability.

Regards,
Sebastian

Quoted 66 lines

---

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 72aef1759b60..35674eeae20d 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 +0 -0
index bdc628e8c1d6..d67fd4038d22 100644
@@ -197,6 +197,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.43.0
Reviewed-by Ricardo Ribalda
#11 lore raw

Re: [PATCH 3/6] media: docs: Add V4L2_CAP_EDID

Quoted 4 lines · Sebastian Fricke

Hello,

On 09.08.2024 09:57, Hans Verkuil wrote:

Quoted 8 lines
Quoted 6 lines

From: Erling Ljunggren <[email protected]>

Add documentation for the new edid capability.

Quoted 71 lines

Regards,
Sebastian

Quoted 66 lines

---

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 72aef1759b60..35674eeae20d 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 +0 -0
index bdc628e8c1d6..d67fd4038d22 100644
@@ -197,6 +197,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 --
2.43.0

Signature · 1 line
Ricardo Ribalda
#12 lore raw

PATCH 4/6 input: serio.h: add SERIO_EXTRON_DA_HD_PLUS

In reply to Hans Verkuil

Add a new serio ID for the Extron DA HD 4K Plus series of 4K HDMI Distribution Amplifiers. These devices support CEC over the serial port, so a new serio ID is needed to be able to associate the CEC driver.

---
 include/uapi/linux/serio.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/serio.h +1 -0
index ed2a96f43ce4..5a2af0942c9f 100644
@@ -83,5 +83,6 @@
 #define SERIO_PULSE8_CEC	0x40
 #define SERIO_RAINSHADOW_CEC	0x41
 #define SERIO_FSIA6B	0x42
+#define SERIO_EXTRON_DA_HD_4K_PLUS	0x43
 
 #endif /* _UAPI_SERIO_H */
Signature · 1 line
2.43.0
#13 lore raw

Re: [PATCH 4/6] input: serio.h: add SERIO_EXTRON_DA_HD_PLUS

Hi Dmitry,

It's a trivial patch, but it would be great if you can give an Acked-by or Reviewed-by.

Regards,

Hans

Quoted 21 lines · Hans Verkuil

Add a new serio ID for the Extron DA HD 4K Plus series of 4K HDMI Distribution Amplifiers. These devices support CEC over the serial port, so a new serio ID is needed to be able to associate the CEC driver.

---
 include/uapi/linux/serio.h | 1 +
 1 file changed, 1 insertion(+)
include/uapi/linux/serio.h +1 -0
index ed2a96f43ce4..5a2af0942c9f 100644
@@ -83,5 +83,6 @@
 #define SERIO_PULSE8_CEC	0x40
 #define SERIO_RAINSHADOW_CEC	0x41
 #define SERIO_FSIA6B	0x42
+#define SERIO_EXTRON_DA_HD_4K_PLUS	0x43
 
 #endif /* _UAPI_SERIO_H */
maintainer
#14 lore raw

Re: [PATCH 4/6] input: serio.h: add SERIO_EXTRON_DA_HD_PLUS

Hi Hans,

Quoted 4 lines · Hans Verkuil

Hi Dmitry,

It's a trivial patch, but it would be great if you can give an Acked-by or Reviewed-by.

My apologies, I missed this.

Please make sure to CC me directly, not just the input list. Hmm, I see that serio.h is missing from the MAINTAINERS file, let me add it...

Thanks.

Signature · 1 line
Dmitry
maintainer Acked-by on v1 4/6
#15 lore raw

Re: [PATCH 4/6] input: serio.h: add SERIO_EXTRON_DA_HD_PLUS

In reply to Hans Verkuil
Quoted 6 lines · Hans Verkuil

Add a new serio ID for the Extron DA HD 4K Plus series of 4K HDMI Distribution Amplifiers. These devices support CEC over the serial port, so a new serio ID is needed to be able to associate the CEC driver.

Please feel free to merge with the rest of the patches.

Thanks.

Signature · 1 line
Dmitry
#16 lore raw

PATCH 5/6 media: cec: move cec_get/put_device to header

In reply to Hans Verkuil

Move cec_get/put_device to the media/cec.h header. This allows CEC drivers to use this.

---
 drivers/media/cec/core/cec-api.c  |  4 ++--
 drivers/media/cec/core/cec-core.c | 29 -----------------------------
 drivers/media/cec/core/cec-priv.h |  2 --
 include/media/cec.h               | 31 +++++++++++++++++++++++++++++++
 4 files changed, 33 insertions(+), 33 deletions(-)
drivers/media/cec/core/cec-api.c +2 -2
index 3ef915344304..c75a4057f00e 100644
@@ -580,7 +580,7 @@ static int cec_open(struct inode *inode, struct file *filp)
 	fh->mode_initiator = CEC_MODE_INITIATOR;
 	fh->adap = adap;
 
-	err = cec_get_device(devnode);
+	err = cec_get_device(adap);
 	if (err) {
 		kfree(fh);
 		return err;
@@ -686,7 +686,7 @@ static int cec_release(struct inode *inode, struct file *filp)
 	mutex_unlock(&fh->lock);
 	kfree(fh);
 
-	cec_put_device(devnode);
+	cec_put_device(adap);
 	filp->private_data = NULL;
 	return 0;
 }
drivers/media/cec/core/cec-core.c +0 -29
index e0756826d629..48282d272fe6 100644
@@ -51,35 +51,6 @@ static struct dentry *top_cec_dir;
 /* dev to cec_devnode */
 #define to_cec_devnode(cd) container_of(cd, struct cec_devnode, dev)
 
-int cec_get_device(struct cec_devnode *devnode)
-{
-	/*
-	 * Check if the cec device is available. This needs to be done with
-	 * the devnode->lock held to prevent an open/unregister race:
-	 * without the lock, the device could be unregistered and freed between
-	 * the devnode->registered check and get_device() calls, leading to
-	 * a crash.
-	 */
-	mutex_lock(&devnode->lock);
-	/*
-	 * return ENODEV if the cec device has been removed
-	 * already or if it is not registered anymore.
-	 */
-	if (!devnode->registered) {
-		mutex_unlock(&devnode->lock);
-		return -ENODEV;
-	}
-	/* and increase the device refcount */
-	get_device(&devnode->dev);
-	mutex_unlock(&devnode->lock);
-	return 0;
-}
-
-void cec_put_device(struct cec_devnode *devnode)
-{
-	put_device(&devnode->dev);
-}
-
 /* Called when the last user of the cec device exits. */
 static void cec_devnode_release(struct device *cd)
 {
drivers/media/cec/core/cec-priv.h +0 -2
index ed1f8c67626b..ce42a37c4ac0 100644
@@ -37,8 +37,6 @@ static inline bool msg_is_raw(const struct cec_msg *msg)
 
 /* cec-core.c */
 extern int cec_debug;
-int cec_get_device(struct cec_devnode *devnode);
-void cec_put_device(struct cec_devnode *devnode);
 
 /* cec-adap.c */
 int cec_monitor_all_cnt_inc(struct cec_adapter *adap);
include/media/cec.h +31 -0
index 07d2ee8a3904..16b412b3131b 100644
@@ -298,6 +298,37 @@ struct cec_adapter {
 	char input_phys[40];
 };
 
+static inline int cec_get_device(struct cec_adapter *adap)
+{
+	struct cec_devnode *devnode = &adap->devnode;
+
+	/*
+	 * Check if the cec device is available. This needs to be done with
+	 * the devnode->lock held to prevent an open/unregister race:
+	 * without the lock, the device could be unregistered and freed between
+	 * the devnode->registered check and get_device() calls, leading to
+	 * a crash.
+	 */
+	mutex_lock(&devnode->lock);
+	/*
+	 * return ENODEV if the cec device has been removed
+	 * already or if it is not registered anymore.
+	 */
+	if (!devnode->registered) {
+		mutex_unlock(&devnode->lock);
+		return -ENODEV;
+	}
+	/* and increase the device refcount */
+	get_device(&devnode->dev);
+	mutex_unlock(&devnode->lock);
+	return 0;
+}
+
+static inline void cec_put_device(struct cec_adapter *adap)
+{
+	put_device(&adap->devnode.dev);
+}
+
 static inline void *cec_get_drvdata(const struct cec_adapter *adap)
 {
 	return adap->priv;
Signature · 1 line
2.43.0
#17 lore raw

PATCH 6/6 media: cec: extron-da-hd-4k-plus: add the Extron DA HD 4K Plus CEC driver

In reply to Hans Verkuil

Add support for the Extron DA HD 4K Plus series of 4K HDMI Distrubution Amplifiers (aka HDMI Splitters).

These devices support CEC and this driver adds support for the CEC protocol for both the input and all outputs (2, 4 or 6 outputs, depending on the model).

It also exports the EDID from the outputs and allows reading and setting the EDID of the input.

---
 Documentation/admin-guide/media/cec.rst       |   87 +
 MAINTAINERS                                   |    7 +
 drivers/media/cec/usb/Kconfig                 |    1 +
 drivers/media/cec/usb/Makefile                |    1 +
 .../cec/usb/extron-da-hd-4k-plus/Kconfig      |   14 +
 .../cec/usb/extron-da-hd-4k-plus/Makefile     |    8 +
 .../usb/extron-da-hd-4k-plus/cec-splitter.c   |  657 ++++++
 .../usb/extron-da-hd-4k-plus/cec-splitter.h   |   51 +
 .../extron-da-hd-4k-plus.c                    | 1836 +++++++++++++++++
 .../extron-da-hd-4k-plus.h                    |  118 ++
 10 files changed, 2780 insertions(+)
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/Kconfig
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/Makefile
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/cec-splitter.c
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/cec-splitter.h
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c
 create mode 100644 drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.h
Documentation/admin-guide/media/cec.rst +87 -0
index 6b30e355cf23..92690e1f2183 100644
@@ -42,10 +42,14 @@ dongles):
   ``persistent_config``: by default this is off, but when set to 1 the driver
   will store the current settings to the device's internal eeprom and restore
   it the next time the device is connected to the USB port.
+
 - RainShadow Tech. Note: this driver does not support the persistent_config
   module option of the Pulse-Eight driver. The hardware supports it, but I
   have no plans to add this feature. But I accept patches :-)
 
+- Extron DA HD 4K PLUS HDMI Distribution Amplifier. See
+  :ref:`extron_da_hd_4k_plus` for more information.
+
 Miscellaneous:
 
 - vivid: emulates a CEC receiver and CEC transmitter.
@@ -378,3 +382,86 @@ it later using ``--analyze-pin``.
 
 You can also use this as a full-fledged CEC device by configuring it
 using ``cec-ctl --tv -p0.0.0.0`` or ``cec-ctl --playback -p1.0.0.0``.
+
+.. _extron_da_hd_4k_plus:
+
+Extron DA HD 4K PLUS CEC Adapter driver
+=======================================
+
+This driver is for the Extron DA HD 4K PLUS series of HDMI Distribution
+Amplifiers: https://www.extron.com/product/dahd4kplusseries
+
+The 2, 4 and 6 port models are supported.
+
+Firmware version 1.02.0001 or higher is required.
+
+Note that older Extron hardware revisions have a problem with the CEC voltage,
+which may mean that CEC will not work. This is fixed in hardware revisions
+E34814 and up.
+
+The CEC support has two modes: the first is a manual mode where userspace has
+to manually control CEC for the HDMI Input and all HDMI Outputs. While this gives
+full control, it is also complicated.
+
+The second mode is an automatic mode, which is selected if the module option
+``vendor_id`` is set. In that case the driver controls CEC and CEC messages
+received in the input will be distributed to the outputs. It is still possible
+to use the /dev/cecX devices to talk to the connected devices directly, but it is
+the driver that configures everything and deals with things like Hotplug Detect
+changes.
+
+The driver also takes care of the EDIDs: /dev/videoX devices are created to
+read the EDIDs and (for the HDMI Input port) to set the EDID.
+
+By default userspace is responsible to set the EDID for the HDMI Input
+according to the EDIDs of the connected displays. But if the ``manufacturer_name``
+module option is set, then the driver will take care of setting the EDID
+of the HDMI Input based on the supported resolutions of the connected displays.
+Currently the driver only supports resolutions 1080p60 and 4kp60: if all connected
+displays support 4kp60, then it will advertise 4kp60 on the HDMI input, otherwise
+it will fall back to an EDID that just reports 1080p60.
+
+The status of the Extron is reported in ``/sys/kernel/debug/cec/cecX/status``.
+
+The extron-da-hd-4k-plus driver implements the following module options:
+
+``debug``
+---------
+
+If set to 1, then all serial port traffic is shown.
+
+``vendor_id``
+-------------
+
+The CEC Vendor ID to report to connected displays.
+
+If set, then the driver will take care of distributing CEC messages received
+on the input to the HDMI outputs. This is done for the following CEC messages:
+
+- <Standby>
+- <Image View On> and <Text View On>
+- <Give Device Power Status>
+- <Set System Audio Mode>
+- <Request Current Latency>
+
+If not set, then userspace is responsible for this, and it will have to
+configure the CEC devices for HDMI Input and the HDMI Outputs manually.
+
+``manufacturer_name``
+---------------------
+
+A three character manufacturer name that is used in the EDID for the HDMI
+Input. If not set, then userspace is reponsible for configuring an EDID.
+If set, then the driver will update the EDID automatically based on the
+resolutions supported by the connected displays, and it will not be possible
+anymore to manually set the EDID for the HDMI Input.
+
+``hpd_never_low``
+-----------------
+
+If set, then the Hotplug Detect pin of the HDMI Input will always be high,
+even if nothing is connected to the HDMI Outputs. If not set (the default)
+then the Hotplug Detect pin of the HDMI input will go low if all the detected
+Hotplug Detect pins of the HDMI Outputs are also low.
+
+This option may be changed dynamically.
MAINTAINERS +7 -0
index 8766f3e5e87e..4f16b0a3a0f9 100644
@@ -8461,6 +8461,13 @@ F:	lib/bootconfig.c
 F:	tools/bootconfig/*
 F:	tools/bootconfig/scripts/*
 
+EXTRON DA HD 4K PLUS CEC DRIVER
+M:	Hans Verkuil <[email protected]>
+L:	[email protected]
+S:	Maintained
+T:	git git://linuxtv.org/media_tree.git
+F:	drivers/media/cec/usb/extron-da-hd-4k-plus/
+
 EXYNOS DP DRIVER
 M:	Jingoo Han <[email protected]>
 L:	[email protected]
drivers/media/cec/usb/Kconfig +1 -0
index 3f3a5c75287a..6faf4742981d 100644
@@ -3,6 +3,7 @@
 # USB drivers
 
 if USB_SUPPORT && TTY
+source "drivers/media/cec/usb/extron-da-hd-4k-plus/Kconfig"
 source "drivers/media/cec/usb/pulse8/Kconfig"
 source "drivers/media/cec/usb/rainshadow/Kconfig"
 endif
drivers/media/cec/usb/Makefile +1 -0
index e4183d1bfa9a..c082679f5318 100644
@@ -2,5 +2,6 @@
 #
 # Makefile for the CEC USB device drivers.
 #
+obj-$(CONFIG_USB_EXTRON_DA_HD_4K_PLUS_CEC) += extron-da-hd-4k-plus/
 obj-$(CONFIG_USB_PULSE8_CEC) += pulse8/
 obj-$(CONFIG_USB_RAINSHADOW_CEC) += rainshadow/
drivers/media/cec/usb/extron-da-hd-4k-plus/Kconfig new file +14 -0
new file mode 100644
index 000000000000..5354f0eebe5c
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config USB_EXTRON_DA_HD_4K_PLUS_CEC
+	tristate "Extron DA HD 4K Plus CEC driver"
+	depends on VIDEO_DEV
+	depends on USB
+	depends on USB_ACM
+	select CEC_CORE
+	select SERIO
+	select SERIO_SERPORT
+	help
+	  This is a CEC driver for the Extron DA HD 4K Plus HDMI Splitter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called extron-da-hd-4k-plus-cec.
drivers/media/cec/usb/extron-da-hd-4k-plus/Makefile new file +8 -0
new file mode 100644
index 000000000000..2e8f7f60263f
@@ -0,0 +1,8 @@
+extron-da-hd-4k-plus-cec-objs := extron-da-hd-4k-plus.o cec-splitter.o
+obj-$(CONFIG_USB_EXTRON_DA_HD_4K_PLUS_CEC) := extron-da-hd-4k-plus-cec.o
+
+all:
+	$(MAKE) -C $(KDIR) M=$(shell pwd) modules
+
+install:
+	$(MAKE) -C $(KDIR) M=$(shell pwd) modules_install
drivers/media/cec/usb/extron-da-hd-4k-plus/cec-splitter.c new file +657 -0

657 lines not on this page · raw message

drivers/media/cec/usb/extron-da-hd-4k-plus/cec-splitter.h new file +51 -0

51 lines not on this page · raw message

drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.c new file +1836 -0

1,836 lines not on this page · raw message

drivers/media/cec/usb/extron-da-hd-4k-plus/extron-da-hd-4k-plus.h new file +118 -0

118 lines not on this page · raw message

Signature · 1 line
2.43.0