[PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform.

2014-08-16 Thread nibble.max
The current m88ts2022 driver will miss the following high symbol rate 
transponders on Telstar 18 138.0.
12385 H 43200, 
12690 H 43200,
12538 V 41250...
the code for f_3db_hz will overflow for the high symbol rate.
for example, symbol rate=41250 KS/s
symbol_rate * 135UL = 556875(1 4BEC 61B0), the value is larger than 
unsigned int on 32bit platform. 
that makes the wrong result.
Exchanging the div and mul position fixs it.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/tuners/m88ts2022.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
index 40c42de..65c8acc 100644
--- a/drivers/media/tuners/m88ts2022.c
+++ b/drivers/media/tuners/m88ts2022.c
@@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
div_min = gdiv28 * 78 / 100;
div_max = clamp_val(div_max, 0U, 63U);
 
-   f_3db_hz = c-symbol_rate * 135UL / 200UL;
+   f_3db_hz = (c-symbol_rate / 200UL) * 135UL;
f_3db_hz +=  200U + (frequency_offset_khz * 1000U);
f_3db_hz = clamp(f_3db_hz, 700U, 4000U);

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] m88ts2022: fix high symbol rate transponders missing on 32bit platform.

2014-08-16 Thread nibble.max
The current m88ts2022 driver will miss the following high symbol rate 
transponders on Telstar 18 138.0.
12385 H 43200, 
12690 H 43200,
12538 V 41250...
the code for f_3db_hz will overflow for the high symbol rate.
for example, symbol rate=41250 KS/s
symbol_rate * 135UL = 556875(1 4BEC 61B0), the value is larger than 
unsigned int on 32bit platform. 
that makes the wrong result.
Exchanging the div and mul position fixs it.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/tuners/m88ts2022.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/m88ts2022.c b/drivers/media/tuners/m88ts2022.c
index 40c42de..65c8acc 100644
--- a/drivers/media/tuners/m88ts2022.c
+++ b/drivers/media/tuners/m88ts2022.c
@@ -314,7 +314,7 @@ static int m88ts2022_set_params(struct dvb_frontend *fe)
div_min = gdiv28 * 78 / 100;
div_max = clamp_val(div_max, 0U, 63U);
 
-   f_3db_hz = c-symbol_rate * 135UL / 200UL;
+   f_3db_hz = (c-symbol_rate / 200UL) * 135UL;
f_3db_hz +=  200U + (frequency_offset_khz * 1000U);
f_3db_hz = clamp(f_3db_hz, 700U, 4000U);

-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4 v3] support for DVBSky dvb-s2 usb: Add ts clock and clock polarity, lnb set voltage and lnb ctrl pin for m88ds3103

2014-08-10 Thread nibble.max
Add ts clock and clock polarity, lnb set voltage and lnb control pin.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/dvb-frontends/m88ds3103.c | 72 -
 drivers/media/dvb-frontends/m88ds3103.h | 35 +---
 2 files changed, 75 insertions(+), 32 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index dfe0c2f..238b04e 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -247,7 +247,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
u8 u8tmp, u8tmp1, u8tmp2;
u8 buf[2];
u16 u16tmp, divide_ratio;
-   u32 tuner_frequency, target_mclk, ts_clk;
+   u32 tuner_frequency, target_mclk;
s32 s32tmp;
dev_dbg(priv-i2c-dev,
%s: delivery_system=%d modulation=%d frequency=%d 
symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n,
@@ -316,9 +316,6 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
target_mclk = 144000;
break;
case M88DS3103_TS_PARALLEL:
-   case M88DS3103_TS_PARALLEL_12:
-   case M88DS3103_TS_PARALLEL_16:
-   case M88DS3103_TS_PARALLEL_19_2:
case M88DS3103_TS_CI:
if (c-symbol_rate  1800)
target_mclk = 96000;
@@ -352,33 +349,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
switch (priv-cfg-ts_mode) {
case M88DS3103_TS_SERIAL:
u8tmp1 = 0x00;
-   ts_clk = 0;
-   u8tmp = 0x46;
+   u8tmp = 0x06;
break;
case M88DS3103_TS_SERIAL_D7:
u8tmp1 = 0x20;
-   ts_clk = 0;
-   u8tmp = 0x46;
+   u8tmp = 0x06;
break;
case M88DS3103_TS_PARALLEL:
-   ts_clk = 24000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_12:
-   ts_clk = 12000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_16:
-   ts_clk = 16000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_19_2:
-   ts_clk = 19200;
-   u8tmp = 0x42;
+   u8tmp = 0x02;
break;
case M88DS3103_TS_CI:
-   ts_clk = 6000;
-   u8tmp = 0x43;
+   u8tmp = 0x03;
break;
default:
dev_dbg(priv-i2c-dev, %s: invalid ts_mode\n, __func__);
@@ -386,6 +367,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
+   if (priv-cfg-ts_clk_pol)
+   u8tmp |= 0x40;
+
/* TS mode */
ret = m88ds3103_wr_reg(priv, 0xfd, u8tmp);
if (ret)
@@ -399,8 +383,8 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
-   if (ts_clk) {
-   divide_ratio = DIV_ROUND_UP(target_mclk, ts_clk);
+   if (priv-cfg-ts_clk) {
+   divide_ratio = DIV_ROUND_UP(target_mclk, priv-cfg-ts_clk);
u8tmp1 = divide_ratio / 2;
u8tmp2 = DIV_ROUND_UP(divide_ratio, 2);
} else {
@@ -411,7 +395,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
 
dev_dbg(priv-i2c-dev,
%s: target_mclk=%d ts_clk=%d divide_ratio=%d\n,
-   __func__, target_mclk, ts_clk, divide_ratio);
+   __func__, target_mclk, priv-cfg-ts_clk, divide_ratio);
 
u8tmp1--;
u8tmp2--;
@@ -1053,6 +1037,39 @@ err:
return ret;
 }
 
+static int m88ds3103_set_voltage(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage)
+{
+   struct m88ds3103_priv *priv = fe-demodulator_priv;
+   u8 data;
+
+   m88ds3103_rd_reg(priv, 0xa2, data);
+
+   data = ~0x03; /* bit0 V/H, bit1 off/on */
+   if (priv-cfg-lnb_en_pol)
+   data |= 0x02;
+
+   switch (voltage) {
+   case SEC_VOLTAGE_18:
+   if (priv-cfg-lnb_hv_pol == 0)
+   data |= 0x01;
+   break;
+   case SEC_VOLTAGE_13:
+   if (priv-cfg-lnb_hv_pol)
+   data |= 0x01;
+   break;
+   case SEC_VOLTAGE_OFF:
+   if (priv-cfg-lnb_en_pol)
+   data = ~0x02;
+   else
+   data |= 0x02;
+   break;
+   }
+   m88ds3103_wr_reg(priv, 0xa2, data);
+
+   return 0;
+}
+
 static int m88ds3103_diseqc_send_master_cmd(struct dvb_frontend *fe,
struct dvb_diseqc_master_cmd *diseqc_cmd)
 {
@@ -1370,6 +1387,7 @@ static struct dvb_frontend_ops m88ds3103_ops = {
.diseqc_send_burst = m88ds3103_diseqc_send_burst,
 

[PATCH 3/4 v4] support for DVBSky dvb-s2 usb: add dvb-usb-v2 driver for DVBSky dvb-s2 box, no ci support.

2014-08-10 Thread nibble.max
remove ci support part in v1 patch.
hook demod read status and set voltage operations.
add m88ts2022 select in Kconfig.

move usb buffer into state for usb ctrl.
make checkpatch.pl happy.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/usb/dvb-usb-v2/Kconfig  |   7 +
 drivers/media/usb/dvb-usb-v2/Makefile |   3 +
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 460 ++
 3 files changed, 470 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
b/drivers/media/usb/dvb-usb-v2/Kconfig
index 66645b0..5b34323 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -141,3 +141,10 @@ config DVB_USB_RTL28XXU
help
  Say Y here to support the Realtek RTL28xxU DVB USB receiver.
 
+config DVB_USB_DVBSKY
+   tristate DVBSky USB support
+   depends on DVB_USB_V2
+   select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT
+   help
+ Say Y here to support the USB receivers from DVBSky.
diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
b/drivers/media/usb/dvb-usb-v2/Makefile
index bc38f03..f10d4df 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -37,6 +37,9 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o
 dvb-usb-rtl28xxu-objs := rtl28xxu.o
 obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o
 
+dvb-usb-dvbsky-objs := dvbsky.o
+obj-$(CONFIG_DVB_USB_DVBSKY) += dvb-usb-dvbsky.o
+
 ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
 ccflags-y += -I$(srctree)/drivers/media/tuners
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
new file mode 100644
index 000..34688c8
--- /dev/null
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -0,0 +1,460 @@
+/*
+ * Driver for DVBSky USB2.0 receiver
+ *
+ * Copyright (C) 2013 Max nibble nibble@gmail.com
+ *
+ *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
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include dvb_usb.h
+#include m88ds3103.h
+#include m88ts2022.h
+
+#define DVBSKY_MSG_DELAY   0/*2000*/
+#define DVBSKY_BUF_LEN 64
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+struct dvbsky_state {
+   struct mutex stream_mutex;
+   u8 ibuf[DVBSKY_BUF_LEN];
+   u8 obuf[DVBSKY_BUF_LEN];
+   u8 last_lock;
+   struct i2c_client *i2c_client_tuner;
+
+   /* fe hook functions*/
+   int (*fe_set_voltage)(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage);
+   int (*fe_read_status)(struct dvb_frontend *fe,
+   fe_status_t *status);
+};
+
+static int dvbsky_usb_generic_rw(struct dvb_usb_device *d,
+   u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
+{
+   int ret;
+   struct dvbsky_state *state = d_to_priv(d);
+
+   mutex_lock(d-usb_mutex);
+   if (wlen != 0)
+   memcpy(state-obuf, wbuf, wlen);
+
+   ret = dvb_usbv2_generic_rw_locked(d, state-obuf, wlen,
+   state-ibuf, rlen);
+
+   if (!ret  (rlen != 0))
+   memcpy(rbuf, state-ibuf, rlen);
+
+   mutex_unlock(d-usb_mutex);
+   return ret;
+}
+
+static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
+{
+   struct dvbsky_state *state = d_to_priv(d);
+   int ret;
+   u8 obuf_pre[3] = { 0x37, 0, 0 };
+   u8 obuf_post[3] = { 0x36, 3, 0 };
+
+   mutex_lock(state-stream_mutex);
+   ret = dvbsky_usb_generic_rw(d, obuf_pre, 3, NULL, 0);
+   if (!ret  onoff) {
+   msleep(20);
+   ret = dvbsky_usb_generic_rw(d, obuf_post, 3, NULL, 0);
+   }
+   mutex_unlock(state-stream_mutex);
+   return ret;
+}
+
+static int dvbsky_streaming_ctrl(struct dvb_frontend *fe, int onoff)
+{
+   struct dvb_usb_device *d = fe_to_d(fe);
+
+   return dvbsky_stream_ctrl(d, (onoff == 0) ? 0 : 1);
+}
+
+/* GPIO */
+static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 gport, u8 value)
+{
+   int ret;
+   u8 obuf[3], ibuf[2];
+
+   obuf[0] = 0x0e;
+   obuf[1] = gport;
+   obuf[2] = value;
+   ret = dvbsky_usb_generic_rw(d, obuf, 3, ibuf, 1);
+   if (ret)
+   dev_err(d-udev-dev, %s: %s() failed=%d\n,
+   KBUILD_MODNAME, 

Re: Re: [PATCH 1/4] support for DVBSky dvb-s2 usb: add some config andset_voltage for m88ds3103

2014-08-07 Thread nibble.max
Moikka!
Thanks for your review.
Moikka!

That patch contains (too) many changes:
1) TS clock config option
2) TS clock polarity config option
3) start_ctrl() callback
4) set_voltage implementation
5) set_voltage() callback

Generally I am fine with 1, 2 and 4.

When you do that many different logical changes for existing driver, you
should split it is one patch per change.

Rest of the comments are between the code.


On 08/06/2014 07:27 AM, nibble.max wrote:
 Add some config parameters and set_voltage function for m88ds3103.
 
 Signed-off-by: Nibble Max nibble@gmail.com
 ---
   drivers/media/dvb-frontends/m88ds3103.c | 91 
 +++--
   drivers/media/dvb-frontends/m88ds3103.h | 37 --
   2 files changed, 96 insertions(+), 32 deletions(-)
 
 diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
 b/drivers/media/dvb-frontends/m88ds3103.c
 index dfe0c2f..df2f89c 100644
 --- a/drivers/media/dvb-frontends/m88ds3103.c
 +++ b/drivers/media/dvb-frontends/m88ds3103.c
 @@ -247,8 +247,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)
  u8 u8tmp, u8tmp1, u8tmp2;
  u8 buf[2];
  u16 u16tmp, divide_ratio;
 -u32 tuner_frequency, target_mclk, ts_clk;
 +u32 tuner_frequency, target_mclk;
  s32 s32tmp;
 +fe_status_t status;
  dev_dbg(priv-i2c-dev,
  %s: delivery_system=%d modulation=%d frequency=%d 
 symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n,
  __func__, c-delivery_system,
 @@ -316,9 +317,6 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)
  target_mclk = 144000;
  break;
  case M88DS3103_TS_PARALLEL:
 -case M88DS3103_TS_PARALLEL_12:
 -case M88DS3103_TS_PARALLEL_16:
 -case M88DS3103_TS_PARALLEL_19_2:
  case M88DS3103_TS_CI:
  if (c-symbol_rate  1800)
  target_mclk = 96000;
 @@ -352,33 +350,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)
  switch (priv-cfg-ts_mode) {
  case M88DS3103_TS_SERIAL:
  u8tmp1 = 0x00;
 -ts_clk = 0;
 -u8tmp = 0x46;
 +u8tmp = 0x06;
  break;
  case M88DS3103_TS_SERIAL_D7:
  u8tmp1 = 0x20;
 -ts_clk = 0;
 -u8tmp = 0x46;
 +u8tmp = 0x06;
  break;
  case M88DS3103_TS_PARALLEL:
 -ts_clk = 24000;
 -u8tmp = 0x42;
 -break;
 -case M88DS3103_TS_PARALLEL_12:
 -ts_clk = 12000;
 -u8tmp = 0x42;
 -break;
 -case M88DS3103_TS_PARALLEL_16:
 -ts_clk = 16000;
 -u8tmp = 0x42;
 -break;
 -case M88DS3103_TS_PARALLEL_19_2:
 -ts_clk = 19200;
 -u8tmp = 0x42;
 +u8tmp = 0x02;
  break;
  case M88DS3103_TS_CI:
 -ts_clk = 6000;
 -u8tmp = 0x43;
 +u8tmp = 0x03;
  break;
  default:
  dev_dbg(priv-i2c-dev, %s: invalid ts_mode\n, __func__);
 @@ -386,6 +368,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)
  goto err;
  }
   
 +if (priv-cfg-ts_clk_pol)
 +u8tmp |= 0x40;
 +
  /* TS mode */
  ret = m88ds3103_wr_reg(priv, 0xfd, u8tmp);
  if (ret)
 @@ -399,8 +384,8 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)
  goto err;
  }
   
 -if (ts_clk) {
 -divide_ratio = DIV_ROUND_UP(target_mclk, ts_clk);
 +if (priv-cfg-ts_clk) {
 +divide_ratio = DIV_ROUND_UP(target_mclk, priv-cfg-ts_clk);
  u8tmp1 = divide_ratio / 2;
  u8tmp2 = DIV_ROUND_UP(divide_ratio, 2);
  } else {
 @@ -411,7 +396,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)
   
  dev_dbg(priv-i2c-dev,
  %s: target_mclk=%d ts_clk=%d divide_ratio=%d\n,
 -__func__, target_mclk, ts_clk, divide_ratio);
 +__func__, target_mclk, priv-cfg-ts_clk, divide_ratio);
   
  u8tmp1--;
  u8tmp2--;
 @@ -523,6 +508,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)
   
  priv-delivery_system = c-delivery_system;
   
 +if (priv-cfg-start_ctrl) {
 +for (len = 0; len  30 ; len++) {
 +m88ds3103_read_status(fe, status);
 +if (status  FE_HAS_LOCK) {
 +priv-cfg-start_ctrl(fe);
 +break;
 +}
 +msleep(20);
 +}
 +}
 +

What is idea of that start_ctrl logic? It looks ugly. Why it is needed?
What is wrong with default DVB-core implementation? You should not need
to poll demod lock here and then call streaming control callback from
USB driver. If you implement .streaming_ctrl() callback to DVB USB
driver

Re: Re: [PATCH 1/4] support for DVBSky dvb-s2 usb: add some config andset_voltagefor m88ds3103

2014-08-07 Thread nibble.max

Moikka!

On 08/07/2014 12:31 PM, nibble.max wrote:
 @@ -523,6 +508,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend 
 *fe)

priv-delivery_system = c-delivery_system;

 +  if (priv-cfg-start_ctrl) {
 +  for (len = 0; len  30 ; len++) {
 +  m88ds3103_read_status(fe, status);
 +  if (status  FE_HAS_LOCK) {
 +  priv-cfg-start_ctrl(fe);
 +  break;
 +  }
 +  msleep(20);
 +  }
 +  }
 +

 What is idea of that start_ctrl logic? It looks ugly. Why it is needed?
 What is wrong with default DVB-core implementation? You should not need
 to poll demod lock here and then call streaming control callback from
 USB driver. If you implement .streaming_ctrl() callback to DVB USB
 driver, it is called automatically for you.
 It is nothing with streaming_ctrl of DVB USB driver.
 It relates with the hardware chip problem.
 The m88ds3103 will not output ts clock when it powers up at the first time.
 It starts to output ts clock as soon as it locks the signal.
 But the slave fifo of Cypress usb chip really need this clock to work.
 If there is no this clock, the salve fifo will stop.
 start_ctrl logic is used to restart the salve fifo when the ts clock is 
 valid.

