aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Toth <stoth@kernellabs.com>2011-10-10 10:09:55 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-10-14 16:18:50 -0400
commit33cdeb35f559270d2c51ed641df69a9ac659bc22 (patch)
treea999889d3b58f38f3fd0c1659a8dc3fcb216becb
parent8304be888c55b501b93907177e683db62d4000c0 (diff)
[media] cx23885: Enable audio line in support from the back panel
Add code to program the flatiron internal i2c ADC and pass the appropriate audio mux enums to the cx25840 driver. Signed-off-by: Steven Toth <stoth@kernellabs.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c3
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c76
2 files changed, 79 insertions, 0 deletions
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 75d77c2db5c9..969a9a336ac8 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -106,12 +106,14 @@ struct cx23885_board cx23885_boards[] = {
106 .vmux = CX25840_VIN7_CH3 | 106 .vmux = CX25840_VIN7_CH3 |
107 CX25840_VIN5_CH2 | 107 CX25840_VIN5_CH2 |
108 CX25840_VIN2_CH1, 108 CX25840_VIN2_CH1,
109 .amux = CX25840_AUDIO8,
109 .gpio0 = 0, 110 .gpio0 = 0,
110 }, { 111 }, {
111 .type = CX23885_VMUX_COMPOSITE1, 112 .type = CX23885_VMUX_COMPOSITE1,
112 .vmux = CX25840_VIN7_CH3 | 113 .vmux = CX25840_VIN7_CH3 |
113 CX25840_VIN4_CH2 | 114 CX25840_VIN4_CH2 |
114 CX25840_VIN6_CH1, 115 CX25840_VIN6_CH1,
116 .amux = CX25840_AUDIO7,
115 .gpio0 = 0, 117 .gpio0 = 0,
116 }, { 118 }, {
117 .type = CX23885_VMUX_SVIDEO, 119 .type = CX23885_VMUX_SVIDEO,
@@ -119,6 +121,7 @@ struct cx23885_board cx23885_boards[] = {
119 CX25840_VIN4_CH2 | 121 CX25840_VIN4_CH2 |
120 CX25840_VIN8_CH1 | 122 CX25840_VIN8_CH1 |
121 CX25840_SVIDEO_ON, 123 CX25840_SVIDEO_ON,
124 .amux = CX25840_AUDIO7,
122 .gpio0 = 0, 125 .gpio0 = 0,
123 } }, 126 } },
124 }, 127 },
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 44a63c4de122..adc8f78d4c58 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -417,6 +417,71 @@ static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh,
417 mutex_unlock(&dev->lock); 417 mutex_unlock(&dev->lock);
418} 418}
419 419
420static int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data)
421{
422 /* 8 bit registers, 8 bit values */
423 u8 buf[] = { reg, data };
424
425 struct i2c_msg msg = { .addr = 0x98 >> 1,
426 .flags = 0, .buf = buf, .len = 2 };
427
428 return i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg, 1);
429}
430
431static u8 cx23885_flatiron_read(struct cx23885_dev *dev, u8 reg)
432{
433 /* 8 bit registers, 8 bit values */
434 int ret;
435 u8 b0[] = { reg };
436 u8 b1[] = { 0 };
437
438 struct i2c_msg msg[] = {
439 { .addr = 0x98 >> 1, .flags = 0, .buf = b0, .len = 1 },
440 { .addr = 0x98 >> 1, .flags = I2C_M_RD, .buf = b1, .len = 1 }
441 };
442
443 ret = i2c_transfer(&dev->i2c_bus[2].i2c_adap, &msg[0], 2);
444 if (ret != 2)
445 printk(KERN_ERR "%s() error\n", __func__);
446
447 return b1[0];
448}
449
450static void cx23885_flatiron_dump(struct cx23885_dev *dev)
451{
452 int i;
453 dprintk(1, "Flatiron dump\n");
454 for (i = 0; i < 0x24; i++) {
455 dprintk(1, "FI[%02x] = %02x\n", i,
456 cx23885_flatiron_read(dev, i));
457 }
458}
459
460static int cx23885_flatiron_mux(struct cx23885_dev *dev, int input)
461{
462 u8 val;
463 dprintk(1, "%s(input = %d)\n", __func__, input);
464
465 if (input == 1)
466 val = cx23885_flatiron_read(dev, CH_PWR_CTRL1) & ~FLD_CH_SEL;
467 else if (input == 2)
468 val = cx23885_flatiron_read(dev, CH_PWR_CTRL1) | FLD_CH_SEL;
469 else
470 return -EINVAL;
471
472 val |= 0x20; /* Enable clock to delta-sigma and dec filter */
473
474 cx23885_flatiron_write(dev, CH_PWR_CTRL1, val);
475
476 /* Wake up */
477 cx23885_flatiron_write(dev, CH_PWR_CTRL2, 0);
478
479 if (video_debug)
480 cx23885_flatiron_dump(dev);
481
482 return 0;
483}
484
420static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) 485static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
421{ 486{
422 dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", 487 dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n",
@@ -437,6 +502,17 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
437 v4l2_subdev_call(dev->sd_cx25840, video, s_routing, 502 v4l2_subdev_call(dev->sd_cx25840, video, s_routing,
438 INPUT(input)->vmux, 0, 0); 503 INPUT(input)->vmux, 0, 0);
439 504
505 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1800) {
506 /* Configure audio routing */
507 v4l2_subdev_call(dev->sd_cx25840, audio, s_routing,
508 INPUT(input)->amux, 0, 0);
509
510 if (INPUT(input)->amux == CX25840_AUDIO7)
511 cx23885_flatiron_mux(dev, 1);
512 else if (INPUT(input)->amux == CX25840_AUDIO6)
513 cx23885_flatiron_mux(dev, 2);
514 }
515
440 return 0; 516 return 0;
441} 517}
442 518