Use one of the struct v4l2_create_buffers reserved bytes to report the maximum possible number of buffers for the queue. V4l2 framework set V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS flags in queue capabilities so userland can know when the field is valid. Does the same change in v4l2_create_buffers32 structure.
Unified · Split
| @@ -116,9 +116,13 @@ than the number requested. · 115 unmodified lines | |||
| 116 | - ``flags`` | 116 | - ``flags`` |
| 117 | - Specifies additional buffer management attributes. | 117 | - Specifies additional buffer management attributes. |
| 118 | See :ref:`memory-flags`. | 118 | See :ref:`memory-flags`. |
| 119 | |||
| 120 | * - __u32 | 119 | * - __u32 |
| 121 | - ``reserved``\ [6] | 120 | - ``max_num_buffers`` |
| 121 | - If the V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set | ||
| 122 | this field indicates the maximum possible number of buffers | ||
| 123 | for this queue. | ||
| 124 | * - __u32 | ||
| 125 | - ``reserved``\ [5] | ||
| 122 | - A place holder for future extensions. Drivers and applications | 126 | - A place holder for future extensions. Drivers and applications |
| 123 | must set the array to zero. | 127 | must set the array to zero. |
| 124 | 128 | ||
| @@ -120,6 +120,7 @@ aborting or finishing any DMA in progress, an implicit · 119 unmodified lines | |||
| 120 | .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS: | 120 | .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS: |
| 121 | .. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF: | 121 | .. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF: |
| 122 | .. _V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS: | 122 | .. _V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS: |
| 123 | .. _V4L2-BUF-CAP-SUPPORTS-MAX-NUM-BUFFERS: | ||
| 123 | 124 | ||
| 124 | .. raw:: latex | 125 | .. raw:: latex |
| 125 | 126 | ||
| @@ -756,6 +756,8 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create) · 755 unmodified lines | |||
| 756 | fill_buf_caps(q, &create->capabilities); | 756 | fill_buf_caps(q, &create->capabilities); |
| 757 | validate_memory_flags(q, create->memory, &create->flags); | 757 | validate_memory_flags(q, create->memory, &create->flags); |
| 758 | create->index = vb2_get_num_buffers(q); | 758 | create->index = vb2_get_num_buffers(q); |
| 759 | create->max_num_buffers = q->max_num_buffers; | ||
| 760 | create->capabilities |= V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS; | ||
| 759 | if (create->count == 0) | 761 | if (create->count == 0) |
| 760 | return ret != -EBUSY ? ret : 0; | 762 | return ret != -EBUSY ? ret : 0; |
| 761 | 763 | ||
| @@ -116,6 +116,9 @@ struct v4l2_format32 { · 115 unmodified lines | |||
| 116 | * @flags: additional buffer management attributes (ignored unless the | 116 | * @flags: additional buffer management attributes (ignored unless the |
| 117 | * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability and | 117 | * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability and |
| 118 | * configured for MMAP streaming I/O). | 118 | * configured for MMAP streaming I/O). |
| 119 | * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set | ||
| 120 | * this field indicate the maximum possible number of buffers | ||
| 121 | * for this queue. | ||
| 119 | * @reserved: future extensions | 122 | * @reserved: future extensions |
| 120 | */ | 123 | */ |
| 121 | struct v4l2_create_buffers32 { | 124 | struct v4l2_create_buffers32 { |
| @@ -125,7 +128,8 @@ struct v4l2_create_buffers32 { · 3 unmodified lines | |||
| 125 | struct v4l2_format32 format; | 128 | struct v4l2_format32 format; |
| 126 | __u32 capabilities; | 129 | __u32 capabilities; |
| 127 | __u32 flags; | 130 | __u32 flags; |
| 128 | __u32 reserved[6]; | 131 | __u32 max_num_buffers; |
| 132 | __u32 reserved[5]; | ||
| 129 | }; | 133 | }; |
| 130 | 134 | ||
| 131 | static int get_v4l2_format32(struct v4l2_format *p64, | 135 | static int get_v4l2_format32(struct v4l2_format *p64, |
| @@ -175,6 +179,9 @@ static int get_v4l2_create32(struct v4l2_create_buffers *p64, · 43 unmodified lines | |||
| 175 | return -EFAULT; | 179 | return -EFAULT; |
| 176 | if (copy_from_user(&p64->flags, &p32->flags, sizeof(p32->flags))) | 180 | if (copy_from_user(&p64->flags, &p32->flags, sizeof(p32->flags))) |
| 177 | return -EFAULT; | 181 | return -EFAULT; |
| 182 | if (copy_from_user(&p64->max_num_buffers, &p32->max_num_buffers, | ||
| 183 | sizeof(p32->max_num_buffers))) | ||
| 184 | return -EFAULT; | ||
| 178 | return get_v4l2_format32(&p64->format, &p32->format); | 185 | return get_v4l2_format32(&p64->format, &p32->format); |
| 179 | } | 186 | } |
| 180 | 187 | ||
| @@ -221,6 +228,7 @@ static int put_v4l2_create32(struct v4l2_create_buffers *p64, · 40 unmodified lines | |||
| 221 | offsetof(struct v4l2_create_buffers32, format)) || | 228 | offsetof(struct v4l2_create_buffers32, format)) || |
| 222 | put_user(p64->capabilities, &p32->capabilities) || | 229 | put_user(p64->capabilities, &p32->capabilities) || |
| 223 | put_user(p64->flags, &p32->flags) || | 230 | put_user(p64->flags, &p32->flags) || |
| 231 | put_user(p64->max_num_buffers, &p32->max_num_buffers) || | ||
| 224 | copy_to_user(p32->reserved, p64->reserved, sizeof(p64->reserved))) | 232 | copy_to_user(p32->reserved, p64->reserved, sizeof(p64->reserved))) |
| 225 | return -EFAULT; | 233 | return -EFAULT; |
| 226 | return put_v4l2_format32(&p64->format, &p32->format); | 234 | return put_v4l2_format32(&p64->format, &p32->format); |
| @@ -483,9 +483,9 @@ static void v4l_print_create_buffers(const void *arg, bool write_only) · 482 unmodified lines | |||
| 483 | { | 483 | { |
| 484 | const struct v4l2_create_buffers *p = arg; | 484 | const struct v4l2_create_buffers *p = arg; |
| 485 | 485 | ||
| 486 | pr_cont("index=%d, count=%d, memory=%s, capabilities=0x%08x, ", | 486 | pr_cont("index=%d, count=%d, memory=%s, capabilities=0x%08x, max num buffers=%u", |
| 487 | p->index, p->count, prt_names(p->memory, v4l2_memory_names), | 487 | p->index, p->count, prt_names(p->memory, v4l2_memory_names), |
| 488 | p->capabilities); | 488 | p->capabilities, p->max_num_buffers); |
| 489 | v4l_print_format(&p->format, write_only); | 489 | v4l_print_format(&p->format, write_only); |
| 490 | } | 490 | } |
| 491 | 491 | ||
| @@ -1035,6 +1035,7 @@ struct v4l2_requestbuffers { · 1034 unmodified lines | |||
| 1035 | #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) | 1035 | #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) |
| 1036 | #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) | 1036 | #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) |
| 1037 | #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6) | 1037 | #define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6) |
| 1038 | #define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS (1 << 7) | ||
| 1038 | 1039 | ||
| 1039 | /** | 1040 | /** |
| 1040 | * struct v4l2_plane - plane info for multi-planar buffers | 1041 | * struct v4l2_plane - plane info for multi-planar buffers |
| @@ -2605,6 +2606,9 @@ struct v4l2_dbg_chip_info { · 1564 unmodified lines | |||
| 2605 | * @flags: additional buffer management attributes (ignored unless the | 2606 | * @flags: additional buffer management attributes (ignored unless the |
| 2606 | * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability | 2607 | * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability |
| 2607 | * and configured for MMAP streaming I/O). | 2608 | * and configured for MMAP streaming I/O). |
| 2609 | * @max_num_buffers: if V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set | ||
| 2610 | * this field indicate the maximum possible number of buffers | ||
| 2611 | * for this queue. | ||
| 2608 | * @reserved: future extensions | 2612 | * @reserved: future extensions |
| 2609 | */ | 2613 | */ |
| 2610 | struct v4l2_create_buffers { | 2614 | struct v4l2_create_buffers { |
| @@ -2614,7 +2618,8 @@ struct v4l2_create_buffers { · 3 unmodified lines | |||
| 2614 | struct v4l2_format format; | 2618 | struct v4l2_format format; |
| 2615 | __u32 capabilities; | 2619 | __u32 capabilities; |
| 2616 | __u32 flags; | 2620 | __u32 flags; |
| 2617 | __u32 reserved[6]; | 2621 | __u32 max_num_buffers; |
| 2622 | __u32 reserved[5]; | ||
| 2618 | }; | 2623 | }; |
| 2619 | 2624 | ||
| 2620 | /* | 2625 | /* |