Mercurial > mplayer.hg
annotate vidix/sis_bridge.c @ 32893:c873777e957d
Get rid of needless listItems variable and pointer.
The tmpList structure variable was only used to check whether a skin can be
read without error. After the check tmpList was erased and the same skin read
once again into another structure - the appropriate target structure. Now
error checking is done with skin reading into the target structure.
The separate skinAppMPlayer pointer was needless, because a skin will only be
read into the one global listItems structure appMPlayer, so that its address
can be used right away.
Freeing the listItems was done twice before and is now performed at a single
place, where the fonts are freed now as well - in skinRead() right before
skin reading starts.
As a result there is now only one listItems variable - the global appMPlayer;
memory is saved, passing around global variables and pointless double actions
are avoided.
author | ib |
---|---|
date | Sun, 27 Feb 2011 17:41:05 +0000 |
parents | 36818ea5ce95 |
children | 3c5c93a30fb7 |
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. |
26718
051b2632f121
consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents:
23048
diff
changeset
|
4 * |
28307
2391228b7ff0
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
26753
diff
changeset
|
5 * Copyright (C) 2003 Jake Page, Sugar Media |
26718
051b2632f121
consistency cosmetics: Move some parts of file headers around; typo fixes.
diego
parents:
23048
diff
changeset
|
6 * Based on SiS Xv driver |
28307
2391228b7ff0
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
26753
diff
changeset
|
7 * Copyright 2002-2003 by Thomas Winischhofer, Vienna, Austria |
23046
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
8 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
9 * 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
|
10 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * (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
|
15 * |
82216ef041e0
updated vidix files headers whenever it's possible to have a clear GPL statement
ben
parents:
22901
diff
changeset
|
16 * 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
|
17 * 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
|
18 * 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
|
19 * 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
|
20 * |
26719 | 21 * You should have received a copy of the GNU General Public License along |
22 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
23046
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" |
30551
36818ea5ce95
Add header file for sis_init_video_bridge() instead of forward declaring it.
diego
parents:
28307
diff
changeset
|
31 #include "sis_bridge.h" |
22850 | 32 #include "sis_regs.h" |
33 #include "sis_defs.h" | |
34 | |
35 | |
36 static void sis_ddc2_delay(unsigned short delaytime) | |
37 { | |
38 unsigned short i; | |
39 int temp; | |
40 | |
41 for (i = 0; i < delaytime; i++) { | |
42 inSISIDXREG(SISSR, 0x05, temp); | |
43 } | |
44 } | |
45 | |
46 | |
47 static int sis_do_sense(int tempbl, int tempbh, int tempcl, int tempch) | |
48 { | |
49 int temp; | |
50 | |
51 outSISIDXREG(SISPART4, 0x11, tempbl); | |
52 temp = tempbh | tempcl; | |
53 setSISIDXREG(SISPART4, 0x10, 0xe0, temp); | |
54 //usleep(200000); | |
55 sis_ddc2_delay(0x1000); | |
56 tempch &= 0x7f; | |
57 inSISIDXREG(SISPART4, 0x03, temp); | |
58 temp ^= 0x0e; | |
59 temp &= tempch; | |
26753
502f04b67653
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26719
diff
changeset
|
60 return temp == tempch; |
22850 | 61 } |
62 | |
63 | |
64 /* sense connected devices on 30x bridge */ | |
65 static void sis_sense_30x(void) | |
66 { | |
67 unsigned char backupP4_0d, backupP2_00, biosflag; | |
68 unsigned char testsvhs_tempbl, testsvhs_tempbh; | |
69 unsigned char testsvhs_tempcl, testsvhs_tempch; | |
70 unsigned char testcvbs_tempbl, testcvbs_tempbh; | |
71 unsigned char testcvbs_tempcl, testcvbs_tempch; | |
72 unsigned char testvga2_tempbl, testvga2_tempbh; | |
73 unsigned char testvga2_tempcl, testvga2_tempch; | |
74 int myflag, result = 0, i, j, haveresult; | |
75 | |
76 inSISIDXREG(SISPART4, 0x0d, backupP4_0d); | |
77 outSISIDXREG(SISPART4, 0x0d, (backupP4_0d | 0x04)); | |
78 | |
79 inSISIDXREG(SISPART2, 0x00, backupP2_00); | |
80 outSISIDXREG(SISPART2, 0x00, (backupP2_00 | 0x1c)); | |
81 | |
82 sis_do_sense(0, 0, 0, 0); | |
83 | |
84 if (sis_vga_engine == SIS_300_VGA) { | |
85 testvga2_tempbh = 0x00; | |
86 testvga2_tempbl = 0xd1; | |
87 testsvhs_tempbh = 0x00; | |
88 testsvhs_tempbl = 0xb9; | |
89 testcvbs_tempbh = 0x00; | |
90 testcvbs_tempbl = 0xb3; | |
91 biosflag = 0; | |
23048 | 92 |
22850 | 93 if (sis_vbflags & (VB_301B | VB_302B | VB_301LV | VB_302LV)) { |
94 testvga2_tempbh = 0x01; | |
95 testvga2_tempbl = 0x90; | |
96 testsvhs_tempbh = 0x01; | |
97 testsvhs_tempbl = 0x6b; | |
98 testcvbs_tempbh = 0x01; | |
99 testcvbs_tempbl = 0x74; | |
100 } | |
101 inSISIDXREG(SISPART4, 0x01, myflag); | |
102 if (myflag & 0x04) { | |
103 testvga2_tempbh = 0x00; | |
104 testvga2_tempbl = 0xfd; | |
105 testsvhs_tempbh = 0x00; | |
106 testsvhs_tempbl = 0xdd; | |
107 testcvbs_tempbh = 0x00; | |
108 testcvbs_tempbl = 0xee; | |
109 } | |
110 testvga2_tempch = 0x0e; | |
111 testvga2_tempcl = 0x08; | |
112 testsvhs_tempch = 0x06; | |
113 testsvhs_tempcl = 0x04; | |
114 testcvbs_tempch = 0x08; | |
115 testcvbs_tempcl = 0x04; | |
116 | |
117 if (sis_device_id == DEVICE_SIS_300) { | |
118 inSISIDXREG(SISSR, 0x3b, myflag); | |
119 if (!(myflag & 0x01)) { | |
120 testvga2_tempbh = 0x00; | |
121 testvga2_tempbl = 0x00; | |
122 testvga2_tempch = 0x00; | |
123 testvga2_tempcl = 0x00; | |
124 } | |
125 } | |
126 } else { | |
127 testvga2_tempbh = 0x00; | |
128 testvga2_tempbl = 0xd1; | |
129 testsvhs_tempbh = 0x00; | |
130 testsvhs_tempbl = 0xb9; | |
131 testcvbs_tempbh = 0x00; | |
132 testcvbs_tempbl = 0xb3; | |
133 biosflag = 0; | |
134 | |
135 if (sis_vbflags & (VB_301B | VB_302B | VB_301LV | VB_302LV)) { | |
136 if (sis_vbflags & (VB_301B | VB_302B)) { | |
137 testvga2_tempbh = 0x01; | |
138 testvga2_tempbl = 0x90; | |
139 testsvhs_tempbh = 0x01; | |
140 testsvhs_tempbl = 0x6b; | |
141 testcvbs_tempbh = 0x01; | |
142 testcvbs_tempbl = 0x74; | |
143 } else { | |
144 testvga2_tempbh = 0x00; | |
145 testvga2_tempbl = 0x00; | |
146 testsvhs_tempbh = 0x02; | |
147 testsvhs_tempbl = 0x00; | |
148 testcvbs_tempbh = 0x01; | |
149 testcvbs_tempbl = 0x00; | |
150 } | |
151 } | |
152 if (sis_vbflags & (VB_301 | VB_301B | VB_302B)) { | |
153 inSISIDXREG(SISPART4, 0x01, myflag); | |
154 if (myflag & 0x04) { | |
155 testvga2_tempbh = 0x00; | |
156 testvga2_tempbl = 0xfd; | |
157 testsvhs_tempbh = 0x00; | |
158 testsvhs_tempbl = 0xdd; | |
159 testcvbs_tempbh = 0x00; | |
160 testcvbs_tempbl = 0xee; | |
161 } | |
162 } | |
163 if (sis_vbflags & (VB_301LV | VB_302LV)) { | |
164 /* TW: No VGA2 or SCART on LV bridges */ | |
165 testvga2_tempbh = 0x00; | |
166 testvga2_tempbl = 0x00; | |
167 testvga2_tempch = 0x00; | |
168 testvga2_tempcl = 0x00; | |
169 testsvhs_tempch = 0x04; | |
170 testsvhs_tempcl = 0x08; | |
171 testcvbs_tempch = 0x08; | |
172 testcvbs_tempcl = 0x08; | |
173 } else { | |
174 testvga2_tempch = 0x0e; | |
175 testvga2_tempcl = 0x08; | |
176 testsvhs_tempch = 0x06; | |
177 testsvhs_tempcl = 0x04; | |
178 testcvbs_tempch = 0x08; | |
179 testcvbs_tempcl = 0x04; | |
180 } | |
181 } | |
182 | |
183 /* XXX: ?? andSISIDXREG(SISCR, 0x32, ~0x14); */ | |
184 /* pSiS->postVBCR32 &= ~0x14; */ | |
185 | |
186 /* scan for VGA2/SCART */ | |
187 if (testvga2_tempch || testvga2_tempcl || | |
188 testvga2_tempbh || testvga2_tempbl) { | |
189 | |
190 haveresult = 0; | |
191 for (j = 0; j < 10; j++) { | |
192 result = 0; | |
193 for (i = 0; i < 3; i++) { | |
194 if (sis_do_sense(testvga2_tempbl, testvga2_tempbh, | |
195 testvga2_tempcl, testvga2_tempch)) | |
196 result++; | |
197 } | |
198 if ((result == 0) || (result >= 2)) | |
199 break; | |
200 } | |
201 if (result) { | |
202 if (biosflag & 0x01) { | |
203 if (sis_verbose > 1) { | |
204 printf | |
205 ("[SiS] SiS30x: Detected TV connected to SCART output\n"); | |
206 } | |
207 sis_vbflags |= TV_SCART; | |
208 orSISIDXREG(SISCR, 0x32, 0x04); | |
209 /*pSiS->postVBCR32 |= 0x04; */ | |
210 } else { | |
211 if (sis_verbose > 1) { | |
212 printf | |
213 ("[SiS] SiS30x: Detected secondary VGA connection\n"); | |
214 } | |
215 sis_vbflags |= VGA2_CONNECTED; | |
216 orSISIDXREG(SISCR, 0x32, 0x10); | |
217 /*pSiS->postVBCR32 |= 0x10; */ | |
218 } | |
219 } | |
220 } | |
221 | |
222 /* scanning for TV */ | |
223 | |
224 /* XXX: ?? andSISIDXREG(SISCR, 0x32, ~0x03); */ | |
225 /* pSiS->postVBCR32 &= ~0x03; */ | |
226 | |
227 result = sis_do_sense(testsvhs_tempbl, testsvhs_tempbh, | |
228 testsvhs_tempcl, testsvhs_tempch); | |
229 | |
230 | |
231 haveresult = 0; | |
232 for (j = 0; j < 10; j++) { | |
233 result = 0; | |
234 for (i = 0; i < 3; i++) { | |
235 if (sis_do_sense(testsvhs_tempbl, testsvhs_tempbh, | |
236 testsvhs_tempcl, testsvhs_tempch)) | |
237 result++; | |
238 } | |
239 if ((result == 0) || (result >= 2)) | |
240 break; | |
241 } | |
242 if (result) { | |
243 if (sis_verbose > 1) { | |
244 printf | |
245 ("[SiS] SiS30x: Detected TV connected to SVIDEO output\n"); | |
246 } | |
247 /* TW: So we can be sure that there IS a SVIDEO output */ | |
248 sis_vbflags |= TV_SVIDEO; | |
249 orSISIDXREG(SISCR, 0x32, 0x02); | |
250 //pSiS->postVBCR32 |= 0x02; | |
251 } | |
252 | |
253 if ((biosflag & 0x02) || (!(result))) { | |
254 haveresult = 0; | |
255 for (j = 0; j < 10; j++) { | |
256 result = 0; | |
257 for (i = 0; i < 3; i++) { | |
258 if (sis_do_sense(testcvbs_tempbl, testcvbs_tempbh, | |
259 testcvbs_tempcl, testcvbs_tempch)) | |
260 result++; | |
261 } | |
262 if ((result == 0) || (result >= 2)) | |
263 break; | |
264 } | |
265 if (result) { | |
266 if (sis_verbose > 1) { | |
267 printf | |
268 ("[SiS] SiS30x: Detected TV connected to COMPOSITE output\n"); | |
269 } | |
270 sis_vbflags |= TV_AVIDEO; | |
271 orSISIDXREG(SISCR, 0x32, 0x01); | |
272 //pSiS->postVBCR32 |= 0x01; | |
273 } | |
274 } | |
275 | |
276 sis_do_sense(0, 0, 0, 0); | |
277 | |
278 outSISIDXREG(SISPART2, 0x00, backupP2_00); | |
279 outSISIDXREG(SISPART4, 0x0d, backupP4_0d); | |
280 } | |
281 | |
282 | |
283 static void sis_detect_crt1(void) | |
284 { | |
285 unsigned char CR32; | |
286 unsigned char CRT1Detected = 0; | |
287 unsigned char OtherDevices = 0; | |
288 | |
289 if (!(sis_vbflags & VB_VIDEOBRIDGE)) { | |
290 sis_crt1_off = 0; | |
291 return; | |
292 } | |
293 | |
294 inSISIDXREG(SISCR, 0x32, CR32); | |
295 | |
296 if (CR32 & 0x20) | |
297 CRT1Detected = 1; | |
298 if (CR32 & 0x5F) | |
299 OtherDevices = 1; | |
300 | |
301 if (sis_crt1_off == -1) { | |
302 if (!CRT1Detected) { | |
303 /* BIOS detected no CRT1. */ | |
304 /* If other devices exist, switch it off */ | |
305 if (OtherDevices) | |
306 sis_crt1_off = 1; | |
307 else | |
308 sis_crt1_off = 0; | |
309 } else { | |
310 /* BIOS detected CRT1, leave/switch it on */ | |
311 sis_crt1_off = 0; | |
312 } | |
313 } | |
314 if (sis_verbose > 0) { | |
315 printf("[SiS] %sCRT1 connection detected\n", | |
316 sis_crt1_off ? "No " : ""); | |
317 } | |
318 } | |
319 | |
320 static void sis_detect_tv(void) | |
321 { | |
322 unsigned char SR16, SR38, CR32, CR38 = 0, CR79; | |
323 int temp = 0; | |
324 | |
325 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
326 return; | |
327 | |
328 inSISIDXREG(SISCR, 0x32, CR32); | |
329 inSISIDXREG(SISSR, 0x16, SR16); | |
330 inSISIDXREG(SISSR, 0x38, SR38); | |
331 switch (sis_vga_engine) { | |
332 case SIS_300_VGA: | |
333 if (sis_device_id == DEVICE_SIS_630_VGA) | |
334 temp = 0x35; | |
335 break; | |
336 case SIS_315_VGA: | |
337 temp = 0x38; | |
338 break; | |
339 } | |
340 if (temp) { | |
341 inSISIDXREG(SISCR, temp, CR38); | |
342 } | |
343 | |
344 if (CR32 & 0x47) | |
345 sis_vbflags |= CRT2_TV; | |
346 | |
347 if (CR32 & 0x04) | |
348 sis_vbflags |= TV_SCART; | |
349 else if (CR32 & 0x02) | |
350 sis_vbflags |= TV_SVIDEO; | |
351 else if (CR32 & 0x01) | |
352 sis_vbflags |= TV_AVIDEO; | |
353 else if (CR32 & 0x40) | |
354 sis_vbflags |= (TV_SVIDEO | TV_HIVISION); | |
355 else if ((CR38 & 0x04) && (sis_vbflags & (VB_301LV | VB_302LV))) | |
356 sis_vbflags |= TV_HIVISION_LV; | |
357 else if ((CR38 & 0x04) && (sis_vbflags & VB_CHRONTEL)) | |
358 sis_vbflags |= (TV_CHSCART | TV_PAL); | |
359 else if ((CR38 & 0x08) && (sis_vbflags & VB_CHRONTEL)) | |
360 sis_vbflags |= (TV_CHHDTV | TV_NTSC); | |
361 | |
362 if (sis_vbflags & (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION)) { | |
363 if (sis_vga_engine == SIS_300_VGA) { | |
364 /* TW: Should be SR38 here as well, but this | |
365 * does not work. Looks like a BIOS bug (2.04.5c). | |
366 */ | |
367 if (SR16 & 0x20) | |
368 sis_vbflags |= TV_PAL; | |
369 else | |
370 sis_vbflags |= TV_NTSC; | |
371 } else if ((sis_device_id == DEVICE_SIS_550_VGA)) { | |
372 inSISIDXREG(SISCR, 0x79, CR79); | |
373 if (CR79 & 0x08) { | |
374 inSISIDXREG(SISCR, 0x79, CR79); | |
375 CR79 >>= 5; | |
376 } | |
377 if (CR79 & 0x01) { | |
378 sis_vbflags |= TV_PAL; | |
379 if (CR38 & 0x40) | |
380 sis_vbflags |= TV_PALM; | |
381 else if (CR38 & 0x80) | |
382 sis_vbflags |= TV_PALN; | |
383 } else | |
384 sis_vbflags |= TV_NTSC; | |
385 } else if ((sis_device_id == DEVICE_SIS_650_VGA)) { | |
386 inSISIDXREG(SISCR, 0x79, CR79); | |
387 if (CR79 & 0x20) { | |
388 sis_vbflags |= TV_PAL; | |
389 if (CR38 & 0x40) | |
390 sis_vbflags |= TV_PALM; | |
391 else if (CR38 & 0x80) | |
392 sis_vbflags |= TV_PALN; | |
393 } else | |
394 sis_vbflags |= TV_NTSC; | |
395 } else { /* 315, 330 */ | |
396 if (SR38 & 0x01) { | |
397 sis_vbflags |= TV_PAL; | |
398 if (CR38 & 0x40) | |
399 sis_vbflags |= TV_PALM; | |
400 else if (CR38 & 0x80) | |
401 sis_vbflags |= TV_PALN; | |
402 } else | |
403 sis_vbflags |= TV_NTSC; | |
404 } | |
405 } | |
406 | |
407 if (sis_vbflags & | |
408 (TV_SCART | TV_SVIDEO | TV_AVIDEO | TV_HIVISION | TV_CHSCART | | |
409 TV_CHHDTV)) { | |
410 if (sis_verbose > 0) { | |
411 printf("[SiS] %sTV standard %s\n", | |
412 (sis_vbflags & (TV_CHSCART | TV_CHHDTV)) ? "Using " : | |
413 "Detected default ", | |
414 (sis_vbflags & TV_NTSC) ? ((sis_vbflags & TV_CHHDTV) ? | |
415 "480i HDTV" : "NTSC") | |
416 : ((sis_vbflags & TV_PALM) ? "PALM" | |
417 : ((sis_vbflags & TV_PALN) ? "PALN" : "PAL"))); | |
418 } | |
419 } | |
420 | |
421 } | |
422 | |
423 | |
424 static void sis_detect_crt2(void) | |
425 { | |
426 unsigned char CR32; | |
427 | |
428 if (!(sis_vbflags & VB_VIDEOBRIDGE)) | |
429 return; | |
430 | |
431 /* CRT2-VGA not supported on LVDS and 30xLV */ | |
432 if (sis_vbflags & (VB_LVDS | VB_301LV | VB_302LV)) | |
433 return; | |
434 | |
435 inSISIDXREG(SISCR, 0x32, CR32); | |
436 | |
437 if (CR32 & 0x10) | |
438 sis_vbflags |= CRT2_VGA; | |
439 } | |
440 | |
441 | |
442 /* Preinit: detect video bridge and sense connected devs */ | |
443 static void sis_detect_video_bridge(void) | |
444 { | |
445 int temp, temp1, temp2; | |
446 | |
447 | |
448 sis_vbflags = 0; | |
449 | |
450 if (sis_vga_engine != SIS_300_VGA && sis_vga_engine != SIS_315_VGA) | |
451 return; | |
452 | |
453 inSISIDXREG(SISPART4, 0x00, temp); | |
454 temp &= 0x0F; | |
455 if (temp == 1) { | |
456 inSISIDXREG(SISPART4, 0x01, temp1); | |
457 temp1 &= 0xff; | |
458 if (temp1 >= 0xE0) { | |
459 sis_vbflags |= VB_302LV; | |
460 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
461 if (sis_verbose > 1) { | |
462 printf | |
463 ("[SiS] Detected SiS302LV video bridge (ID 1; Revision 0x%x)\n", | |
464 temp1); | |
465 } | |
466 | |
467 } else if (temp1 >= 0xD0) { | |
468 sis_vbflags |= VB_301LV; | |
469 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
470 if (sis_verbose > 1) { | |
471 printf | |
472 ("[SiS] Detected SiS301LV video bridge (ID 1; Revision 0x%x)\n", | |
473 temp1); | |
474 } | |
475 } else if (temp1 >= 0xB0) { | |
476 sis_vbflags |= VB_301B; | |
477 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301B; | |
478 inSISIDXREG(SISPART4, 0x23, temp2); | |
479 if (!(temp2 & 0x02)) | |
480 sis_vbflags |= VB_30xBDH; | |
481 if (sis_verbose > 1) { | |
482 printf | |
483 ("[SiS] Detected SiS301B%s video bridge (Revision 0x%x)\n", | |
484 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
485 } | |
486 } else { | |
487 sis_vbflags |= VB_301; | |
488 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301; | |
489 if (sis_verbose > 1) { | |
490 printf | |
491 ("[SiS] Detected SiS301 video bridge (Revision 0x%x)\n", | |
492 temp1); | |
493 } | |
494 } | |
495 | |
496 sis_sense_30x(); | |
497 | |
498 } else if (temp == 2) { | |
499 | |
500 inSISIDXREG(SISPART4, 0x01, temp1); | |
501 temp1 &= 0xff; | |
502 if (temp1 >= 0xE0) { | |
503 sis_vbflags |= VB_302LV; | |
504 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302LV; | |
505 if (sis_verbose > 1) { | |
506 printf | |
507 ("[SiS] Detected SiS302LV video bridge (ID 2; Revision 0x%x)\n", | |
508 temp1); | |
509 } | |
510 } else if (temp1 >= 0xD0) { | |
511 sis_vbflags |= VB_301LV; | |
512 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_301LV; | |
513 if (sis_verbose > 1) { | |
514 printf | |
515 ("[SiS] Detected SiS301LV video bridge (ID 2; Revision 0x%x)\n", | |
516 temp1); | |
517 } | |
518 } else { | |
519 sis_vbflags |= VB_302B; | |
520 //pSiS->sishw_ext.ujVBChipID = VB_CHIP_302B; | |
521 inSISIDXREG(SISPART4, 0x23, temp2); | |
522 if (!(temp & 0x02)) | |
523 sis_vbflags |= VB_30xBDH; | |
524 if (sis_verbose > 1) { | |
525 printf | |
526 ("[SiS] Detected SiS302B%s video bridge (Revision 0x%x)\n", | |
527 (temp2 & 0x02) ? "" : " (DH)", temp1); | |
528 } | |
529 } | |
530 | |
531 sis_sense_30x(); | |
532 | |
533 } else if (temp == 3) { | |
534 if (sis_verbose > 1) { | |
535 printf("[SiS] Detected SiS303 video bridge - not supported\n"); | |
536 } | |
537 } else { | |
538 /* big scary mess of code to handle unknown or Chrontel LVDS */ | |
539 /* skipping it for now */ | |
540 if (sis_verbose > 1) { | |
541 printf | |
542 ("[SiS] Detected Chrontel video bridge - not supported\n"); | |
543 } | |
544 } | |
545 | |
546 /* this is probably not relevant to video overlay driver... */ | |
547 /* detects if brdige uses LCDA for low res text modes */ | |
548 if (sis_vga_engine == SIS_315_VGA) { | |
549 if (sis_vbflags & (VB_302B | VB_301LV | VB_302LV)) { | |
550 inSISIDXREG(SISCR, 0x34, temp); | |
551 if (temp <= 0x13) { | |
552 inSISIDXREG(SISCR, 0x38, temp); | |
553 if ((temp & 0x03) == 0x03) { | |
554 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
555 sis_vbflags |= VB_USELCDA; | |
556 } else { | |
557 inSISIDXREG(SISCR, 0x30, temp); | |
558 if (temp & 0x20) { | |
559 inSISIDXREG(SISPART1, 0x13, temp); | |
560 if (temp & 0x40) { | |
561 //pSiS->SiS_Pr->SiS_UseLCDA = TRUE; | |
562 sis_vbflags |= VB_USELCDA; | |
563 } | |
564 } | |
565 } | |
566 } | |
567 if (sis_vbflags & VB_USELCDA) { | |
568 /* printf("Bridge uses LCDA for low resolution and text modes\n"); */ | |
569 } | |
570 } | |
571 } | |
572 | |
573 | |
574 } | |
575 | |
576 | |
577 /* detect video bridge type and sense connected devices */ | |
578 void sis_init_video_bridge(void) | |
579 { | |
580 | |
581 sis_detect_video_bridge(); | |
582 | |
583 sis_detect_crt1(); | |
584 //sis_detect_lcd(); | |
585 sis_detect_tv(); | |
586 sis_detect_crt2(); | |
587 | |
588 sis_detected_crt2_devices = | |
589 sis_vbflags & (CRT2_LCD | CRT2_TV | CRT2_VGA); | |
590 | |
591 // force crt2 type | |
592 if (sis_force_crt2_type == CRT2_DEFAULT) { | |
593 if (sis_vbflags & CRT2_VGA) | |
594 sis_force_crt2_type = CRT2_VGA; | |
595 else if (sis_vbflags & CRT2_LCD) | |
596 sis_force_crt2_type = CRT2_LCD; | |
597 else if (sis_vbflags & CRT2_TV) | |
598 sis_force_crt2_type = CRT2_TV; | |
599 } | |
600 | |
601 switch (sis_force_crt2_type) { | |
602 case CRT2_TV: | |
603 sis_vbflags = sis_vbflags & ~(CRT2_LCD | CRT2_VGA); | |
604 if (sis_vbflags & VB_VIDEOBRIDGE) | |
605 sis_vbflags = sis_vbflags | CRT2_TV; | |
606 else | |
607 sis_vbflags = sis_vbflags & ~(CRT2_TV); | |
608 break; | |
609 case CRT2_LCD: | |
610 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_VGA); | |
611 if ((sis_vbflags & VB_VIDEOBRIDGE) /* XXX: && (pSiS->VBLCDFlags) */ | |
612 ) | |
613 sis_vbflags = sis_vbflags | CRT2_LCD; | |
614 else { | |
615 sis_vbflags = sis_vbflags & ~(CRT2_LCD); | |
616 if (sis_verbose > 0) { | |
617 printf | |
618 ("[SiS] Can't force CRT2 to LCD, no panel detected\n"); | |
619 } | |
620 } | |
621 break; | |
622 case CRT2_VGA: | |
623 if (sis_vbflags & VB_LVDS) { | |
624 if (sis_verbose > 0) { | |
625 printf("[SiS] LVDS does not support secondary VGA\n"); | |
626 } | |
627 break; | |
628 } | |
629 if (sis_vbflags & (VB_301LV | VB_302LV)) { | |
630 if (sis_verbose > 0) { | |
631 printf | |
632 ("[SiS] SiS30xLV bridge does not support secondary VGA\n"); | |
633 } | |
634 break; | |
635 } | |
636 sis_vbflags = sis_vbflags & ~(CRT2_TV | CRT2_LCD); | |
637 if (sis_vbflags & VB_VIDEOBRIDGE) | |
638 sis_vbflags = sis_vbflags | CRT2_VGA; | |
639 else | |
640 sis_vbflags = sis_vbflags & ~(CRT2_VGA); | |
641 break; | |
642 default: | |
643 sis_vbflags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA); | |
644 } | |
645 | |
646 /* CRT2 gamma correction?? */ | |
647 | |
648 /* other force modes: */ | |
649 /* have a 'force tv type' (svideo, composite, scart) option? */ | |
650 /* have a 'force crt1 type' (to turn it off, etc??) */ | |
651 | |
652 /* TW: Check if CRT1 used (or needed; this eg. if no CRT2 detected) */ | |
653 if (sis_vbflags & VB_VIDEOBRIDGE) { | |
654 | |
655 /* TW: No CRT2 output? Then we NEED CRT1! | |
656 * We also need CRT1 if depth = 8 and bridge=LVDS|630+301B | |
657 */ | |
658 if ((!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) || ( /*(pScrn->bitsPerPixel == 8) && */ | |
659 ((sis_vbflags & (VB_LVDS | VB_CHRONTEL)) || ((sis_vga_engine == SIS_300_VGA) && (sis_vbflags & VB_301B))))) { | |
660 sis_crt1_off = 0; | |
661 } | |
662 /* TW: No CRT2 output? Then we can't use hw overlay on CRT2 */ | |
663 if (!(sis_vbflags & (CRT2_VGA | CRT2_LCD | CRT2_TV))) | |
664 sis_overlay_on_crt1 = 1; | |
665 | |
666 } else { /* TW: no video bridge? */ | |
667 | |
668 /* Then we NEED CRT1... */ | |
669 sis_crt1_off = 0; | |
670 /* ... and can't use CRT2 for overlay output */ | |
671 sis_overlay_on_crt1 = 1; | |
672 } | |
673 | |
674 /* tvstandard options ? */ | |
675 | |
676 // determine using CRT1 or CRT2? | |
677 /* -> NO dualhead right now... */ | |
678 if (sis_vbflags & DISPTYPE_DISP2) { | |
679 if (sis_crt1_off) { | |
680 sis_vbflags |= VB_DISPMODE_SINGLE; | |
681 /* TW: No CRT1? Then we use the video overlay on CRT2 */ | |
682 sis_overlay_on_crt1 = 0; | |
683 } else /* TW: CRT1 and CRT2 - mirror or dual head ----- */ | |
684 sis_vbflags |= (VB_DISPMODE_MIRROR | DISPTYPE_CRT1); | |
685 } else { /* TW: CRT1 only ------------------------------- */ | |
686 sis_vbflags |= (VB_DISPMODE_SINGLE | DISPTYPE_CRT1); | |
687 } | |
688 | |
689 if (sis_verbose > 0) { | |
690 printf("[SiS] Using hardware overlay on CRT%d\n", | |
691 sis_overlay_on_crt1 ? 1 : 2); | |
692 } | |
693 | |
694 } |