2005-05-29 11:29:01 +04:00
|
|
|
/*
|
2005-04-17 02:20:36 +04:00
|
|
|
* USB ATI Remote support
|
|
|
|
*
|
2012-04-01 23:41:46 +04:00
|
|
|
* Copyright (c) 2011, 2012 Anssi Hannula <anssi.hannula@iki.fi>
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
* porting to the 2.6 kernel interfaces, along with other modification
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
*
|
|
|
|
* The 2.1.1 driver was derived from the usbati_remote and usbkbd drivers by
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
2005-04-17 02:20:36 +04:00
|
|
|
* (at your option) any later version.
|
2005-05-29 11:29:01 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
*
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2005-04-17 02:20:36 +04:00
|
|
|
*
|
|
|
|
* Hardware & software notes
|
|
|
|
*
|
2005-05-29 11:29:01 +04: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-17 02:20:36 +04:00
|
|
|
* "USB Receiver" with manufacturer "X10 Wireless Technology Inc".
|
|
|
|
*
|
2005-05-29 11:29:01 +04:00
|
|
|
* The "Lola" remote is available from X10. See:
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
* It is possible to use multiple receivers and remotes on multiple computers
|
2005-04-17 02:20:36 +04:00
|
|
|
* simultaneously by configuring them to use specific channels.
|
2005-05-29 11:29:01 +04: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-17 02:20:36 +04:00
|
|
|
* hardware.
|
|
|
|
*
|
|
|
|
* Each remote can be configured to transmit on one channel as follows:
|
2005-05-29 11:29:01 +04: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-17 02:20:36 +04:00
|
|
|
* to 16, and press the hand icon again.
|
2005-05-29 11:29:01 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
* channels will be ignored by the module. To mask out channels, just add
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
* ignore signals coming from remote controls transmitting on channel 4, but
|
2005-04-17 02:20:36 +04:00
|
|
|
* accept all other channels.
|
|
|
|
*
|
2005-05-29 11:29:01 +04:00
|
|
|
* Or, set channel_mask = 65533, (0xFFFD), and all channels except 1 will be
|
2005-04-17 02:20:36 +04:00
|
|
|
* ignored.
|
|
|
|
*
|
2005-05-29 11:29:01 +04:00
|
|
|
* The default is 0 (respond to all channels). Bit 0 and bits 17-32 of this
|
2005-04-17 02:20:36 +04: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-07 01:18:08 +04:00
|
|
|
#include <linux/mutex.h>
|
2006-06-13 21:04:34 +04:00
|
|
|
#include <linux/usb/input.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/wait.h>
|
2005-12-01 00:50:39 +03:00
|
|
|
#include <linux/jiffies.h>
|
2011-08-07 01:18:08 +04:00
|
|
|
#include <media/rc-core.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Module and Version Information, Module Parameters
|
|
|
|
*/
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2010-05-04 10:30:32 +04: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
|
2011-08-07 01:18:12 +04:00
|
|
|
#define FIREFLY_REMOTE_PRODUCT_ID 0x0008
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-08-07 01:18:07 +04:00
|
|
|
#define DRIVER_VERSION "2.2.1"
|
2005-04-17 02:20:36 +04: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 06:53:02 +04: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 09:35:59 +04:00
|
|
|
#define REPEAT_DELAY 500 /* msec */
|
2006-08-05 06:53:02 +04:00
|
|
|
|
2005-05-29 11:29:38 +04:00
|
|
|
static unsigned long channel_mask;
|
2006-08-05 06:53:15 +04:00
|
|
|
module_param(channel_mask, ulong, 0644);
|
2005-04-17 02:20:36 +04:00
|
|
|
MODULE_PARM_DESC(channel_mask, "Bitmask of remote control channels to ignore");
|
|
|
|
|
2005-05-29 11:29:38 +04:00
|
|
|
static int debug;
|
2006-08-05 06:53:15 +04:00
|
|
|
module_param(debug, int, 0644);
|
2005-04-17 02:20:36 +04:00
|
|
|
MODULE_PARM_DESC(debug, "Enable extra debug messages and information");
|
|
|
|
|
2006-08-05 06:53:02 +04: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 09:35:59 +04: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-07 01:18:08 +04:00
|
|
|
static bool mouse = true;
|
|
|
|
module_param(mouse, bool, 0444);
|
|
|
|
MODULE_PARM_DESC(mouse, "Enable mouse device, default = yes");
|
|
|
|
|
2012-07-07 10:53:28 +04:00
|
|
|
#define dbginfo(dev, format, arg...) \
|
|
|
|
do { if (debug) dev_info(dev , format , ## arg); } while (0)
|
2005-04-17 02:20:36 +04:00
|
|
|
#undef err
|
|
|
|
#define err(format, arg...) printk(KERN_ERR format , ## arg)
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2012-04-01 23:41:45 +04:00
|
|
|
struct ati_receiver_type {
|
|
|
|
/* either default_keymap or get_default_keymap should be set */
|
|
|
|
const char *default_keymap;
|
|
|
|
const char *(*get_default_keymap)(struct usb_interface *interface);
|
|
|
|
};
|
|
|
|
|
2012-04-01 23:41:46 +04:00
|
|
|
static const char *get_medion_keymap(struct usb_interface *interface)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = interface_to_usbdev(interface);
|
|
|
|
|
2012-05-14 16:52:37 +04:00
|
|
|
/*
|
|
|
|
* There are many different Medion remotes shipped with a receiver
|
|
|
|
* with the same usb id, but the receivers have subtle differences
|
|
|
|
* in the USB descriptors allowing us to detect them.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (udev->manufacturer && udev->product) {
|
|
|
|
if (udev->actconfig->desc.bmAttributes & USB_CONFIG_ATT_WAKEUP) {
|
|
|
|
|
|
|
|
if (!strcmp(udev->manufacturer, "X10 Wireless Technology Inc")
|
|
|
|
&& !strcmp(udev->product, "USB Receiver"))
|
|
|
|
return RC_MAP_MEDION_X10_DIGITAINER;
|
|
|
|
|
|
|
|
if (!strcmp(udev->manufacturer, "X10 WTI")
|
|
|
|
&& !strcmp(udev->product, "RF receiver"))
|
|
|
|
return RC_MAP_MEDION_X10_OR2X;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!strcmp(udev->manufacturer, "X10 Wireless Technology Inc")
|
|
|
|
&& !strcmp(udev->product, "USB Receiver"))
|
|
|
|
return RC_MAP_MEDION_X10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dev_info(&interface->dev,
|
|
|
|
"Unknown Medion X10 receiver, using default ati_remote Medion keymap\n");
|
2012-04-01 23:41:46 +04:00
|
|
|
|
|
|
|
return RC_MAP_MEDION_X10;
|
|
|
|
}
|
|
|
|
|
2012-07-07 10:53:28 +04:00
|
|
|
static const struct ati_receiver_type type_ati = {
|
|
|
|
.default_keymap = RC_MAP_ATI_X10
|
|
|
|
};
|
|
|
|
static const struct ati_receiver_type type_medion = {
|
|
|
|
.get_default_keymap = get_medion_keymap
|
|
|
|
};
|
|
|
|
static const struct ati_receiver_type type_firefly = {
|
|
|
|
.default_keymap = RC_MAP_SNAPSTREAM_FIREFLY
|
|
|
|
};
|
2012-04-01 23:41:45 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static struct usb_device_id ati_remote_table[] = {
|
2012-07-07 10:53:28 +04:00
|
|
|
{
|
|
|
|
USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA_REMOTE_PRODUCT_ID),
|
|
|
|
.driver_info = (unsigned long)&type_ati
|
|
|
|
},
|
|
|
|
{
|
|
|
|
USB_DEVICE(ATI_REMOTE_VENDOR_ID, LOLA2_REMOTE_PRODUCT_ID),
|
|
|
|
.driver_info = (unsigned long)&type_ati
|
|
|
|
},
|
|
|
|
{
|
|
|
|
USB_DEVICE(ATI_REMOTE_VENDOR_ID, ATI_REMOTE_PRODUCT_ID),
|
|
|
|
.driver_info = (unsigned long)&type_ati
|
|
|
|
},
|
|
|
|
{
|
|
|
|
USB_DEVICE(ATI_REMOTE_VENDOR_ID, NVIDIA_REMOTE_PRODUCT_ID),
|
|
|
|
.driver_info = (unsigned long)&type_ati
|
|
|
|
},
|
|
|
|
{
|
|
|
|
USB_DEVICE(ATI_REMOTE_VENDOR_ID, MEDION_REMOTE_PRODUCT_ID),
|
|
|
|
.driver_info = (unsigned long)&type_medion
|
|
|
|
},
|
|
|
|
{
|
|
|
|
USB_DEVICE(ATI_REMOTE_VENDOR_ID, FIREFLY_REMOTE_PRODUCT_ID),
|
|
|
|
.driver_info = (unsigned long)&type_firefly
|
|
|
|
},
|
2005-04-17 02:20:36 +04:00
|
|
|
{} /* 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 11:01:47 +04:00
|
|
|
struct input_dev *idev;
|
2011-08-07 01:18:08 +04:00
|
|
|
struct rc_dev *rdev;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct usb_device *udev;
|
|
|
|
struct usb_interface *interface;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04: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;
|
|
|
|
|
2011-12-07 05:34:29 +04:00
|
|
|
unsigned char old_data; /* Detect duplicate events */
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long old_jiffies;
|
|
|
|
unsigned long acc_jiffies; /* handle acceleration */
|
2007-04-12 09:35:59 +04:00
|
|
|
unsigned long first_jiffies;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int repeat_count;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
char rc_name[NAME_BUFSIZE];
|
|
|
|
char rc_phys[NAME_BUFSIZE];
|
|
|
|
char mouse_name[NAME_BUFSIZE];
|
|
|
|
char mouse_phys[NAME_BUFSIZE];
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
wait_queue_head_t wait;
|
|
|
|
int send_flags;
|
2011-08-07 01:18:08 +04:00
|
|
|
|
|
|
|
int users; /* 0-2, users are rc and input */
|
|
|
|
struct mutex open_mutex;
|
2005-04-17 02:20:36 +04: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 11:43:42 +03:00
|
|
|
static const struct {
|
2005-04-17 02:20:36 +04:00
|
|
|
short kind;
|
2011-12-07 05:34:29 +04:00
|
|
|
unsigned char data;
|
2005-04-17 02:20:36 +04:00
|
|
|
int type;
|
|
|
|
unsigned int code;
|
|
|
|
int value;
|
2005-09-15 11:01:47 +04:00
|
|
|
} ati_remote_tbl[] = {
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Directional control pad axes */
|
2011-12-07 05:34:29 +04:00
|
|
|
{KIND_ACCEL, 0x70, EV_REL, REL_X, -1}, /* left */
|
|
|
|
{KIND_ACCEL, 0x71, EV_REL, REL_X, 1}, /* right */
|
|
|
|
{KIND_ACCEL, 0x72, EV_REL, REL_Y, -1}, /* up */
|
|
|
|
{KIND_ACCEL, 0x73, EV_REL, REL_Y, 1}, /* down */
|
2005-05-29 11:29:01 +04:00
|
|
|
/* Directional control pad diagonals */
|
2011-12-07 05:34:29 +04:00
|
|
|
{KIND_LU, 0x74, EV_REL, 0, 0}, /* left up */
|
|
|
|
{KIND_RU, 0x75, EV_REL, 0, 0}, /* right up */
|
|
|
|
{KIND_LD, 0x77, EV_REL, 0, 0}, /* left down */
|
|
|
|
{KIND_RD, 0x76, EV_REL, 0, 0}, /* right down */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* "Mouse button" buttons */
|
2011-12-07 05:34:29 +04:00
|
|
|
{KIND_LITERAL, 0x78, EV_KEY, BTN_LEFT, 1}, /* left btn down */
|
|
|
|
{KIND_LITERAL, 0x79, EV_KEY, BTN_LEFT, 0}, /* left btn up */
|
|
|
|
{KIND_LITERAL, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */
|
|
|
|
{KIND_LITERAL, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-05-29 11:29:01 +04:00
|
|
|
/* Artificial "doubleclick" events are generated by the hardware.
|
2005-04-17 02:20:36 +04:00
|
|
|
* They are mapped to the "side" and "extra" mouse buttons here. */
|
2011-12-07 05:34:29 +04:00
|
|
|
{KIND_FILTERED, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */
|
|
|
|
{KIND_FILTERED, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
/* Non-mouse events are handled by rc-core */
|
2011-12-07 05:34:29 +04:00
|
|
|
{KIND_END, 0x00, EV_MAX + 1, 0, 0}
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_dump_input
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2008-08-14 20:37:34 +04:00
|
|
|
static void ati_remote_dump(struct device *dev, unsigned char *data,
|
|
|
|
unsigned int len)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2011-08-07 01:18:10 +04:00
|
|
|
if (len == 1) {
|
|
|
|
if (data[0] != (unsigned char)0xff && data[0] != 0x00)
|
|
|
|
dev_warn(dev, "Weird byte 0x%02x\n", data[0]);
|
|
|
|
} else if (len == 4)
|
2012-08-07 19:43:09 +04:00
|
|
|
dev_warn(dev, "Weird key %*ph\n", 4, data);
|
2005-04-17 02:20:36 +04:00
|
|
|
else
|
2012-08-07 19:43:09 +04:00
|
|
|
dev_warn(dev, "Weird data, len=%d %*ph ...\n", len, 6, data);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_open
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2011-08-07 01:18:08 +04:00
|
|
|
static int ati_remote_open(struct ati_remote *ati_remote)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2011-08-07 01:18:08 +04:00
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote->open_mutex);
|
|
|
|
|
|
|
|
if (ati_remote->users++ != 0)
|
|
|
|
goto out; /* one was already active */
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
dev_err(&ati_remote->interface->dev,
|
2008-05-05 19:36:18 +04:00
|
|
|
"%s: usb_submit_urb failed!\n", __func__);
|
2011-08-07 01:18:08 +04:00
|
|
|
err = -EIO;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
out: mutex_unlock(&ati_remote->open_mutex);
|
|
|
|
return err;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_close
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2011-08-07 01:18:08 +04: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-17 02:20:36 +04:00
|
|
|
{
|
2007-04-12 09:34:39 +04:00
|
|
|
struct ati_remote *ati_remote = input_get_drvdata(inputdev);
|
2011-08-07 01:18:08 +04:00
|
|
|
return ati_remote_open(ati_remote);
|
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2011-08-07 01:18:08 +04: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-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_irq_out
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
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 17:55:46 +04:00
|
|
|
static void ati_remote_irq_out(struct urb *urb)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = urb->context;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (urb->status) {
|
|
|
|
dev_dbg(&ati_remote->interface->dev, "%s: status %d\n",
|
2008-05-05 19:36:18 +04:00
|
|
|
__func__, urb->status);
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
ati_remote->send_flags |= SEND_FLAG_COMPLETE;
|
|
|
|
wmb();
|
|
|
|
wake_up(&ati_remote->wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_sendpacket
|
2005-05-29 11:29:01 +04:00
|
|
|
*
|
2012-07-07 10:53:28 +04:00
|
|
|
* Used to send device initialization strings
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2012-07-07 10:53:28 +04:00
|
|
|
static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd,
|
|
|
|
unsigned char *data)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int retval = 0;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Set up out_urb */
|
|
|
|
memcpy(ati_remote->out_urb->transfer_buffer + 1, data, LO(cmd));
|
2005-05-29 11:29:01 +04:00
|
|
|
((char *) ati_remote->out_urb->transfer_buffer)[0] = HI(cmd);
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
dev_dbg(&ati_remote->interface->dev,
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
(ati_remote->send_flags & SEND_FLAG_COMPLETE)),
|
2005-04-17 02:20:36 +04:00
|
|
|
HZ);
|
|
|
|
usb_kill_urb(ati_remote->out_urb);
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2006-08-05 06:53:37 +04:00
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_compute_accel
|
2006-08-05 06:53:37 +04:00
|
|
|
*
|
|
|
|
* 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-17 02:20:36 +04:00
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_report_input
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
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 17:55:46 +04:00
|
|
|
static void ati_remote_input_report(struct urb *urb)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct ati_remote *ati_remote = urb->context;
|
|
|
|
unsigned char *data= ati_remote->inbuf;
|
2005-09-15 11:01:47 +04:00
|
|
|
struct input_dev *dev = ati_remote->idev;
|
2011-08-07 01:18:08 +04:00
|
|
|
int index = -1;
|
|
|
|
int acc;
|
2005-04-17 02:20:36 +04:00
|
|
|
int remote_num;
|
2011-12-07 05:34:29 +04:00
|
|
|
unsigned char scancode;
|
2012-04-01 23:41:46 +04:00
|
|
|
u32 wheel_keycode = KEY_RESERVED;
|
2011-12-07 05:34:29 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* data[0] = 0x14
|
|
|
|
* data[1] = data[2] + data[3] + 0xd5 (a checksum byte)
|
|
|
|
* data[2] = the key code (with toggle bit in MSB with some models)
|
|
|
|
* data[3] = channel << 4 (the low 4 bits must be zero)
|
|
|
|
*/
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Deal with strange looking inputs */
|
2005-05-29 11:29:01 +04:00
|
|
|
if ( (urb->actual_length != 4) || (data[0] != 0x14) ||
|
2005-04-17 02:20:36 +04:00
|
|
|
((data[3] & 0x0f) != 0x00) ) {
|
2008-08-14 20:37:34 +04:00
|
|
|
ati_remote_dump(&urb->dev->dev, data, urb->actual_length);
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-07 05:34:29 +04:00
|
|
|
if (data[1] != ((data[2] + data[3] + 0xd5) & 0xff)) {
|
|
|
|
dbginfo(&ati_remote->interface->dev,
|
2012-08-07 19:43:09 +04:00
|
|
|
"wrong checksum in input: %*ph\n", 4, data);
|
2011-12-07 05:34:29 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Mask unwanted remote channels. */
|
|
|
|
/* note: remote_num is 0-based, channel 1 on remote == 0 here */
|
|
|
|
remote_num = (data[3] >> 4) & 0x0f;
|
2011-08-07 01:18:07 +04:00
|
|
|
if (channel_mask & (1 << (remote_num + 1))) {
|
2005-04-17 02:20:36 +04:00
|
|
|
dbginfo(&ati_remote->interface->dev,
|
2012-07-07 10:53:28 +04:00
|
|
|
"Masked input from channel 0x%02x: data %02x,%02x, "
|
|
|
|
"mask= 0x%02lx\n",
|
2005-04-17 02:20:36 +04:00
|
|
|
remote_num, data[1], data[2], channel_mask);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-08-07 01:18:12 +04:00
|
|
|
/*
|
2011-12-07 05:34:29 +04:00
|
|
|
* MSB is a toggle code, though only used by some devices
|
|
|
|
* (e.g. SnapStream Firefly)
|
2011-08-07 01:18:12 +04:00
|
|
|
*/
|
2011-12-07 05:34:29 +04:00
|
|
|
scancode = data[2] & 0x7f;
|
2011-08-07 01:18:08 +04:00
|
|
|
|
2012-04-01 23:41:46 +04:00
|
|
|
dbginfo(&ati_remote->interface->dev,
|
|
|
|
"channel 0x%02x; key data %02x, scancode %02x\n",
|
|
|
|
remote_num, data[2], scancode);
|
|
|
|
|
|
|
|
if (scancode >= 0x70) {
|
|
|
|
/*
|
|
|
|
* This is either a mouse or scrollwheel event, depending on
|
|
|
|
* the remote/keymap.
|
|
|
|
* Get the keycode assigned to scancode 0x78/0x70. If it is
|
|
|
|
* set, assume this is a scrollwheel up/down event.
|
|
|
|
*/
|
|
|
|
wheel_keycode = rc_g_keycode_from_table(ati_remote->rdev,
|
|
|
|
scancode & 0x78);
|
|
|
|
|
|
|
|
if (wheel_keycode == KEY_RESERVED) {
|
|
|
|
/* scrollwheel was not mapped, assume mouse */
|
|
|
|
|
2012-07-07 10:53:28 +04:00
|
|
|
/* Look up event code index in the mouse translation
|
|
|
|
* table.
|
|
|
|
*/
|
2012-04-01 23:41:46 +04:00
|
|
|
for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) {
|
|
|
|
if (scancode == ati_remote_tbl[i].data) {
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-12-07 05:34:29 +04:00
|
|
|
}
|
|
|
|
}
|
2011-08-07 01:18:08 +04:00
|
|
|
|
|
|
|
if (index >= 0 && ati_remote_tbl[index].kind == KIND_LITERAL) {
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
ati_remote->old_jiffies = jiffies;
|
|
|
|
return;
|
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
if (index < 0 || ati_remote_tbl[index].kind == KIND_FILTERED) {
|
2007-04-12 09:35:59 +04:00
|
|
|
unsigned long now = jiffies;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Filter duplicate events which happen "too close" together. */
|
2011-12-07 05:34:29 +04:00
|
|
|
if (ati_remote->old_data == data[2] &&
|
2007-04-12 09:35:59 +04:00
|
|
|
time_before(now, ati_remote->old_jiffies +
|
|
|
|
msecs_to_jiffies(repeat_filter))) {
|
2005-04-17 02:20:36 +04:00
|
|
|
ati_remote->repeat_count++;
|
2005-05-29 11:29:01 +04:00
|
|
|
} else {
|
2005-04-17 02:20:36 +04:00
|
|
|
ati_remote->repeat_count = 0;
|
2007-04-12 09:35:59 +04:00
|
|
|
ati_remote->first_jiffies = now;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2011-12-07 05:34:29 +04:00
|
|
|
ati_remote->old_data = data[2];
|
2007-04-12 09:35:59 +04:00
|
|
|
ati_remote->old_jiffies = now;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2007-04-12 09:35:59 +04: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 06:53:02 +04:00
|
|
|
if (ati_remote->repeat_count > 0 &&
|
2007-04-12 09:35:59 +04:00
|
|
|
(ati_remote->repeat_count < 5 ||
|
|
|
|
time_before(now, ati_remote->first_jiffies +
|
|
|
|
msecs_to_jiffies(repeat_delay))))
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
if (index < 0) {
|
|
|
|
/* Not a mouse event, hand it to rc-core. */
|
2012-04-01 23:41:46 +04:00
|
|
|
int count = 1;
|
|
|
|
|
|
|
|
if (wheel_keycode != KEY_RESERVED) {
|
|
|
|
/*
|
|
|
|
* This is a scrollwheel event, send the
|
|
|
|
* scroll up (0x78) / down (0x70) scancode
|
|
|
|
* repeatedly as many times as indicated by
|
|
|
|
* rest of the scancode.
|
|
|
|
*/
|
|
|
|
count = (scancode & 0x07) + 1;
|
|
|
|
scancode &= 0x78;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (count--) {
|
|
|
|
/*
|
|
|
|
* 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, scancode,
|
|
|
|
data[2]);
|
|
|
|
rc_keyup(ati_remote->rdev);
|
|
|
|
}
|
2011-08-07 01:18:08 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
input_event(dev, ati_remote_tbl[index].type,
|
|
|
|
ati_remote_tbl[index].code, 1);
|
2006-08-05 06:53:24 +04:00
|
|
|
input_sync(dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
input_event(dev, ati_remote_tbl[index].type,
|
|
|
|
ati_remote_tbl[index].code, 0);
|
|
|
|
input_sync(dev);
|
|
|
|
|
2006-08-05 06:53:37 +04:00
|
|
|
} else {
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2006-08-05 06:53:37 +04:00
|
|
|
/*
|
2012-07-07 10:53:28 +04: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.
|
2006-08-05 06:53:37 +04:00
|
|
|
*/
|
|
|
|
acc = ati_remote_compute_accel(ati_remote);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-08-05 06:53:37 +04: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:
|
2012-07-07 10:53:28 +04:00
|
|
|
dev_dbg(&ati_remote->interface->dev,
|
|
|
|
"ati_remote kind=%d\n",
|
2006-08-05 06:53:37 +04:00
|
|
|
ati_remote_tbl[index].kind);
|
|
|
|
}
|
|
|
|
input_sync(dev);
|
|
|
|
|
|
|
|
ati_remote->old_jiffies = jiffies;
|
2011-12-07 05:34:29 +04:00
|
|
|
ati_remote->old_data = data[2];
|
2006-08-05 06:53:37 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_irq_in
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
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 17:55:46 +04:00
|
|
|
static void ati_remote_irq_in(struct urb *urb)
|
2005-04-17 02:20:36 +04: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 17:55:46 +04:00
|
|
|
ati_remote_input_report(urb);
|
2005-04-17 02:20:36 +04:00
|
|
|
break;
|
|
|
|
case -ECONNRESET: /* unlink */
|
|
|
|
case -ENOENT:
|
|
|
|
case -ESHUTDOWN:
|
2012-07-07 10:53:28 +04:00
|
|
|
dev_dbg(&ati_remote->interface->dev,
|
|
|
|
"%s: urb error status, unlink?\n",
|
2008-05-05 19:36:18 +04:00
|
|
|
__func__);
|
2005-05-29 11:29:01 +04:00
|
|
|
return;
|
2005-04-17 02:20:36 +04:00
|
|
|
default: /* error */
|
2012-07-07 10:53:28 +04:00
|
|
|
dev_dbg(&ati_remote->interface->dev,
|
|
|
|
"%s: Nonzero urb status %d\n",
|
2008-05-05 19:36:18 +04:00
|
|
|
__func__, urb->status);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2006-12-07 07:33:16 +03:00
|
|
|
retval = usb_submit_urb(urb, GFP_ATOMIC);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (retval)
|
2012-07-07 10:53:28 +04:00
|
|
|
dev_err(&ati_remote->interface->dev,
|
|
|
|
"%s: usb_submit_urb()=%d\n",
|
2008-05-05 19:36:18 +04:00
|
|
|
__func__, retval);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_alloc_buffers
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2005-09-15 11:01:47 +04:00
|
|
|
static int ati_remote_alloc_buffers(struct usb_device *udev,
|
|
|
|
struct ati_remote *ati_remote)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2010-04-12 15:17:25 +04:00
|
|
|
ati_remote->inbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC,
|
|
|
|
&ati_remote->inbuf_dma);
|
2005-09-15 11:01:47 +04:00
|
|
|
if (!ati_remote->inbuf)
|
|
|
|
return -1;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-04-12 15:17:25 +04:00
|
|
|
ati_remote->outbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC,
|
2011-08-07 01:18:07 +04:00
|
|
|
&ati_remote->outbuf_dma);
|
2005-09-15 11:01:47 +04:00
|
|
|
if (!ati_remote->outbuf)
|
|
|
|
return -1;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!ati_remote->irq_urb)
|
|
|
|
return -1;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!ati_remote->out_urb)
|
|
|
|
return -1;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_free_buffers
|
2005-09-15 11:01:47 +04:00
|
|
|
*/
|
|
|
|
static void ati_remote_free_buffers(struct ati_remote *ati_remote)
|
|
|
|
{
|
2006-11-08 17:35:46 +03:00
|
|
|
usb_free_urb(ati_remote->irq_urb);
|
|
|
|
usb_free_urb(ati_remote->out_urb);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-04-12 15:17:25 +04:00
|
|
|
usb_free_coherent(ati_remote->udev, DATA_BUFSIZE,
|
2006-11-25 22:09:38 +03:00
|
|
|
ati_remote->inbuf, ati_remote->inbuf_dma);
|
2005-09-15 11:01:47 +04:00
|
|
|
|
2010-04-12 15:17:25 +04:00
|
|
|
usb_free_coherent(ati_remote->udev, DATA_BUFSIZE,
|
2006-11-25 22:09:38 +03:00
|
|
|
ati_remote->outbuf, ati_remote->outbuf_dma);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void ati_remote_input_init(struct ati_remote *ati_remote)
|
|
|
|
{
|
2005-09-15 11:01:47 +04:00
|
|
|
struct input_dev *idev = ati_remote->idev;
|
2005-04-17 02:20:36 +04:00
|
|
|
int i;
|
|
|
|
|
2007-10-19 10:40:32 +04: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-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
|
2007-04-12 09:34:39 +04:00
|
|
|
input_set_drvdata(idev, ati_remote);
|
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
idev->open = ati_remote_input_open;
|
|
|
|
idev->close = ati_remote_input_close;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
idev->name = ati_remote->mouse_name;
|
|
|
|
idev->phys = ati_remote->mouse_phys;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-06-30 09:49:08 +04:00
|
|
|
usb_to_input_id(ati_remote->udev, &idev->id);
|
2011-08-07 01:18:09 +04:00
|
|
|
idev->dev.parent = &ati_remote->interface->dev;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2011-08-07 01:18:08 +04: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;
|
2012-10-12 02:11:54 +04:00
|
|
|
rdev->allowed_protos = RC_BIT_OTHER;
|
2011-08-07 01:18:08 +04:00
|
|
|
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-07 01:18:09 +04:00
|
|
|
rdev->dev.parent = &ati_remote->interface->dev;
|
2011-08-07 01:18:08 +04:00
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static int ati_remote_initialize(struct ati_remote *ati_remote)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = ati_remote->udev;
|
|
|
|
int pipe, maxp;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
|
|
|
|
usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf,
|
|
|
|
maxp, ati_remote_irq_in, ati_remote,
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf,
|
|
|
|
maxp, ati_remote_irq_out, ati_remote,
|
2005-04-17 02:20:36 +04: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 11:29:01 +04:00
|
|
|
dev_err(&ati_remote->interface->dev,
|
2005-04-17 02:20:36 +04:00
|
|
|
"Initializing ati_remote hardware failed.\n");
|
2005-09-15 11:01:47 +04:00
|
|
|
return -EIO;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_probe
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2012-07-07 10:53:28 +04:00
|
|
|
static int ati_remote_probe(struct usb_interface *interface,
|
|
|
|
const struct usb_device_id *id)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct usb_device *udev = interface_to_usbdev(interface);
|
2005-09-15 11:01:47 +04:00
|
|
|
struct usb_host_interface *iface_host = interface->cur_altsetting;
|
|
|
|
struct usb_endpoint_descriptor *endpoint_in, *endpoint_out;
|
2012-04-01 23:41:45 +04:00
|
|
|
struct ati_receiver_type *type = (struct ati_receiver_type *)id->driver_info;
|
2005-09-15 11:01:47 +04:00
|
|
|
struct ati_remote *ati_remote;
|
|
|
|
struct input_dev *input_dev;
|
2011-08-07 01:18:08 +04:00
|
|
|
struct rc_dev *rc_dev;
|
2005-09-15 11:01:47 +04:00
|
|
|
int err = -ENOMEM;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
if (iface_host->desc.bNumEndpoints != 2) {
|
2008-05-05 19:36:18 +04:00
|
|
|
err("%s: Unexpected desc.bNumEndpoints\n", __func__);
|
2005-09-15 11:01:47 +04:00
|
|
|
return -ENODEV;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
endpoint_in = &iface_host->endpoint[0].desc;
|
|
|
|
endpoint_out = &iface_host->endpoint[1].desc;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2006-09-27 22:58:53 +04:00
|
|
|
if (!usb_endpoint_is_int_in(endpoint_in)) {
|
2008-05-05 19:36:18 +04:00
|
|
|
err("%s: Unexpected endpoint_in\n", __func__);
|
2005-09-15 11:01:47 +04:00
|
|
|
return -ENODEV;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2005-09-15 11:01:47 +04:00
|
|
|
if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) {
|
2008-05-05 19:36:18 +04:00
|
|
|
err("%s: endpoint_in message size==0? \n", __func__);
|
2005-09-15 11:01:47 +04:00
|
|
|
return -ENODEV;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL);
|
2011-08-07 01:18:08 +04:00
|
|
|
rc_dev = rc_allocate_device();
|
|
|
|
if (!ati_remote || !rc_dev)
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
goto exit_free_dev_rdev;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
/* Allocate URB buffers, URBs */
|
|
|
|
if (ati_remote_alloc_buffers(udev, ati_remote))
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
goto exit_free_buffers;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
ati_remote->endpoint_in = endpoint_in;
|
|
|
|
ati_remote->endpoint_out = endpoint_out;
|
|
|
|
ati_remote->udev = udev;
|
2011-08-07 01:18:08 +04:00
|
|
|
ati_remote->rdev = rc_dev;
|
2005-09-15 11:01:47 +04:00
|
|
|
ati_remote->interface = interface;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-08-07 01:18:08 +04: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-17 02:20:36 +04:00
|
|
|
|
|
|
|
if (udev->manufacturer)
|
2011-08-07 01:18:08 +04:00
|
|
|
strlcpy(ati_remote->rc_name, udev->manufacturer,
|
|
|
|
sizeof(ati_remote->rc_name));
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
if (udev->product)
|
2011-08-07 01:18:08 +04:00
|
|
|
snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name),
|
|
|
|
"%s %s", ati_remote->rc_name, udev->product);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
if (!strlen(ati_remote->rc_name))
|
|
|
|
snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name),
|
2005-09-15 11:01:47 +04:00
|
|
|
DRIVER_DESC "(%04x,%04x)",
|
2005-05-29 11:29:01 +04:00
|
|
|
le16_to_cpu(ati_remote->udev->descriptor.idVendor),
|
2005-04-17 02:20:36 +04:00
|
|
|
le16_to_cpu(ati_remote->udev->descriptor.idProduct));
|
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
snprintf(ati_remote->mouse_name, sizeof(ati_remote->mouse_name),
|
|
|
|
"%s mouse", ati_remote->rc_name);
|
|
|
|
|
2012-04-01 23:41:45 +04:00
|
|
|
rc_dev->map_name = RC_MAP_ATI_X10; /* default map */
|
|
|
|
|
|
|
|
/* set default keymap according to receiver model */
|
|
|
|
if (type) {
|
|
|
|
if (type->default_keymap)
|
|
|
|
rc_dev->map_name = type->default_keymap;
|
|
|
|
else if (type->get_default_keymap)
|
|
|
|
rc_dev->map_name = type->get_default_keymap(interface);
|
|
|
|
}
|
2011-08-07 01:18:11 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
ati_remote_rc_init(ati_remote);
|
|
|
|
mutex_init(&ati_remote->open_mutex);
|
2005-09-15 11:01:47 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Device Hardware Initialization - fills in ati_remote->idev from udev. */
|
2005-09-15 11:01:47 +04:00
|
|
|
err = ati_remote_initialize(ati_remote);
|
|
|
|
if (err)
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
goto exit_kill_urbs;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-08-07 01:18:08 +04:00
|
|
|
/* Set up and register rc device */
|
|
|
|
err = rc_register_device(ati_remote->rdev);
|
2007-04-12 09:33:39 +04:00
|
|
|
if (err)
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
goto exit_kill_urbs;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2011-08-07 01:18:08 +04: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();
|
2012-09-04 15:05:04 +04:00
|
|
|
if (!input_dev) {
|
|
|
|
err = -ENOMEM;
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
goto exit_unregister_device;
|
2012-09-04 15:05:04 +04:00
|
|
|
}
|
2011-08-07 01:18:08 +04:00
|
|
|
|
|
|
|
ati_remote->idev = input_dev;
|
|
|
|
ati_remote_input_init(ati_remote);
|
|
|
|
err = input_register_device(input_dev);
|
|
|
|
|
|
|
|
if (err)
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
goto exit_free_input_device;
|
2011-08-07 01:18:08 +04:00
|
|
|
}
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
usb_set_intfdata(interface, ati_remote);
|
2005-09-15 11:01:47 +04:00
|
|
|
return 0;
|
2005-05-29 11:29:01 +04:00
|
|
|
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
exit_free_input_device:
|
|
|
|
input_free_device(input_dev);
|
|
|
|
exit_unregister_device:
|
|
|
|
rc_unregister_device(rc_dev);
|
2011-08-07 01:18:08 +04:00
|
|
|
rc_dev = NULL;
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
exit_kill_urbs:
|
|
|
|
usb_kill_urb(ati_remote->irq_urb);
|
2005-09-15 11:01:47 +04:00
|
|
|
usb_kill_urb(ati_remote->out_urb);
|
[media] rc: Make probe cleanup goto labels more verbose
Before, labels were simply numbered. Now, the labels are named after the
cleanup action they'll perform (first), based on how the winbond-cir
driver does it. This makes the code a bit more clear and makes changes
in the ordering of labels easier to review.
This change is applied only to the rc drivers that do significant
cleanup in their probe functions: ati-remote, ene-ir, fintek-cir,
gpio-ir-recv, ite-cir, nuvoton-cir.
This commit should not change any code, it just renames goto labels.
[mchehab@redhat.com: removed changes at gpio-ir-recv.c, due to
merge conflicts]
Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-11-02 16:13:54 +04:00
|
|
|
exit_free_buffers:
|
|
|
|
ati_remote_free_buffers(ati_remote);
|
|
|
|
exit_free_dev_rdev:
|
|
|
|
rc_free_device(rc_dev);
|
2005-09-15 11:01:47 +04:00
|
|
|
kfree(ati_remote);
|
|
|
|
return err;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-07 10:53:28 +04:00
|
|
|
* ati_remote_disconnect
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
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 20:37:34 +04:00
|
|
|
dev_warn(&interface->dev, "%s - null device?\n", __func__);
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-05-29 11:29:01 +04:00
|
|
|
|
2005-09-15 11:01:47 +04:00
|
|
|
usb_kill_urb(ati_remote->irq_urb);
|
|
|
|
usb_kill_urb(ati_remote->out_urb);
|
2011-08-07 01:18:08 +04:00
|
|
|
if (ati_remote->idev)
|
|
|
|
input_unregister_device(ati_remote->idev);
|
|
|
|
rc_unregister_device(ati_remote->rdev);
|
2005-09-15 11:01:47 +04:00
|
|
|
ati_remote_free_buffers(ati_remote);
|
|
|
|
kfree(ati_remote);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2012-07-07 10:53:28 +04:00
|
|
|
/* 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,
|
|
|
|
};
|
|
|
|
|
2011-11-18 21:46:12 +04:00
|
|
|
module_usb_driver(ati_remote_driver);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL");
|