Skip to content

Commit 54dcfdb

Browse files
committed
BCM2835-V4L2: Correct ISO control and add V4L2_CID_ISO_SENSITIVITY_AUTO
raspberrypi#1251 V4L2_CID_ISO_SENSITIVITY was not advertising ISO*1000 as it should. V4L2_CID_ISO_SENSITIVITY_AUTO was not implemented, so was taking V4L2_CID_ISO_SENSITIVITY as 0 for auto mode. Still accepts 0 for auto, but also abides by the new parameter.
1 parent 2026046 commit 54dcfdb

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

drivers/media/platform/bcm2835/bcm2835-camera.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* core driver device
1616
*/
1717

18-
#define V4L2_CTRL_COUNT 28 /* number of v4l controls */
18+
#define V4L2_CTRL_COUNT 29 /* number of v4l controls */
1919

2020
enum {
2121
MMAL_COMPONENT_CAMERA = 0,
@@ -58,6 +58,8 @@ struct bm2835_mmal_dev {
5858
enum mmal_parameter_exposuremeteringmode metering_mode;
5959
unsigned int manual_shutter_speed;
6060
bool exp_auto_priority;
61+
bool manual_iso_enabled;
62+
uint32_t iso;
6163

6264
/* allocated mmal instance and components */
6365
struct vchiq_mmal_instance *instance;

drivers/media/platform/bcm2835/controls.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ static const s64 ev_bias_qmenu[] = {
4949
4000
5050
};
5151

52-
/* Supported ISO values
52+
/* Supported ISO values (*1000)
5353
* ISOO = auto ISO
5454
*/
5555
static const s64 iso_qmenu[] = {
56+
0, 100000, 200000, 400000, 800000,
57+
};
58+
static const uint32_t iso_values[] = {
5659
0, 100, 200, 400, 800,
5760
};
5861

@@ -201,7 +204,7 @@ static int ctrl_set_value(struct bm2835_mmal_dev *dev,
201204
&u32_value, sizeof(u32_value));
202205
}
203206

204-
static int ctrl_set_value_menu(struct bm2835_mmal_dev *dev,
207+
static int ctrl_set_iso(struct bm2835_mmal_dev *dev,
205208
struct v4l2_ctrl *ctrl,
206209
const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl)
207210
{
@@ -211,12 +214,20 @@ static int ctrl_set_value_menu(struct bm2835_mmal_dev *dev,
211214
if (ctrl->val > mmal_ctrl->max || ctrl->val < mmal_ctrl->min)
212215
return 1;
213216

217+
if (ctrl->id == V4L2_CID_ISO_SENSITIVITY)
218+
dev->iso = iso_values[ctrl->val];
219+
else if (ctrl->id == V4L2_CID_ISO_SENSITIVITY_AUTO)
220+
dev->manual_iso_enabled = (ctrl->val == V4L2_ISO_SENSITIVITY_MANUAL ? true : false);
221+
214222
control = &dev->component[MMAL_COMPONENT_CAMERA]->control;
215223

216-
u32_value = mmal_ctrl->imenu[ctrl->val];
224+
if (dev->manual_iso_enabled)
225+
u32_value = dev->iso;
226+
else
227+
u32_value = 0;
217228

218229
return vchiq_mmal_port_parameter_set(dev->instance, control,
219-
mmal_ctrl->mmal_id,
230+
MMAL_PARAMETER_ISO,
220231
&u32_value, sizeof(u32_value));
221232
}
222233

@@ -956,7 +967,14 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = {
956967
V4L2_CID_ISO_SENSITIVITY, MMAL_CONTROL_TYPE_INT_MENU,
957968
0, ARRAY_SIZE(iso_qmenu) - 1, 0, 1, iso_qmenu,
958969
MMAL_PARAMETER_ISO,
959-
&ctrl_set_value_menu,
970+
&ctrl_set_iso,
971+
false
972+
},
973+
{
974+
V4L2_CID_ISO_SENSITIVITY_AUTO, MMAL_CONTROL_TYPE_STD_MENU,
975+
0, 1, V4L2_ISO_SENSITIVITY_AUTO, 1, NULL,
976+
MMAL_PARAMETER_ISO,
977+
&ctrl_set_iso,
960978
false
961979
},
962980
{

0 commit comments

Comments
 (0)