diff options
-rw-r--r-- | drivers/media/v4l2-core/videobuf2-core.c | 133 |
1 files changed, 65 insertions, 68 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 2e96f3535e2c..58b97023ae6f 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c | |||
@@ -27,10 +27,10 @@ | |||
27 | static int debug; | 27 | static int debug; |
28 | module_param(debug, int, 0644); | 28 | module_param(debug, int, 0644); |
29 | 29 | ||
30 | #define dprintk(level, fmt, arg...) \ | 30 | #define dprintk(level, fmt, arg...) \ |
31 | do { \ | 31 | do { \ |
32 | if (debug >= level) \ | 32 | if (debug >= level) \ |
33 | printk(KERN_DEBUG "vb2: " fmt, ## arg); \ | 33 | pr_debug("vb2: %s: " fmt, __func__, ## arg); \ |
34 | } while (0) | 34 | } while (0) |
35 | 35 | ||
36 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 36 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
@@ -444,7 +444,7 @@ static int __vb2_queue_free(struct vb2_queue *q, unsigned int buffers) | |||
444 | if (q->bufs[buffer] == NULL) | 444 | if (q->bufs[buffer] == NULL) |
445 | continue; | 445 | continue; |
446 | if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) { | 446 | if (q->bufs[buffer]->state == VB2_BUF_STATE_PREPARING) { |
447 | dprintk(1, "reqbufs: preparing buffers, cannot free\n"); | 447 | dprintk(1, "preparing buffers, cannot free\n"); |
448 | return -EAGAIN; | 448 | return -EAGAIN; |
449 | } | 449 | } |
450 | } | 450 | } |
@@ -729,12 +729,12 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
729 | int ret; | 729 | int ret; |
730 | 730 | ||
731 | if (b->type != q->type) { | 731 | if (b->type != q->type) { |
732 | dprintk(1, "querybuf: wrong buffer type\n"); | 732 | dprintk(1, "wrong buffer type\n"); |
733 | return -EINVAL; | 733 | return -EINVAL; |
734 | } | 734 | } |
735 | 735 | ||
736 | if (b->index >= q->num_buffers) { | 736 | if (b->index >= q->num_buffers) { |
737 | dprintk(1, "querybuf: buffer index out of range\n"); | 737 | dprintk(1, "buffer index out of range\n"); |
738 | return -EINVAL; | 738 | return -EINVAL; |
739 | } | 739 | } |
740 | vb = q->bufs[b->index]; | 740 | vb = q->bufs[b->index]; |
@@ -794,12 +794,12 @@ static int __verify_memory_type(struct vb2_queue *q, | |||
794 | { | 794 | { |
795 | if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR && | 795 | if (memory != V4L2_MEMORY_MMAP && memory != V4L2_MEMORY_USERPTR && |
796 | memory != V4L2_MEMORY_DMABUF) { | 796 | memory != V4L2_MEMORY_DMABUF) { |
797 | dprintk(1, "reqbufs: unsupported memory type\n"); | 797 | dprintk(1, "unsupported memory type\n"); |
798 | return -EINVAL; | 798 | return -EINVAL; |
799 | } | 799 | } |
800 | 800 | ||
801 | if (type != q->type) { | 801 | if (type != q->type) { |
802 | dprintk(1, "reqbufs: requested type is incorrect\n"); | 802 | dprintk(1, "requested type is incorrect\n"); |
803 | return -EINVAL; | 803 | return -EINVAL; |
804 | } | 804 | } |
805 | 805 | ||
@@ -808,17 +808,17 @@ static int __verify_memory_type(struct vb2_queue *q, | |||
808 | * are available. | 808 | * are available. |
809 | */ | 809 | */ |
810 | if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { | 810 | if (memory == V4L2_MEMORY_MMAP && __verify_mmap_ops(q)) { |
811 | dprintk(1, "reqbufs: MMAP for current setup unsupported\n"); | 811 | dprintk(1, "MMAP for current setup unsupported\n"); |
812 | return -EINVAL; | 812 | return -EINVAL; |
813 | } | 813 | } |
814 | 814 | ||
815 | if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { | 815 | if (memory == V4L2_MEMORY_USERPTR && __verify_userptr_ops(q)) { |
816 | dprintk(1, "reqbufs: USERPTR for current setup unsupported\n"); | 816 | dprintk(1, "USERPTR for current setup unsupported\n"); |
817 | return -EINVAL; | 817 | return -EINVAL; |
818 | } | 818 | } |
819 | 819 | ||
820 | if (memory == V4L2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) { | 820 | if (memory == V4L2_MEMORY_DMABUF && __verify_dmabuf_ops(q)) { |
821 | dprintk(1, "reqbufs: DMABUF for current setup unsupported\n"); | 821 | dprintk(1, "DMABUF for current setup unsupported\n"); |
822 | return -EINVAL; | 822 | return -EINVAL; |
823 | } | 823 | } |
824 | 824 | ||
@@ -828,7 +828,7 @@ static int __verify_memory_type(struct vb2_queue *q, | |||
828 | * do the memory and type validation. | 828 | * do the memory and type validation. |
829 | */ | 829 | */ |
830 | if (q->fileio) { | 830 | if (q->fileio) { |
831 | dprintk(1, "reqbufs: file io in progress\n"); | 831 | dprintk(1, "file io in progress\n"); |
832 | return -EBUSY; | 832 | return -EBUSY; |
833 | } | 833 | } |
834 | return 0; | 834 | return 0; |
@@ -863,7 +863,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | |||
863 | int ret; | 863 | int ret; |
864 | 864 | ||
865 | if (q->streaming) { | 865 | if (q->streaming) { |
866 | dprintk(1, "reqbufs: streaming active\n"); | 866 | dprintk(1, "streaming active\n"); |
867 | return -EBUSY; | 867 | return -EBUSY; |
868 | } | 868 | } |
869 | 869 | ||
@@ -873,7 +873,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req) | |||
873 | * are not in use and can be freed. | 873 | * are not in use and can be freed. |
874 | */ | 874 | */ |
875 | if (q->memory == V4L2_MEMORY_MMAP && __buffers_in_use(q)) { | 875 | if (q->memory == V4L2_MEMORY_MMAP && __buffers_in_use(q)) { |
876 | dprintk(1, "reqbufs: memory in use, cannot free\n"); | 876 | dprintk(1, "memory in use, cannot free\n"); |
877 | return -EBUSY; | 877 | return -EBUSY; |
878 | } | 878 | } |
879 | 879 | ||
@@ -1000,8 +1000,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create | |||
1000 | int ret; | 1000 | int ret; |
1001 | 1001 | ||
1002 | if (q->num_buffers == VIDEO_MAX_FRAME) { | 1002 | if (q->num_buffers == VIDEO_MAX_FRAME) { |
1003 | dprintk(1, "%s(): maximum number of buffers already allocated\n", | 1003 | dprintk(1, "maximum number of buffers already allocated\n"); |
1004 | __func__); | ||
1005 | return -ENOBUFS; | 1004 | return -ENOBUFS; |
1006 | } | 1005 | } |
1007 | 1006 | ||
@@ -1329,12 +1328,12 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1329 | && vb->v4l2_planes[plane].length == planes[plane].length) | 1328 | && vb->v4l2_planes[plane].length == planes[plane].length) |
1330 | continue; | 1329 | continue; |
1331 | 1330 | ||
1332 | dprintk(3, "qbuf: userspace address for plane %d changed, " | 1331 | dprintk(3, "userspace address for plane %d changed, " |
1333 | "reacquiring memory\n", plane); | 1332 | "reacquiring memory\n", plane); |
1334 | 1333 | ||
1335 | /* Check if the provided plane buffer is large enough */ | 1334 | /* Check if the provided plane buffer is large enough */ |
1336 | if (planes[plane].length < q->plane_sizes[plane]) { | 1335 | if (planes[plane].length < q->plane_sizes[plane]) { |
1337 | dprintk(1, "qbuf: provided buffer size %u is less than " | 1336 | dprintk(1, "provided buffer size %u is less than " |
1338 | "setup size %u for plane %d\n", | 1337 | "setup size %u for plane %d\n", |
1339 | planes[plane].length, | 1338 | planes[plane].length, |
1340 | q->plane_sizes[plane], plane); | 1339 | q->plane_sizes[plane], plane); |
@@ -1359,7 +1358,7 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1359 | planes[plane].m.userptr, | 1358 | planes[plane].m.userptr, |
1360 | planes[plane].length, write); | 1359 | planes[plane].length, write); |
1361 | if (IS_ERR_OR_NULL(mem_priv)) { | 1360 | if (IS_ERR_OR_NULL(mem_priv)) { |
1362 | dprintk(1, "qbuf: failed acquiring userspace " | 1361 | dprintk(1, "failed acquiring userspace " |
1363 | "memory for plane %d\n", plane); | 1362 | "memory for plane %d\n", plane); |
1364 | ret = mem_priv ? PTR_ERR(mem_priv) : -EINVAL; | 1363 | ret = mem_priv ? PTR_ERR(mem_priv) : -EINVAL; |
1365 | goto err; | 1364 | goto err; |
@@ -1382,14 +1381,14 @@ static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1382 | */ | 1381 | */ |
1383 | ret = call_vb_qop(vb, buf_init, vb); | 1382 | ret = call_vb_qop(vb, buf_init, vb); |
1384 | if (ret) { | 1383 | if (ret) { |
1385 | dprintk(1, "qbuf: buffer initialization failed\n"); | 1384 | dprintk(1, "buffer initialization failed\n"); |
1386 | goto err; | 1385 | goto err; |
1387 | } | 1386 | } |
1388 | } | 1387 | } |
1389 | 1388 | ||
1390 | ret = call_vb_qop(vb, buf_prepare, vb); | 1389 | ret = call_vb_qop(vb, buf_prepare, vb); |
1391 | if (ret) { | 1390 | if (ret) { |
1392 | dprintk(1, "qbuf: buffer preparation failed\n"); | 1391 | dprintk(1, "buffer preparation failed\n"); |
1393 | call_void_vb_qop(vb, buf_cleanup, vb); | 1392 | call_void_vb_qop(vb, buf_cleanup, vb); |
1394 | goto err; | 1393 | goto err; |
1395 | } | 1394 | } |
@@ -1438,7 +1437,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1438 | struct dma_buf *dbuf = dma_buf_get(planes[plane].m.fd); | 1437 | struct dma_buf *dbuf = dma_buf_get(planes[plane].m.fd); |
1439 | 1438 | ||
1440 | if (IS_ERR_OR_NULL(dbuf)) { | 1439 | if (IS_ERR_OR_NULL(dbuf)) { |
1441 | dprintk(1, "qbuf: invalid dmabuf fd for plane %d\n", | 1440 | dprintk(1, "invalid dmabuf fd for plane %d\n", |
1442 | plane); | 1441 | plane); |
1443 | ret = -EINVAL; | 1442 | ret = -EINVAL; |
1444 | goto err; | 1443 | goto err; |
@@ -1449,7 +1448,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1449 | planes[plane].length = dbuf->size; | 1448 | planes[plane].length = dbuf->size; |
1450 | 1449 | ||
1451 | if (planes[plane].length < q->plane_sizes[plane]) { | 1450 | if (planes[plane].length < q->plane_sizes[plane]) { |
1452 | dprintk(1, "qbuf: invalid dmabuf length for plane %d\n", | 1451 | dprintk(1, "invalid dmabuf length for plane %d\n", |
1453 | plane); | 1452 | plane); |
1454 | ret = -EINVAL; | 1453 | ret = -EINVAL; |
1455 | goto err; | 1454 | goto err; |
@@ -1462,7 +1461,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1462 | continue; | 1461 | continue; |
1463 | } | 1462 | } |
1464 | 1463 | ||
1465 | dprintk(1, "qbuf: buffer for plane %d changed\n", plane); | 1464 | dprintk(1, "buffer for plane %d changed\n", plane); |
1466 | 1465 | ||
1467 | if (!reacquired) { | 1466 | if (!reacquired) { |
1468 | reacquired = true; | 1467 | reacquired = true; |
@@ -1477,7 +1476,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1477 | mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_ctx[plane], | 1476 | mem_priv = call_ptr_memop(vb, attach_dmabuf, q->alloc_ctx[plane], |
1478 | dbuf, planes[plane].length, write); | 1477 | dbuf, planes[plane].length, write); |
1479 | if (IS_ERR(mem_priv)) { | 1478 | if (IS_ERR(mem_priv)) { |
1480 | dprintk(1, "qbuf: failed to attach dmabuf\n"); | 1479 | dprintk(1, "failed to attach dmabuf\n"); |
1481 | ret = PTR_ERR(mem_priv); | 1480 | ret = PTR_ERR(mem_priv); |
1482 | dma_buf_put(dbuf); | 1481 | dma_buf_put(dbuf); |
1483 | goto err; | 1482 | goto err; |
@@ -1494,7 +1493,7 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1494 | for (plane = 0; plane < vb->num_planes; ++plane) { | 1493 | for (plane = 0; plane < vb->num_planes; ++plane) { |
1495 | ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv); | 1494 | ret = call_memop(vb, map_dmabuf, vb->planes[plane].mem_priv); |
1496 | if (ret) { | 1495 | if (ret) { |
1497 | dprintk(1, "qbuf: failed to map dmabuf for plane %d\n", | 1496 | dprintk(1, "failed to map dmabuf for plane %d\n", |
1498 | plane); | 1497 | plane); |
1499 | goto err; | 1498 | goto err; |
1500 | } | 1499 | } |
@@ -1515,14 +1514,14 @@ static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1515 | */ | 1514 | */ |
1516 | ret = call_vb_qop(vb, buf_init, vb); | 1515 | ret = call_vb_qop(vb, buf_init, vb); |
1517 | if (ret) { | 1516 | if (ret) { |
1518 | dprintk(1, "qbuf: buffer initialization failed\n"); | 1517 | dprintk(1, "buffer initialization failed\n"); |
1519 | goto err; | 1518 | goto err; |
1520 | } | 1519 | } |
1521 | } | 1520 | } |
1522 | 1521 | ||
1523 | ret = call_vb_qop(vb, buf_prepare, vb); | 1522 | ret = call_vb_qop(vb, buf_prepare, vb); |
1524 | if (ret) { | 1523 | if (ret) { |
1525 | dprintk(1, "qbuf: buffer preparation failed\n"); | 1524 | dprintk(1, "buffer preparation failed\n"); |
1526 | call_void_vb_qop(vb, buf_cleanup, vb); | 1525 | call_void_vb_qop(vb, buf_cleanup, vb); |
1527 | goto err; | 1526 | goto err; |
1528 | } | 1527 | } |
@@ -1561,8 +1560,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1561 | 1560 | ||
1562 | ret = __verify_length(vb, b); | 1561 | ret = __verify_length(vb, b); |
1563 | if (ret < 0) { | 1562 | if (ret < 0) { |
1564 | dprintk(1, "%s(): plane parameters verification failed: %d\n", | 1563 | dprintk(1, "plane parameters verification failed: %d\n", ret); |
1565 | __func__, ret); | ||
1566 | return ret; | 1564 | return ret; |
1567 | } | 1565 | } |
1568 | 1566 | ||
@@ -1606,7 +1604,7 @@ static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) | |||
1606 | } | 1604 | } |
1607 | 1605 | ||
1608 | if (ret) | 1606 | if (ret) |
1609 | dprintk(1, "qbuf: buffer preparation failed: %d\n", ret); | 1607 | dprintk(1, "buffer preparation failed: %d\n", ret); |
1610 | vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED; | 1608 | vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED; |
1611 | 1609 | ||
1612 | return ret; | 1610 | return ret; |
@@ -1616,23 +1614,23 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b, | |||
1616 | const char *opname) | 1614 | const char *opname) |
1617 | { | 1615 | { |
1618 | if (b->type != q->type) { | 1616 | if (b->type != q->type) { |
1619 | dprintk(1, "%s(): invalid buffer type\n", opname); | 1617 | dprintk(1, "%s: invalid buffer type\n", opname); |
1620 | return -EINVAL; | 1618 | return -EINVAL; |
1621 | } | 1619 | } |
1622 | 1620 | ||
1623 | if (b->index >= q->num_buffers) { | 1621 | if (b->index >= q->num_buffers) { |
1624 | dprintk(1, "%s(): buffer index out of range\n", opname); | 1622 | dprintk(1, "%s: buffer index out of range\n", opname); |
1625 | return -EINVAL; | 1623 | return -EINVAL; |
1626 | } | 1624 | } |
1627 | 1625 | ||
1628 | if (q->bufs[b->index] == NULL) { | 1626 | if (q->bufs[b->index] == NULL) { |
1629 | /* Should never happen */ | 1627 | /* Should never happen */ |
1630 | dprintk(1, "%s(): buffer is NULL\n", opname); | 1628 | dprintk(1, "%s: buffer is NULL\n", opname); |
1631 | return -EINVAL; | 1629 | return -EINVAL; |
1632 | } | 1630 | } |
1633 | 1631 | ||
1634 | if (b->memory != q->memory) { | 1632 | if (b->memory != q->memory) { |
1635 | dprintk(1, "%s(): invalid memory type\n", opname); | 1633 | dprintk(1, "%s: invalid memory type\n", opname); |
1636 | return -EINVAL; | 1634 | return -EINVAL; |
1637 | } | 1635 | } |
1638 | 1636 | ||
@@ -1660,7 +1658,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1660 | int ret; | 1658 | int ret; |
1661 | 1659 | ||
1662 | if (q->fileio) { | 1660 | if (q->fileio) { |
1663 | dprintk(1, "%s(): file io in progress\n", __func__); | 1661 | dprintk(1, "file io in progress\n"); |
1664 | return -EBUSY; | 1662 | return -EBUSY; |
1665 | } | 1663 | } |
1666 | 1664 | ||
@@ -1670,7 +1668,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1670 | 1668 | ||
1671 | vb = q->bufs[b->index]; | 1669 | vb = q->bufs[b->index]; |
1672 | if (vb->state != VB2_BUF_STATE_DEQUEUED) { | 1670 | if (vb->state != VB2_BUF_STATE_DEQUEUED) { |
1673 | dprintk(1, "%s(): invalid buffer state %d\n", __func__, | 1671 | dprintk(1, "invalid buffer state %d\n", |
1674 | vb->state); | 1672 | vb->state); |
1675 | return -EINVAL; | 1673 | return -EINVAL; |
1676 | } | 1674 | } |
@@ -1680,7 +1678,7 @@ int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1680 | /* Fill buffer information for the userspace */ | 1678 | /* Fill buffer information for the userspace */ |
1681 | __fill_v4l2_buffer(vb, b); | 1679 | __fill_v4l2_buffer(vb, b); |
1682 | 1680 | ||
1683 | dprintk(1, "%s() of buffer %d succeeded\n", __func__, vb->v4l2_buf.index); | 1681 | dprintk(1, "prepare of buffer %d succeeded\n", vb->v4l2_buf.index); |
1684 | } | 1682 | } |
1685 | return ret; | 1683 | return ret; |
1686 | } | 1684 | } |
@@ -1716,7 +1714,7 @@ static int vb2_start_streaming(struct vb2_queue *q) | |||
1716 | if (!ret) | 1714 | if (!ret) |
1717 | return 0; | 1715 | return 0; |
1718 | 1716 | ||
1719 | dprintk(1, "qbuf: driver refused to start streaming\n"); | 1717 | dprintk(1, "driver refused to start streaming\n"); |
1720 | if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { | 1718 | if (WARN_ON(atomic_read(&q->owned_by_drv_count))) { |
1721 | unsigned i; | 1719 | unsigned i; |
1722 | 1720 | ||
@@ -1754,11 +1752,10 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1754 | case VB2_BUF_STATE_PREPARED: | 1752 | case VB2_BUF_STATE_PREPARED: |
1755 | break; | 1753 | break; |
1756 | case VB2_BUF_STATE_PREPARING: | 1754 | case VB2_BUF_STATE_PREPARING: |
1757 | dprintk(1, "qbuf: buffer still being prepared\n"); | 1755 | dprintk(1, "buffer still being prepared\n"); |
1758 | return -EINVAL; | 1756 | return -EINVAL; |
1759 | default: | 1757 | default: |
1760 | dprintk(1, "%s(): invalid buffer state %d\n", __func__, | 1758 | dprintk(1, "invalid buffer state %d\n", vb->state); |
1761 | vb->state); | ||
1762 | return -EINVAL; | 1759 | return -EINVAL; |
1763 | } | 1760 | } |
1764 | 1761 | ||
@@ -1805,7 +1802,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1805 | return ret; | 1802 | return ret; |
1806 | } | 1803 | } |
1807 | 1804 | ||
1808 | dprintk(1, "%s() of buffer %d succeeded\n", __func__, vb->v4l2_buf.index); | 1805 | dprintk(1, "qbuf of buffer %d succeeded\n", vb->v4l2_buf.index); |
1809 | return 0; | 1806 | return 0; |
1810 | } | 1807 | } |
1811 | 1808 | ||
@@ -1829,7 +1826,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) | |||
1829 | int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) | 1826 | int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) |
1830 | { | 1827 | { |
1831 | if (q->fileio) { | 1828 | if (q->fileio) { |
1832 | dprintk(1, "%s(): file io in progress\n", __func__); | 1829 | dprintk(1, "file io in progress\n"); |
1833 | return -EBUSY; | 1830 | return -EBUSY; |
1834 | } | 1831 | } |
1835 | 1832 | ||
@@ -1990,7 +1987,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n | |||
1990 | int ret; | 1987 | int ret; |
1991 | 1988 | ||
1992 | if (b->type != q->type) { | 1989 | if (b->type != q->type) { |
1993 | dprintk(1, "dqbuf: invalid buffer type\n"); | 1990 | dprintk(1, "invalid buffer type\n"); |
1994 | return -EINVAL; | 1991 | return -EINVAL; |
1995 | } | 1992 | } |
1996 | ret = __vb2_get_done_vb(q, &vb, b, nonblocking); | 1993 | ret = __vb2_get_done_vb(q, &vb, b, nonblocking); |
@@ -1999,13 +1996,13 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n | |||
1999 | 1996 | ||
2000 | switch (vb->state) { | 1997 | switch (vb->state) { |
2001 | case VB2_BUF_STATE_DONE: | 1998 | case VB2_BUF_STATE_DONE: |
2002 | dprintk(3, "dqbuf: Returning done buffer\n"); | 1999 | dprintk(3, "Returning done buffer\n"); |
2003 | break; | 2000 | break; |
2004 | case VB2_BUF_STATE_ERROR: | 2001 | case VB2_BUF_STATE_ERROR: |
2005 | dprintk(3, "dqbuf: Returning done buffer with errors\n"); | 2002 | dprintk(3, "Returning done buffer with errors\n"); |
2006 | break; | 2003 | break; |
2007 | default: | 2004 | default: |
2008 | dprintk(1, "dqbuf: Invalid buffer state\n"); | 2005 | dprintk(1, "Invalid buffer state\n"); |
2009 | return -EINVAL; | 2006 | return -EINVAL; |
2010 | } | 2007 | } |
2011 | 2008 | ||
@@ -2049,7 +2046,7 @@ static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool n | |||
2049 | int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) | 2046 | int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) |
2050 | { | 2047 | { |
2051 | if (q->fileio) { | 2048 | if (q->fileio) { |
2052 | dprintk(1, "dqbuf: file io in progress\n"); | 2049 | dprintk(1, "file io in progress\n"); |
2053 | return -EBUSY; | 2050 | return -EBUSY; |
2054 | } | 2051 | } |
2055 | return vb2_internal_dqbuf(q, b, nonblocking); | 2052 | return vb2_internal_dqbuf(q, b, nonblocking); |
@@ -2121,26 +2118,26 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) | |||
2121 | int ret; | 2118 | int ret; |
2122 | 2119 | ||
2123 | if (type != q->type) { | 2120 | if (type != q->type) { |
2124 | dprintk(1, "streamon: invalid stream type\n"); | 2121 | dprintk(1, "invalid stream type\n"); |
2125 | return -EINVAL; | 2122 | return -EINVAL; |
2126 | } | 2123 | } |
2127 | 2124 | ||
2128 | if (q->streaming) { | 2125 | if (q->streaming) { |
2129 | dprintk(3, "streamon successful: already streaming\n"); | 2126 | dprintk(3, "already streaming\n"); |
2130 | return 0; | 2127 | return 0; |
2131 | } | 2128 | } |
2132 | 2129 | ||
2133 | if (!q->num_buffers) { | 2130 | if (!q->num_buffers) { |
2134 | dprintk(1, "streamon: no buffers have been allocated\n"); | 2131 | dprintk(1, "no buffers have been allocated\n"); |
2135 | return -EINVAL; | 2132 | return -EINVAL; |
2136 | } | 2133 | } |
2137 | 2134 | ||
2138 | if (!q->num_buffers) { | 2135 | if (!q->num_buffers) { |
2139 | dprintk(1, "streamon: no buffers have been allocated\n"); | 2136 | dprintk(1, "no buffers have been allocated\n"); |
2140 | return -EINVAL; | 2137 | return -EINVAL; |
2141 | } | 2138 | } |
2142 | if (q->num_buffers < q->min_buffers_needed) { | 2139 | if (q->num_buffers < q->min_buffers_needed) { |
2143 | dprintk(1, "streamon: need at least %u allocated buffers\n", | 2140 | dprintk(1, "need at least %u allocated buffers\n", |
2144 | q->min_buffers_needed); | 2141 | q->min_buffers_needed); |
2145 | return -EINVAL; | 2142 | return -EINVAL; |
2146 | } | 2143 | } |
@@ -2159,7 +2156,7 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) | |||
2159 | 2156 | ||
2160 | q->streaming = 1; | 2157 | q->streaming = 1; |
2161 | 2158 | ||
2162 | dprintk(3, "Streamon successful\n"); | 2159 | dprintk(3, "successful\n"); |
2163 | return 0; | 2160 | return 0; |
2164 | } | 2161 | } |
2165 | 2162 | ||
@@ -2179,7 +2176,7 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) | |||
2179 | int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) | 2176 | int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type) |
2180 | { | 2177 | { |
2181 | if (q->fileio) { | 2178 | if (q->fileio) { |
2182 | dprintk(1, "streamon: file io in progress\n"); | 2179 | dprintk(1, "file io in progress\n"); |
2183 | return -EBUSY; | 2180 | return -EBUSY; |
2184 | } | 2181 | } |
2185 | return vb2_internal_streamon(q, type); | 2182 | return vb2_internal_streamon(q, type); |
@@ -2189,7 +2186,7 @@ EXPORT_SYMBOL_GPL(vb2_streamon); | |||
2189 | static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) | 2186 | static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) |
2190 | { | 2187 | { |
2191 | if (type != q->type) { | 2188 | if (type != q->type) { |
2192 | dprintk(1, "streamoff: invalid stream type\n"); | 2189 | dprintk(1, "invalid stream type\n"); |
2193 | return -EINVAL; | 2190 | return -EINVAL; |
2194 | } | 2191 | } |
2195 | 2192 | ||
@@ -2204,7 +2201,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) | |||
2204 | */ | 2201 | */ |
2205 | __vb2_queue_cancel(q); | 2202 | __vb2_queue_cancel(q); |
2206 | 2203 | ||
2207 | dprintk(3, "Streamoff successful\n"); | 2204 | dprintk(3, "successful\n"); |
2208 | return 0; | 2205 | return 0; |
2209 | } | 2206 | } |
2210 | 2207 | ||
@@ -2226,7 +2223,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) | |||
2226 | int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) | 2223 | int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type) |
2227 | { | 2224 | { |
2228 | if (q->fileio) { | 2225 | if (q->fileio) { |
2229 | dprintk(1, "streamoff: file io in progress\n"); | 2226 | dprintk(1, "file io in progress\n"); |
2230 | return -EBUSY; | 2227 | return -EBUSY; |
2231 | } | 2228 | } |
2232 | return vb2_internal_streamoff(q, type); | 2229 | return vb2_internal_streamoff(q, type); |
@@ -2294,7 +2291,7 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb) | |||
2294 | } | 2291 | } |
2295 | 2292 | ||
2296 | if (eb->type != q->type) { | 2293 | if (eb->type != q->type) { |
2297 | dprintk(1, "qbuf: invalid buffer type\n"); | 2294 | dprintk(1, "invalid buffer type\n"); |
2298 | return -EINVAL; | 2295 | return -EINVAL; |
2299 | } | 2296 | } |
2300 | 2297 | ||
@@ -2805,7 +2802,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2805 | struct vb2_fileio_buf *buf; | 2802 | struct vb2_fileio_buf *buf; |
2806 | int ret, index; | 2803 | int ret, index; |
2807 | 2804 | ||
2808 | dprintk(3, "file io: mode %s, offset %ld, count %zd, %sblocking\n", | 2805 | dprintk(3, "mode %s, offset %ld, count %zd, %sblocking\n", |
2809 | read ? "read" : "write", (long)*ppos, count, | 2806 | read ? "read" : "write", (long)*ppos, count, |
2810 | nonblock ? "non" : ""); | 2807 | nonblock ? "non" : ""); |
2811 | 2808 | ||
@@ -2817,7 +2814,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2817 | */ | 2814 | */ |
2818 | if (!q->fileio) { | 2815 | if (!q->fileio) { |
2819 | ret = __vb2_init_fileio(q, read); | 2816 | ret = __vb2_init_fileio(q, read); |
2820 | dprintk(3, "file io: vb2_init_fileio result: %d\n", ret); | 2817 | dprintk(3, "vb2_init_fileio result: %d\n", ret); |
2821 | if (ret) | 2818 | if (ret) |
2822 | return ret; | 2819 | return ret; |
2823 | } | 2820 | } |
@@ -2835,7 +2832,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2835 | fileio->b.type = q->type; | 2832 | fileio->b.type = q->type; |
2836 | fileio->b.memory = q->memory; | 2833 | fileio->b.memory = q->memory; |
2837 | ret = vb2_internal_dqbuf(q, &fileio->b, nonblock); | 2834 | ret = vb2_internal_dqbuf(q, &fileio->b, nonblock); |
2838 | dprintk(5, "file io: vb2_dqbuf result: %d\n", ret); | 2835 | dprintk(5, "vb2_dqbuf result: %d\n", ret); |
2839 | if (ret) | 2836 | if (ret) |
2840 | return ret; | 2837 | return ret; |
2841 | fileio->dq_count += 1; | 2838 | fileio->dq_count += 1; |
@@ -2865,14 +2862,14 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2865 | /* | 2862 | /* |
2866 | * Transfer data to userspace. | 2863 | * Transfer data to userspace. |
2867 | */ | 2864 | */ |
2868 | dprintk(3, "file io: copying %zd bytes - buffer %d, offset %u\n", | 2865 | dprintk(3, "copying %zd bytes - buffer %d, offset %u\n", |
2869 | count, index, buf->pos); | 2866 | count, index, buf->pos); |
2870 | if (read) | 2867 | if (read) |
2871 | ret = copy_to_user(data, buf->vaddr + buf->pos, count); | 2868 | ret = copy_to_user(data, buf->vaddr + buf->pos, count); |
2872 | else | 2869 | else |
2873 | ret = copy_from_user(buf->vaddr + buf->pos, data, count); | 2870 | ret = copy_from_user(buf->vaddr + buf->pos, data, count); |
2874 | if (ret) { | 2871 | if (ret) { |
2875 | dprintk(3, "file io: error copying data\n"); | 2872 | dprintk(3, "error copying data\n"); |
2876 | return -EFAULT; | 2873 | return -EFAULT; |
2877 | } | 2874 | } |
2878 | 2875 | ||
@@ -2892,7 +2889,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2892 | */ | 2889 | */ |
2893 | if (read && (fileio->flags & VB2_FILEIO_READ_ONCE) && | 2890 | if (read && (fileio->flags & VB2_FILEIO_READ_ONCE) && |
2894 | fileio->dq_count == 1) { | 2891 | fileio->dq_count == 1) { |
2895 | dprintk(3, "file io: read limit reached\n"); | 2892 | dprintk(3, "read limit reached\n"); |
2896 | return __vb2_cleanup_fileio(q); | 2893 | return __vb2_cleanup_fileio(q); |
2897 | } | 2894 | } |
2898 | 2895 | ||
@@ -2905,7 +2902,7 @@ static size_t __vb2_perform_fileio(struct vb2_queue *q, char __user *data, size_ | |||
2905 | fileio->b.index = index; | 2902 | fileio->b.index = index; |
2906 | fileio->b.bytesused = buf->pos; | 2903 | fileio->b.bytesused = buf->pos; |
2907 | ret = vb2_internal_qbuf(q, &fileio->b); | 2904 | ret = vb2_internal_qbuf(q, &fileio->b); |
2908 | dprintk(5, "file io: vb2_dbuf result: %d\n", ret); | 2905 | dprintk(5, "vb2_dbuf result: %d\n", ret); |
2909 | if (ret) | 2906 | if (ret) |
2910 | return ret; | 2907 | return ret; |
2911 | 2908 | ||