| .. | .. |
|---|
| 17 | 17 | #include <linux/poll.h> |
|---|
| 18 | 18 | #include <linux/dma-buf.h> |
|---|
| 19 | 19 | #include <linux/bitops.h> |
|---|
| 20 | +#include <media/media-request.h> |
|---|
| 20 | 21 | |
|---|
| 21 | 22 | #define VB2_MAX_FRAME (64) |
|---|
| 22 | 23 | #define VB2_MAX_PLANES (8) |
|---|
| .. | .. |
|---|
| 53 | 54 | * will then be passed as @buf_priv argument to other ops in this |
|---|
| 54 | 55 | * structure. Additional gfp_flags to use when allocating the |
|---|
| 55 | 56 | * are also passed to this operation. These flags are from the |
|---|
| 56 | | - * gfp_flags field of vb2_queue. |
|---|
| 57 | + * gfp_flags field of vb2_queue. The size argument to this function |
|---|
| 58 | + * shall be *page aligned*. |
|---|
| 57 | 59 | * @put: inform the allocator that the buffer will no longer be used; |
|---|
| 58 | 60 | * usually will result in the allocator freeing the buffer (if |
|---|
| 59 | 61 | * no other users of this buffer are present); the @buf_priv |
|---|
| .. | .. |
|---|
| 203 | 205 | /** |
|---|
| 204 | 206 | * enum vb2_buffer_state - current video buffer state. |
|---|
| 205 | 207 | * @VB2_BUF_STATE_DEQUEUED: buffer under userspace control. |
|---|
| 208 | + * @VB2_BUF_STATE_IN_REQUEST: buffer is queued in media request. |
|---|
| 206 | 209 | * @VB2_BUF_STATE_PREPARING: buffer is being prepared in videobuf. |
|---|
| 207 | | - * @VB2_BUF_STATE_PREPARED: buffer prepared in videobuf and by the driver. |
|---|
| 208 | 210 | * @VB2_BUF_STATE_QUEUED: buffer queued in videobuf, but not in driver. |
|---|
| 209 | | - * @VB2_BUF_STATE_REQUEUEING: re-queue a buffer to the driver. |
|---|
| 210 | 211 | * @VB2_BUF_STATE_ACTIVE: buffer queued in driver and possibly used |
|---|
| 211 | 212 | * in a hardware operation. |
|---|
| 212 | 213 | * @VB2_BUF_STATE_DONE: buffer returned from driver to videobuf, but |
|---|
| .. | .. |
|---|
| 217 | 218 | */ |
|---|
| 218 | 219 | enum vb2_buffer_state { |
|---|
| 219 | 220 | VB2_BUF_STATE_DEQUEUED, |
|---|
| 221 | + VB2_BUF_STATE_IN_REQUEST, |
|---|
| 220 | 222 | VB2_BUF_STATE_PREPARING, |
|---|
| 221 | | - VB2_BUF_STATE_PREPARED, |
|---|
| 222 | 223 | VB2_BUF_STATE_QUEUED, |
|---|
| 223 | | - VB2_BUF_STATE_REQUEUEING, |
|---|
| 224 | 224 | VB2_BUF_STATE_ACTIVE, |
|---|
| 225 | 225 | VB2_BUF_STATE_DONE, |
|---|
| 226 | 226 | VB2_BUF_STATE_ERROR, |
|---|
| .. | .. |
|---|
| 238 | 238 | * @num_planes: number of planes in the buffer |
|---|
| 239 | 239 | * on an internal driver queue. |
|---|
| 240 | 240 | * @timestamp: frame timestamp in ns. |
|---|
| 241 | + * @request: the request this buffer is associated with. |
|---|
| 242 | + * @req_obj: used to bind this buffer to a request. This |
|---|
| 243 | + * request object has a refcount. |
|---|
| 241 | 244 | */ |
|---|
| 242 | 245 | struct vb2_buffer { |
|---|
| 243 | 246 | struct vb2_queue *vb2_queue; |
|---|
| .. | .. |
|---|
| 246 | 249 | unsigned int memory; |
|---|
| 247 | 250 | unsigned int num_planes; |
|---|
| 248 | 251 | u64 timestamp; |
|---|
| 252 | + struct media_request *request; |
|---|
| 253 | + struct media_request_object req_obj; |
|---|
| 249 | 254 | |
|---|
| 250 | 255 | /* private: internal use only |
|---|
| 251 | 256 | * |
|---|
| 252 | 257 | * state: current buffer state; do not change |
|---|
| 258 | + * synced: this buffer has been synced for DMA, i.e. the |
|---|
| 259 | + * 'prepare' memop was called. It is cleared again |
|---|
| 260 | + * after the 'finish' memop is called. |
|---|
| 261 | + * prepared: this buffer has been prepared, i.e. the |
|---|
| 262 | + * buf_prepare op was called. It is cleared again |
|---|
| 263 | + * after the 'buf_finish' op is called. |
|---|
| 264 | + * copied_timestamp: the timestamp of this capture buffer was copied |
|---|
| 265 | + * from an output buffer. |
|---|
| 253 | 266 | * need_cache_sync_on_prepare: when set buffer's ->prepare() function |
|---|
| 254 | 267 | * performs cache sync/invalidation. |
|---|
| 255 | 268 | * need_cache_sync_on_finish: when set buffer's ->finish() function |
|---|
| .. | .. |
|---|
| 261 | 274 | * vb2_plane: per-plane information; do not change |
|---|
| 262 | 275 | */ |
|---|
| 263 | 276 | enum vb2_buffer_state state; |
|---|
| 277 | + unsigned int synced:1; |
|---|
| 278 | + unsigned int prepared:1; |
|---|
| 279 | + unsigned int copied_timestamp:1; |
|---|
| 264 | 280 | unsigned int need_cache_sync_on_prepare:1; |
|---|
| 265 | 281 | unsigned int need_cache_sync_on_finish:1; |
|---|
| 266 | 282 | |
|---|
| .. | .. |
|---|
| 288 | 304 | u32 cnt_mem_num_users; |
|---|
| 289 | 305 | u32 cnt_mem_mmap; |
|---|
| 290 | 306 | |
|---|
| 307 | + u32 cnt_buf_out_validate; |
|---|
| 291 | 308 | u32 cnt_buf_init; |
|---|
| 292 | 309 | u32 cnt_buf_prepare; |
|---|
| 293 | 310 | u32 cnt_buf_finish; |
|---|
| 294 | 311 | u32 cnt_buf_cleanup; |
|---|
| 295 | 312 | u32 cnt_buf_queue; |
|---|
| 313 | + u32 cnt_buf_request_complete; |
|---|
| 296 | 314 | |
|---|
| 297 | 315 | /* This counts the number of calls to vb2_buffer_done() */ |
|---|
| 298 | 316 | u32 cnt_buf_done; |
|---|
| .. | .. |
|---|
| 333 | 351 | * @wait_finish: reacquire all locks released in the previous callback; |
|---|
| 334 | 352 | * required to continue operation after sleeping while |
|---|
| 335 | 353 | * waiting for a new buffer to arrive. |
|---|
| 354 | + * @buf_out_validate: called when the output buffer is prepared or queued |
|---|
| 355 | + * to a request; drivers can use this to validate |
|---|
| 356 | + * userspace-provided information; this is required only |
|---|
| 357 | + * for OUTPUT queues. |
|---|
| 336 | 358 | * @buf_init: called once after allocating a buffer (in MMAP case) |
|---|
| 337 | 359 | * or after acquiring a new USERPTR buffer; drivers may |
|---|
| 338 | 360 | * perform additional buffer-related initialization; |
|---|
| .. | .. |
|---|
| 367 | 389 | * driver can return an error if hardware fails, in that |
|---|
| 368 | 390 | * case all buffers that have been already given by |
|---|
| 369 | 391 | * the @buf_queue callback are to be returned by the driver |
|---|
| 370 | | - * by calling vb2_buffer_done() with %VB2_BUF_STATE_QUEUED |
|---|
| 371 | | - * or %VB2_BUF_STATE_REQUEUEING. If you need a minimum |
|---|
| 372 | | - * number of buffers before you can start streaming, then |
|---|
| 373 | | - * set &vb2_queue->min_buffers_needed. If that is non-zero |
|---|
| 392 | + * by calling vb2_buffer_done() with %VB2_BUF_STATE_QUEUED. |
|---|
| 393 | + * If you need a minimum number of buffers before you can |
|---|
| 394 | + * start streaming, then set |
|---|
| 395 | + * &vb2_queue->min_buffers_needed. If that is non-zero |
|---|
| 374 | 396 | * then @start_streaming won't be called until at least |
|---|
| 375 | 397 | * that many buffers have been queued up by userspace. |
|---|
| 376 | 398 | * @stop_streaming: called when 'streaming' state must be disabled; driver |
|---|
| .. | .. |
|---|
| 382 | 404 | * @buf_queue: passes buffer vb to the driver; driver may start |
|---|
| 383 | 405 | * hardware operation on this buffer; driver should give |
|---|
| 384 | 406 | * the buffer back by calling vb2_buffer_done() function; |
|---|
| 385 | | - * it is allways called after calling VIDIOC_STREAMON() |
|---|
| 407 | + * it is always called after calling VIDIOC_STREAMON() |
|---|
| 386 | 408 | * ioctl; might be called before @start_streaming callback |
|---|
| 387 | 409 | * if user pre-queued buffers before calling |
|---|
| 388 | 410 | * VIDIOC_STREAMON(). |
|---|
| 411 | + * @buf_request_complete: a buffer that was never queued to the driver but is |
|---|
| 412 | + * associated with a queued request was canceled. |
|---|
| 413 | + * The driver will have to mark associated objects in the |
|---|
| 414 | + * request as completed; required if requests are |
|---|
| 415 | + * supported. |
|---|
| 389 | 416 | */ |
|---|
| 390 | 417 | struct vb2_ops { |
|---|
| 391 | 418 | int (*queue_setup)(struct vb2_queue *q, |
|---|
| .. | .. |
|---|
| 395 | 422 | void (*wait_prepare)(struct vb2_queue *q); |
|---|
| 396 | 423 | void (*wait_finish)(struct vb2_queue *q); |
|---|
| 397 | 424 | |
|---|
| 425 | + int (*buf_out_validate)(struct vb2_buffer *vb); |
|---|
| 398 | 426 | int (*buf_init)(struct vb2_buffer *vb); |
|---|
| 399 | 427 | int (*buf_prepare)(struct vb2_buffer *vb); |
|---|
| 400 | 428 | void (*buf_finish)(struct vb2_buffer *vb); |
|---|
| .. | .. |
|---|
| 404 | 432 | void (*stop_streaming)(struct vb2_queue *q); |
|---|
| 405 | 433 | |
|---|
| 406 | 434 | void (*buf_queue)(struct vb2_buffer *vb); |
|---|
| 435 | + |
|---|
| 436 | + void (*buf_request_complete)(struct vb2_buffer *vb); |
|---|
| 407 | 437 | }; |
|---|
| 408 | 438 | |
|---|
| 409 | 439 | /** |
|---|
| .. | .. |
|---|
| 412 | 442 | * @verify_planes_array: Verify that a given user space structure contains |
|---|
| 413 | 443 | * enough planes for the buffer. This is called |
|---|
| 414 | 444 | * for each dequeued buffer. |
|---|
| 445 | + * @init_buffer: given a &vb2_buffer initialize the extra data after |
|---|
| 446 | + * struct vb2_buffer. |
|---|
| 447 | + * For V4L2 this is a &struct vb2_v4l2_buffer. |
|---|
| 415 | 448 | * @fill_user_buffer: given a &vb2_buffer fill in the userspace structure. |
|---|
| 416 | 449 | * For V4L2 this is a &struct v4l2_buffer. |
|---|
| 417 | 450 | * @fill_vb2_buffer: given a userspace structure, fill in the &vb2_buffer. |
|---|
| .. | .. |
|---|
| 422 | 455 | */ |
|---|
| 423 | 456 | struct vb2_buf_ops { |
|---|
| 424 | 457 | int (*verify_planes_array)(struct vb2_buffer *vb, const void *pb); |
|---|
| 458 | + void (*init_buffer)(struct vb2_buffer *vb); |
|---|
| 425 | 459 | void (*fill_user_buffer)(struct vb2_buffer *vb, void *pb); |
|---|
| 426 | | - int (*fill_vb2_buffer)(struct vb2_buffer *vb, const void *pb, |
|---|
| 427 | | - struct vb2_plane *planes); |
|---|
| 460 | + int (*fill_vb2_buffer)(struct vb2_buffer *vb, struct vb2_plane *planes); |
|---|
| 428 | 461 | void (*copy_timestamp)(struct vb2_buffer *vb, const void *pb); |
|---|
| 429 | 462 | }; |
|---|
| 430 | 463 | |
|---|
| .. | .. |
|---|
| 455 | 488 | * @quirk_poll_must_check_waiting_for_buffers: Return %EPOLLERR at poll when QBUF |
|---|
| 456 | 489 | * has not been called. This is a vb1 idiom that has been adopted |
|---|
| 457 | 490 | * also by vb2. |
|---|
| 491 | + * @supports_requests: this queue supports the Request API. |
|---|
| 492 | + * @requires_requests: this queue requires the Request API. If this is set to 1, |
|---|
| 493 | + * then supports_requests must be set to 1 as well. |
|---|
| 494 | + * @uses_qbuf: qbuf was used directly for this queue. Set to 1 the first |
|---|
| 495 | + * time this is called. Set to 0 when the queue is canceled. |
|---|
| 496 | + * If this is 1, then you cannot queue buffers from a request. |
|---|
| 497 | + * @uses_requests: requests are used for this queue. Set to 1 the first time |
|---|
| 498 | + * a request is queued. Set to 0 when the queue is canceled. |
|---|
| 499 | + * If this is 1, then you cannot queue buffers directly. |
|---|
| 458 | 500 | * @allow_cache_hints: when set user-space can pass cache management hints in |
|---|
| 459 | 501 | * order to skip cache flush/invalidation on ->prepare() or/and |
|---|
| 460 | 502 | * ->finish(). |
|---|
| .. | .. |
|---|
| 472 | 514 | * @buf_ops: callbacks to deliver buffer information. |
|---|
| 473 | 515 | * between user-space and kernel-space. |
|---|
| 474 | 516 | * @drv_priv: driver private data. |
|---|
| 517 | + * @subsystem_flags: Flags specific to the subsystem (V4L2/DVB/etc.). Not used |
|---|
| 518 | + * by the vb2 core. |
|---|
| 475 | 519 | * @buf_struct_size: size of the driver-specific buffer structure; |
|---|
| 476 | 520 | * "0" indicates the driver doesn't want to use a custom buffer |
|---|
| 477 | | - * structure type. for example, ``sizeof(struct vb2_v4l2_buffer)`` |
|---|
| 478 | | - * will be used for v4l2. |
|---|
| 521 | + * structure type. In that case a subsystem-specific struct |
|---|
| 522 | + * will be used (in the case of V4L2 that is |
|---|
| 523 | + * ``sizeof(struct vb2_v4l2_buffer)``). The first field of the |
|---|
| 524 | + * driver-specific buffer structure must be the subsystem-specific |
|---|
| 525 | + * struct (vb2_v4l2_buffer in the case of V4L2). |
|---|
| 479 | 526 | * @timestamp_flags: Timestamp flags; ``V4L2_BUF_FLAG_TIMESTAMP_*`` and |
|---|
| 480 | 527 | * ``V4L2_BUF_FLAG_TSTAMP_SRC_*`` |
|---|
| 481 | 528 | * @gfp_flags: additional gfp flags used when allocating the buffers. |
|---|
| .. | .. |
|---|
| 514 | 561 | * when a buffer with the %V4L2_BUF_FLAG_LAST is dequeued. |
|---|
| 515 | 562 | * @fileio: file io emulator internal data, used only if emulator is active |
|---|
| 516 | 563 | * @threadio: thread io internal data, used only if thread is active |
|---|
| 564 | + * @name: queue name, used for logging purpose. Initialized automatically |
|---|
| 565 | + * if left empty by drivers. |
|---|
| 517 | 566 | */ |
|---|
| 518 | 567 | struct vb2_queue { |
|---|
| 519 | 568 | unsigned int type; |
|---|
| 520 | 569 | unsigned int io_modes; |
|---|
| 521 | 570 | struct device *dev; |
|---|
| 522 | 571 | unsigned long dma_attrs; |
|---|
| 523 | | - unsigned bidirectional:1; |
|---|
| 524 | | - unsigned fileio_read_once:1; |
|---|
| 525 | | - unsigned fileio_write_immediately:1; |
|---|
| 526 | | - unsigned allow_zero_bytesused:1; |
|---|
| 527 | | - unsigned quirk_poll_must_check_waiting_for_buffers:1; |
|---|
| 572 | + unsigned int bidirectional:1; |
|---|
| 573 | + unsigned int fileio_read_once:1; |
|---|
| 574 | + unsigned int fileio_write_immediately:1; |
|---|
| 575 | + unsigned int allow_zero_bytesused:1; |
|---|
| 576 | + unsigned int quirk_poll_must_check_waiting_for_buffers:1; |
|---|
| 577 | + unsigned int supports_requests:1; |
|---|
| 578 | + unsigned int requires_requests:1; |
|---|
| 579 | + unsigned int uses_qbuf:1; |
|---|
| 580 | + unsigned int uses_requests:1; |
|---|
| 528 | 581 | unsigned int allow_cache_hints:1; |
|---|
| 529 | 582 | |
|---|
| 530 | 583 | struct mutex *lock; |
|---|
| .. | .. |
|---|
| 535 | 588 | const struct vb2_buf_ops *buf_ops; |
|---|
| 536 | 589 | |
|---|
| 537 | 590 | void *drv_priv; |
|---|
| 591 | + u32 subsystem_flags; |
|---|
| 538 | 592 | unsigned int buf_struct_size; |
|---|
| 539 | 593 | u32 timestamp_flags; |
|---|
| 540 | 594 | gfp_t gfp_flags; |
|---|
| .. | .. |
|---|
| 569 | 623 | |
|---|
| 570 | 624 | struct vb2_fileio_data *fileio; |
|---|
| 571 | 625 | struct vb2_threadio_data *threadio; |
|---|
| 626 | + |
|---|
| 627 | + char name[32]; |
|---|
| 572 | 628 | |
|---|
| 573 | 629 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
|---|
| 574 | 630 | /* |
|---|
| .. | .. |
|---|
| 626 | 682 | * @state: state of the buffer, as defined by &enum vb2_buffer_state. |
|---|
| 627 | 683 | * Either %VB2_BUF_STATE_DONE if the operation finished |
|---|
| 628 | 684 | * successfully, %VB2_BUF_STATE_ERROR if the operation finished |
|---|
| 629 | | - * with an error or any of %VB2_BUF_STATE_QUEUED or |
|---|
| 630 | | - * %VB2_BUF_STATE_REQUEUEING if the driver wants to |
|---|
| 631 | | - * requeue buffers (see below). |
|---|
| 685 | + * with an error or %VB2_BUF_STATE_QUEUED. |
|---|
| 632 | 686 | * |
|---|
| 633 | 687 | * This function should be called by the driver after a hardware operation on |
|---|
| 634 | 688 | * a buffer is finished and the buffer may be returned to userspace. The driver |
|---|
| .. | .. |
|---|
| 639 | 693 | * While streaming a buffer can only be returned in state DONE or ERROR. |
|---|
| 640 | 694 | * The &vb2_ops->start_streaming op can also return them in case the DMA engine |
|---|
| 641 | 695 | * cannot be started for some reason. In that case the buffers should be |
|---|
| 642 | | - * returned with state QUEUED or REQUEUEING to put them back into the queue. |
|---|
| 643 | | - * |
|---|
| 644 | | - * %VB2_BUF_STATE_REQUEUEING is like %VB2_BUF_STATE_QUEUED, but it also calls |
|---|
| 645 | | - * &vb2_ops->buf_queue to queue buffers back to the driver. Note that calling |
|---|
| 646 | | - * vb2_buffer_done(..., VB2_BUF_STATE_REQUEUEING) from interrupt context will |
|---|
| 647 | | - * result in &vb2_ops->buf_queue being called in interrupt context as well. |
|---|
| 696 | + * returned with state QUEUED to put them back into the queue. |
|---|
| 648 | 697 | */ |
|---|
| 649 | 698 | void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state); |
|---|
| 650 | 699 | |
|---|
| .. | .. |
|---|
| 719 | 768 | * Return: returns zero on success; an error code otherwise. |
|---|
| 720 | 769 | */ |
|---|
| 721 | 770 | int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, |
|---|
| 722 | | - unsigned int *count); |
|---|
| 771 | + unsigned int *count); |
|---|
| 723 | 772 | |
|---|
| 724 | 773 | /** |
|---|
| 725 | 774 | * vb2_core_create_bufs() - Allocate buffers and any required auxiliary structs |
|---|
| .. | .. |
|---|
| 742 | 791 | * Return: returns zero on success; an error code otherwise. |
|---|
| 743 | 792 | */ |
|---|
| 744 | 793 | int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory, |
|---|
| 745 | | - unsigned int *count, unsigned int requested_planes, |
|---|
| 794 | + unsigned int *count, |
|---|
| 795 | + unsigned int requested_planes, |
|---|
| 746 | 796 | const unsigned int requested_sizes[]); |
|---|
| 747 | 797 | |
|---|
| 748 | 798 | /** |
|---|
| .. | .. |
|---|
| 774 | 824 | * @index: id number of the buffer |
|---|
| 775 | 825 | * @pb: buffer structure passed from userspace to |
|---|
| 776 | 826 | * v4l2_ioctl_ops->vidioc_qbuf handler in driver |
|---|
| 827 | + * @req: pointer to &struct media_request, may be NULL. |
|---|
| 777 | 828 | * |
|---|
| 778 | 829 | * Videobuf2 core helper to implement VIDIOC_QBUF() operation. It is called |
|---|
| 779 | 830 | * internally by VB2 by an API-specific handler, like ``videobuf2-v4l2.h``. |
|---|
| 780 | 831 | * |
|---|
| 781 | 832 | * This function: |
|---|
| 782 | 833 | * |
|---|
| 834 | + * #) If @req is non-NULL, then the buffer will be bound to this |
|---|
| 835 | + * media request and it returns. The buffer will be prepared and |
|---|
| 836 | + * queued to the driver (i.e. the next two steps) when the request |
|---|
| 837 | + * itself is queued. |
|---|
| 783 | 838 | * #) if necessary, calls &vb2_ops->buf_prepare callback in the driver |
|---|
| 784 | 839 | * (if provided), in which driver-specific buffer initialization can |
|---|
| 785 | 840 | * be performed; |
|---|
| .. | .. |
|---|
| 788 | 843 | * |
|---|
| 789 | 844 | * Return: returns zero on success; an error code otherwise. |
|---|
| 790 | 845 | */ |
|---|
| 791 | | -int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb); |
|---|
| 846 | +int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb, |
|---|
| 847 | + struct media_request *req); |
|---|
| 792 | 848 | |
|---|
| 793 | 849 | /** |
|---|
| 794 | 850 | * vb2_core_dqbuf() - Dequeue a buffer to the userspace |
|---|
| .. | .. |
|---|
| 1121 | 1177 | return 0; |
|---|
| 1122 | 1178 | } |
|---|
| 1123 | 1179 | |
|---|
| 1180 | +#if defined(CONFIG_ARCH_ROCKCHIP) && IS_ENABLED(CONFIG_USB_F_UVC) |
|---|
| 1181 | +/** |
|---|
| 1182 | + * vb2_plane_data_offset() - return plane data_offset in bytes. |
|---|
| 1183 | + * @vb: pointer to &struct vb2_buffer to which the plane in |
|---|
| 1184 | + * question belongs to. |
|---|
| 1185 | + * @plane_no: plane number for which size should be returned. |
|---|
| 1186 | + */ |
|---|
| 1187 | +static inline unsigned long |
|---|
| 1188 | +vb2_plane_data_offset(struct vb2_buffer *vb, unsigned int plane_no) |
|---|
| 1189 | +{ |
|---|
| 1190 | + if (plane_no < vb->num_planes) |
|---|
| 1191 | + return vb->planes[plane_no].data_offset; |
|---|
| 1192 | + return 0; |
|---|
| 1193 | +} |
|---|
| 1194 | +#endif |
|---|
| 1195 | + |
|---|
| 1124 | 1196 | /** |
|---|
| 1125 | 1197 | * vb2_start_streaming_called() - return streaming status of driver. |
|---|
| 1126 | 1198 | * @q: pointer to &struct vb2_queue with videobuf2 queue. |
|---|
| .. | .. |
|---|
| 1137 | 1209 | static inline void vb2_clear_last_buffer_dequeued(struct vb2_queue *q) |
|---|
| 1138 | 1210 | { |
|---|
| 1139 | 1211 | q->last_buffer_dequeued = false; |
|---|
| 1212 | +} |
|---|
| 1213 | + |
|---|
| 1214 | +/** |
|---|
| 1215 | + * vb2_get_buffer() - get a buffer from a queue |
|---|
| 1216 | + * @q: pointer to &struct vb2_queue with videobuf2 queue. |
|---|
| 1217 | + * @index: buffer index |
|---|
| 1218 | + * |
|---|
| 1219 | + * This function obtains a buffer from a queue, by its index. |
|---|
| 1220 | + * Keep in mind that there is no refcounting involved in this |
|---|
| 1221 | + * operation, so the buffer lifetime should be taken into |
|---|
| 1222 | + * consideration. |
|---|
| 1223 | + */ |
|---|
| 1224 | +static inline struct vb2_buffer *vb2_get_buffer(struct vb2_queue *q, |
|---|
| 1225 | + unsigned int index) |
|---|
| 1226 | +{ |
|---|
| 1227 | + if (index < q->num_buffers) |
|---|
| 1228 | + return q->bufs[index]; |
|---|
| 1229 | + return NULL; |
|---|
| 1140 | 1230 | } |
|---|
| 1141 | 1231 | |
|---|
| 1142 | 1232 | /* |
|---|
| .. | .. |
|---|
| 1165 | 1255 | */ |
|---|
| 1166 | 1256 | int vb2_verify_memory_type(struct vb2_queue *q, |
|---|
| 1167 | 1257 | enum vb2_memory memory, unsigned int type); |
|---|
| 1258 | + |
|---|
| 1259 | +/** |
|---|
| 1260 | + * vb2_request_object_is_buffer() - return true if the object is a buffer |
|---|
| 1261 | + * |
|---|
| 1262 | + * @obj: the request object. |
|---|
| 1263 | + */ |
|---|
| 1264 | +bool vb2_request_object_is_buffer(struct media_request_object *obj); |
|---|
| 1265 | + |
|---|
| 1266 | +/** |
|---|
| 1267 | + * vb2_request_buffer_cnt() - return the number of buffers in the request |
|---|
| 1268 | + * |
|---|
| 1269 | + * @req: the request. |
|---|
| 1270 | + */ |
|---|
| 1271 | +unsigned int vb2_request_buffer_cnt(struct media_request *req); |
|---|
| 1272 | + |
|---|
| 1168 | 1273 | #endif /* _MEDIA_VIDEOBUF2_CORE_H */ |
|---|