Search
SailfishOS Open Build Service
>
Projects
>
home:ballock
:
archosG9
>
kernel-adaptation-archos-gen9-mmc
> leds-init-as-backlight-too.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File leds-init-as-backlight-too.patch of Package kernel-adaptation-archos-gen9-mmc
diff --git a/drivers/leds/leds-omap-pwm.c b/drivers/leds/leds-omap-pwm.c index 91f9048..1e8f92f 100644 --- a/drivers/leds/leds-omap-pwm.c +++ b/drivers/leds/leds-omap-pwm.c @@ -24,8 +24,10 @@ #include <plat/dmtimer.h> #include <linux/slab.h> #include <linux/delay.h> +#include <linux/backlight.h> #define MAX_GPTIMER_ID 12 +#define CONFIG_BACKLIGHT_OMAP_PWM struct omap_pwm_led { struct led_classdev cdev; @@ -37,6 +39,11 @@ struct omap_pwm_led { enum led_brightness brightness; }; +#ifdef CONFIG_BACKLIGHT_OMAP_PWM +static struct platform_device * archos_backlight_device; +static struct omap_pwm_led * archos_led_device; +#endif // CONFIG_BACKLIGHT_OMAP_PWM + static inline struct omap_pwm_led *pdev_to_omap_pwm_led(struct platform_device *pdev) { return platform_get_drvdata(pdev); @@ -311,6 +318,9 @@ static int omap_pwm_led_probe(struct platform_device *pdev) return -EINVAL; led = kzalloc(sizeof(struct omap_pwm_led), GFP_KERNEL); +#ifdef CONFIG_BACKLIGHT_OMAP_PWM + archos_led_device = led; +#endif if (led == NULL) { dev_err(&pdev->dev, "No memory for device\n"); return -ENOMEM; @@ -395,7 +405,9 @@ static int omap_pwm_led_remove(struct platform_device *pdev) omap_dm_timer_free(led->blink_timer); omap_dm_timer_free(led->intensity_timer); kfree(led); - +#ifdef CONFIG_BACKLIGHT_OMAP_PWM + archos_led_device = NULL; +#endif return 0; } @@ -435,9 +447,58 @@ static struct platform_driver omap_pwm_led_driver = { }, }; +#ifdef CONFIG_BACKLIGHT_OMAP_PWM +static int archos_backlight_get_brightness(struct backlight_device *b) +{ + pr_debug( "%s: %p %d.\n", __func__, b, b->props.brightness ); + if( archos_led_device ){ + b->props.brightness = archos_led_device->cdev.brightness; + return archos_led_device->cdev.brightness; + } + return b->props.brightness; +} + + +static int archos_backlight_update_status(struct backlight_device *b) +{ + int brightness; + pr_debug( "%s: %p %d pwm_led_driver %p.\n", __func__, b, b->props.brightness, &omap_pwm_led_driver ); + if( b->props.brightness < 20 ){ + brightness = 20; + } else { + brightness = b->props.brightness; + } + if( archos_led_device ){ + omap_pwm_led_set( &(archos_led_device->cdev), brightness ); + archos_led_device->cdev.brightness = brightness; + archos_led_device->brightness = brightness; + } + return b->props.brightness; +} + +static const struct backlight_ops archos_backlight_ops = { + .get_brightness = archos_backlight_get_brightness, + .update_status = archos_backlight_update_status, +}; +#endif + static int __init omap_pwm_led_init(void) { +#ifdef CONFIG_BACKLIGHT_OMAP_PWM + int ret; + struct backlight_properties props; + ret = platform_driver_register(&omap_pwm_led_driver); + memset(&props, 0, sizeof(struct backlight_properties)); + props.type = BACKLIGHT_PLATFORM; + props.max_brightness = LED_FULL; + archos_backlight_device = backlight_device_register( "archos-backlight", NULL, NULL, &archos_backlight_ops, &props ); + if (IS_ERR(archos_backlight_device)){ + pr_warn("%s: Error, backlight_device_register archos-backlight failed.\n", __func__ ); + } + return ret; +#else return platform_driver_register(&omap_pwm_led_driver); +#endif // CONFIG_BACKLIGHT_OMAP_PWM } static void __exit omap_pwm_led_exit(void)