Mailing List archive

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

[linux-dvb] Re: dvb-kernel budget



> Could you please explain a little more in detail how you want to do this?

I'd cut-paste hardware 7146 diseqc ioctl related stuff from budget-core.c
to budget_diseqc.c, and modify budget.h and Makefile's accordingly.

In the next step, another diseqc hardware ioctl commands will go to 
another file: <hardware>_diseqc.c and it will be linked to budget-core
for making ttpci-budget kernel module

I think that it is more clean that budget-core contains just data stream 
transport functions around vpeirq, while access to different small hardware 
is done by linking another files.o for various hardware diseqc, video 
modules etc.

Exact separation patch for diseqc is attached below

Emard
diff -pur --new-file orig/dvb-kernel/build-2.4/Makefile dvb-kernel/build-2.4/Makefile
--- orig/dvb-kernel/build-2.4/Makefile	Tue Feb 11 20:25:54 2003
+++ dvb-kernel/build-2.4/Makefile	Thu Feb 13 22:06:40 2003
@@ -7,8 +7,8 @@ MDIR		:= misc
 saa7146-objs    := saa7146_i2c.o saa7146_core.o 
 saa7146-vv-objs	:= saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o  
 
-dvb-ttpci-budget-objs := budget-core.o budget.o
-dvb-ttpci-budget-av-objs := budget-core.o budget-av.o
+dvb-ttpci-budget-objs := budget-core.o budget_diseqc.o budget.o
+dvb-ttpci-budget-av-objs := budget-core.o budget_diseqc.o budget-av.o
 
 dvb-ttpci-objs	  := av7110.o av7110_ir.o av7110_ipack.o
 
diff -pur --new-file orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/Makefile dvb-kernel/linux/drivers/media/dvb/ttpci-budget/Makefile
--- orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/Makefile	Thu Jan  9 11:27:22 2003
+++ dvb-kernel/linux/drivers/media/dvb/ttpci-budget/Makefile	Thu Feb 13 22:06:40 2003
@@ -5,7 +5,7 @@
 dvb-ttpci-budget-objs := budget.o
 dvb-ttpci-budget-av-objs := budget-av.o
 
-obj-$(CONFIG_DVB_BUDGET) += budget-core.o dvb-ttpci-budget.o
-obj-$(CONFIG_DVB_BUDGET_AV) += budget-core.o dvb-ttpci-budget-av.o
+obj-$(CONFIG_DVB_BUDGET) += budget-core.o budget_diseqc.c dvb-ttpci-budget.o
+obj-$(CONFIG_DVB_BUDGET_AV) += budget-core.o budget_diseqc.c dvb-ttpci-budget-av.o
 
 EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -I$(src)/../../common/ -I$(src)/../../common/saa7146
diff -pur --new-file orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c
--- orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c	Thu Feb 13 13:08:34 2003
+++ dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget-core.c	Thu Feb 13 22:06:40 2003
@@ -39,12 +39,6 @@ vmalloc_to_sg(unsigned char *virt, int n
 }
 
 
-static inline void ddelay(int i) 
-{
-        current->state=TASK_INTERRUPTIBLE;
-        schedule_timeout((HZ*i)/100);
-}
-
 /****************************************************************************
  * TT budget / WinTV Nova
  ****************************************************************************/
@@ -135,77 +129,6 @@ static void vpeirq (unsigned long data)
         }
 }
 
-inline static void 
-Set22K(struct budget_s *budget, int state)
-{
-        struct saa7146_dev *dev=budget->dev;
- 	DEB_EE(("budget: %p\n",budget));
-	saa7146_setgpio(dev, 3, (state ? SAA7146_GPIO_OUTHI : SAA7146_GPIO_OUTLO));
-}
-
-
-/* Diseqc functions only for TT Budget card */
-/* taken from the Skyvision DVB driver by 
-   Ralph Metzler <rjkm@metzlerbros.de> */
-
-inline static void 
-DiseqcSendBit(struct budget_s *budget, int data)
-{
-        struct saa7146_dev *dev=budget->dev;
- 	DEB_EE(("budget: %p\n",budget));
-
-        saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
-        udelay(data ? 500 : 1000);
-        saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
-        udelay(data ? 1000 : 500);
-}
-
-static void 
-DiseqcSendByte(struct budget_s *budget, int data)
-{
-        int i, par=1, d;
-
- 	DEB_EE(("budget: %p\n",budget));
-
-        for (i=7; i>=0; i--) 
-        {
-                d=(data>>i)&1;
-                par^=d;
-                DiseqcSendBit(budget, d);
-        }
-        DiseqcSendBit(budget, par);
-}
-
-inline static int
-SendDiSEqCMsg(struct budget_s *budget, int len, u8 *msg, int burst)
-{
-        struct saa7146_dev *dev=budget->dev;
-        int i;
-
- 	DEB_EE(("budget: %p\n",budget));
-
-	saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
-	mdelay(16);
-
-	for (i=0; i<len; i++)
-		DiseqcSendByte(budget, msg[i]);
-
-	mdelay(16);
-	 
-	if (burst!=-1) {
-		if (burst) 
-			DiseqcSendByte(budget, 0xff);
-		else {
-			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
-			udelay(12500);
-			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
-		}
-		ddelay(2);
-	}
-	
-        return 0;
-}
-
 /****************************************************************************
  * DVB API SECTION
  ****************************************************************************/
