Skip to content

Commit

Permalink
[PATCH] v4l: (935) Moved common IR stuff to ir-common.c
Browse files Browse the repository at this point in the history
- The pinnacle handler & remote are common to saa7134 PCI boards and em28xx
  USB boards, so the keymap was moved to ir-common and the keyhandler is back
  to ir-kbd-i2c

- request_module("ir-kbd-i2c") is no longer necessary at saa7134-core since
  saa7134.ko now depends on ir-kbd-i2c.ko to get the keyhandler

Signed-off-by: Ricardo Cerqueira <v4l@cerqueira.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Ricardo Cerqueira authored and Linus Torvalds committed Nov 14, 2005
1 parent 800d3c6 commit 8069695
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 111 deletions.
60 changes: 60 additions & 0 deletions drivers/media/common/ir-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,66 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
};
EXPORT_SYMBOL_GPL(ir_codes_winfast);

IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
[ 0x59 ] = KEY_MUTE,
[ 0x4a ] = KEY_POWER,

[ 0x18 ] = KEY_TEXT,
[ 0x26 ] = KEY_TV,
[ 0x3d ] = KEY_PRINT,

[ 0x48 ] = KEY_RED,
[ 0x04 ] = KEY_GREEN,
[ 0x11 ] = KEY_YELLOW,
[ 0x00 ] = KEY_BLUE,

[ 0x2d ] = KEY_VOLUMEUP,
[ 0x1e ] = KEY_VOLUMEDOWN,

[ 0x49 ] = KEY_MENU,

[ 0x16 ] = KEY_CHANNELUP,
[ 0x17 ] = KEY_CHANNELDOWN,

[ 0x20 ] = KEY_UP,
[ 0x21 ] = KEY_DOWN,
[ 0x22 ] = KEY_LEFT,
[ 0x23 ] = KEY_RIGHT,
[ 0x0d ] = KEY_SELECT,



[ 0x08 ] = KEY_BACK,
[ 0x07 ] = KEY_REFRESH,

[ 0x2f ] = KEY_ZOOM,
[ 0x29 ] = KEY_RECORD,

[ 0x4b ] = KEY_PAUSE,
[ 0x4d ] = KEY_REWIND,
[ 0x2e ] = KEY_PLAY,
[ 0x4e ] = KEY_FORWARD,
[ 0x53 ] = KEY_PREVIOUS,
[ 0x4c ] = KEY_STOP,
[ 0x54 ] = KEY_NEXT,

[ 0x69 ] = KEY_KP0,
[ 0x6a ] = KEY_KP1,
[ 0x6b ] = KEY_KP2,
[ 0x6c ] = KEY_KP3,
[ 0x6d ] = KEY_KP4,
[ 0x6e ] = KEY_KP5,
[ 0x6f ] = KEY_KP6,
[ 0x70 ] = KEY_KP7,
[ 0x71 ] = KEY_KP8,
[ 0x72 ] = KEY_KP9,

[ 0x74 ] = KEY_CHANNEL,
[ 0x0a ] = KEY_BACKSPACE,
};

EXPORT_SYMBOL_GPL(ir_codes_pinnacle);

/* empty keytable, can be used as placeholder for not-yet created keytables */
IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
[ 42 ] = KEY_COFFEE,
Expand Down
52 changes: 52 additions & 0 deletions drivers/media/video/ir-kbd-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,58 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
return 1;
}

/* The new pinnacle PCTV remote (with the colored buttons)
*
* Ricardo Cerqueira <v4l@cerqueira.org>
*/

int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
{
unsigned char b[4];
unsigned int start = 0,parity = 0,code = 0;

/* poll IR chip */
if (4 != i2c_master_recv(&ir->c,b,4)) {
dprintk(2,"read error\n");
return -EIO;
}

for (start = 0; start<4; start++) {
if (b[start] == 0x80) {
code=b[(start+3)%4];
parity=b[(start+2)%4];
}
}

/* Empty Request */
if (parity==0)
return 0;

/* Repeating... */
if (ir->old == parity)
return 0;


ir->old = parity;

/* Reduce code value to fit inside IR_KEYTAB_SIZE
*
* this is the only value that results in 42 unique
* codes < 128
*/

code %= 0x88;

*ir_raw = code;
*ir_key = code;

dprintk(1,"Pinnacle PCTV key %02x\n", code);

return 1;
}

EXPORT_SYMBOL_GPL(get_key_pinnacle);

/* ----------------------------------------------------------------------- */

