Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] [PATCH] skystar2 rev193 full soft diseqc



I copied the implementation in budget.c .
Tone busrt (what I have) still works.
DiSEqC messages are untested (no diseqc hw here), but should work if
budget.c is not broken.
It is anyway safe to add this patch to CVS (IMHO).
-- 
Vincenzo Di Massa <hawk.it@tiscalinet.it>
-- 
Vincenzo Di Massa <hawk78_it@yahoo.it>
Index: dvb-kernel/linux/drivers/media/dvb/b2c2/skystar2.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/b2c2/skystar2.c,v
retrieving revision 1.17
diff -p -u -r1.17 skystar2.c
--- dvb-kernel/linux/drivers/media/dvb/b2c2/skystar2.c	1 Dec 2003 08:28:49 -0000	1.17
+++ dvb-kernel/linux/drivers/media/dvb/b2c2/skystar2.c	3 Dec 2003 14:36:12 -0000
@@ -4,11 +4,15 @@
  *
  * Copyright (C) 2003  Vadim Catana, skystar@moldova.cc
  *
- * FIX: DISEQC Tone Burst in flexcop_diseqc_ioctl()
+ * FIX: DiSEqC Tone Burst in flexcop_diseqc_ioctl()
  * 	 Vincenzo Di Massa, hawk.it at tiscalinet.it
  * 	
  * IMP: Converted to Linux coding style
  * 	 Roberto Ragusa, r.ragusa at libero.it
+ *
+ * FIX: FULL soft DiSEqC for skystar2 (rev 193) VP310 equipped
+ *       Vincenzo Di Massa, hawk.it at tiscalinet.it
+ *       
  * 	
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -24,6 +28,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
+
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/pci.h>
@@ -2260,138 +2265,147 @@ static void set_tuner_polarity(struct ad
 	write_reg_dw(adapter, 0x204, var);
 }
 
