Example #1
0
static int __devinit adp8870_probe(struct i2c_client *client,
					const struct i2c_device_id *id)
{
	struct backlight_device *bl;
	struct adp8870_bl *data;
	struct adp8870_backlight_platform_data *pdata =
		client->dev.platform_data;
	uint8_t reg_val;
	int ret;

	if (!i2c_check_functionality(client->adapter,
					I2C_FUNC_SMBUS_BYTE_DATA)) {
		dev_err(&client->dev, "SMBUS Byte Data not Supported\n");
		return -EIO;
	}

	if (!pdata) {
		dev_err(&client->dev, "no platform data?\n");
		return -EINVAL;
	}

	ret = adp8870_read(client, ADP8870_MFDVID, &reg_val);
	if (ret < 0)
		return -EIO;

	if (ADP8870_MANID(reg_val) != ADP8870_MANUFID) {
		dev_err(&client->dev, "failed to probe\n");
		return -ENODEV;
	}

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if (data == NULL)
		return -ENOMEM;

	data->revid = ADP8870_DEVID(reg_val);
	data->client = client;
	data->pdata = pdata;
	data->id = id->driver_data;
	data->current_brightness = 0;
	i2c_set_clientdata(client, data);

	mutex_init(&data->lock);

	bl = backlight_device_register(dev_driver_string(&client->dev),
			&client->dev, data, &adp8870_bl_ops);
	if (IS_ERR(bl)) {
		dev_err(&client->dev, "failed to register backlight\n");
		ret = PTR_ERR(bl);
		goto out2;
	}

	bl->props.max_brightness =
		bl->props.brightness = ADP8870_MAX_BRIGHTNESS;

	data->bl = bl;

	if (pdata->en_ambl_sens)
		ret = sysfs_create_group(&bl->dev.kobj,
			&adp8870_bl_attr_group);

	if (ret) {
		dev_err(&client->dev, "failed to register sysfs\n");
		goto out1;
	}

	ret = adp8870_bl_setup(bl);
	if (ret) {
		ret = -EIO;
		goto out;
	}

	dev_info(&client->dev, "Rev.%d Backlight\n", data->revid);

	if (pdata->num_leds)
		adp8870_led_probe(client);

	return 0;

out:
	if (data->pdata->en_ambl_sens)
		sysfs_remove_group(&data->bl->dev.kobj,
			&adp8870_bl_attr_group);
out1:
	backlight_device_unregister(bl);
out2:
	i2c_set_clientdata(client, NULL);
	kfree(data);

	return ret;
}
Example #2
0
void psb_intel_panel_destroy_backlight(struct drm_device *dev)
{
    struct drm_psb_private *dev_priv = dev->dev_private;
    if (dev_priv->backlight)
        backlight_device_unregister(dev_priv->backlight);
}
static int __init atmel_pwm_bl_probe(struct platform_device *pdev)
{
	struct backlight_properties props;
	const struct atmel_pwm_bl_platform_data *pdata;
	struct backlight_device *bldev;
	struct atmel_pwm_bl *pwmbl;
	int retval;

	pwmbl = devm_kzalloc(&pdev->dev, sizeof(struct atmel_pwm_bl),
				GFP_KERNEL);
	if (!pwmbl)
		return -ENOMEM;

	pwmbl->pdev = pdev;

	pdata = pdev->dev.platform_data;
	if (!pdata) {
		retval = -ENODEV;
		goto err_free_mem;
	}

	if (pdata->pwm_compare_max < pdata->pwm_duty_max ||
			pdata->pwm_duty_min > pdata->pwm_duty_max ||
			pdata->pwm_frequency == 0) {
		retval = -EINVAL;
		goto err_free_mem;
	}

	pwmbl->pdata = pdata;
	pwmbl->gpio_on = pdata->gpio_on;

	retval = pwm_channel_alloc(pdata->pwm_channel, &pwmbl->pwmc);
	if (retval)
		goto err_free_mem;

	if (pwmbl->gpio_on != -1) {
		retval = devm_gpio_request(&pdev->dev, pwmbl->gpio_on,
					"gpio_atmel_pwm_bl");
		if (retval) {
			pwmbl->gpio_on = -1;
			goto err_free_pwm;
		}

		/* Turn display off by default. */
		retval = gpio_direction_output(pwmbl->gpio_on,
				0 ^ pdata->on_active_low);
		if (retval)
			goto err_free_pwm;
	}

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = pdata->pwm_duty_max - pdata->pwm_duty_min;
	bldev = backlight_device_register("atmel-pwm-bl", &pdev->dev, pwmbl,
					  &atmel_pwm_bl_ops, &props);
	if (IS_ERR(bldev)) {
		retval = PTR_ERR(bldev);
		goto err_free_pwm;
	}

	pwmbl->bldev = bldev;

	platform_set_drvdata(pdev, pwmbl);

	/* Power up the backlight by default at middle intesity. */
	bldev->props.power = FB_BLANK_UNBLANK;
	bldev->props.brightness = bldev->props.max_brightness / 2;

	retval = atmel_pwm_bl_init_pwm(pwmbl);
	if (retval)
		goto err_free_bl_dev;

	atmel_pwm_bl_set_intensity(bldev);

	return 0;

err_free_bl_dev:
	platform_set_drvdata(pdev, NULL);
	backlight_device_unregister(bldev);
err_free_pwm:
	pwm_channel_free(&pwmbl->pwmc);
err_free_mem:
	return retval;
}
Example #4
0
static int __init msi_init(void)
{
	int ret;

	if (acpi_disabled)
		return -ENODEV;

	dmi_check_system(msi_dmi_table);
	if (!quirks)
		/* quirks may be NULL if no match in DMI table */
		quirks = &quirk_load_scm_model;
	if (force)
		quirks = &quirk_old_ec_model;

	if (!quirks->old_ec_model)
		get_threeg_exists();

	if (auto_brightness < 0 || auto_brightness > 2)
		return -EINVAL;

	/* Register backlight stuff */

	if (!quirks->old_ec_model || acpi_video_backlight_support()) {
		pr_info("Brightness ignored, must be controlled by ACPI video driver\n");
	} else {
		struct backlight_properties props;
		memset(&props, 0, sizeof(struct backlight_properties));
		props.type = BACKLIGHT_PLATFORM;
		props.max_brightness = MSI_LCD_LEVEL_MAX - 1;
		msibl_device = backlight_device_register("msi-laptop-bl", NULL,
							 NULL, &msibl_ops,
							 &props);
		if (IS_ERR(msibl_device))
			return PTR_ERR(msibl_device);
	}

	ret = platform_driver_register(&msipf_driver);
	if (ret)
		goto fail_backlight;

	/* Register platform stuff */

	msipf_device = platform_device_alloc("msi-laptop-pf", -1);
	if (!msipf_device) {
		ret = -ENOMEM;
		goto fail_platform_driver;
	}

	ret = platform_device_add(msipf_device);
	if (ret)
		goto fail_platform_device1;

	if (quirks->load_scm_model && (load_scm_model_init(msipf_device) < 0)) {
		ret = -EINVAL;
		goto fail_platform_device1;
	}

	ret = sysfs_create_group(&msipf_device->dev.kobj,
				 &msipf_attribute_group);
	if (ret)
		goto fail_platform_device2;

	if (!quirks->old_ec_model) {
		if (threeg_exists)
			ret = device_create_file(&msipf_device->dev,
						&dev_attr_threeg);
		if (ret)
			goto fail_platform_device2;
	} else {
		ret = sysfs_create_group(&msipf_device->dev.kobj,
					 &msipf_old_attribute_group);
		if (ret)
			goto fail_platform_device2;

		/* Disable automatic brightness control by default because
		 * this module was probably loaded to do brightness control in
		 * software. */

		if (auto_brightness != 2)
			set_auto_brightness(auto_brightness);
	}

	pr_info("driver " MSI_DRIVER_VERSION " successfully loaded\n");

	return 0;

fail_platform_device2:

	if (quirks->load_scm_model) {
		i8042_remove_filter(msi_laptop_i8042_filter);
		cancel_delayed_work_sync(&msi_rfkill_dwork);
		cancel_work_sync(&msi_rfkill_work);
		rfkill_cleanup();
	}
	platform_device_del(msipf_device);

fail_platform_device1:

	platform_device_put(msipf_device);

fail_platform_driver:

	platform_driver_unregister(&msipf_driver);

fail_backlight:

	backlight_device_unregister(msibl_device);

	return ret;
}
static int cr_backlight_probe(struct platform_device *pdev)
{
	struct backlight_properties props;
	struct backlight_device *bdp;
	struct lcd_device *ldp;
	struct cr_panel *crp;
	u8 dev_en;

	lpc_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
					CRVML_DEVICE_LPC, NULL);
	if (!lpc_dev) {
		pr_err("INTEL CARILLO RANCH LPC not found.\n");
		return -ENODEV;
	}

	pci_read_config_byte(lpc_dev, CRVML_REG_GPIOEN, &dev_en);
	if (!(dev_en & CRVML_GPIOEN_BIT)) {
		pr_err("Carillo Ranch GPIO device was not enabled.\n");
		pci_dev_put(lpc_dev);
		return -ENODEV;
	}

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	bdp = backlight_device_register("cr-backlight", &pdev->dev, NULL,
					&cr_backlight_ops, &props);
	if (IS_ERR(bdp)) {
		pci_dev_put(lpc_dev);
		return PTR_ERR(bdp);
	}

	ldp = lcd_device_register("cr-lcd", &pdev->dev, NULL, &cr_lcd_ops);
	if (IS_ERR(ldp)) {
		backlight_device_unregister(bdp);
		pci_dev_put(lpc_dev);
		return PTR_ERR(ldp);
	}

	pci_read_config_dword(lpc_dev, CRVML_REG_GPIOBAR,
			      &gpio_bar);
	gpio_bar &= ~0x3F;

	crp = devm_kzalloc(&pdev->dev, sizeof(*crp), GFP_KERNEL);
	if (!crp) {
		lcd_device_unregister(ldp);
		backlight_device_unregister(bdp);
		pci_dev_put(lpc_dev);
		return -ENOMEM;
	}

	crp->cr_backlight_device = bdp;
	crp->cr_lcd_device = ldp;
	crp->cr_backlight_device->props.power = FB_BLANK_UNBLANK;
	crp->cr_backlight_device->props.brightness = 0;
	cr_backlight_set_intensity(crp->cr_backlight_device);
	cr_lcd_set_power(crp->cr_lcd_device, FB_BLANK_UNBLANK);

	platform_set_drvdata(pdev, crp);

	return 0;
}
static void asus_backlight_exit(struct asus_laptop *asus)
{
	if (asus->backlight_device)
		backlight_device_unregister(asus->backlight_device);
	asus->backlight_device = NULL;
}
Example #7
0
static void oaktrail_backlight_exit(void)
{
	backlight_device_unregister(oaktrail_bl_device);
}
Example #8
0
static int pm860x_backlight_probe(struct platform_device *pdev)
{
	struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
	struct pm860x_platform_data *pm860x_pdata;
	struct pm860x_backlight_pdata *pdata = NULL;
	struct pm860x_backlight_data *data;
	struct backlight_device *bl;
	struct resource *res;
	struct backlight_properties props;
	unsigned char value;
	char name[MFD_NAME_SIZE];
	int ret;

	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "No I/O resource!\n");
		return -EINVAL;
	}

	if (pdev->dev.parent->platform_data) {
		pm860x_pdata = pdev->dev.parent->platform_data;
		pdata = pm860x_pdata->backlight;
	}
	if (pdata == NULL) {
		dev_err(&pdev->dev, "platform data isn't assigned to "
			"backlight\n");
		return -EINVAL;
	}

	data = kzalloc(sizeof(struct pm860x_backlight_data), GFP_KERNEL);
	if (data == NULL)
		return -ENOMEM;
	strncpy(name, res->name, MFD_NAME_SIZE);
	data->chip = chip;
	data->i2c = (chip->id == CHIP_PM8606) ? chip->client	\
			: chip->companion;
	data->current_brightness = MAX_BRIGHTNESS;
	data->pwm = pdata->pwm;
	data->iset = pdata->iset;
	data->port = __check_device(pdata, name);
	if (data->port < 0) {
		dev_err(&pdev->dev, "wrong platform data is assigned");
		kfree(data);
		return -EINVAL;
	}

	memset(&props, 0, sizeof(struct backlight_properties));
	props.max_brightness = MAX_BRIGHTNESS;
	bl = backlight_device_register(name, &pdev->dev, data,
					&pm860x_backlight_ops, &props);
	if (IS_ERR(bl)) {
		dev_err(&pdev->dev, "failed to register backlight\n");
		kfree(data);
		return PTR_ERR(bl);
	}
	bl->props.brightness = MAX_BRIGHTNESS;

	platform_set_drvdata(pdev, bl);

	/* Enable reference VSYS */
	ret = pm860x_reg_read(data->i2c, PM8606_VSYS);
	if (ret < 0)
		goto out;
	if ((ret & PM8606_VSYS_EN) == 0) {
		value = ret | PM8606_VSYS_EN;
		ret = pm860x_reg_write(data->i2c, PM8606_VSYS, value);
		if (ret < 0)
			goto out;
	}
	/* Enable reference OSC */
	ret = pm860x_reg_read(data->i2c, PM8606_MISC);
	if (ret < 0)
		goto out;
	if ((ret & PM8606_MISC_OSC_EN) == 0) {
		value = ret | PM8606_MISC_OSC_EN;
		ret = pm860x_reg_write(data->i2c, PM8606_MISC, value);
		if (ret < 0)
			goto out;
	}
	/* read current backlight */
	ret = pm860x_backlight_get_brightness(bl);
	if (ret < 0)
		goto out;

	backlight_update_status(bl);
	return 0;