static void ir_key_poll(struct IR_i2c *ir)
Expand Down
2 changes: 0 additions & 2 deletions drivers/media/video/saa7134/saa7134-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,6 @@ static int saa7134_hwinit2(struct saa7134_dev *dev)
irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 |
SAA7134_IRQ2_INTE_GPIO18A |
SAA7134_IRQ2_INTE_GPIO16 );
else if (dev->has_remote == SAA7134_REMOTE_I2C)
request_module("ir-kbd-i2c");

saa_writel(SAA7134_IRQ1, 0);
saa_writel(SAA7134_IRQ2, irq2_mask);
Expand Down
109 changes: 0 additions & 109 deletions drivers/media/video/saa7134/saa7134-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,64 +485,6 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {

};

static IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
[ 0x59 ] = KEY_MUTE,
[ 0x4a ] = KEY_POWER,

[ 0x18 ] = KEY_TEXT,
[ 0x26 ] = KEY_TV,
[ 0x3d ] = KEY_PRINT,

[ 0x48 ] = KEY_RED,
[ 0x04 ] = KEY_GREEN,
[ 0x11 ] = KEY_YELLOW,
[ 0x00 ] = KEY_BLUE,

[ 0x2d ] = KEY_VOLUMEUP,
[ 0x1e ] = KEY_VOLUMEDOWN,

[ 0x49 ] = KEY_MENU,

[ 0x16 ] = KEY_CHANNELUP,
[ 0x17 ] = KEY_CHANNELDOWN,

[ 0x20 ] = KEY_UP,
[ 0x21 ] = KEY_DOWN,
[ 0x22 ] = KEY_LEFT,
[ 0x23 ] = KEY_RIGHT,
[ 0x0d ] = KEY_SELECT,



[ 0x08 ] = KEY_BACK,
[ 0x07 ] = KEY_REFRESH,

[ 0x2f ] = KEY_ZOOM,
[ 0x29 ] = KEY_RECORD,

[ 0x4b ] = KEY_PAUSE,
[ 0x4d ] = KEY_REWIND,
[ 0x2e ] = KEY_PLAY,
[ 0x4e ] = KEY_FORWARD,
[ 0x53 ] = KEY_PREVIOUS,
[ 0x4c ] = KEY_STOP,
[ 0x54 ] = KEY_NEXT,

[ 0x69 ] = KEY_KP0,
[ 0x6a ] = KEY_KP1,
[ 0x6b ] = KEY_KP2,
[ 0x6c ] = KEY_KP3,
[ 0x6d ] = KEY_KP4,
[ 0x6e ] = KEY_KP5,
[ 0x6f ] = KEY_KP6,
[ 0x70 ] = KEY_KP7,
[ 0x71 ] = KEY_KP8,
[ 0x72 ] = KEY_KP9,

[ 0x74 ] = KEY_CHANNEL,
[ 0x0a ] = KEY_BACKSPACE,
};

/* Mapping for the 28 key remote control as seen at
http://www.sednacomputer.com/photo/cardbus-tv.jpg
Pavel Mihaylov <bin@bash.info> */
Expand Down Expand Up @@ -635,57 +577,6 @@ static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
return 1;
}

/* The new pinnacle PCTV remote (with the colored buttons)
*
* Ricardo Cerqueira <v4l@cerqueira.org>
*/

static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
{
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<4; start++) {
if (b[start] == 0x80) {
code=b[(start+3)%4];
parity=b[(start+2)%4];
}
}

/* Empty Request */
if (parity==0)
return 0;

/* Repeating... */
if (ir->old == parity)
return 0;


ir->old = parity;

/* Reduce code value to fit inside IR_KEYTAB_SIZE
*
* this is the only value that results in 42 unique
* codes < 128
*/

code %= 0x88;

*ir_raw = code;
*ir_key = code;

i2cdprintk("Pinnacle PCTV key %02x\n", code);

return 1;
}


void saa7134_input_irq(struct saa7134_dev *dev)
{
struct saa7134_ir *ir = dev->remote;
Expand Down
1 change: 1 addition & 0 deletions include/media/ir-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct ir_input_state {

extern IR_KEYTAB_TYPE ir_codes_rc5_tv[IR_KEYTAB_SIZE];
extern IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE];
extern IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE];
extern IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE];
extern IR_KEYTAB_TYPE ir_codes_hauppauge_new[IR_KEYTAB_SIZE];
extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE];
Expand Down
2 changes: 2 additions & 0 deletions include/media/ir-kbd-i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ struct IR_i2c {
char phys[32];
int (*get_key)(struct IR_i2c*, u32*, u32*);
};

int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
#endif

0 comments on commit 8069695

Please sign in to comment.