[PATCH 1/1] dvbdev: add dvb_register_subdev() & dvb_unregister_subdev()

2014-10-06 Thread Буди Романто, AreMa Inc
Taken from https://github.com/knight-rider/ptx/tree/master/pt3_dvb,
these routines simplify I2C binding of subdevices.

Applicable at least to the followings:
drivers/media/pci/bt8xx/bttv-input.c
drivers/media/pci/cx23885/cx23885-dvb.c
drivers/media/pci/cx23885/cx23885-i2c.c
drivers/media/pci/cx23885/cx23885.h
drivers/media/pci/cx25821/cx25821-i2c.c
drivers/media/pci/cx25821/cx25821.h
drivers/media/pci/cx88/cx88-input.c
drivers/media/pci/cx88/cx88-video.c
drivers/media/pci/pt3/pt3.c
drivers/media/pci/saa7134/saa7134-i2c.c
drivers/media/pci/saa7134/saa7134-input.c
drivers/media/pci/saa7134/saa7134.h
drivers/media/pci/saa7164/saa7164-i2c.c
drivers/media/pci/saa7164/saa7164.h
drivers/media/usb/au0828/au0828-i2c.c
drivers/media/usb/au0828/au0828.h
drivers/media/usb/cx231xx/cx231xx-dvb.c
drivers/media/usb/cx231xx/cx231xx-i2c.c
drivers/media/usb/cx231xx/cx231xx-input.c
drivers/media/usb/cx231xx/cx231xx.h
drivers/media/usb/dvb-usb-v2/af9035.c
drivers/media/usb/dvb-usb-v2/anysee.c
drivers/media/usb/dvb-usb-v2/dvbsky.c
drivers/media/usb/dvb-usb-v2/rtl28xxu.c
drivers/media/usb/dvb-usb/cxusb.c
drivers/media/usb/em28xx/em28xx-cards.c
drivers/media/usb/em28xx/em28xx-dvb.c
drivers/media/usb/em28xx/em28xx-i2c.c
drivers/media/usb/em28xx/em28xx.h
drivers/media/usb/go7007/s2250-board.c
drivers/media/usb/hdpvr/hdpvr-i2c.c
drivers/media/usb/stk1160/stk1160-i2c.c
drivers/media/usb/stk1160/stk1160.h
drivers/media/usb/tm6000/tm6000-cards.c
drivers/media/usb/tm6000/tm6000-i2c.c
drivers/media/usb/tm6000/tm6000.h
drivers/media/usb/usbvision/usbvision-i2c.c
drivers/media/usb/usbvision/usbvision-video.c
drivers/media/usb/usbvision/usbvision.h

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-core/dvbdev.c | 24 
 drivers/media/dvb-core/dvbdev.h |  3 +++
 2 files changed, 27 insertions(+)

diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 983db75..f449543 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -284,6 +284,30 @@ void dvb_unregister_device(struct dvb_device *dvbdev)
 }
 EXPORT_SYMBOL(dvb_unregister_device);
 
+struct i2c_client *dvb_register_subdev(struct i2c_adapter *adap, struct 
i2c_board_info const *info)
+{
+   struct i2c_client *clt;
+
+   request_module("%s", info->type);
+   clt = i2c_new_device(adap, info);
+   if (clt && clt->dev.driver)
+   if (!try_module_get(clt->dev.driver->owner)) {
+   i2c_unregister_device(clt);
+   clt = NULL;
+   }
+   return clt;
+}
+EXPORT_SYMBOL(dvb_register_subdev);
+
+void dvb_unregister_subdev(struct i2c_client *clt)
+{
+   if (clt) {
+   module_put(clt->dev.driver->owner);
+   i2c_unregister_device(clt);
+   }
+}
+EXPORT_SYMBOL(dvb_unregister_subdev);
+
 static int dvbdev_check_free_adapter_num(int num)
 {
struct list_head *entry;
diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h
index f96b28e..cff2296 100644
--- a/drivers/media/dvb-core/dvbdev.h
+++ b/drivers/media/dvb-core/dvbdev.h
@@ -109,6 +109,9 @@ extern int dvb_register_device (struct dvb_adapter *adap,
 
 extern void dvb_unregister_device (struct dvb_device *dvbdev);
 
+extern struct i2c_client *dvb_register_subdev(struct i2c_adapter *adap, struct 
i2c_board_info const *info);
+extern void dvb_unregister_subdev(struct i2c_client *clt);
+
 extern int dvb_generic_open (struct inode *inode, struct file *file);
 extern int dvb_generic_release (struct inode *inode, struct file *file);
 extern long dvb_generic_ioctl (struct file *file,
-- 
1.8.4.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 1/1] Kconfig: cosmetics, as Mauro suggested

2014-10-05 Thread Буди Романто, AreMa Inc
PT3 is wrongly categorized, fix it

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 5a13454..6c75418 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -648,12 +648,15 @@ config DVB_MB86A20S
  A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator.
  Say Y when you want to support this frontend.
 
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
+   depends on DVB_CORE
+
 config DVB_TC90522
tristate "Toshiba TC90522"
depends on DVB_CORE && I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
- A Toshiba TC90522 2xISDB-T + 2xISDB-S demodulator.
+ Toshiba TC90522 2xISDB-S 8PSK + 2xISDB-T OFDM demodulator.
  Say Y when you want to support this frontend.
 
 comment "Digital terrestrial only tuners/PLL"
-- 
1.8.4.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 1/1] Kconfig: cosmetic improvement

2014-10-05 Thread Буди Романто, AreMa Inc
PT1 & PT3 are wrongly categorized, fix it
Add comment that PT3 needs FE & tuners

This patch can be applied immediately

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig | 4 ++--
 drivers/media/pci/pt3/Kconfig   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 5a13454..0c59825 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -653,7 +653,7 @@ config DVB_TC90522
depends on DVB_CORE && I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
- A Toshiba TC90522 2xISDB-T + 2xISDB-S demodulator.
+ Toshiba TC90522 2xISDB-S 8PSK + 2xISDB-T OFDM demodulator.
  Say Y when you want to support this frontend.
 
 comment "Digital terrestrial only tuners/PLL"
diff --git a/drivers/media/pci/pt3/Kconfig b/drivers/media/pci/pt3/Kconfig
index 16c208a..f7b7210 100644
--- a/drivers/media/pci/pt3/Kconfig
+++ b/drivers/media/pci/pt3/Kconfig
@@ -6,5 +6,5 @@ config DVB_PT3
select MEDIA_TUNER_MXL301RF if MEDIA_SUBDRV_AUTOSELECT
help
  Support for Earthsoft PT3 PCIe cards.
-
+ You need to enable frontend (TC90522) & tuners (QM1D1C0042, MXL301RF)
  Say Y or M if you own such a device and want to use it.
-- 
1.8.4.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 02/11] tc90522 is a client

2014-10-05 Thread Буди Романто, AreMa Inc
tc90522 is an I2C client functioning as a frontend
thus, it is enough to return the FE pointer.

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/tc90522.h | 41 ---
 1 file changed, 14 insertions(+), 27 deletions(-)

diff --git a/drivers/media/dvb-frontends/tc90522.h 
b/drivers/media/dvb-frontends/tc90522.h
index b1cbddf..c78a5b0 100644
--- a/drivers/media/dvb-frontends/tc90522.h
+++ b/drivers/media/dvb-frontends/tc90522.h
@@ -1,12 +1,12 @@
 /*
- * Toshiba TC90522 Demodulator
+ * Earthsoft PT3 demodulator frontend Toshiba TC90522XBG 
OFDM(ISDB-T)/8PSK(ISDB-S)
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,29 +14,16 @@
  * GNU General Public License for more details.
  */
 
-/*
- * The demod has 4 input (2xISDB-T and 2xISDB-S),
- * and provides independent sub modules for each input.
- * As the sub modules work in parallel and have the separate i2c addr's,
- * this driver treats each sub module as one demod device.
- */
-
-#ifndef TC90522_H
-#define TC90522_H
+#ifndef__TC90522_H__
+#define__TC90522_H__
 
-#include 
-#include "dvb_frontend.h"
-
-/* I2C device types */
-#define TC90522_I2C_DEV_SAT "tc90522sat"
-#define TC90522_I2C_DEV_TER "tc90522ter"
+#define TC90522_DRVNAME "tc90522"
 
 struct tc90522_config {
-   /* [OUT] frontend returned by driver */
-   struct dvb_frontend *fe;
-
-   /* [OUT] tuner I2C adapter returned by driver */
-   struct i2c_adapter *tuner_i2c;
+   fe_delivery_system_ttype;   /* IN   SYS_ISDBS or SYS_ISDBT */
+   boolpwr;/* IN   set only once after all demods 
initialized */
+   struct dvb_frontend *fe;/* OUT  allocated frontend */
 };
 
-#endif /* TC90522_H */
+#endif
+
-- 
1.8.4.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 07/11] mxl301rf: namespace cleanup

2014-10-05 Thread Буди Романто, AreMa Inc
minimize export

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/tuners/mxl301rf.h | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/drivers/media/tuners/mxl301rf.h b/drivers/media/tuners/mxl301rf.h
index 19e6840..a5334e7 100644
--- a/drivers/media/tuners/mxl301rf.h
+++ b/drivers/media/tuners/mxl301rf.h
@@ -1,12 +1,12 @@
 /*
- * MaxLinear MxL301RF OFDM tuner driver
+ * Sharp VA4M6JC2103 - Earthsoft PT3 ISDB-T tuner MaxLinear CMOS Hybrid TV 
MxL301RF
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,13 +14,10 @@
  * GNU General Public License for more details.
  */
 
-#ifndef MXL301RF_H
-#define MXL301RF_H
+#ifndef __MXL301RF_H__
+#define __MXL301RF_H__
 
-#include "dvb_frontend.h"
+#define MXL301RF_DRVNAME "mxl301rf"
 
-struct mxl301rf_config {
-   struct dvb_frontend *fe;
-};
+#endif
 
-#endif /* MXL301RF_H */
-- 
1.8.4.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 00/11] pt3: pci, tc90522, mxl301rf, qm1d1c0042

2014-10-05 Thread Буди Романто, AreMa Inc
*** PT3 stable driver ***
Clean Package:
Please pull from
https://github.com/knight-rider/ptx/tree/master/pt3_dvb

