leds: stingray: add blink support for cpcap leds
authorPraveen Bharathi <pbharathi@motorola.com>
Thu, 12 Aug 2010 16:10:44 +0000 (11:10 -0500)
committerColin Cross <ccross@android.com>
Wed, 6 Oct 2010 23:33:39 +0000 (16:33 -0700)
Allows individual led to support blink capability

Change-Id: If2c7bd8a4bc617e3049b0db3a6fec4f92b06c0e5
Signed-off-by: Praveen Bharathi <pbharathi@motorola.com>
drivers/leds/leds-ld-cpcap.c
include/linux/leds-ld-cpcap.h

index b0cebda0285f3fb4c2a11862468e97a0f7b7d996..ca5ce145d4358031d9d92e9bae8eb63999c102f3 100755 (executable)
@@ -34,6 +34,7 @@ struct cpcap_led_data {
        struct work_struct brightness_work;
        enum led_brightness brightness;
        int regulator_state;
+       u8 blink;
 };
 
 static void cpcap_set(struct led_classdev *led_cdev,
@@ -51,6 +52,19 @@ static void cpcap_set(struct led_classdev *led_cdev,
 }
 EXPORT_SYMBOL(cpcap_set);
 
+static int cpcap_msg_ind_blink(struct led_classdev *led_cdev,
+                              unsigned long *delay_on,
+                              unsigned long *delay_off)
+{
+       struct cpcap_led_data *info =
+               container_of(led_cdev, struct cpcap_led_data,
+                        cpcap_class_dev);
+
+       info->blink = 1;
+       schedule_work(&info->brightness_work);
+       return 0;
+}
+
 static void cpcap_brightness_work(struct work_struct *work)
 {
        int cpcap_status = 0;
@@ -80,6 +94,8 @@ static void cpcap_brightness_work(struct work_struct *work)
                        pr_err("%s: Writing to the register failed for %i\n",
                               __func__, cpcap_status);
 
+               if (cpcap_led_data->blink)
+                       cpcap_uc_start(cpcap_led_data->cpcap, CPCAP_MACRO_6);
        } else {
                if ((cpcap_led_data->regulator) &&
                    (cpcap_led_data->regulator_state == 1)) {
@@ -105,6 +121,9 @@ static void cpcap_brightness_work(struct work_struct *work)
                if (cpcap_status < 0)
                        pr_err("%s: Writing to the register failed for %i\n",
                               __func__, cpcap_status);
+
+               if (cpcap_led_data->blink)
+                       cpcap_uc_stop(cpcap_led_data->cpcap, CPCAP_MACRO_6);
        }
 }
 
@@ -143,13 +162,20 @@ static int cpcap_probe(struct platform_device *pdev)
 
        info->cpcap_class_dev.name = info->pdata->class_name;
        info->cpcap_class_dev.brightness_set = cpcap_set;
+       info->cpcap_class_dev.brightness = LED_OFF;
+       info->cpcap_class_dev.max_brightness = 255;
+       if (info->pdata->blink_able)
+               info->cpcap_class_dev.blink_set = cpcap_msg_ind_blink;
+
        ret = led_classdev_register(&pdev->dev, &info->cpcap_class_dev);
        if (ret < 0) {
                pr_err("%s:Register %s class failed\n",
                        __func__, info->cpcap_class_dev.name);
                goto err_reg_button_class_failed;
        }
+
        INIT_WORK(&info->brightness_work, cpcap_brightness_work);
+
        return ret;
 
 err_reg_button_class_failed:
@@ -166,7 +192,6 @@ static int cpcap_remove(struct platform_device *pdev)
 
        if (info->regulator)
                regulator_put(info->regulator);
-
        led_classdev_unregister(&info->cpcap_class_dev);
        return 0;
 }
index 208551be2106d27656f8295c023063ce2a7c3125..a8c52f62ae8cfbcb201db6003df356baf9c53a1f 100644 (file)
@@ -25,6 +25,7 @@
 
 #define LD_DISP_BUTTON_DEV "button-backlight"
 #define LD_PRIVACY_LED_DEV "privacy-led"
+#define LD_NOTIF_LED_DEV "notification-backlight"
 
 struct cpcap_display_led {
        unsigned int display_reg;
@@ -41,6 +42,7 @@ struct cpcap_display_led {
 };
 
 struct cpcap_led {
+       u8 blink_able;
        unsigned int cpcap_register;
        unsigned int cpcap_mask;
        unsigned int on_val;