1 From d88ef7d22cac032c4ddf7e4b8af5982d5a3019cb Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 13 Aug 2020 17:01:27 +0100
4 Subject: [PATCH] staging: vc04_service: codec: Allow start_streaming
5 to update the buffernum
7 start_streaming passes a count of how many buffers have been queued
10 Allow this value to update the number of buffers the VPU allocates
11 on a port to avoid buffer recycling issues.
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 .../bcm2835-codec/bcm2835-v4l2-codec.c | 23 +++++++++++++++----
16 1 file changed, 19 insertions(+), 4 deletions(-)
18 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
19 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
20 @@ -2268,6 +2268,7 @@ static int bcm2835_codec_start_streaming
21 struct bcm2835_codec_ctx *ctx = vb2_get_drv_priv(q);
22 struct bcm2835_codec_dev *dev = ctx->dev;
23 struct bcm2835_codec_q_data *q_data = get_q_data(ctx, q->type);
24 + struct vchiq_mmal_port *port = get_port_data(ctx, q->type);
27 v4l2_dbg(1, debug, &ctx->dev->v4l2_dev, "%s: type: %d count %d\n",
28 @@ -2283,6 +2284,20 @@ static int bcm2835_codec_start_streaming
29 ctx->component_enabled = true;
32 + if (count < port->minimum_buffer.num)
33 + count = port->minimum_buffer.num;
35 + if (port->current_buffer.num != count + 1) {
36 + v4l2_dbg(2, debug, &ctx->dev->v4l2_dev, "%s: ctx:%p, buffer count changed %u to %u\n",
37 + __func__, ctx, port->current_buffer.num, count + 1);
39 + port->current_buffer.num = count + 1;
40 + ret = vchiq_mmal_port_set_format(dev->instance, port);
42 + v4l2_err(&ctx->dev->v4l2_dev, "%s: Error updating buffer count, ret %d\n",
46 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
48 * Create the EOS buffer.
49 @@ -2294,17 +2309,17 @@ static int bcm2835_codec_start_streaming
50 &q_data->eos_buffer.mmal);
51 q_data->eos_buffer_in_use = false;
53 - ctx->component->input[0].cb_ctx = ctx;
55 ret = vchiq_mmal_port_enable(dev->instance,
56 - &ctx->component->input[0],
60 v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed enabling i/p port, ret %d\n",
63 - ctx->component->output[0].cb_ctx = ctx;
65 ret = vchiq_mmal_port_enable(dev->instance,
66 - &ctx->component->output[0],
70 v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed enabling o/p port, ret %d\n",