out:
	backlight_device_unregister(bl);
	kfree(data);
	return ret;
}
static void lp855x_backlight_unregister(struct lp855x *lp)
{
	if (lp->bl)
		backlight_device_unregister(lp->bl);
}
Example #10
0
static int __devinit max8925_backlight_probe(struct platform_device *pdev)
{
	struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
	struct max8925_platform_data *max8925_pdata;
	struct max8925_backlight_pdata *pdata = NULL;
	struct max8925_backlight_data *data;
	struct backlight_device *bl;
	struct backlight_properties props;
	struct resource *res;
	char name[MAX8925_NAME_SIZE];
	unsigned char value;
	int ret;

	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "No I/O resource!\n");
		return -EINVAL;
	}

	if (pdev->dev.parent->platform_data) {
		max8925_pdata = pdev->dev.parent->platform_data;
		pdata = max8925_pdata->backlight;
	}

	if (!pdata) {
		dev_err(&pdev->dev, "platform data isn't assigned to "
			"backlight\n");
		return -EINVAL;
	}

	data = kzalloc(sizeof(struct max8925_backlight_data), GFP_KERNEL);
	if (data == NULL)
		return -ENOMEM;
	strncpy(name, res->name, MAX8925_NAME_SIZE);
	data->chip = chip;
	data->current_brightness = 0;

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = MAX_BRIGHTNESS;
	bl = backlight_device_register(name, &pdev->dev, data,
					&max8925_backlight_ops, &props);
	if (IS_ERR(bl)) {
		dev_err(&pdev->dev, "failed to register backlight\n");
		kfree(data);
		return PTR_ERR(bl);
	}
	bl->props.brightness = MAX_BRIGHTNESS;

	platform_set_drvdata(pdev, bl);

	value = 0;
	if (pdata->lxw_scl)
		value |= (1 << 7);
	if (pdata->lxw_freq)
		value |= (LWX_FREQ(pdata->lxw_freq) << 4);
	if (pdata->dual_string)
		value |= (1 << 1);
	ret = max8925_set_bits(chip->i2c, MAX8925_WLED_MODE_CNTL, 0xfe, value);
	if (ret < 0)
		goto out;

	backlight_update_status(bl);
	return 0;
