1 /* SPDX-License-Identifier: GPL-2.0 */ << 2 /* 1 /* 3 * LCD Lowlevel Control Abstraction 2 * LCD Lowlevel Control Abstraction 4 * 3 * 5 * Copyright (C) 2003,2004 Hewlett-Packard Com 4 * Copyright (C) 2003,2004 Hewlett-Packard Company 6 * 5 * 7 */ 6 */ 8 7 9 #ifndef _LINUX_LCD_H 8 #ifndef _LINUX_LCD_H 10 #define _LINUX_LCD_H 9 #define _LINUX_LCD_H 11 10 12 #include <linux/device.h> 11 #include <linux/device.h> 13 #include <linux/mutex.h> 12 #include <linux/mutex.h> 14 #include <linux/notifier.h> 13 #include <linux/notifier.h> 15 #include <linux/fb.h> 14 #include <linux/fb.h> 16 15 17 /* Notes on locking: 16 /* Notes on locking: 18 * 17 * 19 * lcd_device->ops_lock is an internal backlig 18 * lcd_device->ops_lock is an internal backlight lock protecting the ops 20 * field and no code outside the core should n 19 * field and no code outside the core should need to touch it. 21 * 20 * 22 * Access to set_power() is serialised by the 21 * Access to set_power() is serialised by the update_lock mutex since 23 * most drivers seem to need this and historic 22 * most drivers seem to need this and historically get it wrong. 24 * 23 * 25 * Most drivers don't need locking on their ge 24 * Most drivers don't need locking on their get_power() method. 26 * If yours does, you need to implement it in 25 * If yours does, you need to implement it in the driver. You can use the 27 * update_lock mutex if appropriate. 26 * update_lock mutex if appropriate. 28 * 27 * 29 * Any other use of the locks below is probabl 28 * Any other use of the locks below is probably wrong. 30 */ 29 */ 31 30 32 struct lcd_device; 31 struct lcd_device; 33 struct fb_info; 32 struct fb_info; 34 33 35 struct lcd_properties { 34 struct lcd_properties { 36 /* The maximum value for contrast (rea 35 /* The maximum value for contrast (read-only) */ 37 int max_contrast; 36 int max_contrast; 38 }; 37 }; 39 38 40 struct lcd_ops { 39 struct lcd_ops { 41 /* Get the LCD panel power status (0: 40 /* Get the LCD panel power status (0: full on, 1..3: controller 42 power on, flat panel power off, 4: 41 power on, flat panel power off, 4: full off), see FB_BLANK_XXX */ 43 int (*get_power)(struct lcd_device *); 42 int (*get_power)(struct lcd_device *); >> 43 /* >> 44 * Enable or disable power to the LCD(0: on; 4: off, see FB_BLANK_XXX) >> 45 * and this callback would be called proir to fb driver's callback. >> 46 * >> 47 * P.S. note that if early_set_power is not NULL then early fb notifier >> 48 * would be registered. >> 49 */ >> 50 int (*early_set_power)(struct lcd_device *, int power); >> 51 /* revert the effects of the early blank event. */ >> 52 int (*r_early_set_power)(struct lcd_device *, int power); 44 /* Enable or disable power to the LCD 53 /* Enable or disable power to the LCD (0: on; 4: off, see FB_BLANK_XXX) */ 45 int (*set_power)(struct lcd_device *, 54 int (*set_power)(struct lcd_device *, int power); 46 /* Get the current contrast setting (0 55 /* Get the current contrast setting (0-max_contrast) */ 47 int (*get_contrast)(struct lcd_device 56 int (*get_contrast)(struct lcd_device *); 48 /* Set LCD panel contrast */ 57 /* Set LCD panel contrast */ 49 int (*set_contrast)(struct lcd_device 58 int (*set_contrast)(struct lcd_device *, int contrast); 50 /* Set LCD panel mode (resolutions ... 59 /* Set LCD panel mode (resolutions ...) */ 51 int (*set_mode)(struct lcd_device *, s 60 int (*set_mode)(struct lcd_device *, struct fb_videomode *); 52 /* Check if given framebuffer device i 61 /* Check if given framebuffer device is the one LCD is bound to; 53 return 0 if not, !=0 if it is. If N 62 return 0 if not, !=0 if it is. If NULL, lcd always matches the fb. */ 54 int (*check_fb)(struct lcd_device *, s 63 int (*check_fb)(struct lcd_device *, struct fb_info *); 55 }; 64 }; 56 65 57 struct lcd_device { 66 struct lcd_device { 58 struct lcd_properties props; 67 struct lcd_properties props; 59 /* This protects the 'ops' field. If ' 68 /* This protects the 'ops' field. If 'ops' is NULL, the driver that 60 registered this device has been unl 69 registered this device has been unloaded, and if class_get_devdata() 61 points to something in the body of 70 points to something in the body of that driver, it is also invalid. */ 62 struct mutex ops_lock; 71 struct mutex ops_lock; 63 /* If this is NULL, the backing module 72 /* If this is NULL, the backing module is unloaded */ 64 const struct lcd_ops *ops; !! 73 struct lcd_ops *ops; 65 /* Serialise access to set_power metho 74 /* Serialise access to set_power method */ 66 struct mutex update_lock; 75 struct mutex update_lock; 67 /* The framebuffer notifier block */ 76 /* The framebuffer notifier block */ 68 struct notifier_block fb_notif; 77 struct notifier_block fb_notif; 69 78 70 struct device dev; 79 struct device dev; 71 }; 80 }; 72 81 73 struct lcd_platform_data { 82 struct lcd_platform_data { 74 /* reset lcd panel device. */ 83 /* reset lcd panel device. */ 75 int (*reset)(struct lcd_device *ld); 84 int (*reset)(struct lcd_device *ld); 76 /* on or off to lcd panel. if 'enable' 85 /* on or off to lcd panel. if 'enable' is 0 then 77 lcd power off and 1, lcd power on. 86 lcd power off and 1, lcd power on. */ 78 int (*power_on)(struct lcd_device *ld, 87 int (*power_on)(struct lcd_device *ld, int enable); 79 88 80 /* it indicates whether lcd panel was 89 /* it indicates whether lcd panel was enabled 81 from bootloader or not. */ 90 from bootloader or not. */ 82 int lcd_enabled; 91 int lcd_enabled; 83 /* it means delay for stable time when 92 /* it means delay for stable time when it becomes low to high 84 or high to low that is dependent on 93 or high to low that is dependent on whether reset gpio is 85 low active or high active. */ 94 low active or high active. */ 86 unsigned int reset_delay; 95 unsigned int reset_delay; 87 /* stable time needing to become lcd p 96 /* stable time needing to become lcd power on. */ 88 unsigned int power_on_delay; 97 unsigned int power_on_delay; 89 /* stable time needing to become lcd p 98 /* stable time needing to become lcd power off. */ 90 unsigned int power_off_delay; 99 unsigned int power_off_delay; 91 100 92 /* it could be used for any purpose. * 101 /* it could be used for any purpose. */ 93 void *pdata; 102 void *pdata; 94 }; 103 }; 95 104 96 static inline void lcd_set_power(struct lcd_de 105 static inline void lcd_set_power(struct lcd_device *ld, int power) 97 { 106 { 98 mutex_lock(&ld->update_lock); 107 mutex_lock(&ld->update_lock); 99 if (ld->ops && ld->ops->set_power) 108 if (ld->ops && ld->ops->set_power) 100 ld->ops->set_power(ld, power); 109 ld->ops->set_power(ld, power); 101 mutex_unlock(&ld->update_lock); 110 mutex_unlock(&ld->update_lock); 102 } 111 } 103 112 104 extern struct lcd_device *lcd_device_register( 113 extern struct lcd_device *lcd_device_register(const char *name, 105 struct device *parent, void *devdata, !! 114 struct device *parent, void *devdata, struct lcd_ops *ops); 106 extern struct lcd_device *devm_lcd_device_regi << 107 const char *name, struct device *paren << 108 void *devdata, const struct lcd_ops *o << 109 extern void lcd_device_unregister(struct lcd_d 115 extern void lcd_device_unregister(struct lcd_device *ld); 110 extern void devm_lcd_device_unregister(struct << 111 struct lcd_device *ld); << 112 116 113 #define to_lcd_device(obj) container_of(obj, s 117 #define to_lcd_device(obj) container_of(obj, struct lcd_device, dev) 114 118 115 static inline void * lcd_get_data(struct lcd_d 119 static inline void * lcd_get_data(struct lcd_device *ld_dev) 116 { 120 { 117 return dev_get_drvdata(&ld_dev->dev); 121 return dev_get_drvdata(&ld_dev->dev); 118 } 122 } 119 123 120 124 121 #endif 125 #endif 122 126
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.