Буди Романто, AreMa Inc (11):
  tc90522: better chip description
  tc90522 is a client
  tc90522: use hardware algorithm & correct CNR
  pt3: add comment
  pt3: merge I2C & DMA handlers
  pt3: namespace cleanup
  mxl301rf: namespace cleanup
  qm1d1c0042: namespace cleanup
  mxl301rf: namespace cleanup & remodelling
  qm1d1c0042: namespace cleanup & remodelling
  pt3: merge I2C & DMA handlers

 drivers/media/dvb-frontends/Kconfig   |4 +-
 drivers/media/dvb-frontends/Makefile  |1 +
 drivers/media/dvb-frontends/tc90522.c | 1146 +---
 drivers/media/dvb-frontends/tc90522.h |   41 +-
 drivers/media/pci/pt3/Kconfig |2 +-
 drivers/media/pci/pt3/Makefile|8 +-
 drivers/media/pci/pt3/pt3.c   | 1557 ++---
 drivers/media/pci/pt3/pt3.h   |  183 +---
 drivers/media/pci/pt3/pt3_dma.c   |  225 -
 drivers/media/pci/pt3/pt3_i2c.c   |  240 -
 drivers/media/tuners/mxl301rf.c   |  550 ++--
 drivers/media/tuners/mxl301rf.h   |   23 +-
 drivers/media/tuners/qm1d1c0042.c |  644 +++---
 drivers/media/tuners/qm1d1c0042.h |   34 +-
 14 files changed, 1903 insertions(+), 2755 deletions(-)
 delete mode 100644 drivers/media/pci/pt3/pt3_dma.c
 delete mode 100644 drivers/media/pci/pt3/pt3_i2c.c

-- 
1.8.4.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 09/11] mxl301rf: namespace cleanup & remodelling

2014-10-05 Thread Буди Романто, AreMa Inc
- minimize exports
- use client->dev.platform_data to point frontend
- use real address for I2C
- no freq limits in FE, it is non sense. move here...
- try to treat invalid frequency as channel number

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/tuners/mxl301rf.c | 550 +---
 1 file changed, 291 insertions(+), 259 deletions(-)

diff --git a/drivers/media/tuners/mxl301rf.c b/drivers/media/tuners/mxl301rf.c
index 1575a5d..b1ed978 100644
--- a/drivers/media/tuners/mxl301rf.c
+++ b/drivers/media/tuners/mxl301rf.c
@@ -1,12 +1,12 @@
 /*
- * MaxLinear MxL301RF OFDM tuner driver
+ * Sharp VA4M6JC2103 - Earthsoft PT3 ISDB-T tuner MaxLinear CMOS Hybrid TV 
MxL301RF
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,116 +14,24 @@
  * GNU General Public License for more details.
  */
 
-/*
- * NOTICE:
- * This driver is incomplete and lacks init/config of the chips,
- * as the necessary info is not disclosed.
- * Other features like get_if_frequency() are missing as well.
- * It assumes that users of this driver (such as a PCI bridge of
- * DTV receiver cards) properly init and configure the chip
- * via I2C *before* calling this driver's init() function.
- *
- * Currently, PT3 driver is the only one that uses this driver,
- * and contains init/config code in its firmware.
- * Thus some part of the code might be dependent on PT3 specific config.
- */
-
-#include 
+#include "dvb_frontend.h"
 #include "mxl301rf.h"
 