out:
	backlight_device_unregister(bl);
	kfree(data);
	return ret;
}
static int pm860x_backlight_probe(struct platform_device *pdev)
{
	struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
	struct pm860x_backlight_pdata *pdata = NULL;
	struct pm860x_backlight_data *data;
	struct backlight_device *bl;
	struct resource *res;
	struct backlight_properties props;
	char name[MFD_NAME_SIZE];
	int ret;

	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "No I/O resource!\n");
		return -EINVAL;
	}

	pdata = pdev->dev.platform_data;
	if (pdata == NULL) {
		dev_err(&pdev->dev, "platform data isn't assigned to "
			"backlight\n");
		return -EINVAL;
	}

	data = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_backlight_data),
			    GFP_KERNEL);
	if (data == NULL)
		return -ENOMEM;
	strncpy(name, res->name, MFD_NAME_SIZE);
	data->chip = chip;
	data->i2c = (chip->id == CHIP_PM8606) ? chip->client	\
			: chip->companion;
	data->current_brightness = MAX_BRIGHTNESS;
	data->pwm = pdata->pwm;
	data->iset = pdata->iset;
	data->port = pdata->flags;
	if (data->port < 0) {
		dev_err(&pdev->dev, "wrong platform data is assigned");
		return -EINVAL;
	}

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = MAX_BRIGHTNESS;
	bl = backlight_device_register(name, &pdev->dev, data,
					&pm860x_backlight_ops, &props);
	if (IS_ERR(bl)) {
		dev_err(&pdev->dev, "failed to register backlight\n");
		return PTR_ERR(bl);
	}
	bl->props.brightness = MAX_BRIGHTNESS;

	platform_set_drvdata(pdev, bl);

	
	ret = pm860x_backlight_get_brightness(bl);
	if (ret < 0)
		goto out;

	backlight_update_status(bl);
	return 0;
out:
	backlight_device_unregister(bl);
	return ret;
}
Example #12
0
static int acx565akm_probe(struct spi_device *spi)
{
	struct panel_drv_data *ddata;
	struct omap_dss_device *dssdev;
	struct backlight_device *bldev;
	int max_brightness, brightness;
	struct backlight_properties props;
	int r;

	dev_dbg(&spi->dev, "%s\n", __func__);

	spi->mode = SPI_MODE_3;

	ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL);
	if (ddata == NULL)
		return -ENOMEM;

	dev_set_drvdata(&spi->dev, ddata);

	ddata->spi = spi;

	mutex_init(&ddata->mutex);

	if (dev_get_platdata(&spi->dev)) {
		r = acx565akm_probe_pdata(spi);
		if (r)
			return r;
	} else if (spi->dev.of_node) {
		r = acx565akm_probe_of(spi);
		if (r)
			return r;
	} else {
		dev_err(&spi->dev, "platform data missing!\n");
		return -ENODEV;
	}

	if (gpio_is_valid(ddata->reset_gpio)) {
		r = devm_gpio_request_one(&spi->dev, ddata->reset_gpio,
				GPIOF_OUT_INIT_LOW, "lcd reset");
		if (r)
			goto err_gpio;
	}

	if (gpio_is_valid(ddata->reset_gpio))
		gpio_set_value(ddata->reset_gpio, 1);

	/*
	 * After reset we have to wait 5 msec before the first
	 * command can be sent.
	 */
	usleep_range(5000, 10000);

	ddata->enabled = panel_enabled(ddata);

	r = panel_detect(ddata);

	if (!ddata->enabled && gpio_is_valid(ddata->reset_gpio))
		gpio_set_value(ddata->reset_gpio, 0);

	if (r) {
		dev_err(&spi->dev, "%s panel detect error\n", __func__);
		goto err_detect;
	}

	memset(&props, 0, sizeof(props));
	props.fb_blank = FB_BLANK_UNBLANK;
	props.power = FB_BLANK_UNBLANK;
	props.type = BACKLIGHT_RAW;

	bldev = backlight_device_register("acx565akm", &ddata->spi->dev,
			ddata, &acx565akm_bl_ops, &props);
	if (IS_ERR(bldev)) {
		r = PTR_ERR(bldev);
		goto err_reg_bl;
	}
	ddata->bl_dev = bldev;
	if (ddata->has_cabc) {
		r = sysfs_create_group(&bldev->dev.kobj, &bldev_attr_group);
		if (r) {
			dev_err(&bldev->dev,
				"%s failed to create sysfs files\n", __func__);
			goto err_sysfs;
		}
		ddata->cabc_mode = get_hw_cabc_mode(ddata);
	}

	max_brightness = 255;

	if (ddata->has_bc)
		brightness = acx565akm_get_actual_brightness(ddata);
	else
		brightness = 0;

	bldev->props.max_brightness = max_brightness;
	bldev->props.brightness = brightness;

	acx565akm_bl_update_status(bldev);


	ddata->videomode = acx565akm_panel_timings;

	dssdev = &ddata->dssdev;
	dssdev->dev = &spi->dev;
	dssdev->driver = &acx565akm_ops;
	dssdev->type = OMAP_DISPLAY_TYPE_SDI;
	dssdev->owner = THIS_MODULE;
	dssdev->panel.timings = ddata->videomode;

	r = omapdss_register_display(dssdev);
	if (r) {
		dev_err(&spi->dev, "Failed to register panel\n");
		goto err_reg;
	}

	return 0;

