2d3b5408a50a3e6169d85bb2874e5e44effb7342
[oweals/openwrt.git] /
1 From 316725374b7c221f5d43b31ee9cbe738d3df4709 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Fri, 28 Sep 2018 10:17:11 +0100
4 Subject: [PATCH] staging: bcm2835-camera: Use enums for max value in
5  controls
6
7 Controls of type MMAL_CONTROL_TYPE_STD_MENU call v4l2_ctrl_new_std_menu
8 with a max value and a mask. The max value is one of the defined
9 values for the control, however in the config array there are several
10 entries where raw numbers have been used instead. Replace these
11 with the appropriate enum.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
14 ---
15  .../vc04_services/bcm2835-camera/controls.c   | 37 +++++++------------
16  1 file changed, 13 insertions(+), 24 deletions(-)
17
18 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c
19 +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c
20 @@ -58,19 +58,6 @@ static const uint32_t iso_values[] = {
21         0, 100, 200, 400, 800,
22  };
23  
24 -static const s64 mains_freq_qmenu[] = {
25 -       V4L2_CID_POWER_LINE_FREQUENCY_DISABLED,
26 -       V4L2_CID_POWER_LINE_FREQUENCY_50HZ,
27 -       V4L2_CID_POWER_LINE_FREQUENCY_60HZ,
28 -       V4L2_CID_POWER_LINE_FREQUENCY_AUTO
29 -};
30 -
31 -/* Supported video encode modes */
32 -static const s64 bitrate_mode_qmenu[] = {
33 -       (s64)V4L2_MPEG_VIDEO_BITRATE_MODE_VBR,
34 -       (s64)V4L2_MPEG_VIDEO_BITRATE_MODE_CBR,
35 -};
36 -
37  enum bm2835_mmal_ctrl_type {
38         MMAL_CONTROL_TYPE_STD,
39         MMAL_CONTROL_TYPE_STD_MENU,
40 @@ -966,8 +953,8 @@ static const struct bm2835_mmal_v4l2_ctr
41         },
42         {
43                 V4L2_CID_ISO_SENSITIVITY_AUTO, MMAL_CONTROL_TYPE_STD_MENU,
44 -               0, 1, V4L2_ISO_SENSITIVITY_AUTO, 1, NULL,
45 -               MMAL_PARAMETER_ISO,
46 +               0, V4L2_ISO_SENSITIVITY_AUTO, V4L2_ISO_SENSITIVITY_AUTO, 1,
47 +               NULL, MMAL_PARAMETER_ISO,
48                 &ctrl_set_iso,
49                 false
50         },
51 @@ -984,8 +971,8 @@ static const struct bm2835_mmal_v4l2_ctr
52   */
53         {
54                 V4L2_CID_EXPOSURE_AUTO, MMAL_CONTROL_TYPE_STD_MENU,
55 -               ~0x03, 3, V4L2_EXPOSURE_AUTO, 0, NULL,
56 -               MMAL_PARAMETER_EXPOSURE_MODE,
57 +               ~0x03, V4L2_EXPOSURE_APERTURE_PRIORITY, V4L2_EXPOSURE_AUTO, 0,
58 +               NULL, MMAL_PARAMETER_EXPOSURE_MODE,
59                 &ctrl_set_exposure,
60                 false
61         },
62 @@ -1021,7 +1008,8 @@ static const struct bm2835_mmal_v4l2_ctr
63         {
64                 V4L2_CID_EXPOSURE_METERING,
65                 MMAL_CONTROL_TYPE_STD_MENU,
66 -               ~0x7, 2, V4L2_EXPOSURE_METERING_AVERAGE, 0, NULL,
67 +               ~0x7, V4L2_EXPOSURE_METERING_SPOT,
68 +               V4L2_EXPOSURE_METERING_AVERAGE, 0, NULL,
69                 MMAL_PARAMETER_EXP_METERING_MODE,
70                 &ctrl_set_metering_mode,
71                 false
72 @@ -1029,7 +1017,8 @@ static const struct bm2835_mmal_v4l2_ctr
73         {
74                 V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,
75                 MMAL_CONTROL_TYPE_STD_MENU,
76 -               ~0x3ff, 9, V4L2_WHITE_BALANCE_AUTO, 0, NULL,
77 +               ~0x3ff, V4L2_WHITE_BALANCE_SHADE, V4L2_WHITE_BALANCE_AUTO, 0,
78 +               NULL,
79                 MMAL_PARAMETER_AWB_MODE,
80                 &ctrl_set_awb_mode,
81                 false
82 @@ -1050,7 +1039,7 @@ static const struct bm2835_mmal_v4l2_ctr
83         },
84         {
85                 V4L2_CID_COLORFX, MMAL_CONTROL_TYPE_STD_MENU,
86 -               0, 15, V4L2_COLORFX_NONE, 0, NULL,
87 +               0, V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_NONE, 0, NULL,
88                 MMAL_PARAMETER_IMAGE_EFFECT,
89                 &ctrl_set_image_effect,
90                 false
91 @@ -1085,8 +1074,8 @@ static const struct bm2835_mmal_v4l2_ctr
92         },
93         {
94                 V4L2_CID_MPEG_VIDEO_BITRATE_MODE, MMAL_CONTROL_TYPE_STD_MENU,
95 -               0, ARRAY_SIZE(bitrate_mode_qmenu) - 1,
96 -               0, 0, bitrate_mode_qmenu,
97 +               0, V4L2_MPEG_VIDEO_BITRATE_MODE_CBR,
98 +               0, 0, NULL,
99                 MMAL_PARAMETER_RATECONTROL,
100                 &ctrl_set_bitrate_mode,
101                 false
102 @@ -1108,8 +1097,8 @@ static const struct bm2835_mmal_v4l2_ctr
103         },
104         {
105                 V4L2_CID_POWER_LINE_FREQUENCY, MMAL_CONTROL_TYPE_STD_MENU,
106 -               0, ARRAY_SIZE(mains_freq_qmenu) - 1,
107 -               1, 1, mains_freq_qmenu,
108 +               0, V4L2_CID_POWER_LINE_FREQUENCY_AUTO,
109 +               1, 1, NULL,
110                 MMAL_PARAMETER_FLICKER_AVOID,
111                 &ctrl_set_flicker_avoidance,
112                 false