static void leds_brightness_set(struct led_classdev *led_cdev, enum led_brightness value) { struct aat28xx_driver_data *drvdata = dev_get_drvdata(led_cdev->dev->parent); int brightness; int next; if (!drvdata) { eprintk("Error getting drvier data\n"); return; } brightness = aat28xx_get_intensity(drvdata); next = value * drvdata->max_intensity / LED_FULL; /* If value is not 0, should not backlight off by bongkyu.kim */ if (value !=0 && next == 0) next = 1; dprintk("input brightness value=%d]\n", next); if (brightness != next) { dprintk("brightness[current=%d, next=%d]\n", brightness, next); aat28xx_send_intensity(drvdata, next); } }
static int __devexit aat28xx_remove(struct i2c_client *i2c_dev) { struct aat28xx_driver_data *drvdata = i2c_get_clientdata(i2c_dev); aat28xx_send_intensity(drvdata, 0); backlight_device_unregister(drvdata->bd); led_classdev_unregister(drvdata->led); i2c_set_clientdata(i2c_dev, NULL); if (gpio_is_valid(drvdata->gpio)) gpio_free(drvdata->gpio); kfree(drvdata); return 0; }
static int __devexit aat28xx_remove(struct i2c_client *i2c_dev) { struct aat28xx_driver_data *drvdata = i2c_get_clientdata(i2c_dev); aat28xx_send_intensity(drvdata, 0); #ifdef CONFIG_AAT28XX_BACKLIGHT_CLASS backlight_device_unregister(drvdata->bd); #endif #ifdef CONFIG_AAT28XX_LEDS_CLASS led_classdev_unregister(drvdata->led); #endif i2c_set_clientdata(i2c_dev, NULL); if (gpio_is_valid(drvdata->gpio)) gpio_free(drvdata->gpio); kfree(drvdata); return 0; }
static void leds_brightness_set(struct led_classdev *led_cdev, enum led_brightness value) { struct aat28xx_driver_data *drvdata = dev_get_drvdata(led_cdev->dev->parent); int brightness; int next; if (!drvdata) { eprintk("Error getting drvier data\n"); return; } brightness = aat28xx_get_intensity(drvdata); next = value * drvdata->max_intensity / led_cdev->max_brightness; dprintk("input brightness value=%d]\n", next); if (brightness != next) { dprintk("brightness[current=%d, next=%d]\n", brightness, next); aat28xx_send_intensity(drvdata, next); } }
static void leds_brightness_set(struct led_classdev *led_cdev, enum led_brightness value) { struct aat28xx_driver_data *drvdata = dev_get_drvdata(led_cdev->dev->parent); int brightness; int next; if (!drvdata) { eprintk("Error getting drvier data\n"); return; } brightness = aat28xx_get_intensity(drvdata); /* LGE_CHANGE [[email protected]] 2010-06-09, the interpolation of B/L value */ next = bl_value[value * drvdata->max_intensity / LED_FULL]; dprintk("input brightness value=%d]\n", next); if (brightness != next) { dprintk("brightness[current=%d, next=%d]\n", brightness, next); aat28xx_send_intensity(drvdata, next); } }
static int aat28xx_probe(struct i2c_client *i2c_dev, const struct i2c_device_id *i2c_dev_id) { struct lge_backlight_platform_data *pdata; struct aat28xx_driver_data *drvdata; struct backlight_device *bd; int err; dprintk("start, client addr=0x%x\n", i2c_dev->addr); pdata = i2c_dev->dev.platform_data; if(!pdata) return -EINVAL; drvdata = kzalloc(sizeof(struct aat28xx_driver_data), GFP_KERNEL); if (!drvdata) { dev_err(&i2c_dev->dev, "failed to allocate memory\n"); return -ENOMEM; } if (pdata && pdata->platform_init) pdata->platform_init(); drvdata->client = i2c_dev; drvdata->gpio = pdata->gpio; drvdata->max_intensity = LCD_LED_MAX; if (pdata->max_current > 0) drvdata->max_intensity = pdata->max_current; drvdata->intensity = LCD_LED_MIN; drvdata->mode = NORMAL_MODE; drvdata->state = UNINIT_STATE; drvdata->version = pdata->version; if(aat28xx_setup_version(drvdata) != 0) { eprintk("Error while requesting gpio %d\n", drvdata->gpio); kfree(drvdata); return -ENODEV; } if (drvdata->gpio && gpio_request(drvdata->gpio, "aat28xx_en") != 0) { eprintk("Error while requesting gpio %d\n", drvdata->gpio); kfree(drvdata); return -ENODEV; } bd = backlight_device_register("aat28xx-bl", &i2c_dev->dev, NULL, &aat28xx_ops, NULL); if (bd == NULL) { eprintk("entering aat28xx probe function error \n"); if (gpio_is_valid(drvdata->gpio)) gpio_free(drvdata->gpio); kfree(drvdata); return -1; } bd->props.power = FB_BLANK_UNBLANK; bd->props.brightness = drvdata->intensity; bd->props.max_brightness = drvdata->max_intensity; drvdata->bd = bd; #ifdef CONFIG_BACKLIGHT_LEDS_CLASS if (led_classdev_register(&i2c_dev->dev, &aat28xx_led_dev) == 0) { eprintk("Registering led class dev successfully.\n"); drvdata->led = &aat28xx_led_dev; err = device_create_file(drvdata->led->dev, &dev_attr_alc); err = device_create_file(drvdata->led->dev, &dev_attr_reg); err = device_create_file(drvdata->led->dev, &dev_attr_drvstat); } #endif i2c_set_clientdata(i2c_dev, drvdata); i2c_set_adapdata(i2c_dev->adapter, i2c_dev); aat28xx_device_init(drvdata); aat28xx_send_intensity(drvdata, DEFAULT_BRIGHTNESS); #ifdef CONFIG_HAS_EARLYSUSPEND drvdata->early_suspend.suspend = aat28xx_early_suspend; drvdata->early_suspend.resume = aat28xx_late_resume; drvdata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 40; register_early_suspend(&drvdata->early_suspend); #endif aat28xx_ref = drvdata; eprintk("done\n"); return 0; }
static int aat28xx_set_brightness(struct backlight_device *bd) { struct aat28xx_driver_data *drvdata = dev_get_drvdata(bd->dev.parent); return aat28xx_send_intensity(drvdata, bd->props.brightness); }
static int __init aat28xx_probe(struct i2c_client *i2c_dev, const struct i2c_device_id *i2c_dev_id) { struct aat28xx_platform_data *pdata; struct aat28xx_driver_data *drvdata; struct backlight_device *bd; int err; dprintk("start, client addr=0x%x\n", i2c_dev->addr); pdata = i2c_dev->dev.platform_data; if(!pdata) return -EINVAL; drvdata = kzalloc(sizeof(struct aat28xx_driver_data), GFP_KERNEL); if (!drvdata) { dev_err(&i2c_dev->dev, "failed to allocate memory\n"); return -ENOMEM; } if (pdata && pdata->platform_init) pdata->platform_init(); drvdata->client = i2c_dev; drvdata->gpio = pdata->gpio; /* LGE_CHANGE [[email protected]] 2010-12-27, prove LCD */ #if defined(CONFIG_FB_MSM_MDDI_NOVATEK_HITACHI_HVGA) lge_probe_lcd(); if (g_mddi_lcd_probe == 0) { /* Hitachi LCD */ drvdata->max_intensity = 19; // 21; } else { /* Novatek LCD */ drvdata->max_intensity = 17; } #else drvdata->max_intensity = LCD_LED_MAX; #endif if (pdata->max_current > 0) drvdata->max_intensity = pdata->max_current; drvdata->intensity = LCD_LED_MIN; drvdata->mode = NORMAL_MODE; drvdata->state = UNINIT_STATE; drvdata->version = pdata->version; if(aat28xx_setup_version(drvdata) != 0) { eprintk("Error while requesting gpio %d\n", drvdata->gpio); kfree(drvdata); return -ENODEV; } if (drvdata->gpio && gpio_request(drvdata->gpio, "aat28xx_en") != 0) { eprintk("Error while requesting gpio %d\n", drvdata->gpio); kfree(drvdata); return -ENODEV; } // LGE_CHANGE [[email protected]] 2010-07-12, // set the en as the high if (drvdata->gpio) gpio_direction_output(drvdata->gpio, 1); bd = backlight_device_register("aat28xx-bl", &i2c_dev->dev, NULL, &aat28xx_ops, NULL); if (bd == NULL) { eprintk("entering aat28xx probe function error \n"); if (gpio_is_valid(drvdata->gpio)) gpio_free(drvdata->gpio); kfree(drvdata); return -1; } bd->props.power = FB_BLANK_UNBLANK; bd->props.brightness = drvdata->intensity; bd->props.max_brightness = drvdata->max_intensity; drvdata->bd = bd; #ifdef CONFIG_BACKLIGHT_LEDS_CLASS if (led_classdev_register(&i2c_dev->dev, &aat28xx_led_dev) == 0) { eprintk("Registering led class dev successfully.\n"); drvdata->led = &aat28xx_led_dev; err = device_create_file(drvdata->led->dev, &dev_attr_alc); err = device_create_file(drvdata->led->dev, &dev_attr_reg); err = device_create_file(drvdata->led->dev, &dev_attr_drvstat); /* LGE_CHANGE [[email protected]] 2010-06-22, backlight on/off */ err = device_create_file(drvdata->led->dev, &dev_attr_bl_onoff); } #endif i2c_set_clientdata(i2c_dev, drvdata); i2c_set_adapdata(i2c_dev->adapter, i2c_dev); aat28xx_device_init(drvdata); aat28xx_send_intensity(drvdata, DEFAULT_BRIGHTNESS); #ifdef CONFIG_HAS_EARLYSUSPEND drvdata->early_suspend.suspend = aat28xx_early_suspend; drvdata->early_suspend.resume = aat28xx_late_resume; drvdata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN - 40; register_early_suspend(&drvdata->early_suspend); #endif eprintk("done\n"); return 0; }
static int aat28xx_change_max_current(struct aat28xx_driver_data *drvdata, int max_current) { drvdata->max_intensity = max_current; return aat28xx_send_intensity(drvdata, drvdata->max_intensity); }