err_reg:
	sysfs_remove_group(&bldev->dev.kobj, &bldev_attr_group);
err_sysfs:
	backlight_device_unregister(bldev);
err_reg_bl:
err_detect:
err_gpio:
	omap_dss_put_device(ddata->in);
	return r;
}
Example #13
0
static int __devinit ws2401_dpi_mcde_panel_probe(
    struct mcde_display_device *ddev)
{
    int ret = 0;
    struct ws2401_dpi *lcd = NULL;
    struct backlight_device *bd = NULL;
    struct ssg_dpi_display_platform_data *pdata = ddev->dev.platform_data;

    dev_dbg(&ddev->dev, "Invoked %s\n", __func__);

    if (pdata == NULL) {
        dev_err(&ddev->dev, "%s:Platform data missing\n", __func__);
        ret = -EINVAL;
        goto no_pdata;
    }

    if (ddev->port->type != MCDE_PORTTYPE_DPI) {
        dev_err(&ddev->dev,
                "%s:Invalid port type %d\n",
                __func__, ddev->port->type);
        ret = -EINVAL;
        goto invalid_port_type;
    }

    ddev->prepare_for_update = NULL;
    ddev->try_video_mode = try_video_mode;
    ddev->set_video_mode = set_video_mode;

    lcd = kzalloc(sizeof(struct ws2401_dpi), GFP_KERNEL);
    if (!lcd)
        return -ENOMEM;

    mutex_init(&lcd->lock);

    dev_set_drvdata(&ddev->dev, lcd);
    lcd->mdd = ddev;
    lcd->dev = &ddev->dev;
    lcd->pd = pdata;

#ifdef CONFIG_LCD_CLASS_DEVICE
    lcd->ld = lcd_device_register("panel", &ddev->dev,
                                  lcd, &ws2401_dpi_lcd_ops);
    if (IS_ERR(lcd->ld)) {
        ret = PTR_ERR(lcd->ld);
        goto out_free_lcd;
    } else {
        ret = device_create_file(&(lcd->ld->dev), &dev_attr_panel_type);
        if (ret < 0)
            dev_err(&(lcd->ld->dev),
                    "failed to add panel_type sysfs entries\n");
        ret = device_create_file(&(lcd->ld->dev), &dev_attr_panel_id);
        if (ret < 0)
            dev_err(&(lcd->ld->dev),
                    "failed to add panel_id sysfs entries\n");
    }
#endif

    mutex_init(&lcd->lock);

    if (pdata->bl_ctrl) {
        bd = backlight_device_register("pwm-backlight",
                                       &ddev->dev,
                                       lcd,
                                       &ws2401_dpi_backlight_ops,
                                       NULL);
        if (IS_ERR(bd)) {
            ret =  PTR_ERR(bd);
            goto out_backlight_unregister;
        }

        lcd->bd = bd;
        lcd->bd_enable = TRUE;
        lcd->bd->props.max_brightness = MAX_BRIGHTNESS;
        lcd->bd->props.brightness = DEFAULT_BRIGHTNESS;
    }
    ret = device_create_file(&(ddev->dev), &dev_attr_lcd_power);
    if (ret < 0)
        dev_err(&(ddev->dev),
                "failed to add lcd_power sysfs entries\n");

    lcd->spi_drv.driver.name	= "pri_lcd_spi";
    lcd->spi_drv.driver.bus		= &spi_bus_type;
    lcd->spi_drv.driver.owner	= THIS_MODULE;
    lcd->spi_drv.probe		= ws2401_dpi_spi_probe;
    ret = spi_register_driver(&lcd->spi_drv);
    if (ret < 0) {
        dev_err(&(ddev->dev), "Failed to register SPI driver");
        goto out_backlight_unregister;
    }

#ifdef CONFIG_HAS_EARLYSUSPEND
    lcd->earlysuspend.level   = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1;
    lcd->earlysuspend.suspend = ws2401_dpi_mcde_panel_early_suspend;
    lcd->earlysuspend.resume  = ws2401_dpi_mcde_panel_late_resume;
    register_early_suspend(&lcd->earlysuspend);
#endif
    ws2401_update_brightness(lcd);

    if (prcmu_qos_add_requirement(PRCMU_QOS_APE_OPP,
                                  "codina_lcd_dpi", 100)) {
        pr_info("pcrm_qos_add APE failed\n");
    }

    dev_dbg(&ddev->dev, "DPI display probed\n");

    goto out;

out_backlight_unregister:
    if (pdata->bl_ctrl)
        backlight_device_unregister(bd);
out_free_lcd:
    mutex_destroy(&lcd->lock);
    kfree(lcd);
invalid_port_type:
no_pdata:
out:
    return ret;
}
Example #14
0
static int __devinit lm3530_probe(struct i2c_client *i2c_dev,
		const struct i2c_device_id *id)
{
	struct backlight_platform_data *pdata;
	struct lm3530_device *dev;
	struct backlight_device *bl_dev;
	struct backlight_properties props;
	int err = 0;

	pdata = i2c_dev->dev.platform_data;
	if (!pdata)
		return -ENODEV;

	dev = kzalloc(sizeof(struct lm3530_device), GFP_KERNEL);
	if (!dev) {
		dev_err(&i2c_dev->dev, "out of memory\n");
		return -ENOMEM;
	}

	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = pdata->max_brightness;

	bl_dev = backlight_device_register(I2C_BL_NAME, &i2c_dev->dev, NULL,
			&lm3530_bl_ops, &props);
	if (IS_ERR(bl_dev)) {
		dev_err(&i2c_dev->dev, "failed to register backlight\n");
		err = PTR_ERR(bl_dev);
		goto err_backlight_device_register;
	}
	bl_dev->props.max_brightness = pdata->max_brightness;
	bl_dev->props.brightness = pdata->default_brightness;
	bl_dev->props.power = FB_BLANK_UNBLANK;

	dev->bl_dev = bl_dev;
	dev->client = i2c_dev;
	dev->gpio = pdata->gpio;
	dev->max_current = pdata->max_current;
	dev->min_brightness = pdata->min_brightness;
	dev->max_brightness = pdata->max_brightness;
	dev->default_brightness = pdata->default_brightness;
	dev->blmap = pdata->blmap;
	dev->blmap_size = pdata->blmap_size;
	i2c_set_clientdata(i2c_dev, dev);

	br_mode = 1;
	min_br = dev->min_brightness;
	max_br = dev->max_brightness;

	if (gpio_is_valid(dev->gpio)) {
		err = gpio_request(dev->gpio, "lm3530 reset");
		if (err < 0) {
			dev_err(&i2c_dev->dev, "failed to request gpio\n");
			goto err_gpio_request;
		}
	}

	err = device_create_file(&i2c_dev->dev, 
			&dev_attr_lm3530_level);
	if (err < 0) {
		dev_err(&i2c_dev->dev, "failed to create 1st sysfs\n");
		goto err_device_create_file_1;
	}
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_lm3530_backlight_on_off);
	if (err < 0) {
		dev_err(&i2c_dev->dev, "failed to create 2nd sysfs\n");
		goto err_device_create_file_2;
	}
	err = device_create_file(&i2c_dev->dev,
			&dev_attr_lm3530_pwm);
	if (err < 0) {
		dev_err(&i2c_dev->dev, "failed to create 3rd sysfs\n");
		goto err_device_create_file_3;
	}
	err = device_create_file(&i2c_dev->dev, 
			&dev_attr_lm3530_min_br);
	if (err < 0) {
		dev_err(&i2c_dev->dev, "failed to create 3nd sysfs\n");
		goto err_device_create_file_4;
	}
	err = device_create_file(&i2c_dev->dev, 
			&dev_attr_lm3530_max_br);
	if (err < 0) {
		dev_err(&i2c_dev->dev, "failed to create 4nd sysfs\n");
		goto err_device_create_file_5;
	}
	err = device_create_file(&i2c_dev->dev, 
			&dev_attr_lm3530_br_mode);
	if (err < 0) {
		dev_err(&i2c_dev->dev, "failed to create 5nd sysfs\n");
		goto err_device_create_file_6;
	}

	lm3530_i2c_client = i2c_dev;

	pr_info("lm3530 probed\n");
	return 0;

