diff options
| author | Kamil Debski <k.debski@samsung.com> | 2015-02-23 07:26:17 -0500 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-04-10 08:46:07 -0400 |
| commit | f61bf13b6a07a93b9348e77808d369803f40b681 (patch) | |
| tree | 44ab9d2d33ff1c70cc3d5798a70a913b342737e6 /drivers/media | |
| parent | 06e7a9b638467fddf8f62ca9f07adc7754319461 (diff) | |
[media] vb2: add allow_zero_bytesused flag to the vb2_queue struct
The vb2: fix bytesused == 0 handling (8a75ffb) patch changed the behavior
of __fill_vb2_buffer function, so that if bytesused is 0 it is set to the
size of the buffer. However, bytesused set to 0 is used by older codec
drivers as as indication used to mark the end of stream.
To keep backward compatibility, this patch adds a flag passed to the
vb2_queue_init function - allow_zero_bytesused. If the flag is set upon
initialization of the queue, the videobuf2 keeps the value of bytesused
intact in the OUTPUT queue and passes it to the driver.
Reported-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Signed-off-by: Kamil Debski <k.debski@samsung.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
| -rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 8bc2a6e8623d..1329dccfa072 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
| @@ -1247,6 +1247,16 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b | |||
| 1247 | { | 1247 | { |
| 1248 | unsigned int plane; | 1248 | unsigned int plane; |
| 1249 | 1249 | ||
| 1250 | if (V4L2_TYPE_IS_OUTPUT(b->type)) { | ||
| 1251 | if (WARN_ON_ONCE(b->bytesused == 0)) { | ||
| 1252 | pr_warn_once("use of bytesused == 0 is deprecated and will be removed in the future,\n"); | ||
| 1253 | if (vb->vb2_queue->allow_zero_bytesused) | ||
| 1254 | pr_warn_once("use VIDIOC_DECODER_CMD(V4L2_DEC_CMD_STOP) instead.\n"); | ||
| 1255 | else | ||
| 1256 | pr_warn_once("use the actual size instead.\n"); | ||
| 1257 | } | ||
| 1258 | } | ||
| 1259 | |||
| 1250 | if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { | 1260 | if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { |
| 1251 | if (b->memory == V4L2_MEMORY_USERPTR) { | 1261 | if (b->memory == V4L2_MEMORY_USERPTR) { |
| 1252 | for (plane = 0; plane < vb->num_planes; ++plane) { | 1262 | for (plane = 0; plane < vb->num_planes; ++plane) { |
| @@ -1276,13 +1286,22 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b | |||
| 1276 | * userspace clearly never bothered to set it and | 1286 | * userspace clearly never bothered to set it and |
| 1277 | * it's a safe assumption that they really meant to | 1287 | * it's a safe assumption that they really meant to |
| 1278 | * use the full plane sizes. | 1288 | * use the full plane sizes. |
| 1289 | * | ||
| 1290 | * Some drivers, e.g. old codec drivers, use bytesused == 0 | ||
| 1291 | * as a way to indicate that streaming is finished. | ||
| 1292 | * In that case, the driver should use the | ||
| 1293 | * allow_zero_bytesused flag to keep old userspace | ||
| 1294 | * applications working. | ||
| 1279 | */ | 1295 | */ |
| 1280 | for (plane = 0; plane < vb->num_planes; ++plane) { | 1296 | for (plane = 0; plane < vb->num_planes; ++plane) { |
| 1281 | struct v4l2_plane *pdst = &v4l2_planes[plane]; | 1297 | struct v4l2_plane *pdst = &v4l2_planes[plane]; |
| 1282 | struct v4l2_plane *psrc = &b->m.planes[plane]; | 1298 | struct v4l2_plane *psrc = &b->m.planes[plane]; |
| 1283 | 1299 | ||
| 1284 | pdst->bytesused = psrc->bytesused ? | 1300 | if (vb->vb2_queue->allow_zero_bytesused) |
| 1285 | psrc->bytesused : pdst->length; | 1301 | pdst->bytesused = psrc->bytesused; |
| 1302 | else | ||
| 1303 | pdst->bytesused = psrc->bytesused ? | ||
| 1304 | psrc->bytesused : pdst->length; | ||
| 1286 | pdst->data_offset = psrc->data_offset; | 1305 | pdst->data_offset = psrc->data_offset; |
| 1287 | } | 1306 | } |
| 1288 | } | 1307 | } |
| @@ -1295,6 +1314,11 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b | |||
| 1295 | * | 1314 | * |
| 1296 | * If bytesused == 0 for the output buffer, then fall back | 1315 | * If bytesused == 0 for the output buffer, then fall back |
| 1297 | * to the full buffer size as that's a sensible default. | 1316 | * to the full buffer size as that's a sensible default. |
| 1317 | * | ||
| 1318 | * Some drivers, e.g. old codec drivers, use bytesused == 0 as | ||
| 1319 | * a way to indicate that streaming is finished. In that case, | ||
| 1320 | * the driver should use the allow_zero_bytesused flag to keep | ||
| 1321 | * old userspace applications working. | ||
| 1298 | */ | 1322 | */ |
| 1299 | if (b->memory == V4L2_MEMORY_USERPTR) { | 1323 | if (b->memory == V4L2_MEMORY_USERPTR) { |
| 1300 | v4l2_planes[0].m.userptr = b->m.userptr; | 1324 | v4l2_planes[0].m.userptr = b->m.userptr; |
| @@ -1306,10 +1330,13 @@ static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b | |||
| 1306 | v4l2_planes[0].length = b->length; | 1330 | v4l2_planes[0].length = b->length; |
| 1307 | } | 1331 | } |
| 1308 | 1332 | ||
| 1309 | if (V4L2_TYPE_IS_OUTPUT(b->type)) | 1333 | if (V4L2_TYPE_IS_OUTPUT(b->type)) { |
| 1310 | v4l2_planes[0].bytesused = b->bytesused ? | 1334 | if (vb->vb2_queue->allow_zero_bytesused) |
| 1311 | b->bytesused : v4l2_planes[0].length; | 1335 | v4l2_planes[0].bytesused = b->bytesused; |
| 1312 | else | 1336 | else |
| 1337 | v4l2_planes[0].bytesused = b->bytesused ? | ||
| 1338 | b->bytesused : v4l2_planes[0].length; | ||
| 1339 | } else | ||
| 1313 | v4l2_planes[0].bytesused = 0; | 1340 | v4l2_planes[0].bytesused = 0; |
| 1314 | 1341 | ||
| 1315 | } | 1342 | } |
