patch-2.1.120 linux/drivers/char/bttv.c

Next file: linux/drivers/char/bttv.h
Previous file: linux/drivers/char/apm_bios.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.119/linux/drivers/char/bttv.c linux/drivers/char/bttv.c
@@ -85,7 +85,7 @@
 static unsigned int radio[BTTV_MAX];
 static unsigned int card[BTTV_MAX] = { 0, 0, 
                                        0, 0 };
-static unsigned int pll[BTTV_MAX] = { 0, 0, 0, 0 };
+static unsigned int pll[BTTV_MAX] = { 0, 0, 0, 0 };          
 
 static int bttv_num;			/* number of Bt848s in use */
 static struct bttv bttvs[BTTV_MAX];
@@ -433,6 +433,9 @@
         {0, 0xc00, 0x800, 0x400, 0xc00, 0}},
         /* TurboTV */
         { 3, 0, 2, 3, { 2, 3, 1, 1}, { 1, 1, 2, 3, 0}},
+        /* Newer Hauppauge */
+	{ 2, 0, 2, 1, { 2, 0, 0, 0}, {0, 1, 2, 3, 4}},
+  
 };
 #define TVCARDS (sizeof(tvcards)/sizeof(tvcard))
 
@@ -545,30 +548,25 @@
         int i;
         unsigned long tv;
 
-        if (!btv->pll)
+        if (!btv->pll.pll_crystal)
 		return 0;
-        if ((btread(BT848_IFORM)&BT848_IFORM_XT0))
+        if ((btread(BT848_IFORM)&btv->pll.pll_crystal))
         {
                 /* printk ("switching PLL off\n");*/
                 btwrite(0x00,BT848_TGCTRL);
                 btwrite(0x00,BT848_PLL_XCI);
-                btv->pll&=~2;
+                btv->pll.pll_crystal&=~2;
                 return 0;
         }
         
         /* do not set pll again if already active */
-        if (btv->pll&2)
+        if (btv->pll.pll_crystal&2)
                 return 1;
         
         /* printk ("setting PLL for PAL/SECAM\n");*/
 
-	set_pll_freq(btv, 28636363, 35468950);
-/*	
-        btwrite(0x00,BT848_TGCTRL);
-        btwrite(0xf9,BT848_PLL_F_LO);
-        btwrite(0xdc,BT848_PLL_F_HI);
-        btwrite(14|BT848_PLL_X,BT848_PLL_XCI);
-*/
+	set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq);
+
 	/*
 	 *	Let other people run while the PLL stabilizes
 	 */
@@ -587,7 +585,7 @@
                 else
                 {
                         btwrite(0x08,BT848_TGCTRL);
-                        btv->pll|=2;
+                        btv->pll.pll_crystal|=2;
                         return 1;            
                 }
                 udelay(10000);
@@ -1179,7 +1177,7 @@
 	audio(btv, AUDIO_MUTE);
 	udelay(AUDIO_MUTE_DELAY);
 
