1 From 3d21c93db479bf4269630676ba7d48dec9bf75fc Mon Sep 17 00:00:00 2001
2 From: Maxim Devaev <mdevaev@gmail.com>
3 Date: Wed, 17 Nov 2021 04:57:56 +0300
4 Subject: [PATCH] Pass V4L2_CID_MPEG_VIDEO_H264_MIN_QP/MAX_QP to
7 Following raspberrypi/linux#4704. This is necessary to set up
8 quantization for variable bitrate to avoid video flickering.
10 .../bcm2835-codec/bcm2835-v4l2-codec.c | 32 ++++++++++++++++++-
11 1 file changed, 31 insertions(+), 1 deletion(-)
13 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
14 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
15 @@ -2187,6 +2187,28 @@ static int bcm2835_codec_s_ctrl(struct v
16 ret = bcm2835_codec_set_level_profile(ctx, ctrl);
19 + case V4L2_CID_MPEG_VIDEO_H264_MIN_QP:
20 + if (!ctx->component)
23 + ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
24 + &ctx->component->output[0],
25 + MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
30 + case V4L2_CID_MPEG_VIDEO_H264_MAX_QP:
31 + if (!ctx->component)
34 + ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
35 + &ctx->component->output[0],
36 + MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
41 case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: {
44 @@ -3103,7 +3125,7 @@ static int bcm2835_codec_open(struct fil
48 - v4l2_ctrl_handler_init(hdl, 9);
49 + v4l2_ctrl_handler_init(hdl, 11);
51 v4l2_ctrl_new_std_menu(hdl, &bcm2835_codec_ctrl_ops,
52 V4L2_CID_MPEG_VIDEO_BITRATE_MODE,
53 @@ -3152,6 +3174,14 @@ static int bcm2835_codec_open(struct fil
54 BIT(V4L2_MPEG_VIDEO_H264_PROFILE_HIGH)),
55 V4L2_MPEG_VIDEO_H264_PROFILE_HIGH);
56 v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
57 + V4L2_CID_MPEG_VIDEO_H264_MIN_QP,
60 + v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
61 + V4L2_CID_MPEG_VIDEO_H264_MAX_QP,
64 + v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
65 V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME,