Mercurial > mplayer.hg
annotate vidix/sis_bridge.c @ 23047:702085652768
Suggest svn diff command that does not show most cosmetics
author | reimar |
---|---|
date | Sun, 22 Apr 2007 15:11:47 +0000 |
parents | 82216ef041e0 |
children | 7973a6935234 |
rev | line source |
---|---|
23046
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
1 /* |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
2 * VIDIX driver for SiS chipsets. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
3 * Video bridge detection for SiS 300 and 310/325 series. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
4 * Copyright (C) 2003 Jake Page, Sugar Media. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
5 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
6 * This file is part of MPlayer. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
7 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
8 * MPlayer is free software; you can redistribute it and/or modify |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
11 * (at your option) any later version. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
12 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
13 * MPlayer is distributed in the hope that it will be useful, |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
16 * GNU General Public License for more details. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
17 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
19 * along with MPlayer; if not, write to the Free Software |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
21 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
22 * Based on SiS Xv driver |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
23 * Copyright 2002-2003 by Thomas Winischhofer, Vienna, Austria. |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
24 */ |
22850 | 25 |
26 #include <stdio.h> | |
27 #include <stdlib.h> | |
28 #include <unistd.h> | |
29 | |
22901 | 30 #include "dha.h" |
22850 | 31 #include "sis_regs.h" |
32 #include "sis_defs.h" | |
33 | |
34 | |
35 static void sis_ddc2_delay(unsigned short delaytime) | |
36 { | |
37 unsigned short i; | |
38 int temp; | |
39 | |
40 for (i = 0; i < delaytime; i++) { | |
41 inSISIDXREG(SISSR, 0x05, temp); | |
42 } | |
43 } | |
44 | |
45 | |
46 static int sis_do_sense(int tempbl, int tempbh, int tempcl, int tempch) | |
47 { | |
48 int temp; | |
49 | |
50 outSISIDXREG(SISPART4, 0x11, tempbl); | |
51 temp = tempbh | tempcl; | |
52 setSISIDXREG(SISPART4, 0x10, 0xe0, temp); | |
53 //usleep(200000); | |
54 sis_ddc2_delay(0x1000); | |
55 tempch &= 0x7f; | |
56 inSISIDXREG(SISPART4, 0x03, temp); | |
57 temp ^= 0x0e; | |
58 temp &= tempch; | |
59 return (temp == tempch); | |
60 } | |
61 | |
62 | |
63 /* sense connected devices on 30x bridge */ | |
64 static void sis_sense_30x(void) | |
65 { | |
66 unsigned char backupP4_0d, backupP2_00, biosflag; | |
67 unsigned char testsvhs_tempbl, testsvhs_tempbh; | |
68 unsigned char testsvhs_tempcl, testsvhs_tempch; | |
69 unsigned char testcvbs_tempbl, testcvbs_tempbh; | |
70 unsigned char testcvbs_tempcl, testcvbs_tempch; | |
71 unsigned char testvga2_tempbl, testvga2_tempbh; | |
72 unsigned char testvga2_tempcl, testvga2_tempch; | |
73 int myflag, result = 0, i, j, haveresult; | |
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(void) | |
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 static void sis_detect_tv(void) | |
397 { | |
398 unsigned char SR16, SR38, CR32, CR38 = 0, CR79; | |
399 int temp = 0; | |
400 | |
401 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
402 return; | |
403 | |
404 inSISIDXREG(SISCR, 0x32, CR32); | |
405 inSISIDXREG(SISSR, 0x16, SR16); | |
406 inSISIDXREG(SISSR, 0x38, SR38); | |
407 switch (sis_vga_engine) { | |
408 case SIS_300_VGA: | |
409 if (sis_device_id == DEVICE_SIS_630_VGA) | |
410 temp = 0x35; | |
411 break; | |
412 case SIS_315_VGA: | |
413 temp = 0x38; | |
414 break; | |
415 } | |
416 if (temp) { | |
417 inSISIDXREG(SISCR, temp, CR38); | |
418 } | |
419 | |
420 if (CR32 & 0x47) | |
421 sis_vbflags |= CRT2_TV; | |
422 | |
423 if (CR32 & 0x04) | |
424 sis_vbflags |= TV_SCART; | |
425 else if (CR32 & 0x02) | |
426 sis_vbflags |= TV_SVIDEO; | |
427 else if (CR32 & 0x01) | |
428 sis_vbflags |= TV_AVIDEO; | |
429 else if (CR32 & 0x40) | |
430 sis_vbflags |= (TV_SVIDEO | TV_HIVISION); | |
431 else if ((CR38 & 0x04) && (sis_vbflags & (VB_301LV | VB_302LV))) | |
432 sis_vbflags |= TV_HIVISION_LV; | |
433 else if ((CR38 & 0x04) && (sis_vbflags & VB_CHRONTEL)) | |
434 sis_vbflags |= (TV_CHSCART | TV_PAL); | |
435 else if ((CR38 & 0x08) && (sis_vbflags & VB_CHRONTEL)) | |
436 sis_vbflags |= (TV_CHHDTV | TV_NTSC); | |
437 | |
438 if (sis_vbflags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION)) { | |
439 if (sis_vga_engine == SIS_300_VGA) { | |
440 /* TW: Should be SR38 here as well, but this | |
441 * does not work. Looks like a BIOS bug (2.04.5c). | |
442 */ | |
443 if (SR16 & 0x20) | |
444 sis_vbflags |= TV_PAL; | |
445 else | |
446 sis_vbflags |= TV_NTSC; | |
447 } else if ((sis_device_id == DEVICE_SIS_550_VGA)) { | |
448 inSISIDXREG(SISCR, 0x79, CR79); | |
449 if (CR79 & 0x08) { | |
450 inSISIDXREG(SISCR, 0x79, CR79); | |
451 CR79 >>= 5; | |
452 } | |
453 if (CR79 & 0x01) { | |
454 sis_vbflags |= TV_PAL; | |
455 if (CR38 & 0x40) | |
456 sis_vbflags |= TV_PALM; | |
457 else if (CR38 & 0x80) | |
458 sis_vbflags |= TV_PALN; | |
459 } else | |
460 sis_vbflags |= TV_NTSC; | |
461 } else if ((sis_device_id == DEVICE_SIS_650_VGA)) { | |
462 inSISIDXREG(SISCR, 0x79, CR79); | |
463 if (CR79 & 0x20) { | |
464 sis_vbflags |= TV_PAL; | |
465 if (CR38 & 0x40) | |
466 sis_vbflags |= TV_PALM; | |
467 else if (CR38 & 0x80) | |
468 sis_vbflags |= TV_PALN; | |
469 } else | |
470 sis_vbflags |= TV_NTSC; | |
471 } else { /* 315, 330 */ | |
472 if (SR38 & 0x01) { | |
473 sis_vbflags |= TV_PAL; | |
474 if (CR38 & 0x40) | |
475 sis_vbflags |= TV_PALM; | |
476 else if (CR38 & 0x80) | |
477 sis_vbflags |= TV_PALN; | |
478 } else | |
479 sis_vbflags |= TV_NTSC; | |
480 } | |
481 } | |
482 | |
483 if (sis_vbflags & | |
484 (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_CHSCART | | |
485 TV_CHHDTV)) { | |
486 if (sis_verbose > 0) { | |
487 printf("[SiS] %sTV standard %s\n", | |
488 (sis_vbflags & (TV_CHSCART | TV_CHHDTV)) ? "Using " : | |
489 "Detected default ", | |
490 (sis_vbflags & TV_NTSC) ? ((sis_vbflags & TV_CHHDTV) ? | |
491 "480i HDTV" : "NTSC") | |
492 : ((sis_vbflags & TV_PALM) ? "PALM" | |
493 : ((sis_vbflags & TV_PALN) ? "PALN" : "PAL"))); | |
494 } | |
495 } | |
496 | |
497 } | |
498 | |
499 | |
500 static void sis_detect_crt2(void) | |
501 { | |
502 unsigned char CR32; | |
503 | |
504 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
505 return; | |
506 | |
507 /* CRT2-VGA not supported on LVDS and 30xLV */ | |
508 if (sis_vbflags & (VB_LVDS | VB_301LV | VB_302LV)) | |
509 return; | |
510 | |
511 inSISIDXREG(SISCR, 0x32, CR32); | |
512 | |
513 if (CR32 & 0x10) | |
514 sis_vbflags |= CRT2_VGA; | |
515 | |
516 #if 0 | |
517 if (!(pSiS->nocrt2ddcdetection)) { | |
518 if (sis_vbflags & (VB_301B | VB_302B)) { | |
519 if (!(sis_vbflags & (CRT2_VGA | CRT2_LCD))) { | |
520 printf | |
521 ("[SiS] BIOS detected no secondary VGA, sensing via DDC\n"); | |
522 if (SiS_SenseVGA2DDC(pSiS->SiS_Pr, pSiS)) { | |
523 printf | |
524 ("[SiS] DDC error during secondary VGA detection\n"); | |
525 } else { | |
526 inSISIDXREG(SISCR, 0x32, CR32); | |
527 if (CR32 & 0x10) { | |
528 sis_vbflags |= CRT2_VGA; | |
529 /*pSiS->postVBCR32 |= 0x10; */ | |
530 printf | |
531 ("[SiS] Detected secondary VGA connection\n"); | |
532 } else { | |
533 printf | |
534 ("[SiS] No secondary VGA connection detected\n"); | |
535 } | |
536 } | |
537 } | |
538 } | |
539 } | |
540 #endif | |
541 | |
542 } | |
543 | |
544 | |
545 /* Preinit: detect video bridge and sense connected devs */ | |
546 static void sis_detect_video_bridge(void) | |
547 { | |
548 int temp, temp1, temp2; | |
549 | |
550 | |
551 sis_vbflags = 0; | |
552 | |
553 if (sis_vga_engine != SIS_300_VGA && sis_vga_engine != SIS_315_VGA) | |
554 return; | |
555 | |
556 inSISIDXREG(SISPART4, 0x00, temp); | |
557 temp &= 0x0F; | |
558 if (temp == 1) { | |
559 inSISIDXREG(SISPART4, 0x01, temp1); | |
560 temp1 &= 0xff; | |
561 if (temp1 >= 0xE0) { | |
562 sis_vbflags |= VB_302LV; | |
563 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
564 if (sis_verbose > 1) { | |
565 printf | |
566 ("[SiS] Detected SiS302LV video bridge (ID 1; Revision 0x%x)\n", | |
567 temp1); | |
568 } | |
569 | |
570 } else if (temp1 >= 0xD0) { | |
571 sis_vbflags |= VB_301LV; | |
572 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
573 if (sis_verbose > 1) { | |
574 printf | |
575 ("[SiS] Detected SiS301LV video bridge (ID 1; Revision 0x%x)\n", | |
576 temp1); | |
577 } | |
578 } else if (temp1 >= 0xB0) { | |
579 sis_vbflags |= VB_301B; | |
580 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301B; | |
581 inSISIDXREG(SISPART4, 0x23, temp2); | |
582 if (!(temp2 & 0x02)) | |
583 sis_vbflags |= VB_30xBDH; | |
584 if (sis_verbose > 1) { | |
585 printf | |
586 ("[SiS] Detected SiS301B%s video bridge (Revision 0x%x)\n", | |
587 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
588 } | |
589 } else { | |
590 sis_vbflags |= VB_301; | |
591 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301; | |
592 if (sis_verbose > 1) { | |
593 printf | |
594 ("[SiS] Detected SiS301 video bridge (Revision 0x%x)\n", | |
595 temp1); | |
596 } | |
597 } | |
598 | |
599 sis_sense_30x(); | |
600 | |
601 } else if (temp == 2) { | |
602 | |
603 inSISIDXREG(SISPART4, 0x01, temp1); | |
604 temp1 &= 0xff; | |
605 if (temp1 >= 0xE0) { | |
606 sis_vbflags |= VB_302LV; | |
607 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
608 if (sis_verbose > 1) { | |
609 printf | |
610 ("[SiS] Detected SiS302LV video bridge (ID 2; Revision 0x%x)\n", | |
611 temp1); | |
612 } | |
613 } else if (temp1 >= 0xD0) { | |
614 sis_vbflags |= VB_301LV; | |
615 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
616 if (sis_verbose > 1) { | |
617 printf | |
618 ("[SiS] Detected SiS301LV video bridge (ID 2; Revision 0x%x)\n", | |
619 temp1); | |
620 } | |
621 } else { | |
622 sis_vbflags |= VB_302B; | |
623 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302B; | |
624 inSISIDXREG(SISPART4, 0x23, temp2); | |
625 if (!(temp & 0x02)) | |
626 sis_vbflags |= VB_30xBDH; | |
627 if (sis_verbose > 1) { | |
628 printf | |
629 ("[SiS] Detected SiS302B%s video bridge (Revision 0x%x)\n", | |
630 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
631 } | |
632 } | |
633 | |
634 sis_sense_30x(); | |
635 | |
636 } else if (temp == 3) { | |
637 if (sis_verbose > 1) { | |
638 printf("[SiS] Detected SiS303 video bridge - not supported\n"); | |
639 } | |
640 } else { | |
641 /* big scary mess of code to handle unknown or Chrontel LVDS */ | |
642 /* skipping it for now */ | |
643 if (sis_verbose > 1) { | |
644 printf | |
645 ("[SiS] Detected Chrontel video bridge - not supported\n"); | |
646 } | |
647 } | |
648 | |
649 /* this is probably not relevant to video overlay driver... */ | |
650 /* detects if brdige uses LCDA for low res text modes */ | |
651 if (sis_vga_engine == SIS_315_VGA) { | |
652 if (sis_vbflags & (VB_302B | VB_301LV | VB_302LV)) { | |
653 #if 0 | |
654 if (pSiS->sisfblcda != 0xff) { | |
655 if ((pSiS->sisfblcda & 0x03) == 0x03) { | |
656 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
657 sis_vbflags |= VB_USELCDA; | |
658 } | |
659 } else | |
660 #endif | |
661 { | |
662 inSISIDXREG(SISCR, 0x34, temp); | |
663 if (temp <= 0x13) { | |
664 inSISIDXREG(SISCR, 0x38, temp); | |
665 if ((temp & 0x03) == 0x03) { | |
666 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
667 sis_vbflags |= VB_USELCDA; | |
668 } else { | |
669 inSISIDXREG(SISCR, 0x30, temp); | |
670 if (temp & 0x20) { | |
671 inSISIDXREG(SISPART1, 0x13, temp); | |
672 if (temp & 0x40) { | |
673 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
674 sis_vbflags |= VB_USELCDA; | |
675 } | |
676 } | |
677 } | |
678 } | |
679 } | |
680 if (sis_vbflags & VB_USELCDA) { | |
681 /* printf("Bridge uses LCDA for low resolution and text modes\n"); */ | |
682 } | |
683 } | |
684 } | |
685 | |
686 | |
687 } | |
688 | |
689 | |
690 /* detect video bridge type and sense connected devices */ | |
691 void sis_init_video_bridge(void) | |
692 { | |
693 | |
694 sis_detect_video_bridge(); | |
695 | |
696 sis_detect_crt1(); | |
697 //sis_detect_lcd(); | |
698 sis_detect_tv(); | |
699 sis_detect_crt2(); | |
700 | |
701 sis_detected_crt2_devices = | |
702 sis_vbflags & (CRT2_LCD | CRT2_TV | CRT2_VGA); | |
703 | |
704 // force crt2 type | |
705 if (sis_force_crt2_type == CRT2_DEFAULT) { | |
706 if (sis_vbflags & CRT2_VGA) | |
707 sis_force_crt2_type = CRT2_VGA; | |
708 else if (sis_vbflags & CRT2_LCD) | |
709 sis_force_crt2_type = CRT2_LCD; | |
710 else if (sis_vbflags & CRT2_TV) | |
711 sis_force_crt2_type = CRT2_TV; | |
712 } | |
713 | |
714 switch (sis_force_crt2_type) { | |
715 case CRT2_TV: | |
716 sis_vbflags = sis_vbflags & ~(CRT2_LCD | CRT2_VGA); | |
717 if (sis_vbflags & VB_VIDEOBRIDGE) | |
718 sis_vbflags = sis_vbflags | CRT2_TV; | |
719 else | |
720 sis_vbflags = sis_vbflags & ~(CRT2_TV); | |
721 break; | |
722 case CRT2_LCD: | |
723 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_VGA); | |
724 if ((sis_vbflags & VB_VIDEOBRIDGE) /* XXX: && (pSiS->VBLCDFlags) */ | |
725 ) | |
726 sis_vbflags = sis_vbflags | CRT2_LCD; | |
727 else { | |
728 sis_vbflags = sis_vbflags & ~(CRT2_LCD); | |
729 if (sis_verbose > 0) { | |
730 printf | |
731 ("[SiS] Can't force CRT2 to LCD, no panel detected\n"); | |
732 } | |
733 } | |
734 break; | |
735 case CRT2_VGA: | |
736 if (sis_vbflags & VB_LVDS) { | |
737 if (sis_verbose > 0) { | |
738 printf("[SiS] LVDS does not support secondary VGA\n"); | |
739 } | |
740 break; | |
741 } | |
742 if (sis_vbflags & (VB_301LV | VB_302LV)) { | |
743 if (sis_verbose > 0) { | |
744 printf | |
745 ("[SiS] SiS30xLV bridge does not support secondary VGA\n"); | |
746 } | |
747 break; | |
748 } | |
749 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_LCD); | |
750 if (sis_vbflags & VB_VIDEOBRIDGE) | |
751 sis_vbflags = sis_vbflags | CRT2_VGA; | |
752 else | |
753 sis_vbflags = sis_vbflags & ~(CRT2_VGA); | |
754 break; | |
755 default: | |
756 sis_vbflags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA); | |
757 } | |
758 | |
759 /* CRT2 gamma correction?? */ | |
760 | |
761 /* other force modes: */ | |
762 /* have a 'force tv type' (svideo, composite, scart) option? */ | |
763 /* have a 'force crt1 type' (to turn it off, etc??) */ | |
764 | |
765 /* TW: Check if CRT1 used (or needed; this eg. if no CRT2 detected) */ | |
766 if (sis_vbflags & VB_VIDEOBRIDGE) { | |
767 | |
768 /* TW: No CRT2 output? Then we NEED CRT1! | |
769 * We also need CRT1 if depth = 8 and bridge=LVDS|630+301B | |
770 */ | |
771 if ((!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) || ( /*(pScrn->bitsPerPixel == 8) && */ | |
772 ((sis_vbflags & (VB_LVDS | VB_CHRONTEL)) || ((sis_vga_engine == SIS_300_VGA) && (sis_vbflags & VB_301B))))) { | |
773 sis_crt1_off = 0; | |
774 } | |
775 /* TW: No CRT2 output? Then we can't use hw overlay on CRT2 */ | |
776 if (!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) | |
777 sis_overlay_on_crt1 = 1; | |
778 | |
779 } else { /* TW: no video bridge? */ | |
780 | |
781 /* Then we NEED CRT1... */ | |
782 sis_crt1_off = 0; | |
783 /* ... and can't use CRT2 for overlay output */ | |
784 sis_overlay_on_crt1 = 1; | |
785 } | |
786 | |
787 /* tvstandard options ? */ | |
788 | |
789 // determine using CRT1 or CRT2? | |
790 /* -> NO dualhead right now... */ | |
791 if (sis_vbflags & DISPTYPE_DISP2) { | |
792 if (sis_crt1_off) { | |
793 sis_vbflags |= VB_DISPMODE_SINGLE; | |
794 /* TW: No CRT1? Then we use the video overlay on CRT2 */ | |
795 sis_overlay_on_crt1 = 0; | |
796 } else /* TW: CRT1 and CRT2 - mirror or dual head ----- */ | |
797 sis_vbflags |= (VB_DISPMODE_MIRROR | DISPTYPE_CRT1); | |
798 } else { /* TW: CRT1 only ------------------------------- */ | |
799 sis_vbflags |= (VB_DISPMODE_SINGLE | DISPTYPE_CRT1); | |
800 } | |
801 | |
802 if (sis_verbose > 0) { | |
803 printf("[SiS] Using hardware overlay on CRT%d\n", | |
804 sis_overlay_on_crt1 ? 1 : 2); | |
805 } | |
806 | |
807 } |