leds: stingray: add blink support for cpcap leds

Allows individual led to support blink capability

Change-Id: If2c7bd8a4bc617e3049b0db3a6fec4f92b06c0e5
Signed-off-by: Praveen Bharathi <pbharathi@motorola.com>
This commit is contained in:
Praveen Bharathi
2010-08-12 11:10:44 -05:00
committed by Colin Cross
parent 0182709057
commit 2f0fcdc5df
2 changed files with 28 additions and 1 deletions

View File

@@ -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;
}

View 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;