err_device_create_file_6:
	device_remove_file(&i2c_dev->dev, &dev_attr_lm3530_max_br);
err_device_create_file_5:
	device_remove_file(&i2c_dev->dev, &dev_attr_lm3530_min_br);
err_device_create_file_4:
	device_remove_file(&i2c_dev->dev, &dev_attr_lm3530_pwm);
err_device_create_file_3:
	device_remove_file(&i2c_dev->dev, &dev_attr_lm3530_backlight_on_off);
err_device_create_file_2:
	device_remove_file(&i2c_dev->dev, &dev_attr_lm3530_level);
err_device_create_file_1:
	if (gpio_is_valid(dev->gpio))
		gpio_free(dev->gpio);
err_gpio_request:
	backlight_device_unregister(bl_dev);
err_backlight_device_register:
	kfree(dev);

	return err;
}
Example #15
0
static int lm3639_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	int ret;
	struct lm3639_chip_data *pchip;
	struct lm3639_platform_data *pdata = client->dev.platform_data;
	struct backlight_properties props;

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		dev_err(&client->dev, "i2c functionality check fail.\n");
		return -EOPNOTSUPP;
	}

	if (pdata == NULL) {
		dev_err(&client->dev, "Needs Platform Data.\n");
		return -ENODATA;
	}

	pchip = devm_kzalloc(&client->dev,
			     sizeof(struct lm3639_chip_data), GFP_KERNEL);
	if (!pchip)
		return -ENOMEM;

	pchip->pdata = pdata;
	pchip->dev = &client->dev;

	pchip->regmap = devm_regmap_init_i2c(client, &lm3639_regmap);
	if (IS_ERR(pchip->regmap)) {
		ret = PTR_ERR(pchip->regmap);
		dev_err(&client->dev, "fail : allocate register map: %d\n",
			ret);
		return ret;
	}
	i2c_set_clientdata(client, pchip);

	/* chip initialize */
	ret = lm3639_chip_init(pchip);
	if (ret < 0) {
		dev_err(&client->dev, "fail : chip init\n");
		goto err_out;
	}

	/* backlight */
	props.type = BACKLIGHT_RAW;
	props.brightness = pdata->init_brt_led;
	props.max_brightness = pdata->max_brt_led;
	pchip->bled =
	    backlight_device_register("lm3639_bled", pchip->dev, pchip,
				      &lm3639_bled_ops, &props);
	if (IS_ERR(pchip->bled)) {
		dev_err(&client->dev, "fail : backlight register\n");
		ret = -EIO;
		goto err_out;
	}

	ret = device_create_file(&(pchip->bled->dev), &dev_attr_bled_mode);
	if (ret < 0) {
		dev_err(&client->dev, "failed : add sysfs entries\n");
		ret = -EIO;
		goto err_bled_mode;
	}

	/* flash */
	pchip->cdev_flash.name = "lm3639_flash";
	pchip->cdev_flash.max_brightness = 16;
	pchip->cdev_flash.brightness_set = lm3639_flash_brightness_set;
	ret = led_classdev_register((struct device *)
				    &client->dev, &pchip->cdev_flash);
	if (ret < 0) {
		dev_err(&client->dev, "fail : flash register\n");
		ret = -EIO;
		goto err_flash;
	}

	/* torch */
	pchip->cdev_torch.name = "lm3639_torch";
	pchip->cdev_torch.max_brightness = 8;
	pchip->cdev_torch.brightness_set = lm3639_torch_brightness_set;
	ret = led_classdev_register((struct device *)
				    &client->dev, &pchip->cdev_torch);
	if (ret < 0) {
		dev_err(&client->dev, "fail : torch register\n");
		ret = -EIO;
		goto err_torch;
	}

	return 0;

err_torch:
	led_classdev_unregister(&pchip->cdev_flash);
err_flash:
	device_remove_file(&(pchip->bled->dev), &dev_attr_bled_mode);
err_bled_mode:
	backlight_device_unregister(pchip->bled);