@@ -233,50 +156,6 @@ budget_stop_feed(struct dvb_demux_feed *
 	DEB_EE(("budget: %p\n",budget));
 
 	return TTBStop(budget); 
-}
-
-/******************************************************************************
- * SEC device file operations
- ******************************************************************************/
-
-static
-int budget_diseqc_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
-{
-	struct budget_s *budget = fe->before_after_data;
-
-	DEB_EE(("budget: %p\n",budget));
-
-	switch (cmd) {
-	case FE_SET_TONE:
-		switch ((fe_sec_tone_mode_t) arg) {
-		case SEC_TONE_ON:
-			Set22K (budget, 1);
-			break;
-		case SEC_TONE_OFF:
-			Set22K (budget, 0);
-			break;
-		default:
-			return -EINVAL;
-		};
-		break;
-
-	case FE_DISEQC_SEND_MASTER_CMD:
-	{
-		struct dvb_diseqc_master_cmd *cmd = arg;
-
-		SendDiSEqCMsg (budget, cmd->msg_len, cmd->msg, 0);
-		break;
-	}
-
-	case FE_DISEQC_SEND_BURST:
-		SendDiSEqCMsg (budget, 0, NULL, (int) arg);
-		break;
-
-	default:
-		return -EOPNOTSUPP;
-	};
-
-	return 0;
 }
 
 int budget_register(struct budget_s *budget)
diff -pur --new-file orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget.h dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget.h
--- orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget.h	Thu Feb 13 13:08:34 2003
+++ dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget.h	Thu Feb 13 22:07:05 2003
@@ -80,5 +80,6 @@ void budget_irq(struct saa7146_dev *, u3
 int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info);
 int budget_detach (struct saa7146_dev *);
 int budget_register(struct budget_s *budget);
+int budget_diseqc_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg);
 
 #endif
diff -pur --new-file orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget_diseqc.c dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget_diseqc.c
--- orig/dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget_diseqc.c	Thu Jan  1 01:00:00 1970
+++ dvb-kernel/linux/drivers/media/dvb/ttpci-budget/budget_diseqc.c	Thu Feb 13 22:06:40 2003
@@ -0,0 +1,126 @@
+#include "budget.h"
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51)
+        #define KBUILD_MODNAME budget
+#endif
+
+static inline void ddelay(int i) 
+{
+        current->state=TASK_INTERRUPTIBLE;
+        schedule_timeout((HZ*i)/100);
+}
+
+
+inline static void 
+Set22K(struct budget_s *budget, int state)
+{
+        struct saa7146_dev *dev=budget->dev;
+ 	DEB_EE(("budget: %p\n",budget));
+	saa7146_setgpio(dev, 3, (state ? SAA7146_GPIO_OUTHI : SAA7146_GPIO_OUTLO));
+}
+
+
+/* Diseqc functions only for TT Budget card */
+/* taken from the Skyvision DVB driver by 
+   Ralph Metzler <rjkm@metzlerbros.de> */
+
+inline static void 
+DiseqcSendBit(struct budget_s *budget, int data)
+{
+        struct saa7146_dev *dev=budget->dev;
+ 	DEB_EE(("budget: %p\n",budget));
+
+        saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
+        udelay(data ? 500 : 1000);
+        saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
+        udelay(data ? 1000 : 500);
+}
+
+static void 
+DiseqcSendByte(struct budget_s *budget, int data)
+{
+        int i, par=1, d;
+
+ 	DEB_EE(("budget: %p\n",budget));
+
+        for (i=7; i>=0; i--) 
+        {
+                d=(data>>i)&1;
+                par^=d;
+                DiseqcSendBit(budget, d);
+        }
+        DiseqcSendBit(budget, par);
+}
+
+inline static int
+SendDiSEqCMsg(struct budget_s *budget, int len, u8 *msg, int burst)
+{
+        struct saa7146_dev *dev=budget->dev;
+        int i;
+
+ 	DEB_EE(("budget: %p\n",budget));
+
+	saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
+	mdelay(16);
+
+	for (i=0; i<len; i++)
+		DiseqcSendByte(budget, msg[i]);
+
+	mdelay(16);
+	 
+	if (burst!=-1) {
+		if (burst) 
+			DiseqcSendByte(budget, 0xff);
+		else {
+			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
+			udelay(12500);
+			saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
+		}
+		ddelay(2);
+	}
+	
+        return 0;
+}
+
+/******************************************************************************
+ * SEC device file operations
+ ******************************************************************************/
+
+int budget_diseqc_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
+{
+	struct budget_s *budget = fe->before_after_data;
+
+	DEB_EE(("budget: %p\n",budget));
+
+	switch (cmd) {
+	case FE_SET_TONE:
+		switch ((fe_sec_tone_mode_t) arg) {
+		case SEC_TONE_ON:
+			Set22K (budget, 1);
+			break;
+		case SEC_TONE_OFF:
+			Set22K (budget, 0);
+			break;
+		default:
+			return -EINVAL;
+		};
+		break;
+
+	case FE_DISEQC_SEND_MASTER_CMD:
+	{
+		struct dvb_diseqc_master_cmd *cmd = arg;
+
+		SendDiSEqCMsg (budget, cmd->msg_len, cmd->msg, 0);
+		break;
+	}
+
+	case FE_DISEQC_SEND_BURST:
+		SendDiSEqCMsg (budget, 0, NULL, (int) arg);
+		break;
+
+	default:
+		return -EOPNOTSUPP;
+	};
+
+	return 0;
+}
+

Home | Main Index | Thread Index