Mercurial > mplayer.hg
annotate vidix/sis_bridge.c @ 25588:0f344d22ee48
Fix compilation due to conflicting type declaration:
qtx/list.c:22: error: conflicting types for 'OSErr'
qtx/qtxsdk/components.h:15: error: previous declaration of 'OSErr' was here
author | diego |
---|---|
date | Sun, 06 Jan 2008 11:45:47 +0000 |
parents | 7973a6935234 |
children | 051b2632f121 |
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_300_VGA) { | |
84 testvga2_tempbh = 0x00; | |
85 testvga2_tempbl = 0xd1; | |
86 testsvhs_tempbh = 0x00; | |
87 testsvhs_tempbl = 0xb9; | |
88 testcvbs_tempbh = 0x00; | |
89 testcvbs_tempbl = 0xb3; | |
90 biosflag = 0; | |
23048 | 91 |
22850 | 92 if (sis_vbflags & (VB_301B | VB_302B | VB_301LV | VB_302LV)) { |
93 testvga2_tempbh = 0x01; | |
94 testvga2_tempbl = 0x90; | |
95 testsvhs_tempbh = 0x01; | |
96 testsvhs_tempbl = 0x6b; | |
97 testcvbs_tempbh = 0x01; | |
98 testcvbs_tempbl = 0x74; | |
99 } | |
100 inSISIDXREG(SISPART4, 0x01, myflag); | |
101 if (myflag & 0x04) { | |
102 testvga2_tempbh = 0x00; | |
103 testvga2_tempbl = 0xfd; | |
104 testsvhs_tempbh = 0x00; | |
105 testsvhs_tempbl = 0xdd; | |
106 testcvbs_tempbh = 0x00; | |
107 testcvbs_tempbl = 0xee; | |
108 } | |
109 testvga2_tempch = 0x0e; | |
110 testvga2_tempcl = 0x08; | |
111 testsvhs_tempch = 0x06; | |
112 testsvhs_tempcl = 0x04; | |
113 testcvbs_tempch = 0x08; | |
114 testcvbs_tempcl = 0x04; | |
115 | |
116 if (sis_device_id == DEVICE_SIS_300) { | |
117 inSISIDXREG(SISSR, 0x3b, myflag); | |
118 if (!(myflag & 0x01)) { | |
119 testvga2_tempbh = 0x00; | |
120 testvga2_tempbl = 0x00; | |
121 testvga2_tempch = 0x00; | |
122 testvga2_tempcl = 0x00; | |
123 } | |
124 } | |
125 } else { | |
126 testvga2_tempbh = 0x00; | |
127 testvga2_tempbl = 0xd1; | |
128 testsvhs_tempbh = 0x00; | |
129 testsvhs_tempbl = 0xb9; | |
130 testcvbs_tempbh = 0x00; | |
131 testcvbs_tempbl = 0xb3; | |
132 biosflag = 0; | |
133 | |
134 if (sis_vbflags & (VB_301B | VB_302B | VB_301LV | VB_302LV)) { | |
135 if (sis_vbflags & (VB_301B | VB_302B)) { | |
136 testvga2_tempbh = 0x01; | |
137 testvga2_tempbl = 0x90; | |
138 testsvhs_tempbh = 0x01; | |
139 testsvhs_tempbl = 0x6b; | |
140 testcvbs_tempbh = 0x01; | |
141 testcvbs_tempbl = 0x74; | |
142 } else { | |
143 testvga2_tempbh = 0x00; | |
144 testvga2_tempbl = 0x00; | |
145 testsvhs_tempbh = 0x02; | |
146 testsvhs_tempbl = 0x00; | |
147 testcvbs_tempbh = 0x01; | |
148 testcvbs_tempbl = 0x00; | |
149 } | |
150 } | |
151 if (sis_vbflags & (VB_301 | VB_301B | VB_302B)) { | |
152 inSISIDXREG(SISPART4, 0x01, myflag); | |
153 if (myflag & 0x04) { | |
154 testvga2_tempbh = 0x00; | |
155 testvga2_tempbl = 0xfd; | |
156 testsvhs_tempbh = 0x00; | |
157 testsvhs_tempbl = 0xdd; | |
158 testcvbs_tempbh = 0x00; | |
159 testcvbs_tempbl = 0xee; | |
160 } | |
161 } | |
162 if (sis_vbflags & (VB_301LV | VB_302LV)) { | |
163 /* TW: No VGA2 or SCART on LV bridges */ | |
164 testvga2_tempbh = 0x00; | |
165 testvga2_tempbl = 0x00; | |
166 testvga2_tempch = 0x00; | |
167 testvga2_tempcl = 0x00; | |
168 testsvhs_tempch = 0x04; | |
169 testsvhs_tempcl = 0x08; | |
170 testcvbs_tempch = 0x08; | |
171 testcvbs_tempcl = 0x08; | |
172 } else { | |
173 testvga2_tempch = 0x0e; | |
174 testvga2_tempcl = 0x08; | |
175 testsvhs_tempch = 0x06; | |
176 testsvhs_tempcl = 0x04; | |
177 testcvbs_tempch = 0x08; | |
178 testcvbs_tempcl = 0x04; | |
179 } | |
180 } | |
181 | |
182 /* XXX: ?? andSISIDXREG(SISCR, 0x32, ~0x14); */ | |
183 /* pSiS->postVBCR32 &= ~0x14; */ | |
184 | |
185 /* scan for VGA2/SCART */ | |
186 if (testvga2_tempch || testvga2_tempcl || | |
187 testvga2_tempbh || testvga2_tempbl) { | |
188 | |
189 haveresult = 0; | |
190 for (j = 0; j < 10; j++) { | |
191 result = 0; | |
192 for (i = 0; i < 3; i++) { | |
193 if (sis_do_sense(testvga2_tempbl, testvga2_tempbh, | |
194 testvga2_tempcl, testvga2_tempch)) | |
195 result++; | |
196 } | |
197 if ((result == 0) || (result >= 2)) | |
198 break; | |
199 } | |
200 if (result) { | |
201 if (biosflag & 0x01) { | |
202 if (sis_verbose > 1) { | |
203 printf | |
204 ("[SiS] SiS30x: Detected TV connected to SCART output\n"); | |
205 } | |
206 sis_vbflags |= TV_SCART; | |
207 orSISIDXREG(SISCR, 0x32, 0x04); | |
208 /*pSiS->postVBCR32 |= 0x04; */ | |
209 } else { | |
210 if (sis_verbose > 1) { | |
211 printf | |
212 ("[SiS] SiS30x: Detected secondary VGA connection\n"); | |
213 } | |
214 sis_vbflags |= VGA2_CONNECTED; | |
215 orSISIDXREG(SISCR, 0x32, 0x10); | |
216 /*pSiS->postVBCR32 |= 0x10; */ | |
217 } | |
218 } | |
219 } | |
220 | |
221 /* scanning for TV */ | |
222 | |
223 /* XXX: ?? andSISIDXREG(SISCR, 0x32, ~0x03); */ | |
224 /* pSiS->postVBCR32 &= ~0x03; */ | |
225 | |
226 result = sis_do_sense(testsvhs_tempbl, testsvhs_tempbh, | |
227 testsvhs_tempcl, testsvhs_tempch); | |
228 | |
229 | |
230 haveresult = 0; | |
231 for (j = 0; j < 10; j++) { | |
232 result = 0; | |
233 for (i = 0; i < 3; i++) { | |
234 if (sis_do_sense(testsvhs_tempbl, testsvhs_tempbh, | |
235 testsvhs_tempcl, testsvhs_tempch)) | |
236 result++; | |
237 } | |
238 if ((result == 0) || (result >= 2)) | |
239 break; | |
240 } | |
241 if (result) { | |
242 if (sis_verbose > 1) { | |
243 printf | |
244 ("[SiS] SiS30x: Detected TV connected to SVIDEO output\n"); | |
245 } | |
246 /* TW: So we can be sure that there IS a SVIDEO output */ | |
247 sis_vbflags |= TV_SVIDEO; | |
248 orSISIDXREG(SISCR, 0x32, 0x02); | |
249 //pSiS->postVBCR32 |= 0x02; | |
250 } | |
251 | |
252 if ((biosflag & 0x02) || (!(result))) { | |
253 haveresult = 0; | |
254 for (j = 0; j < 10; j++) { | |
255 result = 0; | |
256 for (i = 0; i < 3; i++) { | |
257 if (sis_do_sense(testcvbs_tempbl, testcvbs_tempbh, | |
258 testcvbs_tempcl, testcvbs_tempch)) | |
259 result++; | |
260 } | |
261 if ((result == 0) || (result >= 2)) | |
262 break; | |
263 } | |
264 if (result) { | |
265 if (sis_verbose > 1) { | |
266 printf | |
267 ("[SiS] SiS30x: Detected TV connected to COMPOSITE output\n"); | |
268 } | |
269 sis_vbflags |= TV_AVIDEO; | |
270 orSISIDXREG(SISCR, 0x32, 0x01); | |
271 //pSiS->postVBCR32 |= 0x01; | |
272 } | |
273 } | |
274 | |
275 sis_do_sense(0, 0, 0, 0); | |
276 | |
277 outSISIDXREG(SISPART2, 0x00, backupP2_00); | |
278 outSISIDXREG(SISPART4, 0x0d, backupP4_0d); | |
279 } | |
280 | |
281 | |
282 static void sis_detect_crt1(void) | |
283 { | |
284 unsigned char CR32; | |
285 unsigned char CRT1Detected = 0; | |
286 unsigned char OtherDevices = 0; | |
287 | |
288 if (!(sis_vbflags & VB_VIDEOBRIDGE)) { | |
289 sis_crt1_off = 0; | |
290 return; | |
291 } | |
292 | |
293 inSISIDXREG(SISCR, 0x32, CR32); | |
294 | |
295 if (CR32 & 0x20) | |
296 CRT1Detected = 1; | |
297 if (CR32 & 0x5F) | |
298 OtherDevices = 1; | |
299 | |
300 if (sis_crt1_off == -1) { | |
301 if (!CRT1Detected) { | |
302 /* BIOS detected no CRT1. */ | |
303 /* If other devices exist, switch it off */ | |
304 if (OtherDevices) | |
305 sis_crt1_off = 1; | |
306 else | |
307 sis_crt1_off = 0; | |
308 } else { | |
309 /* BIOS detected CRT1, leave/switch it on */ | |
310 sis_crt1_off = 0; | |
311 } | |
312 } | |
313 if (sis_verbose > 0) { | |
314 printf("[SiS] %sCRT1 connection detected\n", | |
315 sis_crt1_off ? "No " : ""); | |
316 } | |
317 } | |
318 | |
319 static void sis_detect_tv(void) | |
320 { | |
321 unsigned char SR16, SR38, CR32, CR38 = 0, CR79; | |
322 int temp = 0; | |
323 | |
324 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
325 return; | |
326 | |
327 inSISIDXREG(SISCR, 0x32, CR32); | |
328 inSISIDXREG(SISSR, 0x16, SR16); | |
329 inSISIDXREG(SISSR, 0x38, SR38); | |
330 switch (sis_vga_engine) { | |
331 case SIS_300_VGA: | |
332 if (sis_device_id == DEVICE_SIS_630_VGA) | |
333 temp = 0x35; | |
334 break; | |
335 case SIS_315_VGA: | |
336 temp = 0x38; | |
337 break; | |
338 } | |
339 if (temp) { | |
340 inSISIDXREG(SISCR, temp, CR38); | |
341 } | |
342 | |
343 if (CR32 & 0x47) | |
344 sis_vbflags |= CRT2_TV; | |
345 | |
346 if (CR32 & 0x04) | |
347 sis_vbflags |= TV_SCART; | |
348 else if (CR32 & 0x02) | |
349 sis_vbflags |= TV_SVIDEO; | |
350 else if (CR32 & 0x01) | |
351 sis_vbflags |= TV_AVIDEO; | |
352 else if (CR32 & 0x40) | |
353 sis_vbflags |= (TV_SVIDEO | TV_HIVISION); | |
354 else if ((CR38 & 0x04) && (sis_vbflags & (VB_301LV | VB_302LV))) | |
355 sis_vbflags |= TV_HIVISION_LV; | |
356 else if ((CR38 & 0x04) && (sis_vbflags & VB_CHRONTEL)) | |
357 sis_vbflags |= (TV_CHSCART | TV_PAL); | |
358 else if ((CR38 & 0x08) && (sis_vbflags & VB_CHRONTEL)) | |
359 sis_vbflags |= (TV_CHHDTV | TV_NTSC); | |
360 | |
361 if (sis_vbflags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION)) { | |
362 if (sis_vga_engine == SIS_300_VGA) { | |
363 /* TW: Should be SR38 here as well, but this | |
364 * does not work. Looks like a BIOS bug (2.04.5c). | |
365 */ | |
366 if (SR16 & 0x20) | |
367 sis_vbflags |= TV_PAL; | |
368 else | |
369 sis_vbflags |= TV_NTSC; | |
370 } else if ((sis_device_id == DEVICE_SIS_550_VGA)) { | |
371 inSISIDXREG(SISCR, 0x79, CR79); | |
372 if (CR79 & 0x08) { | |
373 inSISIDXREG(SISCR, 0x79, CR79); | |
374 CR79 >>= 5; | |
375 } | |
376 if (CR79 & 0x01) { | |
377 sis_vbflags |= TV_PAL; | |
378 if (CR38 & 0x40) | |
379 sis_vbflags |= TV_PALM; | |
380 else if (CR38 & 0x80) | |
381 sis_vbflags |= TV_PALN; | |
382 } else | |
383 sis_vbflags |= TV_NTSC; | |
384 } else if ((sis_device_id == DEVICE_SIS_650_VGA)) { | |
385 inSISIDXREG(SISCR, 0x79, CR79); | |
386 if (CR79 & 0x20) { | |
387 sis_vbflags |= TV_PAL; | |
388 if (CR38 & 0x40) | |
389 sis_vbflags |= TV_PALM; | |
390 else if (CR38 & 0x80) | |
391 sis_vbflags |= TV_PALN; | |
392 } else | |
393 sis_vbflags |= TV_NTSC; | |
394 } else { /* 315, 330 */ | |
395 if (SR38 & 0x01) { | |
396 sis_vbflags |= TV_PAL; | |
397 if (CR38 & 0x40) | |
398 sis_vbflags |= TV_PALM; | |
399 else if (CR38 & 0x80) | |
400 sis_vbflags |= TV_PALN; | |
401 } else | |
402 sis_vbflags |= TV_NTSC; | |
403 } | |
404 } | |
405 | |
406 if (sis_vbflags & | |
407 (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_CHSCART | | |
408 TV_CHHDTV)) { | |
409 if (sis_verbose > 0) { | |
410 printf("[SiS] %sTV standard %s\n", | |
411 (sis_vbflags & (TV_CHSCART | TV_CHHDTV)) ? "Using " : | |
412 "Detected default ", | |
413 (sis_vbflags & TV_NTSC) ? ((sis_vbflags & TV_CHHDTV) ? | |
414 "480i HDTV" : "NTSC") | |
415 : ((sis_vbflags & TV_PALM) ? "PALM" | |
416 : ((sis_vbflags & TV_PALN) ? "PALN" : "PAL"))); | |
417 } | |
418 } | |
419 | |
420 } | |
421 | |
422 | |
423 static void sis_detect_crt2(void) | |
424 { | |
425 unsigned char CR32; | |
426 | |
427 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
428 return; | |
429 | |
430 /* CRT2-VGA not supported on LVDS and 30xLV */ | |
431 if (sis_vbflags & (VB_LVDS | VB_301LV | VB_302LV)) | |
432 return; | |
433 | |
434 inSISIDXREG(SISCR, 0x32, CR32); | |
435 | |
436 if (CR32 & 0x10) | |
437 sis_vbflags |= CRT2_VGA; | |
438 } | |
439 | |
440 | |
441 /* Preinit: detect video bridge and sense connected devs */ | |
442 static void sis_detect_video_bridge(void) | |
443 { | |
444 int temp, temp1, temp2; | |
445 | |
446 | |
447 sis_vbflags = 0; | |
448 | |
449 if (sis_vga_engine != SIS_300_VGA && sis_vga_engine != SIS_315_VGA) | |
450 return; | |
451 | |
452 inSISIDXREG(SISPART4, 0x00, temp); | |
453 temp &= 0x0F; | |
454 if (temp == 1) { | |
455 inSISIDXREG(SISPART4, 0x01, temp1); | |
456 temp1 &= 0xff; | |
457 if (temp1 >= 0xE0) { | |
458 sis_vbflags |= VB_302LV; | |
459 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
460 if (sis_verbose > 1) { | |
461 printf | |
462 ("[SiS] Detected SiS302LV video bridge (ID 1; Revision 0x%x)\n", | |
463 temp1); | |
464 } | |
465 | |
466 } else if (temp1 >= 0xD0) { | |
467 sis_vbflags |= VB_301LV; | |
468 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
469 if (sis_verbose > 1) { | |
470 printf | |
471 ("[SiS] Detected SiS301LV video bridge (ID 1; Revision 0x%x)\n", | |
472 temp1); | |
473 } | |
474 } else if (temp1 >= 0xB0) { | |
475 sis_vbflags |= VB_301B; | |
476 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301B; | |
477 inSISIDXREG(SISPART4, 0x23, temp2); | |
478 if (!(temp2 & 0x02)) | |
479 sis_vbflags |= VB_30xBDH; | |
480 if (sis_verbose > 1) { | |
481 printf | |
482 ("[SiS] Detected SiS301B%s video bridge (Revision 0x%x)\n", | |
483 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
484 } | |
485 } else { | |
486 sis_vbflags |= VB_301; | |
487 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301; | |
488 if (sis_verbose > 1) { | |
489 printf | |
490 ("[SiS] Detected SiS301 video bridge (Revision 0x%x)\n", | |
491 temp1); | |
492 } | |
493 } | |
494 | |
495 sis_sense_30x(); | |
496 | |
497 } else if (temp == 2) { | |
498 | |
499 inSISIDXREG(SISPART4, 0x01, temp1); | |
500 temp1 &= 0xff; | |
501 if (temp1 >= 0xE0) { | |
502 sis_vbflags |= VB_302LV; | |
503 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
504 if (sis_verbose > 1) { | |
505 printf | |
506 ("[SiS] Detected SiS302LV video bridge (ID 2; Revision 0x%x)\n", | |
507 temp1); | |
508 } | |
509 } else if (temp1 >= 0xD0) { | |
510 sis_vbflags |= VB_301LV; | |
511 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
512 if (sis_verbose > 1) { | |
513 printf | |
514 ("[SiS] Detected SiS301LV video bridge (ID 2; Revision 0x%x)\n", | |
515 temp1); | |
516 } | |
517 } else { | |
518 sis_vbflags |= VB_302B; | |
519 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302B; | |
520 inSISIDXREG(SISPART4, 0x23, temp2); | |
521 if (!(temp & 0x02)) | |
522 sis_vbflags |= VB_30xBDH; | |
523 if (sis_verbose > 1) { | |
524 printf | |
525 ("[SiS] Detected SiS302B%s video bridge (Revision 0x%x)\n", | |
526 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
527 } | |
528 } | |
529 | |
530 sis_sense_30x(); | |
531 | |
532 } else if (temp == 3) { | |
533 if (sis_verbose > 1) { | |
534 printf("[SiS] Detected SiS303 video bridge - not supported\n"); | |
535 } | |
536 } else { | |
537 /* big scary mess of code to handle unknown or Chrontel LVDS */ | |
538 /* skipping it for now */ | |
539 if (sis_verbose > 1) { | |
540 printf | |
541 ("[SiS] Detected Chrontel video bridge - not supported\n"); | |
542 } | |
543 } | |
544 | |
545 /* this is probably not relevant to video overlay driver... */ | |
546 /* detects if brdige uses LCDA for low res text modes */ | |
547 if (sis_vga_engine == SIS_315_VGA) { | |
548 if (sis_vbflags & (VB_302B | VB_301LV | VB_302LV)) { | |
549 inSISIDXREG(SISCR, 0x34, temp); | |
550 if (temp <= 0x13) { | |
551 inSISIDXREG(SISCR, 0x38, temp); | |
552 if ((temp & 0x03) == 0x03) { | |
553 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
554 sis_vbflags |= VB_USELCDA; | |
555 } else { | |
556 inSISIDXREG(SISCR, 0x30, temp); | |
557 if (temp & 0x20) { | |
558 inSISIDXREG(SISPART1, 0x13, temp); | |
559 if (temp & 0x40) { | |
560 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
561 sis_vbflags |= VB_USELCDA; | |
562 } | |
563 } | |
564 } | |
565 } | |
566 if (sis_vbflags & VB_USELCDA) { | |
567 /* printf("Bridge uses LCDA for low resolution and text modes\n"); */ | |
568 } | |
569 } | |
570 } | |
571 | |
572 | |
573 } | |
574 | |
575 | |
576 /* detect video bridge type and sense connected devices */ | |
577 void sis_init_video_bridge(void) | |
578 { | |
579 | |
580 sis_detect_video_bridge(); | |
581 | |
582 sis_detect_crt1(); | |
583 //sis_detect_lcd(); | |
584 sis_detect_tv(); | |
585 sis_detect_crt2(); | |
586 | |
587 sis_detected_crt2_devices = | |
588 sis_vbflags & (CRT2_LCD | CRT2_TV | CRT2_VGA); | |
589 | |
590 // force crt2 type | |
591 if (sis_force_crt2_type == CRT2_DEFAULT) { | |
592 if (sis_vbflags & CRT2_VGA) | |
593 sis_force_crt2_type = CRT2_VGA; | |
594 else if (sis_vbflags & CRT2_LCD) | |
595 sis_force_crt2_type = CRT2_LCD; | |
596 else if (sis_vbflags & CRT2_TV) | |
597 sis_force_crt2_type = CRT2_TV; | |
598 } | |
599 | |
600 switch (sis_force_crt2_type) { | |
601 case CRT2_TV: | |
602 sis_vbflags = sis_vbflags & ~(CRT2_LCD | CRT2_VGA); | |
603 if (sis_vbflags & VB_VIDEOBRIDGE) | |
604 sis_vbflags = sis_vbflags | CRT2_TV; | |
605 else | |
606 sis_vbflags = sis_vbflags & ~(CRT2_TV); | |
607 break; | |
608 case CRT2_LCD: | |
609 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_VGA); | |
610 if ((sis_vbflags & VB_VIDEOBRIDGE) /* XXX: && (pSiS->VBLCDFlags) */ | |
611 ) | |
612 sis_vbflags = sis_vbflags | CRT2_LCD; | |
613 else { | |
614 sis_vbflags = sis_vbflags & ~(CRT2_LCD); | |
615 if (sis_verbose > 0) { | |
616 printf | |
617 ("[SiS] Can't force CRT2 to LCD, no panel detected\n"); | |
618 } | |
619 } | |
620 break; | |
621 case CRT2_VGA: | |
622 if (sis_vbflags & VB_LVDS) { | |
623 if (sis_verbose > 0) { | |
624 printf("[SiS] LVDS does not support secondary VGA\n"); | |
625 } | |
626 break; | |
627 } | |
628 if (sis_vbflags & (VB_301LV | VB_302LV)) { | |
629 if (sis_verbose > 0) { | |
630 printf | |
631 ("[SiS] SiS30xLV bridge does not support secondary VGA\n"); | |
632 } | |
633 break; | |
634 } | |
635 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_LCD); | |
636 if (sis_vbflags & VB_VIDEOBRIDGE) | |
637 sis_vbflags = sis_vbflags | CRT2_VGA; | |
638 else | |
639 sis_vbflags = sis_vbflags & ~(CRT2_VGA); | |
640 break; | |
641 default: | |
642 sis_vbflags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA); | |
643 } | |
644 | |
645 /* CRT2 gamma correction?? */ | |
646 | |
647 /* other force modes: */ | |
648 /* have a 'force tv type' (svideo, composite, scart) option? */ | |
649 /* have a 'force crt1 type' (to turn it off, etc??) */ | |
650 | |
651 /* TW: Check if CRT1 used (or needed; this eg. if no CRT2 detected) */ | |
652 if (sis_vbflags & VB_VIDEOBRIDGE) { | |
653 | |
654 /* TW: No CRT2 output? Then we NEED CRT1! | |
655 * We also need CRT1 if depth = 8 and bridge=LVDS|630+301B | |
656 */ | |
657 if ((!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) || ( /*(pScrn->bitsPerPixel == 8) && */ | |
658 ((sis_vbflags & (VB_LVDS | VB_CHRONTEL)) || ((sis_vga_engine == SIS_300_VGA) && (sis_vbflags & VB_301B))))) { | |
659 sis_crt1_off = 0; | |
660 } | |
661 /* TW: No CRT2 output? Then we can't use hw overlay on CRT2 */ | |
662 if (!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) | |
663 sis_overlay_on_crt1 = 1; | |
664 | |
665 } else { /* TW: no video bridge? */ | |
666 | |
667 /* Then we NEED CRT1... */ | |
668 sis_crt1_off = 0; | |
669 /* ... and can't use CRT2 for overlay output */ | |
670 sis_overlay_on_crt1 = 1; | |
671 } | |
672 | |
673 /* tvstandard options ? */ | |
674 | |
675 // determine using CRT1 or CRT2? | |
676 /* -> NO dualhead right now... */ | |
677 if (sis_vbflags & DISPTYPE_DISP2) { | |
678 if (sis_crt1_off) { | |
679 sis_vbflags |= VB_DISPMODE_SINGLE; | |
680 /* TW: No CRT1? Then we use the video overlay on CRT2 */ | |
681 sis_overlay_on_crt1 = 0; | |
682 } else /* TW: CRT1 and CRT2 - mirror or dual head ----- */ | |
683 sis_vbflags |= (VB_DISPMODE_MIRROR | DISPTYPE_CRT1); | |
684 } else { /* TW: CRT1 only ------------------------------- */ | |
685 sis_vbflags |= (VB_DISPMODE_SINGLE | DISPTYPE_CRT1); | |
686 } | |
687 | |
688 if (sis_verbose > 0) { | |
689 printf("[SiS] Using hardware overlay on CRT%d\n", | |
690 sis_overlay_on_crt1 ? 1 : 2); | |
691 } | |
692 | |
693 } |