From: Rodolfo Giometti <giometti@enneenne.com>
To: linux-arm-kernel@lists.arm.linux.org.uk
Cc: linux-kernel@vger.kernel.org, linux-fbdev-devel@lists.sourceforge.net
Subject: [PATCH 1/1] PXAFB: Support for backlight control
Date: Wed, 21 Feb 2007 15:53:53 +0100 [thread overview]
Message-ID: <20070221145353.GA23916@enneenne.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1185 bytes --]
Backlight control support for the PXA fram buffer.
Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
---
Each platform should define the backlight properties in its own setup
file in "linux/arch/arm/mach-pxa/" as follow:
static int pxafb_bl_get_brightness(struct backlight_device *bl_dev)
{
return read_the_backlight_brightness();
}
static int pxafb_bl_update_status(struct backlight_device *bl_dev)
{
int perc, ret;
if (bl_dev->props->power != FB_BLANK_UNBLANK ||
bl_dev->props->fb_blank != FB_BLANK_UNBLANK)
perc = 0;
else
perc = bl_dev->props->brightness;
write_the_backlight_brightness(perc);
return 0;
}
static struct backlight_properties wwpc1100_backlight_props = {
.get_brightness = pxafb_bl_get_brightness,
.update_status = pxafb_bl_update_status,
.max_brightness = 100,
};
and then seting up the fb info as follow:
wwpc1100_pxafb_info.modes = &special_modes;
wwpc1100_pxafb_info.bl_props = &wwpc1100_backlight_props;
set_pxa_fb_info(&wwpc1100_pxafb_info);
[-- Attachment #2: patch-pxafb-backlight --]
[-- Type: text/plain, Size: 6009 bytes --]
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index c1536d7..1ee589e 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1514,6 +1514,14 @@ config FB_PXA_PARAMETERS
<file:Documentation/fb/pxafb.txt> describes the available parameters.
+config FB_PXA_BACKLIGHT
+ bool "Support for backlight control"
+ default y
+ depends on FB_PXA
+ select FB_BACKLIGHT
+ help
+ Say Y here if you want to control the backlight of your display.
+
config FB_MBX
tristate "2700G LCD framebuffer support"
depends on FB && ARCH_PXA
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index b4947c8..489174a 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -9,6 +9,8 @@
* which in turn is
* Based on acornfb.c Copyright (C) Russell King.
*
+ * Backlight support by Rodolfo Giometti <giometti@linux.it>
+ *
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive for
* more details.
@@ -37,6 +39,7 @@
#include <linux/cpufreq.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
+#include <linux/backlight.h>
#include <asm/hardware.h>
#include <asm/io.h>
@@ -58,7 +61,6 @@
#define LCCR0_INVALID_CONFIG_MASK (LCCR0_OUM|LCCR0_BM|LCCR0_QDM|LCCR0_DIS|LCCR0_EFM|LCCR0_IUM|LCCR0_SFM|LCCR0_LDM|LCCR0_ENB)
#define LCCR3_INVALID_CONFIG_MASK (LCCR3_HSP|LCCR3_VSP|LCCR3_PCD|LCCR3_BPP)
-static void (*pxafb_backlight_power)(int);
static void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *);
@@ -69,6 +71,71 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state);
static char g_options[PXAFB_OPTIONS_SIZE] __initdata = "";
#endif
+
+/*
+ * Backlight control
+ */
+#ifdef CONFIG_FB_BACKLIGHT
+static void pxafb_bl_suspend(struct pxafb_info *fbi)
+{
+ struct backlight_device *bl_dev = fbi->fb.bl_dev;
+
+ if (bl_dev) {
+ down(&bl_dev->sem);
+ bl_dev->props->fb_blank = FB_BLANK_POWERDOWN;
+ bl_dev->props->update_status(bl_dev);
+ up(&bl_dev->sem);
+ }
+}
+
+static void pxafb_bl_resume(struct pxafb_info *fbi)
+{
+ struct backlight_device *bl_dev = fbi->fb.bl_dev;
+
+ if (bl_dev) {
+ down(&bl_dev->sem);
+ bl_dev->props->fb_blank = FB_BLANK_UNBLANK;
+ bl_dev->props->update_status(bl_dev);
+ up(&bl_dev->sem);
+ }
+}
+
+static void pxafb_bl_init(struct fb_info *info, struct backlight_properties *bl_props)
+{
+ struct backlight_device *bl_dev;
+ char name[16];
+
+ snprintf(name, sizeof(name), "pxabl%d", info->node);
+
+ bl_dev = backlight_device_register(name, info->dev, info, bl_props);
+ if (IS_ERR(bl_dev)) {
+ info->bl_dev = NULL;
+ printk(KERN_WARNING "pxafb: backlight registration failed\n");
+ return;
+ }
+
+ mutex_lock(&info->bl_mutex);
+ info->bl_dev = bl_dev;
+ fb_bl_default_curve(info, 0, 0, 100); /* level: 0 - 100 */
+ mutex_unlock(&info->bl_mutex);
+
+ down(&bl_dev->sem);
+ bl_dev->props->brightness = bl_props->max_brightness;
+ bl_dev->props->power = FB_BLANK_UNBLANK;
+ bl_dev->props->update_status(bl_dev);
+ up(&bl_dev->sem);
+
+ printk("pxafb: backlight initialized (%s)\n", name);
+}
+#else
+static inline void pxafb_bl_init(struct fb_info *info, struct backlight_properties *bl_props) {}
+static inline void pxafb_bl_suspend(struct pxafb_info *fbi) {}
+static inline void pxafb_bl_resume(struct pxafb_info *fbi) {}
+#endif /* CONFIG_FB_BACKLIGHT */
+
+/*
+ *
+ */
static inline void pxafb_schedule_work(struct pxafb_info *fbi, u_int state)
{
unsigned long flags;
@@ -736,14 +803,6 @@ static int pxafb_activate_var(struct fb_var_screeninfo *var, struct pxafb_info *
* to ensure that things happen in the right way 100% of time time.
* -- rmk
*/
-static inline void __pxafb_backlight_power(struct pxafb_info *fbi, int on)
-{
- pr_debug("pxafb: backlight o%s\n", on ? "n" : "ff");
-
- if (pxafb_backlight_power)
- pxafb_backlight_power(on);
-}
-
static inline void __pxafb_lcd_power(struct pxafb_info *fbi, int on)
{
pr_debug("pxafb: LCD power o%s\n", on ? "n" : "ff");
@@ -899,7 +958,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
*/
if (old_state != C_DISABLE) {
fbi->state = state;
- __pxafb_backlight_power(fbi, 0);
+ pxafb_bl_suspend(fbi);
__pxafb_lcd_power(fbi, 0);
if (old_state != C_DISABLE_CLKCHANGE)
pxafb_disable_controller(fbi);
@@ -953,7 +1012,7 @@ static void set_ctrlr_state(struct pxafb_info *fbi, u_int state)
pxafb_setup_gpio(fbi);
pxafb_enable_controller(fbi);
__pxafb_lcd_power(fbi, 1);
- __pxafb_backlight_power(fbi, 1);
+ pxafb_bl_resume(fbi);
}
break;
}
@@ -1112,11 +1171,10 @@ static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
int i, smemlen;
/* Alloc the pxafb_info and pseudo_palette in one step */
- fbi = kmalloc(sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL);
+ fbi = (struct pxafb_info *) framebuffer_alloc(sizeof(u32) * 16, dev);
if (!fbi)
return NULL;
- memset(fbi, 0, sizeof(struct pxafb_info));
fbi->dev = dev;
strcpy(fbi->fb.fix.id, PXA_NAME);
@@ -1368,7 +1426,6 @@ int __init pxafb_probe(struct platform_device *dev)
ret = -EINVAL;
goto failed;
}
- pxafb_backlight_power = inf->pxafb_backlight_power;
pxafb_lcd_power = inf->pxafb_lcd_power;
fbi = pxafb_init_fbinfo(&dev->dev);
if (!fbi) {
@@ -1407,6 +1464,9 @@ int __init pxafb_probe(struct platform_device *dev)
goto failed;
}
+ /* Register the backlight support */
+ pxafb_bl_init(&fbi->fb, inf->bl_props);
+
#ifdef CONFIG_PM
// TODO
#endif
diff --git a/include/asm-arm/arch-pxa/pxafb.h b/include/asm-arm/arch-pxa/pxafb.h
index 81c3928..5c89664 100644
--- a/include/asm-arm/arch-pxa/pxafb.h
+++ b/include/asm-arm/arch-pxa/pxafb.h
@@ -71,7 +71,7 @@ struct pxafb_mach_info {
*/
u_int lccr3;
- void (*pxafb_backlight_power)(int);
+ struct backlight_properties *bl_props;
void (*pxafb_lcd_power)(int, struct fb_var_screeninfo *);
};
next reply other threads:[~2007-02-21 14:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-21 14:53 Rodolfo Giometti [this message]
2007-02-21 16:00 ` [PATCH 1/1] PXAFB: Support for backlight control Paul Sokolovsky
2007-02-21 16:00 ` Paul Sokolovsky
2007-02-21 16:12 ` Rodolfo Giometti
2007-02-21 16:26 ` Paul Sokolovsky
2007-02-21 16:26 ` Paul Sokolovsky
2007-02-22 8:32 ` Rodolfo Giometti
2007-02-22 10:33 ` Paul Sokolovsky
2007-02-22 10:33 ` Paul Sokolovsky
2007-02-22 16:37 ` Rodolfo Giometti
2007-02-22 17:11 ` Richard Purdie
2007-02-22 17:11 ` Richard Purdie
2007-02-28 16:54 ` [Linux-fbdev-devel] " James Simmons
2007-02-22 0:59 ` Richard Purdie
2007-02-22 0:59 ` Richard Purdie
2007-02-22 8:28 ` Rodolfo Giometti
2007-02-22 9:27 ` Richard Purdie
2007-02-22 9:27 ` Richard Purdie
2007-02-22 9:32 ` Rodolfo Giometti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070221145353.GA23916@enneenne.com \
--to=giometti@enneenne.com \
--cc=linux-arm-kernel@lists.arm.linux.org.uk \
--cc=linux-fbdev-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.