summaryrefslogtreecommitdiffstats
path: root/include/led.h
blob: 0210897ff2beca9b10284f561a223f792057e1bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef __LED_H
#define __LED_H

#include <errno.h>

struct led {
	void (*set)(struct led *, unsigned int value);
	int max_value;
	char *name;
	int num;
	struct list_head list;
};

struct led *led_by_number(int no);
struct led *led_by_name(const char *name);
struct led *led_by_name_or_number(const char *str);

static inline int led_get_number(struct led *led)
{
	return led->num;
}

int led_set_num(int num, unsigned int value);
int led_set(struct led *led, unsigned int value);
int led_register(struct led *led);
void led_unregister(struct led *led);
void led_unregister(struct led *led);

/* gpio LED support */
struct gpio_led {
	int gpio;
	bool active_low;
	struct led led;
};

struct gpio_rgb_led {
	int gpio_r, gpio_g, gpio_b;
	bool active_low;
	struct led led;
};

#ifdef CONFIG_LED_GPIO
int led_gpio_register(struct gpio_led *led);
void led_gpio_unregister(struct gpio_led *led);
#else
static inline int led_gpio_register(struct gpio_led *led)
{
	return -ENOSYS;
}

static inline void led_gpio_unregister(struct gpio_led *led)
{
}
#endif

#ifdef CONFIG_LED_GPIO_RGB
int led_gpio_rgb_register(struct gpio_rgb_led *led);
void led_gpio_rgb_unregister(struct gpio_led *led);
#else
static inline int led_gpio_rgb_register(struct gpio_rgb_led *led)
{
	return -ENOSYS;
}

static inline void led_gpio_rgb_unregister(struct gpio_led *led)
{
}
#endif

#endif /* __LED_H */