aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/bt8xx
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-09-22 22:24:04 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:06:07 -0400
commitc0c46826274a4da5d9e312d7cfd4ca0806c0a358 (patch)
treee3237889f6ee931f674f46ce72f1844796899b77 /drivers/media/video/bt8xx
parent8403472f19fea7e7cec7899e998f38b899e59604 (diff)
V4L/DVB: bttv: Move PV951 IR to the right driver
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/bt8xx')
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c38
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c84
-rw-r--r--drivers/media/video/bt8xx/bttv.h1
-rw-r--r--drivers/media/video/bt8xx/bttvp.h13
4 files changed, 87 insertions, 49 deletions
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 685d6597ee79..d502f4106e56 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -390,41 +390,3 @@ int __devinit init_bttv_i2c(struct bttv *btv)
390 390
391 return btv->i2c_rc; 391 return btv->i2c_rc;
392} 392}
393
394/* Instantiate the I2C IR receiver device, if present */
395void __devinit init_bttv_i2c_ir(struct bttv *btv)
396{
397 if (0 == btv->i2c_rc) {
398 struct i2c_board_info info;
399 /* The external IR receiver is at i2c address 0x34 (0x35 for
400 reads). Future Hauppauge cards will have an internal
401 receiver at 0x30 (0x31 for reads). In theory, both can be
402 fitted, and Hauppauge suggest an external overrides an
403 internal.
404
405 That's why we probe 0x1a (~0x34) first. CB
406 */
407 const unsigned short addr_list[] = {
408 0x1a, 0x18, 0x4b, 0x64, 0x30, 0x71,
409 I2C_CLIENT_END
410 };
411
412 memset(&info, 0, sizeof(struct i2c_board_info));
413 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
414 i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
415 }
416}
417
418int __devexit fini_bttv_i2c(struct bttv *btv)
419{
420 if (0 != btv->i2c_rc)
421 return 0;
422
423 return i2c_del_adapter(&btv->c.i2c_adap);
424}
425
426/*
427 * Local variables:
428 * c-basic-offset: 8
429 * End:
430 */
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index f68717a4bdec..6bf05a7dc5f9 100644
--- a/drivers/media/video/bt8xx/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
@@ -245,6 +245,83 @@ static void bttv_ir_stop(struct bttv *btv)
245 } 245 }
246} 246}
247 247
248/*
249 * Get_key functions used by I2C remotes
250 */
251
252static int get_key_pv951(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
253{
254 unsigned char b;
255
256 /* poll IR chip */
257 if (1 != i2c_master_recv(ir->c, &b, 1)) {
258 dprintk(KERN_INFO DEVNAME ": read error\n");
259 return -EIO;
260 }
261
262 /* ignore 0xaa */
263 if (b==0xaa)
264 return 0;
265 dprintk(KERN_INFO DEVNAME ": key %02x\n", b);
266
267 *ir_key = b;
268 *ir_raw = b;
269 return 1;
270}
271
272/* Instantiate the I2C IR receiver device, if present */
273void __devinit init_bttv_i2c_ir(struct bttv *btv)
274{
275 const unsigned short addr_list[] = {
276 0x1a, 0x18, 0x64, 0x30, 0x71,
277 I2C_CLIENT_END
278 };
279 struct i2c_board_info info;
280
281 if (0 != btv->i2c_rc)
282 return;
283
284 memset(&info, 0, sizeof(struct i2c_board_info));
285 memset(&btv->init_data, 0, sizeof(btv->init_data));
286 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
287
288 switch (btv->c.type) {
289 case BTTV_BOARD_PV951:
290 btv->init_data.name = "PV951";
291 btv->init_data.get_key = get_key_pv951;
292 btv->init_data.ir_codes = RC_MAP_PV951;
293 btv->init_data.type = IR_TYPE_OTHER;
294 info.addr = 0x4b;
295 break;
296 default:
297 /*
298 * The external IR receiver is at i2c address 0x34 (0x35 for
299 * reads). Future Hauppauge cards will have an internal
300 * receiver at 0x30 (0x31 for reads). In theory, both can be
301 * fitted, and Hauppauge suggest an external overrides an
302 * internal.
303 * That's why we probe 0x1a (~0x34) first. CB
304 */
305
306 i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
307 return;
308 }
309
310 if (btv->init_data.name)
311 info.platform_data = &btv->init_data;
312 i2c_new_device(&btv->c.i2c_adap, &info);
313
314 return;
315}
316
317int __devexit fini_bttv_i2c(struct bttv *btv)
318{
319 if (0 != btv->i2c_rc)
320 return 0;
321
322 return i2c_del_adapter(&btv->c.i2c_adap);
323}
324
248int bttv_input_init(struct bttv *btv) 325int bttv_input_init(struct bttv *btv)
249{ 326{
250 struct card_ir *ir; 327 struct card_ir *ir;
@@ -420,10 +497,3 @@ void bttv_input_fini(struct bttv *btv)
420 kfree(btv->remote); 497 kfree(btv->remote);
421 btv->remote = NULL; 498 btv->remote = NULL;
422} 499}
423
424
425/*
426 * Local variables:
427 * c-basic-offset: 8
428 * End:
429 */
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h
index 3ec2402c6b4a..6fd2a8ebda1e 100644
--- a/drivers/media/video/bt8xx/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -18,7 +18,6 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <media/v4l2-device.h> 19#include <media/v4l2-device.h>
20#include <media/ir-common.h> 20#include <media/ir-common.h>
21#include <media/ir-kbd-i2c.h>
22#include <media/i2c-addr.h> 21#include <media/i2c-addr.h>
23#include <media/tuner.h> 22#include <media/tuner.h>
24 23
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 6cccc2a17eee..d1e26a448ed2 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -42,7 +42,7 @@
42#include <media/videobuf-dma-sg.h> 42#include <media/videobuf-dma-sg.h>
43#include <media/tveeprom.h> 43#include <media/tveeprom.h>
44#include <media/ir-common.h> 44#include <media/ir-common.h>
45 45#include <media/ir-kbd-i2c.h>
46 46
47#include "bt848.h" 47#include "bt848.h"
48#include "bttv.h" 48#include "bttv.h"
@@ -271,6 +271,12 @@ int bttv_sub_del_devices(struct bttv_core *core);
271extern int no_overlay; 271extern int no_overlay;
272 272
273/* ---------------------------------------------------------- */ 273/* ---------------------------------------------------------- */
274/* bttv-input.c */
275
276extern void init_bttv_i2c_ir(struct bttv *btv);
277extern int fini_bttv_i2c(struct bttv *btv);
278
279/* ---------------------------------------------------------- */
274/* bttv-driver.c */ 280/* bttv-driver.c */
275 281
276/* insmod options */ 282/* insmod options */
@@ -279,8 +285,6 @@ extern unsigned int bttv_debug;
279extern unsigned int bttv_gpio; 285extern unsigned int bttv_gpio;
280extern void bttv_gpio_tracking(struct bttv *btv, char *comment); 286extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
281extern int init_bttv_i2c(struct bttv *btv); 287extern int init_bttv_i2c(struct bttv *btv);
282extern void init_bttv_i2c_ir(struct bttv *btv);
283extern int fini_bttv_i2c(struct bttv *btv);
284 288
285#define bttv_printk if (bttv_verbose) printk 289#define bttv_printk if (bttv_verbose) printk
286#define dprintk if (bttv_debug >= 1) printk 290#define dprintk if (bttv_debug >= 1) printk
@@ -366,6 +370,9 @@ struct bttv {
366 int has_remote; 370 int has_remote;
367 struct card_ir *remote; 371 struct card_ir *remote;
368 372
373 /* I2C remote data */
374 struct IR_i2c_init_data init_data;
375
369 /* locking */ 376 /* locking */
370 spinlock_t s_lock; 377 spinlock_t s_lock;
371 struct mutex lock; 378 struct mutex lock;