From patchwork Wed Apr 14 15:10:23 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 92434 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3EFBUcF004914 for ; Wed, 14 Apr 2010 15:11:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755911Ab0DNPLL (ORCPT ); Wed, 14 Apr 2010 11:11:11 -0400 Received: from cantor.suse.de ([195.135.220.2]:55840 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755201Ab0DNPLK (ORCPT ); Wed, 14 Apr 2010 11:11:10 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 2819893EE3; Wed, 14 Apr 2010 17:11:09 +0200 (CEST) From: Takashi Iwai To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Takashi Iwai Subject: [PATCH 2/2] input: Add LED support to Synaptics device Date: Wed, 14 Apr 2010 17:10:23 +0200 Message-Id: <1271257823-23566-3-git-send-email-tiwai@suse.de> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1271257823-23566-1-git-send-email-tiwai@suse.de> References: <1271257823-23566-1-git-send-email-tiwai@suse.de> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 14 Apr 2010 15:11:30 +0000 (UTC) diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 6a51542..ea874bd 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "psmouse.h" #include "synaptics.h" @@ -328,6 +329,37 @@ static void synaptics_pt_create(struct psmouse *psmouse) * Functions to interpret the absolute mode packets ****************************************************************************/ +static void synaptics_set_led(struct psmouse *psmouse, int on) +{ + unsigned char param[1]; + + if (psmouse_sliced_command(psmouse, on ? 0x88 : 0x10)) + return; + param[0] = 0x0a; + ps2_command(&psmouse->ps2dev, param, PSMOUSE_CMD_SETRATE); +} + +static void synaptics_led_work(struct work_struct *work) +{ + struct synaptics_data *priv = container_of(work, struct synaptics_data, led_work); + synaptics_set_led(priv->psmouse, priv->led_status); +} + +/* input event handler: changed by x11 synaptics driver */ +static int synaptics_led_event(struct input_dev *dev, unsigned int type, + unsigned int code, int value) +{ + struct synaptics_data *priv = dev->dev.platform_data; + + if (!priv) + return 0; + if (type == EV_LED && code == LED_MUTE) { + priv->led_status = !!value; + schedule_work(&priv->led_work); + } + return 0; +} + static void synaptics_check_clickpad(struct psmouse *psmouse) { struct synaptics_data *priv = psmouse->private; @@ -344,6 +376,12 @@ static void synaptics_check_clickpad(struct psmouse *psmouse) if (priv->clickpad) printk(KERN_INFO "Synaptics: Clickpad device detected: %d\n", priv->clickpad); + /* FIXME: this should be ncap[1] 0x20, but it's not really... */ + priv->has_led = 1; + if (priv->has_led) { + printk(KERN_INFO "Synaptics: support LED control\n"); + INIT_WORK(&priv->led_work, synaptics_led_work); + } } static void synaptics_parse_hw_state(unsigned char buf[], struct synaptics_data *priv, struct synaptics_hw_state *hw) @@ -623,10 +661,22 @@ static void set_input_params(struct input_dev *dev, struct synaptics_data *priv) __clear_bit(BTN_RIGHT, dev->keybit); /* only left-button */ __clear_bit(BTN_MIDDLE, dev->keybit); } + if (priv->has_led) { + __set_bit(EV_LED, dev->evbit); + __set_bit(LED_MUTE, dev->ledbit); + dev->event = synaptics_led_event; + dev->dev.platform_data = priv; + } } static void synaptics_disconnect(struct psmouse *psmouse) { + struct synaptics_data *priv = psmouse->private; + + if (priv->has_led) { + cancel_work_sync(&priv->led_work); + synaptics_set_led(psmouse, 0); + } synaptics_reset(psmouse); kfree(psmouse->private); psmouse->private = NULL; @@ -658,6 +708,9 @@ static int synaptics_reconnect(struct psmouse *psmouse) return -1; } + if (priv->has_led) + synaptics_set_led(psmouse, priv->led_status); + return 0; } @@ -713,6 +766,7 @@ int synaptics_init(struct psmouse *psmouse) if (!priv) return -1; + priv->psmouse = psmouse; psmouse_reset(psmouse); if (synaptics_query_hardware(psmouse)) { diff --git a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h index b824851..aeca6d2 100644 --- a/drivers/input/mouse/synaptics.h +++ b/drivers/input/mouse/synaptics.h @@ -107,6 +107,10 @@ struct synaptics_data { int scroll; unsigned char clickpad; + unsigned char has_led; + unsigned char led_status; + struct psmouse *psmouse; + struct work_struct led_work; }; void synaptics_module_init(void);