Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1370774 > unrolled thread
| Started by | info@are.ma |
|---|---|
| First post | 2016-04-04 19:10 +0200 |
| Last post | 2016-04-04 19:10 +0200 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[media 0/6] DVB driver for Earthsoft PT3, PLEX PX-Q3PE ISDB-S/T PCIE cards & PX-BCUD ISDB-S USB dongle info@are.ma - 2016-04-04 19:10 +0200
[media 1/6] Raise adapter number limit info@are.ma - 2016-04-04 19:10 +0200
[media 6/6] Bridge driver for PLEX PX-BCUD ISDB-S USB dongle info@are.ma - 2016-04-04 19:10 +0200
[media 3/6] Demodulator for Earthsoft PT3, PLEX PX-Q3PE ISDB-S/T PCIE cards & PX-BCUD ISDB-S USB dongle info@are.ma - 2016-04-04 19:10 +0200
| From | info@are.ma |
|---|---|
| Date | 2016-04-04 19:10 +0200 |
| Subject | [media 0/6] DVB driver for Earthsoft PT3, PLEX PX-Q3PE ISDB-S/T PCIE cards & PX-BCUD ISDB-S USB dongle |
| Message-ID | <rkgaJ-6mK-19@gated-at.bofh.it> |
From: Буди Романто, AreMa Inc <knightrider@are.ma>
DVB driver for Earthsoft PT3, PLEX PX-Q3PE ISDB-S/T PCIE cards & PX-BCUD ISDB-S USB dongle
==========================================================================================
Status: stable
Features:
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#
Supported Cards & Main components:
A. EarthSoft PT3:
1. Altera EP4CGX15BF14C8N : customized FPGA PCI bridge
2. Toshiba TC90522XBG : quad demodulator (2ch OFDM + 2ch 8PSK)
3. Sharp VA4M6JC2103 : contains 2 ISDB-S + 2 ISDB-T tuners
ISDB-S : Sharp QM1D1C0042 RF-IC, chip ver. 0x48
ISDB-T : MaxLinear CMOS Hybrid TV MxL301RF
B. PLEX PX-Q3PE:
1. ASICEN ASV5220 : PCI-E bridge
2. Toshiba TC90522XBG : quad demodulator (2ch OFDM + 2ch 8PSK)
3. NXP Semiconductors TDA20142 : ISDB-S tuner
4. Newport Media NM120 : ISDB-T tuner
5. ASICEN ASIE5606X8 : crypting controller
C. PLEX PX-BCUD (ISDB-S USB dongle)
1. Empia EM28178 : USB I/F (courtesy of Nagahama Satoshi)
2. Toshiba TC90532 : demodulator (using TC90522 driver)
3. Sharp QM1D1C0045_2 : ISDB-S RF-IC, chip ver. 0x68
Notes:
This is a complex but smartly polished driver package containing 2 (dual head)
PCI-E bridge I/F drivers, single demodulator frontend, and 4 (quad tail) tuner drivers,
plus, simplified Nagahama's patch for PLEX PX-BCUD (ISDB-S USB dongle).
Generic registration related procedures (subdevices, frontend, etc.) summarized in
ptx_common.c are very useful also for other DVB drivers, and would be very handy if
inserted into the core (e.g. dvb_frontend.c & dvb_frontend.h).
For example, currently, the entity of struct dvb_frontend is created sometimes in
demodulators, some in tuners, or even in the parent (bridge) drivers. IMHO, this entity
should be provided by dvb_core. ptx_register_fe() included in ptx_common.c simplifies
the tasks and in fact, significantly reduces coding & kernel size.
Also, currently dvb_frontend's .demodulator_priv & .tuner_priv are of type (void *).
These should be changed to (struct i2c_client *), IMHO. Private data for demodulator
or tuner should be attached under i2c_client, using i2c_set_clientdata() for instance.
FILENAME SUPPORTED CHIPS
======== ===============
tc90522.c TC90522XBG, TC90532XBG,...
tda2014x.c TDA20142
qm1d1c004x.c QM1D1C0042, QM1D1C0045, QM1D1C0045_2
nm131.c NM131, NM130, NM120
mxl301rf.c MxL301RF
pt3_pci.c EP4CGX15BF14C8N
pxq3pe_pci.c ASV5220
Full package:
- URL: https://github.com/knight-rider/ptx
Буди Романто, AreMa Inc (6):
Raise adapter number limit
drop backstabbing drivers
Demodulator for Earthsoft PT3, PLEX PX-Q3PE ISDB-S/T PCIE cards &
PX-BCUD ISDB-S USB dongle
Tuners for Earthsoft PT3, PLEX PX-Q3PE ISDB-S/T PCIE cards & PX-BCUD
ISDB-S USB dongle
PCIE bridge driver for PT3 & PX-Q3PE
Bridge driver for PLEX PX-BCUD ISDB-S USB dongle
drivers/media/Kconfig | 5 +-
drivers/media/dvb-core/Kconfig | 4 +-
drivers/media/dvb-core/dvbdev.h | 2 +-
drivers/media/dvb-frontends/tc90522.c | 964 +++++++-------------------------
drivers/media/dvb-frontends/tc90522.h | 36 +-
drivers/media/pci/Kconfig | 2 +-
drivers/media/pci/Makefile | 2 +-
drivers/media/pci/pt3/Kconfig | 10 -
drivers/media/pci/pt3/Makefile | 8 -
drivers/media/pci/pt3/pt3.c | 874 -----------------------------
drivers/media/pci/pt3/pt3.h | 186 ------
drivers/media/pci/pt3/pt3_dma.c | 225 --------
drivers/media/pci/pt3/pt3_i2c.c | 240 --------
drivers/media/pci/ptx/Kconfig | 23 +
drivers/media/pci/ptx/Makefile | 6 +
drivers/media/pci/ptx/pt3.c | 426 ++++++++++++++
drivers/media/pci/ptx/ptx_common.c | 266 +++++++++
drivers/media/pci/ptx/ptx_common.h | 76 +++
drivers/media/pci/ptx/pxq3pe.c | 585 +++++++++++++++++++
drivers/media/tuners/Kconfig | 21 +-
drivers/media/tuners/Makefile | 4 +-
drivers/media/tuners/mxl301rf.c | 471 ++++++----------
drivers/media/tuners/mxl301rf.h | 19 +-
drivers/media/tuners/nm131.c | 248 ++++++++
drivers/media/tuners/nm131.h | 13 +
drivers/media/tuners/qm1d1c0042.c | 448 ---------------
drivers/media/tuners/qm1d1c0042.h | 37 --
drivers/media/tuners/qm1d1c004x.c | 242 ++++++++
drivers/media/tuners/qm1d1c004x.h | 23 +
drivers/media/tuners/tda2014x.c | 358 ++++++++++++
drivers/media/tuners/tda2014x.h | 13 +
drivers/media/usb/em28xx/Kconfig | 3 +
drivers/media/usb/em28xx/Makefile | 1 +
drivers/media/usb/em28xx/em28xx-cards.c | 27 +
drivers/media/usb/em28xx/em28xx-dvb.c | 81 ++-
drivers/media/usb/em28xx/em28xx.h | 1 +
36 files changed, 2794 insertions(+), 3156 deletions(-)
delete mode 100644 drivers/media/pci/pt3/Kconfig
delete mode 100644 drivers/media/pci/pt3/Makefile
delete mode 100644 drivers/media/pci/pt3/pt3.c
delete mode 100644 drivers/media/pci/pt3/pt3.h
delete mode 100644 drivers/media/pci/pt3/pt3_dma.c
delete mode 100644 drivers/media/pci/pt3/pt3_i2c.c
create mode 100644 drivers/media/pci/ptx/Kconfig
create mode 100644 drivers/media/pci/ptx/Makefile
create mode 100644 drivers/media/pci/ptx/pt3.c
create mode 100644 drivers/media/pci/ptx/ptx_common.c
create mode 100644 drivers/media/pci/ptx/ptx_common.h
create mode 100644 drivers/media/pci/ptx/pxq3pe.c
create mode 100644 drivers/media/tuners/nm131.c
create mode 100644 drivers/media/tuners/nm131.h
delete mode 100644 drivers/media/tuners/qm1d1c0042.c
delete mode 100644 drivers/media/tuners/qm1d1c0042.h
create mode 100644 drivers/media/tuners/qm1d1c004x.c
create mode 100644 drivers/media/tuners/qm1d1c004x.h
create mode 100644 drivers/media/tuners/tda2014x.c
create mode 100644 drivers/media/tuners/tda2014x.h
--
2.7.4
[toc] | [next] | [standalone]
| From | info@are.ma |
|---|---|
| Date | 2016-04-04 19:10 +0200 |
| Subject | [media 1/6] Raise adapter number limit |
| Message-ID | <rkgaK-6mK-43@gated-at.bofh.it> |
| In reply to | #1370774 |
From: Буди Романто, AreMa Inc <knightrider@are.ma> The current limit is too low for latest cards with 8+ tuners on a single slot. IMHO, the most appropriate minimum default is 16. Signed-off-by: Буди Романто, AreMa Inc <knightrider@are.ma> --- drivers/media/dvb-core/Kconfig | 4 ++-- drivers/media/dvb-core/dvbdev.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/dvb-core/Kconfig b/drivers/media/dvb-core/Kconfig index fa7a249..91732a9 100644 --- a/drivers/media/dvb-core/Kconfig +++ b/drivers/media/dvb-core/Kconfig @@ -5,7 +5,7 @@ config DVB_MAX_ADAPTERS int "maximum number of DVB/ATSC adapters" depends on DVB_CORE - default 8 + default 16 range 1 255 help Maximum number of DVB/ATSC adapters. Increasing this number @@ -13,7 +13,7 @@ config DVB_MAX_ADAPTERS if a much lower number of DVB/ATSC adapters is present. Only values in the range 4-32 are tested. - If you are unsure about this, use the default value 8 + If you are unsure about this, use the default value 16 config DVB_DYNAMIC_MINORS bool "Dynamic DVB minor allocation" diff --git a/drivers/media/dvb-core/dvbdev.h b/drivers/media/dvb-core/dvbdev.h index 4aff7bd..ae4e0a2 100644 --- a/drivers/media/dvb-core/dvbdev.h +++ b/drivers/media/dvb-core/dvbdev.h @@ -34,7 +34,7 @@ #if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0 #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS #else - #define DVB_MAX_ADAPTERS 8 + #define DVB_MAX_ADAPTERS 16 #endif #define DVB_UNSET (-1) -- 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | info@are.ma |
|---|---|
| Date | 2016-04-04 19:10 +0200 |
| Subject | [media 6/6] Bridge driver for PLEX PX-BCUD ISDB-S USB dongle |
| Message-ID | <rkgaL-6mK-49@gated-at.bofh.it> |
| In reply to | #1370774 |
From: Буди Романто, AreMa Inc <knightrider@are.ma>
Support for PLEX PX-BCUD (ISDB-S usb dongle)
Nagahama's patch simplified...
Signed-off-by: Буди Романто, AreMa Inc <knightrider@are.ma>
---
drivers/media/Kconfig | 5 +-
drivers/media/usb/em28xx/Kconfig | 3 ++
drivers/media/usb/em28xx/Makefile | 1 +
drivers/media/usb/em28xx/em28xx-cards.c | 27 +++++++++++
drivers/media/usb/em28xx/em28xx-dvb.c | 81 ++++++++++++++++++++++++++++++++-
drivers/media/usb/em28xx/em28xx.h | 1 +
6 files changed, 115 insertions(+), 3 deletions(-)
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index a8518fb..37fae59 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -149,7 +149,10 @@ config DVB_NET
You may want to disable the network support on embedded devices. If
unsure say Y.
-# This Kconfig option is used by both PCI and USB drivers
+# Options used by both PCI and USB drivers
+config DVB_PTX_COMMON
+ tristate
+
config TTPCI_EEPROM
tristate
depends on I2C
diff --git a/drivers/media/usb/em28xx/Kconfig b/drivers/media/usb/em28xx/Kconfig
index e382210..fc19edc 100644
--- a/drivers/media/usb/em28xx/Kconfig
+++ b/drivers/media/usb/em28xx/Kconfig
@@ -59,6 +59,9 @@ config VIDEO_EM28XX_DVB
select DVB_DRX39XYJ if MEDIA_SUBDRV_AUTOSELECT
select DVB_SI2168 if MEDIA_SUBDRV_AUTOSELECT
select MEDIA_TUNER_SI2157 if MEDIA_SUBDRV_AUTOSELECT
+ select DVB_PTX_COMMON
+ select DVB_TC90522 if MEDIA_SUBDRV_AUTOSELECT
+ select MEDIA_TUNER_QM1D1C004X if MEDIA_SUBDRV_AUTOSELECT
---help---
This adds support for DVB cards based on the
Empiatech em28xx chips.
diff --git a/drivers/media/usb/em28xx/Makefile b/drivers/media/usb/em28xx/Makefile
index 3f850d5..1488829 100644
--- a/drivers/media/usb/em28xx/Makefile
+++ b/drivers/media/usb/em28xx/Makefile
@@ -14,3 +14,4 @@ ccflags-y += -Idrivers/media/i2c
ccflags-y += -Idrivers/media/tuners
ccflags-y += -Idrivers/media/dvb-core
ccflags-y += -Idrivers/media/dvb-frontends
+ccflags-y += -Idrivers/media/pci/ptx
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index 930e3e3..772a8f8 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -492,6 +492,20 @@ static struct em28xx_reg_seq terratec_t2_stick_hd[] = {
{-1, -1, -1, -1},
};
+static struct em28xx_reg_seq plex_px_bcud[] = {
+ {EM2874_R80_GPIO_P0_CTRL, 0xff, 0xff, 0},
+ {0x0d, 0xff, 0xff, 0},
+ {EM2874_R50_IR_CONFIG, 0x01, 0xff, 0},
+ {EM28XX_R06_I2C_CLK, 0x40, 0xff, 0},
+ {EM2874_R80_GPIO_P0_CTRL, 0xfd, 0xff, 100},
+ {EM28XX_R12_VINENABLE, 0x20, 0x20, 0},
+ {0x0d, 0x42, 0xff, 1000},
+ {EM2874_R80_GPIO_P0_CTRL, 0xfc, 0xff, 10},
+ {EM2874_R80_GPIO_P0_CTRL, 0xfd, 0xff, 10},
+ {0x73, 0xfd, 0xff, 100},
+ {-1, -1, -1, -1},
+};
+
/*
* Button definitions
*/
@@ -2306,6 +2320,17 @@ struct em28xx_board em28xx_boards[] = {
.has_dvb = 1,
.ir_codes = RC_MAP_TERRATEC_SLIM_2,
},
+ /* 3275:0085 PLEX PX-BCUD.
+ * Empia EM28178, TOSHIBA TC90532XBG, Sharp QM1D1C0042 */
+ [EM28178_BOARD_PLEX_PX_BCUD] = {
+ .name = "PLEX PX-BCUD",
+ .xclk = EM28XX_XCLK_FREQUENCY_4_3MHZ,
+ .def_i2c_bus = 1,
+ .i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE,
+ .tuner_type = TUNER_ABSENT,
+ .tuner_gpio = plex_px_bcud,
+ .has_dvb = 1,
+ },
};
EXPORT_SYMBOL_GPL(em28xx_boards);
@@ -2495,6 +2520,8 @@ struct usb_device_id em28xx_id_table[] = {
.driver_info = EM2861_BOARD_LEADTEK_VC100 },
{ USB_DEVICE(0xeb1a, 0x8179),
.driver_info = EM28178_BOARD_TERRATEC_T2_STICK_HD },
+ { USB_DEVICE(0x3275, 0x0085),
+ .driver_info = EM28178_BOARD_PLEX_PX_BCUD },
{ },
};
MODULE_DEVICE_TABLE(usb, em28xx_id_table);
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 5d209c7..c45112e 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -12,6 +12,10 @@
(c) 2012 Frank Schäfer <fschaefer.oss@googlemail.com>
+ (c) 2016 Nagahama Satoshi <sattnag@aim.com>
+ Budi Rachmanto, AreMa Inc. <info@are.ma>
+ - PLEX PX-BCUD support
+
Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by:
(c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
(c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
@@ -25,11 +29,10 @@
#include <linux/slab.h>
#include <linux/usb.h>
+#include "ptx_common.h"
#include "em28xx.h"
#include <media/v4l2-common.h>
-#include <dvb_demux.h>
#include <dvb_net.h>
-#include <dmxdev.h>
#include <media/tuner.h>
#include "tuner-simple.h"
#include <linux/gpio.h>
@@ -58,6 +61,8 @@
#include "ts2020.h"
#include "si2168.h"
#include "si2157.h"
+#include "tc90522.h"
+#include "qm1d1c004x.h"
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>");
MODULE_LICENSE("GPL");
@@ -787,6 +792,65 @@ static int em28xx_mt352_terratec_xs_init(struct dvb_frontend *fe)
return 0;
}
+static void px_bcud_init(struct em28xx *dev)
+{
+ int i;
+ struct {
+ unsigned char r[4];
+ int len;
+ } regs1[] = {
+ {{ 0x0e, 0x77 }, 2},
+ {{ 0x0f, 0x77 }, 2},
+ {{ 0x03, 0x90 }, 2},
+ }, regs2[] = {
+ {{ 0x07, 0x01 }, 2},
+ {{ 0x08, 0x10 }, 2},
+ {{ 0x13, 0x00 }, 2},
+ {{ 0x17, 0x00 }, 2},
+ {{ 0x03, 0x01 }, 2},
+ {{ 0x10, 0xb1 }, 2},
+ {{ 0x11, 0x40 }, 2},
+ {{ 0x85, 0x7a }, 2},
+ {{ 0x87, 0x04 }, 2},
+ };
+ static struct em28xx_reg_seq gpio[] = {
+ {EM28XX_R06_I2C_CLK, 0x40, 0xff, 300},
+ {EM2874_R80_GPIO_P0_CTRL, 0xfd, 0xff, 60},
+ {EM28XX_R15_RGAIN, 0x20, 0xff, 0},
+ {EM28XX_R16_GGAIN, 0x20, 0xff, 0},
+ {EM28XX_R17_BGAIN, 0x20, 0xff, 0},
+ {EM28XX_R18_ROFFSET, 0x00, 0xff, 0},
+ {EM28XX_R19_GOFFSET, 0x00, 0xff, 0},
+ {EM28XX_R1A_BOFFSET, 0x00, 0xff, 0},
+ {EM28XX_R23_UOFFSET, 0x00, 0xff, 0},
+ {EM28XX_R24_VOFFSET, 0x00, 0xff, 0},
+ {EM28XX_R26_COMPR, 0x00, 0xff, 0},
+ {0x13, 0x08, 0xff, 0},
+ {EM28XX_R12_VINENABLE, 0x27, 0xff, 0},
+ {EM28XX_R0C_USBSUSP, 0x10, 0xff, 0},
+ {EM28XX_R27_OUTFMT, 0x00, 0xff, 0},
+ {EM28XX_R10_VINMODE, 0x00, 0xff, 0},
+ {EM28XX_R11_VINCTRL, 0x11, 0xff, 0},
+ {EM2874_R50_IR_CONFIG, 0x01, 0xff, 0},
+ {EM2874_R5F_TS_ENABLE, 0x80, 0xff, 0},
+ {EM28XX_R06_I2C_CLK, 0x46, 0xff, 0},
+ };
+ em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x46);
+ /* sleeping ISDB-T */
+ dev->dvb->i2c_client_demod->addr = 0x14;
+ for (i = 0; i < ARRAY_SIZE(regs1); i++)
+ i2c_master_send(dev->dvb->i2c_client_demod, regs1[i].r, regs1[i].len);
+ /* sleeping ISDB-S */
+ dev->dvb->i2c_client_demod->addr = 0x15;
+ for (i = 0; i < ARRAY_SIZE(regs2); i++)
+ i2c_master_send(dev->dvb->i2c_client_demod, regs2[i].r, regs2[i].len);
+ for (i = 0; i < ARRAY_SIZE(gpio); i++) {
+ em28xx_write_reg_bits(dev, gpio[i].reg, gpio[i].val, gpio[i].mask);
+ if (gpio[i].sleep > 0)
+ msleep(gpio[i].sleep);
+ }
+};
+
static struct mt352_config terratec_xs_mt352_cfg = {
.demod_address = (0x1e >> 1),
.no_tuner = 1,
@@ -1762,6 +1826,19 @@ static int em28xx_dvb_init(struct em28xx *dev)
dvb->i2c_client_tuner = client;
}
break;
+ case EM28178_BOARD_PLEX_PX_BCUD:
+ {
+ struct ptx_subdev_info pxbcud_subdev_info =
+ {SYS_ISDBS, 0x15, TC90522_MODNAME, 0x61, QM1D1C004X_MODNAME};
+
+ dvb->fe[0] = ptx_register_fe(&dev->i2c_adap[dev->def_i2c_bus], NULL, &pxbcud_subdev_info);
+ if (!dvb->fe[0])
+ goto out_free;
+ dvb->i2c_client_demod = dvb->fe[0]->demodulator_priv;
+ dvb->i2c_client_tuner = dvb->fe[0]->tuner_priv;
+ px_bcud_init(dev);
+ }
+ break;
default:
em28xx_errdev("/2: The frontend of your DVB/ATSC card"
" isn't supported yet\n");
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 2674449..9ad1240 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -145,6 +145,7 @@
#define EM2861_BOARD_LEADTEK_VC100 95
#define EM28178_BOARD_TERRATEC_T2_STICK_HD 96
#define EM2884_BOARD_ELGATO_EYETV_HYBRID_2008 97
+#define EM28178_BOARD_PLEX_PX_BCUD 98
/* Limits minimum and default number of buffers */
#define EM28XX_MIN_BUF 4
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | info@are.ma |
|---|---|
| Date | 2016-04-04 19:10 +0200 |
| Subject | [media 3/6] Demodulator for Earthsoft PT3, PLEX PX-Q3PE ISDB-S/T PCIE cards & PX-BCUD ISDB-S USB dongle |
| Message-ID | <rkgaM-6mK-55@gated-at.bofh.it> |
| In reply to | #1370774 |
From: Буди Романто, AreMa Inc <knightrider@are.ma>
Toshiba TC905xx demodulator driver for PT3, PX-Q3PE & PX-BCUD
Signed-off-by: Буди Романто, AreMa Inc <knightrider@are.ma>
---
drivers/media/dvb-frontends/tc90522.c | 254 ++++++++++++++++++++++++++++++++++
drivers/media/dvb-frontends/tc90522.h | 18 +++
2 files changed, 272 insertions(+)
create mode 100644 drivers/media/dvb-frontends/tc90522.c
create mode 100644 drivers/media/dvb-frontends/tc90522.h
diff --git a/drivers/media/dvb-frontends/tc90522.c b/drivers/media/dvb-frontends/tc90522.c
new file mode 100644
index 0000000..c1c48e5
--- /dev/null
+++ b/drivers/media/dvb-frontends/tc90522.c
@@ -0,0 +1,254 @@
+/*
+ Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator
+
+ Copyright (C) Budi Rachmanto, AreMa Inc. <info@are.ma>
+
+ CHIP CARDS
+ TC90522XBG Earthsoft PT3, PLEX PX-Q3PE
+ TC90532 PLEX PX-BCUD
+
+ 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 "dvb_frontend.h"
+#include "tc90522.h"
+
+bool tc90522_r(struct i2c_client *d, u8 slvadr, u8 *buf, u8 len)
+{
+ struct i2c_msg msg[] = {
+ {.addr = d->addr, .flags = 0, .buf = &slvadr, .len = 1,},
+ {.addr = d->addr, .flags = I2C_M_RD, .buf = buf, .len = len,},
+ };
+ return i2c_transfer(d->adapter, msg, 2) == 2;
+}
+
+bool tc90522_w(struct i2c_client *d, u8 slvadr, u8 dat)
+{
+ u8 buf[] = {slvadr, dat};
+ struct i2c_msg msg[] = {
+ {.addr = d->addr, .flags = 0, .buf = buf, .len = 2,},
+ };
+ return i2c_transfer(d->adapter, msg, 1) == 1;
+}
+
+u64 tc90522_n2int(const u8 *data, u8 n) /* convert n_bytes data from stream (network byte order) to integer */
+{ /* can't use <arpa/inet.h>'s ntoh*() as sometimes n = 3,5,... */
+ u32 i, val = 0;
+
+ for (i = 0; i < n; i++) {
+ val <<= 8;
+ val |= data[i];
+ }
+ return val;
+}
+
+int tc90522_cn_raw(struct dvb_frontend *fe, u16 *raw) /* for DVBv3 compatibility */
+{
+ u8 buf[3],
+ len = fe->dtv_property_cache.delivery_system == SYS_ISDBS ? 2 : 3,
+ adr = fe->dtv_property_cache.delivery_system == SYS_ISDBS ? 0xbc : 0x8b;
+ bool ok = tc90522_r(fe->demodulator_priv, adr, buf, len);
+ int cn = tc90522_n2int(buf, len);
+
+ if (!ok)
+ return -EIO;
+ *raw = cn;
+ return cn;
+}
+
+int tc90522_status(struct dvb_frontend *fe, enum fe_status *stat)
+{
+ enum fe_status *festat = i2c_get_clientdata(fe->demodulator_priv);
+ struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+ u16 v16;
+ s64 raw = tc90522_cn_raw(fe, &v16),
+ x,
+ y;
+
+ s64 cn_s(void) /* @ .0001 dB */
+ {
+ raw -= 3000;
+ if (raw < 0)
+ raw = 0;
+ x = int_sqrt(raw << 20);
+ y = 16346ll * x - (143410ll << 16);
+ y = ((x * y) >> 16) + (502590ll << 16);
+ y = ((x * y) >> 16) - (889770ll << 16);
+ y = ((x * y) >> 16) + (895650ll << 16);
+ y = (588570ll << 16) - ((x * y) >> 16);
+ return y < 0 ? 0 : y >> 16;
+ }
+
+ s64 cn_t(void) /* @ .0001 dB */
+ {
+ if (!raw)
+ return 0;
+ x = (1130911733ll - 10ll * intlog10(raw)) >> 2;
+ y = (x >> 2) - (x >> 6) + (x >> 8) + (x >> 9) - (x >> 10) + (x >> 11) + (x >> 12) - (16ll << 22);
+ y = ((x * y) >> 22) + (398ll << 22);
+ y = ((x * y) >> 22) + (5491ll << 22);
+ y = ((x * y) >> 22) + (30965ll << 22);
+ return y >> 22;
+ }
+
+ c->cnr.len = 1;
+ c->cnr.stat[0].svalue = fe->dtv_property_cache.delivery_system == SYS_ISDBS ? cn_s() : cn_t();
+ c->cnr.stat[0].scale = FE_SCALE_DECIBEL;
+ *stat = *festat;
+ return *festat;
+}
+
+int tc90522_get_frontend_algo(struct dvb_frontend *fe)
+{
+ return DVBFE_ALGO_HW;
+}
+
+int tc90522_tune(struct dvb_frontend *fe, bool retune, u32 mode_flags, u32 *delay, enum fe_status *stat)
+{
+ u32 fno2kHz(u32 fno)
+ {
+ if (fno < 12)
+ return 1049480 + 38360 * fno; /* BS */
+ else if (fno < 24)
+ return 1613000 + 40000 * (fno - 12); /* CS110 right */
+ return 1593000 + 40000 * (fno - 24); /* CS110 left */
+ }
+
+ void s_kHz(u32 *f)
+ {
+ *f = *f > 3000000 ? fno2kHz(14) : /* max kHz, CNN */
+ *f >= 1049480 ? *f : /* min real kHz */
+ *f > 48 ? fno2kHz(4) : /* BS11 etc. */
+ fno2kHz(*f - 1);
+ }
+
+ u32 fno2Hz(u32 fno)
+ {
+ return (fno > 112 ? 557 : 93 + 6 * fno + (fno < 12 ? 0 : fno < 17 ? 2 : fno < 63 ? 0 : 2)) * 1000000 + 142857;
+ }
+
+ void t_Hz(u32 *f)
+ {
+ *f = *f >= 90000000 ? *f : /* real_freq Hz */
+ *f > 255 ? fno2Hz(77) : /* NHK */
+ *f > 127 ? fno2Hz(*f - 128) : /* freqno (IO#) */
+ *f > 63 ? (*f -= 64, /* CATV */
+ *f > 22 ? fno2Hz(*f - 1) : /* C23-C62 */
+ *f > 12 ? fno2Hz(*f - 10) : /* C13-C22 */
+ fno2Hz(77)) :
+ *f > 62 ? fno2Hz(77) :
+ *f > 12 ? fno2Hz(*f + 50) : /* 13-62 */
+ *f > 3 ? fno2Hz(*f + 9) : /* 4-12 */
+ *f ? fno2Hz(*f - 1) : /* 1-3 */
+ fno2Hz(77);
+ }
+ struct i2c_client *d = fe->demodulator_priv;
+ enum fe_status *festat = i2c_get_clientdata(d);
+ u16 set_id = fe->dtv_property_cache.stream_id,
+ i = 999;
+ u8 data[16];
+
+ if (!retune) /* once is enough */
+ return 0;
+ *festat = 0;
+ if (fe->dtv_property_cache.delivery_system == SYS_ISDBT)
+ goto ISDBT;
+
+ s_kHz(&fe->dtv_property_cache.frequency);
+ if (fe->ops.tuner_ops.set_params(fe))
+ return -EIO;
+ while (i--) {
+ if ((tc90522_r(d, 0xC3, data, 1), !(data[0] & 0x10)) && /* locked */
+ (tc90522_r(d, 0xCE, data, 2), *(u16 *)data != 0) && /* valid TSID */
+ tc90522_r(d, 0xC3, data, 1) &&
+ tc90522_r(d, 0xCE, data, 16))
+ break;
+ msleep_interruptible(5);
+ }
+ if (!i)
+ goto ERR;
+ for (i = 0; i < 8; i++) {
+ u16 tsid = tc90522_n2int(data + i*2, 2);
+
+ if ((tsid == set_id || set_id == i) &&
+ tc90522_w(d, 0x8F, tsid >> 8) &&
+ tc90522_w(d, 0x90, tsid & 0xFF) &&
+ tc90522_r(d, 0xE6, data, 2) &&
+ tc90522_n2int(data, 2) == tsid)
+ goto LOCK;
+ }
+ goto ERR;
+ISDBT:
+ t_Hz(&fe->dtv_property_cache.frequency);
+ if (fe->ops.tuner_ops.set_params(fe))
+ return -EIO;
+ while (i--) {
+ bool retryov,
+ lock0,
+ lock1;
+ if (!tc90522_r(d, 0x80, data, 1) || !tc90522_r(d, 0xB0, data + 1, 1))
+ break;
+ retryov = data[0] & 0b10000000 ? true : false;
+ lock0 = data[0] & 0b00001000 ? false : true;
+ lock1 = data[1] & 0b00001000 ? true : false;
+ if (lock0 && lock1) {
+LOCK:
+ *festat = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_LOCK;
+ *stat = *festat;
+ return 0;
+ }
+ if (retryov)
+ break;
+ msleep_interruptible(1);
+ }
+ERR:
+ *stat = *festat;
+ return -ETIMEDOUT;
+}
+
+static struct dvb_frontend_ops tc90522_ops = {
+ .info = {
+ .name = TC90522_MODNAME,
+ .caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_AUTO | FE_CAN_QAM_AUTO | FE_CAN_MULTISTREAM |
+ FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_HIERARCHY_AUTO,
+ .frequency_min = 1, /* actual limit settings are set by .tune */
+ .frequency_max = 770000000,
+ },
+ .get_frontend_algo = tc90522_get_frontend_algo,
+ .read_snr = tc90522_cn_raw,
+ .read_status = tc90522_status,
+ .tune = tc90522_tune,
+};
+
+int tc90522_probe(struct i2c_client *d, const struct i2c_device_id *id)
+{
+ struct dvb_frontend *fe = d->dev.platform_data;
+ static enum fe_status festat;
+
+ memcpy(&fe->ops, &tc90522_ops, sizeof(struct dvb_frontend_ops));
+ festat = 0;
+ i2c_set_clientdata(d, &festat);
+ return 0;
+}
+
+static struct i2c_device_id tc90522_id[] = {
+ {TC90522_MODNAME, 0},
+ {},
+};
+MODULE_DEVICE_TABLE(i2c, tc90522_id);
+
+static struct i2c_driver tc90522_driver = {
+ .driver.name = tc90522_id->name,
+ .probe = tc90522_probe,
+ .id_table = tc90522_id,
+};
+module_i2c_driver(tc90522_driver);
+
+MODULE_AUTHOR("Budi Rachmanto, AreMa Inc. <knightrider(@)are.ma>");
+MODULE_DESCRIPTION("Toshiba TC90522 8PSK(ISDB-S)/OFDM(ISDB-T) quad demodulator");
+MODULE_LICENSE("GPL");
+
diff --git a/drivers/media/dvb-frontends/tc90522.h b/drivers/media/dvb-frontends/tc90522.h
new file mode 100644
index 0000000..b6ee014
--- /dev/null
+++ b/drivers/media/dvb-frontends/tc90522.h
@@ -0,0 +1,18 @@
+/*
+ * Toshiba TC90522XBG 2ch OFDM(ISDB-T) + 2ch 8PSK(ISDB-S) demodulator
+ *
+ * Copyright (C) Budi Rachmanto, AreMa Inc. <info@are.ma>
+ *
+ * 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.
+ */
+
+#ifndef TC90522_H
+#define TC90522_H
+
+#define TC90522_MODNAME "tc90522"
+
+#endif
+
--
2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web