Mercurial > mplayer.hg
comparison vidix/drivers/sis_bridge.c @ 11038:3bac281db5a1
SiS 650/651/740/etc driver by Jake Page <jake@CS.Stanford.EDU>
author | alex |
---|---|
date | Tue, 07 Oct 2003 23:12:16 +0000 |
parents | |
children | 628dd5d2326c |
comparison
equal
deleted
inserted
replaced
11037:77ed12a4f0b1 | 11038:3bac281db5a1 |
---|---|
1 /** | |
2 Video bridge detection for SiS 300 and 310/325 series chips. | |
3 | |
4 Copyright 2003 Jake Page, Sugar Media. | |
5 | |
6 Based on SiS Xv driver: | |
7 Copyright 2002-2003 by Thomas Winischhofer, Vienna, Austria. | |
8 | |
9 This program is free software; you can redistribute it and/or modify | |
10 it under the terms of the GNU General Public License as published by | |
11 the Free Software Foundation; either version 2 of the License, or | |
12 (at your option) any later version. | |
13 | |
14 This program is distributed in the hope that it will be useful, | |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
20 along with this program; if not, write to the Free Software | |
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 | |
23 **/ | |
24 | |
25 #include <stdio.h> | |
26 #include <stdlib.h> | |
27 #include <unistd.h> | |
28 | |
29 | |
30 #include "sis_regs.h" | |
31 #include "sis_defs.h" | |
32 | |
33 | |
34 static void sis_ddc2_delay(unsigned short delaytime) | |
35 { | |
36 unsigned short i; | |
37 int temp; | |
38 | |
39 for (i = 0; i < delaytime; i++) { | |
40 inSISIDXREG(SISSR, 0x05, temp); | |
41 } | |
42 } | |
43 | |
44 | |
45 static int sis_do_sense(int tempbl, int tempbh, int tempcl, int tempch) | |
46 { | |
47 int temp; | |
48 | |
49 outSISIDXREG(SISPART4, 0x11, tempbl); | |
50 temp = tempbh | tempcl; | |
51 setSISIDXREG(SISPART4, 0x10, 0xe0, temp); | |
52 //usleep(200000); | |
53 sis_ddc2_delay(0x1000); | |
54 tempch &= 0x7f; | |
55 inSISIDXREG(SISPART4, 0x03, temp); | |
56 temp ^= 0x0e; | |
57 temp &= tempch; | |
58 return (temp == tempch); | |
59 } | |
60 | |
61 | |
62 /* sense connected devices on 30x bridge */ | |
63 static void sis_sense_30x() | |
64 { | |
65 unsigned char backupP4_0d, backupP2_00, biosflag; | |
66 unsigned char testsvhs_tempbl, testsvhs_tempbh; | |
67 unsigned char testsvhs_tempcl, testsvhs_tempch; | |
68 unsigned char testcvbs_tempbl, testcvbs_tempbh; | |
69 unsigned char testcvbs_tempcl, testcvbs_tempch; | |
70 unsigned char testvga2_tempbl, testvga2_tempbh; | |
71 unsigned char testvga2_tempcl, testvga2_tempch; | |
72 int myflag, result = 0, i, j, haveresult; | |
73 unsigned short temp; | |
74 | |
75 inSISIDXREG(SISPART4, 0x0d, backupP4_0d); | |
76 outSISIDXREG(SISPART4, 0x0d, (backupP4_0d | 0x04)); | |
77 | |
78 inSISIDXREG(SISPART2, 0x00, backupP2_00); | |
79 outSISIDXREG(SISPART2, 0x00, (backupP2_00 | 0x1c)); | |
80 | |
81 sis_do_sense(0, 0, 0, 0); | |
82 | |
83 if ((sis_vga_engine == SIS_315_VGA) || | |
84 (sis_device_id == DEVICE_SIS_300)) { | |
85 #if 0 | |
86 if (0 /*pSiS->sishw_ext.UseROM */ ) { | |
87 if (sis_vga_engine == SIS_300_VGA) | |
88 temp = 0xfe; | |
89 else { | |
90 temp = 0xf3; | |
91 if (sis_device_id == DEVICE_SIS_330) | |
92 temp = 0x11b; | |
93 } | |
94 if (pSiS->BIOS[temp] & 0x08) { | |
95 if (sis_verbose > 1) { | |
96 printf | |
97 ("[SiS] SiS30x: Video bridge has DVI-I TMDS/VGA combo connector\n"); | |
98 } | |
99 orSISIDXREG(SISCR, 0x32, 0x80); | |
100 } else { | |
101 andSISIDXREG(SISCR, 0x32, 0x7f); | |
102 } | |
103 } | |
104 #endif | |
105 } | |
106 | |
107 if (sis_vga_engine == SIS_300_VGA) { | |
108 if (0 /*pSiS->sishw_ext.UseROM */ ) { | |
109 #if 0 | |
110 testvga2_tempbh = pSiS->BIOS[0xf9]; | |
111 testvga2_tempbl = pSiS->BIOS[0xf8]; | |
112 testsvhs_tempbh = pSiS->BIOS[0xfb]; | |
113 testsvhs_tempbl = pSiS->BIOS[0xfa]; | |
114 testcvbs_tempbh = pSiS->BIOS[0xfd]; | |
115 testcvbs_tempbl = pSiS->BIOS[0xfc]; | |
116 biosflag = pSiS->BIOS[0xfe]; | |
117 #endif | |
118 } else { | |
119 testvga2_tempbh = 0x00; | |
120 testvga2_tempbl = 0xd1; | |
121 testsvhs_tempbh = 0x00; | |
122 testsvhs_tempbl = 0xb9; | |
123 testcvbs_tempbh = 0x00; | |
124 testcvbs_tempbl = 0xb3; | |
125 biosflag = 0; | |
126 } | |
127 if (sis_vbflags & (VB_301B | VB_302B | VB_301LV | VB_302LV)) { | |
128 testvga2_tempbh = 0x01; | |
129 testvga2_tempbl = 0x90; | |
130 testsvhs_tempbh = 0x01; | |
131 testsvhs_tempbl = 0x6b; | |
132 testcvbs_tempbh = 0x01; | |
133 testcvbs_tempbl = 0x74; | |
134 } | |
135 inSISIDXREG(SISPART4, 0x01, myflag); | |
136 if (myflag & 0x04) { | |
137 testvga2_tempbh = 0x00; | |
138 testvga2_tempbl = 0xfd; | |
139 testsvhs_tempbh = 0x00; | |
140 testsvhs_tempbl = 0xdd; | |
141 testcvbs_tempbh = 0x00; | |
142 testcvbs_tempbl = 0xee; | |
143 } | |
144 testvga2_tempch = 0x0e; | |
145 testvga2_tempcl = 0x08; | |
146 testsvhs_tempch = 0x06; | |
147 testsvhs_tempcl = 0x04; | |
148 testcvbs_tempch = 0x08; | |
149 testcvbs_tempcl = 0x04; | |
150 | |
151 if (sis_device_id == DEVICE_SIS_300) { | |
152 inSISIDXREG(SISSR, 0x3b, myflag); | |
153 if (!(myflag & 0x01)) { | |
154 testvga2_tempbh = 0x00; | |
155 testvga2_tempbl = 0x00; | |
156 testvga2_tempch = 0x00; | |
157 testvga2_tempcl = 0x00; | |
158 } | |
159 } | |
160 } else { | |
161 if (0 /*pSiS->sishw_ext.UseROM */ ) { | |
162 #if 0 | |
163 if (sis_device_id == DEVICE_SIS_330) { | |
164 testvga2_tempbh = pSiS->BIOS[0xe6]; | |
165 testvga2_tempbl = pSiS->BIOS[0xe5]; | |
166 testsvhs_tempbh = pSiS->BIOS[0xe8]; | |
167 testsvhs_tempbl = pSiS->BIOS[0xe7]; | |
168 testcvbs_tempbh = pSiS->BIOS[0xea]; | |
169 testcvbs_tempbl = pSiS->BIOS[0xe9]; | |
170 biosflag = pSiS->BIOS[0x11b]; | |
171 } else { | |
172 testvga2_tempbh = pSiS->BIOS[0xbe]; | |
173 testvga2_tempbl = pSiS->BIOS[0xbd]; | |
174 testsvhs_tempbh = pSiS->BIOS[0xc0]; | |
175 testsvhs_tempbl = pSiS->BIOS[0xbf]; | |
176 testcvbs_tempbh = pSiS->BIOS[0xc2]; | |
177 testcvbs_tempbl = pSiS->BIOS[0xc1]; | |
178 biosflag = pSiS->BIOS[0xf3]; | |
179 } | |
180 #endif | |
181 } else { | |
182 testvga2_tempbh = 0x00; | |
183 testvga2_tempbl = 0xd1; | |
184 testsvhs_tempbh = 0x00; | |
185 testsvhs_tempbl = 0xb9; | |
186 testcvbs_tempbh = 0x00; | |
187 testcvbs_tempbl = 0xb3; | |
188 biosflag = 0; | |
189 } | |
190 | |
191 if (sis_vbflags & (VB_301B | VB_302B | VB_301LV | VB_302LV)) { | |
192 if (0 /*pSiS->sishw_ext.UseROM */ ) { | |
193 #if 0 | |
194 if (sis_device_id == DEVICE_SIS_330) { | |
195 testvga2_tempbh = pSiS->BIOS[0xec]; | |
196 testvga2_tempbl = pSiS->BIOS[0xeb]; | |
197 testsvhs_tempbh = pSiS->BIOS[0xee]; | |
198 testsvhs_tempbl = pSiS->BIOS[0xed]; | |
199 testcvbs_tempbh = pSiS->BIOS[0xf0]; | |
200 testcvbs_tempbl = pSiS->BIOS[0xef]; | |
201 } else { | |
202 testvga2_tempbh = pSiS->BIOS[0xc4]; | |
203 testvga2_tempbl = pSiS->BIOS[0xc3]; | |
204 testsvhs_tempbh = pSiS->BIOS[0xc6]; | |
205 testsvhs_tempbl = pSiS->BIOS[0xc5]; | |
206 testcvbs_tempbh = pSiS->BIOS[0xc8]; | |
207 testcvbs_tempbl = pSiS->BIOS[0xc7]; | |
208 } | |
209 #endif | |
210 } else { | |
211 if (sis_vbflags & (VB_301B | VB_302B)) { | |
212 testvga2_tempbh = 0x01; | |
213 testvga2_tempbl = 0x90; | |
214 testsvhs_tempbh = 0x01; | |
215 testsvhs_tempbl = 0x6b; | |
216 testcvbs_tempbh = 0x01; | |
217 testcvbs_tempbl = 0x74; | |
218 } else { | |
219 testvga2_tempbh = 0x00; | |
220 testvga2_tempbl = 0x00; | |
221 testsvhs_tempbh = 0x02; | |
222 testsvhs_tempbl = 0x00; | |
223 testcvbs_tempbh = 0x01; | |
224 testcvbs_tempbl = 0x00; | |
225 } | |
226 } | |
227 } | |
228 if (sis_vbflags & (VB_301 | VB_301B | VB_302B)) { | |
229 inSISIDXREG(SISPART4, 0x01, myflag); | |
230 if (myflag & 0x04) { | |
231 testvga2_tempbh = 0x00; | |
232 testvga2_tempbl = 0xfd; | |
233 testsvhs_tempbh = 0x00; | |
234 testsvhs_tempbl = 0xdd; | |
235 testcvbs_tempbh = 0x00; | |
236 testcvbs_tempbl = 0xee; | |
237 } | |
238 } | |
239 if (sis_vbflags & (VB_301LV | VB_302LV)) { | |
240 /* TW: No VGA2 or SCART on LV bridges */ | |
241 testvga2_tempbh = 0x00; | |
242 testvga2_tempbl = 0x00; | |
243 testvga2_tempch = 0x00; | |
244 testvga2_tempcl = 0x00; | |
245 testsvhs_tempch = 0x04; | |
246 testsvhs_tempcl = 0x08; | |
247 testcvbs_tempch = 0x08; | |
248 testcvbs_tempcl = 0x08; | |
249 } else { | |
250 testvga2_tempch = 0x0e; | |
251 testvga2_tempcl = 0x08; | |
252 testsvhs_tempch = 0x06; | |
253 testsvhs_tempcl = 0x04; | |
254 testcvbs_tempch = 0x08; | |
255 testcvbs_tempcl = 0x04; | |
256 } | |
257 } | |
258 | |
259 /* XXX: ?? andSISIDXREG(SISCR, 0x32, ~0x14); */ | |
260 /* pSiS->postVBCR32 &= ~0x14; */ | |
261 | |
262 /* scan for VGA2/SCART */ | |
263 if (testvga2_tempch || testvga2_tempcl || | |
264 testvga2_tempbh || testvga2_tempbl) { | |
265 | |
266 haveresult = 0; | |
267 for (j = 0; j < 10; j++) { | |
268 result = 0; | |
269 for (i = 0; i < 3; i++) { | |
270 if (sis_do_sense(testvga2_tempbl, testvga2_tempbh, | |
271 testvga2_tempcl, testvga2_tempch)) | |
272 result++; | |
273 } | |
274 if ((result == 0) || (result >= 2)) | |
275 break; | |
276 } | |
277 if (result) { | |
278 if (biosflag & 0x01) { | |
279 if (sis_verbose > 1) { | |
280 printf | |
281 ("[SiS] SiS30x: Detected TV connected to SCART output\n"); | |
282 } | |
283 sis_vbflags |= TV_SCART; | |
284 orSISIDXREG(SISCR, 0x32, 0x04); | |
285 /*pSiS->postVBCR32 |= 0x04; */ | |
286 } else { | |
287 if (sis_verbose > 1) { | |
288 printf | |
289 ("[SiS] SiS30x: Detected secondary VGA connection\n"); | |
290 } | |
291 sis_vbflags |= VGA2_CONNECTED; | |
292 orSISIDXREG(SISCR, 0x32, 0x10); | |
293 /*pSiS->postVBCR32 |= 0x10; */ | |
294 } | |
295 } | |
296 } | |
297 | |
298 /* scanning for TV */ | |
299 | |
300 /* XXX: ?? andSISIDXREG(SISCR, 0x32, ~0x03); */ | |
301 /* pSiS->postVBCR32 &= ~0x03; */ | |
302 | |
303 result = sis_do_sense(testsvhs_tempbl, testsvhs_tempbh, | |
304 testsvhs_tempcl, testsvhs_tempch); | |
305 | |
306 | |
307 haveresult = 0; | |
308 for (j = 0; j < 10; j++) { | |
309 result = 0; | |
310 for (i = 0; i < 3; i++) { | |
311 if (sis_do_sense(testsvhs_tempbl, testsvhs_tempbh, | |
312 testsvhs_tempcl, testsvhs_tempch)) | |
313 result++; | |
314 } | |
315 if ((result == 0) || (result >= 2)) | |
316 break; | |
317 } | |
318 if (result) { | |
319 if (sis_verbose > 1) { | |
320 printf | |
321 ("[SiS] SiS30x: Detected TV connected to SVIDEO output\n"); | |
322 } | |
323 /* TW: So we can be sure that there IS a SVIDEO output */ | |
324 sis_vbflags |= TV_SVIDEO; | |
325 orSISIDXREG(SISCR, 0x32, 0x02); | |
326 //pSiS->postVBCR32 |= 0x02; | |
327 } | |
328 | |
329 if ((biosflag & 0x02) || (!(result))) { | |
330 haveresult = 0; | |
331 for (j = 0; j < 10; j++) { | |
332 result = 0; | |
333 for (i = 0; i < 3; i++) { | |
334 if (sis_do_sense(testcvbs_tempbl, testcvbs_tempbh, | |
335 testcvbs_tempcl, testcvbs_tempch)) | |
336 result++; | |
337 } | |
338 if ((result == 0) || (result >= 2)) | |
339 break; | |
340 } | |
341 if (result) { | |
342 if (sis_verbose > 1) { | |
343 printf | |
344 ("[SiS] SiS30x: Detected TV connected to COMPOSITE output\n"); | |
345 } | |
346 sis_vbflags |= TV_AVIDEO; | |
347 orSISIDXREG(SISCR, 0x32, 0x01); | |
348 //pSiS->postVBCR32 |= 0x01; | |
349 } | |
350 } | |
351 | |
352 sis_do_sense(0, 0, 0, 0); | |
353 | |
354 outSISIDXREG(SISPART2, 0x00, backupP2_00); | |
355 outSISIDXREG(SISPART4, 0x0d, backupP4_0d); | |
356 } | |
357 | |
358 | |
359 static void sis_detect_crt1() | |
360 { | |
361 unsigned char CR32; | |
362 unsigned char CRT1Detected = 0; | |
363 unsigned char OtherDevices = 0; | |
364 | |
365 if (!(sis_vbflags & VB_VIDEOBRIDGE)) { | |
366 sis_crt1_off = 0; | |
367 return; | |
368 } | |
369 | |
370 inSISIDXREG(SISCR, 0x32, CR32); | |
371 | |
372 if (CR32 & 0x20) | |
373 CRT1Detected = 1; | |
374 if (CR32 & 0x5F) | |
375 OtherDevices = 1; | |
376 | |
377 if (sis_crt1_off == -1) { | |
378 if (!CRT1Detected) { | |
379 /* BIOS detected no CRT1. */ | |
380 /* If other devices exist, switch it off */ | |
381 if (OtherDevices) | |
382 sis_crt1_off = 1; | |
383 else | |
384 sis_crt1_off = 0; | |
385 } else { | |
386 /* BIOS detected CRT1, leave/switch it on */ | |
387 sis_crt1_off = 0; | |
388 } | |
389 } | |
390 if (sis_verbose > 0) { | |
391 printf("[SiS] %sCRT1 connection detected\n", | |
392 sis_crt1_off ? "No " : ""); | |
393 } | |
394 } | |
395 | |
396 | |
397 static void sis_detect_lcd() | |
398 { | |
399 unsigned char CR32, CR36, CR37; | |
400 | |
401 if (!(sis_vbflags & VB_VIDEOBRIDGE)) { | |
402 return; | |
403 } | |
404 | |
405 inSISIDXREG(SISCR, 0x32, CR32); | |
406 | |
407 if (CR32 & 0x08) | |
408 sis_vbflags |= CRT2_LCD; | |
409 | |
410 /* DDC detection of LCD - not supported yet */ | |
411 | |
412 /* Get other misc info about LCD - not supported */ | |
413 } | |
414 | |
415 | |
416 static void sis_detect_tv() | |
417 { | |
418 unsigned char SR16, SR38, CR32, CR38 = 0, CR79; | |
419 int temp = 0; | |
420 | |
421 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
422 return; | |
423 | |
424 inSISIDXREG(SISCR, 0x32, CR32); | |
425 inSISIDXREG(SISSR, 0x16, SR16); | |
426 inSISIDXREG(SISSR, 0x38, SR38); | |
427 switch (sis_vga_engine) { | |
428 case SIS_300_VGA: | |
429 if (sis_device_id == DEVICE_SIS_630_VGA) | |
430 temp = 0x35; | |
431 break; | |
432 case SIS_315_VGA: | |
433 temp = 0x38; | |
434 break; | |
435 } | |
436 if (temp) { | |
437 inSISIDXREG(SISCR, temp, CR38); | |
438 } | |
439 | |
440 if (CR32 & 0x47) | |
441 sis_vbflags |= CRT2_TV; | |
442 | |
443 if (CR32 & 0x04) | |
444 sis_vbflags |= TV_SCART; | |
445 else if (CR32 & 0x02) | |
446 sis_vbflags |= TV_SVIDEO; | |
447 else if (CR32 & 0x01) | |
448 sis_vbflags |= TV_AVIDEO; | |
449 else if (CR32 & 0x40) | |
450 sis_vbflags |= (TV_SVIDEO | TV_HIVISION); | |
451 else if ((CR38 & 0x04) && (sis_vbflags & (VB_301LV | VB_302LV))) | |
452 sis_vbflags |= TV_HIVISION_LV; | |
453 else if ((CR38 & 0x04) && (sis_vbflags & VB_CHRONTEL)) | |
454 sis_vbflags |= (TV_CHSCART | TV_PAL); | |
455 else if ((CR38 & 0x08) && (sis_vbflags & VB_CHRONTEL)) | |
456 sis_vbflags |= (TV_CHHDTV | TV_NTSC); | |
457 | |
458 if (sis_vbflags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION)) { | |
459 if (sis_vga_engine == SIS_300_VGA) { | |
460 /* TW: Should be SR38 here as well, but this | |
461 * does not work. Looks like a BIOS bug (2.04.5c). | |
462 */ | |
463 if (SR16 & 0x20) | |
464 sis_vbflags |= TV_PAL; | |
465 else | |
466 sis_vbflags |= TV_NTSC; | |
467 } else if ((sis_device_id == DEVICE_SIS_550_VGA)) { | |
468 inSISIDXREG(SISCR, 0x79, CR79); | |
469 if (CR79 & 0x08) { | |
470 inSISIDXREG(SISCR, 0x79, CR79); | |
471 CR79 >>= 5; | |
472 } | |
473 if (CR79 & 0x01) { | |
474 sis_vbflags |= TV_PAL; | |
475 if (CR38 & 0x40) | |
476 sis_vbflags |= TV_PALM; | |
477 else if (CR38 & 0x80) | |
478 sis_vbflags |= TV_PALN; | |
479 } else | |
480 sis_vbflags |= TV_NTSC; | |
481 } else if ((sis_device_id == DEVICE_SIS_650_VGA)) { | |
482 inSISIDXREG(SISCR, 0x79, CR79); | |
483 if (CR79 & 0x20) { | |
484 sis_vbflags |= TV_PAL; | |
485 if (CR38 & 0x40) | |
486 sis_vbflags |= TV_PALM; | |
487 else if (CR38 & 0x80) | |
488 sis_vbflags |= TV_PALN; | |
489 } else | |
490 sis_vbflags |= TV_NTSC; | |
491 } else { /* 315, 330 */ | |
492 if (SR38 & 0x01) { | |
493 sis_vbflags |= TV_PAL; | |
494 if (CR38 & 0x40) | |
495 sis_vbflags |= TV_PALM; | |
496 else if (CR38 & 0x80) | |
497 sis_vbflags |= TV_PALN; | |
498 } else | |
499 sis_vbflags |= TV_NTSC; | |
500 } | |
501 } | |
502 | |
503 if (sis_vbflags & | |
504 (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_CHSCART | | |
505 TV_CHHDTV)) { | |
506 if (sis_verbose > 0) { | |
507 printf("[SiS] %sTV standard %s\n", | |
508 (sis_vbflags & (TV_CHSCART | TV_CHHDTV)) ? "Using " : | |
509 "Detected default ", | |
510 (sis_vbflags & TV_NTSC) ? ((sis_vbflags & TV_CHHDTV) ? | |
511 "480i HDTV" : "NTSC") | |
512 : ((sis_vbflags & TV_PALM) ? "PALM" | |
513 : ((sis_vbflags & TV_PALN) ? "PALN" : "PAL"))); | |
514 } | |
515 } | |
516 | |
517 } | |
518 | |
519 | |
520 static void sis_detect_crt2() | |
521 { | |
522 unsigned char CR32; | |
523 | |
524 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
525 return; | |
526 | |
527 /* CRT2-VGA not supported on LVDS and 30xLV */ | |
528 if (sis_vbflags & (VB_LVDS | VB_301LV | VB_302LV)) | |
529 return; | |
530 | |
531 inSISIDXREG(SISCR, 0x32, CR32); | |
532 | |
533 if (CR32 & 0x10) | |
534 sis_vbflags |= CRT2_VGA; | |
535 | |
536 #if 0 | |
537 if (!(pSiS->nocrt2ddcdetection)) { | |
538 if (sis_vbflags & (VB_301B | VB_302B)) { | |
539 if (!(sis_vbflags & (CRT2_VGA | CRT2_LCD))) { | |
540 printf | |
541 ("[SiS] BIOS detected no secondary VGA, sensing via DDC\n"); | |
542 if (SiS_SenseVGA2DDC(pSiS->SiS_Pr, pSiS)) { | |
543 printf | |
544 ("[SiS] DDC error during secondary VGA detection\n"); | |
545 } else { | |
546 inSISIDXREG(SISCR, 0x32, CR32); | |
547 if (CR32 & 0x10) { | |
548 sis_vbflags |= CRT2_VGA; | |
549 /*pSiS->postVBCR32 |= 0x10; */ | |
550 printf | |
551 ("[SiS] Detected secondary VGA connection\n"); | |
552 } else { | |
553 printf | |
554 ("[SiS] No secondary VGA connection detected\n"); | |
555 } | |
556 } | |
557 } | |
558 } | |
559 } | |
560 #endif | |
561 | |
562 } | |
563 | |
564 | |
565 /* Preinit: detect video bridge and sense connected devs */ | |
566 static void sis_detect_video_bridge() | |
567 { | |
568 int temp, temp1, temp2; | |
569 | |
570 | |
571 sis_vbflags = 0; | |
572 | |
573 if (sis_vga_engine != SIS_300_VGA && sis_vga_engine != SIS_315_VGA) | |
574 return; | |
575 | |
576 inSISIDXREG(SISPART4, 0x00, temp); | |
577 temp &= 0x0F; | |
578 if (temp == 1) { | |
579 inSISIDXREG(SISPART4, 0x01, temp1); | |
580 temp1 &= 0xff; | |
581 if (temp1 >= 0xE0) { | |
582 sis_vbflags |= VB_302LV; | |
583 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
584 if (sis_verbose > 1) { | |
585 printf | |
586 ("[SiS] Detected SiS302LV video bridge (ID 1; Revision 0x%x)\n", | |
587 temp1); | |
588 } | |
589 | |
590 } else if (temp1 >= 0xD0) { | |
591 sis_vbflags |= VB_301LV; | |
592 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
593 if (sis_verbose > 1) { | |
594 printf | |
595 ("[SiS] Detected SiS301LV video bridge (ID 1; Revision 0x%x)\n", | |
596 temp1); | |
597 } | |
598 } else if (temp1 >= 0xB0) { | |
599 sis_vbflags |= VB_301B; | |
600 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301B; | |
601 inSISIDXREG(SISPART4, 0x23, temp2); | |
602 if (!(temp2 & 0x02)) | |
603 sis_vbflags |= VB_30xBDH; | |
604 if (sis_verbose > 1) { | |
605 printf | |
606 ("[SiS] Detected SiS301B%s video bridge (Revision 0x%x)\n", | |
607 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
608 } | |
609 } else { | |
610 sis_vbflags |= VB_301; | |
611 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301; | |
612 if (sis_verbose > 1) { | |
613 printf | |
614 ("[SiS] Detected SiS301 video bridge (Revision 0x%x)\n", | |
615 temp1); | |
616 } | |
617 } | |
618 | |
619 sis_sense_30x(); | |
620 | |
621 } else if (temp == 2) { | |
622 | |
623 inSISIDXREG(SISPART4, 0x01, temp1); | |
624 temp1 &= 0xff; | |
625 if (temp1 >= 0xE0) { | |
626 sis_vbflags |= VB_302LV; | |
627 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
628 if (sis_verbose > 1) { | |
629 printf | |
630 ("[SiS] Detected SiS302LV video bridge (ID 2; Revision 0x%x)\n", | |
631 temp1); | |
632 } | |
633 } else if (temp1 >= 0xD0) { | |
634 sis_vbflags |= VB_301LV; | |
635 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
636 if (sis_verbose > 1) { | |
637 printf | |
638 ("[SiS] Detected SiS301LV video bridge (ID 2; Revision 0x%x)\n", | |
639 temp1); | |
640 } | |
641 } else { | |
642 sis_vbflags |= VB_302B; | |
643 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302B; | |
644 inSISIDXREG(SISPART4, 0x23, temp2); | |
645 if (!(temp & 0x02)) | |
646 sis_vbflags |= VB_30xBDH; | |
647 if (sis_verbose > 1) { | |
648 printf | |
649 ("[SiS] Detected SiS302B%s video bridge (Revision 0x%x)\n", | |
650 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
651 } | |
652 } | |
653 | |
654 sis_sense_30x(); | |
655 | |
656 } else if (temp == 3) { | |
657 if (sis_verbose > 1) { | |
658 printf("[SiS] Detected SiS303 video bridge - not supported\n"); | |
659 } | |
660 } else { | |
661 /* big scary mess of code to handle unknown or Chrontel LVDS */ | |
662 /* skipping it for now */ | |
663 if (sis_verbose > 1) { | |
664 printf | |
665 ("[SiS] Detected Chrontel video bridge - not supported\n"); | |
666 } | |
667 } | |
668 | |
669 /* this is probably not relevant to video overlay driver... */ | |
670 /* detects if brdige uses LCDA for low res text modes */ | |
671 if (sis_vga_engine == SIS_315_VGA) { | |
672 if (sis_vbflags & (VB_302B | VB_301LV | VB_302LV)) { | |
673 #if 0 | |
674 if (pSiS->sisfblcda != 0xff) { | |
675 if ((pSiS->sisfblcda & 0x03) == 0x03) { | |
676 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
677 sis_vbflags |= VB_USELCDA; | |
678 } | |
679 } else | |
680 #endif | |
681 { | |
682 inSISIDXREG(SISCR, 0x34, temp); | |
683 if (temp <= 0x13) { | |
684 inSISIDXREG(SISCR, 0x38, temp); | |
685 if ((temp & 0x03) == 0x03) { | |
686 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
687 sis_vbflags |= VB_USELCDA; | |
688 } else { | |
689 inSISIDXREG(SISCR, 0x30, temp); | |
690 if (temp & 0x20) { | |
691 inSISIDXREG(SISPART1, 0x13, temp); | |
692 if (temp & 0x40) { | |
693 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
694 sis_vbflags |= VB_USELCDA; | |
695 } | |
696 } | |
697 } | |
698 } | |
699 } | |
700 if (sis_vbflags & VB_USELCDA) { | |
701 /* printf("Bridge uses LCDA for low resolution and text modes\n"); */ | |
702 } | |
703 } | |
704 } | |
705 | |
706 | |
707 } | |
708 | |
709 | |
710 /* detect video bridge type and sense connected devices */ | |
711 void sis_init_video_bridge() | |
712 { | |
713 | |
714 sis_detect_video_bridge(); | |
715 | |
716 sis_detect_crt1(); | |
717 //sis_detect_lcd(); | |
718 sis_detect_tv(); | |
719 sis_detect_crt2(); | |
720 | |
721 sis_detected_crt2_devices = | |
722 sis_vbflags & (CRT2_LCD | CRT2_TV | CRT2_VGA); | |
723 | |
724 // force crt2 type | |
725 if (sis_force_crt2_type == CRT2_DEFAULT) { | |
726 if (sis_vbflags & CRT2_VGA) | |
727 sis_force_crt2_type = CRT2_VGA; | |
728 else if (sis_vbflags & CRT2_LCD) | |
729 sis_force_crt2_type = CRT2_LCD; | |
730 else if (sis_vbflags & CRT2_TV) | |
731 sis_force_crt2_type = CRT2_TV; | |
732 } | |
733 | |
734 switch (sis_force_crt2_type) { | |
735 case CRT2_TV: | |
736 sis_vbflags = sis_vbflags & ~(CRT2_LCD | CRT2_VGA); | |
737 if (sis_vbflags & VB_VIDEOBRIDGE) | |
738 sis_vbflags = sis_vbflags | CRT2_TV; | |
739 else | |
740 sis_vbflags = sis_vbflags & ~(CRT2_TV); | |
741 break; | |
742 case CRT2_LCD: | |
743 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_VGA); | |
744 if ((sis_vbflags & VB_VIDEOBRIDGE) /* XXX: && (pSiS->VBLCDFlags) */ | |
745 ) | |
746 sis_vbflags = sis_vbflags | CRT2_LCD; | |
747 else { | |
748 sis_vbflags = sis_vbflags & ~(CRT2_LCD); | |
749 if (sis_verbose > 0) { | |
750 printf | |
751 ("[SiS] Can't force CRT2 to LCD, no panel detected\n"); | |
752 } | |
753 } | |
754 break; | |
755 case CRT2_VGA: | |
756 if (sis_vbflags & VB_LVDS) { | |
757 if (sis_verbose > 0) { | |
758 printf("[SiS] LVDS does not support secondary VGA\n"); | |
759 } | |
760 break; | |
761 } | |
762 if (sis_vbflags & (VB_301LV | VB_302LV)) { | |
763 if (sis_verbose > 0) { | |
764 printf | |
765 ("[SiS] SiS30xLV bridge does not support secondary VGA\n"); | |
766 } | |
767 break; | |
768 } | |
769 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_LCD); | |
770 if (sis_vbflags & VB_VIDEOBRIDGE) | |
771 sis_vbflags = sis_vbflags | CRT2_VGA; | |
772 else | |
773 sis_vbflags = sis_vbflags & ~(CRT2_VGA); | |
774 break; | |
775 default: | |
776 sis_vbflags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA); | |
777 } | |
778 | |
779 /* CRT2 gamma correction?? */ | |
780 | |
781 /* other force modes: */ | |
782 /* have a 'force tv type' (svideo, composite, scart) option? */ | |
783 /* have a 'force crt1 type' (to turn it off, etc??) */ | |
784 | |
785 /* TW: Check if CRT1 used (or needed; this eg. if no CRT2 detected) */ | |
786 if (sis_vbflags & VB_VIDEOBRIDGE) { | |
787 | |
788 /* TW: No CRT2 output? Then we NEED CRT1! | |
789 * We also need CRT1 if depth = 8 and bridge=LVDS|630+301B | |
790 */ | |
791 if ((!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) || ( /*(pScrn->bitsPerPixel == 8) && */ | |
792 ((sis_vbflags & (VB_LVDS | VB_CHRONTEL)) || ((sis_vga_engine == SIS_300_VGA) && (sis_vbflags & VB_301B))))) { | |
793 sis_crt1_off = 0; | |
794 } | |
795 /* TW: No CRT2 output? Then we can't use hw overlay on CRT2 */ | |
796 if (!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) | |
797 sis_overlay_on_crt1 = 1; | |
798 | |
799 } else { /* TW: no video bridge? */ | |
800 | |
801 /* Then we NEED CRT1... */ | |
802 sis_crt1_off = 0; | |
803 /* ... and can't use CRT2 for overlay output */ | |
804 sis_overlay_on_crt1 = 1; | |
805 } | |
806 | |
807 /* tvstandard options ? */ | |
808 | |
809 // determine using CRT1 or CRT2? | |
810 /* -> NO dualhead right now... */ | |
811 if (sis_vbflags & DISPTYPE_DISP2) { | |
812 if (sis_crt1_off) { | |
813 sis_vbflags |= VB_DISPMODE_SINGLE; | |
814 /* TW: No CRT1? Then we use the video overlay on CRT2 */ | |
815 sis_overlay_on_crt1 = 0; | |
816 } else /* TW: CRT1 and CRT2 - mirror or dual head ----- */ | |
817 sis_vbflags |= (VB_DISPMODE_MIRROR | DISPTYPE_CRT1); | |
818 } else { /* TW: CRT1 only ------------------------------- */ | |
819 sis_vbflags |= (VB_DISPMODE_SINGLE | DISPTYPE_CRT1); | |
820 } | |
821 | |
822 if (sis_verbose > 0) { | |
823 printf("[SiS] Using hardware overlay on CRT%d\n", | |
824 sis_overlay_on_crt1 ? 1 : 2); | |
825 } | |
826 | |
827 } |