diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2012-05-08 05:56:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-14 13:33:24 -0400 |
commit | d7a87e4cc39f7ee4f6d1a1a8b8fffc10a7b0c1e9 (patch) | |
tree | f159ed301587ba2f55ec02bda4dcce16f477bc26 /drivers | |
parent | 44b153ca639f7299a94c27fc48708bbbeccf5050 (diff) |
[media] m5mols: Add auto and preset white balance control
Replace the V4L2_CID_AUTO_WHITE_BALANCE control with its extended
version - V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE so the white balance
presets feature is exposed to user land.
Acked-by: HeungJun Kim <riverful.kim@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/m5mols/m5mols.h | 4 | ||||
-rw-r--r-- | drivers/media/video/m5mols/m5mols_controls.c | 47 |
2 files changed, 39 insertions, 12 deletions
diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h index 598bb0fe6036..fa1f2c145852 100644 --- a/drivers/media/video/m5mols/m5mols.h +++ b/drivers/media/video/m5mols/m5mols.h | |||
@@ -164,7 +164,7 @@ struct m5mols_version { | |||
164 | * @exposure: manual exposure control | 164 | * @exposure: manual exposure control |
165 | * @auto_iso: auto/manual ISO sensitivity control | 165 | * @auto_iso: auto/manual ISO sensitivity control |
166 | * @iso: manual ISO sensitivity control | 166 | * @iso: manual ISO sensitivity control |
167 | * @autowb: Auto White Balance control | 167 | * @auto_wb: auto white balance control |
168 | * @colorfx: color effect control | 168 | * @colorfx: color effect control |
169 | * @saturation: saturation control | 169 | * @saturation: saturation control |
170 | * @zoom: zoom control | 170 | * @zoom: zoom control |
@@ -200,8 +200,8 @@ struct m5mols_info { | |||
200 | struct v4l2_ctrl *auto_iso; | 200 | struct v4l2_ctrl *auto_iso; |
201 | struct v4l2_ctrl *iso; | 201 | struct v4l2_ctrl *iso; |
202 | }; | 202 | }; |
203 | |||
204 | struct v4l2_ctrl *auto_wb; | 203 | struct v4l2_ctrl *auto_wb; |
204 | |||
205 | struct v4l2_ctrl *colorfx; | 205 | struct v4l2_ctrl *colorfx; |
206 | struct v4l2_ctrl *saturation; | 206 | struct v4l2_ctrl *saturation; |
207 | struct v4l2_ctrl *zoom; | 207 | struct v4l2_ctrl *zoom; |
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c index f1c88507de4b..1ab21f0afa8a 100644 --- a/drivers/media/video/m5mols/m5mols_controls.c +++ b/drivers/media/video/m5mols/m5mols_controls.c | |||
@@ -256,16 +256,42 @@ static int m5mols_set_exposure(struct m5mols_info *info, int exposure) | |||
256 | return ret; | 256 | return ret; |
257 | } | 257 | } |
258 | 258 | ||
259 | static int m5mols_set_white_balance(struct m5mols_info *info, int awb) | 259 | static int m5mols_set_white_balance(struct m5mols_info *info, int val) |
260 | { | 260 | { |
261 | int ret; | 261 | static const unsigned short wb[][2] = { |
262 | { V4L2_WHITE_BALANCE_INCANDESCENT, REG_AWB_INCANDESCENT }, | ||
263 | { V4L2_WHITE_BALANCE_FLUORESCENT, REG_AWB_FLUORESCENT_1 }, | ||
264 | { V4L2_WHITE_BALANCE_FLUORESCENT_H, REG_AWB_FLUORESCENT_2 }, | ||
265 | { V4L2_WHITE_BALANCE_HORIZON, REG_AWB_HORIZON }, | ||
266 | { V4L2_WHITE_BALANCE_DAYLIGHT, REG_AWB_DAYLIGHT }, | ||
267 | { V4L2_WHITE_BALANCE_FLASH, REG_AWB_LEDLIGHT }, | ||
268 | { V4L2_WHITE_BALANCE_CLOUDY, REG_AWB_CLOUDY }, | ||
269 | { V4L2_WHITE_BALANCE_SHADE, REG_AWB_SHADE }, | ||
270 | { V4L2_WHITE_BALANCE_AUTO, REG_AWB_AUTO }, | ||
271 | }; | ||
272 | int i; | ||
273 | struct v4l2_subdev *sd = &info->sd; | ||
274 | int ret = -EINVAL; | ||
262 | 275 | ||
263 | ret = m5mols_lock_awb(info, !awb); | 276 | for (i = 0; i < ARRAY_SIZE(wb); i++) { |
264 | if (ret < 0) | 277 | int awb; |
265 | return ret; | 278 | if (wb[i][0] != val) |
279 | continue; | ||
280 | |||
281 | v4l2_dbg(1, m5mols_debug, sd, | ||
282 | "Setting white balance to: %#x\n", wb[i][0]); | ||
266 | 283 | ||
267 | return m5mols_write(&info->sd, AWB_MODE, awb ? REG_AWB_AUTO : | 284 | awb = wb[i][0] == V4L2_WHITE_BALANCE_AUTO; |
268 | REG_AWB_PRESET); | 285 | ret = m5mols_write(sd, AWB_MODE, awb ? REG_AWB_AUTO : |
286 | REG_AWB_PRESET); | ||
287 | if (ret < 0) | ||
288 | return ret; | ||
289 | |||
290 | if (!awb) | ||
291 | ret = m5mols_write(sd, AWB_MANUAL, wb[i][1]); | ||
292 | } | ||
293 | |||
294 | return ret; | ||
269 | } | 295 | } |
270 | 296 | ||
271 | static int m5mols_set_saturation(struct m5mols_info *info, int val) | 297 | static int m5mols_set_saturation(struct m5mols_info *info, int val) |
@@ -391,7 +417,7 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl) | |||
391 | ret = m5mols_set_iso(info, ctrl->val); | 417 | ret = m5mols_set_iso(info, ctrl->val); |
392 | break; | 418 | break; |
393 | 419 | ||
394 | case V4L2_CID_AUTO_WHITE_BALANCE: | 420 | case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE: |
395 | ret = m5mols_set_white_balance(info, ctrl->val); | 421 | ret = m5mols_set_white_balance(info, ctrl->val); |
396 | break; | 422 | break; |
397 | 423 | ||
@@ -437,8 +463,9 @@ int m5mols_init_controls(struct v4l2_subdev *sd) | |||
437 | 463 | ||
438 | v4l2_ctrl_handler_init(&info->handle, 6); | 464 | v4l2_ctrl_handler_init(&info->handle, 6); |
439 | 465 | ||
440 | info->auto_wb = v4l2_ctrl_new_std(&info->handle, &m5mols_ctrl_ops, | 466 | info->auto_wb = v4l2_ctrl_new_std_menu(&info->handle, |
441 | V4L2_CID_AUTO_WHITE_BALANCE, 0, 1, 1, 1); | 467 | &m5mols_ctrl_ops, V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, |
468 | 9, ~0x3fe, V4L2_WHITE_BALANCE_AUTO); | ||
442 | 469 | ||
443 | info->auto_exposure = v4l2_ctrl_new_std_menu(&info->handle, | 470 | info->auto_exposure = v4l2_ctrl_new_std_menu(&info->handle, |
444 | &m5mols_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, | 471 | &m5mols_ctrl_ops, V4L2_CID_EXPOSURE_AUTO, |