Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight
* 'for-linus' of git://git.o-hand.com/linux-rpurdie-backlight: backlight: Rename the corgi backlight driver to generic backlight: add support for Toppoly TDO35S series to tdo24m lcd driver backlight: Add suspend/resume support to the backlight core bd->props.brightness doesn't reflect the actual backlight level. backlight: Support VGA/QVGA mode switching in tosa_lcd backlight: Catch invalid input in sysfs attributes backlight: Value of ILI9320_RGB_IF2 register should not be hardcoded backlight: crbllcd_bl - Use platform_device_register_simple() backlight: progear_bl - Use platform_device_register_simple() backlight: hp680_bl - Use platform_device_register_simple()
This commit is contained in:
commit
b64dc5a484
@ -52,11 +52,11 @@ config LCD_ILI9320
|
||||
then say y to include a power driver for it.
|
||||
|
||||
config LCD_TDO24M
|
||||
tristate "Toppoly TDO24M LCD Panels support"
|
||||
tristate "Toppoly TDO24M and TDO35S LCD Panels support"
|
||||
depends on LCD_CLASS_DEVICE && SPI_MASTER
|
||||
default n
|
||||
help
|
||||
If you have a Toppoly TDO24M series LCD panel, say y here to
|
||||
If you have a Toppoly TDO24M/TDO35S series LCD panel, say y here to
|
||||
include the support for it.
|
||||
|
||||
config LCD_VGG2432A4
|
||||
@ -123,17 +123,14 @@ config BACKLIGHT_ATMEL_PWM
|
||||
To compile this driver as a module, choose M here: the module will be
|
||||
called atmel-pwm-bl.
|
||||
|
||||
config BACKLIGHT_CORGI
|
||||
tristate "Generic (aka Sharp Corgi) Backlight Driver (DEPRECATED)"
|
||||
config BACKLIGHT_GENERIC
|
||||
tristate "Generic (aka Sharp Corgi) Backlight Driver"
|
||||
depends on BACKLIGHT_CLASS_DEVICE
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Say y to enable the generic platform backlight driver previously
|
||||
known as the Corgi backlight driver. If you have a Sharp Zaurus
|
||||
SL-C7xx, SL-Cxx00 or SL-6000x say y. Most users can say n.
|
||||
|
||||
Note: this driver is marked as deprecated, try enable SPI and
|
||||
use the new corgi_lcd driver with integrated backlight control
|
||||
SL-C7xx, SL-Cxx00 or SL-6000x say y.
|
||||
|
||||
config BACKLIGHT_LOCOMO
|
||||
tristate "Sharp LOCOMO LCD/Backlight Driver"
|
||||
|
@ -11,7 +11,7 @@ obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o
|
||||
|
||||
obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
|
||||
obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
|
||||
obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
|
||||
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
|
||||
|
@ -40,6 +40,10 @@ static int fb_notifier_callback(struct notifier_block *self,
|
||||
if (!bd->ops->check_fb ||
|
||||
bd->ops->check_fb(evdata->info)) {
|
||||
bd->props.fb_blank = *(int *)evdata->data;
|
||||
if (bd->props.fb_blank == FB_BLANK_UNBLANK)
|
||||
bd->props.state &= ~BL_CORE_FBBLANK;
|
||||
else
|
||||
bd->props.state |= BL_CORE_FBBLANK;
|
||||
backlight_update_status(bd);
|
||||
}
|
||||
mutex_unlock(&bd->ops_lock);
|
||||
@ -80,20 +84,18 @@ static ssize_t backlight_show_power(struct device *dev,
|
||||
static ssize_t backlight_store_power(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int rc = -ENXIO;
|
||||
char *endp;
|
||||
int rc;
|
||||
struct backlight_device *bd = to_backlight_device(dev);
|
||||
int power = simple_strtoul(buf, &endp, 0);
|
||||
size_t size = endp - buf;
|
||||
unsigned long power;
|
||||
|
||||
if (*endp && isspace(*endp))
|
||||
size++;
|
||||
if (size != count)
|
||||
return -EINVAL;
|
||||
rc = strict_strtoul(buf, 0, &power);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = -ENXIO;
|
||||
mutex_lock(&bd->ops_lock);
|
||||
if (bd->ops) {
|
||||
pr_debug("backlight: set power to %d\n", power);
|
||||
pr_debug("backlight: set power to %lu\n", power);
|
||||
if (bd->props.power != power) {
|
||||
bd->props.power = power;
|
||||
backlight_update_status(bd);
|
||||
@ -116,28 +118,25 @@ static ssize_t backlight_show_brightness(struct device *dev,
|
||||
static ssize_t backlight_store_brightness(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int rc = -ENXIO;
|
||||
char *endp;
|
||||
int rc;
|
||||
struct backlight_device *bd = to_backlight_device(dev);
|
||||
int brightness = simple_strtoul(buf, &endp, 0);
|
||||
size_t size = endp - buf;
|
||||
unsigned long brightness;
|
||||
|
||||
if (*endp && isspace(*endp))
|
||||
size++;
|
||||
if (size != count)
|
||||
return -EINVAL;
|
||||
rc = strict_strtoul(buf, 0, &brightness);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
rc = -ENXIO;
|
||||
|
||||
mutex_lock(&bd->ops_lock);
|
||||
if (bd->ops) {
|
||||
if (brightness > bd->props.max_brightness)
|
||||
rc = -EINVAL;
|
||||
else {
|
||||
pr_debug("backlight: set brightness to %d\n",
|
||||
pr_debug("backlight: set brightness to %lu\n",
|
||||
brightness);
|
||||
if (bd->props.brightness != brightness) {
|
||||
bd->props.brightness = brightness;
|
||||
backlight_update_status(bd);
|
||||
}
|
||||
bd->props.brightness = brightness;
|
||||
backlight_update_status(bd);
|
||||
rc = count;
|
||||
}
|
||||
}
|
||||
@ -170,6 +169,34 @@ static ssize_t backlight_show_actual_brightness(struct device *dev,
|
||||
|
||||
static struct class *backlight_class;
|
||||
|
||||
static int backlight_suspend(struct device *dev, pm_message_t state)
|
||||
{
|
||||
struct backlight_device *bd = to_backlight_device(dev);
|
||||
|
||||
if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
|
||||
mutex_lock(&bd->ops_lock);
|
||||
bd->props.state |= BL_CORE_SUSPENDED;
|
||||
backlight_update_status(bd);
|
||||
mutex_unlock(&bd->ops_lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int backlight_resume(struct device *dev)
|
||||
{
|
||||
struct backlight_device *bd = to_backlight_device(dev);
|
||||
|
||||
if (bd->ops->options & BL_CORE_SUSPENDRESUME) {
|
||||
mutex_lock(&bd->ops_lock);
|
||||
bd->props.state &= ~BL_CORE_SUSPENDED;
|
||||
backlight_update_status(bd);
|
||||
mutex_unlock(&bd->ops_lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bl_device_release(struct device *dev)
|
||||
{
|
||||
struct backlight_device *bd = to_backlight_device(dev);
|
||||
@ -286,6 +313,8 @@ static int __init backlight_class_init(void)
|
||||
}
|
||||
|
||||
backlight_class->dev_attrs = bl_device_attributes;
|
||||
backlight_class->suspend = backlight_suspend;
|
||||
backlight_class->resume = backlight_resume;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Backlight Driver for Sharp Zaurus Handhelds (various models)
|
||||
*
|
||||
* Copyright (c) 2004-2006 Richard Purdie
|
||||
*
|
||||
* Based on Sharp's 2.4 Backlight Driver
|
||||
*
|
||||
* 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/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
|
||||
static int corgibl_intensity;
|
||||
static struct backlight_properties corgibl_data;
|
||||
static struct backlight_device *corgi_backlight_device;
|
||||
static struct generic_bl_info *bl_machinfo;
|
||||
|
||||
static unsigned long corgibl_flags;
|
||||
#define CORGIBL_SUSPENDED 0x01
|
||||
#define CORGIBL_BATTLOW 0x02
|
||||
|
||||
static int corgibl_send_intensity(struct backlight_device *bd)
|
||||
{
|
||||
int intensity = bd->props.brightness;
|
||||
|
||||
if (bd->props.power != FB_BLANK_UNBLANK)
|
||||
intensity = 0;
|
||||
if (bd->props.fb_blank != FB_BLANK_UNBLANK)
|
||||
intensity = 0;
|
||||
if (corgibl_flags & CORGIBL_SUSPENDED)
|
||||
intensity = 0;
|
||||
if (corgibl_flags & CORGIBL_BATTLOW)
|
||||
intensity &= bl_machinfo->limit_mask;
|
||||
|
||||
bl_machinfo->set_bl_intensity(intensity);
|
||||
|
||||
corgibl_intensity = intensity;
|
||||
|
||||
if (bl_machinfo->kick_battery)
|
||||
bl_machinfo->kick_battery();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int corgibl_suspend(struct platform_device *pdev, pm_message_t state)
|
||||
{
|
||||
struct backlight_device *bd = platform_get_drvdata(pdev);
|
||||
|
||||
corgibl_flags |= CORGIBL_SUSPENDED;
|
||||
backlight_update_status(bd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int corgibl_resume(struct platform_device *pdev)
|
||||
{
|
||||
struct backlight_device *bd = platform_get_drvdata(pdev);
|
||||
|
||||
corgibl_flags &= ~CORGIBL_SUSPENDED;
|
||||
backlight_update_status(bd);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#define corgibl_suspend NULL
|
||||
#define corgibl_resume NULL
|
||||
#endif
|
||||
|
||||
static int corgibl_get_intensity(struct backlight_device *bd)
|
||||
{
|
||||
return corgibl_intensity;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when the battery is low to limit the backlight intensity.
|
||||
* If limit==0 clear any limit, otherwise limit the intensity
|
||||
*/
|
||||
void corgibl_limit_intensity(int limit)
|
||||
{
|
||||
if (limit)
|
||||
corgibl_flags |= CORGIBL_BATTLOW;
|
||||
else
|
||||
corgibl_flags &= ~CORGIBL_BATTLOW;
|
||||
backlight_update_status(corgi_backlight_device);
|
||||
}
|
||||
EXPORT_SYMBOL(corgibl_limit_intensity);
|
||||
|
||||
|
||||
static struct backlight_ops corgibl_ops = {
|
||||
.get_brightness = corgibl_get_intensity,
|
||||
.update_status = corgibl_send_intensity,
|
||||
};
|
||||
|
||||
static int corgibl_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct generic_bl_info *machinfo = pdev->dev.platform_data;
|
||||
const char *name = "generic-bl";
|
||||
|
||||
bl_machinfo = machinfo;
|
||||
if (!machinfo->limit_mask)
|
||||
machinfo->limit_mask = -1;
|
||||
|
||||
if (machinfo->name)
|
||||
name = machinfo->name;
|
||||
|
||||
corgi_backlight_device = backlight_device_register (name,
|
||||
&pdev->dev, NULL, &corgibl_ops);
|
||||
if (IS_ERR (corgi_backlight_device))
|
||||
return PTR_ERR (corgi_backlight_device);
|
||||
|
||||
platform_set_drvdata(pdev, corgi_backlight_device);
|
||||
|
||||
corgi_backlight_device->props.max_brightness = machinfo->max_intensity;
|
||||
corgi_backlight_device->props.power = FB_BLANK_UNBLANK;
|
||||
corgi_backlight_device->props.brightness = machinfo->default_intensity;
|
||||
backlight_update_status(corgi_backlight_device);
|
||||
|
||||
printk("Corgi Backlight Driver Initialized.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int corgibl_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct backlight_device *bd = platform_get_drvdata(pdev);
|
||||
|
||||
corgibl_data.power = 0;
|
||||
corgibl_data.brightness = 0;
|
||||
backlight_update_status(bd);
|
||||
|
||||
backlight_device_unregister(bd);
|
||||
|
||||
printk("Corgi Backlight Driver Unloaded\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver corgibl_driver = {
|
||||
.probe = corgibl_probe,
|
||||
.remove = corgibl_remove,
|
||||
.suspend = corgibl_suspend,
|
||||
.resume = corgibl_resume,
|
||||
.driver = {
|
||||
.name = "generic-bl",
|
||||
},
|
||||
};
|
||||
|
||||
static int __init corgibl_init(void)
|
||||
{
|
||||
return platform_driver_register(&corgibl_driver);
|
||||
}
|
||||
|
||||
static void __exit corgibl_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&corgibl_driver);
|
||||
}
|
||||
|
||||
module_init(corgibl_init);
|
||||
module_exit(corgibl_exit);
|
||||
|
||||
MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
|
||||
MODULE_DESCRIPTION("Corgi Backlight Driver");
|
||||
MODULE_LICENSE("GPL");
|
@ -259,22 +259,18 @@ static int __init cr_backlight_init(void)
|
||||
{
|
||||
int ret = platform_driver_register(&cr_backlight_driver);
|
||||
|
||||
if (!ret) {
|
||||
crp = platform_device_alloc("cr_backlight", -1);
|
||||
if (!crp)
|
||||
return -ENOMEM;
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = platform_device_add(crp);
|
||||
|
||||
if (ret) {
|
||||
platform_device_put(crp);
|
||||
platform_driver_unregister(&cr_backlight_driver);
|
||||
}
|
||||
crp = platform_device_register_simple("cr_backlight", -1, NULL, 0);
|
||||
if (IS_ERR(crp)) {
|
||||
platform_driver_unregister(&cr_backlight_driver);
|
||||
return PTR_ERR(crp);
|
||||
}
|
||||
|
||||
printk("Carillo Ranch Backlight Driver Initialized.\n");
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit cr_backlight_exit(void)
|
||||
|
147
drivers/video/backlight/generic_bl.c
Normal file
147
drivers/video/backlight/generic_bl.c
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Generic Backlight Driver
|
||||
*
|
||||
* Copyright (c) 2004-2008 Richard Purdie
|
||||
*
|
||||
* 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/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/backlight.h>
|
||||
|
||||
static int genericbl_intensity;
|
||||
static struct backlight_device *generic_backlight_device;
|
||||
static struct generic_bl_info *bl_machinfo;
|
||||
|
||||
/* Flag to signal when the battery is low */
|
||||
#define GENERICBL_BATTLOW BL_CORE_DRIVER1
|
||||
|
||||
static int genericbl_send_intensity(struct backlight_device *bd)
|
||||
{
|
||||
int intensity = bd->props.brightness;
|
||||
|
||||
if (bd->props.power != FB_BLANK_UNBLANK)
|
||||
intensity = 0;
|
||||
if (bd->props.state & BL_CORE_FBBLANK)
|
||||
intensity = 0;
|
||||
if (bd->props.state & BL_CORE_SUSPENDED)
|
||||
intensity = 0;
|
||||
if (bd->props.state & GENERICBL_BATTLOW)
|
||||
intensity &= bl_machinfo->limit_mask;
|
||||
|
||||
bl_machinfo->set_bl_intensity(intensity);
|
||||
|
||||
genericbl_intensity = intensity;
|
||||
|
||||
if (bl_machinfo->kick_battery)
|
||||
bl_machinfo->kick_battery();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int genericbl_get_intensity(struct backlight_device *bd)
|
||||
{
|
||||
return genericbl_intensity;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when the battery is low to limit the backlight intensity.
|
||||
* If limit==0 clear any limit, otherwise limit the intensity
|
||||
*/
|
||||
void corgibl_limit_intensity(int limit)
|
||||
{
|
||||
struct backlight_device *bd = generic_backlight_device;
|
||||
|
||||
mutex_lock(&bd->ops_lock);
|
||||
if (limit)
|
||||
bd->props.state |= GENERICBL_BATTLOW;
|
||||
else
|
||||
bd->props.state &= ~GENERICBL_BATTLOW;
|
||||
backlight_update_status(generic_backlight_device);
|
||||
mutex_unlock(&bd->ops_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(corgibl_limit_intensity);
|
||||
|
||||
static struct backlight_ops genericbl_ops = {
|
||||
.options = BL_CORE_SUSPENDRESUME,
|
||||
.get_brightness = genericbl_get_intensity,
|
||||
.update_status = genericbl_send_intensity,
|
||||
};
|
||||
|
||||
static int genericbl_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct generic_bl_info *machinfo = pdev->dev.platform_data;
|
||||
const char *name = "generic-bl";
|
||||
struct backlight_device *bd;
|
||||
|
||||
bl_machinfo = machinfo;
|
||||
if (!machinfo->limit_mask)
|
||||
machinfo->limit_mask = -1;
|
||||
|
||||
if (machinfo->name)
|
||||
name = machinfo->name;
|
||||
|
||||
bd = backlight_device_register (name,
|
||||
&pdev->dev, NULL, &genericbl_ops);
|
||||
if (IS_ERR (bd))
|
||||
return PTR_ERR (bd);
|
||||
|
||||
platform_set_drvdata(pdev, bd);
|
||||
|
||||
bd->props.max_brightness = machinfo->max_intensity;
|
||||
bd->props.power = FB_BLANK_UNBLANK;
|
||||
bd->props.brightness = machinfo->default_intensity;
|
||||
backlight_update_status(bd);
|
||||
|
||||
generic_backlight_device = bd;
|
||||
|
||||
printk("Generic Backlight Driver Initialized.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int genericbl_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct backlight_device *bd = platform_get_drvdata(pdev);
|
||||
|
||||
bd->props.power = 0;
|
||||
bd->props.brightness = 0;
|
||||
backlight_update_status(bd);
|
||||
|
||||
backlight_device_unregister(bd);
|
||||
|
||||
printk("Generic Backlight Driver Unloaded\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct platform_driver genericbl_driver = {
|
||||
.probe = genericbl_probe,
|
||||
.remove = genericbl_remove,
|
||||
.driver = {
|
||||
.name = "generic-bl",
|
||||
},
|
||||
};
|
||||
|
||||
static int __init genericbl_init(void)
|
||||
{
|
||||
return platform_driver_register(&genericbl_driver);
|
||||
}
|
||||
|
||||
static void __exit genericbl_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&genericbl_driver);
|
||||
}
|
||||
|
||||
module_init(genericbl_init);
|
||||
module_exit(genericbl_exit);
|
||||
|
||||
MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
|
||||
MODULE_DESCRIPTION("Generic Backlight Driver");
|
||||
MODULE_LICENSE("GPL");
|
@ -151,19 +151,15 @@ static int __init hp680bl_init(void)
|
||||
int ret;
|
||||
|
||||
ret = platform_driver_register(&hp680bl_driver);
|
||||
if (!ret) {
|
||||
hp680bl_device = platform_device_alloc("hp680-bl", -1);
|
||||
if (!hp680bl_device)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = platform_device_add(hp680bl_device);
|
||||
|
||||
if (ret) {
|
||||
platform_device_put(hp680bl_device);
|
||||
platform_driver_unregister(&hp680bl_driver);
|
||||
}
|
||||
if (ret)
|
||||
return ret;
|
||||
hp680bl_device = platform_device_register_simple("hp680-bl", -1,
|
||||
NULL, 0);
|
||||
if (IS_ERR(hp680bl_device)) {
|
||||
platform_driver_unregister(&hp680bl_driver);
|
||||
return PTR_ERR(hp680bl_device);
|
||||
}
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit hp680bl_exit(void)
|
||||
|
@ -70,6 +70,7 @@ static int mbp_get_intensity(struct backlight_device *bd)
|
||||
}
|
||||
|
||||
static struct backlight_ops mbp_ops = {
|
||||
.options = BL_CORE_SUSPENDRESUME,
|
||||
.get_brightness = mbp_get_intensity,
|
||||
.update_status = mbp_send_intensity,
|
||||
};
|
||||
|
@ -119,20 +119,16 @@ static int __init progearbl_init(void)
|
||||
{
|
||||
int ret = platform_driver_register(&progearbl_driver);
|
||||
|
||||
if (!ret) {
|
||||
progearbl_device = platform_device_alloc("progear-bl", -1);
|
||||
if (!progearbl_device)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = platform_device_add(progearbl_device);
|
||||
|
||||
if (ret) {
|
||||
platform_device_put(progearbl_device);
|
||||
platform_driver_unregister(&progearbl_driver);
|
||||
}
|
||||
if (ret)
|
||||
return ret;
|
||||
progearbl_device = platform_device_register_simple("progear-bl", -1,
|
||||
NULL, 0);
|
||||
if (IS_ERR(progearbl_device)) {
|
||||
platform_driver_unregister(&progearbl_driver);
|
||||
return PTR_ERR(progearbl_device);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit progearbl_exit(void)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/spi/spi.h>
|
||||
#include <linux/spi/tdo24m.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/lcd.h>
|
||||
|
||||
@ -31,6 +32,9 @@ struct tdo24m {
|
||||
struct spi_transfer xfer;
|
||||
uint8_t *buf;
|
||||
|
||||
int (*adj_mode)(struct tdo24m *lcd, int mode);
|
||||
int color_invert;
|
||||
|
||||
int power;
|
||||
int mode;
|
||||
};
|
||||
@ -66,7 +70,7 @@ static uint32_t lcd_panel_off[] = {
|
||||
CMD_NULL,
|
||||
};
|
||||
|
||||
static uint32_t lcd_vga_pass_through[] = {
|
||||
static uint32_t lcd_vga_pass_through_tdo24m[] = {
|
||||
CMD1(0xB0, 0x16),
|
||||
CMD1(0xBC, 0x80),
|
||||
CMD1(0xE1, 0x00),
|
||||
@ -75,7 +79,7 @@ static uint32_t lcd_vga_pass_through[] = {
|
||||
CMD_NULL,
|
||||
};
|
||||
|
||||
static uint32_t lcd_qvga_pass_through[] = {
|
||||
static uint32_t lcd_qvga_pass_through_tdo24m[] = {
|
||||
CMD1(0xB0, 0x16),
|
||||
CMD1(0xBC, 0x81),
|
||||
CMD1(0xE1, 0x00),
|
||||
@ -84,7 +88,7 @@ static uint32_t lcd_qvga_pass_through[] = {
|
||||
CMD_NULL,
|
||||
};
|
||||
|
||||
static uint32_t lcd_vga_transfer[] = {
|
||||
static uint32_t lcd_vga_transfer_tdo24m[] = {
|
||||
CMD1(0xcf, 0x02), /* Blanking period control (1) */
|
||||
CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
|
||||
CMD1(0xd1, 0x01), /* CKV timing control on/off */
|
||||
@ -110,6 +114,35 @@ static uint32_t lcd_qvga_transfer[] = {
|
||||
CMD_NULL,
|
||||
};
|
||||
|
||||
static uint32_t lcd_vga_pass_through_tdo35s[] = {
|
||||
CMD1(0xB0, 0x16),
|
||||
CMD1(0xBC, 0x80),
|
||||
CMD1(0xE1, 0x00),
|
||||
CMD1(0x3B, 0x00),
|
||||
CMD_NULL,
|
||||
};
|
||||
|
||||
static uint32_t lcd_qvga_pass_through_tdo35s[] = {
|
||||
CMD1(0xB0, 0x16),
|
||||
CMD1(0xBC, 0x81),
|
||||
CMD1(0xE1, 0x00),
|
||||
CMD1(0x3B, 0x22),
|
||||
CMD_NULL,
|
||||
};
|
||||
|
||||
static uint32_t lcd_vga_transfer_tdo35s[] = {
|
||||
CMD1(0xcf, 0x02), /* Blanking period control (1) */
|
||||
CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */
|
||||
CMD1(0xd1, 0x01), /* CKV timing control on/off */
|
||||
CMD2(0xd2, 0x00, 0x1e), /* CKV 1,2 timing control */
|
||||
CMD2(0xd3, 0x14, 0x28), /* OEV timing control */
|
||||
CMD2(0xd4, 0x28, 0x64), /* ASW timing control (1) */
|
||||
CMD1(0xd5, 0x28), /* ASW timing control (2) */
|
||||
CMD0(0x21), /* Invert for normally black display */
|
||||
CMD0(0x29), /* Display on */
|
||||
CMD_NULL,
|
||||
};
|
||||
|
||||
static uint32_t lcd_panel_config[] = {
|
||||
CMD2(0xb8, 0xff, 0xf9), /* Output control */
|
||||
CMD0(0x11), /* sleep out */
|
||||
@ -148,6 +181,8 @@ static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array)
|
||||
int nparams, err = 0;
|
||||
|
||||
for (; *p != CMD_NULL; p++) {
|
||||
if (!lcd->color_invert && *p == CMD0(0x21))
|
||||
continue;
|
||||
|
||||
nparams = (*p >> 30) & 0x3;
|
||||
|
||||
@ -184,12 +219,33 @@ static int tdo24m_adj_mode(struct tdo24m *lcd, int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case MODE_VGA:
|
||||
tdo24m_writes(lcd, lcd_vga_pass_through);
|
||||
tdo24m_writes(lcd, lcd_vga_pass_through_tdo24m);
|
||||
tdo24m_writes(lcd, lcd_panel_config);
|
||||
tdo24m_writes(lcd, lcd_vga_transfer);
|
||||
tdo24m_writes(lcd, lcd_vga_transfer_tdo24m);
|
||||
break;
|
||||
case MODE_QVGA:
|
||||
tdo24m_writes(lcd, lcd_qvga_pass_through);
|
||||
tdo24m_writes(lcd, lcd_qvga_pass_through_tdo24m);
|
||||
tdo24m_writes(lcd, lcd_panel_config);
|
||||
tdo24m_writes(lcd, lcd_qvga_transfer);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
lcd->mode = mode;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tdo35s_adj_mode(struct tdo24m *lcd, int mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case MODE_VGA:
|
||||
tdo24m_writes(lcd, lcd_vga_pass_through_tdo35s);
|
||||
tdo24m_writes(lcd, lcd_panel_config);
|
||||
tdo24m_writes(lcd, lcd_vga_transfer_tdo35s);
|
||||
break;
|
||||
case MODE_QVGA:
|
||||
tdo24m_writes(lcd, lcd_qvga_pass_through_tdo35s);
|
||||
tdo24m_writes(lcd, lcd_panel_config);
|
||||
tdo24m_writes(lcd, lcd_qvga_transfer);
|
||||
break;
|
||||
@ -213,7 +269,7 @@ static int tdo24m_power_on(struct tdo24m *lcd)
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = tdo24m_adj_mode(lcd, lcd->mode);
|
||||
err = lcd->adj_mode(lcd, lcd->mode);
|
||||
out:
|
||||
return err;
|
||||
}
|
||||
@ -262,7 +318,7 @@ static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m)
|
||||
if (lcd->mode == mode)
|
||||
return 0;
|
||||
|
||||
return tdo24m_adj_mode(lcd, mode);
|
||||
return lcd->adj_mode(lcd, mode);
|
||||
}
|
||||
|
||||
static struct lcd_ops tdo24m_ops = {
|
||||
@ -276,8 +332,16 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
|
||||
struct tdo24m *lcd;
|
||||
struct spi_message *m;
|
||||
struct spi_transfer *x;
|
||||
struct tdo24m_platform_data *pdata;
|
||||
enum tdo24m_model model;
|
||||
int err;
|
||||
|
||||
pdata = spi->dev.platform_data;
|
||||
if (pdata)
|
||||
model = pdata->model;
|
||||
else
|
||||
model = TDO24M;
|
||||
|
||||
spi->bits_per_word = 8;
|
||||
spi->mode = SPI_MODE_3;
|
||||
err = spi_setup(spi);
|
||||
@ -306,6 +370,20 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
|
||||
x->tx_buf = &lcd->buf[0];
|
||||
spi_message_add_tail(x, m);
|
||||
|
||||
switch (model) {
|
||||
case TDO24M:
|
||||
lcd->color_invert = 1;
|
||||
lcd->adj_mode = tdo24m_adj_mode;
|
||||
break;
|
||||
case TDO35S:
|
||||
lcd->adj_mode = tdo35s_adj_mode;
|
||||
lcd->color_invert = 0;
|
||||
break;
|
||||
default:
|
||||
dev_err(&spi->dev, "Unsupported model");
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
|
||||
lcd, &tdo24m_ops);
|
||||
if (IS_ERR(lcd->lcd_dev)) {
|
||||
|
@ -39,6 +39,7 @@ struct tosa_lcd_data {
|
||||
struct i2c_client *i2c;
|
||||
|
||||
int lcd_power;
|
||||
bool is_vga;
|
||||
};
|
||||
|
||||
static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data)
|
||||
@ -81,8 +82,12 @@ static void tosa_lcd_tg_init(struct tosa_lcd_data *data)
|
||||
static void tosa_lcd_tg_on(struct tosa_lcd_data *data)
|
||||
{
|
||||
struct spi_device *spi = data->spi;
|
||||
const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR;
|
||||
tosa_tg_send(spi, TG_PNLCTL, value | TG_REG0_VQV); /* this depends on mode */
|
||||
int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR;
|
||||
|
||||
if (data->is_vga)
|
||||
value |= TG_REG0_VQV;
|
||||
|
||||
tosa_tg_send(spi, TG_PNLCTL, value);
|
||||
|
||||
/* TG LCD pannel power up */
|
||||
tosa_tg_send(spi, TG_PINICTL,0x4);
|
||||
@ -142,9 +147,25 @@ static int tosa_lcd_get_power(struct lcd_device *lcd)
|
||||
return data->lcd_power;
|
||||
}
|
||||
|
||||
static int tosa_lcd_set_mode(struct lcd_device *lcd, struct fb_videomode *mode)
|
||||
{
|
||||
struct tosa_lcd_data *data = lcd_get_data(lcd);
|
||||
|
||||
if (mode->xres == 320 || mode->yres == 320)
|
||||
data->is_vga = false;
|
||||
else
|
||||
data->is_vga = true;
|
||||
|
||||
if (POWER_IS_ON(data->lcd_power))
|
||||
tosa_lcd_tg_on(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct lcd_ops tosa_lcd_ops = {
|
||||
.set_power = tosa_lcd_set_power,
|
||||
.get_power = tosa_lcd_get_power,
|
||||
.set_mode = tosa_lcd_set_mode,
|
||||
};
|
||||
|
||||
static int __devinit tosa_lcd_probe(struct spi_device *spi)
|
||||
@ -156,6 +177,8 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
data->is_vga = true; /* defaut to VGA mode */
|
||||
|
||||
/*
|
||||
* bits_per_word cannot be configured in platform data
|
||||
*/
|
||||
|
@ -137,7 +137,7 @@ static int vgg2432a4_lcd_init(struct ili9320 *lcd,
|
||||
|
||||
ili9320_write(lcd, ILI9320_RGB_IF1, cfg->rgb_if1);
|
||||
ili9320_write(lcd, ILI9320_FRAMEMAKER, 0x0);
|
||||
ili9320_write(lcd, ILI9320_RGB_IF2, ILI9320_RGBIF2_DPL);
|
||||
ili9320_write(lcd, ILI9320_RGB_IF2, cfg->rgb_if2);
|
||||
|
||||
ret = ili9320_write_regs(lcd, vgg_init1, ARRAY_SIZE(vgg_init1));
|
||||
if (ret != 0)
|
||||
|
@ -31,6 +31,10 @@ struct backlight_device;
|
||||
struct fb_info;
|
||||
|
||||
struct backlight_ops {
|
||||
unsigned int options;
|
||||
|
||||
#define BL_CORE_SUSPENDRESUME (1 << 0)
|
||||
|
||||
/* Notify the backlight driver some property has changed */
|
||||
int (*update_status)(struct backlight_device *);
|
||||
/* Return the current backlight brightness (accounting for power,
|
||||
@ -51,7 +55,19 @@ struct backlight_properties {
|
||||
modes; 4: full off), see FB_BLANK_XXX */
|
||||
int power;
|
||||
/* FB Blanking active? (values as for power) */
|
||||
/* Due to be removed, please use (state & BL_CORE_FBBLANK) */
|
||||
int fb_blank;
|
||||
/* Flags used to signal drivers of state changes */
|
||||
/* Upper 4 bits are reserved for driver internal use */
|
||||
unsigned int state;
|
||||
|
||||
#define BL_CORE_SUSPENDED (1 << 0) /* backlight is suspended */
|
||||
#define BL_CORE_FBBLANK (1 << 1) /* backlight is under an fb blank event */
|
||||
#define BL_CORE_DRIVER4 (1 << 28) /* reserved for driver specific use */
|
||||
#define BL_CORE_DRIVER3 (1 << 29) /* reserved for driver specific use */
|
||||
#define BL_CORE_DRIVER2 (1 << 30) /* reserved for driver specific use */
|
||||
#define BL_CORE_DRIVER1 (1 << 31) /* reserved for driver specific use */
|
||||
|
||||
};
|
||||
|
||||
struct backlight_device {
|
||||
|
13
include/linux/spi/tdo24m.h
Normal file
13
include/linux/spi/tdo24m.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef __TDO24M_H__
|
||||
#define __TDO24M_H__
|
||||
|
||||
enum tdo24m_model {
|
||||
TDO24M,
|
||||
TDO35S,
|
||||
};
|
||||
|
||||
struct tdo24m_platform_data {
|
||||
enum tdo24m_model model;
|
||||
};
|
||||
|
||||
#endif /* __TDO24M_H__ */
|
Loading…
Reference in New Issue
Block a user