aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-10-09 16:22:00 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-01-06 07:44:42 -0500
commit6807cfcb9ddb913e6d3d2c68f9a8bc1d1d94b87f (patch)
tree300b7fc0127ed6158ad548d27cdfe0d5ecaf69b9
parentc20d78cde37018caa0313469c9320424995cc489 (diff)
[media] pwc: Read new preset values when changing awb control to a preset
So that events get generated for the new red + blue bal values when switching to a preset. This allows apps to solely rely on events instead of needing to do a query + g_ctrl on all controls when a control with the update flag set is gets set or gets an event. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/pwc/pwc-v4l.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index 97e8d629582..566b09c7980 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -575,18 +575,14 @@ static int pwc_s_input(struct file *file, void *fh, unsigned int i)
575 return i ? -EINVAL : 0; 575 return i ? -EINVAL : 0;
576} 576}
577 577
578static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl) 578static int pwc_g_volatile_ctrl_unlocked(struct v4l2_ctrl *ctrl)
579{ 579{
580 struct pwc_device *pdev = 580 struct pwc_device *pdev =
581 container_of(ctrl->handler, struct pwc_device, ctrl_handler); 581 container_of(ctrl->handler, struct pwc_device, ctrl_handler);
582 int ret = 0; 582 int ret = 0;
583 583
584 mutex_lock(&pdev->udevlock); 584 if (!pdev->udev)
585 585 return -ENODEV;
586 if (!pdev->udev) {
587 ret = -ENODEV;
588 goto leave;
589 }
590 586
591 switch (ctrl->id) { 587 switch (ctrl->id) {
592 case V4L2_CID_AUTO_WHITE_BALANCE: 588 case V4L2_CID_AUTO_WHITE_BALANCE:
@@ -651,7 +647,17 @@ static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
651 if (ret) 647 if (ret)
652 PWC_ERROR("g_ctrl %s error %d\n", ctrl->name, ret); 648 PWC_ERROR("g_ctrl %s error %d\n", ctrl->name, ret);
653 649
654leave: 650 return ret;
651}
652
653static int pwc_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
654{
655 struct pwc_device *pdev =
656 container_of(ctrl->handler, struct pwc_device, ctrl_handler);
657 int ret;
658
659 mutex_lock(&pdev->udevlock);
660 ret = pwc_g_volatile_ctrl_unlocked(ctrl);
655 mutex_unlock(&pdev->udevlock); 661 mutex_unlock(&pdev->udevlock);
656 return ret; 662 return ret;
657} 663}
@@ -669,6 +675,15 @@ static int pwc_set_awb(struct pwc_device *pdev)
669 675
670 if (pdev->auto_white_balance->val != awb_manual) 676 if (pdev->auto_white_balance->val != awb_manual)
671 pdev->color_bal_valid = false; /* Force cache update */ 677 pdev->color_bal_valid = false; /* Force cache update */
678
679 /*
680 * If this is a preset, update our red / blue balance values
681 * so that events get generated for the new preset values
682 */
683 if (pdev->auto_white_balance->val == awb_indoor ||
684 pdev->auto_white_balance->val == awb_outdoor ||
685 pdev->auto_white_balance->val == awb_fl)
686 pwc_g_volatile_ctrl_unlocked(pdev->auto_white_balance);
672 } 687 }
673 if (pdev->auto_white_balance->val != awb_manual) 688 if (pdev->auto_white_balance->val != awb_manual)
674 return 0; 689 return 0;