Fix some issues found with v4l2-compliance. Tested in Soraka which also
has some subdevices that had some issues with v4l2-compliance.
Ricardo Ribalda (7):
media: ipu3-cio2: Check num_planes and sizes in queue_setup
media: ipu3-cio2: Set valid initial format
media: ipu3-cio2: imgu_fmt: Handle properly try
media: ipu3-cio2: VIDIOC_QUERYCAP: Fix bus_info
media: dw9714: Add implementation for events
media: ov13858: Add implementation for events
media: ov5670: Add implementation for events
drivers/media/i2c/dw9714.c | 14 ++++++++++++--
drivers/media/i2c/ov13858.c | 11 ++++++++++-
drivers/media/i2c/ov5670.c | 11 ++++++++++-
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 8 ++++++--
drivers/staging/media/ipu3/ipu3-v4l2.c | 9 +++++----
5 files changed, 43 insertions(+), 10 deletions(-)
--
2.33.0.685.g46640cef36-goog
Use v4l2 control API helpers to support the events.
Fixes v4l2-compliance:
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/i2c/dw9714.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c
index c8b4292512dca..3863dfeb82934 100644
--- a/drivers/media/i2c/dw9714.c
+++ b/drivers/media/i2c/dw9714.c
@@ -7,6 +7,7 @@
#include <linux/pm_runtime.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
#define DW9714_NAME "dw9714"
#define DW9714_MAX_FOCUS_POS 1023
@@ -100,7 +101,15 @@ static const struct v4l2_subdev_internal_ops dw9714_int_ops = {
.close = dw9714_close,
};
-static const struct v4l2_subdev_ops dw9714_ops = { };
+static const struct v4l2_subdev_core_ops dw9714_core_ops = {
+ .log_status = v4l2_ctrl_subdev_log_status,
+ .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+ .unsubscribe_event = v4l2_event_subdev_unsubscribe,
+};
+
+static const struct v4l2_subdev_ops dw9714_ops = {
+ .core = &dw9714_core_ops,
+};
static void dw9714_subdev_cleanup(struct dw9714_device *dw9714_dev)
{
@@ -137,7 +146,8 @@ static int dw9714_probe(struct i2c_client *client)
return -ENOMEM;
v4l2_i2c_subdev_init(&dw9714_dev->sd, client, &dw9714_ops);
- dw9714_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ dw9714_dev->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
+ V4L2_SUBDEV_FL_HAS_EVENTS;
dw9714_dev->sd.internal_ops = &dw9714_int_ops;
rval = dw9714_init_controls(dw9714_dev);
--
2.33.0.685.g46640cef36-goog
If num_planes is different than zero num_planes and sizes must be
checked to support the format.
Fix the following v4l2-compliance error:
Buffer ioctls (Input 0):
fail: v4l2-test-buffers.cpp(717): q.create_bufs(node, 1, &fmt) != EINVAL
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index 47db0ee0fcbfa..36099e95d29f2 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -798,13 +798,17 @@ static int cio2_vb2_queue_setup(struct vb2_queue *vq,
struct cio2_queue *q = vb2q_to_cio2_queue(vq);
unsigned int i;
- *num_planes = q->format.num_planes;
+ if (*num_planes && *num_planes < q->format.num_planes)
+ return -EINVAL;
- for (i = 0; i < *num_planes; ++i) {
+ for (i = 0; i < q->format.num_planes; ++i) {
+ if (*num_planes && sizes[i] < q->format.plane_fmt[i].sizeimage)
+ return -EINVAL;
sizes[i] = q->format.plane_fmt[i].sizeimage;
alloc_devs[i] = &cio2->pci_dev->dev;
}
+ *num_planes = q->format.num_planes;
*num_buffers = clamp_val(*num_buffers, 1, CIO2_MAX_BUFFERS);
/* Initialize buffer queue */
--
2.33.0.685.g46640cef36-goog
The initial format did not have a valid size.
Fixes v4l2-compliance:
fail: v4l2-test-formats.cpp(723): Video Output Multiplanar:
TRY_FMT(G_FMT) != G_FMT
test VIDIOC_TRY_FMT: FAIL
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 38a2407645096..fbb9eb2ba99e4 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -1136,7 +1136,7 @@ static int imgu_v4l2_node_setup(struct imgu_device *imgu, unsigned int pipe,
def_pix_fmt.height = def_bus_fmt.height;
def_pix_fmt.field = def_bus_fmt.field;
def_pix_fmt.num_planes = 1;
- def_pix_fmt.plane_fmt[0].bytesperline = def_pix_fmt.width * 2;
+ def_pix_fmt.plane_fmt[0].bytesperline = 2496;
def_pix_fmt.plane_fmt[0].sizeimage =
def_pix_fmt.height * def_pix_fmt.plane_fmt[0].bytesperline;
def_pix_fmt.flags = 0;
--
2.33.0.685.g46640cef36-goog
For a try_fmt call, the node noes not need to be enabled.
Fixes v4l2-compliance
fail: v4l2-test-formats.cpp(717): Video Output Multiplanar is valid, but
no TRY_FMT was implemented
test VIDIOC_TRY_FMT: FAIL
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index fbb9eb2ba99e4..66995c6f15808 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -696,7 +696,7 @@ static int imgu_fmt(struct imgu_device *imgu, unsigned int pipe, int node,
/* CSS expects some format on OUT queue */
if (i != IPU3_CSS_QUEUE_OUT &&
- !imgu_pipe->nodes[inode].enabled) {
+ !imgu_pipe->nodes[inode].enabled && !try) {
fmts[i] = NULL;
continue;
}
--
2.33.0.685.g46640cef36-goog
Use v4l2 control API helpers to support the events.
Fixes v4l2-compliance:
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/i2c/ov5670.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index 49189926afd67..251f459ab484a 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -7,6 +7,7 @@
#include <linux/pm_runtime.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#define OV5670_REG_CHIP_ID 0x300a
@@ -2420,6 +2421,12 @@ static int ov5670_identify_module(struct ov5670 *ov5670)
return 0;
}
+static const struct v4l2_subdev_core_ops ov5670_core_ops = {
+ .log_status = v4l2_ctrl_subdev_log_status,
+ .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+ .unsubscribe_event = v4l2_event_subdev_unsubscribe,
+};
+
static const struct v4l2_subdev_video_ops ov5670_video_ops = {
.s_stream = ov5670_set_stream,
};
@@ -2436,6 +2443,7 @@ static const struct v4l2_subdev_sensor_ops ov5670_sensor_ops = {
};
static const struct v4l2_subdev_ops ov5670_subdev_ops = {
+ .core = &ov5670_core_ops,
.video = &ov5670_video_ops,
.pad = &ov5670_pad_ops,
.sensor = &ov5670_sensor_ops,
@@ -2489,7 +2497,8 @@ static int ov5670_probe(struct i2c_client *client)
}
ov5670->sd.internal_ops = &ov5670_internal_ops;
- ov5670->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ ov5670->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
+ V4L2_SUBDEV_FL_HAS_EVENTS;
ov5670->sd.entity.ops = &ov5670_subdev_entity_ops;
ov5670->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
--
2.33.0.685.g46640cef36-goog
Use v4l2 control API helpers to support the events.
Fixes v4l2-compliance:
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/media/i2c/ov13858.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c
index 7fc70af53e45d..b4d22f5d99337 100644
--- a/drivers/media/i2c/ov13858.c
+++ b/drivers/media/i2c/ov13858.c
@@ -7,6 +7,7 @@
#include <linux/pm_runtime.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>
+#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#define OV13858_REG_VALUE_08BIT 1
@@ -1553,6 +1554,12 @@ static int ov13858_identify_module(struct ov13858 *ov13858)
return 0;
}
+static const struct v4l2_subdev_core_ops ov13858_core_ops = {
+ .log_status = v4l2_ctrl_subdev_log_status,
+ .subscribe_event = v4l2_ctrl_subdev_subscribe_event,
+ .unsubscribe_event = v4l2_event_subdev_unsubscribe,
+};
+
static const struct v4l2_subdev_video_ops ov13858_video_ops = {
.s_stream = ov13858_set_stream,
};
@@ -1569,6 +1576,7 @@ static const struct v4l2_subdev_sensor_ops ov13858_sensor_ops = {
};
static const struct v4l2_subdev_ops ov13858_subdev_ops = {
+ .core = &ov13858_core_ops,
.video = &ov13858_video_ops,
.pad = &ov13858_pad_ops,
.sensor = &ov13858_sensor_ops,
@@ -1724,7 +1732,8 @@ static int ov13858_probe(struct i2c_client *client,
/* Initialize subdev */
ov13858->sd.internal_ops = &ov13858_internal_ops;
- ov13858->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
+ ov13858->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
+ V4L2_SUBDEV_FL_HAS_EVENTS;
ov13858->sd.entity.ops = &ov13858_subdev_entity_ops;
ov13858->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
--
2.33.0.685.g46640cef36-goog
bus_info field had a different value for the media entity and the video
device.
Fixes v4l2-compliance:
v4l2-compliance.cpp(637): media bus_info 'PCI:0000:00:05.0' differs from
V4L2 bus_info 'PCI:viewfinder'
Signed-off-by: Ricardo Ribalda <[email protected]>
---
drivers/staging/media/ipu3/ipu3-v4l2.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
index 66995c6f15808..2594ac4eb0763 100644
--- a/drivers/staging/media/ipu3/ipu3-v4l2.c
+++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
@@ -592,11 +592,12 @@ static const struct imgu_fmt *find_format(struct v4l2_format *f, u32 type)
static int imgu_vidioc_querycap(struct file *file, void *fh,
struct v4l2_capability *cap)
{
- struct imgu_video_device *node = file_to_intel_imgu_node(file);
+ struct imgu_device *imgu = video_drvdata(file);
strscpy(cap->driver, IMGU_NAME, sizeof(cap->driver));
strscpy(cap->card, IMGU_NAME, sizeof(cap->card));
- snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", node->name);
+ snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
+ pci_name(imgu->pci_dev));
return 0;
}
--
2.33.0.685.g46640cef36-goog
Ricardo, thanks for your patch.
On 9/29/21 5:10 AM, Ricardo Ribalda wrote:
> Fix some issues found with v4l2-compliance. Tested in Soraka which also
> has some subdevices that had some issues with v4l2-compliance.
>
> Ricardo Ribalda (7):
...
> media: ipu3-cio2: Set valid initial format
> media: ipu3-cio2: imgu_fmt: Handle properly try
> media: ipu3-cio2: VIDIOC_QUERYCAP: Fix bus_info
These 3 should be staging ImgU category, not cio2 :).
> media: dw9714: Add implementation for events
> media: ov13858: Add implementation for events
> media: ov5670: Add implementation for events
>
> drivers/media/i2c/dw9714.c | 14 ++++++++++++--
> drivers/media/i2c/ov13858.c | 11 ++++++++++-
> drivers/media/i2c/ov5670.c | 11 ++++++++++-
> drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 8 ++++++--
> drivers/staging/media/ipu3/ipu3-v4l2.c | 9 +++++----
> 5 files changed, 43 insertions(+), 10 deletions(-)
>
--
Best regards,
Bingbu Cao
Ricardo, thanks for your patch.
Reviewed-by: Bingbu Cao <[email protected]>
On 9/29/21 5:10 AM, Ricardo Ribalda wrote:
> if (*num_planes && sizes[i] < q->format.plane_fmt[i].sizeimage)
--
Best regards,
Bingbu Cao
Besides the subject,
Reviewed-by: Bingbu Cao <[email protected]>
On 9/29/21 5:10 AM, Ricardo Ribalda wrote:
> bus_info field had a different value for the media entity and the video
> device.
>
> Fixes v4l2-compliance:
>
> v4l2-compliance.cpp(637): media bus_info 'PCI:0000:00:05.0' differs from
> V4L2 bus_info 'PCI:viewfinder'
>
> Signed-off-by: Ricardo Ribalda <[email protected]>
> ---
> drivers/staging/media/ipu3/ipu3-v4l2.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
> index 66995c6f15808..2594ac4eb0763 100644
> --- a/drivers/staging/media/ipu3/ipu3-v4l2.c
> +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
> @@ -592,11 +592,12 @@ static const struct imgu_fmt *find_format(struct v4l2_format *f, u32 type)
> static int imgu_vidioc_querycap(struct file *file, void *fh,
> struct v4l2_capability *cap)
> {
> - struct imgu_video_device *node = file_to_intel_imgu_node(file);
> + struct imgu_device *imgu = video_drvdata(file);
>
> strscpy(cap->driver, IMGU_NAME, sizeof(cap->driver));
> strscpy(cap->card, IMGU_NAME, sizeof(cap->card));
> - snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", node->name);
> + snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s",
> + pci_name(imgu->pci_dev));
>
> return 0;
> }
>
--
Best regards,
Bingbu Cao
Hi Ricardo,
On Tue, Sep 28, 2021 at 09:10:28PM +0000, Ricardo Ribalda wrote:
> The initial format did not have a valid size.
>
> Fixes v4l2-compliance:
>
> fail: v4l2-test-formats.cpp(723): Video Output Multiplanar:
> TRY_FMT(G_FMT) != G_FMT
> test VIDIOC_TRY_FMT: FAIL
>
> Signed-off-by: Ricardo Ribalda <[email protected]>
> ---
> drivers/staging/media/ipu3/ipu3-v4l2.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/ipu3/ipu3-v4l2.c b/drivers/staging/media/ipu3/ipu3-v4l2.c
> index 38a2407645096..fbb9eb2ba99e4 100644
> --- a/drivers/staging/media/ipu3/ipu3-v4l2.c
> +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c
> @@ -1136,7 +1136,7 @@ static int imgu_v4l2_node_setup(struct imgu_device *imgu, unsigned int pipe,
> def_pix_fmt.height = def_bus_fmt.height;
> def_pix_fmt.field = def_bus_fmt.field;
> def_pix_fmt.num_planes = 1;
> - def_pix_fmt.plane_fmt[0].bytesperline = def_pix_fmt.width * 2;
> + def_pix_fmt.plane_fmt[0].bytesperline = 2496;
Please derive the value from the width, don't use a number here.
--
Regards,
Sakari Ailus