aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@brturbo.com.br>2005-11-09 00:37:32 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:18 -0500
commitd5e5265315770bda46c50ecaa64e2b9790f2064c (patch)
tree5c92fa1125dee3f766bd06f18840ce78bf0cd861 /drivers/media/video/em28xx
parentda45a2a5b96afd7188c058a55eb2917d6524c0cf (diff)
[PATCH] v4l: 784: several improvement on i2c ir handling for em2820
- Several Improvement on I2C IR handling for em2820: - moved Pinnacle IR table (ir_codes_em2820) to em2820-input.c - IR struct renamed and moved to a header file. - New file to handle em2820-specific IR. - Some cleanups. - attach now detects I2C IR and calls em2820-specific IR code - IR compat code moved to compat.h - New header with struct IR_i2c there, to allow it to be used by board-specific input handlers. - Some improvements at em28xx board detection: - Board detection message improved to show interface and class. - Now it doesn't touch audio interfaces. 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>
Diffstat (limited to 'drivers/media/video/em28xx')
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c3
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c43
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c150
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c15
-rw-r--r--drivers/media/video/em28xx/em28xx.h20
5 files changed, 196 insertions, 35 deletions
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 91c70ebd0ea4..919520f89975 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -143,7 +143,7 @@ struct em2820_board em2820_boards[] = {
143 .tuner_type = TUNER_PHILIPS_PAL, 143 .tuner_type = TUNER_PHILIPS_PAL,
144 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE, 144 .tda9887_conf = TDA9887_PRESENT|TDA9887_PORT1_ACTIVE|TDA9887_PORT2_ACTIVE,
145 .has_tuner = 1, 145 .has_tuner = 1,
146 .decoder = EM2820_SAA7114, 146 .decoder = EM2820_SAA7114,
147 .input = {{ 147 .input = {{
148 .type = EM2820_VMUX_TELEVISION, 148 .type = EM2820_VMUX_TELEVISION,
149 .vmux = 2, 149 .vmux = 2,
@@ -250,6 +250,7 @@ void em2820_card_setup(struct em2820 *dev)
250 struct tveeprom tv; 250 struct tveeprom tv;
251#ifdef CONFIG_MODULES 251#ifdef CONFIG_MODULES
252 request_module("tveeprom"); 252 request_module("tveeprom");
253 request_module("ir-kbd-i2c");
253#endif 254#endif
254 /* Call first TVeeprom */ 255 /* Call first TVeeprom */
255 256
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index a7b6f678f979..f6bfc038777e 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -26,10 +26,10 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <media/tuner.h>
30#include <linux/video_decoder.h> 29#include <linux/video_decoder.h>
31 30
32#include "em2820.h" 31#include "em2820.h"
32#include <media/tuner.h>
33 33
34/* ----------------------------------------------------------- */ 34/* ----------------------------------------------------------- */
35 35
@@ -41,14 +41,11 @@ static unsigned int i2c_debug = 0;
41module_param(i2c_debug, int, 0644); 41module_param(i2c_debug, int, 0644);
42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); 42MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
43 43
44#define dprintk(fmt, args...) if (i2c_debug) do {\ 44#define dprintk1(lvl,fmt, args...) if (i2c_debug>=lvl) do {\
45 printk(KERN_DEBUG "%s: %s: " fmt "\n",\
46 dev->name, __FUNCTION__ , ##args); } while (0)
47#define dprintk1(fmt, args...) if (i2c_debug) do{ \
48 printk(KERN_DEBUG "%s: %s: " fmt, \
49 dev->name, __FUNCTION__ , ##args); } while (0)
50#define dprintk2(fmt, args...) if (i2c_debug) do {\
51 printk(fmt , ##args); } while (0) 45 printk(fmt , ##args); } while (0)
46#define dprintk2(lvl,fmt, args...) if (i2c_debug>=lvl) do{ \
47 printk(KERN_DEBUG "%s at %s: " fmt, \
48 dev->name, __FUNCTION__ , ##args); } while (0)
52 49
53/* 50/*
54 * em2800_i2c_send_max4() 51 * em2800_i2c_send_max4()
@@ -238,7 +235,7 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
238 return 0; 235 return 0;
239 for (i = 0; i < num; i++) { 236 for (i = 0; i < num; i++) {
240 addr = msgs[i].addr << 1; 237 addr = msgs[i].addr << 1;
241 dprintk1("%s %s addr=%x len=%d:", 238 dprintk2(2,"%s %s addr=%x len=%d:",
242 (msgs[i].flags & I2C_M_RD) ? "read" : "write", 239 (msgs[i].flags & I2C_M_RD) ? "read" : "write",
243 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); 240 i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len);
244 if (!msgs[i].len) { /* no len: check only for device presence */ 241 if (!msgs[i].len) { /* no len: check only for device presence */
@@ -247,7 +244,7 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
247 else 244 else
248 rc = em2820_i2c_check_for_device(dev, addr); 245 rc = em2820_i2c_check_for_device(dev, addr);
249 if (rc < 0) { 246 if (rc < 0) {
250 dprintk2(" no device\n"); 247 dprintk2(2," no device\n");
251 return rc; 248 return rc;
252 } 249 }
253 250
@@ -261,14 +258,14 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
261 rc = em2820_i2c_recv_bytes(dev, addr, 258 rc = em2820_i2c_recv_bytes(dev, addr,
262 msgs[i].buf, 259 msgs[i].buf,
263 msgs[i].len); 260 msgs[i].len);
264 if (i2c_debug) { 261 if (i2c_debug>=2) {
265 for (byte = 0; byte < msgs[i].len; byte++) { 262 for (byte = 0; byte < msgs[i].len; byte++) {
266 printk(" %02x", msgs[i].buf[byte]); 263 printk(" %02x", msgs[i].buf[byte]);
267 } 264 }
268 } 265 }
269 } else { 266 } else {
270 /* write bytes */ 267 /* write bytes */
271 if (i2c_debug) { 268 if (i2c_debug>=2) {
272 for (byte = 0; byte < msgs[i].len; byte++) 269 for (byte = 0; byte < msgs[i].len; byte++)
273 printk(" %02x", msgs[i].buf[byte]); 270 printk(" %02x", msgs[i].buf[byte]);
274 } 271 }
@@ -284,13 +281,13 @@ static int em2820_i2c_xfer(struct i2c_adapter *i2c_adap,
284 if (rc < 0) 281 if (rc < 0)
285 goto err; 282 goto err;
286 } 283 }
287 if (i2c_debug) 284 if (i2c_debug>=2)
288 printk("\n"); 285 printk("\n");
289 } 286 }
290 287
291 return num; 288 return num;
292 err: 289 err:
293 dprintk2(" ERROR: %i\n", rc); 290 dprintk2(2," ERROR: %i\n", rc);
294 return rc; 291 return rc;
295} 292}
296 293
@@ -436,26 +433,34 @@ static int attach_inform(struct i2c_client *client)
436{ 433{
437 struct em2820 *dev = client->adapter->algo_data; 434 struct em2820 *dev = client->adapter->algo_data;
438 435
439 dprintk("address %x", client->addr << 1);
440 switch (client->addr << 1) { 436 switch (client->addr << 1) {
441 case 0x86: 437 case 0x86:
442 em2820_i2c_call_clients(dev, TDA9887_SET_CONFIG, &dev->tda9887_conf); 438 em2820_i2c_call_clients(dev, TDA9887_SET_CONFIG, &dev->tda9887_conf);
443 break; 439 break;
444 case 0x4a: 440 case 0x4a:
445 dprintk1("attach_inform: saa7113 detected.\n"); 441 dprintk1(1,"attach_inform: saa7113 detected.\n");
446 break; 442 break;
447 case 0xa0: 443 case 0xa0:
448 dprintk1("attach_inform: eeprom detected.\n"); 444 dprintk1(1,"attach_inform: eeprom detected.\n");
445 break;
446 case 0x60:
447 case 0x8e:
448 {
449 struct IR_i2c *ir = i2c_get_clientdata(client);
450 dprintk1(1,"attach_inform: IR detected (%s).\n",ir->phys);
451 em2820_set_ir(dev,ir);
449 break; 452 break;
453 }
450 case 0x80: 454 case 0x80:
451 case 0x88: 455 case 0x88:
452 dprintk1("attach_inform: msp34xx detected.\n"); 456 dprintk1(1,"attach_inform: msp34xx detected.\n");
453 break; 457 break;
454 case 0xb8: 458 case 0xb8:
455 case 0xba: 459 case 0xba:
456 dprintk1("attach_inform: tvp5150 detected.\n"); 460 dprintk1(1,"attach_inform: tvp5150 detected.\n");
457 break; 461 break;
458 default: 462 default:
463 dprintk1(1,"attach inform: detected I2C address %x\n", client->addr << 1);
459 dev->tuner_addr = client->addr; 464 dev->tuner_addr = client->addr;
460 em2820_set_tuner(-1, client); 465 em2820_set_tuner(-1, client);
461 } 466 }
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
new file mode 100644
index 000000000000..d6b3e15a0350
--- /dev/null
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -0,0 +1,150 @@
1/*
2 *
3 * handle saa7134 IR remotes via linux kernel input layer.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 */
20
21#include <linux/module.h>
22#include <linux/moduleparam.h>
23#include <linux/init.h>
24#include <linux/delay.h>
25#include <linux/sched.h>
26#include <linux/interrupt.h>
27#include <linux/input.h>
28#include <linux/usb.h>
29
30#include "em2820.h"
31
32static unsigned int disable_ir = 0;
33module_param(disable_ir, int, 0444);
34MODULE_PARM_DESC(disable_ir,"disable infrared remote support");
35
36static unsigned int ir_debug = 0;
37module_param(ir_debug, int, 0644);
38MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]");
39
40#define dprintk(fmt, arg...) if (ir_debug) \
41 printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg)
42
43/* ---------------------------------------------------------------------- */
44
45static IR_KEYTAB_TYPE ir_codes_em_pinnacle[IR_KEYTAB_SIZE] = {
46 [ 0 ] = KEY_CHANNEL,
47 [ 1 ] = KEY_SELECT,
48 [ 2 ] = KEY_MUTE,
49 [ 3 ] = KEY_POWER,
50 [ 4 ] = KEY_KP1,
51 [ 5 ] = KEY_KP2,
52 [ 6 ] = KEY_KP3,
53 [ 7 ] = KEY_CHANNELUP,
54 [ 8 ] = KEY_KP4,
55 [ 9 ] = KEY_KP5,
56 [ 10 ] = KEY_KP6,
57
58 [ 11 ] = KEY_CHANNELDOWN,
59 [ 12 ] = KEY_KP7,
60 [ 13 ] = KEY_KP8,
61 [ 14 ] = KEY_KP9,
62 [ 15 ] = KEY_VOLUMEUP,
63 [ 16 ] = KEY_KP0,
64 [ 17 ] = KEY_MENU,
65 [ 18 ] = KEY_PRINT,
66
67 [ 19 ] = KEY_VOLUMEDOWN,
68 [ 21 ] = KEY_PAUSE,
69 [ 23 ] = KEY_RECORD,
70 [ 24 ] = KEY_REWIND,
71 [ 25 ] = KEY_PLAY,
72 [ 27 ] = KEY_BACKSPACE,
73 [ 29 ] = KEY_STOP,
74 [ 31 ] = KEY_ZOOM,
75};
76
77/* ----------------------------------------------------------------------- */
78
79static int get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
80{
81 unsigned char buf[2];
82 unsigned char code;
83
84 /* poll IR chip */
85 if (2 != i2c_master_recv(&ir->c,buf,2))
86 return -EIO;
87
88 /* Does eliminate repeated parity code */
89 if (buf[1]==0xff)
90 return 0;
91
92 /* avoid fast reapeating */
93 if (buf[1]==ir->old)
94 return 0;
95 ir->old=buf[1];
96
97 /* Rearranges bits to the right order */
98 code= ((buf[0]&0x01)<<5) | /* 0010 0000 */
99 ((buf[0]&0x02)<<3) | /* 0001 0000 */
100 ((buf[0]&0x04)<<1) | /* 0000 1000 */
101 ((buf[0]&0x08)>>1) | /* 0000 0100 */
102 ((buf[0]&0x10)>>3) | /* 0000 0010 */
103 ((buf[0]&0x20)>>5); /* 0000 0001 */
104
105 dprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n",code,buf[0]);
106
107 /* return key */
108 *ir_key = code;
109 *ir_raw = code;
110 return 1;
111}
112
113/* ----------------------------------------------------------------------- */
114void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir)
115{
116 if (disable_ir)
117 return ;
118
119 /* detect & configure */
120 switch (dev->model) {
121 case (EM2800_BOARD_UNKNOWN):
122 break;
123 case (EM2820_BOARD_UNKNOWN):
124 break;
125 case (EM2820_BOARD_TERRATEC_CINERGY_250):
126 break;
127 case (EM2820_BOARD_PINNACLE_USB_2):
128 ir->ir_codes = ir_codes_em_pinnacle;
129 break;
130 case (EM2820_BOARD_HAUPPAUGE_WINTV_USB_2):
131 ir->ir_codes = ir_codes_hauppauge_new;
132 ir->get_key = get_key_em_haup;
133 snprintf(ir->c.name, sizeof(ir->c.name), "i2c IR (EM2840 Hauppage)");
134 break;
135 case (EM2820_BOARD_MSI_VOX_USB_2):
136 break;
137 case (EM2800_BOARD_TERRATEC_CINERGY_200):
138 break;
139 case (EM2800_BOARD_LEADTEK_WINFAST_USBII):
140 break;
141 case (EM2800_BOARD_KWORLD_USB2800):
142 break;
143 }
144}
145
146/* ----------------------------------------------------------------------
147 * Local variables:
148 * c-basic-offset: 8
149 * End:
150 */
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index d3a959b9ee64..f3fc44b352b4 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -28,10 +28,10 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/usb.h> 29#include <linux/usb.h>
30#include <linux/i2c.h> 30#include <linux/i2c.h>
31#include <media/tuner.h>
32#include <linux/video_decoder.h> 31#include <linux/video_decoder.h>
33 32
34#include "em2820.h" 33#include "em2820.h"
34#include <media/tuner.h>
35 35
36#define DRIVER_AUTHOR "Markus Rechberger <mrechberger@gmail.com>, " \ 36#define DRIVER_AUTHOR "Markus Rechberger <mrechberger@gmail.com>, " \
37 "Ludovico Cavedon <cavedon@sssup.it>, " \ 37 "Ludovico Cavedon <cavedon@sssup.it>, " \
@@ -1699,15 +1699,22 @@ static int em2820_usb_probe(struct usb_interface *interface,
1699 struct usb_device *udev; 1699 struct usb_device *udev;
1700 struct em2820 *dev = NULL; 1700 struct em2820 *dev = NULL;
1701 int retval = -ENODEV; 1701 int retval = -ENODEV;
1702 int model,i,nr; 1702 int model,i,nr,ifnum;
1703 1703
1704 udev = usb_get_dev(interface_to_usbdev(interface)); 1704 udev = usb_get_dev(interface_to_usbdev(interface));
1705 endpoint = &interface->cur_altsetting->endpoint[1].desc; 1705 ifnum = interface->altsetting[0].desc.bInterfaceNumber;
1706
1707 em2820_err(DRIVER_NAME " new device (%04x:%04x): interface %i, class %i\n",
1708 udev->descriptor.idVendor,udev->descriptor.idProduct,
1709 ifnum,
1710 interface->altsetting[0].desc.bInterfaceClass);
1706 1711
1707 /* Don't register audio interfaces */ 1712 /* Don't register audio interfaces */
1708 if (interface->altsetting[1].desc.bInterfaceClass == USB_CLASS_AUDIO) 1713 if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO)
1709 return -ENODEV; 1714 return -ENODEV;
1710 1715
1716 endpoint = &interface->cur_altsetting->endpoint[1].desc;
1717
1711 /* check if the the device has the iso in endpoint at the correct place */ 1718 /* check if the the device has the iso in endpoint at the correct place */
1712 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != 1719 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
1713 USB_ENDPOINT_XFER_ISOC) { 1720 USB_ENDPOINT_XFER_ISOC) {
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 4115938a1731..31b23f0db051 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -27,6 +27,7 @@
27 27
28#include <linux/videodev.h> 28#include <linux/videodev.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <media/ir-kbd-i2c.h>
30 31
31/* Boards supported by driver */ 32/* Boards supported by driver */
32 33
@@ -53,19 +54,12 @@
53/* number of buffers for isoc transfers */ 54/* number of buffers for isoc transfers */
54#define EM2820_NUM_BUFS 5 55#define EM2820_NUM_BUFS 5
55 56
56/* number of packets for each buffer */ 57/* number of packets for each buffer
57// windows requests only 40 packets .. so we better do the same 58 windows requests only 40 packets .. so we better do the same
58// this is what I found out for all alternate numbers there! 59 this is what I found out for all alternate numbers there!
59 60 */
60#define EM2820_NUM_PACKETS 40 61#define EM2820_NUM_PACKETS 40
61 62
62/* packet size for each packet */
63/* no longer needed: read from endpoint descriptor */
64//#define EM2820_MAX_PACKET_SIZE 3072 //7
65//#define EM2820_MAX_PACKET_SIZE 2892 //6
66//#define EM2820_MAX_PACKET_SIZE 2580 //5
67//#define EM2820_MAX_PACKET_SIZE 1448 //2
68
69/* default alternate; 0 means choose the best */ 63/* default alternate; 0 means choose the best */
70#define EM2820_PINOUT 0 64#define EM2820_PINOUT 0
71#define EM2820_MAX_ALT 7 65#define EM2820_MAX_ALT 7
@@ -292,6 +286,10 @@ void em2820_i2c_call_clients(struct em2820 *dev, unsigned int cmd, void *arg);
292int em2820_i2c_register(struct em2820 *dev); 286int em2820_i2c_register(struct em2820 *dev);
293int em2820_i2c_unregister(struct em2820 *dev); 287int em2820_i2c_unregister(struct em2820 *dev);
294 288
289/* Provided by em2820-input.c */
290
291void em2820_set_ir(struct em2820 * dev,struct IR_i2c *ir);
292
295/* Provided by em2820-core.c */ 293/* Provided by em2820-core.c */
296 294
297void em2820_print_ioctl(char *name, unsigned int cmd); 295void em2820_print_ioctl(char *name, unsigned int cmd);