| 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>
|
| 12 | #include <linux/mutex.h>
|
| 13 | #include <linux/notifier.h>
|
| 14 | #include <linux/fb.h>
|
| 15 |
|
| 16 | |
| 17 | *
|
| 18 | * lcd_device->ops_lock is an internal backlight lock protecting the ops
|
| 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 |
|
| 31 | struct lcd_device;
|
| 32 | struct fb_info;
|
| 33 |
|
| 34 | struct lcd_properties {
|
| 35 |
|
| 36 | int max_contrast;
|
| 37 | };
|
| 38 |
|
| 39 | struct lcd_ops {
|
| 40 | |
| 41 | power on, flat panel power off, 4: full off), see FB_BLANK_XXX
|
| 42 | int (*get_power)(struct lcd_device *);
|
| 43 |
|
| 44 | int (*set_power)(struct lcd_device *, int power);
|
| 45 |
|
| 46 | int (*get_contrast)(struct lcd_device *);
|
| 47 |
|
| 48 | int (*set_contrast)(struct lcd_device *, int contrast);
|
| 49 |
|
| 50 | int (*set_mode)(struct lcd_device *, struct fb_videomode *);
|
| 51 | |
| 52 | return 0 if not, !=0 if it is. If NULL, lcd always matches the fb.
|
| 53 | int (*check_fb)(struct lcd_device *, struct fb_info *);
|
| 54 | };
|
| 55 |
|
| 56 | struct lcd_device {
|
| 57 | struct lcd_properties props;
|
| 58 | |
| 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.
|
| 61 | struct mutex ops_lock;
|
| 62 |
|
| 63 | struct lcd_ops *ops;
|
| 64 |
|
| 65 | struct mutex update_lock;
|
| 66 |
|
| 67 | struct notifier_block fb_notif;
|
| 68 |
|
| 69 | struct device dev;
|
| 70 | };
|
| 71 |
|
| 72 | struct lcd_platform_data {
|
| 73 |
|
| 74 | int (*reset)(struct lcd_device *ld);
|
| 75 | |
| 76 | lcd power off and 1, lcd power on.
|
| 77 | int (*power_on)(struct lcd_device *ld, int enable);
|
| 78 |
|
| 79 | |
| 80 | from bootloader or not.
|
| 81 | int lcd_enabled;
|
| 82 | |
| 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 |
|
| 87 | unsigned int power_on_delay;
|
| 88 |
|
| 89 | unsigned int power_off_delay;
|
| 90 |
|
| 91 |
|
| 92 | void *pdata;
|
| 93 | };
|
| 94 |
|
| 95 | static inline void lcd_set_power(struct lcd_device *ld, int power)
|
| 96 | {
|
| 97 | mutex_lock(&ld->update_lock);
|
| 98 | if (ld->ops && ld->ops->set_power)
|
| 99 | ld->ops->set_power(ld, power);
|
| 100 | mutex_unlock(&ld->update_lock);
|
| 101 | }
|
| 102 |
|
| 103 | extern struct lcd_device *lcd_device_register(const char *name,
|
| 104 | struct device *parent, void *devdata, struct lcd_ops *ops);
|
| 105 | extern void lcd_device_unregister(struct lcd_device *ld);
|
| 106 |
|
| 107 | #define to_lcd_device(obj) container_of(obj, struct lcd_device, dev)
|
| 108 |
|
| 109 | static inline void * lcd_get_data(struct lcd_device *ld_dev)
|
| 110 | {
|
| 111 | return dev_get_drvdata(&ld_dev->dev);
|
| 112 | }
|
| 113 |
|
| 114 |
|
| 115 | #endif
|