diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-04-02 10:26:22 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 20:44:27 -0400 |
commit | 5325b4272a53b43f55b82cc369c310c2fcacdca1 (patch) | |
tree | f2a1491de3d05901152e0e271c0cb5ce381884c2 /drivers/media/video/mxb.c | |
parent | c0ff29150d37615ac703802ab3edc775fd402491 (diff) |
V4L/DVB (11380): v4l2-subdev: change s_routing prototype
It is no longer needed to use a struct pointer as argument, since v4l2_subdev
doesn't require that ioctl-like approach anymore. Instead just pass the input,
output and config (new!) arguments directly.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mxb.c')
-rw-r--r-- | drivers/media/video/mxb.c | 115 |
1 files changed, 45 insertions, 70 deletions
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c index a547c85b4ca7..3be5a71bdac2 100644 --- a/drivers/media/video/mxb.c +++ b/drivers/media/video/mxb.c | |||
@@ -83,9 +83,14 @@ static struct { | |||
83 | static int video_audio_connect[MXB_INPUTS] = | 83 | static int video_audio_connect[MXB_INPUTS] = |
84 | { 0, 1, 3, 3 }; | 84 | { 0, 1, 3, 3 }; |
85 | 85 | ||
86 | struct 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. */ |
88 | static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = { | 93 | static 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. */ |
100 | static struct v4l2_routing TEA6420_line[MXB_AUDIOS + 1][2] = { | 105 | static 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 | ||
151 | static 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 | |||
159 | static 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 | |||
150 | static struct saa7146_extension extension; | 167 | static struct saa7146_extension extension; |
151 | 168 | ||
152 | static int mxb_probe(struct saa7146_dev *dev) | 169 | static int mxb_probe(struct saa7146_dev *dev) |
@@ -268,7 +285,6 @@ static int mxb_init_done(struct saa7146_dev* dev) | |||
268 | struct i2c_msg msg; | 285 | struct i2c_msg msg; |
269 | struct tuner_setup tun_setup; | 286 | struct tuner_setup tun_setup; |
270 | v4l2_std_id std = V4L2_STD_PAL_BG; | 287 | v4l2_std_id std = V4L2_STD_PAL_BG; |
271 | struct v4l2_routing route; | ||
272 | 288 | ||
273 | int i = 0, err = 0; | 289 | int i = 0, err = 0; |
274 | 290 | ||
@@ -277,9 +293,8 @@ static int mxb_init_done(struct saa7146_dev* dev) | |||
277 | 293 | ||
278 | /* select tuner-output on saa7111a */ | 294 | /* select tuner-output on saa7111a */ |
279 | i = 0; | 295 | i = 0; |
280 | route.input = SAA7115_COMPOSITE0; | 296 | saa7111a_call(mxb, video, s_routing, SAA7115_COMPOSITE0, |
281 | route.output = SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS; | 297 | SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS, 0); |
282 | saa7111a_call(mxb, video, s_routing, &route); | ||
283 | 298 | ||
284 | /* select a tuner type */ | 299 | /* select a tuner type */ |
285 | tun_setup.mode_mask = T_ANALOG_TV; | 300 | tun_setup.mode_mask = T_ANALOG_TV; |
@@ -296,20 +311,14 @@ static int mxb_init_done(struct saa7146_dev* dev) | |||
296 | tuner_call(mxb, core, s_std, std); | 311 | tuner_call(mxb, core, s_std, std); |
297 | 312 | ||
298 | /* mute audio on tea6420s */ | 313 | /* mute audio on tea6420s */ |
299 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]); | 314 | tea6420_route_line(mxb, 6); |
300 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]); | 315 | tea6420_route_cd(mxb, 6); |
301 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_cd[6][0]); | ||
302 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_cd[6][1]); | ||
303 | 316 | ||
304 | /* switch to tuner-channel on tea6415c */ | 317 | /* switch to tuner-channel on tea6415c */ |
305 | route.input = 3; | 318 | tea6415c_call(mxb, video, s_routing, 3, 17, 0); |
306 | route.output = 17; | ||
307 | tea6415c_call(mxb, video, s_routing, &route); | ||
308 | 319 | ||
309 | /* select tuner-output on multicable on tea6415c */ | 320 | /* select tuner-output on multicable on tea6415c */ |
310 | route.input = 3; | 321 | tea6415c_call(mxb, video, s_routing, 3, 13, 0); |
311 | route.output = 13; | ||
312 | tea6415c_call(mxb, video, s_routing, &route); | ||
313 | 322 | ||
314 | /* the rest for mxb */ | 323 | /* the rest for mxb */ |
315 | mxb->cur_input = 0; | 324 | mxb->cur_input = 0; |
@@ -433,18 +442,9 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc) | |||
433 | 442 | ||
434 | if (vc->id == V4L2_CID_AUDIO_MUTE) { | 443 | if (vc->id == V4L2_CID_AUDIO_MUTE) { |
435 | mxb->cur_mute = vc->value; | 444 | mxb->cur_mute = vc->value; |
436 | if (!vc->value) { | 445 | /* switch the audio-source */ |
437 | /* switch the audio-source */ | 446 | tea6420_route_line(mxb, vc->value ? 6 : |
438 | tea6420_1_call(mxb, audio, s_routing, | 447 | video_audio_connect[mxb->cur_input]); |
439 | &TEA6420_line[video_audio_connect[mxb->cur_input]][0]); | ||
440 | tea6420_2_call(mxb, audio, s_routing, | ||
441 | &TEA6420_line[video_audio_connect[mxb->cur_input]][1]); | ||
442 | } else { | ||
443 | tea6420_1_call(mxb, audio, s_routing, | ||
444 | &TEA6420_line[6][0]); | ||
445 | tea6420_2_call(mxb, audio, s_routing, | ||
446 | &TEA6420_line[6][1]); | ||
447 | } | ||
448 | 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)); |
449 | } | 449 | } |
450 | return 0; | 450 | return 0; |
@@ -473,7 +473,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | |||
473 | { | 473 | { |
474 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; | 474 | struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; |
475 | struct mxb *mxb = (struct mxb *)dev->ext_priv; | 475 | struct mxb *mxb = (struct mxb *)dev->ext_priv; |
476 | struct v4l2_routing route; | 476 | int err = 0; |
477 | int i = 0; | 477 | int i = 0; |
478 | 478 | ||
479 | DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); | 479 | DEB_EE(("VIDIOC_S_INPUT %d.\n", input)); |
@@ -491,16 +491,12 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | |||
491 | switch (input) { | 491 | switch (input) { |
492 | case TUNER: | 492 | case TUNER: |
493 | i = SAA7115_COMPOSITE0; | 493 | i = SAA7115_COMPOSITE0; |
494 | route.input = 3; | ||
495 | route.output = 17; | ||
496 | 494 | ||
497 | if (tea6415c_call(mxb, video, s_routing, &route)) { | 495 | err = tea6415c_call(mxb, video, s_routing, 3, 17, 0); |
498 | printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #1\n"); | 496 | |
499 | return -EFAULT; | ||
500 | } | ||
501 | /* connect tuner-output always to multicable */ | 497 | /* connect tuner-output always to multicable */ |
502 | route.input = 3; | 498 | if (!err) |
503 | route.output = 13; | 499 | err = tea6415c_call(mxb, video, s_routing, 3, 13, 0); |
504 | break; | 500 | break; |
505 | case AUX3_YC: | 501 | case AUX3_YC: |
506 | /* nothing to be done here. aux3_yc is | 502 | /* nothing to be done here. aux3_yc is |
@@ -514,37 +510,20 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input) | |||
514 | break; | 510 | break; |
515 | case AUX1: | 511 | case AUX1: |
516 | i = SAA7115_COMPOSITE0; | 512 | i = SAA7115_COMPOSITE0; |
517 | route.input = 1; | 513 | err = tea6415c_call(mxb, video, s_routing, 1, 17, 0); |
518 | route.output = 17; | ||
519 | break; | 514 | break; |
520 | } | 515 | } |
521 | 516 | ||
522 | /* switch video in tea6415c only if necessary */ | 517 | if (err) |
523 | switch (input) { | 518 | return err; |
524 | case TUNER: | ||
525 | case AUX1: | ||
526 | if (tea6415c_call(mxb, video, s_routing, &route)) { | ||
527 | printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #3\n"); | ||
528 | return -EFAULT; | ||
529 | } | ||
530 | break; | ||
531 | default: | ||
532 | break; | ||
533 | } | ||
534 | 519 | ||
535 | /* switch video in saa7111a */ | 520 | /* switch video in saa7111a */ |
536 | route.input = i; | 521 | if (saa7111a_call(mxb, video, s_routing, i, 0, 0)) |
537 | route.output = 0; | ||
538 | if (saa7111a_call(mxb, video, s_routing, &route)) | ||
539 | 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"); |
540 | 523 | ||
541 | /* switch the audio-source only if necessary */ | 524 | /* switch the audio-source only if necessary */ |
542 | if (0 == mxb->cur_mute) { | 525 | if (0 == mxb->cur_mute) |
543 | tea6420_1_call(mxb, audio, s_routing, | 526 | tea6420_route_line(mxb, video_audio_connect[input]); |
544 | &TEA6420_line[video_audio_connect[input]][0]); | ||
545 | tea6420_2_call(mxb, audio, s_routing, | ||
546 | &TEA6420_line[video_audio_connect[input]][1]); | ||
547 | } | ||
548 | 527 | ||
549 | return 0; | 528 | return 0; |
550 | } | 529 | } |
@@ -686,9 +665,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) | |||
686 | 665 | ||
687 | DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); | 666 | DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); |
688 | 667 | ||
689 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_cd[i][0]); | 668 | tea6420_route_cd(mxb, i); |
690 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_cd[i][1]); | ||
691 | |||
692 | return 0; | 669 | return 0; |
693 | } | 670 | } |
694 | case MXB_S_AUDIO_LINE: | 671 | case MXB_S_AUDIO_LINE: |
@@ -701,9 +678,7 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg) | |||
701 | } | 678 | } |
702 | 679 | ||
703 | DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); | 680 | DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); |
704 | tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[i][0]); | 681 | tea6420_route_line(mxb, i); |
705 | tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[i][1]); | ||
706 | |||
707 | return 0; | 682 | return 0; |
708 | } | 683 | } |
709 | default: | 684 | default: |