OK. Then we have to find out some solution... Is there anyone who has a
nice idea how to signal USB interface driver when demod gains a lock?
Sure USB driver could poll read_status() too, but it does not sound good
solution neither.

How about overriding FE .read_status() callback. It is called all the
time by DVB-core when frontend is open. Hook .read_status() to USB
interface driver, then call original .read_status() (implemented by
m88ds3103 driver), and after each call check if status is LOCKED or NOT
LOCKED. When status changes from NOT LOCKED to LOCKED call that board
specific routine which restarts TS FIFO. No change for demod driver
needed at all.

It sounds a good idea.
Try to remove start_ctrl() and set_voltage() callback from demod driver
and send the patch for m88ds3103 later.
regards
Antto

-- 
http://palosaari.fi/

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Re: [PATCH 3/4] support for DVBSky dvb-s2 usb: add dvb-usb-v2 driverfor DVBSky dvb-s2 box

2014-08-07 Thread nibble.max
Moikka!
Moikka!
Biggest issue is that CIMax2 SP2 driver. Olli put all that stuff to own
I2C driver recently. Could you took SP2 from patchwork and use it instead:
https://patchwork.linuxtv.org/patch/25206/
https://patchwork.linuxtv.org/patch/25210/
Yes, the CIMax2 SP2 code here is the same as Olli's.
But Olli comes to make a standard i2c driver, so I will remove the ci code from 
dvbsky usb driver.
As Olli finish the code ready, I will use his code for ci part.

It is not yet in mainline, but there should not be any big changes
coming to that driver.

regards
Antti

On 08/06/2014 07:36 AM, nibble.max wrote:
 add dvb-usb-v2 driver for DVBSky dvb-s2 box
 
 Signed-off-by: Nibble Max nibble@gmail.com
 ---
   drivers/media/usb/dvb-usb-v2/Kconfig  |   6 +
   drivers/media/usb/dvb-usb-v2/Makefile |   3 +
   drivers/media/usb/dvb-usb-v2/dvbsky.c | 872 
 ++
   3 files changed, 881 insertions(+)
 
 diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
 b/drivers/media/usb/dvb-usb-v2/Kconfig
 index 66645b0..8107c8d 100644
 --- a/drivers/media/usb/dvb-usb-v2/Kconfig
 +++ b/drivers/media/usb/dvb-usb-v2/Kconfig
 @@ -141,3 +141,9 @@ config DVB_USB_RTL28XXU
  help
