diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2012-04-09 12:52:06 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-14 13:32:36 -0400 |
commit | 0373e97496793fd91cd7fb1a26840ee43d70f77e (patch) | |
tree | 09038399e27e1d5cd20f148ef045d1bcb4a54944 /drivers/media/video | |
parent | 3c5da0baaada8e8c7176a3e310dfdb4362f74d80 (diff) |
[media] m5mols: Use proper sensor mode for the controls
The parameters corresponding to the V4L controls can be reconfigured
only in associated M-5MOLS operation mode. Use struct v4l2_ctrl
priv field to assign the working mode to the controls which can be
modified only in certain conditions.
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/media/video')
-rw-r--r-- | drivers/media/video/m5mols/m5mols.h | 11 | ||||
-rw-r--r-- | drivers/media/video/m5mols/m5mols_controls.c | 28 |
2 files changed, 31 insertions, 8 deletions
diff --git a/drivers/media/video/m5mols/m5mols.h b/drivers/media/video/m5mols/m5mols.h index ed75bbeddc15..87684c47d372 100644 --- a/drivers/media/video/m5mols/m5mols.h +++ b/drivers/media/video/m5mols/m5mols.h | |||
@@ -305,4 +305,15 @@ static inline struct v4l2_subdev *to_sd(struct v4l2_ctrl *ctrl) | |||
305 | return &info->sd; | 305 | return &info->sd; |
306 | } | 306 | } |
307 | 307 | ||
308 | static inline void m5mols_set_ctrl_mode(struct v4l2_ctrl *ctrl, | ||
309 | unsigned int mode) | ||
310 | { | ||
311 | ctrl->priv = (void *)mode; | ||
312 | } | ||
313 | |||
314 | static inline unsigned int m5mols_get_ctrl_mode(struct v4l2_ctrl *ctrl) | ||
315 | { | ||
316 | return (unsigned int)ctrl->priv; | ||
317 | } | ||
318 | |||
308 | #endif /* M5MOLS_H */ | 319 | #endif /* M5MOLS_H */ |
diff --git a/drivers/media/video/m5mols/m5mols_controls.c b/drivers/media/video/m5mols/m5mols_controls.c index 464ec0cdfb78..477660132c01 100644 --- a/drivers/media/video/m5mols/m5mols_controls.c +++ b/drivers/media/video/m5mols/m5mols_controls.c | |||
@@ -321,10 +321,11 @@ static int m5mols_set_color_effect(struct m5mols_info *info, int val) | |||
321 | 321 | ||
322 | static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl) | 322 | static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl) |
323 | { | 323 | { |
324 | unsigned int ctrl_mode = m5mols_get_ctrl_mode(ctrl); | ||
324 | struct v4l2_subdev *sd = to_sd(ctrl); | 325 | struct v4l2_subdev *sd = to_sd(ctrl); |
325 | struct m5mols_info *info = to_m5mols(sd); | 326 | struct m5mols_info *info = to_m5mols(sd); |
326 | int ispstate = info->mode; | 327 | int last_mode = info->mode; |
327 | int ret; | 328 | int ret = 0; |
328 | 329 | ||
329 | /* | 330 | /* |
330 | * If needed, defer restoring the controls until | 331 | * If needed, defer restoring the controls until |
@@ -335,9 +336,14 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl) | |||
335 | return 0; | 336 | return 0; |
336 | } | 337 | } |
337 | 338 | ||
338 | ret = m5mols_mode(info, REG_PARAMETER); | 339 | v4l2_dbg(1, m5mols_debug, sd, "%s: %s, val: %d, priv: %#x\n", |
339 | if (ret < 0) | 340 | __func__, ctrl->name, ctrl->val, (int)ctrl->priv); |
340 | return ret; | 341 | |
342 | if (ctrl_mode && ctrl_mode != info->mode) { | ||
343 | ret = m5mols_set_mode(info, ctrl_mode); | ||
344 | if (ret < 0) | ||
345 | return ret; | ||
346 | } | ||
341 | 347 | ||
342 | switch (ctrl->id) { | 348 | switch (ctrl->id) { |
343 | case V4L2_CID_ZOOM_ABSOLUTE: | 349 | case V4L2_CID_ZOOM_ABSOLUTE: |
@@ -360,10 +366,11 @@ static int m5mols_s_ctrl(struct v4l2_ctrl *ctrl) | |||
360 | ret = m5mols_set_color_effect(info, ctrl->val); | 366 | ret = m5mols_set_color_effect(info, ctrl->val); |
361 | break; | 367 | break; |
362 | } | 368 | } |
363 | if (ret < 0) | ||
364 | return ret; | ||
365 | 369 | ||
366 | return m5mols_mode(info, ispstate); | 370 | if (ret == 0 && info->mode != last_mode) |
371 | ret = m5mols_set_mode(info, last_mode); | ||
372 | |||
373 | return ret; | ||
367 | } | 374 | } |
368 | 375 | ||
369 | static const struct v4l2_ctrl_ops m5mols_ctrl_ops = { | 376 | static const struct v4l2_ctrl_ops m5mols_ctrl_ops = { |
@@ -414,6 +421,11 @@ int m5mols_init_controls(struct v4l2_subdev *sd) | |||
414 | } | 421 | } |
415 | 422 | ||
416 | v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false); | 423 | v4l2_ctrl_auto_cluster(2, &info->auto_exposure, 1, false); |
424 | |||
425 | m5mols_set_ctrl_mode(info->auto_exposure, REG_PARAMETER); | ||
426 | m5mols_set_ctrl_mode(info->auto_wb, REG_PARAMETER); | ||
427 | m5mols_set_ctrl_mode(info->colorfx, REG_MONITOR); | ||
428 | |||
417 | sd->ctrl_handler = &info->handle; | 429 | sd->ctrl_handler = &info->handle; |
418 | 430 | ||
419 | return 0; | 431 | return 0; |