Lines Matching refs:b

553 static int __verify_planes_array(struct vb2_buffer *vb, const struct v4l2_buffer *b)  in __verify_planes_array()  argument
555 if (!V4L2_TYPE_IS_MULTIPLANAR(b->type)) in __verify_planes_array()
559 if (NULL == b->m.planes) { in __verify_planes_array()
565 if (b->length < vb->num_planes || b->length > VIDEO_MAX_PLANES) { in __verify_planes_array()
567 "expected %d, got %d\n", vb->num_planes, b->length); in __verify_planes_array()
578 static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __verify_length() argument
584 if (!V4L2_TYPE_IS_OUTPUT(b->type)) in __verify_length()
587 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { in __verify_length()
589 length = (b->memory == V4L2_MEMORY_USERPTR || in __verify_length()
590 b->memory == V4L2_MEMORY_DMABUF) in __verify_length()
591 ? b->m.planes[plane].length in __verify_length()
593 bytesused = b->m.planes[plane].bytesused in __verify_length()
594 ? b->m.planes[plane].bytesused : length; in __verify_length()
596 if (b->m.planes[plane].bytesused > length) in __verify_length()
599 if (b->m.planes[plane].data_offset > 0 && in __verify_length()
600 b->m.planes[plane].data_offset >= bytesused) in __verify_length()
604 length = (b->memory == V4L2_MEMORY_USERPTR) in __verify_length()
605 ? b->length : vb->v4l2_planes[0].length; in __verify_length()
606 bytesused = b->bytesused ? b->bytesused : length; in __verify_length()
608 if (b->bytesused > length) in __verify_length()
654 static void __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b) in __fill_v4l2_buffer() argument
659 memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m)); in __fill_v4l2_buffer()
660 b->reserved2 = vb->v4l2_buf.reserved2; in __fill_v4l2_buffer()
661 b->reserved = vb->v4l2_buf.reserved; in __fill_v4l2_buffer()
668 b->length = vb->num_planes; in __fill_v4l2_buffer()
669 memcpy(b->m.planes, vb->v4l2_planes, in __fill_v4l2_buffer()
670 b->length * sizeof(struct v4l2_plane)); in __fill_v4l2_buffer()
676 b->length = vb->v4l2_planes[0].length; in __fill_v4l2_buffer()
677 b->bytesused = vb->v4l2_planes[0].bytesused; in __fill_v4l2_buffer()
679 b->m.offset = vb->v4l2_planes[0].m.mem_offset; in __fill_v4l2_buffer()
681 b->m.userptr = vb->v4l2_planes[0].m.userptr; in __fill_v4l2_buffer()
683 b->m.fd = vb->v4l2_planes[0].m.fd; in __fill_v4l2_buffer()
689 b->flags &= ~V4L2_BUFFER_MASK_FLAGS; in __fill_v4l2_buffer()
690 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK; in __fill_v4l2_buffer()
697 b->flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK; in __fill_v4l2_buffer()
698 b->flags |= q->timestamp_flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK; in __fill_v4l2_buffer()
704 b->flags |= V4L2_BUF_FLAG_QUEUED; in __fill_v4l2_buffer()
707 b->flags |= V4L2_BUF_FLAG_ERROR; in __fill_v4l2_buffer()
710 b->flags |= V4L2_BUF_FLAG_DONE; in __fill_v4l2_buffer()
713 b->flags |= V4L2_BUF_FLAG_PREPARED; in __fill_v4l2_buffer()
722 b->flags |= V4L2_BUF_FLAG_MAPPED; in __fill_v4l2_buffer()
738 int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b) in vb2_querybuf() argument
743 if (b->type != q->type) { in vb2_querybuf()
748 if (b->index >= q->num_buffers) { in vb2_querybuf()
752 vb = q->bufs[b->index]; in vb2_querybuf()
753 ret = __verify_planes_array(vb, b); in vb2_querybuf()
755 __fill_v4l2_buffer(vb, b); in vb2_querybuf()
1262 static void __fill_vb2_buffer(struct vb2_buffer *vb, const struct v4l2_buffer *b, in __fill_vb2_buffer() argument
1267 if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) { in __fill_vb2_buffer()
1268 if (b->memory == V4L2_MEMORY_USERPTR) { in __fill_vb2_buffer()
1271 b->m.planes[plane].m.userptr; in __fill_vb2_buffer()
1273 b->m.planes[plane].length; in __fill_vb2_buffer()
1276 if (b->memory == V4L2_MEMORY_DMABUF) { in __fill_vb2_buffer()
1279 b->m.planes[plane].m.fd; in __fill_vb2_buffer()
1281 b->m.planes[plane].length; in __fill_vb2_buffer()
1286 if (V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
1305 struct v4l2_plane *psrc = &b->m.planes[plane]; in __fill_vb2_buffer()
1333 if (b->memory == V4L2_MEMORY_USERPTR) { in __fill_vb2_buffer()
1334 v4l2_planes[0].m.userptr = b->m.userptr; in __fill_vb2_buffer()
1335 v4l2_planes[0].length = b->length; in __fill_vb2_buffer()
1338 if (b->memory == V4L2_MEMORY_DMABUF) { in __fill_vb2_buffer()
1339 v4l2_planes[0].m.fd = b->m.fd; in __fill_vb2_buffer()
1340 v4l2_planes[0].length = b->length; in __fill_vb2_buffer()
1343 if (V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
1344 if (b->bytesused == 0) in __fill_vb2_buffer()
1348 v4l2_planes[0].bytesused = b->bytesused; in __fill_vb2_buffer()
1350 v4l2_planes[0].bytesused = b->bytesused ? in __fill_vb2_buffer()
1351 b->bytesused : v4l2_planes[0].length; in __fill_vb2_buffer()
1358 vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_MASK_FLAGS; in __fill_vb2_buffer()
1360 V4L2_BUF_FLAG_TIMESTAMP_COPY || !V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
1369 if (V4L2_TYPE_IS_OUTPUT(b->type)) { in __fill_vb2_buffer()
1377 vb->v4l2_buf.field = b->field; in __fill_vb2_buffer()
1387 static int __qbuf_mmap(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __qbuf_mmap() argument
1389 __fill_vb2_buffer(vb, b, vb->v4l2_planes); in __qbuf_mmap()
1396 static int __qbuf_userptr(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __qbuf_userptr() argument
1409 __fill_vb2_buffer(vb, b, planes); in __qbuf_userptr()
1500 static int __qbuf_dmabuf(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __qbuf_dmabuf() argument
1513 __fill_vb2_buffer(vb, b, planes); in __qbuf_dmabuf()
1634 static int __buf_prepare(struct vb2_buffer *vb, const struct v4l2_buffer *b) in __buf_prepare() argument
1639 ret = __verify_length(vb, b); in __buf_prepare()
1644 if (b->field == V4L2_FIELD_ALTERNATE && V4L2_TYPE_IS_OUTPUT(q->type)) { in __buf_prepare()
1670 ret = __qbuf_mmap(vb, b); in __buf_prepare()
1674 ret = __qbuf_userptr(vb, b); in __buf_prepare()
1678 ret = __qbuf_dmabuf(vb, b); in __buf_prepare()
1692 static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b, in vb2_queue_or_prepare_buf() argument
1695 if (b->type != q->type) { in vb2_queue_or_prepare_buf()
1700 if (b->index >= q->num_buffers) { in vb2_queue_or_prepare_buf()
1705 if (q->bufs[b->index] == NULL) { in vb2_queue_or_prepare_buf()
1711 if (b->memory != q->memory) { in vb2_queue_or_prepare_buf()
1716 return __verify_planes_array(q->bufs[b->index], b); in vb2_queue_or_prepare_buf()
1734 int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b) in vb2_prepare_buf() argument
1744 ret = vb2_queue_or_prepare_buf(q, b, "prepare_buf"); in vb2_prepare_buf()
1748 vb = q->bufs[b->index]; in vb2_prepare_buf()
1755 ret = __buf_prepare(vb, b); in vb2_prepare_buf()
1758 __fill_v4l2_buffer(vb, b); in vb2_prepare_buf()
1829 static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) in vb2_internal_qbuf() argument
1831 int ret = vb2_queue_or_prepare_buf(q, b, "qbuf"); in vb2_internal_qbuf()
1837 vb = q->bufs[b->index]; in vb2_internal_qbuf()
1841 ret = __buf_prepare(vb, b); in vb2_internal_qbuf()
1870 vb->v4l2_buf.timestamp = b->timestamp; in vb2_internal_qbuf()
1871 vb->v4l2_buf.flags |= b->flags & V4L2_BUF_FLAG_TIMECODE; in vb2_internal_qbuf()
1872 if (b->flags & V4L2_BUF_FLAG_TIMECODE) in vb2_internal_qbuf()
1873 vb->v4l2_buf.timecode = b->timecode; in vb2_internal_qbuf()
1884 __fill_v4l2_buffer(vb, b); in vb2_internal_qbuf()
1920 int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b) in vb2_qbuf() argument
1927 return vb2_internal_qbuf(q, b); in vb2_qbuf()
2008 struct v4l2_buffer *b, int nonblocking) in __vb2_get_done_vb() argument
2030 ret = __verify_planes_array(*vb, b); in __vb2_get_done_vb()
2084 static int vb2_internal_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) in vb2_internal_dqbuf() argument
2089 if (b->type != q->type) { in vb2_internal_dqbuf()
2093 ret = __vb2_get_done_vb(q, &vb, b, nonblocking); in vb2_internal_dqbuf()
2112 __fill_v4l2_buffer(vb, b); in vb2_internal_dqbuf()
2146 int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking) in vb2_dqbuf() argument
2152 return vb2_internal_dqbuf(q, b, nonblocking); in vb2_dqbuf()
2797 struct v4l2_buffer b; member
2896 struct v4l2_buffer *b = &fileio->b; in __vb2_init_fileio() local
2898 memset(b, 0, sizeof(*b)); in __vb2_init_fileio()
2899 b->type = q->type; in __vb2_init_fileio()
2902 b->m.planes = &fileio->p; in __vb2_init_fileio()
2903 b->length = 1; in __vb2_init_fileio()
2905 b->memory = q->memory; in __vb2_init_fileio()
2906 b->index = i; in __vb2_init_fileio()
2907 ret = vb2_internal_qbuf(q, b); in __vb2_init_fileio()
3009 memset(&fileio->b, 0, sizeof(fileio->b)); in __vb2_perform_fileio()
3010 fileio->b.type = q->type; in __vb2_perform_fileio()
3011 fileio->b.memory = q->memory; in __vb2_perform_fileio()
3014 fileio->b.m.planes = &fileio->p; in __vb2_perform_fileio()
3015 fileio->b.length = 1; in __vb2_perform_fileio()
3017 ret = vb2_internal_dqbuf(q, &fileio->b, nonblock); in __vb2_perform_fileio()
3023 fileio->cur_index = index = fileio->b.index; in __vb2_perform_fileio()
3035 fileio->b.m.planes[0].data_offset < buf->size) { in __vb2_perform_fileio()
3036 buf->pos = fileio->b.m.planes[0].data_offset; in __vb2_perform_fileio()
3086 memset(&fileio->b, 0, sizeof(fileio->b)); in __vb2_perform_fileio()
3087 fileio->b.type = q->type; in __vb2_perform_fileio()
3088 fileio->b.memory = q->memory; in __vb2_perform_fileio()
3089 fileio->b.index = index; in __vb2_perform_fileio()
3090 fileio->b.bytesused = buf->pos; in __vb2_perform_fileio()
3094 fileio->b.m.planes = &fileio->p; in __vb2_perform_fileio()
3095 fileio->b.length = 1; in __vb2_perform_fileio()
3098 v4l2_get_timestamp(&fileio->b.timestamp); in __vb2_perform_fileio()
3099 ret = vb2_internal_qbuf(q, &fileio->b); in __vb2_perform_fileio()
3182 memset(&fileio->b, 0, sizeof(fileio->b)); in vb2_thread()
3183 fileio->b.type = q->type; in vb2_thread()
3184 fileio->b.memory = q->memory; in vb2_thread()
3186 fileio->b.index = index++; in vb2_thread()
3191 ret = vb2_internal_dqbuf(q, &fileio->b, 0); in vb2_thread()
3199 vb = q->bufs[fileio->b.index]; in vb2_thread()
3200 if (!(fileio->b.flags & V4L2_BUF_FLAG_ERROR)) in vb2_thread()
3205 v4l2_get_timestamp(&fileio->b.timestamp); in vb2_thread()
3207 ret = vb2_internal_qbuf(q, &fileio->b); in vb2_thread()