static int ktd259_probe(struct platform_device *pdev) { struct backlight_properties props; struct backlight_device *ktd259_backlight_device; struct ktd259 *pKtd259Data; struct ktd259x_bl_platform_data *pd; int ret = 0; dev_dbg(&pdev->dev, "%s function enter\n", __func__); pKtd259Data = kmalloc(sizeof(struct ktd259), GFP_KERNEL); memset(pKtd259Data, 0, sizeof(struct ktd259)); pKtd259Data->currentRatio = DEFAULT_RATIO; pKtd259Data->brightness = DEFAULT_BRINGHESS; pKtd259Data->pd = pdev->dev.platform_data; memset(&props, 0, sizeof(struct backlight_properties)); props.max_brightness = pKtd259Data->pd->max_brightness; props.type = BACKLIGHT_RAW; ktd259_backlight_device = backlight_device_register( "panel", &pdev->dev, pKtd259Data, &ktd259_ops, &props); if (IS_ERR(ktd259_backlight_device)) { dev_info(&pdev->dev, "backlight_device_register() failed\n"); ret = PTR_ERR(ktd259_backlight_device); } else { ktd259_backlight_device->props.power = FB_BLANK_UNBLANK; ktd259_backlight_device->props.brightness = DEFAULT_BRINGHESS; ktd259_set_brightness(ktd259_backlight_device); } #ifdef CONFIG_HAS_EARLYSUSPEND pKtd259Data->earlysuspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1; pKtd259Data->earlysuspend.suspend = ktd259_early_suspend; pKtd259Data->earlysuspend.resume = ktd259_late_resume; register_early_suspend(&pKtd259Data->earlysuspend); pKtd259Data->backlight_disabled = false; #endif pd = pKtd259Data->pd; pd->bd = ktd259_backlight_device; /* If external control of the backlight has been requested, then provide interface function in backlight platform data */ if (pd->external_bl_control) pd->bl_on_off = ktd259_backlight_on_off; dev_dbg(&pdev->dev, "%s function exit\n", __func__); return ret; }
/* Control function to switch the backlight on/off. May be called by suspend/resume or externally */ static void ktd259_backlight_on_off(struct backlight_device *bd, bool on) { struct ktd259 *pKtd259Data = bl_get_data(bd); dev_dbg(&bd->dev, "%s function enter\n", __func__); if (on){ pKtd259Data->backlight_disabled = false; bd->props.brightness = pKtd259Data->brightness; ktd259_set_brightness(bd); } else { pKtd259Data->backlight_disabled = true; gpio_set_value(pKtd259Data->pd->ctrl_gpio, pKtd259Data->pd->ctrl_low); pKtd259Data->currentRatio = KTD259_BACKLIGHT_OFF; } }
static int ktd259_probe(struct platform_device *pdev) { struct backlight_properties props; struct backlight_device *ktd259_backlight_device; struct ktd259 *pKtd259Data; int ret = 0; dev_dbg(&pdev->dev, "%s fuction enter\n", __func__); pKtd259Data = kmalloc(sizeof(struct ktd259), GFP_KERNEL); memset(pKtd259Data, 0, sizeof(struct ktd259)); pKtd259Data->currentRatio = KTD259_BACKLIGHT_OFF; pKtd259Data->brightness = KTD259_BACKLIGHT_OFF; pKtd259Data->pd = pdev->dev.platform_data; memset(&props, 0, sizeof(struct backlight_properties)); props.max_brightness = pKtd259Data->pd->max_brightness; props.type = BACKLIGHT_RAW; ktd259_backlight_device = backlight_device_register( "panel", &pdev->dev, pKtd259Data, &ktd259_ops, &props); if (IS_ERR(ktd259_backlight_device)) { dev_info(&pdev->dev, "backlight_device_register() failed\n"); ret = PTR_ERR(ktd259_backlight_device); } else { ktd259_backlight_device->props.power = FB_BLANK_UNBLANK; ktd259_backlight_device->props.brightness = ktd259_backlight_device->props.max_brightness; ktd259_set_brightness(ktd259_backlight_device); } #ifdef CONFIG_HAS_EARLYSUSPEND pKtd259Data->earlysuspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1; pKtd259Data->earlysuspend.suspend = ktd259_early_suspend; pKtd259Data->earlysuspend.resume = ktd259_late_resume; register_early_suspend(&pKtd259Data->earlysuspend); #endif dev_dbg(&pdev->dev, "%s fuction exit\n", __func__); return ret; }