2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 Gerd Knorr
|
|
|
|
* Copyright (c) 2003 Pavel Machek
|
|
|
|
*
|
|
|
|
* 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 "bttv.h"
|
2006-01-09 17:25:25 +00:00
|
|
|
#include "bttvp.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-14 00:07:52 +00:00
|
|
|
|
2008-08-05 13:14:13 +00:00
|
|
|
static int ir_debug;
|
|
|
|
module_param(ir_debug, int, 0644);
|
2005-11-14 00:07:52 +00:00
|
|
|
static int repeat_delay = 500;
|
|
|
|
module_param(repeat_delay, int, 0644);
|
|
|
|
static int repeat_period = 33;
|
|
|
|
module_param(repeat_period, int, 0644);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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 = 200;
|
2006-12-08 00:45:28 +00:00
|
|
|
module_param(ir_rc5_key_timeout, int, 0644);
|
|
|
|
|
2008-08-05 13:14:13 +00:00
|
|
|
#undef dprintk
|
|
|
|
#define dprintk(arg...) do { \
|
|
|
|
if (ir_debug >= 1) \
|
|
|
|
printk(arg); \
|
|
|
|
} while (0)
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
#define DEVNAME "bttv-input"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
static void ir_handle_key(struct bttv *btv)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir = btv->remote;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 gpio,data;
|
|
|
|
|
|
|
|
/* read gpio value */
|
2006-01-09 17:25:25 +00:00
|
|
|
gpio = bttv_gpio_read(&btv->c);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ir->polling) {
|
|
|
|
if (ir->last_gpio == gpio)
|
|
|
|
return;
|
|
|
|
ir->last_gpio = gpio;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* extract data */
|
|
|
|
data = ir_extract_bits(gpio, ir->mask_keycode);
|
2006-01-09 17:25:25 +00:00
|
|
|
dprintk(KERN_INFO DEVNAME ": irq gpio=0x%x code=%d | %s%s%s\n",
|
2005-04-16 22:20:36 +00:00
|
|
|
gpio, data,
|
|
|
|
ir->polling ? "poll" : "irq",
|
|
|
|
(gpio & ir->mask_keydown) ? " down" : "",
|
|
|
|
(gpio & ir->mask_keyup) ? " up" : "");
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) ||
|
|
|
|
(ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) {
|
2009-11-28 01:40:22 +00:00
|
|
|
ir_input_keydown(ir->dev, &ir->ir, data);
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2008-01-07 12:30:31 +00:00
|
|
|
/* HACK: Probably, ir->mask_keydown is missing
|
|
|
|
for this board */
|
|
|
|
if (btv->c.type == BTTV_BOARD_WINFAST2000)
|
2009-11-28 01:40:22 +00:00
|
|
|
ir_input_keydown(ir->dev, &ir->ir, data);
|
2008-01-07 12:30:31 +00:00
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
ir_input_nokey(ir->dev,&ir->ir);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-08-05 13:14:13 +00:00
|
|
|
static void ir_enltv_handle_key(struct bttv *btv)
|
|
|
|
{
|
|
|
|
struct card_ir *ir = btv->remote;
|
|
|
|
u32 gpio, data, keyup;
|
|
|
|
|
|
|
|
/* read gpio value */
|
|
|
|
gpio = bttv_gpio_read(&btv->c);
|
|
|
|
|
|
|
|
/* extract data */
|
|
|
|
data = ir_extract_bits(gpio, ir->mask_keycode);
|
|
|
|
|
|
|
|
/* Check if it is keyup */
|
|
|
|
keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0;
|
|
|
|
|
|
|
|
if ((ir->last_gpio & 0x7f) != data) {
|
|
|
|
dprintk(KERN_INFO DEVNAME ": gpio=0x%x code=%d | %s\n",
|
|
|
|
gpio, data,
|
|
|
|
(gpio & ir->mask_keyup) ? " up" : "up/down");
|
|
|
|
|
2009-11-28 01:40:22 +00:00
|
|
|
ir_input_keydown(ir->dev, &ir->ir, data);
|
2008-08-05 13:14:13 +00:00
|
|
|
if (keyup)
|
|
|
|
ir_input_nokey(ir->dev, &ir->ir);
|
|
|
|
} else {
|
|
|
|
if ((ir->last_gpio & 1 << 31) == keyup)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dprintk(KERN_INFO DEVNAME ":(cnt) gpio=0x%x code=%d | %s\n",
|
|
|
|
gpio, data,
|
|
|
|
(gpio & ir->mask_keyup) ? " up" : "down");
|
|
|
|
|
|
|
|
if (keyup)
|
|
|
|
ir_input_nokey(ir->dev, &ir->ir);
|
|
|
|
else
|
2009-11-28 01:40:22 +00:00
|
|
|
ir_input_keydown(ir->dev, &ir->ir, data);
|
2008-08-05 13:14:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ir->last_gpio = data | keyup;
|
|
|
|
}
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
void bttv_input_irq(struct bttv *btv)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir = btv->remote;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
if (!ir->polling)
|
|
|
|
ir_handle_key(btv);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
static void bttv_input_timer(unsigned long data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-01-09 17:25:25 +00:00
|
|
|
struct bttv *btv = (struct bttv*)data;
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir = btv->remote;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-08-05 13:14:13 +00:00
|
|
|
if (btv->c.type == BTTV_BOARD_ENLTV_FM_2)
|
|
|
|
ir_enltv_handle_key(btv);
|
|
|
|
else
|
|
|
|
ir_handle_key(btv);
|
2007-01-02 06:29:48 +00:00
|
|
|
mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-11-14 00:07:52 +00:00
|
|
|
/* ---------------------------------------------------------------*/
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
static int bttv_rc5_irq(struct bttv *btv)
|
2005-11-14 00:07:52 +00:00
|
|
|
{
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir = btv->remote;
|
2005-11-14 00:07:52 +00:00
|
|
|
struct timeval tv;
|
|
|
|
u32 gpio;
|
|
|
|
u32 gap;
|
2007-01-02 06:29:48 +00:00
|
|
|
unsigned long current_jiffies;
|
2005-11-14 00:07:52 +00:00
|
|
|
|
|
|
|
/* read gpio port */
|
2006-01-09 17:25:25 +00:00
|
|
|
gpio = bttv_gpio_read(&btv->c);
|
2005-11-14 00:07:52 +00:00
|
|
|
|
|
|
|
/* remote IRQ? */
|
|
|
|
if (!(gpio & 0x20))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* 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) {
|
2006-12-08 00:45:28 +00:00
|
|
|
ir->last_bit = (gap - ir_rc5_remote_gap / 2) /
|
|
|
|
ir_rc5_remote_gap;
|
2005-11-14 00:07:52 +00:00
|
|
|
ir->code |= 1 << ir->last_bit;
|
|
|
|
}
|
|
|
|
/* starting new code */
|
|
|
|
} else {
|
|
|
|
ir->active = 1;
|
|
|
|
ir->code = 0;
|
|
|
|
ir->base_time = tv;
|
|
|
|
ir->last_bit = 0;
|
|
|
|
|
2007-01-02 06:29:48 +00:00
|
|
|
mod_timer(&ir->timer_end,
|
|
|
|
current_jiffies + msecs_to_jiffies(30));
|
2005-11-14 00:07:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* toggle GPIO pin 4 to reset the irq */
|
2006-01-09 17:25:25 +00:00
|
|
|
bttv_gpio_write(&btv->c, gpio & ~(1 << 4));
|
|
|
|
bttv_gpio_write(&btv->c, gpio | (1 << 4));
|
2005-11-14 00:07:52 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2006-12-08 00:45:28 +00:00
|
|
|
static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)
|
2006-11-20 13:23:04 +00:00
|
|
|
{
|
|
|
|
if (ir->polling) {
|
2007-01-02 06:29:48 +00:00
|
|
|
setup_timer(&ir->timer, bttv_input_timer, (unsigned long)btv);
|
2007-07-17 19:36:20 +00:00
|
|
|
ir->timer.expires = jiffies + msecs_to_jiffies(1000);
|
2006-11-20 13:23:04 +00:00
|
|
|
add_timer(&ir->timer);
|
|
|
|
} else if (ir->rc5_gpio) {
|
|
|
|
/* set timer_end for code completion */
|
|
|
|
init_timer(&ir->timer_end);
|
2006-12-08 00:45:28 +00:00
|
|
|
ir->timer_end.function = ir_rc5_timer_end;
|
2006-11-20 13:23:04 +00:00
|
|
|
ir->timer_end.data = (unsigned long)ir;
|
|
|
|
|
|
|
|
init_timer(&ir->timer_keyup);
|
2006-12-08 00:45:28 +00:00
|
|
|
ir->timer_keyup.function = ir_rc5_timer_keyup;
|
2006-11-20 13:23:04 +00:00
|
|
|
ir->timer_keyup.data = (unsigned long)ir;
|
2006-12-08 00:45:28 +00:00
|
|
|
ir->shift_by = 1;
|
|
|
|
ir->start = 3;
|
|
|
|
ir->addr = 0x0;
|
|
|
|
ir->rc5_key_timeout = ir_rc5_key_timeout;
|
|
|
|
ir->rc5_remote_gap = ir_rc5_remote_gap;
|
2006-11-20 13:23:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void bttv_ir_stop(struct bttv *btv)
|
|
|
|
{
|
|
|
|
if (btv->remote->polling) {
|
|
|
|
del_timer_sync(&btv->remote->timer);
|
|
|
|
flush_scheduled_work();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (btv->remote->rc5_gpio) {
|
|
|
|
u32 gpio;
|
|
|
|
|
|
|
|
del_timer_sync(&btv->remote->timer_end);
|
|
|
|
flush_scheduled_work();
|
|
|
|
|
|
|
|
gpio = bttv_gpio_read(&btv->c);
|
|
|
|
bttv_gpio_write(&btv->c, gpio & ~(1 << 4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
int bttv_input_init(struct bttv *btv)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-12-08 00:45:28 +00:00
|
|
|
struct card_ir *ir;
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
struct ir_scancode_table *ir_codes = NULL;
|
2006-01-09 17:25:25 +00:00
|
|
|
struct input_dev *input_dev;
|
2009-12-14 16:53:37 +00:00
|
|
|
u64 ir_type = IR_TYPE_OTHER;
|
2006-11-20 13:23:04 +00:00
|
|
|
int err = -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
if (!btv->has_remote)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
ir = kzalloc(sizeof(*ir),GFP_KERNEL);
|
2005-09-15 07:01:53 +00:00
|
|
|
input_dev = input_allocate_device();
|
2006-11-20 13:23:04 +00:00
|
|
|
if (!ir || !input_dev)
|
|
|
|
goto err_out_free;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* detect & configure */
|
2006-01-09 17:25:25 +00:00
|
|
|
switch (btv->c.type) {
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_AVERMEDIA:
|
|
|
|
case BTTV_BOARD_AVPHONE98:
|
|
|
|
case BTTV_BOARD_AVERMEDIA98:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_avermedia_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
ir->mask_keycode = 0xf88000;
|
|
|
|
ir->mask_keydown = 0x010000;
|
|
|
|
ir->polling = 50; // ms
|
|
|
|
break;
|
|
|
|
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_AVDVBT_761:
|
|
|
|
case BTTV_BOARD_AVDVBT_771:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_avermedia_dvbt_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
ir->mask_keycode = 0x0f00c0;
|
|
|
|
ir->mask_keydown = 0x000020;
|
|
|
|
ir->polling = 50; // ms
|
|
|
|
break;
|
|
|
|
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_PXELVWPLTVPAK:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_pixelview_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
ir->mask_keycode = 0x003e00;
|
|
|
|
ir->mask_keyup = 0x010000;
|
|
|
|
ir->polling = 50; // ms
|
2005-11-09 05:37:43 +00:00
|
|
|
break;
|
2006-08-23 14:17:30 +00:00
|
|
|
case BTTV_BOARD_PV_M4900:
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_PV_BT878P_9B:
|
|
|
|
case BTTV_BOARD_PV_BT878P_PLUS:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_pixelview_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
ir->mask_keycode = 0x001f00;
|
|
|
|
ir->mask_keyup = 0x008000;
|
|
|
|
ir->polling = 50; // ms
|
2005-11-09 05:37:43 +00:00
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_WINFAST2000:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_winfast_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
ir->mask_keycode = 0x1f8;
|
|
|
|
break;
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_MAGICTVIEW061:
|
|
|
|
case BTTV_BOARD_MAGICTVIEW063:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_winfast_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
ir->mask_keycode = 0x0008e000;
|
|
|
|
ir->mask_keydown = 0x00200000;
|
|
|
|
break;
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_APAC_VIEWCOMP:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_apac_viewcomp_table;
|
2005-04-16 22:20:36 +00:00
|
|
|
ir->mask_keycode = 0x001f00;
|
|
|
|
ir->mask_keyup = 0x008000;
|
|
|
|
ir->polling = 50; // ms
|
|
|
|
break;
|
2009-08-22 17:43:50 +00:00
|
|
|
case BTTV_BOARD_ASKEY_CPH03X:
|
2005-11-09 05:36:52 +00:00
|
|
|
case BTTV_BOARD_CONCEPTRONIC_CTVFMI2:
|
2006-02-27 03:08:15 +00:00
|
|
|
case BTTV_BOARD_CONTVFMI:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_pixelview_table;
|
2005-11-09 05:36:20 +00:00
|
|
|
ir->mask_keycode = 0x001F00;
|
|
|
|
ir->mask_keyup = 0x006000;
|
|
|
|
ir->polling = 50; // ms
|
|
|
|
break;
|
2005-11-14 00:07:52 +00:00
|
|
|
case BTTV_BOARD_NEBULA_DIGITV:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_nebula_table;
|
2006-01-09 17:25:25 +00:00
|
|
|
btv->custom_irq = bttv_rc5_irq;
|
2005-11-14 00:07:52 +00:00
|
|
|
ir->rc5_gpio = 1;
|
2005-12-12 08:37:28 +00:00
|
|
|
break;
|
2006-01-11 21:40:09 +00:00
|
|
|
case BTTV_BOARD_MACHTV_MAGICTV:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_apac_viewcomp_table;
|
2006-01-11 21:40:09 +00:00
|
|
|
ir->mask_keycode = 0x001F00;
|
|
|
|
ir->mask_keyup = 0x004000;
|
|
|
|
ir->polling = 50; /* ms */
|
|
|
|
break;
|
2008-04-22 17:45:58 +00:00
|
|
|
case BTTV_BOARD_KOZUMI_KTV_01C:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_pctv_sedna_table;
|
2008-04-22 17:45:58 +00:00
|
|
|
ir->mask_keycode = 0x001f00;
|
|
|
|
ir->mask_keyup = 0x006000;
|
|
|
|
ir->polling = 50; /* ms */
|
|
|
|
break;
|
2008-08-05 13:14:13 +00:00
|
|
|
case BTTV_BOARD_ENLTV_FM_2:
|
V4L/DVB (12595): common/ir: use a struct for keycode tables
Currently, V4L uses a scancode table whose index is the scancode and
the value is the keycode. While this works, it has some drawbacks:
1) It requires that the scancode to be at the range 00-7f;
2) keycodes should be masked on 7 bits in order for it to work;
3) due to the 7 bits approach, sometimes it is not possible to replace
the default keyboard to another one with a different encoding rule;
4) it is different than what is done with dvb-usb approach;
5) it requires a typedef for it to work. This is not a recommended
Linux CodingStyle.
This patch is part of a larger series of IR changes. It basically
replaces the IR_KEYTAB_TYPE tables by a structured table:
struct ir_scancode {
u16 scancode;
u32 keycode;
};
This is very close to what dvb does. So, a further integration with DVB
code will be easy.
While we've changed the tables, for now, the IR keycode handling is still
based on the old approach.
The only notable effect is the redution of about 35% of the ir-common
module size:
text data bss dec hex filename
6721 29208 4 35933 8c5d old/ir-common.ko
5756 18040 4 23800 5cf8 new/ir-common.ko
In thesis, we could be using above u8 for scancode, reducing even more the size
of the module, but defining it as u16 is more convenient, since, on dvb, each
scancode has up to 16 bits, and we currently have a few troubles with rc5, as their
scancodes are defined with more than 8 bits.
This patch itself shouldn't be doing any functional changes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2009-08-29 17:15:55 +00:00
|
|
|
ir_codes = &ir_codes_encore_enltv2_table;
|
2008-08-05 13:14:13 +00:00
|
|
|
ir->mask_keycode = 0x00fd00;
|
|
|
|
ir->mask_keyup = 0x000080;
|
|
|
|
ir->polling = 1; /* ms */
|
|
|
|
ir->last_gpio = ir_extract_bits(bttv_gpio_read(&btv->c),
|
|
|
|
ir->mask_keycode);
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
if (NULL == ir_codes) {
|
2006-11-20 13:23:04 +00:00
|
|
|
dprintk(KERN_INFO "Ooops: IR config error [card=%d]\n", btv->c.type);
|
|
|
|
err = -ENODEV;
|
|
|
|
goto err_out_free;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-11-14 00:07:52 +00:00
|
|
|
if (ir->rc5_gpio) {
|
|
|
|
u32 gpio;
|
2006-06-20 03:30:57 +00:00
|
|
|
/* enable remote irq */
|
2006-01-09 17:25:25 +00:00
|
|
|
bttv_gpio_inout(&btv->c, (1 << 4), 1 << 4);
|
|
|
|
gpio = bttv_gpio_read(&btv->c);
|
|
|
|
bttv_gpio_write(&btv->c, gpio & ~(1 << 4));
|
|
|
|
bttv_gpio_write(&btv->c, gpio | (1 << 4));
|
2005-11-14 00:07:52 +00:00
|
|
|
} else {
|
|
|
|
/* init hardware-specific stuff */
|
2006-01-09 17:25:25 +00:00
|
|
|
bttv_gpio_inout(&btv->c, ir->mask_keycode | ir->mask_keydown, 0);
|
2005-11-14 00:07:52 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* init input device */
|
2006-01-09 17:25:25 +00:00
|
|
|
ir->dev = input_dev;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
|
2006-01-09 17:25:25 +00:00
|
|
|
btv->c.type);
|
2005-04-16 22:20:36 +00:00
|
|
|
snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0",
|
2006-01-09 17:25:25 +00:00
|
|
|
pci_name(btv->c.pci));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-12-11 14:20:59 +00:00
|
|
|
err = ir_input_init(input_dev, &ir->ir, ir_type);
|
2009-11-29 11:19:59 +00:00
|
|
|
if (err < 0)
|
|
|
|
goto err_out_free;
|
|
|
|
|
2005-09-15 07:01:53 +00:00
|
|
|
input_dev->name = ir->name;
|
|
|
|
input_dev->phys = ir->phys;
|
|
|
|
input_dev->id.bustype = BUS_PCI;
|
|
|
|
input_dev->id.version = 1;
|
2006-01-09 17:25:25 +00:00
|
|
|
if (btv->c.pci->subsystem_vendor) {
|
|
|
|
input_dev->id.vendor = btv->c.pci->subsystem_vendor;
|
|
|
|
input_dev->id.product = btv->c.pci->subsystem_device;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2006-01-09 17:25:25 +00:00
|
|
|
input_dev->id.vendor = btv->c.pci->vendor;
|
|
|
|
input_dev->id.product = btv->c.pci->device;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-07-16 12:28:15 +00:00
|
|
|
input_dev->dev.parent = &btv->c.pci->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
btv->remote = ir;
|
2006-11-20 13:23:04 +00:00
|
|
|
bttv_ir_start(btv, ir);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* all done */
|
2009-12-14 03:16:55 +00:00
|
|
|
err = ir_input_register(btv->remote->dev, ir_codes, NULL);
|
2006-11-20 13:23:04 +00:00
|
|
|
if (err)
|
|
|
|
goto err_out_stop;
|
2005-11-14 00:07:52 +00:00
|
|
|
|
|
|
|
/* the remote isn't as bouncy as a keyboard */
|
2006-01-09 17:25:25 +00:00
|
|
|
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:
|
|
|
|
bttv_ir_stop(btv);
|
|
|
|
btv->remote = NULL;
|
|
|
|
err_out_free:
|
|
|
|
kfree(ir);
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-09 17:25:25 +00:00
|
|
|
void bttv_input_fini(struct bttv *btv)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-01-09 17:25:25 +00:00
|
|
|
if (btv->remote == NULL)
|
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-11-20 13:23:04 +00:00
|
|
|
bttv_ir_stop(btv);
|
2009-12-11 12:47:42 +00:00
|
|
|
ir_input_unregister(btv->remote->dev);
|
2006-01-09 17:25:25 +00:00
|
|
|
kfree(btv->remote);
|
|
|
|
btv->remote = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|