]> bbs.cooldavid.org Git - net-next-2.6.git/blame - include/linux/lcd.h
stmmac: add init/exit callback in plat_stmmacenet_data struct
[net-next-2.6.git] / include / linux / lcd.h
CommitLineData
1da177e4
LT
1/*
2 * LCD Lowlevel Control Abstraction
3 *
4 * Copyright (C) 2003,2004 Hewlett-Packard Company
5 *
6 */
7
8#ifndef _LINUX_LCD_H
9#define _LINUX_LCD_H
10
11#include <linux/device.h>
28ee086d 12#include <linux/mutex.h>
1da177e4 13#include <linux/notifier.h>
faa312da 14#include <linux/fb.h>
1da177e4 15
28ee086d
RP
16/* Notes on locking:
17 *
599a52d1 18 * lcd_device->ops_lock is an internal backlight lock protecting the ops
28ee086d
RP
19 * field and no code outside the core should need to touch it.
20 *
21 * Access to set_power() is serialised by the update_lock mutex since
22 * most drivers seem to need this and historically get it wrong.
23 *
24 * Most drivers don't need locking on their get_power() method.
25 * If yours does, you need to implement it in the driver. You can use the
26 * update_lock mutex if appropriate.
27 *
28 * Any other use of the locks below is probably wrong.
29 */
30
1da177e4
LT
31struct lcd_device;
32struct fb_info;
33
1da177e4 34struct lcd_properties {
599a52d1
RP
35 /* The maximum value for contrast (read-only) */
36 int max_contrast;
37};
38
39struct lcd_ops {
1da177e4
LT
40 /* Get the LCD panel power status (0: full on, 1..3: controller
41 power on, flat panel power off, 4: full off), see FB_BLANK_XXX */
42 int (*get_power)(struct lcd_device *);
43 /* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */
44 int (*set_power)(struct lcd_device *, int power);
1da177e4
LT
45 /* Get the current contrast setting (0-max_contrast) */
46 int (*get_contrast)(struct lcd_device *);
47 /* Set LCD panel contrast */
48 int (*set_contrast)(struct lcd_device *, int contrast);
faa312da
EM
49 /* Set LCD panel mode (resolutions ...) */
50 int (*set_mode)(struct lcd_device *, struct fb_videomode *);
1da177e4
LT
51 /* Check if given framebuffer device is the one LCD is bound to;
52 return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */
0c531360 53 int (*check_fb)(struct lcd_device *, struct fb_info *);
1da177e4
LT
54};
55
56struct lcd_device {
599a52d1
RP
57 struct lcd_properties props;
58 /* This protects the 'ops' field. If 'ops' is NULL, the driver that
1da177e4
LT
59 registered this device has been unloaded, and if class_get_devdata()
60 points to something in the body of that driver, it is also invalid. */
599a52d1 61 struct mutex ops_lock;
1da177e4 62 /* If this is NULL, the backing module is unloaded */
599a52d1 63 struct lcd_ops *ops;
28ee086d
RP
64 /* Serialise access to set_power method */
65 struct mutex update_lock;
1da177e4
LT
66 /* The framebuffer notifier block */
67 struct notifier_block fb_notif;
655bfd7a
RP
68
69 struct device dev;
1da177e4
LT
70};
71
ee378a5c
ID
72struct lcd_platform_data {
73 /* reset lcd panel device. */
74 int (*reset)(struct lcd_device *ld);
75 /* on or off to lcd panel. if 'enable' is 0 then
76 lcd power off and 1, lcd power on. */
77 int (*power_on)(struct lcd_device *ld, int enable);
78
79 /* it indicates whether lcd panel was enabled
80 from bootloader or not. */
81 int lcd_enabled;
82 /* it means delay for stable time when it becomes low to high
83 or high to low that is dependent on whether reset gpio is
84 low active or high active. */
85 unsigned int reset_delay;
86 /* stable time needing to become lcd power on. */
87 unsigned int power_on_delay;
88 /* stable time needing to become lcd power off. */
89 unsigned int power_off_delay;
90
91 /* it could be used for any purpose. */
92 void *pdata;
93};
94
28ee086d
RP
95static inline void lcd_set_power(struct lcd_device *ld, int power)
96{
97 mutex_lock(&ld->update_lock);
599a52d1
RP
98 if (ld->ops && ld->ops->set_power)
99 ld->ops->set_power(ld, power);
28ee086d
RP
100 mutex_unlock(&ld->update_lock);
101}
102
1da177e4 103extern struct lcd_device *lcd_device_register(const char *name,
655bfd7a 104 struct device *parent, void *devdata, struct lcd_ops *ops);
1da177e4
LT
105extern void lcd_device_unregister(struct lcd_device *ld);
106
655bfd7a
RP
107#define to_lcd_device(obj) container_of(obj, struct lcd_device, dev)
108
109static inline void * lcd_get_data(struct lcd_device *ld_dev)
110{
111 return dev_get_drvdata(&ld_dev->dev);
112}
113
1da177e4
LT
114
115#endif