Say Y here to support the Realtek RTL28xxU DVB USB receiver.
   
 +config DVB_USB_DVBSKY
 +tristate DVBSky USB support
 +depends on DVB_USB_V2
 +select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
 +help
 +  Say Y here to support the USB receivers from DVBSky.
 diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
 b/drivers/media/usb/dvb-usb-v2/Makefile
 index bc38f03..f10d4df 100644
 --- a/drivers/media/usb/dvb-usb-v2/Makefile
 +++ b/drivers/media/usb/dvb-usb-v2/Makefile
 @@ -37,6 +37,9 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o
   dvb-usb-rtl28xxu-objs := rtl28xxu.o
   obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o
   
 +dvb-usb-dvbsky-objs := dvbsky.o
 +obj-$(CONFIG_DVB_USB_DVBSKY) += dvb-usb-dvbsky.o
 +
   ccflags-y += -I$(srctree)/drivers/media/dvb-core
   ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
   ccflags-y += -I$(srctree)/drivers/media/tuners
 diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
 b/drivers/media/usb/dvb-usb-v2/dvbsky.c
 new file mode 100644
 index 000..c86927f
 --- /dev/null
 +++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
 @@ -0,0 +1,872 @@
 +/*
 + * Driver for DVBSky USB2.0 receiver
 + *
 + * Copyright (C) 2013 Max nibble nibble@gmail.com
 + *
 + * CIMax code is copied and modified from:
 + * CIMax2(R) SP2 driver in conjunction with NetUp Dual DVB-S2 CI card
 + * Copyright (C) 2009 NetUP Inc.
 + * Copyright (C) 2009 Igor M. Liplianin liplia...@netup.ru
 + * Copyright (C) 2009 Abylay Ospan aos...@netup.ru
 + *
 + *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
 + *(at your option) any later version.
 + *
 + *This program is distributed in the hope that it will be useful,
 + *but WITHOUT ANY WARRANTY; without even the implied warranty of
 + *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 + *GNU General Public License for more details.
 + *
 + *You should have received a copy of the GNU General Public License
 + *along with this program; if not, write to the Free Software
 + *Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + */
 +
 +#include dvb_ca_en50221.h
 +#include dvb_usb.h
 +#include m88ds3103.h
 +#include m88ts2022.h
 +
 +static int dvbsky_debug;
 +module_param(dvbsky_debug, int, 0644);
 +MODULE_PARM_DESC(dvbsky_debug, Activates dvbsky usb debugging 
 (default:0));
 +
 +#define DVBSKY_MSG_DELAY0/*2000*/
 +#define DVBSKY_CI_CTL   0x04
 +#define DVBSKY_CI_RD1
 +
 +#define dprintk(args...) \
 +do { \
 +if (dvbsky_debug) \
 +printk(KERN_INFO dvbsky_usb:  args); \
 +} while (0)
 +
 +DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 +
 +struct dvbsky_state {
 +struct mutex stream_mutex;
 +u8 has_ci;
 +u8 ci_attached;
 +struct dvb_ca_en50221 ci;
 +unsigned long next_status_checked_time;
 +u8 ci_i2c_addr;
 +u8 current_ci_flag;
 +int ci_status;
 +struct i2c_client *i2c_client_tuner;
 +};
 +
 +static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
 +{
 +struct dvbsky_state *state = d_to_priv(d);
 +int ret;
 +u8 obuf_pre[3] = { 0x37, 0, 0 };
 +u8 obuf_post[3] = { 0x36, 3, 0 };
 +dprintk(%s() -off \n, __func__);
 +mutex_lock(state-stream_mutex);
 +ret = dvb_usbv2_generic_write(d, obuf_pre, 3);
 +if (!ret  onoff) {
 +msleep(10);
 +ret = dvb_usbv2_generic_write(d, obuf_post, 3);
 +dprintk(%s() -on \n, __func__);
 +}
 +mutex_unlock(state-stream_mutex);
 +return ret;
 +}
 +
 +/* CI opertaions */
 +static int dvbsky_ci_read_i2c(struct

[PATCH 1/4 v2] support for DVBSky dvb-s2 usb: Add ts clock and clock polarity, lnb set voltage for m88ds3103

2014-08-07 Thread nibble.max
Add ts clock and clock polarity, lnb set voltage.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/dvb-frontends/m88ds3103.c | 77 +
 drivers/media/dvb-frontends/m88ds3103.h | 25 ---
 2 files changed, 70 insertions(+), 32 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index dfe0c2f..142f9a6 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -247,7 +247,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
u8 u8tmp, u8tmp1, u8tmp2;
u8 buf[2];
u16 u16tmp, divide_ratio;
-   u32 tuner_frequency, target_mclk, ts_clk;
+   u32 tuner_frequency, target_mclk;
s32 s32tmp;
dev_dbg(priv-i2c-dev,
%s: delivery_system=%d modulation=%d frequency=%d 
symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n,
@@ -316,9 +316,6 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
target_mclk = 144000;
break;
case M88DS3103_TS_PARALLEL:
-   case M88DS3103_TS_PARALLEL_12:
-   case M88DS3103_TS_PARALLEL_16:
-   case M88DS3103_TS_PARALLEL_19_2:
case M88DS3103_TS_CI:
if (c-symbol_rate  1800)
target_mclk = 96000;
@@ -352,33 +349,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
switch (priv-cfg-ts_mode) {
case M88DS3103_TS_SERIAL:
u8tmp1 = 0x00;
-   ts_clk = 0;
-   u8tmp = 0x46;
+   u8tmp = 0x06;
break;
case M88DS3103_TS_SERIAL_D7:
u8tmp1 = 0x20;
-   ts_clk = 0;
-   u8tmp = 0x46;
+   u8tmp = 0x06;
break;
case M88DS3103_TS_PARALLEL:
-   ts_clk = 24000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_12:
-   ts_clk = 12000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_16:
-   ts_clk = 16000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_19_2:
-   ts_clk = 19200;
-   u8tmp = 0x42;
+   u8tmp = 0x02;
break;
case M88DS3103_TS_CI:
-   ts_clk = 6000;
-   u8tmp = 0x43;
+   u8tmp = 0x03;
break;
default:
dev_dbg(priv-i2c-dev, %s: invalid ts_mode\n, __func__);
@@ -386,6 +367,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
+   if (priv-cfg-ts_clk_pol)
+   u8tmp |= 0x40;
+
/* TS mode */
ret = m88ds3103_wr_reg(priv, 0xfd, u8tmp);
if (ret)
@@ -399,8 +383,8 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
-   if (ts_clk) {
-   divide_ratio = DIV_ROUND_UP(target_mclk, ts_clk);
+   if (priv-cfg-ts_clk) {
+   divide_ratio = DIV_ROUND_UP(target_mclk, priv-cfg-ts_clk);
u8tmp1 = divide_ratio / 2;
u8tmp2 = DIV_ROUND_UP(divide_ratio, 2);
} else {
@@ -411,7 +395,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
 
dev_dbg(priv-i2c-dev,
%s: target_mclk=%d ts_clk=%d divide_ratio=%d\n,
-   __func__, target_mclk, ts_clk, divide_ratio);
+   __func__, target_mclk, priv-cfg-ts_clk, divide_ratio);
 
u8tmp1--;
u8tmp2--;
@@ -1053,6 +1037,44 @@ err:
return ret;
 }
 
+static int m88ds3103_set_voltage(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage)
+{
+   struct m88ds3103_priv *priv = fe-demodulator_priv;
+   u8 data;
+
+   dev_dbg(priv-i2c-dev, %s: pin_ctrl = (%02x)\n,
+   __func__, priv-cfg-pin_ctrl);
+
+   m88ds3103_rd_reg(priv, 0xa2, data);
+
+   if (priv-cfg-pin_ctrl  0x80) { /*If control pin is assigned.*/
+   data = ~0x03; /* bit0 V/H, bit1 off/on */
+   if (priv-cfg-pin_ctrl  0x02)
+   data |= 0x02;
+
+   switch (voltage) {
+   case SEC_VOLTAGE_18:
+if ((priv-cfg-pin_ctrl  0x01) == 0)
+   data |= 0x01;
+break;
+   case SEC_VOLTAGE_13:
+if (priv-cfg-pin_ctrl  0x01)
+   data |= 0x01;
+break;
+   case SEC_VOLTAGE_OFF:
+if (priv-cfg-pin_ctrl  0x02)
+   data = ~0x02;
+else
+   data |= 0x02;
+break;
+   }
+   }
+   m88ds3103_wr_reg(priv, 0xa2, data);
+
+   

[PATCH 3/4 v2] support for DVBSky dvb-s2 usb: add dvb-usb-v2 driver for DVBSky dvb-s2 box, no ci support.

2014-08-07 Thread nibble.max
remove ci support part in v1 patch.
hook demod read status and set voltage operations.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/usb/dvb-usb-v2/Kconfig  |   6 +
 drivers/media/usb/dvb-usb-v2/Makefile |   3 +
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 455 ++
 3 files changed, 464 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
b/drivers/media/usb/dvb-usb-v2/Kconfig
index 66645b0..8107c8d 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -141,3 +141,9 @@ config DVB_USB_RTL28XXU
help
  Say Y here to support the Realtek RTL28xxU DVB USB receiver.
 
+config DVB_USB_DVBSKY
+   tristate DVBSky USB support
+   depends on DVB_USB_V2
+   select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
+   help
+ Say Y here to support the USB receivers from DVBSky.
diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
b/drivers/media/usb/dvb-usb-v2/Makefile
index bc38f03..f10d4df 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -37,6 +37,9 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o
 dvb-usb-rtl28xxu-objs := rtl28xxu.o
 obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o
 
+dvb-usb-dvbsky-objs := dvbsky.o
+obj-$(CONFIG_DVB_USB_DVBSKY) += dvb-usb-dvbsky.o
+
 ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
 ccflags-y += -I$(srctree)/drivers/media/tuners
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
new file mode 100644
index 000..2db363e
--- /dev/null
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -0,0 +1,455 @@
+/*
+ * Driver for DVBSky USB2.0 receiver
+ *
+ * Copyright (C) 2013 Max nibble nibble@gmail.com
+ *
+ *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
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include dvb_usb.h
+#include m88ds3103.h
+#include m88ts2022.h
+
+static int dvbsky_debug;
+module_param(dvbsky_debug, int, 0644);
+MODULE_PARM_DESC(dvbsky_debug, Activates dvbsky usb debugging (default:0));
+
+#define DVBSKY_MSG_DELAY   0/*2000*/
+
+#define dprintk(args...) \
+   do { \
+   if (dvbsky_debug) \
+   printk(KERN_INFO dvbsky_usb:  args); \
+   } while (0)
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+struct dvbsky_state {
+   struct mutex stream_mutex;
+   u8 last_lock;
+   struct i2c_client *i2c_client_tuner;
+   int (*fe_set_voltage)(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage);
+   int (*fe_read_status)(struct dvb_frontend *fe,
+   fe_status_t *status);
+};
+
+static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
+{
+   struct dvbsky_state *state = d_to_priv(d);
+   int ret;
+   u8 obuf_pre[3] = { 0x37, 0, 0 };
+   u8 obuf_post[3] = { 0x36, 3, 0 };
+   dprintk(%s() -off \n, __func__);
+   mutex_lock(state-stream_mutex);
+   ret = dvb_usbv2_generic_write(d, obuf_pre, 3);
+   if (!ret  onoff) {
+   msleep(10);
+   ret = dvb_usbv2_generic_write(d, obuf_post, 3);
+   dprintk(%s() -on \n, __func__);
+   }
+   mutex_unlock(state-stream_mutex);
+   return ret;
+}
+
+static int dvbsky_streaming_ctrl(struct dvb_frontend *fe, int onoff)
+{
+   struct dvb_usb_device *d = fe_to_d(fe);
+   /*dprintk(%s() %d\n, __func__, onoff);*/
+   return dvbsky_stream_ctrl(d, (onoff == 0) ? 0 : 1);
+}
+
+/* GPIO */
+static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 gport, u8 value)
+{
+   int ret;
+   u8 obuf[64], ibuf[64];
+   obuf[0] = 0x0e;
+   obuf[1] = gport;
+   obuf[2] = value;
+   ret = dvb_usbv2_generic_rw(d, obuf, 3, ibuf, 1);
+   if (ret)
+   dev_err(d-udev-dev, %s: %s()  \
+   failed=%d\n, KBUILD_MODNAME, __func__, ret);
+   return ret;
+}
+
+/* I2C */
+static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+   int num)
+{
+   struct dvb_usb_device *d = i2c_get_adapdata(adap);
+   int ret = 0;
+   u8 ibuf[64], obuf[64];
+
+   if (mutex_lock_interruptible(d-i2c_mutex)  0)
+   return -EAGAIN;
+
+   if (num  2) {
+   

Re: Re: [PATCH 3/4] support for DVBSky dvb-s2 usb: add dvb-usb-v2 driver for DVBSky dvb-s2 box

2014-08-07 Thread nibble.max
Hello Olli,
Hi Max,

nibble.max nibble.max at gmail.com writes:
 diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig
b/drivers/media/usb/dvb-usb-v2/Kconfig
 index 66645b0..8107c8d 100644
 --- a/drivers/media/usb/dvb-usb-v2/Kconfig
 +++ b/drivers/media/usb/dvb-usb-v2/Kconfig
  at  at  -141,3 +141,9  at  at  config DVB_USB_RTL28XXU
  help
Say Y here to support the Realtek RTL28xxU DVB USB receiver.
 
 +config DVB_USB_DVBSKY
 +tristate DVBSky USB support
 +depends on DVB_USB_V2
 +select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
 +help
 +  Say Y here to support the USB receivers from DVBSky.

Shouldn't the MEDIA_TUNER_M88TS2022 also be selected in Kconfig?
Yes, I miss it. It should be selected in Kconfig.
Thanks.

Cheers,
-olli



--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4 v3] support for DVBSky dvb-s2 usb: add dvb-usb-v2 driver for DVBSky dvb-s2 box, no ci support.

2014-08-07 Thread nibble.max
remove ci support part in v1 patch.
hook demod read status and set voltage operations.
add m88ts2022 select in Kconfig.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/usb/dvb-usb-v2/Kconfig  |   7 +
 drivers/media/usb/dvb-usb-v2/Makefile |   3 +
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 455 ++
 3 files changed, 465 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
b/drivers/media/usb/dvb-usb-v2/Kconfig
index 66645b0..5b34323 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -141,3 +141,10 @@ config DVB_USB_RTL28XXU
help
  Say Y here to support the Realtek RTL28xxU DVB USB receiver.
 
+config DVB_USB_DVBSKY
+   tristate DVBSky USB support
+   depends on DVB_USB_V2
+   select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_M88TS2022 if MEDIA_SUBDRV_AUTOSELECT
+   help
+ Say Y here to support the USB receivers from DVBSky.
diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
b/drivers/media/usb/dvb-usb-v2/Makefile
index bc38f03..f10d4df 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -37,6 +37,9 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o
 dvb-usb-rtl28xxu-objs := rtl28xxu.o
 obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o
 
+dvb-usb-dvbsky-objs := dvbsky.o
+obj-$(CONFIG_DVB_USB_DVBSKY) += dvb-usb-dvbsky.o
+
 ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
 ccflags-y += -I$(srctree)/drivers/media/tuners
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
new file mode 100644
index 000..2db363e
--- /dev/null
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -0,0 +1,455 @@
+/*
+ * Driver for DVBSky USB2.0 receiver
+ *
+ * Copyright (C) 2013 Max nibble nibble@gmail.com
+ *
+ *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
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include dvb_usb.h
+#include m88ds3103.h
+#include m88ts2022.h
+
+static int dvbsky_debug;
+module_param(dvbsky_debug, int, 0644);
+MODULE_PARM_DESC(dvbsky_debug, Activates dvbsky usb debugging (default:0));
+
+#define DVBSKY_MSG_DELAY   0/*2000*/
+
+#define dprintk(args...) \
+   do { \
+   if (dvbsky_debug) \
+   printk(KERN_INFO dvbsky_usb:  args); \
+   } while (0)
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+struct dvbsky_state {
+   struct mutex stream_mutex;
+   u8 last_lock;
+   struct i2c_client *i2c_client_tuner;
+   int (*fe_set_voltage)(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage);
+   int (*fe_read_status)(struct dvb_frontend *fe,
+   fe_status_t *status);
+};
+
+static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
+{
+   struct dvbsky_state *state = d_to_priv(d);
+   int ret;
+   u8 obuf_pre[3] = { 0x37, 0, 0 };
+   u8 obuf_post[3] = { 0x36, 3, 0 };
+   dprintk(%s() -off \n, __func__);
+   mutex_lock(state-stream_mutex);
+   ret = dvb_usbv2_generic_write(d, obuf_pre, 3);
+   if (!ret  onoff) {
+   msleep(10);
+   ret = dvb_usbv2_generic_write(d, obuf_post, 3);
+   dprintk(%s() -on \n, __func__);
+   }
+   mutex_unlock(state-stream_mutex);
+   return ret;
+}
+
+static int dvbsky_streaming_ctrl(struct dvb_frontend *fe, int onoff)
+{
+   struct dvb_usb_device *d = fe_to_d(fe);
+   /*dprintk(%s() %d\n, __func__, onoff);*/
+   return dvbsky_stream_ctrl(d, (onoff == 0) ? 0 : 1);
+}
+
+/* GPIO */
+static int dvbsky_gpio_ctrl(struct dvb_usb_device *d, u8 gport, u8 value)
+{
+   int ret;
+   u8 obuf[64], ibuf[64];
+   obuf[0] = 0x0e;
+   obuf[1] = gport;
+   obuf[2] = value;
+   ret = dvb_usbv2_generic_rw(d, obuf, 3, ibuf, 1);
+   if (ret)
+   dev_err(d-udev-dev, %s: %s()  \
+   failed=%d\n, KBUILD_MODNAME, __func__, ret);
+   return ret;
+}
+
+/* I2C */
+static int dvbsky_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
+   int num)
+{
+   struct dvb_usb_device *d = i2c_get_adapdata(adap);
+   int ret = 0;
+   u8 ibuf[64], obuf[64];
+
+   if 

[PATCH 1/4] support for DVBSky dvb-s2 usb: add some config and set_voltage for m88ds3103

2014-08-05 Thread nibble.max
Add some config parameters and set_voltage function for m88ds3103.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/dvb-frontends/m88ds3103.c | 91 +++--
 drivers/media/dvb-frontends/m88ds3103.h | 37 --
 2 files changed, 96 insertions(+), 32 deletions(-)

diff --git a/drivers/media/dvb-frontends/m88ds3103.c 
b/drivers/media/dvb-frontends/m88ds3103.c
index dfe0c2f..df2f89c 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -247,8 +247,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
u8 u8tmp, u8tmp1, u8tmp2;
u8 buf[2];
u16 u16tmp, divide_ratio;
-   u32 tuner_frequency, target_mclk, ts_clk;
+   u32 tuner_frequency, target_mclk;
s32 s32tmp;
+   fe_status_t status;
dev_dbg(priv-i2c-dev,
%s: delivery_system=%d modulation=%d frequency=%d 
symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n,
__func__, c-delivery_system,
@@ -316,9 +317,6 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
target_mclk = 144000;
break;
case M88DS3103_TS_PARALLEL:
-   case M88DS3103_TS_PARALLEL_12:
-   case M88DS3103_TS_PARALLEL_16:
-   case M88DS3103_TS_PARALLEL_19_2:
case M88DS3103_TS_CI:
if (c-symbol_rate  1800)
target_mclk = 96000;
@@ -352,33 +350,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
switch (priv-cfg-ts_mode) {
case M88DS3103_TS_SERIAL:
u8tmp1 = 0x00;
-   ts_clk = 0;
-   u8tmp = 0x46;
+   u8tmp = 0x06;
break;
case M88DS3103_TS_SERIAL_D7:
u8tmp1 = 0x20;
-   ts_clk = 0;
-   u8tmp = 0x46;
+   u8tmp = 0x06;
break;
case M88DS3103_TS_PARALLEL:
-   ts_clk = 24000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_12:
-   ts_clk = 12000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_16:
-   ts_clk = 16000;
-   u8tmp = 0x42;
-   break;
-   case M88DS3103_TS_PARALLEL_19_2:
-   ts_clk = 19200;
-   u8tmp = 0x42;
+   u8tmp = 0x02;
break;
case M88DS3103_TS_CI:
-   ts_clk = 6000;
-   u8tmp = 0x43;
+   u8tmp = 0x03;
break;
default:
dev_dbg(priv-i2c-dev, %s: invalid ts_mode\n, __func__);
@@ -386,6 +368,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
+   if (priv-cfg-ts_clk_pol)
+   u8tmp |= 0x40;
+
/* TS mode */
ret = m88ds3103_wr_reg(priv, 0xfd, u8tmp);
if (ret)
@@ -399,8 +384,8 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
goto err;
}
 
-   if (ts_clk) {
-   divide_ratio = DIV_ROUND_UP(target_mclk, ts_clk);
+   if (priv-cfg-ts_clk) {
+   divide_ratio = DIV_ROUND_UP(target_mclk, priv-cfg-ts_clk);
u8tmp1 = divide_ratio / 2;
u8tmp2 = DIV_ROUND_UP(divide_ratio, 2);
} else {
@@ -411,7 +396,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
 
dev_dbg(priv-i2c-dev,
%s: target_mclk=%d ts_clk=%d divide_ratio=%d\n,
-   __func__, target_mclk, ts_clk, divide_ratio);
+   __func__, target_mclk, priv-cfg-ts_clk, divide_ratio);
 
u8tmp1--;
u8tmp2--;
@@ -523,6 +508,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
 
priv-delivery_system = c-delivery_system;
 
+   if (priv-cfg-start_ctrl) {
+   for (len = 0; len  30 ; len++) {
+   m88ds3103_read_status(fe, status);
+   if (status  FE_HAS_LOCK) {
+   priv-cfg-start_ctrl(fe);
+   break;
+   }
+   msleep(20);
+   }
+   }
+
return 0;
 err:
dev_dbg(priv-i2c-dev, %s: failed=%d\n, __func__, ret);
@@ -1053,6 +1049,46 @@ err:
return ret;
 }
 
+static int m88ds3103_set_voltage(struct dvb_frontend *fe,
+   fe_sec_voltage_t voltage)
+{
+   struct m88ds3103_priv *priv = fe-demodulator_priv;
+   u8 data;
+
+   dev_dbg(priv-i2c-dev, %s: pin_ctrl = (%02x)\n,
+   __func__, priv-cfg-pin_ctrl);
+
+   if (priv-cfg-set_voltage)
+   priv-cfg-set_voltage(fe, voltage);
+
+   m88ds3103_rd_reg(priv, 0xa2, data);
+
+   if (priv-cfg-pin_ctrl  0x80) { /*If control pin is assigned.*/
+

[PATCH 2/4] support for DVBSky dvb-s2 usb: change em28xx-dvb.c following the m88ds3103 config change

2014-08-05 Thread nibble.max
change em28xx-dvb.c following the m88ds3103 config change

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/usb/em28xx/em28xx-dvb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c 
b/drivers/media/usb/em28xx/em28xx-dvb.c
index 3a3e243..d8e9760 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -856,7 +856,9 @@ static const struct m88ds3103_config 
pctv_461e_m88ds3103_config = {
.clock = 2700,
.i2c_wr_max = 33,
.clock_out = 0,
-   .ts_mode = M88DS3103_TS_PARALLEL_16,
+   .ts_mode = M88DS3103_TS_PARALLEL,
+   .ts_clk = 16000,
+   .ts_clk_pol = 1,
.agc = 0x99,
 };
  

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] support for DVBSky dvb-s2 usb: add dvb-usb-v2 driver for DVBSky dvb-s2 box

2014-08-05 Thread nibble.max
add dvb-usb-v2 driver for DVBSky dvb-s2 box

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/usb/dvb-usb-v2/Kconfig  |   6 +
 drivers/media/usb/dvb-usb-v2/Makefile |   3 +
 drivers/media/usb/dvb-usb-v2/dvbsky.c | 872 ++
 3 files changed, 881 insertions(+)

diff --git a/drivers/media/usb/dvb-usb-v2/Kconfig 
b/drivers/media/usb/dvb-usb-v2/Kconfig
index 66645b0..8107c8d 100644
--- a/drivers/media/usb/dvb-usb-v2/Kconfig
+++ b/drivers/media/usb/dvb-usb-v2/Kconfig
@@ -141,3 +141,9 @@ config DVB_USB_RTL28XXU
help
  Say Y here to support the Realtek RTL28xxU DVB USB receiver.
 
+config DVB_USB_DVBSKY
+   tristate DVBSky USB support
+   depends on DVB_USB_V2
+   select DVB_M88DS3103 if MEDIA_SUBDRV_AUTOSELECT
+   help
+ Say Y here to support the USB receivers from DVBSky.
diff --git a/drivers/media/usb/dvb-usb-v2/Makefile 
b/drivers/media/usb/dvb-usb-v2/Makefile
index bc38f03..f10d4df 100644
--- a/drivers/media/usb/dvb-usb-v2/Makefile
+++ b/drivers/media/usb/dvb-usb-v2/Makefile
@@ -37,6 +37,9 @@ obj-$(CONFIG_DVB_USB_MXL111SF) += mxl111sf-tuner.o
 dvb-usb-rtl28xxu-objs := rtl28xxu.o
 obj-$(CONFIG_DVB_USB_RTL28XXU) += dvb-usb-rtl28xxu.o
 
+dvb-usb-dvbsky-objs := dvbsky.o
+obj-$(CONFIG_DVB_USB_DVBSKY) += dvb-usb-dvbsky.o
+
 ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
 ccflags-y += -I$(srctree)/drivers/media/tuners
diff --git a/drivers/media/usb/dvb-usb-v2/dvbsky.c 
b/drivers/media/usb/dvb-usb-v2/dvbsky.c
new file mode 100644
index 000..c86927f
--- /dev/null
+++ b/drivers/media/usb/dvb-usb-v2/dvbsky.c
@@ -0,0 +1,872 @@
+/*
+ * Driver for DVBSky USB2.0 receiver
+ *
+ * Copyright (C) 2013 Max nibble nibble@gmail.com
+ *
+ * CIMax code is copied and modified from:
+ * CIMax2(R) SP2 driver in conjunction with NetUp Dual DVB-S2 CI card
+ * Copyright (C) 2009 NetUP Inc.
+ * Copyright (C) 2009 Igor M. Liplianin liplia...@netup.ru
+ * Copyright (C) 2009 Abylay Ospan aos...@netup.ru
+ *
+ *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
+ *(at your option) any later version.
+ *
+ *This program is distributed in the hope that it will be useful,
+ *but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *GNU General Public License for more details.
+ *
+ *You should have received a copy of the GNU General Public License
+ *along with this program; if not, write to the Free Software
+ *Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include dvb_ca_en50221.h
+#include dvb_usb.h
+#include m88ds3103.h
+#include m88ts2022.h
+
+static int dvbsky_debug;
+module_param(dvbsky_debug, int, 0644);
+MODULE_PARM_DESC(dvbsky_debug, Activates dvbsky usb debugging (default:0));
+
+#define DVBSKY_MSG_DELAY   0/*2000*/
+#define DVBSKY_CI_CTL  0x04
+#define DVBSKY_CI_RD   1
+
+#define dprintk(args...) \
+   do { \
+   if (dvbsky_debug) \
+   printk(KERN_INFO dvbsky_usb:  args); \
+   } while (0)
+
+DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+
+struct dvbsky_state {
+   struct mutex stream_mutex;
+   u8 has_ci;
+   u8 ci_attached;
+   struct dvb_ca_en50221 ci;
+   unsigned long next_status_checked_time;
+   u8 ci_i2c_addr;
+   u8 current_ci_flag;
+   int ci_status;
+   struct i2c_client *i2c_client_tuner;
+};
+
+static int dvbsky_stream_ctrl(struct dvb_usb_device *d, u8 onoff)
+{
+   struct dvbsky_state *state = d_to_priv(d);
+   int ret;
+   u8 obuf_pre[3] = { 0x37, 0, 0 };
+   u8 obuf_post[3] = { 0x36, 3, 0 };
+   dprintk(%s() -off \n, __func__);
+   mutex_lock(state-stream_mutex);
+   ret = dvb_usbv2_generic_write(d, obuf_pre, 3);
+   if (!ret  onoff) {
+   msleep(10);
+   ret = dvb_usbv2_generic_write(d, obuf_post, 3);
+   dprintk(%s() -on \n, __func__);
+   }
+   mutex_unlock(state-stream_mutex);
+   return ret;
+}
+
+/* CI opertaions */
+static int dvbsky_ci_read_i2c(struct i2c_adapter *i2c_adap, u8 addr, u8 reg,
+   u8 *buf, int len)
+{
+   int ret;
+   struct i2c_msg msg[] = {
+   {
+   .addr   = addr,
+   .flags  = 0,
+   .buf= reg,
+   .len= 1
+   }, {
+   .addr   = addr,
+   .flags  = I2C_M_RD,
+   .buf= buf,
+   .len= len
+   }
+   };
+
+   ret = i2c_transfer(i2c_adap, msg, 2);
+   if (ret != 2) {
+   dprintk(%s: error, Reg = 0x%02x, 

[PATCH 4/4] support for DVBSky dvb-s2 usb: add dvbsky rc keymaps.

2014-08-05 Thread nibble.max
add dvbsky rc keymaps.

Signed-off-by: Nibble Max nibble@gmail.com
---
 drivers/media/rc/keymaps/Makefile|  1 +
 drivers/media/rc/keymaps/rc-dvbsky.c | 78 
 2 files changed, 79 insertions(+)

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 0b8c549..abf6079 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-dm1105-nec.o \
rc-dntv-live-dvb-t.o \
rc-dntv-live-dvbt-pro.o \
+   rc-dvbsky.o \
rc-em-terratec.o \
rc-encore-enltv2.o \
rc-encore-enltv.o \
diff --git a/drivers/media/rc/keymaps/rc-dvbsky.c 
b/drivers/media/rc/keymaps/rc-dvbsky.c
new file mode 100644
index 000..c5115a1
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-dvbsky.c
@@ -0,0 +1,78 @@
+/* rc-dvbsky.c - Keytable for DVBSky Remote Controllers
+ *
+ * keymap imported from ir-keymaps.c
+ *
+ *
+ * Copyright (c) 2010-2012 by Nibble Max nibble@gmail.com
+ *
+ * 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
+ * (at your option) any later version.
+ */
+
+#include media/rc-map.h
+#include linux/module.h
+/*
+ * This table contains the complete RC5 code, instead of just the data part
+ */
+
+static struct rc_map_table rc5_dvbsky[] = {
+   { 0x, KEY_0 },
+   { 0x0001, KEY_1 },
+   { 0x0002, KEY_2 },
+   { 0x0003, KEY_3 },
+   { 0x0004, KEY_4 },
+   { 0x0005, KEY_5 },
+   { 0x0006, KEY_6 },
+   { 0x0007, KEY_7 },
+   { 0x0008, KEY_8 },
+   { 0x0009, KEY_9 },
+   { 0x000a, KEY_MUTE },
+   { 0x000d, KEY_OK },
+   { 0x000b, KEY_STOP },
+   { 0x000c, KEY_EXIT },
+   { 0x000e, KEY_CAMERA }, /*Snap shot*/
+   { 0x000f, KEY_SUBTITLE }, /*PIP*/
+   { 0x0010, KEY_VOLUMEUP },
+   { 0x0011, KEY_VOLUMEDOWN },
+   { 0x0012, KEY_FAVORITES },
+   { 0x0013, KEY_LIST }, /*Info*/
+   { 0x0016, KEY_PAUSE },
+   { 0x0017, KEY_PLAY },
+   { 0x001f, KEY_RECORD },
+   { 0x0020, KEY_CHANNELDOWN },
+   { 0x0021, KEY_CHANNELUP },
+   { 0x0025, KEY_POWER2 },
+   { 0x0026, KEY_REWIND },
+   { 0x0027, KEY_FASTFORWARD },
+   { 0x0029, KEY_LAST },
+   { 0x002b, KEY_MENU },
+   { 0x002c, KEY_EPG },
+   { 0x002d, KEY_ZOOM },
+};
+
+static struct rc_map_list rc5_dvbsky_map = {
+   .map = {
+   .scan= rc5_dvbsky,
+   .size= ARRAY_SIZE(rc5_dvbsky),
+   .rc_type = RC_TYPE_RC5,
+   .name= RC_MAP_DVBSKY,
+   }
+};
+
+static int __init init_rc_map_rc5_dvbsky(void)
+{
+   return rc_map_register(rc5_dvbsky_map);
+}
+
+static void __exit exit_rc_map_rc5_dvbsky(void)
+{
+   rc_map_unregister(rc5_dvbsky_map);
+}
+
+module_init(init_rc_map_rc5_dvbsky)
+module_exit(exit_rc_map_rc5_dvbsky)
+
+MODULE_LICENSE(GPL);
+MODULE_AUTHOR(Nibble Max nibble@gmail.com);
  

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/4] support for DVBSky dvb-s2 usb: add dvbsky rc keymaps include file

2014-08-05 Thread nibble.max
add dvbsky rc keymaps include file.

Signed-off-by: Nibble Max nibble@gmail.com
---
 include/media/rc-map.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 80f9518..e7a1514 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -135,6 +135,7 @@ void rc_map_init(void);
 #define RC_MAP_DM1105_NECrc-dm1105-nec
 #define RC_MAP_DNTV_LIVE_DVBT_PROrc-dntv-live-dvbt-pro
 #define RC_MAP_DNTV_LIVE_DVB_T   rc-dntv-live-dvb-t
+#define RC_MAP_DVBSKYrc-dvbsky
 #define RC_MAP_EMPTY rc-empty
 #define RC_MAP_EM_TERRATEC   rc-em-terratec
 #define RC_MAP_ENCORE_ENLTV2 rc-encore-enltv2
  

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Re: Hauppauge HVR-900 HD and HVR 930C-HD with si2165

2013-08-20 Thread nibble.max
Hello Hans,

I am the original author of sit2 source code based on the reference code from 
silabs.
And we have signed NDA with silabs, it does not allow us to release the source 
code to the public.
I donot know it is permited or not when you do decompiling the binary code.

What happened between Konstantin Dimitrov and me, I think there is something 
misunderstand before.
But it looks it is not simple thing as I know he works for the competitor 
company.
I have some respect before, but now I think he is ridiculous and hostile.
As soon s his rumor release, we know our products really beat him.
What I want to tell him, please improve your products and make them stable.
The rumor just hurt him, not us. 
The customer start to do not believe him as they know the truth someday.

Finally, I have no relationship with Danny Griegs. He does not work for us and 
pay nothing to him.

BR,
Max
On 08/20/13 00:43, Konstantin Dimitrov wrote:
 German-based company making DVB equipment and maybe if that's the same
 RSD that Danny Griegs guy could be legit. however, nothing in the

Hi,

I've asked Danny to confirm his identity. The @googlemail.com e-mail 
transcript was quite empty :-(

According to Skype he is located in the GB. That's all I've got.

Hope this matter will resolve soon.

--HPS
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] cx23885[v2]: Fix IR interrupt storm.

2013-07-18 Thread nibble.max
Hello Luis,
The internel interrupts are rounted as follow:
flatiron(include ADC)---HammerHead(include IR inside)---Pecos(PCIe)
The flatiron interrupt is enabled when chip power up.
When HammerHead interrupt is enalbe in Pecos, the most of interrupts are coming 
from flatiron.
The more accurate code is that reading back these left and right 
registers(0x1f, 0x23), set its bit-7 to 1 , then write back.
So that it does not touch other bits.
BR,
Max

Hi all,
This path is meant to be up-streamed.

Andy has a nice explanation for the interrupt storm when
enabling the IR interrupt:

The flatiron core (the audio adc) signals the end of its self-test
with an interrupt. Since the flatiron irq seems OR-wired
with the IR irq the result is this interrupt storm.
This i2c tranfers will clear the flatiron interrupts - the left
and right channels self-tests.

Also as suggested by Andy I moved the i2c transfers to the
cx23885 av core interrupt handling worker. If any spurious
interrupt happens we silence them.

The flatiron has some dedicated register read/write functions but are
not exported so Antti just suggested to call the i2c_transfer directly.

Tested in the TBS6981 Dual DVB-S2 card.

PS: I've found this i2c_transfers in TBS media tree, more precisely
in the cx23885-i2c.c file.

Regards,
Luis


Signed-off-by: Luis Alves lja...@gmail.com
---
 drivers/media/pci/cx23885/cx23885-av.c |   17 +
 1 file changed, 17 insertions(+)

diff --git a/drivers/media/pci/cx23885/cx23885-av.c 
b/drivers/media/pci/cx23885/cx23885-av.c
index e958a01..d33570f 100644
--- a/drivers/media/pci/cx23885/cx23885-av.c
+++ b/drivers/media/pci/cx23885/cx23885-av.c
@@ -29,8 +29,25 @@ void cx23885_av_work_handler(struct work_struct *work)
   struct cx23885_dev *dev =
  container_of(work, struct cx23885_dev, cx25840_work);
   bool handled;
+  char buffer[2];
+  struct i2c_msg msg = {
+  .addr = 0x98  1,
+  .flags = 0,
+  .len = 2,
+  .buf = buffer,
+  };
 
   v4l2_subdev_call(dev-sd_cx25840, core, interrupt_service_routine,
PCI_MSK_AV_CORE, handled);
+
+  if (!handled) {
+  /* clear any pending flatiron interrupts */
+  buffer[0] = 0x1f;
+  buffer[1] = 0x80;
+  i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+  buffer[0] = 0x23;
+  i2c_transfer(dev-i2c_bus[2].i2c_adap, msg, 1);
+  }
+
   cx23885_irq_enable(dev, PCI_MSK_AV_CORE);
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Re: [PATCH 2/2] [media] ds3000: properly report firmware loadingissues

2012-08-31 Thread nibble.max
As remember that there is a fault in the tuner register read function in 
ds3000.c file.
It will cause the read back value wrong.
ds3000.c file, 
static int ds3000_tuner_readreg(struct ds3000_state *state, u8 reg)
{
...
ds3000_writereg(state, 0x03, 0x12);
...
}
in DVBSky code, m88ds3103.c file,
static int m88ds3103_tuner_readreg(struct m88ds3103_state *state, u8 reg)
{

m88ds3103_writereg(state, 0x03, 0x11);

}
DVBSky code can read back the value correctly. 
As known that m88ds3103.c also supports the older tuner(m88ts2020) and 
demodulator(m88ds3000/3002).

2012-08-31 16:18:38 nibble@gmail.com
On 08/30/2012 06:21 PM, Rémi Cardona wrote:
 Hi Antti,

 On 08/30/2012 03:39 PM, Antti Palosaari wrote:
 As I understand firmware downloading failure is coming from the fact
 that register read fails = fails to detect if firmware is already
 running or not.

 Well we actually see 2 cases:

   - the register read failure (when ds3000_readreg() returns negative
 values). This case is fairly rare, and no changes we've done to the
 driver allowed us to make those cards work.

hmm, looks like ds3000_readreg() logic is still a little bit broken. It 
checks count of sent messages and compares it to 2. But if I2C-adapter 
sends only 1 message or 3 (which should not be possible) function return 
that count instead of -EREMOTEIO. OK, quite rare situation, but one 
point more to fail if I2C-adapter has also bug.

But that happens for return value 0 too. Could it be the issue? 
I2C-adapter returns 0 for some reason? Bug in I2C-adapter with bug in 
ds3000_readreg() implementation?

   - the register read returning 0. Looking at the current code, it looks
 like the 0xb2 register is supposed to mean that a firmware is loaded.
 This case is fairly common: we've had many cards randomly saying that a
 firmware was loaded when none had been. Often, a simple reboot will do
 the trick. But sometimes, forcing the firmware upload (ie, bypassing the
 0xb2 register check) allows the stubborn cards to function properly.

 Original behavior to expect firmware is loaded and running when register
 read fails is very stupid and your fix seems much better.

 Well, this patch should not really change the behavior. It just
 propagates register read errors to ds3000_initfe(). It'll just fail earlier.

 So first priority should be try fix that issue with register read. Is it
 coming from the USB stack (eg. error 110 timeout) or some other error
 coming from the fact chip answers wrong?

 The cards we're using are PCIe (and not the ones with an embedded USB
 controller).

The idea of my question was to ask where those errors are coming from (I 
spoke mistakenly about USB because I usually play with USB devices).

You basically see two different kind of errors, 1) bus communication 
fails, eg. usb timeouts. 2) chips returns error status. Later cases the 
error could come from the this could come from the firmware if chip uses 
firmware or from the silicon. It could be from the I2C-adapter firmware.

 Do you see other register I/O failing too?

 I'll see if I can get you an answer for that, since the cards are
 shipped with the appliance we send to our customers. Remote debugging is
 somewhat tricky.

 Does adding few usec sleep help?

 I'm not quite sure where to add those sleeps. In the register
 reading/writing functions? 10us? 100us?

Add sleep after the each operation. Good place to add sleep is 
I2C-adapter. I2C-adapters usually supports two different operations, 
write and read + write using repeated START condition. Former us used 
typically for register write and later for register read.

500us is good choice. If it is only that one register read which causes 
problems, how about repeating it?


 Many thanks

 Rémi



-- 
http://palosaari.fi/
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
N�r��yb�X��ǧv�^�)޺{.n�+{���bj)w*jg����ݢj/���z�ޖ��2�ޙ�)ߡ�a�����G���h��j:+v���w��٥

Demod hardware pid filter implement

2012-04-28 Thread nibble.max
Hello Antti,
As we known that AF9013 has the hardware pid filter capability.
How to implement the hardware pid filter, which the demodulator has this 
capability?

For usb, i find 
struct dvb_usb_adapter_fe_properties {
int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
int (*pid_filter)  (struct dvb_usb_adapter *, int, u16, int);
...
It can implement the hardware filter if the demodulator has.

But on the other interface, i do not find similar solution.
For example, we have a hardware of AF9013 and CX23885 pcie chip and want to use 
the hardware pid filter in AF9013.
i find some codes to hook the dvb.demux to do that pid filtering.
I think it is demod property, but the current dvb_frontend_ops has no 
definition for this.
It is better that adding a function pointer of pid filtering in 
dvb_frontend_ops to do in general way.
What is your idea?

BR,
Max

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6 v2] dvbsky, dvb-s/s2 usb box

2012-04-27 Thread nibble.max
Also fix some code sytle errors checked by checkpatch.pl.
---
 drivers/media/dvb/dvb-usb/Kconfig  |2 +
 drivers/media/dvb/dvb-usb/dw2102.c |  337 
 2 files changed, 305 insertions(+), 34 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/Kconfig 
b/drivers/media/dvb/dvb-usb/Kconfig
index be1db75..93c9381 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -279,6 +279,8 @@ config DVB_USB_DW2102
select DVB_STV0288 if !DVB_FE_CUSTOMISE
select DVB_STB6000 if !DVB_FE_CUSTOMISE
select DVB_CX24116 if !DVB_FE_CUSTOMISE
+   select DVB_M88TS202X if !DVB_FE_CUSTOMISE
+   select DVB_M88DS3103 if !DVB_FE_CUSTOMISE
select DVB_SI21XX if !DVB_FE_CUSTOMISE
select DVB_TDA10023 if !DVB_FE_CUSTOMISE
select DVB_MT312 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c 
b/drivers/media/dvb/dvb-usb/dw2102.c
index 451c5a7..1cf62fb 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -19,6 +19,8 @@
 #include stb6000.h
 #include eds1547.h
 #include cx24116.h
+#include m88ts202x.h
+#include m88ds3103.h
 #include tda1002x.h
 #include mt312.h
 #include zl10039.h
@@ -118,12 +120,12 @@ MODULE_PARM_DESC(demod, demod to probe (1=cx24116 
2=stv0903+stv6110 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 static int dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
-   u16 index, u8 * data, u16 len, int flags)
+   u16 index, u8 *data, u16 len, int flags)
 {
int ret;
u8 *u8buf;
unsigned int pipe = (flags == DW210X_READ_MSG) ?
-   usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 
0);
+   usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
 
u8buf = kmalloc(len, GFP_KERNEL);
@@ -133,7 +135,8 @@ static int dw210x_op_rw(struct usb_device *dev, u8 request, 
u16 value,
 
if (flags == DW210X_WRITE_MSG)
memcpy(u8buf, data, len);
-   ret = usb_control_msg(dev, pipe, request, request_type | 
USB_TYPE_VENDOR,
+   ret = usb_control_msg(dev, pipe,
+   request, request_type | USB_TYPE_VENDOR,
value, index , u8buf, len, 2000);
 
if (flags == DW210X_READ_MSG)
@@ -179,7 +182,7 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, 
struct i2c_msg msg[],
break;
case 0x60:
if (msg[0].flags == 0) {
-   /* write to tuner pll */
+   /* write to tuner pll */
buf6[0] = 0x2c;
buf6[1] = 5;
buf6[2] = 0xc0;
@@ -190,7 +193,7 @@ static int dw2102_i2c_transfer(struct i2c_adapter *adap, 
struct i2c_msg msg[],
ret = dw210x_op_rw(d-udev, 0xb2, 0, 0,
buf6, 7, DW210X_WRITE_MSG);
} else {
-   /* read from tuner */
+   /* read from tuner */
ret = dw210x_op_rw(d-udev, 0xb5, 0, 0,
buf6, 1, DW210X_READ_MSG);
msg[0].buf[0] = buf6[0];
@@ -273,7 +276,8 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter 
*adap,
return num;
 }
 
-static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg 
msg[], int num)
+static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap,
+   struct i2c_msg msg[], int num)
 {
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int ret = 0;
@@ -346,7 +350,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter 
*adap, struct i2c_msg ms
return num;
 }
 
-static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], 
int num)
+static int dw2104_i2c_transfer(struct i2c_adapter *adap,
+   struct i2c_msg msg[], int num)
 {
struct dvb_usb_device *d = i2c_get_adapdata(adap);
int ret = 0;
@@ -712,7 +717,8 @@ static int dw210x_read_mac_address(struct dvb_usb_device 
*d, u8 mac[6])
u8 eeprom[256], eepromline[16];
 
for (i = 0; i  256; i++) {
-   if (dw210x_op_rw(d-udev, 0xb6, 0xa0 , i, ibuf, 2, 
DW210X_READ_MSG)  0) {
+   if (dw210x_op_rw(d-udev, 0xb6, 0xa0 , i, ibuf, 2,
+   DW210X_READ_MSG)  0) {
err(read eeprom failed.);
return -1;
} else {
@@ -882,6 +888,41 @@ static int s660_set_voltage(struct dvb_frontend *fe, 
fe_sec_voltage_t voltage)
return 0;
 }
 
+static int bstusb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t 
voltage)
+{

[PATCH 3/6 v2] dvbsky, dvb-s/s2 PCIe card

2012-04-27 Thread nibble.max
Also fix some code sytle errors checked by checkpatch.pl.
---
 drivers/media/video/cx23885/Kconfig |2 +
 drivers/media/video/cx23885/cx23885-cards.c |  106 +++
 drivers/media/video/cx23885/cx23885-dvb.c   |   90 ++-
 drivers/media/video/cx23885/cx23885-f300.c  |   51 +
 drivers/media/video/cx23885/cx23885-f300.h  |6 ++
 drivers/media/video/cx23885/cx23885-input.c |   15 
 drivers/media/video/cx23885/cx23885.h   |6 +-
 7 files changed, 273 insertions(+), 3 deletions(-)

diff --git a/drivers/media/video/cx23885/Kconfig 
b/drivers/media/video/cx23885/Kconfig
index b391e9b..33325f4 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -20,6 +20,8 @@ config VIDEO_CX23885
select DVB_LNBP21 if !DVB_FE_CUSTOMISE
select DVB_STV6110 if !DVB_FE_CUSTOMISE
select DVB_CX24116 if !DVB_FE_CUSTOMISE
+   select DVB_M88TS202X if !DVB_FE_CUSTOMISE
+   select DVB_M88DS3103 if !DVB_FE_CUSTOMISE
select DVB_STV0900 if !DVB_FE_CUSTOMISE
select DVB_DS3000 if !DVB_FE_CUSTOMISE
select DVB_STV0367 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/video/cx23885/cx23885-cards.c 
b/drivers/media/video/cx23885/cx23885-cards.c
index 19b5499..8f13990 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -497,7 +497,22 @@ struct cx23885_board cx23885_boards[] = {
.name   = TerraTec Cinergy T PCIe Dual,
.portb  = CX23885_MPEG_DVB,
.portc  = CX23885_MPEG_DVB,
+   },
+
+   [CX23885_BOARD_BST_PS8512] = {
+   .name   = Bestunar PS8512,
+   .portb  = CX23885_MPEG_DVB,
+   },
+   [CX23885_BOARD_DVBSKY_S950] = {
+   .name   = DVBSKY S950,
+   .portb  = CX23885_MPEG_DVB,
+   },
+   [CX23885_BOARD_DVBSKY_S952] = {
+   .name   = DVBSKY S952,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
}
+
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -705,6 +720,18 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x153b,
.subdevice = 0x117e,
.card  = CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL,
+   }, {
+   .subvendor = 0x14f1,
+   .subdevice = 0x8512,
+   .card  = CX23885_BOARD_BST_PS8512,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0950,
+   .card  = CX23885_BOARD_DVBSKY_S950,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0952,
+   .card  = CX23885_BOARD_DVBSKY_S952,
},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1216,9 +1243,55 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* enable irq */
cx_write(GPIO_ISM, 0x);/* INTERRUPTS active low*/
break;
+   case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_BST_PS8512:
+   cx23885_gpio_enable(dev, GPIO_2, 1);
+   cx23885_gpio_clear(dev, GPIO_2);
+   msleep(100);
+   cx23885_gpio_set(dev, GPIO_2);
+   break;
+   case CX23885_BOARD_DVBSKY_S952:
+   cx_write(MC417_CTL, 0x0037);/* enable GPIO3-18 pins */
+
+   cx23885_gpio_enable(dev, GPIO_2, 1);
+   cx23885_gpio_enable(dev, GPIO_11, 1);
+   cx23885_gpio_clear(dev, GPIO_2);
+   cx23885_gpio_clear(dev, GPIO_11);
+   msleep(100);
+   cx23885_gpio_set(dev, GPIO_2);
+   cx23885_gpio_set(dev, GPIO_11);
+   break;
}
 }
 
+static int cx23885_ir_patch(struct i2c_adapter *i2c, u8 reg, u8 mask)
+{
+   struct i2c_msg msgs[2];
+   u8 tx_buf[2], rx_buf[1];
+   /* Write register address */
+   tx_buf[0] = reg;
+   msgs[0].addr = 0x4c;
+   msgs[0].flags = 0;
+   msgs[0].len = 1;
+   msgs[0].buf = (char *) tx_buf;
+   /* Read data from register */
+   msgs[1].addr = 0x4c;
+   msgs[1].flags = I2C_M_RD;
+   msgs[1].len = 1;
+   msgs[1].buf = (char *) rx_buf;
+
+   i2c_transfer(i2c, msgs, 2);
+
+   tx_buf[0] = reg;
+   tx_buf[1] = rx_buf[0] | mask;
+   msgs[0].addr = 0x4c;
+   msgs[0].flags = 0;
+   msgs[0].len = 2;
+   msgs[0].buf = (char *) tx_buf;
+
+   return i2c_transfer(i2c, msgs, 1);
+}
+
 int cx23885_ir_init(struct cx23885_dev *dev)
 {
static struct v4l2_subdev_io_pin_config ir_rxtx_pin_cfg[] = {
@@ -1301,6 +1374,20 @@ int cx23885_ir_init(struct cx23885_dev *dev)
v4l2_subdev_call(dev-sd_cx25840, core, s_io_pin_config,
 ir_rx_pin_cfg_count, 

[PATCH 5/6 v2] dvbsky, remote control key map

2012-04-27 Thread nibble.max
---
 drivers/media/rc/keymaps/Makefile|1 +
 drivers/media/rc/keymaps/rc-dvbsky.c |   77 ++
 2 files changed, 78 insertions(+)
 create mode 100644 drivers/media/rc/keymaps/rc-dvbsky.c

diff --git a/drivers/media/rc/keymaps/Makefile 
b/drivers/media/rc/keymaps/Makefile
index 49ce266..e6a882b 100644
--- a/drivers/media/rc/keymaps/Makefile
+++ b/drivers/media/rc/keymaps/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
rc-dm1105-nec.o \
rc-dntv-live-dvb-t.o \
rc-dntv-live-dvbt-pro.o \
+   rc-dvbsky.o \
rc-em-terratec.o \
rc-encore-enltv2.o \
rc-encore-enltv.o \
diff --git a/drivers/media/rc/keymaps/rc-dvbsky.c 
b/drivers/media/rc/keymaps/rc-dvbsky.c
new file mode 100644
index 000..25a531c
--- /dev/null
+++ b/drivers/media/rc/keymaps/rc-dvbsky.c
@@ -0,0 +1,77 @@
+/* rc-dvbsky.c - Keytable for Dvbsky Remote Controllers
+ *
+ *
+ *
+ *   Copyright (C) 2011 Max nibblenibble@gmail.com
+ *
+ * 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
+ * (at your option) any later version.
+ */
+
+#include media/rc-map.h
+#include linux/module.h
+/*
+ * This table contains the complete RC5 code, instead of just the data part
+ */
+
+static struct rc_map_table rc5_dvbsky[] = {
+   { 0x, KEY_0 },
+   { 0x0001, KEY_1 },
+   { 0x0002, KEY_2 },
+   { 0x0003, KEY_3 },
+   { 0x0004, KEY_4 },
+   { 0x0005, KEY_5 },
+   { 0x0006, KEY_6 },
+   { 0x0007, KEY_7 },
+   { 0x0008, KEY_8 },
+   { 0x0009, KEY_9 },
+   { 0x000a, KEY_MUTE },
+   { 0x000d, KEY_OK },
+   { 0x000b, KEY_STOP },
+   { 0x000c, KEY_EXIT },
+   { 0x000e, KEY_CAMERA }, /*Snap shot*/
+   { 0x000f, KEY_SUBTITLE }, /*PIP*/
+   { 0x0010, KEY_VOLUMEUP },
+   { 0x0011, KEY_VOLUMEDOWN },
+   { 0x0012, KEY_FAVORITES },
+   { 0x0013, KEY_LIST }, /*Info*/
+   { 0x0016, KEY_PAUSE },
+   { 0x0017, KEY_PLAY },
+   { 0x001f, KEY_RECORD },
+   { 0x0020, KEY_CHANNELDOWN },
+   { 0x0021, KEY_CHANNELUP },
+   { 0x0025, KEY_POWER2 },
+   { 0x0026, KEY_REWIND },
+   { 0x0027, KEY_FASTFORWARD },
+   { 0x0029, KEY_LAST },
+   { 0x002b, KEY_MENU },
+   { 0x002c, KEY_EPG },
+   { 0x002d, KEY_ZOOM },
+};
+
+static struct rc_map_list rc5_dvbsky_map = {
+   .map = {
+   .scan= rc5_dvbsky,
+   .size= ARRAY_SIZE(rc5_dvbsky),
+   .rc_type = RC_TYPE_RC5,
+   .name= RC_MAP_DVBSKY,
+   }
+};
+
+static int __init init_rc_map_rc5_dvbsky(void)
+{
+   return rc_map_register(rc5_dvbsky_map);
+}
+
+static void __exit exit_rc_map_rc5_dvbsky(void)
+{
+   rc_map_unregister(rc5_dvbsky_map);
+}
+
+module_init(init_rc_map_rc5_dvbsky)
+module_exit(exit_rc_map_rc5_dvbsky)
+
+MODULE_LICENSE(GPL);
+MODULE_AUTHOR(Max nibble nibble@gmail.com);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6 v2] dvbsky, remote control include header file

2012-04-27 Thread nibble.max
---
 include/media/rc-map.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/include/media/rc-map.h b/include/media/rc-map.h
index 8db6741..7176dac 100644
--- a/include/media/rc-map.h
+++ b/include/media/rc-map.h
@@ -85,6 +85,7 @@ void rc_map_init(void);
 #define RC_MAP_DM1105_NECrc-dm1105-nec
 #define RC_MAP_DNTV_LIVE_DVBT_PROrc-dntv-live-dvbt-pro
 #define RC_MAP_DNTV_LIVE_DVB_T   rc-dntv-live-dvb-t
+#define RC_MAP_DVBSKYrc-dvbsky
 #define RC_MAP_EMPTY rc-empty
 #define RC_MAP_EM_TERRATEC   rc-em-terratec
 #define RC_MAP_ENCORE_ENLTV2 rc-encore-enltv2
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Re: [PATCH 1/6 v2] dvbsky, montage dvb-s/s2 TS202x tuner and M88DS3103demodulator driver

2012-04-27 Thread nibble.max
2012-04-27 22:03:20 nibble@gmail.com
Em 27-04-2012 04:06, nibble.max escreveu:
 ---
  drivers/media/dvb/frontends/Kconfig  |   14 +
  drivers/media/dvb/frontends/Makefile |3 +
  drivers/media/dvb/frontends/m88ds3103.c  | 1153 
 ++
  drivers/media/dvb/frontends/m88ds3103.h  |   67 ++
  drivers/media/dvb/frontends/m88ds3103_priv.h |  413 +
  drivers/media/dvb/frontends/m88ts202x.c  |  590 +
  drivers/media/dvb/frontends/m88ts202x.h  |   63 ++
  7 files changed, 2303 insertions(+)
  create mode 100644 drivers/media/dvb/frontends/m88ds3103.c
  create mode 100644 drivers/media/dvb/frontends/m88ds3103.h
  create mode 100644 drivers/media/dvb/frontends/m88ds3103_priv.h
  create mode 100644 drivers/media/dvb/frontends/m88ts202x.c
  create mode 100644 drivers/media/dvb/frontends/m88ts202x.h

No, this is not what we've agreed. You should, instead, take Konstantin's 
driver, 
breaking it into two separate ones, without touching the copyrights. Then, 
apply
what else is needed for ds3103/ts2123.
Hello Mauro,

Should I need Konstantin's agreement to do that?
Using the seperate tuner and demod, I need to change the codes which use the 
ds3000 frontend.
How can I test the code to confirm that these codes are right without these 
hardwards?

If I can not do this work, the new m88ds3103 and m88ts2022 code can not be 
patched in the upstream.
It seems i go to a dead lock, doesn't it?

Br,
Max

 diff --git a/drivers/media/dvb/frontends/m88ds3103.c 
 b/drivers/media/dvb/frontends/m88ds3103.c
 new file mode 100644
 index 000..392cada
 --- /dev/null
 +++ b/drivers/media/dvb/frontends/m88ds3103.c
 @@ -0,0 +1,1153 @@
 +/*
 +Montage Technology M88DS3103/3000 - DVBS/S2 Satellite demod driver
 +
 +Copyright (C) 2011 Max nibblenibble@gmail.com

Adding your copyright like that only justifies if you make significant 
contributions
to the code. Adding support for a new card or a new chip within the same chip 
family
in general don't fit on that. 

If Konstantin is ok, you may, instead, add, at the bottom of the copyright 
list, something like:

Copyright (C) 2011 Max nibblenibble@gmail.com
   - Add support for ds3103

 +Copyright (C) 2010 Montage Technologywww.montage-tech.com
 +Fix some bug and add M88DS3103 code, M88DS3000 code based on DS3000.c.
 +
 +Copyright (C) 2009 Konstantin Dimitrov kosio.dimit...@gmail.com
 +
 +Copyright (C) 2009 TurboSight.com

Regards,
Mauro

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Re: [PATCH 1/6] m88ds3103, montage dvb-s/s2 demodulator driver

2012-04-27 Thread nibble.max
2012-04-28 10:57:19 nibble@gmail.com
Antti, Mauro,

i believe we're all on the same page here and i just want to summarize
based on all the discussion so far and if we all agree:

1) ds3000 and ts2020 code split, there are already several strong
arguments about it and most of all that it turned out there is
reference design with 3rd party tuner that works both with ds3000 and
stv090x demodulators. i will take care of this task


Montage demodulator has worked with Sharp 6306 CAN tuner for several years.
I suggest to put the dvb-s/s2 initialize constant data of ds3000 to the 
seperate files.
As i patch ds3103, it has also dvb-s/s2 initialize datas. 
It will make ds3000 file too long and ugly to review.
As i do in the try patch placing them into ds3000_priv.h.

2) the result of 1) would be that the following DVB-S2 tuner and
demodulator drivers will be able to work in any combination of each
other (assuming there is such hardware design available): stb0899*,
stv090x*, ds3000, stv6110x*, stb6100* and ts2020. that's good, because
it starts to put order, because those are significant part of the
DVB-S2 drivers in the kernel

3) not only, because of 2), but in general it's not clear why there is
stv6110.* driver, which is for the exact same silicone as stv6110x*,
as well stv0900*, which is for the same family of chips as stv090x*. i
can help a little here to the degree that i can make all bridge
drivers depend on stv6110x* and stv090x* except the driver for one
card made by NetUP - there i can just do it in theory, but i can't
test and probably break support for it

4) after 1), 2) and if 3) is resolved the only DVB-S2 drivers that
will continue to be married to one particular tuner (CX24118A) that
will left are cx24116 and tda10071, which for the time being will be
left that way until basically there is someone that volunteers to make
separate CX24118A driver based on the LG, SHARP and Comtech datasheets
that are available in the public domain, for which i gave details in a
previous email, and which in my opinion contain sufficient information
that task to be made

5) ds3103 and ts2022 support, done in form of a patch respectively to
ds3000 driver and ts2020 driver or if ts2022 happens to be very
different than ts2020 then ts2022 support be made as separate driver,
i guess Max will take this


FYI,We have approval from Montage to let us use its reference code under GPLv2 
lincense.

But to their surprise, they review ds3000.c and find the tuner and demod config 
part almost same as their reference code.
They have not agree anybody to public their code under GPLv2 before.
They doubt that ds3000.c public is breaking their NDA without their permission.

6) if it's necessary bug fixes, improvements, etc to the shared code
between ds3000 and ds3103, but only after review, discussion and
argumentation why those changes are actually needed


On Fri, Apr 27, 2012 at 11:42 PM, Antti Palosaari cr...@iki.fi wrote:
 On 27.04.2012 23:21, Konstantin Dimitrov wrote:

 On Fri, Apr 27, 2012 at 10:55 PM, Antti Palosaaricr...@iki.fi  wrote:

 On 27.04.2012 22:01, Konstantin Dimitrov wrote:


 Mauro, your reasoning makes sense to me. so, let's split them and at
 least settle this part of the discussion - i will do as far as my
 spare time allows, as well make sure there are no some problems
 introduced after the split.

 also, in one email i've just sent in answer to Antti there is enough
 argument why such split, i.e. tuner-pass-through-mode is subject to
 discussion about CX24116 and TDA10071 drivers too. currently, majority
 of DVB-S2 demodulator drivers in the kernel are married to particular
 tuners and there is no split.



 I read the mail and as it was long study, I comment only that
 CX24116+CX24118A and TDA10071+CX24118A demod+tuner combos versus Montage
 demod+tuner combos. As you may see, CX24116 and TDA10071 are so much
 different than both needs own driver. But as you said those are married
 always as a demod+tuner.

 So if I use your logic, what happens if CX24118A tuner is not driven by
 CX24116 or TDA10071 firmware? ==  it happens we have two drivers,
 CX24116
 and TDA10071 *both* having similar CX24118A tuner driver code inside!
 Same
 tuner driver code inside two demods drivers. Could you now understand why
 we
 want it split?
 The reason which saves us having CX24118A tuner driver is that it is
 inside
 both CX24116 and TDA10071 firmware.

 There is mainly two different controlling situation. Most commonly driver
 controls chip but in some cases it is firmware which is controlling. And
 I
 don't see it very important trying always to by-pass firmware control and
 use driver for that.


 i got that point, but what happens if tomorrow their is CX24116 or
 TDA10071 design with tuner different than CX14118A? in fact the LG
 datasheet i pointed out to you clearly states that for example there
 is actually such design - case when CX24116 is used with CX24128 tuner
 instead CX24118A in which case the only way is 

Re: Re: Re: [PATCH 1/6] m88ds3103, montage dvb-s/s2 demodulator driver

2012-04-26 Thread nibble.max
2012-04-26 20:59:28 nibble@gmail.com
2012-04-24 09:50:33 nibble@gmail.com
Em 23-04-2012 19:51, Konstantin Dimitrov escreveu:
 Antti, i already commented about ds3103 drivers months ago:
 
 also, why Montage tuner code should be spitted from the demodulator
 code? is there any evidence that any Montage tuner (ts2020 or ts2022)
 can work with 3rd party demodulator different than ds3000 or ds3103?

This has nothing to do with Montage devices, but with the way we write
those drivers in Kernel.

There are _several_ examples where the driver for a single silicon were
turned into more than one driver. The biggest examples are the SoC chips,
that are transformed into a large series of drivers.

Another example is the cx88 driver: due to technical reasons, it was splitted 
into 4 drivers, one for each different PCI ID exported by it. 

The cx2341x driver is also an interesting example: while it used to be for a
separate chip, the cx2341x functions are now part of IP blocks on newer 
Conexant chipsets. Those single chips require two drivers to work (cx2341x
and the associated media PCI bridge driver).

Looking into tuners, there are the tda18271 family of devices, with are
supported by several drivers: tda827x, tda8290 and tda18271-fe, depending
on how the actual device is mounted. Eventually, the actual tuner may
also have a tda9887 inside it.

So, there's nothing wrong on splitting it on separate drivers. In a matter of
fact, we strongly prefer to have tuners separate from demods. Having them
together can only be justified technically, if there are really strong reasons
why they should be at the same driver.

I probably missed this at my review for ds3000 (that's why it ended by being
merged), but, on the review I did on it (accidentally due to m88ds3103 
patchset
review), it is clear that the tuner has actually a different I2C address 
(0x60)
than the demod, and it is indeed a separate device. Sorry for slipping into 
it.

Anyway, now that this is noticed, tuner and demod drivers should be split,
especially since there are some patches floating around to add support for 
ds3103.

As I said before, the right thing to do is:

  1) split ds3000 from ts2020 at the existing driver;
  2) add support for the newer chips (ds3103/ts2022) to the ds3000 and 
 ds3103
 drivers.
  3) test if the patches adding support for the newer chips didn't break 
 the
 support for existing hardware.

My proposal is that tasks (1) and (3) should be handled by you. As Max wants 
to
add support for some devices based on ds3103/ts2022, IMO, he can do the 
patches
for (2) in a way that they would be acceptable by you, as the driver 
maintainer
for ds3000/ts2020, testing with their devices.

Regards,
Mauro

Montage M88ds3103 is not only working with its own tuners. 
It works with silicon tuner including AV2011, AV2026 and CAN tuner including 
sharp6306, sharp7803 and sharp7903 etc.
How to add these supports in the single file? It is really headache. 
So I think that spliting the tuner and demod file is only right way.

First I read the source code of DS3000 and show respects to ds3000 work in 
linux.
But find that it can not read back the tuner register correctly, and not set 
the right tuner bandwidth filter,etc.
I fix all those bugs and also update ds3000 firmware to the latest one.
The big one is that I start to add m88ds3103 demodulator and m88ts2022 tuner 
support. It is not just the work as simple as adding some constant. there are 
much difference as you can see much switch and if to apply the especial code 
for new tuner and demodulator.

But Konstantin tell me that I have no right to put the copyright in the file, 
even say many bad words to my works.
As I know that Konstantin works for the competitor company, I donot care the 
fight of his company and dvbsky.
Dvbsky develops its hardware by their own, and write windows driver. some of 
their technical guys have more than ten years in PC tuner design experience 
from old analog one based on bt878 chip. ohh, this story is out of this topic, 
sorry.

As many requirements to run into linux, I become the candidate to do it. 
It is public and open project, everybody can contribute to it. Is it right?
I think it is unfair and is abnormal for open source project. 
even start to read the GNU document carefully to check if the original author 
deny your work in the wrong way, what can i do?
So I decide to rewrite the code from scratch, and find almost ds3000 code copy 
from the reference code except the driver framework. 
It is obvious that the code is old one, montage update its ds3000 code after 
Konstantin' works. So I update to the new one.
I have no hardware of Konstantin's works and patch the original ds3000 because 
more complex works.
That is why I decide to write the new m88ds3103 file and put copyright of 
Montage and Konstantin as well to show repects to both.

BR,
Max

Hello,
I finish the following works.
1)split the montage dvb-s2 frontend into 

Re: Re: [PATCH 1/6] m88ds3103, montage dvb-s/s2 demodulator driver

2012-04-23 Thread nibble.max
2012-04-24 09:50:33 nibble@gmail.com
Em 23-04-2012 19:51, Konstantin Dimitrov escreveu:
 Antti, i already commented about ds3103 drivers months ago:
 
 also, why Montage tuner code should be spitted from the demodulator
 code? is there any evidence that any Montage tuner (ts2020 or ts2022)
 can work with 3rd party demodulator different than ds3000 or ds3103?

This has nothing to do with Montage devices, but with the way we write
those drivers in Kernel.

There are _several_ examples where the driver for a single silicon were
turned into more than one driver. The biggest examples are the SoC chips,
that are transformed into a large series of drivers.

Another example is the cx88 driver: due to technical reasons, it was splitted 
into 4 drivers, one for each different PCI ID exported by it. 

The cx2341x driver is also an interesting example: while it used to be for a
separate chip, the cx2341x functions are now part of IP blocks on newer 
Conexant chipsets. Those single chips require two drivers to work (cx2341x
and the associated media PCI bridge driver).

Looking into tuners, there are the tda18271 family of devices, with are
supported by several drivers: tda827x, tda8290 and tda18271-fe, depending
on how the actual device is mounted. Eventually, the actual tuner may
also have a tda9887 inside it.

So, there's nothing wrong on splitting it on separate drivers. In a matter of
fact, we strongly prefer to have tuners separate from demods. Having them
together can only be justified technically, if there are really strong reasons
why they should be at the same driver.

I probably missed this at my review for ds3000 (that's why it ended by being
merged), but, on the review I did on it (accidentally due to m88ds3103 patchset
review), it is clear that the tuner has actually a different I2C address (0x60)
than the demod, and it is indeed a separate device. Sorry for slipping into it.

Anyway, now that this is noticed, tuner and demod drivers should be split,
especially since there are some patches floating around to add support for 
ds3103.

As I said before, the right thing to do is:

   1) split ds3000 from ts2020 at the existing driver;
   2) add support for the newer chips (ds3103/ts2022) to the ds3000 and 
 ds3103
  drivers.
   3) test if the patches adding support for the newer chips didn't break 
 the
  support for existing hardware.

My proposal is that tasks (1) and (3) should be handled by you. As Max wants to
add support for some devices based on ds3103/ts2022, IMO, he can do the patches
for (2) in a way that they would be acceptable by you, as the driver maintainer
for ds3000/ts2020, testing with their devices.

Regards,
Mauro

Montage M88ds3103 is not only working with its own tuners. 
It works with silicon tuner including AV2011, AV2026 and CAN tuner including 
sharp6306, sharp7803 and sharp7903 etc.
How to add these supports in the single file? It is really headache. 
So I think that spliting the tuner and demod file is only right way.

First I read the source code of DS3000 and show respects to ds3000 work in 
linux.
But find that it can not read back the tuner register correctly, and not set 
the right tuner bandwidth filter,etc.
I fix all those bugs and also update ds3000 firmware to the latest one.
The big one is that I start to add m88ds3103 demodulator and m88ts2022 tuner 
support. It is not just the work as simple as adding some constant. there are 
much difference as you can see much switch and if to apply the especial code 
for new tuner and demodulator.

But Konstantin tell me that I have no right to put the copyright in the file, 
even say many bad words to my works.
As I know that Konstantin works for the competitor company, I donot care the 
fight of his company and dvbsky.
Dvbsky develops its hardware by their own, and write windows driver. some of 
their technical guys have more than ten years in PC tuner design experience 
from old analog one based on bt878 chip. ohh, this story is out of this topic, 
sorry.

As many requirements to run into linux, I become the candidate to do it. 
It is public and open project, everybody can contribute to it. Is it right?
I think it is unfair and is abnormal for open source project. 
even start to read the GNU document carefully to check if the original author 
deny your work in the wrong way, what can i do?
So I decide to rewrite the code from scratch, and find almost ds3000 code copy 
from the reference code except the driver framework. 
It is obvious that the code is old one, montage update its ds3000 code after 
Konstantin' works. So I update to the new one.
I have no hardware of Konstantin's works and patch the original ds3000 because 
more complex works.
That is why I decide to write the new m88ds3103 file and put copyright of 
Montage and Konstantin as well to show repects to both.

BR,
Max

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to 

Re: Re: [PATCH 1/6] m88ds3103, montage dvb-s/s2 demodulator driver

2012-04-20 Thread nibble.max
2012-04-20 15:56:27 nibble@gmail.com
At first time, I check it exist so try to patch it.
But with new m88ds3103 features to add and ts2022 tuner include, find it is 
hard to do simply patch.
It is better to create a new driver for maintain.
Hi Max,

Em 15-04-2012 12:53, nibble.max escreveu:
 Montage m88ds3103 demodulator and ts2022 tuner driver.

It was pointed to me that this device were already discussed on:

   http://www.mail-archive.com/linux-media@vger.kernel.org/msg43109.html

If m88ds3103 demod is similar enough to ds3000, it should just add the needed
bits at the existing driver, and not creating a new driver. 

Thanks,
Mauro

 
 Signed-off-by: Max nibble nibble@gmail.com
 ---
  drivers/media/dvb/frontends/Kconfig |7 +
  drivers/media/dvb/frontends/Makefile|2 +
  drivers/media/dvb/frontends/m88ds3103.c | 1851 
 +++
  drivers/media/dvb/frontends/m88ds3103.h |   53 +
  4 files changed, 1913 insertions(+)
  create mode 100644 drivers/media/dvb/frontends/m88ds3103.c
  create mode 100644 drivers/media/dvb/frontends/m88ds3103.h
 
 diff --git a/drivers/media/dvb/frontends/Kconfig 
 b/drivers/media/dvb/frontends/Kconfig
 index e11adb6..d2bb312 100644
 --- a/drivers/media/dvb/frontends/Kconfig
 +++ b/drivers/media/dvb/frontends/Kconfig
 @@ -214,6 +214,13 @@ config DVB_CX24116
  help
A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
  
 +config DVB_M88DS3103
 +tristate Montage DS3103 based
 +depends on DVB_CORE  I2C
 +default m if DVB_FE_CUSTOMISE
 +help
 +  A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 +  
  config DVB_SI21XX
  tristate Silicon Labs SI21XX based
  depends on DVB_CORE  I2C
 diff --git a/drivers/media/dvb/frontends/Makefile 
 b/drivers/media/dvb/frontends/Makefile
 index 6ca7557..84ddf41 100644
 --- a/drivers/media/dvb/frontends/Makefile
 +++ b/drivers/media/dvb/frontends/Makefile
 @@ -98,5 +98,7 @@ obj-$(CONFIG_DVB_A8293) += a8293.o
  obj-$(CONFIG_DVB_TDA10071) += tda10071.o
  obj-$(CONFIG_DVB_RTL2830) += rtl2830.o
  obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 +obj-$(CONFIG_DVB_M88DS3103) += m88ds3103.o
  obj-$(CONFIG_DVB_AF9033) += af9033.o
  
 +
 diff --git a/drivers/media/dvb/frontends/m88ds3103.c 
 b/drivers/media/dvb/frontends/m88ds3103.c
 new file mode 100644
 index 000..a186ba0
 --- /dev/null
 +++ b/drivers/media/dvb/frontends/m88ds3103.c
 @@ -0,0 +1,1851 @@
 +/*
 +Montage Technology M88DS3103/M88TS2022 - DVBS/S2 Satellite demod/tuner 
 driver
 +
 +Copyright (C) 2011 Max nibblenibble@gmail.com
 +Copyright (C) 2010 Montage Technologywww.montage-tech.com
 +Copyright (C) 2009 Konstantin Dimitrov.
 +
 +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
 +(at your option) any later version.
 +
 +This program is distributed in the hope that it will be useful,
 +but WITHOUT ANY WARRANTY; without even the implied warranty of
 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +GNU General Public License for more details.
 +
 +You should have received a copy of the GNU General Public License
 +along with this program; if not, write to the Free Software
 +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + */
 +
 +#include linux/slab.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/moduleparam.h
 +#include linux/init.h
 +#include linux/firmware.h
 +
 +#include dvb_frontend.h
 +#include m88ds3103.h
 +
 +static int debug;
 +module_param(debug, int, 0644);
 +MODULE_PARM_DESC(debug, Activates frontend debugging (default:0));
 +
 +#define dprintk(args...) \
 +do { \
 +if (debug) \
 +printk(KERN_INFO m88ds3103:  args); \
 +} while (0)
 +
 +#define FW_DOWN_SIZE 32
 +#define FW_DOWN_LOOP (8192/FW_DOWN_SIZE)
 +#define DS3103_DEFAULT_FIRMWARE dvb-fe-ds3103.fw
 +#define DS3000_DEFAULT_FIRMWARE dvb-fe-ds300x.fw
 +#define MT_FE_MCLK_KHZ 96000 /* in kHz */
 +#define MT_FE_CRYSTAL_KHZ   27000 /* in kHz */
 +#define FREQ_OFFSET_AT_SMALL_SYM_RATE_KHz 3000
 +#define DS3000_ID   0x3000
 +#define DS3103_ID   0x3103
 +#define TS2020_ID   0x2020
 +#define TS2022_ID   0x2022
 +#define UNKNOW_ID   0x
 +
 +/* For M88DS3103 demod dvbs mode.*/
 +static u8 ds3103_dvbs_init_tab[] = {
 +0x23, 0x07,
 +0x08, 0x03,
 +0x0c, 0x02,
 +0x21, 0x54,
 +0x25, 0x82,
 +0x27, 0x31,
 +0x30, 0x08,
 +0x31, 0x40,
 +0x32, 0x32,
 +0x33, 0x35,
 +0x35, 0xff,
 +0x3a, 0x00,
 +0x37, 0x10,
 +0x38, 0x10,
 +0x39, 0x02,
 +0x42, 0x60,
 +0x4a, 0x80,
 +0x4b, 0x04,
 +0x4d, 0x91,
 +0x5d, 0xc8,
 +0x50, 0x36,
 +0x51, 0x36,
 +0x52, 0x36,
 +0x53, 0x36,
 +0x63, 0x0f,
 +0x64, 0x30,
 +0x65, 0x40,
 +0x68

Re: Re: [PATCH 1/6] m88ds3103, montage dvb-s/s2 demodulator driver

2012-04-20 Thread nibble.max
2012-04-20 15:48:53 nibble@gmail.com
Mauro, thank you.

Hi Max,

Em 15-04-2012 12:53, nibble.max escreveu:
 Montage m88ds3103 demodulator and ts2022 tuner driver.
 
 Signed-off-by: Max nibble nibble@gmail.com

Please always test any patch you send upstream with ./scripts/checkpatch.pl.

It analyses the code and checks if it is following the Linux Coding Style
(Documentation/CodingStyle).

From what I've seen, there are several small CodingStyle issues on this patch.

There's also another problem here: this driver is mixing an I2C tuner driver
with the demod one. Please split. If the tuner is simple enough, you an add
it to:
   drivers/media/common/tuners/tuner-simple.c
or at:
   drivers/media/dvb/frontends/dvb-pll.c

But please don't mix tuners with demods. Mixing it causes code duplication and
more time lost when debugging it (as two different version of the same driver
can have different bugs).
I check the tuner-simple.c and dvb-pll.c is not fit for m88ts202x tuner.
Should we create a new tuner file like stv6110x?

I'll analyze it deeper after you fix those two issues.

Thanks,
Mauro


 ---
  drivers/media/dvb/frontends/Kconfig |7 +
  drivers/media/dvb/frontends/Makefile|2 +
  drivers/media/dvb/frontends/m88ds3103.c | 1851 
 +++
  drivers/media/dvb/frontends/m88ds3103.h |   53 +
  4 files changed, 1913 insertions(+)
  create mode 100644 drivers/media/dvb/frontends/m88ds3103.c
  create mode 100644 drivers/media/dvb/frontends/m88ds3103.h
 
 diff --git a/drivers/media/dvb/frontends/Kconfig 
 b/drivers/media/dvb/frontends/Kconfig
 index e11adb6..d2bb312 100644
 --- a/drivers/media/dvb/frontends/Kconfig
 +++ b/drivers/media/dvb/frontends/Kconfig
 @@ -214,6 +214,13 @@ config DVB_CX24116
  help
A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
  
 +config DVB_M88DS3103
 +tristate Montage DS3103 based
 +depends on DVB_CORE  I2C
 +default m if DVB_FE_CUSTOMISE
 +help
 +  A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 +  
  config DVB_SI21XX
  tristate Silicon Labs SI21XX based
  depends on DVB_CORE  I2C
 diff --git a/drivers/media/dvb/frontends/Makefile 
 b/drivers/media/dvb/frontends/Makefile
 index 6ca7557..84ddf41 100644
 --- a/drivers/media/dvb/frontends/Makefile
 +++ b/drivers/media/dvb/frontends/Makefile
 @@ -98,5 +98,7 @@ obj-$(CONFIG_DVB_A8293) += a8293.o
  obj-$(CONFIG_DVB_TDA10071) += tda10071.o
  obj-$(CONFIG_DVB_RTL2830) += rtl2830.o
  obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 +obj-$(CONFIG_DVB_M88DS3103) += m88ds3103.o
  obj-$(CONFIG_DVB_AF9033) += af9033.o
  
 +
 diff --git a/drivers/media/dvb/frontends/m88ds3103.c 
 b/drivers/media/dvb/frontends/m88ds3103.c
 new file mode 100644
 index 000..a186ba0
 --- /dev/null
 +++ b/drivers/media/dvb/frontends/m88ds3103.c
 @@ -0,0 +1,1851 @@
 +/*
 +Montage Technology M88DS3103/M88TS2022 - DVBS/S2 Satellite demod/tuner 
 driver
 +
 +Copyright (C) 2011 Max nibblenibble@gmail.com
 +Copyright (C) 2010 Montage Technologywww.montage-tech.com
 +Copyright (C) 2009 Konstantin Dimitrov.
 +
 +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
 +(at your option) any later version.
 +
 +This program is distributed in the hope that it will be useful,
 +but WITHOUT ANY WARRANTY; without even the implied warranty of
 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 +GNU General Public License for more details.
 +
 +You should have received a copy of the GNU General Public License
 +along with this program; if not, write to the Free Software
 +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 + */
 +
 +#include linux/slab.h
 +#include linux/kernel.h
 +#include linux/module.h
 +#include linux/moduleparam.h
 +#include linux/init.h
 +#include linux/firmware.h
 +
 +#include dvb_frontend.h
 +#include m88ds3103.h
 +
 +static int debug;
 +module_param(debug, int, 0644);
 +MODULE_PARM_DESC(debug, Activates frontend debugging (default:0));
 +
 +#define dprintk(args...) \
 +do { \
 +if (debug) \
 +printk(KERN_INFO m88ds3103:  args); \
 +} while (0)
 +
 +#define FW_DOWN_SIZE 32
 +#define FW_DOWN_LOOP (8192/FW_DOWN_SIZE)
 +#define DS3103_DEFAULT_FIRMWARE dvb-fe-ds3103.fw
 +#define DS3000_DEFAULT_FIRMWARE dvb-fe-ds300x.fw
 +#define MT_FE_MCLK_KHZ 96000 /* in kHz */
 +#define MT_FE_CRYSTAL_KHZ   27000 /* in kHz */
 +#define FREQ_OFFSET_AT_SMALL_SYM_RATE_KHz 3000
 +#define DS3000_ID   0x3000
 +#define DS3103_ID   0x3103
 +#define TS2020_ID   0x2020
 +#define TS2022_ID   0x2022
 +#define UNKNOW_ID   0x
 +
 +/* For M88DS3103 demod dvbs mode.*/
 +static u8 ds3103_dvbs_init_tab[] = {
 +0x23, 0x07,
 +0x08, 0x03,
 +0x0c, 0x02,
 +0x21, 0x54

Re: Re: [PATCH 1/6] m88ds3103, montage dvb-s/s2 demodulator driver

2012-04-20 Thread nibble.max
2012-04-21 10:38:02 nibble@gmail.com
Em 20-04-2012 06:47, Antti Palosaari escreveu:
 On 20.04.2012 11:01, nibble.max wrote:
 2012-04-20 15:56:27 nibble@gmail.com
 At first time, I check it exist so try to patch it.
 But with new m88ds3103 features to add and ts2022 tuner include, find it is 
 hard to do simply patch.
 It is better to create a new driver for maintain.
 Hi Max,

 Em 15-04-2012 12:53, nibble.max escreveu:
 Montage m88ds3103 demodulator and ts2022 tuner driver.

 It was pointed to me that this device were already discussed on:

http://www.mail-archive.com/linux-media@vger.kernel.org/msg43109.html

 If m88ds3103 demod is similar enough to ds3000, it should just add the 
 needed
 bits at the existing driver, and not creating a new driver.

 Thanks,
 Mauro
 
 The main problem of these all existing and upcoming Montage DVB-S/S2 drivers 
 are those are not split originally correct as a tuner and demod and now it 
 causes problems.
 
 I really suspect it should be:
 * single demod driver that supports both DS3000 and DS3103
 * single tuner driver that supports both TS2020 and TS2022
 
 And now what we have is 2 drivers that contains both tuner and demod. And a 
 lot of same code. :-(
 
 But it is almost impossible to split it correctly at that phase if you don't 
 have both hardware combinations, DS3000/TS2020 and DS3103/TS2022. I think it 
 is best to leave old DS3000 as it is and make new driver for DS3103 *and* 
 TS2022. Maybe after that someone could add DS3000 support to new DS3103 
 driver and TS2020 support to new TS2022 driver. After that it is possible to 
 remove old DS3000 driver.
 
 And we should really consider make simple rule not to accept any driver 
 which is not split as logical parts: USB/PCI-interface + demodulator + tuner.

Mixing tuner and demod is not good. Yet, dropping the current ds3000 doesn't
seem to be the best approach.

IMO, Konstantin/Montage should split the ds3000 driver on two drivers, putting
the ts2020 bits on a separate driver.

Then, Max should write a patch for ds3000 in order to add support for ds3103 on
it, and a patch for ts2020 driver, in order to add support for ts2022 on it.

Of course, Konstantin should check if Max changes don't break support for the
DS3000/TS2020 configuration.

Regards,
Mauro
Actually, I have the following hardware combinations.
1)DS3000 and TS2020 2)DS3103 and TS2020 3)DS3103 and TS2022
Should I sumbit the driver for DS3103 and TS2022 in the split files?
Or I must wait for Konstantin's work. How long should I wait for?

BR,
Max.

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] m88ds3103, montage dvb-s/s2 demodulator driver

2012-04-15 Thread nibble.max
Montage m88ds3103 demodulator and ts2022 tuner driver.

Signed-off-by: Max nibble nibble@gmail.com
---
 drivers/media/dvb/frontends/Kconfig |7 +
 drivers/media/dvb/frontends/Makefile|2 +
 drivers/media/dvb/frontends/m88ds3103.c | 1851 +++
 drivers/media/dvb/frontends/m88ds3103.h |   53 +
 4 files changed, 1913 insertions(+)
 create mode 100644 drivers/media/dvb/frontends/m88ds3103.c
 create mode 100644 drivers/media/dvb/frontends/m88ds3103.h

diff --git a/drivers/media/dvb/frontends/Kconfig 
b/drivers/media/dvb/frontends/Kconfig
index e11adb6..d2bb312 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -214,6 +214,13 @@ config DVB_CX24116
help
  A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
 
+config DVB_M88DS3103
+   tristate Montage DS3103 based
+   depends on DVB_CORE  I2C
+   default m if DVB_FE_CUSTOMISE
+   help
+ A DVB-S/S2 tuner module. Say Y when you want to support this frontend.
+ 
 config DVB_SI21XX
tristate Silicon Labs SI21XX based
depends on DVB_CORE  I2C
diff --git a/drivers/media/dvb/frontends/Makefile 
b/drivers/media/dvb/frontends/Makefile
index 6ca7557..84ddf41 100644
--- a/drivers/media/dvb/frontends/Makefile
+++ b/drivers/media/dvb/frontends/Makefile
@@ -98,5 +98,7 @@ obj-$(CONFIG_DVB_A8293) += a8293.o
 obj-$(CONFIG_DVB_TDA10071) += tda10071.o
 obj-$(CONFIG_DVB_RTL2830) += rtl2830.o
 obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
+obj-$(CONFIG_DVB_M88DS3103) += m88ds3103.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 
+
diff --git a/drivers/media/dvb/frontends/m88ds3103.c 
b/drivers/media/dvb/frontends/m88ds3103.c
new file mode 100644
index 000..a186ba0
--- /dev/null
+++ b/drivers/media/dvb/frontends/m88ds3103.c
@@ -0,0 +1,1851 @@
+/*
+Montage Technology M88DS3103/M88TS2022 - DVBS/S2 Satellite demod/tuner 
driver
+
+Copyright (C) 2011 Max nibblenibble@gmail.com
+Copyright (C) 2010 Montage Technologywww.montage-tech.com
+Copyright (C) 2009 Konstantin Dimitrov.
+
+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
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include linux/slab.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/moduleparam.h
+#include linux/init.h
+#include linux/firmware.h
+
+#include dvb_frontend.h
+#include m88ds3103.h
+
+static int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, Activates frontend debugging (default:0));
+
+#define dprintk(args...) \
+   do { \
+   if (debug) \
+   printk(KERN_INFO m88ds3103:  args); \
+   } while (0)
+
+#define FW_DOWN_SIZE 32
+#define FW_DOWN_LOOP (8192/FW_DOWN_SIZE)
+#define DS3103_DEFAULT_FIRMWARE dvb-fe-ds3103.fw
+#define DS3000_DEFAULT_FIRMWARE dvb-fe-ds300x.fw
+#define MT_FE_MCLK_KHZ 96000 /* in kHz */
+#define MT_FE_CRYSTAL_KHZ   27000 /* in kHz */
+#define FREQ_OFFSET_AT_SMALL_SYM_RATE_KHz 3000
+#define DS3000_ID  0x3000
+#define DS3103_ID  0x3103
+#define TS2020_ID  0x2020
+#define TS2022_ID  0x2022
+#define UNKNOW_ID  0x
+
+/* For M88DS3103 demod dvbs mode.*/
+static u8 ds3103_dvbs_init_tab[] = {
+   0x23, 0x07,
+   0x08, 0x03,
+   0x0c, 0x02,
+   0x21, 0x54,
+   0x25, 0x82,
+   0x27, 0x31,
+   0x30, 0x08,
+   0x31, 0x40,
+   0x32, 0x32,
+   0x33, 0x35,
+   0x35, 0xff,
+   0x3a, 0x00,
+   0x37, 0x10,
+   0x38, 0x10,
+   0x39, 0x02,
+   0x42, 0x60,
+   0x4a, 0x80,
+   0x4b, 0x04,
+   0x4d, 0x91,
+   0x5d, 0xc8,
+   0x50, 0x36,
+   0x51, 0x36,
+   0x52, 0x36,
+   0x53, 0x36,
+   0x63, 0x0f,
+   0x64, 0x30,
+   0x65, 0x40,
+   0x68, 0x26,
+   0x69, 0x4c,
+   0x70, 0x20,
+   0x71, 0x70,
+   0x72, 0x04,
+   0x73, 0x00,
+   0x70, 0x40,
+   0x71, 0x70,
+   0x72, 0x04,
+   0x73, 0x00,
+   0x70, 0x60,
+   0x71, 0x70,
+   0x72, 0x04,
+   0x73, 0x00,
+   0x70, 0x80,
+   0x71, 0x70,
+   0x72, 0x04,
+   0x73, 0x00,
+   0x70, 0xa0,
+   0x71, 0x70,
+   0x72, 0x04,
+   0x73, 0x00,
+   0x70, 0x1f,
+   0x76, 0x38,
+   0x77, 0xa6,
+   0x78, 0x0c,
+   0x79, 0x80,
+   0x7f, 0x14,
+   0x7c, 0x00,
+   0xae, 0x82,
+ 

[PATCH 2/6] m88ds3103, dvbsky dvb-s2 usb box.

2012-04-15 Thread nibble.max
dvbsky dvb-s2 usb box based on montage m88ds3103 demodulator.

Signed-off-by: Max nibble nibble@gmail.com
---
 drivers/media/dvb/dvb-usb/Kconfig  |1 +
 drivers/media/dvb/dvb-usb/dw2102.c |  236 +++-
 2 files changed, 236 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb/dvb-usb/Kconfig 
b/drivers/media/dvb/dvb-usb/Kconfig
index be1db75..bf63f29 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -279,6 +279,7 @@ config DVB_USB_DW2102
select DVB_STV0288 if !DVB_FE_CUSTOMISE
select DVB_STB6000 if !DVB_FE_CUSTOMISE
select DVB_CX24116 if !DVB_FE_CUSTOMISE
+   select DVB_M88DS3103 if !DVB_FE_CUSTOMISE
select DVB_SI21XX if !DVB_FE_CUSTOMISE
select DVB_TDA10023 if !DVB_FE_CUSTOMISE
select DVB_MT312 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/dvb-usb/dw2102.c 
b/drivers/media/dvb/dvb-usb/dw2102.c
index 451c5a7..0b1bbd2 100644
--- a/drivers/media/dvb/dvb-usb/dw2102.c
+++ b/drivers/media/dvb/dvb-usb/dw2102.c
@@ -19,6 +19,7 @@
 #include stb6000.h
 #include eds1547.h
 #include cx24116.h
+#include m88ds3103.h
 #include tda1002x.h
 #include mt312.h
 #include zl10039.h
@@ -882,6 +883,44 @@ static int s660_set_voltage(struct dvb_frontend *fe, 
fe_sec_voltage_t voltage)
return 0;
 }
 
+static int bstusb_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t 
voltage)
+{
+
+   struct dvb_usb_adapter *udev_adap =
+   (struct dvb_usb_adapter *)(fe-dvb-priv);
+
+   u8 obuf[3] = { 0xe, 0x80, 0 };
+   u8 ibuf[] = { 0 };
+   
+   info(US6830: %s!\n, __func__);
+   
+   if (voltage == SEC_VOLTAGE_OFF)
+   obuf[2] = 0;
+   else 
+   obuf[2] = 1;
+   
+   if (dvb_usb_generic_rw(udev_adap-dev, obuf, 3, ibuf, 1, 0)  0)
+   err(command 0x0e transfer failed.);
+   
+   return 0;
+}
+
+static int bstusb_restart(struct dvb_frontend *fe)
+{
+
+   struct dvb_usb_adapter *udev_adap =
+   (struct dvb_usb_adapter *)(fe-dvb-priv);
+   
+   u8 obuf[3] = { 0x36, 3, 0 };
+   u8 ibuf[] = { 0 };
+   
+
+   if (dvb_usb_generic_rw(udev_adap-dev, obuf, 3, ibuf, 1, 0)  0)
+   err(command 0x36 transfer failed.);
+   
+   return 0;
+}
+
 static void dw210x_led_ctrl(struct dvb_frontend *fe, int offon)
 {
static u8 led_off[] = { 0 };
@@ -987,6 +1026,24 @@ static struct ds3000_config su3000_ds3000_config = {
.ci_mode = 1,
 };
 
+static struct m88ds3103_config US6830_ds3103_config = {
+   .demod_address = 0x68,
+   .ci_mode = 1,
+   .pin_ctrl = 0x83,
+   .ts_mode = 0,
+   .start_ctrl = bstusb_restart,
+   .set_voltage = bstusb_set_voltage,
+};
+
+static struct m88ds3103_config US6832_ds3103_config = {
+   .demod_address = 0x68,
+   .ci_mode = 1,
+   .pin_ctrl = 0x80,
+   .ts_mode = 0,
+   .start_ctrl = bstusb_restart,
+   .set_voltage = bstusb_set_voltage,
+};
+
 static int dw2104_frontend_attach(struct dvb_usb_adapter *d)
 {
struct dvb_tuner_ops *tuner_ops = NULL;
@@ -1214,6 +1271,72 @@ static int su3000_frontend_attach(struct dvb_usb_adapter 
*d)
return 0;
 }
 
+static int US6830_frontend_attach(struct dvb_usb_adapter *d)
+{
+   u8 obuf[3] = { 0xe, 0x83, 0 };
+   u8 ibuf[] = { 0 };
+
+
+   info(US6830: %s!\n, __func__);
+   
+   if (dvb_usb_generic_rw(d-dev, obuf, 3, ibuf, 1, 0)  0)
+   err(command 0x0e transfer failed.);
+
+   obuf[0] = 0xe;
+   obuf[1] = 0x83;
+   obuf[2] = 1;
+
+   if (dvb_usb_generic_rw(d-dev, obuf, 3, ibuf, 1, 0)  0)
+   err(command 0x0e transfer failed.);
+
+   obuf[0] = 0x51;
+
+   if (dvb_usb_generic_rw(d-dev, obuf, 1, ibuf, 1, 0)  0)
+   err(command 0x51 transfer failed.);
+
+   d-fe_adap[0].fe = dvb_attach(m88ds3103_attach, US6830_ds3103_config,
+   d-dev-i2c_adap);
+   if (d-fe_adap[0].fe == NULL)
+   return -EIO;
+
+   info(Attached M88DS3103!\n);
+
+   return 0;
+}
+
+static int US6832_frontend_attach(struct dvb_usb_adapter *d)
+{
+   u8 obuf[3] = { 0xe, 0x83, 0 };
+   u8 ibuf[] = { 0 };
+
+
+   info(US6832: %s!\n, __func__);
+   
+   if (dvb_usb_generic_rw(d-dev, obuf, 3, ibuf, 1, 0)  0)
+   err(command 0x0e transfer failed.);
+
+   obuf[0] = 0xe;
+   obuf[1] = 0x83;
+   obuf[2] = 1;
+
+   if (dvb_usb_generic_rw(d-dev, obuf, 3, ibuf, 1, 0)  0)
+   err(command 0x0e transfer failed.);
+
+   obuf[0] = 0x51;
+
+   if (dvb_usb_generic_rw(d-dev, obuf, 1, ibuf, 1, 0)  0)
+   err(command 0x51 transfer failed.);
+
+   d-fe_adap[0].fe = dvb_attach(m88ds3103_attach, US6832_ds3103_config,
+   d-dev-i2c_adap);
+   if (d-fe_adap[0].fe == 

[PATCH 3/6] m88ds3103, dvbsky dvb-s2 cx23883 pci card.

2012-04-15 Thread nibble.max
dvbsky dvb-s2 pci based on montage m88ds3103 demodulator.

Signed-off-by: Max nibble nibble@gmail.com
---
 drivers/media/video/cx88/Kconfig  |1 +
 drivers/media/video/cx88/cx88-cards.c |   22 +
 drivers/media/video/cx88/cx88-dvb.c   |   85 +
 drivers/media/video/cx88/cx88-input.c |4 ++
 drivers/media/video/cx88/cx88.h   |1 +
 5 files changed, 113 insertions(+)

diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 3598dc0..0daef63 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -57,6 +57,7 @@ config VIDEO_CX88_DVB
select DVB_ISL6421 if !DVB_FE_CUSTOMISE
select DVB_S5H1411 if !DVB_FE_CUSTOMISE
select DVB_CX24116 if !DVB_FE_CUSTOMISE
+   select DVB_M88DS3103 if !DVB_FE_CUSTOMISE
select DVB_STV0299 if !DVB_FE_CUSTOMISE
select DVB_STV0288 if !DVB_FE_CUSTOMISE
select DVB_STB6000 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/video/cx88/cx88-cards.c 
b/drivers/media/video/cx88/cx88-cards.c
index cbd5d11..059b22d 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -2309,6 +2309,18 @@ static const struct cx88_board cx88_boards[] = {
} },
.mpeg   = CX88_MPEG_DVB,
},
+   [CX88_BOARD_BST_PS8312] = {
+   .name   = Bestunar PS8312 DVB-S/S2,
+   .tuner_type = UNSET,
+   .radio_type = UNSET,
+   .tuner_addr = ADDR_UNSET,
+   .radio_addr = ADDR_UNSET,
+   .input  = {{
+   .type   = CX88_VMUX_DVB,
+   .vmux   = 0,
+   } },
+   .mpeg   = CX88_MPEG_DVB,
+   },
 };
 
 /* -- */
@@ -2813,6 +2825,10 @@ static const struct cx88_subid cx88_subids[] = {
.subvendor = 0x1822,
.subdevice = 0x0023,
.card  = CX88_BOARD_TWINHAN_VP1027_DVBS,
+   }, {
+   .subvendor = 0x14f1,
+   .subdevice = 0x8312,
+   .card  = CX88_BOARD_BST_PS8312,
},
 };
 
@@ -3547,6 +3563,12 @@ static void cx88_card_setup(struct cx88_core *core)
cx_write(MO_SRST_IO, 1);
msleep(100);
break;
+   case  CX88_BOARD_BST_PS8312:
+   cx_write(MO_GP1_IO, 0x808000);
+   msleep(100);
+   cx_write(MO_GP1_IO, 0x808080);
+   msleep(100);
+   break;  
} /*end switch() */
 
 
diff --git a/drivers/media/video/cx88/cx88-dvb.c 
b/drivers/media/video/cx88/cx88-dvb.c
index 003937c..5e19ef3 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -54,6 +54,7 @@
 #include stv0288.h
 #include stb6000.h
 #include cx24116.h