err_out:
	return ret;
}
Example #16
0
static int __devinit adp8860_probe(struct i2c_client *client,
					const struct i2c_device_id *id)
{
	struct backlight_device *bl;
	struct adp8860_bl *data;
	struct adp8860_backlight_platform_data *pdata =
		client->dev.platform_data;
	struct backlight_properties props;
	uint8_t reg_val;
	int ret;

	if (!i2c_check_functionality(client->adapter,
					I2C_FUNC_SMBUS_BYTE_DATA)) {
		dev_err(&client->dev, "SMBUS Byte Data not Supported\n");
		return -EIO;
	}

	if (!pdata) {
		dev_err(&client->dev, "no platform data?\n");
		return -EINVAL;
	}

	data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
	if (data == NULL)
		return -ENOMEM;

	ret = adp8860_read(client, ADP8860_MFDVID, &reg_val);
	if (ret < 0)
		return ret;

	switch (ADP8860_MANID(reg_val)) {
	case ADP8863_MANUFID:
		data->gdwn_dis = !!pdata->gdwn_dis;
	case ADP8860_MANUFID:
		data->en_ambl_sens = !!pdata->en_ambl_sens;
		break;
	case ADP8861_MANUFID:
		data->gdwn_dis = !!pdata->gdwn_dis;
		break;
	default:
		dev_err(&client->dev, "failed to probe\n");
		return -ENODEV;
	}

	/* It's confirmed that the DEVID field is actually a REVID */

	data->revid = ADP8860_DEVID(reg_val);
	data->client = client;
	data->pdata = pdata;
	data->id = id->driver_data;
	data->current_brightness = 0;
	i2c_set_clientdata(client, data);

	memset(&props, 0, sizeof(props));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = ADP8860_MAX_BRIGHTNESS;

	mutex_init(&data->lock);

	bl = backlight_device_register(dev_driver_string(&client->dev),
			&client->dev, data, &adp8860_bl_ops, &props);
	if (IS_ERR(bl)) {
		dev_err(&client->dev, "failed to register backlight\n");
		return PTR_ERR(bl);
	}

	bl->props.brightness = ADP8860_MAX_BRIGHTNESS;

	data->bl = bl;

	if (data->en_ambl_sens)
		ret = sysfs_create_group(&bl->dev.kobj,
			&adp8860_bl_attr_group);

	if (ret) {
		dev_err(&client->dev, "failed to register sysfs\n");
		goto out1;
	}

	ret = adp8860_bl_setup(bl);
	if (ret) {
		ret = -EIO;
		goto out;
	}

	backlight_update_status(bl);

	dev_info(&client->dev, "%s Rev.%d Backlight\n",
		client->name, data->revid);

	if (pdata->num_leds)
		adp8860_led_probe(client);

	return 0;

out:
	if (data->en_ambl_sens)
		sysfs_remove_group(&data->bl->dev.kobj,
			&adp8860_bl_attr_group);
out1:
	backlight_device_unregister(bl);

	return ret;
}
static int __devinit ws2401_probe(struct mcde_display_device *ddev)
{
	int ret = 0;
	struct ws2401_platform_data *pdata = ddev->dev.platform_data;
	struct backlight_device *bd = NULL;
	struct ws2401_lcd *lcd = NULL;

	dev_dbg(&ddev->dev, "%s function entered\n", __func__);

	if (pdata == NULL) {
		dev_err(&ddev->dev, "%s:Platform data missing\n", __func__);
		return -EINVAL;
	}

	if (ddev->port->type != MCDE_PORTTYPE_DSI) {
		dev_err(&ddev->dev, "%s:Invalid port type %d\n", __func__, ddev->port->type);
		return -EINVAL;
	}

	ddev->prepare_for_update = NULL;
	ddev->update = ws2401_update;
	ddev->try_video_mode = ws2401_try_video_mode;
	ddev->set_video_mode = ws2401_set_video_mode;

	if (pdata->reset_gpio) {
		ret = gpio_request(pdata->reset_gpio, "LCD Reset");
		if (ret) {
			dev_warn(&ddev->dev, "%s:Failed to request gpio %d\n", __func__, pdata->reset_gpio);
			goto request_reset_gpio_failed;
		}
		gpio_direction_output(pdata->reset_gpio,
			!pdata->reset_high);
	}

	if (pdata->power_on_gpio) {
		ret = gpio_request(pdata->power_on_gpio, "LCD LDO EN");
		if (ret) {
			dev_warn(&ddev->dev, "%s:Failed to request gpio %d\n", __func__, pdata->power_on_gpio);
			goto request_power_on_gpio_failed;
		}
		gpio_direction_output(pdata->power_on_gpio,
			pdata->power_on_high);
	}

	ddev->platform_enable = ws2401_platform_enable,
	ddev->platform_disable = ws2401_platform_disable,
	ddev->set_power_mode = ws2401_set_power_mode;
	ddev->native_x_res = VMODE_XRES;
	ddev->native_y_res = VMODE_YRES;

	lcd = kzalloc(sizeof(struct ws2401_lcd), GFP_KERNEL);
	if (!lcd)
		return -ENOMEM;

	dev_set_drvdata(&ddev->dev, lcd);
	lcd->mdd = ddev;
	lcd->dev = &ddev->dev;
	lcd->pd = pdata;
	lcd->opp_is_requested = false;

	if (ddev->port->mode == MCDE_PORTMODE_CMD) {
		INIT_DELAYED_WORK_DEFERRABLE(
			&lcd->opp_timeout_work,
			ws2401_work_opp_timeout_function);
	}

#ifdef CONFIG_LCD_CLASS_DEVICE
	lcd->ld = lcd_device_register("ws2401", &ddev->dev,
					lcd, &ws2401_lcd_ops);
	if (IS_ERR(lcd->ld)) {
		ret = PTR_ERR(lcd->ld);
		goto out_free_lcd;
	}
#endif

	mutex_init(&lcd->lock);

	if (pdata->no_bl_ctrl) {
		lcd->bd = NULL;
	} else {
		if (gpio_is_valid(pdata->bl_en_gpio)) {
			gpio_request(pdata->bl_en_gpio, "LCD BL Ctrl");
			gpio_direction_output(pdata->bl_en_gpio, 1);
		}

		bd = backlight_device_register("pwm-backlight",
						&ddev->dev,
						lcd,
						&ws2401_backlight_ops,
						&ws2401_backlight_props);
		if (IS_ERR(bd)) {
			ret =  PTR_ERR(bd);
			goto out_backlight_unregister;
		}
		lcd->bd = bd;
	}

	goto out;

out_backlight_unregister:
	backlight_device_unregister(bd);
#ifdef CONFIG_LCD_CLASS_DEVICE
out_free_lcd:
#endif
	kfree(lcd);
request_power_on_gpio_failed:
	if (pdata->reset_gpio)
		gpio_free(pdata->reset_gpio);
request_reset_gpio_failed:
out:
	return ret;
}
Example #18
0
static void exit_backlight(struct atmel_lcdfb_info *sinfo)
{
	if (sinfo->backlight)
		backlight_device_unregister(sinfo->backlight);
}
Example #19
0
/*
 * ubicom32bl_probe
 */
