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