1*4882a593Smuzhiyun============== 2*4882a593SmuzhiyunUserspace LEDs 3*4882a593Smuzhiyun============== 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunThe uleds driver supports userspace LEDs. This can be useful for testing 6*4882a593Smuzhiyuntriggers and can also be used to implement virtual LEDs. 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunUsage 10*4882a593Smuzhiyun===== 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunWhen the driver is loaded, a character device is created at /dev/uleds. To 13*4882a593Smuzhiyuncreate a new LED class device, open /dev/uleds and write a uleds_user_dev 14*4882a593Smuzhiyunstructure to it (found in kernel public header file linux/uleds.h):: 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #define LED_MAX_NAME_SIZE 64 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun struct uleds_user_dev { 19*4882a593Smuzhiyun char name[LED_MAX_NAME_SIZE]; 20*4882a593Smuzhiyun }; 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunA new LED class device will be created with the name given. The name can be 23*4882a593Smuzhiyunany valid sysfs device node name, but consider using the LED class naming 24*4882a593Smuzhiyunconvention of "devicename:color:function". 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunThe current brightness is found by reading a single byte from the character 27*4882a593Smuzhiyundevice. Values are unsigned: 0 to 255. Reading will block until the brightness 28*4882a593Smuzhiyunchanges. The device node can also be polled to notify when the brightness value 29*4882a593Smuzhiyunchanges. 30*4882a593Smuzhiyun 31*4882a593SmuzhiyunThe LED class device will be removed when the open file handle to /dev/uleds 32*4882a593Smuzhiyunis closed. 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunMultiple LED class devices are created by opening additional file handles to 35*4882a593Smuzhiyun/dev/uleds. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunSee tools/leds/uledmon.c for an example userspace program. 38