Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.18-rc2 168 lines 3.9 kB view raw
1/* 2 * Backlight Driver for HP Jornada 680 3 * 4 * Copyright (c) 2005 Andriy Skulysh 5 * 6 * Based on Sharp's Corgi Backlight Driver 7 * 8 * This file is subject to the terms and conditions of the GNU General Public 9 * License. See the file "COPYING" in the main directory of this archive 10 * for more details. 11 */ 12 13#include <linux/module.h> 14#include <linux/kernel.h> 15#include <linux/init.h> 16#include <linux/platform_device.h> 17#include <linux/spinlock.h> 18#include <linux/backlight.h> 19 20#include <cpu/dac.h> 21#include <mach/hp6xx.h> 22#include <asm/hd64461.h> 23 24#define HP680_MAX_INTENSITY 255 25#define HP680_DEFAULT_INTENSITY 10 26 27static int hp680bl_suspended; 28static int current_intensity; 29static DEFINE_SPINLOCK(bl_lock); 30 31static void hp680bl_send_intensity(struct backlight_device *bd) 32{ 33 unsigned long flags; 34 u16 v; 35 int intensity = backlight_get_brightness(bd); 36 37 if (hp680bl_suspended) 38 intensity = 0; 39 40 spin_lock_irqsave(&bl_lock, flags); 41 if (intensity && current_intensity == 0) { 42 sh_dac_enable(DAC_LCD_BRIGHTNESS); 43 v = inw(HD64461_GPBDR); 44 v &= ~HD64461_GPBDR_LCDOFF; 45 outw(v, HD64461_GPBDR); 46 sh_dac_output(255-(u8)intensity, DAC_LCD_BRIGHTNESS); 47 } else if (intensity == 0 && current_intensity != 0) { 48 sh_dac_output(255-(u8)intensity, DAC_LCD_BRIGHTNESS); 49 sh_dac_disable(DAC_LCD_BRIGHTNESS); 50 v = inw(HD64461_GPBDR); 51 v |= HD64461_GPBDR_LCDOFF; 52 outw(v, HD64461_GPBDR); 53 } else if (intensity) { 54 sh_dac_output(255-(u8)intensity, DAC_LCD_BRIGHTNESS); 55 } 56 spin_unlock_irqrestore(&bl_lock, flags); 57 58 current_intensity = intensity; 59} 60 61 62#ifdef CONFIG_PM_SLEEP 63static int hp680bl_suspend(struct device *dev) 64{ 65 struct backlight_device *bd = dev_get_drvdata(dev); 66 67 hp680bl_suspended = 1; 68 hp680bl_send_intensity(bd); 69 return 0; 70} 71 72static int hp680bl_resume(struct device *dev) 73{ 74 struct backlight_device *bd = dev_get_drvdata(dev); 75 76 hp680bl_suspended = 0; 77 hp680bl_send_intensity(bd); 78 return 0; 79} 80#endif 81 82static SIMPLE_DEV_PM_OPS(hp680bl_pm_ops, hp680bl_suspend, hp680bl_resume); 83 84static int hp680bl_set_intensity(struct backlight_device *bd) 85{ 86 hp680bl_send_intensity(bd); 87 return 0; 88} 89 90static int hp680bl_get_intensity(struct backlight_device *bd) 91{ 92 return current_intensity; 93} 94 95static const struct backlight_ops hp680bl_ops = { 96 .get_brightness = hp680bl_get_intensity, 97 .update_status = hp680bl_set_intensity, 98}; 99 100static int hp680bl_probe(struct platform_device *pdev) 101{ 102 struct backlight_properties props; 103 struct backlight_device *bd; 104 105 memset(&props, 0, sizeof(struct backlight_properties)); 106 props.type = BACKLIGHT_RAW; 107 props.max_brightness = HP680_MAX_INTENSITY; 108 bd = devm_backlight_device_register(&pdev->dev, "hp680-bl", &pdev->dev, 109 NULL, &hp680bl_ops, &props); 110 if (IS_ERR(bd)) 111 return PTR_ERR(bd); 112 113 platform_set_drvdata(pdev, bd); 114 115 bd->props.brightness = HP680_DEFAULT_INTENSITY; 116 hp680bl_send_intensity(bd); 117 118 return 0; 119} 120 121static void hp680bl_remove(struct platform_device *pdev) 122{ 123 struct backlight_device *bd = platform_get_drvdata(pdev); 124 125 bd->props.brightness = 0; 126 bd->props.power = 0; 127 hp680bl_send_intensity(bd); 128} 129 130static struct platform_driver hp680bl_driver = { 131 .probe = hp680bl_probe, 132 .remove = hp680bl_remove, 133 .driver = { 134 .name = "hp680-bl", 135 .pm = &hp680bl_pm_ops, 136 }, 137}; 138 139static struct platform_device *hp680bl_device; 140 141static int __init hp680bl_init(void) 142{ 143 int ret; 144 145 ret = platform_driver_register(&hp680bl_driver); 146 if (ret) 147 return ret; 148 hp680bl_device = platform_device_register_simple("hp680-bl", -1, 149 NULL, 0); 150 if (IS_ERR(hp680bl_device)) { 151 platform_driver_unregister(&hp680bl_driver); 152 return PTR_ERR(hp680bl_device); 153 } 154 return 0; 155} 156 157static void __exit hp680bl_exit(void) 158{ 159 platform_device_unregister(hp680bl_device); 160 platform_driver_unregister(&hp680bl_driver); 161} 162 163module_init(hp680bl_init); 164module_exit(hp680bl_exit); 165 166MODULE_AUTHOR("Andriy Skulysh <askulysh@gmail.com>"); 167MODULE_DESCRIPTION("HP Jornada 680 Backlight Driver"); 168MODULE_LICENSE("GPL");