2005-05-29 07:29:01 +00:00
|
|
|
/*
|
2005-04-16 22:20:36 +00:00
|
|
|
* USB ATI Remote support
|
|
|
|
*
|
2011-08-06 21:18:08 +00:00
|
|
|
* Copyright (c) 2011 Anssi Hannula <anssi.hannula@iki.fi>
|
2005-04-16 22:20:36 +00:00
|
|
|
* Version 2.2.0 Copyright (c) 2004 Torrey Hoffman <thoffman@arnor.net>
|
|
|
|
* Version 2.1.1 Copyright (c) 2002 Vladimir Dergachev
|
|
|
|
*
|
|
|
|
* This 2.2.0 version is a rewrite / cleanup of the 2.1.1 driver, including
|
2005-05-29 07:29:01 +00:00
|
|
|
* porting to the 2.6 kernel interfaces, along with other modification
|
2005-04-16 22:20:36 +00:00
|
|
|
* to better match the style of the existing usb/input drivers. However, the
|
|
|
|
* protocol and hardware handling is essentially unchanged from 2.1.1.
|
2005-05-29 07:29:01 +00:00
|
|
|
*
|
|
|
|
* The 2.1.1 driver was derived from the usbati_remote and usbkbd drivers by
|
2005-04-16 22:20:36 +00:00
|
|
|
* Vojtech Pavlik.
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
*
|
|
|
|
* Feb 2004: Torrey Hoffman <thoffman@arnor.net>
|
|
|
|
* Version 2.2.0
|
|
|
|
* Jun 2004: Torrey Hoffman <thoffman@arnor.net>
|
|
|
|
* Version 2.2.1
|
|
|
|
* Added key repeat support contributed by:
|
|
|
|
* Vincent Vanackere <vanackere@lif.univ-mrs.fr>
|
|
|
|
* Added support for the "Lola" remote contributed by:
|
|
|
|
* Seth Cohn <sethcohn@yahoo.com>
|
|
|
|
*
|
2005-05-29 07:29:01 +00:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2005-05-29 07:29:01 +00:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2005-04-16 22:20:36 +00:00
|
|
|
* (at your option) any later version.
|
2005-05-29 07:29:01 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2005-05-29 07:29:01 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2005-05-29 07:29:01 +00:00
|
|
|
*
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Hardware & software notes
|
|
|
|
*
|
2005-05-29 07:29:01 +00:00
|
|
|
* These remote controls are distributed by ATI as part of their
|
|
|
|
* "All-In-Wonder" video card packages. The receiver self-identifies as a
|
2005-04-16 22:20:36 +00:00
|
|
|
* "USB Receiver" with manufacturer "X10 Wireless Technology Inc".
|
|
|
|
*
|
2005-05-29 07:29:01 +00:00
|
|
|
* The "Lola" remote is available from X10. See:
|
2005-04-16 22:20:36 +00:00
|
|
|
* http://www.x10.com/products/lola_sg1.htm
|
|
|
|
* The Lola is similar to the ATI remote but has no mouse support, and slightly
|
|
|
|
* different keys.
|
|
|
|
*
|
2005-05-29 07:29:01 +00:00
|
|
|
* It is possible to use multiple receivers and remotes on multiple computers
|
2005-04-16 22:20:36 +00:00
|
|
|
* simultaneously by configuring them to use specific channels.
|
2005-05-29 07:29:01 +00:00
|
|
|
*
|
|
|
|
* The RF protocol used by the remote supports 16 distinct channels, 1 to 16.
|
|
|
|
* Actually, it may even support more, at least in some revisions of the
|
2005-04-16 22:20:36 +00:00
|
|
|
* hardware.
|
|
|
|
*
|
|
|
|
* Each remote can be configured to transmit on one channel as follows:
|
2005-05-29 07:29:01 +00:00
|
|
|
* - Press and hold the "hand icon" button.
|
|
|
|
* - When the red LED starts to blink, let go of the "hand icon" button.
|
|
|
|
* - When it stops blinking, input the channel code as two digits, from 01
|
2005-04-16 22:20:36 +00:00
|
|
|
* to 16, and press the hand icon again.
|
2005-05-29 07:29:01 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* The timing can be a little tricky. Try loading the module with debug=1
|
|
|
|
* to have the kernel print out messages about the remote control number
|
|
|
|
* and mask. Note: debugging prints remote numbers as zero-based hexadecimal.
|
|
|
|
*
|
|
|
|
* The driver has a "channel_mask" parameter. This bitmask specifies which
|
2005-05-29 07:29:01 +00:00
|
|
|
* channels will be ignored by the module. To mask out channels, just add
|
2005-04-16 22:20:36 +00:00
|
|
|
* all the 2^channel_number values together.
|
|
|
|
*
|
|
|
|
* For instance, set channel_mask = 2^4 = 16 (binary 10000) to make ati_remote
|
2005-05-29 07:29:01 +00:00
|
|
|
* ignore signals coming from remote controls transmitting on channel 4, but
|
2005-04-16 22:20:36 +00:00
|
|
|
* accept all other channels.
|
|
|
|
*
|
2005-05-29 07:29:01 +00:00
|
|
|
* Or, set channel_mask = 65533, (0xFFFD), and all channels except 1 will be
|
2005-04-16 22:20:36 +00:00
|
|
|
* ignored.
|
|
|
|
*
|
2005-05-29 07:29:01 +00:00
|
|
|
* The default is 0 (respond to all channels). Bit 0 and bits 17-32 of this
|
2005-04-16 22:20:36 +00:00
|
|
|
* parameter are unused.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/module.h>
|
2011-08-06 21:18:08 +00:00
|
|
|
#include <linux/mutex.h>
|
2006-06-13 17:04:34 +00:00
|
|
|
#include <linux/usb/input.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/wait.h>
|
2005-11-30 21:50:39 +00:00
|
|
|
#include <linux/jiffies.h>
|
2011-08-06 21:18:08 +00:00
|
|
|
#include <media/rc-core.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Module and Version Information, Module Parameters
|
|
|
|
*/
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2010-05-04 06:30:32 +00:00
|
|
|
#define ATI_REMOTE_VENDOR_ID 0x0bc7
|
|
|
|
#define LOLA_REMOTE_PRODUCT_ID 0x0002
|
|
|
|
#define LOLA2_REMOTE_PRODUCT_ID 0x0003
|
|
|
|
#define ATI_REMOTE_PRODUCT_ID 0x0004
|
|
|
|
#define NVIDIA_REMOTE_PRODUCT_ID 0x0005
|
|
|
|
#define MEDION_REMOTE_PRODUCT_ID 0x0006
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-08-06 21:18:07 +00:00
|
|
|
#define DRIVER_VERSION "2.2.1"
|
2005-04-16 22:20:36 +00:00
|
|
|
#define DRIVER_AUTHOR "Torrey Hoffman <thoffman@arnor.net>"
|
|
|
|
#define DRIVER_DESC "ATI/X10 RF USB Remote Control"
|
|
|
|
|
|
|
|
#define NAME_BUFSIZE 80 /* size of product name, path buffers */
|
|
|
|
#define DATA_BUFSIZE 63 /* size of URB data buffers */
|
|
|
|
|
2006-08-05 02:53:02 +00:00
|
|
|
/*
|
|
|
|
* Duplicate event filtering time.
|
|
|
|
* Sequential, identical KIND_FILTERED inputs with less than
|
|
|
|
* FILTER_TIME milliseconds between them are considered as repeat
|
|
|
|
* events. The hardware generates 5 events for the first keypress
|
|
|
|
* and we have to take this into account for an accurate repeat
|
|
|
|
* behaviour.
|
|
|
|
*/
|
|
|
|
#define FILTER_TIME 60 /* msec */
|
2007-04-12 05:35:59 +00:00
|
|
|
#define REPEAT_DELAY 500 /* msec */
|
2006-08-05 02:53:02 +00:00
|
|
|
|
2005-05-29 07:29:38 +00:00
|
|
|
static unsigned long channel_mask;
|
2006-08-05 02:53:15 +00:00
|
|
|
module_param(channel_mask, ulong, 0644);
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore");
|
|
|
|
|
2005-05-29 07:29:38 +00:00
|
|
|
static int debug;
|
2006-08-05 02:53:15 +00:00
|
|
|
module_param(debug, int, 0644);
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
|
|
|
|
|
2006-08-05 02:53:02 +00:00
|
|
|
static int repeat_filter = FILTER_TIME;
|
|
|
|
module_param(repeat_filter, int, 0644);
|
|
|
|
MODULE_PARM_DESC(repeat_filter, "Repeat filter time, default = 60 msec");
|
|
|
|
|
2007-04-12 05:35:59 +00:00
|
|
|
static int repeat_delay = REPEAT_DELAY;
|
|
|
|
module_param(repeat_delay, int, 0644);
|
|
|
|
MODULE_PARM_DESC(repeat_delay, "Delay before sending repeats, default = 500 msec");
|
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
static bool mouse = true;
|
|
|
|
module_param(mouse, bool, 0444);
|
|
|
|
MODULE_PARM_DESC(mouse, "Enable mouse device, default = yes");
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define dbginfo(dev, format, arg...) do { if (debug) dev_info(dev , format , ## arg); } while (0)
|
|
|
|
#undef err
|
|
|
|
#define err(format, arg...) printk(KERN_ERR format , ## arg)
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct usb_device_id ati_remote_table[] = {
|
|
|
|
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID) },
|
2010-05-04 06:30:32 +00:00
|
|
|
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA2_REMOTE_PRODUCT_ID) },
|
|
|
|
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID) },
|
|
|
|
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, NVIDIA_REMOTE_PRODUCT_ID) },
|
2005-04-16 22:20:36 +00:00
|
|
|
{ USB_DEVICE(ATI_REMOTE_VENDOR_ID, MEDION_REMOTE_PRODUCT_ID) },
|
|
|
|
{} /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, ati_remote_table);
|
|
|
|
|
|
|
|
/* Get hi and low bytes of a 16-bits int */
|
|
|
|
#define HI(a) ((unsigned char)((a) >> 8))
|
|
|
|
#define LO(a) ((unsigned char)((a) & 0xff))
|
|
|
|
|
|
|
|
#define SEND_FLAG_IN_PROGRESS 1
|
|
|
|
#define SEND_FLAG_COMPLETE 2
|
|
|
|
|
|
|
|
/* Device initialization strings */
|
|
|
|
static char init1[] = { 0x01, 0x00, 0x20, 0x14 };
|
|
|
|
static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 };
|
|
|
|
|
|
|
|
struct ati_remote {
|
2005-09-15 07:01:47 +00:00
|
|
|
struct input_dev *idev;
|
2011-08-06 21:18:08 +00:00
|
|
|
struct rc_dev *rdev;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct usb_device *udev;
|
|
|
|
struct usb_interface *interface;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
struct urb *irq_urb;
|
|
|
|
struct urb *out_urb;
|
|
|
|
struct usb_endpoint_descriptor *endpoint_in;
|
|
|
|
struct usb_endpoint_descriptor *endpoint_out;
|
|
|
|
unsigned char *inbuf;
|
|
|
|
unsigned char *outbuf;
|
|
|
|
dma_addr_t inbuf_dma;
|
|
|
|
dma_addr_t outbuf_dma;
|
|
|
|
|
|
|
|
unsigned char old_data[2]; /* Detect duplicate events */
|
|
|
|
unsigned long old_jiffies;
|
|
|
|
unsigned long acc_jiffies; /* handle acceleration */
|
2007-04-12 05:35:59 +00:00
|
|
|
unsigned long first_jiffies;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned int repeat_count;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
char rc_name[NAME_BUFSIZE];
|
|
|
|
char rc_phys[NAME_BUFSIZE];
|
|
|
|
char mouse_name[NAME_BUFSIZE];
|
|
|
|
char mouse_phys[NAME_BUFSIZE];
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
wait_queue_head_t wait;
|
|
|
|
int send_flags;
|
2011-08-06 21:18:08 +00:00
|
|
|
|
|
|
|
int users; /* 0-2, users are rc and input */
|
|
|
|
struct mutex open_mutex;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* "Kinds" of messages sent from the hardware to the driver. */
|
|
|
|
#define KIND_END 0
|
|
|
|
#define KIND_LITERAL 1 /* Simply pass to input system */
|
|
|
|
#define KIND_FILTERED 2 /* Add artificial key-up events, drop keyrepeats */
|
|
|
|
#define KIND_LU 3 /* Directional keypad diagonals - left up, */
|
|
|
|
#define KIND_RU 4 /* right up, */
|
|
|
|
#define KIND_LD 5 /* left down, */
|
|
|
|
#define KIND_RD 6 /* right down */
|
|
|
|
#define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/
|
|
|
|
|
|
|
|
/* Translation table from hardware messages to input events. */
|
2005-11-29 08:43:42 +00:00
|
|
|
static const struct {
|
2005-04-16 22:20:36 +00:00
|
|
|
short kind;
|
|
|
|
unsigned char data1, data2;
|
|
|
|
int type;
|
|
|
|
unsigned int code;
|
|
|
|
int value;
|
2005-09-15 07:01:47 +00:00
|
|
|
} ati_remote_tbl[] = {
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Directional control pad axes */
|
|
|
|
{KIND_ACCEL, 0x35, 0x70, EV_REL, REL_X, -1}, /* left */
|
|
|
|
{KIND_ACCEL, 0x36, 0x71, EV_REL, REL_X, 1}, /* right */
|
|
|
|
{KIND_ACCEL, 0x37, 0x72, EV_REL, REL_Y, -1}, /* up */
|
|
|
|
{KIND_ACCEL, 0x38, 0x73, EV_REL, REL_Y, 1}, /* down */
|
2005-05-29 07:29:01 +00:00
|
|
|
/* Directional control pad diagonals */
|
2005-04-16 22:20:36 +00:00
|
|
|
{KIND_LU, 0x39, 0x74, EV_REL, 0, 0}, /* left up */
|
|
|
|
{KIND_RU, 0x3a, 0x75, EV_REL, 0, 0}, /* right up */
|
|
|
|
{KIND_LD, 0x3c, 0x77, EV_REL, 0, 0}, /* left down */
|
|
|
|
{KIND_RD, 0x3b, 0x76, EV_REL, 0, 0}, /* right down */
|
|
|
|
|
|
|
|
/* "Mouse button" buttons */
|
|
|
|
{KIND_LITERAL, 0x3d, 0x78, EV_KEY, BTN_LEFT, 1}, /* left btn down */
|
|
|
|
{KIND_LITERAL, 0x3e, 0x79, EV_KEY, BTN_LEFT, 0}, /* left btn up */
|
|
|
|
{KIND_LITERAL, 0x41, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */
|
|
|
|
{KIND_LITERAL, 0x42, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */
|
|
|
|
|
2005-05-29 07:29:01 +00:00
|
|
|
/* Artificial "doubleclick" events are generated by the hardware.
|
2005-04-16 22:20:36 +00:00
|
|
|
* They are mapped to the "side" and "extra" mouse buttons here. */
|
|
|
|
{KIND_FILTERED, 0x3f, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */
|
|
|
|
{KIND_FILTERED, 0x43, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */
|
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
/* Non-mouse events are handled by rc-core */
|
2005-04-16 22:20:36 +00:00
|
|
|
{KIND_END, 0x00, 0x00, EV_MAX + 1, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Local function prototypes */
|
|
|
|
static int ati_remote_sendpacket (struct ati_remote *ati_remote, u16 cmd, unsigned char *data);
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void ati_remote_irq_out (struct urb *urb);
|
|
|
|
static void ati_remote_irq_in (struct urb *urb);
|
|
|
|
static void ati_remote_input_report (struct urb *urb);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int ati_remote_initialize (struct ati_remote *ati_remote);
|
|
|
|
static int ati_remote_probe (struct usb_interface *interface, const struct usb_device_id *id);
|
|
|
|
static void ati_remote_disconnect (struct usb_interface *interface);
|
|
|
|
|
|
|
|
/* usb specific object to register with the usb subsystem */
|
|
|
|
static struct usb_driver ati_remote_driver = {
|
|
|
|
.name = "ati_remote",
|
|
|
|
.probe = ati_remote_probe,
|
|
|
|
.disconnect = ati_remote_disconnect,
|
|
|
|
.id_table = ati_remote_table,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_dump_input
|
|
|
|
*/
|
2008-08-14 16:37:34 +00:00
|
|
|
static void ati_remote_dump(struct device *dev, unsigned char *data,
|
|
|
|
unsigned int len)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
if ((len == 1) && (data[0] != (unsigned char)0xff) && (data[0] != 0x00))
|
2008-08-14 16:37:34 +00:00
|
|
|
dev_warn(dev, "Weird byte 0x%02x\n", data[0]);
|
2005-04-16 22:20:36 +00:00
|
|
|
else if (len == 4)
|
2008-08-14 16:37:34 +00:00
|
|
|
dev_warn(dev, "Weird key %02x %02x %02x %02x\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
data[0], data[1], data[2], data[3]);
|
|
|
|
else
|
2008-08-14 16:37:34 +00:00
|
|
|
dev_warn(dev, "Weird data, len=%d %02x %02x %02x %02x %02x %02x ...\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
len, data[0], data[1], data[2], data[3], data[4], data[5]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_open
|
|
|
|
*/
|
2011-08-06 21:18:08 +00:00
|
|
|
static int ati_remote_open(struct ati_remote *ati_remote)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-08-06 21:18:08 +00:00
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote->open_mutex);
|
|
|
|
|
|
|
|
if (ati_remote->users++ != 0)
|
|
|
|
goto out; /* one was already active */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* On first open, submit the read urb which was set up previously. */
|
|
|
|
ati_remote->irq_urb->dev = ati_remote->udev;
|
|
|
|
if (usb_submit_urb(ati_remote->irq_urb, GFP_KERNEL)) {
|
2005-05-29 07:29:01 +00:00
|
|
|
dev_err(&ati_remote->interface->dev,
|
2008-05-05 15:36:18 +00:00
|
|
|
"%s: usb_submit_urb failed!\n", __func__);
|
2011-08-06 21:18:08 +00:00
|
|
|
err = -EIO;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
out: mutex_unlock(&ati_remote->open_mutex);
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_close
|
|
|
|
*/
|
2011-08-06 21:18:08 +00:00
|
|
|
static void ati_remote_close(struct ati_remote *ati_remote)
|
|
|
|
{
|
|
|
|
mutex_lock(&ati_remote->open_mutex);
|
|
|
|
if (--ati_remote->users == 0)
|
|
|
|
usb_kill_urb(ati_remote->irq_urb);
|
|
|
|
mutex_unlock(&ati_remote->open_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote_input_open(struct input_dev *inputdev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-04-12 05:34:39 +00:00
|
|
|
struct ati_remote *ati_remote = input_get_drvdata(inputdev);
|
2011-08-06 21:18:08 +00:00
|
|
|
return ati_remote_open(ati_remote);
|
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
static void ati_remote_input_close(struct input_dev *inputdev)
|
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = input_get_drvdata(inputdev);
|
|
|
|
ati_remote_close(ati_remote);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote_rc_open(struct rc_dev *rdev)
|
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = rdev->priv;
|
|
|
|
return ati_remote_open(ati_remote);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ati_remote_rc_close(struct rc_dev *rdev)
|
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = rdev->priv;
|
|
|
|
ati_remote_close(ati_remote);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_irq_out
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void ati_remote_irq_out(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = urb->context;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (urb->status) {
|
|
|
|
dev_dbg(&ati_remote->interface->dev, "%s: status %d\n",
|
2008-05-05 15:36:18 +00:00
|
|
|
__func__, urb->status);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
ati_remote->send_flags |= SEND_FLAG_COMPLETE;
|
|
|
|
wmb();
|
|
|
|
wake_up(&ati_remote->wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_sendpacket
|
2005-05-29 07:29:01 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Used to send device initialization strings
|
|
|
|
*/
|
|
|
|
static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd, unsigned char *data)
|
|
|
|
{
|
|
|
|
int retval = 0;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Set up out_urb */
|
|
|
|
memcpy(ati_remote->out_urb->transfer_buffer + 1, data, LO(cmd));
|
2005-05-29 07:29:01 +00:00
|
|
|
((char *) ati_remote->out_urb->transfer_buffer)[0] = HI(cmd);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
ati_remote->out_urb->transfer_buffer_length = LO(cmd) + 1;
|
|
|
|
ati_remote->out_urb->dev = ati_remote->udev;
|
|
|
|
ati_remote->send_flags = SEND_FLAG_IN_PROGRESS;
|
|
|
|
|
|
|
|
retval = usb_submit_urb(ati_remote->out_urb, GFP_ATOMIC);
|
|
|
|
if (retval) {
|
2005-05-29 07:29:01 +00:00
|
|
|
dev_dbg(&ati_remote->interface->dev,
|
2005-04-16 22:20:36 +00:00
|
|
|
"sendpacket: usb_submit_urb failed: %d\n", retval);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
wait_event_timeout(ati_remote->wait,
|
|
|
|
((ati_remote->out_urb->status != -EINPROGRESS) ||
|
2005-05-29 07:29:01 +00:00
|
|
|
(ati_remote->send_flags & SEND_FLAG_COMPLETE)),
|
2005-04-16 22:20:36 +00:00
|
|
|
HZ);
|
|
|
|
usb_kill_urb(ati_remote->out_urb);
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_event_lookup
|
|
|
|
*/
|
|
|
|
static int ati_remote_event_lookup(int rem, unsigned char d1, unsigned char d2)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) {
|
2005-05-29 07:29:01 +00:00
|
|
|
/*
|
|
|
|
* Decide if the table entry matches the remote input.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2011-08-06 21:18:08 +00:00
|
|
|
if (ati_remote_tbl[i].data1 == d1 &&
|
|
|
|
ati_remote_tbl[i].data2 == d2)
|
2005-04-16 22:20:36 +00:00
|
|
|
return i;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-08-05 02:53:37 +00:00
|
|
|
/*
|
|
|
|
* ati_remote_compute_accel
|
|
|
|
*
|
|
|
|
* Implements acceleration curve for directional control pad
|
|
|
|
* If elapsed time since last event is > 1/4 second, user "stopped",
|
|
|
|
* so reset acceleration. Otherwise, user is probably holding the control
|
|
|
|
* pad down, so we increase acceleration, ramping up over two seconds to
|
|
|
|
* a maximum speed.
|
|
|
|
*/
|
|
|
|
static int ati_remote_compute_accel(struct ati_remote *ati_remote)
|
|
|
|
{
|
|
|
|
static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
|
|
|
|
unsigned long now = jiffies;
|
|
|
|
int acc;
|
|
|
|
|
|
|
|
if (time_after(now, ati_remote->old_jiffies + msecs_to_jiffies(250))) {
|
|
|
|
acc = 1;
|
|
|
|
ati_remote->acc_jiffies = now;
|
|
|
|
}
|
|
|
|
else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(125)))
|
|
|
|
acc = accel[0];
|
|
|
|
else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(250)))
|
|
|
|
acc = accel[1];
|
|
|
|
else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(500)))
|
|
|
|
acc = accel[2];
|
|
|
|
else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1000)))
|
|
|
|
acc = accel[3];
|
|
|
|
else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(1500)))
|
|
|
|
acc = accel[4];
|
|
|
|
else if (time_before(now, ati_remote->acc_jiffies + msecs_to_jiffies(2000)))
|
|
|
|
acc = accel[5];
|
|
|
|
else
|
|
|
|
acc = accel[6];
|
|
|
|
|
|
|
|
return acc;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ati_remote_report_input
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void ati_remote_input_report(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = urb->context;
|
|
|
|
unsigned char *data= ati_remote->inbuf;
|
2005-09-15 07:01:47 +00:00
|
|
|
struct input_dev *dev = ati_remote->idev;
|
2011-08-06 21:18:08 +00:00
|
|
|
int index = -1;
|
|
|
|
int acc;
|
2005-04-16 22:20:36 +00:00
|
|
|
int remote_num;
|
2011-08-06 21:18:08 +00:00
|
|
|
unsigned char scancode[2];
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Deal with strange looking inputs */
|
2005-05-29 07:29:01 +00:00
|
|
|
if ( (urb->actual_length != 4) || (data[0] != 0x14) ||
|
2005-04-16 22:20:36 +00:00
|
|
|
((data[3] & 0x0f) != 0x00) ) {
|
2008-08-14 16:37:34 +00:00
|
|
|
ati_remote_dump(&urb->dev->dev, data, urb->actual_length);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Mask unwanted remote channels. */
|
|
|
|
/* note: remote_num is 0-based, channel 1 on remote == 0 here */
|
|
|
|
remote_num = (data[3] >> 4) & 0x0f;
|
2011-08-06 21:18:07 +00:00
|
|
|
if (channel_mask & (1 << (remote_num + 1))) {
|
2005-04-16 22:20:36 +00:00
|
|
|
dbginfo(&ati_remote->interface->dev,
|
|
|
|
"Masked input from channel 0x%02x: data %02x,%02x, mask= 0x%02lx\n",
|
|
|
|
remote_num, data[1], data[2], channel_mask);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
scancode[0] = (((data[1] - ((remote_num + 1) << 4)) & 0xf0) | (data[1] & 0x0f));
|
|
|
|
|
|
|
|
scancode[1] = data[2];
|
|
|
|
|
|
|
|
/* Look up event code index in mouse translation table. */
|
|
|
|
index = ati_remote_event_lookup(remote_num, scancode[0], scancode[1]);
|
|
|
|
|
|
|
|
if (index >= 0) {
|
|
|
|
dbginfo(&ati_remote->interface->dev,
|
|
|
|
"channel 0x%02x; mouse data %02x,%02x; index %d; keycode %d\n",
|
|
|
|
remote_num, data[1], data[2], index, ati_remote_tbl[index].code);
|
|
|
|
if (!dev)
|
|
|
|
return; /* no mouse device */
|
|
|
|
} else
|
|
|
|
dbginfo(&ati_remote->interface->dev,
|
|
|
|
"channel 0x%02x; key data %02x,%02x, scancode %02x,%02x\n",
|
|
|
|
remote_num, data[1], data[2], scancode[0], scancode[1]);
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
|
|
|
|
if (index >= 0 && ati_remote_tbl[index].kind == KIND_LITERAL) {
|
2005-04-16 22:20:36 +00:00
|
|
|
input_event(dev, ati_remote_tbl[index].type,
|
|
|
|
ati_remote_tbl[index].code,
|
|
|
|
ati_remote_tbl[index].value);
|
|
|
|
input_sync(dev);
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
ati_remote->old_jiffies = jiffies;
|
|
|
|
return;
|
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
if (index < 0 || ati_remote_tbl[index].kind == KIND_FILTERED) {
|
2007-04-12 05:35:59 +00:00
|
|
|
unsigned long now = jiffies;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Filter duplicate events which happen "too close" together. */
|
2006-08-05 02:53:02 +00:00
|
|
|
if (ati_remote->old_data[0] == data[1] &&
|
|
|
|
ati_remote->old_data[1] == data[2] &&
|
2007-04-12 05:35:59 +00:00
|
|
|
time_before(now, ati_remote->old_jiffies +
|
|
|
|
msecs_to_jiffies(repeat_filter))) {
|
2005-04-16 22:20:36 +00:00
|
|
|
ati_remote->repeat_count++;
|
2005-05-29 07:29:01 +00:00
|
|
|
} else {
|
2005-04-16 22:20:36 +00:00
|
|
|
ati_remote->repeat_count = 0;
|
2007-04-12 05:35:59 +00:00
|
|
|
ati_remote->first_jiffies = now;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
ati_remote->old_data[0] = data[1];
|
|
|
|
ati_remote->old_data[1] = data[2];
|
2007-04-12 05:35:59 +00:00
|
|
|
ati_remote->old_jiffies = now;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-04-12 05:35:59 +00:00
|
|
|
/* Ensure we skip at least the 4 first duplicate events (generated
|
|
|
|
* by a single keypress), and continue skipping until repeat_delay
|
|
|
|
* msecs have passed
|
|
|
|
*/
|
2006-08-05 02:53:02 +00:00
|
|
|
if (ati_remote->repeat_count > 0 &&
|
2007-04-12 05:35:59 +00:00
|
|
|
(ati_remote->repeat_count < 5 ||
|
|
|
|
time_before(now, ati_remote->first_jiffies +
|
|
|
|
msecs_to_jiffies(repeat_delay))))
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
if (index < 0) {
|
|
|
|
/* Not a mouse event, hand it to rc-core. */
|
|
|
|
u32 rc_code = (scancode[0] << 8) | scancode[1];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't use the rc-core repeat handling yet as
|
|
|
|
* it would cause ghost repeats which would be a
|
|
|
|
* regression for this driver.
|
|
|
|
*/
|
|
|
|
rc_keydown_notimeout(ati_remote->rdev, rc_code, 0);
|
|
|
|
rc_keyup(ati_remote->rdev);
|
|
|
|
return;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
input_event(dev, ati_remote_tbl[index].type,
|
|
|
|
ati_remote_tbl[index].code, 1);
|
2006-08-05 02:53:24 +00:00
|
|
|
input_sync(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
input_event(dev, ati_remote_tbl[index].type,
|
|
|
|
ati_remote_tbl[index].code, 0);
|
|
|
|
input_sync(dev);
|
|
|
|
|
2006-08-05 02:53:37 +00:00
|
|
|
} else {
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2006-08-05 02:53:37 +00:00
|
|
|
/*
|
|
|
|
* Other event kinds are from the directional control pad, and have an
|
|
|
|
* acceleration factor applied to them. Without this acceleration, the
|
|
|
|
* control pad is mostly unusable.
|
|
|
|
*/
|
|
|
|
acc = ati_remote_compute_accel(ati_remote);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-08-05 02:53:37 +00:00
|
|
|
switch (ati_remote_tbl[index].kind) {
|
|
|
|
case KIND_ACCEL:
|
|
|
|
input_event(dev, ati_remote_tbl[index].type,
|
|
|
|
ati_remote_tbl[index].code,
|
|
|
|
ati_remote_tbl[index].value * acc);
|
|
|
|
break;
|
|
|
|
case KIND_LU:
|
|
|
|
input_report_rel(dev, REL_X, -acc);
|
|
|
|
input_report_rel(dev, REL_Y, -acc);
|
|
|
|
break;
|
|
|
|
case KIND_RU:
|
|
|
|
input_report_rel(dev, REL_X, acc);
|
|
|
|
input_report_rel(dev, REL_Y, -acc);
|
|
|
|
break;
|
|
|
|
case KIND_LD:
|
|
|
|
input_report_rel(dev, REL_X, -acc);
|
|
|
|
input_report_rel(dev, REL_Y, acc);
|
|
|
|
break;
|
|
|
|
case KIND_RD:
|
|
|
|
input_report_rel(dev, REL_X, acc);
|
|
|
|
input_report_rel(dev, REL_Y, acc);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n",
|
|
|
|
ati_remote_tbl[index].kind);
|
|
|
|
}
|
|
|
|
input_sync(dev);
|
|
|
|
|
|
|
|
ati_remote->old_jiffies = jiffies;
|
|
|
|
ati_remote->old_data[0] = data[1];
|
|
|
|
ati_remote->old_data[1] = data[2];
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_irq_in
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static void ati_remote_irq_in(struct urb *urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = urb->context;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
switch (urb->status) {
|
|
|
|
case 0: /* success */
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
ati_remote_input_report(urb);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case -ECONNRESET: /* unlink */
|
|
|
|
case -ENOENT:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
dev_dbg(&ati_remote->interface->dev, "%s: urb error status, unlink? \n",
|
2008-05-05 15:36:18 +00:00
|
|
|
__func__);
|
2005-05-29 07:29:01 +00:00
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
default: /* error */
|
2005-05-29 07:29:01 +00:00
|
|
|
dev_dbg(&ati_remote->interface->dev, "%s: Nonzero urb status %d\n",
|
2008-05-05 15:36:18 +00:00
|
|
|
__func__, urb->status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2006-12-07 04:33:16 +00:00
|
|
|
retval = usb_submit_urb(urb, GFP_ATOMIC);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (retval)
|
|
|
|
dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n",
|
2008-05-05 15:36:18 +00:00
|
|
|
__func__, retval);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-09-15 07:01:47 +00:00
|
|
|
* ati_remote_alloc_buffers
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2005-09-15 07:01:47 +00:00
|
|
|
static int ati_remote_alloc_buffers(struct usb_device *udev,
|
|
|
|
struct ati_remote *ati_remote)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-04-12 11:17:25 +00:00
|
|
|
ati_remote->inbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC,
|
|
|
|
&ati_remote->inbuf_dma);
|
2005-09-15 07:01:47 +00:00
|
|
|
if (!ati_remote->inbuf)
|
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-04-12 11:17:25 +00:00
|
|
|
ati_remote->outbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC,
|
2011-08-06 21:18:07 +00:00
|
|
|
&ati_remote->outbuf_dma);
|
2005-09-15 07:01:47 +00:00
|
|
|
if (!ati_remote->outbuf)
|
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!ati_remote->irq_urb)
|
|
|
|
return -1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!ati_remote->out_urb)
|
|
|
|
return -1;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
/*
|
|
|
|
* ati_remote_free_buffers
|
|
|
|
*/
|
|
|
|
static void ati_remote_free_buffers(struct ati_remote *ati_remote)
|
|
|
|
{
|
2006-11-08 14:35:46 +00:00
|
|
|
usb_free_urb(ati_remote->irq_urb);
|
|
|
|
usb_free_urb(ati_remote->out_urb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-04-12 11:17:25 +00:00
|
|
|
usb_free_coherent(ati_remote->udev, DATA_BUFSIZE,
|
2006-11-25 19:09:38 +00:00
|
|
|
ati_remote->inbuf, ati_remote->inbuf_dma);
|
2005-09-15 07:01:47 +00:00
|
|
|
|
2010-04-12 11:17:25 +00:00
|
|
|
usb_free_coherent(ati_remote->udev, DATA_BUFSIZE,
|
2006-11-25 19:09:38 +00:00
|
|
|
ati_remote->outbuf, ati_remote->outbuf_dma);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ati_remote_input_init(struct ati_remote *ati_remote)
|
|
|
|
{
|
2005-09-15 07:01:47 +00:00
|
|
|
struct input_dev *idev = ati_remote->idev;
|
2005-04-16 22:20:36 +00:00
|
|
|
int i;
|
|
|
|
|
2007-10-19 06:40:32 +00:00
|
|
|
idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
|
|
|
|
idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
|
|
|
|
BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
|
|
|
|
idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
|
2005-04-16 22:20:36 +00:00
|
|
|
for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++)
|
|
|
|
if (ati_remote_tbl[i].type == EV_KEY)
|
|
|
|
set_bit(ati_remote_tbl[i].code, idev->keybit);
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2007-04-12 05:34:39 +00:00
|
|
|
input_set_drvdata(idev, ati_remote);
|
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
idev->open = ati_remote_input_open;
|
|
|
|
idev->close = ati_remote_input_close;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
idev->name = ati_remote->mouse_name;
|
|
|
|
idev->phys = ati_remote->mouse_phys;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-06-30 05:49:08 +00:00
|
|
|
usb_to_input_id(ati_remote->udev, &idev->id);
|
2011-08-06 21:18:09 +00:00
|
|
|
idev->dev.parent = &ati_remote->interface->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
static void ati_remote_rc_init(struct ati_remote *ati_remote)
|
|
|
|
{
|
|
|
|
struct rc_dev *rdev = ati_remote->rdev;
|
|
|
|
|
|
|
|
rdev->priv = ati_remote;
|
|
|
|
rdev->driver_type = RC_DRIVER_SCANCODE;
|
|
|
|
rdev->allowed_protos = RC_TYPE_OTHER;
|
|
|
|
rdev->driver_name = "ati_remote";
|
|
|
|
|
|
|
|
rdev->open = ati_remote_rc_open;
|
|
|
|
rdev->close = ati_remote_rc_close;
|
|
|
|
|
|
|
|
rdev->input_name = ati_remote->rc_name;
|
|
|
|
rdev->input_phys = ati_remote->rc_phys;
|
|
|
|
|
|
|
|
usb_to_input_id(ati_remote->udev, &rdev->input_id);
|
2011-08-06 21:18:09 +00:00
|
|
|
rdev->dev.parent = &ati_remote->interface->dev;
|
2011-08-06 21:18:08 +00:00
|
|
|
|
|
|
|
rdev->map_name = RC_MAP_ATI_X10;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int ati_remote_initialize(struct ati_remote *ati_remote)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = ati_remote->udev;
|
|
|
|
int pipe, maxp;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
init_waitqueue_head(&ati_remote->wait);
|
|
|
|
|
|
|
|
/* Set up irq_urb */
|
|
|
|
pipe = usb_rcvintpipe(udev, ati_remote->endpoint_in->bEndpointAddress);
|
|
|
|
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
|
|
|
|
maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
|
|
|
usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf,
|
|
|
|
maxp, ati_remote_irq_in, ati_remote,
|
2005-04-16 22:20:36 +00:00
|
|
|
ati_remote->endpoint_in->bInterval);
|
|
|
|
ati_remote->irq_urb->transfer_dma = ati_remote->inbuf_dma;
|
|
|
|
ati_remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Set up out_urb */
|
|
|
|
pipe = usb_sndintpipe(udev, ati_remote->endpoint_out->bEndpointAddress);
|
|
|
|
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
|
|
|
|
maxp = (maxp > DATA_BUFSIZE) ? DATA_BUFSIZE : maxp;
|
|
|
|
|
2005-05-29 07:29:01 +00:00
|
|
|
usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
|
|
|
|
maxp, ati_remote_irq_out, ati_remote,
|
2005-04-16 22:20:36 +00:00
|
|
|
ati_remote->endpoint_out->bInterval);
|
|
|
|
ati_remote->out_urb->transfer_dma = ati_remote->outbuf_dma;
|
|
|
|
ati_remote->out_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
|
|
|
|
|
|
|
/* send initialization strings */
|
|
|
|
if ((ati_remote_sendpacket(ati_remote, 0x8004, init1)) ||
|
|
|
|
(ati_remote_sendpacket(ati_remote, 0x8007, init2))) {
|
2005-05-29 07:29:01 +00:00
|
|
|
dev_err(&ati_remote->interface->dev,
|
2005-04-16 22:20:36 +00:00
|
|
|
"Initializing ati_remote hardware failed.\n");
|
2005-09-15 07:01:47 +00:00
|
|
|
return -EIO;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_probe
|
|
|
|
*/
|
|
|
|
static int ati_remote_probe(struct usb_interface *interface, const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = interface_to_usbdev(interface);
|
2005-09-15 07:01:47 +00:00
|
|
|
struct usb_host_interface *iface_host = interface->cur_altsetting;
|
|
|
|
struct usb_endpoint_descriptor *endpoint_in, *endpoint_out;
|
|
|
|
struct ati_remote *ati_remote;
|
|
|
|
struct input_dev *input_dev;
|
2011-08-06 21:18:08 +00:00
|
|
|
struct rc_dev *rc_dev;
|
2005-09-15 07:01:47 +00:00
|
|
|
int err = -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (iface_host->desc.bNumEndpoints != 2) {
|
2008-05-05 15:36:18 +00:00
|
|
|
err("%s: Unexpected desc.bNumEndpoints\n", __func__);
|
2005-09-15 07:01:47 +00:00
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
endpoint_in = &iface_host->endpoint[0].desc;
|
|
|
|
endpoint_out = &iface_host->endpoint[1].desc;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-09-27 18:58:53 +00:00
|
|
|
if (!usb_endpoint_is_int_in(endpoint_in)) {
|
2008-05-05 15:36:18 +00:00
|
|
|
err("%s: Unexpected endpoint_in\n", __func__);
|
2005-09-15 07:01:47 +00:00
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-09-15 07:01:47 +00:00
|
|
|
if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) {
|
2008-05-05 15:36:18 +00:00
|
|
|
err("%s: endpoint_in message size==0? \n", __func__);
|
2005-09-15 07:01:47 +00:00
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
|
2011-08-06 21:18:08 +00:00
|
|
|
rc_dev = rc_allocate_device();
|
|
|
|
if (!ati_remote || !rc_dev)
|
2005-09-15 07:01:47 +00:00
|
|
|
goto fail1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
/* Allocate URB buffers, URBs */
|
|
|
|
if (ati_remote_alloc_buffers(udev, ati_remote))
|
|
|
|
goto fail2;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
ati_remote->endpoint_in = endpoint_in;
|
|
|
|
ati_remote->endpoint_out = endpoint_out;
|
|
|
|
ati_remote->udev = udev;
|
2011-08-06 21:18:08 +00:00
|
|
|
ati_remote->rdev = rc_dev;
|
2005-09-15 07:01:47 +00:00
|
|
|
ati_remote->interface = interface;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
usb_make_path(udev, ati_remote->rc_phys, sizeof(ati_remote->rc_phys));
|
|
|
|
strlcpy(ati_remote->mouse_phys, ati_remote->rc_phys,
|
|
|
|
sizeof(ati_remote->mouse_phys));
|
|
|
|
|
|
|
|
strlcat(ati_remote->rc_phys, "/input0", sizeof(ati_remote->rc_phys));
|
|
|
|
strlcat(ati_remote->mouse_phys, "/input1", sizeof(ati_remote->mouse_phys));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (udev->manufacturer)
|
2011-08-06 21:18:08 +00:00
|
|
|
strlcpy(ati_remote->rc_name, udev->manufacturer,
|
|
|
|
sizeof(ati_remote->rc_name));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (udev->product)
|
2011-08-06 21:18:08 +00:00
|
|
|
snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name),
|
|
|
|
"%s %s", ati_remote->rc_name, udev->product);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
if (!strlen(ati_remote->rc_name))
|
|
|
|
snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name),
|
2005-09-15 07:01:47 +00:00
|
|
|
DRIVER_DESC "(%04x,%04x)",
|
2005-05-29 07:29:01 +00:00
|
|
|
le16_to_cpu(ati_remote->udev->descriptor.idVendor),
|
2005-04-16 22:20:36 +00:00
|
|
|
le16_to_cpu(ati_remote->udev->descriptor.idProduct));
|
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
snprintf(ati_remote->mouse_name, sizeof(ati_remote->mouse_name),
|
|
|
|
"%s mouse", ati_remote->rc_name);
|
|
|
|
|
|
|
|
ati_remote_rc_init(ati_remote);
|
|
|
|
mutex_init(&ati_remote->open_mutex);
|
2005-09-15 07:01:47 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Device Hardware Initialization - fills in ati_remote->idev from udev. */
|
2005-09-15 07:01:47 +00:00
|
|
|
err = ati_remote_initialize(ati_remote);
|
|
|
|
if (err)
|
|
|
|
goto fail3;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
/* Set up and register rc device */
|
|
|
|
err = rc_register_device(ati_remote->rdev);
|
2007-04-12 05:33:39 +00:00
|
|
|
if (err)
|
|
|
|
goto fail3;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
/* use our delay for rc_dev */
|
|
|
|
ati_remote->rdev->input_dev->rep[REP_DELAY] = repeat_delay;
|
|
|
|
|
|
|
|
/* Set up and register mouse input device */
|
|
|
|
if (mouse) {
|
|
|
|
input_dev = input_allocate_device();
|
|
|
|
if (!input_dev)
|
|
|
|
goto fail4;
|
|
|
|
|
|
|
|
ati_remote->idev = input_dev;
|
|
|
|
ati_remote_input_init(ati_remote);
|
|
|
|
err = input_register_device(input_dev);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto fail5;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
usb_set_intfdata(interface, ati_remote);
|
2005-09-15 07:01:47 +00:00
|
|
|
return 0;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2011-08-06 21:18:08 +00:00
|
|
|
fail5: input_free_device(input_dev);
|
|
|
|
fail4: rc_unregister_device(rc_dev);
|
|
|
|
rc_dev = NULL;
|
2007-04-12 05:33:39 +00:00
|
|
|
fail3: usb_kill_urb(ati_remote->irq_urb);
|
2005-09-15 07:01:47 +00:00
|
|
|
usb_kill_urb(ati_remote->out_urb);
|
2007-04-12 05:33:39 +00:00
|
|
|
fail2: ati_remote_free_buffers(ati_remote);
|
2011-08-06 21:18:08 +00:00
|
|
|
fail1: rc_free_device(rc_dev);
|
2005-09-15 07:01:47 +00:00
|
|
|
kfree(ati_remote);
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_disconnect
|
|
|
|
*/
|
|
|
|
static void ati_remote_disconnect(struct usb_interface *interface)
|
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote;
|
|
|
|
|
|
|
|
ati_remote = usb_get_intfdata(interface);
|
|
|
|
usb_set_intfdata(interface, NULL);
|
|
|
|
if (!ati_remote) {
|
2008-08-14 16:37:34 +00:00
|
|
|
dev_warn(&interface->dev, "%s - null device?\n", __func__);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-09-15 07:01:47 +00:00
|
|
|
usb_kill_urb(ati_remote->irq_urb);
|
|
|
|
usb_kill_urb(ati_remote->out_urb);
|
2011-08-06 21:18:08 +00:00
|
|
|
if (ati_remote->idev)
|
|
|
|
input_unregister_device(ati_remote->idev);
|
|
|
|
rc_unregister_device(ati_remote->rdev);
|
2005-09-15 07:01:47 +00:00
|
|
|
ati_remote_free_buffers(ati_remote);
|
|
|
|
kfree(ati_remote);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_init
|
|
|
|
*/
|
|
|
|
static int __init ati_remote_init(void)
|
|
|
|
{
|
|
|
|
int result;
|
2005-05-29 07:29:01 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
result = usb_register(&ati_remote_driver);
|
|
|
|
if (result)
|
2008-08-18 20:21:04 +00:00
|
|
|
printk(KERN_ERR KBUILD_MODNAME
|
|
|
|
": usb_register error #%d\n", result);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2008-08-18 20:21:04 +00:00
|
|
|
printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
|
|
|
|
DRIVER_DESC "\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ati_remote_exit
|
|
|
|
*/
|
|
|
|
static void __exit ati_remote_exit(void)
|
|
|
|
{
|
|
|
|
usb_deregister(&ati_remote_driver);
|
|
|
|
}
|
|
|
|
|
2005-05-29 07:29:01 +00:00
|
|
|
/*
|
|
|
|
* module specification
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
module_init(ati_remote_init);
|
|
|
|
module_exit(ati_remote_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL");
|