aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mxb.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-07 09:18:05 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:42 -0400
commit1b8dac150a01e2312d8e3fedd6462a0ec34c96d0 (patch)
treeba8fd678a4afb4bd72960e1737f857991fd00a19 /drivers/media/video/mxb.c
parentd30e21ddcdc948ecedfb46a0ed021d57f310a6f3 (diff)
V4L/DVB (10499): saa7146: convert saa7146 and mxb in particular to v4l2_subdev.
Modified mxb to load the i2c modules through v4l2_subdev. So no more probing. Modified tea6415c and tea6420 to use the standard routing ops to do the routing, rather than using private commands. Dropped the private commands from tda9840 (they were never used except during initialization of the module). Added saa7146 support for VIDIOC_DBG_G_CHIP_IDENT. Converted saa5246a and saa5249 to v4l2_subdev. 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.c274
1 files changed, 109 insertions, 165 deletions
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index 8ecda8dfbd04..996011f2aba5 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -32,9 +32,14 @@
32#include "mxb.h" 32#include "mxb.h"
33#include "tea6415c.h" 33#include "tea6415c.h"
34#include "tea6420.h" 34#include "tea6420.h"
35#include "tda9840.h"
36 35
37#define I2C_SAA7111 0x24 36#define I2C_SAA5246A 0x11
37#define I2C_SAA7111A 0x24
38#define I2C_TDA9840 0x42
39#define I2C_TEA6415C 0x43
40#define I2C_TEA6420_1 0x4c
41#define I2C_TEA6420_2 0x4d
42#define I2C_TUNER 0x60
38 43
39#define MXB_BOARD_CAN_DO_VBI(dev) (dev->revision != 0) 44#define MXB_BOARD_CAN_DO_VBI(dev) (dev->revision != 0)
40 45
@@ -79,31 +84,29 @@ static struct {
79static int video_audio_connect[MXB_INPUTS] = 84static int video_audio_connect[MXB_INPUTS] =
80 { 0, 1, 3, 3 }; 85 { 0, 1, 3, 3 };
81 86
82/* these are the necessary input-output-pins for bringing one audio source 87/* These are the necessary input-output-pins for bringing one audio source
83(see above) to the CD-output */ 88 (see above) to the CD-output. Note that gain is set to 0 in this table. */
84static struct tea6420_multiplex TEA6420_cd[MXB_AUDIOS+1][2] = 89static struct v4l2_routing TEA6420_cd[MXB_AUDIOS + 1][2] = {
85 { 90 { { 1, 1 }, { 1, 1 } }, /* Tuner */
86 {{1,1,0},{1,1,0}}, /* Tuner */ 91 { { 5, 1 }, { 6, 1 } }, /* AUX 1 */
87 {{5,1,0},{6,1,0}}, /* AUX 1 */ 92 { { 4, 1 }, { 6, 1 } }, /* AUX 2 */
88 {{4,1,0},{6,1,0}}, /* AUX 2 */ 93 { { 3, 1 }, { 6, 1 } }, /* AUX 3 */
89 {{3,1,0},{6,1,0}}, /* AUX 3 */ 94 { { 1, 1 }, { 3, 1 } }, /* Radio */
90 {{1,1,0},{3,1,0}}, /* Radio */ 95 { { 1, 1 }, { 2, 1 } }, /* CD-Rom */
91 {{1,1,0},{2,1,0}}, /* CD-Rom */ 96 { { 6, 1 }, { 6, 1 } } /* Mute */
92 {{6,1,0},{6,1,0}} /* Mute */ 97};
93 }; 98
94 99/* These are the necessary input-output-pins for bringing one audio source
95/* these are the necessary input-output-pins for bringing one audio source 100 (see above) to the line-output. Note that gain is set to 0 in this table. */
96(see above) to the line-output */ 101static struct v4l2_routing TEA6420_line[MXB_AUDIOS + 1][2] = {
97static struct tea6420_multiplex TEA6420_line[MXB_AUDIOS+1][2] = 102 { { 2, 3 }, { 1, 2 } },
98 { 103 { { 5, 3 }, { 6, 2 } },
99 {{2,3,0},{1,2,0}}, 104 { { 4, 3 }, { 6, 2 } },
100 {{5,3,0},{6,2,0}}, 105 { { 3, 3 }, { 6, 2 } },
101 {{4,3,0},{6,2,0}}, 106 { { 2, 3 }, { 3, 2 } },
102 {{3,3,0},{6,2,0}}, 107 { { 2, 3 }, { 2, 2 } },
103 {{2,3,0},{3,2,0}}, 108 { { 6, 3 }, { 6, 2 } } /* Mute */
104 {{2,3,0},{2,2,0}}, 109};
105 {{6,3,0},{6,2,0}} /* Mute */
106 };
107 110
108#define MAXCONTROLS 1 111#define MAXCONTROLS 1
109static struct v4l2_queryctrl mxb_controls[] = { 112static struct v4l2_queryctrl mxb_controls[] = {
@@ -117,12 +120,12 @@ struct mxb
117 120
118 struct i2c_adapter i2c_adapter; 121 struct i2c_adapter i2c_adapter;
119 122
120 struct i2c_client *saa7111a; 123 struct v4l2_subdev *saa7111a;
121 struct i2c_client *tda9840; 124 struct v4l2_subdev *tda9840;
122 struct i2c_client *tea6415c; 125 struct v4l2_subdev *tea6415c;
123 struct i2c_client *tuner; 126 struct v4l2_subdev *tuner;
124 struct i2c_client *tea6420_1; 127 struct v4l2_subdev *tea6420_1;
125 struct i2c_client *tea6420_2; 128 struct v4l2_subdev *tea6420_2;
126 129
127 int cur_mode; /* current audio mode (mono, stereo, ...) */ 130 int cur_mode; /* current audio mode (mono, stereo, ...) */
128 int cur_input; /* current input */ 131 int cur_input; /* current input */
@@ -130,84 +133,51 @@ struct mxb
130 struct v4l2_frequency cur_freq; /* current frequency the tuner is tuned to */ 133 struct v4l2_frequency cur_freq; /* current frequency the tuner is tuned to */
131}; 134};
132 135
133static struct saa7146_extension extension; 136#define saa7111a_call(mxb, o, f, args...) \
134 137 v4l2_subdev_call(mxb->saa7111a, o, f, ##args)
135static int mxb_check_clients(struct device *dev, void *data) 138#define tea6420_1_call(mxb, o, f, args...) \
136{ 139 v4l2_subdev_call(mxb->tea6420_1, o, f, ##args)
137 struct mxb *mxb = data; 140#define tea6420_2_call(mxb, o, f, args...) \
138 struct i2c_client *client = i2c_verify_client(dev); 141 v4l2_subdev_call(mxb->tea6420_2, o, f, ##args)
139 142#define tda9840_call(mxb, o, f, args...) \
140 if (!client) 143 v4l2_subdev_call(mxb->tda9840, o, f, ##args)
141 return 0; 144#define tea6415c_call(mxb, o, f, args...) \
142 145 v4l2_subdev_call(mxb->tea6415c, o, f, ##args)
143 if (I2C_ADDR_TEA6420_1 == client->addr) 146#define tuner_call(mxb, o, f, args...) \
144 mxb->tea6420_1 = client; 147 v4l2_subdev_call(mxb->tuner, o, f, ##args)
145 if (I2C_ADDR_TEA6420_2 == client->addr) 148#define call_all(dev, o, f, args...) \
146 mxb->tea6420_2 = client; 149 v4l2_device_call_until_err(&dev->v4l2_dev, 0, o, f, ##args)
147 if (I2C_TEA6415C_2 == client->addr)
148 mxb->tea6415c = client;
149 if (I2C_ADDR_TDA9840 == client->addr)
150 mxb->tda9840 = client;
151 if (I2C_SAA7111 == client->addr)
152 mxb->saa7111a = client;
153 if (0x60 == client->addr)
154 mxb->tuner = client;
155 150
156 return 0; 151static struct saa7146_extension extension;
157}
158 152
159static int mxb_probe(struct saa7146_dev* dev) 153static int mxb_probe(struct saa7146_dev *dev)
160{ 154{
161 struct mxb* mxb = NULL; 155 struct mxb *mxb = NULL;
162 int result;
163
164 result = request_module("saa7115");
165 if (result < 0) {
166 printk("mxb: saa7111 i2c module not available.\n");
167 return -ENODEV;
168 }
169 result = request_module("tea6420");
170 if (result < 0) {
171 printk("mxb: tea6420 i2c module not available.\n");
172 return -ENODEV;
173 }
174 result = request_module("tea6415c");
175 if (result < 0) {
176 printk("mxb: tea6415c i2c module not available.\n");
177 return -ENODEV;
178 }
179 result = request_module("tda9840");
180 if (result < 0) {
181 printk("mxb: tda9840 i2c module not available.\n");
182 return -ENODEV;
183 }
184 result = request_module("tuner");
185 if (result < 0) {
186 printk("mxb: tuner i2c module not available.\n");
187 return -ENODEV;
188 }
189 156
190 mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL); 157 mxb = kzalloc(sizeof(struct mxb), GFP_KERNEL);
191 if( NULL == mxb ) { 158 if (mxb == NULL) {
192 DEB_D(("not enough kernel memory.\n")); 159 DEB_D(("not enough kernel memory.\n"));
193 return -ENOMEM; 160 return -ENOMEM;
194 } 161 }
195 162
196 mxb->i2c_adapter = (struct i2c_adapter) {
197 .class = I2C_CLASS_TV_ANALOG,
198 };
199
200 snprintf(mxb->i2c_adapter.name, sizeof(mxb->i2c_adapter.name), "mxb%d", mxb_num); 163 snprintf(mxb->i2c_adapter.name, sizeof(mxb->i2c_adapter.name), "mxb%d", mxb_num);
201 164
202 saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480); 165 saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, SAA7146_I2C_BUS_BIT_RATE_480);
203 if(i2c_add_adapter(&mxb->i2c_adapter) < 0) { 166 if (i2c_add_adapter(&mxb->i2c_adapter) < 0) {
204 DEB_S(("cannot register i2c-device. skipping.\n")); 167 DEB_S(("cannot register i2c-device. skipping.\n"));
205 kfree(mxb); 168 kfree(mxb);
206 return -EFAULT; 169 return -EFAULT;
207 } 170 }
208 171
209 /* loop through all i2c-devices on the bus and look who is there */ 172 mxb->saa7111a = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa7115", "saa7111", I2C_SAA7111A);
210 device_for_each_child(&mxb->i2c_adapter.dev, mxb, mxb_check_clients); 173 mxb->tea6420_1 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_1);
174 mxb->tea6420_2 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_2);
175 mxb->tea6415c = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6415c", "tea6415c", I2C_TEA6415C);
176 mxb->tda9840 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tda9840", "tda9840", I2C_TDA9840);
177 mxb->tuner = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tuner", "tuner", I2C_TUNER);
178 if (v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa5246a", "saa5246a", I2C_SAA5246A)) {
179 printk(KERN_INFO "mxb: found teletext decoder\n");
180 }
211 181
212 /* check if all devices are present */ 182 /* check if all devices are present */
213 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c || 183 if (!mxb->tea6420_1 || !mxb->tea6420_2 || !mxb->tea6415c ||
@@ -295,47 +265,45 @@ static int mxb_init_done(struct saa7146_dev* dev)
295 struct v4l2_routing route; 265 struct v4l2_routing route;
296 266
297 int i = 0, err = 0; 267 int i = 0, err = 0;
298 struct tea6415c_multiplex vm;
299 268
300 /* select video mode in saa7111a */ 269 /* select video mode in saa7111a */
301 mxb->saa7111a->driver->command(mxb->saa7111a, VIDIOC_S_STD, &std); 270 saa7111a_call(mxb, tuner, s_std, std);
302 271
303 /* select tuner-output on saa7111a */ 272 /* select tuner-output on saa7111a */
304 i = 0; 273 i = 0;
305 route.input = SAA7115_COMPOSITE0; 274 route.input = SAA7115_COMPOSITE0;
306 route.output = SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS; 275 route.output = SAA7111_FMT_CCIR | SAA7111_VBI_BYPASS;
307 mxb->saa7111a->driver->command(mxb->saa7111a, VIDIOC_INT_S_VIDEO_ROUTING, &route); 276 saa7111a_call(mxb, video, s_routing, &route);
308 277
309 /* select a tuner type */ 278 /* select a tuner type */
310 tun_setup.mode_mask = T_ANALOG_TV; 279 tun_setup.mode_mask = T_ANALOG_TV;
311 tun_setup.addr = ADDR_UNSET; 280 tun_setup.addr = ADDR_UNSET;
312 tun_setup.type = TUNER_PHILIPS_PAL; 281 tun_setup.type = TUNER_PHILIPS_PAL;
313 mxb->tuner->driver->command(mxb->tuner, TUNER_SET_TYPE_ADDR, &tun_setup); 282 tuner_call(mxb, tuner, s_type_addr, &tun_setup);
314 /* tune in some frequency on tuner */ 283 /* tune in some frequency on tuner */
315 mxb->cur_freq.tuner = 0; 284 mxb->cur_freq.tuner = 0;
316 mxb->cur_freq.type = V4L2_TUNER_ANALOG_TV; 285 mxb->cur_freq.type = V4L2_TUNER_ANALOG_TV;
317 mxb->cur_freq.frequency = freq; 286 mxb->cur_freq.frequency = freq;
318 mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_FREQUENCY, 287 tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);
319 &mxb->cur_freq);
320 288
321 /* set a default video standard */ 289 /* set a default video standard */
322 mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std); 290 tuner_call(mxb, tuner, s_std, std);
323 291
324 /* mute audio on tea6420s */ 292 /* mute audio on tea6420s */
325 mxb->tea6420_1->driver->command(mxb->tea6420_1, TEA6420_SWITCH, &TEA6420_line[6][0]); 293 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]);
326 mxb->tea6420_2->driver->command(mxb->tea6420_2, TEA6420_SWITCH, &TEA6420_line[6][1]); 294 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]);
327 mxb->tea6420_1->driver->command(mxb->tea6420_1, TEA6420_SWITCH, &TEA6420_cd[6][0]); 295 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[6][0]);
328 mxb->tea6420_2->driver->command(mxb->tea6420_2, TEA6420_SWITCH, &TEA6420_cd[6][1]); 296 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[6][1]);
329 297
330 /* switch to tuner-channel on tea6415c*/ 298 /* switch to tuner-channel on tea6415c */
331 vm.out = 17; 299 route.input = 3;
332 vm.in = 3; 300 route.output = 17;
333 mxb->tea6415c->driver->command(mxb->tea6415c, TEA6415C_SWITCH, &vm); 301 tea6415c_call(mxb, video, s_routing, &route);
334 302
335 /* select tuner-output on multicable on tea6415c*/ 303 /* select tuner-output on multicable on tea6415c */
336 vm.in = 3; 304 route.input = 3;
337 vm.out = 13; 305 route.output = 13;
338 mxb->tea6415c->driver->command(mxb->tea6415c, TEA6415C_SWITCH, &vm); 306 tea6415c_call(mxb, video, s_routing, &route);
339 307
340 /* the rest for mxb */ 308 /* the rest for mxb */
341 mxb->cur_input = 0; 309 mxb->cur_input = 0;
@@ -461,14 +429,14 @@ static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *vc)
461 mxb->cur_mute = vc->value; 429 mxb->cur_mute = vc->value;
462 if (!vc->value) { 430 if (!vc->value) {
463 /* switch the audio-source */ 431 /* switch the audio-source */
464 mxb->tea6420_1->driver->command(mxb->tea6420_1, TEA6420_SWITCH, 432 tea6420_1_call(mxb, audio, s_routing,
465 &TEA6420_line[video_audio_connect[mxb->cur_input]][0]); 433 &TEA6420_line[video_audio_connect[mxb->cur_input]][0]);
466 mxb->tea6420_2->driver->command(mxb->tea6420_2, TEA6420_SWITCH, 434 tea6420_2_call(mxb, audio, s_routing,
467 &TEA6420_line[video_audio_connect[mxb->cur_input]][1]); 435 &TEA6420_line[video_audio_connect[mxb->cur_input]][1]);
468 } else { 436 } else {
469 mxb->tea6420_1->driver->command(mxb->tea6420_1, TEA6420_SWITCH, 437 tea6420_1_call(mxb, audio, s_routing,
470 &TEA6420_line[6][0]); 438 &TEA6420_line[6][0]);
471 mxb->tea6420_2->driver->command(mxb->tea6420_2, TEA6420_SWITCH, 439 tea6420_2_call(mxb, audio, s_routing,
472 &TEA6420_line[6][1]); 440 &TEA6420_line[6][1]);
473 } 441 }
474 DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value)); 442 DEB_EE(("VIDIOC_S_CTRL, V4L2_CID_AUDIO_MUTE: %d.\n", vc->value));
@@ -499,7 +467,6 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
499{ 467{
500 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; 468 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
501 struct mxb *mxb = (struct mxb *)dev->ext_priv; 469 struct mxb *mxb = (struct mxb *)dev->ext_priv;
502 struct tea6415c_multiplex vm;
503 struct v4l2_routing route; 470 struct v4l2_routing route;
504 int i = 0; 471 int i = 0;
505 472
@@ -518,16 +485,16 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
518 switch (input) { 485 switch (input) {
519 case TUNER: 486 case TUNER:
520 i = SAA7115_COMPOSITE0; 487 i = SAA7115_COMPOSITE0;
521 vm.in = 3; 488 route.input = 3;
522 vm.out = 17; 489 route.output = 17;
523 490
524 if (mxb->tea6415c->driver->command(mxb->tea6415c, TEA6415C_SWITCH, &vm)) { 491 if (tea6415c_call(mxb, video, s_routing, &route)) {
525 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #1\n"); 492 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #1\n");
526 return -EFAULT; 493 return -EFAULT;
527 } 494 }
528 /* connect tuner-output always to multicable */ 495 /* connect tuner-output always to multicable */
529 vm.in = 3; 496 route.input = 3;
530 vm.out = 13; 497 route.output = 13;
531 break; 498 break;
532 case AUX3_YC: 499 case AUX3_YC:
533 /* nothing to be done here. aux3_yc is 500 /* nothing to be done here. aux3_yc is
@@ -541,8 +508,8 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
541 break; 508 break;
542 case AUX1: 509 case AUX1:
543 i = SAA7115_COMPOSITE0; 510 i = SAA7115_COMPOSITE0;
544 vm.in = 1; 511 route.input = 1;
545 vm.out = 17; 512 route.output = 17;
546 break; 513 break;
547 } 514 }
548 515
@@ -550,7 +517,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
550 switch (input) { 517 switch (input) {
551 case TUNER: 518 case TUNER:
552 case AUX1: 519 case AUX1:
553 if (mxb->tea6415c->driver->command(mxb->tea6415c, TEA6415C_SWITCH, &vm)) { 520 if (tea6415c_call(mxb, video, s_routing, &route)) {
554 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #3\n"); 521 printk(KERN_ERR "VIDIOC_S_INPUT: could not address tea6415c #3\n");
555 return -EFAULT; 522 return -EFAULT;
556 } 523 }
@@ -562,14 +529,14 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int input)
562 /* switch video in saa7111a */ 529 /* switch video in saa7111a */
563 route.input = i; 530 route.input = i;
564 route.output = 0; 531 route.output = 0;
565 if (mxb->saa7111a->driver->command(mxb->saa7111a, VIDIOC_INT_S_VIDEO_ROUTING, &route)) 532 if (saa7111a_call(mxb, video, s_routing, &route))
566 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n"); 533 printk(KERN_ERR "VIDIOC_S_INPUT: could not address saa7111a #1.\n");
567 534
568 /* switch the audio-source only if necessary */ 535 /* switch the audio-source only if necessary */
569 if (0 == mxb->cur_mute) { 536 if (0 == mxb->cur_mute) {
570 mxb->tea6420_1->driver->command(mxb->tea6420_1, TEA6420_SWITCH, 537 tea6420_1_call(mxb, audio, s_routing,
571 &TEA6420_line[video_audio_connect[input]][0]); 538 &TEA6420_line[video_audio_connect[input]][0]);
572 mxb->tea6420_2->driver->command(mxb->tea6420_2, TEA6420_SWITCH, 539 tea6420_2_call(mxb, audio, s_routing,
573 &TEA6420_line[video_audio_connect[input]][1]); 540 &TEA6420_line[video_audio_connect[input]][1]);
574 } 541 }
575 542
@@ -589,14 +556,12 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *t)
589 DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index)); 556 DEB_EE(("VIDIOC_G_TUNER: %d\n", t->index));
590 557
591 memset(t, 0, sizeof(*t)); 558 memset(t, 0, sizeof(*t));
592 i2c_clients_command(&mxb->i2c_adapter, VIDIOC_G_TUNER, t);
593
594 strlcpy(t->name, "TV Tuner", sizeof(t->name)); 559 strlcpy(t->name, "TV Tuner", sizeof(t->name));
595 t->type = V4L2_TUNER_ANALOG_TV; 560 t->type = V4L2_TUNER_ANALOG_TV;
596 t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO | 561 t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO |
597 V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP; 562 V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
598 t->audmode = mxb->cur_mode; 563 t->audmode = mxb->cur_mode;
599 return 0; 564 return call_all(dev, tuner, g_tuner, t);
600} 565}
601 566
602static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *t) 567static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *t)
@@ -610,8 +575,7 @@ static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *t)
610 } 575 }
611 576
612 mxb->cur_mode = t->audmode; 577 mxb->cur_mode = t->audmode;
613 i2c_clients_command(&mxb->i2c_adapter, VIDIOC_S_TUNER, t); 578 return call_all(dev, tuner, s_tuner, t);
614 return 0;
615} 579}
616 580
617static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency *f) 581static int vidioc_g_frequency(struct file *file, void *fh, struct v4l2_frequency *f)
@@ -652,7 +616,7 @@ static int vidioc_s_frequency(struct file *file, void *fh, struct v4l2_frequency
652 DEB_EE(("VIDIOC_S_FREQUENCY: freq:0x%08x.\n", mxb->cur_freq.frequency)); 616 DEB_EE(("VIDIOC_S_FREQUENCY: freq:0x%08x.\n", mxb->cur_freq.frequency));
653 617
654 /* tune in desired frequency */ 618 /* tune in desired frequency */
655 mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_FREQUENCY, &mxb->cur_freq); 619 tuner_call(mxb, tuner, s_frequency, &mxb->cur_freq);
656 620
657 /* hack: changing the frequency should invalidate the vbi-counter (=> alevt) */ 621 /* hack: changing the frequency should invalidate the vbi-counter (=> alevt) */
658 spin_lock(&dev->slock); 622 spin_lock(&dev->slock);
@@ -687,19 +651,15 @@ static int vidioc_s_audio(struct file *file, void *fh, struct v4l2_audio *a)
687static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) 651static int vidioc_g_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
688{ 652{
689 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; 653 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
690 struct mxb *mxb = (struct mxb *)dev->ext_priv;
691 654
692 i2c_clients_command(&mxb->i2c_adapter, VIDIOC_DBG_G_REGISTER, reg); 655 return call_all(dev, core, g_register, reg);
693 return 0;
694} 656}
695 657
696static int vidioc_s_register(struct file *file, void *fh, struct v4l2_dbg_register *reg) 658static int vidioc_s_register(struct file *file, void *fh, struct v4l2_dbg_register *reg)
697{ 659{
698 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev; 660 struct saa7146_dev *dev = ((struct saa7146_fh *)fh)->dev;
699 struct mxb *mxb = (struct mxb *)dev->ext_priv;
700 661
701 i2c_clients_command(&mxb->i2c_adapter, VIDIOC_DBG_S_REGISTER, reg); 662 return call_all(dev, core, s_register, reg);
702 return 0;
703} 663}
704#endif 664#endif
705 665
@@ -720,8 +680,8 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
720 680
721 DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i)); 681 DEB_EE(("MXB_S_AUDIO_CD: i:%d.\n", i));
722 682
723 mxb->tea6420_1->driver->command(mxb->tea6420_1, TEA6420_SWITCH, &TEA6420_cd[i][0]); 683 tea6420_1_call(mxb, audio, s_routing, &TEA6420_cd[i][0]);
724 mxb->tea6420_2->driver->command(mxb->tea6420_2, TEA6420_SWITCH, &TEA6420_cd[i][1]); 684 tea6420_2_call(mxb, audio, s_routing, &TEA6420_cd[i][1]);
725 685
726 return 0; 686 return 0;
727 } 687 }
@@ -735,8 +695,8 @@ static long vidioc_default(struct file *file, void *fh, int cmd, void *arg)
735 } 695 }
736 696
737 DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i)); 697 DEB_EE(("MXB_S_AUDIO_LINE: i:%d.\n", i));
738 mxb->tea6420_1->driver->command(mxb->tea6420_1, TEA6420_SWITCH, &TEA6420_line[i][0]); 698 tea6420_1_call(mxb, audio, s_routing, &TEA6420_line[i][0]);
739 mxb->tea6420_2->driver->command(mxb->tea6420_2, TEA6420_SWITCH, &TEA6420_line[i][1]); 699 tea6420_2_call(mxb, audio, s_routing, &TEA6420_line[i][1]);
740 700
741 return 0; 701 return 0;
742 } 702 }
@@ -791,13 +751,6 @@ static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data
791 } 751 }
792 } 752 }
793 753
794 i2c_use_client(mxb->tea6420_1);
795 i2c_use_client(mxb->tea6420_2);
796 i2c_use_client(mxb->tea6415c);
797 i2c_use_client(mxb->tda9840);
798 i2c_use_client(mxb->saa7111a);
799 i2c_use_client(mxb->tuner);
800
801 printk("mxb: found Multimedia eXtension Board #%d.\n", mxb_num); 754 printk("mxb: found Multimedia eXtension Board #%d.\n", mxb_num);
802 755
803 mxb_num++; 756 mxb_num++;
@@ -811,13 +764,6 @@ static int mxb_detach(struct saa7146_dev *dev)
811 764
812 DEB_EE(("dev:%p\n", dev)); 765 DEB_EE(("dev:%p\n", dev));
813 766
814 i2c_release_client(mxb->tea6420_1);
815 i2c_release_client(mxb->tea6420_2);
816 i2c_release_client(mxb->tea6415c);
817 i2c_release_client(mxb->tda9840);
818 i2c_release_client(mxb->saa7111a);
819 i2c_release_client(mxb->tuner);
820
821 saa7146_unregister_device(&mxb->video_dev,dev); 767 saa7146_unregister_device(&mxb->video_dev,dev);
822 if (MXB_BOARD_CAN_DO_VBI(dev)) 768 if (MXB_BOARD_CAN_DO_VBI(dev))
823 saa7146_unregister_device(&mxb->vbi_dev, dev); 769 saa7146_unregister_device(&mxb->vbi_dev, dev);
@@ -834,8 +780,6 @@ static int mxb_detach(struct saa7146_dev *dev)
834static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standard) 780static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standard)
835{ 781{
836 struct mxb *mxb = (struct mxb *)dev->ext_priv; 782 struct mxb *mxb = (struct mxb *)dev->ext_priv;
837 int zero = 0;
838 int one = 1;
839 783
840 if (V4L2_STD_PAL_I == standard->id) { 784 if (V4L2_STD_PAL_I == standard->id) {
841 v4l2_std_id std = V4L2_STD_PAL_I; 785 v4l2_std_id std = V4L2_STD_PAL_I;
@@ -844,8 +788,8 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
844 /* set the 7146 gpio register -- I don't know what this does exactly */ 788 /* set the 7146 gpio register -- I don't know what this does exactly */
845 saa7146_write(dev, GPIO_CTRL, 0x00404050); 789 saa7146_write(dev, GPIO_CTRL, 0x00404050);
846 /* unset the 7111 gpio register -- I don't know what this does exactly */ 790 /* unset the 7111 gpio register -- I don't know what this does exactly */
847 mxb->saa7111a->driver->command(mxb->saa7111a, VIDIOC_INT_S_GPIO, &zero); 791 saa7111a_call(mxb, core, s_gpio, 0);
848 mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std); 792 tuner_call(mxb, tuner, s_std, std);
849 } else { 793 } else {
850 v4l2_std_id std = V4L2_STD_PAL_BG; 794 v4l2_std_id std = V4L2_STD_PAL_BG;
851 795
@@ -853,8 +797,8 @@ static int std_callback(struct saa7146_dev *dev, struct saa7146_standard *standa
853 /* set the 7146 gpio register -- I don't know what this does exactly */ 797 /* set the 7146 gpio register -- I don't know what this does exactly */
854 saa7146_write(dev, GPIO_CTRL, 0x00404050); 798 saa7146_write(dev, GPIO_CTRL, 0x00404050);
855 /* set the 7111 gpio register -- I don't know what this does exactly */ 799 /* set the 7111 gpio register -- I don't know what this does exactly */
856 mxb->saa7111a->driver->command(mxb->saa7111a, VIDIOC_INT_S_GPIO, &one); 800 saa7111a_call(mxb, core, s_gpio, 1);
857 mxb->tuner->driver->command(mxb->tuner, VIDIOC_S_STD, &std); 801 tuner_call(mxb, tuner, s_std, std);
858 } 802 }
859 return 0; 803 return 0;
860} 804}