aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt20xx.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-08-21 00:24:42 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:07:34 -0400
commitdb8a695658cda21eacfa2a5e3b15e8964bfb93ef (patch)
treeac69f32af5b52f78ad65ad1125d330aa19c7bdda /drivers/media/video/mt20xx.c
parent293197cd0f34eb6bfb5492a63a878575b69e9df4 (diff)
V4L/DVB (6127): tuner: kill i2c_client interface to tuner sub-drivers
To ease the conversion of the analog tuner sub-drivers into dvb_frontend style tuner modules, we must remove the i2c_client interface. dvb_frontend style tuner modules use i2c_transfer directly on the i2c_adapter. This change only alters the interface between tuner.ko and the tuner sub-drivers. The v4l2 / i2c_client interface to tuner.ko remains intact. This patch adds inline functions tuner_i2c_xfer_send, and tuner_i2c_xfer_recv, to replace i2c_master_send and i2c_master_recv inside the tuner sub-drivers. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Acked-by: Hans Verkuil <hverkuil@xs4all.nl> Acked-by: Mike Isely <isely@pobox.com> Acked-by: Steven Toth <stoth@hauppauge.com> Acked-by: Patrick Boettcher <pb@linuxtv.org> Acked-by: Jarod Wilson <jwilson@redhat.com> Acked-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/mt20xx.c')
-rw-r--r--drivers/media/video/mt20xx.c138
1 files changed, 66 insertions, 72 deletions
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c
index bd495c12d29f..41bc91817a16 100644
--- a/drivers/media/video/mt20xx.c
+++ b/drivers/media/video/mt20xx.c
@@ -37,23 +37,22 @@ static char *microtune_part[] = {
37}; 37};
38 38
39struct microtune_priv { 39struct microtune_priv {
40 struct tuner_i2c_props i2c_props;
41
40 unsigned int xogc; 42 unsigned int xogc;
41 unsigned int radio_if2; 43 unsigned int radio_if2;
42}; 44};
43 45
44static void microtune_release(struct i2c_client *c) 46static void microtune_release(struct tuner *t)
45{ 47{
46 struct tuner *t = i2c_get_clientdata(c);
47
48 kfree(t->priv); 48 kfree(t->priv);
49 t->priv = NULL; 49 t->priv = NULL;
50} 50}
51 51
52// IsSpurInBand()? 52// IsSpurInBand()?
53static int mt2032_spurcheck(struct i2c_client *c, 53static int mt2032_spurcheck(struct tuner *t,
54 int f1, int f2, int spectrum_from,int spectrum_to) 54 int f1, int f2, int spectrum_from,int spectrum_to)
55{ 55{
56 struct tuner *t = i2c_get_clientdata(c);
57 int n1=1,n2,f; 56 int n1=1,n2,f;
58 57
59 f1=f1/1000; //scale to kHz to avoid 32bit overflows 58 f1=f1/1000; //scale to kHz to avoid 32bit overflows
@@ -81,7 +80,7 @@ static int mt2032_spurcheck(struct i2c_client *c,
81 return 1; 80 return 1;
82} 81}
83 82
84static int mt2032_compute_freq(struct i2c_client *c, 83static int mt2032_compute_freq(struct tuner *t,
85 unsigned int rfin, 84 unsigned int rfin,
86 unsigned int if1, unsigned int if2, 85 unsigned int if1, unsigned int if2,
87 unsigned int spectrum_from, 86 unsigned int spectrum_from,
@@ -90,7 +89,6 @@ static int mt2032_compute_freq(struct i2c_client *c,
90 int *ret_sel, 89 int *ret_sel,
91 unsigned int xogc) //all in Hz 90 unsigned int xogc) //all in Hz
92{ 91{
93 struct tuner *t = i2c_get_clientdata(c);
94 unsigned int fref,lo1,lo1n,lo1a,s,sel,lo1freq, desired_lo1, 92 unsigned int fref,lo1,lo1n,lo1a,s,sel,lo1freq, desired_lo1,
95 desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq; 93 desired_lo2,lo2,lo2n,lo2a,lo2num,lo2freq;
96 94
@@ -140,7 +138,7 @@ static int mt2032_compute_freq(struct i2c_client *c,
140 return(-1); 138 return(-1);
141 } 139 }
142 140
143 mt2032_spurcheck(c, lo1freq, desired_lo2, spectrum_from, spectrum_to); 141 mt2032_spurcheck(t, lo1freq, desired_lo2, spectrum_from, spectrum_to);
144 // should recalculate lo1 (one step up/down) 142 // should recalculate lo1 (one step up/down)
145 143
146 // set up MT2032 register map for transfer over i2c 144 // set up MT2032 register map for transfer over i2c
@@ -164,16 +162,16 @@ static int mt2032_compute_freq(struct i2c_client *c,
164 return 0; 162 return 0;
165} 163}
166 164
167static int mt2032_check_lo_lock(struct i2c_client *c) 165static int mt2032_check_lo_lock(struct tuner *t)
168{ 166{
169 struct tuner *t = i2c_get_clientdata(c); 167 struct microtune_priv *priv = t->priv;
170 int try,lock=0; 168 int try,lock=0;
171 unsigned char buf[2]; 169 unsigned char buf[2];
172 170
173 for(try=0;try<10;try++) { 171 for(try=0;try<10;try++) {
174 buf[0]=0x0e; 172 buf[0]=0x0e;
175 i2c_master_send(c,buf,1); 173 tuner_i2c_xfer_send(&priv->i2c_props,buf,1);
176 i2c_master_recv(c,buf,1); 174 tuner_i2c_xfer_recv(&priv->i2c_props,buf,1);
177 tuner_dbg("mt2032 Reg.E=0x%02x\n",buf[0]); 175 tuner_dbg("mt2032 Reg.E=0x%02x\n",buf[0]);
178 lock=buf[0] &0x06; 176 lock=buf[0] &0x06;
179 177
@@ -186,15 +184,15 @@ static int mt2032_check_lo_lock(struct i2c_client *c)
186 return lock; 184 return lock;
187} 185}
188 186
189static int mt2032_optimize_vco(struct i2c_client *c,int sel,int lock) 187static int mt2032_optimize_vco(struct tuner *t,int sel,int lock)
190{ 188{
191 struct tuner *t = i2c_get_clientdata(c); 189 struct microtune_priv *priv = t->priv;
192 unsigned char buf[2]; 190 unsigned char buf[2];
193 int tad1; 191 int tad1;
194 192
195 buf[0]=0x0f; 193 buf[0]=0x0f;
196 i2c_master_send(c,buf,1); 194 tuner_i2c_xfer_send(&priv->i2c_props,buf,1);
197 i2c_master_recv(c,buf,1); 195 tuner_i2c_xfer_recv(&priv->i2c_props,buf,1);
198 tuner_dbg("mt2032 Reg.F=0x%02x\n",buf[0]); 196 tuner_dbg("mt2032 Reg.F=0x%02x\n",buf[0]);
199 tad1=buf[0]&0x07; 197 tad1=buf[0]&0x07;
200 198
@@ -217,58 +215,57 @@ static int mt2032_optimize_vco(struct i2c_client *c,int sel,int lock)
217 215
218 buf[0]=0x0f; 216 buf[0]=0x0f;
219 buf[1]=sel; 217 buf[1]=sel;
220 i2c_master_send(c,buf,2); 218 tuner_i2c_xfer_send(&priv->i2c_props,buf,2);
221 lock=mt2032_check_lo_lock(c); 219 lock=mt2032_check_lo_lock(t);
222 return lock; 220 return lock;
223} 221}
224 222
225 223
226static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin, 224static void mt2032_set_if_freq(struct tuner *t, unsigned int rfin,
227 unsigned int if1, unsigned int if2, 225 unsigned int if1, unsigned int if2,
228 unsigned int from, unsigned int to) 226 unsigned int from, unsigned int to)
229{ 227{
230 unsigned char buf[21]; 228 unsigned char buf[21];
231 int lint_try,ret,sel,lock=0; 229 int lint_try,ret,sel,lock=0;
232 struct tuner *t = i2c_get_clientdata(c);
233 struct microtune_priv *priv = t->priv; 230 struct microtune_priv *priv = t->priv;
234 231
235 tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n", 232 tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",
236 rfin,if1,if2,from,to); 233 rfin,if1,if2,from,to);
237 234
238 buf[0]=0; 235 buf[0]=0;
239 ret=i2c_master_send(c,buf,1); 236 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,1);
240 i2c_master_recv(c,buf,21); 237 tuner_i2c_xfer_recv(&priv->i2c_props,buf,21);
241 238
242 buf[0]=0; 239 buf[0]=0;
243 ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,priv->xogc); 240 ret=mt2032_compute_freq(t,rfin,if1,if2,from,to,&buf[1],&sel,priv->xogc);
244 if (ret<0) 241 if (ret<0)
245 return; 242 return;
246 243
247 // send only the relevant registers per Rev. 1.2 244 // send only the relevant registers per Rev. 1.2
248 buf[0]=0; 245 buf[0]=0;
249 ret=i2c_master_send(c,buf,4); 246 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,4);
250 buf[5]=5; 247 buf[5]=5;
251 ret=i2c_master_send(c,buf+5,4); 248 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf+5,4);
252 buf[11]=11; 249 buf[11]=11;
253 ret=i2c_master_send(c,buf+11,3); 250 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf+11,3);
254 if(ret!=3) 251 if(ret!=3)
255 tuner_warn("i2c i/o error: rc == %d (should be 3)\n",ret); 252 tuner_warn("i2c i/o error: rc == %d (should be 3)\n",ret);
256 253
257 // wait for PLLs to lock (per manual), retry LINT if not. 254 // wait for PLLs to lock (per manual), retry LINT if not.
258 for(lint_try=0; lint_try<2; lint_try++) { 255 for(lint_try=0; lint_try<2; lint_try++) {
259 lock=mt2032_check_lo_lock(c); 256 lock=mt2032_check_lo_lock(t);
260 257
261 if(optimize_vco) 258 if(optimize_vco)
262 lock=mt2032_optimize_vco(c,sel,lock); 259 lock=mt2032_optimize_vco(t,sel,lock);
263 if(lock==6) break; 260 if(lock==6) break;
264 261
265 tuner_dbg("mt2032: re-init PLLs by LINT\n"); 262 tuner_dbg("mt2032: re-init PLLs by LINT\n");
266 buf[0]=7; 263 buf[0]=7;
267 buf[1]=0x80 +8+priv->xogc; // set LINT to re-init PLLs 264 buf[1]=0x80 +8+priv->xogc; // set LINT to re-init PLLs
268 i2c_master_send(c,buf,2); 265 tuner_i2c_xfer_send(&priv->i2c_props,buf,2);
269 mdelay(10); 266 mdelay(10);
270 buf[1]=8+priv->xogc; 267 buf[1]=8+priv->xogc;
271 i2c_master_send(c,buf,2); 268 tuner_i2c_xfer_send(&priv->i2c_props,buf,2);
272 } 269 }
273 270
274 if (lock!=6) 271 if (lock!=6)
@@ -276,15 +273,14 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
276 273
277 buf[0]=2; 274 buf[0]=2;
278 buf[1]=0x20; // LOGC for optimal phase noise 275 buf[1]=0x20; // LOGC for optimal phase noise
279 ret=i2c_master_send(c,buf,2); 276 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,2);
280 if (ret!=2) 277 if (ret!=2)
281 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret); 278 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
282} 279}
283 280
284 281
285static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq) 282static void mt2032_set_tv_freq(struct tuner *t, unsigned int freq)
286{ 283{
287 struct tuner *t = i2c_get_clientdata(c);
288 int if2,from,to; 284 int if2,from,to;
289 285
290 // signal bandwidth and picture carrier 286 // signal bandwidth and picture carrier
@@ -300,18 +296,17 @@ static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq)
300 if2 = 38900*1000; 296 if2 = 38900*1000;
301 } 297 }
302 298
303 mt2032_set_if_freq(c, freq*62500 /* freq*1000*1000/16 */, 299 mt2032_set_if_freq(t, freq*62500 /* freq*1000*1000/16 */,
304 1090*1000*1000, if2, from, to); 300 1090*1000*1000, if2, from, to);
305} 301}
306 302
307static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq) 303static void mt2032_set_radio_freq(struct tuner *t, unsigned int freq)
308{ 304{
309 struct tuner *t = i2c_get_clientdata(c);
310 struct microtune_priv *priv = t->priv; 305 struct microtune_priv *priv = t->priv;
311 int if2 = priv->radio_if2; 306 int if2 = priv->radio_if2;
312 307
313 // per Manual for FM tuning: first if center freq. 1085 MHz 308 // per Manual for FM tuning: first if center freq. 1085 MHz
314 mt2032_set_if_freq(c, freq * 1000 / 16, 309 mt2032_set_if_freq(t, freq * 1000 / 16,
315 1085*1000*1000,if2,if2,if2); 310 1085*1000*1000,if2,if2,if2);
316} 311}
317 312
@@ -322,9 +317,8 @@ static struct tuner_operations mt2032_tuner_ops = {
322}; 317};
323 318
324// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001 319// Initalization as described in "MT203x Programming Procedures", Rev 1.2, Feb.2001
325static int mt2032_init(struct i2c_client *c) 320static int mt2032_init(struct tuner *t)
326{ 321{
327 struct tuner *t = i2c_get_clientdata(c);
328 struct microtune_priv *priv = t->priv; 322 struct microtune_priv *priv = t->priv;
329 unsigned char buf[21]; 323 unsigned char buf[21];
330 int ret,xogc,xok=0; 324 int ret,xogc,xok=0;
@@ -334,7 +328,7 @@ static int mt2032_init(struct i2c_client *c)
334 buf[2]=0xff; 328 buf[2]=0xff;
335 buf[3]=0x0f; 329 buf[3]=0x0f;
336 buf[4]=0x1f; 330 buf[4]=0x1f;
337 ret=i2c_master_send(c,buf+1,4); 331 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf+1,4);
338 332
339 buf[5]=6; // Index register 6 333 buf[5]=6; // Index register 6
340 buf[6]=0xe4; 334 buf[6]=0xe4;
@@ -342,11 +336,11 @@ static int mt2032_init(struct i2c_client *c)
342 buf[8]=0xc3; 336 buf[8]=0xc3;
343 buf[9]=0x4e; 337 buf[9]=0x4e;
344 buf[10]=0xec; 338 buf[10]=0xec;
345 ret=i2c_master_send(c,buf+5,6); 339 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf+5,6);
346 340
347 buf[12]=13; // Index register 13 341 buf[12]=13; // Index register 13
348 buf[13]=0x32; 342 buf[13]=0x32;
349 ret=i2c_master_send(c,buf+12,2); 343 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf+12,2);
350 344
351 // Adjust XOGC (register 7), wait for XOK 345 // Adjust XOGC (register 7), wait for XOK
352 xogc=7; 346 xogc=7;
@@ -354,8 +348,8 @@ static int mt2032_init(struct i2c_client *c)
354 tuner_dbg("mt2032: xogc = 0x%02x\n",xogc&0x07); 348 tuner_dbg("mt2032: xogc = 0x%02x\n",xogc&0x07);
355 mdelay(10); 349 mdelay(10);
356 buf[0]=0x0e; 350 buf[0]=0x0e;
357 i2c_master_send(c,buf,1); 351 tuner_i2c_xfer_send(&priv->i2c_props,buf,1);
358 i2c_master_recv(c,buf,1); 352 tuner_i2c_xfer_recv(&priv->i2c_props,buf,1);
359 xok=buf[0]&0x01; 353 xok=buf[0]&0x01;
360 tuner_dbg("mt2032: xok = 0x%02x\n",xok); 354 tuner_dbg("mt2032: xok = 0x%02x\n",xok);
361 if (xok == 1) break; 355 if (xok == 1) break;
@@ -368,7 +362,7 @@ static int mt2032_init(struct i2c_client *c)
368 } 362 }
369 buf[0]=0x07; 363 buf[0]=0x07;
370 buf[1]=0x88 + xogc; 364 buf[1]=0x88 + xogc;
371 ret=i2c_master_send(c,buf,2); 365 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,2);
372 if (ret!=2) 366 if (ret!=2)
373 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret); 367 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
374 } while (xok != 1 ); 368 } while (xok != 1 );
@@ -379,21 +373,21 @@ static int mt2032_init(struct i2c_client *c)
379 return(1); 373 return(1);
380} 374}
381 375
382static void mt2050_set_antenna(struct i2c_client *c, unsigned char antenna) 376static void mt2050_set_antenna(struct tuner *t, unsigned char antenna)
383{ 377{
384 struct tuner *t = i2c_get_clientdata(c); 378 struct microtune_priv *priv = t->priv;
385 unsigned char buf[2]; 379 unsigned char buf[2];
386 int ret; 380 int ret;
387 381
388 buf[0] = 6; 382 buf[0] = 6;
389 buf[1] = antenna ? 0x11 : 0x10; 383 buf[1] = antenna ? 0x11 : 0x10;
390 ret=i2c_master_send(c,buf,2); 384 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,2);
391 tuner_dbg("mt2050: enabled antenna connector %d\n", antenna); 385 tuner_dbg("mt2050: enabled antenna connector %d\n", antenna);
392} 386}
393 387
394static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned int if2) 388static void mt2050_set_if_freq(struct tuner *t,unsigned int freq, unsigned int if2)
395{ 389{
396 struct tuner *t = i2c_get_clientdata(c); 390 struct microtune_priv *priv = t->priv;
397 unsigned int if1=1218*1000*1000; 391 unsigned int if1=1218*1000*1000;
398 unsigned int f_lo1,f_lo2,lo1,lo2,f_lo1_modulo,f_lo2_modulo,num1,num2,div1a,div1b,div2a,div2b; 392 unsigned int f_lo1,f_lo2,lo1,lo2,f_lo1_modulo,f_lo2_modulo,num1,num2,div1a,div1b,div2a,div2b;
399 int ret; 393 int ret;
@@ -449,14 +443,13 @@ static void mt2050_set_if_freq(struct i2c_client *c,unsigned int freq, unsigned
449 printk("\n"); 443 printk("\n");
450 } 444 }
451 445
452 ret=i2c_master_send(c,buf,6); 446 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,6);
453 if (ret!=6) 447 if (ret!=6)
454 tuner_warn("i2c i/o error: rc == %d (should be 6)\n",ret); 448 tuner_warn("i2c i/o error: rc == %d (should be 6)\n",ret);
455} 449}
456 450
457static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq) 451static void mt2050_set_tv_freq(struct tuner *t, unsigned int freq)
458{ 452{
459 struct tuner *t = i2c_get_clientdata(c);
460 unsigned int if2; 453 unsigned int if2;
461 454
462 if (t->std & V4L2_STD_525_60) { 455 if (t->std & V4L2_STD_525_60) {
@@ -470,18 +463,17 @@ static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
470 // DVB (pinnacle 300i) 463 // DVB (pinnacle 300i)
471 if2 = 36150*1000; 464 if2 = 36150*1000;
472 } 465 }
473 mt2050_set_if_freq(c, freq*62500, if2); 466 mt2050_set_if_freq(t, freq*62500, if2);
474 mt2050_set_antenna(c, tv_antenna); 467 mt2050_set_antenna(t, tv_antenna);
475} 468}
476 469
477static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq) 470static void mt2050_set_radio_freq(struct tuner *t, unsigned int freq)
478{ 471{
479 struct tuner *t = i2c_get_clientdata(c);
480 struct microtune_priv *priv = t->priv; 472 struct microtune_priv *priv = t->priv;
481 int if2 = priv->radio_if2; 473 int if2 = priv->radio_if2;
482 474
483 mt2050_set_if_freq(c, freq * 1000 / 16, if2); 475 mt2050_set_if_freq(t, freq * 1000 / 16, if2);
484 mt2050_set_antenna(c, radio_antenna); 476 mt2050_set_antenna(t, radio_antenna);
485} 477}
486 478
487static struct tuner_operations mt2050_tuner_ops = { 479static struct tuner_operations mt2050_tuner_ops = {
@@ -490,23 +482,23 @@ static struct tuner_operations mt2050_tuner_ops = {
490 .release = microtune_release, 482 .release = microtune_release,
491}; 483};
492 484
493static int mt2050_init(struct i2c_client *c) 485static int mt2050_init(struct tuner *t)
494{ 486{
495 struct tuner *t = i2c_get_clientdata(c); 487 struct microtune_priv *priv = t->priv;
496 unsigned char buf[2]; 488 unsigned char buf[2];
497 int ret; 489 int ret;
498 490
499 buf[0]=6; 491 buf[0]=6;
500 buf[1]=0x10; 492 buf[1]=0x10;
501 ret=i2c_master_send(c,buf,2); // power 493 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,2); // power
502 494
503 buf[0]=0x0f; 495 buf[0]=0x0f;
504 buf[1]=0x0f; 496 buf[1]=0x0f;
505 ret=i2c_master_send(c,buf,2); // m1lo 497 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,2); // m1lo
506 498
507 buf[0]=0x0d; 499 buf[0]=0x0d;
508 ret=i2c_master_send(c,buf,1); 500 ret=tuner_i2c_xfer_send(&priv->i2c_props,buf,1);
509 i2c_master_recv(c,buf,1); 501 tuner_i2c_xfer_recv(&priv->i2c_props,buf,1);
510 502
511 tuner_dbg("mt2050: sro is %x\n",buf[0]); 503 tuner_dbg("mt2050: sro is %x\n",buf[0]);
512 504
@@ -515,10 +507,9 @@ static int mt2050_init(struct i2c_client *c)
515 return 0; 507 return 0;
516} 508}
517 509
518int microtune_init(struct i2c_client *c) 510int microtune_init(struct tuner *t)
519{ 511{
520 struct microtune_priv *priv = NULL; 512 struct microtune_priv *priv = NULL;
521 struct tuner *t = i2c_get_clientdata(c);
522 char *name; 513 char *name;
523 unsigned char buf[21]; 514 unsigned char buf[21];
524 int company_code; 515 int company_code;
@@ -528,6 +519,9 @@ int microtune_init(struct i2c_client *c)
528 return -ENOMEM; 519 return -ENOMEM;
529 t->priv = priv; 520 t->priv = priv;
530 521
522 priv->i2c_props.addr = t->i2c.addr;
523 priv->i2c_props.adap = t->i2c.adapter;
524
531 priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */ 525 priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
532 526
533 memset(buf,0,sizeof(buf)); 527 memset(buf,0,sizeof(buf));
@@ -541,8 +535,8 @@ int microtune_init(struct i2c_client *c)
541 } 535 }
542 name = "unknown"; 536 name = "unknown";
543 537
544 i2c_master_send(c,buf,1); 538 tuner_i2c_xfer_send(&priv->i2c_props,buf,1);
545 i2c_master_recv(c,buf,21); 539 tuner_i2c_xfer_recv(&priv->i2c_props,buf,21);
546 if (tuner_debug) { 540 if (tuner_debug) {
547 int i; 541 int i;
548 tuner_dbg("MT20xx hexdump:"); 542 tuner_dbg("MT20xx hexdump:");
@@ -562,10 +556,10 @@ int microtune_init(struct i2c_client *c)
562 name = microtune_part[buf[0x13]]; 556 name = microtune_part[buf[0x13]];
563 switch (buf[0x13]) { 557 switch (buf[0x13]) {
564 case MT2032: 558 case MT2032:
565 mt2032_init(c); 559 mt2032_init(t);
566 break; 560 break;
567 case MT2050: 561 case MT2050:
568 mt2050_init(c); 562 mt2050_init(t);
569 break; 563 break;
570 default: 564 default:
571 tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n", 565 tuner_info("microtune %s found, not (yet?) supported, sorry :-/\n",
@@ -573,7 +567,7 @@ int microtune_init(struct i2c_client *c)
573 return 0; 567 return 0;
574 } 568 }
575 569
576 strlcpy(c->name, name, sizeof(c->name)); 570 strlcpy(t->i2c.name, name, sizeof(t->i2c.name));
577 tuner_info("microtune %s found, OK\n",name); 571 tuner_info("microtune %s found, OK\n",name);
578 return 0; 572 return 0;
579} 573}