diff -Nru ./dvb-kernel/linux/drivers/media/dvb/b2c2/skystar2.c ./dvb-kernel.new/linux/drivers/media/dvb/b2c2/skystar2.c
--- ./dvb-kernel/linux/drivers/media/dvb/b2c2/skystar2.c	2003-10-31 17:44:54.000000000 +0200
+++ ./dvb-kernel.new/linux/drivers/media/dvb/b2c2/skystar2.c	2003-11-06 20:30:15.000000000 +0200
@@ -2,7 +2,7 @@
  * skystar2.c - driver for the Technisat SkyStar2 PCI DVB card
  *              based on the FlexCopII by B2C2,Inc.
  *
- * Copyright (C) 2003  V.C. , skystar@moldova.cc
+ * Copyright (C) 2003  Vadim Catana, skystar@moldova.cc
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -224,7 +224,7 @@
 	u32 bytes_to_transfer;
 	u8 *start;
 
-//	dprintk("%s:\n", __FUNCTION__);
+	dprintk("%s:\n", __FUNCTION__);
 
 	start = buf;
 
@@ -253,7 +253,7 @@
 	u32 bytes_to_transfer;
 	u8 *start;
 
-//	dprintk("%s:\n", __FUNCTION__);
+	dprintk("%s:\n", __FUNCTION__);
 
 	start = buf;
 
@@ -284,59 +284,68 @@
 	if (down_interruptible(&tmp->i2c_sem))
 		return -ERESTARTSYS;
 
