Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105557
b: refs/heads/master
c: c25826a
h: refs/heads/master
i:
  105555: 2469aa3
v: v3
  • Loading branch information
Ben Dooks authored and Linus Torvalds committed Jul 24, 2008
1 parent ab096ee commit 1cd6949
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0c531360ed504aa0ce995fcb8ef08e82b6534d0b
refs/heads/master: c25826a7cf1c61b5c6e6db8365172eb97ef39ef3
7 changes: 7 additions & 0 deletions trunk/drivers/video/backlight/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ config LCD_VGG2432A4
If you have a VGG2432A4 panel based on the ILI9320 controller chip
then say y to include a power driver for it.

config LCD_PLATFORM
tristate "Platform LCD controls"
depends on LCD_CLASS_DEVICE
help
This driver provides a platform-device registered LCD power
control interface.

#
# Backlight
#
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/video/backlight/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o
obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o
obj-$(CONFIG_LCD_ILI9320) += ili9320.o
obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o
obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o

obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
Expand Down
172 changes: 172 additions & 0 deletions trunk/drivers/video/backlight/platform_lcd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
/* drivers/video/backlight/platform_lcd.c
*
* Copyright 2008 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* Generic platform-device LCD power control interface.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/

#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/fb.h>
#include <linux/backlight.h>
#include <linux/lcd.h>

#include <video/platform_lcd.h>

struct platform_lcd {
struct device *us;
struct lcd_device *lcd;
struct plat_lcd_data *pdata;

unsigned int power;
unsigned int suspended : 1;
};

static inline struct platform_lcd *to_our_lcd(struct lcd_device *lcd)
{
return lcd_get_data(lcd);
}

static int platform_lcd_get_power(struct lcd_device *lcd)
{
struct platform_lcd *plcd = to_our_lcd(lcd);

return plcd->power;
}

static int platform_lcd_set_power(struct lcd_device *lcd, int power)
{
struct platform_lcd *plcd = to_our_lcd(lcd);
int lcd_power = 1;

if (power == FB_BLANK_POWERDOWN || plcd->suspended)
lcd_power = 0;

plcd->pdata->set_power(plcd->pdata, lcd_power);
plcd->power = power;

return 0;
}

static int platform_lcd_match(struct lcd_device *lcd, struct fb_info *info)
{
struct platform_lcd *plcd = to_our_lcd(lcd);
struct plat_lcd_data *pdata = plcd->pdata;

if (pdata->match_fb)
return pdata->match_fb(pdata, info);

return plcd->us->parent == info->device;
}

static struct lcd_ops platform_lcd_ops = {
.get_power = platform_lcd_get_power,
.set_power = platform_lcd_set_power,
.check_fb = platform_lcd_match,
};

static int __devinit platform_lcd_probe(struct platform_device *pdev)
{
struct plat_lcd_data *pdata;
struct platform_lcd *plcd;
struct device *dev = &pdev->dev;
int err;

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

plcd = kzalloc(sizeof(struct platform_lcd), GFP_KERNEL);
if (!plcd) {
dev_err(dev, "no memory for state\n");
return -ENOMEM;
}

plcd->us = dev;
plcd->pdata = pdata;
plcd->lcd = lcd_device_register("platform-lcd", dev,
plcd, &platform_lcd_ops);
if (IS_ERR(plcd->lcd)) {
dev_err(dev, "cannot register lcd device\n");
err = PTR_ERR(plcd->lcd);
goto err_mem;
}

platform_set_drvdata(pdev, plcd);
return 0;

err_mem:
kfree(plcd);
return err;
}

static int __devexit platform_lcd_remove(struct platform_device *pdev)
{
struct platform_lcd *plcd = platform_get_drvdata(pdev);

lcd_device_unregister(plcd->lcd);
kfree(plcd);

return 0;
}

#ifdef CONFIG_PM
static int platform_lcd_suspend(struct platform_device *pdev, pm_message_t st)
{
struct platform_lcd *plcd = platform_get_drvdata(pdev);

plcd->suspended = 1;
platform_lcd_set_power(plcd->lcd, plcd->power);

return 0;
}

static int platform_lcd_resume(struct platform_device *pdev)
{
struct platform_lcd *plcd = platform_get_drvdata(pdev);

plcd->suspended = 0;
platform_lcd_set_power(plcd->lcd, plcd->power);

return 0;
}
#else
#define platform_lcd_suspend NULL
#define platform_lcd_resume NULL
#endif

static struct platform_driver platform_lcd_driver = {
.driver = {
.name = "platform-lcd",
.owner = THIS_MODULE,
},
.probe = platform_lcd_probe,
.remove = __devexit_p(platform_lcd_remove),
.suspend = platform_lcd_suspend,
.resume = platform_lcd_resume,
};

static int __init platform_lcd_init(void)
{
return platform_driver_register(&platform_lcd_driver);
}

static void __exit platform_lcd_cleanup(void)
{
platform_driver_unregister(&platform_lcd_driver);
}

module_init(platform_lcd_init);
module_exit(platform_lcd_cleanup);

MODULE_AUTHOR("Ben Dooks <ben-linux@fluff.org>");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:platform-lcd");
21 changes: 21 additions & 0 deletions trunk/include/video/platform_lcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* include/video/platform_lcd.h
*
* Copyright 2008 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* Generic platform-device LCD power control interface.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/

struct plat_lcd_data;
struct fb_info;

struct plat_lcd_data {
void (*set_power)(struct plat_lcd_data *, unsigned int power);
int (*match_fb)(struct plat_lcd_data *, struct fb_info *);
};

0 comments on commit 1cd6949

Please sign in to comment.