From patchwork Mon Jul 18 19:54:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 987542 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6IJtHgW016149 for ; Mon, 18 Jul 2011 19:55:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753625Ab1GRTyy (ORCPT ); Mon, 18 Jul 2011 15:54:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33361 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751692Ab1GRTyw (ORCPT ); Mon, 18 Jul 2011 15:54:52 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6IJsqBe025561 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Jul 2011 15:54:52 -0400 Received: from xavier.bos.redhat.com (xavier.bos.redhat.com [10.16.16.50]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6IJsWQJ029395; Mon, 18 Jul 2011 15:54:51 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Cc: Jarod Wilson Subject: [PATCH v2 5/9] [media] mceusb: query device for firmware emulator version Date: Mon, 18 Jul 2011 15:54:25 -0400 Message-Id: <1311018869-22794-6-git-send-email-jarod@redhat.com> In-Reply-To: <1310681394-3530-1-git-send-email-jarod@redhat.com> References: <1310681394-3530-1-git-send-email-jarod@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 18 Jul 2011 19:55:18 +0000 (UTC) Supposedly, there are essentially three different classes of devices that are compatible with Microsoft's specs. First are the "legacy" devices, which are built using Microsoft-provided hardware specs and firmware. Second are "emulator" devices, which are built using custom hardware and firmware, written to emulate Microsoft's firmware. Third are "port" devices, which have their own device driver and firmware, which provides compatible data to higher levels of the stack. From what I can tell, things like nuvoton-cir and fintek-cir are essentially "port" devices -- their raw IR buffer format is very similar to that of the mceusb devices. Now, within the mceusb driver, we have three different "generations", which at first, seemed like maybe they mapped to emulator versions. Unfortuantely, every single device I have responds "illegal command" to the query to get firmware emulator version from the hardware, which means they're either all emulator version 1, or they're legacy devices, and our different "generations" aren't at all related here. Though in theory, its possible the gen1 devices are "legacy" devices and the rest are emulator v1. There are some useful features of the v2 interface I was hoping to play with, but alas... Signed-off-by: Jarod Wilson --- drivers/media/rc/mceusb.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index f1fc11d..fb2fa9d 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -438,12 +438,14 @@ struct mceusb_dev { enum mceusb_model_type model; bool need_reset; /* flag to issue a device resume cmd */ + u8 emver; /* emulator interface version */ }; /* MCE Device Command Strings, generally a port and command pair */ static char DEVICE_RESUME[] = {MCE_CMD_NULL, MCE_CMD_PORT_SYS, MCE_CMD_RESUME}; static char GET_REVISION[] = {MCE_CMD_PORT_SYS, MCE_CMD_G_REVISION}; +static char GET_EMVER[] = {MCE_CMD_PORT_SYS, MCE_CMD_GETEMVER}; static char GET_WAKEVERSION[] = {MCE_CMD_PORT_SYS, MCE_CMD_GETWAKEVERSION}; static char GET_UNKNOWN2[] = {MCE_CMD_PORT_IR, MCE_CMD_UNKNOWN2}; static char GET_CARRIER_FREQ[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRCFS}; @@ -915,6 +917,9 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index) break; /* 1-byte return value commands */ + case MCE_RSP_EQEMVER: + ir->emver = hi; + break; case MCE_RSP_EQIRTXPORTS: ir->tx_mask = hi; break; @@ -1037,6 +1042,13 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) usb_submit_urb(urb, GFP_ATOMIC); } +static void mceusb_get_emulator_version(struct mceusb_dev *ir) +{ + /* If we get no reply or an illegal command reply, its ver 1, says MS */ + ir->emver = 1; + mce_async_out(ir, GET_EMVER, sizeof(GET_EMVER)); +} + static void mceusb_gen1_init(struct mceusb_dev *ir) { int ret; @@ -1290,6 +1302,9 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, mce_dbg(&intf->dev, "Flushing receive buffers\n"); mce_flush_rx_buffer(ir, maxp); + /* figure out which firmware/emulator version this hardware has */ + mceusb_get_emulator_version(ir); + /* initialize device */ if (ir->flags.microsoft_gen1) mceusb_gen1_init(ir); @@ -1307,8 +1322,8 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, device_set_wakeup_capable(ir->dev, true); device_set_wakeup_enable(ir->dev, true); - dev_info(&intf->dev, "Registered %s on usb%d:%d\n", name, - dev->bus->busnum, dev->devnum); + dev_info(&intf->dev, "Registered %s with mce emulator interface " + "version %x\n", name, ir->emver); return 0;