-	if (radio[btv->nr]) 
+	if (btv->radio) 
 	{
 		if (btv->have_tuner)
 			i2c_control_device(&(btv->i2c), I2C_DRIVERID_TUNER,
@@ -1831,12 +1829,24 @@
 				return -EFAULT;
 			break;
 
-		case BTTV_FIELDNR:
+                case BTTV_FIELDNR: 
 			if(copy_to_user((void *) arg, (void *) &btv->last_field, 
                                         sizeof(btv->last_field)))
 				return -EFAULT;
                         break;
+      
+                case BTTV_PLLSET: {
+                        struct bttv_pll_info p;
+                        if(!capable(CAP_SYS_ADMIN))
+                        	return -EPERM;
+                        if(copy_from_user(&p , (void *) arg, sizeof(btv->pll)))
+				return -EFAULT;
+                        btv->pll.pll_ifreq = p.pll_ifreq;
+                        btv->pll.pll_ofreq = p.pll_ofreq;
+                        btv->pll.pll_crystal = p.pll_crystal;
 
+			break;
+                }						
 	        case VIDIOCMCAPTURE:
 		{
                         struct video_mmap vm;
@@ -2406,7 +2416,12 @@
 	        btv->type=BTTV_MIRO;
     
 		if (I2CRead(&(btv->i2c), I2C_HAUPEE)>=0)
-		        btv->type=BTTV_HAUPPAUGE;
+		{
+			if(btv->id>849)
+				btv->type=BTTV_HAUPPAUGE878;
+			else
+			        btv->type=BTTV_HAUPPAUGE;
+		}
 		else
 		        if (I2CRead(&(btv->i2c), I2C_STBEE)>=0)
 			        btv->type=BTTV_STB;
@@ -2441,6 +2456,8 @@
 
 	/* How do I detect the tuner type for other cards but Miro ??? */
 	printk(KERN_INFO "bttv%d: model: ", btv->nr);
+	
+	sprintf(btv->video_dev.name,"BT%d",btv->id);
 	switch (btv->type) 
 	{
 		case BTTV_MIRO:
@@ -2452,31 +2469,32 @@
 						   I2C_DRIVERID_TUNER,
 						   TUNER_SET_TYPE,&tunertype);
 			}
-			strcpy(btv->video_dev.name,"BT848(Miro)");
+			strcat(btv->video_dev.name, "(Miro)");
 			break;
 		case BTTV_HAUPPAUGE:
+		case BTTV_HAUPPAUGE878:
 			printk("HAUPPAUGE\n");
-			strcpy(btv->video_dev.name,"BT848(Hauppauge)");
+			strcat(btv->video_dev.name,"(Hauppauge)");
 			break;
 		case BTTV_STB: 
 			printk("STB\n");
-			strcpy(btv->video_dev.name,"BT848(STB)");
+			strcat(btv->video_dev.name,"(STB)");
 			break;
 		case BTTV_INTEL: 
 			printk("Intel\n");
-			strcpy(btv->video_dev.name,"BT848(Intel)");
+			strcat(btv->video_dev.name,"(Intel)");
 			break;
 		case BTTV_DIAMOND: 
 			printk("Diamond\n");
-			strcpy(btv->video_dev.name,"BT848(Diamond)");
+			strcat(btv->video_dev.name,"(Diamond)");
 			break;
 		case BTTV_AVERMEDIA: 
 			printk("AVerMedia\n");
-			strcpy(btv->video_dev.name,"BT848(AVerMedia)");
+			strcat(btv->video_dev.name,"(AVerMedia)");
 			break;
 		case BTTV_MATRIX_VISION: 
 			printk("MATRIX-Vision\n");
-			strcpy(btv->video_dev.name,"BT848(MATRIX-Vision)");
+			strcat(btv->video_dev.name,"(MATRIX-Vision)");
 			break;
 	}
 	audio(btv, AUDIO_MUTE);
@@ -2902,12 +2920,16 @@
         printk("irq: %d, ",btv->irq);
         printk("memory: 0x%08x.\n", btv->bt848_adr);
         
-        btv->pll=0;
+        btv->pll.pll_ifreq=0;
+        btv->pll.pll_ifreq=0;
+        btv->pll.pll_crystal=0;
         if(pll[btv->nr])
                 if (!(btv->id==848 && btv->revision==0x11))
                 {
                         printk(KERN_INFO "bttv%d: internal PLL, single crystal operation enabled\n",bttv_num);
-                        btv->pll=1;
+                        btv->pll.pll_ofreq=28636363;
+                        btv->pll.pll_ifreq=35468950;
+                        btv->pll.pll_crystal=BT848_IFORM_XT1;
                 }
         
         btv->bt848_mem=ioremap(btv->bt848_adr, 0x1000);
@@ -2972,7 +2994,7 @@
                 dev = dev->next;
         }
 	if(bttv_num)
-		printk(KERN_INFO "bttv: %d Bt848 card(s) found.\n", bttv_num);
+		printk(KERN_INFO "bttv: %d BT8xx card(s) found.\n", bttv_num);
 	return bttv_num;
 }
  
@@ -3088,3 +3110,4 @@
  * tab-width: 8
  * End:
  */
+ 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov