mirror of https://gitee.com/openkylin/linux.git
This contains the backlight portion of Meghana Madhyastha's patch set to
migrate the backlight helpers from tinydrm to the backlight subsystem. https://patchwork.freedesktop.org/series/36522/ Cc: Meghana Madhyastha <meghana.madhyastha@gmail.com> -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEfxcpfMSgdnQMs+QqlvcN/ahKBwoFAlpvdTQACgkQlvcN/ahK Bwp5Pgf8Cfn7p7/HV5npF0b0NZ3w0FLF+AjggxKdKBNsVYdO1qGrhfQJviuMRj7c cqm+SQ4OFJEwGMqVGsZLgRkyVrbCma/OZEcipJiSGHLG9owDgVFYTQ4bnakmdt1m QYJTETNxoNJ1EHCG1tfr9/jDR3GPL3OnSUOWnlTXDzpJ2PCw4BB0uArqG+pgmyhJ DCMdvYkQ+5tYB814otnN3zklklQITNGww8LTJMtDFyJVIz2RZHioq5JqXD48UfMb haDVbiYsOamw+eP4z5uyfCi1rKwzpPhas9IpeDn5gY6rEp/t+GTkSr0JHUEs/iB+ +eAH076eTp3M8iv7YF67XYLZQeDuwQ== =azAl -----END PGP SIGNATURE----- Merge tag 'topic/backlight_for_lag-2018-01-29' of git://anongit.freedesktop.org/drm/drm-misc into drm-misc-next This contains the backlight portion of Meghana Madhyastha's patch set to migrate the backlight helpers from tinydrm to the backlight subsystem. https://patchwork.freedesktop.org/series/36522/ Cc: Meghana Madhyastha <meghana.madhyastha@gmail.com> Signed-off-by: Sean Paul <seanpaul@chromium.org> # gpg: Signature made Mon 29 Jan 2018 02:25:40 PM EST # gpg: using RSA key 7F17297CC4A076740CB3E42A96F70DFDA84A070A # gpg: Good signature from "Sean Paul <seanpaul@chromium.org>" [unknown] # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 1C5E AB9E D7C9 DDE9 E7F2 087C 732C 0025 72DC AF79 # Subkey fingerprint: 7F17 297C C4A0 7674 0CB3 E42A 96F7 0DFD A84A 070A Link: https://patchwork.freedesktop.org/patch/msgid/20180129192950.bvmhkz3h42t5a25r@art_vandelay
This commit is contained in:
commit
f5155876af
|
@ -580,6 +580,79 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
|
|||
EXPORT_SYMBOL(of_find_backlight_by_node);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* of_find_backlight - Get backlight device
|
||||
* @dev: Device
|
||||
*
|
||||
* This function looks for a property named 'backlight' on the DT node
|
||||
* connected to @dev and looks up the backlight device.
|
||||
*
|
||||
* Call backlight_put() to drop the reference on the backlight device.
|
||||
*
|
||||
* Returns:
|
||||
* A pointer to the backlight device if found.
|
||||
* Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
|
||||
* device is found.
|
||||
* NULL if there's no backlight property.
|
||||
*/
|
||||
struct backlight_device *of_find_backlight(struct device *dev)
|
||||
{
|
||||
struct backlight_device *bd = NULL;
|
||||
struct device_node *np;
|
||||
|
||||
if (!dev)
|
||||
return NULL;
|
||||
|
||||
if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
|
||||
np = of_parse_phandle(dev->of_node, "backlight", 0);
|
||||
if (np) {
|
||||
bd = of_find_backlight_by_node(np);
|
||||
of_node_put(np);
|
||||
if (!bd)
|
||||
return ERR_PTR(-EPROBE_DEFER);
|
||||
/*
|
||||
* Note: gpio_backlight uses brightness as
|
||||
* power state during probe
|
||||
*/
|
||||
if (!bd->props.brightness)
|
||||
bd->props.brightness = bd->props.max_brightness;
|
||||
}
|
||||
}
|
||||
|
||||
return bd;
|
||||
}
|
||||
EXPORT_SYMBOL(of_find_backlight);
|
||||
|
||||
static void devm_backlight_release(void *data)
|
||||
{
|
||||
backlight_put(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* devm_of_find_backlight - Resource-managed of_find_backlight()
|
||||
* @dev: Device
|
||||
*
|
||||
* Device managed version of of_find_backlight().
|
||||
* The reference on the backlight device is automatically
|
||||
* dropped on driver detach.
|
||||
*/
|
||||
struct backlight_device *devm_of_find_backlight(struct device *dev)
|
||||
{
|
||||
struct backlight_device *bd;
|
||||
int ret;
|
||||
|
||||
bd = of_find_backlight(dev);
|
||||
if (IS_ERR_OR_NULL(bd))
|
||||
return bd;
|
||||
ret = devm_add_action(dev, devm_backlight_release, bd);
|
||||
if (ret) {
|
||||
backlight_put(bd);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
return bd;
|
||||
}
|
||||
EXPORT_SYMBOL(devm_of_find_backlight);
|
||||
|
||||
static void __exit backlight_class_exit(void)
|
||||
{
|
||||
class_destroy(backlight_class);
|
||||
|
|
|
@ -130,6 +130,48 @@ static inline int backlight_update_status(struct backlight_device *bd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* backlight_enable - Enable backlight
|
||||
* @bd: the backlight device to enable
|
||||
*/
|
||||
static inline int backlight_enable(struct backlight_device *bd)
|
||||
{
|
||||
if (!bd)
|
||||
return 0;
|
||||
|
||||
bd->props.power = FB_BLANK_UNBLANK;
|
||||
bd->props.fb_blank = FB_BLANK_UNBLANK;
|
||||
bd->props.state &= ~BL_CORE_FBBLANK;
|
||||
|
||||
return backlight_update_status(bd);
|
||||
}
|
||||
|
||||
/**
|
||||
* backlight_disable - Disable backlight
|
||||
* @bd: the backlight device to disable
|
||||
*/
|
||||
static inline int backlight_disable(struct backlight_device *bd)
|
||||
{
|
||||
if (!bd)
|
||||
return 0;
|
||||
|
||||
bd->props.power = FB_BLANK_POWERDOWN;
|
||||
bd->props.fb_blank = FB_BLANK_POWERDOWN;
|
||||
bd->props.state |= BL_CORE_FBBLANK;
|
||||
|
||||
return backlight_update_status(bd);
|
||||
}
|
||||
|
||||
/**
|
||||
* backlight_put - Drop backlight reference
|
||||
* @bd: the backlight device to put
|
||||
*/
|
||||
static inline void backlight_put(struct backlight_device *bd)
|
||||
{
|
||||
if (bd)
|
||||
put_device(&bd->dev);
|
||||
}
|
||||
|
||||
extern struct backlight_device *backlight_device_register(const char *name,
|
||||
struct device *dev, void *devdata, const struct backlight_ops *ops,
|
||||
const struct backlight_properties *props);
|
||||
|
@ -173,4 +215,20 @@ of_find_backlight_by_node(struct device_node *node)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
|
||||
struct backlight_device *of_find_backlight(struct device *dev);
|
||||
struct backlight_device *devm_of_find_backlight(struct device *dev);
|
||||
#else
|
||||
static inline struct backlight_device *of_find_backlight(struct device *dev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct backlight_device *
|
||||
devm_of_find_backlight(struct device *dev)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue