1 From 84ab2b48fc6834e44ef2d6cec5b2d21285090f88 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Thu, 10 May 2018 12:42:10 -0700
4 Subject: [PATCH 370/454] staging: bcm2835-camera: Match MMAL buffer count to
7 commit 7cc31d57f399b00f96ce295d5b86426b95d9076f upstream.
9 For historical reasons, the number of buffers passed to the VPU over
10 MMAL did not match that passed from V4L2. That is a silly situation
11 as the driver has to duplicate serialisation and other functions that
12 have already been implemented in V4L2/videobuf2.
14 As we had more V4L2 buffers than MMAL ones, the MMAL buffer headers
15 were returned to the VPU immediately on being filled, which is now
18 Match the number of buffers notified in queue_setup with that used in
19 MMAL. Return buffers only when we get them from V4L2.
21 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
22 Signed-off-by: Eric Anholt <eric@anholt.net>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 .../bcm2835-camera/bcm2835-camera.c | 6 ++++--
26 .../vc04_services/bcm2835-camera/mmal-vchiq.c | 21 +------------------
27 .../vc04_services/bcm2835-camera/mmal-vchiq.h | 4 ----
28 3 files changed, 5 insertions(+), 26 deletions(-)
30 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
31 +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
32 @@ -262,8 +262,10 @@ static int queue_setup(struct vb2_queue
36 - if (*nbuffers < (dev->capture.port->current_buffer.num + 2))
37 - *nbuffers = (dev->capture.port->current_buffer.num + 2);
38 + if (*nbuffers < dev->capture.port->minimum_buffer.num)
39 + *nbuffers = dev->capture.port->minimum_buffer.num;
41 + dev->capture.port->current_buffer.num = *nbuffers;
45 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
46 +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c
47 @@ -548,7 +548,6 @@ static int port_buffer_from_host(struct
48 /* peek buffer from queue */
49 spin_lock_irqsave(&port->slock, flags);
50 if (list_empty(&port->buffers)) {
51 - port->buffer_underflow++;
52 spin_unlock_irqrestore(&port->slock, flags);
55 @@ -639,9 +638,6 @@ static void buffer_to_host_cb(struct vch
56 msg->u.buffer_from_host.payload_in_message;
59 - /* replace the buffer header */
60 - port_buffer_from_host(instance, msg_context->u.bulk.port);
62 /* schedule the port callback */
63 schedule_work(&msg_context->u.bulk.work);
65 @@ -649,10 +645,6 @@ static void buffer_to_host_cb(struct vch
66 static void bulk_receive_cb(struct vchiq_mmal_instance *instance,
67 struct mmal_msg_context *msg_context)
69 - /* replace the buffer header */
70 - port_buffer_from_host(msg_context->u.bulk.instance,
71 - msg_context->u.bulk.port);
73 msg_context->u.bulk.status = 0;
75 /* schedule the port callback */
76 @@ -664,10 +656,6 @@ static void bulk_abort_cb(struct vchiq_m
78 pr_err("%s: bulk ABORTED msg_context:%p\n", __func__, msg_context);
80 - /* replace the buffer header */
81 - port_buffer_from_host(msg_context->u.bulk.instance,
82 - msg_context->u.bulk.port);
84 msg_context->u.bulk.status = -EINTR;
86 schedule_work(&msg_context->u.bulk.work);
87 @@ -1718,14 +1706,7 @@ int vchiq_mmal_submit_buffer(struct vchi
88 list_add_tail(&buffer->list, &port->buffers);
89 spin_unlock_irqrestore(&port->slock, flags);
91 - /* the port previously underflowed because it was missing a
92 - * mmal_buffer which has just been added, submit that buffer
93 - * to the mmal service.
95 - if (port->buffer_underflow) {
96 - port_buffer_from_host(instance, port);
97 - port->buffer_underflow--;
99 + port_buffer_from_host(instance, port);
103 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
104 +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h
105 @@ -82,10 +82,6 @@ struct vchiq_mmal_port {
106 struct list_head buffers;
107 /* lock to serialise adding and removing buffers from list */
109 - /* count of how many buffer header refils have failed because
110 - * there was no buffer to satisfy them
112 - int buffer_underflow;
113 /* callback on buffer completion */
114 vchiq_mmal_buffer_cb buffer_cb;
115 /* callback context */