diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
| commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
| tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /drivers/media/dvb/pluto2 | |
| parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) | |
Diffstat (limited to 'drivers/media/dvb/pluto2')
| -rw-r--r-- | drivers/media/dvb/pluto2/Kconfig | 15 | ||||
| -rw-r--r-- | drivers/media/dvb/pluto2/Makefile | 3 | ||||
| -rw-r--r-- | drivers/media/dvb/pluto2/pluto2.c | 823 |
3 files changed, 841 insertions, 0 deletions
diff --git a/drivers/media/dvb/pluto2/Kconfig b/drivers/media/dvb/pluto2/Kconfig new file mode 100644 index 00000000000..7d8e6e87bdb --- /dev/null +++ b/drivers/media/dvb/pluto2/Kconfig | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | config DVB_PLUTO2 | ||
| 2 | tristate "Pluto2 cards" | ||
| 3 | depends on DVB_CORE && PCI && I2C | ||
| 4 | select I2C_ALGOBIT | ||
| 5 | select DVB_TDA1004X | ||
| 6 | help | ||
| 7 | Support for PCI cards based on the Pluto2 FPGA like the Satelco | ||
| 8 | Easywatch Mobile Terrestrial DVB-T Receiver. | ||
| 9 | |||
| 10 | Since these cards have no MPEG decoder onboard, they transmit | ||
| 11 | only compressed MPEG data over the PCI bus, so you need | ||
| 12 | an external software decoder to watch TV on your computer. | ||
| 13 | |||
| 14 | Say Y or M if you own such a device and want to use it. | ||
| 15 | |||
diff --git a/drivers/media/dvb/pluto2/Makefile b/drivers/media/dvb/pluto2/Makefile new file mode 100644 index 00000000000..7ac128724df --- /dev/null +++ b/drivers/media/dvb/pluto2/Makefile | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | obj-$(CONFIG_DVB_PLUTO2) += pluto2.o | ||
| 2 | |||
| 3 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | ||
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c new file mode 100644 index 00000000000..80fb5100446 --- /dev/null +++ b/drivers/media/dvb/pluto2/pluto2.c | |||
| @@ -0,0 +1,823 @@ | |||
| 1 | /* | ||
| 2 | * pluto2.c - Satelco Easywatch Mobile Terrestrial Receiver [DVB-T] | ||
| 3 | * | ||
| 4 | * Copyright (C) 2005 Andreas Oberritter <obi@linuxtv.org> | ||
| 5 | * | ||
| 6 | * based on pluto2.c 1.10 - http://instinct-wp8.no-ip.org/pluto/ | ||
| 7 | * by Dany Salman <salmandany@yahoo.fr> | ||
| 8 | * Copyright (c) 2004 TDF | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License as published by | ||
| 12 | * the Free Software Foundation; either version 2 of the License, or | ||
| 13 | * (at your option) any later version. | ||
| 14 | * | ||
| 15 | * This program is distributed in the hope that it will be useful, | ||
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | * GNU General Public License for more details. | ||
| 19 | * | ||
| 20 | * You should have received a copy of the GNU General Public License | ||
| 21 | * along with this program; if not, write to the Free Software | ||
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 23 | * | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <linux/i2c.h> | ||
| 27 | #include <linux/i2c-algo-bit.h> | ||
| 28 | #include <linux/init.h> | ||
| 29 | #include <linux/interrupt.h> | ||
| 30 | #include <linux/kernel.h> | ||
| 31 | #include <linux/module.h> | ||
| 32 | #include <linux/pci.h> | ||
| 33 | #include <linux/dma-mapping.h> | ||
| 34 | #include <linux/slab.h> | ||
| 35 | |||
| 36 | #include "demux.h" | ||
| 37 | #include "dmxdev.h" | ||
| 38 | #include "dvb_demux.h" | ||
| 39 | #include "dvb_frontend.h" | ||
| 40 | #include "dvb_net.h" | ||
| 41 | #include "dvbdev.h" | ||
| 42 | #include "tda1004x.h" | ||
| 43 | |||
| 44 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 45 | |||
| 46 | #define DRIVER_NAME "pluto2" | ||
| 47 | |||
| 48 | #define REG_PIDn(n) ((n) << 2) /* PID n pattern registers */ | ||
| 49 | #define REG_PCAR 0x0020 /* PC address register */ | ||
| 50 | #define REG_TSCR 0x0024 /* TS ctrl & status */ | ||
| 51 | #define REG_MISC 0x0028 /* miscellaneous */ | ||
| 52 | #define REG_MMAC 0x002c /* MSB MAC address */ | ||
| 53 | #define REG_IMAC 0x0030 /* ISB MAC address */ | ||
| 54 | #define REG_LMAC 0x0034 /* LSB MAC address */ | ||
| 55 | #define REG_SPID 0x0038 /* SPI data */ | ||
| 56 | #define REG_SLCS 0x003c /* serial links ctrl/status */ | ||
| 57 | |||
| 58 | #define PID0_NOFIL (0x0001 << 16) | ||
| 59 | #define PIDn_ENP (0x0001 << 15) | ||
| 60 | #define PID0_END (0x0001 << 14) | ||
| 61 | #define PID0_AFIL (0x0001 << 13) | ||
| 62 | #define PIDn_PID (0x1fff << 0) | ||
| 63 | |||
| 64 | #define TSCR_NBPACKETS (0x00ff << 24) | ||
| 65 | #define TSCR_DEM (0x0001 << 17) | ||
| 66 | #define TSCR_DE (0x0001 << 16) | ||
| 67 | #define TSCR_RSTN (0x0001 << 15) | ||
| 68 | #define TSCR_MSKO (0x0001 << 14) | ||
| 69 | #define TSCR_MSKA (0x0001 << 13) | ||
| 70 | #define TSCR_MSKL (0x0001 << 12) | ||
| 71 | #define TSCR_OVR (0x0001 << 11) | ||
| 72 | #define TSCR_AFUL (0x0001 << 10) | ||
| 73 | #define TSCR_LOCK (0x0001 << 9) | ||
| 74 | #define TSCR_IACK (0x0001 << 8) | ||
| 75 | #define TSCR_ADEF (0x007f << 0) | ||
| 76 | |||
| 77 | #define MISC_DVR (0x0fff << 4) | ||
| 78 | #define MISC_ALED (0x0001 << 3) | ||
| 79 | #define MISC_FRST (0x0001 << 2) | ||
| 80 | #define MISC_LED1 (0x0001 << 1) | ||
| 81 | #define MISC_LED0 (0x0001 << 0) | ||
| 82 | |||
| 83 | #define SPID_SPIDR (0x00ff << 0) | ||
| 84 | |||
| 85 | #define SLCS_SCL (0x0001 << 7) | ||
| 86 | #define SLCS_SDA (0x0001 << 6) | ||
| 87 | #define SLCS_CSN (0x0001 << 2) | ||
| 88 | #define SLCS_OVR (0x0001 << 1) | ||
| 89 | #define SLCS_SWC (0x0001 << 0) | ||
| 90 | |||
| 91 | #define TS_DMA_PACKETS (8) | ||
| 92 | #define TS_DMA_BYTES (188 * TS_DMA_PACKETS) | ||
| 93 | |||
| 94 | #define I2C_ADDR_TDA10046 0x10 | ||
| 95 | #define I2C_ADDR_TUA6034 0xc2 | ||
| 96 | #define NHWFILTERS 8 | ||
| 97 | |||
| 98 | struct pluto { | ||
| 99 | /* pci */ | ||
| 100 | struct pci_dev *pdev; | ||
| 101 | u8 __iomem *io_mem; | ||
| 102 | |||
| 103 | /* dvb */ | ||
| 104 | struct dmx_frontend hw_frontend; | ||
| 105 | struct dmx_frontend mem_frontend; | ||
| 106 | struct dmxdev dmxdev; | ||
| 107 | struct dvb_adapter dvb_adapter; | ||
| 108 | struct dvb_demux demux; | ||
| 109 | struct dvb_frontend *fe; | ||
| 110 | struct dvb_net dvbnet; | ||
| 111 | unsigned int full_ts_users; | ||
| 112 | unsigned int users; | ||
| 113 | |||
| 114 | /* i2c */ | ||
| 115 | struct i2c_algo_bit_data i2c_bit; | ||
| 116 | struct i2c_adapter i2c_adap; | ||
| 117 | unsigned int i2cbug; | ||
| 118 | |||
| 119 | /* irq */ | ||
| 120 | unsigned int overflow; | ||
| 121 | unsigned int dead; | ||
| 122 | |||
| 123 | /* dma */ | ||
| 124 | dma_addr_t dma_addr; | ||
| 125 | u8 dma_buf[TS_DMA_BYTES]; | ||
| 126 | u8 dummy[4096]; | ||
| 127 | }; | ||
| 128 | |||
| 129 | static inline struct pluto *feed_to_pluto(struct dvb_demux_feed *feed) | ||
| 130 | { | ||
| 131 | return container_of(feed->demux, struct pluto, demux); | ||
| 132 | } | ||
| 133 | |||
| 134 | static inline struct pluto *frontend_to_pluto(struct dvb_frontend *fe) | ||
| 135 | { | ||
| 136 | return container_of(fe->dvb, struct pluto, dvb_adapter); | ||
| 137 | } | ||
| 138 | |||
| 139 | static inline u32 pluto_readreg(struct pluto *pluto, u32 reg) | ||
| 140 | { | ||
| 141 | return readl(&pluto->io_mem[reg]); | ||
| 142 | } | ||
| 143 | |||
| 144 | static inline void pluto_writereg(struct pluto *pluto, u32 reg, u32 val) | ||
| 145 | { | ||
| 146 | writel(val, &pluto->io_mem[reg]); | ||
| 147 | } | ||
| 148 | |||
| 149 | static inline void pluto_rw(struct pluto *pluto, u32 reg, u32 mask, u32 bits) | ||
| 150 | { | ||
| 151 | u32 val = readl(&pluto->io_mem[reg]); | ||
| 152 | val &= ~mask; | ||
| 153 | val |= bits; | ||
| 154 | writel(val, &pluto->io_mem[reg]); | ||
| 155 | } | ||
| 156 | |||
| 157 | static void pluto_write_tscr(struct pluto *pluto, u32 val) | ||
| 158 | { | ||
| 159 | /* set the number of packets */ | ||
| 160 | val &= ~TSCR_ADEF; | ||
| 161 | val |= TS_DMA_PACKETS / 2; | ||
| 162 | |||
| 163 | pluto_writereg(pluto, REG_TSCR, val); | ||
| 164 | } | ||
| 165 | |||
| 166 | static void pluto_setsda(void *data, int state) | ||
| 167 | { | ||
| 168 | struct pluto *pluto = data; | ||
| 169 | |||
| 170 | if (state) | ||
| 171 | pluto_rw(pluto, REG_SLCS, SLCS_SDA, SLCS_SDA); | ||
| 172 | else | ||
| 173 | pluto_rw(pluto, REG_SLCS, SLCS_SDA, 0); | ||
| 174 | } | ||
| 175 | |||
| 176 | static void pluto_setscl(void *data, int state) | ||
| 177 | { | ||
| 178 | struct pluto *pluto = data; | ||
| 179 | |||
| 180 | if (state) | ||
| 181 | pluto_rw(pluto, REG_SLCS, SLCS_SCL, SLCS_SCL); | ||
| 182 | else | ||
| 183 | pluto_rw(pluto, REG_SLCS, SLCS_SCL, 0); | ||
| 184 | |||
