From patchwork Thu Aug 4 14:22:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Michal_Mal=C3=BD?= X-Patchwork-Id: 1035852 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p74EMG5W006288 for ; Thu, 4 Aug 2011 14:22:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752910Ab1HDOWL (ORCPT ); Thu, 4 Aug 2011 10:22:11 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:48038 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312Ab1HDOWK convert rfc822-to-8bit (ORCPT ); Thu, 4 Aug 2011 10:22:10 -0400 Received: by fxh19 with SMTP id 19so1797491fxh.19 for ; Thu, 04 Aug 2011 07:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type; bh=uYKsDbaWlVzVJJKxXXuaE+wTgjGm5x3oKbna0LzERy0=; b=mK2dRHdHUMKOro/97MCFxR+VgUNLKB/mW4tP3Ej1QODpFuhtAAHCvtrQnWoc1SMG8Z cvp6W5rV+yxJ7ikL13ckiIo9lONnYBJrtB3YKWRSBW5ykQM1mEz0zGF3airJf7PbEbWc f4ArtgsXJJIpZCot+elvYgG+Uno6M0rakthrE= Received: by 10.223.144.136 with SMTP id z8mr1285753fau.31.1312467729405; Thu, 04 Aug 2011 07:22:09 -0700 (PDT) Received: from qosmio-x300.localnet (18.53.broadband14.iol.cz [90.181.53.18]) by mx.google.com with ESMTPS id 6sm171189fas.2.2011.08.04.07.22.08 (version=SSLv3 cipher=OTHER); Thu, 04 Aug 2011 07:22:08 -0700 (PDT) From: Michal =?ISO-8859-1?Q?Mal=FD?= To: jkosina@suse.cz Cc: linux-input@vger.kernel.org, simon@mungewell.org Subject: [v3 4/6] HID: lg4ff - Add autocentering command accepted by Formula Force EX Date: Thu, 04 Aug 2011 16:22:07 +0200 Message-ID: <5231358.6RSPfFRbu0@qosmio-x300> User-Agent: KMail/4.7.0 (Linux/3.0.0-ARCHMOD; KDE/4.7.0; x86_64; ; ) MIME-Version: 1.0 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.6 (demeter1.kernel.org [140.211.167.41]); Thu, 04 Aug 2011 14:22:16 +0000 (UTC) (Hopefully) fixed wordwrapping Signed-off-by: Michal MalĂ˝ --- -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 1ee78d3..1ca121e 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c @@ -157,7 +157,9 @@ static int hid_lg4ff_play(struct input_dev *dev, void *data, struct ff_effect *e return 0; } -static void hid_lg4ff_set_autocenter(struct input_dev *dev, u16 magnitude) +/* Sends default autocentering command compatible with + * all wheels except Formula Force EX */ +static void hid_lg4ff_set_autocenter_default(struct input_dev *dev, u16 magnitude) { struct hid_device *hid = input_get_drvdata(dev); struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; @@ -174,6 +176,26 @@ static void hid_lg4ff_set_autocenter(struct input_dev *dev, u16 magnitude) usbhid_submit_report(hid, report, USB_DIR_OUT); } +/* Sends autocentering command compatible with Formula Force EX */ +static void hid_lg4ff_set_autocenter_ffex(struct input_dev *dev, u16 magnitude) +{ + struct hid_device *hid = input_get_drvdata(dev); + struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; + struct hid_report *report = list_entry(report_list->next, struct hid_report, list); + magnitude = magnitude * 90 / 65535; + + + report->field[0]->value[0] = 0xfe; + report->field[0]->value[1] = 0x03; + report->field[0]->value[2] = magnitude >> 14; + report->field[0]->value[3] = magnitude >> 14; + report->field[0]->value[4] = magnitude; + report->field[0]->value[5] = 0x00; + report->field[0]->value[6] = 0x00; + + usbhid_submit_report(hid, report, USB_DIR_OUT); +} + /* Sends command to set range compatible with G25/G27/Driving Force GT */ static void hid_lg4ff_set_range_g25(struct hid_device *hid, u16 range) { @@ -390,8 +412,16 @@ int lg4ff_init(struct hid_device *hid) if (error) return error; - if (test_bit(FF_AUTOCENTER, dev->ffbit)) - dev->ff->set_autocenter = hid_lg4ff_set_autocenter; + /* Check if autocentering is available and + * set the centering force to zero by default */ + if (test_bit(FF_AUTOCENTER, dev->ffbit)) { + if(rev_maj == FFEX_REV_MAJ && rev_min == FFEX_REV_MIN) /* Formula Force EX expects different autocentering command */ + dev->ff->set_autocenter = hid_lg4ff_set_autocenter_ffex; + else + dev->ff->set_autocenter = hid_lg4ff_set_autocenter_default; + + dev->ff->set_autocenter(dev, 0); + } /* Initialize device_list if this is the first device to handle by lg4ff */ if (!list_inited) {