diff options
author | Rui Miguel Silva <rui.silva@linaro.org> | 2015-08-14 13:58:19 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2015-08-14 14:47:07 -0700 |
commit | 2870b52bae4c81823ffcb3ed2b0626fb39d64f48 (patch) | |
tree | c49f4e2bf727dc76a4b71a23b1894ff14f648a5c /drivers/staging/greybus/kernel_ver.h | |
parent | 13fcfbb6c5bbd7aee7e9980313dc29469357c5cd (diff) |
greybus: lights: add lights implementation
This patch adds lights implementation for Greybus Lights class, it
allows multiplexing of lights devices using the same connection. Also
adds two sysfs entries to led class (color, fade) which are commonly
used in several existing LED devices.
It support 2 major class of devices (normal LED and flash type), for
the first it registers to led_classdev, for the latest it registers in
the led_classdev_flash and v4l2_flash, depending on the support of the
kernel version.
Each Module can have N light devices attach and each light can have
multiple channel associated:
glights
|->light0
| |->channel0
| |->channel1
| | ....
| |->channeln
|->...
|->lightn
|->channel0
|->channel1
| ....
|->channeln
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/kernel_ver.h')
-rw-r--r-- | drivers/staging/greybus/kernel_ver.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/staging/greybus/kernel_ver.h b/drivers/staging/greybus/kernel_ver.h index d0e05e656475..f3cb1895c092 100644 --- a/drivers/staging/greybus/kernel_ver.h +++ b/drivers/staging/greybus/kernel_ver.h @@ -248,4 +248,45 @@ static inline size_t sg_pcopy_from_buffer(struct scatterlist *sgl, list_entry((ptr)->prev, type, member) #endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0) +/* + * Before this version the led classdev did not support groups + */ +#define LED_HAVE_GROUPS +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0) +/* + * At this time the internal API for the set brightness was changed to the async + * version, and one sync API was added to handle cases that need immediate + * effect. Also, the led class flash and lock for sysfs access was introduced. + */ +#define LED_HAVE_SET_SYNC +#define LED_HAVE_FLASH +#define LED_HAVE_LOCK +#include <linux/led-class-flash.h> +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) +/* + * From this version upper it was introduced the possibility to disable led + * sysfs entries to handle control of the led device to v4l2, which was + * implemented later. So, before that this should return false. + */ +#include <linux/leds.h> +static inline bool led_sysfs_is_disabled(struct led_classdev *led_cdev) +{ + return false; +} +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0) +/* + * New helper functions for registering/unregistering flash led devices as v4l2 + * subdevices were added. + */ +#define V4L2_HAVE_FLASH +#include <media/v4l2-flash-led-class.h> +#endif + #endif /* __GREYBUS_KERNEL_VER_H */ |