static int ubicom32bl_probe(struct platform_device *pdev)
{
	const struct ubicom32bl_platform_data *pdata = pdev->dev.platform_data;
	struct ubicom32bl_data *ud;
	struct backlight_device *bldev;
	struct backlight_properties props;
	int retval;

	/*
	 * Check to see if we have any platform data, if we don't then the backlight is not
	 * configured on this device.
	 */
	if (!pdata) {
		return -ENODEV;
	}

	/*
	 * Allocate our private data
	 */
	ud = kzalloc(sizeof(struct ubicom32bl_data), GFP_KERNEL);
	if (!ud) {
		return -ENOMEM;
	}

	ud->pdata = pdata;

	/*
	 * Check to see that the platform data is valid for this driver
	 */
	switch (pdata->type) {
	case UBICOM32BL_TYPE_PWM:
		{
			/*
			 * Make sure we have a PWM peripheral
			 */
			if ((ubicom32_get_chip_id() != 0x00030001) &&
			    (ubicom32_get_chip_id() != 0x00040000)) {
				printk(KERN_WARNING DRIVER_NAME ": no PWM support on this chip\n");
				retval = -ENODEV;
				goto fail;
			}

			if (pdata->pwm_channel > UBICOM32BL_NUM_PWM_CHANNELS) {
				printk(KERN_WARNING DRIVER_NAME ": PWM channel %d does not exist\n", pdata->pwm_channel);
				retval = -ENODEV;
				goto fail;
			}

			if (pdata->pwm_prescale > 16) {
				printk(KERN_WARNING DRIVER_NAME ": PWM prescale must be < 16\n");
				retval = -EINVAL;
				goto fail;
			}

			ud->init_fn = ubicom32bl_init_hw_pwm;
			ud->set_intensity_fn = ubicom32bl_set_intensity_hw;
			printk(KERN_INFO DRIVER_NAME ": HW PWM\n");
			break;
		}

	case UBICOM32BL_TYPE_PWM_HRT:
		// For now, PWM HRT devices are treated as binary lights.

	case UBICOM32BL_TYPE_BINARY:
		ud->init_fn = ubicom32bl_init_gpio;
		ud->set_intensity_fn = ubicom32bl_set_intensity_gpio;
		printk(KERN_INFO DRIVER_NAME ": Binary backlight\n");
		break;
	}

	/*
	 * Register our backlight device
	 */
	memset(&props, 0, sizeof(struct backlight_properties));
	props.max_brightness = UBICOM32BL_MAX_BRIGHTNESS;	
	bldev = backlight_device_register(DRIVER_NAME, &pdev->dev, ud, 
					  &ubicom32bl_ops, &props);
	if (IS_ERR(bldev)) {
		retval = PTR_ERR(bldev);
		goto fail;
	}

	ud->bldev = bldev;
	ud->cur_intensity = pdata->default_intensity;
	platform_set_drvdata(pdev, ud);

	/*
	 * Start up the backlight at the prescribed default intensity
	 */
	bldev->props.power = FB_BLANK_UNBLANK;
	bldev->props.max_brightness = UBICOM32BL_MAX_BRIGHTNESS;
	bldev->props.brightness = pdata->default_intensity;

	if (ud->init_fn) {
		if (ud->init_fn(ud) != 0) {
			retval = -ENODEV;
			backlight_device_unregister(ud->bldev);
			goto fail;
		}
	}
	ubicom32bl_set_intensity(bldev);

	printk(KERN_INFO DRIVER_NAME ": Backlight driver started ch=%d brightness=%d/%d\n",
		pdata->pwm_channel, bldev->props.brightness, bldev->props.max_brightness);

	return 0;

fail:
	platform_set_drvdata(pdev, NULL);
	kfree(ud);
	return retval;
}
Example #20
0
static int __init compal_init(void)
{
	int ret;

	if (acpi_disabled)
		return -ENODEV;

	if (!force && !dmi_check_system(compal_dmi_table))
		return -ENODEV;

	

	if (!acpi_video_backlight_support()) {
		compalbl_device = backlight_device_register("compal-laptop", NULL, NULL,
							    &compalbl_ops);
		if (IS_ERR(compalbl_device))
			return PTR_ERR(compalbl_device);

		compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1;
	}

	ret = platform_driver_register(&compal_driver);
	if (ret)
		goto fail_backlight;

	

	compal_device = platform_device_alloc("compal-laptop", -1);
	if (!compal_device) {
		ret = -ENOMEM;
		goto fail_platform_driver;
	}

	ret = platform_device_add(compal_device);
	if (ret)
		goto fail_platform_device1;

	ret = sysfs_create_group(&compal_device->dev.kobj,
		&compal_attribute_group);
	if (ret)
		goto fail_platform_device2;

	printk(KERN_INFO "compal-laptop: driver "COMPAL_DRIVER_VERSION
		" successfully loaded.\n");

	return 0;

fail_platform_device2:

	platform_device_del(compal_device);

fail_platform_device1:

	platform_device_put(compal_device);

fail_platform_driver:

	platform_driver_unregister(&compal_driver);

fail_backlight:

	backlight_device_unregister(compalbl_device);

	return ret;
}
Example #21
0
static int __devinit tl2796_probe(struct spi_device *spi)
{
	struct s5p_lcd *lcd;
	int ret;

	lcd = kzalloc(sizeof(*lcd), GFP_KERNEL);
	if (!lcd) {
		pr_err("failed to allocate for lcd\n");
		ret = -ENOMEM;
		goto err_alloc;
	}
	mutex_init(&lcd->lock);

	spi->bits_per_word = 8;
	if (spi_setup(spi)) {
		pr_err("failed to setup spi\n");
		ret = -EINVAL;
		goto err_setup;
	}

	lcd->g_spi = spi;
	lcd->dev = &spi->dev;
	lcd->bl = 255;

	if (!spi->dev.platform_data) {
		dev_err(lcd->dev, "failed to get platform data\n");
		ret = -EINVAL;
		goto err_setup;
	}
//	lcd->data = (struct s5p_panel_data *)spi->dev.platform_data;

        //determinate of LCD type 
        lcd->lcd_type = get_lcdtype();

	ret = gpio_request(GPIO_LCD_BL_PWM, "lcd_bl_pwm");
	if (ret < 0) {
		dev_err(lcd->dev, "unable to request gpio for backlight\n");	
		return ret;
	}
	s3c_gpio_cfgpin(GPIO_LCD_BL_PWM,  (0x2 << 0));

	lcd->backlight_pwm_dev = pwm_request(0, "backlight-pwm");

	if (IS_ERR(lcd->backlight_pwm_dev)) {
		dev_err(lcd->dev, "unable to request PWM for backlight\n");		
	} else
		dev_err(lcd->dev, "got pwm for backlight\n");
		
	pwm_config(lcd->backlight_pwm_dev, (bl_freq_count*70)/100, bl_freq_count);	
	pwm_enable(lcd->backlight_pwm_dev);


	lcd->bl_dev = backlight_device_register("s5p_bl",
			&spi->dev, lcd, &s5p_bl_ops, NULL);

	if (!lcd->bl_dev) {
		dev_err(lcd->dev, "failed to register backlight\n");
		ret = -EINVAL;
		goto err_setup;
	}

	lcd->bl_dev->props.max_brightness = 255;


	lcd->lcd_dev = lcd_device_register("s5p_lcd",	&spi->dev, lcd, &s5p_lcd_ops);
	if (!lcd->lcd_dev) 
	{
		dev_err(lcd->dev, "failed to register lcd\n");
		ret = -EINVAL;
		goto err_setup_lcd;
	}

			
	// Class and device file creation 
	printk(KERN_ERR "ldi_class create\n");

	lcd->ldi_class = class_create(THIS_MODULE, "ldi_class");
	if (IS_ERR(lcd->ldi_class))
		pr_err("Failed to create class(ldi_class)!\n");
	
	lcd->ldi_dev = device_create(lcd->ldi_class, &spi->dev, 0, lcd, "ldi_dev");
	if (IS_ERR(lcd->ldi_dev))
		pr_err("Failed to create device(ldi_dev)!\n");

	if (!lcd->ldi_dev) {
		dev_err(lcd->dev, "failed to register device(ldi_dev)\n");
		ret = -EINVAL;
		goto err_setup_ldi;
	}

	
	if (device_create_file(lcd->ldi_dev, &dev_attr_update_brightness_cmd) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_update_brightness_cmd.attr.name);



	spi_set_drvdata(spi, lcd);

	tl2796_ldi_enable(lcd);

#ifdef CONFIG_FB_S3C_MDNIE
	init_mdnie_class();  //set mDNIe UI mode, Outdoormode
#endif


#ifdef CONFIG_HAS_EARLYSUSPEND
	lcd->early_suspend.suspend = tl2796_early_suspend;
	lcd->early_suspend.resume = tl2796_late_resume;
	lcd->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1;
	register_early_suspend(&lcd->early_suspend);
#endif
	gprintk("tl2796_probe successfully probed\n", __func__);

	return 0;

err_setup_ldi:
	lcd_device_unregister(lcd->lcd_dev);

err_setup_lcd:
	backlight_device_unregister(lcd->bl_dev);

err_setup:
	mutex_destroy(&lcd->lock);
	kfree(lcd);

err_alloc:
	return ret;
}
Example #22
0
static int appledisplay_probe(struct usb_interface *iface,
	const struct usb_device_id *id)
{
	struct backlight_properties props;
	struct appledisplay *pdata;
	struct usb_device *udev = interface_to_usbdev(iface);
	struct usb_host_interface *iface_desc;
	struct usb_endpoint_descriptor *endpoint;
	int int_in_endpointAddr = 0;
	int i, retval = -ENOMEM, brightness;
	char bl_name[20];

	/* set up the endpoint information */
	/* use only the first interrupt-in endpoint */
	iface_desc = iface->cur_altsetting;
	for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
		endpoint = &iface_desc->endpoint[i].desc;
		if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) {
			/* we found an interrupt in endpoint */
			int_in_endpointAddr = endpoint->bEndpointAddress;
			break;
		}
	}
	if (!int_in_endpointAddr) {
		dev_err(&iface->dev, "Could not find int-in endpoint\n");
		return -EIO;
	}

	/* allocate memory for our device state and initialize it */
	pdata = kzalloc(sizeof(struct appledisplay), GFP_KERNEL);
	if (!pdata) {
		retval = -ENOMEM;
		dev_err(&iface->dev, "Out of memory\n");
		goto error;
	}

	pdata->udev = udev;

	spin_lock_init(&pdata->lock);
	INIT_DELAYED_WORK(&pdata->work, appledisplay_work);

	/* Allocate buffer for control messages */
	pdata->msgdata = kmalloc(ACD_MSG_BUFFER_LEN, GFP_KERNEL);
	if (!pdata->msgdata) {
		retval = -ENOMEM;
		dev_err(&iface->dev,
			"Allocating buffer for control messages failed\n");
		goto error;
	}

	/* Allocate interrupt URB */
	pdata->urb = usb_alloc_urb(0, GFP_KERNEL);
	if (!pdata->urb) {
		retval = -ENOMEM;
		dev_err(&iface->dev, "Allocating URB failed\n");
		goto error;
	}

	/* Allocate buffer for interrupt data */
	pdata->urbdata = usb_alloc_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
		GFP_KERNEL, &pdata->urb->transfer_dma);
	if (!pdata->urbdata) {
		retval = -ENOMEM;
		dev_err(&iface->dev, "Allocating URB buffer failed\n");
		goto error;
	}

	/* Configure interrupt URB */
	usb_fill_int_urb(pdata->urb, udev,
		usb_rcvintpipe(udev, int_in_endpointAddr),
		pdata->urbdata, ACD_URB_BUFFER_LEN, appledisplay_complete,
		pdata, 1);
	if (usb_submit_urb(pdata->urb, GFP_KERNEL)) {
		retval = -EIO;
		dev_err(&iface->dev, "Submitting URB failed\n");
		goto error;
	}

	/* Register backlight device */
	snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
		atomic_inc_return(&count_displays) - 1);
	memset(&props, 0, sizeof(struct backlight_properties));
	props.type = BACKLIGHT_RAW;
	props.max_brightness = 0xff;
	pdata->bd = backlight_device_register(bl_name, NULL, pdata,
					      &appledisplay_bl_data, &props);
	if (IS_ERR(pdata->bd)) {
		dev_err(&iface->dev, "Backlight registration failed\n");
		retval = PTR_ERR(pdata->bd);
		goto error;
	}

	/* Try to get brightness */
	brightness = appledisplay_bl_get_brightness(pdata->bd);

	if (brightness < 0) {
		retval = brightness;
		dev_err(&iface->dev,
			"Error while getting initial brightness: %d\n", retval);
		goto error;
	}

	/* Set brightness in backlight device */
	pdata->bd->props.brightness = brightness;

	/* save our data pointer in the interface device */
	usb_set_intfdata(iface, pdata);

	printk(KERN_INFO "appledisplay: Apple Cinema Display connected\n");

	return 0;