+#include m88ds3103.h
 #include stv0900.h
 #include stb6100.h
 #include stb6100_proc.h
@@ -458,6 +459,56 @@ static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
return core-prev_set_voltage(fe, voltage);
return 0;
 }
+/*CX88_BOARD_BST_PS8312*/
+static int bst_dvbs_set_voltage(struct dvb_frontend *fe,
+ fe_sec_voltage_t voltage)
+{
+   struct cx8802_dev *dev= fe-dvb-priv;
+   struct cx88_core *core = dev-core;
+
+   cx_write(MO_GP1_IO, 0x11);
+   switch (voltage) {
+   case SEC_VOLTAGE_13:
+   cx_write(MO_GP1_IO, 0x020200);
+   break;
+   case SEC_VOLTAGE_18:
+   cx_write(MO_GP1_IO, 0x020202);
+   break;
+   case SEC_VOLTAGE_OFF:
+   cx_write(MO_GP1_IO, 0x00);
+   break;
+   }
+
+   if (core-prev_set_voltage)
+   return core-prev_set_voltage(fe, voltage);
+   return 0;
+}
+
+static int bst_dvbs_set_voltage_v2(struct dvb_frontend *fe,
+ fe_sec_voltage_t voltage)
+{
+   struct cx8802_dev *dev= fe-dvb-priv;
+   struct cx88_core *core = dev-core;
+
+   cx_write(MO_GP1_IO, 0x01);
+   switch (voltage) {
+   case SEC_VOLTAGE_13:
+   cx_write(MO_GP1_IO, 0x020200);
+   break;
+   case SEC_VOLTAGE_18:
+
+   cx_write(MO_GP1_IO, 0x020202);
+   break;
+   case SEC_VOLTAGE_OFF:
+
+   cx_write(MO_GP1_IO, 0x10);
+   break;
+   }
+
+   if (core-prev_set_voltage)
+   return core-prev_set_voltage(fe, voltage);
+   return 0;
+}
 
 static int vp1027_set_voltage(struct dvb_frontend *fe,
fe_sec_voltage_t voltage)
@@ -700,6 +751,11 @@ static struct ds3000_config 

