Skip to content

Commit 4aeb083

Browse files
committed
Merge tag 'media/v6.8-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab: - remove K3 DT prefix from wave5 - vb2 core: fix missing caps on VIDIO_CREATE_BUFS under certain circumstances - videobuf2: Stop direct calls to queue num_buffers field * tag 'media/v6.8-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: media: vb2: refactor setting flags and caps, fix missing cap media: media videobuf2: Stop direct calls to queue num_buffers field media: chips-media: wave5: Remove K3 References dt-bindings: media: Remove K3 Family Prefix from Compatible
2 parents ecb1b82 + b32431b commit 4aeb083

File tree

4 files changed

+30
-33
lines changed

4 files changed

+30
-33
lines changed

Documentation/devicetree/bindings/media/cnm,wave521c.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ properties:
1717
compatible:
1818
items:
1919
- enum:
20-
- ti,k3-j721s2-wave521c
20+
- ti,j721s2-wave521c
2121
- const: cnm,wave521c
2222

2323
reg:
@@ -53,7 +53,7 @@ additionalProperties: false
5353
examples:
5454
- |
5555
vpu: video-codec@12345678 {
56-
compatible = "ti,k3-j721s2-wave521c", "cnm,wave521c";
56+
compatible = "ti,j721s2-wave521c", "cnm,wave521c";
5757
reg = <0x12345678 0x1000>;
5858
clocks = <&clks 42>;
5959
interrupts = <42>;

drivers/media/common/videobuf2/videobuf2-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
989989
bool no_previous_buffers = !q_num_bufs;
990990
int ret = 0;
991991

992-
if (q->num_buffers == q->max_num_buffers) {
992+
if (q_num_bufs == q->max_num_buffers) {
993993
dprintk(q, 1, "maximum number of buffers already allocated\n");
994994
return -ENOBUFS;
995995
}

drivers/media/common/videobuf2/videobuf2-v4l2.c

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,20 @@ int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b)
671671
}
672672
EXPORT_SYMBOL(vb2_querybuf);
673673

674-
static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
674+
static void vb2_set_flags_and_caps(struct vb2_queue *q, u32 memory,
675+
u32 *flags, u32 *caps, u32 *max_num_bufs)
675676
{
677+
if (!q->allow_cache_hints || memory != V4L2_MEMORY_MMAP) {
678+
/*
679+
* This needs to clear V4L2_MEMORY_FLAG_NON_COHERENT only,
680+
* but in order to avoid bugs we zero out all bits.
681+
*/
682+
*flags = 0;
683+
} else {
684+
/* Clear all unknown flags. */
685+
*flags &= V4L2_MEMORY_FLAG_NON_COHERENT;
686+
}
687+
676688
*caps = V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS;
677689
if (q->io_modes & VB2_MMAP)
678690
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP;
@@ -686,21 +698,9 @@ static void fill_buf_caps(struct vb2_queue *q, u32 *caps)
686698
*caps |= V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS;
687699
if (q->supports_requests)
688700
*caps |= V4L2_BUF_CAP_SUPPORTS_REQUESTS;
689-
}
690-
691-
static void validate_memory_flags(struct vb2_queue *q,
692-
int memory,
693-
u32 *flags)
694-
{
695-
if (!q->allow_cache_hints || memory != V4L2_MEMORY_MMAP) {
696-
/*
697-
* This needs to clear V4L2_MEMORY_FLAG_NON_COHERENT only,
698-
* but in order to avoid bugs we zero out all bits.
699-
*/
700-
*flags = 0;
701-
} else {
702-
/* Clear all unknown flags. */
703-
*flags &= V4L2_MEMORY_FLAG_NON_COHERENT;
701+
if (max_num_bufs) {
702+
*max_num_bufs = q->max_num_buffers;
703+
*caps |= V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
704704
}
705705
}
706706

@@ -709,8 +709,8 @@ int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
709709
int ret = vb2_verify_memory_type(q, req->memory, req->type);
710710
u32 flags = req->flags;
711711

712-
fill_buf_caps(q, &req->capabilities);
713-
validate_memory_flags(q, req->memory, &flags);
712+
vb2_set_flags_and_caps(q, req->memory, &flags,
713+
&req->capabilities, NULL);
714714
req->flags = flags;
715715
return ret ? ret : vb2_core_reqbufs(q, req->memory,
716716
req->flags, &req->count);
@@ -751,11 +751,9 @@ int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)
751751
int ret = vb2_verify_memory_type(q, create->memory, f->type);
752752
unsigned i;
753753

754-
fill_buf_caps(q, &create->capabilities);
755-
validate_memory_flags(q, create->memory, &create->flags);
756754
create->index = vb2_get_num_buffers(q);
757-
create->max_num_buffers = q->max_num_buffers;
758-
create->capabilities |= V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS;
755+
vb2_set_flags_and_caps(q, create->memory, &create->flags,
756+
&create->capabilities, &create->max_num_buffers);
759757
if (create->count == 0)
760758
return ret != -EBUSY ? ret : 0;
761759

@@ -1006,8 +1004,8 @@ int vb2_ioctl_reqbufs(struct file *file, void *priv,
10061004
int res = vb2_verify_memory_type(vdev->queue, p->memory, p->type);
10071005
u32 flags = p->flags;
10081006

1009-
fill_buf_caps(vdev->queue, &p->capabilities);
1010-
validate_memory_flags(vdev->queue, p->memory, &flags);
1007+
vb2_set_flags_and_caps(vdev->queue, p->memory, &flags,
1008+
&p->capabilities, NULL);
10111009
p->flags = flags;
10121010
if (res)
10131011
return res;
@@ -1026,12 +1024,11 @@ int vb2_ioctl_create_bufs(struct file *file, void *priv,
10261024
struct v4l2_create_buffers *p)
10271025
{
10281026
struct video_device *vdev = video_devdata(file);
1029-
int res = vb2_verify_memory_type(vdev->queue, p->memory,
1030-
p->format.type);
1027+
int res = vb2_verify_memory_type(vdev->queue, p->memory, p->format.type);
10311028

1032-
p->index = vdev->queue->num_buffers;
1033-
fill_buf_caps(vdev->queue, &p->capabilities);
1034-
validate_memory_flags(vdev->queue, p->memory, &p->flags);
1029+
p->index = vb2_get_num_buffers(vdev->queue);
1030+
vb2_set_flags_and_caps(vdev->queue, p->memory, &p->flags,
1031+
&p->capabilities, &p->max_num_buffers);
10351032
/*
10361033
* If count == 0, then just check if memory and type are valid.
10371034
* Any -EBUSY result from vb2_verify_memory_type can be mapped to 0.

drivers/media/platform/chips-media/wave5/wave5-vpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static const struct wave5_match_data ti_wave521c_data = {
272272
};
273273

274274
static const struct of_device_id wave5_dt_ids[] = {
275-
{ .compatible = "ti,k3-j721s2-wave521c", .data = &ti_wave521c_data },
275+
{ .compatible = "ti,j721s2-wave521c", .data = &ti_wave521c_data },
276276
{ /* sentinel */ }
277277
};
278278
MODULE_DEVICE_TABLE(of, wave5_dt_ids);

0 commit comments

Comments
 (0)