Lines Matching +full:pdc +full:- +full:ranges

1 // SPDX-License-Identifier: GPL-2.0-or-later
8 * Copyright (C) 2001-2005 Thomas Winischhofer, Vienna, Austria.
19 * which is (c) 1998 Gerd Knorr <kraxel@goldbach.in-berlin.de>
52 /* ---------------------- Prototypes ------------------------- */
105 /* ------------------ Internal helper routines ----------------- */
112 sisfb_accel = -1;
113 sisfb_ypan = -1;
114 sisfb_max = -1;
115 sisfb_userom = -1;
116 sisfb_useoem = -1;
117 sisfb_mode_idx = -1;
118 sisfb_parm_rate = -1;
120 sisfb_forcecrt1 = -1;
121 sisfb_crt2type = -1;
125 sisfb_scalelcd = -1;
127 sisfb_lvdshl = -1;
130 sisfb_tvplug = -1;
131 sisfb_tvstd = -1;
141 /* ------------- Parameter parsing -------------- */
161 if( (sisbios_mode[i-1].vesa_mode_no_1 == vesamode) ||
162 (sisbios_mode[i-1].vesa_mode_no_2 == vesamode) ) {
164 if(sisbios_mode[i-1].mode_no[1] == 0x50 ||
165 sisbios_mode[i-1].mode_no[1] == 0x56 ||
166 sisbios_mode[i-1].mode_no[1] == 0x53)
169 if(sisbios_mode[i-1].mode_no[1] == 0x5a ||
170 sisbios_mode[i-1].mode_no[1] == 0x5b)
173 sisfb_mode_idx = i - 1;
240 if(sisbios_mode[i-1].mode_no[1] == 0x50 ||
241 sisbios_mode[i-1].mode_no[1] == 0x56 ||
242 sisbios_mode[i-1].mode_no[1] == 0x53)
245 if(sisbios_mode[i-1].mode_no[1] == 0x5a ||
246 sisbios_mode[i-1].mode_no[1] == 0x5b)
249 sisfb_mode_idx = i - 1;
268 while(sis_crt2type[i].type_no != -1) {
295 while(sis_tvtype[i].type_no != -1) {
347 /* ----------- Various detection routines ----------- */
357 if(ivideo->SiS_Pr.UseROM) {
358 biosver = ivideo->SiS_Pr.VirtualRomBase + 0x06;
359 biosdate = ivideo->SiS_Pr.VirtualRomBase + 0x2c;
361 chksum += ivideo->SiS_Pr.VirtualRomBase[i];
366 if( (mycustomttable[i].chipID == ivideo->chip) &&
368 (ivideo->SiS_Pr.UseROM &&
372 (ivideo->SiS_Pr.UseROM &&
376 (ivideo->SiS_Pr.UseROM &&
378 (mycustomttable[i].pcisubsysvendor == ivideo->subsysvendor) &&
379 (mycustomttable[i].pcisubsyscard == ivideo->subsysdevice) ) {
383 if(ivideo->SiS_Pr.UseROM) {
384 if(ivideo->SiS_Pr.VirtualRomBase[mycustomttable[i].biosFootprintAddr[j]] !=
393 ivideo->SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID;
425 monitor->feature = buffer[0x18];
436 * to extract ranges
443 monitor->hmin = buffer[j + 7];
444 monitor->hmax = buffer[j + 8];
445 monitor->vmin = buffer[j + 5];
446 monitor->vmax = buffer[j + 6];
447 monitor->dclockmax = buffer[j + 9] * 10 * 1000;
448 monitor->datavalid = true;
455 if(!monitor->datavalid) {
461 monitor->hmin = 65535; monitor->hmax = 0;
462 monitor->vmin = 65535; monitor->vmax = 0;
463 monitor->dclockmax = 0;
467 if(monitor->hmin > sisfb_ddcsmodes[i].h) monitor->hmin = sisfb_ddcsmodes[i].h;
468 if(monitor->hmax < sisfb_ddcsmodes[i].h) monitor->hmax = sisfb_ddcsmodes[i].h + 1;
469 if(monitor->vmin > sisfb_ddcsmodes[i].v) monitor->vmin = sisfb_ddcsmodes[i].v;
470 if(monitor->vmax < sisfb_ddcsmodes[i].v) monitor->vmax = sisfb_ddcsmodes[i].v;
471 if(monitor->dclockmax < sisfb_ddcsmodes[i].d) monitor->dclockmax = sisfb_ddcsmodes[i].d;
489 if(monitor->hmin > sisfb_ddcfmodes[j].h) monitor->hmin = sisfb_ddcfmodes[j].h;
490 if(monitor->hmax < sisfb_ddcfmodes[j].h) monitor->hmax = sisfb_ddcfmodes[j].h + 1;
491 if(monitor->vmin > sisfb_ddcsmodes[j].v) monitor->vmin = sisfb_ddcsmodes[j].v;
492 if(monitor->vmax < sisfb_ddcsmodes[j].v) monitor->vmax = sisfb_ddcsmodes[j].v;
493 if(monitor->dclockmax < sisfb_ddcsmodes[j].d) monitor->dclockmax = sisfb_ddcsmodes[j].d;
499 if((monitor->hmin <= monitor->hmax) && (monitor->vmin <= monitor->vmax)) {
500 monitor->datavalid = true;
504 return monitor->datavalid;
513 monitor->datavalid = false;
516 if(ivideo->vbflags & CRT2_LCD) realcrtno = 1;
517 else if(ivideo->vbflags & CRT2_VGA) realcrtno = 2;
521 if((ivideo->sisfb_crt1off) && (!crtno))
524 temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine,
525 realcrtno, 0, &buffer[0], ivideo->vbflags2);
536 (temp & 0x10) ? "FPDI-2" : "");
540 temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine,
541 realcrtno, 1, &buffer[0], ivideo->vbflags2);
542 } while((temp) && i--);
545 printk(KERN_INFO "sisfb: Monitor range H %d-%dKHz, V %d-%dHz, Max. dotclock %dMHz\n",
546 monitor->hmin, monitor->hmax, monitor->vmin, monitor->vmax,
547 monitor->dclockmax / 1000);
555 printk(KERN_INFO "sisfb: VESA D&P and FPDI-2 not supported yet\n");
560 /* -------------- Mode validation --------------- */
569 if(!monitor->datavalid)
576 switch(sisbios_mode[mode_idx].mode_no[ivideo->mni]) {
590 if(ivideo->sisvga_engine == SIS_315_VGA) return true;
594 if(rate < (monitor->vmin - 1))
596 if(rate > (monitor->vmax + 1))
599 if(sisfb_gettotalfrommode(&ivideo->SiS_Pr,
600 sisbios_mode[mode_idx].mode_no[ivideo->mni],
603 if(dclock > (monitor->dclockmax + 1000))
606 if(hsync < (monitor->hmin - 1))
608 if(hsync > (monitor->hmax + 1))
622 if (ivideo->sisvga_engine == SIS_300_VGA) {
624 return -1 ;
628 if (ivideo->sisvga_engine == SIS_315_VGA) {
630 return -1;
639 xres = ivideo->lcdxres; yres = ivideo->lcdyres;
641 if ((ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL848) &&
642 (ivideo->SiS_Pr.SiS_CustomT != CUT_PANEL856)) {
644 return -1;
646 return -1;
649 if (ivideo->sisfb_fstn) {
655 case 0x53: return -1;
661 if (SiS_GetModeID_LCD(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
662 sisbios_mode[myindex].yres, 0, ivideo->sisfb_fstn,
663 ivideo->SiS_Pr.SiS_CustomT, xres, yres, ivideo->vbflags2) < 0x14) {
664 return -1;
669 if (SiS_GetModeID_TV(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
670 sisbios_mode[myindex].yres, 0, ivideo->vbflags2) < 0x14) {
671 return -1;
676 if (SiS_GetModeID_VGA2(ivideo->sisvga_engine, vbflags, sisbios_mode[myindex].xres,
677 sisbios_mode[myindex].yres, 0, ivideo->vbflags2) < 0x14) {
678 return -1;
693 ivideo->rate_idx = 0;
697 ivideo->rate_idx = sisfb_vrate[i].idx;
700 if((sisfb_vrate[i].refresh - rate) <= 3) {
703 ivideo->rate_idx = sisfb_vrate[i].idx;
704 ivideo->refresh_rate = sisfb_vrate[i].refresh;
706 ((rate - sisfb_vrate[i-1].refresh) <= 2)) {
708 rate, sisfb_vrate[i-1].refresh);
709 ivideo->rate_idx = sisfb_vrate[i-1].idx;
710 ivideo->refresh_rate = sisfb_vrate[i-1].refresh;
713 } else if((rate - sisfb_vrate[i].refresh) <= 2) {
716 ivideo->rate_idx = sisfb_vrate[i].idx;
722 if(ivideo->rate_idx > 0) {
723 return ivideo->rate_idx;
736 if(!(ivideo->vbflags2 & VB2_VIDEOBRIDGE))
740 if( ((ivideo->sisvga_engine == SIS_300_VGA) && (P1_00 & 0xa0) == 0x20) ||
741 ((ivideo->sisvga_engine == SIS_315_VGA) && (P1_00 & 0x50) == 0x10) ) {
785 while ((!(SiS_GetRegByte(SISINPSTAT) & 0x08)) && --watchdog);
787 while ((SiS_GetRegByte(SISINPSTAT) & 0x08) && --watchdog);
795 switch(ivideo->sisvga_engine) {
811 if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {
827 if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!(sisfb_bridgeisslave(ivideo)))) {
834 switch(ivideo->sisvga_engine) {
925 if(ivideo->currentvbflags & VB_DISPTYPE_CRT1) {
927 if( (!ivideo->sisfb_thismonitor.datavalid) ||
928 ((ivideo->sisfb_thismonitor.datavalid) &&
929 (ivideo->sisfb_thismonitor.feature & 0xe0))) {
931 if(ivideo->sisvga_engine == SIS_315_VGA) {
932 SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xbf, cr63);
943 if(ivideo->currentvbflags & CRT2_LCD) {
945 if(ivideo->vbflags2 & VB2_SISLVDSBRIDGE) {
947 SiS_SiS30xBLOn(&ivideo->SiS_Pr);
949 SiS_SiS30xBLOff(&ivideo->SiS_Pr);
951 } else if(ivideo->sisvga_engine == SIS_315_VGA) {
953 if(ivideo->vbflags2 & VB2_CHRONTEL) {
955 SiS_Chrontel701xBLOn(&ivideo->SiS_Pr);
957 SiS_Chrontel701xBLOff(&ivideo->SiS_Pr);
963 if(((ivideo->sisvga_engine == SIS_300_VGA) &&
964 (ivideo->vbflags2 & (VB2_301|VB2_30xBDH|VB2_LVDS))) ||
965 ((ivideo->sisvga_engine == SIS_315_VGA) &&
966 ((ivideo->vbflags2 & (VB2_LVDS | VB2_CHRONTEL)) == VB2_LVDS))) {
970 if(ivideo->sisvga_engine == SIS_300_VGA) {
971 if((ivideo->vbflags2 & VB2_30xB) &&
972 (!(ivideo->vbflags2 & VB2_30xBDH))) {
975 } else if(ivideo->sisvga_engine == SIS_315_VGA) {
976 if((ivideo->vbflags2 & VB2_30xB) &&
977 (!(ivideo->vbflags2 & VB2_30xBDH))) {
982 } else if(ivideo->currentvbflags & CRT2_VGA) {
984 if(ivideo->vbflags2 & VB2_30xB) {
993 /* ------------- Callbacks from init.c/init301.c -------------- */
999 struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo;
1002 pci_read_config_dword(ivideo->nbridge, reg, &val);
1009 struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo;
1011 pci_write_config_dword(ivideo->nbridge, reg, (u32)val);
1017 struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo;
1020 if(!ivideo->lpcdev) return 0;
1022 pci_read_config_dword(ivideo->lpcdev, reg, &val);
1031 struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo;
1033 pci_write_config_byte(ivideo->nbridge, reg, (u8)val);
1039 struct sis_video_info *ivideo = (struct sis_video_info *)SiS_Pr->ivideo;
1042 if(!ivideo->lpcdev) return 0;
1044 pci_read_config_word(ivideo->lpcdev, reg, &val);
1049 /* ----------- FBDev related routines for all series ----------- */
1054 return (var->bits_per_pixel == 8) ? 256 : 16;
1060 switch(ivideo->video_bpp) {
1062 ivideo->DstColor = 0x0000;
1063 ivideo->SiS310_AccelDepth = 0x00000000;
1064 ivideo->video_cmap_len = 256;
1067 ivideo->DstColor = 0x8000;
1068 ivideo->SiS310_AccelDepth = 0x00010000;
1069 ivideo->video_cmap_len = 16;
1072 ivideo->DstColor = 0xC000;
1073 ivideo->SiS310_AccelDepth = 0x00020000;
1074 ivideo->video_cmap_len = 16;
1077 ivideo->video_cmap_len = 16;
1078 printk(KERN_ERR "sisfb: Unsupported depth %d", ivideo->video_bpp);
1079 ivideo->accel = 0;
1086 int maxyres = ivideo->sisfb_mem / (var->xres_virtual * (var->bits_per_pixel >> 3));
1096 ivideo->video_linelength = var->xres_virtual * (var->bits_per_pixel >> 3);
1097 ivideo->scrnpitchCRT1 = ivideo->video_linelength;
1098 if(!(ivideo->currentvbflags & CRT1_LCDA)) {
1099 if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
1100 ivideo->scrnpitchCRT1 <<= 1;
1109 unsigned short HDisplay1 = ivideo->scrnpitchCRT1 >> 3;
1110 unsigned short HDisplay2 = ivideo->video_linelength >> 3;
1115 if((ivideo->currentvbflags & VB_DISPTYPE_DISP1) || (isslavemode)) {
1121 if((ivideo->currentvbflags & VB_DISPTYPE_DISP2) && (!isslavemode)) {
1122 SiS_SetRegOR(SISPART1, ivideo->CRT2_write_enable, 0x01);
1131 ivideo->video_cmap_len = sisfb_get_cmap_len(var);
1133 switch(var->bits_per_pixel) {
1135 var->red.offset = var->green.offset = var->blue.offset = 0;
1136 var->red.length = var->green.length = var->blue.length = 8;
1139 var->red.offset = 11;
1140 var->red.length = 5;
1141 var->green.offset = 5;
1142 var->green.length = 6;
1143 var->blue.offset = 0;
1144 var->blue.length = 5;
1145 var->transp.offset = 0;
1146 var->transp.length = 0;
1149 var->red.offset = 16;
1150 var->red.length = 8;
1151 var->green.offset = 8;
1152 var->green.length = 8;
1153 var->blue.offset = 0;
1154 var->blue.length = 8;
1155 var->transp.offset = 24;
1156 var->transp.length = 8;
1164 unsigned short modeno = ivideo->mode_no;
1173 if(!SiSSetMode(&ivideo->SiS_Pr, modeno)) {
1174 printk(KERN_ERR "sisfb: Setting mode[0x%x] failed\n", ivideo->mode_no);
1175 return -EINVAL;
1189 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1196 htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len;
1198 vtotal = var->upper_margin + var->lower_margin + var->vsync_len;
1200 pixclock = var->pixclock;
1202 if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
1203 vtotal += var->yres;
1205 } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
1206 vtotal += var->yres;
1208 } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
1209 vtotal += var->yres;
1211 } else vtotal += var->yres;
1215 return -EINVAL;
1221 ivideo->refresh_rate = (unsigned int) (hrate * 2 / vtotal);
1223 ivideo->refresh_rate = 60;
1226 old_mode = ivideo->sisfb_mode_idx;
1227 ivideo->sisfb_mode_idx = 0;
1229 while( (sisbios_mode[ivideo->sisfb_mode_idx].mode_no[0] != 0) &&
1230 (sisbios_mode[ivideo->sisfb_mode_idx].xres <= var->xres) ) {
1231 if( (sisbios_mode[ivideo->sisfb_mode_idx].xres == var->xres) &&
1232 (sisbios_mode[ivideo->sisfb_mode_idx].yres == var->yres) &&
1233 (sisbios_mode[ivideo->sisfb_mode_idx].bpp == var->bits_per_pixel)) {
1234 ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
1238 ivideo->sisfb_mode_idx++;
1242 ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo,
1243 ivideo->sisfb_mode_idx, ivideo->currentvbflags);
1245 ivideo->sisfb_mode_idx = -1;
1248 if(ivideo->sisfb_mode_idx < 0) {
1249 printk(KERN_ERR "sisfb: Mode %dx%dx%d not supported\n", var->xres,
1250 var->yres, var->bits_per_pixel);
1251 ivideo->sisfb_mode_idx = old_mode;
1252 return -EINVAL;
1255 ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
1257 if(sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, ivideo->sisfb_mode_idx) == 0) {
1258 ivideo->rate_idx = sisbios_mode[ivideo->sisfb_mode_idx].rate_idx;
1259 ivideo->refresh_rate = 60;
1266 ivideo->accel = 0;
1269 if(var->accel_flags & FB_ACCELF_TEXT) {
1270 info->flags &= ~FBINFO_HWACCEL_DISABLED;
1272 info->flags |= FBINFO_HWACCEL_DISABLED;
1275 if(!(info->flags & FBINFO_HWACCEL_DISABLED)) ivideo->accel = -1;
1277 if(var->accel_flags & FB_ACCELF_TEXT) ivideo->accel = -1;
1284 ivideo->video_bpp = sisbios_mode[ivideo->sisfb_mode_idx].bpp;
1285 ivideo->video_width = sisbios_mode[ivideo->sisfb_mode_idx].xres;
1286 ivideo->video_height = sisbios_mode[ivideo->sisfb_mode_idx].yres;
1293 ivideo->current_width = ivideo->video_width;
1294 ivideo->current_height = ivideo->video_height;
1295 ivideo->current_bpp = ivideo->video_bpp;
1296 ivideo->current_htotal = htotal;
1297 ivideo->current_vtotal = vtotal;
1298 ivideo->current_linelength = ivideo->video_linelength;
1299 ivideo->current_pixclock = var->pixclock;
1300 ivideo->current_refresh_rate = ivideo->refresh_rate;
1301 ivideo->sisfb_lastrates[ivideo->mode_no] = ivideo->refresh_rate;
1315 if(ivideo->sisvga_engine == SIS_315_VGA) {
1323 if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {
1324 SiS_SetRegOR(SISPART1, ivideo->CRT2_write_enable, 0x01);
1328 if(ivideo->sisvga_engine == SIS_315_VGA) {
1338 ivideo->current_base = var->yoffset * info->var.xres_virtual
1339 + var->xoffset;
1342 switch (info->var.bits_per_pixel) {
1346 ivideo->current_base >>= 1;
1350 ivideo->current_base >>= 2;
1354 ivideo->current_base += (ivideo->video_offset >> 2);
1356 sisfb_set_base_CRT1(ivideo, ivideo->current_base);
1357 sisfb_set_base_CRT2(ivideo, ivideo->current_base);
1378 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1380 if(regno >= sisfb_get_cmap_len(&info->var))
1383 switch(info->var.bits_per_pixel) {
1389 if(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {
1400 ((u32 *)(info->pseudo_palette))[regno] =
1412 ((u32 *)(info->pseudo_palette))[regno] =
1424 if((err = sisfb_do_set_var(&info->var, 1, info)))
1427 sisfb_get_fix(&info->fix, -1, info);
1435 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1443 htotal = var->left_margin + var->xres + var->right_margin + var->hsync_len;
1445 vtotal = var->upper_margin + var->lower_margin + var->vsync_len;
1447 if (!var->pixclock)
1448 return -EINVAL;
1449 pixclock = var->pixclock;
1451 if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
1452 vtotal += var->yres;
1454 } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
1455 vtotal += var->yres;
1457 } else if((var->vmode & FB_VMODE_MASK) == FB_VMODE_INTERLACED) {
1458 vtotal += var->yres;
1461 vtotal += var->yres;
1469 (sisbios_mode[search_idx].xres <= var->xres) ) {
1470 if( (sisbios_mode[search_idx].xres == var->xres) &&
1471 (sisbios_mode[search_idx].yres == var->yres) &&
1472 (sisbios_mode[search_idx].bpp == var->bits_per_pixel)) {
1474 ivideo->currentvbflags)) > 0) {
1486 if( (var->xres <= sisbios_mode[search_idx].xres) &&
1487 (var->yres <= sisbios_mode[search_idx].yres) &&
1488 (var->bits_per_pixel == sisbios_mode[search_idx].bpp) ) {
1490 ivideo->currentvbflags)) > 0) {
1501 var->xres, var->yres, var->bits_per_pixel,
1504 var->bits_per_pixel);
1505 var->xres = sisbios_mode[search_idx].xres;
1506 var->yres = sisbios_mode[search_idx].yres;
1510 var->xres, var->yres, var->bits_per_pixel);
1511 return -EINVAL;
1515 if( ((ivideo->vbflags2 & VB2_LVDS) ||
1516 ((ivideo->vbflags2 & VB2_30xBDH) && (ivideo->currentvbflags & CRT2_LCD))) &&
1517 (var->bits_per_pixel == 8) ) {
1518 /* Slave modes on LVDS and 301B-DH */
1521 } else if( (ivideo->current_htotal == htotal) &&
1522 (ivideo->current_vtotal == vtotal) &&
1523 (ivideo->current_pixclock == pixclock) ) {
1524 /* x=x & y=y & c=c -> assume depth change */
1528 } else if( ( (ivideo->current_htotal != htotal) ||
1529 (ivideo->current_vtotal != vtotal) ) &&
1530 (ivideo->current_pixclock == var->pixclock) ) {
1531 /* x!=x | y!=y & c=c -> invalid pixclock */
1532 if(ivideo->sisfb_lastrates[sisbios_mode[search_idx].mode_no[ivideo->mni]]) {
1534 ivideo->sisfb_lastrates[sisbios_mode[search_idx].mode_no[ivideo->mni]];
1535 } else if(ivideo->sisfb_parm_rate != -1) {
1536 /* Sic, sisfb_parm_rate - want to know originally desired rate here */
1537 refresh_rate = ivideo->sisfb_parm_rate;
1546 } else if(ivideo->current_refresh_rate) {
1547 refresh_rate = ivideo->current_refresh_rate;
1559 var->pixclock = (u32) (1000000000 / sisfb_mode_rate_to_dclock(&ivideo->SiS_Pr,
1560 sisbios_mode[search_idx].mode_no[ivideo->mni],
1562 sisfb_mode_rate_to_ddata(&ivideo->SiS_Pr,
1563 sisbios_mode[search_idx].mode_no[ivideo->mni],
1565 if((var->vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
1566 var->pixclock <<= 1;
1570 if(ivideo->sisfb_thismonitor.datavalid) {
1571 if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, search_idx,
1581 if(var->xres > var->xres_virtual)
1582 var->xres_virtual = var->xres;
1584 if(ivideo->sisfb_ypan) {
1586 if(ivideo->sisfb_max) {
1587 var->yres_virtual = maxyres;
1589 if(var->yres_virtual > maxyres) {
1590 var->yres_virtual = maxyres;
1593 if(var->yres_virtual <= var->yres) {
1594 var->yres_virtual = var->yres;
1597 if(var->yres != var->yres_virtual) {
1598 var->yres_virtual = var->yres;
1600 var->xoffset = 0;
1601 var->yoffset = 0;
1605 if(var->xoffset > var->xres_virtual - var->xres) {
1606 var->xoffset = var->xres_virtual - var->xres - 1;
1609 if(var->yoffset > var->yres_virtual - var->yres) {
1610 var->yoffset = var->yres_virtual - var->yres - 1;
1614 var->red.msb_right =
1615 var->green.msb_right =
1616 var->blue.msb_right =
1617 var->transp.offset =
1618 var->transp.length =
1619 var->transp.msb_right = 0;
1627 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1630 if (var->vmode & FB_VMODE_YWRAP)
1631 return -EINVAL;
1633 if (var->xoffset + info->var.xres > info->var.xres_virtual ||
1634 var->yoffset + info->var.yres > info->var.yres_virtual)
1635 return -EINVAL;
1641 info->var.xoffset = var->xoffset;
1642 info->var.yoffset = var->yoffset;
1650 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1655 /* ----------- FBDev related routines for all series ---------- */
1660 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1672 return -EPERM;
1675 return -EFAULT;
1681 return -EFAULT;
1687 return -EPERM;
1690 return -EFAULT;
1703 return -EFAULT;
1711 if(ivideo->warncount++ < 10)
1713 "sisfb: Deprecated ioctl call received - update your application!\n");
1716 ivideo->sisfb_infoblock.sisfb_id = SISFB_ID;
1717 ivideo->sisfb_infoblock.sisfb_version = VER_MAJOR;
1718 ivideo->sisfb_infoblock.sisfb_revision = VER_MINOR;
1719 ivideo->sisfb_infoblock.sisfb_patchlevel = VER_LEVEL;
1720 ivideo->sisfb_infoblock.chip_id = ivideo->chip_id;
1721 ivideo->sisfb_infoblock.sisfb_pci_vendor = ivideo->chip_vendor;
1722 ivideo->sisfb_infoblock.memory = ivideo->video_size / 1024;
1723 ivideo->sisfb_infoblock.heapstart = ivideo->heapstart / 1024;
1724 if(ivideo->modechanged) {
1725 ivideo->sisfb_infoblock.fbvidmode = ivideo->mode_no;
1727 ivideo->sisfb_infoblock.fbvidmode = ivideo->modeprechange;
1729 ivideo->sisfb_infoblock.sisfb_caps = ivideo->caps;
1730 ivideo->sisfb_infoblock.sisfb_tqlen = ivideo->cmdQueueSize / 1024;
1731 ivideo->sisfb_infoblock.sisfb_pcibus = ivideo->pcibus;
1732 ivideo->sisfb_infoblock.sisfb_pcislot = ivideo->pcislot;
1733 ivideo->sisfb_infoblock.sisfb_pcifunc = ivideo->pcifunc;
1734 ivideo->sisfb_infoblock.sisfb_lcdpdc = ivideo->detectedpdc;
1735 ivideo->sisfb_infoblock.sisfb_lcdpdca = ivideo->detectedpdca;
1736 ivideo->sisfb_infoblock.sisfb_lcda = ivideo->detectedlcda;
1737 ivideo->sisfb_infoblock.sisfb_vbflags = ivideo->vbflags;
1738 ivideo->sisfb_infoblock.sisfb_currentvbflags = ivideo->currentvbflags;
1739 ivideo->sisfb_infoblock.sisfb_scalelcd = ivideo->SiS_Pr.UsePanelScaler;
1740 ivideo->sisfb_infoblock.sisfb_specialtiming = ivideo->SiS_Pr.SiS_CustomT;
1741 ivideo->sisfb_infoblock.sisfb_haveemi = ivideo->SiS_Pr.HaveEMI ? 1 : 0;
1742 ivideo->sisfb_infoblock.sisfb_haveemilcd = ivideo->SiS_Pr.HaveEMILCD ? 1 : 0;
1743 ivideo->sisfb_infoblock.sisfb_emi30 = ivideo->SiS_Pr.EMI_30;
1744 ivideo->sisfb_infoblock.sisfb_emi31 = ivideo->SiS_Pr.EMI_31;
1745 ivideo->sisfb_infoblock.sisfb_emi32 = ivideo->SiS_Pr.EMI_32;
1746 ivideo->sisfb_infoblock.sisfb_emi33 = ivideo->SiS_Pr.EMI_33;
1747 ivideo->sisfb_infoblock.sisfb_tvxpos = (u16)(ivideo->tvxpos + 32);
1748 ivideo->sisfb_infoblock.sisfb_tvypos = (u16)(ivideo->tvypos + 32);
1749 ivideo->sisfb_infoblock.sisfb_heapsize = ivideo->sisfb_heap_size / 1024;
1750 ivideo->sisfb_infoblock.sisfb_videooffset = ivideo->video_offset;
1751 ivideo->sisfb_infoblock.sisfb_curfstn = ivideo->curFSTN;
1752 ivideo->sisfb_infoblock.sisfb_curdstn = ivideo->curDSTN;
1753 ivideo->sisfb_infoblock.sisfb_vbflags2 = ivideo->vbflags2;
1754 ivideo->sisfb_infoblock.sisfb_can_post = ivideo->sisfb_can_post ? 1 : 0;
1755 ivideo->sisfb_infoblock.sisfb_card_posted = ivideo->sisfb_card_posted ? 1 : 0;
1756 ivideo->sisfb_infoblock.sisfb_was_boot_device = ivideo->sisfb_was_boot_device ? 1 : 0;
1758 if(copy_to_user((void __user *)arg, &ivideo->sisfb_infoblock,
1759 sizeof(ivideo->sisfb_infoblock)))
1760 return -EFAULT;
1765 if(ivideo->warncount++ < 10)
1767 "sisfb: Deprecated ioctl call received - update your application!\n");
1776 if(ivideo->warncount++ < 10)
1778 "sisfb: Deprecated ioctl call received - update your application!\n");
1781 if(ivideo->sisfb_max)
1787 if(ivideo->warncount++ < 10)
1789 "sisfb: Deprecated ioctl call received - update your application!\n");
1793 return -EFAULT;
1795 ivideo->sisfb_max = (gpu32) ? 1 : 0;
1800 return -EFAULT;
1802 sisfb_set_TVxposoffset(ivideo, ((int)(gpu32 >> 16)) - 32);
1803 sisfb_set_TVyposoffset(ivideo, ((int)(gpu32 & 0xffff)) - 32);
1807 return put_user((u32)(((ivideo->tvxpos+32)<<16)|((ivideo->tvypos+32)&0xffff)),
1811 if(copy_from_user(&ivideo->sisfb_command, (void __user *)arg,
1813 return -EFAULT;
1815 sisfb_handle_command(ivideo, &ivideo->sisfb_command);
1817 if(copy_to_user((void __user *)arg, &ivideo->sisfb_command,
1819 return -EFAULT;
1825 return -EFAULT;
1827 ivideo->sisfblocked = (gpu32) ? 1 : 0;
1832 return -ENOIOCTLCMD;
1834 return -EINVAL;
1843 struct sis_video_info *ivideo = (struct sis_video_info *)info->par;
1847 strscpy(fix->id, ivideo->myid, sizeof(fix->id));
1849 mutex_lock(&info->mm_lock);
1850 fix->smem_start = ivideo->video_base + ivideo->video_offset;
1851 fix->smem_len = ivideo->sisfb_mem;
1852 mutex_unlock(&info->mm_lock);
1853 fix->type = FB_TYPE_PACKED_PIXELS;
1854 fix->type_aux = 0;
1855 fix->visual = (ivideo->video_bpp == 8) ? FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
1856 fix->xpanstep = 1;
1857 fix->ypanstep = (ivideo->sisfb_ypan) ? 1 : 0;
1858 fix->ywrapstep = 0;
1859 fix->line_length = ivideo->video_linelength;
1860 fix->mmio_start = ivideo->mmio_base;
1861 fix->mmio_len = ivideo->mmio_size;
1862 if(ivideo->sisvga_engine == SIS_300_VGA) {
1863 fix->accel = FB_ACCEL_SIS_GLAMOUR;
1864 } else if((ivideo->chip == SIS_330) ||
1865 (ivideo->chip == SIS_760) ||
1866 (ivideo->chip == SIS_761)) {
1867 fix->accel = FB_ACCEL_SIS_XABRE;
1868 } else if(ivideo->chip == XGI_20) {
1869 fix->accel = FB_ACCEL_XGI_VOLARI_Z;
1870 } else if(ivideo->chip >= XGI_40) {
1871 fix->accel = FB_ACCEL_XGI_VOLARI_V;
1873 fix->accel = FB_ACCEL_SIS_GLAMOUR_2;
1879 /* ---------------- fb_ops structures ----------------- */
1902 /* ---------------- Chip generation dependent routines ---------------- */
1949 ivideo->video_size = 0;
1950 ivideo->UMAsize = ivideo->LFBsize = 0;
1952 switch(ivideo->chip) {
1956 ivideo->video_size = ((reg & 0x3F) + 1) << 20;
1961 if(!ivideo->nbridge)
1962 return -1;
1963 pci_read_config_byte(ivideo->nbridge, 0x63, &reg);
1964 ivideo->video_size = 1 << (((reg & 0x70) >> 4) + 21);
1972 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
1976 ivideo->video_size <<= 1;
1979 ivideo->video_size += (ivideo->video_size/2);
1984 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
1985 if(reg & 0x0c) ivideo->video_size <<= 1;
1991 ivideo->video_size = (((reg & 0x3f) + 1) << 2) << 20;
1996 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
2004 ivideo->video_size = (1 << reg) << 20;
2005 ivideo->UMAsize = ivideo->video_size;
2011 ivideo->LFBsize = (32 << 20);
2013 ivideo->LFBsize = (64 << 20);
2015 ivideo->video_size += ivideo->LFBsize;
2022 ivideo->video_size = (1 << ((reg & 0xf0) >> 4)) << 20;
2023 if(ivideo->chip != XGI_20) {
2025 if(ivideo->revision_id == 2) {
2029 if(reg == 0x02) ivideo->video_size <<= 1;
2030 else if(reg == 0x03) ivideo->video_size <<= 2;
2035 return -1;
2040 /* -------------- video bridge device detection --------------- */
2047 if(ivideo->chip == XGI_20) {
2048 ivideo->sisfb_crt1off = 0;
2053 if(ivideo->sisvga_engine == SIS_300_VGA) {
2055 if((temp & 0x0F) && (ivideo->chip != SIS_300)) {
2057 if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN))) {
2060 ivideo->vbflags |= TV_PAL;
2062 ivideo->vbflags |= TV_NTSC;
2071 ivideo->sisfb_crt1off = 0;
2073 ivideo->sisfb_crt1off = (cr32 & 0xDF) ? 1 : 0;
2076 ivideo->vbflags &= ~(CRT2_TV | CRT2_LCD | CRT2_VGA);
2078 if(cr32 & SIS_VB_TV) ivideo->vbflags |= CRT2_TV;
2079 if(cr32 & SIS_VB_LCD) ivideo->vbflags |= CRT2_LCD;
2080 if(cr32 & SIS_VB_CRT2) ivideo->vbflags |= CRT2_VGA;
2087 if(ivideo->chip != SIS_550) {
2088 ivideo->sisfb_dstn = ivideo->sisfb_fstn = 0;
2091 if(ivideo->sisfb_tvplug != -1) {
2092 if( (ivideo->sisvga_engine != SIS_315_VGA) ||
2093 (!(ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) ) {
2094 if(ivideo->sisfb_tvplug & TV_YPBPR) {
2095 ivideo->sisfb_tvplug = -1;
2100 if(ivideo->sisfb_tvplug != -1) {
2101 if( (ivideo->sisvga_engine != SIS_315_VGA) ||
2102 (!(ivideo->vbflags2 & VB2_SISHIVISIONBRIDGE)) ) {
2103 if(ivideo->sisfb_tvplug & TV_HIVISION) {
2104 ivideo->sisfb_tvplug = -1;
2109 if(ivideo->sisfb_tvstd != -1) {
2110 if( (!(ivideo->vbflags2 & VB2_SISBRIDGE)) &&
2111 (!((ivideo->sisvga_engine == SIS_315_VGA) &&
2112 (ivideo->vbflags2 & VB2_CHRONTEL))) ) {
2113 if(ivideo->sisfb_tvstd & (TV_PALM | TV_PALN | TV_NTSCJ)) {
2114 ivideo->sisfb_tvstd = -1;
2121 if(ivideo->sisfb_tvplug != -1) {
2122 ivideo->vbflags |= ivideo->sisfb_tvplug;
2124 if(cr32 & SIS_VB_YPBPR) ivideo->vbflags |= (TV_YPBPR|TV_YPBPR525I); /* default: 480i */
2125 else if(cr32 & SIS_VB_HIVISION) ivideo->vbflags |= TV_HIVISION;
2126 else if(cr32 & SIS_VB_SCART) ivideo->vbflags |= TV_SCART;
2128 if(cr32 & SIS_VB_SVIDEO) ivideo->vbflags |= TV_SVIDEO;
2129 if(cr32 & SIS_VB_COMPOSITE) ivideo->vbflags |= TV_AVIDEO;
2133 if(!(ivideo->vbflags & (TV_YPBPR | TV_HIVISION))) {
2134 if(ivideo->sisfb_tvstd != -1) {
2135 ivideo->vbflags &= ~(TV_NTSC | TV_PAL | TV_PALM | TV_PALN | TV_NTSCJ);
2136 ivideo->vbflags |= ivideo->sisfb_tvstd;
2138 if(ivideo->vbflags & TV_SCART) {
2139 ivideo->vbflags &= ~(TV_NTSC | TV_PALM | TV_PALN | TV_NTSCJ);
2140 ivideo->vbflags |= TV_PAL;
2142 if(!(ivideo->vbflags & (TV_PAL | TV_NTSC | TV_PALM | TV_PALN | TV_NTSCJ))) {
2143 if(ivideo->sisvga_engine == SIS_300_VGA) {
2145 if(temp & 0x01) ivideo->vbflags |= TV_PAL;
2146 else ivideo->vbflags |= TV_NTSC;
2147 } else if((ivideo->chip <= SIS_315PRO) || (ivideo->chip >= SIS_330)) {
2149 if(temp & 0x01) ivideo->vbflags |= TV_PAL;
2150 else ivideo->vbflags |= TV_NTSC;
2153 if(temp & 0x20) ivideo->vbflags |= TV_PAL;
2154 else ivideo->vbflags |= TV_NTSC;
2160 if(ivideo->sisfb_forcecrt1 != -1) {
2161 ivideo->sisfb_crt1off = (ivideo->sisfb_forcecrt1) ? 0 : 1;
2165 /* ------------------ Sensing routines ------------------ */
2172 old = SiS_ReadDDC1Bit(&ivideo->SiS_Pr);
2174 if(old != SiS_ReadDDC1Bit(&ivideo->SiS_Pr)) break;
2175 } while(count--);
2176 return (count != -1);
2197 if (ivideo->sisvga_engine == SIS_315_VGA) {
2198 cr63 = SiS_GetReg(SISCR, ivideo->SiS_Pr.SiS_MyCR63);
2200 SiS_SetRegAND(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF);
2219 if (ivideo->chip >= SIS_330) {
2221 if (ivideo->chip >= SIS_340)
2243 temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags,
2244 ivideo->sisvga_engine, 0, 0, NULL, ivideo->vbflags2);
2245 } while (((temp == 0) || (temp == 0xffff)) && i--);
2257 if (ivideo->sisvga_engine == SIS_315_VGA)
2258 SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, 0xBF, cr63);
2273 ivideo->SiS_Pr.PanelSelfDetected = false;
2276 if (!(ivideo->vbflags2 & VB2_SISTMDSBRIDGE))
2278 if (ivideo->vbflags2 & VB2_30xBDH)
2287 if (ivideo->SiS_Pr.DDCPortMixup)
2291 temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags, ivideo->sisvga_engine,
2292 realcrtno, 0, &buffer[0], ivideo->vbflags2);
2300 temp = SiS_HandleDDC(&ivideo->SiS_Pr, ivideo->vbflags,
2301 ivideo->sisvga_engine, realcrtno, 1,
2302 &buffer[0], ivideo->vbflags2);
2303 } while ((temp) && i--);
2329 if ((yres == 1200) && (ivideo->vbflags2 & VB2_30xC))
2350 ivideo->SiS_Pr.PanelSelfDetected = true;
2364 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1500);
2375 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x1000);
2395 if(ivideo->vbflags2 & VB2_301) {
2401 } else if(ivideo->vbflags2 & (VB2_301B | VB2_302B)) {
2403 } else if(ivideo->vbflags2 & (VB2_301LV | VB2_302LV)) {
2405 } else if(ivideo->vbflags2 & (VB2_301C | VB2_302ELV | VB2_307T | VB2_307LV)) {
2411 if(ivideo->vbflags & (VB2_301LV|VB2_302LV|VB2_302ELV|VB2_307LV)) {
2416 if(ivideo->haveXGIROM) {
2417 biosflag = ivideo->bios_abase[0x58] & 0x03;
2418 } else if(ivideo->newrom) {
2419 if(ivideo->bios_abase[0x5d] & 0x04) biosflag |= 0x01;
2420 } else if(ivideo->sisvga_engine == SIS_300_VGA) {
2421 if(ivideo->bios_abase) {
2422 biosflag = ivideo->bios_abase[0xfe] & 0x03;
2426 if(ivideo->chip == SIS_300) {
2431 if(!(ivideo->vbflags2 & VB2_SISVGA2BRIDGE)) {
2439 if(ivideo->vbflags2 & VB2_30xC) {
2444 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x2000);
2450 if(ivideo->vbflags2 & VB2_SISYPBPRBRIDGE) {
2454 if(!(ivideo->vbflags2 & VB2_30xCLV)) {
2474 if(ivideo->vbflags2 & VB2_30xCLV) {
2478 if((ivideo->sisvga_engine == SIS_315_VGA) && (ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) {
2480 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x2000);
2492 if(!(ivideo->vbflags & TV_YPBPR)) {
2511 if(ivideo->vbflags2 & VB2_30xCLV) {
2514 for(myflag = 2; myflag > 0; myflag--) {
2536 if(ivideo->chip < SIS_315H) {
2539 ivideo->SiS_Pr.SiS_IF_DEF_CH70xx = 1; /* Chrontel 700x */
2540 SiS_SetChrontelGPIO(&ivideo->SiS_Pr, 0x9c); /* Set general purpose IO for Chrontel communication */
2541 SiS_DDC2Delay(&ivideo->SiS_Pr, 1000);
2542 temp1 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x25);
2544 temp2 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0e);
2546 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0e, 0x0b);
2547 SiS_DDC2Delay(&ivideo->SiS_Pr, 300);
2549 temp2 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x25);
2554 temp1 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0e);
2557 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0e,0x0b);
2558 SiS_DDC2Delay(&ivideo->SiS_Pr, 300);
2562 SiS_SetCH700x(&ivideo->SiS_Pr, 0x10, 0x01);
2563 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96);
2564 SiS_SetCH700x(&ivideo->SiS_Pr, 0x10, 0x00);
2565 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96);
2566 temp1 = SiS_GetCH700x(&ivideo->SiS_Pr, 0x10);
2570 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96);
2578 "sisfb: TV detection unreliable - test results varied\n");
2583 ivideo->vbflags |= TV_SVIDEO;
2588 ivideo->vbflags |= TV_AVIDEO;
2592 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8);
2596 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x0e, 0x01, 0xF8);
2600 SiS_SetChrontelGPIO(&ivideo->SiS_Pr, 0x00);
2606 ivideo->SiS_Pr.SiS_IF_DEF_CH70xx = 2; /* Chrontel 7019 */
2607 temp1 = SiS_GetCH701x(&ivideo->SiS_Pr, 0x49);
2608 SiS_SetCH701x(&ivideo->SiS_Pr, 0x49, 0x20);
2609 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96);
2610 temp2 = SiS_GetCH701x(&ivideo->SiS_Pr, 0x20);
2612 SiS_SetCH701x(&ivideo->SiS_Pr, 0x20, temp2);
2613 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96);
2615 SiS_SetCH701x(&ivideo->SiS_Pr, 0x20, temp2);
2616 SiS_DDC2Delay(&ivideo->SiS_Pr, 0x96);
2617 temp2 = SiS_GetCH701x(&ivideo->SiS_Pr, 0x20);
2618 SiS_SetCH701x(&ivideo->SiS_Pr, 0x49, temp1);
2627 ivideo->vbflags |= TV_AVIDEO;
2633 ivideo->vbflags |= TV_SVIDEO;
2657 if(ivideo->chip == XGI_20)
2665 ivideo->vbflags |= VB_301; /* Deprecated */
2666 ivideo->vbflags2 |= VB2_301;
2669 ivideo->vbflags |= VB_301B; /* Deprecated */
2670 ivideo->vbflags2 |= VB2_301B;
2673 ivideo->vbflags |= VB_30xBDH; /* Deprecated */
2674 ivideo->vbflags2 |= VB2_30xBDH;
2675 printk(KERN_INFO "%s SiS301B-DH %s\n", stdstr, bridgestr);
2680 ivideo->vbflags |= VB_301C; /* Deprecated */
2681 ivideo->vbflags2 |= VB2_301C;
2684 ivideo->vbflags |= VB_301LV; /* Deprecated */
2685 ivideo->vbflags2 |= VB2_301LV;
2690 ivideo->vbflags |= VB_302LV; /* Deprecated */
2691 ivideo->vbflags2 |= VB2_302LV;
2694 ivideo->vbflags |= VB_301C; /* Deprecated */
2695 ivideo->vbflags2 |= VB2_301C;
2698 ivideo->vbflags |= VB_302ELV; /* Deprecated */
2699 ivideo->vbflags2 |= VB2_302ELV;
2706 ivideo->vbflags |= VB_302B; /* Deprecated */
2707 ivideo->vbflags2 |= VB2_302B;
2712 if((!(ivideo->vbflags2 & VB2_VIDEOBRIDGE)) && (ivideo->chip != SIS_300)) {
2716 if(ivideo->sisvga_engine == SIS_300_VGA) {
2720 ivideo->vbflags |= VB_LVDS; /* Deprecated */
2721 ivideo->vbflags2 |= VB2_LVDS;
2724 ivideo->vbflags |= (VB_LVDS | VB_TRUMPION); /* Deprecated */
2725 ivideo->vbflags2 |= (VB2_LVDS | VB2_TRUMPION);
2728 ivideo->vbflags |= VB_CHRONTEL; /* Deprecated */
2729 ivideo->vbflags2 |= VB2_CHRONTEL;
2732 ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); /* Deprecated */
2733 ivideo->vbflags2 |= (VB2_LVDS | VB2_CHRONTEL);
2736 if(ivideo->vbflags2 & VB2_CHRONTEL) ivideo->chronteltype = 1;
2738 } else if(ivideo->chip < SIS_661) {
2742 ivideo->vbflags |= VB_LVDS; /* Deprecated */
2743 ivideo->vbflags2 |= VB2_LVDS;
2746 ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); /* Deprecated */
2747 ivideo->vbflags2 |= (VB2_LVDS | VB2_CHRONTEL);
2750 if(ivideo->vbflags2 & VB2_CHRONTEL) ivideo->chronteltype = 2;
2752 } else if(ivideo->chip >= SIS_661) {
2758 ivideo->vbflags |= VB_LVDS; /* Deprecated */
2759 ivideo->vbflags2 |= VB2_LVDS;
2762 ivideo->vbflags |= (VB_LVDS | VB_CHRONTEL); /* Deprecated */
2763 ivideo->vbflags2 |= (VB2_LVDS | VB2_CHRONTEL);
2766 ivideo->vbflags |= (VB_LVDS | VB_CONEXANT); /* Deprecated */
2767 ivideo->vbflags2 |= (VB2_LVDS | VB2_CONEXANT);
2770 if(ivideo->vbflags2 & VB2_CHRONTEL) ivideo->chronteltype = 2;
2773 if(ivideo->vbflags2 & VB2_LVDS) {
2776 if((ivideo->sisvga_engine == SIS_300_VGA) && (ivideo->vbflags2 & VB2_TRUMPION)) {
2779 if(ivideo->vbflags2 & VB2_CHRONTEL) {
2782 if((ivideo->chip >= SIS_661) && (ivideo->vbflags2 & VB2_CONEXANT)) {
2787 if(ivideo->vbflags2 & VB2_SISBRIDGE) {
2790 } else if(ivideo->vbflags2 & VB2_CHRONTEL) {
2795 /* ---------- Engine initialization routines ------------ */
2805 ivideo->caps &= ~(TURBO_QUEUE_CAP |
2811 if(ivideo->sisvga_engine == SIS_300_VGA) {
2815 tqueue_pos = (ivideo->video_size - ivideo->cmdQueueSize) / (64 * 1024);
2825 ivideo->caps |= TURBO_QUEUE_CAP;
2830 if(ivideo->sisvga_engine == SIS_315_VGA) {
2834 if(ivideo->chip == XGI_20) {
2835 switch(ivideo->cmdQueueSize) {
2844 switch(ivideo->cmdQueueSize) {
2863 if((ivideo->chip >= XGI_40) && ivideo->modechanged) {
2869 if(!((templ = MMIO_IN32(ivideo->mmio_vbase, 0x8240)) & (1 << 10))) {
2871 MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, 0);
2875 tempq = MMIO_IN32(ivideo->mmio_vbase, Q_READ_PTR);
2876 MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, tempq);
2878 tempq = (u32)(ivideo->video_size - ivideo->cmdQueueSize);
2879 MMIO_OUT32(ivideo->mmio_vbase, Q_BASE_ADDR, tempq);
2881 writel(0x16800000 + 0x8240, ivideo->video_vbase + tempq);
2882 writel(templ | (1 << 10), ivideo->video_vbase + tempq + 4);
2883 writel(0x168F0000, ivideo->video_vbase + tempq + 8);
2884 writel(0x168F0000, ivideo->video_vbase + tempq + 12);
2886 MMIO_OUT32(ivideo->mmio_vbase, Q_WRITE_PTR, (tempq + 16));
2895 tempq = MMIO_IN32(ivideo->mmio_vbase, MMIO_QUEUE_READPORT);
2896 MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_WRITEPORT, tempq);
2901 tempq = (u32)(ivideo->video_size - ivideo->cmdQueueSize);
2902 MMIO_OUT32(ivideo->mmio_vbase, MMIO_QUEUE_PHYBASE, tempq);
2904 ivideo->caps |= MMIO_CMD_QUEUE_CAP;
2908 ivideo->engineok = 1;
2918 if(ivideo->sisvga_engine == SIS_300_VGA) {
2919 ivideo->CRT2LCDType = sis300paneltype[reg];
2920 } else if(ivideo->chip >= SIS_661) {
2921 ivideo->CRT2LCDType = sis661paneltype[reg];
2923 ivideo->CRT2LCDType = sis310paneltype[reg];
2924 if((ivideo->chip == SIS_550) && (sisfb_fstn)) {
2925 if((ivideo->CRT2LCDType != LCD_320x240_2) &&
2926 (ivideo->CRT2LCDType != LCD_320x240_3)) {
2927 ivideo->CRT2LCDType = LCD_320x240;
2932 if(ivideo->CRT2LCDType == LCD_UNKNOWN) {
2934 ivideo->CRT2LCDType = LCD_1024x768;
2941 if(ivideo->CRT2LCDType == sis_lcd_data[i].lcdtype) {
2942 ivideo->lcdxres = sis_lcd_data[i].xres;
2943 ivideo->lcdyres = sis_lcd_data[i].yres;
2944 ivideo->lcddefmodeidx = sis_lcd_data[i].default_mode_idx;
2950 if(ivideo->SiS_Pr.SiS_CustomT == CUT_BARCO1366) {
2951 ivideo->lcdxres = 1360; ivideo->lcdyres = 1024;
2952 ivideo->lcddefmodeidx = DEFAULT_MODE_1360;
2953 } else if(ivideo->SiS_Pr.SiS_CustomT == CUT_PANEL848) {
2954 ivideo->lcdxres = 848; ivideo->lcdyres = 480;
2955 ivideo->lcddefmodeidx = DEFAULT_MODE_848;
2956 } else if(ivideo->SiS_Pr.SiS_CustomT == CUT_PANEL856) {
2957 ivideo->lcdxres = 856; ivideo->lcdyres = 480;
2958 ivideo->lcddefmodeidx = DEFAULT_MODE_856;
2963 ivideo->lcdxres, ivideo->lcdyres);
2970 if(ivideo->sisvga_engine == SIS_300_VGA) {
2971 if(ivideo->vbflags2 & (VB2_LVDS | VB2_30xBDH)) {
2975 /* Currently on LCD? If yes, read current pdc */
2976 ivideo->detectedpdc = SiS_GetReg(SISPART1, 0x13);
2977 ivideo->detectedpdc &= 0x3c;
2978 if(ivideo->SiS_Pr.PDC == -1) {
2980 ivideo->SiS_Pr.PDC = ivideo->detectedpdc;
2982 printk(KERN_INFO "sisfb: Detected LCD PDC 0x%02x\n",
2983 ivideo->detectedpdc);
2985 if((ivideo->SiS_Pr.PDC != -1) &&
2986 (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) {
2987 printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x\n",
2988 ivideo->SiS_Pr.PDC);
2995 if(ivideo->sisvga_engine == SIS_315_VGA) {
2998 if(ivideo->vbflags2 & VB2_SISLCDABRIDGE) {
3002 ivideo->SiS_Pr.SiS_UseLCDA = true;
3003 ivideo->detectedlcda = 0x03;
3007 /* Save PDC */
3008 if(ivideo->vbflags2 & VB2_SISLVDSBRIDGE) {
3011 if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) {
3012 /* Currently on LCD? If yes, read current pdc */
3013 u8 pdc;
3014 pdc = SiS_GetReg(SISPART1, 0x2D);
3015 ivideo->detectedpdc = (pdc & 0x0f) << 1;
3016 ivideo->detectedpdca = (pdc & 0xf0) >> 3;
3017 pdc = SiS_GetReg(SISPART1, 0x35);
3018 ivideo->detectedpdc |= ((pdc >> 7) & 0x01);
3019 pdc = SiS_GetReg(SISPART1, 0x20);
3020 ivideo->detectedpdca |= ((pdc >> 6) & 0x01);
3021 if(ivideo->newrom) {
3022 /* New ROM invalidates other PDC resp. */
3023 if(ivideo->detectedlcda != 0xff) {
3024 ivideo->detectedpdc = 0xff;
3026 ivideo->detectedpdca = 0xff;
3029 if(ivideo->SiS_Pr.PDC == -1) {
3030 if(ivideo->detectedpdc != 0xff) {
3031 ivideo->SiS_Pr.PDC = ivideo->detectedpdc;
3034 if(ivideo->SiS_Pr.PDCA == -1) {
3035 if(ivideo->detectedpdca != 0xff) {
3036 ivideo->SiS_Pr.PDCA = ivideo->detectedpdca;
3039 if(ivideo->detectedpdc != 0xff) {
3041 "sisfb: Detected LCD PDC 0x%02x (for LCD=CRT2)\n",
3042 ivideo->detectedpdc);
3044 if(ivideo->detectedpdca != 0xff) {
3047 ivideo->detectedpdca);
3052 if(ivideo->vbflags2 & VB2_SISEMIBRIDGE) {
3053 ivideo->SiS_Pr.EMI_30 = SiS_GetReg(SISPART4, 0x30);
3054 ivideo->SiS_Pr.EMI_31 = SiS_GetReg(SISPART4, 0x31);
3055 ivideo->SiS_Pr.EMI_32 = SiS_GetReg(SISPART4, 0x32);
3056 ivideo->SiS_Pr.EMI_33 = SiS_GetReg(SISPART4, 0x33);
3057 ivideo->SiS_Pr.HaveEMI = true;
3058 if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) {
3059 ivideo->SiS_Pr.HaveEMILCD = true;
3065 if(ivideo->vbflags2 & VB2_30xBLV) {
3066 if((ivideo->SiS_Pr.PDC != -1) &&
3067 (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) {
3068 printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x (for LCD=CRT2)\n",
3069 ivideo->SiS_Pr.PDC);
3071 if((ivideo->SiS_Pr.PDCA != -1) &&
3072 (ivideo->SiS_Pr.PDCA != ivideo->detectedpdca)) {
3074 ivideo->SiS_Pr.PDCA);
3082 /* -------------------- Memory manager routines ---------------------- */
3086 u32 ret = ivideo->sisfb_parm_mem * 1024;
3087 u32 maxoffs = ivideo->video_size - ivideo->hwcursor_size - ivideo->cmdQueueSize;
3093 * C = console, D = heap, H = HWCursor, Q = cmd-queue
3103 * maximum = videosize - cmd_queue - hwcursor
3109 if(ivideo->sisvga_engine == SIS_300_VGA) {
3110 if(ivideo->video_size > 0x1000000) {
3112 } else if(ivideo->video_size > 0x800000) {
3117 } else if(ivideo->UMAsize && ivideo->LFBsize) {
3120 def = maxoffs - 0x8000;
3124 if((!ret) || (ret > maxoffs) || (ivideo->cardnumber != 0))
3132 u32 max = ivideo->video_size - ivideo->hwcursor_size - ivideo->cmdQueueSize;
3135 if(ivideo->UMAsize && ivideo->LFBsize) {
3136 if( (!ivideo->sisfb_parm_mem) ||
3137 ((ivideo->sisfb_parm_mem * 1024) > max) ||
3138 ((max - (ivideo->sisfb_parm_mem * 1024)) < ivideo->UMAsize) ) {
3139 ret = ivideo->UMAsize;
3140 max -= ivideo->UMAsize;
3142 ret = max - (ivideo->sisfb_parm_mem * 1024);
3143 max = ivideo->sisfb_parm_mem * 1024;
3145 ivideo->video_offset = ret;
3146 ivideo->sisfb_mem = max;
3148 ret = max - ivideo->heapstart;
3149 ivideo->sisfb_mem = ivideo->heapstart;
3159 ivideo->video_offset = 0;
3160 if(ivideo->sisfb_parm_mem) {
3161 if( (ivideo->sisfb_parm_mem < (2 * 1024 * 1024)) ||
3162 (ivideo->sisfb_parm_mem > ivideo->video_size) ) {
3163 ivideo->sisfb_parm_mem = 0;
3167 ivideo->heapstart = sisfb_getheapstart(ivideo);
3168 ivideo->sisfb_heap_size = sisfb_getheapsize(ivideo);
3170 ivideo->sisfb_heap_start = ivideo->video_vbase + ivideo->heapstart;
3171 ivideo->sisfb_heap_end = ivideo->sisfb_heap_start + ivideo->sisfb_heap_size;
3174 (int)(ivideo->heapstart / 1024), (int)(ivideo->sisfb_heap_size / 1024));
3176 ivideo->sisfb_heap.vinfo = ivideo;
3178 ivideo->sisfb_heap.poha_chain = NULL;
3179 ivideo->sisfb_heap.poh_freelist = NULL;
3181 poh = sisfb_poh_new_node(&ivideo->sisfb_heap);
3185 poh->poh_next = &ivideo->sisfb_heap.oh_free;
3186 poh->poh_prev = &ivideo->sisfb_heap.oh_free;
3187 poh->size = ivideo->sisfb_heap_size;
3188 poh->offset = ivideo->heapstart;
3190 ivideo->sisfb_heap.oh_free.poh_next = poh;
3191 ivideo->sisfb_heap.oh_free.poh_prev = poh;
3192 ivideo->sisfb_heap.oh_free.size = 0;
3193 ivideo->sisfb_heap.max_freesize = poh->size;
3195 ivideo->sisfb_heap.oh_used.poh_next = &ivideo->sisfb_heap.oh_used;
3196 ivideo->sisfb_heap.oh_used.poh_prev = &ivideo->sisfb_heap.oh_used;
3197 ivideo->sisfb_heap.oh_used.size = SENTINEL;
3199 if(ivideo->cardnumber == 0) {
3203 sisfb_heap = &ivideo->sisfb_heap;
3217 if(memheap->poh_freelist == NULL) {
3222 poha->poha_next = memheap->poha_chain;
3223 memheap->poha_chain = poha;
3225 cOhs = (SIS_OH_ALLOC_SIZE - sizeof(struct SIS_OHALLOC)) / sizeof(struct SIS_OH) + 1;
3227 poh = &poha->aoh[0];
3228 for(i = cOhs - 1; i != 0; i--) {
3229 poh->poh_next = poh + 1;
3233 poh->poh_next = NULL;
3234 memheap->poh_freelist = &poha->aoh[0];
3237 poh = memheap->poh_freelist;
3238 memheap->poh_freelist = poh->poh_next;
3250 if(size > memheap->max_freesize) {
3256 pohThis = memheap->oh_free.poh_next;
3258 while(pohThis != &memheap->oh_free) {
3259 if(size <= pohThis->size) {
3263 pohThis = pohThis->poh_next;
3272 if(size == pohThis->size) {
3280 pohRoot->offset = pohThis->offset;
3281 pohRoot->size = size;
3283 pohThis->offset += size;
3284 pohThis->size -= size;
3287 memheap->max_freesize -= size;
3289 pohThis = &memheap->oh_used;
3298 poh->poh_prev->poh_next = poh->poh_next;
3299 poh->poh_next->poh_prev = poh->poh_prev;
3305 struct SIS_OH *pohTemp = pohList->poh_next;
3307 pohList->poh_next = poh;
3308 pohTemp->poh_prev = poh;
3310 poh->poh_prev = pohList;
3311 poh->poh_next = pohTemp;
3325 poh_freed = memheap->oh_used.poh_next;
3327 while(poh_freed != &memheap->oh_used) {
3328 if(poh_freed->offset == base) {
3333 poh_freed = poh_freed->poh_next;
3339 memheap->max_freesize += poh_freed->size;
3342 ulUpper = poh_freed->offset + poh_freed->size;
3343 ulLower = poh_freed->offset;
3345 pohThis = memheap->oh_free.poh_next;
3347 while(pohThis != &memheap->oh_free) {
3348 if(pohThis->offset == ulUpper) {
3350 } else if((pohThis->offset + pohThis->size) == ulLower) {
3353 pohThis = pohThis->poh_next;
3359 poh_prev->size += (poh_freed->size + poh_next->size);
3367 poh_prev->size += poh_freed->size;
3373 poh_next->size += poh_freed->size;
3374 poh_next->offset = poh_freed->offset;
3379 sisfb_insert_node(&memheap->oh_free, poh_freed);
3390 poh->poh_next = memheap->poh_freelist;
3391 memheap->poh_freelist = poh;
3399 if((ivideo) && (ivideo->sisfb_id == SISFB_ID) && (!ivideo->havenoheap))
3400 poh = sisfb_poh_allocate(&ivideo->sisfb_heap, (u32)req->size);
3403 req->offset = req->size = 0;
3406 req->offset = poh->offset;
3407 req->size = poh->size;
3409 (poh->offset + ivideo->video_vbase));
3416 struct sis_video_info *ivideo = sisfb_heap->vinfo;
3418 if(&ivideo->sisfb_heap == sisfb_heap)
3421 req->offset = req->size = 0;
3431 if((!ivideo) || (ivideo->sisfb_id != SISFB_ID) || (ivideo->havenoheap))
3434 poh = sisfb_poh_free(&ivideo->sisfb_heap, base);
3445 struct sis_video_info *ivideo = sisfb_heap->vinfo;
3450 /* --------------------- SetMode routines ------------------------- */
3459 * ivideo->accel here, as this might have
3467 if(ivideo->sisvga_engine == SIS_300_VGA) {
3476 if(ivideo->sisvga_engine == SIS_315_VGA) {
3496 ivideo->currentvbflags &= (VB_VIDEOBRIDGE | VB_DISPTYPE_DISP2);
3504 cr33 = ivideo->rate_idx & 0x0F;
3507 if(ivideo->sisvga_engine == SIS_315_VGA) {
3508 if(ivideo->chip >= SIS_661) {
3519 if(ivideo->sisvga_engine == SIS_300_VGA) {
3525 SiS_SetEnableDstn(&ivideo->SiS_Pr, false);
3526 SiS_SetEnableFstn(&ivideo->SiS_Pr, false);
3527 ivideo->curFSTN = ivideo->curDSTN = 0;
3529 switch(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {
3532 cr38 &= ~0xc0; /* Clear PAL-M / PAL-N bits */
3533 if((ivideo->vbflags & TV_YPBPR) && (ivideo->vbflags2 & VB2_SISYPBPRBRIDGE)) {
3535 if(ivideo->chip >= SIS_661) {
3537 if(ivideo->vbflags & TV_YPBPR525P) cr35 |= 0x20;
3538 else if(ivideo->vbflags & TV_YPBPR750P) cr35 |= 0x40;
3539 else if(ivideo->vbflags & TV_YPBPR1080I) cr35 |= 0x60;
3542 ivideo->currentvbflags |= (TV_YPBPR | (ivideo->vbflags & TV_YPBPRALL));
3543 } else if(ivideo->sisvga_engine == SIS_315_VGA) {
3546 if(ivideo->vbflags & TV_YPBPR525P) cr38 |= 0x10;
3547 else if(ivideo->vbflags & TV_YPBPR750P) cr38 |= 0x20;
3548 else if(ivideo->vbflags & TV_YPBPR1080I) cr38 |= 0x30;
3550 ivideo->currentvbflags |= (TV_YPBPR | (ivideo->vbflags & TV_YPBPRALL));
3553 } else if((ivideo->vbflags & TV_HIVISION) &&
3554 (ivideo->vbflags2 & VB2_SISHIVISIONBRIDGE)) {
3555 if(ivideo->chip >= SIS_661) {
3564 ivideo->currentvbflags |= TV_HIVISION;
3565 } else if(ivideo->vbflags & TV_SCART) {
3569 ivideo->currentvbflags |= TV_SCART;
3571 if(ivideo->vbflags & TV_SVIDEO) {
3573 ivideo->currentvbflags |= TV_SVIDEO;
3575 if(ivideo->vbflags & TV_AVIDEO) {
3577 ivideo->currentvbflags |= TV_AVIDEO;
3582 if(ivideo->vbflags & (TV_AVIDEO | TV_SVIDEO)) {
3583 if(ivideo->vbflags & TV_PAL) {
3585 ivideo->currentvbflags |= TV_PAL;
3586 if(ivideo->vbflags & TV_PALM) {
3588 ivideo->currentvbflags |= TV_PALM;
3589 } else if(ivideo->vbflags & TV_PALN) {
3591 ivideo->currentvbflags |= TV_PALN;
3595 ivideo->currentvbflags |= TV_NTSC;
3596 if(ivideo->vbflags & TV_NTSCJ) {
3598 ivideo->currentvbflags |= TV_NTSCJ;
3607 SiS_SetEnableDstn(&ivideo->SiS_Pr, ivideo->sisfb_dstn);
3608 SiS_SetEnableFstn(&ivideo->SiS_Pr, ivideo->sisfb_fstn);
3609 ivideo->curFSTN = ivideo->sisfb_fstn;
3610 ivideo->curDSTN = ivideo->sisfb_dstn;
3616 if(ivideo->sisfb_nocrt2rate) {
3617 cr33 |= (sisbios_mode[ivideo->sisfb_mode_idx].rate_idx << 4);
3619 cr33 |= ((ivideo->rate_idx & 0x0F) << 4);
3631 if(ivideo->chip >= SIS_661) {
3638 } else if(ivideo->chip != SIS_300) {
3643 ivideo->SiS_Pr.SiS_UseOEM = ivideo->sisfb_useoem;
3655 if(ivideo->chip >= SIS_661) {
3674 if(val < -32) val = -32;
3675 ivideo->tvxpos = val;
3677 if(ivideo->sisfblocked) return;
3678 if(!ivideo->modechanged) return;
3680 if(ivideo->currentvbflags & CRT2_TV) {
3682 if(ivideo->vbflags2 & VB2_CHRONTEL) {
3684 int x = ivideo->tvx;
3686 switch(ivideo->chronteltype) {
3691 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0a, (x & 0xff));
3692 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((x & 0x0100) >> 7), 0xFD);
3699 } else if(ivideo->vbflags2 & VB2_SISBRIDGE) {
3704 p2_1f = ivideo->p2_1f;
3705 p2_20 = ivideo->p2_20;
3706 p2_2b = ivideo->p2_2b;
3707 p2_42 = ivideo->p2_42;
3708 p2_43 = ivideo->p2_43;
3732 if(val < -32) val = -32;
3733 ivideo->tvypos = val;
3735 if(ivideo->sisfblocked) return;
3736 if(!ivideo->modechanged) return;
3738 if(ivideo->currentvbflags & CRT2_TV) {
3740 if(ivideo->vbflags2 & VB2_CHRONTEL) {
3742 int y = ivideo->tvy;
3744 switch(ivideo->chronteltype) {
3746 y -= val;
3749 SiS_SetCH700x(&ivideo->SiS_Pr, 0x0b, (y & 0xff));
3750 SiS_SetCH70xxANDOR(&ivideo->SiS_Pr, 0x08, ((y & 0x0100) >> 8), 0xFE);
3757 } else if(ivideo->vbflags2 & VB2_SISBRIDGE) {
3761 p2_01 = ivideo->p2_01;
3762 p2_02 = ivideo->p2_02;
3766 if(!(ivideo->currentvbflags & (TV_HIVISION | TV_YPBPR))) {
3797 ivideo->modechanged = 1;
3800 if(ivideo->vbflags2 & VB2_VIDEOBRIDGE) {
3803 ivideo->sisfb_crt1off = 0;
3806 if(ivideo->sisvga_engine == SIS_300_VGA) {
3807 if((ivideo->sisfb_crt1off) && (doit)) {
3818 if(ivideo->sisvga_engine == SIS_315_VGA) {
3819 if((ivideo->sisfb_crt1off) && (doit)) {
3828 SiS_SetRegANDOR(SISCR, ivideo->SiS_Pr.SiS_MyCR63, ~0x40, reg);
3834 ivideo->currentvbflags &= ~VB_DISPTYPE_CRT1;
3835 ivideo->currentvbflags |= VB_SINGLE_MODE;
3837 ivideo->currentvbflags |= VB_DISPTYPE_CRT1;
3838 if(ivideo->currentvbflags & VB_DISPTYPE_CRT2) {
3839 ivideo->currentvbflags |= VB_MIRROR_MODE;
3841 ivideo->currentvbflags |= VB_SINGLE_MODE;
3847 if(ivideo->currentvbflags & CRT2_TV) {
3848 if(ivideo->vbflags2 & VB2_SISBRIDGE) {
3849 ivideo->p2_1f = SiS_GetReg(SISPART2, 0x1f);
3850 ivideo->p2_20 = SiS_GetReg(SISPART2, 0x20);
3851 ivideo->p2_2b = SiS_GetReg(SISPART2, 0x2b);
3852 ivideo->p2_42 = SiS_GetReg(SISPART2, 0x42);
3853 ivideo->p2_43 = SiS_GetReg(SISPART2, 0x43);
3854 ivideo->p2_01 = SiS_GetReg(SISPART2, 0x01);
3855 ivideo->p2_02 = SiS_GetReg(SISPART2, 0x02);
3856 } else if(ivideo->vbflags2 & VB2_CHRONTEL) {
3857 if(ivideo->chronteltype == 1) {
3858 ivideo->tvx = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0a);
3859 ivideo->tvx |= (((SiS_GetCH700x(&ivideo->SiS_Pr, 0x08) & 0x02) >> 1) << 8);
3860 ivideo->tvy = SiS_GetCH700x(&ivideo->SiS_Pr, 0x0b);
3861 ivideo->tvy |= ((SiS_GetCH700x(&ivideo->SiS_Pr, 0x08) & 0x01) << 8);
3866 if(ivideo->tvxpos) {
3867 sisfb_set_TVxposoffset(ivideo, ivideo->tvxpos);
3869 if(ivideo->tvypos) {
3870 sisfb_set_TVyposoffset(ivideo, ivideo->tvypos);
3876 /* (Re-)Initialize chip engines */
3877 if(ivideo->accel) {
3880 ivideo->engineok = 0;
3891 sisfb_set_base_CRT1(ivideo, ivideo->current_base);
3892 sisfb_set_base_CRT2(ivideo, ivideo->current_base);
3902 switch(sisfb_command->sisfb_cmd) {
3904 if(!ivideo->modechanged) {
3905 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_EARLY;
3907 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OK;
3908 sisfb_command->sisfb_result[1] = ivideo->currentvbflags;
3909 sisfb_command->sisfb_result[2] = ivideo->vbflags2;
3914 if(!ivideo->modechanged) {
3915 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_EARLY;
3916 } else if(sisfb_command->sisfb_arg[0] == 99) {
3918 sisfb_command->sisfb_result[1] = ivideo->sisfb_crt1off ? 0 : 1;
3919 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OK;
3920 } else if(ivideo->sisfblocked) {
3921 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_LOCKED;
3922 } else if((!(ivideo->currentvbflags & CRT2_ENABLE)) &&
3923 (sisfb_command->sisfb_arg[0] == 0)) {
3924 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_NOCRT2;
3926 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OK;
3927 mycrt1off = sisfb_command->sisfb_arg[0] ? 0 : 1;
3928 if( ((ivideo->currentvbflags & VB_DISPTYPE_CRT1) && mycrt1off) ||
3929 ((!(ivideo->currentvbflags & VB_DISPTYPE_CRT1)) && !mycrt1off) ) {
3930 ivideo->sisfb_crt1off = mycrt1off;
3932 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_OTHER;
3935 sisfb_command->sisfb_result[1] = ivideo->sisfb_crt1off ? 0 : 1;
3940 sisfb_command->sisfb_result[0] = SISFB_CMD_ERR_UNKNOWN;
3942 sisfb_command->sisfb_cmd);
3979 } else if(!strncasecmp(this_opt, "pdc:", 4)) {
3986 sisfb_accel = -1;
3990 sisfb_ypan = -1;
3994 sisfb_max = -1;
4010 if((temp >= -32) && (temp <= 32)) {
4016 if((temp >= -32) && (temp <= 32)) {
4055 if(romptr > (0x10000 - 8))
4064 if((readb(rom + 4) | (readb(rom + 5) << 8)) != ivideo->chip_vendor)
4067 if((readb(rom + 6) | (readb(rom + 7) << 8)) != ivideo->chip_id)
4084 if(!ivideo->nbridge) {
4138 ivideo->video_vbase = ioremap_wc(ivideo->video_base, (*mapsize));
4140 if(!ivideo->video_vbase) {
4144 while((!(ivideo->video_vbase = ioremap_wc(ivideo->video_base, (*mapsize))))) {
4149 if(ivideo->video_vbase) {
4160 void __iomem *FBAddress = ivideo->video_vbase;
4227 void __iomem *FBAddr = ivideo->video_vbase;
4241 BankNumHigh = RankCapacity * 16 * iteration - 1;
4243 BankNumMid = RankCapacity * 16 - 1;
4245 BankNumMid = RankCapacity * 16 * iteration / 2 - 1;
4255 sr14 = (SiS_DRAMType[k][3] * buswidth) - 1;
4300 for(i = 6; i >= 0; i--) {
4302 for(j = 4; j >= 1; j--) {
4303 PseudoAdrPinCount = 15 - j;
4320 unsigned char *bios = ivideo->SiS_Pr.VirtualRomBase;
4325 if(!ivideo->SiS_Pr.UseROM)
4340 if(ivideo->revision_id <= 0x13) {
4385 if(ivideo->revision_id >= 0x80)
4394 SiS_SetReg(SISSR, 0x1c, v8); /* ---- */
4403 if(ivideo->revision_id >= 0x80)
4428 if(ivideo->revision_id >= 0x80)
4436 if (ivideo->SiS_Pr.UseROM && bios) {
4466 reg = ((sisfb_videoram >> 10) - 1) | 0x40;
4471 mapsize = ivideo->video_size;
4474 if(ivideo->video_vbase) {
4476 iounmap(ivideo->video_vbase);
4506 ivideo->SiS_Pr.SiS_UseOEM = false;
4507 SiS_SetEnableDstn(&ivideo->SiS_Pr, false);
4508 SiS_SetEnableFstn(&ivideo->SiS_Pr, false);
4509 ivideo->curFSTN = ivideo->curDSTN = 0;
4510 ivideo->SiS_Pr.VideoMemorySize = 8 << 20;
4511 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80);
4522 ivideo->modeprechange = 0x2e;
4536 return ivideo->chip_real_id == XGI_21;
4559 temp = pdev->vendor;
4576 writel(0, ivideo->video_vbase);
4581 writel(pos, ivideo->video_vbase + pos);
4586 if(readl(ivideo->video_vbase) != 0)
4592 if(readl(ivideo->video_vbase + pos) != pos)
4629 * - if running on x86, if the card is disabled, it means
4632 * - if running on non-x86, there usually is no VGA window
4638 mapsize = ivideo->video_size;
4641 if(!ivideo->video_vbase) {
4646 return -ENOMEM;
4649 /* Non-interleaving */
4654 if(ivideo->chip == XGI_20) {
4718 if(ivideo->revision_id == 2) {
4774 if(ivideo->revision_id == 2) {
4806 j = (ivideo->chip == XGI_20) ? 5 : 9;
4807 k = (ivideo->chip == XGI_20) ? 12 : 4;
4808 status = -EIO;
4812 reg = (ivideo->chip == XGI_20) ?
4817 ranksize = (ivideo->chip == XGI_20) ?
4823 if(ivideo->chip == XGI_20) {
4842 if (sisfb_post_xgi_rwtest(ivideo, j, ((reg >> 4) + channelab - 2 + 20), mapsize)) {
4848 iounmap(ivideo->video_vbase);
4882 if(ivideo->haveXGIROM) {
4883 v1 = ivideo->bios_abase[0x90 + index];
4884 v2 = ivideo->bios_abase[0x90 + index + 1];
4885 v3 = ivideo->bios_abase[0x90 + index + 2];
4895 if(ivideo->haveXGIROM) {
4896 v1 = ivideo->bios_abase[0xb8 + index];
4897 v2 = ivideo->bios_abase[0xb8 + index + 1];
4898 v3 = ivideo->bios_abase[0xb8 + index + 2];
4911 unsigned char *bios = ivideo->bios_abase;
4939 if (ivideo->haveXGIROM) {
4992 unsigned char *bios = ivideo->bios_abase;
5013 if (ivideo->haveXGIROM) {
5036 unsigned char *bios = ivideo->bios_abase;
5042 if (ivideo->haveXGIROM) {
5053 } else if (ivideo->chip == XGI_20) {
5076 unsigned char *bios = ivideo->bios_abase;
5165 if(ivideo->haveXGIROM) {
5173 if(ivideo->haveXGIROM) {
5181 if(ivideo->haveXGIROM) {
5193 if(ivideo->haveXGIROM) {
5200 if(ivideo->chip == XGI_40) {
5201 if(ivideo->revision_id == 2) {
5207 if(ivideo->revision_id == 0) { /* 40 *and* 20? */
5215 reg = (ivideo->chip == XGI_40) ? 0x20 : 0x00;
5218 if(ivideo->chip == XGI_20) {
5298 if(ivideo->revision_id == 2) {
5364 dev_warn(&pdev->dev,
5373 if(ivideo->haveXGIROM) {
5379 if(ivideo->haveXGIROM) {
5388 if(ivideo->haveXGIROM) {
5389 index = (ivideo->chip == XGI_20) ? 0x31a : 0x3a6;
5417 if(ivideo->haveXGIROM) {
5418 index = (ivideo->chip == XGI_20) ? 0x35a : 0x3e6;
5445 if(ivideo->haveXGIROM) {
5455 if(ivideo->haveXGIROM) {
5456 index = (ivideo->chip == XGI_20) ? 0x45a : 0x4e6;
5473 if(ivideo->haveXGIROM) {
5485 if(ivideo->haveXGIROM) {
5495 if(ivideo->haveXGIROM) {
5503 if(ivideo->haveXGIROM) {
5515 if(ivideo->chip == XGI_40) {
5516 if( (ivideo->revision_id == 1) ||
5517 (ivideo->revision_id == 2) ) {
5528 if(ivideo->chip == XGI_20) {
5536 if((ivideo->chip == XGI_20) ||
5537 (ivideo->revision_id == 1) ||
5538 (ivideo->revision_id == 2)) {
5540 if(ivideo->haveXGIROM) {
5563 if(ivideo->chip == XGI_40) {
5570 if((ivideo->chip == XGI_20) ||
5571 (ivideo->revision_id == 2)) {
5578 if((ivideo->chip == XGI_20) || (bios[0x1cb] != 0x0c)) {
5583 if((ivideo->chip == XGI_20) ||
5584 (ivideo->revision_id == 2)) {
5589 } else if((ivideo->chip == XGI_40) && (bios[0x1cb] == 0x0c)) {
5596 if(ivideo->haveXGIROM) {
5598 index = (ivideo->chip == XGI_20) ? 0x4b2 : 0x53e;
5605 SiS_SetReg(SISSR, 0x19, ((ivideo->chip == XGI_20) ? 0x02 : 0x01));
5622 if((ivideo->chip == XGI_40) &&
5623 ((ivideo->revision_id == 1) ||
5624 (ivideo->revision_id == 2))) {
5639 if(ivideo->haveXGIROM) {
5646 if(ivideo->chip == XGI_40) {
5649 if((ivideo->chip == XGI_40) && (ivideo->revision_id == 2)) {
5656 if(ivideo->chip == XGI_40) {
5664 if((ivideo->chip == XGI_40) && (bios[0x1cb] != 0x0c)) {
5675 if(ivideo->haveXGIROM) {
5680 if(ivideo->chip == XGI_40) {
5688 if(ivideo->chip == XGI_40) {
5696 if(ivideo->chip == XGI_40) {
5708 if(ivideo->haveXGIROM) {
5715 if(ivideo->haveXGIROM) {
5721 if((v1 & 0x40) && (v2 & regd) && ivideo->haveXGIROM) {
5730 ivideo->SiS_Pr.SiS_UseOEM = false;
5731 SiS_SetEnableDstn(&ivideo->SiS_Pr, false);
5732 SiS_SetEnableFstn(&ivideo->SiS_Pr, false);
5733 ivideo->curFSTN = ivideo->curDSTN = 0;
5734 ivideo->SiS_Pr.VideoMemorySize = 8 << 20;
5735 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80);
5739 /* Disable read-cache */
5742 /* Enable read-cache */
5746 dev_err(&pdev->dev,
5754 printk(KERN_DEBUG "-----------------\n");
5763 printk(KERN_DEBUG "-----------------\n");
5767 if(ivideo->chip == XGI_20) {
5779 ivideo->SiS_Pr.SiS_UseOEM = false;
5780 SiS_SetEnableDstn(&ivideo->SiS_Pr, false);
5781 SiS_SetEnableFstn(&ivideo->SiS_Pr, false);
5782 ivideo->curFSTN = ivideo->curDSTN = 0;
5783 SiSSetMode(&ivideo->SiS_Pr, 0x2e | 0x80);
5794 ivideo->modeprechange = 0x2e;
5796 if(ivideo->chip == XGI_40) {
5812 struct sisfb_chip_info *chipinfo = &sisfb_chip_info[ent->driver_data];
5820 return -ENXIO;
5826 sis_fb_info = framebuffer_alloc(sizeof(*ivideo), &pdev->dev);
5828 return -ENOMEM;
5830 ivideo = (struct sis_video_info *)sis_fb_info->par;
5831 ivideo->memyselfandi = sis_fb_info;
5833 ivideo->sisfb_id = SISFB_ID;
5836 ivideo->cardnumber = 0;
5839 ivideo->cardnumber = 1;
5840 while((countvideo = countvideo->next) != NULL)
5841 ivideo->cardnumber++;
5844 strscpy(ivideo->myid, chipinfo->chip_name, sizeof(ivideo->myid));
5846 ivideo->warncount = 0;
5847 ivideo->chip_id = pdev->device;
5848 ivideo->chip_vendor = pdev->vendor;
5849 ivideo->revision_id = pdev->revision;
5850 ivideo->SiS_Pr.ChipRevision = ivideo->revision_id;
5852 ivideo->sisvga_enabled = reg16 & 0x01;
5853 ivideo->pcibus = pdev->bus->number;
5854 ivideo->pcislot = PCI_SLOT(pdev->devfn);
5855 ivideo->pcifunc = PCI_FUNC(pdev->devfn);
5856 ivideo->subsysvendor = pdev->subsystem_vendor;
5857 ivideo->subsysdevice = pdev->subsystem_device;
5859 ivideo->chip = chipinfo->chip;
5860 ivideo->chip_real_id = chipinfo->chip;
5861 ivideo->sisvga_engine = chipinfo->vgaengine;
5862 ivideo->hwcursor_size = chipinfo->hwcursor_size;
5863 ivideo->CRT2_write_enable = chipinfo->CRT2_write_enable;
5864 ivideo->mni = chipinfo->mni;
5866 ivideo->detectedpdc = 0xff;
5867 ivideo->detectedpdca = 0xff;
5868 ivideo->detectedlcda = 0xff;
5870 ivideo->sisfb_thismonitor.datavalid = false;
5872 ivideo->current_base = 0;
5874 ivideo->engineok = 0;
5876 ivideo->sisfb_was_boot_device = 0;
5878 if(pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) {
5879 if(ivideo->sisvga_enabled)
5880 ivideo->sisfb_was_boot_device = 1;
5889 ivideo->sisfb_parm_mem = sisfb_parm_mem;
5890 ivideo->sisfb_accel = sisfb_accel;
5891 ivideo->sisfb_ypan = sisfb_ypan;
5892 ivideo->sisfb_max = sisfb_max;
5893 ivideo->sisfb_userom = sisfb_userom;
5894 ivideo->sisfb_useoem = sisfb_useoem;
5895 ivideo->sisfb_mode_idx = sisfb_mode_idx;
5896 ivideo->sisfb_parm_rate = sisfb_parm_rate;
5897 ivideo->sisfb_crt1off = sisfb_crt1off;
5898 ivideo->sisfb_forcecrt1 = sisfb_forcecrt1;
5899 ivideo->sisfb_crt2type = sisfb_crt2type;
5900 ivideo->sisfb_crt2flags = sisfb_crt2flags;
5901 /* pdc(a), scalelcd, special timing, lvdshl handled below */
5902 ivideo->sisfb_dstn = sisfb_dstn;
5903 ivideo->sisfb_fstn = sisfb_fstn;
5904 ivideo->sisfb_tvplug = sisfb_tvplug;
5905 ivideo->sisfb_tvstd = sisfb_tvstd;
5906 ivideo->tvxpos = sisfb_tvxposoffset;
5907 ivideo->tvypos = sisfb_tvyposoffset;
5908 ivideo->sisfb_nocrt2rate = sisfb_nocrt2rate;
5909 ivideo->refresh_rate = 0;
5910 if(ivideo->sisfb_parm_rate != -1) {
5911 ivideo->refresh_rate = ivideo->sisfb_parm_rate;
5914 ivideo->SiS_Pr.UsePanelScaler = sisfb_scalelcd;
5915 ivideo->SiS_Pr.CenterScreen = -1;
5916 ivideo->SiS_Pr.SiS_CustomT = sisfb_specialtiming;
5917 ivideo->SiS_Pr.LVDSHL = sisfb_lvdshl;
5919 ivideo->SiS_Pr.SiS_Backup70xx = 0xff;
5920 ivideo->SiS_Pr.SiS_CHOverScan = -1;
5921 ivideo->SiS_Pr.SiS_ChSW = false;
5922 ivideo->SiS_Pr.SiS_UseLCDA = false;
5923 ivideo->SiS_Pr.HaveEMI = false;
5924 ivideo->SiS_Pr.HaveEMILCD = false;
5925 ivideo->SiS_Pr.OverruleEMI = false;
5926 ivideo->SiS_Pr.SiS_SensibleSR11 = false;
5927 ivideo->SiS_Pr.SiS_MyCR63 = 0x63;
5928 ivideo->SiS_Pr.PDC = -1;
5929 ivideo->SiS_Pr.PDCA = -1;
5930 ivideo->SiS_Pr.DDCPortMixup = false;
5932 if(ivideo->chip >= SIS_330) {
5933 ivideo->SiS_Pr.SiS_MyCR63 = 0x53;
5934 if(ivideo->chip >= SIS_661) {
5935 ivideo->SiS_Pr.SiS_SensibleSR11 = true;
5940 memcpy(&ivideo->default_var, &my_default_var, sizeof(my_default_var));
5945 if((ivideo->nbridge = sisfb_get_northbridge(ivideo->chip))) {
5946 switch(ivideo->nbridge->device) {
5949 ivideo->chip = SIS_730;
5950 strcpy(ivideo->myid, "SiS 730");
5955 /* ivideo->chip is ok */
5956 strcpy(ivideo->myid, "SiS 651");
5959 ivideo->chip = SIS_740;
5960 strcpy(ivideo->myid, "SiS 740");
5963 ivideo->chip = SIS_661;
5964 strcpy(ivideo->myid, "SiS 661");
5967 ivideo->chip = SIS_741;
5968 strcpy(ivideo->myid, "SiS 741");
5971 ivideo->chip = SIS_760;
5972 strcpy(ivideo->myid, "SiS 760");
5975 ivideo->chip = SIS_761;
5976 strcpy(ivideo->myid, "SiS 761");
5984 ivideo->SiS_Pr.ChipType = ivideo->chip;
5986 ivideo->SiS_Pr.ivideo = (void *)ivideo;
5989 if((ivideo->SiS_Pr.ChipType == SIS_315PRO) ||
5990 (ivideo->SiS_Pr.ChipType == SIS_315)) {
5991 ivideo->SiS_Pr.ChipType = SIS_315H;
5995 if(!ivideo->sisvga_enabled) {
5997 pci_dev_put(ivideo->nbridge);
5999 return -EIO;
6003 ivideo->video_base = pci_resource_start(pdev, 0);
6004 ivideo->video_size = pci_resource_len(pdev, 0);
6005 ivideo->mmio_base = pci_resource_start(pdev, 1);
6006 ivideo->mmio_size = pci_resource_len(pdev, 1);
6007 ivideo->SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30;
6008 ivideo->SiS_Pr.IOAddress = ivideo->vga_base = ivideo->SiS_Pr.RelIO;
6010 SiSRegInit(&ivideo->SiS_Pr, ivideo->SiS_Pr.IOAddress);
6014 if(ivideo->chip == SIS_630) {
6017 if(mychswtable[i].subsysVendor == ivideo->subsysvendor &&
6018 mychswtable[i].subsysCard == ivideo->subsysdevice) {
6019 ivideo->SiS_Pr.SiS_ChSW = true;
6024 ivideo->lpcdev = pci_get_device(PCI_VENDOR_ID_SI, 0x0008, NULL);
6033 if((ivideo->chip == SIS_760) && (ivideo->nbridge)) {
6034 ivideo->lpcdev = pci_get_slot(ivideo->nbridge->bus, (2 << 3));
6040 if( (!ivideo->sisvga_enabled)
6051 ivideo->modeprechange = 0x03;
6054 ivideo->modeprechange = reg & 0x7f;
6055 } else if(ivideo->sisvga_enabled) {
6059 ivideo->modeprechange = readb(tt + 0x49);
6066 ivideo->bios_abase = NULL;
6067 ivideo->SiS_Pr.VirtualRomBase = NULL;
6068 ivideo->SiS_Pr.UseROM = false;
6069 ivideo->haveXGIROM = ivideo->SiS_Pr.SiS_XGIROM = false;
6070 if(ivideo->sisfb_userom) {
6071 ivideo->SiS_Pr.VirtualRomBase = sisfb_find_rom(pdev);
6072 ivideo->bios_abase = ivideo->SiS_Pr.VirtualRomBase;
6073 ivideo->SiS_Pr.UseROM = (bool)(ivideo->SiS_Pr.VirtualRomBase);
6075 ivideo->SiS_Pr.UseROM ? "" : "not ");
6076 if((ivideo->SiS_Pr.UseROM) && (ivideo->chip >= XGI_20)) {
6077 ivideo->SiS_Pr.UseROM = false;
6078 ivideo->haveXGIROM = ivideo->SiS_Pr.SiS_XGIROM = true;
6079 if( (ivideo->revision_id == 2) &&
6080 (!(ivideo->bios_abase[0x1d1] & 0x01)) ) {
6081 ivideo->SiS_Pr.DDCPortMixup = true;
6089 if(ivideo->SiS_Pr.SiS_CustomT == CUT_NONE) {
6094 if (ivideo->chip == XGI_20) {
6099 ivideo->chip_real_id = XGI_21;
6100 dev_info(&pdev->dev, "Z9 detected\n");
6106 if( (!ivideo->sisvga_enabled)
6112 if(ivideo->sisvga_engine == SIS_300_VGA) {
6113 if(ivideo->chip == SIS_300) {
6115 ivideo->sisfb_can_post = 1;
6121 if (ivideo->sisvga_engine == SIS_315_VGA) {
6124 if (ivideo->chip == XGI_20) {
6126 ivideo->sisfb_can_post = 1;
6127 } else if ((ivideo->chip == XGI_40) && ivideo->haveXGIROM) {
6129 ivideo->sisfb_can_post = 1;
6136 ret = -ENODEV;
6143 ivideo->sisfb_card_posted = 1;
6148 ret = -ENODEV;
6154 if((ivideo->sisfb_mode_idx < 0) ||
6155 ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) {
6163 if(ivideo->sisvga_engine == SIS_300_VGA)
6167 ivideo->SiS_Pr.PDC = sisfb_pdc;
6170 if(ivideo->sisvga_engine == SIS_315_VGA) {
6172 ivideo->SiS_Pr.PDCA = sisfb_pdca & 0x1f;
6176 if(!request_mem_region(ivideo->video_base, ivideo->video_size, "sisfb FB")) {
6178 (int)(ivideo->video_size >> 20));
6180 ret = -ENODEV;
6184 if(!request_mem_region(ivideo->mmio_base, ivideo->mmio_size, "sisfb MMIO")) {
6186 ret = -ENODEV;
6190 ivideo->video_vbase = ioremap_wc(ivideo->video_base, ivideo->video_size);
6191 ivideo->SiS_Pr.VideoMemoryAddress = ivideo->video_vbase;
6192 if(!ivideo->video_vbase) {
6194 ret = -ENODEV;
6198 ivideo->mmio_vbase = ioremap(ivideo->mmio_base, ivideo->mmio_size);
6199 if(!ivideo->mmio_vbase) {
6201 ret = -ENODEV;
6202 error_0: iounmap(ivideo->video_vbase);
6203 error_1: release_mem_region(ivideo->video_base, ivideo->video_size);
6204 error_2: release_mem_region(ivideo->mmio_base, ivideo->mmio_size);
6205 error_3: vfree(ivideo->bios_abase);
6206 pci_dev_put(ivideo->lpcdev);
6207 pci_dev_put(ivideo->nbridge);
6208 if(!ivideo->sisvga_enabled)
6215 ivideo->video_base, (unsigned long)ivideo->video_vbase, ivideo->video_size / 1024);
6217 if(ivideo->video_offset) {
6219 ivideo->video_offset / 1024);
6223 ivideo->mmio_base, (unsigned long)ivideo->mmio_vbase, ivideo->mmio_size / 1024);
6227 if(ivideo->sisvga_engine == SIS_300_VGA) {
6228 ivideo->cmdQueueSize = TURBO_QUEUE_AREA_SIZE;
6230 if(ivideo->chip == XGI_20) {
6231 ivideo->cmdQueueSize = COMMAND_QUEUE_AREA_SIZE_Z7;
6233 ivideo->cmdQueueSize = COMMAND_QUEUE_AREA_SIZE;
6238 * now done after the first mode-switch (if the
6243 ivideo->hwcursor_vbase = ivideo->video_vbase
6244 + ivideo->video_size
6245 - ivideo->cmdQueueSize
6246 - ivideo->hwcursor_size;
6247 ivideo->caps |= HW_CURSOR_CAP;
6250 if((ivideo->havenoheap = sisfb_heap_init(ivideo))) {
6255 ivideo->SiS_Pr.VideoMemoryAddress += ivideo->video_offset;
6256 ivideo->SiS_Pr.VideoMemorySize = ivideo->sisfb_mem;
6258 ivideo->vbflags = 0;
6259 ivideo->lcddefmodeidx = DEFAULT_LCDMODE;
6260 ivideo->tvdefmodeidx = DEFAULT_TVMODE;
6261 ivideo->defmodeidx = DEFAULT_MODE;
6263 ivideo->newrom = 0;
6264 if(ivideo->chip < XGI_20) {
6265 if(ivideo->bios_abase) {
6266 ivideo->newrom = SiSDetermineROMLayout661(&ivideo->SiS_Pr);
6270 if((ivideo->sisfb_mode_idx < 0) ||
6271 ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) {
6277 if(ivideo->vbflags2 & VB2_VIDEOBRIDGE) {
6281 ivideo->currentvbflags = ivideo->vbflags & (VB_VIDEOBRIDGE | TV_STANDARD);
6284 if(ivideo->vbflags2 & VB2_VIDEOBRIDGE) {
6285 if(ivideo->sisfb_crt2type != -1) {
6286 if((ivideo->sisfb_crt2type == CRT2_LCD) &&
6287 (ivideo->vbflags & CRT2_LCD)) {
6288 ivideo->currentvbflags |= CRT2_LCD;
6289 } else if(ivideo->sisfb_crt2type != CRT2_LCD) {
6290 ivideo->currentvbflags |= ivideo->sisfb_crt2type;
6296 if((ivideo->sisvga_engine == SIS_300_VGA) &&
6297 (ivideo->vbflags2 & VB2_CHRONTEL)) {
6298 if(ivideo->vbflags & CRT2_LCD)
6299 ivideo->currentvbflags |= CRT2_LCD;
6300 else if(ivideo->vbflags & CRT2_TV)
6301 ivideo->currentvbflags |= CRT2_TV;
6302 else if(ivideo->vbflags & CRT2_VGA)
6303 ivideo->currentvbflags |= CRT2_VGA;
6305 if(ivideo->vbflags & CRT2_TV)
6306 ivideo->currentvbflags |= CRT2_TV;
6307 else if(ivideo->vbflags & CRT2_LCD)
6308 ivideo->currentvbflags |= CRT2_LCD;
6309 else if(ivideo->vbflags & CRT2_VGA)
6310 ivideo->currentvbflags |= CRT2_VGA;
6315 if(ivideo->vbflags & CRT2_LCD) {
6321 if(!ivideo->sisfb_crt1off) {
6322 sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 0);
6324 if((ivideo->vbflags2 & VB2_SISTMDSBRIDGE) &&
6325 (ivideo->vbflags & (CRT2_VGA | CRT2_LCD))) {
6326 sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 1);
6330 if(ivideo->sisfb_mode_idx >= 0) {
6331 int bu = ivideo->sisfb_mode_idx;
6332 ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo,
6333 ivideo->sisfb_mode_idx, ivideo->currentvbflags);
6334 if(bu != ivideo->sisfb_mode_idx) {
6342 if(ivideo->sisfb_mode_idx < 0) {
6343 switch(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {
6345 ivideo->sisfb_mode_idx = ivideo->lcddefmodeidx;
6348 ivideo->sisfb_mode_idx = ivideo->tvdefmodeidx;
6351 ivideo->sisfb_mode_idx = ivideo->defmodeidx;
6356 ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];
6358 if(ivideo->refresh_rate != 0) {
6359 sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate,
6360 ivideo->sisfb_mode_idx);
6363 if(ivideo->rate_idx == 0) {
6364 ivideo->rate_idx = sisbios_mode[ivideo->sisfb_mode_idx].rate_idx;
6365 ivideo->refresh_rate = 60;
6368 if(ivideo->sisfb_thismonitor.datavalid) {
6369 if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor,
6370 ivideo->sisfb_mode_idx,
6371 ivideo->rate_idx,
6372 ivideo->refresh_rate)) {
6378 ivideo->video_bpp = sisbios_mode[ivideo->sisfb_mode_idx].bpp;
6379 ivideo->video_width = sisbios_mode[ivideo->sisfb_mode_idx].xres;
6380 ivideo->video_height = sisbios_mode[ivideo->sisfb_mode_idx].yres;
6385 ivideo->video_width, ivideo->video_height, ivideo->video_bpp,
6386 ivideo->refresh_rate);
6389 ivideo->default_var.xres = ivideo->default_var.xres_virtual = ivideo->video_width;
6390 ivideo->default_var.yres = ivideo->default_var.yres_virtual = ivideo->video_height;
6391 ivideo->default_var.bits_per_pixel = ivideo->video_bpp;
6393 sisfb_bpp_to_var(ivideo, &ivideo->default_var);
6395 ivideo->default_var.pixclock = (u32) (1000000000 /
6396 sisfb_mode_rate_to_dclock(&ivideo->SiS_Pr, ivideo->mode_no, ivideo->rate_idx));
6398 if(sisfb_mode_rate_to_ddata(&ivideo->SiS_Pr, ivideo->mode_no,
6399 ivideo->rate_idx, &ivideo->default_var)) {
6400 if((ivideo->default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {
6401 ivideo->default_var.pixclock <<= 1;
6405 if(ivideo->sisfb_ypan) {
6407 ivideo->default_var.yres_virtual =
6408 sisfb_calc_maxyres(ivideo, &ivideo->default_var);
6409 if(ivideo->default_var.yres_virtual < ivideo->default_var.yres) {
6410 ivideo->default_var.yres_virtual = ivideo->default_var.yres;
6414 sisfb_calc_pitch(ivideo, &ivideo->default_var);
6416 ivideo->accel = 0;
6417 if(ivideo->sisfb_accel) {
6418 ivideo->accel = -1;
6420 ivideo->default_var.accel_flags |= FB_ACCELF_TEXT;
6426 sis_fb_info->flags = FBINFO_HWACCEL_YPAN |
6430 ((ivideo->accel) ? 0 : FBINFO_HWACCEL_DISABLED);
6432 sis_fb_info->var = ivideo->default_var;
6433 sis_fb_info->fix = ivideo->sisfb_fix;
6434 sis_fb_info->screen_base = ivideo->video_vbase + ivideo->video_offset;
6435 sis_fb_info->fbops = &sisfb_ops;
6436 sis_fb_info->pseudo_palette = ivideo->pseudo_palette;
6438 fb_alloc_cmap(&sis_fb_info->cmap, 256 , 0);
6440 printk(KERN_DEBUG "sisfb: Initial vbflags 0x%x\n", (int)ivideo->vbflags);
6442 ivideo->wc_cookie = arch_phys_wc_add(ivideo->video_base,
6443 ivideo->video_size);
6446 ret = -EINVAL;
6447 iounmap(ivideo->mmio_vbase);
6451 ivideo->registered = 1;
6454 ivideo->next = card_list;
6457 printk(KERN_INFO "sisfb: 2D acceleration is %s, y-panning %s\n",
6458 ivideo->sisfb_accel ? "enabled" : "disabled",
6459 ivideo->sisfb_ypan ?
6460 (ivideo->sisfb_max ? "enabled (auto-max)" :
6461 "enabled (no auto-max)") :
6466 ivideo->myid, VER_MAJOR, VER_MINOR, VER_LEVEL);
6468 printk(KERN_INFO "sisfb: Copyright (C) 2001-2005 Thomas Winischhofer\n");
6482 struct fb_info *sis_fb_info = ivideo->memyselfandi;
6483 int registered = ivideo->registered;
6484 int modechanged = ivideo->modechanged;
6487 iounmap(ivideo->mmio_vbase);
6488 iounmap(ivideo->video_vbase);
6491 release_mem_region(ivideo->video_base, ivideo->video_size);
6492 release_mem_region(ivideo->mmio_base, ivideo->mmio_size);
6494 vfree(ivideo->bios_abase);
6496 pci_dev_put(ivideo->lpcdev);
6498 pci_dev_put(ivideo->nbridge);
6500 arch_phys_wc_del(ivideo->wc_cookie);
6505 if(!ivideo->sisvga_enabled)
6509 if(ivideo->registered) {
6542 return -ENODEV;
6546 return -ENODEV;
6564 static int vesa = -1;
6569 static int forcecrt1 = -1;
6570 static int pdc = -1;
6571 static int pdc1 = -1;
6572 static int noaccel = -1;
6573 static int noypan = -1;
6574 static int nomax = -1;
6575 static int userom = -1;
6576 static int useoem = -1;
6579 static int scalelcd = -1;
6581 static int lvdshl = -1;
6608 else if(vesa != -1)
6637 if(userom != -1)
6640 if(useoem != -1)
6643 if(pdc != -1)
6644 sisfb_pdc = (pdc & 0x7f);
6646 if(pdc1 != -1)
6694 module_param(pdc, int, 0);
6720 "\nIf set to anything other than 0, y-panning will be disabled and scrolling\n"
6724 "\nIf y-panning is enabled, sisfb will by default use the entire available video\n"
6732 "eg. 1024x768x16. Other formats supported include XxY-Depth and\n"
6733 "XxY-Depth@Rate. If the parameter is only one (decimal or hexadecimal)\n"
6742 "If the mode is specified in the format XxY-Depth@Rate, this parameter\n"
6766 MODULE_PARM_DESC(pdc,
6776 "\nThis is same as pdc, but for LCD-via CRT1. Hence, this is for the 315/330/340\n"
6777 "series only. (default: autodetected if LCD is in LCD-via-CRT1 mode during\n"
6778 "startup) - Note: currently, this has no effect because LCD-via-CRT1 is not\n"
6793 "\nRelocate TV output horizontally. Possible parameters: -32 through 32.\n"
6797 "\nRelocate TV output vertically. Possible parameters: -32 through 32.\n"
6807 "\nSet this to 1 in order to reset (POST) the card on non-x86 machines where\n"
6813 "some non-x86 architectures where the memory auto detection fails. Only\n"
6814 "relevant if resetcard is set, too. SiS300/305 only. Default: [auto-detect]\n");