[PATCH 4/6] m88ds3103, dvbsky dvb-s2 cx23885 pcie card.

2012-04-15 Thread nibble.max
dvbsky dvb-s2 pcie based on montage m88ds3103 demodulator.

Signed-off-by: Max nibble nibble@gmail.com
---
 drivers/media/video/cx23885/Kconfig |1 +
 drivers/media/video/cx23885/cx23885-cards.c |  107 +++
 drivers/media/video/cx23885/cx23885-dvb.c   |   52 +
 drivers/media/video/cx23885/cx23885-f300.c  |   55 ++
 drivers/media/video/cx23885/cx23885-f300.h  |6 ++
 drivers/media/video/cx23885/cx23885-input.c |   15 
 drivers/media/video/cx23885/cx23885.h   |3 +
 7 files changed, 239 insertions(+)

diff --git a/drivers/media/video/cx23885/Kconfig 
b/drivers/media/video/cx23885/Kconfig
index b391e9b..20337c7 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -20,6 +20,7 @@ config VIDEO_CX23885
select DVB_LNBP21 if !DVB_FE_CUSTOMISE
select DVB_STV6110 if !DVB_FE_CUSTOMISE
select DVB_CX24116 if !DVB_FE_CUSTOMISE
+   select DVB_M88DS3103 if !DVB_FE_CUSTOMISE
select DVB_STV0900 if !DVB_FE_CUSTOMISE
select DVB_DS3000 if !DVB_FE_CUSTOMISE
select DVB_STV0367 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/video/cx23885/cx23885-cards.c 
b/drivers/media/video/cx23885/cx23885-cards.c
index 19b5499..fdf9d0f 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -497,6 +497,20 @@ struct cx23885_board cx23885_boards[] = {
.name   = TerraTec Cinergy T PCIe Dual,
.portb  = CX23885_MPEG_DVB,
.portc  = CX23885_MPEG_DVB,
+   },
+
+   [CX23885_BOARD_BST_PS8512] = {
+   .name   = Bestunar PS8512,
+   .portb  = CX23885_MPEG_DVB,
+   },
+   [CX23885_BOARD_DVBSKY_S950] = {
+   .name   = DVBSKY S950,
+   .portb  = CX23885_MPEG_DVB,
+   },
+   [CX23885_BOARD_DVBSKY_S952] = {
+   .name   = DVBSKY S952,
+   .portb  = CX23885_MPEG_DVB,
+   .portc  = CX23885_MPEG_DVB,
}
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
@@ -705,6 +719,18 @@ struct cx23885_subid cx23885_subids[] = {
.subvendor = 0x153b,
.subdevice = 0x117e,
.card  = CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL,
+   }, {
+   .subvendor = 0x14f1,
+   .subdevice = 0x8512,
+   .card  = CX23885_BOARD_BST_PS8512,
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0950,
+   .card  = CX23885_BOARD_DVBSKY_S950, 
+   }, {
+   .subvendor = 0x4254,
+   .subdevice = 0x0952,
+   .card  = CX23885_BOARD_DVBSKY_S952,
},
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1216,9 +1242,57 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
/* enable irq */
cx_write(GPIO_ISM, 0x);/* INTERRUPTS active low*/
break;
+   case CX23885_BOARD_DVBSKY_S950:
+   case CX23885_BOARD_BST_PS8512:  
+   cx23885_gpio_enable(dev, GPIO_2, 1);
+   cx23885_gpio_clear(dev, GPIO_2);
+   msleep(100);
+   cx23885_gpio_set(dev, GPIO_2);
+   break;
+   case CX23885_BOARD_DVBSKY_S952: 
+   cx_write(MC417_CTL, 0x0037);/* enable GPIO3-18 pins */
+   
+   cx23885_gpio_enable(dev, GPIO_2, 1);
+   cx23885_gpio_enable(dev, GPIO_11, 1);
+   
+   cx23885_gpio_clear(dev, GPIO_2);
+   cx23885_gpio_clear(dev, GPIO_11);
+   msleep(100);
+   cx23885_gpio_set(dev, GPIO_2);
+   cx23885_gpio_set(dev, GPIO_11);
+   
+   break;
}
 }
 
