/* This is obsolete/useless. We now support variable maximum brightness. */ enum led_brightness {
LED_OFF = 0,
LED_ON = 1,
LED_HALF = 127,
LED_FULL = 255,
};
/** * struct led_lookup_data - represents a single LED lookup entry * * @list: internal list of all LED lookup entries * @provider: name of led_classdev providing the LED * @dev_id: name of the device associated with this LED * @con_id: name of the LED from the device's point of view
*/ struct led_lookup_data { struct list_head list; constchar *provider; constchar *dev_id; constchar *con_id;
};
struct led_init_data { /* device fwnode handle */ struct fwnode_handle *fwnode; /* * default <color:function> tuple, for backward compatibility * with in-driver hard-coded LED names used as a fallback when * DT "label" property is absent; it should be set to NULL * in new LED class drivers.
*/ constchar *default_label; /* * string to be used for devicename section of LED class device * either for label based LED name composition path or for fwnode * based when devname_mandatory is true
*/ constchar *devicename; /* * indicates if LED name should always comprise devicename section; * only LEDs exposed by drivers of hot-pluggable devices should * set it to true
*/ bool devname_mandatory;
};
#define LED_BLINK_SW 0 #define LED_BLINK_ONESHOT 1 #define LED_BLINK_ONESHOT_STOP 2 #define LED_BLINK_INVERT 3 #define LED_BLINK_BRIGHTNESS_CHANGE 4 #define LED_BLINK_DISABLE 5 /* Brightness off also disables hw-blinking so it is a separate action */ #define LED_SET_BRIGHTNESS_OFF 6 #define LED_SET_BRIGHTNESS 7 #define LED_SET_BLINK 8
/* Set LED brightness level * Must not sleep. Use brightness_set_blocking for drivers * that can sleep while setting brightness.
*/ void (*brightness_set)(struct led_classdev *led_cdev, enum led_brightness brightness); /* * Set LED brightness level immediately - it can block the caller for * the time required for accessing a LED device register.
*/ int (*brightness_set_blocking)(struct led_classdev *led_cdev, enum led_brightness brightness); /* Get LED brightness level */ enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
/* * Activate hardware accelerated blink, delays are in milliseconds * and if both are zero then a sensible default should be chosen. * The call should adjust the timings in that case and if it can't * match the values specified exactly. * Deactivate blinking again when the brightness is set to LED_OFF * via the brightness_set() callback. * For led_blink_set_nosleep() the LED core assumes that blink_set * implementations, of drivers which do not use brightness_set_blocking, * will not sleep. Therefor if brightness_set_blocking is not set * this function must not sleep!
*/ int (*blink_set)(struct led_classdev *led_cdev, unsignedlong *delay_on, unsignedlong *delay_off);
int (*pattern_set)(struct led_classdev *led_cdev, struct led_pattern *pattern, u32 len, int repeat); int (*pattern_clear)(struct led_classdev *led_cdev);
struct list_head node; /* LED Device list */ constchar *default_trigger; /* Trigger to use */
unsignedlong blink_delay_on, blink_delay_off; struct timer_list blink_timer; int blink_brightness; int new_blink_brightness; void (*flash_resume)(struct led_classdev *led_cdev);
struct workqueue_struct *wq; /* LED workqueue */ struct work_struct set_brightness_work; int delayed_set_value; unsignedlong delayed_delay_on; unsignedlong delayed_delay_off;
#ifdef CONFIG_LEDS_TRIGGERS /* Protects the trigger data below */ struct rw_semaphore trigger_lock;
struct led_trigger *trigger; struct list_head trig_list; void *trigger_data; /* true if activated - deactivate routine uses it to do cleanup */ bool activated;
/* LEDs that have private triggers have this set */ struct led_hw_trigger_type *trigger_type;
/* Unique trigger name supported by LED set in hw control mode */ constchar *hw_control_trigger; /* * Check if the LED driver supports the requested mode provided by the * defined supported trigger to setup the LED to hw control mode. * * Return 0 on success. Return -EOPNOTSUPP when the passed flags are not * supported and software fallback needs to be used. * Return a negative error number on any other case for check fail due * to various reason like device not ready or timeouts.
*/ int (*hw_control_is_supported)(struct led_classdev *led_cdev, unsignedlong flags); /* * Activate hardware control, LED driver will use the provided flags * from the supported trigger and setup the LED to be driven by hardware * following the requested mode from the trigger flags. * Deactivate hardware blink control by setting brightness to LED_OFF via * the brightness_set() callback. * * Return 0 on success, a negative error number on flags apply fail.
*/ int (*hw_control_set)(struct led_classdev *led_cdev, unsignedlong flags); /* * Get from the LED driver the current mode that the LED is set in hw * control mode and put them in flags. * Trigger can use this to get the initial state of a LED already set in * hardware blink control. * * Return 0 on success, a negative error number on failing parsing the * initial mode. Error from this function is NOT FATAL as the device * may be in a not supported initial state by the attached LED trigger.
*/ int (*hw_control_get)(struct led_classdev *led_cdev, unsignedlong *flags); /* * Get the device this LED blinks in response to. * e.g. for a PHY LED, it is the network device. If the LED is * not yet associated to a device, return NULL.
*/ struct device *(*hw_control_get_device)(struct led_classdev *led_cdev); #endif
#ifdef CONFIG_LEDS_BRIGHTNESS_HW_CHANGED int brightness_hw_changed; struct kernfs_node *brightness_hw_changed_kn; #endif
/* Ensures consistent access to the LED class device */ struct mutex led_access;
};
/** * led_classdev_register_ext - register a new object of LED class with * init data * @parent: LED controller device this LED is driven by * @led_cdev: the led_classdev structure for this device * @init_data: the LED class device initialization data * * Register a new object of LED class, with name derived from init_data. * * Returns: 0 on success or negative error value on failure
*/ int led_classdev_register_ext(struct device *parent, struct led_classdev *led_cdev, struct led_init_data *init_data);
/** * led_classdev_register - register a new object of LED class * @parent: LED controller device this LED is driven by * @led_cdev: the led_classdev structure for this device * * Register a new object of LED class, with name derived from the name property * of passed led_cdev argument. * * Returns: 0 on success or negative error value on failure
*/ staticinlineint led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
{ return led_classdev_register_ext(parent, led_cdev, NULL);
}
externvoid led_put(struct led_classdev *led_cdev); struct led_classdev *__must_check devm_of_led_get(struct device *dev, int index); struct led_classdev *__must_check devm_of_led_get_optional(struct device *dev, int index);
/** * led_blink_set - set blinking with software fallback * @led_cdev: the LED to start blinking * @delay_on: the time it should be on (in ms) * @delay_off: the time it should ble off (in ms) * * This function makes the LED blink, attempting to use the * hardware acceleration if possible, but falling back to * software blinking if there is no hardware blinking or if * the LED refuses the passed values. * * This function may sleep! * * Note that if software blinking is active, simply calling * led_cdev->brightness_set() will not stop the blinking, * use led_set_brightness() instead.
*/ void led_blink_set(struct led_classdev *led_cdev, unsignedlong *delay_on, unsignedlong *delay_off);
/** * led_blink_set_nosleep - set blinking, guaranteed to not sleep * @led_cdev: the LED to start blinking * @delay_on: the time it should be on (in ms) * @delay_off: the time it should ble off (in ms) * * This function makes the LED blink and is guaranteed to not sleep. Otherwise * this is the same as led_blink_set(), see led_blink_set() for details.
*/ void led_blink_set_nosleep(struct led_classdev *led_cdev, unsignedlong delay_on, unsignedlong delay_off);
/** * led_blink_set_oneshot - do a oneshot software blink * @led_cdev: the LED to start blinking * @delay_on: the time it should be on (in ms) * @delay_off: the time it should ble off (in ms) * @invert: blink off, then on, leaving the led on * * This function makes the LED blink one time for delay_on + * delay_off time, ignoring the request if another one-shot * blink is already in progress. * * If invert is set, led blinks for delay_off first, then for * delay_on and leave the led on after the on-off cycle. * * This function is guaranteed not to sleep.
*/ void led_blink_set_oneshot(struct led_classdev *led_cdev, unsignedlong *delay_on, unsignedlong *delay_off, int invert); /** * led_set_brightness - set LED brightness * @led_cdev: the LED to set * @brightness: the brightness to set it to * * Set an LED's brightness, and, if necessary, cancel the * software blink timer that implements blinking when the * hardware doesn't. This function is guaranteed not to sleep.
*/ void led_set_brightness(struct led_classdev *led_cdev, unsignedint brightness);
/** * led_set_brightness_sync - set LED brightness synchronously * @led_cdev: the LED to set * @value: the brightness to set it to * * Set an LED's brightness immediately. This function will block * the caller for the time required for accessing device registers, * and it can sleep. * * Returns: 0 on success or negative error value on failure
*/ int led_set_brightness_sync(struct led_classdev *led_cdev, unsignedint value);
/** * led_mc_set_brightness - set mc LED color intensity values and brightness * @led_cdev: the LED to set * @intensity_value: array of per color intensity values to set * @num_colors: amount of entries in intensity_value array * @brightness: the brightness to set the LED to * * Set a multi-color LED's per color intensity values and brightness. * If necessary, this cancels the software blink timer. This function is * guaranteed not to sleep. * * Calling this function on a non multi-color led_classdev or with the wrong * num_colors value is an error. In this case an error will be logged once * and the call will do nothing.
*/ void led_mc_set_brightness(struct led_classdev *led_cdev, unsignedint *intensity_value, unsignedint num_colors, unsignedint brightness);
/** * led_update_brightness - update LED brightness * @led_cdev: the LED to query * * Get an LED's current brightness and update led_cdev->brightness * member with the obtained value. * * Returns: 0 on success or negative error value on failure
*/ int led_update_brightness(struct led_classdev *led_cdev);
/** * led_get_default_pattern - return default pattern * * @led_cdev: the LED to get default pattern for * @size: pointer for storing the number of elements in returned array, * modified only if return != NULL * * Return: Allocated array of integers with default pattern from device tree * or NULL. Caller is responsible for kfree().
*/
u32 *led_get_default_pattern(struct led_classdev *led_cdev, unsignedint *size);
/** * led_sysfs_disable - disable LED sysfs interface * @led_cdev: the LED to set * * Disable the led_cdev's sysfs interface.
*/ void led_sysfs_disable(struct led_classdev *led_cdev);
/** * led_sysfs_enable - enable LED sysfs interface * @led_cdev: the LED to set * * Enable the led_cdev's sysfs interface.
*/ void led_sysfs_enable(struct led_classdev *led_cdev);
/** * led_compose_name - compose LED class device name * @dev: LED controller device object * @init_data: the LED class device initialization data * @led_classdev_name: composed LED class device name * * Create LED class device name basing on the provided init_data argument. * The name can have <devicename:color:function> or <color:function>. * form, depending on the init_data configuration. * * Returns: 0 on success or negative error value on failure
*/ int led_compose_name(struct device *dev, struct led_init_data *init_data, char *led_classdev_name);
/** * led_get_color_name - get string representation of color ID * @color_id: The LED_COLOR_ID_* constant * * Get the string name of a LED_COLOR_ID_* constant. * * Returns: A string constant or NULL on an invalid ID.
*/ constchar *led_get_color_name(u8 color_id);
/** * led_sysfs_is_disabled - check if LED sysfs interface is disabled * @led_cdev: the LED to query * * Returns: true if the led_cdev's sysfs interface is disabled.
*/ staticinlinebool led_sysfs_is_disabled(struct led_classdev *led_cdev)
{ return led_cdev->flags & LED_SYSFS_DISABLE;
}
/* Brightness set by led_trigger_event */ enum led_brightness brightness;
/* LED-private triggers have this set */ struct led_hw_trigger_type *trigger_type;
/* LEDs under control by this trigger (for simple triggers) */
spinlock_t leddev_list_lock; struct list_head led_cdevs;
/* Link to next registered trigger */ struct list_head next_trig;
conststruct attribute_group **groups;
};
/* * Currently the attributes in struct led_trigger::groups are added directly to * the LED device. As this might change in the future, the following * macros abstract getting the LED device and its trigger_data from the dev * parameter passed to the attribute accessor functions.
*/ #define led_trigger_get_led(dev) ((struct led_classdev *)dev_get_drvdata((dev))) #define led_trigger_get_drvdata(dev) (led_get_trigger_data(led_trigger_get_led(dev)))
/* Registration functions for complex triggers */ int led_trigger_register(struct led_trigger *trigger); void led_trigger_unregister(struct led_trigger *trigger); int devm_led_trigger_register(struct device *dev, struct led_trigger *trigger);
/* * Generic LED platform data for describing LED names and default triggers.
*/ struct led_info { constchar *name; constchar *default_trigger; int flags;
};
struct led_platform_data { int num_leds; struct led_info *leds;
};
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 ist noch experimentell.