From patchwork Thu Dec 24 13:52:38 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Tolysz X-Patchwork-Id: 69723 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBODqiAP008492 for ; Thu, 24 Dec 2009 13:52:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750998AbZLXNwn (ORCPT ); Thu, 24 Dec 2009 08:52:43 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751498AbZLXNwn (ORCPT ); Thu, 24 Dec 2009 08:52:43 -0500 Received: from mail-ew0-f219.google.com ([209.85.219.219]:64533 "EHLO mail-ew0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750998AbZLXNwm (ORCPT ); Thu, 24 Dec 2009 08:52:42 -0500 Received: by ewy19 with SMTP id 19so7324710ewy.21 for ; Thu, 24 Dec 2009 05:52:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=DtjI3l/P2HDzS8KeSYtmSrxsm1o8B3GMbUJS/frGgpM=; b=kX4nVrv+MRTnYQE5zS5n4glaMKjUzMVAftD5lrn9OkNka2tM7yj6llTzfdXPsLAOQX ZECRn0gvda4UiwGNedXzDgc2KNUcIsej7pNNVpu3Exr9nUqjikGX3hEYQ6HFZEPAb7aQ jOT5h5qAQpTV8AiPNYzI9HlGmZ2qptuzFZE5E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=dct+CZrkQk28W9cftpEWDe34HSCY5EiwAuTmGkHXI+XIDlrsvJZ7W5i0Zu3FmA51ES nEAD8cWYkbUZJw2bLxB15KiInEfjQSQFqjPqZp6jwLARFDtmr8vHHoSfk2GBd8ln7tDq bLK4yUnlZaNDpj8/OwCVG+41/cpoL9gjQID9o= Received: by 10.213.72.207 with SMTP id n15mr12659559ebj.85.1261662761223; Thu, 24 Dec 2009 05:52:41 -0800 (PST) Received: from ?192.168.1.10? (cpc6-croy10-0-0-cust79.croy.cable.virginmedia.com [77.96.104.80]) by mx.google.com with ESMTPS id 16sm5821385ewy.6.2009.12.24.05.52.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 24 Dec 2009 05:52:39 -0800 (PST) Message-ID: <4B337226.6050509@gmail.com> Date: Thu, 24 Dec 2009 13:52:38 +0000 From: Marcin Tolysz User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) MIME-Version: 1.0 To: linux-input@vger.kernel.org CC: Jiri Kosina Subject: [RFC v2] [HID] allow using external Hid Descriptors. Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 80792d3..4ee4299 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -640,6 +641,10 @@ int hid_parse_report(struct hid_device *device, __u8 *start, struct hid_item item; __u8 *end; int ret; + const struct firmware *fw; + int fw_fail; + const char *file; + static int (*dispatch_type[])(struct hid_parser *parser, struct hid_item *item) = { hid_parser_main, @@ -650,10 +655,28 @@ int hid_parse_report(struct hid_device *device, __u8 *start, if (device->driver->report_fixup) device->driver->report_fixup(device, start, size); + /* Now try to load a hid descriptor from a file firmware + if succesful ignoring this fixup thing */ + file = kasprintf(GFP_KERNEL, "hid/%04X:%04X:%04X:%04X.bin", + device->bus, device->vendor, device->product, device->version); + + fw_fail = request_firmware(&fw, file, &device->dev); + + if (fw_fail) + pr_info("To relace HID descriptor place it in /lib/firmaware/%s\n", file); + else{ + start = fw->data; + size = fw->size; + pr_info("HID descriptor relaced with /lib/firmaware/%s\n", file); + } + kfree(file); device->rdesc = kmalloc(size, GFP_KERNEL); - if (device->rdesc == NULL) + if (device->rdesc == NULL) { + if (!fw_fail) + release_firmware(fw); return -ENOMEM; + } memcpy(device->rdesc, start, size); device->rsize = size; @@ -690,6 +713,8 @@ int hid_parse_report(struct hid_device *device, __u8 *start, dbg_hid("unbalanced delimiter at end of report description\n"); goto err; } + if (!fw_fail) + release_firmware(fw); vfree(parser); return 0; } @@ -697,6 +722,8 @@ int hid_parse_report(struct hid_device *device, __u8 *start, dbg_hid("item fetching failed at offset %d\n", (int)(end - start)); err: + if (!fw_fail) + release_firmware(fw); vfree(parser); return ret; }