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 | 116 | - ``flags`` |
| 117 | 117 | - Specifies additional buffer management attributes. |
| 118 | 118 | See :ref:`memory-flags`. |
| 119 | − | |
| 120 | 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 | 126 | - A place holder for future extensions. Drivers and applications |
| 123 | 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 | 120 | .. _V4L2-BUF-CAP-SUPPORTS-ORPHANED-BUFS: |
| 121 | 121 | .. _V4L2-BUF-CAP-SUPPORTS-M2M-HOLD-CAPTURE-BUF: |
| 122 | 122 | .. _V4L2-BUF-CAP-SUPPORTS-MMAP-CACHE-HINTS: |
| 123 | +.. _V4L2-BUF-CAP-SUPPORTS-MAX-NUM-BUFFERS: | |
| 123 | 124 | |
| 124 | 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 | 756 | fill_buf_caps(q, &create->capabilities); |
| 757 | 757 | validate_memory_flags(q, create->memory, &create->flags); |
| 758 | 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 | 761 | if (create->count == 0) |
| 760 | 762 | return ret != -EBUSY ? ret : 0; |
| 761 | 763 | |
| @@ -116,6 +116,9 @@ struct v4l2_format32 { · 115 unmodified lines | ||
| 116 | 116 | * @flags: additional buffer management attributes (ignored unless the |
| 117 | 117 | * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability and |
| 118 | 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 | 122 | * @reserved: future extensions |
| 120 | 123 | */ |
| 121 | 124 | struct v4l2_create_buffers32 { |
| @@ -125,7 +128,8 @@ struct v4l2_create_buffers32 { · 3 unmodified lines | ||
| 125 | 128 | struct v4l2_format32 format; |
| 126 | 129 | __u32 capabilities; |
| 127 | 130 | __u32 flags; |
| 128 | − __u32 reserved[6]; | |
| 131 | + __u32 max_num_buffers; | |
| 132 | + __u32 reserved[5]; | |
| 129 | 133 | }; |
| 130 | 134 | |
| 131 | 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 | 179 | return -EFAULT; |
| 176 | 180 | if (copy_from_user(&p64->flags, &p32->flags, sizeof(p32->flags))) |
| 177 | 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 | 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 | 228 | offsetof(struct v4l2_create_buffers32, format)) || |
| 222 | 229 | put_user(p64->capabilities, &p32->capabilities) || |
| 223 | 230 | put_user(p64->flags, &p32->flags) || |
| 231 | + put_user(p64->max_num_buffers, &p32->max_num_buffers) || | |
| 224 | 232 | copy_to_user(p32->reserved, p64->reserved, sizeof(p64->reserved))) |
| 225 | 233 | return -EFAULT; |
| 226 | 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 | 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 | 487 | p->index, p->count, prt_names(p->memory, v4l2_memory_names), |
| 488 | − p->capabilities); | |
| 488 | + p->capabilities, p->max_num_buffers); | |
| 489 | 489 | v4l_print_format(&p->format, write_only); |
| 490 | 490 | } |
| 491 | 491 | |
| @@ -1035,6 +1035,7 @@ struct v4l2_requestbuffers { · 1034 unmodified lines | ||
| 1035 | 1035 | #define V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS (1 << 4) |
| 1036 | 1036 | #define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5) |
| 1037 | 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 | 1041 | * struct v4l2_plane - plane info for multi-planar buffers |
| @@ -2605,6 +2606,9 @@ struct v4l2_dbg_chip_info { · 1564 unmodified lines | ||
| 2605 | 2606 | * @flags: additional buffer management attributes (ignored unless the |
| 2606 | 2607 | * queue has V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability |
| 2607 | 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 | 2612 | * @reserved: future extensions |
| 2609 | 2613 | */ |
| 2610 | 2614 | struct v4l2_create_buffers { |
| @@ -2614,7 +2618,8 @@ struct v4l2_create_buffers { · 3 unmodified lines | ||
| 2614 | 2618 | struct v4l2_format format; |
| 2615 | 2619 | __u32 capabilities; |
| 2616 | 2620 | __u32 flags; |
| 2617 | − __u32 reserved[6]; | |
| 2621 | + __u32 max_num_buffers; | |
| 2622 | + __u32 reserved[5]; | |
| 2618 | 2623 | }; |
| 2619 | 2624 | |
| 2620 | 2625 | /* |