-struct mxl301rf_state {
-   struct mxl301rf_config cfg;
-   struct i2c_client *i2c;
+struct mxl301rf {
+   struct dvb_frontend *fe;
+   u8 addr_tuner, idx;
+   u32 freq;
+   int (*read)(struct dvb_frontend *fe, u8 *buf, int buflen);
 };
 
-static struct mxl301rf_state *cfg_to_state(struct mxl301rf_config *c)
-{
-   return container_of(c, struct mxl301rf_state, cfg);
-}
-
-static int raw_write(struct mxl301rf_state *state, const u8 *buf, int len)
-{
-   int ret;
-
-   ret = i2c_master_send(state->i2c, buf, len);
-   if (ret >= 0 && ret < len)
-   ret = -EIO;
-   return (ret == len) ? 0 : ret;
-}
-
-static int reg_write(struct mxl301rf_state *state, u8 reg, u8 val)
-{
-   u8 buf[2] = { reg, val };
-
-   return raw_write(state, buf, 2);
-}
-
-static int reg_read(struct mxl301rf_state *state, u8 reg, u8 *val)
-{
-   u8 wbuf[2] = { 0xfb, reg };
-   int ret;
-
-   ret = raw_write(state, wbuf, sizeof(wbuf));
-   if (ret == 0)
-   ret = i2c_master_recv(state->i2c, val, 1);
-   if (ret >= 0 && ret < 1)
-   ret = -EIO;
-   return (ret == 1) ? 0 : ret;
-}
-
-/* tuner_ops */
-
-/* get RSSI and update propery cache, set to *out in % */
-static int mxl301rf_get_rf_strength(struct dvb_frontend *fe, u16 *out)
-{
-   struct mxl301rf_state *state;
-   int ret;
-   u8  rf_in1, rf_in2, rf_off1, rf_off2;
-   u16 rf_in, rf_off;
-   s64 level;
-   struct dtv_fe_stats *rssi;
-
-   rssi = &fe->dtv_property_cache.strength;
-   rssi->len = 1;
-   rssi->stat[0].scale = FE_SCALE_NOT_AVAILABLE;
-   *out = 0;
-
-   state = fe->tuner_priv;
-   ret = reg_write(state, 0x14, 0x01);
-   if (ret < 0)
-   return ret;
-   usleep_range(1000, 2000);
-
-   ret = reg_read(state, 0x18, &rf_in1);
-   if (ret == 0)
-   ret = reg_read(state, 0x19, &rf_in2);
-   if (ret == 0)
-   ret = reg_read(state, 0xd6, &rf_off1);
-   if (ret == 0)
-   ret = reg_read(state, 0xd7, &rf_off2);
-   if (ret != 0)
-   return ret;
-
-   rf_in = (rf_in2 & 0x07) << 8 | rf_in1;
-   rf_off = (rf_off2 & 0x0f) << 5 | (rf_off1 >> 3);
-   level = rf_in - rf_off - (113 << 3); /* x8 dBm */
-   level = level * 1000 / 8;
-   rssi->stat[0].svalue = level;
-   rssi->stat[0].scale = FE_SCALE_DECIBEL;
-   /* *out = (level - min) * 100 / (max - min) */
-   *out = (rf_in - rf_off + (1 << 9) - 1) * 100 / ((5 << 9) - 2);
-   return 0;
-}
-
-/* spur shift parameters */
-struct shf {
-   u32 freq;   /* Channel center frequency */
-   u32 ofst_th;/* Offs

[PATCH 04/11] pt3: add comment

2014-10-05 Thread Буди Романто, AreMa Inc
PT3 needs frontend & tuners to run properly

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/pci/pt3/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/pt3/Kconfig b/drivers/media/pci/pt3/Kconfig
index 16c208a..f7b7210 100644
--- a/drivers/media/pci/pt3/Kconfig
+++ b/drivers/media/pci/pt3/Kconfig
@@ -6,5 +6,5 @@ config DVB_PT3
select MEDIA_TUNER_MXL301RF if MEDIA_SUBDRV_AUTOSELECT
help
  Support for Earthsoft PT3 PCIe cards.
-
+ You need to enable frontend (TC90522) & tuners (QM1D1C0042, MXL301RF)
  Say Y or M if you own such a device and want to use it.
-- 
1.8.4.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 03/11] tc90522: use hardware algorithm & correct CNR

2014-10-05 Thread Буди Романто, AreMa Inc
1. The chip is clever enough to do fine tuning. Thus,
   simply let dvb-core do the iteration of hw_algo.
2. Tsukada's patch violates the consensus in
   include/uapi/linux/dvb/frontend.h
   Change CNR unit from .001 dB to .0001 dB, and yet
   lightweight calculus using only shifters for divs.

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/tc90522.c | 1146 -
 1 file changed, 427 insertions(+), 719 deletions(-)

diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
index d9905fb..cf19cfb 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -1,12 +1,12 @@
 /*
- * Toshiba TC90522 Demodulator
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator frontend 
for Earthsoft PT3
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,827 +14,535 @@
  * GNU General Public License for more details.
  */
 
-/*
- * NOTICE:
- * This driver is incomplete and lacks init/config of the chips,
- * as the necessary info is not disclosed.
- * It assumes that users of this driver (such as a PCI bridge of
- * DTV receiver cards) properly init and configure the chip
- * via I2C *before* calling this driver's init() function.
- *
- * Currently, PT3 driver is the only one that uses this driver,
- * and contains init/config code in its firmware.
- * Thus some part of the code might be dependent on PT3 specific config.
- */
-
-#include 
-#include 
-#include 
 #include "dvb_math.h"
+#include "dvb_frontend.h"
 #include "tc90522.h"
 
-#define TC90522_I2C_THRU_REG 0xfe
-
-#define TC90522_MODULE_IDX(addr) (((u8)(addr) & 0x02U) >> 1)
+#define TC90522_PASSTHROUGH 0xfe
 
-struct tc90522_state {
-   struct tc90522_config cfg;
-   struct dvb_frontend fe;
-   struct i2c_client *i2c_client;
-   struct i2c_adapter tuner_i2c;
-
-   bool lna;
+enum tc90522_state {
+   TC90522_IDLE,
+   TC90522_SET_FREQUENCY,
+   TC90522_SET_MODULATION,
+   TC90522_TRACK,
+   TC90522_ABORT,
 };
 
-struct reg_val {
-   u8 reg;
-   u8 val;
+struct tc90522 {
+   struct dvb_frontend fe;
+   struct i2c_adapter *i2c;
+   fe_delivery_system_t type;
+   u8 idx, addr_demod;
+   s32 offset;
+   enum tc90522_state state;
 };
 
-static int
-reg_write(struct tc90522_state *state, const struct reg_val *regs, int num)
+int tc90522_write(struct dvb_frontend *fe, const u8 *data, int len)
 {
-   int i, ret;
-   struct i2c_msg msg;
-
-   ret = 0;
-   msg.addr = state->i2c_client->addr;
-   msg.flags = 0;
-   msg.len = 2;
-   for (i = 0; i < num; i++) {
-   msg.buf = (u8 *)®s[i];
-   ret = i2c_transfer(state->i2c_client->adapter, &msg, 1);
-   if (ret == 0)
-   ret = -EIO;
-   if (ret < 0)
-   return ret;
-   }
-   return 0;
-}
-
-static int reg_read(struct tc90522_state *state, u8 reg, u8 *val, u8 len)
-{
-   struct i2c_msg msgs[2] = {
-   {
-   .addr = state->i2c_client->addr,
-   .flags = 0,
-   .buf = ®,
-   .len = 1,
-   },
-   {
-   .addr = state->i2c_client->addr,
-   .flags = I2C_M_RD,
-   .buf = val,
-   .len = len,
-   },
+   struct tc90522 *demod = fe->demodulator_priv;
+   struct i2c_msg msg[] = {
+   { .addr = demod->addr_demod, .flags = 0, .buf = (u8 *)data, 
.len = len, },
};
-   int ret;
-
-   ret = i2c_transfer(state->i2c_client->adapter, msgs, ARRAY_SIZE(msgs));
-   if (ret == ARRAY_SIZE(msgs))
-   ret = 0;
-   else if (ret >= 0)
-   ret = -EIO;
-   return ret;
-}
 
-static struct tc90522_state *cfg_to_state(struct tc90522_config *c)
-{
-   return container_of(c, struct tc90522_state, cfg);
+   if (!data || !len)
+   return -EINVAL;
+   return i2c_transfer(demod->i2c, msg, 1) == 1 ? 0 : -EREMOTEIO;
 }
 
-
-static int tc90522s_set_tsid(struct dvb_frontend *fe)
+int tc90522_

[PATCH 05/11] pt3: merge I2C & DMA handlers

2014-10-05 Thread Буди Романто, AreMa Inc
I2C & DMA handlers are merged into single file.

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/pci/pt3/Makefile | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/media/pci/pt3/Makefile b/drivers/media/pci/pt3/Makefile
index 396f146..56ebc9b 100644
--- a/drivers/media/pci/pt3/Makefile
+++ b/drivers/media/pci/pt3/Makefile
@@ -1,8 +1,4 @@
+obj-$(CONFIG_DVB_PT3) += pt3.o
 
-earth-pt3-objs += pt3.o pt3_i2c.o pt3_dma.o
+ccflags-y += -Idrivers/media/dvb-core -Idrivers/media/dvb-frontends 
-Idrivers/media/tuners
 
-obj-$(CONFIG_DVB_PT3) += earth-pt3.o
-
-ccflags-y += -Idrivers/media/dvb-core
-ccflags-y += -Idrivers/media/dvb-frontends
-ccflags-y += -Idrivers/media/tuners
-- 
1.8.4.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 10/11] qm1d1c0042: namespace cleanup & remodelling

2014-10-05 Thread Буди Романто, AreMa Inc
- minimize exports
- use client->dev.platform_data to point frontend
- use real address for I2C
- no freq limits in FE, it is non sense. move here...
- try to treat invalid frequency as channel number

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/tuners/qm1d1c0042.c | 644 ++
 1 file changed, 296 insertions(+), 348 deletions(-)

diff --git a/drivers/media/tuners/qm1d1c0042.c 
b/drivers/media/tuners/qm1d1c0042.c
index 18bc745..39adc0a 100644
--- a/drivers/media/tuners/qm1d1c0042.c
+++ b/drivers/media/tuners/qm1d1c0042.c
@@ -1,12 +1,12 @@
 /*
- * Sharp QM1D1C0042 8PSK tuner driver
+ * Sharp VA4M6JC2103 - Earthsoft PT3 ISDB-S tuner driver QM1D1C0042
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,156 +14,145 @@
  * GNU General Public License for more details.
  */
 
-/*
- * NOTICE:
- * As the disclosed information on the chip is very limited,
- * this driver lacks some features, including chip config like IF freq.
- * It assumes that users of this driver (such as a PCI bridge of
- * DTV receiver cards) know the relevant info and
- * configure the chip via I2C if necessary.
- *
- * Currently, PT3 driver is the only one that uses this driver,
- * and contains init/config code in its firmware.
- * Thus some part of the code might be dependent on PT3 specific config.
- */
-
-#include 
-#include 
+#include "dvb_frontend.h"
 #include "qm1d1c0042.h"
 
-#define QM1D1C0042_NUM_REGS 0x20
+struct qm1d1c0042 {
+   struct dvb_frontend *fe;
+   u8 addr_tuner, idx, reg[32];
+   u32 freq;
+   int (*read)(struct dvb_frontend *fe, u8 *buf, int buflen);
+};
 
-static const u8 reg_initval[QM1D1C0042_NUM_REGS] = {
+static const u8 qm1d1c0042_reg_rw[] = {
0x48, 0x1c, 0xa0, 0x10, 0xbc, 0xc5, 0x20, 0x33,
0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0xff, 0xf3, 0x00, 0x2a, 0x64, 0xa6, 0x86,
-   0x8c, 0xcf, 0xb8, 0xf1, 0xa8, 0xf2, 0x89, 0x00
-};
-
-static const struct qm1d1c0042_config default_cfg = {
-   .xtal_freq = 16000,
-   .lpf = 1,
-   .fast_srch = 0,
-   .lpf_wait = 20,
-   .fast_srch_wait = 4,
-   .normal_srch_wait = 15,
+   0x8c, 0xcf, 0xb8, 0xf1, 0xa8, 0xf2, 0x89, 0x00,
 };
 
-struct qm1d1c0042_state {
-   struct qm1d1c0042_config cfg;
-   struct i2c_client *i2c;
-   u8 regs[QM1D1C0042_NUM_REGS];
-};
-
-static struct qm1d1c0042_state *cfg_to_state(struct qm1d1c0042_config *c)
-{
-   return container_of(c, struct qm1d1c0042_state, cfg);
-}
-
-static int reg_write(struct qm1d1c0042_state *state, u8 reg, u8 val)
+/* read via demodulator */
+int qm1d1c0042_fe_read(struct dvb_frontend *fe, u8 addr_data, u8 *data)
 {
-   u8 wbuf[2] = { reg, val };
int ret;
+   struct qm1d1c0042 *qm = fe->tuner_priv;
+   u8 addr[] = { qm->addr_tuner, addr_data };
 
-   ret = i2c_master_send(state->i2c, wbuf, sizeof(wbuf));
-   if (ret >= 0 && ret < sizeof(wbuf))
-   ret = -EIO;
-   return (ret == sizeof(wbuf)) ? 0 : ret;
+   if ((addr_data != 0x00) && (addr_data != 0x0d))
+   return -EFAULT;
+   ret = qm->read(fe, addr, ARRAY_SIZE(addr));
+   if (ret < 0)
+   return ret;
+   *data = ret;
+   return 0;
 }
 
-static int reg_read(struct qm1d1c0042_state *state, u8 reg, u8 *val)
+/* write via demodulator */
+int qm1d1c0042_fe_write_data(struct dvb_frontend *fe, u8 addr_data, u8 *data, 
int len)
 {
-   struct i2c_msg msgs[2] = {
-   {
-   .addr = state->i2c->addr,
-   .flags = 0,
-   .buf = ®,
-   .len = 1,
-   },
-   {
-   .addr = state->i2c->addr,
-   .flags = I2C_M_RD,
-   .buf = val,
-   .len = 1,
-   },
-   };
-   int ret;
+   u8 buf[len + 1];
 
-   ret = i2c_transfer(state->i2c->adapter, msgs, ARRAY_SIZE(msgs));
-   if (ret >= 0 && ret < ARRAY_SIZE(msgs))
-   ret = -EIO;
-   return (ret == ARRAY_SIZE(msgs)) ? 0 : ret;
+   buf[0] = addr_data;
+   memcpy(buf + 1, data, len);
+   return fe->ops.write(fe, buf, len + 1);
 }
 
+#defin

[PATCH 08/11] qm1d1c0042: namespace cleanup

2014-10-05 Thread Буди Романто, AreMa Inc
minimize export

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/tuners/qm1d1c0042.h | 34 ++
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/media/tuners/qm1d1c0042.h 
b/drivers/media/tuners/qm1d1c0042.h
index 4f5c188..65bca43 100644
--- a/drivers/media/tuners/qm1d1c0042.h
+++ b/drivers/media/tuners/qm1d1c0042.h
@@ -1,12 +1,12 @@
 /*
- * Sharp QM1D1C0042 8PSK tuner driver
+ * Sharp VA4M6JC2103 - Earthsoft PT3 ISDB-S tuner driver QM1D1C0042
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,24 +14,10 @@
  * GNU General Public License for more details.
  */
 
-#ifndef QM1D1C0042_H
-#define QM1D1C0042_H
-
-#include "dvb_frontend.h"
-
+#ifndef __QM1D1C0042_H__
+#define __QM1D1C0042_H__
 
-struct qm1d1c0042_config {
-   struct dvb_frontend *fe;
+#define QM1D1C0042_DRVNAME "qm1d1c0042"
 
-   u32  xtal_freq;/* [kHz] */ /* currently ignored */
-   bool lpf;  /* enable LPF */
-   bool fast_srch;/* enable fast search mode, no LPF */
-   u32  lpf_wait; /* wait in tuning with LPF enabled. [ms] */
-   u32  fast_srch_wait;   /* with fast-search mode, no LPF. [ms] */
-   u32  normal_srch_wait; /* with no LPF/fast-search mode. [ms] */
-};
-/* special values indicating to use the default in qm1d1c0042_config */
-#define QM1D1C0042_CFG_XTAL_DFLT 0
-#define QM1D1C0042_CFG_WAIT_DFLT 0
+#endif
 
-#endif /* QM1D1C0042_H */
-- 
1.8.4.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 11/11] pt3: merge I2C & DMA handlers

2014-10-05 Thread Буди Романто, AreMa Inc
- namespace cleanup, minimize exports and "goto" sentences
- remove useless parameters: one_adapter, num_bufs
- using single DVB adapter is wrong approach, change to 1 adapter per 1 FE + 1 
tuner
- use pci_request_selected_regions() instead of pci_request_regions()
- provide
struct i2c_client *pt3_register_subdev(struct i2c_adapter *adap, struct 
i2c_board_info const *info)
  and
void pt3_unregister_subdev(struct i2c_client *clt)
  -> should be merged into standard functions?

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/pci/pt3/pt3.c | 1557 +--
 drivers/media/pci/pt3/pt3_dma.c |  225 --
 drivers/media/pci/pt3/pt3_i2c.c |  240 --
 3 files changed, 839 insertions(+), 1183 deletions(-)
 delete mode 100644 drivers/media/pci/pt3/pt3_dma.c
 delete mode 100644 drivers/media/pci/pt3/pt3_i2c.c

diff --git a/drivers/media/pci/pt3/pt3.c b/drivers/media/pci/pt3/pt3.c
index 1fdeac1..fcefee7 100644
--- a/drivers/media/pci/pt3/pt3.c
+++ b/drivers/media/pci/pt3/pt3.c
@@ -1,12 +1,12 @@
 /*
- * Earthsoft PT3 driver
+ * DVB driver for Earthsoft PT3 ISDB-S/T PCIE bridge Altera Cyclone IV FPGA 
EP4CGX15BF14C8N
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,863 +14,984 @@
  * GNU General Public License for more details.
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
-
-#include "dmxdev.h"
-#include "dvbdev.h"
+#include 
+#include 
 #include "dvb_demux.h"
+#include "dmxdev.h"
 #include "dvb_frontend.h"
-
+#include "tc90522.h"
+#include "qm1d1c0042.h"
+#include "mxl301rf.h"
 #include "pt3.h"
 
-DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
+MODULE_AUTHOR("Budi Rachmanto, AreMa Inc. ");
+MODULE_DESCRIPTION("Earthsoft PT3 DVB Driver");
+MODULE_LICENSE("GPL");
 
-static bool one_adapter;
-module_param(one_adapter, bool, 0444);
-MODULE_PARM_DESC(one_adapter, "Place FE's together under one adapter.");
+static struct pci_device_id pt3_id_table[] = {
+   { PCI_DEVICE(0x1172, 0x4c15) },
+   { },
+};
+MODULE_DEVICE_TABLE(pci, pt3_id_table);
 
-static int num_bufs = 4;
-module_param(num_bufs, int, 0444);
-MODULE_PARM_DESC(num_bufs, "Number of DMA buffer (188KiB) per FE.");
+static int lnb = 2;
+module_param(lnb, int, 0);
+MODULE_PARM_DESC(lnb, "LNB level (0:OFF 1:+11V 2:+15V)");
+
+/* common defs */
+
+#define PT3_REG_VERSION0x00/*  R   Version */
+#define PT3_REG_BUS0x04/*  R   Bus */
+#define PT3_REG_SYS_W  0x08/*  W   System  */
+#define PT3_REG_SYS_R  0x0c/*  R   System  */
+#define PT3_REG_I2C_W  0x10/*  W   I2C */
+#define PT3_REG_I2C_R  0x14/*  R   I2C */
+#define PT3_REG_RAM_W  0x18/*  W   RAM */
+#define PT3_REG_RAM_R  0x1c/*  R   RAM */
+#define PT3_REG_BASE   0x40/* + 0x18*idx   */
+#define PT3_OFS_DMA_D_L0x00/*  W   DMA descriptor  */
+#define PT3_OFS_DMA_D_H0x04/*  W   DMA descriptor  */
+#define PT3_OFS_DMA_CTL0x08/*  W   DMA */
+#define PT3_OFS_TS_CTL 0x0c/*  W   TS  */
+#define PT3_OFS_STATUS 0x10/*  R   DMA/FIFO/TS */
+#define PT3_OFS_TS_ERR 0x14/*  R   TS  */
+
+struct pt3_adapter;
+
+struct pt3_board {
+   struct mutex lock;
+   int lnb;
+   bool reset;
+
+   struct pci_dev *pdev;
+   int bars;
+   void __iomem *bar_reg, *bar_mem;
+   struct i2c_adapter i2c;
+   u8 i2c_buf;
+   u32 i2c_addr;
+   bool i2c_filled;
+
+   struct pt3_adapter **adap;
+};
 
+struct pt3_adapter {
+   struct mutex lock;
+   struct pt3_board *pt3;
 
-static const struct i2c_algorithm pt3_i2c_algo = {
-   .master_xfer   = &pt3_i2c_master_xfer,
-   .functionality = &pt3_i2c_functionality,
+   u8 idx;
+   bool sleep;
+   struct pt3_dma *dma;
+   struct task_struct *kthread;
+   struct dvb_adapter dvb;
+   struct dvb_demux demux;
+   struct dmxdev dmxdev;
+   int users;
+
+  

[PATCH 06/11] pt3: namespace cleanup

2014-10-05 Thread Буди Романто, AreMa Inc
nothing to export

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/pci/pt3/pt3.h | 183 +++-
 1 file changed, 10 insertions(+), 173 deletions(-)

diff --git a/drivers/media/pci/pt3/pt3.h b/drivers/media/pci/pt3/pt3.h
index 1b3f2ad..13a0c8c 100644
--- a/drivers/media/pci/pt3/pt3.h
+++ b/drivers/media/pci/pt3/pt3.h
@@ -1,12 +1,12 @@
 /*
- * Earthsoft PT3 driver
+ * DVB driver for Earthsoft PT3 ISDB-S/T PCI-E card
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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
@@ -14,173 +14,10 @@
  * GNU General Public License for more details.
  */
 
-#ifndef PT3_H
-#define PT3_H
-
-#include 
-#include 
-
-#include "dvb_demux.h"
-#include "dvb_frontend.h"
-#include "dmxdev.h"
-
-#include "tc90522.h"
-#include "mxl301rf.h"
-#include "qm1d1c0042.h"
-
-#define DRV_NAME KBUILD_MODNAME
-
-#define PT3_NUM_FE 4
-
-/*
- * register index of the FPGA chip
- */
-#define REG_VERSION0x00
-#define REG_BUS0x04
-#define REG_SYSTEM_W   0x08
-#define REG_SYSTEM_R   0x0c
-#define REG_I2C_W  0x10
-#define REG_I2C_R  0x14
-#define REG_RAM_W  0x18
-#define REG_RAM_R  0x1c
-#define REG_DMA_BASE   0x40/* regs for FE[i] = REG_DMA_BASE + 0x18 * i */
-#define OFST_DMA_DESC_L0x00
-#define OFST_DMA_DESC_H0x04
-#define OFST_DMA_CTL   0x08
-#define OFST_TS_CTL0x0c
-#define OFST_STATUS0x10
-#define OFST_TS_ERR0x14
-
-/*
- * internal buffer for I2C
- */
-#define PT3_I2C_MAX 4091
-struct pt3_i2cbuf {
-   u8  data[PT3_I2C_MAX];
-   u8  tmp;
-   u32 num_cmds;
-};
-
-/*
- * DMA things
- */
-#define TS_PACKET_SZ  188
-/* DMA transfers must not cross 4GiB, so use one page / transfer */
-#define DATA_XFER_SZ   4096
-#define DATA_BUF_XFERS 47
-/* (num_bufs * DATA_BUF_SZ) % TS_PACKET_SZ must be 0 */
-#define DATA_BUF_SZ(DATA_BUF_XFERS * DATA_XFER_SZ)
-#define MAX_DATA_BUFS  16
-#define MIN_DATA_BUFS   2
-
-#define DESCS_IN_PAGE (PAGE_SIZE / sizeof(struct xfer_desc))
-#define MAX_NUM_XFERS (MAX_DATA_BUFS * DATA_BUF_XFERS)
-#define MAX_DESC_BUFS DIV_ROUND_UP(MAX_NUM_XFERS, DESCS_IN_PAGE)
-
-/* DMA transfer description.
- * device is passed a pointer to this struct, dma-reads it,
- * and gets the DMA buffer ring for storing TS data.
- */
-struct xfer_desc {
-   u32 addr_l; /* bus address of target data buffer */
-   u32 addr_h;
-   u32 size;
-   u32 next_l; /* bus adddress of the next xfer_desc */
-   u32 next_h;
-};
-
-/* A DMA mapping of a page containing xfer_desc's */
-struct xfer_desc_buffer {
-   dma_addr_t b_addr;
-   struct xfer_desc *descs; /* PAGE_SIZE (xfer_desc[DESCS_IN_PAGE]) */
-};
-
-/* A DMA mapping of a data buffer */
-struct dma_data_buffer {
-   dma_addr_t b_addr;
-   u8 *data; /* size: u8[PAGE_SIZE] */
-};
-
-/*
- * device things
- */
-struct pt3_adap_config {
-   struct i2c_board_info demod_info;
-   struct tc90522_config demod_cfg;
-
-   struct i2c_board_info tuner_info;
-   union tuner_config {
-   struct qm1d1c0042_config qm1d1c0042;
-   struct mxl301rf_config   mxl301rf;
-   } tuner_cfg;
-   u32 init_freq;
-};
-
-struct pt3_adapter {
-   struct dvb_adapter  dvb_adap;  /* dvb_adap.priv => struct pt3_board */
-   int adap_idx;
-
-   struct dvb_demuxdemux;
-   struct dmxdev   dmxdev;
-   struct dvb_frontend *fe;
-   struct i2c_client   *i2c_demod;
-   struct i2c_client   *i2c_tuner;
-
-   /* data fetch thread */
-   struct task_struct *thread;
-   int num_feeds;
-
-   bool cur_lna;
-   bool cur_lnb; /* current LNB power status (on/off) */
-
-   /* items below are for DMA */
-   struct dma_data_buffer buffer[MAX_DATA_BUFS];
-   int buf_idx;
-   int buf_ofs;
-   int num_bufs;  /* == pt3_board->num_bufs */
-   int num_discard; /* how many access units to discard initially */
-
-   struct xfer_desc_buffer desc_buf[MAX_DESC_BUFS];
-   int num_desc_bufs;  /* == num_bufs * DATA_BUF_XFERS / DESCS_IN_PAGE */
-};
+#ifndef__PT3_H__
+#define__PT3_H__
 
+#define PT3_DRVNAME KBUILD_MODNAME
 
-struct pt3_board {
-   struct pci_dev *pdev;
-   void __iomem *regs[2];
-   /* regs[0]: registers, regs[1]: internal memory, used for I2C */
-

[PATCH 01/11] tc90522: better chip description

2014-10-05 Thread Буди Романто, AreMa Inc
tc90522 has both satellite & terrestrial demodulators,
thus change the category description

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig  | 4 ++--
 drivers/media/dvb-frontends/Makefile | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 5a13454..0c59825 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -653,7 +653,7 @@ config DVB_TC90522
depends on DVB_CORE && I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
- A Toshiba TC90522 2xISDB-T + 2xISDB-S demodulator.
+ Toshiba TC90522 2xISDB-S 8PSK + 2xISDB-T OFDM demodulator.
  Say Y when you want to support this frontend.
 
 comment "Digital terrestrial only tuners/PLL"
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index ba59df6..6f05615 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -116,3 +116,4 @@ obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
 obj-$(CONFIG_DVB_TC90522) += tc90522.o
+
-- 
1.8.4.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] pt3 (pci, tc90522, mxl301rf, qm1d1c0042): pt3_unregister_subdev(), pt3_unregister_subdev(), cleanups...

2014-10-02 Thread Буди Романто, AreMa Inc
DVB driver for Earthsoft PT3 PCIE ISDB-S/T receiver
^^^

Status: stable

Changes:
- demod & tuners converted to I2C binding model
- i586 & x86_64 clean compile
- lightweight & yet precise CNR calculus
- raw CNR (DVBv3)
- DVBv5 CNR @ 0.0001 dB (ref: include/uapi/linux/dvb/frontend.h, not 1/1000 dB!)
- removed (unused?) tuner's *_release()
- demod/tuner binding: pt3_unregister_subdev(), pt3_unregister_subdev()
- some cleanups

Features:
- tuning enhancements (compared to PT1 DVB)
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#
- allocated devices
ISDB-S : /dev/dvb/adapter0, /dev/dvb/adapter1
ISDB-T : /dev/dvb/adapter2, /dev/dvb/adapter3

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig   |6 +-
 drivers/media/dvb-frontends/Makefile  |1 +
 drivers/media/dvb-frontends/tc90522.c | 1145 -
 drivers/media/dvb-frontends/tc90522.h |   39 +-
 drivers/media/pci/pt3/Kconfig |   11 +-
 drivers/media/pci/pt3/Makefile|8 +-
 drivers/media/pci/pt3/pt3_common.h|   85 +++
 drivers/media/pci/pt3/pt3_dma.c   |  461 -
 drivers/media/pci/pt3/pt3_dma.h   |   50 ++
 drivers/media/pci/pt3/pt3_i2c.c   |  281 
 drivers/media/pci/pt3/pt3_i2c.h   |   25 +
 drivers/media/pci/pt3/pt3_pci.c   |  435 +
 drivers/media/tuners/mxl301rf.c   |  549 
 drivers/media/tuners/mxl301rf.h   |   23 +-
 drivers/media/tuners/qm1d1c0042.c |  643 +-
 drivers/media/tuners/qm1d1c0042.h |   32 +-
 16 files changed, 2054 insertions(+), 1740 deletions(-)
 create mode 100644 drivers/media/pci/pt3/pt3_common.h
 create mode 100644 drivers/media/pci/pt3/pt3_dma.h
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.h
 create mode 100644 drivers/media/pci/pt3/pt3_pci.c

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 5a13454..cd07b17 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -649,11 +649,11 @@ config DVB_MB86A20S
  Say Y when you want to support this frontend.
 
 config DVB_TC90522
-   tristate "Toshiba TC90522"
+   tristate "Toshiba TC90522XBG 8PSK(ISDB-S)/OFDM(ISDB-T)"
depends on DVB_CORE && I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
- A Toshiba TC90522 2xISDB-T + 2xISDB-S demodulator.
+ Toshiba TC90522XBG 2xISDB-S(8PSK) + 2xISDB-T(OFDM) demodulator.
  Say Y when you want to support this frontend.
 
 comment "Digital terrestrial only tuners/PLL"
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index ba59df6..6f05615 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -116,3 +116,4 @@ obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
 obj-$(CONFIG_DVB_TC90522) += tc90522.o
+
diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
index d9905fb..954ca8d 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -1,12 +1,12 @@
 /*
- * Toshiba TC90522 Demodulator
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator frontend 
for Earthsoft PT3
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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 wa

[PATCH] pt3 (PCI, tc90522, mxl301rf, qm1d1c0042): pt3_unregister_subdev(), pt3_unregister_subdev(),...

2014-10-01 Thread Буди Романто, AreMa Inc

[DVB driver for Earthsoft PT3 PCIE ISDB-S/T receiver]

Status: working, tested

Changes:
- demod & tuners converted to I2C binding model
- i586 & x86_64 clean compile
- lightweight & yet precise CNR calculus
- raw CNR (DVBv3)
- DVBv5 CNR @ 0.0001 dB (ref: include/uapi/linux/dvb/frontend.h, not 1/1000 dB!)
- removed (unused?) tuner's *_release()
- demod/tuner binding: pt3_unregister_subdev(), pt3_unregister_subdev()

Features:
- tuning enhancements (compared to PT1 DVB)
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#
- allocated devices
ISDB-S : /dev/dvb/adapter0, /dev/dvb/adapter1
ISDB-T : /dev/dvb/adapter2, /dev/dvb/adapter3

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb2
- buildable as standalone, DKMS or tree embedded module
- installation:
$ chmod +x dkms.install dkms.uninstall
$ ./dkms.install

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig   |6 +-
 drivers/media/dvb-frontends/Makefile  |1 +
 drivers/media/dvb-frontends/tc90522.c | 1145 -
 drivers/media/dvb-frontends/tc90522.h |   39 +-
 drivers/media/pci/pt3/Kconfig |   11 +-
 drivers/media/pci/pt3/Makefile|8 +-
 drivers/media/pci/pt3/pt3_common.h|   85 +++
 drivers/media/pci/pt3/pt3_dma.c   |  461 -
 drivers/media/pci/pt3/pt3_dma.h   |   50 ++
 drivers/media/pci/pt3/pt3_i2c.c   |  281 
 drivers/media/pci/pt3/pt3_i2c.h   |   25 +
 drivers/media/pci/pt3/pt3_pci.c   |  435 +
 drivers/media/tuners/mxl301rf.c   |  549 
 drivers/media/tuners/mxl301rf.h   |   23 +-
 drivers/media/tuners/qm1d1c0042.c |  646 +--
 drivers/media/tuners/qm1d1c0042.h |   32 +-
 16 files changed, 2058 insertions(+), 1739 deletions(-)
 create mode 100644 drivers/media/pci/pt3/pt3_common.h
 create mode 100644 drivers/media/pci/pt3/pt3_dma.h
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.h
 create mode 100644 drivers/media/pci/pt3/pt3_pci.c

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 5a13454..39fef85 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -649,11 +649,11 @@ config DVB_MB86A20S
  Say Y when you want to support this frontend.
 
 config DVB_TC90522
-   tristate "Toshiba TC90522"
+   tristate "Toshiba TC90522XBG 8PSK(ISDB-S)/OFDM(ISDB-T)"
depends on DVB_CORE && I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
- A Toshiba TC90522 2xISDB-T + 2xISDB-S demodulator.
+ Toshiba TC90522XBG 8PSK(ISDB-S)/OFDM(ISDB-T) quad demodulator.
  Say Y when you want to support this frontend.
 
 comment "Digital terrestrial only tuners/PLL"
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index ba59df6..6f05615 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -116,3 +116,4 @@ obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
 obj-$(CONFIG_DVB_TC90522) += tc90522.o
+
diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
index d9905fb..954ca8d 100644
--- a/drivers/media/dvb-frontends/tc90522.c
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -1,12 +1,12 @@
 /*
- * Toshiba TC90522 Demodulator
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator frontend 
for Earthsoft PT3
  *
- * Copyright (C) 2014 Akihiro Tsukada 
- *
- * 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 version 2.
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
  *
+ * 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 

[PATCH] PT3 ISDB-S/T driver (PCI, tc90522, mxl301rf, qm1d1c0042)

2014-09-25 Thread Буди Романто, AreMa Inc

[DVB driver for Earthsoft PT3 PCIE ISDB-S/T receiver]

Features & changes:
- 32bit + 64bit clean compile (removed math64.h)
- simpler & yet precise CNR calculation
- CNR @ 0.0001 dB (as stated in include/uapi/linux/dvb/frontend.h, not 1/1000 
dB!)
- tuning enhancements (compared to PT1 DVB)
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#
- allocated devices
ISDB-S : /dev/dvb/adapter0, /dev/dvb/adapter1
ISDB-T : /dev/dvb/adapter2, /dev/dvb/adapter3

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig   |  11 +-
 drivers/media/dvb-frontends/Makefile  |   2 +
 drivers/media/dvb-frontends/tc90522.c | 539 ++
 drivers/media/dvb-frontends/tc90522.h |  33 +++
 drivers/media/pci/Kconfig |   1 +
 drivers/media/pci/Makefile|   1 +
 drivers/media/pci/pt3/Kconfig |  11 +
 drivers/media/pci/pt3/Makefile|   6 +
 drivers/media/pci/pt3/pt3_common.h|  84 ++
 drivers/media/pci/pt3/pt3_dma.c   | 332 +
 drivers/media/pci/pt3/pt3_dma.h   |  50 
 drivers/media/pci/pt3/pt3_i2c.c   | 191 
 drivers/media/pci/pt3/pt3_i2c.h   |  25 ++
 drivers/media/pci/pt3/pt3_pci.c   | 400 +
 drivers/media/tuners/Kconfig  |  14 +
 drivers/media/tuners/Makefile |   2 +
 drivers/media/tuners/mxl301rf.c   | 361 +++
 drivers/media/tuners/mxl301rf.h   |  33 +++
 drivers/media/tuners/qm1d1c0042.c | 382 
 drivers/media/tuners/qm1d1c0042.h |  33 +++
 20 files changed, 2510 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/dvb-frontends/tc90522.c
 create mode 100644 drivers/media/dvb-frontends/tc90522.h
 create mode 100644 drivers/media/pci/pt3/Kconfig
 create mode 100644 drivers/media/pci/pt3/Makefile
 create mode 100644 drivers/media/pci/pt3/pt3_common.h
 create mode 100644 drivers/media/pci/pt3/pt3_dma.c
 create mode 100644 drivers/media/pci/pt3/pt3_dma.h
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.c
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.h
 create mode 100644 drivers/media/pci/pt3/pt3_pci.c
 create mode 100644 drivers/media/tuners/mxl301rf.c
 create mode 100644 drivers/media/tuners/mxl301rf.h
 create mode 100644 drivers/media/tuners/qm1d1c0042.c
 create mode 100644 drivers/media/tuners/qm1d1c0042.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 704403f..d925d3f 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -648,6 +648,15 @@ config DVB_MB86A20S
  A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator.
  Say Y when you want to support this frontend.
 
+config DVB_TC90522
+   tristate "Toshiba TC90522XBG 8PSK(ISDB-S)/OFDM(ISDB-T)"
+   depends on DVB_CORE && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Toshiba TC90522XBG 8PSK(ISDB-S)/OFDM(ISDB-T) demodulator
+ frontend for Earthsoft PT3 PCIE cards.
+ Say Y when you want to support this frontend.
+
 comment "Digital terrestrial only tuners/PLL"
depends on DVB_CORE
 
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index 1e19a74..6f05615 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -115,3 +115,5 @@ obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
 obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
+obj-$(CONFIG_DVB_TC90522) += tc90522.o
+
diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
new file mode 100644
index 000..3e82e45
--- /dev/null
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -0,0 +1,539 @@
+/*
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator frontend 
for Earthsoft PT3
+ *
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of

[PATCH] Earthsoft PT3 ISDB-S/T driver (demodulator: tc90522)

2014-09-10 Thread Буди Романто, AreMa Inc
From: Bud 


DVB driver for Earthsoft PT3 (PCIE ISDB-S/T receiver)
-

Status: stable

Features:
- tuning enhancements, from  PT1 DVB
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#
- allocated devices
ISDB-S : /dev/dvb/adapter0, /dev/dvb/adapter1
ISDB-T : /dev/dvb/adapter2, /dev/dvb/adapter3

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb
- buildable as standalone, DKMS or tree embedded module
- installation:
$ chmod +x dkms.install dkms.uninstall
$ ./dkms.install

Changes since last release:
- cleanups (removed unused/useless features, simple is the best)
- removed .ops.write hacks

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig   |  18 +-
 drivers/media/dvb-frontends/Makefile  |   3 +-
 drivers/media/dvb-frontends/tc90522.c | 525 ++
 drivers/media/dvb-frontends/tc90522.h |  33 +++

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 704403f..292694e 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -648,6 +648,15 @@ config DVB_MB86A20S
  A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator.
  Say Y when you want to support this frontend.
 
+config DVB_TC90522
+   tristate "Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S)"
+   depends on DVB_CORE && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S) demodulator
+ frontend for Earthsoft PT3 PCIE cards.
+ Say Y when you want to support this frontend.
+
 comment "Digital terrestrial only tuners/PLL"
depends on DVB_CORE
 
@@ -725,13 +734,6 @@ config DVB_A8293
depends on DVB_CORE && I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
 
-config DVB_SP2
-   tristate "CIMaX SP2"
-   depends on DVB_CORE && I2C
-   default m if !MEDIA_SUBDRV_AUTOSELECT
-   help
- CIMaX SP2/SP2HF Common Interface module.
-
 config DVB_LGS8GL5
tristate "Silicon Legend LGS-8GL5 demodulator (OFDM)"
depends on DVB_CORE && I2C
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index 1e19a74..8f9a229 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -107,7 +107,6 @@ obj-$(CONFIG_DVB_DRXK) += drxk.o
 obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
 obj-$(CONFIG_DVB_SI2165) += si2165.o
 obj-$(CONFIG_DVB_A8293) += a8293.o
-obj-$(CONFIG_DVB_SP2) += sp2.o
 obj-$(CONFIG_DVB_TDA10071) += tda10071.o
 obj-$(CONFIG_DVB_RTL2830) += rtl2830.o
 obj-$(CONFIG_DVB_RTL2832) += rtl2832.o
@@ -115,3 +114,5 @@ obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
 obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
+obj-$(CONFIG_DVB_TC90522) += tc90522.o
+
diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
new file mode 100644
index 000..26e2efe
--- /dev/null
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -0,0 +1,525 @@
+/*
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator frontend 
for Earthsoft PT3
+ *
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
+ *
+ * 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.
+ */
+
+#include "dvb_math.h"
+#include "tc90522.h"
+
+MODULE_AUTHOR("Budi Rachmanto, AreMa Inc. ");
+MODULE_DESCRIPTION("Toshiba TC90522 OFDM(ISDB-T)/8PSK(ISDB-S) demodulator 
[Earthsoft PT3]");
+MODULE_LICENSE("GPL");
+
+#define TC90522_P

[PATCH] Earthsoft PT3 ISDB-S/T driver (PCI bridge: FPGA, I2C, DMA handlers)

2014-09-10 Thread Буди Романто, AreMa Inc
From: Bud 


DVB driver for Earthsoft PT3 (PCIE ISDB-S/T receiver)
-

Status: stable

Features:
- tuning enhancements, from  PT1 DVB
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#
- allocated devices
ISDB-S : /dev/dvb/adapter0, /dev/dvb/adapter1
ISDB-T : /dev/dvb/adapter2, /dev/dvb/adapter3

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb
- buildable as standalone, DKMS or tree embedded module
- installation:
$ chmod +x dkms.install dkms.uninstall
$ ./dkms.install

Changes since last release:
- cleanups (removed unused/useless features, simple is the best)
- removed .ops.write hacks

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/pci/Kconfig |   2 +-
 drivers/media/pci/Makefile|   2 +-
 drivers/media/pci/pt3/Kconfig |  11 +
 drivers/media/pci/pt3/Makefile|   6 +
 drivers/media/pci/pt3/pt3_common.h|  84 ++
 drivers/media/pci/pt3/pt3_dma.c   | 332 +
 drivers/media/pci/pt3/pt3_dma.h   |  50 
 drivers/media/pci/pt3/pt3_i2c.c   | 191 +
 drivers/media/pci/pt3/pt3_i2c.h   |  25 ++
 drivers/media/pci/pt3/pt3_pci.c   | 403 ++

diff --git a/drivers/media/pci/Kconfig b/drivers/media/pci/Kconfig
index 9332807..89bd2a5 100644
--- a/drivers/media/pci/Kconfig
+++ b/drivers/media/pci/Kconfig
@@ -20,7 +20,6 @@ source "drivers/media/pci/ivtv/Kconfig"
 source "drivers/media/pci/zoran/Kconfig"
 source "drivers/media/pci/saa7146/Kconfig"
 source "drivers/media/pci/solo6x10/Kconfig"
-source "drivers/media/pci/tw68/Kconfig"
 endif
 
 if MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT
@@ -42,6 +41,7 @@ source "drivers/media/pci/b2c2/Kconfig"
 source "drivers/media/pci/pluto2/Kconfig"
 source "drivers/media/pci/dm1105/Kconfig"
 source "drivers/media/pci/pt1/Kconfig"
+source "drivers/media/pci/pt3/Kconfig"
 source "drivers/media/pci/mantis/Kconfig"
 source "drivers/media/pci/ngene/Kconfig"
 source "drivers/media/pci/ddbridge/Kconfig"
diff --git a/drivers/media/pci/Makefile b/drivers/media/pci/Makefile
index 73d9c0f..9db6775 100644
--- a/drivers/media/pci/Makefile
+++ b/drivers/media/pci/Makefile
@@ -7,6 +7,7 @@ obj-y+= ttpci/  \
pluto2/ \
dm1105/ \
pt1/\
+   pt3/\
mantis/ \
ngene/  \
ddbridge/   \
@@ -21,7 +22,6 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_BT848) += bt8xx/
 obj-$(CONFIG_VIDEO_SAA7134) += saa7134/
 obj-$(CONFIG_VIDEO_SAA7164) += saa7164/
-obj-$(CONFIG_VIDEO_TW68) += tw68/
 obj-$(CONFIG_VIDEO_MEYE) += meye/
 obj-$(CONFIG_STA2X11_VIP) += sta2x11/
 obj-$(CONFIG_VIDEO_SOLO6X10) += solo6x10/
diff --git a/drivers/media/pci/pt3/Kconfig b/drivers/media/pci/pt3/Kconfig
new file mode 100644
index 000..0d866a0
--- /dev/null
+++ b/drivers/media/pci/pt3/Kconfig
@@ -0,0 +1,11 @@
+config PT3_DVB
+   tristate "Earthsoft PT3 ISDB-S/T cards"
+   depends on DVB_CORE && PCI
+   select DVB_TC90522 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_QM1D1C0042 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_MXL301RF if MEDIA_SUBDRV_AUTOSELECT
+   help
+ Support for Earthsoft PT3 PCI-Express cards.
+ You need to enable frontend (TC90522) & tuners (QM1D1C0042, MXL301RF)
+ Say Y or M if you own such a device and want to use it.
+
diff --git a/drivers/media/pci/pt3/Makefile b/drivers/media/pci/pt3/Makefile
new file mode 100644
index 000..ede00e1
--- /dev/null
+++ b/drivers/media/pci/pt3/Makefile
@@ -0,0 +1,6 @@
+pt3_dvb-objs := pt3_pci.o pt3_dma.o pt3_i2c.o
+
+obj-$(CONFIG_PT3_DVB) += pt3_dvb.o
+
+ccflags-y += -Idrivers/media/dvb-core -Idrivers/media/dvb-frontends 
-Idrivers/media/tuners
+
diff --git a/drivers/media/pci/pt3/pt3_common.h 
b/drivers/media/pci/pt3/pt3_common.h
new file mode 100644
index 000..92b6597
--- /dev/null
+++ b/drivers/media/pci/pt3/pt3_common.h
@@ -0,0 +1,84 @@
+/*
+ * DVB driver for Earthsoft PT3 ISDB-S/T PCI-E card
+ *
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
+ *
+ * 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 Fr

[PATCH] Earthsoft PT3 ISDB-S/T driver (tuners: mxl301rf, qm1d1c0042)

2014-09-10 Thread Буди Романто, AreMa Inc
From: Bud 


DVB driver for Earthsoft PT3 (PCIE ISDB-S/T receiver)
-

Status: stable

Features:
- tuning enhancements, from  PT1 DVB
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#
- allocated devices
ISDB-S : /dev/dvb/adapter0, /dev/dvb/adapter1
ISDB-T : /dev/dvb/adapter2, /dev/dvb/adapter3

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb
- buildable as standalone, DKMS or tree embedded module
- installation:
$ chmod +x dkms.install dkms.uninstall
$ ./dkms.install

Changes since last release:
- cleanups (removed unused/useless features, simple is the best)
- removed .ops.write hacks

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/tuners/Kconfig  |  15 +-
 drivers/media/tuners/Makefile |   2 +
 drivers/media/tuners/mxl301rf.c   | 361 +++
 drivers/media/tuners/mxl301rf.h   |  33 +++
 drivers/media/tuners/qm1d1c0042.c | 382 +
 drivers/media/tuners/qm1d1c0042.h |  33 +++

diff --git a/drivers/media/tuners/Kconfig b/drivers/media/tuners/Kconfig
index 8319996..ee89558 100644
--- a/drivers/media/tuners/Kconfig
+++ b/drivers/media/tuners/Kconfig
@@ -226,7 +226,6 @@ config MEDIA_TUNER_FC2580
 config MEDIA_TUNER_M88TS2022
tristate "Montage M88TS2022 silicon tuner"
depends on MEDIA_SUPPORT && I2C
-   select REGMAP_I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
help
  Montage M88TS2022 silicon tuner driver.
@@ -258,4 +257,18 @@ config MEDIA_TUNER_R820T
default m if !MEDIA_SUBDRV_AUTOSELECT
help
  Rafael Micro R820T silicon tuner driver.
+
+config MEDIA_TUNER_MXL301RF
+   tristate "MaxLinear MXL301RF ISDB-T tuner"
+   depends on MEDIA_SUPPORT && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ MaxLinear MxL301RF ISDB-T tuner for PT3.
+
+config MEDIA_TUNER_QM1D1C0042
+   tristate "Sharp QM1D1C0042 ISDB-S tuner"
+   depends on MEDIA_SUPPORT && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Sharp QM1D1C0042 ISDB-S tuner for PT3.
 endmenu
diff --git a/drivers/media/tuners/Makefile b/drivers/media/tuners/Makefile
index 5591699..04d5efc 100644
--- a/drivers/media/tuners/Makefile
+++ b/drivers/media/tuners/Makefile
@@ -39,6 +39,8 @@ obj-$(CONFIG_MEDIA_TUNER_FC0012) += fc0012.o
 obj-$(CONFIG_MEDIA_TUNER_FC0013) += fc0013.o
 obj-$(CONFIG_MEDIA_TUNER_IT913X) += tuner_it913x.o
 obj-$(CONFIG_MEDIA_TUNER_R820T) += r820t.o
+obj-$(CONFIG_MEDIA_TUNER_MXL301RF) += mxl301rf.o
+obj-$(CONFIG_MEDIA_TUNER_QM1D1C0042) += qm1d1c0042.o
 
 ccflags-y += -I$(srctree)/drivers/media/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb-frontends
diff --git a/drivers/media/tuners/mxl301rf.c b/drivers/media/tuners/mxl301rf.c
new file mode 100644
index 000..f0c0a4a
--- /dev/null
+++ b/drivers/media/tuners/mxl301rf.c
@@ -0,0 +1,361 @@
+/*
+ * Sharp VA4M6JC2103 - Earthsoft PT3 ISDB-T tuner MaxLinear CMOS Hybrid TV 
MxL301RF
+ *
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
+ *
+ * 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.
+ */
+
+#include "mxl301rf.h"
+
+MODULE_AUTHOR("Budi Rachmanto, AreMa Inc. ");
+MODULE_DESCRIPTION("Earthsoft PT3 MxL301RF MaxLinear CMOS Hybrid TV ISDB-T 
tuner driver");
+MODULE_LICENSE("GPL");
+
+struct mxl301rf {
+   struct dvb_frontend *fe;
+   u8 addr_tuner, idx;
+   u32 freq;
+   int (*read)(struct dvb_frontend *fe, u8 *buf, int buflen);
+};
+
+struct shf_dvbt {
+   u32 freq,   /* Channel center frequency @ kHz   */
+   freq_th;/* Offset frequency threshold @ kHz */
+   u8  shf_val,/* Spur shift value */
+   shf_dir;/* Spur shift direction */
+};
+
+static const struct shf_dvbt shf_dvbt_tab[] = {
+   {  64500, 500, 0x92, 0x07 },
+   { 191500, 300, 0xe2, 0x07 },
+   { 205

[PATCH] Earthsoft PT3 ISDB-S/T driver (PCI bridge: FPGA, I2C, DMA handlers)

2014-09-10 Thread Буди Романто, AreMa Inc
From: Bud 


DVB driver for Earthsoft PT3 (PCIE ISDB-S/T receiver)
-

Status: stable

Features:
- tuning enhancements, from  PT1 DVB
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#
- allocated devices
ISDB-S : /dev/dvb/adapter0, /dev/dvb/adapter1
ISDB-T : /dev/dvb/adapter2, /dev/dvb/adapter3

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb
- buildable as standalone, DKMS or tree embedded module
- installation:
$ chmod +x dkms.install dkms.uninstall
$ ./dkms.install

Changes since last release:
- cleanups (removed unused/useless features, simple is the best)
- removed .ops.write hacks

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/pci/Kconfig |   2 +-
 drivers/media/pci/Makefile|   2 +-
 drivers/media/pci/pt3/Kconfig |  11 +
 drivers/media/pci/pt3/Makefile|   6 +
 drivers/media/pci/pt3/pt3_common.h|  84 ++
 drivers/media/pci/pt3/pt3_dma.c   | 332 +
 drivers/media/pci/pt3/pt3_dma.h   |  50 
 drivers/media/pci/pt3/pt3_i2c.c   | 191 +
 drivers/media/pci/pt3/pt3_i2c.h   |  25 ++
 drivers/media/pci/pt3/pt3_pci.c   | 403 ++

diff --git a/drivers/media/pci/Kconfig b/drivers/media/pci/Kconfig
index 9332807..89bd2a5 100644
--- a/drivers/media/pci/Kconfig
+++ b/drivers/media/pci/Kconfig
@@ -20,7 +20,6 @@ source "drivers/media/pci/ivtv/Kconfig"
 source "drivers/media/pci/zoran/Kconfig"
 source "drivers/media/pci/saa7146/Kconfig"
 source "drivers/media/pci/solo6x10/Kconfig"
-source "drivers/media/pci/tw68/Kconfig"
 endif
 
 if MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT
@@ -42,6 +41,7 @@ source "drivers/media/pci/b2c2/Kconfig"
 source "drivers/media/pci/pluto2/Kconfig"
 source "drivers/media/pci/dm1105/Kconfig"
 source "drivers/media/pci/pt1/Kconfig"
+source "drivers/media/pci/pt3/Kconfig"
 source "drivers/media/pci/mantis/Kconfig"
 source "drivers/media/pci/ngene/Kconfig"
 source "drivers/media/pci/ddbridge/Kconfig"
diff --git a/drivers/media/pci/Makefile b/drivers/media/pci/Makefile
index 73d9c0f..9db6775 100644
--- a/drivers/media/pci/Makefile
+++ b/drivers/media/pci/Makefile
@@ -7,6 +7,7 @@ obj-y+= ttpci/  \
pluto2/ \
dm1105/ \
pt1/\
+   pt3/\
mantis/ \
ngene/  \
ddbridge/   \
@@ -21,7 +22,6 @@ obj-$(CONFIG_VIDEO_CX88) += cx88/
 obj-$(CONFIG_VIDEO_BT848) += bt8xx/
 obj-$(CONFIG_VIDEO_SAA7134) += saa7134/
 obj-$(CONFIG_VIDEO_SAA7164) += saa7164/
-obj-$(CONFIG_VIDEO_TW68) += tw68/
 obj-$(CONFIG_VIDEO_MEYE) += meye/
 obj-$(CONFIG_STA2X11_VIP) += sta2x11/
 obj-$(CONFIG_VIDEO_SOLO6X10) += solo6x10/
diff --git a/drivers/media/pci/pt3/Kconfig b/drivers/media/pci/pt3/Kconfig
new file mode 100644
index 000..0d866a0
--- /dev/null
+++ b/drivers/media/pci/pt3/Kconfig
@@ -0,0 +1,11 @@
+config PT3_DVB
+   tristate "Earthsoft PT3 ISDB-S/T cards"
+   depends on DVB_CORE && PCI
+   select DVB_TC90522 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_QM1D1C0042 if MEDIA_SUBDRV_AUTOSELECT
+   select MEDIA_TUNER_MXL301RF if MEDIA_SUBDRV_AUTOSELECT
+   help
+ Support for Earthsoft PT3 PCI-Express cards.
+ You need to enable frontend (TC90522) & tuners (QM1D1C0042, MXL301RF)
+ Say Y or M if you own such a device and want to use it.
+
diff --git a/drivers/media/pci/pt3/Makefile b/drivers/media/pci/pt3/Makefile
new file mode 100644
index 000..ede00e1
--- /dev/null
+++ b/drivers/media/pci/pt3/Makefile
@@ -0,0 +1,6 @@
+pt3_dvb-objs := pt3_pci.o pt3_dma.o pt3_i2c.o
+
+obj-$(CONFIG_PT3_DVB) += pt3_dvb.o
+
+ccflags-y += -Idrivers/media/dvb-core -Idrivers/media/dvb-frontends 
-Idrivers/media/tuners
+
diff --git a/drivers/media/pci/pt3/pt3_common.h 
b/drivers/media/pci/pt3/pt3_common.h
new file mode 100644
index 000..92b6597
--- /dev/null
+++ b/drivers/media/pci/pt3/pt3_common.h
@@ -0,0 +1,84 @@
+/*
+ * DVB driver for Earthsoft PT3 ISDB-S/T PCI-E card
+ *
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
+ *
+ * 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 Fr

[PATCH] Earthsoft PT3 ISDB-S/T driver (PCI, tc90522, mxl301rf, qm1d1c0042)

2014-09-10 Thread Буди Романто, AreMa Inc
From: Bud 

DVB driver for Earthsoft PT3 (PCIE ISDB-S/T receiver)
-

Status: stable

Behavior: same as PT1 DVB, plus some tuning enhancements
1. in addition to the real frequency:
ISDB-S : freq. channel ID
ISDB-T : freq# (I/O# +128), ch#, ch# +64 for CATV
2. in addition to TSID:
ISDB-S : slot#

Main components:
1. SharpVA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
2. Toshiba  TC90522XBG  : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Altera   EP4CGX15BF14C8N : customized FPGA PCI bridge

Full package:
- URL:  https://github.com/knight-rider/ptx/tree/master/pt3_dvb
- buildable as standalone, DKMS or tree embedded module
- installation:
$ chmod +x dkms.install dkms.uninstall
$ ./dkms.install

Changes since last release:
- cleanups (removed unused/useless features, simple is the best)
- removed .ops.write hacks

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig   |  18 +-
 drivers/media/dvb-frontends/Makefile  |   3 +-
 drivers/media/dvb-frontends/tc90522.c | 525 ++
 drivers/media/dvb-frontends/tc90522.h |  33 +++
 drivers/media/pci/Kconfig |   2 +-
 drivers/media/pci/Makefile|   2 +-
 drivers/media/pci/pt3/Kconfig |  11 +
 drivers/media/pci/pt3/Makefile|   6 +
 drivers/media/pci/pt3/pt3_common.h|  84 ++
 drivers/media/pci/pt3/pt3_dma.c   | 332 +
 drivers/media/pci/pt3/pt3_dma.h   |  50 
 drivers/media/pci/pt3/pt3_i2c.c   | 191 +
 drivers/media/pci/pt3/pt3_i2c.h   |  25 ++
 drivers/media/pci/pt3/pt3_pci.c   | 403 ++
 drivers/media/tuners/Kconfig  |  15 +-
 drivers/media/tuners/Makefile |   2 +
 drivers/media/tuners/mxl301rf.c   | 361 +++
 drivers/media/tuners/mxl301rf.h   |  33 +++
 drivers/media/tuners/qm1d1c0042.c | 382 +
 drivers/media/tuners/qm1d1c0042.h |  33 +++
 20 files changed, 2499 insertions(+), 12 deletions(-)
 create mode 100644 drivers/media/dvb-frontends/tc90522.c
 create mode 100644 drivers/media/dvb-frontends/tc90522.h
 create mode 100644 drivers/media/pci/pt3/Kconfig
 create mode 100644 drivers/media/pci/pt3/Makefile
 create mode 100644 drivers/media/pci/pt3/pt3_common.h
 create mode 100644 drivers/media/pci/pt3/pt3_dma.c
 create mode 100644 drivers/media/pci/pt3/pt3_dma.h
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.c
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.h
 create mode 100644 drivers/media/pci/pt3/pt3_pci.c
 create mode 100644 drivers/media/tuners/mxl301rf.c
 create mode 100644 drivers/media/tuners/mxl301rf.h
 create mode 100644 drivers/media/tuners/qm1d1c0042.c
 create mode 100644 drivers/media/tuners/qm1d1c0042.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index 704403f..292694e 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -648,6 +648,15 @@ config DVB_MB86A20S
  A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator.
  Say Y when you want to support this frontend.
 
+config DVB_TC90522
+   tristate "Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S)"
+   depends on DVB_CORE && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S) demodulator
+ frontend for Earthsoft PT3 PCIE cards.
+ Say Y when you want to support this frontend.
+
 comment "Digital terrestrial only tuners/PLL"
depends on DVB_CORE
 
@@ -725,13 +734,6 @@ config DVB_A8293
depends on DVB_CORE && I2C
default m if !MEDIA_SUBDRV_AUTOSELECT
 
-config DVB_SP2
-   tristate "CIMaX SP2"
-   depends on DVB_CORE && I2C
-   default m if !MEDIA_SUBDRV_AUTOSELECT
-   help
- CIMaX SP2/SP2HF Common Interface module.
-
 config DVB_LGS8GL5
tristate "Silicon Legend LGS-8GL5 demodulator (OFDM)"
depends on DVB_CORE && I2C
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index 1e19a74..8f9a229 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -107,7 +107,6 @@ obj-$(CONFIG_DVB_DRXK) += drxk.o
 obj-$(CONFIG_DVB_TDA18271C2DD) += tda18271c2dd.o
 obj-$(CONFIG_DVB_SI2165) += si2165.o
 obj-$(CONFIG_DVB_A8293) += a8293.o
-obj-$(CONFIG_DVB

[PATCH] PT3 (tc90522, mxl301rf, qm1d1c0042) ISDB-S/T driver package

2014-09-06 Thread Буди Романто, AreMa Inc
ed.
  Since all 4 demods share the same I2C, dev_ will print

May 21 05:38:17 puma kernel: i2c i2c-7: #0 tc90522_wakeup S
May 21 05:38:17 puma kernel: i2c i2c-7: #0 tc90522_sleep S
May 21 05:38:18 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 0 frontend 0 (TC90522 ISDB-S)...
May 21 05:38:18 puma kernel: i2c i2c-7: #1 tc90522_wakeup S
May 21 05:38:18 puma kernel: i2c i2c-7: #1 tc90522_sleep S
May 21 05:38:18 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 1 frontend 0 (TC90522 ISDB-S)...
May 21 05:38:18 puma kernel: i2c i2c-7: #2 tc90522_wakeup T
May 21 05:38:18 puma kernel: i2c i2c-7: #2 tc90522_sleep T
May 21 05:38:18 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 2 frontend 0 (TC90522 ISDB-T)...
May 21 05:38:18 puma kernel: i2c i2c-7: #3 tc90522_wakeup T
May 21 05:38:19 puma kernel: i2c i2c-7: #3 tc90522_sleep T
May 21 05:38:19 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 3 frontend 0 (TC90522 ISDB-T)...

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig   |  11 +-
 drivers/media/dvb-frontends/Makefile  |   2 +
 drivers/media/dvb-frontends/tc90522.c | 512 ++
 drivers/media/dvb-frontends/tc90522.h |  33 +++
 drivers/media/pci/Kconfig |   1 +
 drivers/media/pci/Makefile|   1 +
 drivers/media/pci/pt3/Kconfig |  11 +
 drivers/media/pci/pt3/Makefile|   6 +
 drivers/media/pci/pt3/pt3_common.h|  84 ++
 drivers/media/pci/pt3/pt3_dma.c   | 333 ++
 drivers/media/pci/pt3/pt3_dma.h   |  50 
 drivers/media/pci/pt3/pt3_i2c.c   | 189 +
 drivers/media/pci/pt3/pt3_i2c.h   |  25 ++
 drivers/media/pci/pt3/pt3_pci.c   | 397 ++
 drivers/media/tuners/Kconfig  |  14 +
 drivers/media/tuners/Makefile |   2 +
 drivers/media/tuners/mxl301rf.c   | 390 ++
 drivers/media/tuners/mxl301rf.h   |  33 +++
 drivers/media/tuners/qm1d1c0042.c | 374 +
 drivers/media/tuners/qm1d1c0042.h |  33 +++
 20 files changed, 2500 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/dvb-frontends/tc90522.c
 create mode 100644 drivers/media/dvb-frontends/tc90522.h
 create mode 100644 drivers/media/pci/pt3/Kconfig
 create mode 100644 drivers/media/pci/pt3/Makefile
 create mode 100644 drivers/media/pci/pt3/pt3_common.h
 create mode 100644 drivers/media/pci/pt3/pt3_dma.c
 create mode 100644 drivers/media/pci/pt3/pt3_dma.h
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.c
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.h
 create mode 100644 drivers/media/pci/pt3/pt3_pci.c
 create mode 100644 drivers/media/tuners/mxl301rf.c
 create mode 100644 drivers/media/tuners/mxl301rf.h
 create mode 100644 drivers/media/tuners/qm1d1c0042.c
 create mode 100644 drivers/media/tuners/qm1d1c0042.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index aa5ae22..292694e 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -648,6 +648,15 @@ config DVB_MB86A20S
  A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator.
  Say Y when you want to support this frontend.
 
+config DVB_TC90522
+   tristate "Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S)"
+   depends on DVB_CORE && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S) demodulator
+ frontend for Earthsoft PT3 PCIE cards.
+ Say Y when you want to support this frontend.
+
 comment "Digital terrestrial only tuners/PLL"
depends on DVB_CORE
 
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index fc4e689..8f9a229 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -114,3 +114,5 @@ obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
 obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
+obj-$(CONFIG_DVB_TC90522) += tc90522.o
+
diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
new file mode 100644
index 000..f38fc7a
--- /dev/null
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -0,0 +1,512 @@
+/*
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator frontend 
for Earthsoft PT3
+ *
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Publi

[PATCH] PT3 (tc90522, mxl301rf, qm1d1c0042) ISDB-S/T driver package

2014-09-05 Thread Буди Романто, AreMa Inc
v_ will print

May 21 05:38:17 puma kernel: i2c i2c-7: #0 tc90522_wakeup S
May 21 05:38:17 puma kernel: i2c i2c-7: #0 tc90522_sleep S
May 21 05:38:18 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 0 frontend 0 (TC90522 ISDB-S)...
May 21 05:38:18 puma kernel: i2c i2c-7: #1 tc90522_wakeup S
May 21 05:38:18 puma kernel: i2c i2c-7: #1 tc90522_sleep S
May 21 05:38:18 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 1 frontend 0 (TC90522 ISDB-S)...
May 21 05:38:18 puma kernel: i2c i2c-7: #2 tc90522_wakeup T
May 21 05:38:18 puma kernel: i2c i2c-7: #2 tc90522_sleep T
May 21 05:38:18 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 2 frontend 0 (TC90522 ISDB-T)...
May 21 05:38:18 puma kernel: i2c i2c-7: #3 tc90522_wakeup T
May 21 05:38:19 puma kernel: i2c i2c-7: #3 tc90522_sleep T
May 21 05:38:19 puma kernel: pt3_dvb :03:00.0: DVB: registering
adapter 3 frontend 0 (TC90522 ISDB-T)...

Signed-off-by: Буди Романто, AreMa Inc 
---
 drivers/media/dvb-frontends/Kconfig   |  11 +-
 drivers/media/dvb-frontends/Makefile  |   2 +
 drivers/media/dvb-frontends/tc90522.c | 512 ++
 drivers/media/dvb-frontends/tc90522.h |  33 +++
 drivers/media/pci/Kconfig |   1 +
 drivers/media/pci/Makefile|   1 +
 drivers/media/pci/pt3/Kconfig |  11 +
 drivers/media/pci/pt3/Makefile|   6 +
 drivers/media/pci/pt3/pt3_common.h|  84 ++
 drivers/media/pci/pt3/pt3_dma.c   | 333 ++
 drivers/media/pci/pt3/pt3_dma.h   |  50 
 drivers/media/pci/pt3/pt3_i2c.c   | 189 +
 drivers/media/pci/pt3/pt3_i2c.h   |  25 ++
 drivers/media/pci/pt3/pt3_pci.c   | 397 ++
 drivers/media/tuners/Kconfig  |  14 +
 drivers/media/tuners/Makefile |   2 +
 drivers/media/tuners/mxl301rf.c   | 390 ++
 drivers/media/tuners/mxl301rf.h   |  33 +++
 drivers/media/tuners/qm1d1c0042.c | 374 +
 drivers/media/tuners/qm1d1c0042.h |  33 +++
 20 files changed, 2500 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/dvb-frontends/tc90522.c
 create mode 100644 drivers/media/dvb-frontends/tc90522.h
 create mode 100644 drivers/media/pci/pt3/Kconfig
 create mode 100644 drivers/media/pci/pt3/Makefile
 create mode 100644 drivers/media/pci/pt3/pt3_common.h
 create mode 100644 drivers/media/pci/pt3/pt3_dma.c
 create mode 100644 drivers/media/pci/pt3/pt3_dma.h
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.c
 create mode 100644 drivers/media/pci/pt3/pt3_i2c.h
 create mode 100644 drivers/media/pci/pt3/pt3_pci.c
 create mode 100644 drivers/media/tuners/mxl301rf.c
 create mode 100644 drivers/media/tuners/mxl301rf.h
 create mode 100644 drivers/media/tuners/qm1d1c0042.c
 create mode 100644 drivers/media/tuners/qm1d1c0042.h

diff --git a/drivers/media/dvb-frontends/Kconfig 
b/drivers/media/dvb-frontends/Kconfig
index aa5ae22..292694e 100644
--- a/drivers/media/dvb-frontends/Kconfig
+++ b/drivers/media/dvb-frontends/Kconfig
@@ -621,7 +621,7 @@ config DVB_S5H1411
  An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
  to support this frontend.
 
-comment "ISDB-T (terrestrial) frontends"
+comment "ISDB-S (satellite) & ISDB-T (terrestrial) frontends"
depends on DVB_CORE
 
 config DVB_S921
@@ -648,6 +648,15 @@ config DVB_MB86A20S
  A driver for Fujitsu mb86a20s ISDB-T/ISDB-Tsb demodulator.
  Say Y when you want to support this frontend.
 
+config DVB_TC90522
+   tristate "Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S)"
+   depends on DVB_CORE && I2C
+   default m if !MEDIA_SUBDRV_AUTOSELECT
+   help
+ Toshiba TC90522XBG OFDM(ISDB-T)/8PSK(ISDB-S) demodulator
+ frontend for Earthsoft PT3 PCIE cards.
+ Say Y when you want to support this frontend.
+
 comment "Digital terrestrial only tuners/PLL"
depends on DVB_CORE
 
diff --git a/drivers/media/dvb-frontends/Makefile 
b/drivers/media/dvb-frontends/Makefile
index fc4e689..8f9a229 100644
--- a/drivers/media/dvb-frontends/Makefile
+++ b/drivers/media/dvb-frontends/Makefile
@@ -114,3 +114,5 @@ obj-$(CONFIG_DVB_RTL2832_SDR) += rtl2832_sdr.o
 obj-$(CONFIG_DVB_M88RS2000) += m88rs2000.o
 obj-$(CONFIG_DVB_AF9033) += af9033.o
 obj-$(CONFIG_DVB_AS102_FE) += as102_fe.o
+obj-$(CONFIG_DVB_TC90522) += tc90522.o
+
diff --git a/drivers/media/dvb-frontends/tc90522.c 
b/drivers/media/dvb-frontends/tc90522.c
new file mode 100644
index 000..f38fc7a
--- /dev/null
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -0,0 +1,512 @@
+/*
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator frontend 
for Earthsoft PT3
+ *
+ * Copyright (C) 2014 Budi Rachmanto, AreMa Inc. 
+ *
+ * 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