Skip to content

Commit

Permalink
backlight: Adds HP Jornada 700 series backlight driver
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Ericson <[email protected]>
Signed-off-by: Richard Purdie <[email protected]>
  • Loading branch information
Kristoffer Ericson authored and rpurdie committed Apr 6, 2009
1 parent 9e12443 commit 13a7b5d
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/video/backlight/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ config BACKLIGHT_HP680
If you have a HP Jornada 680, say y to enable the
backlight driver.

config BACKLIGHT_HP700
tristate "HP Jornada 700 series Backlight Driver"
depends on BACKLIGHT_CLASS_DEVICE
depends on SA1100_JORNADA720_SSP && !PREEMPT
default y
help
If you have an HP Jornada 700 series,
say Y to include backlight control driver.

config BACKLIGHT_PROGEAR
tristate "Frontpath ProGear Backlight Driver"
depends on BACKLIGHT_CLASS_DEVICE && PCI && X86
Expand Down
1 change: 1 addition & 0 deletions drivers/video/backlight/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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_GENERIC) += generic_bl.o
obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o
obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
Expand Down
161 changes: 161 additions & 0 deletions drivers/video/backlight/jornada720_bl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
*
* Backlight driver for HP Jornada 700 series (710/720/728)
* Copyright (C) 2006-2009 Kristoffer Ericson <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 or any later version as published by the Free Software Foundation.
*
*/

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

#include <mach/jornada720.h>
#include <mach/hardware.h>

#include <video/s1d13xxxfb.h>

#define BL_MAX_BRIGHT 255
#define BL_DEF_BRIGHT 25

static int jornada_bl_get_brightness(struct backlight_device *bd)
{
int ret;

/* check if backlight is on */
if (!(PPSR & PPC_LDD1))
return 0;

jornada_ssp_start();

/* cmd should return txdummy */
ret = jornada_ssp_byte(GETBRIGHTNESS);

if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) {
printk(KERN_ERR "bl : get brightness timeout\n");
jornada_ssp_end();
return -ETIMEDOUT;
} else /* exchange txdummy for value */
ret = jornada_ssp_byte(TXDUMMY);

jornada_ssp_end();

return (BL_MAX_BRIGHT - ret);
}

static int jornada_bl_update_status(struct backlight_device *bd)
{
int ret = 0;

jornada_ssp_start();

/* If backlight is off then really turn it off */
if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
ret = jornada_ssp_byte(BRIGHTNESSOFF);
if (ret != TXDUMMY) {
printk(KERN_INFO "bl : brightness off timeout\n");
/* turn off backlight */
PPSR &= ~PPC_LDD1;
PPDR |= PPC_LDD1;
ret = -ETIMEDOUT;
}
} else /* turn on backlight */
PPSR |= PPC_LDD1;

/* send command to our mcu */
if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) {
printk(KERN_INFO "bl : failed to set brightness\n");
ret = -ETIMEDOUT;
goto out
}

/* at this point we expect that the mcu has accepted
our command and is waiting for our new value
please note that maximum brightness is 255,
but due to physical layout it is equal to 0, so we simply
invert the value (MAX VALUE - NEW VALUE). */
if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) != TXDUMMY) {
printk(KERN_ERR "bl : set brightness failed\n");
ret = -ETIMEDOUT;
}

/* If infact we get an TXDUMMY as output we are happy and dont
make any further comments about it */
out:
jornada_ssp_end();

return ret;
}

static struct backlight_ops jornada_bl_ops = {
.get_brightness = jornada_bl_get_brightness,
.update_status = jornada_bl_update_status,
.options = BL_CORE_SUSPENDRESUME,
};

static int jornada_bl_probe(struct platform_device *pdev)
{
int ret;
struct backlight_device *bd;

bd = backlight_device_register(S1D_DEVICENAME, &pdev->dev, NULL, &jornada_bl_ops);

if (IS_ERR(bd)) {
ret = PTR_ERR(bd);
printk(KERN_ERR "bl : failed to register device, err=%x\n", ret);
return ret;
}

bd->props.power = FB_BLANK_UNBLANK;
bd->props.brightness = BL_DEF_BRIGHT;
/* note. make sure max brightness is set otherwise
you will get seemingly non-related errors when
trying to change brightness */
bd->props.max_brightness = BL_MAX_BRIGHT;
jornada_bl_update_status(bd);

platform_set_drvdata(pdev, bd);
printk(KERN_INFO "HP Jornada 700 series backlight driver\n");

return 0;
}

static int jornada_bl_remove(struct platform_device *pdev)
{
struct backlight_device *bd = platform_get_drvdata(pdev);

backlight_device_unregister(bd);

return 0;
}

static struct platform_driver jornada_bl_driver = {
.probe = jornada_bl_probe,
.remove = jornada_bl_remove,
.driver = {
.name = "jornada_bl",
},
};

int __init jornada_bl_init(void)
{
return platform_driver_register(&jornada_bl_driver);
}

void __exit jornada_bl_exit(void)
{
platform_driver_unregister(&jornada_bl_driver);
}

MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson>");
MODULE_DESCRIPTION("HP Jornada 710/720/728 Backlight driver");
MODULE_LICENSE("GPL");

module_init(jornada_bl_init);
module_exit(jornada_bl_exit);

0 comments on commit 13a7b5d

Please sign in to comment.