diff mbox series

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

Message ID f88991fc4c197ef0e32f05b2f509980183aef012.1723190258.git.hverkuil-cisco@xs4all.nl
State New
Headers show
Series media: cec: add support for the Extron DA HD 4K Plus HDMI Splitter | expand

Commit Message

Hans Verkuil Aug. 9, 2024, 7:57 a.m. UTC
From: Erling Ljunggren <hljunggr@cisco.com>

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

Signed-off-by: Erling Ljunggren <hljunggr@cisco.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/v4l2-core/v4l2-dev.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Ricardo Ribalda Delgado Aug. 29, 2024, 7:27 a.m. UTC | #1
On Wed, Aug 28, 2024 at 2:38 PM Sebastian Fricke
<sebastian.fricke@collabora.com> wrote:
>
> Hello,
>
> On 09.08.2024 09:57, Hans Verkuil wrote:
> >From: Erling Ljunggren <hljunggr@cisco.com>
> >
> >When the V4L2_CAP_EDID capability flag is set,
> >ioctls for enum inputs/outputs and get/set edid are automatically set.
> >
> >Signed-off-by: Erling Ljunggren <hljunggr@cisco.com>
> >Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
>
> Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
>
> Regards,
> Sebastian
> >---
> > drivers/media/v4l2-core/v4l2-dev.c | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
> >
> >diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
> >index be2ba7ca5de2..570ba00e00b3 100644
> >--- a/drivers/media/v4l2-core/v4l2-dev.c
> >+++ b/drivers/media/v4l2-core/v4l2-dev.c
> >@@ -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
> >
> >
>
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index be2ba7ca5de2..570ba00e00b3 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -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);