2008-09-13 21:10:53 +08:00
|
|
|
/*
|
|
|
|
* dm1105.c - driver for DVB cards based on SDMC DM1105 PCI chip
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Igor M. Liplianin <liplianin@me.by>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/i2c.h>
|
2011-05-06 03:35:01 +08:00
|
|
|
#include <linux/i2c-algo-bit.h>
|
2008-09-13 21:10:53 +08:00
|
|
|
#include <linux/init.h>
|
2011-06-06 18:43:46 +08:00
|
|
|
#include <linux/interrupt.h>
|
2008-09-13 21:10:53 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/dma-mapping.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2010-11-18 00:28:38 +08:00
|
|
|
#include <media/rc-core.h>
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
#include "demux.h"
|
|
|
|
#include "dmxdev.h"
|
|
|
|
#include "dvb_demux.h"
|
|
|
|
#include "dvb_frontend.h"
|
|
|
|
#include "dvb_net.h"
|
|
|
|
#include "dvbdev.h"
|
|
|
|
#include "dvb-pll.h"
|
|
|
|
|
|
|
|
#include "stv0299.h"
|
2008-09-24 02:43:57 +08:00
|
|
|
#include "stv0288.h"
|
|
|
|
#include "stb6000.h"
|
2008-09-17 05:21:11 +08:00
|
|
|
#include "si21xx.h"
|
2008-09-14 07:56:59 +08:00
|
|
|
#include "cx24116.h"
|
2008-09-13 21:10:53 +08:00
|
|
|
#include "z0194a.h"
|
2010-01-17 21:32:26 +08:00
|
|
|
#include "ds3000.h"
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-03-13 08:18:14 +08:00
|
|
|
#define MODULE_NAME "dm1105"
|
|
|
|
|
2009-07-23 04:30:25 +08:00
|
|
|
#define UNSET (-1U)
|
|
|
|
|
2011-05-06 03:35:01 +08:00
|
|
|
#define DM1105_BOARD_NOAUTO UNSET
|
|
|
|
#define DM1105_BOARD_UNKNOWN 0
|
|
|
|
#define DM1105_BOARD_DVBWORLD_2002 1
|
|
|
|
#define DM1105_BOARD_DVBWORLD_2004 2
|
|
|
|
#define DM1105_BOARD_AXESS_DM05 3
|
|
|
|
#define DM1105_BOARD_UNBRANDED_I2C_ON_GPIO 4
|
2009-07-23 04:30:25 +08:00
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
/* ----------------------------------------------- */
|
|
|
|
/*
|
|
|
|
* PCI ID's
|
|
|
|
*/
|
|
|
|
#ifndef PCI_VENDOR_ID_TRIGEM
|
|
|
|
#define PCI_VENDOR_ID_TRIGEM 0x109f
|
|
|
|
#endif
|
2009-06-15 08:34:12 +08:00
|
|
|
#ifndef PCI_VENDOR_ID_AXESS
|
|
|
|
#define PCI_VENDOR_ID_AXESS 0x195d
|
|
|
|
#endif
|
2008-09-13 21:10:53 +08:00
|
|
|
#ifndef PCI_DEVICE_ID_DM1105
|
|
|
|
#define PCI_DEVICE_ID_DM1105 0x036f
|
|
|
|
#endif
|
|
|
|
#ifndef PCI_DEVICE_ID_DW2002
|
|
|
|
#define PCI_DEVICE_ID_DW2002 0x2002
|
|
|
|
#endif
|
|
|
|
#ifndef PCI_DEVICE_ID_DW2004
|
|
|
|
#define PCI_DEVICE_ID_DW2004 0x2004
|
|
|
|
#endif
|
2009-06-15 08:34:12 +08:00
|
|
|
#ifndef PCI_DEVICE_ID_DM05
|
|
|
|
#define PCI_DEVICE_ID_DM05 0x1105
|
|
|
|
#endif
|
2008-09-13 21:10:53 +08:00
|
|
|
/* ----------------------------------------------- */
|
|
|
|
/* sdmc dm1105 registers */
|
|
|
|
|
|
|
|
/* TS Control */
|
|
|
|
#define DM1105_TSCTR 0x00
|
|
|
|
#define DM1105_DTALENTH 0x04
|
|
|
|
|
|
|
|
/* GPIO Interface */
|
|
|
|
#define DM1105_GPIOVAL 0x08
|
|
|
|
#define DM1105_GPIOCTR 0x0c
|
|
|
|
|
|
|
|
/* PID serial number */
|
|
|
|
#define DM1105_PIDN 0x10
|
|
|
|
|
|
|
|
/* Odd-even secret key select */
|
|
|
|
#define DM1105_CWSEL 0x14
|
|
|
|
|
|
|
|
/* Host Command Interface */
|
|
|
|
#define DM1105_HOST_CTR 0x18
|
|
|
|
#define DM1105_HOST_AD 0x1c
|
|
|
|
|
|
|
|
/* PCI Interface */
|
|
|
|
#define DM1105_CR 0x30
|
|
|
|
#define DM1105_RST 0x34
|
|
|
|
#define DM1105_STADR 0x38
|
|
|
|
#define DM1105_RLEN 0x3c
|
|
|
|
#define DM1105_WRP 0x40
|
|
|
|
#define DM1105_INTCNT 0x44
|
|
|
|
#define DM1105_INTMAK 0x48
|
|
|
|
#define DM1105_INTSTS 0x4c
|
|
|
|
|
|
|
|
/* CW Value */
|
|
|
|
#define DM1105_ODD 0x50
|
|
|
|
#define DM1105_EVEN 0x58
|
|
|
|
|
|
|
|
/* PID Value */
|
|
|
|
#define DM1105_PID 0x60
|
|
|
|
|
|
|
|
/* IR Control */
|
|
|
|
#define DM1105_IRCTR 0x64
|
|
|
|
#define DM1105_IRMODE 0x68
|
|
|
|
#define DM1105_SYSTEMCODE 0x6c
|
|
|
|
#define DM1105_IRCODE 0x70
|
|
|
|
|
|
|
|
/* Unknown Values */
|
|
|
|
#define DM1105_ENCRYPT 0x74
|
|
|
|
#define DM1105_VER 0x7c
|
|
|
|
|
|
|
|
/* I2C Interface */
|
|
|
|
#define DM1105_I2CCTR 0x80
|
|
|
|
#define DM1105_I2CSTS 0x81
|
|
|
|
#define DM1105_I2CDAT 0x82
|
|
|
|
#define DM1105_I2C_RA 0x83
|
|
|
|
/* ----------------------------------------------- */
|
|
|
|
/* Interrupt Mask Bits */
|
|
|
|
|
|
|
|
#define INTMAK_TSIRQM 0x01
|
|
|
|
#define INTMAK_HIRQM 0x04
|
|
|
|
#define INTMAK_IRM 0x08
|
|
|
|
#define INTMAK_ALLMASK (INTMAK_TSIRQM | \
|
|
|
|
INTMAK_HIRQM | \
|
|
|
|
INTMAK_IRM)
|
|
|
|
#define INTMAK_NONEMASK 0x00
|
|
|
|
|
|
|
|
/* Interrupt Status Bits */
|
|
|
|
#define INTSTS_TSIRQ 0x01
|
|
|
|
#define INTSTS_HIRQ 0x04
|
|
|
|
#define INTSTS_IR 0x08
|
|
|
|
|
|
|
|
/* IR Control Bits */
|
|
|
|
#define DM1105_IR_EN 0x01
|
|
|
|
#define DM1105_SYS_CHK 0x02
|
|
|
|
#define DM1105_REP_FLG 0x08
|
|
|
|
|
|
|
|
/* EEPROM addr */
|
|
|
|
#define IIC_24C01_addr 0xa0
|
|
|
|
/* Max board count */
|
|
|
|
#define DM1105_MAX 0x04
|
|
|
|
|
|
|
|
#define DRIVER_NAME "dm1105"
|
2011-05-06 03:35:01 +08:00
|
|
|
#define DM1105_I2C_GPIO_NAME "dm1105-gpio"
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
#define DM1105_DMA_PACKETS 47
|
|
|
|
#define DM1105_DMA_PACKET_LENGTH (128*4)
|
|
|
|
#define DM1105_DMA_BYTES (128 * 4 * DM1105_DMA_PACKETS)
|
|
|
|
|
2011-05-06 03:35:01 +08:00
|
|
|
/* */
|
|
|
|
#define GPIO08 (1 << 8)
|
|
|
|
#define GPIO13 (1 << 13)
|
|
|
|
#define GPIO14 (1 << 14)
|
|
|
|
#define GPIO15 (1 << 15)
|
|
|
|
#define GPIO16 (1 << 16)
|
|
|
|
#define GPIO17 (1 << 17)
|
|
|
|
#define GPIO_ALL 0x03ffff
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
/* GPIO's for LNB power control */
|
2011-05-06 03:35:01 +08:00
|
|
|
#define DM1105_LNB_MASK (GPIO_ALL & ~(GPIO14 | GPIO13))
|
|
|
|
#define DM1105_LNB_OFF GPIO17
|
|
|
|
#define DM1105_LNB_13V (GPIO16 | GPIO08)
|
|
|
|
#define DM1105_LNB_18V GPIO08
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2009-06-15 08:34:12 +08:00
|
|
|
/* GPIO's for LNB power control for Axess DM05 */
|
2011-05-06 03:35:01 +08:00
|
|
|
#define DM05_LNB_MASK (GPIO_ALL & ~(GPIO14 | GPIO13))
|
|
|
|
#define DM05_LNB_OFF GPIO17/* actually 13v */
|
|
|
|
#define DM05_LNB_13V GPIO17
|
|
|
|
#define DM05_LNB_18V (GPIO17 | GPIO16)
|
|
|
|
|
|
|
|
/* GPIO's for LNB power control for unbranded with I2C on GPIO */
|
|
|
|
#define UNBR_LNB_MASK (GPIO17 | GPIO16)
|
|
|
|
#define UNBR_LNB_OFF 0
|
|
|
|
#define UNBR_LNB_13V GPIO17
|
|
|
|
#define UNBR_LNB_18V (GPIO17 | GPIO16)
|
2009-06-15 08:34:12 +08:00
|
|
|
|
2009-07-23 04:30:25 +08:00
|
|
|
static unsigned int card[] = {[0 ... 3] = UNSET };
|
|
|
|
module_param_array(card, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(card, "card type");
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
static int ir_debug;
|
|
|
|
module_param(ir_debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding");
|
|
|
|
|
2009-07-23 04:30:25 +08:00
|
|
|
static unsigned int dm1105_devcount;
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
|
|
|
|
|
2009-07-23 04:30:25 +08:00
|
|
|
struct dm1105_board {
|
2011-05-06 03:35:01 +08:00
|
|
|
char *name;
|
|
|
|
struct {
|
|
|
|
u32 mask, off, v13, v18;
|
|
|
|
} lnb;
|
|
|
|
u32 gpio_scl, gpio_sda;
|
2009-07-23 04:30:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dm1105_subid {
|
|
|
|
u16 subvendor;
|
|
|
|
u16 subdevice;
|
|
|
|
u32 card;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct dm1105_board dm1105_boards[] = {
|
|
|
|
[DM1105_BOARD_UNKNOWN] = {
|
|
|
|
.name = "UNKNOWN/GENERIC",
|
2011-05-06 03:35:01 +08:00
|
|
|
.lnb = {
|
|
|
|
.mask = DM1105_LNB_MASK,
|
|
|
|
.off = DM1105_LNB_OFF,
|
|
|
|
.v13 = DM1105_LNB_13V,
|
|
|
|
.v18 = DM1105_LNB_18V,
|
|
|
|
},
|
2009-07-23 04:30:25 +08:00
|
|
|
},
|
|
|
|
[DM1105_BOARD_DVBWORLD_2002] = {
|
|
|
|
.name = "DVBWorld PCI 2002",
|
2011-05-06 03:35:01 +08:00
|
|
|
.lnb = {
|
|
|
|
.mask = DM1105_LNB_MASK,
|
|
|
|
.off = DM1105_LNB_OFF,
|
|
|
|
.v13 = DM1105_LNB_13V,
|
|
|
|
.v18 = DM1105_LNB_18V,
|
|
|
|
},
|
2009-07-23 04:30:25 +08:00
|
|
|
},
|
|
|
|
[DM1105_BOARD_DVBWORLD_2004] = {
|
|
|
|
.name = "DVBWorld PCI 2004",
|
2011-05-06 03:35:01 +08:00
|
|
|
.lnb = {
|
|
|
|
.mask = DM1105_LNB_MASK,
|
|
|
|
.off = DM1105_LNB_OFF,
|
|
|
|
.v13 = DM1105_LNB_13V,
|
|
|
|
.v18 = DM1105_LNB_18V,
|
|
|
|
},
|
2009-07-23 04:30:25 +08:00
|
|
|
},
|
|
|
|
[DM1105_BOARD_AXESS_DM05] = {
|
|
|
|
.name = "Axess/EasyTv DM05",
|
2011-05-06 03:35:01 +08:00
|
|
|
.lnb = {
|
|
|
|
.mask = DM05_LNB_MASK,
|
|
|
|
.off = DM05_LNB_OFF,
|
|
|
|
.v13 = DM05_LNB_13V,
|
|
|
|
.v18 = DM05_LNB_18V,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DM1105_BOARD_UNBRANDED_I2C_ON_GPIO] = {
|
|
|
|
.name = "Unbranded DM1105 with i2c on GPIOs",
|
|
|
|
.lnb = {
|
|
|
|
.mask = UNBR_LNB_MASK,
|
|
|
|
.off = UNBR_LNB_OFF,
|
|
|
|
.v13 = UNBR_LNB_13V,
|
|
|
|
.v18 = UNBR_LNB_18V,
|
|
|
|
},
|
|
|
|
.gpio_scl = GPIO14,
|
|
|
|
.gpio_sda = GPIO13,
|
2009-07-23 04:30:25 +08:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct dm1105_subid dm1105_subids[] = {
|
|
|
|
{
|
|
|
|
.subvendor = 0x0000,
|
|
|
|
.subdevice = 0x2002,
|
|
|
|
.card = DM1105_BOARD_DVBWORLD_2002,
|
|
|
|
}, {
|
|
|
|
.subvendor = 0x0001,
|
|
|
|
.subdevice = 0x2002,
|
|
|
|
.card = DM1105_BOARD_DVBWORLD_2002,
|
|
|
|
}, {
|
|
|
|
.subvendor = 0x0000,
|
|
|
|
.subdevice = 0x2004,
|
|
|
|
.card = DM1105_BOARD_DVBWORLD_2004,
|
|
|
|
}, {
|
|
|
|
.subvendor = 0x0001,
|
|
|
|
.subdevice = 0x2004,
|
|
|
|
.card = DM1105_BOARD_DVBWORLD_2004,
|
|
|
|
}, {
|
|
|
|
.subvendor = 0x195d,
|
|
|
|
.subdevice = 0x1105,
|
|
|
|
.card = DM1105_BOARD_AXESS_DM05,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static void dm1105_card_list(struct pci_dev *pci)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (0 == pci->subsystem_vendor &&
|
|
|
|
0 == pci->subsystem_device) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"dm1105: Your board has no valid PCI Subsystem ID\n"
|
|
|
|
"dm1105: and thus can't be autodetected\n"
|
|
|
|
"dm1105: Please pass card=<n> insmod option to\n"
|
|
|
|
"dm1105: workaround that. Redirect complaints to\n"
|
|
|
|
"dm1105: the vendor of the TV card. Best regards,\n"
|
|
|
|
"dm1105: -- tux\n");
|
|
|
|
} else {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"dm1105: Your board isn't known (yet) to the driver.\n"
|
|
|
|
"dm1105: You can try to pick one of the existing\n"
|
|
|
|
"dm1105: card configs via card=<n> insmod option.\n"
|
|
|
|
"dm1105: Updating to the latest version might help\n"
|
|
|
|
"dm1105: as well.\n");
|
|
|
|
}
|
|
|
|
printk(KERN_ERR "Here is a list of valid choices for the card=<n> "
|
|
|
|
"insmod option:\n");
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dm1105_boards); i++)
|
|
|
|
printk(KERN_ERR "dm1105: card=%d -> %s\n",
|
|
|
|
i, dm1105_boards[i].name);
|
|
|
|
}
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
/* infrared remote control */
|
|
|
|
struct infrared {
|
2010-10-30 03:08:23 +08:00
|
|
|
struct rc_dev *dev;
|
2008-09-13 21:10:53 +08:00
|
|
|
char input_phys[32];
|
2009-02-26 14:49:44 +08:00
|
|
|
struct work_struct work;
|
2008-09-13 21:10:53 +08:00
|
|
|
u32 ir_command;
|
|
|
|
};
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev {
|
2008-09-13 21:10:53 +08:00
|
|
|
/* pci */
|
|
|
|
struct pci_dev *pdev;
|
|
|
|
u8 __iomem *io_mem;
|
|
|
|
|
|
|
|
/* ir */
|
|
|
|
struct infrared ir;
|
|
|
|
|
|
|
|
/* dvb */
|
|
|
|
struct dmx_frontend hw_frontend;
|
|
|
|
struct dmx_frontend mem_frontend;
|
|
|
|
struct dmxdev dmxdev;
|
|
|
|
struct dvb_adapter dvb_adapter;
|
|
|
|
struct dvb_demux demux;
|
|
|
|
struct dvb_frontend *fe;
|
|
|
|
struct dvb_net dvbnet;
|
|
|
|
unsigned int full_ts_users;
|
2009-07-23 04:30:25 +08:00
|
|
|
unsigned int boardnr;
|
|
|
|
int nr;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
/* i2c */
|
|
|
|
struct i2c_adapter i2c_adap;
|
2011-05-06 03:35:01 +08:00
|
|
|
struct i2c_adapter i2c_bb_adap;
|
|
|
|
struct i2c_algo_bit_data i2c_bit;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2009-02-26 14:40:41 +08:00
|
|
|
/* irq */
|
|
|
|
struct work_struct work;
|
2009-06-15 08:34:12 +08:00
|
|
|
struct workqueue_struct *wq;
|
|
|
|
char wqn[16];
|
2009-02-26 14:40:41 +08:00
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
/* dma */
|
|
|
|
dma_addr_t dma_addr;
|
|
|
|
unsigned char *ts_buf;
|
|
|
|
u32 wrp;
|
2009-02-26 14:40:41 +08:00
|
|
|
u32 nextwrp;
|
2008-09-13 21:10:53 +08:00
|
|
|
u32 buffer_size;
|
|
|
|
unsigned int PacketErrorCount;
|
|
|
|
unsigned int dmarst;
|
|
|
|
spinlock_t lock;
|
|
|
|
};
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
#define dm_io_mem(reg) ((unsigned long)(&dev->io_mem[reg]))
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:23:04 +08:00
|
|
|
#define dm_readb(reg) inb(dm_io_mem(reg))
|
|
|
|
#define dm_writeb(reg, value) outb((value), (dm_io_mem(reg)))
|
|
|
|
|
|
|
|
#define dm_readw(reg) inw(dm_io_mem(reg))
|
|
|
|
#define dm_writew(reg, value) outw((value), (dm_io_mem(reg)))
|
|
|
|
|
|
|
|
#define dm_readl(reg) inl(dm_io_mem(reg))
|
|
|
|
#define dm_writel(reg, value) outl((value), (dm_io_mem(reg)))
|
|
|
|
|
|
|
|
#define dm_andorl(reg, mask, value) \
|
|
|
|
outl((inl(dm_io_mem(reg)) & ~(mask)) |\
|
|
|
|
((value) & (mask)), (dm_io_mem(reg)))
|
|
|
|
|
|
|
|
#define dm_setl(reg, bit) dm_andorl((reg), (bit), (bit))
|
|
|
|
#define dm_clearl(reg, bit) dm_andorl((reg), (bit), 0)
|
|
|
|
|
2011-05-06 03:35:01 +08:00
|
|
|
/* The chip has 18 GPIOs. In HOST mode GPIO's used as 15 bit address lines,
|
|
|
|
so we can use only 3 GPIO's from GPIO15 to GPIO17.
|
|
|
|
Here I don't check whether HOST is enebled as it is not implemented yet.
|
|
|
|
*/
|
|
|
|
static void dm1105_gpio_set(struct dm1105_dev *dev, u32 mask)
|
|
|
|
{
|
|
|
|
if (mask & 0xfffc0000)
|
|
|
|
printk(KERN_ERR "%s: Only 18 GPIO's are allowed\n", __func__);
|
|
|
|
|
|
|
|
if (mask & 0x0003ffff)
|
|
|
|
dm_setl(DM1105_GPIOVAL, mask & 0x0003ffff);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dm1105_gpio_clear(struct dm1105_dev *dev, u32 mask)
|
|
|
|
{
|
|
|
|
if (mask & 0xfffc0000)
|
|
|
|
printk(KERN_ERR "%s: Only 18 GPIO's are allowed\n", __func__);
|
|
|
|
|
|
|
|
if (mask & 0x0003ffff)
|
|
|
|
dm_clearl(DM1105_GPIOVAL, mask & 0x0003ffff);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dm1105_gpio_andor(struct dm1105_dev *dev, u32 mask, u32 val)
|
|
|
|
{
|
|
|
|
if (mask & 0xfffc0000)
|
|
|
|
printk(KERN_ERR "%s: Only 18 GPIO's are allowed\n", __func__);
|
|
|
|
|
|
|
|
if (mask & 0x0003ffff)
|
|
|
|
dm_andorl(DM1105_GPIOVAL, mask & 0x0003ffff, val);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 dm1105_gpio_get(struct dm1105_dev *dev, u32 mask)
|
|
|
|
{
|
|
|
|
if (mask & 0xfffc0000)
|
|
|
|
printk(KERN_ERR "%s: Only 18 GPIO's are allowed\n", __func__);
|
|
|
|
|
|
|
|
if (mask & 0x0003ffff)
|
|
|
|
return dm_readl(DM1105_GPIOVAL) & mask & 0x0003ffff;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dm1105_gpio_enable(struct dm1105_dev *dev, u32 mask, int asoutput)
|
|
|
|
{
|
|
|
|
if (mask & 0xfffc0000)
|
|
|
|
printk(KERN_ERR "%s: Only 18 GPIO's are allowed\n", __func__);
|
|
|
|
|
|
|
|
if ((mask & 0x0003ffff) && asoutput)
|
|
|
|
dm_clearl(DM1105_GPIOCTR, mask & 0x0003ffff);
|
|
|
|
else if ((mask & 0x0003ffff) && !asoutput)
|
|
|
|
dm_setl(DM1105_GPIOCTR, mask & 0x0003ffff);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dm1105_setline(struct dm1105_dev *dev, u32 line, int state)
|
|
|
|
{
|
|
|
|
if (state)
|
|
|
|
dm1105_gpio_enable(dev, line, 0);
|
|
|
|
else {
|
|
|
|
dm1105_gpio_enable(dev, line, 1);
|
|
|
|
dm1105_gpio_clear(dev, line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dm1105_setsda(void *data, int state)
|
|
|
|
{
|
|
|
|
struct dm1105_dev *dev = data;
|
|
|
|
|
|
|
|
dm1105_setline(dev, dm1105_boards[dev->boardnr].gpio_sda, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dm1105_setscl(void *data, int state)
|
|
|
|
{
|
|
|
|
struct dm1105_dev *dev = data;
|
|
|
|
|
|
|
|
dm1105_setline(dev, dm1105_boards[dev->boardnr].gpio_scl, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dm1105_getsda(void *data)
|
|
|
|
{
|
|
|
|
struct dm1105_dev *dev = data;
|
|
|
|
|
|
|
|
return dm1105_gpio_get(dev, dm1105_boards[dev->boardnr].gpio_sda)
|
|
|
|
? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dm1105_getscl(void *data)
|
|
|
|
{
|
|
|
|
struct dm1105_dev *dev = data;
|
|
|
|
|
|
|
|
return dm1105_gpio_get(dev, dm1105_boards[dev->boardnr].gpio_scl)
|
|
|
|
? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
static int dm1105_i2c_xfer(struct i2c_adapter *i2c_adap,
|
|
|
|
struct i2c_msg *msgs, int num)
|
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev ;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
int addr, rc, i, j, k, len, byte, data;
|
|
|
|
u8 status;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev = i2c_adap->algo_data;
|
2008-09-13 21:10:53 +08:00
|
|
|
for (i = 0; i < num; i++) {
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CCTR, 0x00);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (msgs[i].flags & I2C_M_RD) {
|
|
|
|
/* read bytes */
|
|
|
|
addr = msgs[i].addr << 1;
|
|
|
|
addr |= 1;
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CDAT, addr);
|
2008-09-13 21:10:53 +08:00
|
|
|
for (byte = 0; byte < msgs[i].len; byte++)
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CDAT + byte + 1, 0);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CCTR, 0x81 + msgs[i].len);
|
2008-09-13 21:10:53 +08:00
|
|
|
for (j = 0; j < 55; j++) {
|
|
|
|
mdelay(10);
|
2010-01-17 23:23:04 +08:00
|
|
|
status = dm_readb(DM1105_I2CSTS);
|
2008-09-13 21:10:53 +08:00
|
|
|
if ((status & 0xc0) == 0x40)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (j >= 55)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (byte = 0; byte < msgs[i].len; byte++) {
|
2010-01-17 23:23:04 +08:00
|
|
|
rc = dm_readb(DM1105_I2CDAT + byte + 1);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
|
|
|
msgs[i].buf[byte] = rc;
|
|
|
|
}
|
2010-01-17 22:15:06 +08:00
|
|
|
} else if ((msgs[i].buf[0] == 0xf7) && (msgs[i].addr == 0x55)) {
|
|
|
|
/* prepaired for cx24116 firmware */
|
|
|
|
/* Write in small blocks */
|
|
|
|
len = msgs[i].len - 1;
|
|
|
|
k = 1;
|
|
|
|
do {
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CDAT, msgs[i].addr << 1);
|
|
|
|
dm_writeb(DM1105_I2CDAT + 1, 0xf7);
|
2010-01-17 22:15:06 +08:00
|
|
|
for (byte = 0; byte < (len > 48 ? 48 : len); byte++) {
|
|
|
|
data = msgs[i].buf[k + byte];
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CDAT + byte + 2, data);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CCTR, 0x82 + (len > 48 ? 48 : len));
|
2008-09-13 21:10:53 +08:00
|
|
|
for (j = 0; j < 25; j++) {
|
|
|
|
mdelay(10);
|
2010-01-17 23:23:04 +08:00
|
|
|
status = dm_readb(DM1105_I2CSTS);
|
2008-09-13 21:10:53 +08:00
|
|
|
if ((status & 0xc0) == 0x40)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j >= 25)
|
|
|
|
return -1;
|
2010-01-17 22:15:06 +08:00
|
|
|
|
|
|
|
k += 48;
|
|
|
|
len -= 48;
|
|
|
|
} while (len > 0);
|
|
|
|
} else {
|
|
|
|
/* write bytes */
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CDAT, msgs[i].addr << 1);
|
2010-01-17 22:15:06 +08:00
|
|
|
for (byte = 0; byte < msgs[i].len; byte++) {
|
|
|
|
data = msgs[i].buf[byte];
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CDAT + byte + 1, data);
|
2010-01-17 22:15:06 +08:00
|
|
|
}
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_I2CCTR, 0x81 + msgs[i].len);
|
2010-01-17 22:15:06 +08:00
|
|
|
for (j = 0; j < 25; j++) {
|
|
|
|
mdelay(10);
|
2010-01-17 23:23:04 +08:00
|
|
|
status = dm_readb(DM1105_I2CSTS);
|
2010-01-17 22:15:06 +08:00
|
|
|
if ((status & 0xc0) == 0x40)
|
|
|
|
break;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
2010-01-17 22:15:06 +08:00
|
|
|
|
|
|
|
if (j >= 25)
|
|
|
|
return -1;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return num;
|
|
|
|
err:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 functionality(struct i2c_adapter *adap)
|
|
|
|
{
|
|
|
|
return I2C_FUNC_I2C;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct i2c_algorithm dm1105_algo = {
|
|
|
|
.master_xfer = dm1105_i2c_xfer,
|
|
|
|
.functionality = functionality,
|
|
|
|
};
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static inline struct dm1105_dev *feed_to_dm1105_dev(struct dvb_demux_feed *feed)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
return container_of(feed->demux, struct dm1105_dev, demux);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static inline struct dm1105_dev *frontend_to_dm1105_dev(struct dvb_frontend *fe)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
return container_of(fe->dvb, struct dm1105_dev, dvb_adapter);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static int dm1105_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev = frontend_to_dm1105_dev(fe);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2011-05-06 03:35:01 +08:00
|
|
|
dm1105_gpio_enable(dev, dm1105_boards[dev->boardnr].lnb.mask, 1);
|
2009-06-15 08:34:12 +08:00
|
|
|
if (voltage == SEC_VOLTAGE_18)
|
2011-05-06 03:35:01 +08:00
|
|
|
dm1105_gpio_andor(dev,
|
|
|
|
dm1105_boards[dev->boardnr].lnb.mask,
|
|
|
|
dm1105_boards[dev->boardnr].lnb.v18);
|
2009-07-23 04:30:25 +08:00
|
|
|
else if (voltage == SEC_VOLTAGE_13)
|
2011-05-06 03:35:01 +08:00
|
|
|
dm1105_gpio_andor(dev,
|
|
|
|
dm1105_boards[dev->boardnr].lnb.mask,
|
|
|
|
dm1105_boards[dev->boardnr].lnb.v13);
|
2009-07-23 04:30:25 +08:00
|
|
|
else
|
2011-05-06 03:35:01 +08:00
|
|
|
dm1105_gpio_andor(dev,
|
|
|
|
dm1105_boards[dev->boardnr].lnb.mask,
|
|
|
|
dm1105_boards[dev->boardnr].lnb.off);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static void dm1105_set_dma_addr(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writel(DM1105_STADR, cpu_to_le32(dev->dma_addr));
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static int __devinit dm1105_dma_map(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->ts_buf = pci_alloc_consistent(dev->pdev,
|
|
|
|
6 * DM1105_DMA_BYTES,
|
|
|
|
&dev->dma_addr);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
return !dev->ts_buf;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static void dm1105_dma_unmap(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
pci_free_consistent(dev->pdev,
|
|
|
|
6 * DM1105_DMA_BYTES,
|
|
|
|
dev->ts_buf,
|
|
|
|
dev->dma_addr);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static void dm1105_enable_irqs(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_INTMAK, INTMAK_ALLMASK);
|
|
|
|
dm_writeb(DM1105_CR, 1);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static void dm1105_disable_irqs(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_INTMAK, INTMAK_IRM);
|
|
|
|
dm_writeb(DM1105_CR, 0);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static int dm1105_start_feed(struct dvb_demux_feed *f)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev = feed_to_dm1105_dev(f);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
if (dev->full_ts_users++ == 0)
|
|
|
|
dm1105_enable_irqs(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static int dm1105_stop_feed(struct dvb_demux_feed *f)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev = feed_to_dm1105_dev(f);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
if (--dev->full_ts_users == 0)
|
|
|
|
dm1105_disable_irqs(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-26 14:49:44 +08:00
|
|
|
/* ir work handler */
|
|
|
|
static void dm1105_emit_key(struct work_struct *work)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2009-02-26 14:49:44 +08:00
|
|
|
struct infrared *ir = container_of(work, struct infrared, work);
|
2008-09-13 21:10:53 +08:00
|
|
|
u32 ircom = ir->ir_command;
|
|
|
|
u8 data;
|
|
|
|
|
2009-02-26 14:40:41 +08:00
|
|
|
if (ir_debug)
|
|
|
|
printk(KERN_INFO "%s: received byte 0x%04x\n", __func__, ircom);
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
data = (ircom >> 8) & 0x7f;
|
|
|
|
|
2010-11-18 00:53:11 +08:00
|
|
|
rc_keydown(ir->dev, data, 0);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2009-02-26 14:40:41 +08:00
|
|
|
/* work handler */
|
|
|
|
static void dm1105_dmx_buffer(struct work_struct *work)
|
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev = container_of(work, struct dm1105_dev, work);
|
2009-02-26 14:40:41 +08:00
|
|
|
unsigned int nbpackets;
|
2010-01-17 23:11:00 +08:00
|
|
|
u32 oldwrp = dev->wrp;
|
|
|
|
u32 nextwrp = dev->nextwrp;
|
2009-02-26 14:40:41 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
if (!((dev->ts_buf[oldwrp] == 0x47) &&
|
|
|
|
(dev->ts_buf[oldwrp + 188] == 0x47) &&
|
|
|
|
(dev->ts_buf[oldwrp + 188 * 2] == 0x47))) {
|
|
|
|
dev->PacketErrorCount++;
|
2009-02-26 14:40:41 +08:00
|
|
|
/* bad packet found */
|
2010-01-17 23:11:00 +08:00
|
|
|
if ((dev->PacketErrorCount >= 2) &&
|
|
|
|
(dev->dmarst == 0)) {
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_RST, 1);
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->wrp = 0;
|
|
|
|
dev->PacketErrorCount = 0;
|
|
|
|
dev->dmarst = 0;
|
2009-02-26 14:40:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nextwrp < oldwrp) {
|
2010-01-17 23:11:00 +08:00
|
|
|
memcpy(dev->ts_buf + dev->buffer_size, dev->ts_buf, nextwrp);
|
|
|
|
nbpackets = ((dev->buffer_size - oldwrp) + nextwrp) / 188;
|
2009-02-26 14:40:41 +08:00
|
|
|
} else
|
|
|
|
nbpackets = (nextwrp - oldwrp) / 188;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->wrp = nextwrp;
|
|
|
|
dvb_dmx_swfilter_packets(&dev->demux, &dev->ts_buf[oldwrp], nbpackets);
|
2009-02-26 14:40:41 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static irqreturn_t dm1105_irq(int irq, void *dev_id)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev = dev_id;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
/* Read-Write INSTS Ack's Interrupt for DM1105 chip 16.03.2008 */
|
2010-01-17 23:23:04 +08:00
|
|
|
unsigned int intsts = dm_readb(DM1105_INTSTS);
|
|
|
|
dm_writeb(DM1105_INTSTS, intsts);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
switch (intsts) {
|
|
|
|
case INTSTS_TSIRQ:
|
|
|
|
case (INTSTS_TSIRQ | INTSTS_IR):
|
2010-01-17 23:23:04 +08:00
|
|
|
dev->nextwrp = dm_readl(DM1105_WRP) - dm_readl(DM1105_STADR);
|
2010-01-17 23:11:00 +08:00
|
|
|
queue_work(dev->wq, &dev->work);
|
2008-09-13 21:10:53 +08:00
|
|
|
break;
|
|
|
|
case INTSTS_IR:
|
2010-01-17 23:23:04 +08:00
|
|
|
dev->ir.ir_command = dm_readl(DM1105_IRCODE);
|
2010-01-17 23:11:00 +08:00
|
|
|
schedule_work(&dev->ir.work);
|
2008-09-13 21:10:53 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-02-26 14:40:41 +08:00
|
|
|
return IRQ_HANDLED;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2012-10-27 23:44:41 +08:00
|
|
|
static int __devinit dm1105_ir_init(struct dm1105_dev *dm1105)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-10-30 03:08:23 +08:00
|
|
|
struct rc_dev *dev;
|
2009-02-26 14:49:44 +08:00
|
|
|
int err = -ENOMEM;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
dev = rc_allocate_device();
|
|
|
|
if (!dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
snprintf(dm1105->ir.input_phys, sizeof(dm1105->ir.input_phys),
|
|
|
|
"pci-%s/ir0", pci_name(dm1105->pdev));
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
dev->driver_name = MODULE_NAME;
|
|
|
|
dev->map_name = RC_MAP_DM1105_NEC;
|
|
|
|
dev->driver_type = RC_DRIVER_SCANCODE;
|
|
|
|
dev->input_name = "DVB on-card IR receiver";
|
|
|
|
dev->input_phys = dm1105->ir.input_phys;
|
|
|
|
dev->input_id.bustype = BUS_PCI;
|
|
|
|
dev->input_id.version = 1;
|
2008-09-13 21:10:53 +08:00
|
|
|
if (dm1105->pdev->subsystem_vendor) {
|
2010-10-30 03:08:23 +08:00
|
|
|
dev->input_id.vendor = dm1105->pdev->subsystem_vendor;
|
|
|
|
dev->input_id.product = dm1105->pdev->subsystem_device;
|
2008-09-13 21:10:53 +08:00
|
|
|
} else {
|
2010-10-30 03:08:23 +08:00
|
|
|
dev->input_id.vendor = dm1105->pdev->vendor;
|
|
|
|
dev->input_id.product = dm1105->pdev->device;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
2010-10-30 03:08:23 +08:00
|
|
|
dev->dev.parent = &dm1105->pdev->dev;
|
2009-02-26 14:49:44 +08:00
|
|
|
|
|
|
|
INIT_WORK(&dm1105->ir.work, dm1105_emit_key);
|
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
err = rc_register_device(dev);
|
2010-04-16 05:46:15 +08:00
|
|
|
if (err < 0) {
|
2010-10-30 03:08:23 +08:00
|
|
|
rc_free_device(dev);
|
2010-04-16 05:46:15 +08:00
|
|
|
return err;
|
|
|
|
}
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-10-30 03:08:23 +08:00
|
|
|
dm1105->ir.dev = dev;
|
2010-04-16 05:46:15 +08:00
|
|
|
return 0;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2012-10-27 23:44:41 +08:00
|
|
|
static void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-10-30 03:08:23 +08:00
|
|
|
rc_unregister_device(dm1105->ir.dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static int __devinit dm1105_hw_init(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_disable_irqs(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_HOST_CTR, 0);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
/*DATALEN 188,*/
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_DTALENTH, 188);
|
2008-09-13 21:10:53 +08:00
|
|
|
/*TS_STRT TS_VALP MSBFIRST TS_MODE ALPAS TSPES*/
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writew(DM1105_TSCTR, 0xc10a);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
/* map DMA and set address */
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_dma_map(dev);
|
|
|
|
dm1105_set_dma_addr(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
/* big buffer */
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writel(DM1105_RLEN, 5 * DM1105_DMA_BYTES);
|
|
|
|
dm_writeb(DM1105_INTCNT, 47);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
/* IR NEC mode enable */
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_IRCTR, (DM1105_IR_EN | DM1105_SYS_CHK));
|
|
|
|
dm_writeb(DM1105_IRMODE, 0);
|
|
|
|
dm_writew(DM1105_SYSTEMCODE, 0);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static void dm1105_hw_exit(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_disable_irqs(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
/* IR disable */
|
2010-01-17 23:23:04 +08:00
|
|
|
dm_writeb(DM1105_IRCTR, 0);
|
|
|
|
dm_writeb(DM1105_INTMAK, INTMAK_NONEMASK);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_dma_unmap(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
2008-09-24 02:43:57 +08:00
|
|
|
|
2008-10-18 00:45:55 +08:00
|
|
|
static struct stv0299_config sharp_z0194a_config = {
|
|
|
|
.demod_address = 0x68,
|
|
|
|
.inittab = sharp_z0194a_inittab,
|
|
|
|
.mclk = 88000000UL,
|
|
|
|
.invert = 1,
|
|
|
|
.skip_reinit = 0,
|
|
|
|
.lock_output = STV0299_LOCKOUTPUT_1,
|
|
|
|
.volt13_op0_op1 = STV0299_VOLT13_OP1,
|
|
|
|
.min_delay_ms = 100,
|
|
|
|
.set_symbol_rate = sharp_z0194a_set_symbol_rate,
|
|
|
|
};
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
static struct stv0288_config earda_config = {
|
|
|
|
.demod_address = 0x68,
|
|
|
|
.min_delay_ms = 100,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct si21xx_config serit_config = {
|
|
|
|
.demod_address = 0x68,
|
|
|
|
.min_delay_ms = 100,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct cx24116_config serit_sp2633_config = {
|
|
|
|
.demod_address = 0x55,
|
|
|
|
};
|
|
|
|
|
2010-01-17 21:32:26 +08:00
|
|
|
static struct ds3000_config dvbworld_ds3000_config = {
|
|
|
|
.demod_address = 0x68,
|
|
|
|
};
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static int __devinit frontend_init(struct dm1105_dev *dev)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
switch (dev->boardnr) {
|
2011-05-06 03:35:01 +08:00
|
|
|
case DM1105_BOARD_UNBRANDED_I2C_ON_GPIO:
|
|
|
|
dm1105_gpio_enable(dev, GPIO15, 1);
|
|
|
|
dm1105_gpio_clear(dev, GPIO15);
|
|
|
|
msleep(100);
|
|
|
|
dm1105_gpio_set(dev, GPIO15);
|
|
|
|
msleep(200);
|
|
|
|
dev->fe = dvb_attach(
|
|
|
|
stv0299_attach, &sharp_z0194a_config,
|
|
|
|
&dev->i2c_bb_adap);
|
|
|
|
if (dev->fe) {
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
|
|
|
dvb_attach(dvb_pll_attach, dev->fe, 0x60,
|
|
|
|
&dev->i2c_bb_adap, DVB_PLL_OPERA1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->fe = dvb_attach(
|
|
|
|
stv0288_attach, &earda_config,
|
|
|
|
&dev->i2c_bb_adap);
|
|
|
|
if (dev->fe) {
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
|
|
|
dvb_attach(stb6000_attach, dev->fe, 0x61,
|
|
|
|
&dev->i2c_bb_adap);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->fe = dvb_attach(
|
|
|
|
si21xx_attach, &serit_config,
|
|
|
|
&dev->i2c_bb_adap);
|
|
|
|
if (dev->fe)
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
|
|
|
break;
|
2009-07-23 04:30:25 +08:00
|
|
|
case DM1105_BOARD_DVBWORLD_2004:
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->fe = dvb_attach(
|
2009-06-15 08:34:12 +08:00
|
|
|
cx24116_attach, &serit_sp2633_config,
|
2010-01-17 23:11:00 +08:00
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dev->fe) {
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
2010-01-17 21:32:26 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->fe = dvb_attach(
|
2010-01-17 21:32:26 +08:00
|
|
|
ds3000_attach, &dvbworld_ds3000_config,
|
2010-01-17 23:11:00 +08:00
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dev->fe)
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2009-06-15 08:34:12 +08:00
|
|
|
break;
|
2009-07-23 04:30:25 +08:00
|
|
|
case DM1105_BOARD_DVBWORLD_2002:
|
|
|
|
case DM1105_BOARD_AXESS_DM05:
|
2009-06-15 08:34:12 +08:00
|
|
|
default:
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->fe = dvb_attach(
|
2009-06-15 08:34:12 +08:00
|
|
|
stv0299_attach, &sharp_z0194a_config,
|
2010-01-17 23:11:00 +08:00
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dev->fe) {
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
|
|
|
dvb_attach(dvb_pll_attach, dev->fe, 0x60,
|
|
|
|
&dev->i2c_adap, DVB_PLL_OPERA1);
|
2009-06-15 08:34:12 +08:00
|
|
|
break;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
2008-09-24 02:43:57 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->fe = dvb_attach(
|
2009-06-15 08:34:12 +08:00
|
|
|
stv0288_attach, &earda_config,
|
2010-01-17 23:11:00 +08:00
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dev->fe) {
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
|
|
|
dvb_attach(stb6000_attach, dev->fe, 0x61,
|
|
|
|
&dev->i2c_adap);
|
2009-06-15 08:34:12 +08:00
|
|
|
break;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
2008-09-24 02:43:57 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->fe = dvb_attach(
|
2009-06-15 08:34:12 +08:00
|
|
|
si21xx_attach, &serit_config,
|
2010-01-17 23:11:00 +08:00
|
|
|
&dev->i2c_adap);
|
|
|
|
if (dev->fe)
|
|
|
|
dev->fe->ops.set_voltage = dm1105_set_voltage;
|
2009-06-15 08:34:12 +08:00
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
if (!dev->fe) {
|
|
|
|
dev_err(&dev->pdev->dev, "could not attach frontend\n");
|
2008-09-13 21:10:53 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = dvb_register_frontend(&dev->dvb_adapter, dev->fe);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0) {
|
2010-01-17 23:11:00 +08:00
|
|
|
if (dev->fe->ops.release)
|
|
|
|
dev->fe->ops.release(dev->fe);
|
|
|
|
dev->fe = NULL;
|
2008-09-13 21:10:53 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
static void __devinit dm1105_read_mac(struct dm1105_dev *dev, u8 *mac)
|
2008-09-13 21:10:53 +08:00
|
|
|
{
|
|
|
|
static u8 command[1] = { 0x28 };
|
|
|
|
|
|
|
|
struct i2c_msg msg[] = {
|
2009-06-15 08:34:12 +08:00
|
|
|
{
|
|
|
|
.addr = IIC_24C01_addr >> 1,
|
|
|
|
.flags = 0,
|
|
|
|
.buf = command,
|
|
|
|
.len = 1
|
|
|
|
}, {
|
|
|
|
.addr = IIC_24C01_addr >> 1,
|
|
|
|
.flags = I2C_M_RD,
|
|
|
|
.buf = mac,
|
|
|
|
.len = 6
|
|
|
|
},
|
2008-09-13 21:10:53 +08:00
|
|
|
};
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_i2c_xfer(&dev->i2c_adap, msg , 2);
|
|
|
|
dev_info(&dev->pdev->dev, "MAC %pM\n", mac);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __devinit dm1105_probe(struct pci_dev *pdev,
|
|
|
|
const struct pci_device_id *ent)
|
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev;
|
2008-09-13 21:10:53 +08:00
|
|
|
struct dvb_adapter *dvb_adapter;
|
|
|
|
struct dvb_demux *dvbdemux;
|
|
|
|
struct dmx_demux *dmx;
|
|
|
|
int ret = -ENOMEM;
|
2009-07-23 04:30:25 +08:00
|
|
|
int i;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev = kzalloc(sizeof(struct dm1105_dev), GFP_KERNEL);
|
|
|
|
if (!dev)
|
2009-02-26 14:40:41 +08:00
|
|
|
return -ENOMEM;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2009-07-23 04:30:25 +08:00
|
|
|
/* board config */
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->nr = dm1105_devcount;
|
|
|
|
dev->boardnr = UNSET;
|
|
|
|
if (card[dev->nr] < ARRAY_SIZE(dm1105_boards))
|
|
|
|
dev->boardnr = card[dev->nr];
|
|
|
|
for (i = 0; UNSET == dev->boardnr &&
|
2009-07-23 04:30:25 +08:00
|
|
|
i < ARRAY_SIZE(dm1105_subids); i++)
|
|
|
|
if (pdev->subsystem_vendor ==
|
|
|
|
dm1105_subids[i].subvendor &&
|
|
|
|
pdev->subsystem_device ==
|
|
|
|
dm1105_subids[i].subdevice)
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->boardnr = dm1105_subids[i].card;
|
2009-07-23 04:30:25 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
if (UNSET == dev->boardnr) {
|
|
|
|
dev->boardnr = DM1105_BOARD_UNKNOWN;
|
2009-07-23 04:30:25 +08:00
|
|
|
dm1105_card_list(pdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
dm1105_devcount++;
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->pdev = pdev;
|
|
|
|
dev->buffer_size = 5 * DM1105_DMA_BYTES;
|
|
|
|
dev->PacketErrorCount = 0;
|
|
|
|
dev->dmarst = 0;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
ret = pci_enable_device(pdev);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err_kfree;
|
|
|
|
|
2009-04-07 10:01:15 +08:00
|
|
|
ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto err_pci_disable_device;
|
|
|
|
|
|
|
|
pci_set_master(pdev);
|
|
|
|
|
|
|
|
ret = pci_request_regions(pdev, DRIVER_NAME);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err_pci_disable_device;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->io_mem = pci_iomap(pdev, 0, pci_resource_len(pdev, 0));
|
|
|
|
if (!dev->io_mem) {
|
2008-09-13 21:10:53 +08:00
|
|
|
ret = -EIO;
|
|
|
|
goto err_pci_release_regions;
|
|
|
|
}
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
spin_lock_init(&dev->lock);
|
|
|
|
pci_set_drvdata(pdev, dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = dm1105_hw_init(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0)
|
2009-02-26 14:40:41 +08:00
|
|
|
goto err_pci_iounmap;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
/* i2c */
|
2010-01-17 23:11:00 +08:00
|
|
|
i2c_set_adapdata(&dev->i2c_adap, dev);
|
|
|
|
strcpy(dev->i2c_adap.name, DRIVER_NAME);
|
|
|
|
dev->i2c_adap.owner = THIS_MODULE;
|
|
|
|
dev->i2c_adap.dev.parent = &pdev->dev;
|
|
|
|
dev->i2c_adap.algo = &dm1105_algo;
|
|
|
|
dev->i2c_adap.algo_data = dev;
|
|
|
|
ret = i2c_add_adapter(&dev->i2c_adap);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
if (ret < 0)
|
2010-01-17 23:11:00 +08:00
|
|
|
goto err_dm1105_hw_exit;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2011-05-06 03:35:01 +08:00
|
|
|
i2c_set_adapdata(&dev->i2c_bb_adap, dev);
|
|
|
|
strcpy(dev->i2c_bb_adap.name, DM1105_I2C_GPIO_NAME);
|
|
|
|
dev->i2c_bb_adap.owner = THIS_MODULE;
|
|
|
|
dev->i2c_bb_adap.dev.parent = &pdev->dev;
|
|
|
|
dev->i2c_bb_adap.algo_data = &dev->i2c_bit;
|
|
|
|
dev->i2c_bit.data = dev;
|
|
|
|
dev->i2c_bit.setsda = dm1105_setsda;
|
|
|
|
dev->i2c_bit.setscl = dm1105_setscl;
|
|
|
|
dev->i2c_bit.getsda = dm1105_getsda;
|
|
|
|
dev->i2c_bit.getscl = dm1105_getscl;
|
|
|
|
dev->i2c_bit.udelay = 10;
|
|
|
|
dev->i2c_bit.timeout = 10;
|
|
|
|
|
|
|
|
/* Raise SCL and SDA */
|
|
|
|
dm1105_setsda(dev, 1);
|
|
|
|
dm1105_setscl(dev, 1);
|
|
|
|
|
|
|
|
ret = i2c_bit_add_bus(&dev->i2c_bb_adap);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err_i2c_del_adapter;
|
|
|
|
|
2008-09-13 21:10:53 +08:00
|
|
|
/* dvb */
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = dvb_register_adapter(&dev->dvb_adapter, DRIVER_NAME,
|
2008-09-13 21:10:53 +08:00
|
|
|
THIS_MODULE, &pdev->dev, adapter_nr);
|
|
|
|
if (ret < 0)
|
2011-05-06 03:35:01 +08:00
|
|
|
goto err_i2c_del_adapters;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dvb_adapter = &dev->dvb_adapter;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_read_mac(dev, dvb_adapter->proposed_mac);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dvbdemux = &dev->demux;
|
2008-09-13 21:10:53 +08:00
|
|
|
dvbdemux->filternum = 256;
|
|
|
|
dvbdemux->feednum = 256;
|
2010-01-17 23:11:00 +08:00
|
|
|
dvbdemux->start_feed = dm1105_start_feed;
|
|
|
|
dvbdemux->stop_feed = dm1105_stop_feed;
|
2008-09-13 21:10:53 +08:00
|
|
|
dvbdemux->dmx.capabilities = (DMX_TS_FILTERING |
|
|
|
|
DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
|
|
|
|
ret = dvb_dmx_init(dvbdemux);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err_dvb_unregister_adapter;
|
|
|
|
|
|
|
|
dmx = &dvbdemux->dmx;
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->dmxdev.filternum = 256;
|
|
|
|
dev->dmxdev.demux = dmx;
|
|
|
|
dev->dmxdev.capabilities = 0;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = dvb_dmxdev_init(&dev->dmxdev, dvb_adapter);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto err_dvb_dmx_release;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->hw_frontend.source = DMX_FRONTEND_0;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = dmx->add_frontend(dmx, &dev->hw_frontend);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto err_dvb_dmxdev_release;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dev->mem_frontend.source = DMX_MEMORY_FE;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = dmx->add_frontend(dmx, &dev->mem_frontend);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto err_remove_hw_frontend;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = dmx->connect_frontend(dmx, &dev->hw_frontend);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0)
|
|
|
|
goto err_remove_mem_frontend;
|
|
|
|
|
2011-12-31 19:08:45 +08:00
|
|
|
ret = dvb_net_init(dvb_adapter, &dev->dvbnet, dmx);
|
|
|
|
if (ret < 0)
|
|
|
|
goto err_disconnect_frontend;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = frontend_init(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
if (ret < 0)
|
2012-01-07 01:40:26 +08:00
|
|
|
goto err_dvb_net;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_ir_init(dev);
|
2009-02-26 14:40:41 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
INIT_WORK(&dev->work, dm1105_dmx_buffer);
|
|
|
|
sprintf(dev->wqn, "%s/%d", dvb_adapter->name, dvb_adapter->num);
|
|
|
|
dev->wq = create_singlethread_workqueue(dev->wqn);
|
|
|
|
if (!dev->wq)
|
2009-06-15 08:34:12 +08:00
|
|
|
goto err_dvb_net;
|
2009-02-26 14:40:41 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
ret = request_irq(pdev->irq, dm1105_irq, IRQF_SHARED,
|
|
|
|
DRIVER_NAME, dev);
|
2009-02-26 14:40:41 +08:00
|
|
|
if (ret < 0)
|
2009-06-15 08:34:12 +08:00
|
|
|
goto err_workqueue;
|
2009-02-26 14:40:41 +08:00
|
|
|
|
|
|
|
return 0;
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2009-06-15 08:34:12 +08:00
|
|
|
err_workqueue:
|
2010-01-17 23:11:00 +08:00
|
|
|
destroy_workqueue(dev->wq);
|
2009-06-15 08:34:12 +08:00
|
|
|
err_dvb_net:
|
2010-01-17 23:11:00 +08:00
|
|
|
dvb_net_release(&dev->dvbnet);
|
2008-09-13 21:10:53 +08:00
|
|
|
err_disconnect_frontend:
|
|
|
|
dmx->disconnect_frontend(dmx);
|
|
|
|
err_remove_mem_frontend:
|
2010-01-17 23:11:00 +08:00
|
|
|
dmx->remove_frontend(dmx, &dev->mem_frontend);
|
2008-09-13 21:10:53 +08:00
|
|
|
err_remove_hw_frontend:
|
2010-01-17 23:11:00 +08:00
|
|
|
dmx->remove_frontend(dmx, &dev->hw_frontend);
|
2008-09-13 21:10:53 +08:00
|
|
|
err_dvb_dmxdev_release:
|
2010-01-17 23:11:00 +08:00
|
|
|
dvb_dmxdev_release(&dev->dmxdev);
|
2008-09-13 21:10:53 +08:00
|
|
|
err_dvb_dmx_release:
|
|
|
|
dvb_dmx_release(dvbdemux);
|
|
|
|
err_dvb_unregister_adapter:
|
|
|
|
dvb_unregister_adapter(dvb_adapter);
|
2011-05-06 03:35:01 +08:00
|
|
|
err_i2c_del_adapters:
|
|
|
|
i2c_del_adapter(&dev->i2c_bb_adap);
|
2008-09-13 21:10:53 +08:00
|
|
|
err_i2c_del_adapter:
|
2010-01-17 23:11:00 +08:00
|
|
|
i2c_del_adapter(&dev->i2c_adap);
|
|
|
|
err_dm1105_hw_exit:
|
|
|
|
dm1105_hw_exit(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
err_pci_iounmap:
|
2010-01-17 23:11:00 +08:00
|
|
|
pci_iounmap(pdev, dev->io_mem);
|
2008-09-13 21:10:53 +08:00
|
|
|
err_pci_release_regions:
|
|
|
|
pci_release_regions(pdev);
|
|
|
|
err_pci_disable_device:
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
err_kfree:
|
|
|
|
pci_set_drvdata(pdev, NULL);
|
2010-01-17 23:11:00 +08:00
|
|
|
kfree(dev);
|
2009-02-26 14:40:41 +08:00
|
|
|
return ret;
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __devexit dm1105_remove(struct pci_dev *pdev)
|
|
|
|
{
|
2010-01-17 23:11:00 +08:00
|
|
|
struct dm1105_dev *dev = pci_get_drvdata(pdev);
|
|
|
|
struct dvb_adapter *dvb_adapter = &dev->dvb_adapter;
|
|
|
|
struct dvb_demux *dvbdemux = &dev->demux;
|
2008-09-13 21:10:53 +08:00
|
|
|
struct dmx_demux *dmx = &dvbdemux->dmx;
|
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_ir_exit(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
dmx->close(dmx);
|
2010-01-17 23:11:00 +08:00
|
|
|
dvb_net_release(&dev->dvbnet);
|
|
|
|
if (dev->fe)
|
|
|
|
dvb_unregister_frontend(dev->fe);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
|
|
|
dmx->disconnect_frontend(dmx);
|
2010-01-17 23:11:00 +08:00
|
|
|
dmx->remove_frontend(dmx, &dev->mem_frontend);
|
|
|
|
dmx->remove_frontend(dmx, &dev->hw_frontend);
|
|
|
|
dvb_dmxdev_release(&dev->dmxdev);
|
2008-09-13 21:10:53 +08:00
|
|
|
dvb_dmx_release(dvbdemux);
|
|
|
|
dvb_unregister_adapter(dvb_adapter);
|
2010-01-17 23:11:00 +08:00
|
|
|
if (&dev->i2c_adap)
|
|
|
|
i2c_del_adapter(&dev->i2c_adap);
|
2008-09-13 21:10:53 +08:00
|
|
|
|
2010-01-17 23:11:00 +08:00
|
|
|
dm1105_hw_exit(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
synchronize_irq(pdev->irq);
|
2010-01-17 23:11:00 +08:00
|
|
|
free_irq(pdev->irq, dev);
|
|
|
|
pci_iounmap(pdev, dev->io_mem);
|
2008-09-13 21:10:53 +08:00
|
|
|
pci_release_regions(pdev);
|
|
|
|
pci_disable_device(pdev);
|
|
|
|
pci_set_drvdata(pdev, NULL);
|
2009-07-23 04:30:25 +08:00
|
|
|
dm1105_devcount--;
|
2010-01-17 23:11:00 +08:00
|
|
|
kfree(dev);
|
2008-09-13 21:10:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_device_id dm1105_id_table[] __devinitdata = {
|
|
|
|
{
|
|
|
|
.vendor = PCI_VENDOR_ID_TRIGEM,
|
|
|
|
.device = PCI_DEVICE_ID_DM1105,
|
|
|
|
.subvendor = PCI_ANY_ID,
|
2009-07-23 04:30:25 +08:00
|
|
|
.subdevice = PCI_ANY_ID,
|
2009-06-15 08:34:12 +08:00
|
|
|
}, {
|
|
|
|
.vendor = PCI_VENDOR_ID_AXESS,
|
|
|
|
.device = PCI_DEVICE_ID_DM05,
|
2009-07-23 04:30:25 +08:00
|
|
|
.subvendor = PCI_ANY_ID,
|
|
|
|
.subdevice = PCI_ANY_ID,
|
2008-09-13 21:10:53 +08:00
|
|
|
}, {
|
|
|
|
/* empty */
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, dm1105_id_table);
|
|
|
|
|
|
|
|
static struct pci_driver dm1105_driver = {
|
|
|
|
.name = DRIVER_NAME,
|
|
|
|
.id_table = dm1105_id_table,
|
|
|
|
.probe = dm1105_probe,
|
|
|
|
.remove = __devexit_p(dm1105_remove),
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init dm1105_init(void)
|
|
|
|
{
|
|
|
|
return pci_register_driver(&dm1105_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit dm1105_exit(void)
|
|
|
|
{
|
|
|
|
pci_unregister_driver(&dm1105_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(dm1105_init);
|
|
|
|
module_exit(dm1105_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Igor M. Liplianin <liplianin@me.by>");
|
|
|
|
MODULE_DESCRIPTION("SDMC DM1105 DVB driver");
|
|
|
|
MODULE_LICENSE("GPL");
|