1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>
#include "radeon.h"
#include "radeon_reg.h"
#include "radeon_macros.h"
#include "radeon_probe.h"
#include <X11/extensions/Xv.h>
#include "radeon_video.h"
#include "atipciids.h"
#include "xf86.h"
/* i2c stuff */
#include "xf86i2c.h"
#include "fi1236.h"
#include "msp3430.h"
#include "tda9885.h"
#include "uda1380.h"
#include "i2c_def.h"
#define I2C_DONE (1<<0)
#define I2C_NACK (1<<1)
#define I2C_HALT (1<<2)
#define I2C_SOFT_RST (1<<5)
#define I2C_DRIVE_EN (1<<6)
#define I2C_DRIVE_SEL (1<<7)
#define I2C_START (1<<8)
#define I2C_STOP (1<<9)
#define I2C_RECEIVE (1<<10)
#define I2C_ABORT (1<<11)
#define I2C_GO (1<<12)
#define I2C_SEL (1<<16)
#define I2C_EN (1<<17)
static void RADEON_TDA9885_Init(RADEONPortPrivPtr pPriv);
/* Wait for 10ms at the most for the I2C_GO register to drop. */
#define I2C_WAIT_FOR_GO() { \
int i2ctries = 0; \
RADEONWaitForIdleMMIO(pScrn); \
write_mem_barrier(); \
while (i2ctries < 10) { \
reg = INREG8(RADEON_I2C_CNTL_0+1); \
if (!(reg & (I2C_GO >> 8))) \
break; \
if (reg & (I2C_ABORT >> 8)) \
break; \
usleep(1000); \
i2ctries++; \
} \
}
/* Wait, and dump the status in the 'status' register. If we time out or
* receive an abort signal, halt/restart the I2C bus and leave _ABORT in the
* status register. */
#define I2C_WAIT_WITH_STATUS() { \
I2C_WAIT_FOR_GO() \
if (reg & ((I2C_ABORT >> 8) | (I2C_GO >> 8))) { \
RADEON_I2C_Halt(pScrn); \
status = I2C_ABORT; \
} \
else \
status = RADEON_I2C_WaitForAck(pScrn, pPriv); \
}
/****************************************************************************
* I2C_WaitForAck (void) *
* *
* Function: polls the I2C status bits, waiting for an acknowledge or *
* an error condition. *
* Inputs: NONE *
* Outputs: I2C_DONE - the I2C transfer was completed *
* I2C_NACK - an NACK was received from the slave *
* I2C_HALT - a timeout condition has occured *
****************************************************************************/
static CARD8 RADEON_I2C_WaitForAck (ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
{
CARD8 retval = 0;
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
long counter = 0;
usleep(1000);
while(1)
{
RADEONWaitForIdleMMIO(pScrn);
retval = INREG8(RADEON_I2C_CNTL_0);
if (retval & I2C_HALT)
{
return (I2C_HALT);
}
if (retval & I2C_NACK)
{
return (I2C_NACK);
}
if(retval & I2C_DONE)
{
return I2C_DONE;
}
counter++;
/* 50ms ought to be long enough. */
if(counter > 50)
{
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Timeout condition on Radeon i2c bus\n");
return I2C_HALT;
}
usleep(1000);
}
}
static void RADEON_I2C_Halt (ScrnInfoPtr pScrn)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
CARD8 reg;
/* reset status flags */
RADEONWaitForIdleMMIO(pScrn);
reg = INREG8 (RADEON_I2C_CNTL_0 + 0) & ~(I2C_DONE|I2C_NACK|I2C_HALT);
OUTREG8 (RADEON_I2C_CNTL_0 + 0, reg);
/* issue ABORT call */
RADEONWaitForIdleMMIO(pScrn);
reg = INREG8 (RADEON_I2C_CNTL_0 + 1) & 0xE7;
OUTREG8 (RADEON_I2C_CNTL_0 + 1, (reg |((I2C_GO|I2C_ABORT) >> 8)));
/* wait for GO bit to go low */
I2C_WAIT_FOR_GO();
}
static Bool RADEONI2CWriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
I2CByte *ReadBuffer, int nRead)
{
int loop, status;
CARD32 i2c_cntl_0, i2c_cntl_1;
CARD8 reg;
RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)(d->pI2CBus->DriverPrivate.ptr);
ScrnInfoPtr pScrn = xf86Screens[d->pI2CBus->scrnIndex];
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
status=I2C_DONE;
RADEONWaitForIdleMMIO(pScrn);
if(nWrite>0){
/* RADEONWaitForFifo(pScrn, 4+nWrite); */
/* Clear the status bits of the I2C Controller */
OUTREG(RADEON_I2C_CNTL_0, I2C_DONE | I2C_NACK | I2C_HALT | I2C_SOFT_RST);
/* Write the address into the buffer first */
OUTREG(RADEON_I2C_DATA, (CARD32) (d->SlaveAddr) & ~(1));
/* Write Value into the buffer */
for (loop = 0; loop < nWrite; loop++)
{
OUTREG8(RADEON_I2C_DATA, WriteBuffer[loop]);
}
i2c_cntl_1 = (pPriv->radeon_i2c_timing << 24) | I2C_EN | I2C_SEL |
nWrite | 0x100;
OUTREG(RADEON_I2C_CNTL_1, i2c_cntl_1);
i2c_cntl_0 = (pPriv->radeon_N << 24) | (pPriv->radeon_M << 16) |
I2C_GO | I2C_START | ((nRead >0)?0:I2C_STOP) | I2C_DRIVE_EN;
OUTREG(RADEON_I2C_CNTL_0, i2c_cntl_0);
I2C_WAIT_WITH_STATUS();
if(status!=I2C_DONE){
RADEON_I2C_Halt(pScrn);
return FALSE;
}
}
if(nRead > 0) {
RADEONWaitForFifo(pScrn, 4+nRead);
OUTREG(RADEON_I2C_CNTL_0, I2C_DONE | I2C_NACK | I2C_HALT | I2C_SOFT_RST);
/* Write the address into the buffer first */
OUTREG(RADEON_I2C_DATA, (CARD32) (d->SlaveAddr) | (1));
i2c_cntl_1 = (pPriv->radeon_i2c_timing << 24) | I2C_EN | I2C_SEL |
nRead | 0x100;
OUTREG(RADEON_I2C_CNTL_1, i2c_cntl_1);
i2c_cntl_0 = (pPriv->radeon_N << 24) | (pPriv->radeon_M << 16) |
I2C_GO | I2C_START | I2C_STOP | I2C_DRIVE_EN | I2C_RECEIVE;
OUTREG(RADEON_I2C_CNTL_0, i2c_cntl_0);
I2C_WAIT_WITH_STATUS();
/* Write Value into the buffer */
for (loop = 0; loop < nRead; loop++)
{
RADEONWaitForFifo(pScrn, 1);
if((status == I2C_HALT) || (status == I2C_NACK))
{
ReadBuffer[loop]=0xff;
} else {
RADEONWaitForIdleMMIO(pScrn);
ReadBuffer[loop]=INREG8(RADEON_I2C_DATA) & 0xff;
}
}
}
if(status!=I2C_DONE){
RADEON_I2C_Halt(pScrn);
return FALSE;
}
return TRUE;
}
static Bool R200_I2CWriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
I2CByte *ReadBuffer, int nRead)
{
int loop, status;
CARD32 i2c_cntl_0, i2c_cntl_1;
CARD8 reg;
RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)(d->pI2CBus->DriverPrivate.ptr);
ScrnInfoPtr pScrn = xf86Screens[d->pI2CBus->scrnIndex];
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
status=I2C_DONE;
RADEONWaitForIdleMMIO(pScrn);
if(nWrite>0){
/* RADEONWaitForFifo(pScrn, 4+nWrite); */
/* Clear the status bits of the I2C Controller */
OUTREG(RADEON_I2C_CNTL_0, I2C_DONE | I2C_NACK | I2C_HALT | I2C_SOFT_RST);
/* Write the address into the buffer first */
OUTREG(RADEON_I2C_DATA, (CARD32) (d->SlaveAddr) & ~(1));
/* Write Value into the buffer */
for (loop = 0; loop < nWrite; loop++)
{
OUTREG8(RADEON_I2C_DATA, WriteBuffer[loop]);
}
i2c_cntl_1 = (pPriv->radeon_i2c_timing << 24) | I2C_EN | I2C_SEL |
nWrite | 0x010;
OUTREG(RADEON_I2C_CNTL_1, i2c_cntl_1);
i2c_cntl_0 = (pPriv->radeon_N << 24) | (pPriv->radeon_M << 16) |
I2C_GO | I2C_START | ((nRead >0)?0:I2C_STOP) | I2C_DRIVE_EN;
OUTREG(RADEON_I2C_CNTL_0, i2c_cntl_0);
I2C_WAIT_WITH_STATUS();
if(status!=I2C_DONE){
RADEON_I2C_Halt(pScrn);
return FALSE;
}
}
if(nRead > 0) {
RADEONWaitForFifo(pScrn, 4+nRead);
OUTREG(RADEON_I2C_CNTL_0, I2C_DONE | I2C_NACK | I2C_HALT | I2C_SOFT_RST);
/* Write the address into the buffer first */
OUTREG(RADEON_I2C_DATA, (CARD32) (d->SlaveAddr) | (1));
i2c_cntl_1 = (pPriv->radeon_i2c_timing << 24) | I2C_EN | I2C_SEL |
nRead | 0x010;
OUTREG(RADEON_I2C_CNTL_1, i2c_cntl_1);
i2c_cntl_0 = (pPriv->radeon_N << 24) | (pPriv->radeon_M << 16) |
I2C_GO | I2C_START | I2C_STOP | I2C_DRIVE_EN | I2C_RECEIVE;
OUTREG(RADEON_I2C_CNTL_0, i2c_cntl_0);
I2C_WAIT_WITH_STATUS();
RADEONWaitForIdleMMIO(pScrn);
/* Write Value into the buffer */
for (loop = 0; loop < nRead; loop++)
{
if((status == I2C_HALT) || (status == I2C_NACK))
{
ReadBuffer[loop]=0xff;
} else {
ReadBuffer[loop]=INREG8(RADEON_I2C_DATA) & 0xff;
}
}
}
if(status!=I2C_DONE){
RADEON_I2C_Halt(pScrn);
return FALSE;
}
return TRUE;
}
#if 0
static Bool RADEONProbeAddress(I2CBusPtr b, I2CSlaveAddr addr)
{
I2CByte a;
I2CDevRec d;
d.DevName = "Probing";
d.SlaveAddr = addr;
d.pI2CBus = b;
d.NextDev = NULL;
return I2C_WriteRead(&d, NULL, 0, &a, 1);
}
#endif
#define I2C_CLOCK_FREQ (60000.0)
const struct
{
char *name;
int type;
} RADEON_tuners[32] =
{
/* name ,index to tuner_parms table */
{"NO TUNER" , -1},
{"Philips FI1236 (or compatible)" , TUNER_TYPE_FI1236},
{"Philips FI1236 (or compatible)" , TUNER_TYPE_FI1236},
{"Philips FI1216 (or compatible)" , TUNER_TYPE_FI1216},
{"Philips FI1246 (or compatible)" , TUNER_TYPE_FI1246},
{"Philips FI1216MF (or compatible)" , TUNER_TYPE_FI1216},
{"Philips FI1236 (or compatible)" , TUNER_TYPE_FI1236},
{"Philips FI1256 (or compatible)" , TUNER_TYPE_FI1256},
{"Philips FI1236 (or compatible)" , TUNER_TYPE_FI1236},
{"Philips FI1216 (or compatible)" , TUNER_TYPE_FI1216},
{"Philips FI1246 (or compatible)" , TUNER_TYPE_FI1246},
{"Philips FI1216MF (or compatible)" , TUNER_TYPE_FI1216},
{"Philips FI1236 (or compatible)" , TUNER_TYPE_FI1236},
{"TEMIC-FN5AL" , TUNER_TYPE_TEMIC_FN5AL},
{"FQ1216ME/P" , TUNER_TYPE_FI1216},
{"FI1236W" , TUNER_TYPE_FI1236W},
{"Philips FI1216ME (or compatible)" , TUNER_TYPE_FM1216ME},
/*{"Alps TSCxx" , -1},*/
{"Philips FM1236/F" , TUNER_TYPE_FI1236W},
{"Philips FI1216ME (or compatible)" , TUNER_TYPE_FM1216ME},
{"UNKNOWN-19" , -1},
{"UNKNOWN-20" , -1},
{"UNKNOWN-21" , -1},
{"UNKNOWN-22" , -1},
{"UNKNOWN-23" , -1},
{"UNKNOWN-24" , -1},
{"UNKNOWN-25" , -1},
{"UNKNOWN-26" , -1},
{"UNKNOWN-27" , -1},
{"UNKNOWN-28" , -1},
{"Microtuner MT2032" , TUNER_TYPE_MT2032},
{"Microtuner MT2032" , TUNER_TYPE_MT2032},
{"UNKNOWN-31" , -1}
};
void RADEONResetI2C(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
{
RADEONInfoPtr info = RADEONPTR(pScrn);
unsigned char *RADEONMMIO = info->MMIO;
RADEONWaitForFifo(pScrn, 2);
OUTREG8(RADEON_I2C_CNTL_1+2, ((I2C_SEL | I2C_EN)>>16));
OUTREG8(RADEON_I2C_CNTL_0+0, (I2C_DONE | I2C_NACK | I2C_HALT | I2C_SOFT_RST | I2C_DRIVE_EN | I2C_DRIVE_SEL));
}
void RADEONInitI2C(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
{
double nm;
RADEONInfoPtr info = RADEONPTR(pScrn);
RADEONPLLPtr pll = &(info->pll);
pPriv->i2c = NULL;
pPriv->fi1236 = NULL;
pPriv->msp3430 = NULL;
pPriv->tda9885 = NULL;
pPriv->uda1380 = NULL;
#if 0 /* put back on when saa7114 support is present */
pPriv->saa7114 = NULL;
#endif
/* Blacklist chipsets that lockup - these are usually older mobility chips */
switch(info->Chipset){
case PCI_CHIP_RADEON_LY:
case PCI_CHIP_RADEON_LZ:
xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Detected Radeon Mobility M6, disabling multimedia i2c\n");
return;
case PCI_CHIP_RADEON_LW:
xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Detected Radeon Mobility M7, disabling multimedia i2c\n");
return;
/*case PCI_CHIP_RV250_If:
xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Detected Radeon 9000 - skipping multimedia i2c initialization code.\n");
return;*/
case PCI_CHIP_RV370_5460:
xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Detected Radeon Mobility X300, disabling multimedia i2c\n");
return;
}
/* no multimedia capabilities detected and no information was provided to substitute for it */
if(!info->MM_TABLE_valid &&
!(info->tunerType>=0))
{
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No video input capabilities detected and no information is provided - disabling multimedia i2c\n");
return;
}
if(pPriv->i2c!=NULL) return; /* for some reason we are asked to init it again.. Stop ! */
if(!xf86LoadSubModule(pScrn,"i2c"))
{
xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"Unable to initialize i2c bus\n");
pPriv->i2c = NULL;
return;
}
xf86LoaderReqSymbols("xf86CreateI2CBusRec",
"xf86I2CBusInit",
"xf86DestroyI2CBus",
"xf86CreateI2CDevRec",
"xf86DestroyI2CDevRec",
"xf86I2CDevInit",
"xf86I2CWriteRead",
NULL);
pPriv->i2c=CreateI2CBusRec();
pPriv->i2c->scrnIndex=pScrn->scrnIndex;
pPriv->i2c->BusName="Radeon multimedia bus";
pPriv->i2c->DriverPrivate.ptr=(pointer)pPriv;
switch(info->ChipFamily){
case CHIP_FAMILY_RV350:
case CHIP_FAMILY_R350:
case CHIP_FAMILY_R300:
case CHIP_FAMILY_RV250:
case CHIP_FAMILY_R200:
case CHIP_FAMILY_RV200:
pPriv->i2c->I2CWriteRead=R200_I2CWriteRead;
xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Using R200 i2c bus access method\n");
break;
default:
pPriv->i2c->I2CWriteRead=RADEONI2CWriteRead;
xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Using Radeon bus access method\n");
}
if(!I2CBusInit(pPriv->i2c))
{
xf86DrvMsg(pScrn->scrnIndex,X_ERROR,"Failed to register i2c bus\n");
}
#if 1
switch(info->ChipFamily){
case CHIP_FAMILY_RV200:
nm=(pll->reference_freq * 40000.0)/(1.0*I2C_CLOCK_FREQ);
break;
case CHIP_FAMILY_R300:
case CHIP_FAMILY_R200:
if(info->MM_TABLE_valid && (RADEON_tuners[info->MM_TABLE.tuner_type & 0x1f].type==TUNER_TYPE_MT2032)){
nm=(pll->reference_freq * 40000.0)/(4.0*I2C_CLOCK_FREQ);
break;
}
default:
nm=(pll->reference_freq * 10000.0)/(4.0*I2C_CLOCK_FREQ);
}
#else
nm=(pll->xclk * 40000.0)/(1.0*I2C_CLOCK_FREQ);
#endif
for(pPriv->radeon_N=1; pPriv->radeon_N<255; pPriv->radeon_N++)
if((pPriv->radeon_N * (pPriv->radeon_N-1)) > nm)break;
pPriv->radeon_M=pPriv->radeon_N-1;
pPriv->radeon_i2c_timing=2*pPriv->radeon_N;
#if 0
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ref=%d M=0x%02x N=0x%02x timing=0x%02x\n", pll->reference_freq, pPriv->radeon_M, pPriv->radeon_N, pPriv->radeon_i2c_timing);
pPriv->radeon_M=0x32;
pPriv->radeon_N=0x33;
pPriv->radeon_i2c_timing=2*pPriv->radeon_N;
#endif
RADEONResetI2C(pScrn, pPriv);
#if 0 /* I don't know whether standalone boards are supported with Radeons */
/* looks like none of them have AMC connectors anyway */
if(!info->MM_TABLE_valid)RADEON_read_eeprom(pPriv);
#endif
if(!xf86LoadSubModule(pScrn,"fi1236"))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to initialize fi1236 driver\n");
}
else
{
xf86LoaderReqSymbols(FI1236SymbolsList, NULL);
if(pPriv->fi1236 == NULL)
{
pPriv->fi1236 = xf86_Detect_FI1236(pPriv->i2c, FI1236_ADDR_1);
}
if(pPriv->fi1236 == NULL)
{
pPriv->fi1236 = xf86_Detect_FI1236(pPriv->i2c, FI1236_ADDR_2);
}
}
if(pPriv->fi1236 != NULL)
{
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detected %s device at 0x%02x\n",
RADEON_tuners[info->MM_TABLE.tuner_type & 0x1f].name,
FI1236_ADDR(pPriv->fi1236));
if(info->MM_TABLE_valid)xf86_FI1236_set_tuner_type(pPriv->fi1236, RADEON_tuners[info->MM_TABLE.tuner_type & 0x1f].type);
else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "MM_TABLE not found (standalone board ?), forcing tuner type to NTSC\n");
xf86_FI1236_set_tuner_type(pPriv->fi1236, TUNER_TYPE_FI1236);
}
}
if(info->MM_TABLE_valid && (RADEON_tuners[info->MM_TABLE.tuner_type & 0x1f].type==TUNER_TYPE_MT2032)){
if(!xf86LoadSubModule(pScrn,"tda9885"))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to initialize tda9885 driver\n");
}
else
{
xf86LoaderReqSymbols(TDA9885SymbolsList, NULL);
if(pPriv->tda9885 == NULL)
{
pPriv->tda9885 = xf86_Detect_tda9885(pPriv->i2c, TDA9885_ADDR_1);
}
if(pPriv->tda9885 == NULL)
{
pPriv->tda9885 = xf86_Detect_tda9885(pPriv->i2c, TDA9885_ADDR_2);
}
if(pPriv->tda9885 != NULL)
{
RADEON_TDA9885_Init(pPriv);
}
}
}
if(info->MM_TABLE_valid && ((RADEON_tuners[info->MM_TABLE.tuner_type & 0x1f].type==TUNER_TYPE_FM1216ME)
|| (RADEON_tuners[info->MM_TABLE.tuner_type & 0x1f].type==TUNER_TYPE_FI1236W)))
{
if(!xf86LoadSubModule(pScrn,"tda9885"))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to initialize tda9885 driver\n");
}
else
{
xf86LoaderReqSymbols(TDA9885SymbolsList, NULL);
if(pPriv->tda9885 == NULL)
{
pPriv->tda9885 = xf86_Detect_tda9885(pPriv->i2c, TDA9885_ADDR_1);
}
if(pPriv->tda9885 == NULL)
{
pPriv->tda9885 = xf86_Detect_tda9885(pPriv->i2c, TDA9885_ADDR_2);
}
if(pPriv->tda9885 != NULL)
{
RADEON_TDA9885_Init(pPriv);
pPriv->fi1236->afc_source = (void*)pPriv->tda9885;
}
}
}
if(!xf86LoadSubModule(pScrn,"uda1380"))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to initialize uda1380 driver\n");
}
else
{
xf86LoaderReqSymbols(UDA1380SymbolsList, NULL);
if(pPriv->uda1380 == NULL)
{
pPriv->uda1380 = xf86_Detect_uda1380(pPriv->i2c, UDA1380_ADDR_1);
}
if(pPriv->uda1380 == NULL)
{
pPriv->uda1380 = xf86_Detect_uda1380(pPriv->i2c, UDA1380_ADDR_2);
}
if(pPriv->uda1380 != NULL)
{
xf86_uda1380_init(pPriv->uda1380);
}
}
if(!xf86LoadSubModule(pScrn,"msp3430"))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to initialize msp3430 driver\n");
}
else
{
xf86LoaderReqSymbols(MSP3430SymbolsList, NULL);
if(pPriv->msp3430 == NULL)
{
pPriv->msp3430 = xf86_DetectMSP3430(pPriv->i2c, MSP3430_ADDR_1);
}
if(pPriv->msp3430 == NULL)
{
pPriv->msp3430 = xf86_DetectMSP3430(pPriv->i2c, MSP3430_ADDR_2);
}
#if 0 /* this would confuse bt829 with msp3430 */
if(pPriv->msp3430 == NULL)
{
pPriv->msp3430 = xf86_DetectMSP3430(pPriv->i2c, MSP3430_ADDR_3);
}
#endif
}
if(pPriv->msp3430 != NULL)
{
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detected MSP3430 at 0x%02x\n",
MSP3430_ADDR(pPriv->msp3430));
pPriv->msp3430->standard = MSP3430_NTSC;
pPriv->msp3430->connector = MSP3430_CONNECTOR_1;
xf86_ResetMSP3430(pPriv->msp3430);
xf86_InitMSP3430(pPriv->msp3430);
xf86_MSP3430SetVolume(pPriv->msp3430, pPriv->mute ? MSP3430_FAST_MUTE : MSP3430_VOLUME(pPriv->volume));
}
#if 0 /* put this back when saa7114 driver is ready */
if(!xf86LoadSubModule(pScrn,"saa7114"))
{
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unable to initialize saa7114 driver\n");
}
else
{
xf86LoaderReqSymbols(SAA7114SymbolsList, NULL);
if(pPriv->saa7114 == NULL)
{
pPriv->saa7114 = xf86_DetectSAA7114(pPriv->i2c, SAA7114_ADDR_1);
}
if(pPriv->saa7114 == NULL)
{
pPriv->saa7114 = xf86_DetectSAA7114(pPriv->i2c, SAA7114_ADDR_2);
}
}
if(pPriv->saa7114 != NULL)
{
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detected SAA7114 at 0x%02x\n",
pPriv->saa7114->d.SlaveAddr);
xf86_InitSAA7114(pPriv->saa7114);
}
#endif
}
static void RADEON_TDA9885_Init(RADEONPortPrivPtr pPriv)
{
TDA9885Ptr t=pPriv->tda9885;
t->sound_trap=0;
t->auto_mute_fm=1; /* ? */
t->carrier_mode=0; /* ??? */
t->modulation=2; /* negative FM */
t->forced_mute_audio=0;
t->port1=1;
t->port2=1;
t->top_adjustment=0x10;
t->deemphasis=1;
t->audio_gain=0;
t->minimum_gain=0;
t->gating=0;
t->vif_agc=1; /* set to 1 ? - depends on design */
t->gating=0;
}
|