From patchwork Wed Sep 10 18:41:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 4879651 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 56781C0338 for ; Wed, 10 Sep 2014 18:42:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 66374201C8 for ; Wed, 10 Sep 2014 18:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B2AC20142 for ; Wed, 10 Sep 2014 18:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752668AbaIJSl6 (ORCPT ); Wed, 10 Sep 2014 14:41:58 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:51040 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752398AbaIJSl5 (ORCPT ); Wed, 10 Sep 2014 14:41:57 -0400 Received: by mail-pa0-f46.google.com with SMTP id kq14so5205323pab.19 for ; Wed, 10 Sep 2014 11:41:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=EFOGZBFLIBP1P8vwy7i02iaQyLJgzjiEaSfmIAFVm1s=; b=XjBcPUKLnU9QNMxubelgw0GKTA+Z5/R4+eiKm4/r7+uQVoh4IDL1yJGDDaPNtdmE74 7BZlTK0lxe2AOH+9L4lCCmR/HU7hPYhBVTYEfGxpAO9P/rWrdblfq6c55Vo1dyyufAZ4 odxsBQzjz1shZCy2aBFkvyuvLtZoKCY10LfyhQ+tiUsLUPpxGfl1WfG0pXz0flNN6jt+ S9j+jrf1sVmLc39dGl84CrQt7znTjCm0bPdM2pa4RsnkkA703zmoTaxlLoOFslPtFmvi 1kweCltK0aHEbvY5Pq4zQB37J5LeNuKaMi5I3SyqEwc11jKZkK2FKF5Tc2Es/vXdFpQC DGog== X-Received: by 10.68.194.194 with SMTP id hy2mr6284032pbc.149.1410374517411; Wed, 10 Sep 2014 11:41:57 -0700 (PDT) Received: from wacom-XPS-8500.wacom.com ([67.51.163.2]) by mx.google.com with ESMTPSA id c3sm9742581pdk.3.2014.09.10.11.41.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Sep 2014 11:41:56 -0700 (PDT) From: Ping Cheng X-Google-Original-From: Ping Cheng To: jkosina@suse.cz Cc: killertofu@gmail.com, linux-input@vger.kernel.org, Ping Cheng Subject: [PATCH 4/4] HID: wacom - enable LED support for Wireless Intuos5/Pro Date: Wed, 10 Sep 2014 11:41:48 -0700 Message-Id: <1410374508-25950-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.9.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP And associate all LED/OLED to PAD device Signed-off-by: Ping Cheng Tested-by: Benjamin Tissoires --- drivers/hid/wacom_sys.c | 52 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index f911f97..91fb3c3 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -17,6 +17,7 @@ #define WAC_MSG_RETRIES 5 +#define WAC_CMD_WL_LED_CONTROL 0x03 #define WAC_CMD_LED_CONTROL 0x20 #define WAC_CMD_ICON_START 0x21 #define WAC_CMD_ICON_XFER 0x23 @@ -490,8 +491,14 @@ static int wacom_led_control(struct wacom *wacom) { unsigned char *buf; int retval; + unsigned char report_id = WAC_CMD_LED_CONTROL; + int buf_size = 9; - buf = kzalloc(9, GFP_KERNEL); + if (wacom->wacom_wac.pid) { /* wireless connected */ + report_id = WAC_CMD_WL_LED_CONTROL; + buf_size = 13; + } + buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -505,9 +512,16 @@ static int wacom_led_control(struct wacom *wacom) int ring_led = wacom->led.select[0] & 0x03; int ring_lum = (((wacom->led.llv & 0x60) >> 5) - 1) & 0x03; int crop_lum = 0; - - buf[0] = WAC_CMD_LED_CONTROL; - buf[1] = (crop_lum << 4) | (ring_lum << 2) | (ring_led); + unsigned char led_bits = (crop_lum << 4) | (ring_lum << 2) | (ring_led); + + buf[0] = report_id; + if (wacom->wacom_wac.pid) { + wacom_get_report(wacom->hdev, HID_FEATURE_REPORT, + buf, buf_size, WAC_CMD_RETRIES); + buf[0] = report_id; + buf[4] = led_bits; + } else + buf[1] = led_bits; } else { int led = wacom->led.select[0] | 0x4; @@ -516,14 +530,14 @@ static int wacom_led_control(struct wacom *wacom) wacom->wacom_wac.features.type == WACOM_24HD) led |= (wacom->led.select[1] << 4) | 0x40; - buf[0] = WAC_CMD_LED_CONTROL; + buf[0] = report_id; buf[1] = led; buf[2] = wacom->led.llv; buf[3] = wacom->led.hlv; buf[4] = wacom->led.img_lum; } - retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, 9, + retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, buf, buf_size, WAC_CMD_RETRIES); kfree(buf); @@ -1036,6 +1050,7 @@ static void wacom_unregister_inputs(struct wacom *wacom) input_unregister_device(wacom->wacom_wac.pad_input); wacom->wacom_wac.input = NULL; wacom->wacom_wac.pad_input = NULL; + wacom_destroy_leds(wacom); } static int wacom_register_inputs(struct wacom *wacom) @@ -1073,10 +1088,17 @@ static int wacom_register_inputs(struct wacom *wacom) error = input_register_device(pad_input_dev); if (error) goto fail3; + + error = wacom_initialize_leds(wacom); + if (error) + goto fail4; } return 0; +fail4: + input_unregister_device(pad_input_dev); + pad_input_dev = NULL; fail3: input_unregister_device(input_dev); input_dev = NULL; @@ -1151,6 +1173,7 @@ static void wacom_wireless_work(struct work_struct *work) wacom_wac1->features.name); wacom_wac1->shared->touch_max = wacom_wac1->features.touch_max; wacom_wac1->shared->type = wacom_wac1->features.type; + wacom_wac1->pid = wacom_wac->pid; error = wacom_register_inputs(wacom1); if (error) goto fail; @@ -1171,6 +1194,7 @@ static void wacom_wireless_work(struct work_struct *work) "%s (WL) Pad",wacom_wac2->features.name); snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", wacom_wac2->features.name); + wacom_wac2->pid = wacom_wac->pid; error = wacom_register_inputs(wacom2); if (error) goto fail; @@ -1353,21 +1377,17 @@ static int wacom_probe(struct hid_device *hdev, goto fail1; } - error = wacom_initialize_leds(wacom); - if (error) - goto fail2; - if (!(features->quirks & WACOM_QUIRK_MONITOR) && (features->quirks & WACOM_QUIRK_BATTERY)) { error = wacom_initialize_battery(wacom); if (error) - goto fail3; + goto fail2; } if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) { error = wacom_register_inputs(wacom); if (error) - goto fail4; + goto fail3; } if (hdev->bus == BUS_BLUETOOTH) { @@ -1385,7 +1405,7 @@ static int wacom_probe(struct hid_device *hdev, error = hid_hw_start(hdev, HID_CONNECT_HIDRAW); if (error) { hid_err(hdev, "hw start failed\n"); - goto fail5; + goto fail4; } if (features->quirks & WACOM_QUIRK_MONITOR) @@ -1398,11 +1418,10 @@ static int wacom_probe(struct hid_device *hdev, return 0; - fail5: if (hdev->bus == BUS_BLUETOOTH) + fail4: if (hdev->bus == BUS_BLUETOOTH) device_remove_file(&hdev->dev, &dev_attr_speed); wacom_unregister_inputs(wacom); - fail4: wacom_destroy_battery(wacom); - fail3: wacom_destroy_leds(wacom); + fail3: wacom_destroy_battery(wacom); fail2: wacom_remove_shared_data(wacom_wac); fail1: kfree(wacom); hid_set_drvdata(hdev, NULL); @@ -1420,7 +1439,6 @@ static void wacom_remove(struct hid_device *hdev) if (hdev->bus == BUS_BLUETOOTH) device_remove_file(&hdev->dev, &dev_attr_speed); wacom_destroy_battery(wacom); - wacom_destroy_leds(wacom); wacom_remove_shared_data(&wacom->wacom_wac); hid_set_drvdata(hdev, NULL);