From patchwork Mon Dec 10 16:56:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pandruvada, Srinivas" X-Patchwork-Id: 1858991 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 42F463FCA5 for ; Mon, 10 Dec 2012 16:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751156Ab2LJQ4k (ORCPT ); Mon, 10 Dec 2012 11:56:40 -0500 Received: from mga03.intel.com ([143.182.124.21]:10056 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093Ab2LJQ4j convert rfc822-to-8bit (ORCPT ); Mon, 10 Dec 2012 11:56:39 -0500 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga101.ch.intel.com with ESMTP; 10 Dec 2012 08:56:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,252,1355126400"; d="scan'208";a="178987277" Received: from orsmsx106.amr.corp.intel.com ([10.22.225.133]) by AZSMGA002.ch.intel.com with ESMTP; 10 Dec 2012 08:56:34 -0800 Received: from orsmsx153.amr.corp.intel.com (10.22.226.247) by ORSMSX106.amr.corp.intel.com (10.22.225.133) with Microsoft SMTP Server (TLS) id 14.1.355.2; Mon, 10 Dec 2012 08:56:33 -0800 Received: from orsmsx108.amr.corp.intel.com ([169.254.9.188]) by ORSMSX153.amr.corp.intel.com ([169.254.13.66]) with mapi id 14.01.0355.002; Mon, 10 Dec 2012 08:56:29 -0800 From: "Pandruvada, Srinivas" To: Matteo DAMENO CC: "linux-input@vger.kernel.org" , "linux-iio@vger.kernel.org" , Alexander Holler Subject: RE: [PATCH 1/2] HID: autodetect USB HID sensor hubs. Thread-Topic: [PATCH 1/2] HID: autodetect USB HID sensor hubs. Thread-Index: AQHN1gKfkb8VlU9j8UWbPrSMdnjvHpgSQj/A Date: Mon, 10 Dec 2012 16:56:33 +0000 Message-ID: <4FA419E87744DF4DAECD5BCE1214B7A91C960695@ORSMSX108.amr.corp.intel.com> References: <50C47811.7010503@ahsoftware.de> <1355053470-3939-1-git-send-email-holler@ahsoftware.de> In-Reply-To: <1355053470-3939-1-git-send-email-holler@ahsoftware.de> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Hi Mateo, Can you give a try with these patches and make sure that it doesn't break functionality with STM sensor hub? Thanks, Srinivas -----Original Message----- From: Alexander Holler [mailto:holler@ahsoftware.de] Sent: Sunday, December 09, 2012 3:45 AM To: linux-kernel@vger.kernel.org Cc: linux-input@vger.kernel.org; linux-iio@vger.kernel.org; Jonathan Cameron; Jiri Kosina; Pandruvada, Srinivas; Alexander Holler Subject: [PATCH 1/2] HID: autodetect USB HID sensor hubs. It should not be necessary to add IDs for HID sensor hubs to lists in hid-core.c and hid-sensor-hub.c. So instead of a whitelist, autodetect such USB HID sensor hubs, based on a collection of type physical inside a useage page of type sensor. If some sensor hubs stil must be usable as raw devices, a blacklist might be created. Signed-off-by: Alexander Holler --- drivers/hid/hid-core.c | 11 ++++++++++- drivers/hid/hid-sensor-hub.c | 32 +------------------------------- include/linux/hid-sensor-ids.h | 1 - include/linux/hid.h | 2 ++ 4 files changed, 13 insertions(+), 33 deletions(-) -- 1.7.8.6 -- 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-core.c b/drivers/hid/hid-core.c index f4109fd..7df5399 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -713,7 +713,12 @@ static int hid_scan_report(struct hid_device *hid) hid_scan_usage(hid, u); break; } - } + } else if (page == HID_UP_SENSOR && + item.type == HID_ITEM_TYPE_MAIN && + item.tag == HID_MAIN_ITEM_TAG_BEGIN_COLLECTION && + (item_udata(&item) & 0xff) == HID_COLLECTION_PHYSICAL && + hid->bus == BUS_USB) + hid->group = HID_GROUP_SENSOR_HUB; } return 0; @@ -1465,6 +1470,10 @@ EXPORT_SYMBOL_GPL(hid_disconnect); * there is a proper autodetection and autoloading in place (based on presence * of HID_DG_CONTACTID), so those devices don't need to be added to this list, * as we are doing the right thing in hid_scan_usage(). + * + * Autodetection for (USB) HID sensor hubs exists too. If a collection + of type + * physical is found inside a usage page of type sensor, hid-sensor-hub + will be + * used as a driver. See hid_scan_report(). */ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index d9d73e9..ca88ddc 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -82,23 +82,6 @@ struct hid_sensor_hub_callbacks_list { void *priv; }; -static int sensor_hub_check_for_sensor_page(struct hid_device *hdev) -{ - int i; - int ret = -EINVAL; - - for (i = 0; i < hdev->maxcollection; i++) { - struct hid_collection *col = &hdev->collection[i]; - if (col->type == HID_COLLECTION_PHYSICAL && - (col->usage & HID_USAGE_PAGE) == HID_UP_SENSOR) { - ret = 0; - break; - } - } - - return ret; -} - static struct hid_report *sensor_hub_report(int id, struct hid_device *hdev, int dir) { @@ -524,10 +507,6 @@ static int sensor_hub_probe(struct hid_device *hdev, hid_err(hdev, "parse failed\n"); goto err_free; } - if (sensor_hub_check_for_sensor_page(hdev) < 0) { - hid_err(hdev, "sensor page not found\n"); - goto err_free; - } INIT_LIST_HEAD(&hdev->inputs); ret = hid_hw_start(hdev, 0); @@ -630,16 +609,7 @@ static void sensor_hub_remove(struct hid_device *hdev) } static const struct hid_device_id sensor_hub_devices[] = { - { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, - USB_DEVICE_ID_SENSOR_HUB_1020) }, - { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, - USB_DEVICE_ID_SENSOR_HUB_1020) }, - { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8086, - USB_DEVICE_ID_SENSOR_HUB_09FA) }, - { HID_USB_DEVICE(USB_VENDOR_ID_INTEL_8087, - USB_DEVICE_ID_SENSOR_HUB_09FA) }, - { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, - USB_DEVICE_ID_SENSOR_HUB_7014) }, + { HID_DEVICE(BUS_USB, HID_GROUP_SENSOR_HUB, HID_ANY_ID, HID_ANY_ID) }, { } }; MODULE_DEVICE_TABLE(hid, sensor_hub_devices); diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index ca8d7e9..55f2773 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h @@ -19,7 +19,6 @@ #ifndef _HID_SENSORS_IDS_H #define _HID_SENSORS_IDS_H -#define HID_UP_SENSOR 0x00200000 #define HID_MAX_PHY_DEVICES 0xFF /* Accel 3D (200073) */ diff --git a/include/linux/hid.h b/include/linux/hid.h index c076041..c5f6ec2 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -167,6 +167,7 @@ struct hid_item { #define HID_UP_MSVENDOR 0xff000000 #define HID_UP_CUSTOM 0x00ff0000 #define HID_UP_LOGIVENDOR 0xffbc0000 +#define HID_UP_SENSOR 0x00200000 #define HID_USAGE 0x0000ffff @@ -292,6 +293,7 @@ struct hid_item { */ #define HID_GROUP_GENERIC 0x0001 #define HID_GROUP_MULTITOUCH 0x0002 +#define HID_GROUP_SENSOR_HUB 0x0003 /* * This is the global environment of the parser. This information is