]> git.ipfire.org Git - thirdparty/openwrt.git/blob
869d17d2e8aa5190fa3886a3ad990a2c8600393d
[thirdparty/openwrt.git] /
1 From 886f86f97c0b64322aec955f62d9b1fd3330304e Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 17 Apr 2024 15:46:43 +0100
4 Subject: [PATCH 1088/1135] staging: bcm2835_codec: Pass framerate to the
5 component if set late
6
7 For video encoding, if the framerate was set after the component
8 was created, then it wasn't set correctly on the port, and an
9 old value was encoded in the bitstream.
10
11 Update the port status when the framerate is set.
12
13 https://github.com/raspberrypi/rpicam-apps/issues/664
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 ---
17 .../bcm2835-codec/bcm2835-v4l2-codec.c | 42 ++++++++++++++++++-
18 1 file changed, 41 insertions(+), 1 deletion(-)
19
20 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
21 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
22 @@ -2038,6 +2038,9 @@ static int vidioc_s_parm(struct file *fi
23 struct v4l2_streamparm *parm)
24 {
25 struct bcm2835_codec_ctx *ctx = file2ctx(file);
26 + struct bcm2835_codec_q_data *q_data = &ctx->q_data[V4L2_M2M_DST];
27 + struct vchiq_mmal_port *port;
28 + int ret;
29
30 if (parm->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
31 return -EINVAL;
32 @@ -2053,7 +2056,44 @@ static int vidioc_s_parm(struct file *fi
33
34 parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
35
36 - return 0;
37 + /*
38 + * If we have a component then setup the port as well.
39 + * NB Framerate is passed to MMAL via the DST port, whilst V4L2 uses the
40 + * OUTPUT queue.
41 + */
42 + port = get_port_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
43 + if (!port)
44 + return 0;
45 +
46 + if (port->enabled) {
47 + struct s32_fract frame_rate = { ctx->framerate_num,
48 + ctx->framerate_denom };
49 +
50 + ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
51 + &ctx->component->output[0],
52 + MMAL_PARAMETER_VIDEO_FRAME_RATE,
53 + &frame_rate,
54 + sizeof(frame_rate));
55 +
56 + return ret;
57 + }
58 +
59 + setup_mmal_port_format(ctx, q_data, port);
60 + ret = vchiq_mmal_port_set_format(ctx->dev->instance, port);
61 + if (ret) {
62 + v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed vchiq_mmal_port_set_format on port, ret %d\n",
63 + __func__, ret);
64 + ret = -EINVAL;
65 + }
66 +
67 + if (q_data->sizeimage < port->minimum_buffer.size) {
68 + v4l2_err(&ctx->dev->v4l2_dev, "%s: Current buffer size of %u < min buf size %u - driver mismatch to MMAL\n",
69 + __func__, q_data->sizeimage,
70 + port->minimum_buffer.size);
71 + ret = -EINVAL;
72 + }
73 +
74 + return ret;
75 }
76
77 static int vidioc_g_parm(struct file *file, void *priv,