66a551d2d7da7fb550b7b2ebe5b38a4cd9e38c16
[openwrt/staging/noltari.git] /
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
6
7 start_streaming passes a count of how many buffers have been queued
8 to videobuf2.
9
10 Allow this value to update the number of buffers the VPU allocates
11 on a port to avoid buffer recycling issues.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
14 ---
15 .../bcm2835-codec/bcm2835-v4l2-codec.c | 23 +++++++++++++++----
16 1 file changed, 19 insertions(+), 4 deletions(-)
17
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);
25 int ret;
26
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;
30 }
31
32 + if (count < port->minimum_buffer.num)
33 + count = port->minimum_buffer.num;
34 +
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);
38 +
39 + port->current_buffer.num = count + 1;
40 + ret = vchiq_mmal_port_set_format(dev->instance, port);
41 + if (ret)
42 + v4l2_err(&ctx->dev->v4l2_dev, "%s: Error updating buffer count, ret %d\n",
43 + __func__, ret);
44 + }
45 +
46 if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
47 /*
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;
52
53 - ctx->component->input[0].cb_ctx = ctx;
54 + port->cb_ctx = ctx;
55 ret = vchiq_mmal_port_enable(dev->instance,
56 - &ctx->component->input[0],
57 + port,
58 ip_buffer_cb);
59 if (ret)
60 v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed enabling i/p port, ret %d\n",
61 __func__, ret);
62 } else {
63 - ctx->component->output[0].cb_ctx = ctx;
64 + port->cb_ctx = ctx;
65 ret = vchiq_mmal_port_enable(dev->instance,
66 - &ctx->component->output[0],
67 + port,
68 op_buffer_cb);
69 if (ret)
70 v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed enabling o/p port, ret %d\n",