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
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.
11 Update the port status when the framerate is set.
13 https://github.com/raspberrypi/rpicam-apps/issues/664
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 .../bcm2835-codec/bcm2835-v4l2-codec.c | 42 ++++++++++++++++++-
18 1 file changed, 41 insertions(+), 1 deletion(-)
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)
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;
30 if (parm->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
32 @@ -2053,7 +2056,44 @@ static int vidioc_s_parm(struct file *fi
34 parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
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
42 + port = get_port_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
46 + if (port->enabled) {
47 + struct s32_fract frame_rate = { ctx->framerate_num,
48 + ctx->framerate_denom };
50 + ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
51 + &ctx->component->output[0],
52 + MMAL_PARAMETER_VIDEO_FRAME_RATE,
54 + sizeof(frame_rate));
59 + setup_mmal_port_format(ctx, q_data, port);
60 + ret = vchiq_mmal_port_set_format(ctx->dev->instance, port);
62 + v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed vchiq_mmal_port_set_format on port, ret %d\n",
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);
77 static int vidioc_g_parm(struct file *file, void *priv,