/** * DOC: overview * * The backlight core supports implementing backlight drivers. * * A backlight driver registers a driver using * devm_backlight_device_register(). The properties of the backlight * driver such as type and max_brightness must be specified. * When the core detect changes in for example brightness or power state * the update_status() operation is called. The backlight driver shall * implement this operation and use it to adjust backlight. * * Several sysfs attributes are provided by the backlight core:: * * - brightness R/W, set the requested brightness level * - actual_brightness RO, the brightness level used by the HW * - max_brightness RO, the maximum brightness level supported * * See Documentation/ABI/stable/sysfs-class-backlight for the full list. * * The backlight can be adjusted using the sysfs interface, and * the backlight driver may also support adjusting backlight using * a hot-key or some other platform or firmware specific way. * * The driver must implement the get_brightness() operation if * the HW do not support all the levels that can be specified in * brightness, thus providing user-space access to the actual level * via the actual_brightness attribute. * * When the backlight changes this is reported to user-space using * an uevent connected to the actual_brightness attribute. * When brightness is set by platform specific means, for example * a hot-key to adjust backlight, the driver must notify the backlight * core that brightness has changed using backlight_force_update(). * * Display drives can control the backlight device's status using * backlight_notify_blank() and backlight_notify_blank_all(). If this * results in a change in the backlight state the functions call the * update_status() operation.
*/
/** * backlight_force_update - tell the backlight subsystem that hardware state * has changed * @bd: the backlight device to update * @reason: reason for update * * Updates the internal state of the backlight in response to a hardware event, * and generates an uevent to notify userspace. A backlight driver shall call * backlight_force_update() when the backlight is changed using, for example, * a hot-key. The updated brightness is read using get_brightness() and the * brightness value is reported using an uevent.
*/ void backlight_force_update(struct backlight_device *bd, enum backlight_update_reason reason)
{ int brightness;
mutex_lock(&bd->ops_lock); if (bd->ops && bd->ops->get_brightness) {
brightness = bd->ops->get_brightness(bd); if (brightness >= 0)
bd->props.brightness = brightness; else
dev_err(&bd->dev, "Could not update brightness from device: %pe\n",
ERR_PTR(brightness));
}
mutex_unlock(&bd->ops_lock);
backlight_generate_event(bd, reason);
}
EXPORT_SYMBOL(backlight_force_update);
/** backlight_device_get_by_type - find first backlight device of a type * @type: the type of backlight device * * Look up the first backlight device of the specified type * * RETURNS: * * Pointer to backlight device if any was found. Otherwise NULL.
*/ struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
{ bool found = false; struct backlight_device *bd;
mutex_lock(&backlight_dev_list_mutex);
list_for_each_entry(bd, &backlight_dev_list, entry) { if (bd->props.type == type) {
found = true; break;
}
}
mutex_unlock(&backlight_dev_list_mutex);
return found ? bd : NULL;
}
EXPORT_SYMBOL(backlight_device_get_by_type);
/** * backlight_device_get_by_name - Get backlight device by name * @name: Device name * * This function looks up a backlight device by its name. It obtains a reference * on the backlight device and it is the caller's responsibility to drop the * reference by calling put_device(). * * Returns: * A pointer to the backlight device if found, otherwise NULL.
*/ struct backlight_device *backlight_device_get_by_name(constchar *name)
{ struct device *dev;
dev = class_find_device_by_name(&backlight_class, name);
return dev ? to_backlight_device(dev) : NULL;
}
EXPORT_SYMBOL(backlight_device_get_by_name);
/* deprecated - use devm_backlight_device_unregister() */ void backlight_device_unregister(struct backlight_device *bd)
{ if (!bd) return;
/** * devm_backlight_device_register - register a new backlight device * @dev: the device to register * @name: the name of the device * @parent: a pointer to the parent device (often the same as @dev) * @devdata: an optional pointer to be stored for private driver use * @ops: the backlight operations structure * @props: the backlight properties * * Creates and registers new backlight device. When a backlight device * is registered the configuration must be specified in the @props * parameter. See description of &backlight_properties. * * RETURNS: * * struct backlight on success, or an ERR_PTR on error
*/ struct backlight_device *devm_backlight_device_register(struct device *dev, constchar *name, struct device *parent, void *devdata, conststruct backlight_ops *ops, conststruct backlight_properties *props)
{ struct backlight_device **ptr, *backlight;
ptr = devres_alloc(devm_backlight_device_release, sizeof(*ptr),
GFP_KERNEL); if (!ptr) return ERR_PTR(-ENOMEM);
/** * devm_backlight_device_unregister - unregister backlight device * @dev: the device to unregister * @bd: the backlight device to unregister * * Deallocates a backlight allocated with devm_backlight_device_register(). * Normally this function will not need to be called and the resource management * code will ensure that the resources are freed.
*/ void devm_backlight_device_unregister(struct device *dev, struct backlight_device *bd)
{ int rc;
/** * of_find_backlight_by_node() - find backlight device by device-tree node * @node: device-tree node of the backlight device * * Returns a pointer to the backlight device corresponding to the given DT * node or NULL if no such backlight device exists or if the device hasn't * been probed yet. * * This function obtains a reference on the backlight device and it is the * caller's responsibility to drop the reference by calling put_device() on * the backlight device's .dev field.
*/ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
{ struct device *dev;
dev = class_find_device(&backlight_class, NULL, node, of_parent_match);
return dev ? to_backlight_device(dev) : NULL;
}
EXPORT_SYMBOL(of_find_backlight_by_node); #endif
/** * devm_of_find_backlight - find backlight for a device * @dev: the device * * This function looks for a property named 'backlight' on the DT node * connected to @dev and looks up the backlight device. The lookup is * device managed so the reference to the backlight device is automatically * dropped on driver detach. * * 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 *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_or_reset(dev, devm_backlight_release, bd); if (ret) return ERR_PTR(ret);
/* * if this is compiled into the kernel, we need to ensure that the * class is registered before users of the class try to register lcd's
*/
postcore_initcall(backlight_class_init);
module_exit(backlight_class_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jamey Hicks , Andrew Zabolotny ");
MODULE_DESCRIPTION("Backlight Lowlevel Control Abstraction");
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.