+static int cx23885_ir_patch(struct i2c_adapter *i2c, u8 reg, u8 mask)
+{
+   struct i2c_msg msgs[2];
+   u8 tx_buf[2], rx_buf[1];
+   /* Write register address */
+   tx_buf[0] = reg;
+   msgs[0].addr = 0x4c;
+   msgs[0].flags = 0;
+   msgs[0].len = 1;
+   msgs[0].buf = (char *) tx_buf;
+   /* Read data from register */
+   msgs[1].addr = 0x4c;
+   msgs[1].flags = I2C_M_RD;
+   msgs[1].len = 1;
+   msgs[1].buf = (char *) rx_buf;  
+   
+   i2c_transfer(i2c, msgs, 2);
+
+   tx_buf[0] = reg;
+   tx_buf[1] = rx_buf[0] | mask;
+   msgs[0].addr = 0x4c;
+   msgs[0].flags = 0;
+   msgs[0].len = 2;
+   msgs[0].buf = (char *) tx_buf;
+   
+   return i2c_transfer(i2c, msgs, 1);
+}
+
 int cx23885_ir_init(struct cx23885_dev *dev)
 {
static struct v4l2_subdev_io_pin_config ir_rxtx_pin_cfg[] = {
@@ -1301,6 +1375,20 @@ int cx23885_ir_init(struct cx23885_dev *dev)

Re: Re: Mystique SaTiX-S2 Sky Xpress DUAL card

2012-02-13 Thread nibble.max
Hello Konstantin,
I think Bestunar do make the two wrong things.
One, they put the copyright without your permission. 
But I doute that you copy and paste the Montage Technology's reference code and 
why not put Montage copyright?
Two, they write the code based on the ds3000.c file which you created, even 
they enhance and fix some bugs.

They build the products based on Montage Technology advanced M88DS3103 chip, 
which is totally a new chip different from old ds3000.
And they are the first company to adopt this new chip on the Satellite DVB-S2 
tuner cards.
They do the right thing now that create a new file named m88ds3103.c for the 
new chip in linux media tree.
http://www.dvbsky.net/download/bst-patch.tar.gz 

Br,

2012-02-13 



nibble.max 



发件人: Konstantin Dimitrov 
发送时间: 2011-12-29  18:25:37 
收件人: Andreas Mair 
抄送: linux-media 
主题: Re: Mystique SaTiX-S2 Sky Xpress DUAL card 
hello Andreas,
i've checked the Linux drivers for the card you referred to and
whoever made it is breaking all the rules claiming copyright over the
whole driver adding at the beginning:
Copyright (C) 2010 Bestunar Inc.
when they just patched the driver very slightly adding only new
initialization values - if they wish they can claim copyright only
over those small changes (even they are just number constants provided
by the chip maker). in any case that's ridiculous, because i made that
driver and the copyright notice is:
http://git.linuxtv.org/media_tree.git/blob/61c4f2c81c61f73549928dfd9f3e8f26aa36a8cf:/drivers/media/dvb/frontends/ds3000.c
Montage Technology DS3000/TS2020 - DVBS/S2 Demodulator/Tuner driver
Copyright (C) 2009 Konstantin Dimitrov kosio.dimit...@gmail.com
Copyright (C) 2009 TurboSight.com
and i strongly opposed that copyright massage can be changed in the
way like they did especially over the changes they made.
also, the whole 'ds3000' driver, even it's licensed under GPL, was
submitted to the Linux kernel without my formal permission that to be
done, i.e. you can think for that as it was leaked to the Linux kernel
from third-parties and not the driver author and copyright-holder.
so, it seems to me Bestunar Inc is some obscure Chinese company most
probably cloning hardware rather than spent any time doing
development, which or course also don't honor the work put in
development of open-source driver for the chips they're using and try
very hard to make it look like they did it or that they did something
more significant than what they actually did. i'm sure you can
understand my position and my opinion that such companies shouldn't be
supported in any possible way.
best regards,
konstantin
On Thu, Dec 29, 2011 at 11:07 AM, Andreas Mair amair@googlemail.com wrote:
 Hello,

 I'm using that card in my Linux VDR box:
 http://www.dvbshop.net/product_info.php/info/p2440_Mystique-SaTiX-S2-Sky-Xpress-DUAL--USALS--DiseqC-1-2--Win-Linux.html

 That's the lspci output:
 === SNIP =
 $ lspci -vvvnn
 02:00.0 Multimedia video controller [0400]: Conexant Systems, Inc.
 CX23885 PCI Video and Audio Decoder [14f1:8852] (rev 02)
Subsystem: Device [4254:0952]
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop-
 ParErr- Stepping- SERR- FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast TAbort-
 TAbort- MAbort- SERR- PERR- INTx-
Latency: 0, Cache Line Size: 64 bytes
Interrupt: pin A routed to IRQ 16
Region 0: Memory at fe40 (64-bit, non-prefetchable) [size=2M]
Capabilities: [40] Express (v1) Endpoint, MSI 00
DevCap: MaxPayload 128 bytes, PhantFunc 0, Latency L0s
 64ns, L1 1us
ExtTag- AttnBtn- AttnInd- PwrInd- RBE- FLReset-
DevCtl: Report errors: Correctable- Non-Fatal- Fatal-
 Unsupported-
RlxdOrd- ExtTag- PhantFunc- AuxPwr- NoSnoop+
MaxPayload 128 bytes, MaxReadReq 512 bytes
DevSta: CorrErr- UncorrErr+ FatalErr- UnsuppReq+
 AuxPwr- TransPend-
LnkCap: Port #0, Speed 2.5GT/s, Width x1, ASPM L0s L1,
 Latency L0 2us, L1 4us
ClockPM- Surprise- LLActRep- BwNot-
LnkCtl: ASPM Disabled; RCB 64 bytes Disabled- Retrain- CommClk+
ExtSynch- ClockPM- AutWidDis- BWInt- AutBWInt-
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train-
 SlotClk+ DLActive- BWMgmt- ABWMgmt-
Capabilities: [80] Power Management version 2
Flags: PMEClk- DSI+ D1+ D2+ AuxCurrent=0mA
 PME(D0+,D1+,D2+,D3hot+,D3cold-)
Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
Capabilities: [90] Vital Product Data
Product Name: 
End
Capabilities: [a0] MSI: Enable- Count=1/1 Maskable- 64bit+
Address:   Data: 
Capabilities: [100] Advanced Error Reporting
UESta:  DLP- SDES- TLP- FCP- CmpltTO- CmpltAbrt-
 UnxCmplt

Re: Re: Re: Mystique SaTiX-S2 Sky Xpress DUAL card

2012-02-13 Thread nibble.max
Hello, do you exactly read the codes?
Both of you refer to the codes from Montage Technology. That is why the 
identical in ds3000 code.
in m88ds3103.c, it support the new demodulator m88ds3103 and new tuner ts2022, 
also backward to support ds3000 and ts2020.
The firmware for ds3103 is not compatible with ds3000. and the tuning control 
is also different too.
So does tuner ts2022.

It design the new initilase logic. 
In your ds3000.c file, it will download firmware every time when the 
application tunes the transponders.
Downloading firmware needs lock the firmware file and do many i2c transactions. 
It will slow down the channel tuning.
It is unnecessary. You maybe refer to conexant cx24116 code to do that.
But it is different between Montage chips and cx24116 chip. It is the right 
thing in cx24116, it is not for Montage chips.
In m88ds3103.c, it is only one time to download the firmware not every time.

It also fix the bug in reading back tuner register.
In your ds3000.c file, it is wrong to do read tuner register. So it is wrong 
value when reading back.

It support demod/tuner wake and sleep function.
When the application close or not use dvb device, in m88ds3103.c it will put 
the demod/tuner in the sleep to save power.
In ds3000.c, it is null.
.
I do not want to list all let this mail become a long one.

I do not want to argue with you.
So what is the right thing let Bestunar do?
They create the hardware. The end user like it and want to use it in Linux.
Linux is open sourced and GPL. So every one can do change in any source code. 
Bestunar really change the code and open to the public. 
But they should put your copyright and name in their m88ds3103.c, is it right?
For ds3000.c file, need your permission. If you deny, that they can not change 
it. is it right?
If you agree, whatever they do. They can not put their copyright and name. is 
it right?

2012-02-14 
nibble.max 


发件人: Konstantin Dimitrov 
发送时间: 2012-02-13  23:56:29 
收件人: nibble.max 
抄送: linux-media; Andreas Mair 
主题: Re: Re: Mystique SaTiX-S2 Sky Xpress DUAL card 
 
hello, and what's exactly the different in 'm88ds3103.c' then your
approach before - you just do the same and now even remove my name
from the copyright, which is really ridiculous because almost all of
your code is copypaste from my code inside 'ds3000.c'. so, in
'm88ds3103.c' you take 'ds3000.c' code, make some small patches to add
ds3103 support, which are mainly one array of initialization values
and even this time remove my name from the copyright, while 90% of the
code inside 'm88ds3103.c'  is made by me - you even leave my comments
from the 'ds3000.c' code letter by letter. so, if you want to claim
copyright, please develop your own code that doesn't use like 90% (and
even more) of mine code.
On Mon, Feb 13, 2012 at 5:28 PM, nibble.max nibble@gmail.com wrote:
 Hello Konstantin,
 I think Bestunar do make the two wrong things.
 One, they put the copyright without your permission.
 But I doute that you copy and paste the Montage Technology's reference code
 and why not put Montage copyright?
 Two, they write the code based on the ds3000.c file which you created, even
 they enhance and fix some bugs.

 They build the products based on Montage Technology advanced M88DS3103 chip,
 which is totally a new chip different from old ds3000.
 And they are the first company to adopt this new chip on the Satellite
 DVB-S2 tuner cards.
 They do the right thing now that create a new file named m88ds3103.c for the
 new chip in linux media tree.
 http://www.dvbsky.net/download/bst-patch.tar.gz

 Br,

 2012-02-13
 
 nibble.max
 
 发件人: Konstantin Dimitrov
 发送时间: 2011-12-29  18:25:37
 收件人: Andreas Mair
 抄送: linux-media
 主题: Re: Mystique SaTiX-S2 Sky Xpress DUAL card
 hello Andreas,
 i've checked the Linux drivers for the card you referred to and
 whoever made it is breaking all the rules claiming copyright over the
 whole driver adding at the beginning:
 Copyright (C) 2010 Bestunar Inc.
 when they just patched the driver very slightly adding only new
 initialization values - if they wish they can claim copyright only
 over those small changes (even they are just number constants provided
 by the chip maker). in any case that's ridiculous, because i made that
 driver and the copyright notice is:
 http://git.linuxtv.org/media_tree.git/blob/61c4f2c81c61f73549928dfd9f3e8f26aa36a8cf:/drivers/media/dvb/frontends/ds3000.c
 Montage Technology DS3000/TS2020 - DVBS/S2 Demodulator/Tuner driver
 Copyright (C) 2009 Konstantin Dimitrov kosio.dimit...@gmail.com
 Copyright (C) 2009 TurboSight.com
 and i strongly opposed that copyright massage can be changed in the
 way like they did especially over the changes they made.
 also, the whole 'ds3000' driver, even it's licensed under GPL, was
 submitted to the Linux kernel without my formal permission that to be
 done, i.e