dm: backlight: add backlight_disable() interface

Change-Id: I3b3d1e961b31ac0d4e4bf4656da1ae063e3b5a72
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2017-10-30 17:44:02 +08:00
parent 282d550a61
commit 91d246a3ae
2 changed files with 26 additions and 0 deletions

View File

@ -19,6 +19,16 @@ int backlight_enable(struct udevice *dev)
return ops->enable(dev); return ops->enable(dev);
} }
int backlight_disable(struct udevice *dev)
{
const struct backlight_ops *ops = backlight_get_ops(dev);
if (!ops->disable)
return -ENOSYS;
return ops->disable(dev);
}
UCLASS_DRIVER(backlight) = { UCLASS_DRIVER(backlight) = {
.id = UCLASS_PANEL_BACKLIGHT, .id = UCLASS_PANEL_BACKLIGHT,
.name = "backlight", .name = "backlight",

View File

@ -16,6 +16,14 @@ struct backlight_ops {
* @return 0 if OK, -ve on error * @return 0 if OK, -ve on error
*/ */
int (*enable)(struct udevice *dev); int (*enable)(struct udevice *dev);
/**
* disable() - Disable a backlight
*
* @dev: Backlight device to disable
* @return 0 if OK, -ve on error
*/
int (*disable)(struct udevice *dev);
}; };
#define backlight_get_ops(dev) ((struct backlight_ops *)(dev)->driver->ops) #define backlight_get_ops(dev) ((struct backlight_ops *)(dev)->driver->ops)
@ -28,4 +36,12 @@ struct backlight_ops {
*/ */
int backlight_enable(struct udevice *dev); int backlight_enable(struct udevice *dev);
/**
* backlight_disable() - Disable a backlight
*
* @dev: Backlight device to disable
* @return 0 if OK, -ve on error
*/
int backlight_disable(struct udevice *dev);
#endif #endif