* [PATCH] LCD backlight
@ 2006-06-29 19:35 andrzej zaborowski
2006-08-11 11:09 ` Tony Lindgren
0 siblings, 1 reply; 3+ messages in thread
From: andrzej zaborowski @ 2006-06-29 19:35 UTC (permalink / raw)
To: Linux-OMAP
[-- Attachment #1: Type: text/plain, Size: 897 bytes --]
Add a simple driver for the LCD backlight that uses the Linux backlight api.
---
Some notes:
The "check_fb" field is for the boards that have more than one LCD.
The "set_power" field is for boards that need to do something special
(e.g. GPIOs) before enabling the backlight. You can leave them unset.
You can use this driver only on boards that don't use UART3 because
UART3.TX and PWL use the same pin. Does someone know an easy
workaround for this pin conflict? PalmOS 5 running on OMAP311 somehow
manages to send and receiver IrDA through UART3 and you can't see any
change in the backlight level. In Linux when I set this pin to be
UART3.TX, the backlight level is always forced to 255.
Does someone know if the Kconfig option should depend on (ARCH_OMAP1
|| ARCH_OMAP2) or rather ARCH_OMAP1 only?
To use this patch, first use the previous patch ("fix PWL macro names").
Regards,
Andrzej
[-- Attachment #2: linux-omap-backlight.patch --]
[-- Type: application/octet-stream, Size: 7904 bytes --]
diff -pNaur -X linux-omap-2.6-newbuild/Documentation/dontdiff linux-omap-2.6/drivers/video/backlight/Kconfig linux-omap-2.6-newbuild/drivers/video/backlight/Kconfig
--- linux-omap-2.6/drivers/video/backlight/Kconfig 2006-03-22 18:44:53.000000000 +0100
+++ linux-omap-2.6-newbuild/drivers/video/backlight/Kconfig 2006-06-24 01:37:32.000000000 +0200
@@ -58,3 +58,11 @@ config BACKLIGHT_HP680
If you have a HP Jornada 680, say y to enable the
backlight driver.
+config BACKLIGHT_OMAP
+ tristate "OMAP LCD Backlight"
+ depends on BACKLIGHT_DEVICE && (ARCH_OMAP1 || ARCH_OMAP2)
+ default y
+ help
+ This driver controls the LCD backlight level and power
+ for the PWL module of OMAP processors. Say Y if you want
+ to use power saving.
diff -pNaur -X linux-omap-2.6-newbuild/Documentation/dontdiff linux-omap-2.6/drivers/video/backlight/Makefile linux-omap-2.6-newbuild/drivers/video/backlight/Makefile
--- linux-omap-2.6/drivers/video/backlight/Makefile 2006-03-22 18:44:53.000000000 +0100
+++ linux-omap-2.6-newbuild/drivers/video/backlight/Makefile 2006-06-23 04:15:05.000000000 +0200
@@ -4,4 +4,5 @@ obj-$(CONFIG_LCD_CLASS_DEVICE) += lc
obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o
obj-$(CONFIG_BACKLIGHT_CORGI) += corgi_bl.o
obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
+obj-$(CONFIG_BACKLIGHT_OMAP) += omap_bl.o
obj-$(CONFIG_SHARP_LOCOMO) += locomolcd.o
diff -pNaur -X linux-omap-2.6-newbuild/Documentation/dontdiff linux-omap-2.6/drivers/video/backlight/omap_bl.c linux-omap-2.6-newbuild/drivers/video/backlight/omap_bl.c
--- linux-omap-2.6/drivers/video/backlight/omap_bl.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-omap-2.6-newbuild/drivers/video/backlight/omap_bl.c 2006-06-25 06:05:46.000000000 +0200
@@ -0,0 +1,215 @@
+/*
+ * drivers/video/backlight/omap_bl.c
+ *
+ * Backlight driver for OMAP based boards.
+ *
+ * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this package; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/fb.h>
+#include <linux/backlight.h>
+
+#include <asm/arch/hardware.h>
+#include <asm/arch/board.h>
+#include <asm/arch/mux.h>
+
+#define OMAPBL_MAX_INTENSITY 0xff
+
+struct omap_backlight {
+ int powermode;
+ int current_intensity;
+
+ struct device *dev;
+ struct omap_backlight_config *pdata;
+};
+
+static void inline omapbl_send_intensity(int intensity)
+{
+ omap_writeb(intensity, OMAP_PWL_ENABLE);
+}
+
+static void inline omapbl_send_enable(int enable)
+{
+ omap_writeb(enable, OMAP_PWL_CLK_ENABLE);
+}
+
+static void omapbl_blank(struct omap_backlight *bl, int mode)
+{
+ if (bl->pdata->set_power)
+ bl->pdata->set_power(bl->dev, mode);
+
+ switch (mode) {
+ case FB_BLANK_NORMAL:
+ case FB_BLANK_VSYNC_SUSPEND:
+ case FB_BLANK_HSYNC_SUSPEND:
+ case FB_BLANK_POWERDOWN:
+ omapbl_send_intensity(0);
+ omapbl_send_enable(0);
+ break;
+
+ case FB_BLANK_UNBLANK:
+ omapbl_send_intensity(bl->current_intensity);
+ omapbl_send_enable(1);
+ break;
+ }
+}
+
+#ifdef CONFIG_PM
+static int omapbl_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ struct backlight_device *dev = platform_get_drvdata(pdev);
+ struct omap_backlight *bl = class_get_devdata(&dev->class_dev);
+
+ omapbl_blank(bl, FB_BLANK_POWERDOWN);
+ return 0;
+}
+
+static int omapbl_resume(struct platform_device *pdev)
+{
+ struct backlight_device *dev = platform_get_drvdata(pdev);
+ struct omap_backlight *bl = class_get_devdata(&dev->class_dev);
+
+ omapbl_blank(bl, bl->powermode);
+ return 0;
+}
+#else
+#define omapbl_suspend NULL
+#define omapbl_resume NULL
+#endif
+
+static int omapbl_set_power(struct backlight_device *dev, int state)
+{
+ struct omap_backlight *bl = class_get_devdata(&dev->class_dev);
+
+ omapbl_blank(bl, state);
+ bl->powermode = state;
+
+ return 0;
+}
+
+static int omapbl_get_power(struct backlight_device *dev)
+{
+ struct omap_backlight *bl = class_get_devdata(&dev->class_dev);
+ return bl->powermode;
+}
+
+static int omapbl_set_intensity(struct backlight_device *dev, int intensity)
+{
+ struct omap_backlight *bl = class_get_devdata(&dev->class_dev);
+
+ if (intensity > OMAPBL_MAX_INTENSITY || intensity < 0)
+ return -EPERM; /* Leave current_intensity untouched */
+
+ if (bl->powermode == FB_BLANK_UNBLANK)
+ omapbl_send_intensity(intensity);
+ bl->current_intensity = intensity;
+
+ return 0;
+}
+
+static int omapbl_get_intensity(struct backlight_device *dev)
+{
+ struct omap_backlight *bl = class_get_devdata(&dev->class_dev);
+ return bl->current_intensity;
+}
+
+static struct backlight_properties omapbl_data = {
+ .owner = THIS_MODULE,
+ .get_power = omapbl_get_power,
+ .set_power = omapbl_set_power,
+ .max_brightness = OMAPBL_MAX_INTENSITY,
+ .get_brightness = omapbl_get_intensity,
+ .set_brightness = omapbl_set_intensity,
+};
+
+static int omapbl_probe(struct platform_device *pdev)
+{
+ struct backlight_device *dev;
+ struct omap_backlight *bl;
+ struct omap_backlight_config *pdata = pdev->dev.platform_data;
+
+ omapbl_data.check_fb = pdata->check_fb;
+
+ bl = kzalloc(sizeof(struct omap_backlight), GFP_KERNEL);
+ if (unlikely(!bl))
+ return -ENOMEM;
+
+ dev = backlight_device_register("omap-bl", bl, &omapbl_data);
+ if (IS_ERR(dev)) {
+ kfree(bl);
+ return PTR_ERR(dev);
+ }
+
+ bl->powermode = FB_BLANK_POWERDOWN;
+ bl->current_intensity = 0;
+
+ bl->pdata = pdata;
+ bl->dev = &pdev->dev;
+
+ platform_set_drvdata(pdev, dev);
+
+ omap_cfg_reg(PWL); /* Conflicts with UART3 */
+
+ omapbl_set_power(dev, FB_BLANK_UNBLANK);
+ omapbl_set_intensity(dev, pdata->default_intensity);
+
+ printk(KERN_INFO "OMAP LCD backlight initialised\n");
+
+ return 0;
+}
+
+static int omapbl_remove(struct platform_device *pdev)
+{
+ struct backlight_device *dev = platform_get_drvdata(pdev);
+ struct omap_backlight *bl = class_get_devdata(&dev->class_dev);
+
+ backlight_device_unregister(dev);
+ kfree(bl);
+
+ return 0;
+}
+
+static struct platform_driver omapbl_driver = {
+ .probe = omapbl_probe,
+ .remove = omapbl_remove,
+ .suspend = omapbl_suspend,
+ .resume = omapbl_resume,
+ .driver = {
+ .name = "omap-bl",
+ },
+};
+
+static int __init omapbl_init(void)
+{
+ return platform_driver_register(&omapbl_driver);
+}
+
+static void __exit omapbl_exit(void)
+{
+ platform_driver_unregister(&omapbl_driver);
+}
+
+module_init(omapbl_init);
+module_exit(omapbl_exit);
+
+MODULE_AUTHOR("Andrzej Zaborowski <balrog@zabor.org>");
+MODULE_DESCRIPTION("OMAP LCD Backlight driver");
+MODULE_LICENSE("GPL");
diff -pNaur -X linux-omap-2.6-newbuild/Documentation/dontdiff linux-omap-2.6/include/asm-arm/arch-omap/board.h linux-omap-2.6-newbuild/include/asm-arm/arch-omap/board.h
--- linux-omap-2.6/include/asm-arm/arch-omap/board.h 2006-03-22 18:45:00.000000000 +0100
+++ linux-omap-2.6-newbuild/include/asm-arm/arch-omap/board.h 2006-06-25 05:16:09.000000000 +0200
@@ -104,6 +104,14 @@ struct omap_lcd_config {
u8 data_lines;
};
+struct device;
+struct fb_info;
+struct omap_backlight_config {
+ int default_intensity;
+ int (*set_power)(struct device *dev, int state);
+ int (*check_fb)(struct fb_info *fb);
+};
+
struct omap_fbmem_config {
u32 start;
u32 size;
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LCD backlight
2006-06-29 19:35 [PATCH] LCD backlight andrzej zaborowski
@ 2006-08-11 11:09 ` Tony Lindgren
2006-08-11 11:51 ` andrzej zaborowski
0 siblings, 1 reply; 3+ messages in thread
From: Tony Lindgren @ 2006-08-11 11:09 UTC (permalink / raw)
To: balrogg; +Cc: Linux-OMAP
* andrzej zaborowski <balrog@zabor.org> [060629 22:36]:
> Add a simple driver for the LCD backlight that uses the Linux backlight api.
> ---
> Some notes:
>
> The "check_fb" field is for the boards that have more than one LCD.
> The "set_power" field is for boards that need to do something special
> (e.g. GPIOs) before enabling the backlight. You can leave them unset.
>
> You can use this driver only on boards that don't use UART3 because
> UART3.TX and PWL use the same pin. Does someone know an easy
> workaround for this pin conflict? PalmOS 5 running on OMAP311 somehow
> manages to send and receiver IrDA through UART3 and you can't see any
> change in the backlight level. In Linux when I set this pin to be
> UART3.TX, the backlight level is always forced to 255.
No idea. Maybe you can mux some other pin for UART3.TX?
Could you please post a Signed-off-by for this patch too?
Thanks,
Tony
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] LCD backlight
2006-08-11 11:09 ` Tony Lindgren
@ 2006-08-11 11:51 ` andrzej zaborowski
0 siblings, 0 replies; 3+ messages in thread
From: andrzej zaborowski @ 2006-08-11 11:51 UTC (permalink / raw)
To: Tony Lindgren; +Cc: Linux-OMAP
On 11/08/06, Tony Lindgren <tony@atomide.com> wrote:
> * andrzej zaborowski <balrog@zabor.org> [060629 22:36]:
> > Add a simple driver for the LCD backlight that uses the Linux backlight api.
> > ---
> > Some notes:
> >
> > The "check_fb" field is for the boards that have more than one LCD.
> > The "set_power" field is for boards that need to do something special
> > (e.g. GPIOs) before enabling the backlight. You can leave them unset.
> >
> > You can use this driver only on boards that don't use UART3 because
> > UART3.TX and PWL use the same pin. Does someone know an easy
> > workaround for this pin conflict? PalmOS 5 running on OMAP311 somehow
> > manages to send and receiver IrDA through UART3 and you can't see any
> > change in the backlight level. In Linux when I set this pin to be
> > UART3.TX, the backlight level is always forced to 255.
>
> No idea. Maybe you can mux some other pin for UART3.TX?
I'm not sure how this happens but now I have both IrDA and PWL working
and the pin is set to work as PWL.
>
> Could you please post a Signed-off-by for this patch too?
I will need to rediff it because it seems the backlight API changed in
current git a bit. BTW Also I noticed that struct lcd_panel (in the
OMAP LCD driver) now has pointers for intensity setters and getters
for potential use. Maybe it should be somehow coupled with backlight
api (e.g. using "notifiers").
I will post a new version this week, if this is OK.
>
> Thanks,
>
> Tony
>
--
balrog 2oo6
Dear Outlook users: Please remove me from your address books
http://www.newsforge.com/article.pl?sid=03/08/21/143258
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-08-11 11:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-29 19:35 [PATCH] LCD backlight andrzej zaborowski
2006-08-11 11:09 ` Tony Lindgren
2006-08-11 11:51 ` andrzej zaborowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox