linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 0/3] vb2: add buf_out_validate callback
@ 2019-01-07 13:04 hverkuil-cisco
  2019-01-07 13:04 ` [PATCHv2 1/3] " hverkuil-cisco
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: hverkuil-cisco @ 2019-01-07 13:04 UTC (permalink / raw)
  To: linux-media; +Cc: Sakari Ailus

From: Hans Verkuil <hverkuil-cisco@xs4all.nl>

Adding the request API uncovered a pre-existing problem with
validating output buffers.

The problem is that for output buffers the driver has to validate
the 'field' field of struct v4l2_buffer. This is critical when
encoding or deinterlacing interlaced video.

Drivers always did this in the buf_prepare callback, but that is
not called from VIDIOC_QBUF in two situations: when queueing a
buffer to a request and if VIDIOC_PREPARE_BUF has been called
earlier for that buffer.

As a result of this the 'field' value is not validated.

While the first case (queueing a buffer to a request) is request
API specific, the second case (VIDIOC_PREPARE_BUF has been called
earlier for that buffer) was always wrong.

This patch series adds a new buf_out_validate callback to validate
the output buffer at QBUF time.

Note that PREPARE_BUF doesn't need to validate the field: it just
locks the buffer memory and doesn't need nor want to know about
how this buffer is actually going to be used. It's the QBUF ioctl
that determines this.

This issue was found by v4l2-compliance since vivid failed to replace
V4L2_FIELD_ANY by a proper field value when testing the vivid video
output in combination with requests.

There never was a test before for the PREPARE_BUF/QBUF case, so even
though this bug has been present for quite some time, it was never
noticed. This test has now been added to v4l2-compliance as well.

Regards,

	Hans

Changes since v1:

- Renamed buf_validate to buf_out_validate since this is output
  specific.
- Clarify in the commit log of the first patch that this isn't
  request API specific, but fixes a long standing problem that
  just wasn't noticed until now.

Hans Verkuil (3):
  vb2: add buf_out_validate callback
  vim2m: add buf_out_validate callback
  vivid: add buf_out_validate callback

 .../media/common/videobuf2/videobuf2-core.c   | 14 ++++++++---
 drivers/media/platform/vim2m.c                | 16 ++++++++++---
 drivers/media/platform/vivid/vivid-vid-out.c  | 23 +++++++++++++------
 include/media/videobuf2-core.h                |  5 ++++
 4 files changed, 45 insertions(+), 13 deletions(-)

-- 
2.19.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-01-11 12:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 13:04 [PATCHv2 0/3] vb2: add buf_out_validate callback hverkuil-cisco
2019-01-07 13:04 ` [PATCHv2 1/3] " hverkuil-cisco
2019-01-07 13:04 ` [PATCHv2 2/3] vim2m: " hverkuil-cisco
2019-01-11 12:23   ` [PATCHv3 " Hans Verkuil
2019-01-07 13:04 ` [PATCHv2 3/3] vivid: " hverkuil-cisco

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).