Skip to content

Commit 886f86f

Browse files
6by9pelwell
authored andcommitted
staging: bcm2835_codec: Pass framerate to the component if set late
For video encoding, if the framerate was set after the component was created, then it wasn't set correctly on the port, and an old value was encoded in the bitstream. Update the port status when the framerate is set. raspberrypi/rpicam-apps#664 Signed-off-by: Dave Stevenson <[email protected]>
1 parent f0537b9 commit 886f86f

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,9 @@ static int vidioc_s_parm(struct file *file, void *priv,
20382038
struct v4l2_streamparm *parm)
20392039
{
20402040
struct bcm2835_codec_ctx *ctx = file2ctx(file);
2041+
struct bcm2835_codec_q_data *q_data = &ctx->q_data[V4L2_M2M_DST];
2042+
struct vchiq_mmal_port *port;
2043+
int ret;
20412044

20422045
if (parm->type != V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
20432046
return -EINVAL;
@@ -2053,7 +2056,44 @@ static int vidioc_s_parm(struct file *file, void *priv,
20532056

20542057
parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
20552058

2056-
return 0;
2059+
/*
2060+
* If we have a component then setup the port as well.
2061+
* NB Framerate is passed to MMAL via the DST port, whilst V4L2 uses the
2062+
* OUTPUT queue.
2063+
*/
2064+
port = get_port_data(ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
2065+
if (!port)
2066+
return 0;
2067+
2068+
if (port->enabled) {
2069+
struct s32_fract frame_rate = { ctx->framerate_num,
2070+
ctx->framerate_denom };
2071+
2072+
ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
2073+
&ctx->component->output[0],
2074+
MMAL_PARAMETER_VIDEO_FRAME_RATE,
2075+
&frame_rate,
2076+
sizeof(frame_rate));
2077+
2078+
return ret;
2079+
}
2080+
2081+
setup_mmal_port_format(ctx, q_data, port);
2082+
ret = vchiq_mmal_port_set_format(ctx->dev->instance, port);
2083+
if (ret) {
2084+
v4l2_err(&ctx->dev->v4l2_dev, "%s: Failed vchiq_mmal_port_set_format on port, ret %d\n",
2085+
__func__, ret);
2086+
ret = -EINVAL;
2087+
}
2088+
2089+
if (q_data->sizeimage < port->minimum_buffer.size) {
2090+
v4l2_err(&ctx->dev->v4l2_dev, "%s: Current buffer size of %u < min buf size %u - driver mismatch to MMAL\n",
2091+
__func__, q_data->sizeimage,
2092+
port->minimum_buffer.size);
2093+
ret = -EINVAL;
2094+
}
2095+
2096+
return ret;
20572097
}
20582098

20592099
static int vidioc_g_parm(struct file *file, void *priv,

0 commit comments

Comments
 (0)