ivideo->sisfb_filter = sisfb_filter; 
static int __devinit sisfb_probe(struct pci_dev *pdev,				 const struct pci_device_id *ent){	struct sisfb_chip_info 	*chipinfo = &sisfb_chip_info[ent->driver_data];	struct sis_video_info 	*ivideo = NULL;	struct fb_info 		*sis_fb_info = NULL;	u16 reg16;	u8  reg;	int sisvga_enabled = 0, i;	if(sisfb_off) return -ENXIO;#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,3))	sis_fb_info = framebuffer_alloc(sizeof(*ivideo), &pdev->dev);	if(!sis_fb_info) return -ENOMEM;#else	sis_fb_info = kmalloc(sizeof(*sis_fb_info) + sizeof(*ivideo), GFP_KERNEL);	if(!sis_fb_info) return -ENOMEM;	memset(sis_fb_info, 0, sizeof(*sis_fb_info) + sizeof(*ivideo));	sis_fb_info->par = ((char *)sis_fb_info + sizeof(*sis_fb_info));#endif	ivideo = (struct sis_video_info *)sis_fb_info->par;	ivideo->memyselfandi = sis_fb_info;	if(card_list == NULL) {	   ivideo->cardnumber = 0;	} else {	   struct sis_video_info *countvideo = card_list;	   ivideo->cardnumber = 1;	   while((countvideo = countvideo->next) != NULL) ivideo->cardnumber++;	}	strncpy(ivideo->myid, chipinfo->chip_name, 30);	ivideo->warncount = 0;	ivideo->chip_id = pdev->device;	pci_read_config_byte(pdev, PCI_REVISION_ID, &ivideo->revision_id);	ivideo->sishw_ext.jChipRevision = ivideo->revision_id;	pci_read_config_word(pdev, PCI_COMMAND, &reg16);	sisvga_enabled = reg16 & 0x01;	ivideo->pcibus = pdev->bus->number;	ivideo->pcislot = PCI_SLOT(pdev->devfn);	ivideo->pcifunc = PCI_FUNC(pdev->devfn);	ivideo->subsysvendor = pdev->subsystem_vendor;	ivideo->subsysdevice = pdev->subsystem_device;#ifndef MODULE	if(sisfb_mode_idx == -1) {		sisfb_get_vga_mode_from_kernel();	}#endif	ivideo->chip = chipinfo->chip;	ivideo->sisvga_engine = chipinfo->vgaengine;	ivideo->hwcursor_size = chipinfo->hwcursor_size;	ivideo->CRT2_write_enable = chipinfo->CRT2_write_enable;	ivideo->mni = chipinfo->mni;	ivideo->detectedpdc  = 0xff;	ivideo->detectedpdca = 0xff;	ivideo->detectedlcda = 0xff;	ivideo->sisfb_thismonitor.datavalid = FALSE;	ivideo->sisfb_parm_mem = sisfb_parm_mem;	ivideo->sisfb_accel = sisfb_accel;	ivideo->sisfb_ypan = sisfb_ypan;	ivideo->sisfb_max = sisfb_max;	ivideo->sisfb_userom = sisfb_userom;	ivideo->sisfb_useoem = sisfb_useoem;	ivideo->sisfb_mode_idx = sisfb_mode_idx;	ivideo->sisfb_parm_rate = sisfb_parm_rate;	ivideo->sisfb_crt1off = sisfb_crt1off;	ivideo->sisfb_forcecrt1 = sisfb_forcecrt1;	ivideo->sisfb_crt2type = sisfb_crt2type;	ivideo->sisfb_crt2flags = sisfb_crt2flags;	/* pdc(a), scalelcd, special timing, lvdshl handled below */	ivideo->sisfb_dstn = sisfb_dstn;	ivideo->sisfb_fstn = sisfb_fstn;	ivideo->sisfb_tvplug = sisfb_tvplug;	ivideo->sisfb_tvstd = sisfb_tvstd;	ivideo->tvxpos = sisfb_tvxposoffset;	ivideo->tvypos = sisfb_tvyposoffset;	ivideo->sisfb_filter = sisfb_filter;	ivideo->sisfb_nocrt2rate = sisfb_nocrt2rate;#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,0)	ivideo->sisfb_inverse = sisfb_inverse;#endif	ivideo->refresh_rate = 0;	if(ivideo->sisfb_parm_rate != -1) {	   ivideo->refresh_rate = ivideo->sisfb_parm_rate;	}	ivideo->SiS_Pr.UsePanelScaler = sisfb_scalelcd;	ivideo->SiS_Pr.CenterScreen = -1;	ivideo->SiS_Pr.SiS_CustomT = sisfb_specialtiming;	ivideo->SiS_Pr.LVDSHL = sisfb_lvdshl;	ivideo->SiS_Pr.SiS_Backup70xx = 0xff;        ivideo->SiS_Pr.SiS_CHOverScan = -1;        ivideo->SiS_Pr.SiS_ChSW = FALSE;	ivideo->SiS_Pr.SiS_UseLCDA = FALSE;	ivideo->SiS_Pr.HaveEMI = FALSE;	ivideo->SiS_Pr.HaveEMILCD = FALSE;	ivideo->SiS_Pr.OverruleEMI = FALSE;	ivideo->SiS_Pr.SiS_SensibleSR11 = FALSE;	ivideo->SiS_Pr.SiS_MyCR63 = 0x63;	ivideo->SiS_Pr.PDC  = -1;	ivideo->SiS_Pr.PDCA = -1;#ifdef CONFIG_FB_SIS_315	if(ivideo->chip >= SIS_330) {	   ivideo->SiS_Pr.SiS_MyCR63 = 0x53;	   if(ivideo->chip >= SIS_661) {	      ivideo->SiS_Pr.SiS_SensibleSR11 = TRUE;	   }	}#endif	memcpy(&ivideo->default_var, &my_default_var, sizeof(my_default_var));	pci_set_drvdata(pdev, ivideo);	/* Patch special cases */	if((ivideo->nbridge = sisfb_get_northbridge(ivideo->chip))) {		switch(ivideo->nbridge->device) {#ifdef CONFIG_FB_SIS_300		case PCI_DEVICE_ID_SI_730:		   	ivideo->chip = SIS_730;			strcpy(ivideo->myid, "SiS 730");		   	break;#endif#ifdef CONFIG_FB_SIS_315		case PCI_DEVICE_ID_SI_651:			/* ivideo->chip is ok */			strcpy(ivideo->myid, "SiS 651");			break;		case PCI_DEVICE_ID_SI_740:		   	ivideo->chip = SIS_740;			strcpy(ivideo->myid, "SiS 740");			break;		case PCI_DEVICE_ID_SI_661:		   	ivideo->chip = SIS_661;			strcpy(ivideo->myid, "SiS 661");			break;		case PCI_DEVICE_ID_SI_741:		   	ivideo->chip = SIS_741;			strcpy(ivideo->myid, "SiS 741");			break;		case PCI_DEVICE_ID_SI_760:		   	ivideo->chip = SIS_760;			strcpy(ivideo->myid, "SiS 760");			break;#endif		}	}#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)	strcpy(sis_fb_info->modename, ivideo->myid);#endif	ivideo->sishw_ext.jChipType = ivideo->chip;#ifdef CONFIG_FB_SIS_315	if((ivideo->sishw_ext.jChipType == SIS_315PRO) ||	   (ivideo->sishw_ext.jChipType == SIS_315)) {		ivideo->sishw_ext.jChipType = SIS_315H;	}#endif	ivideo->video_base = pci_resource_start(pdev, 0);	ivideo->mmio_base  = pci_resource_start(pdev, 1);	ivideo->mmio_size  = pci_resource_len(pdev, 1);	ivideo->SiS_Pr.RelIO = pci_resource_start(pdev, 2) + 0x30;	ivideo->sishw_ext.ulIOAddress = ivideo->vga_base = ivideo->SiS_Pr.RelIO;	if(!sisvga_enabled) {	   	if(pci_enable_device(pdev)) {	      		pci_set_drvdata(pdev, NULL);	      		kfree(sis_fb_info);	      		return -EIO;	   	}	}	SiSRegInit(&ivideo->SiS_Pr, ivideo->sishw_ext.ulIOAddress);#ifdef CONFIG_FB_SIS_300	/* Find PCI systems for Chrontel/GPIO communication setup */	if(ivideo->chip == SIS_630) {	   i=0;           do {	      if(mychswtable[i].subsysVendor == ivideo->subsysvendor &&	         mychswtable[i].subsysCard   == ivideo->subsysdevice) {		 ivideo->SiS_Pr.SiS_ChSW = TRUE;		 printk(KERN_DEBUG "sisfb: Identified [%s %s] requiring Chrontel/GPIO setup\n",		        mychswtable[i].vendorName, mychswtable[i].cardName);		 break;              }              i++;           } while(mychswtable[i].subsysVendor != 0);	}#endif        outSISIDXREG(SISSR, 0x05, 0x86);	if( (!sisvga_enabled)#if !defined(__i386__) && !defined(__x86_64__)		  	      || (sisfb_resetcard)#endif			      			   ) {	   	for(i = 0x30; i <= 0x3f; i++) {	      		outSISIDXREG(SISCR,i,0x00);	   	}	}	/* Find out about current video mode */	ivideo->modeprechange = 0x03;	inSISIDXREG(SISCR,0x34,reg);	if(reg & 0x7f) {		ivideo->modeprechange = reg & 0x7f;	} else if(sisvga_enabled) {#if defined(__i386__) || defined(__x86_64__)		unsigned char SIS_IOTYPE2 *tt = ioremap(0, 0x1000);		if(tt) {		   	ivideo->modeprechange = readb(tt + 0x449);		   	iounmap(tt);		}#endif	}#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)#ifdef MODULE	if((reg & 0x80) && (reg != 0xff)) {	   if((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF) {	      printk(KERN_INFO "sisfb: Cannot initialize display mode, X server is active\n");	      pci_set_drvdata(pdev, NULL);	      kfree(sis_fb_info);	      return -EBUSY;	   }	}#endif	#endif	ivideo->sishw_ext.bIntegratedMMEnabled = TRUE;#ifdef CONFIG_FB_SIS_300	if(ivideo->sisvga_engine == SIS_300_VGA) {	   if(ivideo->chip != SIS_300) {	      inSISIDXREG(SISSR, 0x1a, reg);	      if(!(reg & 0x10)) {		 ivideo->sishw_ext.bIntegratedMMEnabled = FALSE;	      }	   }	}#endif	ivideo->bios_abase = NULL;	if(ivideo->sisfb_userom) {	    ivideo->sishw_ext.pjVirtualRomBase = sis_find_rom(pdev);	    ivideo->bios_abase = ivideo->sishw_ext.pjVirtualRomBase;	    if(ivideo->sishw_ext.pjVirtualRomBase) {		printk(KERN_INFO "sisfb: Video ROM found and copied\n");		ivideo->sishw_ext.UseROM = TRUE;	    } else {	        ivideo->sishw_ext.UseROM = FALSE;	        printk(KERN_INFO "sisfb: Video ROM not found\n");	    }	} else {	    ivideo->sishw_ext.pjVirtualRomBase = NULL;	    ivideo->sishw_ext.UseROM = FALSE;	    printk(KERN_INFO "sisfb: Video ROM usage disabled\n");	}        /* Find systems for special custom timing */	if(ivideo->SiS_Pr.SiS_CustomT == CUT_NONE) {	   int j;	   unsigned char *biosver = NULL;           unsigned char *biosdate = NULL;	   BOOLEAN footprint;	   u32 chksum = 0;	   if(ivideo->sishw_ext.UseROM) {	      biosver = ivideo->sishw_ext.pjVirtualRomBase + 0x06;	      biosdate = ivideo->sishw_ext.pjVirtualRomBase + 0x2c;              for(i=0; i<32768; i++) chksum += ivideo->sishw_ext.pjVirtualRomBase[i];	   }	   i=0;           do {	      if( (mycustomttable[i].chipID == ivideo->chip) &&	          ((!strlen(mycustomttable[i].biosversion)) ||		   (ivideo->sishw_ext.UseROM &&		   (!strncmp(mycustomttable[i].biosversion, biosver, strlen(mycustomttable[i].biosversion))))) &&	          ((!strlen(mycustomttable[i].biosdate)) ||		   (ivideo->sishw_ext.UseROM &&		   (!strncmp(mycustomttable[i].biosdate, biosdate, strlen(mycustomttable[i].biosdate))))) &&		  ((!mycustomttable[i].bioschksum) ||		   (ivideo->sishw_ext.UseROM &&	           (mycustomttable[i].bioschksum == chksum)))	&&		  (mycustomttable[i].pcisubsysvendor == ivideo->subsysvendor) &&		  (mycustomttable[i].pcisubsyscard == ivideo->subsysdevice) ) {		 footprint = TRUE;	         for(j = 0; j < 5; j++) {	            if(mycustomttable[i].biosFootprintAddr[j]) {		       if(ivideo->sishw_ext.UseROM) {	                  if(ivideo->sishw_ext.pjVirtualRomBase[mycustomttable[i].biosFootprintAddr[j]] !=		      		mycustomttable[i].biosFootprintData[j]) {		             footprint = FALSE;			  }		       } else footprint = FALSE;		    }	         }	         if(footprint) {	 	    ivideo->SiS_Pr.SiS_CustomT = mycustomttable[i].SpecialID;		    printk(KERN_DEBUG "sisfb: Identified [%s %s], special timing applies\n",		        mycustomttable[i].vendorName,			mycustomttable[i].cardName);		    printk(KERN_DEBUG "sisfb: [specialtiming parameter name: %s]\n",		    	mycustomttable[i].optionName);	            break;                 }	      }              i++;           } while(mycustomttable[i].chipID);	}#ifdef CONFIG_FB_SIS_300	if(ivideo->sisvga_engine == SIS_300_VGA) {		if( (!sisvga_enabled)#if !defined(__i386__) && !defined(__x86_64__)		    		      || (sisfb_resetcard)#endif		  					   ) {			if(ivideo->chip == SIS_300) {				sisfb_post_sis300(pdev);			}		}	}#endif#ifdef CONFIG_FB_SIS_315	if(ivideo->sisvga_engine == SIS_315_VGA) {		if( (!sisvga_enabled)#if !defined(__i386__) && !defined(__x86_64__)		    		     || (sisfb_resetcard)#endif		  					  ) {			if((ivideo->chip == SIS_315H)   ||			   (ivideo->chip == SIS_315)    ||			   (ivideo->chip == SIS_315PRO) ||			   (ivideo->chip == SIS_330)) {				sisfb_post_sis315330(pdev);			}		}	}#endif	if(sisfb_get_dram_size(ivideo)) {		printk(KERN_INFO "sisfb: Fatal error: Unable to determine RAM size.\n");		if(ivideo->bios_abase) vfree(ivideo->bios_abase);		pci_set_drvdata(pdev, NULL);		kfree(sis_fb_info);		return -ENODEV;	}	if((ivideo->sisfb_mode_idx < 0) ||	   ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) {	        /* Enable PCI_LINEAR_ADDRESSING and MMIO_ENABLE  */	        orSISIDXREG(SISSR, IND_SIS_PCI_ADDRESS_SET, (SIS_PCI_ADDR_ENABLE | SIS_MEM_MAP_IO_ENABLE));                /* Enable 2D accelerator engine */	        orSISIDXREG(SISSR, IND_SIS_MODULE_ENABLE, SIS_ENABLE_2D);	}	if(sisfb_pdc != 0xff) {	   if(ivideo->sisvga_engine == SIS_300_VGA) sisfb_pdc &= 0x3c;	   else				            sisfb_pdc &= 0x1f;	   ivideo->SiS_Pr.PDC = sisfb_pdc;	}#ifdef CONFIG_FB_SIS_315	if(ivideo->sisvga_engine == SIS_315_VGA) {	   if(sisfb_pdca != 0xff) ivideo->SiS_Pr.PDCA = sisfb_pdca & 0x1f;	}#endif	if(!request_mem_region(ivideo->video_base, ivideo->video_size, "sisfb FB")) {		printk(KERN_ERR "sisfb: Fatal error: Unable to reserve frame buffer memory\n");		printk(KERN_ERR "sisfb: Is there another framebuffer driver active?\n");		if(ivideo->bios_abase) vfree(ivideo->bios_abase);		pci_set_drvdata(pdev, NULL);		kfree(sis_fb_info);		return -ENODEV;	}	if(!request_mem_region(ivideo->mmio_base, ivideo->mmio_size, "sisfb MMIO")) {		printk(KERN_ERR "sisfb: Fatal error: Unable to reserve MMIO region\n");		release_mem_region(ivideo->video_base, ivideo->video_size);		if(ivideo->bios_abase) vfree(ivideo->bios_abase);		pci_set_drvdata(pdev, NULL);		kfree(sis_fb_info);		return -ENODEV;	}	ivideo->video_vbase = ioremap(ivideo->video_base, ivideo->video_size);	ivideo->sishw_ext.pjVideoMemoryAddress = ivideo->video_vbase;	if(!ivideo->video_vbase) {	   	printk(KERN_ERR "sisfb: Fatal error: Unable to map frame buffer memory\n");	   	release_mem_region(ivideo->video_base, ivideo->video_size);	   	release_mem_region(ivideo->mmio_base, ivideo->mmio_size);		if(ivideo->bios_abase) vfree(ivideo->bios_abase);		pci_set_drvdata(pdev, NULL);	   	kfree(sis_fb_info);	   	return -ENODEV;	}	ivideo->mmio_vbase = ioremap(ivideo->mmio_base, ivideo->mmio_size);	if(!ivideo->mmio_vbase) {	   	printk(KERN_ERR "sisfb: Fatal error: Unable to map MMIO region\n");	   	iounmap(ivideo->video_vbase);	   	release_mem_region(ivideo->video_base, ivideo->video_size);	   	release_mem_region(ivideo->mmio_base, ivideo->mmio_size);		if(ivideo->bios_abase) vfree(ivideo->bios_abase);		pci_set_drvdata(pdev, NULL);	   	kfree(sis_fb_info);	   	return -ENODEV;	}	printk(KERN_INFO "sisfb: Framebuffer at 0x%lx, mapped to 0x%lx, size %ldk\n",	       	ivideo->video_base, (ULONG)ivideo->video_vbase, ivideo->video_size / 1024);	printk(KERN_INFO "sisfb: MMIO at 0x%lx, mapped to 0x%lx, size %ldk\n",	       	ivideo->mmio_base, (ULONG)ivideo->mmio_vbase, ivideo->mmio_size / 1024);	if((ivideo->havenoheap = sisfb_heap_init(ivideo))) {		printk(KERN_WARNING "sisfb: Failed to initialize offscreen memory heap\n");	}	/* Used for clearing the screen only, therefore respect our mem limit */	ivideo->sishw_ext.ulVideoMemorySize = ivideo->sisfb_mem;	ivideo->mtrr = 0;	ivideo->vbflags = 0;	ivideo->lcddefmodeidx = DEFAULT_LCDMODE;	ivideo->tvdefmodeidx  = DEFAULT_TVMODE;	ivideo->defmodeidx    = DEFAULT_MODE;	ivideo->newrom = SiSDetermineROMLayout661(&ivideo->SiS_Pr, &ivideo->sishw_ext);	if((ivideo->sisfb_mode_idx < 0) ||	   ((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF)) {		sisfb_sense_crt1(ivideo);		sisfb_get_VB_type(ivideo);		if(ivideo->vbflags & VB_VIDEOBRIDGE) {			sisfb_detect_VB_connect(ivideo);		}		ivideo->currentvbflags = ivideo->vbflags & (VB_VIDEOBRIDGE | TV_STANDARD);		if(ivideo->vbflags & VB_VIDEOBRIDGE) {		   if(ivideo->sisfb_crt2type != -1) {		      if((ivideo->sisfb_crt2type == CRT2_LCD) && (ivideo->vbflags & CRT2_LCD)) {		         ivideo->currentvbflags |= CRT2_LCD;		      } else if(ivideo->sisfb_crt2type != CRT2_LCD) {		         ivideo->currentvbflags |= ivideo->sisfb_crt2type;		      }		   } else {		      /* Chrontel 700x TV detection often unreliable, therefore use a		       * different default order on such machines		       */		      if((ivideo->sisvga_engine == SIS_300_VGA) && (ivideo->vbflags & VB_CHRONTEL)) {		         if(ivideo->vbflags & CRT2_LCD)      ivideo->currentvbflags |= CRT2_LCD;		         else if(ivideo->vbflags & CRT2_TV)  ivideo->currentvbflags |= CRT2_TV;		         else if(ivideo->vbflags & CRT2_VGA) ivideo->currentvbflags |= CRT2_VGA;		      } else {		         if(ivideo->vbflags & CRT2_TV)       ivideo->currentvbflags |= CRT2_TV;		         else if(ivideo->vbflags & CRT2_LCD) ivideo->currentvbflags |= CRT2_LCD;		         else if(ivideo->vbflags & CRT2_VGA) ivideo->currentvbflags |= CRT2_VGA;		      }		   }		}		if(ivideo->vbflags & CRT2_LCD) {		   inSISIDXREG(SISCR, 0x36, reg);		   reg &= 0x0f;		   if(ivideo->sisvga_engine == SIS_300_VGA) {		      ivideo->CRT2LCDType = sis300paneltype[reg];		   } else if(ivideo->chip >= SIS_661) {		      ivideo->CRT2LCDType = sis661paneltype[reg];		   } else {		      ivideo->CRT2LCDType = sis310paneltype[reg];		      if((ivideo->chip == SIS_550) && (sisfb_fstn)) {		         if((ivideo->CRT2LCDType != LCD_640x480_2) &&			    (ivideo->CRT2LCDType != LCD_640x480_3)) {		      	    ivideo->CRT2LCDType = LCD_320x480;			 }		      }		   }		   if(ivideo->CRT2LCDType == LCD_UNKNOWN) {		      /* For broken BIOSes: Assume 1024x768, RGB18 */		      ivideo->CRT2LCDType = LCD_1024x768;		      setSISIDXREG(SISCR,0x36,0xf0,0x02);		      setSISIDXREG(SISCR,0x37,0xee,0x01);		      printk(KERN_DEBUG "sisfb: Invalid panel ID (%02x), assuming 1024x768, RGB18\n", reg);		   }		   for(i = 0; i < SIS_LCD_NUMBER; i++) {		      if(ivideo->CRT2LCDType == sis_lcd_data[i].lcdtype) {		         ivideo->lcdxres = sis_lcd_data[i].xres;			 ivideo->lcdyres = sis_lcd_data[i].yres;			 ivideo->lcddefmodeidx = sis_lcd_data[i].default_mode_idx;			 break;		      }		   }		   if(ivideo->SiS_Pr.SiS_CustomT == CUT_BARCO1366) {	   		ivideo->lcdxres = 1360; ivideo->lcdyres = 1024; ivideo->lcddefmodeidx = 99;		   } else if(ivideo->SiS_Pr.SiS_CustomT == CUT_PANEL848) {	   		ivideo->lcdxres =  848; ivideo->lcdyres =  480; ivideo->lcddefmodeidx = 47;		   }		   printk(KERN_DEBUG "sisfb: Detected %dx%d flat panel\n",		   		ivideo->lcdxres, ivideo->lcdyres);		}#ifdef CONFIG_FB_SIS_300                /* Save the current PanelDelayCompensation if the LCD is currently used */		if(ivideo->sisvga_engine == SIS_300_VGA) {	           if(ivideo->vbflags & (VB_LVDS | VB_30xBDH)) {		       int tmp;		       inSISIDXREG(SISCR,0x30,tmp);		       if(tmp & 0x20) {		          /* Currently on LCD? If yes, read current pdc */		          inSISIDXREG(SISPART1,0x13,ivideo->detectedpdc);			  ivideo->detectedpdc &= 0x3c;			  if(ivideo->SiS_Pr.PDC == -1) {			     /* Let option override detection */			     ivideo->SiS_Pr.PDC = ivideo->detectedpdc;			  }			  printk(KERN_INFO "sisfb: Detected LCD PDC 0x%02x\n",  			         ivideo->detectedpdc);		       }		       if((ivideo->SiS_Pr.PDC != -1) && (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) {		          printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x\n",				 ivideo->SiS_Pr.PDC);		       }	           }		}#endif#ifdef CONFIG_FB_SIS_315		if(ivideo->sisvga_engine == SIS_315_VGA) {		   /* Try to find about LCDA */		   if(ivideo->vbflags & (VB_301C | VB_302B | VB_301LV | VB_302LV | VB_302ELV)) {		      int tmp;		      inSISIDXREG(SISPART1,0x13,tmp);		      if(tmp & 0x04) {		         ivideo->SiS_Pr.SiS_UseLCDA = TRUE;		         ivideo->detectedlcda = 0x03;		      }	           }		   /* Save PDC */		   if(ivideo->vbflags & (VB_301LV | VB_302LV | VB_302ELV)) {		      int tmp;		      inSISIDXREG(SISCR,0x30,tmp);		      if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) {		         /* Currently on LCD? If yes, read current pdc */			 u8 pdc;		         inSISIDXREG(SISPART1,0x2D,pdc);			 ivideo->detectedpdc  = (pdc & 0x0f) << 1;			 ivideo->detectedpdca = (pdc & 0xf0) >> 3;			 inSISIDXREG(SISPART1,0x35,pdc);			 ivideo->detectedpdc |= ((pdc >> 7) & 0x01);			 inSISIDXREG(SISPART1,0x20,pdc);			 ivideo->detectedpdca |= ((pdc >> 6) & 0x01);			 if(ivideo->newrom) {			    /* New ROM invalidates other PDC resp. */			    if(ivideo->detectedlcda != 0xff) {			       ivideo->detectedpdc = 0xff;			    } else {			       ivideo->detectedpdca = 0xff;			    }			 }			 if(ivideo->SiS_Pr.PDC == -1) {			    if(ivideo->detectedpdc != 0xff) {			       ivideo->SiS_Pr.PDC = ivideo->detectedpdc;			    }			 }			 if(ivideo->SiS_Pr.PDCA == -1) {			    if(ivideo->detectedpdca != 0xff) {			       ivideo->SiS_Pr.PDCA = ivideo->detectedpdca;			    }			 }			 if(ivideo->detectedpdc != 0xff) {			    printk(KERN_INFO			         "sisfb: Detected LCD PDC 0x%02x (for LCD=CRT2)\n",  			          ivideo->detectedpdc);			 }			 if(ivideo->detectedpdca != 0xff) {			    printk(KERN_INFO			         "sisfb: Detected LCD PDC1 0x%02x (for LCD=CRT1)\n",  			          ivideo->detectedpdca);			 }		      }		      /* Save EMI */		      if(ivideo->vbflags & (VB_302LV | VB_302ELV)) {		         inSISIDXREG(SISPART4,0x30,ivideo->SiS_Pr.EMI_30);			 inSISIDXREG(SISPART4,0x31,ivideo->SiS_Pr.EMI_31);			 inSISIDXREG(SISPART4,0x32,ivideo->SiS_Pr.EMI_32);			 inSISIDXREG(SISPART4,0x33,ivideo->SiS_Pr.EMI_33);			 ivideo->SiS_Pr.HaveEMI = TRUE;			 if((tmp & 0x20) || (ivideo->detectedlcda != 0xff)) {			  	ivideo->SiS_Pr.HaveEMILCD = TRUE;			 }		      }		   }		   /* Let user override detected PDCs (all bridges) */		   if(ivideo->vbflags & (VB_301B | VB_301C | VB_301LV | VB_302LV | VB_302ELV)) {		      if((ivideo->SiS_Pr.PDC != -1) && (ivideo->SiS_Pr.PDC != ivideo->detectedpdc)) {		         printk(KERN_INFO "sisfb: Using LCD PDC 0x%02x (for LCD=CRT2)\n",				 ivideo->SiS_Pr.PDC);		      }		      if((ivideo->SiS_Pr.PDCA != -1) && (ivideo->SiS_Pr.PDCA != ivideo->detectedpdca)) {		         printk(KERN_INFO "sisfb: Using LCD PDC1 0x%02x (for LCD=CRT1)\n",				 ivideo->SiS_Pr.PDCA);		      }		   }		}#endif		if(!ivideo->sisfb_crt1off) {		   	sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 0);		} else {		   	if((ivideo->vbflags & (VB_301|VB_301B|VB_301C|VB_302B)) &&		      	   (ivideo->vbflags & (CRT2_VGA | CRT2_LCD))) {		      		sisfb_handle_ddc(ivideo, &ivideo->sisfb_thismonitor, 1);		   	}		}		if(ivideo->sisfb_mode_idx >= 0) {			int bu = ivideo->sisfb_mode_idx;			ivideo->sisfb_mode_idx = sisfb_validate_mode(ivideo,					ivideo->sisfb_mode_idx, ivideo->currentvbflags);			if(bu != ivideo->sisfb_mode_idx) {				printk(KERN_ERR "Mode %dx%dx%d failed validation\n",					sisbios_mode[bu].xres,					sisbios_mode[bu].yres,					sisbios_mode[bu].bpp);			}		}		if(ivideo->sisfb_mode_idx < 0) {			switch(ivideo->currentvbflags & VB_DISPTYPE_DISP2) {			   case CRT2_LCD:				ivideo->sisfb_mode_idx = ivideo->lcddefmodeidx;				break;			   case CRT2_TV:				ivideo->sisfb_mode_idx = ivideo->tvdefmodeidx;				break;			   default:				ivideo->sisfb_mode_idx = ivideo->defmodeidx;				break;			}		}		ivideo->mode_no = sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni];		if(ivideo->refresh_rate != 0) {			sisfb_search_refresh_rate(ivideo, ivideo->refresh_rate, ivideo->sisfb_mode_idx);		}		if(ivideo->rate_idx == 0) {			ivideo->rate_idx = sisbios_mode[ivideo->sisfb_mode_idx].rate_idx;			ivideo->refresh_rate = 60;		}		if(ivideo->sisfb_thismonitor.datavalid) {			if(!sisfb_verify_rate(ivideo, &ivideo->sisfb_thismonitor, ivideo->sisfb_mode_idx,			                      ivideo->rate_idx, ivideo->refresh_rate)) {				printk(KERN_INFO "sisfb: WARNING: Refresh rate exceeds monitor specs!\n");			}		}		ivideo->video_bpp = sisbios_mode[ivideo->sisfb_mode_idx].bpp;		ivideo->video_width = sisbios_mode[ivideo->sisfb_mode_idx].xres;		ivideo->video_height = sisbios_mode[ivideo->sisfb_mode_idx].yres;		sisfb_set_vparms(ivideo);		#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)			/* ---------------- For 2.4: Now switch the mode ------------------ */						printk(KERN_INFO "sisfb: Mode is %dx%dx%d (%dHz)\n",	       		ivideo->video_width, ivideo->video_height, ivideo->video_bpp,			ivideo->refresh_rate);		sisfb_pre_setmode(ivideo);		if(SiSSetMode(&ivideo->SiS_Pr, &ivideo->sishw_ext, ivideo->mode_no) == 0) {			printk(KERN_ERR "sisfb: Fatal error: Setting mode[0x%x] failed\n",									ivideo->mode_no);			iounmap(ivideo->video_vbase);			iounmap(ivideo->mmio_vbase);			release_mem_region(ivideo->video_base, ivideo->video_size);			release_mem_region(ivideo->mmio_base, ivideo->mmio_size);			if(ivideo->bios_abase) vfree(ivideo->bios_abase);			pci_set_drvdata(pdev, NULL);			kfree(sis_fb_info);			return -EINVAL;		}		outSISIDXREG(SISSR, IND_SIS_PASSWORD, SIS_PASSWORD);		sisfb_post_setmode(ivideo);		/* Maximize regardless of sisfb_max at startup */		ivideo->default_var.yres_virtual = 32767;		/* Force reset of x virtual in crtc_to_var */		ivideo->default_var.xres_virtual = 0;		sisfb_crtc_to_var(ivideo, &ivideo->default_var);		sisfb_calc_pitch(ivideo, &ivideo->default_var);		sisfb_set_pitch(ivideo);		ivideo->accel = 0;		if(ivideo->sisfb_accel) {		   ivideo->accel = -1;		   ivideo->default_var.accel_flags |= FB_ACCELF_TEXT;		}		sisfb_initaccel(ivideo);				sis_fb_info->node  = -1;		sis_fb_info->flags = FBINFO_FLAG_DEFAULT;		sis_fb_info->fbops = &sisfb_ops;		sis_fb_info->disp  = &ivideo->sis_disp;		sis_fb_info->blank = &sisfb_blank;		sis_fb_info->switch_con = &sisfb_switch;		sis_fb_info->updatevar  = &sisfb_update_var;		sis_fb_info->changevar  = NULL;		strcpy(sis_fb_info->fontname, sisfb_fontname);		sisfb_set_disp(-1, &ivideo->default_var, sis_fb_info);#else		/* --------- For 2.6: Setup a somewhat sane default var ------------ */		printk(KERN_INFO "sisfb: Default mode is %dx%dx%d (%dHz)\n",	       		ivideo->video_width, ivideo->video_height, ivideo->video_bpp,			ivideo->refresh_rate);		ivideo->default_var.xres = ivideo->default_var.xres_virtual = ivideo->video_width;		ivideo->default_var.yres = ivideo->default_var.yres_virtual = ivideo->video_height;		ivideo->default_var.bits_per_pixel = ivideo->video_bpp;		sisfb_bpp_to_var(ivideo, &ivideo->default_var);				ivideo->default_var.pixclock = (u32) (1000000000 /				sisfb_mode_rate_to_dclock(&ivideo->SiS_Pr, &ivideo->sishw_ext,						ivideo->mode_no, ivideo->rate_idx));								if(sisfb_mode_rate_to_ddata(&ivideo->SiS_Pr, &ivideo->sishw_ext,			 	ivideo->mode_no, ivideo->rate_idx, &ivideo->default_var)) {		   if((ivideo->default_var.vmode & FB_VMODE_MASK) == FB_VMODE_DOUBLE) {		      ivideo->default_var.pixclock <<= 1;	   	   }	        }		if(ivideo->sisfb_ypan) {		   /* Maximize regardless of sisfb_max at startup */	    	   ivideo->default_var.yres_virtual = sisfb_calc_maxyres(ivideo, &ivideo->default_var);	    	   if(ivideo->default_var.yres_virtual < ivideo->default_var.yres) {	              ivideo->default_var.yres_virtual = ivideo->default_var.yres;	    	   }		}		sisfb_calc_pitch(ivideo, &ivideo->default_var);		ivideo->accel = 0;		if(ivideo->sisfb_accel) {		   ivideo->accel = -1;#ifdef STUPID_ACCELF_TEXT_SHIT		   ivideo->default_var.accel_flags |= FB_ACCELF_TEXT;#endif		}		sisfb_initaccel(ivideo);#if defined(FBINFO_HWACCEL_DISABLED) && defined(FBINFO_HWACCEL_XPAN)		sis_fb_info->flags = FBINFO_DEFAULT 		|				     FBINFO_HWACCEL_YPAN 	|				     FBINFO_HWACCEL_XPAN 	|				     FBINFO_HWACCEL_COPYAREA 	|				     FBINFO_HWACCEL_FILLRECT 	|				     ((ivideo->accel) ? 0 : FBINFO_HWACCEL_DISABLED);#else		sis_fb_info->flags = FBINFO_FLAG_DEFAULT;#endif		sis_fb_info->var = ivideo->default_var;		sis_fb_info->fix = ivideo->sisfb_fix;		sis_fb_info->screen_base = ivideo->video_vbase;		sis_fb_info->fbops = &sisfb_ops;		sisfb_get_fix(&sis_fb_info->fix, -1, sis_fb_info);		sis_fb_info->pseudo_palette = ivideo->pseudo_palette;				fb_alloc_cmap(&sis_fb_info->cmap, 256 , 0);#endif		/* 2.6 */		printk(KERN_DEBUG "sisfb: Initial vbflags 0x%lx\n", (unsigned long)ivideo->vbflags);#ifdef CONFIG_MTRR		ivideo->mtrr = mtrr_add(ivideo->video_base, ivideo->video_size,					MTRR_TYPE_WRCOMB, 1);		if(!ivideo->mtrr) {			printk(KERN_DEBUG "sisfb: Failed to add MTRRs\n");		}#endif#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)		vc_resize_con(1, 1, 0);#endif		if(register_framebuffer(sis_fb_info) < 0) {			printk(KERN_ERR "sisfb: Fatal error: Failed to register framebuffer\n");			iounmap(ivideo->video_vbase);			iounmap(ivideo->mmio_vbase);			release_mem_region(ivideo->video_base, ivideo->video_size);			release_mem_region(ivideo->mmio_base, ivideo->mmio_size);			if(ivideo->bios_abase) vfree(ivideo->bios_abase);			pci_set_drvdata(pdev, NULL);			kfree(sis_fb_info);			return -EINVAL;		}		ivideo->registered = 1;		/* Enlist us */		ivideo->next = card_list;		card_list = ivideo;		printk(KERN_INFO "sisfb: 2D acceleration is %s, y-panning %s\n",		     ivideo->sisfb_accel ? "enabled" : "disabled",		     ivideo->sisfb_ypan  ?		     	(ivideo->sisfb_max ? "enabled (auto-max)" : "enabled (no auto-max)") : "disabled");		printk(KERN_INFO "fb%d: %s frame buffer device, Version %d.%d.%d\n",#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)	       		GET_FB_IDX(sis_fb_info->node),#else	       		sis_fb_info->node,#endif			ivideo->myid, VER_MAJOR, VER_MINOR, VER_LEVEL);		printk(KERN_INFO "sisfb: (C) 2001-2004 Thomas Winischhofer.\n");	}	/* if mode = "none" */	return 0;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/544393fe584d333480659a4bed30f5295355df11/sis_main.c/clean/drivers/video/sis/sis_main.c