68f1d1ab7ebc9e8c908ee4bdc24b9b66ed1462ea
[openwrt/staging/wigyori.git] /
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
5 bcm2835-v4l2-codec
6
7 Following raspberrypi/linux#4704. This is necessary to set up
8 quantization for variable bitrate to avoid video flickering.
9 ---
10 .../bcm2835-codec/bcm2835-v4l2-codec.c | 32 ++++++++++++++++++-
11 1 file changed, 31 insertions(+), 1 deletion(-)
12
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);
17 break;
18
19 + case V4L2_CID_MPEG_VIDEO_H264_MIN_QP:
20 + if (!ctx->component)
21 + break;
22 +
23 + ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
24 + &ctx->component->output[0],
25 + MMAL_PARAMETER_VIDEO_ENCODE_MIN_QUANT,
26 + &ctrl->val,
27 + sizeof(ctrl->val));
28 + break;
29 +
30 + case V4L2_CID_MPEG_VIDEO_H264_MAX_QP:
31 + if (!ctx->component)
32 + break;
33 +
34 + ret = vchiq_mmal_port_parameter_set(ctx->dev->instance,
35 + &ctx->component->output[0],
36 + MMAL_PARAMETER_VIDEO_ENCODE_MAX_QUANT,
37 + &ctrl->val,
38 + sizeof(ctrl->val));
39 + break;
40 +
41 case V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME: {
42 u32 mmal_bool = 1;
43
44 @@ -3103,7 +3125,7 @@ static int bcm2835_codec_open(struct fil
45 case ENCODE:
46 {
47 /* Encode controls */
48 - v4l2_ctrl_handler_init(hdl, 9);
49 + v4l2_ctrl_handler_init(hdl, 11);
50
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,
58 + 0, 51,
59 + 1, 20);
60 + v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
61 + V4L2_CID_MPEG_VIDEO_H264_MAX_QP,
62 + 0, 51,
63 + 1, 51);
64 + v4l2_ctrl_new_std(hdl, &bcm2835_codec_ctrl_ops,
65 V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME,
66 0, 0, 0, 0);
67 if (hdl->error) {