-	if (0) {
-		dprintk("%s:\n", __FUNCTION__);
+	dprintk("%s: %d messages to transfer\n", __FUNCTION__, num);
+
+	for (i = 0; i < num; i++)
+	{
+		dprintk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
+				      msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
 
-		for (i = 0; i < num; i++) {
-			printk("message %d: flags=%x, addr=0x%04x, buf=%p, len=%d \n", i, msgs[i].flags, msgs[i].addr, msgs[i].buf, msgs[i].len);
+		/* allow only the mt312 and stv0299 frontends to access the bus */
+		if ((msgs[i].addr != 0x0E) && (msgs[i].addr != 0x68) && (msgs[i].addr != 0x61) )
+		{
+		    up(&tmp->i2c_sem);
+
+		    return -EREMOTEIO;
 		}
 	}
-	
-	/* allow only the vp310 frontend to access the bus */
-	if ((msgs[0].addr != 0x0E) && (msgs[0].addr != 0x61)) {
-		up(&tmp->i2c_sem);
 
-		return -EREMOTEIO;
-	}
+	// read command
+	if ( (num == 2) && (msgs[0].flags == 0) && (msgs[1].flags == I2C_M_RD) && 
+	     (msgs[0].buf != NULL) && (msgs[1].buf != NULL) )
+	{
+	    ret = FLEXI2C_read(tmp, 0x10000000, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len);
 
-	if ((num == 1) && (msgs[0].buf != NULL)) {
-		if (msgs[0].flags == I2C_M_RD) {
-			ret = -EINVAL;
+    	    up(&tmp->i2c_sem);
 
-		} else {
+	    if (ret != msgs[1].len)
+	    {
+		printk("%s: read error !\n", __FUNCTION__);
 
-			// single writes do have the reg addr in buf[0] and data in buf[1] to buf[n]
-			ret = FLEXI2C_write(tmp, 0x10000000, msgs[0].addr, msgs[0].buf[0], &msgs[0].buf[1], msgs[0].len - 1);
+		printk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
+				      msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
 
-			if (ret != msgs[0].len - 1)
-				ret = -EREMOTEIO;
-			else
-				ret = num;
-		}
+		return -EREMOTEIO;
+	    }
+	    
+	    return num;
+	}
 
-	} else if ((num == 2) && (msgs[1].buf != NULL)) {
+	// write command
+	for (i = 0; i < num; i++) {
 
-		// i2c reads consist of a reg addr _write_ followed by a data read, so msg[1].flags has to be examined
-		if (msgs[1].flags == I2C_M_RD) {
-			ret = FLEXI2C_read(tmp, 0x10000000, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len);
+	    if ( (msgs[i].flags != 0) || (msgs[i].buf == NULL) || ( msgs[i].len < 2 ) ) return -EINVAL;
 
-		} else {
+	    ret = FLEXI2C_write(tmp, 0x10000000, msgs[i].addr, msgs[i].buf[0], &msgs[i].buf[1], msgs[i].len - 1);
 
-			ret = FLEXI2C_write(tmp, 0x10000000, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len);
-		}
+    	    up(&tmp->i2c_sem);
 
-		if (ret != msgs[1].len)
-			ret = -EREMOTEIO;
-		else
-			ret = num;
-	}
+	    if (ret != msgs[0].len - 1)
+	    {
+		printk("%s: write error %i !\n", __FUNCTION__, ret);
 
-	up(&tmp->i2c_sem);
+		printk("message %d: flags=0x%x, addr=0x%x, buf[0]=0x%x, len=%d \n", i,
+				      msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
+	    
+		return -EREMOTEIO;
+	    }
+		
+	    return num;
+	}
 
-	/* master xfer functions always return the number of successfully
-	   transmitted messages, not the number of transmitted bytes.
-	   return -EREMOTEIO in case of failure. */
-	return ret;
+	printk("%s: unknown command format !\n", __FUNCTION__);
+	
+	return -EINVAL;
 }
 
 /* SRAM (Skystar2 rev2.3 has one "ISSI IS61LV256" chip on board,
@@ -811,31 +820,9 @@
 }
 */
 
-/* These functions could be called from the initialization routine 
-   to unlock SkyStar2 cards, locked by "Europe On Line".
-        
-   in cards from "Europe On Line" the key is:
- 
-       u8 key[20] = {
- 	    0xB2, 0x01, 0x00, 0x00,
- 	    0x00, 0x00, 0x00, 0x00,
- 	    0x00, 0x00, 0x00, 0x00,
- 	    0x00, 0x00, 0x00, 0x00,
-       };
-
-       LRC = 0xB3;
-
-  in unlocked cards the key is:
-
-       u8 key[20] = {
- 	    0xB2, 0x00, 0x00, 0x00,
- 	    0x00, 0x00, 0x00, 0x00,
- 	    0x00, 0x00, 0x00, 0x00,
- 	    0x00, 0x00, 0x00, 0x00,
-       };
 
-      LRC = 0xB2;
-*/
+/* These functions could be used to unlock SkyStar2 cards. */
+
 /*
 static int EEPROM_writeKey(struct adapter *adapter, u8 * key, u32 len)
 {
@@ -854,7 +841,7 @@
 
 	return EEPROM_LRC_write(adapter, 0x3E4, 20, wbuf, rbuf, 4);
 }
-*/
+
 static int EEPROM_readKey(struct adapter *adapter, u8 * key, u32 len)
 {
 	u8 buf[20];
@@ -869,6 +856,7 @@
 
 	return 1;
 }
+*/
 
 static int EEPROM_getMacAddr(struct adapter *adapter, char type, u8 * mac)
 {
@@ -1839,9 +1827,9 @@
 		nNumNewBytesTransferred = (adapter->dmaq1.buffer_size - adapter->dmaq1.tail) + nCurDmaCounter;
 	}
 
-//	dprintk("%s: nCurDmaCounter   = %d\n" , __FUNCTION__, nCurDmaCounter);
-//	dprintk("%s: dmaq1.tail       = %d\n" , __FUNCTION__, adapter->dmaq1.tail):
-//	dprintk("%s: BytesTransferred = %d\n" , __FUNCTION__, nNumNewBytesTransferred);
+	dprintk("%s: nCurDmaCounter   = %d\n" , __FUNCTION__, nCurDmaCounter);
+	dprintk("%s: dmaq1.tail       = %d\n" , __FUNCTION__, adapter->dmaq1.tail);
+	dprintk("%s: BytesTransferred = %d\n" , __FUNCTION__, nNumNewBytesTransferred);
 
 	if (nNumNewBytesTransferred < dwDefaultPacketSize)
 		return;
@@ -1871,12 +1859,13 @@
 			packet_header.continuity_counter = (*dq & 0x0F000000) >> 0x18;
 
 			if ((packet_header.sync_byte == 0x47) && (packet_header.transport_error_indicator == 0) && (packet_header.pid != 0x1FFF)) {
-				if (CheckPID(adapter, packet_header.pid & 0x0000FFFF) != 0) {
-					dvb_dmx_swfilter_packets(dvbdmx, pbDMABufCurPos, dwDefaultPacketSize / 188);
+				if (CheckPID(adapter, packet_header.pid & 0x0000FFFF) != 0)
+				{
+				    dvb_dmx_swfilter_packets(dvbdmx, pbDMABufCurPos, dwDefaultPacketSize / 188);
 
 				} else {
 
-//				dprintk("%s: pid=%x\n", __FUNCTION__, packet_header.pid);
+				    dprintk("%s: pid=%x\n", __FUNCTION__, packet_header.pid);
 				}
 			}
 		}
@@ -1901,7 +1890,7 @@
 
 	u32 value;
 
-//	dprintk("%s:\n", __FUNCTION__);
+	dprintk("%s:\n", __FUNCTION__);
 
 	spin_lock_irq(&tmp->lock);
 
@@ -2075,8 +2064,7 @@
 {
 	struct adapter *adapter;
 	u32 tmp;
-	u8 key[16];
-
+	
 	if (!(adapter = kmalloc(sizeof(struct adapter), GFP_KERNEL))) {
 		dprintk("%s: out of memory!\n", __FUNCTION__);
 
@@ -2177,10 +2165,6 @@
 		CtrlEnableMAC(adapter, 1);
 	}
 
-	EEPROM_readKey(adapter, key, 16);
-
-	printk("%s key = \n %02x %02x %02x %02x \n %02x %02x %02x %02x \n %02x %02x %02x %02x \n %02x %02x %02x %02x \n", __FUNCTION__, key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7], key[8], key[9], key[10], key[11], key[12], key[13], key[14], key[15]);
-
 	adapter->lock = SPIN_LOCK_UNLOCKED;
 
 	return 0;
@@ -2294,78 +2278,101 @@
 {
 	struct adapter *adapter = fe->before_after_data;
 
+	struct dvb_frontend_info info;
+	
 	switch (cmd) {
-	case FE_SLEEP:
-		{
-			printk("%s: FE_SLEEP\n", __FUNCTION__);
 
-			set_tuner_polarity(adapter, 0);
+	    case FE_SLEEP:
+	    {
+		dprintk("%s: FE_SLEEP\n", __FUNCTION__);
 
-			// return -EOPNOTSUPP, to make DVB core also send "FE_SLEEP" command to frontend.
-			return -EOPNOTSUPP;
-		}
+		set_tuner_polarity(adapter, 0);
 
-	case FE_SET_VOLTAGE:
-		{
-			dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
+		// return -EOPNOTSUPP, to make DVB core also send "FE_SLEEP" command to frontend.
+		return -EOPNOTSUPP;
+	    }
+
+	    case FE_SET_VOLTAGE:
+	    {
+		dprintk("%s: FE_SET_VOLTAGE\n", __FUNCTION__);
 
-			switch ((fe_sec_voltage_t) arg) {
+		switch ((fe_sec_voltage_t) arg)
+		{
 			case SEC_VOLTAGE_13:
 
-				printk("%s: SEC_VOLTAGE_13, %x\n", __FUNCTION__, SEC_VOLTAGE_13);
+				dprintk("%s: SEC_VOLTAGE_13, %x\n", __FUNCTION__, SEC_VOLTAGE_13);
 
 				set_tuner_polarity(adapter, 1);
 
-				break;
+				return 0;
 
 			case SEC_VOLTAGE_18:
 
-				printk("%s: SEC_VOLTAGE_18, %x\n", __FUNCTION__, SEC_VOLTAGE_18);
+				dprintk("%s: SEC_VOLTAGE_18, %x\n", __FUNCTION__, SEC_VOLTAGE_18);
 
 				set_tuner_polarity(adapter, 2);
 
-				break;
+				return 0;
 
 			default:
 
 				return -EINVAL;
-			};
+		};
 
-			break;
-		}
+	    }
 
-	case FE_SET_TONE:
+	    case FE_SET_TONE:
+	    {
+		dprintk("%s: FE_SET_TONE\n", __FUNCTION__);
+
+		fe->ioctl(fe, FE_GET_INFO, &info);
+			
+		if ( strcmp(info.name, "Zarlink MT312") == 0)
 		{
-			dprintk("%s: FE_SET_TONE\n", __FUNCTION__);
+		    dprintk("%s: FE_SET_TONE for %s frontend\n", __FUNCTION__, info.name);
 
-			switch ((fe_sec_tone_mode_t) arg) {
+		    switch ((fe_sec_tone_mode_t) arg)
+		    {
 			case SEC_TONE_ON:
 
-				printk("%s: SEC_TONE_ON, %x\n", __FUNCTION__, SEC_TONE_ON);
+			    dprintk("%s: SEC_TONE_ON, %x\n", __FUNCTION__, SEC_TONE_ON);
 
-				set_tuner_tone(adapter, 1);
+			    set_tuner_tone(adapter, 1);
 
-				break;
+			    return 0;
 
 			case SEC_TONE_OFF:
 
-				printk("%s: SEC_TONE_OFF, %x\n", __FUNCTION__, SEC_TONE_OFF);
+			    dprintk("%s: SEC_TONE_OFF, %x\n", __FUNCTION__, SEC_TONE_OFF);
 
-				set_tuner_tone(adapter, 0);
+			    set_tuner_tone(adapter, 0);
 
-				break;
+			    return 0;
 
 			default:
 
-				return -EINVAL;
-			};
+			    return -EINVAL;
+		    };
 
-			break;
-		}
+		};
+			
+		if ( strcmp(info.name, "STV0299/TSA5059/SL1935 based") == 0)
+		{
+		    dprintk("%s: FE_SET_TONE for %s frontend\n", __FUNCTION__, info.name);
 
-	default:
+		    /* allow the frontend driver to handle this command*/
+		    return -EOPNOTSUPP;
+		};
+
+		printk("%s: FE_SET_TONE unknown frontend : %s\n", __FUNCTION__, info.name);
+
+		return -EINVAL;
+	    }
+
+	    default:
+	    
+	        return -EOPNOTSUPP;
 
-		return -EOPNOTSUPP;
 	};
 
 	return 0;
diff -Nru ./dvb-kernel/linux/drivers/media/dvb/frontends/stv0299.c ./dvb-kernel.new/linux/drivers/media/dvb/frontends/stv0299.c
--- ./dvb-kernel/linux/drivers/media/dvb/frontends/stv0299.c	2003-10-09 02:12:46.000000000 +0300
+++ ./dvb-kernel.new/linux/drivers/media/dvb/frontends/stv0299.c	2003-11-06 20:44:58.000000000 +0200
@@ -19,6 +19,12 @@
     Copyright (C) 2002 Felix Domke <tmbinc@elitedvb.net>
                      & Andreas Oberritter <andreas@oberritter.de>
 
+    Changelog :
+    
+	    Vadim Catana <skystar@moldova.cc>:
+		added support for Samsung TBMU24112IMB used on Technisat SkyStar2 rev. 2.6B
+
+
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
@@ -39,6 +45,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <asm/div64.h>
 
 #include "dvb_frontend.h"
 #include "dvb_functions.h"
@@ -51,11 +58,12 @@
 
 
 /* frontend types */
-#define UNKNOWN_FRONTEND  -1
-#define PHILIPS_SU1278SH   0
-#define ALPS_BSRU6         1
-#define LG_TDQF_S001F      2
-#define PHILIPS_SU1278     3
+#define UNKNOWN_FRONTEND       -1
+#define PHILIPS_SU1278SH        0
+#define ALPS_BSRU6              1
+#define LG_TDQF_S001F           2
+#define PHILIPS_SU1278          3
+#define SAMSUNG_TBMU24112IMB    4
 
 /* Master Clock = 88 MHz */
 #define M_CLK (88000000UL) 
@@ -142,6 +150,51 @@
 };
 
 
+static u8 init_tab_samsung [] = {
+    0x01, 0x15,
+    0x02, 0x00,
+    0x03, 0x00,
+    0x04, 0x7D,
+    0x05, 0x35,
+    0x06, 0x02,
+    0x07, 0x00,
+    0x08, 0xC3,
+    0x0C, 0x00,
+    0x0D, 0x81,
+    0x0E, 0x23,
+    0x0F, 0x12,
+    0x10, 0x7E,
+    0x11, 0x84,
+    0x12, 0xB9,
+    0x13, 0x88,
+    0x14, 0x89,
+    0x15, 0xC9,
+    0x16, 0x00,
+    0x17, 0x5C,
+    0x18, 0x00,
+    0x19, 0x00,
+    0x1A, 0x00,
+    0x1C, 0x00,
+    0x1D, 0x00,
+    0x1E, 0x00,
+    0x1F, 0x3A,
+    0x20, 0x2E,
+    0x21, 0x80,
+    0x22, 0xFF,
+    0x23, 0xC1,
+    0x28, 0x00,
+    0x29, 0x1E,
+    0x2A, 0x14,
+    0x2B, 0x0F,
+    0x2C, 0x09,
+    0x2D, 0x05,
+    0x31, 0x1F,
+    0x32, 0x19,
+    0x33, 0xFE,
+    0x34, 0xB3
+};
+
+
 static int stv0299_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
 {
 	int ret;
@@ -193,18 +246,19 @@
 static int pll_write (struct dvb_i2c_bus *i2c, u8 addr, u8 *data, int len)
 {
 	int ret;
-	u8 rpt1 [] = { 0x05, 0xb5 };  /*  enable i2c repeater on stv0299  */
-	u8 rpt2 [] = { 0x05, 0x35 };  /*  disable i2c repeater on stv0299  */
-	struct i2c_msg msg [] = {{ .addr = 0x68, .flags = 0, .buf = rpt1, .len = 2 },
-			         { addr: addr, .flags = 0, .buf = data, .len = len },
-				 { .addr = 0x68, .flags = 0, .buf = rpt2, .len = 2 }};
+	struct i2c_msg msg = { addr: addr, .flags = 0, .buf = data, .len = len };
+
+
+	stv0299_writereg(i2c, 0x05, 0xb5);	/*  enable i2c repeater on stv0299  */
 
-	ret = i2c->xfer (i2c, msg, 3);
+	ret =  i2c->xfer (i2c, &msg, 1);
 
-	if (ret != 3)
-		printk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
+	stv0299_writereg(i2c, 0x05, 0x35);	/*  disable i2c repeater on stv0299  */
 
-	return (ret != 3) ? ret : 0;
+	if (ret != 1)
+		dprintk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
+
+	return (ret != 1) ? -1 : 0;
 }
 
 
@@ -213,23 +267,16 @@
 	u8 buf[4];
 	u32 div;
 
-	u32 ratios[] = { 2000, 1000, 500, 250, 125 };
-	u8 ratio;
+	div = freq / 125;
 
-	for (ratio = 4; ratio > 0; ratio--)
-		if ((freq / ratios[ratio]) <= 0x3fff)
-			break;
+	dprintk("%s : freq = %i, div = %i\n", __FUNCTION__, freq, div);
 
-	div = freq / ratios[ratio];
+	buf[0] = (div >> 8) & 0x7f;
+	buf[1] = div & 0xff;
+	buf[2] = 0x84;	// 0xC4
+	buf[3] = 0x08;
 
-	buf[0] = (freq >> 8) & 0x7f;
-	buf[1] = freq & 0xff;
-	buf[2] = 0x80 | ratio;
-
-	if (freq < 1531000)
-		buf[3] = 0x10;
-	else
-		buf[3] = 0x00;
+	if (freq < 1500000) buf[3] |= 0x10;
 
 	return pll_write (i2c, 0x61, buf, sizeof(buf));
 }
@@ -385,7 +432,9 @@
 
 static int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype, int srate)
 {
-	if (ftype == LG_TDQF_S001F)
+	if (ftype == SAMSUNG_TBMU24112IMB)
+		return sl1935_set_tv_freq(i2c, freq, ftype);
+	else if (ftype == LG_TDQF_S001F)
 		return sl1935_set_tv_freq(i2c, freq, ftype);
 	else if (ftype == PHILIPS_SU1278)
 		return tua6100_set_tv_freq(i2c, freq, ftype, srate);
@@ -421,6 +470,20 @@
 
 	dprintk("stv0299: init chip\n");
 
+	if(ftype == SAMSUNG_TBMU24112IMB)
+	{
+	    dprintk("%s: init stv0299 chip for Samsung TBMU24112IMB\n", __FUNCTION__);
+
+	    for (i=0; i<sizeof(init_tab_samsung); i+=2)
+	    {
+	    	dprintk("%s: reg == 0x%02x, val == 0x%02x\n", __FUNCTION__, init_tab_samsung[i], init_tab_samsung[i+1]);
+
+		stv0299_writereg (i2c, init_tab_samsung[i], init_tab_samsung[i+1]);
+	    }
+
+	    return 0;	
+	}
+
 	stv0299_writereg (i2c, 0x01, 0x15);
 	stv0299_writereg (i2c, 0x02, ftype == PHILIPS_SU1278 ? 0x00 : 0x30);
 	stv0299_writereg (i2c, 0x03, 0x00);
@@ -448,6 +511,7 @@
 		dvb_delay(30);
 		if ((stv0299_readreg (i2c, 0x1b) & 0x98) != 0x98) {
 			u8 val = stv0299_readreg (i2c, 0x0c);
+			dprintk ("%s : changing inversion\n", __FUNCTION__);
 			return stv0299_writereg (i2c, 0x0c, val ^ 0x01);
 		}
 	}