-static int flexcop_diseqc_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
+static void diseqc_send_bit (struct adapter *adapter, int data)
 {
-	struct adapter *adapter = fe->before_after_data;
-
-	struct dvb_frontend_info info;
-	
-	switch (cmd) {
-	
-	    case FE_DISEQC_SEND_BURST:
-	    {
-		u8 count;
-		fe_sec_mini_cmd_t b = (fe_sec_mini_cmd_t) arg; 
-		dprintk("%s: FE_SEND_BURST ", __FUNCTION__);
-		switch ( b )		
-		{   
-		    case SEC_MINI_A:
-		    {
-		        dprintk("SEC_MINI_A\n");
-		    	set_tuner_tone(adapter, 1); // This lines are needed 
-			udelay(500*25);             // to do a down-step
-		    	set_tuner_tone(adapter, 0);
-			udelay(500*25); 
-			break;
-		    }
-		    case SEC_MINI_B:
-		    {
-		        dprintk("SEC_MINI_B\n");
-			set_tuner_tone(adapter, 0);
-			udelay(1000*15);
-                        for (count=0;count<9; count++)
-			{
-				set_tuner_tone(adapter, 1);
-				udelay(500);
-				set_tuner_tone(adapter, 0);
-				udelay(1000);
-			}
-			udelay(1000*15);
-			break;
-		    }
-		    default:
-		    	break; 
-		};
-		return 0;
-	    }
-	
+	set_tuner_tone(adapter, 1);
+	udelay(data ? 500 : 1000);
+	set_tuner_tone(adapter, 0);
+	udelay(data ? 1000 : 500);
+}
 
-	    case FE_SLEEP:
-	    {
-		dprintk("%s: FE_SLEEP\n", __FUNCTION__);
 
-		set_tuner_polarity(adapter, 0);
+static void diseqc_send_byte (struct adapter *adapter, int data)
+{
+	int i, par=1, d;
 
-		// return -EOPNOTSUPP, to make DVB core also send "FE_SLEEP" command to frontend.
-		return -EOPNOTSUPP;
-	    }
+	for (i=7; i>=0; i--) {
+		d = (data>>i)&1;
+		par ^= d;
+		diseqc_send_bit(adapter, d);
+	}
 
-	    case FE_SET_VOLTAGE:
-	    {
-		dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
+	diseqc_send_bit(adapter, par);
+}
 
-		switch ((fe_sec_voltage_t) arg)
-		{
-			case SEC_VOLTAGE_13:
 
-				dprintk("%s: SEC_VOLTAGE_13, %x\n", __FUNCTION__, SEC_VOLTAGE_13);
+static int send_diseqc_msg (struct adapter *adapter, int len, u8 *msg, unsigned long burst)
+{
+	int i;
 
-				set_tuner_polarity(adapter, 1);
+	set_tuner_tone(adapter, 0);
+	mdelay(16);
 
-				return 0;
+	for (i=0; i<len; i++)
+		diseqc_send_byte(adapter, msg[i]);
 
-			case SEC_VOLTAGE_18:
+	mdelay(16);
 
-				dprintk("%s: SEC_VOLTAGE_18, %x\n", __FUNCTION__, SEC_VOLTAGE_18);
+	if (burst!=-1) {
+		if (burst)
+			diseqc_send_byte(adapter, 0xff);
+		else {
+			set_tuner_tone(adapter, 1);
+			udelay(12500);
+			set_tuner_tone(adapter, 0);
+		}
+		dvb_delay(20);
+	}
 
-				set_tuner_polarity(adapter, 2);
+	return 0;
+}
 
-				return 0;
 
-			default:
+int soft_diseqc (struct adapter *adapter, unsigned int cmd, void *arg)
+{
+	switch (cmd) {
+		case FE_SET_TONE:
+		    switch ((fe_sec_tone_mode_t) arg) {
+			    case SEC_TONE_ON:
+				    set_tuner_tone(adapter, 1);
+					break;
+           	 	case SEC_TONE_OFF:
+                	set_tuner_tone(adapter, 0);
+                	break;
+            	default:
+                	return -EINVAL;
+        	};
+       		break;
+
+       	case FE_DISEQC_SEND_MASTER_CMD:
+       	{
+        	struct dvb_diseqc_master_cmd *cmd = arg;
+
+            send_diseqc_msg (adapter, cmd->msg_len, cmd->msg, 0);
+            break;
+		}
+
+		case FE_DISEQC_SEND_BURST:
+        	send_diseqc_msg (adapter, 0, NULL, (unsigned long)arg);
+            break;
 
-				return -EINVAL;
-		};
+       	default:
+			return -EOPNOTSUPP;
+	};
 
-	    }
+    return 0;
+}
 
-	    case FE_SET_TONE:
-	    {
-		dprintk("%s: FE_SET_TONE\n", __FUNCTION__);
+static int flexcop_diseqc_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
+{
+	struct adapter *adapter = fe->before_after_data;
 
-		fe->ioctl(fe, FE_GET_INFO, &info);
+	struct dvb_frontend_info info;
+	
+	fe->ioctl(fe, FE_GET_INFO, &info);
 			
-		if ( strcmp(info.name, "Zarlink MT312") == 0)
-		{
-		    dprintk("%s: FE_SET_TONE for %s frontend\n", __FUNCTION__, info.name);
-
-		    switch ((fe_sec_tone_mode_t) arg)
-		    {
-			case SEC_TONE_ON:
+	// we must use different DiSEqC hw
+	
+	if ( strcmp(info.name, "Zarlink MT312") == 0){
+		//VP310 using mt312 driver for tuning only: diseqc not wired
+		//use FCII instead
+		if (!soft_diseqc(adapter,cmd,arg)) 
+			return 0;
+	}
+	
+	switch (cmd) {
+	    case FE_SLEEP:
+	    {
+			dprintk("%s: FE_SLEEP\n", __FUNCTION__);
 
-			    dprintk("%s: SEC_TONE_ON, %x\n", __FUNCTION__, SEC_TONE_ON);
+			set_tuner_polarity(adapter, 0);
 
-			    set_tuner_tone(adapter, 1);
+			// return -EOPNOTSUPP, to make DVB core also send "FE_SLEEP" command to frontend.
+			return -EOPNOTSUPP;
+	    }
 
-			    return 0;
+	    case FE_SET_VOLTAGE:
+	    {
+			dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
 
-			case SEC_TONE_OFF:
+			switch ((fe_sec_voltage_t) arg)
+			{
+				case SEC_VOLTAGE_13:
 
-			    dprintk("%s: SEC_TONE_OFF, %x\n", __FUNCTION__, SEC_TONE_OFF);
+					dprintk("%s: SEC_VOLTAGE_13, %x\n", __FUNCTION__, SEC_VOLTAGE_13);
 
-			    set_tuner_tone(adapter, 0);
+					set_tuner_polarity(adapter, 1);
 
-			    return 0;
+					return 0;
 
-			default:
+				case SEC_VOLTAGE_18:
 
-			    return -EINVAL;
-		    };
+					dprintk("%s: SEC_VOLTAGE_18, %x\n", __FUNCTION__, SEC_VOLTAGE_18);
 
-		};
-			
-		if ( strcmp(info.name, "STV0299/TSA5059/SL1935 based") == 0)
-		{
-		    dprintk("%s: FE_SET_TONE for %s frontend\n", __FUNCTION__, info.name);
+					set_tuner_polarity(adapter, 2);
 
-		    /* allow the frontend driver to handle this command*/
-		    return -EOPNOTSUPP;
-		};
+					return 0;
 
-		printk("%s: FE_SET_TONE unknown frontend : %s\n", __FUNCTION__, info.name);
+				default:
 
-		return -EINVAL;
+					return -EINVAL;
+			};
 	    }
+
 
 	    default:
 	    

Home | Main Index | Thread Index