summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-sony.c
diff options
context:
space:
mode:
authorFrank Praznik <frank.praznik@oh.rr.com>2014-01-20 12:27:02 -0500
committerJiri Kosina <jkosina@suse.cz>2014-01-21 07:59:17 +0100
commit61ebca937f2609e66fe6749f8f5df57ff387e2eb (patch)
tree4c5f008608a12ef1d11c704e1cb4f3fcc797378a /drivers/hid/hid-sony.c
parent58d7027b7f92b1c4d883126a54782c656a76cafd (diff)
downloadtalos-obmc-linux-61ebca937f2609e66fe6749f8f5df57ff387e2eb.tar.gz
talos-obmc-linux-61ebca937f2609e66fe6749f8f5df57ff387e2eb.zip
HID: sony: Use colors for the Dualshock 4 LED names
Use the naming scheme 'devicename:colour' for the Dualshock 4 LED lightbar controls as specified in Documentation/leds/leds-class.txt Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-sony.c')
-rw-r--r--drivers/hid/hid-sony.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 62765c76c56a..12354055d474 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -834,33 +834,39 @@ static int sony_leds_init(struct hid_device *hdev)
struct sony_sc *drv_data;
int n, ret = 0;
int max_brightness;
+ int use_colors;
struct led_classdev *led;
size_t name_sz;
char *name;
size_t name_len;
const char *name_fmt;
+ static const char * const color_str[] = { "red", "green", "blue" };
static const __u8 initial_values[MAX_LEDS] = { 0x00, 0x00, 0x00, 0x00 };
drv_data = hid_get_drvdata(hdev);
BUG_ON(!(drv_data->quirks & SONY_LED_SUPPORT));
if (drv_data->quirks & BUZZ_CONTROLLER) {
+ drv_data->led_count = 4;
+ max_brightness = 1;
+ use_colors = 0;
name_len = strlen("::buzz#");
name_fmt = "%s::buzz%d";
/* Validate expected report characteristics. */
if (!hid_validate_values(hdev, HID_OUTPUT_REPORT, 0, 0, 7))
return -ENODEV;
- } else {
- name_len = strlen("::sony#");
- name_fmt = "%s::sony%d";
- }
-
- if (drv_data->quirks & DUALSHOCK4_CONTROLLER_USB) {
+ } else if (drv_data->quirks & DUALSHOCK4_CONTROLLER_USB) {
drv_data->led_count = 3;
max_brightness = 255;
+ use_colors = 1;
+ name_len = 0;
+ name_fmt = "%s:%s";
} else {
drv_data->led_count = 4;
max_brightness = 1;
+ use_colors = 0;
+ name_len = strlen("::sony#");
+ name_fmt = "%s::sony%d";
}
/* Clear LEDs as we have no way of reading their initial state. This is
@@ -871,6 +877,10 @@ static int sony_leds_init(struct hid_device *hdev)
name_sz = strlen(dev_name(&hdev->dev)) + name_len + 1;
for (n = 0; n < drv_data->led_count; n++) {
+
+ if (use_colors)
+ name_sz = strlen(dev_name(&hdev->dev)) + strlen(color_str[n]) + 2;
+
led = kzalloc(sizeof(struct led_classdev) + name_sz, GFP_KERNEL);
if (!led) {
hid_err(hdev, "Couldn't allocate memory for LED %d\n", n);
@@ -879,7 +889,10 @@ static int sony_leds_init(struct hid_device *hdev)
}
name = (void *)(&led[1]);
- snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1);
+ if (use_colors)
+ snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), color_str[n]);
+ else
+ snprintf(name, name_sz, name_fmt, dev_name(&hdev->dev), n + 1);
led->name = name;
led->brightness = 0;
led->max_brightness = max_brightness;
OpenPOWER on IntegriCloud