@@ -462,20 +526,41 @@
 
 	switch (fec) {
 	case FEC_AUTO:
+	{
+		dprintk ("%s : FEC_AUTO\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x31, 0x1f);
+	}
 	case FEC_1_2:
+	{
+		dprintk ("%s : FEC_1_2\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x31, 0x01);
+	}
 	case FEC_2_3:
+	{
+		dprintk ("%s : FEC_2_3\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x31, 0x02);
+	}
 	case FEC_3_4:
+	{
+		dprintk ("%s : FEC_3_4\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x31, 0x04);
+	}
 	case FEC_5_6:
+	{
+		dprintk ("%s : FEC_5_6\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x31, 0x08);
+	}
 	case FEC_7_8:
+	{
+		dprintk ("%s : FEC_7_8\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x31, 0x10);
+	}
 	default:
+	{
+		dprintk ("%s : FEC invalid\n", __FUNCTION__);
 		return -EINVAL;
 	}
+    }
 }
 
 
@@ -606,11 +691,20 @@
 
 	switch (tone) {
 	case SEC_TONE_ON:
+	{
+	    	dprintk("%s: TONE_ON\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x08, val | 0x3);
+	}	
 	case SEC_TONE_OFF:
+	{
+	    	dprintk("%s: TONE_OFF\n", __FUNCTION__);
 		return stv0299_writereg (i2c, 0x08, (val & ~0x3) | 0x02);
+	}
 	default:
+	{
+	    	dprintk("%s: TONE INVALID\n", __FUNCTION__);
 		return -EINVAL;
+	}
 	};
 }
 
@@ -653,8 +747,9 @@
 
 static int stv0299_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
 {
+	u64 big = srate;
 	u32 ratio;
-	u32 tmp;
+
 	u8 aclk = 0xb4, bclk = 0x51;
 
 	if (srate > M_CLK)
@@ -668,19 +763,23 @@
 	if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
 	if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
 
-#define FIN (M_CLK >> 4)
-
-	tmp = srate << 4;
-	ratio = tmp / FIN;
-        
-	tmp = (tmp % FIN) << 8;
-	ratio = (ratio << 8) + tmp / FIN;
-        
-	tmp = (tmp % FIN) << 8;
-	ratio = (ratio << 8) + tmp / FIN;
-  
 	stv0299_writereg (i2c, 0x13, aclk);
 	stv0299_writereg (i2c, 0x14, bclk);
+
+	dprintk("%s : big = 0x%08x%08x\n", __FUNCTION__, (int) ((big>>32) & 0xffffffff),  (int) (big & 0xffffffff) );
+
+	big = big << 20;
+
+	dprintk("%s : big = 0x%08x%08x\n", __FUNCTION__, (int) ((big>>32) & 0xffffffff),  (int) (big & 0xffffffff) );
+
+	do_div(big, M_CLK);
+
+	dprintk("%s : big = 0x%08x%08x\n", __FUNCTION__, (int) ((big>>32) & 0xffffffff),  (int) (big & 0xffffffff) );
+
+	ratio = big << 4;
+
+	dprintk("%s : ratio = %i\n", __FUNCTION__, ratio);
+
 	stv0299_writereg (i2c, 0x1f, (ratio >> 16) & 0xff);
 	stv0299_writereg (i2c, 0x20, (ratio >>  8) & 0xff);
 	stv0299_writereg (i2c, 0x21, (ratio      ) & 0xf0);
@@ -710,6 +809,9 @@
 	offset = (s32) rtf * (srate / 4096L);
 	offset /= 128;
 
+	dprintk ("%s : srate = %i\n", __FUNCTION__, srate);
+	dprintk ("%s : ofset = %i\n", __FUNCTION__, offset);
+
 	srate += offset;
 
 	srate += 1000;
@@ -725,6 +827,8 @@
         int tuner_type = (long) fe->data;
 	struct dvb_i2c_bus *i2c = fe->i2c;
 
+	dprintk ("%s\n", __FUNCTION__);
+
 	switch (cmd) {
 	case FE_GET_INFO:
 		memcpy (arg, &uni0299_info, sizeof(struct dvb_frontend_info));
@@ -736,7 +840,7 @@
 		u8 signal = 0xff - stv0299_readreg (i2c, 0x18);
 		u8 sync = stv0299_readreg (i2c, 0x1b);
 
-		dprintk ("VSTATUS: 0x%02x\n", sync);
+		dprintk ("%s : FE_READ_STATUS : VSTATUS: 0x%02x\n", __FUNCTION__, sync);
 
 		*status = 0;
 
@@ -768,7 +872,7 @@
 		s32 signal =  0xffff - ((stv0299_readreg (i2c, 0x18) << 8)
 			               | stv0299_readreg (i2c, 0x19));
 
-		dprintk ("AGC2I: 0x%02x%02x, signal=0x%04x\n",
+		dprintk ("%s : FE_READ_SIGNAL_STRENGTH : AGC2I: 0x%02x%02x, signal=0x%04x\n", __FUNCTION__,
 			 stv0299_readreg (i2c, 0x18),
 			 stv0299_readreg (i2c, 0x19), (int) signal);
 
@@ -794,6 +898,8 @@
         {
 		struct dvb_frontend_parameters *p = arg;
 
+		dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);
+
 		pll_set_tv_freq (i2c, p->frequency, tuner_type,
 				 p->u.qpsk.symbol_rate);
 
@@ -859,6 +965,8 @@
 
 static long probe_tuner (struct dvb_i2c_bus *i2c)
 {
+	struct dvb_adapter * adapter = (struct dvb_adapter *) i2c->adapter;
+
         /* read the status register of TSA5059 */
 	u8 rpt[] = { 0x05, 0xb5 };
         u8 stat [] = { 0 };
@@ -875,6 +983,17 @@
 	stv0299_writereg (i2c, 0x02, 0x30);
 	stv0299_writereg (i2c, 0x03, 0x00);
 
+
+	printk ("%s: try to attach to %s\n", __FUNCTION__, adapter->name);
+
+	if ( strcmp(adapter->name, "Technisat SkyStar2 driver") == 0 )
+	{
+	    printk ("%s: setup for tuner Samsung TBMU24112IMB\n", __FILE__);
+
+    	    return SAMSUNG_TBMU24112IMB;
+	}
+
+
 	if ((ret = i2c->xfer(i2c, msg1, 2)) == 2) {
 		printk ("%s: setup for tuner SU1278/SH\n", __FILE__);
 		return PHILIPS_SU1278SH;
