2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* handle saa7134 IR remotes via linux kernel input layer.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
#include "saa7134-reg.h"
|
|
|
|
#include "saa7134.h"
|
|
|
|
|
2008-04-22 17:41:48 +00:00
|
|
|
static unsigned int disable_ir;
|
2005-04-16 22:20:36 +00:00
|
|
|
module_param(disable_ir, int, 0444);
|
|
|
|
MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
|
|
|
|
|
2008-04-22 17:41:48 +00:00
|
|
|
static unsigned int ir_debug;
|
2005-04-16 22:20:36 +00:00
|
|
|
module_param(ir_debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
|
|
|
|
|
2008-04-22 17:41:48 +00:00
|
|
|
static int pinnacle_remote;
|
2006-03-26 02:14:42 +00:00
|
|
|
module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */
|
|
|
|
MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)");
|
|
|
|
|
2006-12-28 15:47:47 +00:00
|
|
|
static int ir_rc5_remote_gap = 885;
|
2006-12-08 00:45:28 +00:00
|
|
|
module_param(ir_rc5_remote_gap, int, 0644);
|
2006-12-28 15:47:47 +00:00
|
|
|
static int ir_rc5_key_timeout = 115;
|
2006-12-08 00:45:28 +00:00
|
|
|
module_param(ir_rc5_key_timeout, int, 0644);
|
|
|
|
|
2007-10-17 20:58:40 +00:00
|
|
|
static int repeat_delay = 500;
|
|
|
|
module_param(repeat_delay, int, 0644);
|
|
|
|
MODULE_PARM_DESC(repeat_delay, "delay before key repeat started");
|
|
|
|
static int repeat_period = 33;
|
|
|
|
module_param(repeat_period, int, 0644);
|
2007-11-20 12:00:35 +00:00
|
|
|
MODULE_PARM_DESC(repeat_period, "repeat period between "
|
2007-10-17 20:58:40 +00:00
|
|
|
"keypresses when key is down");
|
|
|
|
|
2008-01-07 08:17:39 +00:00
|
|
|
static unsigned int disable_other_ir;
|
|
|
|
module_param(disable_other_ir, int, 0644);
|
|
|
|
MODULE_PARM_DESC(disable_other_ir, "disable full codes of "
|
|
|
|
"alternative remotes from other manufacturers");
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define dprintk(fmt, arg...) if (ir_debug) \
|
|
|
|
printk(KERN_DEBUG "%s/ir: " fmt, dev->name , ## arg)
|
2005-11-09 05:37:56 +00:00
|
|
|
#define i2cdprintk(fmt, arg...) if (ir_debug) \
|
|
|
|
printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-12-08 00:45:28 +00:00
|
|
|
/** rc5 functions */
|
|
|
|
static int saa7134_rc5_irq(struct saa7134_dev *dev);
|
|
|
|
|
2005-11-09 05:37:56 +00:00
|
|
|
/* -------------------- GPIO generic keycode builder -------------------- */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static int build_key(struct saa7134_dev *dev)
|
|
|
|
{
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir = dev->remote;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 gpio, data;
|
|
|
|
|
2007-10-17 20:58:40 +00:00
|
|
|
/* here comes the additional handshake steps for some cards */
|
|
|
|
switch (dev->board) {
|
|
|
|
case SAA7134_BOARD_GOTVIEW_7135:
|
|
|
|
saa_setb(SAA7134_GPIO_GPSTATUS1, 0x80);
|
|
|
|
saa_clearb(SAA7134_GPIO_GPSTATUS1, 0x80);
|
|
|
|
break;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
/* rising SAA7134_GPIO_GPRESCAN reads the status */
|
|
|
|
saa_clearb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
|
|
|
|
saa_setb(SAA7134_GPIO_GPMODE3,SAA7134_GPIO_GPRESCAN);
|
|
|
|
|
|
|
|
gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
|
2005-11-09 05:37:43 +00:00
|
|
|
if (ir->polling) {
|
|
|
|
if (ir->last_gpio == gpio)
|
|
|
|
return 0;
|
|
|
|
ir->last_gpio = gpio;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-09 05:37:43 +00:00
|
|
|
data = ir_extract_bits(gpio, ir->mask_keycode);
|
2005-04-16 22:20:36 +00:00
|
|
|
dprintk("build_key gpio=0x%x mask=0x%x data=%d\n",
|
|
|
|
gpio, ir->mask_keycode, data);
|
|
|
|
|
2006-01-09 20:21:23 +00:00
|
|
|
if (ir->polling) {
|
|
|
|
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
|
|
|
|
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
|
|
|
|
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
|
|
|
} else {
|
|
|
|
ir_input_nokey(ir->dev, &ir->ir);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2006-01-09 20:21:23 +00:00
|
|
|
else { /* IRQ driven mode - handle key press and release in one go */
|
|
|
|
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
|
|
|
|
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
|
|
|
|
ir_input_keydown(ir->dev, &ir->ir, data, data);
|
|
|
|
ir_input_nokey(ir->dev, &ir->ir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-09 05:37:56 +00:00
|
|
|
/* --------------------- Chip specific I2C key builders ----------------- */
|
|
|
|
|
|
|
|
static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
|
|
|
{
|
|
|
|
unsigned char b;
|
|
|
|
|
|
|
|
/* poll IR chip */
|
|
|
|
if (1 != i2c_master_recv(&ir->c,&b,1)) {
|
|
|
|
i2cdprintk("read error\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* no button press */
|
|
|
|
if (b==0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* repeating */
|
|
|
|
if (b & 0x80)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
*ir_key = b;
|
|
|
|
*ir_raw = b;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-11-30 00:57:24 +00:00
|
|
|
static int get_key_hvr1110(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
|
|
|
{
|
|
|
|
unsigned char buf[5], cod4, code3, code4;
|
|
|
|
|
|
|
|
/* poll IR chip */
|
|
|
|
if (5 != i2c_master_recv(&ir->c,buf,5))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
cod4 = buf[4];
|
|
|
|
code4 = (cod4 >> 2);
|
|
|
|
code3 = buf[3];
|
|
|
|
if (code3 == 0)
|
|
|
|
/* no key pressed */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* return key */
|
|
|
|
*ir_key = code4;
|
|
|
|
*ir_raw = code4;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-01-07 08:17:39 +00:00
|
|
|
|
|
|
|
static int get_key_beholdm6xx(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
|
|
|
{
|
|
|
|
unsigned char data[12];
|
|
|
|
u32 gpio;
|
|
|
|
|
|
|
|
struct saa7134_dev *dev = ir->c.adapter->algo_data;
|
|
|
|
|
|
|
|
/* rising SAA7134_GPIO_GPRESCAN reads the status */
|
|
|
|
saa_clearb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
|
|
|
saa_setb(SAA7134_GPIO_GPMODE3, SAA7134_GPIO_GPRESCAN);
|
|
|
|
|
|
|
|
gpio = saa_readl(SAA7134_GPIO_GPSTATUS0 >> 2);
|
|
|
|
|
2008-01-07 08:18:36 +00:00
|
|
|
if (0x400000 & ~gpio)
|
2008-01-07 08:17:39 +00:00
|
|
|
return 0; /* No button press */
|
|
|
|
|
|
|
|
ir->c.addr = 0x5a >> 1;
|
|
|
|
|
|
|
|
if (12 != i2c_master_recv(&ir->c, data, 12)) {
|
|
|
|
i2cdprintk("read error\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
/* IR of this card normally decode signals NEC-standard from
|
|
|
|
* - Sven IHOO MT 5.1R remote. xxyye718
|
|
|
|
* - Sven DVD HD-10xx remote. xxyyf708
|
|
|
|
* - BBK ...
|
|
|
|
* - mayby others
|
|
|
|
* So, skip not our, if disable full codes mode.
|
|
|
|
*/
|
|
|
|
if (data[10] != 0x6b && data[11] != 0x86 && disable_other_ir)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
*ir_key = data[9];
|
|
|
|
*ir_raw = data[9];
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-07-18 01:31:29 +00:00
|
|
|
/* Common (grey or coloured) pinnacle PCTV remote handling
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw,
|
|
|
|
int parity_offset, int marker, int code_modulo)
|
|
|
|
{
|
|
|
|
unsigned char b[4];
|
|
|
|
unsigned int start = 0,parity = 0,code = 0;
|
|
|
|
|
|
|
|
/* poll IR chip */
|
|
|
|
if (4 != i2c_master_recv(&ir->c, b, 4)) {
|
|
|
|
i2cdprintk("read error\n");
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (start = 0; start < ARRAY_SIZE(b); start++) {
|
|
|
|
if (b[start] == marker) {
|
|
|
|
code=b[(start+parity_offset + 1) % 4];
|
|
|
|
parity=b[(start+parity_offset) % 4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Empty Request */
|
|
|
|
if (parity == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Repeating... */
|
|
|
|
if (ir->old == parity)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ir->old = parity;
|
|
|
|
|
|
|
|
/* drop special codes when a key is held down a long time for the grey controller
|
|
|
|
In this case, the second bit of the code is asserted */
|
|
|
|
if (marker == 0xfe && (code & 0x40))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
code %= code_modulo;
|
|
|
|
|
|
|
|
*ir_raw = code;
|
|
|
|
*ir_key = code;
|
|
|
|
|
|
|
|
i2cdprintk("Pinnacle PCTV key %02x\n", code);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The grey pinnacle PCTV remote
|
|
|
|
*
|
|
|
|
* There are one issue with this remote:
|
|
|
|
* - I2c packet does not change when the same key is pressed quickly. The workaround
|
|
|
|
* is to hold down each key for about half a second, so that another code is generated
|
|
|
|
* in the i2c packet, and the function can distinguish key presses.
|
|
|
|
*
|
|
|
|
* Sylvain Pasche <sylvain.pasche@gmail.com>
|
|
|
|
*/
|
|
|
|
static int get_key_pinnacle_grey(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
|
|
|
{
|
|
|
|
|
|
|
|
return get_key_pinnacle(ir, ir_key, ir_raw, 1, 0xfe, 0xff);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* The new pinnacle PCTV remote (with the colored buttons)
|
|
|
|
*
|
|
|
|
* Ricardo Cerqueira <v4l@cerqueira.org>
|
|
|
|
*/
|
|
|
|
static int get_key_pinnacle_color(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
|
|
|
|
{
|
|
|
|
/* code_modulo parameter (0x88) is used to reduce code value to fit inside IR_KEYTAB_SIZE
|
|
|
|
*
|
|
|
|
* this is the only value that results in 42 unique
|
|
|
|
* codes < 128
|
|
|
|
*/
|
|
|
|
|
|
|
|
return get_key_pinnacle(ir, ir_key, ir_raw, 2, 0x80, 0x88);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
void saa7134_input_irq(struct saa7134_dev *dev)
|
|
|
|
{
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir = dev->remote;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-12-08 00:45:28 +00:00
|
|
|
if (!ir->polling && !ir->rc5_gpio) {
|
2005-04-16 22:20:36 +00:00
|
|
|
build_key(dev);
|
2006-12-08 00:45:28 +00:00
|
|
|
} else if (ir->rc5_gpio) {
|
|
|
|
saa7134_rc5_irq(dev);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void saa7134_input_timer(unsigned long data)
|
|
|
|
{
|
2007-05-21 14:41:02 +00:00
|
|
|
struct saa7134_dev *dev = (struct saa7134_dev *)data;
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir = dev->remote;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
build_key(dev);
|
2007-05-21 14:41:02 +00:00
|
|
|
mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-10-12 03:57:15 +00:00
|
|
|
void saa7134_ir_start(struct saa7134_dev *dev, struct card_ir *ir)
|
2006-11-20 13:23:04 +00:00
|
|
|
{
|
|
|
|
if (ir->polling) {
|
2007-05-21 14:41:02 +00:00
|
|
|
setup_timer(&ir->timer, saa7134_input_timer,
|
|
|
|
(unsigned long)dev);
|
2006-11-20 13:23:04 +00:00
|
|
|
ir->timer.expires = jiffies + HZ;
|
|
|
|
add_timer(&ir->timer);
|
2006-12-08 00:45:28 +00:00
|
|
|
} else if (ir->rc5_gpio) {
|
|
|
|
/* set timer_end for code completion */
|
|
|
|
init_timer(&ir->timer_end);
|
|
|
|
ir->timer_end.function = ir_rc5_timer_end;
|
|
|
|
ir->timer_end.data = (unsigned long)ir;
|
|
|
|
init_timer(&ir->timer_keyup);
|
|
|
|
ir->timer_keyup.function = ir_rc5_timer_keyup;
|
|
|
|
ir->timer_keyup.data = (unsigned long)ir;
|
|
|
|
ir->shift_by = 2;
|
|
|
|
ir->start = 0x2;
|
|
|
|
ir->addr = 0x17;
|
|
|
|
ir->rc5_key_timeout = ir_rc5_key_timeout;
|
|
|
|
ir->rc5_remote_gap = ir_rc5_remote_gap;
|
2006-11-20 13:23:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-12 03:57:15 +00:00
|
|
|
void saa7134_ir_stop(struct saa7134_dev *dev)
|
2006-11-20 13:23:04 +00:00
|
|
|
{
|
|
|
|
if (dev->remote->polling)
|
|
|
|
del_timer_sync(&dev->remote->timer);
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
int saa7134_input_init1(struct saa7134_dev *dev)
|
|
|
|
{
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir;
|
2005-09-15 07:01:53 +00:00
|
|
|
struct input_dev *input_dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
IR_KEYTAB_TYPE *ir_codes = NULL;
|
|
|
|
u32 mask_keycode = 0;
|
|
|
|
u32 mask_keydown = 0;
|
|
|
|
u32 mask_keyup = 0;
|
|
|
|
int polling = 0;
|
2006-12-08 00:45:28 +00:00
|
|
|
int rc5_gpio = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
int ir_type = IR_TYPE_OTHER;
|
2006-11-20 13:23:04 +00:00
|
|
|
int err;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-09 05:38:47 +00:00
|
|
|
if (dev->has_remote != SAA7134_REMOTE_GPIO)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENODEV;
|
|
|
|
if (disable_ir)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
/* detect & configure */
|
|
|
|
switch (dev->board) {
|
|
|
|
case SAA7134_BOARD_FLYVIDEO2000:
|
|
|
|
case SAA7134_BOARD_FLYVIDEO3000:
|
2005-11-09 05:37:43 +00:00
|
|
|
case SAA7134_BOARD_FLYTVPLATINUM_FM:
|
2005-11-09 05:36:55 +00:00
|
|
|
case SAA7134_BOARD_FLYTVPLATINUM_MINI2:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_flyvideo;
|
2005-04-16 22:20:36 +00:00
|
|
|
mask_keycode = 0xEC00000;
|
|
|
|
mask_keydown = 0x0040000;
|
|
|
|
break;
|
|
|
|
case SAA7134_BOARD_CINERGY400:
|
|
|
|
case SAA7134_BOARD_CINERGY600:
|
|
|
|
case SAA7134_BOARD_CINERGY600_MK3:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_cinergy;
|
2005-04-16 22:20:36 +00:00
|
|
|
mask_keycode = 0x00003f;
|
|
|
|
mask_keyup = 0x040000;
|
|
|
|
break;
|
|
|
|
case SAA7134_BOARD_ECS_TVP3XP:
|
|
|
|
case SAA7134_BOARD_ECS_TVP3XP_4CB5:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_eztv;
|
2005-07-12 20:59:01 +00:00
|
|
|
mask_keycode = 0x00017c;
|
|
|
|
mask_keyup = 0x000002;
|
2005-04-16 22:20:36 +00:00
|
|
|
polling = 50; // ms
|
2005-07-12 20:59:01 +00:00
|
|
|
break;
|
|
|
|
case SAA7134_BOARD_KWORLD_XPERT:
|
2005-04-16 22:20:36 +00:00
|
|
|
case SAA7134_BOARD_AVACSSMARTTV:
|
2006-01-23 11:44:10 +00:00
|
|
|
ir_codes = ir_codes_pixelview;
|
2005-04-16 22:20:36 +00:00
|
|
|
mask_keycode = 0x00001F;
|
|
|
|
mask_keyup = 0x000020;
|
|
|
|
polling = 50; // ms
|
|
|
|
break;
|
|
|
|
case SAA7134_BOARD_MD2819:
|
2005-06-24 05:05:09 +00:00
|
|
|
case SAA7134_BOARD_KWORLD_VSTREAM_XPERT:
|
2005-04-16 22:20:36 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_305:
|
|
|
|
case SAA7134_BOARD_AVERMEDIA_307:
|
2005-06-24 05:05:09 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_STUDIO_305:
|
|
|
|
case SAA7134_BOARD_AVERMEDIA_STUDIO_307:
|
2006-10-06 23:23:47 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_STUDIO_507:
|
2005-06-24 05:05:09 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_GO_007_FM:
|
2007-12-09 12:44:38 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_M102:
|
2006-01-23 11:44:10 +00:00
|
|
|
ir_codes = ir_codes_avermedia;
|
2005-04-16 22:20:36 +00:00
|
|
|
mask_keycode = 0x0007C8;
|
|
|
|
mask_keydown = 0x000010;
|
|
|
|
polling = 50; // ms
|
|
|
|
/* Set GPIO pin2 to high to enable the IR controller */
|
|
|
|
saa_setb(SAA7134_GPIO_GPMODE0, 0x4);
|
|
|
|
saa_setb(SAA7134_GPIO_GPSTATUS0, 0x4);
|
|
|
|
break;
|
2006-11-12 17:22:32 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_777:
|
2006-11-12 17:23:32 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_A16AR:
|
2006-11-12 17:22:32 +00:00
|
|
|
ir_codes = ir_codes_avermedia;
|
|
|
|
mask_keycode = 0x02F200;
|
|
|
|
mask_keydown = 0x000400;
|
|
|
|
polling = 50; // ms
|
|
|
|
/* Without this we won't receive key up events */
|
|
|
|
saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
|
|
|
|
saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
|
2006-11-13 17:50:11 +00:00
|
|
|
break;
|
2008-06-15 16:33:42 +00:00
|
|
|
case SAA7134_BOARD_AVERMEDIA_A16D:
|
|
|
|
ir_codes = ir_codes_avermedia_a16d;
|
|
|
|
mask_keycode = 0x02F200;
|
|
|
|
mask_keydown = 0x000400;
|
|
|
|
polling = 50; /* ms */
|
|
|
|
/* Without this we won't receive key up events */
|
|
|
|
saa_setb(SAA7134_GPIO_GPMODE1, 0x1);
|
|
|
|
saa_setb(SAA7134_GPIO_GPSTATUS1, 0x1);
|
|
|
|
break;
|
2005-11-09 05:37:43 +00:00
|
|
|
case SAA7134_BOARD_KWORLD_TERMINATOR:
|
2006-01-23 11:44:10 +00:00
|
|
|
ir_codes = ir_codes_pixelview;
|
2005-11-09 05:37:00 +00:00
|
|
|
mask_keycode = 0x00001f;
|
|
|
|
mask_keyup = 0x000060;
|
|
|
|
polling = 50; // ms
|
|
|
|
break;
|
2005-06-24 05:05:09 +00:00
|
|
|
case SAA7134_BOARD_MANLI_MTV001:
|
|
|
|
case SAA7134_BOARD_MANLI_MTV002:
|
2008-04-23 17:09:08 +00:00
|
|
|
ir_codes = ir_codes_manli;
|
|
|
|
mask_keycode = 0x001f00;
|
|
|
|
mask_keyup = 0x004000;
|
|
|
|
polling = 50; /* ms */
|
|
|
|
break;
|
2005-11-09 05:36:16 +00:00
|
|
|
case SAA7134_BOARD_BEHOLD_409FM:
|
2008-01-07 08:17:39 +00:00
|
|
|
case SAA7134_BOARD_BEHOLD_401:
|
|
|
|
case SAA7134_BOARD_BEHOLD_403:
|
|
|
|
case SAA7134_BOARD_BEHOLD_403FM:
|
|
|
|
case SAA7134_BOARD_BEHOLD_405:
|
|
|
|
case SAA7134_BOARD_BEHOLD_405FM:
|
|
|
|
case SAA7134_BOARD_BEHOLD_407:
|
|
|
|
case SAA7134_BOARD_BEHOLD_407FM:
|
|
|
|
case SAA7134_BOARD_BEHOLD_409:
|
|
|
|
case SAA7134_BOARD_BEHOLD_505FM:
|
|
|
|
case SAA7134_BOARD_BEHOLD_507_9FM:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_manli;
|
2008-04-23 17:09:08 +00:00
|
|
|
mask_keycode = 0x003f00;
|
|
|
|
mask_keyup = 0x004000;
|
|
|
|
polling = 50; /* ms */
|
|
|
|
break;
|
|
|
|
case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM:
|
|
|
|
ir_codes = ir_codes_behold_columbus;
|
|
|
|
mask_keycode = 0x003f00;
|
2005-06-24 05:05:09 +00:00
|
|
|
mask_keyup = 0x004000;
|
|
|
|
polling = 50; // ms
|
|
|
|
break;
|
2005-11-09 05:38:47 +00:00
|
|
|
case SAA7134_BOARD_SEDNA_PC_TV_CARDBUS:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_pctv_sedna;
|
2005-11-09 05:38:43 +00:00
|
|
|
mask_keycode = 0x001f00;
|
|
|
|
mask_keyup = 0x004000;
|
|
|
|
polling = 50; // ms
|
|
|
|
break;
|
2005-11-09 05:37:43 +00:00
|
|
|
case SAA7134_BOARD_GOTVIEW_7135:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_gotview7135;
|
2007-10-17 20:58:40 +00:00
|
|
|
mask_keycode = 0x0003CC;
|
2005-11-09 05:36:22 +00:00
|
|
|
mask_keydown = 0x000010;
|
2007-10-17 20:58:40 +00:00
|
|
|
polling = 5; /* ms */
|
|
|
|
saa_setb(SAA7134_GPIO_GPMODE1, 0x80);
|
2005-11-09 05:36:22 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
case SAA7134_BOARD_VIDEOMATE_TV_PVR:
|
2006-01-09 17:25:33 +00:00
|
|
|
case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
|
2005-07-12 20:59:01 +00:00
|
|
|
case SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_videomate_tv_pvr;
|
2005-04-16 22:20:36 +00:00
|
|
|
mask_keycode = 0x00003F;
|
|
|
|
mask_keyup = 0x400000;
|
|
|
|
polling = 50; // ms
|
|
|
|
break;
|
2006-09-13 19:42:42 +00:00
|
|
|
case SAA7134_BOARD_PROTEUS_2309:
|
|
|
|
ir_codes = ir_codes_proteus_2309;
|
|
|
|
mask_keycode = 0x00007F;
|
|
|
|
mask_keyup = 0x000080;
|
|
|
|
polling = 50; // ms
|
|
|
|
break;
|
2005-11-09 05:37:43 +00:00
|
|
|
case SAA7134_BOARD_VIDEOMATE_DVBT_300:
|
|
|
|
case SAA7134_BOARD_VIDEOMATE_DVBT_200:
|
2006-01-23 11:42:06 +00:00
|
|
|
ir_codes = ir_codes_videomate_tv_pvr;
|
2005-11-09 05:36:47 +00:00
|
|
|
mask_keycode = 0x003F00;
|
|
|
|
mask_keyup = 0x040000;
|
|
|
|
break;
|
2007-07-02 15:53:25 +00:00
|
|
|
case SAA7134_BOARD_FLYDVBS_LR300:
|
2006-02-07 08:49:09 +00:00
|
|
|
case SAA7134_BOARD_FLYDVBT_LR301:
|
2006-02-27 03:08:46 +00:00
|
|
|
case SAA7134_BOARD_FLYDVBTDUO:
|
2006-02-07 08:49:09 +00:00
|
|
|
ir_codes = ir_codes_flydvb;
|
|
|
|
mask_keycode = 0x0001F00;
|
|
|
|
mask_keydown = 0x0040000;
|
|
|
|
break;
|
2006-12-08 00:45:28 +00:00
|
|
|
case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
|
2007-03-29 21:32:49 +00:00
|
|
|
case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
|
2008-07-12 15:27:59 +00:00
|
|
|
case SAA7134_BOARD_ASUSTeK_P7131_ANALOG:
|
2006-12-08 00:45:28 +00:00
|
|
|
ir_codes = ir_codes_asus_pc39;
|
|
|
|
mask_keydown = 0x0040000;
|
|
|
|
rc5_gpio = 1;
|
|
|
|
break;
|
2006-12-27 15:46:36 +00:00
|
|
|
case SAA7134_BOARD_ENCORE_ENLTV:
|
|
|
|
case SAA7134_BOARD_ENCORE_ENLTV_FM:
|
|
|
|
ir_codes = ir_codes_encore_enltv;
|
|
|
|
mask_keycode = 0x00007f;
|
|
|
|
mask_keyup = 0x040000;
|
|
|
|
polling = 50; // ms
|
|
|
|
break;
|
2007-05-11 14:33:50 +00:00
|
|
|
case SAA7134_BOARD_10MOONSTVMASTER3:
|
|
|
|
ir_codes = ir_codes_encore_enltv;
|
|
|
|
mask_keycode = 0x5f80000;
|
|
|
|
mask_keyup = 0x8000000;
|
|
|
|
polling = 50; //ms
|
|
|
|
break;
|
2008-02-11 15:40:53 +00:00
|
|
|
case SAA7134_BOARD_GENIUS_TVGO_A11MCE:
|
|
|
|
ir_codes = ir_codes_genius_tvgo_a11mce;
|
|
|
|
mask_keycode = 0xff;
|
|
|
|
mask_keydown = 0xf00000;
|
|
|
|
polling = 50; /* ms */
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
if (NULL == ir_codes) {
|
|
|
|
printk("%s: Oops: IR config error [card=%d]\n",
|
|
|
|
dev->name, dev->board);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2005-09-15 07:01:53 +00:00
|
|
|
ir = kzalloc(sizeof(*ir), GFP_KERNEL);
|
|
|
|
input_dev = input_allocate_device();
|
|
|
|
if (!ir || !input_dev) {
|
2006-11-20 13:23:04 +00:00
|
|
|
err = -ENOMEM;
|
|
|
|
goto err_out_free;
|
2005-09-15 07:01:53 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-20 05:56:54 +00:00
|
|
|
ir->dev = input_dev;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* init hardware-specific stuff */
|
|
|
|
ir->mask_keycode = mask_keycode;
|
|
|
|
ir->mask_keydown = mask_keydown;
|
|
|
|
ir->mask_keyup = mask_keyup;
|
2005-11-09 05:37:43 +00:00
|
|
|
ir->polling = polling;
|
2006-12-08 00:45:28 +00:00
|
|
|
ir->rc5_gpio = rc5_gpio;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* init input device */
|
|
|
|
snprintf(ir->name, sizeof(ir->name), "saa7134 IR (%s)",
|
|
|
|
saa7134_boards[dev->board].name);
|
|
|
|
snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
|
|
|
|
pci_name(dev->pci));
|
|
|
|
|
2005-09-15 07:01:53 +00:00
|
|
|
ir_input_init(input_dev, &ir->ir, ir_type, ir_codes);
|
|
|
|
input_dev->name = ir->name;
|
|
|
|
input_dev->phys = ir->phys;
|
|
|
|
input_dev->id.bustype = BUS_PCI;
|
|
|
|
input_dev->id.version = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
if (dev->pci->subsystem_vendor) {
|
2005-09-15 07:01:53 +00:00
|
|
|
input_dev->id.vendor = dev->pci->subsystem_vendor;
|
|
|
|
input_dev->id.product = dev->pci->subsystem_device;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2005-09-15 07:01:53 +00:00
|
|
|
input_dev->id.vendor = dev->pci->vendor;
|
|
|
|
input_dev->id.product = dev->pci->device;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-07-16 12:28:15 +00:00
|
|
|
input_dev->dev.parent = &dev->pci->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dev->remote = ir;
|
2006-11-20 13:23:04 +00:00
|
|
|
saa7134_ir_start(dev, ir);
|
|
|
|
|
|
|
|
err = input_register_device(ir->dev);
|
|
|
|
if (err)
|
|
|
|
goto err_out_stop;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-10-17 20:58:40 +00:00
|
|
|
/* the remote isn't as bouncy as a keyboard */
|
|
|
|
ir->dev->rep[REP_DELAY] = repeat_delay;
|
|
|
|
ir->dev->rep[REP_PERIOD] = repeat_period;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
2006-11-20 13:23:04 +00:00
|
|
|
|
|
|
|
err_out_stop:
|
|
|
|
saa7134_ir_stop(dev);
|
|
|
|
dev->remote = NULL;
|
|
|
|
err_out_free:
|
|
|
|
input_free_device(input_dev);
|
|
|
|
kfree(ir);
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void saa7134_input_fini(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
if (NULL == dev->remote)
|
|
|
|
return;
|
|
|
|
|
2006-11-20 13:23:04 +00:00
|
|
|
saa7134_ir_stop(dev);
|
2005-09-15 07:01:53 +00:00
|
|
|
input_unregister_device(dev->remote->dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree(dev->remote);
|
|
|
|
dev->remote = NULL;
|
|
|
|
}
|
|
|
|
|
2005-11-09 05:37:56 +00:00
|
|
|
void saa7134_set_i2c_ir(struct saa7134_dev *dev, struct IR_i2c *ir)
|
|
|
|
{
|
|
|
|
if (disable_ir) {
|
2005-11-09 05:38:47 +00:00
|
|
|
dprintk("Found supported i2c remote, but IR has been disabled\n");
|
2005-11-09 05:37:56 +00:00
|
|
|
ir->get_key=NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (dev->board) {
|
|
|
|
case SAA7134_BOARD_PINNACLE_PCTV_110i:
|
2006-10-12 22:46:16 +00:00
|
|
|
case SAA7134_BOARD_PINNACLE_PCTV_310i:
|
2005-11-09 05:37:56 +00:00
|
|
|
snprintf(ir->c.name, sizeof(ir->c.name), "Pinnacle PCTV");
|
2006-03-26 02:14:42 +00:00
|
|
|
if (pinnacle_remote == 0) {
|
|
|
|
ir->get_key = get_key_pinnacle_color;
|
|
|
|
ir->ir_codes = ir_codes_pinnacle_color;
|
|
|
|
} else {
|
|
|
|
ir->get_key = get_key_pinnacle_grey;
|
|
|
|
ir->ir_codes = ir_codes_pinnacle_grey;
|
|
|
|
}
|
2005-11-09 05:37:56 +00:00
|
|
|
break;
|
|
|
|
case SAA7134_BOARD_UPMOST_PURPLE_TV:
|
|
|
|
snprintf(ir->c.name, sizeof(ir->c.name), "Purple TV");
|
|
|
|
ir->get_key = get_key_purpletv;
|
|
|
|
ir->ir_codes = ir_codes_purpletv;
|
|
|
|
break;
|
2006-11-30 00:57:24 +00:00
|
|
|
case SAA7134_BOARD_HAUPPAUGE_HVR1110:
|
|
|
|
snprintf(ir->c.name, sizeof(ir->c.name), "HVR 1110");
|
|
|
|
ir->get_key = get_key_hvr1110;
|
|
|
|
ir->ir_codes = ir_codes_hauppauge_new;
|
|
|
|
break;
|
2008-01-07 08:17:39 +00:00
|
|
|
case SAA7134_BOARD_BEHOLD_607_9FM:
|
|
|
|
case SAA7134_BOARD_BEHOLD_M6:
|
2008-06-10 17:22:00 +00:00
|
|
|
case SAA7134_BOARD_BEHOLD_M63:
|
|
|
|
case SAA7134_BOARD_BEHOLD_M6_EXTRA:
|
2008-04-26 17:53:48 +00:00
|
|
|
case SAA7134_BOARD_BEHOLD_H6:
|
2008-01-07 08:17:39 +00:00
|
|
|
snprintf(ir->c.name, sizeof(ir->c.name), "BeholdTV");
|
|
|
|
ir->get_key = get_key_beholdm6xx;
|
|
|
|
ir->ir_codes = ir_codes_behold;
|
|
|
|
break;
|
2005-11-09 05:37:56 +00:00
|
|
|
default:
|
|
|
|
dprintk("Shouldn't get here: Unknown board %x for I2C IR?\n",dev->board);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2006-12-08 00:45:28 +00:00
|
|
|
|
|
|
|
static int saa7134_rc5_irq(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
struct card_ir *ir = dev->remote;
|
|
|
|
struct timeval tv;
|
|
|
|
u32 gap;
|
|
|
|
unsigned long current_jiffies, timeout;
|
|
|
|
|
|
|
|
/* get time of bit */
|
|
|
|
current_jiffies = jiffies;
|
|
|
|
do_gettimeofday(&tv);
|
|
|
|
|
|
|
|
/* avoid overflow with gap >1s */
|
|
|
|
if (tv.tv_sec - ir->base_time.tv_sec > 1) {
|
|
|
|
gap = 200000;
|
|
|
|
} else {
|
|
|
|
gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
|
|
|
|
tv.tv_usec - ir->base_time.tv_usec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* active code => add bit */
|
|
|
|
if (ir->active) {
|
|
|
|
/* only if in the code (otherwise spurious IRQ or timer
|
|
|
|
late) */
|
|
|
|
if (ir->last_bit < 28) {
|
|
|
|
ir->last_bit = (gap - ir_rc5_remote_gap / 2) /
|
|
|
|
ir_rc5_remote_gap;
|
|
|
|
ir->code |= 1 << ir->last_bit;
|
|
|
|
}
|
|
|
|
/* starting new code */
|
|
|
|
} else {
|
|
|
|
ir->active = 1;
|
|
|
|
ir->code = 0;
|
|
|
|
ir->base_time = tv;
|
|
|
|
ir->last_bit = 0;
|
|
|
|
|
|
|
|
timeout = current_jiffies + (500 + 30 * HZ) / 1000;
|
|
|
|
mod_timer(&ir->timer_end, timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|