From: Hans Verkuil <hverkuil-cisco@xxxxxxxxx> When queueing a buffer to a request the 'field' value is not validated. That field is only validated when the _buf_prepare() is called, which happens when the request is queued. However, this validation should happen at QBUF time, since you want to know about this as soon as possible. Also, the spec requires that the 'field' value is validated at QBUF time. This patch adds a new buf_out_validate callback to validate the output buffer at buf_prepare time or when QBUF queues an unprepared buffer to a request. This callback is mandatory for output queues that support requests. This issue was found by v4l2-compliance since it failed to replace V4L2_FIELD_ANY by a proper field value when testing the vivid video output in combination with requests. This patch series adds a new buf_out_validate callback and implements it for the three drivers that support requests for output queues: vivid, vim2m and cedrus. The final patch adds a check that this new callback is implemented for output queues supporting requests since it is easy to forget. Regards, Hans Changes since v3: - Implement the callback for the cedrus driver, add check that the callback is implemented when it is required. - Previous versions claimed that there was also a problem when requests are not in use, but that turned out to be wrong. This is request specific. - Call the new callback as well when preparing a buffer. - When calling it from qbuf, only call it when queueing an unprepared buffer to a request. This is the actual fix. Changes since v2: - drop test whether the queue is an output queue. This callback is only called for output queues, so this test is not needed anymore. 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 (5): vb2: add buf_out_validate callback vim2m: add buf_out_validate callback vivid: add buf_out_validate callback cedrus: add buf_out_validate callback vb2: check that buf_out_validate is present .../media/common/videobuf2/videobuf2-core.c | 22 ++++++++++++--- .../media/common/videobuf2/videobuf2-v4l2.c | 7 +++++ drivers/media/platform/vim2m.c | 27 +++++++++++-------- drivers/media/platform/vivid/vivid-vid-out.c | 23 +++++++++++----- .../staging/media/sunxi/cedrus/cedrus_video.c | 9 +++++++ include/media/videobuf2-core.h | 5 ++++ 6 files changed, 72 insertions(+), 21 deletions(-) -- 2.20.1