error:
	if (pdata) {
		if (pdata->urb) {
			usb_kill_urb(pdata->urb);
			if (pdata->urbdata)
				usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
					pdata->urbdata, pdata->urb->transfer_dma);
			usb_free_urb(pdata->urb);
		}
		if (pdata->bd && !IS_ERR(pdata->bd))
			backlight_device_unregister(pdata->bd);
		kfree(pdata->msgdata);
	}
	usb_set_intfdata(iface, NULL);
	kfree(pdata);
	return retval;
}
Example #23
0
static int lm3533_bl_probe(struct platform_device *pdev)
{
    struct lm3533 *lm3533;
    struct lm3533_bl_platform_data *pdata;
    struct lm3533_bl *bl;
    struct backlight_device *bd;
    struct backlight_properties props;
    int ret;

    dev_dbg(&pdev->dev, "%s\n", __func__);

    lm3533 = dev_get_drvdata(pdev->dev.parent);
    if (!lm3533)
        return -EINVAL;

    pdata = pdev->dev.platform_data;
    if (!pdata) {
        dev_err(&pdev->dev, "no platform data\n");
        return -EINVAL;
    }

    if (pdev->id < 0 || pdev->id >= LM3533_HVCTRLBANK_COUNT) {
        dev_err(&pdev->dev, "illegal backlight id %d\n", pdev->id);
        return -EINVAL;
    }

    bl = devm_kzalloc(&pdev->dev, sizeof(*bl), GFP_KERNEL);
    if (!bl) {
        dev_err(&pdev->dev,
                "failed to allocate memory for backlight\n");
        return -ENOMEM;
    }

    bl->lm3533 = lm3533;
    bl->id = pdev->id;

    bl->cb.lm3533 = lm3533;
    bl->cb.id = lm3533_bl_get_ctrlbank_id(bl);
    bl->cb.dev = NULL;			/* until registered */

    memset(&props, 0, sizeof(props));
    props.type = BACKLIGHT_RAW;
    props.max_brightness = LM3533_BL_MAX_BRIGHTNESS;
    props.brightness = pdata->default_brightness;
    bd = backlight_device_register(pdata->name, pdev->dev.parent, bl,
                                   &lm3533_bl_ops, &props);
    if (IS_ERR(bd)) {
        dev_err(&pdev->dev, "failed to register backlight device\n");
        return PTR_ERR(bd);
    }

    bl->bd = bd;
    bl->cb.dev = &bl->bd->dev;

    platform_set_drvdata(pdev, bl);

    ret = sysfs_create_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
    if (ret < 0) {
        dev_err(&pdev->dev, "failed to create sysfs attributes\n");
        goto err_unregister;
    }

    backlight_update_status(bd);

    ret = lm3533_bl_setup(bl, pdata);
    if (ret)
        goto err_sysfs_remove;

    ret = lm3533_ctrlbank_enable(&bl->cb);
    if (ret)
        goto err_sysfs_remove;

    return 0;

err_sysfs_remove:
    sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
err_unregister:
    backlight_device_unregister(bd);

    return ret;
}