2019-06-04 11:11:33 +03:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-12-10 21:30:54 +03:00
|
|
|
/*
|
|
|
|
* ati_remote2 - ATI/Philips USB RF remote driver
|
|
|
|
*
|
2008-07-03 18:45:37 +04:00
|
|
|
* Copyright (C) 2005-2008 Ville Syrjala <syrjala@sci.fi>
|
|
|
|
* Copyright (C) 2007-2008 Peter Stokes <linux@dadeos.co.uk>
|
2005-12-10 21:30:54 +03:00
|
|
|
*/
|
|
|
|
|
2006-06-13 21:04:34 +04:00
|
|
|
#include <linux/usb/input.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 11:04:11 +03:00
|
|
|
#include <linux/slab.h>
|
2011-07-03 21:53:48 +04:00
|
|
|
#include <linux/module.h>
|
2005-12-10 21:30:54 +03:00
|
|
|
|
|
|
|
#define DRIVER_DESC "ATI/Philips USB RF remote driver"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_AUTHOR("Ville Syrjala <syrjala@sci.fi>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2007-04-12 09:33:10 +04:00
|
|
|
/*
|
|
|
|
* ATI Remote Wonder II Channel Configuration
|
|
|
|
*
|
2018-05-09 01:39:31 +03:00
|
|
|
* The remote control can be assigned one of sixteen "channels" in order to facilitate
|
2007-04-12 09:33:10 +04:00
|
|
|
* the use of multiple remote controls within range of each other.
|
|
|
|
* A remote's "channel" may be altered by pressing and holding the "PC" button for
|
|
|
|
* approximately 3 seconds, after which the button will slowly flash the count of the
|
|
|
|
* currently configured "channel", using the numeric keypad enter a number between 1 and
|
2008-07-03 18:45:37 +04:00
|
|
|
* 16 and then press the "PC" button again, the button will slowly flash the count of the
|
2007-04-12 09:33:10 +04:00
|
|
|
* newly configured "channel".
|
|
|
|
*/
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
enum {
|
|
|
|
ATI_REMOTE2_MAX_CHANNEL_MASK = 0xFFFF,
|
|
|
|
ATI_REMOTE2_MAX_MODE_MASK = 0x1F,
|
|
|
|
};
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
static int ati_remote2_set_mask(const char *val,
|
2010-08-12 09:04:12 +04:00
|
|
|
const struct kernel_param *kp,
|
|
|
|
unsigned int max)
|
2009-01-30 10:42:16 +03:00
|
|
|
{
|
2011-11-09 22:20:14 +04:00
|
|
|
unsigned int mask;
|
2009-01-30 10:42:16 +03:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!val)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2011-11-09 22:20:14 +04:00
|
|
|
ret = kstrtouint(val, 0, &mask);
|
2009-01-30 10:42:16 +03:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (mask & ~max)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
*(unsigned int *)kp->arg = mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote2_set_channel_mask(const char *val,
|
2010-08-12 09:04:12 +04:00
|
|
|
const struct kernel_param *kp)
|
2009-01-30 10:42:16 +03:00
|
|
|
{
|
|
|
|
pr_debug("%s()\n", __func__);
|
|
|
|
|
|
|
|
return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_CHANNEL_MASK);
|
|
|
|
}
|
|
|
|
|
2010-08-12 09:04:12 +04:00
|
|
|
static int ati_remote2_get_channel_mask(char *buffer,
|
|
|
|
const struct kernel_param *kp)
|
2009-01-30 10:42:16 +03:00
|
|
|
{
|
|
|
|
pr_debug("%s()\n", __func__);
|
|
|
|
|
2020-07-22 08:24:24 +03:00
|
|
|
return sprintf(buffer, "0x%04x\n", *(unsigned int *)kp->arg);
|
2009-01-30 10:42:16 +03:00
|
|
|
}
|
|
|
|
|
2010-08-12 09:04:12 +04:00
|
|
|
static int ati_remote2_set_mode_mask(const char *val,
|
|
|
|
const struct kernel_param *kp)
|
2009-01-30 10:42:16 +03:00
|
|
|
{
|
|
|
|
pr_debug("%s()\n", __func__);
|
|
|
|
|
|
|
|
return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_MODE_MASK);
|
|
|
|
}
|
|
|
|
|
2010-08-12 09:04:12 +04:00
|
|
|
static int ati_remote2_get_mode_mask(char *buffer,
|
|
|
|
const struct kernel_param *kp)
|
2009-01-30 10:42:16 +03:00
|
|
|
{
|
|
|
|
pr_debug("%s()\n", __func__);
|
|
|
|
|
2020-07-22 08:24:24 +03:00
|
|
|
return sprintf(buffer, "0x%02x\n", *(unsigned int *)kp->arg);
|
2009-01-30 10:42:16 +03:00
|
|
|
}
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK;
|
2009-01-30 10:42:16 +03:00
|
|
|
#define param_check_channel_mask(name, p) __param_check(name, p, unsigned int)
|
2015-05-27 04:39:38 +03:00
|
|
|
static const struct kernel_param_ops param_ops_channel_mask = {
|
2010-08-12 09:04:12 +04:00
|
|
|
.set = ati_remote2_set_channel_mask,
|
|
|
|
.get = ati_remote2_get_channel_mask,
|
|
|
|
};
|
2009-01-30 10:42:16 +03:00
|
|
|
module_param(channel_mask, channel_mask, 0644);
|
2007-04-12 09:33:10 +04:00
|
|
|
MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>");
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK;
|
2009-01-30 10:42:16 +03:00
|
|
|
#define param_check_mode_mask(name, p) __param_check(name, p, unsigned int)
|
2015-05-27 04:39:38 +03:00
|
|
|
static const struct kernel_param_ops param_ops_mode_mask = {
|
2010-08-12 09:04:12 +04:00
|
|
|
.set = ati_remote2_set_mode_mask,
|
|
|
|
.get = ati_remote2_get_mode_mask,
|
|
|
|
};
|
2009-01-30 10:42:16 +03:00
|
|
|
module_param(mode_mask, mode_mask, 0644);
|
2005-12-10 21:30:54 +03:00
|
|
|
MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>");
|
|
|
|
|
2017-08-15 08:10:55 +03:00
|
|
|
static const struct usb_device_id ati_remote2_id_table[] = {
|
2005-12-10 21:30:54 +03:00
|
|
|
{ USB_DEVICE(0x0471, 0x0602) }, /* ATI Remote Wonder II */
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(usb, ati_remote2_id_table);
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
static DEFINE_MUTEX(ati_remote2_mutex);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ATI_REMOTE2_OPENED = 0x1,
|
|
|
|
ATI_REMOTE2_SUSPENDED = 0x2,
|
|
|
|
};
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
enum {
|
|
|
|
ATI_REMOTE2_AUX1,
|
|
|
|
ATI_REMOTE2_AUX2,
|
|
|
|
ATI_REMOTE2_AUX3,
|
|
|
|
ATI_REMOTE2_AUX4,
|
|
|
|
ATI_REMOTE2_PC,
|
|
|
|
ATI_REMOTE2_MODES,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
u8 hw_code;
|
|
|
|
u16 keycode;
|
2005-12-10 21:30:54 +03:00
|
|
|
} ati_remote2_key_table[] = {
|
|
|
|
{ 0x00, KEY_0 },
|
|
|
|
{ 0x01, KEY_1 },
|
|
|
|
{ 0x02, KEY_2 },
|
|
|
|
{ 0x03, KEY_3 },
|
|
|
|
{ 0x04, KEY_4 },
|
|
|
|
{ 0x05, KEY_5 },
|
|
|
|
{ 0x06, KEY_6 },
|
|
|
|
{ 0x07, KEY_7 },
|
|
|
|
{ 0x08, KEY_8 },
|
|
|
|
{ 0x09, KEY_9 },
|
|
|
|
{ 0x0c, KEY_POWER },
|
|
|
|
{ 0x0d, KEY_MUTE },
|
|
|
|
{ 0x10, KEY_VOLUMEUP },
|
|
|
|
{ 0x11, KEY_VOLUMEDOWN },
|
|
|
|
{ 0x20, KEY_CHANNELUP },
|
|
|
|
{ 0x21, KEY_CHANNELDOWN },
|
|
|
|
{ 0x28, KEY_FORWARD },
|
|
|
|
{ 0x29, KEY_REWIND },
|
|
|
|
{ 0x2c, KEY_PLAY },
|
|
|
|
{ 0x30, KEY_PAUSE },
|
|
|
|
{ 0x31, KEY_STOP },
|
|
|
|
{ 0x37, KEY_RECORD },
|
|
|
|
{ 0x38, KEY_DVD },
|
|
|
|
{ 0x39, KEY_TV },
|
2008-07-03 18:45:37 +04:00
|
|
|
{ 0x3f, KEY_PROG1 }, /* AUX1-AUX4 and PC */
|
2005-12-10 21:30:54 +03:00
|
|
|
{ 0x54, KEY_MENU },
|
|
|
|
{ 0x58, KEY_UP },
|
|
|
|
{ 0x59, KEY_DOWN },
|
|
|
|
{ 0x5a, KEY_LEFT },
|
|
|
|
{ 0x5b, KEY_RIGHT },
|
|
|
|
{ 0x5c, KEY_OK },
|
|
|
|
{ 0x78, KEY_A },
|
|
|
|
{ 0x79, KEY_B },
|
|
|
|
{ 0x7a, KEY_C },
|
|
|
|
{ 0x7b, KEY_D },
|
|
|
|
{ 0x7c, KEY_E },
|
|
|
|
{ 0x7d, KEY_F },
|
|
|
|
{ 0x82, KEY_ENTER },
|
|
|
|
{ 0x8e, KEY_VENDOR },
|
|
|
|
{ 0x96, KEY_COFFEE },
|
|
|
|
{ 0xa9, BTN_LEFT },
|
|
|
|
{ 0xaa, BTN_RIGHT },
|
|
|
|
{ 0xbe, KEY_QUESTION },
|
|
|
|
{ 0xd0, KEY_EDIT },
|
2008-07-03 18:45:37 +04:00
|
|
|
{ 0xd5, KEY_FRONT },
|
2005-12-10 21:30:54 +03:00
|
|
|
{ 0xf9, KEY_INFO },
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ati_remote2 {
|
|
|
|
struct input_dev *idev;
|
|
|
|
struct usb_device *udev;
|
|
|
|
|
|
|
|
struct usb_interface *intf[2];
|
|
|
|
struct usb_endpoint_descriptor *ep[2];
|
|
|
|
struct urb *urb[2];
|
|
|
|
void *buf[2];
|
|
|
|
dma_addr_t buf_dma[2];
|
|
|
|
|
|
|
|
unsigned long jiffies;
|
|
|
|
int mode;
|
|
|
|
|
|
|
|
char name[64];
|
|
|
|
char phys[64];
|
2008-07-03 18:45:37 +04:00
|
|
|
|
|
|
|
/* Each mode (AUX1-AUX4 and PC) can have an independent keymap. */
|
|
|
|
u16 keycode[ATI_REMOTE2_MODES][ARRAY_SIZE(ati_remote2_key_table)];
|
2008-07-03 18:45:37 +04:00
|
|
|
|
|
|
|
unsigned int flags;
|
2009-01-30 10:42:16 +03:00
|
|
|
|
|
|
|
unsigned int channel_mask;
|
|
|
|
unsigned int mode_mask;
|
2005-12-10 21:30:54 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id);
|
|
|
|
static void ati_remote2_disconnect(struct usb_interface *interface);
|
2008-07-03 18:45:37 +04:00
|
|
|
static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message);
|
|
|
|
static int ati_remote2_resume(struct usb_interface *interface);
|
2009-01-30 10:42:16 +03:00
|
|
|
static int ati_remote2_reset_resume(struct usb_interface *interface);
|
|
|
|
static int ati_remote2_pre_reset(struct usb_interface *interface);
|
|
|
|
static int ati_remote2_post_reset(struct usb_interface *interface);
|
2005-12-10 21:30:54 +03:00
|
|
|
|
|
|
|
static struct usb_driver ati_remote2_driver = {
|
|
|
|
.name = "ati_remote2",
|
|
|
|
.probe = ati_remote2_probe,
|
|
|
|
.disconnect = ati_remote2_disconnect,
|
|
|
|
.id_table = ati_remote2_id_table,
|
2008-07-03 18:45:37 +04:00
|
|
|
.suspend = ati_remote2_suspend,
|
|
|
|
.resume = ati_remote2_resume,
|
2009-01-30 10:42:16 +03:00
|
|
|
.reset_resume = ati_remote2_reset_resume,
|
|
|
|
.pre_reset = ati_remote2_pre_reset,
|
|
|
|
.post_reset = ati_remote2_post_reset,
|
2008-07-03 18:45:37 +04:00
|
|
|
.supports_autosuspend = 1,
|
2005-12-10 21:30:54 +03:00
|
|
|
};
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
static int ati_remote2_submit_urbs(struct ati_remote2 *ar2)
|
2005-12-10 21:30:54 +03:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = usb_submit_urb(ar2->urb[0], GFP_KERNEL);
|
|
|
|
if (r) {
|
|
|
|
dev_err(&ar2->intf[0]->dev,
|
2008-07-03 18:45:37 +04:00
|
|
|
"%s(): usb_submit_urb() = %d\n", __func__, r);
|
2005-12-10 21:30:54 +03:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
r = usb_submit_urb(ar2->urb[1], GFP_KERNEL);
|
|
|
|
if (r) {
|
|
|
|
usb_kill_urb(ar2->urb[0]);
|
|
|
|
dev_err(&ar2->intf[1]->dev,
|
2008-07-03 18:45:37 +04:00
|
|
|
"%s(): usb_submit_urb() = %d\n", __func__, r);
|
2005-12-10 21:30:54 +03:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
static void ati_remote2_kill_urbs(struct ati_remote2 *ar2)
|
|
|
|
{
|
|
|
|
usb_kill_urb(ar2->urb[1]);
|
|
|
|
usb_kill_urb(ar2->urb[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote2_open(struct input_dev *idev)
|
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2 = input_get_drvdata(idev);
|
|
|
|
int r;
|
|
|
|
|
|
|
|
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
|
|
|
|
|
|
|
|
r = usb_autopm_get_interface(ar2->intf[0]);
|
|
|
|
if (r) {
|
|
|
|
dev_err(&ar2->intf[0]->dev,
|
|
|
|
"%s(): usb_autopm_get_interface() = %d\n", __func__, r);
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) {
|
|
|
|
r = ati_remote2_submit_urbs(ar2);
|
|
|
|
if (r)
|
|
|
|
goto fail2;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar2->flags |= ATI_REMOTE2_OPENED;
|
|
|
|
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
usb_autopm_put_interface(ar2->intf[0]);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail2:
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
|
|
|
usb_autopm_put_interface(ar2->intf[0]);
|
|
|
|
fail1:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
static void ati_remote2_close(struct input_dev *idev)
|
|
|
|
{
|
2007-04-12 09:34:39 +04:00
|
|
|
struct ati_remote2 *ar2 = input_get_drvdata(idev);
|
2005-12-10 21:30:54 +03:00
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
if (!(ar2->flags & ATI_REMOTE2_SUSPENDED))
|
|
|
|
ati_remote2_kill_urbs(ar2);
|
|
|
|
|
|
|
|
ar2->flags &= ~ATI_REMOTE2_OPENED;
|
|
|
|
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
2005-12-10 21:30:54 +03: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_remote2_input_mouse(struct ati_remote2 *ar2)
|
2005-12-10 21:30:54 +03:00
|
|
|
{
|
|
|
|
struct input_dev *idev = ar2->idev;
|
|
|
|
u8 *data = ar2->buf[0];
|
2007-04-12 09:33:10 +04:00
|
|
|
int channel, mode;
|
|
|
|
|
|
|
|
channel = data[0] >> 4;
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
if (!((1 << channel) & ar2->channel_mask))
|
2007-04-12 09:33:10 +04:00
|
|
|
return;
|
2005-12-10 21:30:54 +03:00
|
|
|
|
2007-04-12 09:33:10 +04:00
|
|
|
mode = data[0] & 0x0F;
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
if (mode > ATI_REMOTE2_PC) {
|
2005-12-10 21:30:54 +03:00
|
|
|
dev_err(&ar2->intf[0]->dev,
|
|
|
|
"Unknown mode byte (%02x %02x %02x %02x)\n",
|
|
|
|
data[3], data[2], data[1], data[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
if (!((1 << mode) & ar2->mode_mask))
|
2005-12-10 21:30:54 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
input_event(idev, EV_REL, REL_X, (s8) data[1]);
|
|
|
|
input_event(idev, EV_REL, REL_Y, (s8) data[2]);
|
|
|
|
input_sync(idev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote2_lookup(unsigned int hw_code)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
for (i = 0; i < ARRAY_SIZE(ati_remote2_key_table); i++)
|
2005-12-10 21:30:54 +03:00
|
|
|
if (ati_remote2_key_table[i].hw_code == hw_code)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
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_remote2_input_key(struct ati_remote2 *ar2)
|
2005-12-10 21:30:54 +03:00
|
|
|
{
|
|
|
|
struct input_dev *idev = ar2->idev;
|
|
|
|
u8 *data = ar2->buf[1];
|
2007-04-12 09:33:10 +04:00
|
|
|
int channel, mode, hw_code, index;
|
|
|
|
|
|
|
|
channel = data[0] >> 4;
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
if (!((1 << channel) & ar2->channel_mask))
|
2007-04-12 09:33:10 +04:00
|
|
|
return;
|
2005-12-10 21:30:54 +03:00
|
|
|
|
2007-04-12 09:33:10 +04:00
|
|
|
mode = data[0] & 0x0F;
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
if (mode > ATI_REMOTE2_PC) {
|
2005-12-10 21:30:54 +03:00
|
|
|
dev_err(&ar2->intf[1]->dev,
|
|
|
|
"Unknown mode byte (%02x %02x %02x %02x)\n",
|
|
|
|
data[3], data[2], data[1], data[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hw_code = data[2];
|
|
|
|
if (hw_code == 0x3f) {
|
|
|
|
/*
|
|
|
|
* For some incomprehensible reason the mouse pad generates
|
|
|
|
* events which look identical to the events from the last
|
|
|
|
* pressed mode key. Naturally we don't want to generate key
|
|
|
|
* events for the mouse pad so we filter out any subsequent
|
|
|
|
* events from the same mode key.
|
|
|
|
*/
|
2007-04-12 09:33:10 +04:00
|
|
|
if (ar2->mode == mode)
|
2005-12-10 21:30:54 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (data[1] == 0)
|
2007-04-12 09:33:10 +04:00
|
|
|
ar2->mode = mode;
|
2005-12-10 21:30:54 +03:00
|
|
|
}
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
if (!((1 << mode) & ar2->mode_mask))
|
2005-12-10 21:30:54 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
index = ati_remote2_lookup(hw_code);
|
|
|
|
if (index < 0) {
|
|
|
|
dev_err(&ar2->intf[1]->dev,
|
|
|
|
"Unknown code byte (%02x %02x %02x %02x)\n",
|
|
|
|
data[3], data[2], data[1], data[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (data[1]) {
|
|
|
|
case 0: /* release */
|
|
|
|
break;
|
|
|
|
case 1: /* press */
|
|
|
|
ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_DELAY]);
|
|
|
|
break;
|
|
|
|
case 2: /* repeat */
|
|
|
|
|
|
|
|
/* No repeat for mouse buttons. */
|
2008-07-03 18:45:37 +04:00
|
|
|
if (ar2->keycode[mode][index] == BTN_LEFT ||
|
|
|
|
ar2->keycode[mode][index] == BTN_RIGHT)
|
2005-12-10 21:30:54 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!time_after_eq(jiffies, ar2->jiffies))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_PERIOD]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dev_err(&ar2->intf[1]->dev,
|
|
|
|
"Unknown state byte (%02x %02x %02x %02x)\n",
|
|
|
|
data[3], data[2], data[1], data[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
input_event(idev, EV_KEY, ar2->keycode[mode][index], data[1]);
|
2005-12-10 21:30:54 +03:00
|
|
|
input_sync(idev);
|
|
|
|
}
|
|
|
|
|
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_remote2_complete_mouse(struct urb *urb)
|
2005-12-10 21:30:54 +03:00
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2 = urb->context;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
switch (urb->status) {
|
|
|
|
case 0:
|
2008-07-03 18:45:37 +04:00
|
|
|
usb_mark_last_busy(ar2->udev);
|
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_remote2_input_mouse(ar2);
|
2005-12-10 21:30:54 +03:00
|
|
|
break;
|
|
|
|
case -ENOENT:
|
|
|
|
case -EILSEQ:
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
dev_dbg(&ar2->intf[0]->dev,
|
2008-05-05 19:36:18 +04:00
|
|
|
"%s(): urb status = %d\n", __func__, urb->status);
|
2005-12-10 21:30:54 +03:00
|
|
|
return;
|
|
|
|
default:
|
2008-07-03 18:45:37 +04:00
|
|
|
usb_mark_last_busy(ar2->udev);
|
2005-12-10 21:30:54 +03:00
|
|
|
dev_err(&ar2->intf[0]->dev,
|
2008-05-05 19:36:18 +04:00
|
|
|
"%s(): urb status = %d\n", __func__, urb->status);
|
2005-12-10 21:30:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
r = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (r)
|
|
|
|
dev_err(&ar2->intf[0]->dev,
|
2008-05-05 19:36:18 +04:00
|
|
|
"%s(): usb_submit_urb() = %d\n", __func__, r);
|
2005-12-10 21:30:54 +03: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_remote2_complete_key(struct urb *urb)
|
2005-12-10 21:30:54 +03:00
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2 = urb->context;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
switch (urb->status) {
|
|
|
|
case 0:
|
2008-07-03 18:45:37 +04:00
|
|
|
usb_mark_last_busy(ar2->udev);
|
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_remote2_input_key(ar2);
|
2005-12-10 21:30:54 +03:00
|
|
|
break;
|
|
|
|
case -ENOENT:
|
|
|
|
case -EILSEQ:
|
|
|
|
case -ECONNRESET:
|
|
|
|
case -ESHUTDOWN:
|
|
|
|
dev_dbg(&ar2->intf[1]->dev,
|
2008-05-05 19:36:18 +04:00
|
|
|
"%s(): urb status = %d\n", __func__, urb->status);
|
2005-12-10 21:30:54 +03:00
|
|
|
return;
|
|
|
|
default:
|
2008-07-03 18:45:37 +04:00
|
|
|
usb_mark_last_busy(ar2->udev);
|
2005-12-10 21:30:54 +03:00
|
|
|
dev_err(&ar2->intf[1]->dev,
|
2008-05-05 19:36:18 +04:00
|
|
|
"%s(): urb status = %d\n", __func__, urb->status);
|
2005-12-10 21:30:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
r = usb_submit_urb(urb, GFP_ATOMIC);
|
|
|
|
if (r)
|
|
|
|
dev_err(&ar2->intf[1]->dev,
|
2008-05-05 19:36:18 +04:00
|
|
|
"%s(): usb_submit_urb() = %d\n", __func__, r);
|
2005-12-10 21:30:54 +03:00
|
|
|
}
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
static int ati_remote2_getkeycode(struct input_dev *idev,
|
2010-09-16 06:36:34 +04:00
|
|
|
struct input_keymap_entry *ke)
|
2008-07-03 18:45:37 +04:00
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2 = input_get_drvdata(idev);
|
2010-03-09 09:37:10 +03:00
|
|
|
unsigned int mode;
|
2010-09-16 06:36:34 +04:00
|
|
|
int offset;
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int scancode;
|
|
|
|
|
|
|
|
if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
|
|
|
|
index = ke->index;
|
|
|
|
if (index >= ATI_REMOTE2_MODES *
|
|
|
|
ARRAY_SIZE(ati_remote2_key_table))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
|
|
|
|
offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
|
|
|
|
scancode = (mode << 8) + ati_remote2_key_table[offset].hw_code;
|
|
|
|
} else {
|
|
|
|
if (input_scancode_to_scalar(ke, &scancode))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
mode = scancode >> 8;
|
|
|
|
if (mode > ATI_REMOTE2_PC)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
offset = ati_remote2_lookup(scancode & 0xff);
|
|
|
|
if (offset < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
index = mode * ARRAY_SIZE(ati_remote2_key_table) + offset;
|
|
|
|
}
|
2008-07-03 18:45:37 +04:00
|
|
|
|
2010-09-16 06:36:34 +04:00
|
|
|
ke->keycode = ar2->keycode[mode][offset];
|
|
|
|
ke->len = sizeof(scancode);
|
|
|
|
memcpy(&ke->scancode, &scancode, sizeof(scancode));
|
|
|
|
ke->index = index;
|
2008-07-03 18:45:37 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-09 09:37:10 +03:00
|
|
|
static int ati_remote2_setkeycode(struct input_dev *idev,
|
2010-09-16 06:36:34 +04:00
|
|
|
const struct input_keymap_entry *ke,
|
|
|
|
unsigned int *old_keycode)
|
2008-07-03 18:45:37 +04:00
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2 = input_get_drvdata(idev);
|
2010-09-16 06:36:34 +04:00
|
|
|
unsigned int mode;
|
|
|
|
int offset;
|
|
|
|
unsigned int index;
|
|
|
|
unsigned int scancode;
|
|
|
|
|
|
|
|
if (ke->flags & INPUT_KEYMAP_BY_INDEX) {
|
|
|
|
if (ke->index >= ATI_REMOTE2_MODES *
|
|
|
|
ARRAY_SIZE(ati_remote2_key_table))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
mode = ke->index / ARRAY_SIZE(ati_remote2_key_table);
|
|
|
|
offset = ke->index % ARRAY_SIZE(ati_remote2_key_table);
|
|
|
|
} else {
|
|
|
|
if (input_scancode_to_scalar(ke, &scancode))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
mode = scancode >> 8;
|
|
|
|
if (mode > ATI_REMOTE2_PC)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
offset = ati_remote2_lookup(scancode & 0xff);
|
|
|
|
if (offset < 0)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-07-03 18:45:37 +04:00
|
|
|
|
2010-09-16 06:36:34 +04:00
|
|
|
*old_keycode = ar2->keycode[mode][offset];
|
|
|
|
ar2->keycode[mode][offset] = ke->keycode;
|
|
|
|
__set_bit(ke->keycode, idev->keybit);
|
2008-07-03 18:45:37 +04:00
|
|
|
|
|
|
|
for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
|
|
|
|
for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
|
2010-09-16 06:36:34 +04:00
|
|
|
if (ar2->keycode[mode][index] == *old_keycode)
|
2008-07-03 18:45:37 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-16 06:36:34 +04:00
|
|
|
__clear_bit(*old_keycode, idev->keybit);
|
2008-07-03 18:45:37 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
static int ati_remote2_input_init(struct ati_remote2 *ar2)
|
|
|
|
{
|
|
|
|
struct input_dev *idev;
|
2008-07-03 18:45:37 +04:00
|
|
|
int index, mode, retval;
|
2005-12-10 21:30:54 +03:00
|
|
|
|
|
|
|
idev = input_allocate_device();
|
|
|
|
if (!idev)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ar2->idev = idev;
|
2007-04-12 09:34:39 +04:00
|
|
|
input_set_drvdata(idev, ar2);
|
2005-12-10 21:30:54 +03:00
|
|
|
|
2007-10-19 10:40:32 +04:00
|
|
|
idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_REL);
|
|
|
|
idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
|
|
|
|
BIT_MASK(BTN_RIGHT);
|
|
|
|
idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
|
2008-07-03 18:45:37 +04:00
|
|
|
|
|
|
|
for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
|
|
|
|
for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
|
|
|
|
ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode;
|
2009-05-19 03:01:25 +04:00
|
|
|
__set_bit(ar2->keycode[mode][index], idev->keybit);
|
2008-07-03 18:45:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* AUX1-AUX4 and PC generate the same scancode. */
|
|
|
|
index = ati_remote2_lookup(0x3f);
|
|
|
|
ar2->keycode[ATI_REMOTE2_AUX1][index] = KEY_PROG1;
|
|
|
|
ar2->keycode[ATI_REMOTE2_AUX2][index] = KEY_PROG2;
|
|
|
|
ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3;
|
|
|
|
ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4;
|
|
|
|
ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC;
|
2009-05-19 03:01:25 +04:00
|
|
|
__set_bit(KEY_PROG1, idev->keybit);
|
|
|
|
__set_bit(KEY_PROG2, idev->keybit);
|
|
|
|
__set_bit(KEY_PROG3, idev->keybit);
|
|
|
|
__set_bit(KEY_PROG4, idev->keybit);
|
|
|
|
__set_bit(KEY_PC, idev->keybit);
|
2005-12-10 21:30:54 +03:00
|
|
|
|
|
|
|
idev->rep[REP_DELAY] = 250;
|
|
|
|
idev->rep[REP_PERIOD] = 33;
|
|
|
|
|
|
|
|
idev->open = ati_remote2_open;
|
|
|
|
idev->close = ati_remote2_close;
|
|
|
|
|
2011-02-01 08:06:39 +03:00
|
|
|
idev->getkeycode = ati_remote2_getkeycode;
|
|
|
|
idev->setkeycode = ati_remote2_setkeycode;
|
2008-07-03 18:45:37 +04:00
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
idev->name = ar2->name;
|
|
|
|
idev->phys = ar2->phys;
|
|
|
|
|
|
|
|
usb_to_input_id(ar2->udev, &idev->id);
|
2007-04-12 09:35:03 +04:00
|
|
|
idev->dev.parent = &ar2->udev->dev;
|
2005-12-10 21:30:54 +03:00
|
|
|
|
2007-04-12 09:33:39 +04:00
|
|
|
retval = input_register_device(idev);
|
|
|
|
if (retval)
|
2005-12-10 21:30:54 +03:00
|
|
|
input_free_device(idev);
|
|
|
|
|
2007-04-12 09:33:39 +04:00
|
|
|
return retval;
|
2005-12-10 21:30:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote2_urb_init(struct ati_remote2 *ar2)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = ar2->udev;
|
|
|
|
int i, pipe, maxp;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
2010-04-12 15:17:25 +04:00
|
|
|
ar2->buf[i] = usb_alloc_coherent(udev, 4, GFP_KERNEL, &ar2->buf_dma[i]);
|
2005-12-10 21:30:54 +03:00
|
|
|
if (!ar2->buf[i])
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ar2->urb[i] = usb_alloc_urb(0, GFP_KERNEL);
|
|
|
|
if (!ar2->urb[i])
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pipe = usb_rcvintpipe(udev, ar2->ep[i]->bEndpointAddress);
|
|
|
|
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
|
|
|
|
maxp = maxp > 4 ? 4 : maxp;
|
|
|
|
|
|
|
|
usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
|
|
|
|
i ? ati_remote2_complete_key : ati_remote2_complete_mouse,
|
|
|
|
ar2, ar2->ep[i]->bInterval);
|
|
|
|
ar2->urb[i]->transfer_dma = ar2->buf_dma[i];
|
|
|
|
ar2->urb[i]->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
2006-11-08 17:35:50 +03:00
|
|
|
usb_free_urb(ar2->urb[i]);
|
2010-04-12 15:17:25 +04:00
|
|
|
usb_free_coherent(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]);
|
2005-12-10 21:30:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
static int ati_remote2_setup(struct ati_remote2 *ar2, unsigned int ch_mask)
|
2007-04-12 09:33:10 +04:00
|
|
|
{
|
|
|
|
int r, i, channel;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure receiver to only accept input from remote "channel"
|
|
|
|
* channel == 0 -> Accept input from any remote channel
|
|
|
|
* channel == 1 -> Only accept input from remote channel 1
|
|
|
|
* channel == 2 -> Only accept input from remote channel 2
|
|
|
|
* ...
|
|
|
|
* channel == 16 -> Only accept input from remote channel 16
|
|
|
|
*/
|
|
|
|
|
|
|
|
channel = 0;
|
|
|
|
for (i = 0; i < 16; i++) {
|
2009-01-30 10:42:16 +03:00
|
|
|
if ((1 << i) & ch_mask) {
|
|
|
|
if (!(~(1 << i) & ch_mask))
|
2007-04-12 09:33:10 +04:00
|
|
|
channel = i + 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r = usb_control_msg(ar2->udev, usb_sndctrlpipe(ar2->udev, 0),
|
|
|
|
0x20,
|
|
|
|
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
|
|
|
|
channel, 0x0, NULL, 0, USB_CTRL_SET_TIMEOUT);
|
|
|
|
if (r) {
|
|
|
|
dev_err(&ar2->udev->dev, "%s - failed to set channel due to error: %d\n",
|
2008-05-05 19:36:18 +04:00
|
|
|
__func__, r);
|
2007-04-12 09:33:10 +04:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
static ssize_t ati_remote2_show_channel_mask(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = to_usb_device(dev);
|
|
|
|
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
|
|
|
|
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
|
|
|
|
|
|
|
|
return sprintf(buf, "0x%04x\n", ar2->channel_mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ati_remote2_store_channel_mask(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = to_usb_device(dev);
|
|
|
|
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
|
|
|
|
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
|
2011-11-09 22:20:14 +04:00
|
|
|
unsigned int mask;
|
2009-01-30 10:42:16 +03:00
|
|
|
int r;
|
|
|
|
|
2011-11-09 22:20:14 +04:00
|
|
|
r = kstrtouint(buf, 0, &mask);
|
|
|
|
if (r)
|
|
|
|
return r;
|
2009-01-30 10:42:16 +03:00
|
|
|
|
|
|
|
if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
r = usb_autopm_get_interface(ar2->intf[0]);
|
|
|
|
if (r) {
|
|
|
|
dev_err(&ar2->intf[0]->dev,
|
|
|
|
"%s(): usb_autopm_get_interface() = %d\n", __func__, r);
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote2_mutex);
|
|
|
|
|
2011-05-05 07:54:27 +04:00
|
|
|
if (mask != ar2->channel_mask) {
|
|
|
|
r = ati_remote2_setup(ar2, mask);
|
|
|
|
if (!r)
|
|
|
|
ar2->channel_mask = mask;
|
|
|
|
}
|
2009-01-30 10:42:16 +03:00
|
|
|
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
usb_autopm_put_interface(ar2->intf[0]);
|
|
|
|
|
2011-05-05 07:54:27 +04:00
|
|
|
return r ? r : count;
|
2009-01-30 10:42:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ati_remote2_show_mode_mask(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = to_usb_device(dev);
|
|
|
|
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
|
|
|
|
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
|
|
|
|
|
|
|
|
return sprintf(buf, "0x%02x\n", ar2->mode_mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t ati_remote2_store_mode_mask(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = to_usb_device(dev);
|
|
|
|
struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
|
|
|
|
struct ati_remote2 *ar2 = usb_get_intfdata(intf);
|
2011-11-09 22:20:14 +04:00
|
|
|
unsigned int mask;
|
|
|
|
int err;
|
2009-01-30 10:42:16 +03:00
|
|
|
|
2011-11-09 22:20:14 +04:00
|
|
|
err = kstrtouint(buf, 0, &mask);
|
|
|
|
if (err)
|
|
|
|
return err;
|
2009-01-30 10:42:16 +03:00
|
|
|
|
|
|
|
if (mask & ~ATI_REMOTE2_MAX_MODE_MASK)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ar2->mode_mask = mask;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DEVICE_ATTR(channel_mask, 0644, ati_remote2_show_channel_mask,
|
|
|
|
ati_remote2_store_channel_mask);
|
|
|
|
|
|
|
|
static DEVICE_ATTR(mode_mask, 0644, ati_remote2_show_mode_mask,
|
|
|
|
ati_remote2_store_mode_mask);
|
|
|
|
|
|
|
|
static struct attribute *ati_remote2_attrs[] = {
|
|
|
|
&dev_attr_channel_mask.attr,
|
|
|
|
&dev_attr_mode_mask.attr,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct attribute_group ati_remote2_attr_group = {
|
|
|
|
.attrs = ati_remote2_attrs,
|
|
|
|
};
|
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = interface_to_usbdev(interface);
|
|
|
|
struct usb_host_interface *alt = interface->cur_altsetting;
|
|
|
|
struct ati_remote2 *ar2;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (alt->desc.bInterfaceNumber)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
ar2 = kzalloc(sizeof (struct ati_remote2), GFP_KERNEL);
|
|
|
|
if (!ar2)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
ar2->udev = udev;
|
|
|
|
|
2016-03-23 21:53:46 +03:00
|
|
|
/* Sanity check, first interface must have an endpoint */
|
|
|
|
if (alt->desc.bNumEndpoints < 1 || !alt->endpoint) {
|
|
|
|
dev_err(&interface->dev,
|
|
|
|
"%s(): interface 0 must have an endpoint\n", __func__);
|
|
|
|
r = -ENODEV;
|
|
|
|
goto fail1;
|
|
|
|
}
|
2005-12-10 21:30:54 +03:00
|
|
|
ar2->intf[0] = interface;
|
|
|
|
ar2->ep[0] = &alt->endpoint[0].desc;
|
|
|
|
|
2016-03-23 21:53:46 +03:00
|
|
|
/* Sanity check, the device must have two interfaces */
|
2005-12-10 21:30:54 +03:00
|
|
|
ar2->intf[1] = usb_ifnum_to_if(udev, 1);
|
2016-03-23 21:53:46 +03:00
|
|
|
if ((udev->actconfig->desc.bNumInterfaces < 2) || !ar2->intf[1]) {
|
|
|
|
dev_err(&interface->dev, "%s(): need 2 interfaces, found %d\n",
|
|
|
|
__func__, udev->actconfig->desc.bNumInterfaces);
|
|
|
|
r = -ENODEV;
|
|
|
|
goto fail1;
|
|
|
|
}
|
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
r = usb_driver_claim_interface(&ati_remote2_driver, ar2->intf[1], ar2);
|
|
|
|
if (r)
|
|
|
|
goto fail1;
|
2016-03-23 21:53:46 +03:00
|
|
|
|
|
|
|
/* Sanity check, second interface must have an endpoint */
|
2005-12-10 21:30:54 +03:00
|
|
|
alt = ar2->intf[1]->cur_altsetting;
|
2016-03-23 21:53:46 +03:00
|
|
|
if (alt->desc.bNumEndpoints < 1 || !alt->endpoint) {
|
|
|
|
dev_err(&interface->dev,
|
|
|
|
"%s(): interface 1 must have an endpoint\n", __func__);
|
|
|
|
r = -ENODEV;
|
|
|
|
goto fail2;
|
|
|
|
}
|
2005-12-10 21:30:54 +03:00
|
|
|
ar2->ep[1] = &alt->endpoint[0].desc;
|
|
|
|
|
|
|
|
r = ati_remote2_urb_init(ar2);
|
|
|
|
if (r)
|
2016-03-23 21:53:46 +03:00
|
|
|
goto fail3;
|
2005-12-10 21:30:54 +03:00
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
ar2->channel_mask = channel_mask;
|
|
|
|
ar2->mode_mask = mode_mask;
|
2009-01-30 10:42:16 +03:00
|
|
|
|
|
|
|
r = ati_remote2_setup(ar2, ar2->channel_mask);
|
2007-04-12 09:33:10 +04:00
|
|
|
if (r)
|
2016-03-23 21:53:46 +03:00
|
|
|
goto fail3;
|
2007-04-12 09:33:10 +04:00
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
usb_make_path(udev, ar2->phys, sizeof(ar2->phys));
|
|
|
|
strlcat(ar2->phys, "/input0", sizeof(ar2->phys));
|
|
|
|
|
|
|
|
strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name));
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
r = sysfs_create_group(&udev->dev.kobj, &ati_remote2_attr_group);
|
2005-12-10 21:30:54 +03:00
|
|
|
if (r)
|
2016-03-23 21:53:46 +03:00
|
|
|
goto fail3;
|
2005-12-10 21:30:54 +03:00
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
r = ati_remote2_input_init(ar2);
|
|
|
|
if (r)
|
2016-03-23 21:53:46 +03:00
|
|
|
goto fail4;
|
2009-01-30 10:42:16 +03:00
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
usb_set_intfdata(interface, ar2);
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
interface->needs_remote_wakeup = 1;
|
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
return 0;
|
|
|
|
|
2016-03-23 21:53:46 +03:00
|
|
|
fail4:
|
2009-01-30 10:42:16 +03:00
|
|
|
sysfs_remove_group(&udev->dev.kobj, &ati_remote2_attr_group);
|
2016-03-23 21:53:46 +03:00
|
|
|
fail3:
|
2005-12-10 21:30:54 +03:00
|
|
|
ati_remote2_urb_cleanup(ar2);
|
2016-03-23 21:53:46 +03:00
|
|
|
fail2:
|
2005-12-10 21:30:54 +03:00
|
|
|
usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
|
|
|
|
fail1:
|
|
|
|
kfree(ar2);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ati_remote2_disconnect(struct usb_interface *interface)
|
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2;
|
|
|
|
struct usb_host_interface *alt = interface->cur_altsetting;
|
|
|
|
|
|
|
|
if (alt->desc.bInterfaceNumber)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ar2 = usb_get_intfdata(interface);
|
|
|
|
usb_set_intfdata(interface, NULL);
|
|
|
|
|
|
|
|
input_unregister_device(ar2->idev);
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
sysfs_remove_group(&ar2->udev->dev.kobj, &ati_remote2_attr_group);
|
|
|
|
|
2005-12-10 21:30:54 +03:00
|
|
|
ati_remote2_urb_cleanup(ar2);
|
|
|
|
|
|
|
|
usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
|
|
|
|
|
|
|
|
kfree(ar2);
|
|
|
|
}
|
|
|
|
|
2008-07-03 18:45:37 +04:00
|
|
|
static int ati_remote2_suspend(struct usb_interface *interface,
|
|
|
|
pm_message_t message)
|
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2;
|
|
|
|
struct usb_host_interface *alt = interface->cur_altsetting;
|
|
|
|
|
|
|
|
if (alt->desc.bInterfaceNumber)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ar2 = usb_get_intfdata(interface);
|
|
|
|
|
|
|
|
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
if (ar2->flags & ATI_REMOTE2_OPENED)
|
|
|
|
ati_remote2_kill_urbs(ar2);
|
|
|
|
|
|
|
|
ar2->flags |= ATI_REMOTE2_SUSPENDED;
|
|
|
|
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote2_resume(struct usb_interface *interface)
|
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2;
|
|
|
|
struct usb_host_interface *alt = interface->cur_altsetting;
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if (alt->desc.bInterfaceNumber)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ar2 = usb_get_intfdata(interface);
|
|
|
|
|
|
|
|
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
if (ar2->flags & ATI_REMOTE2_OPENED)
|
|
|
|
r = ati_remote2_submit_urbs(ar2);
|
|
|
|
|
|
|
|
if (!r)
|
|
|
|
ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
|
|
|
|
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
static int ati_remote2_reset_resume(struct usb_interface *interface)
|
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2;
|
|
|
|
struct usb_host_interface *alt = interface->cur_altsetting;
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if (alt->desc.bInterfaceNumber)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ar2 = usb_get_intfdata(interface);
|
|
|
|
|
|
|
|
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote2_mutex);
|
|
|
|
|
2009-01-30 10:42:16 +03:00
|
|
|
r = ati_remote2_setup(ar2, ar2->channel_mask);
|
2009-01-30 10:42:16 +03:00
|
|
|
if (r)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (ar2->flags & ATI_REMOTE2_OPENED)
|
|
|
|
r = ati_remote2_submit_urbs(ar2);
|
|
|
|
|
|
|
|
if (!r)
|
|
|
|
ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
|
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote2_pre_reset(struct usb_interface *interface)
|
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2;
|
|
|
|
struct usb_host_interface *alt = interface->cur_altsetting;
|
|
|
|
|
|
|
|
if (alt->desc.bInterfaceNumber)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ar2 = usb_get_intfdata(interface);
|
|
|
|
|
|
|
|
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
|
|
|
|
|
|
|
|
mutex_lock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
if (ar2->flags == ATI_REMOTE2_OPENED)
|
|
|
|
ati_remote2_kill_urbs(ar2);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ati_remote2_post_reset(struct usb_interface *interface)
|
|
|
|
{
|
|
|
|
struct ati_remote2 *ar2;
|
|
|
|
struct usb_host_interface *alt = interface->cur_altsetting;
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if (alt->desc.bInterfaceNumber)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ar2 = usb_get_intfdata(interface);
|
|
|
|
|
|
|
|
dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
|
|
|
|
|
|
|
|
if (ar2->flags == ATI_REMOTE2_OPENED)
|
|
|
|
r = ati_remote2_submit_urbs(ar2);
|
|
|
|
|
|
|
|
mutex_unlock(&ati_remote2_mutex);
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-11-18 21:48:31 +04:00
|
|
|
module_usb_driver(ati_remote2_driver);
|