Skip to content

Commit

Permalink
staging: bcm2835-codec: Ensure all ctrls are set on streamon
Browse files Browse the repository at this point in the history
Currently the code was only setting some controls from
bcm2835_codec_set_ctrls, but it's simpler to use
v4l2_ctrl_handler_setup to avoid forgetting to adding new
controls to the list.

Signed-off-by: Dave Stevenson <[email protected]>
  • Loading branch information
6by9 committed Sep 23, 2021
1 parent 28f673b commit a702880
Showing 1 changed file with 19 additions and 32 deletions.
51 changes: 19 additions & 32 deletions drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2437,33 +2437,6 @@ static const struct v4l2_ioctl_ops bcm2835_codec_ioctl_ops = {
.vidioc_enum_framesizes = vidioc_enum_framesizes,
};

static int bcm2835_codec_set_ctrls(struct bcm2835_codec_ctx *ctx)
{
/*
* Query the control handler for the value of the various controls and
* set them.
*/
const u32 control_ids[] = {
V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER,
V4L2_CID_MPEG_VIDEO_HEADER_MODE,
V4L2_CID_MPEG_VIDEO_H264_I_PERIOD,
V4L2_CID_MPEG_VIDEO_H264_LEVEL,
V4L2_CID_MPEG_VIDEO_H264_PROFILE,
};
int i;

for (i = 0; i < ARRAY_SIZE(control_ids); i++) {
struct v4l2_ctrl *ctrl;

ctrl = v4l2_ctrl_find(&ctx->hdl, control_ids[i]);
if (ctrl)
bcm2835_codec_s_ctrl(ctrl);
}

return 0;
}

static int bcm2835_codec_create_component(struct bcm2835_codec_ctx *ctx)
{
struct bcm2835_codec_dev *dev = ctx->dev;
Expand Down Expand Up @@ -2567,9 +2540,6 @@ static int bcm2835_codec_create_component(struct bcm2835_codec_ctx *ctx)
ctx->q_data[V4L2_M2M_SRC].sizeimage,
ctx->component->output[0].minimum_buffer.size);

/* Now we have a component we can set all the ctrls */
bcm2835_codec_set_ctrls(ctx);

/* Enable SPS Timing header so framerate information is encoded
* in the H264 header.
*/
Expand Down Expand Up @@ -2598,6 +2568,10 @@ static int bcm2835_codec_create_component(struct bcm2835_codec_ctx *ctx)
ctx->q_data[V4L2_M2M_DST].sizeimage,
ctx->component->output[0].minimum_buffer.size);
}

/* Now we have a component we can set all the ctrls */
ret = v4l2_ctrl_handler_setup(&ctx->hdl);

v4l2_dbg(2, debug, &dev->v4l2_dev, "%s: component created as %s\n",
__func__, components[dev->role]);

Expand Down Expand Up @@ -3099,7 +3073,9 @@ static int bcm2835_codec_open(struct file *file)
file->private_data = &ctx->fh;
ctx->dev = dev;
hdl = &ctx->hdl;
if (dev->role == ENCODE) {
switch (dev->role) {
case ENCODE:
{
/* Encode controls */
v4l2_ctrl_handler_init(hdl, 9);

Expand Down Expand Up @@ -3158,7 +3134,10 @@ static int bcm2835_codec_open(struct file *file)
}
ctx->fh.ctrl_handler = hdl;
v4l2_ctrl_handler_setup(hdl);
} else if (dev->role == DECODE) {
}
break;
case DECODE:
{
v4l2_ctrl_handler_init(hdl, 1);

v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
Expand All @@ -3171,6 +3150,14 @@ static int bcm2835_codec_open(struct file *file)
ctx->fh.ctrl_handler = hdl;
v4l2_ctrl_handler_setup(hdl);
}
break;
case ISP:
case DEINTERLACE:
{
v4l2_ctrl_handler_init(hdl, 0);
}
break;
}

ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);

Expand Down

0 comments on commit a702880

Please sign in to comment.