aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mxb.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-04-06 21:08:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-06 21:11:41 -0400
commit4ef4327b30957a16619ac7d47c749465e62de8c3 (patch)
tree5c80e853f0d9eadd01b2019d03d2432334393c5e /drivers/media/video/mxb.c
parent3989203290fba6fdf6bc4825fbf6526e1bf17977 (diff)
parenta938b8c5be8fe5c28800c9cef4aa43d569aa57a8 (diff)
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (120 commits) cx231xx: Convert to snd_card_create() V4L/DVB (11440): PWC: fix build error when CONFIG_INPUT=m V4L/DVB (11439): UVC: uvc_status_cleanup(): undefined reference to `input_unregister_device' V4L/DVB (11438): au0828: fix Kconfig dependance V4L/DVB (11437): pvrusb2: Drop client_register/unregister stubs V4L/DVB (11436): radio-mr800: convert to to v4l2_device V4L/DVB (11435): dsbr100 radio: convert to to v4l2_device V4L/DVB: zr364xx: remove unused #include <version.h> V4L/DVB: usbvision: remove unused #include <version.h> V4L/DVB (11427): gspca - m5602: Minor cleanups V4L/DVB (11426): gspca - m5602: Don't touch hflip/vflip register on Read/Modify/Write V4L/DVB (11425): gspca - m5602: Move the vflip quirk to probe stage. V4L/DVB (11424): gspca - m5602-ov9650: Use the local ctrl cache. Adjust image on vflip. V4L/DVB (11423): gspca - m5602-ov9650: Add a disconnect hook, setup a ctrl cache ctrl. V4L/DVB (11422): gspca - m5602-ov9650: Replace a magic constant with a define V4L/DVB (11421): gspca - m5602-ov9650: Synthesize modesetting. V4L/DVB (11420): gspca - m5602: Improve error handling in the ov9650 driver V4L/DVB (11419): gspca - m5602-ov9650: Don't read exposure data from COM1. V4L/DVB (11418): gspca - m5602-ov9650: Auto white balancing is on by default V4L/DVB (11417): gspca - m5602-ov9650: Autogain is on by default ...
Diffstat (limited to 'drivers/media/video/mxb.c')
-rw-r--r--drivers/media/video/mxb.c144
1 files changed, 63 insertions, 81 deletions
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 84aec62e8452..3be5a71bdac2 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -83,9 +83,14 @@ static struct {
83static int video_audio_connect[MXB_INPUTS] = 83static int video_audio_connect[MXB_INPUTS] =
84 { 0, 1, 3, 3 }; 84 { 0, 1, 3, 3 };
85 85
86struct mxb_routing {
87 u32 input;
88 u32 output;
89};
90
86/* These are the necessary input-output-pins for bringing one audio source 91/* These are the necessary input-output-pins for bringing one audio source
87 (see above) to the CD-output. Note that gain is set to 0 in this table. */ 92 (see above) to the CD-output. Note that gain is set to 0 in this table. */
88static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = { 93static struct mxb_routing TEA6420_cd[MXB_AUDIOS + 1][2] = {
89 { { 1, 1 }, { 1, 1 } }, /* Tuner */ 94 { { 1, 1 }, { 1, 1 } }, /* Tuner */
90 { { 5, 1 }, { 6, 1 } }, /* AUX 1 */ 95 { { 5, 1 }, { 6, 1 } }, /* AUX 1 */
91 { { 4, 1 }, { 6, 1 } }, /* AUX 2 */ 96 { { 4, 1 }, { 6, 1 } }, /* AUX 2 */
@@ -97,7 +102,7 @@ static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = {
97 102
98/* These are the necessary input-output-pins for bringing one audio source 103/* These are the necessary input-output-pins for bringing one audio source
99 (see above) to the line-output. Note that gain is set to 0 in this table. */ 104 (see above) to the line-output. Note that gain is set to 0 in this table. */
100static struct v4l2_routing TEA6420_line[MXB_AUDIOS + 1][2] = { 105static struct mxb_routing TEA6420_line[MXB_AUDIOS + 1][2] = {
101 { { 2, 3 }, { 1, 2 } }, 106 { { 2, 3 }, { 1, 2 } },
102 { { 5, 3 }, { 6, 2 } }, 107 { { 5, 3 }, { 6, 2 } },
103 { { 4, 3 }, { 6, 2 } }, 108 { { 4, 3 }, { 6, 2 } },
@@ -134,10 +139,6 @@ struct mxb
134 139
135#define saa7111a_call(mxb, o, f, args...) \ 140#define saa7111a_call(mxb, o, f, args...) \
136 v4l2_subdev_call(mxb->saa7111a, o, f, ##args) 141 v4l2_subdev_call(mxb->saa7111a, o, f, ##args)
137#define tea6420_1_call(mxb, o, f, args...) \
138 v4l2_subdev_call(mxb->tea6420_1, o, f, ##args)
139#define tea6420_2_call(mxb, o, f, args...) \
140 v4l2_subdev_call(mxb->tea6420_2, o, f, ##args)
141#define tda9840_call(mxb, o, f, args...) \ 142#define tda9840_call(mxb, o, f, args...) \
142 v4l2_subdev_call(mxb->tda9840, o, f, ##args) 143 v4l2_subdev_call(mxb->tda9840, o, f, ##args)
143#define tea6415c_call(mxb, o, f, args...) \ 144#define tea6415c_call(mxb, o, f, args...) \
@@ -147,6 +148,22 @@ struct mxb
147#define call_all(dev, o, f, args...) \ 148#define call_all(dev, o, f, args...) \
148 v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args) 149 v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args)
149 150
151static inline void tea6420_route_cd(struct mxb *mxb, int idx)
152{
153 v4l2_subdev_call(mxb->tea6420_1, audio, s_routing,
154 TEA6420_cd[idx][0].input, TEA6420_cd[idx][0].output, 0);
155 v4l2_subdev_call(mxb->tea6420_2, audio, s_routing,
156 TEA6420_cd[idx][1].input, TEA6420_cd[idx][1].output, 0);
157}
158
159static inline void tea6420_route_line(struct mxb *mxb, int idx)
160{
161 v4l2_subdev_call(mxb->tea6420_1, audio, s_routing,
162 TEA6420_line[idx][0].input, TEA6420_line[idx][0].output, 0);
163 v4l2_subdev_call(mxb->tea6420_2, audio, s_routing,
164 TEA6420_line[idx][1].input, TEA6420_line[idx][1].output, 0);
165}
166
150static struct saa7146_extension extension; 167static struct saa7146_extension extension;
151 168
152static int mxb_probe(struct saa7146_dev *dev) 169static int mxb_probe(struct saa7146_dev *dev)
@@ -168,13 +185,20 @@ static int mxb_probe(struct saa7146_dev *dev)
168 return -EFAULT; 185 return -EFAULT;
169 } 186 }
170 187
171 mxb->saa7111a = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa7115", "saa7111", I2C_SAA7111A); 188 mxb->saa7111a = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
172 mxb->tea6420_1 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_1); 189 "saa7115", "saa7111", I2C_SAA7111A);
173 mxb->tea6420_2 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_2); 190 mxb->tea6420_1 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
174 mxb->tea6415c = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6415c", "tea6415c", I2C_TEA6415C); 191 "tea6420", "tea6420", I2C_TEA6420_1);
175 mxb->tda9840 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tda9840", "tda9840", I2C_TDA9840); 192 mxb->tea6420_2 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
176 mxb->tuner = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tuner", "tuner", I2C_TUNER); 193 "tea6420", "tea6420", I2C_TEA6420_2);
177 if (v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa5246a", "saa5246a", I2C_SAA5246A)) { 194 mxb->tea6415c = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
195 "tea6415c", "tea6415c", I2C_TEA6415C);
196 mxb->tda9840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
197 "tda9840", "tda9840", I2C_TDA9840);
198 mxb->tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
199 "tuner", "tuner", I2C_TUNER);
200 if (v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
201 "saa5246a", "saa5246a", I2C_SAA5246A)) {
178 printk(KERN_INFO "mxb: found teletext decoder\n"); 202 printk(KERN_INFO "mxb: found teletext decoder\n");
179 } 203 }
180 204
@@ -261,18 +285,16 @@ static int mxb_init_done(struct saa7146_dev* dev)
261 struct i2c_msg msg; 285 struct i2c_msg msg;
262 struct tuner_setup tun_setup; 286 struct tuner_setup tun_setup;
263 v4l2_std_id std = V4L2_STD_PAL_BG; 287 v4l2_std_id std = V4L2_STD_PAL_BG;
264 struct v4l2_routing route;
265 288
266 int i = 0, err = 0; 289 int i = 0, err = 0;
267 290
268 /* select video mode in saa7111a */ 291 /* select video mode in saa7111a */
269 saa7111a_call(mxb, tuner, s_std, std); 292 saa7111a_call(mxb, core, s_std, std);
270 293
271 /* select tuner-output on saa7111a */ 294 /* select tuner-output on saa7111a */
272 i = 0; 295 i = 0;
273 route.input = SAA7115_COMPOSITE0; 296 saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0,
274 route.output = SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS; 297 SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS, 0);
275 saa7111a_call(mxb, video, s_routing, &route);
276 298
277 /* select a tuner type */ 299 /* select a tuner type */
278 tun_setup.mode_mask = T_ANALOG_TV; 300 tun_setup.mode_mask = T_ANALOG_TV;
@@ -286,23 +308,17 @@ static int mxb_init_done(struct saa7146_dev* dev)
286 tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq); 308 tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);
287 309
288 /* set a default video standard */ 310 /* set a default video standard */
289 tuner_call(mxb, tuner, s_std, std); 311 tuner_call(mxb, core, s_std, std);
290 312
291 /* mute audio on tea6420s */ 313 /* mute audio on tea6420s */
292 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]); 314 tea6420_route_line(mxb, 6);
293 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]); 315 tea6420_route_cd(mxb, 6);
294 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]);
295 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]);
296 316
297 /* switch to tuner-channel on tea6415c */ 317 /* switch to tuner-channel on tea6415c */
298 route.input = 3; 318 tea6415c_call(mxb, video, s_routing, 3, 17, 0);
299 route.output = 17;
300 tea6415c_call(mxb, video, s_routing, &route);
301 319
302 /* select tuner-output on multicable on tea6415c */ 320 /* select tuner-output on multicable on tea6415c */
303 route.input = 3; 321 tea6415c_call(mxb, video, s_routing, 3, 13, 0);
304 route.output = 13;
305 tea6415c_call(mxb, video, s_routing, &route);
306 322
307 /* the rest for mxb */ 323 /* the rest for mxb */
308 mxb->cur_input = 0; 324 mxb->cur_input = 0;
@@ -426,18 +442,9 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
426 442
427 if (vc->id == V4L2_CID_AUDIO_MUTE) { 443 if (vc->id == V4L2_CID_AUDIO_MUTE) {
428 mxb->cur_mute = vc->value; 444 mxb->cur_mute = vc->value;
429 if (!vc->value) { 445 /* switch the audio-source */
430 /* switch the audio-source */ 446 tea6420_route_line(mxb, vc->value ? 6 :
431 tea6420_1_call(mxb, audio, s_routing, 447 video_audio_connect[mxb->cur_input]);
432 &TEA6420_line[video_audio_connect[mxb->cur_input]][0]);
433 tea6420_2_call(mxb, audio, s_routing,
434 &TEA6420_line[video_audio_connect[mxb->cur_input]][1]);
435 } else {
436 tea6420_1_call(mxb, audio, s_routing,
437 &TEA6420_line[6][0]);
438 tea6420_2_call(mxb, audio, s_routing,
439 &TEA6420_line[6][1]);
440 }
441 DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value)); 448 DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value));
442 } 449 }
443 return 0; 450 return 0;
@@ -466,7 +473,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
466{ 473{
467 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; 474 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
468 struct mxb *mxb = (struct mxb *)dev->ext_priv; 475 struct mxb *mxb = (struct mxb *)dev->ext_priv;
469 struct v4l2_routing route; 476 int err = 0;
470 int i = 0; 477 int i = 0;
471 478
472 DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); 479 DEB_EE(("VIDIOC_S_INPUT %d.\n", input));
@@ -484,16 +491,12 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
484 switch (input) { 491 switch (input) {
485 case TUNER: 492 case TUNER:
486 i = SAA7115_COMPOSITE0; 493 i = SAA7115_COMPOSITE0;
487 route.input = 3;
488 route.output = 17;
489 494
490 if (tea6415c_call(mxb, video, s_routing, &route)) { 495 err = tea6415c_call(mxb, video, s_routing, 3, 17, 0);
491 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #1\n"); 496
492 return -EFAULT;
493 }
494 /* connect tuner-output always to multicable */ 497 /* connect tuner-output always to multicable */
495 route.input = 3; 498 if (!err)
496 route.output = 13; 499 err = tea6415c_call(mxb, video, s_routing, 3, 13, 0);
497 break; 500 break;
498 case AUX3_YC: 501 case AUX3_YC:
499 /* nothing to be done here. aux3_yc is 502 /* nothing to be done here. aux3_yc is
@@ -507,37 +510,20 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
507 break; 510 break;
508 case AUX1: 511 case AUX1:
509 i = SAA7115_COMPOSITE0; 512 i = SAA7115_COMPOSITE0;
510 route.input = 1; 513 err = tea6415c_call(mxb, video, s_routing, 1, 17, 0);
511 route.output = 17;
512 break; 514 break;
513 } 515 }
514 516
515 /* switch video in tea6415c only if necessary */ 517 if (err)
516 switch (input) { 518 return err;
517 case TUNER:
518 case AUX1:
519 if (tea6415c_call(mxb, video, s_routing, &route)) {
520 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #3\n");
521 return -EFAULT;
522 }
523 break;
524 default:
525 break;
526 }
527 519
528 /* switch video in saa7111a */ 520 /* switch video in saa7111a */
529 route.input = i; 521 if (saa7111a_call(mxb, video, s_routing, i, 0, 0))
530 route.output = 0;
531 if (saa7111a_call(mxb, video, s_routing, &route))
532 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n"); 522 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n");
533 523
534 /* switch the audio-source only if necessary */ 524 /* switch the audio-source only if necessary */
535 if (0 == mxb->cur_mute) { 525 if (0 == mxb->cur_mute)
536 tea6420_1_call(mxb, audio, s_routing, 526 tea6420_route_line(mxb, video_audio_connect[input]);
537 &TEA6420_line[video_audio_connect[input]][0]);
538 tea6420_2_call(mxb, audio, s_routing,
539 &TEA6420_line[video_audio_connect[input]][1]);
540 }
541 527
542 return 0; 528 return 0;
543} 529}
@@ -679,9 +665,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
679 665
680 DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); 666 DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i));
681 667
682 tea6420_1_call(mxb, audio, s_routing, &TEA6420_cd[i][0]); 668 tea6420_route_cd(mxb, i);
683 tea6420_2_call(mxb, audio, s_routing, &TEA6420_cd[i][1]);
684
685 return 0; 669 return 0;
686 } 670 }
687 case MXB_S_AUDIO_LINE: 671 case MXB_S_AUDIO_LINE:
@@ -694,9 +678,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
694 } 678 }
695 679
696 DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); 680 DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i));
697 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[i][0]); 681 tea6420_route_line(mxb, i);
698 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[i][1]);
699
700 return 0; 682 return 0;
701 } 683 }
702 default: 684 default:
@@ -788,7 +770,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
788 saa7146_write(dev, GPIO_CTRL, 0x00404050); 770 saa7146_write(dev, GPIO_CTRL, 0x00404050);
789 /* unset the 7111 gpio register -- I don't know what this does exactly */ 771 /* unset the 7111 gpio register -- I don't know what this does exactly */
790 saa7111a_call(mxb, core, s_gpio, 0); 772 saa7111a_call(mxb, core, s_gpio, 0);
791 tuner_call(mxb, tuner, s_std, std); 773 tuner_call(mxb, core, s_std, std);
792 } else { 774 } else {
793 v4l2_std_id std = V4L2_STD_PAL_BG; 775 v4l2_std_id std = V4L2_STD_PAL_BG;
794 776
@@ -797,7 +779,7 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
797 saa7146_write(dev, GPIO_CTRL, 0x00404050); 779 saa7146_write(dev, GPIO_CTRL, 0x00404050);
798 /* set the 7111 gpio register -- I don't know what this does exactly */ 780 /* set the 7111 gpio register -- I don't know what this does exactly */
799 saa7111a_call(mxb, core, s_gpio, 1); 781 saa7111a_call(mxb, core, s_gpio, 1);
800 tuner_call(mxb, tuner, s_std, std); 782 tuner_call(mxb, core, s_std, std);
801 } 783 }
802 return 0; 784 return 0;
803} 785}