Skip to content

Commit 71c296f

Browse files
Hans Verkuildtor
authored andcommitted
Input: synaptics-rmi4 - fix various V4L2 compliance problems in F54
The v4l2-compliance utility reported several V4L2 API compliance issues: - the sequence counter wasn't filled in - the sequence counter wasn't reset to 0 at the start of streaming - the returned field value wasn't set to V4L2_FIELD_NONE - the timestamp wasn't set - the payload size was undefined if an error was returned - min_buffers_needed doesn't need to be initialized Fix these issues. Signed-off-by: Hans Verkuil <[email protected]> Reviewed-by: Lucas Stach <[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent fc1156f commit 71c296f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/input/rmi4/rmi_f54.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct f54_data {
110110
struct video_device vdev;
111111
struct vb2_queue queue;
112112
struct mutex lock;
113+
u32 sequence;
113114
int input;
114115
enum rmi_f54_report_type inputs[F54_MAX_REPORT_TYPE];
115116
};
@@ -284,6 +285,7 @@ static int rmi_f54_queue_setup(struct vb2_queue *q, unsigned int *nbuffers,
284285

285286
static void rmi_f54_buffer_queue(struct vb2_buffer *vb)
286287
{
288+
struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
287289
struct f54_data *f54 = vb2_get_drv_priv(vb->vb2_queue);
288290
u16 *ptr;
289291
enum vb2_buffer_state state;
@@ -292,6 +294,7 @@ static void rmi_f54_buffer_queue(struct vb2_buffer *vb)
292294

293295
mutex_lock(&f54->status_mutex);
294296

297+
vb2_set_plane_payload(vb, 0, 0);
295298
reptype = rmi_f54_get_reptype(f54, f54->input);
296299
if (reptype == F54_REPORT_NONE) {
297300
state = VB2_BUF_STATE_ERROR;
@@ -338,14 +341,25 @@ static void rmi_f54_buffer_queue(struct vb2_buffer *vb)
338341
data_done:
339342
mutex_unlock(&f54->data_mutex);
340343
done:
344+
vb->timestamp = ktime_get_ns();
345+
vbuf->field = V4L2_FIELD_NONE;
346+
vbuf->sequence = f54->sequence++;
341347
vb2_buffer_done(vb, state);
342348
mutex_unlock(&f54->status_mutex);
343349
}
344350

351+
static void rmi_f54_stop_streaming(struct vb2_queue *q)
352+
{
353+
struct f54_data *f54 = vb2_get_drv_priv(q);
354+
355+
f54->sequence = 0;
356+
}
357+
345358
/* V4L2 structures */
346359
static const struct vb2_ops rmi_f54_queue_ops = {
347360
.queue_setup = rmi_f54_queue_setup,
348361
.buf_queue = rmi_f54_buffer_queue,
362+
.stop_streaming = rmi_f54_stop_streaming,
349363
.wait_prepare = vb2_ops_wait_prepare,
350364
.wait_finish = vb2_ops_wait_finish,
351365
};
@@ -357,7 +371,6 @@ static const struct vb2_queue rmi_f54_queue = {
357371
.ops = &rmi_f54_queue_ops,
358372
.mem_ops = &vb2_vmalloc_memops,
359373
.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC,
360-
.min_buffers_needed = 1,
361374
};
362375

363376
static int rmi_f54_vidioc_querycap(struct file *file, void *priv,

0 commit comments

Comments
 (0)