aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/dvb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/Kconfig51
-rw-r--r--drivers/media/dvb/Makefile5
-rw-r--r--drivers/media/dvb/b2c2/Kconfig39
-rw-r--r--drivers/media/dvb/b2c2/Makefile12
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h165
-rw-r--r--drivers/media/dvb/b2c2/flexcop-dma.c171
-rw-r--r--drivers/media/dvb/b2c2/flexcop-eeprom.c153
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c591
-rw-r--r--drivers/media/dvb/b2c2/flexcop-hw-filter.c212
-rw-r--r--drivers/media/dvb/b2c2/flexcop-i2c.c207
-rw-r--r--drivers/media/dvb/b2c2/flexcop-misc.c80
-rw-r--r--drivers/media/dvb/b2c2/flexcop-pci.c430
-rw-r--r--drivers/media/dvb/b2c2/flexcop-reg.h167
-rw-r--r--drivers/media/dvb/b2c2/flexcop-sram.c403
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c575
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.h119
-rw-r--r--drivers/media/dvb/b2c2/flexcop.c311
-rw-r--r--drivers/media/dvb/b2c2/flexcop.h31
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_be.h458
-rw-r--r--drivers/media/dvb/b2c2/flexcop_ibi_value_le.h458
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig23
-rw-r--r--drivers/media/dvb/bt8xx/Makefile3
-rw-r--r--drivers/media/dvb/bt8xx/bt878.c635
-rw-r--r--drivers/media/dvb/bt8xx/bt878.h166
-rw-r--r--drivers/media/dvb/bt8xx/dst.c1862
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c714
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.h58
-rw-r--r--drivers/media/dvb/bt8xx/dst_common.h187
-rw-r--r--drivers/media/dvb/bt8xx/dst_priv.h35
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c963
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.h63
-rw-r--r--drivers/media/dvb/cinergyT2/Kconfig85
-rw-r--r--drivers/media/dvb/cinergyT2/Makefile3
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c1056
-rw-r--r--drivers/media/dvb/dvb-core/Kconfig11
-rw-r--r--drivers/media/dvb/dvb-core/Makefile9
-rw-r--r--drivers/media/dvb/dvb-core/demux.h278
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c1082
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.h108
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c1771
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.h134
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c1232
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.h140
-rw-r--r--drivers/media/dvb/dvb-core/dvb_filter.c603
-rw-r--r--drivers/media/dvb/dvb-core/dvb_filter.h246
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c1122
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h163
-rw-r--r--drivers/media/dvb/dvb-core/dvb_math.c145
-rw-r--r--drivers/media/dvb/dvb-core/dvb_math.h58
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c1478
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.h46
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ringbuffer.c272
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ringbuffer.h174
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c429
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h105
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig159
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile39
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c177
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c771
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.h35
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c282
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mb.c417
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c115
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb.h124
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c272
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.h65
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u-fe.c205
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c276
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.h57
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-common.h46
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c210
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-firmware.c148
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-i2c.c125
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-ids.h110
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c210
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-remote.c187
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c324
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb.h346
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk-fe.c272
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.c256
-rw-r--r--drivers/media/dvb/dvb-usb/gp8psk.h79
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c232
-rw-r--r--drivers/media/dvb/dvb-usb/umt-010.c161
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c338
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.c291
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.h106
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045-fe.c192
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c286
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.h78
-rw-r--r--drivers/media/dvb/frontends/Kconfig239
-rw-r--r--drivers/media/dvb/frontends/Makefile35
-rw-r--r--drivers/media/dvb/frontends/bcm3510.c854
-rw-r--r--drivers/media/dvb/frontends/bcm3510.h40
-rw-r--r--drivers/media/dvb/frontends/bcm3510_priv.h460
-rw-r--r--drivers/media/dvb/frontends/bsbe1.h125
-rw-r--r--drivers/media/dvb/frontends/bsru6.h142
-rw-r--r--drivers/media/dvb/frontends/cx22700.c441
-rw-r--r--drivers/media/dvb/frontends/cx22700.h37
-rw-r--r--drivers/media/dvb/frontends/cx22702.c534
-rw-r--r--drivers/media/dvb/frontends/cx22702.h47
-rw-r--r--drivers/media/dvb/frontends/cx24110.c667
-rw-r--r--drivers/media/dvb/frontends/cx24110.h41
-rw-r--r--drivers/media/dvb/frontends/cx24123.c1023
-rw-r--r--drivers/media/dvb/frontends/cx24123.h38
-rw-r--r--drivers/media/dvb/frontends/dib3000-common.c83
-rw-r--r--drivers/media/dvb/frontends/dib3000-common.h135
-rw-r--r--drivers/media/dvb/frontends/dib3000.h49
-rw-r--r--drivers/media/dvb/frontends/dib3000mb.c770
-rw-r--r--drivers/media/dvb/frontends/dib3000mb_priv.h467
-rw-r--r--drivers/media/dvb/frontends/dib3000mc.c913
-rw-r--r--drivers/media/dvb/frontends/dib3000mc_priv.h428
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.c652
-rw-r--r--drivers/media/dvb/frontends/dvb-pll.h64
-rw-r--r--drivers/media/dvb/frontends/dvb_dummy_fe.c276
-rw-r--r--drivers/media/dvb/frontends/dvb_dummy_fe.h32
-rw-r--r--drivers/media/dvb/frontends/isl6421.c149
-rw-r--r--drivers/media/dvb/frontends/isl6421.h46
-rw-r--r--drivers/media/dvb/frontends/l64781.c603
-rw-r--r--drivers/media/dvb/frontends/l64781.h38
-rw-r--r--drivers/media/dvb/frontends/lg_h06xf.h64
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.c812
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.h64
-rw-r--r--drivers/media/dvb/frontends/lgdt330x_priv.h72
-rw-r--r--drivers/media/dvb/frontends/lnbp21.c145
-rw-r--r--drivers/media/dvb/frontends/lnbp21.h45
-rw-r--r--drivers/media/dvb/frontends/mt312.c709
-rw-r--r--drivers/media/dvb/frontends/mt312.h41
-rw-r--r--drivers/media/dvb/frontends/mt312_priv.h162
-rw-r--r--drivers/media/dvb/frontends/mt352.c608
-rw-r--r--drivers/media/dvb/frontends/mt352.h59
-rw-r--r--drivers/media/dvb/frontends/mt352_priv.h127
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c1248
-rw-r--r--drivers/media/dvb/frontends/nxt200x.h57
-rw-r--r--drivers/media/dvb/frontends/nxt6000.c610
-rw-r--r--drivers/media/dvb/frontends/nxt6000.h39
-rw-r--r--drivers/media/dvb/frontends/nxt6000_priv.h286
-rw-r--r--drivers/media/dvb/frontends/or51132.c676
-rw-r--r--drivers/media/dvb/frontends/or51132.h46
-rw-r--r--drivers/media/dvb/frontends/or51211.c636
-rw-r--r--drivers/media/dvb/frontends/or51211.h44
-rw-r--r--drivers/media/dvb/frontends/s5h1420.c835
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h40
-rw-r--r--drivers/media/dvb/frontends/sp8870.c620
-rw-r--r--drivers/media/dvb/frontends/sp8870.h41
-rw-r--r--drivers/media/dvb/frontends/sp887x.c617
-rw-r--r--drivers/media/dvb/frontends/sp887x.h23
-rw-r--r--drivers/media/dvb/frontends/stv0297.c700
-rw-r--r--drivers/media/dvb/frontends/stv0297.h48
-rw-r--r--drivers/media/dvb/frontends/stv0299.c728
-rw-r--r--drivers/media/dvb/frontends/stv0299.h97
-rw-r--r--drivers/media/dvb/frontends/tda10021.c481
-rw-r--r--drivers/media/dvb/frontends/tda10021.h40
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c1326
-rw-r--r--drivers/media/dvb/frontends/tda1004x.h82
-rw-r--r--drivers/media/dvb/frontends/tda8083.c457
-rw-r--r--drivers/media/dvb/frontends/tda8083.h41
-rw-r--r--drivers/media/dvb/frontends/ves1820.c446
-rw-r--r--drivers/media/dvb/frontends/ves1820.h47
-rw-r--r--drivers/media/dvb/frontends/ves1x93.c550
-rw-r--r--drivers/media/dvb/frontends/ves1x93.h46
-rw-r--r--drivers/media/dvb/frontends/zl10353.c333
-rw-r--r--drivers/media/dvb/frontends/zl10353.h41
-rw-r--r--drivers/media/dvb/frontends/zl10353_priv.h42
-rw-r--r--drivers/media/dvb/pluto2/Kconfig16
-rw-r--r--drivers/media/dvb/pluto2/Makefile3
-rw-r--r--drivers/media/dvb/pluto2/pluto2.c803
-rw-r--r--drivers/media/dvb/ttpci/Kconfig146
-rw-r--r--drivers/media/dvb/ttpci/Makefile23
-rw-r--r--drivers/media/dvb/ttpci/av7110.c2858
-rw-r--r--drivers/media/dvb/ttpci/av7110.h291
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.c1526
-rw-r--r--drivers/media/dvb/ttpci/av7110_av.h29
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c391
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.h14
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c1223
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.h497
-rw-r--r--drivers/media/dvb/ttpci/av7110_ipack.c403
-rw-r--r--drivers/media/dvb/ttpci/av7110_ipack.h12
-rw-r--r--drivers/media/dvb/ttpci/av7110_ir.c277
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c939
-rw-r--r--drivers/media/dvb/ttpci/budget-av.c1452
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c1185
-rw-r--r--drivers/media/dvb/ttpci/budget-core.c559
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c668
-rw-r--r--drivers/media/dvb/ttpci/budget.c547
-rw-r--r--drivers/media/dvb/ttpci/budget.h118
-rw-r--r--drivers/media/dvb/ttpci/fdump.c44
-rw-r--r--drivers/media/dvb/ttpci/ttpci-eeprom.c147
-rw-r--r--drivers/media/dvb/ttpci/ttpci-eeprom.h33
-rw-r--r--drivers/media/dvb/ttusb-budget/Kconfig19
-rw-r--r--drivers/media/dvb/ttusb-budget/Makefile3
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c1816
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h1644
-rw-r--r--drivers/media/dvb/ttusb-dec/Kconfig22
-rw-r--r--drivers/media/dvb/ttusb-dec/Makefile3
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c1762
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusbdecfe.c288
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusbdecfe.h38
198 files changed, 0 insertions, 70546 deletions
diff --git a/drivers/media/dvb/Kconfig b/drivers/media/dvb/Kconfig
deleted file mode 100644
index a97c8f5e9a5..00000000000
--- a/drivers/media/dvb/Kconfig
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Multimedia device configuration
-#
-
-menu "Digital Video Broadcasting Devices"
-
-config DVB
- bool "DVB For Linux"
- depends on NET && INET
- ---help---
- Support Digital Video Broadcasting hardware. Enable this if you
- own a DVB adapter and want to use it or if you compile Linux for
- a digital SetTopBox.
-
- API specs and user tools are available from <http://www.linuxtv.org/>.
-
- Please report problems regarding this driver to the LinuxDVB
- mailing list.
-
- If unsure say N.
-
-source "drivers/media/dvb/dvb-core/Kconfig"
-
-comment "Supported SAA7146 based PCI Adapters"
- depends on DVB_CORE && PCI && I2C
-source "drivers/media/dvb/ttpci/Kconfig"
-
-comment "Supported USB Adapters"
- depends on DVB_CORE && USB && I2C
-source "drivers/media/dvb/dvb-usb/Kconfig"
-source "drivers/media/dvb/ttusb-budget/Kconfig"
-source "drivers/media/dvb/ttusb-dec/Kconfig"
-source "drivers/media/dvb/cinergyT2/Kconfig"
-
-comment "Supported FlexCopII (B2C2) Adapters"
- depends on DVB_CORE && (PCI || USB) && I2C
-source "drivers/media/dvb/b2c2/Kconfig"
-
-comment "Supported BT878 Adapters"
- depends on DVB_CORE && PCI && I2C
-source "drivers/media/dvb/bt8xx/Kconfig"
-
-comment "Supported Pluto2 Adapters"
- depends on DVB_CORE && PCI && I2C
-source "drivers/media/dvb/pluto2/Kconfig"
-
-comment "Supported DVB Frontends"
- depends on DVB_CORE
-source "drivers/media/dvb/frontends/Kconfig"
-
-endmenu
diff --git a/drivers/media/dvb/Makefile b/drivers/media/dvb/Makefile
deleted file mode 100644
index a7ad0841e6f..00000000000
--- a/drivers/media/dvb/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-#
-# Makefile for the kernel multimedia device drivers.
-#
-
-obj-y := dvb-core/ frontends/ ttpci/ ttusb-dec/ ttusb-budget/ b2c2/ bt8xx/ cinergyT2/ dvb-usb/ pluto2/
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig
deleted file mode 100644
index 49a06fc54c5..00000000000
--- a/drivers/media/dvb/b2c2/Kconfig
+++ /dev/null
@@ -1,39 +0,0 @@
-config DVB_B2C2_FLEXCOP
- tristate "Technisat/B2C2 FlexCopII(b) and FlexCopIII adapters"
- depends on DVB_CORE && I2C
- select DVB_PLL
- select DVB_STV0299
- select DVB_MT352
- select DVB_MT312
- select DVB_NXT200X
- select DVB_STV0297
- select DVB_BCM3510
- select DVB_LGDT330X
- help
- Support for the digital TV receiver chip made by B2C2 Inc. included in
- Technisats PCI cards and USB boxes.
-
- Say Y if you own such a device and want to use it.
-
-config DVB_B2C2_FLEXCOP_PCI
- tristate "Technisat/B2C2 Air/Sky/Cable2PC PCI"
- depends on DVB_B2C2_FLEXCOP && PCI && I2C
- help
- Support for the Air/Sky/CableStar2 PCI card (DVB/ATSC) by Technisat/B2C2.
-
- Say Y if you own such a device and want to use it.
-
-config DVB_B2C2_FLEXCOP_USB
- tristate "Technisat/B2C2 Air/Sky/Cable2PC USB"
- depends on DVB_B2C2_FLEXCOP && USB && I2C
- help
- Support for the Air/Sky/Cable2PC USB1.1 box (DVB/ATSC) by Technisat/B2C2,
-
- Say Y if you own such a device and want to use it.
-
-config DVB_B2C2_FLEXCOP_DEBUG
- bool "Enable debug for the B2C2 FlexCop drivers"
- depends on DVB_B2C2_FLEXCOP
- help
- Say Y if you want to enable the module option to control debug messages
- of all B2C2 FlexCop drivers.
diff --git a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile
deleted file mode 100644
index 1a1c3bca55f..00000000000
--- a/drivers/media/dvb/b2c2/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \
- flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o \
- flexcop-dma.o
-obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o
-
-b2c2-flexcop-pci-objs = flexcop-pci.o
-obj-$(CONFIG_DVB_B2C2_FLEXCOP_PCI) += b2c2-flexcop-pci.o
-
-b2c2-flexcop-usb-objs = flexcop-usb.o
-obj-$(CONFIG_DVB_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
deleted file mode 100644
index 5a6c4fe249e..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-common.h - common header file for device-specific source files also.
- *
- * see flexcop.c for copyright information.
- */
-#ifndef __FLEXCOP_COMMON_H__
-#define __FLEXCOP_COMMON_H__
-
-#include <linux/pci.h>
-#include <linux/mutex.h>
-
-#include "flexcop-reg.h"
-
-#include "dmxdev.h"
-#include "dvb_demux.h"
-#include "dvb_filter.h"
-#include "dvb_net.h"
-#include "dvb_frontend.h"
-
-#define FC_MAX_FEED 256
-
-#ifndef FC_LOG_PREFIX
-#warning please define a log prefix for your file, using a default one
-#define FC_LOG_PREFIX "b2c2-undef"
-#endif
-
-/* Steal from usb.h */
-#undef err
-#define err(format, arg...) printk(KERN_ERR FC_LOG_PREFIX ": " format "\n" , ## arg)
-#undef info
-#define info(format, arg...) printk(KERN_INFO FC_LOG_PREFIX ": " format "\n" , ## arg)
-#undef warn
-#define warn(format, arg...) printk(KERN_WARNING FC_LOG_PREFIX ": " format "\n" , ## arg)
-
-struct flexcop_dma {
- struct pci_dev *pdev;
-
- u8 *cpu_addr0;
- dma_addr_t dma_addr0;
- u8 *cpu_addr1;
- dma_addr_t dma_addr1;
- u32 size; /* size of each address in bytes */
-};
-
-/* Control structure for data definitions that are common to
- * the B2C2-based PCI and USB devices.
- */
-struct flexcop_device {
- /* general */
- struct device *dev; /* for firmware_class */
-
-#define FC_STATE_DVB_INIT 0x01
-#define FC_STATE_I2C_INIT 0x02
-#define FC_STATE_FE_INIT 0x04
- int init_state;
-
- /* device information */
- int has_32_hw_pid_filter;
- flexcop_revision_t rev;
- flexcop_device_type_t dev_type;
- flexcop_bus_t bus_type;
-
- /* dvb stuff */
- struct dvb_adapter dvb_adapter;
- struct dvb_frontend *fe;
- struct dvb_net dvbnet;
- struct dvb_demux demux;
- struct dmxdev dmxdev;
- struct dmx_frontend hw_frontend;
- struct dmx_frontend mem_frontend;
- int (*fe_sleep) (struct dvb_frontend *);
-
- struct i2c_adapter i2c_adap;
- struct mutex i2c_mutex;
- struct module *owner;
-
- /* options and status */
- int extra_feedcount;
- int feedcount;
- int pid_filtering;
- int fullts_streaming_state;
-
- /* bus specific callbacks */
- flexcop_ibi_value (*read_ibi_reg) (struct flexcop_device *, flexcop_ibi_register);
- int (*write_ibi_reg) (struct flexcop_device *, flexcop_ibi_register, flexcop_ibi_value);
-
-
- int (*i2c_request) (struct flexcop_device*, flexcop_access_op_t, flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len);
- int (*stream_control) (struct flexcop_device*, int);
-
- int (*get_mac_addr) (struct flexcop_device *fc, int extended);
-
- void *bus_specific;
-};
-
-/* exported prototypes */
-
-/* from flexcop.c */
-void flexcop_pass_dmx_data(struct flexcop_device *fc, u8 *buf, u32 len);
-void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no);
-
-struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len);
-void flexcop_device_kfree(struct flexcop_device*);
-
-int flexcop_device_initialize(struct flexcop_device*);
-void flexcop_device_exit(struct flexcop_device *fc);
-
-void flexcop_reset_block_300(struct flexcop_device *fc);
-
-/* from flexcop-dma.c */
-int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size);
-void flexcop_dma_free(struct flexcop_dma *dma);
-
-int flexcop_dma_control_timer_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
-int flexcop_dma_control_size_irq(struct flexcop_device *fc, flexcop_dma_index_t no, int onoff);
-int flexcop_dma_config(struct flexcop_device *fc, struct flexcop_dma *dma, flexcop_dma_index_t dma_idx);
-int flexcop_dma_xfer_control(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, flexcop_dma_addr_index_t index, int onoff);
-int flexcop_dma_config_timer(struct flexcop_device *fc, flexcop_dma_index_t dma_idx, u8 cycles);
-
-/* from flexcop-eeprom.c */
-/* the PCI part uses this call to get the MAC address, the USB part has its own */
-int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended);
-
-/* from flexcop-i2c.c */
-/* the PCI part uses this a i2c_request callback, whereas the usb part has its own
- * one. We have it in flexcop-i2c.c, because it is going via the actual
- * I2C-channel of the flexcop.
- */
-int flexcop_i2c_request(struct flexcop_device*, flexcop_access_op_t,
- flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len);
-
-/* from flexcop-sram.c */
-int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target);
-void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s);
-void flexcop_sram_ctrl(struct flexcop_device *fc, int usb_wan, int sramdma, int maximumfill);
-
-/* global prototypes for the flexcop-chip */
-/* from flexcop-fe-tuner.c */
-int flexcop_frontend_init(struct flexcop_device *card);
-void flexcop_frontend_exit(struct flexcop_device *fc);
-
-/* from flexcop-i2c.c */
-int flexcop_i2c_init(struct flexcop_device *fc);
-void flexcop_i2c_exit(struct flexcop_device *fc);
-
-/* from flexcop-sram.c */
-int flexcop_sram_init(struct flexcop_device *fc);
-
-/* from flexcop-misc.c */
-void flexcop_determine_revision(struct flexcop_device *fc);
-void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const char *suffix);
-void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num);
-
-/* from flexcop-hw-filter.c */
-int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff);
-void flexcop_hw_filter_init(struct flexcop_device *fc);
-
-void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff);
-
-void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6]);
-void flexcop_mac_filter_ctrl(struct flexcop_device *fc, int onoff);
-
-#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-dma.c b/drivers/media/dvb/b2c2/flexcop-dma.c
deleted file mode 100644
index 6f592bc32d2..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-dma.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-dma.c - methods for configuring and controlling the DMA of the FlexCop.
- *
- * see flexcop.c for copyright information.
- */
-#include "flexcop.h"
-
-int flexcop_dma_allocate(struct pci_dev *pdev, struct flexcop_dma *dma, u32 size)
-{
- u8 *tcpu;
- dma_addr_t tdma;
-
- if (size % 2) {
- err("dma buffersize has to be even.");
- return -EINVAL;
- }
-
- if ((tcpu = pci_alloc_consistent(pdev, size, &tdma)) != NULL) {
- dma->pdev = pdev;
- dma->cpu_addr0 = tcpu;
- dma->dma_addr0 = tdma;
- dma->cpu_addr1 = tcpu + size/2;
- dma->dma_addr1 = tdma + size/2;
- dma->size = size/2;
- return 0;
- }
- return -ENOMEM;
-}
-EXPORT_SYMBOL(flexcop_dma_allocate);
-
-void flexcop_dma_free(struct flexcop_dma *dma)
-{
- pci_free_consistent(dma->pdev, dma->size*2,dma->cpu_addr0, dma->dma_addr0);
- memset(dma,0,sizeof(struct flexcop_dma));
-}
-EXPORT_SYMBOL(flexcop_dma_free);
-
-int flexcop_dma_config(struct flexcop_device *fc,
- struct flexcop_dma *dma,
- flexcop_dma_index_t dma_idx)
-{
- flexcop_ibi_value v0x0,v0x4,v0xc;
- v0x0.raw = v0x4.raw = v0xc.raw = 0;
-
- v0x0.dma_0x0.dma_address0 = dma->dma_addr0 >> 2;
- v0xc.dma_0xc.dma_address1 = dma->dma_addr1 >> 2;
- v0x4.dma_0x4_write.dma_addr_size = dma->size / 4;
-
- if ((dma_idx & FC_DMA_1) == dma_idx) {
- fc->write_ibi_reg(fc,dma1_000,v0x0);
- fc->write_ibi_reg(fc,dma1_004,v0x4);
- fc->write_ibi_reg(fc,dma1_00c,v0xc);
- } else if ((dma_idx & FC_DMA_2) == dma_idx) {
- fc->write_ibi_reg(fc,dma2_010,v0x0);
- fc->write_ibi_reg(fc,dma2_014,v0x4);
- fc->write_ibi_reg(fc,dma2_01c,v0xc);
- } else {
- err("either DMA1 or DMA2 can be configured at the within one flexcop_dma_config call.");
- return -EINVAL;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(flexcop_dma_config);
-
-/* start the DMA transfers, but not the DMA IRQs */
-int flexcop_dma_xfer_control(struct flexcop_device *fc,
- flexcop_dma_index_t dma_idx,
- flexcop_dma_addr_index_t index,
- int onoff)
-{
- flexcop_ibi_value v0x0,v0xc;
- flexcop_ibi_register r0x0,r0xc;
-
- if ((dma_idx & FC_DMA_1) == dma_idx) {
- r0x0 = dma1_000;
- r0xc = dma1_00c;
- } else if ((dma_idx & FC_DMA_2) == dma_idx) {
- r0x0 = dma2_010;
- r0xc = dma2_01c;
- } else {
- err("either transfer DMA1 or DMA2 can be started within one flexcop_dma_xfer_control call.");
- return -EINVAL;
- }
-
- v0x0 = fc->read_ibi_reg(fc,r0x0);
- v0xc = fc->read_ibi_reg(fc,r0xc);
-
- deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw);
- deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw);
-
- if (index & FC_DMA_SUBADDR_0)
- v0x0.dma_0x0.dma_0start = onoff;
-
- if (index & FC_DMA_SUBADDR_1)
- v0xc.dma_0xc.dma_1start = onoff;
-
- fc->write_ibi_reg(fc,r0x0,v0x0);
- fc->write_ibi_reg(fc,r0xc,v0xc);
-
- deb_rdump("reg: %03x: %x\n",r0x0,v0x0.raw);
- deb_rdump("reg: %03x: %x\n",r0xc,v0xc.raw);
- return 0;
-}
-EXPORT_SYMBOL(flexcop_dma_xfer_control);
-
-static int flexcop_dma_remap(struct flexcop_device *fc,
- flexcop_dma_index_t dma_idx,
- int onoff)
-{
- flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c;
- flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
- deb_info("%s\n",__FUNCTION__);
- v.dma_0xc.remap_enable = onoff;
- fc->write_ibi_reg(fc,r,v);
- return 0;
-}
-
-int flexcop_dma_control_size_irq(struct flexcop_device *fc,
- flexcop_dma_index_t no,
- int onoff)
-{
- flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
-
- if (no & FC_DMA_1)
- v.ctrl_208.DMA1_IRQ_Enable_sig = onoff;
-
- if (no & FC_DMA_2)
- v.ctrl_208.DMA2_IRQ_Enable_sig = onoff;
-
- fc->write_ibi_reg(fc,ctrl_208,v);
- return 0;
-}
-EXPORT_SYMBOL(flexcop_dma_control_size_irq);
-
-int flexcop_dma_control_timer_irq(struct flexcop_device *fc,
- flexcop_dma_index_t no,
- int onoff)
-{
- flexcop_ibi_value v = fc->read_ibi_reg(fc,ctrl_208);
-
- if (no & FC_DMA_1)
- v.ctrl_208.DMA1_Timer_Enable_sig = onoff;
-
- if (no & FC_DMA_2)
- v.ctrl_208.DMA2_Timer_Enable_sig = onoff;
-
- fc->write_ibi_reg(fc,ctrl_208,v);
- return 0;
-}
-EXPORT_SYMBOL(flexcop_dma_control_timer_irq);
-
-/* 1 cycles = 1.97 msec */
-int flexcop_dma_config_timer(struct flexcop_device *fc,
- flexcop_dma_index_t dma_idx,
- u8 cycles)
-{
- flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_004 : dma2_014;
- flexcop_ibi_value v = fc->read_ibi_reg(fc,r);
-
- flexcop_dma_remap(fc,dma_idx,0);
-
- deb_info("%s\n",__FUNCTION__);
- v.dma_0x4_write.dmatimer = cycles;
- fc->write_ibi_reg(fc,r,v);
- return 0;
-}
-EXPORT_SYMBOL(flexcop_dma_config_timer);
-
diff --git a/drivers/media/dvb/b2c2/flexcop-eeprom.c b/drivers/media/dvb/b2c2/flexcop-eeprom.c
deleted file mode 100644
index bbcf070a178..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-eeprom.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-eeprom.c - eeprom access methods (currently only MAC address reading is used)
- *
- * see flexcop.c for copyright information.
- */
-#include "flexcop.h"
-
-#if 0
-/*EEPROM (Skystar2 has one "24LC08B" chip on board) */
-static int eeprom_write(struct adapter *adapter, u16 addr, u8 *buf, u16 len)
-{
- return flex_i2c_write(adapter, 0x20000000, 0x50, addr, buf, len);
-}
-
-static int eeprom_lrc_write(struct adapter *adapter, u32 addr, u32 len, u8 *wbuf, u8 *rbuf, int retries)
-{
- int i;
-
- for (i = 0; i < retries; i++) {
- if (eeprom_write(adapter, addr, wbuf, len) == len) {
- if (eeprom_lrc_read(adapter, addr, len, rbuf, retries) == 1)
- return 1;
- }
- }
-
- return 0;
-}
-
-/* These functions could be used to unlock SkyStar2 cards. */
-
-static int eeprom_writeKey(struct adapter *adapter, u8 *key, u32 len)
-{
- u8 rbuf[20];
- u8 wbuf[20];
-
- if (len != 16)
- return 0;
-
- memcpy(wbuf, key, len);
-
- wbuf[16] = 0;
- wbuf[17] = 0;
- wbuf[18] = 0;
- wbuf[19] = calc_lrc(wbuf, 19);
-
- return eeprom_lrc_write(adapter, 0x3e4, 20, wbuf, rbuf, 4);
-}
-
-static int eeprom_readKey(struct adapter *adapter, u8 *key, u32 len)
-{
- u8 buf[20];
-
- if (len != 16)
- return 0;
-
- if (eeprom_lrc_read(adapter, 0x3e4, 20, buf, 4) == 0)
- return 0;
-
- memcpy(key, buf, len);
-
- return 1;
-}
-
-static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
-{
- u8 tmp[8];
-
- if (type != 0) {
- tmp[0] = mac[0];
- tmp[1] = mac[1];
- tmp[2] = mac[2];
- tmp[3] = mac[5];
- tmp[4] = mac[6];
- tmp[5] = mac[7];
-
- } else {
-
- tmp[0] = mac[0];
- tmp[1] = mac[1];
- tmp[2] = mac[2];
- tmp[3] = mac[3];
- tmp[4] = mac[4];
- tmp[5] = mac[5];
- }
-
- tmp[6] = 0;
- tmp[7] = calc_lrc(tmp, 7);
-
- if (eeprom_write(adapter, 0x3f8, tmp, 8) == 8)
- return 1;
-
- return 0;
-}
-
-static int flexcop_eeprom_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len)
-{
- return fc->i2c_request(fc,FC_READ,FC_I2C_PORT_EEPROM,0x50,addr,buf,len);
-}
-
-#endif
-
-static u8 calc_lrc(u8 *buf, int len)
-{
- int i;
- u8 sum = 0;
- for (i = 0; i < len; i++)
- sum = sum ^ buf[i];
- return sum;
-}
-
-static int flexcop_eeprom_request(struct flexcop_device *fc, flexcop_access_op_t op, u16 addr, u8 *buf, u16 len, int retries)
-{
- int i,ret = 0;
- u8 chipaddr = 0x50 | ((addr >> 8) & 3);
- for (i = 0; i < retries; i++)
- if ((ret = fc->i2c_request(fc,op,FC_I2C_PORT_EEPROM,chipaddr,addr & 0xff,buf,len)) == 0)
- break;
- return ret;
-}
-
-static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len, int retries)
-{
- int ret = flexcop_eeprom_request(fc,FC_READ,addr,buf,len,retries);
- if (ret == 0)
- if (calc_lrc(buf, len - 1) != buf[len - 1])
- ret = -EINVAL;
- return ret;
-}
-
-/* JJ's comment about extended == 1: it is not presently used anywhere but was
- * added to the low-level functions for possible support of EUI64
- */
-int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
-{
- u8 buf[8];
- int ret = 0;
-
- if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) {
- if (extended != 0) {
- err("TODO: extended (EUI64) MAC addresses aren't completely supported yet");
- ret = -EINVAL;
-/* memcpy(fc->dvb_adapter.proposed_mac,buf,3);
- mac[3] = 0xfe;
- mac[4] = 0xff;
- memcpy(&fc->dvb_adapter.proposed_mac[3],&buf[5],3); */
- } else
- memcpy(fc->dvb_adapter.proposed_mac,buf,6);
- }
- return ret;
-}
-EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr);
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
deleted file mode 100644
index 3be87c72e37..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-fe-tuner.c - methods for attaching a frontend and controlling DiSEqC.
- *
- * see flexcop.c for copyright information.
- */
-#include "flexcop.h"
-
-#include "stv0299.h"
-#include "mt352.h"
-#include "nxt200x.h"
-#include "bcm3510.h"
-#include "stv0297.h"
-#include "mt312.h"
-#include "lgdt330x.h"
-#include "lg_h06xf.h"
-#include "dvb-pll.h"
-
-/* lnb control */
-
-static int flexcop_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
-{
- struct flexcop_device *fc = fe->dvb->priv;
- flexcop_ibi_value v;
- deb_tuner("polarity/voltage = %u\n", voltage);
-
- v = fc->read_ibi_reg(fc, misc_204);
- switch (voltage) {
- case SEC_VOLTAGE_OFF:
- v.misc_204.ACPI1_sig = 1;
- break;
- case SEC_VOLTAGE_13:
- v.misc_204.ACPI1_sig = 0;
- v.misc_204.LNB_L_H_sig = 0;
- break;
- case SEC_VOLTAGE_18:
- v.misc_204.ACPI1_sig = 0;
- v.misc_204.LNB_L_H_sig = 1;
- break;
- default:
- err("unknown SEC_VOLTAGE value");
- return -EINVAL;
- }
- return fc->write_ibi_reg(fc, misc_204, v);
-}
-
-static int flexcop_sleep(struct dvb_frontend* fe)
-{
- struct flexcop_device *fc = fe->dvb->priv;
-/* flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204); */
-
- if (fc->fe_sleep)
- return fc->fe_sleep(fe);
-
-/* v.misc_204.ACPI3_sig = 1;
- fc->write_ibi_reg(fc,misc_204,v);*/
-
- return 0;
-}
-
-static int flexcop_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
-{
- /* u16 wz_half_period_for_45_mhz[] = { 0x01ff, 0x0154, 0x00ff, 0x00cc }; */
- struct flexcop_device *fc = fe->dvb->priv;
- flexcop_ibi_value v;
- u16 ax;
- v.raw = 0;
-
- deb_tuner("tone = %u\n",tone);
-
- switch (tone) {
- case SEC_TONE_ON:
- ax = 0x01ff;
- break;
- case SEC_TONE_OFF:
- ax = 0;
- break;
- default:
- err("unknown SEC_TONE value");
- return -EINVAL;
- }
-
- v.lnb_switch_freq_200.LNB_CTLPrescaler_sig = 1; /* divide by 2 */
-
- v.lnb_switch_freq_200.LNB_CTLHighCount_sig = ax;
- v.lnb_switch_freq_200.LNB_CTLLowCount_sig = ax == 0 ? 0x1ff : ax;
-
- return fc->write_ibi_reg(fc,lnb_switch_freq_200,v);
-}
-
-static void flexcop_diseqc_send_bit(struct dvb_frontend* fe, int data)
-{
- flexcop_set_tone(fe, SEC_TONE_ON);
- udelay(data ? 500 : 1000);
- flexcop_set_tone(fe, SEC_TONE_OFF);
- udelay(data ? 1000 : 500);
-}
-
-static void flexcop_diseqc_send_byte(struct dvb_frontend* fe, int data)
-{
- int i, par = 1, d;
-
- for (i = 7; i >= 0; i--) {
- d = (data >> i) & 1;
- par ^= d;
- flexcop_diseqc_send_bit(fe, d);
- }
-
- flexcop_diseqc_send_bit(fe, par);
-}
-
-static int flexcop_send_diseqc_msg(struct dvb_frontend* fe, int len, u8 *msg, unsigned long burst)
-{
- int i;
-
- flexcop_set_tone(fe, SEC_TONE_OFF);
- mdelay(16);
-
- for (i = 0; i < len; i++)
- flexcop_diseqc_send_byte(fe,msg[i]);
-
- mdelay(16);
-
- if (burst != -1) {
- if (burst)
- flexcop_diseqc_send_byte(fe, 0xff);
- else {
- flexcop_set_tone(fe, SEC_TONE_ON);
- udelay(12500);
- flexcop_set_tone(fe, SEC_TONE_OFF);
- }
- msleep(20);
- }
- return 0;
-}
-
-static int flexcop_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
-{
- return flexcop_send_diseqc_msg(fe, cmd->msg_len, cmd->msg, 0);
-}
-
-static int flexcop_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
-{
- return flexcop_send_diseqc_msg(fe, 0, NULL, minicmd);
-}
-
-/* dvb-s stv0299 */
-static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
-{
- u8 aclk = 0;
- u8 bclk = 0;
-
- if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
- else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
- else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
- else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
- else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
- else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
-
- stv0299_writereg (fe, 0x13, aclk);
- stv0299_writereg (fe, 0x14, bclk);
- stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
-
- return 0;
-}
-
-static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- u8 buf[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
- struct flexcop_device *fc = fe->dvb->priv;
-
- div = params->frequency / 125;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x84; /* 0xC4 */
- buf[3] = 0x08;
-
- if (params->frequency < 1500000) buf[3] |= 0x10;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) {
- return -EIO;
- }
- return 0;
-}
-
-static u8 samsung_tbmu24112_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7D,
- 0x05, 0x35,
- 0x06, 0x02,
- 0x07, 0x00,
- 0x08, 0xC3,
- 0x0C, 0x00,
- 0x0D, 0x81,
- 0x0E, 0x23,
- 0x0F, 0x12,
- 0x10, 0x7E,
- 0x11, 0x84,
- 0x12, 0xB9,
- 0x13, 0x88,
- 0x14, 0x89,
- 0x15, 0xC9,
- 0x16, 0x00,
- 0x17, 0x5C,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1A, 0x00,
- 0x1C, 0x00,
- 0x1D, 0x00,
- 0x1E, 0x00,
- 0x1F, 0x3A,
- 0x20, 0x2E,
- 0x21, 0x80,
- 0x22, 0xFF,
- 0x23, 0xC1,
- 0x28, 0x00,
- 0x29, 0x1E,
- 0x2A, 0x14,
- 0x2B, 0x0F,
- 0x2C, 0x09,
- 0x2D, 0x05,
- 0x31, 0x1F,
- 0x32, 0x19,
- 0x33, 0xFE,
- 0x34, 0x93,
- 0xff, 0xff,
-};
-
-static struct stv0299_config samsung_tbmu24112_config = {
- .demod_address = 0x68,
- .inittab = samsung_tbmu24112_inittab,
- .mclk = 88000000UL,
- .invert = 0,
- .skip_reinit = 0,
- .lock_output = STV0229_LOCKOUTPUT_LK,
- .volt13_op0_op1 = STV0299_VOLT13_OP1,
- .min_delay_ms = 100,
- .set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
-};
-
-/* dvb-t mt352 */
-static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
-{
- static u8 mt352_clock_config [] = { 0x89, 0x18, 0x2d };
- static u8 mt352_reset [] = { 0x50, 0x80 };
- static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
- static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
- static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
-
- mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
- udelay(2000);
- mt352_write(fe, mt352_reset, sizeof(mt352_reset));
- mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
-
- mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
- mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
-
- return 0;
-}
-
-static int samsung_tdtc9251dh0_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
-{
- u32 div;
- unsigned char bs = 0;
-
- if (buf_len < 5)
- return -EINVAL;
-
- #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
-
- if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
- if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
- if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
-
- pllbuf[0] = 0x61;
- pllbuf[1] = div >> 8;
- pllbuf[2] = div & 0xff;
- pllbuf[3] = 0xcc;
- pllbuf[4] = bs;
-
- return 5;
-}
-
-static struct mt352_config samsung_tdtc9251dh0_config = {
- .demod_address = 0x0f,
- .demod_init = samsung_tdtc9251dh0_demod_init,
-};
-
-static int flexcop_fe_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
-{
- struct flexcop_device *fc = fe->dvb->priv;
- return request_firmware(fw, name, fc->dev);
-}
-
-static int lgdt3303_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct flexcop_device *fc = fe->dvb->priv;
- return lg_h06xf_pll_set(fe, &fc->i2c_adap, params);
-}
-
-static struct lgdt330x_config air2pc_atsc_hd5000_config = {
- .demod_address = 0x59,
- .demod_chip = LGDT3303,
- .serial_mpeg = 0x04,
- .clock_polarity_flip = 1,
-};
-
-static struct nxt200x_config samsung_tbmv_config = {
- .demod_address = 0x0a,
-};
-
-static struct bcm3510_config air2pc_atsc_first_gen_config = {
- .demod_address = 0x0f,
- .request_firmware = flexcop_fe_request_firmware,
-};
-
-static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- u8 buf[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
- struct flexcop_device *fc = fe->dvb->priv;
-
- div = (params->frequency + (125/2)) / 125;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = (div >> 0) & 0xff;
- buf[2] = 0x84 | ((div >> 10) & 0x60);
- buf[3] = 0x80;
-
- if (params->frequency < 1550000)
- buf[3] |= 0x02;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct mt312_config skystar23_samsung_tbdu18132_config = {
-
- .demod_address = 0x0e,
-};
-
-static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct flexcop_device *fc = fe->dvb->priv;
- u8 buf[4];
- u16 div;
- int ret;
-
-/* 62.5 kHz * 10 */
-#define REF_FREQ 625
-#define FREQ_OFFSET 36125
-
- div = ((fep->frequency/1000 + FREQ_OFFSET ) * 10) / REF_FREQ; // 4 MHz = 4000 KHz
-
- buf[0] = (u8)( div >> 8) & 0x7f;
- buf[1] = (u8) div & 0xff;
-
-/* F(osc) = N * Reference Freq. (62.5 kHz)
- * byte 2 : 0 N14 N13 N12 N11 N10 N9 N8
- * byte 3 : N7 N6 N5 N4 N3 N2 N1 N0
- * byte 4 : 1 * * AGD R3 R2 R1 R0
- * byte 5 : C1 * RE RTS BS4 BS3 BS2 BS1
- * AGD = 1, R3 R2 R1 R0 = 0 1 0 1 => byte 4 = 1**10101 = 0x95 */
- buf[2] = 0x95;
-
-// Range(MHz) C1 * RE RTS BS4 BS3 BS2 BS1 Byte 5
-// 47 - 153 0 * 0 0 0 0 0 1 0x01
-// 153 - 430 0 * 0 0 0 0 1 0 0x02
-// 430 - 822 0 * 0 0 1 0 0 0 0x08
-// 822 - 862 1 * 0 0 1 0 0 0 0x88
-
- if (fep->frequency <= 153000000) buf[3] = 0x01;
- else if (fep->frequency <= 430000000) buf[3] = 0x02;
- else if (fep->frequency <= 822000000) buf[3] = 0x08;
- else buf[3] = 0x88;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]);
- ret = fc->i2c_request(fc,FC_WRITE,FC_I2C_PORT_TUNER,0x61,buf[0],&buf[1],3);
- deb_tuner("tuner write returned: %d\n",ret);
-
- return 0;
-}
-
-static u8 alps_tdee4_stv0297_inittab[] = {
- 0x80, 0x01,
- 0x80, 0x00,
- 0x81, 0x01,
- 0x81, 0x00,
- 0x00, 0x09,
- 0x01, 0x69,
- 0x03, 0x00,
- 0x04, 0x00,
- 0x07, 0x00,
- 0x08, 0x00,
- 0x20, 0x00,
- 0x21, 0x40,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x24, 0x40,
- 0x25, 0x88,
- 0x30, 0xff,
- 0x31, 0x00,
- 0x32, 0xff,
- 0x33, 0x00,
- 0x34, 0x50,
- 0x35, 0x7f,
- 0x36, 0x00,
- 0x37, 0x20,
- 0x38, 0x00,
- 0x40, 0x1c,
- 0x41, 0xff,
- 0x42, 0x29,
- 0x43, 0x00,
- 0x44, 0xff,
- 0x45, 0x00,
- 0x46, 0x00,
- 0x49, 0x04,
- 0x4a, 0x00,
- 0x4b, 0xf8,
- 0x52, 0x30,
- 0x55, 0xae,
- 0x56, 0x47,
- 0x57, 0xe1,
- 0x58, 0x3a,
- 0x5a, 0x1e,
- 0x5b, 0x34,
- 0x60, 0x00,
- 0x63, 0x00,
- 0x64, 0x00,
- 0x65, 0x00,
- 0x66, 0x00,
- 0x67, 0x00,
- 0x68, 0x00,
- 0x69, 0x00,
- 0x6a, 0x02,
- 0x6b, 0x00,
- 0x70, 0xff,
- 0x71, 0x00,
- 0x72, 0x00,
- 0x73, 0x00,
- 0x74, 0x0c,
- 0x80, 0x00,
- 0x81, 0x00,
- 0x82, 0x00,
- 0x83, 0x00,
- 0x84, 0x04,
- 0x85, 0x80,
- 0x86, 0x24,
- 0x87, 0x78,
- 0x88, 0x10,
- 0x89, 0x00,
- 0x90, 0x01,
- 0x91, 0x01,
- 0xa0, 0x04,
- 0xa1, 0x00,
- 0xa2, 0x00,
- 0xb0, 0x91,
- 0xb1, 0x0b,
- 0xc0, 0x53,
- 0xc1, 0x70,
- 0xc2, 0x12,
- 0xd0, 0x00,
- 0xd1, 0x00,
- 0xd2, 0x00,
- 0xd3, 0x00,
- 0xd4, 0x00,
- 0xd5, 0x00,
- 0xde, 0x00,
- 0xdf, 0x00,
- 0x61, 0x49,
- 0x62, 0x0b,
- 0x53, 0x08,
- 0x59, 0x08,
- 0xff, 0xff,
-};
-
-static struct stv0297_config alps_tdee4_stv0297_config = {
- .demod_address = 0x1c,
- .inittab = alps_tdee4_stv0297_inittab,
-// .invert = 1,
-// .pll_set = alps_tdee4_stv0297_pll_set,
-};
-
-/* try to figure out the frontend, each card/box can have on of the following list */
-int flexcop_frontend_init(struct flexcop_device *fc)
-{
- struct dvb_frontend_ops *ops;
-
- /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */
- if ((fc->fe = stv0299_attach(&samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) {
- ops = &fc->fe->ops;
-
- ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params;
-
- ops->set_voltage = flexcop_set_voltage;
-
- fc->fe_sleep = ops->sleep;
- ops->sleep = flexcop_sleep;
-
- fc->dev_type = FC_SKY;
- info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address);
- } else
- /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */
- if ((fc->fe = mt352_attach(&samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) {
- fc->dev_type = FC_AIR_DVB;
- fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs;
- info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address);
- } else
- /* try the air atsc 2nd generation (nxt2002) */
- if ((fc->fe = nxt200x_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) {
- fc->dev_type = FC_AIR_ATSC2;
- dvb_pll_attach(fc->fe, 0x61, &fc->i2c_adap, &dvb_pll_samsung_tbmv);
- info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address);
- } else
- /* try the air atsc 3nd generation (lgdt3303) */
- if ((fc->fe = lgdt330x_attach(&air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) {
- fc->dev_type = FC_AIR_ATSC3;
- fc->fe->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
- info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address);
- } else
- /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */
- if ((fc->fe = bcm3510_attach(&air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) {
- fc->dev_type = FC_AIR_ATSC1;
- info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address);
- } else
- /* try the cable dvb (stv0297) */
- if ((fc->fe = stv0297_attach(&alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) {
- fc->dev_type = FC_CABLE;
- fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params;
- info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
- } else
- /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
- if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
- ops = &fc->fe->ops;
-
- ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params;
-
- ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
- ops->diseqc_send_burst = flexcop_diseqc_send_burst;
- ops->set_tone = flexcop_set_tone;
- ops->set_voltage = flexcop_set_voltage;
-
- fc->fe_sleep = ops->sleep;
- ops->sleep = flexcop_sleep;
-
- fc->dev_type = FC_SKY_OLD;
- info("found the vp310 (aka mt312) at i2c address: 0x%02x",skystar23_samsung_tbdu18132_config.demod_address);
- }
-
- if (fc->fe == NULL) {
- err("no frontend driver found for this B2C2/FlexCop adapter");
- return -ENODEV;
- } else {
- if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) {
- err("frontend registration failed!");
- ops = &fc->fe->ops;
- if (ops->release != NULL)
- ops->release(fc->fe);
- fc->fe = NULL;
- return -EINVAL;
- }
- }
- fc->init_state |= FC_STATE_FE_INIT;
- return 0;
-}
-
-void flexcop_frontend_exit(struct flexcop_device *fc)
-{
- if (fc->init_state & FC_STATE_FE_INIT)
- dvb_unregister_frontend(fc->fe);
-
- fc->init_state &= ~FC_STATE_FE_INIT;
-}
diff --git a/drivers/media/dvb/b2c2/flexcop-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
deleted file mode 100644
index b386cc66c6b..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-hw-filter.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-hw-filter.c - pid and mac address filtering and corresponding control functions.
- *
- * see flexcop.c for copyright information.
- */
-#include "flexcop.h"
-
-static void flexcop_rcv_data_ctrl(struct flexcop_device *fc, int onoff)
-{
- flexcop_set_ibi_value(ctrl_208,Rcv_Data_sig,onoff);
-
- deb_ts("rcv_data is now: '%s'\n",onoff ? "on" : "off");
-}
-
-void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
-{
- flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff);
-}
-
-static void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff)
-{
- flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff);
-}
-
-void flexcop_set_mac_filter(struct flexcop_device *fc, u8 mac[6])
-{
- flexcop_ibi_value v418,v41c;
- v41c = fc->read_ibi_reg(fc,mac_address_41c);
-
- v418.mac_address_418.MAC1 = mac[0];
- v418.mac_address_418.MAC2 = mac[1];
- v418.mac_address_418.MAC3 = mac[2];
- v418.mac_address_418.MAC6 = mac[3];
- v41c.mac_address_41c.MAC7 = mac[4];
- v41c.mac_address_41c.MAC8 = mac[5];
-
- fc->write_ibi_reg(fc,mac_address_418,v418);
- fc->write_ibi_reg(fc,mac_address_41c,v41c);
-}
-
-void flexcop_mac_filter_ctrl(struct flexcop_device *fc, int onoff)
-{
- flexcop_set_ibi_value(ctrl_208,MAC_filter_Mode_sig,onoff);
-}
-
-static void flexcop_pid_group_filter(struct flexcop_device *fc, u16 pid, u16 mask)
-{
- /* index_reg_310.extra_index_reg need to 0 or 7 to work */
- flexcop_ibi_value v30c;
- v30c.pid_filter_30c_ext_ind_0_7.Group_PID = pid;
- v30c.pid_filter_30c_ext_ind_0_7.Group_mask = mask;
- fc->write_ibi_reg(fc,pid_filter_30c,v30c);
-}
-
-static void flexcop_pid_group_filter_ctrl(struct flexcop_device *fc, int onoff)
-{
- flexcop_set_ibi_value(ctrl_208,Mask_filter_sig,onoff);
-}
-
-/* this fancy define reduces the code size of the quite similar PID controlling of
- * the first 6 PIDs
- */
-
-#define pid_ctrl(vregname,field,enablefield,trans_field,transval) \
- flexcop_ibi_value vpid = fc->read_ibi_reg(fc, vregname), \
- v208 = fc->read_ibi_reg(fc, ctrl_208); \
-\
- vpid.vregname.field = onoff ? pid : 0x1fff; \
- vpid.vregname.trans_field = transval; \
- v208.ctrl_208.enablefield = onoff; \
-\
- fc->write_ibi_reg(fc,vregname,vpid); \
- fc->write_ibi_reg(fc,ctrl_208,v208);
-
-static void flexcop_pid_Stream1_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
-{
- pid_ctrl(pid_filter_300,Stream1_PID,Stream1_filter_sig,Stream1_trans,0);
-}
-
-static void flexcop_pid_Stream2_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
-{
- pid_ctrl(pid_filter_300,Stream2_PID,Stream2_filter_sig,Stream2_trans,0);
-}
-
-static void flexcop_pid_PCR_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
-{
- pid_ctrl(pid_filter_304,PCR_PID,PCR_filter_sig,PCR_trans,0);
-}
-
-static void flexcop_pid_PMT_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
-{
- pid_ctrl(pid_filter_304,PMT_PID,PMT_filter_sig,PMT_trans,0);
-}
-
-static void flexcop_pid_EMM_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
-{
- pid_ctrl(pid_filter_308,EMM_PID,EMM_filter_sig,EMM_trans,0);
-}
-
-static void flexcop_pid_ECM_PID_ctrl(struct flexcop_device *fc, u16 pid, int onoff)
-{
- pid_ctrl(pid_filter_308,ECM_PID,ECM_filter_sig,ECM_trans,0);
-}
-
-static void flexcop_pid_control(struct flexcop_device *fc, int index, u16 pid,int onoff)
-{
- if (pid == 0x2000)
- return;
-
- deb_ts("setting pid: %5d %04x at index %d '%s'\n",pid,pid,index,onoff ? "on" : "off");
-
- /* We could use bit magic here to reduce source code size.
- * I decided against it, but to use the real register names */
- switch (index) {
- case 0: flexcop_pid_Stream1_PID_ctrl(fc,pid,onoff); break;
- case 1: flexcop_pid_Stream2_PID_ctrl(fc,pid,onoff); break;
- case 2: flexcop_pid_PCR_PID_ctrl(fc,pid,onoff); break;
- case 3: flexcop_pid_PMT_PID_ctrl(fc,pid,onoff); break;
- case 4: flexcop_pid_EMM_PID_ctrl(fc,pid,onoff); break;
- case 5: flexcop_pid_ECM_PID_ctrl(fc,pid,onoff); break;
- default:
- if (fc->has_32_hw_pid_filter && index < 38) {
- flexcop_ibi_value vpid,vid;
-
- /* set the index */
- vid = fc->read_ibi_reg(fc,index_reg_310);
- vid.index_reg_310.index_reg = index - 6;
- fc->write_ibi_reg(fc,index_reg_310, vid);
-
- vpid = fc->read_ibi_reg(fc,pid_n_reg_314);
- vpid.pid_n_reg_314.PID = onoff ? pid : 0x1fff;
- vpid.pid_n_reg_314.PID_enable_bit = onoff;
- fc->write_ibi_reg(fc,pid_n_reg_314, vpid);
- }
- break;
- }
-}
-
-static int flexcop_toggle_fullts_streaming(struct flexcop_device *fc,int onoff)
-{
- if (fc->fullts_streaming_state != onoff) {
- deb_ts("%s full TS transfer\n",onoff ? "enabling" : "disabling");
- flexcop_pid_group_filter(fc, 0, 0x1fe0 * (!onoff));
- flexcop_pid_group_filter_ctrl(fc,onoff);
- fc->fullts_streaming_state = onoff;
- }
- return 0;
-}
-
-int flexcop_pid_feed_control(struct flexcop_device *fc, struct dvb_demux_feed *dvbdmxfeed, int onoff)
-{
- int max_pid_filter = 6 + fc->has_32_hw_pid_filter*32;
-
- fc->feedcount += onoff ? 1 : -1; /* the number of PIDs/Feed currently requested */
- if (dvbdmxfeed->index >= max_pid_filter)
- fc->extra_feedcount += onoff ? 1 : -1;
-
- /* toggle complete-TS-streaming when:
- * - pid_filtering is not enabled and it is the first or last feed requested
- * - pid_filtering is enabled,
- * - but the number of requested feeds is exceeded
- * - or the requested pid is 0x2000 */
-
- if (!fc->pid_filtering && fc->feedcount == onoff)
- flexcop_toggle_fullts_streaming(fc,onoff);
-
- if (fc->pid_filtering) {
- flexcop_pid_control(fc,dvbdmxfeed->index,dvbdmxfeed->pid,onoff);
-
- if (fc->extra_feedcount > 0)
- flexcop_toggle_fullts_streaming(fc,1);
- else if (dvbdmxfeed->pid == 0x2000)
- flexcop_toggle_fullts_streaming(fc,onoff);
- else
- flexcop_toggle_fullts_streaming(fc,0);
- }
-
- /* if it was the first or last feed request change the stream-status */
- if (fc->feedcount == onoff) {
- flexcop_rcv_data_ctrl(fc,onoff);
- if (fc->stream_control) /* device specific stream control */
- fc->stream_control(fc,onoff);
-
- /* feeding stopped -> reset the flexcop filter*/
- if (onoff == 0) {
- flexcop_reset_block_300(fc);
- flexcop_hw_filter_init(fc);
- }
- }
-
- return 0;
-}
-
-void flexcop_hw_filter_init(struct flexcop_device *fc)
-{
- int i;
- flexcop_ibi_value v;
- for (i = 0; i < 6 + 32*fc->has_32_hw_pid_filter; i++)
- flexcop_pid_control(fc,i,0x1fff,0);
-
- flexcop_pid_group_filter(fc, 0, 0x1fe0);
- flexcop_pid_group_filter_ctrl(fc,0);
-
- v = fc->read_ibi_reg(fc,pid_filter_308);
- v.pid_filter_308.EMM_filter_4 = 1;
- v.pid_filter_308.EMM_filter_6 = 0;
- fc->write_ibi_reg(fc,pid_filter_308,v);
-
- flexcop_null_filter_ctrl(fc, 1);
-}
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c
deleted file mode 100644
index e0bd2d8f0f0..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-i2c.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-i2c.c - flexcop internal 2Wire bus (I2C) and dvb i2c initialization
- *
- * see flexcop.c for copyright information.
- */
-#include "flexcop.h"
-
-#define FC_MAX_I2C_RETRIES 100000
-
-static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r100)
-{
- int i;
- flexcop_ibi_value r;
-
- r100->tw_sm_c_100.working_start = 1;
- deb_i2c("r100 before: %08x\n",r100->raw);
-
- fc->write_ibi_reg(fc, tw_sm_c_100, ibi_zero);
- fc->write_ibi_reg(fc, tw_sm_c_100, *r100); /* initiating i2c operation */
-
- for (i = 0; i < FC_MAX_I2C_RETRIES; i++) {
- r = fc->read_ibi_reg(fc, tw_sm_c_100);
-
- if (!r.tw_sm_c_100.no_base_addr_ack_error) {
- if (r.tw_sm_c_100.st_done) { /* && !r.tw_sm_c_100.working_start */
- *r100 = r;
- deb_i2c("i2c success\n");
- return 0;
- }
- } else {
- deb_i2c("suffering from an i2c ack_error\n");
- return -EREMOTEIO;
- }
- }
- deb_i2c("tried %d times i2c operation, never finished or too many ack errors.\n",i);
- return -EREMOTEIO;
-}
-
-static int flexcop_i2c_read4(struct flexcop_device *fc, flexcop_ibi_value r100, u8 *buf)
-{
- flexcop_ibi_value r104;
- int len = r100.tw_sm_c_100.total_bytes, /* remember total_bytes is buflen-1 */
- ret;
-
- if ((ret = flexcop_i2c_operation(fc,&r100)) != 0) {
- /* The Cablestar needs a different kind of i2c-transfer (does not
- * support "Repeat Start"):
- * wait for the ACK failure,
- * and do a subsequent read with the Bit 30 enabled
- */
- r100.tw_sm_c_100.no_base_addr_ack_error = 1;
- if ((ret = flexcop_i2c_operation(fc,&r100)) != 0) {
- deb_i2c("no_base_addr read failed. %d\n",ret);
- return ret;
- }
- }
-
- buf[0] = r100.tw_sm_c_100.data1_reg;
-
- if (len > 0) {
- r104 = fc->read_ibi_reg(fc,tw_sm_c_104);
- deb_i2c("read: r100: %08x, r104: %08x\n",r100.raw,r104.raw);
-
- /* there is at least one more byte, otherwise we wouldn't be here */
- buf[1] = r104.tw_sm_c_104.data2_reg;
- if (len > 1) buf[2] = r104.tw_sm_c_104.data3_reg;
- if (len > 2) buf[3] = r104.tw_sm_c_104.data4_reg;
- }
-
- return 0;
-}
-
-static int flexcop_i2c_write4(struct flexcop_device *fc, flexcop_ibi_value r100, u8 *buf)
-{
- flexcop_ibi_value r104;
- int len = r100.tw_sm_c_100.total_bytes; /* remember total_bytes is buflen-1 */
- r104.raw = 0;
-
- /* there is at least one byte, otherwise we wouldn't be here */
- r100.tw_sm_c_100.data1_reg = buf[0];
-
- r104.tw_sm_c_104.data2_reg = len > 0 ? buf[1] : 0;
- r104.tw_sm_c_104.data3_reg = len > 1 ? buf[2] : 0;
- r104.tw_sm_c_104.data4_reg = len > 2 ? buf[3] : 0;
-
- deb_i2c("write: r100: %08x, r104: %08x\n",r100.raw,r104.raw);
-
- /* write the additional i2c data before doing the actual i2c operation */
- fc->write_ibi_reg(fc,tw_sm_c_104,r104);
- return flexcop_i2c_operation(fc,&r100);
-}
-
-int flexcop_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op,
- flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
-{
- int ret;
- u16 bytes_to_transfer;
- flexcop_ibi_value r100;
-
- deb_i2c("op = %d\n",op);
- r100.raw = 0;
- r100.tw_sm_c_100.chipaddr = chipaddr;
- r100.tw_sm_c_100.twoWS_rw = op;
- r100.tw_sm_c_100.twoWS_port_reg = port;
-
- while (len != 0) {
- bytes_to_transfer = len > 4 ? 4 : len;
-
- r100.tw_sm_c_100.total_bytes = bytes_to_transfer - 1;
- r100.tw_sm_c_100.baseaddr = addr;
-
- if (op == FC_READ)
- ret = flexcop_i2c_read4(fc, r100, buf);
- else
- ret = flexcop_i2c_write4(fc,r100, buf);
-
- if (ret < 0)
- return ret;
-
- buf += bytes_to_transfer;
- addr += bytes_to_transfer;
- len -= bytes_to_transfer;
- };
-
- return 0;
-}
-/* exported for PCI i2c */
-EXPORT_SYMBOL(flexcop_i2c_request);
-
-/* master xfer callback for demodulator */
-static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num)
-{
- struct flexcop_device *fc = i2c_get_adapdata(i2c_adap);
- int i, ret = 0;
-
- if (mutex_lock_interruptible(&fc->i2c_mutex))
- return -ERESTARTSYS;
-
- /* reading */
- if (num == 2 &&
- msgs[0].flags == 0 &&
- msgs[1].flags == I2C_M_RD &&
- msgs[0].buf != NULL &&
- msgs[1].buf != NULL) {
-
- ret = fc->i2c_request(fc, FC_READ, FC_I2C_PORT_DEMOD, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len);
-
- } else for (i = 0; i < num; i++) { /* writing command */
- if (msgs[i].flags != 0 || msgs[i].buf == NULL || msgs[i].len < 2) {
- ret = -EINVAL;
- break;
- }
-
- ret = fc->i2c_request(fc, FC_WRITE, FC_I2C_PORT_DEMOD, msgs[i].addr, msgs[i].buf[0], &msgs[i].buf[1], msgs[i].len - 1);
- }
-
- if (ret < 0)
- err("i2c master_xfer failed");
- else
- ret = num;
-
- mutex_unlock(&fc->i2c_mutex);
-
- return ret;
-}
-
-static u32 flexcop_i2c_func(struct i2c_adapter *adapter)
-{
- return I2C_FUNC_I2C;
-}
-
-static struct i2c_algorithm flexcop_algo = {
- .master_xfer = flexcop_master_xfer,
- .functionality = flexcop_i2c_func,
-};
-
-int flexcop_i2c_init(struct flexcop_device *fc)
-{
- int ret;
-
- mutex_init(&fc->i2c_mutex);
-
- memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter));
- strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",I2C_NAME_SIZE);
-
- i2c_set_adapdata(&fc->i2c_adap,fc);
-
- fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
- fc->i2c_adap.algo = &flexcop_algo;
- fc->i2c_adap.algo_data = NULL;
-
- if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0)
- return ret;
-
- fc->init_state |= FC_STATE_I2C_INIT;
- return 0;
-}
-
-void flexcop_i2c_exit(struct flexcop_device *fc)
-{
- if (fc->init_state & FC_STATE_I2C_INIT)
- i2c_del_adapter(&fc->i2c_adap);
-
- fc->init_state &= ~FC_STATE_I2C_INIT;
-}
diff --git a/drivers/media/dvb/b2c2/flexcop-misc.c b/drivers/media/dvb/b2c2/flexcop-misc.c
deleted file mode 100644
index 167583bf062..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-misc.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-misc.c - miscellaneous functions.
- *
- * see flexcop.c for copyright information.
- */
-#include "flexcop.h"
-
-void flexcop_determine_revision(struct flexcop_device *fc)
-{
- flexcop_ibi_value v = fc->read_ibi_reg(fc,misc_204);
-
- switch (v.misc_204.Rev_N_sig_revision_hi) {
- case 0x2:
- deb_info("found a FlexCopII.\n");
- fc->rev = FLEXCOP_II;
- break;
- case 0x3:
- deb_info("found a FlexCopIIb.\n");
- fc->rev = FLEXCOP_IIB;
- break;
- case 0x0:
- deb_info("found a FlexCopIII.\n");
- fc->rev = FLEXCOP_III;
- break;
- default:
- err("unkown FlexCop Revision: %x. Please report the linux-dvb@linuxtv.org.",v.misc_204.Rev_N_sig_revision_hi);
- break;
- }
-
- if ((fc->has_32_hw_pid_filter = v.misc_204.Rev_N_sig_caps))
- deb_info("this FlexCop has the additional 32 hardware pid filter.\n");
- else
- deb_info("this FlexCop has only the 6 basic main hardware pid filter.\n");
- /* bus parts have to decide if hw pid filtering is used or not. */
-}
-
-static const char *flexcop_revision_names[] = {
- "Unkown chip",
- "FlexCopII",
- "FlexCopIIb",
- "FlexCopIII",
-};
-
-static const char *flexcop_device_names[] = {
- "Unkown device",
- "Air2PC/AirStar 2 DVB-T",
- "Air2PC/AirStar 2 ATSC 1st generation",
- "Air2PC/AirStar 2 ATSC 2nd generation",
- "Sky2PC/SkyStar 2 DVB-S",
- "Sky2PC/SkyStar 2 DVB-S (old version)",
- "Cable2PC/CableStar 2 DVB-C",
- "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)",
-};
-
-static const char *flexcop_bus_names[] = {
- "USB",
- "PCI",
-};
-
-void flexcop_device_name(struct flexcop_device *fc,const char *prefix,const
- char *suffix)
-{
- info("%s '%s' at the '%s' bus controlled by a '%s' %s",prefix,
- flexcop_device_names[fc->dev_type],flexcop_bus_names[fc->bus_type],
- flexcop_revision_names[fc->rev],suffix);
-}
-
-void flexcop_dump_reg(struct flexcop_device *fc, flexcop_ibi_register reg, int num)
-{
- flexcop_ibi_value v;
- int i;
- for (i = 0; i < num; i++) {
- v = fc->read_ibi_reg(fc,reg+4*i);
- deb_rdump("0x%03x: %08x, ",reg+4*i, v.raw);
- }
- deb_rdump("\n");
-}
-EXPORT_SYMBOL(flexcop_dump_reg);
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c
deleted file mode 100644
index eb2e6432c8c..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-pci.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-pci.c - covers the PCI part including DMA transfers.
- *
- * see flexcop.c for copyright information.
- */
-
-#define FC_LOG_PREFIX "flexcop-pci"
-#include "flexcop-common.h"
-
-static int enable_pid_filtering = 1;
-module_param(enable_pid_filtering, int, 0444);
-MODULE_PARM_DESC(enable_pid_filtering, "enable hardware pid filtering: supported values: 0 (fullts), 1");
-
-static int irq_chk_intv;
-module_param(irq_chk_intv, int, 0644);
-MODULE_PARM_DESC(irq_chk_intv, "set the interval for IRQ watchdog (currently just debugging).");
-
-#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
-#define dprintk(level,args...) \
- do { if ((debug & level)) printk(args); } while (0)
-#define DEBSTATUS ""
-#else
-#define dprintk(level,args...)
-#define DEBSTATUS " (debugging is not enabled)"
-#endif
-
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_reg(args...) dprintk(0x02,args)
-#define deb_ts(args...) dprintk(0x04,args)
-#define deb_irq(args...) dprintk(0x08,args)
-#define deb_chk(args...) dprintk(0x10,args)
-
-static int debug = 0;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debug level (1=info,2=regs,4=TS,8=irqdma (|-able))." DEBSTATUS);
-
-#define DRIVER_VERSION "0.1"
-#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV PCI Driver"
-#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
-
-struct flexcop_pci {
- struct pci_dev *pdev;
-
-#define FC_PCI_INIT 0x01
-#define FC_PCI_DMA_INIT 0x02
- int init_state;
-
- void __iomem *io_mem;
- u32 irq;
-/* buffersize (at least for DMA1, need to be % 188 == 0,
- * this logic is required */
-#define FC_DEFAULT_DMA1_BUFSIZE (1280 * 188)
-#define FC_DEFAULT_DMA2_BUFSIZE (10 * 188)
- struct flexcop_dma dma[2];
-
- int active_dma1_addr; /* 0 = addr0 of dma1; 1 = addr1 of dma1 */
- u32 last_dma1_cur_pos; /* position of the pointer last time the timer/packet irq occured */
- int count;
-
- spinlock_t irq_lock;
-
- unsigned long last_irq;
-
- struct work_struct irq_check_work;
-
- struct flexcop_device *fc_dev;
-};
-
-static int lastwreg,lastwval,lastrreg,lastrval;
-
-static flexcop_ibi_value flexcop_pci_read_ibi_reg (struct flexcop_device *fc, flexcop_ibi_register r)
-{
- struct flexcop_pci *fc_pci = fc->bus_specific;
- flexcop_ibi_value v;
- v.raw = readl(fc_pci->io_mem + r);
-
- if (lastrreg != r || lastrval != v.raw) {
- lastrreg = r; lastrval = v.raw;
- deb_reg("new rd: %3x: %08x\n",r,v.raw);
- }
-
- return v;
-}
-
-static int flexcop_pci_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_register r, flexcop_ibi_value v)
-{
- struct flexcop_pci *fc_pci = fc->bus_specific;
-
- if (lastwreg != r || lastwval != v.raw) {
- lastwreg = r; lastwval = v.raw;
- deb_reg("new wr: %3x: %08x\n",r,v.raw);
- }
-
- writel(v.raw, fc_pci->io_mem + r);
- return 0;
-}
-
-static void flexcop_pci_irq_check_work(void *data)
-{
- struct flexcop_pci *fc_pci = data;
- struct flexcop_device *fc = fc_pci->fc_dev;
-
- flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
-
- flexcop_dump_reg(fc_pci->fc_dev,dma1_000,4);
-
- if (v.sram_dest_reg_714.net_ovflow_error)
- deb_chk("sram net_ovflow_error\n");
- if (v.sram_dest_reg_714.media_ovflow_error)
- deb_chk("sram media_ovflow_error\n");
- if (v.sram_dest_reg_714.cai_ovflow_error)
- deb_chk("sram cai_ovflow_error\n");
- if (v.sram_dest_reg_714.cai_ovflow_error)
- deb_chk("sram cai_ovflow_error\n");
-
- schedule_delayed_work(&fc_pci->irq_check_work,
- msecs_to_jiffies(irq_chk_intv < 100 ? 100 : irq_chk_intv));
-}
-
-/* When PID filtering is turned on, we use the timer IRQ, because small amounts
- * of data need to be passed to the user space instantly as well. When PID
- * filtering is turned off, we use the page-change-IRQ */
-static irqreturn_t flexcop_pci_isr(int irq, void *dev_id, struct pt_regs *regs)
-{
- struct flexcop_pci *fc_pci = dev_id;
- struct flexcop_device *fc = fc_pci->fc_dev;
- flexcop_ibi_value v;
- irqreturn_t ret = IRQ_HANDLED;
-
- spin_lock_irq(&fc_pci->irq_lock);
-
- v = fc->read_ibi_reg(fc,irq_20c);
-
- /* errors */
- if (v.irq_20c.Data_receiver_error)
- deb_chk("data receiver error\n");
- if (v.irq_20c.Continuity_error_flag)
- deb_chk("Contunuity error flag is set\n");
- if (v.irq_20c.LLC_SNAP_FLAG_set)
- deb_chk("LLC_SNAP_FLAG_set is set\n");
- if (v.irq_20c.Transport_Error)
- deb_chk("Transport error\n");
-
- if ((fc_pci->count % 1000) == 0)
- deb_chk("%d valid irq took place so far\n",fc_pci->count);
-
- if (v.irq_20c.DMA1_IRQ_Status == 1) {
- if (fc_pci->active_dma1_addr == 0)
- flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr0,fc_pci->dma[0].size / 188);
- else
- flexcop_pass_dmx_packets(fc_pci->fc_dev,fc_pci->dma[0].cpu_addr1,fc_pci->dma[0].size / 188);
-
- deb_irq("page change to page: %d\n",!fc_pci->active_dma1_addr);
- fc_pci->active_dma1_addr = !fc_pci->active_dma1_addr;
- } else if (v.irq_20c.DMA1_Timer_Status == 1) {
- /* for the timer IRQ we only can use buffer dmx feeding, because we don't have
- * complete TS packets when reading from the DMA memory */
- dma_addr_t cur_addr =
- fc->read_ibi_reg(fc,dma1_008).dma_0x8.dma_cur_addr << 2;
- u32 cur_pos = cur_addr - fc_pci->dma[0].dma_addr0;
-
- deb_irq("%u irq: %08x cur_addr: %llx: cur_pos: %08x, last_cur_pos: %08x ",
- jiffies_to_usecs(jiffies - fc_pci->last_irq),
- v.raw, (unsigned long long)cur_addr, cur_pos,
- fc_pci->last_dma1_cur_pos);
- fc_pci->last_irq = jiffies;
-
- /* buffer end was reached, restarted from the beginning
- * pass the data from last_cur_pos to the buffer end to the demux
- */
- if (cur_pos < fc_pci->last_dma1_cur_pos) {
- deb_irq(" end was reached: passing %d bytes ",(fc_pci->dma[0].size*2 - 1) - fc_pci->last_dma1_cur_pos);
- flexcop_pass_dmx_data(fc_pci->fc_dev,
- fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos,
- (fc_pci->dma[0].size*2) - fc_pci->last_dma1_cur_pos);
- fc_pci->last_dma1_cur_pos = 0;
- }
-
- if (cur_pos > fc_pci->last_dma1_cur_pos) {
- deb_irq(" passing %d bytes ",cur_pos - fc_pci->last_dma1_cur_pos);
- flexcop_pass_dmx_data(fc_pci->fc_dev,
- fc_pci->dma[0].cpu_addr0 + fc_pci->last_dma1_cur_pos,
- cur_pos - fc_pci->last_dma1_cur_pos);
- }
- deb_irq("\n");
-
- fc_pci->last_dma1_cur_pos = cur_pos;
- fc_pci->count++;
- } else {
- deb_irq("isr for flexcop called, apparently without reason (%08x)\n",v.raw);
- ret = IRQ_NONE;
- }
-
- spin_unlock_irq(&fc_pci->irq_lock);
-
- return ret;
-}
-
-static int flexcop_pci_stream_control(struct flexcop_device *fc, int onoff)
-{
- struct flexcop_pci *fc_pci = fc->bus_specific;
- if (onoff) {
- flexcop_dma_config(fc,&fc_pci->dma[0],FC_DMA_1);
- flexcop_dma_config(fc,&fc_pci->dma[1],FC_DMA_2);
-
- flexcop_dma_config_timer(fc,FC_DMA_1,0);
-
- flexcop_dma_xfer_control(fc,FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1,1);
- deb_irq("DMA xfer enabled\n");
-
- fc_pci->last_dma1_cur_pos = 0;
- flexcop_dma_control_timer_irq(fc,FC_DMA_1,1);
- deb_irq("IRQ enabled\n");
-
-// fc_pci->active_dma1_addr = 0;
-// flexcop_dma_control_size_irq(fc,FC_DMA_1,1);
-
- if (irq_chk_intv > 0)
- schedule_delayed_work(&fc_pci->irq_check_work,
- msecs_to_jiffies(irq_chk_intv < 100 ? 100 : irq_chk_intv));
- } else {
- if (irq_chk_intv > 0)
- cancel_delayed_work(&fc_pci->irq_check_work);
-
- flexcop_dma_control_timer_irq(fc,FC_DMA_1,0);
- deb_irq("IRQ disabled\n");
-
-// flexcop_dma_control_size_irq(fc,FC_DMA_1,0);
-
- flexcop_dma_xfer_control(fc,FC_DMA_1,FC_DMA_SUBADDR_0 | FC_DMA_SUBADDR_1,0);
- deb_irq("DMA xfer disabled\n");
- }
-
- return 0;
-}
-
-static int flexcop_pci_dma_init(struct flexcop_pci *fc_pci)
-{
- int ret;
- if ((ret = flexcop_dma_allocate(fc_pci->pdev,&fc_pci->dma[0],FC_DEFAULT_DMA1_BUFSIZE)) != 0)
- return ret;
-
- if ((ret = flexcop_dma_allocate(fc_pci->pdev,&fc_pci->dma[1],FC_DEFAULT_DMA2_BUFSIZE)) != 0) {
- flexcop_dma_free(&fc_pci->dma[0]);
- return ret;
- }
-
- flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_MEDIA | FC_SRAM_DEST_NET, FC_SRAM_DEST_TARGET_DMA1);
- flexcop_sram_set_dest(fc_pci->fc_dev,FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_DMA2);
-
- fc_pci->init_state |= FC_PCI_DMA_INIT;
-
- return ret;
-}
-
-static void flexcop_pci_dma_exit(struct flexcop_pci *fc_pci)
-{
- if (fc_pci->init_state & FC_PCI_DMA_INIT) {
- flexcop_dma_free(&fc_pci->dma[0]);
- flexcop_dma_free(&fc_pci->dma[1]);
- }
- fc_pci->init_state &= ~FC_PCI_DMA_INIT;
-}
-
-static int flexcop_pci_init(struct flexcop_pci *fc_pci)
-{
- int ret;
- u8 card_rev;
-
- pci_read_config_byte(fc_pci->pdev, PCI_CLASS_REVISION, &card_rev);
- info("card revision %x", card_rev);
-
- if ((ret = pci_enable_device(fc_pci->pdev)) != 0)
- return ret;
-
- pci_set_master(fc_pci->pdev);
-
- /* enable interrupts */
- // pci_write_config_dword(pdev, 0x6c, 0x8000);
-
- if ((ret = pci_request_regions(fc_pci->pdev, DRIVER_NAME)) != 0)
- goto err_pci_disable_device;
-
- fc_pci->io_mem = pci_iomap(fc_pci->pdev, 0, 0x800);
-
- if (!fc_pci->io_mem) {
- err("cannot map io memory\n");
- ret = -EIO;
- goto err_pci_release_regions;
- }
-
- pci_set_drvdata(fc_pci->pdev, fc_pci);
-
- if ((ret = request_irq(fc_pci->pdev->irq, flexcop_pci_isr,
- IRQF_SHARED, DRIVER_NAME, fc_pci)) != 0)
- goto err_pci_iounmap;
-
- spin_lock_init(&fc_pci->irq_lock);
-
- fc_pci->init_state |= FC_PCI_INIT;
- return ret;
-
-err_pci_iounmap:
- pci_iounmap(fc_pci->pdev, fc_pci->io_mem);
- pci_set_drvdata(fc_pci->pdev, NULL);
-err_pci_release_regions:
- pci_release_regions(fc_pci->pdev);
-err_pci_disable_device:
- pci_disable_device(fc_pci->pdev);
- return ret;
-}
-
-static void flexcop_pci_exit(struct flexcop_pci *fc_pci)
-{
- if (fc_pci->init_state & FC_PCI_INIT) {
- free_irq(fc_pci->pdev->irq, fc_pci);
- pci_iounmap(fc_pci->pdev, fc_pci->io_mem);
- pci_set_drvdata(fc_pci->pdev, NULL);
- pci_release_regions(fc_pci->pdev);
- pci_disable_device(fc_pci->pdev);
- }
- fc_pci->init_state &= ~FC_PCI_INIT;
-}
-
-
-static int flexcop_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
-{
- struct flexcop_device *fc;
- struct flexcop_pci *fc_pci;
- int ret = -ENOMEM;
-
- if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_pci))) == NULL) {
- err("out of memory\n");
- return -ENOMEM;
- }
-
-/* general flexcop init */
- fc_pci = fc->bus_specific;
- fc_pci->fc_dev = fc;
-
- fc->read_ibi_reg = flexcop_pci_read_ibi_reg;
- fc->write_ibi_reg = flexcop_pci_write_ibi_reg;
- fc->i2c_request = flexcop_i2c_request;
- fc->get_mac_addr = flexcop_eeprom_check_mac_addr;
-
- fc->stream_control = flexcop_pci_stream_control;
-
- if (enable_pid_filtering)
- info("will use the HW PID filter.");
- else
- info("will pass the complete TS to the demuxer.");
-
- fc->pid_filtering = enable_pid_filtering;
- fc->bus_type = FC_PCI;
-
- fc->dev = &pdev->dev;
- fc->owner = THIS_MODULE;
-
-/* bus specific part */
- fc_pci->pdev = pdev;
- if ((ret = flexcop_pci_init(fc_pci)) != 0)
- goto err_kfree;
-
-/* init flexcop */
- if ((ret = flexcop_device_initialize(fc)) != 0)
- goto err_pci_exit;
-
-/* init dma */
- if ((ret = flexcop_pci_dma_init(fc_pci)) != 0)
- goto err_fc_exit;
-
- INIT_WORK(&fc_pci->irq_check_work, flexcop_pci_irq_check_work, fc_pci);
-
- return ret;
-
-err_fc_exit:
- flexcop_device_exit(fc);
-err_pci_exit:
- flexcop_pci_exit(fc_pci);
-err_kfree:
- flexcop_device_kfree(fc);
- return ret;
-}
-
-/* in theory every _exit function should be called exactly two times,
- * here and in the bail-out-part of the _init-function
- */
-static void flexcop_pci_remove(struct pci_dev *pdev)
-{
- struct flexcop_pci *fc_pci = pci_get_drvdata(pdev);
-
- flexcop_pci_dma_exit(fc_pci);
- flexcop_device_exit(fc_pci->fc_dev);
- flexcop_pci_exit(fc_pci);
- flexcop_device_kfree(fc_pci->fc_dev);
-}
-
-static struct pci_device_id flexcop_pci_tbl[] = {
- { PCI_DEVICE(0x13d0, 0x2103) },
-/* { PCI_DEVICE(0x13d0, 0x2200) }, ? */
- { },
-};
-
-MODULE_DEVICE_TABLE(pci, flexcop_pci_tbl);
-
-static struct pci_driver flexcop_pci_driver = {
- .name = "b2c2_flexcop_pci",
- .id_table = flexcop_pci_tbl,
- .probe = flexcop_pci_probe,
- .remove = flexcop_pci_remove,
-};
-
-static int __init flexcop_pci_module_init(void)
-{
- return pci_register_driver(&flexcop_pci_driver);
-}
-
-static void __exit flexcop_pci_module_exit(void)
-{
- pci_unregister_driver(&flexcop_pci_driver);
-}
-
-module_init(flexcop_pci_module_init);
-module_exit(flexcop_pci_module_exit);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_NAME);
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/b2c2/flexcop-reg.h b/drivers/media/dvb/b2c2/flexcop-reg.h
deleted file mode 100644
index 491f9bd6e19..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-reg.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-reg.h - register abstraction for FlexCopII, FlexCopIIb and FlexCopIII
- *
- * see flexcop.c for copyright information.
- */
-#ifndef __FLEXCOP_REG_H__
-#define __FLEXCOP_REG_H__
-
-
-typedef enum {
- FLEXCOP_UNK = 0,
- FLEXCOP_II,
- FLEXCOP_IIB,
- FLEXCOP_III,
-} flexcop_revision_t;
-
-typedef enum {
- FC_UNK = 0,
- FC_AIR_DVB,
- FC_AIR_ATSC1,
- FC_AIR_ATSC2,
- FC_SKY,
- FC_SKY_OLD,
- FC_CABLE,
- FC_AIR_ATSC3,
-} flexcop_device_type_t;
-
-typedef enum {
- FC_USB = 0,
- FC_PCI,
-} flexcop_bus_t;
-
-/* FlexCop IBI Registers */
-#if defined(__LITTLE_ENDIAN)
- #include "flexcop_ibi_value_le.h"
-#else
-#if defined(__BIG_ENDIAN)
- #include "flexcop_ibi_value_be.h"
-#else
- #error no endian defined
-#endif
-#endif
-
-#define fc_data_Tag_ID_DVB 0x3e
-#define fc_data_Tag_ID_ATSC 0x3f
-#define fc_data_Tag_ID_IDSB 0x8b
-
-#define fc_key_code_default 0x1
-#define fc_key_code_even 0x2
-#define fc_key_code_odd 0x3
-
-extern flexcop_ibi_value ibi_zero;
-
-typedef enum {
- FC_I2C_PORT_DEMOD = 1,
- FC_I2C_PORT_EEPROM = 2,
- FC_I2C_PORT_TUNER = 3,
-} flexcop_i2c_port_t;
-
-typedef enum {
- FC_WRITE = 0,
- FC_READ = 1,
-} flexcop_access_op_t;
-
-typedef enum {
- FC_SRAM_DEST_NET = 1,
- FC_SRAM_DEST_CAI = 2,
- FC_SRAM_DEST_CAO = 4,
- FC_SRAM_DEST_MEDIA = 8
-} flexcop_sram_dest_t;
-
-typedef enum {
- FC_SRAM_DEST_TARGET_WAN_USB = 0,
- FC_SRAM_DEST_TARGET_DMA1 = 1,
- FC_SRAM_DEST_TARGET_DMA2 = 2,
- FC_SRAM_DEST_TARGET_FC3_CA = 3
-} flexcop_sram_dest_target_t;
-
-typedef enum {
- FC_SRAM_2_32KB = 0, /* 64KB */
- FC_SRAM_1_32KB = 1, /* 32KB - default fow FCII */
- FC_SRAM_1_128KB = 2, /* 128KB */
- FC_SRAM_1_48KB = 3, /* 48KB - default for FCIII */
-} flexcop_sram_type_t;
-
-typedef enum {
- FC_WAN_SPEED_4MBITS = 0,
- FC_WAN_SPEED_8MBITS = 1,
- FC_WAN_SPEED_12MBITS = 2,
- FC_WAN_SPEED_16MBITS = 3,
-} flexcop_wan_speed_t;
-
-typedef enum {
- FC_DMA_1 = 1,
- FC_DMA_2 = 2,
-} flexcop_dma_index_t;
-
-typedef enum {
- FC_DMA_SUBADDR_0 = 1,
- FC_DMA_SUBADDR_1 = 2,
-} flexcop_dma_addr_index_t;
-
-/* names of the particular registers */
-typedef enum {
- dma1_000 = 0x000,
- dma1_004 = 0x004,
- dma1_008 = 0x008,
- dma1_00c = 0x00c,
- dma2_010 = 0x010,
- dma2_014 = 0x014,
- dma2_018 = 0x018,
- dma2_01c = 0x01c,
-
- tw_sm_c_100 = 0x100,
- tw_sm_c_104 = 0x104,
- tw_sm_c_108 = 0x108,
- tw_sm_c_10c = 0x10c,
- tw_sm_c_110 = 0x110,
-
- lnb_switch_freq_200 = 0x200,
- misc_204 = 0x204,
- ctrl_208 = 0x208,
- irq_20c = 0x20c,
- sw_reset_210 = 0x210,
- misc_214 = 0x214,
- mbox_v8_to_host_218 = 0x218,
- mbox_host_to_v8_21c = 0x21c,
-
- pid_filter_300 = 0x300,
- pid_filter_304 = 0x304,
- pid_filter_308 = 0x308,
- pid_filter_30c = 0x30c,
- index_reg_310 = 0x310,
- pid_n_reg_314 = 0x314,
- mac_low_reg_318 = 0x318,
- mac_high_reg_31c = 0x31c,
-
- data_tag_400 = 0x400,
- card_id_408 = 0x408,
- card_id_40c = 0x40c,
- mac_address_418 = 0x418,
- mac_address_41c = 0x41c,
-
- ci_600 = 0x600,
- pi_604 = 0x604,
- pi_608 = 0x608,
- dvb_reg_60c = 0x60c,
-
- sram_ctrl_reg_700 = 0x700,
- net_buf_reg_704 = 0x704,
- cai_buf_reg_708 = 0x708,
- cao_buf_reg_70c = 0x70c,
- media_buf_reg_710 = 0x710,
- sram_dest_reg_714 = 0x714,
- net_buf_reg_718 = 0x718,
- wan_ctrl_reg_71c = 0x71c,
-} flexcop_ibi_register;
-
-#define flexcop_set_ibi_value(reg,attr,val) { \
- flexcop_ibi_value v = fc->read_ibi_reg(fc,reg); \
- v.reg.attr = val; \
- fc->write_ibi_reg(fc,reg,v); \
-}
-
-#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-sram.c b/drivers/media/dvb/b2c2/flexcop-sram.c
deleted file mode 100644
index 01570ec8096..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-sram.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-sram.c - functions for controlling the SRAM.
- *
- * see flexcop.c for copyright information.
- */
-#include "flexcop.h"
-
-static void flexcop_sram_set_chip (struct flexcop_device *fc, flexcop_sram_type_t type)
-{
- flexcop_set_ibi_value(wan_ctrl_reg_71c,sram_chip,type);
-}
-
-int flexcop_sram_init(struct flexcop_device *fc)
-{
- switch (fc->rev) {
- case FLEXCOP_II:
- case FLEXCOP_IIB:
- flexcop_sram_set_chip(fc,FC_SRAM_1_32KB);
- break;
- case FLEXCOP_III:
- flexcop_sram_set_chip(fc,FC_SRAM_1_48KB);
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target)
-{
- flexcop_ibi_value v;
-
- v = fc->read_ibi_reg(fc,sram_dest_reg_714);
-
- if (fc->rev != FLEXCOP_III && target == FC_SRAM_DEST_TARGET_FC3_CA) {
- err("SRAM destination target to available on FlexCopII(b)\n");
- return -EINVAL;
- }
-
- deb_sram("sram dest: %x target: %x\n",dest, target);
-
- if (dest & FC_SRAM_DEST_NET)
- v.sram_dest_reg_714.NET_Dest = target;
- if (dest & FC_SRAM_DEST_CAI)
- v.sram_dest_reg_714.CAI_Dest = target;
- if (dest & FC_SRAM_DEST_CAO)
- v.sram_dest_reg_714.CAO_Dest = target;
- if (dest & FC_SRAM_DEST_MEDIA)
- v.sram_dest_reg_714.MEDIA_Dest = target;
-
- fc->write_ibi_reg(fc,sram_dest_reg_714,v);
- udelay(1000); /* TODO delay really necessary */
-
- return 0;
-}
-EXPORT_SYMBOL(flexcop_sram_set_dest);
-
-void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s)
-{
- flexcop_set_ibi_value(wan_ctrl_reg_71c,wan_speed_sig,s);
-}
-EXPORT_SYMBOL(flexcop_wan_set_speed);
-
-void flexcop_sram_ctrl(struct flexcop_device *fc, int usb_wan, int sramdma, int maximumfill)
-{
- flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
- v.sram_dest_reg_714.ctrl_usb_wan = usb_wan;
- v.sram_dest_reg_714.ctrl_sramdma = sramdma;
- v.sram_dest_reg_714.ctrl_maximumfill = maximumfill;
- fc->write_ibi_reg(fc,sram_dest_reg_714,v);
-}
-EXPORT_SYMBOL(flexcop_sram_ctrl);
-
-#if 0
-static void flexcop_sram_write(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
-{
- int i, retries;
- u32 command;
-
- for (i = 0; i < len; i++) {
- command = bank | addr | 0x04000000 | (*buf << 0x10);
-
- retries = 2;
-
- while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
- mdelay(1);
- retries--;
- };
-
- if (retries == 0)
- printk("%s: SRAM timeout\n", __FUNCTION__);
-
- write_reg_dw(adapter, 0x700, command);
-
- buf++;
- addr++;
- }
-}
-
-static void flex_sram_read(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
-{
- int i, retries;
- u32 command, value;
-
- for (i = 0; i < len; i++) {
- command = bank | addr | 0x04008000;
-
- retries = 10000;
-
- while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
- mdelay(1);
- retries--;
- };
-
- if (retries == 0)
- printk("%s: SRAM timeout\n", __FUNCTION__);
-
- write_reg_dw(adapter, 0x700, command);
-
- retries = 10000;
-
- while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
- mdelay(1);
- retries--;
- };
-
- if (retries == 0)
- printk("%s: SRAM timeout\n", __FUNCTION__);
-
- value = read_reg_dw(adapter, 0x700) >> 0x10;
-
- *buf = (value & 0xff);
-
- addr++;
- buf++;
- }
-}
-
-static void sram_write_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
-{
- u32 bank;
-
- bank = 0;
-
- if (adapter->dw_sram_type == 0x20000) {
- bank = (addr & 0x18000) << 0x0d;
- }
-
- if (adapter->dw_sram_type == 0x00000) {
- if ((addr >> 0x0f) == 0)
- bank = 0x20000000;
- else
- bank = 0x10000000;
- }
-
- flex_sram_write(adapter, bank, addr & 0x7fff, buf, len);
-}
-
-static void sram_read_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
-{
- u32 bank;
-
- bank = 0;
-
- if (adapter->dw_sram_type == 0x20000) {
- bank = (addr & 0x18000) << 0x0d;
- }
-
- if (adapter->dw_sram_type == 0x00000) {
- if ((addr >> 0x0f) == 0)
- bank = 0x20000000;
- else
- bank = 0x10000000;
- }
-
- flex_sram_read(adapter, bank, addr & 0x7fff, buf, len);
-}
-
-static void sram_read(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
-{
- u32 length;
-
- while (len != 0) {
- length = len;
-
- // check if the address range belongs to the same
- // 32K memory chip. If not, the data is read from
- // one chip at a time.
- if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
- length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
- }
-
- sram_read_chunk(adapter, addr, buf, length);
-
- addr = addr + length;
- buf = buf + length;
- len = len - length;
- }
-}
-
-static void sram_write(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
-{
- u32 length;
-
- while (len != 0) {
- length = len;
-
- // check if the address range belongs to the same
- // 32K memory chip. If not, the data is written to
- // one chip at a time.
- if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
- length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
- }
-
- sram_write_chunk(adapter, addr, buf, length);
-
- addr = addr + length;
- buf = buf + length;
- len = len - length;
- }
-}
-
-static void sram_set_size(struct adapter *adapter, u32 mask)
-{
- write_reg_dw(adapter, 0x71c, (mask | (~0x30000 & read_reg_dw(adapter, 0x71c))));
-}
-
-static void sram_init(struct adapter *adapter)
-{
- u32 tmp;
-
- tmp = read_reg_dw(adapter, 0x71c);
-
- write_reg_dw(adapter, 0x71c, 1);
-
- if (read_reg_dw(adapter, 0x71c) != 0) {
- write_reg_dw(adapter, 0x71c, tmp);
-
- adapter->dw_sram_type = tmp & 0x30000;
-
- ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type);
-
- } else {
-
- adapter->dw_sram_type = 0x10000;
-
- ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type);
- }
-
- /* return value is never used? */
-/* return adapter->dw_sram_type; */
-}
-
-static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
-{
- u8 tmp1, tmp2;
-
- dprintk("%s: mask = %x, addr = %x\n", __FUNCTION__, mask, addr);
-
- sram_set_size(adapter, mask);
- sram_init(adapter);
-
- tmp2 = 0xa5;
- tmp1 = 0x4f;
-
- sram_write(adapter, addr, &tmp2, 1);
- sram_write(adapter, addr + 4, &tmp1, 1);
-
- tmp2 = 0;
-
- mdelay(20);
-
- sram_read(adapter, addr, &tmp2, 1);
- sram_read(adapter, addr, &tmp2, 1);
-
- dprintk("%s: wrote 0xa5, read 0x%2x\n", __FUNCTION__, tmp2);
-
- if (tmp2 != 0xa5)
- return 0;
-
- tmp2 = 0x5a;
- tmp1 = 0xf4;
-
- sram_write(adapter, addr, &tmp2, 1);
- sram_write(adapter, addr + 4, &tmp1, 1);
-
- tmp2 = 0;
-
- mdelay(20);
-
- sram_read(adapter, addr, &tmp2, 1);
- sram_read(adapter, addr, &tmp2, 1);
-
- dprintk("%s: wrote 0x5a, read 0x%2x\n", __FUNCTION__, tmp2);
-
- if (tmp2 != 0x5a)
- return 0;
-
- return 1;
-}
-
-static u32 sram_length(struct adapter *adapter)
-{
- if (adapter->dw_sram_type == 0x10000)
- return 32768; // 32K
- if (adapter->dw_sram_type == 0x00000)
- return 65536; // 64K
- if (adapter->dw_sram_type == 0x20000)
- return 131072; // 128K
-
- return 32768; // 32K
-}
-
-/* FlexcopII can work with 32K, 64K or 128K of external SRAM memory.
- - for 128K there are 4x32K chips at bank 0,1,2,3.
- - for 64K there are 2x32K chips at bank 1,2.
- - for 32K there is one 32K chip at bank 0.
-
- FlexCop works only with one bank at a time. The bank is selected
- by bits 28-29 of the 0x700 register.
-
- bank 0 covers addresses 0x00000-0x07fff
- bank 1 covers addresses 0x08000-0x0ffff
- bank 2 covers addresses 0x10000-0x17fff
- bank 3 covers addresses 0x18000-0x1ffff
-*/
-
-static int flexcop_sram_detect(struct flexcop_device *fc)
-{
- flexcop_ibi_value r208,r71c_0,vr71c_1;
-
- r208 = fc->read_ibi_reg(fc, ctrl_208);
- fc->write_ibi_reg(fc, ctrl_208, ibi_zero);
-
- r71c_0 = fc->read_ibi_reg(fc, wan_ctrl_reg_71c);
-
- write_reg_dw(adapter, 0x71c, 1);
-
- tmp3 = read_reg_dw(adapter, 0x71c);
-
- dprintk("%s: tmp3 = %x\n", __FUNCTION__, tmp3);
-
- write_reg_dw(adapter, 0x71c, tmp2);
-
- // check for internal SRAM ???
- tmp3--;
- if (tmp3 != 0) {
- sram_set_size(adapter, 0x10000);
- sram_init(adapter);
- write_reg_dw(adapter, 0x208, tmp);
-
- dprintk("%s: sram size = 32K\n", __FUNCTION__);
-
- return 32;
- }
-
- if (sram_test_location(adapter, 0x20000, 0x18000) != 0) {
- sram_set_size(adapter, 0x20000);
- sram_init(adapter);
- write_reg_dw(adapter, 0x208, tmp);
-
- dprintk("%s: sram size = 128K\n", __FUNCTION__);
-
- return 128;
- }
-
- if (sram_test_location(adapter, 0x00000, 0x10000) != 0) {
- sram_set_size(adapter, 0x00000);
- sram_init(adapter);
- write_reg_dw(adapter, 0x208, tmp);
-
- dprintk("%s: sram size = 64K\n", __FUNCTION__);
-
- return 64;
- }
-
- if (sram_test_location(adapter, 0x10000, 0x00000) != 0) {
- sram_set_size(adapter, 0x10000);
- sram_init(adapter);
- write_reg_dw(adapter, 0x208, tmp);
-
- dprintk("%s: sram size = 32K\n", __FUNCTION__);
-
- return 32;
- }
-
- sram_set_size(adapter, 0x10000);
- sram_init(adapter);
- write_reg_dw(adapter, 0x208, tmp);
-
- dprintk("%s: SRAM detection failed. Set to 32K \n", __FUNCTION__);
-
- return 0;
-}
-
-static void sll_detect_sram_size(struct adapter *adapter)
-{
- sram_detect_for_flex2(adapter);
-}
-
-#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
deleted file mode 100644
index 515954f96c9..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ /dev/null
@@ -1,575 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop-usb.c - covers the USB part.
- *
- * see flexcop.c for copyright information.
- */
-
-#define FC_LOG_PREFIX "flexcop_usb"
-#include "flexcop-usb.h"
-#include "flexcop-common.h"
-
-/* Version information */
-#define DRIVER_VERSION "0.1"
-#define DRIVER_NAME "Technisat/B2C2 FlexCop II/IIb/III Digital TV USB Driver"
-#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de>"
-
-/* debug */
-#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
-#define dprintk(level,args...) \
- do { if ((debug & level)) { printk(args); } } while (0)
-#define debug_dump(b,l,method) {\
- int i; \
- for (i = 0; i < l; i++) method("%02x ", b[i]); \
- method("\n");\
-}
-
-#define DEBSTATUS ""
-#else
-#define dprintk(level,args...)
-#define debug_dump(b,l,method)
-#define DEBSTATUS " (debugging is not enabled)"
-#endif
-
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,ts=2,ctrl=4,i2c=8,v8mem=16 (or-able))." DEBSTATUS);
-#undef DEBSTATUS
-
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_ts(args...) dprintk(0x02,args)
-#define deb_ctrl(args...) dprintk(0x04,args)
-#define deb_i2c(args...) dprintk(0x08,args)
-#define deb_v8(args...) dprintk(0x10,args)
-
-/* JLP 111700: we will include the 1 bit gap between the upper and lower 3 bits
- * in the IBI address, to make the V8 code simpler.
- * PCI ADDRESS FORMAT: 0x71C -> 0000 0111 0001 1100 (these are the six bits used)
- * in general: 0000 0HHH 000L LL00
- * IBI ADDRESS FORMAT: RHHH BLLL
- *
- * where R is the read(1)/write(0) bit, B is the busy bit
- * and HHH and LLL are the two sets of three bits from the PCI address.
- */
-#define B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(usPCI) (u8) (((usPCI >> 2) & 0x07) + ((usPCI >> 4) & 0x70))
-#define B2C2_FLEX_INTERNALADDR_TO_PCIOFFSET(ucAddr) (u16) (((ucAddr & 0x07) << 2) + ((ucAddr & 0x70) << 4))
-
-/*
- * DKT 020228
- * - forget about this VENDOR_BUFFER_SIZE, read and write register
- * deal with DWORD or 4 bytes, that should be should from now on
- * - from now on, we don't support anything older than firm 1.00
- * I eliminated the write register as a 2 trip of writing hi word and lo word
- * and force this to write only 4 bytes at a time.
- * NOTE: this should work with all the firmware from 1.00 and newer
- */
-static int flexcop_usb_readwrite_dw(struct flexcop_device *fc, u16 wRegOffsPCI, u32 *val, u8 read)
-{
- struct flexcop_usb *fc_usb = fc->bus_specific;
- u8 request = read ? B2C2_USB_READ_REG : B2C2_USB_WRITE_REG;
- u8 request_type = (read ? USB_DIR_IN : USB_DIR_OUT) | USB_TYPE_VENDOR;
- u8 wAddress = B2C2_FLEX_PCIOFFSET_TO_INTERNALADDR(wRegOffsPCI) | (read ? 0x80 : 0);
-
- int len = usb_control_msg(fc_usb->udev,
- read ? B2C2_USB_CTRL_PIPE_IN : B2C2_USB_CTRL_PIPE_OUT,
- request,
- request_type, /* 0xc0 read or 0x40 write*/
- wAddress,
- 0,
- val,
- sizeof(u32),
- B2C2_WAIT_FOR_OPERATION_RDW * HZ);
-
- if (len != sizeof(u32)) {
- err("error while %s dword from %d (%d).",read ? "reading" : "writing",
- wAddress,wRegOffsPCI);
- return -EIO;
- }
- return 0;
-}
-
-/*
- * DKT 010817 - add support for V8 memory read/write and flash update
- */
-static int flexcop_usb_v8_memory_req(struct flexcop_usb *fc_usb,
- flexcop_usb_request_t req, u8 page, u16 wAddress,
- u8 *pbBuffer,u32 buflen)
-{
-// u8 dwRequestType;
- u8 request_type = USB_TYPE_VENDOR;
- u16 wIndex;
- int nWaitTime,pipe,len;
-
- wIndex = page << 8;
-
- switch (req) {
- case B2C2_USB_READ_V8_MEM:
- nWaitTime = B2C2_WAIT_FOR_OPERATION_V8READ;
- request_type |= USB_DIR_IN;
-// dwRequestType = (u8) RTYPE_READ_V8_MEMORY;
- pipe = B2C2_USB_CTRL_PIPE_IN;
- break;
- case B2C2_USB_WRITE_V8_MEM:
- wIndex |= pbBuffer[0];
- request_type |= USB_DIR_OUT;
- nWaitTime = B2C2_WAIT_FOR_OPERATION_V8WRITE;
-// dwRequestType = (u8) RTYPE_WRITE_V8_MEMORY;
- pipe = B2C2_USB_CTRL_PIPE_OUT;
- break;
- case B2C2_USB_FLASH_BLOCK:
- request_type |= USB_DIR_OUT;
- nWaitTime = B2C2_WAIT_FOR_OPERATION_V8FLASH;
-// dwRequestType = (u8) RTYPE_WRITE_V8_FLASH;
- pipe = B2C2_USB_CTRL_PIPE_OUT;
- break;
- default:
- deb_info("unsupported request for v8_mem_req %x.\n",req);
- return -EINVAL;
- }
- deb_v8("v8mem: %02x %02x %04x %04x, len: %d\n",request_type,req,
- wAddress,wIndex,buflen);
-
- len = usb_control_msg(fc_usb->udev,pipe,
- req,
- request_type,
- wAddress,
- wIndex,
- pbBuffer,
- buflen,
- nWaitTime * HZ);
-
- debug_dump(pbBuffer,len,deb_v8);
-
- return len == buflen ? 0 : -EIO;
-}
-
-#define bytes_left_to_read_on_page(paddr,buflen) \
- ((V8_MEMORY_PAGE_SIZE - (paddr & V8_MEMORY_PAGE_MASK)) > buflen \
- ? buflen : (V8_MEMORY_PAGE_SIZE - (paddr & V8_MEMORY_PAGE_MASK)))
-
-static int flexcop_usb_memory_req(struct flexcop_usb *fc_usb,flexcop_usb_request_t req,
- flexcop_usb_mem_page_t page_start, u32 addr, int extended, u8 *buf, u32 len)
-{
- int i,ret = 0;
- u16 wMax;
- u32 pagechunk = 0;
-
- switch(req) {
- case B2C2_USB_READ_V8_MEM: wMax = USB_MEM_READ_MAX; break;
- case B2C2_USB_WRITE_V8_MEM: wMax = USB_MEM_WRITE_MAX; break;
- case B2C2_USB_FLASH_BLOCK: wMax = USB_FLASH_MAX; break;
- default:
- return -EINVAL;
- break;
- }
- for (i = 0; i < len;) {
- pagechunk = wMax < bytes_left_to_read_on_page(addr,len) ? wMax : bytes_left_to_read_on_page(addr,len);
- deb_info("%x\n",(addr & V8_MEMORY_PAGE_MASK) | (V8_MEMORY_EXTENDED*extended));
- if ((ret = flexcop_usb_v8_memory_req(fc_usb,req,
- page_start + (addr / V8_MEMORY_PAGE_SIZE), /* actual page */
- (addr & V8_MEMORY_PAGE_MASK) | (V8_MEMORY_EXTENDED*extended),
- &buf[i],pagechunk)) < 0)
- return ret;
-
- addr += pagechunk;
- len -= pagechunk;
- }
- return 0;
-}
-
-static int flexcop_usb_get_mac_addr(struct flexcop_device *fc, int extended)
-{
- return flexcop_usb_memory_req(fc->bus_specific,B2C2_USB_READ_V8_MEM,
- V8_MEMORY_PAGE_FLASH,0x1f010,1,fc->dvb_adapter.proposed_mac,6);
-}
-
-#if 0
-static int flexcop_usb_utility_req(struct flexcop_usb *fc_usb, int set,
- flexcop_usb_utility_function_t func, u8 extra, u16 wIndex,
- u16 buflen, u8 *pvBuffer)
-{
- u16 wValue;
- u8 request_type = (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR;
-// u8 dwRequestType = (u8) RTYPE_GENERIC,
- int nWaitTime = 2,
- pipe = set ? B2C2_USB_CTRL_PIPE_OUT : B2C2_USB_CTRL_PIPE_IN,
- len;
-
- wValue = (func << 8) | extra;
-
- len = usb_control_msg(fc_usb->udev,pipe,
- B2C2_USB_UTILITY,
- request_type,
- wValue,
- wIndex,
- pvBuffer,
- buflen,
- nWaitTime * HZ);
- return len == buflen ? 0 : -EIO;
-}
-#endif
-
-/* usb i2c stuff */
-static int flexcop_usb_i2c_req(struct flexcop_usb *fc_usb,
- flexcop_usb_request_t req, flexcop_usb_i2c_function_t func,
- flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u8 buflen)
-{
- u16 wValue, wIndex;
- int nWaitTime,pipe,len;
-// u8 dwRequestType;
- u8 request_type = USB_TYPE_VENDOR;
-
- switch (func) {
- case USB_FUNC_I2C_WRITE:
- case USB_FUNC_I2C_MULTIWRITE:
- case USB_FUNC_I2C_REPEATWRITE:
- /* DKT 020208 - add this to support special case of DiSEqC */
- case USB_FUNC_I2C_CHECKWRITE:
- pipe = B2C2_USB_CTRL_PIPE_OUT;
- nWaitTime = 2;
-// dwRequestType = (u8) RTYPE_GENERIC;
- request_type |= USB_DIR_OUT;
- break;
- case USB_FUNC_I2C_READ:
- case USB_FUNC_I2C_REPEATREAD:
- pipe = B2C2_USB_CTRL_PIPE_IN;
- nWaitTime = 2;
-// dwRequestType = (u8) RTYPE_GENERIC;
- request_type |= USB_DIR_IN;
- break;
- default:
- deb_info("unsupported function for i2c_req %x\n",func);
- return -EINVAL;
- }
- wValue = (func << 8 ) | (port << 4);
- wIndex = (chipaddr << 8 ) | addr;
-
- deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req,
- ((wValue && 0xff) << 8),wValue >> 8,((wIndex && 0xff) << 8),wIndex >> 8);
-
- len = usb_control_msg(fc_usb->udev,pipe,
- req,
- request_type,
- wValue,
- wIndex,
- buf,
- buflen,
- nWaitTime * HZ);
-
- return len == buflen ? 0 : -EREMOTEIO;
-}
-
-/* actual bus specific access functions, make sure prototype are/will be equal to pci */
-static flexcop_ibi_value flexcop_usb_read_ibi_reg(struct flexcop_device *fc, flexcop_ibi_register reg)
-{
- flexcop_ibi_value val;
- val.raw = 0;
- flexcop_usb_readwrite_dw(fc,reg, &val.raw, 1);
- return val;
-}
-
-static int flexcop_usb_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_register reg, flexcop_ibi_value val)
-{
- return flexcop_usb_readwrite_dw(fc,reg, &val.raw, 0);
-}
-
-static int flexcop_usb_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op,
- flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u16 len)
-{
- if (op == FC_READ)
- return flexcop_usb_i2c_req(fc->bus_specific,B2C2_USB_I2C_REQUEST,USB_FUNC_I2C_READ,port,chipaddr,addr,buf,len);
- else
- return flexcop_usb_i2c_req(fc->bus_specific,B2C2_USB_I2C_REQUEST,USB_FUNC_I2C_WRITE,port,chipaddr,addr,buf,len);
-}
-
-static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb, u8 *buffer, int buffer_length)
-{
- u8 *b;
- int l;
-
- deb_ts("tmp_buffer_length=%d, buffer_length=%d\n", fc_usb->tmp_buffer_length, buffer_length);
-
- if (fc_usb->tmp_buffer_length > 0) {
- memcpy(fc_usb->tmp_buffer+fc_usb->tmp_buffer_length, buffer, buffer_length);
- fc_usb->tmp_buffer_length += buffer_length;
- b = fc_usb->tmp_buffer;
- l = fc_usb->tmp_buffer_length;
- } else {
- b=buffer;
- l=buffer_length;
- }
-
- while (l >= 190) {
- if (*b == 0xff)
- switch (*(b+1) & 0x03) {
- case 0x01: /* media packet */
- if ( *(b+2) == 0x47 )
- flexcop_pass_dmx_packets(fc_usb->fc_dev, b+2, 1);
- else
- deb_ts("not ts packet %02x %02x %02x %02x \n", *(b+2), *(b+3), *(b+4), *(b+5) );
-
- b += 190;
- l -= 190;
- break;
- default:
- deb_ts("wrong packet type\n");
- l = 0;
- break;
- }
- else {
- deb_ts("wrong header\n");
- l = 0;
- }
- }
-
- if (l>0)
- memcpy(fc_usb->tmp_buffer, b, l);
- fc_usb->tmp_buffer_length = l;
-}
-
-static void flexcop_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
-{
- struct flexcop_usb *fc_usb = urb->context;
- int i;
-
- if (urb->actual_length > 0)
- deb_ts("urb completed, bufsize: %d actlen; %d\n",urb->transfer_buffer_length, urb->actual_length);
-
- for (i = 0; i < urb->number_of_packets; i++) {
- if (urb->iso_frame_desc[i].status < 0) {
- err("iso frame descriptor %d has an error: %d\n",i,urb->iso_frame_desc[i].status);
- } else
- if (urb->iso_frame_desc[i].actual_length > 0) {
- deb_ts("passed %d bytes to the demux\n",urb->iso_frame_desc[i].actual_length);
-
- flexcop_usb_process_frame(fc_usb,
- urb->transfer_buffer + urb->iso_frame_desc[i].offset,
- urb->iso_frame_desc[i].actual_length);
- }
- urb->iso_frame_desc[i].status = 0;
- urb->iso_frame_desc[i].actual_length = 0;
- }
-
- usb_submit_urb(urb,GFP_ATOMIC);
-}
-
-static int flexcop_usb_stream_control(struct flexcop_device *fc, int onoff)
-{
- /* submit/kill iso packets */
- return 0;
-}
-
-static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb)
-{
- int i;
- for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
- if (fc_usb->iso_urb[i] != NULL) {
- deb_ts("unlinking/killing urb no. %d\n",i);
- usb_kill_urb(fc_usb->iso_urb[i]);
- usb_free_urb(fc_usb->iso_urb[i]);
- }
-
- if (fc_usb->iso_buffer != NULL)
- pci_free_consistent(NULL,fc_usb->buffer_size, fc_usb->iso_buffer, fc_usb->dma_addr);
-}
-
-static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb)
-{
- u16 frame_size = fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize;
- int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size,i,j,ret;
- int buffer_offset = 0;
-
- deb_ts("creating %d iso-urbs with %d frames each of %d bytes size = %d.\n",
- B2C2_USB_NUM_ISO_URB, B2C2_USB_FRAMES_PER_ISO, frame_size,bufsize);
-
- fc_usb->iso_buffer = pci_alloc_consistent(NULL,bufsize,&fc_usb->dma_addr);
- if (fc_usb->iso_buffer == NULL)
- return -ENOMEM;
- memset(fc_usb->iso_buffer, 0, bufsize);
- fc_usb->buffer_size = bufsize;
-
- /* creating iso urbs */
- for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++)
- if (!(fc_usb->iso_urb[i] = usb_alloc_urb(B2C2_USB_FRAMES_PER_ISO,GFP_ATOMIC))) {
- ret = -ENOMEM;
- goto urb_error;
- }
- /* initialising and submitting iso urbs */
- for (i = 0; i < B2C2_USB_NUM_ISO_URB; i++) {
- int frame_offset = 0;
- struct urb *urb = fc_usb->iso_urb[i];
- deb_ts("initializing and submitting urb no. %d (buf_offset: %d).\n",i,buffer_offset);
-
- urb->dev = fc_usb->udev;
- urb->context = fc_usb;
- urb->complete = flexcop_usb_urb_complete;
- urb->pipe = B2C2_USB_DATA_PIPE;
- urb->transfer_flags = URB_ISO_ASAP;
- urb->interval = 1;
- urb->number_of_packets = B2C2_USB_FRAMES_PER_ISO;
- urb->transfer_buffer_length = frame_size * B2C2_USB_FRAMES_PER_ISO;
- urb->transfer_buffer = fc_usb->iso_buffer + buffer_offset;
-
- buffer_offset += frame_size * B2C2_USB_FRAMES_PER_ISO;
- for (j = 0; j < B2C2_USB_FRAMES_PER_ISO; j++) {
- deb_ts("urb no: %d, frame: %d, frame_offset: %d\n",i,j,frame_offset);
- urb->iso_frame_desc[j].offset = frame_offset;
- urb->iso_frame_desc[j].length = frame_size;
- frame_offset += frame_size;
- }
-
- if ((ret = usb_submit_urb(fc_usb->iso_urb[i],GFP_ATOMIC))) {
- err("submitting urb %d failed with %d.",i,ret);
- goto urb_error;
- }
- deb_ts("submitted urb no. %d.\n",i);
- }
-
-/* SRAM */
-
- flexcop_sram_set_dest(fc_usb->fc_dev,FC_SRAM_DEST_MEDIA | FC_SRAM_DEST_NET |
- FC_SRAM_DEST_CAO | FC_SRAM_DEST_CAI, FC_SRAM_DEST_TARGET_WAN_USB);
- flexcop_wan_set_speed(fc_usb->fc_dev,FC_WAN_SPEED_8MBITS);
- flexcop_sram_ctrl(fc_usb->fc_dev,1,1,1);
-
- return 0;
-
-urb_error:
- flexcop_usb_transfer_exit(fc_usb);
- return ret;
-}
-
-static int flexcop_usb_init(struct flexcop_usb *fc_usb)
-{
- /* use the alternate setting with the larges buffer */
- usb_set_interface(fc_usb->udev,0,1);
- switch (fc_usb->udev->speed) {
- case USB_SPEED_LOW:
- err("cannot handle USB speed because it is to sLOW.");
- return -ENODEV;
- break;
- case USB_SPEED_FULL:
- info("running at FULL speed.");
- break;
- case USB_SPEED_HIGH:
- info("running at HIGH speed.");
- break;
- case USB_SPEED_UNKNOWN: /* fall through */
- default:
- err("cannot handle USB speed because it is unkown.");
- return -ENODEV;
- }
- usb_set_intfdata(fc_usb->uintf, fc_usb);
- return 0;
-}
-
-static void flexcop_usb_exit(struct flexcop_usb *fc_usb)
-{
- usb_set_intfdata(fc_usb->uintf, NULL);
-}
-
-static int flexcop_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
- struct flexcop_usb *fc_usb = NULL;
- struct flexcop_device *fc = NULL;
- int ret;
-
- if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) {
- err("out of memory\n");
- return -ENOMEM;
- }
-
-/* general flexcop init */
- fc_usb = fc->bus_specific;
- fc_usb->fc_dev = fc;
-
- fc->read_ibi_reg = flexcop_usb_read_ibi_reg;
- fc->write_ibi_reg = flexcop_usb_write_ibi_reg;
- fc->i2c_request = flexcop_usb_i2c_request;
- fc->get_mac_addr = flexcop_usb_get_mac_addr;
-
- fc->stream_control = flexcop_usb_stream_control;
-
- fc->pid_filtering = 1;
- fc->bus_type = FC_USB;
-
- fc->dev = &udev->dev;
- fc->owner = THIS_MODULE;
-
-/* bus specific part */
- fc_usb->udev = udev;
- fc_usb->uintf = intf;
- if ((ret = flexcop_usb_init(fc_usb)) != 0)
- goto err_kfree;
-
-/* init flexcop */
- if ((ret = flexcop_device_initialize(fc)) != 0)
- goto err_usb_exit;
-
-/* xfer init */
- if ((ret = flexcop_usb_transfer_init(fc_usb)) != 0)
- goto err_fc_exit;
-
- info("%s successfully initialized and connected.",DRIVER_NAME);
- return 0;
-
-err_fc_exit:
- flexcop_device_exit(fc);
-err_usb_exit:
- flexcop_usb_exit(fc_usb);
-err_kfree:
- flexcop_device_kfree(fc);
- return ret;
-}
-
-static void flexcop_usb_disconnect(struct usb_interface *intf)
-{
- struct flexcop_usb *fc_usb = usb_get_intfdata(intf);
- flexcop_usb_transfer_exit(fc_usb);
- flexcop_device_exit(fc_usb->fc_dev);
- flexcop_usb_exit(fc_usb);
- flexcop_device_kfree(fc_usb->fc_dev);
- info("%s successfully deinitialized and disconnected.",DRIVER_NAME);
-}
-
-static struct usb_device_id flexcop_usb_table [] = {
- { USB_DEVICE(0x0af7, 0x0101) },
- { }
-};
-MODULE_DEVICE_TABLE (usb, flexcop_usb_table);
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver flexcop_usb_driver = {
- .name = "b2c2_flexcop_usb",
- .probe = flexcop_usb_probe,
- .disconnect = flexcop_usb_disconnect,
- .id_table = flexcop_usb_table,
-};
-
-/* module stuff */
-static int __init flexcop_usb_module_init(void)
-{
- int result;
- if ((result = usb_register(&flexcop_usb_driver))) {
- err("usb_register failed. (%d)",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit flexcop_usb_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&flexcop_usb_driver);
-}
-
-module_init(flexcop_usb_module_init);
-module_exit(flexcop_usb_module_exit);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_NAME);
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.h b/drivers/media/dvb/b2c2/flexcop-usb.h
deleted file mode 100644
index 630e647a2ca..00000000000
--- a/drivers/media/dvb/b2c2/flexcop-usb.h
+++ /dev/null
@@ -1,119 +0,0 @@
-#ifndef __FLEXCOP_USB_H_INCLUDED__
-#define __FLEXCOP_USB_H_INCLUDED__
-
-#include <linux/usb.h>
-
-/* transfer parameters */
-#define B2C2_USB_FRAMES_PER_ISO 4
-#define B2C2_USB_NUM_ISO_URB 4
-
-#define B2C2_USB_CTRL_PIPE_IN usb_rcvctrlpipe(fc_usb->udev,0)
-#define B2C2_USB_CTRL_PIPE_OUT usb_sndctrlpipe(fc_usb->udev,0)
-#define B2C2_USB_DATA_PIPE usb_rcvisocpipe(fc_usb->udev,0x81)
-
-struct flexcop_usb {
- struct usb_device *udev;
- struct usb_interface *uintf;
-
- u8 *iso_buffer;
- int buffer_size;
- dma_addr_t dma_addr;
- struct urb *iso_urb[B2C2_USB_NUM_ISO_URB];
-
- struct flexcop_device *fc_dev;
-
- u8 tmp_buffer[1023+190];
- int tmp_buffer_length;
-};
-
-#if 0
-/* request types TODO What is its use?*/
-typedef enum {
-
-/* something is wrong with this part
- RTYPE_READ_DW = (1 << 6),
- RTYPE_WRITE_DW_1 = (3 << 6),
- RTYPE_READ_V8_MEMORY = (6 << 6),
- RTYPE_WRITE_V8_MEMORY = (7 << 6),
- RTYPE_WRITE_V8_FLASH = (8 << 6),
- RTYPE_GENERIC = (9 << 6),
-*/
-} flexcop_usb_request_type_t;
-#endif
-
-/* request */
-typedef enum {
- B2C2_USB_WRITE_V8_MEM = 0x04,
- B2C2_USB_READ_V8_MEM = 0x05,
- B2C2_USB_READ_REG = 0x08,
- B2C2_USB_WRITE_REG = 0x0A,
-/* B2C2_USB_WRITEREGLO = 0x0A, */
- B2C2_USB_WRITEREGHI = 0x0B,
- B2C2_USB_FLASH_BLOCK = 0x10,
- B2C2_USB_I2C_REQUEST = 0x11,
- B2C2_USB_UTILITY = 0x12,
-} flexcop_usb_request_t;
-
-/* function definition for I2C_REQUEST */
-typedef enum {
- USB_FUNC_I2C_WRITE = 0x01,
- USB_FUNC_I2C_MULTIWRITE = 0x02,
- USB_FUNC_I2C_READ = 0x03,
- USB_FUNC_I2C_REPEATWRITE = 0x04,
- USB_FUNC_GET_DESCRIPTOR = 0x05,
- USB_FUNC_I2C_REPEATREAD = 0x06,
-/* DKT 020208 - add this to support special case of DiSEqC */
- USB_FUNC_I2C_CHECKWRITE = 0x07,
- USB_FUNC_I2C_CHECKRESULT = 0x08,
-} flexcop_usb_i2c_function_t;
-
-/*
- * function definition for UTILITY request 0x12
- * DKT 020304 - new utility function
- */
-typedef enum {
- UTILITY_SET_FILTER = 0x01,
- UTILITY_DATA_ENABLE = 0x02,
- UTILITY_FLEX_MULTIWRITE = 0x03,
- UTILITY_SET_BUFFER_SIZE = 0x04,
- UTILITY_FLEX_OPERATOR = 0x05,
- UTILITY_FLEX_RESET300_START = 0x06,
- UTILITY_FLEX_RESET300_STOP = 0x07,
- UTILITY_FLEX_RESET300 = 0x08,
- UTILITY_SET_ISO_SIZE = 0x09,
- UTILITY_DATA_RESET = 0x0A,
- UTILITY_GET_DATA_STATUS = 0x10,
- UTILITY_GET_V8_REG = 0x11,
-/* DKT 020326 - add function for v1.14 */
- UTILITY_SRAM_WRITE = 0x12,
- UTILITY_SRAM_READ = 0x13,
- UTILITY_SRAM_TESTFILL = 0x14,
- UTILITY_SRAM_TESTSET = 0x15,
- UTILITY_SRAM_TESTVERIFY = 0x16,
-} flexcop_usb_utility_function_t;
-
-#define B2C2_WAIT_FOR_OPERATION_RW 1*HZ /* 1 s */
-#define B2C2_WAIT_FOR_OPERATION_RDW 3*HZ /* 3 s */
-#define B2C2_WAIT_FOR_OPERATION_WDW 1*HZ /* 1 s */
-
-#define B2C2_WAIT_FOR_OPERATION_V8READ 3*HZ /* 3 s */
-#define B2C2_WAIT_FOR_OPERATION_V8WRITE 3*HZ /* 3 s */
-#define B2C2_WAIT_FOR_OPERATION_V8FLASH 3*HZ /* 3 s */
-
-typedef enum {
- V8_MEMORY_PAGE_DVB_CI = 0x20,
- V8_MEMORY_PAGE_DVB_DS = 0x40,
- V8_MEMORY_PAGE_MULTI2 = 0x60,
- V8_MEMORY_PAGE_FLASH = 0x80
-} flexcop_usb_mem_page_t;
-
-#define V8_MEMORY_EXTENDED (1 << 15)
-
-#define USB_MEM_READ_MAX 32
-#define USB_MEM_WRITE_MAX 1
-#define USB_FLASH_MAX 8
-
-#define V8_MEMORY_PAGE_SIZE 0x8000 // 32K
-#define V8_MEMORY_PAGE_MASK 0x7FFF
-
-#endif
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c
deleted file mode 100644
index 29ec4183118..00000000000
--- a/drivers/media/dvb/b2c2/flexcop.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * flexcop.c - driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * Copyright (C) 2004-5 Patrick Boettcher <patrick.boettcher@desy.de>
- *
- * based on the skystar2-driver
- * Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
- *
- * Acknowledgements:
- * John Jurrius from BBTI, Inc. for extensive support with
- * code examples and data books
- *
- * Bjarne Steinsbo, bjarne at steinsbo.com (some ideas for rewriting)
- *
- * Contributions to the skystar2-driver have been done by
- * Vincenzo Di Massa, hawk.it at tiscalinet.it (several DiSEqC fixes)
- * Roberto Ragusa, r.ragusa at libero.it (polishing, restyling the code)
- * Niklas Peinecke, peinecke at gdv.uni-hannover.de (hardware pid/mac filtering)
- *
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "flexcop.h"
-
-#define DRIVER_NAME "B2C2 FlexcopII/II(b)/III digital TV receiver chip"
-#define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@desy.de"
-
-#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
-#define DEBSTATUS ""
-#else
-#define DEBSTATUS " (debugging is not enabled)"
-#endif
-
-int b2c2_flexcop_debug;
-module_param_named(debug, b2c2_flexcop_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))." DEBSTATUS);
-#undef DEBSTATUS
-
-/* global zero for ibi values */
-flexcop_ibi_value ibi_zero;
-
-static int flexcop_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct flexcop_device *fc = dvbdmxfeed->demux->priv;
- return flexcop_pid_feed_control(fc,dvbdmxfeed,1);
-}
-
-static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct flexcop_device *fc = dvbdmxfeed->demux->priv;
- return flexcop_pid_feed_control(fc,dvbdmxfeed,0);
-}
-
-static int flexcop_dvb_init(struct flexcop_device *fc)
-{
- int ret;
- if ((ret = dvb_register_adapter(&fc->dvb_adapter,"FlexCop Digital TV device",fc->owner,fc->dev)) < 0) {
- err("error registering DVB adapter");
- return ret;
- }
- fc->dvb_adapter.priv = fc;
-
- fc->demux.dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING);
- fc->demux.priv = fc;
-
- fc->demux.filternum = fc->demux.feednum = FC_MAX_FEED;
-
- fc->demux.start_feed = flexcop_dvb_start_feed;
- fc->demux.stop_feed = flexcop_dvb_stop_feed;
- fc->demux.write_to_decoder = NULL;
-
- if ((ret = dvb_dmx_init(&fc->demux)) < 0) {
- err("dvb_dmx failed: error %d",ret);
- goto err_dmx;
- }
-
- fc->hw_frontend.source = DMX_FRONTEND_0;
-
- fc->dmxdev.filternum = fc->demux.feednum;
- fc->dmxdev.demux = &fc->demux.dmx;
- fc->dmxdev.capabilities = 0;
- if ((ret = dvb_dmxdev_init(&fc->dmxdev, &fc->dvb_adapter)) < 0) {
- err("dvb_dmxdev_init failed: error %d",ret);
- goto err_dmx_dev;
- }
-
- if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) {
- err("adding hw_frontend to dmx failed: error %d",ret);
- goto err_dmx_add_hw_frontend;
- }
-
- fc->mem_frontend.source = DMX_MEMORY_FE;
- if ((ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->mem_frontend)) < 0) {
- err("adding mem_frontend to dmx failed: error %d",ret);
- goto err_dmx_add_mem_frontend;
- }
-
- if ((ret = fc->demux.dmx.connect_frontend(&fc->demux.dmx, &fc->hw_frontend)) < 0) {
- err("connect frontend failed: error %d",ret);
- goto err_connect_frontend;
- }
-
- dvb_net_init(&fc->dvb_adapter, &fc->dvbnet, &fc->demux.dmx);
-
- fc->init_state |= FC_STATE_DVB_INIT;
- return 0;
-
-err_connect_frontend:
- fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->mem_frontend);
-err_dmx_add_mem_frontend:
- fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->hw_frontend);
-err_dmx_add_hw_frontend:
- dvb_dmxdev_release(&fc->dmxdev);
-err_dmx_dev:
- dvb_dmx_release(&fc->demux);
-err_dmx:
- dvb_unregister_adapter(&fc->dvb_adapter);
- return ret;
-}
-
-static void flexcop_dvb_exit(struct flexcop_device *fc)
-{
- if (fc->init_state & FC_STATE_DVB_INIT) {
- dvb_net_release(&fc->dvbnet);
-
- fc->demux.dmx.close(&fc->demux.dmx);
- fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->mem_frontend);
- fc->demux.dmx.remove_frontend(&fc->demux.dmx,&fc->hw_frontend);
- dvb_dmxdev_release(&fc->dmxdev);
- dvb_dmx_release(&fc->demux);
- dvb_unregister_adapter(&fc->dvb_adapter);
-
- deb_info("deinitialized dvb stuff\n");
- }
- fc->init_state &= ~FC_STATE_DVB_INIT;
-}
-
-/* these methods are necessary to achieve the long-term-goal of hiding the
- * struct flexcop_device from the bus-parts */
-void flexcop_pass_dmx_data(struct flexcop_device *fc, u8 *buf, u32 len)
-{
- dvb_dmx_swfilter(&fc->demux, buf, len);
-}
-EXPORT_SYMBOL(flexcop_pass_dmx_data);
-
-void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no)
-{
- dvb_dmx_swfilter_packets(&fc->demux, buf, no);
-}
-EXPORT_SYMBOL(flexcop_pass_dmx_packets);
-
-static void flexcop_reset(struct flexcop_device *fc)
-{
- flexcop_ibi_value v210,v204;
-
-/* reset the flexcop itself */
- fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
-
- v210.raw = 0;
- v210.sw_reset_210.reset_block_000 = 1;
- v210.sw_reset_210.reset_block_100 = 1;
- v210.sw_reset_210.reset_block_200 = 1;
- v210.sw_reset_210.reset_block_300 = 1;
- v210.sw_reset_210.reset_block_400 = 1;
- v210.sw_reset_210.reset_block_500 = 1;
- v210.sw_reset_210.reset_block_600 = 1;
- v210.sw_reset_210.reset_block_700 = 1;
- v210.sw_reset_210.Block_reset_enable = 0xb2;
-
- v210.sw_reset_210.Special_controls = 0xc259;
-
- fc->write_ibi_reg(fc,sw_reset_210,v210);
- msleep(1);
-
-/* reset the periphical devices */
-
- v204 = fc->read_ibi_reg(fc,misc_204);
- v204.misc_204.Per_reset_sig = 0;
- fc->write_ibi_reg(fc,misc_204,v204);
- msleep(1);
- v204.misc_204.Per_reset_sig = 1;
- fc->write_ibi_reg(fc,misc_204,v204);
-}
-
-void flexcop_reset_block_300(struct flexcop_device *fc)
-{
- flexcop_ibi_value v208_save = fc->read_ibi_reg(fc,ctrl_208),
- v210 = fc->read_ibi_reg(fc,sw_reset_210);
-
- deb_rdump("208: %08x, 210: %08x\n",v208_save.raw,v210.raw);
-
- fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
-
- v210.sw_reset_210.reset_block_300 = 1;
- v210.sw_reset_210.Block_reset_enable = 0xb2;
-
- fc->write_ibi_reg(fc,sw_reset_210,v210);
- msleep(1);
-
- fc->write_ibi_reg(fc,ctrl_208,v208_save);
-}
-EXPORT_SYMBOL(flexcop_reset_block_300);
-
-struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
-{
- void *bus;
- struct flexcop_device *fc = kzalloc(sizeof(struct flexcop_device), GFP_KERNEL);
- if (!fc) {
- err("no memory");
- return NULL;
- }
-
- bus = kzalloc(bus_specific_len, GFP_KERNEL);
- if (!bus) {
- err("no memory");
- kfree(fc);
- return NULL;
- }
-
- fc->bus_specific = bus;
-
- return fc;
-}
-EXPORT_SYMBOL(flexcop_device_kmalloc);
-
-void flexcop_device_kfree(struct flexcop_device *fc)
-{
- kfree(fc->bus_specific);
- kfree(fc);
-}
-EXPORT_SYMBOL(flexcop_device_kfree);
-
-int flexcop_device_initialize(struct flexcop_device *fc)
-{
- int ret;
- ibi_zero.raw = 0;
-
- flexcop_reset(fc);
- flexcop_determine_revision(fc);
- flexcop_sram_init(fc);
- flexcop_hw_filter_init(fc);
-
- flexcop_smc_ctrl(fc, 0);
-
- if ((ret = flexcop_dvb_init(fc)))
- goto error;
-
- /* do the MAC address reading after initializing the dvb_adapter */
- if (fc->get_mac_addr(fc, 0) == 0) {
- u8 *b = fc->dvb_adapter.proposed_mac;
- info("MAC address = %02x:%02x:%02x:%02x:%02x:%02x", b[0],b[1],b[2],b[3],b[4],b[5]);
- flexcop_set_mac_filter(fc,b);
- flexcop_mac_filter_ctrl(fc,1);
- } else
- warn("reading of MAC address failed.\n");
-
-
- if ((ret = flexcop_i2c_init(fc)))
- goto error;
-
- if ((ret = flexcop_frontend_init(fc)))
- goto error;
-
- flexcop_device_name(fc,"initialization of","complete");
-
- return 0;
-
-error:
- flexcop_device_exit(fc);
- return ret;
-}
-EXPORT_SYMBOL(flexcop_device_initialize);
-
-void flexcop_device_exit(struct flexcop_device *fc)
-{
- flexcop_frontend_exit(fc);
- flexcop_i2c_exit(fc);
- flexcop_dvb_exit(fc);
-}
-EXPORT_SYMBOL(flexcop_device_exit);
-
-static int flexcop_module_init(void)
-{
- info(DRIVER_NAME " loaded successfully");
- return 0;
-}
-
-static void flexcop_module_cleanup(void)
-{
- info(DRIVER_NAME " unloaded successfully");
-}
-
-module_init(flexcop_module_init);
-module_exit(flexcop_module_cleanup);
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_NAME);
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/b2c2/flexcop.h b/drivers/media/dvb/b2c2/flexcop.h
deleted file mode 100644
index 0cebe1d92e0..00000000000
--- a/drivers/media/dvb/b2c2/flexcop.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * This file is part of linux driver the digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * flexcop.h - private header file for all flexcop-chip-source files.
- *
- * see flexcop.c for copyright information.
- */
-#ifndef __FLEXCOP_H__
-#define __FLEXCOP_H___
-
-#define FC_LOG_PREFIX "b2c2-flexcop"
-#include "flexcop-common.h"
-
-extern int b2c2_flexcop_debug;
-
-/* debug */
-#ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
-#define dprintk(level,args...) \
- do { if ((b2c2_flexcop_debug & level)) printk(args); } while (0)
-#else
-#define dprintk(level,args...)
-#endif
-
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_tuner(args...) dprintk(0x02,args)
-#define deb_i2c(args...) dprintk(0x04,args)
-#define deb_ts(args...) dprintk(0x08,args)
-#define deb_sram(args...) dprintk(0x10,args)
-#define deb_rdump(args...) dprintk(0x20,args)
-
-#endif
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
deleted file mode 100644
index ed9a6756b19..00000000000
--- a/drivers/media/dvb/b2c2/flexcop_ibi_value_be.h
+++ /dev/null
@@ -1,458 +0,0 @@
-/* This file is part of linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * register descriptions
- *
- * see flexcop.c for copyright information.
- */
-
-/* This file is automatically generated, do not edit things here. */
-#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__
-#define __FLEXCOP_IBI_VALUE_INCLUDED__
-
-typedef union {
- u32 raw;
-
- struct {
- u32 dma_address0 :30;
- u32 dma_0No_update : 1;
- u32 dma_0start : 1;
- } dma_0x0;
-
- struct {
- u32 dma_addr_size :24;
- u32 DMA_maxpackets : 8;
- } dma_0x4_remap;
-
- struct {
- u32 dma_addr_size :24;
- u32 unused : 1;
- u32 dma1timer : 7;
- } dma_0x4_read;
-
- struct {
- u32 dma_addr_size :24;
- u32 dmatimer : 7;
- u32 unused : 1;
- } dma_0x4_write;
-
- struct {
- u32 dma_cur_addr :30;
- u32 unused : 2;
- } dma_0x8;
-
- struct {
- u32 dma_address1 :30;
- u32 remap_enable : 1;
- u32 dma_1start : 1;
- } dma_0xc;
-
- struct {
- u32 st_done : 1;
- u32 no_base_addr_ack_error : 1;
- u32 twoWS_port_reg : 2;
- u32 total_bytes : 2;
- u32 twoWS_rw : 1;
- u32 working_start : 1;
- u32 data1_reg : 8;
- u32 baseaddr : 8;
- u32 reserved1 : 1;
- u32 chipaddr : 7;
- } tw_sm_c_100;
-
- struct {
- u32 unused : 6;
- u32 force_stop : 1;
- u32 exlicit_stops : 1;
- u32 data4_reg : 8;
- u32 data3_reg : 8;
- u32 data2_reg : 8;
- } tw_sm_c_104;
-
- struct {
- u32 reserved2 :19;
- u32 tlo1 : 5;
- u32 reserved1 : 2;
- u32 thi1 : 6;
- } tw_sm_c_108;
-
- struct {
- u32 reserved2 :19;
- u32 tlo1 : 5;
- u32 reserved1 : 2;
- u32 thi1 : 6;
- } tw_sm_c_10c;
-
- struct {
- u32 reserved2 :19;
- u32 tlo1 : 5;
- u32 reserved1 : 2;
- u32 thi1 : 6;
- } tw_sm_c_110;
-
- struct {
- u32 LNB_CTLPrescaler_sig : 2;
- u32 LNB_CTLLowCount_sig :15;
- u32 LNB_CTLHighCount_sig :15;
- } lnb_switch_freq_200;
-
- struct {
- u32 Rev_N_sig_reserved2 : 1;
- u32 Rev_N_sig_caps : 1;
- u32 Rev_N_sig_reserved1 : 2;
- u32 Rev_N_sig_revision_hi : 4;
- u32 reserved :20;
- u32 Per_reset_sig : 1;
- u32 LNB_L_H_sig : 1;
- u32 ACPI3_sig : 1;
- u32 ACPI1_sig : 1;
- } misc_204;
-
- struct {
- u32 unused : 9;
- u32 Mailbox_from_V8_Enable_sig : 1;
- u32 DMA2_Size_IRQ_Enable_sig : 1;
- u32 DMA1_Size_IRQ_Enable_sig : 1;
- u32 DMA2_Timer_Enable_sig : 1;
- u32 DMA2_IRQ_Enable_sig : 1;
- u32 DMA1_Timer_Enable_sig : 1;
- u32 DMA1_IRQ_Enable_sig : 1;
- u32 Rcv_Data_sig : 1;
- u32 MAC_filter_Mode_sig : 1;
- u32 Multi2_Enable_sig : 1;
- u32 Per_CA_Enable_sig : 1;
- u32 SMC_Enable_sig : 1;
- u32 CA_Enable_sig : 1;
- u32 WAN_CA_Enable_sig : 1;
- u32 WAN_Enable_sig : 1;
- u32 Mask_filter_sig : 1;
- u32 Null_filter_sig : 1;
- u32 ECM_filter_sig : 1;
- u32 EMM_filter_sig : 1;
- u32 PMT_filter_sig : 1;
- u32 PCR_filter_sig : 1;
- u32 Stream2_filter_sig : 1;
- u32 Stream1_filter_sig : 1;
- } ctrl_208;
-
- struct {
- u32 reserved :21;
- u32 Transport_Error : 1;
- u32 LLC_SNAP_FLAG_set : 1;
- u32 Continuity_error_flag : 1;
- u32 Data_receiver_error : 1;
- u32 Mailbox_from_V8_Status_sig : 1;
- u32 DMA2_Size_IRQ_Status : 1;
- u32 DMA1_Size_IRQ_Status : 1;
- u32 DMA2_Timer_Status : 1;
- u32 DMA2_IRQ_Status : 1;
- u32 DMA1_Timer_Status : 1;
- u32 DMA1_IRQ_Status : 1;
- } irq_20c;
-
- struct {
- u32 Special_controls :16;
- u32 Block_reset_enable : 8;
- u32 reset_block_700 : 1;
- u32 reset_block_600 : 1;
- u32 reset_block_500 : 1;
- u32 reset_block_400 : 1;
- u32 reset_block_300 : 1;
- u32 reset_block_200 : 1;
- u32 reset_block_100 : 1;
- u32 reset_block_000 : 1;
- } sw_reset_210;
-
- struct {
- u32 unused2 :20;
- u32 polarity_PS_ERR_sig : 1;
- u32 polarity_PS_SYNC_sig : 1;
- u32 polarity_PS_VALID_sig : 1;
- u32 polarity_PS_CLK_sig : 1;
- u32 unused1 : 3;
- u32 s2p_sel_sig : 1;
- u32 section_pkg_enable_sig : 1;
- u32 halt_V8_sig : 1;
- u32 v2WS_oe_sig : 1;
- u32 vuart_oe_sig : 1;
- } misc_214;
-
- struct {
- u32 Mailbox_from_V8 :32;
- } mbox_v8_to_host_218;
-
- struct {
- u32 sysramaccess_busmuster : 1;
- u32 sysramaccess_write : 1;
- u32 unused : 7;
- u32 sysramaccess_addr :15;
- u32 sysramaccess_data : 8;
- } mbox_host_to_v8_21c;
-
- struct {
- u32 debug_fifo_problem : 1;
- u32 debug_flag_write_status00 : 1;
- u32 Stream2_trans : 1;
- u32 Stream2_PID :13;
- u32 debug_flag_pid_saved : 1;
- u32 MAC_Multicast_filter : 1;
- u32 Stream1_trans : 1;
- u32 Stream1_PID :13;
- } pid_filter_300;
-
- struct {
- u32 reserved : 2;
- u32 PMT_trans : 1;
- u32 PMT_PID :13;
- u32 debug_overrun2 : 1;
- u32 debug_overrun3 : 1;
- u32 PCR_trans : 1;
- u32 PCR_PID :13;
- } pid_filter_304;
-
- struct {
- u32 reserved : 2;
- u32 ECM_trans : 1;
- u32 ECM_PID :13;
- u32 EMM_filter_6 : 1;
- u32 EMM_filter_4 : 1;
- u32 EMM_trans : 1;
- u32 EMM_PID :13;
- } pid_filter_308;
-
- struct {
- u32 unused2 : 3;
- u32 Group_mask :13;
- u32 unused1 : 2;
- u32 Group_trans : 1;
- u32 Group_PID :13;
- } pid_filter_30c_ext_ind_0_7;
-
- struct {
- u32 unused :15;
- u32 net_master_read :17;
- } pid_filter_30c_ext_ind_1;
-
- struct {
- u32 unused :15;
- u32 net_master_write :17;
- } pid_filter_30c_ext_ind_2;
-
- struct {
- u32 unused :15;
- u32 next_net_master_write :17;
- } pid_filter_30c_ext_ind_3;
-
- struct {
- u32 reserved2 : 5;
- u32 stack_read :10;
- u32 reserved1 : 6;
- u32 state_write :10;
- u32 unused1 : 1;
- } pid_filter_30c_ext_ind_4;
-
- struct {
- u32 unused :22;
- u32 stack_cnt :10;
- } pid_filter_30c_ext_ind_5;
-
- struct {
- u32 unused : 4;
- u32 data_size_reg :12;
- u32 write_status4 : 2;
- u32 write_status1 : 2;
- u32 pid_fsm_save_reg300 : 2;
- u32 pid_fsm_save_reg4 : 2;
- u32 pid_fsm_save_reg3 : 2;
- u32 pid_fsm_save_reg2 : 2;
- u32 pid_fsm_save_reg1 : 2;
- u32 pid_fsm_save_reg0 : 2;
- } pid_filter_30c_ext_ind_6;
-
- struct {
- u32 unused :22;
- u32 pass_alltables : 1;
- u32 AB_select : 1;
- u32 extra_index_reg : 3;
- u32 index_reg : 5;
- } index_reg_310;
-
- struct {
- u32 reserved :17;
- u32 PID_enable_bit : 1;
- u32 PID_trans : 1;
- u32 PID :13;
- } pid_n_reg_314;
-
- struct {
- u32 reserved : 6;
- u32 HighAB_bit : 1;
- u32 Enable_bit : 1;
- u32 A6_byte : 8;
- u32 A5_byte : 8;
- u32 A4_byte : 8;
- } mac_low_reg_318;
-
- struct {
- u32 reserved : 8;
- u32 A3_byte : 8;
- u32 A2_byte : 8;
- u32 A1_byte : 8;
- } mac_high_reg_31c;
-
- struct {
- u32 data_Tag_ID :16;
- u32 reserved :16;
- } data_tag_400;
-
- struct {
- u32 Card_IDbyte3 : 8;
- u32 Card_IDbyte4 : 8;
- u32 Card_IDbyte5 : 8;
- u32 Card_IDbyte6 : 8;
- } card_id_408;
-
- struct {
- u32 Card_IDbyte1 : 8;
- u32 Card_IDbyte2 : 8;
- } card_id_40c;
-
- struct {
- u32 MAC6 : 8;
- u32 MAC3 : 8;
- u32 MAC2 : 8;
- u32 MAC1 : 8;
- } mac_address_418;
-
- struct {
- u32 reserved :16;
- u32 MAC8 : 8;
- u32 MAC7 : 8;
- } mac_address_41c;
-
- struct {
- u32 reserved :21;
- u32 txbuffempty : 1;
- u32 ReceiveByteFrameError : 1;
- u32 ReceiveDataReady : 1;
- u32 transmitter_data_byte : 8;
- } ci_600;
-
- struct {
- u32 pi_component_reg : 3;
- u32 pi_rw : 1;
- u32 pi_ha :20;
- u32 pi_d : 8;
- } pi_604;
-
- struct {
- u32 pi_busy_n : 1;
- u32 pi_wait_n : 1;
- u32 pi_timeout_status : 1;
- u32 pi_CiMax_IRQ_n : 1;
- u32 config_cclk : 1;
- u32 config_cs_n : 1;
- u32 config_wr_n : 1;
- u32 config_Prog_n : 1;
- u32 config_Init_stat : 1;
- u32 config_Done_stat : 1;
- u32 pcmcia_b_mod_pwr_n : 1;
- u32 pcmcia_a_mod_pwr_n : 1;
- u32 reserved : 3;
- u32 Timer_addr : 5;
- u32 unused : 1;
- u32 timer_data : 7;
- u32 Timer_Load_req : 1;
- u32 Timer_Read_req : 1;
- u32 oncecycle_read : 1;
- u32 serialReset : 1;
- } pi_608;
-
- struct {
- u32 reserved : 6;
- u32 rw_flag : 1;
- u32 dvb_en : 1;
- u32 key_array_row : 5;
- u32 key_array_col : 3;
- u32 key_code : 2;
- u32 key_enable : 1;
- u32 PID :13;
- } dvb_reg_60c;
-
- struct {
- u32 start_sram_ibi : 1;
- u32 reserved2 : 1;
- u32 ce_pin_reg : 1;
- u32 oe_pin_reg : 1;
- u32 reserved1 : 3;
- u32 sc_xfer_bit : 1;
- u32 sram_data : 8;
- u32 sram_rw : 1;
- u32 sram_addr :15;
- } sram_ctrl_reg_700;
-
- struct {
- u32 net_addr_write :16;
- u32 net_addr_read :16;
- } net_buf_reg_704;
-
- struct {
- u32 cai_cnt : 4;
- u32 reserved2 : 6;
- u32 cai_write :11;
- u32 reserved1 : 5;
- u32 cai_read :11;
- } cai_buf_reg_708;
-
- struct {
- u32 cao_cnt : 4;
- u32 reserved2 : 6;
- u32 cap_write :11;
- u32 reserved1 : 5;
- u32 cao_read :11;
- } cao_buf_reg_70c;
-
- struct {
- u32 media_cnt : 4;
- u32 reserved2 : 6;
- u32 media_write :11;
- u32 reserved1 : 5;
- u32 media_read :11;
- } media_buf_reg_710;
-
- struct {
- u32 reserved :17;
- u32 ctrl_maximumfill : 1;
- u32 ctrl_sramdma : 1;
- u32 ctrl_usb_wan : 1;
- u32 cao_ovflow_error : 1;
- u32 cai_ovflow_error : 1;
- u32 media_ovflow_error : 1;
- u32 net_ovflow_error : 1;
- u32 MEDIA_Dest : 2;
- u32 CAO_Dest : 2;
- u32 CAI_Dest : 2;
- u32 NET_Dest : 2;
- } sram_dest_reg_714;
-
- struct {
- u32 reserved3 :11;
- u32 net_addr_write : 1;
- u32 reserved2 : 3;
- u32 net_addr_read : 1;
- u32 reserved1 : 4;
- u32 net_cnt :12;
- } net_buf_reg_718;
-
- struct {
- u32 reserved3 : 4;
- u32 wan_pkt_frame : 4;
- u32 reserved2 : 4;
- u32 sram_memmap : 2;
- u32 sram_chip : 2;
- u32 wan_wait_state : 8;
- u32 reserved1 : 6;
- u32 wan_speed_sig : 2;
- } wan_ctrl_reg_71c;
-} flexcop_ibi_value;
-
-#endif
diff --git a/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h b/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
deleted file mode 100644
index 49f2315b6e5..00000000000
--- a/drivers/media/dvb/b2c2/flexcop_ibi_value_le.h
+++ /dev/null
@@ -1,458 +0,0 @@
-/* This file is part of linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
- *
- * register descriptions
- *
- * see flexcop.c for copyright information.
- */
-
-/* This file is automatically generated, do not edit things here. */
-#ifndef __FLEXCOP_IBI_VALUE_INCLUDED__
-#define __FLEXCOP_IBI_VALUE_INCLUDED__
-
-typedef union {
- u32 raw;
-
- struct {
- u32 dma_0start : 1;
- u32 dma_0No_update : 1;
- u32 dma_address0 :30;
- } dma_0x0;
-
- struct {
- u32 DMA_maxpackets : 8;
- u32 dma_addr_size :24;
- } dma_0x4_remap;
-
- struct {
- u32 dma1timer : 7;
- u32 unused : 1;
- u32 dma_addr_size :24;
- } dma_0x4_read;
-
- struct {
- u32 unused : 1;
- u32 dmatimer : 7;
- u32 dma_addr_size :24;
- } dma_0x4_write;
-
- struct {
- u32 unused : 2;
- u32 dma_cur_addr :30;
- } dma_0x8;
-
- struct {
- u32 dma_1start : 1;
- u32 remap_enable : 1;
- u32 dma_address1 :30;
- } dma_0xc;
-
- struct {
- u32 chipaddr : 7;
- u32 reserved1 : 1;
- u32 baseaddr : 8;
- u32 data1_reg : 8;
- u32 working_start : 1;
- u32 twoWS_rw : 1;
- u32 total_bytes : 2;
- u32 twoWS_port_reg : 2;
- u32 no_base_addr_ack_error : 1;
- u32 st_done : 1;
- } tw_sm_c_100;
-
- struct {
- u32 data2_reg : 8;
- u32 data3_reg : 8;
- u32 data4_reg : 8;
- u32 exlicit_stops : 1;
- u32 force_stop : 1;
- u32 unused : 6;
- } tw_sm_c_104;
-
- struct {
- u32 thi1 : 6;
- u32 reserved1 : 2;
- u32 tlo1 : 5;
- u32 reserved2 :19;
- } tw_sm_c_108;
-
- struct {
- u32 thi1 : 6;
- u32 reserved1 : 2;
- u32 tlo1 : 5;
- u32 reserved2 :19;
- } tw_sm_c_10c;
-
- struct {
- u32 thi1 : 6;
- u32 reserved1 : 2;
- u32 tlo1 : 5;
- u32 reserved2 :19;
- } tw_sm_c_110;
-
- struct {
- u32 LNB_CTLHighCount_sig :15;
- u32 LNB_CTLLowCount_sig :15;
- u32 LNB_CTLPrescaler_sig : 2;
- } lnb_switch_freq_200;
-
- struct {
- u32 ACPI1_sig : 1;
- u32 ACPI3_sig : 1;
- u32 LNB_L_H_sig : 1;
- u32 Per_reset_sig : 1;
- u32 reserved :20;
- u32 Rev_N_sig_revision_hi : 4;
- u32 Rev_N_sig_reserved1 : 2;
- u32 Rev_N_sig_caps : 1;
- u32 Rev_N_sig_reserved2 : 1;
- } misc_204;
-
- struct {
- u32 Stream1_filter_sig : 1;
- u32 Stream2_filter_sig : 1;
- u32 PCR_filter_sig : 1;
- u32 PMT_filter_sig : 1;
- u32 EMM_filter_sig : 1;
- u32 ECM_filter_sig : 1;
- u32 Null_filter_sig : 1;
- u32 Mask_filter_sig : 1;
- u32 WAN_Enable_sig : 1;
- u32 WAN_CA_Enable_sig : 1;
- u32 CA_Enable_sig : 1;
- u32 SMC_Enable_sig : 1;
- u32 Per_CA_Enable_sig : 1;
- u32 Multi2_Enable_sig : 1;
- u32 MAC_filter_Mode_sig : 1;
- u32 Rcv_Data_sig : 1;
- u32 DMA1_IRQ_Enable_sig : 1;
- u32 DMA1_Timer_Enable_sig : 1;
- u32 DMA2_IRQ_Enable_sig : 1;
- u32 DMA2_Timer_Enable_sig : 1;
- u32 DMA1_Size_IRQ_Enable_sig : 1;
- u32 DMA2_Size_IRQ_Enable_sig : 1;
- u32 Mailbox_from_V8_Enable_sig : 1;
- u32 unused : 9;
- } ctrl_208;
-
- struct {
- u32 DMA1_IRQ_Status : 1;
- u32 DMA1_Timer_Status : 1;
- u32 DMA2_IRQ_Status : 1;
- u32 DMA2_Timer_Status : 1;
- u32 DMA1_Size_IRQ_Status : 1;
- u32 DMA2_Size_IRQ_Status : 1;
- u32 Mailbox_from_V8_Status_sig : 1;
- u32 Data_receiver_error : 1;
- u32 Continuity_error_flag : 1;
- u32 LLC_SNAP_FLAG_set : 1;
- u32 Transport_Error : 1;
- u32 reserved :21;
- } irq_20c;
-
- struct {
- u32 reset_block_000 : 1;
- u32 reset_block_100 : 1;
- u32 reset_block_200 : 1;
- u32 reset_block_300 : 1;
- u32 reset_block_400 : 1;
- u32 reset_block_500 : 1;
- u32 reset_block_600 : 1;
- u32 reset_block_700 : 1;
- u32 Block_reset_enable : 8;
- u32 Special_controls :16;
- } sw_reset_210;
-
- struct {
- u32 vuart_oe_sig : 1;
- u32 v2WS_oe_sig : 1;
- u32 halt_V8_sig : 1;
- u32 section_pkg_enable_sig : 1;
- u32 s2p_sel_sig : 1;
- u32 unused1 : 3;
- u32 polarity_PS_CLK_sig : 1;
- u32 polarity_PS_VALID_sig : 1;
- u32 polarity_PS_SYNC_sig : 1;
- u32 polarity_PS_ERR_sig : 1;
- u32 unused2 :20;
- } misc_214;
-
- struct {
- u32 Mailbox_from_V8 :32;
- } mbox_v8_to_host_218;
-
- struct {
- u32 sysramaccess_data : 8;
- u32 sysramaccess_addr :15;
- u32 unused : 7;
- u32 sysramaccess_write : 1;
- u32 sysramaccess_busmuster : 1;
- } mbox_host_to_v8_21c;
-
- struct {
- u32 Stream1_PID :13;
- u32 Stream1_trans : 1;
- u32 MAC_Multicast_filter : 1;
- u32 debug_flag_pid_saved : 1;
- u32 Stream2_PID :13;
- u32 Stream2_trans : 1;
- u32 debug_flag_write_status00 : 1;
- u32 debug_fifo_problem : 1;
- } pid_filter_300;
-
- struct {
- u32 PCR_PID :13;
- u32 PCR_trans : 1;
- u32 debug_overrun3 : 1;
- u32 debug_overrun2 : 1;
- u32 PMT_PID :13;
- u32 PMT_trans : 1;
- u32 reserved : 2;
- } pid_filter_304;
-
- struct {
- u32 EMM_PID :13;
- u32 EMM_trans : 1;
- u32 EMM_filter_4 : 1;
- u32 EMM_filter_6 : 1;
- u32 ECM_PID :13;
- u32 ECM_trans : 1;
- u32 reserved : 2;
- } pid_filter_308;
-
- struct {
- u32 Group_PID :13;
- u32 Group_trans : 1;
- u32 unused1 : 2;
- u32 Group_mask :13;
- u32 unused2 : 3;
- } pid_filter_30c_ext_ind_0_7;
-
- struct {
- u32 net_master_read :17;
- u32 unused :15;
- } pid_filter_30c_ext_ind_1;
-
- struct {
- u32 net_master_write :17;
- u32 unused :15;
- } pid_filter_30c_ext_ind_2;
-
- struct {
- u32 next_net_master_write :17;
- u32 unused :15;
- } pid_filter_30c_ext_ind_3;
-
- struct {
- u32 unused1 : 1;
- u32 state_write :10;
- u32 reserved1 : 6;
- u32 stack_read :10;
- u32 reserved2 : 5;
- } pid_filter_30c_ext_ind_4;
-
- struct {
- u32 stack_cnt :10;
- u32 unused :22;
- } pid_filter_30c_ext_ind_5;
-
- struct {
- u32 pid_fsm_save_reg0 : 2;
- u32 pid_fsm_save_reg1 : 2;
- u32 pid_fsm_save_reg2 : 2;
- u32 pid_fsm_save_reg3 : 2;
- u32 pid_fsm_save_reg4 : 2;
- u32 pid_fsm_save_reg300 : 2;
- u32 write_status1 : 2;
- u32 write_status4 : 2;
- u32 data_size_reg :12;
- u32 unused : 4;
- } pid_filter_30c_ext_ind_6;
-
- struct {
- u32 index_reg : 5;
- u32 extra_index_reg : 3;
- u32 AB_select : 1;
- u32 pass_alltables : 1;
- u32 unused :22;
- } index_reg_310;
-
- struct {
- u32 PID :13;
- u32 PID_trans : 1;
- u32 PID_enable_bit : 1;
- u32 reserved :17;
- } pid_n_reg_314;
-
- struct {
- u32 A4_byte : 8;
- u32 A5_byte : 8;
- u32 A6_byte : 8;
- u32 Enable_bit : 1;
- u32 HighAB_bit : 1;
- u32 reserved : 6;
- } mac_low_reg_318;
-
- struct {
- u32 A1_byte : 8;
- u32 A2_byte : 8;
- u32 A3_byte : 8;
- u32 reserved : 8;
- } mac_high_reg_31c;
-
- struct {
- u32 reserved :16;
- u32 data_Tag_ID :16;
- } data_tag_400;
-
- struct {
- u32 Card_IDbyte6 : 8;
- u32 Card_IDbyte5 : 8;
- u32 Card_IDbyte4 : 8;
- u32 Card_IDbyte3 : 8;
- } card_id_408;
-
- struct {
- u32 Card_IDbyte2 : 8;
- u32 Card_IDbyte1 : 8;
- } card_id_40c;
-
- struct {
- u32 MAC1 : 8;
- u32 MAC2 : 8;
- u32 MAC3 : 8;
- u32 MAC6 : 8;
- } mac_address_418;
-
- struct {
- u32 MAC7 : 8;
- u32 MAC8 : 8;
- u32 reserved :16;
- } mac_address_41c;
-
- struct {
- u32 transmitter_data_byte : 8;
- u32 ReceiveDataReady : 1;
- u32 ReceiveByteFrameError : 1;
- u32 txbuffempty : 1;
- u32 reserved :21;
- } ci_600;
-
- struct {
- u32 pi_d : 8;
- u32 pi_ha :20;
- u32 pi_rw : 1;
- u32 pi_component_reg : 3;
- } pi_604;
-
- struct {
- u32 serialReset : 1;
- u32 oncecycle_read : 1;
- u32 Timer_Read_req : 1;
- u32 Timer_Load_req : 1;
- u32 timer_data : 7;
- u32 unused : 1;
- u32 Timer_addr : 5;
- u32 reserved : 3;
- u32 pcmcia_a_mod_pwr_n : 1;
- u32 pcmcia_b_mod_pwr_n : 1;
- u32 config_Done_stat : 1;
- u32 config_Init_stat : 1;
- u32 config_Prog_n : 1;
- u32 config_wr_n : 1;
- u32 config_cs_n : 1;
- u32 config_cclk : 1;
- u32 pi_CiMax_IRQ_n : 1;
- u32 pi_timeout_status : 1;
- u32 pi_wait_n : 1;
- u32 pi_busy_n : 1;
- } pi_608;
-
- struct {
- u32 PID :13;
- u32 key_enable : 1;
- u32 key_code : 2;
- u32 key_array_col : 3;
- u32 key_array_row : 5;
- u32 dvb_en : 1;
- u32 rw_flag : 1;
- u32 reserved : 6;
- } dvb_reg_60c;
-
- struct {
- u32 sram_addr :15;
- u32 sram_rw : 1;
- u32 sram_data : 8;
- u32 sc_xfer_bit : 1;
- u32 reserved1 : 3;
- u32 oe_pin_reg : 1;
- u32 ce_pin_reg : 1;
- u32 reserved2 : 1;
- u32 start_sram_ibi : 1;
- } sram_ctrl_reg_700;
-
- struct {
- u32 net_addr_read :16;
- u32 net_addr_write :16;
- } net_buf_reg_704;
-
- struct {
- u32 cai_read :11;
- u32 reserved1 : 5;
- u32 cai_write :11;
- u32 reserved2 : 6;
- u32 cai_cnt : 4;
- } cai_buf_reg_708;
-
- struct {
- u32 cao_read :11;
- u32 reserved1 : 5;
- u32 cap_write :11;
- u32 reserved2 : 6;
- u32 cao_cnt : 4;
- } cao_buf_reg_70c;
-
- struct {
- u32 media_read :11;
- u32 reserved1 : 5;
- u32 media_write :11;
- u32 reserved2 : 6;
- u32 media_cnt : 4;
- } media_buf_reg_710;
-
- struct {
- u32 NET_Dest : 2;
- u32 CAI_Dest : 2;
- u32 CAO_Dest : 2;
- u32 MEDIA_Dest : 2;
- u32 net_ovflow_error : 1;
- u32 media_ovflow_error : 1;
- u32 cai_ovflow_error : 1;
- u32 cao_ovflow_error : 1;
- u32 ctrl_usb_wan : 1;
- u32 ctrl_sramdma : 1;
- u32 ctrl_maximumfill : 1;
- u32 reserved :17;
- } sram_dest_reg_714;
-
- struct {
- u32 net_cnt :12;
- u32 reserved1 : 4;
- u32 net_addr_read : 1;
- u32 reserved2 : 3;
- u32 net_addr_write : 1;
- u32 reserved3 :11;
- } net_buf_reg_718;
-
- struct {
- u32 wan_speed_sig : 2;
- u32 reserved1 : 6;
- u32 wan_wait_state : 8;
- u32 sram_chip : 2;
- u32 sram_memmap : 2;
- u32 reserved2 : 4;
- u32 wan_pkt_frame : 4;
- u32 reserved3 : 4;
- } wan_ctrl_reg_71c;
-} flexcop_ibi_value;
-
-#endif
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
deleted file mode 100644
index 7d0ee1ab290..00000000000
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ /dev/null
@@ -1,23 +0,0 @@
-config DVB_BT8XX
- tristate "BT8xx based PCI cards"
- depends on DVB_CORE && PCI && I2C && VIDEO_BT848
- select DVB_PLL
- select DVB_MT352
- select DVB_SP887X
- select DVB_NXT6000
- select DVB_CX24110
- select DVB_OR51211
- select DVB_LGDT330X
- select DVB_ZL10353
- select FW_LOADER
- help
- Support for PCI cards based on the Bt8xx PCI bridge. Examples are
- the Nebula cards, the Pinnacle PCTV cards, the Twinhan DST cards,
- the pcHDTV HD2000 cards, the DViCO FusionHDTV Lite cards, and
- some AVerMedia cards.
-
- Since these cards have no MPEG decoder onboard, they transmit
- only compressed MPEG data over the PCI bus, so you need
- an external software decoder to watch TV on your computer.
-
- Say Y if you own such a device and want to use it.
diff --git a/drivers/media/dvb/bt8xx/Makefile b/drivers/media/dvb/bt8xx/Makefile
deleted file mode 100644
index 9d197efb481..00000000000
--- a/drivers/media/dvb/bt8xx/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video/bt8xx -Idrivers/media/dvb/frontends
diff --git a/drivers/media/dvb/bt8xx/bt878.c b/drivers/media/dvb/bt8xx/bt878.c
deleted file mode 100644
index 755822ee6e9..00000000000
--- a/drivers/media/dvb/bt8xx/bt878.c
+++ /dev/null
@@ -1,635 +0,0 @@
-/*
- * bt878.c: part of the driver for the Pinnacle PCTV Sat DVB PCI card
- *
- * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de>
- *
- * large parts based on the bttv driver
- * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@metzlerbros.de)
- * & Marcus Metzler (mocm@metzlerbros.de)
- * (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <asm/io.h>
-#include <linux/ioport.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
-#include <linux/types.h>
-#include <linux/interrupt.h>
-#include <linux/kmod.h>
-#include <linux/vmalloc.h>
-#include <linux/init.h>
-
-#include "dmxdev.h"
-#include "dvbdev.h"
-#include "bt878.h"
-#include "dst_priv.h"
-
-
-/**************************************/
-/* Miscellaneous utility definitions */
-/**************************************/
-
-static unsigned int bt878_verbose = 1;
-static unsigned int bt878_debug;
-
-module_param_named(verbose, bt878_verbose, int, 0444);
-MODULE_PARM_DESC(verbose,
- "verbose startup messages, default is 1 (yes)");
-module_param_named(debug, bt878_debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off debugging, default is 0 (off).");
-
-int bt878_num;
-struct bt878 bt878[BT878_MAX];
-
-EXPORT_SYMBOL(bt878_num);
-EXPORT_SYMBOL(bt878);
-
-#define btwrite(dat,adr) bmtwrite((dat), (bt->bt878_mem+(adr)))
-#define btread(adr) bmtread(bt->bt878_mem+(adr))
-
-#define btand(dat,adr) btwrite((dat) & btread(adr), adr)
-#define btor(dat,adr) btwrite((dat) | btread(adr), adr)
-#define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
-
-#if defined(dprintk)
-#undef dprintk
-#endif
-#define dprintk if(bt878_debug) printk
-
-static void bt878_mem_free(struct bt878 *bt)
-{
- if (bt->buf_cpu) {
- pci_free_consistent(bt->dev, bt->buf_size, bt->buf_cpu,
- bt->buf_dma);
- bt->buf_cpu = NULL;
- }
-
- if (bt->risc_cpu) {
- pci_free_consistent(bt->dev, bt->risc_size, bt->risc_cpu,
- bt->risc_dma);
- bt->risc_cpu = NULL;
- }
-}
-
-static int bt878_mem_alloc(struct bt878 *bt)
-{
- if (!bt->buf_cpu) {
- bt->buf_size = 128 * 1024;
-
- bt->buf_cpu =
- pci_alloc_consistent(bt->dev, bt->buf_size,
- &bt->buf_dma);
-
- if (!bt->buf_cpu)
- return -ENOMEM;
-
- memset(bt->buf_cpu, 0, bt->buf_size);
- }
-
- if (!bt->risc_cpu) {
- bt->risc_size = PAGE_SIZE;
- bt->risc_cpu =
- pci_alloc_consistent(bt->dev, bt->risc_size,
- &bt->risc_dma);
-
- if (!bt->risc_cpu) {
- bt878_mem_free(bt);
- return -ENOMEM;
- }
-
- memset(bt->risc_cpu, 0, bt->risc_size);
- }
-
- return 0;
-}
-
-/* RISC instructions */
-#define RISC_WRITE (0x01 << 28)
-#define RISC_JUMP (0x07 << 28)
-#define RISC_SYNC (0x08 << 28)
-
-/* RISC bits */
-#define RISC_WR_SOL (1 << 27)
-#define RISC_WR_EOL (1 << 26)
-#define RISC_IRQ (1 << 24)
-#define RISC_STATUS(status) ((((~status) & 0x0F) << 20) | ((status & 0x0F) << 16))
-#define RISC_SYNC_RESYNC (1 << 15)
-#define RISC_SYNC_FM1 0x06
-#define RISC_SYNC_VRO 0x0C
-
-#define RISC_FLUSH() bt->risc_pos = 0
-#define RISC_INSTR(instr) bt->risc_cpu[bt->risc_pos++] = cpu_to_le32(instr)
-
-static int bt878_make_risc(struct bt878 *bt)
-{
- bt->block_bytes = bt->buf_size >> 4;
- bt->block_count = 1 << 4;
- bt->line_bytes = bt->block_bytes;
- bt->line_count = bt->block_count;
-
- while (bt->line_bytes > 4095) {
- bt->line_bytes >>= 1;
- bt->line_count <<= 1;
- }
-
- if (bt->line_count > 255) {
- printk("bt878: buffer size error!\n");
- return -EINVAL;
- }
- return 0;
-}
-
-
-static void bt878_risc_program(struct bt878 *bt, u32 op_sync_orin)
-{
- u32 buf_pos = 0;
- u32 line;
-
- RISC_FLUSH();
- RISC_INSTR(RISC_SYNC | RISC_SYNC_FM1 | op_sync_orin);
- RISC_INSTR(0);
-
- dprintk("bt878: risc len lines %u, bytes per line %u\n",
- bt->line_count, bt->line_bytes);
- for (line = 0; line < bt->line_count; line++) {
- // At the beginning of every block we issue an IRQ with previous (finished) block number set
- if (!(buf_pos % bt->block_bytes))
- RISC_INSTR(RISC_WRITE | RISC_WR_SOL | RISC_WR_EOL |
- RISC_IRQ |
- RISC_STATUS(((buf_pos /
- bt->block_bytes) +
- (bt->block_count -
- 1)) %
- bt->block_count) | bt->
- line_bytes);
- else
- RISC_INSTR(RISC_WRITE | RISC_WR_SOL | RISC_WR_EOL |
- bt->line_bytes);
- RISC_INSTR(bt->buf_dma + buf_pos);
- buf_pos += bt->line_bytes;
- }
-
- RISC_INSTR(RISC_SYNC | op_sync_orin | RISC_SYNC_VRO);
- RISC_INSTR(0);
-
- RISC_INSTR(RISC_JUMP);
- RISC_INSTR(bt->risc_dma);
-
- btwrite((bt->line_count << 16) | bt->line_bytes, BT878_APACK_LEN);
-}
-
-/*****************************/
-/* Start/Stop grabbing funcs */
-/*****************************/
-
-void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin,
- u32 irq_err_ignore)
-{
- u32 int_mask;
-
- dprintk("bt878 debug: bt878_start (ctl=%8.8x)\n", controlreg);
- /* complete the writing of the risc dma program now we have
- * the card specifics
- */
- bt878_risc_program(bt, op_sync_orin);
- controlreg &= ~0x1f;
- controlreg |= 0x1b;
-
- btwrite(bt->risc_dma, BT878_ARISC_START);
-
- /* original int mask had :
- * 6 2 8 4 0
- * 1111 1111 1000 0000 0000
- * SCERR|OCERR|PABORT|RIPERR|FDSR|FTRGT|FBUS|RISCI
- * Hacked for DST to:
- * SCERR | OCERR | FDSR | FTRGT | FBUS | RISCI
- */
- int_mask = BT878_ASCERR | BT878_AOCERR | BT878_APABORT |
- BT878_ARIPERR | BT878_APPERR | BT878_AFDSR | BT878_AFTRGT |
- BT878_AFBUS | BT878_ARISCI;
-
-
- /* ignore pesky bits */
- int_mask &= ~irq_err_ignore;
-
- btwrite(int_mask, BT878_AINT_MASK);
- btwrite(controlreg, BT878_AGPIO_DMA_CTL);
-}
-
-void bt878_stop(struct bt878 *bt)
-{
- u32 stat;
- int i = 0;
-
- dprintk("bt878 debug: bt878_stop\n");
-
- btwrite(0, BT878_AINT_MASK);
- btand(~0x13, BT878_AGPIO_DMA_CTL);
-
- do {
- stat = btread(BT878_AINT_STAT);
- if (!(stat & BT878_ARISC_EN))
- break;
- i++;
- } while (i < 500);
-
- dprintk("bt878(%d) debug: bt878_stop, i=%d, stat=0x%8.8x\n",
- bt->nr, i, stat);
-}
-
-EXPORT_SYMBOL(bt878_start);
-EXPORT_SYMBOL(bt878_stop);
-
-/*****************************/
-/* Interrupt service routine */
-/*****************************/
-
-static irqreturn_t bt878_irq(int irq, void *dev_id, struct pt_regs *regs)
-{
- u32 stat, astat, mask;
- int count;
- struct bt878 *bt;
-
- bt = (struct bt878 *) dev_id;
-
- count = 0;
- while (1) {
- stat = btread(BT878_AINT_STAT);
- mask = btread(BT878_AINT_MASK);
- if (!(astat = (stat & mask)))
- return IRQ_NONE; /* this interrupt is not for me */
-/* dprintk("bt878(%d) debug: irq count %d, stat 0x%8.8x, mask 0x%8.8x\n",bt->nr,count,stat,mask); */
- btwrite(astat, BT878_AINT_STAT); /* try to clear interupt condition */
-
-
- if (astat & (BT878_ASCERR | BT878_AOCERR)) {
- if (bt878_verbose) {
- printk("bt878(%d): irq%s%s risc_pc=%08x\n",
- bt->nr,
- (astat & BT878_ASCERR) ? " SCERR" :
- "",
- (astat & BT878_AOCERR) ? " OCERR" :
- "", btread(BT878_ARISC_PC));
- }
- }
- if (astat & (BT878_APABORT | BT878_ARIPERR | BT878_APPERR)) {
- if (bt878_verbose) {
- printk
- ("bt878(%d): irq%s%s%s risc_pc=%08x\n",
- bt->nr,
- (astat & BT878_APABORT) ? " PABORT" :
- "",
- (astat & BT878_ARIPERR) ? " RIPERR" :
- "",
- (astat & BT878_APPERR) ? " PPERR" :
- "", btread(BT878_ARISC_PC));
- }
- }
- if (astat & (BT878_AFDSR | BT878_AFTRGT | BT878_AFBUS)) {
- if (bt878_verbose) {
- printk
- ("bt878(%d): irq%s%s%s risc_pc=%08x\n",
- bt->nr,
- (astat & BT878_AFDSR) ? " FDSR" : "",
- (astat & BT878_AFTRGT) ? " FTRGT" :
- "",
- (astat & BT878_AFBUS) ? " FBUS" : "",
- btread(BT878_ARISC_PC));
- }
- }
- if (astat & BT878_ARISCI) {
- bt->finished_block = (stat & BT878_ARISCS) >> 28;
- tasklet_schedule(&bt->tasklet);
- break;
- }
- count++;
- if (count > 20) {
- btwrite(0, BT878_AINT_MASK);
- printk(KERN_ERR
- "bt878(%d): IRQ lockup, cleared int mask\n",
- bt->nr);
- break;
- }
- }
- return IRQ_HANDLED;
-}
-
-int
-bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp)
-{
- int retval;
-
- retval = 0;
- if (mutex_lock_interruptible(&bt->gpio_lock))
- return -ERESTARTSYS;
- /* special gpio signal */
- switch (cmd) {
- case DST_IG_ENABLE:
- // dprintk("dvb_bt8xx: dst enable mask 0x%02x enb 0x%02x \n", mp->dstg.enb.mask, mp->dstg.enb.enable);
- retval = bttv_gpio_enable(bt->bttv_nr,
- mp->enb.mask,
- mp->enb.enable);
- break;
- case DST_IG_WRITE:
- // dprintk("dvb_bt8xx: dst write gpio mask 0x%02x out 0x%02x\n", mp->dstg.outp.mask, mp->dstg.outp.highvals);
- retval = bttv_write_gpio(bt->bttv_nr,
- mp->outp.mask,
- mp->outp.highvals);
-
- break;
- case DST_IG_READ:
- /* read */
- retval = bttv_read_gpio(bt->bttv_nr, &mp->rd.value);
- // dprintk("dvb_bt8xx: dst read gpio 0x%02x\n", (unsigned)mp->dstg.rd.value);
- break;
- case DST_IG_TS:
- /* Set packet size */
- bt->TS_Size = mp->psize;
- break;
-
- default:
- retval = -EINVAL;
- break;
- }
- mutex_unlock(&bt->gpio_lock);
- return retval;
-}
-
-EXPORT_SYMBOL(bt878_device_control);
-
-
-static struct cards card_list[] __devinitdata = {
-
- { 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" },
- { 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" },
- { 0x001c11bd, BTTV_BOARD_PINNACLESAT, "Pinnacle PCTV Sat" },
- { 0x002611bd, BTTV_BOARD_TWINHAN_DST, "Pinnacle PCTV SAT CI" },
- { 0x00011822, BTTV_BOARD_TWINHAN_DST, "Twinhan VisionPlus DVB" },
- { 0xfc00270f, BTTV_BOARD_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" },
- { 0x07711461, BTTV_BOARD_AVDVBT_771, "AVermedia AverTV DVB-T 771" },
- { 0xdb1018ac, BTTV_BOARD_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" },
- { 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" },
- { 0x20007063, BTTV_BOARD_PC_HDTV, "pcHDTV HD-2000 TV" },
- { 0x00261822, BTTV_BOARD_TWINHAN_DST, "DNTV Live! Mini" },
-
- { 0, -1, NULL }
-};
-
-
-/***********************/
-/* PCI device handling */
-/***********************/
-
-static int __devinit bt878_probe(struct pci_dev *dev,
- const struct pci_device_id *pci_id)
-{
- int result = 0, has_dvb = 0, i;
- unsigned char lat;
- struct bt878 *bt;
-#if defined(__powerpc__)
- unsigned int cmd;
-#endif
- unsigned int cardid;
- unsigned short id;
- struct cards *dvb_cards;
-
- printk(KERN_INFO "bt878: Bt878 AUDIO function found (%d).\n",
- bt878_num);
- if (bt878_num >= BT878_MAX) {
- printk(KERN_ERR "bt878: Too many devices inserted\n");
- result = -ENOMEM;
- goto fail0;
- }
- if (pci_enable_device(dev))
- return -EIO;
-
- pci_read_config_word(dev, PCI_SUBSYSTEM_ID, &id);
- cardid = id << 16;
- pci_read_config_word(dev, PCI_SUBSYSTEM_VENDOR_ID, &id);
- cardid |= id;
-
- for (i = 0, dvb_cards = card_list; i < ARRAY_SIZE(card_list); i++, dvb_cards++) {
- if (cardid == dvb_cards->pci_id) {
- printk("%s: card id=[0x%x],[ %s ] has DVB functions.\n",
- __func__, cardid, dvb_cards->name);
- has_dvb = 1;
- }
- }
-
- if (!has_dvb) {
- printk("%s: card id=[0x%x], Unknown card.\nExiting..\n", __func__, cardid);
- result = -EINVAL;
-
- goto fail0;
- }
-
- bt = &bt878[bt878_num];
- bt->dev = dev;
- bt->nr = bt878_num;
- bt->shutdown = 0;
-
- bt->id = dev->device;
- bt->irq = dev->irq;
- bt->bt878_adr = pci_resource_start(dev, 0);
- if (!request_mem_region(pci_resource_start(dev, 0),
- pci_resource_len(dev, 0), "bt878")) {
- result = -EBUSY;
- goto fail0;
- }
-
- pci_read_config_byte(dev, PCI_CLASS_REVISION, &bt->revision);
- pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
-
-
- printk(KERN_INFO "bt878(%d): Bt%x (rev %d) at %02x:%02x.%x, ",
- bt878_num, bt->id, bt->revision, dev->bus->number,
- PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
- printk("irq: %d, latency: %d, memory: 0x%lx\n",
- bt->irq, lat, bt->bt878_adr);
-
-
-#if defined(__powerpc__)
- /* on OpenFirmware machines (PowerMac at least), PCI memory cycle */
- /* response on cards with no firmware is not enabled by OF */
- pci_read_config_dword(dev, PCI_COMMAND, &cmd);
- cmd = (cmd | PCI_COMMAND_MEMORY);
- pci_write_config_dword(dev, PCI_COMMAND, cmd);
-#endif
-
-#ifdef __sparc__
- bt->bt878_mem = (unsigned char *) bt->bt878_adr;
-#else
- bt->bt878_mem = ioremap(bt->bt878_adr, 0x1000);
-#endif
-
- /* clear interrupt mask */
- btwrite(0, BT848_INT_MASK);
-
- result = request_irq(bt->irq, bt878_irq,
- IRQF_SHARED | IRQF_DISABLED, "bt878",
- (void *) bt);
- if (result == -EINVAL) {
- printk(KERN_ERR "bt878(%d): Bad irq number or handler\n",
- bt878_num);
- goto fail1;
- }
- if (result == -EBUSY) {
- printk(KERN_ERR
- "bt878(%d): IRQ %d busy, change your PnP config in BIOS\n",
- bt878_num, bt->irq);
- goto fail1;
- }
- if (result < 0)
- goto fail1;
-
- pci_set_master(dev);
- pci_set_drvdata(dev, bt);
-
-/* if(init_bt878(btv) < 0) {
- bt878_remove(dev);
- return -EIO;
- }
-*/
-
- if ((result = bt878_mem_alloc(bt))) {
- printk("bt878: failed to allocate memory!\n");
- goto fail2;
- }
-
- bt878_make_risc(bt);
- btwrite(0, BT878_AINT_MASK);
- bt878_num++;
-
- return 0;
-
- fail2:
- free_irq(bt->irq, bt);
- fail1:
- release_mem_region(pci_resource_start(bt->dev, 0),
- pci_resource_len(bt->dev, 0));
- fail0:
- pci_disable_device(dev);
- return result;
-}
-
-static void __devexit bt878_remove(struct pci_dev *pci_dev)
-{
- u8 command;
- struct bt878 *bt = pci_get_drvdata(pci_dev);
-
- if (bt878_verbose)
- printk("bt878(%d): unloading\n", bt->nr);
-
- /* turn off all capturing, DMA and IRQs */
- btand(~0x13, BT878_AGPIO_DMA_CTL);
-
- /* first disable interrupts before unmapping the memory! */
- btwrite(0, BT878_AINT_MASK);
- btwrite(~0U, BT878_AINT_STAT);
-
- /* disable PCI bus-mastering */
- pci_read_config_byte(bt->dev, PCI_COMMAND, &command);
- /* Should this be &=~ ?? */
- command &= ~PCI_COMMAND_MASTER;
- pci_write_config_byte(bt->dev, PCI_COMMAND, command);
-
- free_irq(bt->irq, bt);
- printk(KERN_DEBUG "bt878_mem: 0x%p.\n", bt->bt878_mem);
- if (bt->bt878_mem)
- iounmap(bt->bt878_mem);
-
- release_mem_region(pci_resource_start(bt->dev, 0),
- pci_resource_len(bt->dev, 0));
- /* wake up any waiting processes
- because shutdown flag is set, no new processes (in this queue)
- are expected
- */
- bt->shutdown = 1;
- bt878_mem_free(bt);
-
- pci_set_drvdata(pci_dev, NULL);
- pci_disable_device(pci_dev);
- return;
-}
-
-static struct pci_device_id bt878_pci_tbl[] __devinitdata = {
- {PCI_VENDOR_ID_BROOKTREE, PCI_DEVICE_ID_BROOKTREE_878,
- PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
- {0,}
-};
-
-MODULE_DEVICE_TABLE(pci, bt878_pci_tbl);
-
-static struct pci_driver bt878_pci_driver = {
- .name = "bt878",
- .id_table = bt878_pci_tbl,
- .probe = bt878_probe,
- .remove = bt878_remove,
-};
-
-static int bt878_pci_driver_registered;
-
-/*******************************/
-/* Module management functions */
-/*******************************/
-
-static int bt878_init_module(void)
-{
- bt878_num = 0;
- bt878_pci_driver_registered = 0;
-
- printk(KERN_INFO "bt878: AUDIO driver version %d.%d.%d loaded\n",
- (BT878_VERSION_CODE >> 16) & 0xff,
- (BT878_VERSION_CODE >> 8) & 0xff,
- BT878_VERSION_CODE & 0xff);
-/*
- bt878_check_chipset();
-*/
- /* later we register inside of bt878_find_audio_dma()
- * because we may want to ignore certain cards */
- bt878_pci_driver_registered = 1;
- return pci_register_driver(&bt878_pci_driver);
-}
-
-static void bt878_cleanup_module(void)
-{
- if (bt878_pci_driver_registered) {
- bt878_pci_driver_registered = 0;
- pci_unregister_driver(&bt878_pci_driver);
- }
- return;
-}
-
-module_init(bt878_init_module);
-module_exit(bt878_cleanup_module);
-
-//MODULE_AUTHOR("XXX");
-MODULE_LICENSE("GPL");
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/drivers/media/dvb/bt8xx/bt878.h b/drivers/media/dvb/bt8xx/bt878.h
deleted file mode 100644
index f685bc12960..00000000000
--- a/drivers/media/dvb/bt8xx/bt878.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- bt878.h - Bt878 audio module (register offsets)
-
- Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de>
-
- 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.
-*/
-
-#ifndef _BT878_H_
-#define _BT878_H_
-
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/mutex.h>
-
-#include "bt848.h"
-#include "bttv.h"
-
-#define BT878_VERSION_CODE 0x000000
-
-#define BT878_AINT_STAT 0x100
-#define BT878_ARISCS (0xf<<28)
-#define BT878_ARISC_EN (1<<27)
-#define BT878_ASCERR (1<<19)
-#define BT878_AOCERR (1<<18)
-#define BT878_APABORT (1<<17)
-#define BT878_ARIPERR (1<<16)
-#define BT878_APPERR (1<<15)
-#define BT878_AFDSR (1<<14)
-#define BT878_AFTRGT (1<<13)
-#define BT878_AFBUS (1<<12)
-#define BT878_ARISCI (1<<11)
-#define BT878_AOFLOW (1<<3)
-
-#define BT878_AINT_MASK 0x104
-
-#define BT878_AGPIO_DMA_CTL 0x10c
-#define BT878_A_GAIN (0xf<<28)
-#define BT878_A_G2X (1<<27)
-#define BT878_A_PWRDN (1<<26)
-#define BT878_A_SEL (3<<24)
-#define BT878_DA_SCE (1<<23)
-#define BT878_DA_LRI (1<<22)
-#define BT878_DA_MLB (1<<21)
-#define BT878_DA_LRD (0x1f<<16)
-#define BT878_DA_DPM (1<<15)
-#define BT878_DA_SBR (1<<14)
-#define BT878_DA_ES2 (1<<13)
-#define BT878_DA_LMT (1<<12)
-#define BT878_DA_SDR (0xf<<8)
-#define BT878_DA_IOM (3<<6)
-#define BT878_DA_APP (1<<5)
-#define BT878_ACAP_EN (1<<4)
-#define BT878_PKTP (3<<2)
-#define BT878_RISC_EN (1<<1)
-#define BT878_FIFO_EN 1
-
-#define BT878_APACK_LEN 0x110
-#define BT878_AFP_LEN (0xff<<16)
-#define BT878_ALP_LEN 0xfff
-
-#define BT878_ARISC_START 0x114
-
-#define BT878_ARISC_PC 0x120
-
-/* BT878 FUNCTION 0 REGISTERS */
-#define BT878_GPIO_DMA_CTL 0x10c
-
-/* Interrupt register */
-#define BT878_INT_STAT 0x100
-#define BT878_INT_MASK 0x104
-#define BT878_I2CRACK (1<<25)
-#define BT878_I2CDONE (1<<8)
-
-#define BT878_MAX 4
-
-#define BT878_RISC_SYNC_MASK (1 << 15)
-
-
-#define BTTV_BOARD_UNKNOWN 0x00
-#define BTTV_BOARD_PINNACLESAT 0x5e
-#define BTTV_BOARD_NEBULA_DIGITV 0x68
-#define BTTV_BOARD_PC_HDTV 0x70
-#define BTTV_BOARD_TWINHAN_DST 0x71
-#define BTTV_BOARD_AVDVBT_771 0x7b
-#define BTTV_BOARD_AVDVBT_761 0x7c
-#define BTTV_BOARD_DVICO_DVBT_LITE 0x80
-#define BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE 0x87
-
-struct cards {
- __u32 pci_id;
- __u16 card_id;
- char *name;
-};
-
-extern int bt878_num;
-
-struct bt878 {
- struct mutex gpio_lock;
- unsigned int nr;
- unsigned int bttv_nr;
- struct i2c_adapter *adapter;
- struct pci_dev *dev;
- unsigned int id;
- unsigned int TS_Size;
- unsigned char revision;
- unsigned int irq;
- unsigned long bt878_adr;
- volatile void __iomem *bt878_mem; /* function 1 */
-
- volatile u32 finished_block;
- volatile u32 last_block;
- u32 block_count;
- u32 block_bytes;
- u32 line_bytes;
- u32 line_count;
-
- u32 buf_size;
- u8 *buf_cpu;
- dma_addr_t buf_dma;
-
- u32 risc_size;
- u32 *risc_cpu;
- dma_addr_t risc_dma;
- u32 risc_pos;
-
- struct tasklet_struct tasklet;
- int shutdown;
-};
-
-extern struct bt878 bt878[BT878_MAX];
-
-void bt878_start(struct bt878 *bt, u32 controlreg, u32 op_sync_orin,
- u32 irq_err_ignore);
-void bt878_stop(struct bt878 *bt);
-
-#if defined(__powerpc__) /* big-endian */
-extern __inline__ void io_st_le32(volatile unsigned __iomem *addr, unsigned val)
-{
- __asm__ __volatile__("stwbrx %1,0,%2":"=m"(*addr):"r"(val),
- "r"(addr));
- __asm__ __volatile__("eieio":::"memory");
-}
-
-#define bmtwrite(dat,adr) io_st_le32((adr),(dat))
-#define bmtread(adr) ld_le32((adr))
-#else
-#define bmtwrite(dat,adr) writel((dat), (adr))
-#define bmtread(adr) readl(adr)
-#endif
-
-#endif
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
deleted file mode 100644
index 06ac899a9a2..00000000000
--- a/drivers/media/dvb/bt8xx/dst.c
+++ /dev/null
@@ -1,1862 +0,0 @@
-/*
- Frontend/Card driver for TwinHan DST Frontend
- Copyright (C) 2003 Jamie Honan
- Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/delay.h>
-#include <asm/div64.h>
-#include "dvb_frontend.h"
-#include "dst_priv.h"
-#include "dst_common.h"
-
-static unsigned int verbose = 1;
-module_param(verbose, int, 0644);
-MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
-
-static unsigned int dst_addons;
-module_param(dst_addons, int, 0644);
-MODULE_PARM_DESC(dst_addons, "CA daughterboard, default is 0 (No addons)");
-
-static unsigned int dst_algo;
-module_param(dst_algo, int, 0644);
-MODULE_PARM_DESC(dst_algo, "tuning algo: default is 0=(SW), 1=(HW)");
-
-#define HAS_LOCK 1
-#define ATTEMPT_TUNE 2
-#define HAS_POWER 4
-
-#define DST_ERROR 0
-#define DST_NOTICE 1
-#define DST_INFO 2
-#define DST_DEBUG 3
-
-#define dprintk(x, y, z, format, arg...) do { \
- if (z) { \
- if ((x > DST_ERROR) && (x > y)) \
- printk(KERN_ERR "dst(%d) %s: " format "\n", \
- state->bt->nr, __func__ , ##arg); \
- else if ((x > DST_NOTICE) && (x > y)) \
- printk(KERN_NOTICE "dst(%d) %s: " format "\n", \
- state->bt->nr, __func__ , ##arg); \
- else if ((x > DST_INFO) && (x > y)) \
- printk(KERN_INFO "dst(%d) %s: " format "\n", \
- state->bt->nr, __func__ , ##arg); \
- else if ((x > DST_DEBUG) && (x > y)) \
- printk(KERN_DEBUG "dst(%d) %s: " format "\n", \
- state->bt->nr, __func__ , ##arg); \
- } else { \
- if (x > y) \
- printk(format, ##arg); \
- } \
-} while(0)
-
-
-static void dst_packsize(struct dst_state *state, int psize)
-{
- union dst_gpio_packet bits;
-
- bits.psize = psize;
- bt878_device_control(state->bt, DST_IG_TS, &bits);
-}
-
-int dst_gpio_outb(struct dst_state *state, u32 mask, u32 enbb, u32 outhigh, int delay)
-{
- union dst_gpio_packet enb;
- union dst_gpio_packet bits;
- int err;
-
- enb.enb.mask = mask;
- enb.enb.enable = enbb;
-
- dprintk(verbose, DST_INFO, 1, "mask=[%04x], enbb=[%04x], outhigh=[%04x]", mask, enbb, outhigh);
- if ((err = bt878_device_control(state->bt, DST_IG_ENABLE, &enb)) < 0) {
- dprintk(verbose, DST_INFO, 1, "dst_gpio_enb error (err == %i, mask == %02x, enb == %02x)", err, mask, enbb);
- return -EREMOTEIO;
- }
- udelay(1000);
- /* because complete disabling means no output, no need to do output packet */
- if (enbb == 0)
- return 0;
- if (delay)
- msleep(10);
- bits.outp.mask = enbb;
- bits.outp.highvals = outhigh;
- if ((err = bt878_device_control(state->bt, DST_IG_WRITE, &bits)) < 0) {
- dprintk(verbose, DST_INFO, 1, "dst_gpio_outb error (err == %i, enbb == %02x, outhigh == %02x)", err, enbb, outhigh);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(dst_gpio_outb);
-
-int dst_gpio_inb(struct dst_state *state, u8 *result)
-{
- union dst_gpio_packet rd_packet;
- int err;
-
- *result = 0;
- if ((err = bt878_device_control(state->bt, DST_IG_READ, &rd_packet)) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb error (err == %i)", err);
- return -EREMOTEIO;
- }
- *result = (u8) rd_packet.rd.value;
-
- return 0;
-}
-EXPORT_SYMBOL(dst_gpio_inb);
-
-int rdc_reset_state(struct dst_state *state)
-{
- dprintk(verbose, DST_INFO, 1, "Resetting state machine");
- if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, 0, NO_DELAY) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
- return -1;
- }
- msleep(10);
- if (dst_gpio_outb(state, RDC_8820_INT, RDC_8820_INT, RDC_8820_INT, NO_DELAY) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
- msleep(10);
- return -1;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(rdc_reset_state);
-
-int rdc_8820_reset(struct dst_state *state)
-{
- dprintk(verbose, DST_DEBUG, 1, "Resetting DST");
- if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, 0, NO_DELAY) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
- return -1;
- }
- udelay(1000);
- if (dst_gpio_outb(state, RDC_8820_RESET, RDC_8820_RESET, RDC_8820_RESET, DELAY) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
- return -1;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(rdc_8820_reset);
-
-int dst_pio_enable(struct dst_state *state)
-{
- if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_ENABLE, 0, NO_DELAY) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
- return -1;
- }
- udelay(1000);
-
- return 0;
-}
-EXPORT_SYMBOL(dst_pio_enable);
-
-int dst_pio_disable(struct dst_state *state)
-{
- if (dst_gpio_outb(state, ~0, RDC_8820_PIO_0_DISABLE, RDC_8820_PIO_0_DISABLE, NO_DELAY) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_outb ERROR !");
- return -1;
- }
- if (state->type_flags & DST_TYPE_HAS_FW_1)
- udelay(1000);
-
- return 0;
-}
-EXPORT_SYMBOL(dst_pio_disable);
-
-int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode)
-{
- u8 reply;
- int i;
-
- for (i = 0; i < 200; i++) {
- if (dst_gpio_inb(state, &reply) < 0) {
- dprintk(verbose, DST_ERROR, 1, "dst_gpio_inb ERROR !");
- return -1;
- }
- if ((reply & RDC_8820_PIO_0_ENABLE) == 0) {
- dprintk(verbose, DST_INFO, 1, "dst wait ready after %d", i);
- return 1;
- }
- msleep(10);
- }
- dprintk(verbose, DST_NOTICE, 1, "dst wait NOT ready after %d", i);
-
- return 0;
-}
-EXPORT_SYMBOL(dst_wait_dst_ready);
-
-int dst_error_recovery(struct dst_state *state)
-{
- dprintk(verbose, DST_NOTICE, 1, "Trying to return from previous errors.");
- dst_pio_disable(state);
- msleep(10);
- dst_pio_enable(state);
- msleep(10);
-
- return 0;
-}
-EXPORT_SYMBOL(dst_error_recovery);
-
-int dst_error_bailout(struct dst_state *state)
-{
- dprintk(verbose, DST_INFO, 1, "Trying to bailout from previous error.");
- rdc_8820_reset(state);
- dst_pio_disable(state);
- msleep(10);
-
- return 0;
-}
-EXPORT_SYMBOL(dst_error_bailout);
-
-int dst_comm_init(struct dst_state *state)
-{
- dprintk(verbose, DST_INFO, 1, "Initializing DST.");
- if ((dst_pio_enable(state)) < 0) {
- dprintk(verbose, DST_ERROR, 1, "PIO Enable Failed");
- return -1;
- }
- if ((rdc_reset_state(state)) < 0) {
- dprintk(verbose, DST_ERROR, 1, "RDC 8820 State RESET Failed.");
- return -1;
- }
- if (state->type_flags & DST_TYPE_HAS_FW_1)
- msleep(100);
- else
- msleep(5);
-
- return 0;
-}
-EXPORT_SYMBOL(dst_comm_init);
-
-int write_dst(struct dst_state *state, u8 *data, u8 len)
-{
- struct i2c_msg msg = {
- .addr = state->config->demod_address,
- .flags = 0,
- .buf = data,
- .len = len
- };
-
- int err;
- u8 cnt, i;
-
- dprintk(verbose, DST_NOTICE, 0, "writing [ ");
- for (i = 0; i < len; i++)
- dprintk(verbose, DST_NOTICE, 0, "%02x ", data[i]);
- dprintk(verbose, DST_NOTICE, 0, "]\n");
-
- for (cnt = 0; cnt < 2; cnt++) {
- if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
- dprintk(verbose, DST_INFO, 1, "_write_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, data[0]);
- dst_error_recovery(state);
- continue;
- } else
- break;
- }
- if (cnt >= 2) {
- dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET");
- dst_error_bailout(state);
-
- return -1;
- }
-
- return 0;
-}
-EXPORT_SYMBOL(write_dst);
-
-int read_dst(struct dst_state *state, u8 *ret, u8 len)
-{
- struct i2c_msg msg = {
- .addr = state->config->demod_address,
- .flags = I2C_M_RD,
- .buf = ret,
- .len = len
- };
-
- int err;
- int cnt;
-
- for (cnt = 0; cnt < 2; cnt++) {
- if ((err = i2c_transfer(state->i2c, &msg, 1)) < 0) {
- dprintk(verbose, DST_INFO, 1, "read_dst error (err == %i, len == 0x%02x, b0 == 0x%02x)", err, len, ret[0]);
- dst_error_recovery(state);
- continue;
- } else
- break;
- }
- if (cnt >= 2) {
- dprintk(verbose, DST_INFO, 1, "RDC 8820 RESET");
- dst_error_bailout(state);
-
- return -1;
- }
- dprintk(verbose, DST_DEBUG, 1, "reply is 0x%x", ret[0]);
- for (err = 1; err < len; err++)
- dprintk(verbose, DST_DEBUG, 0, " 0x%x", ret[err]);
- if (err > 1)
- dprintk(verbose, DST_DEBUG, 0, "\n");
-
- return 0;
-}
-EXPORT_SYMBOL(read_dst);
-
-static int dst_set_polarization(struct dst_state *state)
-{
- switch (state->voltage) {
- case SEC_VOLTAGE_13: /* Vertical */
- dprintk(verbose, DST_INFO, 1, "Polarization=[Vertical]");
- state->tx_tuna[8] &= ~0x40;
- break;
- case SEC_VOLTAGE_18: /* Horizontal */
- dprintk(verbose, DST_INFO, 1, "Polarization=[Horizontal]");
- state->tx_tuna[8] |= 0x40;
- break;
- case SEC_VOLTAGE_OFF:
- break;
- }
-
- return 0;
-}
-
-static int dst_set_freq(struct dst_state *state, u32 freq)
-{
- state->frequency = freq;
- dprintk(verbose, DST_INFO, 1, "set Frequency %u", freq);
-
- if (state->dst_type == DST_TYPE_IS_SAT) {
- freq = freq / 1000;
- if (freq < 950 || freq > 2150)
- return -EINVAL;
- state->tx_tuna[2] = (freq >> 8);
- state->tx_tuna[3] = (u8) freq;
- state->tx_tuna[4] = 0x01;
- state->tx_tuna[8] &= ~0x04;
- if (state->type_flags & DST_TYPE_HAS_OBS_REGS) {
- if (freq < 1531)
- state->tx_tuna[8] |= 0x04;
- }
- } else if (state->dst_type == DST_TYPE_IS_TERR) {
- freq = freq / 1000;
- if (freq < 137000 || freq > 858000)
- return -EINVAL;
- state->tx_tuna[2] = (freq >> 16) & 0xff;
- state->tx_tuna[3] = (freq >> 8) & 0xff;
- state->tx_tuna[4] = (u8) freq;
- } else if (state->dst_type == DST_TYPE_IS_CABLE) {
- freq = freq / 1000;
- state->tx_tuna[2] = (freq >> 16) & 0xff;
- state->tx_tuna[3] = (freq >> 8) & 0xff;
- state->tx_tuna[4] = (u8) freq;
- } else if (state->dst_type == DST_TYPE_IS_ATSC) {
- freq = freq / 1000;
- if (freq < 51000 || freq > 858000)
- return -EINVAL;
- state->tx_tuna[2] = (freq >> 16) & 0xff;
- state->tx_tuna[3] = (freq >> 8) & 0xff;
- state->tx_tuna[4] = (u8) freq;
- state->tx_tuna[5] = 0x00; /* ATSC */
- state->tx_tuna[6] = 0x00;
- if (state->dst_hw_cap & DST_TYPE_HAS_ANALOG)
- state->tx_tuna[7] = 0x00; /* Digital */
- } else
- return -EINVAL;
-
- return 0;
-}
-
-static int dst_set_bandwidth(struct dst_state *state, fe_bandwidth_t bandwidth)
-{
- state->bandwidth = bandwidth;
-
- if (state->dst_type != DST_TYPE_IS_TERR)
- return -EOPNOTSUPP;
-
- switch (bandwidth) {
- case BANDWIDTH_6_MHZ:
- if (state->dst_hw_cap & DST_TYPE_HAS_CA)
- state->tx_tuna[7] = 0x06;
- else {
- state->tx_tuna[6] = 0x06;
- state->tx_tuna[7] = 0x00;
- }
- break;
- case BANDWIDTH_7_MHZ:
- if (state->dst_hw_cap & DST_TYPE_HAS_CA)
- state->tx_tuna[7] = 0x07;
- else {
- state->tx_tuna[6] = 0x07;
- state->tx_tuna[7] = 0x00;
- }
- break;
- case BANDWIDTH_8_MHZ:
- if (state->dst_hw_cap & DST_TYPE_HAS_CA)
- state->tx_tuna[7] = 0x08;
- else {
- state->tx_tuna[6] = 0x08;
- state->tx_tuna[7] = 0x00;
- }
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int dst_set_inversion(struct dst_state *state, fe_spectral_inversion_t inversion)
-{
- state->inversion = inversion;
- switch (inversion) {
- case INVERSION_OFF: /* Inversion = Normal */
- state->tx_tuna[8] &= ~0x80;
- break;
- case INVERSION_ON:
- state->tx_tuna[8] |= 0x80;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int dst_set_fec(struct dst_state *state, fe_code_rate_t fec)
-{
- state->fec = fec;
- return 0;
-}
-
-static fe_code_rate_t dst_get_fec(struct dst_state *state)
-{
- return state->fec;
-}
-
-static int dst_set_symbolrate(struct dst_state *state, u32 srate)
-{
- u32 symcalc;
- u64 sval;
-
- state->symbol_rate = srate;
- if (state->dst_type == DST_TYPE_IS_TERR) {
- return -EOPNOTSUPP;
- }
- dprintk(verbose, DST_INFO, 1, "set symrate %u", srate);
- srate /= 1000;
- if (state->dst_type == DST_TYPE_IS_SAT) {
- if (state->type_flags & DST_TYPE_HAS_SYMDIV) {
- sval = srate;
- sval <<= 20;
- do_div(sval, 88000);
- symcalc = (u32) sval;
- dprintk(verbose, DST_INFO, 1, "set symcalc %u", symcalc);
- state->tx_tuna[5] = (u8) (symcalc >> 12);
- state->tx_tuna[6] = (u8) (symcalc >> 4);
- state->tx_tuna[7] = (u8) (symcalc << 4);
- } else {
- state->tx_tuna[5] = (u8) (srate >> 16) & 0x7f;
- state->tx_tuna[6] = (u8) (srate >> 8);
- state->tx_tuna[7] = (u8) srate;
- }
- state->tx_tuna[8] &= ~0x20;
- if (state->type_flags & DST_TYPE_HAS_OBS_REGS) {
- if (srate > 8000)
- state->tx_tuna[8] |= 0x20;
- }
- } else if (state->dst_type == DST_TYPE_IS_CABLE) {
- dprintk(verbose, DST_DEBUG, 1, "%s", state->fw_name);
- if (!strncmp(state->fw_name, "DCTNEW", 6)) {
- state->tx_tuna[5] = (u8) (srate >> 8);
- state->tx_tuna[6] = (u8) srate;
- state->tx_tuna[7] = 0x00;
- } else if (!strncmp(state->fw_name, "DCT-CI", 6)) {
- state->tx_tuna[5] = 0x00;
- state->tx_tuna[6] = (u8) (srate >> 8);
- state->tx_tuna[7] = (u8) srate;
- }
- }
- return 0;
-}
-
-static int dst_set_modulation(struct dst_state *state, fe_modulation_t modulation)
-{
- if (state->dst_type != DST_TYPE_IS_CABLE)
- return -EOPNOTSUPP;
-
- state->modulation = modulation;
- switch (modulation) {
- case QAM_16:
- state->tx_tuna[8] = 0x10;
- break;
- case QAM_32:
- state->tx_tuna[8] = 0x20;
- break;
- case QAM_64:
- state->tx_tuna[8] = 0x40;
- break;
- case QAM_128:
- state->tx_tuna[8] = 0x80;
- break;
- case QAM_256:
- if (!strncmp(state->fw_name, "DCTNEW", 6))
- state->tx_tuna[8] = 0xff;
- else if (!strncmp(state->fw_name, "DCT-CI", 6))
- state->tx_tuna[8] = 0x00;
- break;
- case QPSK:
- case QAM_AUTO:
- case VSB_8:
- case VSB_16:
- default:
- return -EINVAL;
-
- }
-
- return 0;
-}
-
-static fe_modulation_t dst_get_modulation(struct dst_state *state)
-{
- return state->modulation;
-}
-
-
-u8 dst_check_sum(u8 *buf, u32 len)
-{
- u32 i;
- u8 val = 0;
- if (!len)
- return 0;
- for (i = 0; i < len; i++) {
- val += buf[i];
- }
- return ((~val) + 1);
-}
-EXPORT_SYMBOL(dst_check_sum);
-
-static void dst_type_flags_print(struct dst_state *state)
-{
- u32 type_flags = state->type_flags;
-
- dprintk(verbose, DST_ERROR, 0, "DST type flags :");
- if (type_flags & DST_TYPE_HAS_TS188)
- dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner", DST_TYPE_HAS_TS188);
- if (type_flags & DST_TYPE_HAS_NEWTUNE_2)
- dprintk(verbose, DST_ERROR, 0, " 0x%x newtuner 2", DST_TYPE_HAS_NEWTUNE_2);
- if (type_flags & DST_TYPE_HAS_TS204)
- dprintk(verbose, DST_ERROR, 0, " 0x%x ts204", DST_TYPE_HAS_TS204);
- if (type_flags & DST_TYPE_HAS_VLF)
- dprintk(verbose, DST_ERROR, 0, " 0x%x VLF", DST_TYPE_HAS_VLF);
- if (type_flags & DST_TYPE_HAS_SYMDIV)
- dprintk(verbose, DST_ERROR, 0, " 0x%x symdiv", DST_TYPE_HAS_SYMDIV);
- if (type_flags & DST_TYPE_HAS_FW_1)
- dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 1", DST_TYPE_HAS_FW_1);
- if (type_flags & DST_TYPE_HAS_FW_2)
- dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 2", DST_TYPE_HAS_FW_2);
- if (type_flags & DST_TYPE_HAS_FW_3)
- dprintk(verbose, DST_ERROR, 0, " 0x%x firmware version = 3", DST_TYPE_HAS_FW_3);
- dprintk(verbose, DST_ERROR, 0, "\n");
-}
-
-
-static int dst_type_print(struct dst_state *state, u8 type)
-{
- char *otype;
- switch (type) {
- case DST_TYPE_IS_SAT:
- otype = "satellite";
- break;
-
- case DST_TYPE_IS_TERR:
- otype = "terrestrial";
- break;
-
- case DST_TYPE_IS_CABLE:
- otype = "cable";
- break;
-
- case DST_TYPE_IS_ATSC:
- otype = "atsc";
- break;
-
- default:
- dprintk(verbose, DST_INFO, 1, "invalid dst type %d", type);
- return -EINVAL;
- }
- dprintk(verbose, DST_INFO, 1, "DST type: %s", otype);
-
- return 0;
-}
-
-struct tuner_types tuner_list[] = {
- {
- .tuner_type = TUNER_TYPE_L64724,
- .tuner_name = "L 64724",
- .board_name = "UNKNOWN",
- .fw_name = "UNKNOWN"
- },
-
- {
- .tuner_type = TUNER_TYPE_STV0299,
- .tuner_name = "STV 0299",
- .board_name = "VP1020",
- .fw_name = "DST-MOT"
- },
-
- {
- .tuner_type = TUNER_TYPE_STV0299,
- .tuner_name = "STV 0299",
- .board_name = "VP1020",
- .fw_name = "DST-03T"
- },
-
- {
- .tuner_type = TUNER_TYPE_MB86A15,
- .tuner_name = "MB 86A15",
- .board_name = "VP1022",
- .fw_name = "DST-03T"
- },
-
- {
- .tuner_type = TUNER_TYPE_MB86A15,
- .tuner_name = "MB 86A15",
- .board_name = "VP1025",
- .fw_name = "DST-03T"
- },
-
- {
- .tuner_type = TUNER_TYPE_STV0299,
- .tuner_name = "STV 0299",
- .board_name = "VP1030",
- .fw_name = "DST-CI"
- },
-
- {
- .tuner_type = TUNER_TYPE_STV0299,
- .tuner_name = "STV 0299",
- .board_name = "VP1030",
- .fw_name = "DSTMCI"
- },
-
- {
- .tuner_type = TUNER_TYPE_UNKNOWN,
- .tuner_name = "UNKNOWN",
- .board_name = "VP2021",
- .fw_name = "DCTNEW"
- },
-
- {
- .tuner_type = TUNER_TYPE_UNKNOWN,
- .tuner_name = "UNKNOWN",
- .board_name = "VP2030",
- .fw_name = "DCT-CI"
- },
-
- {
- .tuner_type = TUNER_TYPE_UNKNOWN,
- .tuner_name = "UNKNOWN",
- .board_name = "VP2031",
- .fw_name = "DCT-CI"
- },
-
- {
- .tuner_type = TUNER_TYPE_UNKNOWN,
- .tuner_name = "UNKNOWN",
- .board_name = "VP2040",
- .fw_name = "DCT-CI"
- },
-
- {
- .tuner_type = TUNER_TYPE_UNKNOWN,
- .tuner_name = "UNKNOWN",
- .board_name = "VP3020",
- .fw_name = "DTTFTA"
- },
-
- {
- .tuner_type = TUNER_TYPE_UNKNOWN,
- .tuner_name = "UNKNOWN",
- .board_name = "VP3021",
- .fw_name = "DTTFTA"
- },
-
- {
- .tuner_type = TUNER_TYPE_TDA10046,
- .tuner_name = "TDA10046",
- .board_name = "VP3040",
- .fw_name = "DTT-CI"
- },
-
- {
- .tuner_type = TUNER_TYPE_UNKNOWN,
- .tuner_name = "UNKNOWN",
- .board_name = "VP3051",
- .fw_name = "DTTNXT"
- },
-
- {
- .tuner_type = TUNER_TYPE_NXT200x,
- .tuner_name = "NXT200x",
- .board_name = "VP3220",
- .fw_name = "ATSCDI"
- },
-
- {
- .tuner_type = TUNER_TYPE_NXT200x,
- .tuner_name = "NXT200x",
- .board_name = "VP3250",
- .fw_name = "ATSCAD"
- },
-};
-
-/*
- Known cards list
- Satellite
- -------------------
- 200103A
- VP-1020 DST-MOT LG(old), TS=188
-
- VP-1020 DST-03T LG(new), TS=204
- VP-1022 DST-03T LG(new), TS=204
- VP-1025 DST-03T LG(new), TS=204
-
- VP-1030 DSTMCI, LG(new), TS=188
- VP-1032 DSTMCI, LG(new), TS=188
-
- Cable
- -------------------
- VP-2030 DCT-CI, Samsung, TS=204
- VP-2021 DCT-CI, Unknown, TS=204
- VP-2031 DCT-CI, Philips, TS=188
- VP-2040 DCT-CI, Philips, TS=188, with CA daughter board
- VP-2040 DCT-CI, Philips, TS=204, without CA daughter board
-
- Terrestrial
- -------------------
- VP-3050 DTTNXT TS=188
- VP-3040 DTT-CI, Philips, TS=188
- VP-3040 DTT-CI, Philips, TS=204
-
- ATSC
- -------------------
- VP-3220 ATSCDI, TS=188
- VP-3250 ATSCAD, TS=188
-
-*/
-
-static struct dst_types dst_tlist[] = {
- {
- .device_id = "200103A",
- .offset = 0,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1 | DST_TYPE_HAS_OBS_REGS,
- .dst_feature = 0,
- .tuner_type = 0
- }, /* obsolete */
-
- {
- .device_id = "DST-020",
- .offset = 0,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1,
- .dst_feature = 0,
- .tuner_type = 0
- }, /* obsolete */
-
- {
- .device_id = "DST-030",
- .offset = 0,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_1,
- .dst_feature = 0,
- .tuner_type = 0
- }, /* obsolete */
-
- {
- .device_id = "DST-03T",
- .offset = 0,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_2,
- .dst_feature = DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4 | DST_TYPE_HAS_DISEQC5
- | DST_TYPE_HAS_MAC | DST_TYPE_HAS_MOTO,
- .tuner_type = TUNER_TYPE_MULTI
- },
-
- {
- .device_id = "DST-MOT",
- .offset = 0,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_SYMDIV | DST_TYPE_HAS_FW_1,
- .dst_feature = 0,
- .tuner_type = 0
- }, /* obsolete */
-
- {
- .device_id = "DST-CI",
- .offset = 1,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_TS204 | DST_TYPE_HAS_FW_1,
- .dst_feature = DST_TYPE_HAS_CA,
- .tuner_type = 0
- }, /* An OEM board */
-
- {
- .device_id = "DSTMCI",
- .offset = 1,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD | DST_TYPE_HAS_INC_COUNT | DST_TYPE_HAS_VLF,
- .dst_feature = DST_TYPE_HAS_CA | DST_TYPE_HAS_DISEQC3 | DST_TYPE_HAS_DISEQC4
- | DST_TYPE_HAS_MOTO | DST_TYPE_HAS_MAC,
- .tuner_type = TUNER_TYPE_MULTI
- },
-
- {
- .device_id = "DSTFCI",
- .offset = 1,
- .dst_type = DST_TYPE_IS_SAT,
- .type_flags = DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_1,
- .dst_feature = 0,
- .tuner_type = 0
- }, /* unknown to vendor */
-
- {
- .device_id = "DCT-CI",
- .offset = 1,
- .dst_type = DST_TYPE_IS_CABLE,
- .type_flags = DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_FW_1 | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_VLF,
- .dst_feature = DST_TYPE_HAS_CA,
- .tuner_type = 0
- },
-
- {
- .device_id = "DCTNEW",
- .offset = 1,
- .dst_type = DST_TYPE_IS_CABLE,
- .type_flags = DST_TYPE_HAS_TS188 | DST_TYPE_HAS_FW_3 | DST_TYPE_HAS_FW_BUILD | DST_TYPE_HAS_MULTI_FE,
- .dst_feature = 0,
- .tuner_type = 0
- },
-
- {
- .device_id = "DTT-CI",
- .offset = 1,
- .dst_type = DST_TYPE_IS_TERR,
- .type_flags = DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_VLF,
- .dst_feature = DST_TYPE_HAS_CA,
- .tuner_type = 0
- },
-
- {
- .device_id = "DTTDIG",
- .offset = 1,
- .dst_type = DST_TYPE_IS_TERR,
- .type_flags = DST_TYPE_HAS_FW_2,
- .dst_feature = 0,
- .tuner_type = 0
- },
-
- {
- .device_id = "DTTNXT",
- .offset = 1,
- .dst_type = DST_TYPE_IS_TERR,
- .type_flags = DST_TYPE_HAS_FW_2,
- .dst_feature = DST_TYPE_HAS_ANALOG,
- .tuner_type = 0
- },
-
- {
- .device_id = "ATSCDI",
- .offset = 1,
- .dst_type = DST_TYPE_IS_ATSC,
- .type_flags = DST_TYPE_HAS_FW_2,
- .dst_feature = 0,
- .tuner_type = 0
- },
-
- {
- .device_id = "ATSCAD",
- .offset = 1,
- .dst_type = DST_TYPE_IS_ATSC,
- .type_flags = DST_TYPE_HAS_MULTI_FE | DST_TYPE_HAS_FW_2 | DST_TYPE_HAS_FW_BUILD,
- .dst_feature = DST_TYPE_HAS_MAC | DST_TYPE_HAS_ANALOG,
- .tuner_type = 0
- },
-
- { }
-
-};
-
-static int dst_get_mac(struct dst_state *state)
-{
- u8 get_mac[] = { 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- get_mac[7] = dst_check_sum(get_mac, 7);
- if (dst_command(state, get_mac, 8) < 0) {
- dprintk(verbose, DST_INFO, 1, "Unsupported Command");
- return -1;
- }
- memset(&state->mac_address, '\0', 8);
- memcpy(&state->mac_address, &state->rxbuffer, 6);
- dprintk(verbose, DST_ERROR, 1, "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]",
- state->mac_address[0], state->mac_address[1], state->mac_address[2],
- state->mac_address[4], state->mac_address[5], state->mac_address[6]);
-
- return 0;
-}
-
-static int dst_fw_ver(struct dst_state *state)
-{
- u8 get_ver[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- get_ver[7] = dst_check_sum(get_ver, 7);
- if (dst_command(state, get_ver, 8) < 0) {
- dprintk(verbose, DST_INFO, 1, "Unsupported Command");
- return -1;
- }
- memset(&state->fw_version, '\0', 8);
- memcpy(&state->fw_version, &state->rxbuffer, 8);
- dprintk(verbose, DST_ERROR, 1, "Firmware Ver = %x.%x Build = %02x, on %x:%x, %x-%x-20%02x",
- state->fw_version[0] >> 4, state->fw_version[0] & 0x0f,
- state->fw_version[1],
- state->fw_version[5], state->fw_version[6],
- state->fw_version[4], state->fw_version[3], state->fw_version[2]);
-
- return 0;
-}
-
-static int dst_card_type(struct dst_state *state)
-{
- int j;
- struct tuner_types *p_tuner_list = NULL;
-
- u8 get_type[] = { 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- get_type[7] = dst_check_sum(get_type, 7);
- if (dst_command(state, get_type, 8) < 0) {
- dprintk(verbose, DST_INFO, 1, "Unsupported Command");
- return -1;
- }
- memset(&state->card_info, '\0', 8);
- memcpy(&state->card_info, &state->rxbuffer, 7);
- dprintk(verbose, DST_ERROR, 1, "Device Model=[%s]", &state->card_info[0]);
-
- for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) {
- if (!strcmp(&state->card_info[0], p_tuner_list->board_name)) {
- state->tuner_type = p_tuner_list->tuner_type;
- dprintk(verbose, DST_ERROR, 1, "DST has [%s] tuner, tuner type=[%d]",
- p_tuner_list->tuner_name, p_tuner_list->tuner_type);
- }
- }
-
- return 0;
-}
-
-static int dst_get_vendor(struct dst_state *state)
-{
- u8 get_vendor[] = { 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- get_vendor[7] = dst_check_sum(get_vendor, 7);
- if (dst_command(state, get_vendor, 8) < 0) {
- dprintk(verbose, DST_INFO, 1, "Unsupported Command");
- return -1;
- }
- memset(&state->vendor, '\0', 8);
- memcpy(&state->vendor, &state->rxbuffer, 7);
- dprintk(verbose, DST_ERROR, 1, "Vendor=[%s]", &state->vendor[0]);
-
- return 0;
-}
-
-static void debug_dst_buffer(struct dst_state *state)
-{
- int i;
-
- if (verbose > 2) {
- printk("%s: [", __func__);
- for (i = 0; i < 8; i++)
- printk(" %02x", state->rxbuffer[i]);
- printk("]\n");
- }
-}
-
-static int dst_check_stv0299(struct dst_state *state)
-{
- u8 check_stv0299[] = { 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
- check_stv0299[7] = dst_check_sum(check_stv0299, 7);
- if (dst_command(state, check_stv0299, 8) < 0) {
- dprintk(verbose, DST_ERROR, 1, "Cmd=[0x04] failed");
- return -1;
- }
- debug_dst_buffer(state);
-
- if (memcmp(&check_stv0299, &state->rxbuffer, 8)) {
- dprintk(verbose, DST_ERROR, 1, "Found a STV0299 NIM");
- state->tuner_type = TUNER_TYPE_STV0299;
- return 0;
- }
-
- return -1;
-}
-
-static int dst_check_mb86a15(struct dst_state *state)
-{
- u8 check_mb86a15[] = { 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
- check_mb86a15[7] = dst_check_sum(check_mb86a15, 7);
- if (dst_command(state, check_mb86a15, 8) < 0) {
- dprintk(verbose, DST_ERROR, 1, "Cmd=[0x10], failed");
- return -1;
- }
- debug_dst_buffer(state);
-
- if (memcmp(&check_mb86a15, &state->rxbuffer, 8) < 0) {
- dprintk(verbose, DST_ERROR, 1, "Found a MB86A15 NIM");
- state->tuner_type = TUNER_TYPE_MB86A15;
- return 0;
- }
-
- return -1;
-}
-
-static int dst_get_tuner_info(struct dst_state *state)
-{
- u8 get_tuner_1[] = { 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- u8 get_tuner_2[] = { 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
- get_tuner_1[7] = dst_check_sum(get_tuner_1, 7);
- get_tuner_2[7] = dst_check_sum(get_tuner_2, 7);
- dprintk(verbose, DST_ERROR, 1, "DST TYpe = MULTI FE");
- if (state->type_flags & DST_TYPE_HAS_MULTI_FE) {
- if (dst_command(state, get_tuner_1, 8) < 0) {
- dprintk(verbose, DST_INFO, 1, "Cmd=[0x13], Unsupported");
- goto force;
- }
- } else {
- if (dst_command(state, get_tuner_2, 8) < 0) {
- dprintk(verbose, DST_INFO, 1, "Cmd=[0xb], Unsupported");
- goto force;
- }
- }
- memset(&state->board_info, '\0', 8);
- memcpy(&state->board_info, &state->rxbuffer, 8);
- if (state->type_flags & DST_TYPE_HAS_MULTI_FE) {
- dprintk(verbose, DST_ERROR, 1, "DST type has TS=188");
- }
- if (state->board_info[0] == 0xbc) {
- if (state->type_flags != DST_TYPE_IS_ATSC)
- state->type_flags |= DST_TYPE_HAS_TS188;
- else
- state->type_flags |= DST_TYPE_HAS_NEWTUNE_2;
-
- if (state->board_info[1] == 0x01) {
- state->dst_hw_cap |= DST_TYPE_HAS_DBOARD;
- dprintk(verbose, DST_ERROR, 1, "DST has Daughterboard");
- }
- }
-
- return 0;
-force:
- if (!strncmp(state->fw_name, "DCT-CI", 6)) {
- state->type_flags |= DST_TYPE_HAS_TS204;
- dprintk(verbose, DST_ERROR, 1, "Forcing [%s] to TS188", state->fw_name);
- }
-
- return -1;
-}
-
-static int dst_get_device_id(struct dst_state *state)
-{
- u8 reply;
-
- int i, j;
- struct dst_types *p_dst_type = NULL;
- struct tuner_types *p_tuner_list = NULL;
-
- u8 use_dst_type = 0;
- u32 use_type_flags = 0;
-
- static u8 device_type[8] = {0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};
-
- state->tuner_type = 0;
- device_type[7] = dst_check_sum(device_type, 7);
-
- if (write_dst(state, device_type, FIXED_COMM))
- return -1; /* Write failed */
- if ((dst_pio_disable(state)) < 0)
- return -1;
- if (read_dst(state, &reply, GET_ACK))
- return -1; /* Read failure */
- if (reply != ACK) {
- dprintk(verbose, DST_INFO, 1, "Write not Acknowledged! [Reply=0x%02x]", reply);
- return -1; /* Unack'd write */
- }
- if (!dst_wait_dst_ready(state, DEVICE_INIT))
- return -1; /* DST not ready yet */
- if (read_dst(state, state->rxbuffer, FIXED_COMM))
- return -1;
-
- dst_pio_disable(state);
- if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
- dprintk(verbose, DST_INFO, 1, "Checksum failure!");
- return -1; /* Checksum failure */
- }
- state->rxbuffer[7] = '\0';
-
- for (i = 0, p_dst_type = dst_tlist; i < ARRAY_SIZE(dst_tlist); i++, p_dst_type++) {
- if (!strncmp (&state->rxbuffer[p_dst_type->offset], p_dst_type->device_id, strlen (p_dst_type->device_id))) {
- use_type_flags = p_dst_type->type_flags;
- use_dst_type = p_dst_type->dst_type;
-
- /* Card capabilities */
- state->dst_hw_cap = p_dst_type->dst_feature;
- dprintk(verbose, DST_ERROR, 1, "Recognise [%s]", p_dst_type->device_id);
- strncpy(&state->fw_name[0], p_dst_type->device_id, 6);
- /* Multiple tuners */
- if (p_dst_type->tuner_type & TUNER_TYPE_MULTI) {
- switch (use_dst_type) {
- case DST_TYPE_IS_SAT:
- /* STV0299 check */
- if (dst_check_stv0299(state) < 0) {
- dprintk(verbose, DST_ERROR, 1, "Unsupported");
- state->tuner_type = TUNER_TYPE_MB86A15;
- }
- break;
- default:
- break;
- }
- if (dst_check_mb86a15(state) < 0)
- dprintk(verbose, DST_ERROR, 1, "Unsupported");
- /* Single tuner */
- } else {
- state->tuner_type = p_dst_type->tuner_type;
- }
- for (j = 0, p_tuner_list = tuner_list; j < ARRAY_SIZE(tuner_list); j++, p_tuner_list++) {
- if (!(strncmp(p_dst_type->device_id, p_tuner_list->fw_name, 7)) &&
- p_tuner_list->tuner_type == state->tuner_type) {
- dprintk(verbose, DST_ERROR, 1, "[%s] has a [%s]",
- p_dst_type->device_id, p_tuner_list->tuner_name);
- }
- }
- break;
- }
- }
-
- if (i >= sizeof (dst_tlist) / sizeof (dst_tlist [0])) {
- dprintk(verbose, DST_ERROR, 1, "Unable to recognize %s or %s", &state->rxbuffer[0], &state->rxbuffer[1]);
- dprintk(verbose, DST_ERROR, 1, "please email linux-dvb@linuxtv.org with this type in");
- use_dst_type = DST_TYPE_IS_SAT;
- use_type_flags = DST_TYPE_HAS_SYMDIV;
- }
- dst_type_print(state, use_dst_type);
- state->type_flags = use_type_flags;
- state->dst_type = use_dst_type;
- dst_type_flags_print(state);
-
- return 0;
-}
-
-static int dst_probe(struct dst_state *state)
-{
- mutex_init(&state->dst_mutex);
- if (dst_addons & DST_TYPE_HAS_CA) {
- if ((rdc_8820_reset(state)) < 0) {
- dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
- return -1;
- }
- msleep(4000);
- } else {
- msleep(100);
- }
- if ((dst_comm_init(state)) < 0) {
- dprintk(verbose, DST_ERROR, 1, "DST Initialization Failed.");
- return -1;
- }
- msleep(100);
- if (dst_get_device_id(state) < 0) {
- dprintk(verbose, DST_ERROR, 1, "unknown device.");
- return -1;
- }
- if (dst_get_mac(state) < 0) {
- dprintk(verbose, DST_INFO, 1, "MAC: Unsupported command");
- }
- if ((state->type_flags & DST_TYPE_HAS_MULTI_FE) || (state->type_flags & DST_TYPE_HAS_FW_BUILD)) {
- if (dst_get_tuner_info(state) < 0)
- dprintk(verbose, DST_INFO, 1, "Tuner: Unsupported command");
- }
- if (state->type_flags & DST_TYPE_HAS_TS204) {
- dst_packsize(state, 204);
- }
- if (state->type_flags & DST_TYPE_HAS_FW_BUILD) {
- if (dst_fw_ver(state) < 0) {
- dprintk(verbose, DST_INFO, 1, "FW: Unsupported command");
- return 0;
- }
- if (dst_card_type(state) < 0) {
- dprintk(verbose, DST_INFO, 1, "Card: Unsupported command");
- return 0;
- }
- if (dst_get_vendor(state) < 0) {
- dprintk(verbose, DST_INFO, 1, "Vendor: Unsupported command");
- return 0;
- }
- }
-
- return 0;
-}
-
-int dst_command(struct dst_state *state, u8 *data, u8 len)
-{
- u8 reply;
-
- mutex_lock(&state->dst_mutex);
- if ((dst_comm_init(state)) < 0) {
- dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
- goto error;
- }
- if (write_dst(state, data, len)) {
- dprintk(verbose, DST_INFO, 1, "Trying to recover.. ");
- if ((dst_error_recovery(state)) < 0) {
- dprintk(verbose, DST_ERROR, 1, "Recovery Failed.");
- goto error;
- }
- goto error;
- }
- if ((dst_pio_disable(state)) < 0) {
- dprintk(verbose, DST_ERROR, 1, "PIO Disable Failed.");
- goto error;
- }
- if (state->type_flags & DST_TYPE_HAS_FW_1)
- udelay(3000);
- if (read_dst(state, &reply, GET_ACK)) {
- dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
- if ((dst_error_recovery(state)) < 0) {
- dprintk(verbose, DST_INFO, 1, "Recovery Failed.");
- goto error;
- }
- goto error;
- }
- if (reply != ACK) {
- dprintk(verbose, DST_INFO, 1, "write not acknowledged 0x%02x ", reply);
- goto error;
- }
- if (len >= 2 && data[0] == 0 && (data[1] == 1 || data[1] == 3))
- goto error;
- if (state->type_flags & DST_TYPE_HAS_FW_1)
- udelay(3000);
- else
- udelay(2000);
- if (!dst_wait_dst_ready(state, NO_DELAY))
- goto error;
- if (read_dst(state, state->rxbuffer, FIXED_COMM)) {
- dprintk(verbose, DST_DEBUG, 1, "Trying to recover.. ");
- if ((dst_error_recovery(state)) < 0) {
- dprintk(verbose, DST_INFO, 1, "Recovery failed.");
- goto error;
- }
- goto error;
- }
- if (state->rxbuffer[7] != dst_check_sum(state->rxbuffer, 7)) {
- dprintk(verbose, DST_INFO, 1, "checksum failure");
- goto error;
- }
- mutex_unlock(&state->dst_mutex);
- return 0;
-
-error:
- mutex_unlock(&state->dst_mutex);
- return -EIO;
-
-}
-EXPORT_SYMBOL(dst_command);
-
-static int dst_get_signal(struct dst_state *state)
-{
- int retval;
- u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb };
- //dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__);
- if ((state->diseq_flags & ATTEMPT_TUNE) == 0) {
- state->decode_lock = state->decode_strength = state->decode_snr = 0;
- return 0;
- }
- if (0 == (state->diseq_flags & HAS_LOCK)) {
- state->decode_lock = state->decode_strength = state->decode_snr = 0;
- return 0;
- }
- if (time_after_eq(jiffies, state->cur_jiff + (HZ / 5))) {
- retval = dst_command(state, get_signal, 8);
- if (retval < 0)
- return retval;
- if (state->dst_type == DST_TYPE_IS_SAT) {
- state->decode_lock = ((state->rxbuffer[6] & 0x10) == 0) ? 1 : 0;
- state->decode_strength = state->rxbuffer[5] << 8;
- state->decode_snr = state->rxbuffer[2] << 8 | state->rxbuffer[3];
- } else if ((state->dst_type == DST_TYPE_IS_TERR) || (state->dst_type == DST_TYPE_IS_CABLE)) {
- state->decode_lock = (state->rxbuffer[1]) ? 1 : 0;
- state->decode_strength = state->rxbuffer[4] << 8;
- state->decode_snr = state->rxbuffer[3] << 8;
- } else if (state->dst_type == DST_TYPE_IS_ATSC) {
- state->decode_lock = (state->rxbuffer[6] == 0x00) ? 1 : 0;
- state->decode_strength = state->rxbuffer[4] << 8;
- state->decode_snr = state->rxbuffer[2] << 8 | state->rxbuffer[3];
- }
- state->cur_jiff = jiffies;
- }
- return 0;
-}
-
-static int dst_tone_power_cmd(struct dst_state *state)
-{
- u8 paket[8] = { 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00 };
-
- if (state->dst_type != DST_TYPE_IS_SAT)
- return -EOPNOTSUPP;
- paket[4] = state->tx_tuna[4];
- paket[2] = state->tx_tuna[2];
- paket[3] = state->tx_tuna[3];
- paket[7] = dst_check_sum (paket, 7);
- return dst_command(state, paket, 8);
-}
-
-static int dst_get_tuna(struct dst_state *state)
-{
- int retval;
-
- if ((state->diseq_flags & ATTEMPT_TUNE) == 0)
- return 0;
- state->diseq_flags &= ~(HAS_LOCK);
- if (!dst_wait_dst_ready(state, NO_DELAY))
- return -EIO;
- if ((state->type_flags & DST_TYPE_HAS_VLF) &&
- !(state->dst_type == DST_TYPE_IS_ATSC))
-
- retval = read_dst(state, state->rx_tuna, 10);
- else
- retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
- if (retval < 0) {
- dprintk(verbose, DST_DEBUG, 1, "read not successful");
- return retval;
- }
- if ((state->type_flags & DST_TYPE_HAS_VLF) &&
- !(state->dst_type == DST_TYPE_IS_CABLE) &&
- !(state->dst_type == DST_TYPE_IS_ATSC)) {
-
- if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
- dprintk(verbose, DST_INFO, 1, "checksum failure ? ");
- return -EIO;
- }
- } else {
- if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) {
- dprintk(verbose, DST_INFO, 1, "checksum failure? ");
- return -EIO;
- }
- }
- if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0)
- return 0;
- if (state->dst_type == DST_TYPE_IS_SAT) {
- state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3];
- } else {
- state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 16) + (state->rx_tuna[3] << 8) + state->rx_tuna[4];
- }
- state->decode_freq = state->decode_freq * 1000;
- state->decode_lock = 1;
- state->diseq_flags |= HAS_LOCK;
-
- return 1;
-}
-
-static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage);
-
-static int dst_write_tuna(struct dvb_frontend *fe)
-{
- struct dst_state *state = fe->demodulator_priv;
- int retval;
- u8 reply;
-
- dprintk(verbose, DST_INFO, 1, "type_flags 0x%x ", state->type_flags);
- state->decode_freq = 0;
- state->decode_lock = state->decode_strength = state->decode_snr = 0;
- if (state->dst_type == DST_TYPE_IS_SAT) {
- if (!(state->diseq_flags & HAS_POWER))
- dst_set_voltage(fe, SEC_VOLTAGE_13);
- }
- state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
- mutex_lock(&state->dst_mutex);
- if ((dst_comm_init(state)) < 0) {
- dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
- goto error;
- }
-// if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
- if ((state->type_flags & DST_TYPE_HAS_VLF) &&
- (!(state->dst_type == DST_TYPE_IS_ATSC))) {
-
- state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
- retval = write_dst(state, &state->tx_tuna[0], 10);
- } else {
- state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[2], 7);
- retval = write_dst(state, &state->tx_tuna[2], FIXED_COMM);
- }
- if (retval < 0) {
- dst_pio_disable(state);
- dprintk(verbose, DST_DEBUG, 1, "write not successful");
- goto werr;
- }
- if ((dst_pio_disable(state)) < 0) {
- dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !");
- goto error;
- }
- if ((read_dst(state, &reply, GET_ACK) < 0)) {
- dprintk(verbose, DST_DEBUG, 1, "read verify not successful.");
- goto error;
- }
- if (reply != ACK) {
- dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply);
- goto error;
- }
- state->diseq_flags |= ATTEMPT_TUNE;
- retval = dst_get_tuna(state);
-werr:
- mutex_unlock(&state->dst_mutex);
- return retval;
-
-error:
- mutex_unlock(&state->dst_mutex);
- return -EIO;
-}
-
-/*
- * line22k0 0x00, 0x09, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00
- * line22k1 0x00, 0x09, 0x01, 0xff, 0x01, 0x00, 0x00, 0x00
- * line22k2 0x00, 0x09, 0x02, 0xff, 0x01, 0x00, 0x00, 0x00
- * tone 0x00, 0x09, 0xff, 0x00, 0x01, 0x00, 0x00, 0x00
- * data 0x00, 0x09, 0xff, 0x01, 0x01, 0x00, 0x00, 0x00
- * power_off 0x00, 0x09, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00
- * power_on 0x00, 0x09, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00
- * Diseqc 1 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec
- * Diseqc 2 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf4, 0xe8
- * Diseqc 3 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf8, 0xe4
- * Diseqc 4 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xfc, 0xe0
- */
-
-static int dst_set_diseqc(struct dvb_frontend *fe, struct dvb_diseqc_master_cmd *cmd)
-{
- struct dst_state *state = fe->demodulator_priv;
- u8 paket[8] = { 0x00, 0x08, 0x04, 0xe0, 0x10, 0x38, 0xf0, 0xec };
-
- if (state->dst_type != DST_TYPE_IS_SAT)
- return -EOPNOTSUPP;
- if (cmd->msg_len > 0 && cmd->msg_len < 5)
- memcpy(&paket[3], cmd->msg, cmd->msg_len);
- else if (cmd->msg_len == 5 && state->dst_hw_cap & DST_TYPE_HAS_DISEQC5)
- memcpy(&paket[2], cmd->msg, cmd->msg_len);
- else
- return -EINVAL;
- paket[7] = dst_check_sum(&paket[0], 7);
- return dst_command(state, paket, 8);
-}
-
-static int dst_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
-{
- int need_cmd, retval = 0;
- struct dst_state *state = fe->demodulator_priv;
-
- state->voltage = voltage;
- if (state->dst_type != DST_TYPE_IS_SAT)
- return -EOPNOTSUPP;
-
- need_cmd = 0;
-
- switch (voltage) {
- case SEC_VOLTAGE_13:
- case SEC_VOLTAGE_18:
- if ((state->diseq_flags & HAS_POWER) == 0)
- need_cmd = 1;
- state->diseq_flags |= HAS_POWER;
- state->tx_tuna[4] = 0x01;
- break;
- case SEC_VOLTAGE_OFF:
- need_cmd = 1;
- state->diseq_flags &= ~(HAS_POWER | HAS_LOCK | ATTEMPT_TUNE);
- state->tx_tuna[4] = 0x00;
- break;
- default:
- return -EINVAL;
- }
-
- if (need_cmd)
- retval = dst_tone_power_cmd(state);
-
- return retval;
-}
-
-static int dst_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- state->tone = tone;
- if (state->dst_type != DST_TYPE_IS_SAT)
- return -EOPNOTSUPP;
-
- switch (tone) {
- case SEC_TONE_OFF:
- if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
- state->tx_tuna[2] = 0x00;
- else
- state->tx_tuna[2] = 0xff;
- break;
-
- case SEC_TONE_ON:
- state->tx_tuna[2] = 0x02;
- break;
- default:
- return -EINVAL;
- }
- return dst_tone_power_cmd(state);
-}
-
-static int dst_send_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t minicmd)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- if (state->dst_type != DST_TYPE_IS_SAT)
- return -EOPNOTSUPP;
- state->minicmd = minicmd;
- switch (minicmd) {
- case SEC_MINI_A:
- state->tx_tuna[3] = 0x02;
- break;
- case SEC_MINI_B:
- state->tx_tuna[3] = 0xff;
- break;
- }
- return dst_tone_power_cmd(state);
-}
-
-
-static int dst_init(struct dvb_frontend *fe)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- static u8 sat_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x00, 0x73, 0x21, 0x00, 0x00 };
- static u8 sat_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x55, 0xbd, 0x50, 0x00, 0x00 };
- static u8 ter_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
- static u8 ter_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
- static u8 cab_tuna_188[] = { 0x09, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
- static u8 cab_tuna_204[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
- static u8 atsc_tuner[] = { 0x00, 0x00, 0x03, 0xb6, 0x01, 0x07, 0x00, 0x00, 0x00, 0x00 };
-
- state->inversion = INVERSION_OFF;
- state->voltage = SEC_VOLTAGE_13;
- state->tone = SEC_TONE_OFF;
- state->diseq_flags = 0;
- state->k22 = 0x02;
- state->bandwidth = BANDWIDTH_7_MHZ;
- state->cur_jiff = jiffies;
- if (state->dst_type == DST_TYPE_IS_SAT)
- memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? sat_tuna_188 : sat_tuna_204), sizeof (sat_tuna_204));
- else if (state->dst_type == DST_TYPE_IS_TERR)
- memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? ter_tuna_188 : ter_tuna_204), sizeof (ter_tuna_204));
- else if (state->dst_type == DST_TYPE_IS_CABLE)
- memcpy(state->tx_tuna, ((state->type_flags & DST_TYPE_HAS_VLF) ? cab_tuna_188 : cab_tuna_204), sizeof (cab_tuna_204));
- else if (state->dst_type == DST_TYPE_IS_ATSC)
- memcpy(state->tx_tuna, atsc_tuner, sizeof (atsc_tuner));
-
- return 0;
-}
-
-static int dst_read_status(struct dvb_frontend *fe, fe_status_t *status)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- *status = 0;
- if (state->diseq_flags & HAS_LOCK) {
-// dst_get_signal(state); // don't require(?) to ask MCU
- if (state->decode_lock)
- *status |= FE_HAS_LOCK | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_SYNC | FE_HAS_VITERBI;
- }
-
- return 0;
-}
-
-static int dst_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- int retval = dst_get_signal(state);
- *strength = state->decode_strength;
-
- return retval;
-}
-
-static int dst_read_snr(struct dvb_frontend *fe, u16 *snr)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- int retval = dst_get_signal(state);
- *snr = state->decode_snr;
-
- return retval;
-}
-
-static int dst_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
-{
- int retval = -EINVAL;
- struct dst_state *state = fe->demodulator_priv;
-
- if (p != NULL) {
- retval = dst_set_freq(state, p->frequency);
- if(retval != 0)
- return retval;
- dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
-
- if (state->dst_type == DST_TYPE_IS_SAT) {
- if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
- dst_set_inversion(state, p->inversion);
- dst_set_fec(state, p->u.qpsk.fec_inner);
- dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
- dst_set_polarization(state);
- dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate);
-
- } else if (state->dst_type == DST_TYPE_IS_TERR)
- dst_set_bandwidth(state, p->u.ofdm.bandwidth);
- else if (state->dst_type == DST_TYPE_IS_CABLE) {
- dst_set_fec(state, p->u.qam.fec_inner);
- dst_set_symbolrate(state, p->u.qam.symbol_rate);
- dst_set_modulation(state, p->u.qam.modulation);
- }
- retval = dst_write_tuna(fe);
- }
-
- return retval;
-}
-
-static int dst_tune_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* p,
- unsigned int mode_flags,
- int *delay,
- fe_status_t *status)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- if (p != NULL) {
- dst_set_freq(state, p->frequency);
- dprintk(verbose, DST_DEBUG, 1, "Set Frequency=[%d]", p->frequency);
-
- if (state->dst_type == DST_TYPE_IS_SAT) {
- if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
- dst_set_inversion(state, p->inversion);
- dst_set_fec(state, p->u.qpsk.fec_inner);
- dst_set_symbolrate(state, p->u.qpsk.symbol_rate);
- dst_set_polarization(state);
- dprintk(verbose, DST_DEBUG, 1, "Set Symbolrate=[%d]", p->u.qpsk.symbol_rate);
-
- } else if (state->dst_type == DST_TYPE_IS_TERR)
- dst_set_bandwidth(state, p->u.ofdm.bandwidth);
- else if (state->dst_type == DST_TYPE_IS_CABLE) {
- dst_set_fec(state, p->u.qam.fec_inner);
- dst_set_symbolrate(state, p->u.qam.symbol_rate);
- dst_set_modulation(state, p->u.qam.modulation);
- }
- dst_write_tuna(fe);
- }
-
- if (!(mode_flags & FE_TUNE_MODE_ONESHOT))
- dst_read_status(fe, status);
-
- *delay = HZ/10;
- return 0;
-}
-
-static int dst_get_tuning_algo(struct dvb_frontend *fe)
-{
- return dst_algo;
-}
-
-static int dst_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
-{
- struct dst_state *state = fe->demodulator_priv;
-
- p->frequency = state->decode_freq;
- if (state->dst_type == DST_TYPE_IS_SAT) {
- if (state->type_flags & DST_TYPE_HAS_OBS_REGS)
- p->inversion = state->inversion;
- p->u.qpsk.symbol_rate = state->symbol_rate;
- p->u.qpsk.fec_inner = dst_get_fec(state);
- } else if (state->dst_type == DST_TYPE_IS_TERR) {
- p->u.ofdm.bandwidth = state->bandwidth;
- } else if (state->dst_type == DST_TYPE_IS_CABLE) {
- p->u.qam.symbol_rate = state->symbol_rate;
- p->u.qam.fec_inner = dst_get_fec(state);
- p->u.qam.modulation = dst_get_modulation(state);
- }
-
- return 0;
-}
-
-static void dst_release(struct dvb_frontend *fe)
-{
- struct dst_state *state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops dst_dvbt_ops;
-static struct dvb_frontend_ops dst_dvbs_ops;
-static struct dvb_frontend_ops dst_dvbc_ops;
-static struct dvb_frontend_ops dst_atsc_ops;
-
-struct dst_state *dst_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter)
-{
- /* check if the ASIC is there */
- if (dst_probe(state) < 0) {
- kfree(state);
- return NULL;
- }
- /* determine settings based on type */
- /* create dvb_frontend */
- switch (state->dst_type) {
- case DST_TYPE_IS_TERR:
- memcpy(&state->frontend.ops, &dst_dvbt_ops, sizeof(struct dvb_frontend_ops));
- break;
- case DST_TYPE_IS_CABLE:
- memcpy(&state->frontend.ops, &dst_dvbc_ops, sizeof(struct dvb_frontend_ops));
- break;
- case DST_TYPE_IS_SAT:
- memcpy(&state->frontend.ops, &dst_dvbs_ops, sizeof(struct dvb_frontend_ops));
- break;
- case DST_TYPE_IS_ATSC:
- memcpy(&state->frontend.ops, &dst_atsc_ops, sizeof(struct dvb_frontend_ops));
- break;
- default:
- dprintk(verbose, DST_ERROR, 1, "unknown DST type. please report to the LinuxTV.org DVB mailinglist.");
- kfree(state);
- return NULL;
- }
- state->frontend.demodulator_priv = state;
-
- return state; /* Manu (DST is a card not a frontend) */
-}
-
-EXPORT_SYMBOL(dst_attach);
-
-static struct dvb_frontend_ops dst_dvbt_ops = {
-
- .info = {
- .name = "DST DVB-T",
- .type = FE_OFDM,
- .frequency_min = 137000000,
- .frequency_max = 858000000,
- .frequency_stepsize = 166667,
- .caps = FE_CAN_FEC_AUTO | FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
- },
-
- .release = dst_release,
- .init = dst_init,
- .tune = dst_tune_frontend,
- .set_frontend = dst_set_frontend,
- .get_frontend = dst_get_frontend,
- .get_frontend_algo = dst_get_tuning_algo,
- .read_status = dst_read_status,
- .read_signal_strength = dst_read_signal_strength,
- .read_snr = dst_read_snr,
-};
-
-static struct dvb_frontend_ops dst_dvbs_ops = {
-
- .info = {
- .name = "DST DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 1000, /* kHz for QPSK frontends */
- .frequency_tolerance = 29500,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- /* . symbol_rate_tolerance = ???,*/
- .caps = FE_CAN_FEC_AUTO | FE_CAN_QPSK
- },
-
- .release = dst_release,
- .init = dst_init,
- .tune = dst_tune_frontend,
- .set_frontend = dst_set_frontend,
- .get_frontend = dst_get_frontend,
- .get_frontend_algo = dst_get_tuning_algo,
- .read_status = dst_read_status,
- .read_signal_strength = dst_read_signal_strength,
- .read_snr = dst_read_snr,
- .diseqc_send_burst = dst_send_burst,
- .diseqc_send_master_cmd = dst_set_diseqc,
- .set_voltage = dst_set_voltage,
- .set_tone = dst_set_tone,
-};
-
-static struct dvb_frontend_ops dst_dvbc_ops = {
-
- .info = {
- .name = "DST DVB-C",
- .type = FE_QAM,
- .frequency_stepsize = 62500,
- .frequency_min = 51000000,
- .frequency_max = 858000000,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- /* . symbol_rate_tolerance = ???,*/
- .caps = FE_CAN_FEC_AUTO | FE_CAN_QAM_AUTO
- },
-
- .release = dst_release,
- .init = dst_init,
- .tune = dst_tune_frontend,
- .set_frontend = dst_set_frontend,
- .get_frontend = dst_get_frontend,
- .get_frontend_algo = dst_get_tuning_algo,
- .read_status = dst_read_status,
- .read_signal_strength = dst_read_signal_strength,
- .read_snr = dst_read_snr,
-};
-
-static struct dvb_frontend_ops dst_atsc_ops = {
- .info = {
- .name = "DST ATSC",
- .type = FE_ATSC,
- .frequency_stepsize = 62500,
- .frequency_min = 510000000,
- .frequency_max = 858000000,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .caps = FE_CAN_FEC_AUTO | FE_CAN_QAM_AUTO | FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
- },
-
- .release = dst_release,
- .init = dst_init,
- .tune = dst_tune_frontend,
- .set_frontend = dst_set_frontend,
- .get_frontend = dst_get_frontend,
- .get_frontend_algo = dst_get_tuning_algo,
- .read_status = dst_read_status,
- .read_signal_strength = dst_read_signal_strength,
- .read_snr = dst_read_snr,
-};
-
-MODULE_DESCRIPTION("DST DVB-S/T/C/ATSC Combo Frontend driver");
-MODULE_AUTHOR("Jamie Honan, Manu Abraham");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
deleted file mode 100644
index fa923b9b346..00000000000
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- CA-driver for TwinHan DST Frontend/Card
-
- Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/dvb/ca.h>
-#include "dvbdev.h"
-#include "dvb_frontend.h"
-#include "dst_ca.h"
-#include "dst_common.h"
-
-#define DST_CA_ERROR 0
-#define DST_CA_NOTICE 1
-#define DST_CA_INFO 2
-#define DST_CA_DEBUG 3
-
-#define dprintk(x, y, z, format, arg...) do { \
- if (z) { \
- if ((x > DST_CA_ERROR) && (x > y)) \
- printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \
- else if ((x > DST_CA_NOTICE) && (x > y)) \
- printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \
- else if ((x > DST_CA_INFO) && (x > y)) \
- printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \
- else if ((x > DST_CA_DEBUG) && (x > y)) \
- printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \
- } else { \
- if (x > y) \
- printk(format, ## arg); \
- } \
-} while(0)
-
-
-static unsigned int verbose = 5;
-module_param(verbose, int, 0644);
-MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
-
-/* Need some more work */
-static int ca_set_slot_descr(void)
-{
- /* We could make this more graceful ? */
- return -EOPNOTSUPP;
-}
-
-/* Need some more work */
-static int ca_set_pid(void)
-{
- /* We could make this more graceful ? */
- return -EOPNOTSUPP;
-}
-
-static void put_command_and_length(u8 *data, int command, int length)
-{
- data[0] = (command >> 16) & 0xff;
- data[1] = (command >> 8) & 0xff;
- data[2] = command & 0xff;
- data[3] = length;
-}
-
-static void put_checksum(u8 *check_string, int length)
-{
- dprintk(verbose, DST_CA_DEBUG, 1, " Computing string checksum.");
- dprintk(verbose, DST_CA_DEBUG, 1, " -> string length : 0x%02x", length);
- check_string[length] = dst_check_sum (check_string, length);
- dprintk(verbose, DST_CA_DEBUG, 1, " -> checksum : 0x%02x", check_string[length]);
-}
-
-static int dst_ci_command(struct dst_state* state, u8 * data, u8 *ca_string, u8 len, int read)
-{
- u8 reply;
-
- mutex_lock(&state->dst_mutex);
- dst_comm_init(state);
- msleep(65);
-
- if (write_dst(state, data, len)) {
- dprintk(verbose, DST_CA_INFO, 1, " Write not successful, trying to recover");
- dst_error_recovery(state);
- goto error;
- }
- if ((dst_pio_disable(state)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " DST PIO disable failed.");
- goto error;
- }
- if (read_dst(state, &reply, GET_ACK) < 0) {
- dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover");
- dst_error_recovery(state);
- goto error;
- }
- if (read) {
- if (! dst_wait_dst_ready(state, LONG_DELAY)) {
- dprintk(verbose, DST_CA_NOTICE, 1, " 8820 not ready");
- goto error;
- }
- if (read_dst(state, ca_string, 128) < 0) { /* Try to make this dynamic */
- dprintk(verbose, DST_CA_INFO, 1, " Read not successful, trying to recover");
- dst_error_recovery(state);
- goto error;
- }
- }
- mutex_unlock(&state->dst_mutex);
- return 0;
-
-error:
- mutex_unlock(&state->dst_mutex);
- return -EIO;
-}
-
-
-static int dst_put_ci(struct dst_state *state, u8 *data, int len, u8 *ca_string, int read)
-{
- u8 dst_ca_comm_err = 0;
-
- while (dst_ca_comm_err < RETRIES) {
- dprintk(verbose, DST_CA_NOTICE, 1, " Put Command");
- if (dst_ci_command(state, data, ca_string, len, read)) { // If error
- dst_error_recovery(state);
- dst_ca_comm_err++; // work required here.
- } else {
- break;
- }
- }
-
- if(dst_ca_comm_err == RETRIES)
- return -1;
-
- return 0;
-}
-
-
-
-static int ca_get_app_info(struct dst_state *state)
-{
- int length, str_length;
- static u8 command[8] = {0x07, 0x40, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff};
-
- put_checksum(&command[0], command[0]);
- if ((dst_put_ci(state, command, sizeof(command), state->messages, GET_REPLY)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
- return -1;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
- dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================");
- dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]",
- state->messages[7], (state->messages[8] << 8) | state->messages[9],
- (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12]));
- dprintk(verbose, DST_CA_INFO, 1, " ==================================================================================================");
-
- // Transform dst message to correct application_info message
- length = state->messages[5];
- str_length = length - 6;
- if (str_length < 0) {
- str_length = 0;
- dprintk(verbose, DST_CA_ERROR, 1, "Invalid string length returned in ca_get_app_info(). Recovering.");
- }
-
- // First, the command and length fields
- put_command_and_length(&state->messages[0], CA_APP_INFO, length);
-
- // Copy application_type, application_manufacturer and manufacturer_code
- memcpy(&state->messages[4], &state->messages[7], 5);
-
- // Set string length and copy string
- state->messages[9] = str_length;
- memcpy(&state->messages[10], &state->messages[12], str_length);
-
- return 0;
-}
-
-static int ca_get_ca_info(struct dst_state *state)
-{
- int srcPtr, dstPtr, i, num_ids;
- static u8 slot_command[8] = {0x07, 0x40, 0x00, 0x00, 0x02, 0x00, 0x00, 0xff};
- const int in_system_id_pos = 8, out_system_id_pos = 4, in_num_ids_pos = 7;
-
- put_checksum(&slot_command[0], slot_command[0]);
- if ((dst_put_ci(state, slot_command, sizeof (slot_command), state->messages, GET_REPLY)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
- return -1;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
-
- // Print raw data
- dprintk(verbose, DST_CA_INFO, 0, " DST data = [");
- for (i = 0; i < state->messages[0] + 1; i++) {
- dprintk(verbose, DST_CA_INFO, 0, " 0x%02x", state->messages[i]);
- }
- dprintk(verbose, DST_CA_INFO, 0, "]\n");
-
- // Set the command and length of the output
- num_ids = state->messages[in_num_ids_pos];
- if (num_ids >= 100) {
- num_ids = 100;
- dprintk(verbose, DST_CA_ERROR, 1, "Invalid number of ids (>100). Recovering.");
- }
- put_command_and_length(&state->messages[0], CA_INFO, num_ids * 2);
-
- dprintk(verbose, DST_CA_INFO, 0, " CA_INFO = [");
- srcPtr = in_system_id_pos;
- dstPtr = out_system_id_pos;
- for(i = 0; i < num_ids; i++) {
- dprintk(verbose, DST_CA_INFO, 0, " 0x%02x%02x", state->messages[srcPtr + 0], state->messages[srcPtr + 1]);
- // Append to output
- state->messages[dstPtr + 0] = state->messages[srcPtr + 0];
- state->messages[dstPtr + 1] = state->messages[srcPtr + 1];
- srcPtr += 2;
- dstPtr += 2;
- }
- dprintk(verbose, DST_CA_INFO, 0, "]\n");
-
- return 0;
-}
-
-static int ca_get_slot_caps(struct dst_state *state, struct ca_caps *p_ca_caps, void __user *arg)
-{
- int i;
- u8 slot_cap[256];
- static u8 slot_command[8] = {0x07, 0x40, 0x02, 0x00, 0x02, 0x00, 0x00, 0xff};
-
- put_checksum(&slot_command[0], slot_command[0]);
- if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_cap, GET_REPLY)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
- return -1;
- }
- dprintk(verbose, DST_CA_NOTICE, 1, " -->dst_put_ci SUCCESS !");
-
- /* Will implement the rest soon */
-
- dprintk(verbose, DST_CA_INFO, 1, " Slot cap = [%d]", slot_cap[7]);
- dprintk(verbose, DST_CA_INFO, 0, "===================================\n");
- for (i = 0; i < slot_cap[0] + 1; i++)
- dprintk(verbose, DST_CA_INFO, 0, " %d", slot_cap[i]);
- dprintk(verbose, DST_CA_INFO, 0, "\n");
-
- p_ca_caps->slot_num = 1;
- p_ca_caps->slot_type = 1;
- p_ca_caps->descr_num = slot_cap[7];
- p_ca_caps->descr_type = 1;
-
- if (copy_to_user(arg, p_ca_caps, sizeof (struct ca_caps)))
- return -EFAULT;
-
- return 0;
-}
-
-/* Need some more work */
-static int ca_get_slot_descr(struct dst_state *state, struct ca_msg *p_ca_message, void __user *arg)
-{
- return -EOPNOTSUPP;
-}
-
-
-static int ca_get_slot_info(struct dst_state *state, struct ca_slot_info *p_ca_slot_info, void __user *arg)
-{
- int i;
- static u8 slot_command[8] = {0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff};
-
- u8 *slot_info = state->messages;
-
- put_checksum(&slot_command[0], 7);
- if ((dst_put_ci(state, slot_command, sizeof (slot_command), slot_info, GET_REPLY)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->dst_put_ci FAILED !");
- return -1;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->dst_put_ci SUCCESS !");
-
- /* Will implement the rest soon */
-
- dprintk(verbose, DST_CA_INFO, 1, " Slot info = [%d]", slot_info[3]);
- dprintk(verbose, DST_CA_INFO, 0, "===================================\n");
- for (i = 0; i < 8; i++)
- dprintk(verbose, DST_CA_INFO, 0, " %d", slot_info[i]);
- dprintk(verbose, DST_CA_INFO, 0, "\n");
-
- if (slot_info[4] & 0x80) {
- p_ca_slot_info->flags = CA_CI_MODULE_PRESENT;
- p_ca_slot_info->num = 1;
- p_ca_slot_info->type = CA_CI;
- } else if (slot_info[4] & 0x40) {
- p_ca_slot_info->flags = CA_CI_MODULE_READY;
- p_ca_slot_info->num = 1;
- p_ca_slot_info->type = CA_CI;
- } else
- p_ca_slot_info->flags = 0;
-
- if (copy_to_user(arg, p_ca_slot_info, sizeof (struct ca_slot_info)))
- return -EFAULT;
-
- return 0;
-}
-
-
-static int ca_get_message(struct dst_state *state, struct ca_msg *p_ca_message, void __user *arg)
-{
- u8 i = 0;
- u32 command = 0;
-
- if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg)))
- return -EFAULT;
-
- if (p_ca_message->msg) {
- dprintk(verbose, DST_CA_NOTICE, 1, " Message = [%02x %02x %02x]", p_ca_message->msg[0], p_ca_message->msg[1], p_ca_message->msg[2]);
-
- for (i = 0; i < 3; i++) {
- command = command | p_ca_message->msg[i];
- if (i < 2)
- command = command << 8;
- }
- dprintk(verbose, DST_CA_NOTICE, 1, " Command=[0x%x]", command);
-
- switch (command) {
- case CA_APP_INFO:
- memcpy(p_ca_message->msg, state->messages, 128);
- if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) )
- return -EFAULT;
- break;
- case CA_INFO:
- memcpy(p_ca_message->msg, state->messages, 128);
- if (copy_to_user(arg, p_ca_message, sizeof (struct ca_msg)) )
- return -EFAULT;
- break;
- }
- }
-
- return 0;
-}
-
-static int handle_dst_tag(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u32 length)
-{
- if (state->dst_hw_cap & DST_TYPE_HAS_SESSION) {
- hw_buffer->msg[2] = p_ca_message->msg[1]; /* MSB */
- hw_buffer->msg[3] = p_ca_message->msg[2]; /* LSB */
- } else {
- if (length > 247) {
- dprintk(verbose, DST_CA_ERROR, 1, " Message too long ! *** Bailing Out *** !");
- return -1;
- }
- hw_buffer->msg[0] = (length & 0xff) + 7;
- hw_buffer->msg[1] = 0x40;
- hw_buffer->msg[2] = 0x03;
- hw_buffer->msg[3] = 0x00;
- hw_buffer->msg[4] = 0x03;
- hw_buffer->msg[5] = length & 0xff;
- hw_buffer->msg[6] = 0x00;
-
- /*
- * Need to compute length for EN50221 section 8.3.2, for the time being
- * assuming 8.3.2 is not applicable
- */
- memcpy(&hw_buffer->msg[7], &p_ca_message->msg[4], length);
- }
-
- return 0;
-}
-
-static int write_to_8820(struct dst_state *state, struct ca_msg *hw_buffer, u8 length, u8 reply)
-{
- if ((dst_put_ci(state, hw_buffer->msg, length, hw_buffer->msg, reply)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " DST-CI Command failed.");
- dprintk(verbose, DST_CA_NOTICE, 1, " Resetting DST.");
- rdc_reset_state(state);
- return -1;
- }
- dprintk(verbose, DST_CA_NOTICE, 1, " DST-CI Command success.");
-
- return 0;
-}
-
-static u32 asn_1_decode(u8 *asn_1_array)
-{
- u8 length_field = 0, word_count = 0, count = 0;
- u32 length = 0;
-
- length_field = asn_1_array[0];
- dprintk(verbose, DST_CA_DEBUG, 1, " Length field=[%02x]", length_field);
- if (length_field < 0x80) {
- length = length_field & 0x7f;
- dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%02x]\n", length);
- } else {
- word_count = length_field & 0x7f;
- for (count = 0; count < word_count; count++) {
- length = length << 8;
- length += asn_1_array[count + 1];
- dprintk(verbose, DST_CA_DEBUG, 1, " Length=[%04x]", length);
- }
- }
- return length;
-}
-
-static int debug_string(u8 *msg, u32 length, u32 offset)
-{
- u32 i;
-
- dprintk(verbose, DST_CA_DEBUG, 0, " String=[ ");
- for (i = offset; i < length; i++)
- dprintk(verbose, DST_CA_DEBUG, 0, "%02x ", msg[i]);
- dprintk(verbose, DST_CA_DEBUG, 0, "]\n");
-
- return 0;
-}
-
-
-static int ca_set_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer, u8 reply, u8 query)
-{
- u32 length = 0;
- u8 tag_length = 8;
-
- length = asn_1_decode(&p_ca_message->msg[3]);
- dprintk(verbose, DST_CA_DEBUG, 1, " CA Message length=[%d]", length);
- debug_string(&p_ca_message->msg[4], length, 0); /* length is excluding tag & length */
-
- memset(hw_buffer->msg, '\0', length);
- handle_dst_tag(state, p_ca_message, hw_buffer, length);
- put_checksum(hw_buffer->msg, hw_buffer->msg[0]);
-
- debug_string(hw_buffer->msg, (length + tag_length), 0); /* tags too */
- write_to_8820(state, hw_buffer, (length + tag_length), reply);
-
- return 0;
-}
-
-
-/* Board supports CA PMT reply ? */
-static int dst_check_ca_pmt(struct dst_state *state, struct ca_msg *p_ca_message, struct ca_msg *hw_buffer)
-{
- int ca_pmt_reply_test = 0;
-
- /* Do test board */
- /* Not there yet but soon */
-
- /* CA PMT Reply capable */
- if (ca_pmt_reply_test) {
- if ((ca_set_pmt(state, p_ca_message, hw_buffer, 1, GET_REPLY)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !");
- return -1;
- }
-
- /* Process CA PMT Reply */
- /* will implement soon */
- dprintk(verbose, DST_CA_ERROR, 1, " Not there yet");
- }
- /* CA PMT Reply not capable */
- if (!ca_pmt_reply_test) {
- if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, NO_REPLY)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " ca_set_pmt.. failed !");
- return -1;
- }
- dprintk(verbose, DST_CA_NOTICE, 1, " ca_set_pmt.. success !");
- /* put a dummy message */
-
- }
- return 0;
-}
-
-static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message, void __user *arg)
-{
- int i = 0;
- unsigned int ca_message_header_len;
-
- u32 command = 0;
- struct ca_msg *hw_buffer;
- int result = 0;
-
- if ((hw_buffer = (struct ca_msg *) kmalloc(sizeof (struct ca_msg), GFP_KERNEL)) == NULL) {
- dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
- return -ENOMEM;
- }
- dprintk(verbose, DST_CA_DEBUG, 1, " ");
-
- if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg))) {
- result = -EFAULT;
- goto free_mem_and_exit;
- }
-
-
- if (p_ca_message->msg) {
- ca_message_header_len = p_ca_message->length; /* Restore it back when you are done */
- /* EN50221 tag */
- command = 0;
-
- for (i = 0; i < 3; i++) {
- command = command | p_ca_message->msg[i];
- if (i < 2)
- command = command << 8;
- }
- dprintk(verbose, DST_CA_DEBUG, 1, " Command=[0x%x]\n", command);
-
- switch (command) {
- case CA_PMT:
- dprintk(verbose, DST_CA_DEBUG, 1, "Command = SEND_CA_PMT");
- if ((ca_set_pmt(state, p_ca_message, hw_buffer, 0, 0)) < 0) { // code simplification started
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT Success !");
- break;
- case CA_PMT_REPLY:
- dprintk(verbose, DST_CA_INFO, 1, "Command = CA_PMT_REPLY");
- /* Have to handle the 2 basic types of cards here */
- if ((dst_check_ca_pmt(state, p_ca_message, hw_buffer)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_PMT_REPLY Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_PMT_REPLY Success !");
- break;
- case CA_APP_INFO_ENQUIRY: // only for debugging
- dprintk(verbose, DST_CA_INFO, 1, " Getting Cam Application information");
-
- if ((ca_get_app_info(state)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_APP_INFO_ENQUIRY Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_APP_INFO_ENQUIRY Success !");
- break;
- case CA_INFO_ENQUIRY:
- dprintk(verbose, DST_CA_INFO, 1, " Getting CA Information");
-
- if ((ca_get_ca_info(state)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_INFO_ENQUIRY Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_INFO_ENQUIRY Success !");
- break;
- }
- }
-free_mem_and_exit:
- kfree (hw_buffer);
-
- return result;
-}
-
-static int dst_ca_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long ioctl_arg)
-{
- struct dvb_device* dvbdev = (struct dvb_device*) file->private_data;
- struct dst_state* state = (struct dst_state*) dvbdev->priv;
- struct ca_slot_info *p_ca_slot_info;
- struct ca_caps *p_ca_caps;
- struct ca_msg *p_ca_message;
- void __user *arg = (void __user *)ioctl_arg;
- int result = 0;
-
- p_ca_message = kmalloc(sizeof (struct ca_msg), GFP_KERNEL);
- p_ca_slot_info = kmalloc(sizeof (struct ca_slot_info), GFP_KERNEL);
- p_ca_caps = kmalloc(sizeof (struct ca_caps), GFP_KERNEL);
- if (!p_ca_message || !p_ca_slot_info || !p_ca_caps) {
- dprintk(verbose, DST_CA_ERROR, 1, " Memory allocation failure");
- result = -ENOMEM;
- goto free_mem_and_exit;
- }
-
- /* We have now only the standard ioctl's, the driver is upposed to handle internals. */
- switch (cmd) {
- case CA_SEND_MSG:
- dprintk(verbose, DST_CA_INFO, 1, " Sending message");
- if ((ca_send_message(state, p_ca_message, arg)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SEND_MSG Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- break;
- case CA_GET_MSG:
- dprintk(verbose, DST_CA_INFO, 1, " Getting message");
- if ((ca_get_message(state, p_ca_message, arg)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_MSG Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_MSG Success !");
- break;
- case CA_RESET:
- dprintk(verbose, DST_CA_ERROR, 1, " Resetting DST");
- dst_error_bailout(state);
- msleep(4000);
- break;
- case CA_GET_SLOT_INFO:
- dprintk(verbose, DST_CA_INFO, 1, " Getting Slot info");
- if ((ca_get_slot_info(state, p_ca_slot_info, arg)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_SLOT_INFO Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_SLOT_INFO Success !");
- break;
- case CA_GET_CAP:
- dprintk(verbose, DST_CA_INFO, 1, " Getting Slot capabilities");
- if ((ca_get_slot_caps(state, p_ca_caps, arg)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_CAP Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_CAP Success !");
- break;
- case CA_GET_DESCR_INFO:
- dprintk(verbose, DST_CA_INFO, 1, " Getting descrambler description");
- if ((ca_get_slot_descr(state, p_ca_message, arg)) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_GET_DESCR_INFO Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_GET_DESCR_INFO Success !");
- break;
- case CA_SET_DESCR:
- dprintk(verbose, DST_CA_INFO, 1, " Setting descrambler");
- if ((ca_set_slot_descr()) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_DESCR Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_DESCR Success !");
- break;
- case CA_SET_PID:
- dprintk(verbose, DST_CA_INFO, 1, " Setting PID");
- if ((ca_set_pid()) < 0) {
- dprintk(verbose, DST_CA_ERROR, 1, " -->CA_SET_PID Failed !");
- result = -1;
- goto free_mem_and_exit;
- }
- dprintk(verbose, DST_CA_INFO, 1, " -->CA_SET_PID Success !");
- default:
- result = -EOPNOTSUPP;
- };
- free_mem_and_exit:
- kfree (p_ca_message);
- kfree (p_ca_slot_info);
- kfree (p_ca_caps);
-
- return result;
-}
-
-static int dst_ca_open(struct inode *inode, struct file *file)
-{
- dprintk(verbose, DST_CA_DEBUG, 1, " Device opened [%p] ", file);
- try_module_get(THIS_MODULE);
-
- return 0;
-}
-
-static int dst_ca_release(struct inode *inode, struct file *file)
-{
- dprintk(verbose, DST_CA_DEBUG, 1, " Device closed.");
- module_put(THIS_MODULE);
-
- return 0;
-}
-
-static ssize_t dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset)
-{
- ssize_t bytes_read = 0;
-
- dprintk(verbose, DST_CA_DEBUG, 1, " Device read.");
-
- return bytes_read;
-}
-
-static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset)
-{
- dprintk(verbose, DST_CA_DEBUG, 1, " Device write.");
-
- return 0;
-}
-
-static struct file_operations dst_ca_fops = {
- .owner = THIS_MODULE,
- .ioctl = dst_ca_ioctl,
- .open = dst_ca_open,
- .release = dst_ca_release,
- .read = dst_ca_read,
- .write = dst_ca_write
-};
-
-static struct dvb_device dvbdev_ca = {
- .priv = NULL,
- .users = 1,
- .readers = 1,
- .writers = 1,
- .fops = &dst_ca_fops
-};
-
-int dst_ca_attach(struct dst_state *dst, struct dvb_adapter *dvb_adapter)
-{
- struct dvb_device *dvbdev;
- dprintk(verbose, DST_CA_ERROR, 1, "registering DST-CA device");
- dvb_register_device(dvb_adapter, &dvbdev, &dvbdev_ca, dst, DVB_DEVICE_CA);
- return 0;
-}
-
-EXPORT_SYMBOL(dst_ca_attach);
-
-MODULE_DESCRIPTION("DST DVB-S/T/C Combo CA driver");
-MODULE_AUTHOR("Manu Abraham");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/bt8xx/dst_ca.h b/drivers/media/dvb/bt8xx/dst_ca.h
deleted file mode 100644
index 59cd0ddd6d8..00000000000
--- a/drivers/media/dvb/bt8xx/dst_ca.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- CA-driver for TwinHan DST Frontend/Card
-
- Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef _DST_CA_H_
-#define _DST_CA_H_
-
-#define RETRIES 5
-
-
-#define CA_APP_INFO_ENQUIRY 0x9f8020
-#define CA_APP_INFO 0x9f8021
-#define CA_ENTER_MENU 0x9f8022
-#define CA_INFO_ENQUIRY 0x9f8030
-#define CA_INFO 0x9f8031
-#define CA_PMT 0x9f8032
-#define CA_PMT_REPLY 0x9f8033
-
-#define CA_CLOSE_MMI 0x9f8800
-#define CA_DISPLAY_CONTROL 0x9f8801
-#define CA_DISPLAY_REPLY 0x9f8802
-#define CA_TEXT_LAST 0x9f8803
-#define CA_TEXT_MORE 0x9f8804
-#define CA_KEYPAD_CONTROL 0x9f8805
-#define CA_KEYPRESS 0x9f8806
-
-#define CA_ENQUIRY 0x9f8807
-#define CA_ANSWER 0x9f8808
-#define CA_MENU_LAST 0x9f8809
-#define CA_MENU_MORE 0x9f880a
-#define CA_MENU_ANSWER 0x9f880b
-#define CA_LIST_LAST 0x9f880c
-#define CA_LIST_MORE 0x9f880d
-
-
-struct dst_ca_private {
- struct dst_state *dst;
- struct dvb_device *dvbdev;
-};
-
-
-#endif
diff --git a/drivers/media/dvb/bt8xx/dst_common.h b/drivers/media/dvb/bt8xx/dst_common.h
deleted file mode 100644
index 0677b047b3a..00000000000
--- a/drivers/media/dvb/bt8xx/dst_common.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- Frontend-driver for TwinHan DST Frontend
-
- Copyright (C) 2003 Jamie Honan
- Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef DST_COMMON_H
-#define DST_COMMON_H
-
-#include <linux/smp_lock.h>
-#include <linux/dvb/frontend.h>
-#include <linux/device.h>
-#include <linux/mutex.h>
-#include "bt878.h"
-
-#include "dst_ca.h"
-
-
-#define NO_DELAY 0
-#define LONG_DELAY 1
-#define DEVICE_INIT 2
-
-#define DELAY 1
-
-#define DST_TYPE_IS_SAT 0
-#define DST_TYPE_IS_TERR 1
-#define DST_TYPE_IS_CABLE 2
-#define DST_TYPE_IS_ATSC 3
-
-#define DST_TYPE_HAS_TS188 1
-#define DST_TYPE_HAS_TS204 2
-#define DST_TYPE_HAS_SYMDIV 4
-#define DST_TYPE_HAS_FW_1 8
-#define DST_TYPE_HAS_FW_2 16
-#define DST_TYPE_HAS_FW_3 32
-#define DST_TYPE_HAS_FW_BUILD 64
-#define DST_TYPE_HAS_OBS_REGS 128
-#define DST_TYPE_HAS_INC_COUNT 256
-#define DST_TYPE_HAS_MULTI_FE 512
-#define DST_TYPE_HAS_NEWTUNE_2 1024
-#define DST_TYPE_HAS_DBOARD 2048
-#define DST_TYPE_HAS_VLF 4096
-
-/* Card capability list */
-
-#define DST_TYPE_HAS_MAC 1
-#define DST_TYPE_HAS_DISEQC3 2
-#define DST_TYPE_HAS_DISEQC4 4
-#define DST_TYPE_HAS_DISEQC5 8
-#define DST_TYPE_HAS_MOTO 16
-#define DST_TYPE_HAS_CA 32
-#define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */
-#define DST_TYPE_HAS_SESSION 128
-
-#define TUNER_TYPE_MULTI 1
-#define TUNER_TYPE_UNKNOWN 2
-/* DVB-S */
-#define TUNER_TYPE_L64724 4
-#define TUNER_TYPE_STV0299 8
-#define TUNER_TYPE_MB86A15 16
-
-/* DVB-T */
-#define TUNER_TYPE_TDA10046 32
-
-/* ATSC */
-#define TUNER_TYPE_NXT200x 64
-
-
-#define RDC_8820_PIO_0_DISABLE 0
-#define RDC_8820_PIO_0_ENABLE 1
-#define RDC_8820_INT 2
-#define RDC_8820_RESET 4
-
-/* DST Communication */
-#define GET_REPLY 1
-#define NO_REPLY 0
-
-#define GET_ACK 1
-#define FIXED_COMM 8
-
-#define ACK 0xff
-
-struct dst_state {
-
- struct i2c_adapter* i2c;
-
- struct bt878* bt;
-
- /* configuration settings */
- const struct dst_config* config;
-
- struct dvb_frontend frontend;
-
- /* private ASIC data */
- u8 tx_tuna[10];
- u8 rx_tuna[10];
- u8 rxbuffer[10];
- u8 diseq_flags;
- u8 dst_type;
- u32 type_flags;
- u32 frequency; /* intermediate frequency in kHz for QPSK */
- fe_spectral_inversion_t inversion;
- u32 symbol_rate; /* symbol rate in Symbols per second */
- fe_code_rate_t fec;
- fe_sec_voltage_t voltage;
- fe_sec_tone_mode_t tone;
- u32 decode_freq;
- u8 decode_lock;
- u16 decode_strength;
- u16 decode_snr;
- unsigned long cur_jiff;
- u8 k22;
- fe_bandwidth_t bandwidth;
- u32 dst_hw_cap;
- u8 dst_fw_version;
- fe_sec_mini_cmd_t minicmd;
- fe_modulation_t modulation;
- u8 messages[256];
- u8 mac_address[8];
- u8 fw_version[8];
- u8 card_info[8];
- u8 vendor[8];
- u8 board_info[8];
- u32 tuner_type;
- char *tuner_name;
- struct mutex dst_mutex;
- u8 fw_name[8];
-};
-
-struct tuner_types {
- u32 tuner_type;
- char *tuner_name;
- char *board_name;
- char *fw_name;
-};
-
-struct dst_types {
- char *device_id;
- int offset;
- u8 dst_type;
- u32 type_flags;
- u32 dst_feature;
- u32 tuner_type;
-};
-
-struct dst_config
-{
- /* the ASIC i2c address */
- u8 demod_address;
-};
-
-int rdc_reset_state(struct dst_state *state);
-int rdc_8820_reset(struct dst_state *state);
-
-int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode);
-int dst_pio_enable(struct dst_state *state);
-int dst_pio_disable(struct dst_state *state);
-int dst_error_recovery(struct dst_state* state);
-int dst_error_bailout(struct dst_state *state);
-int dst_comm_init(struct dst_state* state);
-
-int write_dst(struct dst_state *state, u8 * data, u8 len);
-int read_dst(struct dst_state *state, u8 * ret, u8 len);
-u8 dst_check_sum(u8 * buf, u32 len);
-struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
-int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
-int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
-
-int dst_command(struct dst_state* state, u8 * data, u8 len);
-
-
-#endif // DST_COMMON_H
diff --git a/drivers/media/dvb/bt8xx/dst_priv.h b/drivers/media/dvb/bt8xx/dst_priv.h
deleted file mode 100644
index 3974a4c6ebe..00000000000
--- a/drivers/media/dvb/bt8xx/dst_priv.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * dst-bt878.h: part of the DST driver for the TwinHan DST Frontend
- *
- * Copyright (C) 2003 Jamie Honan
- */
-
-struct dst_gpio_enable {
- u32 mask;
- u32 enable;
-};
-
-struct dst_gpio_output {
- u32 mask;
- u32 highvals;
-};
-
-struct dst_gpio_read {
- unsigned long value;
-};
-
-union dst_gpio_packet {
- struct dst_gpio_enable enb;
- struct dst_gpio_output outp;
- struct dst_gpio_read rd;
- int psize;
-};
-
-#define DST_IG_ENABLE 0
-#define DST_IG_WRITE 1
-#define DST_IG_READ 2
-#define DST_IG_TS 3
-
-struct bt878;
-
-int bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *mp);
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
deleted file mode 100644
index b715b972d2f..00000000000
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ /dev/null
@@ -1,963 +0,0 @@
-/*
- * Bt8xx based DVB adapter driver
- *
- * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org>
- *
- * 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/bitops.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/i2c.h>
-
-#include "dmxdev.h"
-#include "dvbdev.h"
-#include "dvb_demux.h"
-#include "dvb_frontend.h"
-#include "dvb-bt8xx.h"
-#include "bt878.h"
-#include "dvb-pll.h"
-
-static int debug;
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
-
-#define dprintk( args... ) \
- do \
- if (debug) printk(KERN_DEBUG args); \
- while (0)
-
-#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
-
-static void dvb_bt8xx_task(unsigned long data)
-{
- struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *)data;
-
- //printk("%d ", card->bt->finished_block);
-
- while (card->bt->last_block != card->bt->finished_block) {
- (card->bt->TS_Size ? dvb_dmx_swfilter_204 : dvb_dmx_swfilter)
- (&card->demux,
- &card->bt->buf_cpu[card->bt->last_block *
- card->bt->block_bytes],
- card->bt->block_bytes);
- card->bt->last_block = (card->bt->last_block + 1) %
- card->bt->block_count;
- }
-}
-
-static int dvb_bt8xx_start_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
- struct dvb_bt8xx_card *card = dvbdmx->priv;
- int rc;
-
- dprintk("dvb_bt8xx: start_feed\n");
-
- if (!dvbdmx->dmx.frontend)
- return -EINVAL;
-
- mutex_lock(&card->lock);
- card->nfeeds++;
- rc = card->nfeeds;
- if (card->nfeeds == 1)
- bt878_start(card->bt, card->gpio_mode,
- card->op_sync_orin, card->irq_err_ignore);
- mutex_unlock(&card->lock);
- return rc;
-}
-
-static int dvb_bt8xx_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
- struct dvb_bt8xx_card *card = dvbdmx->priv;
-
- dprintk("dvb_bt8xx: stop_feed\n");
-
- if (!dvbdmx->dmx.frontend)
- return -EINVAL;
-
- mutex_lock(&card->lock);
- card->nfeeds--;
- if (card->nfeeds == 0)
- bt878_stop(card->bt);
- mutex_unlock(&card->lock);
-
- return 0;
-}
-
-static int is_pci_slot_eq(struct pci_dev* adev, struct pci_dev* bdev)
-{
- if ((adev->subsystem_vendor == bdev->subsystem_vendor) &&
- (adev->subsystem_device == bdev->subsystem_device) &&
- (adev->bus->number == bdev->bus->number) &&
- (PCI_SLOT(adev->devfn) == PCI_SLOT(bdev->devfn)))
- return 1;
- return 0;
-}
-
-static struct bt878 __devinit *dvb_bt8xx_878_match(unsigned int bttv_nr, struct pci_dev* bttv_pci_dev)
-{
- unsigned int card_nr;
-
- /* Hmm, n squared. Hope n is small */
- for (card_nr = 0; card_nr < bt878_num; card_nr++)
- if (is_pci_slot_eq(bt878[card_nr].dev, bttv_pci_dev))
- return &bt878[card_nr];
- return NULL;
-}
-
-static int thomson_dtt7579_demod_init(struct dvb_frontend* fe)
-{
- static u8 mt352_clock_config [] = { 0x89, 0x38, 0x38 };
- static u8 mt352_reset [] = { 0x50, 0x80 };
- static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
- static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0x20 };
- static u8 mt352_gpp_ctl_cfg [] = { 0x8C, 0x33 };
- static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
-
- mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
- udelay(2000);
- mt352_write(fe, mt352_reset, sizeof(mt352_reset));
- mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
-
- mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
- mt352_write(fe, mt352_gpp_ctl_cfg, sizeof(mt352_gpp_ctl_cfg));
- mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
-
- return 0;
-}
-
-static int thomson_dtt7579_tuner_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len)
-{
- u32 div;
- unsigned char bs = 0;
- unsigned char cp = 0;
-
- if (buf_len < 5)
- return -EINVAL;
-
- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
-
- if (params->frequency < 542000000)
- cp = 0xb4;
- else if (params->frequency < 771000000)
- cp = 0xbc;
- else
- cp = 0xf4;
-
- if (params->frequency == 0)
- bs = 0x03;
- else if (params->frequency < 443250000)
- bs = 0x02;
- else
- bs = 0x08;
-
- pllbuf[0] = 0x60;
- pllbuf[1] = div >> 8;
- pllbuf[2] = div & 0xff;
- pllbuf[3] = cp;
- pllbuf[4] = bs;
-
- return 5;
-}
-
-static struct mt352_config thomson_dtt7579_config = {
- .demod_address = 0x0f,
- .demod_init = thomson_dtt7579_demod_init,
-};
-
-static struct zl10353_config thomson_dtt7579_zl10353_config = {
- .demod_address = 0x0f,
-};
-
-static int cx24108_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- u32 freq = params->frequency;
-
- int i, a, n, pump;
- u32 band, pll;
-
- u32 osci[]={950000,1019000,1075000,1178000,1296000,1432000,
- 1576000,1718000,1856000,2036000,2150000};
- u32 bandsel[]={0,0x00020000,0x00040000,0x00100800,0x00101000,
- 0x00102000,0x00104000,0x00108000,0x00110000,
- 0x00120000,0x00140000};
-
- #define XTAL 1011100 /* Hz, really 1.0111 MHz and a /10 prescaler */
- printk("cx24108 debug: entering SetTunerFreq, freq=%d\n",freq);
-
- /* This is really the bit driving the tuner chip cx24108 */
-
- if (freq<950000)
- freq = 950000; /* kHz */
- else if (freq>2150000)
- freq = 2150000; /* satellite IF is 950..2150MHz */
-
- /* decide which VCO to use for the input frequency */
- for(i=1;(i<sizeof(osci)/sizeof(osci[0]))&&(osci[i]<freq);i++);
- printk("cx24108 debug: select vco #%d (f=%d)\n",i,freq);
- band=bandsel[i];
- /* the gain values must be set by SetSymbolrate */
- /* compute the pll divider needed, from Conexant data sheet,
- resolved for (n*32+a), remember f(vco) is f(receive) *2 or *4,
- depending on the divider bit. It is set to /4 on the 2 lowest
- bands */
- n=((i<=2?2:1)*freq*10L)/(XTAL/100);
- a=n%32; n/=32; if(a==0) n--;
- pump=(freq<(osci[i-1]+osci[i])/2);
- pll=0xf8000000|
- ((pump?1:2)<<(14+11))|
- ((n&0x1ff)<<(5+11))|
- ((a&0x1f)<<11);
- /* everything is shifted left 11 bits to left-align the bits in the
- 32bit word. Output to the tuner goes MSB-aligned, after all */
- printk("cx24108 debug: pump=%d, n=%d, a=%d\n",pump,n,a);
- cx24110_pll_write(fe,band);
- /* set vga and vca to their widest-band settings, as a precaution.
- SetSymbolrate might not be called to set this up */
- cx24110_pll_write(fe,0x500c0000);
- cx24110_pll_write(fe,0x83f1f800);
- cx24110_pll_write(fe,pll);
- //writereg(client,0x56,0x7f);
-
- return 0;
-}
-
-static int pinnsat_tuner_init(struct dvb_frontend* fe)
-{
- struct dvb_bt8xx_card *card = fe->dvb->priv;
-
- bttv_gpio_enable(card->bttv_nr, 1, 1); /* output */
- bttv_write_gpio(card->bttv_nr, 1, 1); /* relay on */
-
- return 0;
-}
-
-static int pinnsat_tuner_sleep(struct dvb_frontend* fe)
-{
- struct dvb_bt8xx_card *card = fe->dvb->priv;
-
- bttv_write_gpio(card->bttv_nr, 1, 0); /* relay off */
-
- return 0;
-}
-
-static struct cx24110_config pctvsat_config = {
- .demod_address = 0x55,
-};
-
-static int microtune_mt7202dtf_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
- u8 cfg, cpump, band_select;
- u8 data[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (36000000 + params->frequency + 83333) / 166666;
- cfg = 0x88;
-
- if (params->frequency < 175000000)
- cpump = 2;
- else if (params->frequency < 390000000)
- cpump = 1;
- else if (params->frequency < 470000000)
- cpump = 2;
- else if (params->frequency < 750000000)
- cpump = 2;
- else
- cpump = 3;
-
- if (params->frequency < 175000000)
- band_select = 0x0e;
- else if (params->frequency < 470000000)
- band_select = 0x05;
- else
- band_select = 0x03;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = ((div >> 10) & 0x60) | cfg;
- data[3] = (cpump << 6) | band_select;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- i2c_transfer(card->i2c_adapter, &msg, 1);
- return (div * 166666 - 36000000);
-}
-
-static int microtune_mt7202dtf_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
-{
- struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
-
- return request_firmware(fw, name, &bt->bt->dev->dev);
-}
-
-static struct sp887x_config microtune_mt7202dtf_config = {
- .demod_address = 0x70,
- .request_firmware = microtune_mt7202dtf_request_firmware,
-};
-
-static int advbt771_samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
-{
- static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
- static u8 mt352_reset [] = { 0x50, 0x80 };
- static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
- static u8 mt352_agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
- 0x00, 0xFF, 0x00, 0x40, 0x40 };
- static u8 mt352_av771_extra[] = { 0xB5, 0x7A };
- static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
-
- mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
- udelay(2000);
- mt352_write(fe, mt352_reset, sizeof(mt352_reset));
- mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
-
- mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
- udelay(2000);
- mt352_write(fe, mt352_av771_extra,sizeof(mt352_av771_extra));
- mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
-
- return 0;
-}
-
-static int advbt771_samsung_tdtc9251dh0_tuner_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len)
-{
- u32 div;
- unsigned char bs = 0;
- unsigned char cp = 0;
-
- if (buf_len < 5) return -EINVAL;
-
- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
-
- if (params->frequency < 150000000)
- cp = 0xB4;
- else if (params->frequency < 173000000)
- cp = 0xBC;
- else if (params->frequency < 250000000)
- cp = 0xB4;
- else if (params->frequency < 400000000)
- cp = 0xBC;
- else if (params->frequency < 420000000)
- cp = 0xF4;
- else if (params->frequency < 470000000)
- cp = 0xFC;
- else if (params->frequency < 600000000)
- cp = 0xBC;
- else if (params->frequency < 730000000)
- cp = 0xF4;
- else
- cp = 0xFC;
-
- if (params->frequency < 150000000)
- bs = 0x01;
- else if (params->frequency < 173000000)
- bs = 0x01;
- else if (params->frequency < 250000000)
- bs = 0x02;
- else if (params->frequency < 400000000)
- bs = 0x02;
- else if (params->frequency < 420000000)
- bs = 0x02;
- else if (params->frequency < 470000000)
- bs = 0x02;
- else if (params->frequency < 600000000)
- bs = 0x08;
- else if (params->frequency < 730000000)
- bs = 0x08;
- else
- bs = 0x08;
-
- pllbuf[0] = 0x61;
- pllbuf[1] = div >> 8;
- pllbuf[2] = div & 0xff;
- pllbuf[3] = cp;
- pllbuf[4] = bs;
-
- return 5;
-}
-
-static struct mt352_config advbt771_samsung_tdtc9251dh0_config = {
- .demod_address = 0x0f,
- .demod_init = advbt771_samsung_tdtc9251dh0_demod_init,
-};
-
-static struct dst_config dst_config = {
- .demod_address = 0x55,
-};
-
-static int or51211_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
-{
- struct dvb_bt8xx_card* bt = (struct dvb_bt8xx_card*) fe->dvb->priv;
-
- return request_firmware(fw, name, &bt->bt->dev->dev);
-}
-
-static void or51211_setmode(struct dvb_frontend * fe, int mode)
-{
- struct dvb_bt8xx_card *bt = fe->dvb->priv;
- bttv_write_gpio(bt->bttv_nr, 0x0002, mode); /* Reset */
- msleep(20);
-}
-
-static void or51211_reset(struct dvb_frontend * fe)
-{
- struct dvb_bt8xx_card *bt = fe->dvb->priv;
-
- /* RESET DEVICE
- * reset is controled by GPIO-0
- * when set to 0 causes reset and when to 1 for normal op
- * must remain reset for 128 clock cycles on a 50Mhz clock
- * also PRM1 PRM2 & PRM4 are controled by GPIO-1,GPIO-2 & GPIO-4
- * We assume that the reset has be held low long enough or we
- * have been reset by a power on. When the driver is unloaded
- * reset set to 0 so if reloaded we have been reset.
- */
- /* reset & PRM1,2&4 are outputs */
- int ret = bttv_gpio_enable(bt->bttv_nr, 0x001F, 0x001F);
- if (ret != 0)
- printk(KERN_WARNING "or51211: Init Error - Can't Reset DVR (%i)\n", ret);
- bttv_write_gpio(bt->bttv_nr, 0x001F, 0x0000); /* Reset */
- msleep(20);
- /* Now set for normal operation */
- bttv_write_gpio(bt->bttv_nr, 0x0001F, 0x0001);
- /* wait for operation to begin */
- msleep(500);
-}
-
-static void or51211_sleep(struct dvb_frontend * fe)
-{
- struct dvb_bt8xx_card *bt = fe->dvb->priv;
- bttv_write_gpio(bt->bttv_nr, 0x0001, 0x0000);
-}
-
-static struct or51211_config or51211_config = {
- .demod_address = 0x15,
- .request_firmware = or51211_request_firmware,
- .setmode = or51211_setmode,
- .reset = or51211_reset,
- .sleep = or51211_sleep,
-};
-
-static int vp3021_alps_tded4_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
- u8 buf[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = buf, .len = sizeof(buf) };
-
- div = (params->frequency + 36166667) / 166667;
-
- buf[0] = (div >> 8) & 0x7F;
- buf[1] = div & 0xFF;
- buf[2] = 0x85;
- if ((params->frequency >= 47000000) && (params->frequency < 153000000))
- buf[3] = 0x01;
- else if ((params->frequency >= 153000000) && (params->frequency < 430000000))
- buf[3] = 0x02;
- else if ((params->frequency >= 430000000) && (params->frequency < 824000000))
- buf[3] = 0x0C;
- else if ((params->frequency >= 824000000) && (params->frequency < 863000000))
- buf[3] = 0x8C;
- else
- return -EINVAL;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- i2c_transfer(card->i2c_adapter, &msg, 1);
- return 0;
-}
-
-static struct nxt6000_config vp3021_alps_tded4_config = {
- .demod_address = 0x0a,
- .clock_inversion = 1,
-};
-
-static int digitv_alps_tded4_demod_init(struct dvb_frontend* fe)
-{
- static u8 mt352_clock_config [] = { 0x89, 0x38, 0x2d };
- static u8 mt352_reset [] = { 0x50, 0x80 };
- static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
- static u8 mt352_agc_cfg [] = { 0x67, 0x20, 0xa0 };
- static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
-
- mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
- udelay(2000);
- mt352_write(fe, mt352_reset, sizeof(mt352_reset));
- mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
- mt352_write(fe, mt352_agc_cfg,sizeof(mt352_agc_cfg));
- mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
-
- return 0;
-}
-
-static int digitv_alps_tded4_tuner_calc_regs(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf, int buf_len)
-{
- u32 div;
- struct dvb_ofdm_parameters *op = &params->u.ofdm;
-
- if (buf_len < 5)
- return -EINVAL;
-
- div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
-
- pllbuf[0] = 0x61;
- pllbuf[1] = (div >> 8) & 0x7F;
- pllbuf[2] = div & 0xFF;
- pllbuf[3] = 0x85;
-
- dprintk("frequency %u, div %u\n", params->frequency, div);
-
- if (params->frequency < 470000000)
- pllbuf[4] = 0x02;
- else if (params->frequency > 823000000)
- pllbuf[4] = 0x88;
- else
- pllbuf[4] = 0x08;
-
- if (op->bandwidth == 8)
- pllbuf[4] |= 0x04;
-
- return 5;
-}
-
-static void digitv_alps_tded4_reset(struct dvb_bt8xx_card *bt)
-{
- /*
- * Reset the frontend, must be called before trying
- * to initialise the MT352 or mt352_attach
- * will fail. Same goes for the nxt6000 frontend.
- *
- */
-
- int ret = bttv_gpio_enable(bt->bttv_nr, 0x08, 0x08);
- if (ret != 0)
- printk(KERN_WARNING "digitv_alps_tded4: Init Error - Can't Reset DVR (%i)\n", ret);
-
- /* Pulse the reset line */
- bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
- bttv_write_gpio(bt->bttv_nr, 0x08, 0x00); /* Low */
- msleep(100);
-
- bttv_write_gpio(bt->bttv_nr, 0x08, 0x08); /* High */
-}
-
-static struct mt352_config digitv_alps_tded4_config = {
- .demod_address = 0x0a,
- .demod_init = digitv_alps_tded4_demod_init,
-};
-
-static int tdvs_tua6034_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct dvb_bt8xx_card *card = (struct dvb_bt8xx_card *) fe->dvb->priv;
- return lg_h06xf_pll_set(fe, card->i2c_adapter, params);
-}
-
-static struct lgdt330x_config tdvs_tua6034_config = {
- .demod_address = 0x0e,
- .demod_chip = LGDT3303,
- .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
-};
-
-static void lgdt330x_reset(struct dvb_bt8xx_card *bt)
-{
- /* Set pin 27 of the lgdt3303 chip high to reset the frontend */
-
- /* Pulse the reset line */
- bttv_write_gpio(bt->bttv_nr, 0x00e00007, 0x00000001); /* High */
- bttv_write_gpio(bt->bttv_nr, 0x00e00007, 0x00000000); /* Low */
- msleep(100);
-
- bttv_write_gpio(bt->bttv_nr, 0x00e00007, 0x00000001); /* High */
- msleep(100);
-}
-
-static void frontend_init(struct dvb_bt8xx_card *card, u32 type)
-{
- int ret;
- struct dst_state* state = NULL;
-
- switch(type) {
- case BTTV_BOARD_DVICO_DVBT_LITE:
- card->fe = mt352_attach(&thomson_dtt7579_config, card->i2c_adapter);
-
- if (card->fe == NULL)
- card->fe = zl10353_attach(&thomson_dtt7579_zl10353_config,
- card->i2c_adapter);
-
- if (card->fe != NULL) {
- card->fe->ops.tuner_ops.calc_regs = thomson_dtt7579_tuner_calc_regs;
- card->fe->ops.info.frequency_min = 174000000;
- card->fe->ops.info.frequency_max = 862000000;
- }
- break;
-
- case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:
- lgdt330x_reset(card);
- card->fe = lgdt330x_attach(&tdvs_tua6034_config, card->i2c_adapter);
- if (card->fe != NULL) {
- card->fe->ops.tuner_ops.set_params = tdvs_tua6034_tuner_set_params;
- dprintk ("dvb_bt8xx: lgdt330x detected\n");
- }
- break;
-
- case BTTV_BOARD_NEBULA_DIGITV:
- /*
- * It is possible to determine the correct frontend using the I2C bus (see the Nebula SDK);
- * this would be a cleaner solution than trying each frontend in turn.
- */
-
- /* Old Nebula (marked (c)2003 on high profile pci card) has nxt6000 demod */
- digitv_alps_tded4_reset(card);
- card->fe = nxt6000_attach(&vp3021_alps_tded4_config, card->i2c_adapter);
- if (card->fe != NULL) {
- card->fe->ops.tuner_ops.set_params = vp3021_alps_tded4_tuner_set_params;
- dprintk ("dvb_bt8xx: an nxt6000 was detected on your digitv card\n");
- break;
- }
-
- /* New Nebula (marked (c)2005 on low profile pci card) has mt352 demod */
- digitv_alps_tded4_reset(card);
- card->fe = mt352_attach(&digitv_alps_tded4_config, card->i2c_adapter);
-
- if (card->fe != NULL) {
- card->fe->ops.tuner_ops.calc_regs = digitv_alps_tded4_tuner_calc_regs;
- dprintk ("dvb_bt8xx: an mt352 was detected on your digitv card\n");
- }
- break;
-
- case BTTV_BOARD_AVDVBT_761:
- card->fe = sp887x_attach(&microtune_mt7202dtf_config, card->i2c_adapter);
- if (card->fe) {
- card->fe->ops.tuner_ops.set_params = microtune_mt7202dtf_tuner_set_params;
- }
- break;
-
- case BTTV_BOARD_AVDVBT_771:
- card->fe = mt352_attach(&advbt771_samsung_tdtc9251dh0_config, card->i2c_adapter);
- if (card->fe != NULL) {
- card->fe->ops.tuner_ops.calc_regs = advbt771_samsung_tdtc9251dh0_tuner_calc_regs;
- card->fe->ops.info.frequency_min = 174000000;
- card->fe->ops.info.frequency_max = 862000000;
- }
- break;
-
- case BTTV_BOARD_TWINHAN_DST:
- /* DST is not a frontend driver !!! */
- state = (struct dst_state *) kmalloc(sizeof (struct dst_state), GFP_KERNEL);
- /* Setup the Card */
- state->config = &dst_config;
- state->i2c = card->i2c_adapter;
- state->bt = card->bt;
-
- /* DST is not a frontend, attaching the ASIC */
- if ((dst_attach(state, &card->dvb_adapter)) == NULL) {
- printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__);
- break;
- }
- card->fe = &state->frontend;
-
- /* Attach other DST peripherals if any */
- /* Conditional Access device */
- if (state->dst_hw_cap & DST_TYPE_HAS_CA)
- ret = dst_ca_attach(state, &card->dvb_adapter);
- break;
-
- case BTTV_BOARD_PINNACLESAT:
- card->fe = cx24110_attach(&pctvsat_config, card->i2c_adapter);
- if (card->fe) {
- card->fe->ops.tuner_ops.init = pinnsat_tuner_init;
- card->fe->ops.tuner_ops.sleep = pinnsat_tuner_sleep;
- card->fe->ops.tuner_ops.set_params = cx24108_tuner_set_params;
- }
- break;
-
- case BTTV_BOARD_PC_HDTV:
- card->fe = or51211_attach(&or51211_config, card->i2c_adapter);
- break;
- }
-
- if (card->fe == NULL)
- printk("dvb-bt8xx: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
- card->bt->dev->vendor,
- card->bt->dev->device,
- card->bt->dev->subsystem_vendor,
- card->bt->dev->subsystem_device);
- else
- if (dvb_register_frontend(&card->dvb_adapter, card->fe)) {
- printk("dvb-bt8xx: Frontend registration failed!\n");
- if (card->fe->ops.release)
- card->fe->ops.release(card->fe);
- card->fe = NULL;
- }
-}
-
-static int __devinit dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type)
-{
- int result;
-
- if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE, &card->bt->dev->dev)) < 0) {
- printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result);
- return result;
- }
- card->dvb_adapter.priv = card;
-
- card->bt->adapter = card->i2c_adapter;
-
- memset(&card->demux, 0, sizeof(struct dvb_demux));
-
- card->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING;
-
- card->demux.priv = card;
- card->demux.filternum = 256;
- card->demux.feednum = 256;
- card->demux.start_feed = dvb_bt8xx_start_feed;
- card->demux.stop_feed = dvb_bt8xx_stop_feed;
- card->demux.write_to_decoder = NULL;
-
- if ((result = dvb_dmx_init(&card->demux)) < 0) {
- printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
-
- dvb_unregister_adapter(&card->dvb_adapter);
- return result;
- }
-
- card->dmxdev.filternum = 256;
- card->dmxdev.demux = &card->demux.dmx;
- card->dmxdev.capabilities = 0;
-
- if ((result = dvb_dmxdev_init(&card->dmxdev, &card->dvb_adapter)) < 0) {
- printk("dvb_bt8xx: dvb_dmxdev_init failed (errno = %d)\n", result);
-
- dvb_dmx_release(&card->demux);
- dvb_unregister_adapter(&card->dvb_adapter);
- return result;
- }
-
- card->fe_hw.source = DMX_FRONTEND_0;
-
- if ((result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_hw)) < 0) {
- printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
-
- dvb_dmxdev_release(&card->dmxdev);
- dvb_dmx_release(&card->demux);
- dvb_unregister_adapter(&card->dvb_adapter);
- return result;
- }
-
- card->fe_mem.source = DMX_MEMORY_FE;
-
- if ((result = card->demux.dmx.add_frontend(&card->demux.dmx, &card->fe_mem)) < 0) {
- printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
-
- card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
- dvb_dmxdev_release(&card->dmxdev);
- dvb_dmx_release(&card->demux);
- dvb_unregister_adapter(&card->dvb_adapter);
- return result;
- }
-
- if ((result = card->demux.dmx.connect_frontend(&card->demux.dmx, &card->fe_hw)) < 0) {
- printk("dvb_bt8xx: dvb_dmx_init failed (errno = %d)\n", result);
-
- card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem);
- card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
- dvb_dmxdev_release(&card->dmxdev);
- dvb_dmx_release(&card->demux);
- dvb_unregister_adapter(&card->dvb_adapter);
- return result;
- }
-
- dvb_net_init(&card->dvb_adapter, &card->dvbnet, &card->demux.dmx);
-
- tasklet_init(&card->bt->tasklet, dvb_bt8xx_task, (unsigned long) card);
-
- frontend_init(card, type);
-
- return 0;
-}
-
-static int __devinit dvb_bt8xx_probe(struct bttv_sub_device *sub)
-{
- struct dvb_bt8xx_card *card;
- struct pci_dev* bttv_pci_dev;
- int ret;
-
- if (!(card = kzalloc(sizeof(struct dvb_bt8xx_card), GFP_KERNEL)))
- return -ENOMEM;
-
- mutex_init(&card->lock);
- card->bttv_nr = sub->core->nr;
- strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
- card->i2c_adapter = &sub->core->i2c_adap;
-
- switch(sub->core->type) {
- case BTTV_BOARD_PINNACLESAT:
- card->gpio_mode = 0x0400c060;
- /* should be: BT878_A_GAIN=0,BT878_A_PWRDN,BT878_DA_DPM,BT878_DA_SBR,
- BT878_DA_IOM=1,BT878_DA_APP to enable serial highspeed mode. */
- card->op_sync_orin = BT878_RISC_SYNC_MASK;
- card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
- break;
-
- case BTTV_BOARD_DVICO_DVBT_LITE:
- card->gpio_mode = 0x0400C060;
- card->op_sync_orin = BT878_RISC_SYNC_MASK;
- card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
- /* 26, 15, 14, 6, 5
- * A_PWRDN DA_DPM DA_SBR DA_IOM_DA
- * DA_APP(parallel) */
- break;
-
- case BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE:
- card->gpio_mode = 0x0400c060;
- card->op_sync_orin = BT878_RISC_SYNC_MASK;
- card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
- break;
-
- case BTTV_BOARD_NEBULA_DIGITV:
- case BTTV_BOARD_AVDVBT_761:
- card->gpio_mode = (1 << 26) | (1 << 14) | (1 << 5);
- card->op_sync_orin = BT878_RISC_SYNC_MASK;
- card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
- /* A_PWRDN DA_SBR DA_APP (high speed serial) */
- break;
-
- case BTTV_BOARD_AVDVBT_771: //case 0x07711461:
- card->gpio_mode = 0x0400402B;
- card->op_sync_orin = BT878_RISC_SYNC_MASK;
- card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
- /* A_PWRDN DA_SBR DA_APP[0] PKTP=10 RISC_ENABLE FIFO_ENABLE*/
- break;
-
- case BTTV_BOARD_TWINHAN_DST:
- card->gpio_mode = 0x2204f2c;
- card->op_sync_orin = BT878_RISC_SYNC_MASK;
- card->irq_err_ignore = BT878_APABORT | BT878_ARIPERR |
- BT878_APPERR | BT878_AFBUS;
- /* 25,21,14,11,10,9,8,3,2 then
- * 0x33 = 5,4,1,0
- * A_SEL=SML, DA_MLB, DA_SBR,
- * DA_SDR=f, fifo trigger = 32 DWORDS
- * IOM = 0 == audio A/D
- * DPM = 0 == digital audio mode
- * == async data parallel port
- * then 0x33 (13 is set by start_capture)
- * DA_APP = async data parallel port,
- * ACAP_EN = 1,
- * RISC+FIFO ENABLE */
- break;
-
- case BTTV_BOARD_PC_HDTV:
- card->gpio_mode = 0x0100EC7B;
- card->op_sync_orin = BT878_RISC_SYNC_MASK;
- card->irq_err_ignore = BT878_AFBUS | BT878_AFDSR;
- break;
-
- default:
- printk(KERN_WARNING "dvb_bt8xx: Unknown bttv card type: %d.\n",
- sub->core->type);
- kfree(card);
- return -ENODEV;
- }
-
- dprintk("dvb_bt8xx: identified card%d as %s\n", card->bttv_nr, card->card_name);
-
- if (!(bttv_pci_dev = bttv_get_pcidev(card->bttv_nr))) {
- printk("dvb_bt8xx: no pci device for card %d\n", card->bttv_nr);
- kfree(card);
- return -EFAULT;
- }
-
- if (!(card->bt = dvb_bt8xx_878_match(card->bttv_nr, bttv_pci_dev))) {
- printk("dvb_bt8xx: unable to determine DMA core of card %d,\n",
- card->bttv_nr);
- printk("dvb_bt8xx: if you have the ALSA bt87x audio driver "
- "installed, try removing it.\n");
-
- kfree(card);
- return -EFAULT;
- }
-
- mutex_init(&card->bt->gpio_lock);
- card->bt->bttv_nr = sub->core->nr;
-
- if ( (ret = dvb_bt8xx_load_card(card, sub->core->type)) ) {
- kfree(card);
- return ret;
- }
-
- dev_set_drvdata(&sub->dev, card);
- return 0;
-}
-
-static void dvb_bt8xx_remove(struct bttv_sub_device *sub)
-{
- struct dvb_bt8xx_card *card = dev_get_drvdata(&sub->dev);
-
- dprintk("dvb_bt8xx: unloading card%d\n", card->bttv_nr);
-
- bt878_stop(card->bt);
- tasklet_kill(&card->bt->tasklet);
- dvb_net_release(&card->dvbnet);
- card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_mem);
- card->demux.dmx.remove_frontend(&card->demux.dmx, &card->fe_hw);
- dvb_dmxdev_release(&card->dmxdev);
- dvb_dmx_release(&card->demux);
- if (card->fe)
- dvb_unregister_frontend(card->fe);
- dvb_unregister_adapter(&card->dvb_adapter);
-
- kfree(card);
-}
-
-static struct bttv_sub_driver driver = {
- .drv = {
- .name = "dvb-bt8xx",
- },
- .probe = dvb_bt8xx_probe,
- .remove = dvb_bt8xx_remove,
- /* FIXME:
- * .shutdown = dvb_bt8xx_shutdown,
- * .suspend = dvb_bt8xx_suspend,
- * .resume = dvb_bt8xx_resume,
- */
-};
-
-static int __init dvb_bt8xx_init(void)
-{
- return bttv_sub_register(&driver, "dvb");
-}
-
-static void __exit dvb_bt8xx_exit(void)
-{
- bttv_sub_unregister(&driver);
-}
-
-module_init(dvb_bt8xx_init);
-module_exit(dvb_bt8xx_exit);
-
-MODULE_DESCRIPTION("Bt8xx based DVB adapter driver");
-MODULE_AUTHOR("Florian Schirmer <jolt@tuxbox.org>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h
deleted file mode 100644
index 4745a9017a1..00000000000
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Bt8xx based DVB adapter driver
- *
- * Copyright (C) 2002,2003 Florian Schirmer <jolt@tuxbox.org>
- * Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de>
- * Copyright (C) 1999-2001 Ralph Metzler & Marcus Metzler for convergence integrated media GmbH
- * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
- *
- * 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.
- *
- */
-
-#ifndef DVB_BT8XX_H
-#define DVB_BT8XX_H
-
-#include <linux/i2c.h>
-#include <linux/mutex.h>
-#include "dvbdev.h"
-#include "dvb_net.h"
-#include "bttv.h"
-#include "mt352.h"
-#include "sp887x.h"
-#include "dst_common.h"
-#include "nxt6000.h"
-#include "cx24110.h"
-#include "or51211.h"
-#include "lgdt330x.h"
-#include "lg_h06xf.h"
-#include "zl10353.h"
-
-struct dvb_bt8xx_card {
- struct mutex lock;
- int nfeeds;
- char card_name[32];
- struct dvb_adapter dvb_adapter;
- struct bt878 *bt;
- unsigned int bttv_nr;
- struct dvb_demux demux;
- struct dmxdev dmxdev;
- struct dmx_frontend fe_hw;
- struct dmx_frontend fe_mem;
- u32 gpio_mode;
- u32 op_sync_orin;
- u32 irq_err_ignore;
- struct i2c_adapter *i2c_adapter;
- struct dvb_net dvbnet;
-
- struct dvb_frontend* fe;
-};
-
-#endif /* DVB_BT8XX_H */
diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig
deleted file mode 100644
index b5cdd57ec6f..00000000000
--- a/drivers/media/dvb/cinergyT2/Kconfig
+++ /dev/null
@@ -1,85 +0,0 @@
-config DVB_CINERGYT2
- tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver"
- depends on DVB_CORE && USB
- help
- Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers
-
- Say Y if you own such a device and want to use it.
-
-
-config DVB_CINERGYT2_TUNING
- bool "sophisticated fine-tuning for CinergyT2 cards"
- depends on DVB_CINERGYT2
- help
- Here you can fine-tune some parameters of the CinergyT2 driver.
-
- Normally you don't need to touch this, but in exotic setups you
- may fine-tune your setup and adjust e.g. DMA buffer sizes for
- a particular application.
-
-
-config DVB_CINERGYT2_STREAM_URB_COUNT
- int "Number of queued USB Request Blocks for Highspeed Stream Transfers"
- depends on DVB_CINERGYT2_TUNING
- default "32"
- help
- USB Request Blocks for Highspeed Stream transfers are scheduled in
- a queue for the Host Controller.
-
- Usually the default value is a safe choice.
-
- You may increase this number if you are using this device in a
- Server Environment with many high-traffic USB Highspeed devices
- sharing the same USB bus.
-
-
-config DVB_CINERGYT2_STREAM_BUF_SIZE
- int "Size of URB Stream Buffers for Highspeed Transfers"
- depends on DVB_CINERGYT2_TUNING
- default "512"
- help
- Should be a multiple of native buffer size of 512 bytes.
- Default value is a safe choice.
-
- You may increase this number if you are using this device in a
- Server Environment with many high-traffic USB Highspeed devices
- sharing the same USB bus.
-
-
-config DVB_CINERGYT2_QUERY_INTERVAL
- int "Status update interval [milliseconds]"
- depends on DVB_CINERGYT2_TUNING
- default "250"
- help
- This is the interval for status readouts from the demodulator.
- You may try lower values if you need more responsive signal quality
- measurements.
-
- Please keep in mind that these updates cause traffic on the tuner
- control bus and thus may or may not affect receiption sensitivity.
-
- The default value should be a safe choice for common applications.
-
-
-config DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
- bool "Register the onboard IR Remote Control Receiver as Input Device"
- depends on DVB_CINERGYT2_TUNING
- default y
- help
- Enable this option if you want to use the onboard Infrared Remote
- Control Receiver as Linux-Input device.
-
- Right now only the keycode table for the default Remote Control
- delivered with the device is supported, please see the driver
- source code to find out how to add support for other controls.
-
-
-config DVB_CINERGYT2_RC_QUERY_INTERVAL
- int "Infrared Remote Controller update interval [milliseconds]"
- depends on DVB_CINERGYT2_TUNING && DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
- default "50"
- help
- If you have a very fast-repeating remote control you can try lower
- values, for normal consumer receivers the default value should be
- a safe choice.
-
diff --git a/drivers/media/dvb/cinergyT2/Makefile b/drivers/media/dvb/cinergyT2/Makefile
deleted file mode 100644
index c51aece20f9..00000000000
--- a/drivers/media/dvb/cinergyT2/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_DVB_CINERGYT2) += cinergyT2.o
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
deleted file mode 100644
index 410fa6d620f..00000000000
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ /dev/null
@@ -1,1056 +0,0 @@
-/*
- * TerraTec Cinergy T²/qanu USB2 DVB-T adapter.
- *
- * Copyright (C) 2004 Daniel Mack <daniel@qanu.de> and
- * Holger Waechtler <holger@qanu.de>
- *
- * Protocol Spec published on http://qanu.de/specs/terratec_cinergyT2.pdf
- *
- * 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/init.h>
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/usb.h>
-#include <linux/pci.h>
-#include <linux/input.h>
-#include <linux/dvb/frontend.h>
-#include <linux/mutex.h>
-
-#include "dmxdev.h"
-#include "dvb_demux.h"
-#include "dvb_net.h"
-
-#ifdef CONFIG_DVB_CINERGYT2_TUNING
- #define STREAM_URB_COUNT (CONFIG_DVB_CINERGYT2_STREAM_URB_COUNT)
- #define STREAM_BUF_SIZE (CONFIG_DVB_CINERGYT2_STREAM_BUF_SIZE)
- #define QUERY_INTERVAL (CONFIG_DVB_CINERGYT2_QUERY_INTERVAL)
- #ifdef CONFIG_DVB_CINERGYT2_ENABLE_RC_INPUT_DEVICE
- #define RC_QUERY_INTERVAL (CONFIG_DVB_CINERGYT2_RC_QUERY_INTERVAL)
- #define ENABLE_RC (1)
- #endif
-#else
- #define STREAM_URB_COUNT (32)
- #define STREAM_BUF_SIZE (512) /* bytes */
- #define ENABLE_RC (1)
- #define RC_QUERY_INTERVAL (50) /* milliseconds */
- #define QUERY_INTERVAL (333) /* milliseconds */
-#endif
-
-#define DRIVER_NAME "TerraTec/qanu USB2.0 Highspeed DVB-T Receiver"
-
-static int debug;
-module_param_named(debug, debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
-
-#define dprintk(level, args...) \
-do { \
- if ((debug & level)) { \
- printk("%s: %s(): ", KBUILD_MODNAME, \
- __FUNCTION__); \
- printk(args); } \
-} while (0)
-
-enum cinergyt2_ep1_cmd {
- CINERGYT2_EP1_PID_TABLE_RESET = 0x01,
- CINERGYT2_EP1_PID_SETUP = 0x02,
- CINERGYT2_EP1_CONTROL_STREAM_TRANSFER = 0x03,
- CINERGYT2_EP1_SET_TUNER_PARAMETERS = 0x04,
- CINERGYT2_EP1_GET_TUNER_STATUS = 0x05,
- CINERGYT2_EP1_START_SCAN = 0x06,
- CINERGYT2_EP1_CONTINUE_SCAN = 0x07,
- CINERGYT2_EP1_GET_RC_EVENTS = 0x08,
- CINERGYT2_EP1_SLEEP_MODE = 0x09
-};
-
-struct dvbt_set_parameters_msg {
- uint8_t cmd;
- uint32_t freq;
- uint8_t bandwidth;
- uint16_t tps;
- uint8_t flags;
-} __attribute__((packed));
-
-struct dvbt_get_status_msg {
- uint32_t freq;
- uint8_t bandwidth;
- uint16_t tps;
- uint8_t flags;
- uint16_t gain;
- uint8_t snr;
- uint32_t viterbi_error_rate;
- uint32_t rs_error_rate;
- uint32_t uncorrected_block_count;
- uint8_t lock_bits;
- uint8_t prev_lock_bits;
-} __attribute__((packed));
-
-static struct dvb_frontend_info cinergyt2_fe_info = {
- .name = DRIVER_NAME,
- .type = FE_OFDM,
- .frequency_min = 174000000,
- .frequency_max = 862000000,
- .frequency_stepsize = 166667,
- .caps = FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
- FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
- FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER | FE_CAN_MUTE_TS
-};
-
-struct cinergyt2 {
- struct dvb_demux demux;
- struct usb_device *udev;
- struct mutex sem;
- struct dvb_adapter adapter;
- struct dvb_device *fedev;
- struct dmxdev dmxdev;
- struct dvb_net dvbnet;
-
- int streaming;
- int sleeping;
-
- struct dvbt_set_parameters_msg param;
- struct dvbt_get_status_msg status;
- struct work_struct query_work;
-
- wait_queue_head_t poll_wq;
- int pending_fe_events;
- int disconnect_pending;
- atomic_t inuse;
-
- void *streambuf;
- dma_addr_t streambuf_dmahandle;
- struct urb *stream_urb [STREAM_URB_COUNT];
-
-#ifdef ENABLE_RC
- struct input_dev *rc_input_dev;
- char phys[64];
- struct work_struct rc_query_work;
- int rc_input_event;
- u32 rc_last_code;
- unsigned long last_event_jiffies;
-#endif
-};
-
-enum {
- CINERGYT2_RC_EVENT_TYPE_NONE = 0x00,
- CINERGYT2_RC_EVENT_TYPE_NEC = 0x01,
- CINERGYT2_RC_EVENT_TYPE_RC5 = 0x02
-};
-
-struct cinergyt2_rc_event {
- char type;
- uint32_t value;
-} __attribute__((packed));
-
-static const uint32_t rc_keys[] = {
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xfe01eb04, KEY_POWER,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xfd02eb04, KEY_1,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xfc03eb04, KEY_2,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xfb04eb04, KEY_3,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xfa05eb04, KEY_4,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf906eb04, KEY_5,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf807eb04, KEY_6,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf708eb04, KEY_7,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf609eb04, KEY_8,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf50aeb04, KEY_9,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf30ceb04, KEY_0,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf40beb04, KEY_VIDEO,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf20deb04, KEY_REFRESH,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf10eeb04, KEY_SELECT,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xf00feb04, KEY_EPG,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xef10eb04, KEY_UP,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xeb14eb04, KEY_DOWN,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xee11eb04, KEY_LEFT,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xec13eb04, KEY_RIGHT,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xed12eb04, KEY_OK,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xea15eb04, KEY_TEXT,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe916eb04, KEY_INFO,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe817eb04, KEY_RED,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe718eb04, KEY_GREEN,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe619eb04, KEY_YELLOW,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe51aeb04, KEY_BLUE,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe31ceb04, KEY_VOLUMEUP,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe11eeb04, KEY_VOLUMEDOWN,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe21deb04, KEY_MUTE,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe41beb04, KEY_CHANNELUP,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xe01feb04, KEY_CHANNELDOWN,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xbf40eb04, KEY_PAUSE,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xb34ceb04, KEY_PLAY,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xa758eb04, KEY_RECORD,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xab54eb04, KEY_PREVIOUS,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xb748eb04, KEY_STOP,
- CINERGYT2_RC_EVENT_TYPE_NEC, 0xa35ceb04, KEY_NEXT
-};
-
-static int cinergyt2_command (struct cinergyt2 *cinergyt2,
- char *send_buf, int send_buf_len,
- char *recv_buf, int recv_buf_len)
-{
- int actual_len;
- char dummy;
- int ret;
-
- ret = usb_bulk_msg(cinergyt2->udev, usb_sndbulkpipe(cinergyt2->udev, 1),
- send_buf, send_buf_len, &actual_len, 1000);
-
- if (ret)
- dprintk(1, "usb_bulk_msg (send) failed, err %i\n", ret);
-
- if (!recv_buf)
- recv_buf = &dummy;
-
- ret = usb_bulk_msg(cinergyt2->udev, usb_rcvbulkpipe(cinergyt2->udev, 1),
- recv_buf, recv_buf_len, &actual_len, 1000);
-
- if (ret)
- dprintk(1, "usb_bulk_msg (read) failed, err %i\n", ret);
-
- return ret ? ret : actual_len;
-}
-
-static void cinergyt2_control_stream_transfer (struct cinergyt2 *cinergyt2, int enable)
-{
- char buf [] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 };
- cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
-}
-
-static void cinergyt2_sleep (struct cinergyt2 *cinergyt2, int sleep)
-{
- char buf [] = { CINERGYT2_EP1_SLEEP_MODE, sleep ? 1 : 0 };
- cinergyt2_command(cinergyt2, buf, sizeof(buf), NULL, 0);
- cinergyt2->sleeping = sleep;
-}
-
-static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs);
-
-static int cinergyt2_submit_stream_urb (struct cinergyt2 *cinergyt2, struct urb *urb)
-{
- int err;
-
- usb_fill_bulk_urb(urb,
- cinergyt2->udev,
- usb_rcvbulkpipe(cinergyt2->udev, 0x2),
- urb->transfer_buffer,
- STREAM_BUF_SIZE,
- cinergyt2_stream_irq,
- cinergyt2);
-
- if ((err = usb_submit_urb(urb, GFP_ATOMIC)))
- dprintk(1, "urb submission failed (err = %i)!\n", err);
-
- return err;
-}
-
-static void cinergyt2_stream_irq (struct urb *urb, struct pt_regs *regs)
-{
- struct cinergyt2 *cinergyt2 = urb->context;
-
- if (urb->actual_length > 0)
- dvb_dmx_swfilter(&cinergyt2->demux,
- urb->transfer_buffer, urb->actual_length);
-
- if (cinergyt2->streaming)
- cinergyt2_submit_stream_urb(cinergyt2, urb);
-}
-
-static void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
-{
- int i;
-
- for (i=0; i<STREAM_URB_COUNT; i++)
- if (cinergyt2->stream_urb[i])
- usb_free_urb(cinergyt2->stream_urb[i]);
-
- usb_buffer_free(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
- cinergyt2->streambuf, cinergyt2->streambuf_dmahandle);
-}
-
-static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
-{
- int i;
-
- cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
- SLAB_KERNEL, &cinergyt2->streambuf_dmahandle);
- if (!cinergyt2->streambuf) {
- dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
- return -ENOMEM;
- }
-
- memset(cinergyt2->streambuf, 0, STREAM_URB_COUNT*STREAM_BUF_SIZE);
-
- for (i=0; i<STREAM_URB_COUNT; i++) {
- struct urb *urb;
-
- if (!(urb = usb_alloc_urb(0, GFP_ATOMIC))) {
- dprintk(1, "failed to alloc consistent stream urbs, bailing out!\n");
- cinergyt2_free_stream_urbs(cinergyt2);
- return -ENOMEM;
- }
-
- urb->transfer_buffer = cinergyt2->streambuf + i * STREAM_BUF_SIZE;
- urb->transfer_buffer_length = STREAM_BUF_SIZE;
-
- cinergyt2->stream_urb[i] = urb;
- }
-
- return 0;
-}
-
-static void cinergyt2_stop_stream_xfer (struct cinergyt2 *cinergyt2)
-{
- int i;
-
- cinergyt2_control_stream_transfer(cinergyt2, 0);
-
- for (i=0; i<STREAM_URB_COUNT; i++)
- if (cinergyt2->stream_urb[i])
- usb_kill_urb(cinergyt2->stream_urb[i]);
-}
-
-static int cinergyt2_start_stream_xfer (struct cinergyt2 *cinergyt2)
-{
- int i, err;
-
- for (i=0; i<STREAM_URB_COUNT; i++) {
- if ((err = cinergyt2_submit_stream_urb(cinergyt2, cinergyt2->stream_urb[i]))) {
- cinergyt2_stop_stream_xfer(cinergyt2);
- dprintk(1, "failed urb submission (%i: err = %i)!\n", i, err);
- return err;
- }
- }
-
- cinergyt2_control_stream_transfer(cinergyt2, 1);
- return 0;
-}
-
-static int cinergyt2_start_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *demux = dvbdmxfeed->demux;
- struct cinergyt2 *cinergyt2 = demux->priv;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- if (cinergyt2->streaming == 0)
- cinergyt2_start_stream_xfer(cinergyt2);
-
- cinergyt2->streaming++;
- mutex_unlock(&cinergyt2->sem);
- return 0;
-}
-
-static int cinergyt2_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *demux = dvbdmxfeed->demux;
- struct cinergyt2 *cinergyt2 = demux->priv;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- if (--cinergyt2->streaming == 0)
- cinergyt2_stop_stream_xfer(cinergyt2);
-
- mutex_unlock(&cinergyt2->sem);
- return 0;
-}
-
-/**
- * convert linux-dvb frontend parameter set into TPS.
- * See ETSI ETS-300744, section 4.6.2, table 9 for details.
- *
- * This function is probably reusable and may better get placed in a support
- * library.
- *
- * We replace errornous fields by default TPS fields (the ones with value 0).
- */
-static uint16_t compute_tps (struct dvb_frontend_parameters *p)
-{
- struct dvb_ofdm_parameters *op = &p->u.ofdm;
- uint16_t tps = 0;
-
- switch (op->code_rate_HP) {
- case FEC_2_3:
- tps |= (1 << 7);
- break;
- case FEC_3_4:
- tps |= (2 << 7);
- break;
- case FEC_5_6:
- tps |= (3 << 7);
- break;
- case FEC_7_8:
- tps |= (4 << 7);
- break;
- case FEC_1_2:
- case FEC_AUTO:
- default:
- /* tps |= (0 << 7) */;
- }
-
- switch (op->code_rate_LP) {
- case FEC_2_3:
- tps |= (1 << 4);
- break;
- case FEC_3_4:
- tps |= (2 << 4);
- break;
- case FEC_5_6:
- tps |= (3 << 4);
- break;
- case FEC_7_8:
- tps |= (4 << 4);
- break;
- case FEC_1_2:
- case FEC_AUTO:
- default:
- /* tps |= (0 << 4) */;
- }
-
- switch (op->constellation) {
- case QAM_16:
- tps |= (1 << 13);
- break;
- case QAM_64:
- tps |= (2 << 13);
- break;
- case QPSK:
- default:
- /* tps |= (0 << 13) */;
- }
-
- switch (op->transmission_mode) {
- case TRANSMISSION_MODE_8K:
- tps |= (1 << 0);
- break;
- case TRANSMISSION_MODE_2K:
- default:
- /* tps |= (0 << 0) */;
- }
-
- switch (op->guard_interval) {
- case GUARD_INTERVAL_1_16:
- tps |= (1 << 2);
- break;
- case GUARD_INTERVAL_1_8:
- tps |= (2 << 2);
- break;
- case GUARD_INTERVAL_1_4:
- tps |= (3 << 2);
- break;
- case GUARD_INTERVAL_1_32:
- default:
- /* tps |= (0 << 2) */;
- }
-
- switch (op->hierarchy_information) {
- case HIERARCHY_1:
- tps |= (1 << 10);
- break;
- case HIERARCHY_2:
- tps |= (2 << 10);
- break;
- case HIERARCHY_4:
- tps |= (3 << 10);
- break;
- case HIERARCHY_NONE:
- default:
- /* tps |= (0 << 10) */;
- }
-
- return tps;
-}
-
-static int cinergyt2_open (struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct cinergyt2 *cinergyt2 = dvbdev->priv;
- int err = -ERESTARTSYS;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- if ((err = dvb_generic_open(inode, file))) {
- mutex_unlock(&cinergyt2->sem);
- return err;
- }
-
-
- if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
- cinergyt2_sleep(cinergyt2, 0);
- schedule_delayed_work(&cinergyt2->query_work, HZ/2);
- }
-
- atomic_inc(&cinergyt2->inuse);
-
- mutex_unlock(&cinergyt2->sem);
- return 0;
-}
-
-static void cinergyt2_unregister(struct cinergyt2 *cinergyt2)
-{
- dvb_net_release(&cinergyt2->dvbnet);
- dvb_dmxdev_release(&cinergyt2->dmxdev);
- dvb_dmx_release(&cinergyt2->demux);
- dvb_unregister_device(cinergyt2->fedev);
- dvb_unregister_adapter(&cinergyt2->adapter);
-
- cinergyt2_free_stream_urbs(cinergyt2);
- kfree(cinergyt2);
-}
-
-static int cinergyt2_release (struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct cinergyt2 *cinergyt2 = dvbdev->priv;
-
- if (mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- if (!cinergyt2->disconnect_pending && (file->f_flags & O_ACCMODE) != O_RDONLY) {
- cancel_delayed_work(&cinergyt2->query_work);
- flush_scheduled_work();
- cinergyt2_sleep(cinergyt2, 1);
- }
-
- mutex_unlock(&cinergyt2->sem);
-
- if (atomic_dec_and_test(&cinergyt2->inuse) && cinergyt2->disconnect_pending) {
- warn("delayed unregister in release");
- cinergyt2_unregister(cinergyt2);
- }
-
- return dvb_generic_release(inode, file);
-}
-
-static unsigned int cinergyt2_poll (struct file *file, struct poll_table_struct *wait)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct cinergyt2 *cinergyt2 = dvbdev->priv;
- unsigned int mask = 0;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- poll_wait(file, &cinergyt2->poll_wq, wait);
-
- if (cinergyt2->pending_fe_events != 0)
- mask |= (POLLIN | POLLRDNORM | POLLPRI);
-
- mutex_unlock(&cinergyt2->sem);
-
- return mask;
-}
-
-
-static int cinergyt2_ioctl (struct inode *inode, struct file *file,
- unsigned cmd, unsigned long arg)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct cinergyt2 *cinergyt2 = dvbdev->priv;
- struct dvbt_get_status_msg *stat = &cinergyt2->status;
- fe_status_t status = 0;
-
- switch (cmd) {
- case FE_GET_INFO:
- return copy_to_user((void __user*) arg, &cinergyt2_fe_info,
- sizeof(struct dvb_frontend_info));
-
- case FE_READ_STATUS:
- if (0xffff - le16_to_cpu(stat->gain) > 30)
- status |= FE_HAS_SIGNAL;
- if (stat->lock_bits & (1 << 6))
- status |= FE_HAS_LOCK;
- if (stat->lock_bits & (1 << 5))
- status |= FE_HAS_SYNC;
- if (stat->lock_bits & (1 << 4))
- status |= FE_HAS_CARRIER;
- if (stat->lock_bits & (1 << 1))
- status |= FE_HAS_VITERBI;
-
- return copy_to_user((void __user*) arg, &status, sizeof(status));
-
- case FE_READ_BER:
- return put_user(le32_to_cpu(stat->viterbi_error_rate),
- (__u32 __user *) arg);
-
- case FE_READ_SIGNAL_STRENGTH:
- return put_user(0xffff - le16_to_cpu(stat->gain),
- (__u16 __user *) arg);
-
- case FE_READ_SNR:
- return put_user((stat->snr << 8) | stat->snr,
- (__u16 __user *) arg);
-
- case FE_READ_UNCORRECTED_BLOCKS:
- {
- uint32_t unc_count;
-
- unc_count = stat->uncorrected_block_count;
- stat->uncorrected_block_count = 0;
-
- /* UNC are already converted to host byte order... */
- return put_user(unc_count,(__u32 __user *) arg);
- }
- case FE_SET_FRONTEND:
- {
- struct dvbt_set_parameters_msg *param = &cinergyt2->param;
- struct dvb_frontend_parameters p;
- int err;
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY)
- return -EPERM;
-
- if (copy_from_user(&p, (void __user*) arg, sizeof(p)))
- return -EFAULT;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
- param->tps = cpu_to_le16(compute_tps(&p));
- param->freq = cpu_to_le32(p.frequency / 1000);
- param->bandwidth = 8 - p.u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
-
- stat->lock_bits = 0;
- cinergyt2->pending_fe_events++;
- wake_up_interruptible(&cinergyt2->poll_wq);
-
- err = cinergyt2_command(cinergyt2,
- (char *) param, sizeof(*param),
- NULL, 0);
-
- mutex_unlock(&cinergyt2->sem);
-
- return (err < 0) ? err : 0;
- }
-
- case FE_GET_FRONTEND:
- /**
- * trivial to implement (see struct dvbt_get_status_msg).
- * equivalent to FE_READ ioctls, but needs
- * TPS -> linux-dvb parameter set conversion. Feel free
- * to implement this and send us a patch if you need this
- * functionality.
- */
- break;
-
- case FE_GET_EVENT:
- {
- /**
- * for now we only fill the status field. the parameters
- * are trivial to fill as soon FE_GET_FRONTEND is done.
- */
- struct dvb_frontend_event __user *e = (void __user *) arg;
- if (cinergyt2->pending_fe_events == 0) {
- if (file->f_flags & O_NONBLOCK)
- return -EWOULDBLOCK;
- wait_event_interruptible(cinergyt2->poll_wq,
- cinergyt2->pending_fe_events > 0);
- }
- cinergyt2->pending_fe_events = 0;
- return cinergyt2_ioctl(inode, file, FE_READ_STATUS,
- (unsigned long) &e->status);
- }
-
- default:
- ;
- }
-
- return -EINVAL;
-}
-
-static int cinergyt2_mmap(struct file *file, struct vm_area_struct *vma)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct cinergyt2 *cinergyt2 = dvbdev->priv;
- int ret = 0;
-
- lock_kernel();
-
- if (vma->vm_flags & (VM_WRITE | VM_EXEC)) {
- ret = -EPERM;
- goto bailout;
- }
-
- if (vma->vm_end > vma->vm_start + STREAM_URB_COUNT * STREAM_BUF_SIZE) {
- ret = -EINVAL;
- goto bailout;
- }
-
- vma->vm_flags |= (VM_IO | VM_DONTCOPY);
- vma->vm_file = file;
-
- ret = remap_pfn_range(vma, vma->vm_start,
- virt_to_phys(cinergyt2->streambuf) >> PAGE_SHIFT,
- vma->vm_end - vma->vm_start,
- vma->vm_page_prot) ? -EAGAIN : 0;
-bailout:
- unlock_kernel();
- return ret;
-}
-
-static struct file_operations cinergyt2_fops = {
- .owner = THIS_MODULE,
- .ioctl = cinergyt2_ioctl,
- .poll = cinergyt2_poll,
- .open = cinergyt2_open,
- .release = cinergyt2_release,
- .mmap = cinergyt2_mmap
-};
-
-static struct dvb_device cinergyt2_fe_template = {
- .users = ~0,
- .writers = 1,
- .readers = (~0)-1,
- .fops = &cinergyt2_fops
-};
-
-#ifdef ENABLE_RC
-
-static void cinergyt2_query_rc (void *data)
-{
- struct cinergyt2 *cinergyt2 = data;
- char buf[1] = { CINERGYT2_EP1_GET_RC_EVENTS };
- struct cinergyt2_rc_event rc_events[12];
- int n, len, i;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return;
-
- len = cinergyt2_command(cinergyt2, buf, sizeof(buf),
- (char *) rc_events, sizeof(rc_events));
- if (len < 0)
- goto out;
- if (len == 0) {
- if (time_after(jiffies, cinergyt2->last_event_jiffies +
- msecs_to_jiffies(150))) {
- /* stop key repeat */
- if (cinergyt2->rc_input_event != KEY_MAX) {
- dprintk(1, "rc_input_event=%d Up\n", cinergyt2->rc_input_event);
- input_report_key(cinergyt2->rc_input_dev,
- cinergyt2->rc_input_event, 0);
- cinergyt2->rc_input_event = KEY_MAX;
- }
- cinergyt2->rc_last_code = ~0;
- }
- goto out;
- }
- cinergyt2->last_event_jiffies = jiffies;
-
- for (n = 0; n < (len / sizeof(rc_events[0])); n++) {
- dprintk(1, "rc_events[%d].value = %x, type=%x\n",
- n, le32_to_cpu(rc_events[n].value), rc_events[n].type);
-
- if (rc_events[n].type == CINERGYT2_RC_EVENT_TYPE_NEC &&
- rc_events[n].value == ~0) {
- /* keyrepeat bit -> just repeat last rc_input_event */
- } else {
- cinergyt2->rc_input_event = KEY_MAX;
- for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3) {
- if (rc_keys[i + 0] == rc_events[n].type &&
- rc_keys[i + 1] == le32_to_cpu(rc_events[n].value)) {
- cinergyt2->rc_input_event = rc_keys[i + 2];
- break;
- }
- }
- }
-
- if (cinergyt2->rc_input_event != KEY_MAX) {
- if (rc_events[n].value == cinergyt2->rc_last_code &&
- cinergyt2->rc_last_code != ~0) {
- /* emit a key-up so the double event is recognized */
- dprintk(1, "rc_input_event=%d UP\n", cinergyt2->rc_input_event);
- input_report_key(cinergyt2->rc_input_dev,
- cinergyt2->rc_input_event, 0);
- }
- dprintk(1, "rc_input_event=%d\n", cinergyt2->rc_input_event);
- input_report_key(cinergyt2->rc_input_dev,
- cinergyt2->rc_input_event, 1);
- cinergyt2->rc_last_code = rc_events[n].value;
- }
- }
-
-out:
- schedule_delayed_work(&cinergyt2->rc_query_work,
- msecs_to_jiffies(RC_QUERY_INTERVAL));
-
- mutex_unlock(&cinergyt2->sem);
-}
-
-static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
-{
- struct input_dev *input_dev;
- int i;
-
- cinergyt2->rc_input_dev = input_dev = input_allocate_device();
- if (!input_dev)
- return -ENOMEM;
-
- usb_make_path(cinergyt2->udev, cinergyt2->phys, sizeof(cinergyt2->phys));
- strlcat(cinergyt2->phys, "/input0", sizeof(cinergyt2->phys));
- cinergyt2->rc_input_event = KEY_MAX;
- cinergyt2->rc_last_code = ~0;
- INIT_WORK(&cinergyt2->rc_query_work, cinergyt2_query_rc, cinergyt2);
-
- input_dev->name = DRIVER_NAME " remote control";
- input_dev->phys = cinergyt2->phys;
- input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
- for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3)
- set_bit(rc_keys[i + 2], input_dev->keybit);
- input_dev->keycodesize = 0;
- input_dev->keycodemax = 0;
-
- input_register_device(cinergyt2->rc_input_dev);
- schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
-
- return 0;
-}
-
-static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2)
-{
- cancel_delayed_work(&cinergyt2->rc_query_work);
- input_unregister_device(cinergyt2->rc_input_dev);
-}
-
-static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2)
-{
- cancel_delayed_work(&cinergyt2->rc_query_work);
-}
-
-static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2)
-{
- schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
-}
-
-#else
-
-static inline int cinergyt2_register_rc(struct cinergyt2 *cinergyt2) { return 0; }
-static inline void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2) { }
-static inline void cinergyt2_suspend_rc(struct cinergyt2 *cinergyt2) { }
-static inline void cinergyt2_resume_rc(struct cinergyt2 *cinergyt2) { }
-
-#endif /* ENABLE_RC */
-
-static void cinergyt2_query (void *data)
-{
- struct cinergyt2 *cinergyt2 = (struct cinergyt2 *) data;
- char cmd [] = { CINERGYT2_EP1_GET_TUNER_STATUS };
- struct dvbt_get_status_msg *s = &cinergyt2->status;
- uint8_t lock_bits;
- uint32_t unc;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return;
-
- unc = s->uncorrected_block_count;
- lock_bits = s->lock_bits;
-
- cinergyt2_command(cinergyt2, cmd, sizeof(cmd), (char *) s, sizeof(*s));
-
- unc += le32_to_cpu(s->uncorrected_block_count);
- s->uncorrected_block_count = unc;
-
- if (lock_bits != s->lock_bits) {
- wake_up_interruptible(&cinergyt2->poll_wq);
- cinergyt2->pending_fe_events++;
- }
-
- schedule_delayed_work(&cinergyt2->query_work,
- msecs_to_jiffies(QUERY_INTERVAL));
-
- mutex_unlock(&cinergyt2->sem);
-}
-
-static int cinergyt2_probe (struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct cinergyt2 *cinergyt2;
- int err;
-
- if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) {
- dprintk(1, "out of memory?!?\n");
- return -ENOMEM;
- }
-
- memset (cinergyt2, 0, sizeof (struct cinergyt2));
- usb_set_intfdata (intf, (void *) cinergyt2);
-
- mutex_init(&cinergyt2->sem);
- init_waitqueue_head (&cinergyt2->poll_wq);
- INIT_WORK(&cinergyt2->query_work, cinergyt2_query, cinergyt2);
-
- cinergyt2->udev = interface_to_usbdev(intf);
- cinergyt2->param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS;
-
- if (cinergyt2_alloc_stream_urbs (cinergyt2) < 0) {
- dprintk(1, "unable to allocate stream urbs\n");
- kfree(cinergyt2);
- return -ENOMEM;
- }
-
- if ((err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE, &cinergyt2->udev->dev)) < 0) {
- kfree(cinergyt2);
- return err;
- }
-
- cinergyt2->demux.priv = cinergyt2;
- cinergyt2->demux.filternum = 256;
- cinergyt2->demux.feednum = 256;
- cinergyt2->demux.start_feed = cinergyt2_start_feed;
- cinergyt2->demux.stop_feed = cinergyt2_stop_feed;
- cinergyt2->demux.dmx.capabilities = DMX_TS_FILTERING |
- DMX_SECTION_FILTERING |
- DMX_MEMORY_BASED_FILTERING;
-
- if ((err = dvb_dmx_init(&cinergyt2->demux)) < 0) {
- dprintk(1, "dvb_dmx_init() failed (err = %d)\n", err);
- goto bailout;
- }
-
- cinergyt2->dmxdev.filternum = cinergyt2->demux.filternum;
- cinergyt2->dmxdev.demux = &cinergyt2->demux.dmx;
- cinergyt2->dmxdev.capabilities = 0;
-
- if ((err = dvb_dmxdev_init(&cinergyt2->dmxdev, &cinergyt2->adapter)) < 0) {
- dprintk(1, "dvb_dmxdev_init() failed (err = %d)\n", err);
- goto bailout;
- }
-
- if (dvb_net_init(&cinergyt2->adapter, &cinergyt2->dvbnet, &cinergyt2->demux.dmx))
- dprintk(1, "dvb_net_init() failed!\n");
-
- dvb_register_device(&cinergyt2->adapter, &cinergyt2->fedev,
- &cinergyt2_fe_template, cinergyt2,
- DVB_DEVICE_FRONTEND);
-
- err = cinergyt2_register_rc(cinergyt2);
- if (err)
- goto bailout;
-
- return 0;
-
-bailout:
- dvb_net_release(&cinergyt2->dvbnet);
- dvb_dmxdev_release(&cinergyt2->dmxdev);
- dvb_dmx_release(&cinergyt2->demux);
- dvb_unregister_adapter(&cinergyt2->adapter);
- cinergyt2_free_stream_urbs(cinergyt2);
- kfree(cinergyt2);
- return -ENOMEM;
-}
-
-static void cinergyt2_disconnect (struct usb_interface *intf)
-{
- struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
-
- flush_scheduled_work();
-
- cinergyt2_unregister_rc(cinergyt2);
-
- cancel_delayed_work(&cinergyt2->query_work);
- wake_up_interruptible(&cinergyt2->poll_wq);
-
- cinergyt2->demux.dmx.close(&cinergyt2->demux.dmx);
- cinergyt2->disconnect_pending = 1;
-
- if (!atomic_read(&cinergyt2->inuse))
- cinergyt2_unregister(cinergyt2);
-}
-
-static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
-{
- struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- if (1) {
- struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
-
- cinergyt2_suspend_rc(cinergyt2);
- cancel_delayed_work(&cinergyt2->query_work);
- if (cinergyt2->streaming)
- cinergyt2_stop_stream_xfer(cinergyt2);
- flush_scheduled_work();
- cinergyt2_sleep(cinergyt2, 1);
- }
-
- mutex_unlock(&cinergyt2->sem);
- return 0;
-}
-
-static int cinergyt2_resume (struct usb_interface *intf)
-{
- struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
- struct dvbt_set_parameters_msg *param = &cinergyt2->param;
-
- if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
- return -ERESTARTSYS;
-
- if (!cinergyt2->sleeping) {
- cinergyt2_sleep(cinergyt2, 0);
- cinergyt2_command(cinergyt2, (char *) param, sizeof(*param), NULL, 0);
- if (cinergyt2->streaming)
- cinergyt2_start_stream_xfer(cinergyt2);
- schedule_delayed_work(&cinergyt2->query_work, HZ/2);
- }
-
- cinergyt2_resume_rc(cinergyt2);
-
- mutex_unlock(&cinergyt2->sem);
- return 0;
-}
-
-static const struct usb_device_id cinergyt2_table [] __devinitdata = {
- { USB_DEVICE(0x0ccd, 0x0038) },
- { 0 }
-};
-
-MODULE_DEVICE_TABLE(usb, cinergyt2_table);
-
-static struct usb_driver cinergyt2_driver = {
- .name = "cinergyT2",
- .probe = cinergyt2_probe,
- .disconnect = cinergyt2_disconnect,
- .suspend = cinergyt2_suspend,
- .resume = cinergyt2_resume,
- .id_table = cinergyt2_table
-};
-
-static int __init cinergyt2_init (void)
-{
- int err;
-
- if ((err = usb_register(&cinergyt2_driver)) < 0)
- dprintk(1, "usb_register() failed! (err %i)\n", err);
-
- return err;
-}
-
-static void __exit cinergyt2_exit (void)
-{
- usb_deregister(&cinergyt2_driver);
-}
-
-module_init (cinergyt2_init);
-module_exit (cinergyt2_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Holger Waechtler, Daniel Mack");
diff --git a/drivers/media/dvb/dvb-core/Kconfig b/drivers/media/dvb/dvb-core/Kconfig
deleted file mode 100644
index 12ee912a570..00000000000
--- a/drivers/media/dvb/dvb-core/Kconfig
+++ /dev/null
@@ -1,11 +0,0 @@
-config DVB_CORE
- tristate "DVB Core Support"
- depends on DVB
- select CRC32
- help
- DVB core utility functions for device handling, software fallbacks etc.
- Say Y when you have a DVB card and want to use it. Say Y if your want
- to build your drivers outside the kernel, but need the DVB core. All
- in-kernel drivers will select this automatically if needed.
- If unsure say N.
-
diff --git a/drivers/media/dvb/dvb-core/Makefile b/drivers/media/dvb/dvb-core/Makefile
deleted file mode 100644
index 0b5182835cc..00000000000
--- a/drivers/media/dvb/dvb-core/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile for the kernel DVB device drivers.
-#
-
-dvb-core-objs := dvbdev.o dmxdev.o dvb_demux.o dvb_filter.o \
- dvb_ca_en50221.o dvb_frontend.o \
- dvb_net.o dvb_ringbuffer.o dvb_math.o
-
-obj-$(CONFIG_DVB_CORE) += dvb-core.o
diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h
deleted file mode 100644
index 0c1d87c5227..00000000000
--- a/drivers/media/dvb/dvb-core/demux.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * demux.h
- *
- * Copyright (c) 2002 Convergence GmbH
- *
- * based on code:
- * Copyright (c) 2000 Nokia Research Center
- * Tampere, FINLAND
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef __DEMUX_H
-#define __DEMUX_H
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/list.h>
-#include <linux/time.h>
-#include <linux/dvb/dmx.h>
-
-/*--------------------------------------------------------------------------*/
-/* Common definitions */
-/*--------------------------------------------------------------------------*/
-
-/*
- * DMX_MAX_FILTER_SIZE: Maximum length (in bytes) of a section/PES filter.
- */
-
-#ifndef DMX_MAX_FILTER_SIZE
-#define DMX_MAX_FILTER_SIZE 18
-#endif
-
-/*
- * DMX_MAX_SECFEED_SIZE: Maximum length (in bytes) of a private section feed filter.
- */
-
-#ifndef DMX_MAX_SECTION_SIZE
-#define DMX_MAX_SECTION_SIZE 4096
-#endif
-#ifndef DMX_MAX_SECFEED_SIZE
-#define DMX_MAX_SECFEED_SIZE (DMX_MAX_SECTION_SIZE + 188)
-#endif
-
-
-/*
- * enum dmx_success: Success codes for the Demux Callback API.
- */
-
-enum dmx_success {
- DMX_OK = 0, /* Received Ok */
- DMX_LENGTH_ERROR, /* Incorrect length */
- DMX_OVERRUN_ERROR, /* Receiver ring buffer overrun */
- DMX_CRC_ERROR, /* Incorrect CRC */
- DMX_FRAME_ERROR, /* Frame alignment error */
- DMX_FIFO_ERROR, /* Receiver FIFO overrun */
- DMX_MISSED_ERROR /* Receiver missed packet */
-} ;
-
-/*--------------------------------------------------------------------------*/
-/* TS packet reception */
-/*--------------------------------------------------------------------------*/
-
-/* TS filter type for set() */
-
-#define TS_PACKET 1 /* send TS packets (188 bytes) to callback (default) */
-#define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS
- payload (<=184 bytes per packet) to callback */
-#define TS_DECODER 4 /* send stream to built-in decoder (if present) */
-
-/* PES type for filters which write to built-in decoder */
-/* these should be kept identical to the types in dmx.h */
-
-enum dmx_ts_pes
-{ /* also send packets to decoder (if it exists) */
- DMX_TS_PES_AUDIO0,
- DMX_TS_PES_VIDEO0,
- DMX_TS_PES_TELETEXT0,
- DMX_TS_PES_SUBTITLE0,
- DMX_TS_PES_PCR0,
-
- DMX_TS_PES_AUDIO1,
- DMX_TS_PES_VIDEO1,
- DMX_TS_PES_TELETEXT1,
- DMX_TS_PES_SUBTITLE1,
- DMX_TS_PES_PCR1,
-
- DMX_TS_PES_AUDIO2,
- DMX_TS_PES_VIDEO2,
- DMX_TS_PES_TELETEXT2,
- DMX_TS_PES_SUBTITLE2,
- DMX_TS_PES_PCR2,
-
- DMX_TS_PES_AUDIO3,
- DMX_TS_PES_VIDEO3,
- DMX_TS_PES_TELETEXT3,
- DMX_TS_PES_SUBTITLE3,
- DMX_TS_PES_PCR3,
-
- DMX_TS_PES_OTHER
-};
-
-#define DMX_TS_PES_AUDIO DMX_TS_PES_AUDIO0
-#define DMX_TS_PES_VIDEO DMX_TS_PES_VIDEO0
-#define DMX_TS_PES_TELETEXT DMX_TS_PES_TELETEXT0
-#define DMX_TS_PES_SUBTITLE DMX_TS_PES_SUBTITLE0
-#define DMX_TS_PES_PCR DMX_TS_PES_PCR0
-
-
-struct dmx_ts_feed {
- int is_filtering; /* Set to non-zero when filtering in progress */
- struct dmx_demux *parent; /* Back-pointer */
- void *priv; /* Pointer to private data of the API client */
- int (*set) (struct dmx_ts_feed *feed,
- u16 pid,
- int type,
- enum dmx_ts_pes pes_type,
- size_t circular_buffer_size,
- struct timespec timeout);
- int (*start_filtering) (struct dmx_ts_feed* feed);
- int (*stop_filtering) (struct dmx_ts_feed* feed);
-};
-
-/*--------------------------------------------------------------------------*/
-/* Section reception */
-/*--------------------------------------------------------------------------*/
-
-struct dmx_section_filter {
- u8 filter_value [DMX_MAX_FILTER_SIZE];
- u8 filter_mask [DMX_MAX_FILTER_SIZE];
- u8 filter_mode [DMX_MAX_FILTER_SIZE];
- struct dmx_section_feed* parent; /* Back-pointer */
- void* priv; /* Pointer to private data of the API client */
-};
-
-struct dmx_section_feed {
- int is_filtering; /* Set to non-zero when filtering in progress */
- struct dmx_demux* parent; /* Back-pointer */
- void* priv; /* Pointer to private data of the API client */
-
- int check_crc;
- u32 crc_val;
-
- u8 *secbuf;
- u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
- u16 secbufp, seclen, tsfeedp;
-
- int (*set) (struct dmx_section_feed* feed,
- u16 pid,
- size_t circular_buffer_size,
- int check_crc);
- int (*allocate_filter) (struct dmx_section_feed* feed,
- struct dmx_section_filter** filter);
- int (*release_filter) (struct dmx_section_feed* feed,
- struct dmx_section_filter* filter);
- int (*start_filtering) (struct dmx_section_feed* feed);
- int (*stop_filtering) (struct dmx_section_feed* feed);
-};
-
-/*--------------------------------------------------------------------------*/
-/* Callback functions */
-/*--------------------------------------------------------------------------*/
-
-typedef int (*dmx_ts_cb) ( const u8 * buffer1,
- size_t buffer1_length,
- const u8 * buffer2,
- size_t buffer2_length,
- struct dmx_ts_feed* source,
- enum dmx_success success);
-
-typedef int (*dmx_section_cb) ( const u8 * buffer1,
- size_t buffer1_len,
- const u8 * buffer2,
- size_t buffer2_len,
- struct dmx_section_filter * source,
- enum dmx_success success);
-
-/*--------------------------------------------------------------------------*/
-/* DVB Front-End */
-/*--------------------------------------------------------------------------*/
-
-enum dmx_frontend_source {
- DMX_MEMORY_FE,
- DMX_FRONTEND_0,
- DMX_FRONTEND_1,
- DMX_FRONTEND_2,
- DMX_FRONTEND_3,
- DMX_STREAM_0, /* external stream input, e.g. LVDS */
- DMX_STREAM_1,
- DMX_STREAM_2,
- DMX_STREAM_3
-};
-
-struct dmx_frontend {
- struct list_head connectivity_list; /* List of front-ends that can
- be connected to a particular
- demux */
- enum dmx_frontend_source source;
-};
-
-/*--------------------------------------------------------------------------*/
-/* MPEG-2 TS Demux */
-/*--------------------------------------------------------------------------*/
-
-/*
- * Flags OR'ed in the capabilities field of struct dmx_demux.
- */
-
-#define DMX_TS_FILTERING 1
-#define DMX_PES_FILTERING 2
-#define DMX_SECTION_FILTERING 4
-#define DMX_MEMORY_BASED_FILTERING 8 /* write() available */
-#define DMX_CRC_CHECKING 16
-#define DMX_TS_DESCRAMBLING 32
-
-/*
- * Demux resource type identifier.
-*/
-
-/*
- * DMX_FE_ENTRY(): Casts elements in the list of registered
- * front-ends from the generic type struct list_head
- * to the type * struct dmx_frontend
- *.
-*/
-
-#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)
-
-struct dmx_demux {
- u32 capabilities; /* Bitfield of capability flags */
- struct dmx_frontend* frontend; /* Front-end connected to the demux */
- void* priv; /* Pointer to private data of the API client */
- int (*open) (struct dmx_demux* demux);
- int (*close) (struct dmx_demux* demux);
- int (*write) (struct dmx_demux* demux, const char* buf, size_t count);
- int (*allocate_ts_feed) (struct dmx_demux* demux,
- struct dmx_ts_feed** feed,
- dmx_ts_cb callback);
- int (*release_ts_feed) (struct dmx_demux* demux,
- struct dmx_ts_feed* feed);
- int (*allocate_section_feed) (struct dmx_demux* demux,
- struct dmx_section_feed** feed,
- dmx_section_cb callback);
- int (*release_section_feed) (struct dmx_demux* demux,
- struct dmx_section_feed* feed);
- int (*add_frontend) (struct dmx_demux* demux,
- struct dmx_frontend* frontend);
- int (*remove_frontend) (struct dmx_demux* demux,
- struct dmx_frontend* frontend);
- struct list_head* (*get_frontends) (struct dmx_demux* demux);
- int (*connect_frontend) (struct dmx_demux* demux,
- struct dmx_frontend* frontend);
- int (*disconnect_frontend) (struct dmx_demux* demux);
-
- int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
-
- int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
-
- int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
-
- int (*get_stc) (struct dmx_demux* demux, unsigned int num,
- u64 *stc, unsigned int *base);
-};
-
-#endif /* #ifndef __DEMUX_H */
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
deleted file mode 100644
index 988499dfddf..00000000000
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ /dev/null
@@ -1,1082 +0,0 @@
-/*
- * dmxdev.c - DVB demultiplexer device
- *
- * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
- * for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/sched.h>
-#include <linux/poll.h>
-#include <linux/ioctl.h>
-#include <linux/wait.h>
-#include <asm/uaccess.h>
-#include <asm/system.h>
-#include "dmxdev.h"
-
-static int debug;
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
-
-#define dprintk if (debug) printk
-
-static int dvb_dmxdev_buffer_write(struct dvb_ringbuffer *buf,
- const u8 *src, size_t len)
-{
- ssize_t free;
-
- if (!len)
- return 0;
- if (!buf->data)
- return 0;
-
- free = dvb_ringbuffer_free(buf);
- if (len > free) {
- dprintk("dmxdev: buffer overflow\n");
- return -EOVERFLOW;
- }
-
- return dvb_ringbuffer_write(buf, src, len);
-}
-
-static ssize_t dvb_dmxdev_buffer_read(struct dvb_ringbuffer *src,
- int non_blocking, char __user *buf,
- size_t count, loff_t *ppos)
-{
- size_t todo;
- ssize_t avail;
- ssize_t ret = 0;
-
- if (!src->data)
- return 0;
-
- if (src->error) {
- ret = src->error;
- dvb_ringbuffer_flush(src);
- return ret;
- }
-
- for (todo = count; todo > 0; todo -= ret) {
- if (non_blocking && dvb_ringbuffer_empty(src)) {
- ret = -EWOULDBLOCK;
- break;
- }
-
- ret = wait_event_interruptible(src->queue,
- !dvb_ringbuffer_empty(src) ||
- (src->error != 0));
- if (ret < 0)
- break;
-
- if (src->error) {
- ret = src->error;
- dvb_ringbuffer_flush(src);
- break;
- }
-
- avail = dvb_ringbuffer_avail(src);
- if (avail > todo)
- avail = todo;
-
- ret = dvb_ringbuffer_read(src, buf, avail, 1);
- if (ret < 0)
- break;
-
- buf += ret;
- }
-
- return (count - todo) ? (count - todo) : ret;
-}
-
-static struct dmx_frontend *get_fe(struct dmx_demux *demux, int type)
-{
- struct list_head *head, *pos;
-
- head = demux->get_frontends(demux);
- if (!head)
- return NULL;
- list_for_each(pos, head)
- if (DMX_FE_ENTRY(pos)->source == type)
- return DMX_FE_ENTRY(pos);
-
- return NULL;
-}
-
-static int dvb_dvr_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dmxdev *dmxdev = dvbdev->priv;
- struct dmx_frontend *front;
-
- dprintk("function : %s\n", __FUNCTION__);
-
- if (mutex_lock_interruptible(&dmxdev->mutex))
- return -ERESTARTSYS;
-
- if ((file->f_flags & O_ACCMODE) == O_RDWR) {
- if (!(dmxdev->capabilities & DMXDEV_CAP_DUPLEX)) {
- mutex_unlock(&dmxdev->mutex);
- return -EOPNOTSUPP;
- }
- }
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
- void *mem;
- if (!dvbdev->readers) {
- mutex_unlock(&dmxdev->mutex);
- return -EBUSY;
- }
- mem = vmalloc(DVR_BUFFER_SIZE);
- if (!mem) {
- mutex_unlock(&dmxdev->mutex);
- return -ENOMEM;
- }
- dvb_ringbuffer_init(&dmxdev->dvr_buffer, mem, DVR_BUFFER_SIZE);
- dvbdev->readers--;
- }
-
- if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
- dmxdev->dvr_orig_fe = dmxdev->demux->frontend;
-
- if (!dmxdev->demux->write) {
- mutex_unlock(&dmxdev->mutex);
- return -EOPNOTSUPP;
- }
-
- front = get_fe(dmxdev->demux, DMX_MEMORY_FE);
-
- if (!front) {
- mutex_unlock(&dmxdev->mutex);
- return -EINVAL;
- }
- dmxdev->demux->disconnect_frontend(dmxdev->demux);
- dmxdev->demux->connect_frontend(dmxdev->demux, front);
- }
- mutex_unlock(&dmxdev->mutex);
- return 0;
-}
-
-static int dvb_dvr_release(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dmxdev *dmxdev = dvbdev->priv;
-
- if (mutex_lock_interruptible(&dmxdev->mutex))
- return -ERESTARTSYS;
-
- if ((file->f_flags & O_ACCMODE) == O_WRONLY) {
- dmxdev->demux->disconnect_frontend(dmxdev->demux);
- dmxdev->demux->connect_frontend(dmxdev->demux,
- dmxdev->dvr_orig_fe);
- }
- if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
- dvbdev->readers++;
- if (dmxdev->dvr_buffer.data) {
- void *mem = dmxdev->dvr_buffer.data;
- mb();
- spin_lock_irq(&dmxdev->lock);
- dmxdev->dvr_buffer.data = NULL;
- spin_unlock_irq(&dmxdev->lock);
- vfree(mem);
- }
- }
- mutex_unlock(&dmxdev->mutex);
- return 0;
-}
-
-static ssize_t dvb_dvr_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dmxdev *dmxdev = dvbdev->priv;
- int ret;
-
- if (!dmxdev->demux->write)
- return -EOPNOTSUPP;
- if ((file->f_flags & O_ACCMODE) != O_WRONLY)
- return -EINVAL;
- if (mutex_lock_interruptible(&dmxdev->mutex))
- return -ERESTARTSYS;
- ret = dmxdev->demux->write(dmxdev->demux, buf, count);
- mutex_unlock(&dmxdev->mutex);
- return ret;
-}
-
-static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count,
- loff_t *ppos)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dmxdev *dmxdev = dvbdev->priv;
- int ret;
-
- //mutex_lock(&dmxdev->mutex);
- ret = dvb_dmxdev_buffer_read(&dmxdev->dvr_buffer,
- file->f_flags & O_NONBLOCK,
- buf, count, ppos);
- //mutex_unlock(&dmxdev->mutex);
- return ret;
-}
-
-static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter
- *dmxdevfilter, int state)
-{
- spin_lock_irq(&dmxdevfilter->dev->lock);
- dmxdevfilter->state = state;
- spin_unlock_irq(&dmxdevfilter->dev->lock);
-}
-
-static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter,
- unsigned long size)
-{
- struct dvb_ringbuffer *buf = &dmxdevfilter->buffer;
- void *mem;
-
- if (buf->size == size)
- return 0;
- if (dmxdevfilter->state >= DMXDEV_STATE_GO)
- return -EBUSY;
- spin_lock_irq(&dmxdevfilter->dev->lock);
- mem = buf->data;
- buf->data = NULL;
- buf->size = size;
- dvb_ringbuffer_flush(buf);
- spin_unlock_irq(&dmxdevfilter->dev->lock);
- vfree(mem);
-
- if (buf->size) {
- mem = vmalloc(dmxdevfilter->buffer.size);
- if (!mem)
- return -ENOMEM;
- spin_lock_irq(&dmxdevfilter->dev->lock);
- buf->data = mem;
- spin_unlock_irq(&dmxdevfilter->dev->lock);
- }
- return 0;
-}
-
-static void dvb_dmxdev_filter_timeout(unsigned long data)
-{
- struct dmxdev_filter *dmxdevfilter = (struct dmxdev_filter *)data;
-
- dmxdevfilter->buffer.error = -ETIMEDOUT;
- spin_lock_irq(&dmxdevfilter->dev->lock);
- dmxdevfilter->state = DMXDEV_STATE_TIMEDOUT;
- spin_unlock_irq(&dmxdevfilter->dev->lock);
- wake_up(&dmxdevfilter->buffer.queue);
-}
-
-static void dvb_dmxdev_filter_timer(struct dmxdev_filter *dmxdevfilter)
-{
- struct dmx_sct_filter_params *para = &dmxdevfilter->params.sec;
-
- del_timer(&dmxdevfilter->timer);
- if (para->timeout) {
- dmxdevfilter->timer.function = dvb_dmxdev_filter_timeout;
- dmxdevfilter->timer.data = (unsigned long)dmxdevfilter;
- dmxdevfilter->timer.expires =
- jiffies + 1 + (HZ / 2 + HZ * para->timeout) / 1000;
- add_timer(&dmxdevfilter->timer);
- }
-}
-
-static int dvb_dmxdev_section_callback(const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_section_filter *filter,
- enum dmx_success success)
-{
- struct dmxdev_filter *dmxdevfilter = filter->priv;
- int ret;
-
- if (dmxdevfilter->buffer.error) {
- wake_up(&dmxdevfilter->buffer.queue);
- return 0;
- }
- spin_lock(&dmxdevfilter->dev->lock);
- if (dmxdevfilter->state != DMXDEV_STATE_GO) {
- spin_unlock(&dmxdevfilter->dev->lock);
- return 0;
- }
- del_timer(&dmxdevfilter->timer);
- dprintk("dmxdev: section callback %02x %02x %02x %02x %02x %02x\n",
- buffer1[0], buffer1[1],
- buffer1[2], buffer1[3], buffer1[4], buffer1[5]);
- ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer1,
- buffer1_len);
- if (ret == buffer1_len) {
- ret = dvb_dmxdev_buffer_write(&dmxdevfilter->buffer, buffer2,
- buffer2_len);
- }
- if (ret < 0) {
- dvb_ringbuffer_flush(&dmxdevfilter->buffer);
- dmxdevfilter->buffer.error = ret;
- }
- if (dmxdevfilter->params.sec.flags & DMX_ONESHOT)
- dmxdevfilter->state = DMXDEV_STATE_DONE;
- spin_unlock(&dmxdevfilter->dev->lock);
- wake_up(&dmxdevfilter->buffer.queue);
- return 0;
-}
-
-static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_ts_feed *feed,
- enum dmx_success success)
-{
- struct dmxdev_filter *dmxdevfilter = feed->priv;
- struct dvb_ringbuffer *buffer;
- int ret;
-
- spin_lock(&dmxdevfilter->dev->lock);
- if (dmxdevfilter->params.pes.output == DMX_OUT_DECODER) {
- spin_unlock(&dmxdevfilter->dev->lock);
- return 0;
- }
-
- if (dmxdevfilter->params.pes.output == DMX_OUT_TAP)
- buffer = &dmxdevfilter->buffer;
- else
- buffer = &dmxdevfilter->dev->dvr_buffer;
- if (buffer->error) {
- spin_unlock(&dmxdevfilter->dev->lock);
- wake_up(&buffer->queue);
- return 0;
- }
- ret = dvb_dmxdev_buffer_write(buffer, buffer1, buffer1_len);
- if (ret == buffer1_len)
- ret = dvb_dmxdev_buffer_write(buffer, buffer2, buffer2_len);
- if (ret < 0) {
- dvb_ringbuffer_flush(buffer);
- buffer->error = ret;
- }
- spin_unlock(&dmxdevfilter->dev->lock);
- wake_up(&buffer->queue);
- return 0;
-}
-
-/* stop feed but only mark the specified filter as stopped (state set) */
-static int dvb_dmxdev_feed_stop(struct dmxdev_filter *dmxdevfilter)
-{
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
-
- switch (dmxdevfilter->type) {
- case DMXDEV_TYPE_SEC:
- del_timer(&dmxdevfilter->timer);
- dmxdevfilter->feed.sec->stop_filtering(dmxdevfilter->feed.sec);
- break;
- case DMXDEV_TYPE_PES:
- dmxdevfilter->feed.ts->stop_filtering(dmxdevfilter->feed.ts);
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-/* start feed associated with the specified filter */
-static int dvb_dmxdev_feed_start(struct dmxdev_filter *filter)
-{
- dvb_dmxdev_filter_state_set(filter, DMXDEV_STATE_GO);
-
- switch (filter->type) {
- case DMXDEV_TYPE_SEC:
- return filter->feed.sec->start_filtering(filter->feed.sec);
- case DMXDEV_TYPE_PES:
- return filter->feed.ts->start_filtering(filter->feed.ts);
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-/* restart section feed if it has filters left associated with it,
- otherwise release the feed */
-static int dvb_dmxdev_feed_restart(struct dmxdev_filter *filter)
-{
- int i;
- struct dmxdev *dmxdev = filter->dev;
- u16 pid = filter->params.sec.pid;
-
- for (i = 0; i < dmxdev->filternum; i++)
- if (dmxdev->filter[i].state >= DMXDEV_STATE_GO &&
- dmxdev->filter[i].type == DMXDEV_TYPE_SEC &&
- dmxdev->filter[i].params.sec.pid == pid) {
- dvb_dmxdev_feed_start(&dmxdev->filter[i]);
- return 0;
- }
-
- filter->dev->demux->release_section_feed(dmxdev->demux,
- filter->feed.sec);
-
- return 0;
-}
-
-static int dvb_dmxdev_filter_stop(struct dmxdev_filter *dmxdevfilter)
-{
- if (dmxdevfilter->state < DMXDEV_STATE_GO)
- return 0;
-
- switch (dmxdevfilter->type) {
- case DMXDEV_TYPE_SEC:
- if (!dmxdevfilter->feed.sec)
- break;
- dvb_dmxdev_feed_stop(dmxdevfilter);
- if (dmxdevfilter->filter.sec)
- dmxdevfilter->feed.sec->
- release_filter(dmxdevfilter->feed.sec,
- dmxdevfilter->filter.sec);
- dvb_dmxdev_feed_restart(dmxdevfilter);
- dmxdevfilter->feed.sec = NULL;
- break;
- case DMXDEV_TYPE_PES:
- if (!dmxdevfilter->feed.ts)
- break;
- dvb_dmxdev_feed_stop(dmxdevfilter);
- dmxdevfilter->dev->demux->
- release_ts_feed(dmxdevfilter->dev->demux,
- dmxdevfilter->feed.ts);
- dmxdevfilter->feed.ts = NULL;
- break;
- default:
- if (dmxdevfilter->state == DMXDEV_STATE_ALLOCATED)
- return 0;
- return -EINVAL;
- }
-
- dvb_ringbuffer_flush(&dmxdevfilter->buffer);
- return 0;
-}
-
-static inline int dvb_dmxdev_filter_reset(struct dmxdev_filter *dmxdevfilter)
-{
- if (dmxdevfilter->state < DMXDEV_STATE_SET)
- return 0;
-
- dmxdevfilter->type = DMXDEV_TYPE_NONE;
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
- return 0;
-}
-
-static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter)
-{
- struct dmxdev *dmxdev = filter->dev;
- void *mem;
- int ret, i;
-
- if (filter->state < DMXDEV_STATE_SET)
- return -EINVAL;
-
- if (filter->state >= DMXDEV_STATE_GO)
- dvb_dmxdev_filter_stop(filter);
-
- if (!filter->buffer.data) {
- mem = vmalloc(filter->buffer.size);
- if (!mem)
- return -ENOMEM;
- spin_lock_irq(&filter->dev->lock);
- filter->buffer.data = mem;
- spin_unlock_irq(&filter->dev->lock);
- }
-
- dvb_ringbuffer_flush(&filter->buffer);
-
- switch (filter->type) {
- case DMXDEV_TYPE_SEC:
- {
- struct dmx_sct_filter_params *para = &filter->params.sec;
- struct dmx_section_filter **secfilter = &filter->filter.sec;
- struct dmx_section_feed **secfeed = &filter->feed.sec;
-
- *secfilter = NULL;
- *secfeed = NULL;
-
-
- /* find active filter/feed with same PID */
- for (i = 0; i < dmxdev->filternum; i++) {
- if (dmxdev->filter[i].state >= DMXDEV_STATE_GO &&
- dmxdev->filter[i].type == DMXDEV_TYPE_SEC &&
- dmxdev->filter[i].params.sec.pid == para->pid) {
- *secfeed = dmxdev->filter[i].feed.sec;
- break;
- }
- }
-
- /* if no feed found, try to allocate new one */
- if (!*secfeed) {
- ret = dmxdev->demux->allocate_section_feed(dmxdev->demux,
- secfeed,
- dvb_dmxdev_section_callback);
- if (ret < 0) {
- printk("DVB (%s): could not alloc feed\n",
- __FUNCTION__);
- return ret;
- }
-
- ret = (*secfeed)->set(*secfeed, para->pid, 32768,
- (para->flags & DMX_CHECK_CRC) ? 1 : 0);
- if (ret < 0) {
- printk("DVB (%s): could not set feed\n",
- __FUNCTION__);
- dvb_dmxdev_feed_restart(filter);
- return ret;
- }
- } else {
- dvb_dmxdev_feed_stop(filter);
- }
-
- ret = (*secfeed)->allocate_filter(*secfeed, secfilter);
- if (ret < 0) {
- dvb_dmxdev_feed_restart(filter);
- filter->feed.sec->start_filtering(*secfeed);
- dprintk("could not get filter\n");
- return ret;
- }
-
- (*secfilter)->priv = filter;
-
- memcpy(&((*secfilter)->filter_value[3]),
- &(para->filter.filter[1]), DMX_FILTER_SIZE - 1);
- memcpy(&(*secfilter)->filter_mask[3],
- &para->filter.mask[1], DMX_FILTER_SIZE - 1);
- memcpy(&(*secfilter)->filter_mode[3],
- &para->filter.mode[1], DMX_FILTER_SIZE - 1);
-
- (*secfilter)->filter_value[0] = para->filter.filter[0];
- (*secfilter)->filter_mask[0] = para->filter.mask[0];
- (*secfilter)->filter_mode[0] = para->filter.mode[0];
- (*secfilter)->filter_mask[1] = 0;
- (*secfilter)->filter_mask[2] = 0;
-
- filter->todo = 0;
-
- ret = filter->feed.sec->start_filtering(filter->feed.sec);
- if (ret < 0)
- return ret;
-
- dvb_dmxdev_filter_timer(filter);
- break;
- }
- case DMXDEV_TYPE_PES:
- {
- struct timespec timeout = { 0 };
- struct dmx_pes_filter_params *para = &filter->params.pes;
- dmx_output_t otype;
- int ret;
- int ts_type;
- enum dmx_ts_pes ts_pes;
- struct dmx_ts_feed **tsfeed = &filter->feed.ts;
-
- filter->feed.ts = NULL;
- otype = para->output;
-
- ts_pes = (enum dmx_ts_pes)para->pes_type;
-
- if (ts_pes < DMX_PES_OTHER)
- ts_type = TS_DECODER;
- else
- ts_type = 0;
-
- if (otype == DMX_OUT_TS_TAP)
- ts_type |= TS_PACKET;
-
- if (otype == DMX_OUT_TAP)
- ts_type |= TS_PAYLOAD_ONLY | TS_PACKET;
-
- ret = dmxdev->demux->allocate_ts_feed(dmxdev->demux,
- tsfeed,
- dvb_dmxdev_ts_callback);
- if (ret < 0)
- return ret;
-
- (*tsfeed)->priv = filter;
-
- ret = (*tsfeed)->set(*tsfeed, para->pid, ts_type, ts_pes,
- 32768, timeout);
- if (ret < 0) {
- dmxdev->demux->release_ts_feed(dmxdev->demux,
- *tsfeed);
- return ret;
- }
-
- ret = filter->feed.ts->start_filtering(filter->feed.ts);
- if (ret < 0) {
- dmxdev->demux->release_ts_feed(dmxdev->demux,
- *tsfeed);
- return ret;
- }
-
- break;
- }
- default:
- return -EINVAL;
- }
-
- dvb_dmxdev_filter_state_set(filter, DMXDEV_STATE_GO);
- return 0;
-}
-
-static int dvb_demux_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dmxdev *dmxdev = dvbdev->priv;
- int i;
- struct dmxdev_filter *dmxdevfilter;
-
- if (!dmxdev->filter)
- return -EINVAL;
-
- if (mutex_lock_interruptible(&dmxdev->mutex))
- return -ERESTARTSYS;
-
- for (i = 0; i < dmxdev->filternum; i++)
- if (dmxdev->filter[i].state == DMXDEV_STATE_FREE)
- break;
-
- if (i == dmxdev->filternum) {
- mutex_unlock(&dmxdev->mutex);
- return -EMFILE;
- }
-
- dmxdevfilter = &dmxdev->filter[i];
- mutex_init(&dmxdevfilter->mutex);
- file->private_data = dmxdevfilter;
-
- dvb_ringbuffer_init(&dmxdevfilter->buffer, NULL, 8192);
- dmxdevfilter->type = DMXDEV_TYPE_NONE;
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_ALLOCATED);
- dmxdevfilter->feed.ts = NULL;
- init_timer(&dmxdevfilter->timer);
-
- mutex_unlock(&dmxdev->mutex);
- return 0;
-}
-
-static int dvb_dmxdev_filter_free(struct dmxdev *dmxdev,
- struct dmxdev_filter *dmxdevfilter)
-{
- if (mutex_lock_interruptible(&dmxdev->mutex))
- return -ERESTARTSYS;
-
- if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
- mutex_unlock(&dmxdev->mutex);
- return -ERESTARTSYS;
- }
-
- dvb_dmxdev_filter_stop(dmxdevfilter);
- dvb_dmxdev_filter_reset(dmxdevfilter);
-
- if (dmxdevfilter->buffer.data) {
- void *mem = dmxdevfilter->buffer.data;
-
- spin_lock_irq(&dmxdev->lock);
- dmxdevfilter->buffer.data = NULL;
- spin_unlock_irq(&dmxdev->lock);
- vfree(mem);
- }
-
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_FREE);
- wake_up(&dmxdevfilter->buffer.queue);
- mutex_unlock(&dmxdevfilter->mutex);
- mutex_unlock(&dmxdev->mutex);
- return 0;
-}
-
-static inline void invert_mode(dmx_filter_t *filter)
-{
- int i;
-
- for (i = 0; i < DMX_FILTER_SIZE; i++)
- filter->mode[i] ^= 0xff;
-}
-
-static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev,
- struct dmxdev_filter *dmxdevfilter,
- struct dmx_sct_filter_params *params)
-{
- dprintk("function : %s\n", __FUNCTION__);
-
- dvb_dmxdev_filter_stop(dmxdevfilter);
-
- dmxdevfilter->type = DMXDEV_TYPE_SEC;
- memcpy(&dmxdevfilter->params.sec,
- params, sizeof(struct dmx_sct_filter_params));
- invert_mode(&dmxdevfilter->params.sec.filter);
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
-
- if (params->flags & DMX_IMMEDIATE_START)
- return dvb_dmxdev_filter_start(dmxdevfilter);
-
- return 0;
-}
-
-static int dvb_dmxdev_pes_filter_set(struct dmxdev *dmxdev,
- struct dmxdev_filter *dmxdevfilter,
- struct dmx_pes_filter_params *params)
-{
- dvb_dmxdev_filter_stop(dmxdevfilter);
-
- if (params->pes_type > DMX_PES_OTHER || params->pes_type < 0)
- return -EINVAL;
-
- dmxdevfilter->type = DMXDEV_TYPE_PES;
- memcpy(&dmxdevfilter->params, params,
- sizeof(struct dmx_pes_filter_params));
-
- dvb_dmxdev_filter_state_set(dmxdevfilter, DMXDEV_STATE_SET);
-
- if (params->flags & DMX_IMMEDIATE_START)
- return dvb_dmxdev_filter_start(dmxdevfilter);
-
- return 0;
-}
-
-static ssize_t dvb_dmxdev_read_sec(struct dmxdev_filter *dfil,
- struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
-{
- int result, hcount;
- int done = 0;
-
- if (dfil->todo <= 0) {
- hcount = 3 + dfil->todo;
- if (hcount > count)
- hcount = count;
- result = dvb_dmxdev_buffer_read(&dfil->buffer,
- file->f_flags & O_NONBLOCK,
- buf, hcount, ppos);
- if (result < 0) {
- dfil->todo = 0;
- return result;
- }
- if (copy_from_user(dfil->secheader - dfil->todo, buf, result))
- return -EFAULT;
- buf += result;
- done = result;
- count -= result;
- dfil->todo -= result;
- if (dfil->todo > -3)
- return done;
- dfil->todo = ((dfil->secheader[1] << 8) | dfil->secheader[2]) & 0xfff;
- if (!count)
- return done;
- }
- if (count > dfil->todo)
- count = dfil->todo;
- result = dvb_dmxdev_buffer_read(&dfil->buffer,
- file->f_flags & O_NONBLOCK,
- buf, count, ppos);
- if (result < 0)
- return result;
- dfil->todo -= result;
- return (result + done);
-}
-
-static ssize_t
-dvb_demux_read(struct file *file, char __user *buf, size_t count,
- loff_t *ppos)
-{
- struct dmxdev_filter *dmxdevfilter = file->private_data;
- int ret;
-
- if (mutex_lock_interruptible(&dmxdevfilter->mutex))
- return -ERESTARTSYS;
-
- if (dmxdevfilter->type == DMXDEV_TYPE_SEC)
- ret = dvb_dmxdev_read_sec(dmxdevfilter, file, buf, count, ppos);
- else
- ret = dvb_dmxdev_buffer_read(&dmxdevfilter->buffer,
- file->f_flags & O_NONBLOCK,
- buf, count, ppos);
-
- mutex_unlock(&dmxdevfilter->mutex);
- return ret;
-}
-
-static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dmxdev_filter *dmxdevfilter = file->private_data;
- struct dmxdev *dmxdev = dmxdevfilter->dev;
- unsigned long arg = (unsigned long)parg;
- int ret = 0;
-
- if (mutex_lock_interruptible(&dmxdev->mutex))
- return -ERESTARTSYS;
-
- switch (cmd) {
- case DMX_START:
- if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
- mutex_unlock(&dmxdev->mutex);
- return -ERESTARTSYS;
- }
- if (dmxdevfilter->state < DMXDEV_STATE_SET)
- ret = -EINVAL;
- else
- ret = dvb_dmxdev_filter_start(dmxdevfilter);
- mutex_unlock(&dmxdevfilter->mutex);
- break;
-
- case DMX_STOP:
- if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
- mutex_unlock(&dmxdev->mutex);
- return -ERESTARTSYS;
- }
- ret = dvb_dmxdev_filter_stop(dmxdevfilter);
- mutex_unlock(&dmxdevfilter->mutex);
- break;
-
- case DMX_SET_FILTER:
- if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
- mutex_unlock(&dmxdev->mutex);
- return -ERESTARTSYS;
- }
- ret = dvb_dmxdev_filter_set(dmxdev, dmxdevfilter, parg);
- mutex_unlock(&dmxdevfilter->mutex);
- break;
-
- case DMX_SET_PES_FILTER:
- if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
- mutex_unlock(&dmxdev->mutex);
- return -ERESTARTSYS;
- }
- ret = dvb_dmxdev_pes_filter_set(dmxdev, dmxdevfilter, parg);
- mutex_unlock(&dmxdevfilter->mutex);
- break;
-
- case DMX_SET_BUFFER_SIZE:
- if (mutex_lock_interruptible(&dmxdevfilter->mutex)) {
- mutex_unlock(&dmxdev->mutex);
- return -ERESTARTSYS;
- }
- ret = dvb_dmxdev_set_buffer_size(dmxdevfilter, arg);
- mutex_unlock(&dmxdevfilter->mutex);
- break;
-
- case DMX_GET_PES_PIDS:
- if (!dmxdev->demux->get_pes_pids) {
- ret = -EINVAL;
- break;
- }
- dmxdev->demux->get_pes_pids(dmxdev->demux, parg);
- break;
-
- case DMX_GET_CAPS:
- if (!dmxdev->demux->get_caps) {
- ret = -EINVAL;
- break;
- }
- ret = dmxdev->demux->get_caps(dmxdev->demux, parg);
- break;
-
- case DMX_SET_SOURCE:
- if (!dmxdev->demux->set_source) {
- ret = -EINVAL;
- break;
- }
- ret = dmxdev->demux->set_source(dmxdev->demux, parg);
- break;
-
- case DMX_GET_STC:
- if (!dmxdev->demux->get_stc) {
- ret = -EINVAL;
- break;
- }
- ret = dmxdev->demux->get_stc(dmxdev->demux,
- ((struct dmx_stc *)parg)->num,
- &((struct dmx_stc *)parg)->stc,
- &((struct dmx_stc *)parg)->base);
- break;
-
- default:
- ret = -EINVAL;
- break;
- }
- mutex_unlock(&dmxdev->mutex);
- return ret;
-}
-
-static int dvb_demux_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- return dvb_usercopy(inode, file, cmd, arg, dvb_demux_do_ioctl);
-}
-
-static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
-{
- struct dmxdev_filter *dmxdevfilter = file->private_data;
- unsigned int mask = 0;
-
- if (!dmxdevfilter)
- return -EINVAL;
-
- poll_wait(file, &dmxdevfilter->buffer.queue, wait);
-
- if (dmxdevfilter->state != DMXDEV_STATE_GO &&
- dmxdevfilter->state != DMXDEV_STATE_DONE &&
- dmxdevfilter->state != DMXDEV_STATE_TIMEDOUT)
- return 0;
-
- if (dmxdevfilter->buffer.error)
- mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
-
- if (!dvb_ringbuffer_empty(&dmxdevfilter->buffer))
- mask |= (POLLIN | POLLRDNORM | POLLPRI);
-
- return mask;
-}
-
-static int dvb_demux_release(struct inode *inode, struct file *file)
-{
- struct dmxdev_filter *dmxdevfilter = file->private_data;
- struct dmxdev *dmxdev = dmxdevfilter->dev;
-
- return dvb_dmxdev_filter_free(dmxdev, dmxdevfilter);
-}
-
-static struct file_operations dvb_demux_fops = {
- .owner = THIS_MODULE,
- .read = dvb_demux_read,
- .ioctl = dvb_demux_ioctl,
- .open = dvb_demux_open,
- .release = dvb_demux_release,
- .poll = dvb_demux_poll,
-};
-
-static struct dvb_device dvbdev_demux = {
- .priv = NULL,
- .users = 1,
- .writers = 1,
- .fops = &dvb_demux_fops
-};
-
-static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dmxdev *dmxdev = dvbdev->priv;
- int ret;
-
- if (mutex_lock_interruptible(&dmxdev->mutex))
- return -ERESTARTSYS;
-
- switch (cmd) {
- case DMX_SET_BUFFER_SIZE:
- // FIXME: implement
- ret = 0;
- break;
-
- default:
- ret = -EINVAL;
- break;
- }
- mutex_unlock(&dmxdev->mutex);
- return ret;
-}
-
-static int dvb_dvr_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- return dvb_usercopy(inode, file, cmd, arg, dvb_dvr_do_ioctl);
-}
-
-static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dmxdev *dmxdev = dvbdev->priv;
- unsigned int mask = 0;
-
- dprintk("function : %s\n", __FUNCTION__);
-
- poll_wait(file, &dmxdev->dvr_buffer.queue, wait);
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
- if (dmxdev->dvr_buffer.error)
- mask |= (POLLIN | POLLRDNORM | POLLPRI | POLLERR);
-
- if (!dvb_ringbuffer_empty(&dmxdev->dvr_buffer))
- mask |= (POLLIN | POLLRDNORM | POLLPRI);
- } else
- mask |= (POLLOUT | POLLWRNORM | POLLPRI);
-
- return mask;
-}
-
-static struct file_operations dvb_dvr_fops = {
- .owner = THIS_MODULE,
- .read = dvb_dvr_read,
- .write = dvb_dvr_write,
- .ioctl = dvb_dvr_ioctl,
- .open = dvb_dvr_open,
- .release = dvb_dvr_release,
- .poll = dvb_dvr_poll,
-};
-
-static struct dvb_device dvbdev_dvr = {
- .priv = NULL,
- .readers = 1,
- .fops = &dvb_dvr_fops
-};
-
-int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
-{
- int i;
-
- if (dmxdev->demux->open(dmxdev->demux) < 0)
- return -EUSERS;
-
- dmxdev->filter = vmalloc(dmxdev->filternum * sizeof(struct dmxdev_filter));
- if (!dmxdev->filter)
- return -ENOMEM;
-
- mutex_init(&dmxdev->mutex);
- spin_lock_init(&dmxdev->lock);
- for (i = 0; i < dmxdev->filternum; i++) {
- dmxdev->filter[i].dev = dmxdev;
- dmxdev->filter[i].buffer.data = NULL;
- dvb_dmxdev_filter_state_set(&dmxdev->filter[i],
- DMXDEV_STATE_FREE);
- }
-
- dvb_register_device(dvb_adapter, &dmxdev->dvbdev, &dvbdev_demux, dmxdev,
- DVB_DEVICE_DEMUX);
- dvb_register_device(dvb_adapter, &dmxdev->dvr_dvbdev, &dvbdev_dvr,
- dmxdev, DVB_DEVICE_DVR);
-
- dvb_ringbuffer_init(&dmxdev->dvr_buffer, NULL, 8192);
-
- return 0;
-}
-
-EXPORT_SYMBOL(dvb_dmxdev_init);
-
-void dvb_dmxdev_release(struct dmxdev *dmxdev)
-{
- dvb_unregister_device(dmxdev->dvbdev);
- dvb_unregister_device(dmxdev->dvr_dvbdev);
-
- vfree(dmxdev->filter);
- dmxdev->filter = NULL;
- dmxdev->demux->close(dmxdev->demux);
-}
-
-EXPORT_SYMBOL(dvb_dmxdev_release);
diff --git a/drivers/media/dvb/dvb-core/dmxdev.h b/drivers/media/dvb/dvb-core/dmxdev.h
deleted file mode 100644
index d2bee9ffe43..00000000000
--- a/drivers/media/dvb/dvb-core/dmxdev.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * dmxdev.h
- *
- * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
- * for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _DMXDEV_H_
-#define _DMXDEV_H_
-
-#include <linux/types.h>
-#include <linux/spinlock.h>
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/wait.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/mutex.h>
-
-#include <linux/dvb/dmx.h>
-
-#include "dvbdev.h"
-#include "demux.h"
-#include "dvb_ringbuffer.h"
-
-enum dmxdev_type {
- DMXDEV_TYPE_NONE,
- DMXDEV_TYPE_SEC,
- DMXDEV_TYPE_PES,
-};
-
-enum dmxdev_state {
- DMXDEV_STATE_FREE,
- DMXDEV_STATE_ALLOCATED,
- DMXDEV_STATE_SET,
- DMXDEV_STATE_GO,
- DMXDEV_STATE_DONE,
- DMXDEV_STATE_TIMEDOUT
-};
-
-struct dmxdev_filter {
- union {
- struct dmx_section_filter *sec;
- } filter;
-
- union {
- struct dmx_ts_feed *ts;
- struct dmx_section_feed *sec;
- } feed;
-
- union {
- struct dmx_sct_filter_params sec;
- struct dmx_pes_filter_params pes;
- } params;
-
- enum dmxdev_type type;
- enum dmxdev_state state;
- struct dmxdev *dev;
- struct dvb_ringbuffer buffer;
-
- struct mutex mutex;
-
- /* only for sections */
- struct timer_list timer;
- int todo;
- u8 secheader[3];
-};
-
-
-struct dmxdev {
- struct dvb_device *dvbdev;
- struct dvb_device *dvr_dvbdev;
-
- struct dmxdev_filter *filter;
- struct dmx_demux *demux;
-
- int filternum;
- int capabilities;
-#define DMXDEV_CAP_DUPLEX 1
- struct dmx_frontend *dvr_orig_fe;
-
- struct dvb_ringbuffer dvr_buffer;
-#define DVR_BUFFER_SIZE (10*188*1024)
-
- struct mutex mutex;
- spinlock_t lock;
-};
-
-
-int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *);
-void dvb_dmxdev_release(struct dmxdev *dmxdev);
-
-#endif /* _DMXDEV_H_ */
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
deleted file mode 100644
index 2a03bf53cb2..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ /dev/null
@@ -1,1771 +0,0 @@
-/*
- * dvb_ca.c: generic DVB functions for EN50221 CAM interfaces
- *
- * Copyright (C) 2004 Andrew de Quincey
- *
- * Parts of this file were based on sources as follows:
- *
- * Copyright (C) 2003 Ralph Metzler <rjkm@metzlerbros.de>
- *
- * based on code:
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/vmalloc.h>
-#include <linux/delay.h>
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-
-#include "dvb_ca_en50221.h"
-#include "dvb_ringbuffer.h"
-
-static int dvb_ca_en50221_debug;
-
-module_param_named(cam_debug, dvb_ca_en50221_debug, int, 0644);
-MODULE_PARM_DESC(cam_debug, "enable verbose debug messages");
-
-#define dprintk if (dvb_ca_en50221_debug) printk
-
-#define INIT_TIMEOUT_SECS 10
-
-#define HOST_LINK_BUF_SIZE 0x200
-
-#define RX_BUFFER_SIZE 65535
-
-#define MAX_RX_PACKETS_PER_ITERATION 10
-
-#define CTRLIF_DATA 0
-#define CTRLIF_COMMAND 1
-#define CTRLIF_STATUS 1
-#define CTRLIF_SIZE_LOW 2
-#define CTRLIF_SIZE_HIGH 3
-
-#define CMDREG_HC 1 /* Host control */
-#define CMDREG_SW 2 /* Size write */
-#define CMDREG_SR 4 /* Size read */
-#define CMDREG_RS 8 /* Reset interface */
-#define CMDREG_FRIE 0x40 /* Enable FR interrupt */
-#define CMDREG_DAIE 0x80 /* Enable DA interrupt */
-#define IRQEN (CMDREG_DAIE)
-
-#define STATUSREG_RE 1 /* read error */
-#define STATUSREG_WE 2 /* write error */
-#define STATUSREG_FR 0x40 /* module free */
-#define STATUSREG_DA 0x80 /* data available */
-#define STATUSREG_TXERR (STATUSREG_RE|STATUSREG_WE) /* general transfer error */
-
-
-#define DVB_CA_SLOTSTATE_NONE 0
-#define DVB_CA_SLOTSTATE_UNINITIALISED 1
-#define DVB_CA_SLOTSTATE_RUNNING 2
-#define DVB_CA_SLOTSTATE_INVALID 3
-#define DVB_CA_SLOTSTATE_WAITREADY 4
-#define DVB_CA_SLOTSTATE_VALIDATE 5
-#define DVB_CA_SLOTSTATE_WAITFR 6
-#define DVB_CA_SLOTSTATE_LINKINIT 7
-
-
-/* Information on a CA slot */
-struct dvb_ca_slot {
-
- /* current state of the CAM */
- int slot_state;
-
- /* Number of CAMCHANGES that have occurred since last processing */
- atomic_t camchange_count;
-
- /* Type of last CAMCHANGE */
- int camchange_type;
-
- /* base address of CAM config */
- u32 config_base;
-
- /* value to write into Config Control register */
- u8 config_option;
-
- /* if 1, the CAM supports DA IRQs */
- u8 da_irq_supported:1;
-
- /* size of the buffer to use when talking to the CAM */
- int link_buf_size;
-
- /* buffer for incoming packets */
- struct dvb_ringbuffer rx_buffer;
-
- /* timer used during various states of the slot */
- unsigned long timeout;
-};
-
-/* Private CA-interface information */
-struct dvb_ca_private {
-
- /* pointer back to the public data structure */
- struct dvb_ca_en50221 *pub;
-
- /* the DVB device */
- struct dvb_device *dvbdev;
-
- /* Flags describing the interface (DVB_CA_FLAG_*) */
- u32 flags;
-
- /* number of slots supported by this CA interface */
- unsigned int slot_count;
-
- /* information on each slot */
- struct dvb_ca_slot *slot_info;
-
- /* wait queues for read() and write() operations */
- wait_queue_head_t wait_queue;
-
- /* PID of the monitoring thread */
- pid_t thread_pid;
-
- /* Wait queue used when shutting thread down */
- wait_queue_head_t thread_queue;
-
- /* Flag indicating when thread should exit */
- unsigned int exit:1;
-
- /* Flag indicating if the CA device is open */
- unsigned int open:1;
-
- /* Flag indicating the thread should wake up now */
- unsigned int wakeup:1;
-
- /* Delay the main thread should use */
- unsigned long delay;
-
- /* Slot to start looking for data to read from in the next user-space read operation */
- int next_read_slot;
-};
-
-static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca);
-static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * ebuf, int ecount);
-static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * ebuf, int ecount);
-
-
-/**
- * Safely find needle in haystack.
- *
- * @param haystack Buffer to look in.
- * @param hlen Number of bytes in haystack.
- * @param needle Buffer to find.
- * @param nlen Number of bytes in needle.
- * @return Pointer into haystack needle was found at, or NULL if not found.
- */
-static u8 *findstr(u8 * haystack, int hlen, u8 * needle, int nlen)
-{
- int i;
-
- if (hlen < nlen)
- return NULL;
-
- for (i = 0; i <= hlen - nlen; i++) {
- if (!strncmp(haystack + i, needle, nlen))
- return haystack + i;
- }
-
- return NULL;
-}
-
-
-
-/* ******************************************************************************** */
-/* EN50221 physical interface functions */
-
-
-/**
- * Check CAM status.
- */
-static int dvb_ca_en50221_check_camstatus(struct dvb_ca_private *ca, int slot)
-{
- int slot_status;
- int cam_present_now;
- int cam_changed;
-
- /* IRQ mode */
- if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE) {
- return (atomic_read(&ca->slot_info[slot].camchange_count) != 0);
- }
-
- /* poll mode */
- slot_status = ca->pub->poll_slot_status(ca->pub, slot, ca->open);
-
- cam_present_now = (slot_status & DVB_CA_EN50221_POLL_CAM_PRESENT) ? 1 : 0;
- cam_changed = (slot_status & DVB_CA_EN50221_POLL_CAM_CHANGED) ? 1 : 0;
- if (!cam_changed) {
- int cam_present_old = (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE);
- cam_changed = (cam_present_now != cam_present_old);
- }
-
- if (cam_changed) {
- if (!cam_present_now) {
- ca->slot_info[slot].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
- } else {
- ca->slot_info[slot].camchange_type = DVB_CA_EN50221_CAMCHANGE_INSERTED;
- }
- atomic_set(&ca->slot_info[slot].camchange_count, 1);
- } else {
- if ((ca->slot_info[slot].slot_state == DVB_CA_SLOTSTATE_WAITREADY) &&
- (slot_status & DVB_CA_EN50221_POLL_CAM_READY)) {
- // move to validate state if reset is completed
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_VALIDATE;
- }
- }
-
- return cam_changed;
-}
-
-
-/**
- * Wait for flags to become set on the STATUS register on a CAM interface,
- * checking for errors and timeout.
- *
- * @param ca CA instance.
- * @param slot Slot on interface.
- * @param waitfor Flags to wait for.
- * @param timeout_ms Timeout in milliseconds.
- *
- * @return 0 on success, nonzero on error.
- */
-static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot,
- u8 waitfor, int timeout_hz)
-{
- unsigned long timeout;
- unsigned long start;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* loop until timeout elapsed */
- start = jiffies;
- timeout = jiffies + timeout_hz;
- while (1) {
- /* read the status and check for error */
- int res = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
- if (res < 0)
- return -EIO;
-
- /* if we got the flags, it was successful! */
- if (res & waitfor) {
- dprintk("%s succeeded timeout:%lu\n", __FUNCTION__, jiffies - start);
- return 0;
- }
-
- /* check for timeout */
- if (time_after(jiffies, timeout)) {
- break;
- }
-
- /* wait for a bit */
- msleep(1);
- }
-
- dprintk("%s failed timeout:%lu\n", __FUNCTION__, jiffies - start);
-
- /* if we get here, we've timed out */
- return -ETIMEDOUT;
-}
-
-
-/**
- * Initialise the link layer connection to a CAM.
- *
- * @param ca CA instance.
- * @param slot Slot id.
- *
- * @return 0 on success, nonzero on failure.
- */
-static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot)
-{
- int ret;
- int buf_size;
- u8 buf[2];
-
- dprintk("%s\n", __FUNCTION__);
-
- /* we'll be determining these during this function */
- ca->slot_info[slot].da_irq_supported = 0;
-
- /* set the host link buffer size temporarily. it will be overwritten with the
- * real negotiated size later. */
- ca->slot_info[slot].link_buf_size = 2;
-
- /* read the buffer size from the CAM */
- if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SR)) != 0)
- return ret;
- if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_DA, HZ / 10)) != 0)
- return ret;
- if ((ret = dvb_ca_en50221_read_data(ca, slot, buf, 2)) != 2)
- return -EIO;
- if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
- return ret;
-
- /* store it, and choose the minimum of our buffer and the CAM's buffer size */
- buf_size = (buf[0] << 8) | buf[1];
- if (buf_size > HOST_LINK_BUF_SIZE)
- buf_size = HOST_LINK_BUF_SIZE;
- ca->slot_info[slot].link_buf_size = buf_size;
- buf[0] = buf_size >> 8;
- buf[1] = buf_size & 0xff;
- dprintk("Chosen link buffer size of %i\n", buf_size);
-
- /* write the buffer size to the CAM */
- if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN | CMDREG_SW)) != 0)
- return ret;
- if ((ret = dvb_ca_en50221_wait_if_status(ca, slot, STATUSREG_FR, HZ / 10)) != 0)
- return ret;
- if ((ret = dvb_ca_en50221_write_data(ca, slot, buf, 2)) != 2)
- return -EIO;
- if ((ret = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN)) != 0)
- return ret;
-
- /* success */
- return 0;
-}
-
-/**
- * Read a tuple from attribute memory.
- *
- * @param ca CA instance.
- * @param slot Slot id.
- * @param address Address to read from. Updated.
- * @param tupleType Tuple id byte. Updated.
- * @param tupleLength Tuple length. Updated.
- * @param tuple Dest buffer for tuple (must be 256 bytes). Updated.
- *
- * @return 0 on success, nonzero on error.
- */
-static int dvb_ca_en50221_read_tuple(struct dvb_ca_private *ca, int slot,
- int *address, int *tupleType, int *tupleLength, u8 * tuple)
-{
- int i;
- int _tupleType;
- int _tupleLength;
- int _address = *address;
-
- /* grab the next tuple length and type */
- if ((_tupleType = ca->pub->read_attribute_mem(ca->pub, slot, _address)) < 0)
- return _tupleType;
- if (_tupleType == 0xff) {
- dprintk("END OF CHAIN TUPLE type:0x%x\n", _tupleType);
- *address += 2;
- *tupleType = _tupleType;
- *tupleLength = 0;
- return 0;
- }
- if ((_tupleLength = ca->pub->read_attribute_mem(ca->pub, slot, _address + 2)) < 0)
- return _tupleLength;
- _address += 4;
-
- dprintk("TUPLE type:0x%x length:%i\n", _tupleType, _tupleLength);
-
- /* read in the whole tuple */
- for (i = 0; i < _tupleLength; i++) {
- tuple[i] = ca->pub->read_attribute_mem(ca->pub, slot, _address + (i * 2));
- dprintk(" 0x%02x: 0x%02x %c\n",
- i, tuple[i] & 0xff,
- ((tuple[i] > 31) && (tuple[i] < 127)) ? tuple[i] : '.');
- }
- _address += (_tupleLength * 2);
-
- // success
- *tupleType = _tupleType;
- *tupleLength = _tupleLength;
- *address = _address;
- return 0;
-}
-
-
-/**
- * Parse attribute memory of a CAM module, extracting Config register, and checking
- * it is a DVB CAM module.
- *
- * @param ca CA instance.
- * @param slot Slot id.
- *
- * @return 0 on success, <0 on failure.
- */
-static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
-{
- int address = 0;
- int tupleLength;
- int tupleType;
- u8 tuple[257];
- char *dvb_str;
- int rasz;
- int status;
- int got_cftableentry = 0;
- int end_chain = 0;
- int i;
- u16 manfid = 0;
- u16 devid = 0;
-
-
- // CISTPL_DEVICE_0A
- if ((status =
- dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
- return status;
- if (tupleType != 0x1D)
- return -EINVAL;
-
-
-
- // CISTPL_DEVICE_0C
- if ((status =
- dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
- return status;
- if (tupleType != 0x1C)
- return -EINVAL;
-
-
-
- // CISTPL_VERS_1
- if ((status =
- dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, &tupleLength, tuple)) < 0)
- return status;
- if (tupleType != 0x15)
- return -EINVAL;
-
-
-
- // CISTPL_MANFID
- if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
- &tupleLength, tuple)) < 0)
- return status;
- if (tupleType != 0x20)
- return -EINVAL;
- if (tupleLength != 4)
- return -EINVAL;
- manfid = (tuple[1] << 8) | tuple[0];
- devid = (tuple[3] << 8) | tuple[2];
-
-
-
- // CISTPL_CONFIG
- if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
- &tupleLength, tuple)) < 0)
- return status;
- if (tupleType != 0x1A)
- return -EINVAL;
- if (tupleLength < 3)
- return -EINVAL;
-
- /* extract the configbase */
- rasz = tuple[0] & 3;
- if (tupleLength < (3 + rasz + 14))
- return -EINVAL;
- ca->slot_info[slot].config_base = 0;
- for (i = 0; i < rasz + 1; i++) {
- ca->slot_info[slot].config_base |= (tuple[2 + i] << (8 * i));
- }
-
- /* check it contains the correct DVB string */
- dvb_str = findstr(tuple, tupleLength, "DVB_CI_V", 8);
- if (dvb_str == NULL)
- return -EINVAL;
- if (tupleLength < ((dvb_str - (char *) tuple) + 12))
- return -EINVAL;
-
- /* is it a version we support? */
- if (strncmp(dvb_str + 8, "1.00", 4)) {
- printk("dvb_ca adapter %d: Unsupported DVB CAM module version %c%c%c%c\n",
- ca->dvbdev->adapter->num, dvb_str[8], dvb_str[9], dvb_str[10], dvb_str[11]);
- return -EINVAL;
- }
-
- /* process the CFTABLE_ENTRY tuples, and any after those */
- while ((!end_chain) && (address < 0x1000)) {
- if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
- &tupleLength, tuple)) < 0)
- return status;
- switch (tupleType) {
- case 0x1B: // CISTPL_CFTABLE_ENTRY
- if (tupleLength < (2 + 11 + 17))
- break;
-
- /* if we've already parsed one, just use it */
- if (got_cftableentry)
- break;
-
- /* get the config option */
- ca->slot_info[slot].config_option = tuple[0] & 0x3f;
-
- /* OK, check it contains the correct strings */
- if ((findstr(tuple, tupleLength, "DVB_HOST", 8) == NULL) ||
- (findstr(tuple, tupleLength, "DVB_CI_MODULE", 13) == NULL))
- break;
-
- got_cftableentry = 1;
- break;
-
- case 0x14: // CISTPL_NO_LINK
- break;
-
- case 0xFF: // CISTPL_END
- end_chain = 1;
- break;
-
- default: /* Unknown tuple type - just skip this tuple and move to the next one */
- dprintk("dvb_ca: Skipping unknown tuple type:0x%x length:0x%x\n", tupleType,
- tupleLength);
- break;
- }
- }
-
- if ((address > 0x1000) || (!got_cftableentry))
- return -EINVAL;
-
- dprintk("Valid DVB CAM detected MANID:%x DEVID:%x CONFIGBASE:0x%x CONFIGOPTION:0x%x\n",
- manfid, devid, ca->slot_info[slot].config_base, ca->slot_info[slot].config_option);
-
- // success!
- return 0;
-}
-
-
-/**
- * Set CAM's configoption correctly.
- *
- * @param ca CA instance.
- * @param slot Slot containing the CAM.
- */
-static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot)
-{
- int configoption;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* set the config option */
- ca->pub->write_attribute_mem(ca->pub, slot,
- ca->slot_info[slot].config_base,
- ca->slot_info[slot].config_option);
-
- /* check it */
- configoption = ca->pub->read_attribute_mem(ca->pub, slot, ca->slot_info[slot].config_base);
- dprintk("Set configoption 0x%x, read configoption 0x%x\n",
- ca->slot_info[slot].config_option, configoption & 0x3f);
-
- /* fine! */
- return 0;
-
-}
-
-
-/**
- * This function talks to an EN50221 CAM control interface. It reads a buffer of
- * data from the CAM. The data can either be stored in a supplied buffer, or
- * automatically be added to the slot's rx_buffer.
- *
- * @param ca CA instance.
- * @param slot Slot to read from.
- * @param ebuf If non-NULL, the data will be written to this buffer. If NULL,
- * the data will be added into the buffering system as a normal fragment.
- * @param ecount Size of ebuf. Ignored if ebuf is NULL.
- *
- * @return Number of bytes read, or < 0 on error
- */
-static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * ebuf, int ecount)
-{
- int bytes_read;
- int status;
- u8 buf[HOST_LINK_BUF_SIZE];
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* check if we have space for a link buf in the rx_buffer */
- if (ebuf == NULL) {
- int buf_free;
-
- if (ca->slot_info[slot].rx_buffer.data == NULL) {
- status = -EIO;
- goto exit;
- }
- buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer);
-
- if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
- status = -EAGAIN;
- goto exit;
- }
- }
-
- /* check if there is data available */
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
- goto exit;
- if (!(status & STATUSREG_DA)) {
- /* no data */
- status = 0;
- goto exit;
- }
-
- /* read the amount of data */
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH)) < 0)
- goto exit;
- bytes_read = status << 8;
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW)) < 0)
- goto exit;
- bytes_read |= status;
-
- /* check it will fit */
- if (ebuf == NULL) {
- if (bytes_read > ca->slot_info[slot].link_buf_size) {
- printk("dvb_ca adapter %d: CAM tried to send a buffer larger than the link buffer size (%i > %i)!\n",
- ca->dvbdev->adapter->num, bytes_read, ca->slot_info[slot].link_buf_size);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
- status = -EIO;
- goto exit;
- }
- if (bytes_read < 2) {
- printk("dvb_ca adapter %d: CAM sent a buffer that was less than 2 bytes!\n",
- ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
- status = -EIO;
- goto exit;
- }
- } else {
- if (bytes_read > ecount) {
- printk("dvb_ca adapter %d: CAM tried to send a buffer larger than the ecount size!\n",
- ca->dvbdev->adapter->num);
- status = -EIO;
- goto exit;
- }
- }
-
- /* fill the buffer */
- for (i = 0; i < bytes_read; i++) {
- /* read byte and check */
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_DATA)) < 0)
- goto exit;
-
- /* OK, store it in the buffer */
- buf[i] = status;
- }
-
- /* check for read error (RE should now be 0) */
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
- goto exit;
- if (status & STATUSREG_RE) {
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
- status = -EIO;
- goto exit;
- }
-
- /* OK, add it to the receive buffer, or copy into external buffer if supplied */
- if (ebuf == NULL) {
- if (ca->slot_info[slot].rx_buffer.data == NULL) {
- status = -EIO;
- goto exit;
- }
- dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read);
- } else {
- memcpy(ebuf, buf, bytes_read);
- }
-
- dprintk("Received CA packet for slot %i connection id 0x%x last_frag:%i size:0x%x\n", slot,
- buf[0], (buf[1] & 0x80) == 0, bytes_read);
-
- /* wake up readers when a last_fragment is received */
- if ((buf[1] & 0x80) == 0x00) {
- wake_up_interruptible(&ca->wait_queue);
- }
- status = bytes_read;
-
-exit:
- return status;
-}
-
-
-/**
- * This function talks to an EN50221 CAM control interface. It writes a buffer of data
- * to a CAM.
- *
- * @param ca CA instance.
- * @param slot Slot to write to.
- * @param ebuf The data in this buffer is treated as a complete link-level packet to
- * be written.
- * @param count Size of ebuf.
- *
- * @return Number of bytes written, or < 0 on error.
- */
-static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * buf, int bytes_write)
-{
- int status;
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
-
- // sanity check
- if (bytes_write > ca->slot_info[slot].link_buf_size)
- return -EINVAL;
-
- /* check if interface is actually waiting for us to read from it, or if a read is in progress */
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
- goto exitnowrite;
- if (status & (STATUSREG_DA | STATUSREG_RE)) {
- status = -EAGAIN;
- goto exitnowrite;
- }
-
- /* OK, set HC bit */
- if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND,
- IRQEN | CMDREG_HC)) != 0)
- goto exit;
-
- /* check if interface is still free */
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
- goto exit;
- if (!(status & STATUSREG_FR)) {
- /* it wasn't free => try again later */
- status = -EAGAIN;
- goto exit;
- }
-
- /* send the amount of data */
- if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_HIGH, bytes_write >> 8)) != 0)
- goto exit;
- if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_SIZE_LOW,
- bytes_write & 0xff)) != 0)
- goto exit;
-
- /* send the buffer */
- for (i = 0; i < bytes_write; i++) {
- if ((status = ca->pub->write_cam_control(ca->pub, slot, CTRLIF_DATA, buf[i])) != 0)
- goto exit;
- }
-
- /* check for write error (WE should now be 0) */
- if ((status = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS)) < 0)
- goto exit;
- if (status & STATUSREG_WE) {
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
- status = -EIO;
- goto exit;
- }
- status = bytes_write;
-
- dprintk("Wrote CA packet for slot %i, connection id 0x%x last_frag:%i size:0x%x\n", slot,
- buf[0], (buf[1] & 0x80) == 0, bytes_write);
-
-exit:
- ca->pub->write_cam_control(ca->pub, slot, CTRLIF_COMMAND, IRQEN);
-
-exitnowrite:
- return status;
-}
-EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq);
-
-
-
-/* ******************************************************************************** */
-/* EN50221 higher level functions */
-
-
-/**
- * A CAM has been removed => shut it down.
- *
- * @param ca CA instance.
- * @param slot Slot to shut down.
- */
-static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
-{
- dprintk("%s\n", __FUNCTION__);
-
- ca->pub->slot_shutdown(ca->pub, slot);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
-
- /* need to wake up all processes to check if they're now
- trying to write to a defunct CAM */
- wake_up_interruptible(&ca->wait_queue);
-
- dprintk("Slot %i shutdown\n", slot);
-
- /* success */
- return 0;
-}
-EXPORT_SYMBOL(dvb_ca_en50221_camready_irq);
-
-
-/**
- * A CAMCHANGE IRQ has occurred.
- *
- * @param ca CA instance.
- * @param slot Slot concerned.
- * @param change_type One of the DVB_CA_CAMCHANGE_* values.
- */
-void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221 *pubca, int slot, int change_type)
-{
- struct dvb_ca_private *ca = pubca->private;
-
- dprintk("CAMCHANGE IRQ slot:%i change_type:%i\n", slot, change_type);
-
- switch (change_type) {
- case DVB_CA_EN50221_CAMCHANGE_REMOVED:
- case DVB_CA_EN50221_CAMCHANGE_INSERTED:
- break;
-
- default:
- return;
- }
-
- ca->slot_info[slot].camchange_type = change_type;
- atomic_inc(&ca->slot_info[slot].camchange_count);
- dvb_ca_en50221_thread_wakeup(ca);
-}
-EXPORT_SYMBOL(dvb_ca_en50221_frda_irq);
-
-
-/**
- * A CAMREADY IRQ has occurred.
- *
- * @param ca CA instance.
- * @param slot Slot concerned.
- */
-void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221 *pubca, int slot)
-{
- struct dvb_ca_private *ca = pubca->private;
-
- dprintk("CAMREADY IRQ slot:%i\n", slot);
-
- if (ca->slot_info[slot].slot_state == DVB_CA_SLOTSTATE_WAITREADY) {
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_VALIDATE;
- dvb_ca_en50221_thread_wakeup(ca);
- }
-}
-
-
-/**
- * An FR or DA IRQ has occurred.
- *
- * @param ca CA instance.
- * @param slot Slot concerned.
- */
-void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
-{
- struct dvb_ca_private *ca = pubca->private;
- int flags;
-
- dprintk("FR/DA IRQ slot:%i\n", slot);
-
- switch (ca->slot_info[slot].slot_state) {
- case DVB_CA_SLOTSTATE_LINKINIT:
- flags = ca->pub->read_cam_control(pubca, slot, CTRLIF_STATUS);
- if (flags & STATUSREG_DA) {
- dprintk("CAM supports DA IRQ\n");
- ca->slot_info[slot].da_irq_supported = 1;
- }
- break;
-
- case DVB_CA_SLOTSTATE_RUNNING:
- if (ca->open)
- dvb_ca_en50221_thread_wakeup(ca);
- break;
- }
-}
-
-
-
-/* ******************************************************************************** */
-/* EN50221 thread functions */
-
-/**
- * Wake up the DVB CA thread
- *
- * @param ca CA instance.
- */
-static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca)
-{
-
- dprintk("%s\n", __FUNCTION__);
-
- ca->wakeup = 1;
- mb();
- wake_up_interruptible(&ca->thread_queue);
-}
-
-/**
- * Used by the CA thread to determine if an early wakeup is necessary
- *
- * @param ca CA instance.
- */
-static int dvb_ca_en50221_thread_should_wakeup(struct dvb_ca_private *ca)
-{
- if (ca->wakeup) {
- ca->wakeup = 0;
- return 1;
- }
- if (ca->exit)
- return 1;
-
- return 0;
-}
-
-
-/**
- * Update the delay used by the thread.
- *
- * @param ca CA instance.
- */
-static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
-{
- int delay;
- int curdelay = 100000000;
- int slot;
-
- for (slot = 0; slot < ca->slot_count; slot++) {
- switch (ca->slot_info[slot].slot_state) {
- default:
- case DVB_CA_SLOTSTATE_NONE:
- case DVB_CA_SLOTSTATE_INVALID:
- delay = HZ * 60;
- if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) {
- delay = HZ / 10;
- }
- break;
-
- case DVB_CA_SLOTSTATE_UNINITIALISED:
- case DVB_CA_SLOTSTATE_WAITREADY:
- case DVB_CA_SLOTSTATE_VALIDATE:
- case DVB_CA_SLOTSTATE_WAITFR:
- case DVB_CA_SLOTSTATE_LINKINIT:
- delay = HZ / 10;
- break;
-
- case DVB_CA_SLOTSTATE_RUNNING:
- delay = HZ * 60;
- if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) {
- delay = HZ / 10;
- }
- if (ca->open) {
- if ((!ca->slot_info[slot].da_irq_supported) ||
- (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) {
- delay = HZ / 10;
- }
- }
- break;
- }
-
- if (delay < curdelay)
- curdelay = delay;
- }
-
- ca->delay = curdelay;
-}
-
-
-
-/**
- * Kernel thread which monitors CA slots for CAM changes, and performs data transfers.
- */
-static int dvb_ca_en50221_thread(void *data)
-{
- struct dvb_ca_private *ca = data;
- char name[15];
- int slot;
- int flags;
- int status;
- int pktcount;
- void *rxbuf;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* setup kernel thread */
- snprintf(name, sizeof(name), "kdvb-ca-%i:%i", ca->dvbdev->adapter->num, ca->dvbdev->id);
-
- lock_kernel();
- daemonize(name);
- sigfillset(&current->blocked);
- unlock_kernel();
-
- /* choose the correct initial delay */
- dvb_ca_en50221_thread_update_delay(ca);
-
- /* main loop */
- while (!ca->exit) {
- /* sleep for a bit */
- if (!ca->wakeup) {
- flags = wait_event_interruptible_timeout(ca->thread_queue,
- dvb_ca_en50221_thread_should_wakeup(ca),
- ca->delay);
- if ((flags == -ERESTARTSYS) || ca->exit) {
- /* got signal or quitting */
- break;
- }
- }
- ca->wakeup = 0;
-
- /* go through all the slots processing them */
- for (slot = 0; slot < ca->slot_count; slot++) {
-
- // check the cam status + deal with CAMCHANGEs
- while (dvb_ca_en50221_check_camstatus(ca, slot)) {
- /* clear down an old CI slot if necessary */
- if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE)
- dvb_ca_en50221_slot_shutdown(ca, slot);
-
- /* if a CAM is NOW present, initialise it */
- if (ca->slot_info[slot].camchange_type == DVB_CA_EN50221_CAMCHANGE_INSERTED) {
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_UNINITIALISED;
- }
-
- /* we've handled one CAMCHANGE */
- dvb_ca_en50221_thread_update_delay(ca);
- atomic_dec(&ca->slot_info[slot].camchange_count);
- }
-
- // CAM state machine
- switch (ca->slot_info[slot].slot_state) {
- case DVB_CA_SLOTSTATE_NONE:
- case DVB_CA_SLOTSTATE_INVALID:
- // no action needed
- break;
-
- case DVB_CA_SLOTSTATE_UNINITIALISED:
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_WAITREADY;
- ca->pub->slot_reset(ca->pub, slot);
- ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
- break;
-
- case DVB_CA_SLOTSTATE_WAITREADY:
- if (time_after(jiffies, ca->slot_info[slot].timeout)) {
- printk("dvb_ca adaptor %d: PC card did not respond :(\n",
- ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- // no other action needed; will automatically change state when ready
- break;
-
- case DVB_CA_SLOTSTATE_VALIDATE:
- if (dvb_ca_en50221_parse_attributes(ca, slot) != 0) {
- /* we need this extra check for annoying interfaces like the budget-av */
- if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
- (ca->pub->poll_slot_status)) {
- int status = ca->pub->poll_slot_status(ca->pub, slot, 0);
- if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- }
-
- printk("dvb_ca adapter %d: Invalid PC card inserted :(\n",
- ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- if (dvb_ca_en50221_set_configoption(ca, slot) != 0) {
- printk("dvb_ca adapter %d: Unable to initialise CAM :(\n",
- ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- if (ca->pub->write_cam_control(ca->pub, slot,
- CTRLIF_COMMAND, CMDREG_RS) != 0) {
- printk("dvb_ca adapter %d: Unable to reset CAM IF\n",
- ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- dprintk("DVB CAM validated successfully\n");
-
- ca->slot_info[slot].timeout = jiffies + (INIT_TIMEOUT_SECS * HZ);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_WAITFR;
- ca->wakeup = 1;
- break;
-
- case DVB_CA_SLOTSTATE_WAITFR:
- if (time_after(jiffies, ca->slot_info[slot].timeout)) {
- printk("dvb_ca adapter %d: DVB CAM did not respond :(\n",
- ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
-
- flags = ca->pub->read_cam_control(ca->pub, slot, CTRLIF_STATUS);
- if (flags & STATUSREG_FR) {
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_LINKINIT;
- ca->wakeup = 1;
- }
- break;
-
- case DVB_CA_SLOTSTATE_LINKINIT:
- if (dvb_ca_en50221_link_init(ca, slot) != 0) {
- /* we need this extra check for annoying interfaces like the budget-av */
- if ((!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) &&
- (ca->pub->poll_slot_status)) {
- int status = ca->pub->poll_slot_status(ca->pub, slot, 0);
- if (!(status & DVB_CA_EN50221_POLL_CAM_PRESENT)) {
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- }
-
- printk("dvb_ca adapter %d: DVB CAM link initialisation failed :(\n", ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
-
- if (ca->slot_info[slot].rx_buffer.data == NULL) {
- rxbuf = vmalloc(RX_BUFFER_SIZE);
- if (rxbuf == NULL) {
- printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
- dvb_ca_en50221_thread_update_delay(ca);
- break;
- }
- dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
- }
-
- ca->pub->slot_ts_enable(ca->pub, slot);
- ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
- dvb_ca_en50221_thread_update_delay(ca);
- printk("dvb_ca adapter %d: DVB CAM detected and initialised successfully\n", ca->dvbdev->adapter->num);
- break;
-
- case DVB_CA_SLOTSTATE_RUNNING:
- if (!ca->open)
- continue;
-
- // poll slots for data
- pktcount = 0;
- while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
- if (!ca->open)
- break;
-
- /* if a CAMCHANGE occurred at some point, do not do any more processing of this slot */
- if (dvb_ca_en50221_check_camstatus(ca, slot)) {
- // we dont want to sleep on the next iteration so we can handle the cam change
- ca->wakeup = 1;
- break;
- }
-
- /* check if we've hit our limit this time */
- if (++pktcount >= MAX_RX_PACKETS_PER_ITERATION) {
- // dont sleep; there is likely to be more data to read
- ca->wakeup = 1;
- break;
- }
- }
- break;
- }
- }
- }
-
- /* completed */
- ca->thread_pid = 0;
- mb();
- wake_up_interruptible(&ca->thread_queue);
- return 0;
-}
-
-
-
-/* ******************************************************************************** */
-/* EN50221 IO interface functions */
-
-/**
- * Real ioctl implementation.
- * NOTE: CA_SEND_MSG/CA_GET_MSG ioctls have userspace buffers passed to them.
- *
- * @param inode Inode concerned.
- * @param file File concerned.
- * @param cmd IOCTL command.
- * @param arg Associated argument.
- *
- * @return 0 on success, <0 on error.
- */
-static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_ca_private *ca = dvbdev->priv;
- int err = 0;
- int slot;
-
- dprintk("%s\n", __FUNCTION__);
-
- switch (cmd) {
- case CA_RESET:
- for (slot = 0; slot < ca->slot_count; slot++) {
- if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_NONE) {
- dvb_ca_en50221_slot_shutdown(ca, slot);
- if (ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)
- dvb_ca_en50221_camchange_irq(ca->pub,
- slot,
- DVB_CA_EN50221_CAMCHANGE_INSERTED);
- }
- }
- ca->next_read_slot = 0;
- dvb_ca_en50221_thread_wakeup(ca);
- break;
-
- case CA_GET_CAP: {
- struct ca_caps *caps = parg;
-
- caps->slot_num = ca->slot_count;
- caps->slot_type = CA_CI_LINK;
- caps->descr_num = 0;
- caps->descr_type = 0;
- break;
- }
-
- case CA_GET_SLOT_INFO: {
- struct ca_slot_info *info = parg;
-
- if ((info->num > ca->slot_count) || (info->num < 0))
- return -EINVAL;
-
- info->type = CA_CI_LINK;
- info->flags = 0;
- if ((ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_NONE)
- && (ca->slot_info[info->num].slot_state != DVB_CA_SLOTSTATE_INVALID)) {
- info->flags = CA_CI_MODULE_PRESENT;
- }
- if (ca->slot_info[info->num].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
- info->flags |= CA_CI_MODULE_READY;
- }
- break;
- }
-
- default:
- err = -EINVAL;
- break;
- }
-
- return err;
-}
-
-
-/**
- * Wrapper for ioctl implementation.
- *
- * @param inode Inode concerned.
- * @param file File concerned.
- * @param cmd IOCTL command.
- * @param arg Associated argument.
- *
- * @return 0 on success, <0 on error.
- */
-static int dvb_ca_en50221_io_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- return dvb_usercopy(inode, file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
-}
-
-
-/**
- * Implementation of write() syscall.
- *
- * @param file File structure.
- * @param buf Source buffer.
- * @param count Size of source buffer.
- * @param ppos Position in file (ignored).
- *
- * @return Number of bytes read, or <0 on error.
- */
-static ssize_t dvb_ca_en50221_io_write(struct file *file,
- const char __user * buf, size_t count, loff_t * ppos)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_ca_private *ca = dvbdev->priv;
- u8 slot, connection_id;
- int status;
- char fragbuf[HOST_LINK_BUF_SIZE];
- int fragpos = 0;
- int fraglen;
- unsigned long timeout;
- int written;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* Incoming packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */
- if (count < 2)
- return -EINVAL;
-
- /* extract slot & connection id */
- if (copy_from_user(&slot, buf, 1))
- return -EFAULT;
- if (copy_from_user(&connection_id, buf + 1, 1))
- return -EFAULT;
- buf += 2;
- count -= 2;
-
- /* check if the slot is actually running */
- if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
- return -EINVAL;
-
- /* fragment the packets & store in the buffer */
- while (fragpos < count) {
- fraglen = ca->slot_info[slot].link_buf_size - 2;
- if ((count - fragpos) < fraglen)
- fraglen = count - fragpos;
-
- fragbuf[0] = connection_id;
- fragbuf[1] = ((fragpos + fraglen) < count) ? 0x80 : 0x00;
- if ((status = copy_from_user(fragbuf + 2, buf + fragpos, fraglen)) != 0)
- goto exit;
-
- timeout = jiffies + HZ / 2;
- written = 0;
- while (!time_after(jiffies, timeout)) {
- /* check the CAM hasn't been removed/reset in the meantime */
- if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) {
- status = -EIO;
- goto exit;
- }
-
- status = dvb_ca_en50221_write_data(ca, slot, fragbuf, fraglen + 2);
- if (status == (fraglen + 2)) {
- written = 1;
- break;
- }
- if (status != -EAGAIN)
- goto exit;
-
- msleep(1);
- }
- if (!written) {
- status = -EIO;
- goto exit;
- }
-
- fragpos += fraglen;
- }
- status = count + 2;
-
-exit:
- return status;
-}
-
-
-/**
- * Condition for waking up in dvb_ca_en50221_io_read_condition
- */
-static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
- int *result, int *_slot)
-{
- int slot;
- int slot_count = 0;
- int idx;
- size_t fraglen;
- int connection_id = -1;
- int found = 0;
- u8 hdr[2];
-
- slot = ca->next_read_slot;
- while ((slot_count < ca->slot_count) && (!found)) {
- if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
- goto nextslot;
-
- if (ca->slot_info[slot].rx_buffer.data == NULL) {
- return 0;
- }
-
- idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, -1, &fraglen);
- while (idx != -1) {
- dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2, 0);
- if (connection_id == -1)
- connection_id = hdr[0];
- if ((hdr[0] == connection_id) && ((hdr[1] & 0x80) == 0)) {
- *_slot = slot;
- found = 1;
- break;
- }
-
- idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
- }
-
-nextslot:
- slot = (slot + 1) % ca->slot_count;
- slot_count++;
- }
-
- ca->next_read_slot = slot;
- return found;
-}
-
-
-/**
- * Implementation of read() syscall.
- *
- * @param file File structure.
- * @param buf Destination buffer.
- * @param count Size of destination buffer.
- * @param ppos Position in file (ignored).
- *
- * @return Number of bytes read, or <0 on error.
- */
-static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
- size_t count, loff_t * ppos)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_ca_private *ca = dvbdev->priv;
- int status;
- int result = 0;
- u8 hdr[2];
- int slot;
- int connection_id = -1;
- size_t idx, idx2;
- int last_fragment = 0;
- size_t fraglen;
- int pktlen;
- int dispose = 0;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* Outgoing packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */
- if (count < 2)
- return -EINVAL;
-
- /* wait for some data */
- if ((status = dvb_ca_en50221_io_read_condition(ca, &result, &slot)) == 0) {
-
- /* if we're in nonblocking mode, exit immediately */
- if (file->f_flags & O_NONBLOCK)
- return -EWOULDBLOCK;
-
- /* wait for some data */
- status = wait_event_interruptible(ca->wait_queue,
- dvb_ca_en50221_io_read_condition
- (ca, &result, &slot));
- }
- if ((status < 0) || (result < 0)) {
- if (result)
- return result;
- return status;
- }
-
- idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, -1, &fraglen);
- pktlen = 2;
- do {
- if (idx == -1) {
- printk("dvb_ca adapter %d: BUG: read packet ended before last_fragment encountered\n", ca->dvbdev->adapter->num);
- status = -EIO;
- goto exit;
- }
-
- dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 0, hdr, 2, 0);
- if (connection_id == -1)
- connection_id = hdr[0];
- if (hdr[0] == connection_id) {
- if (pktlen < count) {
- if ((pktlen + fraglen - 2) > count) {
- fraglen = count - pktlen;
- } else {
- fraglen -= 2;
- }
-
- if ((status = dvb_ringbuffer_pkt_read(&ca->slot_info[slot].rx_buffer, idx, 2,
- buf + pktlen, fraglen, 1)) < 0) {
- goto exit;
- }
- pktlen += fraglen;
- }
-
- if ((hdr[1] & 0x80) == 0)
- last_fragment = 1;
- dispose = 1;
- }
-
- idx2 = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
- if (dispose)
- dvb_ringbuffer_pkt_dispose(&ca->slot_info[slot].rx_buffer, idx);
- idx = idx2;
- dispose = 0;
- } while (!last_fragment);
-
- hdr[0] = slot;
- hdr[1] = connection_id;
- if ((status = copy_to_user(buf, hdr, 2)) != 0)
- goto exit;
- status = pktlen;
-
-exit:
- return status;
-}
-
-
-/**
- * Implementation of file open syscall.
- *
- * @param inode Inode concerned.
- * @param file File concerned.
- *
- * @return 0 on success, <0 on failure.
- */
-static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_ca_private *ca = dvbdev->priv;
- int err;
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (!try_module_get(ca->pub->owner))
- return -EIO;
-
- err = dvb_generic_open(inode, file);
- if (err < 0)
- return err;
-
- for (i = 0; i < ca->slot_count; i++) {
-
- if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
- if (ca->slot_info[i].rx_buffer.data != NULL) {
- /* it is safe to call this here without locks because
- * ca->open == 0. Data is not read in this case */
- dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer);
- }
- }
- }
-
- ca->open = 1;
- dvb_ca_en50221_thread_update_delay(ca);
- dvb_ca_en50221_thread_wakeup(ca);
-
- return 0;
-}
-
-
-/**
- * Implementation of file close syscall.
- *
- * @param inode Inode concerned.
- * @param file File concerned.
- *
- * @return 0 on success, <0 on failure.
- */
-static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_ca_private *ca = dvbdev->priv;
- int err = 0;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* mark the CA device as closed */
- ca->open = 0;
- dvb_ca_en50221_thread_update_delay(ca);
-
- err = dvb_generic_release(inode, file);
-
- module_put(ca->pub->owner);
-
- return 0;
-}
-
-
-/**
- * Implementation of poll() syscall.
- *
- * @param file File concerned.
- * @param wait poll wait table.
- *
- * @return Standard poll mask.
- */
-static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_ca_private *ca = dvbdev->priv;
- unsigned int mask = 0;
- int slot;
- int result = 0;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
- mask |= POLLIN;
- }
-
- /* if there is something, return now */
- if (mask)
- return mask;
-
- /* wait for something to happen */
- poll_wait(file, &ca->wait_queue, wait);
-
- if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
- mask |= POLLIN;
- }
-
- return mask;
-}
-EXPORT_SYMBOL(dvb_ca_en50221_init);
-
-
-static struct file_operations dvb_ca_fops = {
- .owner = THIS_MODULE,
- .read = dvb_ca_en50221_io_read,
- .write = dvb_ca_en50221_io_write,
- .ioctl = dvb_ca_en50221_io_ioctl,
- .open = dvb_ca_en50221_io_open,
- .release = dvb_ca_en50221_io_release,
- .poll = dvb_ca_en50221_io_poll,
-};
-
-static struct dvb_device dvbdev_ca = {
- .priv = NULL,
- .users = 1,
- .readers = 1,
- .writers = 1,
- .fops = &dvb_ca_fops,
-};
-
-
-/* ******************************************************************************** */
-/* Initialisation/shutdown functions */
-
-
-/**
- * Initialise a new DVB CA EN50221 interface device.
- *
- * @param dvb_adapter DVB adapter to attach the new CA device to.
- * @param ca The dvb_ca instance.
- * @param flags Flags describing the CA device (DVB_CA_FLAG_*).
- * @param slot_count Number of slots supported.
- *
- * @return 0 on success, nonzero on failure
- */
-int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
- struct dvb_ca_en50221 *pubca, int flags, int slot_count)
-{
- int ret;
- struct dvb_ca_private *ca = NULL;
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (slot_count < 1)
- return -EINVAL;
-
- /* initialise the system data */
- if ((ca = kzalloc(sizeof(struct dvb_ca_private), GFP_KERNEL)) == NULL) {
- ret = -ENOMEM;
- goto error;
- }
- ca->pub = pubca;
- ca->flags = flags;
- ca->slot_count = slot_count;
- if ((ca->slot_info = kcalloc(slot_count, sizeof(struct dvb_ca_slot), GFP_KERNEL)) == NULL) {
- ret = -ENOMEM;
- goto error;
- }
- init_waitqueue_head(&ca->wait_queue);
- ca->thread_pid = 0;
- init_waitqueue_head(&ca->thread_queue);
- ca->exit = 0;
- ca->open = 0;
- ca->wakeup = 0;
- ca->next_read_slot = 0;
- pubca->private = ca;
-
- /* register the DVB device */
- ret = dvb_register_device(dvb_adapter, &ca->dvbdev, &dvbdev_ca, ca, DVB_DEVICE_CA);
- if (ret)
- goto error;
-
- /* now initialise each slot */
- for (i = 0; i < slot_count; i++) {
- memset(&ca->slot_info[i], 0, sizeof(struct dvb_ca_slot));
- ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE;
- atomic_set(&ca->slot_info[i].camchange_count, 0);
- ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
- }
-
- if (signal_pending(current)) {
- ret = -EINTR;
- goto error;
- }
- mb();
-
- /* create a kthread for monitoring this CA device */
-
- ret = kernel_thread(dvb_ca_en50221_thread, ca, 0);
-
- if (ret < 0) {
- printk("dvb_ca_init: failed to start kernel_thread (%d)\n", ret);
- goto error;
- }
- ca->thread_pid = ret;
- return 0;
-
-error:
- if (ca != NULL) {
- if (ca->dvbdev != NULL)
- dvb_unregister_device(ca->dvbdev);
- kfree(ca->slot_info);
- kfree(ca);
- }
- pubca->private = NULL;
- return ret;
-}
-EXPORT_SYMBOL(dvb_ca_en50221_release);
-
-
-
-/**
- * Release a DVB CA EN50221 interface device.
- *
- * @param ca_dev The dvb_device_t instance for the CA device.
- * @param ca The associated dvb_ca instance.
- */
-void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
-{
- struct dvb_ca_private *ca = pubca->private;
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* shutdown the thread if there was one */
- if (ca->thread_pid) {
- if (kill_proc(ca->thread_pid, 0, 1) == -ESRCH) {
- printk("dvb_ca_release adapter %d: thread PID %d already died\n",
- ca->dvbdev->adapter->num, ca->thread_pid);
- } else {
- ca->exit = 1;
- mb();
- dvb_ca_en50221_thread_wakeup(ca);
- wait_event_interruptible(ca->thread_queue, ca->thread_pid == 0);
- }
- }
-
- for (i = 0; i < ca->slot_count; i++) {
- dvb_ca_en50221_slot_shutdown(ca, i);
- vfree(ca->slot_info[i].rx_buffer.data);
- }
- kfree(ca->slot_info);
- dvb_unregister_device(ca->dvbdev);
- kfree(ca);
- pubca->private = NULL;
-}
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h b/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
deleted file mode 100644
index 8467e63ddc0..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * dvb_ca.h: generic DVB functions for EN50221 CA interfaces
- *
- * Copyright (C) 2004 Andrew de Quincey
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _DVB_CA_EN50221_H_
-#define _DVB_CA_EN50221_H_
-
-#include <linux/list.h>
-#include <linux/dvb/ca.h>
-
-#include "dvbdev.h"
-
-#define DVB_CA_EN50221_POLL_CAM_PRESENT 1
-#define DVB_CA_EN50221_POLL_CAM_CHANGED 2
-#define DVB_CA_EN50221_POLL_CAM_READY 4
-
-#define DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE 1
-#define DVB_CA_EN50221_FLAG_IRQ_FR 2
-#define DVB_CA_EN50221_FLAG_IRQ_DA 4
-
-#define DVB_CA_EN50221_CAMCHANGE_REMOVED 0
-#define DVB_CA_EN50221_CAMCHANGE_INSERTED 1
-
-
-
-/* Structure describing a CA interface */
-struct dvb_ca_en50221 {
-
- /* the module owning this structure */
- struct module* owner;
-
- /* NOTE: the read_*, write_* and poll_slot_status functions must use locks as
- * they may be called from several threads at once */
-
- /* functions for accessing attribute memory on the CAM */
- int (*read_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address);
- int (*write_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address, u8 value);
-
- /* functions for accessing the control interface on the CAM */
- int (*read_cam_control)(struct dvb_ca_en50221* ca, int slot, u8 address);
- int (*write_cam_control)(struct dvb_ca_en50221* ca, int slot, u8 address, u8 value);
-
- /* Functions for controlling slots */
- int (*slot_reset)(struct dvb_ca_en50221* ca, int slot);
- int (*slot_shutdown)(struct dvb_ca_en50221* ca, int slot);
- int (*slot_ts_enable)(struct dvb_ca_en50221* ca, int slot);
-
- /*
- * Poll slot status.
- * Only necessary if DVB_CA_FLAG_EN50221_IRQ_CAMCHANGE is not set
- */
- int (*poll_slot_status)(struct dvb_ca_en50221* ca, int slot, int open);
-
- /* private data, used by caller */
- void* data;
-
- /* Opaque data used by the dvb_ca core. Do not modify! */
- void* private;
-};
-
-
-
-
-/* ******************************************************************************** */
-/* Functions for reporting IRQ events */
-
-/**
- * A CAMCHANGE IRQ has occurred.
- *
- * @param ca CA instance.
- * @param slot Slot concerned.
- * @param change_type One of the DVB_CA_CAMCHANGE_* values
- */
-void dvb_ca_en50221_camchange_irq(struct dvb_ca_en50221* pubca, int slot, int change_type);
-
-/**
- * A CAMREADY IRQ has occurred.
- *
- * @param ca CA instance.
- * @param slot Slot concerned.
- */
-void dvb_ca_en50221_camready_irq(struct dvb_ca_en50221* pubca, int slot);
-
-/**
- * An FR or a DA IRQ has occurred.
- *
- * @param ca CA instance.
- * @param slot Slot concerned.
- */
-void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221* ca, int slot);
-
-
-
-/* ******************************************************************************** */
-/* Initialisation/shutdown functions */
-
-/**
- * Initialise a new DVB CA device.
- *
- * @param dvb_adapter DVB adapter to attach the new CA device to.
- * @param ca The dvb_ca instance.
- * @param flags Flags describing the CA device (DVB_CA_EN50221_FLAG_*).
- * @param slot_count Number of slots supported.
- *
- * @return 0 on success, nonzero on failure
- */
-extern int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, struct dvb_ca_en50221* ca, int flags, int slot_count);
-
-/**
- * Release a DVB CA device.
- *
- * @param ca The associated dvb_ca instance.
- */
-extern void dvb_ca_en50221_release(struct dvb_ca_en50221* ca);
-
-
-
-#endif
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
deleted file mode 100644
index fcff5eab21a..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ /dev/null
@@ -1,1232 +0,0 @@
-/*
- * dvb_demux.c - DVB kernel demux API
- *
- * Copyright (C) 2000-2001 Ralph Metzler <ralph@convergence.de>
- * & Marcus Metzler <marcus@convergence.de>
- * for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/module.h>
-#include <linux/poll.h>
-#include <linux/string.h>
-#include <linux/crc32.h>
-#include <asm/uaccess.h>
-
-#include "dvb_demux.h"
-
-#define NOBUFS
-/*
-** #define DVB_DEMUX_SECTION_LOSS_LOG to monitor payload loss in the syslog
-*/
-// #define DVB_DEMUX_SECTION_LOSS_LOG
-
-/******************************************************************************
- * static inlined helper functions
- ******************************************************************************/
-
-static inline u16 section_length(const u8 *buf)
-{
- return 3 + ((buf[1] & 0x0f) << 8) + buf[2];
-}
-
-static inline u16 ts_pid(const u8 *buf)
-{
- return ((buf[1] & 0x1f) << 8) + buf[2];
-}
-
-static inline u8 payload(const u8 *tsp)
-{
- if (!(tsp[3] & 0x10)) // no payload?
- return 0;
-
- if (tsp[3] & 0x20) { // adaptation field?
- if (tsp[4] > 183) // corrupted data?
- return 0;
- else
- return 184 - 1 - tsp[4];
- }
-
- return 184;
-}
-
-static u32 dvb_dmx_crc32(struct dvb_demux_feed *f, const u8 *src, size_t len)
-{
- return (f->feed.sec.crc_val = crc32_be(f->feed.sec.crc_val, src, len));
-}
-
-static void dvb_dmx_memcopy(struct dvb_demux_feed *f, u8 *d, const u8 *s,
- size_t len)
-{
- memcpy(d, s, len);
-}
-
-/******************************************************************************
- * Software filter functions
- ******************************************************************************/
-
-static inline int dvb_dmx_swfilter_payload(struct dvb_demux_feed *feed,
- const u8 *buf)
-{
- int count = payload(buf);
- int p;
- //int ccok;
- //u8 cc;
-
- if (count == 0)
- return -1;
-
- p = 188 - count;
-
- /*
- cc = buf[3] & 0x0f;
- ccok = ((feed->cc + 1) & 0x0f) == cc;
- feed->cc = cc;
- if (!ccok)
- printk("missed packet!\n");
- */
-
- if (buf[1] & 0x40) // PUSI ?
- feed->peslen = 0xfffa;
-
- feed->peslen += count;
-
- return feed->cb.ts(&buf[p], count, NULL, 0, &feed->feed.ts, DMX_OK);
-}
-
-static int dvb_dmx_swfilter_sectionfilter(struct dvb_demux_feed *feed,
- struct dvb_demux_filter *f)
-{
- u8 neq = 0;
- int i;
-
- for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
- u8 xor = f->filter.filter_value[i] ^ feed->feed.sec.secbuf[i];
-
- if (f->maskandmode[i] & xor)
- return 0;
-
- neq |= f->maskandnotmode[i] & xor;
- }
-
- if (f->doneq && !neq)
- return 0;
-
- return feed->cb.sec(feed->feed.sec.secbuf, feed->feed.sec.seclen,
- NULL, 0, &f->filter, DMX_OK);
-}
-
-static inline int dvb_dmx_swfilter_section_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct dvb_demux_filter *f = feed->filter;
- struct dmx_section_feed *sec = &feed->feed.sec;
- int section_syntax_indicator;
-
- if (!sec->is_filtering)
- return 0;
-
- if (!f)
- return 0;
-
- if (sec->check_crc) {
- section_syntax_indicator = ((sec->secbuf[1] & 0x80) != 0);
- if (section_syntax_indicator &&
- demux->check_crc32(feed, sec->secbuf, sec->seclen))
- return -1;
- }
-
- do {
- if (dvb_dmx_swfilter_sectionfilter(feed, f) < 0)
- return -1;
- } while ((f = f->next) && sec->is_filtering);
-
- sec->seclen = 0;
-
- return 0;
-}
-
-static void dvb_dmx_swfilter_section_new(struct dvb_demux_feed *feed)
-{
- struct dmx_section_feed *sec = &feed->feed.sec;
-
-#ifdef DVB_DEMUX_SECTION_LOSS_LOG
- if (sec->secbufp < sec->tsfeedp) {
- int i, n = sec->tsfeedp - sec->secbufp;
-
- /*
- * Section padding is done with 0xff bytes entirely.
- * Due to speed reasons, we won't check all of them
- * but just first and last.
- */
- if (sec->secbuf[0] != 0xff || sec->secbuf[n - 1] != 0xff) {
- printk("dvb_demux.c section ts padding loss: %d/%d\n",
- n, sec->tsfeedp);
- printk("dvb_demux.c pad data:");
- for (i = 0; i < n; i++)
- printk(" %02x", sec->secbuf[i]);
- printk("\n");
- }
- }
-#endif
-
- sec->tsfeedp = sec->secbufp = sec->seclen = 0;
- sec->secbuf = sec->secbuf_base;
-}
-
-/*
- * Losless Section Demux 1.4.1 by Emard
- * Valsecchi Patrick:
- * - middle of section A (no PUSI)
- * - end of section A and start of section B
- * (with PUSI pointing to the start of the second section)
- *
- * In this case, without feed->pusi_seen you'll receive a garbage section
- * consisting of the end of section A. Basically because tsfeedp
- * is incemented and the use=0 condition is not raised
- * when the second packet arrives.
- *
- * Fix:
- * when demux is started, let feed->pusi_seen = 0 to
- * prevent initial feeding of garbage from the end of
- * previous section. When you for the first time see PUSI=1
- * then set feed->pusi_seen = 1
- */
-static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed,
- const u8 *buf, u8 len)
-{
- struct dvb_demux *demux = feed->demux;
- struct dmx_section_feed *sec = &feed->feed.sec;
- u16 limit, seclen, n;
-
- if (sec->tsfeedp >= DMX_MAX_SECFEED_SIZE)
- return 0;
-
- if (sec->tsfeedp + len > DMX_MAX_SECFEED_SIZE) {
-#ifdef DVB_DEMUX_SECTION_LOSS_LOG
- printk("dvb_demux.c section buffer full loss: %d/%d\n",
- sec->tsfeedp + len - DMX_MAX_SECFEED_SIZE,
- DMX_MAX_SECFEED_SIZE);
-#endif
- len = DMX_MAX_SECFEED_SIZE - sec->tsfeedp;
- }
-
- if (len <= 0)
- return 0;
-
- demux->memcopy(feed, sec->secbuf_base + sec->tsfeedp, buf, len);
- sec->tsfeedp += len;
-
- /*
- * Dump all the sections we can find in the data (Emard)
- */
- limit = sec->tsfeedp;
- if (limit > DMX_MAX_SECFEED_SIZE)
- return -1; /* internal error should never happen */
-
- /* to be sure always set secbuf */
- sec->secbuf = sec->secbuf_base + sec->secbufp;
-
- for (n = 0; sec->secbufp + 2 < limit; n++) {
- seclen = section_length(sec->secbuf);
- if (seclen <= 0 || seclen > DMX_MAX_SECTION_SIZE
- || seclen + sec->secbufp > limit)
- return 0;
- sec->seclen = seclen;
- sec->crc_val = ~0;
- /* dump [secbuf .. secbuf+seclen) */
- if (feed->pusi_seen)
- dvb_dmx_swfilter_section_feed(feed);
-#ifdef DVB_DEMUX_SECTION_LOSS_LOG
- else
- printk("dvb_demux.c pusi not seen, discarding section data\n");
-#endif
- sec->secbufp += seclen; /* secbufp and secbuf moving together is */
- sec->secbuf += seclen; /* redundant but saves pointer arithmetic */
- }
-
- return 0;
-}
-
-static int dvb_dmx_swfilter_section_packet(struct dvb_demux_feed *feed,
- const u8 *buf)
-{
- u8 p, count;
- int ccok, dc_i = 0;
- u8 cc;
-
- count = payload(buf);
-
- if (count == 0) /* count == 0 if no payload or out of range */
- return -1;
-
- p = 188 - count; /* payload start */
-
- cc = buf[3] & 0x0f;
- ccok = ((feed->cc + 1) & 0x0f) == cc;
- feed->cc = cc;
-
- if (buf[3] & 0x20) {
- /* adaption field present, check for discontinuity_indicator */
- if ((buf[4] > 0) && (buf[5] & 0x80))
- dc_i = 1;
- }
-
- if (!ccok || dc_i) {
-#ifdef DVB_DEMUX_SECTION_LOSS_LOG
- printk("dvb_demux.c discontinuity detected %d bytes lost\n",
- count);
- /*
- * those bytes under sume circumstances will again be reported
- * in the following dvb_dmx_swfilter_section_new
- */
-#endif
- /*
- * Discontinuity detected. Reset pusi_seen = 0 to
- * stop feeding of suspicious data until next PUSI=1 arrives
- */
- feed->pusi_seen = 0;
- dvb_dmx_swfilter_section_new(feed);
- }
-
- if (buf[1] & 0x40) {
- /* PUSI=1 (is set), section boundary is here */
- if (count > 1 && buf[p] < count) {
- const u8 *before = &buf[p + 1];
- u8 before_len = buf[p];
- const u8 *after = &before[before_len];
- u8 after_len = count - 1 - before_len;
-
- dvb_dmx_swfilter_section_copy_dump(feed, before,
- before_len);
- /* before start of new section, set pusi_seen = 1 */
- feed->pusi_seen = 1;
- dvb_dmx_swfilter_section_new(feed);
- dvb_dmx_swfilter_section_copy_dump(feed, after,
- after_len);
- }
-#ifdef DVB_DEMUX_SECTION_LOSS_LOG
- else if (count > 0)
- printk("dvb_demux.c PUSI=1 but %d bytes lost\n", count);
-#endif
- } else {
- /* PUSI=0 (is not set), no section boundary */
- dvb_dmx_swfilter_section_copy_dump(feed, &buf[p], count);
- }
-
- return 0;
-}
-
-static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed,
- const u8 *buf)
-{
- switch (feed->type) {
- case DMX_TYPE_TS:
- if (!feed->feed.ts.is_filtering)
- break;
- if (feed->ts_type & TS_PACKET) {
- if (feed->ts_type & TS_PAYLOAD_ONLY)
- dvb_dmx_swfilter_payload(feed, buf);
- else
- feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts,
- DMX_OK);
- }
- if (feed->ts_type & TS_DECODER)
- if (feed->demux->write_to_decoder)
- feed->demux->write_to_decoder(feed, buf, 188);
- break;
-
- case DMX_TYPE_SEC:
- if (!feed->feed.sec.is_filtering)
- break;
- if (dvb_dmx_swfilter_section_packet(feed, buf) < 0)
- feed->feed.sec.seclen = feed->feed.sec.secbufp = 0;
- break;
-
- default:
- break;
- }
-}
-
-#define DVR_FEED(f) \
- (((f)->type == DMX_TYPE_TS) && \
- ((f)->feed.ts.is_filtering) && \
- (((f)->ts_type & (TS_PACKET|TS_PAYLOAD_ONLY)) == TS_PACKET))
-
-static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
-{
- struct dvb_demux_feed *feed;
- struct list_head *pos, *head = &demux->feed_list;
- u16 pid = ts_pid(buf);
- int dvr_done = 0;
-
- list_for_each(pos, head) {
- feed = list_entry(pos, struct dvb_demux_feed, list_head);
-
- if ((feed->pid != pid) && (feed->pid != 0x2000))
- continue;
-
- /* copy each packet only once to the dvr device, even
- * if a PID is in multiple filters (e.g. video + PCR) */
- if ((DVR_FEED(feed)) && (dvr_done++))
- continue;
-
- if (feed->pid == pid) {
- dvb_dmx_swfilter_packet_type(feed, buf);
- if (DVR_FEED(feed))
- continue;
- }
-
- if (feed->pid == 0x2000)
- feed->cb.ts(buf, 188, NULL, 0, &feed->feed.ts, DMX_OK);
- }
-}
-
-void dvb_dmx_swfilter_packets(struct dvb_demux *demux, const u8 *buf,
- size_t count)
-{
- spin_lock(&demux->lock);
-
- while (count--) {
- if (buf[0] == 0x47)
- dvb_dmx_swfilter_packet(demux, buf);
- buf += 188;
- }
-
- spin_unlock(&demux->lock);
-}
-
-EXPORT_SYMBOL(dvb_dmx_swfilter_packets);
-
-void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count)
-{
- int p = 0, i, j;
-
- spin_lock(&demux->lock);
-
- if (demux->tsbufp) {
- i = demux->tsbufp;
- j = 188 - i;
- if (count < j) {
- memcpy(&demux->tsbuf[i], buf, count);
- demux->tsbufp += count;
- goto bailout;
- }
- memcpy(&demux->tsbuf[i], buf, j);
- if (demux->tsbuf[0] == 0x47)
- dvb_dmx_swfilter_packet(demux, demux->tsbuf);
- demux->tsbufp = 0;
- p += j;
- }
-
- while (p < count) {
- if (buf[p] == 0x47) {
- if (count - p >= 188) {
- dvb_dmx_swfilter_packet(demux, &buf[p]);
- p += 188;
- } else {
- i = count - p;
- memcpy(demux->tsbuf, &buf[p], i);
- demux->tsbufp = i;
- goto bailout;
- }
- } else
- p++;
- }
-
-bailout:
- spin_unlock(&demux->lock);
-}
-
-EXPORT_SYMBOL(dvb_dmx_swfilter);
-
-void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf, size_t count)
-{
- int p = 0, i, j;
- u8 tmppack[188];
-
- spin_lock(&demux->lock);
-
- if (demux->tsbufp) {
- i = demux->tsbufp;
- j = 204 - i;
- if (count < j) {
- memcpy(&demux->tsbuf[i], buf, count);
- demux->tsbufp += count;
- goto bailout;
- }
- memcpy(&demux->tsbuf[i], buf, j);
- if ((demux->tsbuf[0] == 0x47) || (demux->tsbuf[0] == 0xB8)) {
- memcpy(tmppack, demux->tsbuf, 188);
- if (tmppack[0] == 0xB8)
- tmppack[0] = 0x47;
- dvb_dmx_swfilter_packet(demux, tmppack);
- }
- demux->tsbufp = 0;
- p += j;
- }
-
- while (p < count) {
- if ((buf[p] == 0x47) || (buf[p] == 0xB8)) {
- if (count - p >= 204) {
- memcpy(tmppack, &buf[p], 188);
- if (tmppack[0] == 0xB8)
- tmppack[0] = 0x47;
- dvb_dmx_swfilter_packet(demux, tmppack);
- p += 204;
- } else {
- i = count - p;
- memcpy(demux->tsbuf, &buf[p], i);
- demux->tsbufp = i;
- goto bailout;
- }
- } else {
- p++;
- }
- }
-
-bailout:
- spin_unlock(&demux->lock);
-}
-
-EXPORT_SYMBOL(dvb_dmx_swfilter_204);
-
-static struct dvb_demux_filter *dvb_dmx_filter_alloc(struct dvb_demux *demux)
-{
- int i;
-
- for (i = 0; i < demux->filternum; i++)
- if (demux->filter[i].state == DMX_STATE_FREE)
- break;
-
- if (i == demux->filternum)
- return NULL;
-
- demux->filter[i].state = DMX_STATE_ALLOCATED;
-
- return &demux->filter[i];
-}
-
-static struct dvb_demux_feed *dvb_dmx_feed_alloc(struct dvb_demux *demux)
-{
- int i;
-
- for (i = 0; i < demux->feednum; i++)
- if (demux->feed[i].state == DMX_STATE_FREE)
- break;
-
- if (i == demux->feednum)
- return NULL;
-
- demux->feed[i].state = DMX_STATE_ALLOCATED;
-
- return &demux->feed[i];
-}
-
-static int dvb_demux_feed_find(struct dvb_demux_feed *feed)
-{
- struct dvb_demux_feed *entry;
-
- list_for_each_entry(entry, &feed->demux->feed_list, list_head)
- if (entry == feed)
- return 1;
-
- return 0;
-}
-
-static void dvb_demux_feed_add(struct dvb_demux_feed *feed)
-{
- spin_lock_irq(&feed->demux->lock);
- if (dvb_demux_feed_find(feed)) {
- printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n",
- __FUNCTION__, feed->type, feed->state, feed->pid);
- goto out;
- }
-
- list_add(&feed->list_head, &feed->demux->feed_list);
-out:
- spin_unlock_irq(&feed->demux->lock);
-}
-
-static void dvb_demux_feed_del(struct dvb_demux_feed *feed)
-{
- spin_lock_irq(&feed->demux->lock);
- if (!(dvb_demux_feed_find(feed))) {
- printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n",
- __FUNCTION__, feed->type, feed->state, feed->pid);
- goto out;
- }
-
- list_del(&feed->list_head);
-out:
- spin_unlock_irq(&feed->demux->lock);
-}
-
-static int dmx_ts_feed_set(struct dmx_ts_feed *ts_feed, u16 pid, int ts_type,
- enum dmx_ts_pes pes_type,
- size_t circular_buffer_size, struct timespec timeout)
-{
- struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
- struct dvb_demux *demux = feed->demux;
-
- if (pid > DMX_MAX_PID)
- return -EINVAL;
-
- if (mutex_lock_interruptible(&demux->mutex))
- return -ERESTARTSYS;
-
- if (ts_type & TS_DECODER) {
- if (pes_type >= DMX_TS_PES_OTHER) {
- mutex_unlock(&demux->mutex);
- return -EINVAL;
- }
-
- if (demux->pesfilter[pes_type] &&
- demux->pesfilter[pes_type] != feed) {
- mutex_unlock(&demux->mutex);
- return -EINVAL;
- }
-
- demux->pesfilter[pes_type] = feed;
- demux->pids[pes_type] = pid;
- }
-
- dvb_demux_feed_add(feed);
-
- feed->pid = pid;
- feed->buffer_size = circular_buffer_size;
- feed->timeout = timeout;
- feed->ts_type = ts_type;
- feed->pes_type = pes_type;
-
- if (feed->buffer_size) {
-#ifdef NOBUFS
- feed->buffer = NULL;
-#else
- feed->buffer = vmalloc(feed->buffer_size);
- if (!feed->buffer) {
- mutex_unlock(&demux->mutex);
- return -ENOMEM;
- }
-#endif
- }
-
- feed->state = DMX_STATE_READY;
- mutex_unlock(&demux->mutex);
-
- return 0;
-}
-
-static int dmx_ts_feed_start_filtering(struct dmx_ts_feed *ts_feed)
-{
- struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
- struct dvb_demux *demux = feed->demux;
- int ret;
-
- if (mutex_lock_interruptible(&demux->mutex))
- return -ERESTARTSYS;
-
- if (feed->state != DMX_STATE_READY || feed->type != DMX_TYPE_TS) {
- mutex_unlock(&demux->mutex);
- return -EINVAL;
- }
-
- if (!demux->start_feed) {
- mutex_unlock(&demux->mutex);
- return -ENODEV;
- }
-
- if ((ret = demux->start_feed(feed)) < 0) {
- mutex_unlock(&demux->mutex);
- return ret;
- }
-
- spin_lock_irq(&demux->lock);
- ts_feed->is_filtering = 1;
- feed->state = DMX_STATE_GO;
- spin_unlock_irq(&demux->lock);
- mutex_unlock(&demux->mutex);
-
- return 0;
-}
-
-static int dmx_ts_feed_stop_filtering(struct dmx_ts_feed *ts_feed)
-{
- struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
- struct dvb_demux *demux = feed->demux;
- int ret;
-
- if (mutex_lock_interruptible(&demux->mutex))
- return -ERESTARTSYS;
-
- if (feed->state < DMX_STATE_GO) {
- mutex_unlock(&demux->mutex);
- return -EINVAL;
- }
-
- if (!demux->stop_feed) {
- mutex_unlock(&demux->mutex);
- return -ENODEV;
- }
-
- ret = demux->stop_feed(feed);
-
- spin_lock_irq(&demux->lock);
- ts_feed->is_filtering = 0;
- feed->state = DMX_STATE_ALLOCATED;
- spin_unlock_irq(&demux->lock);
- mutex_unlock(&demux->mutex);
-
- return ret;
-}
-
-static int dvbdmx_allocate_ts_feed(struct dmx_demux *dmx,
- struct dmx_ts_feed **ts_feed,
- dmx_ts_cb callback)
-{
- struct dvb_demux *demux = (struct dvb_demux *)dmx;
- struct dvb_demux_feed *feed;
-
- if (mutex_lock_interruptible(&demux->mutex))
- return -ERESTARTSYS;
-
- if (!(feed = dvb_dmx_feed_alloc(demux))) {
- mutex_unlock(&demux->mutex);
- return -EBUSY;
- }
-
- feed->type = DMX_TYPE_TS;
- feed->cb.ts = callback;
- feed->demux = demux;
- feed->pid = 0xffff;
- feed->peslen = 0xfffa;
- feed->buffer = NULL;
-
- (*ts_feed) = &feed->feed.ts;
- (*ts_feed)->parent = dmx;
- (*ts_feed)->priv = NULL;
- (*ts_feed)->is_filtering = 0;
- (*ts_feed)->start_filtering = dmx_ts_feed_start_filtering;
- (*ts_feed)->stop_filtering = dmx_ts_feed_stop_filtering;
- (*ts_feed)->set = dmx_ts_feed_set;
-
- if (!(feed->filter = dvb_dmx_filter_alloc(demux))) {
- feed->state = DMX_STATE_FREE;
- mutex_unlock(&demux->mutex);
- return -EBUSY;
- }
-
- feed->filter->type = DMX_TYPE_TS;
- feed->filter->feed = feed;
- feed->filter->state = DMX_STATE_READY;
-
- mutex_unlock(&demux->mutex);
-
- return 0;
-}
-
-static int dvbdmx_release_ts_feed(struct dmx_demux *dmx,
- struct dmx_ts_feed *ts_feed)
-{
- struct dvb_demux *demux = (struct dvb_demux *)dmx;
- struct dvb_demux_feed *feed = (struct dvb_demux_feed *)ts_feed;
-
- if (mutex_lock_interruptible(&demux->mutex))
- return -ERESTARTSYS;
-
- if (feed->state == DMX_STATE_FREE) {
- mutex_unlock(&demux->mutex);
- return -EINVAL;
- }
-#ifndef NOBUFS
- vfree(feed->buffer);
- feed->buffer = NULL;
-#endif
-
- feed->state = DMX_STATE_FREE;
- feed->filter->state = DMX_STATE_FREE;
-
- dvb_demux_feed_del(feed);
-
- feed->pid = 0xffff;
-
- if (feed->ts_type & TS_DECODER && feed->pes_type < DMX_TS_PES_OTHER)
- demux->pesfilter[feed->pes_type] = NULL;
-
- mutex_unlock(&demux->mutex);
- return 0;
-}
-
-/******************************************************************************
- * dmx_section_feed API calls
- ******************************************************************************/
-
-static int dmx_section_feed_allocate_filter(struct dmx_section_feed *feed,
- struct dmx_section_filter **filter)
-{
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
- struct dvb_demux *dvbdemux = dvbdmxfeed->demux;
- struct dvb_demux_filter *dvbdmxfilter;
-
- if (mutex_lock_interruptible(&dvbdemux->mutex))
- return -ERESTARTSYS;
-
- dvbdmxfilter = dvb_dmx_filter_alloc(dvbdemux);
- if (!dvbdmxfilter) {
- mutex_unlock(&dvbdemux->mutex);
- return -EBUSY;
- }
-
- spin_lock_irq(&dvbdemux->lock);
- *filter = &dvbdmxfilter->filter;
- (*filter)->parent = feed;
- (*filter)->priv = NULL;
- dvbdmxfilter->feed = dvbdmxfeed;
- dvbdmxfilter->type = DMX_TYPE_SEC;
- dvbdmxfilter->state = DMX_STATE_READY;
- dvbdmxfilter->next = dvbdmxfeed->filter;
- dvbdmxfeed->filter = dvbdmxfilter;
- spin_unlock_irq(&dvbdemux->lock);
-
- mutex_unlock(&dvbdemux->mutex);
- return 0;
-}
-
-static int dmx_section_feed_set(struct dmx_section_feed *feed,
- u16 pid, size_t circular_buffer_size,
- int check_crc)
-{
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
-
- if (pid > 0x1fff)
- return -EINVAL;
-
- if (mutex_lock_interruptible(&dvbdmx->mutex))
- return -ERESTARTSYS;
-
- dvb_demux_feed_add(dvbdmxfeed);
-
- dvbdmxfeed->pid = pid;
- dvbdmxfeed->buffer_size = circular_buffer_size;
- dvbdmxfeed->feed.sec.check_crc = check_crc;
-
-#ifdef NOBUFS
- dvbdmxfeed->buffer = NULL;
-#else
- dvbdmxfeed->buffer = vmalloc(dvbdmxfeed->buffer_size);
- if (!dvbdmxfeed->buffer) {
- mutex_unlock(&dvbdmx->mutex);
- return -ENOMEM;
- }
-#endif
-
- dvbdmxfeed->state = DMX_STATE_READY;
- mutex_unlock(&dvbdmx->mutex);
- return 0;
-}
-
-static void prepare_secfilters(struct dvb_demux_feed *dvbdmxfeed)
-{
- int i;
- struct dvb_demux_filter *f;
- struct dmx_section_filter *sf;
- u8 mask, mode, doneq;
-
- if (!(f = dvbdmxfeed->filter))
- return;
- do {
- sf = &f->filter;
- doneq = 0;
- for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
- mode = sf->filter_mode[i];
- mask = sf->filter_mask[i];
- f->maskandmode[i] = mask & mode;
- doneq |= f->maskandnotmode[i] = mask & ~mode;
- }
- f->doneq = doneq ? 1 : 0;
- } while ((f = f->next));
-}
-
-static int dmx_section_feed_start_filtering(struct dmx_section_feed *feed)
-{
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
- int ret;
-
- if (mutex_lock_interruptible(&dvbdmx->mutex))
- return -ERESTARTSYS;
-
- if (feed->is_filtering) {
- mutex_unlock(&dvbdmx->mutex);
- return -EBUSY;
- }
-
- if (!dvbdmxfeed->filter) {
- mutex_unlock(&dvbdmx->mutex);
- return -EINVAL;
- }
-
- dvbdmxfeed->feed.sec.tsfeedp = 0;
- dvbdmxfeed->feed.sec.secbuf = dvbdmxfeed->feed.sec.secbuf_base;
- dvbdmxfeed->feed.sec.secbufp = 0;
- dvbdmxfeed->feed.sec.seclen = 0;
-
- if (!dvbdmx->start_feed) {
- mutex_unlock(&dvbdmx->mutex);
- return -ENODEV;
- }
-
- prepare_secfilters(dvbdmxfeed);
-
- if ((ret = dvbdmx->start_feed(dvbdmxfeed)) < 0) {
- mutex_unlock(&dvbdmx->mutex);
- return ret;
- }
-
- spin_lock_irq(&dvbdmx->lock);
- feed->is_filtering = 1;
- dvbdmxfeed->state = DMX_STATE_GO;
- spin_unlock_irq(&dvbdmx->lock);
-
- mutex_unlock(&dvbdmx->mutex);
- return 0;
-}
-
-static int dmx_section_feed_stop_filtering(struct dmx_section_feed *feed)
-{
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
- int ret;
-
- if (mutex_lock_interruptible(&dvbdmx->mutex))
- return -ERESTARTSYS;
-
- if (!dvbdmx->stop_feed) {
- mutex_unlock(&dvbdmx->mutex);
- return -ENODEV;
- }
-
- ret = dvbdmx->stop_feed(dvbdmxfeed);
-
- spin_lock_irq(&dvbdmx->lock);
- dvbdmxfeed->state = DMX_STATE_READY;
- feed->is_filtering = 0;
- spin_unlock_irq(&dvbdmx->lock);
-
- mutex_unlock(&dvbdmx->mutex);
- return ret;
-}
-
-static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
- struct dmx_section_filter *filter)
-{
- struct dvb_demux_filter *dvbdmxfilter = (struct dvb_demux_filter *)filter, *f;
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
-
- if (mutex_lock_interruptible(&dvbdmx->mutex))
- return -ERESTARTSYS;
-
- if (dvbdmxfilter->feed != dvbdmxfeed) {
- mutex_unlock(&dvbdmx->mutex);
- return -EINVAL;
- }
-
- if (feed->is_filtering)
- feed->stop_filtering(feed);
-
- spin_lock_irq(&dvbdmx->lock);
- f = dvbdmxfeed->filter;
-
- if (f == dvbdmxfilter) {
- dvbdmxfeed->filter = dvbdmxfilter->next;
- } else {
- while (f->next != dvbdmxfilter)
- f = f->next;
- f->next = f->next->next;
- }
-
- dvbdmxfilter->state = DMX_STATE_FREE;
- spin_unlock_irq(&dvbdmx->lock);
- mutex_unlock(&dvbdmx->mutex);
- return 0;
-}
-
-static int dvbdmx_allocate_section_feed(struct dmx_demux *demux,
- struct dmx_section_feed **feed,
- dmx_section_cb callback)
-{
- struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
- struct dvb_demux_feed *dvbdmxfeed;
-
- if (mutex_lock_interruptible(&dvbdmx->mutex))
- return -ERESTARTSYS;
-
- if (!(dvbdmxfeed = dvb_dmx_feed_alloc(dvbdmx))) {
- mutex_unlock(&dvbdmx->mutex);
- return -EBUSY;
- }
-
- dvbdmxfeed->type = DMX_TYPE_SEC;
- dvbdmxfeed->cb.sec = callback;
- dvbdmxfeed->demux = dvbdmx;
- dvbdmxfeed->pid = 0xffff;
- dvbdmxfeed->feed.sec.secbuf = dvbdmxfeed->feed.sec.secbuf_base;
- dvbdmxfeed->feed.sec.secbufp = dvbdmxfeed->feed.sec.seclen = 0;
- dvbdmxfeed->feed.sec.tsfeedp = 0;
- dvbdmxfeed->filter = NULL;
- dvbdmxfeed->buffer = NULL;
-
- (*feed) = &dvbdmxfeed->feed.sec;
- (*feed)->is_filtering = 0;
- (*feed)->parent = demux;
- (*feed)->priv = NULL;
-
- (*feed)->set = dmx_section_feed_set;
- (*feed)->allocate_filter = dmx_section_feed_allocate_filter;
- (*feed)->start_filtering = dmx_section_feed_start_filtering;
- (*feed)->stop_filtering = dmx_section_feed_stop_filtering;
- (*feed)->release_filter = dmx_section_feed_release_filter;
-
- mutex_unlock(&dvbdmx->mutex);
- return 0;
-}
-
-static int dvbdmx_release_section_feed(struct dmx_demux *demux,
- struct dmx_section_feed *feed)
-{
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *)feed;
- struct dvb_demux *dvbdmx = (struct dvb_demux *)demux;
-
- if (mutex_lock_interruptible(&dvbdmx->mutex))
- return -ERESTARTSYS;
-
- if (dvbdmxfeed->state == DMX_STATE_FREE) {
- mutex_unlock(&dvbdmx->mutex);
- return -EINVAL;
- }
-#ifndef NOBUFS
- vfree(dvbdmxfeed->buffer);
- dvbdmxfeed->buffer = NULL;
-#endif
- dvbdmxfeed->state = DMX_STATE_FREE;
-
- dvb_demux_feed_del(dvbdmxfeed);
-
- dvbdmxfeed->pid = 0xffff;
-
- mutex_unlock(&dvbdmx->mutex);
- return 0;
-}
-
-/******************************************************************************
- * dvb_demux kernel data API calls
- ******************************************************************************/
-
-static int dvbdmx_open(struct dmx_demux *demux)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
-
- if (dvbdemux->users >= MAX_DVB_DEMUX_USERS)
- return -EUSERS;
-
- dvbdemux->users++;
- return 0;
-}
-
-static int dvbdmx_close(struct dmx_demux *demux)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
-
- if (dvbdemux->users == 0)
- return -ENODEV;
-
- dvbdemux->users--;
- //FIXME: release any unneeded resources if users==0
- return 0;
-}
-
-static int dvbdmx_write(struct dmx_demux *demux, const char *buf, size_t count)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
-
- if ((!demux->frontend) || (demux->frontend->source != DMX_MEMORY_FE))
- return -EINVAL;
-
- if (mutex_lock_interruptible(&dvbdemux->mutex))
- return -ERESTARTSYS;
- dvb_dmx_swfilter(dvbdemux, buf, count);
- mutex_unlock(&dvbdemux->mutex);
-
- if (signal_pending(current))
- return -EINTR;
- return count;
-}
-
-static int dvbdmx_add_frontend(struct dmx_demux *demux,
- struct dmx_frontend *frontend)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
- struct list_head *head = &dvbdemux->frontend_list;
-
- list_add(&(frontend->connectivity_list), head);
-
- return 0;
-}
-
-static int dvbdmx_remove_frontend(struct dmx_demux *demux,
- struct dmx_frontend *frontend)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
- struct list_head *pos, *n, *head = &dvbdemux->frontend_list;
-
- list_for_each_safe(pos, n, head) {
- if (DMX_FE_ENTRY(pos) == frontend) {
- list_del(pos);
- return 0;
- }
- }
-
- return -ENODEV;
-}
-
-static struct list_head *dvbdmx_get_frontends(struct dmx_demux *demux)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
-
- if (list_empty(&dvbdemux->frontend_list))
- return NULL;
-
- return &dvbdemux->frontend_list;
-}
-
-static int dvbdmx_connect_frontend(struct dmx_demux *demux,
- struct dmx_frontend *frontend)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
-
- if (demux->frontend)
- return -EINVAL;
-
- if (mutex_lock_interruptible(&dvbdemux->mutex))
- return -ERESTARTSYS;
-
- demux->frontend = frontend;
- mutex_unlock(&dvbdemux->mutex);
- return 0;
-}
-
-static int dvbdmx_disconnect_frontend(struct dmx_demux *demux)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
-
- if (mutex_lock_interruptible(&dvbdemux->mutex))
- return -ERESTARTSYS;
-
- demux->frontend = NULL;
- mutex_unlock(&dvbdemux->mutex);
- return 0;
-}
-
-static int dvbdmx_get_pes_pids(struct dmx_demux *demux, u16 * pids)
-{
- struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
-
- memcpy(pids, dvbdemux->pids, 5 * sizeof(u16));
- return 0;
-}
-
-int dvb_dmx_init(struct dvb_demux *dvbdemux)
-{
- int i;
- struct dmx_demux *dmx = &dvbdemux->dmx;
-
- dvbdemux->users = 0;
- dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter));
-
- if (!dvbdemux->filter)
- return -ENOMEM;
-
- dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed));
- if (!dvbdemux->feed) {
- vfree(dvbdemux->filter);
- return -ENOMEM;
- }
- for (i = 0; i < dvbdemux->filternum; i++) {
- dvbdemux->filter[i].state = DMX_STATE_FREE;
- dvbdemux->filter[i].index = i;
- }
- for (i = 0; i < dvbdemux->feednum; i++) {
- dvbdemux->feed[i].state = DMX_STATE_FREE;
- dvbdemux->feed[i].index = i;
- }
-
- INIT_LIST_HEAD(&dvbdemux->frontend_list);
-
- for (i = 0; i < DMX_TS_PES_OTHER; i++) {
- dvbdemux->pesfilter[i] = NULL;
- dvbdemux->pids[i] = 0xffff;
- }
-
- INIT_LIST_HEAD(&dvbdemux->feed_list);
-
- dvbdemux->playing = 0;
- dvbdemux->recording = 0;
- dvbdemux->tsbufp = 0;
-
- if (!dvbdemux->check_crc32)
- dvbdemux->check_crc32 = dvb_dmx_crc32;
-
- if (!dvbdemux->memcopy)
- dvbdemux->memcopy = dvb_dmx_memcopy;
-
- dmx->frontend = NULL;
- dmx->priv = dvbdemux;
- dmx->open = dvbdmx_open;
- dmx->close = dvbdmx_close;
- dmx->write = dvbdmx_write;
- dmx->allocate_ts_feed = dvbdmx_allocate_ts_feed;
- dmx->release_ts_feed = dvbdmx_release_ts_feed;
- dmx->allocate_section_feed = dvbdmx_allocate_section_feed;
- dmx->release_section_feed = dvbdmx_release_section_feed;
-
- dmx->add_frontend = dvbdmx_add_frontend;
- dmx->remove_frontend = dvbdmx_remove_frontend;
- dmx->get_frontends = dvbdmx_get_frontends;
- dmx->connect_frontend = dvbdmx_connect_frontend;
- dmx->disconnect_frontend = dvbdmx_disconnect_frontend;
- dmx->get_pes_pids = dvbdmx_get_pes_pids;
-
- mutex_init(&dvbdemux->mutex);
- spin_lock_init(&dvbdemux->lock);
-
- return 0;
-}
-
-EXPORT_SYMBOL(dvb_dmx_init);
-
-void dvb_dmx_release(struct dvb_demux *dvbdemux)
-{
- vfree(dvbdemux->filter);
- vfree(dvbdemux->feed);
-}
-
-EXPORT_SYMBOL(dvb_dmx_release);
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.h b/drivers/media/dvb/dvb-core/dvb_demux.h
deleted file mode 100644
index 2c5f915329c..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_demux.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * dvb_demux.h: DVB kernel demux API
- *
- * Copyright (C) 2000-2001 Marcus Metzler & Ralph Metzler
- * for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _DVB_DEMUX_H_
-#define _DVB_DEMUX_H_
-
-#include <linux/time.h>
-#include <linux/timer.h>
-#include <linux/spinlock.h>
-#include <linux/mutex.h>
-
-#include "demux.h"
-
-#define DMX_TYPE_TS 0
-#define DMX_TYPE_SEC 1
-#define DMX_TYPE_PES 2
-
-#define DMX_STATE_FREE 0
-#define DMX_STATE_ALLOCATED 1
-#define DMX_STATE_SET 2
-#define DMX_STATE_READY 3
-#define DMX_STATE_GO 4
-
-#define DVB_DEMUX_MASK_MAX 18
-
-struct dvb_demux_filter {
- struct dmx_section_filter filter;
- u8 maskandmode[DMX_MAX_FILTER_SIZE];
- u8 maskandnotmode[DMX_MAX_FILTER_SIZE];
- int doneq;
-
- struct dvb_demux_filter *next;
- struct dvb_demux_feed *feed;
- int index;
- int state;
- int type;
-
- u16 hw_handle;
- struct timer_list timer;
-};
-
-#define DMX_FEED_ENTRY(pos) list_entry(pos, struct dvb_demux_feed, list_head)
-
-struct dvb_demux_feed {
- union {
- struct dmx_ts_feed ts;
- struct dmx_section_feed sec;
- } feed;
-
- union {
- dmx_ts_cb ts;
- dmx_section_cb sec;
- } cb;
-
- struct dvb_demux *demux;
- void *priv;
- int type;
- int state;
- u16 pid;
- u8 *buffer;
- int buffer_size;
-
- struct timespec timeout;
- struct dvb_demux_filter *filter;
-
- int ts_type;
- enum dmx_ts_pes pes_type;
-
- int cc;
- int pusi_seen; /* prevents feeding of garbage from previous section */
-
- u16 peslen;
-
- struct list_head list_head;
- unsigned int index; /* a unique index for each feed (can be used as hardware pid filter index) */
-};
-
-struct dvb_demux {
- struct dmx_demux dmx;
- void *priv;
- int filternum;
- int feednum;
- int (*start_feed)(struct dvb_demux_feed *feed);
- int (*stop_feed)(struct dvb_demux_feed *feed);
- int (*write_to_decoder)(struct dvb_demux_feed *feed,
- const u8 *buf, size_t len);
- u32 (*check_crc32)(struct dvb_demux_feed *feed,
- const u8 *buf, size_t len);
- void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst,
- const u8 *src, size_t len);
-
- int users;
-#define MAX_DVB_DEMUX_USERS 10
- struct dvb_demux_filter *filter;
- struct dvb_demux_feed *feed;
-
- struct list_head frontend_list;
-
- struct dvb_demux_feed *pesfilter[DMX_TS_PES_OTHER];
- u16 pids[DMX_TS_PES_OTHER];
- int playing;
- int recording;
-
-#define DMX_MAX_PID 0x2000
- struct list_head feed_list;
- u8 tsbuf[204];
- int tsbufp;
-
- struct mutex mutex;
- spinlock_t lock;
-};
-
-int dvb_dmx_init(struct dvb_demux *dvbdemux);
-void dvb_dmx_release(struct dvb_demux *dvbdemux);
-void dvb_dmx_swfilter_packets(struct dvb_demux *dvbdmx, const u8 *buf,
- size_t count);
-void dvb_dmx_swfilter(struct dvb_demux *demux, const u8 *buf, size_t count);
-void dvb_dmx_swfilter_204(struct dvb_demux *demux, const u8 *buf,
- size_t count);
-
-#endif /* _DVB_DEMUX_H_ */
diff --git a/drivers/media/dvb/dvb-core/dvb_filter.c b/drivers/media/dvb/dvb-core/dvb_filter.c
deleted file mode 100644
index 772003fb182..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_filter.c
+++ /dev/null
@@ -1,603 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include "dvb_filter.h"
-
-#if 0
-static unsigned int bitrates[3][16] =
-{{0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,0},
- {0,32,48,56,64,80,96,112,128,160,192,224,256,320,384,0},
- {0,32,40,48,56,64,80,96,112,128,160,192,224,256,320,0}};
-#endif
-
-static u32 freq[4] = {480, 441, 320, 0};
-
-static unsigned int ac3_bitrates[32] =
- {32,40,48,56,64,80,96,112,128,160,192,224,256,320,384,448,512,576,640,
- 0,0,0,0,0,0,0,0,0,0,0,0,0};
-
-static u32 ac3_frames[3][32] =
- {{64,80,96,112,128,160,192,224,256,320,384,448,512,640,768,896,1024,
- 1152,1280,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {69,87,104,121,139,174,208,243,278,348,417,487,557,696,835,975,1114,
- 1253,1393,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {96,120,144,168,192,240,288,336,384,480,576,672,768,960,1152,1344,
- 1536,1728,1920,0,0,0,0,0,0,0,0,0,0,0,0,0}};
-
-
-
-#if 0
-static void setup_ts2pes(ipack *pa, ipack *pv, u16 *pida, u16 *pidv,
- void (*pes_write)(u8 *buf, int count, void *data),
- void *priv)
-{
- dvb_filter_ipack_init(pa, IPACKS, pes_write);
- dvb_filter_ipack_init(pv, IPACKS, pes_write);
- pa->pid = pida;
- pv->pid = pidv;
- pa->data = priv;
- pv->data = priv;
-}
-#endif
-
-#if 0
-static void ts_to_pes(ipack *p, u8 *buf) // don't need count (=188)
-{
- u8 off = 0;
-
- if (!buf || !p ){
- printk("NULL POINTER IDIOT\n");
- return;
- }
- if (buf[1]&PAY_START) {
- if (p->plength == MMAX_PLENGTH-6 && p->found>6){
- p->plength = p->found-6;
- p->found = 0;
- send_ipack(p);
- dvb_filter_ipack_reset(p);
- }
- }
- if (buf[3] & ADAPT_FIELD) { // adaptation field?
- off = buf[4] + 1;
- if (off+4 > 187) return;
- }
- dvb_filter_instant_repack(buf+4+off, TS_SIZE-4-off, p);
-}
-#endif
-
-#if 0
-/* needs 5 byte input, returns picture coding type*/
-static int read_picture_header(u8 *headr, struct mpg_picture *pic, int field, int pr)
-{
- u8 pct;
-
- if (pr) printk( "Pic header: ");
- pic->temporal_reference[field] = (( headr[0] << 2 ) |
- (headr[1] & 0x03) )& 0x03ff;
- if (pr) printk( " temp ref: 0x%04x", pic->temporal_reference[field]);
-
- pct = ( headr[1] >> 2 ) & 0x07;
- pic->picture_coding_type[field] = pct;
- if (pr) {
- switch(pct){
- case I_FRAME:
- printk( " I-FRAME");
- break;
- case B_FRAME:
- printk( " B-FRAME");
- break;
- case P_FRAME:
- printk( " P-FRAME");
- break;
- }
- }
-
-
- pic->vinfo.vbv_delay = (( headr[1] >> 5 ) | ( headr[2] << 3) |
- ( (headr[3] & 0x1F) << 11) ) & 0xffff;
-
- if (pr) printk( " vbv delay: 0x%04x", pic->vinfo.vbv_delay);
-
- pic->picture_header_parameter = ( headr[3] & 0xe0 ) |
- ((headr[4] & 0x80) >> 3);
-
- if ( pct == B_FRAME ){
- pic->picture_header_parameter |= ( headr[4] >> 3 ) & 0x0f;
- }
- if (pr) printk( " pic head param: 0x%x",
- pic->picture_header_parameter);
-
- return pct;
-}
-#endif
-
-#if 0
-/* needs 4 byte input */
-static int read_gop_header(u8 *headr, struct mpg_picture *pic, int pr)
-{
- if (pr) printk("GOP header: ");
-
- pic->time_code = (( headr[0] << 17 ) | ( headr[1] << 9) |
- ( headr[2] << 1 ) | (headr[3] &0x01)) & 0x1ffffff;
-
- if (pr) printk(" time: %d:%d.%d ", (headr[0]>>2)& 0x1F,
- ((headr[0]<<4)& 0x30)| ((headr[1]>>4)& 0x0F),
- ((headr[1]<<3)& 0x38)| ((headr[2]>>5)& 0x0F));
-
- if ( ( headr[3] & 0x40 ) != 0 ){
- pic->closed_gop = 1;
- } else {
- pic->closed_gop = 0;
- }
- if (pr) printk("closed: %d", pic->closed_gop);
-
- if ( ( headr[3] & 0x20 ) != 0 ){
- pic->broken_link = 1;
- } else {
- pic->broken_link = 0;
- }
- if (pr) printk(" broken: %d\n", pic->broken_link);
-
- return 0;
-}
-#endif
-
-#if 0
-/* needs 8 byte input */
-static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr)
-{
- int sw;
- int form = -1;
-
- if (pr) printk("Reading sequence header\n");
-
- vi->horizontal_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4);
- vi->vertical_size = ((headr[1] &0x0F) << 8) | (headr[2]);
-
- sw = (int)((headr[3]&0xF0) >> 4) ;
-
- switch( sw ){
- case 1:
- if (pr)
- printk("Videostream: ASPECT: 1:1");
- vi->aspect_ratio = 100;
- break;
- case 2:
- if (pr)
- printk("Videostream: ASPECT: 4:3");
- vi->aspect_ratio = 133;
- break;
- case 3:
- if (pr)
- printk("Videostream: ASPECT: 16:9");
- vi->aspect_ratio = 177;
- break;
- case 4:
- if (pr)
- printk("Videostream: ASPECT: 2.21:1");
- vi->aspect_ratio = 221;
- break;
-
- case 5 ... 15:
- if (pr)
- printk("Videostream: ASPECT: reserved");
- vi->aspect_ratio = 0;
- break;
-
- default:
- vi->aspect_ratio = 0;
- return -1;
- }
-
- if (pr)
- printk(" Size = %dx%d",vi->horizontal_size,vi->vertical_size);
-
- sw = (int)(headr[3]&0x0F);
-
- switch ( sw ) {
- case 1:
- if (pr)
- printk(" FRate: 23.976 fps");
- vi->framerate = 23976;
- form = -1;
- break;
- case 2:
- if (pr)
- printk(" FRate: 24 fps");
- vi->framerate = 24000;
- form = -1;
- break;
- case 3:
- if (pr)
- printk(" FRate: 25 fps");
- vi->framerate = 25000;
- form = VIDEO_MODE_PAL;
- break;
- case 4:
- if (pr)
- printk(" FRate: 29.97 fps");
- vi->framerate = 29970;
- form = VIDEO_MODE_NTSC;
- break;
- case 5:
- if (pr)
- printk(" FRate: 30 fps");
- vi->framerate = 30000;
- form = VIDEO_MODE_NTSC;
- break;
- case 6:
- if (pr)
- printk(" FRate: 50 fps");
- vi->framerate = 50000;
- form = VIDEO_MODE_PAL;
- break;
- case 7:
- if (pr)
- printk(" FRate: 60 fps");
- vi->framerate = 60000;
- form = VIDEO_MODE_NTSC;
- break;
- }
-
- vi->bit_rate = (headr[4] << 10) | (headr[5] << 2) | (headr[6] & 0x03);
-
- vi->vbv_buffer_size
- = (( headr[6] & 0xF8) >> 3 ) | (( headr[7] & 0x1F )<< 5);
-
- if (pr){
- printk(" BRate: %d Mbit/s",4*(vi->bit_rate)/10000);
- printk(" vbvbuffer %d",16*1024*(vi->vbv_buffer_size));
- printk("\n");
- }
-
- vi->video_format = form;
-
- return 0;
-}
-#endif
-
-
-#if 0
-static int get_vinfo(u8 *mbuf, int count, struct dvb_video_info *vi, int pr)
-{
- u8 *headr;
- int found = 0;
- int c = 0;
-
- while (found < 4 && c+4 < count){
- u8 *b;
-
- b = mbuf+c;
- if ( b[0] == 0x00 && b[1] == 0x00 && b[2] == 0x01
- && b[3] == 0xb3) found = 4;
- else {
- c++;
- }
- }
-
- if (! found) return -1;
- c += 4;
- if (c+12 >= count) return -1;
- headr = mbuf+c;
- if (read_sequence_header(headr, vi, pr) < 0) return -1;
- vi->off = c-4;
- return 0;
-}
-#endif
-
-
-#if 0
-static int get_ainfo(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
-{
- u8 *headr;
- int found = 0;
- int c = 0;
- int fr = 0;
-
- while (found < 2 && c < count){
- u8 b[2];
- memcpy( b, mbuf+c, 2);
-
- if ( b[0] == 0xff && (b[1] & 0xf8) == 0xf8)
- found = 2;
- else {
- c++;
- }
- }
-
- if (!found) return -1;
-
- if (c+3 >= count) return -1;
- headr = mbuf+c;
-
- ai->layer = (headr[1] & 0x06) >> 1;
-
- if (pr)
- printk("Audiostream: Layer: %d", 4-ai->layer);
-
-
- ai->bit_rate = bitrates[(3-ai->layer)][(headr[2] >> 4 )]*1000;
-
- if (pr){
- if (ai->bit_rate == 0)
- printk(" Bit rate: free");
- else if (ai->bit_rate == 0xf)
- printk(" BRate: reserved");
- else
- printk(" BRate: %d kb/s", ai->bit_rate/1000);
- }
-
- fr = (headr[2] & 0x0c ) >> 2;
- ai->frequency = freq[fr]*100;
- if (pr){
- if (ai->frequency == 3)
- printk(" Freq: reserved\n");
- else
- printk(" Freq: %d kHz\n",ai->frequency);
-
- }
- ai->off = c;
- return 0;
-}
-#endif
-
-
-int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
-{
- u8 *headr;
- int found = 0;
- int c = 0;
- u8 frame = 0;
- int fr = 0;
-
- while ( !found && c < count){
- u8 *b = mbuf+c;
-
- if ( b[0] == 0x0b && b[1] == 0x77 )
- found = 1;
- else {
- c++;
- }
- }
-
- if (!found) return -1;
- if (pr)
- printk("Audiostream: AC3");
-
- ai->off = c;
- if (c+5 >= count) return -1;
-
- ai->layer = 0; // 0 for AC3
- headr = mbuf+c+2;
-
- frame = (headr[2]&0x3f);
- ai->bit_rate = ac3_bitrates[frame >> 1]*1000;
-
- if (pr)
- printk(" BRate: %d kb/s", (int) ai->bit_rate/1000);
-
- ai->frequency = (headr[2] & 0xc0 ) >> 6;
- fr = (headr[2] & 0xc0 ) >> 6;
- ai->frequency = freq[fr]*100;
- if (pr) printk (" Freq: %d Hz\n", (int) ai->frequency);
-
-
- ai->framesize = ac3_frames[fr][frame >> 1];
- if ((frame & 1) && (fr == 1)) ai->framesize++;
- ai->framesize = ai->framesize << 1;
- if (pr) printk (" Framesize %d\n",(int) ai->framesize);
-
-
- return 0;
-}
-EXPORT_SYMBOL(dvb_filter_get_ac3info);
-
-
-#if 0
-static u8 *skip_pes_header(u8 **bufp)
-{
- u8 *inbuf = *bufp;
- u8 *buf = inbuf;
- u8 *pts = NULL;
- int skip = 0;
-
- static const int mpeg1_skip_table[16] = {
- 1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff,
- 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
- };
-
-
- if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */
- if (buf[7] & PTS_ONLY)
- pts = buf+9;
- else pts = NULL;
- buf = inbuf + 9 + inbuf[8];
- } else { /* mpeg1 */
- for (buf = inbuf + 6; *buf == 0xff; buf++)
- if (buf == inbuf + 6 + 16) {
- break;
- }
- if ((*buf & 0xc0) == 0x40)
- buf += 2;
- skip = mpeg1_skip_table [*buf >> 4];
- if (skip == 5 || skip == 10) pts = buf;
- else pts = NULL;
-
- buf += mpeg1_skip_table [*buf >> 4];
- }
-
- *bufp = buf;
- return pts;
-}
-#endif
-
-#if 0
-static void initialize_quant_matrix( u32 *matrix )
-{
- int i;
-
- matrix[0] = 0x08101013;
- matrix[1] = 0x10131616;
- matrix[2] = 0x16161616;
- matrix[3] = 0x1a181a1b;
- matrix[4] = 0x1b1b1a1a;
- matrix[5] = 0x1a1a1b1b;
- matrix[6] = 0x1b1d1d1d;
- matrix[7] = 0x2222221d;
- matrix[8] = 0x1d1d1b1b;
- matrix[9] = 0x1d1d2020;
- matrix[10] = 0x22222526;
- matrix[11] = 0x25232322;
- matrix[12] = 0x23262628;
- matrix[13] = 0x28283030;
- matrix[14] = 0x2e2e3838;
- matrix[15] = 0x3a454553;
-
- for ( i = 16 ; i < 32 ; i++ )
- matrix[i] = 0x10101010;
-}
-#endif
-
-#if 0
-static void initialize_mpg_picture(struct mpg_picture *pic)
-{
- int i;
-
- /* set MPEG1 */
- pic->mpeg1_flag = 1;
- pic->profile_and_level = 0x4A ; /* MP@LL */
- pic->progressive_sequence = 1;
- pic->low_delay = 0;
-
- pic->sequence_display_extension_flag = 0;
- for ( i = 0 ; i < 4 ; i++ ){
- pic->frame_centre_horizontal_offset[i] = 0;
- pic->frame_centre_vertical_offset[i] = 0;
- }
- pic->last_frame_centre_horizontal_offset = 0;
- pic->last_frame_centre_vertical_offset = 0;
-
- pic->picture_display_extension_flag[0] = 0;
- pic->picture_display_extension_flag[1] = 0;
- pic->sequence_header_flag = 0;
- pic->gop_flag = 0;
- pic->sequence_end_flag = 0;
-}
-#endif
-
-#if 0
-static void mpg_set_picture_parameter( int32_t field_type, struct mpg_picture *pic )
-{
- int16_t last_h_offset;
- int16_t last_v_offset;
-
- int16_t *p_h_offset;
- int16_t *p_v_offset;
-
- if ( pic->mpeg1_flag ){
- pic->picture_structure[field_type] = VIDEO_FRAME_PICTURE;
- pic->top_field_first = 0;
- pic->repeat_first_field = 0;
- pic->progressive_frame = 1;
- pic->picture_coding_parameter = 0x000010;
- }
-
- /* Reset flag */
- pic->picture_display_extension_flag[field_type] = 0;
-
- last_h_offset = pic->last_frame_centre_horizontal_offset;
- last_v_offset = pic->last_frame_centre_vertical_offset;
- if ( field_type == FIRST_FIELD ){
- p_h_offset = pic->frame_centre_horizontal_offset;
- p_v_offset = pic->frame_centre_vertical_offset;
- *p_h_offset = last_h_offset;
- *(p_h_offset + 1) = last_h_offset;
- *(p_h_offset + 2) = last_h_offset;
- *p_v_offset = last_v_offset;
- *(p_v_offset + 1) = last_v_offset;
- *(p_v_offset + 2) = last_v_offset;
- } else {
- pic->frame_centre_horizontal_offset[3] = last_h_offset;
- pic->frame_centre_vertical_offset[3] = last_v_offset;
- }
-}
-#endif
-
-#if 0
-static void init_mpg_picture( struct mpg_picture *pic, int chan, int32_t field_type)
-{
- pic->picture_header = 0;
- pic->sequence_header_data
- = ( INIT_HORIZONTAL_SIZE << 20 )
- | ( INIT_VERTICAL_SIZE << 8 )
- | ( INIT_ASPECT_RATIO << 4 )
- | ( INIT_FRAME_RATE );
- pic->mpeg1_flag = 0;
- pic->vinfo.horizontal_size
- = INIT_DISP_HORIZONTAL_SIZE;
- pic->vinfo.vertical_size
- = INIT_DISP_VERTICAL_SIZE;
- pic->picture_display_extension_flag[field_type]
- = 0;
- pic->pts_flag[field_type] = 0;
-
- pic->sequence_gop_header = 0;
- pic->picture_header = 0;
- pic->sequence_header_flag = 0;
- pic->gop_flag = 0;
- pic->sequence_end_flag = 0;
- pic->sequence_display_extension_flag = 0;
- pic->last_frame_centre_horizontal_offset = 0;
- pic->last_frame_centre_vertical_offset = 0;
- pic->channel = chan;
-}
-#endif
-
-void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid,
- dvb_filter_pes2ts_cb_t *cb, void *priv)
-{
- unsigned char *buf=p2ts->buf;
-
- buf[0]=0x47;
- buf[1]=(pid>>8);
- buf[2]=pid&0xff;
- p2ts->cc=0;
- p2ts->cb=cb;
- p2ts->priv=priv;
-}
-EXPORT_SYMBOL(dvb_filter_pes2ts_init);
-
-int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes,
- int len, int payload_start)
-{
- unsigned char *buf=p2ts->buf;
- int ret=0, rest;
-
- //len=6+((pes[4]<<8)|pes[5]);
-
- if (payload_start)
- buf[1]|=0x40;
- else
- buf[1]&=~0x40;
- while (len>=184) {
- buf[3]=0x10|((p2ts->cc++)&0x0f);
- memcpy(buf+4, pes, 184);
- if ((ret=p2ts->cb(p2ts->priv, buf)))
- return ret;
- len-=184; pes+=184;
- buf[1]&=~0x40;
- }
- if (!len)
- return 0;
- buf[3]=0x30|((p2ts->cc++)&0x0f);
- rest=183-len;
- if (rest) {
- buf[5]=0x00;
- if (rest-1)
- memset(buf+6, 0xff, rest-1);
- }
- buf[4]=rest;
- memcpy(buf+5+rest, pes, len);
- return p2ts->cb(p2ts->priv, buf);
-}
-EXPORT_SYMBOL(dvb_filter_pes2ts);
diff --git a/drivers/media/dvb/dvb-core/dvb_filter.h b/drivers/media/dvb/dvb-core/dvb_filter.h
deleted file mode 100644
index 375e3be184b..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_filter.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * dvb_filter.h
- *
- * Copyright (C) 2003 Convergence GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _DVB_FILTER_H_
-#define _DVB_FILTER_H_
-
-#include <linux/slab.h>
-
-#include "demux.h"
-
-typedef int (dvb_filter_pes2ts_cb_t) (void *, unsigned char *);
-
-struct dvb_filter_pes2ts {
- unsigned char buf[188];
- unsigned char cc;
- dvb_filter_pes2ts_cb_t *cb;
- void *priv;
-};
-
-void dvb_filter_pes2ts_init(struct dvb_filter_pes2ts *p2ts, unsigned short pid,
- dvb_filter_pes2ts_cb_t *cb, void *priv);
-
-int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes,
- int len, int payload_start);
-
-
-#define PROG_STREAM_MAP 0xBC
-#define PRIVATE_STREAM1 0xBD
-#define PADDING_STREAM 0xBE
-#define PRIVATE_STREAM2 0xBF
-#define AUDIO_STREAM_S 0xC0
-#define AUDIO_STREAM_E 0xDF
-#define VIDEO_STREAM_S 0xE0
-#define VIDEO_STREAM_E 0xEF
-#define ECM_STREAM 0xF0
-#define EMM_STREAM 0xF1
-#define DSM_CC_STREAM 0xF2
-#define ISO13522_STREAM 0xF3
-#define PROG_STREAM_DIR 0xFF
-
-#define DVB_PICTURE_START 0x00
-#define DVB_USER_START 0xb2
-#define DVB_SEQUENCE_HEADER 0xb3
-#define DVB_SEQUENCE_ERROR 0xb4
-#define DVB_EXTENSION_START 0xb5
-#define DVB_SEQUENCE_END 0xb7
-#define DVB_GOP_START 0xb8
-#define DVB_EXCEPT_SLICE 0xb0
-
-#define SEQUENCE_EXTENSION 0x01
-#define SEQUENCE_DISPLAY_EXTENSION 0x02
-#define PICTURE_CODING_EXTENSION 0x08
-#define QUANT_MATRIX_EXTENSION 0x03
-#define PICTURE_DISPLAY_EXTENSION 0x07
-
-#define I_FRAME 0x01
-#define B_FRAME 0x02
-#define P_FRAME 0x03
-
-/* Initialize sequence_data */
-#define INIT_HORIZONTAL_SIZE 720
-#define INIT_VERTICAL_SIZE 576
-#define INIT_ASPECT_RATIO 0x02
-#define INIT_FRAME_RATE 0x03
-#define INIT_DISP_HORIZONTAL_SIZE 540
-#define INIT_DISP_VERTICAL_SIZE 576
-
-
-//flags2
-#define PTS_DTS_FLAGS 0xC0
-#define ESCR_FLAG 0x20
-#define ES_RATE_FLAG 0x10
-#define DSM_TRICK_FLAG 0x08
-#define ADD_CPY_FLAG 0x04
-#define PES_CRC_FLAG 0x02
-#define PES_EXT_FLAG 0x01
-
-//pts_dts flags
-#define PTS_ONLY 0x80
-#define PTS_DTS 0xC0
-
-#define TS_SIZE 188
-#define TRANS_ERROR 0x80
-#define PAY_START 0x40
-#define TRANS_PRIO 0x20
-#define PID_MASK_HI 0x1F
-//flags
-#define TRANS_SCRMBL1 0x80
-#define TRANS_SCRMBL2 0x40
-#define ADAPT_FIELD 0x20
-#define PAYLOAD 0x10
-#define COUNT_MASK 0x0F
-
-// adaptation flags
-#define DISCON_IND 0x80
-#define RAND_ACC_IND 0x40
-#define ES_PRI_IND 0x20
-#define PCR_FLAG 0x10
-#define OPCR_FLAG 0x08
-#define SPLICE_FLAG 0x04
-#define TRANS_PRIV 0x02
-#define ADAP_EXT_FLAG 0x01
-
-// adaptation extension flags
-#define LTW_FLAG 0x80
-#define PIECE_RATE 0x40
-#define SEAM_SPLICE 0x20
-
-
-#define MAX_PLENGTH 0xFFFF
-#define MMAX_PLENGTH (256*MAX_PLENGTH)
-
-#ifndef IPACKS
-#define IPACKS 2048
-#endif
-
-struct ipack {
- int size;
- int found;
- u8 *buf;
- u8 cid;
- u32 plength;
- u8 plen[2];
- u8 flag1;
- u8 flag2;
- u8 hlength;
- u8 pts[5];
- u16 *pid;
- int mpeg;
- u8 check;
- int which;
- int done;
- void *data;
- void (*func)(u8 *buf, int size, void *priv);
- int count;
- int repack_subids;
-};
-
-struct dvb_video_info {
- u32 horizontal_size;
- u32 vertical_size;
- u32 aspect_ratio;
- u32 framerate;
- u32 video_format;
- u32 bit_rate;
- u32 comp_bit_rate;
- u32 vbv_buffer_size;
- s16 vbv_delay;
- u32 CSPF;
- u32 off;
-};
-
-#define OFF_SIZE 4
-#define FIRST_FIELD 0
-#define SECOND_FIELD 1
-#define VIDEO_FRAME_PICTURE 0x03
-
-struct mpg_picture {
- int channel;
- struct dvb_video_info vinfo;
- u32 *sequence_gop_header;
- u32 *picture_header;
- s32 time_code;
- int low_delay;
- int closed_gop;
- int broken_link;
- int sequence_header_flag;
- int gop_flag;
- int sequence_end_flag;
-
- u8 profile_and_level;
- s32 picture_coding_parameter;
- u32 matrix[32];
- s8 matrix_change_flag;
-
- u8 picture_header_parameter;
- /* bit 0 - 2: bwd f code
- bit 3 : fpb vector
- bit 4 - 6: fwd f code
- bit 7 : fpf vector */
-
- int mpeg1_flag;
- int progressive_sequence;
- int sequence_display_extension_flag;
- u32 sequence_header_data;
- s16 last_frame_centre_horizontal_offset;
- s16 last_frame_centre_vertical_offset;
-
- u32 pts[2]; /* [0] 1st field, [1] 2nd field */
- int top_field_first;
- int repeat_first_field;
- int progressive_frame;
- int bank;
- int forward_bank;
- int backward_bank;
- int compress;
- s16 frame_centre_horizontal_offset[OFF_SIZE];
- /* [0-2] 1st field, [3] 2nd field */
- s16 frame_centre_vertical_offset[OFF_SIZE];
- /* [0-2] 1st field, [3] 2nd field */
- s16 temporal_reference[2];
- /* [0] 1st field, [1] 2nd field */
-
- s8 picture_coding_type[2];
- /* [0] 1st field, [1] 2nd field */
- s8 picture_structure[2];
- /* [0] 1st field, [1] 2nd field */
- s8 picture_display_extension_flag[2];
- /* [0] 1st field, [1] 2nd field */
- /* picture_display_extenion() 0:no 1:exit*/
- s8 pts_flag[2];
- /* [0] 1st field, [1] 2nd field */
-};
-
-struct dvb_audio_info {
- int layer;
- u32 bit_rate;
- u32 frequency;
- u32 mode;
- u32 mode_extension ;
- u32 emphasis;
- u32 framesize;
- u32 off;
-};
-
-int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr);
-
-
-#endif
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
deleted file mode 100644
index 57b34cda99f..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ /dev/null
@@ -1,1122 +0,0 @@
-/*
- * dvb_frontend.c: DVB frontend tuning interface/thread
- *
- *
- * Copyright (C) 1999-2001 Ralph Metzler
- * Marcus Metzler
- * Holger Waechtler
- * for convergence integrated media GmbH
- *
- * Copyright (C) 2004 Andrew de Quincey (tuning thread cleanup)
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/slab.h>
-#include <linux/poll.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/list.h>
-#include <linux/suspend.h>
-#include <linux/jiffies.h>
-#include <asm/processor.h>
-
-#include "dvb_frontend.h"
-#include "dvbdev.h"
-
-static int dvb_frontend_debug;
-static int dvb_shutdown_timeout = 5;
-static int dvb_force_auto_inversion;
-static int dvb_override_tune_delay;
-static int dvb_powerdown_on_sleep = 1;
-
-module_param_named(frontend_debug, dvb_frontend_debug, int, 0644);
-MODULE_PARM_DESC(frontend_debug, "Turn on/off frontend core debugging (default:off).");
-module_param(dvb_shutdown_timeout, int, 0644);
-MODULE_PARM_DESC(dvb_shutdown_timeout, "wait <shutdown_timeout> seconds after close() before suspending hardware");
-module_param(dvb_force_auto_inversion, int, 0644);
-MODULE_PARM_DESC(dvb_force_auto_inversion, "0: normal (default), 1: INVERSION_AUTO forced always");
-module_param(dvb_override_tune_delay, int, 0644);
-MODULE_PARM_DESC(dvb_override_tune_delay, "0: normal (default), >0 => delay in milliseconds to wait for lock after a tune attempt");
-module_param(dvb_powerdown_on_sleep, int, 0644);
-MODULE_PARM_DESC(dvb_powerdown_on_sleep, "0: do not power down, 1: turn LNB voltage off on sleep (default)");
-
-#define dprintk if (dvb_frontend_debug) printk
-
-#define FESTATE_IDLE 1
-#define FESTATE_RETUNE 2
-#define FESTATE_TUNING_FAST 4
-#define FESTATE_TUNING_SLOW 8
-#define FESTATE_TUNED 16
-#define FESTATE_ZIGZAG_FAST 32
-#define FESTATE_ZIGZAG_SLOW 64
-#define FESTATE_DISEQC 128
-#define FESTATE_WAITFORLOCK (FESTATE_TUNING_FAST | FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_FAST | FESTATE_ZIGZAG_SLOW | FESTATE_DISEQC)
-#define FESTATE_SEARCHING_FAST (FESTATE_TUNING_FAST | FESTATE_ZIGZAG_FAST)
-#define FESTATE_SEARCHING_SLOW (FESTATE_TUNING_SLOW | FESTATE_ZIGZAG_SLOW)
-#define FESTATE_LOSTLOCK (FESTATE_ZIGZAG_FAST | FESTATE_ZIGZAG_SLOW)
-
-#define FE_ALGO_HW 1
-/*
- * FESTATE_IDLE. No tuning parameters have been supplied and the loop is idling.
- * FESTATE_RETUNE. Parameters have been supplied, but we have not yet performed the first tune.
- * FESTATE_TUNING_FAST. Tuning parameters have been supplied and fast zigzag scan is in progress.
- * FESTATE_TUNING_SLOW. Tuning parameters have been supplied. Fast zigzag failed, so we're trying again, but slower.
- * FESTATE_TUNED. The frontend has successfully locked on.
- * FESTATE_ZIGZAG_FAST. The lock has been lost, and a fast zigzag has been initiated to try and regain it.
- * FESTATE_ZIGZAG_SLOW. The lock has been lost. Fast zigzag has been failed, so we're trying again, but slower.
- * FESTATE_DISEQC. A DISEQC command has just been issued.
- * FESTATE_WAITFORLOCK. When we're waiting for a lock.
- * FESTATE_SEARCHING_FAST. When we're searching for a signal using a fast zigzag scan.
- * FESTATE_SEARCHING_SLOW. When we're searching for a signal using a slow zigzag scan.
- * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
- */
-
-static DEFINE_MUTEX(frontend_mutex);
-
-struct dvb_frontend_private {
-
- /* thread/frontend values */
- struct dvb_device *dvbdev;
- struct dvb_frontend_parameters parameters;
- struct dvb_fe_events events;
- struct semaphore sem;
- struct list_head list_head;
- wait_queue_head_t wait_queue;
- pid_t thread_pid;
- unsigned long release_jiffies;
- unsigned int exit;
- unsigned int wakeup;
- fe_status_t status;
- unsigned long tune_mode_flags;
- unsigned int delay;
- unsigned int reinitialise;
- int tone;
- int voltage;
-
- /* swzigzag values */
- unsigned int state;
- unsigned int bending;
- int lnb_drift;
- unsigned int inversion;
- unsigned int auto_step;
- unsigned int auto_sub_step;
- unsigned int started_auto_step;
- unsigned int min_delay;
- unsigned int max_drift;
- unsigned int step_size;
- int quality;
- unsigned int check_wrapped;
-};
-
-static void dvb_frontend_wakeup(struct dvb_frontend *fe);
-
-static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status)
-{
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
- struct dvb_fe_events *events = &fepriv->events;
- struct dvb_frontend_event *e;
- int wp;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (down_interruptible (&events->sem))
- return;
-
- wp = (events->eventw + 1) % MAX_EVENT;
-
- if (wp == events->eventr) {
- events->overflow = 1;
- events->eventr = (events->eventr + 1) % MAX_EVENT;
- }
-
- e = &events->events[events->eventw];
-
- memcpy (&e->parameters, &fepriv->parameters,
- sizeof (struct dvb_frontend_parameters));
-
- if (status & FE_HAS_LOCK)
- if (fe->ops.get_frontend)
- fe->ops.get_frontend(fe, &e->parameters);
-
- events->eventw = wp;
-
- up (&events->sem);
-
- e->status = status;
-
- wake_up_interruptible (&events->wait_queue);
-}
-
-static int dvb_frontend_get_event(struct dvb_frontend *fe,
- struct dvb_frontend_event *event, int flags)
-{
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
- struct dvb_fe_events *events = &fepriv->events;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (events->overflow) {
- events->overflow = 0;
- return -EOVERFLOW;
- }
-
- if (events->eventw == events->eventr) {
- int ret;
-
- if (flags & O_NONBLOCK)
- return -EWOULDBLOCK;
-
- up(&fepriv->sem);
-
- ret = wait_event_interruptible (events->wait_queue,
- events->eventw != events->eventr);
-
- if (down_interruptible (&fepriv->sem))
- return -ERESTARTSYS;
-
- if (ret < 0)
- return ret;
- }
-
- if (down_interruptible (&events->sem))
- return -ERESTARTSYS;
-
- memcpy (event, &events->events[events->eventr],
- sizeof(struct dvb_frontend_event));
-
- events->eventr = (events->eventr + 1) % MAX_EVENT;
-
- up (&events->sem);
-
- return 0;
-}
-
-static void dvb_frontend_init(struct dvb_frontend *fe)
-{
- dprintk ("DVB: initialising frontend %i (%s)...\n",
- fe->dvb->num,
- fe->ops.info.name);
-
- if (fe->ops.init)
- fe->ops.init(fe);
- if (fe->ops.tuner_ops.init) {
- fe->ops.tuner_ops.init(fe);
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
- }
-}
-
-void dvb_frontend_reinitialise(struct dvb_frontend *fe)
-{
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- fepriv->reinitialise = 1;
- dvb_frontend_wakeup(fe);
-}
-EXPORT_SYMBOL(dvb_frontend_reinitialise);
-
-static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepriv, int locked)
-{
- int q2;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (locked)
- (fepriv->quality) = (fepriv->quality * 220 + 36*256) / 256;
- else
- (fepriv->quality) = (fepriv->quality * 220 + 0) / 256;
-
- q2 = fepriv->quality - 128;
- q2 *= q2;
-
- fepriv->delay = fepriv->min_delay + q2 * HZ / (128*128);
-}
-
-/**
- * Performs automatic twiddling of frontend parameters.
- *
- * @param fe The frontend concerned.
- * @param check_wrapped Checks if an iteration has completed. DO NOT SET ON THE FIRST ATTEMPT
- * @returns Number of complete iterations that have been performed.
- */
-static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wrapped)
-{
- int autoinversion;
- int ready = 0;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
- int original_inversion = fepriv->parameters.inversion;
- u32 original_frequency = fepriv->parameters.frequency;
-
- /* are we using autoinversion? */
- autoinversion = ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) &&
- (fepriv->parameters.inversion == INVERSION_AUTO));
-
- /* setup parameters correctly */
- while(!ready) {
- /* calculate the lnb_drift */
- fepriv->lnb_drift = fepriv->auto_step * fepriv->step_size;
-
- /* wrap the auto_step if we've exceeded the maximum drift */
- if (fepriv->lnb_drift > fepriv->max_drift) {
- fepriv->auto_step = 0;
- fepriv->auto_sub_step = 0;
- fepriv->lnb_drift = 0;
- }
-
- /* perform inversion and +/- zigzag */
- switch(fepriv->auto_sub_step) {
- case 0:
- /* try with the current inversion and current drift setting */
- ready = 1;
- break;
-
- case 1:
- if (!autoinversion) break;
-
- fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
- ready = 1;
- break;
-
- case 2:
- if (fepriv->lnb_drift == 0) break;
-
- fepriv->lnb_drift = -fepriv->lnb_drift;
- ready = 1;
- break;
-
- case 3:
- if (fepriv->lnb_drift == 0) break;
- if (!autoinversion) break;
-
- fepriv->inversion = (fepriv->inversion == INVERSION_OFF) ? INVERSION_ON : INVERSION_OFF;
- fepriv->lnb_drift = -fepriv->lnb_drift;
- ready = 1;
- break;
-
- default:
- fepriv->auto_step++;
- fepriv->auto_sub_step = -1; /* it'll be incremented to 0 in a moment */
- break;
- }
-
- if (!ready) fepriv->auto_sub_step++;
- }
-
- /* if this attempt would hit where we started, indicate a complete
- * iteration has occurred */
- if ((fepriv->auto_step == fepriv->started_auto_step) &&
- (fepriv->auto_sub_step == 0) && check_wrapped) {
- return 1;
- }
-
- dprintk("%s: drift:%i inversion:%i auto_step:%i "
- "auto_sub_step:%i started_auto_step:%i\n",
- __FUNCTION__, fepriv->lnb_drift, fepriv->inversion,
- fepriv->auto_step, fepriv->auto_sub_step, fepriv->started_auto_step);
-
- /* set the frontend itself */
- fepriv->parameters.frequency += fepriv->lnb_drift;
- if (autoinversion)
- fepriv->parameters.inversion = fepriv->inversion;
- if (fe->ops.set_frontend)
- fe->ops.set_frontend(fe, &fepriv->parameters);
-
- fepriv->parameters.frequency = original_frequency;
- fepriv->parameters.inversion = original_inversion;
-
- fepriv->auto_sub_step++;
- return 0;
-}
-
-static void dvb_frontend_swzigzag(struct dvb_frontend *fe)
-{
- fe_status_t s;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- /* if we've got no parameters, just keep idling */
- if (fepriv->state & FESTATE_IDLE) {
- fepriv->delay = 3*HZ;
- fepriv->quality = 0;
- return;
- }
-
- /* in SCAN mode, we just set the frontend when asked and leave it alone */
- if (fepriv->tune_mode_flags & FE_TUNE_MODE_ONESHOT) {
- if (fepriv->state & FESTATE_RETUNE) {
- if (fe->ops.set_frontend)
- fe->ops.set_frontend(fe, &fepriv->parameters);
- fepriv->state = FESTATE_TUNED;
- }
- fepriv->delay = 3*HZ;
- fepriv->quality = 0;
- return;
- }
-
- /* get the frontend status */
- if (fepriv->state & FESTATE_RETUNE) {
- s = 0;
- } else {
- if (fe->ops.read_status)
- fe->ops.read_status(fe, &s);
- if (s != fepriv->status) {
- dvb_frontend_add_event(fe, s);
- fepriv->status = s;
- }
- }
-
- /* if we're not tuned, and we have a lock, move to the TUNED state */
- if ((fepriv->state & FESTATE_WAITFORLOCK) && (s & FE_HAS_LOCK)) {
- dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);
- fepriv->state = FESTATE_TUNED;
-
- /* if we're tuned, then we have determined the correct inversion */
- if ((!(fe->ops.info.caps & FE_CAN_INVERSION_AUTO)) &&
- (fepriv->parameters.inversion == INVERSION_AUTO)) {
- fepriv->parameters.inversion = fepriv->inversion;
- }
- return;
- }
-
- /* if we are tuned already, check we're still locked */
- if (fepriv->state & FESTATE_TUNED) {
- dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);
-
- /* we're tuned, and the lock is still good... */
- if (s & FE_HAS_LOCK) {
- return;
- } else { /* if we _WERE_ tuned, but now don't have a lock */
- fepriv->state = FESTATE_ZIGZAG_FAST;
- fepriv->started_auto_step = fepriv->auto_step;
- fepriv->check_wrapped = 0;
- }
- }
-
- /* don't actually do anything if we're in the LOSTLOCK state,
- * the frontend is set to FE_CAN_RECOVER, and the max_drift is 0 */
- if ((fepriv->state & FESTATE_LOSTLOCK) &&
- (fe->ops.info.caps & FE_CAN_RECOVER) && (fepriv->max_drift == 0)) {
- dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);
- return;
- }
-
- /* don't do anything if we're in the DISEQC state, since this
- * might be someone with a motorized dish controlled by DISEQC.
- * If its actually a re-tune, there will be a SET_FRONTEND soon enough. */
- if (fepriv->state & FESTATE_DISEQC) {
- dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);
- return;
- }
-
- /* if we're in the RETUNE state, set everything up for a brand
- * new scan, keeping the current inversion setting, as the next
- * tune is _very_ likely to require the same */
- if (fepriv->state & FESTATE_RETUNE) {
- fepriv->lnb_drift = 0;
- fepriv->auto_step = 0;
- fepriv->auto_sub_step = 0;
- fepriv->started_auto_step = 0;
- fepriv->check_wrapped = 0;
- }
-
- /* fast zigzag. */
- if ((fepriv->state & FESTATE_SEARCHING_FAST) || (fepriv->state & FESTATE_RETUNE)) {
- fepriv->delay = fepriv->min_delay;
-
- /* peform a tune */
- if (dvb_frontend_swzigzag_autotune(fe, fepriv->check_wrapped)) {
- /* OK, if we've run out of trials at the fast speed.
- * Drop back to slow for the _next_ attempt */
- fepriv->state = FESTATE_SEARCHING_SLOW;
- fepriv->started_auto_step = fepriv->auto_step;
- return;
- }
- fepriv->check_wrapped = 1;
-
- /* if we've just retuned, enter the ZIGZAG_FAST state.
- * This ensures we cannot return from an
- * FE_SET_FRONTEND ioctl before the first frontend tune
- * occurs */
- if (fepriv->state & FESTATE_RETUNE) {
- fepriv->state = FESTATE_TUNING_FAST;
- }
- }
-
- /* slow zigzag */
- if (fepriv->state & FESTATE_SEARCHING_SLOW) {
- dvb_frontend_swzigzag_update_delay(fepriv, s & FE_HAS_LOCK);
-
- /* Note: don't bother checking for wrapping; we stay in this
- * state until we get a lock */
- dvb_frontend_swzigzag_autotune(fe, 0);
- }
-}
-
-static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
-{
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- if (fepriv->exit)
- return 1;
-
- if (fepriv->dvbdev->writers == 1)
- if (time_after(jiffies, fepriv->release_jiffies +
- dvb_shutdown_timeout * HZ))
- return 1;
-
- return 0;
-}
-
-static int dvb_frontend_should_wakeup(struct dvb_frontend *fe)
-{
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- if (fepriv->wakeup) {
- fepriv->wakeup = 0;
- return 1;
- }
- return dvb_frontend_is_exiting(fe);
-}
-
-static void dvb_frontend_wakeup(struct dvb_frontend *fe)
-{
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- fepriv->wakeup = 1;
- wake_up_interruptible(&fepriv->wait_queue);
-}
-
-static int dvb_frontend_thread(void *data)
-{
- struct dvb_frontend *fe = data;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
- unsigned long timeout;
- char name [15];
- fe_status_t s;
- struct dvb_frontend_parameters *params;
-
- dprintk("%s\n", __FUNCTION__);
-
- snprintf (name, sizeof(name), "kdvb-fe-%i", fe->dvb->num);
-
- lock_kernel();
- daemonize(name);
- sigfillset(&current->blocked);
- unlock_kernel();
-
- fepriv->check_wrapped = 0;
- fepriv->quality = 0;
- fepriv->delay = 3*HZ;
- fepriv->status = 0;
- fepriv->wakeup = 0;
- fepriv->reinitialise = 0;
-
- dvb_frontend_init(fe);
-
- while (1) {
- up(&fepriv->sem); /* is locked when we enter the thread... */
-
- timeout = wait_event_interruptible_timeout(fepriv->wait_queue,
- dvb_frontend_should_wakeup(fe),
- fepriv->delay);
- if (0 != dvb_frontend_is_exiting(fe)) {
- /* got signal or quitting */
- break;
- }
-
- try_to_freeze();
-
- if (down_interruptible(&fepriv->sem))
- break;
-
- if (fepriv->reinitialise) {
- dvb_frontend_init(fe);
- if (fepriv->tone != -1) {
- fe->ops.set_tone(fe, fepriv->tone);
- }
- if (fepriv->voltage != -1) {
- fe->ops.set_voltage(fe, fepriv->voltage);
- }
- fepriv->reinitialise = 0;
- }
-
- /* do an iteration of the tuning loop */
- if (fe->ops.get_frontend_algo) {
- if (fe->ops.get_frontend_algo(fe) == FE_ALGO_HW) {
- /* have we been asked to retune? */
- params = NULL;
- if (fepriv->state & FESTATE_RETUNE) {
- params = &fepriv->parameters;
- fepriv->state = FESTATE_TUNED;
- }
-
- fe->ops.tune(fe, params, fepriv->tune_mode_flags, &fepriv->delay, &s);
- if (s != fepriv->status) {
- dvb_frontend_add_event(fe, s);
- fepriv->status = s;
- }
- } else
- dvb_frontend_swzigzag(fe);
- } else
- dvb_frontend_swzigzag(fe);
- }
-
- if (dvb_shutdown_timeout) {
- if (dvb_powerdown_on_sleep)
- if (fe->ops.set_voltage)
- fe->ops.set_voltage(fe, SEC_VOLTAGE_OFF);
- if (fe->ops.tuner_ops.sleep) {
- fe->ops.tuner_ops.sleep(fe);
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
- }
- if (fe->ops.sleep)
- fe->ops.sleep(fe);
- }
-
- fepriv->thread_pid = 0;
- mb();
-
- dvb_frontend_wakeup(fe);
- return 0;
-}
-
-static void dvb_frontend_stop(struct dvb_frontend *fe)
-{
- unsigned long ret;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- dprintk ("%s\n", __FUNCTION__);
-
- fepriv->exit = 1;
- mb();
-
- if (!fepriv->thread_pid)
- return;
-
- /* check if the thread is really alive */
- if (kill_proc(fepriv->thread_pid, 0, 1) == -ESRCH) {
- printk("dvb_frontend_stop: thread PID %d already died\n",
- fepriv->thread_pid);
- /* make sure the mutex was not held by the thread */
- init_MUTEX (&fepriv->sem);
- return;
- }
-
- /* wake up the frontend thread, so it notices that fe->exit == 1 */
- dvb_frontend_wakeup(fe);
-
- /* wait until the frontend thread has exited */
- ret = wait_event_interruptible(fepriv->wait_queue,0 == fepriv->thread_pid);
- if (-ERESTARTSYS != ret) {
- fepriv->state = FESTATE_IDLE;
- return;
- }
- fepriv->state = FESTATE_IDLE;
-
- /* paranoia check in case a signal arrived */
- if (fepriv->thread_pid)
- printk("dvb_frontend_stop: warning: thread PID %d won't exit\n",
- fepriv->thread_pid);
-}
-
-s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime)
-{
- return ((curtime.tv_usec < lasttime.tv_usec) ?
- 1000000 - lasttime.tv_usec + curtime.tv_usec :
- curtime.tv_usec - lasttime.tv_usec);
-}
-EXPORT_SYMBOL(timeval_usec_diff);
-
-static inline void timeval_usec_add(struct timeval *curtime, u32 add_usec)
-{
- curtime->tv_usec += add_usec;
- if (curtime->tv_usec >= 1000000) {
- curtime->tv_usec -= 1000000;
- curtime->tv_sec++;
- }
-}
-
-/*
- * Sleep until gettimeofday() > waketime + add_usec
- * This needs to be as precise as possible, but as the delay is
- * usually between 2ms and 32ms, it is done using a scheduled msleep
- * followed by usleep (normally a busy-wait loop) for the remainder
- */
-void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec)
-{
- struct timeval lasttime;
- s32 delta, newdelta;
-
- timeval_usec_add(waketime, add_usec);
-
- do_gettimeofday(&lasttime);
- delta = timeval_usec_diff(lasttime, *waketime);
- if (delta > 2500) {
- msleep((delta - 1500) / 1000);
- do_gettimeofday(&lasttime);
- newdelta = timeval_usec_diff(lasttime, *waketime);
- delta = (newdelta > delta) ? 0 : newdelta;
- }
- if (delta > 0)
- udelay(delta);
-}
-EXPORT_SYMBOL(dvb_frontend_sleep_until);
-
-static int dvb_frontend_start(struct dvb_frontend *fe)
-{
- int ret;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (fepriv->thread_pid) {
- if (!fepriv->exit)
- return 0;
- else
- dvb_frontend_stop (fe);
- }
-
- if (signal_pending(current))
- return -EINTR;
- if (down_interruptible (&fepriv->sem))
- return -EINTR;
-
- fepriv->state = FESTATE_IDLE;
- fepriv->exit = 0;
- fepriv->thread_pid = 0;
- mb();
-
- ret = kernel_thread (dvb_frontend_thread, fe, 0);
-
- if (ret < 0) {
- printk("dvb_frontend_start: failed to start kernel_thread (%d)\n", ret);
- up(&fepriv->sem);
- return ret;
- }
- fepriv->thread_pid = ret;
-
- return 0;
-}
-
-static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_frontend *fe = dvbdev->priv;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
- int err = -EOPNOTSUPP;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (!fe || fepriv->exit)
- return -ENODEV;
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
- (_IOC_DIR(cmd) != _IOC_READ || cmd == FE_GET_EVENT ||
- cmd == FE_DISEQC_RECV_SLAVE_REPLY))
- return -EPERM;
-
- if (down_interruptible (&fepriv->sem))
- return -ERESTARTSYS;
-
- switch (cmd) {
- case FE_GET_INFO: {
- struct dvb_frontend_info* info = parg;
- memcpy(info, &fe->ops.info, sizeof(struct dvb_frontend_info));
-
- /* Force the CAN_INVERSION_AUTO bit on. If the frontend doesn't
- * do it, it is done for it. */
- info->caps |= FE_CAN_INVERSION_AUTO;
- err = 0;
- break;
- }
-
- case FE_READ_STATUS: {
- fe_status_t* status = parg;
-
- /* if retune was requested but hasn't occured yet, prevent
- * that user get signal state from previous tuning */
- if(fepriv->state == FESTATE_RETUNE) {
- err=0;
- *status = 0;
- break;
- }
-
- if (fe->ops.read_status)
- err = fe->ops.read_status(fe, status);
- break;
- }
- case FE_READ_BER:
- if (fe->ops.read_ber)
- err = fe->ops.read_ber(fe, (__u32*) parg);
- break;
-
- case FE_READ_SIGNAL_STRENGTH:
- if (fe->ops.read_signal_strength)
- err = fe->ops.read_signal_strength(fe, (__u16*) parg);
- break;
-
- case FE_READ_SNR:
- if (fe->ops.read_snr)
- err = fe->ops.read_snr(fe, (__u16*) parg);
- break;
-
- case FE_READ_UNCORRECTED_BLOCKS:
- if (fe->ops.read_ucblocks)
- err = fe->ops.read_ucblocks(fe, (__u32*) parg);
- break;
-
-
- case FE_DISEQC_RESET_OVERLOAD:
- if (fe->ops.diseqc_reset_overload) {
- err = fe->ops.diseqc_reset_overload(fe);
- fepriv->state = FESTATE_DISEQC;
- fepriv->status = 0;
- }
- break;
-
- case FE_DISEQC_SEND_MASTER_CMD:
- if (fe->ops.diseqc_send_master_cmd) {
- err = fe->ops.diseqc_send_master_cmd(fe, (struct dvb_diseqc_master_cmd*) parg);
- fepriv->state = FESTATE_DISEQC;
- fepriv->status = 0;
- }
- break;
-
- case FE_DISEQC_SEND_BURST:
- if (fe->ops.diseqc_send_burst) {
- err = fe->ops.diseqc_send_burst(fe, (fe_sec_mini_cmd_t) parg);
- fepriv->state = FESTATE_DISEQC;
- fepriv->status = 0;
- }
- break;
-
- case FE_SET_TONE:
- if (fe->ops.set_tone) {
- err = fe->ops.set_tone(fe, (fe_sec_tone_mode_t) parg);
- fepriv->tone = (fe_sec_tone_mode_t) parg;
- fepriv->state = FESTATE_DISEQC;
- fepriv->status = 0;
- }
- break;
-
- case FE_SET_VOLTAGE:
- if (fe->ops.set_voltage) {
- err = fe->ops.set_voltage(fe, (fe_sec_voltage_t) parg);
- fepriv->voltage = (fe_sec_voltage_t) parg;
- fepriv->state = FESTATE_DISEQC;
- fepriv->status = 0;
- }
- break;
-
- case FE_DISHNETWORK_SEND_LEGACY_CMD:
- if (fe->ops.dishnetwork_send_legacy_command) {
- err = fe->ops.dishnetwork_send_legacy_command(fe, (unsigned long) parg);
- fepriv->state = FESTATE_DISEQC;
- fepriv->status = 0;
- } else if (fe->ops.set_voltage) {
- /*
- * NOTE: This is a fallback condition. Some frontends
- * (stv0299 for instance) take longer than 8msec to
- * respond to a set_voltage command. Those switches
- * need custom routines to switch properly. For all
- * other frontends, the following shoule work ok.
- * Dish network legacy switches (as used by Dish500)
- * are controlled by sending 9-bit command words
- * spaced 8msec apart.
- * the actual command word is switch/port dependant
- * so it is up to the userspace application to send
- * the right command.
- * The command must always start with a '0' after
- * initialization, so parg is 8 bits and does not
- * include the initialization or start bit
- */
- unsigned long cmd = ((unsigned long) parg) << 1;
- struct timeval nexttime;
- struct timeval tv[10];
- int i;
- u8 last = 1;
- if (dvb_frontend_debug)
- printk("%s switch command: 0x%04lx\n", __FUNCTION__, cmd);
- do_gettimeofday(&nexttime);
- if (dvb_frontend_debug)
- memcpy(&tv[0], &nexttime, sizeof(struct timeval));
- /* before sending a command, initialize by sending
- * a 32ms 18V to the switch
- */
- fe->ops.set_voltage(fe, SEC_VOLTAGE_18);
- dvb_frontend_sleep_until(&nexttime, 32000);
-
- for (i = 0; i < 9; i++) {
- if (dvb_frontend_debug)
- do_gettimeofday(&tv[i + 1]);
- if ((cmd & 0x01) != last) {
- /* set voltage to (last ? 13V : 18V) */
- fe->ops.set_voltage(fe, (last) ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18);
- last = (last) ? 0 : 1;
- }
- cmd = cmd >> 1;
- if (i != 8)
- dvb_frontend_sleep_until(&nexttime, 8000);
- }
- if (dvb_frontend_debug) {
- printk("%s(%d): switch delay (should be 32k followed by all 8k\n",
- __FUNCTION__, fe->dvb->num);
- for (i = 1; i < 10; i++)
- printk("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i]));
- }
- err = 0;
- fepriv->state = FESTATE_DISEQC;
- fepriv->status = 0;
- }
- break;
-
- case FE_DISEQC_RECV_SLAVE_REPLY:
- if (fe->ops.diseqc_recv_slave_reply)
- err = fe->ops.diseqc_recv_slave_reply(fe, (struct dvb_diseqc_slave_reply*) parg);
- break;
-
- case FE_ENABLE_HIGH_LNB_VOLTAGE:
- if (fe->ops.enable_high_lnb_voltage)
- err = fe->ops.enable_high_lnb_voltage(fe, (long) parg);
- break;
-
- case FE_SET_FRONTEND: {
- struct dvb_frontend_tune_settings fetunesettings;
-
- memcpy (&fepriv->parameters, parg,
- sizeof (struct dvb_frontend_parameters));
-
- memset(&fetunesettings, 0, sizeof(struct dvb_frontend_tune_settings));
- memcpy(&fetunesettings.parameters, parg,
- sizeof (struct dvb_frontend_parameters));
-
- /* force auto frequency inversion if requested */
- if (dvb_force_auto_inversion) {
- fepriv->parameters.inversion = INVERSION_AUTO;
- fetunesettings.parameters.inversion = INVERSION_AUTO;
- }
- if (fe->ops.info.type == FE_OFDM) {
- /* without hierachical coding code_rate_LP is irrelevant,
- * so we tolerate the otherwise invalid FEC_NONE setting */
- if (fepriv->parameters.u.ofdm.hierarchy_information == HIERARCHY_NONE &&
- fepriv->parameters.u.ofdm.code_rate_LP == FEC_NONE)
- fepriv->parameters.u.ofdm.code_rate_LP = FEC_AUTO;
- }
-
- /* get frontend-specific tuning settings */
- if (fe->ops.get_tune_settings && (fe->ops.get_tune_settings(fe, &fetunesettings) == 0)) {
- fepriv->min_delay = (fetunesettings.min_delay_ms * HZ) / 1000;
- fepriv->max_drift = fetunesettings.max_drift;
- fepriv->step_size = fetunesettings.step_size;
- } else {
- /* default values */
- switch(fe->ops.info.type) {
- case FE_QPSK:
- fepriv->min_delay = HZ/20;
- fepriv->step_size = fepriv->parameters.u.qpsk.symbol_rate / 16000;
- fepriv->max_drift = fepriv->parameters.u.qpsk.symbol_rate / 2000;
- break;
-
- case FE_QAM:
- fepriv->min_delay = HZ/20;
- fepriv->step_size = 0; /* no zigzag */
- fepriv->max_drift = 0;
- break;
-
- case FE_OFDM:
- fepriv->min_delay = HZ/20;
- fepriv->step_size = fe->ops.info.frequency_stepsize * 2;
- fepriv->max_drift = (fe->ops.info.frequency_stepsize * 2) + 1;
- break;
- case FE_ATSC:
- fepriv->min_delay = HZ/20;
- fepriv->step_size = 0;
- fepriv->max_drift = 0;
- break;
- }
- }
- if (dvb_override_tune_delay > 0)
- fepriv->min_delay = (dvb_override_tune_delay * HZ) / 1000;
-
- fepriv->state = FESTATE_RETUNE;
- dvb_frontend_wakeup(fe);
- dvb_frontend_add_event(fe, 0);
- fepriv->status = 0;
- err = 0;
- break;
- }
-
- case FE_GET_EVENT:
- err = dvb_frontend_get_event (fe, parg, file->f_flags);
- break;
-
- case FE_GET_FRONTEND:
- if (fe->ops.get_frontend) {
- memcpy (parg, &fepriv->parameters, sizeof (struct dvb_frontend_parameters));
- err = fe->ops.get_frontend(fe, (struct dvb_frontend_parameters*) parg);
- }
- break;
-
- case FE_SET_FRONTEND_TUNE_MODE:
- fepriv->tune_mode_flags = (unsigned long) parg;
- err = 0;
- break;
- };
-
- up (&fepriv->sem);
- return err;
-}
-
-static unsigned int dvb_frontend_poll(struct file *file, struct poll_table_struct *wait)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_frontend *fe = dvbdev->priv;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- dprintk ("%s\n", __FUNCTION__);
-
- poll_wait (file, &fepriv->events.wait_queue, wait);
-
- if (fepriv->events.eventw != fepriv->events.eventr)
- return (POLLIN | POLLRDNORM | POLLPRI);
-
- return 0;
-}
-
-static int dvb_frontend_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_frontend *fe = dvbdev->priv;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
- int ret;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if ((ret = dvb_generic_open (inode, file)) < 0)
- return ret;
-
- if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
-
- /* normal tune mode when opened R/W */
- fepriv->tune_mode_flags &= ~FE_TUNE_MODE_ONESHOT;
- fepriv->tone = -1;
- fepriv->voltage = -1;
-
- ret = dvb_frontend_start (fe);
- if (ret)
- dvb_generic_release (inode, file);
-
- /* empty event queue */
- fepriv->events.eventr = fepriv->events.eventw = 0;
- }
-
- return ret;
-}
-
-static int dvb_frontend_release(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_frontend *fe = dvbdev->priv;
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if ((file->f_flags & O_ACCMODE) != O_RDONLY)
- fepriv->release_jiffies = jiffies;
-
- return dvb_generic_release (inode, file);
-}
-
-static struct file_operations dvb_frontend_fops = {
- .owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
- .poll = dvb_frontend_poll,
- .open = dvb_frontend_open,
- .release = dvb_frontend_release
-};
-
-int dvb_register_frontend(struct dvb_adapter* dvb,
- struct dvb_frontend* fe)
-{
- struct dvb_frontend_private *fepriv;
- static const struct dvb_device dvbdev_template = {
- .users = ~0,
- .writers = 1,
- .readers = (~0)-1,
- .fops = &dvb_frontend_fops,
- .kernel_ioctl = dvb_frontend_ioctl
- };
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (mutex_lock_interruptible(&frontend_mutex))
- return -ERESTARTSYS;
-
- fe->frontend_priv = kzalloc(sizeof(struct dvb_frontend_private), GFP_KERNEL);
- if (fe->frontend_priv == NULL) {
- mutex_unlock(&frontend_mutex);
- return -ENOMEM;
- }
- fepriv = fe->frontend_priv;
-
- init_MUTEX (&fepriv->sem);
- init_waitqueue_head (&fepriv->wait_queue);
- init_waitqueue_head (&fepriv->events.wait_queue);
- init_MUTEX (&fepriv->events.sem);
- fe->dvb = dvb;
- fepriv->inversion = INVERSION_OFF;
-
- printk ("DVB: registering frontend %i (%s)...\n",
- fe->dvb->num,
- fe->ops.info.name);
-
- dvb_register_device (fe->dvb, &fepriv->dvbdev, &dvbdev_template,
- fe, DVB_DEVICE_FRONTEND);
-
- mutex_unlock(&frontend_mutex);
- return 0;
-}
-EXPORT_SYMBOL(dvb_register_frontend);
-
-int dvb_unregister_frontend(struct dvb_frontend* fe)
-{
- struct dvb_frontend_private *fepriv = fe->frontend_priv;
- dprintk ("%s\n", __FUNCTION__);
-
- mutex_lock(&frontend_mutex);
- dvb_unregister_device (fepriv->dvbdev);
- dvb_frontend_stop (fe);
- if (fe->ops.tuner_ops.release) {
- fe->ops.tuner_ops.release(fe);
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
- }
- if (fe->ops.release)
- fe->ops.release(fe);
- else
- printk("dvb_frontend: Demodulator (%s) does not have a release callback!\n", fe->ops.info.name);
- /* fe is invalid now */
- kfree(fepriv);
- mutex_unlock(&frontend_mutex);
- return 0;
-}
-EXPORT_SYMBOL(dvb_unregister_frontend);
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
deleted file mode 100644
index 2887e2b862a..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * dvb_frontend.h
- *
- * Copyright (C) 2001 convergence integrated media GmbH
- * Copyright (C) 2004 convergence GmbH
- *
- * Written by Ralph Metzler
- * Overhauled by Holger Waechtler
- * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _DVB_FRONTEND_H_
-#define _DVB_FRONTEND_H_
-
-#include <linux/types.h>
-#include <linux/sched.h>
-#include <linux/ioctl.h>
-#include <linux/i2c.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/delay.h>
-
-#include <linux/dvb/frontend.h>
-
-#include "dvbdev.h"
-
-struct dvb_frontend_tune_settings {
- int min_delay_ms;
- int step_size;
- int max_drift;
- struct dvb_frontend_parameters parameters;
-};
-
-struct dvb_frontend;
-
-struct dvb_tuner_info {
- char name[128];
-
- u32 frequency_min;
- u32 frequency_max;
- u32 frequency_step;
-
- u32 bandwidth_min;
- u32 bandwidth_max;
- u32 bandwidth_step;
-};
-
-struct dvb_tuner_ops {
-
- struct dvb_tuner_info info;
-
- int (*release)(struct dvb_frontend *fe);
- int (*init)(struct dvb_frontend *fe);
- int (*sleep)(struct dvb_frontend *fe);
-
- /** This is for simple PLLs - set all parameters in one go. */
- int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
-
- /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
- int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);
-
- int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
- int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
-
-#define TUNER_STATUS_LOCKED 1
- int (*get_status)(struct dvb_frontend *fe, u32 *status);
-
- /** These are provided seperately from set_params in order to facilitate silicon
- * tuners which require sophisticated tuning loops, controlling each parameter seperately. */
- int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
- int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
-};
-
-struct dvb_frontend_ops {
-
- struct dvb_frontend_info info;
-
- void (*release)(struct dvb_frontend* fe);
-
- int (*init)(struct dvb_frontend* fe);
- int (*sleep)(struct dvb_frontend* fe);
-
- /* if this is set, it overrides the default swzigzag */
- int (*tune)(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* params,
- unsigned int mode_flags,
- int *delay,
- fe_status_t *status);
- /* get frontend tuning algorithm from the module */
- int (*get_frontend_algo)(struct dvb_frontend *fe);
-
- /* these two are only used for the swzigzag code */
- int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
- int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
-
- int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
-
- int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
- int (*read_ber)(struct dvb_frontend* fe, u32* ber);
- int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
- int (*read_snr)(struct dvb_frontend* fe, u16* snr);
- int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
-
- int (*diseqc_reset_overload)(struct dvb_frontend* fe);
- int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
- int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
- int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
- int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
- int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
- int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
- int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
- int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
-
- struct dvb_tuner_ops tuner_ops;
-};
-
-#define MAX_EVENT 8
-
-struct dvb_fe_events {
- struct dvb_frontend_event events[MAX_EVENT];
- int eventw;
- int eventr;
- int overflow;
- wait_queue_head_t wait_queue;
- struct semaphore sem;
-};
-
-struct dvb_frontend {
- struct dvb_frontend_ops ops;
- struct dvb_adapter *dvb;
- void* demodulator_priv;
- void* tuner_priv;
- void* frontend_priv;
- void* misc_priv;
-};
-
-extern int dvb_register_frontend(struct dvb_adapter* dvb,
- struct dvb_frontend* fe);
-
-extern int dvb_unregister_frontend(struct dvb_frontend* fe);
-
-extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
-
-extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
-extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);
-
-#endif
diff --git a/drivers/media/dvb/dvb-core/dvb_math.c b/drivers/media/dvb/dvb-core/dvb_math.c
deleted file mode 100644
index beb7c93aa6c..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_math.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * dvb-math provides some complex fixed-point math
- * operations shared between the dvb related stuff
- *
- * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com)
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <linux/bitops.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <asm/bug.h>
-#include "dvb_math.h"
-
-static const unsigned short logtable[256] = {
- 0x0000, 0x0171, 0x02e0, 0x044e, 0x05ba, 0x0725, 0x088e, 0x09f7,
- 0x0b5d, 0x0cc3, 0x0e27, 0x0f8a, 0x10eb, 0x124b, 0x13aa, 0x1508,
- 0x1664, 0x17bf, 0x1919, 0x1a71, 0x1bc8, 0x1d1e, 0x1e73, 0x1fc6,
- 0x2119, 0x226a, 0x23ba, 0x2508, 0x2656, 0x27a2, 0x28ed, 0x2a37,
- 0x2b80, 0x2cc8, 0x2e0f, 0x2f54, 0x3098, 0x31dc, 0x331e, 0x345f,
- 0x359f, 0x36de, 0x381b, 0x3958, 0x3a94, 0x3bce, 0x3d08, 0x3e41,
- 0x3f78, 0x40af, 0x41e4, 0x4319, 0x444c, 0x457f, 0x46b0, 0x47e1,
- 0x4910, 0x4a3f, 0x4b6c, 0x4c99, 0x4dc5, 0x4eef, 0x5019, 0x5142,
- 0x526a, 0x5391, 0x54b7, 0x55dc, 0x5700, 0x5824, 0x5946, 0x5a68,
- 0x5b89, 0x5ca8, 0x5dc7, 0x5ee5, 0x6003, 0x611f, 0x623a, 0x6355,
- 0x646f, 0x6588, 0x66a0, 0x67b7, 0x68ce, 0x69e4, 0x6af8, 0x6c0c,
- 0x6d20, 0x6e32, 0x6f44, 0x7055, 0x7165, 0x7274, 0x7383, 0x7490,
- 0x759d, 0x76aa, 0x77b5, 0x78c0, 0x79ca, 0x7ad3, 0x7bdb, 0x7ce3,
- 0x7dea, 0x7ef0, 0x7ff6, 0x80fb, 0x81ff, 0x8302, 0x8405, 0x8507,
- 0x8608, 0x8709, 0x8809, 0x8908, 0x8a06, 0x8b04, 0x8c01, 0x8cfe,
- 0x8dfa, 0x8ef5, 0x8fef, 0x90e9, 0x91e2, 0x92db, 0x93d2, 0x94ca,
- 0x95c0, 0x96b6, 0x97ab, 0x98a0, 0x9994, 0x9a87, 0x9b7a, 0x9c6c,
- 0x9d5e, 0x9e4f, 0x9f3f, 0xa02e, 0xa11e, 0xa20c, 0xa2fa, 0xa3e7,
- 0xa4d4, 0xa5c0, 0xa6ab, 0xa796, 0xa881, 0xa96a, 0xaa53, 0xab3c,
- 0xac24, 0xad0c, 0xadf2, 0xaed9, 0xafbe, 0xb0a4, 0xb188, 0xb26c,
- 0xb350, 0xb433, 0xb515, 0xb5f7, 0xb6d9, 0xb7ba, 0xb89a, 0xb97a,
- 0xba59, 0xbb38, 0xbc16, 0xbcf4, 0xbdd1, 0xbead, 0xbf8a, 0xc065,
- 0xc140, 0xc21b, 0xc2f5, 0xc3cf, 0xc4a8, 0xc580, 0xc658, 0xc730,
- 0xc807, 0xc8de, 0xc9b4, 0xca8a, 0xcb5f, 0xcc34, 0xcd08, 0xcddc,
- 0xceaf, 0xcf82, 0xd054, 0xd126, 0xd1f7, 0xd2c8, 0xd399, 0xd469,
- 0xd538, 0xd607, 0xd6d6, 0xd7a4, 0xd872, 0xd93f, 0xda0c, 0xdad9,
- 0xdba5, 0xdc70, 0xdd3b, 0xde06, 0xded0, 0xdf9a, 0xe063, 0xe12c,
- 0xe1f5, 0xe2bd, 0xe385, 0xe44c, 0xe513, 0xe5d9, 0xe69f, 0xe765,
- 0xe82a, 0xe8ef, 0xe9b3, 0xea77, 0xeb3b, 0xebfe, 0xecc1, 0xed83,
- 0xee45, 0xef06, 0xefc8, 0xf088, 0xf149, 0xf209, 0xf2c8, 0xf387,
- 0xf446, 0xf505, 0xf5c3, 0xf680, 0xf73e, 0xf7fb, 0xf8b7, 0xf973,
- 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47
-};
-
-unsigned int intlog2(u32 value)
-{
- /**
- * returns: log2(value) * 2^24
- * wrong result if value = 0 (log2(0) is undefined)
- */
- unsigned int msb;
- unsigned int logentry;
- unsigned int significand;
- unsigned int interpolation;
-
- if (unlikely(value == 0)) {
- WARN_ON(1);
- return 0;
- }
-
- /* first detect the msb (count begins at 0) */
- msb = fls(value) - 1;
-
- /**
- * now we use a logtable after the following method:
- *
- * log2(2^x * y) * 2^24 = x * 2^24 + log2(y) * 2^24
- * where x = msb and therefore 1 <= y < 2
- * first y is determined by shifting the value left
- * so that msb is bit 31
- * 0x00231f56 -> 0x8C7D5800
- * the result is y * 2^31 -> "significand"
- * then the highest 9 bits are used for a table lookup
- * the highest bit is discarded because it's always set
- * the highest nine bits in our example are 100011000
- * so we would use the entry 0x18
- */
- significand = value << (31 - msb);
- logentry = (significand >> 23) & 0xff;
-
- /**
- * last step we do is interpolation because of the
- * limitations of the log table the error is that part of
- * the significand which isn't used for lookup then we
- * compute the ratio between the error and the next table entry
- * and interpolate it between the log table entry used and the
- * next one the biggest error possible is 0x7fffff
- * (in our example it's 0x7D5800)
- * needed value for next table entry is 0x800000
- * so the interpolation is
- * (error / 0x800000) * (logtable_next - logtable_current)
- * in the implementation the division is moved to the end for
- * better accuracy there is also an overflow correction if
- * logtable_next is 256
- */
- interpolation = ((significand & 0x7fffff) *
- ((logtable[(logentry + 1) & 0xff] -
- logtable[logentry]) & 0xffff)) >> 15;
-
- /* now we return the result */
- return ((msb << 24) + (logtable[logentry] << 8) + interpolation);
-}
-EXPORT_SYMBOL(intlog2);
-
-unsigned int intlog10(u32 value)
-{
- /**
- * returns: log10(value) * 2^24
- * wrong result if value = 0 (log10(0) is undefined)
- */
- u64 log;
-
- if (unlikely(value == 0)) {
- WARN_ON(1);
- return 0;
- }
-
- log = intlog2(value);
-
- /**
- * we use the following method:
- * log10(x) = log2(x) * log10(2)
- */
-
- return (log * 646456993) >> 31;
-}
-EXPORT_SYMBOL(intlog10);
diff --git a/drivers/media/dvb/dvb-core/dvb_math.h b/drivers/media/dvb/dvb-core/dvb_math.h
deleted file mode 100644
index aecc867e940..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_math.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * dvb-math provides some complex fixed-point math
- * operations shared between the dvb related stuff
- *
- * Copyright (C) 2006 Christoph Pfister (christophpfister@gmail.com)
- *
- * This library is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __DVB_MATH_H
-#define __DVB_MATH_H
-
-#include <linux/types.h>
-
-/**
- * computes log2 of a value; the result is shifted left by 24 bits
- *
- * to use rational values you can use the following method:
- * intlog2(value) = intlog2(value * 2^x) - x * 2^24
- *
- * example: intlog2(8) will give 3 << 24 = 3 * 2^24
- * example: intlog2(9) will give 3 << 24 + ... = 3.16... * 2^24
- * example: intlog2(1.5) = intlog2(3) - 2^24 = 0.584... * 2^24
- *
- * @param value The value (must be != 0)
- * @return log2(value) * 2^24
- */
-extern unsigned int intlog2(u32 value);
-
-/**
- * computes log10 of a value; the result is shifted left by 24 bits
- *
- * to use rational values you can use the following method:
- * intlog10(value) = intlog10(value * 10^x) - x * 2^24
- *
- * example: intlog10(1000) will give 3 << 24 = 3 * 2^24
- * due to the implementation intlog10(1000) might be not exactly 3 * 2^24
- *
- * look at intlog2 for similar examples
- *
- * @param value The value (must be != 0)
- * @return log10(value) * 2^24
- */
-extern unsigned int intlog10(u32 value);
-
-#endif
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
deleted file mode 100644
index 8859ab74f0f..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ /dev/null
@@ -1,1478 +0,0 @@
-/*
- * dvb_net.c
- *
- * Copyright (C) 2001 Convergence integrated media GmbH
- * Ralph Metzler <ralph@convergence.de>
- * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
- *
- * ULE Decapsulation code:
- * Copyright (C) 2003, 2004 gcs - Global Communication & Services GmbH.
- * and Department of Scientific Computing
- * Paris Lodron University of Salzburg.
- * Hilmar Linder <hlinder@cosy.sbg.ac.at>
- * and Wolfram Stering <wstering@cosy.sbg.ac.at>
- *
- * ULE Decaps according to RFC 4326.
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- */
-
-/*
- * ULE ChangeLog:
- * Feb 2004: hl/ws v1: Implementing draft-fair-ipdvb-ule-01.txt
- *
- * Dec 2004: hl/ws v2: Implementing draft-ietf-ipdvb-ule-03.txt:
- * ULE Extension header handling.
- * Bugreports by Moritz Vieth and Hanno Tersteegen,
- * Fraunhofer Institute for Open Communication Systems
- * Competence Center for Advanced Satellite Communications.
- * Bugfixes and robustness improvements.
- * Filtering on dest MAC addresses, if present (D-Bit = 0)
- * ULE_DEBUG compile-time option.
- * Apr 2006: cp v3: Bugfixes and compliency with RFC 4326 (ULE) by
- * Christian Praehauser <cpraehaus@cosy.sbg.ac.at>,
- * Paris Lodron University of Salzburg.
- */
-
-/*
- * FIXME / TODO (dvb_net.c):
- *
- * Unloading does not work for 2.6.9 kernels: a refcount doesn't go to zero.
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/dvb/net.h>
-#include <linux/uio.h>
-#include <asm/uaccess.h>
-#include <linux/crc32.h>
-#include <linux/mutex.h>
-
-#include "dvb_demux.h"
-#include "dvb_net.h"
-
-static int dvb_net_debug;
-module_param(dvb_net_debug, int, 0444);
-MODULE_PARM_DESC(dvb_net_debug, "enable debug messages");
-
-#define dprintk(x...) do { if (dvb_net_debug) printk(x); } while (0)
-
-
-static inline __u32 iov_crc32( __u32 c, struct kvec *iov, unsigned int cnt )
-{
- unsigned int j;
- for (j = 0; j < cnt; j++)
- c = crc32_be( c, iov[j].iov_base, iov[j].iov_len );
- return c;
-}
-
-
-#define DVB_NET_MULTICAST_MAX 10
-
-#undef ULE_DEBUG
-
-#ifdef ULE_DEBUG
-
-#define MAC_ADDR_PRINTFMT "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x"
-#define MAX_ADDR_PRINTFMT_ARGS(macap) (macap)[0],(macap)[1],(macap)[2],(macap)[3],(macap)[4],(macap)[5]
-
-#define isprint(c) ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
-
-static void hexdump( const unsigned char *buf, unsigned short len )
-{
- char str[80], octet[10];
- int ofs, i, l;
-
- for (ofs = 0; ofs < len; ofs += 16) {
- sprintf( str, "%03d: ", ofs );
-
- for (i = 0; i < 16; i++) {
- if ((i + ofs) < len)
- sprintf( octet, "%02x ", buf[ofs + i] );
- else
- strcpy( octet, " " );
-
- strcat( str, octet );
- }
- strcat( str, " " );
- l = strlen( str );
-
- for (i = 0; (i < 16) && ((i + ofs) < len); i++)
- str[l++] = isprint( buf[ofs + i] ) ? buf[ofs + i] : '.';
-
- str[l] = '\0';
- printk( KERN_WARNING "%s\n", str );
- }
-}
-
-#endif
-
-struct dvb_net_priv {
- int in_use;
- struct net_device_stats stats;
- u16 pid;
- struct dvb_net *host;
- struct dmx_demux *demux;
- struct dmx_section_feed *secfeed;
- struct dmx_section_filter *secfilter;
- struct dmx_ts_feed *tsfeed;
- int multi_num;
- struct dmx_section_filter *multi_secfilter[DVB_NET_MULTICAST_MAX];
- unsigned char multi_macs[DVB_NET_MULTICAST_MAX][6];
- int rx_mode;
-#define RX_MODE_UNI 0
-#define RX_MODE_MULTI 1
-#define RX_MODE_ALL_MULTI 2
-#define RX_MODE_PROMISC 3
- struct work_struct set_multicast_list_wq;
- struct work_struct restart_net_feed_wq;
- unsigned char feedtype; /* Either FEED_TYPE_ or FEED_TYPE_ULE */
- int need_pusi; /* Set to 1, if synchronization on PUSI required. */
- unsigned char tscc; /* TS continuity counter after sync on PUSI. */
- struct sk_buff *ule_skb; /* ULE SNDU decodes into this buffer. */
- unsigned char *ule_next_hdr; /* Pointer into skb to next ULE extension header. */
- unsigned short ule_sndu_len; /* ULE SNDU length in bytes, w/o D-Bit. */
- unsigned short ule_sndu_type; /* ULE SNDU type field, complete. */
- unsigned char ule_sndu_type_1; /* ULE SNDU type field, if split across 2 TS cells. */
- unsigned char ule_dbit; /* Whether the DestMAC address present
- * or not (bit is set). */
- unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */
- int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */
- unsigned long ts_count; /* Current ts cell counter. */
- struct mutex mutex;
-};
-
-
-/**
- * Determine the packet's protocol ID. The rule here is that we
- * assume 802.3 if the type field is short enough to be a length.
- * This is normal practice and works for any 'now in use' protocol.
- *
- * stolen from eth.c out of the linux kernel, hacked for dvb-device
- * by Michael Holzt <kju@debian.org>
- */
-static unsigned short dvb_net_eth_type_trans(struct sk_buff *skb,
- struct net_device *dev)
-{
- struct ethhdr *eth;
- unsigned char *rawp;
-
- skb->mac.raw=skb->data;
- skb_pull(skb,dev->hard_header_len);
- eth = eth_hdr(skb);
-
- if (*eth->h_dest & 1) {
- if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0)
- skb->pkt_type=PACKET_BROADCAST;
- else
- skb->pkt_type=PACKET_MULTICAST;
- }
-
- if (ntohs(eth->h_proto) >= 1536)
- return eth->h_proto;
-
- rawp = skb->data;
-
- /**
- * This is a magic hack to spot IPX packets. Older Novell breaks
- * the protocol design and runs IPX over 802.3 without an 802.2 LLC
- * layer. We look for FFFF which isn't a used 802.2 SSAP/DSAP. This
- * won't work for fault tolerant netware but does for the rest.
- */
- if (*(unsigned short *)rawp == 0xFFFF)
- return htons(ETH_P_802_3);
-
- /**
- * Real 802.2 LLC
- */
- return htons(ETH_P_802_2);
-}
-
-#define TS_SZ 188
-#define TS_SYNC 0x47
-#define TS_TEI 0x80
-#define TS_SC 0xC0
-#define TS_PUSI 0x40
-#define TS_AF_A 0x20
-#define TS_AF_D 0x10
-
-/* ULE Extension Header handlers. */
-
-#define ULE_TEST 0
-#define ULE_BRIDGED 1
-
-#define ULE_OPTEXTHDR_PADDING 0
-
-static int ule_test_sndu( struct dvb_net_priv *p )
-{
- return -1;
-}
-
-static int ule_bridged_sndu( struct dvb_net_priv *p )
-{
- struct ethhdr *hdr = (struct ethhdr*) p->ule_next_hdr;
- if(ntohs(hdr->h_proto) < 1536) {
- int framelen = p->ule_sndu_len - ((p->ule_next_hdr+sizeof(struct ethhdr)) - p->ule_skb->data);
- /* A frame Type < 1536 for a bridged frame, introduces a LLC Length field. */
- if(framelen != ntohs(hdr->h_proto)) {
- return -1;
- }
- }
- /* Note:
- * From RFC4326:
- * "A bridged SNDU is a Mandatory Extension Header of Type 1.
- * It must be the final (or only) extension header specified in the header chain of a SNDU."
- * The 'ule_bridged' flag will cause the extension header processing loop to terminate.
- */
- p->ule_bridged = 1;
- return 0;
-}
-
-static int ule_exthdr_padding(struct dvb_net_priv *p)
-{
- return 0;
-}
-
-/** Handle ULE extension headers.
- * Function is called after a successful CRC32 verification of an ULE SNDU to complete its decoding.
- * Returns: >= 0: nr. of bytes consumed by next extension header
- * -1: Mandatory extension header that is not recognized or TEST SNDU; discard.
- */
-static int handle_one_ule_extension( struct dvb_net_priv *p )
-{
- /* Table of mandatory extension header handlers. The header type is the index. */
- static int (*ule_mandatory_ext_handlers[255])( struct dvb_net_priv *p ) =
- { [0] = ule_test_sndu, [1] = ule_bridged_sndu, [2] = NULL, };
-
- /* Table of optional extension header handlers. The header type is the index. */
- static int (*ule_optional_ext_handlers[255])( struct dvb_net_priv *p ) =
- { [0] = ule_exthdr_padding, [1] = NULL, };
-
- int ext_len = 0;
- unsigned char hlen = (p->ule_sndu_type & 0x0700) >> 8;
- unsigned char htype = p->ule_sndu_type & 0x00FF;
-
- /* Discriminate mandatory and optional extension headers. */
- if (hlen == 0) {
- /* Mandatory extension header */
- if (ule_mandatory_ext_handlers[htype]) {
- ext_len = ule_mandatory_ext_handlers[htype]( p );
- if(ext_len >= 0) {
- p->ule_next_hdr += ext_len;
- if (!p->ule_bridged) {
- p->ule_sndu_type = ntohs(*(unsigned short *)p->ule_next_hdr);
- p->ule_next_hdr += 2;
- } else {
- p->ule_sndu_type = ntohs(*(unsigned short *)(p->ule_next_hdr + ((p->ule_dbit ? 2 : 3) * ETH_ALEN)));
- /* This assures the extension handling loop will terminate. */
- }
- }
- // else: extension handler failed or SNDU should be discarded
- } else
- ext_len = -1; /* SNDU has to be discarded. */
- } else {
- /* Optional extension header. Calculate the length. */
- ext_len = hlen << 1;
- /* Process the optional extension header according to its type. */
- if (ule_optional_ext_handlers[htype])
- (void)ule_optional_ext_handlers[htype]( p );
- p->ule_next_hdr += ext_len;
- p->ule_sndu_type = ntohs( *(unsigned short *)(p->ule_next_hdr-2) );
- /*
- * note: the length of the next header type is included in the
- * length of THIS optional extension header
- */
- }
-
- return ext_len;
-}
-
-static int handle_ule_extensions( struct dvb_net_priv *p )
-{
- int total_ext_len = 0, l;
-
- p->ule_next_hdr = p->ule_skb->data;
- do {
- l = handle_one_ule_extension( p );
- if (l < 0)
- return l; /* Stop extension header processing and discard SNDU. */
- total_ext_len += l;
-#ifdef ULE_DEBUG
- dprintk("handle_ule_extensions: ule_next_hdr=%p, ule_sndu_type=%i, "
- "l=%i, total_ext_len=%i\n", p->ule_next_hdr,
- (int) p->ule_sndu_type, l, total_ext_len);
-#endif
-
- } while (p->ule_sndu_type < 1536);
-
- return total_ext_len;
-}
-
-
-/** Prepare for a new ULE SNDU: reset the decoder state. */
-static inline void reset_ule( struct dvb_net_priv *p )
-{
- p->ule_skb = NULL;
- p->ule_next_hdr = NULL;
- p->ule_sndu_len = 0;
- p->ule_sndu_type = 0;
- p->ule_sndu_type_1 = 0;
- p->ule_sndu_remain = 0;
- p->ule_dbit = 0xFF;
- p->ule_bridged = 0;
-}
-
-/**
- * Decode ULE SNDUs according to draft-ietf-ipdvb-ule-03.txt from a sequence of
- * TS cells of a single PID.
- */
-static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
-{
- struct dvb_net_priv *priv = dev->priv;
- unsigned long skipped = 0L;
- u8 *ts, *ts_end, *from_where = NULL, ts_remain = 0, how_much = 0, new_ts = 1;
- struct ethhdr *ethh = NULL;
-
-#ifdef ULE_DEBUG
- /* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */
- static unsigned char ule_hist[100*TS_SZ];
- static unsigned char *ule_where = ule_hist, ule_dump = 0;
-#endif
-
- if (dev == NULL) {
- printk( KERN_ERR "NO netdev struct!\n" );
- return;
- }
-
- /* For all TS cells in current buffer.
- * Appearently, we are called for every single TS cell.
- */
- for (ts = (char *)buf, ts_end = (char *)buf + buf_len; ts < ts_end; /* no default incr. */ ) {
-
- if (new_ts) {
- /* We are about to process a new TS cell. */
-
-#ifdef ULE_DEBUG
- if (ule_where >= &ule_hist[100*TS_SZ]) ule_where = ule_hist;
- memcpy( ule_where, ts, TS_SZ );
- if (ule_dump) {
- hexdump( ule_where, TS_SZ );
- ule_dump = 0;
- }
- ule_where += TS_SZ;
-#endif
-
- /* Check TS error conditions: sync_byte, transport_error_indicator, scrambling_control . */
- if ((ts[0] != TS_SYNC) || (ts[1] & TS_TEI) || ((ts[3] & TS_SC) != 0)) {
- printk(KERN_WARNING "%lu: Invalid TS cell: SYNC %#x, TEI %u, SC %#x.\n",
- priv->ts_count, ts[0], ts[1] & TS_TEI >> 7, ts[3] & 0xC0 >> 6);
-
- /* Drop partly decoded SNDU, reset state, resync on PUSI. */
- if (priv->ule_skb) {
- dev_kfree_skb( priv->ule_skb );
- /* Prepare for next SNDU. */
- priv->stats.rx_errors++;
- priv->stats.rx_frame_errors++;
- }
- reset_ule(priv);
- priv->need_pusi = 1;
-
- /* Continue with next TS cell. */
- ts += TS_SZ;
- priv->ts_count++;
- continue;
- }
-
- ts_remain = 184;
- from_where = ts + 4;
- }
- /* Synchronize on PUSI, if required. */
- if (priv->need_pusi) {
- if (ts[1] & TS_PUSI) {
- /* Find beginning of first ULE SNDU in current TS cell. */
- /* Synchronize continuity counter. */
- priv->tscc = ts[3] & 0x0F;
- /* There is a pointer field here. */
- if (ts[4] > ts_remain) {
- printk(KERN_ERR "%lu: Invalid ULE packet "
- "(pointer field %d)\n", priv->ts_count, ts[4]);
- ts += TS_SZ;
- priv->ts_count++;
- continue;
- }
- /* Skip to destination of pointer field. */
- from_where = &ts[5] + ts[4];
- ts_remain -= 1 + ts[4];
- skipped = 0;
- } else {
- skipped++;
- ts += TS_SZ;
- priv->ts_count++;
- continue;
- }
- }
-
- if (new_ts) {
- /* Check continuity counter. */
- if ((ts[3] & 0x0F) == priv->tscc)
- priv->tscc = (priv->tscc + 1) & 0x0F;
- else {
- /* TS discontinuity handling: */
- printk(KERN_WARNING "%lu: TS discontinuity: got %#x, "
- "expected %#x.\n", priv->ts_count, ts[3] & 0x0F, priv->tscc);
- /* Drop partly decoded SNDU, reset state, resync on PUSI. */
- if (priv->ule_skb) {
- dev_kfree_skb( priv->ule_skb );
- /* Prepare for next SNDU. */
- // reset_ule(priv); moved to below.
- priv->stats.rx_errors++;
- priv->stats.rx_frame_errors++;
- }
- reset_ule(priv);
- /* skip to next PUSI. */
- priv->need_pusi = 1;
- continue;
- }
- /* If we still have an incomplete payload, but PUSI is
- * set; some TS cells are missing.
- * This is only possible here, if we missed exactly 16 TS
- * cells (continuity counter wrap). */
- if (ts[1] & TS_PUSI) {
- if (! priv->need_pusi) {
- if (!(*from_where < (ts_remain-1)) || *from_where != priv->ule_sndu_remain) {
- /* Pointer field is invalid. Drop this TS cell and any started ULE SNDU. */
- printk(KERN_WARNING "%lu: Invalid pointer "
- "field: %u.\n", priv->ts_count, *from_where);
-
- /* Drop partly decoded SNDU, reset state, resync on PUSI. */
- if (priv->ule_skb) {
- dev_kfree_skb( priv->ule_skb );
- ((struct dvb_net_priv *) dev->priv)->stats.rx_errors++;
- ((struct dvb_net_priv *) dev->priv)->stats.rx_frame_errors++;
- }
- reset_ule(priv);
- priv->need_pusi = 1;
- continue;
- }
- /* Skip pointer field (we're processing a
- * packed payload). */
- from_where += 1;
- ts_remain -= 1;
- } else
- priv->need_pusi = 0;
-
- if (priv->ule_sndu_remain > 183) {
- /* Current SNDU lacks more data than there could be available in the
- * current TS cell. */
- priv->stats.rx_errors++;
- priv->stats.rx_length_errors++;
- printk(KERN_WARNING "%lu: Expected %d more SNDU bytes, but "
- "got PUSI (pf %d, ts_remain %d). Flushing incomplete payload.\n",
- priv->ts_count, priv->ule_sndu_remain, ts[4], ts_remain);
- dev_kfree_skb(priv->ule_skb);
- /* Prepare for next SNDU. */
- reset_ule(priv);
- /* Resync: go to where pointer field points to: start of next ULE SNDU. */
- from_where += ts[4];
- ts_remain -= ts[4];
- }
- }
- }
-
- /* Check if new payload needs to be started. */
- if (priv->ule_skb == NULL) {
- /* Start a new payload with skb.
- * Find ULE header. It is only guaranteed that the
- * length field (2 bytes) is contained in the current
- * TS.
- * Check ts_remain has to be >= 2 here. */
- if (ts_remain < 2) {
- printk(KERN_WARNING "Invalid payload packing: only %d "
- "bytes left in TS. Resyncing.\n", ts_remain);
- priv->ule_sndu_len = 0;
- priv->need_pusi = 1;
- continue;
- }
-
- if (! priv->ule_sndu_len) {
- /* Got at least two bytes, thus extrace the SNDU length. */
- priv->ule_sndu_len = from_where[0] << 8 | from_where[1];
- if (priv->ule_sndu_len & 0x8000) {
- /* D-Bit is set: no dest mac present. */
- priv->ule_sndu_len &= 0x7FFF;
- priv->ule_dbit = 1;
- } else
- priv->ule_dbit = 0;
-
- if (priv->ule_sndu_len < 5) {
- printk(KERN_WARNING "%lu: Invalid ULE SNDU length %u. "
- "Resyncing.\n", priv->ts_count, priv->ule_sndu_len);
- priv->stats.rx_errors++;
- priv->stats.rx_length_errors++;
- priv->ule_sndu_len = 0;
- priv->need_pusi = 1;
- new_ts = 1;
- ts += TS_SZ;
- priv->ts_count++;
- continue;
- }
- ts_remain -= 2; /* consume the 2 bytes SNDU length. */
- from_where += 2;
- }
-
- /*
- * State of current TS:
- * ts_remain (remaining bytes in the current TS cell)
- * 0 ule_type is not available now, we need the next TS cell
- * 1 the first byte of the ule_type is present
- * >=2 full ULE header present, maybe some payload data as well.
- */
- switch (ts_remain) {
- case 1:
- priv->ule_sndu_type = from_where[0] << 8;
- priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */
- ts_remain -= 1; from_where += 1;
- /* Continue w/ next TS. */
- case 0:
- new_ts = 1;
- ts += TS_SZ;
- priv->ts_count++;
- continue;
-
- default: /* complete ULE header is present in current TS. */
- /* Extract ULE type field. */
- if (priv->ule_sndu_type_1) {
- priv->ule_sndu_type |= from_where[0];
- from_where += 1; /* points to payload start. */
- ts_remain -= 1;
- } else {
- /* Complete type is present in new TS. */
- priv->ule_sndu_type = from_where[0] << 8 | from_where[1];
- from_where += 2; /* points to payload start. */
- ts_remain -= 2;
- }
- break;
- }
-
- /* Allocate the skb (decoder target buffer) with the correct size, as follows:
- * prepare for the largest case: bridged SNDU with MAC address (dbit = 0). */
- priv->ule_skb = dev_alloc_skb( priv->ule_sndu_len + ETH_HLEN + ETH_ALEN );
- if (priv->ule_skb == NULL) {
- printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
- dev->name);
- ((struct dvb_net_priv *)dev->priv)->stats.rx_dropped++;
- return;
- }
-
- /* This includes the CRC32 _and_ dest mac, if !dbit. */
- priv->ule_sndu_remain = priv->ule_sndu_len;
- priv->ule_skb->dev = dev;
- /* Leave space for Ethernet or bridged SNDU header (eth hdr plus one MAC addr). */
- skb_reserve( priv->ule_skb, ETH_HLEN + ETH_ALEN );
- }
-
- /* Copy data into our current skb. */
- how_much = min(priv->ule_sndu_remain, (int)ts_remain);
- memcpy(skb_put(priv->ule_skb, how_much), from_where, how_much);
- priv->ule_sndu_remain -= how_much;
- ts_remain -= how_much;
- from_where += how_much;
-
- /* Check for complete payload. */
- if (priv->ule_sndu_remain <= 0) {
- /* Check CRC32, we've got it in our skb already. */
- unsigned short ulen = htons(priv->ule_sndu_len);
- unsigned short utype = htons(priv->ule_sndu_type);
- struct kvec iov[3] = {
- { &ulen, sizeof ulen },
- { &utype, sizeof utype },
- { priv->ule_skb->data, priv->ule_skb->len - 4 }
- };
- unsigned long ule_crc = ~0L, expected_crc;
- if (priv->ule_dbit) {
- /* Set D-bit for CRC32 verification,
- * if it was set originally. */
- ulen |= 0x0080;
- }
-
- ule_crc = iov_crc32(ule_crc, iov, 3);
- expected_crc = *((u8 *)priv->ule_skb->tail - 4) << 24 |
- *((u8 *)priv->ule_skb->tail - 3) << 16 |
- *((u8 *)priv->ule_skb->tail - 2) << 8 |
- *((u8 *)priv->ule_skb->tail - 1);
- if (ule_crc != expected_crc) {
- printk(KERN_WARNING "%lu: CRC32 check FAILED: %#lx / %#lx, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
- priv->ts_count, ule_crc, expected_crc, priv->ule_sndu_len, priv->ule_sndu_type, ts_remain, ts_remain > 2 ? *(unsigned short *)from_where : 0);
-
-#ifdef ULE_DEBUG
- hexdump( iov[0].iov_base, iov[0].iov_len );
- hexdump( iov[1].iov_base, iov[1].iov_len );
- hexdump( iov[2].iov_base, iov[2].iov_len );
-
- if (ule_where == ule_hist) {
- hexdump( &ule_hist[98*TS_SZ], TS_SZ );
- hexdump( &ule_hist[99*TS_SZ], TS_SZ );
- } else if (ule_where == &ule_hist[TS_SZ]) {
- hexdump( &ule_hist[99*TS_SZ], TS_SZ );
- hexdump( ule_hist, TS_SZ );
- } else {
- hexdump( ule_where - TS_SZ - TS_SZ, TS_SZ );
- hexdump( ule_where - TS_SZ, TS_SZ );
- }
- ule_dump = 1;
-#endif
-
- priv->stats.rx_errors++;
- priv->stats.rx_crc_errors++;
- dev_kfree_skb(priv->ule_skb);
- } else {
- /* CRC32 verified OK. */
- u8 dest_addr[ETH_ALEN];
- static const u8 bc_addr[ETH_ALEN] =
- { [ 0 ... ETH_ALEN-1] = 0xff };
-
- /* CRC32 was OK. Remove it from skb. */
- priv->ule_skb->tail -= 4;
- priv->ule_skb->len -= 4;
-
- if (!priv->ule_dbit) {
- /*
- * The destination MAC address is the
- * next data in the skb. It comes
- * before any extension headers.
- *
- * Check if the payload of this SNDU
- * should be passed up the stack.
- */
- register int drop = 0;
- if (priv->rx_mode != RX_MODE_PROMISC) {
- if (priv->ule_skb->data[0] & 0x01) {
- /* multicast or broadcast */
- if (memcmp(priv->ule_skb->data, bc_addr, ETH_ALEN)) {
- /* multicast */
- if (priv->rx_mode == RX_MODE_MULTI) {
- int i;
- for(i = 0; i < priv->multi_num && memcmp(priv->ule_skb->data, priv->multi_macs[i], ETH_ALEN); i++)
- ;
- if (i == priv->multi_num)
- drop = 1;
- } else if (priv->rx_mode != RX_MODE_ALL_MULTI)
- drop = 1; /* no broadcast; */
- /* else: all multicast mode: accept all multicast packets */
- }
- /* else: broadcast */
- }
- else if (memcmp(priv->ule_skb->data, dev->dev_addr, ETH_ALEN))
- drop = 1;
- /* else: destination address matches the MAC address of our receiver device */
- }
- /* else: promiscious mode; pass everything up the stack */
-
- if (drop) {
-#ifdef ULE_DEBUG
- dprintk("Dropping SNDU: MAC destination address does not match: dest addr: "MAC_ADDR_PRINTFMT", dev addr: "MAC_ADDR_PRINTFMT"\n",
- MAX_ADDR_PRINTFMT_ARGS(priv->ule_skb->data), MAX_ADDR_PRINTFMT_ARGS(dev->dev_addr));
-#endif
- dev_kfree_skb(priv->ule_skb);
- goto sndu_done;
- }
- else
- {
- memcpy(dest_addr, priv->ule_skb->data, ETH_ALEN);
- skb_pull(priv->ule_skb, ETH_ALEN);
- }
- }
-
- /* Handle ULE Extension Headers. */
- if (priv->ule_sndu_type < 1536) {
- /* There is an extension header. Handle it accordingly. */
- int l = handle_ule_extensions(priv);
- if (l < 0) {
- /* Mandatory extension header unknown or TEST SNDU. Drop it. */
- // printk( KERN_WARNING "Dropping SNDU, extension headers.\n" );
- dev_kfree_skb(priv->ule_skb);
- goto sndu_done;
- }
- skb_pull(priv->ule_skb, l);
- }
-
- /*
- * Construct/assure correct ethernet header.
- * Note: in bridged mode (priv->ule_bridged !=
- * 0) we already have the (original) ethernet
- * header at the start of the payload (after
- * optional dest. address and any extension
- * headers).
- */
-
- if (!priv->ule_bridged) {
- skb_push(priv->ule_skb, ETH_HLEN);
- ethh = (struct ethhdr *)priv->ule_skb->data;
- if (!priv->ule_dbit) {
- /* dest_addr buffer is only valid if priv->ule_dbit == 0 */
- memcpy(ethh->h_dest, dest_addr, ETH_ALEN);
- memset(ethh->h_source, 0, ETH_ALEN);
- }
- else /* zeroize source and dest */
- memset( ethh, 0, ETH_ALEN*2 );
-
- ethh->h_proto = htons(priv->ule_sndu_type);
- }
- /* else: skb is in correct state; nothing to do. */
- priv->ule_bridged = 0;
-
- /* Stuff into kernel's protocol stack. */
- priv->ule_skb->protocol = dvb_net_eth_type_trans(priv->ule_skb, dev);
- /* If D-bit is set (i.e. destination MAC address not present),
- * receive the packet anyhow. */
- /* if (priv->ule_dbit && skb->pkt_type == PACKET_OTHERHOST)
- priv->ule_skb->pkt_type = PACKET_HOST; */
- priv->stats.rx_packets++;
- priv->stats.rx_bytes += priv->ule_skb->len;
- netif_rx(priv->ule_skb);
- }
- sndu_done:
- /* Prepare for next SNDU. */
- reset_ule(priv);
- }
-
- /* More data in current TS (look at the bytes following the CRC32)? */
- if (ts_remain >= 2 && *((unsigned short *)from_where) != 0xFFFF) {
- /* Next ULE SNDU starts right there. */
- new_ts = 0;
- priv->ule_skb = NULL;
- priv->ule_sndu_type_1 = 0;
- priv->ule_sndu_len = 0;
- // printk(KERN_WARNING "More data in current TS: [%#x %#x %#x %#x]\n",
- // *(from_where + 0), *(from_where + 1),
- // *(from_where + 2), *(from_where + 3));
- // printk(KERN_WARNING "ts @ %p, stopped @ %p:\n", ts, from_where + 0);
- // hexdump(ts, 188);
- } else {
- new_ts = 1;
- ts += TS_SZ;
- priv->ts_count++;
- if (priv->ule_skb == NULL) {
- priv->need_pusi = 1;
- priv->ule_sndu_type_1 = 0;
- priv->ule_sndu_len = 0;
- }
- }
- } /* for all available TS cells */
-}
-
-static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_ts_feed *feed, enum dmx_success success)
-{
- struct net_device *dev = feed->priv;
-
- if (buffer2 != 0)
- printk(KERN_WARNING "buffer2 not 0: %p.\n", buffer2);
- if (buffer1_len > 32768)
- printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len);
- /* printk("TS callback: %u bytes, %u TS cells @ %p.\n",
- buffer1_len, buffer1_len / TS_SZ, buffer1); */
- dvb_net_ule(dev, buffer1, buffer1_len);
- return 0;
-}
-
-
-static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
-{
- u8 *eth;
- struct sk_buff *skb;
- struct net_device_stats *stats = &(((struct dvb_net_priv *) dev->priv)->stats);
- int snap = 0;
-
- /* note: pkt_len includes a 32bit checksum */
- if (pkt_len < 16) {
- printk("%s: IP/MPE packet length = %d too small.\n",
- dev->name, pkt_len);
- stats->rx_errors++;
- stats->rx_length_errors++;
- return;
- }
-/* it seems some ISPs manage to screw up here, so we have to
- * relax the error checks... */
-#if 0
- if ((pkt[5] & 0xfd) != 0xc1) {
- /* drop scrambled or broken packets */
-#else
- if ((pkt[5] & 0x3c) != 0x00) {
- /* drop scrambled */
-#endif
- stats->rx_errors++;
- stats->rx_crc_errors++;
- return;
- }
- if (pkt[5] & 0x02) {
- /* handle LLC/SNAP, see rfc-1042 */
- if (pkt_len < 24 || memcmp(&pkt[12], "\xaa\xaa\x03\0\0\0", 6)) {
- stats->rx_dropped++;
- return;
- }
- snap = 8;
- }
- if (pkt[7]) {
- /* FIXME: assemble datagram from multiple sections */
- stats->rx_errors++;
- stats->rx_frame_errors++;
- return;
- }
-
- /* we have 14 byte ethernet header (ip header follows);
- * 12 byte MPE header; 4 byte checksum; + 2 byte alignment, 8 byte LLC/SNAP
- */
- if (!(skb = dev_alloc_skb(pkt_len - 4 - 12 + 14 + 2 - snap))) {
- //printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
- stats->rx_dropped++;
- return;
- }
- skb_reserve(skb, 2); /* longword align L3 header */
- skb->dev = dev;
-
- /* copy L3 payload */
- eth = (u8 *) skb_put(skb, pkt_len - 12 - 4 + 14 - snap);
- memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap);
-
- /* create ethernet header: */
- eth[0]=pkt[0x0b];
- eth[1]=pkt[0x0a];
- eth[2]=pkt[0x09];
- eth[3]=pkt[0x08];
- eth[4]=pkt[0x04];
- eth[5]=pkt[0x03];
-
- eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0;
-
- if (snap) {
- eth[12] = pkt[18];
- eth[13] = pkt[19];
- } else {
- /* protocol numbers are from rfc-1700 or
- * http://www.iana.org/assignments/ethernet-numbers
- */
- if (pkt[12] >> 4 == 6) { /* version field from IP header */
- eth[12] = 0x86; /* IPv6 */
- eth[13] = 0xdd;
- } else {
- eth[12] = 0x08; /* IPv4 */
- eth[13] = 0x00;
- }
- }
-
- skb->protocol = dvb_net_eth_type_trans(skb, dev);
-
- stats->rx_packets++;
- stats->rx_bytes+=skb->len;
- netif_rx(skb);
-}
-
-static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len,
- const u8 *buffer2, size_t buffer2_len,
- struct dmx_section_filter *filter,
- enum dmx_success success)
-{
- struct net_device *dev = filter->priv;
-
- /**
- * we rely on the DVB API definition where exactly one complete
- * section is delivered in buffer1
- */
- dvb_net_sec (dev, (u8*) buffer1, buffer1_len);
- return 0;
-}
-
-static int dvb_net_tx(struct sk_buff *skb, struct net_device *dev)
-{
- dev_kfree_skb(skb);
- return 0;
-}
-
-static u8 mask_normal[6]={0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
-static u8 mask_allmulti[6]={0xff, 0xff, 0xff, 0x00, 0x00, 0x00};
-static u8 mac_allmulti[6]={0x01, 0x00, 0x5e, 0x00, 0x00, 0x00};
-static u8 mask_promisc[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-static int dvb_net_filter_sec_set(struct net_device *dev,
- struct dmx_section_filter **secfilter,
- u8 *mac, u8 *mac_mask)
-{
- struct dvb_net_priv *priv = dev->priv;
- int ret;
-
- *secfilter=NULL;
- ret = priv->secfeed->allocate_filter(priv->secfeed, secfilter);
- if (ret<0) {
- printk("%s: could not get filter\n", dev->name);
- return ret;
- }
-
- (*secfilter)->priv=(void *) dev;
-
- memset((*secfilter)->filter_value, 0x00, DMX_MAX_FILTER_SIZE);
- memset((*secfilter)->filter_mask, 0x00, DMX_MAX_FILTER_SIZE);
- memset((*secfilter)->filter_mode, 0xff, DMX_MAX_FILTER_SIZE);
-
- (*secfilter)->filter_value[0]=0x3e;
- (*secfilter)->filter_value[3]=mac[5];
- (*secfilter)->filter_value[4]=mac[4];
- (*secfilter)->filter_value[8]=mac[3];
- (*secfilter)->filter_value[9]=mac[2];
- (*secfilter)->filter_value[10]=mac[1];
- (*secfilter)->filter_value[11]=mac[0];
-
- (*secfilter)->filter_mask[0] = 0xff;
- (*secfilter)->filter_mask[3] = mac_mask[5];
- (*secfilter)->filter_mask[4] = mac_mask[4];
- (*secfilter)->filter_mask[8] = mac_mask[3];
- (*secfilter)->filter_mask[9] = mac_mask[2];
- (*secfilter)->filter_mask[10] = mac_mask[1];
- (*secfilter)->filter_mask[11]=mac_mask[0];
-
- dprintk("%s: filter mac=%02x %02x %02x %02x %02x %02x\n",
- dev->name, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
- dprintk("%s: filter mask=%02x %02x %02x %02x %02x %02x\n",
- dev->name, mac_mask[0], mac_mask[1], mac_mask[2],
- mac_mask[3], mac_mask[4], mac_mask[5]);
-
- return 0;
-}
-
-static int dvb_net_feed_start(struct net_device *dev)
-{
- int ret = 0, i;
- struct dvb_net_priv *priv = dev->priv;
- struct dmx_demux *demux = priv->demux;
- unsigned char *mac = (unsigned char *) dev->dev_addr;
-
- dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
- mutex_lock(&priv->mutex);
- if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
- printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
-
- priv->secfeed=NULL;
- priv->secfilter=NULL;
- priv->tsfeed = NULL;
-
- if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
- dprintk("%s: alloc secfeed\n", __FUNCTION__);
- ret=demux->allocate_section_feed(demux, &priv->secfeed,
- dvb_net_sec_callback);
- if (ret<0) {
- printk("%s: could not allocate section feed\n", dev->name);
- goto error;
- }
-
- ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1);
-
- if (ret<0) {
- printk("%s: could not set section feed\n", dev->name);
- priv->demux->release_section_feed(priv->demux, priv->secfeed);
- priv->secfeed=NULL;
- goto error;
- }
-
- if (priv->rx_mode != RX_MODE_PROMISC) {
- dprintk("%s: set secfilter\n", __FUNCTION__);
- dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_normal);
- }
-
- switch (priv->rx_mode) {
- case RX_MODE_MULTI:
- for (i = 0; i < priv->multi_num; i++) {
- dprintk("%s: set multi_secfilter[%d]\n", __FUNCTION__, i);
- dvb_net_filter_sec_set(dev, &priv->multi_secfilter[i],
- priv->multi_macs[i], mask_normal);
- }
- break;
- case RX_MODE_ALL_MULTI:
- priv->multi_num=1;
- dprintk("%s: set multi_secfilter[0]\n", __FUNCTION__);
- dvb_net_filter_sec_set(dev, &priv->multi_secfilter[0],
- mac_allmulti, mask_allmulti);
- break;
- case RX_MODE_PROMISC:
- priv->multi_num=0;
- dprintk("%s: set secfilter\n", __FUNCTION__);
- dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_promisc);
- break;
- }
-
- dprintk("%s: start filtering\n", __FUNCTION__);
- priv->secfeed->start_filtering(priv->secfeed);
- } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) {
- struct timespec timeout = { 0, 10000000 }; // 10 msec
-
- /* we have payloads encapsulated in TS */
- dprintk("%s: alloc tsfeed\n", __FUNCTION__);
- ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback);
- if (ret < 0) {
- printk("%s: could not allocate ts feed\n", dev->name);
- goto error;
- }
-
- /* Set netdevice pointer for ts decaps callback. */
- priv->tsfeed->priv = (void *)dev;
- ret = priv->tsfeed->set(priv->tsfeed,
- priv->pid, /* pid */
- TS_PACKET, /* type */
- DMX_TS_PES_OTHER, /* pes type */
- 32768, /* circular buffer size */
- timeout /* timeout */
- );
-
- if (ret < 0) {
- printk("%s: could not set ts feed\n", dev->name);
- priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
- priv->tsfeed = NULL;
- goto error;
- }
-
- dprintk("%s: start filtering\n", __FUNCTION__);
- priv->tsfeed->start_filtering(priv->tsfeed);
- } else
- ret = -EINVAL;
-
-error:
- mutex_unlock(&priv->mutex);
- return ret;
-}
-
-static int dvb_net_feed_stop(struct net_device *dev)
-{
- struct dvb_net_priv *priv = dev->priv;
- int i, ret = 0;
-
- dprintk("%s\n", __FUNCTION__);
- mutex_lock(&priv->mutex);
- if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
- if (priv->secfeed) {
- if (priv->secfeed->is_filtering) {
- dprintk("%s: stop secfeed\n", __FUNCTION__);
- priv->secfeed->stop_filtering(priv->secfeed);
- }
-
- if (priv->secfilter) {
- dprintk("%s: release secfilter\n", __FUNCTION__);
- priv->secfeed->release_filter(priv->secfeed,
- priv->secfilter);
- priv->secfilter=NULL;
- }
-
- for (i=0; i<priv->multi_num; i++) {
- if (priv->multi_secfilter[i]) {
- dprintk("%s: release multi_filter[%d]\n",
- __FUNCTION__, i);
- priv->secfeed->release_filter(priv->secfeed,
- priv->multi_secfilter[i]);
- priv->multi_secfilter[i] = NULL;
- }
- }
-
- priv->demux->release_section_feed(priv->demux, priv->secfeed);
- priv->secfeed = NULL;
- } else
- printk("%s: no feed to stop\n", dev->name);
- } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) {
- if (priv->tsfeed) {
- if (priv->tsfeed->is_filtering) {
- dprintk("%s: stop tsfeed\n", __FUNCTION__);
- priv->tsfeed->stop_filtering(priv->tsfeed);
- }
- priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
- priv->tsfeed = NULL;
- }
- else
- printk("%s: no ts feed to stop\n", dev->name);
- } else
- ret = -EINVAL;
- mutex_unlock(&priv->mutex);
- return ret;
-}
-
-
-static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc)
-{
- struct dvb_net_priv *priv = dev->priv;
-
- if (priv->multi_num == DVB_NET_MULTICAST_MAX)
- return -ENOMEM;
-
- memcpy(priv->multi_macs[priv->multi_num], mc->dmi_addr, 6);
-
- priv->multi_num++;
- return 0;
-}
-
-
-static void wq_set_multicast_list (void *data)
-{
- struct net_device *dev = data;
- struct dvb_net_priv *priv = dev->priv;
-
- dvb_net_feed_stop(dev);
- priv->rx_mode = RX_MODE_UNI;
- netif_tx_lock_bh(dev);
-
- if (dev->flags & IFF_PROMISC) {
- dprintk("%s: promiscuous mode\n", dev->name);
- priv->rx_mode = RX_MODE_PROMISC;
- } else if ((dev->flags & IFF_ALLMULTI)) {
- dprintk("%s: allmulti mode\n", dev->name);
- priv->rx_mode = RX_MODE_ALL_MULTI;
- } else if (dev->mc_count) {
- int mci;
- struct dev_mc_list *mc;
-
- dprintk("%s: set_mc_list, %d entries\n",
- dev->name, dev->mc_count);
-
- priv->rx_mode = RX_MODE_MULTI;
- priv->multi_num = 0;
-
- for (mci = 0, mc=dev->mc_list;
- mci < dev->mc_count;
- mc = mc->next, mci++) {
- dvb_set_mc_filter(dev, mc);
- }
- }
-
- netif_tx_unlock_bh(dev);
- dvb_net_feed_start(dev);
-}
-
-
-static void dvb_net_set_multicast_list (struct net_device *dev)
-{
- struct dvb_net_priv *priv = dev->priv;
- schedule_work(&priv->set_multicast_list_wq);
-}
-
-
-static void wq_restart_net_feed (void *data)
-{
- struct net_device *dev = data;
-
- if (netif_running(dev)) {
- dvb_net_feed_stop(dev);
- dvb_net_feed_start(dev);
- }
-}
-
-
-static int dvb_net_set_mac (struct net_device *dev, void *p)
-{
- struct dvb_net_priv *priv = dev->priv;
- struct sockaddr *addr=p;
-
- memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
-
- if (netif_running(dev))
- schedule_work(&priv->restart_net_feed_wq);
-
- return 0;
-}
-
-
-static int dvb_net_open(struct net_device *dev)
-{
- struct dvb_net_priv *priv = dev->priv;
-
- priv->in_use++;
- dvb_net_feed_start(dev);
- return 0;
-}
-
-
-static int dvb_net_stop(struct net_device *dev)
-{
- struct dvb_net_priv *priv = dev->priv;
-
- priv->in_use--;
- return dvb_net_feed_stop(dev);
-}
-
-static struct net_device_stats * dvb_net_get_stats(struct net_device *dev)
-{
- return &((struct dvb_net_priv*) dev->priv)->stats;
-}
-
-static void dvb_net_setup(struct net_device *dev)
-{
- ether_setup(dev);
-
- dev->open = dvb_net_open;
- dev->stop = dvb_net_stop;
- dev->hard_start_xmit = dvb_net_tx;
- dev->get_stats = dvb_net_get_stats;
- dev->set_multicast_list = dvb_net_set_multicast_list;
- dev->set_mac_address = dvb_net_set_mac;
- dev->mtu = 4096;
- dev->mc_count = 0;
- dev->hard_header_cache = NULL;
- dev->flags |= IFF_NOARP;
-}
-
-static int get_if(struct dvb_net *dvbnet)
-{
- int i;
-
- for (i=0; i<DVB_NET_DEVICES_MAX; i++)
- if (!dvbnet->state[i])
- break;
-
- if (i == DVB_NET_DEVICES_MAX)
- return -1;
-
- dvbnet->state[i]=1;
- return i;
-}
-
-static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
-{
- struct net_device *net;
- struct dvb_net_priv *priv;
- int result;
- int if_num;
-
- if (feedtype != DVB_NET_FEEDTYPE_MPE && feedtype != DVB_NET_FEEDTYPE_ULE)
- return -EINVAL;
- if ((if_num = get_if(dvbnet)) < 0)
- return -EINVAL;
-
- net = alloc_netdev(sizeof(struct dvb_net_priv), "dvb", dvb_net_setup);
- if (!net)
- return -ENOMEM;
-
- if (dvbnet->dvbdev->id)
- snprintf(net->name, IFNAMSIZ, "dvb%d%u%d",
- dvbnet->dvbdev->adapter->num, dvbnet->dvbdev->id, if_num);
- else
- /* compatibility fix to keep dvb0_0 format */
- snprintf(net->name, IFNAMSIZ, "dvb%d_%d",
- dvbnet->dvbdev->adapter->num, if_num);
-
- net->addr_len = 6;
- memcpy(net->dev_addr, dvbnet->dvbdev->adapter->proposed_mac, 6);
-
- dvbnet->device[if_num] = net;
-
- priv = net->priv;
- priv->demux = dvbnet->demux;
- priv->pid = pid;
- priv->rx_mode = RX_MODE_UNI;
- priv->need_pusi = 1;
- priv->tscc = 0;
- priv->feedtype = feedtype;
- reset_ule(priv);
-
- INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
- INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
- mutex_init(&priv->mutex);
-
- net->base_addr = pid;
-
- if ((result = register_netdev(net)) < 0) {
- dvbnet->device[if_num] = NULL;
- free_netdev(net);
- return result;
- }
- printk("dvb_net: created network interface %s\n", net->name);
-
- return if_num;
-}
-
-static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned long num)
-{
- struct net_device *net = dvbnet->device[num];
- struct dvb_net_priv *priv;
-
- if (!dvbnet->state[num])
- return -EINVAL;
- priv = net->priv;
- if (priv->in_use)
- return -EBUSY;
-
- dvb_net_stop(net);
- flush_scheduled_work();
- printk("dvb_net: removed network interface %s\n", net->name);
- unregister_netdev(net);
- dvbnet->state[num]=0;
- dvbnet->device[num] = NULL;
- free_netdev(net);
-
- return 0;
-}
-
-static int dvb_net_do_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = file->private_data;
- struct dvb_net *dvbnet = dvbdev->priv;
-
- if (((file->f_flags&O_ACCMODE)==O_RDONLY))
- return -EPERM;
-
- switch (cmd) {
- case NET_ADD_IF:
- {
- struct dvb_net_if *dvbnetif = parg;
- int result;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (!try_module_get(dvbdev->adapter->module))
- return -EPERM;
-
- result=dvb_net_add_if(dvbnet, dvbnetif->pid, dvbnetif->feedtype);
- if (result<0) {
- module_put(dvbdev->adapter->module);
- return result;
- }
- dvbnetif->if_num=result;
- break;
- }
- case NET_GET_IF:
- {
- struct net_device *netdev;
- struct dvb_net_priv *priv_data;
- struct dvb_net_if *dvbnetif = parg;
-
- if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
- !dvbnet->state[dvbnetif->if_num])
- return -EINVAL;
-
- netdev = dvbnet->device[dvbnetif->if_num];
-
- priv_data = netdev->priv;
- dvbnetif->pid=priv_data->pid;
- dvbnetif->feedtype=priv_data->feedtype;
- break;
- }
- case NET_REMOVE_IF:
- {
- int ret;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
- if ((unsigned long) parg >= DVB_NET_DEVICES_MAX)
- return -EINVAL;
- ret = dvb_net_remove_if(dvbnet, (unsigned long) parg);
- if (!ret)
- module_put(dvbdev->adapter->module);
- return ret;
- }
-
- /* binary compatiblity cruft */
- case __NET_ADD_IF_OLD:
- {
- struct __dvb_net_if_old *dvbnetif = parg;
- int result;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- if (!try_module_get(dvbdev->adapter->module))
- return -EPERM;
-
- result=dvb_net_add_if(dvbnet, dvbnetif->pid, DVB_NET_FEEDTYPE_MPE);
- if (result<0) {
- module_put(dvbdev->adapter->module);
- return result;
- }
- dvbnetif->if_num=result;
- break;
- }
- case __NET_GET_IF_OLD:
- {
- struct net_device *netdev;
- struct dvb_net_priv *priv_data;
- struct __dvb_net_if_old *dvbnetif = parg;
-
- if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
- !dvbnet->state[dvbnetif->if_num])
- return -EINVAL;
-
- netdev = dvbnet->device[dvbnetif->if_num];
-
- priv_data = netdev->priv;
- dvbnetif->pid=priv_data->pid;
- break;
- }
- default:
- return -ENOTTY;
- }
- return 0;
-}
-
-static int dvb_net_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- return dvb_usercopy(inode, file, cmd, arg, dvb_net_do_ioctl);
-}
-
-static struct file_operations dvb_net_fops = {
- .owner = THIS_MODULE,
- .ioctl = dvb_net_ioctl,
- .open = dvb_generic_open,
- .release = dvb_generic_release,
-};
-
-static struct dvb_device dvbdev_net = {
- .priv = NULL,
- .users = 1,
- .writers = 1,
- .fops = &dvb_net_fops,
-};
-
-
-void dvb_net_release (struct dvb_net *dvbnet)
-{
- int i;
-
- dvb_unregister_device(dvbnet->dvbdev);
-
- for (i=0; i<DVB_NET_DEVICES_MAX; i++) {
- if (!dvbnet->state[i])
- continue;
- dvb_net_remove_if(dvbnet, i);
- }
-}
-EXPORT_SYMBOL(dvb_net_release);
-
-
-int dvb_net_init (struct dvb_adapter *adap, struct dvb_net *dvbnet,
- struct dmx_demux *dmx)
-{
- int i;
-
- dvbnet->demux = dmx;
-
- for (i=0; i<DVB_NET_DEVICES_MAX; i++)
- dvbnet->state[i] = 0;
-
- dvb_register_device (adap, &dvbnet->dvbdev, &dvbdev_net,
- dvbnet, DVB_DEVICE_NET);
-
- return 0;
-}
-EXPORT_SYMBOL(dvb_net_init);
diff --git a/drivers/media/dvb/dvb-core/dvb_net.h b/drivers/media/dvb/dvb-core/dvb_net.h
deleted file mode 100644
index f14e4ca3857..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_net.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * dvb_net.h
- *
- * Copyright (C) 2001 Ralph Metzler for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _DVB_NET_H_
-#define _DVB_NET_H_
-
-#include <linux/module.h>
-#include <linux/netdevice.h>
-#include <linux/inetdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-
-#include "dvbdev.h"
-
-#define DVB_NET_DEVICES_MAX 10
-
-struct dvb_net {
- struct dvb_device *dvbdev;
- struct net_device *device[DVB_NET_DEVICES_MAX];
- int state[DVB_NET_DEVICES_MAX];
- struct dmx_demux *demux;
-};
-
-
-void dvb_net_release(struct dvb_net *);
-int dvb_net_init(struct dvb_adapter *, struct dvb_net *, struct dmx_demux *);
-
-#endif
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
deleted file mode 100644
index c972fe014c5..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- *
- * dvb_ringbuffer.c: ring buffer implementation for the dvb driver
- *
- * Copyright (C) 2003 Oliver Endriss
- * Copyright (C) 2004 Andrew de Quincey
- *
- * based on code originally found in av7110.c & dvb_ci.c:
- * Copyright (C) 1999-2003 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-
-
-#define __KERNEL_SYSCALLS__
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/string.h>
-#include <asm/uaccess.h>
-
-#include "dvb_ringbuffer.h"
-
-#define PKT_READY 0
-#define PKT_DISPOSED 1
-
-
-void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len)
-{
- rbuf->pread=rbuf->pwrite=0;
- rbuf->data=data;
- rbuf->size=len;
- rbuf->error=0;
-
- init_waitqueue_head(&rbuf->queue);
-
- spin_lock_init(&(rbuf->lock));
-}
-
-
-
-int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf)
-{
- return (rbuf->pread==rbuf->pwrite);
-}
-
-
-
-ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf)
-{
- ssize_t free;
-
- free = rbuf->pread - rbuf->pwrite;
- if (free <= 0)
- free += rbuf->size;
- return free-1;
-}
-
-
-
-ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf)
-{
- ssize_t avail;
-
- avail = rbuf->pwrite - rbuf->pread;
- if (avail < 0)
- avail += rbuf->size;
- return avail;
-}
-
-
-
-void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
-{
- rbuf->pread = rbuf->pwrite;
- rbuf->error = 0;
-}
-
-
-
-void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&rbuf->lock, flags);
- dvb_ringbuffer_flush(rbuf);
- spin_unlock_irqrestore(&rbuf->lock, flags);
-
- wake_up(&rbuf->queue);
-}
-
-
-
-ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, size_t len, int usermem)
-{
- size_t todo = len;
- size_t split;
-
- split = (rbuf->pread + len > rbuf->size) ? rbuf->size - rbuf->pread : 0;
- if (split > 0) {
- if (!usermem)
- memcpy(buf, rbuf->data+rbuf->pread, split);
- else
- if (copy_to_user(buf, rbuf->data+rbuf->pread, split))
- return -EFAULT;
- buf += split;
- todo -= split;
- rbuf->pread = 0;
- }
- if (!usermem)
- memcpy(buf, rbuf->data+rbuf->pread, todo);
- else
- if (copy_to_user(buf, rbuf->data+rbuf->pread, todo))
- return -EFAULT;
-
- rbuf->pread = (rbuf->pread + todo) % rbuf->size;
-
- return len;
-}
-
-
-
-ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, size_t len)
-{
- size_t todo = len;
- size_t split;
-
- split = (rbuf->pwrite + len > rbuf->size) ? rbuf->size - rbuf->pwrite : 0;
-
- if (split > 0) {
- memcpy(rbuf->data+rbuf->pwrite, buf, split);
- buf += split;
- todo -= split;
- rbuf->pwrite = 0;
- }
- memcpy(rbuf->data+rbuf->pwrite, buf, todo);
- rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size;
-
- return len;
-}
-
-ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, size_t len)
-{
- int status;
- ssize_t oldpwrite = rbuf->pwrite;
-
- DVB_RINGBUFFER_WRITE_BYTE(rbuf, len >> 8);
- DVB_RINGBUFFER_WRITE_BYTE(rbuf, len & 0xff);
- DVB_RINGBUFFER_WRITE_BYTE(rbuf, PKT_READY);
- status = dvb_ringbuffer_write(rbuf, buf, len);
-
- if (status < 0) rbuf->pwrite = oldpwrite;
- return status;
-}
-
-ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,
- int offset, u8* buf, size_t len, int usermem)
-{
- size_t todo;
- size_t split;
- size_t pktlen;
-
- pktlen = rbuf->data[idx] << 8;
- pktlen |= rbuf->data[(idx + 1) % rbuf->size];
- if (offset > pktlen) return -EINVAL;
- if ((offset + len) > pktlen) len = pktlen - offset;
-
- idx = (idx + DVB_RINGBUFFER_PKTHDRSIZE + offset) % rbuf->size;
- todo = len;
- split = ((idx + len) > rbuf->size) ? rbuf->size - idx : 0;
- if (split > 0) {
- if (!usermem)
- memcpy(buf, rbuf->data+idx, split);
- else
- if (copy_to_user(buf, rbuf->data+idx, split))
- return -EFAULT;
- buf += split;
- todo -= split;
- idx = 0;
- }
- if (!usermem)
- memcpy(buf, rbuf->data+idx, todo);
- else
- if (copy_to_user(buf, rbuf->data+idx, todo))
- return -EFAULT;
-
- return len;
-}
-
-void dvb_ringbuffer_pkt_dispose(struct dvb_ringbuffer *rbuf, size_t idx)
-{
- size_t pktlen;
-
- rbuf->data[(idx + 2) % rbuf->size] = PKT_DISPOSED;
-
- // clean up disposed packets
- while(dvb_ringbuffer_avail(rbuf) > DVB_RINGBUFFER_PKTHDRSIZE) {
- if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) {
- pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8;
- pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1);
- DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE);
- } else {
- // first packet is not disposed, so we stop cleaning now
- break;
- }
- }
-}
-
-ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t* pktlen)
-{
- int consumed;
- int curpktlen;
- int curpktstatus;
-
- if (idx == -1) {
- idx = rbuf->pread;
- } else {
- curpktlen = rbuf->data[idx] << 8;
- curpktlen |= rbuf->data[(idx + 1) % rbuf->size];
- idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
- }
-
- consumed = (idx - rbuf->pread) % rbuf->size;
-
- while((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) {
-
- curpktlen = rbuf->data[idx] << 8;
- curpktlen |= rbuf->data[(idx + 1) % rbuf->size];
- curpktstatus = rbuf->data[(idx + 2) % rbuf->size];
-
- if (curpktstatus == PKT_READY) {
- *pktlen = curpktlen;
- return idx;
- }
-
- consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE;
- idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
- }
-
- // no packets available
- return -1;
-}
-
-
-
-EXPORT_SYMBOL(dvb_ringbuffer_init);
-EXPORT_SYMBOL(dvb_ringbuffer_empty);
-EXPORT_SYMBOL(dvb_ringbuffer_free);
-EXPORT_SYMBOL(dvb_ringbuffer_avail);
-EXPORT_SYMBOL(dvb_ringbuffer_flush);
-EXPORT_SYMBOL(dvb_ringbuffer_flush_spinlock_wakeup);
-EXPORT_SYMBOL(dvb_ringbuffer_read);
-EXPORT_SYMBOL(dvb_ringbuffer_write);
-EXPORT_SYMBOL(dvb_ringbuffer_pkt_write);
-EXPORT_SYMBOL(dvb_ringbuffer_pkt_read);
-EXPORT_SYMBOL(dvb_ringbuffer_pkt_dispose);
-EXPORT_SYMBOL(dvb_ringbuffer_pkt_next);
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
deleted file mode 100644
index d97714e7573..00000000000
--- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- *
- * dvb_ringbuffer.h: ring buffer implementation for the dvb driver
- *
- * Copyright (C) 2003 Oliver Endriss
- * Copyright (C) 2004 Andrew de Quincey
- *
- * based on code originally found in av7110.c & dvb_ci.c:
- * Copyright (C) 1999-2003 Ralph Metzler & Marcus Metzler
- * for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef _DVB_RINGBUFFER_H_
-#define _DVB_RINGBUFFER_H_
-
-#include <linux/spinlock.h>
-#include <linux/wait.h>
-
-struct dvb_ringbuffer {
- u8 *data;
- ssize_t size;
- ssize_t pread;
- ssize_t pwrite;
- int error;
-
- wait_queue_head_t queue;
- spinlock_t lock;
-};
-
-#define DVB_RINGBUFFER_PKTHDRSIZE 3
-
-
-/*
-** Notes:
-** ------
-** (1) For performance reasons read and write routines don't check buffer sizes
-** and/or number of bytes free/available. This has to be done before these
-** routines are called. For example:
-**
-** *** write <buflen> bytes ***
-** free = dvb_ringbuffer_free(rbuf);
-** if (free >= buflen)
-** count = dvb_ringbuffer_write(rbuf, buffer, buflen);
-** else
-** ...
-**
-** *** read min. 1000, max. <bufsize> bytes ***
-** avail = dvb_ringbuffer_avail(rbuf);
-** if (avail >= 1000)
-** count = dvb_ringbuffer_read(rbuf, buffer, min(avail, bufsize), 0);
-** else
-** ...
-**
-** (2) If there is exactly one reader and one writer, there is no need
-** to lock read or write operations.
-** Two or more readers must be locked against each other.
-** Flushing the buffer counts as a read operation.
-** Two or more writers must be locked against each other.
-*/
-
-/* initialize ring buffer, lock and queue */
-extern void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len);
-
-/* test whether buffer is empty */
-extern int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf);
-
-/* return the number of free bytes in the buffer */
-extern ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf);
-
-/* return the number of bytes waiting in the buffer */
-extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf);
-
-
-/* read routines & macros */
-/* ---------------------- */
-/* flush buffer */
-extern void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf);
-
-/* flush buffer protected by spinlock and wake-up waiting task(s) */
-extern void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf);
-
-/* peek at byte <offs> in the buffer */
-#define DVB_RINGBUFFER_PEEK(rbuf,offs) \
- (rbuf)->data[((rbuf)->pread+(offs))%(rbuf)->size]
-
-/* advance read ptr by <num> bytes */
-#define DVB_RINGBUFFER_SKIP(rbuf,num) \
- (rbuf)->pread=((rbuf)->pread+(num))%(rbuf)->size
-
-/*
-** read <len> bytes from ring buffer into <buf>
-** <usermem> specifies whether <buf> resides in user space
-** returns number of bytes transferred or -EFAULT
-*/
-extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf,
- size_t len, int usermem);
-
-
-/* write routines & macros */
-/* ----------------------- */
-/* write single byte to ring buffer */
-#define DVB_RINGBUFFER_WRITE_BYTE(rbuf,byte) \
- { (rbuf)->data[(rbuf)->pwrite]=(byte); \
- (rbuf)->pwrite=((rbuf)->pwrite+1)%(rbuf)->size; }
-/*
-** write <len> bytes to ring buffer
-** <usermem> specifies whether <buf> resides in user space
-** returns number of bytes transferred or -EFAULT
-*/
-extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf,
- size_t len);
-
-
-/**
- * Write a packet into the ringbuffer.
- *
- * <rbuf> Ringbuffer to write to.
- * <buf> Buffer to write.
- * <len> Length of buffer (currently limited to 65535 bytes max).
- * returns Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL.
- */
-extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf,
- size_t len);
-
-/**
- * Read from a packet in the ringbuffer. Note: unlike dvb_ringbuffer_read(), this
- * does NOT update the read pointer in the ringbuffer. You must use
- * dvb_ringbuffer_pkt_dispose() to mark a packet as no longer required.
- *
- * <rbuf> Ringbuffer concerned.
- * <idx> Packet index as returned by dvb_ringbuffer_pkt_next().
- * <offset> Offset into packet to read from.
- * <buf> Destination buffer for data.
- * <len> Size of destination buffer.
- * <usermem> Set to 1 if <buf> is in userspace.
- * returns Number of bytes read, or -EFAULT.
- */
-extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,
- int offset, u8* buf, size_t len, int usermem);
-
-/**
- * Dispose of a packet in the ring buffer.
- *
- * <rbuf> Ring buffer concerned.
- * <idx> Packet index as returned by dvb_ringbuffer_pkt_next().
- */
-extern void dvb_ringbuffer_pkt_dispose(struct dvb_ringbuffer *rbuf, size_t idx);
-
-/**
- * Get the index of the next packet in a ringbuffer.
- *
- * <rbuf> Ringbuffer concerned.
- * <idx> Previous packet index, or -1 to return the first packet index.
- * <pktlen> On success, will be updated to contain the length of the packet in bytes.
- * returns Packet index (if >=0), or -1 if no packets available.
- */
-extern ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t* pktlen);
-
-
-#endif /* _DVB_RINGBUFFER_H_ */
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
deleted file mode 100644
index 40774feb895..00000000000
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * dvbdev.c
- *
- * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
- * & Marcus Metzler <marcus@convergence.de>
- * for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#include <linux/types.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/cdev.h>
-#include <linux/mutex.h>
-#include "dvbdev.h"
-
-static int dvbdev_debug;
-
-module_param(dvbdev_debug, int, 0644);
-MODULE_PARM_DESC(dvbdev_debug, "Turn on/off device debugging (default:off).");
-
-#define dprintk if (dvbdev_debug) printk
-
-static LIST_HEAD(dvb_adapter_list);
-static DEFINE_MUTEX(dvbdev_register_lock);
-
-static const char * const dnames[] = {
- "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
- "net", "osd"
-};
-
-#define DVB_MAX_ADAPTERS 8
-#define DVB_MAX_IDS 4
-#define nums2minor(num,type,id) ((num << 6) | (id << 4) | type)
-#define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64)
-
-static struct class *dvb_class;
-
-static struct dvb_device* dvbdev_find_device (int minor)
-{
- struct list_head *entry;
-
- list_for_each (entry, &dvb_adapter_list) {
- struct list_head *entry0;
- struct dvb_adapter *adap;
- adap = list_entry (entry, struct dvb_adapter, list_head);
- list_for_each (entry0, &adap->device_list) {
- struct dvb_device *dev;
- dev = list_entry (entry0, struct dvb_device, list_head);
- if (nums2minor(adap->num, dev->type, dev->id) == minor)
- return dev;
- }
- }
-
- return NULL;
-}
-
-
-static int dvb_device_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev;
-
- dvbdev = dvbdev_find_device (iminor(inode));
-
- if (dvbdev && dvbdev->fops) {
- int err = 0;
- const struct file_operations *old_fops;
-
- file->private_data = dvbdev;
- old_fops = file->f_op;
- file->f_op = fops_get(dvbdev->fops);
- if(file->f_op->open)
- err = file->f_op->open(inode,file);
- if (err) {
- fops_put(file->f_op);
- file->f_op = fops_get(old_fops);
- }
- fops_put(old_fops);
- return err;
- }
- return -ENODEV;
-}
-
-
-static struct file_operations dvb_device_fops =
-{
- .owner = THIS_MODULE,
- .open = dvb_device_open,
-};
-
-static struct cdev dvb_device_cdev = {
- .kobj = {.name = "dvb", },
- .owner = THIS_MODULE,
-};
-
-int dvb_generic_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
-
- if (!dvbdev)
- return -ENODEV;
-
- if (!dvbdev->users)
- return -EBUSY;
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
- if (!dvbdev->readers)
- return -EBUSY;
- dvbdev->readers--;
- } else {
- if (!dvbdev->writers)
- return -EBUSY;
- dvbdev->writers--;
- }
-
- dvbdev->users--;
- return 0;
-}
-EXPORT_SYMBOL(dvb_generic_open);
-
-
-int dvb_generic_release(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = file->private_data;
-
- if (!dvbdev)
- return -ENODEV;
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
- dvbdev->readers++;
- } else {
- dvbdev->writers++;
- }
-
- dvbdev->users++;
- return 0;
-}
-EXPORT_SYMBOL(dvb_generic_release);
-
-
-int dvb_generic_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
-{
- struct dvb_device *dvbdev = file->private_data;
-
- if (!dvbdev)
- return -ENODEV;
-
- if (!dvbdev->kernel_ioctl)
- return -EINVAL;
-
- return dvb_usercopy (inode, file, cmd, arg, dvbdev->kernel_ioctl);
-}
-EXPORT_SYMBOL(dvb_generic_ioctl);
-
-
-static int dvbdev_get_free_id (struct dvb_adapter *adap, int type)
-{
- u32 id = 0;
-
- while (id < DVB_MAX_IDS) {
- struct list_head *entry;
- list_for_each (entry, &adap->device_list) {
- struct dvb_device *dev;
- dev = list_entry (entry, struct dvb_device, list_head);
- if (dev->type == type && dev->id == id)
- goto skip;
- }
- return id;
-skip:
- id++;
- }
- return -ENFILE;
-}
-
-
-int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
- const struct dvb_device *template, void *priv, int type)
-{
- struct dvb_device *dvbdev;
- int id;
-
- if (mutex_lock_interruptible(&dvbdev_register_lock))
- return -ERESTARTSYS;
-
- if ((id = dvbdev_get_free_id (adap, type)) < 0) {
- mutex_unlock(&dvbdev_register_lock);
- *pdvbdev = NULL;
- printk ("%s: could get find free device id...\n", __FUNCTION__);
- return -ENFILE;
- }
-
- *pdvbdev = dvbdev = kmalloc(sizeof(struct dvb_device), GFP_KERNEL);
-
- if (!dvbdev) {
- mutex_unlock(&dvbdev_register_lock);
- return -ENOMEM;
- }
-
- memcpy(dvbdev, template, sizeof(struct dvb_device));
- dvbdev->type = type;
- dvbdev->id = id;
- dvbdev->adapter = adap;
- dvbdev->priv = priv;
-
- dvbdev->fops->owner = adap->module;
-
- list_add_tail (&dvbdev->list_head, &adap->device_list);
-
- mutex_unlock(&dvbdev_register_lock);
-
- class_device_create(dvb_class, NULL, MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
- adap->device, "dvb%d.%s%d", adap->num, dnames[type], id);
-
- dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n",
- adap->num, dnames[type], id, nums2minor(adap->num, type, id),
- nums2minor(adap->num, type, id));
-
- return 0;
-}
-EXPORT_SYMBOL(dvb_register_device);
-
-
-void dvb_unregister_device(struct dvb_device *dvbdev)
-{
- if (!dvbdev)
- return;
-
- class_device_destroy(dvb_class, MKDEV(DVB_MAJOR, nums2minor(dvbdev->adapter->num,
- dvbdev->type, dvbdev->id)));
-
- list_del (&dvbdev->list_head);
- kfree (dvbdev);
-}
-EXPORT_SYMBOL(dvb_unregister_device);
-
-
-static int dvbdev_get_free_adapter_num (void)
-{
- int num = 0;
-
- while (num < DVB_MAX_ADAPTERS) {
- struct list_head *entry;
- list_for_each (entry, &dvb_adapter_list) {
- struct dvb_adapter *adap;
- adap = list_entry (entry, struct dvb_adapter, list_head);
- if (adap->num == num)
- goto skip;
- }
- return num;
-skip:
- num++;
- }
-
- return -ENFILE;
-}
-
-
-int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct module *module, struct device *device)
-{
- int num;
-
- if (mutex_lock_interruptible(&dvbdev_register_lock))
- return -ERESTARTSYS;
-
- if ((num = dvbdev_get_free_adapter_num ()) < 0) {
- mutex_unlock(&dvbdev_register_lock);
- return -ENFILE;
- }
-
- memset (adap, 0, sizeof(struct dvb_adapter));
- INIT_LIST_HEAD (&adap->device_list);
-
- printk ("DVB: registering new adapter (%s).\n", name);
-
- adap->num = num;
- adap->name = name;
- adap->module = module;
- adap->device = device;
-
- list_add_tail (&adap->list_head, &dvb_adapter_list);
-
- mutex_unlock(&dvbdev_register_lock);
-
- return num;
-}
-EXPORT_SYMBOL(dvb_register_adapter);
-
-
-int dvb_unregister_adapter(struct dvb_adapter *adap)
-{
- if (mutex_lock_interruptible(&dvbdev_register_lock))
- return -ERESTARTSYS;
- list_del (&adap->list_head);
- mutex_unlock(&dvbdev_register_lock);
- return 0;
-}
-EXPORT_SYMBOL(dvb_unregister_adapter);
-
-/* if the miracle happens and "generic_usercopy()" is included into
- the kernel, then this can vanish. please don't make the mistake and
- define this as video_usercopy(). this will introduce a dependecy
- to the v4l "videodev.o" module, which is unnecessary for some
- cards (ie. the budget dvb-cards don't need the v4l module...) */
-int dvb_usercopy(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg,
- int (*func)(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg))
-{
- char sbuf[128];
- void *mbuf = NULL;
- void *parg = NULL;
- int err = -EINVAL;
-
- /* Copy arguments into temp kernel buffer */
- switch (_IOC_DIR(cmd)) {
- case _IOC_NONE:
- /*
- * For this command, the pointer is actually an integer
- * argument.
- */
- parg = (void *) arg;
- break;
- case _IOC_READ: /* some v4l ioctls are marked wrong ... */
- case _IOC_WRITE:
- case (_IOC_WRITE | _IOC_READ):
- if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
- parg = sbuf;
- } else {
- /* too big to allocate from stack */
- mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
- if (NULL == mbuf)
- return -ENOMEM;
- parg = mbuf;
- }
-
- err = -EFAULT;
- if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
- goto out;
- break;
- }
-
- /* call driver */
- if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
- err = -EINVAL;
-
- if (err < 0)
- goto out;
-
- /* Copy results into user buffer */
- switch (_IOC_DIR(cmd))
- {
- case _IOC_READ:
- case (_IOC_WRITE | _IOC_READ):
- if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
- err = -EFAULT;
- break;
- }
-
-out:
- kfree(mbuf);
- return err;
-}
-
-static int __init init_dvbdev(void)
-{
- int retval;
- dev_t dev = MKDEV(DVB_MAJOR, 0);
-
- if ((retval = register_chrdev_region(dev, MAX_DVB_MINORS, "DVB")) != 0) {
- printk("dvb-core: unable to get major %d\n", DVB_MAJOR);
- return retval;
- }
-
- cdev_init(&dvb_device_cdev, &dvb_device_fops);
- if ((retval = cdev_add(&dvb_device_cdev, dev, MAX_DVB_MINORS)) != 0) {
- printk("dvb-core: unable to get major %d\n", DVB_MAJOR);
- goto error;
- }
-
- dvb_class = class_create(THIS_MODULE, "dvb");
- if (IS_ERR(dvb_class)) {
- retval = PTR_ERR(dvb_class);
- goto error;
- }
- return 0;
-
-error:
- cdev_del(&dvb_device_cdev);
- unregister_chrdev_region(dev, MAX_DVB_MINORS);
- return retval;
-}
-
-
-static void __exit exit_dvbdev(void)
-{
- class_destroy(dvb_class);
- cdev_del(&dvb_device_cdev);
- unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS);
-}
-
-module_init(init_dvbdev);
-module_exit(exit_dvbdev);
-
-MODULE_DESCRIPTION("DVB Core Driver");
-MODULE_AUTHOR("Marcus Metzler, Ralph Metzler, Holger Waechtler");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
deleted file mode 100644
index 7a7f75fd168..00000000000
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * dvbdev.h
- *
- * Copyright (C) 2000 Ralph Metzler & Marcus Metzler
- * for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Lesser Public License
- * as published by the Free Software Foundation; either version 2.1
- * 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 Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _DVBDEV_H_
-#define _DVBDEV_H_
-
-#include <linux/types.h>
-#include <linux/poll.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/smp_lock.h>
-
-#define DVB_MAJOR 212
-
-#define DVB_DEVICE_VIDEO 0
-#define DVB_DEVICE_AUDIO 1
-#define DVB_DEVICE_SEC 2
-#define DVB_DEVICE_FRONTEND 3
-#define DVB_DEVICE_DEMUX 4
-#define DVB_DEVICE_DVR 5
-#define DVB_DEVICE_CA 6
-#define DVB_DEVICE_NET 7
-#define DVB_DEVICE_OSD 8
-
-
-struct dvb_adapter {
- int num;
- struct list_head list_head;
- struct list_head device_list;
- const char *name;
- u8 proposed_mac [6];
- void* priv;
-
- struct device *device;
-
- struct module *module;
-};
-
-
-struct dvb_device {
- struct list_head list_head;
- struct file_operations *fops;
- struct dvb_adapter *adapter;
- int type;
- u32 id;
-
- /* in theory, 'users' can vanish now,
- but I don't want to change too much now... */
- int readers;
- int writers;
- int users;
-
- /* don't really need those !? -- FIXME: use video_usercopy */
- int (*kernel_ioctl)(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg);
-
- void *priv;
-};
-
-
-extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module, struct device *device);
-extern int dvb_unregister_adapter (struct dvb_adapter *adap);
-
-extern int dvb_register_device (struct dvb_adapter *adap,
- struct dvb_device **pdvbdev,
- const struct dvb_device *template,
- void *priv,
- int type);
-
-extern void dvb_unregister_device (struct dvb_device *dvbdev);
-
-extern int dvb_generic_open (struct inode *inode, struct file *file);
-extern int dvb_generic_release (struct inode *inode, struct file *file);
-extern int dvb_generic_ioctl (struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
-
-/* we don't mess with video_usercopy() any more,
-we simply define out own dvb_usercopy(), which will hopefully become
-generic_usercopy() someday... */
-
-extern int dvb_usercopy(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg,
- int (*func)(struct inode *inode, struct file *file,
- unsigned int cmd, void *arg));
-
-#endif /* #ifndef _DVBDEV_H_ */
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
deleted file mode 100644
index 75824b77198..00000000000
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ /dev/null
@@ -1,159 +0,0 @@
-config DVB_USB
- tristate "Support for various USB DVB devices"
- depends on DVB_CORE && USB && I2C
- select FW_LOADER
- select DVB_PLL
- help
- By enabling this you will be able to choose the various supported
- USB1.1 and USB2.0 DVB devices.
-
- Almost every USB device needs a firmware, please look into
- <file:Documentation/dvb/README.dvb-usb>.
-
- For a complete list of supported USB devices see the LinuxTV DVB Wiki:
- <http://www.linuxtv.org/wiki/index.php/DVB_USB>
-
- Say Y if you own a USB DVB device.
-
-config DVB_USB_DEBUG
- bool "Enable extended debug support for all DVB-USB devices"
- depends on DVB_USB
- help
- Say Y if you want to enable debugging. See modinfo dvb-usb (and the
- appropriate drivers) for debug levels.
-
-config DVB_USB_A800
- tristate "AVerMedia AverTV DVB-T USB 2.0 (A800)"
- depends on DVB_USB
- select DVB_DIB3000MC
- help
- Say Y here to support the AVerMedia AverTV DVB-T USB 2.0 (A800) receiver.
-
-config DVB_USB_DIBUSB_MB
- tristate "DiBcom USB DVB-T devices (based on the DiB3000M-B) (see help for device list)"
- depends on DVB_USB
- select DVB_DIB3000MB
- help
- Support for USB 1.1 and 2.0 DVB-T receivers based on reference designs made by
- DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-B demodulator.
-
- Devices supported by this driver:
- Artec T1 USB1.1 boxes
- Avermedia AverTV DVBT USB1.1
- Compro Videomate DVB-U2000 - DVB-T USB
- DiBcom USB1.1 reference devices (non-public)
- Grandtec DVB-T USB
- Hama DVB-T USB1.1-Box
- KWorld/JetWay/ADSTech V-Stream XPERT DTV - DVB-T USB1.1 and USB2.0
- TwinhanDTV Magic Box (VP7041e)
- TwinhanDTV USB-Ter (VP7041)
- Ultima Electronic/Artec T1 USB TVBOX
-
- The VP7041 seems to be identical to "CTS Portable" (Chinese
- Television System).
-
- Say Y if you own such a device and want to use it. You should build it as
- a module.
-
-config DVB_USB_DIBUSB_MB_FAULTY
- bool "Support faulty USB IDs"
- depends on DVB_USB_DIBUSB_MB
- help
- Support for faulty USB IDs due to an invalid EEPROM on some Artec devices.
-
-config DVB_USB_DIBUSB_MC
- tristate "DiBcom USB DVB-T devices (based on the DiB3000M-C/P) (see help for device list)"
- depends on DVB_USB
- select DVB_DIB3000MC
- help
- Support for 2.0 DVB-T receivers based on reference designs made by
- DiBcom (<http://www.dibcom.fr>) equipped with a DiB3000M-C/P demodulator.
-
- Devices supported by this driver:
- Artec T1 USB2.0 boxes
- DiBcom USB2.0 reference devices (non-public)
-
- Say Y if you own such a device and want to use it. You should build it as
- a module.
-
-config DVB_USB_UMT_010
- tristate "HanfTek UMT-010 DVB-T USB2.0 support"
- depends on DVB_USB
- select DVB_DIB3000MC
- help
- Say Y here to support the HanfTek UMT-010 USB2.0 stick-sized DVB-T receiver.
-
-config DVB_USB_CXUSB
- tristate "Conexant USB2.0 hybrid reference design support"
- depends on DVB_USB
- select DVB_CX22702
- select DVB_LGDT330X
- select DVB_MT352
- select DVB_ZL10353
- help
- Say Y here to support the Conexant USB2.0 hybrid reference design.
- Currently, only DVB and ATSC modes are supported, analog mode
- shall be added in the future. Devices that require this module:
-
- Medion MD95700 hybrid USB2.0 device.
- DViCO FusionHDTV (Bluebird) USB2.0 devices
-
-config DVB_USB_DIGITV
- tristate "Nebula Electronics uDigiTV DVB-T USB2.0 support"
- depends on DVB_USB
- select DVB_NXT6000
- select DVB_MT352
- help
- Say Y here to support the Nebula Electronics uDigitV USB2.0 DVB-T receiver.
-
-config DVB_USB_VP7045
- tristate "TwinhanDTV Alpha/MagicBoxII, DNTV tinyUSB2, Beetle USB2.0 support"
- depends on DVB_USB
- help
- Say Y here to support the
-
- TwinhanDTV Alpha (stick) (VP-7045),
- TwinhanDTV MagicBox II (VP-7046),
- DigitalNow TinyUSB 2 DVB-t,
- DigitalRise USB 2.0 Ter (Beetle) and
- TYPHOON DVB-T USB DRIVE
-
- DVB-T USB2.0 receivers.
-
-config DVB_USB_VP702X
- tristate "TwinhanDTV StarBox and clones DVB-S USB2.0 support"
- depends on DVB_USB
- help
- Say Y here to support the
-
- TwinhanDTV StarBox,
- DigitalRise USB Starbox and
- TYPHOON DVB-S USB 2.0 BOX
-
- DVB-S USB2.0 receivers.
-
-config DVB_USB_GP8PSK
- tristate "GENPIX 8PSK->USB module support"
- depends on DVB_USB
- help
- Say Y here to support the
- GENPIX 8psk module
-
- DVB-S USB2.0 receivers.
-
-config DVB_USB_NOVA_T_USB2
- tristate "Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 support"
- depends on DVB_USB
- select DVB_DIB3000MC
- help
- Say Y here to support the Hauppauge WinTV-NOVA-T usb2 DVB-T USB2.0 receiver.
-
-config DVB_USB_DTT200U
- tristate "WideView WT-200U and WT-220U (pen) DVB-T USB2.0 support (Yakumo/Hama/Typhoon/Yuan)"
- depends on DVB_USB
- help
- Say Y here to support the WideView/Yakumo/Hama/Typhoon/Yuan DVB-T USB2.0 receiver.
-
- The receivers are also known as DTT200U (Yakumo) and UB300 (Yuan).
-
- The WT-220U and its clones are pen-sized.
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
deleted file mode 100644
index 9643f56c7fe..00000000000
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ /dev/null
@@ -1,39 +0,0 @@
-dvb-usb-objs = dvb-usb-firmware.o dvb-usb-init.o dvb-usb-urb.o dvb-usb-i2c.o dvb-usb-dvb.o dvb-usb-remote.o
-obj-$(CONFIG_DVB_USB) += dvb-usb.o
-
-dvb-usb-vp7045-objs = vp7045.o vp7045-fe.o
-obj-$(CONFIG_DVB_USB_VP7045) += dvb-usb-vp7045.o
-
-dvb-usb-vp702x-objs = vp702x.o vp702x-fe.o
-obj-$(CONFIG_DVB_USB_VP702X) += dvb-usb-vp702x.o
-
-dvb-usb-gp8psk-objs = gp8psk.o gp8psk-fe.o
-obj-$(CONFIG_DVB_USB_GP8PSK) += dvb-usb-gp8psk.o
-
-dvb-usb-dtt200u-objs = dtt200u.o dtt200u-fe.o
-obj-$(CONFIG_DVB_USB_DTT200U) += dvb-usb-dtt200u.o
-
-dvb-usb-dibusb-common-objs = dibusb-common.o
-
-dvb-usb-a800-objs = a800.o
-obj-$(CONFIG_DVB_USB_A800) += dvb-usb-dibusb-common.o dvb-usb-a800.o
-
-dvb-usb-dibusb-mb-objs = dibusb-mb.o
-obj-$(CONFIG_DVB_USB_DIBUSB_MB) += dvb-usb-dibusb-common.o dvb-usb-dibusb-mb.o
-
-dvb-usb-dibusb-mc-objs = dibusb-mc.o
-obj-$(CONFIG_DVB_USB_DIBUSB_MC) += dvb-usb-dibusb-common.o dvb-usb-dibusb-mc.o
-
-dvb-usb-nova-t-usb2-objs = nova-t-usb2.o
-obj-$(CONFIG_DVB_USB_NOVA_T_USB2) += dvb-usb-dibusb-common.o dvb-usb-nova-t-usb2.o
-
-dvb-usb-umt-010-objs = umt-010.o
-obj-$(CONFIG_DVB_USB_UMT_010) += dvb-usb-dibusb-common.o dvb-usb-umt-010.o
-
-dvb-usb-digitv-objs = digitv.o
-obj-$(CONFIG_DVB_USB_DIGITV) += dvb-usb-digitv.o
-
-dvb-usb-cxusb-objs = cxusb.o
-obj-$(CONFIG_DVB_USB_CXUSB) += dvb-usb-cxusb.o
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
deleted file mode 100644
index ce44aa6bbb8..00000000000
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* DVB USB framework compliant Linux driver for the AVerMedia AverTV DVB-T
- * USB2.0 (A800) DVB-T receiver.
- *
- * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * Thanks to
- * - AVerMedia who kindly provided information and
- * - Glen Harris who suffered from my mistakes during development.
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dibusb.h"
-
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS);
-#define deb_rc(args...) dprintk(debug,0x01,args)
-
-static int a800_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- /* do nothing for the AVerMedia */
- return 0;
-}
-
-static struct dvb_usb_rc_key a800_rc_keys[] = {
- { 0x02, 0x01, KEY_PROG1 }, /* SOURCE */
- { 0x02, 0x00, KEY_POWER }, /* POWER */
- { 0x02, 0x05, KEY_1 }, /* 1 */
- { 0x02, 0x06, KEY_2 }, /* 2 */
- { 0x02, 0x07, KEY_3 }, /* 3 */
- { 0x02, 0x09, KEY_4 }, /* 4 */
- { 0x02, 0x0a, KEY_5 }, /* 5 */
- { 0x02, 0x0b, KEY_6 }, /* 6 */
- { 0x02, 0x0d, KEY_7 }, /* 7 */
- { 0x02, 0x0e, KEY_8 }, /* 8 */
- { 0x02, 0x0f, KEY_9 }, /* 9 */
- { 0x02, 0x12, KEY_LEFT }, /* L / DISPLAY */
- { 0x02, 0x11, KEY_0 }, /* 0 */
- { 0x02, 0x13, KEY_RIGHT }, /* R / CH RTN */
- { 0x02, 0x17, KEY_PROG2 }, /* SNAP SHOT */
- { 0x02, 0x10, KEY_PROG3 }, /* 16-CH PREV */
- { 0x02, 0x1e, KEY_VOLUMEDOWN }, /* VOL DOWN */
- { 0x02, 0x0c, KEY_ZOOM }, /* FULL SCREEN */
- { 0x02, 0x1f, KEY_VOLUMEUP }, /* VOL UP */
- { 0x02, 0x14, KEY_MUTE }, /* MUTE */
- { 0x02, 0x08, KEY_AUDIO }, /* AUDIO */
- { 0x02, 0x19, KEY_RECORD }, /* RECORD */
- { 0x02, 0x18, KEY_PLAY }, /* PLAY */
- { 0x02, 0x1b, KEY_STOP }, /* STOP */
- { 0x02, 0x1a, KEY_PLAYPAUSE }, /* TIMESHIFT / PAUSE */
- { 0x02, 0x1d, KEY_BACK }, /* << / RED */
- { 0x02, 0x1c, KEY_FORWARD }, /* >> / YELLOW */
- { 0x02, 0x03, KEY_TEXT }, /* TELETEXT */
- { 0x02, 0x04, KEY_EPG }, /* EPG */
- { 0x02, 0x15, KEY_MENU }, /* MENU */
-
- { 0x03, 0x03, KEY_CHANNELUP }, /* CH UP */
- { 0x03, 0x02, KEY_CHANNELDOWN }, /* CH DOWN */
- { 0x03, 0x01, KEY_FIRST }, /* |<< / GREEN */
- { 0x03, 0x00, KEY_LAST }, /* >>| / BLUE */
-
-};
-
-static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- u8 key[5];
- if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
- 0x04, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, key, 5,
- 2000) != 5)
- return -ENODEV;
-
- /* call the universal NEC remote processor, to find out the key's state and event */
- dvb_usb_nec_rc_key_to_event(d,key,event,state);
- if (key[0] != 0)
- deb_rc("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
- return 0;
-}
-
-/* USB Driver stuff */
-static struct dvb_usb_properties a800_properties;
-
-static int a800_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE,NULL);
-}
-
-/* do not change the order of the ID table */
-static struct usb_device_id a800_table [] = {
-/* 00 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_COLD) },
-/* 01 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_DVBT_USB2_WARM) },
- { } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE (usb, a800_table);
-
-static struct dvb_usb_properties a800_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
- .pid_filter_count = 32,
-
- .usb_ctrl = CYPRESS_FX2,
-
- .firmware = "dvb-usb-avertv-a800-02.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb2_0_streaming_ctrl,
- .pid_filter = dibusb_pid_filter,
- .pid_filter_ctrl = dibusb_pid_filter_ctrl,
- .power_ctrl = a800_power_ctrl,
- .frontend_attach = dibusb_dib3000mc_frontend_attach,
- .tuner_attach = dibusb_dib3000mc_tuner_attach,
-
- .rc_interval = DEFAULT_RC_INTERVAL,
- .rc_key_map = a800_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(a800_rc_keys),
- .rc_query = a800_rc_query,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x06,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "AVerMedia AverTV DVB-T USB 2.0 (A800)",
- { &a800_table[0], NULL },
- { &a800_table[1], NULL },
- },
- }
-};
-
-static struct usb_driver a800_driver = {
- .name = "dvb_usb_a800",
- .probe = a800_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = a800_table,
-};
-
-/* module stuff */
-static int __init a800_module_init(void)
-{
- int result;
- if ((result = usb_register(&a800_driver))) {
- err("usb_register failed. Error number %d",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit a800_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&a800_driver);
-}
-
-module_init (a800_module_init);
-module_exit (a800_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("AVerMedia AverTV DVB-T USB 2.0 (A800)");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
deleted file mode 100644
index ae23bdde42a..00000000000
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ /dev/null
@@ -1,771 +0,0 @@
-/* DVB USB compliant linux driver for Conexant USB reference design.
- *
- * The Conexant reference design I saw on their website was only for analogue
- * capturing (using the cx25842). The box I took to write this driver (reverse
- * engineered) is the one labeled Medion MD95700. In addition to the cx25842
- * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
- * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
- *
- * Maybe it is a little bit premature to call this driver cxusb, but I assume
- * the USB protocol is identical or at least inherited from the reference
- * design, so it can be reused for the "analogue-only" device (if it will
- * appear at all).
- *
- * TODO: Use the cx25840-driver for the analogue part
- *
- * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
- * Copyright (C) 2005 Michael Krufky (mkrufky@m1k.net)
- * Copyright (C) 2006 Chris Pascoe (c.pascoe@itee.uq.edu.au)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "cxusb.h"
-
-#include "cx22702.h"
-#include "lgdt330x.h"
-#include "lg_h06xf.h"
-#include "mt352.h"
-#include "mt352_priv.h"
-#include "zl10353.h"
-
-/* debug */
-int dvb_usb_cxusb_debug;
-module_param_named(debug,dvb_usb_cxusb_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
-
-static int cxusb_ctrl_msg(struct dvb_usb_device *d,
- u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
-{
- int wo = (rbuf == NULL || rlen == 0); /* write-only */
- u8 sndbuf[1+wlen];
- memset(sndbuf,0,1+wlen);
-
- sndbuf[0] = cmd;
- memcpy(&sndbuf[1],wbuf,wlen);
- if (wo)
- dvb_usb_generic_write(d,sndbuf,1+wlen);
- else
- dvb_usb_generic_rw(d,sndbuf,1+wlen,rbuf,rlen,0);
-
- return 0;
-}
-
-/* GPIO */
-static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
-{
- struct cxusb_state *st = d->priv;
- u8 o[2],i;
-
- if (st->gpio_write_state[GPIO_TUNER] == onoff)
- return;
-
- o[0] = GPIO_TUNER;
- o[1] = onoff;
- cxusb_ctrl_msg(d,CMD_GPIO_WRITE,o,2,&i,1);
-
- if (i != 0x01)
- deb_info("gpio_write failed.\n");
-
- st->gpio_write_state[GPIO_TUNER] = onoff;
-}
-
-/* I2C */
-static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
-{
- struct dvb_usb_device *d = i2c_get_adapdata(adap);
- int i;
-
- if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
- return -EAGAIN;
-
- if (num > 2)
- warn("more than two i2c messages at a time is not handled yet. TODO.");
-
- for (i = 0; i < num; i++) {
-
- if (d->udev->descriptor.idVendor == USB_VID_MEDION)
- switch (msg[i].addr) {
- case 0x63:
- cxusb_gpio_tuner(d,0);
- break;
- default:
- cxusb_gpio_tuner(d,1);
- break;
- }
-
- /* read request */
- if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
- u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
- obuf[0] = msg[i].len;
- obuf[1] = msg[i+1].len;
- obuf[2] = msg[i].addr;
- memcpy(&obuf[3],msg[i].buf,msg[i].len);
-
- if (cxusb_ctrl_msg(d, CMD_I2C_READ,
- obuf, 3+msg[i].len,
- ibuf, 1+msg[i+1].len) < 0)
- break;
-
- if (ibuf[0] != 0x08)
- deb_i2c("i2c read may have failed\n");
-
- memcpy(msg[i+1].buf,&ibuf[1],msg[i+1].len);
-
- i++;
- } else { /* write */
- u8 obuf[2+msg[i].len], ibuf;
- obuf[0] = msg[i].addr;
- obuf[1] = msg[i].len;
- memcpy(&obuf[2],msg[i].buf,msg[i].len);
-
- if (cxusb_ctrl_msg(d,CMD_I2C_WRITE, obuf, 2+msg[i].len, &ibuf,1) < 0)
- break;
- if (ibuf != 0x08)
- deb_i2c("i2c write may have failed\n");
- }
- }
-
- mutex_unlock(&d->i2c_mutex);
- return i;
-}
-
-static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
-{
- return I2C_FUNC_I2C;
-}
-
-static struct i2c_algorithm cxusb_i2c_algo = {
- .master_xfer = cxusb_i2c_xfer,
- .functionality = cxusb_i2c_func,
-};
-
-static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 b = 0;
- if (onoff)
- return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
- else
- return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
-}
-
-static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 b = 0;
- if (onoff)
- return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
- else
- return 0;
-}
-
-static int cxusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 buf[2] = { 0x03, 0x00 };
- if (onoff)
- cxusb_ctrl_msg(d,CMD_STREAMING_ON, buf, 2, NULL, 0);
- else
- cxusb_ctrl_msg(d,CMD_STREAMING_OFF, NULL, 0, NULL, 0);
-
- return 0;
-}
-
-static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
- u8 ircode[4];
- int i;
-
- cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
-
- *event = 0;
- *state = REMOTE_NO_KEY_PRESSED;
-
- for (i = 0; i < d->props.rc_key_map_size; i++) {
- if (keymap[i].custom == ircode[2] &&
- keymap[i].data == ircode[3]) {
- *event = keymap[i].event;
- *state = REMOTE_KEY_PRESSED;
-
- return 0;
- }
- }
-
- return 0;
-}
-
-static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
- { 0xfe, 0x02, KEY_TV },
- { 0xfe, 0x0e, KEY_MP3 },
- { 0xfe, 0x1a, KEY_DVD },
- { 0xfe, 0x1e, KEY_FAVORITES },
- { 0xfe, 0x16, KEY_SETUP },
- { 0xfe, 0x46, KEY_POWER2 },
- { 0xfe, 0x0a, KEY_EPG },
- { 0xfe, 0x49, KEY_BACK },
- { 0xfe, 0x4d, KEY_MENU },
- { 0xfe, 0x51, KEY_UP },
- { 0xfe, 0x5b, KEY_LEFT },
- { 0xfe, 0x5f, KEY_RIGHT },
- { 0xfe, 0x53, KEY_DOWN },
- { 0xfe, 0x5e, KEY_OK },
- { 0xfe, 0x59, KEY_INFO },
- { 0xfe, 0x55, KEY_TAB },
- { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
- { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
- { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
- { 0xfe, 0x15, KEY_VOLUMEUP },
- { 0xfe, 0x05, KEY_VOLUMEDOWN },
- { 0xfe, 0x11, KEY_CHANNELUP },
- { 0xfe, 0x09, KEY_CHANNELDOWN },
- { 0xfe, 0x52, KEY_CAMERA },
- { 0xfe, 0x5a, KEY_TUNER }, /* Live */
- { 0xfe, 0x19, KEY_OPEN },
- { 0xfe, 0x0b, KEY_1 },
- { 0xfe, 0x17, KEY_2 },
- { 0xfe, 0x1b, KEY_3 },
- { 0xfe, 0x07, KEY_4 },
- { 0xfe, 0x50, KEY_5 },
- { 0xfe, 0x54, KEY_6 },
- { 0xfe, 0x48, KEY_7 },
- { 0xfe, 0x4c, KEY_8 },
- { 0xfe, 0x58, KEY_9 },
- { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
- { 0xfe, 0x03, KEY_0 },
- { 0xfe, 0x1f, KEY_ZOOM },
- { 0xfe, 0x43, KEY_REWIND },
- { 0xfe, 0x47, KEY_PLAYPAUSE },
- { 0xfe, 0x4f, KEY_FASTFORWARD },
- { 0xfe, 0x57, KEY_MUTE },
- { 0xfe, 0x0d, KEY_STOP },
- { 0xfe, 0x01, KEY_RECORD },
- { 0xfe, 0x4e, KEY_POWER },
-};
-
-static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
- { 0xfc, 0x02, KEY_SETUP }, /* Profile */
- { 0xfc, 0x43, KEY_POWER2 },
- { 0xfc, 0x06, KEY_EPG },
- { 0xfc, 0x5a, KEY_BACK },
- { 0xfc, 0x05, KEY_MENU },
- { 0xfc, 0x47, KEY_INFO },
- { 0xfc, 0x01, KEY_TAB },
- { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
- { 0xfc, 0x49, KEY_VOLUMEUP },
- { 0xfc, 0x09, KEY_VOLUMEDOWN },
- { 0xfc, 0x54, KEY_CHANNELUP },
- { 0xfc, 0x0b, KEY_CHANNELDOWN },
- { 0xfc, 0x16, KEY_CAMERA },
- { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
- { 0xfc, 0x45, KEY_OPEN },
- { 0xfc, 0x19, KEY_1 },
- { 0xfc, 0x18, KEY_2 },
- { 0xfc, 0x1b, KEY_3 },
- { 0xfc, 0x1a, KEY_4 },
- { 0xfc, 0x58, KEY_5 },
- { 0xfc, 0x59, KEY_6 },
- { 0xfc, 0x15, KEY_7 },
- { 0xfc, 0x14, KEY_8 },
- { 0xfc, 0x17, KEY_9 },
- { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
- { 0xfc, 0x55, KEY_0 },
- { 0xfc, 0x07, KEY_ZOOM },
- { 0xfc, 0x0a, KEY_REWIND },
- { 0xfc, 0x08, KEY_PLAYPAUSE },
- { 0xfc, 0x4b, KEY_FASTFORWARD },
- { 0xfc, 0x5b, KEY_MUTE },
- { 0xfc, 0x04, KEY_STOP },
- { 0xfc, 0x56, KEY_RECORD },
- { 0xfc, 0x57, KEY_POWER },
- { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
- { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
-};
-
-static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
-{
- static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
- static u8 reset [] = { RESET, 0x80 };
- static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
- static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
- static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
- static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
-
- mt352_write(fe, clock_config, sizeof(clock_config));
- udelay(200);
- mt352_write(fe, reset, sizeof(reset));
- mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
-
- mt352_write(fe, agc_cfg, sizeof(agc_cfg));
- mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
- mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
-
- return 0;
-}
-
-static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
-{ /* used in both lgz201 and th7579 */
- static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
- static u8 reset [] = { RESET, 0x80 };
- static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
- static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
- static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
- static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
-
- mt352_write(fe, clock_config, sizeof(clock_config));
- udelay(200);
- mt352_write(fe, reset, sizeof(reset));
- mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
-
- mt352_write(fe, agc_cfg, sizeof(agc_cfg));
- mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
- mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
- return 0;
-}
-
-static int cxusb_lgh064f_tuner_set_params(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *fep)
-{
- struct dvb_usb_device *d = fe->dvb->priv;
- return lg_h06xf_pll_set(fe, &d->i2c_adap, fep);
-}
-
-static struct cx22702_config cxusb_cx22702_config = {
- .demod_address = 0x63,
-
- .output_mode = CX22702_PARALLEL_OUTPUT,
-};
-
-static struct lgdt330x_config cxusb_lgdt3303_config = {
- .demod_address = 0x0e,
- .demod_chip = LGDT3303,
-};
-
-static struct mt352_config cxusb_dee1601_config = {
- .demod_address = 0x0f,
- .demod_init = cxusb_dee1601_demod_init,
-};
-
-static struct zl10353_config cxusb_zl10353_dee1601_config = {
- .demod_address = 0x0f,
-};
-
-static struct mt352_config cxusb_mt352_config = {
- /* used in both lgz201 and th7579 */
- .demod_address = 0x0f,
- .demod_init = cxusb_mt352_demod_init,
-};
-
-/* Callbacks for DVB USB */
-static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d)
-{
- u8 bpll[4] = { 0x0b, 0xdc, 0x9c, 0xa0 };
- d->pll_addr = 0x61;
- memcpy(d->pll_init, bpll, 4);
- d->pll_desc = &dvb_pll_fmd1216me;
-
- d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
- d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
-
- return 0;
-}
-
-static int cxusb_dee1601_tuner_attach(struct dvb_usb_device *d)
-{
- d->pll_addr = 0x61;
- d->pll_desc = &dvb_pll_thomson_dtt7579;
- d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
- return 0;
-}
-
-static int cxusb_lgz201_tuner_attach(struct dvb_usb_device *d)
-{
- d->pll_addr = 0x61;
- d->pll_desc = &dvb_pll_lg_z201;
- d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
- return 0;
-}
-
-static int cxusb_dtt7579_tuner_attach(struct dvb_usb_device *d)
-{
- d->pll_addr = 0x60;
- d->pll_desc = &dvb_pll_thomson_dtt7579;
- d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
- return 0;
-}
-
-static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_device *d)
-{
- d->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params;
- return 0;
-}
-
-static int cxusb_cx22702_frontend_attach(struct dvb_usb_device *d)
-{
- u8 b;
- if (usb_set_interface(d->udev,0,6) < 0)
- err("set interface failed");
-
- cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, &b, 1);
-
- if ((d->fe = cx22702_attach(&cxusb_cx22702_config, &d->i2c_adap)) != NULL)
- return 0;
-
- return -EIO;
-}
-
-static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_device *d)
-{
- if (usb_set_interface(d->udev,0,7) < 0)
- err("set interface failed");
-
- cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
-
- if ((d->fe = lgdt330x_attach(&cxusb_lgdt3303_config, &d->i2c_adap)) != NULL)
- return 0;
-
- return -EIO;
-}
-
-static int cxusb_mt352_frontend_attach(struct dvb_usb_device *d)
-{ /* used in both lgz201 and th7579 */
- if (usb_set_interface(d->udev,0,0) < 0)
- err("set interface failed");
-
- cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
-
- if ((d->fe = mt352_attach(&cxusb_mt352_config, &d->i2c_adap)) != NULL)
- return 0;
-
- return -EIO;
-}
-
-static int cxusb_dee1601_frontend_attach(struct dvb_usb_device *d)
-{
- if (usb_set_interface(d->udev,0,0) < 0)
- err("set interface failed");
-
- cxusb_ctrl_msg(d,CMD_DIGITAL, NULL, 0, NULL, 0);
-
- if (((d->fe = mt352_attach(&cxusb_dee1601_config, &d->i2c_adap)) != NULL) ||
- ((d->fe = zl10353_attach(&cxusb_zl10353_dee1601_config, &d->i2c_adap)) != NULL))
- return 0;
-
- return -EIO;
-}
-
-/*
- * DViCO bluebird firmware needs the "warm" product ID to be patched into the
- * firmware file before download.
- */
-
-#define BLUEBIRD_01_ID_OFFSET 6638
-static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const struct firmware *fw)
-{
- if (fw->size < BLUEBIRD_01_ID_OFFSET + 4)
- return -EINVAL;
-
- if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
- fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
-
- fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1;
- fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8;
-
- return usb_cypress_load_firmware(udev,fw,CYPRESS_FX2);
- }
-
- return -EINVAL;
-}
-
-/* DVB USB Driver stuff */
-static struct dvb_usb_properties cxusb_medion_properties;
-static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties;
-static struct dvb_usb_properties cxusb_bluebird_dee1601_properties;
-static struct dvb_usb_properties cxusb_bluebird_lgz201_properties;
-static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties;
-
-static int cxusb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0) {
- return 0;
- }
-
- return -EINVAL;
-}
-
-static struct usb_device_id cxusb_table [] = {
- { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_COLD) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DEE1601_WARM) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_COLD) },
- { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_WARM) },
- {} /* Terminating entry */
-};
-MODULE_DEVICE_TABLE (usb, cxusb_table);
-
-static struct dvb_usb_properties cxusb_medion_properties = {
- .caps = DVB_USB_IS_AN_I2C_ADAPTER,
-
- .usb_ctrl = CYPRESS_FX2,
-
- .size_of_priv = sizeof(struct cxusb_state),
-
- .streaming_ctrl = cxusb_streaming_ctrl,
- .power_ctrl = cxusb_power_ctrl,
- .frontend_attach = cxusb_cx22702_frontend_attach,
- .tuner_attach = cxusb_fmd1216me_tuner_attach,
-
- .i2c_algo = &cxusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 5,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 8192,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "Medion MD95700 (MDUSBTV-HYBRID)",
- { NULL },
- { &cxusb_table[0], NULL },
- },
- }
-};
-
-static struct dvb_usb_properties cxusb_bluebird_lgh064f_properties = {
- .caps = DVB_USB_IS_AN_I2C_ADAPTER,
-
- .usb_ctrl = DEVICE_SPECIFIC,
- .firmware = "dvb-usb-bluebird-01.fw",
- .download_firmware = bluebird_patch_dvico_firmware_download,
- /* use usb alt setting 0 for EP4 transfer (dvb-t),
- use usb alt setting 7 for EP2 transfer (atsc) */
-
- .size_of_priv = sizeof(struct cxusb_state),
-
- .streaming_ctrl = cxusb_streaming_ctrl,
- .power_ctrl = cxusb_bluebird_power_ctrl,
- .frontend_attach = cxusb_lgdt3303_frontend_attach,
- .tuner_attach = cxusb_lgdt3303_tuner_attach,
-
- .i2c_algo = &cxusb_i2c_algo,
-
- .rc_interval = 100,
- .rc_key_map = dvico_portable_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
- .rc_query = cxusb_rc_query,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 5,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 8192,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "DViCO FusionHDTV5 USB Gold",
- { &cxusb_table[1], NULL },
- { &cxusb_table[2], NULL },
- },
- }
-};
-
-static struct dvb_usb_properties cxusb_bluebird_dee1601_properties = {
- .caps = DVB_USB_IS_AN_I2C_ADAPTER,
-
- .usb_ctrl = DEVICE_SPECIFIC,
- .firmware = "dvb-usb-bluebird-01.fw",
- .download_firmware = bluebird_patch_dvico_firmware_download,
- /* use usb alt setting 0 for EP4 transfer (dvb-t),
- use usb alt setting 7 for EP2 transfer (atsc) */
-
- .size_of_priv = sizeof(struct cxusb_state),
-
- .streaming_ctrl = cxusb_streaming_ctrl,
- .power_ctrl = cxusb_bluebird_power_ctrl,
- .frontend_attach = cxusb_dee1601_frontend_attach,
- .tuner_attach = cxusb_dee1601_tuner_attach,
-
- .i2c_algo = &cxusb_i2c_algo,
-
- .rc_interval = 150,
- .rc_key_map = dvico_mce_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
- .rc_query = cxusb_rc_query,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 5,
- .endpoint = 0x04,
- .u = {
- .bulk = {
- .buffersize = 8192,
- }
- }
- },
-
- .num_device_descs = 2,
- .devices = {
- { "DViCO FusionHDTV DVB-T Dual USB",
- { &cxusb_table[3], NULL },
- { &cxusb_table[4], NULL },
- },
- { "DigitalNow DVB-T Dual USB",
- { &cxusb_table[9], NULL },
- { &cxusb_table[10], NULL },
- },
- }
-};
-
-static struct dvb_usb_properties cxusb_bluebird_lgz201_properties = {
- .caps = DVB_USB_IS_AN_I2C_ADAPTER,
-
- .usb_ctrl = DEVICE_SPECIFIC,
- .firmware = "dvb-usb-bluebird-01.fw",
- .download_firmware = bluebird_patch_dvico_firmware_download,
- /* use usb alt setting 0 for EP4 transfer (dvb-t),
- use usb alt setting 7 for EP2 transfer (atsc) */
-
- .size_of_priv = sizeof(struct cxusb_state),
-
- .streaming_ctrl = cxusb_streaming_ctrl,
- .power_ctrl = cxusb_bluebird_power_ctrl,
- .frontend_attach = cxusb_mt352_frontend_attach,
- .tuner_attach = cxusb_lgz201_tuner_attach,
-
- .i2c_algo = &cxusb_i2c_algo,
-
- .rc_interval = 100,
- .rc_key_map = dvico_portable_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
- .rc_query = cxusb_rc_query,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 5,
- .endpoint = 0x04,
- .u = {
- .bulk = {
- .buffersize = 8192,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "DViCO FusionHDTV DVB-T USB (LGZ201)",
- { &cxusb_table[5], NULL },
- { &cxusb_table[6], NULL },
- },
- }
-};
-
-static struct dvb_usb_properties cxusb_bluebird_dtt7579_properties = {
- .caps = DVB_USB_IS_AN_I2C_ADAPTER,
-
- .usb_ctrl = DEVICE_SPECIFIC,
- .firmware = "dvb-usb-bluebird-01.fw",
- .download_firmware = bluebird_patch_dvico_firmware_download,
- /* use usb alt setting 0 for EP4 transfer (dvb-t),
- use usb alt setting 7 for EP2 transfer (atsc) */
-
- .size_of_priv = sizeof(struct cxusb_state),
-
- .streaming_ctrl = cxusb_streaming_ctrl,
- .power_ctrl = cxusb_bluebird_power_ctrl,
- .frontend_attach = cxusb_mt352_frontend_attach,
- .tuner_attach = cxusb_dtt7579_tuner_attach,
-
- .i2c_algo = &cxusb_i2c_algo,
-
- .rc_interval = 100,
- .rc_key_map = dvico_portable_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
- .rc_query = cxusb_rc_query,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 5,
- .endpoint = 0x04,
- .u = {
- .bulk = {
- .buffersize = 8192,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "DViCO FusionHDTV DVB-T USB (TH7579)",
- { &cxusb_table[7], NULL },
- { &cxusb_table[8], NULL },
- },
- }
-};
-
-static struct usb_driver cxusb_driver = {
- .name = "dvb_usb_cxusb",
- .probe = cxusb_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = cxusb_table,
-};
-
-/* module stuff */
-static int __init cxusb_module_init(void)
-{
- int result;
- if ((result = usb_register(&cxusb_driver))) {
- err("usb_register failed. Error number %d",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit cxusb_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&cxusb_driver);
-}
-
-module_init (cxusb_module_init);
-module_exit (cxusb_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_AUTHOR("Michael Krufky <mkrufky@m1k.net>");
-MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
-MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
-MODULE_VERSION("1.0-alpha");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h
deleted file mode 100644
index c8ef77554b0..00000000000
--- a/drivers/media/dvb/dvb-usb/cxusb.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef _DVB_USB_CXUSB_H_
-#define _DVB_USB_CXUSB_H_
-
-#define DVB_USB_LOG_PREFIX "cxusb"
-#include "dvb-usb.h"
-
-extern int dvb_usb_cxusb_debug;
-#define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
-#define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
- dprintk(dvb_usb_cxusb_debug,0x01,args)
-
-/* usb commands - some of it are guesses, don't have a reference yet */
-#define CMD_I2C_WRITE 0x08
-#define CMD_I2C_READ 0x09
-
-#define CMD_GPIO_READ 0x0d
-#define CMD_GPIO_WRITE 0x0e
-#define GPIO_TUNER 0x02
-
-#define CMD_POWER_OFF 0xdc
-#define CMD_POWER_ON 0xde
-
-#define CMD_STREAMING_ON 0x36
-#define CMD_STREAMING_OFF 0x37
-
-#define CMD_GET_IR_CODE 0x47
-
-#define CMD_ANALOG 0x50
-#define CMD_DIGITAL 0x51
-
-struct cxusb_state {
- u8 gpio_write_state[3];
-};
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
deleted file mode 100644
index abd75b4a350..00000000000
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/* Common methods for dibusb-based-receivers.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dibusb.h"
-
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info (|-able))." DVB_USB_DEBUG_STATUS);
-MODULE_LICENSE("GPL");
-
-#define deb_info(args...) dprintk(debug,0x01,args)
-
-/* common stuff used by the different dibusb modules */
-int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
-{
- if (d->priv != NULL) {
- struct dibusb_state *st = d->priv;
- if (st->ops.fifo_ctrl != NULL)
- if (st->ops.fifo_ctrl(d->fe,onoff)) {
- err("error while controlling the fifo of the demod.");
- return -ENODEV;
- }
- }
- return 0;
-}
-EXPORT_SYMBOL(dibusb_streaming_ctrl);
-
-int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
-{
- if (d->priv != NULL) {
- struct dibusb_state *st = d->priv;
- if (st->ops.pid_ctrl != NULL)
- st->ops.pid_ctrl(d->fe,index,pid,onoff);
- }
- return 0;
-}
-EXPORT_SYMBOL(dibusb_pid_filter);
-
-int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff)
-{
- if (d->priv != NULL) {
- struct dibusb_state *st = d->priv;
- if (st->ops.pid_parse != NULL)
- if (st->ops.pid_parse(d->fe,onoff) < 0)
- err("could not handle pid_parser");
- }
- return 0;
-}
-EXPORT_SYMBOL(dibusb_pid_filter_ctrl);
-
-int dibusb_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 b[3];
- int ret;
- b[0] = DIBUSB_REQ_SET_IOCTL;
- b[1] = DIBUSB_IOCTL_CMD_POWER_MODE;
- b[2] = onoff ? DIBUSB_IOCTL_POWER_WAKEUP : DIBUSB_IOCTL_POWER_SLEEP;
- ret = dvb_usb_generic_write(d,b,3);
- msleep(10);
- return ret;
-}
-EXPORT_SYMBOL(dibusb_power_ctrl);
-
-int dibusb2_0_streaming_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 b[3] = { 0 };
- int ret;
-
- if ((ret = dibusb_streaming_ctrl(d,onoff)) < 0)
- return ret;
-
- if (onoff) {
- b[0] = DIBUSB_REQ_SET_STREAMING_MODE;
- b[1] = 0x00;
- if ((ret = dvb_usb_generic_write(d,b,2)) < 0)
- return ret;
- }
-
- b[0] = DIBUSB_REQ_SET_IOCTL;
- b[1] = onoff ? DIBUSB_IOCTL_CMD_ENABLE_STREAM : DIBUSB_IOCTL_CMD_DISABLE_STREAM;
- return dvb_usb_generic_write(d,b,3);
-}
-EXPORT_SYMBOL(dibusb2_0_streaming_ctrl);
-
-int dibusb2_0_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- if (onoff) {
- u8 b[3] = { DIBUSB_REQ_SET_IOCTL, DIBUSB_IOCTL_CMD_POWER_MODE, DIBUSB_IOCTL_POWER_WAKEUP };
- return dvb_usb_generic_write(d,b,3);
- } else
- return 0;
-}
-EXPORT_SYMBOL(dibusb2_0_power_ctrl);
-
-static int dibusb_i2c_msg(struct dvb_usb_device *d, u8 addr,
- u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
-{
- u8 sndbuf[wlen+4]; /* lead(1) devaddr,direction(1) addr(2) data(wlen) (len(2) (when reading)) */
- /* write only ? */
- int wo = (rbuf == NULL || rlen == 0),
- len = 2 + wlen + (wo ? 0 : 2);
-
- sndbuf[0] = wo ? DIBUSB_REQ_I2C_WRITE : DIBUSB_REQ_I2C_READ;
- sndbuf[1] = (addr << 1) | (wo ? 0 : 1);
-
- memcpy(&sndbuf[2],wbuf,wlen);
-
- if (!wo) {
- sndbuf[wlen+2] = (rlen >> 8) & 0xff;
- sndbuf[wlen+3] = rlen & 0xff;
- }
-
- return dvb_usb_generic_rw(d,sndbuf,len,rbuf,rlen,0);
-}
-
-/*
- * I2C master xfer function
- */
-static int dibusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
-{
- struct dvb_usb_device *d = i2c_get_adapdata(adap);
- int i;
-
- if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
- return -EAGAIN;
-
- if (num > 2)
- warn("more than 2 i2c messages at a time is not handled yet. TODO.");
-
- for (i = 0; i < num; i++) {
- /* write/read request */
- if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
- if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,
- msg[i+1].buf,msg[i+1].len) < 0)
- break;
- i++;
- } else
- if (dibusb_i2c_msg(d, msg[i].addr, msg[i].buf,msg[i].len,NULL,0) < 0)
- break;
- }
-
- mutex_unlock(&d->i2c_mutex);
- return i;
-}
-
-static u32 dibusb_i2c_func(struct i2c_adapter *adapter)
-{
- return I2C_FUNC_I2C;
-}
-
-struct i2c_algorithm dibusb_i2c_algo = {
- .master_xfer = dibusb_i2c_xfer,
- .functionality = dibusb_i2c_func,
-};
-EXPORT_SYMBOL(dibusb_i2c_algo);
-
-int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
-{
- u8 wbuf[1] = { offs };
- return dibusb_i2c_msg(d, 0x50, wbuf, 1, val, 1);
-}
-EXPORT_SYMBOL(dibusb_read_eeprom_byte);
-
-int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *d)
-{
- struct dib3000_config demod_cfg;
- struct dibusb_state *st = d->priv;
-
- for (demod_cfg.demod_address = 0x8; demod_cfg.demod_address < 0xd; demod_cfg.demod_address++)
- if ((d->fe = dib3000mc_attach(&demod_cfg,&d->i2c_adap,&st->ops)) != NULL) {
- d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
- d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
- d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
- return 0;
- }
-
- return -ENODEV;
-}
-EXPORT_SYMBOL(dibusb_dib3000mc_frontend_attach);
-
-int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *d)
-{
- d->pll_addr = 0x60;
- d->pll_desc = &dvb_pll_env57h1xd5;
-
- d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
- d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
-
- return 0;
-}
-EXPORT_SYMBOL(dibusb_dib3000mc_tuner_attach);
-
-/*
- * common remote control stuff
- */
-struct dvb_usb_rc_key dibusb_rc_keys[] = {
- /* Key codes for the little Artec T1/Twinhan/HAMA/ remote. */
- { 0x00, 0x16, KEY_POWER },
- { 0x00, 0x10, KEY_MUTE },
- { 0x00, 0x03, KEY_1 },
- { 0x00, 0x01, KEY_2 },
- { 0x00, 0x06, KEY_3 },
- { 0x00, 0x09, KEY_4 },
- { 0x00, 0x1d, KEY_5 },
- { 0x00, 0x1f, KEY_6 },
- { 0x00, 0x0d, KEY_7 },
- { 0x00, 0x19, KEY_8 },
- { 0x00, 0x1b, KEY_9 },
- { 0x00, 0x15, KEY_0 },
- { 0x00, 0x05, KEY_CHANNELUP },
- { 0x00, 0x02, KEY_CHANNELDOWN },
- { 0x00, 0x1e, KEY_VOLUMEUP },
- { 0x00, 0x0a, KEY_VOLUMEDOWN },
- { 0x00, 0x11, KEY_RECORD },
- { 0x00, 0x17, KEY_FAVORITES }, /* Heart symbol - Channel list. */
- { 0x00, 0x14, KEY_PLAY },
- { 0x00, 0x1a, KEY_STOP },
- { 0x00, 0x40, KEY_REWIND },
- { 0x00, 0x12, KEY_FASTFORWARD },
- { 0x00, 0x0e, KEY_PREVIOUS }, /* Recall - Previous channel. */
- { 0x00, 0x4c, KEY_PAUSE },
- { 0x00, 0x4d, KEY_SCREEN }, /* Full screen mode. */
- { 0x00, 0x54, KEY_AUDIO }, /* MTS - Switch to secondary audio. */
- /* additional keys TwinHan VisionPlus, the Artec seemingly not have */
- { 0x00, 0x0c, KEY_CANCEL }, /* Cancel */
- { 0x00, 0x1c, KEY_EPG }, /* EPG */
- { 0x00, 0x00, KEY_TAB }, /* Tab */
- { 0x00, 0x48, KEY_INFO }, /* Preview */
- { 0x00, 0x04, KEY_LIST }, /* RecordList */
- { 0x00, 0x0f, KEY_TEXT }, /* Teletext */
- /* Key codes for the KWorld/ADSTech/JetWay remote. */
- { 0x86, 0x12, KEY_POWER },
- { 0x86, 0x0f, KEY_SELECT }, /* source */
- { 0x86, 0x0c, KEY_UNKNOWN }, /* scan */
- { 0x86, 0x0b, KEY_EPG },
- { 0x86, 0x10, KEY_MUTE },
- { 0x86, 0x01, KEY_1 },
- { 0x86, 0x02, KEY_2 },
- { 0x86, 0x03, KEY_3 },
- { 0x86, 0x04, KEY_4 },
- { 0x86, 0x05, KEY_5 },
- { 0x86, 0x06, KEY_6 },
- { 0x86, 0x07, KEY_7 },
- { 0x86, 0x08, KEY_8 },
- { 0x86, 0x09, KEY_9 },
- { 0x86, 0x0a, KEY_0 },
- { 0x86, 0x18, KEY_ZOOM },
- { 0x86, 0x1c, KEY_UNKNOWN }, /* preview */
- { 0x86, 0x13, KEY_UNKNOWN }, /* snap */
- { 0x86, 0x00, KEY_UNDO },
- { 0x86, 0x1d, KEY_RECORD },
- { 0x86, 0x0d, KEY_STOP },
- { 0x86, 0x0e, KEY_PAUSE },
- { 0x86, 0x16, KEY_PLAY },
- { 0x86, 0x11, KEY_BACK },
- { 0x86, 0x19, KEY_FORWARD },
- { 0x86, 0x14, KEY_UNKNOWN }, /* pip */
- { 0x86, 0x15, KEY_ESC },
- { 0x86, 0x1a, KEY_UP },
- { 0x86, 0x1e, KEY_DOWN },
- { 0x86, 0x1f, KEY_LEFT },
- { 0x86, 0x1b, KEY_RIGHT },
-};
-EXPORT_SYMBOL(dibusb_rc_keys);
-
-int dibusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- u8 key[5],cmd = DIBUSB_REQ_POLL_REMOTE;
- dvb_usb_generic_rw(d,&cmd,1,key,5,0);
- dvb_usb_nec_rc_key_to_event(d,key,event,state);
- if (key[0] != 0)
- deb_info("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
- return 0;
-}
-EXPORT_SYMBOL(dibusb_rc_query);
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c
deleted file mode 100644
index f4c45f386eb..00000000000
--- a/drivers/media/dvb/dvb-usb/dibusb-mb.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/* DVB USB compliant linux driver for mobile DVB-T USB devices based on
- * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-B)
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * based on GPL code from DiBcom, which has
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dibusb.h"
-
-static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_device *d)
-{
- struct dib3000_config demod_cfg;
- struct dibusb_state *st = d->priv;
-
- demod_cfg.demod_address = 0x8;
-
- if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) {
- d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c;
- d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c;
- return -ENODEV;
- }
-
- d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl;
-
- return 0;
-}
-
-static int dibusb_thomson_tuner_attach(struct dvb_usb_device *d)
-{
- d->pll_addr = 0x61;
- d->pll_desc = &dvb_pll_tua6010xs;
- return 0;
-}
-
-/* Some of the Artec 1.1 device aren't equipped with the default tuner
- * (Thomson Cable), but with a Panasonic ENV77H11D5. This function figures
- * this out. */
-static int dibusb_tuner_probe_and_attach(struct dvb_usb_device *d)
-{
- u8 b[2] = { 0,0 }, b2[1];
- int ret = 0;
- struct i2c_msg msg[2] = {
- { .flags = 0, .buf = b, .len = 2 },
- { .flags = I2C_M_RD, .buf = b2, .len = 1 },
- };
-
- /* the Panasonic sits on I2C addrass 0x60, the Thomson on 0x61 */
- msg[0].addr = msg[1].addr = 0x60;
-
- if (d->tuner_pass_ctrl)
- d->tuner_pass_ctrl(d->fe,1,msg[0].addr);
-
- if (i2c_transfer (&d->i2c_adap, msg, 2) != 2) {
- err("tuner i2c write failed.");
- ret = -EREMOTEIO;
- }
-
- if (d->tuner_pass_ctrl)
- d->tuner_pass_ctrl(d->fe,0,msg[0].addr);
-
- if (b2[0] == 0xfe) {
- info("This device has the Thomson Cable onboard. Which is default.");
- dibusb_thomson_tuner_attach(d);
- } else {
- u8 bpll[4] = { 0x0b, 0xf5, 0x85, 0xab };
- info("This device has the Panasonic ENV77H11D5 onboard.");
- d->pll_addr = 0x60;
- memcpy(d->pll_init,bpll,4);
- d->pll_desc = &dvb_pll_tda665x;
- }
-
- return ret;
-}
-
-/* USB Driver stuff */
-static struct dvb_usb_properties dibusb1_1_properties;
-static struct dvb_usb_properties dibusb1_1_an2235_properties;
-static struct dvb_usb_properties dibusb2_0b_properties;
-static struct dvb_usb_properties artec_t1_usb2_properties;
-
-static int dibusb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&artec_t1_usb2_properties,THIS_MODULE,NULL) == 0)
- return 0;
-
- return -EINVAL;
-}
-
-/* do not change the order of the ID table */
-static struct usb_device_id dibusb_dib3000mb_table [] = {
-/* 00 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_COLD) },
-/* 01 */ { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_AVERMEDIA_DVBT_USB_WARM) },
-/* 02 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_COLD) },
-/* 03 */ { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_DVBU2000_WARM) },
-/* 04 */ { USB_DEVICE(USB_VID_COMPRO_UNK, USB_PID_COMPRO_DVBU2000_UNK_COLD) },
-/* 05 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_COLD) },
-/* 06 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3000_WARM) },
-/* 07 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_COLD) },
-/* 08 */ { USB_DEVICE(USB_VID_EMPIA, USB_PID_KWORLD_VSTREAM_WARM) },
-/* 09 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_COLD) },
-/* 10 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_GRANDTEC_DVBT_USB_WARM) },
-/* 11 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_COLD) },
-/* 12 */ { USB_DEVICE(USB_VID_GRANDTEC, USB_PID_DIBCOM_MOD3000_WARM) },
-/* 13 */ { USB_DEVICE(USB_VID_HYPER_PALTEK, USB_PID_UNK_HYPER_PALTEK_COLD) },
-/* 14 */ { USB_DEVICE(USB_VID_HYPER_PALTEK, USB_PID_UNK_HYPER_PALTEK_WARM) },
-/* 15 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_COLD) },
-/* 16 */ { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7041_WARM) },
-/* 17 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_COLD) },
-/* 18 */ { USB_DEVICE(USB_VID_TWINHAN, USB_PID_TWINHAN_VP7041_WARM) },
-/* 19 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_COLD) },
-/* 20 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_WARM) },
-/* 21 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_COLD) },
-/* 22 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_AN2235_WARM) },
-/* 23 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_COLD) },
-
-/* device ID with default DIBUSB2_0-firmware and with the hacked firmware */
-/* 24 */ { USB_DEVICE(USB_VID_ADSTECH, USB_PID_ADSTECH_USB2_WARM) },
-/* 25 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_COLD) },
-/* 26 */ { USB_DEVICE(USB_VID_KYE, USB_PID_KYE_DVB_T_WARM) },
-
-/* 27 */ { USB_DEVICE(USB_VID_KWORLD, USB_PID_KWORLD_VSTREAM_COLD) },
-
-/* 28 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) },
-/* 29 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_WARM) },
-
-/*
- * XXX: As Artec just 'forgot' to program the EEPROM on some Artec T1 devices
- * we don't catch these faulty IDs (namely 'Cypress FX1 USB controller') that
- * have been left on the device. If you don't have such a device but an Artec
- * device that's supposed to work with this driver but is not detected by it,
- * free to enable CONFIG_DVB_USB_DIBUSB_MB_FAULTY via your kernel config.
- */
-
-#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY
-/* 30 */ { USB_DEVICE(USB_VID_ANCHOR, USB_PID_ULTIMA_TVBOX_ANCHOR_COLD) },
-#endif
-
- { } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE (usb, dibusb_dib3000mb_table);
-
-static struct dvb_usb_properties dibusb1_1_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
- .pid_filter_count = 16,
-
- .usb_ctrl = CYPRESS_AN2135,
-
- .firmware = "dvb-usb-dibusb-5.0.0.11.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb_streaming_ctrl,
- .pid_filter = dibusb_pid_filter,
- .pid_filter_ctrl = dibusb_pid_filter_ctrl,
- .power_ctrl = dibusb_power_ctrl,
- .frontend_attach = dibusb_dib3000mb_frontend_attach,
- .tuner_attach = dibusb_tuner_probe_and_attach,
-
- .rc_interval = DEFAULT_RC_INTERVAL,
- .rc_key_map = dibusb_rc_keys,
- .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */
- .rc_query = dibusb_rc_query,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 9,
- .devices = {
- { "AVerMedia AverTV DVBT USB1.1",
- { &dibusb_dib3000mb_table[0], NULL },
- { &dibusb_dib3000mb_table[1], NULL },
- },
- { "Compro Videomate DVB-U2000 - DVB-T USB1.1 (please confirm to linux-dvb)",
- { &dibusb_dib3000mb_table[2], &dibusb_dib3000mb_table[4], NULL},
- { &dibusb_dib3000mb_table[3], NULL },
- },
- { "DiBcom USB1.1 DVB-T reference design (MOD3000)",
- { &dibusb_dib3000mb_table[5], NULL },
- { &dibusb_dib3000mb_table[6], NULL },
- },
- { "KWorld V-Stream XPERT DTV - DVB-T USB1.1",
- { &dibusb_dib3000mb_table[7], NULL },
- { &dibusb_dib3000mb_table[8], NULL },
- },
- { "Grandtec USB1.1 DVB-T",
- { &dibusb_dib3000mb_table[9], &dibusb_dib3000mb_table[11], NULL },
- { &dibusb_dib3000mb_table[10], &dibusb_dib3000mb_table[12], NULL },
- },
- { "Unkown USB1.1 DVB-T device ???? please report the name to the author",
- { &dibusb_dib3000mb_table[13], NULL },
- { &dibusb_dib3000mb_table[14], NULL },
- },
- { "TwinhanDTV USB-Ter USB1.1 / Magic Box I / HAMA USB1.1 DVB-T device",
- { &dibusb_dib3000mb_table[15], &dibusb_dib3000mb_table[17], NULL},
- { &dibusb_dib3000mb_table[16], &dibusb_dib3000mb_table[18], NULL},
- },
- { "Artec T1 USB1.1 TVBOX with AN2135",
- { &dibusb_dib3000mb_table[19], NULL },
- { &dibusb_dib3000mb_table[20], NULL },
- },
- { "VideoWalker DVB-T USB",
- { &dibusb_dib3000mb_table[25], NULL },
- { &dibusb_dib3000mb_table[26], NULL },
- },
- }
-};
-
-static struct dvb_usb_properties dibusb1_1_an2235_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
- .pid_filter_count = 16,
-
- .usb_ctrl = CYPRESS_AN2235,
-
- .firmware = "dvb-usb-dibusb-an2235-01.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb_streaming_ctrl,
- .pid_filter = dibusb_pid_filter,
- .pid_filter_ctrl = dibusb_pid_filter_ctrl,
- .power_ctrl = dibusb_power_ctrl,
- .frontend_attach = dibusb_dib3000mb_frontend_attach,
- .tuner_attach = dibusb_tuner_probe_and_attach,
-
- .rc_interval = DEFAULT_RC_INTERVAL,
- .rc_key_map = dibusb_rc_keys,
- .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */
- .rc_query = dibusb_rc_query,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
-#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY
- .num_device_descs = 2,
-#else
- .num_device_descs = 1,
-#endif
- .devices = {
- { "Artec T1 USB1.1 TVBOX with AN2235",
- { &dibusb_dib3000mb_table[20], NULL },
- { &dibusb_dib3000mb_table[21], NULL },
- },
-#ifdef CONFIG_DVB_USB_DIBUSB_MB_FAULTY
- { "Artec T1 USB1.1 TVBOX with AN2235 (faulty USB IDs)",
- { &dibusb_dib3000mb_table[30], NULL },
- { NULL },
- },
- { NULL },
-#endif
- }
-};
-
-static struct dvb_usb_properties dibusb2_0b_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
- .pid_filter_count = 16,
-
- .usb_ctrl = CYPRESS_FX2,
-
- .firmware = "dvb-usb-adstech-usb2-02.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb2_0_streaming_ctrl,
- .pid_filter = dibusb_pid_filter,
- .pid_filter_ctrl = dibusb_pid_filter_ctrl,
- .power_ctrl = dibusb2_0_power_ctrl,
- .frontend_attach = dibusb_dib3000mb_frontend_attach,
- .tuner_attach = dibusb_thomson_tuner_attach,
-
- .rc_interval = DEFAULT_RC_INTERVAL,
- .rc_key_map = dibusb_rc_keys,
- .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */
- .rc_query = dibusb_rc_query,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x06,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 2,
- .devices = {
- { "KWorld/ADSTech Instant DVB-T USB2.0",
- { &dibusb_dib3000mb_table[23], NULL },
- { &dibusb_dib3000mb_table[24], NULL },
- },
- { "KWorld Xpert DVB-T USB2.0",
- { &dibusb_dib3000mb_table[27], NULL },
- { NULL }
- },
- { NULL },
- }
-};
-
-static struct dvb_usb_properties artec_t1_usb2_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
- .pid_filter_count = 16,
-
- .usb_ctrl = CYPRESS_FX2,
-
- .firmware = "dvb-usb-dibusb-6.0.0.8.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb2_0_streaming_ctrl,
- .pid_filter = dibusb_pid_filter,
- .pid_filter_ctrl = dibusb_pid_filter_ctrl,
- .power_ctrl = dibusb2_0_power_ctrl,
- .frontend_attach = dibusb_dib3000mb_frontend_attach,
- .tuner_attach = dibusb_tuner_probe_and_attach,
-
- .rc_interval = DEFAULT_RC_INTERVAL,
- .rc_key_map = dibusb_rc_keys,
- .rc_key_map_size = 63, /* wow, that is ugly ... I want to load it to the driver dynamically */
- .rc_query = dibusb_rc_query,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x06,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "Artec T1 USB2.0",
- { &dibusb_dib3000mb_table[28], NULL },
- { &dibusb_dib3000mb_table[29], NULL },
- },
- { NULL },
- }
-};
-
-static struct usb_driver dibusb_driver = {
- .name = "dvb_usb_dibusb_mb",
- .probe = dibusb_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = dibusb_dib3000mb_table,
-};
-
-/* module stuff */
-static int __init dibusb_module_init(void)
-{
- int result;
- if ((result = usb_register(&dibusb_driver))) {
- err("usb_register failed. Error number %d",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit dibusb_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&dibusb_driver);
-}
-
-module_init (dibusb_module_init);
-module_exit (dibusb_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Driver for DiBcom USB DVB-T devices (DiB3000M-B based)");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
deleted file mode 100644
index 55802fba3c2..00000000000
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* DVB USB compliant linux driver for mobile DVB-T USB devices based on
- * reference designs made by DiBcom (http://www.dibcom.fr/) (DiB3000M-C/P)
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * based on GPL code from DiBcom, which has
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dibusb.h"
-
-/* USB Driver stuff */
-static struct dvb_usb_properties dibusb_mc_properties;
-
-static int dibusb_mc_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE,NULL);
-}
-
-/* do not change the order of the ID table */
-static struct usb_device_id dibusb_dib3000mc_table [] = {
-/* 00 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_COLD) },
-/* 01 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_MOD3001_WARM) },
-/* 02 */ { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ULTIMA_TVBOX_USB2_COLD) },
- { } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE (usb, dibusb_dib3000mc_table);
-
-static struct dvb_usb_properties dibusb_mc_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
- .pid_filter_count = 32,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-dibusb-6.0.0.8.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb2_0_streaming_ctrl,
- .pid_filter = dibusb_pid_filter,
- .pid_filter_ctrl = dibusb_pid_filter_ctrl,
- .power_ctrl = dibusb2_0_power_ctrl,
- .frontend_attach = dibusb_dib3000mc_frontend_attach,
- .tuner_attach = dibusb_dib3000mc_tuner_attach,
-
- .rc_interval = DEFAULT_RC_INTERVAL,
- .rc_key_map = dibusb_rc_keys,
- .rc_key_map_size = 63, /* FIXME */
- .rc_query = dibusb_rc_query,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x06,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 2,
- .devices = {
- { "DiBcom USB2.0 DVB-T reference design (MOD3000P)",
- { &dibusb_dib3000mc_table[0], NULL },
- { &dibusb_dib3000mc_table[1], NULL },
- },
- { "Artec T1 USB2.0 TVBOX (please report the warm ID)",
- { &dibusb_dib3000mc_table[2], NULL },
- { NULL },
- },
- }
-};
-
-static struct usb_driver dibusb_mc_driver = {
- .name = "dvb_usb_dibusb_mc",
- .probe = dibusb_mc_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = dibusb_dib3000mc_table,
-};
-
-/* module stuff */
-static int __init dibusb_mc_module_init(void)
-{
- int result;
- if ((result = usb_register(&dibusb_mc_driver))) {
- err("usb_register failed. Error number %d",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit dibusb_mc_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&dibusb_mc_driver);
-}
-
-module_init (dibusb_mc_module_init);
-module_exit (dibusb_mc_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Driver for DiBcom USB2.0 DVB-T (DiB3000M-C/P based) devices");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dibusb.h b/drivers/media/dvb/dvb-usb/dibusb.h
deleted file mode 100644
index 2d99d05c7ea..00000000000
--- a/drivers/media/dvb/dvb-usb/dibusb.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Header file for all dibusb-based-receivers.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#ifndef _DVB_USB_DIBUSB_H_
-#define _DVB_USB_DIBUSB_H_
-
-#ifndef DVB_USB_LOG_PREFIX
- #define DVB_USB_LOG_PREFIX "dibusb"
-#endif
-#include "dvb-usb.h"
-
-#include "dib3000.h"
-
-/*
- * protocol of all dibusb related devices
- */
-
-/*
- * bulk msg to/from endpoint 0x01
- *
- * general structure:
- * request_byte parameter_bytes
- */
-
-#define DIBUSB_REQ_START_READ 0x00
-#define DIBUSB_REQ_START_DEMOD 0x01
-
-/*
- * i2c read
- * bulk write: 0x02 ((7bit i2c_addr << 1) & 0x01) register_bytes length_word
- * bulk read: byte_buffer (length_word bytes)
- */
-#define DIBUSB_REQ_I2C_READ 0x02
-
-/*
- * i2c write
- * bulk write: 0x03 (7bit i2c_addr << 1) register_bytes value_bytes
- */
-#define DIBUSB_REQ_I2C_WRITE 0x03
-
-/*
- * polling the value of the remote control
- * bulk write: 0x04
- * bulk read: byte_buffer (5 bytes)
- */
-#define DIBUSB_REQ_POLL_REMOTE 0x04
-
-/* additional status values for Hauppauge Remote Control Protocol */
-#define DIBUSB_RC_HAUPPAUGE_KEY_PRESSED 0x01
-#define DIBUSB_RC_HAUPPAUGE_KEY_EMPTY 0x03
-
-/* streaming mode:
- * bulk write: 0x05 mode_byte
- *
- * mode_byte is mostly 0x00
- */
-#define DIBUSB_REQ_SET_STREAMING_MODE 0x05
-
-/* interrupt the internal read loop, when blocking */
-#define DIBUSB_REQ_INTR_READ 0x06
-
-/* io control
- * 0x07 cmd_byte param_bytes
- *
- * param_bytes can be up to 32 bytes
- *
- * cmd_byte function parameter name
- * 0x00 power mode
- * 0x00 sleep
- * 0x01 wakeup
- *
- * 0x01 enable streaming
- * 0x02 disable streaming
- *
- *
- */
-#define DIBUSB_REQ_SET_IOCTL 0x07
-
-/* IOCTL commands */
-
-/* change the power mode in firmware */
-#define DIBUSB_IOCTL_CMD_POWER_MODE 0x00
-#define DIBUSB_IOCTL_POWER_SLEEP 0x00
-#define DIBUSB_IOCTL_POWER_WAKEUP 0x01
-
-/* modify streaming of the FX2 */
-#define DIBUSB_IOCTL_CMD_ENABLE_STREAM 0x01
-#define DIBUSB_IOCTL_CMD_DISABLE_STREAM 0x02
-
-struct dibusb_state {
- struct dib_fe_xfer_ops ops;
-
- /* for RC5 remote control */
- int old_toggle;
- int last_repeat_count;
-};
-
-extern struct i2c_algorithm dibusb_i2c_algo;
-
-extern int dibusb_dib3000mc_frontend_attach(struct dvb_usb_device *);
-extern int dibusb_dib3000mc_tuner_attach (struct dvb_usb_device *);
-
-extern int dibusb_streaming_ctrl(struct dvb_usb_device *, int);
-extern int dibusb_pid_filter(struct dvb_usb_device *, int, u16, int);
-extern int dibusb_pid_filter_ctrl(struct dvb_usb_device *, int);
-extern int dibusb_power_ctrl(struct dvb_usb_device *, int);
-extern int dibusb2_0_streaming_ctrl(struct dvb_usb_device *, int);
-extern int dibusb2_0_power_ctrl(struct dvb_usb_device *, int);
-
-#define DEFAULT_RC_INTERVAL 150
-//#define DEFAULT_RC_INTERVAL 100000
-
-extern struct dvb_usb_rc_key dibusb_rc_keys[];
-extern int dibusb_rc_query(struct dvb_usb_device *, u32 *, int *);
-extern int dibusb_read_eeprom_byte(struct dvb_usb_device *, u8, u8 *);
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
deleted file mode 100644
index c14d9efb48f..00000000000
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/* DVB USB compliant linux driver for Nebula Electronics uDigiTV DVB-T USB2.0
- * receiver
- *
- * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * partly based on the SDK published by Nebula Electronics
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "digitv.h"
-
-#include "mt352.h"
-#include "nxt6000.h"
-
-/* debug */
-int dvb_usb_digitv_debug;
-module_param_named(debug,dvb_usb_digitv_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
-
-static int digitv_ctrl_msg(struct dvb_usb_device *d,
- u8 cmd, u8 vv, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
-{
- int wo = (rbuf == NULL || rlen == 0); /* write-only */
- u8 sndbuf[7],rcvbuf[7];
- memset(sndbuf,0,7); memset(rcvbuf,0,7);
-
- sndbuf[0] = cmd;
- sndbuf[1] = vv;
- sndbuf[2] = wo ? wlen : rlen;
-
- if (wo) {
- memcpy(&sndbuf[3],wbuf,wlen);
- dvb_usb_generic_write(d,sndbuf,7);
- } else {
- dvb_usb_generic_rw(d,sndbuf,7,rcvbuf,7,10);
- memcpy(rbuf,&rcvbuf[3],rlen);
- }
- return 0;
-}
-
-/* I2C */
-static int digitv_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
-{
- struct dvb_usb_device *d = i2c_get_adapdata(adap);
- int i;
-
- if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
- return -EAGAIN;
-
- if (num > 2)
- warn("more than 2 i2c messages at a time is not handled yet. TODO.");
-
- for (i = 0; i < num; i++) {
- /* write/read request */
- if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
- if (digitv_ctrl_msg(d, USB_READ_COFDM, msg[i].buf[0], NULL, 0,
- msg[i+1].buf,msg[i+1].len) < 0)
- break;
- i++;
- } else
- if (digitv_ctrl_msg(d,USB_WRITE_COFDM, msg[i].buf[0],
- &msg[i].buf[1],msg[i].len-1,NULL,0) < 0)
- break;
- }
-
- mutex_unlock(&d->i2c_mutex);
- return i;
-}
-
-static u32 digitv_i2c_func(struct i2c_adapter *adapter)
-{
- return I2C_FUNC_I2C;
-}
-
-static struct i2c_algorithm digitv_i2c_algo = {
- .master_xfer = digitv_i2c_xfer,
- .functionality = digitv_i2c_func,
-};
-
-/* Callbacks for DVB USB */
-static int digitv_identify_state (struct usb_device *udev, struct
- dvb_usb_properties *props, struct dvb_usb_device_description **desc,
- int *cold)
-{
- *cold = udev->descriptor.iManufacturer == 0 && udev->descriptor.iProduct == 0;
- return 0;
-}
-
-static int digitv_mt352_demod_init(struct dvb_frontend *fe)
-{
- static u8 reset_buf[] = { 0x89, 0x38, 0x8a, 0x2d, 0x50, 0x80 };
- static u8 init_buf[] = { 0x68, 0xa0, 0x8e, 0x40, 0x53, 0x50,
- 0x67, 0x20, 0x7d, 0x01, 0x7c, 0x00, 0x7a, 0x00,
- 0x79, 0x20, 0x57, 0x05, 0x56, 0x31, 0x88, 0x0f,
- 0x75, 0x32 };
- int i;
-
- for (i = 0; i < ARRAY_SIZE(reset_buf); i += 2)
- mt352_write(fe, &reset_buf[i], 2);
-
- msleep(1);
-
- for (i = 0; i < ARRAY_SIZE(init_buf); i += 2)
- mt352_write(fe, &init_buf[i], 2);
-
- return 0;
-}
-
-static struct mt352_config digitv_mt352_config = {
- .demod_init = digitv_mt352_demod_init,
-};
-
-static int digitv_nxt6000_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
-{
- struct dvb_usb_device *d = fe->dvb->priv;
- u8 b[5];
- dvb_usb_tuner_calc_regs(fe,fep,b, 5);
- return digitv_ctrl_msg(d,USB_WRITE_TUNER,0,&b[1],4,NULL,0);
-}
-
-static struct nxt6000_config digitv_nxt6000_config = {
- .clock_inversion = 1,
-};
-
-static int digitv_frontend_attach(struct dvb_usb_device *d)
-{
- if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) {
- d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
- return 0;
- }
- if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) {
- d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params;
- return 0;
- }
- return -EIO;
-}
-
-static int digitv_tuner_attach(struct dvb_usb_device *d)
-{
- d->pll_addr = 0x60;
- d->pll_desc = &dvb_pll_tded4;
- return 0;
-}
-
-static struct dvb_usb_rc_key digitv_rc_keys[] = {
- { 0x00, 0x16, KEY_POWER }, /* dummy key */
-};
-
-/* TODO is it really the NEC protocol ? */
-static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- u8 key[5];
-
- digitv_ctrl_msg(d,USB_READ_REMOTE,0,NULL,0,&key[1],4);
- /* TODO state, maybe it is VV ? */
- if (key[1] != 0)
- key[0] = 0x01; /* if something is inside the buffer, simulate key press */
-
- /* call the universal NEC remote processor, to find out the key's state and event */
- dvb_usb_nec_rc_key_to_event(d,key,event,state);
- if (key[0] != 0)
- deb_rc("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
- return 0;
-}
-
-/* DVB USB Driver stuff */
-static struct dvb_usb_properties digitv_properties;
-
-static int digitv_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct dvb_usb_device *d;
- int ret;
- if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) {
- u8 b[4] = { 0 };
-
- if (d != NULL) { /* do that only when the firmware is loaded */
- b[0] = 1;
- digitv_ctrl_msg(d,USB_WRITE_REMOTE_TYPE,0,b,4,NULL,0);
-
- b[0] = 0;
- digitv_ctrl_msg(d,USB_WRITE_REMOTE,0,b,4,NULL,0);
- }
- }
- return ret;
-}
-
-static struct usb_device_id digitv_table [] = {
- { USB_DEVICE(USB_VID_ANCHOR, USB_PID_NEBULA_DIGITV) },
- { } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE (usb, digitv_table);
-
-static struct dvb_usb_properties digitv_properties = {
- .caps = DVB_USB_IS_AN_I2C_ADAPTER,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-digitv-02.fw",
-
- .size_of_priv = 0,
-
- .frontend_attach = digitv_frontend_attach,
- .tuner_attach = digitv_tuner_attach,
-
- .rc_interval = 1000,
- .rc_key_map = digitv_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(digitv_rc_keys),
- .rc_query = digitv_rc_query,
-
- .identify_state = digitv_identify_state,
-
- .i2c_algo = &digitv_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "Nebula Electronics uDigiTV DVB-T USB2.0)",
- { &digitv_table[0], NULL },
- { NULL },
- },
- { NULL },
- }
-};
-
-static struct usb_driver digitv_driver = {
- .name = "dvb_usb_digitv",
- .probe = digitv_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = digitv_table,
-};
-
-/* module stuff */
-static int __init digitv_module_init(void)
-{
- int result;
- if ((result = usb_register(&digitv_driver))) {
- err("usb_register failed. Error number %d",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit digitv_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&digitv_driver);
-}
-
-module_init (digitv_module_init);
-module_exit (digitv_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Driver for Nebula Electronics uDigiTV DVB-T USB2.0");
-MODULE_VERSION("1.0-alpha");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/digitv.h b/drivers/media/dvb/dvb-usb/digitv.h
deleted file mode 100644
index 477ee428a70..00000000000
--- a/drivers/media/dvb/dvb-usb/digitv.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef _DVB_USB_DIGITV_H_
-#define _DVB_USB_DIGITV_H_
-
-#define DVB_USB_LOG_PREFIX "digitv"
-#include "dvb-usb.h"
-
-extern int dvb_usb_digitv_debug;
-#define deb_rc(args...) dprintk(dvb_usb_digitv_debug,0x01,args)
-
-/* protocol (from usblogging and the SDK:
- *
- * Always 7 bytes bulk message(s) for controlling
- *
- * First byte describes the command. Reads are 2 consecutive transfer (as always).
- *
- * General structure:
- *
- * write or first message of a read:
- * <cmdbyte> VV <len> B0 B1 B2 B3
- *
- * second message of a read
- * <cmdbyte> VV <len> R0 R1 R2 R3
- *
- * whereas 0 < len <= 4
- *
- * I2C address is stored somewhere inside the device.
- *
- * 0x01 read from EEPROM
- * VV = offset; B* = 0; R* = value(s)
- *
- * 0x02 read register of the COFDM
- * VV = register; B* = 0; R* = value(s)
- *
- * 0x05 write register of the COFDM
- * VV = register; B* = value(s);
- *
- * 0x06 write to the tuner (only for NXT6000)
- * VV = 0; B* = PLL data; len = 4;
- *
- * 0x03 read remote control
- * VV = 0; B* = 0; len = 4; R* = key
- *
- * 0x07 write to the remote (don't know why one should this, resetting ?)
- * VV = 0; B* = key; len = 4;
- *
- * 0x08 write remote type
- * VV = 0; B[0] = 0x01, len = 4
- *
- * 0x09 write device init
- * TODO
- */
-#define USB_READ_EEPROM 1
-
-#define USB_READ_COFDM 2
-#define USB_WRITE_COFDM 5
-
-#define USB_WRITE_TUNER 6
-
-#define USB_READ_REMOTE 3
-#define USB_WRITE_REMOTE 7
-#define USB_WRITE_REMOTE_TYPE 8
-
-#define USB_DEV_INIT 9
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c
deleted file mode 100644
index 17413adec7a..00000000000
--- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Frontend part of the Linux driver for the WideView/ Yakumo/ Hama/
- * Typhoon/ Yuan DVB-T USB2.0 receiver.
- *
- * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de>
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dtt200u.h"
-
-struct dtt200u_fe_state {
- struct dvb_usb_device *d;
-
- fe_status_t stat;
-
- struct dvb_frontend_parameters fep;
- struct dvb_frontend frontend;
-};
-
-static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- u8 st = GET_TUNE_STATUS, b[3];
-
- dvb_usb_generic_rw(state->d,&st,1,b,3,0);
-
- switch (b[0]) {
- case 0x01:
- *stat = FE_HAS_SIGNAL | FE_HAS_CARRIER |
- FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
- break;
- case 0x00: /* pending */
- *stat = FE_TIMEDOUT; /* during set_frontend */
- break;
- default:
- case 0x02: /* failed */
- *stat = 0;
- break;
- }
- return 0;
-}
-
-static int dtt200u_fe_read_ber(struct dvb_frontend* fe, u32 *ber)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- u8 bw = GET_VIT_ERR_CNT,b[3];
- dvb_usb_generic_rw(state->d,&bw,1,b,3,0);
- *ber = (b[0] << 16) | (b[1] << 8) | b[2];
- return 0;
-}
-
-static int dtt200u_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- u8 bw = GET_RS_UNCOR_BLK_CNT,b[2];
-
- dvb_usb_generic_rw(state->d,&bw,1,b,2,0);
- *unc = (b[0] << 8) | b[1];
- return 0;
-}
-
-static int dtt200u_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- u8 bw = GET_AGC, b;
- dvb_usb_generic_rw(state->d,&bw,1,&b,1,0);
- *strength = (b << 8) | b;
- return 0;
-}
-
-static int dtt200u_fe_read_snr(struct dvb_frontend* fe, u16 *snr)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- u8 bw = GET_SNR,br;
- dvb_usb_generic_rw(state->d,&bw,1,&br,1,0);
- *snr = ~((br << 8) | br);
- return 0;
-}
-
-static int dtt200u_fe_init(struct dvb_frontend* fe)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- u8 b = SET_INIT;
- return dvb_usb_generic_write(state->d,&b,1);
-}
-
-static int dtt200u_fe_sleep(struct dvb_frontend* fe)
-{
- return dtt200u_fe_init(fe);
-}
-
-static int dtt200u_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- tune->min_delay_ms = 1500;
- tune->step_size = 0;
- tune->max_drift = 0;
- return 0;
-}
-
-static int dtt200u_fe_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- int i;
- fe_status_t st;
- u16 freq = fep->frequency / 250000;
- u8 bwbuf[2] = { SET_BANDWIDTH, 0 },freqbuf[3] = { SET_RF_FREQ, 0, 0 };
-
- switch (fep->u.ofdm.bandwidth) {
- case BANDWIDTH_8_MHZ: bwbuf[1] = 8; break;
- case BANDWIDTH_7_MHZ: bwbuf[1] = 7; break;
- case BANDWIDTH_6_MHZ: bwbuf[1] = 6; break;
- case BANDWIDTH_AUTO: return -EOPNOTSUPP;
- default:
- return -EINVAL;
- }
-
- dvb_usb_generic_write(state->d,bwbuf,2);
-
- freqbuf[1] = freq & 0xff;
- freqbuf[2] = (freq >> 8) & 0xff;
- dvb_usb_generic_write(state->d,freqbuf,3);
-
- for (i = 0; i < 30; i++) {
- msleep(20);
- dtt200u_fe_read_status(fe, &st);
- if (st & FE_TIMEDOUT)
- continue;
- }
-
- return 0;
-}
-
-static int dtt200u_fe_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct dtt200u_fe_state *state = fe->demodulator_priv;
- memcpy(fep,&state->fep,sizeof(struct dvb_frontend_parameters));
- return 0;
-}
-
-static void dtt200u_fe_release(struct dvb_frontend* fe)
-{
- struct dtt200u_fe_state *state = (struct dtt200u_fe_state*) fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops dtt200u_fe_ops;
-
-struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d)
-{
- struct dtt200u_fe_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct dtt200u_fe_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- deb_info("attaching frontend dtt200u\n");
-
- state->d = d;
-
- memcpy(&state->frontend.ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
-
- return &state->frontend;
-error:
- return NULL;
-}
-
-static struct dvb_frontend_ops dtt200u_fe_ops = {
- .info = {
- .name = "WideView USB DVB-T",
- .type = FE_OFDM,
- .frequency_min = 44250000,
- .frequency_max = 867250000,
- .frequency_stepsize = 250000,
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO |
- FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_RECOVER |
- FE_CAN_HIERARCHY_AUTO,
- },
-
- .release = dtt200u_fe_release,
-
- .init = dtt200u_fe_init,
- .sleep = dtt200u_fe_sleep,
-
- .set_frontend = dtt200u_fe_set_frontend,
- .get_frontend = dtt200u_fe_get_frontend,
- .get_tune_settings = dtt200u_fe_get_tune_settings,
-
- .read_status = dtt200u_fe_read_status,
- .read_ber = dtt200u_fe_read_ber,
- .read_signal_strength = dtt200u_fe_read_signal_strength,
- .read_snr = dtt200u_fe_read_snr,
- .read_ucblocks = dtt200u_fe_read_unc_blocks,
-};
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
deleted file mode 100644
index 70afcfd141c..00000000000
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/* DVB USB library compliant Linux driver for the WideView/ Yakumo/ Hama/
- * Typhoon/ Yuan DVB-T USB2.0 receiver.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * Thanks to Steve Chang from WideView for providing support for the WT-220U.
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dtt200u.h"
-
-/* debug */
-int dvb_usb_dtt200u_debug;
-module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS);
-
-static int dtt200u_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 b = SET_INIT;
-
- if (onoff)
- dvb_usb_generic_write(d,&b,2);
-
- return 0;
-}
-
-static int dtt200u_streaming_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 b_streaming[2] = { SET_STREAMING, onoff };
- u8 b_rst_pid = RESET_PID_FILTER;
-
- dvb_usb_generic_write(d,b_streaming,2);
-
- if (onoff == 0)
- dvb_usb_generic_write(d,&b_rst_pid,1);
- return 0;
-}
-
-static int dtt200u_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
-{
- u8 b_pid[4];
- pid = onoff ? pid : 0;
-
- b_pid[0] = SET_PID_FILTER;
- b_pid[1] = index;
- b_pid[2] = pid & 0xff;
- b_pid[3] = (pid >> 8) & 0x1f;
-
- return dvb_usb_generic_write(d,b_pid,4);
-}
-
-/* remote control */
-/* key list for the tiny remote control (Yakumo, don't know about the others) */
-static struct dvb_usb_rc_key dtt200u_rc_keys[] = {
- { 0x80, 0x01, KEY_MUTE },
- { 0x80, 0x02, KEY_CHANNELDOWN },
- { 0x80, 0x03, KEY_VOLUMEDOWN },
- { 0x80, 0x04, KEY_1 },
- { 0x80, 0x05, KEY_2 },
- { 0x80, 0x06, KEY_3 },
- { 0x80, 0x07, KEY_4 },
- { 0x80, 0x08, KEY_5 },
- { 0x80, 0x09, KEY_6 },
- { 0x80, 0x0a, KEY_7 },
- { 0x80, 0x0c, KEY_ZOOM },
- { 0x80, 0x0d, KEY_0 },
- { 0x80, 0x0e, KEY_SELECT },
- { 0x80, 0x12, KEY_POWER },
- { 0x80, 0x1a, KEY_CHANNELUP },
- { 0x80, 0x1b, KEY_8 },
- { 0x80, 0x1e, KEY_VOLUMEUP },
- { 0x80, 0x1f, KEY_9 },
-};
-
-static int dtt200u_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- u8 key[5],cmd = GET_RC_CODE;
- dvb_usb_generic_rw(d,&cmd,1,key,5,0);
- dvb_usb_nec_rc_key_to_event(d,key,event,state);
- if (key[0] != 0)
- deb_info("key: %x %x %x %x %x\n",key[0],key[1],key[2],key[3],key[4]);
- return 0;
-}
-
-static int dtt200u_frontend_attach(struct dvb_usb_device *d)
-{
- d->fe = dtt200u_fe_attach(d);
- return 0;
-}
-
-static struct dvb_usb_properties dtt200u_properties;
-static struct dvb_usb_properties wt220u_properties;
-static struct dvb_usb_properties wt220u_zl0353_properties;
-
-static int dtt200u_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0 ||
- dvb_usb_device_init(intf,&wt220u_zl0353_properties,THIS_MODULE,NULL) == 0)
- return 0;
-
- return -ENODEV;
-}
-
-static struct usb_device_id dtt200u_usb_table [] = {
- { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_COLD) },
- { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_DTT200U_WARM) },
- { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_COLD) },
- { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_WARM) },
- { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_COLD) },
- { USB_DEVICE(USB_VID_WIDEVIEW, USB_PID_WT220U_ZL0353_WARM) },
- { 0 },
-};
-MODULE_DEVICE_TABLE(usb, dtt200u_usb_table);
-
-static struct dvb_usb_properties dtt200u_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
- .pid_filter_count = 15,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-dtt200u-01.fw",
-
- .power_ctrl = dtt200u_power_ctrl,
- .streaming_ctrl = dtt200u_streaming_ctrl,
- .pid_filter = dtt200u_pid_filter,
- .frontend_attach = dtt200u_frontend_attach,
-
- .rc_interval = 300,
- .rc_key_map = dtt200u_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
- .rc_query = dtt200u_rc_query,
-
- .generic_bulk_ctrl_endpoint = 0x01,
-
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { .name = "WideView/Yuan/Yakumo/Hama/Typhoon DVB-T USB2.0 (WT-200U)",
- .cold_ids = { &dtt200u_usb_table[0], NULL },
- .warm_ids = { &dtt200u_usb_table[1], NULL },
- },
- { NULL },
- }
-};
-
-static struct dvb_usb_properties wt220u_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
- .pid_filter_count = 15,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-wt220u-02.fw",
-
- .power_ctrl = dtt200u_power_ctrl,
- .streaming_ctrl = dtt200u_streaming_ctrl,
- .pid_filter = dtt200u_pid_filter,
- .frontend_attach = dtt200u_frontend_attach,
-
- .rc_interval = 300,
- .rc_key_map = dtt200u_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
- .rc_query = dtt200u_rc_query,
-
- .generic_bulk_ctrl_endpoint = 0x01,
-
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { .name = "WideView WT-220U PenType Receiver (Typhoon/Freecom)",
- .cold_ids = { &dtt200u_usb_table[2], NULL },
- .warm_ids = { &dtt200u_usb_table[3], NULL },
- },
- { NULL },
- }
-};
-
-static struct dvb_usb_properties wt220u_zl0353_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
- .pid_filter_count = 15,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-wt220u-zl0353-01.fw",
-
- .power_ctrl = dtt200u_power_ctrl,
- .streaming_ctrl = dtt200u_streaming_ctrl,
- .pid_filter = dtt200u_pid_filter,
- .frontend_attach = dtt200u_frontend_attach,
-
- .rc_interval = 300,
- .rc_key_map = dtt200u_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(dtt200u_rc_keys),
- .rc_query = dtt200u_rc_query,
-
- .generic_bulk_ctrl_endpoint = 0x01,
-
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { .name = "WideView WT-220U PenType Receiver (based on ZL353)",
- .cold_ids = { &dtt200u_usb_table[4], NULL },
- .warm_ids = { &dtt200u_usb_table[5], NULL },
- },
- { NULL },
- }
-};
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver dtt200u_usb_driver = {
- .name = "dvb_usb_dtt200u",
- .probe = dtt200u_usb_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = dtt200u_usb_table,
-};
-
-/* module stuff */
-static int __init dtt200u_usb_module_init(void)
-{
- int result;
- if ((result = usb_register(&dtt200u_usb_driver))) {
- err("usb_register failed. (%d)",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit dtt200u_usb_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&dtt200u_usb_driver);
-}
-
-module_init(dtt200u_usb_module_init);
-module_exit(dtt200u_usb_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Driver for the WideView/Yakumo/Hama/Typhoon DVB-T USB2.0 devices");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.h b/drivers/media/dvb/dvb-usb/dtt200u.h
deleted file mode 100644
index 005b0a7df35..00000000000
--- a/drivers/media/dvb/dvb-usb/dtt200u.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Common header file of Linux driver for the WideView/ Yakumo/ Hama/
- * Typhoon/ Yuan DVB-T USB2.0 receiver.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#ifndef _DVB_USB_DTT200U_H_
-#define _DVB_USB_DTT200U_H_
-
-#define DVB_USB_LOG_PREFIX "dtt200u"
-
-#include "dvb-usb.h"
-
-extern int dvb_usb_dtt200u_debug;
-#define deb_info(args...) dprintk(dvb_usb_dtt200u_debug,0x01,args)
-#define deb_xfer(args...) dprintk(dvb_usb_dtt200u_debug,0x02,args)
-
-/* guessed protocol description (reverse engineered):
- * read
- * 00 - USB type 0x02 for usb2.0, 0x01 for usb1.1
- * 88 - locking 2 bytes (0x80 0x40 == no signal, 0x89 0x20 == nice signal)
- */
-
-#define GET_SPEED 0x00
-#define GET_TUNE_STATUS 0x81
-#define GET_RC_CODE 0x84
-#define GET_CONFIGURATION 0x88
-#define GET_AGC 0x89
-#define GET_SNR 0x8a
-#define GET_VIT_ERR_CNT 0x8c
-#define GET_RS_ERR_CNT 0x8d
-#define GET_RS_UNCOR_BLK_CNT 0x8e
-
-/* write
- * 01 - init
- * 02 - frequency (divided by 250000)
- * 03 - bandwidth
- * 04 - pid table (index pid(7:0) pid(12:8))
- * 05 - reset the pid table
- * 08 - transfer switch
- */
-
-#define SET_INIT 0x01
-#define SET_RF_FREQ 0x02
-#define SET_BANDWIDTH 0x03
-#define SET_PID_FILTER 0x04
-#define RESET_PID_FILTER 0x05
-#define SET_STREAMING 0x08
-
-extern struct dvb_frontend * dtt200u_fe_attach(struct dvb_usb_device *d);
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-common.h b/drivers/media/dvb/dvb-usb/dvb-usb-common.h
deleted file mode 100644
index a3460bf2d9f..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-common.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* dvb-usb-common.h is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- * see dvb-usb-init.c for copyright information.
- *
- * a header file containing prototypes and types for internal use of the dvb-usb-lib
- */
-#ifndef _DVB_USB_COMMON_H_
-#define _DVB_USB_COMMON_H_
-
-#define DVB_USB_LOG_PREFIX "dvb-usb"
-#include "dvb-usb.h"
-
-extern int dvb_usb_debug;
-extern int dvb_usb_disable_rc_polling;
-
-#define deb_info(args...) dprintk(dvb_usb_debug,0x01,args)
-#define deb_xfer(args...) dprintk(dvb_usb_debug,0x02,args)
-#define deb_pll(args...) dprintk(dvb_usb_debug,0x04,args)
-#define deb_ts(args...) dprintk(dvb_usb_debug,0x08,args)
-#define deb_err(args...) dprintk(dvb_usb_debug,0x10,args)
-#define deb_rc(args...) dprintk(dvb_usb_debug,0x20,args)
-#define deb_fw(args...) dprintk(dvb_usb_debug,0x40,args)
-#define deb_mem(args...) dprintk(dvb_usb_debug,0x80,args)
-
-/* commonly used methods */
-extern int dvb_usb_download_firmware(struct usb_device *, struct dvb_usb_properties *);
-
-extern int dvb_usb_urb_submit(struct dvb_usb_device *);
-extern int dvb_usb_urb_kill(struct dvb_usb_device *);
-extern int dvb_usb_urb_init(struct dvb_usb_device *);
-extern int dvb_usb_urb_exit(struct dvb_usb_device *);
-
-extern int dvb_usb_i2c_init(struct dvb_usb_device *);
-extern int dvb_usb_i2c_exit(struct dvb_usb_device *);
-
-extern int dvb_usb_dvb_init(struct dvb_usb_device *);
-extern int dvb_usb_dvb_exit(struct dvb_usb_device *);
-
-extern int dvb_usb_fe_init(struct dvb_usb_device *);
-extern int dvb_usb_fe_exit(struct dvb_usb_device *);
-
-extern int dvb_usb_remote_init(struct dvb_usb_device *);
-extern int dvb_usb_remote_exit(struct dvb_usb_device *);
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
deleted file mode 100644
index ec631708c39..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/* dvb-usb-dvb.c is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- * see dvb-usb-init.c for copyright information.
- *
- * This file contains functions for initializing and handling the
- * linux-dvb API.
- */
-#include "dvb-usb-common.h"
-
-static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
-{
- struct dvb_usb_device *d = dvbdmxfeed->demux->priv;
- int newfeedcount,ret;
-
- if (d == NULL)
- return -ENODEV;
-
- newfeedcount = d->feedcount + (onoff ? 1 : -1);
-
- /*
- * stop feed before setting a new pid if there will be no pid anymore
- */
- if (newfeedcount == 0) {
- deb_ts("stop feeding\n");
- dvb_usb_urb_kill(d);
-
- if (d->props.streaming_ctrl != NULL)
- if ((ret = d->props.streaming_ctrl(d,0)))
- err("error while stopping stream.");
-
- }
-
- d->feedcount = newfeedcount;
-
- /* activate the pid on the device specific pid_filter */
- deb_ts("setting pid: %5d %04x at index %d '%s'\n",dvbdmxfeed->pid,dvbdmxfeed->pid,dvbdmxfeed->index,onoff ? "on" : "off");
- if (d->props.caps & DVB_USB_HAS_PID_FILTER &&
- d->pid_filtering &&
- d->props.pid_filter != NULL)
- d->props.pid_filter(d,dvbdmxfeed->index,dvbdmxfeed->pid,onoff);
-
- /* start the feed if this was the first feed and there is still a feed
- * for reception.
- */
- if (d->feedcount == onoff && d->feedcount > 0) {
- deb_ts("submitting all URBs\n");
- dvb_usb_urb_submit(d);
-
- deb_ts("controlling pid parser\n");
- if (d->props.caps & DVB_USB_HAS_PID_FILTER &&
- d->props.caps & DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF &&
- d->props.pid_filter_ctrl != NULL)
- if (d->props.pid_filter_ctrl(d,d->pid_filtering) < 0)
- err("could not handle pid_parser");
-
- deb_ts("start feeding\n");
- if (d->props.streaming_ctrl != NULL)
- if (d->props.streaming_ctrl(d,1)) {
- err("error while enabling fifo.");
- return -ENODEV;
- }
-
- }
- return 0;
-}
-
-static int dvb_usb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- deb_ts("start pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid,dvbdmxfeed->type);
- return dvb_usb_ctrl_feed(dvbdmxfeed,1);
-}
-
-static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- deb_ts("stop pid: 0x%04x, feedtype: %d\n", dvbdmxfeed->pid, dvbdmxfeed->type);
- return dvb_usb_ctrl_feed(dvbdmxfeed,0);
-}
-
-int dvb_usb_dvb_init(struct dvb_usb_device *d)
-{
- int ret;
-
- if ((ret = dvb_register_adapter(&d->dvb_adap, d->desc->name,
- d->owner, &d->udev->dev)) < 0) {
- deb_info("dvb_register_adapter failed: error %d", ret);
- goto err;
- }
- d->dvb_adap.priv = d;
-
- if (d->props.read_mac_address) {
- if (d->props.read_mac_address(d,d->dvb_adap.proposed_mac) == 0)
- info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",d->dvb_adap.proposed_mac[0],
- d->dvb_adap.proposed_mac[1],d->dvb_adap.proposed_mac[2],
- d->dvb_adap.proposed_mac[3],d->dvb_adap.proposed_mac[4],
- d->dvb_adap.proposed_mac[5]);
- else
- err("MAC address reading failed.");
- }
-
-
- d->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
- d->demux.priv = d;
-
- d->demux.feednum = d->demux.filternum = d->max_feed_count;
- d->demux.start_feed = dvb_usb_start_feed;
- d->demux.stop_feed = dvb_usb_stop_feed;
- d->demux.write_to_decoder = NULL;
- if ((ret = dvb_dmx_init(&d->demux)) < 0) {
- err("dvb_dmx_init failed: error %d",ret);
- goto err_dmx;
- }
-
- d->dmxdev.filternum = d->demux.filternum;
- d->dmxdev.demux = &d->demux.dmx;
- d->dmxdev.capabilities = 0;
- if ((ret = dvb_dmxdev_init(&d->dmxdev, &d->dvb_adap)) < 0) {
- err("dvb_dmxdev_init failed: error %d",ret);
- goto err_dmx_dev;
- }
-
- dvb_net_init(&d->dvb_adap, &d->dvb_net, &d->demux.dmx);
-
- d->state |= DVB_USB_STATE_DVB;
- return 0;
-
-err_dmx_dev:
- dvb_dmx_release(&d->demux);
-err_dmx:
- dvb_unregister_adapter(&d->dvb_adap);
-err:
- return ret;
-}
-
-int dvb_usb_dvb_exit(struct dvb_usb_device *d)
-{
- if (d->state & DVB_USB_STATE_DVB) {
- deb_info("unregistering DVB part\n");
- dvb_net_release(&d->dvb_net);
- d->demux.dmx.close(&d->demux.dmx);
- dvb_dmxdev_release(&d->dmxdev);
- dvb_dmx_release(&d->demux);
- dvb_unregister_adapter(&d->dvb_adap);
- d->state &= ~DVB_USB_STATE_DVB;
- }
- return 0;
-}
-
-static int dvb_usb_fe_wakeup(struct dvb_frontend *fe)
-{
- struct dvb_usb_device *d = fe->dvb->priv;
-
- if (d->props.power_ctrl)
- d->props.power_ctrl(d,1);
-
- if (d->fe_init)
- d->fe_init(fe);
-
- return 0;
-}
-
-static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
-{
- struct dvb_usb_device *d = fe->dvb->priv;
-
- if (d->fe_sleep)
- d->fe_sleep(fe);
-
- if (d->props.power_ctrl)
- d->props.power_ctrl(d,0);
-
- return 0;
-}
-
-int dvb_usb_fe_init(struct dvb_usb_device* d)
-{
- if (d->props.frontend_attach == NULL) {
- err("strange '%s' doesn't want to attach a frontend.",d->desc->name);
- return 0;
- }
-
- d->props.frontend_attach(d);
-
- /* re-assign sleep and wakeup functions */
- if (d->fe != NULL) {
- d->fe_init = d->fe->ops.init; d->fe->ops.init = dvb_usb_fe_wakeup;
- d->fe_sleep = d->fe->ops.sleep; d->fe->ops.sleep = dvb_usb_fe_sleep;
-
- if (dvb_register_frontend(&d->dvb_adap, d->fe)) {
- err("Frontend registration failed.");
- if (d->fe->ops.release)
- d->fe->ops.release(d->fe);
- d->fe = NULL;
- return -ENODEV;
- }
- } else
- err("no frontend was attached by '%s'",d->desc->name);
-
- if (d->props.tuner_attach != NULL)
- d->props.tuner_attach(d);
-
- return 0;
-}
-
-int dvb_usb_fe_exit(struct dvb_usb_device *d)
-{
- if (d->fe != NULL)
- dvb_unregister_frontend(d->fe);
- return 0;
-}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c b/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
deleted file mode 100644
index 9222b0a81f7..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-firmware.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/* dvb-usb-firmware.c is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- * see dvb-usb-init.c for copyright information.
- *
- * This file contains functions for downloading the firmware to Cypress FX 1 and 2 based devices.
- *
- * FIXME: This part does actually not belong to dvb-usb, but to the usb-subsystem.
- */
-#include "dvb-usb-common.h"
-
-#include <linux/usb.h>
-
-struct usb_cypress_controller {
- int id;
- const char *name; /* name of the usb controller */
- u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */
-};
-
-static struct usb_cypress_controller cypress[] = {
- { .id = DEVICE_SPECIFIC, .name = "Device specific", .cpu_cs_register = 0 },
- { .id = CYPRESS_AN2135, .name = "Cypress AN2135", .cpu_cs_register = 0x7f92 },
- { .id = CYPRESS_AN2235, .name = "Cypress AN2235", .cpu_cs_register = 0x7f92 },
- { .id = CYPRESS_FX2, .name = "Cypress FX2", .cpu_cs_register = 0xe600 },
-};
-
-static int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
- int *pos);
-
-/*
- * load a firmware packet to the device
- */
-static int usb_cypress_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len)
-{
- return usb_control_msg(udev, usb_sndctrlpipe(udev,0),
- 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5000);
-}
-
-int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type)
-{
- struct hexline hx;
- u8 reset;
- int ret,pos=0;
-
- /* stop the CPU */
- reset = 1;
- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1)
- err("could not stop the USB controller CPU.");
-
- while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) {
- deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk);
- ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len);
-
- if (ret != hx.len) {
- err("error while transferring firmware "
- "(transferred size: %d, block size: %d)",
- ret,hx.len);
- ret = -EINVAL;
- break;
- }
- }
- if (ret < 0) {
- err("firmware download failed at %d with %d",pos,ret);
- return ret;
- }
-
- if (ret == 0) {
- /* restart the CPU */
- reset = 0;
- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) {
- err("could not restart the USB controller CPU.");
- ret = -EINVAL;
- }
- } else
- ret = -EIO;
-
- return ret;
-}
-EXPORT_SYMBOL(usb_cypress_load_firmware);
-
-int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_properties *props)
-{
- int ret;
- const struct firmware *fw = NULL;
-
- if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) {
- err("did not find the firmware file. (%s) "
- "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
- props->firmware,ret);
- return ret;
- }
-
- info("downloading firmware from file '%s'",props->firmware);
-
- switch (props->usb_ctrl) {
- case CYPRESS_AN2135:
- case CYPRESS_AN2235:
- case CYPRESS_FX2:
- ret = usb_cypress_load_firmware(udev, fw, props->usb_ctrl);
- break;
- case DEVICE_SPECIFIC:
- if (props->download_firmware)
- ret = props->download_firmware(udev,fw);
- else {
- err("BUG: driver didn't specified a download_firmware-callback, although it claims to have a DEVICE_SPECIFIC one.");
- ret = -EINVAL;
- }
- break;
- default:
- ret = -EINVAL;
- break;
- }
-
- release_firmware(fw);
- return ret;
-}
-
-static int dvb_usb_get_hexline(const struct firmware *fw, struct hexline *hx,
- int *pos)
-{
- u8 *b = (u8 *) &fw->data[*pos];
- int data_offs = 4;
- if (*pos >= fw->size)
- return 0;
-
- memset(hx,0,sizeof(struct hexline));
-
- hx->len = b[0];
-
- if ((*pos + hx->len + 4) >= fw->size)
- return -EINVAL;
-
- hx->addr = le16_to_cpu( *((u16 *) &b[1]) );
- hx->type = b[3];
-
- if (hx->type == 0x04) {
- /* b[4] and b[5] are the Extended linear address record data field */
- hx->addr |= (b[4] << 24) | (b[5] << 16);
-/* hx->len -= 2;
- data_offs += 2; */
- }
- memcpy(hx->data,&b[data_offs],hx->len);
- hx->chk = b[hx->len + data_offs];
-
- *pos += hx->len + 5;
-
- return *pos;
-}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
deleted file mode 100644
index 6b611a72509..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/* dvb-usb-i2c.c is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- * see dvb-usb-init.c for copyright information.
- *
- * This file contains functions for (de-)initializing an I2C adapter.
- */
-#include "dvb-usb-common.h"
-
-int dvb_usb_i2c_init(struct dvb_usb_device *d)
-{
- int ret = 0;
-
- if (!(d->props.caps & DVB_USB_IS_AN_I2C_ADAPTER))
- return 0;
-
- if (d->props.i2c_algo == NULL) {
- err("no i2c algorithm specified");
- return -EINVAL;
- }
-
- strncpy(d->i2c_adap.name,d->desc->name,I2C_NAME_SIZE);
-#ifdef I2C_ADAP_CLASS_TV_DIGITAL
- d->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL,
-#else
- d->i2c_adap.class = I2C_CLASS_TV_DIGITAL,
-#endif
- d->i2c_adap.algo = d->props.i2c_algo;
- d->i2c_adap.algo_data = NULL;
-
- i2c_set_adapdata(&d->i2c_adap, d);
-
- if ((ret = i2c_add_adapter(&d->i2c_adap)) < 0)
- err("could not add i2c adapter");
-
- d->state |= DVB_USB_STATE_I2C;
-
- return ret;
-}
-
-int dvb_usb_i2c_exit(struct dvb_usb_device *d)
-{
- if (d->state & DVB_USB_STATE_I2C)
- i2c_del_adapter(&d->i2c_adap);
- d->state &= ~DVB_USB_STATE_I2C;
- return 0;
-}
-
-int dvb_usb_tuner_init_i2c(struct dvb_frontend *fe)
-{
- struct dvb_usb_device *d = fe->dvb->priv;
- struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = d->pll_init, .len = 4 };
- int ret = 0;
-
- /* if pll_desc is not used */
- if (d->pll_desc == NULL)
- return 0;
-
- if (d->tuner_pass_ctrl)
- d->tuner_pass_ctrl(fe,1,d->pll_addr);
-
- deb_pll("pll init: %x\n",d->pll_addr);
- deb_pll("pll-buf: %x %x %x %x\n",d->pll_init[0],d->pll_init[1],
- d->pll_init[2],d->pll_init[3]);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) {
- err("tuner i2c write failed for pll_init.");
- ret = -EREMOTEIO;
- }
- msleep(1);
-
- if (d->tuner_pass_ctrl)
- d->tuner_pass_ctrl(fe,0,d->pll_addr);
- return ret;
-}
-EXPORT_SYMBOL(dvb_usb_tuner_init_i2c);
-
-int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep, u8 *b, int buf_len)
-{
- struct dvb_usb_device *d = fe->dvb->priv;
-
- if (buf_len != 5)
- return -EINVAL;
- if (d->pll_desc == NULL)
- return 0;
-
- deb_pll("pll addr: %x, freq: %d %p\n",d->pll_addr,fep->frequency,d->pll_desc);
-
- b[0] = d->pll_addr;
- dvb_pll_configure(d->pll_desc,&b[1],fep->frequency,fep->u.ofdm.bandwidth);
-
- deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]);
-
- return 5;
-}
-EXPORT_SYMBOL(dvb_usb_tuner_calc_regs);
-
-int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep)
-{
- struct dvb_usb_device *d = fe->dvb->priv;
- int ret = 0;
- u8 b[5];
- struct i2c_msg msg = { .addr = d->pll_addr, .flags = 0, .buf = &b[1], .len = 4 };
-
- dvb_usb_tuner_calc_regs(fe,fep,b,5);
-
- if (d->tuner_pass_ctrl)
- d->tuner_pass_ctrl(fe,1,d->pll_addr);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) {
- err("tuner i2c write failed for pll_set.");
- ret = -EREMOTEIO;
- }
- msleep(1);
-
- if (d->tuner_pass_ctrl)
- d->tuner_pass_ctrl(fe,0,d->pll_addr);
-
- return ret;
-}
-EXPORT_SYMBOL(dvb_usb_tuner_set_params_i2c);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
deleted file mode 100644
index 95698918bc1..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* dvb-usb-ids.h is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) see
- * dvb-usb-init.c for copyright information.
- *
- * a header file containing define's for the USB device supported by the
- * various drivers.
- */
-#ifndef _DVB_USB_IDS_H_
-#define _DVB_USB_IDS_H_
-
-/* Vendor IDs */
-#define USB_VID_ADSTECH 0x06e1
-#define USB_VID_ANCHOR 0x0547
-#define USB_VID_WIDEVIEW 0x14aa
-#define USB_VID_AVERMEDIA 0x07ca
-#define USB_VID_COMPRO 0x185b
-#define USB_VID_COMPRO_UNK 0x145f
-#define USB_VID_CYPRESS 0x04b4
-#define USB_VID_DIBCOM 0x10b8
-#define USB_VID_DVICO 0x0fe9
-#define USB_VID_EMPIA 0xeb1a
-#define USB_VID_GRANDTEC 0x5032
-#define USB_VID_HANFTEK 0x15f4
-#define USB_VID_HAUPPAUGE 0x2040
-#define USB_VID_HYPER_PALTEK 0x1025
-#define USB_VID_KWORLD 0xeb2a
-#define USB_VID_KYE 0x0458
-#define USB_VID_MEDION 0x1660
-#define USB_VID_PINNACLE 0x2304
-#define USB_VID_VISIONPLUS 0x13d3
-#define USB_VID_TWINHAN 0x1822
-#define USB_VID_ULTIMA_ELECTRONIC 0x05d8
-#define USB_VID_GENPIX 0x09c0
-
-/* Product IDs */
-#define USB_PID_ADSTECH_USB2_COLD 0xa333
-#define USB_PID_ADSTECH_USB2_WARM 0xa334
-#define USB_PID_AVERMEDIA_DVBT_USB_COLD 0x0001
-#define USB_PID_AVERMEDIA_DVBT_USB_WARM 0x0002
-#define USB_PID_AVERMEDIA_DVBT_USB2_COLD 0xa800
-#define USB_PID_AVERMEDIA_DVBT_USB2_WARM 0xa801
-#define USB_PID_COMPRO_DVBU2000_COLD 0xd000
-#define USB_PID_COMPRO_DVBU2000_WARM 0xd001
-#define USB_PID_COMPRO_DVBU2000_UNK_COLD 0x010c
-#define USB_PID_COMPRO_DVBU2000_UNK_WARM 0x010d
-#define USB_PID_DIBCOM_HOOK_DEFAULT 0x0064
-#define USB_PID_DIBCOM_HOOK_DEFAULT_REENUM 0x0065
-#define USB_PID_DIBCOM_MOD3000_COLD 0x0bb8
-#define USB_PID_DIBCOM_MOD3000_WARM 0x0bb9
-#define USB_PID_DIBCOM_MOD3001_COLD 0x0bc6
-#define USB_PID_DIBCOM_MOD3001_WARM 0x0bc7
-#define USB_PID_DIBCOM_STK7700 0x1e14
-#define USB_PID_DIBCOM_STK7700_REENUM 0x1e15
-#define USB_PID_DIBCOM_ANCHOR_2135_COLD 0x2131
-#define USB_PID_GRANDTEC_DVBT_USB_COLD 0x0fa0
-#define USB_PID_GRANDTEC_DVBT_USB_WARM 0x0fa1
-#define USB_PID_KWORLD_VSTREAM_COLD 0x17de
-#define USB_PID_KWORLD_VSTREAM_WARM 0x17df
-#define USB_PID_TWINHAN_VP7041_COLD 0x3201
-#define USB_PID_TWINHAN_VP7041_WARM 0x3202
-#define USB_PID_TWINHAN_VP7020_COLD 0x3203
-#define USB_PID_TWINHAN_VP7020_WARM 0x3204
-#define USB_PID_TWINHAN_VP7045_COLD 0x3205
-#define USB_PID_TWINHAN_VP7045_WARM 0x3206
-#define USB_PID_TWINHAN_VP7021_COLD 0x3207
-#define USB_PID_TWINHAN_VP7021_WARM 0x3208
-#define USB_PID_DNTV_TINYUSB2_COLD 0x3223
-#define USB_PID_DNTV_TINYUSB2_WARM 0x3224
-#define USB_PID_ULTIMA_TVBOX_COLD 0x8105
-#define USB_PID_ULTIMA_TVBOX_WARM 0x8106
-#define USB_PID_ULTIMA_TVBOX_AN2235_COLD 0x8107
-#define USB_PID_ULTIMA_TVBOX_AN2235_WARM 0x8108
-#define USB_PID_ULTIMA_TVBOX_ANCHOR_COLD 0x2235
-#define USB_PID_ULTIMA_TVBOX_USB2_COLD 0x8109
-#define USB_PID_ULTIMA_TVBOX_USB2_WARM 0x810a
-#define USB_PID_ULTIMA_TVBOX_USB2_FX_COLD 0x8613
-#define USB_PID_ULTIMA_TVBOX_USB2_FX_WARM 0x1002
-#define USB_PID_UNK_HYPER_PALTEK_COLD 0x005e
-#define USB_PID_UNK_HYPER_PALTEK_WARM 0x005f
-#define USB_PID_HANFTEK_UMT_010_COLD 0x0001
-#define USB_PID_HANFTEK_UMT_010_WARM 0x0015
-#define USB_PID_DTT200U_COLD 0x0201
-#define USB_PID_DTT200U_WARM 0x0301
-#define USB_PID_WT220U_COLD 0x0222
-#define USB_PID_WT220U_WARM 0x0221
-#define USB_PID_WT220U_ZL0353_COLD 0x022a
-#define USB_PID_WT220U_ZL0353_WARM 0x022b
-#define USB_PID_WINTV_NOVA_T_USB2_COLD 0x9300
-#define USB_PID_WINTV_NOVA_T_USB2_WARM 0x9301
-#define USB_PID_NEBULA_DIGITV 0x0201
-#define USB_PID_DVICO_BLUEBIRD_LGDT 0xd820
-#define USB_PID_DVICO_BLUEBIRD_LG064F_COLD 0xd500
-#define USB_PID_DVICO_BLUEBIRD_LG064F_WARM 0xd501
-#define USB_PID_DVICO_BLUEBIRD_LGZ201_COLD 0xdb00
-#define USB_PID_DVICO_BLUEBIRD_LGZ201_WARM 0xdb01
-#define USB_PID_DVICO_BLUEBIRD_TH7579_COLD 0xdb10
-#define USB_PID_DVICO_BLUEBIRD_TH7579_WARM 0xdb11
-#define USB_PID_DVICO_BLUEBIRD_DEE1601_COLD 0xdb50
-#define USB_PID_DVICO_BLUEBIRD_DEE1601_WARM 0xdb51
-#define USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_COLD 0xdb54
-#define USB_PID_DIGITALNOW_BLUEBIRD_DEE1601_WARM 0xdb55
-#define USB_PID_MEDION_MD95700 0x0932
-#define USB_PID_KYE_DVB_T_COLD 0x701e
-#define USB_PID_KYE_DVB_T_WARM 0x701f
-#define USB_PID_PCTV_200E 0x020e
-#define USB_PID_PCTV_400E 0x020f
-#define USB_PID_GENPIX_8PSK_COLD 0x0200
-#define USB_PID_GENPIX_8PSK_WARM 0x0201
-#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
deleted file mode 100644
index a1705ecb9a5..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * DVB USB library - provides a generic interface for a DVB USB device driver.
- *
- * dvb-usb-init.c
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dvb-usb-common.h"
-
-/* debug */
-int dvb_usb_debug;
-module_param_named(debug,dvb_usb_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." DVB_USB_DEBUG_STATUS);
-
-int dvb_usb_disable_rc_polling;
-module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
-MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0).");
-
-/* general initialization functions */
-static int dvb_usb_exit(struct dvb_usb_device *d)
-{
- deb_info("state before exiting everything: %x\n",d->state);
- dvb_usb_remote_exit(d);
- dvb_usb_fe_exit(d);
- dvb_usb_i2c_exit(d);
- dvb_usb_dvb_exit(d);
- dvb_usb_urb_exit(d);
- deb_info("state should be zero now: %x\n",d->state);
- d->state = DVB_USB_STATE_INIT;
- kfree(d->priv);
- kfree(d);
- return 0;
-}
-
-static int dvb_usb_init(struct dvb_usb_device *d)
-{
- int ret = 0;
-
- mutex_init(&d->usb_mutex);
- mutex_init(&d->i2c_mutex);
-
- d->state = DVB_USB_STATE_INIT;
-
-/* check the capabilities and set appropriate variables */
-
-/* speed - when running at FULL speed we need a HW PID filter */
- if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) {
- err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)");
- return -ENODEV;
- }
-
- if ((d->udev->speed == USB_SPEED_FULL && d->props.caps & DVB_USB_HAS_PID_FILTER) ||
- (d->props.caps & DVB_USB_NEED_PID_FILTERING)) {
- info("will use the device's hardware PID filter (table count: %d).",d->props.pid_filter_count);
- d->pid_filtering = 1;
- d->max_feed_count = d->props.pid_filter_count;
- } else {
- info("will pass the complete MPEG2 transport stream to the software demuxer.");
- d->pid_filtering = 0;
- d->max_feed_count = 255;
- }
-
- if (d->props.power_ctrl)
- d->props.power_ctrl(d,1);
-
- if ((ret = dvb_usb_urb_init(d)) ||
- (ret = dvb_usb_dvb_init(d)) ||
- (ret = dvb_usb_i2c_init(d)) ||
- (ret = dvb_usb_fe_init(d))) {
- dvb_usb_exit(d);
- return ret;
- }
-
- if ((ret = dvb_usb_remote_init(d)))
- err("could not initialize remote control.");
-
- if (d->props.power_ctrl)
- d->props.power_ctrl(d,0);
-
- return 0;
-}
-
-/* determine the name and the state of the just found USB device */
-static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device *udev,struct dvb_usb_properties *props, int *cold)
-{
- int i,j;
- struct dvb_usb_device_description *desc = NULL;
- *cold = -1;
-
- for (i = 0; i < props->num_device_descs; i++) {
-
- for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].cold_ids[j] != NULL; j++) {
- deb_info("check for cold %x %x\n",props->devices[i].cold_ids[j]->idVendor, props->devices[i].cold_ids[j]->idProduct);
- if (props->devices[i].cold_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) &&
- props->devices[i].cold_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) {
- *cold = 1;
- desc = &props->devices[i];
- break;
- }
- }
-
- if (desc != NULL)
- break;
-
- for (j = 0; j < DVB_USB_ID_MAX_NUM && props->devices[i].warm_ids[j] != NULL; j++) {
- deb_info("check for warm %x %x\n",props->devices[i].warm_ids[j]->idVendor, props->devices[i].warm_ids[j]->idProduct);
- if (props->devices[i].warm_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) &&
- props->devices[i].warm_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) {
- *cold = 0;
- desc = &props->devices[i];
- break;
- }
- }
- }
-
- if (desc != NULL && props->identify_state != NULL)
- props->identify_state(udev,props,&desc,cold);
-
- return desc;
-}
-
-/*
- * USB
- */
-
-int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
- *props, struct module *owner,struct dvb_usb_device **du)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
- struct dvb_usb_device *d = NULL;
- struct dvb_usb_device_description *desc = NULL;
-
- int ret = -ENOMEM,cold=0;
-
- if (du != NULL)
- *du = NULL;
-
- if ((desc = dvb_usb_find_device(udev,props,&cold)) == NULL) {
- deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n");
- return -ENODEV;
- }
-
- if (cold) {
- info("found a '%s' in cold state, will try to load a firmware",desc->name);
- ret = dvb_usb_download_firmware(udev,props);
- if (!props->no_reconnect)
- return ret;
- }
-
- info("found a '%s' in warm state.",desc->name);
- d = kzalloc(sizeof(struct dvb_usb_device),GFP_KERNEL);
- if (d == NULL) {
- err("no memory for 'struct dvb_usb_device'");
- return ret;
- }
-
- d->udev = udev;
- memcpy(&d->props,props,sizeof(struct dvb_usb_properties));
- d->desc = desc;
- d->owner = owner;
-
- if (d->props.size_of_priv > 0) {
- d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL);
- if (d->priv == NULL) {
- err("no memory for priv in 'struct dvb_usb_device'");
- kfree(d);
- return -ENOMEM;
- }
- }
-
- usb_set_intfdata(intf, d);
-
- if (du != NULL)
- *du = d;
-
- ret = dvb_usb_init(d);
-
- if (ret == 0)
- info("%s successfully initialized and connected.",desc->name);
- else
- info("%s error while loading driver (%d)",desc->name,ret);
- return ret;
-}
-EXPORT_SYMBOL(dvb_usb_device_init);
-
-void dvb_usb_device_exit(struct usb_interface *intf)
-{
- struct dvb_usb_device *d = usb_get_intfdata(intf);
- const char *name = "generic DVB-USB module";
-
- usb_set_intfdata(intf,NULL);
- if (d != NULL && d->desc != NULL) {
- name = d->desc->name;
- dvb_usb_exit(d);
- }
- info("%s successfully deinitialized and disconnected.",name);
-
-}
-EXPORT_SYMBOL(dvb_usb_device_exit);
-
-MODULE_VERSION("0.3");
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c b/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
deleted file mode 100644
index e5c6d9835e0..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-remote.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* dvb-usb-remote.c is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- * see dvb-usb-init.c for copyright information.
- *
- * This file contains functions for initializing the the input-device and for handling remote-control-queries.
- */
-#include "dvb-usb-common.h"
-
-/* Remote-control poll function - called every dib->rc_query_interval ms to see
- * whether the remote control has received anything.
- *
- * TODO: Fix the repeat rate of the input device.
- */
-static void dvb_usb_read_remote_control(void *data)
-{
- struct dvb_usb_device *d = data;
- u32 event;
- int state;
-
- /* TODO: need a lock here. We can simply skip checking for the remote control
- if we're busy. */
-
- /* when the parameter has been set to 1 via sysfs while the driver was running */
- if (dvb_usb_disable_rc_polling)
- return;
-
- if (d->props.rc_query(d,&event,&state)) {
- err("error while querying for an remote control event.");
- goto schedule;
- }
-
-
- switch (state) {
- case REMOTE_NO_KEY_PRESSED:
- break;
- case REMOTE_KEY_PRESSED:
- deb_rc("key pressed\n");
- d->last_event = event;
- case REMOTE_KEY_REPEAT:
- deb_rc("key repeated\n");
- input_event(d->rc_input_dev, EV_KEY, event, 1);
- input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
- input_sync(d->rc_input_dev);
- break;
- default:
- break;
- }
-
-/* improved repeat handling ???
- switch (state) {
- case REMOTE_NO_KEY_PRESSED:
- deb_rc("NO KEY PRESSED\n");
- if (d->last_state != REMOTE_NO_KEY_PRESSED) {
- deb_rc("releasing event %d\n",d->last_event);
- input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
- input_sync(d->rc_input_dev);
- }
- d->last_state = REMOTE_NO_KEY_PRESSED;
- d->last_event = 0;
- break;
- case REMOTE_KEY_PRESSED:
- deb_rc("KEY PRESSED\n");
- deb_rc("pressing event %d\n",event);
-
- input_event(d->rc_input_dev, EV_KEY, event, 1);
- input_sync(d->rc_input_dev);
-
- d->last_event = event;
- d->last_state = REMOTE_KEY_PRESSED;
- break;
- case REMOTE_KEY_REPEAT:
- deb_rc("KEY_REPEAT\n");
- if (d->last_state != REMOTE_NO_KEY_PRESSED) {
- deb_rc("repeating event %d\n",d->last_event);
- input_event(d->rc_input_dev, EV_KEY, d->last_event, 2);
- input_sync(d->rc_input_dev);
- d->last_state = REMOTE_KEY_REPEAT;
- }
- default:
- break;
- }
-*/
-
-schedule:
- schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval));
-}
-
-int dvb_usb_remote_init(struct dvb_usb_device *d)
-{
- int i;
-
- if (d->props.rc_key_map == NULL ||
- d->props.rc_query == NULL ||
- dvb_usb_disable_rc_polling)
- return 0;
-
- usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
- strlcpy(d->rc_phys, "/ir0", sizeof(d->rc_phys));
-
- d->rc_input_dev = input_allocate_device();
- if (!d->rc_input_dev)
- return -ENOMEM;
-
- d->rc_input_dev->evbit[0] = BIT(EV_KEY);
- d->rc_input_dev->keycodesize = sizeof(unsigned char);
- d->rc_input_dev->keycodemax = KEY_MAX;
- d->rc_input_dev->name = "IR-receiver inside an USB DVB receiver";
- d->rc_input_dev->phys = d->rc_phys;
-
- /* set the bits for the keys */
- deb_rc("key map size: %d\n", d->props.rc_key_map_size);
- for (i = 0; i < d->props.rc_key_map_size; i++) {
- deb_rc("setting bit for event %d item %d\n",d->props.rc_key_map[i].event, i);
- set_bit(d->props.rc_key_map[i].event, d->rc_input_dev->keybit);
- }
-
- /* Start the remote-control polling. */
- if (d->props.rc_interval < 40)
- d->props.rc_interval = 100; /* default */
-
- /* setting these two values to non-zero, we have to manage key repeats */
- d->rc_input_dev->rep[REP_PERIOD] = d->props.rc_interval;
- d->rc_input_dev->rep[REP_DELAY] = d->props.rc_interval + 150;
-
- input_register_device(d->rc_input_dev);
-
- INIT_WORK(&d->rc_query_work, dvb_usb_read_remote_control, d);
-
- info("schedule remote query interval to %d msecs.", d->props.rc_interval);
- schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval));
-
- d->state |= DVB_USB_STATE_REMOTE;
-
- return 0;
-}
-
-int dvb_usb_remote_exit(struct dvb_usb_device *d)
-{
- if (d->state & DVB_USB_STATE_REMOTE) {
- cancel_delayed_work(&d->rc_query_work);
- flush_scheduled_work();
- input_unregister_device(d->rc_input_dev);
- }
- d->state &= ~DVB_USB_STATE_REMOTE;
- return 0;
-}
-
-#define DVB_USB_RC_NEC_EMPTY 0x00
-#define DVB_USB_RC_NEC_KEY_PRESSED 0x01
-#define DVB_USB_RC_NEC_KEY_REPEATED 0x02
-int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *d,
- u8 keybuf[5], u32 *event, int *state)
-{
- int i;
- struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
- *event = 0;
- *state = REMOTE_NO_KEY_PRESSED;
- switch (keybuf[0]) {
- case DVB_USB_RC_NEC_EMPTY:
- break;
- case DVB_USB_RC_NEC_KEY_PRESSED:
- if ((u8) ~keybuf[1] != keybuf[2] ||
- (u8) ~keybuf[3] != keybuf[4]) {
- deb_err("remote control checksum failed.\n");
- break;
- }
- /* See if we can match the raw key code. */
- for (i = 0; i < d->props.rc_key_map_size; i++)
- if (keymap[i].custom == keybuf[1] &&
- keymap[i].data == keybuf[3]) {
- *event = keymap[i].event;
- *state = REMOTE_KEY_PRESSED;
- return 0;
- }
- deb_err("key mapping failed - no appropriate key found in keymapping\n");
- break;
- case DVB_USB_RC_NEC_KEY_REPEATED:
- *state = REMOTE_KEY_REPEAT;
- break;
- default:
- deb_err("unkown type of remote status: %d\n",keybuf[0]);
- break;
- }
- return 0;
-}
-EXPORT_SYMBOL(dvb_usb_nec_rc_key_to_event);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
deleted file mode 100644
index 9002f35aa95..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/* dvb-usb-urb.c is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- * see dvb-usb-init.c for copyright information.
- *
- * This file contains functions for initializing and handling the
- * USB and URB stuff.
- */
-#include "dvb-usb-common.h"
-
-int dvb_usb_generic_rw(struct dvb_usb_device *d, u8 *wbuf, u16 wlen, u8 *rbuf,
- u16 rlen, int delay_ms)
-{
- int actlen,ret = -ENOMEM;
-
- if (d->props.generic_bulk_ctrl_endpoint == 0) {
- err("endpoint for generic control not specified.");
- return -EINVAL;
- }
-
- if (wbuf == NULL || wlen == 0)
- return -EINVAL;
-
- if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
- return ret;
-
- deb_xfer(">>> ");
- debug_dump(wbuf,wlen,deb_xfer);
-
- ret = usb_bulk_msg(d->udev,usb_sndbulkpipe(d->udev,
- d->props.generic_bulk_ctrl_endpoint), wbuf,wlen,&actlen,
- 2000);
-
- if (ret)
- err("bulk message failed: %d (%d/%d)",ret,wlen,actlen);
- else
- ret = actlen != wlen ? -1 : 0;
-
- /* an answer is expected, and no error before */
- if (!ret && rbuf && rlen) {
- if (delay_ms)
- msleep(delay_ms);
-
- ret = usb_bulk_msg(d->udev,usb_rcvbulkpipe(d->udev,
- d->props.generic_bulk_ctrl_endpoint),rbuf,rlen,&actlen,
- 2000);
-
- if (ret)
- err("recv bulk message failed: %d",ret);
- else {
- deb_xfer("<<< ");
- debug_dump(rbuf,actlen,deb_xfer);
- }
- }
-
- mutex_unlock(&d->usb_mutex);
- return ret;
-}
-EXPORT_SYMBOL(dvb_usb_generic_rw);
-
-int dvb_usb_generic_write(struct dvb_usb_device *d, u8 *buf, u16 len)
-{
- return dvb_usb_generic_rw(d,buf,len,NULL,0,0);
-}
-EXPORT_SYMBOL(dvb_usb_generic_write);
-
-
-/* URB stuff for streaming */
-static void dvb_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
-{
- struct dvb_usb_device *d = urb->context;
- int ptype = usb_pipetype(urb->pipe);
- int i;
- u8 *b;
-
- deb_ts("'%s' urb completed. feedcount: %d, status: %d, length: %d/%d, pack_num: %d, errors: %d\n",
- ptype == PIPE_ISOCHRONOUS ? "isoc" : "bulk", d->feedcount,
- urb->status,urb->actual_length,urb->transfer_buffer_length,
- urb->number_of_packets,urb->error_count);
-
- switch (urb->status) {
- case 0: /* success */
- case -ETIMEDOUT: /* NAK */
- break;
- case -ECONNRESET: /* kill */
- case -ENOENT:
- case -ESHUTDOWN:
- return;
- default: /* error */
- deb_ts("urb completition error %d.", urb->status);
- break;
- }
-
- if (d->feedcount > 0) {
- if (d->state & DVB_USB_STATE_DVB) {
- switch (ptype) {
- case PIPE_ISOCHRONOUS:
- b = (u8 *) urb->transfer_buffer;
- for (i = 0; i < urb->number_of_packets; i++) {
- if (urb->iso_frame_desc[i].status != 0)
- deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status);
- else if (urb->iso_frame_desc[i].actual_length > 0) {
- dvb_dmx_swfilter(&d->demux,b + urb->iso_frame_desc[i].offset,
- urb->iso_frame_desc[i].actual_length);
- }
- urb->iso_frame_desc[i].status = 0;
- urb->iso_frame_desc[i].actual_length = 0;
- }
- debug_dump(b,20,deb_ts);
- break;
- case PIPE_BULK:
- if (urb->actual_length > 0)
- dvb_dmx_swfilter(&d->demux, (u8 *) urb->transfer_buffer,urb->actual_length);
- break;
- default:
- err("unkown endpoint type in completition handler.");
- return;
- }
- }
- }
-
- usb_submit_urb(urb,GFP_ATOMIC);
-}
-
-int dvb_usb_urb_kill(struct dvb_usb_device *d)
-{
- int i;
- for (i = 0; i < d->urbs_submitted; i++) {
- deb_ts("killing URB no. %d.\n",i);
-
- /* stop the URB */
- usb_kill_urb(d->urb_list[i]);
- }
- d->urbs_submitted = 0;
- return 0;
-}
-
-int dvb_usb_urb_submit(struct dvb_usb_device *d)
-{
- int i,ret;
- for (i = 0; i < d->urbs_initialized; i++) {
- deb_ts("submitting URB no. %d\n",i);
- if ((ret = usb_submit_urb(d->urb_list[i],GFP_ATOMIC))) {
- err("could not submit URB no. %d - get them all back",i);
- dvb_usb_urb_kill(d);
- return ret;
- }
- d->urbs_submitted++;
- }
- return 0;
-}
-
-static int dvb_usb_free_stream_buffers(struct dvb_usb_device *d)
-{
- if (d->state & DVB_USB_STATE_URB_BUF) {
- while (d->buf_num) {
- d->buf_num--;
- deb_mem("freeing buffer %d\n",d->buf_num);
- usb_buffer_free(d->udev, d->buf_size,
- d->buf_list[d->buf_num], d->dma_addr[d->buf_num]);
- }
- kfree(d->buf_list);
- kfree(d->dma_addr);
- }
-
- d->state &= ~DVB_USB_STATE_URB_BUF;
-
- return 0;
-}
-
-static int dvb_usb_allocate_stream_buffers(struct dvb_usb_device *d, int num, unsigned long size)
-{
- d->buf_num = 0;
- d->buf_size = size;
-
- deb_mem("all in all I will use %lu bytes for streaming\n",num*size);
-
- if ((d->buf_list = kcalloc(num, sizeof(u8 *), GFP_ATOMIC)) == NULL)
- return -ENOMEM;
-
- if ((d->dma_addr = kcalloc(num, sizeof(dma_addr_t), GFP_ATOMIC)) == NULL) {
- kfree(d->buf_list);
- return -ENOMEM;
- }
-
- d->state |= DVB_USB_STATE_URB_BUF;
-
- for (d->buf_num = 0; d->buf_num < num; d->buf_num++) {
- deb_mem("allocating buffer %d\n",d->buf_num);
- if (( d->buf_list[d->buf_num] =
- usb_buffer_alloc(d->udev, size, SLAB_ATOMIC,
- &d->dma_addr[d->buf_num]) ) == NULL) {
- deb_mem("not enough memory for urb-buffer allocation.\n");
- dvb_usb_free_stream_buffers(d);
- return -ENOMEM;
- }
- deb_mem("buffer %d: %p (dma: %llu)\n",
- d->buf_num, d->buf_list[d->buf_num],
- (unsigned long long)d->dma_addr[d->buf_num]);
- memset(d->buf_list[d->buf_num],0,size);
- }
- deb_mem("allocation successful\n");
-
- return 0;
-}
-
-static int dvb_usb_bulk_urb_init(struct dvb_usb_device *d)
-{
- int i;
-
- if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count,
- d->props.urb.u.bulk.buffersize)) < 0)
- return i;
-
- /* allocate the URBs */
- for (i = 0; i < d->props.urb.count; i++) {
- if ((d->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC)) == NULL)
- return -ENOMEM;
-
- usb_fill_bulk_urb( d->urb_list[i], d->udev,
- usb_rcvbulkpipe(d->udev,d->props.urb.endpoint),
- d->buf_list[i],
- d->props.urb.u.bulk.buffersize,
- dvb_usb_urb_complete, d);
-
- d->urb_list[i]->transfer_flags = 0;
- d->urbs_initialized++;
- }
- return 0;
-}
-
-static int dvb_usb_isoc_urb_init(struct dvb_usb_device *d)
-{
- int i,j;
-
- if ((i = dvb_usb_allocate_stream_buffers(d,d->props.urb.count,
- d->props.urb.u.isoc.framesize*d->props.urb.u.isoc.framesperurb)) < 0)
- return i;
-
- /* allocate the URBs */
- for (i = 0; i < d->props.urb.count; i++) {
- struct urb *urb;
- int frame_offset = 0;
- if ((d->urb_list[i] =
- usb_alloc_urb(d->props.urb.u.isoc.framesperurb,GFP_ATOMIC)) == NULL)
- return -ENOMEM;
-
- urb = d->urb_list[i];
-
- urb->dev = d->udev;
- urb->context = d;
- urb->complete = dvb_usb_urb_complete;
- urb->pipe = usb_rcvisocpipe(d->udev,d->props.urb.endpoint);
- urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
- urb->interval = d->props.urb.u.isoc.interval;
- urb->number_of_packets = d->props.urb.u.isoc.framesperurb;
- urb->transfer_buffer_length = d->buf_size;
- urb->transfer_buffer = d->buf_list[i];
- urb->transfer_dma = d->dma_addr[i];
-
- for (j = 0; j < d->props.urb.u.isoc.framesperurb; j++) {
- urb->iso_frame_desc[j].offset = frame_offset;
- urb->iso_frame_desc[j].length = d->props.urb.u.isoc.framesize;
- frame_offset += d->props.urb.u.isoc.framesize;
- }
-
- d->urbs_initialized++;
- }
- return 0;
-
-}
-
-int dvb_usb_urb_init(struct dvb_usb_device *d)
-{
- /*
- * when reloading the driver w/o replugging the device
- * sometimes a timeout occures, this helps
- */
- if (d->props.generic_bulk_ctrl_endpoint != 0) {
- usb_clear_halt(d->udev,usb_sndbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
- usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
- }
- usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.urb.endpoint));
-
- /* allocate the array for the data transfer URBs */
- d->urb_list = kzalloc(d->props.urb.count * sizeof(struct urb *),GFP_KERNEL);
- if (d->urb_list == NULL)
- return -ENOMEM;
- d->state |= DVB_USB_STATE_URB_LIST;
-
- switch (d->props.urb.type) {
- case DVB_USB_BULK:
- return dvb_usb_bulk_urb_init(d);
- case DVB_USB_ISOC:
- return dvb_usb_isoc_urb_init(d);
- default:
- err("unkown URB-type for data transfer.");
- return -EINVAL;
- }
-}
-
-int dvb_usb_urb_exit(struct dvb_usb_device *d)
-{
- int i;
-
- dvb_usb_urb_kill(d);
-
- if (d->state & DVB_USB_STATE_URB_LIST) {
- for (i = 0; i < d->urbs_initialized; i++) {
- if (d->urb_list[i] != NULL) {
- deb_mem("freeing URB no. %d.\n",i);
- /* free the URBs */
- usb_free_urb(d->urb_list[i]);
- }
- }
- d->urbs_initialized = 0;
- /* free the urb array */
- kfree(d->urb_list);
- d->state &= ~DVB_USB_STATE_URB_LIST;
- }
-
- dvb_usb_free_stream_buffers(d);
- return 0;
-}
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
deleted file mode 100644
index 97f8ea96243..00000000000
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ /dev/null
@@ -1,346 +0,0 @@
-/* dvb-usb.h is part of the DVB USB library.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- * see dvb-usb-init.c for copyright information.
- *
- * the headerfile, all dvb-usb-drivers have to include.
- */
-#ifndef __DVB_USB_H__
-#define __DVB_USB_H__
-
-#include <linux/input.h>
-#include <linux/usb.h>
-#include <linux/firmware.h>
-#include <linux/mutex.h>
-
-#include "dvb_frontend.h"
-#include "dvb_demux.h"
-#include "dvb_net.h"
-#include "dmxdev.h"
-
-#include "dvb-pll.h"
-
-#include "dvb-usb-ids.h"
-
-/* debug */
-#ifdef CONFIG_DVB_USB_DEBUG
-#define dprintk(var,level,args...) \
- do { if ((var & level)) { printk(args); } } while (0)
-
-#define debug_dump(b,l,func) {\
- int loop_; \
- for (loop_ = 0; loop_ < l; loop_++) func("%02x ", b[loop_]); \
- func("\n");\
-}
-#define DVB_USB_DEBUG_STATUS
-#else
-#define dprintk(args...)
-#define debug_dump(b,l,func)
-
-#define DVB_USB_DEBUG_STATUS " (debugging is not enabled)"
-
-#endif
-
-/* generic log methods - taken from usb.h */
-#ifndef DVB_USB_LOG_PREFIX
- #define DVB_USB_LOG_PREFIX "dvb-usb (please define a log prefix)"
-#endif
-
-#undef err
-#define err(format, arg...) printk(KERN_ERR DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
-#undef info
-#define info(format, arg...) printk(KERN_INFO DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
-#undef warn
-#define warn(format, arg...) printk(KERN_WARNING DVB_USB_LOG_PREFIX ": " format "\n" , ## arg)
-
-/**
- * struct dvb_usb_device_description - name and its according USB IDs
- * @name: real name of the box, regardless which DVB USB device class is in use
- * @cold_ids: array of struct usb_device_id which describe the device in
- * pre-firmware state
- * @warm_ids: array of struct usb_device_id which describe the device in
- * post-firmware state
- *
- * Each DVB USB device class can have one or more actual devices, this struct
- * assigns a name to it.
- */
-struct dvb_usb_device_description {
- const char *name;
-
-#define DVB_USB_ID_MAX_NUM 15
- struct usb_device_id *cold_ids[DVB_USB_ID_MAX_NUM];
- struct usb_device_id *warm_ids[DVB_USB_ID_MAX_NUM];
-};
-
-/**
- * struct dvb_usb_rc_key - a remote control key and its input-event
- * @custom: the vendor/custom part of the key
- * @data: the actual key part
- * @event: the input event assigned to key identified by custom and data
- */
-struct dvb_usb_rc_key {
- u8 custom,data;
- u32 event;
-};
-
-struct dvb_usb_device;
-
-/**
- * struct dvb_usb_properties - properties of a dvb-usb-device
- * @caps: capabilities of the DVB USB device.
- * @pid_filter_count: number of PID filter position in the optional hardware
- * PID-filter.
- *
- * @usb_ctrl: which USB device-side controller is in use. Needed for firmware
- * download.
- * @firmware: name of the firmware file.
- * @download_firmware: called to download the firmware when the usb_ctrl is
- * DEVICE_SPECIFIC.
- * @no_reconnect: device doesn't do a reconnect after downloading the firmware,
- so do the warm initialization right after it
-
- * @size_of_priv: how many bytes shall be allocated for the private field
- * of struct dvb_usb_device.
- *
- * @power_ctrl: called to enable/disable power of the device.
- * @streaming_crtl: called to start and stop the MPEG2-TS streaming of the
- * device (not URB submitting/killing).
- * @pid_filter_ctrl: called to en/disable the PID filter, if any.
- * @pid_filter: called to set/unset a PID for filtering.
- *
- * @read_mac_address: called to read the MAC address of the device.
- *
- * @frontend_attach: called to attach the possible frontends (fill fe-field
- * of struct dvb_usb_device).
- * @tuner_attach: called to attach the correct tuner and to fill pll_addr,
- * pll_desc and pll_init_buf of struct dvb_usb_device).
- * @identify_state: called to determine the state (cold or warm), when it
- * is not distinguishable by the USB IDs.
- *
- * @rc_key_map: a hard-wired array of struct dvb_usb_rc_key (NULL to disable
- * remote control handling).
- * @rc_key_map_size: number of items in @rc_key_map.
- * @rc_query: called to query an event event.
- * @rc_interval: time in ms between two queries.
- *
- * @i2c_algo: i2c_algorithm if the device has I2CoverUSB.
- *
- * @generic_bulk_ctrl_endpoint: most of the DVB USB devices have a generic
- * endpoint which received control messages with bulk transfers. When this
- * is non-zero, one can use dvb_usb_generic_rw and dvb_usb_generic_write-
- * helper functions.
- *
- * @urb: describes the kind of USB transfer used for MPEG2-TS-streaming.
- * (BULK or ISOC)
- *
- * @num_device_descs: number of struct dvb_usb_device_description in @devices
- * @devices: array of struct dvb_usb_device_description compatibles with these
- * properties.
- */
-struct dvb_usb_properties {
-
-#define DVB_USB_HAS_PID_FILTER 0x01
-#define DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF 0x02
-#define DVB_USB_NEED_PID_FILTERING 0x04
-#define DVB_USB_IS_AN_I2C_ADAPTER 0x08
- int caps;
- int pid_filter_count;
-
-#define DEVICE_SPECIFIC 0
-#define CYPRESS_AN2135 1
-#define CYPRESS_AN2235 2
-#define CYPRESS_FX2 3
- int usb_ctrl;
- const char firmware[FIRMWARE_NAME_MAX];
- int (*download_firmware) (struct usb_device *, const struct firmware *);
- int no_reconnect;
-
- int size_of_priv;
-
- int (*power_ctrl) (struct dvb_usb_device *, int);
- int (*streaming_ctrl) (struct dvb_usb_device *, int);
- int (*pid_filter_ctrl) (struct dvb_usb_device *, int);
- int (*pid_filter) (struct dvb_usb_device *, int, u16, int);
-
- int (*read_mac_address) (struct dvb_usb_device *, u8 []);
- int (*frontend_attach) (struct dvb_usb_device *);
- int (*tuner_attach) (struct dvb_usb_device *);
-
- int (*identify_state) (struct usb_device *, struct dvb_usb_properties *,
- struct dvb_usb_device_description **, int *);
-
-/* remote control properties */
-#define REMOTE_NO_KEY_PRESSED 0x00
-#define REMOTE_KEY_PRESSED 0x01
-#define REMOTE_KEY_REPEAT 0x02
- struct dvb_usb_rc_key *rc_key_map;
- int rc_key_map_size;
- int (*rc_query) (struct dvb_usb_device *, u32 *, int *);
- int rc_interval;
-
- struct i2c_algorithm *i2c_algo;
-
- int generic_bulk_ctrl_endpoint;
-
- struct {
-#define DVB_USB_BULK 1
-#define DVB_USB_ISOC 2
- int type;
- int count;
- int endpoint;
-
- union {
- struct {
- int buffersize; /* per URB */
- } bulk;
- struct {
- int framesperurb;
- int framesize;
- int interval;
- } isoc;
- } u;
- } urb;
-
- int num_device_descs;
- struct dvb_usb_device_description devices[9];
-};
-
-
-/**
- * struct dvb_usb_device - object of a DVB USB device
- * @props: copy of the struct dvb_usb_properties this device belongs to.
- * @desc: pointer to the device's struct dvb_usb_device_description.
- * @state: initialization and runtime state of the device.
- *
- * @udev: pointer to the device's struct usb_device.
- * @urb_list: array of dynamically allocated struct urb for the MPEG2-TS-
- * streaming.
- *
- * @buf_num: number of buffer allocated.
- * @buf_size: size of each buffer in buf_list.
- * @buf_list: array containing all allocate buffers for streaming.
- * @dma_addr: list of dma_addr_t for each buffer in buf_list.
- *
- * @urbs_initialized: number of URBs initialized.
- * @urbs_submitted: number of URBs submitted.
- *
- * @feedcount: number of reqested feeds (used for streaming-activation)
- * @pid_filtering: is hardware pid_filtering used or not.
- *
- * @usb_mutex: semaphore of USB control messages (reading needs two messages)
- * @i2c_mutex: semaphore for i2c-transfers
- *
- * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB
- * @pll_addr: I2C address of the tuner for programming
- * @pll_init: array containing the initialization buffer
- * @pll_desc: pointer to the appropriate struct dvb_pll_desc
- *
- * @tuner_pass_ctrl: called to (de)activate tuner passthru of the demod or the board
- *
- * @dvb_adap: device's dvb_adapter.
- * @dmxdev: device's dmxdev.
- * @demux: device's software demuxer.
- * @dvb_net: device's dvb_net interfaces.
- * @dvb_frontend: device's frontend.
- * @max_feed_count: how many feeds can be handled simultaneously by this
- * device
- * @fe_sleep: rerouted frontend-sleep function.
- * @fe_init: rerouted frontend-init (wakeup) function.
- * @rc_input_dev: input device for the remote control.
- * @rc_query_work: struct work_struct frequent rc queries
- * @last_event: last triggered event
- * @last_state: last state (no, pressed, repeat)
- * @owner: owner of the dvb_adapter
- * @priv: private data of the actual driver (allocate by dvb-usb, size defined
- * in size_of_priv of dvb_usb_properties).
- */
-struct dvb_usb_device {
- struct dvb_usb_properties props;
- struct dvb_usb_device_description *desc;
-
-#define DVB_USB_STATE_INIT 0x000
-#define DVB_USB_STATE_URB_LIST 0x001
-#define DVB_USB_STATE_URB_BUF 0x002
-#define DVB_USB_STATE_DVB 0x004
-#define DVB_USB_STATE_I2C 0x008
-#define DVB_USB_STATE_REMOTE 0x010
-#define DVB_USB_STATE_URB_SUBMIT 0x020
- int state;
-
- /* usb */
- struct usb_device *udev;
- struct urb **urb_list;
-
- int buf_num;
- unsigned long buf_size;
- u8 **buf_list;
- dma_addr_t *dma_addr;
-
- int urbs_initialized;
- int urbs_submitted;
-
- int feedcount;
- int pid_filtering;
-
- /* locking */
- struct mutex usb_mutex;
-
- /* i2c */
- struct mutex i2c_mutex;
- struct i2c_adapter i2c_adap;
-
- /* tuner programming information */
- u8 pll_addr;
- u8 pll_init[4];
- struct dvb_pll_desc *pll_desc;
- int (*tuner_pass_ctrl)(struct dvb_frontend *, int, u8);
-
- /* dvb */
- struct dvb_adapter dvb_adap;
- struct dmxdev dmxdev;
- struct dvb_demux demux;
- struct dvb_net dvb_net;
- struct dvb_frontend* fe;
- int max_feed_count;
-
- int (*fe_sleep) (struct dvb_frontend *);
- int (*fe_init) (struct dvb_frontend *);
-
- /* remote control */
- struct input_dev *rc_input_dev;
- char rc_phys[64];
- struct work_struct rc_query_work;
- u32 last_event;
- int last_state;
-
- struct module *owner;
-
- void *priv;
-};
-
-extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_properties *, struct module *, struct dvb_usb_device **);
-extern void dvb_usb_device_exit(struct usb_interface *);
-
-/* the generic read/write method for device control */
-extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int);
-extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);
-
-/* commonly used remote control parsing */
-extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *);
-
-/* commonly used pll init and set functions */
-extern int dvb_usb_tuner_init_i2c(struct dvb_frontend *);
-extern int dvb_usb_tuner_calc_regs(struct dvb_frontend *, struct dvb_frontend_parameters *, u8 *buf, int buf_len);
-extern int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *, struct dvb_frontend_parameters *);
-
-/* commonly used firmware download types and function */
-struct hexline {
- u8 len;
- u32 addr;
- u8 type;
- u8 data[255];
- u8 chk;
-};
-extern int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type);
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/gp8psk-fe.c b/drivers/media/dvb/dvb-usb/gp8psk-fe.c
deleted file mode 100644
index 6ccbdc9cd77..00000000000
--- a/drivers/media/dvb/dvb-usb/gp8psk-fe.c
+++ /dev/null
@@ -1,272 +0,0 @@
-/* DVB USB compliant Linux driver for the
- * - GENPIX 8pks/qpsk USB2.0 DVB-S module
- *
- * Copyright (C) 2006 Alan Nisota (alannisota@gmail.com)
- *
- * Thanks to GENPIX for the sample code used to implement this module.
- *
- * This module is based off the vp7045 and vp702x modules
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "gp8psk.h"
-
-struct gp8psk_fe_state {
- struct dvb_frontend fe;
-
- struct dvb_usb_device *d;
-
- u16 snr;
-
- unsigned long next_snr_check;
-};
-
-static int gp8psk_fe_read_status(struct dvb_frontend* fe, fe_status_t *status)
-{
- struct gp8psk_fe_state *st = fe->demodulator_priv;
- u8 lock;
-
- if (gp8psk_usb_in_op(st->d, GET_SIGNAL_LOCK, 0, 0, &lock,1))
- return -EINVAL;
-
- if (lock)
- *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER;
- else
- *status = 0;
-
- return 0;
-}
-
-/* not supported by this Frontend */
-static int gp8psk_fe_read_ber(struct dvb_frontend* fe, u32 *ber)
-{
- (void) fe;
- *ber = 0;
- return 0;
-}
-
-/* not supported by this Frontend */
-static int gp8psk_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
-{
- (void) fe;
- *unc = 0;
- return 0;
-}
-
-static int gp8psk_fe_read_snr(struct dvb_frontend* fe, u16 *snr)
-{
- struct gp8psk_fe_state *st = fe->demodulator_priv;
- u8 buf[2];
-
- if (time_after(jiffies,st->next_snr_check)) {
- gp8psk_usb_in_op(st->d,GET_SIGNAL_STRENGTH,0,0,buf,2);
- *snr = (int)(buf[1]) << 8 | buf[0];
- /* snr is reported in dBu*256 */
- /* snr / 38.4 ~= 100% strength */
- /* snr * 17 returns 100% strength as 65535 */
- if (*snr <= 3855)
- *snr = (*snr<<4) + *snr; // snr * 17
- else
- *snr = 65535;
- st->next_snr_check = jiffies + (10*HZ)/1000;
- } else {
- *snr = st->snr;
- }
- return 0;
-}
-
-static int gp8psk_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
-{
- return gp8psk_fe_read_snr(fe, strength);
-}
-
-static int gp8psk_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- tune->min_delay_ms = 800;
- return 0;
-}
-
-static int gp8psk_fe_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct gp8psk_fe_state *state = fe->demodulator_priv;
- u8 cmd[10];
- u32 freq = fep->frequency * 1000;
-
- cmd[4] = freq & 0xff;
- cmd[5] = (freq >> 8) & 0xff;
- cmd[6] = (freq >> 16) & 0xff;
- cmd[7] = (freq >> 24) & 0xff;
-
- switch(fe->ops.info.type) {
- case FE_QPSK:
- cmd[0] = fep->u.qpsk.symbol_rate & 0xff;
- cmd[1] = (fep->u.qpsk.symbol_rate >> 8) & 0xff;
- cmd[2] = (fep->u.qpsk.symbol_rate >> 16) & 0xff;
- cmd[3] = (fep->u.qpsk.symbol_rate >> 24) & 0xff;
- cmd[8] = ADV_MOD_DVB_QPSK;
- cmd[9] = 0x03; /*ADV_MOD_FEC_XXX*/
- break;
- default:
- // other modes are unsuported right now
- cmd[0] = 0;
- cmd[1] = 0;
- cmd[2] = 0;
- cmd[3] = 0;
- cmd[8] = 0;
- cmd[9] = 0;
- break;
- }
-
- gp8psk_usb_out_op(state->d,TUNE_8PSK,0,0,cmd,10);
-
- state->next_snr_check = jiffies;
-
- return 0;
-}
-
-static int gp8psk_fe_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- return 0;
-}
-
-
-static int gp8psk_fe_send_diseqc_msg (struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd *m)
-{
- struct gp8psk_fe_state *st = fe->demodulator_priv;
-
- deb_fe("%s\n",__FUNCTION__);
-
- if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0,
- m->msg, m->msg_len)) {
- return -EINVAL;
- }
- return 0;
-}
-
-static int gp8psk_fe_send_diseqc_burst (struct dvb_frontend* fe,
- fe_sec_mini_cmd_t burst)
-{
- struct gp8psk_fe_state *st = fe->demodulator_priv;
- u8 cmd;
-
- deb_fe("%s\n",__FUNCTION__);
-
- /* These commands are certainly wrong */
- cmd = (burst == SEC_MINI_A) ? 0x00 : 0x01;
-
- if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, cmd, 0,
- &cmd, 0)) {
- return -EINVAL;
- }
- return 0;
-}
-
-static int gp8psk_fe_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct gp8psk_fe_state* state = fe->demodulator_priv;
-
- if (gp8psk_usb_out_op(state->d,SET_22KHZ_TONE,
- (tone == SEC_TONE_ON), 0, NULL, 0)) {
- return -EINVAL;
- }
- return 0;
-}
-
-static int gp8psk_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct gp8psk_fe_state* state = fe->demodulator_priv;
-
- if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE,
- voltage == SEC_VOLTAGE_18, 0, NULL, 0)) {
- return -EINVAL;
- }
- return 0;
-}
-
-static int gp8psk_fe_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long sw_cmd)
-{
- struct gp8psk_fe_state* state = fe->demodulator_priv;
- u8 cmd = sw_cmd & 0x7f;
-
- if (gp8psk_usb_out_op(state->d,SET_DN_SWITCH, cmd, 0,
- NULL, 0)) {
- return -EINVAL;
- }
- if (gp8psk_usb_out_op(state->d,SET_LNB_VOLTAGE, !!(sw_cmd & 0x80),
- 0, NULL, 0)) {
- return -EINVAL;
- }
-
- return 0;
-}
-
-static void gp8psk_fe_release(struct dvb_frontend* fe)
-{
- struct gp8psk_fe_state *state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops gp8psk_fe_ops;
-
-struct dvb_frontend * gp8psk_fe_attach(struct dvb_usb_device *d)
-{
- struct gp8psk_fe_state *s = kzalloc(sizeof(struct gp8psk_fe_state), GFP_KERNEL);
- if (s == NULL)
- goto error;
-
- s->d = d;
- memcpy(&s->fe.ops, &gp8psk_fe_ops, sizeof(struct dvb_frontend_ops));
- s->fe.demodulator_priv = s;
-
- goto success;
-error:
- return NULL;
-success:
- return &s->fe;
-}
-
-
-static struct dvb_frontend_ops gp8psk_fe_ops = {
- .info = {
- .name = "Genpix 8psk-USB DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 100,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .symbol_rate_tolerance = 500, /* ppm */
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK
- },
-
- .release = gp8psk_fe_release,
-
- .init = NULL,
- .sleep = NULL,
-
- .set_frontend = gp8psk_fe_set_frontend,
- .get_frontend = gp8psk_fe_get_frontend,
- .get_tune_settings = gp8psk_fe_get_tune_settings,
-
- .read_status = gp8psk_fe_read_status,
- .read_ber = gp8psk_fe_read_ber,
- .read_signal_strength = gp8psk_fe_read_signal_strength,
- .read_snr = gp8psk_fe_read_snr,
- .read_ucblocks = gp8psk_fe_read_unc_blocks,
-
- .diseqc_send_master_cmd = gp8psk_fe_send_diseqc_msg,
- .diseqc_send_burst = gp8psk_fe_send_diseqc_burst,
- .set_tone = gp8psk_fe_set_tone,
- .set_voltage = gp8psk_fe_set_voltage,
- .dishnetwork_send_legacy_command = gp8psk_fe_send_legacy_dish_cmd,
-};
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c
deleted file mode 100644
index 9a98f3fdae3..00000000000
--- a/drivers/media/dvb/dvb-usb/gp8psk.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* DVB USB compliant Linux driver for the
- * - GENPIX 8pks/qpsk USB2.0 DVB-S module
- *
- * Copyright (C) 2006 Alan Nisota (alannisota@gmail.com)
- *
- * Thanks to GENPIX for the sample code used to implement this module.
- *
- * This module is based off the vp7045 and vp702x modules
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "gp8psk.h"
-
-/* debug */
-static char bcm4500_firmware[] = "dvb-usb-gp8psk-02.fw";
-int dvb_usb_gp8psk_debug;
-module_param_named(debug,dvb_usb_gp8psk_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
-
-int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen)
-{
- int ret = 0,try = 0;
-
- if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
- return ret;
-
- while (ret >= 0 && ret != blen && try < 3) {
- ret = usb_control_msg(d->udev,
- usb_rcvctrlpipe(d->udev,0),
- req,
- USB_TYPE_VENDOR | USB_DIR_IN,
- value,index,b,blen,
- 2000);
- deb_info("reading number %d (ret: %d)\n",try,ret);
- try++;
- }
-
- if (ret < 0 || ret != blen) {
- warn("usb in operation failed.");
- ret = -EIO;
- } else
- ret = 0;
-
- deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index);
- debug_dump(b,blen,deb_xfer);
-
- mutex_unlock(&d->usb_mutex);
-
- return ret;
-}
-
-int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
- u16 index, u8 *b, int blen)
-{
- int ret;
-
- deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index);
- debug_dump(b,blen,deb_xfer);
-
- if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
- return ret;
-
- if (usb_control_msg(d->udev,
- usb_sndctrlpipe(d->udev,0),
- req,
- USB_TYPE_VENDOR | USB_DIR_OUT,
- value,index,b,blen,
- 2000) != blen) {
- warn("usb out operation failed.");
- ret = -EIO;
- } else
- ret = 0;
- mutex_unlock(&d->usb_mutex);
-
- return ret;
-}
-
-static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d)
-{
- int ret;
- const struct firmware *fw = NULL;
- u8 *ptr, *buf;
- if ((ret = request_firmware(&fw, bcm4500_firmware,
- &d->udev->dev)) != 0) {
- err("did not find the bcm4500 firmware file. (%s) "
- "Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
- bcm4500_firmware,ret);
- return ret;
- }
-
- ret = -EINVAL;
-
- if (gp8psk_usb_out_op(d, LOAD_BCM4500,1,0,NULL, 0))
- goto out_rel_fw;
-
- info("downloaidng bcm4500 firmware from file '%s'",bcm4500_firmware);
-
- ptr = fw->data;
- buf = kmalloc(512, GFP_KERNEL | GFP_DMA);
-
- while (ptr[0] != 0xff) {
- u16 buflen = ptr[0] + 4;
- if (ptr + buflen >= fw->data + fw->size) {
- err("failed to load bcm4500 firmware.");
- goto out_free;
- }
- memcpy(buf, ptr, buflen);
- if (dvb_usb_generic_write(d, buf, buflen)) {
- err("failed to load bcm4500 firmware.");
- goto out_free;
- }
- ptr += buflen;
- }
-
- ret = 0;
-
-out_free:
- kfree(buf);
-out_rel_fw:
- release_firmware(fw);
-
- return ret;
-}
-
-static int gp8psk_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 status, buf;
- if (onoff) {
- gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1);
- if (! (status & 0x01)) /* started */
- if (gp8psk_usb_in_op(d, BOOT_8PSK, 1, 0, &buf, 1))
- return -EINVAL;
-
- if (! (status & 0x02)) /* BCM4500 firmware loaded */
- if(gp8psk_load_bcm4500fw(d))
- return EINVAL;
-
- if (! (status & 0x04)) /* LNB Power */
- if (gp8psk_usb_in_op(d, START_INTERSIL, 1, 0,
- &buf, 1))
- return EINVAL;
-
- /* Set DVB mode */
- if(gp8psk_usb_out_op(d, SET_DVB_MODE, 1, 0, NULL, 0))
- return -EINVAL;
- gp8psk_usb_in_op(d, GET_8PSK_CONFIG,0,0,&status,1);
- } else {
- /* Turn off LNB power */
- if (gp8psk_usb_in_op(d, START_INTERSIL, 0, 0, &buf, 1))
- return EINVAL;
- /* Turn off 8psk power */
- if (gp8psk_usb_in_op(d, BOOT_8PSK, 0, 0, &buf, 1))
- return -EINVAL;
-
- }
- return 0;
-}
-
-
-static int gp8psk_streaming_ctrl(struct dvb_usb_device *d, int onoff)
-{
- return gp8psk_usb_out_op(d, ARM_TRANSFER, onoff, 0 , NULL, 0);
-}
-
-static int gp8psk_frontend_attach(struct dvb_usb_device *d)
-{
- d->fe = gp8psk_fe_attach(d);
-
- return 0;
-}
-
-static struct dvb_usb_properties gp8psk_properties;
-
-static int gp8psk_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- return dvb_usb_device_init(intf,&gp8psk_properties,THIS_MODULE,NULL);
-}
-
-static struct usb_device_id gp8psk_usb_table [] = {
- { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_COLD) },
- { USB_DEVICE(USB_VID_GENPIX, USB_PID_GENPIX_8PSK_WARM) },
- { 0 },
-};
-MODULE_DEVICE_TABLE(usb, gp8psk_usb_table);
-
-static struct dvb_usb_properties gp8psk_properties = {
- .caps = 0,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-gp8psk-01.fw",
-
- .streaming_ctrl = gp8psk_streaming_ctrl,
- .power_ctrl = gp8psk_power_ctrl,
- .frontend_attach = gp8psk_frontend_attach,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x82,
- .u = {
- .bulk = {
- .buffersize = 8192,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { .name = "Genpix 8PSK-USB DVB-S USB2.0 receiver",
- .cold_ids = { &gp8psk_usb_table[0], NULL },
- .warm_ids = { &gp8psk_usb_table[1], NULL },
- },
- { 0 },
- }
-};
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver gp8psk_usb_driver = {
- .name = "dvb_usb_gp8psk",
- .probe = gp8psk_usb_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = gp8psk_usb_table,
-};
-
-/* module stuff */
-static int __init gp8psk_usb_module_init(void)
-{
- int result;
- if ((result = usb_register(&gp8psk_usb_driver))) {
- err("usb_register failed. (%d)",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit gp8psk_usb_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&gp8psk_usb_driver);
-}
-
-module_init(gp8psk_usb_module_init);
-module_exit(gp8psk_usb_module_exit);
-
-MODULE_AUTHOR("Alan Nisota <alannisota@gamil.com>");
-MODULE_DESCRIPTION("Driver for Genpix 8psk-USB DVB-S USB2.0");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.h b/drivers/media/dvb/dvb-usb/gp8psk.h
deleted file mode 100644
index 3eba7061011..00000000000
--- a/drivers/media/dvb/dvb-usb/gp8psk.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* DVB USB compliant Linux driver for the
- * - GENPIX 8pks/qpsk USB2.0 DVB-S module
- *
- * Copyright (C) 2006 Alan Nisota (alannisota@gmail.com)
- *
- * Thanks to GENPIX for the sample code used to implement this module.
- *
- * This module is based off the vp7045 and vp702x modules
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#ifndef _DVB_USB_GP8PSK_H_
-#define _DVB_USB_GP8PSK_H_
-
-#define DVB_USB_LOG_PREFIX "gp8psk"
-#include "dvb-usb.h"
-
-extern int dvb_usb_gp8psk_debug;
-#define deb_info(args...) dprintk(dvb_usb_gp8psk_debug,0x01,args)
-#define deb_xfer(args...) dprintk(dvb_usb_gp8psk_debug,0x02,args)
-#define deb_rc(args...) dprintk(dvb_usb_gp8psk_debug,0x04,args)
-#define deb_fe(args...) dprintk(dvb_usb_gp8psk_debug,0x08,args)
-/* gp8psk commands */
-
-/* Twinhan Vendor requests */
-#define TH_COMMAND_IN 0xC0
-#define TH_COMMAND_OUT 0xC1
-
-/* command bytes */
-#define GET_8PSK_CONFIG 0x80
-#define SET_8PSK_CONFIG 0x81
-#define ARM_TRANSFER 0x85
-#define TUNE_8PSK 0x86
-#define GET_SIGNAL_STRENGTH 0x87
-#define LOAD_BCM4500 0x88
-#define BOOT_8PSK 0x89
-#define START_INTERSIL 0x8A
-#define SET_LNB_VOLTAGE 0x8B
-#define SET_22KHZ_TONE 0x8C
-#define SEND_DISEQC_COMMAND 0x8D
-#define SET_DVB_MODE 0x8E
-#define SET_DN_SWITCH 0x8F
-#define GET_SIGNAL_LOCK 0x90
-
-/* Satellite modulation modes */
-#define ADV_MOD_DVB_QPSK 0 /* DVB-S QPSK */
-#define ADV_MOD_TURBO_QPSK 1 /* Turbo QPSK */
-#define ADV_MOD_TURBO_8PSK 2 /* Turbo 8PSK (also used for Trellis 8PSK) */
-#define ADV_MOD_TURBO_16QAM 3 /* Turbo 16QAM (also used for Trellis 8PSK) */
-
-#define ADV_MOD_DCII_C_QPSK 4 /* Digicipher II Combo */
-#define ADV_MOD_DCII_I_QPSK 5 /* Digicipher II I-stream */
-#define ADV_MOD_DCII_Q_QPSK 6 /* Digicipher II Q-stream */
-#define ADV_MOD_DCII_C_OQPSK 7 /* Digicipher II offset QPSK */
-#define ADV_MOD_DSS_QPSK 8 /* DSS (DIRECTV) QPSK */
-#define ADV_MOD_DVB_BPSK 9 /* DVB-S BPSK */
-
-#define GET_USB_SPEED 0x07
- #define USB_SPEED_LOW 0
- #define USB_SPEED_FULL 1
- #define USB_SPEED_HIGH 2
-
-#define RESET_FX2 0x13
-
-#define FW_VERSION_READ 0x0B
-#define VENDOR_STRING_READ 0x0C
-#define PRODUCT_STRING_READ 0x0D
-#define FW_BCD_VERSION_READ 0x14
-
-extern struct dvb_frontend * gp8psk_fe_attach(struct dvb_usb_device *d);
-extern int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
-extern int gp8psk_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
- u16 index, u8 *b, int blen);
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
deleted file mode 100644
index 412039d8dba..00000000000
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/* DVB USB framework compliant Linux driver for the Hauppauge WinTV-NOVA-T usb2
- * DVB-T receiver.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dibusb.h"
-
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=rc,2=eeprom (|-able))." DVB_USB_DEBUG_STATUS);
-
-#define deb_rc(args...) dprintk(debug,0x01,args)
-#define deb_ee(args...) dprintk(debug,0x02,args)
-
-/* Hauppauge NOVA-T USB2 keys */
-static struct dvb_usb_rc_key haupp_rc_keys [] = {
- { 0x1e, 0x00, KEY_0 },
- { 0x1e, 0x01, KEY_1 },
- { 0x1e, 0x02, KEY_2 },
- { 0x1e, 0x03, KEY_3 },
- { 0x1e, 0x04, KEY_4 },
- { 0x1e, 0x05, KEY_5 },
- { 0x1e, 0x06, KEY_6 },
- { 0x1e, 0x07, KEY_7 },
- { 0x1e, 0x08, KEY_8 },
- { 0x1e, 0x09, KEY_9 },
- { 0x1e, 0x0a, KEY_KPASTERISK },
- { 0x1e, 0x0b, KEY_RED },
- { 0x1e, 0x0c, KEY_RADIO },
- { 0x1e, 0x0d, KEY_MENU },
- { 0x1e, 0x0e, KEY_GRAVE }, /* # */
- { 0x1e, 0x0f, KEY_MUTE },
- { 0x1e, 0x10, KEY_VOLUMEUP },
- { 0x1e, 0x11, KEY_VOLUMEDOWN },
- { 0x1e, 0x12, KEY_CHANNEL },
- { 0x1e, 0x14, KEY_UP },
- { 0x1e, 0x15, KEY_DOWN },
- { 0x1e, 0x16, KEY_LEFT },
- { 0x1e, 0x17, KEY_RIGHT },
- { 0x1e, 0x18, KEY_VIDEO },
- { 0x1e, 0x19, KEY_AUDIO },
- { 0x1e, 0x1a, KEY_MEDIA },
- { 0x1e, 0x1b, KEY_EPG },
- { 0x1e, 0x1c, KEY_TV },
- { 0x1e, 0x1e, KEY_NEXT },
- { 0x1e, 0x1f, KEY_BACK },
- { 0x1e, 0x20, KEY_CHANNELUP },
- { 0x1e, 0x21, KEY_CHANNELDOWN },
- { 0x1e, 0x24, KEY_LAST }, /* Skip backwards */
- { 0x1e, 0x25, KEY_OK },
- { 0x1e, 0x29, KEY_BLUE},
- { 0x1e, 0x2e, KEY_GREEN },
- { 0x1e, 0x30, KEY_PAUSE },
- { 0x1e, 0x32, KEY_REWIND },
- { 0x1e, 0x34, KEY_FASTFORWARD },
- { 0x1e, 0x35, KEY_PLAY },
- { 0x1e, 0x36, KEY_STOP },
- { 0x1e, 0x37, KEY_RECORD },
- { 0x1e, 0x38, KEY_YELLOW },
- { 0x1e, 0x3b, KEY_GOTO },
- { 0x1e, 0x3d, KEY_POWER },
-};
-
-/* Firmware bug? sometimes, when a new key is pressed, the previous pressed key
- * is delivered. No workaround yet, maybe a new firmware.
- */
-static int nova_t_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- u8 key[5],cmd[2] = { DIBUSB_REQ_POLL_REMOTE, 0x35 }, data,toggle,custom;
- u16 raw;
- int i;
- struct dibusb_state *st = d->priv;
-
- dvb_usb_generic_rw(d,cmd,2,key,5,0);
-
- *state = REMOTE_NO_KEY_PRESSED;
- switch (key[0]) {
- case DIBUSB_RC_HAUPPAUGE_KEY_PRESSED:
- raw = ((key[1] << 8) | key[2]) >> 3;
- toggle = !!(raw & 0x800);
- data = raw & 0x3f;
- custom = (raw >> 6) & 0x1f;
-
- deb_rc("raw key code 0x%02x, 0x%02x, 0x%02x to c: %02x d: %02x toggle: %d\n",key[1],key[2],key[3],custom,data,toggle);
-
- for (i = 0; i < ARRAY_SIZE(haupp_rc_keys); i++) {
- deb_rc("c: %x, d: %x\n",haupp_rc_keys[i].data,haupp_rc_keys[i].custom);
- if (haupp_rc_keys[i].data == data &&
- haupp_rc_keys[i].custom == custom) {
- *event = haupp_rc_keys[i].event;
- *state = REMOTE_KEY_PRESSED;
- if (st->old_toggle == toggle) {
- if (st->last_repeat_count++ < 2)
- *state = REMOTE_NO_KEY_PRESSED;
- } else {
- st->last_repeat_count = 0;
- st->old_toggle = toggle;
- }
- break;
- }
- }
-
- break;
- case DIBUSB_RC_HAUPPAUGE_KEY_EMPTY:
- default:
- break;
- }
-
- return 0;
-}
-
-static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
-{
- int i;
- u8 b;
-
- mac[0] = 0x00;
- mac[1] = 0x0d;
- mac[2] = 0xfe;
-
- /* this is a complete guess, but works for my box */
- for (i = 136; i < 139; i++) {
- dibusb_read_eeprom_byte(d,i, &b);
-
- mac[5 - (i - 136)] = b;
- }
-
- return 0;
-}
-
-/* USB Driver stuff */
-static struct dvb_usb_properties nova_t_properties;
-
-static int nova_t_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE,NULL);
-}
-
-/* do not change the order of the ID table */
-static struct usb_device_id nova_t_table [] = {
-/* 00 */ { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_WINTV_NOVA_T_USB2_COLD) },
-/* 01 */ { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_WINTV_NOVA_T_USB2_WARM) },
- { } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(usb, nova_t_table);
-
-static struct dvb_usb_properties nova_t_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF | DVB_USB_IS_AN_I2C_ADAPTER,
- .pid_filter_count = 32,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-nova-t-usb2-01.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb2_0_streaming_ctrl,
- .pid_filter = dibusb_pid_filter,
- .pid_filter_ctrl = dibusb_pid_filter_ctrl,
- .power_ctrl = dibusb2_0_power_ctrl,
- .frontend_attach = dibusb_dib3000mc_frontend_attach,
- .tuner_attach = dibusb_dib3000mc_tuner_attach,
- .read_mac_address = nova_t_read_mac_address,
-
- .rc_interval = 100,
- .rc_key_map = haupp_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(haupp_rc_keys),
- .rc_query = nova_t_rc_query,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x06,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "Hauppauge WinTV-NOVA-T usb2",
- { &nova_t_table[0], NULL },
- { &nova_t_table[1], NULL },
- },
- { NULL },
- }
-};
-
-static struct usb_driver nova_t_driver = {
- .name = "dvb_usb_nova_t_usb2",
- .probe = nova_t_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = nova_t_table,
-};
-
-/* module stuff */
-static int __init nova_t_module_init(void)
-{
- int result;
- if ((result = usb_register(&nova_t_driver))) {
- err("usb_register failed. Error number %d",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit nova_t_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&nova_t_driver);
-}
-
-module_init (nova_t_module_init);
-module_exit (nova_t_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Hauppauge WinTV-NOVA-T usb2");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c
deleted file mode 100644
index 97d74da0dad..00000000000
--- a/drivers/media/dvb/dvb-usb/umt-010.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* DVB USB framework compliant Linux driver for the HanfTek UMT-010 USB2.0
- * DVB-T receiver.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "dibusb.h"
-
-#include "mt352.h"
-
-static int umt_mt352_demod_init(struct dvb_frontend *fe)
-{
- static u8 mt352_clock_config[] = { 0x89, 0xb8, 0x2d };
- static u8 mt352_reset[] = { 0x50, 0x80 };
- static u8 mt352_mclk_ratio[] = { 0x8b, 0x00 };
- static u8 mt352_adc_ctl_1_cfg[] = { 0x8E, 0x40 };
- static u8 mt352_agc_cfg[] = { 0x67, 0x10, 0xa0 };
-
- static u8 mt352_sec_agc_cfg1[] = { 0x6a, 0xff };
- static u8 mt352_sec_agc_cfg2[] = { 0x6d, 0xff };
- static u8 mt352_sec_agc_cfg3[] = { 0x70, 0x40 };
- static u8 mt352_sec_agc_cfg4[] = { 0x7b, 0x03 };
- static u8 mt352_sec_agc_cfg5[] = { 0x7d, 0x0f };
-
- static u8 mt352_acq_ctl[] = { 0x53, 0x50 };
- static u8 mt352_input_freq_1[] = { 0x56, 0x31, 0x06 };
-
- mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
- udelay(2000);
- mt352_write(fe, mt352_reset, sizeof(mt352_reset));
- mt352_write(fe, mt352_mclk_ratio, sizeof(mt352_mclk_ratio));
-
- mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
- mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
-
- mt352_write(fe, mt352_sec_agc_cfg1, sizeof(mt352_sec_agc_cfg1));
- mt352_write(fe, mt352_sec_agc_cfg2, sizeof(mt352_sec_agc_cfg2));
- mt352_write(fe, mt352_sec_agc_cfg3, sizeof(mt352_sec_agc_cfg3));
- mt352_write(fe, mt352_sec_agc_cfg4, sizeof(mt352_sec_agc_cfg4));
- mt352_write(fe, mt352_sec_agc_cfg5, sizeof(mt352_sec_agc_cfg5));
-
- mt352_write(fe, mt352_acq_ctl, sizeof(mt352_acq_ctl));
- mt352_write(fe, mt352_input_freq_1, sizeof(mt352_input_freq_1));
-
- return 0;
-}
-
-static int umt_mt352_frontend_attach(struct dvb_usb_device *d)
-{
- struct mt352_config umt_config;
-
- memset(&umt_config,0,sizeof(struct mt352_config));
- umt_config.demod_init = umt_mt352_demod_init;
- umt_config.demod_address = 0xf;
-
- d->fe = mt352_attach(&umt_config, &d->i2c_adap);
-
- return 0;
-}
-
-static int umt_tuner_attach (struct dvb_usb_device *d)
-{
- d->pll_addr = 0x61;
- d->pll_desc = &dvb_pll_tua6034;
- d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs;
- return 0;
-}
-
-/* USB Driver stuff */
-static struct dvb_usb_properties umt_properties;
-
-static int umt_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0)
- return 0;
- return -EINVAL;
-}
-
-/* do not change the order of the ID table */
-static struct usb_device_id umt_table [] = {
-/* 00 */ { USB_DEVICE(USB_VID_HANFTEK, USB_PID_HANFTEK_UMT_010_COLD) },
-/* 01 */ { USB_DEVICE(USB_VID_HANFTEK, USB_PID_HANFTEK_UMT_010_WARM) },
- { } /* Terminating entry */
-};
-MODULE_DEVICE_TABLE (usb, umt_table);
-
-static struct dvb_usb_properties umt_properties = {
- .caps = DVB_USB_IS_AN_I2C_ADAPTER,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-umt-010-02.fw",
-
- .size_of_priv = sizeof(struct dibusb_state),
-
- .streaming_ctrl = dibusb2_0_streaming_ctrl,
- .power_ctrl = dibusb_power_ctrl,
- .frontend_attach = umt_mt352_frontend_attach,
- .tuner_attach = umt_tuner_attach,
-
- .i2c_algo = &dibusb_i2c_algo,
-
- .generic_bulk_ctrl_endpoint = 0x01,
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 20,
- .endpoint = 0x06,
- .u = {
- .bulk = {
- .buffersize = 512,
- }
- }
- },
-
- .num_device_descs = 1,
- .devices = {
- { "Hanftek UMT-010 DVB-T USB2.0",
- { &umt_table[0], NULL },
- { &umt_table[1], NULL },
- },
- }
-};
-
-static struct usb_driver umt_driver = {
- .name = "dvb_usb_umt_010",
- .probe = umt_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = umt_table,
-};
-
-/* module stuff */
-static int __init umt_module_init(void)
-{
- int result;
- if ((result = usb_register(&umt_driver))) {
- err("usb_register failed. Error number %d",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit umt_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&umt_driver);
-}
-
-module_init (umt_module_init);
-module_exit (umt_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Driver for HanfTek UMT 010 USB2.0 DVB-T device");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c
deleted file mode 100644
index d4da494132e..00000000000
--- a/drivers/media/dvb/dvb-usb/vp702x-fe.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/* DVB frontend part of the Linux driver for the TwinhanDTV StarBox USB2.0
- * DVB-S receiver.
- *
- * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de>
- * Metzler Brothers Systementwicklung GbR
- *
- * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de>
- *
- * Thanks to Twinhan who kindly provided hardware and information.
- *
- * This file can be removed soon, after the DST-driver is rewritten to provice
- * the frontend-controlling separately.
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- *
- */
-#include "vp702x.h"
-
-struct vp702x_fe_state {
- struct dvb_frontend fe;
- struct dvb_usb_device *d;
-
- fe_sec_voltage_t voltage;
- fe_sec_tone_mode_t tone_mode;
-
- u8 lnb_buf[8];
-
- u8 lock;
- u8 sig;
- u8 snr;
-
- unsigned long next_status_check;
- unsigned long status_check_interval;
-};
-
-static int vp702x_fe_refresh_state(struct vp702x_fe_state *st)
-{
- u8 buf[10];
- if (time_after(jiffies,st->next_status_check)) {
- vp702x_usb_in_op(st->d,READ_STATUS,0,0,buf,10);
-
- st->lock = buf[4];
- vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x11,0,&st->snr,1);
- vp702x_usb_in_op(st->d,READ_TUNER_REG_REQ,0x15,0,&st->sig,1);
-
- st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
- }
- return 0;
-}
-
-static u8 vp702x_chksum(u8 *buf,int f, int count)
-{
- u8 s = 0;
- int i;
- for (i = f; i < f+count; i++)
- s += buf[i];
- return ~s+1;
-}
-
-static int vp702x_fe_read_status(struct dvb_frontend* fe, fe_status_t *status)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- vp702x_fe_refresh_state(st);
- deb_fe("%s\n",__FUNCTION__);
-
- if (st->lock == 0)
- *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER;
- else
- *status = 0;
-
- deb_fe("real state: %x\n",*status);
- *status = 0x1f;
-
- if (*status & FE_HAS_LOCK)
- st->status_check_interval = 1000;
- else
- st->status_check_interval = 250;
- return 0;
-}
-
-/* not supported by this Frontend */
-static int vp702x_fe_read_ber(struct dvb_frontend* fe, u32 *ber)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- vp702x_fe_refresh_state(st);
- *ber = 0;
- return 0;
-}
-
-/* not supported by this Frontend */
-static int vp702x_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- vp702x_fe_refresh_state(st);
- *unc = 0;
- return 0;
-}
-
-static int vp702x_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- vp702x_fe_refresh_state(st);
-
- *strength = (st->sig << 8) | st->sig;
- return 0;
-}
-
-static int vp702x_fe_read_snr(struct dvb_frontend* fe, u16 *snr)
-{
- u8 _snr;
- struct vp702x_fe_state *st = fe->demodulator_priv;
- vp702x_fe_refresh_state(st);
-
- _snr = (st->snr & 0x1f) * 0xff / 0x1f;
- *snr = (_snr << 8) | _snr;
- return 0;
-}
-
-static int vp702x_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- deb_fe("%s\n",__FUNCTION__);
- tune->min_delay_ms = 2000;
- return 0;
-}
-
-static int vp702x_fe_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- u32 freq = fep->frequency/1000;
- /*CalFrequency*/
-/* u16 frequencyRef[16] = { 2, 4, 8, 16, 32, 64, 128, 256, 24, 5, 10, 20, 40, 80, 160, 320 }; */
- u64 sr;
- u8 cmd[8] = { 0 },ibuf[10];
-
- cmd[0] = (freq >> 8) & 0x7f;
- cmd[1] = freq & 0xff;
- cmd[2] = 1; /* divrate == 4 -> frequencyRef[1] -> 1 here */
-
- sr = (u64) (fep->u.qpsk.symbol_rate/1000) << 20;
- do_div(sr,88000);
- cmd[3] = (sr >> 12) & 0xff;
- cmd[4] = (sr >> 4) & 0xff;
- cmd[5] = (sr << 4) & 0xf0;
-
- deb_fe("setting frontend to: %u -> %u (%x) LNB-based GHz, symbolrate: %d -> %lu (%lx)\n",
- fep->frequency,freq,freq, fep->u.qpsk.symbol_rate,
- (unsigned long) sr, (unsigned long) sr);
-
-/* if (fep->inversion == INVERSION_ON)
- cmd[6] |= 0x80; */
-
- if (st->voltage == SEC_VOLTAGE_18)
- cmd[6] |= 0x40;
-
-/* if (fep->u.qpsk.symbol_rate > 8000000)
- cmd[6] |= 0x20;
-
- if (fep->frequency < 1531000)
- cmd[6] |= 0x04;
-
- if (st->tone_mode == SEC_TONE_ON)
- cmd[6] |= 0x01;*/
-
- cmd[7] = vp702x_chksum(cmd,0,7);
-
- st->status_check_interval = 250;
- st->next_status_check = jiffies;
-
- vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0);
- msleep(30);
- vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100);
-
- if (ibuf[2] == 0 && ibuf[3] == 0)
- deb_fe("tuning failed.\n");
- else
- deb_fe("tuning succeeded.\n");
-
- return 0;
-}
-
-static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- deb_fe("%s\n",__FUNCTION__);
- return 0;
-}
-
-static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd *m)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- u8 cmd[8],ibuf[10];
- memset(cmd,0,8);
-
- deb_fe("%s\n",__FUNCTION__);
-
- if (m->msg_len > 4)
- return -EINVAL;
-
- cmd[1] = SET_DISEQC_CMD;
- cmd[2] = m->msg_len;
- memcpy(&cmd[3], m->msg, m->msg_len);
- cmd[7] = vp702x_chksum(cmd,0,7);
-
- vp702x_usb_inout_op(st->d,cmd,8,ibuf,10,100);
-
- if (ibuf[2] == 0 && ibuf[3] == 0)
- deb_fe("diseqc cmd failed.\n");
- else
- deb_fe("diseqc cmd succeeded.\n");
-
- return 0;
-}
-
-static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
-{
- deb_fe("%s\n",__FUNCTION__);
- return 0;
-}
-
-static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- u8 ibuf[10];
- deb_fe("%s\n",__FUNCTION__);
-
- st->tone_mode = tone;
-
- if (tone == SEC_TONE_ON)
- st->lnb_buf[2] = 0x02;
- else
- st->lnb_buf[2] = 0x00;
-
- st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7);
-
- vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100);
- if (ibuf[2] == 0 && ibuf[3] == 0)
- deb_fe("set_tone cmd failed.\n");
- else
- deb_fe("set_tone cmd succeeded.\n");
-
- return 0;
-}
-
-static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t
- voltage)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- u8 ibuf[10];
- deb_fe("%s\n",__FUNCTION__);
-
- st->voltage = voltage;
-
- if (voltage != SEC_VOLTAGE_OFF)
- st->lnb_buf[4] = 0x01;
- else
- st->lnb_buf[4] = 0x00;
-
- st->lnb_buf[7] = vp702x_chksum(st->lnb_buf,0,7);
-
- vp702x_usb_inout_op(st->d,st->lnb_buf,8,ibuf,10,100);
- if (ibuf[2] == 0 && ibuf[3] == 0)
- deb_fe("set_voltage cmd failed.\n");
- else
- deb_fe("set_voltage cmd succeeded.\n");
-
- return 0;
-}
-
-static void vp702x_fe_release(struct dvb_frontend* fe)
-{
- struct vp702x_fe_state *st = fe->demodulator_priv;
- kfree(st);
-}
-
-static struct dvb_frontend_ops vp702x_fe_ops;
-
-struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d)
-{
- struct vp702x_fe_state *s = kzalloc(sizeof(struct vp702x_fe_state), GFP_KERNEL);
- if (s == NULL)
- goto error;
-
- s->d = d;
-
- memcpy(&s->fe.ops,&vp702x_fe_ops,sizeof(struct dvb_frontend_ops));
- s->fe.demodulator_priv = s;
-
- s->lnb_buf[1] = SET_LNB_POWER;
- s->lnb_buf[3] = 0xff; /* 0=tone burst, 2=data burst, ff=off */
-
- return &s->fe;
-error:
- return NULL;
-}
-
-
-static struct dvb_frontend_ops vp702x_fe_ops = {
- .info = {
- .name = "Twinhan DST-like frontend (VP7021/VP7020) DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 1000, /* kHz for QPSK frontends */
- .frequency_tolerance = 0,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .symbol_rate_tolerance = 500, /* ppm */
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
- FE_CAN_QPSK |
- FE_CAN_FEC_AUTO
- },
- .release = vp702x_fe_release,
-
- .init = NULL,
- .sleep = NULL,
-
- .set_frontend = vp702x_fe_set_frontend,
- .get_frontend = vp702x_fe_get_frontend,
- .get_tune_settings = vp702x_fe_get_tune_settings,
-
- .read_status = vp702x_fe_read_status,
- .read_ber = vp702x_fe_read_ber,
- .read_signal_strength = vp702x_fe_read_signal_strength,
- .read_snr = vp702x_fe_read_snr,
- .read_ucblocks = vp702x_fe_read_unc_blocks,
-
- .diseqc_send_master_cmd = vp702x_fe_send_diseqc_msg,
- .diseqc_send_burst = vp702x_fe_send_diseqc_burst,
- .set_tone = vp702x_fe_set_tone,
- .set_voltage = vp702x_fe_set_voltage,
-};
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
deleted file mode 100644
index b2f098a2d5f..00000000000
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/* DVB USB compliant Linux driver for the TwinhanDTV StarBox USB2.0 DVB-S
- * receiver.
- *
- * Copyright (C) 2005 Ralph Metzler <rjkm@metzlerbros.de>
- * Metzler Brothers Systementwicklung GbR
- *
- * Copyright (C) 2005 Patrick Boettcher <patrick.boettcher@desy.de>
- *
- * Thanks to Twinhan who kindly provided hardware and information.
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "vp702x.h"
-
-/* debug */
-int dvb_usb_vp702x_debug;
-module_param_named(debug,dvb_usb_vp702x_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
-
-struct vp702x_state {
- u8 pid_table[17]; /* [16] controls the pid_table state */
-};
-
-/* check for mutex FIXME */
-int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen)
-{
- int ret = 0,try = 0;
-
- while (ret >= 0 && ret != blen && try < 3) {
- ret = usb_control_msg(d->udev,
- usb_rcvctrlpipe(d->udev,0),
- req,
- USB_TYPE_VENDOR | USB_DIR_IN,
- value,index,b,blen,
- 2000);
- deb_info("reading number %d (ret: %d)\n",try,ret);
- try++;
- }
-
- if (ret < 0 || ret != blen) {
- warn("usb in operation failed.");
- ret = -EIO;
- } else
- ret = 0;
-
- deb_xfer("in: req. %x, val: %x, ind: %x, buffer: ",req,value,index);
- debug_dump(b,blen,deb_xfer);
-
- return ret;
-}
-
-static int vp702x_usb_out_op(struct dvb_usb_device *d, u8 req, u16 value,
- u16 index, u8 *b, int blen)
-{
- deb_xfer("out: req. %x, val: %x, ind: %x, buffer: ",req,value,index);
- debug_dump(b,blen,deb_xfer);
-
- if (usb_control_msg(d->udev,
- usb_sndctrlpipe(d->udev,0),
- req,
- USB_TYPE_VENDOR | USB_DIR_OUT,
- value,index,b,blen,
- 2000) != blen) {
- warn("usb out operation failed.");
- return -EIO;
- } else
- return 0;
-}
-
-int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec)
-{
- int ret;
-
- if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
- return ret;
-
- if ((ret = vp702x_usb_out_op(d,REQUEST_OUT,0,0,o,olen)) < 0)
- goto unlock;
- msleep(msec);
- ret = vp702x_usb_in_op(d,REQUEST_IN,0,0,i,ilen);
-
-unlock:
- mutex_unlock(&d->usb_mutex);
-
- return ret;
-}
-
-static int vp702x_usb_inout_cmd(struct dvb_usb_device *d, u8 cmd, u8 *o,
- int olen, u8 *i, int ilen, int msec)
-{
- u8 bout[olen+2];
- u8 bin[ilen+1];
- int ret = 0;
-
- bout[0] = 0x00;
- bout[1] = cmd;
- memcpy(&bout[2],o,olen);
-
- ret = vp702x_usb_inout_op(d, bout, olen+2, bin, ilen+1,msec);
-
- if (ret == 0)
- memcpy(i,&bin[1],ilen);
-
- return ret;
-}
-
-static int vp702x_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
-{
- struct vp702x_state *st = d->priv;
- u8 buf[9];
-
- if (onoff) {
- st->pid_table[16] |= 1 << index;
- st->pid_table[index*2] = (pid >> 8) & 0xff;
- st->pid_table[index*2+1] = pid & 0xff;
- } else {
- st->pid_table[16] &= ~(1 << index);
- st->pid_table[index*2] = st->pid_table[index*2+1] = 0;
- }
-
- return vp702x_usb_inout_cmd(d,SET_PID_FILTER,st->pid_table,17,buf,9,10);
-}
-
-static int vp702x_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- vp702x_usb_in_op(d,RESET_TUNER,0,0,NULL,0);
-
- vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0);
- return vp702x_usb_in_op(d,SET_TUNER_POWER_REQ,0,onoff,NULL,0);
-}
-
-/* keys for the enclosed remote control */
-static struct dvb_usb_rc_key vp702x_rc_keys[] = {
- { 0x00, 0x01, KEY_1 },
- { 0x00, 0x02, KEY_2 },
-};
-
-/* remote control stuff (does not work with my box) */
-static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- u8 key[10];
- int i;
-
-/* remove the following return to enabled remote querying */
- return 0;
-
- vp702x_usb_in_op(d,READ_REMOTE_REQ,0,0,key,10);
-
- deb_rc("remote query key: %x %d\n",key[1],key[1]);
-
- if (key[1] == 0x44) {
- *state = REMOTE_NO_KEY_PRESSED;
- return 0;
- }
-
- for (i = 0; i < ARRAY_SIZE(vp702x_rc_keys); i++)
- if (vp702x_rc_keys[i].custom == key[1]) {
- *state = REMOTE_KEY_PRESSED;
- *event = vp702x_rc_keys[i].event;
- break;
- }
- return 0;
-}
-
-static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
-{
- u8 macb[9];
- if (vp702x_usb_inout_cmd(d, GET_MAC_ADDRESS, NULL, 0, macb, 9, 10))
- return -EIO;
- memcpy(mac,&macb[3],6);
- return 0;
-}
-
-static int vp702x_frontend_attach(struct dvb_usb_device *d)
-{
- u8 buf[9] = { 0 };
-
- if (vp702x_usb_inout_cmd(d, GET_SYSTEM_STRING, NULL, 0, buf, 9, 10))
- return -EIO;
-
- buf[8] = '\0';
- info("system string: %s",&buf[1]);
-
- d->fe = vp702x_fe_attach(d);
- return 0;
-}
-
-static struct dvb_usb_properties vp702x_properties;
-
-static int vp702x_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_device *udev = interface_to_usbdev(intf);
-
- usb_clear_halt(udev,usb_sndctrlpipe(udev,0));
- usb_clear_halt(udev,usb_rcvctrlpipe(udev,0));
-
- return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL);
-}
-
-static struct usb_device_id vp702x_usb_table [] = {
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_COLD) },
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7021_WARM) },
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_COLD) },
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7020_WARM) },
- { 0 },
-};
-MODULE_DEVICE_TABLE(usb, vp702x_usb_table);
-
-static struct dvb_usb_properties vp702x_properties = {
- .caps = DVB_USB_HAS_PID_FILTER | DVB_USB_NEED_PID_FILTERING,
- .pid_filter_count = 8, /* !!! */
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-vp702x-01.fw",
-
- .pid_filter = vp702x_pid_filter,
- .power_ctrl = vp702x_power_ctrl,
- .frontend_attach = vp702x_frontend_attach,
- .read_mac_address = vp702x_read_mac_addr,
-
- .rc_key_map = vp702x_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(vp702x_rc_keys),
- .rc_interval = 400,
- .rc_query = vp702x_rc_query,
-
- .size_of_priv = sizeof(struct vp702x_state),
-
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 2,
- .devices = {
- { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7021)",
- .cold_ids = { &vp702x_usb_table[0], NULL },
- .warm_ids = { &vp702x_usb_table[1], NULL },
- },
- { .name = "TwinhanDTV StarBox DVB-S USB2.0 (VP7020)",
- .cold_ids = { &vp702x_usb_table[2], NULL },
- .warm_ids = { &vp702x_usb_table[3], NULL },
- },
- { 0 },
- }
-};
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver vp702x_usb_driver = {
- .name = "dvb-usb-vp702x",
- .probe = vp702x_usb_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = vp702x_usb_table,
-};
-
-/* module stuff */
-static int __init vp702x_usb_module_init(void)
-{
- int result;
- if ((result = usb_register(&vp702x_usb_driver))) {
- err("usb_register failed. (%d)",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit vp702x_usb_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&vp702x_usb_driver);
-}
-
-module_init(vp702x_usb_module_init);
-module_exit(vp702x_usb_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Driver for Twinhan StarBox DVB-S USB2.0 and clones");
-MODULE_VERSION("1.0-alpha");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/vp702x.h b/drivers/media/dvb/dvb-usb/vp702x.h
deleted file mode 100644
index c2f97f96c21..00000000000
--- a/drivers/media/dvb/dvb-usb/vp702x.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef _DVB_USB_VP7021_H_
-#define _DVB_USB_VP7021_H_
-
-#define DVB_USB_LOG_PREFIX "vp702x"
-#include "dvb-usb.h"
-
-extern int dvb_usb_vp702x_debug;
-#define deb_info(args...) dprintk(dvb_usb_vp702x_debug,0x01,args)
-#define deb_xfer(args...) dprintk(dvb_usb_vp702x_debug,0x02,args)
-#define deb_rc(args...) dprintk(dvb_usb_vp702x_debug,0x04,args)
-#define deb_fe(args...) dprintk(dvb_usb_vp702x_debug,0x08,args)
-
-/* commands are read and written with USB control messages */
-
-/* consecutive read/write operation */
-#define REQUEST_OUT 0xB2
-#define REQUEST_IN 0xB3
-
-/* the out-buffer of these consecutive operations contain sub-commands when b[0] = 0
- * request: 0xB2; i: 0; v: 0; b[0] = 0, b[1] = subcmd, additional buffer
- * the returning buffer looks as follows
- * request: 0xB3; i: 0; v: 0; b[0] = 0xB3, additional buffer */
-
-#define GET_TUNER_STATUS 0x05
-/* additional in buffer:
- * 0 1 2 3 4 5 6 7 8
- * N/A N/A 0x05 signal-quality N/A N/A signal-strength lock==0 N/A */
-
-#define GET_SYSTEM_STRING 0x06
-/* additional in buffer:
- * 0 1 2 3 4 5 6 7 8
- * N/A 'U' 'S' 'B' '7' '0' '2' 'X' N/A */
-
-#define SET_DISEQC_CMD 0x08
-/* additional out buffer:
- * 0 1 2 3 4
- * len X1 X2 X3 X4
- * additional in buffer:
- * 0 1 2
- * N/A 0 0 b[1] == b[2] == 0 -> success, failure otherwise */
-
-#define SET_LNB_POWER 0x09
-/* additional out buffer:
- * 0 1 2
- * 0x00 0xff 1 = on, 0 = off
- * additional in buffer:
- * 0 1 2
- * N/A 0 0 b[1] == b[2] == 0 -> success failure otherwise */
-
-#define GET_MAC_ADDRESS 0x0A
-/* #define GET_MAC_ADDRESS 0x0B */
-/* additional in buffer:
- * 0 1 2 3 4 5 6 7 8
- * N/A N/A 0x0A or 0x0B MAC0 MAC1 MAC2 MAC3 MAC4 MAC5 */
-
-#define SET_PID_FILTER 0x11
-/* additional in buffer:
- * 0 1 ... 14 15 16
- * PID0_MSB PID0_LSB ... PID7_MSB PID7_LSB PID_active (bits) */
-
-/* request: 0xB2; i: 0; v: 0;
- * b[0] != 0 -> tune and lock a channel
- * 0 1 2 3 4 5 6 7
- * freq0 freq1 divstep srate0 srate1 srate2 flag chksum
- */
-
-/* one direction requests */
-#define READ_REMOTE_REQ 0xB4
-/* IN i: 0; v: 0; b[0] == request, b[1] == key */
-
-#define READ_PID_NUMBER_REQ 0xB5
-/* IN i: 0; v: 0; b[0] == request, b[1] == 0, b[2] = pid number */
-
-#define WRITE_EEPROM_REQ 0xB6
-/* OUT i: offset; v: value to write; no extra buffer */
-
-#define READ_EEPROM_REQ 0xB7
-/* IN i: bufferlen; v: offset; buffer with bufferlen bytes */
-
-#define READ_STATUS 0xB8
-/* IN i: 0; v: 0; bufferlen 10 */
-
-#define READ_TUNER_REG_REQ 0xB9
-/* IN i: 0; v: register; b[0] = value */
-
-#define READ_FX2_REG_REQ 0xBA
-/* IN i: offset; v: 0; b[0] = value */
-
-#define WRITE_FX2_REG_REQ 0xBB
-/* OUT i: offset; v: value to write; 1 byte extra buffer */
-
-#define SET_TUNER_POWER_REQ 0xBC
-/* IN i: 0 = power off, 1 = power on */
-
-#define WRITE_TUNER_REG_REQ 0xBD
-/* IN i: register, v: value to write, no extra buffer */
-
-#define RESET_TUNER 0xBE
-/* IN i: 0, v: 0, no extra buffer */
-
-extern struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d);
-
-extern int vp702x_usb_inout_op(struct dvb_usb_device *d, u8 *o, int olen, u8 *i, int ilen, int msec);
-extern int vp702x_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen);
-
-#endif
diff --git a/drivers/media/dvb/dvb-usb/vp7045-fe.c b/drivers/media/dvb/dvb-usb/vp7045-fe.c
deleted file mode 100644
index 8452eef9032..00000000000
--- a/drivers/media/dvb/dvb-usb/vp7045-fe.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/* DVB frontend part of the Linux driver for TwinhanDTV Alpha/MagicBoxII USB2.0
- * DVB-T receiver.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * Thanks to Twinhan who kindly provided hardware and information.
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- *
- */
-#include "vp7045.h"
-
-/* It is a Zarlink MT352 within a Samsung Tuner (DNOS404ZH102A) - 040929 - AAT
- *
- * Programming is hidden inside the firmware, so set_frontend is very easy.
- * Even though there is a Firmware command that one can use to access the demod
- * via its registers. This is used for status information.
- */
-
-struct vp7045_fe_state {
- struct dvb_frontend fe;
- struct dvb_usb_device *d;
-};
-
-static int vp7045_fe_read_status(struct dvb_frontend* fe, fe_status_t *status)
-{
- struct vp7045_fe_state *state = fe->demodulator_priv;
- u8 s0 = vp7045_read_reg(state->d,0x00),
- s1 = vp7045_read_reg(state->d,0x01),
- s3 = vp7045_read_reg(state->d,0x03);
-
- *status = 0;
- if (s0 & (1 << 4))
- *status |= FE_HAS_CARRIER;
- if (s0 & (1 << 1))
- *status |= FE_HAS_VITERBI;
- if (s0 & (1 << 5))
- *status |= FE_HAS_LOCK;
- if (s1 & (1 << 1))
- *status |= FE_HAS_SYNC;
- if (s3 & (1 << 6))
- *status |= FE_HAS_SIGNAL;
-
- if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
- (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
- *status &= ~FE_HAS_LOCK;
-
- return 0;
-}
-
-static int vp7045_fe_read_ber(struct dvb_frontend* fe, u32 *ber)
-{
- struct vp7045_fe_state *state = fe->demodulator_priv;
- *ber = (vp7045_read_reg(state->d, 0x0D) << 16) |
- (vp7045_read_reg(state->d, 0x0E) << 8) |
- vp7045_read_reg(state->d, 0x0F);
- return 0;
-}
-
-static int vp7045_fe_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
-{
- struct vp7045_fe_state *state = fe->demodulator_priv;
- *unc = (vp7045_read_reg(state->d, 0x10) << 8) |
- vp7045_read_reg(state->d, 0x11);
- return 0;
-}
-
-static int vp7045_fe_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
-{
- struct vp7045_fe_state *state = fe->demodulator_priv;
- u16 signal = (vp7045_read_reg(state->d, 0x14) << 8) |
- vp7045_read_reg(state->d, 0x15);
-
- *strength = ~signal;
- return 0;
-}
-
-static int vp7045_fe_read_snr(struct dvb_frontend* fe, u16 *snr)
-{
- struct vp7045_fe_state *state = fe->demodulator_priv;
- u8 _snr = vp7045_read_reg(state->d, 0x09);
- *snr = (_snr << 8) | _snr;
- return 0;
-}
-
-static int vp7045_fe_init(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int vp7045_fe_sleep(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int vp7045_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- tune->min_delay_ms = 800;
- return 0;
-}
-
-static int vp7045_fe_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct vp7045_fe_state *state = fe->demodulator_priv;
- u8 buf[5];
- u32 freq = fep->frequency / 1000;
-
- buf[0] = (freq >> 16) & 0xff;
- buf[1] = (freq >> 8) & 0xff;
- buf[2] = freq & 0xff;
- buf[3] = 0;
-
- switch (fep->u.ofdm.bandwidth) {
- case BANDWIDTH_8_MHZ: buf[4] = 8; break;
- case BANDWIDTH_7_MHZ: buf[4] = 7; break;
- case BANDWIDTH_6_MHZ: buf[4] = 6; break;
- case BANDWIDTH_AUTO: return -EOPNOTSUPP;
- default:
- return -EINVAL;
- }
-
- vp7045_usb_op(state->d,LOCK_TUNER_COMMAND,buf,5,NULL,0,200);
- return 0;
-}
-
-static int vp7045_fe_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- return 0;
-}
-
-static void vp7045_fe_release(struct dvb_frontend* fe)
-{
- struct vp7045_fe_state *state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops vp7045_fe_ops;
-
-struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d)
-{
- struct vp7045_fe_state *s = kzalloc(sizeof(struct vp7045_fe_state), GFP_KERNEL);
- if (s == NULL)
- goto error;
-
- s->d = d;
- memcpy(&s->fe.ops, &vp7045_fe_ops, sizeof(struct dvb_frontend_ops));
- s->fe.demodulator_priv = s;
-
- return &s->fe;
-error:
- return NULL;
-}
-
-
-static struct dvb_frontend_ops vp7045_fe_ops = {
- .info = {
- .name = "Twinhan VP7045/46 USB DVB-T",
- .type = FE_OFDM,
- .frequency_min = 44250000,
- .frequency_max = 867250000,
- .frequency_stepsize = 1000,
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO |
- FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_RECOVER |
- FE_CAN_HIERARCHY_AUTO,
- },
-
- .release = vp7045_fe_release,
-
- .init = vp7045_fe_init,
- .sleep = vp7045_fe_sleep,
-
- .set_frontend = vp7045_fe_set_frontend,
- .get_frontend = vp7045_fe_get_frontend,
- .get_tune_settings = vp7045_fe_get_tune_settings,
-
- .read_status = vp7045_fe_read_status,
- .read_ber = vp7045_fe_read_ber,
- .read_signal_strength = vp7045_fe_read_signal_strength,
- .read_snr = vp7045_fe_read_snr,
- .read_ucblocks = vp7045_fe_read_unc_blocks,
-};
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
deleted file mode 100644
index 8ea3834a6cf..00000000000
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/* DVB USB compliant Linux driver for the
- * - TwinhanDTV Alpha/MagicBoxII USB2.0 DVB-T receiver
- * - DigitalNow TinyUSB2 DVB-t receiver
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * Thanks to Twinhan who kindly provided hardware and information.
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#include "vp7045.h"
-
-/* debug */
-int dvb_usb_vp7045_debug;
-module_param_named(debug,dvb_usb_vp7045_debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS);
-
-int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec)
-{
- int ret = 0;
- u8 inbuf[12] = { 0 }, outbuf[20] = { 0 };
-
- outbuf[0] = cmd;
-
- if (outlen > 19)
- outlen = 19;
-
- if (inlen > 11)
- inlen = 11;
-
- if (out != NULL && outlen > 0)
- memcpy(&outbuf[1], out, outlen);
-
- deb_xfer("out buffer: ");
- debug_dump(outbuf,outlen+1,deb_xfer);
-
- if ((ret = mutex_lock_interruptible(&d->usb_mutex)))
- return ret;
-
- if (usb_control_msg(d->udev,
- usb_sndctrlpipe(d->udev,0),
- TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0,
- outbuf, 20, 2000) != 20) {
- err("USB control message 'out' went wrong.");
- ret = -EIO;
- goto unlock;
- }
-
- msleep(msec);
-
- if (usb_control_msg(d->udev,
- usb_rcvctrlpipe(d->udev,0),
- TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
- inbuf, 12, 2000) != 12) {
- err("USB control message 'in' went wrong.");
- ret = -EIO;
- goto unlock;
- }
-
- deb_xfer("in buffer: ");
- debug_dump(inbuf,12,deb_xfer);
-
- if (in != NULL && inlen > 0)
- memcpy(in,&inbuf[1],inlen);
-
-unlock:
- mutex_unlock(&d->usb_mutex);
-
- return ret;
-}
-
-u8 vp7045_read_reg(struct dvb_usb_device *d, u8 reg)
-{
- u8 obuf[2] = { 0 },v;
- obuf[1] = reg;
-
- vp7045_usb_op(d,TUNER_REG_READ,obuf,2,&v,1,30);
-
- return v;
-}
-
-static int vp7045_power_ctrl(struct dvb_usb_device *d, int onoff)
-{
- u8 v = onoff;
- return vp7045_usb_op(d,SET_TUNER_POWER,&v,1,NULL,0,150);
-}
-
-/* remote control stuff */
-
-/* The keymapping struct. Somehow this should be loaded to the driver, but
- * currently it is hardcoded. */
-static struct dvb_usb_rc_key vp7045_rc_keys[] = {
- { 0x00, 0x16, KEY_POWER },
- { 0x00, 0x10, KEY_MUTE },
- { 0x00, 0x03, KEY_1 },
- { 0x00, 0x01, KEY_2 },
- { 0x00, 0x06, KEY_3 },
- { 0x00, 0x09, KEY_4 },
- { 0x00, 0x1d, KEY_5 },
- { 0x00, 0x1f, KEY_6 },
- { 0x00, 0x0d, KEY_7 },
- { 0x00, 0x19, KEY_8 },
- { 0x00, 0x1b, KEY_9 },
- { 0x00, 0x15, KEY_0 },
- { 0x00, 0x05, KEY_CHANNELUP },
- { 0x00, 0x02, KEY_CHANNELDOWN },
- { 0x00, 0x1e, KEY_VOLUMEUP },
- { 0x00, 0x0a, KEY_VOLUMEDOWN },
- { 0x00, 0x11, KEY_RECORD },
- { 0x00, 0x17, KEY_FAVORITES }, /* Heart symbol - Channel list. */
- { 0x00, 0x14, KEY_PLAY },
- { 0x00, 0x1a, KEY_STOP },
- { 0x00, 0x40, KEY_REWIND },
- { 0x00, 0x12, KEY_FASTFORWARD },
- { 0x00, 0x0e, KEY_PREVIOUS }, /* Recall - Previous channel. */
- { 0x00, 0x4c, KEY_PAUSE },
- { 0x00, 0x4d, KEY_SCREEN }, /* Full screen mode. */
- { 0x00, 0x54, KEY_AUDIO }, /* MTS - Switch to secondary audio. */
- { 0x00, 0x0c, KEY_CANCEL }, /* Cancel */
- { 0x00, 0x1c, KEY_EPG }, /* EPG */
- { 0x00, 0x00, KEY_TAB }, /* Tab */
- { 0x00, 0x48, KEY_INFO }, /* Preview */
- { 0x00, 0x04, KEY_LIST }, /* RecordList */
- { 0x00, 0x0f, KEY_TEXT } /* Teletext */
-};
-
-static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
-{
- u8 key;
- int i;
- vp7045_usb_op(d,RC_VAL_READ,NULL,0,&key,1,20);
-
- deb_rc("remote query key: %x %d\n",key,key);
-
- if (key == 0x44) {
- *state = REMOTE_NO_KEY_PRESSED;
- return 0;
- }
-
- for (i = 0; i < sizeof(vp7045_rc_keys)/sizeof(struct dvb_usb_rc_key); i++)
- if (vp7045_rc_keys[i].data == key) {
- *state = REMOTE_KEY_PRESSED;
- *event = vp7045_rc_keys[i].event;
- break;
- }
- return 0;
-}
-
-static int vp7045_read_eeprom(struct dvb_usb_device *d,u8 *buf, int len, int offset)
-{
- int i = 0;
- u8 v,br[2];
- for (i=0; i < len; i++) {
- v = offset + i;
- vp7045_usb_op(d,GET_EE_VALUE,&v,1,br,2,5);
- buf[i] = br[1];
- }
- deb_info("VP7045 EEPROM read (offs: %d, len: %d) : ",offset, i);
- debug_dump(buf,i,deb_info);
- return 0;
-}
-
-static int vp7045_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
-{
- return vp7045_read_eeprom(d,mac, 6, MAC_0_ADDR);
-}
-
-static int vp7045_frontend_attach(struct dvb_usb_device *d)
-{
- u8 buf[255] = { 0 };
-
- vp7045_usb_op(d,VENDOR_STRING_READ,NULL,0,buf,20,0);
- buf[10] = '\0';
- deb_info("firmware says: %s ",buf);
-
- vp7045_usb_op(d,PRODUCT_STRING_READ,NULL,0,buf,20,0);
- buf[10] = '\0';
- deb_info("%s ",buf);
-
- vp7045_usb_op(d,FW_VERSION_READ,NULL,0,buf,20,0);
- buf[10] = '\0';
- deb_info("v%s\n",buf);
-
-/* Dump the EEPROM */
-/* vp7045_read_eeprom(d,buf, 255, FX2_ID_ADDR); */
-
- d->fe = vp7045_fe_attach(d);
-
- return 0;
-}
-
-static struct dvb_usb_properties vp7045_properties;
-
-static int vp7045_usb_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE,NULL);
-}
-
-static struct usb_device_id vp7045_usb_table [] = {
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7045_COLD) },
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_TWINHAN_VP7045_WARM) },
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_DNTV_TINYUSB2_COLD) },
- { USB_DEVICE(USB_VID_VISIONPLUS, USB_PID_DNTV_TINYUSB2_WARM) },
- { 0 },
-};
-MODULE_DEVICE_TABLE(usb, vp7045_usb_table);
-
-static struct dvb_usb_properties vp7045_properties = {
- .caps = 0,
-
- .usb_ctrl = CYPRESS_FX2,
- .firmware = "dvb-usb-vp7045-01.fw",
-
- .power_ctrl = vp7045_power_ctrl,
- .frontend_attach = vp7045_frontend_attach,
- .read_mac_address = vp7045_read_mac_addr,
-
- .rc_interval = 400,
- .rc_key_map = vp7045_rc_keys,
- .rc_key_map_size = ARRAY_SIZE(vp7045_rc_keys),
- .rc_query = vp7045_rc_query,
-
- /* parameter for the MPEG2-data transfer */
- .urb = {
- .type = DVB_USB_BULK,
- .count = 7,
- .endpoint = 0x02,
- .u = {
- .bulk = {
- .buffersize = 4096,
- }
- }
- },
-
- .num_device_descs = 2,
- .devices = {
- { .name = "Twinhan USB2.0 DVB-T receiver (TwinhanDTV Alpha/MagicBox II)",
- .cold_ids = { &vp7045_usb_table[0], NULL },
- .warm_ids = { &vp7045_usb_table[1], NULL },
- },
- { .name = "DigitalNow TinyUSB 2 DVB-t Receiver",
- .cold_ids = { &vp7045_usb_table[2], NULL },
- .warm_ids = { &vp7045_usb_table[3], NULL },
- },
- { NULL },
- }
-};
-
-/* usb specific object needed to register this driver with the usb subsystem */
-static struct usb_driver vp7045_usb_driver = {
- .name = "dvb_usb_vp7045",
- .probe = vp7045_usb_probe,
- .disconnect = dvb_usb_device_exit,
- .id_table = vp7045_usb_table,
-};
-
-/* module stuff */
-static int __init vp7045_usb_module_init(void)
-{
- int result;
- if ((result = usb_register(&vp7045_usb_driver))) {
- err("usb_register failed. (%d)",result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit vp7045_usb_module_exit(void)
-{
- /* deregister this driver from the USB subsystem */
- usb_deregister(&vp7045_usb_driver);
-}
-
-module_init(vp7045_usb_module_init);
-module_exit(vp7045_usb_module_exit);
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_DESCRIPTION("Driver for Twinhan MagicBox/Alpha and DNTV tinyUSB2 DVB-T USB2.0");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/dvb-usb/vp7045.h b/drivers/media/dvb/dvb-usb/vp7045.h
deleted file mode 100644
index 9ce21a20fa8..00000000000
--- a/drivers/media/dvb/dvb-usb/vp7045.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Common header-file of the Linux driver for the TwinhanDTV Alpha/MagicBoxII
- * USB2.0 DVB-T receiver.
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * Thanks to Twinhan who kindly provided hardware and information.
- *
- * 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.
- *
- * see Documentation/dvb/README.dvb-usb for more information
- */
-#ifndef _DVB_USB_VP7045_H_
-#define _DVB_USB_VP7045_H_
-
-#define DVB_USB_LOG_PREFIX "vp7045"
-#include "dvb-usb.h"
-
-extern int dvb_usb_vp7045_debug;
-#define deb_info(args...) dprintk(dvb_usb_vp7045_debug,0x01,args)
-#define deb_xfer(args...) dprintk(dvb_usb_vp7045_debug,0x02,args)
-#define deb_rc(args...) dprintk(dvb_usb_vp7045_debug,0x04,args)
-
-/* vp7045 commands */
-
-/* Twinhan Vendor requests */
-#define TH_COMMAND_IN 0xC0
-#define TH_COMMAND_OUT 0xC1
-
-/* command bytes */
-#define TUNER_REG_READ 0x03
-#define TUNER_REG_WRITE 0x04
-
-#define RC_VAL_READ 0x05
- #define RC_NO_KEY 0x44
-
-#define SET_TUNER_POWER 0x06
-#define CHECK_TUNER_POWER 0x12
- #define Tuner_Power_ON 1
- #define Tuner_Power_OFF 0
-
-#define GET_USB_SPEED 0x07
- #define USB_SPEED_LOW 0
- #define USB_SPEED_FULL 1
- #define USB_SPEED_HIGH 2
-
-#define LOCK_TUNER_COMMAND 0x09
-
-#define TUNER_SIGNAL_READ 0x0A
-
-/* FX2 eeprom */
-#define SET_EE_VALUE 0x10
-#define GET_EE_VALUE 0x11
- #define FX2_ID_ADDR 0x00
- #define VID_MSB_ADDR 0x02
- #define VID_LSB_ADDR 0x01
- #define PID_MSB_ADDR 0x04
- #define PID_LSB_ADDR 0x03
- #define MAC_0_ADDR 0x07
- #define MAC_1_ADDR 0x08
- #define MAC_2_ADDR 0x09
- #define MAC_3_ADDR 0x0a
- #define MAC_4_ADDR 0x0b
- #define MAC_5_ADDR 0x0c
-
-#define RESET_FX2 0x13
-
-#define FW_VERSION_READ 0x0B
-#define VENDOR_STRING_READ 0x0C
-#define PRODUCT_STRING_READ 0x0D
-#define FW_BCD_VERSION_READ 0x14
-
-extern struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d);
-extern int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen,int msec);
-extern u8 vp7045_read_reg(struct dvb_usb_device *d, u8 reg);
-
-#endif
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
deleted file mode 100644
index db978555b1e..00000000000
--- a/drivers/media/dvb/frontends/Kconfig
+++ /dev/null
@@ -1,239 +0,0 @@
-menu "Customise DVB Frontends"
- depends on DVB_CORE
-
-comment "DVB-S (satellite) frontends"
- depends on DVB_CORE
-
-config DVB_STV0299
- tristate "ST STV0299 based"
- depends on DVB_CORE && I2C
- help
- A DVB-S tuner module. Say Y when you want to support this frontend.
-
-config DVB_CX24110
- tristate "Conexant CX24110 based"
- depends on DVB_CORE && I2C
- help
- A DVB-S tuner module. Say Y when you want to support this frontend.
-
-config DVB_CX24123
- tristate "Conexant CX24123 based"
- depends on DVB_CORE && I2C
- help
- A DVB-S tuner module. Say Y when you want to support this frontend.
-
-config DVB_TDA8083
- tristate "Philips TDA8083 based"
- depends on DVB_CORE && I2C
- help
- A DVB-S tuner module. Say Y when you want to support this frontend.
-
-config DVB_MT312
- tristate "Zarlink VP310/MT312 based"
- depends on DVB_CORE && I2C
- help
- A DVB-S tuner module. Say Y when you want to support this frontend.
-
-config DVB_VES1X93
- tristate "VLSI VES1893 or VES1993 based"
- depends on DVB_CORE && I2C
- help
- A DVB-S tuner module. Say Y when you want to support this frontend.
-
-config DVB_S5H1420
- tristate "Samsung S5H1420 based"
- depends on DVB_CORE && I2C
- help
- A DVB-S tuner module. Say Y when you want to support this frontend.
-
-comment "DVB-T (terrestrial) frontends"
- depends on DVB_CORE
-
-config DVB_SP8870
- tristate "Spase sp8870 based"
- depends on DVB_CORE && I2C
- select FW_LOADER
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
- This driver needs external firmware. Please use the command
- "<kerneldir>/Documentation/dvb/get_dvb_firmware sp8870" to
- download/extract it, and then copy it to /usr/lib/hotplug/firmware
- or /lib/firmware (depending on configuration of firmware hotplug).
-
-config DVB_SP887X
- tristate "Spase sp887x based"
- depends on DVB_CORE && I2C
- select FW_LOADER
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
- This driver needs external firmware. Please use the command
- "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to
- download/extract it, and then copy it to /usr/lib/hotplug/firmware
- or /lib/firmware (depending on configuration of firmware hotplug).
-
-config DVB_CX22700
- tristate "Conexant CX22700 based"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
-config DVB_CX22702
- tristate "Conexant cx22702 demodulator (OFDM)"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
-config DVB_L64781
- tristate "LSI L64781"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
-config DVB_TDA1004X
- tristate "Philips TDA10045H/TDA10046H based"
- depends on DVB_CORE && I2C
- select FW_LOADER
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
- This driver needs external firmware. Please use the commands
- "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
- "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
- download/extract them, and then copy them to /usr/lib/hotplug/firmware
- or /lib/firmware (depending on configuration of firmware hotplug).
-
-config DVB_NXT6000
- tristate "NxtWave Communications NXT6000 based"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
-config DVB_MT352
- tristate "Zarlink MT352 based"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
-config DVB_ZL10353
- tristate "Zarlink ZL10353 based"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Say Y when you want to support this frontend.
-
-config DVB_DIB3000MB
- tristate "DiBcom 3000M-B"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Designed for mobile usage. Say Y when you want
- to support this frontend.
-
-config DVB_DIB3000MC
- tristate "DiBcom 3000P/M-C"
- depends on DVB_CORE && I2C
- help
- A DVB-T tuner module. Designed for mobile usage. Say Y when you want
- to support this frontend.
-
-comment "DVB-C (cable) frontends"
- depends on DVB_CORE
-
-config DVB_VES1820
- tristate "VLSI VES1820 based"
- depends on DVB_CORE && I2C
- help
- A DVB-C tuner module. Say Y when you want to support this frontend.
-
-config DVB_TDA10021
- tristate "Philips TDA10021 based"
- depends on DVB_CORE && I2C
- help
- A DVB-C tuner module. Say Y when you want to support this frontend.
-
-config DVB_STV0297
- tristate "ST STV0297 based"
- depends on DVB_CORE && I2C
- help
- A DVB-C tuner module. Say Y when you want to support this frontend.
-
-comment "ATSC (North American/Korean Terrestrial/Cable DTV) frontends"
- depends on DVB_CORE
-
-config DVB_NXT200X
- tristate "NxtWave Communications NXT2002/NXT2004 based"
- depends on DVB_CORE && I2C
- select FW_LOADER
- help
- An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
- to support this frontend.
-
- This driver needs external firmware. Please use the commands
- "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" and
- "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2004" to
- download/extract them, and then copy them to /usr/lib/hotplug/firmware
- or /lib/firmware (depending on configuration of firmware hotplug).
-
-config DVB_OR51211
- tristate "Oren OR51211 based"
- depends on DVB_CORE && I2C
- select FW_LOADER
- help
- An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
-
- This driver needs external firmware. Please use the command
- "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to
- download it, and then copy it to /usr/lib/hotplug/firmware
- or /lib/firmware (depending on configuration of firmware hotplug).
-
-config DVB_OR51132
- tristate "Oren OR51132 based"
- depends on DVB_CORE && I2C
- select FW_LOADER
- help
- An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
- to support this frontend.
-
- This driver needs external firmware. Please use the commands
- "<kerneldir>/Documentation/dvb/get_dvb_firmware or51132_vsb" and/or
- "<kerneldir>/Documentation/dvb/get_dvb_firmware or51132_qam" to
- download firmwares for 8VSB and QAM64/256, respectively. Copy them to
- /usr/lib/hotplug/firmware or /lib/firmware (depending on
- configuration of firmware hotplug).
-
-config DVB_BCM3510
- tristate "Broadcom BCM3510"
- depends on DVB_CORE && I2C
- select FW_LOADER
- help
- An ATSC 8VSB/16VSB and QAM64/256 tuner module. Say Y when you want to
- support this frontend.
-
-config DVB_LGDT330X
- tristate "LG Electronics LGDT3302/LGDT3303 based"
- depends on DVB_CORE && I2C
- help
- An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want
- to support this frontend.
-
-
-comment "Miscellaneous devices"
- depends on DVB_CORE
-
-config DVB_PLL
- tristate
- depends on DVB_CORE && I2C
-
-config DVB_LNBP21
- tristate "LNBP21 SEC controller"
- depends on DVB_CORE && I2C
- help
- An SEC control chip.
-
-config DVB_ISL6421
- tristate "ISL6421 SEC controller"
- depends on DVB_CORE && I2C
- help
- An SEC control chip.
-
-endmenu
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile
deleted file mode 100644
index 0e4880b6db1..00000000000
--- a/drivers/media/dvb/frontends/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Makefile for the kernel DVB frontend device drivers.
-#
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
-
-obj-$(CONFIG_DVB_PLL) += dvb-pll.o
-obj-$(CONFIG_DVB_STV0299) += stv0299.o
-obj-$(CONFIG_DVB_SP8870) += sp8870.o
-obj-$(CONFIG_DVB_CX22700) += cx22700.o
-obj-$(CONFIG_DVB_CX24110) += cx24110.o
-obj-$(CONFIG_DVB_TDA8083) += tda8083.o
-obj-$(CONFIG_DVB_L64781) += l64781.o
-obj-$(CONFIG_DVB_DIB3000MB) += dib3000mb.o dib3000-common.o
-obj-$(CONFIG_DVB_DIB3000MC) += dib3000mc.o dib3000-common.o
-obj-$(CONFIG_DVB_MT312) += mt312.o
-obj-$(CONFIG_DVB_VES1820) += ves1820.o
-obj-$(CONFIG_DVB_VES1X93) += ves1x93.o
-obj-$(CONFIG_DVB_TDA1004X) += tda1004x.o
-obj-$(CONFIG_DVB_SP887X) += sp887x.o
-obj-$(CONFIG_DVB_NXT6000) += nxt6000.o
-obj-$(CONFIG_DVB_MT352) += mt352.o
-obj-$(CONFIG_DVB_ZL10353) += zl10353.o
-obj-$(CONFIG_DVB_CX22702) += cx22702.o
-obj-$(CONFIG_DVB_TDA10021) += tda10021.o
-obj-$(CONFIG_DVB_STV0297) += stv0297.o
-obj-$(CONFIG_DVB_NXT200X) += nxt200x.o
-obj-$(CONFIG_DVB_OR51211) += or51211.o
-obj-$(CONFIG_DVB_OR51132) += or51132.o
-obj-$(CONFIG_DVB_BCM3510) += bcm3510.o
-obj-$(CONFIG_DVB_S5H1420) += s5h1420.o
-obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o
-obj-$(CONFIG_DVB_CX24123) += cx24123.o
-obj-$(CONFIG_DVB_LNBP21) += lnbp21.o
-obj-$(CONFIG_DVB_ISL6421) += isl6421.o
diff --git a/drivers/media/dvb/frontends/bcm3510.c b/drivers/media/dvb/frontends/bcm3510.c
deleted file mode 100644
index baeb311de89..00000000000
--- a/drivers/media/dvb/frontends/bcm3510.c
+++ /dev/null
@@ -1,854 +0,0 @@
-/*
- * Support for the Broadcom BCM3510 ATSC demodulator (1st generation Air2PC)
- *
- * Copyright (C) 2001-5, B2C2 inc.
- *
- * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de>
- *
- * This driver is "hard-coded" to be used with the 1st generation of
- * Technisat/B2C2's Air2PC ATSC PCI/USB cards/boxes. The pll-programming
- * (Panasonic CT10S) is located here, which is actually wrong. Unless there is
- * another device with a BCM3510, this is no problem.
- *
- * The driver works also with QAM64 DVB-C, but had an unreasonable high
- * UNC. (Tested with the Air2PC ATSC 1st generation)
- *
- * You'll need a firmware for this driver in order to get it running. It is
- * called "dvb-fe-bcm3510-01.fw".
- *
- * 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/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/device.h>
-#include <linux/firmware.h>
-#include <linux/jiffies.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/mutex.h>
-
-#include "dvb_frontend.h"
-#include "bcm3510.h"
-#include "bcm3510_priv.h"
-
-struct bcm3510_state {
-
- struct i2c_adapter* i2c;
- const struct bcm3510_config* config;
- struct dvb_frontend frontend;
-
- /* demodulator private data */
- struct mutex hab_mutex;
- u8 firmware_loaded:1;
-
- unsigned long next_status_check;
- unsigned long status_check_interval;
- struct bcm3510_hab_cmd_status1 status1;
- struct bcm3510_hab_cmd_status2 status2;
-};
-
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c (|-able)).");
-
-#define dprintk(level,x...) if (level & debug) printk(x)
-#define dbufout(b,l,m) {\
- int i; \
- for (i = 0; i < l; i++) \
- m("%02x ",b[i]); \
-}
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_i2c(args...) dprintk(0x02,args)
-#define deb_hab(args...) dprintk(0x04,args)
-
-/* transfer functions */
-static int bcm3510_writebytes (struct bcm3510_state *state, u8 reg, u8 *buf, u8 len)
-{
- u8 b[256];
- int err;
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = b, .len = len + 1 };
-
- b[0] = reg;
- memcpy(&b[1],buf,len);
-
- deb_i2c("i2c wr %02x: ",reg);
- dbufout(buf,len,deb_i2c);
- deb_i2c("\n");
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
-
- deb_info("%s: i2c write error (addr %02x, reg %02x, err == %i)\n",
- __FUNCTION__, state->config->demod_address, reg, err);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static int bcm3510_readbytes (struct bcm3510_state *state, u8 reg, u8 *buf, u8 len)
-{
- struct i2c_msg msg[] = {
- { .addr = state->config->demod_address, .flags = 0, .buf = &reg, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len }
- };
- int err;
-
- memset(buf,0,len);
-
- if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) {
- deb_info("%s: i2c read error (addr %02x, reg %02x, err == %i)\n",
- __FUNCTION__, state->config->demod_address, reg, err);
- return -EREMOTEIO;
- }
- deb_i2c("i2c rd %02x: ",reg);
- dbufout(buf,len,deb_i2c);
- deb_i2c("\n");
-
- return 0;
-}
-
-static int bcm3510_writeB(struct bcm3510_state *state, u8 reg, bcm3510_register_value v)
-{
- return bcm3510_writebytes(state,reg,&v.raw,1);
-}
-
-static int bcm3510_readB(struct bcm3510_state *state, u8 reg, bcm3510_register_value *v)
-{
- return bcm3510_readbytes(state,reg,&v->raw,1);
-}
-
-/* Host Access Buffer transfers */
-static int bcm3510_hab_get_response(struct bcm3510_state *st, u8 *buf, int len)
-{
- bcm3510_register_value v;
- int ret,i;
-
- v.HABADR_a6.HABADR = 0;
- if ((ret = bcm3510_writeB(st,0xa6,v)) < 0)
- return ret;
-
- for (i = 0; i < len; i++) {
- if ((ret = bcm3510_readB(st,0xa7,&v)) < 0)
- return ret;
- buf[i] = v.HABDATA_a7;
- }
- return 0;
-}
-
-static int bcm3510_hab_send_request(struct bcm3510_state *st, u8 *buf, int len)
-{
- bcm3510_register_value v,hab;
- int ret,i;
- unsigned long t;
-
-/* Check if any previous HAB request still needs to be serviced by the
- * Aquisition Processor before sending new request */
- if ((ret = bcm3510_readB(st,0xa8,&v)) < 0)
- return ret;
- if (v.HABSTAT_a8.HABR) {
- deb_info("HAB is running already - clearing it.\n");
- v.HABSTAT_a8.HABR = 0;
- bcm3510_writeB(st,0xa8,v);
-// return -EBUSY;
- }
-
-/* Send the start HAB Address (automatically incremented after write of
- * HABDATA) and write the HAB Data */
- hab.HABADR_a6.HABADR = 0;
- if ((ret = bcm3510_writeB(st,0xa6,hab)) < 0)
- return ret;
-
- for (i = 0; i < len; i++) {
- hab.HABDATA_a7 = buf[i];
- if ((ret = bcm3510_writeB(st,0xa7,hab)) < 0)
- return ret;
- }
-
-/* Set the HABR bit to indicate AP request in progress (LBHABR allows HABR to
- * be written) */
- v.raw = 0; v.HABSTAT_a8.HABR = 1; v.HABSTAT_a8.LDHABR = 1;
- if ((ret = bcm3510_writeB(st,0xa8,v)) < 0)
- return ret;
-
-/* Polling method: Wait until the AP finishes processing the HAB request */
- t = jiffies + 1*HZ;
- while (time_before(jiffies, t)) {
- deb_info("waiting for HAB to complete\n");
- msleep(10);
- if ((ret = bcm3510_readB(st,0xa8,&v)) < 0)
- return ret;
-
- if (!v.HABSTAT_a8.HABR)
- return 0;
- }
-
- deb_info("send_request execution timed out.\n");
- return -ETIMEDOUT;
-}
-
-static int bcm3510_do_hab_cmd(struct bcm3510_state *st, u8 cmd, u8 msgid, u8 *obuf, u8 olen, u8 *ibuf, u8 ilen)
-{
- u8 ob[olen+2],ib[ilen+2];
- int ret = 0;
-
- ob[0] = cmd;
- ob[1] = msgid;
- memcpy(&ob[2],obuf,olen);
-
- deb_hab("hab snd: ");
- dbufout(ob,olen+2,deb_hab);
- deb_hab("\n");
-
- if (mutex_lock_interruptible(&st->hab_mutex) < 0)
- return -EAGAIN;
-
- if ((ret = bcm3510_hab_send_request(st, ob, olen+2)) < 0 ||
- (ret = bcm3510_hab_get_response(st, ib, ilen+2)) < 0)
- goto error;
-
- deb_hab("hab get: ");
- dbufout(ib,ilen+2,deb_hab);
- deb_hab("\n");
-
- memcpy(ibuf,&ib[2],ilen);
-error:
- mutex_unlock(&st->hab_mutex);
- return ret;
-}
-
-#if 0
-/* not needed, we use a semaphore to prevent HAB races */
-static int bcm3510_is_ap_ready(struct bcm3510_state *st)
-{
- bcm3510_register_value ap,hab;
- int ret;
-
- if ((ret = bcm3510_readB(st,0xa8,&hab)) < 0 ||
- (ret = bcm3510_readB(st,0xa2,&ap) < 0))
- return ret;
-
- if (ap.APSTAT1_a2.RESET || ap.APSTAT1_a2.IDLE || ap.APSTAT1_a2.STOP || hab.HABSTAT_a8.HABR) {
- deb_info("AP is busy\n");
- return -EBUSY;
- }
-
- return 0;
-}
-#endif
-
-static int bcm3510_bert_reset(struct bcm3510_state *st)
-{
- bcm3510_register_value b;
- int ret;
-
- if ((ret = bcm3510_readB(st,0xfa,&b)) < 0)
- return ret;
-
- b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b);
- b.BERCTL_fa.RESYNC = 1; bcm3510_writeB(st,0xfa,b);
- b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b);
- b.BERCTL_fa.CNTCTL = 1; b.BERCTL_fa.BITCNT = 1; bcm3510_writeB(st,0xfa,b);
-
- /* clear residual bit counter TODO */
- return 0;
-}
-
-static int bcm3510_refresh_state(struct bcm3510_state *st)
-{
- if (time_after(jiffies,st->next_status_check)) {
- bcm3510_do_hab_cmd(st, CMD_STATUS, MSGID_STATUS1, NULL,0, (u8 *)&st->status1, sizeof(st->status1));
- bcm3510_do_hab_cmd(st, CMD_STATUS, MSGID_STATUS2, NULL,0, (u8 *)&st->status2, sizeof(st->status2));
- st->next_status_check = jiffies + (st->status_check_interval*HZ)/1000;
- }
- return 0;
-}
-
-static int bcm3510_read_status(struct dvb_frontend *fe, fe_status_t *status)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- bcm3510_refresh_state(st);
-
- *status = 0;
- if (st->status1.STATUS1.RECEIVER_LOCK)
- *status |= FE_HAS_LOCK | FE_HAS_SYNC;
-
- if (st->status1.STATUS1.FEC_LOCK)
- *status |= FE_HAS_VITERBI;
-
- if (st->status1.STATUS1.OUT_PLL_LOCK)
- *status |= FE_HAS_SIGNAL | FE_HAS_CARRIER;
-
- if (*status & FE_HAS_LOCK)
- st->status_check_interval = 1500;
- else /* more frequently checks if no lock has been achieved yet */
- st->status_check_interval = 500;
-
- deb_info("real_status: %02x\n",*status);
- return 0;
-}
-
-static int bcm3510_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- bcm3510_refresh_state(st);
-
- *ber = (st->status2.LDBER0 << 16) | (st->status2.LDBER1 << 8) | st->status2.LDBER2;
- return 0;
-}
-
-static int bcm3510_read_unc(struct dvb_frontend* fe, u32* unc)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- bcm3510_refresh_state(st);
- *unc = (st->status2.LDUERC0 << 8) | st->status2.LDUERC1;
- return 0;
-}
-
-static int bcm3510_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- s32 t;
-
- bcm3510_refresh_state(st);
- t = st->status2.SIGNAL;
-
- if (t > 190)
- t = 190;
- if (t < 90)
- t = 90;
-
- t -= 90;
- t = t * 0xff / 100;
- /* normalize if necessary */
- *strength = (t << 8) | t;
- return 0;
-}
-
-static int bcm3510_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- bcm3510_refresh_state(st);
-
- *snr = st->status1.SNR_EST0*1000 + ((st->status1.SNR_EST1*1000) >> 8);
- return 0;
-}
-
-/* tuner frontend programming */
-static int bcm3510_tuner_cmd(struct bcm3510_state* st,u8 bc, u16 n, u8 a)
-{
- struct bcm3510_hab_cmd_tune c;
- memset(&c,0,sizeof(struct bcm3510_hab_cmd_tune));
-
-/* I2C Mode disabled, set 16 control / Data pairs */
- c.length = 0x10;
- c.clock_width = 0;
-/* CS1, CS0, DATA, CLK bits control the tuner RF_AGC_SEL pin is set to
- * logic high (as Configuration) */
- c.misc = 0x10;
-/* Set duration of the initial state of TUNCTL = 3.34 micro Sec */
- c.TUNCTL_state = 0x40;
-
-/* PRESCALER DEVIDE RATIO | BC1_2_3_4; (band switch), 1stosc REFERENCE COUNTER REF_S12 and REF_S11 */
- c.ctl_dat[0].ctrl.size = BITS_8;
- c.ctl_dat[0].data = 0x80 | bc;
-
-/* Control DATA pin, 1stosc REFERENCE COUNTER REF_S10 to REF_S3 */
- c.ctl_dat[1].ctrl.size = BITS_8;
- c.ctl_dat[1].data = 4;
-
-/* set CONTROL BIT 1 to 1, 1stosc REFERENCE COUNTER REF_S2 to REF_S1 */
- c.ctl_dat[2].ctrl.size = BITS_3;
- c.ctl_dat[2].data = 0x20;
-
-/* control CS0 pin, pulse byte ? */
- c.ctl_dat[3].ctrl.size = BITS_3;
- c.ctl_dat[3].ctrl.clk_off = 1;
- c.ctl_dat[3].ctrl.cs0 = 1;
- c.ctl_dat[3].data = 0x40;
-
-/* PGM_S18 to PGM_S11 */
- c.ctl_dat[4].ctrl.size = BITS_8;
- c.ctl_dat[4].data = n >> 3;
-
-/* PGM_S10 to PGM_S8, SWL_S7 to SWL_S3 */
- c.ctl_dat[5].ctrl.size = BITS_8;
- c.ctl_dat[5].data = ((n & 0x7) << 5) | (a >> 2);
-
-/* SWL_S2 and SWL_S1, set CONTROL BIT 2 to 0 */
- c.ctl_dat[6].ctrl.size = BITS_3;
- c.ctl_dat[6].data = (a << 6) & 0xdf;
-
-/* control CS0 pin, pulse byte ? */
- c.ctl_dat[7].ctrl.size = BITS_3;
- c.ctl_dat[7].ctrl.clk_off = 1;
- c.ctl_dat[7].ctrl.cs0 = 1;
- c.ctl_dat[7].data = 0x40;
-
-/* PRESCALER DEVIDE RATIO, 2ndosc REFERENCE COUNTER REF_S12 and REF_S11 */
- c.ctl_dat[8].ctrl.size = BITS_8;
- c.ctl_dat[8].data = 0x80;
-
-/* 2ndosc REFERENCE COUNTER REF_S10 to REF_S3 */
- c.ctl_dat[9].ctrl.size = BITS_8;
- c.ctl_dat[9].data = 0x10;
-
-/* set CONTROL BIT 1 to 1, 2ndosc REFERENCE COUNTER REF_S2 to REF_S1 */
- c.ctl_dat[10].ctrl.size = BITS_3;
- c.ctl_dat[10].data = 0x20;
-
-/* pulse byte */
- c.ctl_dat[11].ctrl.size = BITS_3;
- c.ctl_dat[11].ctrl.clk_off = 1;
- c.ctl_dat[11].ctrl.cs1 = 1;
- c.ctl_dat[11].data = 0x40;
-
-/* PGM_S18 to PGM_S11 */
- c.ctl_dat[12].ctrl.size = BITS_8;
- c.ctl_dat[12].data = 0x2a;
-
-/* PGM_S10 to PGM_S8 and SWL_S7 to SWL_S3 */
- c.ctl_dat[13].ctrl.size = BITS_8;
- c.ctl_dat[13].data = 0x8e;
-
-/* SWL_S2 and SWL_S1 and set CONTROL BIT 2 to 0 */
- c.ctl_dat[14].ctrl.size = BITS_3;
- c.ctl_dat[14].data = 0;
-
-/* Pulse Byte */
- c.ctl_dat[15].ctrl.size = BITS_3;
- c.ctl_dat[15].ctrl.clk_off = 1;
- c.ctl_dat[15].ctrl.cs1 = 1;
- c.ctl_dat[15].data = 0x40;
-
- return bcm3510_do_hab_cmd(st,CMD_TUNE, MSGID_TUNE,(u8 *) &c,sizeof(c), NULL, 0);
-}
-
-static int bcm3510_set_freq(struct bcm3510_state* st,u32 freq)
-{
- u8 bc,a;
- u16 n;
- s32 YIntercept,Tfvco1;
-
- freq /= 1000;
-
- deb_info("%dkHz:",freq);
- /* set Band Switch */
- if (freq <= 168000)
- bc = 0x1c;
- else if (freq <= 378000)
- bc = 0x2c;
- else
- bc = 0x30;
-
- if (freq >= 470000) {
- freq -= 470001;
- YIntercept = 18805;
- } else if (freq >= 90000) {
- freq -= 90001;
- YIntercept = 15005;
- } else if (freq >= 76000){
- freq -= 76001;
- YIntercept = 14865;
- } else {
- freq -= 54001;
- YIntercept = 14645;
- }
-
- Tfvco1 = (((freq/6000)*60 + YIntercept)*4)/10;
-
- n = Tfvco1 >> 6;
- a = Tfvco1 & 0x3f;
-
- deb_info(" BC1_2_3_4: %x, N: %x A: %x\n", bc, n, a);
- if (n >= 16 && n <= 2047)
- return bcm3510_tuner_cmd(st,bc,n,a);
-
- return -EINVAL;
-}
-
-static int bcm3510_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- struct bcm3510_hab_cmd_ext_acquire cmd;
- struct bcm3510_hab_cmd_bert_control bert;
- int ret;
-
- memset(&cmd,0,sizeof(cmd));
- switch (p->u.vsb.modulation) {
- case QAM_256:
- cmd.ACQUIRE0.MODE = 0x1;
- cmd.ACQUIRE1.SYM_RATE = 0x1;
- cmd.ACQUIRE1.IF_FREQ = 0x1;
- break;
- case QAM_64:
- cmd.ACQUIRE0.MODE = 0x2;
- cmd.ACQUIRE1.SYM_RATE = 0x2;
- cmd.ACQUIRE1.IF_FREQ = 0x1;
- break;
-/* case QAM_256:
- cmd.ACQUIRE0.MODE = 0x3;
- break;
- case QAM_128:
- cmd.ACQUIRE0.MODE = 0x4;
- break;
- case QAM_64:
- cmd.ACQUIRE0.MODE = 0x5;
- break;
- case QAM_32:
- cmd.ACQUIRE0.MODE = 0x6;
- break;
- case QAM_16:
- cmd.ACQUIRE0.MODE = 0x7;
- break;*/
- case VSB_8:
- cmd.ACQUIRE0.MODE = 0x8;
- cmd.ACQUIRE1.SYM_RATE = 0x0;
- cmd.ACQUIRE1.IF_FREQ = 0x0;
- break;
- case VSB_16:
- cmd.ACQUIRE0.MODE = 0x9;
- cmd.ACQUIRE1.SYM_RATE = 0x0;
- cmd.ACQUIRE1.IF_FREQ = 0x0;
- default:
- return -EINVAL;
- };
- cmd.ACQUIRE0.OFFSET = 0;
- cmd.ACQUIRE0.NTSCSWEEP = 1;
- cmd.ACQUIRE0.FA = 1;
- cmd.ACQUIRE0.BW = 0;
-
-/* if (enableOffset) {
- cmd.IF_OFFSET0 = xx;
- cmd.IF_OFFSET1 = xx;
-
- cmd.SYM_OFFSET0 = xx;
- cmd.SYM_OFFSET1 = xx;
- if (enableNtscSweep) {
- cmd.NTSC_OFFSET0;
- cmd.NTSC_OFFSET1;
- }
- } */
- bcm3510_do_hab_cmd(st, CMD_ACQUIRE, MSGID_EXT_TUNER_ACQUIRE, (u8 *) &cmd, sizeof(cmd), NULL, 0);
-
-/* doing it with different MSGIDs, data book and source differs */
- bert.BE = 0;
- bert.unused = 0;
- bcm3510_do_hab_cmd(st, CMD_STATE_CONTROL, MSGID_BERT_CONTROL, (u8 *) &bert, sizeof(bert), NULL, 0);
- bcm3510_do_hab_cmd(st, CMD_STATE_CONTROL, MSGID_BERT_SET, (u8 *) &bert, sizeof(bert), NULL, 0);
-
- bcm3510_bert_reset(st);
-
- if ((ret = bcm3510_set_freq(st,p->frequency)) < 0)
- return ret;
-
- memset(&st->status1,0,sizeof(st->status1));
- memset(&st->status2,0,sizeof(st->status2));
- st->status_check_interval = 500;
-
-/* Give the AP some time */
- msleep(200);
-
- return 0;
-}
-
-static int bcm3510_sleep(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int bcm3510_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings *s)
-{
- s->min_delay_ms = 1000;
- s->step_size = 0;
- s->max_drift = 0;
- return 0;
-}
-
-static void bcm3510_release(struct dvb_frontend* fe)
-{
- struct bcm3510_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-/* firmware download:
- * firmware file is build up like this:
- * 16bit addr, 16bit length, 8byte of length
- */
-#define BCM3510_DEFAULT_FIRMWARE "dvb-fe-bcm3510-01.fw"
-
-static int bcm3510_write_ram(struct bcm3510_state *st, u16 addr, u8 *b, u16 len)
-{
- int ret = 0,i;
- bcm3510_register_value vH, vL,vD;
-
- vH.MADRH_a9 = addr >> 8;
- vL.MADRL_aa = addr;
- if ((ret = bcm3510_writeB(st,0xa9,vH)) < 0) return ret;
- if ((ret = bcm3510_writeB(st,0xaa,vL)) < 0) return ret;
-
- for (i = 0; i < len; i++) {
- vD.MDATA_ab = b[i];
- if ((ret = bcm3510_writeB(st,0xab,vD)) < 0)
- return ret;
- }
-
- return 0;
-}
-
-static int bcm3510_download_firmware(struct dvb_frontend* fe)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- const struct firmware *fw;
- u16 addr,len;
- u8 *b;
- int ret,i;
-
- deb_info("requesting firmware\n");
- if ((ret = st->config->request_firmware(fe, &fw, BCM3510_DEFAULT_FIRMWARE)) < 0) {
- err("could not load firmware (%s): %d",BCM3510_DEFAULT_FIRMWARE,ret);
- return ret;
- }
- deb_info("got firmware: %zd\n",fw->size);
-
- b = fw->data;
- for (i = 0; i < fw->size;) {
- addr = le16_to_cpu( *( (u16 *)&b[i] ) );
- len = le16_to_cpu( *( (u16 *)&b[i+2] ) );
- deb_info("firmware chunk, addr: 0x%04x, len: 0x%04x, total length: 0x%04zx\n",addr,len,fw->size);
- if ((ret = bcm3510_write_ram(st,addr,&b[i+4],len)) < 0) {
- err("firmware download failed: %d\n",ret);
- return ret;
- }
- i += 4 + len;
- }
- release_firmware(fw);
- deb_info("firmware download successfully completed\n");
- return 0;
-}
-
-static int bcm3510_check_firmware_version(struct bcm3510_state *st)
-{
- struct bcm3510_hab_cmd_get_version_info ver;
- bcm3510_do_hab_cmd(st,CMD_GET_VERSION_INFO,MSGID_GET_VERSION_INFO,NULL,0,(u8*)&ver,sizeof(ver));
-
- deb_info("Version information: 0x%02x 0x%02x 0x%02x 0x%02x\n",
- ver.microcode_version, ver.script_version, ver.config_version, ver.demod_version);
-
- if (ver.script_version == BCM3510_DEF_SCRIPT_VERSION &&
- ver.config_version == BCM3510_DEF_CONFIG_VERSION &&
- ver.demod_version == BCM3510_DEF_DEMOD_VERSION)
- return 0;
-
- deb_info("version check failed\n");
- return -ENODEV;
-}
-
-/* (un)resetting the AP */
-static int bcm3510_reset(struct bcm3510_state *st)
-{
- int ret;
- unsigned long t;
- bcm3510_register_value v;
-
- bcm3510_readB(st,0xa0,&v); v.HCTL1_a0.RESET = 1;
- if ((ret = bcm3510_writeB(st,0xa0,v)) < 0)
- return ret;
-
- t = jiffies + 3*HZ;
- while (time_before(jiffies, t)) {
- msleep(10);
- if ((ret = bcm3510_readB(st,0xa2,&v)) < 0)
- return ret;
-
- if (v.APSTAT1_a2.RESET)
- return 0;
- }
- deb_info("reset timed out\n");
- return -ETIMEDOUT;
-}
-
-static int bcm3510_clear_reset(struct bcm3510_state *st)
-{
- bcm3510_register_value v;
- int ret;
- unsigned long t;
-
- v.raw = 0;
- if ((ret = bcm3510_writeB(st,0xa0,v)) < 0)
- return ret;
-
- t = jiffies + 3*HZ;
- while (time_before(jiffies, t)) {
- msleep(10);
- if ((ret = bcm3510_readB(st,0xa2,&v)) < 0)
- return ret;
-
- /* verify that reset is cleared */
- if (!v.APSTAT1_a2.RESET)
- return 0;
- }
- deb_info("reset clear timed out\n");
- return -ETIMEDOUT;
-}
-
-static int bcm3510_init_cold(struct bcm3510_state *st)
-{
- int ret;
- bcm3510_register_value v;
-
- /* read Acquisation Processor status register and check it is not in RUN mode */
- if ((ret = bcm3510_readB(st,0xa2,&v)) < 0)
- return ret;
- if (v.APSTAT1_a2.RUN) {
- deb_info("AP is already running - firmware already loaded.\n");
- return 0;
- }
-
- deb_info("reset?\n");
- if ((ret = bcm3510_reset(st)) < 0)
- return ret;
-
- deb_info("tristate?\n");
- /* tri-state */
- v.TSTCTL_2e.CTL = 0;
- if ((ret = bcm3510_writeB(st,0x2e,v)) < 0)
- return ret;
-
- deb_info("firmware?\n");
- if ((ret = bcm3510_download_firmware(&st->frontend)) < 0 ||
- (ret = bcm3510_clear_reset(st)) < 0)
- return ret;
-
- /* anything left here to Let the acquisition processor begin execution at program counter 0000 ??? */
-
- return 0;
-}
-
-static int bcm3510_init(struct dvb_frontend* fe)
-{
- struct bcm3510_state* st = fe->demodulator_priv;
- bcm3510_register_value j;
- struct bcm3510_hab_cmd_set_agc c;
- int ret;
-
- if ((ret = bcm3510_readB(st,0xca,&j)) < 0)
- return ret;
-
- deb_info("JDEC: %02x\n",j.raw);
-
- switch (j.JDEC_ca.JDEC) {
- case JDEC_WAIT_AT_RAM:
- deb_info("attempting to download firmware\n");
- if ((ret = bcm3510_init_cold(st)) < 0)
- return ret;
- case JDEC_EEPROM_LOAD_WAIT: /* fall-through is wanted */
- deb_info("firmware is loaded\n");
- bcm3510_check_firmware_version(st);
- break;
- default:
- return -ENODEV;
- }
-
- memset(&c,0,1);
- c.SEL = 1;
- bcm3510_do_hab_cmd(st,CMD_AUTO_PARAM,MSGID_SET_RF_AGC_SEL,(u8 *)&c,sizeof(c),NULL,0);
-
- return 0;
-}
-
-
-static struct dvb_frontend_ops bcm3510_ops;
-
-struct dvb_frontend* bcm3510_attach(const struct bcm3510_config *config,
- struct i2c_adapter *i2c)
-{
- struct bcm3510_state* state = NULL;
- int ret;
- bcm3510_register_value v;
-
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct bcm3510_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
-
- state->config = config;
- state->i2c = i2c;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &bcm3510_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
-
- mutex_init(&state->hab_mutex);
-
- if ((ret = bcm3510_readB(state,0xe0,&v)) < 0)
- goto error;
-
- deb_info("Revision: 0x%1x, Layer: 0x%1x.\n",v.REVID_e0.REV,v.REVID_e0.LAYER);
-
- if ((v.REVID_e0.REV != 0x1 && v.REVID_e0.LAYER != 0xb) && /* cold */
- (v.REVID_e0.REV != 0x8 && v.REVID_e0.LAYER != 0x0)) /* warm */
- goto error;
-
- info("Revision: 0x%1x, Layer: 0x%1x.",v.REVID_e0.REV,v.REVID_e0.LAYER);
-
- bcm3510_reset(state);
-
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-EXPORT_SYMBOL(bcm3510_attach);
-
-static struct dvb_frontend_ops bcm3510_ops = {
-
- .info = {
- .name = "Broadcom BCM3510 VSB/QAM frontend",
- .type = FE_ATSC,
- .frequency_min = 54000000,
- .frequency_max = 803000000,
- /* stepsize is just a guess */
- .frequency_stepsize = 0,
- .caps =
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_8VSB | FE_CAN_16VSB |
- FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_128 | FE_CAN_QAM_256
- },
-
- .release = bcm3510_release,
-
- .init = bcm3510_init,
- .sleep = bcm3510_sleep,
-
- .set_frontend = bcm3510_set_frontend,
- .get_tune_settings = bcm3510_get_tune_settings,
-
- .read_status = bcm3510_read_status,
- .read_ber = bcm3510_read_ber,
- .read_signal_strength = bcm3510_read_signal_strength,
- .read_snr = bcm3510_read_snr,
- .read_ucblocks = bcm3510_read_unc,
-};
-
-MODULE_DESCRIPTION("Broadcom BCM3510 ATSC (8VSB/16VSB & ITU J83 AnnexB FEC QAM64/256) demodulator driver");
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/bcm3510.h b/drivers/media/dvb/frontends/bcm3510.h
deleted file mode 100644
index 80f5d0953d0..00000000000
--- a/drivers/media/dvb/frontends/bcm3510.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Support for the Broadcom BCM3510 ATSC demodulator (1st generation Air2PC)
- *
- * Copyright (C) 2001-5, B2C2 inc.
- *
- * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de>
- *
- * 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.
- */
-#ifndef BCM3510_H
-#define BCM3510_H
-
-#include <linux/dvb/frontend.h>
-#include <linux/firmware.h>
-
-struct bcm3510_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* request firmware for device */
- int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
-};
-
-extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config,
- struct i2c_adapter* i2c);
-
-#endif
diff --git a/drivers/media/dvb/frontends/bcm3510_priv.h b/drivers/media/dvb/frontends/bcm3510_priv.h
deleted file mode 100644
index 3bb1bc2a04f..00000000000
--- a/drivers/media/dvb/frontends/bcm3510_priv.h
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * Support for the Broadcom BCM3510 ATSC demodulator (1st generation Air2PC)
- *
- * Copyright (C) 2001-5, B2C2 inc.
- *
- * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@desy.de>
- *
- * 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.
- */
-#ifndef __BCM3510_PRIV_H__
-#define __BCM3510_PRIV_H__
-
-#define PACKED __attribute__((packed))
-
-#undef err
-#define err(format, arg...) printk(KERN_ERR "bcm3510: " format "\n" , ## arg)
-#undef info
-#define info(format, arg...) printk(KERN_INFO "bcm3510: " format "\n" , ## arg)
-#undef warn
-#define warn(format, arg...) printk(KERN_WARNING "bcm3510: " format "\n" , ## arg)
-
-
-#define PANASONIC_FIRST_IF_BASE_IN_KHz 1407500
-#define BCM3510_SYMBOL_RATE 5381000
-
-typedef union {
- u8 raw;
-
- struct {
- u8 CTL :8;
- } TSTCTL_2e;
-
- u8 LDCERC_4e;
- u8 LDUERC_4f;
- u8 LD_BER0_65;
- u8 LD_BER1_66;
- u8 LD_BER2_67;
- u8 LD_BER3_68;
-
- struct {
- u8 RESET :1;
- u8 IDLE :1;
- u8 STOP :1;
- u8 HIRQ0 :1;
- u8 HIRQ1 :1;
- u8 na0 :1;
- u8 HABAV :1;
- u8 na1 :1;
- } HCTL1_a0;
-
- struct {
- u8 na0 :1;
- u8 IDLMSK :1;
- u8 STMSK :1;
- u8 I0MSK :1;
- u8 I1MSK :1;
- u8 na1 :1;
- u8 HABMSK :1;
- u8 na2 :1;
- } HCTLMSK_a1;
-
- struct {
- u8 RESET :1;
- u8 IDLE :1;
- u8 STOP :1;
- u8 RUN :1;
- u8 HABAV :1;
- u8 MEMAV :1;
- u8 ALDONE :1;
- u8 REIRQ :1;
- } APSTAT1_a2;
-
- struct {
- u8 RSTMSK :1;
- u8 IMSK :1;
- u8 SMSK :1;
- u8 RMSK :1;
- u8 HABMSK :1;
- u8 MAVMSK :1;
- u8 ALDMSK :1;
- u8 REMSK :1;
- } APMSK1_a3;
-
- u8 APSTAT2_a4;
- u8 APMSK2_a5;
-
- struct {
- u8 HABADR :7;
- u8 na :1;
- } HABADR_a6;
-
- u8 HABDATA_a7;
-
- struct {
- u8 HABR :1;
- u8 LDHABR :1;
- u8 APMSK :1;
- u8 HMSK :1;
- u8 LDMSK :1;
- u8 na :3;
- } HABSTAT_a8;
-
- u8 MADRH_a9;
- u8 MADRL_aa;
- u8 MDATA_ab;
-
- struct {
-#define JDEC_WAIT_AT_RAM 0x7
-#define JDEC_EEPROM_LOAD_WAIT 0x4
- u8 JDEC :3;
- u8 na :5;
- } JDEC_ca;
-
- struct {
- u8 REV :4;
- u8 LAYER :4;
- } REVID_e0;
-
- struct {
- u8 unk0 :1;
- u8 CNTCTL :1;
- u8 BITCNT :1;
- u8 unk1 :1;
- u8 RESYNC :1;
- u8 unk2 :3;
- } BERCTL_fa;
-
- struct {
- u8 CSEL0 :1;
- u8 CLKED0 :1;
- u8 CSEL1 :1;
- u8 CLKED1 :1;
- u8 CLKLEV :1;
- u8 SPIVAR :1;
- u8 na :2;
- } TUNSET_fc;
-
- struct {
- u8 CLK :1;
- u8 DATA :1;
- u8 CS0 :1;
- u8 CS1 :1;
- u8 AGCSEL :1;
- u8 na0 :1;
- u8 TUNSEL :1;
- u8 na1 :1;
- } TUNCTL_fd;
-
- u8 TUNSEL0_fe;
- u8 TUNSEL1_ff;
-
-} bcm3510_register_value;
-
-/* HAB commands */
-
-/* version */
-#define CMD_GET_VERSION_INFO 0x3D
-#define MSGID_GET_VERSION_INFO 0x15
-struct bcm3510_hab_cmd_get_version_info {
- u8 microcode_version;
- u8 script_version;
- u8 config_version;
- u8 demod_version;
-} PACKED;
-
-#define BCM3510_DEF_MICROCODE_VERSION 0x0E
-#define BCM3510_DEF_SCRIPT_VERSION 0x06
-#define BCM3510_DEF_CONFIG_VERSION 0x01
-#define BCM3510_DEF_DEMOD_VERSION 0xB1
-
-/* acquire */
-#define CMD_ACQUIRE 0x38
-
-#define MSGID_EXT_TUNER_ACQUIRE 0x0A
-struct bcm3510_hab_cmd_ext_acquire {
- struct {
- u8 MODE :4;
- u8 BW :1;
- u8 FA :1;
- u8 NTSCSWEEP :1;
- u8 OFFSET :1;
- } PACKED ACQUIRE0; /* control_byte */
-
- struct {
- u8 IF_FREQ :3;
- u8 zero0 :1;
- u8 SYM_RATE :3;
- u8 zero1 :1;
- } PACKED ACQUIRE1; /* sym_if */
-
- u8 IF_OFFSET0; /* IF_Offset_10hz */
- u8 IF_OFFSET1;
- u8 SYM_OFFSET0; /* SymbolRateOffset */
- u8 SYM_OFFSET1;
- u8 NTSC_OFFSET0; /* NTSC_Offset_10hz */
- u8 NTSC_OFFSET1;
-} PACKED;
-
-#define MSGID_INT_TUNER_ACQUIRE 0x0B
-struct bcm3510_hab_cmd_int_acquire {
- struct {
- u8 MODE :4;
- u8 BW :1;
- u8 FA :1;
- u8 NTSCSWEEP :1;
- u8 OFFSET :1;
- } PACKED ACQUIRE0; /* control_byte */
-
- struct {
- u8 IF_FREQ :3;
- u8 zero0 :1;
- u8 SYM_RATE :3;
- u8 zero1 :1;
- } PACKED ACQUIRE1; /* sym_if */
-
- u8 TUNER_FREQ0;
- u8 TUNER_FREQ1;
- u8 TUNER_FREQ2;
- u8 TUNER_FREQ3;
- u8 IF_OFFSET0; /* IF_Offset_10hz */
- u8 IF_OFFSET1;
- u8 SYM_OFFSET0; /* SymbolRateOffset */
- u8 SYM_OFFSET1;
- u8 NTSC_OFFSET0; /* NTSC_Offset_10hz */
- u8 NTSC_OFFSET1;
-} PACKED;
-
-/* modes */
-#define BCM3510_QAM16 = 0x01
-#define BCM3510_QAM32 = 0x02
-#define BCM3510_QAM64 = 0x03
-#define BCM3510_QAM128 = 0x04
-#define BCM3510_QAM256 = 0x05
-#define BCM3510_8VSB = 0x0B
-#define BCM3510_16VSB = 0x0D
-
-/* IF_FREQS */
-#define BCM3510_IF_TERRESTRIAL 0x0
-#define BCM3510_IF_CABLE 0x1
-#define BCM3510_IF_USE_CMD 0x7
-
-/* SYM_RATE */
-#define BCM3510_SR_8VSB 0x0 /* 5381119 s/sec */
-#define BCM3510_SR_256QAM 0x1 /* 5360537 s/sec */
-#define BCM3510_SR_16QAM 0x2 /* 5056971 s/sec */
-#define BCM3510_SR_MISC 0x3 /* 5000000 s/sec */
-#define BCM3510_SR_USE_CMD 0x7
-
-/* special symbol rate */
-#define CMD_SET_VALUE_NOT_LISTED 0x2d
-#define MSGID_SET_SYMBOL_RATE_NOT_LISTED 0x0c
-struct bcm3510_hab_cmd_set_sr_not_listed {
- u8 HOST_SYM_RATE0;
- u8 HOST_SYM_RATE1;
- u8 HOST_SYM_RATE2;
- u8 HOST_SYM_RATE3;
-} PACKED;
-
-/* special IF */
-#define MSGID_SET_IF_FREQ_NOT_LISTED 0x0d
-struct bcm3510_hab_cmd_set_if_freq_not_listed {
- u8 HOST_IF_FREQ0;
- u8 HOST_IF_FREQ1;
- u8 HOST_IF_FREQ2;
- u8 HOST_IF_FREQ3;
-} PACKED;
-
-/* auto reacquire */
-#define CMD_AUTO_PARAM 0x2a
-#define MSGID_AUTO_REACQUIRE 0x0e
-struct bcm3510_hab_cmd_auto_reacquire {
- u8 ACQ :1; /* on/off*/
- u8 unused :7;
-} PACKED;
-
-#define MSGID_SET_RF_AGC_SEL 0x12
-struct bcm3510_hab_cmd_set_agc {
- u8 LVL :1;
- u8 unused :6;
- u8 SEL :1;
-} PACKED;
-
-#define MSGID_SET_AUTO_INVERSION 0x14
-struct bcm3510_hab_cmd_auto_inversion {
- u8 AI :1;
- u8 unused :7;
-} PACKED;
-
-
-/* bert control */
-#define CMD_STATE_CONTROL 0x12
-#define MSGID_BERT_CONTROL 0x0e
-#define MSGID_BERT_SET 0xfa
-struct bcm3510_hab_cmd_bert_control {
- u8 BE :1;
- u8 unused :7;
-} PACKED;
-
-#define MSGID_TRI_STATE 0x2e
-struct bcm3510_hab_cmd_tri_state {
- u8 RE :1; /* a/d ram port pins */
- u8 PE :1; /* baud clock pin */
- u8 AC :1; /* a/d clock pin */
- u8 BE :1; /* baud clock pin */
- u8 unused :4;
-} PACKED;
-
-
-/* tune */
-#define CMD_TUNE 0x38
-#define MSGID_TUNE 0x16
-struct bcm3510_hab_cmd_tune_ctrl_data_pair {
- struct {
-#define BITS_8 0x07
-#define BITS_7 0x06
-#define BITS_6 0x05
-#define BITS_5 0x04
-#define BITS_4 0x03
-#define BITS_3 0x02
-#define BITS_2 0x01
-#define BITS_1 0x00
- u8 size :3;
- u8 unk :2;
- u8 clk_off :1;
- u8 cs0 :1;
- u8 cs1 :1;
-
- } PACKED ctrl;
-
- u8 data;
-} PACKED;
-
-struct bcm3510_hab_cmd_tune {
- u8 length;
- u8 clock_width;
- u8 misc;
- u8 TUNCTL_state;
-
- struct bcm3510_hab_cmd_tune_ctrl_data_pair ctl_dat[16];
-} PACKED;
-
-#define CMD_STATUS 0x38
-#define MSGID_STATUS1 0x08
-struct bcm3510_hab_cmd_status1 {
- struct {
- u8 EQ_MODE :4;
- u8 reserved :2;
- u8 QRE :1; /* if QSE and the spectrum is inversed */
- u8 QSE :1; /* automatic spectral inversion */
- } PACKED STATUS0;
-
- struct {
- u8 RECEIVER_LOCK :1;
- u8 FEC_LOCK :1;
- u8 OUT_PLL_LOCK :1;
- u8 reserved :5;
- } PACKED STATUS1;
-
- struct {
- u8 reserved :2;
- u8 BW :1;
- u8 NTE :1; /* NTSC filter sweep enabled */
- u8 AQI :1; /* currently acquiring */
- u8 FA :1; /* fast acquisition */
- u8 ARI :1; /* auto reacquire */
- u8 TI :1; /* programming the tuner */
- } PACKED STATUS2;
- u8 STATUS3;
- u8 SNR_EST0;
- u8 SNR_EST1;
- u8 TUNER_FREQ0;
- u8 TUNER_FREQ1;
- u8 TUNER_FREQ2;
- u8 TUNER_FREQ3;
- u8 SYM_RATE0;
- u8 SYM_RATE1;
- u8 SYM_RATE2;
- u8 SYM_RATE3;
- u8 SYM_OFFSET0;
- u8 SYM_OFFSET1;
- u8 SYM_ERROR0;
- u8 SYM_ERROR1;
- u8 IF_FREQ0;
- u8 IF_FREQ1;
- u8 IF_FREQ2;
- u8 IF_FREQ3;
- u8 IF_OFFSET0;
- u8 IF_OFFSET1;
- u8 IF_ERROR0;
- u8 IF_ERROR1;
- u8 NTSC_FILTER0;
- u8 NTSC_FILTER1;
- u8 NTSC_FILTER2;
- u8 NTSC_FILTER3;
- u8 NTSC_OFFSET0;
- u8 NTSC_OFFSET1;
- u8 NTSC_ERROR0;
- u8 NTSC_ERROR1;
- u8 INT_AGC_LEVEL0;
- u8 INT_AGC_LEVEL1;
- u8 EXT_AGC_LEVEL0;
- u8 EXT_AGC_LEVEL1;
-} PACKED;
-
-#define MSGID_STATUS2 0x14
-struct bcm3510_hab_cmd_status2 {
- struct {
- u8 EQ_MODE :4;
- u8 reserved :2;
- u8 QRE :1;
- u8 QSR :1;
- } PACKED STATUS0;
- struct {
- u8 RL :1;
- u8 FL :1;
- u8 OL :1;
- u8 reserved :5;
- } PACKED STATUS1;
- u8 SYMBOL_RATE0;
- u8 SYMBOL_RATE1;
- u8 SYMBOL_RATE2;
- u8 SYMBOL_RATE3;
- u8 LDCERC0;
- u8 LDCERC1;
- u8 LDCERC2;
- u8 LDCERC3;
- u8 LDUERC0;
- u8 LDUERC1;
- u8 LDUERC2;
- u8 LDUERC3;
- u8 LDBER0;
- u8 LDBER1;
- u8 LDBER2;
- u8 LDBER3;
- struct {
- u8 MODE_TYPE :4; /* acquire mode 0 */
- u8 reservd :4;
- } MODE_TYPE;
- u8 SNR_EST0;
- u8 SNR_EST1;
- u8 SIGNAL;
-} PACKED;
-
-#define CMD_SET_RF_BW_NOT_LISTED 0x3f
-#define MSGID_SET_RF_BW_NOT_LISTED 0x11
-/* TODO */
-
-#endif
diff --git a/drivers/media/dvb/frontends/bsbe1.h b/drivers/media/dvb/frontends/bsbe1.h
deleted file mode 100644
index d8f65738e5d..00000000000
--- a/drivers/media/dvb/frontends/bsbe1.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * bsbe1.h - ALPS BSBE1 tuner support (moved from av7110.c)
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org
- */
-
-#ifndef BSBE1_H
-#define BSBE1_H
-
-static u8 alps_bsbe1_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- 0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
- 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
- 0x09, 0x00, /* FIFO */
- 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
- 0x10, 0x3f, // AGC2 0x3d
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9, // lock detector threshold
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
- 0x29, 0x1e, // 1/2 threshold
- 0x2a, 0x14, // 2/3 threshold
- 0x2b, 0x0f, // 3/4 threshold
- 0x2c, 0x09, // 5/6 threshold
- 0x2d, 0x05, // 7/8 threshold
- 0x2e, 0x01,
- 0x31, 0x1f, // test all FECs
- 0x32, 0x19, // viterbi and synchro search
- 0x33, 0xfc, // rs control
- 0x34, 0x93, // error control
- 0x0f, 0x92,
- 0xff, 0xff
-};
-
-
-static int alps_bsbe1_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
-{
- u8 aclk = 0;
- u8 bclk = 0;
-
- if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
- else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
- else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
- else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
- else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
- else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
-
- stv0299_writereg(fe, 0x13, aclk);
- stv0299_writereg(fe, 0x14, bclk);
- stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg(fe, 0x21, (ratio ) & 0xf0);
-
- return 0;
-}
-
-static int alps_bsbe1_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- int ret;
- u8 data[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
- struct i2c_adapter *i2c = fe->tuner_priv;
-
- if ((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- div = (params->frequency + (125 - 1)) / 125; // round correctly
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
- data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- ret = i2c_transfer(i2c, &msg, 1);
- return (ret != 1) ? -EIO : 0;
-}
-
-static struct stv0299_config alps_bsbe1_config = {
- .demod_address = 0x68,
- .inittab = alps_bsbe1_inittab,
- .mclk = 88000000UL,
- .invert = 1,
- .skip_reinit = 0,
- .min_delay_ms = 100,
- .set_symbol_rate = alps_bsbe1_set_symbol_rate,
-};
-
-#endif
diff --git a/drivers/media/dvb/frontends/bsru6.h b/drivers/media/dvb/frontends/bsru6.h
deleted file mode 100644
index e231cd84b3a..00000000000
--- a/drivers/media/dvb/frontends/bsru6.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * bsru6.h - ALPS BSRU6 tuner support (moved from budget-ci.c)
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org
- */
-
-#ifndef BSRU6_H
-#define BSRU6_H
-
-static u8 alps_bsru6_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x00,
- 0x03, 0x00,
- 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- 0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
- 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
- 0x09, 0x00, /* FIFO */
- 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
- 0x10, 0x3f, // AGC2 0x3d
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9, // lock detector threshold
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
- 0x29, 0x1e, // 1/2 threshold
- 0x2a, 0x14, // 2/3 threshold
- 0x2b, 0x0f, // 3/4 threshold
- 0x2c, 0x09, // 5/6 threshold
- 0x2d, 0x05, // 7/8 threshold
- 0x2e, 0x01,
- 0x31, 0x1f, // test all FECs
- 0x32, 0x19, // viterbi and synchro search
- 0x33, 0xfc, // rs control
- 0x34, 0x93, // error control
- 0x0f, 0x52,
- 0xff, 0xff
-};
-
-static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
-{
- u8 aclk = 0;
- u8 bclk = 0;
-
- if (srate < 1500000) {
- aclk = 0xb7;
- bclk = 0x47;
- } else if (srate < 3000000) {
- aclk = 0xb7;
- bclk = 0x4b;
- } else if (srate < 7000000) {
- aclk = 0xb7;
- bclk = 0x4f;
- } else if (srate < 14000000) {
- aclk = 0xb7;
- bclk = 0x53;
- } else if (srate < 30000000) {
- aclk = 0xb6;
- bclk = 0x53;
- } else if (srate < 45000000) {
- aclk = 0xb4;
- bclk = 0x51;
- }
-
- stv0299_writereg(fe, 0x13, aclk);
- stv0299_writereg(fe, 0x14, bclk);
- stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg(fe, 0x21, ratio & 0xf0);
-
- return 0;
-}
-
-static int alps_bsru6_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- u8 buf[4];
- u32 div;
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
- struct i2c_adapter *i2c = fe->tuner_priv;
-
- if ((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- div = (params->frequency + (125 - 1)) / 125; // round correctly
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
- buf[3] = 0xC4;
-
- if (params->frequency > 1530000)
- buf[3] = 0xc0;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(i2c, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct stv0299_config alps_bsru6_config = {
- .demod_address = 0x68,
- .inittab = alps_bsru6_inittab,
- .mclk = 88000000UL,
- .invert = 1,
- .skip_reinit = 0,
- .lock_output = STV0229_LOCKOUTPUT_1,
- .volt13_op0_op1 = STV0299_VOLT13_OP1,
- .min_delay_ms = 100,
- .set_symbol_rate = alps_bsru6_set_symbol_rate,
-};
-
-#endif
diff --git a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c
deleted file mode 100644
index 13ad1bfae66..00000000000
--- a/drivers/media/dvb/frontends/cx22700.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- Conexant cx22700 DVB OFDM demodulator driver
-
- Copyright (C) 2001-2002 Convergence Integrated Media GmbH
- Holger Waechtler <holger@convergence.de>
-
- 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/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "dvb_frontend.h"
-#include "cx22700.h"
-
-
-struct cx22700_state {
-
- struct i2c_adapter* i2c;
-
- const struct cx22700_config* config;
-
- struct dvb_frontend frontend;
-};
-
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "cx22700: " args); \
- } while (0)
-
-static u8 init_tab [] = {
- 0x04, 0x10,
- 0x05, 0x09,
- 0x06, 0x00,
- 0x08, 0x04,
- 0x09, 0x00,
- 0x0a, 0x01,
- 0x15, 0x40,
- 0x16, 0x10,
- 0x17, 0x87,
- 0x18, 0x17,
- 0x1a, 0x10,
- 0x25, 0x04,
- 0x2e, 0x00,
- 0x39, 0x00,
- 0x3a, 0x04,
- 0x45, 0x08,
- 0x46, 0x02,
- 0x47, 0x05,
-};
-
-
-static int cx22700_writereg (struct cx22700_state* state, u8 reg, u8 data)
-{
- int ret;
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
-
- dprintk ("%s\n", __FUNCTION__);
-
- ret = i2c_transfer (state->i2c, &msg, 1);
-
- if (ret != 1)
- printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
- __FUNCTION__, reg, data, ret);
-
- return (ret != 1) ? -1 : 0;
-}
-
-static int cx22700_readreg (struct cx22700_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
- dprintk ("%s\n", __FUNCTION__);
-
- ret = i2c_transfer (state->i2c, msg, 2);
-
- if (ret != 2) return -EIO;
-
- return b1[0];
-}
-
-static int cx22700_set_inversion (struct cx22700_state* state, int inversion)
-{
- u8 val;
-
- dprintk ("%s\n", __FUNCTION__);
-
- switch (inversion) {
- case INVERSION_AUTO:
- return -EOPNOTSUPP;
- case INVERSION_ON:
- val = cx22700_readreg (state, 0x09);
- return cx22700_writereg (state, 0x09, val | 0x01);
- case INVERSION_OFF:
- val = cx22700_readreg (state, 0x09);
- return cx22700_writereg (state, 0x09, val & 0xfe);
- default:
- return -EINVAL;
- }
-}
-
-static int cx22700_set_tps (struct cx22700_state *state, struct dvb_ofdm_parameters *p)
-{
- static const u8 qam_tab [4] = { 0, 1, 0, 2 };
- static const u8 fec_tab [6] = { 0, 1, 2, 0, 3, 4 };
- u8 val;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (p->code_rate_HP < FEC_1_2 || p->code_rate_HP > FEC_7_8)
- return -EINVAL;
-
- if (p->code_rate_LP < FEC_1_2 || p->code_rate_LP > FEC_7_8)
- return -EINVAL;
-
- if (p->code_rate_HP == FEC_4_5 || p->code_rate_LP == FEC_4_5)
- return -EINVAL;
-
- if (p->guard_interval < GUARD_INTERVAL_1_32 ||
- p->guard_interval > GUARD_INTERVAL_1_4)
- return -EINVAL;
-
- if (p->transmission_mode != TRANSMISSION_MODE_2K &&
- p->transmission_mode != TRANSMISSION_MODE_8K)
- return -EINVAL;
-
- if (p->constellation != QPSK &&
- p->constellation != QAM_16 &&
- p->constellation != QAM_64)
- return -EINVAL;
-
- if (p->hierarchy_information < HIERARCHY_NONE ||
- p->hierarchy_information > HIERARCHY_4)
- return -EINVAL;
-
- if (p->bandwidth < BANDWIDTH_8_MHZ && p->bandwidth > BANDWIDTH_6_MHZ)
- return -EINVAL;
-
- if (p->bandwidth == BANDWIDTH_7_MHZ)
- cx22700_writereg (state, 0x09, cx22700_readreg (state, 0x09 | 0x10));
- else
- cx22700_writereg (state, 0x09, cx22700_readreg (state, 0x09 & ~0x10));
-
- val = qam_tab[p->constellation - QPSK];
- val |= p->hierarchy_information - HIERARCHY_NONE;
-
- cx22700_writereg (state, 0x04, val);
-
- val = fec_tab[p->code_rate_HP - FEC_1_2] << 3;
- val |= fec_tab[p->code_rate_LP - FEC_1_2];
-
- cx22700_writereg (state, 0x05, val);
-
- val = (p->guard_interval - GUARD_INTERVAL_1_32) << 2;
- val |= p->transmission_mode - TRANSMISSION_MODE_2K;
-
- cx22700_writereg (state, 0x06, val);
-
- cx22700_writereg (state, 0x08, 0x04 | 0x02); /* use user tps parameters */
- cx22700_writereg (state, 0x08, 0x04); /* restart aquisition */
-
- return 0;
-}
-
-static int cx22700_get_tps (struct cx22700_state* state, struct dvb_ofdm_parameters *p)
-{
- static const fe_modulation_t qam_tab [3] = { QPSK, QAM_16, QAM_64 };
- static const fe_code_rate_t fec_tab [5] = { FEC_1_2, FEC_2_3, FEC_3_4,
- FEC_5_6, FEC_7_8 };
- u8 val;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (!(cx22700_readreg(state, 0x07) & 0x20)) /* tps valid? */
- return -EAGAIN;
-
- val = cx22700_readreg (state, 0x01);
-
- if ((val & 0x7) > 4)
- p->hierarchy_information = HIERARCHY_AUTO;
- else
- p->hierarchy_information = HIERARCHY_NONE + (val & 0x7);
-
- if (((val >> 3) & 0x3) > 2)
- p->constellation = QAM_AUTO;
- else
- p->constellation = qam_tab[(val >> 3) & 0x3];
-
- val = cx22700_readreg (state, 0x02);
-
- if (((val >> 3) & 0x07) > 4)
- p->code_rate_HP = FEC_AUTO;
- else
- p->code_rate_HP = fec_tab[(val >> 3) & 0x07];
-
- if ((val & 0x07) > 4)
- p->code_rate_LP = FEC_AUTO;
- else
- p->code_rate_LP = fec_tab[val & 0x07];
-
- val = cx22700_readreg (state, 0x03);
-
- p->guard_interval = GUARD_INTERVAL_1_32 + ((val >> 6) & 0x3);
- p->transmission_mode = TRANSMISSION_MODE_2K + ((val >> 5) & 0x1);
-
- return 0;
-}
-
-static int cx22700_init (struct dvb_frontend* fe)
-
-{ struct cx22700_state* state = fe->demodulator_priv;
- int i;
-
- dprintk("cx22700_init: init chip\n");
-
- cx22700_writereg (state, 0x00, 0x02); /* soft reset */
- cx22700_writereg (state, 0x00, 0x00);
-
- msleep(10);
-
- for (i=0; i<sizeof(init_tab); i+=2)
- cx22700_writereg (state, init_tab[i], init_tab[i+1]);
-
- cx22700_writereg (state, 0x00, 0x01);
-
- return 0;
-}
-
-static int cx22700_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct cx22700_state* state = fe->demodulator_priv;
-
- u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
- | (cx22700_readreg (state, 0x0e) << 1);
- u8 sync = cx22700_readreg (state, 0x07);
-
- *status = 0;
-
- if (rs_ber < 0xff00)
- *status |= FE_HAS_SIGNAL;
-
- if (sync & 0x20)
- *status |= FE_HAS_CARRIER;
-
- if (sync & 0x10)
- *status |= FE_HAS_VITERBI;
-
- if (sync & 0x10)
- *status |= FE_HAS_SYNC;
-
- if (*status == 0x0f)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int cx22700_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct cx22700_state* state = fe->demodulator_priv;
-
- *ber = cx22700_readreg (state, 0x0c) & 0x7f;
- cx22700_writereg (state, 0x0c, 0x00);
-
- return 0;
-}
-
-static int cx22700_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
-{
- struct cx22700_state* state = fe->demodulator_priv;
-
- u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
- | (cx22700_readreg (state, 0x0e) << 1);
- *signal_strength = ~rs_ber;
-
- return 0;
-}
-
-static int cx22700_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct cx22700_state* state = fe->demodulator_priv;
-
- u16 rs_ber = (cx22700_readreg (state, 0x0d) << 9)
- | (cx22700_readreg (state, 0x0e) << 1);
- *snr = ~rs_ber;
-
- return 0;
-}
-
-static int cx22700_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct cx22700_state* state = fe->demodulator_priv;
-
- *ucblocks = cx22700_readreg (state, 0x0f);
- cx22700_writereg (state, 0x0f, 0x00);
-
- return 0;
-}
-
-static int cx22700_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx22700_state* state = fe->demodulator_priv;
-
- cx22700_writereg (state, 0x00, 0x02); /* XXX CHECKME: soft reset*/
- cx22700_writereg (state, 0x00, 0x00);
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- cx22700_set_inversion (state, p->inversion);
- cx22700_set_tps (state, &p->u.ofdm);
- cx22700_writereg (state, 0x37, 0x01); /* PAL loop filter off */
- cx22700_writereg (state, 0x00, 0x01); /* restart acquire */
-
- return 0;
-}
-
-static int cx22700_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx22700_state* state = fe->demodulator_priv;
- u8 reg09 = cx22700_readreg (state, 0x09);
-
- p->inversion = reg09 & 0x1 ? INVERSION_ON : INVERSION_OFF;
- return cx22700_get_tps (state, &p->u.ofdm);
-}
-
-static int cx22700_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct cx22700_state* state = fe->demodulator_priv;
-
- if (enable) {
- return cx22700_writereg(state, 0x0a, 0x00);
- } else {
- return cx22700_writereg(state, 0x0a, 0x01);
- }
-}
-
-static int cx22700_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 150;
- fesettings->step_size = 166667;
- fesettings->max_drift = 166667*2;
- return 0;
-}
-
-static void cx22700_release(struct dvb_frontend* fe)
-{
- struct cx22700_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops cx22700_ops;
-
-struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
- struct i2c_adapter* i2c)
-{
- struct cx22700_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct cx22700_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
-
- /* check if the demod is there */
- if (cx22700_readreg(state, 0x07) < 0) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &cx22700_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops cx22700_ops = {
-
- .info = {
- .name = "Conexant CX22700 DVB-T",
- .type = FE_OFDM,
- .frequency_min = 470000000,
- .frequency_max = 860000000,
- .frequency_stepsize = 166667,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
- FE_CAN_RECOVER
- },
-
- .release = cx22700_release,
-
- .init = cx22700_init,
- .i2c_gate_ctrl = cx22700_i2c_gate_ctrl,
-
- .set_frontend = cx22700_set_frontend,
- .get_frontend = cx22700_get_frontend,
- .get_tune_settings = cx22700_get_tune_settings,
-
- .read_status = cx22700_read_status,
- .read_ber = cx22700_read_ber,
- .read_signal_strength = cx22700_read_signal_strength,
- .read_snr = cx22700_read_snr,
- .read_ucblocks = cx22700_read_ucblocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Conexant CX22700 DVB-T Demodulator driver");
-MODULE_AUTHOR("Holger Waechtler");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(cx22700_attach);
diff --git a/drivers/media/dvb/frontends/cx22700.h b/drivers/media/dvb/frontends/cx22700.h
deleted file mode 100644
index dcd8979c1a1..00000000000
--- a/drivers/media/dvb/frontends/cx22700.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Conexant CX22700 DVB OFDM demodulator driver
-
- Copyright (C) 2001-2002 Convergence Integrated Media GmbH
- Holger Waechtler <holger@convergence.de>
-
- 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.
-
-*/
-
-#ifndef CX22700_H
-#define CX22700_H
-
-#include <linux/dvb/frontend.h>
-
-struct cx22700_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-};
-
-extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
- struct i2c_adapter* i2c);
-
-#endif // CX22700_H
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
deleted file mode 100644
index 4106d46c957..00000000000
--- a/drivers/media/dvb/frontends/cx22702.c
+++ /dev/null
@@ -1,534 +0,0 @@
-/*
- Conexant 22702 DVB OFDM demodulator driver
-
- based on:
- Alps TDMB7 DVB OFDM demodulator driver
-
- Copyright (C) 2001-2002 Convergence Integrated Media GmbH
- Holger Waechtler <holger@convergence.de>
-
- Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include "dvb_frontend.h"
-#include "dvb-pll.h"
-#include "cx22702.h"
-
-
-struct cx22702_state {
-
- struct i2c_adapter* i2c;
-
- /* configuration settings */
- const struct cx22702_config* config;
-
- struct dvb_frontend frontend;
-
- /* previous uncorrected block counter */
- u8 prevUCBlocks;
-};
-
-static int debug = 0;
-#define dprintk if (debug) printk
-
-/* Register values to initialise the demod */
-static u8 init_tab [] = {
- 0x00, 0x00, /* Stop aquisition */
- 0x0B, 0x06,
- 0x09, 0x01,
- 0x0D, 0x41,
- 0x16, 0x32,
- 0x20, 0x0A,
- 0x21, 0x17,
- 0x24, 0x3e,
- 0x26, 0xff,
- 0x27, 0x10,
- 0x28, 0x00,
- 0x29, 0x00,
- 0x2a, 0x10,
- 0x2b, 0x00,
- 0x2c, 0x10,
- 0x2d, 0x00,
- 0x48, 0xd4,
- 0x49, 0x56,
- 0x6b, 0x1e,
- 0xc8, 0x02,
- 0xf9, 0x00,
- 0xfa, 0x00,
- 0xfb, 0x00,
- 0xfc, 0x00,
- 0xfd, 0x00,
-};
-
-static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data)
-{
- int ret;
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
-
- ret = i2c_transfer(state->i2c, &msg, 1);
-
- if (ret != 1)
- printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
- __FUNCTION__, reg, data, ret);
-
- return (ret != 1) ? -1 : 0;
-}
-
-static u8 cx22702_readreg (struct cx22702_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
-
- struct i2c_msg msg [] = {
- { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2)
- printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
-
- return b1[0];
-}
-
-static int cx22702_set_inversion (struct cx22702_state *state, int inversion)
-{
- u8 val;
-
- switch (inversion) {
-
- case INVERSION_AUTO:
- return -EOPNOTSUPP;
-
- case INVERSION_ON:
- val = cx22702_readreg (state, 0x0C);
- return cx22702_writereg (state, 0x0C, val | 0x01);
-
- case INVERSION_OFF:
- val = cx22702_readreg (state, 0x0C);
- return cx22702_writereg (state, 0x0C, val & 0xfe);
-
- default:
- return -EINVAL;
-
- }
-
-}
-
-/* Retrieve the demod settings */
-static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_parameters *p)
-{
- u8 val;
-
- /* Make sure the TPS regs are valid */
- if (!(cx22702_readreg(state, 0x0A) & 0x20))
- return -EAGAIN;
-
- val = cx22702_readreg (state, 0x01);
- switch( (val&0x18)>>3) {
- case 0: p->constellation = QPSK; break;
- case 1: p->constellation = QAM_16; break;
- case 2: p->constellation = QAM_64; break;
- }
- switch( val&0x07 ) {
- case 0: p->hierarchy_information = HIERARCHY_NONE; break;
- case 1: p->hierarchy_information = HIERARCHY_1; break;
- case 2: p->hierarchy_information = HIERARCHY_2; break;
- case 3: p->hierarchy_information = HIERARCHY_4; break;
- }
-
-
- val = cx22702_readreg (state, 0x02);
- switch( (val&0x38)>>3 ) {
- case 0: p->code_rate_HP = FEC_1_2; break;
- case 1: p->code_rate_HP = FEC_2_3; break;
- case 2: p->code_rate_HP = FEC_3_4; break;
- case 3: p->code_rate_HP = FEC_5_6; break;
- case 4: p->code_rate_HP = FEC_7_8; break;
- }
- switch( val&0x07 ) {
- case 0: p->code_rate_LP = FEC_1_2; break;
- case 1: p->code_rate_LP = FEC_2_3; break;
- case 2: p->code_rate_LP = FEC_3_4; break;
- case 3: p->code_rate_LP = FEC_5_6; break;
- case 4: p->code_rate_LP = FEC_7_8; break;
- }
-
-
- val = cx22702_readreg (state, 0x03);
- switch( (val&0x0c)>>2 ) {
- case 0: p->guard_interval = GUARD_INTERVAL_1_32; break;
- case 1: p->guard_interval = GUARD_INTERVAL_1_16; break;
- case 2: p->guard_interval = GUARD_INTERVAL_1_8; break;
- case 3: p->guard_interval = GUARD_INTERVAL_1_4; break;
- }
- switch( val&0x03 ) {
- case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break;
- case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break;
- }
-
- return 0;
-}
-
-static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct cx22702_state* state = fe->demodulator_priv;
- dprintk ("%s(%d)\n", __FUNCTION__, enable);
- if (enable)
- return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe);
- else
- return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) | 1);
-}
-
-/* Talk to the demod, set the FEC, GUARD, QAM settings etc */
-static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- u8 val;
- struct cx22702_state* state = fe->demodulator_priv;
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- /* set inversion */
- cx22702_set_inversion (state, p->inversion);
-
- /* set bandwidth */
- switch(p->u.ofdm.bandwidth) {
- case BANDWIDTH_6_MHZ:
- cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x20 );
- break;
- case BANDWIDTH_7_MHZ:
- cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xcf) | 0x10 );
- break;
- case BANDWIDTH_8_MHZ:
- cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf );
- break;
- default:
- dprintk ("%s: invalid bandwidth\n",__FUNCTION__);
- return -EINVAL;
- }
-
-
- p->u.ofdm.code_rate_LP = FEC_AUTO; //temp hack as manual not working
-
- /* use auto configuration? */
- if((p->u.ofdm.hierarchy_information==HIERARCHY_AUTO) ||
- (p->u.ofdm.constellation==QAM_AUTO) ||
- (p->u.ofdm.code_rate_HP==FEC_AUTO) ||
- (p->u.ofdm.code_rate_LP==FEC_AUTO) ||
- (p->u.ofdm.guard_interval==GUARD_INTERVAL_AUTO) ||
- (p->u.ofdm.transmission_mode==TRANSMISSION_MODE_AUTO) ) {
-
- /* TPS Source - use hardware driven values */
- cx22702_writereg(state, 0x06, 0x10);
- cx22702_writereg(state, 0x07, 0x9);
- cx22702_writereg(state, 0x08, 0xC1);
- cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc );
- cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 );
- cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */
- dprintk("%s: Autodetecting\n",__FUNCTION__);
- return 0;
- }
-
- /* manually programmed values */
- val=0;
- switch(p->u.ofdm.constellation) {
- case QPSK: val = (val&0xe7); break;
- case QAM_16: val = (val&0xe7)|0x08; break;
- case QAM_64: val = (val&0xe7)|0x10; break;
- default:
- dprintk ("%s: invalid constellation\n",__FUNCTION__);
- return -EINVAL;
- }
- switch(p->u.ofdm.hierarchy_information) {
- case HIERARCHY_NONE: val = (val&0xf8); break;
- case HIERARCHY_1: val = (val&0xf8)|1; break;
- case HIERARCHY_2: val = (val&0xf8)|2; break;
- case HIERARCHY_4: val = (val&0xf8)|3; break;
- default:
- dprintk ("%s: invalid hierarchy\n",__FUNCTION__);
- return -EINVAL;
- }
- cx22702_writereg (state, 0x06, val);
-
- val=0;
- switch(p->u.ofdm.code_rate_HP) {
- case FEC_NONE:
- case FEC_1_2: val = (val&0xc7); break;
- case FEC_2_3: val = (val&0xc7)|0x08; break;
- case FEC_3_4: val = (val&0xc7)|0x10; break;
- case FEC_5_6: val = (val&0xc7)|0x18; break;
- case FEC_7_8: val = (val&0xc7)|0x20; break;
- default:
- dprintk ("%s: invalid code_rate_HP\n",__FUNCTION__);
- return -EINVAL;
- }
- switch(p->u.ofdm.code_rate_LP) {
- case FEC_NONE:
- case FEC_1_2: val = (val&0xf8); break;
- case FEC_2_3: val = (val&0xf8)|1; break;
- case FEC_3_4: val = (val&0xf8)|2; break;
- case FEC_5_6: val = (val&0xf8)|3; break;
- case FEC_7_8: val = (val&0xf8)|4; break;
- default:
- dprintk ("%s: invalid code_rate_LP\n",__FUNCTION__);
- return -EINVAL;
- }
- cx22702_writereg (state, 0x07, val);
-
- val=0;
- switch(p->u.ofdm.guard_interval) {
- case GUARD_INTERVAL_1_32: val = (val&0xf3); break;
- case GUARD_INTERVAL_1_16: val = (val&0xf3)|0x04; break;
- case GUARD_INTERVAL_1_8: val = (val&0xf3)|0x08; break;
- case GUARD_INTERVAL_1_4: val = (val&0xf3)|0x0c; break;
- default:
- dprintk ("%s: invalid guard_interval\n",__FUNCTION__);
- return -EINVAL;
- }
- switch(p->u.ofdm.transmission_mode) {
- case TRANSMISSION_MODE_2K: val = (val&0xfc); break;
- case TRANSMISSION_MODE_8K: val = (val&0xfc)|1; break;
- default:
- dprintk ("%s: invalid transmission_mode\n",__FUNCTION__);
- return -EINVAL;
- }
- cx22702_writereg(state, 0x08, val);
- cx22702_writereg(state, 0x0B, (cx22702_readreg(state, 0x0B) & 0xfc) | 0x02 );
- cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 );
-
- /* Begin channel aquisition */
- cx22702_writereg(state, 0x00, 0x01);
-
- return 0;
-}
-
-/* Reset the demod hardware and reset all of the configuration registers
- to a default state. */
-static int cx22702_init (struct dvb_frontend* fe)
-{
- int i;
- struct cx22702_state* state = fe->demodulator_priv;
-
- cx22702_writereg (state, 0x00, 0x02);
-
- msleep(10);
-
- for (i=0; i<sizeof(init_tab); i+=2)
- cx22702_writereg (state, init_tab[i], init_tab[i+1]);
-
- cx22702_writereg (state, 0xf8, (state->config->output_mode << 1) & 0x02);
-
- cx22702_i2c_gate_ctrl(fe, 0);
-
- return 0;
-}
-
-static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct cx22702_state* state = fe->demodulator_priv;
- u8 reg0A;
- u8 reg23;
-
- *status = 0;
-
- reg0A = cx22702_readreg (state, 0x0A);
- reg23 = cx22702_readreg (state, 0x23);
-
- dprintk ("%s: status demod=0x%02x agc=0x%02x\n"
- ,__FUNCTION__,reg0A,reg23);
-
- if(reg0A & 0x10) {
- *status |= FE_HAS_LOCK;
- *status |= FE_HAS_VITERBI;
- *status |= FE_HAS_SYNC;
- }
-
- if(reg0A & 0x20)
- *status |= FE_HAS_CARRIER;
-
- if(reg23 < 0xf0)
- *status |= FE_HAS_SIGNAL;
-
- return 0;
-}
-
-static int cx22702_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct cx22702_state* state = fe->demodulator_priv;
-
- if(cx22702_readreg (state, 0xE4) & 0x02) {
- /* Realtime statistics */
- *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
- | (cx22702_readreg (state, 0xDF)&0x7F);
- } else {
- /* Averagtine statistics */
- *ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
- | cx22702_readreg (state, 0xDF);
- }
-
- return 0;
-}
-
-static int cx22702_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
-{
- struct cx22702_state* state = fe->demodulator_priv;
-
- *signal_strength = cx22702_readreg (state, 0x23);
-
- return 0;
-}
-
-static int cx22702_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct cx22702_state* state = fe->demodulator_priv;
-
- u16 rs_ber=0;
- if(cx22702_readreg (state, 0xE4) & 0x02) {
- /* Realtime statistics */
- rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 7
- | (cx22702_readreg (state, 0xDF)& 0x7F);
- } else {
- /* Averagine statistics */
- rs_ber = (cx22702_readreg (state, 0xDE) & 0x7F) << 8
- | cx22702_readreg (state, 0xDF);
- }
- *snr = ~rs_ber;
-
- return 0;
-}
-
-static int cx22702_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct cx22702_state* state = fe->demodulator_priv;
-
- u8 _ucblocks;
-
- /* RS Uncorrectable Packet Count then reset */
- _ucblocks = cx22702_readreg (state, 0xE3);
- if (state->prevUCBlocks < _ucblocks)
- *ucblocks = (_ucblocks - state->prevUCBlocks);
- else
- *ucblocks = state->prevUCBlocks - _ucblocks;
- state->prevUCBlocks = _ucblocks;
-
- return 0;
-}
-
-static int cx22702_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx22702_state* state = fe->demodulator_priv;
-
- u8 reg0C = cx22702_readreg (state, 0x0C);
-
- p->inversion = reg0C & 0x1 ? INVERSION_ON : INVERSION_OFF;
- return cx22702_get_tps (state, &p->u.ofdm);
-}
-
-static int cx22702_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- tune->min_delay_ms = 1000;
- return 0;
-}
-
-static void cx22702_release(struct dvb_frontend* fe)
-{
- struct cx22702_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops cx22702_ops;
-
-struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
- struct i2c_adapter* i2c)
-{
- struct cx22702_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->prevUCBlocks = 0;
-
- /* check if the demod is there */
- if (cx22702_readreg(state, 0x1f) != 0x3)
- goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &cx22702_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops cx22702_ops = {
-
- .info = {
- .name = "Conexant CX22702 DVB-T",
- .type = FE_OFDM,
- .frequency_min = 177000000,
- .frequency_max = 858000000,
- .frequency_stepsize = 166666,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_HIERARCHY_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_RECOVER
- },
-
- .release = cx22702_release,
-
- .init = cx22702_init,
- .i2c_gate_ctrl = cx22702_i2c_gate_ctrl,
-
- .set_frontend = cx22702_set_tps,
- .get_frontend = cx22702_get_frontend,
- .get_tune_settings = cx22702_get_tune_settings,
-
- .read_status = cx22702_read_status,
- .read_ber = cx22702_read_ber,
- .read_signal_strength = cx22702_read_signal_strength,
- .read_snr = cx22702_read_snr,
- .read_ucblocks = cx22702_read_ucblocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Enable verbose debug messages");
-
-MODULE_DESCRIPTION("Conexant CX22702 DVB-T Demodulator driver");
-MODULE_AUTHOR("Steven Toth");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(cx22702_attach);
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
deleted file mode 100644
index 7f2f241e5d4..00000000000
--- a/drivers/media/dvb/frontends/cx22702.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Conexant 22702 DVB OFDM demodulator driver
-
- based on:
- Alps TDMB7 DVB OFDM demodulator driver
-
- Copyright (C) 2001-2002 Convergence Integrated Media GmbH
- Holger Waechtler <holger@convergence.de>
-
- Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef CX22702_H
-#define CX22702_H
-
-#include <linux/dvb/frontend.h>
-
-struct cx22702_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* serial/parallel output */
-#define CX22702_PARALLEL_OUTPUT 0
-#define CX22702_SERIAL_OUTPUT 1
- u8 output_mode;
-};
-
-extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config,
- struct i2c_adapter* i2c);
-
-#endif // CX22702_H
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
deleted file mode 100644
index ce3c7398bac..00000000000
--- a/drivers/media/dvb/frontends/cx24110.c
+++ /dev/null
@@ -1,667 +0,0 @@
-/*
- cx24110 - Single Chip Satellite Channel Receiver driver module
-
- Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on
- work
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-
-#include "dvb_frontend.h"
-#include "cx24110.h"
-
-
-struct cx24110_state {
-
- struct i2c_adapter* i2c;
-
- const struct cx24110_config* config;
-
- struct dvb_frontend frontend;
-
- u32 lastber;
- u32 lastbler;
- u32 lastesn0;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "cx24110: " args); \
- } while (0)
-
-static struct {u8 reg; u8 data;} cx24110_regdata[]=
- /* Comments beginning with @ denote this value should
- be the default */
- {{0x09,0x01}, /* SoftResetAll */
- {0x09,0x00}, /* release reset */
- {0x01,0xe8}, /* MSB of code rate 27.5MS/s */
- {0x02,0x17}, /* middle byte " */
- {0x03,0x29}, /* LSB " */
- {0x05,0x03}, /* @ DVB mode, standard code rate 3/4 */
- {0x06,0xa5}, /* @ PLL 60MHz */
- {0x07,0x01}, /* @ Fclk, i.e. sampling clock, 60MHz */
- {0x0a,0x00}, /* @ partial chip disables, do not set */
- {0x0b,0x01}, /* set output clock in gapped mode, start signal low
- active for first byte */
- {0x0c,0x11}, /* no parity bytes, large hold time, serial data out */
- {0x0d,0x6f}, /* @ RS Sync/Unsync thresholds */
- {0x10,0x40}, /* chip doc is misleading here: write bit 6 as 1
- to avoid starting the BER counter. Reset the
- CRC test bit. Finite counting selected */
- {0x15,0xff}, /* @ size of the limited time window for RS BER
- estimation. It is <value>*256 RS blocks, this
- gives approx. 2.6 sec at 27.5MS/s, rate 3/4 */
- {0x16,0x00}, /* @ enable all RS output ports */
- {0x17,0x04}, /* @ time window allowed for the RS to sync */
- {0x18,0xae}, /* @ allow all standard DVB code rates to be scanned
- for automatically */
- /* leave the current code rate and normalization
- registers as they are after reset... */
- {0x21,0x10}, /* @ during AutoAcq, search each viterbi setting
- only once */
- {0x23,0x18}, /* @ size of the limited time window for Viterbi BER
- estimation. It is <value>*65536 channel bits, i.e.
- approx. 38ms at 27.5MS/s, rate 3/4 */
- {0x24,0x24}, /* do not trigger Viterbi CRC test. Finite count window */
- /* leave front-end AGC parameters at default values */
- /* leave decimation AGC parameters at default values */
- {0x35,0x40}, /* disable all interrupts. They are not connected anyway */
- {0x36,0xff}, /* clear all interrupt pending flags */
- {0x37,0x00}, /* @ fully enable AutoAcqq state machine */
- {0x38,0x07}, /* @ enable fade recovery, but not autostart AutoAcq */
- /* leave the equalizer parameters on their default values */
- /* leave the final AGC parameters on their default values */
- {0x41,0x00}, /* @ MSB of front-end derotator frequency */
- {0x42,0x00}, /* @ middle bytes " */
- {0x43,0x00}, /* @ LSB " */
- /* leave the carrier tracking loop parameters on default */
- /* leave the bit timing loop parameters at gefault */
- {0x56,0x4d}, /* set the filtune voltage to 2.7V, as recommended by */
- /* the cx24108 data sheet for symbol rates above 15MS/s */
- {0x57,0x00}, /* @ Filter sigma delta enabled, positive */
- {0x61,0x95}, /* GPIO pins 1-4 have special function */
- {0x62,0x05}, /* GPIO pin 5 has special function, pin 6 is GPIO */
- {0x63,0x00}, /* All GPIO pins use CMOS output characteristics */
- {0x64,0x20}, /* GPIO 6 is input, all others are outputs */
- {0x6d,0x30}, /* tuner auto mode clock freq 62kHz */
- {0x70,0x15}, /* use auto mode, tuner word is 21 bits long */
- {0x73,0x00}, /* @ disable several demod bypasses */
- {0x74,0x00}, /* @ " */
- {0x75,0x00} /* @ " */
- /* the remaining registers are for SEC */
- };
-
-
-static int cx24110_writereg (struct cx24110_state* state, int reg, int data)
-{
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
- int err;
-
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- dprintk ("%s: writereg error (err == %i, reg == 0x%02x,"
- " data == 0x%02x)\n", __FUNCTION__, err, reg, data);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static int cx24110_readreg (struct cx24110_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2) return ret;
-
- return b1[0];
-}
-
-static int cx24110_set_inversion (struct cx24110_state* state, fe_spectral_inversion_t inversion)
-{
-/* fixme (low): error handling */
-
- switch (inversion) {
- case INVERSION_OFF:
- cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1);
- /* AcqSpectrInvDis on. No idea why someone should want this */
- cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)&0xf7);
- /* Initial value 0 at start of acq */
- cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)&0xef);
- /* current value 0 */
- /* The cx24110 manual tells us this reg is read-only.
- But what the heck... set it ayways */
- break;
- case INVERSION_ON:
- cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1);
- /* AcqSpectrInvDis on. No idea why someone should want this */
- cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)|0x08);
- /* Initial value 1 at start of acq */
- cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)|0x10);
- /* current value 1 */
- break;
- case INVERSION_AUTO:
- cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xfe);
- /* AcqSpectrInvDis off. Leave initial & current states as is */
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int cx24110_set_fec (struct cx24110_state* state, fe_code_rate_t fec)
-{
-/* fixme (low): error handling */
-
- static const int rate[]={-1,1,2,3,5,7,-1};
- static const int g1[]={-1,0x01,0x02,0x05,0x15,0x45,-1};
- static const int g2[]={-1,0x01,0x03,0x06,0x1a,0x7a,-1};
-
- /* Well, the AutoAcq engine of the cx24106 and 24110 automatically
- searches all enabled viterbi rates, and can handle non-standard
- rates as well. */
-
- if (fec>FEC_AUTO)
- fec=FEC_AUTO;
-
- if (fec==FEC_AUTO) { /* (re-)establish AutoAcq behaviour */
- cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xdf);
- /* clear AcqVitDis bit */
- cx24110_writereg(state,0x18,0xae);
- /* allow all DVB standard code rates */
- cx24110_writereg(state,0x05,(cx24110_readreg(state,0x05)&0xf0)|0x3);
- /* set nominal Viterbi rate 3/4 */
- cx24110_writereg(state,0x22,(cx24110_readreg(state,0x22)&0xf0)|0x3);
- /* set current Viterbi rate 3/4 */
- cx24110_writereg(state,0x1a,0x05); cx24110_writereg(state,0x1b,0x06);
- /* set the puncture registers for code rate 3/4 */
- return 0;
- } else {
- cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x20);
- /* set AcqVitDis bit */
- if(rate[fec]>0) {
- cx24110_writereg(state,0x05,(cx24110_readreg(state,0x05)&0xf0)|rate[fec]);
- /* set nominal Viterbi rate */
- cx24110_writereg(state,0x22,(cx24110_readreg(state,0x22)&0xf0)|rate[fec]);
- /* set current Viterbi rate */
- cx24110_writereg(state,0x1a,g1[fec]);
- cx24110_writereg(state,0x1b,g2[fec]);
- /* not sure if this is the right way: I always used AutoAcq mode */
- } else
- return -EOPNOTSUPP;
-/* fixme (low): which is the correct return code? */
- };
- return 0;
-}
-
-static fe_code_rate_t cx24110_get_fec (struct cx24110_state* state)
-{
- int i;
-
- i=cx24110_readreg(state,0x22)&0x0f;
- if(!(i&0x08)) {
- return FEC_1_2 + i - 1;
- } else {
-/* fixme (low): a special code rate has been selected. In theory, we need to
- return a denominator value, a numerator value, and a pair of puncture
- maps to correctly describe this mode. But this should never happen in
- practice, because it cannot be set by cx24110_get_fec. */
- return FEC_NONE;
- }
-}
-
-static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate)
-{
-/* fixme (low): add error handling */
- u32 ratio;
- u32 tmp, fclk, BDRI;
-
- static const u32 bands[]={5000000UL,15000000UL,90999000UL/2};
- int i;
-
- dprintk("cx24110 debug: entering %s(%d)\n",__FUNCTION__,srate);
- if (srate>90999000UL/2)
- srate=90999000UL/2;
- if (srate<500000)
- srate=500000;
-
- for(i=0;(i<sizeof(bands)/sizeof(bands[0]))&&(srate>bands[i]);i++)
- ;
- /* first, check which sample rate is appropriate: 45, 60 80 or 90 MHz,
- and set the PLL accordingly (R07[1:0] Fclk, R06[7:4] PLLmult,
- R06[3:0] PLLphaseDetGain */
- tmp=cx24110_readreg(state,0x07)&0xfc;
- if(srate<90999000UL/4) { /* sample rate 45MHz*/
- cx24110_writereg(state,0x07,tmp);
- cx24110_writereg(state,0x06,0x78);
- fclk=90999000UL/2;
- } else if(srate<60666000UL/2) { /* sample rate 60MHz */
- cx24110_writereg(state,0x07,tmp|0x1);
- cx24110_writereg(state,0x06,0xa5);
- fclk=60666000UL;
- } else if(srate<80888000UL/2) { /* sample rate 80MHz */
- cx24110_writereg(state,0x07,tmp|0x2);
- cx24110_writereg(state,0x06,0x87);
- fclk=80888000UL;
- } else { /* sample rate 90MHz */
- cx24110_writereg(state,0x07,tmp|0x3);
- cx24110_writereg(state,0x06,0x78);
- fclk=90999000UL;
- };
- dprintk("cx24110 debug: fclk %d Hz\n",fclk);
- /* we need to divide two integers with approx. 27 bits in 32 bit
- arithmetic giving a 25 bit result */
- /* the maximum dividend is 90999000/2, 0x02b6446c, this number is
- also the most complex divisor. Hence, the dividend has,
- assuming 32bit unsigned arithmetic, 6 clear bits on top, the
- divisor 2 unused bits at the bottom. Also, the quotient is
- always less than 1/2. Borrowed from VES1893.c, of course */
-
- tmp=srate<<6;
- BDRI=fclk>>2;
- ratio=(tmp/BDRI);
-
- tmp=(tmp%BDRI)<<8;
- ratio=(ratio<<8)+(tmp/BDRI);
-
- tmp=(tmp%BDRI)<<8;
- ratio=(ratio<<8)+(tmp/BDRI);
-
- tmp=(tmp%BDRI)<<1;
- ratio=(ratio<<1)+(tmp/BDRI);
-
- dprintk("srate= %d (range %d, up to %d)\n", srate,i,bands[i]);
- dprintk("fclk = %d\n", fclk);
- dprintk("ratio= %08x\n", ratio);
-
- cx24110_writereg(state, 0x1, (ratio>>16)&0xff);
- cx24110_writereg(state, 0x2, (ratio>>8)&0xff);
- cx24110_writereg(state, 0x3, (ratio)&0xff);
-
- return 0;
-
-}
-
-int cx24110_pll_write (struct dvb_frontend* fe, u32 data)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
-/* tuner data is 21 bits long, must be left-aligned in data */
-/* tuner cx24108 is written through a dedicated 3wire interface on the demod chip */
-/* FIXME (low): add error handling, avoid infinite loops if HW fails... */
-
- dprintk("cx24110 debug: cx24108_write(%8.8x)\n",data);
-
- cx24110_writereg(state,0x6d,0x30); /* auto mode at 62kHz */
- cx24110_writereg(state,0x70,0x15); /* auto mode 21 bits */
-
- /* if the auto tuner writer is still busy, clear it out */
- while (cx24110_readreg(state,0x6d)&0x80)
- cx24110_writereg(state,0x72,0);
-
- /* write the topmost 8 bits */
- cx24110_writereg(state,0x72,(data>>24)&0xff);
-
- /* wait for the send to be completed */
- while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
- ;
-
- /* send another 8 bytes */
- cx24110_writereg(state,0x72,(data>>16)&0xff);
- while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
- ;
-
- /* and the topmost 5 bits of this byte */
- cx24110_writereg(state,0x72,(data>>8)&0xff);
- while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
- ;
-
- /* now strobe the enable line once */
- cx24110_writereg(state,0x6d,0x32);
- cx24110_writereg(state,0x6d,0x30);
-
- return 0;
-}
-
-static int cx24110_initfe(struct dvb_frontend* fe)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-/* fixme (low): error handling */
- int i;
-
- dprintk("%s: init chip\n", __FUNCTION__);
-
- for(i=0;i<sizeof(cx24110_regdata)/sizeof(cx24110_regdata[0]);i++) {
- cx24110_writereg(state, cx24110_regdata[i].reg, cx24110_regdata[i].data);
- };
-
- return 0;
-}
-
-static int cx24110_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
- switch (voltage) {
- case SEC_VOLTAGE_13:
- return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&0x3b)|0xc0);
- case SEC_VOLTAGE_18:
- return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&0x3b)|0x40);
- default:
- return -EINVAL;
- };
-}
-
-static int cx24110_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
-{
- int rv, bit;
- struct cx24110_state *state = fe->demodulator_priv;
- unsigned long timeout;
-
- if (burst == SEC_MINI_A)
- bit = 0x00;
- else if (burst == SEC_MINI_B)
- bit = 0x08;
- else
- return -EINVAL;
-
- rv = cx24110_readreg(state, 0x77);
- if (!(rv & 0x04))
- cx24110_writereg(state, 0x77, rv | 0x04);
-
- rv = cx24110_readreg(state, 0x76);
- cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40 | bit));
- timeout = jiffies + msecs_to_jiffies(100);
- while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40))
- ; /* wait for LNB ready */
-
- return 0;
-}
-
-static int cx24110_send_diseqc_msg(struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd *cmd)
-{
- int i, rv;
- struct cx24110_state *state = fe->demodulator_priv;
- unsigned long timeout;
-
- if (cmd->msg_len < 3 || cmd->msg_len > 6)
- return -EINVAL; /* not implemented */
-
- for (i = 0; i < cmd->msg_len; i++)
- cx24110_writereg(state, 0x79 + i, cmd->msg[i]);
-
- rv = cx24110_readreg(state, 0x77);
- if (rv & 0x04) {
- cx24110_writereg(state, 0x77, rv & ~0x04);
- msleep(30); /* reportedly fixes switching problems */
- }
-
- rv = cx24110_readreg(state, 0x76);
-
- cx24110_writereg(state, 0x76, ((rv & 0x90) | 0x40) | ((cmd->msg_len-3) & 3));
- timeout = jiffies + msecs_to_jiffies(100);
- while (!time_after(jiffies, timeout) && !(cx24110_readreg(state, 0x76) & 0x40))
- ; /* wait for LNB ready */
-
- return 0;
-}
-
-static int cx24110_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
- int sync = cx24110_readreg (state, 0x55);
-
- *status = 0;
-
- if (sync & 0x10)
- *status |= FE_HAS_SIGNAL;
-
- if (sync & 0x08)
- *status |= FE_HAS_CARRIER;
-
- sync = cx24110_readreg (state, 0x08);
-
- if (sync & 0x40)
- *status |= FE_HAS_VITERBI;
-
- if (sync & 0x20)
- *status |= FE_HAS_SYNC;
-
- if ((sync & 0x60) == 0x60)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int cx24110_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
- /* fixme (maybe): value range is 16 bit. Scale? */
- if(cx24110_readreg(state,0x24)&0x10) {
- /* the Viterbi error counter has finished one counting window */
- cx24110_writereg(state,0x24,0x04); /* select the ber reg */
- state->lastber=cx24110_readreg(state,0x25)|
- (cx24110_readreg(state,0x26)<<8);
- cx24110_writereg(state,0x24,0x04); /* start new count window */
- cx24110_writereg(state,0x24,0x14);
- }
- *ber = state->lastber;
-
- return 0;
-}
-
-static int cx24110_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
-/* no provision in hardware. Read the frontend AGC accumulator. No idea how to scale this, but I know it is 2s complement */
- u8 signal = cx24110_readreg (state, 0x27)+128;
- *signal_strength = (signal << 8) | signal;
-
- return 0;
-}
-
-static int cx24110_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
- /* no provision in hardware. Can be computed from the Es/N0 estimator, but I don't know how. */
- if(cx24110_readreg(state,0x6a)&0x80) {
- /* the Es/N0 error counter has finished one counting window */
- state->lastesn0=cx24110_readreg(state,0x69)|
- (cx24110_readreg(state,0x68)<<8);
- cx24110_writereg(state,0x6a,0x84); /* start new count window */
- }
- *snr = state->lastesn0;
-
- return 0;
-}
-
-static int cx24110_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct cx24110_state *state = fe->demodulator_priv;
- u32 lastbyer;
-
- if(cx24110_readreg(state,0x10)&0x40) {
- /* the RS error counter has finished one counting window */
- cx24110_writereg(state,0x10,0x60); /* select the byer reg */
- lastbyer=cx24110_readreg(state,0x12)|
- (cx24110_readreg(state,0x13)<<8)|
- (cx24110_readreg(state,0x14)<<16);
- cx24110_writereg(state,0x10,0x70); /* select the bler reg */
- state->lastbler=cx24110_readreg(state,0x12)|
- (cx24110_readreg(state,0x13)<<8)|
- (cx24110_readreg(state,0x14)<<16);
- cx24110_writereg(state,0x10,0x20); /* start new count window */
- }
- *ucblocks = state->lastbler;
-
- return 0;
-}
-
-static int cx24110_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- cx24110_set_inversion (state, p->inversion);
- cx24110_set_fec (state, p->u.qpsk.fec_inner);
- cx24110_set_symbolrate (state, p->u.qpsk.symbol_rate);
- cx24110_writereg(state,0x04,0x05); /* start aquisition */
-
- return 0;
-}
-
-static int cx24110_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx24110_state *state = fe->demodulator_priv;
- s32 afc; unsigned sclk;
-
-/* cannot read back tuner settings (freq). Need to have some private storage */
-
- sclk = cx24110_readreg (state, 0x07) & 0x03;
-/* ok, real AFC (FEDR) freq. is afc/2^24*fsamp, fsamp=45/60/80/90MHz.
- * Need 64 bit arithmetic. Is thiss possible in the kernel? */
- if (sclk==0) sclk=90999000L/2L;
- else if (sclk==1) sclk=60666000L;
- else if (sclk==2) sclk=80888000L;
- else sclk=90999000L;
- sclk>>=8;
- afc = sclk*(cx24110_readreg (state, 0x44)&0x1f)+
- ((sclk*cx24110_readreg (state, 0x45))>>8)+
- ((sclk*cx24110_readreg (state, 0x46))>>16);
-
- p->frequency += afc;
- p->inversion = (cx24110_readreg (state, 0x22) & 0x10) ?
- INVERSION_ON : INVERSION_OFF;
- p->u.qpsk.fec_inner = cx24110_get_fec (state);
-
- return 0;
-}
-
-static int cx24110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct cx24110_state *state = fe->demodulator_priv;
-
- return cx24110_writereg(state,0x76,(cx24110_readreg(state,0x76)&~0x10)|(((tone==SEC_TONE_ON))?0x10:0));
-}
-
-static void cx24110_release(struct dvb_frontend* fe)
-{
- struct cx24110_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops cx24110_ops;
-
-struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
- struct i2c_adapter* i2c)
-{
- struct cx24110_state* state = NULL;
- int ret;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct cx24110_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->lastber = 0;
- state->lastbler = 0;
- state->lastesn0 = 0;
-
- /* check if the demod is there */
- ret = cx24110_readreg(state, 0x00);
- if ((ret != 0x5a) && (ret != 0x69)) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &cx24110_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops cx24110_ops = {
-
- .info = {
- .name = "Conexant CX24110 DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 1011, /* kHz for QPSK frontends */
- .frequency_tolerance = 29500,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_RECOVER
- },
-
- .release = cx24110_release,
-
- .init = cx24110_initfe,
- .set_frontend = cx24110_set_frontend,
- .get_frontend = cx24110_get_frontend,
- .read_status = cx24110_read_status,
- .read_ber = cx24110_read_ber,
- .read_signal_strength = cx24110_read_signal_strength,
- .read_snr = cx24110_read_snr,
- .read_ucblocks = cx24110_read_ucblocks,
-
- .diseqc_send_master_cmd = cx24110_send_diseqc_msg,
- .set_tone = cx24110_set_tone,
- .set_voltage = cx24110_set_voltage,
- .diseqc_send_burst = cx24110_diseqc_send_burst,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Conexant CX24110 DVB-S Demodulator driver");
-MODULE_AUTHOR("Peter Hettkamp");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(cx24110_attach);
-EXPORT_SYMBOL(cx24110_pll_write);
diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h
deleted file mode 100644
index b354a64e0e7..00000000000
--- a/drivers/media/dvb/frontends/cx24110.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- cx24110 - Single Chip Satellite Channel Receiver driver module
-
- Copyright (C) 2002 Peter Hettkamp <peter.hettkamp@htp-tel.de> based on
- work
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
-
- 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.
-
-*/
-
-#ifndef CX24110_H
-#define CX24110_H
-
-#include <linux/dvb/frontend.h>
-
-struct cx24110_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-};
-
-extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
- struct i2c_adapter* i2c);
-
-extern int cx24110_pll_write(struct dvb_frontend* fe, u32 data);
-
-#endif // CX24110_H
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
deleted file mode 100644
index 274a87b7a5d..00000000000
--- a/drivers/media/dvb/frontends/cx24123.c
+++ /dev/null
@@ -1,1023 +0,0 @@
-/*
- Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver
-
- Copyright (C) 2005 Steven Toth <stoth@hauppauge.com>
-
- Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-
-#include "dvb_frontend.h"
-#include "cx24123.h"
-
-#define XTAL 10111000
-
-static int force_band;
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk (KERN_DEBUG "cx24123: " args); \
- } while (0)
-
-struct cx24123_state
-{
- struct i2c_adapter* i2c;
- const struct cx24123_config* config;
-
- struct dvb_frontend frontend;
-
- u32 lastber;
- u16 snr;
-
- /* Some PLL specifics for tuning */
- u32 VCAarg;
- u32 VGAarg;
- u32 bandselectarg;
- u32 pllarg;
- u32 FILTune;
-
- /* The Demod/Tuner can't easily provide these, we cache them */
- u32 currentfreq;
- u32 currentsymbolrate;
-};
-
-/* Various tuner defaults need to be established for a given symbol rate Sps */
-static struct
-{
- u32 symbolrate_low;
- u32 symbolrate_high;
- u32 VCAprogdata;
- u32 VGAprogdata;
- u32 FILTune;
-} cx24123_AGC_vals[] =
-{
- {
- .symbolrate_low = 1000000,
- .symbolrate_high = 4999999,
- /* the specs recommend other values for VGA offsets,
- but tests show they are wrong */
- .VGAprogdata = (1 << 19) | (0x180 << 9) | 0x1e0,
- .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x07,
- .FILTune = 0x27f /* 0.41 V */
- },
- {
- .symbolrate_low = 5000000,
- .symbolrate_high = 14999999,
- .VGAprogdata = (1 << 19) | (0x180 << 9) | 0x1e0,
- .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x1f,
- .FILTune = 0x317 /* 0.90 V */
- },
- {
- .symbolrate_low = 15000000,
- .symbolrate_high = 45000000,
- .VGAprogdata = (1 << 19) | (0x100 << 9) | 0x180,
- .VCAprogdata = (2 << 19) | (0x07 << 9) | 0x3f,
- .FILTune = 0x145 /* 2.70 V */
- },
-};
-
-/*
- * Various tuner defaults need to be established for a given frequency kHz.
- * fixme: The bounds on the bands do not match the doc in real life.
- * fixme: Some of them have been moved, other might need adjustment.
- */
-static struct
-{
- u32 freq_low;
- u32 freq_high;
- u32 VCOdivider;
- u32 progdata;
-} cx24123_bandselect_vals[] =
-{
- /* band 1 */
- {
- .freq_low = 950000,
- .freq_high = 1074999,
- .VCOdivider = 4,
- .progdata = (0 << 19) | (0 << 9) | 0x40,
- },
-
- /* band 2 */
- {
- .freq_low = 1075000,
- .freq_high = 1177999,
- .VCOdivider = 4,
- .progdata = (0 << 19) | (0 << 9) | 0x80,
- },
-
- /* band 3 */
- {
- .freq_low = 1178000,
- .freq_high = 1295999,
- .VCOdivider = 2,
- .progdata = (0 << 19) | (1 << 9) | 0x01,
- },
-
- /* band 4 */
- {
- .freq_low = 1296000,
- .freq_high = 1431999,
- .VCOdivider = 2,
- .progdata = (0 << 19) | (1 << 9) | 0x02,
- },
-
- /* band 5 */
- {
- .freq_low = 1432000,
- .freq_high = 1575999,
- .VCOdivider = 2,
- .progdata = (0 << 19) | (1 << 9) | 0x04,
- },
-
- /* band 6 */
- {
- .freq_low = 1576000,
- .freq_high = 1717999,
- .VCOdivider = 2,
- .progdata = (0 << 19) | (1 << 9) | 0x08,
- },
-
- /* band 7 */
- {
- .freq_low = 1718000,
- .freq_high = 1855999,
- .VCOdivider = 2,
- .progdata = (0 << 19) | (1 << 9) | 0x10,
- },
-
- /* band 8 */
- {
- .freq_low = 1856000,
- .freq_high = 2035999,
- .VCOdivider = 2,
- .progdata = (0 << 19) | (1 << 9) | 0x20,
- },
-
- /* band 9 */
- {
- .freq_low = 2036000,
- .freq_high = 2150000,
- .VCOdivider = 2,
- .progdata = (0 << 19) | (1 << 9) | 0x40,
- },
-};
-
-static struct {
- u8 reg;
- u8 data;
-} cx24123_regdata[] =
-{
- {0x00, 0x03}, /* Reset system */
- {0x00, 0x00}, /* Clear reset */
- {0x03, 0x07}, /* QPSK, DVB, Auto Acquisition (default) */
- {0x04, 0x10}, /* MPEG */
- {0x05, 0x04}, /* MPEG */
- {0x06, 0x31}, /* MPEG (default) */
- {0x0b, 0x00}, /* Freq search start point (default) */
- {0x0c, 0x00}, /* Demodulator sample gain (default) */
- {0x0d, 0x02}, /* Frequency search range = Fsymbol / 4 (default) */
- {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */
- {0x0f, 0xfe}, /* FEC search mask (all supported codes) */
- {0x10, 0x01}, /* Default search inversion, no repeat (default) */
- {0x16, 0x00}, /* Enable reading of frequency */
- {0x17, 0x01}, /* Enable EsNO Ready Counter */
- {0x1c, 0x80}, /* Enable error counter */
- {0x20, 0x00}, /* Tuner burst clock rate = 500KHz */
- {0x21, 0x15}, /* Tuner burst mode, word length = 0x15 */
- {0x28, 0x00}, /* Enable FILTERV with positive pol., DiSEqC 2.x off */
- {0x29, 0x00}, /* DiSEqC LNB_DC off */
- {0x2a, 0xb0}, /* DiSEqC Parameters (default) */
- {0x2b, 0x73}, /* DiSEqC Tone Frequency (default) */
- {0x2c, 0x00}, /* DiSEqC Message (0x2c - 0x31) */
- {0x2d, 0x00},
- {0x2e, 0x00},
- {0x2f, 0x00},
- {0x30, 0x00},
- {0x31, 0x00},
- {0x32, 0x8c}, /* DiSEqC Parameters (default) */
- {0x33, 0x00}, /* Interrupts off (0x33 - 0x34) */
- {0x34, 0x00},
- {0x35, 0x03}, /* DiSEqC Tone Amplitude (default) */
- {0x36, 0x02}, /* DiSEqC Parameters (default) */
- {0x37, 0x3a}, /* DiSEqC Parameters (default) */
- {0x3a, 0x00}, /* Enable AGC accumulator (for signal strength) */
- {0x44, 0x00}, /* Constellation (default) */
- {0x45, 0x00}, /* Symbol count (default) */
- {0x46, 0x0d}, /* Symbol rate estimator on (default) */
- {0x56, 0x41}, /* Various (default) */
- {0x57, 0xff}, /* Error Counter Window (default) */
- {0x67, 0x83}, /* Non-DCII symbol clock */
-};
-
-static int cx24123_writereg(struct cx24123_state* state, int reg, int data)
-{
- u8 buf[] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
- int err;
-
- if (debug>1)
- printk("cx24123: %s: write reg 0x%02x, value 0x%02x\n",
- __FUNCTION__,reg, data);
-
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- printk("%s: writereg error(err == %i, reg == 0x%02x,"
- " data == 0x%02x)\n", __FUNCTION__, err, reg, data);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static int cx24123_readreg(struct cx24123_state* state, u8 reg)
-{
- int ret;
- u8 b0[] = { reg };
- u8 b1[] = { 0 };
- struct i2c_msg msg[] = {
- { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 }
- };
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2) {
- printk("%s: reg=0x%x (error=%d)\n", __FUNCTION__, reg, ret);
- return ret;
- }
-
- if (debug>1)
- printk("cx24123: read reg 0x%02x, value 0x%02x\n",reg, ret);
-
- return b1[0];
-}
-
-static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion)
-{
- u8 nom_reg = cx24123_readreg(state, 0x0e);
- u8 auto_reg = cx24123_readreg(state, 0x10);
-
- switch (inversion) {
- case INVERSION_OFF:
- dprintk("%s: inversion off\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg & ~0x80);
- cx24123_writereg(state, 0x10, auto_reg | 0x80);
- break;
- case INVERSION_ON:
- dprintk("%s: inversion on\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x80);
- cx24123_writereg(state, 0x10, auto_reg | 0x80);
- break;
- case INVERSION_AUTO:
- dprintk("%s: inversion auto\n",__FUNCTION__);
- cx24123_writereg(state, 0x10, auto_reg & ~0x80);
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion)
-{
- u8 val;
-
- val = cx24123_readreg(state, 0x1b) >> 7;
-
- if (val == 0) {
- dprintk("%s: read inversion off\n",__FUNCTION__);
- *inversion = INVERSION_OFF;
- } else {
- dprintk("%s: read inversion on\n",__FUNCTION__);
- *inversion = INVERSION_ON;
- }
-
- return 0;
-}
-
-static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)
-{
- u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07;
-
- if ( (fec < FEC_NONE) || (fec > FEC_AUTO) )
- fec = FEC_AUTO;
-
- switch (fec) {
- case FEC_1_2:
- dprintk("%s: set FEC to 1/2\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x01);
- cx24123_writereg(state, 0x0f, 0x02);
- break;
- case FEC_2_3:
- dprintk("%s: set FEC to 2/3\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x02);
- cx24123_writereg(state, 0x0f, 0x04);
- break;
- case FEC_3_4:
- dprintk("%s: set FEC to 3/4\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x03);
- cx24123_writereg(state, 0x0f, 0x08);
- break;
- case FEC_4_5:
- dprintk("%s: set FEC to 4/5\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x04);
- cx24123_writereg(state, 0x0f, 0x10);
- break;
- case FEC_5_6:
- dprintk("%s: set FEC to 5/6\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x05);
- cx24123_writereg(state, 0x0f, 0x20);
- break;
- case FEC_6_7:
- dprintk("%s: set FEC to 6/7\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x06);
- cx24123_writereg(state, 0x0f, 0x40);
- break;
- case FEC_7_8:
- dprintk("%s: set FEC to 7/8\n",__FUNCTION__);
- cx24123_writereg(state, 0x0e, nom_reg | 0x07);
- cx24123_writereg(state, 0x0f, 0x80);
- break;
- case FEC_AUTO:
- dprintk("%s: set FEC to auto\n",__FUNCTION__);
- cx24123_writereg(state, 0x0f, 0xfe);
- break;
- default:
- return -EOPNOTSUPP;
- }
-
- return 0;
-}
-
-static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec)
-{
- int ret;
-
- ret = cx24123_readreg (state, 0x1b);
- if (ret < 0)
- return ret;
- ret = ret & 0x07;
-
- switch (ret) {
- case 1:
- *fec = FEC_1_2;
- break;
- case 2:
- *fec = FEC_2_3;
- break;
- case 3:
- *fec = FEC_3_4;
- break;
- case 4:
- *fec = FEC_4_5;
- break;
- case 5:
- *fec = FEC_5_6;
- break;
- case 6:
- *fec = FEC_6_7;
- break;
- case 7:
- *fec = FEC_7_8;
- break;
- default:
- /* this can happen when there's no lock */
- *fec = FEC_NONE;
- }
-
- return 0;
-}
-
-/* Approximation of closest integer of log2(a/b). It actually gives the
- lowest integer i such that 2^i >= round(a/b) */
-static u32 cx24123_int_log2(u32 a, u32 b)
-{
- u32 exp, nearest = 0;
- u32 div = a / b;
- if(a % b >= b / 2) ++div;
- if(div < (1 << 31))
- {
- for(exp = 1; div > exp; nearest++)
- exp += exp;
- }
- return nearest;
-}
-
-static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate)
-{
- u32 tmp, sample_rate, ratio, sample_gain;
- u8 pll_mult;
-
- /* check if symbol rate is within limits */
- if ((srate > state->frontend.ops.info.symbol_rate_max) ||
- (srate < state->frontend.ops.info.symbol_rate_min))
- return -EOPNOTSUPP;;
-
- /* choose the sampling rate high enough for the required operation,
- while optimizing the power consumed by the demodulator */
- if (srate < (XTAL*2)/2)
- pll_mult = 2;
- else if (srate < (XTAL*3)/2)
- pll_mult = 3;
- else if (srate < (XTAL*4)/2)
- pll_mult = 4;
- else if (srate < (XTAL*5)/2)
- pll_mult = 5;
- else if (srate < (XTAL*6)/2)
- pll_mult = 6;
- else if (srate < (XTAL*7)/2)
- pll_mult = 7;
- else if (srate < (XTAL*8)/2)
- pll_mult = 8;
- else
- pll_mult = 9;
-
-
- sample_rate = pll_mult * XTAL;
-
- /*
- SYSSymbolRate[21:0] = (srate << 23) / sample_rate
-
- We have to use 32 bit unsigned arithmetic without precision loss.
- The maximum srate is 45000000 or 0x02AEA540. This number has
- only 6 clear bits on top, hence we can shift it left only 6 bits
- at a time. Borrowed from cx24110.c
- */
-
- tmp = srate << 6;
- ratio = tmp / sample_rate;
-
- tmp = (tmp % sample_rate) << 6;
- ratio = (ratio << 6) + (tmp / sample_rate);
-
- tmp = (tmp % sample_rate) << 6;
- ratio = (ratio << 6) + (tmp / sample_rate);
-
- tmp = (tmp % sample_rate) << 5;
- ratio = (ratio << 5) + (tmp / sample_rate);
-
-
- cx24123_writereg(state, 0x01, pll_mult * 6);
-
- cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f );
- cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff );
- cx24123_writereg(state, 0x0a, (ratio ) & 0xff );
-
- /* also set the demodulator sample gain */
- sample_gain = cx24123_int_log2(sample_rate, srate);
- tmp = cx24123_readreg(state, 0x0c) & ~0xe0;
- cx24123_writereg(state, 0x0c, tmp | sample_gain << 5);
-
- dprintk("%s: srate=%d, ratio=0x%08x, sample_rate=%i sample_gain=%d\n", __FUNCTION__, srate, ratio, sample_rate, sample_gain);
-
- return 0;
-}
-
-/*
- * Based on the required frequency and symbolrate, the tuner AGC has to be configured
- * and the correct band selected. Calculate those values
- */
-static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- u32 ndiv = 0, adiv = 0, vco_div = 0;
- int i = 0;
- int pump = 2;
- int band = 0;
- int num_bands = sizeof(cx24123_bandselect_vals) / sizeof(cx24123_bandselect_vals[0]);
-
- /* Defaults for low freq, low rate */
- state->VCAarg = cx24123_AGC_vals[0].VCAprogdata;
- state->VGAarg = cx24123_AGC_vals[0].VGAprogdata;
- state->bandselectarg = cx24123_bandselect_vals[0].progdata;
- vco_div = cx24123_bandselect_vals[0].VCOdivider;
-
- /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */
- for (i = 0; i < sizeof(cx24123_AGC_vals) / sizeof(cx24123_AGC_vals[0]); i++)
- {
- if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) &&
- (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) {
- state->VCAarg = cx24123_AGC_vals[i].VCAprogdata;
- state->VGAarg = cx24123_AGC_vals[i].VGAprogdata;
- state->FILTune = cx24123_AGC_vals[i].FILTune;
- }
- }
-
- /* determine the band to use */
- if(force_band < 1 || force_band > num_bands)
- {
- for (i = 0; i < num_bands; i++)
- {
- if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) &&
- (cx24123_bandselect_vals[i].freq_high >= p->frequency) )
- band = i;
- }
- }
- else
- band = force_band - 1;
-
- state->bandselectarg = cx24123_bandselect_vals[band].progdata;
- vco_div = cx24123_bandselect_vals[band].VCOdivider;
-
- /* determine the charge pump current */
- if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 )
- pump = 0x01;
- else
- pump = 0x02;
-
- /* Determine the N/A dividers for the requested lband freq (in kHz). */
- /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */
- ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff;
- adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f;
-
- if (adiv == 0)
- ndiv++;
-
- /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */
- state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv;
-
- return 0;
-}
-
-/*
- * Tuner data is 21 bits long, must be left-aligned in data.
- * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip.
- */
-static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- unsigned long timeout;
-
- dprintk("%s: pll writereg called, data=0x%08x\n",__FUNCTION__,data);
-
- /* align the 21 bytes into to bit23 boundary */
- data = data << 3;
-
- /* Reset the demod pll word length to 0x15 bits */
- cx24123_writereg(state, 0x21, 0x15);
-
- /* write the msb 8 bits, wait for the send to be completed */
- timeout = jiffies + msecs_to_jiffies(40);
- cx24123_writereg(state, 0x22, (data >> 16) & 0xff);
- while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {
- if (time_after(jiffies, timeout)) {
- printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);
- return -EREMOTEIO;
- }
- msleep(10);
- }
-
- /* send another 8 bytes, wait for the send to be completed */
- timeout = jiffies + msecs_to_jiffies(40);
- cx24123_writereg(state, 0x22, (data>>8) & 0xff );
- while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {
- if (time_after(jiffies, timeout)) {
- printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);
- return -EREMOTEIO;
- }
- msleep(10);
- }
-
- /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */
- timeout = jiffies + msecs_to_jiffies(40);
- cx24123_writereg(state, 0x22, (data) & 0xff );
- while ((cx24123_readreg(state, 0x20) & 0x80)) {
- if (time_after(jiffies, timeout)) {
- printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__);
- return -EREMOTEIO;
- }
- msleep(10);
- }
-
- /* Trigger the demod to configure the tuner */
- cx24123_writereg(state, 0x20, cx24123_readreg(state, 0x20) | 2);
- cx24123_writereg(state, 0x20, cx24123_readreg(state, 0x20) & 0xfd);
-
- return 0;
-}
-
-static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- u8 val;
-
- dprintk("frequency=%i\n", p->frequency);
-
- if (cx24123_pll_calculate(fe, p) != 0) {
- printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__);
- return -EINVAL;
- }
-
- /* Write the new VCO/VGA */
- cx24123_pll_writereg(fe, p, state->VCAarg);
- cx24123_pll_writereg(fe, p, state->VGAarg);
-
- /* Write the new bandselect and pll args */
- cx24123_pll_writereg(fe, p, state->bandselectarg);
- cx24123_pll_writereg(fe, p, state->pllarg);
-
- /* set the FILTUNE voltage */
- val = cx24123_readreg(state, 0x28) & ~0x3;
- cx24123_writereg(state, 0x27, state->FILTune >> 2);
- cx24123_writereg(state, 0x28, val | (state->FILTune & 0x3));
-
- dprintk("%s: pll tune VCA=%d, band=%d, pll=%d\n",__FUNCTION__,state->VCAarg,
- state->bandselectarg,state->pllarg);
-
- return 0;
-}
-
-static int cx24123_initfe(struct dvb_frontend* fe)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- int i;
-
- dprintk("%s: init frontend\n",__FUNCTION__);
-
- /* Configure the demod to a good set of defaults */
- for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++)
- cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data);
-
- return 0;
-}
-
-static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- u8 val;
-
- val = cx24123_readreg(state, 0x29) & ~0x40;
-
- switch (voltage) {
- case SEC_VOLTAGE_13:
- dprintk("%s: setting voltage 13V\n", __FUNCTION__);
- return cx24123_writereg(state, 0x29, val & 0x7f);
- case SEC_VOLTAGE_18:
- dprintk("%s: setting voltage 18V\n", __FUNCTION__);
- return cx24123_writereg(state, 0x29, val | 0x80);
- default:
- return -EINVAL;
- };
-
- return 0;
-}
-
-/* wait for diseqc queue to become ready (or timeout) */
-static void cx24123_wait_for_diseqc(struct cx24123_state *state)
-{
- unsigned long timeout = jiffies + msecs_to_jiffies(200);
- while (!(cx24123_readreg(state, 0x29) & 0x40)) {
- if(time_after(jiffies, timeout)) {
- printk("%s: diseqc queue not ready, command may be lost.\n", __FUNCTION__);
- break;
- }
- msleep(10);
- }
-}
-
-static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- int i, val, tone;
-
- dprintk("%s:\n",__FUNCTION__);
-
- /* stop continuous tone if enabled */
- tone = cx24123_readreg(state, 0x29);
- if (tone & 0x10)
- cx24123_writereg(state, 0x29, tone & ~0x50);
-
- /* wait for diseqc queue ready */
- cx24123_wait_for_diseqc(state);
-
- /* select tone mode */
- cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb);
-
- for (i = 0; i < cmd->msg_len; i++)
- cx24123_writereg(state, 0x2C + i, cmd->msg[i]);
-
- val = cx24123_readreg(state, 0x29);
- cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3));
-
- /* wait for diseqc message to finish sending */
- cx24123_wait_for_diseqc(state);
-
- /* restart continuous tone if enabled */
- if (tone & 0x10) {
- cx24123_writereg(state, 0x29, tone & ~0x40);
- }
-
- return 0;
-}
-
-static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- int val, tone;
-
- dprintk("%s:\n", __FUNCTION__);
-
- /* stop continuous tone if enabled */
- tone = cx24123_readreg(state, 0x29);
- if (tone & 0x10)
- cx24123_writereg(state, 0x29, tone & ~0x50);
-
- /* wait for diseqc queue ready */
- cx24123_wait_for_diseqc(state);
-
- /* select tone mode */
- cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) | 0x4);
- msleep(30);
- val = cx24123_readreg(state, 0x29);
- if (burst == SEC_MINI_A)
- cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40 | 0x00));
- else if (burst == SEC_MINI_B)
- cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40 | 0x08));
- else
- return -EINVAL;
-
- cx24123_wait_for_diseqc(state);
- cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb);
-
- /* restart continuous tone if enabled */
- if (tone & 0x10) {
- cx24123_writereg(state, 0x29, tone & ~0x40);
- }
- return 0;
-}
-
-static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct cx24123_state *state = fe->demodulator_priv;
-
- int sync = cx24123_readreg(state, 0x14);
- int lock = cx24123_readreg(state, 0x20);
-
- *status = 0;
- if (lock & 0x01)
- *status |= FE_HAS_SIGNAL;
- if (sync & 0x02)
- *status |= FE_HAS_CARRIER;
- if (sync & 0x04)
- *status |= FE_HAS_VITERBI;
- if (sync & 0x08)
- *status |= FE_HAS_SYNC;
- if (sync & 0x80)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-/*
- * Configured to return the measurement of errors in blocks, because no UCBLOCKS value
- * is available, so this value doubles up to satisfy both measurements
- */
-static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct cx24123_state *state = fe->demodulator_priv;
-
- state->lastber =
- ((cx24123_readreg(state, 0x1c) & 0x3f) << 16) |
- (cx24123_readreg(state, 0x1d) << 8 |
- cx24123_readreg(state, 0x1e));
-
- /* Do the signal quality processing here, it's derived from the BER. */
- /* Scale the BER from a 24bit to a SNR 16 bit where higher = better */
- if (state->lastber < 5000)
- state->snr = 655*100;
- else if ( (state->lastber >= 5000) && (state->lastber < 55000) )
- state->snr = 655*90;
- else if ( (state->lastber >= 55000) && (state->lastber < 150000) )
- state->snr = 655*80;
- else if ( (state->lastber >= 150000) && (state->lastber < 250000) )
- state->snr = 655*70;
- else if ( (state->lastber >= 250000) && (state->lastber < 450000) )
- state->snr = 655*65;
- else
- state->snr = 0;
-
- dprintk("%s: BER = %d, S/N index = %d\n",__FUNCTION__,state->lastber, state->snr);
-
- *ber = state->lastber;
-
- return 0;
-}
-
-static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */
-
- dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength);
-
- return 0;
-}
-
-static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- *snr = state->snr;
-
- dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr);
-
- return 0;
-}
-
-static int cx24123_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- *ucblocks = state->lastber;
-
- dprintk("%s: ucblocks (ber) = %d\n",__FUNCTION__,*ucblocks);
-
- return 0;
-}
-
-static int cx24123_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx24123_state *state = fe->demodulator_priv;
-
- dprintk("%s: set_frontend\n",__FUNCTION__);
-
- if (state->config->set_ts_params)
- state->config->set_ts_params(fe, 0);
-
- state->currentfreq=p->frequency;
- state->currentsymbolrate = p->u.qpsk.symbol_rate;
-
- cx24123_set_inversion(state, p->inversion);
- cx24123_set_fec(state, p->u.qpsk.fec_inner);
- cx24123_set_symbolrate(state, p->u.qpsk.symbol_rate);
- cx24123_pll_tune(fe, p);
-
- /* Enable automatic aquisition and reset cycle */
- cx24123_writereg(state, 0x03, (cx24123_readreg(state, 0x03) | 0x07));
- cx24123_writereg(state, 0x00, 0x10);
- cx24123_writereg(state, 0x00, 0);
-
- return 0;
-}
-
-static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct cx24123_state *state = fe->demodulator_priv;
-
- dprintk("%s: get_frontend\n",__FUNCTION__);
-
- if (cx24123_get_inversion(state, &p->inversion) != 0) {
- printk("%s: Failed to get inversion status\n",__FUNCTION__);
- return -EREMOTEIO;
- }
- if (cx24123_get_fec(state, &p->u.qpsk.fec_inner) != 0) {
- printk("%s: Failed to get fec status\n",__FUNCTION__);
- return -EREMOTEIO;
- }
- p->frequency = state->currentfreq;
- p->u.qpsk.symbol_rate = state->currentsymbolrate;
-
- return 0;
-}
-
-static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct cx24123_state *state = fe->demodulator_priv;
- u8 val;
-
- /* wait for diseqc queue ready */
- cx24123_wait_for_diseqc(state);
-
- val = cx24123_readreg(state, 0x29) & ~0x40;
-
- switch (tone) {
- case SEC_TONE_ON:
- dprintk("%s: setting tone on\n", __FUNCTION__);
- return cx24123_writereg(state, 0x29, val | 0x10);
- case SEC_TONE_OFF:
- dprintk("%s: setting tone off\n",__FUNCTION__);
- return cx24123_writereg(state, 0x29, val & 0xef);
- default:
- printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone);
- return -EINVAL;
- }
-
- return 0;
-}
-
-static void cx24123_release(struct dvb_frontend* fe)
-{
- struct cx24123_state* state = fe->demodulator_priv;
- dprintk("%s\n",__FUNCTION__);
- kfree(state);
-}
-
-static struct dvb_frontend_ops cx24123_ops;
-
-struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
- struct i2c_adapter* i2c)
-{
- struct cx24123_state* state = NULL;
- int ret;
-
- dprintk("%s\n",__FUNCTION__);
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct cx24123_state), GFP_KERNEL);
- if (state == NULL) {
- printk("Unable to kmalloc\n");
- goto error;
- }
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->lastber = 0;
- state->snr = 0;
- state->VCAarg = 0;
- state->VGAarg = 0;
- state->bandselectarg = 0;
- state->pllarg = 0;
- state->currentfreq = 0;
- state->currentsymbolrate = 0;
-
- /* check if the demod is there */
- ret = cx24123_readreg(state, 0x00);
- if ((ret != 0xd1) && (ret != 0xe1)) {
- printk("Version != d1 or e1\n");
- goto error;
- }
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
-
- return NULL;
-}
-
-static struct dvb_frontend_ops cx24123_ops = {
-
- .info = {
- .name = "Conexant CX24123/CX24109",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 1011, /* kHz for QPSK frontends */
- .frequency_tolerance = 5000,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
- FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_RECOVER
- },
-
- .release = cx24123_release,
-
- .init = cx24123_initfe,
- .set_frontend = cx24123_set_frontend,
- .get_frontend = cx24123_get_frontend,
- .read_status = cx24123_read_status,
- .read_ber = cx24123_read_ber,
- .read_signal_strength = cx24123_read_signal_strength,
- .read_snr = cx24123_read_snr,
- .read_ucblocks = cx24123_read_ucblocks,
- .diseqc_send_master_cmd = cx24123_send_diseqc_msg,
- .diseqc_send_burst = cx24123_diseqc_send_burst,
- .set_tone = cx24123_set_tone,
- .set_voltage = cx24123_set_voltage,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
-
-module_param(force_band, int, 0644);
-MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off).");
-
-MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware");
-MODULE_AUTHOR("Steven Toth");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(cx24123_attach);
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h
deleted file mode 100644
index 9606f825935..00000000000
--- a/drivers/media/dvb/frontends/cx24123.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver
-
- Copyright (C) 2005 Steven Toth <stoth@hauppauge.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
-#ifndef CX24123_H
-#define CX24123_H
-
-#include <linux/dvb/frontend.h>
-
-struct cx24123_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* Need to set device param for start_dma */
- int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
-};
-
-extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
- struct i2c_adapter* i2c);
-
-#endif /* CX24123_H */
diff --git a/drivers/media/dvb/frontends/dib3000-common.c b/drivers/media/dvb/frontends/dib3000-common.c
deleted file mode 100644
index 1a4f1f7c228..00000000000
--- a/drivers/media/dvb/frontends/dib3000-common.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include "dib3000-common.h"
-
-#ifdef CONFIG_DVB_DIBCOM_DEBUG
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c,4=srch (|-able)).");
-#endif
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_i2c(args...) dprintk(0x02,args)
-#define deb_srch(args...) dprintk(0x04,args)
-
-
-int dib3000_read_reg(struct dib3000_state *state, u16 reg)
-{
- u8 wb[] = { ((reg >> 8) | 0x80) & 0xff, reg & 0xff };
- u8 rb[2];
- struct i2c_msg msg[] = {
- { .addr = state->config.demod_address, .flags = 0, .buf = wb, .len = 2 },
- { .addr = state->config.demod_address, .flags = I2C_M_RD, .buf = rb, .len = 2 },
- };
-
- if (i2c_transfer(state->i2c, msg, 2) != 2)
- deb_i2c("i2c read error\n");
-
- deb_i2c("reading i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,
- (rb[0] << 8) | rb[1],(rb[0] << 8) | rb[1]);
-
- return (rb[0] << 8) | rb[1];
-}
-
-int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val)
-{
- u8 b[] = {
- (reg >> 8) & 0xff, reg & 0xff,
- (val >> 8) & 0xff, val & 0xff,
- };
- struct i2c_msg msg[] = {
- { .addr = state->config.demod_address, .flags = 0, .buf = b, .len = 4 }
- };
- deb_i2c("writing i2c bus (reg: %5d 0x%04x, val: %5d 0x%04x)\n",reg,reg,val,val);
-
- return i2c_transfer(state->i2c,msg, 1) != 1 ? -EREMOTEIO : 0;
-}
-
-int dib3000_search_status(u16 irq,u16 lock)
-{
- if (irq & 0x02) {
- if (lock & 0x01) {
- deb_srch("auto search succeeded\n");
- return 1; // auto search succeeded
- } else {
- deb_srch("auto search not successful\n");
- return 0; // auto search failed
- }
- } else if (irq & 0x01) {
- deb_srch("auto search failed\n");
- return 0; // auto search failed
- }
- return -1; // try again
-}
-
-/* for auto search */
-u16 dib3000_seq[2][2][2] = /* fft,gua, inv */
- { /* fft */
- { /* gua */
- { 0, 1 }, /* 0 0 { 0,1 } */
- { 3, 9 }, /* 0 1 { 0,1 } */
- },
- {
- { 2, 5 }, /* 1 0 { 0,1 } */
- { 6, 11 }, /* 1 1 { 0,1 } */
- }
- };
-
-MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de");
-MODULE_DESCRIPTION("Common functions for the dib3000mb/dib3000mc dvb frontend drivers");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(dib3000_seq);
-
-EXPORT_SYMBOL(dib3000_read_reg);
-EXPORT_SYMBOL(dib3000_write_reg);
-EXPORT_SYMBOL(dib3000_search_status);
diff --git a/drivers/media/dvb/frontends/dib3000-common.h b/drivers/media/dvb/frontends/dib3000-common.h
deleted file mode 100644
index be1c0d3e138..00000000000
--- a/drivers/media/dvb/frontends/dib3000-common.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * .h-files for the common use of the frontend drivers made by DiBcom
- * DiBcom 3000M-B/C, 3000P
- *
- * DiBcom (http://www.dibcom.fr/)
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * based on GPL code from DibCom, which has
- *
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
- *
- * 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.
- *
- * Acknowledgements
- *
- * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
- * sources, on which this driver (and the dvb-dibusb) are based.
- *
- * see Documentation/dvb/README.dibusb for more information
- *
- */
-
-#ifndef DIB3000_COMMON_H
-#define DIB3000_COMMON_H
-
-#include "dvb_frontend.h"
-#include "dib3000.h"
-
-/* info and err, taken from usb.h, if there is anything available like by default. */
-#define err(format, arg...) printk(KERN_ERR "dib3000: " format "\n" , ## arg)
-#define info(format, arg...) printk(KERN_INFO "dib3000: " format "\n" , ## arg)
-#define warn(format, arg...) printk(KERN_WARNING "dib3000: " format "\n" , ## arg)
-
-/* frontend state */
-struct dib3000_state {
- struct i2c_adapter* i2c;
-
-/* configuration settings */
- struct dib3000_config config;
-
- struct dvb_frontend frontend;
- int timing_offset;
- int timing_offset_comp_done;
-
- fe_bandwidth_t last_tuned_bw;
- u32 last_tuned_freq;
-};
-
-/* commonly used methods by the dib3000mb/mc/p frontend */
-extern int dib3000_read_reg(struct dib3000_state *state, u16 reg);
-extern int dib3000_write_reg(struct dib3000_state *state, u16 reg, u16 val);
-
-extern int dib3000_search_status(u16 irq,u16 lock);
-
-/* handy shortcuts */
-#define rd(reg) dib3000_read_reg(state,reg)
-
-#define wr(reg,val) if (dib3000_write_reg(state,reg,val)) \
- { err("while sending 0x%04x to 0x%04x.",val,reg); return -EREMOTEIO; }
-
-#define wr_foreach(a,v) { int i; \
- if (sizeof(a) != sizeof(v)) \
- err("sizeof: %zu %zu is different",sizeof(a),sizeof(v));\
- for (i=0; i < sizeof(a)/sizeof(u16); i++) \
- wr(a[i],v[i]); \
- }
-
-#define set_or(reg,val) wr(reg,rd(reg) | val)
-
-#define set_and(reg,val) wr(reg,rd(reg) & val)
-
-
-/* debug */
-
-#ifdef CONFIG_DVB_DIBCOM_DEBUG
-#define dprintk(level,args...) \
- do { if ((debug & level)) { printk(args); } } while (0)
-#else
-#define dprintk(args...) do { } while (0)
-#endif
-
-/* mask for enabling a specific pid for the pid_filter */
-#define DIB3000_ACTIVATE_PID_FILTERING (0x2000)
-
-/* common values for tuning */
-#define DIB3000_ALPHA_0 ( 0)
-#define DIB3000_ALPHA_1 ( 1)
-#define DIB3000_ALPHA_2 ( 2)
-#define DIB3000_ALPHA_4 ( 4)
-
-#define DIB3000_CONSTELLATION_QPSK ( 0)
-#define DIB3000_CONSTELLATION_16QAM ( 1)
-#define DIB3000_CONSTELLATION_64QAM ( 2)
-
-#define DIB3000_GUARD_TIME_1_32 ( 0)
-#define DIB3000_GUARD_TIME_1_16 ( 1)
-#define DIB3000_GUARD_TIME_1_8 ( 2)
-#define DIB3000_GUARD_TIME_1_4 ( 3)
-
-#define DIB3000_TRANSMISSION_MODE_2K ( 0)
-#define DIB3000_TRANSMISSION_MODE_8K ( 1)
-
-#define DIB3000_SELECT_LP ( 0)
-#define DIB3000_SELECT_HP ( 1)
-
-#define DIB3000_FEC_1_2 ( 1)
-#define DIB3000_FEC_2_3 ( 2)
-#define DIB3000_FEC_3_4 ( 3)
-#define DIB3000_FEC_5_6 ( 5)
-#define DIB3000_FEC_7_8 ( 7)
-
-#define DIB3000_HRCH_OFF ( 0)
-#define DIB3000_HRCH_ON ( 1)
-
-#define DIB3000_DDS_INVERSION_OFF ( 0)
-#define DIB3000_DDS_INVERSION_ON ( 1)
-
-#define DIB3000_TUNER_WRITE_ENABLE(a) (0xffff & (a << 8))
-#define DIB3000_TUNER_WRITE_DISABLE(a) (0xffff & ((a << 8) | (1 << 7)))
-
-/* for auto search */
-extern u16 dib3000_seq[2][2][2];
-
-#define DIB3000_REG_MANUFACTOR_ID ( 1025)
-#define DIB3000_I2C_ID_DIBCOM (0x01b3)
-
-#define DIB3000_REG_DEVICE_ID ( 1026)
-#define DIB3000MB_DEVICE_ID (0x3000)
-#define DIB3000MC_DEVICE_ID (0x3001)
-#define DIB3000P_DEVICE_ID (0x3002)
-
-#endif // DIB3000_COMMON_H
diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h
deleted file mode 100644
index ec927628d27..00000000000
--- a/drivers/media/dvb/frontends/dib3000.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * public header file of the frontend drivers for mobile DVB-T demodulators
- * DiBcom 3000M-B and DiBcom 3000P/M-C (http://www.dibcom.fr/)
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * based on GPL code from DibCom, which has
- *
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
- *
- * 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.
- *
- * Acknowledgements
- *
- * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
- * sources, on which this driver (and the dvb-dibusb) are based.
- *
- * see Documentation/dvb/README.dibusb for more information
- *
- */
-
-#ifndef DIB3000_H
-#define DIB3000_H
-
-#include <linux/dvb/frontend.h>
-
-struct dib3000_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-};
-
-struct dib_fe_xfer_ops
-{
- /* pid and transfer handling is done in the demodulator */
- int (*pid_parse)(struct dvb_frontend *fe, int onoff);
- int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
- int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
- int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
-};
-
-extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
- struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
-
-extern struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
- struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops);
-#endif // DIB3000_H
diff --git a/drivers/media/dvb/frontends/dib3000mb.c b/drivers/media/dvb/frontends/dib3000mb.c
deleted file mode 100644
index 5302e11883a..00000000000
--- a/drivers/media/dvb/frontends/dib3000mb.c
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
- * Frontend driver for mobile DVB-T demodulator DiBcom 3000M-B
- * DiBcom (http://www.dibcom.fr/)
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * based on GPL code from DibCom, which has
- *
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
- *
- * 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.
- *
- * Acknowledgements
- *
- * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
- * sources, on which this driver (and the dvb-dibusb) are based.
- *
- * see Documentation/dvb/README.dibusb for more information
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dib3000-common.h"
-#include "dib3000mb_priv.h"
-#include "dib3000.h"
-
-/* Version information */
-#define DRIVER_VERSION "0.1"
-#define DRIVER_DESC "DiBcom 3000M-B DVB-T demodulator"
-#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
-
-#ifdef CONFIG_DVB_DIBCOM_DEBUG
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe (|-able)).");
-#endif
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_xfer(args...) dprintk(0x02,args)
-#define deb_setf(args...) dprintk(0x04,args)
-#define deb_getf(args...) dprintk(0x08,args)
-
-static int dib3000mb_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep);
-
-static int dib3000mb_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep, int tuner)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
- fe_code_rate_t fe_cr = FEC_NONE;
- int search_state, seq;
-
- if (tuner && fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, fep);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
-
- deb_setf("bandwidth: ");
- switch (ofdm->bandwidth) {
- case BANDWIDTH_8_MHZ:
- deb_setf("8 MHz\n");
- wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]);
- wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz);
- break;
- case BANDWIDTH_7_MHZ:
- deb_setf("7 MHz\n");
- wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[1]);
- wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_7mhz);
- break;
- case BANDWIDTH_6_MHZ:
- deb_setf("6 MHz\n");
- wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[0]);
- wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_6mhz);
- break;
- case BANDWIDTH_AUTO:
- return -EOPNOTSUPP;
- default:
- err("unkown bandwidth value.");
- return -EINVAL;
- }
- }
- wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4);
-
- deb_setf("transmission mode: ");
- switch (ofdm->transmission_mode) {
- case TRANSMISSION_MODE_2K:
- deb_setf("2k\n");
- wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_2K);
- break;
- case TRANSMISSION_MODE_8K:
- deb_setf("8k\n");
- wr(DIB3000MB_REG_FFT, DIB3000_TRANSMISSION_MODE_8K);
- break;
- case TRANSMISSION_MODE_AUTO:
- deb_setf("auto\n");
- break;
- default:
- return -EINVAL;
- }
-
- deb_setf("guard: ");
- switch (ofdm->guard_interval) {
- case GUARD_INTERVAL_1_32:
- deb_setf("1_32\n");
- wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_32);
- break;
- case GUARD_INTERVAL_1_16:
- deb_setf("1_16\n");
- wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_16);
- break;
- case GUARD_INTERVAL_1_8:
- deb_setf("1_8\n");
- wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_8);
- break;
- case GUARD_INTERVAL_1_4:
- deb_setf("1_4\n");
- wr(DIB3000MB_REG_GUARD_TIME, DIB3000_GUARD_TIME_1_4);
- break;
- case GUARD_INTERVAL_AUTO:
- deb_setf("auto\n");
- break;
- default:
- return -EINVAL;
- }
-
- deb_setf("inversion: ");
- switch (fep->inversion) {
- case INVERSION_OFF:
- deb_setf("off\n");
- wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_OFF);
- break;
- case INVERSION_AUTO:
- deb_setf("auto ");
- break;
- case INVERSION_ON:
- deb_setf("on\n");
- wr(DIB3000MB_REG_DDS_INV, DIB3000_DDS_INVERSION_ON);
- break;
- default:
- return -EINVAL;
- }
-
- deb_setf("constellation: ");
- switch (ofdm->constellation) {
- case QPSK:
- deb_setf("qpsk\n");
- wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_QPSK);
- break;
- case QAM_16:
- deb_setf("qam16\n");
- wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_16QAM);
- break;
- case QAM_64:
- deb_setf("qam64\n");
- wr(DIB3000MB_REG_QAM, DIB3000_CONSTELLATION_64QAM);
- break;
- case QAM_AUTO:
- break;
- default:
- return -EINVAL;
- }
- deb_setf("hierachy: ");
- switch (ofdm->hierarchy_information) {
- case HIERARCHY_NONE:
- deb_setf("none ");
- /* fall through */
- case HIERARCHY_1:
- deb_setf("alpha=1\n");
- wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_1);
- break;
- case HIERARCHY_2:
- deb_setf("alpha=2\n");
- wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_2);
- break;
- case HIERARCHY_4:
- deb_setf("alpha=4\n");
- wr(DIB3000MB_REG_VIT_ALPHA, DIB3000_ALPHA_4);
- break;
- case HIERARCHY_AUTO:
- deb_setf("alpha=auto\n");
- break;
- default:
- return -EINVAL;
- }
-
- deb_setf("hierarchy: ");
- if (ofdm->hierarchy_information == HIERARCHY_NONE) {
- deb_setf("none\n");
- wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_OFF);
- wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_HP);
- fe_cr = ofdm->code_rate_HP;
- } else if (ofdm->hierarchy_information != HIERARCHY_AUTO) {
- deb_setf("on\n");
- wr(DIB3000MB_REG_VIT_HRCH, DIB3000_HRCH_ON);
- wr(DIB3000MB_REG_VIT_HP, DIB3000_SELECT_LP);
- fe_cr = ofdm->code_rate_LP;
- }
- deb_setf("fec: ");
- switch (fe_cr) {
- case FEC_1_2:
- deb_setf("1_2\n");
- wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_1_2);
- break;
- case FEC_2_3:
- deb_setf("2_3\n");
- wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_2_3);
- break;
- case FEC_3_4:
- deb_setf("3_4\n");
- wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_3_4);
- break;
- case FEC_5_6:
- deb_setf("5_6\n");
- wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_5_6);
- break;
- case FEC_7_8:
- deb_setf("7_8\n");
- wr(DIB3000MB_REG_VIT_CODE_RATE, DIB3000_FEC_7_8);
- break;
- case FEC_NONE:
- deb_setf("none ");
- break;
- case FEC_AUTO:
- deb_setf("auto\n");
- break;
- default:
- return -EINVAL;
- }
-
- seq = dib3000_seq
- [ofdm->transmission_mode == TRANSMISSION_MODE_AUTO]
- [ofdm->guard_interval == GUARD_INTERVAL_AUTO]
- [fep->inversion == INVERSION_AUTO];
-
- deb_setf("seq? %d\n", seq);
-
- wr(DIB3000MB_REG_SEQ, seq);
-
- wr(DIB3000MB_REG_ISI, seq ? DIB3000MB_ISI_INHIBIT : DIB3000MB_ISI_ACTIVATE);
-
- if (ofdm->transmission_mode == TRANSMISSION_MODE_2K) {
- if (ofdm->guard_interval == GUARD_INTERVAL_1_8) {
- wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_2K_1_8);
- } else {
- wr(DIB3000MB_REG_SYNC_IMPROVEMENT, DIB3000MB_SYNC_IMPROVE_DEFAULT);
- }
-
- wr(DIB3000MB_REG_UNK_121, DIB3000MB_UNK_121_2K);
- } else {
- wr(DIB3000MB_REG_UNK_121, DIB3000MB_UNK_121_DEFAULT);
- }
-
- wr(DIB3000MB_REG_MOBILE_ALGO, DIB3000MB_MOBILE_ALGO_OFF);
- wr(DIB3000MB_REG_MOBILE_MODE_QAM, DIB3000MB_MOBILE_MODE_QAM_OFF);
- wr(DIB3000MB_REG_MOBILE_MODE, DIB3000MB_MOBILE_MODE_OFF);
-
- wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_high);
-
- wr(DIB3000MB_REG_ISI, DIB3000MB_ISI_ACTIVATE);
-
- wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_AGC + DIB3000MB_RESTART_CTRL);
- wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_OFF);
-
- /* wait for AGC lock */
- msleep(70);
-
- wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low);
-
- /* something has to be auto searched */
- if (ofdm->constellation == QAM_AUTO ||
- ofdm->hierarchy_information == HIERARCHY_AUTO ||
- fe_cr == FEC_AUTO ||
- fep->inversion == INVERSION_AUTO) {
- int as_count=0;
-
- deb_setf("autosearch enabled.\n");
-
- wr(DIB3000MB_REG_ISI, DIB3000MB_ISI_INHIBIT);
-
- wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_AUTO_SEARCH);
- wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_OFF);
-
- while ((search_state =
- dib3000_search_status(
- rd(DIB3000MB_REG_AS_IRQ_PENDING),
- rd(DIB3000MB_REG_LOCK2_VALUE))) < 0 && as_count++ < 100)
- msleep(1);
-
- deb_setf("search_state after autosearch %d after %d checks\n",search_state,as_count);
-
- if (search_state == 1) {
- struct dvb_frontend_parameters feps;
- if (dib3000mb_get_frontend(fe, &feps) == 0) {
- deb_setf("reading tuning data from frontend succeeded.\n");
- return dib3000mb_set_frontend(fe, &feps, 0);
- }
- }
-
- } else {
- wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_CTRL);
- wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_OFF);
- }
-
- return 0;
-}
-
-static int dib3000mb_fe_init(struct dvb_frontend* fe, int mobile_mode)
-{
- struct dib3000_state* state = fe->demodulator_priv;
-
- deb_info("dib3000mb is getting up.\n");
- wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_UP);
-
- wr(DIB3000MB_REG_RESTART, DIB3000MB_RESTART_AGC);
-
- wr(DIB3000MB_REG_RESET_DEVICE, DIB3000MB_RESET_DEVICE);
- wr(DIB3000MB_REG_RESET_DEVICE, DIB3000MB_RESET_DEVICE_RST);
-
- wr(DIB3000MB_REG_CLOCK, DIB3000MB_CLOCK_DEFAULT);
-
- wr(DIB3000MB_REG_ELECT_OUT_MODE, DIB3000MB_ELECT_OUT_MODE_ON);
-
- wr(DIB3000MB_REG_DDS_FREQ_MSB, DIB3000MB_DDS_FREQ_MSB);
- wr(DIB3000MB_REG_DDS_FREQ_LSB, DIB3000MB_DDS_FREQ_LSB);
-
- wr_foreach(dib3000mb_reg_timing_freq, dib3000mb_timing_freq[2]);
-
- wr_foreach(dib3000mb_reg_impulse_noise,
- dib3000mb_impulse_noise_values[DIB3000MB_IMPNOISE_OFF]);
-
- wr_foreach(dib3000mb_reg_agc_gain, dib3000mb_default_agc_gain);
-
- wr(DIB3000MB_REG_PHASE_NOISE, DIB3000MB_PHASE_NOISE_DEFAULT);
-
- wr_foreach(dib3000mb_reg_phase_noise, dib3000mb_default_noise_phase);
-
- wr_foreach(dib3000mb_reg_lock_duration, dib3000mb_default_lock_duration);
-
- wr_foreach(dib3000mb_reg_agc_bandwidth, dib3000mb_agc_bandwidth_low);
-
- wr(DIB3000MB_REG_LOCK0_MASK, DIB3000MB_LOCK0_DEFAULT);
- wr(DIB3000MB_REG_LOCK1_MASK, DIB3000MB_LOCK1_SEARCH_4);
- wr(DIB3000MB_REG_LOCK2_MASK, DIB3000MB_LOCK2_DEFAULT);
- wr(DIB3000MB_REG_SEQ, dib3000_seq[1][1][1]);
-
- wr_foreach(dib3000mb_reg_bandwidth, dib3000mb_bandwidth_8mhz);
-
- wr(DIB3000MB_REG_UNK_68, DIB3000MB_UNK_68);
- wr(DIB3000MB_REG_UNK_69, DIB3000MB_UNK_69);
- wr(DIB3000MB_REG_UNK_71, DIB3000MB_UNK_71);
- wr(DIB3000MB_REG_UNK_77, DIB3000MB_UNK_77);
- wr(DIB3000MB_REG_UNK_78, DIB3000MB_UNK_78);
- wr(DIB3000MB_REG_ISI, DIB3000MB_ISI_INHIBIT);
- wr(DIB3000MB_REG_UNK_92, DIB3000MB_UNK_92);
- wr(DIB3000MB_REG_UNK_96, DIB3000MB_UNK_96);
- wr(DIB3000MB_REG_UNK_97, DIB3000MB_UNK_97);
- wr(DIB3000MB_REG_UNK_106, DIB3000MB_UNK_106);
- wr(DIB3000MB_REG_UNK_107, DIB3000MB_UNK_107);
- wr(DIB3000MB_REG_UNK_108, DIB3000MB_UNK_108);
- wr(DIB3000MB_REG_UNK_122, DIB3000MB_UNK_122);
- wr(DIB3000MB_REG_MOBILE_MODE_QAM, DIB3000MB_MOBILE_MODE_QAM_OFF);
- wr(DIB3000MB_REG_BERLEN, DIB3000MB_BERLEN_DEFAULT);
-
- wr_foreach(dib3000mb_reg_filter_coeffs, dib3000mb_filter_coeffs);
-
- wr(DIB3000MB_REG_MOBILE_ALGO, DIB3000MB_MOBILE_ALGO_ON);
- wr(DIB3000MB_REG_MULTI_DEMOD_MSB, DIB3000MB_MULTI_DEMOD_MSB);
- wr(DIB3000MB_REG_MULTI_DEMOD_LSB, DIB3000MB_MULTI_DEMOD_LSB);
-
- wr(DIB3000MB_REG_OUTPUT_MODE, DIB3000MB_OUTPUT_MODE_SLAVE);
-
- wr(DIB3000MB_REG_FIFO_142, DIB3000MB_FIFO_142);
- wr(DIB3000MB_REG_MPEG2_OUT_MODE, DIB3000MB_MPEG2_OUT_MODE_188);
- wr(DIB3000MB_REG_PID_PARSE, DIB3000MB_PID_PARSE_ACTIVATE);
- wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_INHIBIT);
- wr(DIB3000MB_REG_FIFO_146, DIB3000MB_FIFO_146);
- wr(DIB3000MB_REG_FIFO_147, DIB3000MB_FIFO_147);
-
- wr(DIB3000MB_REG_DATA_IN_DIVERSITY, DIB3000MB_DATA_DIVERSITY_IN_OFF);
-
- return 0;
-}
-
-static int dib3000mb_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
- fe_code_rate_t *cr;
- u16 tps_val;
- int inv_test1,inv_test2;
- u32 dds_val, threshold = 0x800000;
-
- if (!rd(DIB3000MB_REG_TPS_LOCK))
- return 0;
-
- dds_val = ((rd(DIB3000MB_REG_DDS_VALUE_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_VALUE_LSB);
- deb_getf("DDS_VAL: %x %x %x",dds_val, rd(DIB3000MB_REG_DDS_VALUE_MSB), rd(DIB3000MB_REG_DDS_VALUE_LSB));
- if (dds_val < threshold)
- inv_test1 = 0;
- else if (dds_val == threshold)
- inv_test1 = 1;
- else
- inv_test1 = 2;
-
- dds_val = ((rd(DIB3000MB_REG_DDS_FREQ_MSB) & 0xff) << 16) + rd(DIB3000MB_REG_DDS_FREQ_LSB);
- deb_getf("DDS_FREQ: %x %x %x",dds_val, rd(DIB3000MB_REG_DDS_FREQ_MSB), rd(DIB3000MB_REG_DDS_FREQ_LSB));
- if (dds_val < threshold)
- inv_test2 = 0;
- else if (dds_val == threshold)
- inv_test2 = 1;
- else
- inv_test2 = 2;
-
- fep->inversion =
- ((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) ||
- ((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
- INVERSION_ON : INVERSION_OFF;
-
- deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion);
-
- switch ((tps_val = rd(DIB3000MB_REG_TPS_QAM))) {
- case DIB3000_CONSTELLATION_QPSK:
- deb_getf("QPSK ");
- ofdm->constellation = QPSK;
- break;
- case DIB3000_CONSTELLATION_16QAM:
- deb_getf("QAM16 ");
- ofdm->constellation = QAM_16;
- break;
- case DIB3000_CONSTELLATION_64QAM:
- deb_getf("QAM64 ");
- ofdm->constellation = QAM_64;
- break;
- default:
- err("Unexpected constellation returned by TPS (%d)", tps_val);
- break;
- }
- deb_getf("TPS: %d\n", tps_val);
-
- if (rd(DIB3000MB_REG_TPS_HRCH)) {
- deb_getf("HRCH ON\n");
- cr = &ofdm->code_rate_LP;
- ofdm->code_rate_HP = FEC_NONE;
- switch ((tps_val = rd(DIB3000MB_REG_TPS_VIT_ALPHA))) {
- case DIB3000_ALPHA_0:
- deb_getf("HIERARCHY_NONE ");
- ofdm->hierarchy_information = HIERARCHY_NONE;
- break;
- case DIB3000_ALPHA_1:
- deb_getf("HIERARCHY_1 ");
- ofdm->hierarchy_information = HIERARCHY_1;
- break;
- case DIB3000_ALPHA_2:
- deb_getf("HIERARCHY_2 ");
- ofdm->hierarchy_information = HIERARCHY_2;
- break;
- case DIB3000_ALPHA_4:
- deb_getf("HIERARCHY_4 ");
- ofdm->hierarchy_information = HIERARCHY_4;
- break;
- default:
- err("Unexpected ALPHA value returned by TPS (%d)", tps_val);
- break;
- }
- deb_getf("TPS: %d\n", tps_val);
-
- tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_LP);
- } else {
- deb_getf("HRCH OFF\n");
- cr = &ofdm->code_rate_HP;
- ofdm->code_rate_LP = FEC_NONE;
- ofdm->hierarchy_information = HIERARCHY_NONE;
-
- tps_val = rd(DIB3000MB_REG_TPS_CODE_RATE_HP);
- }
-
- switch (tps_val) {
- case DIB3000_FEC_1_2:
- deb_getf("FEC_1_2 ");
- *cr = FEC_1_2;
- break;
- case DIB3000_FEC_2_3:
- deb_getf("FEC_2_3 ");
- *cr = FEC_2_3;
- break;
- case DIB3000_FEC_3_4:
- deb_getf("FEC_3_4 ");
- *cr = FEC_3_4;
- break;
- case DIB3000_FEC_5_6:
- deb_getf("FEC_5_6 ");
- *cr = FEC_4_5;
- break;
- case DIB3000_FEC_7_8:
- deb_getf("FEC_7_8 ");
- *cr = FEC_7_8;
- break;
- default:
- err("Unexpected FEC returned by TPS (%d)", tps_val);
- break;
- }
- deb_getf("TPS: %d\n",tps_val);
-
- switch ((tps_val = rd(DIB3000MB_REG_TPS_GUARD_TIME))) {
- case DIB3000_GUARD_TIME_1_32:
- deb_getf("GUARD_INTERVAL_1_32 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_32;
- break;
- case DIB3000_GUARD_TIME_1_16:
- deb_getf("GUARD_INTERVAL_1_16 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_16;
- break;
- case DIB3000_GUARD_TIME_1_8:
- deb_getf("GUARD_INTERVAL_1_8 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_8;
- break;
- case DIB3000_GUARD_TIME_1_4:
- deb_getf("GUARD_INTERVAL_1_4 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_4;
- break;
- default:
- err("Unexpected Guard Time returned by TPS (%d)", tps_val);
- break;
- }
- deb_getf("TPS: %d\n", tps_val);
-
- switch ((tps_val = rd(DIB3000MB_REG_TPS_FFT))) {
- case DIB3000_TRANSMISSION_MODE_2K:
- deb_getf("TRANSMISSION_MODE_2K ");
- ofdm->transmission_mode = TRANSMISSION_MODE_2K;
- break;
- case DIB3000_TRANSMISSION_MODE_8K:
- deb_getf("TRANSMISSION_MODE_8K ");
- ofdm->transmission_mode = TRANSMISSION_MODE_8K;
- break;
- default:
- err("unexpected transmission mode return by TPS (%d)", tps_val);
- break;
- }
- deb_getf("TPS: %d\n", tps_val);
-
- return 0;
-}
-
-static int dib3000mb_read_status(struct dvb_frontend* fe, fe_status_t *stat)
-{
- struct dib3000_state* state = fe->demodulator_priv;
-
- *stat = 0;
-
- if (rd(DIB3000MB_REG_AGC_LOCK))
- *stat |= FE_HAS_SIGNAL;
- if (rd(DIB3000MB_REG_CARRIER_LOCK))
- *stat |= FE_HAS_CARRIER;
- if (rd(DIB3000MB_REG_VIT_LCK))
- *stat |= FE_HAS_VITERBI;
- if (rd(DIB3000MB_REG_TS_SYNC_LOCK))
- *stat |= (FE_HAS_SYNC | FE_HAS_LOCK);
-
- deb_getf("actual status is %2x\n",*stat);
-
- deb_getf("autoval: tps: %d, qam: %d, hrch: %d, alpha: %d, hp: %d, lp: %d, guard: %d, fft: %d cell: %d\n",
- rd(DIB3000MB_REG_TPS_LOCK),
- rd(DIB3000MB_REG_TPS_QAM),
- rd(DIB3000MB_REG_TPS_HRCH),
- rd(DIB3000MB_REG_TPS_VIT_ALPHA),
- rd(DIB3000MB_REG_TPS_CODE_RATE_HP),
- rd(DIB3000MB_REG_TPS_CODE_RATE_LP),
- rd(DIB3000MB_REG_TPS_GUARD_TIME),
- rd(DIB3000MB_REG_TPS_FFT),
- rd(DIB3000MB_REG_TPS_CELL_ID));
-
- //*stat = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
- return 0;
-}
-
-static int dib3000mb_read_ber(struct dvb_frontend* fe, u32 *ber)
-{
- struct dib3000_state* state = fe->demodulator_priv;
-
- *ber = ((rd(DIB3000MB_REG_BER_MSB) << 16) | rd(DIB3000MB_REG_BER_LSB));
- return 0;
-}
-
-/* see dib3000-watch dvb-apps for exact calcuations of signal_strength and snr */
-static int dib3000mb_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
-{
- struct dib3000_state* state = fe->demodulator_priv;
-
- *strength = rd(DIB3000MB_REG_SIGNAL_POWER) * 0xffff / 0x170;
- return 0;
-}
-
-static int dib3000mb_read_snr(struct dvb_frontend* fe, u16 *snr)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- short sigpow = rd(DIB3000MB_REG_SIGNAL_POWER);
- int icipow = ((rd(DIB3000MB_REG_NOISE_POWER_MSB) & 0xff) << 16) |
- rd(DIB3000MB_REG_NOISE_POWER_LSB);
- *snr = (sigpow << 8) / ((icipow > 0) ? icipow : 1);
- return 0;
-}
-
-static int dib3000mb_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
-{
- struct dib3000_state* state = fe->demodulator_priv;
-
- *unc = rd(DIB3000MB_REG_PACKET_ERROR_RATE);
- return 0;
-}
-
-static int dib3000mb_sleep(struct dvb_frontend* fe)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- deb_info("dib3000mb is going to bed.\n");
- wr(DIB3000MB_REG_POWER_CONTROL, DIB3000MB_POWER_DOWN);
- return 0;
-}
-
-static int dib3000mb_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- tune->min_delay_ms = 800;
- return 0;
-}
-
-static int dib3000mb_fe_init_nonmobile(struct dvb_frontend* fe)
-{
- return dib3000mb_fe_init(fe, 0);
-}
-
-static int dib3000mb_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep)
-{
- return dib3000mb_set_frontend(fe, fep, 1);
-}
-
-static void dib3000mb_release(struct dvb_frontend* fe)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- kfree(state);
-}
-
-/* pid filter and transfer stuff */
-static int dib3000mb_pid_control(struct dvb_frontend *fe,int index, int pid,int onoff)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- pid = (onoff ? pid | DIB3000_ACTIVATE_PID_FILTERING : 0);
- wr(index+DIB3000MB_REG_FIRST_PID,pid);
- return 0;
-}
-
-static int dib3000mb_fifo_control(struct dvb_frontend *fe, int onoff)
-{
- struct dib3000_state *state = fe->demodulator_priv;
-
- deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling");
- if (onoff) {
- wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_ACTIVATE);
- } else {
- wr(DIB3000MB_REG_FIFO, DIB3000MB_FIFO_INHIBIT);
- }
- return 0;
-}
-
-static int dib3000mb_pid_parse(struct dvb_frontend *fe, int onoff)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- deb_xfer("%s pid parsing\n",onoff ? "enabling" : "disabling");
- wr(DIB3000MB_REG_PID_PARSE,onoff);
- return 0;
-}
-
-static int dib3000mb_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- if (onoff) {
- wr(DIB3000MB_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr));
- } else {
- wr(DIB3000MB_REG_TUNER, DIB3000_TUNER_WRITE_DISABLE(pll_addr));
- }
- return 0;
-}
-
-static struct dvb_frontend_ops dib3000mb_ops;
-
-struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
- struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
-{
- struct dib3000_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct dib3000_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->i2c = i2c;
- memcpy(&state->config,config,sizeof(struct dib3000_config));
-
- /* check for the correct demod */
- if (rd(DIB3000_REG_MANUFACTOR_ID) != DIB3000_I2C_ID_DIBCOM)
- goto error;
-
- if (rd(DIB3000_REG_DEVICE_ID) != DIB3000MB_DEVICE_ID)
- goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &dib3000mb_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
-
- /* set the xfer operations */
- xfer_ops->pid_parse = dib3000mb_pid_parse;
- xfer_ops->fifo_ctrl = dib3000mb_fifo_control;
- xfer_ops->pid_ctrl = dib3000mb_pid_control;
- xfer_ops->tuner_pass_ctrl = dib3000mb_tuner_pass_ctrl;
-
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops dib3000mb_ops = {
-
- .info = {
- .name = "DiBcom 3000M-B DVB-T",
- .type = FE_OFDM,
- .frequency_min = 44250000,
- .frequency_max = 867250000,
- .frequency_stepsize = 62500,
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO |
- FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_RECOVER |
- FE_CAN_HIERARCHY_AUTO,
- },
-
- .release = dib3000mb_release,
-
- .init = dib3000mb_fe_init_nonmobile,
- .sleep = dib3000mb_sleep,
-
- .set_frontend = dib3000mb_set_frontend_and_tuner,
- .get_frontend = dib3000mb_get_frontend,
- .get_tune_settings = dib3000mb_fe_get_tune_settings,
-
- .read_status = dib3000mb_read_status,
- .read_ber = dib3000mb_read_ber,
- .read_signal_strength = dib3000mb_read_signal_strength,
- .read_snr = dib3000mb_read_snr,
- .read_ucblocks = dib3000mb_read_unc_blocks,
-};
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(dib3000mb_attach);
diff --git a/drivers/media/dvb/frontends/dib3000mb_priv.h b/drivers/media/dvb/frontends/dib3000mb_priv.h
deleted file mode 100644
index 999b1904781..00000000000
--- a/drivers/media/dvb/frontends/dib3000mb_priv.h
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * dib3000mb_priv.h
- *
- * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * for more information see dib3000mb.c .
- */
-
-#ifndef __DIB3000MB_PRIV_H_INCLUDED__
-#define __DIB3000MB_PRIV_H_INCLUDED__
-
-/* register addresses and some of their default values */
-
-/* restart subsystems */
-#define DIB3000MB_REG_RESTART ( 0)
-
-#define DIB3000MB_RESTART_OFF ( 0)
-#define DIB3000MB_RESTART_AUTO_SEARCH (1 << 1)
-#define DIB3000MB_RESTART_CTRL (1 << 2)
-#define DIB3000MB_RESTART_AGC (1 << 3)
-
-/* FFT size */
-#define DIB3000MB_REG_FFT ( 1)
-
-/* Guard time */
-#define DIB3000MB_REG_GUARD_TIME ( 2)
-
-/* QAM */
-#define DIB3000MB_REG_QAM ( 3)
-
-/* Alpha coefficient high priority Viterbi algorithm */
-#define DIB3000MB_REG_VIT_ALPHA ( 4)
-
-/* spectrum inversion */
-#define DIB3000MB_REG_DDS_INV ( 5)
-
-/* DDS frequency value (IF position) ad ? values don't match reg_3000mb.txt */
-#define DIB3000MB_REG_DDS_FREQ_MSB ( 6)
-#define DIB3000MB_REG_DDS_FREQ_LSB ( 7)
-#define DIB3000MB_DDS_FREQ_MSB ( 178)
-#define DIB3000MB_DDS_FREQ_LSB ( 8990)
-
-/* timing frequency (carrier spacing) */
-static u16 dib3000mb_reg_timing_freq[] = { 8,9 };
-static u16 dib3000mb_timing_freq[][2] = {
- { 126 , 48873 }, /* 6 MHz */
- { 147 , 57019 }, /* 7 MHz */
- { 168 , 65164 }, /* 8 MHz */
-};
-
-/* impulse noise parameter */
-/* 36 ??? */
-
-static u16 dib3000mb_reg_impulse_noise[] = { 10,11,12,15,36 };
-
-enum dib3000mb_impulse_noise_type {
- DIB3000MB_IMPNOISE_OFF,
- DIB3000MB_IMPNOISE_MOBILE,
- DIB3000MB_IMPNOISE_FIXED,
- DIB3000MB_IMPNOISE_DEFAULT
-};
-
-static u16 dib3000mb_impulse_noise_values[][5] = {
- { 0x0000, 0x0004, 0x0014, 0x01ff, 0x0399 }, /* off */
- { 0x0001, 0x0004, 0x0014, 0x01ff, 0x037b }, /* mobile */
- { 0x0001, 0x0004, 0x0020, 0x01bd, 0x0399 }, /* fixed */
- { 0x0000, 0x0002, 0x000a, 0x01ff, 0x0399 }, /* default */
-};
-
-/*
- * Dual Automatic-Gain-Control
- * - gains RF in tuner (AGC1)
- * - gains IF after filtering (AGC2)
- */
-
-/* also from 16 to 18 */
-static u16 dib3000mb_reg_agc_gain[] = {
- 19,20,21,22,23,24,25,26,27,28,29,30,31,32
-};
-
-static u16 dib3000mb_default_agc_gain[] =
- { 0x0001, 52429, 623, 128, 166, 195, 61, /* RF ??? */
- 0x0001, 53766, 38011, 0, 90, 33, 23 }; /* IF ??? */
-
-/* phase noise */
-/* 36 is set when setting the impulse noise */
-static u16 dib3000mb_reg_phase_noise[] = { 33,34,35,37,38 };
-
-static u16 dib3000mb_default_noise_phase[] = { 2, 544, 0, 5, 4 };
-
-/* lock duration */
-static u16 dib3000mb_reg_lock_duration[] = { 39,40 };
-static u16 dib3000mb_default_lock_duration[] = { 135, 135 };
-
-/* AGC loop bandwidth */
-static u16 dib3000mb_reg_agc_bandwidth[] = { 43,44,45,46,47,48,49,50 };
-
-static u16 dib3000mb_agc_bandwidth_low[] =
- { 2088, 10, 2088, 10, 3448, 5, 3448, 5 };
-static u16 dib3000mb_agc_bandwidth_high[] =
- { 2349, 5, 2349, 5, 2586, 2, 2586, 2 };
-
-/*
- * lock0 definition (coff_lock)
- */
-#define DIB3000MB_REG_LOCK0_MASK ( 51)
-#define DIB3000MB_LOCK0_DEFAULT ( 4)
-
-/*
- * lock1 definition (cpil_lock)
- * for auto search
- * which values hide behind the lock masks
- */
-#define DIB3000MB_REG_LOCK1_MASK ( 52)
-#define DIB3000MB_LOCK1_SEARCH_4 (0x0004)
-#define DIB3000MB_LOCK1_SEARCH_2048 (0x0800)
-#define DIB3000MB_LOCK1_DEFAULT (0x0001)
-
-/*
- * lock2 definition (fec_lock) */
-#define DIB3000MB_REG_LOCK2_MASK ( 53)
-#define DIB3000MB_LOCK2_DEFAULT (0x0080)
-
-/*
- * SEQ ? what was that again ... :)
- * changes when, inversion, guard time and fft is
- * either automatically detected or not
- */
-#define DIB3000MB_REG_SEQ ( 54)
-
-/* bandwidth */
-static u16 dib3000mb_reg_bandwidth[] = { 55,56,57,58,59,60,61,62,63,64,65,66,67 };
-static u16 dib3000mb_bandwidth_6mhz[] =
- { 0, 33, 53312, 112, 46635, 563, 36565, 0, 1000, 0, 1010, 1, 45264 };
-
-static u16 dib3000mb_bandwidth_7mhz[] =
- { 0, 28, 64421, 96, 39973, 483, 3255, 0, 1000, 0, 1010, 1, 45264 };
-
-static u16 dib3000mb_bandwidth_8mhz[] =
- { 0, 25, 23600, 84, 34976, 422, 43808, 0, 1000, 0, 1010, 1, 45264 };
-
-#define DIB3000MB_REG_UNK_68 ( 68)
-#define DIB3000MB_UNK_68 ( 0)
-
-#define DIB3000MB_REG_UNK_69 ( 69)
-#define DIB3000MB_UNK_69 ( 0)
-
-#define DIB3000MB_REG_UNK_71 ( 71)
-#define DIB3000MB_UNK_71 ( 0)
-
-#define DIB3000MB_REG_UNK_77 ( 77)
-#define DIB3000MB_UNK_77 ( 6)
-
-#define DIB3000MB_REG_UNK_78 ( 78)
-#define DIB3000MB_UNK_78 (0x0080)
-
-/* isi */
-#define DIB3000MB_REG_ISI ( 79)
-#define DIB3000MB_ISI_ACTIVATE ( 0)
-#define DIB3000MB_ISI_INHIBIT ( 1)
-
-/* sync impovement */
-#define DIB3000MB_REG_SYNC_IMPROVEMENT ( 84)
-#define DIB3000MB_SYNC_IMPROVE_2K_1_8 ( 3)
-#define DIB3000MB_SYNC_IMPROVE_DEFAULT ( 0)
-
-/* phase noise compensation inhibition */
-#define DIB3000MB_REG_PHASE_NOISE ( 87)
-#define DIB3000MB_PHASE_NOISE_DEFAULT ( 0)
-
-#define DIB3000MB_REG_UNK_92 ( 92)
-#define DIB3000MB_UNK_92 (0x0080)
-
-#define DIB3000MB_REG_UNK_96 ( 96)
-#define DIB3000MB_UNK_96 (0x0010)
-
-#define DIB3000MB_REG_UNK_97 ( 97)
-#define DIB3000MB_UNK_97 (0x0009)
-
-/* mobile mode ??? */
-#define DIB3000MB_REG_MOBILE_MODE ( 101)
-#define DIB3000MB_MOBILE_MODE_ON ( 1)
-#define DIB3000MB_MOBILE_MODE_OFF ( 0)
-
-#define DIB3000MB_REG_UNK_106 ( 106)
-#define DIB3000MB_UNK_106 (0x0080)
-
-#define DIB3000MB_REG_UNK_107 ( 107)
-#define DIB3000MB_UNK_107 (0x0080)
-
-#define DIB3000MB_REG_UNK_108 ( 108)
-#define DIB3000MB_UNK_108 (0x0080)
-
-/* fft */
-#define DIB3000MB_REG_UNK_121 ( 121)
-#define DIB3000MB_UNK_121_2K ( 7)
-#define DIB3000MB_UNK_121_DEFAULT ( 5)
-
-#define DIB3000MB_REG_UNK_122 ( 122)
-#define DIB3000MB_UNK_122 ( 2867)
-
-/* QAM for mobile mode */
-#define DIB3000MB_REG_MOBILE_MODE_QAM ( 126)
-#define DIB3000MB_MOBILE_MODE_QAM_64 ( 3)
-#define DIB3000MB_MOBILE_MODE_QAM_QPSK_16 ( 1)
-#define DIB3000MB_MOBILE_MODE_QAM_OFF ( 0)
-
-/*
- * data diversity when having more than one chip on-board
- * see also DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY
- */
-#define DIB3000MB_REG_DATA_IN_DIVERSITY ( 127)
-#define DIB3000MB_DATA_DIVERSITY_IN_OFF ( 0)
-#define DIB3000MB_DATA_DIVERSITY_IN_ON ( 2)
-
-/* vit hrch */
-#define DIB3000MB_REG_VIT_HRCH ( 128)
-
-/* vit code rate */
-#define DIB3000MB_REG_VIT_CODE_RATE ( 129)
-
-/* vit select hp */
-#define DIB3000MB_REG_VIT_HP ( 130)
-
-/* time frame for Bit-Error-Rate calculation */
-#define DIB3000MB_REG_BERLEN ( 135)
-#define DIB3000MB_BERLEN_LONG ( 0)
-#define DIB3000MB_BERLEN_DEFAULT ( 1)
-#define DIB3000MB_BERLEN_MEDIUM ( 2)
-#define DIB3000MB_BERLEN_SHORT ( 3)
-
-/* 142 - 152 FIFO parameters
- * which is what ?
- */
-
-#define DIB3000MB_REG_FIFO_142 ( 142)
-#define DIB3000MB_FIFO_142 ( 0)
-
-/* MPEG2 TS output mode */
-#define DIB3000MB_REG_MPEG2_OUT_MODE ( 143)
-#define DIB3000MB_MPEG2_OUT_MODE_204 ( 0)
-#define DIB3000MB_MPEG2_OUT_MODE_188 ( 1)
-
-#define DIB3000MB_REG_PID_PARSE ( 144)
-#define DIB3000MB_PID_PARSE_INHIBIT ( 0)
-#define DIB3000MB_PID_PARSE_ACTIVATE ( 1)
-
-#define DIB3000MB_REG_FIFO ( 145)
-#define DIB3000MB_FIFO_INHIBIT ( 1)
-#define DIB3000MB_FIFO_ACTIVATE ( 0)
-
-#define DIB3000MB_REG_FIFO_146 ( 146)
-#define DIB3000MB_FIFO_146 ( 3)
-
-#define DIB3000MB_REG_FIFO_147 ( 147)
-#define DIB3000MB_FIFO_147 (0x0100)
-
-/*
- * pidfilter
- * it is not a hardware pidfilter but a filter which drops all pids
- * except the ones set. Necessary because of the limited USB1.1 bandwidth.
- * regs 153-168
- */
-
-#define DIB3000MB_REG_FIRST_PID ( 153)
-#define DIB3000MB_NUM_PIDS ( 16)
-
-/*
- * output mode
- * USB devices have to use 'slave'-mode
- * see also DIB3000MB_REG_ELECT_OUT_MODE
- */
-#define DIB3000MB_REG_OUTPUT_MODE ( 169)
-#define DIB3000MB_OUTPUT_MODE_GATED_CLK ( 0)
-#define DIB3000MB_OUTPUT_MODE_CONT_CLK ( 1)
-#define DIB3000MB_OUTPUT_MODE_SERIAL ( 2)
-#define DIB3000MB_OUTPUT_MODE_DATA_DIVERSITY ( 5)
-#define DIB3000MB_OUTPUT_MODE_SLAVE ( 6)
-
-/* irq event mask */
-#define DIB3000MB_REG_IRQ_EVENT_MASK ( 170)
-#define DIB3000MB_IRQ_EVENT_MASK ( 0)
-
-/* filter coefficients */
-static u16 dib3000mb_reg_filter_coeffs[] = {
- 171, 172, 173, 174, 175, 176, 177, 178,
- 179, 180, 181, 182, 183, 184, 185, 186,
- 188, 189, 190, 191, 192, 194
-};
-
-static u16 dib3000mb_filter_coeffs[] = {
- 226, 160, 29,
- 979, 998, 19,
- 22, 1019, 1006,
- 1022, 12, 6,
- 1017, 1017, 3,
- 6, 1019,
- 1021, 2, 3,
- 1, 0,
-};
-
-/*
- * mobile algorithm (when you are moving with your device)
- * but not faster than 90 km/h
- */
-#define DIB3000MB_REG_MOBILE_ALGO ( 195)
-#define DIB3000MB_MOBILE_ALGO_ON ( 0)
-#define DIB3000MB_MOBILE_ALGO_OFF ( 1)
-
-/* multiple demodulators algorithm */
-#define DIB3000MB_REG_MULTI_DEMOD_MSB ( 206)
-#define DIB3000MB_REG_MULTI_DEMOD_LSB ( 207)
-
-/* terminator, no more demods */
-#define DIB3000MB_MULTI_DEMOD_MSB ( 32767)
-#define DIB3000MB_MULTI_DEMOD_LSB ( 4095)
-
-/* bring the device into a known */
-#define DIB3000MB_REG_RESET_DEVICE ( 1024)
-#define DIB3000MB_RESET_DEVICE (0x812c)
-#define DIB3000MB_RESET_DEVICE_RST ( 0)
-
-/* hardware clock configuration */
-#define DIB3000MB_REG_CLOCK ( 1027)
-#define DIB3000MB_CLOCK_DEFAULT (0x9000)
-#define DIB3000MB_CLOCK_DIVERSITY (0x92b0)
-
-/* power down config */
-#define DIB3000MB_REG_POWER_CONTROL ( 1028)
-#define DIB3000MB_POWER_DOWN ( 1)
-#define DIB3000MB_POWER_UP ( 0)
-
-/* electrical output mode */
-#define DIB3000MB_REG_ELECT_OUT_MODE ( 1029)
-#define DIB3000MB_ELECT_OUT_MODE_OFF ( 0)
-#define DIB3000MB_ELECT_OUT_MODE_ON ( 1)
-
-/* set the tuner i2c address */
-#define DIB3000MB_REG_TUNER ( 1089)
-
-/* monitoring registers (read only) */
-
-/* agc loop locked (size: 1) */
-#define DIB3000MB_REG_AGC_LOCK ( 324)
-
-/* agc power (size: 16) */
-#define DIB3000MB_REG_AGC_POWER ( 325)
-
-/* agc1 value (16) */
-#define DIB3000MB_REG_AGC1_VALUE ( 326)
-
-/* agc2 value (16) */
-#define DIB3000MB_REG_AGC2_VALUE ( 327)
-
-/* total RF power (16), can be used for signal strength */
-#define DIB3000MB_REG_RF_POWER ( 328)
-
-/* dds_frequency with offset (24) */
-#define DIB3000MB_REG_DDS_VALUE_MSB ( 339)
-#define DIB3000MB_REG_DDS_VALUE_LSB ( 340)
-
-/* timing offset signed (24) */
-#define DIB3000MB_REG_TIMING_OFFSET_MSB ( 341)
-#define DIB3000MB_REG_TIMING_OFFSET_LSB ( 342)
-
-/* fft start position (13) */
-#define DIB3000MB_REG_FFT_WINDOW_POS ( 353)
-
-/* carriers locked (1) */
-#define DIB3000MB_REG_CARRIER_LOCK ( 355)
-
-/* noise power (24) */
-#define DIB3000MB_REG_NOISE_POWER_MSB ( 372)
-#define DIB3000MB_REG_NOISE_POWER_LSB ( 373)
-
-#define DIB3000MB_REG_MOBILE_NOISE_MSB ( 374)
-#define DIB3000MB_REG_MOBILE_NOISE_LSB ( 375)
-
-/*
- * signal power (16), this and the above can be
- * used to calculate the signal/noise - ratio
- */
-#define DIB3000MB_REG_SIGNAL_POWER ( 380)
-
-/* mer (24) */
-#define DIB3000MB_REG_MER_MSB ( 381)
-#define DIB3000MB_REG_MER_LSB ( 382)
-
-/*
- * Transmission Parameter Signalling (TPS)
- * the following registers can be used to get TPS-information.
- * The values are according to the DVB-T standard.
- */
-
-/* TPS locked (1) */
-#define DIB3000MB_REG_TPS_LOCK ( 394)
-
-/* QAM from TPS (2) (values according to DIB3000MB_REG_QAM) */
-#define DIB3000MB_REG_TPS_QAM ( 398)
-
-/* hierarchy from TPS (1) */
-#define DIB3000MB_REG_TPS_HRCH ( 399)
-
-/* alpha from TPS (3) (values according to DIB3000MB_REG_VIT_ALPHA) */
-#define DIB3000MB_REG_TPS_VIT_ALPHA ( 400)
-
-/* code rate high priority from TPS (3) (values according to DIB3000MB_FEC_*) */
-#define DIB3000MB_REG_TPS_CODE_RATE_HP ( 401)
-
-/* code rate low priority from TPS (3) if DIB3000MB_REG_TPS_VIT_ALPHA */
-#define DIB3000MB_REG_TPS_CODE_RATE_LP ( 402)
-
-/* guard time from TPS (2) (values according to DIB3000MB_REG_GUARD_TIME */
-#define DIB3000MB_REG_TPS_GUARD_TIME ( 403)
-
-/* fft size from TPS (2) (values according to DIB3000MB_REG_FFT) */
-#define DIB3000MB_REG_TPS_FFT ( 404)
-
-/* cell id from TPS (16) */
-#define DIB3000MB_REG_TPS_CELL_ID ( 406)
-
-/* TPS (68) */
-#define DIB3000MB_REG_TPS_1 ( 408)
-#define DIB3000MB_REG_TPS_2 ( 409)
-#define DIB3000MB_REG_TPS_3 ( 410)
-#define DIB3000MB_REG_TPS_4 ( 411)
-#define DIB3000MB_REG_TPS_5 ( 412)
-
-/* bit error rate (before RS correction) (21) */
-#define DIB3000MB_REG_BER_MSB ( 414)
-#define DIB3000MB_REG_BER_LSB ( 415)
-
-/* packet error rate (uncorrected TS packets) (16) */
-#define DIB3000MB_REG_PACKET_ERROR_RATE ( 417)
-
-/* uncorrected packet count (16) */
-#define DIB3000MB_REG_UNC ( 420)
-
-/* viterbi locked (1) */
-#define DIB3000MB_REG_VIT_LCK ( 421)
-
-/* viterbi inidcator (16) */
-#define DIB3000MB_REG_VIT_INDICATOR ( 422)
-
-/* transport stream sync lock (1) */
-#define DIB3000MB_REG_TS_SYNC_LOCK ( 423)
-
-/* transport stream RS lock (1) */
-#define DIB3000MB_REG_TS_RS_LOCK ( 424)
-
-/* lock mask 0 value (1) */
-#define DIB3000MB_REG_LOCK0_VALUE ( 425)
-
-/* lock mask 1 value (1) */
-#define DIB3000MB_REG_LOCK1_VALUE ( 426)
-
-/* lock mask 2 value (1) */
-#define DIB3000MB_REG_LOCK2_VALUE ( 427)
-
-/* interrupt pending for auto search */
-#define DIB3000MB_REG_AS_IRQ_PENDING ( 434)
-
-#endif
diff --git a/drivers/media/dvb/frontends/dib3000mc.c b/drivers/media/dvb/frontends/dib3000mc.c
deleted file mode 100644
index 98673474a14..00000000000
--- a/drivers/media/dvb/frontends/dib3000mc.c
+++ /dev/null
@@ -1,913 +0,0 @@
-/*
- * Frontend driver for mobile DVB-T demodulator DiBcom 3000P/M-C
- * DiBcom (http://www.dibcom.fr/)
- *
- * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * based on GPL code from DiBCom, which has
- *
- * Copyright (C) 2004 Amaury Demol for DiBcom (ademol@dibcom.fr)
- *
- * 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.
- *
- * Acknowledgements
- *
- * Amaury Demol (ademol@dibcom.fr) from DiBcom for providing specs and driver
- * sources, on which this driver (and the dvb-dibusb) are based.
- *
- * see Documentation/dvb/README.dibusb for more information
- *
- */
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dib3000-common.h"
-#include "dib3000mc_priv.h"
-#include "dib3000.h"
-
-/* Version information */
-#define DRIVER_VERSION "0.1"
-#define DRIVER_DESC "DiBcom 3000M-C DVB-T demodulator"
-#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de"
-
-#ifdef CONFIG_DVB_DIBCOM_DEBUG
-static int debug;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "set debugging level (1=info,2=xfer,4=setfe,8=getfe,16=stat (|-able)).");
-#endif
-#define deb_info(args...) dprintk(0x01,args)
-#define deb_xfer(args...) dprintk(0x02,args)
-#define deb_setf(args...) dprintk(0x04,args)
-#define deb_getf(args...) dprintk(0x08,args)
-#define deb_stat(args...) dprintk(0x10,args)
-
-static int dib3000mc_set_impulse_noise(struct dib3000_state * state, int mode,
- fe_transmit_mode_t transmission_mode, fe_bandwidth_t bandwidth)
-{
- switch (transmission_mode) {
- case TRANSMISSION_MODE_2K:
- wr_foreach(dib3000mc_reg_fft,dib3000mc_fft_modes[0]);
- break;
- case TRANSMISSION_MODE_8K:
- wr_foreach(dib3000mc_reg_fft,dib3000mc_fft_modes[1]);
- break;
- default:
- break;
- }
-
- switch (bandwidth) {
-/* case BANDWIDTH_5_MHZ:
- wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[0]);
- break; */
- case BANDWIDTH_6_MHZ:
- wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[1]);
- break;
- case BANDWIDTH_7_MHZ:
- wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[2]);
- break;
- case BANDWIDTH_8_MHZ:
- wr_foreach(dib3000mc_reg_impulse_noise,dib3000mc_impluse_noise[3]);
- break;
- default:
- break;
- }
-
- switch (mode) {
- case 0: /* no impulse */ /* fall through */
- wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[0]);
- break;
- case 1: /* new algo */
- wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[1]);
- set_or(DIB3000MC_REG_IMP_NOISE_55,DIB3000MC_IMP_NEW_ALGO(0)); /* gives 1<<10 */
- break;
- default: /* old algo */
- wr_foreach(dib3000mc_reg_imp_noise_ctl,dib3000mc_imp_noise_ctl[3]);
- break;
- }
- return 0;
-}
-
-static int dib3000mc_set_timing(struct dib3000_state *state, int upd_offset,
- fe_transmit_mode_t fft, fe_bandwidth_t bw)
-{
- u16 timf_msb,timf_lsb;
- s32 tim_offset,tim_sgn;
- u64 comp1,comp2,comp=0;
-
- switch (bw) {
- case BANDWIDTH_8_MHZ: comp = DIB3000MC_CLOCK_REF*8; break;
- case BANDWIDTH_7_MHZ: comp = DIB3000MC_CLOCK_REF*7; break;
- case BANDWIDTH_6_MHZ: comp = DIB3000MC_CLOCK_REF*6; break;
- default: err("unknown bandwidth (%d)",bw); break;
- }
- timf_msb = (comp >> 16) & 0xff;
- timf_lsb = (comp & 0xffff);
-
- // Update the timing offset ;
- if (upd_offset > 0) {
- if (!state->timing_offset_comp_done) {
- msleep(200);
- state->timing_offset_comp_done = 1;
- }
- tim_offset = rd(DIB3000MC_REG_TIMING_OFFS_MSB);
- if ((tim_offset & 0x2000) == 0x2000)
- tim_offset |= 0xC000;
- if (fft == TRANSMISSION_MODE_2K)
- tim_offset <<= 2;
- state->timing_offset += tim_offset;
- }
-
- tim_offset = state->timing_offset;
- if (tim_offset < 0) {
- tim_sgn = 1;
- tim_offset = -tim_offset;
- } else
- tim_sgn = 0;
-
- comp1 = (u32)tim_offset * (u32)timf_lsb ;
- comp2 = (u32)tim_offset * (u32)timf_msb ;
- comp = ((comp1 >> 16) + comp2) >> 7;
-
- if (tim_sgn == 0)
- comp = (u32)(timf_msb << 16) + (u32) timf_lsb + comp;
- else
- comp = (u32)(timf_msb << 16) + (u32) timf_lsb - comp ;
-
- timf_msb = (comp >> 16) & 0xff;
- timf_lsb = comp & 0xffff;
-
- wr(DIB3000MC_REG_TIMING_FREQ_MSB,timf_msb);
- wr(DIB3000MC_REG_TIMING_FREQ_LSB,timf_lsb);
- return 0;
-}
-
-static int dib3000mc_init_auto_scan(struct dib3000_state *state, fe_bandwidth_t bw, int boost)
-{
- if (boost) {
- wr(DIB3000MC_REG_SCAN_BOOST,DIB3000MC_SCAN_BOOST_ON);
- } else {
- wr(DIB3000MC_REG_SCAN_BOOST,DIB3000MC_SCAN_BOOST_OFF);
- }
- switch (bw) {
- case BANDWIDTH_8_MHZ:
- wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_8mhz);
- break;
- case BANDWIDTH_7_MHZ:
- wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_7mhz);
- break;
- case BANDWIDTH_6_MHZ:
- wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_6mhz);
- break;
-/* case BANDWIDTH_5_MHZ:
- wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_5mhz);
- break;*/
- case BANDWIDTH_AUTO:
- return -EOPNOTSUPP;
- default:
- err("unknown bandwidth value (%d).",bw);
- return -EINVAL;
- }
- if (boost) {
- u32 timeout = (rd(DIB3000MC_REG_BW_TIMOUT_MSB) << 16) +
- rd(DIB3000MC_REG_BW_TIMOUT_LSB);
- timeout *= 85; timeout >>= 7;
- wr(DIB3000MC_REG_BW_TIMOUT_MSB,(timeout >> 16) & 0xffff);
- wr(DIB3000MC_REG_BW_TIMOUT_LSB,timeout & 0xffff);
- }
- return 0;
-}
-
-static int dib3000mc_set_adp_cfg(struct dib3000_state *state, fe_modulation_t con)
-{
- switch (con) {
- case QAM_64:
- wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[2]);
- break;
- case QAM_16:
- wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[1]);
- break;
- case QPSK:
- wr_foreach(dib3000mc_reg_adp_cfg,dib3000mc_adp_cfg[0]);
- break;
- case QAM_AUTO:
- break;
- default:
- warn("unkown constellation.");
- break;
- }
- return 0;
-}
-
-static int dib3000mc_set_general_cfg(struct dib3000_state *state, struct dvb_frontend_parameters *fep, int *auto_val)
-{
- struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
- fe_code_rate_t fe_cr = FEC_NONE;
- u8 fft=0, guard=0, qam=0, alpha=0, sel_hp=0, cr=0, hrch=0;
- int seq;
-
- switch (ofdm->transmission_mode) {
- case TRANSMISSION_MODE_2K: fft = DIB3000_TRANSMISSION_MODE_2K; break;
- case TRANSMISSION_MODE_8K: fft = DIB3000_TRANSMISSION_MODE_8K; break;
- case TRANSMISSION_MODE_AUTO: break;
- default: return -EINVAL;
- }
- switch (ofdm->guard_interval) {
- case GUARD_INTERVAL_1_32: guard = DIB3000_GUARD_TIME_1_32; break;
- case GUARD_INTERVAL_1_16: guard = DIB3000_GUARD_TIME_1_16; break;
- case GUARD_INTERVAL_1_8: guard = DIB3000_GUARD_TIME_1_8; break;
- case GUARD_INTERVAL_1_4: guard = DIB3000_GUARD_TIME_1_4; break;
- case GUARD_INTERVAL_AUTO: break;
- default: return -EINVAL;
- }
- switch (ofdm->constellation) {
- case QPSK: qam = DIB3000_CONSTELLATION_QPSK; break;
- case QAM_16: qam = DIB3000_CONSTELLATION_16QAM; break;
- case QAM_64: qam = DIB3000_CONSTELLATION_64QAM; break;
- case QAM_AUTO: break;
- default: return -EINVAL;
- }
- switch (ofdm->hierarchy_information) {
- case HIERARCHY_NONE: /* fall through */
- case HIERARCHY_1: alpha = DIB3000_ALPHA_1; break;
- case HIERARCHY_2: alpha = DIB3000_ALPHA_2; break;
- case HIERARCHY_4: alpha = DIB3000_ALPHA_4; break;
- case HIERARCHY_AUTO: break;
- default: return -EINVAL;
- }
- if (ofdm->hierarchy_information == HIERARCHY_NONE) {
- hrch = DIB3000_HRCH_OFF;
- sel_hp = DIB3000_SELECT_HP;
- fe_cr = ofdm->code_rate_HP;
- } else if (ofdm->hierarchy_information != HIERARCHY_AUTO) {
- hrch = DIB3000_HRCH_ON;
- sel_hp = DIB3000_SELECT_LP;
- fe_cr = ofdm->code_rate_LP;
- }
- switch (fe_cr) {
- case FEC_1_2: cr = DIB3000_FEC_1_2; break;
- case FEC_2_3: cr = DIB3000_FEC_2_3; break;
- case FEC_3_4: cr = DIB3000_FEC_3_4; break;
- case FEC_5_6: cr = DIB3000_FEC_5_6; break;
- case FEC_7_8: cr = DIB3000_FEC_7_8; break;
- case FEC_NONE: break;
- case FEC_AUTO: break;
- default: return -EINVAL;
- }
-
- wr(DIB3000MC_REG_DEMOD_PARM,DIB3000MC_DEMOD_PARM(alpha,qam,guard,fft));
- wr(DIB3000MC_REG_HRCH_PARM,DIB3000MC_HRCH_PARM(sel_hp,cr,hrch));
-
- switch (fep->inversion) {
- case INVERSION_OFF:
- wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_OFF);
- break;
- case INVERSION_AUTO: /* fall through */
- case INVERSION_ON:
- wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_ON);
- break;
- default:
- return -EINVAL;
- }
-
- seq = dib3000_seq
- [ofdm->transmission_mode == TRANSMISSION_MODE_AUTO]
- [ofdm->guard_interval == GUARD_INTERVAL_AUTO]
- [fep->inversion == INVERSION_AUTO];
-
- deb_setf("seq? %d\n", seq);
- wr(DIB3000MC_REG_SEQ_TPS,DIB3000MC_SEQ_TPS(seq,1));
- *auto_val = ofdm->constellation == QAM_AUTO ||
- ofdm->hierarchy_information == HIERARCHY_AUTO ||
- ofdm->guard_interval == GUARD_INTERVAL_AUTO ||
- ofdm->transmission_mode == TRANSMISSION_MODE_AUTO ||
- fe_cr == FEC_AUTO ||
- fep->inversion == INVERSION_AUTO;
- return 0;
-}
-
-static int dib3000mc_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
- fe_code_rate_t *cr;
- u16 tps_val,cr_val;
- int inv_test1,inv_test2;
- u32 dds_val, threshold = 0x1000000;
-
- if (!(rd(DIB3000MC_REG_LOCK_507) & DIB3000MC_LOCK_507))
- return 0;
-
- dds_val = (rd(DIB3000MC_REG_DDS_FREQ_MSB) << 16) + rd(DIB3000MC_REG_DDS_FREQ_LSB);
- deb_getf("DDS_FREQ: %6x\n",dds_val);
- if (dds_val < threshold)
- inv_test1 = 0;
- else if (dds_val == threshold)
- inv_test1 = 1;
- else
- inv_test1 = 2;
-
- dds_val = (rd(DIB3000MC_REG_SET_DDS_FREQ_MSB) << 16) + rd(DIB3000MC_REG_SET_DDS_FREQ_LSB);
- deb_getf("DDS_SET_FREQ: %6x\n",dds_val);
- if (dds_val < threshold)
- inv_test2 = 0;
- else if (dds_val == threshold)
- inv_test2 = 1;
- else
- inv_test2 = 2;
-
- fep->inversion =
- ((inv_test2 == 2) && (inv_test1==1 || inv_test1==0)) ||
- ((inv_test2 == 0) && (inv_test1==1 || inv_test1==2)) ?
- INVERSION_ON : INVERSION_OFF;
-
- deb_getf("inversion %d %d, %d\n", inv_test2, inv_test1, fep->inversion);
-
- fep->frequency = state->last_tuned_freq;
- fep->u.ofdm.bandwidth= state->last_tuned_bw;
-
- tps_val = rd(DIB3000MC_REG_TUNING_PARM);
-
- switch (DIB3000MC_TP_QAM(tps_val)) {
- case DIB3000_CONSTELLATION_QPSK:
- deb_getf("QPSK ");
- ofdm->constellation = QPSK;
- break;
- case DIB3000_CONSTELLATION_16QAM:
- deb_getf("QAM16 ");
- ofdm->constellation = QAM_16;
- break;
- case DIB3000_CONSTELLATION_64QAM:
- deb_getf("QAM64 ");
- ofdm->constellation = QAM_64;
- break;
- default:
- err("Unexpected constellation returned by TPS (%d)", tps_val);
- break;
- }
-
- if (DIB3000MC_TP_HRCH(tps_val)) {
- deb_getf("HRCH ON ");
- cr = &ofdm->code_rate_LP;
- ofdm->code_rate_HP = FEC_NONE;
- switch (DIB3000MC_TP_ALPHA(tps_val)) {
- case DIB3000_ALPHA_0:
- deb_getf("HIERARCHY_NONE ");
- ofdm->hierarchy_information = HIERARCHY_NONE;
- break;
- case DIB3000_ALPHA_1:
- deb_getf("HIERARCHY_1 ");
- ofdm->hierarchy_information = HIERARCHY_1;
- break;
- case DIB3000_ALPHA_2:
- deb_getf("HIERARCHY_2 ");
- ofdm->hierarchy_information = HIERARCHY_2;
- break;
- case DIB3000_ALPHA_4:
- deb_getf("HIERARCHY_4 ");
- ofdm->hierarchy_information = HIERARCHY_4;
- break;
- default:
- err("Unexpected ALPHA value returned by TPS (%d)", tps_val);
- break;
- }
- cr_val = DIB3000MC_TP_FEC_CR_LP(tps_val);
- } else {
- deb_getf("HRCH OFF ");
- cr = &ofdm->code_rate_HP;
- ofdm->code_rate_LP = FEC_NONE;
- ofdm->hierarchy_information = HIERARCHY_NONE;
- cr_val = DIB3000MC_TP_FEC_CR_HP(tps_val);
- }
-
- switch (cr_val) {
- case DIB3000_FEC_1_2:
- deb_getf("FEC_1_2 ");
- *cr = FEC_1_2;
- break;
- case DIB3000_FEC_2_3:
- deb_getf("FEC_2_3 ");
- *cr = FEC_2_3;
- break;
- case DIB3000_FEC_3_4:
- deb_getf("FEC_3_4 ");
- *cr = FEC_3_4;
- break;
- case DIB3000_FEC_5_6:
- deb_getf("FEC_5_6 ");
- *cr = FEC_4_5;
- break;
- case DIB3000_FEC_7_8:
- deb_getf("FEC_7_8 ");
- *cr = FEC_7_8;
- break;
- default:
- err("Unexpected FEC returned by TPS (%d)", tps_val);
- break;
- }
-
- switch (DIB3000MC_TP_GUARD(tps_val)) {
- case DIB3000_GUARD_TIME_1_32:
- deb_getf("GUARD_INTERVAL_1_32 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_32;
- break;
- case DIB3000_GUARD_TIME_1_16:
- deb_getf("GUARD_INTERVAL_1_16 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_16;
- break;
- case DIB3000_GUARD_TIME_1_8:
- deb_getf("GUARD_INTERVAL_1_8 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_8;
- break;
- case DIB3000_GUARD_TIME_1_4:
- deb_getf("GUARD_INTERVAL_1_4 ");
- ofdm->guard_interval = GUARD_INTERVAL_1_4;
- break;
- default:
- err("Unexpected Guard Time returned by TPS (%d)", tps_val);
- break;
- }
-
- switch (DIB3000MC_TP_FFT(tps_val)) {
- case DIB3000_TRANSMISSION_MODE_2K:
- deb_getf("TRANSMISSION_MODE_2K ");
- ofdm->transmission_mode = TRANSMISSION_MODE_2K;
- break;
- case DIB3000_TRANSMISSION_MODE_8K:
- deb_getf("TRANSMISSION_MODE_8K ");
- ofdm->transmission_mode = TRANSMISSION_MODE_8K;
- break;
- default:
- err("unexpected transmission mode return by TPS (%d)", tps_val);
- break;
- }
- deb_getf("\n");
-
- return 0;
-}
-
-static int dib3000mc_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fep, int tuner)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- struct dvb_ofdm_parameters *ofdm = &fep->u.ofdm;
- int search_state,auto_val;
- u16 val;
-
- if (tuner && fe->ops.tuner_ops.set_params) { /* initial call from dvb */
- fe->ops.tuner_ops.set_params(fe, fep);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
-
- state->last_tuned_freq = fep->frequency;
- // if (!scanboost) {
- dib3000mc_set_timing(state,0,ofdm->transmission_mode,ofdm->bandwidth);
- dib3000mc_init_auto_scan(state, ofdm->bandwidth, 0);
- state->last_tuned_bw = ofdm->bandwidth;
-
- wr_foreach(dib3000mc_reg_agc_bandwidth,dib3000mc_agc_bandwidth);
- wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_AGC);
- wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_OFF);
-
- /* Default cfg isi offset adp */
- wr_foreach(dib3000mc_reg_offset,dib3000mc_offset[0]);
-
- wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT | DIB3000MC_ISI_INHIBIT);
- dib3000mc_set_adp_cfg(state,ofdm->constellation);
- wr(DIB3000MC_REG_UNK_133,DIB3000MC_UNK_133);
-
- wr_foreach(dib3000mc_reg_bandwidth_general,dib3000mc_bandwidth_general);
- /* power smoothing */
- if (ofdm->bandwidth != BANDWIDTH_8_MHZ) {
- wr_foreach(dib3000mc_reg_bw,dib3000mc_bw[0]);
- } else {
- wr_foreach(dib3000mc_reg_bw,dib3000mc_bw[3]);
- }
- auto_val = 0;
- dib3000mc_set_general_cfg(state,fep,&auto_val);
- dib3000mc_set_impulse_noise(state,0,ofdm->constellation,ofdm->bandwidth);
-
- val = rd(DIB3000MC_REG_DEMOD_PARM);
- wr(DIB3000MC_REG_DEMOD_PARM,val|DIB3000MC_DEMOD_RST_DEMOD_ON);
- wr(DIB3000MC_REG_DEMOD_PARM,val);
- // }
- msleep(70);
-
- /* something has to be auto searched */
- if (auto_val) {
- int as_count=0;
-
- deb_setf("autosearch enabled.\n");
-
- val = rd(DIB3000MC_REG_DEMOD_PARM);
- wr(DIB3000MC_REG_DEMOD_PARM,val | DIB3000MC_DEMOD_RST_AUTO_SRCH_ON);
- wr(DIB3000MC_REG_DEMOD_PARM,val);
-
- while ((search_state = dib3000_search_status(
- rd(DIB3000MC_REG_AS_IRQ),1)) < 0 && as_count++ < 100)
- msleep(10);
-
- deb_info("search_state after autosearch %d after %d checks\n",search_state,as_count);
-
- if (search_state == 1) {
- struct dvb_frontend_parameters feps;
- if (dib3000mc_get_frontend(fe, &feps) == 0) {
- deb_setf("reading tuning data from frontend succeeded.\n");
- return dib3000mc_set_frontend(fe, &feps, 0);
- }
- }
- } else {
- dib3000mc_set_impulse_noise(state,0,ofdm->transmission_mode,ofdm->bandwidth);
- wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT|DIB3000MC_ISI_ACTIVATE);
- dib3000mc_set_adp_cfg(state,ofdm->constellation);
-
- /* set_offset_cfg */
- wr_foreach(dib3000mc_reg_offset,
- dib3000mc_offset[(ofdm->transmission_mode == TRANSMISSION_MODE_8K)+1]);
- }
- } else { /* second call, after autosearch (fka: set_WithKnownParams) */
-// dib3000mc_set_timing(state,1,ofdm->transmission_mode,ofdm->bandwidth);
-
- auto_val = 0;
- dib3000mc_set_general_cfg(state,fep,&auto_val);
- if (auto_val)
- deb_info("auto_val is true, even though an auto search was already performed.\n");
-
- dib3000mc_set_impulse_noise(state,0,ofdm->constellation,ofdm->bandwidth);
-
- val = rd(DIB3000MC_REG_DEMOD_PARM);
- wr(DIB3000MC_REG_DEMOD_PARM,val | DIB3000MC_DEMOD_RST_AUTO_SRCH_ON);
- wr(DIB3000MC_REG_DEMOD_PARM,val);
-
- msleep(30);
-
- wr(DIB3000MC_REG_ISI,DIB3000MC_ISI_DEFAULT|DIB3000MC_ISI_ACTIVATE);
- dib3000mc_set_adp_cfg(state,ofdm->constellation);
- wr_foreach(dib3000mc_reg_offset,
- dib3000mc_offset[(ofdm->transmission_mode == TRANSMISSION_MODE_8K)+1]);
- }
- return 0;
-}
-
-static int dib3000mc_fe_init(struct dvb_frontend* fe, int mobile_mode)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- deb_info("init start\n");
-
- state->timing_offset = 0;
- state->timing_offset_comp_done = 0;
-
- wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_CONFIG);
- wr(DIB3000MC_REG_RESTART,DIB3000MC_RESTART_OFF);
- wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_UP);
- wr(DIB3000MC_REG_CLK_CFG_2,DIB3000MC_CLK_CFG_2_PUP_MOBILE);
- wr(DIB3000MC_REG_CLK_CFG_3,DIB3000MC_CLK_CFG_3_POWER_UP);
- wr(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_INIT);
-
- wr(DIB3000MC_REG_RST_UNC,DIB3000MC_RST_UNC_OFF);
- wr(DIB3000MC_REG_UNK_19,DIB3000MC_UNK_19);
-
- wr(33,5);
- wr(36,81);
- wr(DIB3000MC_REG_UNK_88,DIB3000MC_UNK_88);
-
- wr(DIB3000MC_REG_UNK_99,DIB3000MC_UNK_99);
- wr(DIB3000MC_REG_UNK_111,DIB3000MC_UNK_111_PH_N_MODE_0); /* phase noise algo off */
-
- /* mobile mode - portable reception */
- wr_foreach(dib3000mc_reg_mobile_mode,dib3000mc_mobile_mode[1]);
-
-/* TUNER_PANASONIC_ENV57H12D5: */
- wr_foreach(dib3000mc_reg_agc_bandwidth,dib3000mc_agc_bandwidth);
- wr_foreach(dib3000mc_reg_agc_bandwidth_general,dib3000mc_agc_bandwidth_general);
- wr_foreach(dib3000mc_reg_agc,dib3000mc_agc_tuner[1]);
-
- wr(DIB3000MC_REG_UNK_110,DIB3000MC_UNK_110);
- wr(26,0x6680);
- wr(DIB3000MC_REG_UNK_1,DIB3000MC_UNK_1);
- wr(DIB3000MC_REG_UNK_2,DIB3000MC_UNK_2);
- wr(DIB3000MC_REG_UNK_3,DIB3000MC_UNK_3);
- wr(DIB3000MC_REG_SEQ_TPS,DIB3000MC_SEQ_TPS_DEFAULT);
-
- wr_foreach(dib3000mc_reg_bandwidth,dib3000mc_bandwidth_8mhz);
- wr_foreach(dib3000mc_reg_bandwidth_general,dib3000mc_bandwidth_general);
-
- wr(DIB3000MC_REG_UNK_4,DIB3000MC_UNK_4);
-
- wr(DIB3000MC_REG_SET_DDS_FREQ_MSB,DIB3000MC_DDS_FREQ_MSB_INV_OFF);
- wr(DIB3000MC_REG_SET_DDS_FREQ_LSB,DIB3000MC_DDS_FREQ_LSB);
-
- dib3000mc_set_timing(state,0,TRANSMISSION_MODE_8K,BANDWIDTH_8_MHZ);
-// wr_foreach(dib3000mc_reg_timing_freq,dib3000mc_timing_freq[3]);
-
- wr(DIB3000MC_REG_UNK_120,DIB3000MC_UNK_120);
- wr(DIB3000MC_REG_UNK_134,DIB3000MC_UNK_134);
- wr(DIB3000MC_REG_FEC_CFG,DIB3000MC_FEC_CFG);
-
- wr(DIB3000MC_REG_DIVERSITY3,DIB3000MC_DIVERSITY3_IN_OFF);
-
- dib3000mc_set_impulse_noise(state,0,TRANSMISSION_MODE_8K,BANDWIDTH_8_MHZ);
-
-/* output mode control, just the MPEG2_SLAVE */
-// set_or(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_SLAVE);
- wr(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_SLAVE);
- wr(DIB3000MC_REG_SMO_MODE,DIB3000MC_SMO_MODE_SLAVE);
- wr(DIB3000MC_REG_FIFO_THRESHOLD,DIB3000MC_FIFO_THRESHOLD_SLAVE);
- wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_SLAVE);
-
-/* MPEG2_PARALLEL_CONTINUOUS_CLOCK
- wr(DIB3000MC_REG_OUTMODE,
- DIB3000MC_SET_OUTMODE(DIB3000MC_OM_PAR_CONT_CLK,
- rd(DIB3000MC_REG_OUTMODE)));
-
- wr(DIB3000MC_REG_SMO_MODE,
- DIB3000MC_SMO_MODE_DEFAULT |
- DIB3000MC_SMO_MODE_188);
-
- wr(DIB3000MC_REG_FIFO_THRESHOLD,DIB3000MC_FIFO_THRESHOLD_DEFAULT);
- wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_DIV_OUT_ON);
-*/
-
-/* diversity */
- wr(DIB3000MC_REG_DIVERSITY1,DIB3000MC_DIVERSITY1_DEFAULT);
- wr(DIB3000MC_REG_DIVERSITY2,DIB3000MC_DIVERSITY2_DEFAULT);
-
- set_and(DIB3000MC_REG_DIVERSITY3,DIB3000MC_DIVERSITY3_IN_OFF);
-
- set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_DIV_IN_OFF);
-
- deb_info("init end\n");
- return 0;
-}
-static int dib3000mc_read_status(struct dvb_frontend* fe, fe_status_t *stat)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- u16 lock = rd(DIB3000MC_REG_LOCKING);
-
- *stat = 0;
- if (DIB3000MC_AGC_LOCK(lock))
- *stat |= FE_HAS_SIGNAL;
- if (DIB3000MC_CARRIER_LOCK(lock))
- *stat |= FE_HAS_CARRIER;
- if (DIB3000MC_TPS_LOCK(lock))
- *stat |= FE_HAS_VITERBI;
- if (DIB3000MC_MPEG_SYNC_LOCK(lock))
- *stat |= (FE_HAS_SYNC | FE_HAS_LOCK);
-
- deb_stat("actual status is %2x fifo_level: %x,244: %x, 206: %x, 207: %x, 1040: %x\n",*stat,rd(510),rd(244),rd(206),rd(207),rd(1040));
-
- return 0;
-}
-
-static int dib3000mc_read_ber(struct dvb_frontend* fe, u32 *ber)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- *ber = ((rd(DIB3000MC_REG_BER_MSB) << 16) | rd(DIB3000MC_REG_BER_LSB));
- return 0;
-}
-
-static int dib3000mc_read_unc_blocks(struct dvb_frontend* fe, u32 *unc)
-{
- struct dib3000_state* state = fe->demodulator_priv;
-
- *unc = rd(DIB3000MC_REG_PACKET_ERRORS);
- return 0;
-}
-
-/* see dib3000mb.c for calculation comments */
-static int dib3000mc_read_signal_strength(struct dvb_frontend* fe, u16 *strength)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB);
- *strength = (((val >> 6) & 0xff) << 8) + (val & 0x3f);
-
- deb_stat("signal: mantisse = %d, exponent = %d\n",(*strength >> 8) & 0xff, *strength & 0xff);
- return 0;
-}
-
-/* see dib3000mb.c for calculation comments */
-static int dib3000mc_read_snr(struct dvb_frontend* fe, u16 *snr)
-{
- struct dib3000_state* state = fe->demodulator_priv;
- u16 val = rd(DIB3000MC_REG_SIGNAL_NOISE_LSB),
- val2 = rd(DIB3000MC_REG_SIGNAL_NOISE_MSB);
- u16 sig,noise;
-
- sig = (((val >> 6) & 0xff) << 8) + (val & 0x3f);
- noise = (((val >> 4) & 0xff) << 8) + ((val & 0xf) << 2) + ((val2 >> 14) & 0x3);
- if (noise == 0)
- *snr = 0xffff;
- else
- *snr = (u16) sig/noise;
-
- deb_stat("signal: mantisse = %d, exponent = %d\n",(sig >> 8) & 0xff, sig & 0xff);
- deb_stat("noise: mantisse = %d, exponent = %d\n",(noise >> 8) & 0xff, noise & 0xff);
- deb_stat("snr: %d\n",*snr);
- return 0;
-}
-
-static int dib3000mc_sleep(struct dvb_frontend* fe)
-{
- struct dib3000_state* state = fe->demodulator_priv;
-
- set_or(DIB3000MC_REG_CLK_CFG_7,DIB3000MC_CLK_CFG_7_PWR_DOWN);
- wr(DIB3000MC_REG_CLK_CFG_1,DIB3000MC_CLK_CFG_1_POWER_DOWN);
- wr(DIB3000MC_REG_CLK_CFG_2,DIB3000MC_CLK_CFG_2_POWER_DOWN);
- wr(DIB3000MC_REG_CLK_CFG_3,DIB3000MC_CLK_CFG_3_POWER_DOWN);
- return 0;
-}
-
-static int dib3000mc_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- tune->min_delay_ms = 1000;
- return 0;
-}
-
-static int dib3000mc_fe_init_nonmobile(struct dvb_frontend* fe)
-{
- return dib3000mc_fe_init(fe, 0);
-}
-
-static int dib3000mc_set_frontend_and_tuner(struct dvb_frontend* fe, struct dvb_frontend_parameters *fep)
-{
- return dib3000mc_set_frontend(fe, fep, 1);
-}
-
-static void dib3000mc_release(struct dvb_frontend* fe)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- kfree(state);
-}
-
-/* pid filter and transfer stuff */
-static int dib3000mc_pid_control(struct dvb_frontend *fe,int index, int pid,int onoff)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- pid = (onoff ? pid | DIB3000_ACTIVATE_PID_FILTERING : 0);
- wr(index+DIB3000MC_REG_FIRST_PID,pid);
- return 0;
-}
-
-static int dib3000mc_fifo_control(struct dvb_frontend *fe, int onoff)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- u16 tmp = rd(DIB3000MC_REG_SMO_MODE);
-
- deb_xfer("%s fifo\n",onoff ? "enabling" : "disabling");
-
- if (onoff) {
- deb_xfer("%d %x\n",tmp & DIB3000MC_SMO_MODE_FIFO_UNFLUSH,tmp & DIB3000MC_SMO_MODE_FIFO_UNFLUSH);
- wr(DIB3000MC_REG_SMO_MODE,tmp & DIB3000MC_SMO_MODE_FIFO_UNFLUSH);
- } else {
- deb_xfer("%d %x\n",tmp | DIB3000MC_SMO_MODE_FIFO_FLUSH,tmp | DIB3000MC_SMO_MODE_FIFO_FLUSH);
- wr(DIB3000MC_REG_SMO_MODE,tmp | DIB3000MC_SMO_MODE_FIFO_FLUSH);
- }
- return 0;
-}
-
-static int dib3000mc_pid_parse(struct dvb_frontend *fe, int onoff)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- u16 tmp = rd(DIB3000MC_REG_SMO_MODE);
-
- deb_xfer("%s pid parsing\n",onoff ? "enabling" : "disabling");
-
- if (onoff) {
- wr(DIB3000MC_REG_SMO_MODE,tmp | DIB3000MC_SMO_MODE_PID_PARSE);
- } else {
- wr(DIB3000MC_REG_SMO_MODE,tmp & DIB3000MC_SMO_MODE_NO_PID_PARSE);
- }
- return 0;
-}
-
-static int dib3000mc_tuner_pass_ctrl(struct dvb_frontend *fe, int onoff, u8 pll_addr)
-{
- struct dib3000_state *state = fe->demodulator_priv;
- if (onoff) {
- wr(DIB3000MC_REG_TUNER, DIB3000_TUNER_WRITE_ENABLE(pll_addr));
- } else {
- wr(DIB3000MC_REG_TUNER, DIB3000_TUNER_WRITE_DISABLE(pll_addr));
- }
- return 0;
-}
-
-static int dib3000mc_demod_init(struct dib3000_state *state)
-{
- u16 default_addr = 0x0a;
- /* first init */
- if (state->config.demod_address != default_addr) {
- deb_info("initializing the demod the first time. Setting demod addr to 0x%x\n",default_addr);
- wr(DIB3000MC_REG_ELEC_OUT,DIB3000MC_ELEC_OUT_DIV_OUT_ON);
- wr(DIB3000MC_REG_OUTMODE,DIB3000MC_OM_PAR_CONT_CLK);
-
- wr(DIB3000MC_REG_RST_I2C_ADDR,
- DIB3000MC_DEMOD_ADDR(default_addr) |
- DIB3000MC_DEMOD_ADDR_ON);
-
- state->config.demod_address = default_addr;
-
- wr(DIB3000MC_REG_RST_I2C_ADDR,
- DIB3000MC_DEMOD_ADDR(default_addr));
- } else
- deb_info("demod is already initialized. Demod addr: 0x%x\n",state->config.demod_address);
- return 0;
-}
-
-
-static struct dvb_frontend_ops dib3000mc_ops;
-
-struct dvb_frontend* dib3000mc_attach(const struct dib3000_config* config,
- struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops)
-{
- struct dib3000_state* state = NULL;
- u16 devid;
-
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct dib3000_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->i2c = i2c;
- memcpy(&state->config,config,sizeof(struct dib3000_config));
-
- /* check for the correct demod */
- if (rd(DIB3000_REG_MANUFACTOR_ID) != DIB3000_I2C_ID_DIBCOM)
- goto error;
-
- devid = rd(DIB3000_REG_DEVICE_ID);
- if (devid != DIB3000MC_DEVICE_ID && devid != DIB3000P_DEVICE_ID)
- goto error;
-
- switch (devid) {
- case DIB3000MC_DEVICE_ID:
- info("Found a DiBcom 3000M-C, interesting...");
- break;
- case DIB3000P_DEVICE_ID:
- info("Found a DiBcom 3000P.");
- break;
- }
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &dib3000mc_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
-
- /* set the xfer operations */
- xfer_ops->pid_parse = dib3000mc_pid_parse;
- xfer_ops->fifo_ctrl = dib3000mc_fifo_control;
- xfer_ops->pid_ctrl = dib3000mc_pid_control;
- xfer_ops->tuner_pass_ctrl = dib3000mc_tuner_pass_ctrl;
-
- dib3000mc_demod_init(state);
-
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-EXPORT_SYMBOL(dib3000mc_attach);
-
-static struct dvb_frontend_ops dib3000mc_ops = {
-
- .info = {
- .name = "DiBcom 3000P/M-C DVB-T",
- .type = FE_OFDM,
- .frequency_min = 44250000,
- .frequency_max = 867250000,
- .frequency_stepsize = 62500,
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO |
- FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_RECOVER |
- FE_CAN_HIERARCHY_AUTO,
- },
-
- .release = dib3000mc_release,
-
- .init = dib3000mc_fe_init_nonmobile,
- .sleep = dib3000mc_sleep,
-
- .set_frontend = dib3000mc_set_frontend_and_tuner,
- .get_frontend = dib3000mc_get_frontend,
- .get_tune_settings = dib3000mc_fe_get_tune_settings,
-
- .read_status = dib3000mc_read_status,
- .read_ber = dib3000mc_read_ber,
- .read_signal_strength = dib3000mc_read_signal_strength,
- .read_snr = dib3000mc_read_snr,
- .read_ucblocks = dib3000mc_read_unc_blocks,
-};
-
-MODULE_AUTHOR(DRIVER_AUTHOR);
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/dib3000mc_priv.h b/drivers/media/dvb/frontends/dib3000mc_priv.h
deleted file mode 100644
index 2930aac7591..00000000000
--- a/drivers/media/dvb/frontends/dib3000mc_priv.h
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * dib3000mc_priv.h
- *
- * Copyright (C) 2004 Patrick Boettcher (patrick.boettcher@desy.de)
- *
- * 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.
- *
- * for more information see dib3000mc.c .
- */
-
-#ifndef __DIB3000MC_PRIV_H__
-#define __DIB3000MC_PRIV_H__
-
-/*
- * Demodulator parameters
- * reg: 0 1 1 1 11 11 111
- * | | | | | |
- * | | | | | +-- alpha (000=0, 001=1, 010=2, 100=4)
- * | | | | +----- constellation (00=QPSK, 01=16QAM, 10=64QAM)
- * | | | +-------- guard (00=1/32, 01=1/16, 10=1/8, 11=1/4)
- * | | +----------- transmission mode (0=2k, 1=8k)
- * | |
- * | +-------------- restart autosearch for parameters
- * +---------------- restart the demodulator
- * reg: 181 1 111 1
- * | | |
- * | | +- FEC applies for HP or LP (0=LP, 1=HP)
- * | +---- FEC rate (001=1/2, 010=2/3, 011=3/4, 101=5/6, 111=7/8)
- * +------- hierarchy on (0=no, 1=yes)
- */
-
-/* demodulator tuning parameter and restart options */
-#define DIB3000MC_REG_DEMOD_PARM ( 0)
-#define DIB3000MC_DEMOD_PARM(a,c,g,t) ( \
- (0x7 & a) | \
- ((0x3 & c) << 3) | \
- ((0x3 & g) << 5) | \
- ((0x1 & t) << 7) )
-#define DIB3000MC_DEMOD_RST_AUTO_SRCH_ON (1 << 8)
-#define DIB3000MC_DEMOD_RST_AUTO_SRCH_OFF (0 << 8)
-#define DIB3000MC_DEMOD_RST_DEMOD_ON (1 << 9)
-#define DIB3000MC_DEMOD_RST_DEMOD_OFF (0 << 9)
-
-/* register for hierarchy parameters */
-#define DIB3000MC_REG_HRCH_PARM ( 181)
-#define DIB3000MC_HRCH_PARM(s,f,h) ( \
- (0x1 & s) | \
- ((0x7 & f) << 1) | \
- ((0x1 & h) << 4) )
-
-/* timeout ??? */
-#define DIB3000MC_REG_UNK_1 ( 1)
-#define DIB3000MC_UNK_1 ( 0x04)
-
-/* timeout ??? */
-#define DIB3000MC_REG_UNK_2 ( 2)
-#define DIB3000MC_UNK_2 ( 0x04)
-
-/* timeout ??? */
-#define DIB3000MC_REG_UNK_3 ( 3)
-#define DIB3000MC_UNK_3 (0x1000)
-
-#define DIB3000MC_REG_UNK_4 ( 4)
-#define DIB3000MC_UNK_4 (0x0814)
-
-/* timeout ??? */
-#define DIB3000MC_REG_SEQ_TPS ( 5)
-#define DIB3000MC_SEQ_TPS_DEFAULT ( 1)
-#define DIB3000MC_SEQ_TPS(s,t) ( \
- ((s & 0x0f) << 4) | \
- ((t & 0x01) << 8) )
-#define DIB3000MC_IS_TPS(v) ((v << 8) & 0x1)
-#define DIB3000MC_IS_AS(v) ((v >> 4) & 0xf)
-
-/* parameters for the bandwidth */
-#define DIB3000MC_REG_BW_TIMOUT_MSB ( 6)
-#define DIB3000MC_REG_BW_TIMOUT_LSB ( 7)
-
-static u16 dib3000mc_reg_bandwidth[] = { 6,7,8,9,10,11,16,17 };
-
-/*static u16 dib3000mc_bandwidth_5mhz[] =
- { 0x28, 0x9380, 0x87, 0x4100, 0x2a4, 0x4500, 0x1, 0xb0d0 };*/
-
-static u16 dib3000mc_bandwidth_6mhz[] =
- { 0x21, 0xd040, 0x70, 0xb62b, 0x233, 0x8ed5, 0x1, 0xb0d0 };
-
-static u16 dib3000mc_bandwidth_7mhz[] =
- { 0x1c, 0xfba5, 0x60, 0x9c25, 0x1e3, 0x0cb7, 0x1, 0xb0d0 };
-
-static u16 dib3000mc_bandwidth_8mhz[] =
- { 0x19, 0x5c30, 0x54, 0x88a0, 0x1a6, 0xab20, 0x1, 0xb0d0 };
-
-static u16 dib3000mc_reg_bandwidth_general[] = { 12,13,14,15 };
-static u16 dib3000mc_bandwidth_general[] = { 0x0000, 0x03e8, 0x0000, 0x03f2 };
-
-/* lock mask */
-#define DIB3000MC_REG_LOCK_MASK ( 15)
-#define DIB3000MC_ACTIVATE_LOCK_MASK (0x0800)
-
-/* reset the uncorrected packet count (??? do it 5 times) */
-#define DIB3000MC_REG_RST_UNC ( 18)
-#define DIB3000MC_RST_UNC_ON ( 1)
-#define DIB3000MC_RST_UNC_OFF ( 0)
-
-#define DIB3000MC_REG_UNK_19 ( 19)
-#define DIB3000MC_UNK_19 ( 0)
-
-/* DDS frequency value (IF position) and inversion bit */
-#define DIB3000MC_REG_INVERSION ( 21)
-#define DIB3000MC_REG_SET_DDS_FREQ_MSB ( 21)
-#define DIB3000MC_DDS_FREQ_MSB_INV_OFF (0x0164)
-#define DIB3000MC_DDS_FREQ_MSB_INV_ON (0x0364)
-
-#define DIB3000MC_REG_SET_DDS_FREQ_LSB ( 22)
-#define DIB3000MC_DDS_FREQ_LSB (0x463d)
-
-/* timing frequencies setting */
-#define DIB3000MC_REG_TIMING_FREQ_MSB ( 23)
-#define DIB3000MC_REG_TIMING_FREQ_LSB ( 24)
-#define DIB3000MC_CLOCK_REF (0x151fd1)
-
-//static u16 dib3000mc_reg_timing_freq[] = { 23,24 };
-
-//static u16 dib3000mc_timing_freq[][2] = {
-// { 0x69, 0x9f18 }, /* 5 MHz */
-// { 0x7e ,0xbee9 }, /* 6 MHz */
-// { 0x93 ,0xdebb }, /* 7 MHz */
-// { 0xa8 ,0xfe8c }, /* 8 MHz */
-//};
-
-/* timeout ??? */
-static u16 dib3000mc_reg_offset[] = { 26,33 };
-
-static u16 dib3000mc_offset[][2] = {
- { 26240, 5 }, /* default */
- { 30336, 6 }, /* 8K */
- { 38528, 8 }, /* 2K */
-};
-
-#define DIB3000MC_REG_ISI ( 29)
-#define DIB3000MC_ISI_DEFAULT (0x1073)
-#define DIB3000MC_ISI_ACTIVATE (0x0000)
-#define DIB3000MC_ISI_INHIBIT (0x0200)
-
-/* impulse noise control */
-static u16 dib3000mc_reg_imp_noise_ctl[] = { 34,35 };
-
-static u16 dib3000mc_imp_noise_ctl[][2] = {
- { 0x1294, 0x1ff8 }, /* mode 0 */
- { 0x1294, 0x1ff8 }, /* mode 1 */
- { 0x1294, 0x1ff8 }, /* mode 2 */
- { 0x1294, 0x1ff8 }, /* mode 3 */
- { 0x1294, 0x1ff8 }, /* mode 4 */
-};
-
-/* AGC registers */
-static u16 dib3000mc_reg_agc[] = {
- 36,37,38,39,42,43,44,45,46,47,48,49
-};
-
-static u16 dib3000mc_agc_tuner[][12] = {
- { 0x0051, 0x301d, 0x0000, 0x1cc7, 0xcf5c, 0x6666,
- 0xbae1, 0xa148, 0x3b5e, 0x3c1c, 0x001a, 0x2019
- }, /* TUNER_PANASONIC_ENV77H04D5, */
-
- { 0x0051, 0x301d, 0x0000, 0x1cc7, 0xdc29, 0x570a,
- 0xbae1, 0x8ccd, 0x3b6d, 0x551d, 0x000a, 0x951e
- }, /* TUNER_PANASONIC_ENV57H13D5, TUNER_PANASONIC_ENV57H12D5 */
-
- { 0x0051, 0x301d, 0x0000, 0x1cc7, 0xffff, 0xffff,
- 0xffff, 0x0000, 0xfdfd, 0x4040, 0x00fd, 0x4040
- }, /* TUNER_SAMSUNG_DTOS333IH102, TUNER_RFAGCIN_UNKNOWN */
-
- { 0x0196, 0x301d, 0x0000, 0x1cc7, 0xbd71, 0x5c29,
- 0xb5c3, 0x6148, 0x6569, 0x5127, 0x0033, 0x3537
- }, /* TUNER_PROVIDER_X */
- /* TODO TUNER_PANASONIC_ENV57H10D8, TUNER_PANASONIC_ENV57H11D8 */
-};
-
-/* AGC loop bandwidth */
-static u16 dib3000mc_reg_agc_bandwidth[] = { 40,41 };
-static u16 dib3000mc_agc_bandwidth[] = { 0x119,0x330 };
-
-static u16 dib3000mc_reg_agc_bandwidth_general[] = { 50,51,52,53,54 };
-static u16 dib3000mc_agc_bandwidth_general[] =
- { 0x8000, 0x91ca, 0x01ba, 0x0087, 0x0087 };
-
-#define DIB3000MC_REG_IMP_NOISE_55 ( 55)
-#define DIB3000MC_IMP_NEW_ALGO(w) (w | (1<<10))
-
-/* Impulse noise params */
-static u16 dib3000mc_reg_impulse_noise[] = { 55,56,57 };
-static u16 dib3000mc_impluse_noise[][3] = {
- { 0x489, 0x89, 0x72 }, /* 5 MHz */
- { 0x4a5, 0xa5, 0x89 }, /* 6 MHz */
- { 0x4c0, 0xc0, 0xa0 }, /* 7 MHz */
- { 0x4db, 0xdb, 0xb7 }, /* 8 Mhz */
-};
-
-static u16 dib3000mc_reg_fft[] = {
- 58,59,60,61,62,63,64,65,66,67,68,69,
- 70,71,72,73,74,75,76,77,78,79,80,81,
- 82,83,84,85,86
-};
-
-static u16 dib3000mc_fft_modes[][29] = {
- { 0x38, 0x6d9, 0x3f28, 0x7a7, 0x3a74, 0x196, 0x32a, 0x48c,
- 0x3ffe, 0x7f3, 0x2d94, 0x76, 0x53d,
- 0x3ff8, 0x7e3, 0x3320, 0x76, 0x5b3,
- 0x3feb, 0x7d2, 0x365e, 0x76, 0x48c,
- 0x3ffe, 0x5b3, 0x3feb, 0x76, 0x0, 0xd
- }, /* fft mode 0 */
- { 0x3b, 0x6d9, 0x3f28, 0x7a7, 0x3a74, 0x196, 0x32a, 0x48c,
- 0x3ffe, 0x7f3, 0x2d94, 0x76, 0x53d,
- 0x3ff8, 0x7e3, 0x3320, 0x76, 0x5b3,
- 0x3feb, 0x7d2, 0x365e, 0x76, 0x48c,
- 0x3ffe, 0x5b3, 0x3feb, 0x0, 0x8200, 0xd
- }, /* fft mode 1 */
-};
-
-#define DIB3000MC_REG_UNK_88 ( 88)
-#define DIB3000MC_UNK_88 (0x0410)
-
-static u16 dib3000mc_reg_bw[] = { 93,94,95,96,97,98 };
-static u16 dib3000mc_bw[][6] = {
- { 0,0,0,0,0,0 }, /* 5 MHz */
- { 0,0,0,0,0,0 }, /* 6 MHz */
- { 0,0,0,0,0,0 }, /* 7 MHz */
- { 0x20, 0x21, 0x20, 0x23, 0x20, 0x27 }, /* 8 MHz */
-};
-
-
-/* phase noise control */
-#define DIB3000MC_REG_UNK_99 ( 99)
-#define DIB3000MC_UNK_99 (0x0220)
-
-#define DIB3000MC_REG_SCAN_BOOST ( 100)
-#define DIB3000MC_SCAN_BOOST_ON ((11 << 6) + 6)
-#define DIB3000MC_SCAN_BOOST_OFF ((16 << 6) + 9)
-
-/* timeout ??? */
-#define DIB3000MC_REG_UNK_110 ( 110)
-#define DIB3000MC_UNK_110 ( 3277)
-
-#define DIB3000MC_REG_UNK_111 ( 111)
-#define DIB3000MC_UNK_111_PH_N_MODE_0 ( 0)
-#define DIB3000MC_UNK_111_PH_N_MODE_1 (1 << 1)
-
-/* superious rm config */
-#define DIB3000MC_REG_UNK_120 ( 120)
-#define DIB3000MC_UNK_120 ( 8207)
-
-#define DIB3000MC_REG_UNK_133 ( 133)
-#define DIB3000MC_UNK_133 ( 15564)
-
-#define DIB3000MC_REG_UNK_134 ( 134)
-#define DIB3000MC_UNK_134 ( 0)
-
-/* adapter config for constellation */
-static u16 dib3000mc_reg_adp_cfg[] = { 129, 130, 131, 132 };
-
-static u16 dib3000mc_adp_cfg[][4] = {
- { 0x99a, 0x7fae, 0x333, 0x7ff0 }, /* QPSK */
- { 0x23d, 0x7fdf, 0x0a4, 0x7ff0 }, /* 16-QAM */
- { 0x148, 0x7ff0, 0x0a4, 0x7ff8 }, /* 64-QAM */
-};
-
-static u16 dib3000mc_reg_mobile_mode[] = { 139, 140, 141, 175, 1032 };
-
-static u16 dib3000mc_mobile_mode[][5] = {
- { 0x01, 0x0, 0x0, 0x00, 0x12c }, /* fixed */
- { 0x01, 0x0, 0x0, 0x00, 0x12c }, /* portable */
- { 0x00, 0x0, 0x0, 0x02, 0x000 }, /* mobile */
- { 0x00, 0x0, 0x0, 0x02, 0x000 }, /* auto */
-};
-
-#define DIB3000MC_REG_DIVERSITY1 ( 177)
-#define DIB3000MC_DIVERSITY1_DEFAULT ( 1)
-
-#define DIB3000MC_REG_DIVERSITY2 ( 178)
-#define DIB3000MC_DIVERSITY2_DEFAULT ( 1)
-
-#define DIB3000MC_REG_DIVERSITY3 ( 180)
-#define DIB3000MC_DIVERSITY3_IN_OFF (0xfff0)
-#define DIB3000MC_DIVERSITY3_IN_ON (0xfff6)
-
-#define DIB3000MC_REG_FEC_CFG ( 195)
-#define DIB3000MC_FEC_CFG ( 0x10)
-
-/*
- * reg 206, output mode
- * 1111 1111
- * |||| ||||
- * |||| |||+- unk
- * |||| ||+-- unk
- * |||| |+--- unk (on by default)
- * |||| +---- fifo_ctrl (1 = inhibit (flushed), 0 = active (unflushed))
- * |||+------ pid_parse (1 = enabled, 0 = disabled)
- * ||+------- outp_188 (1 = TS packet size 188, 0 = packet size 204)
- * |+-------- unk
- * +--------- unk
- */
-
-#define DIB3000MC_REG_SMO_MODE ( 206)
-#define DIB3000MC_SMO_MODE_DEFAULT (1 << 2)
-#define DIB3000MC_SMO_MODE_FIFO_FLUSH (1 << 3)
-#define DIB3000MC_SMO_MODE_FIFO_UNFLUSH (0xfff7)
-#define DIB3000MC_SMO_MODE_PID_PARSE (1 << 4)
-#define DIB3000MC_SMO_MODE_NO_PID_PARSE (0xffef)
-#define DIB3000MC_SMO_MODE_188 (1 << 5)
-#define DIB3000MC_SMO_MODE_SLAVE (DIB3000MC_SMO_MODE_DEFAULT | \
- DIB3000MC_SMO_MODE_188 | DIB3000MC_SMO_MODE_PID_PARSE | (1<<1))
-
-#define DIB3000MC_REG_FIFO_THRESHOLD ( 207)
-#define DIB3000MC_FIFO_THRESHOLD_DEFAULT ( 1792)
-#define DIB3000MC_FIFO_THRESHOLD_SLAVE ( 512)
-/*
- * pidfilter
- * it is not a hardware pidfilter but a filter which drops all pids
- * except the ones set. When connected to USB1.1 bandwidth this is important.
- * DiB3000P/M-C can filter up to 32 PIDs
- */
-#define DIB3000MC_REG_FIRST_PID ( 212)
-#define DIB3000MC_NUM_PIDS ( 32)
-
-#define DIB3000MC_REG_OUTMODE ( 244)
-#define DIB3000MC_OM_PARALLEL_GATED_CLK ( 0)
-#define DIB3000MC_OM_PAR_CONT_CLK (1 << 11)
-#define DIB3000MC_OM_SERIAL (2 << 11)
-#define DIB3000MC_OM_DIVOUT_ON (4 << 11)
-#define DIB3000MC_OM_SLAVE (DIB3000MC_OM_DIVOUT_ON | DIB3000MC_OM_PAR_CONT_CLK)
-
-#define DIB3000MC_REG_RF_POWER ( 392)
-
-#define DIB3000MC_REG_FFT_POSITION ( 407)
-
-#define DIB3000MC_REG_DDS_FREQ_MSB ( 414)
-#define DIB3000MC_REG_DDS_FREQ_LSB ( 415)
-
-#define DIB3000MC_REG_TIMING_OFFS_MSB ( 416)
-#define DIB3000MC_REG_TIMING_OFFS_LSB ( 417)
-
-#define DIB3000MC_REG_TUNING_PARM ( 458)
-#define DIB3000MC_TP_QAM(v) ((v >> 13) & 0x03)
-#define DIB3000MC_TP_HRCH(v) ((v >> 12) & 0x01)
-#define DIB3000MC_TP_ALPHA(v) ((v >> 9) & 0x07)
-#define DIB3000MC_TP_FFT(v) ((v >> 8) & 0x01)
-#define DIB3000MC_TP_FEC_CR_HP(v) ((v >> 5) & 0x07)
-#define DIB3000MC_TP_FEC_CR_LP(v) ((v >> 2) & 0x07)
-#define DIB3000MC_TP_GUARD(v) (v & 0x03)
-
-#define DIB3000MC_REG_SIGNAL_NOISE_MSB ( 483)
-#define DIB3000MC_REG_SIGNAL_NOISE_LSB ( 484)
-
-#define DIB3000MC_REG_MER ( 485)
-
-#define DIB3000MC_REG_BER_MSB ( 500)
-#define DIB3000MC_REG_BER_LSB ( 501)
-
-#define DIB3000MC_REG_PACKET_ERRORS ( 503)
-
-#define DIB3000MC_REG_PACKET_ERROR_COUNT ( 506)
-
-#define DIB3000MC_REG_LOCK_507 ( 507)
-#define DIB3000MC_LOCK_507 (0x0002) // ? name correct ?
-
-#define DIB3000MC_REG_LOCKING ( 509)
-#define DIB3000MC_AGC_LOCK(v) (v & 0x8000)
-#define DIB3000MC_CARRIER_LOCK(v) (v & 0x2000)
-#define DIB3000MC_MPEG_SYNC_LOCK(v) (v & 0x0080)
-#define DIB3000MC_MPEG_DATA_LOCK(v) (v & 0x0040)
-#define DIB3000MC_TPS_LOCK(v) (v & 0x0004)
-
-#define DIB3000MC_REG_AS_IRQ ( 511)
-#define DIB3000MC_AS_IRQ_SUCCESS (1 << 1)
-#define DIB3000MC_AS_IRQ_FAIL ( 1)
-
-#define DIB3000MC_REG_TUNER ( 769)
-
-#define DIB3000MC_REG_RST_I2C_ADDR ( 1024)
-#define DIB3000MC_DEMOD_ADDR_ON ( 1)
-#define DIB3000MC_DEMOD_ADDR(a) ((a << 4) & 0x03F0)
-
-#define DIB3000MC_REG_RESTART ( 1027)
-#define DIB3000MC_RESTART_OFF (0x0000)
-#define DIB3000MC_RESTART_AGC (0x0800)
-#define DIB3000MC_RESTART_CONFIG (0x8000)
-
-#define DIB3000MC_REG_RESTART_VIT ( 1028)
-#define DIB3000MC_RESTART_VIT_OFF ( 0)
-#define DIB3000MC_RESTART_VIT_ON ( 1)
-
-#define DIB3000MC_REG_CLK_CFG_1 ( 1031)
-#define DIB3000MC_CLK_CFG_1_POWER_UP ( 0)
-#define DIB3000MC_CLK_CFG_1_POWER_DOWN (0xffff)
-
-#define DIB3000MC_REG_CLK_CFG_2 ( 1032)
-#define DIB3000MC_CLK_CFG_2_PUP_FIXED (0x012c)
-#define DIB3000MC_CLK_CFG_2_PUP_PORT (0x0104)
-#define DIB3000MC_CLK_CFG_2_PUP_MOBILE (0x0000)
-#define DIB3000MC_CLK_CFG_2_POWER_DOWN (0xffff)
-
-#define DIB3000MC_REG_CLK_CFG_3 ( 1033)
-#define DIB3000MC_CLK_CFG_3_POWER_UP ( 0)
-#define DIB3000MC_CLK_CFG_3_POWER_DOWN (0xfff5)
-
-#define DIB3000MC_REG_CLK_CFG_7 ( 1037)
-#define DIB3000MC_CLK_CFG_7_INIT ( 12592)
-#define DIB3000MC_CLK_CFG_7_POWER_UP (~0x0003)
-#define DIB3000MC_CLK_CFG_7_PWR_DOWN (0x0003)
-#define DIB3000MC_CLK_CFG_7_DIV_IN_OFF (1 << 8)
-
-/* was commented out ??? */
-#define DIB3000MC_REG_CLK_CFG_8 ( 1038)
-#define DIB3000MC_CLK_CFG_8_POWER_UP (0x160c)
-
-#define DIB3000MC_REG_CLK_CFG_9 ( 1039)
-#define DIB3000MC_CLK_CFG_9_POWER_UP ( 0)
-
-/* also clock ??? */
-#define DIB3000MC_REG_ELEC_OUT ( 1040)
-#define DIB3000MC_ELEC_OUT_HIGH_Z ( 0)
-#define DIB3000MC_ELEC_OUT_DIV_OUT_ON ( 1)
-#define DIB3000MC_ELEC_OUT_SLAVE ( 3)
-
-#endif
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c
deleted file mode 100644
index 2be33f27c69..00000000000
--- a/drivers/media/dvb/frontends/dvb-pll.c
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- * descriptions + helper functions for simple dvb plls.
- *
- * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
- *
- * 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/module.h>
-#include <linux/dvb/frontend.h>
-#include <asm/types.h>
-
-#include "dvb-pll.h"
-
-/* ----------------------------------------------------------- */
-/* descriptions */
-
-struct dvb_pll_desc dvb_pll_thomson_dtt7579 = {
- .name = "Thomson dtt7579",
- .min = 177000000,
- .max = 858000000,
- .count = 5,
- .entries = {
- { 0, 36166667, 166666, 0xb4, 0x03 }, /* go sleep */
- { 443250000, 36166667, 166666, 0xb4, 0x02 },
- { 542000000, 36166667, 166666, 0xb4, 0x08 },
- { 771000000, 36166667, 166666, 0xbc, 0x08 },
- { 999999999, 36166667, 166666, 0xf4, 0x08 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_thomson_dtt7579);
-
-struct dvb_pll_desc dvb_pll_thomson_dtt7610 = {
- .name = "Thomson dtt7610",
- .min = 44000000,
- .max = 958000000,
- .count = 3,
- .entries = {
- { 157250000, 44000000, 62500, 0x8e, 0x39 },
- { 454000000, 44000000, 62500, 0x8e, 0x3a },
- { 999999999, 44000000, 62500, 0x8e, 0x3c },
- },
-};
-EXPORT_SYMBOL(dvb_pll_thomson_dtt7610);
-
-static void thomson_dtt759x_bw(u8 *buf, u32 freq, int bandwidth)
-{
- if (BANDWIDTH_7_MHZ == bandwidth)
- buf[3] |= 0x10;
-}
-
-struct dvb_pll_desc dvb_pll_thomson_dtt759x = {
- .name = "Thomson dtt759x",
- .min = 177000000,
- .max = 896000000,
- .setbw = thomson_dtt759x_bw,
- .count = 6,
- .entries = {
- { 0, 36166667, 166666, 0x84, 0x03 },
- { 264000000, 36166667, 166666, 0xb4, 0x02 },
- { 470000000, 36166667, 166666, 0xbc, 0x02 },
- { 735000000, 36166667, 166666, 0xbc, 0x08 },
- { 835000000, 36166667, 166666, 0xf4, 0x08 },
- { 999999999, 36166667, 166666, 0xfc, 0x08 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_thomson_dtt759x);
-
-struct dvb_pll_desc dvb_pll_lg_z201 = {
- .name = "LG z201",
- .min = 174000000,
- .max = 862000000,
- .count = 6,
- .entries = {
- { 0, 36166667, 166666, 0xbc, 0x03 },
- { 157500000, 36166667, 166666, 0xbc, 0x01 },
- { 443250000, 36166667, 166666, 0xbc, 0x02 },
- { 542000000, 36166667, 166666, 0xbc, 0x04 },
- { 830000000, 36166667, 166666, 0xf4, 0x04 },
- { 999999999, 36166667, 166666, 0xfc, 0x04 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_lg_z201);
-
-struct dvb_pll_desc dvb_pll_microtune_4042 = {
- .name = "Microtune 4042 FI5",
- .min = 57000000,
- .max = 858000000,
- .count = 3,
- .entries = {
- { 162000000, 44000000, 62500, 0x8e, 0xa1 },
- { 457000000, 44000000, 62500, 0x8e, 0x91 },
- { 999999999, 44000000, 62500, 0x8e, 0x31 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_microtune_4042);
-
-struct dvb_pll_desc dvb_pll_thomson_dtt761x = {
- /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */
- .name = "Thomson dtt761x",
- .min = 57000000,
- .max = 863000000,
- .count = 3,
- .entries = {
- { 147000000, 44000000, 62500, 0x8e, 0x39 },
- { 417000000, 44000000, 62500, 0x8e, 0x3a },
- { 999999999, 44000000, 62500, 0x8e, 0x3c },
- },
-};
-EXPORT_SYMBOL(dvb_pll_thomson_dtt761x);
-
-struct dvb_pll_desc dvb_pll_unknown_1 = {
- .name = "unknown 1", /* used by dntv live dvb-t */
- .min = 174000000,
- .max = 862000000,
- .count = 9,
- .entries = {
- { 150000000, 36166667, 166666, 0xb4, 0x01 },
- { 173000000, 36166667, 166666, 0xbc, 0x01 },
- { 250000000, 36166667, 166666, 0xb4, 0x02 },
- { 400000000, 36166667, 166666, 0xbc, 0x02 },
- { 420000000, 36166667, 166666, 0xf4, 0x02 },
- { 470000000, 36166667, 166666, 0xfc, 0x02 },
- { 600000000, 36166667, 166666, 0xbc, 0x08 },
- { 730000000, 36166667, 166666, 0xf4, 0x08 },
- { 999999999, 36166667, 166666, 0xfc, 0x08 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_unknown_1);
-
-/* Infineon TUA6010XS
- * used in Thomson Cable Tuner
- */
-struct dvb_pll_desc dvb_pll_tua6010xs = {
- .name = "Infineon TUA6010XS",
- .min = 44250000,
- .max = 858000000,
- .count = 3,
- .entries = {
- { 115750000, 36125000, 62500, 0x8e, 0x03 },
- { 403250000, 36125000, 62500, 0x8e, 0x06 },
- { 999999999, 36125000, 62500, 0x8e, 0x85 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_tua6010xs);
-
-/* Panasonic env57h1xd5 (some Philips PLL ?) */
-struct dvb_pll_desc dvb_pll_env57h1xd5 = {
- .name = "Panasonic ENV57H1XD5",
- .min = 44250000,
- .max = 858000000,
- .count = 4,
- .entries = {
- { 153000000, 36291666, 166666, 0xc2, 0x41 },
- { 470000000, 36291666, 166666, 0xc2, 0x42 },
- { 526000000, 36291666, 166666, 0xc2, 0x84 },
- { 999999999, 36291666, 166666, 0xc2, 0xa4 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_env57h1xd5);
-
-/* Philips TDA6650/TDA6651
- * used in Panasonic ENV77H11D5
- */
-static void tda665x_bw(u8 *buf, u32 freq, int bandwidth)
-{
- if (bandwidth == BANDWIDTH_8_MHZ)
- buf[3] |= 0x08;
-}
-
-struct dvb_pll_desc dvb_pll_tda665x = {
- .name = "Philips TDA6650/TDA6651",
- .min = 44250000,
- .max = 858000000,
- .setbw = tda665x_bw,
- .count = 12,
- .entries = {
- { 93834000, 36249333, 166667, 0xca, 0x61 /* 011 0 0 0 01 */ },
- { 123834000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
- { 161000000, 36249333, 166667, 0xca, 0xa1 /* 101 0 0 0 01 */ },
- { 163834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
- { 253834000, 36249333, 166667, 0xca, 0x62 /* 011 0 0 0 10 */ },
- { 383834000, 36249333, 166667, 0xca, 0xa2 /* 101 0 0 0 10 */ },
- { 443834000, 36249333, 166667, 0xca, 0xc2 /* 110 0 0 0 10 */ },
- { 444000000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
- { 583834000, 36249333, 166667, 0xca, 0x64 /* 011 0 0 1 00 */ },
- { 793834000, 36249333, 166667, 0xca, 0xa4 /* 101 0 0 1 00 */ },
- { 444834000, 36249333, 166667, 0xca, 0xc4 /* 110 0 0 1 00 */ },
- { 861000000, 36249333, 166667, 0xca, 0xe4 /* 111 0 0 1 00 */ },
- }
-};
-EXPORT_SYMBOL(dvb_pll_tda665x);
-
-/* Infineon TUA6034
- * used in LG TDTP E102P
- */
-static void tua6034_bw(u8 *buf, u32 freq, int bandwidth)
-{
- if (BANDWIDTH_7_MHZ != bandwidth)
- buf[3] |= 0x08;
-}
-
-struct dvb_pll_desc dvb_pll_tua6034 = {
- .name = "Infineon TUA6034",
- .min = 44250000,
- .max = 858000000,
- .count = 3,
- .setbw = tua6034_bw,
- .entries = {
- { 174500000, 36166667, 62500, 0xce, 0x01 },
- { 230000000, 36166667, 62500, 0xce, 0x02 },
- { 999999999, 36166667, 62500, 0xce, 0x04 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_tua6034);
-
-/* Infineon TUA6034
- * used in LG TDVS-H061F, LG TDVS-H062F and LG TDVS-H064F
- */
-struct dvb_pll_desc dvb_pll_lg_tdvs_h06xf = {
- .name = "LG TDVS-H06xF",
- .min = 54000000,
- .max = 863000000,
- .count = 3,
- .entries = {
- { 165000000, 44000000, 62500, 0xce, 0x01 },
- { 450000000, 44000000, 62500, 0xce, 0x02 },
- { 999999999, 44000000, 62500, 0xce, 0x04 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_lg_tdvs_h06xf);
-
-/* Philips FMD1216ME
- * used in Medion Hybrid PCMCIA card and USB Box
- */
-static void fmd1216me_bw(u8 *buf, u32 freq, int bandwidth)
-{
- if (bandwidth == BANDWIDTH_8_MHZ && freq >= 158870000)
- buf[3] |= 0x08;
-}
-
-struct dvb_pll_desc dvb_pll_fmd1216me = {
- .name = "Philips FMD1216ME",
- .min = 50870000,
- .max = 858000000,
- .setbw = fmd1216me_bw,
- .count = 7,
- .entries = {
- { 143870000, 36213333, 166667, 0xbc, 0x41 },
- { 158870000, 36213333, 166667, 0xf4, 0x41 },
- { 329870000, 36213333, 166667, 0xbc, 0x42 },
- { 441870000, 36213333, 166667, 0xf4, 0x42 },
- { 625870000, 36213333, 166667, 0xbc, 0x44 },
- { 803870000, 36213333, 166667, 0xf4, 0x44 },
- { 999999999, 36213333, 166667, 0xfc, 0x44 },
- }
-};
-EXPORT_SYMBOL(dvb_pll_fmd1216me);
-
-/* ALPS TDED4
- * used in Nebula-Cards and USB boxes
- */
-static void tded4_bw(u8 *buf, u32 freq, int bandwidth)
-{
- if (bandwidth == BANDWIDTH_8_MHZ)
- buf[3] |= 0x04;
-}
-
-struct dvb_pll_desc dvb_pll_tded4 = {
- .name = "ALPS TDED4",
- .min = 47000000,
- .max = 863000000,
- .setbw = tded4_bw,
- .count = 4,
- .entries = {
- { 153000000, 36166667, 166667, 0x85, 0x01 },
- { 470000000, 36166667, 166667, 0x85, 0x02 },
- { 823000000, 36166667, 166667, 0x85, 0x08 },
- { 999999999, 36166667, 166667, 0x85, 0x88 },
- }
-};
-EXPORT_SYMBOL(dvb_pll_tded4);
-
-/* ALPS TDHU2
- * used in AverTVHD MCE A180
- */
-struct dvb_pll_desc dvb_pll_tdhu2 = {
- .name = "ALPS TDHU2",
- .min = 54000000,
- .max = 864000000,
- .count = 4,
- .entries = {
- { 162000000, 44000000, 62500, 0x85, 0x01 },
- { 426000000, 44000000, 62500, 0x85, 0x02 },
- { 782000000, 44000000, 62500, 0x85, 0x08 },
- { 999999999, 44000000, 62500, 0x85, 0x88 },
- }
-};
-EXPORT_SYMBOL(dvb_pll_tdhu2);
-
-/* Philips TUV1236D
- * used in ATI HDTV Wonder
- */
-struct dvb_pll_desc dvb_pll_tuv1236d = {
- .name = "Philips TUV1236D",
- .min = 54000000,
- .max = 864000000,
- .count = 3,
- .entries = {
- { 157250000, 44000000, 62500, 0xc6, 0x41 },
- { 454000000, 44000000, 62500, 0xc6, 0x42 },
- { 999999999, 44000000, 62500, 0xc6, 0x44 },
- },
-};
-EXPORT_SYMBOL(dvb_pll_tuv1236d);
-
-/* Samsung TBMV30111IN / TBMV30712IN1
- * used in Air2PC ATSC - 2nd generation (nxt2002)
- */
-struct dvb_pll_desc dvb_pll_samsung_tbmv = {
- .name = "Samsung TBMV30111IN / TBMV30712IN1",
- .min = 54000000,
- .max = 860000000,
- .count = 6,
- .entries = {
- { 172000000, 44000000, 166666, 0xb4, 0x01 },
- { 214000000, 44000000, 166666, 0xb4, 0x02 },
- { 467000000, 44000000, 166666, 0xbc, 0x02 },
- { 721000000, 44000000, 166666, 0xbc, 0x08 },
- { 841000000, 44000000, 166666, 0xf4, 0x08 },
- { 999999999, 44000000, 166666, 0xfc, 0x02 },
- }
-};
-EXPORT_SYMBOL(dvb_pll_samsung_tbmv);
-
-/*
- * Philips SD1878 Tuner.
- */
-struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = {
- .name = "Philips SD1878",
- .min = 950000,
- .max = 2150000,
- .count = 4,
- .entries = {
- { 1250000, 499, 500, 0xc4, 0x00},
- { 1550000, 499, 500, 0xc4, 0x40},
- { 2050000, 499, 500, 0xc4, 0x80},
- { 2150000, 499, 500, 0xc4, 0xc0},
- },
-};
-EXPORT_SYMBOL(dvb_pll_philips_sd1878_tda8261);
-
-/*
- * Philips TD1316 Tuner.
- */
-static void td1316_bw(u8 *buf, u32 freq, int bandwidth)
-{
- u8 band;
-
- /* determine band */
- if (freq < 161000000)
- band = 1;
- else if (freq < 444000000)
- band = 2;
- else
- band = 4;
-
- buf[3] |= band;
-
- /* setup PLL filter */
- if (bandwidth == BANDWIDTH_8_MHZ)
- buf[3] |= 1 << 3;
-}
-
-struct dvb_pll_desc dvb_pll_philips_td1316 = {
- .name = "Philips TD1316",
- .min = 87000000,
- .max = 895000000,
- .setbw = td1316_bw,
- .count = 9,
- .entries = {
- { 93834000, 36166000, 166666, 0xca, 0x60},
- { 123834000, 36166000, 166666, 0xca, 0xa0},
- { 163834000, 36166000, 166666, 0xca, 0xc0},
- { 253834000, 36166000, 166666, 0xca, 0x60},
- { 383834000, 36166000, 166666, 0xca, 0xa0},
- { 443834000, 36166000, 166666, 0xca, 0xc0},
- { 583834000, 36166000, 166666, 0xca, 0x60},
- { 793834000, 36166000, 166666, 0xca, 0xa0},
- { 858834000, 36166000, 166666, 0xca, 0xe0},
- },
-};
-EXPORT_SYMBOL(dvb_pll_philips_td1316);
-
-/* FE6600 used on DViCO Hybrid */
-struct dvb_pll_desc dvb_pll_thomson_fe6600 = {
- .name = "Thomson FE6600",
- .min = 44250000,
- .max = 858000000,
- .count = 4,
- .entries = {
- { 250000000, 36213333, 166667, 0xb4, 0x12 },
- { 455000000, 36213333, 166667, 0xfe, 0x11 },
- { 775500000, 36213333, 166667, 0xbc, 0x18 },
- { 999999999, 36213333, 166667, 0xf4, 0x18 },
- }
-};
-EXPORT_SYMBOL(dvb_pll_thomson_fe6600);
-
-struct dvb_pll_priv {
- /* i2c details */
- int pll_i2c_address;
- struct i2c_adapter *i2c;
-
- /* the PLL descriptor */
- struct dvb_pll_desc *pll_desc;
-
- /* cached frequency/bandwidth */
- u32 frequency;
- u32 bandwidth;
-};
-
-/* ----------------------------------------------------------- */
-/* code */
-
-static int debug = 0;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "enable verbose debug messages");
-
-int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
- u32 freq, int bandwidth)
-{
- u32 div;
- int i;
-
- if (freq != 0 && (freq < desc->min || freq > desc->max))
- return -EINVAL;
-
- for (i = 0; i < desc->count; i++) {
- if (freq > desc->entries[i].limit)
- continue;
- break;
- }
- if (debug)
- printk("pll: %s: freq=%d bw=%d | i=%d/%d\n",
- desc->name, freq, bandwidth, i, desc->count);
- if (i == desc->count)
- return -EINVAL;
-
- div = (freq + desc->entries[i].offset) / desc->entries[i].stepsize;
- buf[0] = div >> 8;
- buf[1] = div & 0xff;
- buf[2] = desc->entries[i].config;
- buf[3] = desc->entries[i].cb;
-
- if (desc->setbw)
- desc->setbw(buf, freq, bandwidth);
-
- if (debug)
- printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
- desc->name, div, buf[0], buf[1], buf[2], buf[3]);
-
- return 0;
-}
-EXPORT_SYMBOL(dvb_pll_configure);
-
-static int dvb_pll_release(struct dvb_frontend *fe)
-{
- if (fe->tuner_priv)
- kfree(fe->tuner_priv);
- fe->tuner_priv = NULL;
- return 0;
-}
-
-static int dvb_pll_sleep(struct dvb_frontend *fe)
-{
- struct dvb_pll_priv *priv = fe->tuner_priv;
- u8 buf[4];
- struct i2c_msg msg =
- { .addr = priv->pll_i2c_address, .flags = 0, .buf = buf, .len = sizeof(buf) };
- int i;
- int result;
-
- for (i = 0; i < priv->pll_desc->count; i++) {
- if (priv->pll_desc->entries[i].limit == 0)
- break;
- }
- if (i == priv->pll_desc->count)
- return 0;
-
- buf[0] = 0;
- buf[1] = 0;
- buf[2] = priv->pll_desc->entries[i].config;
- buf[3] = priv->pll_desc->entries[i].cb;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) {
- return result;
- }
-
- return 0;
-}
-
-static int dvb_pll_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct dvb_pll_priv *priv = fe->tuner_priv;
- u8 buf[4];
- struct i2c_msg msg =
- { .addr = priv->pll_i2c_address, .flags = 0, .buf = buf, .len = sizeof(buf) };
- int result;
- u32 div;
- int i;
- u32 bandwidth = 0;
-
- if (priv->i2c == NULL)
- return -EINVAL;
-
- // DVBT bandwidth only just now
- if (fe->ops.info.type == FE_OFDM) {
- bandwidth = params->u.ofdm.bandwidth;
- }
-
- if ((result = dvb_pll_configure(priv->pll_desc, buf, params->frequency, bandwidth)) != 0)
- return result;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if ((result = i2c_transfer(priv->i2c, &msg, 1)) != 1) {
- return result;
- }
-
- // calculate the frequency we set it to
- for (i = 0; i < priv->pll_desc->count; i++) {
- if (params->frequency > priv->pll_desc->entries[i].limit)
- continue;
- break;
- }
- div = (params->frequency + priv->pll_desc->entries[i].offset) / priv->pll_desc->entries[i].stepsize;
- priv->frequency = (div * priv->pll_desc->entries[i].stepsize) - priv->pll_desc->entries[i].offset;
- priv->bandwidth = bandwidth;
-
- return 0;
-}
-
-static int dvb_pll_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8 *buf, int buf_len)
-{
- struct dvb_pll_priv *priv = fe->tuner_priv;
- int result;
- u32 div;
- int i;
- u32 bandwidth = 0;
-
- if (buf_len < 5)
- return -EINVAL;
-
- // DVBT bandwidth only just now
- if (fe->ops.info.type == FE_OFDM) {
- bandwidth = params->u.ofdm.bandwidth;
- }
-
- if ((result = dvb_pll_configure(priv->pll_desc, buf+1, params->frequency, bandwidth)) != 0)
- return result;
- buf[0] = priv->pll_i2c_address;
-
- // calculate the frequency we set it to
- for (i = 0; i < priv->pll_desc->count; i++) {
- if (params->frequency > priv->pll_desc->entries[i].limit)
- continue;
- break;
- }
- div = (params->frequency + priv->pll_desc->entries[i].offset) / priv->pll_desc->entries[i].stepsize;
- priv->frequency = (div * priv->pll_desc->entries[i].stepsize) - priv->pll_desc->entries[i].offset;
- priv->bandwidth = bandwidth;
-
- return 5;
-}
-
-static int dvb_pll_get_frequency(struct dvb_frontend *fe, u32 *frequency)
-{
- struct dvb_pll_priv *priv = fe->tuner_priv;
- *frequency = priv->frequency;
- return 0;
-}
-
-static int dvb_pll_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
-{
- struct dvb_pll_priv *priv = fe->tuner_priv;
- *bandwidth = priv->bandwidth;
- return 0;
-}
-
-static struct dvb_tuner_ops dvb_pll_tuner_ops = {
- .release = dvb_pll_release,
- .sleep = dvb_pll_sleep,
- .set_params = dvb_pll_set_params,
- .calc_regs = dvb_pll_calc_regs,
- .get_frequency = dvb_pll_get_frequency,
- .get_bandwidth = dvb_pll_get_bandwidth,
-};
-
-int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc)
-{
- u8 b1 [] = { 0 };
- struct i2c_msg msg = { .addr = pll_addr, .flags = I2C_M_RD, .buf = b1, .len = 1 };
- struct dvb_pll_priv *priv = NULL;
- int ret;
-
- if (i2c != NULL) {
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
-
- ret = i2c_transfer (i2c, &msg, 1);
- if (ret != 1)
- return -1;
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- priv = kzalloc(sizeof(struct dvb_pll_priv), GFP_KERNEL);
- if (priv == NULL)
- return -ENOMEM;
-
- priv->pll_i2c_address = pll_addr;
- priv->i2c = i2c;
- priv->pll_desc = desc;
-
- memcpy(&fe->ops.tuner_ops, &dvb_pll_tuner_ops, sizeof(struct dvb_tuner_ops));
- strncpy(fe->ops.tuner_ops.info.name, desc->name, 128);
- fe->ops.tuner_ops.info.frequency_min = desc->min;
- fe->ops.tuner_ops.info.frequency_min = desc->max;
-
- fe->tuner_priv = priv;
- return 0;
-}
-EXPORT_SYMBOL(dvb_pll_attach);
-
-MODULE_DESCRIPTION("dvb pll library");
-MODULE_AUTHOR("Gerd Knorr");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h
deleted file mode 100644
index 66361cd1880..00000000000
--- a/drivers/media/dvb/frontends/dvb-pll.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * descriptions + helper functions for simple dvb plls.
- */
-
-#ifndef __DVB_PLL_H__
-#define __DVB_PLL_H__
-
-#include <linux/i2c.h>
-#include "dvb_frontend.h"
-
-struct dvb_pll_desc {
- char *name;
- u32 min;
- u32 max;
- void (*setbw)(u8 *buf, u32 freq, int bandwidth);
- int count;
- struct {
- u32 limit;
- u32 offset;
- u32 stepsize;
- u8 config;
- u8 cb;
- } entries[12];
-};
-
-extern struct dvb_pll_desc dvb_pll_thomson_dtt7579;
-extern struct dvb_pll_desc dvb_pll_thomson_dtt759x;
-extern struct dvb_pll_desc dvb_pll_thomson_dtt7610;
-extern struct dvb_pll_desc dvb_pll_lg_z201;
-extern struct dvb_pll_desc dvb_pll_microtune_4042;
-extern struct dvb_pll_desc dvb_pll_thomson_dtt761x;
-extern struct dvb_pll_desc dvb_pll_unknown_1;
-
-extern struct dvb_pll_desc dvb_pll_tua6010xs;
-extern struct dvb_pll_desc dvb_pll_env57h1xd5;
-extern struct dvb_pll_desc dvb_pll_tua6034;
-extern struct dvb_pll_desc dvb_pll_lg_tdvs_h06xf;
-extern struct dvb_pll_desc dvb_pll_tda665x;
-extern struct dvb_pll_desc dvb_pll_fmd1216me;
-extern struct dvb_pll_desc dvb_pll_tded4;
-
-extern struct dvb_pll_desc dvb_pll_tuv1236d;
-extern struct dvb_pll_desc dvb_pll_tdhu2;
-extern struct dvb_pll_desc dvb_pll_samsung_tbmv;
-extern struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261;
-extern struct dvb_pll_desc dvb_pll_philips_td1316;
-
-extern struct dvb_pll_desc dvb_pll_thomson_fe6600;
-
-extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf,
- u32 freq, int bandwidth);
-
-/**
- * Attach a dvb-pll to the supplied frontend structure.
- *
- * @param fe Frontend to attach to.
- * @param pll_addr i2c address of the PLL (if used).
- * @param i2c i2c adapter to use (set to NULL if not used).
- * @param desc dvb_pll_desc to use.
- * @return 0 on success, nonzero on failure.
- */
-extern int dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, struct i2c_adapter *i2c, struct dvb_pll_desc *desc);
-
-#endif
diff --git a/drivers/media/dvb/frontends/dvb_dummy_fe.c b/drivers/media/dvb/frontends/dvb_dummy_fe.c
deleted file mode 100644
index 6271b1e7f6a..00000000000
--- a/drivers/media/dvb/frontends/dvb_dummy_fe.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Driver for Dummy Frontend
- *
- * Written by Emard <emard@softhome.net>
- *
- * 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/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "dvb_dummy_fe.h"
-
-
-struct dvb_dummy_fe_state {
- struct dvb_frontend frontend;
-};
-
-
-static int dvb_dummy_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- *status = FE_HAS_SIGNAL
- | FE_HAS_CARRIER
- | FE_HAS_VITERBI
- | FE_HAS_SYNC
- | FE_HAS_LOCK;
-
- return 0;
-}
-
-static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- *ber = 0;
- return 0;
-}
-
-static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- *strength = 0;
- return 0;
-}
-
-static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- *snr = 0;
- return 0;
-}
-
-static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- *ucblocks = 0;
- return 0;
-}
-
-static int dvb_dummy_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- return 0;
-}
-
-static int dvb_dummy_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- if (fe->ops->tuner_ops->set_params) {
- fe->ops->tuner_ops->set_params(fe, p);
- if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0);
- }
-
- return 0;
-}
-
-static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int dvb_dummy_fe_init(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- return 0;
-}
-
-static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- return 0;
-}
-
-static void dvb_dummy_fe_release(struct dvb_frontend* fe)
-{
- struct dvb_dummy_fe_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
-
-struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
-{
- struct dvb_dummy_fe_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
-
-struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
-{
- struct dvb_dummy_fe_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
-
-struct dvb_frontend* dvb_dummy_fe_qam_attach()
-{
- struct dvb_dummy_fe_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
-
- .info = {
- .name = "Dummy DVB-T",
- .type = FE_OFDM,
- .frequency_min = 0,
- .frequency_max = 863250000,
- .frequency_stepsize = 62500,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
- FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
- FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO |
- FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_HIERARCHY_AUTO,
- },
-
- .release = dvb_dummy_fe_release,
-
- .init = dvb_dummy_fe_init,
- .sleep = dvb_dummy_fe_sleep,
-
- .set_frontend = dvb_dummy_fe_set_frontend,
- .get_frontend = dvb_dummy_fe_get_frontend,
-
- .read_status = dvb_dummy_fe_read_status,
- .read_ber = dvb_dummy_fe_read_ber,
- .read_signal_strength = dvb_dummy_fe_read_signal_strength,
- .read_snr = dvb_dummy_fe_read_snr,
- .read_ucblocks = dvb_dummy_fe_read_ucblocks,
-};
-
-static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
-
- .info = {
- .name = "Dummy DVB-C",
- .type = FE_QAM,
- .frequency_stepsize = 62500,
- .frequency_min = 51000000,
- .frequency_max = 858000000,
- .symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */
- .symbol_rate_max = (57840000/2)/4, /* SACLK/4 */
- .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
- FE_CAN_QAM_128 | FE_CAN_QAM_256 |
- FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
- },
-
- .release = dvb_dummy_fe_release,
-
- .init = dvb_dummy_fe_init,
- .sleep = dvb_dummy_fe_sleep,
-
- .set_frontend = dvb_dummy_fe_set_frontend,
- .get_frontend = dvb_dummy_fe_get_frontend,
-
- .read_status = dvb_dummy_fe_read_status,
- .read_ber = dvb_dummy_fe_read_ber,
- .read_signal_strength = dvb_dummy_fe_read_signal_strength,
- .read_snr = dvb_dummy_fe_read_snr,
- .read_ucblocks = dvb_dummy_fe_read_ucblocks,
-};
-
-static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
-
- .info = {
- .name = "Dummy DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 250, /* kHz for QPSK frontends */
- .frequency_tolerance = 29500,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK
- },
-
- .release = dvb_dummy_fe_release,
-
- .init = dvb_dummy_fe_init,
- .sleep = dvb_dummy_fe_sleep,
-
- .set_frontend = dvb_dummy_fe_set_frontend,
- .get_frontend = dvb_dummy_fe_get_frontend,
-
- .read_status = dvb_dummy_fe_read_status,
- .read_ber = dvb_dummy_fe_read_ber,
- .read_signal_strength = dvb_dummy_fe_read_signal_strength,
- .read_snr = dvb_dummy_fe_read_snr,
- .read_ucblocks = dvb_dummy_fe_read_ucblocks,
-
- .set_voltage = dvb_dummy_fe_set_voltage,
- .set_tone = dvb_dummy_fe_set_tone,
-};
-
-MODULE_DESCRIPTION("DVB DUMMY Frontend");
-MODULE_AUTHOR("Emard");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
-EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
-EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);
diff --git a/drivers/media/dvb/frontends/dvb_dummy_fe.h b/drivers/media/dvb/frontends/dvb_dummy_fe.h
deleted file mode 100644
index 8210f19d56c..00000000000
--- a/drivers/media/dvb/frontends/dvb_dummy_fe.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Driver for Dummy Frontend
- *
- * Written by Emard <emard@softhome.net>
- *
- * 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.=
- */
-
-#ifndef DVB_DUMMY_FE_H
-#define DVB_DUMMY_FE_H
-
-#include <linux/dvb/frontend.h>
-#include "dvb_frontend.h"
-
-extern struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void);
-extern struct dvb_frontend* dvb_dummy_fe_qpsk_attach(void);
-extern struct dvb_frontend* dvb_dummy_fe_qam_attach(void);
-
-#endif // DVB_DUMMY_FE_H
diff --git a/drivers/media/dvb/frontends/isl6421.c b/drivers/media/dvb/frontends/isl6421.c
deleted file mode 100644
index 58c34db3107..00000000000
--- a/drivers/media/dvb/frontends/isl6421.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * isl6421.h - driver for lnb supply and control ic ISL6421
- *
- * Copyright (C) 2006 Andrew de Quincey
- * Copyright (C) 2006 Oliver Endriss
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org
- */
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "isl6421.h"
-
-struct isl6421 {
- u8 config;
- u8 override_or;
- u8 override_and;
- struct i2c_adapter *i2c;
- u8 i2c_addr;
- void (*release_chain)(struct dvb_frontend* fe);
-};
-
-static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
-{
- struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv;
- struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0,
- .buf = &isl6421->config,
- .len = sizeof(isl6421->config) };
-
- isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1);
-
- switch(voltage) {
- case SEC_VOLTAGE_OFF:
- break;
- case SEC_VOLTAGE_13:
- isl6421->config |= ISL6421_EN1;
- break;
- case SEC_VOLTAGE_18:
- isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1);
- break;
- default:
- return -EINVAL;
- };
-
- isl6421->config |= isl6421->override_or;
- isl6421->config &= isl6421->override_and;
-
- return (i2c_transfer(isl6421->i2c, &msg, 1) == 1) ? 0 : -EIO;
-}
-
-static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
-{
- struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv;
- struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0,
- .buf = &isl6421->config,
- .len = sizeof(isl6421->config) };
-
- if (arg)
- isl6421->config |= ISL6421_LLC1;
- else
- isl6421->config &= ~ISL6421_LLC1;
-
- isl6421->config |= isl6421->override_or;
- isl6421->config &= isl6421->override_and;
-
- return (i2c_transfer(isl6421->i2c, &msg, 1) == 1) ? 0 : -EIO;
-}
-
-static void isl6421_release(struct dvb_frontend *fe)
-{
- struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv;
-
- /* power off */
- isl6421_set_voltage(fe, SEC_VOLTAGE_OFF);
-
- /* free data & call next release routine */
- fe->ops.release = isl6421->release_chain;
- kfree(fe->misc_priv);
- fe->misc_priv = NULL;
- if (fe->ops.release)
- fe->ops.release(fe);
-}
-
-int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
- u8 override_set, u8 override_clear)
-{
- struct isl6421 *isl6421 = kmalloc(sizeof(struct isl6421), GFP_KERNEL);
- if (!isl6421)
- return -ENOMEM;
-
- /* default configuration */
- isl6421->config = ISL6421_ISEL1;
- isl6421->i2c = i2c;
- isl6421->i2c_addr = i2c_addr;
- fe->misc_priv = isl6421;
-
- /* bits which should be forced to '1' */
- isl6421->override_or = override_set;
-
- /* bits which should be forced to '0' */
- isl6421->override_and = ~override_clear;
-
- /* detect if it is present or not */
- if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) {
- kfree(isl6421);
- fe->misc_priv = NULL;
- return -EIO;
- }
-
- /* install release callback */
- isl6421->release_chain = fe->ops.release;
- fe->ops.release = isl6421_release;
-
- /* override frontend ops */
- fe->ops.set_voltage = isl6421_set_voltage;
- fe->ops.enable_high_lnb_voltage = isl6421_enable_high_lnb_voltage;
-
- return 0;
-}
-EXPORT_SYMBOL(isl6421_attach);
-
-MODULE_DESCRIPTION("Driver for lnb supply and control ic isl6421");
-MODULE_AUTHOR("Andrew de Quincey & Oliver Endriss");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h
deleted file mode 100644
index 675f80a19b9..00000000000
--- a/drivers/media/dvb/frontends/isl6421.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * isl6421.h - driver for lnb supply and control ic ISL6421
- *
- * Copyright (C) 2006 Andrew de Quincey
- * Copyright (C) 2006 Oliver Endriss
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org
- */
-
-#ifndef _ISL6421_H
-#define _ISL6421_H
-
-#include <linux/dvb/frontend.h>
-
-/* system register bits */
-#define ISL6421_OLF1 0x01
-#define ISL6421_EN1 0x02
-#define ISL6421_VSEL1 0x04
-#define ISL6421_LLC1 0x08
-#define ISL6421_ENT1 0x10
-#define ISL6421_ISEL1 0x20
-#define ISL6421_DCL 0x40
-
-/* override_set and override_clear control which system register bits (above) to always set & clear */
-extern int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
- u8 override_set, u8 override_clear);
-
-#endif
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
deleted file mode 100644
index f3bc82e44a2..00000000000
--- a/drivers/media/dvb/frontends/l64781.c
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- driver for LSI L64781 COFDM demodulator
-
- Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH
- Marko Kohtala <marko.kohtala@luukku.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "dvb_frontend.h"
-#include "l64781.h"
-
-
-struct l64781_state {
- struct i2c_adapter* i2c;
- const struct l64781_config* config;
- struct dvb_frontend frontend;
-
- /* private demodulator data */
- int first:1;
-};
-
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "l64781: " args); \
- } while (0)
-
-static int debug;
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-
-static int l64781_writereg (struct l64781_state* state, u8 reg, u8 data)
-{
- int ret;
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
-
- if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1)
- dprintk ("%s: write_reg error (reg == %02x) = %02x!\n",
- __FUNCTION__, reg, ret);
-
- return (ret != 1) ? -1 : 0;
-}
-
-static int l64781_readreg (struct l64781_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2) return ret;
-
- return b1[0];
-}
-
-static void apply_tps (struct l64781_state* state)
-{
- l64781_writereg (state, 0x2a, 0x00);
- l64781_writereg (state, 0x2a, 0x01);
-
- /* This here is a little bit questionable because it enables
- the automatic update of TPS registers. I think we'd need to
- handle the IRQ from FE to update some other registers as
- well, or at least implement some magic to tuning to correct
- to the TPS received from transmission. */
- l64781_writereg (state, 0x2a, 0x02);
-}
-
-
-static void reset_afc (struct l64781_state* state)
-{
- /* Set AFC stall for the AFC_INIT_FRQ setting, TIM_STALL for
- timing offset */
- l64781_writereg (state, 0x07, 0x9e); /* stall AFC */
- l64781_writereg (state, 0x08, 0); /* AFC INIT FREQ */
- l64781_writereg (state, 0x09, 0);
- l64781_writereg (state, 0x0a, 0);
- l64781_writereg (state, 0x07, 0x8e);
- l64781_writereg (state, 0x0e, 0); /* AGC gain to zero in beginning */
- l64781_writereg (state, 0x11, 0x80); /* stall TIM */
- l64781_writereg (state, 0x10, 0); /* TIM_OFFSET_LSB */
- l64781_writereg (state, 0x12, 0);
- l64781_writereg (state, 0x13, 0);
- l64781_writereg (state, 0x11, 0x00);
-}
-
-static int reset_and_configure (struct l64781_state* state)
-{
- u8 buf [] = { 0x06 };
- struct i2c_msg msg = { .addr = 0x00, .flags = 0, .buf = buf, .len = 1 };
- // NOTE: this is correct in writing to address 0x00
-
- return (i2c_transfer(state->i2c, &msg, 1) == 1) ? 0 : -ENODEV;
-}
-
-static int apply_frontend_param (struct dvb_frontend* fe, struct dvb_frontend_parameters *param)
-{
- struct l64781_state* state = fe->demodulator_priv;
- /* The coderates for FEC_NONE, FEC_4_5 and FEC_FEC_6_7 are arbitrary */
- static const u8 fec_tab[] = { 7, 0, 1, 2, 9, 3, 10, 4 };
- /* QPSK, QAM_16, QAM_64 */
- static const u8 qam_tab [] = { 2, 4, 0, 6 };
- static const u8 bw_tab [] = { 8, 7, 6 }; /* 8Mhz, 7MHz, 6MHz */
- static const u8 guard_tab [] = { 1, 2, 4, 8 };
- /* The Grundig 29504-401.04 Tuner comes with 18.432MHz crystal. */
- static const u32 ppm = 8000;
- struct dvb_ofdm_parameters *p = &param->u.ofdm;
- u32 ddfs_offset_fixed;
-/* u32 ddfs_offset_variable = 0x6000-((1000000UL+ppm)/ */
-/* bw_tab[p->bandWidth]<<10)/15625; */
- u32 init_freq;
- u32 spi_bias;
- u8 val0x04;
- u8 val0x05;
- u8 val0x06;
- int bw = p->bandwidth - BANDWIDTH_8_MHZ;
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, param);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- if (param->inversion != INVERSION_ON &&
- param->inversion != INVERSION_OFF)
- return -EINVAL;
-
- if (bw < 0 || bw > 2)
- return -EINVAL;
-
- if (p->code_rate_HP != FEC_1_2 && p->code_rate_HP != FEC_2_3 &&
- p->code_rate_HP != FEC_3_4 && p->code_rate_HP != FEC_5_6 &&
- p->code_rate_HP != FEC_7_8)
- return -EINVAL;
-
- if (p->hierarchy_information != HIERARCHY_NONE &&
- (p->code_rate_LP != FEC_1_2 && p->code_rate_LP != FEC_2_3 &&
- p->code_rate_LP != FEC_3_4 && p->code_rate_LP != FEC_5_6 &&
- p->code_rate_LP != FEC_7_8))
- return -EINVAL;
-
- if (p->constellation != QPSK && p->constellation != QAM_16 &&
- p->constellation != QAM_64)
- return -EINVAL;
-
- if (p->transmission_mode != TRANSMISSION_MODE_2K &&
- p->transmission_mode != TRANSMISSION_MODE_8K)
- return -EINVAL;
-
- if (p->guard_interval < GUARD_INTERVAL_1_32 ||
- p->guard_interval > GUARD_INTERVAL_1_4)
- return -EINVAL;
-
- if (p->hierarchy_information < HIERARCHY_NONE ||
- p->hierarchy_information > HIERARCHY_4)
- return -EINVAL;
-
- ddfs_offset_fixed = 0x4000-(ppm<<16)/bw_tab[p->bandwidth]/1000000;
-
- /* This works up to 20000 ppm, it overflows if too large ppm! */
- init_freq = (((8UL<<25) + (8UL<<19) / 25*ppm / (15625/25)) /
- bw_tab[p->bandwidth] & 0xFFFFFF);
-
- /* SPI bias calculation is slightly modified to fit in 32bit */
- /* will work for high ppm only... */
- spi_bias = 378 * (1 << 10);
- spi_bias *= 16;
- spi_bias *= bw_tab[p->bandwidth];
- spi_bias *= qam_tab[p->constellation];
- spi_bias /= p->code_rate_HP + 1;
- spi_bias /= (guard_tab[p->guard_interval] + 32);
- spi_bias *= 1000ULL;
- spi_bias /= 1000ULL + ppm/1000;
- spi_bias *= p->code_rate_HP;
-
- val0x04 = (p->transmission_mode << 2) | p->guard_interval;
- val0x05 = fec_tab[p->code_rate_HP];
-
- if (p->hierarchy_information != HIERARCHY_NONE)
- val0x05 |= (p->code_rate_LP - FEC_1_2) << 3;
-
- val0x06 = (p->hierarchy_information << 2) | p->constellation;
-
- l64781_writereg (state, 0x04, val0x04);
- l64781_writereg (state, 0x05, val0x05);
- l64781_writereg (state, 0x06, val0x06);
-
- reset_afc (state);
-
- /* Technical manual section 2.6.1, TIM_IIR_GAIN optimal values */
- l64781_writereg (state, 0x15,
- p->transmission_mode == TRANSMISSION_MODE_2K ? 1 : 3);
- l64781_writereg (state, 0x16, init_freq & 0xff);
- l64781_writereg (state, 0x17, (init_freq >> 8) & 0xff);
- l64781_writereg (state, 0x18, (init_freq >> 16) & 0xff);
-
- l64781_writereg (state, 0x1b, spi_bias & 0xff);
- l64781_writereg (state, 0x1c, (spi_bias >> 8) & 0xff);
- l64781_writereg (state, 0x1d, ((spi_bias >> 16) & 0x7f) |
- (param->inversion == INVERSION_ON ? 0x80 : 0x00));
-
- l64781_writereg (state, 0x22, ddfs_offset_fixed & 0xff);
- l64781_writereg (state, 0x23, (ddfs_offset_fixed >> 8) & 0x3f);
-
- l64781_readreg (state, 0x00); /* clear interrupt registers... */
- l64781_readreg (state, 0x01); /* dto. */
-
- apply_tps (state);
-
- return 0;
-}
-
-static int get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* param)
-{
- struct l64781_state* state = fe->demodulator_priv;
- int tmp;
-
-
- tmp = l64781_readreg(state, 0x04);
- switch(tmp & 3) {
- case 0:
- param->u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
- break;
- case 1:
- param->u.ofdm.guard_interval = GUARD_INTERVAL_1_16;
- break;
- case 2:
- param->u.ofdm.guard_interval = GUARD_INTERVAL_1_8;
- break;
- case 3:
- param->u.ofdm.guard_interval = GUARD_INTERVAL_1_4;
- break;
- }
- switch((tmp >> 2) & 3) {
- case 0:
- param->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
- break;
- case 1:
- param->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
- break;
- default:
- printk("Unexpected value for transmission_mode\n");
- }
-
-
-
- tmp = l64781_readreg(state, 0x05);
- switch(tmp & 7) {
- case 0:
- param->u.ofdm.code_rate_HP = FEC_1_2;
- break;
- case 1:
- param->u.ofdm.code_rate_HP = FEC_2_3;
- break;
- case 2:
- param->u.ofdm.code_rate_HP = FEC_3_4;
- break;
- case 3:
- param->u.ofdm.code_rate_HP = FEC_5_6;
- break;
- case 4:
- param->u.ofdm.code_rate_HP = FEC_7_8;
- break;
- default:
- printk("Unexpected value for code_rate_HP\n");
- }
- switch((tmp >> 3) & 7) {
- case 0:
- param->u.ofdm.code_rate_LP = FEC_1_2;
- break;
- case 1:
- param->u.ofdm.code_rate_LP = FEC_2_3;
- break;
- case 2:
- param->u.ofdm.code_rate_LP = FEC_3_4;
- break;
- case 3:
- param->u.ofdm.code_rate_LP = FEC_5_6;
- break;
- case 4:
- param->u.ofdm.code_rate_LP = FEC_7_8;
- break;
- default:
- printk("Unexpected value for code_rate_LP\n");
- }
-
-
- tmp = l64781_readreg(state, 0x06);
- switch(tmp & 3) {
- case 0:
- param->u.ofdm.constellation = QPSK;
- break;
- case 1:
- param->u.ofdm.constellation = QAM_16;
- break;
- case 2:
- param->u.ofdm.constellation = QAM_64;
- break;
- default:
- printk("Unexpected value for constellation\n");
- }
- switch((tmp >> 2) & 7) {
- case 0:
- param->u.ofdm.hierarchy_information = HIERARCHY_NONE;
- break;
- case 1:
- param->u.ofdm.hierarchy_information = HIERARCHY_1;
- break;
- case 2:
- param->u.ofdm.hierarchy_information = HIERARCHY_2;
- break;
- case 3:
- param->u.ofdm.hierarchy_information = HIERARCHY_4;
- break;
- default:
- printk("Unexpected value for hierarchy\n");
- }
-
-
- tmp = l64781_readreg (state, 0x1d);
- param->inversion = (tmp & 0x80) ? INVERSION_ON : INVERSION_OFF;
-
- tmp = (int) (l64781_readreg (state, 0x08) |
- (l64781_readreg (state, 0x09) << 8) |
- (l64781_readreg (state, 0x0a) << 16));
- param->frequency += tmp;
-
- return 0;
-}
-
-static int l64781_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct l64781_state* state = fe->demodulator_priv;
- int sync = l64781_readreg (state, 0x32);
- int gain = l64781_readreg (state, 0x0e);
-
- l64781_readreg (state, 0x00); /* clear interrupt registers... */
- l64781_readreg (state, 0x01); /* dto. */
-
- *status = 0;
-
- if (gain > 5)
- *status |= FE_HAS_SIGNAL;
-
- if (sync & 0x02) /* VCXO locked, this criteria should be ok */
- *status |= FE_HAS_CARRIER;
-
- if (sync & 0x20)
- *status |= FE_HAS_VITERBI;
-
- if (sync & 0x40)
- *status |= FE_HAS_SYNC;
-
- if (sync == 0x7f)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int l64781_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct l64781_state* state = fe->demodulator_priv;
-
- /* XXX FIXME: set up counting period (reg 0x26...0x28)
- */
- *ber = l64781_readreg (state, 0x39)
- | (l64781_readreg (state, 0x3a) << 8);
-
- return 0;
-}
-
-static int l64781_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
-{
- struct l64781_state* state = fe->demodulator_priv;
-
- u8 gain = l64781_readreg (state, 0x0e);
- *signal_strength = (gain << 8) | gain;
-
- return 0;
-}
-
-static int l64781_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct l64781_state* state = fe->demodulator_priv;
-
- u8 avg_quality = 0xff - l64781_readreg (state, 0x33);
- *snr = (avg_quality << 8) | avg_quality; /* not exact, but...*/
-
- return 0;
-}
-
-static int l64781_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct l64781_state* state = fe->demodulator_priv;
-
- *ucblocks = l64781_readreg (state, 0x37)
- | (l64781_readreg (state, 0x38) << 8);
-
- return 0;
-}
-
-static int l64781_sleep(struct dvb_frontend* fe)
-{
- struct l64781_state* state = fe->demodulator_priv;
-
- /* Power down */
- return l64781_writereg (state, 0x3e, 0x5a);
-}
-
-static int l64781_init(struct dvb_frontend* fe)
-{
- struct l64781_state* state = fe->demodulator_priv;
-
- reset_and_configure (state);
-
- /* Power up */
- l64781_writereg (state, 0x3e, 0xa5);
-
- /* Reset hard */
- l64781_writereg (state, 0x2a, 0x04);
- l64781_writereg (state, 0x2a, 0x00);
-
- /* Set tuner specific things */
- /* AFC_POL, set also in reset_afc */
- l64781_writereg (state, 0x07, 0x8e);
-
- /* Use internal ADC */
- l64781_writereg (state, 0x0b, 0x81);
-
- /* AGC loop gain, and polarity is positive */
- l64781_writereg (state, 0x0c, 0x84);
-
- /* Internal ADC outputs two's complement */
- l64781_writereg (state, 0x0d, 0x8c);
-
- /* With ppm=8000, it seems the DTR_SENSITIVITY will result in
- value of 2 with all possible bandwidths and guard
- intervals, which is the initial value anyway. */
- /*l64781_writereg (state, 0x19, 0x92);*/
-
- /* Everything is two's complement, soft bit and CSI_OUT too */
- l64781_writereg (state, 0x1e, 0x09);
-
- /* delay a bit after first init attempt */
- if (state->first) {
- state->first = 0;
- msleep(200);
- }
-
- return 0;
-}
-
-static int l64781_get_tune_settings(struct dvb_frontend* fe,
- struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 4000;
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static void l64781_release(struct dvb_frontend* fe)
-{
- struct l64781_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops l64781_ops;
-
-struct dvb_frontend* l64781_attach(const struct l64781_config* config,
- struct i2c_adapter* i2c)
-{
- struct l64781_state* state = NULL;
- int reg0x3e = -1;
- u8 b0 [] = { 0x1a };
- u8 b1 [] = { 0x00 };
- struct i2c_msg msg [] = { { .addr = config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct l64781_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->first = 1;
-
- /**
- * the L64781 won't show up before we send the reset_and_configure()
- * broadcast. If nothing responds there is no L64781 on the bus...
- */
- if (reset_and_configure(state) < 0) {
- dprintk("No response to reset and configure broadcast...\n");
- goto error;
- }
-
- /* The chip always responds to reads */
- if (i2c_transfer(state->i2c, msg, 2) != 2) {
- dprintk("No response to read on I2C bus\n");
- goto error;
- }
-
- /* Save current register contents for bailout */
- reg0x3e = l64781_readreg(state, 0x3e);
-
- /* Reading the POWER_DOWN register always returns 0 */
- if (reg0x3e != 0) {
- dprintk("Device doesn't look like L64781\n");
- goto error;
- }
-
- /* Turn the chip off */
- l64781_writereg (state, 0x3e, 0x5a);
-
- /* Responds to all reads with 0 */
- if (l64781_readreg(state, 0x1a) != 0) {
- dprintk("Read 1 returned unexpcted value\n");
- goto error;
- }
-
- /* Turn the chip on */
- l64781_writereg (state, 0x3e, 0xa5);
-
- /* Responds with register default value */
- if (l64781_readreg(state, 0x1a) != 0xa1) {
- dprintk("Read 2 returned unexpcted value\n");
- goto error;
- }
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &l64781_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- if (reg0x3e >= 0)
- l64781_writereg (state, 0x3e, reg0x3e); /* restore reg 0x3e */
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops l64781_ops = {
-
- .info = {
- .name = "LSI L64781 DVB-T",
- .type = FE_OFDM,
- /* .frequency_min = ???,*/
- /* .frequency_max = ???,*/
- .frequency_stepsize = 166666,
- /* .frequency_tolerance = ???,*/
- /* .symbol_rate_tolerance = ???,*/
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
- FE_CAN_MUTE_TS
- },
-
- .release = l64781_release,
-
- .init = l64781_init,
- .sleep = l64781_sleep,
-
- .set_frontend = apply_frontend_param,
- .get_frontend = get_frontend,
- .get_tune_settings = l64781_get_tune_settings,
-
- .read_status = l64781_read_status,
- .read_ber = l64781_read_ber,
- .read_signal_strength = l64781_read_signal_strength,
- .read_snr = l64781_read_snr,
- .read_ucblocks = l64781_read_ucblocks,
-};
-
-MODULE_DESCRIPTION("LSI L64781 DVB-T Demodulator driver");
-MODULE_AUTHOR("Holger Waechtler, Marko Kohtala");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(l64781_attach);
diff --git a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h
deleted file mode 100644
index 83b8bc21027..00000000000
--- a/drivers/media/dvb/frontends/l64781.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- driver for LSI L64781 COFDM demodulator
-
- Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH
- Marko Kohtala <marko.kohtala@luukku.com>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef L64781_H
-#define L64781_H
-
-#include <linux/dvb/frontend.h>
-
-struct l64781_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-};
-
-
-extern struct dvb_frontend* l64781_attach(const struct l64781_config* config,
- struct i2c_adapter* i2c);
-
-#endif // L64781_H
diff --git a/drivers/media/dvb/frontends/lg_h06xf.h b/drivers/media/dvb/frontends/lg_h06xf.h
deleted file mode 100644
index 754d51d1112..00000000000
--- a/drivers/media/dvb/frontends/lg_h06xf.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * lg_h06xf.h - ATSC Tuner support for LG TDVS-H06xF
- *
- * 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.
- */
-
-#ifndef _LG_H06XF_H_
-#define _LG_H06XF_H_
-#include "dvb-pll.h"
-
-static int lg_h06xf_pll_set(struct dvb_frontend* fe, struct i2c_adapter* i2c_adap,
- struct dvb_frontend_parameters* params)
-{
- u8 buf[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0,
- .buf = buf, .len = sizeof(buf) };
- int err;
-
- dvb_pll_configure(&dvb_pll_lg_tdvs_h06xf, buf, params->frequency, 0);
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if ((err = i2c_transfer(i2c_adap, &msg, 1)) != 1) {
- printk(KERN_WARNING "lg_h06xf: %s error "
- "(addr %02x <- %02x, err = %i)\n",
- __FUNCTION__, buf[0], buf[1], err);
- if (err < 0)
- return err;
- else
- return -EREMOTEIO;
- }
-
- /* Set the Auxiliary Byte. */
- buf[0] = buf[2];
- buf[0] &= ~0x20;
- buf[0] |= 0x18;
- buf[1] = 0x50;
- msg.len = 2;
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if ((err = i2c_transfer(i2c_adap, &msg, 1)) != 1) {
- printk(KERN_WARNING "lg_h06xf: %s error "
- "(addr %02x <- %02x, err = %i)\n",
- __FUNCTION__, buf[0], buf[1], err);
- if (err < 0)
- return err;
- else
- return -EREMOTEIO;
- }
-
- return 0;
-}
-#endif
diff --git a/drivers/media/dvb/frontends/lgdt330x.c b/drivers/media/dvb/frontends/lgdt330x.c
deleted file mode 100644
index 9a354708bd2..00000000000
--- a/drivers/media/dvb/frontends/lgdt330x.c
+++ /dev/null
@@ -1,812 +0,0 @@
-/*
- * Support for LGDT3302 and LGDT3303 - VSB/QAM
- *
- * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
- *
- * 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.
- *
- */
-
-/*
- * NOTES ABOUT THIS DRIVER
- *
- * This Linux driver supports:
- * DViCO FusionHDTV 3 Gold-Q
- * DViCO FusionHDTV 3 Gold-T
- * DViCO FusionHDTV 5 Gold
- * DViCO FusionHDTV 5 Lite
- * DViCO FusionHDTV 5 USB Gold
- * Air2PC/AirStar 2 ATSC 3rd generation (HD5000)
- * pcHDTV HD5500
- *
- * TODO:
- * signal strength always returns 0.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <asm/byteorder.h>
-
-#include "dvb_frontend.h"
-#include "lgdt330x_priv.h"
-#include "lgdt330x.h"
-
-static int debug = 0;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug,"Turn on/off lgdt330x frontend debugging (default:off).");
-#define dprintk(args...) \
-do { \
-if (debug) printk(KERN_DEBUG "lgdt330x: " args); \
-} while (0)
-
-struct lgdt330x_state
-{
- struct i2c_adapter* i2c;
-
- /* Configuration settings */
- const struct lgdt330x_config* config;
-
- struct dvb_frontend frontend;
-
- /* Demodulator private data */
- fe_modulation_t current_modulation;
-
- /* Tuner private data */
- u32 current_frequency;
-};
-
-static int i2c_write_demod_bytes (struct lgdt330x_state* state,
- u8 *buf, /* data bytes to send */
- int len /* number of bytes to send */ )
-{
- struct i2c_msg msg =
- { .addr = state->config->demod_address,
- .flags = 0,
- .buf = buf,
- .len = 2 };
- int i;
- int err;
-
- for (i=0; i<len-1; i+=2){
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "lgdt330x: %s error (addr %02x <- %02x, err = %i)\n", __FUNCTION__, msg.buf[0], msg.buf[1], err);
- if (err < 0)
- return err;
- else
- return -EREMOTEIO;
- }
- msg.buf += 2;
- }
- return 0;
-}
-
-/*
- * This routine writes the register (reg) to the demod bus
- * then reads the data returned for (len) bytes.
- */
-
-static u8 i2c_read_demod_bytes (struct lgdt330x_state* state,
- enum I2C_REG reg, u8* buf, int len)
-{
- u8 wr [] = { reg };
- struct i2c_msg msg [] = {
- { .addr = state->config->demod_address,
- .flags = 0, .buf = wr, .len = 1 },
- { .addr = state->config->demod_address,
- .flags = I2C_M_RD, .buf = buf, .len = len },
- };
- int ret;
- ret = i2c_transfer(state->i2c, msg, 2);
- if (ret != 2) {
- printk(KERN_WARNING "lgdt330x: %s: addr 0x%02x select 0x%02x error (ret == %i)\n", __FUNCTION__, state->config->demod_address, reg, ret);
- } else {
- ret = 0;
- }
- return ret;
-}
-
-/* Software reset */
-static int lgdt3302_SwReset(struct lgdt330x_state* state)
-{
- u8 ret;
- u8 reset[] = {
- IRQ_MASK,
- 0x00 /* bit 6 is active low software reset
- * bits 5-0 are 1 to mask interrupts */
- };
-
- ret = i2c_write_demod_bytes(state,
- reset, sizeof(reset));
- if (ret == 0) {
-
- /* force reset high (inactive) and unmask interrupts */
- reset[1] = 0x7f;
- ret = i2c_write_demod_bytes(state,
- reset, sizeof(reset));
- }
- return ret;
-}
-
-static int lgdt3303_SwReset(struct lgdt330x_state* state)
-{
- u8 ret;
- u8 reset[] = {
- 0x02,
- 0x00 /* bit 0 is active low software reset */
- };
-
- ret = i2c_write_demod_bytes(state,
- reset, sizeof(reset));
- if (ret == 0) {
-
- /* force reset high (inactive) */
- reset[1] = 0x01;
- ret = i2c_write_demod_bytes(state,
- reset, sizeof(reset));
- }
- return ret;
-}
-
-static int lgdt330x_SwReset(struct lgdt330x_state* state)
-{
- switch (state->config->demod_chip) {
- case LGDT3302:
- return lgdt3302_SwReset(state);
- case LGDT3303:
- return lgdt3303_SwReset(state);
- default:
- return -ENODEV;
- }
-}
-
-static int lgdt330x_init(struct dvb_frontend* fe)
-{
- /* Hardware reset is done using gpio[0] of cx23880x chip.
- * I'd like to do it here, but don't know how to find chip address.
- * cx88-cards.c arranges for the reset bit to be inactive (high).
- * Maybe there needs to be a callable function in cx88-core or
- * the caller of this function needs to do it. */
-
- /*
- * Array of byte pairs <address, value>
- * to initialize each different chip
- */
- static u8 lgdt3302_init_data[] = {
- /* Use 50MHz parameter values from spec sheet since xtal is 50 */
- /* Change the value of NCOCTFV[25:0] of carrier
- recovery center frequency register */
- VSB_CARRIER_FREQ0, 0x00,
- VSB_CARRIER_FREQ1, 0x87,
- VSB_CARRIER_FREQ2, 0x8e,
- VSB_CARRIER_FREQ3, 0x01,
- /* Change the TPCLK pin polarity
- data is valid on falling clock */
- DEMUX_CONTROL, 0xfb,
- /* Change the value of IFBW[11:0] of
- AGC IF/RF loop filter bandwidth register */
- AGC_RF_BANDWIDTH0, 0x40,
- AGC_RF_BANDWIDTH1, 0x93,
- AGC_RF_BANDWIDTH2, 0x00,
- /* Change the value of bit 6, 'nINAGCBY' and
- 'NSSEL[1:0] of ACG function control register 2 */
- AGC_FUNC_CTRL2, 0xc6,
- /* Change the value of bit 6 'RFFIX'
- of AGC function control register 3 */
- AGC_FUNC_CTRL3, 0x40,
- /* Set the value of 'INLVTHD' register 0x2a/0x2c
- to 0x7fe */
- AGC_DELAY0, 0x07,
- AGC_DELAY2, 0xfe,
- /* Change the value of IAGCBW[15:8]
- of inner AGC loop filter bandwidth */
- AGC_LOOP_BANDWIDTH0, 0x08,
- AGC_LOOP_BANDWIDTH1, 0x9a
- };
-
- static u8 lgdt3303_init_data[] = {
- 0x4c, 0x14
- };
-
- static u8 flip_lgdt3303_init_data[] = {
- 0x4c, 0x14,
- 0x87, 0xf3
- };
-
- struct lgdt330x_state* state = fe->demodulator_priv;
- char *chip_name;
- int err;
-
- switch (state->config->demod_chip) {
- case LGDT3302:
- chip_name = "LGDT3302";
- err = i2c_write_demod_bytes(state, lgdt3302_init_data,
- sizeof(lgdt3302_init_data));
- break;
- case LGDT3303:
- chip_name = "LGDT3303";
- if (state->config->clock_polarity_flip) {
- err = i2c_write_demod_bytes(state, flip_lgdt3303_init_data,
- sizeof(flip_lgdt3303_init_data));
- } else {
- err = i2c_write_demod_bytes(state, lgdt3303_init_data,
- sizeof(lgdt3303_init_data));
- }
- break;
- default:
- chip_name = "undefined";
- printk (KERN_WARNING "Only LGDT3302 and LGDT3303 are supported chips.\n");
- err = -ENODEV;
- }
- dprintk("%s entered as %s\n", __FUNCTION__, chip_name);
- if (err < 0)
- return err;
- return lgdt330x_SwReset(state);
-}
-
-static int lgdt330x_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- *ber = 0; /* Not supplied by the demod chips */
- return 0;
-}
-
-static int lgdt330x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct lgdt330x_state* state = fe->demodulator_priv;
- int err;
- u8 buf[2];
-
- switch (state->config->demod_chip) {
- case LGDT3302:
- err = i2c_read_demod_bytes(state, LGDT3302_PACKET_ERR_COUNTER1,
- buf, sizeof(buf));
- break;
- case LGDT3303:
- err = i2c_read_demod_bytes(state, LGDT3303_PACKET_ERR_COUNTER1,
- buf, sizeof(buf));
- break;
- default:
- printk(KERN_WARNING
- "Only LGDT3302 and LGDT3303 are supported chips.\n");
- err = -ENODEV;
- }
-
- *ucblocks = (buf[0] << 8) | buf[1];
- return 0;
-}
-
-static int lgdt330x_set_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- /*
- * Array of byte pairs <address, value>
- * to initialize 8VSB for lgdt3303 chip 50 MHz IF
- */
- static u8 lgdt3303_8vsb_44_data[] = {
- 0x04, 0x00,
- 0x0d, 0x40,
- 0x0e, 0x87,
- 0x0f, 0x8e,
- 0x10, 0x01,
- 0x47, 0x8b };
-
- /*
- * Array of byte pairs <address, value>
- * to initialize QAM for lgdt3303 chip
- */
- static u8 lgdt3303_qam_data[] = {
- 0x04, 0x00,
- 0x0d, 0x00,
- 0x0e, 0x00,
- 0x0f, 0x00,
- 0x10, 0x00,
- 0x51, 0x63,
- 0x47, 0x66,
- 0x48, 0x66,
- 0x4d, 0x1a,
- 0x49, 0x08,
- 0x4a, 0x9b };
-
- struct lgdt330x_state* state = fe->demodulator_priv;
-
- static u8 top_ctrl_cfg[] = { TOP_CONTROL, 0x03 };
-
- int err;
- /* Change only if we are actually changing the modulation */
- if (state->current_modulation != param->u.vsb.modulation) {
- switch(param->u.vsb.modulation) {
- case VSB_8:
- dprintk("%s: VSB_8 MODE\n", __FUNCTION__);
-
- /* Select VSB mode */
- top_ctrl_cfg[1] = 0x03;
-
- /* Select ANT connector if supported by card */
- if (state->config->pll_rf_set)
- state->config->pll_rf_set(fe, 1);
-
- if (state->config->demod_chip == LGDT3303) {
- err = i2c_write_demod_bytes(state, lgdt3303_8vsb_44_data,
- sizeof(lgdt3303_8vsb_44_data));
- }
- break;
-
- case QAM_64:
- dprintk("%s: QAM_64 MODE\n", __FUNCTION__);
-
- /* Select QAM_64 mode */
- top_ctrl_cfg[1] = 0x00;
-
- /* Select CABLE connector if supported by card */
- if (state->config->pll_rf_set)
- state->config->pll_rf_set(fe, 0);
-
- if (state->config->demod_chip == LGDT3303) {
- err = i2c_write_demod_bytes(state, lgdt3303_qam_data,
- sizeof(lgdt3303_qam_data));
- }
- break;
-
- case QAM_256:
- dprintk("%s: QAM_256 MODE\n", __FUNCTION__);
-
- /* Select QAM_256 mode */
- top_ctrl_cfg[1] = 0x01;
-
- /* Select CABLE connector if supported by card */
- if (state->config->pll_rf_set)
- state->config->pll_rf_set(fe, 0);
-
- if (state->config->demod_chip == LGDT3303) {
- err = i2c_write_demod_bytes(state, lgdt3303_qam_data,
- sizeof(lgdt3303_qam_data));
- }
- break;
- default:
- printk(KERN_WARNING "lgdt330x: %s: Modulation type(%d) UNSUPPORTED\n", __FUNCTION__, param->u.vsb.modulation);
- return -1;
- }
- /*
- * select serial or parallel MPEG harware interface
- * Serial: 0x04 for LGDT3302 or 0x40 for LGDT3303
- * Parallel: 0x00
- */
- top_ctrl_cfg[1] |= state->config->serial_mpeg;
-
- /* Select the requested mode */
- i2c_write_demod_bytes(state, top_ctrl_cfg,
- sizeof(top_ctrl_cfg));
- if (state->config->set_ts_params)
- state->config->set_ts_params(fe, 0);
- state->current_modulation = param->u.vsb.modulation;
- }
-
- /* Tune to the specified frequency */
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, param);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- /* Keep track of the new frequency */
- /* FIXME this is the wrong way to do this... */
- /* The tuner is shared with the video4linux analog API */
- state->current_frequency = param->frequency;
-
- lgdt330x_SwReset(state);
- return 0;
-}
-
-static int lgdt330x_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* param)
-{
- struct lgdt330x_state *state = fe->demodulator_priv;
- param->frequency = state->current_frequency;
- return 0;
-}
-
-static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct lgdt330x_state* state = fe->demodulator_priv;
- u8 buf[3];
-
- *status = 0; /* Reset status result */
-
- /* AGC status register */
- i2c_read_demod_bytes(state, AGC_STATUS, buf, 1);
- dprintk("%s: AGC_STATUS = 0x%02x\n", __FUNCTION__, buf[0]);
- if ((buf[0] & 0x0c) == 0x8){
- /* Test signal does not exist flag */
- /* as well as the AGC lock flag. */
- *status |= FE_HAS_SIGNAL;
- } else {
- /* Without a signal all other status bits are meaningless */
- return 0;
- }
-
- /*
- * You must set the Mask bits to 1 in the IRQ_MASK in order
- * to see that status bit in the IRQ_STATUS register.
- * This is done in SwReset();
- */
- /* signal status */
- i2c_read_demod_bytes(state, TOP_CONTROL, buf, sizeof(buf));
- dprintk("%s: TOP_CONTROL = 0x%02x, IRO_MASK = 0x%02x, IRQ_STATUS = 0x%02x\n", __FUNCTION__, buf[0], buf[1], buf[2]);
-
-
- /* sync status */
- if ((buf[2] & 0x03) == 0x01) {
- *status |= FE_HAS_SYNC;
- }
-
- /* FEC error status */
- if ((buf[2] & 0x0c) == 0x08) {
- *status |= FE_HAS_LOCK;
- *status |= FE_HAS_VITERBI;
- }
-
- /* Carrier Recovery Lock Status Register */
- i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
- dprintk("%s: CARRIER_LOCK = 0x%02x\n", __FUNCTION__, buf[0]);
- switch (state->current_modulation) {
- case QAM_256:
- case QAM_64:
- /* Need to undestand why there are 3 lock levels here */
- if ((buf[0] & 0x07) == 0x07)
- *status |= FE_HAS_CARRIER;
- break;
- case VSB_8:
- if ((buf[0] & 0x80) == 0x80)
- *status |= FE_HAS_CARRIER;
- break;
- default:
- printk("KERN_WARNING lgdt330x: %s: Modulation set to unsupported value\n", __FUNCTION__);
- }
-
- return 0;
-}
-
-static int lgdt3303_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct lgdt330x_state* state = fe->demodulator_priv;
- int err;
- u8 buf[3];
-
- *status = 0; /* Reset status result */
-
- /* lgdt3303 AGC status register */
- err = i2c_read_demod_bytes(state, 0x58, buf, 1);
- if (err < 0)
- return err;
-
- dprintk("%s: AGC_STATUS = 0x%02x\n", __FUNCTION__, buf[0]);
- if ((buf[0] & 0x21) == 0x01){
- /* Test input signal does not exist flag */
- /* as well as the AGC lock flag. */
- *status |= FE_HAS_SIGNAL;
- } else {
- /* Without a signal all other status bits are meaningless */
- return 0;
- }
-
- /* Carrier Recovery Lock Status Register */
- i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1);
- dprintk("%s: CARRIER_LOCK = 0x%02x\n", __FUNCTION__, buf[0]);
- switch (state->current_modulation) {
- case QAM_256:
- case QAM_64:
- /* Need to undestand why there are 3 lock levels here */
- if ((buf[0] & 0x07) == 0x07)
- *status |= FE_HAS_CARRIER;
- else
- break;
- i2c_read_demod_bytes(state, 0x8a, buf, 1);
- if ((buf[0] & 0x04) == 0x04)
- *status |= FE_HAS_SYNC;
- if ((buf[0] & 0x01) == 0x01)
- *status |= FE_HAS_LOCK;
- if ((buf[0] & 0x08) == 0x08)
- *status |= FE_HAS_VITERBI;
- break;
- case VSB_8:
- if ((buf[0] & 0x80) == 0x80)
- *status |= FE_HAS_CARRIER;
- else
- break;
- i2c_read_demod_bytes(state, 0x38, buf, 1);
- if ((buf[0] & 0x02) == 0x00)
- *status |= FE_HAS_SYNC;
- if ((buf[0] & 0x01) == 0x01) {
- *status |= FE_HAS_LOCK;
- *status |= FE_HAS_VITERBI;
- }
- break;
- default:
- printk("KERN_WARNING lgdt330x: %s: Modulation set to unsupported value\n", __FUNCTION__);
- }
- return 0;
-}
-
-static int lgdt330x_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- /* not directly available. */
- *strength = 0;
- return 0;
-}
-
-static int lgdt3302_read_snr(struct dvb_frontend* fe, u16* snr)
-{
-#ifdef SNR_IN_DB
- /*
- * Spec sheet shows formula for SNR_EQ = 10 log10(25 * 24**2 / noise)
- * and SNR_PH = 10 log10(25 * 32**2 / noise) for equalizer and phase tracker
- * respectively. The following tables are built on these formulas.
- * The usual definition is SNR = 20 log10(signal/noise)
- * If the specification is wrong the value retuned is 1/2 the actual SNR in db.
- *
- * This table is a an ordered list of noise values computed by the
- * formula from the spec sheet such that the index into the table
- * starting at 43 or 45 is the SNR value in db. There are duplicate noise
- * value entries at the beginning because the SNR varies more than
- * 1 db for a change of 1 digit in noise at very small values of noise.
- *
- * Examples from SNR_EQ table:
- * noise SNR
- * 0 43
- * 1 42
- * 2 39
- * 3 37
- * 4 36
- * 5 35
- * 6 34
- * 7 33
- * 8 33
- * 9 32
- * 10 32
- * 11 31
- * 12 31
- * 13 30
- */
-
- static const u32 SNR_EQ[] =
- { 1, 2, 2, 2, 3, 3, 4, 4, 5, 7,
- 9, 11, 13, 17, 21, 26, 33, 41, 52, 65,
- 81, 102, 129, 162, 204, 257, 323, 406, 511, 644,
- 810, 1020, 1284, 1616, 2035, 2561, 3224, 4059, 5110, 6433,
- 8098, 10195, 12835, 16158, 20341, 25608, 32238, 40585, 51094, 64323,
- 80978, 101945, 128341, 161571, 203406, 256073, 0x40000
- };
-
- static const u32 SNR_PH[] =
- { 1, 2, 2, 2, 3, 3, 4, 5, 6, 8,
- 10, 12, 15, 19, 23, 29, 37, 46, 58, 73,
- 91, 115, 144, 182, 229, 288, 362, 456, 574, 722,
- 909, 1144, 1440, 1813, 2282, 2873, 3617, 4553, 5732, 7216,
- 9084, 11436, 14396, 18124, 22817, 28724, 36161, 45524, 57312, 72151,
- 90833, 114351, 143960, 181235, 228161, 0x080000
- };
-
- static u8 buf[5];/* read data buffer */
- static u32 noise; /* noise value */
- static u32 snr_db; /* index into SNR_EQ[] */
- struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
-
- /* read both equalizer and phase tracker noise data */
- i2c_read_demod_bytes(state, EQPH_ERR0, buf, sizeof(buf));
-
- if (state->current_modulation == VSB_8) {
- /* Equalizer Mean-Square Error Register for VSB */
- noise = ((buf[0] & 7) << 16) | (buf[1] << 8) | buf[2];
-
- /*
- * Look up noise value in table.
- * A better search algorithm could be used...
- * watch out there are duplicate entries.
- */
- for (snr_db = 0; snr_db < sizeof(SNR_EQ); snr_db++) {
- if (noise < SNR_EQ[snr_db]) {
- *snr = 43 - snr_db;
- break;
- }
- }
- } else {
- /* Phase Tracker Mean-Square Error Register for QAM */
- noise = ((buf[0] & 7<<3) << 13) | (buf[3] << 8) | buf[4];
-
- /* Look up noise value in table. */
- for (snr_db = 0; snr_db < sizeof(SNR_PH); snr_db++) {
- if (noise < SNR_PH[snr_db]) {
- *snr = 45 - snr_db;
- break;
- }
- }
- }
-#else
- /* Return the raw noise value */
- static u8 buf[5];/* read data buffer */
- static u32 noise; /* noise value */
- struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
-
- /* read both equalizer and pase tracker noise data */
- i2c_read_demod_bytes(state, EQPH_ERR0, buf, sizeof(buf));
-
- if (state->current_modulation == VSB_8) {
- /* Phase Tracker Mean-Square Error Register for VSB */
- noise = ((buf[0] & 7<<3) << 13) | (buf[3] << 8) | buf[4];
- } else {
-
- /* Carrier Recovery Mean-Square Error for QAM */
- i2c_read_demod_bytes(state, 0x1a, buf, 2);
- noise = ((buf[0] & 3) << 8) | buf[1];
- }
-
- /* Small values for noise mean signal is better so invert noise */
- *snr = ~noise;
-#endif
-
- dprintk("%s: noise = 0x%05x, snr = %idb\n",__FUNCTION__, noise, *snr);
-
- return 0;
-}
-
-static int lgdt3303_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- /* Return the raw noise value */
- static u8 buf[5];/* read data buffer */
- static u32 noise; /* noise value */
- struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
-
- if (state->current_modulation == VSB_8) {
-
- i2c_read_demod_bytes(state, 0x6e, buf, 5);
- /* Phase Tracker Mean-Square Error Register for VSB */
- noise = ((buf[0] & 7) << 16) | (buf[3] << 8) | buf[4];
- } else {
-
- /* Carrier Recovery Mean-Square Error for QAM */
- i2c_read_demod_bytes(state, 0x1a, buf, 2);
- noise = (buf[0] << 8) | buf[1];
- }
-
- /* Small values for noise mean signal is better so invert noise */
- *snr = ~noise;
-
- dprintk("%s: noise = 0x%05x, snr = %idb\n",__FUNCTION__, noise, *snr);
-
- return 0;
-}
-
-static int lgdt330x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
-{
- /* I have no idea about this - it may not be needed */
- fe_tune_settings->min_delay_ms = 500;
- fe_tune_settings->step_size = 0;
- fe_tune_settings->max_drift = 0;
- return 0;
-}
-
-static void lgdt330x_release(struct dvb_frontend* fe)
-{
- struct lgdt330x_state* state = (struct lgdt330x_state*) fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops lgdt3302_ops;
-static struct dvb_frontend_ops lgdt3303_ops;
-
-struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
- struct i2c_adapter* i2c)
-{
- struct lgdt330x_state* state = NULL;
- u8 buf[1];
-
- /* Allocate memory for the internal state */
- state = kzalloc(sizeof(struct lgdt330x_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* Setup the state */
- state->config = config;
- state->i2c = i2c;
-
- /* Create dvb_frontend */
- switch (config->demod_chip) {
- case LGDT3302:
- memcpy(&state->frontend.ops, &lgdt3302_ops, sizeof(struct dvb_frontend_ops));
- break;
- case LGDT3303:
- memcpy(&state->frontend.ops, &lgdt3303_ops, sizeof(struct dvb_frontend_ops));
- break;
- default:
- goto error;
- }
- state->frontend.demodulator_priv = state;
-
- /* Verify communication with demod chip */
- if (i2c_read_demod_bytes(state, 2, buf, 1))
- goto error;
-
- state->current_frequency = -1;
- state->current_modulation = -1;
-
- return &state->frontend;
-
-error:
- kfree(state);
- dprintk("%s: ERROR\n",__FUNCTION__);
- return NULL;
-}
-
-static struct dvb_frontend_ops lgdt3302_ops = {
- .info = {
- .name= "LG Electronics LGDT3302 VSB/QAM Frontend",
- .type = FE_ATSC,
- .frequency_min= 54000000,
- .frequency_max= 858000000,
- .frequency_stepsize= 62500,
- .symbol_rate_min = 5056941, /* QAM 64 */
- .symbol_rate_max = 10762000, /* VSB 8 */
- .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
- },
- .init = lgdt330x_init,
- .set_frontend = lgdt330x_set_parameters,
- .get_frontend = lgdt330x_get_frontend,
- .get_tune_settings = lgdt330x_get_tune_settings,
- .read_status = lgdt3302_read_status,
- .read_ber = lgdt330x_read_ber,
- .read_signal_strength = lgdt330x_read_signal_strength,
- .read_snr = lgdt3302_read_snr,
- .read_ucblocks = lgdt330x_read_ucblocks,
- .release = lgdt330x_release,
-};
-
-static struct dvb_frontend_ops lgdt3303_ops = {
- .info = {
- .name= "LG Electronics LGDT3303 VSB/QAM Frontend",
- .type = FE_ATSC,
- .frequency_min= 54000000,
- .frequency_max= 858000000,
- .frequency_stepsize= 62500,
- .symbol_rate_min = 5056941, /* QAM 64 */
- .symbol_rate_max = 10762000, /* VSB 8 */
- .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
- },
- .init = lgdt330x_init,
- .set_frontend = lgdt330x_set_parameters,
- .get_frontend = lgdt330x_get_frontend,
- .get_tune_settings = lgdt330x_get_tune_settings,
- .read_status = lgdt3303_read_status,
- .read_ber = lgdt330x_read_ber,
- .read_signal_strength = lgdt330x_read_signal_strength,
- .read_snr = lgdt3303_read_snr,
- .read_ucblocks = lgdt330x_read_ucblocks,
- .release = lgdt330x_release,
-};
-
-MODULE_DESCRIPTION("LGDT330X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
-MODULE_AUTHOR("Wilson Michaels");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(lgdt330x_attach);
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/drivers/media/dvb/frontends/lgdt330x.h b/drivers/media/dvb/frontends/lgdt330x.h
deleted file mode 100644
index bad903c6f0f..00000000000
--- a/drivers/media/dvb/frontends/lgdt330x.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Support for LGDT3302 and LGDT3303 - VSB/QAM
- *
- * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
- *
- * 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.
- *
- */
-
-#ifndef LGDT330X_H
-#define LGDT330X_H
-
-#include <linux/dvb/frontend.h>
-
-typedef enum lg_chip_t {
- UNDEFINED,
- LGDT3302,
- LGDT3303
-}lg_chip_type;
-
-struct lgdt330x_config
-{
- /* The demodulator's i2c address */
- u8 demod_address;
-
- /* LG demodulator chip LGDT3302 or LGDT3303 */
- lg_chip_type demod_chip;
-
- /* MPEG hardware interface - 0:parallel 1:serial */
- int serial_mpeg;
-
- /* PLL interface */
- int (*pll_rf_set) (struct dvb_frontend* fe, int index);
-
- /* Need to set device param for start_dma */
- int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
-
- /* Flip the polarity of the mpeg data transfer clock using alternate init data
- * This option applies ONLY to LGDT3303 - 0:disabled (default) 1:enabled */
- int clock_polarity_flip;
-};
-
-extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config,
- struct i2c_adapter* i2c);
-
-#endif /* LGDT330X_H */
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/drivers/media/dvb/frontends/lgdt330x_priv.h b/drivers/media/dvb/frontends/lgdt330x_priv.h
deleted file mode 100644
index 59b7c5b9012..00000000000
--- a/drivers/media/dvb/frontends/lgdt330x_priv.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Support for LGDT3302 and LGDT3303 - VSB/QAM
- *
- * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
- *
- * 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.
- *
- */
-
-#ifndef _LGDT330X_PRIV_
-#define _LGDT330X_PRIV_
-
-/* i2c control register addresses */
-enum I2C_REG {
- TOP_CONTROL= 0x00,
- IRQ_MASK= 0x01,
- IRQ_STATUS= 0x02,
- VSB_CARRIER_FREQ0= 0x16,
- VSB_CARRIER_FREQ1= 0x17,
- VSB_CARRIER_FREQ2= 0x18,
- VSB_CARRIER_FREQ3= 0x19,
- CARRIER_MSEQAM1= 0x1a,
- CARRIER_MSEQAM2= 0x1b,
- CARRIER_LOCK= 0x1c,
- TIMING_RECOVERY= 0x1d,
- AGC_DELAY0= 0x2a,
- AGC_DELAY1= 0x2b,
- AGC_DELAY2= 0x2c,
- AGC_RF_BANDWIDTH0= 0x2d,
- AGC_RF_BANDWIDTH1= 0x2e,
- AGC_RF_BANDWIDTH2= 0x2f,
- AGC_LOOP_BANDWIDTH0= 0x30,
- AGC_LOOP_BANDWIDTH1= 0x31,
- AGC_FUNC_CTRL1= 0x32,
- AGC_FUNC_CTRL2= 0x33,
- AGC_FUNC_CTRL3= 0x34,
- AGC_RFIF_ACC0= 0x39,
- AGC_RFIF_ACC1= 0x3a,
- AGC_RFIF_ACC2= 0x3b,
- AGC_STATUS= 0x3f,
- SYNC_STATUS_VSB= 0x43,
- EQPH_ERR0= 0x47,
- EQ_ERR1= 0x48,
- EQ_ERR2= 0x49,
- PH_ERR1= 0x4a,
- PH_ERR2= 0x4b,
- DEMUX_CONTROL= 0x66,
- LGDT3302_PACKET_ERR_COUNTER1= 0x6a,
- LGDT3302_PACKET_ERR_COUNTER2= 0x6b,
- LGDT3303_PACKET_ERR_COUNTER1= 0x8b,
- LGDT3303_PACKET_ERR_COUNTER2= 0x8c,
-};
-
-#endif /* _LGDT330X_PRIV_ */
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/drivers/media/dvb/frontends/lnbp21.c b/drivers/media/dvb/frontends/lnbp21.c
deleted file mode 100644
index e933edc8dd2..00000000000
--- a/drivers/media/dvb/frontends/lnbp21.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * lnbp21.h - driver for lnb supply and control ic lnbp21
- *
- * Copyright (C) 2006 Oliver Endriss
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org
- */
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "lnbp21.h"
-
-struct lnbp21 {
- u8 config;
- u8 override_or;
- u8 override_and;
- struct i2c_adapter *i2c;
- void (*release_chain)(struct dvb_frontend* fe);
-};
-
-static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
-{
- struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
- struct i2c_msg msg = { .addr = 0x08, .flags = 0,
- .buf = &lnbp21->config,
- .len = sizeof(lnbp21->config) };
-
- lnbp21->config &= ~(LNBP21_VSEL | LNBP21_EN);
-
- switch(voltage) {
- case SEC_VOLTAGE_OFF:
- break;
- case SEC_VOLTAGE_13:
- lnbp21->config |= LNBP21_EN;
- break;
- case SEC_VOLTAGE_18:
- lnbp21->config |= (LNBP21_EN | LNBP21_VSEL);
- break;
- default:
- return -EINVAL;
- };
-
- lnbp21->config |= lnbp21->override_or;
- lnbp21->config &= lnbp21->override_and;
-
- return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
-}
-
-static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
-{
- struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
- struct i2c_msg msg = { .addr = 0x08, .flags = 0,
- .buf = &lnbp21->config,
- .len = sizeof(lnbp21->config) };
-
- if (arg)
- lnbp21->config |= LNBP21_LLC;
- else
- lnbp21->config &= ~LNBP21_LLC;
-
- lnbp21->config |= lnbp21->override_or;
- lnbp21->config &= lnbp21->override_and;
-
- return (i2c_transfer(lnbp21->i2c, &msg, 1) == 1) ? 0 : -EIO;
-}
-
-static void lnbp21_release(struct dvb_frontend *fe)
-{
- struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
-
- /* LNBP power off */
- lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF);
-
- /* free data & call next release routine */
- fe->ops.release = lnbp21->release_chain;
- kfree(fe->misc_priv);
- fe->misc_priv = NULL;
- if (fe->ops.release)
- fe->ops.release(fe);
-}
-
-int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear)
-{
- struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL);
- if (!lnbp21)
- return -ENOMEM;
-
- /* default configuration */
- lnbp21->config = LNBP21_ISEL;
- lnbp21->i2c = i2c;
- fe->misc_priv = lnbp21;
-
- /* bits which should be forced to '1' */
- lnbp21->override_or = override_set;
-
- /* bits which should be forced to '0' */
- lnbp21->override_and = ~override_clear;
-
- /* detect if it is present or not */
- if (lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF)) {
- kfree(lnbp21);
- fe->misc_priv = NULL;
- return -EIO;
- }
-
- /* install release callback */
- lnbp21->release_chain = fe->ops.release;
- fe->ops.release = lnbp21_release;
-
- /* override frontend ops */
- fe->ops.set_voltage = lnbp21_set_voltage;
- fe->ops.enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
-
- return 0;
-}
-EXPORT_SYMBOL(lnbp21_attach);
-
-MODULE_DESCRIPTION("Driver for lnb supply and control ic lnbp21");
-MODULE_AUTHOR("Oliver Endriss");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h
deleted file mode 100644
index 047a4ab68c0..00000000000
--- a/drivers/media/dvb/frontends/lnbp21.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * lnbp21.h - driver for lnb supply and control ic lnbp21
- *
- * Copyright (C) 2006 Oliver Endriss
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org
- */
-
-#ifndef _LNBP21_H
-#define _LNBP21_H
-
-/* system register bits */
-#define LNBP21_OLF 0x01
-#define LNBP21_OTF 0x02
-#define LNBP21_EN 0x04
-#define LNBP21_VSEL 0x08
-#define LNBP21_LLC 0x10
-#define LNBP21_TEN 0x20
-#define LNBP21_ISEL 0x40
-#define LNBP21_PCL 0x80
-
-#include <linux/dvb/frontend.h>
-
-/* override_set and override_clear control which system register bits (above) to always set & clear */
-extern int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear);
-
-#endif
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
deleted file mode 100644
index 1ef82182564..00000000000
--- a/drivers/media/dvb/frontends/mt312.c
+++ /dev/null
@@ -1,709 +0,0 @@
-/*
- Driver for Zarlink VP310/MT312 Satellite Channel Decoder
-
- Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org>
-
- 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.
-
- References:
- http://products.zarlink.com/product_profiles/MT312.htm
- http://products.zarlink.com/product_profiles/SL1935.htm
-*/
-
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "mt312_priv.h"
-#include "mt312.h"
-
-
-struct mt312_state {
- struct i2c_adapter* i2c;
- /* configuration settings */
- const struct mt312_config* config;
- struct dvb_frontend frontend;
-
- u8 id;
- u8 frequency;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "mt312: " args); \
- } while (0)
-
-#define MT312_SYS_CLK 90000000UL /* 90 MHz */
-#define MT312_LPOWER_SYS_CLK 60000000UL /* 60 MHz */
-#define MT312_PLL_CLK 10000000UL /* 10 MHz */
-
-static int mt312_read(struct mt312_state* state, const enum mt312_reg_addr reg,
- void *buf, const size_t count)
-{
- int ret;
- struct i2c_msg msg[2];
- u8 regbuf[1] = { reg };
-
- msg[0].addr = state->config->demod_address;
- msg[0].flags = 0;
- msg[0].buf = regbuf;
- msg[0].len = 1;
- msg[1].addr = state->config->demod_address;
- msg[1].flags = I2C_M_RD;
- msg[1].buf = buf;
- msg[1].len = count;
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2) {
- printk(KERN_ERR "%s: ret == %d\n", __FUNCTION__, ret);
- return -EREMOTEIO;
- }
-
- if(debug) {
- int i;
- dprintk("R(%d):", reg & 0x7f);
- for (i = 0; i < count; i++)
- printk(" %02x", ((const u8 *) buf)[i]);
- printk("\n");
- }
-
- return 0;
-}
-
-static int mt312_write(struct mt312_state* state, const enum mt312_reg_addr reg,
- const void *src, const size_t count)
-{
- int ret;
- u8 buf[count + 1];
- struct i2c_msg msg;
-
- if(debug) {
- int i;
- dprintk("W(%d):", reg & 0x7f);
- for (i = 0; i < count; i++)
- printk(" %02x", ((const u8 *) src)[i]);
- printk("\n");
- }
-
- buf[0] = reg;
- memcpy(&buf[1], src, count);
-
- msg.addr = state->config->demod_address;
- msg.flags = 0;
- msg.buf = buf;
- msg.len = count + 1;
-
- ret = i2c_transfer(state->i2c, &msg, 1);
-
- if (ret != 1) {
- dprintk("%s: ret == %d\n", __FUNCTION__, ret);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static inline int mt312_readreg(struct mt312_state* state,
- const enum mt312_reg_addr reg, u8 *val)
-{
- return mt312_read(state, reg, val, 1);
-}
-
-static inline int mt312_writereg(struct mt312_state* state,
- const enum mt312_reg_addr reg, const u8 val)
-{
- return mt312_write(state, reg, &val, 1);
-}
-
-static inline u32 mt312_div(u32 a, u32 b)
-{
- return (a + (b / 2)) / b;
-}
-
-static int mt312_reset(struct mt312_state* state, const u8 full)
-{
- return mt312_writereg(state, RESET, full ? 0x80 : 0x40);
-}
-
-static int mt312_get_inversion(struct mt312_state* state,
- fe_spectral_inversion_t *i)
-{
- int ret;
- u8 vit_mode;
-
- if ((ret = mt312_readreg(state, VIT_MODE, &vit_mode)) < 0)
- return ret;
-
- if (vit_mode & 0x80) /* auto inversion was used */
- *i = (vit_mode & 0x40) ? INVERSION_ON : INVERSION_OFF;
-
- return 0;
-}
-
-static int mt312_get_symbol_rate(struct mt312_state* state, u32 *sr)
-{
- int ret;
- u8 sym_rate_h;
- u8 dec_ratio;
- u16 sym_rat_op;
- u16 monitor;
- u8 buf[2];
-
- if ((ret = mt312_readreg(state, SYM_RATE_H, &sym_rate_h)) < 0)
- return ret;
-
- if (sym_rate_h & 0x80) { /* symbol rate search was used */
- if ((ret = mt312_writereg(state, MON_CTRL, 0x03)) < 0)
- return ret;
-
- if ((ret = mt312_read(state, MONITOR_H, buf, sizeof(buf))) < 0)
- return ret;
-
- monitor = (buf[0] << 8) | buf[1];
-
- dprintk(KERN_DEBUG "sr(auto) = %u\n",
- mt312_div(monitor * 15625, 4));
- } else {
- if ((ret = mt312_writereg(state, MON_CTRL, 0x05)) < 0)
- return ret;
-
- if ((ret = mt312_read(state, MONITOR_H, buf, sizeof(buf))) < 0)
- return ret;
-
- dec_ratio = ((buf[0] >> 5) & 0x07) * 32;
-
- if ((ret = mt312_read(state, SYM_RAT_OP_H, buf, sizeof(buf))) < 0)
- return ret;
-
- sym_rat_op = (buf[0] << 8) | buf[1];
-
- dprintk(KERN_DEBUG "sym_rat_op=%d dec_ratio=%d\n",
- sym_rat_op, dec_ratio);
- dprintk(KERN_DEBUG "*sr(manual) = %lu\n",
- (((MT312_PLL_CLK * 8192) / (sym_rat_op + 8192)) *
- 2) - dec_ratio);
- }
-
- return 0;
-}
-
-static int mt312_get_code_rate(struct mt312_state* state, fe_code_rate_t *cr)
-{
- const fe_code_rate_t fec_tab[8] =
- { FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_6_7, FEC_7_8,
- FEC_AUTO, FEC_AUTO };
-
- int ret;
- u8 fec_status;
-
- if ((ret = mt312_readreg(state, FEC_STATUS, &fec_status)) < 0)
- return ret;
-
- *cr = fec_tab[(fec_status >> 4) & 0x07];
-
- return 0;
-}
-
-static int mt312_initfe(struct dvb_frontend* fe)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 buf[2];
-
- /* wake up */
- if ((ret = mt312_writereg(state, CONFIG, (state->frequency == 60 ? 0x88 : 0x8c))) < 0)
- return ret;
-
- /* wait at least 150 usec */
- udelay(150);
-
- /* full reset */
- if ((ret = mt312_reset(state, 1)) < 0)
- return ret;
-
-// Per datasheet, write correct values. 09/28/03 ACCJr.
-// If we don't do this, we won't get FE_HAS_VITERBI in the VP310.
- {
- u8 buf_def[8]={0x14, 0x12, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00};
-
- if ((ret = mt312_write(state, VIT_SETUP, buf_def, sizeof(buf_def))) < 0)
- return ret;
- }
-
- /* SYS_CLK */
- buf[0] = mt312_div((state->frequency == 60 ? MT312_LPOWER_SYS_CLK : MT312_SYS_CLK) * 2, 1000000);
-
- /* DISEQC_RATIO */
- buf[1] = mt312_div(MT312_PLL_CLK, 15000 * 4);
-
- if ((ret = mt312_write(state, SYS_CLK, buf, sizeof(buf))) < 0)
- return ret;
-
- if ((ret = mt312_writereg(state, SNR_THS_HIGH, 0x32)) < 0)
- return ret;
-
- if ((ret = mt312_writereg(state, OP_CTRL, 0x53)) < 0)
- return ret;
-
- /* TS_SW_LIM */
- buf[0] = 0x8c;
- buf[1] = 0x98;
-
- if ((ret = mt312_write(state, TS_SW_LIM_L, buf, sizeof(buf))) < 0)
- return ret;
-
- if ((ret = mt312_writereg(state, CS_SW_LIM, 0x69)) < 0)
- return ret;
-
- return 0;
-}
-
-static int mt312_send_master_cmd(struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd *c)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 diseqc_mode;
-
- if ((c->msg_len == 0) || (c->msg_len > sizeof(c->msg)))
- return -EINVAL;
-
- if ((ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode)) < 0)
- return ret;
-
- if ((ret =
- mt312_write(state, (0x80 | DISEQC_INSTR), c->msg, c->msg_len)) < 0)
- return ret;
-
- if ((ret =
- mt312_writereg(state, DISEQC_MODE,
- (diseqc_mode & 0x40) | ((c->msg_len - 1) << 3)
- | 0x04)) < 0)
- return ret;
-
- /* set DISEQC_MODE[2:0] to zero if a return message is expected */
- if (c->msg[0] & 0x02)
- if ((ret =
- mt312_writereg(state, DISEQC_MODE, (diseqc_mode & 0x40))) < 0)
- return ret;
-
- return 0;
-}
-
-static int mt312_send_burst(struct dvb_frontend* fe, const fe_sec_mini_cmd_t c)
-{
- struct mt312_state *state = fe->demodulator_priv;
- const u8 mini_tab[2] = { 0x02, 0x03 };
-
- int ret;
- u8 diseqc_mode;
-
- if (c > SEC_MINI_B)
- return -EINVAL;
-
- if ((ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode)) < 0)
- return ret;
-
- if ((ret =
- mt312_writereg(state, DISEQC_MODE,
- (diseqc_mode & 0x40) | mini_tab[c])) < 0)
- return ret;
-
- return 0;
-}
-
-static int mt312_set_tone(struct dvb_frontend* fe, const fe_sec_tone_mode_t t)
-{
- struct mt312_state *state = fe->demodulator_priv;
- const u8 tone_tab[2] = { 0x01, 0x00 };
-
- int ret;
- u8 diseqc_mode;
-
- if (t > SEC_TONE_OFF)
- return -EINVAL;
-
- if ((ret = mt312_readreg(state, DISEQC_MODE, &diseqc_mode)) < 0)
- return ret;
-
- if ((ret =
- mt312_writereg(state, DISEQC_MODE,
- (diseqc_mode & 0x40) | tone_tab[t])) < 0)
- return ret;
-
- return 0;
-}
-
-static int mt312_set_voltage(struct dvb_frontend* fe, const fe_sec_voltage_t v)
-{
- struct mt312_state *state = fe->demodulator_priv;
- const u8 volt_tab[3] = { 0x00, 0x40, 0x00 };
-
- if (v > SEC_VOLTAGE_OFF)
- return -EINVAL;
-
- return mt312_writereg(state, DISEQC_MODE, volt_tab[v]);
-}
-
-static int mt312_read_status(struct dvb_frontend* fe, fe_status_t *s)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 status[3];
-
- *s = 0;
-
- if ((ret = mt312_read(state, QPSK_STAT_H, status, sizeof(status))) < 0)
- return ret;
-
- dprintk(KERN_DEBUG "QPSK_STAT_H: 0x%02x, QPSK_STAT_L: 0x%02x, FEC_STATUS: 0x%02x\n", status[0], status[1], status[2]);
-
- if (status[0] & 0xc0)
- *s |= FE_HAS_SIGNAL; /* signal noise ratio */
- if (status[0] & 0x04)
- *s |= FE_HAS_CARRIER; /* qpsk carrier lock */
- if (status[2] & 0x02)
- *s |= FE_HAS_VITERBI; /* viterbi lock */
- if (status[2] & 0x04)
- *s |= FE_HAS_SYNC; /* byte align lock */
- if (status[0] & 0x01)
- *s |= FE_HAS_LOCK; /* qpsk lock */
-
- return 0;
-}
-
-static int mt312_read_ber(struct dvb_frontend* fe, u32 *ber)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 buf[3];
-
- if ((ret = mt312_read(state, RS_BERCNT_H, buf, 3)) < 0)
- return ret;
-
- *ber = ((buf[0] << 16) | (buf[1] << 8) | buf[2]) * 64;
-
- return 0;
-}
-
-static int mt312_read_signal_strength(struct dvb_frontend* fe, u16 *signal_strength)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 buf[3];
- u16 agc;
- s16 err_db;
-
- if ((ret = mt312_read(state, AGC_H, buf, sizeof(buf))) < 0)
- return ret;
-
- agc = (buf[0] << 6) | (buf[1] >> 2);
- err_db = (s16) (((buf[1] & 0x03) << 14) | buf[2] << 6) >> 6;
-
- *signal_strength = agc;
-
- dprintk(KERN_DEBUG "agc=%08x err_db=%hd\n", agc, err_db);
-
- return 0;
-}
-
-static int mt312_read_snr(struct dvb_frontend* fe, u16 *snr)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 buf[2];
-
- if ((ret = mt312_read(state, M_SNR_H, &buf, sizeof(buf))) < 0)
- return ret;
-
- *snr = 0xFFFF - ((((buf[0] & 0x7f) << 8) | buf[1]) << 1);
-
- return 0;
-}
-
-static int mt312_read_ucblocks(struct dvb_frontend* fe, u32 *ubc)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 buf[2];
-
- if ((ret = mt312_read(state, RS_UBC_H, &buf, sizeof(buf))) < 0)
- return ret;
-
- *ubc = (buf[0] << 8) | buf[1];
-
- return 0;
-}
-
-static int mt312_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 buf[5], config_val;
- u16 sr;
-
- const u8 fec_tab[10] =
- { 0x00, 0x01, 0x02, 0x04, 0x3f, 0x08, 0x10, 0x20, 0x3f, 0x3f };
- const u8 inv_tab[3] = { 0x00, 0x40, 0x80 };
-
- dprintk("%s: Freq %d\n", __FUNCTION__, p->frequency);
-
- if ((p->frequency < fe->ops.info.frequency_min)
- || (p->frequency > fe->ops.info.frequency_max))
- return -EINVAL;
-
- if ((p->inversion < INVERSION_OFF)
- || (p->inversion > INVERSION_ON))
- return -EINVAL;
-
- if ((p->u.qpsk.symbol_rate < fe->ops.info.symbol_rate_min)
- || (p->u.qpsk.symbol_rate > fe->ops.info.symbol_rate_max))
- return -EINVAL;
-
- if ((p->u.qpsk.fec_inner < FEC_NONE)
- || (p->u.qpsk.fec_inner > FEC_AUTO))
- return -EINVAL;
-
- if ((p->u.qpsk.fec_inner == FEC_4_5)
- || (p->u.qpsk.fec_inner == FEC_8_9))
- return -EINVAL;
-
- switch (state->id) {
- case ID_VP310:
- // For now we will do this only for the VP310.
- // It should be better for the mt312 as well, but tunning will be slower. ACCJr 09/29/03
- ret = mt312_readreg(state, CONFIG, &config_val);
- if (ret < 0)
- return ret;
- if (p->u.qpsk.symbol_rate >= 30000000) //Note that 30MS/s should use 90MHz
- {
- if ((config_val & 0x0c) == 0x08) { //We are running 60MHz
- state->frequency = 90;
- if ((ret = mt312_initfe(fe)) < 0)
- return ret;
- }
- }
- else
- {
- if ((config_val & 0x0c) == 0x0C) { //We are running 90MHz
- state->frequency = 60;
- if ((ret = mt312_initfe(fe)) < 0)
- return ret;
- }
- }
- break;
-
- case ID_MT312:
- break;
-
- default:
- return -EINVAL;
- }
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- /* sr = (u16)(sr * 256.0 / 1000000.0) */
- sr = mt312_div(p->u.qpsk.symbol_rate * 4, 15625);
-
- /* SYM_RATE */
- buf[0] = (sr >> 8) & 0x3f;
- buf[1] = (sr >> 0) & 0xff;
-
- /* VIT_MODE */
- buf[2] = inv_tab[p->inversion] | fec_tab[p->u.qpsk.fec_inner];
-
- /* QPSK_CTRL */
- buf[3] = 0x40; /* swap I and Q before QPSK demodulation */
-
- if (p->u.qpsk.symbol_rate < 10000000)
- buf[3] |= 0x04; /* use afc mode */
-
- /* GO */
- buf[4] = 0x01;
-
- if ((ret = mt312_write(state, SYM_RATE_H, buf, sizeof(buf))) < 0)
- return ret;
-
- mt312_reset(state, 0);
-
- return 0;
-}
-
-static int mt312_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
-
- if ((ret = mt312_get_inversion(state, &p->inversion)) < 0)
- return ret;
-
- if ((ret = mt312_get_symbol_rate(state, &p->u.qpsk.symbol_rate)) < 0)
- return ret;
-
- if ((ret = mt312_get_code_rate(state, &p->u.qpsk.fec_inner)) < 0)
- return ret;
-
- return 0;
-}
-
-static int mt312_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct mt312_state* state = fe->demodulator_priv;
-
- if (enable) {
- return mt312_writereg(state, GPP_CTRL, 0x40);
- } else {
- return mt312_writereg(state, GPP_CTRL, 0x00);
- }
-}
-
-static int mt312_sleep(struct dvb_frontend* fe)
-{
- struct mt312_state *state = fe->demodulator_priv;
- int ret;
- u8 config;
-
- /* reset all registers to defaults */
- if ((ret = mt312_reset(state, 1)) < 0)
- return ret;
-
- if ((ret = mt312_readreg(state, CONFIG, &config)) < 0)
- return ret;
-
- /* enter standby */
- if ((ret = mt312_writereg(state, CONFIG, config & 0x7f)) < 0)
- return ret;
-
- return 0;
-}
-
-static int mt312_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 50;
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static void mt312_release(struct dvb_frontend* fe)
-{
- struct mt312_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops vp310_mt312_ops = {
-
- .info = {
- .name = "Zarlink ???? DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = (MT312_PLL_CLK / 1000) / 128,
- .symbol_rate_min = MT312_SYS_CLK / 128,
- .symbol_rate_max = MT312_SYS_CLK / 2,
- .caps =
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
- FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
- FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_MUTE_TS |
- FE_CAN_RECOVER
- },
-
- .release = mt312_release,
-
- .init = mt312_initfe,
- .sleep = mt312_sleep,
- .i2c_gate_ctrl = mt312_i2c_gate_ctrl,
-
- .set_frontend = mt312_set_frontend,
- .get_frontend = mt312_get_frontend,
- .get_tune_settings = mt312_get_tune_settings,
-
- .read_status = mt312_read_status,
- .read_ber = mt312_read_ber,
- .read_signal_strength = mt312_read_signal_strength,
- .read_snr = mt312_read_snr,
- .read_ucblocks = mt312_read_ucblocks,
-
- .diseqc_send_master_cmd = mt312_send_master_cmd,
- .diseqc_send_burst = mt312_send_burst,
- .set_tone = mt312_set_tone,
- .set_voltage = mt312_set_voltage,
-};
-
-struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
- struct i2c_adapter* i2c)
-{
- struct mt312_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
-
- /* check if the demod is there */
- if (mt312_readreg(state, ID, &state->id) < 0)
- goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
-
- switch (state->id) {
- case ID_VP310:
- strcpy(state->frontend.ops.info.name, "Zarlink VP310 DVB-S");
- state->frequency = 90;
- break;
- case ID_MT312:
- strcpy(state->frontend.ops.info.name, "Zarlink MT312 DVB-S");
- state->frequency = 60;
- break;
- default:
- printk (KERN_WARNING "Only Zarlink VP310/MT312 are supported chips.\n");
- goto error;
- }
-
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Zarlink VP310/MT312 DVB-S Demodulator driver");
-MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(vp310_mt312_attach);
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
deleted file mode 100644
index 666a1bd1c24..00000000000
--- a/drivers/media/dvb/frontends/mt312.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Driver for Zarlink MT312 Satellite Channel Decoder
-
- Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org>
-
- 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.
-
- References:
- http://products.zarlink.com/product_profiles/MT312.htm
- http://products.zarlink.com/product_profiles/SL1935.htm
-*/
-
-#ifndef MT312_H
-#define MT312_H
-
-#include <linux/dvb/frontend.h>
-
-struct mt312_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-};
-
-struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
- struct i2c_adapter* i2c);
-
-
-#endif // MT312_H
diff --git a/drivers/media/dvb/frontends/mt312_priv.h b/drivers/media/dvb/frontends/mt312_priv.h
deleted file mode 100644
index 5e0b95b5337..00000000000
--- a/drivers/media/dvb/frontends/mt312_priv.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- Driver for Zarlink MT312 QPSK Frontend
-
- Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org>
-
- 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.
-
-*/
-
-#ifndef _DVB_FRONTENDS_MT312_PRIV
-#define _DVB_FRONTENDS_MT312_PRIV
-
-enum mt312_reg_addr {
- QPSK_INT_H = 0,
- QPSK_INT_M = 1,
- QPSK_INT_L = 2,
- FEC_INT = 3,
- QPSK_STAT_H = 4,
- QPSK_STAT_L = 5,
- FEC_STATUS = 6,
- LNB_FREQ_H = 7,
- LNB_FREQ_L = 8,
- M_SNR_H = 9,
- M_SNR_L = 10,
- VIT_ERRCNT_H = 11,
- VIT_ERRCNT_M = 12,
- VIT_ERRCNT_L = 13,
- RS_BERCNT_H = 14,
- RS_BERCNT_M = 15,
- RS_BERCNT_L = 16,
- RS_UBC_H = 17,
- RS_UBC_L = 18,
- SIG_LEVEL = 19,
- GPP_CTRL = 20,
- RESET = 21,
- DISEQC_MODE = 22,
- SYM_RATE_H = 23,
- SYM_RATE_L = 24,
- VIT_MODE = 25,
- QPSK_CTRL = 26,
- GO = 27,
- IE_QPSK_H = 28,
- IE_QPSK_M = 29,
- IE_QPSK_L = 30,
- IE_FEC = 31,
- QPSK_STAT_EN = 32,
- FEC_STAT_EN = 33,
- SYS_CLK = 34,
- DISEQC_RATIO = 35,
- DISEQC_INSTR = 36,
- FR_LIM = 37,
- FR_OFF = 38,
- AGC_CTRL = 39,
- AGC_INIT = 40,
- AGC_REF = 41,
- AGC_MAX = 42,
- AGC_MIN = 43,
- AGC_LK_TH = 44,
- TS_AGC_LK_TH = 45,
- AGC_PWR_SET = 46,
- QPSK_MISC = 47,
- SNR_THS_LOW = 48,
- SNR_THS_HIGH = 49,
- TS_SW_RATE = 50,
- TS_SW_LIM_L = 51,
- TS_SW_LIM_H = 52,
- CS_SW_RATE_1 = 53,
- CS_SW_RATE_2 = 54,
- CS_SW_RATE_3 = 55,
- CS_SW_RATE_4 = 56,
- CS_SW_LIM = 57,
- TS_LPK = 58,
- TS_LPK_M = 59,
- TS_LPK_L = 60,
- CS_KPROP_H = 61,
- CS_KPROP_L = 62,
- CS_KINT_H = 63,
- CS_KINT_L = 64,
- QPSK_SCALE = 65,
- TLD_OUTCLK_TH = 66,
- TLD_INCLK_TH = 67,
- FLD_TH = 68,
- PLD_OUTLK3 = 69,
- PLD_OUTLK2 = 70,
- PLD_OUTLK1 = 71,
- PLD_OUTLK0 = 72,
- PLD_INLK3 = 73,
- PLD_INLK2 = 74,
- PLD_INLK1 = 75,
- PLD_INLK0 = 76,
- PLD_ACC_TIME = 77,
- SWEEP_PAR = 78,
- STARTUP_TIME = 79,
- LOSSLOCK_TH = 80,
- FEC_LOCK_TM = 81,
- LOSSLOCK_TM = 82,
- VIT_ERRPER_H = 83,
- VIT_ERRPER_M = 84,
- VIT_ERRPER_L = 85,
- VIT_SETUP = 86,
- VIT_REF0 = 87,
- VIT_REF1 = 88,
- VIT_REF2 = 89,
- VIT_REF3 = 90,
- VIT_REF4 = 91,
- VIT_REF5 = 92,
- VIT_REF6 = 93,
- VIT_MAXERR = 94,
- BA_SETUPT = 95,
- OP_CTRL = 96,
- FEC_SETUP = 97,
- PROG_SYNC = 98,
- AFC_SEAR_TH = 99,
- CSACC_DIF_TH = 100,
- QPSK_LK_CT = 101,
- QPSK_ST_CT = 102,
- MON_CTRL = 103,
- QPSK_RESET = 104,
- QPSK_TST_CT = 105,
- QPSK_TST_ST = 106,
- TEST_R = 107,
- AGC_H = 108,
- AGC_M = 109,
- AGC_L = 110,
- FREQ_ERR1_H = 111,
- FREQ_ERR1_M = 112,
- FREQ_ERR1_L = 113,
- FREQ_ERR2_H = 114,
- FREQ_ERR2_L = 115,
- SYM_RAT_OP_H = 116,
- SYM_RAT_OP_L = 117,
- DESEQC2_INT = 118,
- DISEQC2_STAT = 119,
- DISEQC2_FIFO = 120,
- DISEQC2_CTRL1 = 121,
- DISEQC2_CTRL2 = 122,
- MONITOR_H = 123,
- MONITOR_L = 124,
- TEST_MODE = 125,
- ID = 126,
- CONFIG = 127
-};
-
-enum mt312_model_id {
- ID_VP310 = 1,
- ID_MT312 = 3
-};
-
-#endif /* DVB_FRONTENDS_MT312_PRIV */
diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c
deleted file mode 100644
index 5de7376c94c..00000000000
--- a/drivers/media/dvb/frontends/mt352.c
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * Driver for Zarlink DVB-T MT352 demodulator
- *
- * Written by Holger Waechtler <holger@qanu.de>
- * and Daniel Mack <daniel@qanu.de>
- *
- * AVerMedia AVerTV DVB-T 771 support by
- * Wolfram Joost <dbox2@frokaschwei.de>
- *
- * Support for Samsung TDTC9251DH01C(M) tuner
- * Copyright (C) 2004 Antonio Mancuso <antonio.mancuso@digitaltelevision.it>
- * Amauri Celani <acelani@essegi.net>
- *
- * DVICO FusionHDTV DVB-T1 and DVICO FusionHDTV DVB-T Lite support by
- * Christopher Pascoe <c.pascoe@itee.uq.edu.au>
- *
- * 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/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "mt352_priv.h"
-#include "mt352.h"
-
-struct mt352_state {
- struct i2c_adapter* i2c;
- struct dvb_frontend frontend;
-
- /* configuration settings */
- struct mt352_config config;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "mt352: " args); \
- } while (0)
-
-static int mt352_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
-{
- struct mt352_state* state = fe->demodulator_priv;
- u8 buf[2] = { reg, val };
- struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0,
- .buf = buf, .len = 2 };
- int err = i2c_transfer(state->i2c, &msg, 1);
- if (err != 1) {
- printk("mt352_write() to reg %x failed (err = %d)!\n", reg, err);
- return err;
- }
- return 0;
-}
-
-int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen)
-{
- int err,i;
- for (i=0; i < ilen-1; i++)
- if ((err = mt352_single_write(fe,ibuf[0]+i,ibuf[i+1])))
- return err;
-
- return 0;
-}
-
-static int mt352_read_register(struct mt352_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg [] = { { .addr = state->config.demod_address,
- .flags = 0,
- .buf = b0, .len = 1 },
- { .addr = state->config.demod_address,
- .flags = I2C_M_RD,
- .buf = b1, .len = 1 } };
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2) {
- printk("%s: readreg error (reg=%d, ret==%i)\n",
- __FUNCTION__, reg, ret);
- return ret;
- }
-
- return b1[0];
-}
-
-static int mt352_sleep(struct dvb_frontend* fe)
-{
- static u8 mt352_softdown[] = { CLOCK_CTL, 0x20, 0x08 };
-
- mt352_write(fe, mt352_softdown, sizeof(mt352_softdown));
- return 0;
-}
-
-static void mt352_calc_nominal_rate(struct mt352_state* state,
- enum fe_bandwidth bandwidth,
- unsigned char *buf)
-{
- u32 adc_clock = 20480; /* 20.340 MHz */
- u32 bw,value;
-
- switch (bandwidth) {
- case BANDWIDTH_6_MHZ:
- bw = 6;
- break;
- case BANDWIDTH_7_MHZ:
- bw = 7;
- break;
- case BANDWIDTH_8_MHZ:
- default:
- bw = 8;
- break;
- }
- if (state->config.adc_clock)
- adc_clock = state->config.adc_clock;
-
- value = 64 * bw * (1<<16) / (7 * 8);
- value = value * 1000 / adc_clock;
- dprintk("%s: bw %d, adc_clock %d => 0x%x\n",
- __FUNCTION__, bw, adc_clock, value);
- buf[0] = msb(value);
- buf[1] = lsb(value);
-}
-
-static void mt352_calc_input_freq(struct mt352_state* state,
- unsigned char *buf)
-{
- int adc_clock = 20480; /* 20.480000 MHz */
- int if2 = 36167; /* 36.166667 MHz */
- int ife,value;
-
- if (state->config.adc_clock)
- adc_clock = state->config.adc_clock;
- if (state->config.if2)
- if2 = state->config.if2;
-
- ife = (2*adc_clock - if2);
- value = -16374 * ife / adc_clock;
- dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n",
- __FUNCTION__, if2, ife, adc_clock, value, value & 0x3fff);
- buf[0] = msb(value);
- buf[1] = lsb(value);
-}
-
-static int mt352_set_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- struct mt352_state* state = fe->demodulator_priv;
- unsigned char buf[13];
- static unsigned char tuner_go[] = { 0x5d, 0x01 };
- static unsigned char fsm_go[] = { 0x5e, 0x01 };
- unsigned int tps = 0;
- struct dvb_ofdm_parameters *op = &param->u.ofdm;
-
- switch (op->code_rate_HP) {
- case FEC_2_3:
- tps |= (1 << 7);
- break;
- case FEC_3_4:
- tps |= (2 << 7);
- break;
- case FEC_5_6:
- tps |= (3 << 7);
- break;
- case FEC_7_8:
- tps |= (4 << 7);
- break;
- case FEC_1_2:
- case FEC_AUTO:
- break;
- default:
- return -EINVAL;
- }
-
- switch (op->code_rate_LP) {
- case FEC_2_3:
- tps |= (1 << 4);
- break;
- case FEC_3_4:
- tps |= (2 << 4);
- break;
- case FEC_5_6:
- tps |= (3 << 4);
- break;
- case FEC_7_8:
- tps |= (4 << 4);
- break;
- case FEC_1_2:
- case FEC_AUTO:
- break;
- case FEC_NONE:
- if (op->hierarchy_information == HIERARCHY_AUTO ||
- op->hierarchy_information == HIERARCHY_NONE)
- break;
- default:
- return -EINVAL;
- }
-
- switch (op->constellation) {
- case QPSK:
- break;
- case QAM_AUTO:
- case QAM_16:
- tps |= (1 << 13);
- break;
- case QAM_64:
- tps |= (2 << 13);
- break;
- default:
- return -EINVAL;
- }
-
- switch (op->transmission_mode) {
- case TRANSMISSION_MODE_2K:
- case TRANSMISSION_MODE_AUTO:
- break;
- case TRANSMISSION_MODE_8K:
- tps |= (1 << 0);
- break;
- default:
- return -EINVAL;
- }
-
- switch (op->guard_interval) {
- case GUARD_INTERVAL_1_32:
- case GUARD_INTERVAL_AUTO:
- break;
- case GUARD_INTERVAL_1_16:
- tps |= (1 << 2);
- break;
- case GUARD_INTERVAL_1_8:
- tps |= (2 << 2);
- break;
- case GUARD_INTERVAL_1_4:
- tps |= (3 << 2);
- break;
- default:
- return -EINVAL;
- }
-
- switch (op->hierarchy_information) {
- case HIERARCHY_AUTO:
- case HIERARCHY_NONE:
- break;
- case HIERARCHY_1:
- tps |= (1 << 10);
- break;
- case HIERARCHY_2:
- tps |= (2 << 10);
- break;
- case HIERARCHY_4:
- tps |= (3 << 10);
- break;
- default:
- return -EINVAL;
- }
-
-
- buf[0] = TPS_GIVEN_1; /* TPS_GIVEN_1 and following registers */
-
- buf[1] = msb(tps); /* TPS_GIVEN_(1|0) */
- buf[2] = lsb(tps);
-
- buf[3] = 0x50; // old
-// buf[3] = 0xf4; // pinnacle
-
- mt352_calc_nominal_rate(state, op->bandwidth, buf+4);
- mt352_calc_input_freq(state, buf+6);
-
- if (state->config.no_tuner) {
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, param);
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- mt352_write(fe, buf, 8);
- mt352_write(fe, fsm_go, 2);
- } else {
- if (fe->ops.tuner_ops.calc_regs) {
- fe->ops.tuner_ops.calc_regs(fe, param, buf+8, 5);
- buf[8] <<= 1;
- mt352_write(fe, buf, sizeof(buf));
- mt352_write(fe, tuner_go, 2);
- }
- }
-
- return 0;
-}
-
-static int mt352_get_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- struct mt352_state* state = fe->demodulator_priv;
- u16 tps;
- u16 div;
- u8 trl;
- struct dvb_ofdm_parameters *op = &param->u.ofdm;
- static const u8 tps_fec_to_api[8] =
- {
- FEC_1_2,
- FEC_2_3,
- FEC_3_4,
- FEC_5_6,
- FEC_7_8,
- FEC_AUTO,
- FEC_AUTO,
- FEC_AUTO
- };
-
- if ( (mt352_read_register(state,0x00) & 0xC0) != 0xC0 )
- return -EINVAL;
-
- /* Use TPS_RECEIVED-registers, not the TPS_CURRENT-registers because
- * the mt352 sometimes works with the wrong parameters
- */
- tps = (mt352_read_register(state, TPS_RECEIVED_1) << 8) | mt352_read_register(state, TPS_RECEIVED_0);
- div = (mt352_read_register(state, CHAN_START_1) << 8) | mt352_read_register(state, CHAN_START_0);
- trl = mt352_read_register(state, TRL_NOMINAL_RATE_1);
-
- op->code_rate_HP = tps_fec_to_api[(tps >> 7) & 7];
- op->code_rate_LP = tps_fec_to_api[(tps >> 4) & 7];
-
- switch ( (tps >> 13) & 3)
- {
- case 0:
- op->constellation = QPSK;
- break;
- case 1:
- op->constellation = QAM_16;
- break;
- case 2:
- op->constellation = QAM_64;
- break;
- default:
- op->constellation = QAM_AUTO;
- break;
- }
-
- op->transmission_mode = (tps & 0x01) ? TRANSMISSION_MODE_8K : TRANSMISSION_MODE_2K;
-
- switch ( (tps >> 2) & 3)
- {
- case 0:
- op->guard_interval = GUARD_INTERVAL_1_32;
- break;
- case 1:
- op->guard_interval = GUARD_INTERVAL_1_16;
- break;
- case 2:
- op->guard_interval = GUARD_INTERVAL_1_8;
- break;
- case 3:
- op->guard_interval = GUARD_INTERVAL_1_4;
- break;
- default:
- op->guard_interval = GUARD_INTERVAL_AUTO;
- break;
- }
-
- switch ( (tps >> 10) & 7)
- {
- case 0:
- op->hierarchy_information = HIERARCHY_NONE;
- break;
- case 1:
- op->hierarchy_information = HIERARCHY_1;
- break;
- case 2:
- op->hierarchy_information = HIERARCHY_2;
- break;
- case 3:
- op->hierarchy_information = HIERARCHY_4;
- break;
- default:
- op->hierarchy_information = HIERARCHY_AUTO;
- break;
- }
-
- param->frequency = ( 500 * (div - IF_FREQUENCYx6) ) / 3 * 1000;
-
- if (trl == 0x72)
- op->bandwidth = BANDWIDTH_8_MHZ;
- else if (trl == 0x64)
- op->bandwidth = BANDWIDTH_7_MHZ;
- else
- op->bandwidth = BANDWIDTH_6_MHZ;
-
-
- if (mt352_read_register(state, STATUS_2) & 0x02)
- param->inversion = INVERSION_OFF;
- else
- param->inversion = INVERSION_ON;
-
- return 0;
-}
-
-static int mt352_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct mt352_state* state = fe->demodulator_priv;
- int s0, s1, s3;
-
- /* FIXME:
- *
- * The MT352 design manual from Zarlink states (page 46-47):
- *
- * Notes about the TUNER_GO register:
- *
- * If the Read_Tuner_Byte (bit-1) is activated, then the tuner status
- * byte is copied from the tuner to the STATUS_3 register and
- * completion of the read operation is indicated by bit-5 of the
- * INTERRUPT_3 register.
- */
-
- if ((s0 = mt352_read_register(state, STATUS_0)) < 0)
- return -EREMOTEIO;
- if ((s1 = mt352_read_register(state, STATUS_1)) < 0)
- return -EREMOTEIO;
- if ((s3 = mt352_read_register(state, STATUS_3)) < 0)
- return -EREMOTEIO;
-
- *status = 0;
- if (s0 & (1 << 4))
- *status |= FE_HAS_CARRIER;
- if (s0 & (1 << 1))
- *status |= FE_HAS_VITERBI;
- if (s0 & (1 << 5))
- *status |= FE_HAS_LOCK;
- if (s1 & (1 << 1))
- *status |= FE_HAS_SYNC;
- if (s3 & (1 << 6))
- *status |= FE_HAS_SIGNAL;
-
- if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
- (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
- *status &= ~FE_HAS_LOCK;
-
- return 0;
-}
-
-static int mt352_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct mt352_state* state = fe->demodulator_priv;
-
- *ber = (mt352_read_register (state, RS_ERR_CNT_2) << 16) |
- (mt352_read_register (state, RS_ERR_CNT_1) << 8) |
- (mt352_read_register (state, RS_ERR_CNT_0));
-
- return 0;
-}
-
-static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct mt352_state* state = fe->demodulator_priv;
-
- /* align the 12 bit AGC gain with the most significant bits */
- u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) |
- (mt352_read_register(state, AGC_GAIN_0) << 4);
-
- /* inverse of gain is signal strength */
- *strength = ~signal;
- return 0;
-}
-
-static int mt352_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct mt352_state* state = fe->demodulator_priv;
-
- u8 _snr = mt352_read_register (state, SNR);
- *snr = (_snr << 8) | _snr;
-
- return 0;
-}
-
-static int mt352_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct mt352_state* state = fe->demodulator_priv;
-
- *ucblocks = (mt352_read_register (state, RS_UBC_1) << 8) |
- (mt352_read_register (state, RS_UBC_0));
-
- return 0;
-}
-
-static int mt352_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
-{
- fe_tune_settings->min_delay_ms = 800;
- fe_tune_settings->step_size = 0;
- fe_tune_settings->max_drift = 0;
-
- return 0;
-}
-
-static int mt352_init(struct dvb_frontend* fe)
-{
- struct mt352_state* state = fe->demodulator_priv;
-
- static u8 mt352_reset_attach [] = { RESET, 0xC0 };
-
- dprintk("%s: hello\n",__FUNCTION__);
-
- if ((mt352_read_register(state, CLOCK_CTL) & 0x10) == 0 ||
- (mt352_read_register(state, CONFIG) & 0x20) == 0) {
-
- /* Do a "hard" reset */
- mt352_write(fe, mt352_reset_attach, sizeof(mt352_reset_attach));
- return state->config.demod_init(fe);
- }
-
- return 0;
-}
-
-static void mt352_release(struct dvb_frontend* fe)
-{
- struct mt352_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops mt352_ops;
-
-struct dvb_frontend* mt352_attach(const struct mt352_config* config,
- struct i2c_adapter* i2c)
-{
- struct mt352_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct mt352_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->i2c = i2c;
- memcpy(&state->config,config,sizeof(struct mt352_config));
-
- /* check if the demod is there */
- if (mt352_read_register(state, CHIP_ID) != ID_MT352) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &mt352_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops mt352_ops = {
-
- .info = {
- .name = "Zarlink MT352 DVB-T",
- .type = FE_OFDM,
- .frequency_min = 174000000,
- .frequency_max = 862000000,
- .frequency_stepsize = 166667,
- .frequency_tolerance = 0,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
- FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
- FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER |
- FE_CAN_MUTE_TS
- },
-
- .release = mt352_release,
-
- .init = mt352_init,
- .sleep = mt352_sleep,
-
- .set_frontend = mt352_set_parameters,
- .get_frontend = mt352_get_parameters,
- .get_tune_settings = mt352_get_tune_settings,
-
- .read_status = mt352_read_status,
- .read_ber = mt352_read_ber,
- .read_signal_strength = mt352_read_signal_strength,
- .read_snr = mt352_read_snr,
- .read_ucblocks = mt352_read_ucblocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Zarlink MT352 DVB-T Demodulator driver");
-MODULE_AUTHOR("Holger Waechtler, Daniel Mack, Antonio Mancuso");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(mt352_attach);
-EXPORT_SYMBOL(mt352_write);
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h
deleted file mode 100644
index 9e7ff4b8fe5..00000000000
--- a/drivers/media/dvb/frontends/mt352.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Driver for Zarlink DVB-T MT352 demodulator
- *
- * Written by Holger Waechtler <holger@qanu.de>
- * and Daniel Mack <daniel@qanu.de>
- *
- * AVerMedia AVerTV DVB-T 771 support by
- * Wolfram Joost <dbox2@frokaschwei.de>
- *
- * Support for Samsung TDTC9251DH01C(M) tuner
- * Copyright (C) 2004 Antonio Mancuso <antonio.mancuso@digitaltelevision.it>
- * Amauri Celani <acelani@essegi.net>
- *
- * DVICO FusionHDTV DVB-T1 and DVICO FusionHDTV DVB-T Lite support by
- * Christopher Pascoe <c.pascoe@itee.uq.edu.au>
- *
- * 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.=
- */
-
-#ifndef MT352_H
-#define MT352_H
-
-#include <linux/dvb/frontend.h>
-
-struct mt352_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* frequencies in kHz */
- int adc_clock; // default: 20480
- int if2; // default: 36166
-
- /* set if no pll is connected to the secondary i2c bus */
- int no_tuner;
-
- /* Initialise the demodulator and PLL. Cannot be NULL */
- int (*demod_init)(struct dvb_frontend* fe);
-};
-
-extern struct dvb_frontend* mt352_attach(const struct mt352_config* config,
- struct i2c_adapter* i2c);
-
-extern int mt352_write(struct dvb_frontend* fe, u8* ibuf, int ilen);
-
-#endif // MT352_H
diff --git a/drivers/media/dvb/frontends/mt352_priv.h b/drivers/media/dvb/frontends/mt352_priv.h
deleted file mode 100644
index 44ad0d4c8f1..00000000000
--- a/drivers/media/dvb/frontends/mt352_priv.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Driver for Zarlink DVB-T MT352 demodulator
- *
- * Written by Holger Waechtler <holger@qanu.de>
- * and Daniel Mack <daniel@qanu.de>
- *
- * AVerMedia AVerTV DVB-T 771 support by
- * Wolfram Joost <dbox2@frokaschwei.de>
- *
- * Support for Samsung TDTC9251DH01C(M) tuner
- * Copyright (C) 2004 Antonio Mancuso <antonio.mancuso@digitaltelevision.it>
- * Amauri Celani <acelani@essegi.net>
- *
- * DVICO FusionHDTV DVB-T1 and DVICO FusionHDTV DVB-T Lite support by
- * Christopher Pascoe <c.pascoe@itee.uq.edu.au>
- *
- * 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.=
- */
-
-#ifndef _MT352_PRIV_
-#define _MT352_PRIV_
-
-#define ID_MT352 0x13
-
-#define msb(x) (((x) >> 8) & 0xff)
-#define lsb(x) ((x) & 0xff)
-
-enum mt352_reg_addr {
- STATUS_0 = 0x00,
- STATUS_1 = 0x01,
- STATUS_2 = 0x02,
- STATUS_3 = 0x03,
- STATUS_4 = 0x04,
- INTERRUPT_0 = 0x05,
- INTERRUPT_1 = 0x06,
- INTERRUPT_2 = 0x07,
- INTERRUPT_3 = 0x08,
- SNR = 0x09,
- VIT_ERR_CNT_2 = 0x0A,
- VIT_ERR_CNT_1 = 0x0B,
- VIT_ERR_CNT_0 = 0x0C,
- RS_ERR_CNT_2 = 0x0D,
- RS_ERR_CNT_1 = 0x0E,
- RS_ERR_CNT_0 = 0x0F,
- RS_UBC_1 = 0x10,
- RS_UBC_0 = 0x11,
- AGC_GAIN_3 = 0x12,
- AGC_GAIN_2 = 0x13,
- AGC_GAIN_1 = 0x14,
- AGC_GAIN_0 = 0x15,
- FREQ_OFFSET_2 = 0x17,
- FREQ_OFFSET_1 = 0x18,
- FREQ_OFFSET_0 = 0x19,
- TIMING_OFFSET_1 = 0x1A,
- TIMING_OFFSET_0 = 0x1B,
- CHAN_FREQ_1 = 0x1C,
- CHAN_FREQ_0 = 0x1D,
- TPS_RECEIVED_1 = 0x1E,
- TPS_RECEIVED_0 = 0x1F,
- TPS_CURRENT_1 = 0x20,
- TPS_CURRENT_0 = 0x21,
- TPS_CELL_ID_1 = 0x22,
- TPS_CELL_ID_0 = 0x23,
- TPS_MISC_DATA_2 = 0x24,
- TPS_MISC_DATA_1 = 0x25,
- TPS_MISC_DATA_0 = 0x26,
- RESET = 0x50,
- TPS_GIVEN_1 = 0x51,
- TPS_GIVEN_0 = 0x52,
- ACQ_CTL = 0x53,
- TRL_NOMINAL_RATE_1 = 0x54,
- TRL_NOMINAL_RATE_0 = 0x55,
- INPUT_FREQ_1 = 0x56,
- INPUT_FREQ_0 = 0x57,
- TUNER_ADDR = 0x58,
- CHAN_START_1 = 0x59,
- CHAN_START_0 = 0x5A,
- CONT_1 = 0x5B,
- CONT_0 = 0x5C,
- TUNER_GO = 0x5D,
- STATUS_EN_0 = 0x5F,
- STATUS_EN_1 = 0x60,
- INTERRUPT_EN_0 = 0x61,
- INTERRUPT_EN_1 = 0x62,
- INTERRUPT_EN_2 = 0x63,
- INTERRUPT_EN_3 = 0x64,
- AGC_TARGET = 0x67,
- AGC_CTL = 0x68,
- CAPT_RANGE = 0x75,
- SNR_SELECT_1 = 0x79,
- SNR_SELECT_0 = 0x7A,
- RS_ERR_PER_1 = 0x7C,
- RS_ERR_PER_0 = 0x7D,
- CHIP_ID = 0x7F,
- CHAN_STOP_1 = 0x80,
- CHAN_STOP_0 = 0x81,
- CHAN_STEP_1 = 0x82,
- CHAN_STEP_0 = 0x83,
- FEC_LOCK_TIME = 0x85,
- OFDM_LOCK_TIME = 0x86,
- ACQ_DELAY = 0x87,
- SCAN_CTL = 0x88,
- CLOCK_CTL = 0x89,
- CONFIG = 0x8A,
- MCLK_RATIO = 0x8B,
- GPP_CTL = 0x8C,
- ADC_CTL_1 = 0x8E,
- ADC_CTL_0 = 0x8F
-};
-
-/* here we assume 1/6MHz == 166.66kHz stepsize */
-#define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
-
-#endif /* _MT352_PRIV_ */
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
deleted file mode 100644
index 87c286ee6a0..00000000000
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ /dev/null
@@ -1,1248 +0,0 @@
-/*
- * Support for NXT2002 and NXT2004 - VSB/QAM
- *
- * Copyright (C) 2005 Kirk Lapray <kirk.lapray@gmail.com>
- * Copyright (C) 2006 Michael Krufky <mkrufky@m1k.net>
- * based on nxt2002 by Taylor Jacob <rtjacob@earthlink.net>
- * and nxt2004 by Jean-Francois Thibert <jeanfrancois@sagetv.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
-*/
-
-/*
- * NOTES ABOUT THIS DRIVER
- *
- * This Linux driver supports:
- * B2C2/BBTI Technisat Air2PC - ATSC (NXT2002)
- * AverTVHD MCE A180 (NXT2004)
- * ATI HDTV Wonder (NXT2004)
- *
- * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" or
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2004" to
- * download/extract the appropriate firmware, and then copy it to
- * /usr/lib/hotplug/firmware/ or /lib/firmware/
- * (depending on configuration of firmware hotplug).
- */
-#define NXT2002_DEFAULT_FIRMWARE "dvb-fe-nxt2002.fw"
-#define NXT2004_DEFAULT_FIRMWARE "dvb-fe-nxt2004.fw"
-#define CRC_CCIT_MASK 0x1021
-
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-
-#include "dvb_frontend.h"
-#include "dvb-pll.h"
-#include "nxt200x.h"
-
-struct nxt200x_state {
-
- struct i2c_adapter* i2c;
- const struct nxt200x_config* config;
- struct dvb_frontend frontend;
-
- /* demodulator private data */
- nxt_chip_type demod_chip;
- u8 initialised:1;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "nxt200x: " args); \
- } while (0)
-
-static int i2c_writebytes (struct nxt200x_state* state, u8 addr, u8 *buf, u8 len)
-{
- int err;
- struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = len };
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- printk (KERN_WARNING "nxt200x: %s: i2c write error (addr 0x%02x, err == %i)\n",
- __FUNCTION__, addr, err);
- return -EREMOTEIO;
- }
- return 0;
-}
-
-static u8 i2c_readbytes (struct nxt200x_state* state, u8 addr, u8* buf, u8 len)
-{
- int err;
- struct i2c_msg msg = { .addr = addr, .flags = I2C_M_RD, .buf = buf, .len = len };
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- printk (KERN_WARNING "nxt200x: %s: i2c read error (addr 0x%02x, err == %i)\n",
- __FUNCTION__, addr, err);
- return -EREMOTEIO;
- }
- return 0;
-}
-
-static int nxt200x_writebytes (struct nxt200x_state* state, u8 reg, u8 *buf, u8 len)
-{
- u8 buf2 [len+1];
- int err;
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf2, .len = len + 1 };
-
- buf2[0] = reg;
- memcpy(&buf2[1], buf, len);
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- printk (KERN_WARNING "nxt200x: %s: i2c write error (addr 0x%02x, err == %i)\n",
- __FUNCTION__, state->config->demod_address, err);
- return -EREMOTEIO;
- }
- return 0;
-}
-
-static u8 nxt200x_readbytes (struct nxt200x_state* state, u8 reg, u8* buf, u8 len)
-{
- u8 reg2 [] = { reg };
-
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = reg2, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = buf, .len = len } };
-
- int err;
-
- if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) {
- printk (KERN_WARNING "nxt200x: %s: i2c read error (addr 0x%02x, err == %i)\n",
- __FUNCTION__, state->config->demod_address, err);
- return -EREMOTEIO;
- }
- return 0;
-}
-
-static u16 nxt200x_crc(u16 crc, u8 c)
-{
- u8 i;
- u16 input = (u16) c & 0xFF;
-
- input<<=8;
- for(i=0; i<8; i++) {
- if((crc^input) & 0x8000)
- crc=(crc<<1)^CRC_CCIT_MASK;
- else
- crc<<=1;
- input<<=1;
- }
- return crc;
-}
-
-static int nxt200x_writereg_multibyte (struct nxt200x_state* state, u8 reg, u8* data, u8 len)
-{
- u8 attr, len2, buf;
- dprintk("%s\n", __FUNCTION__);
-
- /* set mutli register register */
- nxt200x_writebytes(state, 0x35, &reg, 1);
-
- /* send the actual data */
- nxt200x_writebytes(state, 0x36, data, len);
-
- switch (state->demod_chip) {
- case NXT2002:
- len2 = len;
- buf = 0x02;
- break;
- case NXT2004:
- /* probably not right, but gives correct values */
- attr = 0x02;
- if (reg & 0x80) {
- attr = attr << 1;
- if (reg & 0x04)
- attr = attr >> 1;
- }
- /* set write bit */
- len2 = ((attr << 4) | 0x10) | len;
- buf = 0x80;
- break;
- default:
- return -EINVAL;
- break;
- }
-
- /* set multi register length */
- nxt200x_writebytes(state, 0x34, &len2, 1);
-
- /* toggle the multireg write bit */
- nxt200x_writebytes(state, 0x21, &buf, 1);
-
- nxt200x_readbytes(state, 0x21, &buf, 1);
-
- switch (state->demod_chip) {
- case NXT2002:
- if ((buf & 0x02) == 0)
- return 0;
- break;
- case NXT2004:
- if (buf == 0)
- return 0;
- break;
- default:
- return -EINVAL;
- break;
- }
-
- printk(KERN_WARNING "nxt200x: Error writing multireg register 0x%02X\n",reg);
-
- return 0;
-}
-
-static int nxt200x_readreg_multibyte (struct nxt200x_state* state, u8 reg, u8* data, u8 len)
-{
- int i;
- u8 buf, len2, attr;
- dprintk("%s\n", __FUNCTION__);
-
- /* set mutli register register */
- nxt200x_writebytes(state, 0x35, &reg, 1);
-
- switch (state->demod_chip) {
- case NXT2002:
- /* set multi register length */
- len2 = len & 0x80;
- nxt200x_writebytes(state, 0x34, &len2, 1);
-
- /* read the actual data */
- nxt200x_readbytes(state, reg, data, len);
- return 0;
- break;
- case NXT2004:
- /* probably not right, but gives correct values */
- attr = 0x02;
- if (reg & 0x80) {
- attr = attr << 1;
- if (reg & 0x04)
- attr = attr >> 1;
- }
-
- /* set multi register length */
- len2 = (attr << 4) | len;
- nxt200x_writebytes(state, 0x34, &len2, 1);
-
- /* toggle the multireg bit*/
- buf = 0x80;
- nxt200x_writebytes(state, 0x21, &buf, 1);
-
- /* read the actual data */
- for(i = 0; i < len; i++) {
- nxt200x_readbytes(state, 0x36 + i, &data[i], 1);
- }
- return 0;
- break;
- default:
- return -EINVAL;
- break;
- }
-}
-
-static void nxt200x_microcontroller_stop (struct nxt200x_state* state)
-{
- u8 buf, stopval, counter = 0;
- dprintk("%s\n", __FUNCTION__);
-
- /* set correct stop value */
- switch (state->demod_chip) {
- case NXT2002:
- stopval = 0x40;
- break;
- case NXT2004:
- stopval = 0x10;
- break;
- default:
- stopval = 0;
- break;
- }
-
- buf = 0x80;
- nxt200x_writebytes(state, 0x22, &buf, 1);
-
- while (counter < 20) {
- nxt200x_readbytes(state, 0x31, &buf, 1);
- if (buf & stopval)
- return;
- msleep(10);
- counter++;
- }
-
- printk(KERN_WARNING "nxt200x: Timeout waiting for nxt200x to stop. This is ok after firmware upload.\n");
- return;
-}
-
-static void nxt200x_microcontroller_start (struct nxt200x_state* state)
-{
- u8 buf;
- dprintk("%s\n", __FUNCTION__);
-
- buf = 0x00;
- nxt200x_writebytes(state, 0x22, &buf, 1);
-}
-
-static void nxt2004_microcontroller_init (struct nxt200x_state* state)
-{
- u8 buf[9];
- u8 counter = 0;
- dprintk("%s\n", __FUNCTION__);
-
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0x2b, buf, 1);
- buf[0] = 0x70;
- nxt200x_writebytes(state, 0x34, buf, 1);
- buf[0] = 0x04;
- nxt200x_writebytes(state, 0x35, buf, 1);
- buf[0] = 0x01; buf[1] = 0x23; buf[2] = 0x45; buf[3] = 0x67; buf[4] = 0x89;
- buf[5] = 0xAB; buf[6] = 0xCD; buf[7] = 0xEF; buf[8] = 0xC0;
- nxt200x_writebytes(state, 0x36, buf, 9);
- buf[0] = 0x80;
- nxt200x_writebytes(state, 0x21, buf, 1);
-
- while (counter < 20) {
- nxt200x_readbytes(state, 0x21, buf, 1);
- if (buf[0] == 0)
- return;
- msleep(10);
- counter++;
- }
-
- printk(KERN_WARNING "nxt200x: Timeout waiting for nxt2004 to init.\n");
-
- return;
-}
-
-static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
-{
- u8 buf, count = 0;
-
- dprintk("%s\n", __FUNCTION__);
-
- dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[1], data[2], data[3], data[4]);
-
- /* if NXT2004, write directly to tuner. if NXT2002, write through NXT chip.
- * direct write is required for Philips TUV1236D and ALPS TDHU2 */
- switch (state->demod_chip) {
- case NXT2004:
- if (i2c_writebytes(state, data[0], data+1, 4))
- printk(KERN_WARNING "nxt200x: error writing to tuner\n");
- /* wait until we have a lock */
- while (count < 20) {
- i2c_readbytes(state, data[0], &buf, 1);
- if (buf & 0x40)
- return 0;
- msleep(100);
- count++;
- }
- printk("nxt2004: timeout waiting for tuner lock\n");
- break;
- case NXT2002:
- /* set the i2c transfer speed to the tuner */
- buf = 0x03;
- nxt200x_writebytes(state, 0x20, &buf, 1);
-
- /* setup to transfer 4 bytes via i2c */
- buf = 0x04;
- nxt200x_writebytes(state, 0x34, &buf, 1);
-
- /* write actual tuner bytes */
- nxt200x_writebytes(state, 0x36, data+1, 4);
-
- /* set tuner i2c address */
- buf = data[0] << 1;
- nxt200x_writebytes(state, 0x35, &buf, 1);
-
- /* write UC Opmode to begin transfer */
- buf = 0x80;
- nxt200x_writebytes(state, 0x21, &buf, 1);
-
- while (count < 20) {
- nxt200x_readbytes(state, 0x21, &buf, 1);
- if ((buf & 0x80)== 0x00)
- return 0;
- msleep(100);
- count++;
- }
- printk("nxt2002: timeout error writing tuner\n");
- break;
- default:
- return -EINVAL;
- break;
- }
- return 0;
-}
-
-static void nxt200x_agc_reset(struct nxt200x_state* state)
-{
- u8 buf;
- dprintk("%s\n", __FUNCTION__);
-
- switch (state->demod_chip) {
- case NXT2002:
- buf = 0x08;
- nxt200x_writebytes(state, 0x08, &buf, 1);
- buf = 0x00;
- nxt200x_writebytes(state, 0x08, &buf, 1);
- break;
- case NXT2004:
- nxt200x_readreg_multibyte(state, 0x08, &buf, 1);
- buf = 0x08;
- nxt200x_writereg_multibyte(state, 0x08, &buf, 1);
- buf = 0x00;
- nxt200x_writereg_multibyte(state, 0x08, &buf, 1);
- break;
- default:
- break;
- }
- return;
-}
-
-static int nxt2002_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
-{
-
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 buf[3], written = 0, chunkpos = 0;
- u16 rambase, position, crc = 0;
-
- dprintk("%s\n", __FUNCTION__);
- dprintk("Firmware is %zu bytes\n", fw->size);
-
- /* Get the RAM base for this nxt2002 */
- nxt200x_readbytes(state, 0x10, buf, 1);
-
- if (buf[0] & 0x10)
- rambase = 0x1000;
- else
- rambase = 0x0000;
-
- dprintk("rambase on this nxt2002 is %04X\n", rambase);
-
- /* Hold the micro in reset while loading firmware */
- buf[0] = 0x80;
- nxt200x_writebytes(state, 0x2B, buf, 1);
-
- for (position = 0; position < fw->size; position++) {
- if (written == 0) {
- crc = 0;
- chunkpos = 0x28;
- buf[0] = ((rambase + position) >> 8);
- buf[1] = (rambase + position) & 0xFF;
- buf[2] = 0x81;
- /* write starting address */
- nxt200x_writebytes(state, 0x29, buf, 3);
- }
- written++;
- chunkpos++;
-
- if ((written % 4) == 0)
- nxt200x_writebytes(state, chunkpos, &fw->data[position-3], 4);
-
- crc = nxt200x_crc(crc, fw->data[position]);
-
- if ((written == 255) || (position+1 == fw->size)) {
- /* write remaining bytes of firmware */
- nxt200x_writebytes(state, chunkpos+4-(written %4),
- &fw->data[position-(written %4) + 1],
- written %4);
- buf[0] = crc << 8;
- buf[1] = crc & 0xFF;
-
- /* write crc */
- nxt200x_writebytes(state, 0x2C, buf, 2);
-
- /* do a read to stop things */
- nxt200x_readbytes(state, 0x2A, buf, 1);
-
- /* set transfer mode to complete */
- buf[0] = 0x80;
- nxt200x_writebytes(state, 0x2B, buf, 1);
-
- written = 0;
- }
- }
-
- return 0;
-};
-
-static int nxt2004_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
-{
-
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 buf[3];
- u16 rambase, position, crc=0;
-
- dprintk("%s\n", __FUNCTION__);
- dprintk("Firmware is %zu bytes\n", fw->size);
-
- /* set rambase */
- rambase = 0x1000;
-
- /* hold the micro in reset while loading firmware */
- buf[0] = 0x80;
- nxt200x_writebytes(state, 0x2B, buf,1);
-
- /* calculate firmware CRC */
- for (position = 0; position < fw->size; position++) {
- crc = nxt200x_crc(crc, fw->data[position]);
- }
-
- buf[0] = rambase >> 8;
- buf[1] = rambase & 0xFF;
- buf[2] = 0x81;
- /* write starting address */
- nxt200x_writebytes(state,0x29,buf,3);
-
- for (position = 0; position < fw->size;) {
- nxt200x_writebytes(state, 0x2C, &fw->data[position],
- fw->size-position > 255 ? 255 : fw->size-position);
- position += (fw->size-position > 255 ? 255 : fw->size-position);
- }
- buf[0] = crc >> 8;
- buf[1] = crc & 0xFF;
-
- dprintk("firmware crc is 0x%02X 0x%02X\n", buf[0], buf[1]);
-
- /* write crc */
- nxt200x_writebytes(state, 0x2C, buf,2);
-
- /* do a read to stop things */
- nxt200x_readbytes(state, 0x2C, buf, 1);
-
- /* set transfer mode to complete */
- buf[0] = 0x80;
- nxt200x_writebytes(state, 0x2B, buf,1);
-
- return 0;
-};
-
-static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 buf[5];
-
- /* stop the micro first */
- nxt200x_microcontroller_stop(state);
-
- if (state->demod_chip == NXT2004) {
- /* make sure demod is set to digital */
- buf[0] = 0x04;
- nxt200x_writebytes(state, 0x14, buf, 1);
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0x17, buf, 1);
- }
-
- /* get tuning information */
- if (fe->ops.tuner_ops.calc_regs) {
- fe->ops.tuner_ops.calc_regs(fe, p, buf, 5);
- }
-
- /* set additional params */
- switch (p->u.vsb.modulation) {
- case QAM_64:
- case QAM_256:
- /* Set punctured clock for QAM */
- /* This is just a guess since I am unable to test it */
- if (state->config->set_ts_params)
- state->config->set_ts_params(fe, 1);
-
- /* set input */
- if (state->config->set_pll_input)
- state->config->set_pll_input(buf, 1);
- break;
- case VSB_8:
- /* Set non-punctured clock for VSB */
- if (state->config->set_ts_params)
- state->config->set_ts_params(fe, 0);
-
- /* set input */
- if (state->config->set_pll_input)
- state->config->set_pll_input(buf, 0);
- break;
- default:
- return -EINVAL;
- break;
- }
-
- /* write frequency information */
- nxt200x_writetuner(state, buf);
-
- /* reset the agc now that tuning has been completed */
- nxt200x_agc_reset(state);
-
- /* set target power level */
- switch (p->u.vsb.modulation) {
- case QAM_64:
- case QAM_256:
- buf[0] = 0x74;
- break;
- case VSB_8:
- buf[0] = 0x70;
- break;
- default:
- return -EINVAL;
- break;
- }
- nxt200x_writebytes(state, 0x42, buf, 1);
-
- /* configure sdm */
- switch (state->demod_chip) {
- case NXT2002:
- buf[0] = 0x87;
- break;
- case NXT2004:
- buf[0] = 0x07;
- break;
- default:
- return -EINVAL;
- break;
- }
- nxt200x_writebytes(state, 0x57, buf, 1);
-
- /* write sdm1 input */
- buf[0] = 0x10;
- buf[1] = 0x00;
- switch (state->demod_chip) {
- case NXT2002:
- nxt200x_writereg_multibyte(state, 0x58, buf, 2);
- break;
- case NXT2004:
- nxt200x_writebytes(state, 0x58, buf, 2);
- break;
- default:
- return -EINVAL;
- break;
- }
-
- /* write sdmx input */
- switch (p->u.vsb.modulation) {
- case QAM_64:
- buf[0] = 0x68;
- break;
- case QAM_256:
- buf[0] = 0x64;
- break;
- case VSB_8:
- buf[0] = 0x60;
- break;
- default:
- return -EINVAL;
- break;
- }
- buf[1] = 0x00;
- switch (state->demod_chip) {
- case NXT2002:
- nxt200x_writereg_multibyte(state, 0x5C, buf, 2);
- break;
- case NXT2004:
- nxt200x_writebytes(state, 0x5C, buf, 2);
- break;
- default:
- return -EINVAL;
- break;
- }
-
- /* write adc power lpf fc */
- buf[0] = 0x05;
- nxt200x_writebytes(state, 0x43, buf, 1);
-
- if (state->demod_chip == NXT2004) {
- /* write ??? */
- buf[0] = 0x00;
- buf[1] = 0x00;
- nxt200x_writebytes(state, 0x46, buf, 2);
- }
-
- /* write accumulator2 input */
- buf[0] = 0x80;
- buf[1] = 0x00;
- switch (state->demod_chip) {
- case NXT2002:
- nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
- break;
- case NXT2004:
- nxt200x_writebytes(state, 0x4B, buf, 2);
- break;
- default:
- return -EINVAL;
- break;
- }
-
- /* write kg1 */
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0x4D, buf, 1);
-
- /* write sdm12 lpf fc */
- buf[0] = 0x44;
- nxt200x_writebytes(state, 0x55, buf, 1);
-
- /* write agc control reg */
- buf[0] = 0x04;
- nxt200x_writebytes(state, 0x41, buf, 1);
-
- if (state->demod_chip == NXT2004) {
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x24;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
-
- /* soft reset? */
- nxt200x_readreg_multibyte(state, 0x08, buf, 1);
- buf[0] = 0x10;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
- nxt200x_readreg_multibyte(state, 0x08, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
-
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x04;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x81, buf, 1);
- buf[0] = 0x80; buf[1] = 0x00; buf[2] = 0x00;
- nxt200x_writereg_multibyte(state, 0x82, buf, 3);
- nxt200x_readreg_multibyte(state, 0x88, buf, 1);
- buf[0] = 0x11;
- nxt200x_writereg_multibyte(state, 0x88, buf, 1);
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x44;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
- }
-
- /* write agc ucgp0 */
- switch (p->u.vsb.modulation) {
- case QAM_64:
- buf[0] = 0x02;
- break;
- case QAM_256:
- buf[0] = 0x03;
- break;
- case VSB_8:
- buf[0] = 0x00;
- break;
- default:
- return -EINVAL;
- break;
- }
- nxt200x_writebytes(state, 0x30, buf, 1);
-
- /* write agc control reg */
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0x41, buf, 1);
-
- /* write accumulator2 input */
- buf[0] = 0x80;
- buf[1] = 0x00;
- switch (state->demod_chip) {
- case NXT2002:
- nxt200x_writereg_multibyte(state, 0x49, buf, 2);
- nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
- break;
- case NXT2004:
- nxt200x_writebytes(state, 0x49, buf, 2);
- nxt200x_writebytes(state, 0x4B, buf, 2);
- break;
- default:
- return -EINVAL;
- break;
- }
-
- /* write agc control reg */
- buf[0] = 0x04;
- nxt200x_writebytes(state, 0x41, buf, 1);
-
- nxt200x_microcontroller_start(state);
-
- if (state->demod_chip == NXT2004) {
- nxt2004_microcontroller_init(state);
-
- /* ???? */
- buf[0] = 0xF0;
- buf[1] = 0x00;
- nxt200x_writebytes(state, 0x5C, buf, 2);
- }
-
- /* adjacent channel detection should be done here, but I don't
- have any stations with this need so I cannot test it */
-
- return 0;
-}
-
-static int nxt200x_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 lock;
- nxt200x_readbytes(state, 0x31, &lock, 1);
-
- *status = 0;
- if (lock & 0x20) {
- *status |= FE_HAS_SIGNAL;
- *status |= FE_HAS_CARRIER;
- *status |= FE_HAS_VITERBI;
- *status |= FE_HAS_SYNC;
- *status |= FE_HAS_LOCK;
- }
- return 0;
-}
-
-static int nxt200x_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 b[3];
-
- nxt200x_readreg_multibyte(state, 0xE6, b, 3);
-
- *ber = ((b[0] << 8) + b[1]) * 8;
-
- return 0;
-}
-
-static int nxt200x_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 b[2];
- u16 temp = 0;
-
- /* setup to read cluster variance */
- b[0] = 0x00;
- nxt200x_writebytes(state, 0xA1, b, 1);
-
- /* get multreg val */
- nxt200x_readreg_multibyte(state, 0xA6, b, 2);
-
- temp = (b[0] << 8) | b[1];
- *strength = ((0x7FFF - temp) & 0x0FFF) * 16;
-
- return 0;
-}
-
-static int nxt200x_read_snr(struct dvb_frontend* fe, u16* snr)
-{
-
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 b[2];
- u16 temp = 0, temp2;
- u32 snrdb = 0;
-
- /* setup to read cluster variance */
- b[0] = 0x00;
- nxt200x_writebytes(state, 0xA1, b, 1);
-
- /* get multreg val from 0xA6 */
- nxt200x_readreg_multibyte(state, 0xA6, b, 2);
-
- temp = (b[0] << 8) | b[1];
- temp2 = 0x7FFF - temp;
-
- /* snr will be in db */
- if (temp2 > 0x7F00)
- snrdb = 1000*24 + ( 1000*(30-24) * ( temp2 - 0x7F00 ) / ( 0x7FFF - 0x7F00 ) );
- else if (temp2 > 0x7EC0)
- snrdb = 1000*18 + ( 1000*(24-18) * ( temp2 - 0x7EC0 ) / ( 0x7F00 - 0x7EC0 ) );
- else if (temp2 > 0x7C00)
- snrdb = 1000*12 + ( 1000*(18-12) * ( temp2 - 0x7C00 ) / ( 0x7EC0 - 0x7C00 ) );
- else
- snrdb = 1000*0 + ( 1000*(12-0) * ( temp2 - 0 ) / ( 0x7C00 - 0 ) );
-
- /* the value reported back from the frontend will be FFFF=32db 0000=0db */
- *snr = snrdb * (0xFFFF/32000);
-
- return 0;
-}
-
-static int nxt200x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- u8 b[3];
-
- nxt200x_readreg_multibyte(state, 0xE6, b, 3);
- *ucblocks = b[2];
-
- return 0;
-}
-
-static int nxt200x_sleep(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int nxt2002_init(struct dvb_frontend* fe)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- const struct firmware *fw;
- int ret;
- u8 buf[2];
-
- /* request the firmware, this will block until someone uploads it */
- printk("nxt2002: Waiting for firmware upload (%s)...\n", NXT2002_DEFAULT_FIRMWARE);
- ret = request_firmware(&fw, NXT2002_DEFAULT_FIRMWARE, &state->i2c->dev);
- printk("nxt2002: Waiting for firmware upload(2)...\n");
- if (ret) {
- printk("nxt2002: No firmware uploaded (timeout or file not found?)\n");
- return ret;
- }
-
- ret = nxt2002_load_firmware(fe, fw);
- release_firmware(fw);
- if (ret) {
- printk("nxt2002: Writing firmware to device failed\n");
- return ret;
- }
- printk("nxt2002: Firmware upload complete\n");
-
- /* Put the micro into reset */
- nxt200x_microcontroller_stop(state);
-
- /* ensure transfer is complete */
- buf[0]=0x00;
- nxt200x_writebytes(state, 0x2B, buf, 1);
-
- /* Put the micro into reset for real this time */
- nxt200x_microcontroller_stop(state);
-
- /* soft reset everything (agc,frontend,eq,fec)*/
- buf[0] = 0x0F;
- nxt200x_writebytes(state, 0x08, buf, 1);
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0x08, buf, 1);
-
- /* write agc sdm configure */
- buf[0] = 0xF1;
- nxt200x_writebytes(state, 0x57, buf, 1);
-
- /* write mod output format */
- buf[0] = 0x20;
- nxt200x_writebytes(state, 0x09, buf, 1);
-
- /* write fec mpeg mode */
- buf[0] = 0x7E;
- buf[1] = 0x00;
- nxt200x_writebytes(state, 0xE9, buf, 2);
-
- /* write mux selection */
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0xCC, buf, 1);
-
- return 0;
-}
-
-static int nxt2004_init(struct dvb_frontend* fe)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- const struct firmware *fw;
- int ret;
- u8 buf[3];
-
- /* ??? */
- buf[0]=0x00;
- nxt200x_writebytes(state, 0x1E, buf, 1);
-
- /* request the firmware, this will block until someone uploads it */
- printk("nxt2004: Waiting for firmware upload (%s)...\n", NXT2004_DEFAULT_FIRMWARE);
- ret = request_firmware(&fw, NXT2004_DEFAULT_FIRMWARE, &state->i2c->dev);
- printk("nxt2004: Waiting for firmware upload(2)...\n");
- if (ret) {
- printk("nxt2004: No firmware uploaded (timeout or file not found?)\n");
- return ret;
- }
-
- ret = nxt2004_load_firmware(fe, fw);
- release_firmware(fw);
- if (ret) {
- printk("nxt2004: Writing firmware to device failed\n");
- return ret;
- }
- printk("nxt2004: Firmware upload complete\n");
-
- /* ensure transfer is complete */
- buf[0] = 0x01;
- nxt200x_writebytes(state, 0x19, buf, 1);
-
- nxt2004_microcontroller_init(state);
- nxt200x_microcontroller_stop(state);
- nxt200x_microcontroller_stop(state);
- nxt2004_microcontroller_init(state);
- nxt200x_microcontroller_stop(state);
-
- /* soft reset everything (agc,frontend,eq,fec)*/
- buf[0] = 0xFF;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
-
- /* write agc sdm configure */
- buf[0] = 0xD7;
- nxt200x_writebytes(state, 0x57, buf, 1);
-
- /* ???*/
- buf[0] = 0x07;
- buf[1] = 0xfe;
- nxt200x_writebytes(state, 0x35, buf, 2);
- buf[0] = 0x12;
- nxt200x_writebytes(state, 0x34, buf, 1);
- buf[0] = 0x80;
- nxt200x_writebytes(state, 0x21, buf, 1);
-
- /* ???*/
- buf[0] = 0x21;
- nxt200x_writebytes(state, 0x0A, buf, 1);
-
- /* ???*/
- buf[0] = 0x01;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
-
- /* write fec mpeg mode */
- buf[0] = 0x7E;
- buf[1] = 0x00;
- nxt200x_writebytes(state, 0xE9, buf, 2);
-
- /* write mux selection */
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0xCC, buf, 1);
-
- /* ???*/
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
-
- /* soft reset? */
- nxt200x_readreg_multibyte(state, 0x08, buf, 1);
- buf[0] = 0x10;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
- nxt200x_readreg_multibyte(state, 0x08, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
-
- /* ???*/
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x01;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x70;
- nxt200x_writereg_multibyte(state, 0x81, buf, 1);
- buf[0] = 0x31; buf[1] = 0x5E; buf[2] = 0x66;
- nxt200x_writereg_multibyte(state, 0x82, buf, 3);
-
- nxt200x_readreg_multibyte(state, 0x88, buf, 1);
- buf[0] = 0x11;
- nxt200x_writereg_multibyte(state, 0x88, buf, 1);
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x40;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
-
- nxt200x_readbytes(state, 0x10, buf, 1);
- buf[0] = 0x10;
- nxt200x_writebytes(state, 0x10, buf, 1);
- nxt200x_readbytes(state, 0x0A, buf, 1);
- buf[0] = 0x21;
- nxt200x_writebytes(state, 0x0A, buf, 1);
-
- nxt2004_microcontroller_init(state);
-
- buf[0] = 0x21;
- nxt200x_writebytes(state, 0x0A, buf, 1);
- buf[0] = 0x7E;
- nxt200x_writebytes(state, 0xE9, buf, 1);
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0xEA, buf, 1);
-
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
-
- /* soft reset? */
- nxt200x_readreg_multibyte(state, 0x08, buf, 1);
- buf[0] = 0x10;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
- nxt200x_readreg_multibyte(state, 0x08, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x08, buf, 1);
-
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x04;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x00;
- nxt200x_writereg_multibyte(state, 0x81, buf, 1);
- buf[0] = 0x80; buf[1] = 0x00; buf[2] = 0x00;
- nxt200x_writereg_multibyte(state, 0x82, buf, 3);
-
- nxt200x_readreg_multibyte(state, 0x88, buf, 1);
- buf[0] = 0x11;
- nxt200x_writereg_multibyte(state, 0x88, buf, 1);
-
- nxt200x_readreg_multibyte(state, 0x80, buf, 1);
- buf[0] = 0x44;
- nxt200x_writereg_multibyte(state, 0x80, buf, 1);
-
- /* initialize tuner */
- nxt200x_readbytes(state, 0x10, buf, 1);
- buf[0] = 0x12;
- nxt200x_writebytes(state, 0x10, buf, 1);
- buf[0] = 0x04;
- nxt200x_writebytes(state, 0x13, buf, 1);
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0x16, buf, 1);
- buf[0] = 0x04;
- nxt200x_writebytes(state, 0x14, buf, 1);
- buf[0] = 0x00;
- nxt200x_writebytes(state, 0x14, buf, 1);
- nxt200x_writebytes(state, 0x17, buf, 1);
- nxt200x_writebytes(state, 0x14, buf, 1);
- nxt200x_writebytes(state, 0x17, buf, 1);
-
- return 0;
-}
-
-static int nxt200x_init(struct dvb_frontend* fe)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- int ret = 0;
-
- if (!state->initialised) {
- switch (state->demod_chip) {
- case NXT2002:
- ret = nxt2002_init(fe);
- break;
- case NXT2004:
- ret = nxt2004_init(fe);
- break;
- default:
- return -EINVAL;
- break;
- }
- state->initialised = 1;
- }
- return ret;
-}
-
-static int nxt200x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 500;
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static void nxt200x_release(struct dvb_frontend* fe)
-{
- struct nxt200x_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops nxt200x_ops;
-
-struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
- struct i2c_adapter* i2c)
-{
- struct nxt200x_state* state = NULL;
- u8 buf [] = {0,0,0,0,0};
-
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct nxt200x_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->initialised = 0;
-
- /* read card id */
- nxt200x_readbytes(state, 0x00, buf, 5);
- dprintk("NXT info: %02X %02X %02X %02X %02X\n",
- buf[0], buf[1], buf[2], buf[3], buf[4]);
-
- /* set demod chip */
- switch (buf[0]) {
- case 0x04:
- state->demod_chip = NXT2002;
- printk("nxt200x: NXT2002 Detected\n");
- break;
- case 0x05:
- state->demod_chip = NXT2004;
- printk("nxt200x: NXT2004 Detected\n");
- break;
- default:
- goto error;
- }
-
- /* make sure demod chip is supported */
- switch (state->demod_chip) {
- case NXT2002:
- if (buf[0] != 0x04) goto error; /* device id */
- if (buf[1] != 0x02) goto error; /* fab id */
- if (buf[2] != 0x11) goto error; /* month */
- if (buf[3] != 0x20) goto error; /* year msb */
- if (buf[4] != 0x00) goto error; /* year lsb */
- break;
- case NXT2004:
- if (buf[0] != 0x05) goto error; /* device id */
- break;
- default:
- goto error;
- }
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &nxt200x_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- printk("Unknown/Unsupported NXT chip: %02X %02X %02X %02X %02X\n",
- buf[0], buf[1], buf[2], buf[3], buf[4]);
- return NULL;
-}
-
-static struct dvb_frontend_ops nxt200x_ops = {
-
- .info = {
- .name = "Nextwave NXT200X VSB/QAM frontend",
- .type = FE_ATSC,
- .frequency_min = 54000000,
- .frequency_max = 860000000,
- .frequency_stepsize = 166666, /* stepsize is just a guess */
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_8VSB | FE_CAN_QAM_64 | FE_CAN_QAM_256
- },
-
- .release = nxt200x_release,
-
- .init = nxt200x_init,
- .sleep = nxt200x_sleep,
-
- .set_frontend = nxt200x_setup_frontend_parameters,
- .get_tune_settings = nxt200x_get_tune_settings,
-
- .read_status = nxt200x_read_status,
- .read_ber = nxt200x_read_ber,
- .read_signal_strength = nxt200x_read_signal_strength,
- .read_snr = nxt200x_read_snr,
- .read_ucblocks = nxt200x_read_ucblocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("NXT200X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
-MODULE_AUTHOR("Kirk Lapray, Michael Krufky, Jean-Francois Thibert, and Taylor Jacob");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(nxt200x_attach);
-
diff --git a/drivers/media/dvb/frontends/nxt200x.h b/drivers/media/dvb/frontends/nxt200x.h
deleted file mode 100644
index 34d61735845..00000000000
--- a/drivers/media/dvb/frontends/nxt200x.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Support for NXT2002 and NXT2004 - VSB/QAM
- *
- * Copyright (C) 2005 Kirk Lapray (kirk.lapray@gmail.com)
- * based on nxt2002 by Taylor Jacob <rtjacob@earthlink.net>
- * and nxt2004 by Jean-Francois Thibert (jeanfrancois@sagetv.com)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
-*/
-
-#ifndef NXT200X_H
-#define NXT200X_H
-
-#include <linux/dvb/frontend.h>
-#include <linux/firmware.h>
-
-typedef enum nxt_chip_t {
- NXTUNDEFINED,
- NXT2002,
- NXT2004
-}nxt_chip_type;
-
-struct nxt200x_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* used to set pll input */
- int (*set_pll_input)(u8* buf, int input);
-
- /* need to set device param for start_dma */
- int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
-};
-
-extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
- struct i2c_adapter* i2c);
-
-#endif /* NXT200X_H */
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c
deleted file mode 100644
index d313d7dcf38..00000000000
--- a/drivers/media/dvb/frontends/nxt6000.c
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- NxtWave Communications - NXT6000 demodulator driver
-
- Copyright (C) 2002-2003 Florian Schirmer <jolt@tuxbox.org>
- Copyright (C) 2003 Paul Andreassen <paul@andreassen.com.au>
-
- 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/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "nxt6000_priv.h"
-#include "nxt6000.h"
-
-
-
-struct nxt6000_state {
- struct i2c_adapter* i2c;
- /* configuration settings */
- const struct nxt6000_config* config;
- struct dvb_frontend frontend;
-};
-
-static int debug = 0;
-#define dprintk if (debug) printk
-
-static int nxt6000_writereg(struct nxt6000_state* state, u8 reg, u8 data)
-{
- u8 buf[] = { reg, data };
- struct i2c_msg msg = {.addr = state->config->demod_address,.flags = 0,.buf = buf,.len = 2 };
- int ret;
-
- if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1)
- dprintk("nxt6000: nxt6000_write error (reg: 0x%02X, data: 0x%02X, ret: %d)\n", reg, data, ret);
-
- return (ret != 1) ? -EFAULT : 0;
-}
-
-static u8 nxt6000_readreg(struct nxt6000_state* state, u8 reg)
-{
- int ret;
- u8 b0[] = { reg };
- u8 b1[] = { 0 };
- struct i2c_msg msgs[] = {
- {.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 1},
- {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1}
- };
-
- ret = i2c_transfer(state->i2c, msgs, 2);
-
- if (ret != 2)
- dprintk("nxt6000: nxt6000_read error (reg: 0x%02X, ret: %d)\n", reg, ret);
-
- return b1[0];
-}
-
-static void nxt6000_reset(struct nxt6000_state* state)
-{
- u8 val;
-
- val = nxt6000_readreg(state, OFDM_COR_CTL);
-
- nxt6000_writereg(state, OFDM_COR_CTL, val & ~COREACT);
- nxt6000_writereg(state, OFDM_COR_CTL, val | COREACT);
-}
-
-static int nxt6000_set_bandwidth(struct nxt6000_state* state, fe_bandwidth_t bandwidth)
-{
- u16 nominal_rate;
- int result;
-
- switch (bandwidth) {
-
- case BANDWIDTH_6_MHZ:
- nominal_rate = 0x55B7;
- break;
-
- case BANDWIDTH_7_MHZ:
- nominal_rate = 0x6400;
- break;
-
- case BANDWIDTH_8_MHZ:
- nominal_rate = 0x7249;
- break;
-
- default:
- return -EINVAL;
- }
-
- if ((result = nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_1, nominal_rate & 0xFF)) < 0)
- return result;
-
- return nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, (nominal_rate >> 8) & 0xFF);
-}
-
-static int nxt6000_set_guard_interval(struct nxt6000_state* state, fe_guard_interval_t guard_interval)
-{
- switch (guard_interval) {
-
- case GUARD_INTERVAL_1_32:
- return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x00 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
-
- case GUARD_INTERVAL_1_16:
- return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x01 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
-
- case GUARD_INTERVAL_AUTO:
- case GUARD_INTERVAL_1_8:
- return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x02 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
-
- case GUARD_INTERVAL_1_4:
- return nxt6000_writereg(state, OFDM_COR_MODEGUARD, 0x03 | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x03));
-
- default:
- return -EINVAL;
- }
-}
-
-static int nxt6000_set_inversion(struct nxt6000_state* state, fe_spectral_inversion_t inversion)
-{
- switch (inversion) {
-
- case INVERSION_OFF:
- return nxt6000_writereg(state, OFDM_ITB_CTL, 0x00);
-
- case INVERSION_ON:
- return nxt6000_writereg(state, OFDM_ITB_CTL, ITBINV);
-
- default:
- return -EINVAL;
-
- }
-}
-
-static int nxt6000_set_transmission_mode(struct nxt6000_state* state, fe_transmit_mode_t transmission_mode)
-{
- int result;
-
- switch (transmission_mode) {
-
- case TRANSMISSION_MODE_2K:
- if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x00 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
- return result;
-
- return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x00 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
-
- case TRANSMISSION_MODE_8K:
- case TRANSMISSION_MODE_AUTO:
- if ((result = nxt6000_writereg(state, EN_DMD_RACQ, 0x02 | (nxt6000_readreg(state, EN_DMD_RACQ) & ~0x03))) < 0)
- return result;
-
- return nxt6000_writereg(state, OFDM_COR_MODEGUARD, (0x01 << 2) | (nxt6000_readreg(state, OFDM_COR_MODEGUARD) & ~0x04));
-
- default:
- return -EINVAL;
-
- }
-}
-
-static void nxt6000_setup(struct dvb_frontend* fe)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
-
- nxt6000_writereg(state, RS_COR_SYNC_PARAM, SYNC_PARAM);
- nxt6000_writereg(state, BER_CTRL, /*(1 << 2) | */ (0x01 << 1) | 0x01);
- nxt6000_writereg(state, VIT_BERTIME_2, 0x00); // BER Timer = 0x000200 * 256 = 131072 bits
- nxt6000_writereg(state, VIT_BERTIME_1, 0x02); //
- nxt6000_writereg(state, VIT_BERTIME_0, 0x00); //
- nxt6000_writereg(state, VIT_COR_INTEN, 0x98); // Enable BER interrupts
- nxt6000_writereg(state, VIT_COR_CTL, 0x82); // Enable BER measurement
- nxt6000_writereg(state, VIT_COR_CTL, VIT_COR_RESYNC | 0x02 );
- nxt6000_writereg(state, OFDM_COR_CTL, (0x01 << 5) | (nxt6000_readreg(state, OFDM_COR_CTL) & 0x0F));
- nxt6000_writereg(state, OFDM_COR_MODEGUARD, FORCEMODE8K | 0x02);
- nxt6000_writereg(state, OFDM_AGC_CTL, AGCLAST | INITIAL_AGC_BW);
- nxt6000_writereg(state, OFDM_ITB_FREQ_1, 0x06);
- nxt6000_writereg(state, OFDM_ITB_FREQ_2, 0x31);
- nxt6000_writereg(state, OFDM_CAS_CTL, (0x01 << 7) | (0x02 << 3) | 0x04);
- nxt6000_writereg(state, CAS_FREQ, 0xBB); /* CHECKME */
- nxt6000_writereg(state, OFDM_SYR_CTL, 1 << 2);
- nxt6000_writereg(state, OFDM_PPM_CTL_1, PPM256);
- nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_1, 0x49);
- nxt6000_writereg(state, OFDM_TRL_NOMINALRATE_2, 0x72);
- nxt6000_writereg(state, ANALOG_CONTROL_0, 1 << 5);
- nxt6000_writereg(state, EN_DMD_RACQ, (1 << 7) | (3 << 4) | 2);
- nxt6000_writereg(state, DIAG_CONFIG, TB_SET);
-
- if (state->config->clock_inversion)
- nxt6000_writereg(state, SUB_DIAG_MODE_SEL, CLKINVERSION);
- else
- nxt6000_writereg(state, SUB_DIAG_MODE_SEL, 0);
-
- nxt6000_writereg(state, TS_FORMAT, 0);
-}
-
-static void nxt6000_dump_status(struct nxt6000_state *state)
-{
- u8 val;
-
-/*
- printk("RS_COR_STAT: 0x%02X\n", nxt6000_readreg(fe, RS_COR_STAT));
- printk("VIT_SYNC_STATUS: 0x%02X\n", nxt6000_readreg(fe, VIT_SYNC_STATUS));
- printk("OFDM_COR_STAT: 0x%02X\n", nxt6000_readreg(fe, OFDM_COR_STAT));
- printk("OFDM_SYR_STAT: 0x%02X\n", nxt6000_readreg(fe, OFDM_SYR_STAT));
- printk("OFDM_TPS_RCVD_1: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_1));
- printk("OFDM_TPS_RCVD_2: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_2));
- printk("OFDM_TPS_RCVD_3: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_3));
- printk("OFDM_TPS_RCVD_4: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RCVD_4));
- printk("OFDM_TPS_RESERVED_1: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RESERVED_1));
- printk("OFDM_TPS_RESERVED_2: 0x%02X\n", nxt6000_readreg(fe, OFDM_TPS_RESERVED_2));
-*/
- printk("NXT6000 status:");
-
- val = nxt6000_readreg(state, RS_COR_STAT);
-
- printk(" DATA DESCR LOCK: %d,", val & 0x01);
- printk(" DATA SYNC LOCK: %d,", (val >> 1) & 0x01);
-
- val = nxt6000_readreg(state, VIT_SYNC_STATUS);
-
- printk(" VITERBI LOCK: %d,", (val >> 7) & 0x01);
-
- switch ((val >> 4) & 0x07) {
-
- case 0x00:
- printk(" VITERBI CODERATE: 1/2,");
- break;
-
- case 0x01:
- printk(" VITERBI CODERATE: 2/3,");
- break;
-
- case 0x02:
- printk(" VITERBI CODERATE: 3/4,");
- break;
-
- case 0x03:
- printk(" VITERBI CODERATE: 5/6,");
- break;
-
- case 0x04:
- printk(" VITERBI CODERATE: 7/8,");
- break;
-
- default:
- printk(" VITERBI CODERATE: Reserved,");
-
- }
-
- val = nxt6000_readreg(state, OFDM_COR_STAT);
-
- printk(" CHCTrack: %d,", (val >> 7) & 0x01);
- printk(" TPSLock: %d,", (val >> 6) & 0x01);
- printk(" SYRLock: %d,", (val >> 5) & 0x01);
- printk(" AGCLock: %d,", (val >> 4) & 0x01);
-
- switch (val & 0x0F) {
-
- case 0x00:
- printk(" CoreState: IDLE,");
- break;
-
- case 0x02:
- printk(" CoreState: WAIT_AGC,");
- break;
-
- case 0x03:
- printk(" CoreState: WAIT_SYR,");
- break;
-
- case 0x04:
- printk(" CoreState: WAIT_PPM,");
- break;
-
- case 0x01:
- printk(" CoreState: WAIT_TRL,");
- break;
-
- case 0x05:
- printk(" CoreState: WAIT_TPS,");
- break;
-
- case 0x06:
- printk(" CoreState: MONITOR_TPS,");
- break;
-
- default:
- printk(" CoreState: Reserved,");
-
- }
-
- val = nxt6000_readreg(state, OFDM_SYR_STAT);
-
- printk(" SYRLock: %d,", (val >> 4) & 0x01);
- printk(" SYRMode: %s,", (val >> 2) & 0x01 ? "8K" : "2K");
-
- switch ((val >> 4) & 0x03) {
-
- case 0x00:
- printk(" SYRGuard: 1/32,");
- break;
-
- case 0x01:
- printk(" SYRGuard: 1/16,");
- break;
-
- case 0x02:
- printk(" SYRGuard: 1/8,");
- break;
-
- case 0x03:
- printk(" SYRGuard: 1/4,");
- break;
- }
-
- val = nxt6000_readreg(state, OFDM_TPS_RCVD_3);
-
- switch ((val >> 4) & 0x07) {
-
- case 0x00:
- printk(" TPSLP: 1/2,");
- break;
-
- case 0x01:
- printk(" TPSLP: 2/3,");
- break;
-
- case 0x02:
- printk(" TPSLP: 3/4,");
- break;
-
- case 0x03:
- printk(" TPSLP: 5/6,");
- break;
-
- case 0x04:
- printk(" TPSLP: 7/8,");
- break;
-
- default:
- printk(" TPSLP: Reserved,");
-
- }
-
- switch (val & 0x07) {
-
- case 0x00:
- printk(" TPSHP: 1/2,");
- break;
-
- case 0x01:
- printk(" TPSHP: 2/3,");
- break;
-
- case 0x02:
- printk(" TPSHP: 3/4,");
- break;
-
- case 0x03:
- printk(" TPSHP: 5/6,");
- break;
-
- case 0x04:
- printk(" TPSHP: 7/8,");
- break;
-
- default:
- printk(" TPSHP: Reserved,");
-
- }
-
- val = nxt6000_readreg(state, OFDM_TPS_RCVD_4);
-
- printk(" TPSMode: %s,", val & 0x01 ? "8K" : "2K");
-
- switch ((val >> 4) & 0x03) {
-
- case 0x00:
- printk(" TPSGuard: 1/32,");
- break;
-
- case 0x01:
- printk(" TPSGuard: 1/16,");
- break;
-
- case 0x02:
- printk(" TPSGuard: 1/8,");
- break;
-
- case 0x03:
- printk(" TPSGuard: 1/4,");
- break;
-
- }
-
- /* Strange magic required to gain access to RF_AGC_STATUS */
- nxt6000_readreg(state, RF_AGC_VAL_1);
- val = nxt6000_readreg(state, RF_AGC_STATUS);
- val = nxt6000_readreg(state, RF_AGC_STATUS);
-
- printk(" RF AGC LOCK: %d,", (val >> 4) & 0x01);
- printk("\n");
-}
-
-static int nxt6000_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- u8 core_status;
- struct nxt6000_state* state = fe->demodulator_priv;
-
- *status = 0;
-
- core_status = nxt6000_readreg(state, OFDM_COR_STAT);
-
- if (core_status & AGCLOCKED)
- *status |= FE_HAS_SIGNAL;
-
- if (nxt6000_readreg(state, OFDM_SYR_STAT) & GI14_SYR_LOCK)
- *status |= FE_HAS_CARRIER;
-
- if (nxt6000_readreg(state, VIT_SYNC_STATUS) & VITINSYNC)
- *status |= FE_HAS_VITERBI;
-
- if (nxt6000_readreg(state, RS_COR_STAT) & RSCORESTATUS)
- *status |= FE_HAS_SYNC;
-
- if ((core_status & TPSLOCKED) && (*status == (FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)))
- *status |= FE_HAS_LOCK;
-
- if (debug)
- nxt6000_dump_status(state);
-
- return 0;
-}
-
-static int nxt6000_init(struct dvb_frontend* fe)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
-
- nxt6000_reset(state);
- nxt6000_setup(fe);
-
- return 0;
-}
-
-static int nxt6000_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *param)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
- int result;
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, param);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- if ((result = nxt6000_set_bandwidth(state, param->u.ofdm.bandwidth)) < 0)
- return result;
- if ((result = nxt6000_set_guard_interval(state, param->u.ofdm.guard_interval)) < 0)
- return result;
- if ((result = nxt6000_set_transmission_mode(state, param->u.ofdm.transmission_mode)) < 0)
- return result;
- if ((result = nxt6000_set_inversion(state, param->inversion)) < 0)
- return result;
-
- msleep(500);
- return 0;
-}
-
-static void nxt6000_release(struct dvb_frontend* fe)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static int nxt6000_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
-
- *snr = nxt6000_readreg( state, OFDM_CHC_SNR) / 8;
-
- return 0;
-}
-
-static int nxt6000_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
-
- nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18 );
-
- *ber = (nxt6000_readreg( state, VIT_BER_1 ) << 8 ) |
- nxt6000_readreg( state, VIT_BER_0 );
-
- nxt6000_writereg( state, VIT_COR_INTSTAT, 0x18); // Clear BER Done interrupts
-
- return 0;
-}
-
-static int nxt6000_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
-
- *signal_strength = (short) (511 -
- (nxt6000_readreg(state, AGC_GAIN_1) +
- ((nxt6000_readreg(state, AGC_GAIN_2) & 0x03) << 8)));
-
- return 0;
-}
-
-static int nxt6000_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune)
-{
- tune->min_delay_ms = 500;
- return 0;
-}
-
-static int nxt6000_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct nxt6000_state* state = fe->demodulator_priv;
-
- if (enable) {
- return nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x01);
- } else {
- return nxt6000_writereg(state, ENABLE_TUNER_IIC, 0x00);
- }
-}
-
-static struct dvb_frontend_ops nxt6000_ops;
-
-struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
- struct i2c_adapter* i2c)
-{
- struct nxt6000_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
-
- /* check if the demod is there */
- if (nxt6000_readreg(state, OFDM_MSC_REV) != NXT6000ASICDEVICE) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &nxt6000_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops nxt6000_ops = {
-
- .info = {
- .name = "NxtWave NXT6000 DVB-T",
- .type = FE_OFDM,
- .frequency_min = 0,
- .frequency_max = 863250000,
- .frequency_stepsize = 62500,
- /*.frequency_tolerance = *//* FIXME: 12% of SR */
- .symbol_rate_min = 0, /* FIXME */
- .symbol_rate_max = 9360000, /* FIXME */
- .symbol_rate_tolerance = 4000,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
- FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
- FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_HIERARCHY_AUTO,
- },
-
- .release = nxt6000_release,
-
- .init = nxt6000_init,
- .i2c_gate_ctrl = nxt6000_i2c_gate_ctrl,
-
- .get_tune_settings = nxt6000_fe_get_tune_settings,
-
- .set_frontend = nxt6000_set_frontend,
-
- .read_status = nxt6000_read_status,
- .read_ber = nxt6000_read_ber,
- .read_signal_strength = nxt6000_read_signal_strength,
- .read_snr = nxt6000_read_snr,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("NxtWave NXT6000 DVB-T demodulator driver");
-MODULE_AUTHOR("Florian Schirmer");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(nxt6000_attach);
diff --git a/drivers/media/dvb/frontends/nxt6000.h b/drivers/media/dvb/frontends/nxt6000.h
deleted file mode 100644
index 117031d1170..00000000000
--- a/drivers/media/dvb/frontends/nxt6000.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- NxtWave Communications - NXT6000 demodulator driver
-
- Copyright (C) 2002-2003 Florian Schirmer <jolt@tuxbox.org>
- Copyright (C) 2003 Paul Andreassen <paul@andreassen.com.au>
-
- 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.
-*/
-
-#ifndef NXT6000_H
-#define NXT6000_H
-
-#include <linux/dvb/frontend.h>
-
-struct nxt6000_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* should clock inversion be used? */
- u8 clock_inversion:1;
-};
-
-extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
- struct i2c_adapter* i2c);
-
-#endif // NXT6000_H
diff --git a/drivers/media/dvb/frontends/nxt6000_priv.h b/drivers/media/dvb/frontends/nxt6000_priv.h
deleted file mode 100644
index 0422e580038..00000000000
--- a/drivers/media/dvb/frontends/nxt6000_priv.h
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Public Include File for DRV6000 users
- * (ie. NxtWave Communications - NXT6000 demodulator driver)
- *
- * Copyright (C) 2001 NxtWave Communications, Inc.
- *
- */
-
-/* Nxt6000 Register Addresses and Bit Masks */
-
-/* Maximum Register Number */
-#define MAXNXT6000REG (0x9A)
-
-/* 0x1B A_VIT_BER_0 aka 0x3A */
-#define A_VIT_BER_0 (0x1B)
-
-/* 0x1D A_VIT_BER_TIMER_0 aka 0x38 */
-#define A_VIT_BER_TIMER_0 (0x1D)
-
-/* 0x21 RS_COR_STAT */
-#define RS_COR_STAT (0x21)
-#define RSCORESTATUS (0x03)
-
-/* 0x22 RS_COR_INTEN */
-#define RS_COR_INTEN (0x22)
-
-/* 0x23 RS_COR_INSTAT */
-#define RS_COR_INSTAT (0x23)
-#define INSTAT_ERROR (0x04)
-#define LOCK_LOSS_BITS (0x03)
-
-/* 0x24 RS_COR_SYNC_PARAM */
-#define RS_COR_SYNC_PARAM (0x24)
-#define SYNC_PARAM (0x03)
-
-/* 0x25 BER_CTRL */
-#define BER_CTRL (0x25)
-#define BER_ENABLE (0x02)
-#define BER_RESET (0x01)
-
-/* 0x26 BER_PAY */
-#define BER_PAY (0x26)
-
-/* 0x27 BER_PKT_L */
-#define BER_PKT_L (0x27)
-#define BER_PKTOVERFLOW (0x80)
-
-/* 0x30 VIT_COR_CTL */
-#define VIT_COR_CTL (0x30)
-#define BER_CONTROL (0x02)
-#define VIT_COR_MASK (0x82)
-#define VIT_COR_RESYNC (0x80)
-
-
-/* 0x32 VIT_SYNC_STATUS */
-#define VIT_SYNC_STATUS (0x32)
-#define VITINSYNC (0x80)
-
-/* 0x33 VIT_COR_INTEN */
-#define VIT_COR_INTEN (0x33)
-#define GLOBAL_ENABLE (0x80)
-
-/* 0x34 VIT_COR_INTSTAT */
-#define VIT_COR_INTSTAT (0x34)
-#define BER_DONE (0x08)
-#define BER_OVERFLOW (0x10)
-
-/* 0x38 VIT_BERTIME_2 */
-#define VIT_BERTIME_2 (0x38)
-
-/* 0x39 VIT_BERTIME_1 */
-#define VIT_BERTIME_1 (0x39)
-
-/* 0x3A VIT_BERTIME_0 */
-#define VIT_BERTIME_0 (0x3a)
-
- /* 0x38 OFDM_BERTimer *//* Use the alias registers */
-#define A_VIT_BER_TIMER_0 (0x1D)
-
- /* 0x3A VIT_BER_TIMER_0 *//* Use the alias registers */
-#define A_VIT_BER_0 (0x1B)
-
-/* 0x3B VIT_BER_1 */
-#define VIT_BER_1 (0x3b)
-
-/* 0x3C VIT_BER_0 */
-#define VIT_BER_0 (0x3c)
-
-/* 0x40 OFDM_COR_CTL */
-#define OFDM_COR_CTL (0x40)
-#define COREACT (0x20)
-#define HOLDSM (0x10)
-#define WAIT_AGC (0x02)
-#define WAIT_SYR (0x03)
-
-/* 0x41 OFDM_COR_STAT */
-#define OFDM_COR_STAT (0x41)
-#define COR_STATUS (0x0F)
-#define MONITOR_TPS (0x06)
-#define TPSLOCKED (0x40)
-#define AGCLOCKED (0x10)
-
-/* 0x42 OFDM_COR_INTEN */
-#define OFDM_COR_INTEN (0x42)
-#define TPSRCVBAD (0x04)
-#define TPSRCVCHANGED (0x02)
-#define TPSRCVUPDATE (0x01)
-
-/* 0x43 OFDM_COR_INSTAT */
-#define OFDM_COR_INSTAT (0x43)
-
-/* 0x44 OFDM_COR_MODEGUARD */
-#define OFDM_COR_MODEGUARD (0x44)
-#define FORCEMODE (0x08)
-#define FORCEMODE8K (0x04)
-
-/* 0x45 OFDM_AGC_CTL */
-#define OFDM_AGC_CTL (0x45)
-#define INITIAL_AGC_BW (0x08)
-#define AGCNEG (0x02)
-#define AGCLAST (0x10)
-
-/* 0x48 OFDM_AGC_TARGET */
-#define OFDM_AGC_TARGET (0x48)
-#define OFDM_AGC_TARGET_DEFAULT (0x28)
-#define OFDM_AGC_TARGET_IMPULSE (0x38)
-
-/* 0x49 OFDM_AGC_GAIN_1 */
-#define OFDM_AGC_GAIN_1 (0x49)
-
-/* 0x4B OFDM_ITB_CTL */
-#define OFDM_ITB_CTL (0x4B)
-#define ITBINV (0x01)
-
-/* 0x49 AGC_GAIN_1 */
-#define AGC_GAIN_1 (0x49)
-
-/* 0x4A AGC_GAIN_2 */
-#define AGC_GAIN_2 (0x4A)
-
-/* 0x4C OFDM_ITB_FREQ_1 */
-#define OFDM_ITB_FREQ_1 (0x4C)
-
-/* 0x4D OFDM_ITB_FREQ_2 */
-#define OFDM_ITB_FREQ_2 (0x4D)
-
-/* 0x4E OFDM_CAS_CTL */
-#define OFDM_CAS_CTL (0x4E)
-#define ACSDIS (0x40)
-#define CCSEN (0x80)
-
-/* 0x4F CAS_FREQ */
-#define CAS_FREQ (0x4F)
-
-/* 0x51 OFDM_SYR_CTL */
-#define OFDM_SYR_CTL (0x51)
-#define SIXTH_ENABLE (0x80)
-#define SYR_TRACKING_DISABLE (0x01)
-
-/* 0x52 OFDM_SYR_STAT */
-#define OFDM_SYR_STAT (0x52)
-#define GI14_2K_SYR_LOCK (0x13)
-#define GI14_8K_SYR_LOCK (0x17)
-#define GI14_SYR_LOCK (0x10)
-
-/* 0x55 OFDM_SYR_OFFSET_1 */
-#define OFDM_SYR_OFFSET_1 (0x55)
-
-/* 0x56 OFDM_SYR_OFFSET_2 */
-#define OFDM_SYR_OFFSET_2 (0x56)
-
-/* 0x58 OFDM_SCR_CTL */
-#define OFDM_SCR_CTL (0x58)
-#define SYR_ADJ_DECAY_MASK (0x70)
-#define SYR_ADJ_DECAY (0x30)
-
-/* 0x59 OFDM_PPM_CTL_1 */
-#define OFDM_PPM_CTL_1 (0x59)
-#define PPMMAX_MASK (0x30)
-#define PPM256 (0x30)
-
-/* 0x5B OFDM_TRL_NOMINALRATE_1 */
-#define OFDM_TRL_NOMINALRATE_1 (0x5B)
-
-/* 0x5C OFDM_TRL_NOMINALRATE_2 */
-#define OFDM_TRL_NOMINALRATE_2 (0x5C)
-
-/* 0x5D OFDM_TRL_TIME_1 */
-#define OFDM_TRL_TIME_1 (0x5D)
-
-/* 0x60 OFDM_CRL_FREQ_1 */
-#define OFDM_CRL_FREQ_1 (0x60)
-
-/* 0x63 OFDM_CHC_CTL_1 */
-#define OFDM_CHC_CTL_1 (0x63)
-#define MANMEAN1 (0xF0);
-#define CHCFIR (0x01)
-
-/* 0x64 OFDM_CHC_SNR */
-#define OFDM_CHC_SNR (0x64)
-
-/* 0x65 OFDM_BDI_CTL */
-#define OFDM_BDI_CTL (0x65)
-#define LP_SELECT (0x02)
-
-/* 0x67 OFDM_TPS_RCVD_1 */
-#define OFDM_TPS_RCVD_1 (0x67)
-#define TPSFRAME (0x03)
-
-/* 0x68 OFDM_TPS_RCVD_2 */
-#define OFDM_TPS_RCVD_2 (0x68)
-
-/* 0x69 OFDM_TPS_RCVD_3 */
-#define OFDM_TPS_RCVD_3 (0x69)
-
-/* 0x6A OFDM_TPS_RCVD_4 */
-#define OFDM_TPS_RCVD_4 (0x6A)
-
-/* 0x6B OFDM_TPS_RESERVED_1 */
-#define OFDM_TPS_RESERVED_1 (0x6B)
-
-/* 0x6C OFDM_TPS_RESERVED_2 */
-#define OFDM_TPS_RESERVED_2 (0x6C)
-
-/* 0x73 OFDM_MSC_REV */
-#define OFDM_MSC_REV (0x73)
-
-/* 0x76 OFDM_SNR_CARRIER_2 */
-#define OFDM_SNR_CARRIER_2 (0x76)
-#define MEAN_MASK (0x80)
-#define MEANBIT (0x80)
-
-/* 0x80 ANALOG_CONTROL_0 */
-#define ANALOG_CONTROL_0 (0x80)
-#define POWER_DOWN_ADC (0x40)
-
-/* 0x81 ENABLE_TUNER_IIC */
-#define ENABLE_TUNER_IIC (0x81)
-#define ENABLE_TUNER_BIT (0x01)
-
-/* 0x82 EN_DMD_RACQ */
-#define EN_DMD_RACQ (0x82)
-#define EN_DMD_RACQ_REG_VAL (0x81)
-#define EN_DMD_RACQ_REG_VAL_14 (0x01)
-
-/* 0x84 SNR_COMMAND */
-#define SNR_COMMAND (0x84)
-#define SNRStat (0x80)
-
-/* 0x85 SNRCARRIERNUMBER_LSB */
-#define SNRCARRIERNUMBER_LSB (0x85)
-
-/* 0x87 SNRMINTHRESHOLD_LSB */
-#define SNRMINTHRESHOLD_LSB (0x87)
-
-/* 0x89 SNR_PER_CARRIER_LSB */
-#define SNR_PER_CARRIER_LSB (0x89)
-
-/* 0x8B SNRBELOWTHRESHOLD_LSB */
-#define SNRBELOWTHRESHOLD_LSB (0x8B)
-
-/* 0x91 RF_AGC_VAL_1 */
-#define RF_AGC_VAL_1 (0x91)
-
-/* 0x92 RF_AGC_STATUS */
-#define RF_AGC_STATUS (0x92)
-
-/* 0x98 DIAG_CONFIG */
-#define DIAG_CONFIG (0x98)
-#define DIAG_MASK (0x70)
-#define TB_SET (0x10)
-#define TRAN_SELECT (0x07)
-#define SERIAL_SELECT (0x01)
-
-/* 0x99 SUB_DIAG_MODE_SEL */
-#define SUB_DIAG_MODE_SEL (0x99)
-#define CLKINVERSION (0x01)
-
-/* 0x9A TS_FORMAT */
-#define TS_FORMAT (0x9A)
-#define ERROR_SENSE (0x08)
-#define VALID_SENSE (0x04)
-#define SYNC_SENSE (0x02)
-#define GATED_CLOCK (0x01)
-
-#define NXT6000ASICDEVICE (0x0b)
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c
deleted file mode 100644
index d20ab30c1e8..00000000000
--- a/drivers/media/dvb/frontends/or51132.c
+++ /dev/null
@@ -1,676 +0,0 @@
-/*
- * Support for OR51132 (pcHDTV HD-3000) - VSB/QAM
- *
- * Copyright (C) 2005 Kirk Lapray <kirk_lapray@bigfoot.com>
- *
- * Based on code from Jack Kelliher (kelliher@xmission.com)
- * Copyright (C) 2002 & pcHDTV, 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.
- *
- * 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.
- *
-*/
-
-/*
- * This driver needs two external firmware files. Please copy
- * "dvb-fe-or51132-vsb.fw" and "dvb-fe-or51132-qam.fw" to
- * /usr/lib/hotplug/firmware/ or /lib/firmware/
- * (depending on configuration of firmware hotplug).
- */
-#define OR51132_VSB_FIRMWARE "dvb-fe-or51132-vsb.fw"
-#define OR51132_QAM_FIRMWARE "dvb-fe-or51132-qam.fw"
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <asm/byteorder.h>
-
-#include "dvb_frontend.h"
-#include "dvb-pll.h"
-#include "or51132.h"
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "or51132: " args); \
- } while (0)
-
-
-struct or51132_state
-{
- struct i2c_adapter* i2c;
-
- /* Configuration settings */
- const struct or51132_config* config;
-
- struct dvb_frontend frontend;
-
- /* Demodulator private data */
- fe_modulation_t current_modulation;
-
- /* Tuner private data */
- u32 current_frequency;
-};
-
-static int i2c_writebytes (struct or51132_state* state, u8 reg, u8 *buf, int len)
-{
- int err;
- struct i2c_msg msg;
- msg.addr = reg;
- msg.flags = 0;
- msg.len = len;
- msg.buf = buf;
-
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "or51132: i2c_writebytes error (addr %02x, err == %i)\n", reg, err);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static u8 i2c_readbytes (struct or51132_state* state, u8 reg, u8* buf, int len)
-{
- int err;
- struct i2c_msg msg;
- msg.addr = reg;
- msg.flags = I2C_M_RD;
- msg.len = len;
- msg.buf = buf;
-
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "or51132: i2c_readbytes error (addr %02x, err == %i)\n", reg, err);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
-{
- struct or51132_state* state = fe->demodulator_priv;
- static u8 run_buf[] = {0x7F,0x01};
- u8 rec_buf[8];
- u8 cmd_buf[3];
- u32 firmwareAsize, firmwareBsize;
- int i,ret;
-
- dprintk("Firmware is %Zd bytes\n",fw->size);
-
- /* Get size of firmware A and B */
- firmwareAsize = le32_to_cpu(*((u32*)fw->data));
- dprintk("FirmwareA is %i bytes\n",firmwareAsize);
- firmwareBsize = le32_to_cpu(*((u32*)(fw->data+4)));
- dprintk("FirmwareB is %i bytes\n",firmwareBsize);
-
- /* Upload firmware */
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- &fw->data[8],firmwareAsize))) {
- printk(KERN_WARNING "or51132: load_firmware error 1\n");
- return ret;
- }
- msleep(1); /* 1ms */
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- &fw->data[8+firmwareAsize],firmwareBsize))) {
- printk(KERN_WARNING "or51132: load_firmware error 2\n");
- return ret;
- }
- msleep(1); /* 1ms */
-
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- run_buf,2))) {
- printk(KERN_WARNING "or51132: load_firmware error 3\n");
- return ret;
- }
-
- /* Wait at least 5 msec */
- msleep(20); /* 10ms */
-
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- run_buf,2))) {
- printk(KERN_WARNING "or51132: load_firmware error 4\n");
- return ret;
- }
-
- /* 50ms for operation to begin */
- msleep(50);
-
- /* Read back ucode version to besure we loaded correctly and are really up and running */
- /* Get uCode version */
- cmd_buf[0] = 0x10;
- cmd_buf[1] = 0x10;
- cmd_buf[2] = 0x00;
- msleep(20); /* 20ms */
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- cmd_buf,3))) {
- printk(KERN_WARNING "or51132: load_firmware error a\n");
- return ret;
- }
-
- cmd_buf[0] = 0x04;
- cmd_buf[1] = 0x17;
- msleep(20); /* 20ms */
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- cmd_buf,2))) {
- printk(KERN_WARNING "or51132: load_firmware error b\n");
- return ret;
- }
-
- cmd_buf[0] = 0x00;
- cmd_buf[1] = 0x00;
- msleep(20); /* 20ms */
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- cmd_buf,2))) {
- printk(KERN_WARNING "or51132: load_firmware error c\n");
- return ret;
- }
-
- for(i=0;i<4;i++) {
- msleep(20); /* 20ms */
- /* Once upon a time, this command might have had something
- to do with getting the firmware version, but it's
- not used anymore:
- {0x04,0x00,0x30,0x00,i+1} */
- /* Read 8 bytes, two bytes at a time */
- if ((ret = i2c_readbytes(state,state->config->demod_address,
- &rec_buf[i*2],2))) {
- printk(KERN_WARNING
- "or51132: load_firmware error d - %d\n",i);
- return ret;
- }
- }
-
- printk(KERN_WARNING
- "or51132: Version: %02X%02X%02X%02X-%02X%02X%02X%02X (%02X%01X-%01X-%02X%01X-%01X)\n",
- rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
- rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6],
- rec_buf[3],rec_buf[2]>>4,rec_buf[2]&0x0f,
- rec_buf[5],rec_buf[4]>>4,rec_buf[4]&0x0f);
-
- cmd_buf[0] = 0x10;
- cmd_buf[1] = 0x00;
- cmd_buf[2] = 0x00;
- msleep(20); /* 20ms */
- if ((ret = i2c_writebytes(state,state->config->demod_address,
- cmd_buf,3))) {
- printk(KERN_WARNING "or51132: load_firmware error e\n");
- return ret;
- }
- return 0;
-};
-
-static int or51132_init(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int or51132_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- *ber = 0;
- return 0;
-}
-
-static int or51132_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- *ucblocks = 0;
- return 0;
-}
-
-static int or51132_sleep(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int or51132_setmode(struct dvb_frontend* fe)
-{
- struct or51132_state* state = fe->demodulator_priv;
- unsigned char cmd_buf[3];
-
- dprintk("setmode %d\n",(int)state->current_modulation);
- /* set operation mode in Receiver 1 register; */
- cmd_buf[0] = 0x04;
- cmd_buf[1] = 0x01;
- switch (state->current_modulation) {
- case QAM_256:
- case QAM_64:
- case QAM_AUTO:
- /* Auto-deinterleave; MPEG ser, MPEG2tr, phase noise-high*/
- cmd_buf[2] = 0x5F;
- break;
- case VSB_8:
- /* Auto CH, Auto NTSC rej, MPEGser, MPEG2tr, phase noise-high*/
- cmd_buf[2] = 0x50;
- break;
- default:
- printk("setmode:Modulation set to unsupported value\n");
- };
- if (i2c_writebytes(state,state->config->demod_address,
- cmd_buf,3)) {
- printk(KERN_WARNING "or51132: set_mode error 1\n");
- return -1;
- }
- dprintk("or51132: set #1 to %02x\n", cmd_buf[2]);
-
- /* Set operation mode in Receiver 6 register */
- cmd_buf[0] = 0x1C;
- switch (state->current_modulation) {
- case QAM_AUTO:
- /* REC MODE Normal Carrier Lock */
- cmd_buf[1] = 0x00;
- /* Channel MODE Auto QAM64/256 */
- cmd_buf[2] = 0x4f;
- break;
- case QAM_256:
- /* REC MODE Normal Carrier Lock */
- cmd_buf[1] = 0x00;
- /* Channel MODE QAM256 */
- cmd_buf[2] = 0x45;
- break;
- case QAM_64:
- /* REC MODE Normal Carrier Lock */
- cmd_buf[1] = 0x00;
- /* Channel MODE QAM64 */
- cmd_buf[2] = 0x43;
- break;
- case VSB_8:
- /* REC MODE inv IF spectrum, Normal */
- cmd_buf[1] = 0x03;
- /* Channel MODE ATSC/VSB8 */
- cmd_buf[2] = 0x06;
- break;
- default:
- printk("setmode: Modulation set to unsupported value\n");
- };
- msleep(20); /* 20ms */
- if (i2c_writebytes(state,state->config->demod_address,
- cmd_buf,3)) {
- printk(KERN_WARNING "or51132: set_mode error 2\n");
- return -1;
- }
- dprintk("or51132: set #6 to 0x%02x%02x\n", cmd_buf[1], cmd_buf[2]);
-
- return 0;
-}
-
-/* Some modulations use the same firmware. This classifies modulations
- by the firmware they use. */
-#define MOD_FWCLASS_UNKNOWN 0
-#define MOD_FWCLASS_VSB 1
-#define MOD_FWCLASS_QAM 2
-static int modulation_fw_class(fe_modulation_t modulation)
-{
- switch(modulation) {
- case VSB_8:
- return MOD_FWCLASS_VSB;
- case QAM_AUTO:
- case QAM_64:
- case QAM_256:
- return MOD_FWCLASS_QAM;
- default:
- return MOD_FWCLASS_UNKNOWN;
- }
-}
-
-static int or51132_set_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- int ret;
- struct or51132_state* state = fe->demodulator_priv;
- const struct firmware *fw;
- const char *fwname;
- int clock_mode;
-
- /* Upload new firmware only if we need a different one */
- if (modulation_fw_class(state->current_modulation) !=
- modulation_fw_class(param->u.vsb.modulation)) {
- switch(modulation_fw_class(param->u.vsb.modulation)) {
- case MOD_FWCLASS_VSB:
- dprintk("set_parameters VSB MODE\n");
- fwname = OR51132_VSB_FIRMWARE;
-
- /* Set non-punctured clock for VSB */
- clock_mode = 0;
- break;
- case MOD_FWCLASS_QAM:
- dprintk("set_parameters QAM MODE\n");
- fwname = OR51132_QAM_FIRMWARE;
-
- /* Set punctured clock for QAM */
- clock_mode = 1;
- break;
- default:
- printk("or51132: Modulation type(%d) UNSUPPORTED\n",
- param->u.vsb.modulation);
- return -1;
- }
- printk("or51132: Waiting for firmware upload(%s)...\n",
- fwname);
- ret = request_firmware(&fw, fwname, &state->i2c->dev);
- if (ret) {
- printk(KERN_WARNING "or51132: No firmware up"
- "loaded(timeout or file not found?)\n");
- return ret;
- }
- ret = or51132_load_firmware(fe, fw);
- release_firmware(fw);
- if (ret) {
- printk(KERN_WARNING "or51132: Writing firmware to "
- "device failed!\n");
- return ret;
- }
- printk("or51132: Firmware upload complete.\n");
- state->config->set_ts_params(fe, clock_mode);
- }
- /* Change only if we are actually changing the modulation */
- if (state->current_modulation != param->u.vsb.modulation) {
- state->current_modulation = param->u.vsb.modulation;
- or51132_setmode(fe);
- }
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, param);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- /* Set to current mode */
- or51132_setmode(fe);
-
- /* Update current frequency */
- state->current_frequency = param->frequency;
- return 0;
-}
-
-static int or51132_get_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- struct or51132_state* state = fe->demodulator_priv;
- u8 buf[2];
-
- /* Receiver Status */
- buf[0]=0x04;
- buf[1]=0x00;
- msleep(30); /* 30ms */
- if (i2c_writebytes(state,state->config->demod_address,buf,2)) {
- printk(KERN_WARNING "or51132: get_parameters write error\n");
- return -EREMOTEIO;
- }
- msleep(30); /* 30ms */
- if (i2c_readbytes(state,state->config->demod_address,buf,2)) {
- printk(KERN_WARNING "or51132: get_parameters read error\n");
- return -EREMOTEIO;
- }
- switch(buf[0]) {
- case 0x06: param->u.vsb.modulation = VSB_8; break;
- case 0x43: param->u.vsb.modulation = QAM_64; break;
- case 0x45: param->u.vsb.modulation = QAM_256; break;
- default:
- printk(KERN_WARNING "or51132: unknown status 0x%02x\n",
- buf[0]);
- return -EREMOTEIO;
- }
-
- /* FIXME: Read frequency from frontend, take AFC into account */
- param->frequency = state->current_frequency;
-
- /* FIXME: How to read inversion setting? Receiver 6 register? */
- param->inversion = INVERSION_AUTO;
-
- return 0;
-}
-
-static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct or51132_state* state = fe->demodulator_priv;
- unsigned char rec_buf[2];
- unsigned char snd_buf[2];
- *status = 0;
-
- /* Receiver Status */
- snd_buf[0]=0x04;
- snd_buf[1]=0x00;
- msleep(30); /* 30ms */
- if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
- printk(KERN_WARNING "or51132: read_status write error\n");
- return -1;
- }
- msleep(30); /* 30ms */
- if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51132: read_status read error\n");
- return -1;
- }
- dprintk("read_status %x %x\n",rec_buf[0],rec_buf[1]);
-
- if (rec_buf[1] & 0x01) { /* Receiver Lock */
- *status |= FE_HAS_SIGNAL;
- *status |= FE_HAS_CARRIER;
- *status |= FE_HAS_VITERBI;
- *status |= FE_HAS_SYNC;
- *status |= FE_HAS_LOCK;
- }
- return 0;
-}
-
-/* log10-1 table at .5 increments from 1 to 100.5 */
-static unsigned int i100x20log10[] = {
- 0, 352, 602, 795, 954, 1088, 1204, 1306, 1397, 1480,
- 1556, 1625, 1690, 1750, 1806, 1858, 1908, 1955, 2000, 2042,
- 2082, 2121, 2158, 2193, 2227, 2260, 2292, 2322, 2352, 2380,
- 2408, 2434, 2460, 2486, 2510, 2534, 2557, 2580, 2602, 2623,
- 2644, 2664, 2684, 2704, 2723, 2742, 2760, 2778, 2795, 2813,
- 2829, 2846, 2862, 2878, 2894, 2909, 2924, 2939, 2954, 2968,
- 2982, 2996, 3010, 3023, 3037, 3050, 3062, 3075, 3088, 3100,
- 3112, 3124, 3136, 3148, 3159, 3170, 3182, 3193, 3204, 3214,
- 3225, 3236, 3246, 3256, 3266, 3276, 3286, 3296, 3306, 3316,
- 3325, 3334, 3344, 3353, 3362, 3371, 3380, 3389, 3397, 3406,
- 3415, 3423, 3432, 3440, 3448, 3456, 3464, 3472, 3480, 3488,
- 3496, 3504, 3511, 3519, 3526, 3534, 3541, 3549, 3556, 3563,
- 3570, 3577, 3584, 3591, 3598, 3605, 3612, 3619, 3625, 3632,
- 3639, 3645, 3652, 3658, 3665, 3671, 3677, 3683, 3690, 3696,
- 3702, 3708, 3714, 3720, 3726, 3732, 3738, 3744, 3750, 3755,
- 3761, 3767, 3772, 3778, 3784, 3789, 3795, 3800, 3806, 3811,
- 3816, 3822, 3827, 3832, 3838, 3843, 3848, 3853, 3858, 3863,
- 3868, 3874, 3879, 3884, 3888, 3893, 3898, 3903, 3908, 3913,
- 3918, 3922, 3927, 3932, 3936, 3941, 3946, 3950, 3955, 3960,
- 3964, 3969, 3973, 3978, 3982, 3986, 3991, 3995, 4000, 4004,
-};
-
-static unsigned int denom[] = {1,1,100,1000,10000,100000,1000000,10000000,100000000};
-
-static unsigned int i20Log10(unsigned short val)
-{
- unsigned int rntval = 100;
- unsigned int tmp = val;
- unsigned int exp = 1;
-
- while(tmp > 100) {tmp /= 100; exp++;}
-
- val = (2 * val)/denom[exp];
- if (exp > 1) rntval = 2000*exp;
-
- rntval += i100x20log10[val];
- return rntval;
-}
-
-static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct or51132_state* state = fe->demodulator_priv;
- unsigned char rec_buf[2];
- unsigned char snd_buf[2];
- u8 rcvr_stat;
- u16 snr_equ;
- u32 signal_strength;
- int usK;
-
- snd_buf[0]=0x04;
- snd_buf[1]=0x02; /* SNR after Equalizer */
- msleep(30); /* 30ms */
- if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
- printk(KERN_WARNING "or51132: read_status write error\n");
- return -1;
- }
- msleep(30); /* 30ms */
- if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51132: read_status read error\n");
- return -1;
- }
- snr_equ = rec_buf[0] | (rec_buf[1] << 8);
- dprintk("read_signal_strength snr_equ %x %x (%i)\n",rec_buf[0],rec_buf[1],snr_equ);
-
- /* Receiver Status */
- snd_buf[0]=0x04;
- snd_buf[1]=0x00;
- msleep(30); /* 30ms */
- if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
- printk(KERN_WARNING "or51132: read_signal_strength read_status write error\n");
- return -1;
- }
- msleep(30); /* 30ms */
- if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51132: read_signal_strength read_status read error\n");
- return -1;
- }
- dprintk("read_signal_strength read_status %x %x\n",rec_buf[0],rec_buf[1]);
- rcvr_stat = rec_buf[1];
- usK = (rcvr_stat & 0x10) ? 3 : 0;
-
- /* The value reported back from the frontend will be FFFF=100% 0000=0% */
- signal_strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000;
- if (signal_strength > 0xffff)
- *strength = 0xffff;
- else
- *strength = signal_strength;
- dprintk("read_signal_strength %i\n",*strength);
-
- return 0;
-}
-
-static int or51132_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct or51132_state* state = fe->demodulator_priv;
- unsigned char rec_buf[2];
- unsigned char snd_buf[2];
- u16 snr_equ;
-
- snd_buf[0]=0x04;
- snd_buf[1]=0x02; /* SNR after Equalizer */
- msleep(30); /* 30ms */
- if (i2c_writebytes(state,state->config->demod_address,snd_buf,2)) {
- printk(KERN_WARNING "or51132: read_snr write error\n");
- return -1;
- }
- msleep(30); /* 30ms */
- if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51132: read_snr dvr read error\n");
- return -1;
- }
- snr_equ = rec_buf[0] | (rec_buf[1] << 8);
- dprintk("read_snr snr_equ %x %x (%i)\n",rec_buf[0],rec_buf[1],snr_equ);
-
- *snr = 0xFFFF - snr_equ;
- dprintk("read_snr %i\n",*snr);
-
- return 0;
-}
-
-static int or51132_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
-{
- fe_tune_settings->min_delay_ms = 500;
- fe_tune_settings->step_size = 0;
- fe_tune_settings->max_drift = 0;
-
- return 0;
-}
-
-static void or51132_release(struct dvb_frontend* fe)
-{
- struct or51132_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops or51132_ops;
-
-struct dvb_frontend* or51132_attach(const struct or51132_config* config,
- struct i2c_adapter* i2c)
-{
- struct or51132_state* state = NULL;
-
- /* Allocate memory for the internal state */
- state = kmalloc(sizeof(struct or51132_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* Setup the state */
- state->config = config;
- state->i2c = i2c;
- state->current_frequency = -1;
- state->current_modulation = -1;
-
- /* Create dvb_frontend */
- memcpy(&state->frontend.ops, &or51132_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops or51132_ops = {
-
- .info = {
- .name = "Oren OR51132 VSB/QAM Frontend",
- .type = FE_ATSC,
- .frequency_min = 44000000,
- .frequency_max = 958000000,
- .frequency_stepsize = 166666,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_QAM_AUTO |
- FE_CAN_8VSB
- },
-
- .release = or51132_release,
-
- .init = or51132_init,
- .sleep = or51132_sleep,
-
- .set_frontend = or51132_set_parameters,
- .get_frontend = or51132_get_parameters,
- .get_tune_settings = or51132_get_tune_settings,
-
- .read_status = or51132_read_status,
- .read_ber = or51132_read_ber,
- .read_signal_strength = or51132_read_signal_strength,
- .read_snr = or51132_read_snr,
- .read_ucblocks = or51132_read_ucblocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("OR51132 ATSC [pcHDTV HD-3000] (8VSB & ITU J83 AnnexB FEC QAM64/256) Demodulator Driver");
-MODULE_AUTHOR("Kirk Lapray");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(or51132_attach);
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/drivers/media/dvb/frontends/or51132.h b/drivers/media/dvb/frontends/or51132.h
deleted file mode 100644
index 89658883abf..00000000000
--- a/drivers/media/dvb/frontends/or51132.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Support for OR51132 (pcHDTV HD-3000) - VSB/QAM
- *
- * Copyright (C) 2005 Kirk Lapray <kirk_lapray@bigfoot.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
-*/
-
-#ifndef OR51132_H
-#define OR51132_H
-
-#include <linux/firmware.h>
-#include <linux/dvb/frontend.h>
-
-struct or51132_config
-{
- /* The demodulator's i2c address */
- u8 demod_address;
-
- /* Need to set device param for start_dma */
- int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
-};
-
-extern struct dvb_frontend* or51132_attach(const struct or51132_config* config,
- struct i2c_adapter* i2c);
-
-#endif // OR51132_H
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/drivers/media/dvb/frontends/or51211.c b/drivers/media/dvb/frontends/or51211.c
deleted file mode 100644
index 2bf124b5368..00000000000
--- a/drivers/media/dvb/frontends/or51211.c
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Support for OR51211 (pcHDTV HD-2000) - VSB
- *
- * Copyright (C) 2005 Kirk Lapray <kirk_lapray@bigfoot.com>
- *
- * Based on code from Jack Kelliher (kelliher@xmission.com)
- * Copyright (C) 2002 & pcHDTV, 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.
- *
- * 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.
- *
-*/
-
-/*
- * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to
- * download/extract it, and then copy it to /usr/lib/hotplug/firmware
- * or /lib/firmware (depending on configuration of firmware hotplug).
- */
-#define OR51211_DEFAULT_FIRMWARE "dvb-fe-or51211.fw"
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/device.h>
-#include <linux/firmware.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <asm/byteorder.h>
-
-#include "dvb_frontend.h"
-#include "or51211.h"
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "or51211: " args); \
- } while (0)
-
-static u8 run_buf[] = {0x7f,0x01};
-static u8 cmd_buf[] = {0x04,0x01,0x50,0x80,0x06}; // ATSC
-
-struct or51211_state {
-
- struct i2c_adapter* i2c;
-
- /* Configuration settings */
- const struct or51211_config* config;
-
- struct dvb_frontend frontend;
- struct bt878* bt;
-
- /* Demodulator private data */
- u8 initialized:1;
-
- /* Tuner private data */
- u32 current_frequency;
-};
-
-static int i2c_writebytes (struct or51211_state* state, u8 reg, u8 *buf,
- int len)
-{
- int err;
- struct i2c_msg msg;
- msg.addr = reg;
- msg.flags = 0;
- msg.len = len;
- msg.buf = buf;
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "or51211: i2c_writebytes error "
- "(addr %02x, err == %i)\n", reg, err);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static u8 i2c_readbytes (struct or51211_state* state, u8 reg, u8* buf, int len)
-{
- int err;
- struct i2c_msg msg;
- msg.addr = reg;
- msg.flags = I2C_M_RD;
- msg.len = len;
- msg.buf = buf;
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "or51211: i2c_readbytes error "
- "(addr %02x, err == %i)\n", reg, err);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static int or51211_load_firmware (struct dvb_frontend* fe,
- const struct firmware *fw)
-{
- struct or51211_state* state = fe->demodulator_priv;
- u8 tudata[585];
- int i;
-
- dprintk("Firmware is %zd bytes\n",fw->size);
-
- /* Get eprom data */
- tudata[0] = 17;
- if (i2c_writebytes(state,0x50,tudata,1)) {
- printk(KERN_WARNING "or51211:load_firmware error eprom addr\n");
- return -1;
- }
- if (i2c_readbytes(state,0x50,&tudata[145],192)) {
- printk(KERN_WARNING "or51211: load_firmware error eprom\n");
- return -1;
- }
-
- /* Create firmware buffer */
- for (i = 0; i < 145; i++)
- tudata[i] = fw->data[i];
-
- for (i = 0; i < 248; i++)
- tudata[i+337] = fw->data[145+i];
-
- state->config->reset(fe);
-
- if (i2c_writebytes(state,state->config->demod_address,tudata,585)) {
- printk(KERN_WARNING "or51211: load_firmware error 1\n");
- return -1;
- }
- msleep(1);
-
- if (i2c_writebytes(state,state->config->demod_address,
- &fw->data[393],8125)) {
- printk(KERN_WARNING "or51211: load_firmware error 2\n");
- return -1;
- }
- msleep(1);
-
- if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51211: load_firmware error 3\n");
- return -1;
- }
-
- /* Wait at least 5 msec */
- msleep(10);
- if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51211: load_firmware error 4\n");
- return -1;
- }
- msleep(10);
-
- printk("or51211: Done.\n");
- return 0;
-};
-
-static int or51211_setmode(struct dvb_frontend* fe, int mode)
-{
- struct or51211_state* state = fe->demodulator_priv;
- u8 rec_buf[14];
-
- state->config->setmode(fe, mode);
-
- if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51211: setmode error 1\n");
- return -1;
- }
-
- /* Wait at least 5 msec */
- msleep(10);
- if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
- printk(KERN_WARNING "or51211: setmode error 2\n");
- return -1;
- }
-
- msleep(10);
-
- /* Set operation mode in Receiver 1 register;
- * type 1:
- * data 0x50h Automatic sets receiver channel conditions
- * Automatic NTSC rejection filter
- * Enable MPEG serial data output
- * MPEG2tr
- * High tuner phase noise
- * normal +/-150kHz Carrier acquisition range
- */
- if (i2c_writebytes(state,state->config->demod_address,cmd_buf,3)) {
- printk(KERN_WARNING "or51211: setmode error 3\n");
- return -1;
- }
-
- rec_buf[0] = 0x04;
- rec_buf[1] = 0x00;
- rec_buf[2] = 0x03;
- rec_buf[3] = 0x00;
- msleep(20);
- if (i2c_writebytes(state,state->config->demod_address,rec_buf,3)) {
- printk(KERN_WARNING "or51211: setmode error 5\n");
- }
- msleep(3);
- if (i2c_readbytes(state,state->config->demod_address,&rec_buf[10],2)) {
- printk(KERN_WARNING "or51211: setmode error 6");
- return -1;
- }
- dprintk("setmode rec status %02x %02x\n",rec_buf[10],rec_buf[11]);
-
- return 0;
-}
-
-static int or51211_set_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- struct or51211_state* state = fe->demodulator_priv;
- u32 freq = 0;
- u16 tunerfreq = 0;
- u8 buf[4];
-
- /* Change only if we are actually changing the channel */
- if (state->current_frequency != param->frequency) {
- freq = 44000 + (param->frequency/1000);
- tunerfreq = freq * 16/1000;
-
- dprintk("set_parameters frequency = %d (tunerfreq = %d)\n",
- param->frequency,tunerfreq);
-
- buf[0] = (tunerfreq >> 8) & 0x7F;
- buf[1] = (tunerfreq & 0xFF);
- buf[2] = 0x8E;
-
- if (param->frequency < 157250000) {
- buf[3] = 0xA0;
- dprintk("set_parameters VHF low range\n");
- } else if (param->frequency < 454000000) {
- buf[3] = 0x90;
- dprintk("set_parameters VHF high range\n");
- } else {
- buf[3] = 0x30;
- dprintk("set_parameters UHF range\n");
- }
- dprintk("set_parameters tuner bytes: 0x%02x 0x%02x "
- "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
-
- if (i2c_writebytes(state,0xC2>>1,buf,4))
- printk(KERN_WARNING "or51211:set_parameters error "
- "writing to tuner\n");
-
- /* Set to ATSC mode */
- or51211_setmode(fe,0);
-
- /* Update current frequency */
- state->current_frequency = param->frequency;
- }
- return 0;
-}
-
-static int or51211_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct or51211_state* state = fe->demodulator_priv;
- unsigned char rec_buf[2];
- unsigned char snd_buf[] = {0x04,0x00,0x03,0x00};
- *status = 0;
-
- /* Receiver Status */
- if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) {
- printk(KERN_WARNING "or51132: read_status write error\n");
- return -1;
- }
- msleep(3);
- if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51132: read_status read error\n");
- return -1;
- }
- dprintk("read_status %x %x\n",rec_buf[0],rec_buf[1]);
-
- if (rec_buf[0] & 0x01) { /* Receiver Lock */
- *status |= FE_HAS_SIGNAL;
- *status |= FE_HAS_CARRIER;
- *status |= FE_HAS_VITERBI;
- *status |= FE_HAS_SYNC;
- *status |= FE_HAS_LOCK;
- }
- return 0;
-}
-
-/* log10-1 table at .5 increments from 1 to 100.5 */
-static unsigned int i100x20log10[] = {
- 0, 352, 602, 795, 954, 1088, 1204, 1306, 1397, 1480,
- 1556, 1625, 1690, 1750, 1806, 1858, 1908, 1955, 2000, 2042,
- 2082, 2121, 2158, 2193, 2227, 2260, 2292, 2322, 2352, 2380,
- 2408, 2434, 2460, 2486, 2510, 2534, 2557, 2580, 2602, 2623,
- 2644, 2664, 2684, 2704, 2723, 2742, 2760, 2778, 2795, 2813,
- 2829, 2846, 2862, 2878, 2894, 2909, 2924, 2939, 2954, 2968,
- 2982, 2996, 3010, 3023, 3037, 3050, 3062, 3075, 3088, 3100,
- 3112, 3124, 3136, 3148, 3159, 3170, 3182, 3193, 3204, 3214,
- 3225, 3236, 3246, 3256, 3266, 3276, 3286, 3296, 3306, 3316,
- 3325, 3334, 3344, 3353, 3362, 3371, 3380, 3389, 3397, 3406,
- 3415, 3423, 3432, 3440, 3448, 3456, 3464, 3472, 3480, 3488,
- 3496, 3504, 3511, 3519, 3526, 3534, 3541, 3549, 3556, 3563,
- 3570, 3577, 3584, 3591, 3598, 3605, 3612, 3619, 3625, 3632,
- 3639, 3645, 3652, 3658, 3665, 3671, 3677, 3683, 3690, 3696,
- 3702, 3708, 3714, 3720, 3726, 3732, 3738, 3744, 3750, 3755,
- 3761, 3767, 3772, 3778, 3784, 3789, 3795, 3800, 3806, 3811,
- 3816, 3822, 3827, 3832, 3838, 3843, 3848, 3853, 3858, 3863,
- 3868, 3874, 3879, 3884, 3888, 3893, 3898, 3903, 3908, 3913,
- 3918, 3922, 3927, 3932, 3936, 3941, 3946, 3950, 3955, 3960,
- 3964, 3969, 3973, 3978, 3982, 3986, 3991, 3995, 4000, 4004,
-};
-
-static unsigned int denom[] = {1,1,100,1000,10000,100000,1000000,10000000,100000000};
-
-static unsigned int i20Log10(unsigned short val)
-{
- unsigned int rntval = 100;
- unsigned int tmp = val;
- unsigned int exp = 1;
-
- while(tmp > 100) {tmp /= 100; exp++;}
-
- val = (2 * val)/denom[exp];
- if (exp > 1) rntval = 2000*exp;
-
- rntval += i100x20log10[val];
- return rntval;
-}
-
-static int or51211_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct or51211_state* state = fe->demodulator_priv;
- u8 rec_buf[2];
- u8 snd_buf[4];
- u8 snr_equ;
- u32 signal_strength;
-
- /* SNR after Equalizer */
- snd_buf[0] = 0x04;
- snd_buf[1] = 0x00;
- snd_buf[2] = 0x04;
- snd_buf[3] = 0x00;
-
- if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) {
- printk(KERN_WARNING "or51211: read_status write error\n");
- return -1;
- }
- msleep(3);
- if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51211: read_status read error\n");
- return -1;
- }
- snr_equ = rec_buf[0] & 0xff;
-
- /* The value reported back from the frontend will be FFFF=100% 0000=0% */
- signal_strength = (((5334 - i20Log10(snr_equ))/3+5)*65535)/1000;
- if (signal_strength > 0xffff)
- *strength = 0xffff;
- else
- *strength = signal_strength;
- dprintk("read_signal_strength %i\n",*strength);
-
- return 0;
-}
-
-static int or51211_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct or51211_state* state = fe->demodulator_priv;
- u8 rec_buf[2];
- u8 snd_buf[4];
-
- /* SNR after Equalizer */
- snd_buf[0] = 0x04;
- snd_buf[1] = 0x00;
- snd_buf[2] = 0x04;
- snd_buf[3] = 0x00;
-
- if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) {
- printk(KERN_WARNING "or51211: read_status write error\n");
- return -1;
- }
- msleep(3);
- if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) {
- printk(KERN_WARNING "or51211: read_status read error\n");
- return -1;
- }
- *snr = rec_buf[0] & 0xff;
-
- dprintk("read_snr %i\n",*snr);
-
- return 0;
-}
-
-static int or51211_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- *ber = -ENOSYS;
- return 0;
-}
-
-static int or51211_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- *ucblocks = -ENOSYS;
- return 0;
-}
-
-static int or51211_sleep(struct dvb_frontend* fe)
-{
- return 0;
-}
-
-static int or51211_init(struct dvb_frontend* fe)
-{
- struct or51211_state* state = fe->demodulator_priv;
- const struct or51211_config* config = state->config;
- const struct firmware* fw;
- unsigned char get_ver_buf[] = {0x04,0x00,0x30,0x00,0x00};
- unsigned char rec_buf[14];
- int ret,i;
-
- if (!state->initialized) {
- /* Request the firmware, this will block until it uploads */
- printk(KERN_INFO "or51211: Waiting for firmware upload "
- "(%s)...\n", OR51211_DEFAULT_FIRMWARE);
- ret = config->request_firmware(fe, &fw,
- OR51211_DEFAULT_FIRMWARE);
- printk(KERN_INFO "or51211:Got Hotplug firmware\n");
- if (ret) {
- printk(KERN_WARNING "or51211: No firmware uploaded "
- "(timeout or file not found?)\n");
- return ret;
- }
-
- ret = or51211_load_firmware(fe, fw);
- release_firmware(fw);
- if (ret) {
- printk(KERN_WARNING "or51211: Writing firmware to "
- "device failed!\n");
- return ret;
- }
- printk(KERN_INFO "or51211: Firmware upload complete.\n");
-
- /* Set operation mode in Receiver 1 register;
- * type 1:
- * data 0x50h Automatic sets receiver channel conditions
- * Automatic NTSC rejection filter
- * Enable MPEG serial data output
- * MPEG2tr
- * High tuner phase noise
- * normal +/-150kHz Carrier acquisition range
- */
- if (i2c_writebytes(state,state->config->demod_address,
- cmd_buf,3)) {
- printk(KERN_WARNING "or51211: Load DVR Error 5\n");
- return -1;
- }
-
- /* Read back ucode version to besure we loaded correctly */
- /* and are really up and running */
- rec_buf[0] = 0x04;
- rec_buf[1] = 0x00;
- rec_buf[2] = 0x03;
- rec_buf[3] = 0x00;
- msleep(30);
- if (i2c_writebytes(state,state->config->demod_address,
- rec_buf,3)) {
- printk(KERN_WARNING "or51211: Load DVR Error A\n");
- return -1;
- }
- msleep(3);
- if (i2c_readbytes(state,state->config->demod_address,
- &rec_buf[10],2)) {
- printk(KERN_WARNING "or51211: Load DVR Error B\n");
- return -1;
- }
-
- rec_buf[0] = 0x04;
- rec_buf[1] = 0x00;
- rec_buf[2] = 0x01;
- rec_buf[3] = 0x00;
- msleep(20);
- if (i2c_writebytes(state,state->config->demod_address,
- rec_buf,3)) {
- printk(KERN_WARNING "or51211: Load DVR Error C\n");
- return -1;
- }
- msleep(3);
- if (i2c_readbytes(state,state->config->demod_address,
- &rec_buf[12],2)) {
- printk(KERN_WARNING "or51211: Load DVR Error D\n");
- return -1;
- }
-
- for (i = 0; i < 8; i++)
- rec_buf[i]=0xed;
-
- for (i = 0; i < 5; i++) {
- msleep(30);
- get_ver_buf[4] = i+1;
- if (i2c_writebytes(state,state->config->demod_address,
- get_ver_buf,5)) {
- printk(KERN_WARNING "or51211:Load DVR Error 6"
- " - %d\n",i);
- return -1;
- }
- msleep(3);
-
- if (i2c_readbytes(state,state->config->demod_address,
- &rec_buf[i*2],2)) {
- printk(KERN_WARNING "or51211:Load DVR Error 7"
- " - %d\n",i);
- return -1;
- }
- /* If we didn't receive the right index, try again */
- if ((int)rec_buf[i*2+1]!=i+1){
- i--;
- }
- }
- dprintk("read_fwbits %x %x %x %x %x %x %x %x %x %x\n",
- rec_buf[0], rec_buf[1], rec_buf[2], rec_buf[3],
- rec_buf[4], rec_buf[5], rec_buf[6], rec_buf[7],
- rec_buf[8], rec_buf[9]);
-
- printk(KERN_INFO "or51211: ver TU%02x%02x%02x VSB mode %02x"
- " Status %02x\n",
- rec_buf[2], rec_buf[4],rec_buf[6],
- rec_buf[12],rec_buf[10]);
-
- rec_buf[0] = 0x04;
- rec_buf[1] = 0x00;
- rec_buf[2] = 0x03;
- rec_buf[3] = 0x00;
- msleep(20);
- if (i2c_writebytes(state,state->config->demod_address,
- rec_buf,3)) {
- printk(KERN_WARNING "or51211: Load DVR Error 8\n");
- return -1;
- }
- msleep(20);
- if (i2c_readbytes(state,state->config->demod_address,
- &rec_buf[8],2)) {
- printk(KERN_WARNING "or51211: Load DVR Error 9\n");
- return -1;
- }
- state->initialized = 1;
- }
-
- return 0;
-}
-
-static int or51211_get_tune_settings(struct dvb_frontend* fe,
- struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 500;
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static void or51211_release(struct dvb_frontend* fe)
-{
- struct or51211_state* state = fe->demodulator_priv;
- state->config->sleep(fe);
- kfree(state);
-}
-
-static struct dvb_frontend_ops or51211_ops;
-
-struct dvb_frontend* or51211_attach(const struct or51211_config* config,
- struct i2c_adapter* i2c)
-{
- struct or51211_state* state = NULL;
-
- /* Allocate memory for the internal state */
- state = kmalloc(sizeof(struct or51211_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* Setup the state */
- state->config = config;
- state->i2c = i2c;
- state->initialized = 0;
- state->current_frequency = 0;
-
- /* Create dvb_frontend */
- memcpy(&state->frontend.ops, &or51211_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops or51211_ops = {
-
- .info = {
- .name = "Oren OR51211 VSB Frontend",
- .type = FE_ATSC,
- .frequency_min = 44000000,
- .frequency_max = 958000000,
- .frequency_stepsize = 166666,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_8VSB
- },
-
- .release = or51211_release,
-
- .init = or51211_init,
- .sleep = or51211_sleep,
-
- .set_frontend = or51211_set_parameters,
- .get_tune_settings = or51211_get_tune_settings,
-
- .read_status = or51211_read_status,
- .read_ber = or51211_read_ber,
- .read_signal_strength = or51211_read_signal_strength,
- .read_snr = or51211_read_snr,
- .read_ucblocks = or51211_read_ucblocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Oren OR51211 VSB [pcHDTV HD-2000] Demodulator Driver");
-MODULE_AUTHOR("Kirk Lapray");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(or51211_attach);
-
diff --git a/drivers/media/dvb/frontends/or51211.h b/drivers/media/dvb/frontends/or51211.h
deleted file mode 100644
index 13a5a3afbf8..00000000000
--- a/drivers/media/dvb/frontends/or51211.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Support for OR51211 (pcHDTV HD-2000) - VSB
- *
- * Copyright (C) 2005 Kirk Lapray <kirk_lapray@bigfoot.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
-*/
-
-#ifndef OR51211_H
-#define OR51211_H
-
-#include <linux/dvb/frontend.h>
-#include <linux/firmware.h>
-
-struct or51211_config
-{
- /* The demodulator's i2c address */
- u8 demod_address;
-
- /* Request firmware for device */
- int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
- void (*setmode)(struct dvb_frontend * fe, int mode);
- void (*reset)(struct dvb_frontend * fe);
- void (*sleep)(struct dvb_frontend * fe);
-};
-
-extern struct dvb_frontend* or51211_attach(const struct or51211_config* config,
- struct i2c_adapter* i2c);
-
-#endif // OR51211_H
-
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c
deleted file mode 100644
index 2c2c344c4c6..00000000000
--- a/drivers/media/dvb/frontends/s5h1420.c
+++ /dev/null
@@ -1,835 +0,0 @@
-/*
-Driver for Samsung S5H1420 QPSK Demodulator
-
-Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net>
-
-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/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/jiffies.h>
-#include <asm/div64.h>
-
-#include "dvb_frontend.h"
-#include "s5h1420.h"
-
-
-
-#define TONE_FREQ 22000
-
-struct s5h1420_state {
- struct i2c_adapter* i2c;
- const struct s5h1420_config* config;
- struct dvb_frontend frontend;
-
- u8 postlocked:1;
- u32 fclk;
- u32 tunedfreq;
- fe_code_rate_t fec_inner;
- u32 symbol_rate;
-};
-
-static u32 s5h1420_getsymbolrate(struct s5h1420_state* state);
-static int s5h1420_get_tune_settings(struct dvb_frontend* fe,
- struct dvb_frontend_tune_settings* fesettings);
-
-
-static int debug = 0;
-#define dprintk if (debug) printk
-
-static int s5h1420_writereg (struct s5h1420_state* state, u8 reg, u8 data)
-{
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
- int err;
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static u8 s5h1420_readreg (struct s5h1420_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg1 = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 };
- struct i2c_msg msg2 = { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 };
-
- if ((ret = i2c_transfer (state->i2c, &msg1, 1)) != 1)
- return ret;
-
- if ((ret = i2c_transfer (state->i2c, &msg2, 1)) != 1)
- return ret;
-
- return b1[0];
-}
-
-static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- switch(voltage) {
- case SEC_VOLTAGE_13:
- s5h1420_writereg(state, 0x3c,
- (s5h1420_readreg(state, 0x3c) & 0xfe) | 0x02);
- break;
-
- case SEC_VOLTAGE_18:
- s5h1420_writereg(state, 0x3c, s5h1420_readreg(state, 0x3c) | 0x03);
- break;
-
- case SEC_VOLTAGE_OFF:
- s5h1420_writereg(state, 0x3c, s5h1420_readreg(state, 0x3c) & 0xfd);
- break;
- }
-
- return 0;
-}
-
-static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- switch(tone) {
- case SEC_TONE_ON:
- s5h1420_writereg(state, 0x3b,
- (s5h1420_readreg(state, 0x3b) & 0x74) | 0x08);
- break;
-
- case SEC_TONE_OFF:
- s5h1420_writereg(state, 0x3b,
- (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01);
- break;
- }
-
- return 0;
-}
-
-static int s5h1420_send_master_cmd (struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd* cmd)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
- u8 val;
- int i;
- unsigned long timeout;
- int result = 0;
-
- if (cmd->msg_len > 8)
- return -EINVAL;
-
- /* setup for DISEQC */
- val = s5h1420_readreg(state, 0x3b);
- s5h1420_writereg(state, 0x3b, 0x02);
- msleep(15);
-
- /* write the DISEQC command bytes */
- for(i=0; i< cmd->msg_len; i++) {
- s5h1420_writereg(state, 0x3d + i, cmd->msg[i]);
- }
-
- /* kick off transmission */
- s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) |
- ((cmd->msg_len-1) << 4) | 0x08);
-
- /* wait for transmission to complete */
- timeout = jiffies + ((100*HZ) / 1000);
- while(time_before(jiffies, timeout)) {
- if (!(s5h1420_readreg(state, 0x3b) & 0x08))
- break;
-
- msleep(5);
- }
- if (time_after(jiffies, timeout))
- result = -ETIMEDOUT;
-
- /* restore original settings */
- s5h1420_writereg(state, 0x3b, val);
- msleep(15);
- return result;
-}
-
-static int s5h1420_recv_slave_reply (struct dvb_frontend* fe,
- struct dvb_diseqc_slave_reply* reply)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
- u8 val;
- int i;
- int length;
- unsigned long timeout;
- int result = 0;
-
- /* setup for DISEQC recieve */
- val = s5h1420_readreg(state, 0x3b);
- s5h1420_writereg(state, 0x3b, 0x82); /* FIXME: guess - do we need to set DIS_RDY(0x08) in receive mode? */
- msleep(15);
-
- /* wait for reception to complete */
- timeout = jiffies + ((reply->timeout*HZ) / 1000);
- while(time_before(jiffies, timeout)) {
- if (!(s5h1420_readreg(state, 0x3b) & 0x80)) /* FIXME: do we test DIS_RDY(0x08) or RCV_EN(0x80)? */
- break;
-
- msleep(5);
- }
- if (time_after(jiffies, timeout)) {
- result = -ETIMEDOUT;
- goto exit;
- }
-
- /* check error flag - FIXME: not sure what this does - docs do not describe
- * beyond "error flag for diseqc receive data :( */
- if (s5h1420_readreg(state, 0x49)) {
- result = -EIO;
- goto exit;
- }
-
- /* check length */
- length = (s5h1420_readreg(state, 0x3b) & 0x70) >> 4;
- if (length > sizeof(reply->msg)) {
- result = -EOVERFLOW;
- goto exit;
- }
- reply->msg_len = length;
-
- /* extract data */
- for(i=0; i< length; i++) {
- reply->msg[i] = s5h1420_readreg(state, 0x3d + i);
- }
-
-exit:
- /* restore original settings */
- s5h1420_writereg(state, 0x3b, val);
- msleep(15);
- return result;
-}
-
-static int s5h1420_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
- u8 val;
- int result = 0;
- unsigned long timeout;
-
- /* setup for tone burst */
- val = s5h1420_readreg(state, 0x3b);
- s5h1420_writereg(state, 0x3b, (s5h1420_readreg(state, 0x3b) & 0x70) | 0x01);
-
- /* set value for B position if requested */
- if (minicmd == SEC_MINI_B) {
- s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x04);
- }
- msleep(15);
-
- /* start transmission */
- s5h1420_writereg(state, 0x3b, s5h1420_readreg(state, 0x3b) | 0x08);
-
- /* wait for transmission to complete */
- timeout = jiffies + ((100*HZ) / 1000);
- while(time_before(jiffies, timeout)) {
- if (!(s5h1420_readreg(state, 0x3b) & 0x08))
- break;
-
- msleep(5);
- }
- if (time_after(jiffies, timeout))
- result = -ETIMEDOUT;
-
- /* restore original settings */
- s5h1420_writereg(state, 0x3b, val);
- msleep(15);
- return result;
-}
-
-static fe_status_t s5h1420_get_status_bits(struct s5h1420_state* state)
-{
- u8 val;
- fe_status_t status = 0;
-
- val = s5h1420_readreg(state, 0x14);
- if (val & 0x02)
- status |= FE_HAS_SIGNAL;
- if (val & 0x01)
- status |= FE_HAS_CARRIER;
- val = s5h1420_readreg(state, 0x36);
- if (val & 0x01)
- status |= FE_HAS_VITERBI;
- if (val & 0x20)
- status |= FE_HAS_SYNC;
- if (status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI|FE_HAS_SYNC))
- status |= FE_HAS_LOCK;
-
- return status;
-}
-
-static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
- u8 val;
-
- if (status == NULL)
- return -EINVAL;
-
- /* determine lock state */
- *status = s5h1420_get_status_bits(state);
-
- /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert
- the inversion, wait a bit and check again */
- if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) {
- val = s5h1420_readreg(state, 0x32);
- if ((val & 0x07) == 0x03) {
- if (val & 0x08)
- s5h1420_writereg(state, 0x31, 0x13);
- else
- s5h1420_writereg(state, 0x31, 0x1b);
-
- /* wait a bit then update lock status */
- mdelay(200);
- *status = s5h1420_get_status_bits(state);
- }
- }
-
- /* perform post lock setup */
- if ((*status & FE_HAS_LOCK) && (!state->postlocked)) {
-
- /* calculate the data rate */
- u32 tmp = s5h1420_getsymbolrate(state);
- switch(s5h1420_readreg(state, 0x32) & 0x07) {
- case 0:
- tmp = (tmp * 2 * 1) / 2;
- break;
-
- case 1:
- tmp = (tmp * 2 * 2) / 3;
- break;
-
- case 2:
- tmp = (tmp * 2 * 3) / 4;
- break;
-
- case 3:
- tmp = (tmp * 2 * 5) / 6;
- break;
-
- case 4:
- tmp = (tmp * 2 * 6) / 7;
- break;
-
- case 5:
- tmp = (tmp * 2 * 7) / 8;
- break;
- }
- if (tmp == 0) {
- printk("s5h1420: avoided division by 0\n");
- tmp = 1;
- }
- tmp = state->fclk / tmp;
-
- /* set the MPEG_CLK_INTL for the calculated data rate */
- if (tmp < 4)
- val = 0x00;
- else if (tmp < 8)
- val = 0x01;
- else if (tmp < 12)
- val = 0x02;
- else if (tmp < 16)
- val = 0x03;
- else if (tmp < 24)
- val = 0x04;
- else if (tmp < 32)
- val = 0x05;
- else
- val = 0x06;
- s5h1420_writereg(state, 0x22, val);
-
- /* DC freeze */
- s5h1420_writereg(state, 0x1f, s5h1420_readreg(state, 0x1f) | 0x01);
-
- /* kicker disable + remove DC offset */
- s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) & 0x6f);
-
- /* post-lock processing has been done! */
- state->postlocked = 1;
- }
-
- return 0;
-}
-
-static int s5h1420_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- s5h1420_writereg(state, 0x46, 0x1d);
- mdelay(25);
-
- *ber = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
-
- return 0;
-}
-
-static int s5h1420_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- u8 val = s5h1420_readreg(state, 0x15);
-
- *strength = (u16) ((val << 8) | val);
-
- return 0;
-}
-
-static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- s5h1420_writereg(state, 0x46, 0x1f);
- mdelay(25);
-
- *ucblocks = (s5h1420_readreg(state, 0x48) << 8) | s5h1420_readreg(state, 0x47);
-
- return 0;
-}
-
-static void s5h1420_reset(struct s5h1420_state* state)
-{
- s5h1420_writereg (state, 0x01, 0x08);
- s5h1420_writereg (state, 0x01, 0x00);
- udelay(10);
-}
-
-static void s5h1420_setsymbolrate(struct s5h1420_state* state,
- struct dvb_frontend_parameters *p)
-{
- u64 val;
-
- val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24);
- if (p->u.qpsk.symbol_rate <= 21000000) {
- val *= 2;
- }
- do_div(val, (state->fclk / 1000));
-
- s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) & 0x7f);
- s5h1420_writereg(state, 0x11, val >> 16);
- s5h1420_writereg(state, 0x12, val >> 8);
- s5h1420_writereg(state, 0x13, val & 0xff);
- s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) | 0x80);
-}
-
-static u32 s5h1420_getsymbolrate(struct s5h1420_state* state)
-{
- u64 val = 0;
- int sampling = 2;
-
- if (s5h1420_readreg(state, 0x05) & 0x2)
- sampling = 1;
-
- s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) | 0x08);
- val = s5h1420_readreg(state, 0x11) << 16;
- val |= s5h1420_readreg(state, 0x12) << 8;
- val |= s5h1420_readreg(state, 0x13);
- s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7);
-
- val *= (state->fclk / 1000ULL);
- do_div(val, ((1<<24) * sampling));
-
- return (u32) (val * 1000ULL);
-}
-
-static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset)
-{
- int val;
-
- /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so
- * divide fclk by 1000000 to get the correct value. */
- val = -(int) ((freqoffset * (1<<24)) / (state->fclk / 1000000));
-
- s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) & 0xbf);
- s5h1420_writereg(state, 0x0e, val >> 16);
- s5h1420_writereg(state, 0x0f, val >> 8);
- s5h1420_writereg(state, 0x10, val & 0xff);
- s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) | 0x40);
-}
-
-static int s5h1420_getfreqoffset(struct s5h1420_state* state)
-{
- int val;
-
- s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) | 0x08);
- val = s5h1420_readreg(state, 0x0e) << 16;
- val |= s5h1420_readreg(state, 0x0f) << 8;
- val |= s5h1420_readreg(state, 0x10);
- s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7);
-
- if (val & 0x800000)
- val |= 0xff000000;
-
- /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so
- * divide fclk by 1000000 to get the correct value. */
- val = (((-val) * (state->fclk/1000000)) / (1<<24));
-
- return val;
-}
-
-static void s5h1420_setfec_inversion(struct s5h1420_state* state,
- struct dvb_frontend_parameters *p)
-{
- u8 inversion = 0;
-
- if (p->inversion == INVERSION_OFF) {
- inversion = state->config->invert ? 0x08 : 0;
- } else if (p->inversion == INVERSION_ON) {
- inversion = state->config->invert ? 0 : 0x08;
- }
-
- if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) {
- s5h1420_writereg(state, 0x30, 0x3f);
- s5h1420_writereg(state, 0x31, 0x00 | inversion);
- } else {
- switch(p->u.qpsk.fec_inner) {
- case FEC_1_2:
- s5h1420_writereg(state, 0x30, 0x01);
- s5h1420_writereg(state, 0x31, 0x10 | inversion);
- break;
-
- case FEC_2_3:
- s5h1420_writereg(state, 0x30, 0x02);
- s5h1420_writereg(state, 0x31, 0x11 | inversion);
- break;
-
- case FEC_3_4:
- s5h1420_writereg(state, 0x30, 0x04);
- s5h1420_writereg(state, 0x31, 0x12 | inversion);
- break;
-
- case FEC_5_6:
- s5h1420_writereg(state, 0x30, 0x08);
- s5h1420_writereg(state, 0x31, 0x13 | inversion);
- break;
-
- case FEC_6_7:
- s5h1420_writereg(state, 0x30, 0x10);
- s5h1420_writereg(state, 0x31, 0x14 | inversion);
- break;
-
- case FEC_7_8:
- s5h1420_writereg(state, 0x30, 0x20);
- s5h1420_writereg(state, 0x31, 0x15 | inversion);
- break;
-
- default:
- return;
- }
- }
-}
-
-static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state)
-{
- switch(s5h1420_readreg(state, 0x32) & 0x07) {
- case 0:
- return FEC_1_2;
-
- case 1:
- return FEC_2_3;
-
- case 2:
- return FEC_3_4;
-
- case 3:
- return FEC_5_6;
-
- case 4:
- return FEC_6_7;
-
- case 5:
- return FEC_7_8;
- }
-
- return FEC_NONE;
-}
-
-static fe_spectral_inversion_t s5h1420_getinversion(struct s5h1420_state* state)
-{
- if (s5h1420_readreg(state, 0x32) & 0x08)
- return INVERSION_ON;
-
- return INVERSION_OFF;
-}
-
-static int s5h1420_set_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
- int frequency_delta;
- struct dvb_frontend_tune_settings fesettings;
-
- /* check if we should do a fast-tune */
- memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters));
- s5h1420_get_tune_settings(fe, &fesettings);
- frequency_delta = p->frequency - state->tunedfreq;
- if ((frequency_delta > -fesettings.max_drift) &&
- (frequency_delta < fesettings.max_drift) &&
- (frequency_delta != 0) &&
- (state->fec_inner == p->u.qpsk.fec_inner) &&
- (state->symbol_rate == p->u.qpsk.symbol_rate)) {
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
- if (fe->ops.tuner_ops.get_frequency) {
- u32 tmp;
- fe->ops.tuner_ops.get_frequency(fe, &tmp);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- s5h1420_setfreqoffset(state, p->frequency - tmp);
- } else {
- s5h1420_setfreqoffset(state, 0);
- }
- return 0;
- }
-
- /* first of all, software reset */
- s5h1420_reset(state);
-
- /* set s5h1420 fclk PLL according to desired symbol rate */
- if (p->u.qpsk.symbol_rate > 28000000) {
- state->fclk = 88000000;
- s5h1420_writereg(state, 0x03, 0x50);
- s5h1420_writereg(state, 0x04, 0x40);
- s5h1420_writereg(state, 0x05, 0xae);
- } else if (p->u.qpsk.symbol_rate > 21000000) {
- state->fclk = 59000000;
- s5h1420_writereg(state, 0x03, 0x33);
- s5h1420_writereg(state, 0x04, 0x40);
- s5h1420_writereg(state, 0x05, 0xae);
- } else {
- state->fclk = 88000000;
- s5h1420_writereg(state, 0x03, 0x50);
- s5h1420_writereg(state, 0x04, 0x40);
- s5h1420_writereg(state, 0x05, 0xac);
- }
-
- /* set misc registers */
- s5h1420_writereg(state, 0x02, 0x00);
- s5h1420_writereg(state, 0x06, 0x00);
- s5h1420_writereg(state, 0x07, 0xb0);
- s5h1420_writereg(state, 0x0a, 0xe7);
- s5h1420_writereg(state, 0x0b, 0x78);
- s5h1420_writereg(state, 0x0c, 0x48);
- s5h1420_writereg(state, 0x0d, 0x6b);
- s5h1420_writereg(state, 0x2e, 0x8e);
- s5h1420_writereg(state, 0x35, 0x33);
- s5h1420_writereg(state, 0x38, 0x01);
- s5h1420_writereg(state, 0x39, 0x7d);
- s5h1420_writereg(state, 0x3a, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32));
- s5h1420_writereg(state, 0x3c, 0x00);
- s5h1420_writereg(state, 0x45, 0x61);
- s5h1420_writereg(state, 0x46, 0x1d);
-
- /* start QPSK */
- s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1);
-
- /* set tuner PLL */
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- s5h1420_setfreqoffset(state, 0);
- }
-
- /* set the reset of the parameters */
- s5h1420_setsymbolrate(state, p);
- s5h1420_setfec_inversion(state, p);
-
- state->fec_inner = p->u.qpsk.fec_inner;
- state->symbol_rate = p->u.qpsk.symbol_rate;
- state->postlocked = 0;
- state->tunedfreq = p->frequency;
- return 0;
-}
-
-static int s5h1420_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- p->frequency = state->tunedfreq + s5h1420_getfreqoffset(state);
- p->inversion = s5h1420_getinversion(state);
- p->u.qpsk.symbol_rate = s5h1420_getsymbolrate(state);
- p->u.qpsk.fec_inner = s5h1420_getfec(state);
-
- return 0;
-}
-
-static int s5h1420_get_tune_settings(struct dvb_frontend* fe,
- struct dvb_frontend_tune_settings* fesettings)
-{
- if (fesettings->parameters.u.qpsk.symbol_rate > 20000000) {
- fesettings->min_delay_ms = 50;
- fesettings->step_size = 2000;
- fesettings->max_drift = 8000;
- } else if (fesettings->parameters.u.qpsk.symbol_rate > 12000000) {
- fesettings->min_delay_ms = 100;
- fesettings->step_size = 1500;
- fesettings->max_drift = 9000;
- } else if (fesettings->parameters.u.qpsk.symbol_rate > 8000000) {
- fesettings->min_delay_ms = 100;
- fesettings->step_size = 1000;
- fesettings->max_drift = 8000;
- } else if (fesettings->parameters.u.qpsk.symbol_rate > 4000000) {
- fesettings->min_delay_ms = 100;
- fesettings->step_size = 500;
- fesettings->max_drift = 7000;
- } else if (fesettings->parameters.u.qpsk.symbol_rate > 2000000) {
- fesettings->min_delay_ms = 200;
- fesettings->step_size = (fesettings->parameters.u.qpsk.symbol_rate / 8000);
- fesettings->max_drift = 14 * fesettings->step_size;
- } else {
- fesettings->min_delay_ms = 200;
- fesettings->step_size = (fesettings->parameters.u.qpsk.symbol_rate / 8000);
- fesettings->max_drift = 18 * fesettings->step_size;
- }
-
- return 0;
-}
-
-static int s5h1420_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- if (enable) {
- return s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1);
- } else {
- return s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe);
- }
-}
-
-static int s5h1420_init (struct dvb_frontend* fe)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- /* disable power down and do reset */
- s5h1420_writereg(state, 0x02, 0x10);
- msleep(10);
- s5h1420_reset(state);
-
- return 0;
-}
-
-static int s5h1420_sleep(struct dvb_frontend* fe)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
-
- return s5h1420_writereg(state, 0x02, 0x12);
-}
-
-static void s5h1420_release(struct dvb_frontend* fe)
-{
- struct s5h1420_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops s5h1420_ops;
-
-struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
- struct i2c_adapter* i2c)
-{
- struct s5h1420_state* state = NULL;
- u8 identity;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct s5h1420_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->postlocked = 0;
- state->fclk = 88000000;
- state->tunedfreq = 0;
- state->fec_inner = FEC_NONE;
- state->symbol_rate = 0;
-
- /* check if the demod is there + identify it */
- identity = s5h1420_readreg(state, 0x00);
- if (identity != 0x03)
- goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops s5h1420_ops = {
-
- .info = {
- .name = "Samsung S5H1420 DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 125, /* kHz for QPSK frontends */
- .frequency_tolerance = 29500,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- /* .symbol_rate_tolerance = ???,*/
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK
- },
-
- .release = s5h1420_release,
-
- .init = s5h1420_init,
- .sleep = s5h1420_sleep,
- .i2c_gate_ctrl = s5h1420_i2c_gate_ctrl,
-
- .set_frontend = s5h1420_set_frontend,
- .get_frontend = s5h1420_get_frontend,
- .get_tune_settings = s5h1420_get_tune_settings,
-
- .read_status = s5h1420_read_status,
- .read_ber = s5h1420_read_ber,
- .read_signal_strength = s5h1420_read_signal_strength,
- .read_ucblocks = s5h1420_read_ucblocks,
-
- .diseqc_send_master_cmd = s5h1420_send_master_cmd,
- .diseqc_recv_slave_reply = s5h1420_recv_slave_reply,
- .diseqc_send_burst = s5h1420_send_burst,
- .set_tone = s5h1420_set_tone,
- .set_voltage = s5h1420_set_voltage,
-};
-
-module_param(debug, int, 0644);
-
-MODULE_DESCRIPTION("Samsung S5H1420 DVB-S Demodulator driver");
-MODULE_AUTHOR("Andrew de Quincey");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(s5h1420_attach);
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
deleted file mode 100644
index 4e39015fa67..00000000000
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Driver for S5H1420 QPSK Demodulators
-
- Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net>
-
- 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.
-
-*/
-
-#ifndef S5H1420_H
-#define S5H1420_H
-
-#include <linux/dvb/frontend.h>
-
-struct s5h1420_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* does the inversion require inversion? */
- u8 invert:1;
-};
-
-extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
- struct i2c_adapter* i2c);
-
-#endif // S5H1420_H
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c
deleted file mode 100644
index d98fd5c2e13..00000000000
--- a/drivers/media/dvb/frontends/sp8870.c
+++ /dev/null
@@ -1,620 +0,0 @@
-/*
- Driver for Spase SP8870 demodulator
-
- Copyright (C) 1999 Juergen Peitz
-
- 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.
-
-*/
-/*
- * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware alps_tdlb7" to
- * download/extract it, and then copy it to /usr/lib/hotplug/firmware
- * or /lib/firmware (depending on configuration of firmware hotplug).
- */
-#define SP8870_DEFAULT_FIRMWARE "dvb-fe-sp8870.fw"
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/device.h>
-#include <linux/firmware.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "sp8870.h"
-
-
-struct sp8870_state {
-
- struct i2c_adapter* i2c;
-
- const struct sp8870_config* config;
-
- struct dvb_frontend frontend;
-
- /* demodulator private data */
- u8 initialised:1;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "sp8870: " args); \
- } while (0)
-
-/* firmware size for sp8870 */
-#define SP8870_FIRMWARE_SIZE 16382
-
-/* starting point for firmware in file 'Sc_main.mc' */
-#define SP8870_FIRMWARE_OFFSET 0x0A
-
-static int sp8870_writereg (struct sp8870_state* state, u16 reg, u16 data)
-{
- u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 4 };
- int err;
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static int sp8870_readreg (struct sp8870_state* state, u16 reg)
-{
- int ret;
- u8 b0 [] = { reg >> 8 , reg & 0xff };
- u8 b1 [] = { 0, 0 };
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 } };
-
- ret = i2c_transfer (state->i2c, msg, 2);
-
- if (ret != 2) {
- dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
- return -1;
- }
-
- return (b1[0] << 8 | b1[1]);
-}
-
-static int sp8870_firmware_upload (struct sp8870_state* state, const struct firmware *fw)
-{
- struct i2c_msg msg;
- char *fw_buf = fw->data;
- int fw_pos;
- u8 tx_buf[255];
- int tx_len;
- int err = 0;
-
- dprintk ("%s: ...\n", __FUNCTION__);
-
- if (fw->size < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET)
- return -EINVAL;
-
- // system controller stop
- sp8870_writereg(state, 0x0F00, 0x0000);
-
- // instruction RAM register hiword
- sp8870_writereg(state, 0x8F08, ((SP8870_FIRMWARE_SIZE / 2) & 0xFFFF));
-
- // instruction RAM MWR
- sp8870_writereg(state, 0x8F0A, ((SP8870_FIRMWARE_SIZE / 2) >> 16));
-
- // do firmware upload
- fw_pos = SP8870_FIRMWARE_OFFSET;
- while (fw_pos < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET){
- tx_len = (fw_pos <= SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET - 252) ? 252 : SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET - fw_pos;
- // write register 0xCF0A
- tx_buf[0] = 0xCF;
- tx_buf[1] = 0x0A;
- memcpy(&tx_buf[2], fw_buf + fw_pos, tx_len);
- msg.addr = state->config->demod_address;
- msg.flags = 0;
- msg.buf = tx_buf;
- msg.len = tx_len + 2;
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- printk("%s: firmware upload failed!\n", __FUNCTION__);
- printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err);
- return err;
- }
- fw_pos += tx_len;
- }
-
- dprintk ("%s: done!\n", __FUNCTION__);
- return 0;
-};
-
-static void sp8870_microcontroller_stop (struct sp8870_state* state)
-{
- sp8870_writereg(state, 0x0F08, 0x000);
- sp8870_writereg(state, 0x0F09, 0x000);
-
- // microcontroller STOP
- sp8870_writereg(state, 0x0F00, 0x000);
-}
-
-static void sp8870_microcontroller_start (struct sp8870_state* state)
-{
- sp8870_writereg(state, 0x0F08, 0x000);
- sp8870_writereg(state, 0x0F09, 0x000);
-
- // microcontroller START
- sp8870_writereg(state, 0x0F00, 0x001);
- // not documented but if we don't read 0x0D01 out here
- // we don't get a correct data valid signal
- sp8870_readreg(state, 0x0D01);
-}
-
-static int sp8870_read_data_valid_signal(struct sp8870_state* state)
-{
- return (sp8870_readreg(state, 0x0D02) > 0);
-}
-
-static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
-{
- int known_parameters = 1;
-
- *reg0xc05 = 0x000;
-
- switch (p->u.ofdm.constellation) {
- case QPSK:
- break;
- case QAM_16:
- *reg0xc05 |= (1 << 10);
- break;
- case QAM_64:
- *reg0xc05 |= (2 << 10);
- break;
- case QAM_AUTO:
- known_parameters = 0;
- break;
- default:
- return -EINVAL;
- };
-
- switch (p->u.ofdm.hierarchy_information) {
- case HIERARCHY_NONE:
- break;
- case HIERARCHY_1:
- *reg0xc05 |= (1 << 7);
- break;
- case HIERARCHY_2:
- *reg0xc05 |= (2 << 7);
- break;
- case HIERARCHY_4:
- *reg0xc05 |= (3 << 7);
- break;
- case HIERARCHY_AUTO:
- known_parameters = 0;
- break;
- default:
- return -EINVAL;
- };
-
- switch (p->u.ofdm.code_rate_HP) {
- case FEC_1_2:
- break;
- case FEC_2_3:
- *reg0xc05 |= (1 << 3);
- break;
- case FEC_3_4:
- *reg0xc05 |= (2 << 3);
- break;
- case FEC_5_6:
- *reg0xc05 |= (3 << 3);
- break;
- case FEC_7_8:
- *reg0xc05 |= (4 << 3);
- break;
- case FEC_AUTO:
- known_parameters = 0;
- break;
- default:
- return -EINVAL;
- };
-
- if (known_parameters)
- *reg0xc05 |= (2 << 1); /* use specified parameters */
- else
- *reg0xc05 |= (1 << 1); /* enable autoprobing */
-
- return 0;
-}
-
-static int sp8870_wake_up(struct sp8870_state* state)
-{
- // enable TS output and interface pins
- return sp8870_writereg(state, 0xC18, 0x00D);
-}
-
-static int sp8870_set_frontend_parameters (struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct sp8870_state* state = fe->demodulator_priv;
- int err;
- u16 reg0xc05;
-
- if ((err = configure_reg0xc05(p, &reg0xc05)))
- return err;
-
- // system controller stop
- sp8870_microcontroller_stop(state);
-
- // set tuner parameters
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- // sample rate correction bit [23..17]
- sp8870_writereg(state, 0x0319, 0x000A);
-
- // sample rate correction bit [16..0]
- sp8870_writereg(state, 0x031A, 0x0AAB);
-
- // integer carrier offset
- sp8870_writereg(state, 0x0309, 0x0400);
-
- // fractional carrier offset
- sp8870_writereg(state, 0x030A, 0x0000);
-
- // filter for 6/7/8 Mhz channel
- if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
- sp8870_writereg(state, 0x0311, 0x0002);
- else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
- sp8870_writereg(state, 0x0311, 0x0001);
- else
- sp8870_writereg(state, 0x0311, 0x0000);
-
- // scan order: 2k first = 0x0000, 8k first = 0x0001
- if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K)
- sp8870_writereg(state, 0x0338, 0x0000);
- else
- sp8870_writereg(state, 0x0338, 0x0001);
-
- sp8870_writereg(state, 0xc05, reg0xc05);
-
- // read status reg in order to clear pending irqs
- sp8870_readreg(state, 0x200);
-
- // system controller start
- sp8870_microcontroller_start(state);
-
- return 0;
-}
-
-static int sp8870_init (struct dvb_frontend* fe)
-{
- struct sp8870_state* state = fe->demodulator_priv;
- const struct firmware *fw = NULL;
-
- sp8870_wake_up(state);
- if (state->initialised) return 0;
- state->initialised = 1;
-
- dprintk ("%s\n", __FUNCTION__);
-
-
- /* request the firmware, this will block until someone uploads it */
- printk("sp8870: waiting for firmware upload (%s)...\n", SP8870_DEFAULT_FIRMWARE);
- if (state->config->request_firmware(fe, &fw, SP8870_DEFAULT_FIRMWARE)) {
- printk("sp8870: no firmware upload (timeout or file not found?)\n");
- return -EIO;
- }
-
- if (sp8870_firmware_upload(state, fw)) {
- printk("sp8870: writing firmware to device failed\n");
- release_firmware(fw);
- return -EIO;
- }
- release_firmware(fw);
- printk("sp8870: firmware upload complete\n");
-
- /* enable TS output and interface pins */
- sp8870_writereg(state, 0xc18, 0x00d);
-
- // system controller stop
- sp8870_microcontroller_stop(state);
-
- // ADC mode
- sp8870_writereg(state, 0x0301, 0x0003);
-
- // Reed Solomon parity bytes passed to output
- sp8870_writereg(state, 0x0C13, 0x0001);
-
- // MPEG clock is suppressed if no valid data
- sp8870_writereg(state, 0x0C14, 0x0001);
-
- /* bit 0x010: enable data valid signal */
- sp8870_writereg(state, 0x0D00, 0x010);
- sp8870_writereg(state, 0x0D01, 0x000);
-
- return 0;
-}
-
-static int sp8870_read_status (struct dvb_frontend* fe, fe_status_t * fe_status)
-{
- struct sp8870_state* state = fe->demodulator_priv;
- int status;
- int signal;
-
- *fe_status = 0;
-
- status = sp8870_readreg (state, 0x0200);
- if (status < 0)
- return -EIO;
-
- signal = sp8870_readreg (state, 0x0303);
- if (signal < 0)
- return -EIO;
-
- if (signal > 0x0F)
- *fe_status |= FE_HAS_SIGNAL;
- if (status & 0x08)
- *fe_status |= FE_HAS_SYNC;
- if (status & 0x04)
- *fe_status |= FE_HAS_LOCK | FE_HAS_CARRIER | FE_HAS_VITERBI;
-
- return 0;
-}
-
-static int sp8870_read_ber (struct dvb_frontend* fe, u32 * ber)
-{
- struct sp8870_state* state = fe->demodulator_priv;
- int ret;
- u32 tmp;
-
- *ber = 0;
-
- ret = sp8870_readreg(state, 0xC08);
- if (ret < 0)
- return -EIO;
-
- tmp = ret & 0x3F;
-
- ret = sp8870_readreg(state, 0xC07);
- if (ret < 0)
- return -EIO;
-
- tmp = ret << 6;
-
- if (tmp >= 0x3FFF0)
- tmp = ~0;
-
- *ber = tmp;
-
- return 0;
-}
-
-static int sp8870_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
-{
- struct sp8870_state* state = fe->demodulator_priv;
- int ret;
- u16 tmp;
-
- *signal = 0;
-
- ret = sp8870_readreg (state, 0x306);
- if (ret < 0)
- return -EIO;
-
- tmp = ret << 8;
-
- ret = sp8870_readreg (state, 0x303);
- if (ret < 0)
- return -EIO;
-
- tmp |= ret;
-
- if (tmp)
- *signal = 0xFFFF - tmp;
-
- return 0;
-}
-
-static int sp8870_read_uncorrected_blocks (struct dvb_frontend* fe, u32* ublocks)
-{
- struct sp8870_state* state = fe->demodulator_priv;
- int ret;
-
- *ublocks = 0;
-
- ret = sp8870_readreg(state, 0xC0C);
- if (ret < 0)
- return -EIO;
-
- if (ret == 0xFFFF)
- ret = ~0;
-
- *ublocks = ret;
-
- return 0;
-}
-
-// number of trials to recover from lockup
-#define MAXTRIALS 5
-// maximum checks for data valid signal
-#define MAXCHECKS 100
-
-// only for debugging: counter for detected lockups
-static int lockups = 0;
-// only for debugging: counter for channel switches
-static int switches = 0;
-
-static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct sp8870_state* state = fe->demodulator_priv;
-
- /*
- The firmware of the sp8870 sometimes locks up after setting frontend parameters.
- We try to detect this by checking the data valid signal.
- If it is not set after MAXCHECKS we try to recover the lockup by setting
- the frontend parameters again.
- */
-
- int err = 0;
- int valid = 0;
- int trials = 0;
- int check_count = 0;
-
- dprintk("%s: frequency = %i\n", __FUNCTION__, p->frequency);
-
- for (trials = 1; trials <= MAXTRIALS; trials++) {
-
- if ((err = sp8870_set_frontend_parameters(fe, p)))
- return err;
-
- for (check_count = 0; check_count < MAXCHECKS; check_count++) {
-// valid = ((sp8870_readreg(i2c, 0x0200) & 4) == 0);
- valid = sp8870_read_data_valid_signal(state);
- if (valid) {
- dprintk("%s: delay = %i usec\n",
- __FUNCTION__, check_count * 10);
- break;
- }
- udelay(10);
- }
- if (valid)
- break;
- }
-
- if (!valid) {
- printk("%s: firmware crash!!!!!!\n", __FUNCTION__);
- return -EIO;
- }
-
- if (debug) {
- if (valid) {
- if (trials > 1) {
- printk("%s: firmware lockup!!!\n", __FUNCTION__);
- printk("%s: recovered after %i trial(s))\n", __FUNCTION__, trials - 1);
- lockups++;
- }
- }
- switches++;
- printk("%s: switches = %i lockups = %i\n", __FUNCTION__, switches, lockups);
- }
-
- return 0;
-}
-
-static int sp8870_sleep(struct dvb_frontend* fe)
-{
- struct sp8870_state* state = fe->demodulator_priv;
-
- // tristate TS output and disable interface pins
- return sp8870_writereg(state, 0xC18, 0x000);
-}
-
-static int sp8870_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 350;
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static int sp8870_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct sp8870_state* state = fe->demodulator_priv;
-
- if (enable) {
- return sp8870_writereg(state, 0x206, 0x001);
- } else {
- return sp8870_writereg(state, 0x206, 0x000);
- }
-}
-
-static void sp8870_release(struct dvb_frontend* fe)
-{
- struct sp8870_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops sp8870_ops;
-
-struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
- struct i2c_adapter* i2c)
-{
- struct sp8870_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct sp8870_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->initialised = 0;
-
- /* check if the demod is there */
- if (sp8870_readreg(state, 0x0200) < 0) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &sp8870_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops sp8870_ops = {
-
- .info = {
- .name = "Spase SP8870 DVB-T",
- .type = FE_OFDM,
- .frequency_min = 470000000,
- .frequency_max = 860000000,
- .frequency_stepsize = 166666,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
- FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 |
- FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 |
- FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER
- },
-
- .release = sp8870_release,
-
- .init = sp8870_init,
- .sleep = sp8870_sleep,
- .i2c_gate_ctrl = sp8870_i2c_gate_ctrl,
-
- .set_frontend = sp8870_set_frontend,
- .get_tune_settings = sp8870_get_tune_settings,
-
- .read_status = sp8870_read_status,
- .read_ber = sp8870_read_ber,
- .read_signal_strength = sp8870_read_signal_strength,
- .read_ucblocks = sp8870_read_uncorrected_blocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Spase SP8870 DVB-T Demodulator driver");
-MODULE_AUTHOR("Juergen Peitz");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(sp8870_attach);
diff --git a/drivers/media/dvb/frontends/sp8870.h b/drivers/media/dvb/frontends/sp8870.h
deleted file mode 100644
index 93afbb969d6..00000000000
--- a/drivers/media/dvb/frontends/sp8870.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Driver for Spase SP8870 demodulator
-
- Copyright (C) 1999 Juergen Peitz
-
- 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.
-
-*/
-
-#ifndef SP8870_H
-#define SP8870_H
-
-#include <linux/dvb/frontend.h>
-#include <linux/firmware.h>
-
-struct sp8870_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* request firmware for device */
- int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
-};
-
-extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
- struct i2c_adapter* i2c);
-
-#endif // SP8870_H
diff --git a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c
deleted file mode 100644
index 5c2f8f4e0ae..00000000000
--- a/drivers/media/dvb/frontends/sp887x.c
+++ /dev/null
@@ -1,617 +0,0 @@
-/*
- Driver for the Spase sp887x demodulator
-*/
-
-/*
- * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to
- * download/extract it, and then copy it to /usr/lib/hotplug/firmware
- * or /lib/firmware (depending on configuration of firmware hotplug).
- */
-#define SP887X_DEFAULT_FIRMWARE "dvb-fe-sp887x.fw"
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/device.h>
-#include <linux/firmware.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "sp887x.h"
-
-
-struct sp887x_state {
- struct i2c_adapter* i2c;
- const struct sp887x_config* config;
- struct dvb_frontend frontend;
-
- /* demodulator private data */
- u8 initialised:1;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "sp887x: " args); \
- } while (0)
-
-static int i2c_writebytes (struct sp887x_state* state, u8 *buf, u8 len)
-{
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = len };
- int err;
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- printk ("%s: i2c write error (addr %02x, err == %i)\n",
- __FUNCTION__, state->config->demod_address, err);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static int sp887x_writereg (struct sp887x_state* state, u16 reg, u16 data)
-{
- u8 b0 [] = { reg >> 8 , reg & 0xff, data >> 8, data & 0xff };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 4 };
- int ret;
-
- if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- /**
- * in case of soft reset we ignore ACK errors...
- */
- if (!(reg == 0xf1a && data == 0x000 &&
- (ret == -EREMOTEIO || ret == -EFAULT)))
- {
- printk("%s: writereg error "
- "(reg %03x, data %03x, ret == %i)\n",
- __FUNCTION__, reg & 0xffff, data & 0xffff, ret);
- return ret;
- }
- }
-
- return 0;
-}
-
-static int sp887x_readreg (struct sp887x_state* state, u16 reg)
-{
- u8 b0 [] = { reg >> 8 , reg & 0xff };
- u8 b1 [2];
- int ret;
- struct i2c_msg msg[] = {{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }};
-
- if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) {
- printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
- return -1;
- }
-
- return (((b1[0] << 8) | b1[1]) & 0xfff);
-}
-
-static void sp887x_microcontroller_stop (struct sp887x_state* state)
-{
- dprintk("%s\n", __FUNCTION__);
- sp887x_writereg(state, 0xf08, 0x000);
- sp887x_writereg(state, 0xf09, 0x000);
-
- /* microcontroller STOP */
- sp887x_writereg(state, 0xf00, 0x000);
-}
-
-static void sp887x_microcontroller_start (struct sp887x_state* state)
-{
- dprintk("%s\n", __FUNCTION__);
- sp887x_writereg(state, 0xf08, 0x000);
- sp887x_writereg(state, 0xf09, 0x000);
-
- /* microcontroller START */
- sp887x_writereg(state, 0xf00, 0x001);
-}
-
-static void sp887x_setup_agc (struct sp887x_state* state)
-{
- /* setup AGC parameters */
- dprintk("%s\n", __FUNCTION__);
- sp887x_writereg(state, 0x33c, 0x054);
- sp887x_writereg(state, 0x33b, 0x04c);
- sp887x_writereg(state, 0x328, 0x000);
- sp887x_writereg(state, 0x327, 0x005);
- sp887x_writereg(state, 0x326, 0x001);
- sp887x_writereg(state, 0x325, 0x001);
- sp887x_writereg(state, 0x324, 0x001);
- sp887x_writereg(state, 0x318, 0x050);
- sp887x_writereg(state, 0x317, 0x3fe);
- sp887x_writereg(state, 0x316, 0x001);
- sp887x_writereg(state, 0x313, 0x005);
- sp887x_writereg(state, 0x312, 0x002);
- sp887x_writereg(state, 0x306, 0x000);
- sp887x_writereg(state, 0x303, 0x000);
-}
-
-#define BLOCKSIZE 30
-#define FW_SIZE 0x4000
-/**
- * load firmware and setup MPEG interface...
- */
-static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware *fw)
-{
- struct sp887x_state* state = fe->demodulator_priv;
- u8 buf [BLOCKSIZE+2];
- int i;
- int fw_size = fw->size;
- unsigned char *mem = fw->data;
-
- dprintk("%s\n", __FUNCTION__);
-
- /* ignore the first 10 bytes, then we expect 0x4000 bytes of firmware */
- if (fw_size < FW_SIZE+10)
- return -ENODEV;
-
- mem = fw->data + 10;
-
- /* soft reset */
- sp887x_writereg(state, 0xf1a, 0x000);
-
- sp887x_microcontroller_stop (state);
-
- printk ("%s: firmware upload... ", __FUNCTION__);
-
- /* setup write pointer to -1 (end of memory) */
- /* bit 0x8000 in address is set to enable 13bit mode */
- sp887x_writereg(state, 0x8f08, 0x1fff);
-
- /* dummy write (wrap around to start of memory) */
- sp887x_writereg(state, 0x8f0a, 0x0000);
-
- for (i = 0; i < FW_SIZE; i += BLOCKSIZE) {
- int c = BLOCKSIZE;
- int err;
-
- if (i+c > FW_SIZE)
- c = FW_SIZE - i;
-
- /* bit 0x8000 in address is set to enable 13bit mode */
- /* bit 0x4000 enables multibyte read/write transfers */
- /* write register is 0xf0a */
- buf[0] = 0xcf;
- buf[1] = 0x0a;
-
- memcpy(&buf[2], mem + i, c);
-
- if ((err = i2c_writebytes (state, buf, c+2)) < 0) {
- printk ("failed.\n");
- printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err);
- return err;
- }
- }
-
- /* don't write RS bytes between packets */
- sp887x_writereg(state, 0xc13, 0x001);
-
- /* suppress clock if (!data_valid) */
- sp887x_writereg(state, 0xc14, 0x000);
-
- /* setup MPEG interface... */
- sp887x_writereg(state, 0xc1a, 0x872);
- sp887x_writereg(state, 0xc1b, 0x001);
- sp887x_writereg(state, 0xc1c, 0x000); /* parallel mode (serial mode == 1) */
- sp887x_writereg(state, 0xc1a, 0x871);
-
- /* ADC mode, 2 for MT8872, 3 for SP8870/SP8871 */
- sp887x_writereg(state, 0x301, 0x002);
-
- sp887x_setup_agc(state);
-
- /* bit 0x010: enable data valid signal */
- sp887x_writereg(state, 0xd00, 0x010);
- sp887x_writereg(state, 0x0d1, 0x000);
- return 0;
-};
-
-static int configure_reg0xc05 (struct dvb_frontend_parameters *p, u16 *reg0xc05)
-{
- int known_parameters = 1;
-
- *reg0xc05 = 0x000;
-
- switch (p->u.ofdm.constellation) {
- case QPSK:
- break;
- case QAM_16:
- *reg0xc05 |= (1 << 10);
- break;
- case QAM_64:
- *reg0xc05 |= (2 << 10);
- break;
- case QAM_AUTO:
- known_parameters = 0;
- break;
- default:
- return -EINVAL;
- };
-
- switch (p->u.ofdm.hierarchy_information) {
- case HIERARCHY_NONE:
- break;
- case HIERARCHY_1:
- *reg0xc05 |= (1 << 7);
- break;
- case HIERARCHY_2:
- *reg0xc05 |= (2 << 7);
- break;
- case HIERARCHY_4:
- *reg0xc05 |= (3 << 7);
- break;
- case HIERARCHY_AUTO:
- known_parameters = 0;
- break;
- default:
- return -EINVAL;
- };
-
- switch (p->u.ofdm.code_rate_HP) {
- case FEC_1_2:
- break;
- case FEC_2_3:
- *reg0xc05 |= (1 << 3);
- break;
- case FEC_3_4:
- *reg0xc05 |= (2 << 3);
- break;
- case FEC_5_6:
- *reg0xc05 |= (3 << 3);
- break;
- case FEC_7_8:
- *reg0xc05 |= (4 << 3);
- break;
- case FEC_AUTO:
- known_parameters = 0;
- break;
- default:
- return -EINVAL;
- };
-
- if (known_parameters)
- *reg0xc05 |= (2 << 1); /* use specified parameters */
- else
- *reg0xc05 |= (1 << 1); /* enable autoprobing */
-
- return 0;
-}
-
-/**
- * estimates division of two 24bit numbers,
- * derived from the ves1820/stv0299 driver code
- */
-static void divide (int n, int d, int *quotient_i, int *quotient_f)
-{
- unsigned int q, r;
-
- r = (n % d) << 8;
- q = (r / d);
-
- if (quotient_i)
- *quotient_i = q;
-
- if (quotient_f) {
- r = (r % d) << 8;
- q = (q << 8) | (r / d);
- r = (r % d) << 8;
- *quotient_f = (q << 8) | (r / d);
- }
-}
-
-static void sp887x_correct_offsets (struct sp887x_state* state,
- struct dvb_frontend_parameters *p,
- int actual_freq)
-{
- static const u32 srate_correction [] = { 1879617, 4544878, 8098561 };
- int bw_index = p->u.ofdm.bandwidth - BANDWIDTH_8_MHZ;
- int freq_offset = actual_freq - p->frequency;
- int sysclock = 61003; //[kHz]
- int ifreq = 36000000;
- int freq;
- int frequency_shift;
-
- if (p->inversion == INVERSION_ON)
- freq = ifreq - freq_offset;
- else
- freq = ifreq + freq_offset;
-
- divide(freq / 333, sysclock, NULL, &frequency_shift);
-
- if (p->inversion == INVERSION_ON)
- frequency_shift = -frequency_shift;
-
- /* sample rate correction */
- sp887x_writereg(state, 0x319, srate_correction[bw_index] >> 12);
- sp887x_writereg(state, 0x31a, srate_correction[bw_index] & 0xfff);
-
- /* carrier offset correction */
- sp887x_writereg(state, 0x309, frequency_shift >> 12);
- sp887x_writereg(state, 0x30a, frequency_shift & 0xfff);
-}
-
-static int sp887x_setup_frontend_parameters (struct dvb_frontend* fe,
- struct dvb_frontend_parameters *p)
-{
- struct sp887x_state* state = fe->demodulator_priv;
- int actual_freq, err;
- u16 val, reg0xc05;
-
- if (p->u.ofdm.bandwidth != BANDWIDTH_8_MHZ &&
- p->u.ofdm.bandwidth != BANDWIDTH_7_MHZ &&
- p->u.ofdm.bandwidth != BANDWIDTH_6_MHZ)
- return -EINVAL;
-
- if ((err = configure_reg0xc05(p, &reg0xc05)))
- return err;
-
- sp887x_microcontroller_stop(state);
-
- /* setup the PLL */
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
- if (fe->ops.tuner_ops.get_frequency) {
- fe->ops.tuner_ops.get_frequency(fe, &actual_freq);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- } else {
- actual_freq = p->frequency;
- }
-
- /* read status reg in order to clear <pending irqs */
- sp887x_readreg(state, 0x200);
-
- sp887x_correct_offsets(state, p, actual_freq);
-
- /* filter for 6/7/8 Mhz channel */
- if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
- val = 2;
- else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
- val = 1;
- else
- val = 0;
-
- sp887x_writereg(state, 0x311, val);
-
- /* scan order: 2k first = 0, 8k first = 1 */
- if (p->u.ofdm.transmission_mode == TRANSMISSION_MODE_2K)
- sp887x_writereg(state, 0x338, 0x000);
- else
- sp887x_writereg(state, 0x338, 0x001);
-
- sp887x_writereg(state, 0xc05, reg0xc05);
-
- if (p->u.ofdm.bandwidth == BANDWIDTH_6_MHZ)
- val = 2 << 3;
- else if (p->u.ofdm.bandwidth == BANDWIDTH_7_MHZ)
- val = 3 << 3;
- else
- val = 0 << 3;
-
- /* enable OFDM and SAW bits as lock indicators in sync register 0xf17,
- * optimize algorithm for given bandwidth...
- */
- sp887x_writereg(state, 0xf14, 0x160 | val);
- sp887x_writereg(state, 0xf15, 0x000);
-
- sp887x_microcontroller_start(state);
- return 0;
-}
-
-static int sp887x_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct sp887x_state* state = fe->demodulator_priv;
- u16 snr12 = sp887x_readreg(state, 0xf16);
- u16 sync0x200 = sp887x_readreg(state, 0x200);
- u16 sync0xf17 = sp887x_readreg(state, 0xf17);
-
- *status = 0;
-
- if (snr12 > 0x00f)
- *status |= FE_HAS_SIGNAL;
-
- //if (sync0x200 & 0x004)
- // *status |= FE_HAS_SYNC | FE_HAS_CARRIER;
-
- //if (sync0x200 & 0x008)
- // *status |= FE_HAS_VITERBI;
-
- if ((sync0xf17 & 0x00f) == 0x002) {
- *status |= FE_HAS_LOCK;
- *status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_CARRIER;
- }
-
- if (sync0x200 & 0x001) { /* tuner adjustment requested...*/
- int steps = (sync0x200 >> 4) & 0x00f;
- if (steps & 0x008)
- steps = -steps;
- dprintk("sp887x: implement tuner adjustment (%+i steps)!!\n",
- steps);
- }
-
- return 0;
-}
-
-static int sp887x_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct sp887x_state* state = fe->demodulator_priv;
-
- *ber = (sp887x_readreg(state, 0xc08) & 0x3f) |
- (sp887x_readreg(state, 0xc07) << 6);
- sp887x_writereg(state, 0xc08, 0x000);
- sp887x_writereg(state, 0xc07, 0x000);
- if (*ber >= 0x3fff0)
- *ber = ~0;
-
- return 0;
-}
-
-static int sp887x_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct sp887x_state* state = fe->demodulator_priv;
-
- u16 snr12 = sp887x_readreg(state, 0xf16);
- u32 signal = 3 * (snr12 << 4);
- *strength = (signal < 0xffff) ? signal : 0xffff;
-
- return 0;
-}
-
-static int sp887x_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct sp887x_state* state = fe->demodulator_priv;
-
- u16 snr12 = sp887x_readreg(state, 0xf16);
- *snr = (snr12 << 4) | (snr12 >> 8);
-
- return 0;
-}
-
-static int sp887x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct sp887x_state* state = fe->demodulator_priv;
-
- *ucblocks = sp887x_readreg(state, 0xc0c);
- if (*ucblocks == 0xfff)
- *ucblocks = ~0;
-
- return 0;
-}
-
-static int sp887x_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct sp887x_state* state = fe->demodulator_priv;
-
- if (enable) {
- return sp887x_writereg(state, 0x206, 0x001);
- } else {
- return sp887x_writereg(state, 0x206, 0x000);
- }
-}
-
-static int sp887x_sleep(struct dvb_frontend* fe)
-{
- struct sp887x_state* state = fe->demodulator_priv;
-
- /* tristate TS output and disable interface pins */
- sp887x_writereg(state, 0xc18, 0x000);
-
- return 0;
-}
-
-static int sp887x_init(struct dvb_frontend* fe)
-{
- struct sp887x_state* state = fe->demodulator_priv;
- const struct firmware *fw = NULL;
- int ret;
-
- if (!state->initialised) {
- /* request the firmware, this will block until someone uploads it */
- printk("sp887x: waiting for firmware upload (%s)...\n", SP887X_DEFAULT_FIRMWARE);
- ret = state->config->request_firmware(fe, &fw, SP887X_DEFAULT_FIRMWARE);
- if (ret) {
- printk("sp887x: no firmware upload (timeout or file not found?)\n");
- return ret;
- }
-
- ret = sp887x_initial_setup(fe, fw);
- release_firmware(fw);
- if (ret) {
- printk("sp887x: writing firmware to device failed\n");
- return ret;
- }
- printk("sp887x: firmware upload complete\n");
- state->initialised = 1;
- }
-
- /* enable TS output and interface pins */
- sp887x_writereg(state, 0xc18, 0x00d);
-
- return 0;
-}
-
-static int sp887x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 350;
- fesettings->step_size = 166666*2;
- fesettings->max_drift = (166666*2)+1;
- return 0;
-}
-
-static void sp887x_release(struct dvb_frontend* fe)
-{
- struct sp887x_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops sp887x_ops;
-
-struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
- struct i2c_adapter* i2c)
-{
- struct sp887x_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct sp887x_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->initialised = 0;
-
- /* check if the demod is there */
- if (sp887x_readreg(state, 0x0200) < 0) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &sp887x_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops sp887x_ops = {
-
- .info = {
- .name = "Spase SP887x DVB-T",
- .type = FE_OFDM,
- .frequency_min = 50500000,
- .frequency_max = 858000000,
- .frequency_stepsize = 166666,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
- FE_CAN_RECOVER
- },
-
- .release = sp887x_release,
-
- .init = sp887x_init,
- .sleep = sp887x_sleep,
- .i2c_gate_ctrl = sp887x_i2c_gate_ctrl,
-
- .set_frontend = sp887x_setup_frontend_parameters,
- .get_tune_settings = sp887x_get_tune_settings,
-
- .read_status = sp887x_read_status,
- .read_ber = sp887x_read_ber,
- .read_signal_strength = sp887x_read_signal_strength,
- .read_snr = sp887x_read_snr,
- .read_ucblocks = sp887x_read_ucblocks,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Spase sp887x DVB-T demodulator driver");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(sp887x_attach);
diff --git a/drivers/media/dvb/frontends/sp887x.h b/drivers/media/dvb/frontends/sp887x.h
deleted file mode 100644
index c44b0ebdf1e..00000000000
--- a/drivers/media/dvb/frontends/sp887x.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- Driver for the Spase sp887x demodulator
-*/
-
-#ifndef SP887X_H
-#define SP887X_H
-
-#include <linux/dvb/frontend.h>
-#include <linux/firmware.h>
-
-struct sp887x_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* request firmware for device */
- int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
-};
-
-extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
- struct i2c_adapter* i2c);
-
-#endif // SP887X_H
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c
deleted file mode 100644
index 1ca64249010..00000000000
--- a/drivers/media/dvb/frontends/stv0297.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- Driver for STV0297 demodulator
-
- Copyright (C) 2004 Andrew de Quincey <adq_dvb@lidskialf.net>
- Copyright (C) 2003-2004 Dennis Noermann <dennis.noermann@noernet.de>
-
- 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/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/delay.h>
-#include <linux/jiffies.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "stv0297.h"
-
-struct stv0297_state {
- struct i2c_adapter *i2c;
- const struct stv0297_config *config;
- struct dvb_frontend frontend;
-
- unsigned long base_freq;
-};
-
-#if 1
-#define dprintk(x...) printk(x)
-#else
-#define dprintk(x...)
-#endif
-
-#define STV0297_CLOCK_KHZ 28900
-
-
-static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data)
-{
- int ret;
- u8 buf[] = { reg, data };
- struct i2c_msg msg = {.addr = state->config->demod_address,.flags = 0,.buf = buf,.len = 2 };
-
- ret = i2c_transfer(state->i2c, &msg, 1);
-
- if (ret != 1)
- dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, "
- "ret == %i)\n", __FUNCTION__, reg, data, ret);
-
- return (ret != 1) ? -1 : 0;
-}
-
-static int stv0297_readreg(struct stv0297_state *state, u8 reg)
-{
- int ret;
- u8 b0[] = { reg };
- u8 b1[] = { 0 };
- struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 1},
- {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1}
- };
-
- // this device needs a STOP between the register and data
- if (state->config->stop_during_read) {
- if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) {
- dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret);
- return -1;
- }
- if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) {
- dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret);
- return -1;
- }
- } else {
- if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) {
- dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret);
- return -1;
- }
- }
-
- return b1[0];
-}
-
-static int stv0297_writereg_mask(struct stv0297_state *state, u8 reg, u8 mask, u8 data)
-{
- int val;
-
- val = stv0297_readreg(state, reg);
- val &= ~mask;
- val |= (data & mask);
- stv0297_writereg(state, reg, val);
-
- return 0;
-}
-
-static int stv0297_readregs(struct stv0297_state *state, u8 reg1, u8 * b, u8 len)
-{
- int ret;
- struct i2c_msg msg[] = { {.addr = state->config->demod_address,.flags = 0,.buf =
- &reg1,.len = 1},
- {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b,.len = len}
- };
-
- // this device needs a STOP between the register and data
- if (state->config->stop_during_read) {
- if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) {
- dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret);
- return -1;
- }
- if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) {
- dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret);
- return -1;
- }
- } else {
- if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) {
- dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret);
- return -1;
- }
- }
-
- return 0;
-}
-
-static u32 stv0297_get_symbolrate(struct stv0297_state *state)
-{
- u64 tmp;
-
- tmp = stv0297_readreg(state, 0x55);
- tmp |= stv0297_readreg(state, 0x56) << 8;
- tmp |= stv0297_readreg(state, 0x57) << 16;
- tmp |= stv0297_readreg(state, 0x58) << 24;
-
- tmp *= STV0297_CLOCK_KHZ;
- tmp >>= 32;
-
- return (u32) tmp;
-}
-
-static void stv0297_set_symbolrate(struct stv0297_state *state, u32 srate)
-{
- long tmp;
-
- tmp = 131072L * srate; /* 131072 = 2^17 */
- tmp = tmp / (STV0297_CLOCK_KHZ / 4); /* 1/4 = 2^-2 */
- tmp = tmp * 8192L; /* 8192 = 2^13 */
-
- stv0297_writereg(state, 0x55, (unsigned char) (tmp & 0xFF));
- stv0297_writereg(state, 0x56, (unsigned char) (tmp >> 8));
- stv0297_writereg(state, 0x57, (unsigned char) (tmp >> 16));
- stv0297_writereg(state, 0x58, (unsigned char) (tmp >> 24));
-}
-
-static void stv0297_set_sweeprate(struct stv0297_state *state, short fshift, long symrate)
-{
- long tmp;
-
- tmp = (long) fshift *262144L; /* 262144 = 2*18 */
- tmp /= symrate;
- tmp *= 1024; /* 1024 = 2*10 */
-
- // adjust
- if (tmp >= 0) {
- tmp += 500000;
- } else {
- tmp -= 500000;
- }
- tmp /= 1000000;
-
- stv0297_writereg(state, 0x60, tmp & 0xFF);
- stv0297_writereg_mask(state, 0x69, 0xF0, (tmp >> 4) & 0xf0);
-}
-
-static void stv0297_set_carrieroffset(struct stv0297_state *state, long offset)
-{
- long tmp;
-
- /* symrate is hardcoded to 10000 */
- tmp = offset * 26844L; /* (2**28)/10000 */
- if (tmp < 0)
- tmp += 0x10000000;
- tmp &= 0x0FFFFFFF;
-
- stv0297_writereg(state, 0x66, (unsigned char) (tmp & 0xFF));
- stv0297_writereg(state, 0x67, (unsigned char) (tmp >> 8));
- stv0297_writereg(state, 0x68, (unsigned char) (tmp >> 16));
- stv0297_writereg_mask(state, 0x69, 0x0F, (tmp >> 24) & 0x0f);
-}
-
-/*
-static long stv0297_get_carrieroffset(struct stv0297_state *state)
-{
- s64 tmp;
-
- stv0297_writereg(state, 0x6B, 0x00);
-
- tmp = stv0297_readreg(state, 0x66);
- tmp |= (stv0297_readreg(state, 0x67) << 8);
- tmp |= (stv0297_readreg(state, 0x68) << 16);
- tmp |= (stv0297_readreg(state, 0x69) & 0x0F) << 24;
-
- tmp *= stv0297_get_symbolrate(state);
- tmp >>= 28;
-
- return (s32) tmp;
-}
-*/
-
-static void stv0297_set_initialdemodfreq(struct stv0297_state *state, long freq)
-{
- s32 tmp;
-
- if (freq > 10000)
- freq -= STV0297_CLOCK_KHZ;
-
- tmp = (STV0297_CLOCK_KHZ * 1000) / (1 << 16);
- tmp = (freq * 1000) / tmp;
- if (tmp > 0xffff)
- tmp = 0xffff;
-
- stv0297_writereg_mask(state, 0x25, 0x80, 0x80);
- stv0297_writereg(state, 0x21, tmp >> 8);
- stv0297_writereg(state, 0x20, tmp);
-}
-
-static int stv0297_set_qam(struct stv0297_state *state, fe_modulation_t modulation)
-{
- int val = 0;
-
- switch (modulation) {
- case QAM_16:
- val = 0;
- break;
-
- case QAM_32:
- val = 1;
- break;
-
- case QAM_64:
- val = 4;
- break;
-
- case QAM_128:
- val = 2;
- break;
-
- case QAM_256:
- val = 3;
- break;
-
- default:
- return -EINVAL;
- }
-
- stv0297_writereg_mask(state, 0x00, 0x70, val << 4);
-
- return 0;
-}
-
-static int stv0297_set_inversion(struct stv0297_state *state, fe_spectral_inversion_t inversion)
-{
- int val = 0;
-
- switch (inversion) {
- case INVERSION_OFF:
- val = 0;
- break;
-
- case INVERSION_ON:
- val = 1;
- break;
-
- default:
- return -EINVAL;
- }
-
- stv0297_writereg_mask(state, 0x83, 0x08, val << 3);
-
- return 0;
-}
-
-static int stv0297_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
-{
- struct stv0297_state *state = fe->demodulator_priv;
-
- if (enable) {
- stv0297_writereg(state, 0x87, 0x78);
- stv0297_writereg(state, 0x86, 0xc8);
- }
-
- return 0;
-}
-
-static int stv0297_init(struct dvb_frontend *fe)
-{
- struct stv0297_state *state = fe->demodulator_priv;
- int i;
-
- /* load init table */
- for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2)
- stv0297_writereg(state, state->config->inittab[i], state->config->inittab[i+1]);
- msleep(200);
-
- return 0;
-}
-
-static int stv0297_sleep(struct dvb_frontend *fe)
-{
- struct stv0297_state *state = fe->demodulator_priv;
-
- stv0297_writereg_mask(state, 0x80, 1, 1);
-
- return 0;
-}
-
-static int stv0297_read_status(struct dvb_frontend *fe, fe_status_t * status)
-{
- struct stv0297_state *state = fe->demodulator_priv;
-
- u8 sync = stv0297_readreg(state, 0xDF);
-
- *status = 0;
- if (sync & 0x80)
- *status |=
- FE_HAS_SYNC | FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_LOCK;
- return 0;
-}
-
-static int stv0297_read_ber(struct dvb_frontend *fe, u32 * ber)
-{
- struct stv0297_state *state = fe->demodulator_priv;
- u8 BER[3];
-
- stv0297_writereg(state, 0xA0, 0x80); // Start Counting bit errors for 4096 Bytes
- mdelay(25); // Hopefully got 4096 Bytes
- stv0297_readregs(state, 0xA0, BER, 3);
- mdelay(25);
- *ber = (BER[2] << 8 | BER[1]) / (8 * 4096);
-
- return 0;
-}
-
-
-static int stv0297_read_signal_strength(struct dvb_frontend *fe, u16 * strength)
-{
- struct stv0297_state *state = fe->demodulator_priv;
- u8 STRENGTH[2];
-
- stv0297_readregs(state, 0x41, STRENGTH, 2);
- *strength = (STRENGTH[1] & 0x03) << 8 | STRENGTH[0];
-
- return 0;
-}
-
-static int stv0297_read_snr(struct dvb_frontend *fe, u16 * snr)
-{
- struct stv0297_state *state = fe->demodulator_priv;
- u8 SNR[2];
-
- stv0297_readregs(state, 0x07, SNR, 2);
- *snr = SNR[1] << 8 | SNR[0];
-
- return 0;
-}
-
-static int stv0297_read_ucblocks(struct dvb_frontend *fe, u32 * ucblocks)
-{
- struct stv0297_state *state = fe->demodulator_priv;
-
- *ucblocks = (stv0297_readreg(state, 0xD5) << 8)
- | stv0297_readreg(state, 0xD4);
-
- return 0;
-}
-
-static int stv0297_set_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
-{
- struct stv0297_state *state = fe->demodulator_priv;
- int u_threshold;
- int initial_u;
- int blind_u;
- int delay;
- int sweeprate;
- int carrieroffset;
- unsigned long starttime;
- unsigned long timeout;
- fe_spectral_inversion_t inversion;
-
- switch (p->u.qam.modulation) {
- case QAM_16:
- case QAM_32:
- case QAM_64:
- delay = 100;
- sweeprate = 1000;
- break;
-
- case QAM_128:
- case QAM_256:
- delay = 200;
- sweeprate = 500;
- break;
-
- default:
- return -EINVAL;
- }
-
- // determine inversion dependant parameters
- inversion = p->inversion;
- if (state->config->invert)
- inversion = (inversion == INVERSION_ON) ? INVERSION_OFF : INVERSION_ON;
- carrieroffset = -330;
- switch (inversion) {
- case INVERSION_OFF:
- break;
-
- case INVERSION_ON:
- sweeprate = -sweeprate;
- carrieroffset = -carrieroffset;
- break;
-
- default:
- return -EINVAL;
- }
-
- stv0297_init(fe);
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- /* clear software interrupts */
- stv0297_writereg(state, 0x82, 0x0);
-
- /* set initial demodulation frequency */
- stv0297_set_initialdemodfreq(state, 7250);
-
- /* setup AGC */
- stv0297_writereg_mask(state, 0x43, 0x10, 0x00);
- stv0297_writereg(state, 0x41, 0x00);
- stv0297_writereg_mask(state, 0x42, 0x03, 0x01);
- stv0297_writereg_mask(state, 0x36, 0x60, 0x00);
- stv0297_writereg_mask(state, 0x36, 0x18, 0x00);
- stv0297_writereg_mask(state, 0x71, 0x80, 0x80);
- stv0297_writereg(state, 0x72, 0x00);
- stv0297_writereg(state, 0x73, 0x00);
- stv0297_writereg_mask(state, 0x74, 0x0F, 0x00);
- stv0297_writereg_mask(state, 0x43, 0x08, 0x00);
- stv0297_writereg_mask(state, 0x71, 0x80, 0x00);
-
- /* setup STL */
- stv0297_writereg_mask(state, 0x5a, 0x20, 0x20);
- stv0297_writereg_mask(state, 0x5b, 0x02, 0x02);
- stv0297_writereg_mask(state, 0x5b, 0x02, 0x00);
- stv0297_writereg_mask(state, 0x5b, 0x01, 0x00);
- stv0297_writereg_mask(state, 0x5a, 0x40, 0x40);
-
- /* disable frequency sweep */
- stv0297_writereg_mask(state, 0x6a, 0x01, 0x00);
-
- /* reset deinterleaver */
- stv0297_writereg_mask(state, 0x81, 0x01, 0x01);
- stv0297_writereg_mask(state, 0x81, 0x01, 0x00);
-
- /* ??? */
- stv0297_writereg_mask(state, 0x83, 0x20, 0x20);
- stv0297_writereg_mask(state, 0x83, 0x20, 0x00);
-
- /* reset equaliser */
- u_threshold = stv0297_readreg(state, 0x00) & 0xf;
- initial_u = stv0297_readreg(state, 0x01) >> 4;
- blind_u = stv0297_readreg(state, 0x01) & 0xf;
- stv0297_writereg_mask(state, 0x84, 0x01, 0x01);
- stv0297_writereg_mask(state, 0x84, 0x01, 0x00);
- stv0297_writereg_mask(state, 0x00, 0x0f, u_threshold);
- stv0297_writereg_mask(state, 0x01, 0xf0, initial_u << 4);
- stv0297_writereg_mask(state, 0x01, 0x0f, blind_u);
-
- /* data comes from internal A/D */
- stv0297_writereg_mask(state, 0x87, 0x80, 0x00);
-
- /* clear phase registers */
- stv0297_writereg(state, 0x63, 0x00);
- stv0297_writereg(state, 0x64, 0x00);
- stv0297_writereg(state, 0x65, 0x00);
- stv0297_writereg(state, 0x66, 0x00);
- stv0297_writereg(state, 0x67, 0x00);
- stv0297_writereg(state, 0x68, 0x00);
- stv0297_writereg_mask(state, 0x69, 0x0f, 0x00);
-
- /* set parameters */
- stv0297_set_qam(state, p->u.qam.modulation);
- stv0297_set_symbolrate(state, p->u.qam.symbol_rate / 1000);
- stv0297_set_sweeprate(state, sweeprate, p->u.qam.symbol_rate / 1000);
- stv0297_set_carrieroffset(state, carrieroffset);
- stv0297_set_inversion(state, inversion);
-
- /* kick off lock */
- /* Disable corner detection for higher QAMs */
- if (p->u.qam.modulation == QAM_128 ||
- p->u.qam.modulation == QAM_256)
- stv0297_writereg_mask(state, 0x88, 0x08, 0x00);
- else
- stv0297_writereg_mask(state, 0x88, 0x08, 0x08);
-
- stv0297_writereg_mask(state, 0x5a, 0x20, 0x00);
- stv0297_writereg_mask(state, 0x6a, 0x01, 0x01);
- stv0297_writereg_mask(state, 0x43, 0x40, 0x40);
- stv0297_writereg_mask(state, 0x5b, 0x30, 0x00);
- stv0297_writereg_mask(state, 0x03, 0x0c, 0x0c);
- stv0297_writereg_mask(state, 0x03, 0x03, 0x03);
- stv0297_writereg_mask(state, 0x43, 0x10, 0x10);
-
- /* wait for WGAGC lock */
- starttime = jiffies;
- timeout = jiffies + msecs_to_jiffies(2000);
- while (time_before(jiffies, timeout)) {
- msleep(10);
- if (stv0297_readreg(state, 0x43) & 0x08)
- break;
- }
- if (time_after(jiffies, timeout)) {
- goto timeout;
- }
- msleep(20);
-
- /* wait for equaliser partial convergence */
- timeout = jiffies + msecs_to_jiffies(500);
- while (time_before(jiffies, timeout)) {
- msleep(10);
-
- if (stv0297_readreg(state, 0x82) & 0x04) {
- break;
- }
- }
- if (time_after(jiffies, timeout)) {
- goto timeout;
- }
-
- /* wait for equaliser full convergence */
- timeout = jiffies + msecs_to_jiffies(delay);
- while (time_before(jiffies, timeout)) {
- msleep(10);
-
- if (stv0297_readreg(state, 0x82) & 0x08) {
- break;
- }
- }
- if (time_after(jiffies, timeout)) {
- goto timeout;
- }
-
- /* disable sweep */
- stv0297_writereg_mask(state, 0x6a, 1, 0);
- stv0297_writereg_mask(state, 0x88, 8, 0);
-
- /* wait for main lock */
- timeout = jiffies + msecs_to_jiffies(20);
- while (time_before(jiffies, timeout)) {
- msleep(10);
-
- if (stv0297_readreg(state, 0xDF) & 0x80) {
- break;
- }
- }
- if (time_after(jiffies, timeout)) {
- goto timeout;
- }
- msleep(100);
-
- /* is it still locked after that delay? */
- if (!(stv0297_readreg(state, 0xDF) & 0x80)) {
- goto timeout;
- }
-
- /* success!! */
- stv0297_writereg_mask(state, 0x5a, 0x40, 0x00);
- state->base_freq = p->frequency;
- return 0;
-
-timeout:
- stv0297_writereg_mask(state, 0x6a, 0x01, 0x00);
- return 0;
-}
-
-static int stv0297_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p)
-{
- struct stv0297_state *state = fe->demodulator_priv;
- int reg_00, reg_83;
-
- reg_00 = stv0297_readreg(state, 0x00);
- reg_83 = stv0297_readreg(state, 0x83);
-
- p->frequency = state->base_freq;
- p->inversion = (reg_83 & 0x08) ? INVERSION_ON : INVERSION_OFF;
- if (state->config->invert)
- p->inversion = (p->inversion == INVERSION_ON) ? INVERSION_OFF : INVERSION_ON;
- p->u.qam.symbol_rate = stv0297_get_symbolrate(state) * 1000;
- p->u.qam.fec_inner = FEC_NONE;
-
- switch ((reg_00 >> 4) & 0x7) {
- case 0:
- p->u.qam.modulation = QAM_16;
- break;
- case 1:
- p->u.qam.modulation = QAM_32;
- break;
- case 2:
- p->u.qam.modulation = QAM_128;
- break;
- case 3:
- p->u.qam.modulation = QAM_256;
- break;
- case 4:
- p->u.qam.modulation = QAM_64;
- break;
- }
-
- return 0;
-}
-
-static void stv0297_release(struct dvb_frontend *fe)
-{
- struct stv0297_state *state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops stv0297_ops;
-
-struct dvb_frontend *stv0297_attach(const struct stv0297_config *config,
- struct i2c_adapter *i2c)
-{
- struct stv0297_state *state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct stv0297_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->base_freq = 0;
-
- /* check if the demod is there */
- if ((stv0297_readreg(state, 0x80) & 0x70) != 0x20)
- goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &stv0297_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops stv0297_ops = {
-
- .info = {
- .name = "ST STV0297 DVB-C",
- .type = FE_QAM,
- .frequency_min = 64000000,
- .frequency_max = 1300000000,
- .frequency_stepsize = 62500,
- .symbol_rate_min = 870000,
- .symbol_rate_max = 11700000,
- .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
- FE_CAN_QAM_128 | FE_CAN_QAM_256 | FE_CAN_FEC_AUTO},
-
- .release = stv0297_release,
-
- .init = stv0297_init,
- .sleep = stv0297_sleep,
- .i2c_gate_ctrl = stv0297_i2c_gate_ctrl,
-
- .set_frontend = stv0297_set_frontend,
- .get_frontend = stv0297_get_frontend,
-
- .read_status = stv0297_read_status,
- .read_ber = stv0297_read_ber,
- .read_signal_strength = stv0297_read_signal_strength,
- .read_snr = stv0297_read_snr,
- .read_ucblocks = stv0297_read_ucblocks,
-};
-
-MODULE_DESCRIPTION("ST STV0297 DVB-C Demodulator driver");
-MODULE_AUTHOR("Dennis Noermann and Andrew de Quincey");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(stv0297_attach);
diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h
deleted file mode 100644
index 1da5384fb98..00000000000
--- a/drivers/media/dvb/frontends/stv0297.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Driver for STV0297 demodulator
-
- Copyright (C) 2003-2004 Dennis Noermann <dennis.noermann@noernet.de>
-
- 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.
-*/
-
-#ifndef STV0297_H
-#define STV0297_H
-
-#include <linux/dvb/frontend.h>
-#include "dvb_frontend.h"
-
-struct stv0297_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* inittab - array of pairs of values.
- * First of each pair is the register, second is the value.
- * List should be terminated with an 0xff, 0xff pair.
- */
- u8* inittab;
-
- /* does the "inversion" need inverted? */
- u8 invert:1;
-
- /* set to 1 if the device requires an i2c STOP during reading */
- u8 stop_during_read:1;
-};
-
-extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config,
- struct i2c_adapter* i2c);
-
-#endif // STV0297_H
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
deleted file mode 100644
index 96648a75440..00000000000
--- a/drivers/media/dvb/frontends/stv0299.c
+++ /dev/null
@@ -1,728 +0,0 @@
-/*
- Driver for ST STV0299 demodulator
-
- Copyright (C) 2001-2002 Convergence Integrated Media GmbH
- <ralph@convergence.de>,
- <holger@convergence.de>,
- <js@convergence.de>
-
-
- Philips SU1278/SH
-
- Copyright (C) 2002 by Peter Schildmann <peter.schildmann@web.de>
-
-
- LG TDQF-S001F
-
- Copyright (C) 2002 Felix Domke <tmbinc@elitedvb.net>
- & Andreas Oberritter <obi@linuxtv.org>
-
-
- Support for Samsung TBMU24112IMB used on Technisat SkyStar2 rev. 2.6B
-
- Copyright (C) 2003 Vadim Catana <skystar@moldova.cc>:
-
- Support for Philips SU1278 on Technotrend hardware
-
- Copyright (C) 2004 Andrew de Quincey <adq_dvb@lidskialf.net>
-
- 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/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/jiffies.h>
-#include <asm/div64.h>
-
-#include "dvb_frontend.h"
-#include "stv0299.h"
-
-struct stv0299_state {
- struct i2c_adapter* i2c;
- const struct stv0299_config* config;
- struct dvb_frontend frontend;
-
- u8 initialised:1;
- u32 tuner_frequency;
- u32 symbol_rate;
- fe_code_rate_t fec_inner;
- int errmode;
-};
-
-#define STATUS_BER 0
-#define STATUS_UCBLOCKS 1
-
-static int debug;
-static int debug_legacy_dish_switch;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "stv0299: " args); \
- } while (0)
-
-
-static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
-{
- int ret;
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
-
- ret = i2c_transfer (state->i2c, &msg, 1);
-
- if (ret != 1)
- dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, "
- "ret == %i)\n", __FUNCTION__, reg, data, ret);
-
- return (ret != 1) ? -EREMOTEIO : 0;
-}
-
-int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- return stv0299_writeregI(state, reg, data);
-}
-
-static u8 stv0299_readreg (struct stv0299_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
- ret = i2c_transfer (state->i2c, msg, 2);
-
- if (ret != 2)
- dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n",
- __FUNCTION__, reg, ret);
-
- return b1[0];
-}
-
-static int stv0299_readregs (struct stv0299_state* state, u8 reg1, u8 *b, u8 len)
-{
- int ret;
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg1, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } };
-
- ret = i2c_transfer (state->i2c, msg, 2);
-
- if (ret != 2)
- dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
-
- return ret == 2 ? 0 : ret;
-}
-
-static int stv0299_set_FEC (struct stv0299_state* state, fe_code_rate_t fec)
-{
- dprintk ("%s\n", __FUNCTION__);
-
- switch (fec) {
- case FEC_AUTO:
- {
- return stv0299_writeregI (state, 0x31, 0x1f);
- }
- case FEC_1_2:
- {
- return stv0299_writeregI (state, 0x31, 0x01);
- }
- case FEC_2_3:
- {
- return stv0299_writeregI (state, 0x31, 0x02);
- }
- case FEC_3_4:
- {
- return stv0299_writeregI (state, 0x31, 0x04);
- }
- case FEC_5_6:
- {
- return stv0299_writeregI (state, 0x31, 0x08);
- }
- case FEC_7_8:
- {
- return stv0299_writeregI (state, 0x31, 0x10);
- }
- default:
- {
- return -EINVAL;
- }
- }
-}
-
-static fe_code_rate_t stv0299_get_fec (struct stv0299_state* state)
-{
- static fe_code_rate_t fec_tab [] = { FEC_2_3, FEC_3_4, FEC_5_6,
- FEC_7_8, FEC_1_2 };
- u8 index;
-
- dprintk ("%s\n", __FUNCTION__);
-
- index = stv0299_readreg (state, 0x1b);
- index &= 0x7;
-
- if (index > 4)
- return FEC_AUTO;
-
- return fec_tab [index];
-}
-
-static int stv0299_wait_diseqc_fifo (struct stv0299_state* state, int timeout)
-{
- unsigned long start = jiffies;
-
- dprintk ("%s\n", __FUNCTION__);
-
- while (stv0299_readreg(state, 0x0a) & 1) {
- if (jiffies - start > timeout) {
- dprintk ("%s: timeout!!\n", __FUNCTION__);
- return -ETIMEDOUT;
- }
- msleep(10);
- };
-
- return 0;
-}
-
-static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout)
-{
- unsigned long start = jiffies;
-
- dprintk ("%s\n", __FUNCTION__);
-
- while ((stv0299_readreg(state, 0x0a) & 3) != 2 ) {
- if (jiffies - start > timeout) {
- dprintk ("%s: timeout!!\n", __FUNCTION__);
- return -ETIMEDOUT;
- }
- msleep(10);
- };
-
- return 0;
-}
-
-static int stv0299_set_symbolrate (struct dvb_frontend* fe, u32 srate)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- u64 big = srate;
- u32 ratio;
-
- // check rate is within limits
- if ((srate < 1000000) || (srate > 45000000)) return -EINVAL;
-
- // calculate value to program
- big = big << 20;
- big += (state->config->mclk-1); // round correctly
- do_div(big, state->config->mclk);
- ratio = big << 4;
-
- return state->config->set_symbol_rate(fe, srate, ratio);
-}
-
-static int stv0299_get_symbolrate (struct stv0299_state* state)
-{
- u32 Mclk = state->config->mclk / 4096L;
- u32 srate;
- s32 offset;
- u8 sfr[3];
- s8 rtf;
-
- dprintk ("%s\n", __FUNCTION__);
-
- stv0299_readregs (state, 0x1f, sfr, 3);
- stv0299_readregs (state, 0x1a, &rtf, 1);
-
- srate = (sfr[0] << 8) | sfr[1];
- srate *= Mclk;
- srate /= 16;
- srate += (sfr[2] >> 4) * Mclk / 256;
- offset = (s32) rtf * (srate / 4096L);
- offset /= 128;
-
- dprintk ("%s : srate = %i\n", __FUNCTION__, srate);
- dprintk ("%s : ofset = %i\n", __FUNCTION__, offset);
-
- srate += offset;
-
- srate += 1000;
- srate /= 2000;
- srate *= 2000;
-
- return srate;
-}
-
-static int stv0299_send_diseqc_msg (struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd *m)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- u8 val;
- int i;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (stv0299_wait_diseqc_idle (state, 100) < 0)
- return -ETIMEDOUT;
-
- val = stv0299_readreg (state, 0x08);
-
- if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x6)) /* DiSEqC mode */
- return -EREMOTEIO;
-
- for (i=0; i<m->msg_len; i++) {
- if (stv0299_wait_diseqc_fifo (state, 100) < 0)
- return -ETIMEDOUT;
-
- if (stv0299_writeregI (state, 0x09, m->msg[i]))
- return -EREMOTEIO;
- }
-
- if (stv0299_wait_diseqc_idle (state, 100) < 0)
- return -ETIMEDOUT;
-
- return 0;
-}
-
-static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- u8 val;
-
- dprintk ("%s\n", __FUNCTION__);
-
- if (stv0299_wait_diseqc_idle (state, 100) < 0)
- return -ETIMEDOUT;
-
- val = stv0299_readreg (state, 0x08);
-
- if (stv0299_writeregI (state, 0x08, (val & ~0x7) | 0x2)) /* burst mode */
- return -EREMOTEIO;
-
- if (stv0299_writeregI (state, 0x09, burst == SEC_MINI_A ? 0x00 : 0xff))
- return -EREMOTEIO;
-
- if (stv0299_wait_diseqc_idle (state, 100) < 0)
- return -ETIMEDOUT;
-
- if (stv0299_writeregI (state, 0x08, val))
- return -EREMOTEIO;
-
- return 0;
-}
-
-static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- u8 val;
-
- if (stv0299_wait_diseqc_idle (state, 100) < 0)
- return -ETIMEDOUT;
-
- val = stv0299_readreg (state, 0x08);
-
- switch (tone) {
- case SEC_TONE_ON:
- return stv0299_writeregI (state, 0x08, val | 0x3);
-
- case SEC_TONE_OFF:
- return stv0299_writeregI (state, 0x08, (val & ~0x3) | 0x02);
-
- default:
- return -EINVAL;
- }
-}
-
-static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- u8 reg0x08;
- u8 reg0x0c;
-
- dprintk("%s: %s\n", __FUNCTION__,
- voltage == SEC_VOLTAGE_13 ? "SEC_VOLTAGE_13" :
- voltage == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : "??");
-
- reg0x08 = stv0299_readreg (state, 0x08);
- reg0x0c = stv0299_readreg (state, 0x0c);
-
- /**
- * H/V switching over OP0, OP1 and OP2 are LNB power enable bits
- */
- reg0x0c &= 0x0f;
-
- if (voltage == SEC_VOLTAGE_OFF) {
- stv0299_writeregI (state, 0x0c, 0x00); /* LNB power off! */
- return stv0299_writeregI (state, 0x08, 0x00); /* LNB power off! */
- }
-
- stv0299_writeregI (state, 0x08, (reg0x08 & 0x3f) | (state->config->lock_output << 6));
-
- switch (voltage) {
- case SEC_VOLTAGE_13:
- if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) reg0x0c |= 0x10;
- else reg0x0c |= 0x40;
-
- return stv0299_writeregI(state, 0x0c, reg0x0c);
-
- case SEC_VOLTAGE_18:
- return stv0299_writeregI(state, 0x0c, reg0x0c | 0x50);
- default:
- return -EINVAL;
- };
-}
-
-static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long cmd)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- u8 reg0x08;
- u8 reg0x0c;
- u8 lv_mask = 0x40;
- u8 last = 1;
- int i;
- struct timeval nexttime;
- struct timeval tv[10];
-
- reg0x08 = stv0299_readreg (state, 0x08);
- reg0x0c = stv0299_readreg (state, 0x0c);
- reg0x0c &= 0x0f;
- stv0299_writeregI (state, 0x08, (reg0x08 & 0x3f) | (state->config->lock_output << 6));
- if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0)
- lv_mask = 0x10;
-
- cmd = cmd << 1;
- if (debug_legacy_dish_switch)
- printk ("%s switch command: 0x%04lx\n",__FUNCTION__, cmd);
-
- do_gettimeofday (&nexttime);
- if (debug_legacy_dish_switch)
- memcpy (&tv[0], &nexttime, sizeof (struct timeval));
- stv0299_writeregI (state, 0x0c, reg0x0c | 0x50); /* set LNB to 18V */
-
- dvb_frontend_sleep_until(&nexttime, 32000);
-
- for (i=0; i<9; i++) {
- if (debug_legacy_dish_switch)
- do_gettimeofday (&tv[i+1]);
- if((cmd & 0x01) != last) {
- /* set voltage to (last ? 13V : 18V) */
- stv0299_writeregI (state, 0x0c, reg0x0c | (last ? lv_mask : 0x50));
- last = (last) ? 0 : 1;
- }
-
- cmd = cmd >> 1;
-
- if (i != 8)
- dvb_frontend_sleep_until(&nexttime, 8000);
- }
- if (debug_legacy_dish_switch) {
- printk ("%s(%d): switch delay (should be 32k followed by all 8k\n",
- __FUNCTION__, fe->dvb->num);
- for (i = 1; i < 10; i++)
- printk ("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i]));
- }
-
- return 0;
-}
-
-static int stv0299_init (struct dvb_frontend* fe)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- int i;
-
- dprintk("stv0299: init chip\n");
-
- for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2)
- stv0299_writeregI(state, state->config->inittab[i], state->config->inittab[i+1]);
-
- return 0;
-}
-
-static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- u8 signal = 0xff - stv0299_readreg (state, 0x18);
- u8 sync = stv0299_readreg (state, 0x1b);
-
- dprintk ("%s : FE_READ_STATUS : VSTATUS: 0x%02x\n", __FUNCTION__, sync);
- *status = 0;
-
- if (signal > 10)
- *status |= FE_HAS_SIGNAL;
-
- if (sync & 0x80)
- *status |= FE_HAS_CARRIER;
-
- if (sync & 0x10)
- *status |= FE_HAS_VITERBI;
-
- if (sync & 0x08)
- *status |= FE_HAS_SYNC;
-
- if ((sync & 0x98) == 0x98)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- if (state->errmode != STATUS_BER) return 0;
- *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
-
- return 0;
-}
-
-static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8)
- | stv0299_readreg (state, 0x19));
-
- dprintk ("%s : FE_READ_SIGNAL_STRENGTH : AGC2I: 0x%02x%02x, signal=0x%04x\n", __FUNCTION__,
- stv0299_readreg (state, 0x18),
- stv0299_readreg (state, 0x19), (int) signal);
-
- signal = signal * 5 / 4;
- *strength = (signal > 0xffff) ? 0xffff : (signal < 0) ? 0 : signal;
-
- return 0;
-}
-
-static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8)
- | stv0299_readreg (state, 0x25));
- xsnr = 3 * (xsnr - 0xa100);
- *snr = (xsnr > 0xffff) ? 0xffff : (xsnr < 0) ? 0 : xsnr;
-
- return 0;
-}
-
-static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0;
- else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
-
- return 0;
-}
-
-static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- int invval = 0;
-
- dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);
-
- // set the inversion
- if (p->inversion == INVERSION_OFF) invval = 0;
- else if (p->inversion == INVERSION_ON) invval = 1;
- else {
- printk("stv0299 does not support auto-inversion\n");
- return -EINVAL;
- }
- if (state->config->invert) invval = (~invval) & 1;
- stv0299_writeregI(state, 0x0c, (stv0299_readreg(state, 0x0c) & 0xfe) | invval);
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- stv0299_set_FEC (state, p->u.qpsk.fec_inner);
- stv0299_set_symbolrate (fe, p->u.qpsk.symbol_rate);
- stv0299_writeregI(state, 0x22, 0x00);
- stv0299_writeregI(state, 0x23, 0x00);
-
- state->tuner_frequency = p->frequency;
- state->fec_inner = p->u.qpsk.fec_inner;
- state->symbol_rate = p->u.qpsk.symbol_rate;
-
- return 0;
-}
-
-static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- s32 derot_freq;
- int invval;
-
- derot_freq = (s32)(s16) ((stv0299_readreg (state, 0x22) << 8)
- | stv0299_readreg (state, 0x23));
-
- derot_freq *= (state->config->mclk >> 16);
- derot_freq += 500;
- derot_freq /= 1000;
-
- p->frequency += derot_freq;
-
- invval = stv0299_readreg (state, 0x0c) & 1;
- if (state->config->invert) invval = (~invval) & 1;
- p->inversion = invval ? INVERSION_ON : INVERSION_OFF;
-
- p->u.qpsk.fec_inner = stv0299_get_fec (state);
- p->u.qpsk.symbol_rate = stv0299_get_symbolrate (state);
-
- return 0;
-}
-
-static int stv0299_sleep(struct dvb_frontend* fe)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- stv0299_writeregI(state, 0x02, 0x80);
- state->initialised = 0;
-
- return 0;
-}
-
-static int stv0299_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- if (enable) {
- stv0299_writeregI(state, 0x05, 0xb5);
- } else {
- stv0299_writeregI(state, 0x05, 0x35);
- }
- udelay(1);
- return 0;
-}
-
-static int stv0299_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
- struct stv0299_state* state = fe->demodulator_priv;
-
- fesettings->min_delay_ms = state->config->min_delay_ms;
- if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
- fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 32000;
- fesettings->max_drift = 5000;
- } else {
- fesettings->step_size = fesettings->parameters.u.qpsk.symbol_rate / 16000;
- fesettings->max_drift = fesettings->parameters.u.qpsk.symbol_rate / 2000;
- }
- return 0;
-}
-
-static void stv0299_release(struct dvb_frontend* fe)
-{
- struct stv0299_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops stv0299_ops;
-
-struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
- struct i2c_adapter* i2c)
-{
- struct stv0299_state* state = NULL;
- int id;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->initialised = 0;
- state->tuner_frequency = 0;
- state->symbol_rate = 0;
- state->fec_inner = 0;
- state->errmode = STATUS_BER;
-
- /* check if the demod is there */
- stv0299_writeregI(state, 0x02, 0x34); /* standby off */
- msleep(200);
- id = stv0299_readreg(state, 0x00);
-
- /* register 0x00 contains 0xa1 for STV0299 and STV0299B */
- /* register 0x00 might contain 0x80 when returning from standby */
- if (id != 0xa1 && id != 0x80) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &stv0299_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops stv0299_ops = {
-
- .info = {
- .name = "ST STV0299 DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 125, /* kHz for QPSK frontends */
- .frequency_tolerance = 0,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- .symbol_rate_tolerance = 500, /* ppm */
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
- FE_CAN_QPSK |
- FE_CAN_FEC_AUTO
- },
-
- .release = stv0299_release,
-
- .init = stv0299_init,
- .sleep = stv0299_sleep,
- .i2c_gate_ctrl = stv0299_i2c_gate_ctrl,
-
- .set_frontend = stv0299_set_frontend,
- .get_frontend = stv0299_get_frontend,
- .get_tune_settings = stv0299_get_tune_settings,
-
- .read_status = stv0299_read_status,
- .read_ber = stv0299_read_ber,
- .read_signal_strength = stv0299_read_signal_strength,
- .read_snr = stv0299_read_snr,
- .read_ucblocks = stv0299_read_ucblocks,
-
- .diseqc_send_master_cmd = stv0299_send_diseqc_msg,
- .diseqc_send_burst = stv0299_send_diseqc_burst,
- .set_tone = stv0299_set_tone,
- .set_voltage = stv0299_set_voltage,
- .dishnetwork_send_legacy_command = stv0299_send_legacy_dish_cmd,
-};
-
-module_param(debug_legacy_dish_switch, int, 0444);
-MODULE_PARM_DESC(debug_legacy_dish_switch, "Enable timing analysis for Dish Network legacy switches");
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("ST STV0299 DVB Demodulator driver");
-MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, "
- "Andreas Oberritter, Andrew de Quincey, Kenneth Aafly");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(stv0299_writereg);
-EXPORT_SYMBOL(stv0299_attach);
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h
deleted file mode 100644
index 1504828e423..00000000000
--- a/drivers/media/dvb/frontends/stv0299.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- Driver for ST STV0299 demodulator
-
- Copyright (C) 2001-2002 Convergence Integrated Media GmbH
- <ralph@convergence.de>,
- <holger@convergence.de>,
- <js@convergence.de>
-
-
- Philips SU1278/SH
-
- Copyright (C) 2002 by Peter Schildmann <peter.schildmann@web.de>
-
-
- LG TDQF-S001F
-
- Copyright (C) 2002 Felix Domke <tmbinc@elitedvb.net>
- & Andreas Oberritter <obi@linuxtv.org>
-
-
- Support for Samsung TBMU24112IMB used on Technisat SkyStar2 rev. 2.6B
-
- Copyright (C) 2003 Vadim Catana <skystar@moldova.cc>:
-
- Support for Philips SU1278 on Technotrend hardware
-
- Copyright (C) 2004 Andrew de Quincey <adq_dvb@lidskialf.net>
-
- 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.
-
-*/
-
-#ifndef STV0299_H
-#define STV0299_H
-
-#include <linux/dvb/frontend.h>
-#include "dvb_frontend.h"
-
-#define STV0229_LOCKOUTPUT_0 0
-#define STV0229_LOCKOUTPUT_1 1
-#define STV0229_LOCKOUTPUT_CF 2
-#define STV0229_LOCKOUTPUT_LK 3
-
-#define STV0299_VOLT13_OP0 0
-#define STV0299_VOLT13_OP1 1
-
-struct stv0299_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* inittab - array of pairs of values.
- * First of each pair is the register, second is the value.
- * List should be terminated with an 0xff, 0xff pair.
- */
- u8* inittab;
-
- /* master clock to use */
- u32 mclk;
-
- /* does the inversion require inversion? */
- u8 invert:1;
-
- /* Skip reinitialisation? */
- u8 skip_reinit:1;
-
- /* LOCK OUTPUT setting */
- u8 lock_output:2;
-
- /* Is 13v controlled by OP0 or OP1? */
- u8 volt13_op0_op1:1;
-
- /* minimum delay before retuning */
- int min_delay_ms;
-
- /* Set the symbol rate */
- int (*set_symbol_rate)(struct dvb_frontend* fe, u32 srate, u32 ratio);
-};
-
-extern int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data);
-
-extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
- struct i2c_adapter* i2c);
-
-#endif // STV0299_H
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
deleted file mode 100644
index 9cbd164aa28..00000000000
--- a/drivers/media/dvb/frontends/tda10021.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/*
- TDA10021 - Single Chip Cable Channel Receiver driver module
- used on the the Siemens DVB-C cards
-
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
- Copyright (C) 2004 Markus Schulz <msc@antzsystem.de>
- Support for TDA10021
-
- 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/delay.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "tda10021.h"
-
-
-struct tda10021_state {
- struct i2c_adapter* i2c;
- /* configuration settings */
- const struct tda10021_config* config;
- struct dvb_frontend frontend;
-
- u8 pwm;
- u8 reg0;
-};
-
-
-#if 0
-#define dprintk(x...) printk(x)
-#else
-#define dprintk(x...)
-#endif
-
-static int verbose;
-
-#define XIN 57840000UL
-#define DISABLE_INVERSION(reg0) do { reg0 |= 0x20; } while (0)
-#define ENABLE_INVERSION(reg0) do { reg0 &= ~0x20; } while (0)
-#define HAS_INVERSION(reg0) (!(reg0 & 0x20))
-
-#define FIN (XIN >> 4)
-
-static int tda10021_inittab_size = 0x40;
-static u8 tda10021_inittab[0x40]=
-{
- 0x73, 0x6a, 0x23, 0x0a, 0x02, 0x37, 0x77, 0x1a,
- 0x37, 0x6a, 0x17, 0x8a, 0x1e, 0x86, 0x43, 0x40,
- 0xb8, 0x3f, 0xa0, 0x00, 0xcd, 0x01, 0x00, 0xff,
- 0x11, 0x00, 0x7c, 0x31, 0x30, 0x20, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x00,
- 0x07, 0x00, 0x33, 0x11, 0x0d, 0x95, 0x08, 0x58,
- 0x00, 0x00, 0x80, 0x00, 0x80, 0xff, 0x00, 0x00,
- 0x04, 0x2d, 0x2f, 0xff, 0x00, 0x00, 0x00, 0x00,
-};
-
-static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
-{
- u8 buf[] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
- int ret;
-
- ret = i2c_transfer (state->i2c, &msg, 1);
- if (ret != 1)
- printk("DVB: TDA10021(%d): %s, writereg error "
- "(reg == 0x%02x, val == 0x%02x, ret == %i)\n",
- state->frontend.dvb->num, __FUNCTION__, reg, data, ret);
-
- msleep(10);
- return (ret != 1) ? -EREMOTEIO : 0;
-}
-
-int tda10021_write_byte(struct dvb_frontend* fe, int reg, int data)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- return tda10021_writereg(state, reg, data);
-}
-EXPORT_SYMBOL(tda10021_write_byte);
-
-static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
-{
- u8 b0 [] = { reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
- int ret;
-
- ret = i2c_transfer (state->i2c, msg, 2);
- if (ret != 2)
- printk("DVB: TDA10021: %s: readreg error (ret == %i)\n",
- __FUNCTION__, ret);
- return b1[0];
-}
-
-//get access to tuner
-static int lock_tuner(struct tda10021_state* state)
-{
- u8 buf[2] = { 0x0f, tda10021_inittab[0x0f] | 0x80 };
- struct i2c_msg msg = {.addr=state->config->demod_address, .flags=0, .buf=buf, .len=2};
-
- if(i2c_transfer(state->i2c, &msg, 1) != 1)
- {
- printk("tda10021: lock tuner fails\n");
- return -EREMOTEIO;
- }
- return 0;
-}
-
-//release access from tuner
-static int unlock_tuner(struct tda10021_state* state)
-{
- u8 buf[2] = { 0x0f, tda10021_inittab[0x0f] & 0x7f };
- struct i2c_msg msg_post={.addr=state->config->demod_address, .flags=0, .buf=buf, .len=2};
-
- if(i2c_transfer(state->i2c, &msg_post, 1) != 1)
- {
- printk("tda10021: unlock tuner fails\n");
- return -EREMOTEIO;
- }
- return 0;
-}
-
-static int tda10021_setup_reg0 (struct tda10021_state* state, u8 reg0,
- fe_spectral_inversion_t inversion)
-{
- reg0 |= state->reg0 & 0x63;
-
- if (INVERSION_ON == inversion)
- ENABLE_INVERSION(reg0);
- else if (INVERSION_OFF == inversion)
- DISABLE_INVERSION(reg0);
-
- tda10021_writereg (state, 0x00, reg0 & 0xfe);
- tda10021_writereg (state, 0x00, reg0 | 0x01);
-
- state->reg0 = reg0;
- return 0;
-}
-
-static int tda10021_set_symbolrate (struct tda10021_state* state, u32 symbolrate)
-{
- s32 BDR;
- s32 BDRI;
- s16 SFIL=0;
- u16 NDEC = 0;
- u32 tmp, ratio;
-
- if (symbolrate > XIN/2)
- symbolrate = XIN/2;
- if (symbolrate < 500000)
- symbolrate = 500000;
-
- if (symbolrate < XIN/16) NDEC = 1;
- if (symbolrate < XIN/32) NDEC = 2;
- if (symbolrate < XIN/64) NDEC = 3;
-
- if (symbolrate < (u32)(XIN/12.3)) SFIL = 1;
- if (symbolrate < (u32)(XIN/16)) SFIL = 0;
- if (symbolrate < (u32)(XIN/24.6)) SFIL = 1;
- if (symbolrate < (u32)(XIN/32)) SFIL = 0;
- if (symbolrate < (u32)(XIN/49.2)) SFIL = 1;
- if (symbolrate < (u32)(XIN/64)) SFIL = 0;
- if (symbolrate < (u32)(XIN/98.4)) SFIL = 1;
-
- symbolrate <<= NDEC;
- ratio = (symbolrate << 4) / FIN;
- tmp = ((symbolrate << 4) % FIN) << 8;
- ratio = (ratio << 8) + tmp / FIN;
- tmp = (tmp % FIN) << 8;
- ratio = (ratio << 8) + (tmp + FIN/2) / FIN;
-
- BDR = ratio;
- BDRI = (((XIN << 5) / symbolrate) + 1) / 2;
-
- if (BDRI > 0xFF)
- BDRI = 0xFF;
-
- SFIL = (SFIL << 4) | tda10021_inittab[0x0E];
-
- NDEC = (NDEC << 6) | tda10021_inittab[0x03];
-
- tda10021_writereg (state, 0x03, NDEC);
- tda10021_writereg (state, 0x0a, BDR&0xff);
- tda10021_writereg (state, 0x0b, (BDR>> 8)&0xff);
- tda10021_writereg (state, 0x0c, (BDR>>16)&0x3f);
-
- tda10021_writereg (state, 0x0d, BDRI);
- tda10021_writereg (state, 0x0e, SFIL);
-
- return 0;
-}
-
-static int tda10021_init (struct dvb_frontend *fe)
-{
- struct tda10021_state* state = fe->demodulator_priv;
- int i;
-
- dprintk("DVB: TDA10021(%d): init chip\n", fe->adapter->num);
-
- //tda10021_writereg (fe, 0, 0);
-
- for (i=0; i<tda10021_inittab_size; i++)
- tda10021_writereg (state, i, tda10021_inittab[i]);
-
- tda10021_writereg (state, 0x34, state->pwm);
-
- //Comment by markus
- //0x2A[3-0] == PDIV -> P multiplaying factor (P=PDIV+1)(default 0)
- //0x2A[4] == BYPPLL -> Power down mode (default 1)
- //0x2A[5] == LCK -> PLL Lock Flag
- //0x2A[6] == POLAXIN -> Polarity of the input reference clock (default 0)
-
- //Activate PLL
- tda10021_writereg(state, 0x2a, tda10021_inittab[0x2a] & 0xef);
- return 0;
-}
-
-static int tda10021_set_parameters (struct dvb_frontend *fe,
- struct dvb_frontend_parameters *p)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- //table for QAM4-QAM256 ready QAM4 QAM16 QAM32 QAM64 QAM128 QAM256
- //CONF
- static const u8 reg0x00 [] = { 0x14, 0x00, 0x04, 0x08, 0x0c, 0x10 };
- //AGCREF value
- static const u8 reg0x01 [] = { 0x78, 0x8c, 0x8c, 0x6a, 0x78, 0x5c };
- //LTHR value
- static const u8 reg0x05 [] = { 0x78, 0x87, 0x64, 0x46, 0x36, 0x26 };
- //MSETH
- static const u8 reg0x08 [] = { 0x8c, 0xa2, 0x74, 0x43, 0x34, 0x23 };
- //AREF
- static const u8 reg0x09 [] = { 0x96, 0x91, 0x96, 0x6a, 0x7e, 0x6b };
-
- int qam = p->u.qam.modulation;
-
- if (qam < 0 || qam > 5)
- return -EINVAL;
-
- //printk("tda10021: set frequency to %d qam=%d symrate=%d\n", p->frequency,qam,p->u.qam.symbol_rate);
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- tda10021_set_symbolrate (state, p->u.qam.symbol_rate);
- tda10021_writereg (state, 0x34, state->pwm);
-
- tda10021_writereg (state, 0x01, reg0x01[qam]);
- tda10021_writereg (state, 0x05, reg0x05[qam]);
- tda10021_writereg (state, 0x08, reg0x08[qam]);
- tda10021_writereg (state, 0x09, reg0x09[qam]);
-
- tda10021_setup_reg0 (state, reg0x00[qam], p->inversion);
-
- return 0;
-}
-
-static int tda10021_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct tda10021_state* state = fe->demodulator_priv;
- int sync;
-
- *status = 0;
- //0x11[0] == EQALGO -> Equalizer algorithms state
- //0x11[1] == CARLOCK -> Carrier locked
- //0x11[2] == FSYNC -> Frame synchronisation
- //0x11[3] == FEL -> Front End locked
- //0x11[6] == NODVB -> DVB Mode Information
- sync = tda10021_readreg (state, 0x11);
-
- if (sync & 2)
- *status |= FE_HAS_SIGNAL|FE_HAS_CARRIER;
-
- if (sync & 4)
- *status |= FE_HAS_SYNC|FE_HAS_VITERBI;
-
- if (sync & 8)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int tda10021_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- u32 _ber = tda10021_readreg(state, 0x14) |
- (tda10021_readreg(state, 0x15) << 8) |
- ((tda10021_readreg(state, 0x16) & 0x0f) << 16);
- *ber = 10 * _ber;
-
- return 0;
-}
-
-static int tda10021_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- u8 gain = tda10021_readreg(state, 0x17);
- *strength = (gain << 8) | gain;
-
- return 0;
-}
-
-static int tda10021_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- u8 quality = ~tda10021_readreg(state, 0x18);
- *snr = (quality << 8) | quality;
-
- return 0;
-}
-
-static int tda10021_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- *ucblocks = tda10021_readreg (state, 0x13) & 0x7f;
- if (*ucblocks == 0x7f)
- *ucblocks = 0xffffffff;
-
- /* reset uncorrected block counter */
- tda10021_writereg (state, 0x10, tda10021_inittab[0x10] & 0xdf);
- tda10021_writereg (state, 0x10, tda10021_inittab[0x10]);
-
- return 0;
-}
-
-static int tda10021_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct tda10021_state* state = fe->demodulator_priv;
- int sync;
- s8 afc = 0;
-
- sync = tda10021_readreg(state, 0x11);
- afc = tda10021_readreg(state, 0x19);
- if (verbose) {
- /* AFC only valid when carrier has been recovered */
- printk(sync & 2 ? "DVB: TDA10021(%d): AFC (%d) %dHz\n" :
- "DVB: TDA10021(%d): [AFC (%d) %dHz]\n",
- state->frontend.dvb->num, afc,
- -((s32)p->u.qam.symbol_rate * afc) >> 10);
- }
-
- p->inversion = HAS_INVERSION(state->reg0) ? INVERSION_ON : INVERSION_OFF;
- p->u.qam.modulation = ((state->reg0 >> 2) & 7) + QAM_16;
-
- p->u.qam.fec_inner = FEC_NONE;
- p->frequency = ((p->frequency + 31250) / 62500) * 62500;
-
- if (sync & 2)
- p->frequency -= ((s32)p->u.qam.symbol_rate * afc) >> 10;
-
- return 0;
-}
-
-static int tda10021_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- if (enable) {
- lock_tuner(state);
- } else {
- unlock_tuner(state);
- }
- return 0;
-}
-
-static int tda10021_sleep(struct dvb_frontend* fe)
-{
- struct tda10021_state* state = fe->demodulator_priv;
-
- tda10021_writereg (state, 0x1b, 0x02); /* pdown ADC */
- tda10021_writereg (state, 0x00, 0x80); /* standby */
-
- return 0;
-}
-
-static void tda10021_release(struct dvb_frontend* fe)
-{
- struct tda10021_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops tda10021_ops;
-
-struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
- struct i2c_adapter* i2c,
- u8 pwm)
-{
- struct tda10021_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct tda10021_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->pwm = pwm;
- state->reg0 = tda10021_inittab[0];
-
- /* check if the demod is there */
- if ((tda10021_readreg(state, 0x1a) & 0xf0) != 0x70) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &tda10021_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops tda10021_ops = {
-
- .info = {
- .name = "Philips TDA10021 DVB-C",
- .type = FE_QAM,
- .frequency_stepsize = 62500,
- .frequency_min = 51000000,
- .frequency_max = 858000000,
- .symbol_rate_min = (XIN/2)/64, /* SACLK/64 == (XIN/2)/64 */
- .symbol_rate_max = (XIN/2)/4, /* SACLK/4 */
-#if 0
- .frequency_tolerance = ???,
- .symbol_rate_tolerance = ???, /* ppm */ /* == 8% (spec p. 5) */
- #endif
- .caps = 0x400 | //FE_CAN_QAM_4
- FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
- FE_CAN_QAM_128 | FE_CAN_QAM_256 |
- FE_CAN_FEC_AUTO
- },
-
- .release = tda10021_release,
-
- .init = tda10021_init,
- .sleep = tda10021_sleep,
- .i2c_gate_ctrl = tda10021_i2c_gate_ctrl,
-
- .set_frontend = tda10021_set_parameters,
- .get_frontend = tda10021_get_frontend,
-
- .read_status = tda10021_read_status,
- .read_ber = tda10021_read_ber,
- .read_signal_strength = tda10021_read_signal_strength,
- .read_snr = tda10021_read_snr,
- .read_ucblocks = tda10021_read_ucblocks,
-};
-
-module_param(verbose, int, 0644);
-MODULE_PARM_DESC(verbose, "print AFC offset after tuning for debugging the PWM setting");
-
-MODULE_DESCRIPTION("Philips TDA10021 DVB-C demodulator driver");
-MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Markus Schulz");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(tda10021_attach);
diff --git a/drivers/media/dvb/frontends/tda10021.h b/drivers/media/dvb/frontends/tda10021.h
deleted file mode 100644
index b1df4259bee..00000000000
--- a/drivers/media/dvb/frontends/tda10021.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- TDA10021 - Single Chip Cable Channel Receiver driver module
- used on the the Siemens DVB-C cards
-
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
- Copyright (C) 2004 Markus Schulz <msc@antzsystem.de>
- Support for TDA10021
-
- 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.
-*/
-
-#ifndef TDA10021_H
-#define TDA10021_H
-
-#include <linux/dvb/frontend.h>
-
-struct tda10021_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-};
-
-extern struct dvb_frontend* tda10021_attach(const struct tda10021_config* config,
- struct i2c_adapter* i2c, u8 pwm);
-
-extern int tda10021_write_byte(struct dvb_frontend* fe, int reg, int data);
-
-#endif // TDA10021_H
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
deleted file mode 100644
index 59a2ed614fc..00000000000
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ /dev/null
@@ -1,1326 +0,0 @@
- /*
- Driver for Philips tda1004xh OFDM Demodulator
-
- (c) 2003, 2004 Andrew de Quincey & Robert Schlabbach
-
- 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.
-
- */
-/*
- * This driver needs external firmware. Please use the commands
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
- * download/extract them, and then copy them to /usr/lib/hotplug/firmware
- * or /lib/firmware (depending on configuration of firmware hotplug).
- */
-#define TDA10045_DEFAULT_FIRMWARE "dvb-fe-tda10045.fw"
-#define TDA10046_DEFAULT_FIRMWARE "dvb-fe-tda10046.fw"
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/device.h>
-#include <linux/jiffies.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "tda1004x.h"
-
-enum tda1004x_demod {
- TDA1004X_DEMOD_TDA10045,
- TDA1004X_DEMOD_TDA10046,
-};
-
-struct tda1004x_state {
- struct i2c_adapter* i2c;
- const struct tda1004x_config* config;
- struct dvb_frontend frontend;
-
- /* private demod data */
- enum tda1004x_demod demod_type;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "tda1004x: " args); \
- } while (0)
-
-#define TDA1004X_CHIPID 0x00
-#define TDA1004X_AUTO 0x01
-#define TDA1004X_IN_CONF1 0x02
-#define TDA1004X_IN_CONF2 0x03
-#define TDA1004X_OUT_CONF1 0x04
-#define TDA1004X_OUT_CONF2 0x05
-#define TDA1004X_STATUS_CD 0x06
-#define TDA1004X_CONFC4 0x07
-#define TDA1004X_DSSPARE2 0x0C
-#define TDA10045H_CODE_IN 0x0D
-#define TDA10045H_FWPAGE 0x0E
-#define TDA1004X_SCAN_CPT 0x10
-#define TDA1004X_DSP_CMD 0x11
-#define TDA1004X_DSP_ARG 0x12
-#define TDA1004X_DSP_DATA1 0x13
-#define TDA1004X_DSP_DATA2 0x14
-#define TDA1004X_CONFADC1 0x15
-#define TDA1004X_CONFC1 0x16
-#define TDA10045H_S_AGC 0x1a
-#define TDA10046H_AGC_TUN_LEVEL 0x1a
-#define TDA1004X_SNR 0x1c
-#define TDA1004X_CONF_TS1 0x1e
-#define TDA1004X_CONF_TS2 0x1f
-#define TDA1004X_CBER_RESET 0x20
-#define TDA1004X_CBER_MSB 0x21
-#define TDA1004X_CBER_LSB 0x22
-#define TDA1004X_CVBER_LUT 0x23
-#define TDA1004X_VBER_MSB 0x24
-#define TDA1004X_VBER_MID 0x25
-#define TDA1004X_VBER_LSB 0x26
-#define TDA1004X_UNCOR 0x27
-
-#define TDA10045H_CONFPLL_P 0x2D
-#define TDA10045H_CONFPLL_M_MSB 0x2E
-#define TDA10045H_CONFPLL_M_LSB 0x2F
-#define TDA10045H_CONFPLL_N 0x30
-
-#define TDA10046H_CONFPLL1 0x2D
-#define TDA10046H_CONFPLL2 0x2F
-#define TDA10046H_CONFPLL3 0x30
-#define TDA10046H_TIME_WREF1 0x31
-#define TDA10046H_TIME_WREF2 0x32
-#define TDA10046H_TIME_WREF3 0x33
-#define TDA10046H_TIME_WREF4 0x34
-#define TDA10046H_TIME_WREF5 0x35
-
-#define TDA10045H_UNSURW_MSB 0x31
-#define TDA10045H_UNSURW_LSB 0x32
-#define TDA10045H_WREF_MSB 0x33
-#define TDA10045H_WREF_MID 0x34
-#define TDA10045H_WREF_LSB 0x35
-#define TDA10045H_MUXOUT 0x36
-#define TDA1004X_CONFADC2 0x37
-
-#define TDA10045H_IOFFSET 0x38
-
-#define TDA10046H_CONF_TRISTATE1 0x3B
-#define TDA10046H_CONF_TRISTATE2 0x3C
-#define TDA10046H_CONF_POLARITY 0x3D
-#define TDA10046H_FREQ_OFFSET 0x3E
-#define TDA10046H_GPIO_OUT_SEL 0x41
-#define TDA10046H_GPIO_SELECT 0x42
-#define TDA10046H_AGC_CONF 0x43
-#define TDA10046H_AGC_THR 0x44
-#define TDA10046H_AGC_RENORM 0x45
-#define TDA10046H_AGC_GAINS 0x46
-#define TDA10046H_AGC_TUN_MIN 0x47
-#define TDA10046H_AGC_TUN_MAX 0x48
-#define TDA10046H_AGC_IF_MIN 0x49
-#define TDA10046H_AGC_IF_MAX 0x4A
-
-#define TDA10046H_FREQ_PHY2_MSB 0x4D
-#define TDA10046H_FREQ_PHY2_LSB 0x4E
-
-#define TDA10046H_CVBER_CTRL 0x4F
-#define TDA10046H_AGC_IF_LEVEL 0x52
-#define TDA10046H_CODE_CPT 0x57
-#define TDA10046H_CODE_IN 0x58
-
-
-static int tda1004x_write_byteI(struct tda1004x_state *state, int reg, int data)
-{
- int ret;
- u8 buf[] = { reg, data };
- struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 };
-
- dprintk("%s: reg=0x%x, data=0x%x\n", __FUNCTION__, reg, data);
-
- msg.addr = state->config->demod_address;
- ret = i2c_transfer(state->i2c, &msg, 1);
-
- if (ret != 1)
- dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n",
- __FUNCTION__, reg, data, ret);
-
- dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__,
- reg, data, ret);
- return (ret != 1) ? -1 : 0;
-}
-
-static int tda1004x_read_byte(struct tda1004x_state *state, int reg)
-{
- int ret;
- u8 b0[] = { reg };
- u8 b1[] = { 0 };
- struct i2c_msg msg[] = {{ .flags = 0, .buf = b0, .len = 1 },
- { .flags = I2C_M_RD, .buf = b1, .len = 1 }};
-
- dprintk("%s: reg=0x%x\n", __FUNCTION__, reg);
-
- msg[0].addr = state->config->demod_address;
- msg[1].addr = state->config->demod_address;
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2) {
- dprintk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__, reg,
- ret);
- return -1;
- }
-
- dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__,
- reg, b1[0], ret);
- return b1[0];
-}
-
-static int tda1004x_write_mask(struct tda1004x_state *state, int reg, int mask, int data)
-{
- int val;
- dprintk("%s: reg=0x%x, mask=0x%x, data=0x%x\n", __FUNCTION__, reg,
- mask, data);
-
- // read a byte and check
- val = tda1004x_read_byte(state, reg);
- if (val < 0)
- return val;
-
- // mask if off
- val = val & ~mask;
- val |= data & 0xff;
-
- // write it out again
- return tda1004x_write_byteI(state, reg, val);
-}
-
-static int tda1004x_write_buf(struct tda1004x_state *state, int reg, unsigned char *buf, int len)
-{
- int i;
- int result;
-
- dprintk("%s: reg=0x%x, len=0x%x\n", __FUNCTION__, reg, len);
-
- result = 0;
- for (i = 0; i < len; i++) {
- result = tda1004x_write_byteI(state, reg + i, buf[i]);
- if (result != 0)
- break;
- }
-
- return result;
-}
-
-static int tda1004x_enable_tuner_i2c(struct tda1004x_state *state)
-{
- int result;
- dprintk("%s\n", __FUNCTION__);
-
- result = tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 2);
- msleep(20);
- return result;
-}
-
-static int tda1004x_disable_tuner_i2c(struct tda1004x_state *state)
-{
- dprintk("%s\n", __FUNCTION__);
-
- return tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 0);
-}
-
-static int tda10045h_set_bandwidth(struct tda1004x_state *state,
- fe_bandwidth_t bandwidth)
-{
- static u8 bandwidth_6mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x60, 0x1e, 0xa7, 0x45, 0x4f };
- static u8 bandwidth_7mhz[] = { 0x02, 0x00, 0x37, 0x00, 0x4a, 0x2f, 0x6d, 0x76, 0xdb };
- static u8 bandwidth_8mhz[] = { 0x02, 0x00, 0x3d, 0x00, 0x48, 0x17, 0x89, 0xc7, 0x14 };
-
- switch (bandwidth) {
- case BANDWIDTH_6_MHZ:
- tda1004x_write_buf(state, TDA10045H_CONFPLL_P, bandwidth_6mhz, sizeof(bandwidth_6mhz));
- break;
-
- case BANDWIDTH_7_MHZ:
- tda1004x_write_buf(state, TDA10045H_CONFPLL_P, bandwidth_7mhz, sizeof(bandwidth_7mhz));
- break;
-
- case BANDWIDTH_8_MHZ:
- tda1004x_write_buf(state, TDA10045H_CONFPLL_P, bandwidth_8mhz, sizeof(bandwidth_8mhz));
- break;
-
- default:
- return -EINVAL;
- }
-
- tda1004x_write_byteI(state, TDA10045H_IOFFSET, 0);
-
- return 0;
-}
-
-static int tda10046h_set_bandwidth(struct tda1004x_state *state,
- fe_bandwidth_t bandwidth)
-{
- static u8 bandwidth_6mhz_53M[] = { 0x7b, 0x2e, 0x11, 0xf0, 0xd2 };
- static u8 bandwidth_7mhz_53M[] = { 0x6a, 0x02, 0x6a, 0x43, 0x9f };
- static u8 bandwidth_8mhz_53M[] = { 0x5c, 0x32, 0xc2, 0x96, 0x6d };
-
- static u8 bandwidth_6mhz_48M[] = { 0x70, 0x02, 0x49, 0x24, 0x92 };
- static u8 bandwidth_7mhz_48M[] = { 0x60, 0x02, 0xaa, 0xaa, 0xab };
- static u8 bandwidth_8mhz_48M[] = { 0x54, 0x03, 0x0c, 0x30, 0xc3 };
- int tda10046_clk53m;
-
- if ((state->config->if_freq == TDA10046_FREQ_045) ||
- (state->config->if_freq == TDA10046_FREQ_052))
- tda10046_clk53m = 0;
- else
- tda10046_clk53m = 1;
- switch (bandwidth) {
- case BANDWIDTH_6_MHZ:
- if (tda10046_clk53m)
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_53M,
- sizeof(bandwidth_6mhz_53M));
- else
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz_48M,
- sizeof(bandwidth_6mhz_48M));
- if (state->config->if_freq == TDA10046_FREQ_045) {
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0a);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xab);
- }
- break;
-
- case BANDWIDTH_7_MHZ:
- if (tda10046_clk53m)
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_53M,
- sizeof(bandwidth_7mhz_53M));
- else
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz_48M,
- sizeof(bandwidth_7mhz_48M));
- if (state->config->if_freq == TDA10046_FREQ_045) {
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00);
- }
- break;
-
- case BANDWIDTH_8_MHZ:
- if (tda10046_clk53m)
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_53M,
- sizeof(bandwidth_8mhz_53M));
- else
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz_48M,
- sizeof(bandwidth_8mhz_48M));
- if (state->config->if_freq == TDA10046_FREQ_045) {
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x55);
- }
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int tda1004x_do_upload(struct tda1004x_state *state,
- unsigned char *mem, unsigned int len,
- u8 dspCodeCounterReg, u8 dspCodeInReg)
-{
- u8 buf[65];
- struct i2c_msg fw_msg = { .flags = 0, .buf = buf, .len = 0 };
- int tx_size;
- int pos = 0;
-
- /* clear code counter */
- tda1004x_write_byteI(state, dspCodeCounterReg, 0);
- fw_msg.addr = state->config->demod_address;
-
- buf[0] = dspCodeInReg;
- while (pos != len) {
- // work out how much to send this time
- tx_size = len - pos;
- if (tx_size > 0x10)
- tx_size = 0x10;
-
- // send the chunk
- memcpy(buf + 1, mem + pos, tx_size);
- fw_msg.len = tx_size + 1;
- if (i2c_transfer(state->i2c, &fw_msg, 1) != 1) {
- printk(KERN_ERR "tda1004x: Error during firmware upload\n");
- return -EIO;
- }
- pos += tx_size;
-
- dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, pos);
- }
- // give the DSP a chance to settle 03/10/05 Hac
- msleep(100);
-
- return 0;
-}
-
-static int tda1004x_check_upload_ok(struct tda1004x_state *state)
-{
- u8 data1, data2;
- unsigned long timeout;
-
- if (state->demod_type == TDA1004X_DEMOD_TDA10046) {
- timeout = jiffies + 2 * HZ;
- while(!(tda1004x_read_byte(state, TDA1004X_STATUS_CD) & 0x20)) {
- if (time_after(jiffies, timeout)) {
- printk(KERN_ERR "tda1004x: timeout waiting for DSP ready\n");
- break;
- }
- msleep(1);
- }
- } else
- msleep(100);
-
- // check upload was OK
- tda1004x_write_mask(state, TDA1004X_CONFC4, 0x10, 0); // we want to read from the DSP
- tda1004x_write_byteI(state, TDA1004X_DSP_CMD, 0x67);
-
- data1 = tda1004x_read_byte(state, TDA1004X_DSP_DATA1);
- data2 = tda1004x_read_byte(state, TDA1004X_DSP_DATA2);
- if (data1 != 0x67 || data2 < 0x20 || data2 > 0x2e) {
- printk(KERN_INFO "tda1004x: found firmware revision %x -- invalid\n", data2);
- return -EIO;
- }
- printk(KERN_INFO "tda1004x: found firmware revision %x -- ok\n", data2);
- return 0;
-}
-
-static int tda10045_fwupload(struct dvb_frontend* fe)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int ret;
- const struct firmware *fw;
-
- /* don't re-upload unless necessary */
- if (tda1004x_check_upload_ok(state) == 0)
- return 0;
-
- /* request the firmware, this will block until someone uploads it */
- printk(KERN_INFO "tda1004x: waiting for firmware upload (%s)...\n", TDA10045_DEFAULT_FIRMWARE);
- ret = state->config->request_firmware(fe, &fw, TDA10045_DEFAULT_FIRMWARE);
- if (ret) {
- printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n");
- return ret;
- }
-
- /* reset chip */
- tda1004x_write_mask(state, TDA1004X_CONFC4, 0x10, 0);
- tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8);
- tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 0);
- msleep(10);
-
- /* set parameters */
- tda10045h_set_bandwidth(state, BANDWIDTH_8_MHZ);
-
- ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10045H_FWPAGE, TDA10045H_CODE_IN);
- release_firmware(fw);
- if (ret)
- return ret;
- printk(KERN_INFO "tda1004x: firmware upload complete\n");
-
- /* wait for DSP to initialise */
- /* DSPREADY doesn't seem to work on the TDA10045H */
- msleep(100);
-
- return tda1004x_check_upload_ok(state);
-}
-
-static void tda10046_init_plls(struct dvb_frontend* fe)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int tda10046_clk53m;
-
- if ((state->config->if_freq == TDA10046_FREQ_045) ||
- (state->config->if_freq == TDA10046_FREQ_052))
- tda10046_clk53m = 0;
- else
- tda10046_clk53m = 1;
-
- tda1004x_write_byteI(state, TDA10046H_CONFPLL1, 0xf0);
- if(tda10046_clk53m) {
- printk(KERN_INFO "tda1004x: setting up plls for 53MHz sampling clock\n");
- tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x08); // PLL M = 8
- } else {
- printk(KERN_INFO "tda1004x: setting up plls for 48MHz sampling clock\n");
- tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x03); // PLL M = 3
- }
- if (state->config->xtal_freq == TDA10046_XTAL_4M ) {
- dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__);
- tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0
- } else {
- dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__);
- tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3
- }
- if(tda10046_clk53m)
- tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x67);
- else
- tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 0x72);
- /* Note clock frequency is handled implicitly */
- switch (state->config->if_freq) {
- case TDA10046_FREQ_045:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x00);
- break;
- case TDA10046_FREQ_052:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0d);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xc7);
- break;
- case TDA10046_FREQ_3617:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x59);
- break;
- case TDA10046_FREQ_3613:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd7);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x3f);
- break;
- }
- tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz
- /* let the PLLs settle */
- msleep(120);
-}
-
-static int tda10046_fwupload(struct dvb_frontend* fe)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int ret;
- const struct firmware *fw;
-
- /* reset + wake up chip */
- if (state->config->xtal_freq == TDA10046_XTAL_4M) {
- tda1004x_write_byteI(state, TDA1004X_CONFC4, 0);
- } else {
- dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __FUNCTION__);
- tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80);
- }
- tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0);
- /* let the clocks recover from sleep */
- msleep(5);
-
- /* The PLLs need to be reprogrammed after sleep */
- tda10046_init_plls(fe);
-
- /* don't re-upload unless necessary */
- if (tda1004x_check_upload_ok(state) == 0)
- return 0;
-
- if (state->config->request_firmware != NULL) {
- /* request the firmware, this will block until someone uploads it */
- printk(KERN_INFO "tda1004x: waiting for firmware upload...\n");
- ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE);
- if (ret) {
- printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n");
- return ret;
- }
- tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST
- ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN);
- release_firmware(fw);
- if (ret)
- return ret;
- } else {
- /* boot from firmware eeprom */
- printk(KERN_INFO "tda1004x: booting from eeprom\n");
- tda1004x_write_mask(state, TDA1004X_CONFC4, 4, 4);
- msleep(300);
- }
- return tda1004x_check_upload_ok(state);
-}
-
-static int tda1004x_encode_fec(int fec)
-{
- // convert known FEC values
- switch (fec) {
- case FEC_1_2:
- return 0;
- case FEC_2_3:
- return 1;
- case FEC_3_4:
- return 2;
- case FEC_5_6:
- return 3;
- case FEC_7_8:
- return 4;
- }
-
- // unsupported
- return -EINVAL;
-}
-
-static int tda1004x_decode_fec(int tdafec)
-{
- // convert known FEC values
- switch (tdafec) {
- case 0:
- return FEC_1_2;
- case 1:
- return FEC_2_3;
- case 2:
- return FEC_3_4;
- case 3:
- return FEC_5_6;
- case 4:
- return FEC_7_8;
- }
-
- // unsupported
- return -1;
-}
-
-int tda1004x_write_byte(struct dvb_frontend* fe, int reg, int data)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
-
- return tda1004x_write_byteI(state, reg, data);
-}
-
-static int tda10045_init(struct dvb_frontend* fe)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (tda10045_fwupload(fe)) {
- printk("tda1004x: firmware upload failed\n");
- return -EIO;
- }
-
- tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC
-
- // tda setup
- tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
- tda1004x_write_mask(state, TDA1004X_AUTO, 8, 0); // select HP stream
- tda1004x_write_mask(state, TDA1004X_CONFC1, 0x40, 0); // set polarity of VAGC signal
- tda1004x_write_mask(state, TDA1004X_CONFC1, 0x80, 0x80); // enable pulse killer
- tda1004x_write_mask(state, TDA1004X_AUTO, 0x10, 0x10); // enable auto offset
- tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0xC0, 0x0); // no frequency offset
- tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 0); // setup MPEG2 TS interface
- tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0); // setup MPEG2 TS interface
- tda1004x_write_mask(state, TDA1004X_VBER_MSB, 0xe0, 0xa0); // 10^6 VBER measurement bits
- tda1004x_write_mask(state, TDA1004X_CONFC1, 0x10, 0); // VAGC polarity
- tda1004x_write_byteI(state, TDA1004X_CONFADC1, 0x2e);
-
- tda1004x_write_mask(state, 0x1f, 0x01, state->config->invert_oclk);
-
- return 0;
-}
-
-static int tda10046_init(struct dvb_frontend* fe)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- dprintk("%s\n", __FUNCTION__);
-
- if (tda10046_fwupload(fe)) {
- printk("tda1004x: firmware upload failed\n");
- return -EIO;
- }
-
- // tda setup
- tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
- tda1004x_write_byteI(state, TDA1004X_AUTO, 0x87); // 100 ppm crystal, select HP stream
- tda1004x_write_byteI(state, TDA1004X_CONFC1, 0x88); // enable pulse killer
-
- switch (state->config->agc_config) {
- case TDA10046_AGC_DEFAULT:
- tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x00); // AGC setup
- tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
- break;
- case TDA10046_AGC_IFO_AUTO_NEG:
- tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup
- tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
- break;
- case TDA10046_AGC_IFO_AUTO_POS:
- tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x0a); // AGC setup
- tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x00); // set AGC polarities
- break;
- case TDA10046_AGC_TDA827X:
- tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup
- tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold
- tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize
- tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x6a); // set AGC polarities
- break;
- case TDA10046_AGC_TDA827X_GPL:
- tda1004x_write_byteI(state, TDA10046H_AGC_CONF, 0x02); // AGC setup
- tda1004x_write_byteI(state, TDA10046H_AGC_THR, 0x70); // AGC Threshold
- tda1004x_write_byteI(state, TDA10046H_AGC_RENORM, 0x08); // Gain Renormalize
- tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
- break;
- }
- tda1004x_write_byteI(state, TDA1004X_CONFADC2, 0x38);
- tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0x61); // Turn both AGC outputs on
- tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MIN, 0); // }
- tda1004x_write_byteI(state, TDA10046H_AGC_TUN_MAX, 0xff); // } AGC min/max values
- tda1004x_write_byteI(state, TDA10046H_AGC_IF_MIN, 0); // }
- tda1004x_write_byteI(state, TDA10046H_AGC_IF_MAX, 0xff); // }
- tda1004x_write_byteI(state, TDA10046H_AGC_GAINS, 0x12); // IF gain 2, TUN gain 1
- tda1004x_write_byteI(state, TDA10046H_CVBER_CTRL, 0x1a); // 10^6 VBER measurement bits
- tda1004x_write_byteI(state, TDA1004X_CONF_TS1, 7); // MPEG2 interface config
- tda1004x_write_byteI(state, TDA1004X_CONF_TS2, 0xc0); // MPEG2 interface config
- // tda1004x_write_mask(state, 0x50, 0x80, 0x80); // handle out of guard echoes
- tda1004x_write_mask(state, 0x3a, 0x80, state->config->invert_oclk << 7);
-
- return 0;
-}
-
-static int tda1004x_set_fe(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *fe_params)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int tmp;
- int inversion;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (state->demod_type == TDA1004X_DEMOD_TDA10046) {
- // setup auto offset
- tda1004x_write_mask(state, TDA1004X_AUTO, 0x10, 0x10);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x80, 0);
- tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0xC0, 0);
-
- // disable agc_conf[2]
- tda1004x_write_mask(state, TDA10046H_AGC_CONF, 4, 0);
- }
-
- // set frequency
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, fe_params);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- // Hardcoded to use auto as much as possible on the TDA10045 as it
- // is very unreliable if AUTO mode is _not_ used.
- if (state->demod_type == TDA1004X_DEMOD_TDA10045) {
- fe_params->u.ofdm.code_rate_HP = FEC_AUTO;
- fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_AUTO;
- fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO;
- }
-
- // Set standard params.. or put them to auto
- if ((fe_params->u.ofdm.code_rate_HP == FEC_AUTO) ||
- (fe_params->u.ofdm.code_rate_LP == FEC_AUTO) ||
- (fe_params->u.ofdm.constellation == QAM_AUTO) ||
- (fe_params->u.ofdm.hierarchy_information == HIERARCHY_AUTO)) {
- tda1004x_write_mask(state, TDA1004X_AUTO, 1, 1); // enable auto
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x03, 0); // turn off constellation bits
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0); // turn off hierarchy bits
- tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0x3f, 0); // turn off FEC bits
- } else {
- tda1004x_write_mask(state, TDA1004X_AUTO, 1, 0); // disable auto
-
- // set HP FEC
- tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_HP);
- if (tmp < 0)
- return tmp;
- tda1004x_write_mask(state, TDA1004X_IN_CONF2, 7, tmp);
-
- // set LP FEC
- tmp = tda1004x_encode_fec(fe_params->u.ofdm.code_rate_LP);
- if (tmp < 0)
- return tmp;
- tda1004x_write_mask(state, TDA1004X_IN_CONF2, 0x38, tmp << 3);
-
- // set constellation
- switch (fe_params->u.ofdm.constellation) {
- case QPSK:
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 3, 0);
- break;
-
- case QAM_16:
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 3, 1);
- break;
-
- case QAM_64:
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 3, 2);
- break;
-
- default:
- return -EINVAL;
- }
-
- // set hierarchy
- switch (fe_params->u.ofdm.hierarchy_information) {
- case HIERARCHY_NONE:
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 0 << 5);
- break;
-
- case HIERARCHY_1:
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 1 << 5);
- break;
-
- case HIERARCHY_2:
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 2 << 5);
- break;
-
- case HIERARCHY_4:
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x60, 3 << 5);
- break;
-
- default:
- return -EINVAL;
- }
- }
-
- // set bandwidth
- switch (state->demod_type) {
- case TDA1004X_DEMOD_TDA10045:
- tda10045h_set_bandwidth(state, fe_params->u.ofdm.bandwidth);
- break;
-
- case TDA1004X_DEMOD_TDA10046:
- tda10046h_set_bandwidth(state, fe_params->u.ofdm.bandwidth);
- break;
- }
-
- // set inversion
- inversion = fe_params->inversion;
- if (state->config->invert)
- inversion = inversion ? INVERSION_OFF : INVERSION_ON;
- switch (inversion) {
- case INVERSION_OFF:
- tda1004x_write_mask(state, TDA1004X_CONFC1, 0x20, 0);
- break;
-
- case INVERSION_ON:
- tda1004x_write_mask(state, TDA1004X_CONFC1, 0x20, 0x20);
- break;
-
- default:
- return -EINVAL;
- }
-
- // set guard interval
- switch (fe_params->u.ofdm.guard_interval) {
- case GUARD_INTERVAL_1_32:
- tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 0 << 2);
- break;
-
- case GUARD_INTERVAL_1_16:
- tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 1 << 2);
- break;
-
- case GUARD_INTERVAL_1_8:
- tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 2 << 2);
- break;
-
- case GUARD_INTERVAL_1_4:
- tda1004x_write_mask(state, TDA1004X_AUTO, 2, 0);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 3 << 2);
- break;
-
- case GUARD_INTERVAL_AUTO:
- tda1004x_write_mask(state, TDA1004X_AUTO, 2, 2);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x0c, 0 << 2);
- break;
-
- default:
- return -EINVAL;
- }
-
- // set transmission mode
- switch (fe_params->u.ofdm.transmission_mode) {
- case TRANSMISSION_MODE_2K:
- tda1004x_write_mask(state, TDA1004X_AUTO, 4, 0);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x10, 0 << 4);
- break;
-
- case TRANSMISSION_MODE_8K:
- tda1004x_write_mask(state, TDA1004X_AUTO, 4, 0);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x10, 1 << 4);
- break;
-
- case TRANSMISSION_MODE_AUTO:
- tda1004x_write_mask(state, TDA1004X_AUTO, 4, 4);
- tda1004x_write_mask(state, TDA1004X_IN_CONF1, 0x10, 0);
- break;
-
- default:
- return -EINVAL;
- }
-
- // start the lock
- switch (state->demod_type) {
- case TDA1004X_DEMOD_TDA10045:
- tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8);
- tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 0);
- break;
-
- case TDA1004X_DEMOD_TDA10046:
- tda1004x_write_mask(state, TDA1004X_AUTO, 0x40, 0x40);
- msleep(1);
- tda1004x_write_mask(state, TDA10046H_AGC_CONF, 4, 1);
- break;
- }
-
- msleep(10);
-
- return 0;
-}
-
-static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_parameters *fe_params)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
-
- dprintk("%s\n", __FUNCTION__);
-
- // inversion status
- fe_params->inversion = INVERSION_OFF;
- if (tda1004x_read_byte(state, TDA1004X_CONFC1) & 0x20)
- fe_params->inversion = INVERSION_ON;
- if (state->config->invert)
- fe_params->inversion = fe_params->inversion ? INVERSION_OFF : INVERSION_ON;
-
- // bandwidth
- switch (state->demod_type) {
- case TDA1004X_DEMOD_TDA10045:
- switch (tda1004x_read_byte(state, TDA10045H_WREF_LSB)) {
- case 0x14:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
- break;
- case 0xdb:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
- break;
- case 0x4f:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
- break;
- }
- break;
- case TDA1004X_DEMOD_TDA10046:
- switch (tda1004x_read_byte(state, TDA10046H_TIME_WREF1)) {
- case 0x5c:
- case 0x54:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
- break;
- case 0x6a:
- case 0x60:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
- break;
- case 0x7b:
- case 0x70:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
- break;
- }
- break;
- }
-
- // FEC
- fe_params->u.ofdm.code_rate_HP =
- tda1004x_decode_fec(tda1004x_read_byte(state, TDA1004X_OUT_CONF2) & 7);
- fe_params->u.ofdm.code_rate_LP =
- tda1004x_decode_fec((tda1004x_read_byte(state, TDA1004X_OUT_CONF2) >> 3) & 7);
-
- // constellation
- switch (tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 3) {
- case 0:
- fe_params->u.ofdm.constellation = QPSK;
- break;
- case 1:
- fe_params->u.ofdm.constellation = QAM_16;
- break;
- case 2:
- fe_params->u.ofdm.constellation = QAM_64;
- break;
- }
-
- // transmission mode
- fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
- if (tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x10)
- fe_params->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
-
- // guard interval
- switch ((tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x0c) >> 2) {
- case 0:
- fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
- break;
- case 1:
- fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_1_16;
- break;
- case 2:
- fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_1_8;
- break;
- case 3:
- fe_params->u.ofdm.guard_interval = GUARD_INTERVAL_1_4;
- break;
- }
-
- // hierarchy
- switch ((tda1004x_read_byte(state, TDA1004X_OUT_CONF1) & 0x60) >> 5) {
- case 0:
- fe_params->u.ofdm.hierarchy_information = HIERARCHY_NONE;
- break;
- case 1:
- fe_params->u.ofdm.hierarchy_information = HIERARCHY_1;
- break;
- case 2:
- fe_params->u.ofdm.hierarchy_information = HIERARCHY_2;
- break;
- case 3:
- fe_params->u.ofdm.hierarchy_information = HIERARCHY_4;
- break;
- }
-
- return 0;
-}
-
-static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int status;
- int cber;
- int vber;
-
- dprintk("%s\n", __FUNCTION__);
-
- // read status
- status = tda1004x_read_byte(state, TDA1004X_STATUS_CD);
- if (status == -1)
- return -EIO;
-
- // decode
- *fe_status = 0;
- if (status & 4)
- *fe_status |= FE_HAS_SIGNAL;
- if (status & 2)
- *fe_status |= FE_HAS_CARRIER;
- if (status & 8)
- *fe_status |= FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK;
-
- // if we don't already have VITERBI (i.e. not LOCKED), see if the viterbi
- // is getting anything valid
- if (!(*fe_status & FE_HAS_VITERBI)) {
- // read the CBER
- cber = tda1004x_read_byte(state, TDA1004X_CBER_LSB);
- if (cber == -1)
- return -EIO;
- status = tda1004x_read_byte(state, TDA1004X_CBER_MSB);
- if (status == -1)
- return -EIO;
- cber |= (status << 8);
- // The address 0x20 should be read to cope with a TDA10046 bug
- tda1004x_read_byte(state, TDA1004X_CBER_RESET);
-
- if (cber != 65535)
- *fe_status |= FE_HAS_VITERBI;
- }
-
- // if we DO have some valid VITERBI output, but don't already have SYNC
- // bytes (i.e. not LOCKED), see if the RS decoder is getting anything valid.
- if ((*fe_status & FE_HAS_VITERBI) && (!(*fe_status & FE_HAS_SYNC))) {
- // read the VBER
- vber = tda1004x_read_byte(state, TDA1004X_VBER_LSB);
- if (vber == -1)
- return -EIO;
- status = tda1004x_read_byte(state, TDA1004X_VBER_MID);
- if (status == -1)
- return -EIO;
- vber |= (status << 8);
- status = tda1004x_read_byte(state, TDA1004X_VBER_MSB);
- if (status == -1)
- return -EIO;
- vber |= (status & 0x0f) << 16;
- // The CVBER_LUT should be read to cope with TDA10046 hardware bug
- tda1004x_read_byte(state, TDA1004X_CVBER_LUT);
-
- // if RS has passed some valid TS packets, then we must be
- // getting some SYNC bytes
- if (vber < 16632)
- *fe_status |= FE_HAS_SYNC;
- }
-
- // success
- dprintk("%s: fe_status=0x%x\n", __FUNCTION__, *fe_status);
- return 0;
-}
-
-static int tda1004x_read_signal_strength(struct dvb_frontend* fe, u16 * signal)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int tmp;
- int reg = 0;
-
- dprintk("%s\n", __FUNCTION__);
-
- // determine the register to use
- switch (state->demod_type) {
- case TDA1004X_DEMOD_TDA10045:
- reg = TDA10045H_S_AGC;
- break;
-
- case TDA1004X_DEMOD_TDA10046:
- reg = TDA10046H_AGC_IF_LEVEL;
- break;
- }
-
- // read it
- tmp = tda1004x_read_byte(state, reg);
- if (tmp < 0)
- return -EIO;
-
- *signal = (tmp << 8) | tmp;
- dprintk("%s: signal=0x%x\n", __FUNCTION__, *signal);
- return 0;
-}
-
-static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int tmp;
-
- dprintk("%s\n", __FUNCTION__);
-
- // read it
- tmp = tda1004x_read_byte(state, TDA1004X_SNR);
- if (tmp < 0)
- return -EIO;
- tmp = 255 - tmp;
-
- *snr = ((tmp << 8) | tmp);
- dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr);
- return 0;
-}
-
-static int tda1004x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int tmp;
- int tmp2;
- int counter;
-
- dprintk("%s\n", __FUNCTION__);
-
- // read the UCBLOCKS and reset
- counter = 0;
- tmp = tda1004x_read_byte(state, TDA1004X_UNCOR);
- if (tmp < 0)
- return -EIO;
- tmp &= 0x7f;
- while (counter++ < 5) {
- tda1004x_write_mask(state, TDA1004X_UNCOR, 0x80, 0);
- tda1004x_write_mask(state, TDA1004X_UNCOR, 0x80, 0);
- tda1004x_write_mask(state, TDA1004X_UNCOR, 0x80, 0);
-
- tmp2 = tda1004x_read_byte(state, TDA1004X_UNCOR);
- if (tmp2 < 0)
- return -EIO;
- tmp2 &= 0x7f;
- if ((tmp2 < tmp) || (tmp2 == 0))
- break;
- }
-
- if (tmp != 0x7f)
- *ucblocks = tmp;
- else
- *ucblocks = 0xffffffff;
-
- dprintk("%s: ucblocks=0x%x\n", __FUNCTION__, *ucblocks);
- return 0;
-}
-
-static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- int tmp;
-
- dprintk("%s\n", __FUNCTION__);
-
- // read it in
- tmp = tda1004x_read_byte(state, TDA1004X_CBER_LSB);
- if (tmp < 0)
- return -EIO;
- *ber = tmp << 1;
- tmp = tda1004x_read_byte(state, TDA1004X_CBER_MSB);
- if (tmp < 0)
- return -EIO;
- *ber |= (tmp << 9);
- // The address 0x20 should be read to cope with a TDA10046 bug
- tda1004x_read_byte(state, TDA1004X_CBER_RESET);
-
- dprintk("%s: ber=0x%x\n", __FUNCTION__, *ber);
- return 0;
-}
-
-static int tda1004x_sleep(struct dvb_frontend* fe)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
-
- switch (state->demod_type) {
- case TDA1004X_DEMOD_TDA10045:
- tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0x10);
- break;
-
- case TDA1004X_DEMOD_TDA10046:
- /* set outputs to tristate */
- tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE1, 0xff);
- tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
- break;
- }
-
- return 0;
-}
-
-static int tda1004x_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
-
- if (enable) {
- return tda1004x_enable_tuner_i2c(state);
- } else {
- return tda1004x_disable_tuner_i2c(state);
- }
-}
-
-static int tda1004x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 800;
- /* Drift compensation makes no sense for DVB-T */
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static void tda1004x_release(struct dvb_frontend* fe)
-{
- struct tda1004x_state *state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops tda10045_ops = {
- .info = {
- .name = "Philips TDA10045H DVB-T",
- .type = FE_OFDM,
- .frequency_min = 51000000,
- .frequency_max = 858000000,
- .frequency_stepsize = 166667,
- .caps =
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
- },
-
- .release = tda1004x_release,
-
- .init = tda10045_init,
- .sleep = tda1004x_sleep,
- .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl,
-
- .set_frontend = tda1004x_set_fe,
- .get_frontend = tda1004x_get_fe,
- .get_tune_settings = tda1004x_get_tune_settings,
-
- .read_status = tda1004x_read_status,
- .read_ber = tda1004x_read_ber,
- .read_signal_strength = tda1004x_read_signal_strength,
- .read_snr = tda1004x_read_snr,
- .read_ucblocks = tda1004x_read_ucblocks,
-};
-
-struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
- struct i2c_adapter* i2c)
-{
- struct tda1004x_state *state;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
- if (!state)
- return NULL;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->demod_type = TDA1004X_DEMOD_TDA10045;
-
- /* check if the demod is there */
- if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x25) {
- kfree(state);
- return NULL;
- }
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-}
-
-static struct dvb_frontend_ops tda10046_ops = {
- .info = {
- .name = "Philips TDA10046H DVB-T",
- .type = FE_OFDM,
- .frequency_min = 51000000,
- .frequency_max = 858000000,
- .frequency_stepsize = 166667,
- .caps =
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO
- },
-
- .release = tda1004x_release,
-
- .init = tda10046_init,
- .sleep = tda1004x_sleep,
- .i2c_gate_ctrl = tda1004x_i2c_gate_ctrl,
-
- .set_frontend = tda1004x_set_fe,
- .get_frontend = tda1004x_get_fe,
- .get_tune_settings = tda1004x_get_tune_settings,
-
- .read_status = tda1004x_read_status,
- .read_ber = tda1004x_read_ber,
- .read_signal_strength = tda1004x_read_signal_strength,
- .read_snr = tda1004x_read_snr,
- .read_ucblocks = tda1004x_read_ucblocks,
-};
-
-struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
- struct i2c_adapter* i2c)
-{
- struct tda1004x_state *state;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
- if (!state)
- return NULL;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->demod_type = TDA1004X_DEMOD_TDA10046;
-
- /* check if the demod is there */
- if (tda1004x_read_byte(state, TDA1004X_CHIPID) != 0x46) {
- kfree(state);
- return NULL;
- }
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-}
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Philips TDA10045H & TDA10046H DVB-T Demodulator");
-MODULE_AUTHOR("Andrew de Quincey & Robert Schlabbach");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(tda10045_attach);
-EXPORT_SYMBOL(tda10046_attach);
-EXPORT_SYMBOL(tda1004x_write_byte);
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h
deleted file mode 100644
index b877b23ed73..00000000000
--- a/drivers/media/dvb/frontends/tda1004x.h
+++ /dev/null
@@ -1,82 +0,0 @@
- /*
- Driver for Philips tda1004xh OFDM Frontend
-
- (c) 2004 Andrew de Quincey
-
- 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.
-
- */
-
-#ifndef TDA1004X_H
-#define TDA1004X_H
-
-#include <linux/dvb/frontend.h>
-#include <linux/firmware.h>
-
-enum tda10046_xtal {
- TDA10046_XTAL_4M,
- TDA10046_XTAL_16M,
-};
-
-enum tda10046_agc {
- TDA10046_AGC_DEFAULT, /* original configuration */
- TDA10046_AGC_IFO_AUTO_NEG, /* IF AGC only, automatic, negtive */
- TDA10046_AGC_IFO_AUTO_POS, /* IF AGC only, automatic, positive */
- TDA10046_AGC_TDA827X, /* IF AGC only, special setup for tda827x */
- TDA10046_AGC_TDA827X_GPL, /* same as above, but GPIOs 0 */
-};
-
-enum tda10046_if {
- TDA10046_FREQ_3617, /* original config, 36,166 MHZ */
- TDA10046_FREQ_3613, /* 36,13 MHZ */
- TDA10046_FREQ_045, /* low IF, 4.0, 4.5, or 5.0 MHZ */
- TDA10046_FREQ_052, /* low IF, 5.1667 MHZ for tda9889 */
-};
-
-struct tda1004x_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* does the "inversion" need inverted? */
- u8 invert;
-
- /* Does the OCLK signal need inverted? */
- u8 invert_oclk;
-
- /* Xtal frequency, 4 or 16MHz*/
- enum tda10046_xtal xtal_freq;
-
- /* IF frequency */
- enum tda10046_if if_freq;
-
- /* AGC configuration */
- enum tda10046_agc agc_config;
-
- /* request firmware for device */
- /* set this to NULL if the card has a firmware EEPROM */
- int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name);
-};
-
-extern struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
- struct i2c_adapter* i2c);
-
-extern struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
- struct i2c_adapter* i2c);
-
-extern int tda1004x_write_byte(struct dvb_frontend* fe, int reg, int data);
-
-#endif // TDA1004X_H
diff --git a/drivers/media/dvb/frontends/tda8083.c b/drivers/media/dvb/frontends/tda8083.c
deleted file mode 100644
index 3aa45ebbac3..00000000000
--- a/drivers/media/dvb/frontends/tda8083.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/*
- Driver for Philips TDA8083 based QPSK Demodulator
-
- Copyright (C) 2001 Convergence Integrated Media GmbH
-
- written by Ralph Metzler <ralph@convergence.de>
-
- adoption to the new DVB frontend API and diagnostic ioctl's
- by Holger Waechtler <holger@convergence.de>
-
- 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/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/jiffies.h>
-#include "dvb_frontend.h"
-#include "tda8083.h"
-
-
-struct tda8083_state {
- struct i2c_adapter* i2c;
- /* configuration settings */
- const struct tda8083_config* config;
- struct dvb_frontend frontend;
-};
-
-static int debug;
-#define dprintk(args...) \
- do { \
- if (debug) printk(KERN_DEBUG "tda8083: " args); \
- } while (0)
-
-
-static u8 tda8083_init_tab [] = {
- 0x04, 0x00, 0x4a, 0x79, 0x04, 0x00, 0xff, 0xea,
- 0x48, 0x42, 0x79, 0x60, 0x70, 0x52, 0x9a, 0x10,
- 0x0e, 0x10, 0xf2, 0xa7, 0x93, 0x0b, 0x05, 0xc8,
- 0x9d, 0x00, 0x42, 0x80, 0x00, 0x60, 0x40, 0x00,
- 0x00, 0x75, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00
-};
-
-
-static int tda8083_writereg (struct tda8083_state* state, u8 reg, u8 data)
-{
- int ret;
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
-
- ret = i2c_transfer(state->i2c, &msg, 1);
-
- if (ret != 1)
- dprintk ("%s: writereg error (reg %02x, ret == %i)\n",
- __FUNCTION__, reg, ret);
-
- return (ret != 1) ? -1 : 0;
-}
-
-static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len)
-{
- int ret;
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = &reg1, .len = 1 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = len } };
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2)
- dprintk ("%s: readreg error (reg %02x, ret == %i)\n",
- __FUNCTION__, reg1, ret);
-
- return ret == 2 ? 0 : -1;
-}
-
-static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg)
-{
- u8 val;
-
- tda8083_readregs (state, reg, &val, 1);
-
- return val;
-}
-
-static int tda8083_set_inversion (struct tda8083_state* state, fe_spectral_inversion_t inversion)
-{
- /* XXX FIXME: implement other modes than FEC_AUTO */
- if (inversion == INVERSION_AUTO)
- return 0;
-
- return -EINVAL;
-}
-
-static int tda8083_set_fec (struct tda8083_state* state, fe_code_rate_t fec)
-{
- if (fec == FEC_AUTO)
- return tda8083_writereg (state, 0x07, 0xff);
-
- if (fec >= FEC_1_2 && fec <= FEC_8_9)
- return tda8083_writereg (state, 0x07, 1 << (FEC_8_9 - fec));
-
- return -EINVAL;
-}
-
-static fe_code_rate_t tda8083_get_fec (struct tda8083_state* state)
-{
- u8 index;
- static fe_code_rate_t fec_tab [] = { FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
- FEC_4_5, FEC_5_6, FEC_6_7, FEC_7_8 };
-
- index = tda8083_readreg(state, 0x0e) & 0x07;
-
- return fec_tab [index];
-}
-
-static int tda8083_set_symbolrate (struct tda8083_state* state, u32 srate)
-{
- u32 ratio;
- u32 tmp;
- u8 filter;
-
- if (srate > 32000000)
- srate = 32000000;
- if (srate < 500000)
- srate = 500000;
-
- filter = 0;
- if (srate < 24000000)
- filter = 2;
- if (srate < 16000000)
- filter = 3;
-
- tmp = 31250 << 16;
- ratio = tmp / srate;
-
- tmp = (tmp % srate) << 8;
- ratio = (ratio << 8) + tmp / srate;
-
- tmp = (tmp % srate) << 8;
- ratio = (ratio << 8) + tmp / srate;
-
- dprintk("tda8083: ratio == %08x\n", (unsigned int) ratio);
-
- tda8083_writereg (state, 0x05, filter);
- tda8083_writereg (state, 0x02, (ratio >> 16) & 0xff);
- tda8083_writereg (state, 0x03, (ratio >> 8) & 0xff);
- tda8083_writereg (state, 0x04, (ratio ) & 0xff);
-
- tda8083_writereg (state, 0x00, 0x3c);
- tda8083_writereg (state, 0x00, 0x04);
-
- return 1;
-}
-
-static void tda8083_wait_diseqc_fifo (struct tda8083_state* state, int timeout)
-{
- unsigned long start = jiffies;
-
- while (jiffies - start < timeout &&
- !(tda8083_readreg(state, 0x02) & 0x80))
- {
- msleep(50);
- };
-}
-
-static int tda8083_set_tone (struct tda8083_state* state, fe_sec_tone_mode_t tone)
-{
- tda8083_writereg (state, 0x26, 0xf1);
-
- switch (tone) {
- case SEC_TONE_OFF:
- return tda8083_writereg (state, 0x29, 0x00);
- case SEC_TONE_ON:
- return tda8083_writereg (state, 0x29, 0x80);
- default:
- return -EINVAL;
- };
-}
-
-static int tda8083_set_voltage (struct tda8083_state* state, fe_sec_voltage_t voltage)
-{
- switch (voltage) {
- case SEC_VOLTAGE_13:
- return tda8083_writereg (state, 0x20, 0x00);
- case SEC_VOLTAGE_18:
- return tda8083_writereg (state, 0x20, 0x11);
- default:
- return -EINVAL;
- };
-}
-
-static int tda8083_send_diseqc_burst (struct tda8083_state* state, fe_sec_mini_cmd_t burst)
-{
- switch (burst) {
- case SEC_MINI_A:
- tda8083_writereg (state, 0x29, (5 << 2)); /* send burst A */
- break;
- case SEC_MINI_B:
- tda8083_writereg (state, 0x29, (7 << 2)); /* send B */
- break;
- default:
- return -EINVAL;
- };
-
- tda8083_wait_diseqc_fifo (state, 100);
-
- return 0;
-}
-
-static int tda8083_send_diseqc_msg (struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd *m)
-{
- struct tda8083_state* state = fe->demodulator_priv;
- int i;
-
- tda8083_writereg (state, 0x29, (m->msg_len - 3) | (1 << 2)); /* enable */
-
- for (i=0; i<m->msg_len; i++)
- tda8083_writereg (state, 0x23 + i, m->msg[i]);
-
- tda8083_writereg (state, 0x29, (m->msg_len - 3) | (3 << 2)); /* send!! */
-
- tda8083_wait_diseqc_fifo (state, 100);
-
- return 0;
-}
-
-static int tda8083_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- u8 signal = ~tda8083_readreg (state, 0x01);
- u8 sync = tda8083_readreg (state, 0x02);
-
- *status = 0;
-
- if (signal > 10)
- *status |= FE_HAS_SIGNAL;
-
- if (sync & 0x01)
- *status |= FE_HAS_CARRIER;
-
- if (sync & 0x02)
- *status |= FE_HAS_VITERBI;
-
- if (sync & 0x10)
- *status |= FE_HAS_SYNC;
-
- if ((sync & 0x1f) == 0x1f)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int tda8083_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- u8 signal = ~tda8083_readreg (state, 0x01);
- *strength = (signal << 8) | signal;
-
- return 0;
-}
-
-static int tda8083_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- u8 _snr = tda8083_readreg (state, 0x08);
- *snr = (_snr << 8) | _snr;
-
- return 0;
-}
-
-static int tda8083_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- tda8083_set_inversion (state, p->inversion);
- tda8083_set_fec (state, p->u.qpsk.fec_inner);
- tda8083_set_symbolrate (state, p->u.qpsk.symbol_rate);
-
- tda8083_writereg (state, 0x00, 0x3c);
- tda8083_writereg (state, 0x00, 0x04);
-
- return 0;
-}
-
-static int tda8083_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- /* FIXME: get symbolrate & frequency offset...*/
- /*p->frequency = ???;*/
- p->inversion = (tda8083_readreg (state, 0x0e) & 0x80) ?
- INVERSION_ON : INVERSION_OFF;
- p->u.qpsk.fec_inner = tda8083_get_fec (state);
- /*p->u.qpsk.symbol_rate = tda8083_get_symbolrate (state);*/
-
- return 0;
-}
-
-static int tda8083_sleep(struct dvb_frontend* fe)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- tda8083_writereg (state, 0x00, 0x02);
- return 0;
-}
-
-static int tda8083_init(struct dvb_frontend* fe)
-{
- struct tda8083_state* state = fe->demodulator_priv;
- int i;
-
- for (i=0; i<44; i++)
- tda8083_writereg (state, i, tda8083_init_tab[i]);
-
- tda8083_writereg (state, 0x00, 0x3c);
- tda8083_writereg (state, 0x00, 0x04);
-
- return 0;
-}
-
-static int tda8083_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- tda8083_send_diseqc_burst (state, burst);
- tda8083_writereg (state, 0x00, 0x3c);
- tda8083_writereg (state, 0x00, 0x04);
-
- return 0;
-}
-
-static int tda8083_diseqc_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- tda8083_set_tone (state, tone);
- tda8083_writereg (state, 0x00, 0x3c);
- tda8083_writereg (state, 0x00, 0x04);
-
- return 0;
-}
-
-static int tda8083_diseqc_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct tda8083_state* state = fe->demodulator_priv;
-
- tda8083_set_voltage (state, voltage);
- tda8083_writereg (state, 0x00, 0x3c);
- tda8083_writereg (state, 0x00, 0x04);
-
- return 0;
-}
-
-static void tda8083_release(struct dvb_frontend* fe)
-{
- struct tda8083_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops tda8083_ops;
-
-struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
- struct i2c_adapter* i2c)
-{
- struct tda8083_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct tda8083_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
-
- /* check if the demod is there */
- if ((tda8083_readreg(state, 0x00)) != 0x05) goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &tda8083_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops tda8083_ops = {
-
- .info = {
- .name = "Philips TDA8083 DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000, /* FIXME: guessed! */
- .frequency_max = 1400000, /* FIXME: guessed! */
- .frequency_stepsize = 125, /* kHz for QPSK frontends */
- /* .frequency_tolerance = ???,*/
- .symbol_rate_min = 1000000, /* FIXME: guessed! */
- .symbol_rate_max = 45000000, /* FIXME: guessed! */
- /* .symbol_rate_tolerance = ???,*/
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
- FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_MUTE_TS
- },
-
- .release = tda8083_release,
-
- .init = tda8083_init,
- .sleep = tda8083_sleep,
-
- .set_frontend = tda8083_set_frontend,
- .get_frontend = tda8083_get_frontend,
-
- .read_status = tda8083_read_status,
- .read_signal_strength = tda8083_read_signal_strength,
- .read_snr = tda8083_read_snr,
-
- .diseqc_send_master_cmd = tda8083_send_diseqc_msg,
- .diseqc_send_burst = tda8083_diseqc_send_burst,
- .set_tone = tda8083_diseqc_set_tone,
- .set_voltage = tda8083_diseqc_set_voltage,
-};
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
-
-MODULE_DESCRIPTION("Philips TDA8083 DVB-S Demodulator");
-MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(tda8083_attach);
diff --git a/drivers/media/dvb/frontends/tda8083.h b/drivers/media/dvb/frontends/tda8083.h
deleted file mode 100644
index e7a48f61ea2..00000000000
--- a/drivers/media/dvb/frontends/tda8083.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Driver for Grundig 29504-491, a Philips TDA8083 based QPSK Frontend
-
- Copyright (C) 2001 Convergence Integrated Media GmbH
-
- written by Ralph Metzler <ralph@convergence.de>
-
- adoption to the new DVB frontend API and diagnostic ioctl's
- by Holger Waechtler <holger@convergence.de>
-
- 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.
-
-*/
-
-#ifndef TDA8083_H
-#define TDA8083_H
-
-#include <linux/dvb/frontend.h>
-
-struct tda8083_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-};
-
-extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
- struct i2c_adapter* i2c);
-
-#endif // TDA8083_H
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
deleted file mode 100644
index 9b57576bfeb..00000000000
--- a/drivers/media/dvb/frontends/ves1820.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- VES1820 - Single Chip Cable Channel Receiver driver module
-
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
-
- 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/delay.h>
-#include <linux/errno.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <asm/div64.h>
-
-#include "dvb_frontend.h"
-#include "ves1820.h"
-
-
-
-struct ves1820_state {
- struct i2c_adapter* i2c;
- /* configuration settings */
- const struct ves1820_config* config;
- struct dvb_frontend frontend;
-
- /* private demodulator data */
- u8 reg0;
- u8 pwm;
-};
-
-
-static int verbose;
-
-static u8 ves1820_inittab[] = {
- 0x69, 0x6A, 0x93, 0x12, 0x12, 0x46, 0x26, 0x1A,
- 0x43, 0x6A, 0xAA, 0xAA, 0x1E, 0x85, 0x43, 0x20,
- 0xE0, 0x00, 0xA1, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x40
-};
-
-static int ves1820_writereg(struct ves1820_state *state, u8 reg, u8 data)
-{
- u8 buf[] = { 0x00, reg, data };
- struct i2c_msg msg = {.addr = state->config->demod_address,.flags = 0,.buf = buf,.len = 3 };
- int ret;
-
- ret = i2c_transfer(state->i2c, &msg, 1);
-
- if (ret != 1)
- printk("ves1820: %s(): writereg error (reg == 0x%02x,"
- "val == 0x%02x, ret == %i)\n", __FUNCTION__, reg, data, ret);
-
- return (ret != 1) ? -EREMOTEIO : 0;
-}
-
-static u8 ves1820_readreg(struct ves1820_state *state, u8 reg)
-{
- u8 b0[] = { 0x00, reg };
- u8 b1[] = { 0 };
- struct i2c_msg msg[] = {
- {.addr = state->config->demod_address,.flags = 0,.buf = b0,.len = 2},
- {.addr = state->config->demod_address,.flags = I2C_M_RD,.buf = b1,.len = 1}
- };
- int ret;
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2)
- printk("ves1820: %s(): readreg error (reg == 0x%02x,"
- "ret == %i)\n", __FUNCTION__, reg, ret);
-
- return b1[0];
-}
-
-static int ves1820_setup_reg0(struct ves1820_state *state, u8 reg0, fe_spectral_inversion_t inversion)
-{
- reg0 |= state->reg0 & 0x62;
-
- if (INVERSION_ON == inversion) {
- if (!state->config->invert) reg0 |= 0x20;
- else reg0 &= ~0x20;
- } else if (INVERSION_OFF == inversion) {
- if (!state->config->invert) reg0 &= ~0x20;
- else reg0 |= 0x20;
- }
-
- ves1820_writereg(state, 0x00, reg0 & 0xfe);
- ves1820_writereg(state, 0x00, reg0 | 0x01);
-
- state->reg0 = reg0;
-
- return 0;
-}
-
-static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
-{
- s32 BDR;
- s32 BDRI;
- s16 SFIL = 0;
- u16 NDEC = 0;
- u32 ratio;
- u32 fin;
- u32 tmp;
- u64 fptmp;
- u64 fpxin;
-
- if (symbolrate > state->config->xin / 2)
- symbolrate = state->config->xin / 2;
-
- if (symbolrate < 500000)
- symbolrate = 500000;
-
- if (symbolrate < state->config->xin / 16)
- NDEC = 1;
- if (symbolrate < state->config->xin / 32)
- NDEC = 2;
- if (symbolrate < state->config->xin / 64)
- NDEC = 3;
-
- /* yeuch! */
- fpxin = state->config->xin * 10;
- fptmp = fpxin; do_div(fptmp, 123);
- if (symbolrate < fptmp)
- SFIL = 1;
- fptmp = fpxin; do_div(fptmp, 160);
- if (symbolrate < fptmp)
- SFIL = 0;
- fptmp = fpxin; do_div(fptmp, 246);
- if (symbolrate < fptmp)
- SFIL = 1;
- fptmp = fpxin; do_div(fptmp, 320);
- if (symbolrate < fptmp)
- SFIL = 0;
- fptmp = fpxin; do_div(fptmp, 492);
- if (symbolrate < fptmp)
- SFIL = 1;
- fptmp = fpxin; do_div(fptmp, 640);
- if (symbolrate < fptmp)
- SFIL = 0;
- fptmp = fpxin; do_div(fptmp, 984);
- if (symbolrate < fptmp)
- SFIL = 1;
-
- fin = state->config->xin >> 4;
- symbolrate <<= NDEC;
- ratio = (symbolrate << 4) / fin;
- tmp = ((symbolrate << 4) % fin) << 8;
- ratio = (ratio << 8) + tmp / fin;
- tmp = (tmp % fin) << 8;
- ratio = (ratio << 8) + (tmp + fin / 2) / fin;
-
- BDR = ratio;
- BDRI = (((state->config->xin << 5) / symbolrate) + 1) / 2;
-
- if (BDRI > 0xFF)
- BDRI = 0xFF;
-
- SFIL = (SFIL << 4) | ves1820_inittab[0x0E];
-
- NDEC = (NDEC << 6) | ves1820_inittab[0x03];
-
- ves1820_writereg(state, 0x03, NDEC);
- ves1820_writereg(state, 0x0a, BDR & 0xff);
- ves1820_writereg(state, 0x0b, (BDR >> 8) & 0xff);
- ves1820_writereg(state, 0x0c, (BDR >> 16) & 0x3f);
-
- ves1820_writereg(state, 0x0d, BDRI);
- ves1820_writereg(state, 0x0e, SFIL);
-
- return 0;
-}
-
-static int ves1820_init(struct dvb_frontend* fe)
-{
- struct ves1820_state* state = fe->demodulator_priv;
- int i;
-
- ves1820_writereg(state, 0, 0);
-
- for (i = 0; i < sizeof(ves1820_inittab); i++)
- ves1820_writereg(state, i, ves1820_inittab[i]);
- if (state->config->selagc)
- ves1820_writereg(state, 2, ves1820_inittab[2] | 0x08);
-
- ves1820_writereg(state, 0x34, state->pwm);
-
- return 0;
-}
-
-static int ves1820_set_parameters(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct ves1820_state* state = fe->demodulator_priv;
- static const u8 reg0x00[] = { 0x00, 0x04, 0x08, 0x0c, 0x10 };
- static const u8 reg0x01[] = { 140, 140, 106, 100, 92 };
- static const u8 reg0x05[] = { 135, 100, 70, 54, 38 };
- static const u8 reg0x08[] = { 162, 116, 67, 52, 35 };
- static const u8 reg0x09[] = { 145, 150, 106, 126, 107 };
- int real_qam = p->u.qam.modulation - QAM_16;
-
- if (real_qam < 0 || real_qam > 4)
- return -EINVAL;
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
-
- ves1820_set_symbolrate(state, p->u.qam.symbol_rate);
- ves1820_writereg(state, 0x34, state->pwm);
-
- ves1820_writereg(state, 0x01, reg0x01[real_qam]);
- ves1820_writereg(state, 0x05, reg0x05[real_qam]);
- ves1820_writereg(state, 0x08, reg0x08[real_qam]);
- ves1820_writereg(state, 0x09, reg0x09[real_qam]);
-
- ves1820_setup_reg0(state, reg0x00[real_qam], p->inversion);
- ves1820_writereg(state, 2, ves1820_inittab[2] | (state->config->selagc ? 0x08 : 0));
- return 0;
-}
-
-static int ves1820_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct ves1820_state* state = fe->demodulator_priv;
- int sync;
-
- *status = 0;
- sync = ves1820_readreg(state, 0x11);
-
- if (sync & 1)
- *status |= FE_HAS_SIGNAL;
-
- if (sync & 2)
- *status |= FE_HAS_CARRIER;
-
- if (sync & 2) /* XXX FIXME! */
- *status |= FE_HAS_VITERBI;
-
- if (sync & 4)
- *status |= FE_HAS_SYNC;
-
- if (sync & 8)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int ves1820_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct ves1820_state* state = fe->demodulator_priv;
-
- u32 _ber = ves1820_readreg(state, 0x14) |
- (ves1820_readreg(state, 0x15) << 8) |
- ((ves1820_readreg(state, 0x16) & 0x0f) << 16);
- *ber = 10 * _ber;
-
- return 0;
-}
-
-static int ves1820_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct ves1820_state* state = fe->demodulator_priv;
-
- u8 gain = ves1820_readreg(state, 0x17);
- *strength = (gain << 8) | gain;
-
- return 0;
-}
-
-static int ves1820_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct ves1820_state* state = fe->demodulator_priv;
-
- u8 quality = ~ves1820_readreg(state, 0x18);
- *snr = (quality << 8) | quality;
-
- return 0;
-}
-
-static int ves1820_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct ves1820_state* state = fe->demodulator_priv;
-
- *ucblocks = ves1820_readreg(state, 0x13) & 0x7f;
- if (*ucblocks == 0x7f)
- *ucblocks = 0xffffffff;
-
- /* reset uncorrected block counter */
- ves1820_writereg(state, 0x10, ves1820_inittab[0x10] & 0xdf);
- ves1820_writereg(state, 0x10, ves1820_inittab[0x10]);
-
- return 0;
-}
-
-static int ves1820_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct ves1820_state* state = fe->demodulator_priv;
- int sync;
- s8 afc = 0;
-
- sync = ves1820_readreg(state, 0x11);
- afc = ves1820_readreg(state, 0x19);
- if (verbose) {
- /* AFC only valid when carrier has been recovered */
- printk(sync & 2 ? "ves1820: AFC (%d) %dHz\n" :
- "ves1820: [AFC (%d) %dHz]\n", afc, -((s32) p->u.qam.symbol_rate * afc) >> 10);
- }
-
- if (!state->config->invert) {
- p->inversion = (state->reg0 & 0x20) ? INVERSION_ON : INVERSION_OFF;
- } else {
- p->inversion = (!(state->reg0 & 0x20)) ? INVERSION_ON : INVERSION_OFF;
- }
-
- p->u.qam.modulation = ((state->reg0 >> 2) & 7) + QAM_16;
-
- p->u.qam.fec_inner = FEC_NONE;
-
- p->frequency = ((p->frequency + 31250) / 62500) * 62500;
- if (sync & 2)
- p->frequency -= ((s32) p->u.qam.symbol_rate * afc) >> 10;
-
- return 0;
-}
-
-static int ves1820_sleep(struct dvb_frontend* fe)
-{
- struct ves1820_state* state = fe->demodulator_priv;
-
- ves1820_writereg(state, 0x1b, 0x02); /* pdown ADC */
- ves1820_writereg(state, 0x00, 0x80); /* standby */
-
- return 0;
-}
-
-static int ves1820_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
-{
-
- fesettings->min_delay_ms = 200;
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static void ves1820_release(struct dvb_frontend* fe)
-{
- struct ves1820_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops ves1820_ops;
-
-struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
- struct i2c_adapter* i2c,
- u8 pwm)
-{
- struct ves1820_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct ves1820_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->reg0 = ves1820_inittab[0];
- state->config = config;
- state->i2c = i2c;
- state->pwm = pwm;
-
- /* check if the demod is there */
- if ((ves1820_readreg(state, 0x1a) & 0xf0) != 0x70)
- goto error;
-
- if (verbose)
- printk("ves1820: pwm=0x%02x\n", state->pwm);
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &ves1820_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.ops.info.symbol_rate_min = (state->config->xin / 2) / 64; /* SACLK/64 == (XIN/2)/64 */
- state->frontend.ops.info.symbol_rate_max = (state->config->xin / 2) / 4; /* SACLK/4 */
- state->frontend.demodulator_priv = state;
-
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops ves1820_ops = {
-
- .info = {
- .name = "VLSI VES1820 DVB-C",
- .type = FE_QAM,
- .frequency_stepsize = 62500,
- .frequency_min = 51000000,
- .frequency_max = 858000000,
- .caps = FE_CAN_QAM_16 |
- FE_CAN_QAM_32 |
- FE_CAN_QAM_64 |
- FE_CAN_QAM_128 |
- FE_CAN_QAM_256 |
- FE_CAN_FEC_AUTO
- },
-
- .release = ves1820_release,
-
- .init = ves1820_init,
- .sleep = ves1820_sleep,
-
- .set_frontend = ves1820_set_parameters,
- .get_frontend = ves1820_get_frontend,
- .get_tune_settings = ves1820_get_tune_settings,
-
- .read_status = ves1820_read_status,
- .read_ber = ves1820_read_ber,
- .read_signal_strength = ves1820_read_signal_strength,
- .read_snr = ves1820_read_snr,
- .read_ucblocks = ves1820_read_ucblocks,
-};
-
-module_param(verbose, int, 0644);
-MODULE_PARM_DESC(verbose, "print AFC offset after tuning for debugging the PWM setting");
-
-MODULE_DESCRIPTION("VLSI VES1820 DVB-C Demodulator driver");
-MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(ves1820_attach);
diff --git a/drivers/media/dvb/frontends/ves1820.h b/drivers/media/dvb/frontends/ves1820.h
deleted file mode 100644
index 520f09522fb..00000000000
--- a/drivers/media/dvb/frontends/ves1820.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- VES1820 - Single Chip Cable Channel Receiver driver module
-
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
-
- 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.
-*/
-
-#ifndef VES1820_H
-#define VES1820_H
-
-#include <linux/dvb/frontend.h>
-
-#define VES1820_SELAGC_PWM 0
-#define VES1820_SELAGC_SIGNAMPERR 1
-
-struct ves1820_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* value of XIN to use */
- u32 xin;
-
- /* does inversion need inverted? */
- u8 invert:1;
-
- /* SELAGC control */
- u8 selagc:1;
-};
-
-extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
- struct i2c_adapter* i2c, u8 pwm);
-
-#endif // VES1820_H
diff --git a/drivers/media/dvb/frontends/ves1x93.c b/drivers/media/dvb/frontends/ves1x93.c
deleted file mode 100644
index 54d7b07571b..00000000000
--- a/drivers/media/dvb/frontends/ves1x93.c
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- Driver for VES1893 and VES1993 QPSK Demodulators
-
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
- Copyright (C) 2001 Ronny Strutz <3des@elitedvb.de>
- Copyright (C) 2002 Dennis Noermann <dennis.noermann@noernet.de>
- Copyright (C) 2002-2003 Andreas Oberritter <obi@linuxtv.org>
-
- 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/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-
-#include "dvb_frontend.h"
-#include "ves1x93.h"
-
-
-struct ves1x93_state {
- struct i2c_adapter* i2c;
- /* configuration settings */
- const struct ves1x93_config* config;
- struct dvb_frontend frontend;
-
- /* previous uncorrected block counter */
- fe_spectral_inversion_t inversion;
- u8 *init_1x93_tab;
- u8 *init_1x93_wtab;
- u8 tab_size;
- u8 demod_type;
-};
-
-static int debug = 0;
-#define dprintk if (debug) printk
-
-#define DEMOD_VES1893 0
-#define DEMOD_VES1993 1
-
-static u8 init_1893_tab [] = {
- 0x01, 0xa4, 0x35, 0x80, 0x2a, 0x0b, 0x55, 0xc4,
- 0x09, 0x69, 0x00, 0x86, 0x4c, 0x28, 0x7f, 0x00,
- 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x00, 0x21, 0xb0, 0x14, 0x00, 0xdc, 0x00,
- 0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x55, 0x00, 0x00, 0x7f, 0x00
-};
-
-static u8 init_1993_tab [] = {
- 0x00, 0x9c, 0x35, 0x80, 0x6a, 0x09, 0x72, 0x8c,
- 0x09, 0x6b, 0x00, 0x00, 0x4c, 0x08, 0x00, 0x00,
- 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x80, 0x40, 0x21, 0xb0, 0x00, 0x00, 0x00, 0x10,
- 0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x55, 0x03, 0x00, 0x00, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x0e, 0x80, 0x00
-};
-
-static u8 init_1893_wtab[] =
-{
- 1,1,1,1,1,1,1,1, 1,1,0,0,1,1,0,0,
- 0,1,0,0,0,0,0,0, 1,0,1,1,0,0,0,1,
- 1,1,1,0,0,0,0,0, 0,0,1,1,0,0,0,0,
- 1,1,1,0,1,1
-};
-
-static u8 init_1993_wtab[] =
-{
- 1,1,1,1,1,1,1,1, 1,1,0,0,1,1,0,0,
- 0,1,0,0,0,0,0,0, 1,1,1,1,0,0,0,1,
- 1,1,1,0,0,0,0,0, 0,0,1,1,0,0,0,0,
- 1,1,1,0,1,1,1,1, 1,1,1,1,1
-};
-
-static int ves1x93_writereg (struct ves1x93_state* state, u8 reg, u8 data)
-{
- u8 buf [] = { 0x00, reg, data };
- struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 3 };
- int err;
-
- if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
- dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
- return -EREMOTEIO;
- }
-
- return 0;
-}
-
-static u8 ves1x93_readreg (struct ves1x93_state* state, u8 reg)
-{
- int ret;
- u8 b0 [] = { 0x00, reg };
- u8 b1 [] = { 0 };
- struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
- { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
-
- ret = i2c_transfer (state->i2c, msg, 2);
-
- if (ret != 2) return ret;
-
- return b1[0];
-}
-
-static int ves1x93_clr_bit (struct ves1x93_state* state)
-{
- msleep(10);
- ves1x93_writereg (state, 0, state->init_1x93_tab[0] & 0xfe);
- ves1x93_writereg (state, 0, state->init_1x93_tab[0]);
- msleep(50);
- return 0;
-}
-
-static int ves1x93_set_inversion (struct ves1x93_state* state, fe_spectral_inversion_t inversion)
-{
- u8 val;
-
- /*
- * inversion on/off are interchanged because i and q seem to
- * be swapped on the hardware
- */
-
- switch (inversion) {
- case INVERSION_OFF:
- val = 0xc0;
- break;
- case INVERSION_ON:
- val = 0x80;
- break;
- case INVERSION_AUTO:
- val = 0x00;
- break;
- default:
- return -EINVAL;
- }
-
- return ves1x93_writereg (state, 0x0c, (state->init_1x93_tab[0x0c] & 0x3f) | val);
-}
-
-static int ves1x93_set_fec (struct ves1x93_state* state, fe_code_rate_t fec)
-{
- if (fec == FEC_AUTO)
- return ves1x93_writereg (state, 0x0d, 0x08);
- else if (fec < FEC_1_2 || fec > FEC_8_9)
- return -EINVAL;
- else
- return ves1x93_writereg (state, 0x0d, fec - FEC_1_2);
-}
-
-static fe_code_rate_t ves1x93_get_fec (struct ves1x93_state* state)
-{
- return FEC_1_2 + ((ves1x93_readreg (state, 0x0d) >> 4) & 0x7);
-}
-
-static int ves1x93_set_symbolrate (struct ves1x93_state* state, u32 srate)
-{
- u32 BDR;
- u32 ratio;
- u8 ADCONF, FCONF, FNR, AGCR;
- u32 BDRI;
- u32 tmp;
- u32 FIN;
-
- dprintk("%s: srate == %d\n", __FUNCTION__, (unsigned int) srate);
-
- if (srate > state->config->xin/2)
- srate = state->config->xin/2;
-
- if (srate < 500000)
- srate = 500000;
-
-#define MUL (1UL<<26)
-
- FIN = (state->config->xin + 6000) >> 4;
-
- tmp = srate << 6;
- ratio = tmp / FIN;
-
- tmp = (tmp % FIN) << 8;
- ratio = (ratio << 8) + tmp / FIN;
-
- tmp = (tmp % FIN) << 8;
- ratio = (ratio << 8) + tmp / FIN;
-
- FNR = 0xff;
-
- if (ratio < MUL/3) FNR = 0;
- if (ratio < (MUL*11)/50) FNR = 1;
- if (ratio < MUL/6) FNR = 2;
- if (ratio < MUL/9) FNR = 3;
- if (ratio < MUL/12) FNR = 4;
- if (ratio < (MUL*11)/200) FNR = 5;
- if (ratio < MUL/24) FNR = 6;
- if (ratio < (MUL*27)/1000) FNR = 7;
- if (ratio < MUL/48) FNR = 8;
- if (ratio < (MUL*137)/10000) FNR = 9;
-
- if (FNR == 0xff) {
- ADCONF = 0x89;
- FCONF = 0x80;
- FNR = 0;
- } else {
- ADCONF = 0x81;
- FCONF = 0x88 | (FNR >> 1) | ((FNR & 0x01) << 5);
- /*FCONF = 0x80 | ((FNR & 0x01) << 5) | (((FNR > 1) & 0x03) << 3) | ((FNR >> 1) & 0x07);*/
- }
-
- BDR = (( (ratio << (FNR >> 1)) >> 4) + 1) >> 1;
- BDRI = ( ((FIN << 8) / ((srate << (FNR >> 1)) >> 2)) + 1) >> 1;
-
- dprintk("FNR= %d\n", FNR);
- dprintk("ratio= %08x\n", (unsigned int) ratio);
- dprintk("BDR= %08x\n", (unsigned int) BDR);
- dprintk("BDRI= %02x\n", (unsigned int) BDRI);
-
- if (BDRI > 0xff)
- BDRI = 0xff;
-
- ves1x93_writereg (state, 0x06, 0xff & BDR);
- ves1x93_writereg (state, 0x07, 0xff & (BDR >> 8));
- ves1x93_writereg (state, 0x08, 0x0f & (BDR >> 16));
-
- ves1x93_writereg (state, 0x09, BDRI);
- ves1x93_writereg (state, 0x20, ADCONF);
- ves1x93_writereg (state, 0x21, FCONF);
-
- AGCR = state->init_1x93_tab[0x05];
- if (state->config->invert_pwm)
- AGCR |= 0x20;
-
- if (srate < 6000000)
- AGCR |= 0x80;
- else
- AGCR &= ~0x80;
-
- ves1x93_writereg (state, 0x05, AGCR);
-
- /* ves1993 hates this, will lose lock */
- if (state->demod_type != DEMOD_VES1993)
- ves1x93_clr_bit (state);
-
- return 0;
-}
-
-static int ves1x93_init (struct dvb_frontend* fe)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
- int i;
- int val;
-
- dprintk("%s: init chip\n", __FUNCTION__);
-
- for (i = 0; i < state->tab_size; i++) {
- if (state->init_1x93_wtab[i]) {
- val = state->init_1x93_tab[i];
-
- if (state->config->invert_pwm && (i == 0x05)) val |= 0x20; /* invert PWM */
- ves1x93_writereg (state, i, val);
- }
- }
-
- return 0;
-}
-
-static int ves1x93_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- switch (voltage) {
- case SEC_VOLTAGE_13:
- return ves1x93_writereg (state, 0x1f, 0x20);
- case SEC_VOLTAGE_18:
- return ves1x93_writereg (state, 0x1f, 0x30);
- case SEC_VOLTAGE_OFF:
- return ves1x93_writereg (state, 0x1f, 0x00);
- default:
- return -EINVAL;
- }
-}
-
-static int ves1x93_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- u8 sync = ves1x93_readreg (state, 0x0e);
-
- /*
- * The ves1893 sometimes returns sync values that make no sense,
- * because, e.g., the SIGNAL bit is 0, while some of the higher
- * bits are 1 (and how can there be a CARRIER w/o a SIGNAL?).
- * Tests showed that the the VITERBI and SYNC bits are returned
- * reliably, while the SIGNAL and CARRIER bits ar sometimes wrong.
- * If such a case occurs, we read the value again, until we get a
- * valid value.
- */
- int maxtry = 10; /* just for safety - let's not get stuck here */
- while ((sync & 0x03) != 0x03 && (sync & 0x0c) && maxtry--) {
- msleep(10);
- sync = ves1x93_readreg (state, 0x0e);
- }
-
- *status = 0;
-
- if (sync & 1)
- *status |= FE_HAS_SIGNAL;
-
- if (sync & 2)
- *status |= FE_HAS_CARRIER;
-
- if (sync & 4)
- *status |= FE_HAS_VITERBI;
-
- if (sync & 8)
- *status |= FE_HAS_SYNC;
-
- if ((sync & 0x1f) == 0x1f)
- *status |= FE_HAS_LOCK;
-
- return 0;
-}
-
-static int ves1x93_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- *ber = ves1x93_readreg (state, 0x15);
- *ber |= (ves1x93_readreg (state, 0x16) << 8);
- *ber |= ((ves1x93_readreg (state, 0x17) & 0x0F) << 16);
- *ber *= 10;
-
- return 0;
-}
-
-static int ves1x93_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- u8 signal = ~ves1x93_readreg (state, 0x0b);
- *strength = (signal << 8) | signal;
-
- return 0;
-}
-
-static int ves1x93_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- u8 _snr = ~ves1x93_readreg (state, 0x1c);
- *snr = (_snr << 8) | _snr;
-
- return 0;
-}
-
-static int ves1x93_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- *ucblocks = ves1x93_readreg (state, 0x18) & 0x7f;
-
- if (*ucblocks == 0x7f)
- *ucblocks = 0xffffffff; /* counter overflow... */
-
- ves1x93_writereg (state, 0x18, 0x00); /* reset the counter */
- ves1x93_writereg (state, 0x18, 0x80); /* dto. */
-
- return 0;
-}
-
-static int ves1x93_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, p);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
- ves1x93_set_inversion (state, p->inversion);
- ves1x93_set_fec (state, p->u.qpsk.fec_inner);
- ves1x93_set_symbolrate (state, p->u.qpsk.symbol_rate);
- state->inversion = p->inversion;
-
- return 0;
-}
-
-static int ves1x93_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
- int afc;
-
- afc = ((int)((char)(ves1x93_readreg (state, 0x0a) << 1)))/2;
- afc = (afc * (int)(p->u.qpsk.symbol_rate/1000/8))/16;
-
- p->frequency -= afc;
-
- /*
- * inversion indicator is only valid
- * if auto inversion was used
- */
- if (state->inversion == INVERSION_AUTO)
- p->inversion = (ves1x93_readreg (state, 0x0f) & 2) ?
- INVERSION_OFF : INVERSION_ON;
- p->u.qpsk.fec_inner = ves1x93_get_fec (state);
- /* XXX FIXME: timing offset !! */
-
- return 0;
-}
-
-static int ves1x93_sleep(struct dvb_frontend* fe)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- return ves1x93_writereg (state, 0x00, 0x08);
-}
-
-static void ves1x93_release(struct dvb_frontend* fe)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
- kfree(state);
-}
-
-static int ves1x93_i2c_gate_ctrl(struct dvb_frontend* fe, int enable)
-{
- struct ves1x93_state* state = fe->demodulator_priv;
-
- if (enable) {
- return ves1x93_writereg(state, 0x00, 0x11);
- } else {
- return ves1x93_writereg(state, 0x00, 0x01);
- }
-}
-
-static struct dvb_frontend_ops ves1x93_ops;
-
-struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
- struct i2c_adapter* i2c)
-{
- struct ves1x93_state* state = NULL;
- u8 identity;
-
- /* allocate memory for the internal state */
- state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL);
- if (state == NULL) goto error;
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- state->inversion = INVERSION_OFF;
-
- /* check if the demod is there + identify it */
- identity = ves1x93_readreg(state, 0x1e);
- switch (identity) {
- case 0xdc: /* VES1893A rev1 */
- printk("ves1x93: Detected ves1893a rev1\n");
- state->demod_type = DEMOD_VES1893;
- state->init_1x93_tab = init_1893_tab;
- state->init_1x93_wtab = init_1893_wtab;
- state->tab_size = sizeof(init_1893_tab);
- break;
-
- case 0xdd: /* VES1893A rev2 */
- printk("ves1x93: Detected ves1893a rev2\n");
- state->demod_type = DEMOD_VES1893;
- state->init_1x93_tab = init_1893_tab;
- state->init_1x93_wtab = init_1893_wtab;
- state->tab_size = sizeof(init_1893_tab);
- break;
-
- case 0xde: /* VES1993 */
- printk("ves1x93: Detected ves1993\n");
- state->demod_type = DEMOD_VES1993;
- state->init_1x93_tab = init_1993_tab;
- state->init_1x93_wtab = init_1993_wtab;
- state->tab_size = sizeof(init_1993_tab);
- break;
-
- default:
- goto error;
- }
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &ves1x93_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops ves1x93_ops = {
-
- .info = {
- .name = "VLSI VES1x93 DVB-S",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 125, /* kHz for QPSK frontends */
- .frequency_tolerance = 29500,
- .symbol_rate_min = 1000000,
- .symbol_rate_max = 45000000,
- /* .symbol_rate_tolerance = ???,*/
- .caps = FE_CAN_INVERSION_AUTO |
- FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK
- },
-
- .release = ves1x93_release,
-
- .init = ves1x93_init,
- .sleep = ves1x93_sleep,
- .i2c_gate_ctrl = ves1x93_i2c_gate_ctrl,
-
- .set_frontend = ves1x93_set_frontend,
- .get_frontend = ves1x93_get_frontend,
-
- .read_status = ves1x93_read_status,
- .read_ber = ves1x93_read_ber,
- .read_signal_strength = ves1x93_read_signal_strength,
- .read_snr = ves1x93_read_snr,
- .read_ucblocks = ves1x93_read_ucblocks,
-
- .set_voltage = ves1x93_set_voltage,
-};
-
-module_param(debug, int, 0644);
-
-MODULE_DESCRIPTION("VLSI VES1x93 DVB-S Demodulator driver");
-MODULE_AUTHOR("Ralph Metzler");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(ves1x93_attach);
diff --git a/drivers/media/dvb/frontends/ves1x93.h b/drivers/media/dvb/frontends/ves1x93.h
deleted file mode 100644
index ba88ae0855c..00000000000
--- a/drivers/media/dvb/frontends/ves1x93.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Driver for VES1893 and VES1993 QPSK Demodulators
-
- Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
- Copyright (C) 2001 Ronny Strutz <3des@elitedvb.de>
- Copyright (C) 2002 Dennis Noermann <dennis.noermann@noernet.de>
- Copyright (C) 2002-2003 Andreas Oberritter <obi@linuxtv.org>
-
- 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.
-
-*/
-
-#ifndef VES1X93_H
-#define VES1X93_H
-
-#include <linux/dvb/frontend.h>
-
-struct ves1x93_config
-{
- /* the demodulator's i2c address */
- u8 demod_address;
-
- /* value of XIN to use */
- u32 xin;
-
- /* should PWM be inverted? */
- u8 invert_pwm:1;
-};
-
-extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
- struct i2c_adapter* i2c);
-
-#endif // VES1X93_H
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
deleted file mode 100644
index 2b95e8b6cd3..00000000000
--- a/drivers/media/dvb/frontends/zl10353.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Driver for Zarlink DVB-T ZL10353 demodulator
- *
- * Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
- *
- * 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/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-
-#include "dvb_frontend.h"
-#include "zl10353_priv.h"
-#include "zl10353.h"
-
-struct zl10353_state {
- struct i2c_adapter *i2c;
- struct dvb_frontend frontend;
-
- struct zl10353_config config;
-};
-
-static int debug_regs = 0;
-
-static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val)
-{
- struct zl10353_state *state = fe->demodulator_priv;
- u8 buf[2] = { reg, val };
- struct i2c_msg msg = { .addr = state->config.demod_address, .flags = 0,
- .buf = buf, .len = 2 };
- int err = i2c_transfer(state->i2c, &msg, 1);
- if (err != 1) {
- printk("zl10353: write to reg %x failed (err = %d)!\n", reg, err);
- return err;
- }
- return 0;
-}
-
-int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen)
-{
- int err, i;
- for (i = 0; i < ilen - 1; i++)
- if ((err = zl10353_single_write(fe, ibuf[0] + i, ibuf[i + 1])))
- return err;
-
- return 0;
-}
-
-static int zl10353_read_register(struct zl10353_state *state, u8 reg)
-{
- int ret;
- u8 b0[1] = { reg };
- u8 b1[1] = { 0 };
- struct i2c_msg msg[2] = { { .addr = state->config.demod_address,
- .flags = 0,
- .buf = b0, .len = 1 },
- { .addr = state->config.demod_address,
- .flags = I2C_M_RD,
- .buf = b1, .len = 1 } };
-
- ret = i2c_transfer(state->i2c, msg, 2);
-
- if (ret != 2) {
- printk("%s: readreg error (reg=%d, ret==%i)\n",
- __FUNCTION__, reg, ret);
- return ret;
- }
-
- return b1[0];
-}
-
-static void zl10353_dump_regs(struct dvb_frontend *fe)
-{
- struct zl10353_state *state = fe->demodulator_priv;
- char buf[52], buf2[4];
- int ret;
- u8 reg;
-
- /* Dump all registers. */
- for (reg = 0; ; reg++) {
- if (reg % 16 == 0) {
- if (reg)
- printk(KERN_DEBUG "%s\n", buf);
- sprintf(buf, "%02x: ", reg);
- }
- ret = zl10353_read_register(state, reg);
- if (ret >= 0)
- sprintf(buf2, "%02x ", (u8)ret);
- else
- strcpy(buf2, "-- ");
- strcat(buf, buf2);
- if (reg == 0xff)
- break;
- }
- printk(KERN_DEBUG "%s\n", buf);
-}
-
-static int zl10353_sleep(struct dvb_frontend *fe)
-{
- static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 };
-
- zl10353_write(fe, zl10353_softdown, sizeof(zl10353_softdown));
- return 0;
-}
-
-static int zl10353_set_parameters(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *param)
-{
- struct zl10353_state *state = fe->demodulator_priv;
-
- u8 pllbuf[6] = { 0x67 };
-
- /* These settings set "auto-everything" and start the FSM. */
- zl10353_single_write(fe, 0x55, 0x80);
- udelay(200);
- zl10353_single_write(fe, 0xEA, 0x01);
- udelay(200);
- zl10353_single_write(fe, 0xEA, 0x00);
-
- zl10353_single_write(fe, 0x56, 0x28);
- zl10353_single_write(fe, 0x89, 0x20);
- zl10353_single_write(fe, 0x5E, 0x00);
- zl10353_single_write(fe, 0x65, 0x5A);
- zl10353_single_write(fe, 0x66, 0xE9);
- zl10353_single_write(fe, 0x62, 0x0A);
-
- // if there is no attached secondary tuner, we call set_params to program
- // a potential tuner attached somewhere else
- if (state->config.no_tuner) {
- if (fe->ops.tuner_ops.set_params) {
- fe->ops.tuner_ops.set_params(fe, param);
- if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
- }
- }
-
- // if pllbuf is defined, retrieve the settings
- if (fe->ops.tuner_ops.calc_regs) {
- fe->ops.tuner_ops.calc_regs(fe, param, pllbuf+1, 5);
- pllbuf[1] <<= 1;
- } else {
- // fake pllbuf settings
- pllbuf[1] = 0x61 << 1;
- pllbuf[2] = 0;
- pllbuf[3] = 0;
- pllbuf[3] = 0;
- pllbuf[4] = 0;
- }
-
- // there is no call to _just_ start decoding, so we send the pllbuf anyway
- // even if there isn't a PLL attached to the secondary bus
- zl10353_write(fe, pllbuf, sizeof(pllbuf));
-
- zl10353_single_write(fe, 0x70, 0x01);
- udelay(250);
- zl10353_single_write(fe, 0xE4, 0x00);
- zl10353_single_write(fe, 0xE5, 0x2A);
- zl10353_single_write(fe, 0xE9, 0x02);
- zl10353_single_write(fe, 0xE7, 0x40);
- zl10353_single_write(fe, 0xE8, 0x10);
-
- return 0;
-}
-
-static int zl10353_read_status(struct dvb_frontend *fe, fe_status_t *status)
-{
- struct zl10353_state *state = fe->demodulator_priv;
- int s6, s7, s8;
-
- if ((s6 = zl10353_read_register(state, STATUS_6)) < 0)
- return -EREMOTEIO;
- if ((s7 = zl10353_read_register(state, STATUS_7)) < 0)
- return -EREMOTEIO;
- if ((s8 = zl10353_read_register(state, STATUS_8)) < 0)
- return -EREMOTEIO;
-
- *status = 0;
- if (s6 & (1 << 2))
- *status |= FE_HAS_CARRIER;
- if (s6 & (1 << 1))
- *status |= FE_HAS_VITERBI;
- if (s6 & (1 << 5))
- *status |= FE_HAS_LOCK;
- if (s7 & (1 << 4))
- *status |= FE_HAS_SYNC;
- if (s8 & (1 << 6))
- *status |= FE_HAS_SIGNAL;
-
- if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) !=
- (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC))
- *status &= ~FE_HAS_LOCK;
-
- return 0;
-}
-
-static int zl10353_read_snr(struct dvb_frontend *fe, u16 *snr)
-{
- struct zl10353_state *state = fe->demodulator_priv;
- u8 _snr;
-
- if (debug_regs)
- zl10353_dump_regs(fe);
-
- _snr = zl10353_read_register(state, SNR);
- *snr = (_snr << 8) | _snr;
-
- return 0;
-}
-
-static int zl10353_get_tune_settings(struct dvb_frontend *fe,
- struct dvb_frontend_tune_settings
- *fe_tune_settings)
-{
- fe_tune_settings->min_delay_ms = 1000;
- fe_tune_settings->step_size = 0;
- fe_tune_settings->max_drift = 0;
-
- return 0;
-}
-
-static int zl10353_init(struct dvb_frontend *fe)
-{
- struct zl10353_state *state = fe->demodulator_priv;
- u8 zl10353_reset_attach[6] = { 0x50, 0x03, 0x64, 0x46, 0x15, 0x0F };
- int rc = 0;
-
- if (debug_regs)
- zl10353_dump_regs(fe);
-
- /* Do a "hard" reset if not already done */
- if (zl10353_read_register(state, 0x50) != 0x03) {
- rc = zl10353_write(fe, zl10353_reset_attach,
- sizeof(zl10353_reset_attach));
- if (debug_regs)
- zl10353_dump_regs(fe);
- }
-
- return 0;
-}
-
-static void zl10353_release(struct dvb_frontend *fe)
-{
- struct zl10353_state *state = fe->demodulator_priv;
-
- kfree(state);
-}
-
-static struct dvb_frontend_ops zl10353_ops;
-
-struct dvb_frontend *zl10353_attach(const struct zl10353_config *config,
- struct i2c_adapter *i2c)
-{
- struct zl10353_state *state = NULL;
-
- /* allocate memory for the internal state */
- state = kzalloc(sizeof(struct zl10353_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
-
- /* setup the state */
- state->i2c = i2c;
- memcpy(&state->config, config, sizeof(struct zl10353_config));
-
- /* check if the demod is there */
- if (zl10353_read_register(state, CHIP_ID) != ID_ZL10353)
- goto error;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &zl10353_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
-
- return &state->frontend;
-error:
- kfree(state);
- return NULL;
-}
-
-static struct dvb_frontend_ops zl10353_ops = {
-
- .info = {
- .name = "Zarlink ZL10353 DVB-T",
- .type = FE_OFDM,
- .frequency_min = 174000000,
- .frequency_max = 862000000,
- .frequency_stepsize = 166667,
- .frequency_tolerance = 0,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
- FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
- FE_CAN_FEC_AUTO |
- FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_HIERARCHY_AUTO | FE_CAN_RECOVER |
- FE_CAN_MUTE_TS
- },
-
- .release = zl10353_release,
-
- .init = zl10353_init,
- .sleep = zl10353_sleep,
-
- .set_frontend = zl10353_set_parameters,
- .get_tune_settings = zl10353_get_tune_settings,
-
- .read_status = zl10353_read_status,
- .read_snr = zl10353_read_snr,
-};
-
-module_param(debug_regs, int, 0644);
-MODULE_PARM_DESC(debug_regs, "Turn on/off frontend register dumps (default:off).");
-
-MODULE_DESCRIPTION("Zarlink ZL10353 DVB-T demodulator driver");
-MODULE_AUTHOR("Chris Pascoe");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(zl10353_attach);
-EXPORT_SYMBOL(zl10353_write);
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h
deleted file mode 100644
index 9770cb840cf..00000000000
--- a/drivers/media/dvb/frontends/zl10353.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Driver for Zarlink DVB-T ZL10353 demodulator
- *
- * Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
- *
- * 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.=
- */
-
-#ifndef ZL10353_H
-#define ZL10353_H
-
-#include <linux/dvb/frontend.h>
-
-struct zl10353_config
-{
- /* demodulator's I2C address */
- u8 demod_address;
-
- /* set if no pll is connected to the secondary i2c bus */
- int no_tuner;
-};
-
-extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config,
- struct i2c_adapter *i2c);
-
-extern int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen);
-
-#endif /* ZL10353_H */
diff --git a/drivers/media/dvb/frontends/zl10353_priv.h b/drivers/media/dvb/frontends/zl10353_priv.h
deleted file mode 100644
index b72224bd7dd..00000000000
--- a/drivers/media/dvb/frontends/zl10353_priv.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Driver for Zarlink DVB-T ZL10353 demodulator
- *
- * Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
- *
- * 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.=
- */
-
-#ifndef _ZL10353_PRIV_
-#define _ZL10353_PRIV_
-
-#define ID_ZL10353 0x14
-
-enum zl10353_reg_addr {
- INTERRUPT_0 = 0x00,
- INTERRUPT_1 = 0x01,
- INTERRUPT_2 = 0x02,
- INTERRUPT_3 = 0x03,
- INTERRUPT_4 = 0x04,
- INTERRUPT_5 = 0x05,
- STATUS_6 = 0x06,
- STATUS_7 = 0x07,
- STATUS_8 = 0x08,
- STATUS_9 = 0x09,
- SNR = 0x10,
- CHIP_ID = 0x7F,
-};
-
-#endif /* _ZL10353_PRIV_ */
diff --git a/drivers/media/dvb/pluto2/Kconfig b/drivers/media/dvb/pluto2/Kconfig
deleted file mode 100644
index 9b84b1bdc31..00000000000
--- a/drivers/media/dvb/pluto2/Kconfig
+++ /dev/null
@@ -1,16 +0,0 @@
-config DVB_PLUTO2
- tristate "Pluto2 cards"
- depends on DVB_CORE && PCI && I2C
- select I2C_ALGOBIT
- select DVB_PLL
- select DVB_TDA1004X
- help
- Support for PCI cards based on the Pluto2 FPGA like the Satelco
- Easywatch Mobile Terrestrial DVB-T Receiver.
-
- Since these cards have no MPEG decoder onboard, they transmit
- only compressed MPEG data over the PCI bus, so you need
- an external software decoder to watch TV on your computer.
-
- Say Y or M if you own such a device and want to use it.
-
diff --git a/drivers/media/dvb/pluto2/Makefile b/drivers/media/dvb/pluto2/Makefile
deleted file mode 100644
index ce6a9aaf937..00000000000
--- a/drivers/media/dvb/pluto2/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_DVB_PLUTO2) += pluto2.o
-
-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
deleted file mode 100644
index 2310b2bfed4..00000000000
--- a/drivers/media/dvb/pluto2/pluto2.c
+++ /dev/null
@@ -1,803 +0,0 @@
-/*
- * pluto2.c - Satelco Easywatch Mobile Terrestrial Receiver [DVB-T]
- *
- * Copyright (C) 2005 Andreas Oberritter <obi@linuxtv.org>
- *
- * based on pluto2.c 1.10 - http://instinct-wp8.no-ip.org/pluto/
- * by Dany Salman <salmandany@yahoo.fr>
- * Copyright (c) 2004 TDF
- *
- * 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>
-#include <linux/i2c-algo-bit.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/dma-mapping.h>
-
-#include "demux.h"
-#include "dmxdev.h"
-#include "dvb_demux.h"
-#include "dvb_frontend.h"
-#include "dvb_net.h"
-#include "dvbdev.h"
-#include "tda1004x.h"
-
-#define DRIVER_NAME "pluto2"
-
-#define REG_PIDn(n) ((n) << 2) /* PID n pattern registers */
-#define REG_PCAR 0x0020 /* PC address register */
-#define REG_TSCR 0x0024 /* TS ctrl & status */
-#define REG_MISC 0x0028 /* miscellaneous */
-#define REG_MMAC 0x002c /* MSB MAC address */
-#define REG_IMAC 0x0030 /* ISB MAC address */
-#define REG_LMAC 0x0034 /* LSB MAC address */
-#define REG_SPID 0x0038 /* SPI data */
-#define REG_SLCS 0x003c /* serial links ctrl/status */
-
-#define PID0_NOFIL (0x0001 << 16)
-#define PIDn_ENP (0x0001 << 15)
-#define PID0_END (0x0001 << 14)
-#define PID0_AFIL (0x0001 << 13)
-#define PIDn_PID (0x1fff << 0)
-
-#define TSCR_NBPACKETS (0x00ff << 24)
-#define TSCR_DEM (0x0001 << 17)
-#define TSCR_DE (0x0001 << 16)
-#define TSCR_RSTN (0x0001 << 15)
-#define TSCR_MSKO (0x0001 << 14)
-#define TSCR_MSKA (0x0001 << 13)
-#define TSCR_MSKL (0x0001 << 12)
-#define TSCR_OVR (0x0001 << 11)
-#define TSCR_AFUL (0x0001 << 10)
-#define TSCR_LOCK (0x0001 << 9)
-#define TSCR_IACK (0x0001 << 8)
-#define TSCR_ADEF (0x007f << 0)
-
-#define MISC_DVR (0x0fff << 4)
-#define MISC_ALED (0x0001 << 3)
-#define MISC_FRST (0x0001 << 2)
-#define MISC_LED1 (0x0001 << 1)
-#define MISC_LED0 (0x0001 << 0)
-
-#define SPID_SPIDR (0x00ff << 0)
-
-#define SLCS_SCL (0x0001 << 7)
-#define SLCS_SDA (0x0001 << 6)
-#define SLCS_CSN (0x0001 << 2)
-#define SLCS_OVR (0x0001 << 1)
-#define SLCS_SWC (0x0001 << 0)
-
-#define TS_DMA_PACKETS (8)
-#define TS_DMA_BYTES (188 * TS_DMA_PACKETS)
-
-#define I2C_ADDR_TDA10046 0x10
-#define I2C_ADDR_TUA6034 0xc2
-#define NHWFILTERS 8
-
-struct pluto {
- /* pci */
- struct pci_dev *pdev;
- u8 __iomem *io_mem;
-
- /* 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;
- unsigned int users;
-
- /* i2c */
- struct i2c_algo_bit_data i2c_bit;
- struct i2c_adapter i2c_adap;
- unsigned int i2cbug;
-
- /* irq */
- unsigned int overflow;
-
- /* dma */
- dma_addr_t dma_addr;
- u8 dma_buf[TS_DMA_BYTES];
- u8 dummy[4096];
-};
-
-static inline struct pluto *feed_to_pluto(struct dvb_demux_feed *feed)
-{
- return container_of(feed->demux, struct pluto, demux);
-}
-
-static inline struct pluto *frontend_to_pluto(struct dvb_frontend *fe)
-{
- return container_of(fe->dvb, struct pluto, dvb_adapter);
-}
-
-static inline u32 pluto_readreg(struct pluto *pluto, u32 reg)
-{
- return readl(&pluto->io_mem[reg]);
-}
-
-static inline void pluto_writereg(struct pluto *pluto, u32 reg, u32 val)
-{
- writel(val, &pluto->io_mem[reg]);
-}
-
-static inline void pluto_rw(struct pluto *pluto, u32 reg, u32 mask, u32 bits)
-{
- u32 val = readl(&pluto->io_mem[reg]);
- val &= ~mask;
- val |= bits;
- writel(val, &pluto->io_mem[reg]);
-}
-
-static void pluto_setsda(void *data, int state)
-{
- struct pluto *pluto = data;
-
- if (state)
- pluto_rw(pluto, REG_SLCS, SLCS_SDA, SLCS_SDA);
- else
- pluto_rw(pluto, REG_SLCS, SLCS_SDA, 0);
-}
-
-static void pluto_setscl(void *data, int state)
-{
- struct pluto *pluto = data;
-
- if (state)
- pluto_rw(pluto, REG_SLCS, SLCS_SCL, SLCS_SCL);
- else
- pluto_rw(pluto, REG_SLCS, SLCS_SCL, 0);
-
- /* try to detect i2c_inb() to workaround hardware bug:
- * reset SDA to high after SCL has been set to low */
- if ((state) && (pluto->i2cbug == 0)) {
- pluto->i2cbug = 1;
- } else {
- if ((!state) && (pluto->i2cbug == 1))
- pluto_setsda(pluto, 1);
- pluto->i2cbug = 0;
- }
-}
-
-static int pluto_getsda(void *data)
-{
- struct pluto *pluto = data;
-
- return pluto_readreg(pluto, REG_SLCS) & SLCS_SDA;
-}
-
-static int pluto_getscl(void *data)
-{
- struct pluto *pluto = data;
-
- return pluto_readreg(pluto, REG_SLCS) & SLCS_SCL;
-}
-
-static void pluto_reset_frontend(struct pluto *pluto, int reenable)
-{
- u32 val = pluto_readreg(pluto, REG_MISC);
-
- if (val & MISC_FRST) {
- val &= ~MISC_FRST;
- pluto_writereg(pluto, REG_MISC, val);
- }
- if (reenable) {
- val |= MISC_FRST;
- pluto_writereg(pluto, REG_MISC, val);
- }
-}
-
-static void pluto_reset_ts(struct pluto *pluto, int reenable)
-{
- u32 val = pluto_readreg(pluto, REG_TSCR);
-
- if (val & TSCR_RSTN) {
- val &= ~TSCR_RSTN;
- pluto_writereg(pluto, REG_TSCR, val);
- }
- if (reenable) {
- val |= TSCR_RSTN;
- pluto_writereg(pluto, REG_TSCR, val);
- }
-}
-
-static void pluto_set_dma_addr(struct pluto *pluto)
-{
- pluto_writereg(pluto, REG_PCAR, cpu_to_le32(pluto->dma_addr));
-}
-
-static int __devinit pluto_dma_map(struct pluto *pluto)
-{
- pluto->dma_addr = pci_map_single(pluto->pdev, pluto->dma_buf,
- TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
-
- return pci_dma_mapping_error(pluto->dma_addr);
-}
-
-static void pluto_dma_unmap(struct pluto *pluto)
-{
- pci_unmap_single(pluto->pdev, pluto->dma_addr,
- TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
-}
-
-static int pluto_start_feed(struct dvb_demux_feed *f)
-{
- struct pluto *pluto = feed_to_pluto(f);
-
- /* enable PID filtering */
- if (pluto->users++ == 0)
- pluto_rw(pluto, REG_PIDn(0), PID0_AFIL | PID0_NOFIL, 0);
-
- if ((f->pid < 0x2000) && (f->index < NHWFILTERS))
- pluto_rw(pluto, REG_PIDn(f->index), PIDn_ENP | PIDn_PID, PIDn_ENP | f->pid);
- else if (pluto->full_ts_users++ == 0)
- pluto_rw(pluto, REG_PIDn(0), PID0_NOFIL, PID0_NOFIL);
-
- return 0;
-}
-
-static int pluto_stop_feed(struct dvb_demux_feed *f)
-{
- struct pluto *pluto = feed_to_pluto(f);
-
- /* disable PID filtering */
- if (--pluto->users == 0)
- pluto_rw(pluto, REG_PIDn(0), PID0_AFIL, PID0_AFIL);
-
- if ((f->pid < 0x2000) && (f->index < NHWFILTERS))
- pluto_rw(pluto, REG_PIDn(f->index), PIDn_ENP | PIDn_PID, 0x1fff);
- else if (--pluto->full_ts_users == 0)
- pluto_rw(pluto, REG_PIDn(0), PID0_NOFIL, 0);
-
- return 0;
-}
-
-static void pluto_dma_end(struct pluto *pluto, unsigned int nbpackets)
-{
- /* synchronize the DMA transfer with the CPU
- * first so that we see updated contents. */
- pci_dma_sync_single_for_cpu(pluto->pdev, pluto->dma_addr,
- TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
-
- /* Workaround for broken hardware:
- * [1] On startup NBPACKETS seems to contain an uninitialized value,
- * but no packets have been transfered.
- * [2] Sometimes (actually very often) NBPACKETS stays at zero
- * although one packet has been transfered.
- */
- if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) {
- unsigned int i = 0;
- while (pluto->dma_buf[i] == 0x47)
- i += 188;
- nbpackets = i / 188;
- }
-
- dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets);
-
- /* clear the dma buffer. this is needed to be able to identify
- * new valid ts packets above */
- memset(pluto->dma_buf, 0, nbpackets * 188);
-
- /* reset the dma address */
- pluto_set_dma_addr(pluto);
-
- /* sync the buffer and give it back to the card */
- pci_dma_sync_single_for_device(pluto->pdev, pluto->dma_addr,
- TS_DMA_BYTES, PCI_DMA_FROMDEVICE);
-}
-
-static irqreturn_t pluto_irq(int irq, void *dev_id, struct pt_regs *regs)
-{
- struct pluto *pluto = dev_id;
- u32 tscr;
-
- /* check whether an interrupt occured on this device */
- tscr = pluto_readreg(pluto, REG_TSCR);
- if (!(tscr & (TSCR_DE | TSCR_OVR)))
- return IRQ_NONE;
-
- if (tscr == 0xffffffff) {
- // FIXME: maybe recover somehow
- dev_err(&pluto->pdev->dev, "card hung up :(\n");
- return IRQ_HANDLED;
- }
-
- /* dma end interrupt */
- if (tscr & TSCR_DE) {
- pluto_dma_end(pluto, (tscr & TSCR_NBPACKETS) >> 24);
- /* overflow interrupt */
- if (tscr & TSCR_OVR)
- pluto->overflow++;
- if (pluto->overflow) {
- dev_err(&pluto->pdev->dev, "overflow irq (%d)\n",
- pluto->overflow);
- pluto_reset_ts(pluto, 1);
- pluto->overflow = 0;
- }
- } else if (tscr & TSCR_OVR) {
- pluto->overflow++;
- }
-
- /* ACK the interrupt */
- pluto_writereg(pluto, REG_TSCR, tscr | TSCR_IACK);
-
- return IRQ_HANDLED;
-}
-
-static void __devinit pluto_enable_irqs(struct pluto *pluto)
-{
- u32 val = pluto_readreg(pluto, REG_TSCR);
-
- /* set the number of packets */
- val &= ~TSCR_ADEF;
- val |= TS_DMA_PACKETS / 2;
- /* disable AFUL and LOCK interrupts */
- val |= (TSCR_MSKA | TSCR_MSKL);
- /* enable DMA and OVERFLOW interrupts */
- val &= ~(TSCR_DEM | TSCR_MSKO);
- /* clear pending interrupts */
- val |= TSCR_IACK;
-
- pluto_writereg(pluto, REG_TSCR, val);
-}
-
-static void pluto_disable_irqs(struct pluto *pluto)
-{
- u32 val = pluto_readreg(pluto, REG_TSCR);
-
- /* disable all interrupts */
- val |= (TSCR_DEM | TSCR_MSKO | TSCR_MSKA | TSCR_MSKL);
- /* clear pending interrupts */
- val |= TSCR_IACK;
-
- pluto_writereg(pluto, REG_TSCR, val);
-}
-
-static int __devinit pluto_hw_init(struct pluto *pluto)
-{
- pluto_reset_frontend(pluto, 1);
-
- /* set automatic LED control by FPGA */
- pluto_rw(pluto, REG_MISC, MISC_ALED, MISC_ALED);
-
- /* set data endianess */
-#ifdef __LITTLE_ENDIAN
- pluto_rw(pluto, REG_PIDn(0), PID0_END, PID0_END);
-#else
- pluto_rw(pluto, REG_PIDn(0), PID0_END, 0);
-#endif
- /* map DMA and set address */
- pluto_dma_map(pluto);
- pluto_set_dma_addr(pluto);
-
- /* enable interrupts */
- pluto_enable_irqs(pluto);
-
- /* reset TS logic */
- pluto_reset_ts(pluto, 1);
-
- return 0;
-}
-
-static void pluto_hw_exit(struct pluto *pluto)
-{
- /* disable interrupts */
- pluto_disable_irqs(pluto);
-
- pluto_reset_ts(pluto, 0);
-
- /* LED: disable automatic control, enable yellow, disable green */
- pluto_rw(pluto, REG_MISC, MISC_ALED | MISC_LED1 | MISC_LED0, MISC_LED1);
-
- /* unmap DMA */
- pluto_dma_unmap(pluto);
-
- pluto_reset_frontend(pluto, 0);
-}
-
-static inline u32 divide(u32 numerator, u32 denominator)
-{
- if (denominator == 0)
- return ~0;
-
- return (numerator + denominator / 2) / denominator;
-}
-
-/* LG Innotek TDTE-E001P (Infineon TUA6034) */
-static int lg_tdtpe001p_tuner_set_params(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *p)
-{
- struct pluto *pluto = frontend_to_pluto(fe);
- struct i2c_msg msg;
- int ret;
- u8 buf[4];
- u32 div;
-
- // Fref = 166.667 Hz
- // Fref * 3 = 500.000 Hz
- // IF = 36166667
- // IF / Fref = 217
- //div = divide(p->frequency + 36166667, 166667);
- div = divide(p->frequency * 3, 500000) + 217;
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = (div >> 0) & 0xff;
-
- if (p->frequency < 611000000)
- buf[2] = 0xb4;
- else if (p->frequency < 811000000)
- buf[2] = 0xbc;
- else
- buf[2] = 0xf4;
-
- // VHF: 174-230 MHz
- // center: 350 MHz
- // UHF: 470-862 MHz
- if (p->frequency < 350000000)
- buf[3] = 0x02;
- else
- buf[3] = 0x04;
-
- if (p->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
- buf[3] |= 0x08;
-
- if (sizeof(buf) == 6) {
- buf[4] = buf[2];
- buf[4] &= ~0x1c;
- buf[4] |= 0x18;
-
- buf[5] = (0 << 7) | (2 << 4);
- }
-
- msg.addr = I2C_ADDR_TUA6034 >> 1;
- msg.flags = 0;
- msg.buf = buf;
- msg.len = sizeof(buf);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- ret = i2c_transfer(&pluto->i2c_adap, &msg, 1);
- if (ret < 0)
- return ret;
- else if (ret == 0)
- return -EREMOTEIO;
-
- return 0;
-}
-
-static int pluto2_request_firmware(struct dvb_frontend *fe,
- const struct firmware **fw, char *name)
-{
- struct pluto *pluto = frontend_to_pluto(fe);
-
- return request_firmware(fw, name, &pluto->pdev->dev);
-}
-
-static struct tda1004x_config pluto2_fe_config __devinitdata = {
- .demod_address = I2C_ADDR_TDA10046 >> 1,
- .invert = 1,
- .invert_oclk = 0,
- .xtal_freq = TDA10046_XTAL_16M,
- .agc_config = TDA10046_AGC_DEFAULT,
- .if_freq = TDA10046_FREQ_3617,
- .request_firmware = pluto2_request_firmware,
-};
-
-static int __devinit frontend_init(struct pluto *pluto)
-{
- int ret;
-
- pluto->fe = tda10046_attach(&pluto2_fe_config, &pluto->i2c_adap);
- if (!pluto->fe) {
- dev_err(&pluto->pdev->dev, "could not attach frontend\n");
- return -ENODEV;
- }
- pluto->fe->ops.tuner_ops.set_params = lg_tdtpe001p_tuner_set_params;
-
- ret = dvb_register_frontend(&pluto->dvb_adapter, pluto->fe);
- if (ret < 0) {
- if (pluto->fe->ops.release)
- pluto->fe->ops.release(pluto->fe);
- return ret;
- }
-
- return 0;
-}
-
-static void __devinit pluto_read_rev(struct pluto *pluto)
-{
- u32 val = pluto_readreg(pluto, REG_MISC) & MISC_DVR;
- dev_info(&pluto->pdev->dev, "board revision %d.%d\n",
- (val >> 12) & 0x0f, (val >> 4) & 0xff);
-}
-
-static void __devinit pluto_read_mac(struct pluto *pluto, u8 *mac)
-{
- u32 val = pluto_readreg(pluto, REG_MMAC);
- mac[0] = (val >> 8) & 0xff;
- mac[1] = (val >> 0) & 0xff;
-
- val = pluto_readreg(pluto, REG_IMAC);
- mac[2] = (val >> 8) & 0xff;
- mac[3] = (val >> 0) & 0xff;
-
- val = pluto_readreg(pluto, REG_LMAC);
- mac[4] = (val >> 8) & 0xff;
- mac[5] = (val >> 0) & 0xff;
-
- dev_info(&pluto->pdev->dev, "MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
- mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-}
-
-static int __devinit pluto_read_serial(struct pluto *pluto)
-{
- struct pci_dev *pdev = pluto->pdev;
- unsigned int i, j;
- u8 __iomem *cis;
-
- cis = pci_iomap(pdev, 1, 0);
- if (!cis)
- return -EIO;
-
- dev_info(&pdev->dev, "S/N ");
-
- for (i = 0xe0; i < 0x100; i += 4) {
- u32 val = readl(&cis[i]);
- for (j = 0; j < 32; j += 8) {
- if ((val & 0xff) == 0xff)
- goto out;
- printk("%c", val & 0xff);
- val >>= 8;
- }
- }
-out:
- printk("\n");
- pci_iounmap(pdev, cis);
-
- return 0;
-}
-
-static int __devinit pluto2_probe(struct pci_dev *pdev,
- const struct pci_device_id *ent)
-{
- struct pluto *pluto;
- struct dvb_adapter *dvb_adapter;
- struct dvb_demux *dvbdemux;
- struct dmx_demux *dmx;
- int ret = -ENOMEM;
-
- pluto = kzalloc(sizeof(struct pluto), GFP_KERNEL);
- if (!pluto)
- goto out;
-
- pluto->pdev = pdev;
-
- ret = pci_enable_device(pdev);
- if (ret < 0)
- goto err_kfree;
-
- /* enable interrupts */
- pci_write_config_dword(pdev, 0x6c, 0x8000);
-
- ret = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
- 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;
-
- pluto->io_mem = pci_iomap(pdev, 0, 0x40);
- if (!pluto->io_mem) {
- ret = -EIO;
- goto err_pci_release_regions;
- }
-
- pci_set_drvdata(pdev, pluto);
-
- ret = request_irq(pdev->irq, pluto_irq, IRQF_SHARED, DRIVER_NAME, pluto);
- if (ret < 0)
- goto err_pci_iounmap;
-
- ret = pluto_hw_init(pluto);
- if (ret < 0)
- goto err_free_irq;
-
- /* i2c */
- i2c_set_adapdata(&pluto->i2c_adap, pluto);
- strcpy(pluto->i2c_adap.name, DRIVER_NAME);
- pluto->i2c_adap.owner = THIS_MODULE;
- pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
- pluto->i2c_adap.dev.parent = &pdev->dev;
- pluto->i2c_adap.algo_data = &pluto->i2c_bit;
- pluto->i2c_bit.data = pluto;
- pluto->i2c_bit.setsda = pluto_setsda;
- pluto->i2c_bit.setscl = pluto_setscl;
- pluto->i2c_bit.getsda = pluto_getsda;
- pluto->i2c_bit.getscl = pluto_getscl;
- pluto->i2c_bit.udelay = 10;
- pluto->i2c_bit.timeout = 10;
-
- /* Raise SCL and SDA */
- pluto_setsda(pluto, 1);
- pluto_setscl(pluto, 1);
-
- ret = i2c_bit_add_bus(&pluto->i2c_adap);
- if (ret < 0)
- goto err_pluto_hw_exit;
-
- /* dvb */
- ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev);
- if (ret < 0)
- goto err_i2c_bit_del_bus;
-
- dvb_adapter = &pluto->dvb_adapter;
-
- pluto_read_rev(pluto);
- pluto_read_serial(pluto);
- pluto_read_mac(pluto, dvb_adapter->proposed_mac);
-
- dvbdemux = &pluto->demux;
- dvbdemux->filternum = 256;
- dvbdemux->feednum = 256;
- dvbdemux->start_feed = pluto_start_feed;
- dvbdemux->stop_feed = pluto_stop_feed;
- 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;
-
- pluto->hw_frontend.source = DMX_FRONTEND_0;
- pluto->mem_frontend.source = DMX_MEMORY_FE;
- pluto->dmxdev.filternum = NHWFILTERS;
- pluto->dmxdev.demux = dmx;
-
- ret = dvb_dmxdev_init(&pluto->dmxdev, dvb_adapter);
- if (ret < 0)
- goto err_dvb_dmx_release;
-
- ret = dmx->add_frontend(dmx, &pluto->hw_frontend);
- if (ret < 0)
- goto err_dvb_dmxdev_release;
-
- ret = dmx->add_frontend(dmx, &pluto->mem_frontend);
- if (ret < 0)
- goto err_remove_hw_frontend;
-
- ret = dmx->connect_frontend(dmx, &pluto->hw_frontend);
- if (ret < 0)
- goto err_remove_mem_frontend;
-
- ret = frontend_init(pluto);
- if (ret < 0)
- goto err_disconnect_frontend;
-
- dvb_net_init(dvb_adapter, &pluto->dvbnet, dmx);
-out:
- return ret;
-
-err_disconnect_frontend:
- dmx->disconnect_frontend(dmx);
-err_remove_mem_frontend:
- dmx->remove_frontend(dmx, &pluto->mem_frontend);
-err_remove_hw_frontend:
- dmx->remove_frontend(dmx, &pluto->hw_frontend);
-err_dvb_dmxdev_release:
- dvb_dmxdev_release(&pluto->dmxdev);
-err_dvb_dmx_release:
- dvb_dmx_release(dvbdemux);
-err_dvb_unregister_adapter:
- dvb_unregister_adapter(dvb_adapter);
-err_i2c_bit_del_bus:
- i2c_bit_del_bus(&pluto->i2c_adap);
-err_pluto_hw_exit:
- pluto_hw_exit(pluto);
-err_free_irq:
- free_irq(pdev->irq, pluto);
-err_pci_iounmap:
- pci_iounmap(pdev, pluto->io_mem);
-err_pci_release_regions:
- pci_release_regions(pdev);
-err_pci_disable_device:
- pci_disable_device(pdev);
-err_kfree:
- pci_set_drvdata(pdev, NULL);
- kfree(pluto);
- goto out;
-}
-
-static void __devexit pluto2_remove(struct pci_dev *pdev)
-{
- struct pluto *pluto = pci_get_drvdata(pdev);
- struct dvb_adapter *dvb_adapter = &pluto->dvb_adapter;
- struct dvb_demux *dvbdemux = &pluto->demux;
- struct dmx_demux *dmx = &dvbdemux->dmx;
-
- dmx->close(dmx);
- dvb_net_release(&pluto->dvbnet);
- if (pluto->fe)
- dvb_unregister_frontend(pluto->fe);
-
- dmx->disconnect_frontend(dmx);
- dmx->remove_frontend(dmx, &pluto->mem_frontend);
- dmx->remove_frontend(dmx, &pluto->hw_frontend);
- dvb_dmxdev_release(&pluto->dmxdev);
- dvb_dmx_release(dvbdemux);
- dvb_unregister_adapter(dvb_adapter);
- i2c_bit_del_bus(&pluto->i2c_adap);
- pluto_hw_exit(pluto);
- free_irq(pdev->irq, pluto);
- pci_iounmap(pdev, pluto->io_mem);
- pci_release_regions(pdev);
- pci_disable_device(pdev);
- pci_set_drvdata(pdev, NULL);
- kfree(pluto);
-}
-
-#ifndef PCI_VENDOR_ID_SCM
-#define PCI_VENDOR_ID_SCM 0x0432
-#endif
-#ifndef PCI_DEVICE_ID_PLUTO2
-#define PCI_DEVICE_ID_PLUTO2 0x0001
-#endif
-
-static struct pci_device_id pluto2_id_table[] __devinitdata = {
- {
- .vendor = PCI_VENDOR_ID_SCM,
- .device = PCI_DEVICE_ID_PLUTO2,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- }, {
- /* empty */
- },
-};
-
-MODULE_DEVICE_TABLE(pci, pluto2_id_table);
-
-static struct pci_driver pluto2_driver = {
- .name = DRIVER_NAME,
- .id_table = pluto2_id_table,
- .probe = pluto2_probe,
- .remove = __devexit_p(pluto2_remove),
-};
-
-static int __init pluto2_init(void)
-{
- return pci_register_driver(&pluto2_driver);
-}
-
-static void __exit pluto2_exit(void)
-{
- pci_unregister_driver(&pluto2_driver);
-}
-
-module_init(pluto2_init);
-module_exit(pluto2_exit);
-
-MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
-MODULE_DESCRIPTION("Pluto2 driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
deleted file mode 100644
index 5fb097595cf..00000000000
--- a/drivers/media/dvb/ttpci/Kconfig
+++ /dev/null
@@ -1,146 +0,0 @@
-config DVB_AV7110
- tristate "AV7110 cards"
- depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
- select FW_LOADER
- select VIDEO_SAA7146_VV
- select DVB_PLL
- select DVB_VES1820
- select DVB_VES1X93
- select DVB_STV0299
- select DVB_TDA8083
- select DVB_SP8870
- select DVB_STV0297
- select DVB_L64781
- select DVB_LNBP21
- help
- Support for SAA7146 and AV7110 based DVB cards as produced
- by Fujitsu-Siemens, Technotrend, Hauppauge and others.
-
- This driver only supports the fullfeatured cards with
- onboard MPEG2 decoder.
-
- This driver needs an external firmware. Please use the script
- "<kerneldir>/Documentation/dvb/get_dvb_firmware av7110" to
- download/extract it, and then copy it to /usr/lib/hotplug/firmware
- or /lib/firmware (depending on configuration of firmware hotplug).
-
- Say Y if you own such a card and want to use it.
-
-config DVB_AV7110_FIRMWARE
- bool "Compile AV7110 firmware into the driver"
- depends on DVB_AV7110 && !STANDALONE
- default y if DVB_AV7110=y
- help
- The AV7110 firmware is normally loaded by the firmware hotplug manager.
- If you want to compile the firmware into the driver you need to say
- Y here and provide the correct path of the firmware. You need this
- option if you want to compile the whole driver statically into the
- kernel.
-
- All other people say N.
-
-config DVB_AV7110_FIRMWARE_FILE
- string "Full pathname of av7110 firmware file"
- depends on DVB_AV7110_FIRMWARE
- default "/usr/lib/hotplug/firmware/dvb-ttpci-01.fw"
-
-config DVB_AV7110_OSD
- bool "AV7110 OSD support"
- depends on DVB_AV7110
- default y if DVB_AV7110=y || DVB_AV7110=m
- help
- The AV7110 firmware provides some code to generate an OnScreenDisplay
- on the video output. This is kind of nonstandard and not guaranteed to
- be maintained.
-
- Anyway, some popular DVB software like VDR uses this OSD to render
- its menus, so say Y if you want to use this software.
-
- All other people say N.
-
-config DVB_BUDGET
- tristate "Budget cards"
- depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
- select VIDEO_SAA7146
- select DVB_PLL
- select DVB_STV0299
- select DVB_VES1X93
- select DVB_VES1820
- select DVB_L64781
- select DVB_TDA8083
- select DVB_TDA10021
- select DVB_S5H1420
- select DVB_LNBP21
- help
- Support for simple SAA7146 based DVB cards
- (so called Budget- or Nova-PCI cards) without onboard
- MPEG2 decoder.
-
- Say Y if you own such a card and want to use it.
-
- To compile this driver as a module, choose M here: the
- module will be called budget.
-
-config DVB_BUDGET_CI
- tristate "Budget cards with onboard CI connector"
- depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
- select VIDEO_SAA7146
- select DVB_PLL
- select DVB_STV0297
- select DVB_STV0299
- select DVB_TDA1004X
- select DVB_LNBP21
- help
- Support for simple SAA7146 based DVB cards
- (so called Budget- or Nova-PCI cards) without onboard
- MPEG2 decoder, but with onboard Common Interface connector.
-
- Note: The Common Interface is not yet supported by this driver
- due to lack of information from the vendor.
-
- Say Y if you own such a card and want to use it.
-
- To compile this driver as a module, choose M here: the
- module will be called budget-ci.
-
-config DVB_BUDGET_AV
- tristate "Budget cards with analog video inputs"
- depends on DVB_CORE && PCI && I2C && VIDEO_V4L1
- select VIDEO_SAA7146_VV
- select DVB_PLL
- select DVB_STV0299
- select DVB_TDA1004X
- select DVB_TDA10021
- select FW_LOADER
- help
- Support for simple SAA7146 based DVB cards
- (so called Budget- or Nova-PCI cards) without onboard
- MPEG2 decoder, but with one or more analog video inputs.
-
- Say Y if you own such a card and want to use it.
-
- To compile this driver as a module, choose M here: the
- module will be called budget-av.
-
-config DVB_BUDGET_PATCH
- tristate "AV7110 cards with Budget Patch"
- depends on DVB_CORE && DVB_BUDGET && VIDEO_V4L1
- select DVB_AV7110
- select DVB_PLL
- select DVB_STV0299
- select DVB_VES1X93
- select DVB_TDA8083
- help
- Support for Budget Patch (full TS) modification on
- SAA7146+AV7110 based cards (DVB-S cards). This
- driver doesn't use onboard MPEG2 decoder. The
- card is driven in Budget-only mode. Card is
- required to have loaded firmware to tune properly.
- Firmware can be loaded by insertion and removal of
- standard AV7110 driver prior to loading this
- driver.
-
- Say Y if you own such a card and want to use it.
-
- To compile this driver as a module, choose M here: the
- module will be called budget-patch.
diff --git a/drivers/media/dvb/ttpci/Makefile b/drivers/media/dvb/ttpci/Makefile
deleted file mode 100644
index aa85ecdc6c8..00000000000
--- a/drivers/media/dvb/ttpci/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Makefile for the kernel SAA7146 FULL TS DVB device driver
-# and the AV7110 DVB device driver
-#
-
-dvb-ttpci-objs := av7110_hw.o av7110_v4l.o av7110_av.o av7110_ca.o av7110.o av7110_ipack.o av7110_ir.o
-
-obj-$(CONFIG_DVB_BUDGET) += budget-core.o budget.o ttpci-eeprom.o
-obj-$(CONFIG_DVB_BUDGET_AV) += budget-core.o budget-av.o ttpci-eeprom.o
-obj-$(CONFIG_DVB_BUDGET_CI) += budget-core.o budget-ci.o ttpci-eeprom.o
-obj-$(CONFIG_DVB_BUDGET_PATCH) += budget-core.o budget-patch.o ttpci-eeprom.o
-obj-$(CONFIG_DVB_AV7110) += dvb-ttpci.o ttpci-eeprom.o
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/
-
-hostprogs-y := fdump
-
-ifeq ($(CONFIG_DVB_AV7110_FIRMWARE),y)
-$(obj)/av7110.o: $(obj)/av7110_firm.h
-
-$(obj)/av7110_firm.h: $(obj)/fdump
- $(obj)/fdump $(CONFIG_DVB_AV7110_FIRMWARE_FILE) dvb_ttpci_fw $@
-endif
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
deleted file mode 100644
index 4506165c5de..00000000000
--- a/drivers/media/dvb/ttpci/av7110.c
+++ /dev/null
@@ -1,2858 +0,0 @@
-/*
- * driver for the SAA7146 based AV110 cards (like the Fujitsu-Siemens DVB)
- * av7110.c: initialization and demux stuff
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * originally based on code by:
- * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-
-#include <linux/module.h>
-#include <linux/kmod.h>
-#include <linux/delay.h>
-#include <linux/fs.h>
-#include <linux/timer.h>
-#include <linux/poll.h>
-#include <linux/byteorder/swabb.h>
-#include <linux/smp_lock.h>
-
-#include <linux/kernel.h>
-#include <linux/moduleparam.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/fcntl.h>
-#include <linux/interrupt.h>
-#include <linux/string.h>
-#include <linux/pci.h>
-#include <linux/vmalloc.h>
-#include <linux/firmware.h>
-#include <linux/crc32.h>
-#include <linux/i2c.h>
-
-#include <asm/system.h>
-
-#include <linux/dvb/frontend.h>
-
-#include "dvb_frontend.h"
-
-#include "ttpci-eeprom.h"
-#include "av7110.h"
-#include "av7110_hw.h"
-#include "av7110_av.h"
-#include "av7110_ca.h"
-#include "av7110_ipack.h"
-
-#include "bsbe1.h"
-#include "lnbp21.h"
-#include "bsru6.h"
-
-#define TS_WIDTH 376
-#define TS_HEIGHT 512
-#define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
-#define TS_MAX_PACKETS (TS_BUFLEN/TS_SIZE)
-
-
-int av7110_debug;
-
-static int vidmode = CVBS_RGB_OUT;
-static int pids_off;
-static int adac = DVB_ADAC_TI;
-static int hw_sections;
-static int rgb_on;
-static int volume = 255;
-static int budgetpatch;
-static int wss_cfg_4_3 = 0x4008;
-static int wss_cfg_16_9 = 0x0007;
-static int tv_standard;
-
-module_param_named(debug, av7110_debug, int, 0644);
-MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)");
-module_param(vidmode, int, 0444);
-MODULE_PARM_DESC(vidmode,"analog video out: 0 off, 1 CVBS+RGB (default), 2 CVBS+YC, 3 YC");
-module_param(pids_off, int, 0444);
-MODULE_PARM_DESC(pids_off,"clear video/audio/PCR PID filters when demux is closed");
-module_param(adac, int, 0444);
-MODULE_PARM_DESC(adac,"audio DAC type: 0 TI, 1 CRYSTAL, 2 MSP (use if autodetection fails)");
-module_param(hw_sections, int, 0444);
-MODULE_PARM_DESC(hw_sections, "0 use software section filter, 1 use hardware");
-module_param(rgb_on, int, 0444);
-MODULE_PARM_DESC(rgb_on, "For Siemens DVB-C cards only: Enable RGB control"
- " signal on SCART pin 16 to switch SCART video mode from CVBS to RGB");
-module_param(volume, int, 0444);
-MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)");
-module_param(budgetpatch, int, 0444);
-MODULE_PARM_DESC(budgetpatch, "use budget-patch hardware modification: default 0 (0 no, 1 autodetect, 2 always)");
-module_param(wss_cfg_4_3, int, 0444);
-MODULE_PARM_DESC(wss_cfg_4_3, "WSS 4:3 - default 0x4008 - bit 15: disable, 14: burst mode, 13..0: wss data");
-module_param(wss_cfg_16_9, int, 0444);
-MODULE_PARM_DESC(wss_cfg_16_9, "WSS 16:9 - default 0x0007 - bit 15: disable, 14: burst mode, 13..0: wss data");
-module_param(tv_standard, int, 0444);
-MODULE_PARM_DESC(tv_standard, "TV standard: 0 PAL (default), 1 NTSC");
-
-static void restart_feeds(struct av7110 *av7110);
-
-static int av7110_num;
-
-#define FE_FUNC_OVERRIDE(fe_func, av7110_copy, av7110_func) \
-{\
- if (fe_func != NULL) { \
- av7110_copy = fe_func; \
- fe_func = av7110_func; \
- } \
-}
-
-
-static void init_av7110_av(struct av7110 *av7110)
-{
- int ret;
- struct saa7146_dev *dev = av7110->dev;
-
- /* set internal volume control to maximum */
- av7110->adac_type = DVB_ADAC_TI;
- ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
- if (ret < 0)
- printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret);
-
- ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 2, wss_cfg_4_3);
- if (ret < 0)
- printk("dvb-ttpci: unable to configure 4:3 wss\n");
- ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 3, wss_cfg_16_9);
- if (ret < 0)
- printk("dvb-ttpci: unable to configure 16:9 wss\n");
-
- ret = av7710_set_video_mode(av7110, vidmode);
- if (ret < 0)
- printk("dvb-ttpci:cannot set video mode:%d\n",ret);
-
- /* handle different card types */
- /* remaining inits according to card and frontend type */
- av7110->analog_tuner_flags = 0;
- av7110->current_input = 0;
- if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000a)
- av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 0); // SPDIF on
- if (i2c_writereg(av7110, 0x20, 0x00, 0x00) == 1) {
- printk ("dvb-ttpci: Crystal audio DAC @ card %d detected\n",
- av7110->dvb_adapter.num);
- av7110->adac_type = DVB_ADAC_CRYSTAL;
- i2c_writereg(av7110, 0x20, 0x01, 0xd2);
- i2c_writereg(av7110, 0x20, 0x02, 0x49);
- i2c_writereg(av7110, 0x20, 0x03, 0x00);
- i2c_writereg(av7110, 0x20, 0x04, 0x00);
-
- /**
- * some special handling for the Siemens DVB-C cards...
- */
- } else if (0 == av7110_init_analog_module(av7110)) {
- /* done. */
- }
- else if (dev->pci->subsystem_vendor == 0x110a) {
- printk("dvb-ttpci: DVB-C w/o analog module @ card %d detected\n",
- av7110->dvb_adapter.num);
- av7110->adac_type = DVB_ADAC_NONE;
- }
- else {
- av7110->adac_type = adac;
- printk("dvb-ttpci: adac type set to %d @ card %d\n",
- av7110->adac_type, av7110->dvb_adapter.num);
- }
-
- if (av7110->adac_type == DVB_ADAC_NONE || av7110->adac_type == DVB_ADAC_MSP34x0) {
- // switch DVB SCART on
- ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
- if (ret < 0)
- printk("dvb-ttpci:cannot switch on SCART(Main):%d\n",ret);
- ret = av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
- if (ret < 0)
- printk("dvb-ttpci:cannot switch on SCART(AD):%d\n",ret);
- if (rgb_on &&
- ((av7110->dev->pci->subsystem_vendor == 0x110a) ||
- (av7110->dev->pci->subsystem_vendor == 0x13c2)) &&
- (av7110->dev->pci->subsystem_device == 0x0000)) {
- saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
- //saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
- }
- }
-
- if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000e)
- av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, SpdifSwitch, 1, 0); // SPDIF on
-
- ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
- if (ret < 0)
- printk("dvb-ttpci:cannot set volume :%d\n",ret);
-}
-
-static void recover_arm(struct av7110 *av7110)
-{
- dprintk(4, "%p\n",av7110);
-
- av7110_bootarm(av7110);
- msleep(100);
-
- init_av7110_av(av7110);
-
- /* card-specific recovery */
- if (av7110->recover)
- av7110->recover(av7110);
-
- restart_feeds(av7110);
- av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, av7110->ir_config);
-}
-
-static void av7110_arm_sync(struct av7110 *av7110)
-{
- av7110->arm_rmmod = 1;
- wake_up_interruptible(&av7110->arm_wait);
-
- while (av7110->arm_thread)
- msleep(1);
-}
-
-static int arm_thread(void *data)
-{
- struct av7110 *av7110 = data;
- u16 newloops = 0;
- int timeout;
-
- dprintk(4, "%p\n",av7110);
-
- lock_kernel();
- daemonize("arm_mon");
- sigfillset(&current->blocked);
- unlock_kernel();
-
- av7110->arm_thread = current;
-
- for (;;) {
- timeout = wait_event_interruptible_timeout(av7110->arm_wait,
- av7110->arm_rmmod, 5 * HZ);
- if (-ERESTARTSYS == timeout || av7110->arm_rmmod) {
- /* got signal or told to quit*/
- break;
- }
-
- if (!av7110->arm_ready)
- continue;
-
- if (mutex_lock_interruptible(&av7110->dcomlock))
- break;
- newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
- mutex_unlock(&av7110->dcomlock);
-
- if (newloops == av7110->arm_loops || av7110->arm_errors > 3) {
- printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
- av7110->dvb_adapter.num);
-
- recover_arm(av7110);
-
- if (mutex_lock_interruptible(&av7110->dcomlock))
- break;
- newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
- mutex_unlock(&av7110->dcomlock);
- }
- av7110->arm_loops = newloops;
- av7110->arm_errors = 0;
- }
-
- av7110->arm_thread = NULL;
- return 0;
-}
-
-
-/****************************************************************************
- * IRQ handling
- ****************************************************************************/
-
-static int DvbDmxFilterCallback(u8 *buffer1, size_t buffer1_len,
- u8 *buffer2, size_t buffer2_len,
- struct dvb_demux_filter *dvbdmxfilter,
- enum dmx_success success,
- struct av7110 *av7110)
-{
- if (!dvbdmxfilter->feed->demux->dmx.frontend)
- return 0;
- if (dvbdmxfilter->feed->demux->dmx.frontend->source == DMX_MEMORY_FE)
- return 0;
-
- switch (dvbdmxfilter->type) {
- case DMX_TYPE_SEC:
- if ((((buffer1[1] << 8) | buffer1[2]) & 0xfff) + 3 != buffer1_len)
- return 0;
- if (dvbdmxfilter->doneq) {
- struct dmx_section_filter *filter = &dvbdmxfilter->filter;
- int i;
- u8 xor, neq = 0;
-
- for (i = 0; i < DVB_DEMUX_MASK_MAX; i++) {
- xor = filter->filter_value[i] ^ buffer1[i];
- neq |= dvbdmxfilter->maskandnotmode[i] & xor;
- }
- if (!neq)
- return 0;
- }
- return dvbdmxfilter->feed->cb.sec(buffer1, buffer1_len,
- buffer2, buffer2_len,
- &dvbdmxfilter->filter,
- DMX_OK);
- case DMX_TYPE_TS:
- if (!(dvbdmxfilter->feed->ts_type & TS_PACKET))
- return 0;
- if (dvbdmxfilter->feed->ts_type & TS_PAYLOAD_ONLY)
- return dvbdmxfilter->feed->cb.ts(buffer1, buffer1_len,
- buffer2, buffer2_len,
- &dvbdmxfilter->feed->feed.ts,
- DMX_OK);
- else
- av7110_p2t_write(buffer1, buffer1_len,
- dvbdmxfilter->feed->pid,
- &av7110->p2t_filter[dvbdmxfilter->index]);
- default:
- return 0;
- }
-}
-
-
-//#define DEBUG_TIMING
-static inline void print_time(char *s)
-{
-#ifdef DEBUG_TIMING
- struct timeval tv;
- do_gettimeofday(&tv);
- printk("%s: %d.%d\n", s, (int)tv.tv_sec, (int)tv.tv_usec);
-#endif
-}
-
-#define DEBI_READ 0
-#define DEBI_WRITE 1
-static inline void start_debi_dma(struct av7110 *av7110, int dir,
- unsigned long addr, unsigned int len)
-{
- dprintk(8, "%c %08lx %u\n", dir == DEBI_READ ? 'R' : 'W', addr, len);
- if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
- printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__);
- return;
- }
-
- SAA7146_ISR_CLEAR(av7110->dev, MASK_19); /* for good measure */
- SAA7146_IER_ENABLE(av7110->dev, MASK_19);
- if (len < 5)
- len = 5; /* we want a real DEBI DMA */
- if (dir == DEBI_WRITE)
- iwdebi(av7110, DEBISWAB, addr, 0, (len + 3) & ~3);
- else
- irdebi(av7110, DEBISWAB, addr, 0, len);
-}
-
-static void debiirq(unsigned long data)
-{
- struct av7110 *av7110 = (struct av7110 *) data;
- int type = av7110->debitype;
- int handle = (type >> 8) & 0x1f;
- unsigned int xfer = 0;
-
- print_time("debi");
- dprintk(4, "type 0x%04x\n", type);
-
- if (type == -1) {
- printk("DEBI irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
- jiffies, saa7146_read(av7110->dev, PSR),
- saa7146_read(av7110->dev, SSR));
- goto debi_done;
- }
- av7110->debitype = -1;
-
- switch (type & 0xff) {
-
- case DATA_TS_RECORD:
- dvb_dmx_swfilter_packets(&av7110->demux,
- (const u8 *) av7110->debi_virt,
- av7110->debilen / 188);
- xfer = RX_BUFF;
- break;
-
- case DATA_PES_RECORD:
- if (av7110->demux.recording)
- av7110_record_cb(&av7110->p2t[handle],
- (u8 *) av7110->debi_virt,
- av7110->debilen);
- xfer = RX_BUFF;
- break;
-
- case DATA_IPMPE:
- case DATA_FSECTION:
- case DATA_PIPING:
- if (av7110->handle2filter[handle])
- DvbDmxFilterCallback((u8 *)av7110->debi_virt,
- av7110->debilen, NULL, 0,
- av7110->handle2filter[handle],
- DMX_OK, av7110);
- xfer = RX_BUFF;
- break;
-
- case DATA_CI_GET:
- {
- u8 *data = av7110->debi_virt;
-
- if ((data[0] < 2) && data[2] == 0xff) {
- int flags = 0;
- if (data[5] > 0)
- flags |= CA_CI_MODULE_PRESENT;
- if (data[5] > 5)
- flags |= CA_CI_MODULE_READY;
- av7110->ci_slot[data[0]].flags = flags;
- } else
- ci_get_data(&av7110->ci_rbuffer,
- av7110->debi_virt,
- av7110->debilen);
- xfer = RX_BUFF;
- break;
- }
-
- case DATA_COMMON_INTERFACE:
- CI_handle(av7110, (u8 *)av7110->debi_virt, av7110->debilen);
-#if 0
- {
- int i;
-
- printk("av7110%d: ", av7110->num);
- printk("%02x ", *(u8 *)av7110->debi_virt);
- printk("%02x ", *(1+(u8 *)av7110->debi_virt));
- for (i = 2; i < av7110->debilen; i++)
- printk("%02x ", (*(i+(unsigned char *)av7110->debi_virt)));
- for (i = 2; i < av7110->debilen; i++)
- printk("%c", chtrans(*(i+(unsigned char *)av7110->debi_virt)));
-
- printk("\n");
- }
-#endif
- xfer = RX_BUFF;
- break;
-
- case DATA_DEBUG_MESSAGE:
- ((s8*)av7110->debi_virt)[Reserved_SIZE - 1] = 0;
- printk("%s\n", (s8 *) av7110->debi_virt);
- xfer = RX_BUFF;
- break;
-
- case DATA_CI_PUT:
- dprintk(4, "debi DATA_CI_PUT\n");
- case DATA_MPEG_PLAY:
- dprintk(4, "debi DATA_MPEG_PLAY\n");
- case DATA_BMP_LOAD:
- dprintk(4, "debi DATA_BMP_LOAD\n");
- xfer = TX_BUFF;
- break;
- default:
- break;
- }
-debi_done:
- spin_lock(&av7110->debilock);
- if (xfer)
- iwdebi(av7110, DEBINOSWAP, xfer, 0, 2);
- ARM_ClearMailBox(av7110);
- spin_unlock(&av7110->debilock);
-}
-
-/* irq from av7110 firmware writing the mailbox register in the DPRAM */
-static void gpioirq(unsigned long data)
-{
- struct av7110 *av7110 = (struct av7110 *) data;
- u32 rxbuf, txbuf;
- int len;
-
- if (av7110->debitype != -1)
- /* we shouldn't get any irq while a debi xfer is running */
- printk("dvb-ttpci: GPIO0 irq oops @ %ld, psr:0x%08x, ssr:0x%08x\n",
- jiffies, saa7146_read(av7110->dev, PSR),
- saa7146_read(av7110->dev, SSR));
-
- if (saa7146_wait_for_debi_done(av7110->dev, 0)) {
- printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__);
- BUG(); /* maybe we should try resetting the debi? */
- }
-
- spin_lock(&av7110->debilock);
- ARM_ClearIrq(av7110);
-
- /* see what the av7110 wants */
- av7110->debitype = irdebi(av7110, DEBINOSWAP, IRQ_STATE, 0, 2);
- av7110->debilen = irdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
- rxbuf = irdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
- txbuf = irdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
- len = (av7110->debilen + 3) & ~3;
-
- print_time("gpio");
- dprintk(8, "GPIO0 irq 0x%04x %d\n", av7110->debitype, av7110->debilen);
-
- switch (av7110->debitype & 0xff) {
-
- case DATA_TS_PLAY:
- case DATA_PES_PLAY:
- break;
-
- case DATA_MPEG_VIDEO_EVENT:
- {
- u32 h_ar;
- struct video_event event;
-
- av7110->video_size.w = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_WIDTH, 0, 2);
- h_ar = irdebi(av7110, DEBINOSWAP, STATUS_MPEG_HEIGHT_AR, 0, 2);
-
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
- iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
-
- av7110->video_size.h = h_ar & 0xfff;
-
- event.type = VIDEO_EVENT_SIZE_CHANGED;
- event.u.size.w = av7110->video_size.w;
- event.u.size.h = av7110->video_size.h;
- switch ((h_ar >> 12) & 0xf)
- {
- case 3:
- av7110->video_size.aspect_ratio = VIDEO_FORMAT_16_9;
- event.u.size.aspect_ratio = VIDEO_FORMAT_16_9;
- av7110->videostate.video_format = VIDEO_FORMAT_16_9;
- break;
- case 4:
- av7110->video_size.aspect_ratio = VIDEO_FORMAT_221_1;
- event.u.size.aspect_ratio = VIDEO_FORMAT_221_1;
- av7110->videostate.video_format = VIDEO_FORMAT_221_1;
- break;
- default:
- av7110->video_size.aspect_ratio = VIDEO_FORMAT_4_3;
- event.u.size.aspect_ratio = VIDEO_FORMAT_4_3;
- av7110->videostate.video_format = VIDEO_FORMAT_4_3;
- }
-
- dprintk(8, "GPIO0 irq: DATA_MPEG_VIDEO_EVENT: w/h/ar = %u/%u/%u\n",
- av7110->video_size.w, av7110->video_size.h,
- av7110->video_size.aspect_ratio);
-
- dvb_video_add_event(av7110, &event);
- break;
- }
-
- case DATA_CI_PUT:
- {
- int avail;
- struct dvb_ringbuffer *cibuf = &av7110->ci_wbuffer;
-
- avail = dvb_ringbuffer_avail(cibuf);
- if (avail <= 2) {
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
- break;
- }
- len = DVB_RINGBUFFER_PEEK(cibuf, 0) << 8;
- len |= DVB_RINGBUFFER_PEEK(cibuf, 1);
- if (avail < len + 2) {
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
- break;
- }
- DVB_RINGBUFFER_SKIP(cibuf, 2);
-
- dvb_ringbuffer_read(cibuf, av7110->debi_virt, len, 0);
-
- iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
- dprintk(8, "DMA: CI\n");
- start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
- spin_unlock(&av7110->debilock);
- wake_up(&cibuf->queue);
- return;
- }
-
- case DATA_MPEG_PLAY:
- if (!av7110->playing) {
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
- break;
- }
- len = 0;
- if (av7110->debitype & 0x100) {
- spin_lock(&av7110->aout.lock);
- len = av7110_pes_play(av7110->debi_virt, &av7110->aout, 2048);
- spin_unlock(&av7110->aout.lock);
- }
- if (len <= 0 && (av7110->debitype & 0x200)
- &&av7110->videostate.play_state != VIDEO_FREEZED) {
- spin_lock(&av7110->avout.lock);
- len = av7110_pes_play(av7110->debi_virt, &av7110->avout, 2048);
- spin_unlock(&av7110->avout.lock);
- }
- if (len <= 0) {
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
- break;
- }
- dprintk(8, "GPIO0 PES_PLAY len=%04x\n", len);
- iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
- dprintk(8, "DMA: MPEG_PLAY\n");
- start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE + txbuf, len);
- spin_unlock(&av7110->debilock);
- return;
-
- case DATA_BMP_LOAD:
- len = av7110->debilen;
- dprintk(8, "gpio DATA_BMP_LOAD len %d\n", len);
- if (!len) {
- av7110->bmp_state = BMP_LOADED;
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_LEN, 0, 2);
- iwdebi(av7110, DEBINOSWAP, TX_BUFF, 0, 2);
- wake_up(&av7110->bmpq);
- dprintk(8, "gpio DATA_BMP_LOAD done\n");
- break;
- }
- if (len > av7110->bmplen)
- len = av7110->bmplen;
- if (len > 2 * 1024)
- len = 2 * 1024;
- iwdebi(av7110, DEBINOSWAP, TX_LEN, len, 2);
- iwdebi(av7110, DEBINOSWAP, IRQ_STATE_EXT, len, 2);
- memcpy(av7110->debi_virt, av7110->bmpbuf+av7110->bmpp, len);
- av7110->bmpp += len;
- av7110->bmplen -= len;
- dprintk(8, "gpio DATA_BMP_LOAD DMA len %d\n", len);
- start_debi_dma(av7110, DEBI_WRITE, DPRAM_BASE+txbuf, len);
- spin_unlock(&av7110->debilock);
- return;
-
- case DATA_CI_GET:
- case DATA_COMMON_INTERFACE:
- case DATA_FSECTION:
- case DATA_IPMPE:
- case DATA_PIPING:
- if (!len || len > 4 * 1024) {
- iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
- break;
- }
- /* fall through */
-
- case DATA_TS_RECORD:
- case DATA_PES_RECORD:
- dprintk(8, "DMA: TS_REC etc.\n");
- start_debi_dma(av7110, DEBI_READ, DPRAM_BASE+rxbuf, len);
- spin_unlock(&av7110->debilock);
- return;
-
- case DATA_DEBUG_MESSAGE:
- if (!len || len > 0xff) {
- iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
- break;
- }
- start_debi_dma(av7110, DEBI_READ, Reserved, len);
- spin_unlock(&av7110->debilock);
- return;
-
- case DATA_IRCOMMAND:
- if (av7110->ir_handler)
- av7110->ir_handler(av7110,
- swahw32(irdebi(av7110, DEBINOSWAP, Reserved, 0, 4)));
- iwdebi(av7110, DEBINOSWAP, RX_BUFF, 0, 2);
- break;
-
- default:
- printk("dvb-ttpci: gpioirq unknown type=%d len=%d\n",
- av7110->debitype, av7110->debilen);
- break;
- }
- av7110->debitype = -1;
- ARM_ClearMailBox(av7110);
- spin_unlock(&av7110->debilock);
-}
-
-
-#ifdef CONFIG_DVB_AV7110_OSD
-static int dvb_osd_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
-
- dprintk(4, "%p\n", av7110);
-
- if (cmd == OSD_SEND_CMD)
- return av7110_osd_cmd(av7110, (osd_cmd_t *) parg);
- if (cmd == OSD_GET_CAPABILITY)
- return av7110_osd_capability(av7110, (osd_cap_t *) parg);
-
- return -EINVAL;
-}
-
-
-static struct file_operations dvb_osd_fops = {
- .owner = THIS_MODULE,
- .ioctl = dvb_generic_ioctl,
- .open = dvb_generic_open,
- .release = dvb_generic_release,
-};
-
-static struct dvb_device dvbdev_osd = {
- .priv = NULL,
- .users = 1,
- .writers = 1,
- .fops = &dvb_osd_fops,
- .kernel_ioctl = dvb_osd_ioctl,
-};
-#endif /* CONFIG_DVB_AV7110_OSD */
-
-
-static inline int SetPIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
- u16 subpid, u16 pcrpid)
-{
- u16 aflags = 0;
-
- dprintk(4, "%p\n", av7110);
-
- if (vpid == 0x1fff || apid == 0x1fff ||
- ttpid == 0x1fff || subpid == 0x1fff || pcrpid == 0x1fff) {
- vpid = apid = ttpid = subpid = pcrpid = 0;
- av7110->pids[DMX_PES_VIDEO] = 0;
- av7110->pids[DMX_PES_AUDIO] = 0;
- av7110->pids[DMX_PES_TELETEXT] = 0;
- av7110->pids[DMX_PES_PCR] = 0;
- }
-
- if (av7110->audiostate.bypass_mode)
- aflags |= 0x8000;
-
- return av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, MultiPID, 6,
- pcrpid, vpid, apid, ttpid, subpid, aflags);
-}
-
-int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
- u16 subpid, u16 pcrpid)
-{
- int ret = 0;
- dprintk(4, "%p\n", av7110);
-
- if (mutex_lock_interruptible(&av7110->pid_mutex))
- return -ERESTARTSYS;
-
- if (!(vpid & 0x8000))
- av7110->pids[DMX_PES_VIDEO] = vpid;
- if (!(apid & 0x8000))
- av7110->pids[DMX_PES_AUDIO] = apid;
- if (!(ttpid & 0x8000))
- av7110->pids[DMX_PES_TELETEXT] = ttpid;
- if (!(pcrpid & 0x8000))
- av7110->pids[DMX_PES_PCR] = pcrpid;
-
- av7110->pids[DMX_PES_SUBTITLE] = 0;
-
- if (av7110->fe_synced) {
- pcrpid = av7110->pids[DMX_PES_PCR];
- ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
- }
-
- mutex_unlock(&av7110->pid_mutex);
- return ret;
-}
-
-
-/******************************************************************************
- * hardware filter functions
- ******************************************************************************/
-
-static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter)
-{
- struct dvb_demux_feed *dvbdmxfeed = dvbdmxfilter->feed;
- struct av7110 *av7110 = (struct av7110 *) dvbdmxfeed->demux->priv;
- u16 buf[20];
- int ret, i;
- u16 handle;
-// u16 mode = 0x0320;
- u16 mode = 0xb96a;
-
- dprintk(4, "%p\n", av7110);
-
- if (dvbdmxfilter->type == DMX_TYPE_SEC) {
- if (hw_sections) {
- buf[4] = (dvbdmxfilter->filter.filter_value[0] << 8) |
- dvbdmxfilter->maskandmode[0];
- for (i = 3; i < 18; i++)
- buf[i + 4 - 2] =
- (dvbdmxfilter->filter.filter_value[i] << 8) |
- dvbdmxfilter->maskandmode[i];
- mode = 4;
- }
- } else if ((dvbdmxfeed->ts_type & TS_PACKET) &&
- !(dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)) {
- av7110_p2t_init(&av7110->p2t_filter[dvbdmxfilter->index], dvbdmxfeed);
- }
-
- buf[0] = (COMTYPE_PID_FILTER << 8) + AddPIDFilter;
- buf[1] = 16;
- buf[2] = dvbdmxfeed->pid;
- buf[3] = mode;
-
- ret = av7110_fw_request(av7110, buf, 20, &handle, 1);
- if (ret != 0 || handle >= 32) {
- printk("dvb-ttpci: %s error buf %04x %04x %04x %04x "
- "ret %d handle %04x\n",
- __FUNCTION__, buf[0], buf[1], buf[2], buf[3],
- ret, handle);
- dvbdmxfilter->hw_handle = 0xffff;
- if (!ret)
- ret = -1;
- return ret;
- }
-
- av7110->handle2filter[handle] = dvbdmxfilter;
- dvbdmxfilter->hw_handle = handle;
-
- return ret;
-}
-
-static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter)
-{
- struct av7110 *av7110 = (struct av7110 *) dvbdmxfilter->feed->demux->priv;
- u16 buf[3];
- u16 answ[2];
- int ret;
- u16 handle;
-
- dprintk(4, "%p\n", av7110);
-
- handle = dvbdmxfilter->hw_handle;
- if (handle >= 32) {
- printk("%s tried to stop invalid filter %04x, filter type = %x\n",
- __FUNCTION__, handle, dvbdmxfilter->type);
- return -EINVAL;
- }
-
- av7110->handle2filter[handle] = NULL;
-
- buf[0] = (COMTYPE_PID_FILTER << 8) + DelPIDFilter;
- buf[1] = 1;
- buf[2] = handle;
- ret = av7110_fw_request(av7110, buf, 3, answ, 2);
- if (ret != 0 || answ[1] != handle) {
- printk("dvb-ttpci: %s error cmd %04x %04x %04x ret %x "
- "resp %04x %04x pid %d\n",
- __FUNCTION__, buf[0], buf[1], buf[2], ret,
- answ[0], answ[1], dvbdmxfilter->feed->pid);
- if (!ret)
- ret = -1;
- }
- return ret;
-}
-
-
-static int dvb_feed_start_pid(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
- struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
- u16 *pid = dvbdmx->pids, npids[5];
- int i;
- int ret = 0;
-
- dprintk(4, "%p\n", av7110);
-
- npids[0] = npids[1] = npids[2] = npids[3] = npids[4] = 0xffff;
- i = dvbdmxfeed->pes_type;
- npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
- if ((i == 2) && npids[i] && (dvbdmxfeed->ts_type & TS_PACKET)) {
- npids[i] = 0;
- ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
- if (!ret)
- ret = StartHWFilter(dvbdmxfeed->filter);
- return ret;
- }
- if (dvbdmxfeed->pes_type <= 2 || dvbdmxfeed->pes_type == 4) {
- ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
- if (ret)
- return ret;
- }
-
- if (dvbdmxfeed->pes_type < 2 && npids[0])
- if (av7110->fe_synced)
- {
- ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
- if (ret)
- return ret;
- }
-
- if ((dvbdmxfeed->ts_type & TS_PACKET)) {
- if (dvbdmxfeed->pes_type == 0 && !(dvbdmx->pids[0] & 0x8000))
- ret = av7110_av_start_record(av7110, RP_AUDIO, dvbdmxfeed);
- if (dvbdmxfeed->pes_type == 1 && !(dvbdmx->pids[1] & 0x8000))
- ret = av7110_av_start_record(av7110, RP_VIDEO, dvbdmxfeed);
- }
- return ret;
-}
-
-static int dvb_feed_stop_pid(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
- struct av7110 *av7110 = (struct av7110 *) dvbdmx->priv;
- u16 *pid = dvbdmx->pids, npids[5];
- int i;
-
- int ret = 0;
-
- dprintk(4, "%p\n", av7110);
-
- if (dvbdmxfeed->pes_type <= 1) {
- ret = av7110_av_stop(av7110, dvbdmxfeed->pes_type ? RP_VIDEO : RP_AUDIO);
- if (ret)
- return ret;
- if (!av7110->rec_mode)
- dvbdmx->recording = 0;
- if (!av7110->playing)
- dvbdmx->playing = 0;
- }
- npids[0] = npids[1] = npids[2] = npids[3] = npids[4] = 0xffff;
- i = dvbdmxfeed->pes_type;
- switch (i) {
- case 2: //teletext
- if (dvbdmxfeed->ts_type & TS_PACKET)
- ret = StopHWFilter(dvbdmxfeed->filter);
- npids[2] = 0;
- break;
- case 0:
- case 1:
- case 4:
- if (!pids_off)
- return 0;
- npids[i] = (pid[i]&0x8000) ? 0 : pid[i];
- break;
- }
- if (!ret)
- ret = ChangePIDs(av7110, npids[1], npids[0], npids[2], npids[3], npids[4]);
- return ret;
-}
-
-static int av7110_start_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct av7110 *av7110 = demux->priv;
- int ret = 0;
-
- dprintk(4, "%p\n", av7110);
-
- if (!demux->dmx.frontend)
- return -EINVAL;
-
- if (feed->pid > 0x1fff)
- return -EINVAL;
-
- if (feed->type == DMX_TYPE_TS) {
- if ((feed->ts_type & TS_DECODER) &&
- (feed->pes_type < DMX_TS_PES_OTHER)) {
- switch (demux->dmx.frontend->source) {
- case DMX_MEMORY_FE:
- if (feed->ts_type & TS_DECODER)
- if (feed->pes_type < 2 &&
- !(demux->pids[0] & 0x8000) &&
- !(demux->pids[1] & 0x8000)) {
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
- ret = av7110_av_start_play(av7110,RP_AV);
- if (!ret)
- demux->playing = 1;
- }
- break;
- default:
- ret = dvb_feed_start_pid(feed);
- break;
- }
- } else if ((feed->ts_type & TS_PACKET) &&
- (demux->dmx.frontend->source != DMX_MEMORY_FE)) {
- ret = StartHWFilter(feed->filter);
- }
- }
-
- else if (feed->type == DMX_TYPE_SEC) {
- int i;
-
- for (i = 0; i < demux->filternum; i++) {
- if (demux->filter[i].state != DMX_STATE_READY)
- continue;
- if (demux->filter[i].type != DMX_TYPE_SEC)
- continue;
- if (demux->filter[i].filter.parent != &feed->feed.sec)
- continue;
- demux->filter[i].state = DMX_STATE_GO;
- if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
- ret = StartHWFilter(&demux->filter[i]);
- if (ret)
- break;
- }
- }
- }
-
- return ret;
-}
-
-
-static int av7110_stop_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct av7110 *av7110 = demux->priv;
- int i, rc, ret = 0;
- dprintk(4, "%p\n", av7110);
-
- if (feed->type == DMX_TYPE_TS) {
- if (feed->ts_type & TS_DECODER) {
- if (feed->pes_type >= DMX_TS_PES_OTHER ||
- !demux->pesfilter[feed->pes_type])
- return -EINVAL;
- demux->pids[feed->pes_type] |= 0x8000;
- demux->pesfilter[feed->pes_type] = NULL;
- }
- if (feed->ts_type & TS_DECODER &&
- feed->pes_type < DMX_TS_PES_OTHER) {
- ret = dvb_feed_stop_pid(feed);
- } else
- if ((feed->ts_type & TS_PACKET) &&
- (demux->dmx.frontend->source != DMX_MEMORY_FE))
- ret = StopHWFilter(feed->filter);
- }
-
- if (!ret && feed->type == DMX_TYPE_SEC) {
- for (i = 0; i<demux->filternum; i++) {
- if (demux->filter[i].state == DMX_STATE_GO &&
- demux->filter[i].filter.parent == &feed->feed.sec) {
- demux->filter[i].state = DMX_STATE_READY;
- if (demux->dmx.frontend->source != DMX_MEMORY_FE) {
- rc = StopHWFilter(&demux->filter[i]);
- if (!ret)
- ret = rc;
- /* keep going, stop as many filters as possible */
- }
- }
- }
- }
-
- return ret;
-}
-
-
-static void restart_feeds(struct av7110 *av7110)
-{
- struct dvb_demux *dvbdmx = &av7110->demux;
- struct dvb_demux_feed *feed;
- int mode;
- int i, j;
-
- dprintk(4, "%p\n", av7110);
-
- mode = av7110->playing;
- av7110->playing = 0;
- av7110->rec_mode = 0;
-
- for (i = 0; i < dvbdmx->feednum; i++) {
- feed = &dvbdmx->feed[i];
- if (feed->state == DMX_STATE_GO) {
- if (feed->type == DMX_TYPE_SEC) {
- for (j = 0; j < dvbdmx->filternum; j++) {
- if (dvbdmx->filter[j].type != DMX_TYPE_SEC)
- continue;
- if (dvbdmx->filter[j].filter.parent != &feed->feed.sec)
- continue;
- if (dvbdmx->filter[j].state == DMX_STATE_GO)
- dvbdmx->filter[j].state = DMX_STATE_READY;
- }
- }
- av7110_start_feed(feed);
- }
- }
-
- if (mode)
- av7110_av_start_play(av7110, mode);
-}
-
-static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
- uint64_t *stc, unsigned int *base)
-{
- int ret;
- u16 fwstc[4];
- u16 tag = ((COMTYPE_REQUEST << 8) + ReqSTC);
- struct dvb_demux *dvbdemux;
- struct av7110 *av7110;
-
- /* pointer casting paranoia... */
- BUG_ON(!demux);
- dvbdemux = (struct dvb_demux *) demux->priv;
- BUG_ON(!dvbdemux);
- av7110 = (struct av7110 *) dvbdemux->priv;
-
- dprintk(4, "%p\n", av7110);
-
- if (num != 0)
- return -EINVAL;
-
- ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4);
- if (ret) {
- printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__);
- return ret;
- }
- dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n",
- fwstc[0], fwstc[1], fwstc[2], fwstc[3]);
-
- *stc = (((uint64_t) ((fwstc[3] & 0x8000) >> 15)) << 32) |
- (((uint64_t) fwstc[1]) << 16) | ((uint64_t) fwstc[0]);
- *base = 1;
-
- dprintk(4, "stc = %lu\n", (unsigned long)*stc);
-
- return 0;
-}
-
-
-/******************************************************************************
- * SEC device file operations
- ******************************************************************************/
-
-
-static int av7110_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
-
- switch (tone) {
- case SEC_TONE_ON:
- return Set22K(av7110, 1);
-
- case SEC_TONE_OFF:
- return Set22K(av7110, 0);
-
- default:
- return -EINVAL;
- }
-}
-
-static int av7110_diseqc_send_master_cmd(struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd* cmd)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- return av7110_diseqc_send(av7110, cmd->msg_len, cmd->msg, -1);
-}
-
-static int av7110_diseqc_send_burst(struct dvb_frontend* fe,
- fe_sec_mini_cmd_t minicmd)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- return av7110_diseqc_send(av7110, 0, NULL, minicmd);
-}
-
-/* simplified code from budget-core.c */
-static int stop_ts_capture(struct av7110 *budget)
-{
- dprintk(2, "budget: %p\n", budget);
-
- if (--budget->feeding1)
- return budget->feeding1;
- saa7146_write(budget->dev, MC1, MASK_20); /* DMA3 off */
- SAA7146_IER_DISABLE(budget->dev, MASK_10);
- SAA7146_ISR_CLEAR(budget->dev, MASK_10);
- return 0;
-}
-
-static int start_ts_capture(struct av7110 *budget)
-{
- dprintk(2, "budget: %p\n", budget);
-
- if (budget->feeding1)
- return ++budget->feeding1;
- memset(budget->grabbing, 0x00, TS_HEIGHT * TS_WIDTH);
- budget->tsf = 0xff;
- budget->ttbp = 0;
- SAA7146_IER_ENABLE(budget->dev, MASK_10); /* VPE */
- saa7146_write(budget->dev, MC1, (MASK_04 | MASK_20)); /* DMA3 on */
- return ++budget->feeding1;
-}
-
-static int budget_start_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct av7110 *budget = (struct av7110 *) demux->priv;
- int status;
-
- dprintk(2, "av7110: %p\n", budget);
-
- spin_lock(&budget->feedlock1);
- feed->pusi_seen = 0; /* have a clean section start */
- status = start_ts_capture(budget);
- spin_unlock(&budget->feedlock1);
- return status;
-}
-
-static int budget_stop_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct av7110 *budget = (struct av7110 *) demux->priv;
- int status;
-
- dprintk(2, "budget: %p\n", budget);
-
- spin_lock(&budget->feedlock1);
- status = stop_ts_capture(budget);
- spin_unlock(&budget->feedlock1);
- return status;
-}
-
-static void vpeirq(unsigned long data)
-{
- struct av7110 *budget = (struct av7110 *) data;
- u8 *mem = (u8 *) (budget->grabbing);
- u32 olddma = budget->ttbp;
- u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
-
- if (!budgetpatch) {
- printk("av7110.c: vpeirq() called while budgetpatch disabled!"
- " check saa7146 IER register\n");
- BUG();
- }
- /* nearest lower position divisible by 188 */
- newdma -= newdma % 188;
-
- if (newdma >= TS_BUFLEN)
- return;
-
- budget->ttbp = newdma;
-
- if (!budget->feeding1 || (newdma == olddma))
- return;
-
-#if 0
- /* track rps1 activity */
- printk("vpeirq: %02x Event Counter 1 0x%04x\n",
- mem[olddma],
- saa7146_read(budget->dev, EC1R) & 0x3fff);
-#endif
-
- if (newdma > olddma)
- /* no wraparound, dump olddma..newdma */
- dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (newdma - olddma) / 188);
- else {
- /* wraparound, dump olddma..buflen and 0..newdma */
- dvb_dmx_swfilter_packets(&budget->demux1, mem + olddma, (TS_BUFLEN - olddma) / 188);
- dvb_dmx_swfilter_packets(&budget->demux1, mem, newdma / 188);
- }
-}
-
-static int av7110_register(struct av7110 *av7110)
-{
- int ret, i;
- struct dvb_demux *dvbdemux = &av7110->demux;
- struct dvb_demux *dvbdemux1 = &av7110->demux1;
-
- dprintk(4, "%p\n", av7110);
-
- if (av7110->registered)
- return -1;
-
- av7110->registered = 1;
-
- dvbdemux->priv = (void *) av7110;
-
- for (i = 0; i < 32; i++)
- av7110->handle2filter[i] = NULL;
-
- dvbdemux->filternum = 32;
- dvbdemux->feednum = 32;
- dvbdemux->start_feed = av7110_start_feed;
- dvbdemux->stop_feed = av7110_stop_feed;
- dvbdemux->write_to_decoder = av7110_write_to_decoder;
- dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
- DMX_MEMORY_BASED_FILTERING);
-
- dvb_dmx_init(&av7110->demux);
- av7110->demux.dmx.get_stc = dvb_get_stc;
-
- av7110->dmxdev.filternum = 32;
- av7110->dmxdev.demux = &dvbdemux->dmx;
- av7110->dmxdev.capabilities = 0;
-
- dvb_dmxdev_init(&av7110->dmxdev, &av7110->dvb_adapter);
-
- av7110->hw_frontend.source = DMX_FRONTEND_0;
-
- ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
-
- if (ret < 0)
- return ret;
-
- av7110->mem_frontend.source = DMX_MEMORY_FE;
-
- ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
-
- if (ret < 0)
- return ret;
-
- ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx,
- &av7110->hw_frontend);
- if (ret < 0)
- return ret;
-
- av7110_av_register(av7110);
- av7110_ca_register(av7110);
-
-#ifdef CONFIG_DVB_AV7110_OSD
- dvb_register_device(&av7110->dvb_adapter, &av7110->osd_dev,
- &dvbdev_osd, av7110, DVB_DEVICE_OSD);
-#endif
-
- dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net, &dvbdemux->dmx);
-
- if (budgetpatch) {
- /* initialize software demux1 without its own frontend
- * demux1 hardware is connected to frontend0 of demux0
- */
- dvbdemux1->priv = (void *) av7110;
-
- dvbdemux1->filternum = 256;
- dvbdemux1->feednum = 256;
- dvbdemux1->start_feed = budget_start_feed;
- dvbdemux1->stop_feed = budget_stop_feed;
- dvbdemux1->write_to_decoder = NULL;
-
- dvbdemux1->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
- DMX_MEMORY_BASED_FILTERING);
-
- dvb_dmx_init(&av7110->demux1);
-
- av7110->dmxdev1.filternum = 256;
- av7110->dmxdev1.demux = &dvbdemux1->dmx;
- av7110->dmxdev1.capabilities = 0;
-
- dvb_dmxdev_init(&av7110->dmxdev1, &av7110->dvb_adapter);
-
- dvb_net_init(&av7110->dvb_adapter, &av7110->dvb_net1, &dvbdemux1->dmx);
- printk("dvb-ttpci: additional demux1 for budget-patch registered\n");
- }
- return 0;
-}
-
-
-static void dvb_unregister(struct av7110 *av7110)
-{
- struct dvb_demux *dvbdemux = &av7110->demux;
- struct dvb_demux *dvbdemux1 = &av7110->demux1;
-
- dprintk(4, "%p\n", av7110);
-
- if (!av7110->registered)
- return;
-
- if (budgetpatch) {
- dvb_net_release(&av7110->dvb_net1);
- dvbdemux->dmx.close(&dvbdemux1->dmx);
- dvb_dmxdev_release(&av7110->dmxdev1);
- dvb_dmx_release(&av7110->demux1);
- }
-
- dvb_net_release(&av7110->dvb_net);
-
- dvbdemux->dmx.close(&dvbdemux->dmx);
- dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->hw_frontend);
- dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &av7110->mem_frontend);
-
- dvb_dmxdev_release(&av7110->dmxdev);
- dvb_dmx_release(&av7110->demux);
-
- if (av7110->fe != NULL)
- dvb_unregister_frontend(av7110->fe);
- dvb_unregister_device(av7110->osd_dev);
- av7110_av_unregister(av7110);
- av7110_ca_unregister(av7110);
-}
-
-
-/****************************************************************************
- * I2C client commands
- ****************************************************************************/
-
-int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val)
-{
- u8 msg[2] = { reg, val };
- struct i2c_msg msgs;
-
- msgs.flags = 0;
- msgs.addr = id / 2;
- msgs.len = 2;
- msgs.buf = msg;
- return i2c_transfer(&av7110->i2c_adap, &msgs, 1);
-}
-
-#if 0
-u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg)
-{
- u8 mm1[] = {0x00};
- u8 mm2[] = {0x00};
- struct i2c_msg msgs[2];
-
- msgs[0].flags = 0;
- msgs[1].flags = I2C_M_RD;
- msgs[0].addr = msgs[1].addr = id / 2;
- mm1[0] = reg;
- msgs[0].len = 1; msgs[1].len = 1;
- msgs[0].buf = mm1; msgs[1].buf = mm2;
- i2c_transfer(&av7110->i2c_adap, msgs, 2);
-
- return mm2[0];
-}
-#endif
-
-/****************************************************************************
- * INITIALIZATION
- ****************************************************************************/
-
-
-static int check_firmware(struct av7110* av7110)
-{
- u32 crc = 0, len = 0;
- unsigned char *ptr;
-
- /* check for firmware magic */
- ptr = av7110->bin_fw;
- if (ptr[0] != 'A' || ptr[1] != 'V' ||
- ptr[2] != 'F' || ptr[3] != 'W') {
- printk("dvb-ttpci: this is not an av7110 firmware\n");
- return -EINVAL;
- }
- ptr += 4;
-
- /* check dpram file */
- crc = ntohl(*(u32*) ptr);
- ptr += 4;
- len = ntohl(*(u32*) ptr);
- ptr += 4;
- if (len >= 512) {
- printk("dvb-ttpci: dpram file is way too big.\n");
- return -EINVAL;
- }
- if (crc != crc32_le(0, ptr, len)) {
- printk("dvb-ttpci: crc32 of dpram file does not match.\n");
- return -EINVAL;
- }
- av7110->bin_dpram = ptr;
- av7110->size_dpram = len;
- ptr += len;
-
- /* check root file */
- crc = ntohl(*(u32*) ptr);
- ptr += 4;
- len = ntohl(*(u32*) ptr);
- ptr += 4;
-
- if (len <= 200000 || len >= 300000 ||
- len > ((av7110->bin_fw + av7110->size_fw) - ptr)) {
- printk("dvb-ttpci: root file has strange size (%d). aborting.\n", len);
- return -EINVAL;
- }
- if( crc != crc32_le(0, ptr, len)) {
- printk("dvb-ttpci: crc32 of root file does not match.\n");
- return -EINVAL;
- }
- av7110->bin_root = ptr;
- av7110->size_root = len;
- return 0;
-}
-
-#ifdef CONFIG_DVB_AV7110_FIRMWARE_FILE
-#include "av7110_firm.h"
-static void put_firmware(struct av7110* av7110)
-{
- av7110->bin_fw = NULL;
-}
-
-static inline int get_firmware(struct av7110* av7110)
-{
- av7110->bin_fw = dvb_ttpci_fw;
- av7110->size_fw = sizeof(dvb_ttpci_fw);
- return check_firmware(av7110);
-}
-#else
-static void put_firmware(struct av7110* av7110)
-{
- vfree(av7110->bin_fw);
-}
-
-static int get_firmware(struct av7110* av7110)
-{
- int ret;
- const struct firmware *fw;
-
- /* request the av7110 firmware, this will block until someone uploads it */
- ret = request_firmware(&fw, "dvb-ttpci-01.fw", &av7110->dev->pci->dev);
- if (ret) {
- if (ret == -ENOENT) {
- printk(KERN_ERR "dvb-ttpci: could not load firmware,"
- " file not found: dvb-ttpci-01.fw\n");
- printk(KERN_ERR "dvb-ttpci: usually this should be in "
- "/usr/lib/hotplug/firmware or /lib/firmware\n");
- printk(KERN_ERR "dvb-ttpci: and can be downloaded from"
- " http://www.linuxtv.org/download/dvb/firmware/\n");
- } else
- printk(KERN_ERR "dvb-ttpci: cannot request firmware"
- " (error %i)\n", ret);
- return -EINVAL;
- }
-
- if (fw->size <= 200000) {
- printk("dvb-ttpci: this firmware is way too small.\n");
- release_firmware(fw);
- return -EINVAL;
- }
-
- /* check if the firmware is available */
- av7110->bin_fw = (unsigned char *) vmalloc(fw->size);
- if (NULL == av7110->bin_fw) {
- dprintk(1, "out of memory\n");
- release_firmware(fw);
- return -ENOMEM;
- }
-
- memcpy(av7110->bin_fw, fw->data, fw->size);
- av7110->size_fw = fw->size;
- if ((ret = check_firmware(av7110)))
- vfree(av7110->bin_fw);
-
- release_firmware(fw);
- return ret;
-}
-#endif
-
-
-static int alps_bsrv2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
- u8 pwr = 0;
- u8 buf[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
- u32 div = (params->frequency + 479500) / 125;
-
- if (params->frequency > 2000000) pwr = 3;
- else if (params->frequency > 1800000) pwr = 2;
- else if (params->frequency > 1600000) pwr = 1;
- else if (params->frequency > 1200000) pwr = 0;
- else if (params->frequency >= 1100000) pwr = 1;
- else pwr = 2;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = ((div & 0x18000) >> 10) | 0x95;
- buf[3] = (pwr << 6) | 0x30;
-
- // NOTE: since we're using a prescaler of 2, we set the
- // divisor frequency to 62.5kHz and divide by 125 above
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct ves1x93_config alps_bsrv2_config = {
- .demod_address = 0x08,
- .xin = 90100000UL,
- .invert_pwm = 0,
-};
-
-static int alps_tdbe2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct av7110* av7110 = fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (params->frequency + 35937500 + 31250) / 62500;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x85 | ((div >> 10) & 0x60);
- data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct ves1820_config alps_tdbe2_config = {
- .demod_address = 0x09,
- .xin = 57840000UL,
- .invert = 1,
- .selagc = VES1820_SELAGC_SIGNAMPERR,
-};
-
-
-
-
-static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct av7110* av7110 = fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = params->frequency / 125;
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x8e;
- data[3] = 0x00;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct tda8083_config grundig_29504_451_config = {
- .demod_address = 0x68,
-};
-
-
-
-static int philips_cd1516_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct av7110* av7110 = fe->dvb->priv;
- u32 div;
- u32 f = params->frequency;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (f + 36125000 + 31250) / 62500;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x8e;
- data[3] = (f < 174000000 ? 0xa1 : f < 470000000 ? 0x92 : 0x34);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct ves1820_config philips_cd1516_config = {
- .demod_address = 0x09,
- .xin = 57840000UL,
- .invert = 1,
- .selagc = VES1820_SELAGC_SIGNAMPERR,
-};
-
-
-
-static int alps_tdlb7_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct av7110* av7110 = fe->dvb->priv;
- u32 div, pwr;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (params->frequency + 36200000) / 166666;
-
- if (params->frequency <= 782000000)
- pwr = 1;
- else
- pwr = 2;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x85;
- data[3] = pwr << 6;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static int alps_tdlb7_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
-{
- struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
-
- return request_firmware(fw, name, &av7110->dev->pci->dev);
-}
-
-static struct sp8870_config alps_tdlb7_config = {
-
- .demod_address = 0x71,
- .request_firmware = alps_tdlb7_request_firmware,
-};
-
-
-static u8 nexusca_stv0297_inittab[] = {
- 0x80, 0x01,
- 0x80, 0x00,
- 0x81, 0x01,
- 0x81, 0x00,
- 0x00, 0x09,
- 0x01, 0x69,
- 0x03, 0x00,
- 0x04, 0x00,
- 0x07, 0x00,
- 0x08, 0x00,
- 0x20, 0x00,
- 0x21, 0x40,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x24, 0x40,
- 0x25, 0x88,
- 0x30, 0xff,
- 0x31, 0x00,
- 0x32, 0xff,
- 0x33, 0x00,
- 0x34, 0x50,
- 0x35, 0x7f,
- 0x36, 0x00,
- 0x37, 0x20,
- 0x38, 0x00,
- 0x40, 0x1c,
- 0x41, 0xff,
- 0x42, 0x29,
- 0x43, 0x00,
- 0x44, 0xff,
- 0x45, 0x00,
- 0x46, 0x00,
- 0x49, 0x04,
- 0x4a, 0x00,
- 0x4b, 0x7b,
- 0x52, 0x30,
- 0x55, 0xae,
- 0x56, 0x47,
- 0x57, 0xe1,
- 0x58, 0x3a,
- 0x5a, 0x1e,
- 0x5b, 0x34,
- 0x60, 0x00,
- 0x63, 0x00,
- 0x64, 0x00,
- 0x65, 0x00,
- 0x66, 0x00,
- 0x67, 0x00,
- 0x68, 0x00,
- 0x69, 0x00,
- 0x6a, 0x02,
- 0x6b, 0x00,
- 0x70, 0xff,
- 0x71, 0x00,
- 0x72, 0x00,
- 0x73, 0x00,
- 0x74, 0x0c,
- 0x80, 0x00,
- 0x81, 0x00,
- 0x82, 0x00,
- 0x83, 0x00,
- 0x84, 0x04,
- 0x85, 0x80,
- 0x86, 0x24,
- 0x87, 0x78,
- 0x88, 0x10,
- 0x89, 0x00,
- 0x90, 0x01,
- 0x91, 0x01,
- 0xa0, 0x04,
- 0xa1, 0x00,
- 0xa2, 0x00,
- 0xb0, 0x91,
- 0xb1, 0x0b,
- 0xc0, 0x53,
- 0xc1, 0x70,
- 0xc2, 0x12,
- 0xd0, 0x00,
- 0xd1, 0x00,
- 0xd2, 0x00,
- 0xd3, 0x00,
- 0xd4, 0x00,
- 0xd5, 0x00,
- 0xde, 0x00,
- 0xdf, 0x00,
- 0x61, 0x49,
- 0x62, 0x0b,
- 0x53, 0x08,
- 0x59, 0x08,
- 0xff, 0xff,
-};
-
-static int nexusca_stv0297_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct av7110* av7110 = fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x63, .flags = 0, .buf = data, .len = sizeof(data) };
- struct i2c_msg readmsg = { .addr = 0x63, .flags = I2C_M_RD, .buf = data, .len = 1 };
- int i;
-
- div = (params->frequency + 36150000 + 31250) / 62500;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0xce;
-
- if (params->frequency < 45000000)
- return -EINVAL;
- else if (params->frequency < 137000000)
- data[3] = 0x01;
- else if (params->frequency < 403000000)
- data[3] = 0x02;
- else if (params->frequency < 860000000)
- data[3] = 0x04;
- else
- return -EINVAL;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&av7110->i2c_adap, &msg, 1) != 1) {
- printk("nexusca: pll transfer failed!\n");
- return -EIO;
- }
-
- // wait for PLL lock
- for(i = 0; i < 20; i++) {
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&av7110->i2c_adap, &readmsg, 1) == 1)
- if (data[0] & 0x40) break;
- msleep(10);
- }
-
- return 0;
-}
-
-static struct stv0297_config nexusca_stv0297_config = {
-
- .demod_address = 0x1C,
- .inittab = nexusca_stv0297_inittab,
- .invert = 1,
- .stop_during_read = 1,
-};
-
-
-
-static int grundig_29504_401_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters *params)
-{
- struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
- u32 div;
- u8 cfg, cpump, band_select;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (36125000 + params->frequency) / 166666;
-
- cfg = 0x88;
-
- if (params->frequency < 175000000) cpump = 2;
- else if (params->frequency < 390000000) cpump = 1;
- else if (params->frequency < 470000000) cpump = 2;
- else if (params->frequency < 750000000) cpump = 1;
- else cpump = 3;
-
- if (params->frequency < 175000000) band_select = 0x0e;
- else if (params->frequency < 470000000) band_select = 0x05;
- else band_select = 0x03;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = ((div >> 10) & 0x60) | cfg;
- data[3] = (cpump << 6) | band_select;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) return -EIO;
- return 0;
-}
-
-static struct l64781_config grundig_29504_401_config = {
- .demod_address = 0x55,
-};
-
-
-
-static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
-{
- int ret = 0;
- int synced = (status & FE_HAS_LOCK) ? 1 : 0;
-
- av7110->fe_status = status;
-
- if (av7110->fe_synced == synced)
- return 0;
-
- if (av7110->playing)
- return 0;
-
- if (mutex_lock_interruptible(&av7110->pid_mutex))
- return -ERESTARTSYS;
-
- if (synced) {
- ret = SetPIDs(av7110, av7110->pids[DMX_PES_VIDEO],
- av7110->pids[DMX_PES_AUDIO],
- av7110->pids[DMX_PES_TELETEXT], 0,
- av7110->pids[DMX_PES_PCR]);
- if (!ret)
- ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
- } else {
- ret = SetPIDs(av7110, 0, 0, 0, 0, 0);
- if (!ret) {
- ret = av7110_fw_cmd(av7110, COMTYPE_PID_FILTER, FlushTSQueue, 0);
- if (!ret)
- ret = av7110_wait_msgstate(av7110, GPMQBusy);
- }
- }
-
- if (!ret)
- av7110->fe_synced = synced;
-
- mutex_unlock(&av7110->pid_mutex);
- return ret;
-}
-
-static int av7110_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret) {
- av7110->saved_fe_params = *params;
- ret = av7110->fe_set_frontend(fe, params);
- }
- return ret;
-}
-
-static int av7110_fe_init(struct dvb_frontend* fe)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret)
- ret = av7110->fe_init(fe);
- return ret;
-}
-
-static int av7110_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- /* call the real implementation */
- int ret = av7110->fe_read_status(fe, status);
- if (!ret)
- if (((*status ^ av7110->fe_status) & FE_HAS_LOCK) && (*status & FE_HAS_LOCK))
- ret = av7110_fe_lock_fix(av7110, *status);
- return ret;
-}
-
-static int av7110_fe_diseqc_reset_overload(struct dvb_frontend* fe)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret)
- ret = av7110->fe_diseqc_reset_overload(fe);
- return ret;
-}
-
-static int av7110_fe_diseqc_send_master_cmd(struct dvb_frontend* fe,
- struct dvb_diseqc_master_cmd* cmd)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret) {
- av7110->saved_master_cmd = *cmd;
- ret = av7110->fe_diseqc_send_master_cmd(fe, cmd);
- }
- return ret;
-}
-
-static int av7110_fe_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret) {
- av7110->saved_minicmd = minicmd;
- ret = av7110->fe_diseqc_send_burst(fe, minicmd);
- }
- return ret;
-}
-
-static int av7110_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret) {
- av7110->saved_tone = tone;
- ret = av7110->fe_set_tone(fe, tone);
- }
- return ret;
-}
-
-static int av7110_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret) {
- av7110->saved_voltage = voltage;
- ret = av7110->fe_set_voltage(fe, voltage);
- }
- return ret;
-}
-
-static int av7110_fe_dishnetwork_send_legacy_command(struct dvb_frontend* fe, unsigned long cmd)
-{
- struct av7110* av7110 = fe->dvb->priv;
-
- int ret = av7110_fe_lock_fix(av7110, 0);
- if (!ret)
- ret = av7110->fe_dishnetwork_send_legacy_command(fe, cmd);
- return ret;
-}
-
-static void dvb_s_recover(struct av7110* av7110)
-{
- av7110_fe_init(av7110->fe);
-
- av7110_fe_set_voltage(av7110->fe, av7110->saved_voltage);
- if (av7110->saved_master_cmd.msg_len) {
- msleep(20);
- av7110_fe_diseqc_send_master_cmd(av7110->fe, &av7110->saved_master_cmd);
- }
- msleep(20);
- av7110_fe_diseqc_send_burst(av7110->fe, av7110->saved_minicmd);
- msleep(20);
- av7110_fe_set_tone(av7110->fe, av7110->saved_tone);
-
- av7110_fe_set_frontend(av7110->fe, &av7110->saved_fe_params);
-}
-
-static u8 read_pwm(struct av7110* av7110)
-{
- u8 b = 0xff;
- u8 pwm;
- struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
- { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
-
- if ((i2c_transfer(&av7110->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
- pwm = 0x48;
-
- return pwm;
-}
-
-static int frontend_init(struct av7110 *av7110)
-{
- int ret;
-
- if (av7110->dev->pci->subsystem_vendor == 0x110a) {
- switch(av7110->dev->pci->subsystem_device) {
- case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??))
- av7110->fe = ves1820_attach(&philips_cd1516_config,
- &av7110->i2c_adap, read_pwm(av7110));
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
- }
- break;
- }
-
- } else if (av7110->dev->pci->subsystem_vendor == 0x13c2) {
- switch(av7110->dev->pci->subsystem_device) {
- case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X
- case 0x0003: // Hauppauge/TT WinTV Nexus-S Rev 2.X
- case 0x1002: // Hauppauge/TT WinTV DVB-S rev1.3SE
-
- // try the ALPS BSRV2 first of all
- av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
- av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
- av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
- av7110->fe->ops.set_tone = av7110_set_tone;
- av7110->recover = dvb_s_recover;
- break;
- }
-
- // try the ALPS BSRU6 now
- av7110->fe = stv0299_attach(&alps_bsru6_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
- av7110->fe->tuner_priv = &av7110->i2c_adap;
-
- av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
- av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
- av7110->fe->ops.set_tone = av7110_set_tone;
- av7110->recover = dvb_s_recover;
- break;
- }
-
- // Try the grundig 29504-451
- av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
- av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
- av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
- av7110->fe->ops.set_tone = av7110_set_tone;
- av7110->recover = dvb_s_recover;
- break;
- }
-
- /* Try DVB-C cards */
- switch(av7110->dev->pci->subsystem_device) {
- case 0x0000:
- /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */
- av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap,
- read_pwm(av7110));
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = philips_cd1516_tuner_set_params;
- }
- break;
- case 0x0003:
- /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */
- av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap,
- read_pwm(av7110));
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
- }
- break;
- }
- break;
-
- case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
-
- // ALPS TDLB7
- av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = alps_tdlb7_tuner_set_params;
- }
- break;
-
- case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
-
- av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
- }
- break;
-
- case 0x0004: // Galaxis DVB-S rev1.3
- /* ALPS BSRV2 */
- av7110->fe = ves1x93_attach(&alps_bsrv2_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
- av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
- av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
- av7110->fe->ops.set_tone = av7110_set_tone;
- av7110->recover = dvb_s_recover;
- }
- break;
-
- case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
- /* Grundig 29504-451 */
- av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
- av7110->fe->ops.diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
- av7110->fe->ops.diseqc_send_burst = av7110_diseqc_send_burst;
- av7110->fe->ops.set_tone = av7110_set_tone;
- av7110->recover = dvb_s_recover;
- }
- break;
-
- case 0x0008: // Hauppauge/TT DVB-T
-
- av7110->fe = l64781_attach(&grundig_29504_401_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
- }
- break;
-
- case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
-
- av7110->fe = stv0297_attach(&nexusca_stv0297_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = nexusca_stv0297_tuner_set_params;
-
- /* set TDA9819 into DVB mode */
- saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD)
- saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF)
-
- /* tuner on this needs a slower i2c bus speed */
- av7110->dev->i2c_bitrate = SAA7146_I2C_BUS_BIT_RATE_240;
- break;
- }
- break;
-
- case 0x000E: /* Hauppauge/TT Nexus-S rev 2.3 */
- /* ALPS BSBE1 */
- av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
- if (av7110->fe) {
- av7110->fe->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
- av7110->fe->tuner_priv = &av7110->i2c_adap;
-
- if (lnbp21_attach(av7110->fe, &av7110->i2c_adap, 0, 0)) {
- printk("dvb-ttpci: LNBP21 not found!\n");
- if (av7110->fe->ops.release)
- av7110->fe->ops.release(av7110->fe);
- av7110->fe = NULL;
- } else {
- av7110->fe->ops.dishnetwork_send_legacy_command = NULL;
- av7110->recover = dvb_s_recover;
- }
- }
- break;
- }
- }
-
- if (!av7110->fe) {
- /* FIXME: propagate the failure code from the lower layers */
- ret = -ENOMEM;
- printk("dvb-ttpci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
- av7110->dev->pci->vendor,
- av7110->dev->pci->device,
- av7110->dev->pci->subsystem_vendor,
- av7110->dev->pci->subsystem_device);
- } else {
- FE_FUNC_OVERRIDE(av7110->fe->ops.init, av7110->fe_init, av7110_fe_init);
- FE_FUNC_OVERRIDE(av7110->fe->ops.read_status, av7110->fe_read_status, av7110_fe_read_status);
- FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_reset_overload, av7110->fe_diseqc_reset_overload, av7110_fe_diseqc_reset_overload);
- FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_master_cmd, av7110->fe_diseqc_send_master_cmd, av7110_fe_diseqc_send_master_cmd);
- FE_FUNC_OVERRIDE(av7110->fe->ops.diseqc_send_burst, av7110->fe_diseqc_send_burst, av7110_fe_diseqc_send_burst);
- FE_FUNC_OVERRIDE(av7110->fe->ops.set_tone, av7110->fe_set_tone, av7110_fe_set_tone);
- FE_FUNC_OVERRIDE(av7110->fe->ops.set_voltage, av7110->fe_set_voltage, av7110_fe_set_voltage;)
- FE_FUNC_OVERRIDE(av7110->fe->ops.dishnetwork_send_legacy_command, av7110->fe_dishnetwork_send_legacy_command, av7110_fe_dishnetwork_send_legacy_command);
- FE_FUNC_OVERRIDE(av7110->fe->ops.set_frontend, av7110->fe_set_frontend, av7110_fe_set_frontend);
-
- ret = dvb_register_frontend(&av7110->dvb_adapter, av7110->fe);
- if (ret < 0) {
- printk("av7110: Frontend registration failed!\n");
- if (av7110->fe->ops.release)
- av7110->fe->ops.release(av7110->fe);
- av7110->fe = NULL;
- }
- }
- return ret;
-}
-
-/* Budgetpatch note:
- * Original hardware design by Roberto Deza:
- * There is a DVB_Wiki at
- * http://212.227.36.83/linuxtv/wiki/index.php/Main_Page
- * where is described this 'DVB TT Budget Patch', on Card Modding:
- * http://212.227.36.83/linuxtv/wiki/index.php/DVB_TT_Budget_Patch
- * On the short description there is also a link to a external file,
- * with more details:
- * http://perso.wanadoo.es/jesussolano/Ttf_tsc1.zip
- *
- * New software triggering design by Emard that works on
- * original Roberto Deza's hardware:
- *
- * rps1 code for budgetpatch will copy internal HS event to GPIO3 pin.
- * GPIO3 is in budget-patch hardware connectd to port B VSYNC
- * HS is an internal event of 7146, accessible with RPS
- * and temporarily raised high every n lines
- * (n in defined in the RPS_THRESH1 counter threshold)
- * I think HS is raised high on the beginning of the n-th line
- * and remains high until this n-th line that triggered
- * it is completely received. When the receiption of n-th line
- * ends, HS is lowered.
- *
- * To transmit data over DMA, 7146 needs changing state at
- * port B VSYNC pin. Any changing of port B VSYNC will
- * cause some DMA data transfer, with more or less packets loss.
- * It depends on the phase and frequency of VSYNC and
- * the way of 7146 is instructed to trigger on port B (defined
- * in DD1_INIT register, 3rd nibble from the right valid
- * numbers are 0-7, see datasheet)
- *
- * The correct triggering can minimize packet loss,
- * dvbtraffic should give this stable bandwidths:
- * 22k transponder = 33814 kbit/s
- * 27.5k transponder = 38045 kbit/s
- * by experiment it is found that the best results
- * (stable bandwidths and almost no packet loss)
- * are obtained using DD1_INIT triggering number 2
- * (Va at rising edge of VS Fa = HS x VS-failing forced toggle)
- * and a VSYNC phase that occurs in the middle of DMA transfer
- * (about byte 188*512=96256 in the DMA window).
- *
- * Phase of HS is still not clear to me how to control,
- * It just happens to be so. It can be seen if one enables
- * RPS_IRQ and print Event Counter 1 in vpeirq(). Every
- * time RPS_INTERRUPT is called, the Event Counter 1 will
- * increment. That's how the 7146 is programmed to do event
- * counting in this budget-patch.c
- * I *think* HPS setting has something to do with the phase
- * of HS but I cant be 100% sure in that.
- *
- * hardware debug note: a working budget card (including budget patch)
- * with vpeirq() interrupt setup in mode "0x90" (every 64K) will
- * generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
- * and that means 3*25=75 Hz of interrupt freqency, as seen by
- * watch cat /proc/interrupts
- *
- * If this frequency is 3x lower (and data received in the DMA
- * buffer don't start with 0x47, but in the middle of packets,
- * whose lengths appear to be like 188 292 188 104 etc.
- * this means VSYNC line is not connected in the hardware.
- * (check soldering pcb and pins)
- * The same behaviour of missing VSYNC can be duplicated on budget
- * cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
- */
-static int __devinit av7110_attach(struct saa7146_dev* dev,
- struct saa7146_pci_extension_data *pci_ext)
-{
- const int length = TS_WIDTH * TS_HEIGHT;
- struct pci_dev *pdev = dev->pci;
- struct av7110 *av7110;
- int ret, count = 0;
-
- dprintk(4, "dev: %p\n", dev);
-
- /* Set RPS_IRQ to 1 to track rps1 activity.
- * Enabling this won't send any interrupt to PC CPU.
- */
-#define RPS_IRQ 0
-
- if (budgetpatch == 1) {
- budgetpatch = 0;
- /* autodetect the presence of budget patch
- * this only works if saa7146 has been recently
- * reset with with MASK_31 to MC1
- *
- * will wait for VBI_B event (vertical blank at port B)
- * and will reset GPIO3 after VBI_B is detected.
- * (GPIO3 should be raised high by CPU to
- * test if GPIO3 will generate vertical blank signal
- * in budget patch GPIO3 is connected to VSYNC_B
- */
-
- /* RESET SAA7146 */
- saa7146_write(dev, MC1, MASK_31);
- /* autodetection success seems to be time-dependend after reset */
-
- /* Fix VSYNC level */
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- /* set vsync_b triggering */
- saa7146_write(dev, DD1_STREAM_B, 0);
- /* port B VSYNC at rising edge */
- saa7146_write(dev, DD1_INIT, 0x00000200);
- saa7146_write(dev, BRS_CTRL, 0x00000000); // VBI
- saa7146_write(dev, MC2,
- 1 * (MASK_08 | MASK_24) | // BRS control
- 0 * (MASK_09 | MASK_25) | // a
- 1 * (MASK_10 | MASK_26) | // b
- 0 * (MASK_06 | MASK_22) | // HPS_CTRL1
- 0 * (MASK_05 | MASK_21) | // HPS_CTRL2
- 0 * (MASK_01 | MASK_15) // DEBI
- );
-
- /* start writing RPS1 code from beginning */
- count = 0;
- /* Disable RPS1 */
- saa7146_write(dev, MC1, MASK_29);
- /* RPS1 timeout disable */
- saa7146_write(dev, RPS_TOV1, 0);
- WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_VBI_B));
- WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
- WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
- WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
-#if RPS_IRQ
- /* issue RPS1 interrupt to increment counter */
- WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
-#endif
- WRITE_RPS1(cpu_to_le32(CMD_STOP));
- /* Jump to begin of RPS program as safety measure (p37) */
- WRITE_RPS1(cpu_to_le32(CMD_JUMP));
- WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
-
-#if RPS_IRQ
- /* set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
- * use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
- * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
- */
- saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
- /* set event counter 1 treshold to maximum allowed value (rEC p55) */
- saa7146_write(dev, ECT1R, 0x3fff );
-#endif
- /* Set RPS1 Address register to point to RPS code (r108 p42) */
- saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
- /* Enable RPS1, (rFC p33) */
- saa7146_write(dev, MC1, (MASK_13 | MASK_29 ));
-
- mdelay(10);
- /* now send VSYNC_B to rps1 by rising GPIO3 */
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
- mdelay(10);
- /* if rps1 responded by lowering the GPIO3,
- * then we have budgetpatch hardware
- */
- if ((saa7146_read(dev, GPIO_CTRL) & 0x10000000) == 0) {
- budgetpatch = 1;
- printk("dvb-ttpci: BUDGET-PATCH DETECTED.\n");
- }
- /* Disable RPS1 */
- saa7146_write(dev, MC1, ( MASK_29 ));
-#if RPS_IRQ
- printk("dvb-ttpci: Event Counter 1 0x%04x\n", saa7146_read(dev, EC1R) & 0x3fff );
-#endif
- }
-
- /* prepare the av7110 device struct */
- av7110 = kzalloc(sizeof(struct av7110), GFP_KERNEL);
- if (!av7110) {
- dprintk(1, "out of memory\n");
- return -ENOMEM;
- }
-
- av7110->card_name = (char*) pci_ext->ext_priv;
- av7110->dev = dev;
- dev->ext_priv = av7110;
-
- ret = get_firmware(av7110);
- if (ret < 0)
- goto err_kfree_0;
-
- ret = dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name,
- THIS_MODULE, &dev->pci->dev);
- if (ret < 0)
- goto err_put_firmware_1;
-
- /* the Siemens DVB needs this if you want to have the i2c chips
- get recognized before the main driver is fully loaded */
- saa7146_write(dev, GPIO_CTRL, 0x500000);
-
-#ifdef I2C_ADAP_CLASS_TV_DIGITAL
- av7110->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
-#else
- av7110->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
-#endif
- strlcpy(av7110->i2c_adap.name, pci_ext->ext_priv, sizeof(av7110->i2c_adap.name));
-
- saa7146_i2c_adapter_prepare(dev, &av7110->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120); /* 275 kHz */
-
- ret = i2c_add_adapter(&av7110->i2c_adap);
- if (ret < 0)
- goto err_dvb_unregister_adapter_2;
-
- ttpci_eeprom_parse_mac(&av7110->i2c_adap,
- av7110->dvb_adapter.proposed_mac);
- ret = -ENOMEM;
-
- if (budgetpatch) {
- spin_lock_init(&av7110->feedlock1);
- av7110->grabbing = saa7146_vmalloc_build_pgtable(pdev, length,
- &av7110->pt);
- if (!av7110->grabbing)
- goto err_i2c_del_3;
-
- saa7146_write(dev, PCI_BT_V1, 0x1c1f101f);
- saa7146_write(dev, BCS_CTRL, 0x80400040);
- /* set dd1 stream a & b */
- saa7146_write(dev, DD1_STREAM_B, 0x00000000);
- saa7146_write(dev, DD1_INIT, 0x03000200);
- saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
- saa7146_write(dev, BRS_CTRL, 0x60000000);
- saa7146_write(dev, BASE_ODD3, 0);
- saa7146_write(dev, BASE_EVEN3, 0);
- saa7146_write(dev, PROT_ADDR3, TS_WIDTH * TS_HEIGHT);
- saa7146_write(dev, BASE_PAGE3, av7110->pt.dma | ME1 | 0x90);
-
- saa7146_write(dev, PITCH3, TS_WIDTH);
- saa7146_write(dev, NUM_LINE_BYTE3, (TS_HEIGHT << 16) | TS_WIDTH);
-
- /* upload all */
- saa7146_write(dev, MC2, 0x077c077c);
- saa7146_write(dev, GPIO_CTRL, 0x000000);
-#if RPS_IRQ
- /* set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
- * use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
- * use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
- */
- saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
- /* set event counter 1 treshold to maximum allowed value (rEC p55) */
- saa7146_write(dev, ECT1R, 0x3fff );
-#endif
- /* Setup BUDGETPATCH MAIN RPS1 "program" (p35) */
- count = 0;
-
- /* Wait Source Line Counter Threshold (p36) */
- WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS));
- /* Set GPIO3=1 (p42) */
- WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
- WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
- WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTHI<<24));
-#if RPS_IRQ
- /* issue RPS1 interrupt */
- WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
-#endif
- /* Wait reset Source Line Counter Threshold (p36) */
- WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS));
- /* Set GPIO3=0 (p42) */
- WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
- WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
- WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
-#if RPS_IRQ
- /* issue RPS1 interrupt */
- WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
-#endif
- /* Jump to begin of RPS program (p37) */
- WRITE_RPS1(cpu_to_le32(CMD_JUMP));
- WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
-
- /* Fix VSYNC level */
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- /* Set RPS1 Address register to point to RPS code (r108 p42) */
- saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
- /* Set Source Line Counter Threshold, using BRS (rCC p43)
- * It generates HS event every TS_HEIGHT lines
- * this is related to TS_WIDTH set in register
- * NUM_LINE_BYTE3. If NUM_LINE_BYTE low 16 bits
- * are set to TS_WIDTH bytes (TS_WIDTH=2*188),
- * then RPS_THRESH1 should be set to trigger
- * every TS_HEIGHT (512) lines.
- */
- saa7146_write(dev, RPS_THRESH1, (TS_HEIGHT*1) | MASK_12 );
-
- /* Enable RPS1 (rFC p33) */
- saa7146_write(dev, MC1, (MASK_13 | MASK_29));
-
- /* end of budgetpatch register initialization */
- tasklet_init (&av7110->vpe_tasklet, vpeirq, (unsigned long) av7110);
- } else {
- saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
- saa7146_write(dev, BCS_CTRL, 0x80400040);
-
- /* set dd1 stream a & b */
- saa7146_write(dev, DD1_STREAM_B, 0x00000000);
- saa7146_write(dev, DD1_INIT, 0x03000000);
- saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
-
- /* upload all */
- saa7146_write(dev, MC2, 0x077c077c);
- saa7146_write(dev, GPIO_CTRL, 0x000000);
- }
-
- tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
- tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110);
-
- mutex_init(&av7110->pid_mutex);
-
- /* locks for data transfers from/to AV7110 */
- spin_lock_init(&av7110->debilock);
- mutex_init(&av7110->dcomlock);
- av7110->debitype = -1;
-
- /* default OSD window */
- av7110->osdwin = 1;
- mutex_init(&av7110->osd_mutex);
-
- /* TV standard */
- av7110->vidmode = tv_standard == 1 ? VIDEO_MODE_NTSC : VIDEO_MODE_PAL;
-
- /* ARM "watchdog" */
- init_waitqueue_head(&av7110->arm_wait);
- av7110->arm_thread = NULL;
-
- /* allocate and init buffers */
- av7110->debi_virt = pci_alloc_consistent(pdev, 8192, &av7110->debi_bus);
- if (!av7110->debi_virt)
- goto err_saa71466_vfree_4;
-
-
- av7110->iobuf = vmalloc(AVOUTLEN+AOUTLEN+BMPLEN+4*IPACKS);
- if (!av7110->iobuf)
- goto err_pci_free_5;
-
- ret = av7110_av_init(av7110);
- if (ret < 0)
- goto err_iobuf_vfree_6;
-
- /* init BMP buffer */
- av7110->bmpbuf = av7110->iobuf+AVOUTLEN+AOUTLEN;
- init_waitqueue_head(&av7110->bmpq);
-
- ret = av7110_ca_init(av7110);
- if (ret < 0)
- goto err_av7110_av_exit_7;
-
- /* load firmware into AV7110 cards */
- ret = av7110_bootarm(av7110);
- if (ret < 0)
- goto err_av7110_ca_exit_8;
-
- ret = av7110_firmversion(av7110);
- if (ret < 0)
- goto err_stop_arm_9;
-
- if (FW_VERSION(av7110->arm_app)<0x2501)
- printk ("dvb-ttpci: Warning, firmware version 0x%04x is too old. "
- "System might be unstable!\n", FW_VERSION(av7110->arm_app));
-
- ret = kernel_thread(arm_thread, (void *) av7110, 0);
- if (ret < 0)
- goto err_stop_arm_9;
-
- /* set initial volume in mixer struct */
- av7110->mixer.volume_left = volume;
- av7110->mixer.volume_right = volume;
-
- init_av7110_av(av7110);
-
- ret = av7110_register(av7110);
- if (ret < 0)
- goto err_arm_thread_stop_10;
-
- /* special case DVB-C: these cards have an analog tuner
- plus need some special handling, so we have separate
- saa7146_ext_vv data for these... */
- ret = av7110_init_v4l(av7110);
- if (ret < 0)
- goto err_av7110_unregister_11;
-
- av7110->dvb_adapter.priv = av7110;
- ret = frontend_init(av7110);
- if (ret < 0)
- goto err_av7110_exit_v4l_12;
-
-#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
- av7110_ir_init(av7110);
-#endif
- printk(KERN_INFO "dvb-ttpci: found av7110-%d.\n", av7110_num);
- av7110_num++;
-out:
- return ret;
-
-err_av7110_exit_v4l_12:
- av7110_exit_v4l(av7110);
-err_av7110_unregister_11:
- dvb_unregister(av7110);
-err_arm_thread_stop_10:
- av7110_arm_sync(av7110);
-err_stop_arm_9:
- /* Nothing to do. Rejoice. */
-err_av7110_ca_exit_8:
- av7110_ca_exit(av7110);
-err_av7110_av_exit_7:
- av7110_av_exit(av7110);
-err_iobuf_vfree_6:
- vfree(av7110->iobuf);
-err_pci_free_5:
- pci_free_consistent(pdev, 8192, av7110->debi_virt, av7110->debi_bus);
-err_saa71466_vfree_4:
- if (!av7110->grabbing)
- saa7146_pgtable_free(pdev, &av7110->pt);
-err_i2c_del_3:
- i2c_del_adapter(&av7110->i2c_adap);
-err_dvb_unregister_adapter_2:
- dvb_unregister_adapter(&av7110->dvb_adapter);
-err_put_firmware_1:
- put_firmware(av7110);
-err_kfree_0:
- kfree(av7110);
- goto out;
-}
-
-static int __devexit av7110_detach(struct saa7146_dev* saa)
-{
- struct av7110 *av7110 = saa->ext_priv;
- dprintk(4, "%p\n", av7110);
-
-#if defined(CONFIG_INPUT_EVDEV) || defined(CONFIG_INPUT_EVDEV_MODULE)
- av7110_ir_exit(av7110);
-#endif
- if (budgetpatch) {
- /* Disable RPS1 */
- saa7146_write(saa, MC1, MASK_29);
- /* VSYNC LOW (inactive) */
- saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
- saa7146_write(saa, MC1, MASK_20); /* DMA3 off */
- SAA7146_IER_DISABLE(saa, MASK_10);
- SAA7146_ISR_CLEAR(saa, MASK_10);
- msleep(50);
- tasklet_kill(&av7110->vpe_tasklet);
- saa7146_pgtable_free(saa->pci, &av7110->pt);
- }
- av7110_exit_v4l(av7110);
-
- av7110_arm_sync(av7110);
-
- tasklet_kill(&av7110->debi_tasklet);
- tasklet_kill(&av7110->gpio_tasklet);
-
- dvb_unregister(av7110);
-
- SAA7146_IER_DISABLE(saa, MASK_19 | MASK_03);
- SAA7146_ISR_CLEAR(saa, MASK_19 | MASK_03);
-
- av7110_ca_exit(av7110);
- av7110_av_exit(av7110);
-
- vfree(av7110->iobuf);
- pci_free_consistent(saa->pci, 8192, av7110->debi_virt,
- av7110->debi_bus);
-
- i2c_del_adapter(&av7110->i2c_adap);
-
- dvb_unregister_adapter (&av7110->dvb_adapter);
-
- av7110_num--;
-
- put_firmware(av7110);
-
- kfree(av7110);
-
- saa->ext_priv = NULL;
-
- return 0;
-}
-
-
-static void av7110_irq(struct saa7146_dev* dev, u32 *isr)
-{
- struct av7110 *av7110 = dev->ext_priv;
-
- //print_time("av7110_irq");
-
- /* Note: Don't try to handle the DEBI error irq (MASK_18), in
- * intel mode the timeout is asserted all the time...
- */
-
- if (*isr & MASK_19) {
- //printk("av7110_irq: DEBI\n");
- /* Note 1: The DEBI irq is level triggered: We must enable it
- * only after we started a DMA xfer, and disable it here
- * immediately, or it will be signalled all the time while
- * DEBI is idle.
- * Note 2: You would think that an irq which is masked is
- * not signalled by the hardware. Not so for the SAA7146:
- * An irq is signalled as long as the corresponding bit
- * in the ISR is set, and disabling irqs just prevents the
- * hardware from setting the ISR bit. This means a) that we
- * must clear the ISR *after* disabling the irq (which is why
- * we must do it here even though saa7146_core did it already),
- * and b) that if we were to disable an edge triggered irq
- * (like the gpio irqs sadly are) temporarily we would likely
- * loose some. This sucks :-(
- */
- SAA7146_IER_DISABLE(av7110->dev, MASK_19);
- SAA7146_ISR_CLEAR(av7110->dev, MASK_19);
- tasklet_schedule(&av7110->debi_tasklet);
- }
-
- if (*isr & MASK_03) {
- //printk("av7110_irq: GPIO\n");
- tasklet_schedule(&av7110->gpio_tasklet);
- }
-
- if ((*isr & MASK_10) && budgetpatch)
- tasklet_schedule(&av7110->vpe_tasklet);
-}
-
-
-static struct saa7146_extension av7110_extension;
-
-#define MAKE_AV7110_INFO(x_var,x_name) \
-static struct saa7146_pci_extension_data x_var = { \
- .ext_priv = x_name, \
- .ext = &av7110_extension }
-
-MAKE_AV7110_INFO(tts_1_X_fsc,"Technotrend/Hauppauge WinTV DVB-S rev1.X or Fujitsu Siemens DVB-C");
-MAKE_AV7110_INFO(ttt_1_X, "Technotrend/Hauppauge WinTV DVB-T rev1.X");
-MAKE_AV7110_INFO(ttc_1_X, "Technotrend/Hauppauge WinTV Nexus-CA rev1.X");
-MAKE_AV7110_INFO(ttc_2_X, "Technotrend/Hauppauge WinTV DVB-C rev2.X");
-MAKE_AV7110_INFO(tts_2_X, "Technotrend/Hauppauge WinTV Nexus-S rev2.X");
-MAKE_AV7110_INFO(tts_2_3, "Technotrend/Hauppauge WinTV Nexus-S rev2.3");
-MAKE_AV7110_INFO(tts_1_3se, "Technotrend/Hauppauge WinTV DVB-S rev1.3 SE");
-MAKE_AV7110_INFO(ttt, "Technotrend/Hauppauge DVB-T");
-MAKE_AV7110_INFO(fsc, "Fujitsu Siemens DVB-C");
-MAKE_AV7110_INFO(fss, "Fujitsu Siemens DVB-S rev1.6");
-MAKE_AV7110_INFO(gxs_1_3, "Galaxis DVB-S rev1.3");
-
-static struct pci_device_id pci_tbl[] = {
- MAKE_EXTENSION_PCI(fsc, 0x110a, 0x0000),
- MAKE_EXTENSION_PCI(tts_1_X_fsc, 0x13c2, 0x0000),
- MAKE_EXTENSION_PCI(ttt_1_X, 0x13c2, 0x0001),
- MAKE_EXTENSION_PCI(ttc_2_X, 0x13c2, 0x0002),
- MAKE_EXTENSION_PCI(tts_2_X, 0x13c2, 0x0003),
- MAKE_EXTENSION_PCI(gxs_1_3, 0x13c2, 0x0004),
- MAKE_EXTENSION_PCI(fss, 0x13c2, 0x0006),
- MAKE_EXTENSION_PCI(ttt, 0x13c2, 0x0008),
- MAKE_EXTENSION_PCI(ttc_1_X, 0x13c2, 0x000a),
- MAKE_EXTENSION_PCI(tts_2_3, 0x13c2, 0x000e),
- MAKE_EXTENSION_PCI(tts_1_3se, 0x13c2, 0x1002),
-
-/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0005), UNDEFINED CARD */ // Technisat SkyStar1
-/* MAKE_EXTENSION_PCI(???, 0x13c2, 0x0009), UNDEFINED CARD */ // TT/Hauppauge WinTV Nexus-CA v????
-
- {
- .vendor = 0,
- }
-};
-
-MODULE_DEVICE_TABLE(pci, pci_tbl);
-
-
-static struct saa7146_extension av7110_extension = {
- .name = "dvb\0",
- .flags = SAA7146_I2C_SHORT_DELAY,
-
- .module = THIS_MODULE,
- .pci_tbl = &pci_tbl[0],
- .attach = av7110_attach,
- .detach = __devexit_p(av7110_detach),
-
- .irq_mask = MASK_19 | MASK_03 | MASK_10,
- .irq_func = av7110_irq,
-};
-
-
-static int __init av7110_init(void)
-{
- int retval;
- retval = saa7146_register_extension(&av7110_extension);
- return retval;
-}
-
-
-static void __exit av7110_exit(void)
-{
- saa7146_unregister_extension(&av7110_extension);
-}
-
-module_init(av7110_init);
-module_exit(av7110_exit);
-
-MODULE_DESCRIPTION("driver for the SAA7146 based AV110 PCI DVB cards by "
- "Siemens, Technotrend, Hauppauge");
-MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h
deleted file mode 100644
index 9c79696da08..00000000000
--- a/drivers/media/dvb/ttpci/av7110.h
+++ /dev/null
@@ -1,291 +0,0 @@
-#ifndef _AV7110_H_
-#define _AV7110_H_
-
-#include <linux/interrupt.h>
-#include <linux/socket.h>
-#include <linux/netdevice.h>
-#include <linux/i2c.h>
-
-#include <linux/dvb/video.h>
-#include <linux/dvb/audio.h>
-#include <linux/dvb/dmx.h>
-#include <linux/dvb/ca.h>
-#include <linux/dvb/osd.h>
-#include <linux/dvb/net.h>
-#include <linux/mutex.h>
-
-#include "dvbdev.h"
-#include "demux.h"
-#include "dvb_demux.h"
-#include "dmxdev.h"
-#include "dvb_filter.h"
-#include "dvb_net.h"
-#include "dvb_ringbuffer.h"
-#include "dvb_frontend.h"
-#include "ves1820.h"
-#include "ves1x93.h"
-#include "stv0299.h"
-#include "tda8083.h"
-#include "sp8870.h"
-#include "stv0297.h"
-#include "l64781.h"
-
-#include <media/saa7146_vv.h>
-
-
-#define ANALOG_TUNER_VES1820 1
-#define ANALOG_TUNER_STV0297 2
-#define ANALOG_TUNER_VBI 0x100
-
-extern int av7110_debug;
-
-#define dprintk(level,args...) \
- do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __FUNCTION__); printk(args); } } while (0)
-
-#define MAXFILT 32
-
-enum {AV_PES_STREAM, PS_STREAM, TS_STREAM, PES_STREAM};
-
-struct av7110_p2t {
- u8 pes[TS_SIZE];
- u8 counter;
- long int pos;
- int frags;
- struct dvb_demux_feed *feed;
-};
-
-/* video MPEG decoder events: */
-/* (code copied from dvb_frontend.c, should maybe be factored out...) */
-#define MAX_VIDEO_EVENT 8
-struct dvb_video_events {
- struct video_event events[MAX_VIDEO_EVENT];
- int eventw;
- int eventr;
- int overflow;
- wait_queue_head_t wait_queue;
- spinlock_t lock;
-};
-
-
-/* place to store all the necessary device information */
-struct av7110 {
-
- /* devices */
-
- struct dvb_device dvb_dev;
- struct dvb_net dvb_net;
-
- struct video_device *v4l_dev;
- struct video_device *vbi_dev;
-
- struct saa7146_dev *dev;
-
- struct i2c_adapter i2c_adap;
-
- char *card_name;
-
- /* support for analog module of dvb-c */
- int analog_tuner_flags;
- int current_input;
- u32 current_freq;
-
- struct tasklet_struct debi_tasklet;
- struct tasklet_struct gpio_tasklet;
-
- int adac_type; /* audio DAC type */
-#define DVB_ADAC_TI 0
-#define DVB_ADAC_CRYSTAL 1
-#define DVB_ADAC_MSP34x0 2
-#define DVB_ADAC_MSP34x5 3
-#define DVB_ADAC_NONE -1
-
-
- /* buffers */
-
- void *iobuf; /* memory for all buffers */
- struct dvb_ringbuffer avout; /* buffer for video or A/V mux */
-#define AVOUTLEN (128*1024)
- struct dvb_ringbuffer aout; /* buffer for audio */
-#define AOUTLEN (64*1024)
- void *bmpbuf;
-#define BMPLEN (8*32768+1024)
-
- /* bitmap buffers and states */
-
- int bmpp;
- int bmplen;
- volatile int bmp_state;
-#define BMP_NONE 0
-#define BMP_LOADING 1
-#define BMP_LOADED 2
- wait_queue_head_t bmpq;
-
-
- /* DEBI and polled command interface */
-
- spinlock_t debilock;
- struct mutex dcomlock;
- volatile int debitype;
- volatile int debilen;
-
-
- /* Recording and playback flags */
-
- int rec_mode;
- int playing;
-#define RP_NONE 0
-#define RP_VIDEO 1
-#define RP_AUDIO 2
-#define RP_AV 3
-
-
- /* OSD */
-
- int osdwin; /* currently active window */
- u16 osdbpp[8];
- struct mutex osd_mutex;
-
- /* CA */
-
- ca_slot_info_t ci_slot[2];
-
- int vidmode;
- struct dmxdev dmxdev;
- struct dvb_demux demux;
-
- struct dmx_frontend hw_frontend;
- struct dmx_frontend mem_frontend;
-
- /* for budget mode demux1 */
- struct dmxdev dmxdev1;
- struct dvb_demux demux1;
- struct dvb_net dvb_net1;
- spinlock_t feedlock1;
- int feeding1;
- u8 tsf;
- u32 ttbp;
- unsigned char *grabbing;
- struct saa7146_pgtable pt;
- struct tasklet_struct vpe_tasklet;
-
- int fe_synced;
- struct mutex pid_mutex;
-
- int video_blank;
- struct video_status videostate;
- int display_ar;
- int trickmode;
-#define TRICK_NONE 0
-#define TRICK_FAST 1
-#define TRICK_SLOW 2
-#define TRICK_FREEZE 3
- struct audio_status audiostate;
-
- struct dvb_demux_filter *handle2filter[32];
- struct av7110_p2t p2t_filter[MAXFILT];
- struct dvb_filter_pes2ts p2t[2];
- struct ipack ipack[2];
- u8 *kbuf[2];
-
- int sinfo;
- int feeding;
-
- int arm_errors;
- int registered;
-
-
- /* AV711X */
-
- u32 arm_fw;
- u32 arm_rtsl;
- u32 arm_vid;
- u32 arm_app;
- u32 avtype;
- int arm_ready;
- struct task_struct *arm_thread;
- wait_queue_head_t arm_wait;
- u16 arm_loops;
- int arm_rmmod;
-
- void *debi_virt;
- dma_addr_t debi_bus;
-
- u16 pids[DMX_PES_OTHER];
-
- struct dvb_ringbuffer ci_rbuffer;
- struct dvb_ringbuffer ci_wbuffer;
-
- struct audio_mixer mixer;
-
- struct dvb_adapter dvb_adapter;
- struct dvb_device *video_dev;
- struct dvb_device *audio_dev;
- struct dvb_device *ca_dev;
- struct dvb_device *osd_dev;
-
- struct dvb_video_events video_events;
- video_size_t video_size;
-
- u16 wssMode;
- u16 wssData;
-
- u32 ir_config;
- u32 ir_command;
- void (*ir_handler)(struct av7110 *av7110, u32 ircom);
- struct tasklet_struct ir_tasklet;
-
- /* firmware stuff */
- unsigned char *bin_fw;
- unsigned long size_fw;
-
- unsigned char *bin_dpram;
- unsigned long size_dpram;
-
- unsigned char *bin_root;
- unsigned long size_root;
-
- struct dvb_frontend* fe;
- fe_status_t fe_status;
-
- /* crash recovery */
- void (*recover)(struct av7110* av7110);
- struct dvb_frontend_parameters saved_fe_params;
- fe_sec_voltage_t saved_voltage;
- fe_sec_tone_mode_t saved_tone;
- struct dvb_diseqc_master_cmd saved_master_cmd;
- fe_sec_mini_cmd_t saved_minicmd;
-
- int (*fe_init)(struct dvb_frontend* fe);
- int (*fe_read_status)(struct dvb_frontend* fe, fe_status_t* status);
- int (*fe_diseqc_reset_overload)(struct dvb_frontend* fe);
- int (*fe_diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
- int (*fe_diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
- int (*fe_set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
- int (*fe_set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
- int (*fe_dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
- int (*fe_set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
-};
-
-
-extern int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
- u16 subpid, u16 pcrpid);
-
-extern int av7110_ir_init(struct av7110 *av7110);
-extern void av7110_ir_exit(struct av7110 *av7110);
-
-/* msp3400 i2c subaddresses */
-#define MSP_WR_DEM 0x10
-#define MSP_RD_DEM 0x11
-#define MSP_WR_DSP 0x12
-#define MSP_RD_DSP 0x13
-
-extern int i2c_writereg(struct av7110 *av7110, u8 id, u8 reg, u8 val);
-extern u8 i2c_readreg(struct av7110 *av7110, u8 id, u8 reg);
-extern int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val);
-
-
-extern int av7110_init_analog_module(struct av7110 *av7110);
-extern int av7110_init_v4l(struct av7110 *av7110);
-extern int av7110_exit_v4l(struct av7110 *av7110);
-
-#endif /* _AV7110_H_ */
diff --git a/drivers/media/dvb/ttpci/av7110_av.c b/drivers/media/dvb/ttpci/av7110_av.c
deleted file mode 100644
index 0f3a044aeb1..00000000000
--- a/drivers/media/dvb/ttpci/av7110_av.c
+++ /dev/null
@@ -1,1526 +0,0 @@
-/*
- * av7110_av.c: audio and video MPEG decoder stuff
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * originally based on code by:
- * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/byteorder/swabb.h>
-#include <linux/smp_lock.h>
-#include <linux/fs.h>
-
-#include "av7110.h"
-#include "av7110_hw.h"
-#include "av7110_av.h"
-#include "av7110_ipack.h"
-
-/* MPEG-2 (ISO 13818 / H.222.0) stream types */
-#define PROG_STREAM_MAP 0xBC
-#define PRIVATE_STREAM1 0xBD
-#define PADDING_STREAM 0xBE
-#define PRIVATE_STREAM2 0xBF
-#define AUDIO_STREAM_S 0xC0
-#define AUDIO_STREAM_E 0xDF
-#define VIDEO_STREAM_S 0xE0
-#define VIDEO_STREAM_E 0xEF
-#define ECM_STREAM 0xF0
-#define EMM_STREAM 0xF1
-#define DSM_CC_STREAM 0xF2
-#define ISO13522_STREAM 0xF3
-#define PROG_STREAM_DIR 0xFF
-
-#define PTS_DTS_FLAGS 0xC0
-
-//pts_dts flags
-#define PTS_ONLY 0x80
-#define PTS_DTS 0xC0
-#define TS_SIZE 188
-#define TRANS_ERROR 0x80
-#define PAY_START 0x40
-#define TRANS_PRIO 0x20
-#define PID_MASK_HI 0x1F
-//flags
-#define TRANS_SCRMBL1 0x80
-#define TRANS_SCRMBL2 0x40
-#define ADAPT_FIELD 0x20
-#define PAYLOAD 0x10
-#define COUNT_MASK 0x0F
-
-// adaptation flags
-#define DISCON_IND 0x80
-#define RAND_ACC_IND 0x40
-#define ES_PRI_IND 0x20
-#define PCR_FLAG 0x10
-#define OPCR_FLAG 0x08
-#define SPLICE_FLAG 0x04
-#define TRANS_PRIV 0x02
-#define ADAP_EXT_FLAG 0x01
-
-// adaptation extension flags
-#define LTW_FLAG 0x80
-#define PIECE_RATE 0x40
-#define SEAM_SPLICE 0x20
-
-
-static void p_to_t(u8 const *buf, long int length, u16 pid,
- u8 *counter, struct dvb_demux_feed *feed);
-
-
-int av7110_record_cb(struct dvb_filter_pes2ts *p2t, u8 *buf, size_t len)
-{
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) p2t->priv;
-
- if (!(dvbdmxfeed->ts_type & TS_PACKET))
- return 0;
- if (buf[3] == 0xe0) // video PES do not have a length in TS
- buf[4] = buf[5] = 0;
- if (dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)
- return dvbdmxfeed->cb.ts(buf, len, NULL, 0,
- &dvbdmxfeed->feed.ts, DMX_OK);
- else
- return dvb_filter_pes2ts(p2t, buf, len, 1);
-}
-
-static int dvb_filter_pes2ts_cb(void *priv, unsigned char *data)
-{
- struct dvb_demux_feed *dvbdmxfeed = (struct dvb_demux_feed *) priv;
-
- dvbdmxfeed->cb.ts(data, 188, NULL, 0,
- &dvbdmxfeed->feed.ts, DMX_OK);
- return 0;
-}
-
-int av7110_av_start_record(struct av7110 *av7110, int av,
- struct dvb_demux_feed *dvbdmxfeed)
-{
- int ret = 0;
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
-
- dprintk(2, "av7110:%p, , dvb_demux_feed:%p\n", av7110, dvbdmxfeed);
-
- if (av7110->playing || (av7110->rec_mode & av))
- return -EBUSY;
- av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
- dvbdmx->recording = 1;
- av7110->rec_mode |= av;
-
- switch (av7110->rec_mode) {
- case RP_AUDIO:
- dvb_filter_pes2ts_init(&av7110->p2t[0],
- dvbdmx->pesfilter[0]->pid,
- dvb_filter_pes2ts_cb,
- (void *) dvbdmx->pesfilter[0]);
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0);
- break;
-
- case RP_VIDEO:
- dvb_filter_pes2ts_init(&av7110->p2t[1],
- dvbdmx->pesfilter[1]->pid,
- dvb_filter_pes2ts_cb,
- (void *) dvbdmx->pesfilter[1]);
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0);
- break;
-
- case RP_AV:
- dvb_filter_pes2ts_init(&av7110->p2t[0],
- dvbdmx->pesfilter[0]->pid,
- dvb_filter_pes2ts_cb,
- (void *) dvbdmx->pesfilter[0]);
- dvb_filter_pes2ts_init(&av7110->p2t[1],
- dvbdmx->pesfilter[1]->pid,
- dvb_filter_pes2ts_cb,
- (void *) dvbdmx->pesfilter[1]);
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AV_PES, 0);
- break;
- }
- return ret;
-}
-
-int av7110_av_start_play(struct av7110 *av7110, int av)
-{
- int ret = 0;
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (av7110->rec_mode)
- return -EBUSY;
- if (av7110->playing & av)
- return -EBUSY;
-
- av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
-
- if (av7110->playing == RP_NONE) {
- av7110_ipack_reset(&av7110->ipack[0]);
- av7110_ipack_reset(&av7110->ipack[1]);
- }
-
- av7110->playing |= av;
- switch (av7110->playing) {
- case RP_AUDIO:
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0);
- break;
- case RP_VIDEO:
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0);
- av7110->sinfo = 0;
- break;
- case RP_AV:
- av7110->sinfo = 0;
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AV_PES, 0);
- break;
- }
- if (!ret)
- ret = av7110->playing;
- return ret;
-}
-
-int av7110_av_stop(struct av7110 *av7110, int av)
-{
- int ret = 0;
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (!(av7110->playing & av) && !(av7110->rec_mode & av))
- return 0;
- av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
- if (av7110->playing) {
- av7110->playing &= ~av;
- switch (av7110->playing) {
- case RP_AUDIO:
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, AudioPES, 0);
- break;
- case RP_VIDEO:
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Play, 2, VideoPES, 0);
- break;
- case RP_NONE:
- ret = av7110_set_vidmode(av7110, av7110->vidmode);
- break;
- }
- } else {
- av7110->rec_mode &= ~av;
- switch (av7110->rec_mode) {
- case RP_AUDIO:
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, AudioPES, 0);
- break;
- case RP_VIDEO:
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Record, 2, VideoPES, 0);
- break;
- case RP_NONE:
- break;
- }
- }
- return ret;
-}
-
-
-int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen)
-{
- int len;
- u32 sync;
- u16 blen;
-
- if (!dlen) {
- wake_up(&buf->queue);
- return -1;
- }
- while (1) {
- if ((len = dvb_ringbuffer_avail(buf)) < 6)
- return -1;
- sync = DVB_RINGBUFFER_PEEK(buf, 0) << 24;
- sync |= DVB_RINGBUFFER_PEEK(buf, 1) << 16;
- sync |= DVB_RINGBUFFER_PEEK(buf, 2) << 8;
- sync |= DVB_RINGBUFFER_PEEK(buf, 3);
-
- if (((sync &~ 0x0f) == 0x000001e0) ||
- ((sync &~ 0x1f) == 0x000001c0) ||
- (sync == 0x000001bd))
- break;
- printk("resync\n");
- DVB_RINGBUFFER_SKIP(buf, 1);
- }
- blen = DVB_RINGBUFFER_PEEK(buf, 4) << 8;
- blen |= DVB_RINGBUFFER_PEEK(buf, 5);
- blen += 6;
- if (len < blen || blen > dlen) {
- //printk("buffer empty - avail %d blen %u dlen %d\n", len, blen, dlen);
- wake_up(&buf->queue);
- return -1;
- }
-
- dvb_ringbuffer_read(buf, dest, (size_t) blen, 0);
-
- dprintk(2, "pread=0x%08lx, pwrite=0x%08lx\n",
- (unsigned long) buf->pread, (unsigned long) buf->pwrite);
- wake_up(&buf->queue);
- return blen;
-}
-
-
-int av7110_set_volume(struct av7110 *av7110, int volleft, int volright)
-{
- int err, vol, val, balance = 0;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- av7110->mixer.volume_left = volleft;
- av7110->mixer.volume_right = volright;
-
- switch (av7110->adac_type) {
- case DVB_ADAC_TI:
- volleft = (volleft * 256) / 1036;
- volright = (volright * 256) / 1036;
- if (volleft > 0x3f)
- volleft = 0x3f;
- if (volright > 0x3f)
- volright = 0x3f;
- if ((err = SendDAC(av7110, 3, 0x80 + volleft)))
- return err;
- return SendDAC(av7110, 4, volright);
-
- case DVB_ADAC_CRYSTAL:
- volleft = 127 - volleft / 2;
- volright = 127 - volright / 2;
- i2c_writereg(av7110, 0x20, 0x03, volleft);
- i2c_writereg(av7110, 0x20, 0x04, volright);
- return 0;
-
- case DVB_ADAC_MSP34x0:
- vol = (volleft > volright) ? volleft : volright;
- val = (vol * 0x73 / 255) << 8;
- if (vol > 0)
- balance = ((volright - volleft) * 127) / vol;
- msp_writereg(av7110, MSP_WR_DSP, 0x0001, balance << 8);
- msp_writereg(av7110, MSP_WR_DSP, 0x0000, val); /* loudspeaker */
- msp_writereg(av7110, MSP_WR_DSP, 0x0006, val); /* headphonesr */
- return 0;
-
- case DVB_ADAC_MSP34x5:
- vol = (volleft > volright) ? volleft : volright;
- val = (vol * 0x73 / 255) << 8;
- if (vol > 0)
- balance = ((volright - volleft) * 127) / vol;
- msp_writereg(av7110, MSP_WR_DSP, 0x0001, balance << 8);
- msp_writereg(av7110, MSP_WR_DSP, 0x0000, val); /* loudspeaker */
- return 0;
- }
-
- return 0;
-}
-
-int av7110_set_vidmode(struct av7110 *av7110, int mode)
-{
- int ret;
- dprintk(2, "av7110:%p, \n", av7110);
-
- ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, LoadVidCode, 1, mode);
-
- if (!ret && !av7110->playing) {
- ret = ChangePIDs(av7110, av7110->pids[DMX_PES_VIDEO],
- av7110->pids[DMX_PES_AUDIO],
- av7110->pids[DMX_PES_TELETEXT],
- 0, av7110->pids[DMX_PES_PCR]);
- if (!ret)
- ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, Scan, 0);
- }
- return ret;
-}
-
-
-static int sw2mode[16] = {
- VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_NTSC, VIDEO_MODE_PAL,
- VIDEO_MODE_NTSC, VIDEO_MODE_NTSC, VIDEO_MODE_PAL, VIDEO_MODE_NTSC,
- VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL,
- VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL, VIDEO_MODE_PAL,
-};
-
-static int get_video_format(struct av7110 *av7110, u8 *buf, int count)
-{
- int i;
- int hsize, vsize;
- int sw;
- u8 *p;
- int ret = 0;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (av7110->sinfo)
- return 0;
- for (i = 7; i < count - 10; i++) {
- p = buf + i;
- if (p[0] || p[1] || p[2] != 0x01 || p[3] != 0xb3)
- continue;
- p += 4;
- hsize = ((p[1] &0xF0) >> 4) | (p[0] << 4);
- vsize = ((p[1] &0x0F) << 8) | (p[2]);
- sw = (p[3] & 0x0F);
- ret = av7110_set_vidmode(av7110, sw2mode[sw]);
- if (!ret) {
- dprintk(2, "playback %dx%d fr=%d\n", hsize, vsize, sw);
- av7110->sinfo = 1;
- }
- break;
- }
- return ret;
-}
-
-
-/****************************************************************************
- * I/O buffer management and control
- ****************************************************************************/
-
-static inline long aux_ring_buffer_write(struct dvb_ringbuffer *rbuf,
- const char *buf, unsigned long count)
-{
- unsigned long todo = count;
- int free;
-
- while (todo > 0) {
- if (dvb_ringbuffer_free(rbuf) < 2048) {
- if (wait_event_interruptible(rbuf->queue,
- (dvb_ringbuffer_free(rbuf) >= 2048)))
- return count - todo;
- }
- free = dvb_ringbuffer_free(rbuf);
- if (free > todo)
- free = todo;
- dvb_ringbuffer_write(rbuf, buf, free);
- todo -= free;
- buf += free;
- }
-
- return count - todo;
-}
-
-static void play_video_cb(u8 *buf, int count, void *priv)
-{
- struct av7110 *av7110 = (struct av7110 *) priv;
- dprintk(2, "av7110:%p, \n", av7110);
-
- if ((buf[3] & 0xe0) == 0xe0) {
- get_video_format(av7110, buf, count);
- aux_ring_buffer_write(&av7110->avout, buf, count);
- } else
- aux_ring_buffer_write(&av7110->aout, buf, count);
-}
-
-static void play_audio_cb(u8 *buf, int count, void *priv)
-{
- struct av7110 *av7110 = (struct av7110 *) priv;
- dprintk(2, "av7110:%p, \n", av7110);
-
- aux_ring_buffer_write(&av7110->aout, buf, count);
-}
-
-#define FREE_COND (dvb_ringbuffer_free(&av7110->avout) >= 20 * 1024 && \
- dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)
-
-static ssize_t dvb_play(struct av7110 *av7110, const u8 __user *buf,
- unsigned long count, int nonblock, int type)
-{
- unsigned long todo = count, n;
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (!av7110->kbuf[type])
- return -ENOBUFS;
-
- if (nonblock && !FREE_COND)
- return -EWOULDBLOCK;
-
- while (todo > 0) {
- if (!FREE_COND) {
- if (nonblock)
- return count - todo;
- if (wait_event_interruptible(av7110->avout.queue,
- FREE_COND))
- return count - todo;
- }
- n = todo;
- if (n > IPACKS * 2)
- n = IPACKS * 2;
- if (copy_from_user(av7110->kbuf[type], buf, n))
- return -EFAULT;
- av7110_ipack_instant_repack(av7110->kbuf[type], n,
- &av7110->ipack[type]);
- todo -= n;
- buf += n;
- }
- return count - todo;
-}
-
-static ssize_t dvb_play_kernel(struct av7110 *av7110, const u8 *buf,
- unsigned long count, int nonblock, int type)
-{
- unsigned long todo = count, n;
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (!av7110->kbuf[type])
- return -ENOBUFS;
-
- if (nonblock && !FREE_COND)
- return -EWOULDBLOCK;
-
- while (todo > 0) {
- if (!FREE_COND) {
- if (nonblock)
- return count - todo;
- if (wait_event_interruptible(av7110->avout.queue,
- FREE_COND))
- return count - todo;
- }
- n = todo;
- if (n > IPACKS * 2)
- n = IPACKS * 2;
- av7110_ipack_instant_repack(buf, n, &av7110->ipack[type]);
- todo -= n;
- buf += n;
- }
- return count - todo;
-}
-
-static ssize_t dvb_aplay(struct av7110 *av7110, const u8 __user *buf,
- unsigned long count, int nonblock, int type)
-{
- unsigned long todo = count, n;
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (!av7110->kbuf[type])
- return -ENOBUFS;
- if (nonblock && dvb_ringbuffer_free(&av7110->aout) < 20 * 1024)
- return -EWOULDBLOCK;
-
- while (todo > 0) {
- if (dvb_ringbuffer_free(&av7110->aout) < 20 * 1024) {
- if (nonblock)
- return count - todo;
- if (wait_event_interruptible(av7110->aout.queue,
- (dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)))
- return count-todo;
- }
- n = todo;
- if (n > IPACKS * 2)
- n = IPACKS * 2;
- if (copy_from_user(av7110->kbuf[type], buf, n))
- return -EFAULT;
- av7110_ipack_instant_repack(av7110->kbuf[type], n,
- &av7110->ipack[type]);
- todo -= n;
- buf += n;
- }
- return count - todo;
-}
-
-void av7110_p2t_init(struct av7110_p2t *p, struct dvb_demux_feed *feed)
-{
- memset(p->pes, 0, TS_SIZE);
- p->counter = 0;
- p->pos = 0;
- p->frags = 0;
- if (feed)
- p->feed = feed;
-}
-
-static void clear_p2t(struct av7110_p2t *p)
-{
- memset(p->pes, 0, TS_SIZE);
-// p->counter = 0;
- p->pos = 0;
- p->frags = 0;
-}
-
-
-static int find_pes_header(u8 const *buf, long int length, int *frags)
-{
- int c = 0;
- int found = 0;
-
- *frags = 0;
-
- while (c < length - 3 && !found) {
- if (buf[c] == 0x00 && buf[c + 1] == 0x00 &&
- buf[c + 2] == 0x01) {
- switch ( buf[c + 3] ) {
- case PROG_STREAM_MAP:
- case PRIVATE_STREAM2:
- case PROG_STREAM_DIR:
- case ECM_STREAM :
- case EMM_STREAM :
- case PADDING_STREAM :
- case DSM_CC_STREAM :
- case ISO13522_STREAM:
- case PRIVATE_STREAM1:
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- found = 1;
- break;
-
- default:
- c++;
- break;
- }
- } else
- c++;
- }
- if (c == length - 3 && !found) {
- if (buf[length - 1] == 0x00)
- *frags = 1;
- if (buf[length - 2] == 0x00 &&
- buf[length - 1] == 0x00)
- *frags = 2;
- if (buf[length - 3] == 0x00 &&
- buf[length - 2] == 0x00 &&
- buf[length - 1] == 0x01)
- *frags = 3;
- return -1;
- }
-
- return c;
-}
-
-void av7110_p2t_write(u8 const *buf, long int length, u16 pid, struct av7110_p2t *p)
-{
- int c, c2, l, add;
- int check, rest;
-
- c = 0;
- c2 = 0;
- if (p->frags){
- check = 0;
- switch(p->frags) {
- case 1:
- if (buf[c] == 0x00 && buf[c + 1] == 0x01) {
- check = 1;
- c += 2;
- }
- break;
- case 2:
- if (buf[c] == 0x01) {
- check = 1;
- c++;
- }
- break;
- case 3:
- check = 1;
- }
- if (check) {
- switch (buf[c]) {
- case PROG_STREAM_MAP:
- case PRIVATE_STREAM2:
- case PROG_STREAM_DIR:
- case ECM_STREAM :
- case EMM_STREAM :
- case PADDING_STREAM :
- case DSM_CC_STREAM :
- case ISO13522_STREAM:
- case PRIVATE_STREAM1:
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- p->pes[0] = 0x00;
- p->pes[1] = 0x00;
- p->pes[2] = 0x01;
- p->pes[3] = buf[c];
- p->pos = 4;
- memcpy(p->pes + p->pos, buf + c, (TS_SIZE - 4) - p->pos);
- c += (TS_SIZE - 4) - p->pos;
- p_to_t(p->pes, (TS_SIZE - 4), pid, &p->counter, p->feed);
- clear_p2t(p);
- break;
-
- default:
- c = 0;
- break;
- }
- }
- p->frags = 0;
- }
-
- if (p->pos) {
- c2 = find_pes_header(buf + c, length - c, &p->frags);
- if (c2 >= 0 && c2 < (TS_SIZE - 4) - p->pos)
- l = c2+c;
- else
- l = (TS_SIZE - 4) - p->pos;
- memcpy(p->pes + p->pos, buf, l);
- c += l;
- p->pos += l;
- p_to_t(p->pes, p->pos, pid, &p->counter, p->feed);
- clear_p2t(p);
- }
-
- add = 0;
- while (c < length) {
- c2 = find_pes_header(buf + c + add, length - c - add, &p->frags);
- if (c2 >= 0) {
- c2 += c + add;
- if (c2 > c){
- p_to_t(buf + c, c2 - c, pid, &p->counter, p->feed);
- c = c2;
- clear_p2t(p);
- add = 0;
- } else
- add = 1;
- } else {
- l = length - c;
- rest = l % (TS_SIZE - 4);
- l -= rest;
- p_to_t(buf + c, l, pid, &p->counter, p->feed);
- memcpy(p->pes, buf + c + l, rest);
- p->pos = rest;
- c = length;
- }
- }
-}
-
-
-static int write_ts_header2(u16 pid, u8 *counter, int pes_start, u8 *buf, u8 length)
-{
- int i;
- int c = 0;
- int fill;
- u8 tshead[4] = { 0x47, 0x00, 0x00, 0x10 };
-
- fill = (TS_SIZE - 4) - length;
- if (pes_start)
- tshead[1] = 0x40;
- if (fill)
- tshead[3] = 0x30;
- tshead[1] |= (u8)((pid & 0x1F00) >> 8);
- tshead[2] |= (u8)(pid & 0x00FF);
- tshead[3] |= ((*counter)++ & 0x0F);
- memcpy(buf, tshead, 4);
- c += 4;
-
- if (fill) {
- buf[4] = fill - 1;
- c++;
- if (fill > 1) {
- buf[5] = 0x00;
- c++;
- }
- for (i = 6; i < fill + 4; i++) {
- buf[i] = 0xFF;
- c++;
- }
- }
-
- return c;
-}
-
-
-static void p_to_t(u8 const *buf, long int length, u16 pid, u8 *counter,
- struct dvb_demux_feed *feed)
-{
- int l, pes_start;
- u8 obuf[TS_SIZE];
- long c = 0;
-
- pes_start = 0;
- if (length > 3 &&
- buf[0] == 0x00 && buf[1] == 0x00 && buf[2] == 0x01)
- switch (buf[3]) {
- case PROG_STREAM_MAP:
- case PRIVATE_STREAM2:
- case PROG_STREAM_DIR:
- case ECM_STREAM :
- case EMM_STREAM :
- case PADDING_STREAM :
- case DSM_CC_STREAM :
- case ISO13522_STREAM:
- case PRIVATE_STREAM1:
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- pes_start = 1;
- break;
-
- default:
- break;
- }
-
- while (c < length) {
- memset(obuf, 0, TS_SIZE);
- if (length - c >= (TS_SIZE - 4)){
- l = write_ts_header2(pid, counter, pes_start,
- obuf, (TS_SIZE - 4));
- memcpy(obuf + l, buf + c, TS_SIZE - l);
- c += TS_SIZE - l;
- } else {
- l = write_ts_header2(pid, counter, pes_start,
- obuf, length - c);
- memcpy(obuf + l, buf + c, TS_SIZE - l);
- c = length;
- }
- feed->cb.ts(obuf, 188, NULL, 0, &feed->feed.ts, DMX_OK);
- pes_start = 0;
- }
-}
-
-
-int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len)
-{
- struct dvb_demux *demux = feed->demux;
- struct av7110 *av7110 = (struct av7110 *) demux->priv;
- struct ipack *ipack = &av7110->ipack[feed->pes_type];
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- switch (feed->pes_type) {
- case 0:
- if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
- return -EINVAL;
- break;
- case 1:
- if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY)
- return -EINVAL;
- break;
- default:
- return -1;
- }
-
- if (!(buf[3] & 0x10)) /* no payload? */
- return -1;
- if (buf[1] & 0x40)
- av7110_ipack_flush(ipack);
-
- if (buf[3] & 0x20) { /* adaptation field? */
- len -= buf[4] + 1;
- buf += buf[4] + 1;
- if (!len)
- return 0;
- }
-
- av7110_ipack_instant_repack(buf + 4, len - 4, &av7110->ipack[feed->pes_type]);
- return 0;
-}
-
-
-
-/******************************************************************************
- * Video MPEG decoder events
- ******************************************************************************/
-void dvb_video_add_event(struct av7110 *av7110, struct video_event *event)
-{
- struct dvb_video_events *events = &av7110->video_events;
- int wp;
-
- spin_lock_bh(&events->lock);
-
- wp = (events->eventw + 1) % MAX_VIDEO_EVENT;
- if (wp == events->eventr) {
- events->overflow = 1;
- events->eventr = (events->eventr + 1) % MAX_VIDEO_EVENT;
- }
-
- //FIXME: timestamp?
- memcpy(&events->events[events->eventw], event, sizeof(struct video_event));
- events->eventw = wp;
-
- spin_unlock_bh(&events->lock);
-
- wake_up_interruptible(&events->wait_queue);
-}
-
-
-static int dvb_video_get_event (struct av7110 *av7110, struct video_event *event, int flags)
-{
- struct dvb_video_events *events = &av7110->video_events;
-
- if (events->overflow) {
- events->overflow = 0;
- return -EOVERFLOW;
- }
- if (events->eventw == events->eventr) {
- int ret;
-
- if (flags & O_NONBLOCK)
- return -EWOULDBLOCK;
-
- ret = wait_event_interruptible(events->wait_queue,
- events->eventw != events->eventr);
- if (ret < 0)
- return ret;
- }
-
- spin_lock_bh(&events->lock);
-
- memcpy(event, &events->events[events->eventr],
- sizeof(struct video_event));
- events->eventr = (events->eventr + 1) % MAX_VIDEO_EVENT;
-
- spin_unlock_bh(&events->lock);
-
- return 0;
-}
-
-
-/******************************************************************************
- * DVB device file operations
- ******************************************************************************/
-
-static unsigned int dvb_video_poll(struct file *file, poll_table *wait)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- unsigned int mask = 0;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if ((file->f_flags & O_ACCMODE) != O_RDONLY)
- poll_wait(file, &av7110->avout.queue, wait);
-
- poll_wait(file, &av7110->video_events.wait_queue, wait);
-
- if (av7110->video_events.eventw != av7110->video_events.eventr)
- mask = POLLPRI;
-
- if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
- if (av7110->playing) {
- if (FREE_COND)
- mask |= (POLLOUT | POLLWRNORM);
- } else /* if not playing: may play if asked for */
- mask |= (POLLOUT | POLLWRNORM);
- }
-
- return mask;
-}
-
-static ssize_t dvb_video_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY)
- return -EPERM;
-
- if (av7110->videostate.stream_source != VIDEO_SOURCE_MEMORY)
- return -EPERM;
-
- return dvb_play(av7110, buf, count, file->f_flags & O_NONBLOCK, 1);
-}
-
-static unsigned int dvb_audio_poll(struct file *file, poll_table *wait)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- unsigned int mask = 0;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- poll_wait(file, &av7110->aout.queue, wait);
-
- if (av7110->playing) {
- if (dvb_ringbuffer_free(&av7110->aout) >= 20 * 1024)
- mask |= (POLLOUT | POLLWRNORM);
- } else /* if not playing: may play if asked for */
- mask = (POLLOUT | POLLWRNORM);
-
- return mask;
-}
-
-static ssize_t dvb_audio_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (av7110->audiostate.stream_source != AUDIO_SOURCE_MEMORY) {
- printk(KERN_ERR "not audio source memory\n");
- return -EPERM;
- }
- return dvb_aplay(av7110, buf, count, file->f_flags & O_NONBLOCK, 0);
-}
-
-static u8 iframe_header[] = { 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00 };
-
-#define MIN_IFRAME 400000
-
-static int play_iframe(struct av7110 *av7110, u8 __user *buf, unsigned int len, int nonblock)
-{
- int i, n;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (!(av7110->playing & RP_VIDEO)) {
- if (av7110_av_start_play(av7110, RP_VIDEO) < 0)
- return -EBUSY;
- }
-
- /* setting n always > 1, fixes problems when playing stillframes
- consisting of I- and P-Frames */
- n = MIN_IFRAME / len + 1;
-
- /* FIXME: nonblock? */
- dvb_play_kernel(av7110, iframe_header, sizeof(iframe_header), 0, 1);
-
- for (i = 0; i < n; i++)
- dvb_play(av7110, buf, len, 0, 1);
-
- av7110_ipack_flush(&av7110->ipack[1]);
- return 0;
-}
-
-
-static int dvb_video_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- unsigned long arg = (unsigned long) parg;
- int ret = 0;
-
- dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
-
- if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
- if ( cmd != VIDEO_GET_STATUS && cmd != VIDEO_GET_EVENT &&
- cmd != VIDEO_GET_SIZE ) {
- return -EPERM;
- }
- }
-
- switch (cmd) {
- case VIDEO_STOP:
- av7110->videostate.play_state = VIDEO_STOPPED;
- if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY)
- ret = av7110_av_stop(av7110, RP_VIDEO);
- else
- ret = vidcom(av7110, VIDEO_CMD_STOP,
- av7110->videostate.video_blank ? 0 : 1);
- if (!ret)
- av7110->trickmode = TRICK_NONE;
- break;
-
- case VIDEO_PLAY:
- av7110->trickmode = TRICK_NONE;
- if (av7110->videostate.play_state == VIDEO_FREEZED) {
- av7110->videostate.play_state = VIDEO_PLAYING;
- ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
- if (ret)
- break;
- }
-
- if (av7110->videostate.stream_source == VIDEO_SOURCE_MEMORY) {
- if (av7110->playing == RP_AV) {
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Stop, 0);
- if (ret)
- break;
- av7110->playing &= ~RP_VIDEO;
- }
- ret = av7110_av_start_play(av7110, RP_VIDEO);
- }
- if (!ret)
- ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
- if (!ret)
- av7110->videostate.play_state = VIDEO_PLAYING;
- break;
-
- case VIDEO_FREEZE:
- av7110->videostate.play_state = VIDEO_FREEZED;
- if (av7110->playing & RP_VIDEO)
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Pause, 0);
- else
- ret = vidcom(av7110, VIDEO_CMD_FREEZE, 1);
- if (!ret)
- av7110->trickmode = TRICK_FREEZE;
- break;
-
- case VIDEO_CONTINUE:
- if (av7110->playing & RP_VIDEO)
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Continue, 0);
- if (!ret)
- ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
- if (!ret) {
- av7110->videostate.play_state = VIDEO_PLAYING;
- av7110->trickmode = TRICK_NONE;
- }
- break;
-
- case VIDEO_SELECT_SOURCE:
- av7110->videostate.stream_source = (video_stream_source_t) arg;
- break;
-
- case VIDEO_SET_BLANK:
- av7110->videostate.video_blank = (int) arg;
- break;
-
- case VIDEO_GET_STATUS:
- memcpy(parg, &av7110->videostate, sizeof(struct video_status));
- break;
-
- case VIDEO_GET_EVENT:
- ret = dvb_video_get_event(av7110, parg, file->f_flags);
- break;
-
- case VIDEO_GET_SIZE:
- memcpy(parg, &av7110->video_size, sizeof(video_size_t));
- break;
-
- case VIDEO_SET_DISPLAY_FORMAT:
- {
- video_displayformat_t format = (video_displayformat_t) arg;
- u16 val = 0;
-
- switch (format) {
- case VIDEO_PAN_SCAN:
- val = VID_PAN_SCAN_PREF;
- break;
-
- case VIDEO_LETTER_BOX:
- val = VID_VC_AND_PS_PREF;
- break;
-
- case VIDEO_CENTER_CUT_OUT:
- val = VID_CENTRE_CUT_PREF;
- break;
-
- default:
- ret = -EINVAL;
- }
- if (ret < 0)
- break;
- av7110->videostate.display_format = format;
- ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetPanScanType,
- 1, (u16) val);
- break;
- }
-
- case VIDEO_SET_FORMAT:
- if (arg > 1) {
- ret = -EINVAL;
- break;
- }
- av7110->display_ar = arg;
- ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetMonitorType,
- 1, (u16) arg);
- break;
-
- case VIDEO_STILLPICTURE:
- {
- struct video_still_picture *pic =
- (struct video_still_picture *) parg;
- av7110->videostate.stream_source = VIDEO_SOURCE_MEMORY;
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
- ret = play_iframe(av7110, pic->iFrame, pic->size,
- file->f_flags & O_NONBLOCK);
- break;
- }
-
- case VIDEO_FAST_FORWARD:
- //note: arg is ignored by firmware
- if (av7110->playing & RP_VIDEO)
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
- __Scan_I, 2, AV_PES, 0);
- else
- ret = vidcom(av7110, VIDEO_CMD_FFWD, arg);
- if (!ret) {
- av7110->trickmode = TRICK_FAST;
- av7110->videostate.play_state = VIDEO_PLAYING;
- }
- break;
-
- case VIDEO_SLOWMOTION:
- if (av7110->playing&RP_VIDEO) {
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY, __Slow, 2, 0, 0);
- if (!ret)
- ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
- } else {
- ret = vidcom(av7110, VIDEO_CMD_PLAY, 0);
- if (!ret)
- ret = vidcom(av7110, VIDEO_CMD_STOP, 0);
- if (!ret)
- ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
- }
- if (!ret) {
- av7110->trickmode = TRICK_SLOW;
- av7110->videostate.play_state = VIDEO_PLAYING;
- }
- break;
-
- case VIDEO_GET_CAPABILITIES:
- *(int *)parg = VIDEO_CAP_MPEG1 | VIDEO_CAP_MPEG2 |
- VIDEO_CAP_SYS | VIDEO_CAP_PROG;
- break;
-
- case VIDEO_CLEAR_BUFFER:
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
- av7110_ipack_reset(&av7110->ipack[1]);
-
- if (av7110->playing == RP_AV) {
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
- __Play, 2, AV_PES, 0);
- if (ret)
- break;
- if (av7110->trickmode == TRICK_FAST)
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
- __Scan_I, 2, AV_PES, 0);
- if (av7110->trickmode == TRICK_SLOW) {
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
- __Slow, 2, 0, 0);
- if (!ret)
- ret = vidcom(av7110, VIDEO_CMD_SLOW, arg);
- }
- if (av7110->trickmode == TRICK_FREEZE)
- ret = vidcom(av7110, VIDEO_CMD_STOP, 1);
- }
- break;
-
- case VIDEO_SET_STREAMTYPE:
-
- break;
-
- default:
- ret = -ENOIOCTLCMD;
- break;
- }
- return ret;
-}
-
-static int dvb_audio_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- unsigned long arg = (unsigned long) parg;
- int ret = 0;
-
- dprintk(1, "av7110:%p, cmd=%04x\n", av7110,cmd);
-
- if (((file->f_flags & O_ACCMODE) == O_RDONLY) &&
- (cmd != AUDIO_GET_STATUS))
- return -EPERM;
-
- switch (cmd) {
- case AUDIO_STOP:
- if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
- ret = av7110_av_stop(av7110, RP_AUDIO);
- else
- ret = audcom(av7110, AUDIO_CMD_MUTE);
- if (!ret)
- av7110->audiostate.play_state = AUDIO_STOPPED;
- break;
-
- case AUDIO_PLAY:
- if (av7110->audiostate.stream_source == AUDIO_SOURCE_MEMORY)
- ret = av7110_av_start_play(av7110, RP_AUDIO);
- if (!ret)
- ret = audcom(av7110, AUDIO_CMD_UNMUTE);
- if (!ret)
- av7110->audiostate.play_state = AUDIO_PLAYING;
- break;
-
- case AUDIO_PAUSE:
- ret = audcom(av7110, AUDIO_CMD_MUTE);
- if (!ret)
- av7110->audiostate.play_state = AUDIO_PAUSED;
- break;
-
- case AUDIO_CONTINUE:
- if (av7110->audiostate.play_state == AUDIO_PAUSED) {
- av7110->audiostate.play_state = AUDIO_PLAYING;
- ret = audcom(av7110, AUDIO_CMD_UNMUTE | AUDIO_CMD_PCM16);
- }
- break;
-
- case AUDIO_SELECT_SOURCE:
- av7110->audiostate.stream_source = (audio_stream_source_t) arg;
- break;
-
- case AUDIO_SET_MUTE:
- {
- ret = audcom(av7110, arg ? AUDIO_CMD_MUTE : AUDIO_CMD_UNMUTE);
- if (!ret)
- av7110->audiostate.mute_state = (int) arg;
- break;
- }
-
- case AUDIO_SET_AV_SYNC:
- av7110->audiostate.AV_sync_state = (int) arg;
- ret = audcom(av7110, arg ? AUDIO_CMD_SYNC_ON : AUDIO_CMD_SYNC_OFF);
- break;
-
- case AUDIO_SET_BYPASS_MODE:
- if (FW_VERSION(av7110->arm_app) < 0x2621)
- ret = -EINVAL;
- av7110->audiostate.bypass_mode = (int)arg;
- break;
-
- case AUDIO_CHANNEL_SELECT:
- av7110->audiostate.channel_select = (audio_channel_select_t) arg;
-
- switch(av7110->audiostate.channel_select) {
- case AUDIO_STEREO:
- ret = audcom(av7110, AUDIO_CMD_STEREO);
- if (!ret) {
- if (av7110->adac_type == DVB_ADAC_CRYSTAL)
- i2c_writereg(av7110, 0x20, 0x02, 0x49);
- else if (av7110->adac_type == DVB_ADAC_MSP34x5)
- msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220);
- }
- break;
-
- case AUDIO_MONO_LEFT:
- ret = audcom(av7110, AUDIO_CMD_MONO_L);
- if (!ret) {
- if (av7110->adac_type == DVB_ADAC_CRYSTAL)
- i2c_writereg(av7110, 0x20, 0x02, 0x4a);
- else if (av7110->adac_type == DVB_ADAC_MSP34x5)
- msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0200);
- }
- break;
-
- case AUDIO_MONO_RIGHT:
- ret = audcom(av7110, AUDIO_CMD_MONO_R);
- if (!ret) {
- if (av7110->adac_type == DVB_ADAC_CRYSTAL)
- i2c_writereg(av7110, 0x20, 0x02, 0x45);
- else if (av7110->adac_type == DVB_ADAC_MSP34x5)
- msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0210);
- }
- break;
-
- default:
- ret = -EINVAL;
- break;
- }
- break;
-
- case AUDIO_GET_STATUS:
- memcpy(parg, &av7110->audiostate, sizeof(struct audio_status));
- break;
-
- case AUDIO_GET_CAPABILITIES:
- if (FW_VERSION(av7110->arm_app) < 0x2621)
- *(unsigned int *)parg = AUDIO_CAP_LPCM | AUDIO_CAP_MP1 | AUDIO_CAP_MP2;
- else
- *(unsigned int *)parg = AUDIO_CAP_LPCM | AUDIO_CAP_DTS | AUDIO_CAP_AC3 |
- AUDIO_CAP_MP1 | AUDIO_CAP_MP2;
- break;
-
- case AUDIO_CLEAR_BUFFER:
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
- av7110_ipack_reset(&av7110->ipack[0]);
- if (av7110->playing == RP_AV)
- ret = av7110_fw_cmd(av7110, COMTYPE_REC_PLAY,
- __Play, 2, AV_PES, 0);
- break;
- case AUDIO_SET_ID:
-
- break;
- case AUDIO_SET_MIXER:
- {
- struct audio_mixer *amix = (struct audio_mixer *)parg;
-
- ret = av7110_set_volume(av7110, amix->volume_left, amix->volume_right);
- break;
- }
- case AUDIO_SET_STREAMTYPE:
- break;
- default:
- ret = -ENOIOCTLCMD;
- }
- return ret;
-}
-
-
-static int dvb_video_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- int err;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if ((err = dvb_generic_open(inode, file)) < 0)
- return err;
-
- if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->avout);
- av7110->video_blank = 1;
- av7110->audiostate.AV_sync_state = 1;
- av7110->videostate.stream_source = VIDEO_SOURCE_DEMUX;
-
- /* empty event queue */
- av7110->video_events.eventr = av7110->video_events.eventw = 0;
- }
-
- return 0;
-}
-
-static int dvb_video_release(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
- av7110_av_stop(av7110, RP_VIDEO);
- }
-
- return dvb_generic_release(inode, file);
-}
-
-static int dvb_audio_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- int err=dvb_generic_open(inode, file);
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- if (err < 0)
- return err;
- dvb_ringbuffer_flush_spinlock_wakeup(&av7110->aout);
- av7110->audiostate.stream_source = AUDIO_SOURCE_DEMUX;
- return 0;
-}
-
-static int dvb_audio_release(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
-
- dprintk(2, "av7110:%p, \n", av7110);
-
- av7110_av_stop(av7110, RP_AUDIO);
- return dvb_generic_release(inode, file);
-}
-
-
-
-/******************************************************************************
- * driver registration
- ******************************************************************************/
-
-static struct file_operations dvb_video_fops = {
- .owner = THIS_MODULE,
- .write = dvb_video_write,
- .ioctl = dvb_generic_ioctl,
- .open = dvb_video_open,
- .release = dvb_video_release,
- .poll = dvb_video_poll,
-};
-
-static struct dvb_device dvbdev_video = {
- .priv = NULL,
- .users = 6,
- .readers = 5, /* arbitrary */
- .writers = 1,
- .fops = &dvb_video_fops,
- .kernel_ioctl = dvb_video_ioctl,
-};
-
-static struct file_operations dvb_audio_fops = {
- .owner = THIS_MODULE,
- .write = dvb_audio_write,
- .ioctl = dvb_generic_ioctl,
- .open = dvb_audio_open,
- .release = dvb_audio_release,
- .poll = dvb_audio_poll,
-};
-
-static struct dvb_device dvbdev_audio = {
- .priv = NULL,
- .users = 1,
- .writers = 1,
- .fops = &dvb_audio_fops,
- .kernel_ioctl = dvb_audio_ioctl,
-};
-
-
-int av7110_av_register(struct av7110 *av7110)
-{
- av7110->audiostate.AV_sync_state = 0;
- av7110->audiostate.mute_state = 0;
- av7110->audiostate.play_state = AUDIO_STOPPED;
- av7110->audiostate.stream_source = AUDIO_SOURCE_DEMUX;
- av7110->audiostate.channel_select = AUDIO_STEREO;
- av7110->audiostate.bypass_mode = 0;
-
- av7110->videostate.video_blank = 0;
- av7110->videostate.play_state = VIDEO_STOPPED;
- av7110->videostate.stream_source = VIDEO_SOURCE_DEMUX;
- av7110->videostate.video_format = VIDEO_FORMAT_4_3;
- av7110->videostate.display_format = VIDEO_CENTER_CUT_OUT;
- av7110->display_ar = VIDEO_FORMAT_4_3;
-
- init_waitqueue_head(&av7110->video_events.wait_queue);
- spin_lock_init(&av7110->video_events.lock);
- av7110->video_events.eventw = av7110->video_events.eventr = 0;
- av7110->video_events.overflow = 0;
- memset(&av7110->video_size, 0, sizeof (video_size_t));
-
- dvb_register_device(&av7110->dvb_adapter, &av7110->video_dev,
- &dvbdev_video, av7110, DVB_DEVICE_VIDEO);
-
- dvb_register_device(&av7110->dvb_adapter, &av7110->audio_dev,
- &dvbdev_audio, av7110, DVB_DEVICE_AUDIO);
-
- return 0;
-}
-
-void av7110_av_unregister(struct av7110 *av7110)
-{
- dvb_unregister_device(av7110->audio_dev);
- dvb_unregister_device(av7110->video_dev);
-}
-
-int av7110_av_init(struct av7110 *av7110)
-{
- void (*play[])(u8 *, int, void *) = { play_audio_cb, play_video_cb };
- int i, ret;
-
- for (i = 0; i < 2; i++) {
- struct ipack *ipack = av7110->ipack + i;
-
- ret = av7110_ipack_init(ipack, IPACKS, play[i]);
- if (ret < 0) {
- if (i)
- av7110_ipack_free(--ipack);
- goto out;
- }
- ipack->data = av7110;
- }
-
- dvb_ringbuffer_init(&av7110->avout, av7110->iobuf, AVOUTLEN);
- dvb_ringbuffer_init(&av7110->aout, av7110->iobuf + AVOUTLEN, AOUTLEN);
-
- av7110->kbuf[0] = (u8 *)(av7110->iobuf + AVOUTLEN + AOUTLEN + BMPLEN);
- av7110->kbuf[1] = av7110->kbuf[0] + 2 * IPACKS;
-out:
- return ret;
-}
-
-void av7110_av_exit(struct av7110 *av7110)
-{
- av7110_ipack_free(&av7110->ipack[0]);
- av7110_ipack_free(&av7110->ipack[1]);
-}
diff --git a/drivers/media/dvb/ttpci/av7110_av.h b/drivers/media/dvb/ttpci/av7110_av.h
deleted file mode 100644
index 45dc144b8b4..00000000000
--- a/drivers/media/dvb/ttpci/av7110_av.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef _AV7110_AV_H_
-#define _AV7110_AV_H_
-
-struct av7110;
-
-extern int av7110_set_vidmode(struct av7110 *av7110, int mode);
-
-extern int av7110_record_cb(struct dvb_filter_pes2ts *p2t, u8 *buf, size_t len);
-extern int av7110_pes_play(void *dest, struct dvb_ringbuffer *buf, int dlen);
-extern int av7110_write_to_decoder(struct dvb_demux_feed *feed, const u8 *buf, size_t len);
-
-extern int av7110_set_volume(struct av7110 *av7110, int volleft, int volright);
-extern int av7110_av_stop(struct av7110 *av7110, int av);
-extern int av7110_av_start_record(struct av7110 *av7110, int av,
- struct dvb_demux_feed *dvbdmxfeed);
-extern int av7110_av_start_play(struct av7110 *av7110, int av);
-
-extern void dvb_video_add_event(struct av7110 *av7110, struct video_event *event);
-
-extern void av7110_p2t_init(struct av7110_p2t *p, struct dvb_demux_feed *feed);
-extern void av7110_p2t_write(u8 const *buf, long int length, u16 pid, struct av7110_p2t *p);
-
-extern int av7110_av_register(struct av7110 *av7110);
-extern void av7110_av_unregister(struct av7110 *av7110);
-extern int av7110_av_init(struct av7110 *av7110);
-extern void av7110_av_exit(struct av7110 *av7110);
-
-
-#endif /* _AV7110_AV_H_ */
diff --git a/drivers/media/dvb/ttpci/av7110_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
deleted file mode 100644
index 6079e8865d5..00000000000
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * av7110_ca.c: CA and CI stuff
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * originally based on code by:
- * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/delay.h>
-#include <linux/fs.h>
-#include <linux/timer.h>
-#include <linux/poll.h>
-#include <linux/byteorder/swabb.h>
-#include <linux/smp_lock.h>
-
-#include "av7110.h"
-#include "av7110_hw.h"
-#include "av7110_ca.h"
-
-
-void CI_handle(struct av7110 *av7110, u8 *data, u16 len)
-{
- dprintk(8, "av7110:%p\n",av7110);
-
- if (len < 3)
- return;
- switch (data[0]) {
- case CI_MSG_CI_INFO:
- if (data[2] != 1 && data[2] != 2)
- break;
- switch (data[1]) {
- case 0:
- av7110->ci_slot[data[2] - 1].flags = 0;
- break;
- case 1:
- av7110->ci_slot[data[2] - 1].flags |= CA_CI_MODULE_PRESENT;
- break;
- case 2:
- av7110->ci_slot[data[2] - 1].flags |= CA_CI_MODULE_READY;
- break;
- }
- break;
- case CI_SWITCH_PRG_REPLY:
- //av7110->ci_stat=data[1];
- break;
- default:
- break;
- }
-}
-
-
-void ci_get_data(struct dvb_ringbuffer *cibuf, u8 *data, int len)
-{
- if (dvb_ringbuffer_free(cibuf) < len + 2)
- return;
-
- DVB_RINGBUFFER_WRITE_BYTE(cibuf, len >> 8);
- DVB_RINGBUFFER_WRITE_BYTE(cibuf, len & 0xff);
- dvb_ringbuffer_write(cibuf, data, len);
- wake_up_interruptible(&cibuf->queue);
-}
-
-
-/******************************************************************************
- * CI link layer file ops
- ******************************************************************************/
-
-static int ci_ll_init(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf, int size)
-{
- struct dvb_ringbuffer *tab[] = { cirbuf, ciwbuf, NULL }, **p;
- void *data;
-
- for (p = tab; *p; p++) {
- data = vmalloc(size);
- if (!data) {
- while (p-- != tab) {
- vfree(p[0]->data);
- p[0]->data = NULL;
- }
- return -ENOMEM;
- }
- dvb_ringbuffer_init(*p, data, size);
- }
- return 0;
-}
-
-static void ci_ll_flush(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf)
-{
- dvb_ringbuffer_flush_spinlock_wakeup(cirbuf);
- dvb_ringbuffer_flush_spinlock_wakeup(ciwbuf);
-}
-
-static void ci_ll_release(struct dvb_ringbuffer *cirbuf, struct dvb_ringbuffer *ciwbuf)
-{
- vfree(cirbuf->data);
- cirbuf->data = NULL;
- vfree(ciwbuf->data);
- ciwbuf->data = NULL;
-}
-
-static int ci_ll_reset(struct dvb_ringbuffer *cibuf, struct file *file,
- int slots, ca_slot_info_t *slot)
-{
- int i;
- int len = 0;
- u8 msg[8] = { 0x00, 0x06, 0x00, 0x00, 0xff, 0x02, 0x00, 0x00 };
-
- for (i = 0; i < 2; i++) {
- if (slots & (1 << i))
- len += 8;
- }
-
- if (dvb_ringbuffer_free(cibuf) < len)
- return -EBUSY;
-
- for (i = 0; i < 2; i++) {
- if (slots & (1 << i)) {
- msg[2] = i;
- dvb_ringbuffer_write(cibuf, msg, 8);
- slot[i].flags = 0;
- }
- }
-
- return 0;
-}
-
-static ssize_t ci_ll_write(struct dvb_ringbuffer *cibuf, struct file *file,
- const char __user *buf, size_t count, loff_t *ppos)
-{
- int free;
- int non_blocking = file->f_flags & O_NONBLOCK;
- char *page = (char *)__get_free_page(GFP_USER);
- int res;
-
- if (!page)
- return -ENOMEM;
-
- res = -EINVAL;
- if (count > 2048)
- goto out;
-
- res = -EFAULT;
- if (copy_from_user(page, buf, count))
- goto out;
-
- free = dvb_ringbuffer_free(cibuf);
- if (count + 2 > free) {
- res = -EWOULDBLOCK;
- if (non_blocking)
- goto out;
- res = -ERESTARTSYS;
- if (wait_event_interruptible(cibuf->queue,
- (dvb_ringbuffer_free(cibuf) >= count + 2)))
- goto out;
- }
-
- DVB_RINGBUFFER_WRITE_BYTE(cibuf, count >> 8);
- DVB_RINGBUFFER_WRITE_BYTE(cibuf, count & 0xff);
-
- res = dvb_ringbuffer_write(cibuf, page, count);
-out:
- free_page((unsigned long)page);
- return res;
-}
-
-static ssize_t ci_ll_read(struct dvb_ringbuffer *cibuf, struct file *file,
- char __user *buf, size_t count, loff_t *ppos)
-{
- int avail;
- int non_blocking = file->f_flags & O_NONBLOCK;
- ssize_t len;
-
- if (!cibuf->data || !count)
- return 0;
- if (non_blocking && (dvb_ringbuffer_empty(cibuf)))
- return -EWOULDBLOCK;
- if (wait_event_interruptible(cibuf->queue,
- !dvb_ringbuffer_empty(cibuf)))
- return -ERESTARTSYS;
- avail = dvb_ringbuffer_avail(cibuf);
- if (avail < 4)
- return 0;
- len = DVB_RINGBUFFER_PEEK(cibuf, 0) << 8;
- len |= DVB_RINGBUFFER_PEEK(cibuf, 1);
- if (avail < len + 2 || count < len)
- return -EINVAL;
- DVB_RINGBUFFER_SKIP(cibuf, 2);
-
- return dvb_ringbuffer_read(cibuf, buf, len, 1);
-}
-
-static int dvb_ca_open(struct inode *inode, struct file *file)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- int err = dvb_generic_open(inode, file);
-
- dprintk(8, "av7110:%p\n",av7110);
-
- if (err < 0)
- return err;
- ci_ll_flush(&av7110->ci_rbuffer, &av7110->ci_wbuffer);
- return 0;
-}
-
-static unsigned int dvb_ca_poll (struct file *file, poll_table *wait)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- struct dvb_ringbuffer *rbuf = &av7110->ci_rbuffer;
- struct dvb_ringbuffer *wbuf = &av7110->ci_wbuffer;
- unsigned int mask = 0;
-
- dprintk(8, "av7110:%p\n",av7110);
-
- poll_wait(file, &rbuf->queue, wait);
- poll_wait(file, &wbuf->queue, wait);
-
- if (!dvb_ringbuffer_empty(rbuf))
- mask |= (POLLIN | POLLRDNORM);
-
- if (dvb_ringbuffer_free(wbuf) > 1024)
- mask |= (POLLOUT | POLLWRNORM);
-
- return mask;
-}
-
-static int dvb_ca_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, void *parg)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
- unsigned long arg = (unsigned long) parg;
-
- dprintk(8, "av7110:%p\n",av7110);
-
- switch (cmd) {
- case CA_RESET:
- return ci_ll_reset(&av7110->ci_wbuffer, file, arg, &av7110->ci_slot[0]);
- break;
- case CA_GET_CAP:
- {
- ca_caps_t cap;
-
- cap.slot_num = 2;
- cap.slot_type = (FW_CI_LL_SUPPORT(av7110->arm_app) ?
- CA_CI_LINK : CA_CI) | CA_DESCR;
- cap.descr_num = 16;
- cap.descr_type = CA_ECD;
- memcpy(parg, &cap, sizeof(cap));
- break;
- }
-
- case CA_GET_SLOT_INFO:
- {
- ca_slot_info_t *info=(ca_slot_info_t *)parg;
-
- if (info->num > 1)
- return -EINVAL;
- av7110->ci_slot[info->num].num = info->num;
- av7110->ci_slot[info->num].type = FW_CI_LL_SUPPORT(av7110->arm_app) ?
- CA_CI_LINK : CA_CI;
- memcpy(info, &av7110->ci_slot[info->num], sizeof(ca_slot_info_t));
- break;
- }
-
- case CA_GET_MSG:
- break;
-
- case CA_SEND_MSG:
- break;
-
- case CA_GET_DESCR_INFO:
- {
- ca_descr_info_t info;
-
- info.num = 16;
- info.type = CA_ECD;
- memcpy(parg, &info, sizeof (info));
- break;
- }
-
- case CA_SET_DESCR:
- {
- ca_descr_t *descr = (ca_descr_t*) parg;
-
- if (descr->index >= 16)
- return -EINVAL;
- if (descr->parity > 1)
- return -EINVAL;
- av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetDescr, 5,
- (descr->index<<8)|descr->parity,
- (descr->cw[0]<<8)|descr->cw[1],
- (descr->cw[2]<<8)|descr->cw[3],
- (descr->cw[4]<<8)|descr->cw[5],
- (descr->cw[6]<<8)|descr->cw[7]);
- break;
- }
-
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static ssize_t dvb_ca_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
-
- dprintk(8, "av7110:%p\n",av7110);
- return ci_ll_write(&av7110->ci_wbuffer, file, buf, count, ppos);
-}
-
-static ssize_t dvb_ca_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
-{
- struct dvb_device *dvbdev = (struct dvb_device *) file->private_data;
- struct av7110 *av7110 = (struct av7110 *) dvbdev->priv;
-
- dprintk(8, "av7110:%p\n",av7110);
- return ci_ll_read(&av7110->ci_rbuffer, file, buf, count, ppos);
-}
-
-
-
-static struct file_operations dvb_ca_fops = {
- .owner = THIS_MODULE,
- .read = dvb_ca_read,
- .write = dvb_ca_write,
- .ioctl = dvb_generic_ioctl,
- .open = dvb_ca_open,
- .release = dvb_generic_release,
- .poll = dvb_ca_poll,
-};
-
-static struct dvb_device dvbdev_ca = {
- .priv = NULL,
- .users = 1,
- .writers = 1,
- .fops = &dvb_ca_fops,
- .kernel_ioctl = dvb_ca_ioctl,
-};
-
-
-int av7110_ca_register(struct av7110 *av7110)
-{
- return dvb_register_device(&av7110->dvb_adapter, &av7110->ca_dev,
- &dvbdev_ca, av7110, DVB_DEVICE_CA);
-}
-
-void av7110_ca_unregister(struct av7110 *av7110)
-{
- dvb_unregister_device(av7110->ca_dev);
-}
-
-int av7110_ca_init(struct av7110* av7110)
-{
- return ci_ll_init(&av7110->ci_rbuffer, &av7110->ci_wbuffer, 8192);
-}
-
-void av7110_ca_exit(struct av7110* av7110)
-{
- ci_ll_release(&av7110->ci_rbuffer, &av7110->ci_wbuffer);
-}
diff --git a/drivers/media/dvb/ttpci/av7110_ca.h b/drivers/media/dvb/ttpci/av7110_ca.h
deleted file mode 100644
index 70ee855ece1..00000000000
--- a/drivers/media/dvb/ttpci/av7110_ca.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _AV7110_CA_H_
-#define _AV7110_CA_H_
-
-struct av7110;
-
-extern void CI_handle(struct av7110 *av7110, u8 *data, u16 len);
-extern void ci_get_data(struct dvb_ringbuffer *cibuf, u8 *data, int len);
-
-extern int av7110_ca_register(struct av7110 *av7110);
-extern void av7110_ca_unregister(struct av7110 *av7110);
-extern int av7110_ca_init(struct av7110* av7110);
-extern void av7110_ca_exit(struct av7110* av7110);
-
-#endif /* _AV7110_CA_H_ */
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
deleted file mode 100644
index 75736f2fe83..00000000000
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ /dev/null
@@ -1,1223 +0,0 @@
-/*
- * av7110_hw.c: av7110 low level hardware access and firmware interface
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * originally based on code by:
- * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-/* for debugging ARM communication: */
-//#define COM_DEBUG
-
-#include <stdarg.h>
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/byteorder/swabb.h>
-#include <linux/smp_lock.h>
-#include <linux/fs.h>
-
-#include "av7110.h"
-#include "av7110_hw.h"
-
-#define _NOHANDSHAKE
-
-/****************************************************************************
- * DEBI functions
- ****************************************************************************/
-
-/* This DEBI code is based on the Stradis driver
- by Nathan Laredo <laredo@gnu.org> */
-
-int av7110_debiwrite(struct av7110 *av7110, u32 config,
- int addr, u32 val, int count)
-{
- struct saa7146_dev *dev = av7110->dev;
-
- if (count <= 0 || count > 32764) {
- printk("%s: invalid count %d\n", __FUNCTION__, count);
- return -1;
- }
- if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
- printk("%s: wait_for_debi_done failed\n", __FUNCTION__);
- return -1;
- }
- saa7146_write(dev, DEBI_CONFIG, config);
- if (count <= 4) /* immediate transfer */
- saa7146_write(dev, DEBI_AD, val);
- else /* block transfer */
- saa7146_write(dev, DEBI_AD, av7110->debi_bus);
- saa7146_write(dev, DEBI_COMMAND, (count << 17) | (addr & 0xffff));
- saa7146_write(dev, MC2, (2 << 16) | 2);
- return 0;
-}
-
-u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count)
-{
- struct saa7146_dev *dev = av7110->dev;
- u32 result = 0;
-
- if (count > 32764 || count <= 0) {
- printk("%s: invalid count %d\n", __FUNCTION__, count);
- return 0;
- }
- if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
- printk("%s: wait_for_debi_done #1 failed\n", __FUNCTION__);
- return 0;
- }
- saa7146_write(dev, DEBI_AD, av7110->debi_bus);
- saa7146_write(dev, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff));
-
- saa7146_write(dev, DEBI_CONFIG, config);
- saa7146_write(dev, MC2, (2 << 16) | 2);
- if (count > 4)
- return count;
- if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) {
- printk("%s: wait_for_debi_done #2 failed\n", __FUNCTION__);
- return 0;
- }
-
- result = saa7146_read(dev, DEBI_AD);
- result &= (0xffffffffUL >> ((4 - count) * 8));
- return result;
-}
-
-
-
-/* av7110 ARM core boot stuff */
-#if 0
-void av7110_reset_arm(struct av7110 *av7110)
-{
- saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTLO);
-
- /* Disable DEBI and GPIO irq */
- SAA7146_IER_DISABLE(av7110->dev, MASK_19 | MASK_03);
- SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
-
- saa7146_setgpio(av7110->dev, RESET_LINE, SAA7146_GPIO_OUTHI);
- msleep(30); /* the firmware needs some time to initialize */
-
- ARM_ResetMailBox(av7110);
-
- SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
- SAA7146_IER_ENABLE(av7110->dev, MASK_03);
-
- av7110->arm_ready = 1;
- dprintk(1, "reset ARM\n");
-}
-#endif /* 0 */
-
-static int waitdebi(struct av7110 *av7110, int adr, int state)
-{
- int k;
-
- dprintk(4, "%p\n", av7110);
-
- for (k = 0; k < 100; k++) {
- if (irdebi(av7110, DEBINOSWAP, adr, 0, 2) == state)
- return 0;
- udelay(5);
- }
- return -ETIMEDOUT;
-}
-
-static int load_dram(struct av7110 *av7110, u32 *data, int len)
-{
- int i;
- int blocks, rest;
- u32 base, bootblock = AV7110_BOOT_BLOCK;
-
- dprintk(4, "%p\n", av7110);
-
- blocks = len / AV7110_BOOT_MAX_SIZE;
- rest = len % AV7110_BOOT_MAX_SIZE;
- base = DRAM_START_CODE;
-
- for (i = 0; i < blocks; i++) {
- if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
- printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at block %d\n", i);
- return -ETIMEDOUT;
- }
- dprintk(4, "writing DRAM block %d\n", i);
- mwdebi(av7110, DEBISWAB, bootblock,
- ((char*)data) + i * AV7110_BOOT_MAX_SIZE, AV7110_BOOT_MAX_SIZE);
- bootblock ^= 0x1400;
- iwdebi(av7110, DEBISWAB, AV7110_BOOT_BASE, swab32(base), 4);
- iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, AV7110_BOOT_MAX_SIZE, 2);
- iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
- base += AV7110_BOOT_MAX_SIZE;
- }
-
- if (rest > 0) {
- if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
- printk(KERN_ERR "dvb-ttpci: load_dram(): timeout at last block\n");
- return -ETIMEDOUT;
- }
- if (rest > 4)
- mwdebi(av7110, DEBISWAB, bootblock,
- ((char*)data) + i * AV7110_BOOT_MAX_SIZE, rest);
- else
- mwdebi(av7110, DEBISWAB, bootblock,
- ((char*)data) + i * AV7110_BOOT_MAX_SIZE - 4, rest + 4);
-
- iwdebi(av7110, DEBISWAB, AV7110_BOOT_BASE, swab32(base), 4);
- iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, rest, 2);
- iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
- }
- if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_EMPTY) < 0) {
- printk(KERN_ERR "dvb-ttpci: load_dram(): timeout after last block\n");
- return -ETIMEDOUT;
- }
- iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_SIZE, 0, 2);
- iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
- if (waitdebi(av7110, AV7110_BOOT_STATE, BOOTSTATE_AV7110_BOOT_COMPLETE) < 0) {
- printk(KERN_ERR "dvb-ttpci: load_dram(): final handshake timeout\n");
- return -ETIMEDOUT;
- }
- return 0;
-}
-
-
-/* we cannot write av7110 DRAM directly, so load a bootloader into
- * the DPRAM which implements a simple boot protocol */
-static u8 bootcode[] = {
- 0xea, 0x00, 0x00, 0x0e, 0xe1, 0xb0, 0xf0, 0x0e, 0xe2, 0x5e, 0xf0, 0x04,
- 0xe2, 0x5e, 0xf0, 0x04, 0xe2, 0x5e, 0xf0, 0x08, 0xe2, 0x5e, 0xf0, 0x04,
- 0xe2, 0x5e, 0xf0, 0x04, 0xe2, 0x5e, 0xf0, 0x04, 0x2c, 0x00, 0x00, 0x24,
- 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x34,
- 0x00, 0x00, 0x00, 0x00, 0xa5, 0xa5, 0x5a, 0x5a, 0x00, 0x1f, 0x15, 0x55,
- 0x00, 0x00, 0x00, 0x09, 0xe5, 0x9f, 0xd0, 0x7c, 0xe5, 0x9f, 0x40, 0x74,
- 0xe3, 0xa0, 0x00, 0x00, 0xe5, 0x84, 0x00, 0x00, 0xe5, 0x84, 0x00, 0x04,
- 0xe5, 0x9f, 0x10, 0x70, 0xe5, 0x9f, 0x20, 0x70, 0xe5, 0x9f, 0x30, 0x64,
- 0xe8, 0xb1, 0x1f, 0xe0, 0xe8, 0xa3, 0x1f, 0xe0, 0xe1, 0x51, 0x00, 0x02,
- 0xda, 0xff, 0xff, 0xfb, 0xe5, 0x9f, 0xf0, 0x50, 0xe1, 0xd4, 0x10, 0xb0,
- 0xe3, 0x51, 0x00, 0x00, 0x0a, 0xff, 0xff, 0xfc, 0xe1, 0xa0, 0x10, 0x0d,
- 0xe5, 0x94, 0x30, 0x04, 0xe1, 0xd4, 0x20, 0xb2, 0xe2, 0x82, 0x20, 0x3f,
- 0xe1, 0xb0, 0x23, 0x22, 0x03, 0xa0, 0x00, 0x02, 0xe1, 0xc4, 0x00, 0xb0,
- 0x0a, 0xff, 0xff, 0xf4, 0xe8, 0xb1, 0x1f, 0xe0, 0xe8, 0xa3, 0x1f, 0xe0,
- 0xe8, 0xb1, 0x1f, 0xe0, 0xe8, 0xa3, 0x1f, 0xe0, 0xe2, 0x52, 0x20, 0x01,
- 0x1a, 0xff, 0xff, 0xf9, 0xe2, 0x2d, 0xdb, 0x05, 0xea, 0xff, 0xff, 0xec,
- 0x2c, 0x00, 0x03, 0xf8, 0x2c, 0x00, 0x04, 0x00, 0x9e, 0x00, 0x08, 0x00,
- 0x2c, 0x00, 0x00, 0x74, 0x2c, 0x00, 0x00, 0xc0
-};
-
-int av7110_bootarm(struct av7110 *av7110)
-{
- struct saa7146_dev *dev = av7110->dev;
- u32 ret;
- int i;
-
- dprintk(4, "%p\n", av7110);
-
- av7110->arm_ready = 0;
-
- saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO);
-
- /* Disable DEBI and GPIO irq */
- SAA7146_IER_DISABLE(av7110->dev, MASK_03 | MASK_19);
- SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
-
- /* enable DEBI */
- saa7146_write(av7110->dev, MC1, 0x08800880);
- saa7146_write(av7110->dev, DD1_STREAM_B, 0x00000000);
- saa7146_write(av7110->dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
-
- /* test DEBI */
- iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
- /* FIXME: Why does Nexus CA require 2x iwdebi for first init? */
- iwdebi(av7110, DEBISWAP, DPRAM_BASE, 0x76543210, 4);
-
- if ((ret=irdebi(av7110, DEBINOSWAP, DPRAM_BASE, 0, 4)) != 0x10325476) {
- printk(KERN_ERR "dvb-ttpci: debi test in av7110_bootarm() failed: "
- "%08x != %08x (check your BIOS 'Plug&Play OS' settings)\n",
- ret, 0x10325476);
- return -1;
- }
- for (i = 0; i < 8192; i += 4)
- iwdebi(av7110, DEBISWAP, DPRAM_BASE + i, 0x00, 4);
- dprintk(2, "debi test OK\n");
-
- /* boot */
- dprintk(1, "load boot code\n");
- saa7146_setgpio(dev, ARM_IRQ_LINE, SAA7146_GPIO_IRQLO);
- //saa7146_setgpio(dev, DEBI_DONE_LINE, SAA7146_GPIO_INPUT);
- //saa7146_setgpio(dev, 3, SAA7146_GPIO_INPUT);
-
- mwdebi(av7110, DEBISWAB, DPRAM_BASE, bootcode, sizeof(bootcode));
- iwdebi(av7110, DEBINOSWAP, AV7110_BOOT_STATE, BOOTSTATE_BUFFER_FULL, 2);
-
- if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
- printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
- "saa7146_wait_for_debi_done() timed out\n");
- return -ETIMEDOUT;
- }
- saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
- mdelay(1);
-
- dprintk(1, "load dram code\n");
- if (load_dram(av7110, (u32 *)av7110->bin_root, av7110->size_root) < 0) {
- printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
- "load_dram() failed\n");
- return -1;
- }
-
- saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTLO);
- mdelay(1);
-
- dprintk(1, "load dpram code\n");
- mwdebi(av7110, DEBISWAB, DPRAM_BASE, av7110->bin_dpram, av7110->size_dpram);
-
- if (saa7146_wait_for_debi_done(av7110->dev, 1)) {
- printk(KERN_ERR "dvb-ttpci: av7110_bootarm(): "
- "saa7146_wait_for_debi_done() timed out after loading DRAM\n");
- return -ETIMEDOUT;
- }
- saa7146_setgpio(dev, RESET_LINE, SAA7146_GPIO_OUTHI);
- msleep(30); /* the firmware needs some time to initialize */
-
- //ARM_ClearIrq(av7110);
- ARM_ResetMailBox(av7110);
- SAA7146_ISR_CLEAR(av7110->dev, MASK_19 | MASK_03);
- SAA7146_IER_ENABLE(av7110->dev, MASK_03);
-
- av7110->arm_errors = 0;
- av7110->arm_ready = 1;
- return 0;
-}
-
-
-/****************************************************************************
- * DEBI command polling
- ****************************************************************************/
-
-int av7110_wait_msgstate(struct av7110 *av7110, u16 flags)
-{
- unsigned long start;
- u32 stat;
- int err;
-
- if (FW_VERSION(av7110->arm_app) <= 0x261c) {
- /* not supported by old firmware */
- msleep(50);
- return 0;
- }
-
- /* new firmware */
- start = jiffies;
- for (;;) {
- err = time_after(jiffies, start + ARM_WAIT_FREE);
- if (mutex_lock_interruptible(&av7110->dcomlock))
- return -ERESTARTSYS;
- stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
- mutex_unlock(&av7110->dcomlock);
- if ((stat & flags) == 0)
- break;
- if (err) {
- printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n",
- __FUNCTION__, stat & flags);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
- return 0;
-}
-
-static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
-{
- int i;
- unsigned long start;
- char *type = NULL;
- u16 flags[2] = {0, 0};
- u32 stat;
- int err;
-
-// dprintk(4, "%p\n", av7110);
-
- if (!av7110->arm_ready) {
- dprintk(1, "arm not ready.\n");
- return -ENXIO;
- }
-
- start = jiffies;
- while (1) {
- err = time_after(jiffies, start + ARM_WAIT_FREE);
- if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
- break;
- if (err) {
- printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __FUNCTION__);
- av7110->arm_errors++;
- return -ETIMEDOUT;
- }
- msleep(1);
- }
-
- if (FW_VERSION(av7110->arm_app) <= 0x261f)
- wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0xffff, 2);
-
-#ifndef _NOHANDSHAKE
- start = jiffies;
- while (1) {
- err = time_after(jiffies, start + ARM_WAIT_SHAKE);
- if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
- break;
- if (err) {
- printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
-#endif
-
- switch ((buf[0] >> 8) & 0xff) {
- case COMTYPE_PIDFILTER:
- case COMTYPE_ENCODER:
- case COMTYPE_REC_PLAY:
- case COMTYPE_MPEGDECODER:
- type = "MSG";
- flags[0] = GPMQOver;
- flags[1] = GPMQFull;
- break;
- case COMTYPE_OSD:
- type = "OSD";
- flags[0] = OSDQOver;
- flags[1] = OSDQFull;
- break;
- case COMTYPE_MISC:
- if (FW_VERSION(av7110->arm_app) >= 0x261d) {
- type = "MSG";
- flags[0] = GPMQOver;
- flags[1] = GPMQBusy;
- }
- break;
- default:
- break;
- }
-
- if (type != NULL) {
- /* non-immediate COMMAND type */
- start = jiffies;
- for (;;) {
- err = time_after(jiffies, start + ARM_WAIT_FREE);
- stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
- if (stat & flags[0]) {
- printk(KERN_ERR "%s: %s QUEUE overflow\n",
- __FUNCTION__, type);
- return -1;
- }
- if ((stat & flags[1]) == 0)
- break;
- if (err) {
- printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n",
- __FUNCTION__, type);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
- }
-
- for (i = 2; i < length; i++)
- wdebi(av7110, DEBINOSWAP, COMMAND + 2 * i, (u32) buf[i], 2);
-
- if (length)
- wdebi(av7110, DEBINOSWAP, COMMAND + 2, (u32) buf[1], 2);
- else
- wdebi(av7110, DEBINOSWAP, COMMAND + 2, 0, 2);
-
- wdebi(av7110, DEBINOSWAP, COMMAND, (u32) buf[0], 2);
-
- if (FW_VERSION(av7110->arm_app) <= 0x261f)
- wdebi(av7110, DEBINOSWAP, COM_IF_LOCK, 0x0000, 2);
-
-#ifdef COM_DEBUG
- start = jiffies;
- while (1) {
- err = time_after(jiffies, start + ARM_WAIT_FREE);
- if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
- break;
- if (err) {
- printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND %d to complete\n",
- __FUNCTION__, (buf[0] >> 8) & 0xff);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
-
- stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
- if (stat & GPMQOver) {
- printk(KERN_ERR "dvb-ttpci: %s(): GPMQOver\n", __FUNCTION__);
- return -ENOSPC;
- }
- else if (stat & OSDQOver) {
- printk(KERN_ERR "dvb-ttpci: %s(): OSDQOver\n", __FUNCTION__);
- return -ENOSPC;
- }
-#endif
-
- return 0;
-}
-
-static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length)
-{
- int ret;
-
-// dprintk(4, "%p\n", av7110);
-
- if (!av7110->arm_ready) {
- dprintk(1, "arm not ready.\n");
- return -1;
- }
- if (mutex_lock_interruptible(&av7110->dcomlock))
- return -ERESTARTSYS;
-
- ret = __av7110_send_fw_cmd(av7110, buf, length);
- mutex_unlock(&av7110->dcomlock);
- if (ret && ret!=-ERESTARTSYS)
- printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n",
- __FUNCTION__, ret);
- return ret;
-}
-
-int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...)
-{
- va_list args;
- u16 buf[num + 2];
- int i, ret;
-
-// dprintk(4, "%p\n", av7110);
-
- buf[0] = ((type << 8) | com);
- buf[1] = num;
-
- if (num) {
- va_start(args, num);
- for (i = 0; i < num; i++)
- buf[i + 2] = va_arg(args, u32);
- va_end(args);
- }
-
- ret = av7110_send_fw_cmd(av7110, buf, num + 2);
- if (ret && ret != -ERESTARTSYS)
- printk(KERN_ERR "dvb-ttpci: av7110_fw_cmd error %d\n", ret);
- return ret;
-}
-
-#if 0
-int av7110_send_ci_cmd(struct av7110 *av7110, u8 subcom, u8 *buf, u8 len)
-{
- int i, ret;
- u16 cmd[18] = { ((COMTYPE_COMMON_IF << 8) + subcom),
- 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- dprintk(4, "%p\n", av7110);
-
- for(i = 0; i < len && i < 32; i++)
- {
- if(i % 2 == 0)
- cmd[(i / 2) + 2] = (u16)(buf[i]) << 8;
- else
- cmd[(i / 2) + 2] |= buf[i];
- }
-
- ret = av7110_send_fw_cmd(av7110, cmd, 18);
- if (ret && ret != -ERESTARTSYS)
- printk(KERN_ERR "dvb-ttpci: av7110_send_ci_cmd error %d\n", ret);
- return ret;
-}
-#endif /* 0 */
-
-int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
- int request_buf_len, u16 *reply_buf, int reply_buf_len)
-{
- int err;
- s16 i;
- unsigned long start;
-#ifdef COM_DEBUG
- u32 stat;
-#endif
-
- dprintk(4, "%p\n", av7110);
-
- if (!av7110->arm_ready) {
- dprintk(1, "arm not ready.\n");
- return -1;
- }
-
- if (mutex_lock_interruptible(&av7110->dcomlock))
- return -ERESTARTSYS;
-
- if ((err = __av7110_send_fw_cmd(av7110, request_buf, request_buf_len)) < 0) {
- mutex_unlock(&av7110->dcomlock);
- printk(KERN_ERR "dvb-ttpci: av7110_fw_request error %d\n", err);
- return err;
- }
-
- start = jiffies;
- while (1) {
- err = time_after(jiffies, start + ARM_WAIT_FREE);
- if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0)
- break;
- if (err) {
- printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__);
- mutex_unlock(&av7110->dcomlock);
- return -ETIMEDOUT;
- }
-#ifdef _NOHANDSHAKE
- msleep(1);
-#endif
- }
-
-#ifndef _NOHANDSHAKE
- start = jiffies;
- while (1) {
- err = time_after(jiffies, start + ARM_WAIT_SHAKE);
- if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
- break;
- if (err) {
- printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__);
- mutex_unlock(&av7110->dcomlock);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
-#endif
-
-#ifdef COM_DEBUG
- stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2);
- if (stat & GPMQOver) {
- printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__);
- mutex_unlock(&av7110->dcomlock);
- return -1;
- }
- else if (stat & OSDQOver) {
- printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__);
- mutex_unlock(&av7110->dcomlock);
- return -1;
- }
-#endif
-
- for (i = 0; i < reply_buf_len; i++)
- reply_buf[i] = rdebi(av7110, DEBINOSWAP, COM_BUFF + 2 * i, 0, 2);
-
- mutex_unlock(&av7110->dcomlock);
- return 0;
-}
-
-static int av7110_fw_query(struct av7110 *av7110, u16 tag, u16* buf, s16 length)
-{
- int ret;
- ret = av7110_fw_request(av7110, &tag, 0, buf, length);
- if (ret)
- printk(KERN_ERR "dvb-ttpci: av7110_fw_query error %d\n", ret);
- return ret;
-}
-
-
-/****************************************************************************
- * Firmware commands
- ****************************************************************************/
-
-/* get version of the firmware ROM, RTSL, video ucode and ARM application */
-int av7110_firmversion(struct av7110 *av7110)
-{
- u16 buf[20];
- u16 tag = ((COMTYPE_REQUEST << 8) + ReqVersion);
-
- dprintk(4, "%p\n", av7110);
-
- if (av7110_fw_query(av7110, tag, buf, 16)) {
- printk("dvb-ttpci: failed to boot firmware @ card %d\n",
- av7110->dvb_adapter.num);
- return -EIO;
- }
-
- av7110->arm_fw = (buf[0] << 16) + buf[1];
- av7110->arm_rtsl = (buf[2] << 16) + buf[3];
- av7110->arm_vid = (buf[4] << 16) + buf[5];
- av7110->arm_app = (buf[6] << 16) + buf[7];
- av7110->avtype = (buf[8] << 16) + buf[9];
-
- printk("dvb-ttpci: info @ card %d: firm %08x, rtsl %08x, vid %08x, app %08x\n",
- av7110->dvb_adapter.num, av7110->arm_fw,
- av7110->arm_rtsl, av7110->arm_vid, av7110->arm_app);
-
- /* print firmware capabilities */
- if (FW_CI_LL_SUPPORT(av7110->arm_app))
- printk("dvb-ttpci: firmware @ card %d supports CI link layer interface\n",
- av7110->dvb_adapter.num);
- else
- printk("dvb-ttpci: no firmware support for CI link layer interface @ card %d\n",
- av7110->dvb_adapter.num);
-
- return 0;
-}
-
-
-int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long burst)
-{
- int i, ret;
- u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) + SendDiSEqC),
- 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- dprintk(4, "%p\n", av7110);
-
- if (len > 10)
- len = 10;
-
- buf[1] = len + 2;
- buf[2] = len;
-
- if (burst != -1)
- buf[3] = burst ? 0x01 : 0x00;
- else
- buf[3] = 0xffff;
-
- for (i = 0; i < len; i++)
- buf[i + 4] = msg[i];
-
- ret = av7110_send_fw_cmd(av7110, buf, 18);
- if (ret && ret!=-ERESTARTSYS)
- printk(KERN_ERR "dvb-ttpci: av7110_diseqc_send error %d\n", ret);
- return ret;
-}
-
-
-#ifdef CONFIG_DVB_AV7110_OSD
-
-static inline int SetColorBlend(struct av7110 *av7110, u8 windownr)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, SetCBlend, 1, windownr);
-}
-
-static inline int SetBlend_(struct av7110 *av7110, u8 windownr,
- enum av7110_osd_palette_type colordepth, u16 index, u8 blending)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, SetBlend, 4,
- windownr, colordepth, index, blending);
-}
-
-static inline int SetColor_(struct av7110 *av7110, u8 windownr,
- enum av7110_osd_palette_type colordepth, u16 index, u16 colorhi, u16 colorlo)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, SetColor, 5,
- windownr, colordepth, index, colorhi, colorlo);
-}
-
-static inline int SetFont(struct av7110 *av7110, u8 windownr, u8 fontsize,
- u16 colorfg, u16 colorbg)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, Set_Font, 4,
- windownr, fontsize, colorfg, colorbg);
-}
-
-static int FlushText(struct av7110 *av7110)
-{
- unsigned long start;
- int err;
-
- if (mutex_lock_interruptible(&av7110->dcomlock))
- return -ERESTARTSYS;
- start = jiffies;
- while (1) {
- err = time_after(jiffies, start + ARM_WAIT_OSD);
- if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0)
- break;
- if (err) {
- printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n",
- __FUNCTION__);
- mutex_unlock(&av7110->dcomlock);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
- mutex_unlock(&av7110->dcomlock);
- return 0;
-}
-
-static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, u8* buf)
-{
- int i, ret;
- unsigned long start;
- int length = strlen(buf) + 1;
- u16 cbuf[5] = { (COMTYPE_OSD << 8) + DText, 3, win, x, y };
-
- if (mutex_lock_interruptible(&av7110->dcomlock))
- return -ERESTARTSYS;
-
- start = jiffies;
- while (1) {
- ret = time_after(jiffies, start + ARM_WAIT_OSD);
- if (rdebi(av7110, DEBINOSWAP, BUFF1_BASE, 0, 2) == 0)
- break;
- if (ret) {
- printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n",
- __FUNCTION__);
- mutex_unlock(&av7110->dcomlock);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
-#ifndef _NOHANDSHAKE
- start = jiffies;
- while (1) {
- ret = time_after(jiffies, start + ARM_WAIT_SHAKE);
- if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0)
- break;
- if (ret) {
- printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n",
- __FUNCTION__);
- mutex_unlock(&av7110->dcomlock);
- return -ETIMEDOUT;
- }
- msleep(1);
- }
-#endif
- for (i = 0; i < length / 2; i++)
- wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2,
- swab16(*(u16 *)(buf + 2 * i)), 2);
- if (length & 1)
- wdebi(av7110, DEBINOSWAP, BUFF1_BASE + i * 2, 0, 2);
- ret = __av7110_send_fw_cmd(av7110, cbuf, 5);
- mutex_unlock(&av7110->dcomlock);
- if (ret && ret!=-ERESTARTSYS)
- printk(KERN_ERR "dvb-ttpci: WriteText error %d\n", ret);
- return ret;
-}
-
-static inline int DrawLine(struct av7110 *av7110, u8 windownr,
- u16 x, u16 y, u16 dx, u16 dy, u16 color)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, DLine, 6,
- windownr, x, y, dx, dy, color);
-}
-
-static inline int DrawBlock(struct av7110 *av7110, u8 windownr,
- u16 x, u16 y, u16 dx, u16 dy, u16 color)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, DBox, 6,
- windownr, x, y, dx, dy, color);
-}
-
-static inline int HideWindow(struct av7110 *av7110, u8 windownr)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, WHide, 1, windownr);
-}
-
-static inline int MoveWindowRel(struct av7110 *av7110, u8 windownr, u16 x, u16 y)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, WMoveD, 3, windownr, x, y);
-}
-
-static inline int MoveWindowAbs(struct av7110 *av7110, u8 windownr, u16 x, u16 y)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, WMoveA, 3, windownr, x, y);
-}
-
-static inline int DestroyOSDWindow(struct av7110 *av7110, u8 windownr)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, WDestroy, 1, windownr);
-}
-
-static inline int CreateOSDWindow(struct av7110 *av7110, u8 windownr,
- osd_raw_window_t disptype,
- u16 width, u16 height)
-{
- return av7110_fw_cmd(av7110, COMTYPE_OSD, WCreate, 4,
- windownr, disptype, width, height);
-}
-
-
-static enum av7110_osd_palette_type bpp2pal[8] = {
- Pal1Bit, Pal2Bit, 0, Pal4Bit, 0, 0, 0, Pal8Bit
-};
-static osd_raw_window_t bpp2bit[8] = {
- OSD_BITMAP1, OSD_BITMAP2, 0, OSD_BITMAP4, 0, 0, 0, OSD_BITMAP8
-};
-
-static inline int WaitUntilBmpLoaded(struct av7110 *av7110)
-{
- int ret = wait_event_interruptible_timeout(av7110->bmpq,
- av7110->bmp_state != BMP_LOADING, 10*HZ);
- if (ret == -ERESTARTSYS)
- return ret;
- if (ret == 0) {
- printk("dvb-ttpci: warning: timeout waiting in LoadBitmap: %d, %d\n",
- ret, av7110->bmp_state);
- av7110->bmp_state = BMP_NONE;
- return -ETIMEDOUT;
- }
- return 0;
-}
-
-static inline int LoadBitmap(struct av7110 *av7110,
- u16 dx, u16 dy, int inc, u8 __user * data)
-{
- u16 format;
- int bpp;
- int i;
- int d, delta;
- u8 c;
- int ret;
-
- dprintk(4, "%p\n", av7110);
-
- format = bpp2bit[av7110->osdbpp[av7110->osdwin]];
-
- av7110->bmp_state = BMP_LOADING;
- if (format == OSD_BITMAP8) {
- bpp=8; delta = 1;
- } else if (format == OSD_BITMAP4) {
- bpp=4; delta = 2;
- } else if (format == OSD_BITMAP2) {
- bpp=2; delta = 4;
- } else if (format == OSD_BITMAP1) {
- bpp=1; delta = 8;
- } else {
- av7110->bmp_state = BMP_NONE;
- return -EINVAL;
- }
- av7110->bmplen = ((dx * dy * bpp + 7) & ~7) / 8;
- av7110->bmpp = 0;
- if (av7110->bmplen > 32768) {
- av7110->bmp_state = BMP_NONE;
- return -EINVAL;
- }
- for (i = 0; i < dy; i++) {
- if (copy_from_user(av7110->bmpbuf + 1024 + i * dx, data + i * inc, dx)) {
- av7110->bmp_state = BMP_NONE;
- return -EINVAL;
- }
- }
- if (format != OSD_BITMAP8) {
- for (i = 0; i < dx * dy / delta; i++) {
- c = ((u8 *)av7110->bmpbuf)[1024 + i * delta + delta - 1];
- for (d = delta - 2; d >= 0; d--) {
- c |= (((u8 *)av7110->bmpbuf)[1024 + i * delta + d]
- << ((delta - d - 1) * bpp));
- ((u8 *)av7110->bmpbuf)[1024 + i] = c;
- }
- }
- }
- av7110->bmplen += 1024;
- dprintk(4, "av7110_fw_cmd: LoadBmp size %d\n", av7110->bmplen);
- ret = av7110_fw_cmd(av7110, COMTYPE_OSD, LoadBmp, 3, format, dx, dy);
- if (!ret)
- ret = WaitUntilBmpLoaded(av7110);
- return ret;
-}
-
-static int BlitBitmap(struct av7110 *av7110, u16 x, u16 y)
-{
- dprintk(4, "%p\n", av7110);
-
- return av7110_fw_cmd(av7110, COMTYPE_OSD, BlitBmp, 4, av7110->osdwin, x, y, 0);
-}
-
-static inline int ReleaseBitmap(struct av7110 *av7110)
-{
- dprintk(4, "%p\n", av7110);
-
- if (av7110->bmp_state != BMP_LOADED && FW_VERSION(av7110->arm_app) < 0x261e)
- return -1;
- if (av7110->bmp_state == BMP_LOADING)
- dprintk(1,"ReleaseBitmap called while BMP_LOADING\n");
- av7110->bmp_state = BMP_NONE;
- return av7110_fw_cmd(av7110, COMTYPE_OSD, ReleaseBmp, 0);
-}
-
-static u32 RGB2YUV(u16 R, u16 G, u16 B)
-{
- u16 y, u, v;
- u16 Y, Cr, Cb;
-
- y = R * 77 + G * 150 + B * 29; /* Luma=0.299R+0.587G+0.114B 0..65535 */
- u = 2048 + B * 8 -(y >> 5); /* Cr 0..4095 */
- v = 2048 + R * 8 -(y >> 5); /* Cb 0..4095 */
-
- Y = y / 256;
- Cb = u / 16;
- Cr = v / 16;
-
- return Cr | (Cb << 16) | (Y << 8);
-}
-
-static int OSDSetColor(struct av7110 *av7110, u8 color, u8 r, u8 g, u8 b, u8 blend)
-{
- int ret;
-
- u16 ch, cl;
- u32 yuv;
-
- yuv = blend ? RGB2YUV(r,g,b) : 0;
- cl = (yuv & 0xffff);
- ch = ((yuv >> 16) & 0xffff);
- ret = SetColor_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
- color, ch, cl);
- if (!ret)
- ret = SetBlend_(av7110, av7110->osdwin, bpp2pal[av7110->osdbpp[av7110->osdwin]],
- color, ((blend >> 4) & 0x0f));
- return ret;
-}
-
-static int OSDSetPalette(struct av7110 *av7110, u32 __user * colors, u8 first, u8 last)
-{
- int i;
- int length = last - first + 1;
-
- if (length * 4 > DATA_BUFF3_SIZE)
- return -EINVAL;
-
- for (i = 0; i < length; i++) {
- u32 color, blend, yuv;
-
- if (get_user(color, colors + i))
- return -EFAULT;
- blend = (color & 0xF0000000) >> 4;
- yuv = blend ? RGB2YUV(color & 0xFF, (color >> 8) & 0xFF,
- (color >> 16) & 0xFF) | blend : 0;
- yuv = ((yuv & 0xFFFF0000) >> 16) | ((yuv & 0x0000FFFF) << 16);
- wdebi(av7110, DEBINOSWAP, DATA_BUFF3_BASE + i * 4, yuv, 4);
- }
- return av7110_fw_cmd(av7110, COMTYPE_OSD, Set_Palette, 4,
- av7110->osdwin,
- bpp2pal[av7110->osdbpp[av7110->osdwin]],
- first, last);
-}
-
-static int OSDSetBlock(struct av7110 *av7110, int x0, int y0,
- int x1, int y1, int inc, u8 __user * data)
-{
- uint w, h, bpp, bpl, size, lpb, bnum, brest;
- int i;
- int rc,release_rc;
-
- w = x1 - x0 + 1;
- h = y1 - y0 + 1;
- if (inc <= 0)
- inc = w;
- if (w <= 0 || w > 720 || h <= 0 || h > 576)
- return -EINVAL;
- bpp = av7110->osdbpp[av7110->osdwin] + 1;
- bpl = ((w * bpp + 7) & ~7) / 8;
- size = h * bpl;
- lpb = (32 * 1024) / bpl;
- bnum = size / (lpb * bpl);
- brest = size - bnum * lpb * bpl;
-
- if (av7110->bmp_state == BMP_LOADING) {
- /* possible if syscall is repeated by -ERESTARTSYS and if firmware cannot abort */
- BUG_ON (FW_VERSION(av7110->arm_app) >= 0x261e);
- rc = WaitUntilBmpLoaded(av7110);
- if (rc)
- return rc;
- /* just continue. This should work for all fw versions
- * if bnum==1 && !brest && LoadBitmap was successful
- */
- }
-
- rc = 0;
- for (i = 0; i < bnum; i++) {
- rc = LoadBitmap(av7110, w, lpb, inc, data);
- if (rc)
- break;
- rc = BlitBitmap(av7110, x0, y0 + i * lpb);
- if (rc)
- break;
- data += lpb * inc;
- }
- if (!rc && brest) {
- rc = LoadBitmap(av7110, w, brest / bpl, inc, data);
- if (!rc)
- rc = BlitBitmap(av7110, x0, y0 + bnum * lpb);
- }
- release_rc = ReleaseBitmap(av7110);
- if (!rc)
- rc = release_rc;
- if (rc)
- dprintk(1,"returns %d\n",rc);
- return rc;
-}
-
-int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
-{
- int ret;
-
- if (mutex_lock_interruptible(&av7110->osd_mutex))
- return -ERESTARTSYS;
-
- switch (dc->cmd) {
- case OSD_Close:
- ret = DestroyOSDWindow(av7110, av7110->osdwin);
- break;
- case OSD_Open:
- av7110->osdbpp[av7110->osdwin] = (dc->color - 1) & 7;
- ret = CreateOSDWindow(av7110, av7110->osdwin,
- bpp2bit[av7110->osdbpp[av7110->osdwin]],
- dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1);
- if (ret)
- break;
- if (!dc->data) {
- ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
- if (ret)
- break;
- ret = SetColorBlend(av7110, av7110->osdwin);
- }
- break;
- case OSD_Show:
- ret = MoveWindowRel(av7110, av7110->osdwin, 0, 0);
- break;
- case OSD_Hide:
- ret = HideWindow(av7110, av7110->osdwin);
- break;
- case OSD_Clear:
- ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, 0);
- break;
- case OSD_Fill:
- ret = DrawBlock(av7110, av7110->osdwin, 0, 0, 720, 576, dc->color);
- break;
- case OSD_SetColor:
- ret = OSDSetColor(av7110, dc->color, dc->x0, dc->y0, dc->x1, dc->y1);
- break;
- case OSD_SetPalette:
- if (FW_VERSION(av7110->arm_app) >= 0x2618)
- ret = OSDSetPalette(av7110, dc->data, dc->color, dc->x0);
- else {
- int i, len = dc->x0-dc->color+1;
- u8 __user *colors = (u8 __user *)dc->data;
- u8 r, g, b, blend;
- ret = 0;
- for (i = 0; i<len; i++) {
- if (get_user(r, colors + i * 4) ||
- get_user(g, colors + i * 4 + 1) ||
- get_user(b, colors + i * 4 + 2) ||
- get_user(blend, colors + i * 4 + 3)) {
- ret = -EFAULT;
- break;
- }
- ret = OSDSetColor(av7110, dc->color + i, r, g, b, blend);
- if (ret)
- break;
- }
- }
- break;
- case OSD_SetPixel:
- ret = DrawLine(av7110, av7110->osdwin,
- dc->x0, dc->y0, 0, 0, dc->color);
- break;
- case OSD_SetRow:
- dc->y1 = dc->y0;
- /* fall through */
- case OSD_SetBlock:
- ret = OSDSetBlock(av7110, dc->x0, dc->y0, dc->x1, dc->y1, dc->color, dc->data);
- break;
- case OSD_FillRow:
- ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
- dc->x1-dc->x0+1, dc->y1, dc->color);
- break;
- case OSD_FillBlock:
- ret = DrawBlock(av7110, av7110->osdwin, dc->x0, dc->y0,
- dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1, dc->color);
- break;
- case OSD_Line:
- ret = DrawLine(av7110, av7110->osdwin,
- dc->x0, dc->y0, dc->x1 - dc->x0, dc->y1 - dc->y0, dc->color);
- break;
- case OSD_Text:
- {
- char textbuf[240];
-
- if (strncpy_from_user(textbuf, dc->data, 240) < 0) {
- ret = -EFAULT;
- break;
- }
- textbuf[239] = 0;
- if (dc->x1 > 3)
- dc->x1 = 3;
- ret = SetFont(av7110, av7110->osdwin, dc->x1,
- (u16) (dc->color & 0xffff), (u16) (dc->color >> 16));
- if (!ret)
- ret = FlushText(av7110);
- if (!ret)
- ret = WriteText(av7110, av7110->osdwin, dc->x0, dc->y0, textbuf);
- break;
- }
- case OSD_SetWindow:
- if (dc->x0 < 1 || dc->x0 > 7)
- ret = -EINVAL;
- else {
- av7110->osdwin = dc->x0;
- ret = 0;
- }
- break;
- case OSD_MoveWindow:
- ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
- if (!ret)
- ret = SetColorBlend(av7110, av7110->osdwin);
- break;
- case OSD_OpenRaw:
- if (dc->color < OSD_BITMAP1 || dc->color > OSD_CURSOR) {
- ret = -EINVAL;
- break;
- }
- if (dc->color >= OSD_BITMAP1 && dc->color <= OSD_BITMAP8HR)
- av7110->osdbpp[av7110->osdwin] = (1 << (dc->color & 3)) - 1;
- else
- av7110->osdbpp[av7110->osdwin] = 0;
- ret = CreateOSDWindow(av7110, av7110->osdwin, (osd_raw_window_t)dc->color,
- dc->x1 - dc->x0 + 1, dc->y1 - dc->y0 + 1);
- if (ret)
- break;
- if (!dc->data) {
- ret = MoveWindowAbs(av7110, av7110->osdwin, dc->x0, dc->y0);
- if (!ret)
- ret = SetColorBlend(av7110, av7110->osdwin);
- }
- break;
- default:
- ret = -EINVAL;
- break;
- }
-
- mutex_unlock(&av7110->osd_mutex);
- if (ret==-ERESTARTSYS)
- dprintk(1, "av7110_osd_cmd(%d) returns with -ERESTARTSYS\n",dc->cmd);
- else if (ret)
- dprintk(1, "av7110_osd_cmd(%d) returns with %d\n",dc->cmd,ret);
-
- return ret;
-}
-
-int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap)
-{
- switch (cap->cmd) {
- case OSD_CAP_MEMSIZE:
- if (FW_4M_SDRAM(av7110->arm_app))
- cap->val = 1000000;
- else
- cap->val = 92000;
- return 0;
- default:
- return -EINVAL;
- }
-}
-#endif /* CONFIG_DVB_AV7110_OSD */
diff --git a/drivers/media/dvb/ttpci/av7110_hw.h b/drivers/media/dvb/ttpci/av7110_hw.h
deleted file mode 100644
index 4e173c67fbb..00000000000
--- a/drivers/media/dvb/ttpci/av7110_hw.h
+++ /dev/null
@@ -1,497 +0,0 @@
-#ifndef _AV7110_HW_H_
-#define _AV7110_HW_H_
-
-#include "av7110.h"
-
-/* DEBI transfer mode defs */
-
-#define DEBINOSWAP 0x000e0000
-#define DEBISWAB 0x001e0000
-#define DEBISWAP 0x002e0000
-
-#define ARM_WAIT_FREE (HZ)
-#define ARM_WAIT_SHAKE (HZ/5)
-#define ARM_WAIT_OSD (HZ)
-
-
-enum av7110_bootstate
-{
- BOOTSTATE_BUFFER_EMPTY = 0,
- BOOTSTATE_BUFFER_FULL = 1,
- BOOTSTATE_AV7110_BOOT_COMPLETE = 2
-};
-
-enum av7110_type_rec_play_format
-{ RP_None,
- AudioPES,
- AudioMp2,
- AudioPCM,
- VideoPES,
- AV_PES
-};
-
-enum av7110_osd_palette_type
-{
- NoPalet = 0, /* No palette */
- Pal1Bit = 2, /* 2 colors for 1 Bit Palette */
- Pal2Bit = 4, /* 4 colors for 2 bit palette */
- Pal4Bit = 16, /* 16 colors for 4 bit palette */
- Pal8Bit = 256 /* 256 colors for 16 bit palette */
-};
-
-/* switch defines */
-#define SB_GPIO 3
-#define SB_OFF SAA7146_GPIO_OUTLO /* SlowBlank off (TV-Mode) */
-#define SB_ON SAA7146_GPIO_INPUT /* SlowBlank on (AV-Mode) */
-#define SB_WIDE SAA7146_GPIO_OUTHI /* SlowBlank 6V (16/9-Mode) (not implemented) */
-
-#define FB_GPIO 1
-#define FB_OFF SAA7146_GPIO_LO /* FastBlank off (CVBS-Mode) */
-#define FB_ON SAA7146_GPIO_OUTHI /* FastBlank on (RGB-Mode) */
-#define FB_LOOP SAA7146_GPIO_INPUT /* FastBlank loop-through (PC graphics ???) */
-
-enum av7110_video_output_mode
-{
- NO_OUT = 0, /* disable analog output */
- CVBS_RGB_OUT = 1,
- CVBS_YC_OUT = 2,
- YC_OUT = 3
-};
-
-/* firmware internal msg q status: */
-#define GPMQFull 0x0001 /* Main Message Queue Full */
-#define GPMQOver 0x0002 /* Main Message Queue Overflow */
-#define HPQFull 0x0004 /* High Priority Msg Queue Full */
-#define HPQOver 0x0008
-#define OSDQFull 0x0010 /* OSD Queue Full */
-#define OSDQOver 0x0020
-#define GPMQBusy 0x0040 /* Queue not empty, FW >= 261d */
-#define HPQBusy 0x0080
-#define OSDQBusy 0x0100
-
-/* hw section filter flags */
-#define SECTION_EIT 0x01
-#define SECTION_SINGLE 0x00
-#define SECTION_CYCLE 0x02
-#define SECTION_CONTINUOS 0x04
-#define SECTION_MODE 0x06
-#define SECTION_IPMPE 0x0C /* size up to 4k */
-#define SECTION_HIGH_SPEED 0x1C /* larger buffer */
-#define DATA_PIPING_FLAG 0x20 /* for Data Piping Filter */
-
-#define PBUFSIZE_NONE 0x0000
-#define PBUFSIZE_1P 0x0100
-#define PBUFSIZE_2P 0x0200
-#define PBUFSIZE_1K 0x0300
-#define PBUFSIZE_2K 0x0400
-#define PBUFSIZE_4K 0x0500
-#define PBUFSIZE_8K 0x0600
-#define PBUFSIZE_16K 0x0700
-#define PBUFSIZE_32K 0x0800
-
-
-/* firmware command codes */
-enum av7110_osd_command {
- WCreate,
- WDestroy,
- WMoveD,
- WMoveA,
- WHide,
- WTop,
- DBox,
- DLine,
- DText,
- Set_Font,
- SetColor,
- SetBlend,
- SetWBlend,
- SetCBlend,
- SetNonBlend,
- LoadBmp,
- BlitBmp,
- ReleaseBmp,
- SetWTrans,
- SetWNoTrans,
- Set_Palette
-};
-
-enum av7110_pid_command {
- MultiPID,
- VideoPID,
- AudioPID,
- InitFilt,
- FiltError,
- NewVersion,
- CacheError,
- AddPIDFilter,
- DelPIDFilter,
- Scan,
- SetDescr,
- SetIR,
- FlushTSQueue
-};
-
-enum av7110_mpeg_command {
- SelAudChannels
-};
-
-enum av7110_audio_command {
- AudioDAC,
- CabADAC,
- ON22K,
- OFF22K,
- MainSwitch,
- ADSwitch,
- SendDiSEqC,
- SetRegister,
- SpdifSwitch
-};
-
-enum av7110_request_command {
- AudioState,
- AudioBuffState,
- VideoState1,
- VideoState2,
- VideoState3,
- CrashCounter,
- ReqVersion,
- ReqVCXO,
- ReqRegister,
- ReqSecFilterError,
- ReqSTC
-};
-
-enum av7110_encoder_command {
- SetVidMode,
- SetTestMode,
- LoadVidCode,
- SetMonitorType,
- SetPanScanType,
- SetFreezeMode,
- SetWSSConfig
-};
-
-enum av7110_rec_play_state {
- __Record,
- __Stop,
- __Play,
- __Pause,
- __Slow,
- __FF_IP,
- __Scan_I,
- __Continue
-};
-
-enum av7110_fw_cmd_misc {
- AV7110_FW_VIDEO_ZOOM = 1,
- AV7110_FW_VIDEO_COMMAND,
- AV7110_FW_AUDIO_COMMAND
-};
-
-enum av7110_command_type {
- COMTYPE_NOCOM,
- COMTYPE_PIDFILTER,
- COMTYPE_MPEGDECODER,
- COMTYPE_OSD,
- COMTYPE_BMP,
- COMTYPE_ENCODER,
- COMTYPE_AUDIODAC,
- COMTYPE_REQUEST,
- COMTYPE_SYSTEM,
- COMTYPE_REC_PLAY,
- COMTYPE_COMMON_IF,
- COMTYPE_PID_FILTER,
- COMTYPE_PES,
- COMTYPE_TS,
- COMTYPE_VIDEO,
- COMTYPE_AUDIO,
- COMTYPE_CI_LL,
- COMTYPE_MISC = 0x80
-};
-
-#define VID_NONE_PREF 0x00 /* No aspect ration processing preferred */
-#define VID_PAN_SCAN_PREF 0x01 /* Pan and Scan Display preferred */
-#define VID_VERT_COMP_PREF 0x02 /* Vertical compression display preferred */
-#define VID_VC_AND_PS_PREF 0x03 /* PanScan and vertical Compression if allowed */
-#define VID_CENTRE_CUT_PREF 0x05 /* PanScan with zero vector */
-
-/* MPEG video decoder commands */
-#define VIDEO_CMD_STOP 0x000e
-#define VIDEO_CMD_PLAY 0x000d
-#define VIDEO_CMD_FREEZE 0x0102
-#define VIDEO_CMD_FFWD 0x0016
-#define VIDEO_CMD_SLOW 0x0022
-
-/* MPEG audio decoder commands */
-#define AUDIO_CMD_MUTE 0x0001
-#define AUDIO_CMD_UNMUTE 0x0002
-#define AUDIO_CMD_PCM16 0x0010
-#define AUDIO_CMD_STEREO 0x0080
-#define AUDIO_CMD_MONO_L 0x0100
-#define AUDIO_CMD_MONO_R 0x0200
-#define AUDIO_CMD_SYNC_OFF 0x000e
-#define AUDIO_CMD_SYNC_ON 0x000f
-
-/* firmware data interface codes */
-#define DATA_NONE 0x00
-#define DATA_FSECTION 0x01
-#define DATA_IPMPE 0x02
-#define DATA_MPEG_RECORD 0x03
-#define DATA_DEBUG_MESSAGE 0x04
-#define DATA_COMMON_INTERFACE 0x05
-#define DATA_MPEG_PLAY 0x06
-#define DATA_BMP_LOAD 0x07
-#define DATA_IRCOMMAND 0x08
-#define DATA_PIPING 0x09
-#define DATA_STREAMING 0x0a
-#define DATA_CI_GET 0x0b
-#define DATA_CI_PUT 0x0c
-#define DATA_MPEG_VIDEO_EVENT 0x0d
-
-#define DATA_PES_RECORD 0x10
-#define DATA_PES_PLAY 0x11
-#define DATA_TS_RECORD 0x12
-#define DATA_TS_PLAY 0x13
-
-/* ancient CI command codes, only two are actually still used
- * by the link level CI firmware */
-#define CI_CMD_ERROR 0x00
-#define CI_CMD_ACK 0x01
-#define CI_CMD_SYSTEM_READY 0x02
-#define CI_CMD_KEYPRESS 0x03
-#define CI_CMD_ON_TUNED 0x04
-#define CI_CMD_ON_SWITCH_PROGRAM 0x05
-#define CI_CMD_SECTION_ARRIVED 0x06
-#define CI_CMD_SECTION_TIMEOUT 0x07
-#define CI_CMD_TIME 0x08
-#define CI_CMD_ENTER_MENU 0x09
-#define CI_CMD_FAST_PSI 0x0a
-#define CI_CMD_GET_SLOT_INFO 0x0b
-
-#define CI_MSG_NONE 0x00
-#define CI_MSG_CI_INFO 0x01
-#define CI_MSG_MENU 0x02
-#define CI_MSG_LIST 0x03
-#define CI_MSG_TEXT 0x04
-#define CI_MSG_REQUEST_INPUT 0x05
-#define CI_MSG_INPUT_COMPLETE 0x06
-#define CI_MSG_LIST_MORE 0x07
-#define CI_MSG_MENU_MORE 0x08
-#define CI_MSG_CLOSE_MMI_IMM 0x09
-#define CI_MSG_SECTION_REQUEST 0x0a
-#define CI_MSG_CLOSE_FILTER 0x0b
-#define CI_PSI_COMPLETE 0x0c
-#define CI_MODULE_READY 0x0d
-#define CI_SWITCH_PRG_REPLY 0x0e
-#define CI_MSG_TEXT_MORE 0x0f
-
-#define CI_MSG_CA_PMT 0xe0
-#define CI_MSG_ERROR 0xf0
-
-
-/* base address of the dual ported RAM which serves as communication
- * area between PCI bus and av7110,
- * as seen by the DEBI bus of the saa7146 */
-#define DPRAM_BASE 0x4000
-
-/* boot protocol area */
-#define AV7110_BOOT_STATE (DPRAM_BASE + 0x3F8)
-#define AV7110_BOOT_SIZE (DPRAM_BASE + 0x3FA)
-#define AV7110_BOOT_BASE (DPRAM_BASE + 0x3FC)
-#define AV7110_BOOT_BLOCK (DPRAM_BASE + 0x400)
-#define AV7110_BOOT_MAX_SIZE 0xc00
-
-/* firmware command protocol area */
-#define IRQ_STATE (DPRAM_BASE + 0x0F4)
-#define IRQ_STATE_EXT (DPRAM_BASE + 0x0F6)
-#define MSGSTATE (DPRAM_BASE + 0x0F8)
-#define FILT_STATE (DPRAM_BASE + 0x0FA)
-#define COMMAND (DPRAM_BASE + 0x0FC)
-#define COM_BUFF (DPRAM_BASE + 0x100)
-#define COM_BUFF_SIZE 0x20
-
-/* various data buffers */
-#define BUFF1_BASE (DPRAM_BASE + 0x120)
-#define BUFF1_SIZE 0xE0
-
-#define DATA_BUFF0_BASE (DPRAM_BASE + 0x200)
-#define DATA_BUFF0_SIZE 0x0800
-
-#define DATA_BUFF1_BASE (DATA_BUFF0_BASE+DATA_BUFF0_SIZE)
-#define DATA_BUFF1_SIZE 0x0800
-
-#define DATA_BUFF2_BASE (DATA_BUFF1_BASE+DATA_BUFF1_SIZE)
-#define DATA_BUFF2_SIZE 0x0800
-
-#define DATA_BUFF3_BASE (DATA_BUFF2_BASE+DATA_BUFF2_SIZE)
-#define DATA_BUFF3_SIZE 0x0400
-
-#define Reserved (DPRAM_BASE + 0x1E00)
-#define Reserved_SIZE 0x1C0
-
-
-/* firmware status area */
-#define STATUS_BASE (DPRAM_BASE + 0x1FC0)
-#define STATUS_SCR (STATUS_BASE + 0x00)
-#define STATUS_MODES (STATUS_BASE + 0x04)
-#define STATUS_LOOPS (STATUS_BASE + 0x08)
-
-#define STATUS_MPEG_WIDTH (STATUS_BASE + 0x0C)
-/* ((aspect_ratio & 0xf) << 12) | (height & 0xfff) */
-#define STATUS_MPEG_HEIGHT_AR (STATUS_BASE + 0x0E)
-
-/* firmware data protocol area */
-#define RX_TYPE (DPRAM_BASE + 0x1FE8)
-#define RX_LEN (DPRAM_BASE + 0x1FEA)
-#define TX_TYPE (DPRAM_BASE + 0x1FEC)
-#define TX_LEN (DPRAM_BASE + 0x1FEE)
-
-#define RX_BUFF (DPRAM_BASE + 0x1FF4)
-#define TX_BUFF (DPRAM_BASE + 0x1FF6)
-
-#define HANDSHAKE_REG (DPRAM_BASE + 0x1FF8)
-#define COM_IF_LOCK (DPRAM_BASE + 0x1FFA)
-
-#define IRQ_RX (DPRAM_BASE + 0x1FFC)
-#define IRQ_TX (DPRAM_BASE + 0x1FFE)
-
-/* used by boot protocol to load firmware into av7110 DRAM */
-#define DRAM_START_CODE 0x2e000404
-#define DRAM_MAX_CODE_SIZE 0x00100000
-
-/* saa7146 gpio lines */
-#define RESET_LINE 2
-#define DEBI_DONE_LINE 1
-#define ARM_IRQ_LINE 0
-
-
-
-extern int av7110_bootarm(struct av7110 *av7110);
-extern int av7110_firmversion(struct av7110 *av7110);
-#define FW_CI_LL_SUPPORT(arm_app) ((arm_app) & 0x80000000)
-#define FW_4M_SDRAM(arm_app) ((arm_app) & 0x40000000)
-#define FW_VERSION(arm_app) ((arm_app) & 0x0000FFFF)
-
-extern int av7110_wait_msgstate(struct av7110 *av7110, u16 flags);
-extern int av7110_fw_cmd(struct av7110 *av7110, int type, int com, int num, ...);
-extern int av7110_fw_request(struct av7110 *av7110, u16 *request_buf,
- int request_buf_len, u16 *reply_buf, int reply_buf_len);
-
-
-/* DEBI (saa7146 data extension bus interface) access */
-extern int av7110_debiwrite(struct av7110 *av7110, u32 config,
- int addr, u32 val, int count);
-extern u32 av7110_debiread(struct av7110 *av7110, u32 config,
- int addr, int count);
-
-
-/* DEBI during interrupt */
-/* single word writes */
-static inline void iwdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count)
-{
- av7110_debiwrite(av7110, config, addr, val, count);
-}
-
-/* buffer writes */
-static inline void mwdebi(struct av7110 *av7110, u32 config, int addr, char *val, int count)
-{
- memcpy(av7110->debi_virt, val, count);
- av7110_debiwrite(av7110, config, addr, 0, count);
-}
-
-static inline u32 irdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count)
-{
- u32 res;
-
- res=av7110_debiread(av7110, config, addr, count);
- if (count<=4)
- memcpy(av7110->debi_virt, (char *) &res, count);
- return res;
-}
-
-/* DEBI outside interrupts, only for count <= 4! */
-static inline void wdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&av7110->debilock, flags);
- av7110_debiwrite(av7110, config, addr, val, count);
- spin_unlock_irqrestore(&av7110->debilock, flags);
-}
-
-static inline u32 rdebi(struct av7110 *av7110, u32 config, int addr, u32 val, int count)
-{
- unsigned long flags;
- u32 res;
-
- spin_lock_irqsave(&av7110->debilock, flags);
- res=av7110_debiread(av7110, config, addr, count);
- spin_unlock_irqrestore(&av7110->debilock, flags);
- return res;
-}
-
-/* handle mailbox registers of the dual ported RAM */
-static inline void ARM_ResetMailBox(struct av7110 *av7110)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&av7110->debilock, flags);
- av7110_debiread(av7110, DEBINOSWAP, IRQ_RX, 2);
- av7110_debiwrite(av7110, DEBINOSWAP, IRQ_RX, 0, 2);
- spin_unlock_irqrestore(&av7110->debilock, flags);
-}
-
-static inline void ARM_ClearMailBox(struct av7110 *av7110)
-{
- iwdebi(av7110, DEBINOSWAP, IRQ_RX, 0, 2);
-}
-
-static inline void ARM_ClearIrq(struct av7110 *av7110)
-{
- irdebi(av7110, DEBINOSWAP, IRQ_RX, 0, 2);
-}
-
-/****************************************************************************
- * Firmware commands
- ****************************************************************************/
-
-static inline int SendDAC(struct av7110 *av7110, u8 addr, u8 data)
-{
- return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, AudioDAC, 2, addr, data);
-}
-
-static inline int av7710_set_video_mode(struct av7110 *av7110, int mode)
-{
- return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetVidMode, 1, mode);
-}
-
-static inline int vidcom(struct av7110 *av7110, u32 com, u32 arg)
-{
- return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_VIDEO_COMMAND, 4,
- (com>>16), (com&0xffff),
- (arg>>16), (arg&0xffff));
-}
-
-static inline int audcom(struct av7110 *av7110, u32 com)
-{
- return av7110_fw_cmd(av7110, COMTYPE_MISC, AV7110_FW_AUDIO_COMMAND, 2,
- (com>>16), (com&0xffff));
-}
-
-static inline int Set22K(struct av7110 *av7110, int state)
-{
- return av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, (state ? ON22K : OFF22K), 0);
-}
-
-
-extern int av7110_diseqc_send(struct av7110 *av7110, int len, u8 *msg, unsigned long burst);
-
-
-#ifdef CONFIG_DVB_AV7110_OSD
-extern int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc);
-extern int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap);
-#endif /* CONFIG_DVB_AV7110_OSD */
-
-
-
-#endif /* _AV7110_HW_H_ */
diff --git a/drivers/media/dvb/ttpci/av7110_ipack.c b/drivers/media/dvb/ttpci/av7110_ipack.c
deleted file mode 100644
index 699ef8b5b99..00000000000
--- a/drivers/media/dvb/ttpci/av7110_ipack.c
+++ /dev/null
@@ -1,403 +0,0 @@
-#include "dvb_filter.h"
-#include "av7110_ipack.h"
-#include <linux/string.h> /* for memcpy() */
-#include <linux/vmalloc.h>
-
-
-void av7110_ipack_reset(struct ipack *p)
-{
- p->found = 0;
- p->cid = 0;
- p->plength = 0;
- p->flag1 = 0;
- p->flag2 = 0;
- p->hlength = 0;
- p->mpeg = 0;
- p->check = 0;
- p->which = 0;
- p->done = 0;
- p->count = 0;
-}
-
-
-int av7110_ipack_init(struct ipack *p, int size,
- void (*func)(u8 *buf, int size, void *priv))
-{
- if (!(p->buf = vmalloc(size*sizeof(u8)))) {
- printk(KERN_WARNING "Couldn't allocate memory for ipack\n");
- return -ENOMEM;
- }
- p->size = size;
- p->func = func;
- p->repack_subids = 0;
- av7110_ipack_reset(p);
- return 0;
-}
-
-
-void av7110_ipack_free(struct ipack *p)
-{
- vfree(p->buf);
-}
-
-
-static void send_ipack(struct ipack *p)
-{
- int off;
- struct dvb_audio_info ai;
- int ac3_off = 0;
- int streamid = 0;
- int nframes = 0;
- int f = 0;
-
- switch (p->mpeg) {
- case 2:
- if (p->count < 10)
- return;
- p->buf[3] = p->cid;
- p->buf[4] = (u8)(((p->count - 6) & 0xff00) >> 8);
- p->buf[5] = (u8)((p->count - 6) & 0x00ff);
- if (p->repack_subids && p->cid == PRIVATE_STREAM1) {
- off = 9 + p->buf[8];
- streamid = p->buf[off];
- if ((streamid & 0xf8) == 0x80) {
- ai.off = 0;
- ac3_off = ((p->buf[off + 2] << 8)|
- p->buf[off + 3]);
- if (ac3_off < p->count)
- f = dvb_filter_get_ac3info(p->buf + off + 3 + ac3_off,
- p->count - ac3_off, &ai, 0);
- if (!f) {
- nframes = (p->count - off - 3 - ac3_off) /
- ai.framesize + 1;
- p->buf[off + 2] = (ac3_off >> 8) & 0xff;
- p->buf[off + 3] = (ac3_off) & 0xff;
- p->buf[off + 1] = nframes;
- ac3_off += nframes * ai.framesize - p->count;
- }
- }
- }
- p->func(p->buf, p->count, p->data);
-
- p->buf[6] = 0x80;
- p->buf[7] = 0x00;
- p->buf[8] = 0x00;
- p->count = 9;
- if (p->repack_subids && p->cid == PRIVATE_STREAM1
- && (streamid & 0xf8) == 0x80) {
- p->count += 4;
- p->buf[9] = streamid;
- p->buf[10] = (ac3_off >> 8) & 0xff;
- p->buf[11] = (ac3_off) & 0xff;
- p->buf[12] = 0;
- }
- break;
-
- case 1:
- if (p->count < 8)
- return;
- p->buf[3] = p->cid;
- p->buf[4] = (u8)(((p->count - 6) & 0xff00) >> 8);
- p->buf[5] = (u8)((p->count - 6) & 0x00ff);
- p->func(p->buf, p->count, p->data);
-
- p->buf[6] = 0x0f;
- p->count = 7;
- break;
- }
-}
-
-
-void av7110_ipack_flush(struct ipack *p)
-{
- if (p->plength != MMAX_PLENGTH - 6 || p->found <= 6)
- return;
- p->plength = p->found - 6;
- p->found = 0;
- send_ipack(p);
- av7110_ipack_reset(p);
-}
-
-
-static void write_ipack(struct ipack *p, const u8 *data, int count)
-{
- u8 headr[3] = { 0x00, 0x00, 0x01 };
-
- if (p->count < 6) {
- memcpy(p->buf, headr, 3);
- p->count = 6;
- }
-
- if (p->count + count < p->size){
- memcpy(p->buf+p->count, data, count);
- p->count += count;
- } else {
- int rest = p->size - p->count;
- memcpy(p->buf+p->count, data, rest);
- p->count += rest;
- send_ipack(p);
- if (count - rest > 0)
- write_ipack(p, data + rest, count - rest);
- }
-}
-
-
-int av7110_ipack_instant_repack (const u8 *buf, int count, struct ipack *p)
-{
- int l;
- int c = 0;
-
- while (c < count && (p->mpeg == 0 ||
- (p->mpeg == 1 && p->found < 7) ||
- (p->mpeg == 2 && p->found < 9))
- && (p->found < 5 || !p->done)) {
- switch (p->found) {
- case 0:
- case 1:
- if (buf[c] == 0x00)
- p->found++;
- else
- p->found = 0;
- c++;
- break;
- case 2:
- if (buf[c] == 0x01)
- p->found++;
- else if (buf[c] == 0)
- p->found = 2;
- else
- p->found = 0;
- c++;
- break;
- case 3:
- p->cid = 0;
- switch (buf[c]) {
- case PROG_STREAM_MAP:
- case PRIVATE_STREAM2:
- case PROG_STREAM_DIR:
- case ECM_STREAM :
- case EMM_STREAM :
- case PADDING_STREAM :
- case DSM_CC_STREAM :
- case ISO13522_STREAM:
- p->done = 1;
- /* fall through */
- case PRIVATE_STREAM1:
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- p->found++;
- p->cid = buf[c];
- c++;
- break;
- default:
- p->found = 0;
- break;
- }
- break;
-
- case 4:
- if (count-c > 1) {
- p->plen[0] = buf[c];
- c++;
- p->plen[1] = buf[c];
- c++;
- p->found += 2;
- p->plength = (p->plen[0] << 8) | p->plen[1];
- } else {
- p->plen[0] = buf[c];
- p->found++;
- return count;
- }
- break;
- case 5:
- p->plen[1] = buf[c];
- c++;
- p->found++;
- p->plength = (p->plen[0] << 8) | p->plen[1];
- break;
- case 6:
- if (!p->done) {
- p->flag1 = buf[c];
- c++;
- p->found++;
- if ((p->flag1 & 0xc0) == 0x80)
- p->mpeg = 2;
- else {
- p->hlength = 0;
- p->which = 0;
- p->mpeg = 1;
- p->flag2 = 0;
- }
- }
- break;
-
- case 7:
- if (!p->done && p->mpeg == 2) {
- p->flag2 = buf[c];
- c++;
- p->found++;
- }
- break;
-
- case 8:
- if (!p->done && p->mpeg == 2) {
- p->hlength = buf[c];
- c++;
- p->found++;
- }
- break;
- }
- }
-
- if (c == count)
- return count;
-
- if (!p->plength)
- p->plength = MMAX_PLENGTH - 6;
-
- if (p->done || ((p->mpeg == 2 && p->found >= 9) ||
- (p->mpeg == 1 && p->found >= 7))) {
- switch (p->cid) {
- case AUDIO_STREAM_S ... AUDIO_STREAM_E:
- case VIDEO_STREAM_S ... VIDEO_STREAM_E:
- case PRIVATE_STREAM1:
- if (p->mpeg == 2 && p->found == 9) {
- write_ipack(p, &p->flag1, 1);
- write_ipack(p, &p->flag2, 1);
- write_ipack(p, &p->hlength, 1);
- }
-
- if (p->mpeg == 1 && p->found == 7)
- write_ipack(p, &p->flag1, 1);
-
- if (p->mpeg == 2 && (p->flag2 & PTS_ONLY) &&
- p->found < 14) {
- while (c < count && p->found < 14) {
- p->pts[p->found - 9] = buf[c];
- write_ipack(p, buf + c, 1);
- c++;
- p->found++;
- }
- if (c == count)
- return count;
- }
-
- if (p->mpeg == 1 && p->which < 2000) {
-
- if (p->found == 7) {
- p->check = p->flag1;
- p->hlength = 1;
- }
-
- while (!p->which && c < count &&
- p->check == 0xff){
- p->check = buf[c];
- write_ipack(p, buf + c, 1);
- c++;
- p->found++;
- p->hlength++;
- }
-
- if (c == count)
- return count;
-
- if ((p->check & 0xc0) == 0x40 && !p->which) {
- p->check = buf[c];
- write_ipack(p, buf + c, 1);
- c++;
- p->found++;
- p->hlength++;
-
- p->which = 1;
- if (c == count)
- return count;
- p->check = buf[c];
- write_ipack(p, buf + c, 1);
- c++;
- p->found++;
- p->hlength++;
- p->which = 2;
- if (c == count)
- return count;
- }
-
- if (p->which == 1) {
- p->check = buf[c];
- write_ipack(p, buf + c, 1);
- c++;
- p->found++;
- p->hlength++;
- p->which = 2;
- if (c == count)
- return count;
- }
-
- if ((p->check & 0x30) && p->check != 0xff) {
- p->flag2 = (p->check & 0xf0) << 2;
- p->pts[0] = p->check;
- p->which = 3;
- }
-
- if (c == count)
- return count;
- if (p->which > 2){
- if ((p->flag2 & PTS_DTS_FLAGS) == PTS_ONLY) {
- while (c < count && p->which < 7) {
- p->pts[p->which - 2] = buf[c];
- write_ipack(p, buf + c, 1);
- c++;
- p->found++;
- p->which++;
- p->hlength++;
- }
- if (c == count)
- return count;
- } else if ((p->flag2 & PTS_DTS_FLAGS) == PTS_DTS) {
- while (c < count && p->which < 12) {
- if (p->which < 7)
- p->pts[p->which - 2] = buf[c];
- write_ipack(p, buf + c, 1);
- c++;
- p->found++;
- p->which++;
- p->hlength++;
- }
- if (c == count)
- return count;
- }
- p->which = 2000;
- }
-
- }
-
- while (c < count && p->found < p->plength + 6) {
- l = count - c;
- if (l + p->found > p->plength + 6)
- l = p->plength + 6 - p->found;
- write_ipack(p, buf + c, l);
- p->found += l;
- c += l;
- }
- break;
- }
-
-
- if (p->done) {
- if (p->found + count - c < p->plength + 6) {
- p->found += count - c;
- c = count;
- } else {
- c += p->plength + 6 - p->found;
- p->found = p->plength + 6;
- }
- }
-
- if (p->plength && p->found == p->plength + 6) {
- send_ipack(p);
- av7110_ipack_reset(p);
- if (c < count)
- av7110_ipack_instant_repack(buf + c, count - c, p);
- }
- }
- return count;
-}
diff --git a/drivers/media/dvb/ttpci/av7110_ipack.h b/drivers/media/dvb/ttpci/av7110_ipack.h
deleted file mode 100644
index becf94d3fdf..00000000000
--- a/drivers/media/dvb/ttpci/av7110_ipack.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _AV7110_IPACK_H_
-#define _AV7110_IPACK_H_
-
-extern int av7110_ipack_init(struct ipack *p, int size,
- void (*func)(u8 *buf, int size, void *priv));
-
-extern void av7110_ipack_reset(struct ipack *p);
-extern int av7110_ipack_instant_repack(const u8 *buf, int count, struct ipack *p);
-extern void av7110_ipack_free(struct ipack * p);
-extern void av7110_ipack_flush(struct ipack *p);
-
-#endif
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
deleted file mode 100644
index d54bbcdde2c..00000000000
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ /dev/null
@@ -1,277 +0,0 @@
-#include <linux/types.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/input.h>
-#include <linux/proc_fs.h>
-#include <asm/bitops.h>
-
-#include "av7110.h"
-#include "av7110_hw.h"
-
-#define UP_TIMEOUT (HZ*7/25)
-
-/* enable ir debugging by or'ing debug with 16 */
-
-static int av_cnt;
-static struct av7110 *av_list[4];
-static struct input_dev *input_dev;
-
-static u8 delay_timer_finished;
-
-static u16 key_map [256] = {
- KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7,
- KEY_8, KEY_9, KEY_BACK, 0, KEY_POWER, KEY_MUTE, 0, KEY_INFO,
- KEY_VOLUMEUP, KEY_VOLUMEDOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- KEY_CHANNELUP, KEY_CHANNELDOWN, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, KEY_TEXT, 0, 0, KEY_TV, 0, 0, 0, 0, 0, KEY_SETUP, 0, 0,
- 0, 0, 0, KEY_SUBTITLE, 0, 0, KEY_LANGUAGE, 0,
- KEY_RADIO, 0, 0, 0, 0, KEY_EXIT, 0, 0,
- KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_OK, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_RED, KEY_GREEN, KEY_YELLOW,
- KEY_BLUE, 0, 0, 0, 0, 0, 0, 0, KEY_MENU, KEY_LIST, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, KEY_UP, KEY_UP, KEY_DOWN, KEY_DOWN,
- 0, 0, 0, 0, KEY_EPG, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_VCR
-};
-
-
-static void av7110_emit_keyup(unsigned long data)
-{
- if (!data || !test_bit(data, input_dev->key))
- return;
-
- input_event(input_dev, EV_KEY, data, !!0);
-}
-
-
-static struct timer_list keyup_timer = { .function = av7110_emit_keyup };
-
-
-static void av7110_emit_key(unsigned long parm)
-{
- struct av7110 *av7110 = (struct av7110 *) parm;
- u32 ir_config = av7110->ir_config;
- u32 ircom = av7110->ir_command;
- u8 data;
- u8 addr;
- static u16 old_toggle = 0;
- u16 new_toggle;
- u16 keycode;
-
- /* extract device address and data */
- switch (ir_config & 0x0003) {
- case 0: /* RC5: 5 bits device address, 6 bits data */
- data = ircom & 0x3f;
- addr = (ircom >> 6) & 0x1f;
- break;
-
- case 1: /* RCMM: 8(?) bits device address, 8(?) bits data */
- data = ircom & 0xff;
- addr = (ircom >> 8) & 0xff;
- break;
-
- case 2: /* extended RC5: 5 bits device address, 7 bits data */
- data = ircom & 0x3f;
- addr = (ircom >> 6) & 0x1f;
- /* invert 7th data bit for backward compatibility with RC5 keymaps */
- if (!(ircom & 0x1000))
- data |= 0x40;
- break;
-
- default:
- printk("invalid ir_config %x\n", ir_config);
- return;
- }
-
- keycode = key_map[data];
-
- dprintk(16, "code %08x -> addr %i data 0x%02x -> keycode %i\n",
- ircom, addr, data, keycode);
-
- /* check device address (if selected) */
- if (ir_config & 0x4000)
- if (addr != ((ir_config >> 16) & 0xff))
- return;
-
- if (!keycode) {
- printk ("%s: unknown key 0x%02x!!\n", __FUNCTION__, data);
- return;
- }
-
- if ((ir_config & 0x0003) == 1)
- new_toggle = 0; /* RCMM */
- else
- new_toggle = (ircom & 0x800); /* RC5, extended RC5 */
-
- if (timer_pending(&keyup_timer)) {
- del_timer(&keyup_timer);
- if (keyup_timer.data != keycode || new_toggle != old_toggle) {
- delay_timer_finished = 0;
- input_event(input_dev, EV_KEY, keyup_timer.data, !!0);
- input_event(input_dev, EV_KEY, keycode, !0);
- } else
- if (delay_timer_finished)
- input_event(input_dev, EV_KEY, keycode, 2);
- } else {
- delay_timer_finished = 0;
- input_event(input_dev, EV_KEY, keycode, !0);
- }
-
- keyup_timer.expires = jiffies + UP_TIMEOUT;
- keyup_timer.data = keycode;
-
- add_timer(&keyup_timer);
-
- old_toggle = new_toggle;
-}
-
-static void input_register_keys(void)
-{
- int i;
-
- memset(input_dev->keybit, 0, sizeof(input_dev->keybit));
-
- for (i = 0; i < ARRAY_SIZE(key_map); i++) {
- if (key_map[i] > KEY_MAX)
- key_map[i] = 0;
- else if (key_map[i] > KEY_RESERVED)
- set_bit(key_map[i], input_dev->keybit);
- }
-}
-
-
-static void input_repeat_key(unsigned long data)
-{
- /* called by the input driver after rep[REP_DELAY] ms */
- delay_timer_finished = 1;
-}
-
-
-static int av7110_setup_irc_config(struct av7110 *av7110, u32 ir_config)
-{
- int ret = 0;
-
- dprintk(4, "%p\n", av7110);
- if (av7110) {
- ret = av7110_fw_cmd(av7110, COMTYPE_PIDFILTER, SetIR, 1, ir_config);
- av7110->ir_config = ir_config;
- }
- return ret;
-}
-
-
-static int av7110_ir_write_proc(struct file *file, const char __user *buffer,
- unsigned long count, void *data)
-{
- char *page;
- int size = 4 + 256 * sizeof(u16);
- u32 ir_config;
- int i;
-
- if (count < size)
- return -EINVAL;
-
- page = (char *) vmalloc(size);
- if (!page)
- return -ENOMEM;
-
- if (copy_from_user(page, buffer, size)) {
- vfree(page);
- return -EFAULT;
- }
-
- memcpy(&ir_config, page, 4);
- memcpy(&key_map, page + 4, 256 * sizeof(u16));
- vfree(page);
- if (FW_VERSION(av_list[0]->arm_app) >= 0x2620 && !(ir_config & 0x0001))
- ir_config |= 0x0002; /* enable extended RC5 */
- for (i = 0; i < av_cnt; i++)
- av7110_setup_irc_config(av_list[i], ir_config);
- input_register_keys();
- return count;
-}
-
-
-static void ir_handler(struct av7110 *av7110, u32 ircom)
-{
- dprintk(4, "ircommand = %08x\n", ircom);
- av7110->ir_command = ircom;
- tasklet_schedule(&av7110->ir_tasklet);
-}
-
-
-int __devinit av7110_ir_init(struct av7110 *av7110)
-{
- static struct proc_dir_entry *e;
-
- if (av_cnt >= sizeof av_list/sizeof av_list[0])
- return -ENOSPC;
-
- av7110_setup_irc_config(av7110, 0x0001);
- av_list[av_cnt++] = av7110;
-
- if (av_cnt == 1) {
- init_timer(&keyup_timer);
- keyup_timer.data = 0;
-
- input_dev = input_allocate_device();
- if (!input_dev)
- return -ENOMEM;
-
- input_dev->name = "DVB on-card IR receiver";
-
- set_bit(EV_KEY, input_dev->evbit);
- set_bit(EV_REP, input_dev->evbit);
- input_register_keys();
- input_register_device(input_dev);
- input_dev->timer.function = input_repeat_key;
-
- e = create_proc_entry("av7110_ir", S_IFREG | S_IRUGO | S_IWUSR, NULL);
- if (e) {
- e->write_proc = av7110_ir_write_proc;
- e->size = 4 + 256 * sizeof(u16);
- }
- }
-
- tasklet_init(&av7110->ir_tasklet, av7110_emit_key, (unsigned long) av7110);
- av7110->ir_handler = ir_handler;
-
- return 0;
-}
-
-
-void __devexit av7110_ir_exit(struct av7110 *av7110)
-{
- int i;
-
- if (av_cnt == 0)
- return;
-
- av7110->ir_handler = NULL;
- tasklet_kill(&av7110->ir_tasklet);
- for (i = 0; i < av_cnt; i++)
- if (av_list[i] == av7110) {
- av_list[i] = av_list[av_cnt-1];
- av_list[av_cnt-1] = NULL;
- break;
- }
-
- if (av_cnt == 1) {
- del_timer_sync(&keyup_timer);
- remove_proc_entry("av7110_ir", NULL);
- input_unregister_device(input_dev);
- }
-
- av_cnt--;
-}
-
-//MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>");
-//MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
deleted file mode 100644
index 6ffe53fdcf5..00000000000
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * av7110_v4l.c: av7110 video4linux interface for DVB and Siemens DVB-C analog module
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * originally based on code by:
- * Copyright (C) 1998,1999 Christian Theiss <mistert@rz.fh-augsburg.de>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/types.h>
-#include <linux/delay.h>
-#include <linux/fs.h>
-#include <linux/timer.h>
-#include <linux/poll.h>
-#include <linux/byteorder/swabb.h>
-#include <linux/smp_lock.h>
-
-#include "av7110.h"
-#include "av7110_hw.h"
-#include "av7110_av.h"
-
-int msp_writereg(struct av7110 *av7110, u8 dev, u16 reg, u16 val)
-{
- u8 msg[5] = { dev, reg >> 8, reg & 0xff, val >> 8 , val & 0xff };
- struct i2c_msg msgs = { .flags = 0, .len = 5, .buf = msg };
-
- switch (av7110->adac_type) {
- case DVB_ADAC_MSP34x0:
- msgs.addr = 0x40;
- break;
- case DVB_ADAC_MSP34x5:
- msgs.addr = 0x42;
- break;
- default:
- return 0;
- }
-
- if (i2c_transfer(&av7110->i2c_adap, &msgs, 1) != 1) {
- dprintk(1, "dvb-ttpci: failed @ card %d, %u = %u\n",
- av7110->dvb_adapter.num, reg, val);
- return -EIO;
- }
- return 0;
-}
-
-static int msp_readreg(struct av7110 *av7110, u8 dev, u16 reg, u16 *val)
-{
- u8 msg1[3] = { dev, reg >> 8, reg & 0xff };
- u8 msg2[2];
- struct i2c_msg msgs[2] = {
- { .flags = 0 , .len = 3, .buf = msg1 },
- { .flags = I2C_M_RD, .len = 2, .buf = msg2 }
- };
-
- switch (av7110->adac_type) {
- case DVB_ADAC_MSP34x0:
- msgs[0].addr = 0x40;
- msgs[1].addr = 0x40;
- break;
- case DVB_ADAC_MSP34x5:
- msgs[0].addr = 0x42;
- msgs[1].addr = 0x42;
- break;
- default:
- return 0;
- }
-
- if (i2c_transfer(&av7110->i2c_adap, &msgs[0], 2) != 2) {
- dprintk(1, "dvb-ttpci: failed @ card %d, %u\n",
- av7110->dvb_adapter.num, reg);
- return -EIO;
- }
- *val = (msg2[0] << 8) | msg2[1];
- return 0;
-}
-
-static struct v4l2_input inputs[4] = {
- {
- .index = 0,
- .name = "DVB",
- .type = V4L2_INPUT_TYPE_CAMERA,
- .audioset = 1,
- .tuner = 0, /* ignored */
- .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
- .status = 0,
- }, {
- .index = 1,
- .name = "Television",
- .type = V4L2_INPUT_TYPE_TUNER,
- .audioset = 2,
- .tuner = 0,
- .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
- .status = 0,
- }, {
- .index = 2,
- .name = "Video",
- .type = V4L2_INPUT_TYPE_CAMERA,
- .audioset = 0,
- .tuner = 0,
- .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
- .status = 0,
- }, {
- .index = 3,
- .name = "Y/C",
- .type = V4L2_INPUT_TYPE_CAMERA,
- .audioset = 0,
- .tuner = 0,
- .std = V4L2_STD_PAL_BG|V4L2_STD_NTSC_M,
- .status = 0,
- }
-};
-
-static int ves1820_writereg(struct saa7146_dev *dev, u8 addr, u8 reg, u8 data)
-{
- u8 buf[] = { 0x00, reg, data };
- struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 3 };
-
- dprintk(4, "dev: %p\n", dev);
-
- if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1))
- return -1;
- return 0;
-}
-
-static int stv0297_writereg(struct saa7146_dev *dev, u8 addr, u8 reg, u8 data)
-{
- u8 buf [] = { reg, data };
- struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 2 };
-
- if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1))
- return -1;
- return 0;
-}
-
-
-static int tuner_write(struct saa7146_dev *dev, u8 addr, u8 data [4])
-{
- struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = data, .len = 4 };
-
- dprintk(4, "dev: %p\n", dev);
-
- if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1))
- return -1;
- return 0;
-}
-
-static int ves1820_set_tv_freq(struct saa7146_dev *dev, u32 freq)
-{
- u32 div;
- u8 config;
- u8 buf[4];
-
- dprintk(4, "freq: 0x%08x\n", freq);
-
- /* magic number: 614. tuning with the frequency given by v4l2
- is always off by 614*62.5 = 38375 kHz...*/
- div = freq + 614;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x8e;
-
- if (freq < (u32) (16 * 168.25))
- config = 0xa0;
- else if (freq < (u32) (16 * 447.25))
- config = 0x90;
- else
- config = 0x30;
- config &= ~0x02;
-
- buf[3] = config;
-
- return tuner_write(dev, 0x61, buf);
-}
-
-static int stv0297_set_tv_freq(struct saa7146_dev *dev, u32 freq)
-{
- u32 div;
- u8 data[4];
-
- div = (freq + 38900000 + 31250) / 62500;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0xce;
-
- if (freq < 45000000)
- return -EINVAL;
- else if (freq < 137000000)
- data[3] = 0x01;
- else if (freq < 403000000)
- data[3] = 0x02;
- else if (freq < 860000000)
- data[3] = 0x04;
- else
- return -EINVAL;
-
- stv0297_writereg(dev, 0x1C, 0x87, 0x78);
- stv0297_writereg(dev, 0x1C, 0x86, 0xc8);
- return tuner_write(dev, 0x63, data);
-}
-
-
-
-static struct saa7146_standard analog_standard[];
-static struct saa7146_standard dvb_standard[];
-static struct saa7146_standard standard[];
-
-static struct v4l2_audio msp3400_v4l2_audio = {
- .index = 0,
- .name = "Television",
- .capability = V4L2_AUDCAP_STEREO
-};
-
-static int av7110_dvb_c_switch(struct saa7146_fh *fh)
-{
- struct saa7146_dev *dev = fh->dev;
- struct saa7146_vv *vv = dev->vv_data;
- struct av7110 *av7110 = (struct av7110*)dev->ext_priv;
- u16 adswitch;
- int source, sync, err;
-
- dprintk(4, "%p\n", av7110);
-
- if ((vv->video_status & STATUS_OVERLAY) != 0) {
- vv->ov_suspend = vv->video_fh;
- err = saa7146_stop_preview(vv->video_fh); /* side effect: video_status is now 0, video_fh is NULL */
- if (err != 0) {
- dprintk(2, "suspending video failed\n");
- vv->ov_suspend = NULL;
- }
- }
-
- if (0 != av7110->current_input) {
- dprintk(1, "switching to analog TV:\n");
- adswitch = 1;
- source = SAA7146_HPS_SOURCE_PORT_B;
- sync = SAA7146_HPS_SYNC_PORT_B;
- memcpy(standard, analog_standard, sizeof(struct saa7146_standard) * 2);
-
- switch (av7110->current_input) {
- case 1:
- dprintk(1, "switching SAA7113 to Analog Tuner Input.\n");
- msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0000); // loudspeaker source
- msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0000); // headphone source
- msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0000); // SCART 1 source
- msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
- msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
- msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
-
- if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
- if (ves1820_writereg(dev, 0x09, 0x0f, 0x60))
- dprintk(1, "setting band in demodulator failed.\n");
- } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
- saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // TDA9819 pin9(STD)
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); // TDA9819 pin30(VIF)
- }
- if (i2c_writereg(av7110, 0x48, 0x02, 0xd0) != 1)
- dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
- break;
- case 2:
- dprintk(1, "switching SAA7113 to Video AV CVBS Input.\n");
- if (i2c_writereg(av7110, 0x48, 0x02, 0xd2) != 1)
- dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
- break;
- case 3:
- dprintk(1, "switching SAA7113 to Video AV Y/C Input.\n");
- if (i2c_writereg(av7110, 0x48, 0x02, 0xd9) != 1)
- dprintk(1, "saa7113 write failed @ card %d", av7110->dvb_adapter.num);
- break;
- default:
- dprintk(1, "switching SAA7113 to Input: AV7110: SAA7113: invalid input.\n");
- }
- } else {
- adswitch = 0;
- source = SAA7146_HPS_SOURCE_PORT_A;
- sync = SAA7146_HPS_SYNC_PORT_A;
- memcpy(standard, dvb_standard, sizeof(struct saa7146_standard) * 2);
- dprintk(1, "switching DVB mode\n");
- msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source
- msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0220); // headphone source
- msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0220); // SCART 1 source
- msp_writereg(av7110, MSP_WR_DSP, 0x000e, 0x3000); // FM matrix, mono
- msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
- msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x7f00); // SCART 1 volume
-
- if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
- if (ves1820_writereg(dev, 0x09, 0x0f, 0x20))
- dprintk(1, "setting band in demodulator failed.\n");
- } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
- saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD)
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF)
- }
- }
-
- /* hmm, this does not do anything!? */
- if (av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, adswitch))
- dprintk(1, "ADSwitch error\n");
-
- saa7146_set_hps_source_and_sync(dev, source, sync);
-
- if (vv->ov_suspend != NULL) {
- saa7146_start_preview(vv->ov_suspend);
- vv->ov_suspend = NULL;
- }
-
- return 0;
-}
-
-static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
-{
- struct saa7146_dev *dev = fh->dev;
- struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
- dprintk(4, "saa7146_dev: %p\n", dev);
-
- switch (cmd) {
- case VIDIOC_G_TUNER:
- {
- struct v4l2_tuner *t = arg;
- u16 stereo_det;
- s8 stereo;
-
- dprintk(2, "VIDIOC_G_TUNER: %d\n", t->index);
-
- if (!av7110->analog_tuner_flags || t->index != 0)
- return -EINVAL;
-
- memset(t, 0, sizeof(*t));
- strcpy(t->name, "Television");
-
- t->type = V4L2_TUNER_ANALOG_TV;
- t->capability = V4L2_TUNER_CAP_NORM | V4L2_TUNER_CAP_STEREO |
- V4L2_TUNER_CAP_LANG1 | V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
- t->rangelow = 772; /* 48.25 MHZ / 62.5 kHz = 772, see fi1216mk2-specs, page 2 */
- t->rangehigh = 13684; /* 855.25 MHz / 62.5 kHz = 13684 */
- /* FIXME: add the real signal strength here */
- t->signal = 0xffff;
- t->afc = 0;
-
- // FIXME: standard / stereo detection is still broken
- msp_readreg(av7110, MSP_RD_DEM, 0x007e, &stereo_det);
- dprintk(1, "VIDIOC_G_TUNER: msp3400 TV standard detection: 0x%04x\n", stereo_det);
- msp_readreg(av7110, MSP_RD_DSP, 0x0018, &stereo_det);
- dprintk(1, "VIDIOC_G_TUNER: msp3400 stereo detection: 0x%04x\n", stereo_det);
- stereo = (s8)(stereo_det >> 8);
- if (stereo > 0x10) {
- /* stereo */
- t->rxsubchans = V4L2_TUNER_SUB_STEREO | V4L2_TUNER_SUB_MONO;
- t->audmode = V4L2_TUNER_MODE_STEREO;
- }
- else if (stereo < -0x10) {
- /* bilingual */
- t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
- t->audmode = V4L2_TUNER_MODE_LANG1;
- }
- else /* mono */
- t->rxsubchans = V4L2_TUNER_SUB_MONO;
-
- return 0;
- }
- case VIDIOC_S_TUNER:
- {
- struct v4l2_tuner *t = arg;
- u16 fm_matrix, src;
- dprintk(2, "VIDIOC_S_TUNER: %d\n", t->index);
-
- if (!av7110->analog_tuner_flags || av7110->current_input != 1)
- return -EINVAL;
-
- switch (t->audmode) {
- case V4L2_TUNER_MODE_STEREO:
- dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n");
- fm_matrix = 0x3001; // stereo
- src = 0x0020;
- break;
- case V4L2_TUNER_MODE_LANG1_LANG2:
- dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1_LANG2\n");
- fm_matrix = 0x3000; // bilingual
- src = 0x0020;
- break;
- case V4L2_TUNER_MODE_LANG1:
- dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n");
- fm_matrix = 0x3000; // mono
- src = 0x0000;
- break;
- case V4L2_TUNER_MODE_LANG2:
- dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG2\n");
- fm_matrix = 0x3000; // mono
- src = 0x0010;
- break;
- default: /* case V4L2_TUNER_MODE_MONO: */
- dprintk(2, "VIDIOC_S_TUNER: TDA9840_SET_MONO\n");
- fm_matrix = 0x3000; // mono
- src = 0x0030;
- break;
- }
- msp_writereg(av7110, MSP_WR_DSP, 0x000e, fm_matrix);
- msp_writereg(av7110, MSP_WR_DSP, 0x0008, src);
- msp_writereg(av7110, MSP_WR_DSP, 0x0009, src);
- msp_writereg(av7110, MSP_WR_DSP, 0x000a, src);
- return 0;
- }
- case VIDIOC_G_FREQUENCY:
- {
- struct v4l2_frequency *f = arg;
-
- dprintk(2, "VIDIOC_G_FREQ: freq:0x%08x.\n", f->frequency);
-
- if (!av7110->analog_tuner_flags || av7110->current_input != 1)
- return -EINVAL;
-
- memset(f, 0, sizeof(*f));
- f->type = V4L2_TUNER_ANALOG_TV;
- f->frequency = av7110->current_freq;
- return 0;
- }
- case VIDIOC_S_FREQUENCY:
- {
- struct v4l2_frequency *f = arg;
-
- dprintk(2, "VIDIOC_S_FREQUENCY: freq:0x%08x.\n", f->frequency);
-
- if (!av7110->analog_tuner_flags || av7110->current_input != 1)
- return -EINVAL;
-
- if (V4L2_TUNER_ANALOG_TV != f->type)
- return -EINVAL;
-
- msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0xffe0); // fast mute
- msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0xffe0);
-
- /* tune in desired frequency */
- if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
- ves1820_set_tv_freq(dev, f->frequency);
- } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
- stv0297_set_tv_freq(dev, f->frequency);
- }
- av7110->current_freq = f->frequency;
-
- msp_writereg(av7110, MSP_WR_DSP, 0x0015, 0x003f); // start stereo detection
- msp_writereg(av7110, MSP_WR_DSP, 0x0015, 0x0000);
- msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x4f00); // loudspeaker + headphone
- msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x4f00); // SCART 1 volume
- return 0;
- }
- case VIDIOC_ENUMINPUT:
- {
- struct v4l2_input *i = arg;
-
- dprintk(2, "VIDIOC_ENUMINPUT: %d\n", i->index);
-
- if (av7110->analog_tuner_flags) {
- if (i->index < 0 || i->index >= 4)
- return -EINVAL;
- } else {
- if (i->index != 0)
- return -EINVAL;
- }
-
- memcpy(i, &inputs[i->index], sizeof(struct v4l2_input));
-
- return 0;
- }
- case VIDIOC_G_INPUT:
- {
- int *input = (int *)arg;
- *input = av7110->current_input;
- dprintk(2, "VIDIOC_G_INPUT: %d\n", *input);
- return 0;
- }
- case VIDIOC_S_INPUT:
- {
- int input = *(int *)arg;
-
- dprintk(2, "VIDIOC_S_INPUT: %d\n", input);
-
- if (!av7110->analog_tuner_flags)
- return 0;
-
- if (input < 0 || input >= 4)
- return -EINVAL;
-
- av7110->current_input = input;
- return av7110_dvb_c_switch(fh);
- }
- case VIDIOC_G_AUDIO:
- {
- struct v4l2_audio *a = arg;
-
- dprintk(2, "VIDIOC_G_AUDIO: %d\n", a->index);
- if (a->index != 0)
- return -EINVAL;
- memcpy(a, &msp3400_v4l2_audio, sizeof(struct v4l2_audio));
- break;
- }
- case VIDIOC_S_AUDIO:
- {
- struct v4l2_audio *a = arg;
- dprintk(2, "VIDIOC_S_AUDIO: %d\n", a->index);
- break;
- }
- case VIDIOC_G_SLICED_VBI_CAP:
- {
- struct v4l2_sliced_vbi_cap *cap = arg;
- dprintk(2, "VIDIOC_G_SLICED_VBI_CAP\n");
- memset(cap, 0, sizeof *cap);
- if (FW_VERSION(av7110->arm_app) >= 0x2623) {
- cap->service_set = V4L2_SLICED_WSS_625;
- cap->service_lines[0][23] = V4L2_SLICED_WSS_625;
- }
- break;
- }
- case VIDIOC_G_FMT:
- {
- struct v4l2_format *f = arg;
- dprintk(2, "VIDIOC_G_FMT:\n");
- if (f->type != V4L2_BUF_TYPE_SLICED_VBI_OUTPUT ||
- FW_VERSION(av7110->arm_app) < 0x2623)
- return -EAGAIN; /* handled by core driver */
- memset(&f->fmt.sliced, 0, sizeof f->fmt.sliced);
- if (av7110->wssMode) {
- f->fmt.sliced.service_set = V4L2_SLICED_WSS_625;
- f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625;
- f->fmt.sliced.io_size = sizeof (struct v4l2_sliced_vbi_data);
- }
- break;
- }
- case VIDIOC_S_FMT:
- {
- struct v4l2_format *f = arg;
- dprintk(2, "VIDIOC_S_FMT\n");
- if (f->type != V4L2_BUF_TYPE_SLICED_VBI_OUTPUT ||
- FW_VERSION(av7110->arm_app) < 0x2623)
- return -EAGAIN; /* handled by core driver */
- if (f->fmt.sliced.service_set != V4L2_SLICED_WSS_625 &&
- f->fmt.sliced.service_lines[0][23] != V4L2_SLICED_WSS_625) {
- memset(&f->fmt.sliced, 0, sizeof f->fmt.sliced);
- /* WSS controlled by firmware */
- av7110->wssMode = 0;
- av7110->wssData = 0;
- return av7110_fw_cmd(av7110, COMTYPE_ENCODER,
- SetWSSConfig, 1, 0);
- } else {
- memset(&f->fmt.sliced, 0, sizeof f->fmt.sliced);
- f->fmt.sliced.service_set = V4L2_SLICED_WSS_625;
- f->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625;
- f->fmt.sliced.io_size = sizeof (struct v4l2_sliced_vbi_data);
- /* WSS controlled by userspace */
- av7110->wssMode = 1;
- av7110->wssData = 0;
- }
- break;
- }
- default:
- printk("no such ioctl\n");
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-static int av7110_vbi_reset(struct inode *inode, struct file *file)
-{
- struct saa7146_fh *fh = file->private_data;
- struct saa7146_dev *dev = fh->dev;
- struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
-
- dprintk(2, "%s\n", __FUNCTION__);
- av7110->wssMode = 0;
- av7110->wssData = 0;
- if (FW_VERSION(av7110->arm_app) < 0x2623)
- return 0;
- else
- return av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 1, 0);
-}
-
-static ssize_t av7110_vbi_write(struct file *file, const char __user *data, size_t count, loff_t *ppos)
-{
- struct saa7146_fh *fh = file->private_data;
- struct saa7146_dev *dev = fh->dev;
- struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
- struct v4l2_sliced_vbi_data d;
- int rc;
-
- dprintk(2, "%s\n", __FUNCTION__);
- if (FW_VERSION(av7110->arm_app) < 0x2623 || !av7110->wssMode || count != sizeof d)
- return -EINVAL;
- if (copy_from_user(&d, data, count))
- return -EFAULT;
- if ((d.id != 0 && d.id != V4L2_SLICED_WSS_625) || d.field != 0 || d.line != 23)
- return -EINVAL;
- if (d.id)
- av7110->wssData = ((d.data[1] << 8) & 0x3f00) | d.data[0];
- else
- av7110->wssData = 0x8000;
- rc = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 1, av7110->wssData);
- return (rc < 0) ? rc : count;
-}
-
-/****************************************************************************
- * INITIALIZATION
- ****************************************************************************/
-
-static struct saa7146_extension_ioctls ioctls[] = {
- { VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE },
- { VIDIOC_G_INPUT, SAA7146_EXCLUSIVE },
- { VIDIOC_S_INPUT, SAA7146_EXCLUSIVE },
- { VIDIOC_G_FREQUENCY, SAA7146_EXCLUSIVE },
- { VIDIOC_S_FREQUENCY, SAA7146_EXCLUSIVE },
- { VIDIOC_G_TUNER, SAA7146_EXCLUSIVE },
- { VIDIOC_S_TUNER, SAA7146_EXCLUSIVE },
- { VIDIOC_G_AUDIO, SAA7146_EXCLUSIVE },
- { VIDIOC_S_AUDIO, SAA7146_EXCLUSIVE },
- { VIDIOC_G_SLICED_VBI_CAP, SAA7146_EXCLUSIVE },
- { VIDIOC_G_FMT, SAA7146_BEFORE },
- { VIDIOC_S_FMT, SAA7146_BEFORE },
- { 0, 0 }
-};
-
-static u8 saa7113_init_regs[] = {
- 0x02, 0xd0,
- 0x03, 0x23,
- 0x04, 0x00,
- 0x05, 0x00,
- 0x06, 0xe9,
- 0x07, 0x0d,
- 0x08, 0x98,
- 0x09, 0x02,
- 0x0a, 0x80,
- 0x0b, 0x40,
- 0x0c, 0x40,
- 0x0d, 0x00,
- 0x0e, 0x01,
- 0x0f, 0x7c,
- 0x10, 0x48,
- 0x11, 0x0c,
- 0x12, 0x8b,
- 0x13, 0x1a,
- 0x14, 0x00,
- 0x15, 0x00,
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1b, 0x00,
- 0x1c, 0x00,
- 0x1d, 0x00,
- 0x1e, 0x00,
-
- 0x41, 0x77,
- 0x42, 0x77,
- 0x43, 0x77,
- 0x44, 0x77,
- 0x45, 0x77,
- 0x46, 0x77,
- 0x47, 0x77,
- 0x48, 0x77,
- 0x49, 0x77,
- 0x4a, 0x77,
- 0x4b, 0x77,
- 0x4c, 0x77,
- 0x4d, 0x77,
- 0x4e, 0x77,
- 0x4f, 0x77,
- 0x50, 0x77,
- 0x51, 0x77,
- 0x52, 0x77,
- 0x53, 0x77,
- 0x54, 0x77,
- 0x55, 0x77,
- 0x56, 0x77,
- 0x57, 0xff,
-
- 0xff
-};
-
-
-static struct saa7146_ext_vv av7110_vv_data_st;
-static struct saa7146_ext_vv av7110_vv_data_c;
-
-int av7110_init_analog_module(struct av7110 *av7110)
-{
- u16 version1, version2;
-
- if (i2c_writereg(av7110, 0x80, 0x0, 0x80) == 1 &&
- i2c_writereg(av7110, 0x80, 0x0, 0) == 1) {
- printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3400\n",
- av7110->dvb_adapter.num);
- av7110->adac_type = DVB_ADAC_MSP34x0;
- } else if (i2c_writereg(av7110, 0x84, 0x0, 0x80) == 1 &&
- i2c_writereg(av7110, 0x84, 0x0, 0) == 1) {
- printk("dvb-ttpci: DVB-C analog module @ card %d detected, initializing MSP3415\n",
- av7110->dvb_adapter.num);
- av7110->adac_type = DVB_ADAC_MSP34x5;
- } else
- return -ENODEV;
-
- msleep(100); // the probing above resets the msp...
- msp_readreg(av7110, MSP_RD_DSP, 0x001e, &version1);
- msp_readreg(av7110, MSP_RD_DSP, 0x001f, &version2);
- dprintk(1, "dvb-ttpci: @ card %d MSP34xx version 0x%04x 0x%04x\n",
- av7110->dvb_adapter.num, version1, version2);
- msp_writereg(av7110, MSP_WR_DSP, 0x0013, 0x0c00);
- msp_writereg(av7110, MSP_WR_DSP, 0x0000, 0x7f00); // loudspeaker + headphone
- msp_writereg(av7110, MSP_WR_DSP, 0x0008, 0x0220); // loudspeaker source
- msp_writereg(av7110, MSP_WR_DSP, 0x0009, 0x0220); // headphone source
- msp_writereg(av7110, MSP_WR_DSP, 0x0004, 0x7f00); // loudspeaker volume
- msp_writereg(av7110, MSP_WR_DSP, 0x000a, 0x0220); // SCART 1 source
- msp_writereg(av7110, MSP_WR_DSP, 0x0007, 0x7f00); // SCART 1 volume
- msp_writereg(av7110, MSP_WR_DSP, 0x000d, 0x1900); // prescale SCART
-
- if (i2c_writereg(av7110, 0x48, 0x01, 0x00)!=1) {
- INFO(("saa7113 not accessible.\n"));
- } else {
- u8 *i = saa7113_init_regs;
-
- if ((av7110->dev->pci->subsystem_vendor == 0x110a) && (av7110->dev->pci->subsystem_device == 0x0000)) {
- /* Fujitsu/Siemens DVB-Cable */
- av7110->analog_tuner_flags |= ANALOG_TUNER_VES1820;
- } else if ((av7110->dev->pci->subsystem_vendor == 0x13c2) && (av7110->dev->pci->subsystem_device == 0x0002)) {
- /* Hauppauge/TT DVB-C premium */
- av7110->analog_tuner_flags |= ANALOG_TUNER_VES1820;
- } else if ((av7110->dev->pci->subsystem_vendor == 0x13c2) && (av7110->dev->pci->subsystem_device == 0x000A)) {
- /* Hauppauge/TT DVB-C premium */
- av7110->analog_tuner_flags |= ANALOG_TUNER_STV0297;
- }
-
- /* setup for DVB by default */
- if (av7110->analog_tuner_flags & ANALOG_TUNER_VES1820) {
- if (ves1820_writereg(av7110->dev, 0x09, 0x0f, 0x20))
- dprintk(1, "setting band in demodulator failed.\n");
- } else if (av7110->analog_tuner_flags & ANALOG_TUNER_STV0297) {
- saa7146_setgpio(av7110->dev, 1, SAA7146_GPIO_OUTLO); // TDA9819 pin9(STD)
- saa7146_setgpio(av7110->dev, 3, SAA7146_GPIO_OUTLO); // TDA9819 pin30(VIF)
- }
-
- /* init the saa7113 */
- while (*i != 0xff) {
- if (i2c_writereg(av7110, 0x48, i[0], i[1]) != 1) {
- dprintk(1, "saa7113 initialization failed @ card %d", av7110->dvb_adapter.num);
- break;
- }
- i += 2;
- }
- /* setup msp for analog sound: B/G Dual-FM */
- msp_writereg(av7110, MSP_WR_DEM, 0x00bb, 0x02d0); // AD_CV
- msp_writereg(av7110, MSP_WR_DEM, 0x0001, 3); // FIR1
- msp_writereg(av7110, MSP_WR_DEM, 0x0001, 18); // FIR1
- msp_writereg(av7110, MSP_WR_DEM, 0x0001, 27); // FIR1
- msp_writereg(av7110, MSP_WR_DEM, 0x0001, 48); // FIR1
- msp_writereg(av7110, MSP_WR_DEM, 0x0001, 66); // FIR1
- msp_writereg(av7110, MSP_WR_DEM, 0x0001, 72); // FIR1
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 4); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 64); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 0); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 3); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 18); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 27); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 48); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 66); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0005, 72); // FIR2
- msp_writereg(av7110, MSP_WR_DEM, 0x0083, 0xa000); // MODE_REG
- msp_writereg(av7110, MSP_WR_DEM, 0x0093, 0x00aa); // DCO1_LO 5.74MHz
- msp_writereg(av7110, MSP_WR_DEM, 0x009b, 0x04fc); // DCO1_HI
- msp_writereg(av7110, MSP_WR_DEM, 0x00a3, 0x038e); // DCO2_LO 5.5MHz
- msp_writereg(av7110, MSP_WR_DEM, 0x00ab, 0x04c6); // DCO2_HI
- msp_writereg(av7110, MSP_WR_DEM, 0x0056, 0); // LOAD_REG 1/2
- }
-
- memcpy(standard, dvb_standard, sizeof(struct saa7146_standard) * 2);
- /* set dd1 stream a & b */
- saa7146_write(av7110->dev, DD1_STREAM_B, 0x00000000);
- saa7146_write(av7110->dev, DD1_INIT, 0x03000700);
- saa7146_write(av7110->dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
-
- return 0;
-}
-
-int av7110_init_v4l(struct av7110 *av7110)
-{
- struct saa7146_dev* dev = av7110->dev;
- int ret;
-
- /* special case DVB-C: these cards have an analog tuner
- plus need some special handling, so we have separate
- saa7146_ext_vv data for these... */
- if (av7110->analog_tuner_flags)
- ret = saa7146_vv_init(dev, &av7110_vv_data_c);
- else
- ret = saa7146_vv_init(dev, &av7110_vv_data_st);
-
- if (ret) {
- ERR(("cannot init capture device. skipping.\n"));
- return -ENODEV;
- }
-
- if (saa7146_register_device(&av7110->v4l_dev, dev, "av7110", VFL_TYPE_GRABBER)) {
- ERR(("cannot register capture device. skipping.\n"));
- saa7146_vv_release(dev);
- return -ENODEV;
- }
- if (saa7146_register_device(&av7110->vbi_dev, dev, "av7110", VFL_TYPE_VBI)) {
- ERR(("cannot register vbi v4l2 device. skipping.\n"));
- } else {
- if (av7110->analog_tuner_flags)
- av7110->analog_tuner_flags |= ANALOG_TUNER_VBI;
- }
- return 0;
-}
-
-int av7110_exit_v4l(struct av7110 *av7110)
-{
- saa7146_unregister_device(&av7110->v4l_dev, av7110->dev);
- if (av7110->analog_tuner_flags & ANALOG_TUNER_VBI)
- saa7146_unregister_device(&av7110->vbi_dev, av7110->dev);
- return 0;
-}
-
-
-
-/* FIXME: these values are experimental values that look better than the
- values from the latest "official" driver -- at least for me... (MiHu) */
-static struct saa7146_standard standard[] = {
- {
- .name = "PAL", .id = V4L2_STD_PAL_BG,
- .v_offset = 0x15, .v_field = 288,
- .h_offset = 0x48, .h_pixels = 708,
- .v_max_out = 576, .h_max_out = 768,
- }, {
- .name = "NTSC", .id = V4L2_STD_NTSC,
- .v_offset = 0x10, .v_field = 244,
- .h_offset = 0x40, .h_pixels = 708,
- .v_max_out = 480, .h_max_out = 640,
- }
-};
-
-static struct saa7146_standard analog_standard[] = {
- {
- .name = "PAL", .id = V4L2_STD_PAL_BG,
- .v_offset = 0x1b, .v_field = 288,
- .h_offset = 0x08, .h_pixels = 708,
- .v_max_out = 576, .h_max_out = 768,
- }, {
- .name = "NTSC", .id = V4L2_STD_NTSC,
- .v_offset = 0x10, .v_field = 244,
- .h_offset = 0x40, .h_pixels = 708,
- .v_max_out = 480, .h_max_out = 640,
- }
-};
-
-static struct saa7146_standard dvb_standard[] = {
- {
- .name = "PAL", .id = V4L2_STD_PAL_BG,
- .v_offset = 0x14, .v_field = 288,
- .h_offset = 0x48, .h_pixels = 708,
- .v_max_out = 576, .h_max_out = 768,
- }, {
- .name = "NTSC", .id = V4L2_STD_NTSC,
- .v_offset = 0x10, .v_field = 244,
- .h_offset = 0x40, .h_pixels = 708,
- .v_max_out = 480, .h_max_out = 640,
- }
-};
-
-static int std_callback(struct saa7146_dev* dev, struct saa7146_standard *std)
-{
- struct av7110 *av7110 = (struct av7110*) dev->ext_priv;
-
- if (std->id & V4L2_STD_PAL) {
- av7110->vidmode = VIDEO_MODE_PAL;
- av7110_set_vidmode(av7110, av7110->vidmode);
- }
- else if (std->id & V4L2_STD_NTSC) {
- av7110->vidmode = VIDEO_MODE_NTSC;
- av7110_set_vidmode(av7110, av7110->vidmode);
- }
- else
- return -1;
-
- return 0;
-}
-
-
-static struct saa7146_ext_vv av7110_vv_data_st = {
- .inputs = 1,
- .audios = 1,
- .capabilities = V4L2_CAP_SLICED_VBI_OUTPUT,
- .flags = 0,
-
- .stds = &standard[0],
- .num_stds = ARRAY_SIZE(standard),
- .std_callback = &std_callback,
-
- .ioctls = &ioctls[0],
- .ioctl = av7110_ioctl,
-
- .vbi_fops.open = av7110_vbi_reset,
- .vbi_fops.release = av7110_vbi_reset,
- .vbi_fops.write = av7110_vbi_write,
-};
-
-static struct saa7146_ext_vv av7110_vv_data_c = {
- .inputs = 1,
- .audios = 1,
- .capabilities = V4L2_CAP_TUNER | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT,
- .flags = SAA7146_USE_PORT_B_FOR_VBI,
-
- .stds = &standard[0],
- .num_stds = ARRAY_SIZE(standard),
- .std_callback = &std_callback,
-
- .ioctls = &ioctls[0],
- .ioctl = av7110_ioctl,
-
- .vbi_fops.open = av7110_vbi_reset,
- .vbi_fops.release = av7110_vbi_reset,
- .vbi_fops.write = av7110_vbi_write,
-};
-
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c
deleted file mode 100644
index 2d21fec23b4..00000000000
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ /dev/null
@@ -1,1452 +0,0 @@
-/*
- * budget-av.c: driver for the SAA7146 based Budget DVB cards
- * with analog video in
- *
- * Compiled from various sources by Michael Hunold <michael@mihu.de>
- *
- * CI interface support (c) 2004 Olivier Gournet <ogournet@anevia.com> &
- * Andrew de Quincey <adq_dvb@lidskialf.net>
- *
- * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include "budget.h"
-#include "stv0299.h"
-#include "tda10021.h"
-#include "tda1004x.h"
-#include "dvb-pll.h"
-#include <media/saa7146_vv.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/input.h>
-#include <linux/spinlock.h>
-
-#include "dvb_ca_en50221.h"
-
-#define DEBICICAM 0x02420000
-
-#define SLOTSTATUS_NONE 1
-#define SLOTSTATUS_PRESENT 2
-#define SLOTSTATUS_RESET 4
-#define SLOTSTATUS_READY 8
-#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
-
-struct budget_av {
- struct budget budget;
- struct video_device *vd;
- int cur_input;
- int has_saa7113;
- struct tasklet_struct ciintf_irq_tasklet;
- int slot_status;
- struct dvb_ca_en50221 ca;
- u8 reinitialise_demod:1;
- u8 tda10021_poclkp:1;
- u8 tda10021_ts_enabled;
- int (*tda10021_set_frontend)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
-};
-
-static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot);
-
-
-/* GPIO Connections:
- * 0 - Vcc/Reset (Reset is controlled by capacitor). Resets the frontend *AS WELL*!
- * 1 - CI memory select 0=>IO memory, 1=>Attribute Memory
- * 2 - CI Card Enable (Active Low)
- * 3 - CI Card Detect
- */
-
-/****************************************************************************
- * INITIALIZATION
- ****************************************************************************/
-
-static u8 i2c_readreg(struct i2c_adapter *i2c, u8 id, u8 reg)
-{
- u8 mm1[] = { 0x00 };
- u8 mm2[] = { 0x00 };
- struct i2c_msg msgs[2];
-
- msgs[0].flags = 0;
- msgs[1].flags = I2C_M_RD;
- msgs[0].addr = msgs[1].addr = id / 2;
- mm1[0] = reg;
- msgs[0].len = 1;
- msgs[1].len = 1;
- msgs[0].buf = mm1;
- msgs[1].buf = mm2;
-
- i2c_transfer(i2c, msgs, 2);
-
- return mm2[0];
-}
-
-static int i2c_readregs(struct i2c_adapter *i2c, u8 id, u8 reg, u8 * buf, u8 len)
-{
- u8 mm1[] = { reg };
- struct i2c_msg msgs[2] = {
- {.addr = id / 2,.flags = 0,.buf = mm1,.len = 1},
- {.addr = id / 2,.flags = I2C_M_RD,.buf = buf,.len = len}
- };
-
- if (i2c_transfer(i2c, msgs, 2) != 2)
- return -EIO;
-
- return 0;
-}
-
-static int i2c_writereg(struct i2c_adapter *i2c, u8 id, u8 reg, u8 val)
-{
- u8 msg[2] = { reg, val };
- struct i2c_msg msgs;
-
- msgs.flags = 0;
- msgs.addr = id / 2;
- msgs.len = 2;
- msgs.buf = msg;
- return i2c_transfer(i2c, &msgs, 1);
-}
-
-static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- int result;
-
- if (slot != 0)
- return -EINVAL;
-
- saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
- udelay(1);
-
- result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 0xfff, 1, 0, 1);
- if (result == -ETIMEDOUT) {
- ciintf_slot_shutdown(ca, slot);
- printk(KERN_INFO "budget-av: cam ejected 1\n");
- }
- return result;
-}
-
-static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- int result;
-
- if (slot != 0)
- return -EINVAL;
-
- saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTHI);
- udelay(1);
-
- result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 0xfff, 1, value, 0, 1);
- if (result == -ETIMEDOUT) {
- ciintf_slot_shutdown(ca, slot);
- printk(KERN_INFO "budget-av: cam ejected 2\n");
- }
- return result;
-}
-
-static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- int result;
-
- if (slot != 0)
- return -EINVAL;
-
- saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
- udelay(1);
-
- result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0);
- if ((result == -ETIMEDOUT) || ((result == 0xff) && ((address & 3) < 2))) {
- ciintf_slot_shutdown(ca, slot);
- printk(KERN_INFO "budget-av: cam ejected 3\n");
- return -ETIMEDOUT;
- }
- return result;
-}
-
-static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- int result;
-
- if (slot != 0)
- return -EINVAL;
-
- saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
- udelay(1);
-
- result = ttpci_budget_debiwrite(&budget_av->budget, DEBICICAM, address & 3, 1, value, 0, 0);
- if (result == -ETIMEDOUT) {
- ciintf_slot_shutdown(ca, slot);
- printk(KERN_INFO "budget-av: cam ejected 5\n");
- }
- return result;
-}
-
-static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- struct saa7146_dev *saa = budget_av->budget.dev;
-
- if (slot != 0)
- return -EINVAL;
-
- dprintk(1, "ciintf_slot_reset\n");
- budget_av->slot_status = SLOTSTATUS_RESET;
-
- saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTHI); /* disable card */
-
- saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI); /* Vcc off */
- msleep(2);
- saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO); /* Vcc on */
- msleep(20); /* 20 ms Vcc settling time */
-
- saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO); /* enable card */
- ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
- msleep(20);
-
- /* reinitialise the frontend if necessary */
- if (budget_av->reinitialise_demod)
- dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
-
- /* set tda10021 back to original clock configuration on reset */
- if (budget_av->tda10021_poclkp) {
- tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0);
- budget_av->tda10021_ts_enabled = 0;
- }
-
- return 0;
-}
-
-static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- struct saa7146_dev *saa = budget_av->budget.dev;
-
- if (slot != 0)
- return -EINVAL;
-
- dprintk(1, "ciintf_slot_shutdown\n");
-
- ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
- budget_av->slot_status = SLOTSTATUS_NONE;
-
- /* set tda10021 back to original clock configuration when cam removed */
- if (budget_av->tda10021_poclkp) {
- tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0);
- budget_av->tda10021_ts_enabled = 0;
- }
- return 0;
-}
-
-static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- struct saa7146_dev *saa = budget_av->budget.dev;
-
- if (slot != 0)
- return -EINVAL;
-
- dprintk(1, "ciintf_slot_ts_enable: %d\n", budget_av->slot_status);
-
- ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
-
- /* tda10021 seems to need a different TS clock config when data is routed to the CAM */
- if (budget_av->tda10021_poclkp) {
- tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1);
- budget_av->tda10021_ts_enabled = 1;
- }
-
- return 0;
-}
-
-static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
-{
- struct budget_av *budget_av = (struct budget_av *) ca->data;
- struct saa7146_dev *saa = budget_av->budget.dev;
- int result;
-
- if (slot != 0)
- return -EINVAL;
-
- /* test the card detect line - needs to be done carefully
- * since it never goes high for some CAMs on this interface (e.g. topuptv) */
- if (budget_av->slot_status == SLOTSTATUS_NONE) {
- saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
- udelay(1);
- if (saa7146_read(saa, PSR) & MASK_06) {
- if (budget_av->slot_status == SLOTSTATUS_NONE) {
- budget_av->slot_status = SLOTSTATUS_PRESENT;
- printk(KERN_INFO "budget-av: cam inserted A\n");
- }
- }
- saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
- }
-
- /* We also try and read from IO memory to work round the above detection bug. If
- * there is no CAM, we will get a timeout. Only done if there is no cam
- * present, since this test actually breaks some cams :(
- *
- * if the CI interface is not open, we also do the above test since we
- * don't care if the cam has problems - we'll be resetting it on open() anyway */
- if ((budget_av->slot_status == SLOTSTATUS_NONE) || (!open)) {
- saa7146_setgpio(budget_av->budget.dev, 1, SAA7146_GPIO_OUTLO);
- result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, 0, 1, 0, 1);
- if ((result >= 0) && (budget_av->slot_status == SLOTSTATUS_NONE)) {
- budget_av->slot_status = SLOTSTATUS_PRESENT;
- printk(KERN_INFO "budget-av: cam inserted B\n");
- } else if (result < 0) {
- if (budget_av->slot_status != SLOTSTATUS_NONE) {
- ciintf_slot_shutdown(ca, slot);
- printk(KERN_INFO "budget-av: cam ejected 5\n");
- return 0;
- }
- }
- }
-
- /* read from attribute memory in reset/ready state to know when the CAM is ready */
- if (budget_av->slot_status == SLOTSTATUS_RESET) {
- result = ciintf_read_attribute_mem(ca, slot, 0);
- if (result == 0x1d) {
- budget_av->slot_status = SLOTSTATUS_READY;
- }
- }
-
- /* work out correct return code */
- if (budget_av->slot_status != SLOTSTATUS_NONE) {
- if (budget_av->slot_status & SLOTSTATUS_READY) {
- return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
- }
- return DVB_CA_EN50221_POLL_CAM_PRESENT;
- }
- return 0;
-}
-
-static int ciintf_init(struct budget_av *budget_av)
-{
- struct saa7146_dev *saa = budget_av->budget.dev;
- int result;
-
- memset(&budget_av->ca, 0, sizeof(struct dvb_ca_en50221));
-
- saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
- saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
- saa7146_setgpio(saa, 2, SAA7146_GPIO_OUTLO);
- saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTLO);
-
- /* Enable DEBI pins */
- saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
-
- /* register CI interface */
- budget_av->ca.owner = THIS_MODULE;
- budget_av->ca.read_attribute_mem = ciintf_read_attribute_mem;
- budget_av->ca.write_attribute_mem = ciintf_write_attribute_mem;
- budget_av->ca.read_cam_control = ciintf_read_cam_control;
- budget_av->ca.write_cam_control = ciintf_write_cam_control;
- budget_av->ca.slot_reset = ciintf_slot_reset;
- budget_av->ca.slot_shutdown = ciintf_slot_shutdown;
- budget_av->ca.slot_ts_enable = ciintf_slot_ts_enable;
- budget_av->ca.poll_slot_status = ciintf_poll_slot_status;
- budget_av->ca.data = budget_av;
- budget_av->budget.ci_present = 1;
- budget_av->slot_status = SLOTSTATUS_NONE;
-
- if ((result = dvb_ca_en50221_init(&budget_av->budget.dvb_adapter,
- &budget_av->ca, 0, 1)) != 0) {
- printk(KERN_ERR "budget-av: ci initialisation failed.\n");
- goto error;
- }
-
- printk(KERN_INFO "budget-av: ci interface initialised.\n");
- return 0;
-
-error:
- saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16));
- return result;
-}
-
-static void ciintf_deinit(struct budget_av *budget_av)
-{
- struct saa7146_dev *saa = budget_av->budget.dev;
-
- saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
- saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
- saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
- saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
-
- /* release the CA device */
- dvb_ca_en50221_release(&budget_av->ca);
-
- /* disable DEBI pins */
- saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16));
-}
-
-
-static const u8 saa7113_tab[] = {
- 0x01, 0x08,
- 0x02, 0xc0,
- 0x03, 0x33,
- 0x04, 0x00,
- 0x05, 0x00,
- 0x06, 0xeb,
- 0x07, 0xe0,
- 0x08, 0x28,
- 0x09, 0x00,
- 0x0a, 0x80,
- 0x0b, 0x47,
- 0x0c, 0x40,
- 0x0d, 0x00,
- 0x0e, 0x01,
- 0x0f, 0x44,
-
- 0x10, 0x08,
- 0x11, 0x0c,
- 0x12, 0x7b,
- 0x13, 0x00,
- 0x15, 0x00, 0x16, 0x00, 0x17, 0x00,
-
- 0x57, 0xff,
- 0x40, 0x82, 0x58, 0x00, 0x59, 0x54, 0x5a, 0x07,
- 0x5b, 0x83, 0x5e, 0x00,
- 0xff
-};
-
-static int saa7113_init(struct budget_av *budget_av)
-{
- struct budget *budget = &budget_av->budget;
- struct saa7146_dev *saa = budget->dev;
- const u8 *data = saa7113_tab;
-
- saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTHI);
- msleep(200);
-
- if (i2c_writereg(&budget->i2c_adap, 0x4a, 0x01, 0x08) != 1) {
- dprintk(1, "saa7113 not found on KNC card\n");
- return -ENODEV;
- }
-
- dprintk(1, "saa7113 detected and initializing\n");
-
- while (*data != 0xff) {
- i2c_writereg(&budget->i2c_adap, 0x4a, *data, *(data + 1));
- data += 2;
- }
-
- dprintk(1, "saa7113 status=%02x\n", i2c_readreg(&budget->i2c_adap, 0x4a, 0x1f));
-
- return 0;
-}
-
-static int saa7113_setinput(struct budget_av *budget_av, int input)
-{
- struct budget *budget = &budget_av->budget;
-
- if (1 != budget_av->has_saa7113)
- return -ENODEV;
-
- if (input == 1) {
- i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc7);
- i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x80);
- } else if (input == 0) {
- i2c_writereg(&budget->i2c_adap, 0x4a, 0x02, 0xc0);
- i2c_writereg(&budget->i2c_adap, 0x4a, 0x09, 0x00);
- } else
- return -EINVAL;
-
- budget_av->cur_input = input;
- return 0;
-}
-
-
-static int philips_su1278_ty_ci_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
-{
- u8 aclk = 0;
- u8 bclk = 0;
- u8 m1;
-
- aclk = 0xb5;
- if (srate < 2000000)
- bclk = 0x86;
- else if (srate < 5000000)
- bclk = 0x89;
- else if (srate < 15000000)
- bclk = 0x8f;
- else if (srate < 45000000)
- bclk = 0x95;
-
- m1 = 0x14;
- if (srate < 4000000)
- m1 = 0x10;
-
- stv0299_writereg(fe, 0x13, aclk);
- stv0299_writereg(fe, 0x14, bclk);
- stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
- stv0299_writereg(fe, 0x0f, 0x80 | m1);
-
- return 0;
-}
-
-static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *params)
-{
- u32 div;
- u8 buf[4];
- struct budget *budget = (struct budget *) fe->dvb->priv;
- struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
-
- if ((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- div = (params->frequency + (125 - 1)) / 125; // round correctly
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
- buf[3] = 0x20;
-
- if (params->u.qpsk.symbol_rate < 4000000)
- buf[3] |= 1;
-
- if (params->frequency < 1250000)
- buf[3] |= 0;
- else if (params->frequency < 1550000)
- buf[3] |= 0x40;
- else if (params->frequency < 2050000)
- buf[3] |= 0x80;
- else if (params->frequency < 2150000)
- buf[3] |= 0xC0;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-#define MIN2(a,b) ((a) < (b) ? (a) : (b))
-#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
-
-static int philips_su1278sh2_tua6100_tuner_set_params(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *params)
-{
- u8 reg0 [2] = { 0x00, 0x00 };
- u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 };
- u8 reg2 [3] = { 0x02, 0x00, 0x00 };
- int _fband;
- int first_ZF;
- int R, A, N, P, M;
- struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 };
- int freq = params->frequency;
- struct budget *budget = (struct budget *) fe->dvb->priv;
-
- first_ZF = (freq) / 1000;
-
- if (abs(MIN2(abs(first_ZF-1190),abs(first_ZF-1790))) <
- abs(MIN3(abs(first_ZF-1202),abs(first_ZF-1542),abs(first_ZF-1890))))
- _fband = 2;
- else
- _fband = 3;
-
- if (_fband == 2) {
- if (((first_ZF >= 950) && (first_ZF < 1350)) ||
- ((first_ZF >= 1430) && (first_ZF < 1950)))
- reg0[1] = 0x07;
- else if (((first_ZF >= 1350) && (first_ZF < 1430)) ||
- ((first_ZF >= 1950) && (first_ZF < 2150)))
- reg0[1] = 0x0B;
- }
-
- if(_fband == 3) {
- if (((first_ZF >= 950) && (first_ZF < 1350)) ||
- ((first_ZF >= 1455) && (first_ZF < 1950)))
- reg0[1] = 0x07;
- else if (((first_ZF >= 1350) && (first_ZF < 1420)) ||
- ((first_ZF >= 1950) && (first_ZF < 2150)))
- reg0[1] = 0x0B;
- else if ((first_ZF >= 1420) && (first_ZF < 1455))
- reg0[1] = 0x0F;
- }
-
- if (first_ZF > 1525)
- reg1[1] |= 0x80;
- else
- reg1[1] &= 0x7F;
-
- if (_fband == 2) {
- if (first_ZF > 1430) { /* 1430MHZ */
- reg1[1] &= 0xCF; /* N2 */
- reg2[1] &= 0xCF; /* R2 */
- reg2[1] |= 0x10;
- } else {
- reg1[1] &= 0xCF; /* N2 */
- reg1[1] |= 0x20;
- reg2[1] &= 0xCF; /* R2 */
- reg2[1] |= 0x10;
- }
- }
-
- if (_fband == 3) {
- if ((first_ZF >= 1455) &&
- (first_ZF < 1630)) {
- reg1[1] &= 0xCF; /* N2 */
- reg1[1] |= 0x20;
- reg2[1] &= 0xCF; /* R2 */
- } else {
- if (first_ZF < 1455) {
- reg1[1] &= 0xCF; /* N2 */
- reg1[1] |= 0x20;
- reg2[1] &= 0xCF; /* R2 */
- reg2[1] |= 0x10;
- } else {
- if (first_ZF >= 1630) {
- reg1[1] &= 0xCF; /* N2 */
- reg2[1] &= 0xCF; /* R2 */
- reg2[1] |= 0x10;
- }
- }
- }
- }
-
- /* set ports, enable P0 for symbol rates > 4Ms/s */
- if (params->u.qpsk.symbol_rate >= 4000000)
- reg1[1] |= 0x0c;
- else
- reg1[1] |= 0x04;
-
- reg2[1] |= 0x0c;
-
- R = 64;
- A = 64;
- P = 64; //32
-
- M = (freq * R) / 4; /* in Mhz */
- N = (M - A * 1000) / (P * 1000);
-
- reg1[1] |= (N >> 9) & 0x03;
- reg1[2] = (N >> 1) & 0xff;
- reg1[3] = (N << 7) & 0x80;
-
- reg2[1] |= (R >> 8) & 0x03;
- reg2[2] = R & 0xFF; /* R */
-
- reg1[3] |= A & 0x7f; /* A */
-
- if (P == 64)
- reg1[1] |= 0x40; /* Prescaler 64/65 */
-
- reg0[1] |= 0x03;
-
- /* already enabled - do not reenable i2c repeater or TX fails */
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- msg.buf = reg0;
- msg.len = sizeof(reg0);
- if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- msg.buf = reg1;
- msg.len = sizeof(reg1);
- if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- msg.buf = reg2;
- msg.len = sizeof(reg2);
- if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
-
- return 0;
-}
-
-static u8 typhoon_cinergy1200s_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- 0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
- 0x08, 0x40, /* DiSEqC off */
- 0x09, 0x00, /* FIFO */
- 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
- 0x10, 0x3f, // AGC2 0x3d
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9, // lock detector threshold
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
- 0x29, 0x1e, // 1/2 threshold
- 0x2a, 0x14, // 2/3 threshold
- 0x2b, 0x0f, // 3/4 threshold
- 0x2c, 0x09, // 5/6 threshold
- 0x2d, 0x05, // 7/8 threshold
- 0x2e, 0x01,
- 0x31, 0x1f, // test all FECs
- 0x32, 0x19, // viterbi and synchro search
- 0x33, 0xfc, // rs control
- 0x34, 0x93, // error control
- 0x0f, 0x92,
- 0xff, 0xff
-};
-
-static struct stv0299_config typhoon_config = {
- .demod_address = 0x68,
- .inittab = typhoon_cinergy1200s_inittab,
- .mclk = 88000000UL,
- .invert = 0,
- .skip_reinit = 0,
- .lock_output = STV0229_LOCKOUTPUT_1,
- .volt13_op0_op1 = STV0299_VOLT13_OP0,
- .min_delay_ms = 100,
- .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
-};
-
-
-static struct stv0299_config cinergy_1200s_config = {
- .demod_address = 0x68,
- .inittab = typhoon_cinergy1200s_inittab,
- .mclk = 88000000UL,
- .invert = 0,
- .skip_reinit = 0,
- .lock_output = STV0229_LOCKOUTPUT_0,
- .volt13_op0_op1 = STV0299_VOLT13_OP0,
- .min_delay_ms = 100,
- .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
-};
-
-static struct stv0299_config cinergy_1200s_1894_0010_config = {
- .demod_address = 0x68,
- .inittab = typhoon_cinergy1200s_inittab,
- .mclk = 88000000UL,
- .invert = 1,
- .skip_reinit = 0,
- .lock_output = STV0229_LOCKOUTPUT_1,
- .volt13_op0_op1 = STV0299_VOLT13_OP0,
- .min_delay_ms = 100,
- .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate,
-};
-
-static int philips_cu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct budget *budget = (struct budget *) fe->dvb->priv;
- u8 buf[4];
- struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
-
-#define TUNER_MUL 62500
-
- u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x86;
- buf[3] = (params->frequency < 150000000 ? 0x01 :
- params->frequency < 445000000 ? 0x02 : 0x04);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct tda10021_config philips_cu1216_config = {
- .demod_address = 0x0c,
-};
-
-
-
-
-static int philips_tu1216_tuner_init(struct dvb_frontend *fe)
-{
- struct budget *budget = (struct budget *) fe->dvb->priv;
- static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
- struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
-
- // setup PLL configuration
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
- msleep(1);
-
- return 0;
-}
-
-static int philips_tu1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct budget *budget = (struct budget *) fe->dvb->priv;
- u8 tuner_buf[4];
- struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,.len =
- sizeof(tuner_buf) };
- int tuner_frequency = 0;
- u8 band, cp, filter;
-
- // determine charge pump
- tuner_frequency = params->frequency + 36166000;
- if (tuner_frequency < 87000000)
- return -EINVAL;
- else if (tuner_frequency < 130000000)
- cp = 3;
- else if (tuner_frequency < 160000000)
- cp = 5;
- else if (tuner_frequency < 200000000)
- cp = 6;
- else if (tuner_frequency < 290000000)
- cp = 3;
- else if (tuner_frequency < 420000000)
- cp = 5;
- else if (tuner_frequency < 480000000)
- cp = 6;
- else if (tuner_frequency < 620000000)
- cp = 3;
- else if (tuner_frequency < 830000000)
- cp = 5;
- else if (tuner_frequency < 895000000)
- cp = 7;
- else
- return -EINVAL;
-
- // determine band
- if (params->frequency < 49000000)
- return -EINVAL;
- else if (params->frequency < 161000000)
- band = 1;
- else if (params->frequency < 444000000)
- band = 2;
- else if (params->frequency < 861000000)
- band = 4;
- else
- return -EINVAL;
-
- // setup PLL filter
- switch (params->u.ofdm.bandwidth) {
- case BANDWIDTH_6_MHZ:
- filter = 0;
- break;
-
- case BANDWIDTH_7_MHZ:
- filter = 0;
- break;
-
- case BANDWIDTH_8_MHZ:
- filter = 1;
- break;
-
- default:
- return -EINVAL;
- }
-
- // calculate divisor
- // ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
- tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
-
- // setup tuner buffer
- tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
- tuner_buf[1] = tuner_frequency & 0xff;
- tuner_buf[2] = 0xca;
- tuner_buf[3] = (cp << 5) | (filter << 3) | band;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
-
- msleep(1);
- return 0;
-}
-
-static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
- const struct firmware **fw, char *name)
-{
- struct budget *budget = (struct budget *) fe->dvb->priv;
-
- return request_firmware(fw, name, &budget->dev->pci->dev);
-}
-
-static struct tda1004x_config philips_tu1216_config = {
-
- .demod_address = 0x8,
- .invert = 1,
- .invert_oclk = 1,
- .xtal_freq = TDA10046_XTAL_4M,
- .agc_config = TDA10046_AGC_DEFAULT,
- .if_freq = TDA10046_FREQ_3617,
- .request_firmware = philips_tu1216_request_firmware,
-};
-
-static u8 philips_sd1878_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7d,
- 0x05, 0x35,
- 0x06, 0x40,
- 0x07, 0x00,
- 0x08, 0x43,
- 0x09, 0x02,
- 0x0C, 0x51,
- 0x0D, 0x82,
- 0x0E, 0x23,
- 0x10, 0x3f,
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9,
- 0x16, 0x19,
- 0x17, 0x8c,
- 0x18, 0x59,
- 0x19, 0xf8,
- 0x1a, 0xfe,
- 0x1c, 0x7f,
- 0x1d, 0x00,
- 0x1e, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00,
- 0x29, 0x28,
- 0x2a, 0x14,
- 0x2b, 0x0f,
- 0x2c, 0x09,
- 0x2d, 0x09,
- 0x31, 0x1f,
- 0x32, 0x19,
- 0x33, 0xfc,
- 0x34, 0x93,
- 0xff, 0xff
-};
-
-static int philips_sd1878_tda8261_tuner_set_params(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *params)
-{
- u8 buf[4];
- int rc;
- struct i2c_msg tuner_msg = {.addr=0x60,.flags=0,.buf=buf,.len=sizeof(buf)};
- struct budget *budget = (struct budget *) fe->dvb->priv;
-
- if((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- rc=dvb_pll_configure(&dvb_pll_philips_sd1878_tda8261, buf,
- params->frequency, 0);
- if(rc < 0) return rc;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if(i2c_transfer(&budget->i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
-
- return 0;
-}
-
-static int philips_sd1878_ci_set_symbol_rate(struct dvb_frontend *fe,
- u32 srate, u32 ratio)
-{
- u8 aclk = 0;
- u8 bclk = 0;
- u8 m1;
-
- aclk = 0xb5;
- if (srate < 2000000)
- bclk = 0x86;
- else if (srate < 5000000)
- bclk = 0x89;
- else if (srate < 15000000)
- bclk = 0x8f;
- else if (srate < 45000000)
- bclk = 0x95;
-
- m1 = 0x14;
- if (srate < 4000000)
- m1 = 0x10;
-
- stv0299_writereg(fe, 0x0e, 0x23);
- stv0299_writereg(fe, 0x0f, 0x94);
- stv0299_writereg(fe, 0x10, 0x39);
- stv0299_writereg(fe, 0x13, aclk);
- stv0299_writereg(fe, 0x14, bclk);
- stv0299_writereg(fe, 0x15, 0xc9);
- stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
- stv0299_writereg(fe, 0x0f, 0x80 | m1);
-
- return 0;
-}
-
-static struct stv0299_config philips_sd1878_config = {
- .demod_address = 0x68,
- .inittab = philips_sd1878_inittab,
- .mclk = 88000000UL,
- .invert = 0,
- .skip_reinit = 0,
- .lock_output = STV0229_LOCKOUTPUT_1,
- .volt13_op0_op1 = STV0299_VOLT13_OP0,
- .min_delay_ms = 100,
- .set_symbol_rate = philips_sd1878_ci_set_symbol_rate,
-};
-
-static u8 read_pwm(struct budget_av *budget_av)
-{
- u8 b = 0xff;
- u8 pwm;
- struct i2c_msg msg[] = { {.addr = 0x50,.flags = 0,.buf = &b,.len = 1},
- {.addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1}
- };
-
- if ((i2c_transfer(&budget_av->budget.i2c_adap, msg, 2) != 2)
- || (pwm == 0xff))
- pwm = 0x48;
-
- return pwm;
-}
-
-#define SUBID_DVBS_KNC1 0x0010
-#define SUBID_DVBS_KNC1_PLUS 0x0011
-#define SUBID_DVBS_TYPHOON 0x4f56
-#define SUBID_DVBS_CINERGY1200 0x1154
-#define SUBID_DVBS_CYNERGY1200N 0x1155
-
-#define SUBID_DVBS_TV_STAR 0x0014
-#define SUBID_DVBS_TV_STAR_CI 0x0016
-#define SUBID_DVBS_EASYWATCH_1 0x001a
-#define SUBID_DVBS_EASYWATCH 0x001e
-#define SUBID_DVBC_KNC1 0x0020
-#define SUBID_DVBC_KNC1_PLUS 0x0021
-#define SUBID_DVBC_CINERGY1200 0x1156
-
-#define SUBID_DVBT_KNC1_PLUS 0x0031
-#define SUBID_DVBT_KNC1 0x0030
-#define SUBID_DVBT_CINERGY1200 0x1157
-
-
-static int tda10021_set_frontend(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *p)
-{
- struct budget_av* budget_av = fe->dvb->priv;
- int result;
-
- result = budget_av->tda10021_set_frontend(fe, p);
- if (budget_av->tda10021_ts_enabled) {
- tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa1);
- } else {
- tda10021_write_byte(budget_av->budget.dvb_frontend, 0x12, 0xa0);
- }
-
- return result;
-}
-
-static void frontend_init(struct budget_av *budget_av)
-{
- struct saa7146_dev * saa = budget_av->budget.dev;
- struct dvb_frontend * fe = NULL;
-
- /* Enable / PowerON Frontend */
- saa7146_setgpio(saa, 0, SAA7146_GPIO_OUTLO);
-
- /* additional setup necessary for the PLUS cards */
- switch (saa->pci->subsystem_device) {
- case SUBID_DVBS_KNC1_PLUS:
- case SUBID_DVBC_KNC1_PLUS:
- case SUBID_DVBT_KNC1_PLUS:
- saa7146_setgpio(saa, 3, SAA7146_GPIO_OUTHI);
- break;
- }
-
- switch (saa->pci->subsystem_device) {
-
- case SUBID_DVBS_KNC1:
- case SUBID_DVBS_EASYWATCH_1:
- if (saa->pci->subsystem_vendor == 0x1894) {
- fe = stv0299_attach(&cinergy_1200s_1894_0010_config,
- &budget_av->budget.i2c_adap);
- if (fe) {
- fe->ops.tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params;
- }
- } else {
- fe = stv0299_attach(&typhoon_config,
- &budget_av->budget.i2c_adap);
- if (fe) {
- fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
- }
- }
- break;
-
- case SUBID_DVBS_TV_STAR:
- case SUBID_DVBS_TV_STAR_CI:
- case SUBID_DVBS_CYNERGY1200N:
- case SUBID_DVBS_EASYWATCH:
- fe = stv0299_attach(&philips_sd1878_config,
- &budget_av->budget.i2c_adap);
- if (fe) {
- fe->ops.tuner_ops.set_params = philips_sd1878_tda8261_tuner_set_params;
- }
- break;
-
- case SUBID_DVBS_KNC1_PLUS:
- case SUBID_DVBS_TYPHOON:
- fe = stv0299_attach(&typhoon_config,
- &budget_av->budget.i2c_adap);
- if (fe) {
- fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
- }
- break;
-
- case SUBID_DVBS_CINERGY1200:
- fe = stv0299_attach(&cinergy_1200s_config,
- &budget_av->budget.i2c_adap);
- if (fe) {
- fe->ops.tuner_ops.set_params = philips_su1278_ty_ci_tuner_set_params;
- }
- break;
-
- case SUBID_DVBC_KNC1:
- budget_av->reinitialise_demod = 1;
- fe = tda10021_attach(&philips_cu1216_config,
- &budget_av->budget.i2c_adap,
- read_pwm(budget_av));
- if (fe) {
- fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
- }
- break;
-
- case SUBID_DVBC_KNC1_PLUS:
- case SUBID_DVBC_CINERGY1200:
- budget_av->reinitialise_demod = 1;
- fe = tda10021_attach(&philips_cu1216_config,
- &budget_av->budget.i2c_adap,
- read_pwm(budget_av));
- if (fe) {
- budget_av->tda10021_poclkp = 1;
- budget_av->tda10021_set_frontend = fe->ops.set_frontend;
- fe->ops.set_frontend = tda10021_set_frontend;
- fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
- }
- break;
-
- case SUBID_DVBT_KNC1:
- case SUBID_DVBT_KNC1_PLUS:
- case SUBID_DVBT_CINERGY1200:
- budget_av->reinitialise_demod = 1;
- fe = tda10046_attach(&philips_tu1216_config,
- &budget_av->budget.i2c_adap);
- if (fe) {
- fe->ops.tuner_ops.init = philips_tu1216_tuner_init;
- fe->ops.tuner_ops.set_params = philips_tu1216_tuner_set_params;
- }
- break;
- }
-
- if (fe == NULL) {
- printk(KERN_ERR "budget-av: A frontend driver was not found "
- "for device %04x/%04x subsystem %04x/%04x\n",
- saa->pci->vendor,
- saa->pci->device,
- saa->pci->subsystem_vendor,
- saa->pci->subsystem_device);
- return;
- }
-
- budget_av->budget.dvb_frontend = fe;
-
- if (dvb_register_frontend(&budget_av->budget.dvb_adapter,
- budget_av->budget.dvb_frontend)) {
- printk(KERN_ERR "budget-av: Frontend registration failed!\n");
- if (budget_av->budget.dvb_frontend->ops.release)
- budget_av->budget.dvb_frontend->ops.release(budget_av->budget.dvb_frontend);
- budget_av->budget.dvb_frontend = NULL;
- }
-}
-
-
-static void budget_av_irq(struct saa7146_dev *dev, u32 * isr)
-{
- struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
-
- dprintk(8, "dev: %p, budget_av: %p\n", dev, budget_av);
-
- if (*isr & MASK_10)
- ttpci_budget_irq10_handler(dev, isr);
-}
-
-static int budget_av_detach(struct saa7146_dev *dev)
-{
- struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
- int err;
-
- dprintk(2, "dev: %p\n", dev);
-
- if (1 == budget_av->has_saa7113) {
- saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO);
-
- msleep(200);
-
- saa7146_unregister_device(&budget_av->vd, dev);
- }
-
- if (budget_av->budget.ci_present)
- ciintf_deinit(budget_av);
-
- if (budget_av->budget.dvb_frontend != NULL)
- dvb_unregister_frontend(budget_av->budget.dvb_frontend);
- err = ttpci_budget_deinit(&budget_av->budget);
-
- kfree(budget_av);
-
- return err;
-}
-
-static struct saa7146_ext_vv vv_data;
-
-static int budget_av_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
-{
- struct budget_av *budget_av;
- u8 *mac;
- int err;
-
- dprintk(2, "dev: %p\n", dev);
-
- if (!(budget_av = kzalloc(sizeof(struct budget_av), GFP_KERNEL)))
- return -ENOMEM;
-
- budget_av->has_saa7113 = 0;
- budget_av->budget.ci_present = 0;
-
- dev->ext_priv = budget_av;
-
- if ((err = ttpci_budget_init(&budget_av->budget, dev, info, THIS_MODULE))) {
- kfree(budget_av);
- return err;
- }
-
- /* knc1 initialization */
- saa7146_write(dev, DD1_STREAM_B, 0x04000000);
- saa7146_write(dev, DD1_INIT, 0x07000600);
- saa7146_write(dev, MC2, MASK_09 | MASK_25 | MASK_10 | MASK_26);
-
- if (saa7113_init(budget_av) == 0) {
- budget_av->has_saa7113 = 1;
-
- if (0 != saa7146_vv_init(dev, &vv_data)) {
- /* fixme: proper cleanup here */
- ERR(("cannot init vv subsystem.\n"));
- return err;
- }
-
- if ((err = saa7146_register_device(&budget_av->vd, dev, "knc1", VFL_TYPE_GRABBER))) {
- /* fixme: proper cleanup here */
- ERR(("cannot register capture v4l2 device.\n"));
- return err;
- }
-
- /* beware: this modifies dev->vv ... */
- saa7146_set_hps_source_and_sync(dev, SAA7146_HPS_SOURCE_PORT_A,
- SAA7146_HPS_SYNC_PORT_A);
-
- saa7113_setinput(budget_av, 0);
- }
-
- /* fixme: find some sane values here... */
- saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
-
- mac = budget_av->budget.dvb_adapter.proposed_mac;
- if (i2c_readregs(&budget_av->budget.i2c_adap, 0xa0, 0x30, mac, 6)) {
- printk(KERN_ERR "KNC1-%d: Could not read MAC from KNC1 card\n",
- budget_av->budget.dvb_adapter.num);
- memset(mac, 0, 6);
- } else {
- printk(KERN_INFO "KNC1-%d: MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
- budget_av->budget.dvb_adapter.num,
- mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
- }
-
- budget_av->budget.dvb_adapter.priv = budget_av;
- frontend_init(budget_av);
- ciintf_init(budget_av);
-
- ttpci_budget_init_hooks(&budget_av->budget);
-
- return 0;
-}
-
-#define KNC1_INPUTS 2
-static struct v4l2_input knc1_inputs[KNC1_INPUTS] = {
- {0, "Composite", V4L2_INPUT_TYPE_TUNER, 1, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0},
- {1, "S-Video", V4L2_INPUT_TYPE_CAMERA, 2, 0, V4L2_STD_PAL_BG | V4L2_STD_NTSC_M, 0},
-};
-
-static struct saa7146_extension_ioctls ioctls[] = {
- {VIDIOC_ENUMINPUT, SAA7146_EXCLUSIVE},
- {VIDIOC_G_INPUT, SAA7146_EXCLUSIVE},
- {VIDIOC_S_INPUT, SAA7146_EXCLUSIVE},
- {0, 0}
-};
-
-static int av_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
-{
- struct saa7146_dev *dev = fh->dev;
- struct budget_av *budget_av = (struct budget_av *) dev->ext_priv;
-
- switch (cmd) {
- case VIDIOC_ENUMINPUT:{
- struct v4l2_input *i = arg;
-
- dprintk(1, "VIDIOC_ENUMINPUT %d.\n", i->index);
- if (i->index < 0 || i->index >= KNC1_INPUTS) {
- return -EINVAL;
- }
- memcpy(i, &knc1_inputs[i->index], sizeof(struct v4l2_input));
- return 0;
- }
- case VIDIOC_G_INPUT:{
- int *input = (int *) arg;
-
- *input = budget_av->cur_input;
-
- dprintk(1, "VIDIOC_G_INPUT %d.\n", *input);
- return 0;
- }
- case VIDIOC_S_INPUT:{
- int input = *(int *) arg;
- dprintk(1, "VIDIOC_S_INPUT %d.\n", input);
- return saa7113_setinput(budget_av, input);
- }
- default:
- return -ENOIOCTLCMD;
- }
- return 0;
-}
-
-static struct saa7146_standard standard[] = {
- {.name = "PAL",.id = V4L2_STD_PAL,
- .v_offset = 0x17,.v_field = 288,
- .h_offset = 0x14,.h_pixels = 680,
- .v_max_out = 576,.h_max_out = 768 },
-
- {.name = "NTSC",.id = V4L2_STD_NTSC,
- .v_offset = 0x16,.v_field = 240,
- .h_offset = 0x06,.h_pixels = 708,
- .v_max_out = 480,.h_max_out = 640, },
-};
-
-static struct saa7146_ext_vv vv_data = {
- .inputs = 2,
- .capabilities = 0, // perhaps later: V4L2_CAP_VBI_CAPTURE, but that need tweaking with the saa7113
- .flags = 0,
- .stds = &standard[0],
- .num_stds = sizeof(standard) / sizeof(struct saa7146_standard),
- .ioctls = &ioctls[0],
- .ioctl = av_ioctl,
-};
-
-static struct saa7146_extension budget_extension;
-
-MAKE_BUDGET_INFO(knc1s, "KNC1 DVB-S", BUDGET_KNC1S);
-MAKE_BUDGET_INFO(knc1c, "KNC1 DVB-C", BUDGET_KNC1C);
-MAKE_BUDGET_INFO(knc1t, "KNC1 DVB-T", BUDGET_KNC1T);
-MAKE_BUDGET_INFO(kncxs, "KNC TV STAR DVB-S", BUDGET_TVSTAR);
-MAKE_BUDGET_INFO(satewpls, "Satelco EasyWatch DVB-S light", BUDGET_TVSTAR);
-MAKE_BUDGET_INFO(satewpls1, "Satelco EasyWatch DVB-S light", BUDGET_KNC1S);
-MAKE_BUDGET_INFO(knc1sp, "KNC1 DVB-S Plus", BUDGET_KNC1SP);
-MAKE_BUDGET_INFO(knc1cp, "KNC1 DVB-C Plus", BUDGET_KNC1CP);
-MAKE_BUDGET_INFO(knc1tp, "KNC1 DVB-T Plus", BUDGET_KNC1TP);
-MAKE_BUDGET_INFO(cin1200s, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
-MAKE_BUDGET_INFO(cin1200sn, "TerraTec Cinergy 1200 DVB-S", BUDGET_CIN1200S);
-MAKE_BUDGET_INFO(cin1200c, "Terratec Cinergy 1200 DVB-C", BUDGET_CIN1200C);
-MAKE_BUDGET_INFO(cin1200t, "Terratec Cinergy 1200 DVB-T", BUDGET_CIN1200T);
-
-static struct pci_device_id pci_tbl[] = {
- MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x4f56),
- MAKE_EXTENSION_PCI(knc1s, 0x1131, 0x0010),
- MAKE_EXTENSION_PCI(knc1s, 0x1894, 0x0010),
- MAKE_EXTENSION_PCI(knc1sp, 0x1131, 0x0011),
- MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0014),
- MAKE_EXTENSION_PCI(kncxs, 0x1894, 0x0016),
- MAKE_EXTENSION_PCI(satewpls, 0x1894, 0x001e),
- MAKE_EXTENSION_PCI(satewpls1, 0x1894, 0x001a),
- MAKE_EXTENSION_PCI(knc1c, 0x1894, 0x0020),
- MAKE_EXTENSION_PCI(knc1cp, 0x1894, 0x0021),
- MAKE_EXTENSION_PCI(knc1t, 0x1894, 0x0030),
- MAKE_EXTENSION_PCI(knc1tp, 0x1894, 0x0031),
- MAKE_EXTENSION_PCI(cin1200s, 0x153b, 0x1154),
- MAKE_EXTENSION_PCI(cin1200sn, 0x153b, 0x1155),
- MAKE_EXTENSION_PCI(cin1200c, 0x153b, 0x1156),
- MAKE_EXTENSION_PCI(cin1200t, 0x153b, 0x1157),
- {
- .vendor = 0,
- }
-};
-
-MODULE_DEVICE_TABLE(pci, pci_tbl);
-
-static struct saa7146_extension budget_extension = {
- .name = "budget_av",
- .flags = SAA7146_I2C_SHORT_DELAY,
-
- .pci_tbl = pci_tbl,
-
- .module = THIS_MODULE,
- .attach = budget_av_attach,
- .detach = budget_av_detach,
-
- .irq_mask = MASK_10,
- .irq_func = budget_av_irq,
-};
-
-static int __init budget_av_init(void)
-{
- return saa7146_register_extension(&budget_extension);
-}
-
-static void __exit budget_av_exit(void)
-{
- saa7146_unregister_extension(&budget_extension);
-}
-
-module_init(budget_av_init);
-module_exit(budget_av_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
-MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
- "budget PCI DVB w/ analog input and CI-module (e.g. the KNC cards)");
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
deleted file mode 100644
index ffbbb3e34be..00000000000
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ /dev/null
@@ -1,1185 +0,0 @@
-/*
- * budget-ci.c: driver for the SAA7146 based Budget DVB cards
- *
- * Compiled from various sources by Michael Hunold <michael@mihu.de>
- *
- * msp430 IR support contributed by Jack Thomasson <jkt@Helius.COM>
- * partially based on the Siemens DVB driver by Ralph+Marcus Metzler
- *
- * CI interface support (c) 2004 Andrew de Quincey <adq_dvb@lidskialf.net>
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include "budget.h"
-
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/input.h>
-#include <linux/spinlock.h>
-
-#include "dvb_ca_en50221.h"
-#include "stv0299.h"
-#include "stv0297.h"
-#include "tda1004x.h"
-#include "lnbp21.h"
-#include "bsbe1.h"
-#include "bsru6.h"
-
-#define DEBIADDR_IR 0x1234
-#define DEBIADDR_CICONTROL 0x0000
-#define DEBIADDR_CIVERSION 0x4000
-#define DEBIADDR_IO 0x1000
-#define DEBIADDR_ATTR 0x3000
-
-#define CICONTROL_RESET 0x01
-#define CICONTROL_ENABLETS 0x02
-#define CICONTROL_CAMDETECT 0x08
-
-#define DEBICICTL 0x00420000
-#define DEBICICAM 0x02420000
-
-#define SLOTSTATUS_NONE 1
-#define SLOTSTATUS_PRESENT 2
-#define SLOTSTATUS_RESET 4
-#define SLOTSTATUS_READY 8
-#define SLOTSTATUS_OCCUPIED (SLOTSTATUS_PRESENT|SLOTSTATUS_RESET|SLOTSTATUS_READY)
-
-struct budget_ci {
- struct budget budget;
- struct input_dev *input_dev;
- struct tasklet_struct msp430_irq_tasklet;
- struct tasklet_struct ciintf_irq_tasklet;
- int slot_status;
- int ci_irq;
- struct dvb_ca_en50221 ca;
- char ir_dev_name[50];
- u8 tuner_pll_address; /* used for philips_tdm1316l configs */
-};
-
-/* from reading the following remotes:
- Zenith Universal 7 / TV Mode 807 / VCR Mode 837
- Hauppauge (from NOVA-CI-s box product)
- i've taken a "middle of the road" approach and note the differences
-*/
-static u16 key_map[64] = {
- /* 0x0X */
- KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, KEY_7, KEY_8,
- KEY_9,
- KEY_ENTER,
- KEY_RED,
- KEY_POWER, /* RADIO on Hauppauge */
- KEY_MUTE,
- 0,
- KEY_A, /* TV on Hauppauge */
- /* 0x1X */
- KEY_VOLUMEUP, KEY_VOLUMEDOWN,
- 0, 0,
- KEY_B,
- 0, 0, 0, 0, 0, 0, 0,
- KEY_UP, KEY_DOWN,
- KEY_OPTION, /* RESERVED on Hauppauge */
- KEY_BREAK,
- /* 0x2X */
- KEY_CHANNELUP, KEY_CHANNELDOWN,
- KEY_PREVIOUS, /* Prev. Ch on Zenith, SOURCE on Hauppauge */
- 0, KEY_RESTART, KEY_OK,
- KEY_CYCLEWINDOWS, /* MINIMIZE on Hauppauge */
- 0,
- KEY_ENTER, /* VCR mode on Zenith */
- KEY_PAUSE,
- 0,
- KEY_RIGHT, KEY_LEFT,
- 0,
- KEY_MENU, /* FULL SCREEN on Hauppauge */
- 0,
- /* 0x3X */
- KEY_SLOW,
- KEY_PREVIOUS, /* VCR mode on Zenith */
- KEY_REWIND,
- 0,
- KEY_FASTFORWARD,
- KEY_PLAY, KEY_STOP,
- KEY_RECORD,
- KEY_TUNER, /* TV/VCR on Zenith */
- 0,
- KEY_C,
- 0,
- KEY_EXIT,
- KEY_POWER2,
- KEY_TUNER, /* VCR mode on Zenith */
- 0,
-};
-
-static void msp430_ir_debounce(unsigned long data)
-{
- struct input_dev *dev = (struct input_dev *) data;
-
- if (dev->rep[0] == 0 || dev->rep[0] == ~0) {
- input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
- return;
- }
-
- dev->rep[0] = 0;
- dev->timer.expires = jiffies + HZ * 350 / 1000;
- add_timer(&dev->timer);
- input_event(dev, EV_KEY, key_map[dev->repeat_key], 2); /* REPEAT */
-}
-
-static void msp430_ir_interrupt(unsigned long data)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) data;
- struct input_dev *dev = budget_ci->input_dev;
- unsigned int code =
- ttpci_budget_debiread(&budget_ci->budget, DEBINOSWAP, DEBIADDR_IR, 2, 1, 0) >> 8;
-
- if (code & 0x40) {
- code &= 0x3f;
-
- if (timer_pending(&dev->timer)) {
- if (code == dev->repeat_key) {
- ++dev->rep[0];
- return;
- }
- del_timer(&dev->timer);
- input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
- }
-
- if (!key_map[code]) {
- printk("DVB (%s): no key for %02x!\n", __FUNCTION__, code);
- return;
- }
-
- /* initialize debounce and repeat */
- dev->repeat_key = code;
- /* Zenith remote _always_ sends 2 sequences */
- dev->rep[0] = ~0;
- /* 350 milliseconds */
- dev->timer.expires = jiffies + HZ * 350 / 1000;
- /* MAKE */
- input_event(dev, EV_KEY, key_map[code], !0);
- add_timer(&dev->timer);
- }
-}
-
-static int msp430_ir_init(struct budget_ci *budget_ci)
-{
- struct saa7146_dev *saa = budget_ci->budget.dev;
- struct input_dev *input_dev;
- int i;
-
- budget_ci->input_dev = input_dev = input_allocate_device();
- if (!input_dev)
- return -ENOMEM;
-
- sprintf(budget_ci->ir_dev_name, "Budget-CI dvb ir receiver %s", saa->name);
-
- input_dev->name = budget_ci->ir_dev_name;
-
- set_bit(EV_KEY, input_dev->evbit);
- for (i = 0; i < ARRAY_SIZE(key_map); i++)
- if (key_map[i])
- set_bit(key_map[i], input_dev->keybit);
-
- input_register_device(budget_ci->input_dev);
-
- input_dev->timer.function = msp430_ir_debounce;
-
- saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_06);
- saa7146_setgpio(saa, 3, SAA7146_GPIO_IRQHI);
-
- return 0;
-}
-
-static void msp430_ir_deinit(struct budget_ci *budget_ci)
-{
- struct saa7146_dev *saa = budget_ci->budget.dev;
- struct input_dev *dev = budget_ci->input_dev;
-
- saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_06);
- saa7146_setgpio(saa, 3, SAA7146_GPIO_INPUT);
-
- if (del_timer(&dev->timer))
- input_event(dev, EV_KEY, key_map[dev->repeat_key], !!0);
-
- input_unregister_device(dev);
-}
-
-static int ciintf_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
-
- if (slot != 0)
- return -EINVAL;
-
- return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
- DEBIADDR_ATTR | (address & 0xfff), 1, 1, 0);
-}
-
-static int ciintf_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
-
- if (slot != 0)
- return -EINVAL;
-
- return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
- DEBIADDR_ATTR | (address & 0xfff), 1, value, 1, 0);
-}
-
-static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
-
- if (slot != 0)
- return -EINVAL;
-
- return ttpci_budget_debiread(&budget_ci->budget, DEBICICAM,
- DEBIADDR_IO | (address & 3), 1, 1, 0);
-}
-
-static int ciintf_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
-
- if (slot != 0)
- return -EINVAL;
-
- return ttpci_budget_debiwrite(&budget_ci->budget, DEBICICAM,
- DEBIADDR_IO | (address & 3), 1, value, 1, 0);
-}
-
-static int ciintf_slot_reset(struct dvb_ca_en50221 *ca, int slot)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
- struct saa7146_dev *saa = budget_ci->budget.dev;
-
- if (slot != 0)
- return -EINVAL;
-
- if (budget_ci->ci_irq) {
- // trigger on RISING edge during reset so we know when READY is re-asserted
- saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
- }
- budget_ci->slot_status = SLOTSTATUS_RESET;
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
- msleep(1);
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- CICONTROL_RESET, 1, 0);
-
- saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
- ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
- return 0;
-}
-
-static int ciintf_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
- struct saa7146_dev *saa = budget_ci->budget.dev;
-
- if (slot != 0)
- return -EINVAL;
-
- saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTHI);
- ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTB);
- return 0;
-}
-
-static int ciintf_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
- struct saa7146_dev *saa = budget_ci->budget.dev;
- int tmp;
-
- if (slot != 0)
- return -EINVAL;
-
- saa7146_setgpio(saa, 1, SAA7146_GPIO_OUTLO);
-
- tmp = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- tmp | CICONTROL_ENABLETS, 1, 0);
-
- ttpci_budget_set_video_port(saa, BUDGET_VIDEO_PORTA);
- return 0;
-}
-
-static void ciintf_interrupt(unsigned long data)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) data;
- struct saa7146_dev *saa = budget_ci->budget.dev;
- unsigned int flags;
-
- // ensure we don't get spurious IRQs during initialisation
- if (!budget_ci->budget.ci_present)
- return;
-
- // read the CAM status
- flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
- if (flags & CICONTROL_CAMDETECT) {
-
- // GPIO should be set to trigger on falling edge if a CAM is present
- saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO);
-
- if (budget_ci->slot_status & SLOTSTATUS_NONE) {
- // CAM insertion IRQ
- budget_ci->slot_status = SLOTSTATUS_PRESENT;
- dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0,
- DVB_CA_EN50221_CAMCHANGE_INSERTED);
-
- } else if (budget_ci->slot_status & SLOTSTATUS_RESET) {
- // CAM ready (reset completed)
- budget_ci->slot_status = SLOTSTATUS_READY;
- dvb_ca_en50221_camready_irq(&budget_ci->ca, 0);
-
- } else if (budget_ci->slot_status & SLOTSTATUS_READY) {
- // FR/DA IRQ
- dvb_ca_en50221_frda_irq(&budget_ci->ca, 0);
- }
- } else {
-
- // trigger on rising edge if a CAM is not present - when a CAM is inserted, we
- // only want to get the IRQ when it sets READY. If we trigger on the falling edge,
- // the CAM might not actually be ready yet.
- saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
-
- // generate a CAM removal IRQ if we haven't already
- if (budget_ci->slot_status & SLOTSTATUS_OCCUPIED) {
- // CAM removal IRQ
- budget_ci->slot_status = SLOTSTATUS_NONE;
- dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0,
- DVB_CA_EN50221_CAMCHANGE_REMOVED);
- }
- }
-}
-
-static int ciintf_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) ca->data;
- unsigned int flags;
-
- // ensure we don't get spurious IRQs during initialisation
- if (!budget_ci->budget.ci_present)
- return -EINVAL;
-
- // read the CAM status
- flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
- if (flags & CICONTROL_CAMDETECT) {
- // mark it as present if it wasn't before
- if (budget_ci->slot_status & SLOTSTATUS_NONE) {
- budget_ci->slot_status = SLOTSTATUS_PRESENT;
- }
-
- // during a RESET, we check if we can read from IO memory to see when CAM is ready
- if (budget_ci->slot_status & SLOTSTATUS_RESET) {
- if (ciintf_read_attribute_mem(ca, slot, 0) == 0x1d) {
- budget_ci->slot_status = SLOTSTATUS_READY;
- }
- }
- } else {
- budget_ci->slot_status = SLOTSTATUS_NONE;
- }
-
- if (budget_ci->slot_status != SLOTSTATUS_NONE) {
- if (budget_ci->slot_status & SLOTSTATUS_READY) {
- return DVB_CA_EN50221_POLL_CAM_PRESENT | DVB_CA_EN50221_POLL_CAM_READY;
- }
- return DVB_CA_EN50221_POLL_CAM_PRESENT;
- }
-
- return 0;
-}
-
-static int ciintf_init(struct budget_ci *budget_ci)
-{
- struct saa7146_dev *saa = budget_ci->budget.dev;
- int flags;
- int result;
- int ci_version;
- int ca_flags;
-
- memset(&budget_ci->ca, 0, sizeof(struct dvb_ca_en50221));
-
- // enable DEBI pins
- saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16) | 0x800);
-
- // test if it is there
- ci_version = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CIVERSION, 1, 1, 0);
- if ((ci_version & 0xa0) != 0xa0) {
- result = -ENODEV;
- goto error;
- }
-
- // determine whether a CAM is present or not
- flags = ttpci_budget_debiread(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 1, 0);
- budget_ci->slot_status = SLOTSTATUS_NONE;
- if (flags & CICONTROL_CAMDETECT)
- budget_ci->slot_status = SLOTSTATUS_PRESENT;
-
- // version 0xa2 of the CI firmware doesn't generate interrupts
- if (ci_version == 0xa2) {
- ca_flags = 0;
- budget_ci->ci_irq = 0;
- } else {
- ca_flags = DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE |
- DVB_CA_EN50221_FLAG_IRQ_FR |
- DVB_CA_EN50221_FLAG_IRQ_DA;
- budget_ci->ci_irq = 1;
- }
-
- // register CI interface
- budget_ci->ca.owner = THIS_MODULE;
- budget_ci->ca.read_attribute_mem = ciintf_read_attribute_mem;
- budget_ci->ca.write_attribute_mem = ciintf_write_attribute_mem;
- budget_ci->ca.read_cam_control = ciintf_read_cam_control;
- budget_ci->ca.write_cam_control = ciintf_write_cam_control;
- budget_ci->ca.slot_reset = ciintf_slot_reset;
- budget_ci->ca.slot_shutdown = ciintf_slot_shutdown;
- budget_ci->ca.slot_ts_enable = ciintf_slot_ts_enable;
- budget_ci->ca.poll_slot_status = ciintf_poll_slot_status;
- budget_ci->ca.data = budget_ci;
- if ((result = dvb_ca_en50221_init(&budget_ci->budget.dvb_adapter,
- &budget_ci->ca,
- ca_flags, 1)) != 0) {
- printk("budget_ci: CI interface detected, but initialisation failed.\n");
- goto error;
- }
-
- // Setup CI slot IRQ
- if (budget_ci->ci_irq) {
- tasklet_init(&budget_ci->ciintf_irq_tasklet, ciintf_interrupt, (unsigned long) budget_ci);
- if (budget_ci->slot_status != SLOTSTATUS_NONE) {
- saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQLO);
- } else {
- saa7146_setgpio(saa, 0, SAA7146_GPIO_IRQHI);
- }
- saa7146_write(saa, IER, saa7146_read(saa, IER) | MASK_03);
- }
-
- // enable interface
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- CICONTROL_RESET, 1, 0);
-
- // success!
- printk("budget_ci: CI interface initialised\n");
- budget_ci->budget.ci_present = 1;
-
- // forge a fake CI IRQ so the CAM state is setup correctly
- if (budget_ci->ci_irq) {
- flags = DVB_CA_EN50221_CAMCHANGE_REMOVED;
- if (budget_ci->slot_status != SLOTSTATUS_NONE)
- flags = DVB_CA_EN50221_CAMCHANGE_INSERTED;
- dvb_ca_en50221_camchange_irq(&budget_ci->ca, 0, flags);
- }
-
- return 0;
-
-error:
- saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16));
- return result;
-}
-
-static void ciintf_deinit(struct budget_ci *budget_ci)
-{
- struct saa7146_dev *saa = budget_ci->budget.dev;
-
- // disable CI interrupts
- if (budget_ci->ci_irq) {
- saa7146_write(saa, IER, saa7146_read(saa, IER) & ~MASK_03);
- saa7146_setgpio(saa, 0, SAA7146_GPIO_INPUT);
- tasklet_kill(&budget_ci->ciintf_irq_tasklet);
- }
-
- // reset interface
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1, 0, 1, 0);
- msleep(1);
- ttpci_budget_debiwrite(&budget_ci->budget, DEBICICTL, DEBIADDR_CICONTROL, 1,
- CICONTROL_RESET, 1, 0);
-
- // disable TS data stream to CI interface
- saa7146_setgpio(saa, 1, SAA7146_GPIO_INPUT);
-
- // release the CA device
- dvb_ca_en50221_release(&budget_ci->ca);
-
- // disable DEBI pins
- saa7146_write(saa, MC1, saa7146_read(saa, MC1) | (0x800 << 16));
-}
-
-static void budget_ci_irq(struct saa7146_dev *dev, u32 * isr)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) dev->ext_priv;
-
- dprintk(8, "dev: %p, budget_ci: %p\n", dev, budget_ci);
-
- if (*isr & MASK_06)
- tasklet_schedule(&budget_ci->msp430_irq_tasklet);
-
- if (*isr & MASK_10)
- ttpci_budget_irq10_handler(dev, isr);
-
- if ((*isr & MASK_03) && (budget_ci->budget.ci_present) && (budget_ci->ci_irq))
- tasklet_schedule(&budget_ci->ciintf_irq_tasklet);
-}
-
-static u8 philips_su1278_tt_inittab[] = {
- 0x01, 0x0f,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x5b,
- 0x05, 0x85,
- 0x06, 0x02,
- 0x07, 0x00,
- 0x08, 0x02,
- 0x09, 0x00,
- 0x0C, 0x01,
- 0x0D, 0x81,
- 0x0E, 0x44,
- 0x0f, 0x14,
- 0x10, 0x3c,
- 0x11, 0x84,
- 0x12, 0xda,
- 0x13, 0x97,
- 0x14, 0x95,
- 0x15, 0xc9,
- 0x16, 0x19,
- 0x17, 0x8c,
- 0x18, 0x59,
- 0x19, 0xf8,
- 0x1a, 0xfe,
- 0x1c, 0x7f,
- 0x1d, 0x00,
- 0x1e, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00,
- 0x29, 0x28,
- 0x2a, 0x14,
- 0x2b, 0x0f,
- 0x2c, 0x09,
- 0x2d, 0x09,
- 0x31, 0x1f,
- 0x32, 0x19,
- 0x33, 0xfc,
- 0x34, 0x93,
- 0xff, 0xff
-};
-
-static int philips_su1278_tt_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
-{
- stv0299_writereg(fe, 0x0e, 0x44);
- if (srate >= 10000000) {
- stv0299_writereg(fe, 0x13, 0x97);
- stv0299_writereg(fe, 0x14, 0x95);
- stv0299_writereg(fe, 0x15, 0xc9);
- stv0299_writereg(fe, 0x17, 0x8c);
- stv0299_writereg(fe, 0x1a, 0xfe);
- stv0299_writereg(fe, 0x1c, 0x7f);
- stv0299_writereg(fe, 0x2d, 0x09);
- } else {
- stv0299_writereg(fe, 0x13, 0x99);
- stv0299_writereg(fe, 0x14, 0x8d);
- stv0299_writereg(fe, 0x15, 0xce);
- stv0299_writereg(fe, 0x17, 0x43);
- stv0299_writereg(fe, 0x1a, 0x1d);
- stv0299_writereg(fe, 0x1c, 0x12);
- stv0299_writereg(fe, 0x2d, 0x05);
- }
- stv0299_writereg(fe, 0x0e, 0x23);
- stv0299_writereg(fe, 0x0f, 0x94);
- stv0299_writereg(fe, 0x10, 0x39);
- stv0299_writereg(fe, 0x15, 0xc9);
-
- stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
-
- return 0;
-}
-
-static int philips_su1278_tt_tuner_set_params(struct dvb_frontend *fe,
- struct dvb_frontend_parameters *params)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
- u32 div;
- u8 buf[4];
- struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = buf,.len = sizeof(buf) };
-
- if ((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- div = (params->frequency + (500 - 1)) / 500; // round correctly
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x80 | ((div & 0x18000) >> 10) | 2;
- buf[3] = 0x20;
-
- if (params->u.qpsk.symbol_rate < 4000000)
- buf[3] |= 1;
-
- if (params->frequency < 1250000)
- buf[3] |= 0;
- else if (params->frequency < 1550000)
- buf[3] |= 0x40;
- else if (params->frequency < 2050000)
- buf[3] |= 0x80;
- else if (params->frequency < 2150000)
- buf[3] |= 0xC0;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget_ci->budget.i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct stv0299_config philips_su1278_tt_config = {
-
- .demod_address = 0x68,
- .inittab = philips_su1278_tt_inittab,
- .mclk = 64000000UL,
- .invert = 0,
- .skip_reinit = 1,
- .lock_output = STV0229_LOCKOUTPUT_1,
- .volt13_op0_op1 = STV0299_VOLT13_OP1,
- .min_delay_ms = 50,
- .set_symbol_rate = philips_su1278_tt_set_symbol_rate,
-};
-
-
-
-static int philips_tdm1316l_tuner_init(struct dvb_frontend *fe)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
- static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
- static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
- struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = td1316_init,.len =
- sizeof(td1316_init) };
-
- // setup PLL configuration
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
- msleep(1);
-
- // disable the mc44BC374c (do not check for errors)
- tuner_msg.addr = 0x65;
- tuner_msg.buf = disable_mc44BC374c;
- tuner_msg.len = sizeof(disable_mc44BC374c);
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1) {
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1);
- }
-
- return 0;
-}
-
-static int philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
- u8 tuner_buf[4];
- struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,.flags = 0,.buf = tuner_buf,.len = sizeof(tuner_buf) };
- int tuner_frequency = 0;
- u8 band, cp, filter;
-
- // determine charge pump
- tuner_frequency = params->frequency + 36130000;
- if (tuner_frequency < 87000000)
- return -EINVAL;
- else if (tuner_frequency < 130000000)
- cp = 3;
- else if (tuner_frequency < 160000000)
- cp = 5;
- else if (tuner_frequency < 200000000)
- cp = 6;
- else if (tuner_frequency < 290000000)
- cp = 3;
- else if (tuner_frequency < 420000000)
- cp = 5;
- else if (tuner_frequency < 480000000)
- cp = 6;
- else if (tuner_frequency < 620000000)
- cp = 3;
- else if (tuner_frequency < 830000000)
- cp = 5;
- else if (tuner_frequency < 895000000)
- cp = 7;
- else
- return -EINVAL;
-
- // determine band
- if (params->frequency < 49000000)
- return -EINVAL;
- else if (params->frequency < 159000000)
- band = 1;
- else if (params->frequency < 444000000)
- band = 2;
- else if (params->frequency < 861000000)
- band = 4;
- else
- return -EINVAL;
-
- // setup PLL filter and TDA9889
- switch (params->u.ofdm.bandwidth) {
- case BANDWIDTH_6_MHZ:
- tda1004x_write_byte(fe, 0x0C, 0x14);
- filter = 0;
- break;
-
- case BANDWIDTH_7_MHZ:
- tda1004x_write_byte(fe, 0x0C, 0x80);
- filter = 0;
- break;
-
- case BANDWIDTH_8_MHZ:
- tda1004x_write_byte(fe, 0x0C, 0x14);
- filter = 1;
- break;
-
- default:
- return -EINVAL;
- }
-
- // calculate divisor
- // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
- tuner_frequency = (((params->frequency / 1000) * 6) + 217280) / 1000;
-
- // setup tuner buffer
- tuner_buf[0] = tuner_frequency >> 8;
- tuner_buf[1] = tuner_frequency & 0xff;
- tuner_buf[2] = 0xca;
- tuner_buf[3] = (cp << 5) | (filter << 3) | band;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
-
- msleep(1);
- return 0;
-}
-
-static int philips_tdm1316l_request_firmware(struct dvb_frontend *fe,
- const struct firmware **fw, char *name)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
-
- return request_firmware(fw, name, &budget_ci->budget.dev->pci->dev);
-}
-
-static struct tda1004x_config philips_tdm1316l_config = {
-
- .demod_address = 0x8,
- .invert = 0,
- .invert_oclk = 0,
- .xtal_freq = TDA10046_XTAL_4M,
- .agc_config = TDA10046_AGC_DEFAULT,
- .if_freq = TDA10046_FREQ_3617,
- .request_firmware = philips_tdm1316l_request_firmware,
-};
-
-static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) fe->dvb->priv;
- u8 tuner_buf[5];
- struct i2c_msg tuner_msg = {.addr = budget_ci->tuner_pll_address,
- .flags = 0,
- .buf = tuner_buf,
- .len = sizeof(tuner_buf) };
- int tuner_frequency = 0;
- u8 band, cp, filter;
-
- // determine charge pump
- tuner_frequency = params->frequency + 36125000;
- if (tuner_frequency < 87000000)
- return -EINVAL;
- else if (tuner_frequency < 130000000) {
- cp = 3;
- band = 1;
- } else if (tuner_frequency < 160000000) {
- cp = 5;
- band = 1;
- } else if (tuner_frequency < 200000000) {
- cp = 6;
- band = 1;
- } else if (tuner_frequency < 290000000) {
- cp = 3;
- band = 2;
- } else if (tuner_frequency < 420000000) {
- cp = 5;
- band = 2;
- } else if (tuner_frequency < 480000000) {
- cp = 6;
- band = 2;
- } else if (tuner_frequency < 620000000) {
- cp = 3;
- band = 4;
- } else if (tuner_frequency < 830000000) {
- cp = 5;
- band = 4;
- } else if (tuner_frequency < 895000000) {
- cp = 7;
- band = 4;
- } else
- return -EINVAL;
-
- // assume PLL filter should always be 8MHz for the moment.
- filter = 1;
-
- // calculate divisor
- tuner_frequency = (params->frequency + 36125000 + (62500/2)) / 62500;
-
- // setup tuner buffer
- tuner_buf[0] = tuner_frequency >> 8;
- tuner_buf[1] = tuner_frequency & 0xff;
- tuner_buf[2] = 0xc8;
- tuner_buf[3] = (cp << 5) | (filter << 3) | band;
- tuner_buf[4] = 0x80;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
-
- msleep(50);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&budget_ci->budget.i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
-
- msleep(1);
-
- return 0;
-}
-
-static u8 dvbc_philips_tdm1316l_inittab[] = {
- 0x80, 0x01,
- 0x80, 0x00,
- 0x81, 0x01,
- 0x81, 0x00,
- 0x00, 0x09,
- 0x01, 0x69,
- 0x03, 0x00,
- 0x04, 0x00,
- 0x07, 0x00,
- 0x08, 0x00,
- 0x20, 0x00,
- 0x21, 0x40,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x24, 0x40,
- 0x25, 0x88,
- 0x30, 0xff,
- 0x31, 0x00,
- 0x32, 0xff,
- 0x33, 0x00,
- 0x34, 0x50,
- 0x35, 0x7f,
- 0x36, 0x00,
- 0x37, 0x20,
- 0x38, 0x00,
- 0x40, 0x1c,
- 0x41, 0xff,
- 0x42, 0x29,
- 0x43, 0x20,
- 0x44, 0xff,
- 0x45, 0x00,
- 0x46, 0x00,
- 0x49, 0x04,
- 0x4a, 0x00,
- 0x4b, 0x7b,
- 0x52, 0x30,
- 0x55, 0xae,
- 0x56, 0x47,
- 0x57, 0xe1,
- 0x58, 0x3a,
- 0x5a, 0x1e,
- 0x5b, 0x34,
- 0x60, 0x00,
- 0x63, 0x00,
- 0x64, 0x00,
- 0x65, 0x00,
- 0x66, 0x00,
- 0x67, 0x00,
- 0x68, 0x00,
- 0x69, 0x00,
- 0x6a, 0x02,
- 0x6b, 0x00,
- 0x70, 0xff,
- 0x71, 0x00,
- 0x72, 0x00,
- 0x73, 0x00,
- 0x74, 0x0c,
- 0x80, 0x00,
- 0x81, 0x00,
- 0x82, 0x00,
- 0x83, 0x00,
- 0x84, 0x04,
- 0x85, 0x80,
- 0x86, 0x24,
- 0x87, 0x78,
- 0x88, 0x10,
- 0x89, 0x00,
- 0x90, 0x01,
- 0x91, 0x01,
- 0xa0, 0x04,
- 0xa1, 0x00,
- 0xa2, 0x00,
- 0xb0, 0x91,
- 0xb1, 0x0b,
- 0xc0, 0x53,
- 0xc1, 0x70,
- 0xc2, 0x12,
- 0xd0, 0x00,
- 0xd1, 0x00,
- 0xd2, 0x00,
- 0xd3, 0x00,
- 0xd4, 0x00,
- 0xd5, 0x00,
- 0xde, 0x00,
- 0xdf, 0x00,
- 0x61, 0x38,
- 0x62, 0x0a,
- 0x53, 0x13,
- 0x59, 0x08,
- 0xff, 0xff,
-};
-
-static struct stv0297_config dvbc_philips_tdm1316l_config = {
- .demod_address = 0x1c,
- .inittab = dvbc_philips_tdm1316l_inittab,
- .invert = 0,
- .stop_during_read = 1,
-};
-
-
-
-
-static void frontend_init(struct budget_ci *budget_ci)
-{
- switch (budget_ci->budget.dev->pci->subsystem_device) {
- case 0x100c: // Hauppauge/TT Nova-CI budget (stv0299/ALPS BSRU6(tsa5059))
- budget_ci->budget.dvb_frontend =
- stv0299_attach(&alps_bsru6_config, &budget_ci->budget.i2c_adap);
- if (budget_ci->budget.dvb_frontend) {
- budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
- budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
- break;
- }
- break;
-
- case 0x100f: // Hauppauge/TT Nova-CI budget (stv0299b/Philips su1278(tsa5059))
- budget_ci->budget.dvb_frontend =
- stv0299_attach(&philips_su1278_tt_config, &budget_ci->budget.i2c_adap);
- if (budget_ci->budget.dvb_frontend) {
- budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_su1278_tt_tuner_set_params;
- break;
- }
- break;
-
- case 0x1010: // TT DVB-C CI budget (stv0297/Philips tdm1316l(tda6651tt))
- budget_ci->tuner_pll_address = 0x61;
- budget_ci->budget.dvb_frontend =
- stv0297_attach(&dvbc_philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
- if (budget_ci->budget.dvb_frontend) {
- budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
- break;
- }
- break;
-
- case 0x1011: // Hauppauge/TT Nova-T budget (tda10045/Philips tdm1316l(tda6651tt) + TDA9889)
- budget_ci->tuner_pll_address = 0x63;
- budget_ci->budget.dvb_frontend =
- tda10045_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
- if (budget_ci->budget.dvb_frontend) {
- budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
- budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
- break;
- }
- break;
-
- case 0x1012: // TT DVB-T CI budget (tda10046/Philips tdm1316l(tda6651tt))
- budget_ci->tuner_pll_address = 0x60;
- budget_ci->budget.dvb_frontend =
- tda10046_attach(&philips_tdm1316l_config, &budget_ci->budget.i2c_adap);
- if (budget_ci->budget.dvb_frontend) {
- budget_ci->budget.dvb_frontend->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
- budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
- break;
- }
- break;
-
- case 0x1017: // TT S-1500 PCI
- budget_ci->budget.dvb_frontend = stv0299_attach(&alps_bsbe1_config, &budget_ci->budget.i2c_adap);
- if (budget_ci->budget.dvb_frontend) {
- budget_ci->budget.dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params;
- budget_ci->budget.dvb_frontend->tuner_priv = &budget_ci->budget.i2c_adap;
-
- budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
- if (lnbp21_attach(budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0)) {
- printk("%s: No LNBP21 found!\n", __FUNCTION__);
- if (budget_ci->budget.dvb_frontend->ops.release)
- budget_ci->budget.dvb_frontend->ops.release(budget_ci->budget.dvb_frontend);
- budget_ci->budget.dvb_frontend = NULL;
- }
- }
-
- break;
- }
-
- if (budget_ci->budget.dvb_frontend == NULL) {
- printk("budget-ci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
- budget_ci->budget.dev->pci->vendor,
- budget_ci->budget.dev->pci->device,
- budget_ci->budget.dev->pci->subsystem_vendor,
- budget_ci->budget.dev->pci->subsystem_device);
- } else {
- if (dvb_register_frontend
- (&budget_ci->budget.dvb_adapter, budget_ci->budget.dvb_frontend)) {
- printk("budget-ci: Frontend registration failed!\n");
- if (budget_ci->budget.dvb_frontend->ops.release)
- budget_ci->budget.dvb_frontend->ops.release(budget_ci->budget.dvb_frontend);
- budget_ci->budget.dvb_frontend = NULL;
- }
- }
-}
-
-static int budget_ci_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info)
-{
- struct budget_ci *budget_ci;
- int err;
-
- if (!(budget_ci = kmalloc(sizeof(struct budget_ci), GFP_KERNEL)))
- return -ENOMEM;
-
- dprintk(2, "budget_ci: %p\n", budget_ci);
-
- budget_ci->budget.ci_present = 0;
-
- dev->ext_priv = budget_ci;
-
- if ((err = ttpci_budget_init(&budget_ci->budget, dev, info, THIS_MODULE))) {
- kfree(budget_ci);
- return err;
- }
-
- tasklet_init(&budget_ci->msp430_irq_tasklet, msp430_ir_interrupt,
- (unsigned long) budget_ci);
-
- msp430_ir_init(budget_ci);
-
- ciintf_init(budget_ci);
-
- budget_ci->budget.dvb_adapter.priv = budget_ci;
- frontend_init(budget_ci);
-
- ttpci_budget_init_hooks(&budget_ci->budget);
-
- return 0;
-}
-
-static int budget_ci_detach(struct saa7146_dev *dev)
-{
- struct budget_ci *budget_ci = (struct budget_ci *) dev->ext_priv;
- struct saa7146_dev *saa = budget_ci->budget.dev;
- int err;
-
- if (budget_ci->budget.ci_present)
- ciintf_deinit(budget_ci);
- if (budget_ci->budget.dvb_frontend)
- dvb_unregister_frontend(budget_ci->budget.dvb_frontend);
- err = ttpci_budget_deinit(&budget_ci->budget);
-
- tasklet_kill(&budget_ci->msp430_irq_tasklet);
-
- msp430_ir_deinit(budget_ci);
-
- // disable frontend and CI interface
- saa7146_setgpio(saa, 2, SAA7146_GPIO_INPUT);
-
- kfree(budget_ci);
-
- return err;
-}
-
-static struct saa7146_extension budget_extension;
-
-MAKE_BUDGET_INFO(ttbs2, "TT-Budget/S-1500 PCI", BUDGET_TT);
-MAKE_BUDGET_INFO(ttbci, "TT-Budget/WinTV-NOVA-CI PCI", BUDGET_TT_HW_DISEQC);
-MAKE_BUDGET_INFO(ttbt2, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
-MAKE_BUDGET_INFO(ttbtci, "TT-Budget-T-CI PCI", BUDGET_TT);
-MAKE_BUDGET_INFO(ttbcci, "TT-Budget-C-CI PCI", BUDGET_TT);
-
-static struct pci_device_id pci_tbl[] = {
- MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100c),
- MAKE_EXTENSION_PCI(ttbci, 0x13c2, 0x100f),
- MAKE_EXTENSION_PCI(ttbcci, 0x13c2, 0x1010),
- MAKE_EXTENSION_PCI(ttbt2, 0x13c2, 0x1011),
- MAKE_EXTENSION_PCI(ttbtci, 0x13c2, 0x1012),
- MAKE_EXTENSION_PCI(ttbs2, 0x13c2, 0x1017),
- {
- .vendor = 0,
- }
-};
-
-MODULE_DEVICE_TABLE(pci, pci_tbl);
-
-static struct saa7146_extension budget_extension = {
- .name = "budget_ci dvb\0",
- .flags = SAA7146_I2C_SHORT_DELAY,
-
- .module = THIS_MODULE,
- .pci_tbl = &pci_tbl[0],
- .attach = budget_ci_attach,
- .detach = budget_ci_detach,
-
- .irq_mask = MASK_03 | MASK_06 | MASK_10,
- .irq_func = budget_ci_irq,
-};
-
-static int __init budget_ci_init(void)
-{
- return saa7146_register_extension(&budget_extension);
-}
-
-static void __exit budget_ci_exit(void)
-{
- saa7146_unregister_extension(&budget_extension);
-}
-
-module_init(budget_ci_init);
-module_exit(budget_ci_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Michael Hunold, Jack Thomasson, Andrew de Quincey, others");
-MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
- "budget PCI DVB cards w/ CI-module produced by "
- "Siemens, Technotrend, Hauppauge");
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
deleted file mode 100644
index e15562f8166..00000000000
--- a/drivers/media/dvb/ttpci/budget-core.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * budget-core.c: driver for the SAA7146 based Budget DVB cards
- *
- * Compiled from various sources by Michael Hunold <michael@mihu.de>
- *
- * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * 26feb2004 Support for FS Activy Card (Grundig tuner) by
- * Michael Dreher <michael@5dot1.de>,
- * Oliver Endriss <o.endriss@gmx.de>,
- * Andreas 'randy' Weinberger
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include <linux/moduleparam.h>
-
-#include "budget.h"
-#include "ttpci-eeprom.h"
-
-#define TS_WIDTH (2 * TS_SIZE)
-#define TS_WIDTH_ACTIVY TS_SIZE
-#define TS_HEIGHT_MASK 0xf00
-#define TS_HEIGHT_MASK_ACTIVY 0xc00
-#define TS_MIN_BUFSIZE_K 188
-#define TS_MAX_BUFSIZE_K 1410
-#define TS_MAX_BUFSIZE_K_ACTIVY 564
-#define BUFFER_WARNING_WAIT (30*HZ)
-
-int budget_debug;
-static int dma_buffer_size = TS_MIN_BUFSIZE_K;
-module_param_named(debug, budget_debug, int, 0644);
-module_param_named(bufsize, dma_buffer_size, int, 0444);
-MODULE_PARM_DESC(debug, "Turn on/off budget debugging (default:off).");
-MODULE_PARM_DESC(bufsize, "DMA buffer size in KB, default: 188, min: 188, max: 1410 (Activy: 564)");
-
-/****************************************************************************
- * TT budget / WinTV Nova
- ****************************************************************************/
-
-static int stop_ts_capture(struct budget *budget)
-{
- dprintk(2, "budget: %p\n", budget);
-
- saa7146_write(budget->dev, MC1, MASK_20); // DMA3 off
- SAA7146_IER_DISABLE(budget->dev, MASK_10);
- return 0;
-}
-
-static int start_ts_capture(struct budget *budget)
-{
- struct saa7146_dev *dev = budget->dev;
-
- dprintk(2, "budget: %p\n", budget);
-
- if (!budget->feeding || !budget->fe_synced)
- return 0;
-
- saa7146_write(dev, MC1, MASK_20); // DMA3 off
-
- memset(budget->grabbing, 0x00, budget->buffer_size);
-
- saa7146_write(dev, PCI_BT_V1, 0x001c0000 | (saa7146_read(dev, PCI_BT_V1) & ~0x001f0000));
-
- budget->ttbp = 0;
-
- /*
- * Signal path on the Activy:
- *
- * tuner -> SAA7146 port A -> SAA7146 BRS -> SAA7146 DMA3 -> memory
- *
- * Since the tuner feeds 204 bytes packets into the SAA7146,
- * DMA3 is configured to strip the trailing 16 FEC bytes:
- * Pitch: 188, NumBytes3: 188, NumLines3: 1024
- */
-
- switch(budget->card->type) {
- case BUDGET_FS_ACTIVY:
- saa7146_write(dev, DD1_INIT, 0x04000000);
- saa7146_write(dev, MC2, (MASK_09 | MASK_25));
- saa7146_write(dev, BRS_CTRL, 0x00000000);
- break;
- case BUDGET_PATCH:
- saa7146_write(dev, DD1_INIT, 0x00000200);
- saa7146_write(dev, MC2, (MASK_10 | MASK_26));
- saa7146_write(dev, BRS_CTRL, 0x60000000);
- break;
- default:
- if (budget->video_port == BUDGET_VIDEO_PORTA) {
- saa7146_write(dev, DD1_INIT, 0x06000200);
- saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
- saa7146_write(dev, BRS_CTRL, 0x00000000);
- } else {
- saa7146_write(dev, DD1_INIT, 0x02000600);
- saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
- saa7146_write(dev, BRS_CTRL, 0x60000000);
- }
- }
-
- saa7146_write(dev, MC2, (MASK_08 | MASK_24));
- mdelay(10);
-
- saa7146_write(dev, BASE_ODD3, 0);
- saa7146_write(dev, BASE_EVEN3, 0);
- saa7146_write(dev, PROT_ADDR3, budget->buffer_size);
- saa7146_write(dev, BASE_PAGE3, budget->pt.dma | ME1 | 0x90);
-
- saa7146_write(dev, PITCH3, budget->buffer_width);
- saa7146_write(dev, NUM_LINE_BYTE3,
- (budget->buffer_height << 16) | budget->buffer_width);
-
- saa7146_write(dev, MC2, (MASK_04 | MASK_20));
-
- SAA7146_ISR_CLEAR(budget->dev, MASK_10); /* VPE */
- SAA7146_IER_ENABLE(budget->dev, MASK_10); /* VPE */
- saa7146_write(dev, MC1, (MASK_04 | MASK_20)); /* DMA3 on */
-
- return 0;
-}
-
-static int budget_read_fe_status(struct dvb_frontend *fe, fe_status_t *status)
-{
- struct budget *budget = (struct budget *) fe->dvb->priv;
- int synced;
- int ret;
-
- if (budget->read_fe_status)
- ret = budget->read_fe_status(fe, status);
- else
- ret = -EINVAL;
-
- if (!ret) {
- synced = (*status & FE_HAS_LOCK);
- if (synced != budget->fe_synced) {
- budget->fe_synced = synced;
- spin_lock(&budget->feedlock);
- if (synced)
- start_ts_capture(budget);
- else
- stop_ts_capture(budget);
- spin_unlock(&budget->feedlock);
- }
- }
- return ret;
-}
-
-static void vpeirq(unsigned long data)
-{
- struct budget *budget = (struct budget *) data;
- u8 *mem = (u8 *) (budget->grabbing);
- u32 olddma = budget->ttbp;
- u32 newdma = saa7146_read(budget->dev, PCI_VDP3);
- u32 count;
-
- /* nearest lower position divisible by 188 */
- newdma -= newdma % 188;
-
- if (newdma >= budget->buffer_size)
- return;
-
- budget->ttbp = newdma;
-
- if (budget->feeding == 0 || newdma == olddma)
- return;
-
- if (newdma > olddma) { /* no wraparound, dump olddma..newdma */
- count = newdma - olddma;
- dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, count / 188);
- } else { /* wraparound, dump olddma..buflen and 0..newdma */
- count = budget->buffer_size - olddma;
- dvb_dmx_swfilter_packets(&budget->demux, mem + olddma, count / 188);
- count += newdma;
- dvb_dmx_swfilter_packets(&budget->demux, mem, newdma / 188);
- }
-
- if (count > budget->buffer_warning_threshold)
- budget->buffer_warnings++;
-
- if (budget->buffer_warnings && time_after(jiffies, budget->buffer_warning_time)) {
- printk("%s %s: used %d times >80%% of buffer (%u bytes now)\n",
- budget->dev->name, __FUNCTION__, budget->buffer_warnings, count);
- budget->buffer_warning_time = jiffies + BUFFER_WARNING_WAIT;
- budget->buffer_warnings = 0;
- }
-}
-
-
-int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count,
- int uselocks, int nobusyloop)
-{
- struct saa7146_dev *saa = budget->dev;
- int result = 0;
- unsigned long flags = 0;
-
- if (count > 4 || count <= 0)
- return 0;
-
- if (uselocks)
- spin_lock_irqsave(&budget->debilock, flags);
-
- if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
- if (uselocks)
- spin_unlock_irqrestore(&budget->debilock, flags);
- return result;
- }
-
- saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x10000 | (addr & 0xffff));
- saa7146_write(saa, DEBI_CONFIG, config);
- saa7146_write(saa, DEBI_PAGE, 0);
- saa7146_write(saa, MC2, (2 << 16) | 2);
-
- if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
- if (uselocks)
- spin_unlock_irqrestore(&budget->debilock, flags);
- return result;
- }
-
- result = saa7146_read(saa, DEBI_AD);
- result &= (0xffffffffUL >> ((4 - count) * 8));
-
- if (uselocks)
- spin_unlock_irqrestore(&budget->debilock, flags);
-
- return result;
-}
-
-int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr,
- int count, u32 value, int uselocks, int nobusyloop)
-{
- struct saa7146_dev *saa = budget->dev;
- unsigned long flags = 0;
- int result;
-
- if (count > 4 || count <= 0)
- return 0;
-
- if (uselocks)
- spin_lock_irqsave(&budget->debilock, flags);
-
- if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
- if (uselocks)
- spin_unlock_irqrestore(&budget->debilock, flags);
- return result;
- }
-
- saa7146_write(saa, DEBI_COMMAND, (count << 17) | 0x00000 | (addr & 0xffff));
- saa7146_write(saa, DEBI_CONFIG, config);
- saa7146_write(saa, DEBI_PAGE, 0);
- saa7146_write(saa, DEBI_AD, value);
- saa7146_write(saa, MC2, (2 << 16) | 2);
-
- if ((result = saa7146_wait_for_debi_done(saa, nobusyloop)) < 0) {
- if (uselocks)
- spin_unlock_irqrestore(&budget->debilock, flags);
- return result;
- }
-
- if (uselocks)
- spin_unlock_irqrestore(&budget->debilock, flags);
- return 0;
-}
-
-
-/****************************************************************************
- * DVB API SECTION
- ****************************************************************************/
-
-static int budget_start_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct budget *budget = (struct budget *) demux->priv;
- int status = 0;
-
- dprintk(2, "budget: %p\n", budget);
-
- if (!demux->dmx.frontend)
- return -EINVAL;
-
- spin_lock(&budget->feedlock);
- feed->pusi_seen = 0; /* have a clean section start */
- if (budget->feeding++ == 0)
- status = start_ts_capture(budget);
- spin_unlock(&budget->feedlock);
- return status;
-}
-
-static int budget_stop_feed(struct dvb_demux_feed *feed)
-{
- struct dvb_demux *demux = feed->demux;
- struct budget *budget = (struct budget *) demux->priv;
- int status = 0;
-
- dprintk(2, "budget: %p\n", budget);
-
- spin_lock(&budget->feedlock);
- if (--budget->feeding == 0)
- status = stop_ts_capture(budget);
- spin_unlock(&budget->feedlock);
- return status;
-}
-
-static int budget_register(struct budget *budget)
-{
- struct dvb_demux *dvbdemux = &budget->demux;
- int ret;
-
- dprintk(2, "budget: %p\n", budget);
-
- dvbdemux->priv = (void *) budget;
-
- dvbdemux->filternum = 256;
- dvbdemux->feednum = 256;
- dvbdemux->start_feed = budget_start_feed;
- dvbdemux->stop_feed = budget_stop_feed;
- dvbdemux->write_to_decoder = NULL;
-
- dvbdemux->dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING |
- DMX_MEMORY_BASED_FILTERING);
-
- dvb_dmx_init(&budget->demux);
-
- budget->dmxdev.filternum = 256;
- budget->dmxdev.demux = &dvbdemux->dmx;
- budget->dmxdev.capabilities = 0;
-
- dvb_dmxdev_init(&budget->dmxdev, &budget->dvb_adapter);
-
- budget->hw_frontend.source = DMX_FRONTEND_0;
-
- ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->hw_frontend);
-
- if (ret < 0)
- return ret;
-
- budget->mem_frontend.source = DMX_MEMORY_FE;
- ret = dvbdemux->dmx.add_frontend(&dvbdemux->dmx, &budget->mem_frontend);
- if (ret < 0)
- return ret;
-
- ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &budget->hw_frontend);
- if (ret < 0)
- return ret;
-
- dvb_net_init(&budget->dvb_adapter, &budget->dvb_net, &dvbdemux->dmx);
-
- return 0;
-}
-
-static void budget_unregister(struct budget *budget)
-{
- struct dvb_demux *dvbdemux = &budget->demux;
-
- dprintk(2, "budget: %p\n", budget);
-
- dvb_net_release(&budget->dvb_net);
-
- dvbdemux->dmx.close(&dvbdemux->dmx);
- dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &budget->hw_frontend);
- dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, &budget->mem_frontend);
-
- dvb_dmxdev_release(&budget->dmxdev);
- dvb_dmx_release(&budget->demux);
-}
-
-int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
- struct saa7146_pci_extension_data *info,
- struct module *owner)
-{
- int ret = 0;
- struct budget_info *bi = info->ext_priv;
- int max_bufsize;
- int height_mask;
-
- memset(budget, 0, sizeof(struct budget));
-
- dprintk(2, "dev: %p, budget: %p\n", dev, budget);
-
- budget->card = bi;
- budget->dev = (struct saa7146_dev *) dev;
-
- if (budget->card->type == BUDGET_FS_ACTIVY) {
- budget->buffer_width = TS_WIDTH_ACTIVY;
- max_bufsize = TS_MAX_BUFSIZE_K_ACTIVY;
- height_mask = TS_HEIGHT_MASK_ACTIVY;
- } else {
- budget->buffer_width = TS_WIDTH;
- max_bufsize = TS_MAX_BUFSIZE_K;
- height_mask = TS_HEIGHT_MASK;
- }
-
- if (dma_buffer_size < TS_MIN_BUFSIZE_K)
- dma_buffer_size = TS_MIN_BUFSIZE_K;
- else if (dma_buffer_size > max_bufsize)
- dma_buffer_size = max_bufsize;
-
- budget->buffer_height = dma_buffer_size * 1024 / budget->buffer_width;
- budget->buffer_height &= height_mask;
- budget->buffer_size = budget->buffer_height * budget->buffer_width;
- budget->buffer_warning_threshold = budget->buffer_size * 80/100;
- budget->buffer_warnings = 0;
- budget->buffer_warning_time = jiffies;
-
- dprintk(2, "%s: width = %d, height = %d\n",
- budget->dev->name, budget->buffer_width, budget->buffer_height);
- printk("%s: dma buffer size %u\n", budget->dev->name, budget->buffer_size);
-
- if ((ret = dvb_register_adapter(&budget->dvb_adapter, budget->card->name, owner, &budget->dev->pci->dev)) < 0) {
- return ret;
- }
-
- /* set dd1 stream a & b */
- saa7146_write(dev, DD1_STREAM_B, 0x00000000);
- saa7146_write(dev, MC2, (MASK_09 | MASK_25));
- saa7146_write(dev, MC2, (MASK_10 | MASK_26));
- saa7146_write(dev, DD1_INIT, 0x02000000);
- saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
-
- if (bi->type != BUDGET_FS_ACTIVY)
- budget->video_port = BUDGET_VIDEO_PORTB;
- else
- budget->video_port = BUDGET_VIDEO_PORTA;
- spin_lock_init(&budget->feedlock);
- spin_lock_init(&budget->debilock);
-
- /* the Siemens DVB needs this if you want to have the i2c chips
- get recognized before the main driver is loaded */
- if (bi->type != BUDGET_FS_ACTIVY)
- saa7146_write(dev, GPIO_CTRL, 0x500000); /* GPIO 3 = 1 */
-
-#ifdef I2C_ADAP_CLASS_TV_DIGITAL
- budget->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
-#else
- budget->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
-#endif
-
- strlcpy(budget->i2c_adap.name, budget->card->name, sizeof(budget->i2c_adap.name));
-
- saa7146_i2c_adapter_prepare(dev, &budget->i2c_adap, SAA7146_I2C_BUS_BIT_RATE_120);
- strcpy(budget->i2c_adap.name, budget->card->name);
-
- if (i2c_add_adapter(&budget->i2c_adap) < 0) {
- dvb_unregister_adapter(&budget->dvb_adapter);
- return -ENOMEM;
- }
-
- ttpci_eeprom_parse_mac(&budget->i2c_adap, budget->dvb_adapter.proposed_mac);
-
- if (NULL ==
- (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci, budget->buffer_size, &budget->pt))) {
- ret = -ENOMEM;
- goto err;
- }
-
- saa7146_write(dev, PCI_BT_V1, 0x001c0000);
- /* upload all */
- saa7146_write(dev, GPIO_CTRL, 0x000000);
-
- tasklet_init(&budget->vpe_tasklet, vpeirq, (unsigned long) budget);
-
- /* frontend power on */
- if (bi->type != BUDGET_FS_ACTIVY)
- saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
-
- if (budget_register(budget) == 0) {
- return 0;
- }
-err:
- i2c_del_adapter(&budget->i2c_adap);
-
- vfree(budget->grabbing);
-
- dvb_unregister_adapter(&budget->dvb_adapter);
-
- return ret;
-}
-
-void ttpci_budget_init_hooks(struct budget *budget)
-{
- if (budget->dvb_frontend && !budget->read_fe_status) {
- budget->read_fe_status = budget->dvb_frontend->ops.read_status;
- budget->dvb_frontend->ops.read_status = budget_read_fe_status;
- }
-}
-
-int ttpci_budget_deinit(struct budget *budget)
-{
- struct saa7146_dev *dev = budget->dev;
-
- dprintk(2, "budget: %p\n", budget);
-
- budget_unregister(budget);
-
- i2c_del_adapter(&budget->i2c_adap);
-
- dvb_unregister_adapter(&budget->dvb_adapter);
-
- tasklet_kill(&budget->vpe_tasklet);
-
- saa7146_pgtable_free(dev->pci, &budget->pt);
-
- vfree(budget->grabbing);
-
- return 0;
-}
-
-void ttpci_budget_irq10_handler(struct saa7146_dev *dev, u32 * isr)
-{
- struct budget *budget = (struct budget *) dev->ext_priv;
-
- dprintk(8, "dev: %p, budget: %p\n", dev, budget);
-
- if (*isr & MASK_10)
- tasklet_schedule(&budget->vpe_tasklet);
-}
-
-void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port)
-{
- struct budget *budget = (struct budget *) dev->ext_priv;
-
- spin_lock(&budget->feedlock);
- budget->video_port = video_port;
- if (budget->feeding) {
- stop_ts_capture(budget);
- start_ts_capture(budget);
- }
- spin_unlock(&budget->feedlock);
-}
-
-EXPORT_SYMBOL_GPL(ttpci_budget_debiread);
-EXPORT_SYMBOL_GPL(ttpci_budget_debiwrite);
-EXPORT_SYMBOL_GPL(ttpci_budget_init);
-EXPORT_SYMBOL_GPL(ttpci_budget_init_hooks);
-EXPORT_SYMBOL_GPL(ttpci_budget_deinit);
-EXPORT_SYMBOL_GPL(ttpci_budget_irq10_handler);
-EXPORT_SYMBOL_GPL(ttpci_budget_set_video_port);
-EXPORT_SYMBOL_GPL(budget_debug);
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
deleted file mode 100644
index 57227441891..00000000000
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ /dev/null
@@ -1,668 +0,0 @@
-/*
- * budget-patch.c: driver for Budget Patch,
- * hardware modification of DVB-S cards enabling full TS
- *
- * Written by Emard <emard@softhome.net>
- *
- * Original idea by Roberto Deza <rdeza@unav.es>
- *
- * Special thanks to Holger Waechtler, Michael Hunold, Marian Durkovic
- * and Metzlerbros
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include "av7110.h"
-#include "av7110_hw.h"
-#include "budget.h"
-#include "stv0299.h"
-#include "ves1x93.h"
-#include "tda8083.h"
-
-#include "bsru6.h"
-
-#define budget_patch budget
-
-static struct saa7146_extension budget_extension;
-
-MAKE_BUDGET_INFO(ttbp, "TT-Budget/Patch DVB-S 1.x PCI", BUDGET_PATCH);
-//MAKE_BUDGET_INFO(satel,"TT-Budget/Patch SATELCO PCI", BUDGET_TT_HW_DISEQC);
-
-static struct pci_device_id pci_tbl[] = {
- MAKE_EXTENSION_PCI(ttbp,0x13c2, 0x0000),
-// MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
- {
- .vendor = 0,
- }
-};
-
-/* those lines are for budget-patch to be tried
-** on a true budget card and observe the
-** behaviour of VSYNC generated by rps1.
-** this code was shamelessly copy/pasted from budget.c
-*/
-static void gpio_Set22K (struct budget *budget, int state)
-{
- struct saa7146_dev *dev=budget->dev;
- dprintk(2, "budget: %p\n", budget);
- saa7146_setgpio(dev, 3, (state ? SAA7146_GPIO_OUTHI : SAA7146_GPIO_OUTLO));
-}
-
-/* Diseqc functions only for TT Budget card */
-/* taken from the Skyvision DVB driver by
- Ralph Metzler <rjkm@metzlerbros.de> */
-
-static void DiseqcSendBit (struct budget *budget, int data)
-{
- struct saa7146_dev *dev=budget->dev;
- dprintk(2, "budget: %p\n", budget);
-
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
- udelay(data ? 500 : 1000);
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- udelay(data ? 1000 : 500);
-}
-
-static void DiseqcSendByte (struct budget *budget, int data)
-{
- int i, par=1, d;
-
- dprintk(2, "budget: %p\n", budget);
-
- for (i=7; i>=0; i--) {
- d = (data>>i)&1;
- par ^= d;
- DiseqcSendBit(budget, d);
- }
-
- DiseqcSendBit(budget, par);
-}
-
-static int SendDiSEqCMsg (struct budget *budget, int len, u8 *msg, unsigned long burst)
-{
- struct saa7146_dev *dev=budget->dev;
- int i;
-
- dprintk(2, "budget: %p\n", budget);
-
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- mdelay(16);
-
- for (i=0; i<len; i++)
- DiseqcSendByte(budget, msg[i]);
-
- mdelay(16);
-
- if (burst!=-1) {
- if (burst)
- DiseqcSendByte(budget, 0xff);
- else {
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
- udelay(12500);
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- }
- msleep(20);
- }
-
- return 0;
-}
-
-/* shamelessly copy/pasted from budget.c
-*/
-static int budget_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
-
- switch (tone) {
- case SEC_TONE_ON:
- gpio_Set22K (budget, 1);
- break;
-
- case SEC_TONE_OFF:
- gpio_Set22K (budget, 0);
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int budget_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
-
- SendDiSEqCMsg (budget, cmd->msg_len, cmd->msg, 0);
-
- return 0;
-}
-
-static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
-
- SendDiSEqCMsg (budget, 0, NULL, minicmd);
-
- return 0;
-}
-
-static int budget_av7110_send_fw_cmd(struct budget_patch *budget, u16* buf, int length)
-{
- int i;
-
- dprintk(2, "budget: %p\n", budget);
-
- for (i = 2; i < length; i++)
- {
- ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2*i, 2, (u32) buf[i], 0,0);
- msleep(5);
- }
- if (length)
- ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2, 2, (u32) buf[1], 0,0);
- else
- ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2, 2, 0, 0,0);
- msleep(5);
- ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND, 2, (u32) buf[0], 0,0);
- msleep(5);
- return 0;
-}
-
-static void av7110_set22k(struct budget_patch *budget, int state)
-{
- u16 buf[2] = {( COMTYPE_AUDIODAC << 8) | (state ? ON22K : OFF22K), 0};
-
- dprintk(2, "budget: %p\n", budget);
- budget_av7110_send_fw_cmd(budget, buf, 2);
-}
-
-static int av7110_send_diseqc_msg(struct budget_patch *budget, int len, u8 *msg, int burst)
-{
- int i;
- u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) | SendDiSEqC),
- 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- dprintk(2, "budget: %p\n", budget);
-
- if (len>10)
- len=10;
-
- buf[1] = len+2;
- buf[2] = len;
-
- if (burst != -1)
- buf[3]=burst ? 0x01 : 0x00;
- else
- buf[3]=0xffff;
-
- for (i=0; i<len; i++)
- buf[i+4]=msg[i];
-
- budget_av7110_send_fw_cmd(budget, buf, 18);
- return 0;
-}
-
-static int budget_patch_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
-
- switch (tone) {
- case SEC_TONE_ON:
- av7110_set22k (budget, 1);
- break;
-
- case SEC_TONE_OFF:
- av7110_set22k (budget, 0);
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int budget_patch_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
-{
- struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
-
- av7110_send_diseqc_msg (budget, cmd->msg_len, cmd->msg, 0);
-
- return 0;
-}
-
-static int budget_patch_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
-{
- struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
-
- av7110_send_diseqc_msg (budget, 0, NULL, minicmd);
-
- return 0;
-}
-
-static int alps_bsrv2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
- u8 pwr = 0;
- u8 buf[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
- u32 div = (params->frequency + 479500) / 125;
-
- if (params->frequency > 2000000) pwr = 3;
- else if (params->frequency > 1800000) pwr = 2;
- else if (params->frequency > 1600000) pwr = 1;
- else if (params->frequency > 1200000) pwr = 0;
- else if (params->frequency >= 1100000) pwr = 1;
- else pwr = 2;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = ((div & 0x18000) >> 10) | 0x95;
- buf[3] = (pwr << 6) | 0x30;
-
- // NOTE: since we're using a prescaler of 2, we set the
- // divisor frequency to 62.5kHz and divide by 125 above
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct ves1x93_config alps_bsrv2_config = {
- .demod_address = 0x08,
- .xin = 90100000UL,
- .invert_pwm = 0,
-};
-
-static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = params->frequency / 125;
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x8e;
- data[3] = 0x00;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1)
- return -EIO;
- return 0;
-}
-
-static struct tda8083_config grundig_29504_451_config = {
- .demod_address = 0x68,
-};
-
-static void frontend_init(struct budget_patch* budget)
-{
- switch(budget->dev->pci->subsystem_device) {
- case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X
- case 0x1013: // SATELCO Multimedia PCI
-
- // try the ALPS BSRV2 first of all
- budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
- budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
- budget->dvb_frontend->ops.diseqc_send_burst = budget_patch_diseqc_send_burst;
- budget->dvb_frontend->ops.set_tone = budget_patch_set_tone;
- break;
- }
-
- // try the ALPS BSRU6 now
- budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
- budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
-
- budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
- budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
- budget->dvb_frontend->ops.set_tone = budget_set_tone;
- break;
- }
-
- // Try the grundig 29504-451
- budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
- budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
- budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
- budget->dvb_frontend->ops.set_tone = budget_set_tone;
- break;
- }
- break;
- }
-
- if (budget->dvb_frontend == NULL) {
- printk("dvb-ttpci: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
- budget->dev->pci->vendor,
- budget->dev->pci->device,
- budget->dev->pci->subsystem_vendor,
- budget->dev->pci->subsystem_device);
- } else {
- if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
- printk("budget-av: Frontend registration failed!\n");
- if (budget->dvb_frontend->ops.release)
- budget->dvb_frontend->ops.release(budget->dvb_frontend);
- budget->dvb_frontend = NULL;
- }
- }
-}
-
-/* written by Emard */
-static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
-{
- struct budget_patch *budget;
- int err;
- int count = 0;
- int detected = 0;
-
-#define PATCH_RESET 0
-#define RPS_IRQ 0
-#define HPS_SETUP 0
-#if PATCH_RESET
- saa7146_write(dev, MC1, MASK_31);
- msleep(40);
-#endif
-#if HPS_SETUP
- // initialize registers. Better to have it like this
- // than leaving something unconfigured
- saa7146_write(dev, DD1_STREAM_B, 0);
- // port B VSYNC at rising edge
- saa7146_write(dev, DD1_INIT, 0x00000200); // have this in budget-core too!
- saa7146_write(dev, BRS_CTRL, 0x00000000); // VBI
-
- // debi config
- // saa7146_write(dev, DEBI_CONFIG, MASK_30|MASK_28|MASK_18);
-
- // zero all HPS registers
- saa7146_write(dev, HPS_H_PRESCALE, 0); // r68
- saa7146_write(dev, HPS_H_SCALE, 0); // r6c
- saa7146_write(dev, BCS_CTRL, 0); // r70
- saa7146_write(dev, HPS_V_SCALE, 0); // r60
- saa7146_write(dev, HPS_V_GAIN, 0); // r64
- saa7146_write(dev, CHROMA_KEY_RANGE, 0); // r74
- saa7146_write(dev, CLIP_FORMAT_CTRL, 0); // r78
- // Set HPS prescaler for port B input
- saa7146_write(dev, HPS_CTRL, (1<<30) | (0<<29) | (1<<28) | (0<<12) );
- saa7146_write(dev, MC2,
- 0 * (MASK_08 | MASK_24) | // BRS control
- 0 * (MASK_09 | MASK_25) | // a
- 0 * (MASK_10 | MASK_26) | // b
- 1 * (MASK_06 | MASK_22) | // HPS_CTRL1
- 1 * (MASK_05 | MASK_21) | // HPS_CTRL2
- 0 * (MASK_01 | MASK_15) // DEBI
- );
-#endif
- // Disable RPS1 and RPS0
- saa7146_write(dev, MC1, ( MASK_29 | MASK_28));
- // RPS1 timeout disable
- saa7146_write(dev, RPS_TOV1, 0);
-
- // code for autodetection
- // will wait for VBI_B event (vertical blank at port B)
- // and will reset GPIO3 after VBI_B is detected.
- // (GPIO3 should be raised high by CPU to
- // test if GPIO3 will generate vertical blank signal
- // in budget patch GPIO3 is connected to VSYNC_B
- count = 0;
-#if 0
- WRITE_RPS1(cpu_to_le32(CMD_UPLOAD |
- MASK_10 | MASK_09 | MASK_08 | MASK_06 | MASK_05 | MASK_04 | MASK_03 | MASK_02 ));
-#endif
- WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_VBI_B));
- WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
- WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
- WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
-#if RPS_IRQ
- // issue RPS1 interrupt to increment counter
- WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
- // at least a NOP is neede between two interrupts
- WRITE_RPS1(cpu_to_le32(CMD_NOP));
- // interrupt again
- WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
-#endif
- WRITE_RPS1(cpu_to_le32(CMD_STOP));
-
-#if RPS_IRQ
- // set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
- // use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
- // use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
- saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
- // set event counter 1 treshold to maximum allowed value (rEC p55)
- saa7146_write(dev, ECT1R, 0x3fff );
-#endif
- // Fix VSYNC level
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- // Set RPS1 Address register to point to RPS code (r108 p42)
- saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
- // Enable RPS1, (rFC p33)
- saa7146_write(dev, MC1, (MASK_13 | MASK_29 ));
-
-
- mdelay(50);
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
- mdelay(150);
-
-
- if( (saa7146_read(dev, GPIO_CTRL) & 0x10000000) == 0)
- detected = 1;
-
-#if RPS_IRQ
- printk("Event Counter 1 0x%04x\n", saa7146_read(dev, EC1R) & 0x3fff );
-#endif
- // Disable RPS1
- saa7146_write(dev, MC1, ( MASK_29 ));
-
- if(detected == 0)
- printk("budget-patch not detected or saa7146 in non-default state.\n"
- "try enabling ressetting of 7146 with MASK_31 in MC1 register\n");
-
- else
- printk("BUDGET-PATCH DETECTED.\n");
-
-
-/* OLD (Original design by Roberto Deza):
-** This code will setup the SAA7146_RPS1 to generate a square
-** wave on GPIO3, changing when a field (TS_HEIGHT/2 "lines" of
-** TS_WIDTH packets) has been acquired on SAA7146_D1B video port;
-** then, this GPIO3 output which is connected to the D1B_VSYNC
-** input, will trigger the acquisition of the alternate field
-** and so on.
-** Currently, the TT_budget / WinTV_Nova cards have two ICs
-** (74HCT4040, LVC74) for the generation of this VSYNC signal,
-** which seems that can be done perfectly without this :-)).
-*/
-
-/* New design (By Emard)
-** this rps1 code will copy internal HS event to GPIO3 pin.
-** GPIO3 is in budget-patch hardware connectd to port B VSYNC
-
-** HS is an internal event of 7146, accessible with RPS
-** and temporarily raised high every n lines
-** (n in defined in the RPS_THRESH1 counter threshold)
-** I think HS is raised high on the beginning of the n-th line
-** and remains high until this n-th line that triggered
-** it is completely received. When the receiption of n-th line
-** ends, HS is lowered.
-
-** To transmit data over DMA, 7146 needs changing state at
-** port B VSYNC pin. Any changing of port B VSYNC will
-** cause some DMA data transfer, with more or less packets loss.
-** It depends on the phase and frequency of VSYNC and
-** the way of 7146 is instructed to trigger on port B (defined
-** in DD1_INIT register, 3rd nibble from the right valid
-** numbers are 0-7, see datasheet)
-**
-** The correct triggering can minimize packet loss,
-** dvbtraffic should give this stable bandwidths:
-** 22k transponder = 33814 kbit/s
-** 27.5k transponder = 38045 kbit/s
-** by experiment it is found that the best results
-** (stable bandwidths and almost no packet loss)
-** are obtained using DD1_INIT triggering number 2
-** (Va at rising edge of VS Fa = HS x VS-failing forced toggle)
-** and a VSYNC phase that occurs in the middle of DMA transfer
-** (about byte 188*512=96256 in the DMA window).
-**
-** Phase of HS is still not clear to me how to control,
-** It just happens to be so. It can be seen if one enables
-** RPS_IRQ and print Event Counter 1 in vpeirq(). Every
-** time RPS_INTERRUPT is called, the Event Counter 1 will
-** increment. That's how the 7146 is programmed to do event
-** counting in this budget-patch.c
-** I *think* HPS setting has something to do with the phase
-** of HS but I cant be 100% sure in that.
-
-** hardware debug note: a working budget card (including budget patch)
-** with vpeirq() interrupt setup in mode "0x90" (every 64K) will
-** generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
-** and that means 3*25=75 Hz of interrupt freqency, as seen by
-** watch cat /proc/interrupts
-**
-** If this frequency is 3x lower (and data received in the DMA
-** buffer don't start with 0x47, but in the middle of packets,
-** whose lengths appear to be like 188 292 188 104 etc.
-** this means VSYNC line is not connected in the hardware.
-** (check soldering pcb and pins)
-** The same behaviour of missing VSYNC can be duplicated on budget
-** cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
-*/
-
- // Setup RPS1 "program" (p35)
- count = 0;
-
-
- // Wait Source Line Counter Threshold (p36)
- WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS));
- // Set GPIO3=1 (p42)
- WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
- WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
- WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTHI<<24));
-#if RPS_IRQ
- // issue RPS1 interrupt
- WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
-#endif
- // Wait reset Source Line Counter Threshold (p36)
- WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS));
- // Set GPIO3=0 (p42)
- WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
- WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
- WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
-#if RPS_IRQ
- // issue RPS1 interrupt
- WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
-#endif
- // Jump to begin of RPS program (p37)
- WRITE_RPS1(cpu_to_le32(CMD_JUMP));
- WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
-
- // Fix VSYNC level
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- // Set RPS1 Address register to point to RPS code (r108 p42)
- saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
-
- if (!(budget = kmalloc (sizeof(struct budget_patch), GFP_KERNEL)))
- return -ENOMEM;
-
- dprintk(2, "budget: %p\n", budget);
-
- if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) {
- kfree (budget);
- return err;
- }
-
- // Set Source Line Counter Threshold, using BRS (rCC p43)
- // It generates HS event every TS_HEIGHT lines
- // this is related to TS_WIDTH set in register
- // NUM_LINE_BYTE3 in budget-core.c. If NUM_LINE_BYTE
- // low 16 bits are set to TS_WIDTH bytes (TS_WIDTH=2*188
- //,then RPS_THRESH1
- // should be set to trigger every TS_HEIGHT (512) lines.
- //
- saa7146_write(dev, RPS_THRESH1, budget->buffer_height | MASK_12 );
-
- // saa7146_write(dev, RPS_THRESH0, ((TS_HEIGHT/2)<<16) |MASK_28| (TS_HEIGHT/2) |MASK_12 );
- // Enable RPS1 (rFC p33)
- saa7146_write(dev, MC1, (MASK_13 | MASK_29));
-
-
- dev->ext_priv = budget;
-
- budget->dvb_adapter.priv = budget;
- frontend_init(budget);
-
- ttpci_budget_init_hooks(budget);
-
- return 0;
-}
-
-static int budget_patch_detach (struct saa7146_dev* dev)
-{
- struct budget_patch *budget = (struct budget_patch*) dev->ext_priv;
- int err;
-
- if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend);
-
- err = ttpci_budget_deinit (budget);
-
- kfree (budget);
-
- return err;
-}
-
-static int __init budget_patch_init(void)
-{
- return saa7146_register_extension(&budget_extension);
-}
-
-static void __exit budget_patch_exit(void)
-{
- saa7146_unregister_extension(&budget_extension);
-}
-
-static struct saa7146_extension budget_extension = {
- .name = "budget_patch dvb\0",
- .flags = 0,
-
- .module = THIS_MODULE,
- .pci_tbl = pci_tbl,
- .attach = budget_patch_attach,
- .detach = budget_patch_detach,
-
- .irq_mask = MASK_10,
- .irq_func = ttpci_budget_irq10_handler,
-};
-
-module_init(budget_patch_init);
-module_exit(budget_patch_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Emard, Roberto Deza, Holger Waechtler, Michael Hunold, others");
-MODULE_DESCRIPTION("Driver for full TS modified DVB-S SAA7146+AV7110 "
- "based so-called Budget Patch cards");
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
deleted file mode 100644
index 863dffb4ed8..00000000000
--- a/drivers/media/dvb/ttpci/budget.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * budget.c: driver for the SAA7146 based Budget DVB cards
- *
- * Compiled from various sources by Michael Hunold <michael@mihu.de>
- *
- * Copyright (C) 2002 Ralph Metzler <rjkm@metzlerbros.de>
- *
- * Copyright (C) 1999-2002 Ralph Metzler
- * & Marcus Metzler for convergence integrated media GmbH
- *
- * 26feb2004 Support for FS Activy Card (Grundig tuner) by
- * Michael Dreher <michael@5dot1.de>,
- * Oliver Endriss <o.endriss@gmx.de> and
- * Andreas 'randy' Weinberger
- *
- * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
- *
- *
- * the project's page is at http://www.linuxtv.org/dvb/
- */
-
-#include "budget.h"
-#include "stv0299.h"
-#include "ves1x93.h"
-#include "ves1820.h"
-#include "l64781.h"
-#include "tda8083.h"
-#include "s5h1420.h"
-#include "lnbp21.h"
-#include "bsru6.h"
-
-static void Set22K (struct budget *budget, int state)
-{
- struct saa7146_dev *dev=budget->dev;
- dprintk(2, "budget: %p\n", budget);
- saa7146_setgpio(dev, 3, (state ? SAA7146_GPIO_OUTHI : SAA7146_GPIO_OUTLO));
-}
-
-/* Diseqc functions only for TT Budget card */
-/* taken from the Skyvision DVB driver by
- Ralph Metzler <rjkm@metzlerbros.de> */
-
-static void DiseqcSendBit (struct budget *budget, int data)
-{
- struct saa7146_dev *dev=budget->dev;
- dprintk(2, "budget: %p\n", budget);
-
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
- udelay(data ? 500 : 1000);
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- udelay(data ? 1000 : 500);
-}
-
-static void DiseqcSendByte (struct budget *budget, int data)
-{
- int i, par=1, d;
-
- dprintk(2, "budget: %p\n", budget);
-
- for (i=7; i>=0; i--) {
- d = (data>>i)&1;
- par ^= d;
- DiseqcSendBit(budget, d);
- }
-
- DiseqcSendBit(budget, par);
-}
-
-static int SendDiSEqCMsg (struct budget *budget, int len, u8 *msg, unsigned long burst)
-{
- struct saa7146_dev *dev=budget->dev;
- int i;
-
- dprintk(2, "budget: %p\n", budget);
-
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- mdelay(16);
-
- for (i=0; i<len; i++)
- DiseqcSendByte(budget, msg[i]);
-
- mdelay(16);
-
- if (burst!=-1) {
- if (burst)
- DiseqcSendByte(budget, 0xff);
- else {
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
- udelay(12500);
- saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
- }
- msleep(20);
- }
-
- return 0;
-}
-
-/*
- * Routines for the Fujitsu Siemens Activy budget card
- * 22 kHz tone and DiSEqC are handled by the frontend.
- * Voltage must be set here.
- * GPIO 1: LNBP EN, GPIO 2: LNBP VSEL
- */
-static int SetVoltage_Activy (struct budget *budget, fe_sec_voltage_t voltage)
-{
- struct saa7146_dev *dev=budget->dev;
-
- dprintk(2, "budget: %p\n", budget);
-
- switch (voltage) {
- case SEC_VOLTAGE_13:
- saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);
- saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTLO);
- break;
- case SEC_VOLTAGE_18:
- saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI);
- saa7146_setgpio(dev, 2, SAA7146_GPIO_OUTHI);
- break;
- case SEC_VOLTAGE_OFF:
- saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTLO);
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int siemens_budget_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
-
- return SetVoltage_Activy (budget, voltage);
-}
-
-static int budget_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
-
- switch (tone) {
- case SEC_TONE_ON:
- Set22K (budget, 1);
- break;
-
- case SEC_TONE_OFF:
- Set22K (budget, 0);
- break;
-
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static int budget_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
-
- SendDiSEqCMsg (budget, cmd->msg_len, cmd->msg, 0);
-
- return 0;
-}
-
-static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
-
- SendDiSEqCMsg (budget, 0, NULL, minicmd);
-
- return 0;
-}
-
-static int alps_bsrv2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
- u8 pwr = 0;
- u8 buf[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
- u32 div = (params->frequency + 479500) / 125;
-
- if (params->frequency > 2000000) pwr = 3;
- else if (params->frequency > 1800000) pwr = 2;
- else if (params->frequency > 1600000) pwr = 1;
- else if (params->frequency > 1200000) pwr = 0;
- else if (params->frequency >= 1100000) pwr = 1;
- else pwr = 2;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = ((div & 0x18000) >> 10) | 0x95;
- buf[3] = (pwr << 6) | 0x30;
-
- // NOTE: since we're using a prescaler of 2, we set the
- // divisor frequency to 62.5kHz and divide by 125 above
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
- return 0;
-}
-
-static struct ves1x93_config alps_bsrv2_config =
-{
- .demod_address = 0x08,
- .xin = 90100000UL,
- .invert_pwm = 0,
-};
-
-static int alps_tdbe2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (params->frequency + 35937500 + 31250) / 62500;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x85 | ((div >> 10) & 0x60);
- data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
- return 0;
-}
-
-static struct ves1820_config alps_tdbe2_config = {
- .demod_address = 0x09,
- .xin = 57840000UL,
- .invert = 1,
- .selagc = VES1820_SELAGC_SIGNAMPERR,
-};
-
-static int grundig_29504_401_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
- u32 div;
- u8 cfg, cpump, band_select;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (36125000 + params->frequency) / 166666;
-
- cfg = 0x88;
-
- if (params->frequency < 175000000) cpump = 2;
- else if (params->frequency < 390000000) cpump = 1;
- else if (params->frequency < 470000000) cpump = 2;
- else if (params->frequency < 750000000) cpump = 1;
- else cpump = 3;
-
- if (params->frequency < 175000000) band_select = 0x0e;
- else if (params->frequency < 470000000) band_select = 0x05;
- else band_select = 0x03;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = ((div >> 10) & 0x60) | cfg;
- data[3] = (cpump << 6) | band_select;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
- return 0;
-}
-
-static struct l64781_config grundig_29504_401_config = {
- .demod_address = 0x55,
-};
-
-static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = params->frequency / 125;
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x8e;
- data[3] = 0x00;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
- return 0;
-}
-
-static struct tda8083_config grundig_29504_451_config = {
- .demod_address = 0x68,
-};
-
-static int s5h1420_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct budget* budget = (struct budget*) fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = params->frequency / 1000;
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0xc2;
-
- if (div < 1450)
- data[3] = 0x00;
- else if (div < 1850)
- data[3] = 0x40;
- else if (div < 2000)
- data[3] = 0x80;
- else
- data[3] = 0xc0;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
-
- return 0;
-}
-
-static struct s5h1420_config s5h1420_config = {
- .demod_address = 0x53,
- .invert = 1,
-};
-
-static u8 read_pwm(struct budget* budget)
-{
- u8 b = 0xff;
- u8 pwm;
- struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
- { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
-
- if ((i2c_transfer(&budget->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
- pwm = 0x48;
-
- return pwm;
-}
-
-static void frontend_init(struct budget *budget)
-{
- switch(budget->dev->pci->subsystem_device) {
- case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659))
- case 0x1013:
- // try the ALPS BSRV2 first of all
- budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
- budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
- budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
- budget->dvb_frontend->ops.set_tone = budget_set_tone;
- break;
- }
-
- // try the ALPS BSRU6 now
- budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
- budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
- break;
- }
- break;
-
- case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
-
- budget->dvb_frontend = ves1820_attach(&alps_tdbe2_config, &budget->i2c_adap, read_pwm(budget));
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
- break;
- }
- break;
-
- case 0x1005: // Hauppauge/TT Nova-T budget (L64781/Grundig 29504-401(tsa5060))
-
- budget->dvb_frontend = l64781_attach(&grundig_29504_401_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params;
- break;
- }
- break;
-
- case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059))
- budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
- budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
- budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage;
- budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
- }
- break;
-
- case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522))
- budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
- budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage;
- budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL;
- }
- break;
-
- case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260))
- budget->dvb_frontend = s5h1420_attach(&s5h1420_config, &budget->i2c_adap);
- if (budget->dvb_frontend) {
- budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params;
- if (lnbp21_attach(budget->dvb_frontend, &budget->i2c_adap, 0, 0)) {
- printk("%s: No LNBP21 found!\n", __FUNCTION__);
- goto error_out;
- }
- break;
- }
- }
-
- if (budget->dvb_frontend == NULL) {
- printk("budget: A frontend driver was not found for device %04x/%04x subsystem %04x/%04x\n",
- budget->dev->pci->vendor,
- budget->dev->pci->device,
- budget->dev->pci->subsystem_vendor,
- budget->dev->pci->subsystem_device);
- } else {
- if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend))
- goto error_out;
- }
- return;
-
-error_out:
- printk("budget: Frontend registration failed!\n");
- if (budget->dvb_frontend->ops.release)
- budget->dvb_frontend->ops.release(budget->dvb_frontend);
- budget->dvb_frontend = NULL;
- return;
-}
-
-static int budget_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
-{
- struct budget *budget = NULL;
- int err;
-
- budget = kmalloc(sizeof(struct budget), GFP_KERNEL);
- if( NULL == budget ) {
- return -ENOMEM;
- }
-
- dprintk(2, "dev:%p, info:%p, budget:%p\n", dev, info, budget);
-
- dev->ext_priv = budget;
-
- if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) {
- printk("==> failed\n");
- kfree (budget);
- return err;
- }
-
- budget->dvb_adapter.priv = budget;
- frontend_init(budget);
-
- ttpci_budget_init_hooks(budget);
-
- return 0;
-}
-
-static int budget_detach (struct saa7146_dev* dev)
-{
- struct budget *budget = (struct budget*) dev->ext_priv;
- int err;
-
- if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend);
-
- err = ttpci_budget_deinit (budget);
-
- kfree (budget);
- dev->ext_priv = NULL;
-
- return err;
-}
-
-static struct saa7146_extension budget_extension;
-
-MAKE_BUDGET_INFO(ttbs, "TT-Budget/WinTV-NOVA-S PCI", BUDGET_TT);
-MAKE_BUDGET_INFO(ttbc, "TT-Budget/WinTV-NOVA-C PCI", BUDGET_TT);
-MAKE_BUDGET_INFO(ttbt, "TT-Budget/WinTV-NOVA-T PCI", BUDGET_TT);
-MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC);
-MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY);
-MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY);
-
-static struct pci_device_id pci_tbl[] = {
- MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003),
- MAKE_EXTENSION_PCI(ttbc, 0x13c2, 0x1004),
- MAKE_EXTENSION_PCI(ttbt, 0x13c2, 0x1005),
- MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
- MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1016),
- MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60),
- MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61),
- {
- .vendor = 0,
- }
-};
-
-MODULE_DEVICE_TABLE(pci, pci_tbl);
-
-static struct saa7146_extension budget_extension = {
- .name = "budget dvb\0",
- .flags = SAA7146_I2C_SHORT_DELAY,
-
- .module = THIS_MODULE,
- .pci_tbl = pci_tbl,
- .attach = budget_attach,
- .detach = budget_detach,
-
- .irq_mask = MASK_10,
- .irq_func = ttpci_budget_irq10_handler,
-};
-
-static int __init budget_init(void)
-{
- return saa7146_register_extension(&budget_extension);
-}
-
-static void __exit budget_exit(void)
-{
- saa7146_unregister_extension(&budget_extension);
-}
-
-module_init(budget_init);
-module_exit(budget_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, Michael Hunold, others");
-MODULE_DESCRIPTION("driver for the SAA7146 based so-called "
- "budget PCI DVB cards by Siemens, Technotrend, Hauppauge");
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
deleted file mode 100644
index e8a5c79178e..00000000000
--- a/drivers/media/dvb/ttpci/budget.h
+++ /dev/null
@@ -1,118 +0,0 @@
-#ifndef __BUDGET_DVB__
-#define __BUDGET_DVB__
-
-#include "dvb_frontend.h"
-#include "dvbdev.h"
-#include "demux.h"
-#include "dvb_demux.h"
-#include "dmxdev.h"
-#include "dvb_filter.h"
-#include "dvb_net.h"
-
-#include <linux/module.h>
-#include <linux/mutex.h>
-
-#include <media/saa7146.h>
-
-extern int budget_debug;
-
-#ifdef dprintk
-#undef dprintk
-#endif
-
-#define dprintk(level,args...) \
- do { if ((budget_debug & level)) { printk("%s: %s(): ", KBUILD_MODNAME, __FUNCTION__); printk(args); } } while (0)
-
-struct budget_info {
- char *name;
- int type;
-};
-
-/* place to store all the necessary device information */
-struct budget {
-
- /* devices */
- struct dvb_device dvb_dev;
- struct dvb_net dvb_net;
-
- struct saa7146_dev *dev;
-
- struct i2c_adapter i2c_adap;
- struct budget_info *card;
-
- unsigned char *grabbing;
- struct saa7146_pgtable pt;
-
- struct tasklet_struct fidb_tasklet;
- struct tasklet_struct vpe_tasklet;
-
- struct dmxdev dmxdev;
- struct dvb_demux demux;
-
- struct dmx_frontend hw_frontend;
- struct dmx_frontend mem_frontend;
-
- int ci_present;
- int video_port;
-
- u32 buffer_width;
- u32 buffer_height;
- u32 buffer_size;
- u32 buffer_warning_threshold;
- u32 buffer_warnings;
- unsigned long buffer_warning_time;
-
- u32 ttbp;
- int feeding;
-
- spinlock_t feedlock;
-
- spinlock_t debilock;
-
- struct dvb_adapter dvb_adapter;
- struct dvb_frontend *dvb_frontend;
- int (*read_fe_status)(struct dvb_frontend *fe, fe_status_t *status);
- int fe_synced;
-
- void *priv;
-};
-
-#define MAKE_BUDGET_INFO(x_var,x_name,x_type) \
-static struct budget_info x_var ## _info = { \
- .name=x_name, \
- .type=x_type }; \
-static struct saa7146_pci_extension_data x_var = { \
- .ext_priv = &x_var ## _info, \
- .ext = &budget_extension };
-
-#define BUDGET_TT 0
-#define BUDGET_TT_HW_DISEQC 1
-#define BUDGET_PATCH 3
-#define BUDGET_FS_ACTIVY 4
-#define BUDGET_CIN1200S 5
-#define BUDGET_CIN1200C 6
-#define BUDGET_CIN1200T 7
-#define BUDGET_KNC1S 8
-#define BUDGET_KNC1C 9
-#define BUDGET_KNC1T 10
-#define BUDGET_KNC1SP 11
-#define BUDGET_KNC1CP 12
-#define BUDGET_KNC1TP 13
-#define BUDGET_TVSTAR 14
-
-#define BUDGET_VIDEO_PORTA 0
-#define BUDGET_VIDEO_PORTB 1
-
-extern int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev,
- struct saa7146_pci_extension_data *info,
- struct module *owner);
-extern void ttpci_budget_init_hooks(struct budget *budget);
-extern int ttpci_budget_deinit(struct budget *budget);
-extern void ttpci_budget_irq10_handler(struct saa7146_dev *dev, u32 * isr);
-extern void ttpci_budget_set_video_port(struct saa7146_dev *dev, int video_port);
-extern int ttpci_budget_debiread(struct budget *budget, u32 config, int addr, int count,
- int uselocks, int nobusyloop);
-extern int ttpci_budget_debiwrite(struct budget *budget, u32 config, int addr, int count, u32 value,
- int uselocks, int nobusyloop);
-
-#endif
diff --git a/drivers/media/dvb/ttpci/fdump.c b/drivers/media/dvb/ttpci/fdump.c
deleted file mode 100644
index c90001d35e7..00000000000
--- a/drivers/media/dvb/ttpci/fdump.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-int main(int argc, char **argv)
-{
- unsigned char buf[8];
- unsigned int i, count, bytes = 0;
- FILE *fd_in, *fd_out;
-
- if (argc != 4) {
- fprintf(stderr, "\n\tusage: %s <ucode.bin> <array_name> <output_name>\n\n", argv[0]);
- return -1;
- }
-
- fd_in = fopen(argv[1], "rb");
- if (fd_in == NULL) {
- fprintf(stderr, "firmware file '%s' not found\n", argv[1]);
- return -1;
- }
-
- fd_out = fopen(argv[3], "w+");
- if (fd_out == NULL) {
- fprintf(stderr, "cannot create output file '%s'\n", argv[3]);
- return -1;
- }
-
- fprintf(fd_out, "\n#include <asm/types.h>\n\nu8 %s [] = {", argv[2]);
-
- while ((count = fread(buf, 1, 8, fd_in)) > 0) {
- fprintf(fd_out, "\n\t");
- for (i = 0; i < count; i++, bytes++)
- fprintf(fd_out, "0x%02x, ", buf[i]);
- }
-
- fprintf(fd_out, "\n};\n\n");
-
- fclose(fd_in);
- fclose(fd_out);
-
- return 0;
-}
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.c b/drivers/media/dvb/ttpci/ttpci-eeprom.c
deleted file mode 100644
index 1f31e91195b..00000000000
--- a/drivers/media/dvb/ttpci/ttpci-eeprom.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- Retrieve encoded MAC address from 24C16 serial 2-wire EEPROM,
- decode it and store it in the associated adapter struct for
- use by dvb_net.c
-
- This card appear to have the 24C16 write protect held to ground,
- thus permitting normal read/write operation. Theoretically it
- would be possible to write routines to burn a different (encoded)
- MAC address into the EEPROM.
-
- Robert Schlabbach GMX
- Michael Glaum KVH Industries
- Holger Waechtler Convergence
-
- Copyright (C) 2002-2003 Ralph Metzler <rjkm@metzlerbros.de>
- Metzler Brothers Systementwicklung GbR
-
- 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 <asm/errno.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/i2c.h>
-
-#include "ttpci-eeprom.h"
-
-#if 1
-#define dprintk(x...) do { printk(x); } while (0)
-#else
-#define dprintk(x...) do { } while (0)
-#endif
-
-
-static int check_mac_tt(u8 *buf)
-{
- int i;
- u16 tmp = 0xffff;
-
- for (i = 0; i < 8; i++) {
- tmp = (tmp << 8) | ((tmp >> 8) ^ buf[i]);
- tmp ^= (tmp >> 4) & 0x0f;
- tmp ^= (tmp << 12) ^ ((tmp & 0xff) << 5);
- }
- tmp ^= 0xffff;
- return (((tmp >> 8) ^ buf[8]) | ((tmp & 0xff) ^ buf[9]));
-}
-
-static int getmac_tt(u8 * decodedMAC, u8 * encodedMAC)
-{
- u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c,
- 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6,
- 0x1d, 0x36, 0x64, 0x78};
- u8 data[20];
- int i;
-
- /* In case there is a sig check failure have the orig contents available */
- memcpy(data, encodedMAC, 20);
-
- for (i = 0; i < 20; i++)
- data[i] ^= xor[i];
- for (i = 0; i < 10; i++)
- data[i] = ((data[2 * i + 1] << 8) | data[2 * i])
- >> ((data[2 * i + 1] >> 6) & 3);
-
- if (check_mac_tt(data))
- return -ENODEV;
-
- decodedMAC[0] = data[2]; decodedMAC[1] = data[1]; decodedMAC[2] = data[0];
- decodedMAC[3] = data[6]; decodedMAC[4] = data[5]; decodedMAC[5] = data[4];
- return 0;
-}
-
-static int ttpci_eeprom_read_encodedMAC(struct i2c_adapter *adapter, u8 * encodedMAC)
-{
- int ret;
- u8 b0[] = { 0xcc };
-
- struct i2c_msg msg[] = {
- { .addr = 0x50, .flags = 0, .buf = b0, .len = 1 },
- { .addr = 0x50, .flags = I2C_M_RD, .buf = encodedMAC, .len = 20 }
- };
-
- /* dprintk("%s\n", __FUNCTION__); */
-
- ret = i2c_transfer(adapter, msg, 2);
-
- if (ret != 2) /* Assume EEPROM isn't there */
- return (-ENODEV);
-
- return 0;
-}
-
-
-int ttpci_eeprom_parse_mac(struct i2c_adapter *adapter, u8 *proposed_mac)
-{
- int ret, i;
- u8 encodedMAC[20];
- u8 decodedMAC[6];
-
- ret = ttpci_eeprom_read_encodedMAC(adapter, encodedMAC);
-
- if (ret != 0) { /* Will only be -ENODEV */
- dprintk("Couldn't read from EEPROM: not there?\n");
- memset(proposed_mac, 0, 6);
- return ret;
- }
-
- ret = getmac_tt(decodedMAC, encodedMAC);
- if( ret != 0 ) {
- dprintk("adapter failed MAC signature check\n");
- dprintk("encoded MAC from EEPROM was " );
- for(i=0; i<19; i++) {
- dprintk( "%.2x:", encodedMAC[i]);
- }
- dprintk("%.2x\n", encodedMAC[19]);
- memset(proposed_mac, 0, 6);
- return ret;
- }
-
- memcpy(proposed_mac, decodedMAC, 6);
- dprintk("adapter has MAC addr = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
- decodedMAC[0], decodedMAC[1], decodedMAC[2],
- decodedMAC[3], decodedMAC[4], decodedMAC[5]);
- return 0;
-}
-
-EXPORT_SYMBOL(ttpci_eeprom_parse_mac);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Ralph Metzler, Marcus Metzler, others");
-MODULE_DESCRIPTION("Decode dvb_net MAC address from EEPROM of PCI DVB cards "
- "made by Siemens, Technotrend, Hauppauge");
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.h b/drivers/media/dvb/ttpci/ttpci-eeprom.h
deleted file mode 100644
index e2dc6cfe205..00000000000
--- a/drivers/media/dvb/ttpci/ttpci-eeprom.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Retrieve encoded MAC address from ATMEL ttpci_eeprom serial 2-wire EEPROM,
- decode it and store it in associated adapter net device
-
- Robert Schlabbach GMX
- Michael Glaum KVH Industries
- Holger Waechtler Convergence
-
- 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.
-
-*/
-
-#ifndef __TTPCI_EEPROM_H__
-#define __TTPCI_EEPROM_H__
-
-#include <linux/types.h>
-#include <linux/i2c.h>
-
-extern int ttpci_eeprom_parse_mac(struct i2c_adapter *adapter, u8 *propsed_mac);
-
-#endif
diff --git a/drivers/media/dvb/ttusb-budget/Kconfig b/drivers/media/dvb/ttusb-budget/Kconfig
deleted file mode 100644
index 46a6a60d2ab..00000000000
--- a/drivers/media/dvb/ttusb-budget/Kconfig
+++ /dev/null
@@ -1,19 +0,0 @@
-config DVB_TTUSB_BUDGET
- tristate "Technotrend/Hauppauge Nova-USB devices"
- depends on DVB_CORE && USB && I2C
- select DVB_PLL
- select DVB_CX22700
- select DVB_TDA1004X
- select DVB_VES1820
- select DVB_TDA8083
- select DVB_STV0299
- select DVB_STV0297
- select DVB_LNBP21
- help
- Support for external USB adapters designed by Technotrend and
- produced by Hauppauge, shipped under the brand name 'Nova-USB'.
-
- These devices don't have a MPEG decoder built in, so you need
- an external software decoder to watch TV.
-
- Say Y if you own such a device and want to use it.
diff --git a/drivers/media/dvb/ttusb-budget/Makefile b/drivers/media/dvb/ttusb-budget/Makefile
deleted file mode 100644
index 6ab97f6b53f..00000000000
--- a/drivers/media/dvb/ttusb-budget/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_DVB_TTUSB_BUDGET) += dvb-ttusb-budget.o
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
deleted file mode 100644
index 04cef302345..00000000000
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ /dev/null
@@ -1,1816 +0,0 @@
-/*
- * TTUSB DVB driver
- *
- * Copyright (c) 2002 Holger Waechtler <holger@convergence.de>
- * Copyright (c) 2003 Felix Domke <tmbinc@elitedvb.net>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- */
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/wait.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/usb.h>
-#include <linux/delay.h>
-#include <linux/time.h>
-#include <linux/errno.h>
-#include <linux/jiffies.h>
-#include <linux/mutex.h>
-
-#include "dvb_frontend.h"
-#include "dmxdev.h"
-#include "dvb_demux.h"
-#include "dvb_net.h"
-#include "ves1820.h"
-#include "cx22700.h"
-#include "tda1004x.h"
-#include "stv0299.h"
-#include "tda8083.h"
-#include "stv0297.h"
-#include "lnbp21.h"
-
-#include <linux/dvb/frontend.h>
-#include <linux/dvb/dmx.h>
-#include <linux/pci.h>
-
-/*
- TTUSB_HWSECTIONS:
- the DSP supports filtering in hardware, however, since the "muxstream"
- is a bit braindead (no matching channel masks or no matching filter mask),
- we won't support this - yet. it doesn't event support negative filters,
- so the best way is maybe to keep TTUSB_HWSECTIONS undef'd and just
- parse TS data. USB bandwidth will be a problem when having large
- datastreams, especially for dvb-net, but hey, that's not my problem.
-
- TTUSB_DISEQC, TTUSB_TONE:
- let the STC do the diseqc/tone stuff. this isn't supported at least with
- my TTUSB, so let it undef'd unless you want to implement another
- frontend. never tested.
-
- DEBUG:
- define it to > 3 for really hardcore debugging. you probably don't want
- this unless the device doesn't load at all. > 2 for bandwidth statistics.
-*/
-
-static int debug;
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
-
-#define dprintk(x...) do { if (debug) printk(KERN_DEBUG x); } while (0)
-
-#define ISO_BUF_COUNT 4
-#define FRAMES_PER_ISO_BUF 4
-#define ISO_FRAME_SIZE 912
-#define TTUSB_MAXCHANNEL 32
-#ifdef TTUSB_HWSECTIONS
-#define TTUSB_MAXFILTER 16 /* ??? */
-#endif
-
-#define TTUSB_REV_2_2 0x22
-#define TTUSB_BUDGET_NAME "ttusb_stc_fw"
-
-/**
- * since we're casting (struct ttusb*) <-> (struct dvb_demux*) around
- * the dvb_demux field must be the first in struct!!
- */
-struct ttusb {
- struct dvb_demux dvb_demux;
- struct dmxdev dmxdev;
- struct dvb_net dvbnet;
-
- /* and one for USB access. */
- struct mutex semi2c;
- struct mutex semusb;
-
- struct dvb_adapter adapter;
- struct usb_device *dev;
-
- struct i2c_adapter i2c_adap;
-
- int disconnecting;
- int iso_streaming;
-
- unsigned int bulk_out_pipe;
- unsigned int bulk_in_pipe;
- unsigned int isoc_in_pipe;
-
- void *iso_buffer;
- dma_addr_t iso_dma_handle;
-
- struct urb *iso_urb[ISO_BUF_COUNT];
-
- int running_feed_count;
- int last_channel;
- int last_filter;
-
- u8 c; /* transaction counter, wraps around... */
- fe_sec_tone_mode_t tone;
- fe_sec_voltage_t voltage;
-
- int mux_state; // 0..2 - MuxSyncWord, 3 - nMuxPacks, 4 - muxpack
- u8 mux_npacks;
- u8 muxpack[256 + 8];
- int muxpack_ptr, muxpack_len;
-
- int insync;
-
- int cc; /* MuxCounter - will increment on EVERY MUX PACKET */
- /* (including stuffing. yes. really.) */
-
- u8 last_result[32];
-
- int revision;
-
- struct dvb_frontend* fe;
-};
-
-/* ugly workaround ... don't know why it's neccessary to read */
-/* all result codes. */
-
-#define DEBUG 0
-static int ttusb_cmd(struct ttusb *ttusb,
- const u8 * data, int len, int needresult)
-{
- int actual_len;
- int err;
-#if DEBUG >= 3
- int i;
-
- printk(">");
- for (i = 0; i < len; ++i)
- printk(" %02x", data[i]);
- printk("\n");
-#endif
-
- if (mutex_lock_interruptible(&ttusb->semusb) < 0)
- return -EAGAIN;
-
- err = usb_bulk_msg(ttusb->dev, ttusb->bulk_out_pipe,
- (u8 *) data, len, &actual_len, 1000);
- if (err != 0) {
- dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n",
- __FUNCTION__, err);
- mutex_unlock(&ttusb->semusb);
- return err;
- }
- if (actual_len != len) {
- dprintk("%s: only wrote %d of %d bytes\n", __FUNCTION__,
- actual_len, len);
- mutex_unlock(&ttusb->semusb);
- return -1;
- }
-
- err = usb_bulk_msg(ttusb->dev, ttusb->bulk_in_pipe,
- ttusb->last_result, 32, &actual_len, 1000);
-
- if (err != 0) {
- printk("%s: failed, receive error %d\n", __FUNCTION__,
- err);
- mutex_unlock(&ttusb->semusb);
- return err;
- }
-#if DEBUG >= 3
- actual_len = ttusb->last_result[3] + 4;
- printk("<");
- for (i = 0; i < actual_len; ++i)
- printk(" %02x", ttusb->last_result[i]);
- printk("\n");
-#endif
- if (!needresult)
- mutex_unlock(&ttusb->semusb);
- return 0;
-}
-
-static int ttusb_result(struct ttusb *ttusb, u8 * data, int len)
-{
- memcpy(data, ttusb->last_result, len);
- mutex_unlock(&ttusb->semusb);
- return 0;
-}
-
-static int ttusb_i2c_msg(struct ttusb *ttusb,
- u8 addr, u8 * snd_buf, u8 snd_len, u8 * rcv_buf,
- u8 rcv_len)
-{
- u8 b[0x28];
- u8 id = ++ttusb->c;
- int i, err;
-
- if (snd_len > 0x28 - 7 || rcv_len > 0x20 - 7)
- return -EINVAL;
-
- b[0] = 0xaa;
- b[1] = id;
- b[2] = 0x31;
- b[3] = snd_len + 3;
- b[4] = addr << 1;
- b[5] = snd_len;
- b[6] = rcv_len;
-
- for (i = 0; i < snd_len; i++)
- b[7 + i] = snd_buf[i];
-
- err = ttusb_cmd(ttusb, b, snd_len + 7, 1);
-
- if (err)
- return -EREMOTEIO;
-
- err = ttusb_result(ttusb, b, 0x20);
-
- /* check if the i2c transaction was successful */
- if ((snd_len != b[5]) || (rcv_len != b[6])) return -EREMOTEIO;
-
- if (rcv_len > 0) {
-
- if (err || b[0] != 0x55 || b[1] != id) {
- dprintk
- ("%s: usb_bulk_msg(recv) failed, err == %i, id == %02x, b == ",
- __FUNCTION__, err, id);
- return -EREMOTEIO;
- }
-
- for (i = 0; i < rcv_len; i++)
- rcv_buf[i] = b[7 + i];
- }
-
- return rcv_len;
-}
-
-static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num)
-{
- struct ttusb *ttusb = i2c_get_adapdata(adapter);
- int i = 0;
- int inc;
-
- if (mutex_lock_interruptible(&ttusb->semi2c) < 0)
- return -EAGAIN;
-
- while (i < num) {
- u8 addr, snd_len, rcv_len, *snd_buf, *rcv_buf;
- int err;
-
- if (num > i + 1 && (msg[i + 1].flags & I2C_M_RD)) {
- addr = msg[i].addr;
- snd_buf = msg[i].buf;
- snd_len = msg[i].len;
- rcv_buf = msg[i + 1].buf;
- rcv_len = msg[i + 1].len;
- inc = 2;
- } else {
- addr = msg[i].addr;
- snd_buf = msg[i].buf;
- snd_len = msg[i].len;
- rcv_buf = NULL;
- rcv_len = 0;
- inc = 1;
- }
-
- err = ttusb_i2c_msg(ttusb, addr,
- snd_buf, snd_len, rcv_buf, rcv_len);
-
- if (err < rcv_len) {
- dprintk("%s: i == %i\n", __FUNCTION__, i);
- break;
- }
-
- i += inc;
- }
-
- mutex_unlock(&ttusb->semi2c);
- return i;
-}
-
-#include "dvb-ttusb-dspbootcode.h"
-
-static int ttusb_boot_dsp(struct ttusb *ttusb)
-{
- int i, err;
- u8 b[40];
-
- /* BootBlock */
- b[0] = 0xaa;
- b[2] = 0x13;
- b[3] = 28;
-
- /* upload dsp code in 32 byte steps (36 didn't work for me ...) */
- /* 32 is max packet size, no messages should be splitted. */
- for (i = 0; i < sizeof(dsp_bootcode); i += 28) {
- memcpy(&b[4], &dsp_bootcode[i], 28);
-
- b[1] = ++ttusb->c;
-
- err = ttusb_cmd(ttusb, b, 32, 0);
- if (err)
- goto done;
- }
-
- /* last block ... */
- b[1] = ++ttusb->c;
- b[2] = 0x13;
- b[3] = 0;
-
- err = ttusb_cmd(ttusb, b, 4, 0);
- if (err)
- goto done;
-
- /* BootEnd */
- b[1] = ++ttusb->c;
- b[2] = 0x14;
- b[3] = 0;
-
- err = ttusb_cmd(ttusb, b, 4, 0);
-
- done:
- if (err) {
- dprintk("%s: usb_bulk_msg() failed, return value %i!\n",
- __FUNCTION__, err);
- }
-
- return err;
-}
-
-static int ttusb_set_channel(struct ttusb *ttusb, int chan_id, int filter_type,
- int pid)
-{
- int err;
- /* SetChannel */
- u8 b[] = { 0xaa, ++ttusb->c, 0x22, 4, chan_id, filter_type,
- (pid >> 8) & 0xff, pid & 0xff
- };
-
- err = ttusb_cmd(ttusb, b, sizeof(b), 0);
- return err;
-}
-
-static int ttusb_del_channel(struct ttusb *ttusb, int channel_id)
-{
- int err;
- /* DelChannel */
- u8 b[] = { 0xaa, ++ttusb->c, 0x23, 1, channel_id };
-
- err = ttusb_cmd(ttusb, b, sizeof(b), 0);
- return err;
-}
-
-#ifdef TTUSB_HWSECTIONS
-static int ttusb_set_filter(struct ttusb *ttusb, int filter_id,
- int associated_chan, u8 filter[8], u8 mask[8])
-{
- int err;
- /* SetFilter */
- u8 b[] = { 0xaa, 0, 0x24, 0x1a, filter_id, associated_chan,
- filter[0], filter[1], filter[2], filter[3],
- filter[4], filter[5], filter[6], filter[7],
- filter[8], filter[9], filter[10], filter[11],
- mask[0], mask[1], mask[2], mask[3],
- mask[4], mask[5], mask[6], mask[7],
- mask[8], mask[9], mask[10], mask[11]
- };
-
- err = ttusb_cmd(ttusb, b, sizeof(b), 0);
- return err;
-}
-
-static int ttusb_del_filter(struct ttusb *ttusb, int filter_id)
-{
- int err;
- /* DelFilter */
- u8 b[] = { 0xaa, ++ttusb->c, 0x25, 1, filter_id };
-
- err = ttusb_cmd(ttusb, b, sizeof(b), 0);
- return err;
-}
-#endif
-
-static int ttusb_init_controller(struct ttusb *ttusb)
-{
- u8 b0[] = { 0xaa, ++ttusb->c, 0x15, 1, 0 };
- u8 b1[] = { 0xaa, ++ttusb->c, 0x15, 1, 1 };
- u8 b2[] = { 0xaa, ++ttusb->c, 0x32, 1, 0 };
- /* i2c write read: 5 bytes, addr 0x10, 0x02 bytes write, 1 bytes read. */
- u8 b3[] =
- { 0xaa, ++ttusb->c, 0x31, 5, 0x10, 0x02, 0x01, 0x00, 0x1e };
- u8 b4[] =
- { 0x55, ttusb->c, 0x31, 4, 0x10, 0x02, 0x01, 0x00, 0x1e };
-
- u8 get_version[] = { 0xaa, ++ttusb->c, 0x17, 5, 0, 0, 0, 0, 0 };
- u8 get_dsp_version[0x20] =
- { 0xaa, ++ttusb->c, 0x26, 28, 0, 0, 0, 0, 0 };
- int err;
-
- /* reset board */
- if ((err = ttusb_cmd(ttusb, b0, sizeof(b0), 0)))
- return err;
-
- /* reset board (again?) */
- if ((err = ttusb_cmd(ttusb, b1, sizeof(b1), 0)))
- return err;
-
- ttusb_boot_dsp(ttusb);
-
- /* set i2c bit rate */
- if ((err = ttusb_cmd(ttusb, b2, sizeof(b2), 0)))
- return err;
-
- if ((err = ttusb_cmd(ttusb, b3, sizeof(b3), 1)))
- return err;
-
- err = ttusb_result(ttusb, b4, sizeof(b4));
-
- if ((err = ttusb_cmd(ttusb, get_version, sizeof(get_version), 1)))
- return err;
-
- if ((err = ttusb_result(ttusb, get_version, sizeof(get_version))))
- return err;
-
- dprintk("%s: stc-version: %c%c%c%c%c\n", __FUNCTION__,
- get_version[4], get_version[5], get_version[6],
- get_version[7], get_version[8]);
-
- if (memcmp(get_version + 4, "V 0.0", 5) &&
- memcmp(get_version + 4, "V 1.1", 5) &&
- memcmp(get_version + 4, "V 2.1", 5) &&
- memcmp(get_version + 4, "V 2.2", 5)) {
- printk
- ("%s: unknown STC version %c%c%c%c%c, please report!\n",
- __FUNCTION__, get_version[4], get_version[5],
- get_version[6], get_version[7], get_version[8]);
- }
-
- ttusb->revision = ((get_version[6] - '0') << 4) |
- (get_version[8] - '0');
-
- err =
- ttusb_cmd(ttusb, get_dsp_version, sizeof(get_dsp_version), 1);
- if (err)
- return err;
-
- err =
- ttusb_result(ttusb, get_dsp_version, sizeof(get_dsp_version));
- if (err)
- return err;
- printk("%s: dsp-version: %c%c%c\n", __FUNCTION__,
- get_dsp_version[4], get_dsp_version[5], get_dsp_version[6]);
- return 0;
-}
-
-#ifdef TTUSB_DISEQC
-static int ttusb_send_diseqc(struct dvb_frontend* fe,
- const struct dvb_diseqc_master_cmd *cmd)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
- u8 b[12] = { 0xaa, ++ttusb->c, 0x18 };
-
- int err;
-
- b[3] = 4 + 2 + cmd->msg_len;
- b[4] = 0xFF; /* send diseqc master, not burst */
- b[5] = cmd->msg_len;
-
- memcpy(b + 5, cmd->msg, cmd->msg_len);
-
- /* Diseqc */
- if ((err = ttusb_cmd(ttusb, b, 4 + b[3], 0))) {
- dprintk("%s: usb_bulk_msg() failed, return value %i!\n",
- __FUNCTION__, err);
- }
-
- return err;
-}
-#endif
-
-static int ttusb_update_lnb(struct ttusb *ttusb)
-{
- u8 b[] = { 0xaa, ++ttusb->c, 0x16, 5, /*power: */ 1,
- ttusb->voltage == SEC_VOLTAGE_18 ? 0 : 1,
- ttusb->tone == SEC_TONE_ON ? 1 : 0, 1, 1
- };
- int err;
-
- /* SetLNB */
- if ((err = ttusb_cmd(ttusb, b, sizeof(b), 0))) {
- dprintk("%s: usb_bulk_msg() failed, return value %i!\n",
- __FUNCTION__, err);
- }
-
- return err;
-}
-
-static int ttusb_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
-
- ttusb->voltage = voltage;
- return ttusb_update_lnb(ttusb);
-}
-
-#ifdef TTUSB_TONE
-static int ttusb_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
-
- ttusb->tone = tone;
- return ttusb_update_lnb(ttusb);
-}
-#endif
-
-
-#if 0
-static void ttusb_set_led_freq(struct ttusb *ttusb, u8 freq)
-{
- u8 b[] = { 0xaa, ++ttusb->c, 0x19, 1, freq };
- int err, actual_len;
-
- err = ttusb_cmd(ttusb, b, sizeof(b), 0);
- if (err) {
- dprintk("%s: usb_bulk_msg() failed, return value %i!\n",
- __FUNCTION__, err);
- }
-}
-#endif
-
-/*****************************************************************************/
-
-#ifdef TTUSB_HWSECTIONS
-static void ttusb_handle_ts_data(struct ttusb_channel *channel,
- const u8 * data, int len);
-static void ttusb_handle_sec_data(struct ttusb_channel *channel,
- const u8 * data, int len);
-#endif
-
-static int numpkt = 0, numts, numstuff, numsec, numinvalid;
-static unsigned long lastj;
-
-static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack,
- int len)
-{
- u16 csum = 0, cc;
- int i;
- for (i = 0; i < len; i += 2)
- csum ^= le16_to_cpup((u16 *) (muxpack + i));
- if (csum) {
- printk("%s: muxpack with incorrect checksum, ignoring\n",
- __FUNCTION__);
- numinvalid++;
- return;
- }
-
- cc = (muxpack[len - 4] << 8) | muxpack[len - 3];
- cc &= 0x7FFF;
- if ((cc != ttusb->cc) && (ttusb->cc != -1))
- printk("%s: cc discontinuity (%d frames missing)\n",
- __FUNCTION__, (cc - ttusb->cc) & 0x7FFF);
- ttusb->cc = (cc + 1) & 0x7FFF;
- if (muxpack[0] & 0x80) {
-#ifdef TTUSB_HWSECTIONS
- /* section data */
- int pusi = muxpack[0] & 0x40;
- int channel = muxpack[0] & 0x1F;
- int payload = muxpack[1];
- const u8 *data = muxpack + 2;
- /* check offset flag */
- if (muxpack[0] & 0x20)
- data++;
-
- ttusb_handle_sec_data(ttusb->channel + channel, data,
- payload);
- data += payload;
-
- if ((!!(ttusb->muxpack[0] & 0x20)) ^
- !!(ttusb->muxpack[1] & 1))
- data++;
-#warning TODO: pusi
- printk("cc: %04x\n", (data[0] << 8) | data[1]);
-#endif
- numsec++;
- } else if (muxpack[0] == 0x47) {
-#ifdef TTUSB_HWSECTIONS
- /* we have TS data here! */
- int pid = ((muxpack[1] & 0x0F) << 8) | muxpack[2];
- int channel;
- for (channel = 0; channel < TTUSB_MAXCHANNEL; ++channel)
- if (ttusb->channel[channel].active
- && (pid == ttusb->channel[channel].pid))
- ttusb_handle_ts_data(ttusb->channel +
- channel, muxpack,
- 188);
-#endif
- numts++;
- dvb_dmx_swfilter_packets(&ttusb->dvb_demux, muxpack, 1);
- } else if (muxpack[0] != 0) {
- numinvalid++;
- printk("illegal muxpack type %02x\n", muxpack[0]);
- } else
- numstuff++;
-}
-
-static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len)
-{
- int maxwork = 1024;
- while (len) {
- if (!(maxwork--)) {
- printk("%s: too much work\n", __FUNCTION__);
- break;
- }
-
- switch (ttusb->mux_state) {
- case 0:
- case 1:
- case 2:
- len--;
- if (*data++ == 0xAA)
- ++ttusb->mux_state;
- else {
- ttusb->mux_state = 0;
-#if DEBUG > 3
- if (ttusb->insync)
- printk("%02x ", data[-1]);
-#else
- if (ttusb->insync) {
- printk("%s: lost sync.\n",
- __FUNCTION__);
- ttusb->insync = 0;
- }
-#endif
- }
- break;
- case 3:
- ttusb->insync = 1;
- len--;
- ttusb->mux_npacks = *data++;
- ++ttusb->mux_state;
- ttusb->muxpack_ptr = 0;
- /* maximum bytes, until we know the length */
- ttusb->muxpack_len = 2;
- break;
- case 4:
- {
- int avail;
- avail = len;
- if (avail >
- (ttusb->muxpack_len -
- ttusb->muxpack_ptr))
- avail =
- ttusb->muxpack_len -
- ttusb->muxpack_ptr;
- memcpy(ttusb->muxpack + ttusb->muxpack_ptr,
- data, avail);
- ttusb->muxpack_ptr += avail;
- BUG_ON(ttusb->muxpack_ptr > 264);
- data += avail;
- len -= avail;
- /* determine length */
- if (ttusb->muxpack_ptr == 2) {
- if (ttusb->muxpack[0] & 0x80) {
- ttusb->muxpack_len =
- ttusb->muxpack[1] + 2;
- if (ttusb->
- muxpack[0] & 0x20)
- ttusb->
- muxpack_len++;
- if ((!!
- (ttusb->
- muxpack[0] & 0x20)) ^
- !!(ttusb->
- muxpack[1] & 1))
- ttusb->
- muxpack_len++;
- ttusb->muxpack_len += 4;
- } else if (ttusb->muxpack[0] ==
- 0x47)
- ttusb->muxpack_len =
- 188 + 4;
- else if (ttusb->muxpack[0] == 0x00)
- ttusb->muxpack_len =
- ttusb->muxpack[1] + 2 +
- 4;
- else {
- dprintk
- ("%s: invalid state: first byte is %x\n",
- __FUNCTION__,
- ttusb->muxpack[0]);
- ttusb->mux_state = 0;
- }
- }
-
- /**
- * if length is valid and we reached the end:
- * goto next muxpack
- */
- if ((ttusb->muxpack_ptr >= 2) &&
- (ttusb->muxpack_ptr ==
- ttusb->muxpack_len)) {
- ttusb_process_muxpack(ttusb,
- ttusb->
- muxpack,
- ttusb->
- muxpack_ptr);
- ttusb->muxpack_ptr = 0;
- /* maximum bytes, until we know the length */
- ttusb->muxpack_len = 2;
-
- /**
- * no muxpacks left?
- * return to search-sync state
- */
- if (!ttusb->mux_npacks--) {
- ttusb->mux_state = 0;
- break;
- }
- }
- break;
- }
- default:
- BUG();
- break;
- }
- }
-}
-
-static void ttusb_iso_irq(struct urb *urb, struct pt_regs *ptregs)
-{
- struct ttusb *ttusb = urb->context;
-
- if (!ttusb->iso_streaming)
- return;
-
-#if 0
- printk("%s: status %d, errcount == %d, length == %i\n",
- __FUNCTION__,
- urb->status, urb->error_count, urb->actual_length);
-#endif
-
- if (!urb->status) {
- int i;
- for (i = 0; i < urb->number_of_packets; ++i) {
- struct usb_iso_packet_descriptor *d;
- u8 *data;
- int len;
- numpkt++;
- if (time_after_eq(jiffies, lastj + HZ)) {
-#if DEBUG > 2
- printk
- ("frames/s: %d (ts: %d, stuff %d, sec: %d, invalid: %d, all: %d)\n",
- numpkt * HZ / (jiffies - lastj),
- numts, numstuff, numsec, numinvalid,
- numts + numstuff + numsec +
- numinvalid);
-#endif
- numts = numstuff = numsec = numinvalid = 0;
- lastj = jiffies;
- numpkt = 0;
- }
- d = &urb->iso_frame_desc[i];
- data = urb->transfer_buffer + d->offset;
- len = d->actual_length;
- d->actual_length = 0;
- d->status = 0;
- ttusb_process_frame(ttusb, data, len);
- }
- }
- usb_submit_urb(urb, GFP_ATOMIC);
-}
-
-static void ttusb_free_iso_urbs(struct ttusb *ttusb)
-{
- int i;
-
- for (i = 0; i < ISO_BUF_COUNT; i++)
- if (ttusb->iso_urb[i])
- usb_free_urb(ttusb->iso_urb[i]);
-
- pci_free_consistent(NULL,
- ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF *
- ISO_BUF_COUNT, ttusb->iso_buffer,
- ttusb->iso_dma_handle);
-}
-
-static int ttusb_alloc_iso_urbs(struct ttusb *ttusb)
-{
- int i;
-
- ttusb->iso_buffer = pci_alloc_consistent(NULL,
- ISO_FRAME_SIZE *
- FRAMES_PER_ISO_BUF *
- ISO_BUF_COUNT,
- &ttusb->iso_dma_handle);
-
- memset(ttusb->iso_buffer, 0,
- ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF * ISO_BUF_COUNT);
-
- for (i = 0; i < ISO_BUF_COUNT; i++) {
- struct urb *urb;
-
- if (!
- (urb =
- usb_alloc_urb(FRAMES_PER_ISO_BUF, GFP_ATOMIC))) {
- ttusb_free_iso_urbs(ttusb);
- return -ENOMEM;
- }
-
- ttusb->iso_urb[i] = urb;
- }
-
- return 0;
-}
-
-static void ttusb_stop_iso_xfer(struct ttusb *ttusb)
-{
- int i;
-
- for (i = 0; i < ISO_BUF_COUNT; i++)
- usb_kill_urb(ttusb->iso_urb[i]);
-
- ttusb->iso_streaming = 0;
-}
-
-static int ttusb_start_iso_xfer(struct ttusb *ttusb)
-{
- int i, j, err, buffer_offset = 0;
-
- if (ttusb->iso_streaming) {
- printk("%s: iso xfer already running!\n", __FUNCTION__);
- return 0;
- }
-
- ttusb->cc = -1;
- ttusb->insync = 0;
- ttusb->mux_state = 0;
-
- for (i = 0; i < ISO_BUF_COUNT; i++) {
- int frame_offset = 0;
- struct urb *urb = ttusb->iso_urb[i];
-
- urb->dev = ttusb->dev;
- urb->context = ttusb;
- urb->complete = ttusb_iso_irq;
- urb->pipe = ttusb->isoc_in_pipe;
- urb->transfer_flags = URB_ISO_ASAP;
- urb->interval = 1;
- urb->number_of_packets = FRAMES_PER_ISO_BUF;
- urb->transfer_buffer_length =
- ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF;
- urb->transfer_buffer = ttusb->iso_buffer + buffer_offset;
- buffer_offset += ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF;
-
- for (j = 0; j < FRAMES_PER_ISO_BUF; j++) {
- urb->iso_frame_desc[j].offset = frame_offset;
- urb->iso_frame_desc[j].length = ISO_FRAME_SIZE;
- frame_offset += ISO_FRAME_SIZE;
- }
- }
-
- for (i = 0; i < ISO_BUF_COUNT; i++) {
- if ((err = usb_submit_urb(ttusb->iso_urb[i], GFP_ATOMIC))) {
- ttusb_stop_iso_xfer(ttusb);
- printk
- ("%s: failed urb submission (%i: err = %i)!\n",
- __FUNCTION__, i, err);
- return err;
- }
- }
-
- ttusb->iso_streaming = 1;
-
- return 0;
-}
-
-#ifdef TTUSB_HWSECTIONS
-static void ttusb_handle_ts_data(struct dvb_demux_feed *dvbdmxfeed, const u8 * data,
- int len)
-{
- dvbdmxfeed->cb.ts(data, len, 0, 0, &dvbdmxfeed->feed.ts, 0);
-}
-
-static void ttusb_handle_sec_data(struct dvb_demux_feed *dvbdmxfeed, const u8 * data,
- int len)
-{
-// struct dvb_demux_feed *dvbdmxfeed = channel->dvbdmxfeed;
-#error TODO: handle ugly stuff
-// dvbdmxfeed->cb.sec(data, len, 0, 0, &dvbdmxfeed->feed.sec, 0);
-}
-#endif
-
-static int ttusb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct ttusb *ttusb = (struct ttusb *) dvbdmxfeed->demux;
- int feed_type = 1;
-
- dprintk("ttusb_start_feed\n");
-
- switch (dvbdmxfeed->type) {
- case DMX_TYPE_TS:
- break;
- case DMX_TYPE_SEC:
- break;
- default:
- return -EINVAL;
- }
-
- if (dvbdmxfeed->type == DMX_TYPE_TS) {
- switch (dvbdmxfeed->pes_type) {
- case DMX_TS_PES_VIDEO:
- case DMX_TS_PES_AUDIO:
- case DMX_TS_PES_TELETEXT:
- case DMX_TS_PES_PCR:
- case DMX_TS_PES_OTHER:
- break;
- default:
- return -EINVAL;
- }
- }
-
-#ifdef TTUSB_HWSECTIONS
-#error TODO: allocate filters
- if (dvbdmxfeed->type == DMX_TYPE_TS) {
- feed_type = 1;
- } else if (dvbdmxfeed->type == DMX_TYPE_SEC) {
- feed_type = 2;
- }
-#endif
-
- ttusb_set_channel(ttusb, dvbdmxfeed->index, feed_type, dvbdmxfeed->pid);
-
- if (0 == ttusb->running_feed_count++)
- ttusb_start_iso_xfer(ttusb);
-
- return 0;
-}
-
-static int ttusb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct ttusb *ttusb = (struct ttusb *) dvbdmxfeed->demux;
-
- ttusb_del_channel(ttusb, dvbdmxfeed->index);
-
- if (--ttusb->running_feed_count == 0)
- ttusb_stop_iso_xfer(ttusb);
-
- return 0;
-}
-
-static int ttusb_setup_interfaces(struct ttusb *ttusb)
-{
- usb_set_interface(ttusb->dev, 1, 1);
-
- ttusb->bulk_out_pipe = usb_sndbulkpipe(ttusb->dev, 1);
- ttusb->bulk_in_pipe = usb_rcvbulkpipe(ttusb->dev, 1);
- ttusb->isoc_in_pipe = usb_rcvisocpipe(ttusb->dev, 2);
-
- return 0;
-}
-
-#if 0
-static u8 stc_firmware[8192];
-
-static int stc_open(struct inode *inode, struct file *file)
-{
- struct ttusb *ttusb = file->private_data;
- int addr;
-
- for (addr = 0; addr < 8192; addr += 16) {
- u8 snd_buf[2] = { addr >> 8, addr & 0xFF };
- ttusb_i2c_msg(ttusb, 0x50, snd_buf, 2, stc_firmware + addr,
- 16);
- }
-
- return 0;
-}
-
-static ssize_t stc_read(struct file *file, char *buf, size_t count,
- loff_t * offset)
-{
- int tc = count;
-
- if ((tc + *offset) > 8192)
- tc = 8192 - *offset;
-
- if (tc < 0)
- return 0;
-
- if (copy_to_user(buf, stc_firmware + *offset, tc))
- return -EFAULT;
-
- *offset += tc;
-
- return tc;
-}
-
-static int stc_release(struct inode *inode, struct file *file)
-{
- return 0;
-}
-
-static struct file_operations stc_fops = {
- .owner = THIS_MODULE,
- .read = stc_read,
- .open = stc_open,
- .release = stc_release,
-};
-#endif
-
-static u32 functionality(struct i2c_adapter *adapter)
-{
- return I2C_FUNC_I2C;
-}
-
-
-
-static int alps_tdmb7_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
- u8 data[4];
- struct i2c_msg msg = {.addr=0x61, .flags=0, .buf=data, .len=sizeof(data) };
- u32 div;
-
- div = (params->frequency + 36166667) / 166667;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = ((div >> 10) & 0x60) | 0x85;
- data[3] = params->frequency < 592000000 ? 0x40 : 0x80;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1) return -EIO;
- return 0;
-}
-
-static struct cx22700_config alps_tdmb7_config = {
- .demod_address = 0x43,
-};
-
-
-
-
-
-static int philips_tdm1316l_tuner_init(struct dvb_frontend* fe)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
- static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
- static u8 disable_mc44BC374c[] = { 0x1d, 0x74, 0xa0, 0x68 };
- struct i2c_msg tuner_msg = { .addr=0x60, .flags=0, .buf=td1316_init, .len=sizeof(td1316_init) };
-
- // setup PLL configuration
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) return -EIO;
- msleep(1);
-
- // disable the mc44BC374c (do not check for errors)
- tuner_msg.addr = 0x65;
- tuner_msg.buf = disable_mc44BC374c;
- tuner_msg.len = sizeof(disable_mc44BC374c);
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
- i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1);
- }
-
- return 0;
-}
-
-static int philips_tdm1316l_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
- u8 tuner_buf[4];
- struct i2c_msg tuner_msg = {.addr=0x60, .flags=0, .buf=tuner_buf, .len=sizeof(tuner_buf) };
- int tuner_frequency = 0;
- u8 band, cp, filter;
-
- // determine charge pump
- tuner_frequency = params->frequency + 36130000;
- if (tuner_frequency < 87000000) return -EINVAL;
- else if (tuner_frequency < 130000000) cp = 3;
- else if (tuner_frequency < 160000000) cp = 5;
- else if (tuner_frequency < 200000000) cp = 6;
- else if (tuner_frequency < 290000000) cp = 3;
- else if (tuner_frequency < 420000000) cp = 5;
- else if (tuner_frequency < 480000000) cp = 6;
- else if (tuner_frequency < 620000000) cp = 3;
- else if (tuner_frequency < 830000000) cp = 5;
- else if (tuner_frequency < 895000000) cp = 7;
- else return -EINVAL;
-
- // determine band
- if (params->frequency < 49000000) return -EINVAL;
- else if (params->frequency < 159000000) band = 1;
- else if (params->frequency < 444000000) band = 2;
- else if (params->frequency < 861000000) band = 4;
- else return -EINVAL;
-
- // setup PLL filter
- switch (params->u.ofdm.bandwidth) {
- case BANDWIDTH_6_MHZ:
- tda1004x_write_byte(fe, 0x0C, 0);
- filter = 0;
- break;
-
- case BANDWIDTH_7_MHZ:
- tda1004x_write_byte(fe, 0x0C, 0);
- filter = 0;
- break;
-
- case BANDWIDTH_8_MHZ:
- tda1004x_write_byte(fe, 0x0C, 0xFF);
- filter = 1;
- break;
-
- default:
- return -EINVAL;
- }
-
- // calculate divisor
- // ((36130000+((1000000/6)/2)) + Finput)/(1000000/6)
- tuner_frequency = (((params->frequency / 1000) * 6) + 217280) / 1000;
-
- // setup tuner buffer
- tuner_buf[0] = tuner_frequency >> 8;
- tuner_buf[1] = tuner_frequency & 0xff;
- tuner_buf[2] = 0xca;
- tuner_buf[3] = (cp << 5) | (filter << 3) | band;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1)
- return -EIO;
-
- msleep(1);
- return 0;
-}
-
-static int philips_tdm1316l_request_firmware(struct dvb_frontend* fe, const struct firmware **fw, char* name)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
-
- return request_firmware(fw, name, &ttusb->dev->dev);
-}
-
-static struct tda1004x_config philips_tdm1316l_config = {
-
- .demod_address = 0x8,
- .invert = 1,
- .invert_oclk = 0,
- .request_firmware = philips_tdm1316l_request_firmware,
-};
-
-static u8 alps_bsbe1_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- 0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
- 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
- 0x09, 0x00, /* FIFO */
- 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
- 0x10, 0x3f, // AGC2 0x3d
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9, // lock detector threshold
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
- 0x29, 0x1e, // 1/2 threshold
- 0x2a, 0x14, // 2/3 threshold
- 0x2b, 0x0f, // 3/4 threshold
- 0x2c, 0x09, // 5/6 threshold
- 0x2d, 0x05, // 7/8 threshold
- 0x2e, 0x01,
- 0x31, 0x1f, // test all FECs
- 0x32, 0x19, // viterbi and synchro search
- 0x33, 0xfc, // rs control
- 0x34, 0x93, // error control
- 0x0f, 0x92,
- 0xff, 0xff
-};
-
-static u8 alps_bsru6_inittab[] = {
- 0x01, 0x15,
- 0x02, 0x30,
- 0x03, 0x00,
- 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
- 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
- 0x06, 0x40, /* DAC not used, set to high impendance mode */
- 0x07, 0x00, /* DAC LSB */
- 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
- 0x09, 0x00, /* FIFO */
- 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
- 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
- 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
- 0x10, 0x3f, // AGC2 0x3d
- 0x11, 0x84,
- 0x12, 0xb9,
- 0x15, 0xc9, // lock detector threshold
- 0x16, 0x00,
- 0x17, 0x00,
- 0x18, 0x00,
- 0x19, 0x00,
- 0x1a, 0x00,
- 0x1f, 0x50,
- 0x20, 0x00,
- 0x21, 0x00,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
- 0x29, 0x1e, // 1/2 threshold
- 0x2a, 0x14, // 2/3 threshold
- 0x2b, 0x0f, // 3/4 threshold
- 0x2c, 0x09, // 5/6 threshold
- 0x2d, 0x05, // 7/8 threshold
- 0x2e, 0x01,
- 0x31, 0x1f, // test all FECs
- 0x32, 0x19, // viterbi and synchro search
- 0x33, 0xfc, // rs control
- 0x34, 0x93, // error control
- 0x0f, 0x52,
- 0xff, 0xff
-};
-
-static int alps_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)
-{
- u8 aclk = 0;
- u8 bclk = 0;
-
- if (srate < 1500000) {
- aclk = 0xb7;
- bclk = 0x47;
- } else if (srate < 3000000) {
- aclk = 0xb7;
- bclk = 0x4b;
- } else if (srate < 7000000) {
- aclk = 0xb7;
- bclk = 0x4f;
- } else if (srate < 14000000) {
- aclk = 0xb7;
- bclk = 0x53;
- } else if (srate < 30000000) {
- aclk = 0xb6;
- bclk = 0x53;
- } else if (srate < 45000000) {
- aclk = 0xb4;
- bclk = 0x51;
- }
-
- stv0299_writereg(fe, 0x13, aclk);
- stv0299_writereg(fe, 0x14, bclk);
- stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
- stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
- stv0299_writereg(fe, 0x21, (ratio) & 0xf0);
-
- return 0;
-}
-
-static int philips_tsa5059_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
- u8 buf[4];
- u32 div;
- struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
-
- if ((params->frequency < 950000) || (params->frequency > 2150000))
- return -EINVAL;
-
- div = (params->frequency + (125 - 1)) / 125; // round correctly
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
- buf[3] = 0xC4;
-
- if (params->frequency > 1530000)
- buf[3] = 0xC0;
-
- /* BSBE1 wants XCE bit set */
- if (ttusb->revision == TTUSB_REV_2_2)
- buf[3] |= 0x20;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1)
- return -EIO;
-
- return 0;
-}
-
-static struct stv0299_config alps_stv0299_config = {
- .demod_address = 0x68,
- .inittab = alps_bsru6_inittab,
- .mclk = 88000000UL,
- .invert = 1,
- .skip_reinit = 0,
- .lock_output = STV0229_LOCKOUTPUT_1,
- .volt13_op0_op1 = STV0299_VOLT13_OP1,
- .min_delay_ms = 100,
- .set_symbol_rate = alps_stv0299_set_symbol_rate,
-};
-
-static int ttusb_novas_grundig_29504_491_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
- u8 buf[4];
- u32 div;
- struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
-
- div = params->frequency / 125;
-
- buf[0] = (div >> 8) & 0x7f;
- buf[1] = div & 0xff;
- buf[2] = 0x8e;
- buf[3] = 0x00;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &msg, 1) != 1)
- return -EIO;
-
- return 0;
-}
-
-static struct tda8083_config ttusb_novas_grundig_29504_491_config = {
-
- .demod_address = 0x68,
-};
-
-static int alps_tdbe2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
-{
- struct ttusb* ttusb = fe->dvb->priv;
- u32 div;
- u8 data[4];
- struct i2c_msg msg = { .addr = 0x62, .flags = 0, .buf = data, .len = sizeof(data) };
-
- div = (params->frequency + 35937500 + 31250) / 62500;
-
- data[0] = (div >> 8) & 0x7f;
- data[1] = div & 0xff;
- data[2] = 0x85 | ((div >> 10) & 0x60);
- data[3] = (params->frequency < 174000000 ? 0x88 : params->frequency < 470000000 ? 0x84 : 0x81);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer (&ttusb->i2c_adap, &msg, 1) != 1)
- return -EIO;
-
- return 0;
-}
-
-
-static struct ves1820_config alps_tdbe2_config = {
- .demod_address = 0x09,
- .xin = 57840000UL,
- .invert = 1,
- .selagc = VES1820_SELAGC_SIGNAMPERR,
-};
-
-static u8 read_pwm(struct ttusb* ttusb)
-{
- u8 b = 0xff;
- u8 pwm;
- struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
- { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
-
- if ((i2c_transfer(&ttusb->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
- pwm = 0x48;
-
- return pwm;
-}
-
-
-static int dvbc_philips_tdm1316l_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
-{
- struct ttusb *ttusb = (struct ttusb *) fe->dvb->priv;
- u8 tuner_buf[5];
- struct i2c_msg tuner_msg = {.addr = 0x60,
- .flags = 0,
- .buf = tuner_buf,
- .len = sizeof(tuner_buf) };
- int tuner_frequency = 0;
- u8 band, cp, filter;
-
- // determine charge pump
- tuner_frequency = params->frequency;
- if (tuner_frequency < 87000000) {return -EINVAL;}
- else if (tuner_frequency < 130000000) {cp = 3; band = 1;}
- else if (tuner_frequency < 160000000) {cp = 5; band = 1;}
- else if (tuner_frequency < 200000000) {cp = 6; band = 1;}
- else if (tuner_frequency < 290000000) {cp = 3; band = 2;}
- else if (tuner_frequency < 420000000) {cp = 5; band = 2;}
- else if (tuner_frequency < 480000000) {cp = 6; band = 2;}
- else if (tuner_frequency < 620000000) {cp = 3; band = 4;}
- else if (tuner_frequency < 830000000) {cp = 5; band = 4;}
- else if (tuner_frequency < 895000000) {cp = 7; band = 4;}
- else {return -EINVAL;}
-
- // assume PLL filter should always be 8MHz for the moment.
- filter = 1;
-
- // calculate divisor
- // (Finput + Fif)/Fref; Fif = 36125000 Hz, Fref = 62500 Hz
- tuner_frequency = ((params->frequency + 36125000) / 62500);
-
- // setup tuner buffer
- tuner_buf[0] = tuner_frequency >> 8;
- tuner_buf[1] = tuner_frequency & 0xff;
- tuner_buf[2] = 0xc8;
- tuner_buf[3] = (cp << 5) | (filter << 3) | band;
- tuner_buf[4] = 0x80;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
- printk("dvb-ttusb-budget: dvbc_philips_tdm1316l_pll_set Error 1\n");
- return -EIO;
- }
-
- msleep(50);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
- if (i2c_transfer(&ttusb->i2c_adap, &tuner_msg, 1) != 1) {
- printk("dvb-ttusb-budget: dvbc_philips_tdm1316l_pll_set Error 2\n");
- return -EIO;
- }
-
- msleep(1);
-
- return 0;
-}
-
-static u8 dvbc_philips_tdm1316l_inittab[] = {
- 0x80, 0x21,
- 0x80, 0x20,
- 0x81, 0x01,
- 0x81, 0x00,
- 0x00, 0x09,
- 0x01, 0x69,
- 0x03, 0x00,
- 0x04, 0x00,
- 0x07, 0x00,
- 0x08, 0x00,
- 0x20, 0x00,
- 0x21, 0x40,
- 0x22, 0x00,
- 0x23, 0x00,
- 0x24, 0x40,
- 0x25, 0x88,
- 0x30, 0xff,
- 0x31, 0x00,
- 0x32, 0xff,
- 0x33, 0x00,
- 0x34, 0x50,
- 0x35, 0x7f,
- 0x36, 0x00,
- 0x37, 0x20,
- 0x38, 0x00,
- 0x40, 0x1c,
- 0x41, 0xff,
- 0x42, 0x29,
- 0x43, 0x20,
- 0x44, 0xff,
- 0x45, 0x00,
- 0x46, 0x00,
- 0x49, 0x04,
- 0x4a, 0xff,
- 0x4b, 0x7f,
- 0x52, 0x30,
- 0x55, 0xae,
- 0x56, 0x47,
- 0x57, 0xe1,
- 0x58, 0x3a,
- 0x5a, 0x1e,
- 0x5b, 0x34,
- 0x60, 0x00,
- 0x63, 0x00,
- 0x64, 0x00,
- 0x65, 0x00,
- 0x66, 0x00,
- 0x67, 0x00,
- 0x68, 0x00,
- 0x69, 0x00,
- 0x6a, 0x02,
- 0x6b, 0x00,
- 0x70, 0xff,
- 0x71, 0x00,
- 0x72, 0x00,
- 0x73, 0x00,
- 0x74, 0x0c,
- 0x80, 0x00,
- 0x81, 0x00,
- 0x82, 0x00,
- 0x83, 0x00,
- 0x84, 0x04,
- 0x85, 0x80,
- 0x86, 0x24,
- 0x87, 0x78,
- 0x88, 0x00,
- 0x89, 0x00,
- 0x90, 0x01,
- 0x91, 0x01,
- 0xa0, 0x00,
- 0xa1, 0x00,
- 0xa2, 0x00,
- 0xb0, 0x91,
- 0xb1, 0x0b,
- 0xc0, 0x4b,
- 0xc1, 0x00,
- 0xc2, 0x00,
- 0xd0, 0x00,
- 0xd1, 0x00,
- 0xd2, 0x00,
- 0xd3, 0x00,
- 0xd4, 0x00,
- 0xd5, 0x00,
- 0xde, 0x00,
- 0xdf, 0x00,
- 0x61, 0x38,
- 0x62, 0x0a,
- 0x53, 0x13,
- 0x59, 0x08,
- 0x55, 0x00,
- 0x56, 0x40,
- 0x57, 0x08,
- 0x58, 0x3d,
- 0x88, 0x10,
- 0xa0, 0x00,
- 0xa0, 0x00,
- 0xa0, 0x00,
- 0xa0, 0x04,
- 0xff, 0xff,
-};
-
-static struct stv0297_config dvbc_philips_tdm1316l_config = {
- .demod_address = 0x1c,
- .inittab = dvbc_philips_tdm1316l_inittab,
- .invert = 0,
-};
-
-static void frontend_init(struct ttusb* ttusb)
-{
- switch(le16_to_cpu(ttusb->dev->descriptor.idProduct)) {
- case 0x1003: // Hauppauge/TT Nova-USB-S budget (stv0299/ALPS BSRU6|BSBE1(tsa5059))
- // try the stv0299 based first
- ttusb->fe = stv0299_attach(&alps_stv0299_config, &ttusb->i2c_adap);
- if (ttusb->fe != NULL) {
- ttusb->fe->ops.tuner_ops.set_params = philips_tsa5059_tuner_set_params;
-
- if(ttusb->revision == TTUSB_REV_2_2) { // ALPS BSBE1
- alps_stv0299_config.inittab = alps_bsbe1_inittab;
- lnbp21_attach(ttusb->fe, &ttusb->i2c_adap, 0, 0);
- } else { // ALPS BSRU6
- ttusb->fe->ops.set_voltage = ttusb_set_voltage;
- }
- break;
- }
-
- // Grundig 29504-491
- ttusb->fe = tda8083_attach(&ttusb_novas_grundig_29504_491_config, &ttusb->i2c_adap);
- if (ttusb->fe != NULL) {
- ttusb->fe->ops.tuner_ops.set_params = ttusb_novas_grundig_29504_491_tuner_set_params;
- ttusb->fe->ops.set_voltage = ttusb_set_voltage;
- break;
- }
- break;
-
- case 0x1004: // Hauppauge/TT DVB-C budget (ves1820/ALPS TDBE2(sp5659))
- ttusb->fe = ves1820_attach(&alps_tdbe2_config, &ttusb->i2c_adap, read_pwm(ttusb));
- if (ttusb->fe != NULL) {
- ttusb->fe->ops.tuner_ops.set_params = alps_tdbe2_tuner_set_params;
- break;
- }
-
- ttusb->fe = stv0297_attach(&dvbc_philips_tdm1316l_config, &ttusb->i2c_adap);
- if (ttusb->fe != NULL) {
- ttusb->fe->ops.tuner_ops.set_params = dvbc_philips_tdm1316l_tuner_set_params;
- break;
- }
- break;
-
- case 0x1005: // Hauppauge/TT Nova-USB-t budget (tda10046/Philips td1316(tda6651tt) OR cx22700/ALPS TDMB7(??))
- // try the ALPS TDMB7 first
- ttusb->fe = cx22700_attach(&alps_tdmb7_config, &ttusb->i2c_adap);
- if (ttusb->fe != NULL) {
- ttusb->fe->ops.tuner_ops.set_params = alps_tdmb7_tuner_set_params;
- break;
- }
-
- // Philips td1316
- ttusb->fe = tda10046_attach(&philips_tdm1316l_config, &ttusb->i2c_adap);
- if (ttusb->fe != NULL) {
- ttusb->fe->ops.tuner_ops.init = philips_tdm1316l_tuner_init;
- ttusb->fe->ops.tuner_ops.set_params = philips_tdm1316l_tuner_set_params;
- break;
- }
- break;
- }
-
- if (ttusb->fe == NULL) {
- printk("dvb-ttusb-budget: A frontend driver was not found for device %04x/%04x\n",
- le16_to_cpu(ttusb->dev->descriptor.idVendor),
- le16_to_cpu(ttusb->dev->descriptor.idProduct));
- } else {
- if (dvb_register_frontend(&ttusb->adapter, ttusb->fe)) {
- printk("dvb-ttusb-budget: Frontend registration failed!\n");
- if (ttusb->fe->ops.release)
- ttusb->fe->ops.release(ttusb->fe);
- ttusb->fe = NULL;
- }
- }
-}
-
-
-
-static struct i2c_algorithm ttusb_dec_algo = {
- .master_xfer = master_xfer,
- .functionality = functionality,
-};
-
-static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *id)
-{
- struct usb_device *udev;
- struct ttusb *ttusb;
- int result;
-
- dprintk("%s: TTUSB DVB connected\n", __FUNCTION__);
-
- udev = interface_to_usbdev(intf);
-
- if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV;
-
- if (!(ttusb = kzalloc(sizeof(struct ttusb), GFP_KERNEL)))
- return -ENOMEM;
-
- ttusb->dev = udev;
- ttusb->c = 0;
- ttusb->mux_state = 0;
- mutex_init(&ttusb->semi2c);
-
- mutex_lock(&ttusb->semi2c);
-
- mutex_init(&ttusb->semusb);
-
- ttusb_setup_interfaces(ttusb);
-
- ttusb_alloc_iso_urbs(ttusb);
- if (ttusb_init_controller(ttusb))
- printk("ttusb_init_controller: error\n");
-
- mutex_unlock(&ttusb->semi2c);
-
- if ((result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE, &udev->dev)) < 0) {
- ttusb_free_iso_urbs(ttusb);
- kfree(ttusb);
- return result;
- }
- ttusb->adapter.priv = ttusb;
-
- /* i2c */
- memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter));
- strcpy(ttusb->i2c_adap.name, "TTUSB DEC");
-
- i2c_set_adapdata(&ttusb->i2c_adap, ttusb);
-
-#ifdef I2C_ADAP_CLASS_TV_DIGITAL
- ttusb->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
-#else
- ttusb->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
-#endif
- ttusb->i2c_adap.algo = &ttusb_dec_algo;
- ttusb->i2c_adap.algo_data = NULL;
-
- result = i2c_add_adapter(&ttusb->i2c_adap);
- if (result) {
- dvb_unregister_adapter (&ttusb->adapter);
- return result;
- }
-
- memset(&ttusb->dvb_demux, 0, sizeof(ttusb->dvb_demux));
-
- ttusb->dvb_demux.dmx.capabilities =
- DMX_TS_FILTERING | DMX_SECTION_FILTERING;
- ttusb->dvb_demux.priv = NULL;
-#ifdef TTUSB_HWSECTIONS
- ttusb->dvb_demux.filternum = TTUSB_MAXFILTER;
-#else
- ttusb->dvb_demux.filternum = 32;
-#endif
- ttusb->dvb_demux.feednum = TTUSB_MAXCHANNEL;
- ttusb->dvb_demux.start_feed = ttusb_start_feed;
- ttusb->dvb_demux.stop_feed = ttusb_stop_feed;
- ttusb->dvb_demux.write_to_decoder = NULL;
-
- if ((result = dvb_dmx_init(&ttusb->dvb_demux)) < 0) {
- printk("ttusb_dvb: dvb_dmx_init failed (errno = %d)\n", result);
- i2c_del_adapter(&ttusb->i2c_adap);
- dvb_unregister_adapter (&ttusb->adapter);
- return -ENODEV;
- }
-//FIXME dmxdev (nur WAS?)
- ttusb->dmxdev.filternum = ttusb->dvb_demux.filternum;
- ttusb->dmxdev.demux = &ttusb->dvb_demux.dmx;
- ttusb->dmxdev.capabilities = 0;
-
- if ((result = dvb_dmxdev_init(&ttusb->dmxdev, &ttusb->adapter)) < 0) {
- printk("ttusb_dvb: dvb_dmxdev_init failed (errno = %d)\n",
- result);
- dvb_dmx_release(&ttusb->dvb_demux);
- i2c_del_adapter(&ttusb->i2c_adap);
- dvb_unregister_adapter (&ttusb->adapter);
- return -ENODEV;
- }
-
- if (dvb_net_init(&ttusb->adapter, &ttusb->dvbnet, &ttusb->dvb_demux.dmx)) {
- printk("ttusb_dvb: dvb_net_init failed!\n");
- dvb_dmxdev_release(&ttusb->dmxdev);
- dvb_dmx_release(&ttusb->dvb_demux);
- i2c_del_adapter(&ttusb->i2c_adap);
- dvb_unregister_adapter (&ttusb->adapter);
- return -ENODEV;
- }
-
- usb_set_intfdata(intf, (void *) ttusb);
-
- frontend_init(ttusb);
-
- return 0;
-}
-
-static void ttusb_disconnect(struct usb_interface *intf)
-{
- struct ttusb *ttusb = usb_get_intfdata(intf);
-
- usb_set_intfdata(intf, NULL);
-
- ttusb->disconnecting = 1;
-
- ttusb_stop_iso_xfer(ttusb);
-
- ttusb->dvb_demux.dmx.close(&ttusb->dvb_demux.dmx);
- dvb_net_release(&ttusb->dvbnet);
- dvb_dmxdev_release(&ttusb->dmxdev);
- dvb_dmx_release(&ttusb->dvb_demux);
- if (ttusb->fe != NULL) dvb_unregister_frontend(ttusb->fe);
- i2c_del_adapter(&ttusb->i2c_adap);
- dvb_unregister_adapter(&ttusb->adapter);
-
- ttusb_free_iso_urbs(ttusb);
-
- kfree(ttusb);
-
- dprintk("%s: TTUSB DVB disconnected\n", __FUNCTION__);
-}
-
-static struct usb_device_id ttusb_table[] = {
- {USB_DEVICE(0xb48, 0x1003)},
- {USB_DEVICE(0xb48, 0x1004)},
- {USB_DEVICE(0xb48, 0x1005)},
- {}
-};
-
-MODULE_DEVICE_TABLE(usb, ttusb_table);
-
-static struct usb_driver ttusb_driver = {
- .name = "ttusb",
- .probe = ttusb_probe,
- .disconnect = ttusb_disconnect,
- .id_table = ttusb_table,
-};
-
-static int __init ttusb_init(void)
-{
- int err;
-
- if ((err = usb_register(&ttusb_driver)) < 0) {
- printk("%s: usb_register failed! Error number %d",
- __FILE__, err);
- return err;
- }
-
- return 0;
-}
-
-static void __exit ttusb_exit(void)
-{
- usb_deregister(&ttusb_driver);
-}
-
-module_init(ttusb_init);
-module_exit(ttusb_exit);
-
-MODULE_AUTHOR("Holger Waechtler <holger@convergence.de>");
-MODULE_DESCRIPTION("TTUSB DVB Driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h b/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h
deleted file mode 100644
index 8c3cd545e8f..00000000000
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h
+++ /dev/null
@@ -1,1644 +0,0 @@
-
-#include <asm/types.h>
-
-static u8 dsp_bootcode [] = {
- 0x08, 0xaa, 0x00, 0x18, 0x00, 0x03, 0x08, 0x00,
- 0x00, 0x10, 0x00, 0x00, 0x01, 0x80, 0x18, 0x5f,
- 0x00, 0x00, 0x01, 0x80, 0x77, 0x18, 0x2a, 0xeb,
- 0x6b, 0xf8, 0x00, 0x18, 0x03, 0xff, 0x68, 0xf8,
- 0x00, 0x18, 0xff, 0xfe, 0xf7, 0xb8, 0xf7, 0xbe,
- 0xf6, 0xb9, 0xf4, 0xa0, 0xf6, 0xb7, 0xf6, 0xb5,
- 0xf6, 0xb6, 0xf0, 0x20, 0x19, 0xdf, 0xf1, 0x00,
- 0x00, 0x01, 0xf8, 0x4d, 0x01, 0xab, 0xf6, 0xb8,
- 0xf0, 0x20, 0x19, 0xdf, 0xf0, 0x73, 0x01, 0xa5,
- 0x7e, 0xf8, 0x00, 0x12, 0xf0, 0x00, 0x00, 0x01,
- 0x47, 0xf8, 0x00, 0x11, 0x7e, 0x92, 0x00, 0xf8,
- 0x00, 0x11, 0xf0, 0x00, 0x00, 0x01, 0x7e, 0xf8,
- 0x00, 0x11, 0xf0, 0x00, 0x00, 0x01, 0x6c, 0x89,
- 0x01, 0x9a, 0xf7, 0xb8, 0xee, 0xfc, 0xf0, 0x20,
- 0xff, 0xff, 0xf1, 0x00, 0x00, 0x01, 0xf8, 0x4d,
- 0x01, 0xbf, 0xf2, 0x73, 0x01, 0xb9, 0x4e, 0x02,
- 0xf4, 0x95, 0xf5, 0xe3, 0x56, 0x02, 0x7e, 0x00,
- 0x11, 0x00, 0xfa, 0x4c, 0x01, 0xb7, 0x6b, 0x03,
- 0x00, 0x01, 0xf6, 0xb8, 0xee, 0x04, 0xf0, 0x74,
- 0x0d, 0xa7, 0xf0, 0x74, 0x01, 0xc5, 0x4a, 0x11,
- 0x4a, 0x16, 0x72, 0x11, 0x2a, 0xe6, 0x10, 0xf8,
- 0x00, 0x11, 0xfa, 0x45, 0x01, 0xdb, 0xf4, 0x95,
- 0xee, 0xff, 0x48, 0x11, 0xf0, 0x00, 0x2a, 0xc6,
- 0x88, 0x16, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0xee,
- 0xff, 0xff, 0xf4, 0xe3, 0x6c, 0xe9, 0xff, 0xff,
- 0x01, 0xd5, 0x10, 0xf8, 0x2a, 0xe7, 0xf8, 0x45,
- 0x01, 0xe2, 0x10, 0xf8, 0x2a, 0xe7, 0xf4, 0xe3,
- 0xf0, 0x74, 0x01, 0xff, 0xee, 0x01, 0x8a, 0x16,
- 0x8a, 0x11, 0xfc, 0x00, 0xf7, 0xb8, 0xe9, 0x20,
- 0x4a, 0x11, 0x09, 0xf8, 0x2a, 0xe6, 0xf8, 0x4e,
- 0x01, 0xf3, 0xf2, 0x73, 0x01, 0xfd, 0xf4, 0x95,
- 0xe8, 0x01, 0x72, 0x11, 0x2a, 0xe6, 0x49, 0x11,
- 0x80, 0xe1, 0x2a, 0xc6, 0xf3, 0x00, 0x00, 0x01,
- 0xe8, 0x00, 0x81, 0xf8, 0x2a, 0xe6, 0x8a, 0x11,
- 0xfc, 0x00, 0xf4, 0x95, 0xf0, 0x73, 0x02, 0x00,
- 0x10, 0xf8, 0x2a, 0x0f, 0xfc, 0x00, 0x4a, 0x11,
- 0xf0, 0x74, 0x02, 0x02, 0x80, 0xf8, 0x2a, 0x10,
- 0x73, 0x08, 0x00, 0x09, 0x40, 0xf8, 0x2a, 0x15,
- 0x82, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0x77, 0x10,
- 0x03, 0xe8, 0xf5, 0xa9, 0xf8, 0x30, 0x02, 0x21,
- 0x71, 0xf8, 0x2a, 0x10, 0x2a, 0x15, 0x56, 0xf8,
- 0x2a, 0x0c, 0xf0, 0xe3, 0x4e, 0xf8, 0x2a, 0x16,
- 0xe8, 0x00, 0x4e, 0xf8, 0x2a, 0x0c, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1d,
- 0x68, 0xf8, 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8,
- 0x00, 0x07, 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d,
- 0xff, 0xfc, 0x6b, 0xf8, 0x2a, 0x0f, 0x00, 0x01,
- 0x8a, 0x1d, 0x8a, 0x07, 0x8a, 0x06, 0xf4, 0xeb,
- 0xee, 0xfd, 0x76, 0xf8, 0x2a, 0x0f, 0x00, 0x00,
- 0x76, 0x00, 0x00, 0x00, 0xfb, 0x80, 0x19, 0x4c,
- 0xf4, 0x95, 0xe8, 0x00, 0x80, 0xf8, 0x2a, 0x11,
- 0xf9, 0x80, 0x19, 0x07, 0x80, 0xf8, 0x2a, 0x0e,
- 0xf9, 0x80, 0x16, 0x66, 0x76, 0x00, 0x2a, 0x12,
- 0x10, 0xf8, 0x2a, 0x11, 0xf9, 0x80, 0x18, 0xe3,
- 0x10, 0xf8, 0x2a, 0x0e, 0xf9, 0x80, 0x16, 0x66,
- 0x10, 0xf8, 0x2a, 0x0e, 0xf9, 0x80, 0x16, 0x87,
- 0xee, 0x03, 0xfc, 0x00, 0x4a, 0x11, 0xf6, 0xb8,
- 0xf4, 0x95, 0xf0, 0x20, 0x80, 0x00, 0x11, 0xf8,
- 0x2a, 0x5a, 0xf8, 0x4d, 0x02, 0x93, 0x11, 0xf8,
- 0x2a, 0x9f, 0xf8, 0x4c, 0x02, 0x7c, 0x77, 0x12,
- 0x2a, 0x39, 0x49, 0x12, 0x01, 0xf8, 0x2a, 0x9f,
- 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0x81,
- 0x00, 0x11, 0x6c, 0xe1, 0xff, 0xab, 0x02, 0x93,
- 0x6b, 0xf8, 0x2a, 0x9f, 0x00, 0x01, 0xe9, 0x05,
- 0x01, 0xe2, 0x00, 0x03, 0x81, 0xf8, 0x2a, 0xa0,
- 0xf0, 0x73, 0x02, 0x95, 0x72, 0x11, 0x2a, 0x9f,
- 0xf4, 0x95, 0x10, 0xe1, 0x2a, 0x39, 0x6b, 0xf8,
- 0x2a, 0x9f, 0x00, 0x01, 0x11, 0xf8, 0x2a, 0x9f,
- 0x09, 0xf8, 0x2a, 0xa0, 0xf8, 0x4c, 0x02, 0x93,
- 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x00, 0x76, 0xf8,
- 0x2a, 0x9f, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa0,
- 0x00, 0x00, 0x88, 0x11, 0xf4, 0x95, 0x48, 0x11,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
- 0x10, 0xf8, 0x2a, 0x5a, 0xf8, 0x44, 0x02, 0xb2,
- 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x01, 0xf0, 0x74,
- 0x02, 0x58, 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10,
- 0x80, 0x00, 0xf4, 0xa9, 0xf8, 0x30, 0x02, 0xb2,
- 0x48, 0x11, 0xf0, 0x30, 0x00, 0xff, 0x80, 0x00,
- 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x18, 0xd6,
- 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00, 0xf4, 0x95,
- 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a, 0x4a, 0x0b,
- 0x4a, 0x0c, 0x4a, 0x0d, 0x4a, 0x10, 0x4a, 0x11,
- 0x4a, 0x12, 0x4a, 0x13, 0x4a, 0x14, 0x4a, 0x15,
- 0x4a, 0x16, 0x4a, 0x17, 0x4a, 0x17, 0x4a, 0x19,
- 0x4a, 0x0e, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1a,
- 0x4a, 0x1d, 0x4a, 0x1b, 0x4a, 0x1c, 0x68, 0xf8,
- 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
- 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
- 0x48, 0x18, 0x68, 0xf8, 0x00, 0x18, 0xff, 0xfe,
- 0xf4, 0x95, 0xf4, 0x95, 0x4a, 0x08, 0xee, 0xfd,
- 0xf0, 0x74, 0x02, 0x58, 0x88, 0x11, 0xf4, 0x95,
- 0x77, 0x10, 0x80, 0x00, 0xf4, 0xa9, 0xf8, 0x30,
- 0x02, 0xef, 0x48, 0x11, 0xf0, 0x30, 0x00, 0xff,
- 0x80, 0x00, 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80,
- 0x18, 0xd6, 0xee, 0x03, 0x8a, 0x18, 0xf4, 0x95,
- 0x8a, 0x1c, 0x8a, 0x1b, 0x8a, 0x1d, 0x8a, 0x1a,
- 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0e, 0x8a, 0x19,
- 0x8a, 0x17, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x15,
- 0x8a, 0x14, 0x8a, 0x13, 0x8a, 0x12, 0x8a, 0x11,
- 0x8a, 0x10, 0x8a, 0x0d, 0x8a, 0x0c, 0x8a, 0x0b,
- 0x8a, 0x0a, 0x8a, 0x09, 0x8a, 0x08, 0xf4, 0xeb,
- 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81,
- 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2,
- 0x00, 0x01, 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe2,
- 0x00, 0x02, 0x80, 0xe1, 0x00, 0x02, 0x76, 0xe1,
- 0x00, 0x03, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04,
- 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11, 0xf4, 0x95,
- 0xf4, 0x95, 0x10, 0x81, 0x6f, 0xf8, 0x2a, 0x9e,
- 0x0c, 0x88, 0xe8, 0xff, 0x18, 0xe1, 0x00, 0x01,
- 0x1a, 0xf8, 0x2a, 0x9e, 0xf0, 0x30, 0x1f, 0xff,
- 0x80, 0xf8, 0x2a, 0x9e, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81,
- 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18, 0x11, 0xe2,
- 0x00, 0x01, 0x81, 0xe1, 0x00, 0x01, 0x11, 0xe2,
- 0x00, 0x02, 0x81, 0xe1, 0x00, 0x02, 0x76, 0xe1,
- 0x00, 0x03, 0x00, 0x02, 0x48, 0x08, 0x6f, 0xe1,
- 0x00, 0x04, 0x0c, 0x98, 0xf0, 0x30, 0x00, 0xff,
- 0x80, 0xe1, 0x00, 0x05, 0x76, 0xe1, 0x00, 0x06,
- 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39,
- 0x76, 0x81, 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18,
- 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1, 0x00, 0x01,
- 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1, 0x00, 0x02,
- 0x76, 0xe1, 0x00, 0x03, 0x00, 0x04, 0x48, 0x11,
- 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12, 0xf4, 0x95,
- 0x77, 0x13, 0x2a, 0x76, 0xe9, 0x00, 0xe5, 0x98,
- 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8, 0x48, 0x0b,
- 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 0x03, 0x71,
- 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xf0,
- 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0x81,
- 0x00, 0x14, 0x71, 0xe1, 0x00, 0x01, 0x00, 0x15,
- 0x49, 0x11, 0xf3, 0x00, 0x00, 0x02, 0x89, 0x11,
- 0xe7, 0x82, 0x6d, 0xea, 0x00, 0x04, 0xe7, 0x83,
- 0x6d, 0xeb, 0x00, 0x0a, 0x77, 0x1a, 0x00, 0x05,
- 0xf0, 0x72, 0x03, 0xaa, 0x11, 0x81, 0xf2, 0xe8,
- 0x80, 0x82, 0xe9, 0xff, 0x19, 0xe1, 0x00, 0x01,
- 0xf1, 0xa0, 0x81, 0x92, 0x11, 0xe1, 0x00, 0x0c,
- 0xf2, 0xe8, 0x80, 0x83, 0xe9, 0xff, 0x19, 0xe1,
- 0x00, 0x0d, 0xf1, 0xa0, 0x81, 0x93, 0x6d, 0xe9,
- 0x00, 0x02, 0x48, 0x18, 0x49, 0x18, 0x70, 0x00,
- 0x00, 0x15, 0xf0, 0x00, 0x00, 0x04, 0xf3, 0x00,
- 0x00, 0x0a, 0x80, 0x01, 0x81, 0x02, 0xf2, 0x74,
- 0x0e, 0x54, 0xf4, 0x95, 0x48, 0x14, 0xee, 0x10,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xf0, 0x74,
- 0x0c, 0x5e, 0x80, 0xf8, 0x2a, 0x5c, 0x77, 0x12,
- 0x2a, 0x39, 0x76, 0x82, 0x00, 0x55, 0x77, 0x11,
- 0x2a, 0x18, 0x10, 0xe1, 0x00, 0x01, 0x80, 0xe2,
- 0x00, 0x01, 0x10, 0xe1, 0x00, 0x02, 0x80, 0xe2,
- 0x00, 0x02, 0x76, 0xe2, 0x00, 0x03, 0x00, 0x1c,
- 0xf6, 0xb8, 0x56, 0xf8, 0x2a, 0x16, 0xf0, 0xf0,
- 0xf0, 0xf8, 0x80, 0xe2, 0x00, 0x07, 0x56, 0xf8,
- 0x2a, 0x16, 0xf1, 0xf0, 0xe8, 0xff, 0xf2, 0x80,
- 0x80, 0xe2, 0x00, 0x06, 0x56, 0xf8, 0x2a, 0x16,
- 0xf1, 0xf8, 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2,
- 0x00, 0x05, 0x57, 0xf8, 0x2a, 0x16, 0xe8, 0xff,
- 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x04, 0x56, 0xf8,
- 0x27, 0x6c, 0xf0, 0xf0, 0xf0, 0xf8, 0x80, 0xe2,
- 0x00, 0x0b, 0x56, 0xf8, 0x27, 0x6c, 0xf1, 0xf0,
- 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x0a,
- 0x56, 0xf8, 0x27, 0x6c, 0xf1, 0xf8, 0xe8, 0xff,
- 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x09, 0xe8, 0xff,
- 0x57, 0xf8, 0x27, 0x6c, 0xf2, 0x80, 0x80, 0xe2,
- 0x00, 0x08, 0x56, 0xf8, 0x27, 0x6a, 0xf0, 0xf0,
- 0xf0, 0xf8, 0x80, 0xe2, 0x00, 0x0f, 0x56, 0xf8,
- 0x27, 0x6a, 0xf1, 0xf0, 0xe8, 0xff, 0xf2, 0x80,
- 0x80, 0xe2, 0x00, 0x0e, 0x56, 0xf8, 0x27, 0x6a,
- 0xf1, 0xf8, 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2,
- 0x00, 0x0d, 0x57, 0xf8, 0x27, 0x6a, 0xe8, 0xff,
- 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x0c, 0x76, 0xe2,
- 0x00, 0x13, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x12,
- 0x00, 0x00, 0x6f, 0xf8, 0x2a, 0x5c, 0x0c, 0x58,
- 0x80, 0xe2, 0x00, 0x11, 0xe8, 0xff, 0x18, 0xf8,
- 0x2a, 0x5c, 0x80, 0xe2, 0x00, 0x10, 0x76, 0xe2,
- 0x00, 0x17, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x16,
- 0x00, 0x00, 0x6f, 0xf8, 0x2a, 0x9e, 0x0c, 0x58,
- 0x80, 0xe2, 0x00, 0x15, 0xe8, 0xff, 0x18, 0xf8,
- 0x2a, 0x9e, 0x80, 0xe2, 0x00, 0x14, 0x76, 0xe2,
- 0x00, 0x1b, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1a,
- 0x00, 0x00, 0x76, 0xe2, 0x00, 0x19, 0x00, 0x00,
- 0x70, 0xe2, 0x00, 0x18, 0x27, 0x6e, 0x76, 0xe2,
- 0x00, 0x1f, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1e,
- 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1d, 0x00, 0x00,
- 0x76, 0xe2, 0x00, 0x1c, 0x00, 0x00, 0x76, 0xe2,
- 0x00, 0x20, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
- 0x10, 0xf8, 0x2a, 0x38, 0xf8, 0x45, 0x04, 0xed,
- 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x02,
- 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x08,
- 0x6d, 0xe9, 0xff, 0xdf, 0xf6, 0xa9, 0xf8, 0x20,
- 0x04, 0x75, 0xf0, 0x73, 0x04, 0x7d, 0xf0, 0x10,
- 0x00, 0x21, 0xf0, 0x00, 0x1a, 0x83, 0x48, 0x08,
- 0x7e, 0xf8, 0x00, 0x08, 0xf4, 0xe2, 0xf0, 0x74,
- 0x03, 0x0a, 0xf0, 0x73, 0x04, 0xea, 0x48, 0x12,
- 0xf2, 0x74, 0x03, 0x23, 0xf0, 0x00, 0x00, 0x04,
- 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00,
- 0xf0, 0x73, 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18,
- 0xe8, 0xff, 0x6f, 0xe1, 0x00, 0x04, 0x0d, 0x48,
- 0x18, 0xe1, 0x00, 0x05, 0xf2, 0x74, 0x09, 0x69,
- 0xf4, 0x95, 0xf2, 0xa0, 0xf0, 0x74, 0x03, 0x36,
- 0xf0, 0x73, 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18,
- 0xe8, 0xff, 0x6f, 0xe1, 0x00, 0x04, 0x0d, 0x48,
- 0x18, 0xe1, 0x00, 0x05, 0xf2, 0x74, 0x09, 0x41,
- 0xf4, 0x95, 0xf2, 0xa0, 0xf0, 0x74, 0x03, 0x36,
- 0xf0, 0x73, 0x04, 0xea, 0xf0, 0x74, 0x03, 0x57,
- 0xf0, 0x73, 0x04, 0xea, 0x10, 0xf8, 0x2a, 0x1c,
- 0xf0, 0x74, 0x12, 0xa4, 0xf2, 0x74, 0x03, 0x36,
- 0xf4, 0x95, 0xe8, 0x00, 0xf0, 0x73, 0x04, 0xea,
- 0x48, 0x12, 0xf2, 0x74, 0x03, 0x80, 0xf0, 0x00,
- 0x00, 0x04, 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95,
- 0xe8, 0x00, 0xf0, 0x73, 0x04, 0xea, 0x10, 0xf8,
- 0x2a, 0x1c, 0xf0, 0x74, 0x12, 0xc5, 0xf2, 0x74,
- 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00, 0xf0, 0x73,
- 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18, 0xe8, 0xff,
- 0x6f, 0xe1, 0x00, 0x06, 0x0d, 0x48, 0x18, 0xe1,
- 0x00, 0x07, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0xf2, 0xa0, 0x70, 0x00, 0x00, 0x12, 0x80, 0x01,
- 0x10, 0xe1, 0x00, 0x04, 0xf0, 0x74, 0x0e, 0x7a,
- 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00,
- 0xf0, 0x73, 0x04, 0xea, 0xf0, 0x74, 0x03, 0xbc,
- 0x76, 0xf8, 0x2a, 0x38, 0x00, 0x00, 0xee, 0x02,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11,
- 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 0x77, 0x12,
- 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1,
- 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1,
- 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x09,
- 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12,
- 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x86, 0xe9, 0x00,
- 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8,
- 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43,
- 0x05, 0x0a, 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74,
- 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55,
- 0x77, 0x13, 0x2a, 0x18, 0x10, 0xe3, 0x00, 0x01,
- 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe3, 0x00, 0x02,
- 0x80, 0xe1, 0x00, 0x02, 0x13, 0xe3, 0x00, 0x03,
- 0x81, 0xe1, 0x00, 0x03, 0x48, 0x11, 0x77, 0x11,
- 0x00, 0x00, 0xf8, 0x4d, 0x05, 0x44, 0xf0, 0x00,
- 0x00, 0x04, 0x88, 0x12, 0x48, 0x13, 0xf0, 0x00,
- 0x00, 0x04, 0x88, 0x13, 0xf4, 0x95, 0xf4, 0x95,
- 0xe5, 0x98, 0x6d, 0x91, 0xf6, 0xb8, 0x48, 0x11,
- 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 0x05, 0x3a,
- 0xf0, 0x20, 0x2a, 0x39, 0x49, 0x11, 0xf5, 0x00,
- 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x76, 0xe1,
- 0x00, 0x04, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11,
- 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 0x77, 0x12,
- 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1,
- 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1,
- 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x0c,
- 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12,
- 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x7a, 0xe9, 0x00,
- 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8,
- 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43,
- 0x05, 0x6a, 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74,
- 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55,
- 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01,
- 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02,
- 0x80, 0xe1, 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03,
- 0x00, 0x19, 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04,
- 0x88, 0x12, 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x5d,
- 0xe9, 0x00, 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01,
- 0xf6, 0xb8, 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c,
- 0xf8, 0x43, 0x05, 0x93, 0x76, 0x82, 0x00, 0xaa,
- 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0x88, 0x11, 0x10, 0xf8, 0x2a, 0x38,
- 0xf8, 0x44, 0x05, 0xe3, 0x10, 0xf8, 0x2a, 0xa1,
- 0xf8, 0x44, 0x05, 0xba, 0x6c, 0xe1, 0xff, 0x56,
- 0x05, 0xe3, 0x72, 0x12, 0x2a, 0xa1, 0xf4, 0x95,
- 0x70, 0xe2, 0x2a, 0x18, 0x00, 0x11, 0x6b, 0xf8,
- 0x2a, 0xa1, 0x00, 0x01, 0xf0, 0x73, 0x05, 0xe3,
- 0x72, 0x12, 0x2a, 0xa1, 0xf4, 0x95, 0x70, 0xe2,
- 0x2a, 0x18, 0x00, 0x11, 0x10, 0xf8, 0x2a, 0xa1,
- 0xf0, 0x00, 0x00, 0x01, 0x88, 0x12, 0xf4, 0x95,
- 0xf4, 0x95, 0x6e, 0xe2, 0xff, 0xfc, 0x05, 0xd1,
- 0x73, 0x12, 0x2a, 0xa1, 0x48, 0x11, 0xf0, 0x00,
- 0x00, 0x05, 0x80, 0xf8, 0x2a, 0xa2, 0x10, 0xf8,
- 0x2a, 0xa1, 0x08, 0xf8, 0x2a, 0xa2, 0xf8, 0x44,
- 0x05, 0xe3, 0x6c, 0xe1, 0xff, 0xab, 0x05, 0xdd,
- 0x76, 0xf8, 0x2a, 0x38, 0x00, 0x01, 0x76, 0xf8,
- 0x2a, 0xa1, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa2,
- 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0xf4, 0x95,
- 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a, 0x4a, 0x0b,
- 0x4a, 0x0c, 0x4a, 0x0d, 0x4a, 0x10, 0x4a, 0x11,
- 0x4a, 0x12, 0x4a, 0x13, 0x4a, 0x14, 0x4a, 0x15,
- 0x4a, 0x16, 0x4a, 0x17, 0x4a, 0x17, 0x4a, 0x19,
- 0x4a, 0x0e, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1a,
- 0x4a, 0x1d, 0x4a, 0x1b, 0x4a, 0x1c, 0x68, 0xf8,
- 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
- 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
- 0x48, 0x18, 0x68, 0xf8, 0x00, 0x18, 0xff, 0xfe,
- 0xf4, 0x95, 0xf4, 0x95, 0x4a, 0x08, 0xee, 0xff,
- 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x18, 0x04,
- 0xf0, 0x74, 0x05, 0xa2, 0xee, 0x01, 0x8a, 0x18,
- 0xf4, 0x95, 0x8a, 0x1c, 0x8a, 0x1b, 0x8a, 0x1d,
- 0x8a, 0x1a, 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0e,
- 0x8a, 0x19, 0x8a, 0x17, 0x8a, 0x17, 0x8a, 0x16,
- 0x8a, 0x15, 0x8a, 0x14, 0x8a, 0x13, 0x8a, 0x12,
- 0x8a, 0x11, 0x8a, 0x10, 0x8a, 0x0d, 0x8a, 0x0c,
- 0x8a, 0x0b, 0x8a, 0x0a, 0x8a, 0x09, 0x8a, 0x08,
- 0xf4, 0xeb, 0xee, 0xfd, 0x76, 0xf8, 0x2a, 0x38,
- 0x00, 0x00, 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x00,
- 0xe8, 0x01, 0x4e, 0x00, 0xfb, 0x80, 0x17, 0xd6,
- 0xf4, 0x95, 0xe8, 0x01, 0x80, 0xf8, 0x2a, 0x5b,
- 0x76, 0x00, 0x2a, 0x8f, 0xf9, 0x80, 0x16, 0xaa,
- 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x17, 0x5c,
- 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x17, 0x6f,
- 0xfb, 0x80, 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x1a,
- 0xfb, 0x80, 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x1a,
- 0xfb, 0x80, 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x1b,
- 0xfb, 0x80, 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x1b,
- 0xee, 0x03, 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95,
- 0x13, 0x02, 0x88, 0x11, 0xe8, 0x00, 0xf8, 0x4d,
- 0x06, 0x6a, 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a,
- 0xf4, 0x95, 0xf0, 0x72, 0x06, 0x69, 0x1c, 0x91,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11,
- 0x12, 0x03, 0x11, 0x02, 0xf8, 0x45, 0x06, 0x79,
- 0xf0, 0x10, 0x00, 0x01, 0x88, 0x1a, 0xf4, 0x95,
- 0xf0, 0x72, 0x06, 0x78, 0x81, 0x91, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02,
- 0x00, 0x11, 0x11, 0x03, 0x61, 0xf8, 0x00, 0x11,
- 0x00, 0x01, 0xf8, 0x30, 0x06, 0x91, 0xf6, 0xb8,
- 0x6f, 0xf8, 0x00, 0x11, 0x0c, 0x1f, 0x88, 0x11,
- 0xf3, 0xe8, 0xe8, 0xff, 0x18, 0x81, 0xf1, 0xa0,
- 0x81, 0x81, 0xf0, 0x73, 0x06, 0x9d, 0xf6, 0xb8,
- 0x6f, 0xf8, 0x00, 0x11, 0x0c, 0x1f, 0x88, 0x11,
- 0xf3, 0x30, 0x00, 0xff, 0xf0, 0x20, 0xff, 0x00,
- 0x18, 0x81, 0xf1, 0xa0, 0x81, 0x81, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x11, 0x02,
- 0x61, 0xf8, 0x00, 0x0b, 0x00, 0x01, 0xf8, 0x20,
- 0x06, 0xb1, 0x49, 0x0b, 0xf6, 0x1f, 0x88, 0x11,
- 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xf2, 0x73,
- 0x06, 0xb8, 0xf0, 0x30, 0x00, 0xff, 0x49, 0x0b,
- 0xf6, 0x1f, 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95,
- 0x12, 0x81, 0xf4, 0x78, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x12,
- 0x13, 0x03, 0x88, 0x11, 0xe8, 0x00, 0xf8, 0x4d,
- 0x06, 0xcc, 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a,
- 0xf4, 0x95, 0xf0, 0x72, 0x06, 0xcb, 0x11, 0x92,
- 0xf2, 0xc0, 0x81, 0x91, 0x8a, 0x11, 0xfc, 0x00,
- 0x88, 0x12, 0x12, 0x02, 0x71, 0x01, 0x00, 0x13,
- 0xf8, 0x45, 0x06, 0xdb, 0xf0, 0x10, 0x00, 0x01,
- 0x88, 0x1a, 0xf4, 0x95, 0xf0, 0x72, 0x06, 0xda,
- 0xe5, 0x98, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
- 0x88, 0x11, 0x11, 0x04, 0x10, 0x06, 0x71, 0x05,
- 0x00, 0x12, 0x61, 0xf8, 0x00, 0x12, 0x00, 0x01,
- 0xf8, 0x20, 0x06, 0xea, 0xf0, 0x00, 0x00, 0x01,
- 0xf6, 0xb8, 0xf0, 0x00, 0x00, 0x01, 0x6f, 0xf8,
- 0x00, 0x12, 0x0f, 0x1f, 0x48, 0x08, 0x81, 0x00,
- 0xf4, 0x7f, 0x80, 0x01, 0xf2, 0x74, 0x06, 0xba,
- 0xf4, 0x95, 0x48, 0x11, 0xee, 0x02, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 0x88, 0x12,
- 0x11, 0x04, 0x10, 0x06, 0x71, 0x05, 0x00, 0x13,
- 0x61, 0xf8, 0x00, 0x13, 0x00, 0x01, 0xf8, 0x20,
- 0x07, 0x09, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00,
- 0x00, 0x01, 0x88, 0x11, 0xf6, 0xb8, 0x6f, 0xf8,
- 0x00, 0x13, 0x0f, 0x1f, 0x81, 0x00, 0x48, 0x11,
- 0xf4, 0x7f, 0x80, 0x01, 0xf2, 0x74, 0x06, 0xce,
- 0xf4, 0x95, 0x48, 0x12, 0x48, 0x11, 0xf0, 0x30,
- 0xff, 0xfe, 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xfc,
- 0xf4, 0x95, 0x80, 0x02, 0x71, 0x08, 0x00, 0x16,
- 0x10, 0x09, 0x71, 0x0b, 0x00, 0x17, 0x80, 0x03,
- 0x71, 0x0a, 0x00, 0x11, 0x48, 0x17, 0xf8, 0x45,
- 0x07, 0x3f, 0x70, 0x00, 0x00, 0x11, 0x10, 0x03,
- 0xf0, 0x74, 0x06, 0x9f, 0x80, 0x01, 0x70, 0x00,
- 0x00, 0x16, 0x10, 0x02, 0xf0, 0x74, 0x06, 0x7b,
- 0x6d, 0x91, 0x6d, 0x96, 0x6c, 0xef, 0xff, 0xff,
- 0x07, 0x2f, 0xee, 0x04, 0x8a, 0x17, 0x8a, 0x16,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
- 0x10, 0xf8, 0x2a, 0xe8, 0x08, 0xf8, 0x2a, 0xe9,
- 0xf8, 0x45, 0x07, 0x64, 0x76, 0x00, 0x00, 0x01,
- 0x62, 0xf8, 0x2a, 0xe9, 0x00, 0x5e, 0xf2, 0x74,
- 0x12, 0x0b, 0xf0, 0x00, 0x30, 0x40, 0x72, 0x11,
- 0x2a, 0xe9, 0x77, 0x10, 0x00, 0x0f, 0xf5, 0xa9,
- 0xf8, 0x20, 0x07, 0x61, 0x6b, 0xf8, 0x2a, 0xe9,
- 0x00, 0x01, 0xf0, 0x73, 0x07, 0x64, 0x76, 0xf8,
- 0x2a, 0xe9, 0x00, 0x00, 0xee, 0x02, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11, 0xe8, 0x00,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x08, 0xe8, 0x00,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x09, 0xf6, 0xb8,
- 0xf4, 0x95, 0xf0, 0x20, 0xfc, 0x3f, 0x75, 0xf8,
- 0x00, 0x08, 0x00, 0x0d, 0xf0, 0x20, 0x0c, 0x30,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0c, 0x76, 0xf8,
- 0x2a, 0xe8, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xe9,
- 0x00, 0x00, 0x6c, 0x81, 0x07, 0x92, 0x76, 0xf8,
- 0x2a, 0xea, 0x00, 0x00, 0xfb, 0x80, 0x16, 0x76,
- 0xf4, 0x95, 0xe8, 0x10, 0xe8, 0x00, 0x75, 0xf8,
- 0x00, 0x08, 0x00, 0x00, 0xf0, 0x73, 0x07, 0xa8,
- 0x76, 0xf8, 0x2a, 0xea, 0x00, 0x01, 0xfb, 0x80,
- 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x10, 0xfb, 0x80,
- 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x10, 0xe8, 0x00,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00, 0xf6, 0xb8,
- 0xf4, 0x95, 0xf0, 0x20, 0xff, 0xff, 0x75, 0xf8,
- 0x00, 0x08, 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00,
- 0xf4, 0x95, 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a,
- 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8,
- 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
- 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
- 0x10, 0xf8, 0x2a, 0xea, 0xf8, 0x45, 0x07, 0xe1,
- 0x10, 0xf8, 0x2a, 0xe8, 0xf0, 0x00, 0x00, 0x01,
- 0xf0, 0x30, 0x00, 0x0f, 0x80, 0xf8, 0x2a, 0xe8,
- 0x10, 0xf8, 0x2a, 0xe8, 0xf8, 0x44, 0x07, 0xd6,
- 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xfc, 0x3f,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0d, 0xf0, 0x20,
- 0x0c, 0x30, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0c,
- 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00,
- 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xff, 0xff,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00, 0x8a, 0x1d,
- 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0a, 0x8a, 0x09,
- 0x8a, 0x08, 0xf4, 0xeb, 0xee, 0xff, 0xf2, 0x74,
- 0x07, 0x67, 0xf4, 0x95, 0xe8, 0x01, 0xee, 0x01,
- 0xfc, 0x00, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8,
- 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
- 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
- 0x8a, 0x1d, 0x8a, 0x07, 0xf4, 0xeb, 0x4a, 0x11,
- 0x77, 0x11, 0x00, 0x28, 0x76, 0x81, 0x24, 0x00,
- 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
- 0xf2, 0x74, 0x07, 0x67, 0xf4, 0x95, 0xe8, 0x00,
- 0x77, 0x11, 0x00, 0x1d, 0x68, 0x81, 0x00, 0x7f,
- 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xff, 0x80,
- 0x77, 0x11, 0x00, 0x1d, 0xf0, 0x30, 0x01, 0x00,
- 0x1a, 0x81, 0x80, 0x81, 0xf0, 0x74, 0x0a, 0x33,
- 0xf0, 0x74, 0x11, 0xac, 0xf9, 0x80, 0x13, 0x25,
- 0xf9, 0x80, 0x16, 0x53, 0xf9, 0x80, 0x17, 0x82,
- 0xf0, 0x74, 0x06, 0x2f, 0xf9, 0x80, 0x14, 0xb2,
- 0xf9, 0x80, 0x19, 0x10, 0xf0, 0x74, 0x0d, 0xe3,
- 0xf0, 0x74, 0x07, 0xe8, 0xf0, 0x74, 0x02, 0x36,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x60, 0xf8,
- 0x27, 0x7b, 0xff, 0xff, 0xf8, 0x30, 0x08, 0x39,
- 0x71, 0xf8, 0x27, 0x7b, 0x27, 0x79, 0x60, 0xf8,
- 0x27, 0x79, 0xff, 0xff, 0xf8, 0x30, 0x08, 0xb2,
- 0x10, 0xf8, 0x29, 0x86, 0x08, 0xf8, 0x27, 0x79,
- 0xf0, 0x30, 0x7f, 0xff, 0x88, 0x11, 0xf4, 0x95,
- 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x30,
- 0x08, 0x58, 0x10, 0xf8, 0x27, 0x79, 0x08, 0xf8,
- 0x27, 0x7a, 0xf0, 0x30, 0x7f, 0xff, 0x88, 0x11,
- 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9,
- 0xf8, 0x20, 0x08, 0x63, 0x76, 0xf8, 0x27, 0x79,
- 0xff, 0xff, 0x76, 0xf8, 0x27, 0x7b, 0xff, 0xff,
- 0xf7, 0xb8, 0xf2, 0x73, 0x08, 0xd9, 0xf0, 0x20,
- 0xff, 0xff, 0xf6, 0xb8, 0x56, 0xf8, 0x27, 0x74,
- 0xf0, 0xf9, 0x88, 0x11, 0x56, 0xf8, 0x27, 0x72,
- 0xf0, 0xf9, 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95,
- 0xe7, 0x20, 0xf4, 0xa9, 0xf8, 0x30, 0x08, 0x8f,
- 0xf1, 0x20, 0x27, 0x7c, 0x48, 0x11, 0xf6, 0x00,
- 0x88, 0x13, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x83,
- 0x08, 0xf8, 0x27, 0x79, 0xf0, 0x30, 0x7f, 0xff,
- 0x88, 0x13, 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00,
- 0xf5, 0xab, 0xf8, 0x30, 0x08, 0x8f, 0x6d, 0x91,
- 0x48, 0x11, 0xf0, 0x30, 0x01, 0xff, 0x88, 0x11,
- 0xf4, 0x95, 0xe7, 0x20, 0xf7, 0xa9, 0xf8, 0x30,
- 0x08, 0x74, 0x6d, 0x89, 0x48, 0x11, 0xf0, 0x30,
- 0x01, 0xff, 0xf0, 0xe7, 0xf4, 0x95, 0x48, 0x08,
- 0x4e, 0xf8, 0x27, 0x74, 0x48, 0x08, 0xf1, 0xf9,
- 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0xe1,
- 0x27, 0x7c, 0x27, 0x7a, 0x60, 0xf8, 0x27, 0x7b,
- 0xff, 0xff, 0xf8, 0x30, 0x08, 0xab, 0x48, 0x08,
- 0x4e, 0xf8, 0x27, 0x72, 0x76, 0xf8, 0x27, 0x7b,
- 0xff, 0xff, 0x76, 0xf8, 0x27, 0x79, 0xff, 0xff,
- 0xf2, 0x73, 0x08, 0xd9, 0xf4, 0x95, 0xe8, 0x00,
- 0x44, 0xf8, 0x27, 0x73, 0x40, 0xf8, 0x27, 0x75,
- 0x82, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0x77, 0x10,
- 0x80, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x08, 0xd8,
- 0xf6, 0xb8, 0x10, 0xf8, 0x27, 0x73, 0xf0, 0x00,
- 0x80, 0x00, 0x48, 0x08, 0x4e, 0xf8, 0x27, 0x74,
- 0x48, 0x08, 0xf0, 0xf9, 0x88, 0x11, 0xf4, 0x95,
- 0xf4, 0x95, 0x71, 0xe1, 0x27, 0x7c, 0x27, 0x7a,
- 0xf7, 0xb8, 0x57, 0xf8, 0x27, 0x74, 0xf0, 0x62,
- 0xff, 0xff, 0xf0, 0x40, 0xff, 0x80, 0xf2, 0x80,
- 0x4e, 0xf8, 0x27, 0x74, 0xe8, 0x00, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xfb,
- 0x11, 0xf8, 0x27, 0x71, 0x09, 0xf8, 0x27, 0x73,
- 0x89, 0x11, 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95,
- 0xf6, 0xa9, 0xf8, 0x20, 0x08, 0xed, 0xf2, 0x73,
- 0x09, 0x0e, 0xf4, 0x95, 0xe8, 0x00, 0xf6, 0x20,
- 0x76, 0x00, 0x00, 0x41, 0xf0, 0x74, 0x12, 0xee,
- 0x88, 0x16, 0xf4, 0x95, 0xf7, 0xb8, 0x6d, 0x96,
- 0x10, 0xf8, 0x00, 0x16, 0xf8, 0x47, 0x09, 0x0a,
- 0xe7, 0x61, 0x76, 0x00, 0x00, 0x00, 0x76, 0x01,
- 0x00, 0x80, 0x76, 0x02, 0x00, 0xff, 0x76, 0x03,
- 0x00, 0x00, 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95,
- 0xe8, 0x00, 0x6c, 0xe9, 0xff, 0xff, 0x08, 0xfb,
- 0x73, 0x16, 0x00, 0x0e, 0xf0, 0x66, 0x00, 0x41,
- 0xee, 0x05, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x13,
- 0xf6, 0xb8, 0x77, 0x11, 0x7f, 0xff, 0x57, 0xf8,
- 0x27, 0x72, 0x48, 0x11, 0xf2, 0x80, 0xf0, 0x00,
- 0x80, 0x00, 0x88, 0x11, 0xf6, 0x40, 0xf0, 0xe0,
- 0xf1, 0xf1, 0xe8, 0x01, 0xf2, 0x80, 0x80, 0xf8,
- 0x27, 0x78, 0x77, 0x12, 0x80, 0x00, 0x57, 0xf8,
- 0x27, 0x72, 0x48, 0x12, 0xf2, 0x80, 0x88, 0x12,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x82, 0x09, 0x38,
- 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
- 0xf0, 0x73, 0x09, 0x3d, 0xf0, 0x20, 0x80, 0x01,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0x70, 0x81,
- 0x00, 0x13, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0xf0, 0x30, 0x7f, 0xff, 0x11, 0xf8, 0x29, 0x86,
- 0xf5, 0x20, 0xf3, 0x30, 0x7f, 0xff, 0x89, 0x11,
- 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9,
- 0xf8, 0x20, 0x09, 0x54, 0xf2, 0x73, 0x09, 0x67,
- 0xf4, 0x95, 0xe8, 0x02, 0x6f, 0xf8, 0x27, 0x7a,
- 0x0d, 0x20, 0xf3, 0x30, 0x7f, 0xff, 0x89, 0x11,
- 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9,
- 0xf8, 0x20, 0x09, 0x64, 0xf2, 0x73, 0x09, 0x67,
- 0xf4, 0x95, 0xe8, 0x01, 0x80, 0xf8, 0x27, 0x7b,
- 0xe8, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0x11, 0xf8, 0x29, 0x86, 0xf5, 0x20, 0xf3, 0x30,
- 0x7f, 0xff, 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10,
- 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x09, 0x7a,
- 0xf2, 0x73, 0x09, 0x8d, 0xf4, 0x95, 0xe8, 0x02,
- 0x6f, 0xf8, 0x27, 0x7a, 0x0d, 0x20, 0xf3, 0x30,
- 0x7f, 0xff, 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10,
- 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x09, 0x8a,
- 0xf2, 0x73, 0x09, 0x8d, 0xf4, 0x95, 0xe8, 0x01,
- 0x80, 0xf8, 0x27, 0x79, 0xe8, 0x00, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02,
- 0x00, 0x12, 0x88, 0x11, 0xf6, 0xb8, 0x57, 0xf8,
- 0x27, 0x72, 0xf0, 0x20, 0x7f, 0xff, 0xf2, 0x80,
- 0xf0, 0x00, 0x80, 0x00, 0x80, 0x81, 0x57, 0xf8,
- 0x27, 0x72, 0xe8, 0x01, 0xf3, 0xf1, 0xf2, 0x80,
- 0x80, 0xf8, 0x27, 0x78, 0x77, 0x11, 0x80, 0x00,
- 0x48, 0x11, 0x57, 0xf8, 0x27, 0x72, 0xf2, 0x80,
- 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81,
- 0x09, 0xb5, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08,
- 0x00, 0x01, 0xf0, 0x73, 0x09, 0xba, 0xf0, 0x20,
- 0x80, 0x01, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
- 0x45, 0xf8, 0x27, 0x71, 0x43, 0xf8, 0x27, 0x73,
- 0x83, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0xe7, 0x20,
- 0xf6, 0xa9, 0xf8, 0x30, 0x09, 0xc9, 0xf2, 0x73,
- 0x09, 0xe4, 0x77, 0x12, 0x00, 0x00, 0x57, 0xf8,
- 0x27, 0x72, 0xf0, 0x20, 0x7f, 0xff, 0xf2, 0x80,
- 0x49, 0x12, 0xf5, 0x00, 0xf3, 0x00, 0x80, 0x00,
- 0x61, 0xf8, 0x00, 0x0b, 0x80, 0x00, 0xf8, 0x30,
- 0x09, 0xdc, 0xf1, 0x20, 0x80, 0x00, 0xf5, 0x20,
- 0x89, 0x12, 0xf4, 0x95, 0x48, 0x12, 0x6f, 0xf8,
- 0x27, 0x73, 0x0d, 0x00, 0xf4, 0x95, 0x49, 0x0b,
- 0x4f, 0xf8, 0x27, 0x72, 0x8a, 0x11, 0xfe, 0x00,
- 0x48, 0x12, 0xf4, 0x95, 0x4a, 0x11, 0x4a, 0x16,
- 0x4a, 0x17, 0xee, 0xfc, 0xf4, 0x95, 0x71, 0x08,
- 0x00, 0x16, 0x88, 0x17, 0xf0, 0x74, 0x08, 0x30,
- 0x48, 0x18, 0x70, 0x00, 0x00, 0x16, 0xf2, 0x74,
- 0x09, 0x8f, 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 0x0a, 0x0a,
- 0xf2, 0x74, 0x08, 0xdb, 0xf4, 0x95, 0x48, 0x16,
- 0x48, 0x18, 0x70, 0x00, 0x00, 0x16, 0xf2, 0x74,
- 0x09, 0x8f, 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11,
- 0x10, 0x02, 0x70, 0x01, 0x00, 0x11, 0x80, 0x00,
- 0xf2, 0x74, 0x06, 0xce, 0xf4, 0x95, 0x48, 0x17,
- 0x49, 0x11, 0x48, 0x17, 0xf6, 0x00, 0x88, 0x17,
- 0xe7, 0x60, 0xf5, 0xa9, 0xf8, 0x20, 0x0a, 0x2d,
- 0x48, 0x16, 0xf6, 0x20, 0x88, 0x11, 0x48, 0x18,
- 0x70, 0x00, 0x00, 0x11, 0xf2, 0x74, 0x09, 0x8f,
- 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11, 0x70, 0x01,
- 0x00, 0x11, 0x10, 0x02, 0x80, 0x00, 0xf2, 0x74,
- 0x06, 0xce, 0xf4, 0x95, 0x48, 0x17, 0xee, 0x04,
- 0x48, 0x16, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11,
- 0xfc, 0x00, 0xee, 0xfd, 0xe8, 0x00, 0x4e, 0xf8,
- 0x27, 0x70, 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x72,
- 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x74, 0xe8, 0x00,
- 0x4e, 0xf8, 0x27, 0x76, 0x76, 0xf8, 0x27, 0x79,
- 0xff, 0xff, 0x76, 0xf8, 0x27, 0x7a, 0x00, 0x00,
- 0x76, 0xf8, 0x27, 0x7b, 0xff, 0xff, 0x76, 0xf8,
- 0x27, 0x78, 0x00, 0x00, 0xe8, 0x00, 0x75, 0xf8,
- 0x00, 0x08, 0x00, 0x01, 0x76, 0x00, 0x00, 0x00,
- 0x76, 0x01, 0x02, 0x00, 0xf2, 0x74, 0x12, 0xdc,
- 0xf0, 0x20, 0x27, 0x7c, 0xee, 0x03, 0xfc, 0x00,
- 0x4a, 0x11, 0xee, 0xfc, 0xf4, 0x95, 0x4e, 0x00,
- 0x77, 0x12, 0x7f, 0xff, 0xf6, 0xb8, 0x49, 0x12,
- 0xf1, 0x80, 0xf3, 0x00, 0x80, 0x00, 0x89, 0x12,
- 0xf0, 0xe0, 0xf1, 0xf1, 0x4f, 0x02, 0xe9, 0x01,
- 0xf4, 0x95, 0x48, 0x0b, 0xf5, 0x40, 0x56, 0x02,
- 0xf1, 0x80, 0x81, 0xf8, 0x27, 0x78, 0x77, 0x11,
- 0x80, 0x00, 0x56, 0x00, 0x49, 0x11, 0xf1, 0x80,
- 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81,
- 0x0a, 0x81, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08,
- 0x00, 0x01, 0xf0, 0x73, 0x0a, 0x86, 0xf0, 0x20,
- 0x80, 0x01, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
- 0x10, 0x82, 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0xee, 0xfe, 0xf4, 0x95, 0x4e, 0x00,
- 0x77, 0x11, 0x7f, 0xff, 0xf6, 0xb8, 0x49, 0x11,
- 0xf1, 0x80, 0xf3, 0x00, 0x80, 0x00, 0x89, 0x11,
- 0xf0, 0xe0, 0xf1, 0xf1, 0xe8, 0x01, 0xf2, 0x80,
- 0x80, 0xf8, 0x27, 0x78, 0x56, 0x00, 0xf1, 0x20,
- 0x80, 0x00, 0xf1, 0x80, 0xf4, 0x95, 0x49, 0x0b,
- 0xf8, 0x4d, 0x0a, 0xab, 0xf0, 0x20, 0x80, 0x01,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0xf0, 0x73,
- 0x0a, 0xaf, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08,
- 0x00, 0x01, 0xee, 0x02, 0x48, 0x11, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x12, 0x13, 0x02,
- 0x77, 0x11, 0x00, 0x00, 0xf8, 0x4d, 0x0a, 0xcb,
- 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a, 0xf4, 0x95,
- 0xf0, 0x72, 0x0a, 0xca, 0x48, 0x11, 0x1c, 0xf8,
- 0x29, 0x7e, 0x88, 0x11, 0x11, 0xf8, 0x29, 0x7e,
- 0xf2, 0x00, 0x00, 0x01, 0x80, 0xf8, 0x29, 0x7e,
- 0x81, 0x92, 0x48, 0x11, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x11,
- 0x88, 0x12, 0xf6, 0xb8, 0xf0, 0x20, 0x7f, 0xff,
- 0x57, 0xf8, 0x27, 0x70, 0xf2, 0x80, 0xf0, 0x00,
- 0x80, 0x00, 0x80, 0x82, 0x57, 0xf8, 0x27, 0x70,
- 0xe8, 0x01, 0xf3, 0xf1, 0xf2, 0x80, 0x80, 0xf8,
- 0x27, 0x78, 0x77, 0x12, 0x80, 0x00, 0x48, 0x12,
- 0x57, 0xf8, 0x27, 0x70, 0xf2, 0x80, 0x88, 0x12,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x82, 0x0a, 0xf4,
- 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
- 0xf0, 0x73, 0x0a, 0xf9, 0xf0, 0x20, 0x80, 0x01,
- 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0x45, 0xf8,
- 0x27, 0x75, 0xe7, 0x10, 0x43, 0xf8, 0x27, 0x71,
- 0x83, 0xf8, 0x00, 0x12, 0x6d, 0xe8, 0x00, 0x04,
- 0x6d, 0x8a, 0xf6, 0xaa, 0xf8, 0x30, 0x0b, 0x0a,
- 0xf2, 0x73, 0x0b, 0x25, 0x77, 0x11, 0x00, 0x00,
- 0x57, 0xf8, 0x27, 0x70, 0xf0, 0x20, 0x7f, 0xff,
- 0xf2, 0x80, 0x49, 0x11, 0xf5, 0x00, 0xf3, 0x00,
- 0x80, 0x00, 0x61, 0xf8, 0x00, 0x0b, 0x80, 0x00,
- 0xf8, 0x30, 0x0b, 0x1d, 0xf1, 0x20, 0x80, 0x00,
- 0xf5, 0x20, 0x89, 0x11, 0xf4, 0x95, 0x48, 0x11,
- 0x6f, 0xf8, 0x27, 0x71, 0x0d, 0x00, 0xf4, 0x95,
- 0x49, 0x0b, 0x4f, 0xf8, 0x27, 0x70, 0x48, 0x11,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16,
- 0x4a, 0x17, 0xee, 0xf0, 0x88, 0x17, 0x10, 0x17,
- 0x80, 0x05, 0x10, 0x16, 0x80, 0x06, 0x10, 0x15,
- 0x80, 0x07, 0x71, 0x14, 0x00, 0x11, 0x10, 0x05,
- 0xf0, 0x30, 0x00, 0x01, 0x88, 0x10, 0x10, 0x06,
- 0xf0, 0x30, 0x00, 0x01, 0x80, 0x08, 0x49, 0x11,
- 0x10, 0x05, 0xf6, 0x01, 0x80, 0x09, 0x10, 0x06,
- 0x61, 0xf8, 0x00, 0x08, 0x00, 0x01, 0xf8, 0x20,
- 0x0b, 0x4b, 0x10, 0x09, 0xf0, 0x00, 0x00, 0x01,
- 0x80, 0x09, 0x71, 0x08, 0x00, 0x12, 0xf4, 0xaa,
- 0xf8, 0x30, 0x0b, 0x54, 0x10, 0x09, 0xf0, 0x00,
- 0x00, 0x01, 0x80, 0x09, 0x12, 0x09, 0x49, 0x11,
- 0xf4, 0x7f, 0x80, 0x09, 0xf6, 0x20, 0x80, 0x0a,
- 0x56, 0xf8, 0x27, 0x70, 0x4e, 0x0c, 0x10, 0x09,
- 0x80, 0x00, 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce,
- 0xf0, 0x00, 0x00, 0x04, 0x88, 0x16, 0xf4, 0x95,
- 0xf4, 0x95, 0x6c, 0x86, 0x0b, 0x6d, 0xf2, 0x73,
- 0x0c, 0x59, 0xf4, 0x95, 0xe8, 0x00, 0xf6, 0xb8,
- 0xf4, 0x95, 0x56, 0x0c, 0xf0, 0xf9, 0x88, 0x12,
- 0xf4, 0x95, 0xf4, 0x95, 0x70, 0xe2, 0x27, 0x7c,
- 0x29, 0x86, 0xe8, 0x00, 0x80, 0x0e, 0x48, 0x11,
- 0xf8, 0x45, 0x0b, 0xcc, 0x77, 0x10, 0x00, 0x01,
- 0xf4, 0xa9, 0xf8, 0x30, 0x0b, 0x89, 0x6c, 0xe1,
- 0xff, 0xfd, 0x0b, 0x8b, 0x10, 0xe7, 0x00, 0x02,
- 0x80, 0x0e, 0xf0, 0x73, 0x0b, 0x8b, 0x10, 0x87,
- 0x80, 0x0e, 0xe7, 0x10, 0xf5, 0xae, 0xf8, 0x20,
- 0x0b, 0xb2, 0x70, 0x00, 0x00, 0x17, 0x70, 0x01,
- 0x00, 0x16, 0x10, 0x04, 0xf0, 0x74, 0x06, 0xce,
- 0x48, 0x17, 0x49, 0x16, 0xf6, 0x00, 0x88, 0x17,
- 0x48, 0x11, 0xf6, 0x20, 0x88, 0x11, 0x10, 0x09,
- 0xf6, 0x20, 0x80, 0x00, 0x48, 0x18, 0xf2, 0x74,
- 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x16,
- 0x10, 0x04, 0x70, 0x00, 0x00, 0x17, 0x70, 0x01,
- 0x00, 0x11, 0xf0, 0x74, 0x06, 0xce, 0x48, 0x11,
- 0x00, 0x04, 0x80, 0x04, 0xf0, 0x73, 0x0b, 0xbc,
- 0x70, 0x00, 0x00, 0x17, 0x70, 0x01, 0x00, 0x11,
- 0x10, 0x04, 0xf0, 0x74, 0x06, 0xce, 0x48, 0x11,
- 0x00, 0x04, 0x80, 0x04, 0x49, 0x11, 0x48, 0x16,
- 0xf6, 0x20, 0x88, 0x16, 0xf4, 0x95, 0xf4, 0x95,
- 0x6c, 0x86, 0x0b, 0xcc, 0x10, 0x0a, 0x80, 0x00,
- 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00,
- 0x00, 0x04, 0x88, 0x16, 0x12, 0x0a, 0xf8, 0x45,
- 0x0c, 0x33, 0x71, 0x0a, 0x00, 0x10, 0xf4, 0xae,
- 0xf8, 0x30, 0x0c, 0x1c, 0x48, 0x16, 0xf0, 0xe1,
- 0x88, 0x11, 0x12, 0x08, 0xf8, 0x45, 0x0b, 0xdb,
- 0x6d, 0x89, 0x12, 0x07, 0xf8, 0x45, 0x0b, 0xe9,
- 0x10, 0x07, 0x80, 0x00, 0x70, 0x02, 0x00, 0x11,
- 0x10, 0x06, 0x80, 0x01, 0x10, 0x04, 0xf0, 0x74,
- 0x06, 0xdc, 0xf0, 0x73, 0x0b, 0xef, 0x48, 0x11,
- 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04, 0xf0, 0x74,
- 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0, 0x81, 0x0e,
- 0x10, 0x06, 0x49, 0x11, 0xf6, 0x00, 0x80, 0x06,
- 0x10, 0x05, 0xf6, 0x20, 0x88, 0x11, 0xf0, 0x00,
- 0x00, 0x01, 0x48, 0x08, 0x6f, 0x00, 0x0c, 0x9f,
- 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00,
- 0x00, 0x04, 0x12, 0x07, 0xf8, 0x45, 0x0c, 0x11,
- 0x10, 0x07, 0x80, 0x00, 0x70, 0x02, 0x00, 0x11,
- 0x10, 0x06, 0x80, 0x01, 0x10, 0x04, 0xf0, 0x74,
- 0x06, 0xdc, 0xf0, 0x73, 0x0c, 0x17, 0x48, 0x11,
- 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04, 0xf0, 0x74,
- 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0, 0x81, 0x0e,
- 0xf0, 0x73, 0x0c, 0x33, 0x12, 0x07, 0xf8, 0x45,
- 0x0c, 0x2a, 0x10, 0x07, 0x80, 0x00, 0x10, 0x06,
- 0x80, 0x01, 0x10, 0x05, 0x80, 0x02, 0x10, 0x04,
- 0xf0, 0x74, 0x06, 0xdc, 0xf0, 0x73, 0x0c, 0x30,
- 0x12, 0x05, 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04,
- 0xf0, 0x74, 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0,
- 0x81, 0x0e, 0x76, 0x00, 0x00, 0x01, 0x48, 0x18,
- 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04,
- 0x71, 0x04, 0x00, 0x11, 0x70, 0x81, 0x29, 0x86,
- 0x10, 0x0e, 0x1c, 0xf8, 0x29, 0x86, 0x80, 0x0e,
- 0x76, 0x00, 0x00, 0x01, 0x48, 0x18, 0xf2, 0x74,
- 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04, 0x10, 0x0e,
- 0x71, 0x04, 0x00, 0x11, 0x80, 0x81, 0x10, 0xf8,
- 0x29, 0x86, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x30,
- 0x7f, 0xff, 0x80, 0xf8, 0x29, 0x86, 0x10, 0x09,
- 0xf0, 0x00, 0x00, 0x02, 0x80, 0x09, 0xee, 0x10,
- 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00,
- 0x10, 0xf8, 0x27, 0x75, 0x08, 0xf8, 0x27, 0x71,
- 0xf0, 0x10, 0x00, 0x01, 0x48, 0x08, 0xfc, 0x00,
- 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xff, 0xf4, 0x95,
- 0x71, 0x04, 0x00, 0x16, 0xf0, 0x00, 0x00, 0x01,
- 0x48, 0x08, 0x4e, 0xf8, 0x29, 0x7c, 0x6d, 0xee,
- 0xff, 0xfd, 0x48, 0x16, 0xf8, 0x45, 0x0c, 0x99,
- 0x56, 0xf8, 0x29, 0x7c, 0xf0, 0x74, 0x0a, 0x5a,
- 0x88, 0x11, 0x10, 0xf8, 0x29, 0x7d, 0xf0, 0x00,
- 0x00, 0x01, 0x48, 0x08, 0x4e, 0xf8, 0x29, 0x7c,
- 0x10, 0xf8, 0x29, 0x82, 0xf0, 0x00, 0x00, 0x01,
- 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xa9,
- 0xfa, 0x30, 0x0c, 0x96, 0x80, 0xf8, 0x29, 0x82,
- 0x56, 0xf8, 0x29, 0x80, 0xf0, 0x00, 0x00, 0x01,
- 0x4e, 0xf8, 0x29, 0x80, 0x73, 0x11, 0x29, 0x82,
- 0x6c, 0xee, 0xff, 0xff, 0x0c, 0x76, 0xee, 0x01,
- 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0x76, 0xf8, 0x29, 0x84, 0x00, 0x00, 0x76, 0xf8,
- 0x29, 0x85, 0x00, 0x01, 0xe8, 0x00, 0x4e, 0xf8,
- 0x2a, 0x0c, 0x76, 0xf8, 0x29, 0x86, 0x00, 0x00,
- 0x76, 0xf8, 0x29, 0x87, 0x00, 0x00, 0x77, 0x11,
- 0x29, 0x88, 0x76, 0x81, 0xaa, 0xaa, 0x76, 0xe1,
- 0x00, 0x01, 0xaa, 0xaa, 0x76, 0xe1, 0x00, 0x02,
- 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0xee, 0xfc, 0xf4, 0x95, 0x71, 0x06, 0x00, 0x14,
- 0x71, 0x07, 0x00, 0x13, 0x71, 0x08, 0x00, 0x12,
- 0x71, 0x09, 0x00, 0x15, 0x77, 0x10, 0x00, 0xff,
- 0xf4, 0xaa, 0xf8, 0x30, 0x0d, 0x44, 0x49, 0x13,
- 0x53, 0xf8, 0x2a, 0x0c, 0x4f, 0xf8, 0x2a, 0x0c,
- 0x73, 0x12, 0x00, 0x0e, 0xf1, 0x66, 0x00, 0x0d,
- 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x01,
- 0x71, 0xe1, 0x24, 0x00, 0x00, 0x11, 0xf4, 0xa9,
- 0xf8, 0x30, 0x0d, 0x17, 0x77, 0x10, 0x00, 0x02,
- 0xf4, 0xa9, 0xf8, 0x30, 0x0c, 0xec, 0x77, 0x11,
- 0x29, 0x8a, 0x76, 0x81, 0x00, 0x00, 0xe8, 0x00,
- 0x77, 0x14, 0x00, 0x00, 0x77, 0x13, 0x00, 0x00,
- 0xf0, 0x73, 0x0d, 0x48, 0x6c, 0x83, 0x0c, 0xfa,
- 0x77, 0x11, 0x29, 0x8a, 0x48, 0x12, 0xf0, 0xe8,
- 0xf0, 0x40, 0x80, 0x00, 0x80, 0x81, 0xe8, 0x00,
- 0x77, 0x14, 0x00, 0x00, 0xf0, 0x73, 0x0d, 0x48,
- 0x49, 0x13, 0xf3, 0x40, 0x80, 0x00, 0x81, 0xf8,
- 0x29, 0x8a, 0x61, 0xf8, 0x00, 0x15, 0x00, 0x01,
- 0xf8, 0x20, 0x0d, 0x07, 0x69, 0xf8, 0x29, 0x8a,
- 0x40, 0x00, 0x61, 0xf8, 0x00, 0x14, 0x00, 0x01,
- 0xf8, 0x20, 0x0d, 0x0f, 0x69, 0xf8, 0x29, 0x8a,
- 0x20, 0x00, 0x77, 0x11, 0x29, 0x8a, 0x49, 0x12,
- 0xf3, 0xe8, 0x1b, 0x81, 0x81, 0x81, 0xf0, 0x73,
- 0x0d, 0x48, 0x11, 0xf8, 0x29, 0x84, 0xf8, 0x4c,
- 0x0d, 0x37, 0x77, 0x11, 0x29, 0x88, 0x76, 0x81,
- 0xaa, 0xaa, 0x11, 0xf8, 0x29, 0x85, 0xf3, 0x10,
- 0x00, 0x01, 0xf3, 0x40, 0xaa, 0x00, 0x81, 0xe1,
- 0x00, 0x01, 0x76, 0x00, 0x00, 0x02, 0x80, 0x01,
- 0x70, 0x02, 0x00, 0x14, 0x70, 0x03, 0x00, 0x13,
- 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 0x48, 0x11,
- 0x71, 0xf8, 0x29, 0x85, 0x29, 0x84, 0xf0, 0x73,
- 0x0d, 0x73, 0x76, 0x00, 0x00, 0x00, 0x80, 0x01,
- 0x76, 0x02, 0x00, 0x00, 0x70, 0x03, 0x00, 0x13,
- 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 0xe8, 0x00,
- 0xf0, 0x73, 0x0d, 0x73, 0x77, 0x11, 0x29, 0x8a,
- 0x70, 0x81, 0x00, 0x13, 0x11, 0xf8, 0x29, 0x84,
- 0xf8, 0x4c, 0x0d, 0x68, 0x77, 0x11, 0x29, 0x88,
- 0x76, 0x81, 0xaa, 0xaa, 0x11, 0xf8, 0x29, 0x85,
- 0xf3, 0x10, 0x00, 0x01, 0xf3, 0x40, 0xaa, 0x00,
- 0x81, 0xe1, 0x00, 0x01, 0x76, 0x00, 0x00, 0x03,
- 0x80, 0x01, 0x70, 0x02, 0x00, 0x14, 0x70, 0x03,
- 0x00, 0x13, 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95,
- 0x48, 0x11, 0x71, 0xf8, 0x29, 0x85, 0x29, 0x84,
- 0xf0, 0x73, 0x0d, 0x73, 0x76, 0x00, 0x00, 0x01,
- 0x80, 0x01, 0x70, 0x02, 0x00, 0x14, 0x70, 0x03,
- 0x00, 0x13, 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95,
- 0x48, 0x11, 0x6b, 0xf8, 0x29, 0x84, 0xff, 0xff,
- 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0xf5, 0x40, 0xf4, 0x95, 0x48, 0x0b, 0xf4, 0x78,
- 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0xe1,
- 0xff, 0xb9, 0x0d, 0x88, 0xf2, 0x73, 0x0d, 0xa5,
- 0xf4, 0x95, 0xe8, 0x60, 0xf2, 0x00, 0x00, 0x06,
- 0x61, 0xf8, 0x00, 0x11, 0x00, 0x20, 0xf8, 0x30,
- 0x0d, 0x98, 0x61, 0xf8, 0x00, 0x0b, 0x00, 0x01,
- 0xf8, 0x20, 0x0d, 0xa3, 0xf2, 0x00, 0x00, 0x07,
- 0xf0, 0x73, 0x0d, 0xa3, 0x61, 0xf8, 0x00, 0x0b,
- 0x00, 0x01, 0xf8, 0x20, 0x0d, 0xa1, 0xf2, 0x73,
- 0x0d, 0xa3, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00,
- 0x00, 0x02, 0x48, 0x08, 0xf4, 0x7f, 0x8a, 0x11,
- 0xfc, 0x00, 0xee, 0xff, 0xf0, 0x74, 0x07, 0xfd,
- 0xf0, 0x74, 0x07, 0x44, 0xf0, 0x74, 0x0d, 0xb4,
- 0xf0, 0x74, 0x02, 0x05, 0xf0, 0x74, 0x04, 0x60,
- 0xf0, 0x73, 0x0d, 0xaa, 0xee, 0xfd, 0x10, 0xf8,
- 0x2a, 0xa3, 0xf8, 0x44, 0x0d, 0xcb, 0x10, 0xf8,
- 0x2a, 0xa4, 0xf8, 0x45, 0x0d, 0xd7, 0x76, 0x00,
- 0x02, 0x00, 0xf2, 0x74, 0x09, 0xe8, 0xf0, 0x20,
- 0x22, 0x00, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x00,
- 0x76, 0xf8, 0x2a, 0xa7, 0x00, 0x00, 0xf0, 0x73,
- 0x0d, 0xd7, 0x76, 0x00, 0x02, 0x00, 0xf2, 0x74,
- 0x09, 0xe8, 0xf0, 0x20, 0x20, 0x00, 0x76, 0xf8,
- 0x2a, 0xa3, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa7,
- 0x00, 0x01, 0xf0, 0x74, 0x0c, 0x5e, 0xf0, 0xe0,
- 0xf0, 0x10, 0x3a, 0x98, 0xf8, 0x47, 0x0d, 0xe1,
- 0x76, 0xf8, 0x27, 0x6e, 0x00, 0x00, 0xee, 0x03,
- 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 0x77, 0x11,
- 0x20, 0x00, 0x76, 0x00, 0xaa, 0xaa, 0x76, 0x01,
- 0x02, 0x00, 0xf2, 0x74, 0x06, 0x6c, 0xf4, 0x95,
- 0x48, 0x11, 0x76, 0x00, 0x55, 0x55, 0x76, 0x01,
- 0x02, 0x00, 0x48, 0x11, 0xf2, 0x74, 0x06, 0x6c,
- 0xf0, 0x00, 0x02, 0x00, 0x76, 0xf8, 0x2a, 0xa3,
- 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x00,
- 0xe8, 0x00, 0x4e, 0x00, 0xfb, 0x80, 0x15, 0x3e,
- 0xf4, 0x95, 0xe8, 0x04, 0x80, 0xf8, 0x2a, 0xa5,
- 0x76, 0x00, 0x2a, 0xa8, 0xf9, 0x80, 0x14, 0x87,
- 0x76, 0x00, 0x2a, 0xad, 0xfb, 0x80, 0x13, 0x62,
- 0xf4, 0x95, 0xe8, 0x02, 0x10, 0xf8, 0x2a, 0xa5,
- 0xf9, 0x80, 0x14, 0x63, 0xfb, 0x80, 0x16, 0x66,
- 0xf4, 0x95, 0xe8, 0x1c, 0xfb, 0x80, 0x16, 0x87,
- 0xf4, 0x95, 0xe8, 0x1c, 0xe8, 0x01, 0x4e, 0x00,
- 0xfb, 0x80, 0x17, 0xd6, 0xf4, 0x95, 0xe8, 0x00,
- 0x80, 0xf8, 0x2a, 0xa6, 0x76, 0x00, 0x2a, 0xb7,
- 0xf9, 0x80, 0x16, 0xaa, 0x10, 0xf8, 0x2a, 0xa6,
- 0xf9, 0x80, 0x17, 0x5c, 0x10, 0xf8, 0x2a, 0xa6,
- 0xf9, 0x80, 0x17, 0x6f, 0xee, 0x02, 0x8a, 0x11,
- 0xfc, 0x00, 0xf4, 0x95, 0x4a, 0x08, 0x4a, 0x09,
- 0x4a, 0x0a, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8,
- 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
- 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
- 0x10, 0xf8, 0x2a, 0xa7, 0xf8, 0x44, 0x0e, 0x4b,
- 0x76, 0xf8, 0x2a, 0xa3, 0x00, 0x01, 0xf0, 0x73,
- 0x0e, 0x4e, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x01,
- 0x8a, 0x1d, 0x8a, 0x07, 0x8a, 0x0a, 0x8a, 0x09,
- 0x8a, 0x08, 0xf4, 0xeb, 0x4a, 0x11, 0x4a, 0x16,
- 0x4a, 0x17, 0xee, 0xfe, 0x88, 0x0e, 0x71, 0x08,
- 0x00, 0x16, 0x71, 0x06, 0x00, 0x17, 0x11, 0x07,
- 0xf0, 0x66, 0x00, 0x0d, 0xf0, 0x00, 0x25, 0xa0,
- 0x88, 0x11, 0x76, 0x01, 0x00, 0x06, 0x81, 0x00,
- 0xf2, 0x74, 0x06, 0xce, 0xf0, 0x00, 0x00, 0x01,
- 0x76, 0x01, 0x00, 0x06, 0x70, 0x00, 0x00, 0x16,
- 0x48, 0x11, 0xf2, 0x74, 0x06, 0xce, 0xf0, 0x00,
- 0x00, 0x07, 0x70, 0x81, 0x00, 0x17, 0xee, 0x02,
- 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00,
- 0x4a, 0x11, 0x88, 0x0e, 0x71, 0x02, 0x00, 0x12,
- 0x11, 0x03, 0xf0, 0x66, 0x00, 0x0d, 0xf0, 0x00,
- 0x24, 0x00, 0x88, 0x11, 0xf4, 0x95, 0x70, 0x81,
- 0x00, 0x12, 0x6e, 0xe2, 0xff, 0xfe, 0x0e, 0x8d,
- 0xf4, 0x95, 0xe8, 0x00, 0xe8, 0x01, 0x80, 0xe1,
- 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff,
- 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1,
- 0x00, 0x0b, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0c,
- 0x00, 0x00, 0x81, 0xe1, 0x00, 0x01, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfc, 0x88, 0x0e,
- 0xf4, 0x95, 0xf1, 0x66, 0x00, 0x0d, 0xf3, 0x00,
- 0x24, 0x00, 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95,
- 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x00, 0x76, 0xe1,
- 0x00, 0x0b, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
- 0x00, 0x01, 0x76, 0x00, 0x00, 0x00, 0x76, 0x01,
- 0x00, 0x00, 0x80, 0x02, 0x76, 0x03, 0x00, 0x00,
- 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95, 0xe8, 0x00,
- 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0x88, 0x19, 0xf4, 0x95, 0x73, 0x19, 0x00, 0x0e,
- 0xf1, 0x66, 0x00, 0x0d, 0xf2, 0x00, 0x24, 0x00,
- 0x77, 0x15, 0x25, 0xa0, 0x77, 0x14, 0x00, 0x00,
- 0x77, 0x1a, 0x00, 0x1f, 0xf0, 0x72, 0x0f, 0x14,
- 0xf6, 0xb8, 0x49, 0x19, 0x09, 0x85, 0xf8, 0x4c,
- 0x0f, 0x13, 0xf1, 0x00, 0x00, 0x05, 0x89, 0x11,
- 0x49, 0x15, 0xf3, 0x00, 0x00, 0x01, 0x89, 0x13,
- 0x49, 0x15, 0xf3, 0x00, 0x00, 0x07, 0x89, 0x12,
- 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
- 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
- 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
- 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
- 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
- 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x11,
- 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 0x0f, 0x13,
- 0x6d, 0x94, 0x6d, 0xed, 0x00, 0x0d, 0x48, 0x14,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16,
- 0x4a, 0x17, 0xee, 0xf8, 0x88, 0x17, 0x10, 0x0d,
- 0x80, 0x04, 0x10, 0x0c, 0x80, 0x05, 0x71, 0x0e,
- 0x00, 0x16, 0x73, 0x17, 0x00, 0x0e, 0xf0, 0x66,
- 0x00, 0x0d, 0xf0, 0x00, 0x24, 0x00, 0x88, 0x11,
- 0x10, 0xf8, 0x27, 0x63, 0xf8, 0x45, 0x0f, 0x32,
- 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17,
- 0x10, 0xf8, 0x27, 0x60, 0xf8, 0x44, 0x0f, 0x3d,
- 0x60, 0xe1, 0x00, 0x02, 0x00, 0x01, 0xf8, 0x20,
- 0x0f, 0x6d, 0xf0, 0x73, 0x11, 0x33, 0x10, 0x04,
- 0x80, 0x00, 0x10, 0x05, 0xf0, 0x74, 0x06, 0x9f,
- 0x11, 0x04, 0xf3, 0x00, 0x00, 0x01, 0x81, 0x04,
- 0x6d, 0x8e, 0x77, 0x10, 0x00, 0x01, 0x71, 0xe1,
- 0x00, 0x02, 0x00, 0x12, 0xf4, 0xaa, 0xf8, 0x30,
- 0x0f, 0x62, 0x77, 0x10, 0x00, 0x02, 0xf4, 0xaa,
- 0xf8, 0x30, 0x0f, 0x6d, 0x45, 0xe1, 0x00, 0x0b,
- 0x88, 0x10, 0x43, 0xe1, 0x00, 0x0c, 0x83, 0xf8,
- 0x00, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xaa,
- 0xf8, 0x30, 0x0f, 0x6d, 0xf0, 0x73, 0x0f, 0x96,
- 0xf5, 0x00, 0x81, 0x04, 0x49, 0x16, 0xf5, 0x20,
- 0x89, 0x16, 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x48, 0x16,
- 0xf8, 0x45, 0x11, 0x33, 0xf7, 0xb8, 0x71, 0xe1,
- 0x00, 0x02, 0x00, 0x12, 0x10, 0xf8, 0x00, 0x12,
- 0xf0, 0x10, 0x00, 0x03, 0xf8, 0x46, 0x0f, 0x8c,
- 0x10, 0xf8, 0x00, 0x12, 0xf0, 0x10, 0x00, 0x03,
- 0xf8, 0x45, 0x10, 0x16, 0x77, 0x10, 0x00, 0x01,
- 0xf4, 0xaa, 0xf8, 0x30, 0x0f, 0x9c, 0x77, 0x10,
- 0x00, 0x02, 0xf4, 0xaa, 0xf8, 0x30, 0x0f, 0xa8,
- 0xf0, 0x73, 0x0f, 0x96, 0x77, 0x10, 0x00, 0x04,
- 0xf4, 0xaa, 0xf8, 0x30, 0x10, 0xb7, 0x77, 0x10,
- 0x00, 0x05, 0xf4, 0xaa, 0xf8, 0x30, 0x10, 0xbc,
- 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17,
- 0xf0, 0x73, 0x11, 0x31, 0x76, 0xe1, 0x00, 0x0c,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1,
- 0x00, 0x02, 0x00, 0x02, 0x11, 0xe1, 0x00, 0x0c,
- 0xe8, 0x03, 0xf6, 0x20, 0x89, 0x12, 0xf4, 0x95,
- 0x77, 0x10, 0x00, 0x03, 0xf5, 0xaa, 0xf8, 0x30,
- 0x0f, 0xb6, 0x6b, 0xf8, 0x27, 0x6f, 0x00, 0x01,
- 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 0xf5, 0xae,
- 0xf8, 0x20, 0x0f, 0xbd, 0x48, 0x16, 0x80, 0x06,
- 0x88, 0x13, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x03,
- 0xf6, 0xab, 0xf8, 0x20, 0x0f, 0xc8, 0x6b, 0xf8,
- 0x27, 0x6f, 0x00, 0x01, 0x12, 0x06, 0xf8, 0x45,
- 0x10, 0x00, 0x10, 0xe1, 0x00, 0x04, 0x80, 0x00,
- 0x10, 0x05, 0x80, 0x01, 0x10, 0x04, 0x80, 0x02,
- 0x10, 0x06, 0x80, 0x03, 0x48, 0x11, 0xf2, 0x74,
- 0x07, 0x1e, 0xf0, 0x00, 0x00, 0x05, 0x10, 0x06,
- 0x00, 0xe1, 0x00, 0x04, 0x80, 0xe1, 0x00, 0x04,
- 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1,
- 0x00, 0x0c, 0x88, 0x12, 0x11, 0x06, 0x10, 0x04,
- 0xf6, 0x00, 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20,
- 0x88, 0x16, 0x89, 0x13, 0xf4, 0x95, 0x77, 0x10,
- 0x00, 0x03, 0xf6, 0xab, 0xf8, 0x20, 0x0f, 0xf5,
- 0x6b, 0xf8, 0x27, 0x6f, 0x00, 0x01, 0x77, 0x10,
- 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x13,
- 0xf6, 0xab, 0xf8, 0x20, 0x10, 0x00, 0x6b, 0xf8,
- 0x27, 0x6f, 0x00, 0x01, 0x6c, 0xe2, 0xff, 0xfd,
- 0x11, 0x31, 0xf6, 0xb8, 0x6f, 0xe1, 0x00, 0x05,
- 0x0c, 0x48, 0x6f, 0xe1, 0x00, 0x06, 0x0c, 0x18,
- 0xf0, 0x30, 0x0f, 0xff, 0xf0, 0x00, 0x00, 0x03,
- 0x80, 0xe1, 0x00, 0x0b, 0x76, 0xe1, 0x00, 0x02,
- 0x00, 0x03, 0x48, 0x16, 0xf8, 0x45, 0x11, 0x33,
- 0x71, 0xe1, 0x00, 0x0c, 0x00, 0x12, 0x10, 0xe1,
- 0x00, 0x0b, 0x49, 0x12, 0xf6, 0x20, 0x88, 0x13,
- 0xe8, 0x0c, 0xf6, 0x20, 0x88, 0x10, 0xf4, 0x95,
- 0xf4, 0x95, 0xf5, 0xab, 0xf8, 0x20, 0x10, 0x27,
- 0x48, 0x13, 0x80, 0x06, 0x88, 0x10, 0xf4, 0x95,
- 0xf4, 0x95, 0xf5, 0xae, 0xf8, 0x20, 0x10, 0x30,
- 0x70, 0x06, 0x00, 0x16, 0x12, 0x06, 0xf8, 0x45,
- 0x10, 0x5f, 0x10, 0xe1, 0x00, 0x04, 0x80, 0x00,
- 0x10, 0x05, 0x80, 0x01, 0x10, 0x04, 0x80, 0x02,
- 0x10, 0x06, 0x80, 0x03, 0x48, 0x11, 0xf2, 0x74,
- 0x07, 0x1e, 0xf0, 0x00, 0x00, 0x05, 0x10, 0x06,
- 0x00, 0xe1, 0x00, 0x04, 0x80, 0xe1, 0x00, 0x04,
- 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1,
- 0x00, 0x0c, 0x88, 0x12, 0x11, 0x06, 0x10, 0x04,
- 0xf6, 0x00, 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20,
- 0x88, 0x16, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x0c,
- 0x71, 0xe1, 0x00, 0x04, 0x00, 0x13, 0xf6, 0xab,
- 0xf8, 0x20, 0x10, 0x5f, 0x6b, 0xf8, 0x27, 0x6f,
- 0x00, 0x01, 0x77, 0x10, 0x00, 0x0c, 0xf6, 0xaa,
- 0xf8, 0x20, 0x10, 0x6b, 0xf2, 0x74, 0x0e, 0x9f,
- 0xf4, 0x95, 0x48, 0x17, 0x71, 0xe1, 0x00, 0x0c,
- 0x00, 0x12, 0x77, 0x10, 0x00, 0x0c, 0xf4, 0xaa,
- 0xf8, 0x30, 0x10, 0x7c, 0x77, 0x10, 0x00, 0x0c,
- 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x13, 0xf6, 0xab,
- 0xf8, 0x30, 0x10, 0xb4, 0xe7, 0x30, 0xf7, 0xaa,
- 0xf8, 0x30, 0x10, 0xb4, 0xf2, 0x74, 0x0e, 0xc1,
- 0xf4, 0x95, 0x48, 0x17, 0x88, 0x12, 0xf4, 0x95,
- 0xf4, 0x95, 0x6c, 0x82, 0x10, 0x8d, 0x76, 0xe1,
- 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
- 0x00, 0x05, 0xf0, 0x73, 0x10, 0xb4, 0x76, 0xe1,
- 0x00, 0x02, 0x00, 0x04, 0x77, 0x10, 0x00, 0x0c,
- 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x12, 0xf5, 0xaa,
- 0xf8, 0x20, 0x10, 0x9a, 0xf0, 0x73, 0x10, 0x9c,
- 0x77, 0x12, 0x00, 0x0c, 0x76, 0x00, 0x00, 0x00,
- 0x70, 0x01, 0x00, 0x12, 0x70, 0x02, 0x00, 0x17,
- 0x76, 0x03, 0x00, 0x01, 0x48, 0x11, 0xf2, 0x74,
- 0x0c, 0xb9, 0xf0, 0x00, 0x00, 0x05, 0x76, 0xe1,
- 0x00, 0x04, 0x00, 0x00, 0x77, 0x10, 0x00, 0x0c,
- 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x12, 0xf6, 0xaa,
- 0xf8, 0x20, 0x11, 0x1c, 0x48, 0x16, 0xf8, 0x45,
- 0x11, 0x33, 0x60, 0xe1, 0x00, 0x02, 0x00, 0x05,
- 0xf8, 0x20, 0x10, 0xdf, 0x10, 0xe1, 0x00, 0x0b,
- 0x08, 0xe1, 0x00, 0x0c, 0x11, 0xe1, 0x00, 0x04,
- 0xf8, 0x4d, 0x10, 0xc7, 0x6b, 0xf8, 0x27, 0x6f,
- 0x00, 0x01, 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95,
- 0xf5, 0xae, 0xf8, 0x20, 0x10, 0xcf, 0x48, 0x16,
- 0xf4, 0x95, 0x48, 0x08, 0xf8, 0x45, 0x11, 0x16,
- 0x6f, 0xe1, 0x00, 0x0c, 0x0d, 0x00, 0x81, 0xe1,
- 0x00, 0x0c, 0x11, 0x04, 0xf5, 0x00, 0x81, 0x04,
- 0x49, 0x16, 0xf5, 0x20, 0x89, 0x16, 0xf0, 0x73,
- 0x11, 0x0e, 0x10, 0xe1, 0x00, 0x0b, 0x71, 0xe1,
- 0x00, 0x0c, 0x00, 0x12, 0x88, 0x10, 0xf4, 0x95,
- 0xf4, 0x95, 0xf6, 0xaa, 0xf8, 0x30, 0x11, 0x16,
- 0x49, 0x12, 0xf6, 0x20, 0x88, 0x10, 0xf4, 0x95,
- 0xf4, 0x95, 0xf5, 0xae, 0xf8, 0x20, 0x10, 0xf3,
- 0x48, 0x16, 0x80, 0x06, 0x48, 0x08, 0xf8, 0x45,
- 0x11, 0x16, 0x10, 0x04, 0x70, 0x02, 0x00, 0x17,
- 0x80, 0x00, 0x76, 0x03, 0x00, 0x00, 0x10, 0x06,
- 0x80, 0x01, 0x10, 0x05, 0xf0, 0x74, 0x0c, 0xb9,
- 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1,
- 0x00, 0x0c, 0x11, 0x06, 0x10, 0x04, 0xf6, 0x00,
- 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20, 0x88, 0x16,
- 0x10, 0xe1, 0x00, 0x0c, 0x08, 0xe1, 0x00, 0x0b,
- 0xf8, 0x45, 0x11, 0x1c, 0xf0, 0x73, 0x11, 0x31,
- 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17,
- 0xf0, 0x73, 0x11, 0x33, 0x76, 0xe1, 0x00, 0x0c,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0x02, 0x00, 0x01, 0x10, 0x04,
- 0x80, 0x00, 0x10, 0x05, 0xf0, 0x74, 0x06, 0x9f,
- 0x88, 0x12, 0xf4, 0x95, 0x77, 0x10, 0x00, 0xff,
- 0xf4, 0xaa, 0xf8, 0x30, 0x11, 0x33, 0x6c, 0x86,
- 0x0f, 0x70, 0xee, 0x08, 0x8a, 0x17, 0x8a, 0x16,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfc,
- 0xf4, 0x95, 0x71, 0x06, 0x00, 0x12, 0x88, 0x11,
- 0x73, 0x12, 0x00, 0x0e, 0xf1, 0x66, 0x00, 0x0d,
- 0xf3, 0x00, 0x24, 0x00, 0x89, 0x14, 0x13, 0x81,
- 0xf7, 0x7a, 0xf3, 0x30, 0x00, 0x01, 0x81, 0xf8,
- 0x27, 0x60, 0x13, 0xe1, 0x00, 0x01, 0xf7, 0x7c,
- 0xf3, 0x30, 0x00, 0x03, 0x81, 0xf8, 0x27, 0x61,
- 0xe9, 0x0f, 0x19, 0xe1, 0x00, 0x01, 0x81, 0xf8,
- 0x27, 0x62, 0x71, 0xe4, 0x00, 0x03, 0x00, 0x13,
- 0xf6, 0xb8, 0x49, 0x13, 0xf3, 0x00, 0x00, 0x01,
- 0xf3, 0x30, 0x00, 0x0f, 0x49, 0x0b, 0x09, 0xf8,
- 0x27, 0x62, 0xf8, 0x4d, 0x11, 0x75, 0x77, 0x10,
- 0x00, 0xff, 0xf4, 0xab, 0xf8, 0x30, 0x11, 0x75,
- 0x57, 0xf8, 0x27, 0x6c, 0xf3, 0x00, 0x00, 0x01,
- 0x4f, 0xf8, 0x27, 0x6c, 0x76, 0xf8, 0x27, 0x63,
- 0x00, 0x01, 0xf0, 0x73, 0x11, 0x78, 0x76, 0xf8,
- 0x27, 0x63, 0x00, 0x00, 0x70, 0xe4, 0x00, 0x03,
- 0x27, 0x62, 0x76, 0xf8, 0x27, 0x64, 0x00, 0x00,
- 0x11, 0xf8, 0x27, 0x61, 0x61, 0xf8, 0x00, 0x0b,
- 0x00, 0x02, 0xf8, 0x20, 0x11, 0x8d, 0xe9, 0x01,
- 0x6f, 0xe1, 0x00, 0x02, 0x0f, 0x18, 0x81, 0xf8,
- 0x27, 0x64, 0x11, 0xf8, 0x27, 0x61, 0x61, 0xf8,
- 0x00, 0x0b, 0x00, 0x01, 0xf8, 0x20, 0x11, 0xa9,
- 0x10, 0xf8, 0x27, 0x64, 0xf1, 0x00, 0x00, 0x04,
- 0x89, 0x13, 0xe9, 0xb8, 0xf5, 0x20, 0x81, 0xf8,
- 0x27, 0x65, 0x60, 0x84, 0x00, 0x02, 0xf8, 0x20,
- 0x11, 0xa9, 0x70, 0x00, 0x00, 0x11, 0x70, 0x01,
- 0x00, 0x13, 0x70, 0x02, 0x27, 0x65, 0xf2, 0x74,
- 0x0f, 0x18, 0xf4, 0x95, 0x48, 0x12, 0xee, 0x04,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16,
- 0x4a, 0x17, 0xee, 0xfc, 0xe8, 0x00, 0x4e, 0xf8,
- 0x27, 0x66, 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x68,
- 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x6c, 0xe8, 0x00,
- 0x4e, 0xf8, 0x27, 0x6a, 0x77, 0x12, 0x27, 0x40,
- 0x77, 0x11, 0x24, 0x00, 0x77, 0x1a, 0x00, 0x1f,
- 0xf0, 0x72, 0x11, 0xdb, 0x70, 0x92, 0x00, 0x11,
- 0x76, 0xe1, 0x00, 0x01, 0xff, 0xff, 0x76, 0x81,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff, 0x76, 0xe1,
- 0x00, 0x0c, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00,
- 0x6d, 0xe9, 0x00, 0x0d, 0xf0, 0x20, 0x25, 0xa0,
- 0xf1, 0x00, 0x00, 0x07, 0x89, 0x11, 0xf1, 0x00,
- 0x00, 0x01, 0x81, 0x02, 0x88, 0x16, 0xf4, 0x95,
- 0x77, 0x17, 0x00, 0x20, 0x76, 0x86, 0x00, 0xff,
- 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0x06,
- 0x10, 0x02, 0xf0, 0x74, 0x06, 0x6c, 0x76, 0x00,
- 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0xf2, 0x74,
- 0x06, 0x6c, 0xf4, 0x95, 0x48, 0x11, 0x10, 0x02,
- 0xf0, 0x00, 0x00, 0x0d, 0x80, 0x02, 0x6d, 0xe9,
- 0x00, 0x0d, 0x6d, 0xee, 0x00, 0x0d, 0x6c, 0xef,
- 0xff, 0xff, 0x11, 0xe8, 0xf0, 0x74, 0x0c, 0x9d,
- 0xee, 0x04, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11,
- 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17,
- 0xee, 0xfa, 0x88, 0x11, 0x10, 0x0a, 0x49, 0x11,
- 0xf8, 0x4d, 0x12, 0x9f, 0x48, 0x08, 0xf8, 0x45,
- 0x12, 0x9f, 0x80, 0x04, 0x12, 0x81, 0xf5, 0x78,
- 0x89, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0xe2,
- 0xff, 0xb9, 0x12, 0x8a, 0x61, 0xf8, 0x00, 0x08,
- 0x00, 0x80, 0xf8, 0x30, 0x12, 0x8a, 0x13, 0xe1,
- 0x00, 0x01, 0xf0, 0xe8, 0xf7, 0x78, 0xf1, 0xa0,
- 0xf2, 0x30, 0x1f, 0xff, 0x88, 0x17, 0xf4, 0x95,
- 0x77, 0x12, 0x24, 0x00, 0x77, 0x16, 0x00, 0x00,
- 0x77, 0x13, 0x00, 0x20, 0xf6, 0xb8, 0x48, 0x17,
- 0x08, 0xe2, 0x00, 0x01, 0xf8, 0x45, 0x12, 0x42,
- 0x6d, 0xea, 0x00, 0x0d, 0x6d, 0x96, 0x6c, 0xeb,
- 0xff, 0xff, 0x12, 0x34, 0xf0, 0x73, 0x12, 0x90,
- 0x56, 0xf8, 0x27, 0x6a, 0xf0, 0x00, 0x00, 0x01,
- 0x4e, 0xf8, 0x27, 0x6a, 0x60, 0x82, 0x00, 0x01,
- 0xf8, 0x30, 0x12, 0x54, 0x70, 0x00, 0x00, 0x16,
- 0xf2, 0x74, 0x11, 0x38, 0xf4, 0x95, 0x48, 0x11,
- 0xf0, 0x73, 0x12, 0x90, 0x70, 0x00, 0x00, 0x16,
- 0xf2, 0x74, 0x11, 0x38, 0xf4, 0x95, 0x48, 0x11,
- 0x72, 0x10, 0x2a, 0x9e, 0xf4, 0x95, 0xf4, 0xaf,
- 0xf8, 0x30, 0x12, 0x6e, 0x76, 0x00, 0x00, 0x00,
- 0x76, 0x01, 0x00, 0xbc, 0x70, 0x02, 0x00, 0x16,
- 0x76, 0x03, 0x00, 0x00, 0xf2, 0x74, 0x0c, 0xb9,
- 0xf4, 0x95, 0x48, 0x11, 0xf0, 0x73, 0x12, 0x90,
- 0x10, 0xf8, 0x27, 0x6e, 0xf8, 0x44, 0x12, 0x90,
- 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0xbc,
- 0x70, 0x02, 0x00, 0x16, 0x76, 0x03, 0x00, 0x00,
- 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95, 0x48, 0x11,
- 0xf0, 0x74, 0x0c, 0x5e, 0xf0, 0xe0, 0xf0, 0x10,
- 0x13, 0x88, 0xf8, 0x42, 0x12, 0x90, 0x76, 0xf8,
- 0x27, 0x6e, 0x00, 0x01, 0xf0, 0x73, 0x12, 0x90,
- 0x56, 0xf8, 0x27, 0x66, 0xf0, 0x00, 0x00, 0x01,
- 0x4e, 0xf8, 0x27, 0x66, 0x6d, 0xe9, 0x00, 0x5e,
- 0x56, 0xf8, 0x27, 0x68, 0xf0, 0x00, 0x00, 0x01,
- 0x4e, 0xf8, 0x27, 0x68, 0x71, 0x04, 0x00, 0x12,
- 0x6e, 0xea, 0xff, 0xff, 0x12, 0x18, 0x70, 0x04,
- 0x00, 0x12, 0xee, 0x06, 0x8a, 0x17, 0x8a, 0x16,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
- 0x88, 0x0e, 0xf4, 0x95, 0xf0, 0x66, 0x00, 0x0d,
- 0xf0, 0x00, 0x25, 0xa0, 0x88, 0x11, 0xf4, 0x95,
- 0xf4, 0x95, 0x76, 0x81, 0x00, 0xff, 0x76, 0x00,
- 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0xf2, 0x74,
- 0x06, 0x6c, 0xf0, 0x00, 0x00, 0x01, 0x76, 0x00,
- 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0x48, 0x11,
- 0xf2, 0x74, 0x06, 0x6c, 0xf0, 0x00, 0x00, 0x07,
- 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
- 0x88, 0x0e, 0xf4, 0x95, 0xf0, 0x66, 0x00, 0x0d,
- 0xf0, 0x00, 0x24, 0x00, 0x88, 0x11, 0xf4, 0x95,
- 0xf4, 0x95, 0x76, 0xe1, 0x00, 0x01, 0xff, 0xff,
- 0x76, 0x81, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff,
- 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95,
- 0x13, 0x03, 0x88, 0x11, 0xfa, 0x4d, 0x12, 0xec,
- 0x71, 0x02, 0x00, 0x12, 0xf3, 0x10, 0x00, 0x01,
- 0x89, 0x1a, 0xf4, 0x95, 0xf0, 0x72, 0x12, 0xeb,
- 0x70, 0x91, 0x00, 0x12, 0x8a, 0x11, 0xfc, 0x00,
- 0xf4, 0x95, 0x4a, 0x0b, 0x4a, 0x0c, 0x4a, 0x0d,
- 0xf7, 0xb8, 0xee, 0xfe, 0x10, 0xf8, 0x00, 0x08,
- 0x11, 0x06, 0xf1, 0xc0, 0x83, 0x00, 0xf4, 0x85,
- 0x11, 0x06, 0xf7, 0x85, 0x81, 0x06, 0xf6, 0xb8,
- 0xec, 0x0f, 0x1e, 0x06, 0x61, 0x00, 0x80, 0x00,
- 0xf8, 0x20, 0x13, 0x05, 0xf4, 0x84, 0xee, 0x02,
- 0x8a, 0x0d, 0x8a, 0x0c, 0x8a, 0x0b, 0xfc, 0x00,
- 0xf4, 0x95, 0x4a, 0x0b, 0x4a, 0x0c, 0x4a, 0x0d,
- 0xee, 0xfe, 0xf7, 0xb8, 0x80, 0x00, 0x10, 0xf8,
- 0x00, 0x08, 0xf4, 0x85, 0x11, 0x06, 0xf7, 0x85,
- 0x81, 0x06, 0xf6, 0xb8, 0xec, 0x0f, 0x1e, 0x06,
- 0xf0, 0xf0, 0x61, 0x00, 0x80, 0x00, 0xf8, 0x20,
- 0x13, 0x20, 0xf4, 0x84, 0xee, 0x02, 0x8a, 0x0d,
- 0x8a, 0x0c, 0x8a, 0x0b, 0xfc, 0x00, 0x4a, 0x11,
- 0x77, 0x11, 0x00, 0x7b, 0x76, 0x81, 0x2e, 0xec,
- 0x77, 0x11, 0x00, 0x7b, 0xee, 0xff, 0x71, 0x81,
- 0x00, 0x11, 0xee, 0x01, 0x76, 0xe1, 0x00, 0x01,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0x06, 0x00, 0x00, 0x76, 0xe1,
- 0x00, 0x62, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x76,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x92, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0x94, 0x00, 0x00, 0x76, 0xe1,
- 0x00, 0xb0, 0x00, 0x00, 0x76, 0xe1, 0x00, 0xb3,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0xbe, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0xbf, 0x00, 0x00, 0x76, 0xe1,
- 0x00, 0xc1, 0x00, 0x00, 0x76, 0xe1, 0x00, 0xc3,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0xc5, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0xc7, 0x00, 0x00, 0x76, 0x81,
- 0x00, 0x00, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
- 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xff,
- 0xf4, 0x95, 0x71, 0x06, 0x00, 0x16, 0xfb, 0x80,
- 0x16, 0xa2, 0x88, 0x17, 0xf4, 0x95, 0xf7, 0xb8,
- 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x02,
- 0xfa, 0x46, 0x13, 0x88, 0x77, 0x11, 0x00, 0x00,
- 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x02,
- 0xf8, 0x45, 0x13, 0xf9, 0x10, 0xf8, 0x00, 0x17,
- 0xf8, 0x45, 0x14, 0x39, 0x10, 0xf8, 0x00, 0x17,
- 0xf0, 0x10, 0x00, 0x01, 0xf8, 0x45, 0x14, 0x1f,
- 0xf0, 0x73, 0x14, 0x52, 0x10, 0xf8, 0x00, 0x17,
- 0xf0, 0x10, 0x00, 0x03, 0xf8, 0x45, 0x13, 0xd3,
- 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x06,
- 0xf8, 0x44, 0x14, 0x52, 0x77, 0x12, 0x00, 0x7b,
- 0x71, 0x82, 0x00, 0x14, 0x61, 0xe4, 0x00, 0x07,
- 0x00, 0x40, 0xf8, 0x30, 0x14, 0x52, 0x49, 0x14,
- 0x48, 0x17, 0xf6, 0x00, 0x88, 0x12, 0xf4, 0x95,
- 0x77, 0x13, 0x00, 0x55, 0x77, 0x11, 0x00, 0x57,
- 0x6d, 0xea, 0x00, 0x3b, 0xe5, 0x01, 0x10, 0xe6,
- 0x00, 0x06, 0x80, 0x81, 0x48, 0x14, 0x00, 0xf8,
- 0x00, 0x17, 0x88, 0x12, 0xf4, 0x95, 0x77, 0x11,
- 0x00, 0x55, 0x10, 0xe2, 0x00, 0x40, 0x80, 0x81,
- 0x77, 0x11, 0x00, 0x57, 0x10, 0xe6, 0x00, 0x07,
- 0x80, 0x81, 0x77, 0x11, 0x00, 0x55, 0x10, 0xe2,
- 0x00, 0x45, 0x80, 0x81, 0x10, 0xe6, 0x00, 0x08,
- 0x77, 0x11, 0x00, 0x57, 0x80, 0x81, 0x77, 0x11,
- 0x00, 0x55, 0x10, 0xe2, 0x00, 0x4a, 0x80, 0x81,
- 0x77, 0x11, 0x00, 0x57, 0x10, 0xe6, 0x00, 0x09,
- 0x80, 0x81, 0xf2, 0x73, 0x14, 0x52, 0x77, 0x11,
- 0x03, 0xc0, 0x77, 0x12, 0x00, 0x7b, 0x10, 0x82,
- 0xf0, 0x00, 0x00, 0x07, 0x88, 0x13, 0xf4, 0x95,
- 0xf4, 0x95, 0x96, 0x1b, 0xf8, 0x30, 0x14, 0x52,
- 0x10, 0xe3, 0x00, 0x35, 0x77, 0x12, 0x00, 0x55,
- 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6,
- 0x00, 0x04, 0x80, 0x82, 0x77, 0x12, 0x00, 0x55,
- 0x10, 0xe3, 0x00, 0x37, 0x80, 0x82, 0x77, 0x12,
- 0x00, 0x57, 0x10, 0xe6, 0x00, 0x05, 0x80, 0x82,
- 0x48, 0x11, 0xf0, 0x40, 0x00, 0x10, 0xf2, 0x73,
- 0x14, 0x50, 0xf0, 0x40, 0x00, 0x20, 0x77, 0x12,
- 0x00, 0x7b, 0x10, 0x82, 0xf0, 0x00, 0x00, 0x07,
- 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x96, 0x0d,
- 0xf8, 0x30, 0x14, 0x52, 0x10, 0xe2, 0x00, 0x34,
- 0x77, 0x13, 0x00, 0x55, 0x80, 0x83, 0x77, 0x13,
- 0x00, 0x57, 0x10, 0xe6, 0x00, 0x02, 0x80, 0x83,
- 0x10, 0xe2, 0x00, 0x36, 0x77, 0x12, 0x00, 0x55,
- 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6,
- 0x00, 0x03, 0x80, 0x82, 0x48, 0x11, 0xf0, 0x40,
- 0x00, 0x04, 0xf2, 0x73, 0x14, 0x50, 0xf0, 0x40,
- 0x00, 0x08, 0x77, 0x12, 0x00, 0x7b, 0x10, 0x82,
- 0xf0, 0x00, 0x00, 0x07, 0x88, 0x12, 0xf4, 0x95,
- 0xf4, 0x95, 0x96, 0x0e, 0xf8, 0x30, 0x14, 0x52,
- 0x10, 0xe2, 0x00, 0x33, 0x77, 0x12, 0x00, 0x55,
- 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6,
- 0x00, 0x01, 0x80, 0x82, 0x48, 0x11, 0xf2, 0x73,
- 0x14, 0x50, 0xf0, 0x40, 0x00, 0x02, 0x77, 0x12,
- 0x00, 0x7b, 0x10, 0x82, 0xf0, 0x00, 0x00, 0x07,
- 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x96, 0x0f,
- 0xf8, 0x30, 0x14, 0x52, 0x10, 0xe2, 0x00, 0x32,
- 0x77, 0x12, 0x00, 0x55, 0x77, 0x13, 0x00, 0x57,
- 0x80, 0x82, 0x48, 0x11, 0xe7, 0x62, 0xf0, 0x40,
- 0x00, 0x01, 0xe5, 0x01, 0x88, 0x11, 0xf4, 0x95,
- 0x77, 0x12, 0x00, 0x7b, 0x48, 0x11, 0x71, 0x82,
- 0x00, 0x12, 0x1a, 0xe2, 0x00, 0x07, 0x80, 0xe2,
- 0x00, 0x07, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01,
- 0x8a, 0x17, 0x48, 0x11, 0x8a, 0x16, 0x8a, 0x11,
- 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0x77, 0x0e,
- 0x00, 0x05, 0x77, 0x12, 0x00, 0x55, 0xe8, 0x04,
- 0xf6, 0xb8, 0x28, 0xe1, 0x00, 0x02, 0xee, 0xff,
- 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0xf0, 0x20,
- 0x80, 0x00, 0xee, 0x01, 0x1a, 0x82, 0x77, 0x12,
- 0x00, 0x57, 0x80, 0x82, 0xe8, 0x01, 0x32, 0xe1,
- 0x00, 0x02, 0xf5, 0x82, 0x77, 0x11, 0x00, 0x54,
- 0xf6, 0x93, 0x18, 0x81, 0x77, 0x11, 0x00, 0x54,
- 0xf2, 0xa0, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95,
- 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95,
- 0x71, 0x04, 0x00, 0x11, 0xfb, 0x80, 0x16, 0xa2,
- 0x88, 0x16, 0xf4, 0x95, 0x77, 0x12, 0x00, 0x55,
- 0x10, 0xe6, 0x00, 0x03, 0x80, 0x82, 0x77, 0x12,
- 0x00, 0x56, 0x10, 0xe1, 0x00, 0x02, 0x77, 0x13,
- 0x00, 0x56, 0x80, 0x82, 0x77, 0x12, 0x00, 0x56,
- 0x10, 0xe1, 0x00, 0x03, 0x80, 0x82, 0x10, 0xe1,
- 0x00, 0x04, 0x77, 0x12, 0x00, 0x56, 0x80, 0x82,
- 0x77, 0x12, 0x00, 0x56, 0x10, 0xe1, 0x00, 0x01,
- 0x80, 0x82, 0xe7, 0x12, 0xe5, 0x01, 0xf9, 0x80,
- 0x16, 0x9a, 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4,
- 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xf9,
- 0x77, 0x11, 0x00, 0x7b, 0x76, 0x00, 0x00, 0x16,
- 0x76, 0x01, 0x00, 0x17, 0x76, 0x02, 0x00, 0x1a,
- 0x76, 0x03, 0x00, 0x1b, 0x76, 0x04, 0x00, 0x1c,
- 0x76, 0x05, 0x00, 0x1d, 0x71, 0x81, 0x00, 0x17,
- 0x71, 0xe7, 0x00, 0x06, 0x00, 0x11, 0x10, 0x81,
- 0xf8, 0x44, 0x14, 0xdf, 0xf9, 0x80, 0x16, 0x53,
- 0xf6, 0xb8, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x20,
- 0xff, 0xff, 0xf6, 0xb8, 0xfb, 0x80, 0x16, 0x08,
- 0xf0, 0x20, 0xff, 0xff, 0x77, 0x11, 0x00, 0x7b,
- 0x71, 0x81, 0x00, 0x17, 0x76, 0xe7, 0x00, 0x06,
- 0x00, 0x01, 0x48, 0x17, 0x77, 0x16, 0x00, 0x00,
- 0x77, 0x10, 0x00, 0x04, 0x77, 0x15, 0x00, 0x03,
- 0x77, 0x14, 0x00, 0x02, 0x77, 0x13, 0x00, 0x01,
- 0xf0, 0x00, 0x00, 0x39, 0x76, 0xe7, 0x00, 0x08,
- 0x00, 0x1f, 0x76, 0xe7, 0x00, 0x07, 0x00, 0x00,
- 0x88, 0x0e, 0x77, 0x1a, 0x00, 0x05, 0x48, 0x17,
- 0xf0, 0x00, 0x00, 0x09, 0x88, 0x12, 0x48, 0x18,
- 0x88, 0x19, 0xe8, 0x00, 0xf0, 0x72, 0x15, 0x2c,
- 0x73, 0x19, 0x00, 0x11, 0x76, 0x82, 0x00, 0x00,
- 0x11, 0x91, 0x73, 0x11, 0x00, 0x19, 0x70, 0xe2,
- 0x00, 0x03, 0x00, 0x16, 0x70, 0xe2, 0x00, 0x04,
- 0x00, 0x13, 0x70, 0xe2, 0x00, 0x05, 0x00, 0x14,
- 0x81, 0xe2, 0x00, 0x01, 0x70, 0xe2, 0x00, 0x06,
- 0x00, 0x15, 0x70, 0xe2, 0x00, 0x07, 0x00, 0x10,
- 0x80, 0xe2, 0x00, 0x02, 0x73, 0x0e, 0x00, 0x11,
- 0xf1, 0x00, 0x00, 0x1e, 0x6d, 0xee, 0x00, 0x05,
- 0x6d, 0xeb, 0x00, 0x05, 0x6d, 0xec, 0x00, 0x05,
- 0x6d, 0xed, 0x00, 0x05, 0x6d, 0xe8, 0x00, 0x05,
- 0xf0, 0x00, 0x00, 0x01, 0x81, 0x91, 0x6d, 0xea,
- 0x00, 0x08, 0x73, 0x11, 0x00, 0x0e, 0xee, 0x07,
- 0x76, 0xe7, 0x00, 0x41, 0x00, 0x24, 0x76, 0xe7,
- 0x00, 0x46, 0x00, 0x25, 0x76, 0xe7, 0x00, 0x4b,
- 0x00, 0x26, 0x76, 0xe7, 0x00, 0x50, 0x00, 0x27,
- 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4,
- 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xfe, 0x88, 0x11,
- 0x56, 0x06, 0x4e, 0x00, 0xf9, 0x80, 0x16, 0xa2,
- 0xf7, 0xb8, 0x10, 0xf8, 0x00, 0x11, 0xf0, 0x10,
- 0xff, 0xff, 0xfa, 0x45, 0x15, 0x60, 0x77, 0x16,
- 0xff, 0xff, 0x77, 0x12, 0x00, 0x7b, 0x49, 0x11,
- 0x10, 0x82, 0xf6, 0x03, 0xf0, 0x00, 0x00, 0x09,
- 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81,
- 0xf8, 0x44, 0x15, 0x71, 0xf2, 0x73, 0x15, 0x71,
- 0xf4, 0x95, 0xe7, 0x16, 0x77, 0x11, 0x00, 0x7b,
- 0x10, 0x81, 0xf0, 0x00, 0x00, 0x09, 0x88, 0x11,
- 0xf4, 0x95, 0x77, 0x12, 0x00, 0x06, 0x10, 0x81,
- 0xf8, 0x45, 0x15, 0x5c, 0x6e, 0xea, 0xff, 0xff,
- 0x15, 0x69, 0x6d, 0xe9, 0x00, 0x08, 0x76, 0x86,
- 0x00, 0x01, 0xe9, 0x01, 0x56, 0x00, 0xf1, 0x80,
- 0x10, 0xf8, 0x00, 0x0b, 0xf8, 0x45, 0x15, 0x7e,
- 0xfb, 0x80, 0x15, 0x85, 0xf4, 0x95, 0x48, 0x16,
- 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x02, 0x48, 0x16,
- 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11,
- 0xee, 0xff, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11,
- 0xf4, 0x95, 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9,
- 0xf8, 0x30, 0x15, 0xc4, 0x10, 0xe1, 0x00, 0x03,
- 0x77, 0x12, 0x00, 0x55, 0x80, 0x82, 0x77, 0x12,
- 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
- 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
- 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
- 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
- 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1,
- 0x00, 0x02, 0xf0, 0x00, 0x00, 0x08, 0x32, 0xf8,
- 0x00, 0x08, 0x77, 0x12, 0x00, 0x54, 0xe8, 0x01,
- 0xf4, 0x82, 0xf4, 0x93, 0x18, 0x82, 0x77, 0x12,
- 0x00, 0x54, 0xf0, 0x40, 0x00, 0x00, 0x80, 0x82,
- 0x10, 0xe1, 0x00, 0x01, 0xf9, 0x80, 0x16, 0x76,
- 0x10, 0xe1, 0x00, 0x01, 0xf9, 0x80, 0x16, 0x66,
- 0xf0, 0x73, 0x16, 0x03, 0x77, 0x11, 0x00, 0x7b,
- 0x71, 0x81, 0x00, 0x11, 0x71, 0xe1, 0x00, 0x07,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1,
- 0x00, 0x09, 0xf9, 0x80, 0x15, 0x85, 0x77, 0x11,
- 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1,
- 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00,
- 0x00, 0x08, 0x77, 0x11, 0x00, 0x7b, 0x71, 0x81,
- 0x00, 0x11, 0x10, 0xe1, 0x00, 0x09, 0xfb, 0x80,
- 0x15, 0x85, 0xf0, 0x00, 0x00, 0x10, 0x77, 0x11,
- 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1,
- 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00,
- 0x00, 0x18, 0x77, 0x11, 0x00, 0x7b, 0x71, 0x81,
- 0x00, 0x11, 0x10, 0xe1, 0x00, 0x09, 0xfb, 0x80,
- 0x15, 0x85, 0xf0, 0x00, 0x00, 0x20, 0x77, 0x11,
- 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1,
- 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00,
- 0x00, 0x28, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01,
- 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff,
- 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95,
- 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30,
- 0x16, 0x41, 0x77, 0x11, 0x00, 0x55, 0x76, 0x81,
- 0x00, 0x1e, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
- 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0xf2, 0x73,
- 0x16, 0x4e, 0x76, 0x81, 0x00, 0x00, 0x77, 0x11,
- 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x71, 0xe1,
- 0x00, 0x07, 0x00, 0x12, 0x76, 0x82, 0x00, 0x00,
- 0x10, 0xe1, 0x00, 0x39, 0xf9, 0x80, 0x16, 0x08,
- 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11,
- 0xf4, 0xe4, 0x4a, 0x11, 0x77, 0x11, 0x00, 0x7b,
- 0x10, 0x81, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x11,
- 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xfa, 0x44,
- 0x16, 0x63, 0xf4, 0x95, 0xee, 0xff, 0x76, 0x81,
- 0x00, 0x01, 0xee, 0x01, 0x8a, 0x11, 0xf4, 0xe4,
- 0xf0, 0x10, 0x00, 0x10, 0x4a, 0x11, 0x32, 0xf8,
- 0x00, 0x08, 0xee, 0xff, 0x77, 0x11, 0x00, 0x01,
- 0xe8, 0x01, 0xee, 0x01, 0xf4, 0x82, 0x1a, 0x81,
- 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
- 0xf0, 0x10, 0x00, 0x10, 0x4a, 0x11, 0x32, 0xf8,
- 0x00, 0x08, 0xee, 0xff, 0xe8, 0x01, 0x77, 0x11,
- 0x00, 0x00, 0xf4, 0x82, 0xee, 0x01, 0xf4, 0x93,
- 0x18, 0x81, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95,
- 0xf4, 0xe4, 0x4a, 0x11, 0xf0, 0x10, 0x00, 0x10,
- 0x77, 0x11, 0x00, 0x00, 0x32, 0xf8, 0x00, 0x08,
- 0xee, 0xff, 0x11, 0x81, 0xe8, 0x01, 0xee, 0x01,
- 0x77, 0x11, 0x00, 0x00, 0xf4, 0x82, 0xf2, 0xa0,
- 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
- 0xf2, 0x73, 0x16, 0x9e, 0xf6, 0xbb, 0xf4, 0x95,
- 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xe4,
- 0xf2, 0x73, 0x16, 0xa6, 0xf7, 0xbb, 0xf4, 0x95,
- 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xe4,
- 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95, 0x71, 0x04,
- 0x00, 0x16, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11,
- 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x0e, 0x10, 0xe6, 0x00, 0x0e,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x80, 0x82,
- 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x0d, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
- 0x10, 0xe6, 0x00, 0x0d, 0x80, 0x82, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0c,
- 0x10, 0xe6, 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x0b, 0x10, 0xe6,
- 0x00, 0x0b, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
- 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x0a, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x10, 0xe6, 0x00, 0x0a, 0x80, 0x82,
- 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x09, 0x10, 0xe6, 0x00, 0x09, 0x71, 0xe1,
- 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x08,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6,
- 0x00, 0x08, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x07, 0x10, 0xe6,
- 0x00, 0x07, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
- 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x06, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x10, 0xe6, 0x00, 0x06, 0x80, 0x82,
- 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x05, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
- 0x10, 0xe6, 0x00, 0x05, 0x80, 0x82, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x04,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6,
- 0x00, 0x04, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x03, 0x71, 0xe1,
- 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6, 0x00, 0x03,
- 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x02, 0x10, 0xe6, 0x00, 0x02,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x80, 0x82,
- 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x01, 0x10, 0xe6, 0x00, 0x01, 0x71, 0xe1,
- 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x00,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x13, 0xe7, 0x62,
- 0xe5, 0x01, 0xf9, 0x80, 0x16, 0x9a, 0x8a, 0x16,
- 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11,
- 0xf4, 0x95, 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05,
- 0x00, 0x12, 0xee, 0xff, 0x76, 0x82, 0x00, 0x00,
- 0xee, 0x01, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x11,
- 0x69, 0x81, 0x00, 0x01, 0x8a, 0x11, 0xf4, 0x95,
- 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0xf4, 0x95,
- 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0xee, 0xff, 0x76, 0x82, 0x00, 0x01, 0xee, 0x01,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x11, 0x69, 0x81,
- 0x00, 0x01, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
- 0x4a, 0x11, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
- 0xf0, 0x00, 0x00, 0x94, 0x88, 0x11, 0xf4, 0x95,
- 0xf4, 0x95, 0x10, 0x81, 0xfa, 0x44, 0x17, 0x9c,
- 0xf4, 0x95, 0xee, 0xff, 0xf9, 0x80, 0x16, 0x53,
- 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 0xf0, 0x00,
- 0x00, 0x94, 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95,
- 0x76, 0x81, 0x00, 0x01, 0xee, 0x01, 0x76, 0xe1,
- 0x00, 0x01, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
- 0x00, 0x21, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x20,
- 0x76, 0xe1, 0x00, 0x04, 0x00, 0x23, 0x76, 0xe1,
- 0x00, 0x05, 0x00, 0x22, 0x76, 0xe1, 0x00, 0x06,
- 0x00, 0x38, 0x76, 0xe1, 0x00, 0x07, 0x00, 0x39,
- 0x76, 0xe1, 0x00, 0x08, 0x00, 0x15, 0x76, 0xe1,
- 0x00, 0x09, 0x00, 0x14, 0x76, 0xe1, 0x00, 0x0a,
- 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x41,
- 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x40, 0x76, 0xe1,
- 0x00, 0x0d, 0x00, 0x43, 0x76, 0xe1, 0x00, 0x0e,
- 0x00, 0x42, 0x76, 0xe1, 0x00, 0x0f, 0x00, 0x48,
- 0x76, 0xe1, 0x00, 0x10, 0x00, 0x49, 0x76, 0xe1,
- 0x00, 0x11, 0x00, 0x1b, 0x76, 0xe1, 0x00, 0x12,
- 0x00, 0x1a, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
- 0x4a, 0x11, 0xee, 0xfd, 0x88, 0x11, 0x56, 0x06,
- 0x4e, 0x00, 0xf9, 0x80, 0x16, 0xa2, 0x77, 0x12,
- 0x00, 0x7b, 0x77, 0x0e, 0x00, 0x09, 0x10, 0x82,
- 0x28, 0xf8, 0x00, 0x11, 0xf0, 0x00, 0x00, 0x95,
- 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81,
- 0xf8, 0x45, 0x17, 0xf0, 0xf2, 0x73, 0x17, 0xfd,
- 0x77, 0x11, 0xff, 0xff, 0x76, 0x81, 0x00, 0x01,
- 0xe9, 0x01, 0x56, 0x00, 0xf1, 0x80, 0x10, 0xf8,
- 0x00, 0x0b, 0xf8, 0x45, 0x17, 0xfd, 0xfb, 0x80,
- 0x18, 0x10, 0xf4, 0x95, 0x48, 0x11, 0xf9, 0x80,
- 0x16, 0x9a, 0xee, 0x03, 0x48, 0x11, 0x8a, 0x11,
- 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11,
- 0xf4, 0x95, 0xee, 0xff, 0x71, 0xe1, 0x00, 0x01,
- 0x00, 0x11, 0xee, 0x01, 0x10, 0x81, 0x8a, 0x11,
- 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff,
- 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95,
- 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30,
- 0x18, 0xc3, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x01,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x02, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x03,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x04, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x05,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x06, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x01, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x07,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
- 0x20, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x08, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x09,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x0a, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0b,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
- 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0d,
- 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
- 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
- 0x76, 0x82, 0x00, 0x0e, 0x71, 0xe1, 0x00, 0x06,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1,
- 0x00, 0x07, 0xf9, 0x80, 0x16, 0x76, 0x10, 0xe1,
- 0x00, 0x08, 0xf9, 0x80, 0x16, 0x76, 0x10, 0xe1,
- 0x00, 0x07, 0xf9, 0x80, 0x16, 0x66, 0x10, 0xe1,
- 0x00, 0x08, 0xf9, 0x80, 0x16, 0x66, 0xf0, 0x73,
- 0x18, 0xd1, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
- 0xfb, 0x80, 0x18, 0x10, 0xf0, 0x00, 0x00, 0x95,
- 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 0xfb, 0x80,
- 0x18, 0x10, 0xf0, 0x00, 0x00, 0x9e, 0xf9, 0x80,
- 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11, 0xf4, 0xe4,
- 0x4a, 0x11, 0x88, 0x11, 0xee, 0xff, 0xf4, 0x95,
- 0x10, 0x04, 0x71, 0xe1, 0x00, 0x03, 0x00, 0x11,
- 0xee, 0x01, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95,
- 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95,
- 0x71, 0x04, 0x00, 0x16, 0xfb, 0x80, 0x16, 0xa2,
- 0x88, 0x11, 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x02,
- 0x00, 0x12, 0x76, 0x82, 0x00, 0x10, 0x10, 0xe6,
- 0x00, 0x01, 0x71, 0xe1, 0x00, 0x03, 0x00, 0x12,
- 0x80, 0x82, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x12,
- 0x10, 0xe6, 0x00, 0x02, 0x80, 0x82, 0xe7, 0x62,
- 0x71, 0xe1, 0x00, 0x02, 0x00, 0x13, 0xe5, 0x01,
- 0xf9, 0x80, 0x16, 0x9a, 0x8a, 0x16, 0x8a, 0x11,
- 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0xee, 0xff,
- 0xee, 0x01, 0x10, 0xe1, 0x00, 0x01, 0x8a, 0x11,
- 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x77, 0x11,
- 0x00, 0x7b, 0x10, 0x81, 0xf0, 0x00, 0x00, 0xb3,
- 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81,
- 0xfa, 0x44, 0x19, 0x2a, 0xf4, 0x95, 0xee, 0xff,
- 0xf9, 0x80, 0x16, 0x53, 0x77, 0x11, 0x00, 0x7b,
- 0x10, 0x81, 0xf0, 0x00, 0x00, 0xb3, 0x88, 0x11,
- 0xf4, 0x95, 0xf4, 0x95, 0x76, 0x81, 0x00, 0x01,
- 0xee, 0x01, 0x76, 0xe1, 0x00, 0x01, 0x00, 0x00,
- 0x76, 0xe1, 0x00, 0x02, 0x00, 0x13, 0x76, 0xe1,
- 0x00, 0x03, 0x00, 0x26, 0x76, 0xe1, 0x00, 0x04,
- 0x00, 0x25, 0x76, 0xe1, 0x00, 0x05, 0x00, 0x24,
- 0x76, 0xe1, 0x00, 0x06, 0x00, 0x00, 0x76, 0xe1,
- 0x00, 0x07, 0x00, 0x17, 0x76, 0xe1, 0x00, 0x08,
- 0x00, 0x32, 0x76, 0xe1, 0x00, 0x09, 0x00, 0x31,
- 0x76, 0xe1, 0x00, 0x0a, 0x00, 0x30, 0x8a, 0x11,
- 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16,
- 0x4a, 0x17, 0xee, 0xff, 0xf4, 0x95, 0x71, 0x06,
- 0x00, 0x17, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11,
- 0xf4, 0x95, 0xf7, 0xb8, 0x10, 0xf8, 0x00, 0x11,
- 0xf0, 0x10, 0xff, 0xff, 0xfa, 0x45, 0x19, 0x73,
- 0x77, 0x16, 0xff, 0xff, 0x77, 0x12, 0x00, 0x7b,
- 0x77, 0x0e, 0x00, 0x05, 0x10, 0x82, 0x28, 0xf8,
- 0x00, 0x11, 0xf0, 0x00, 0x00, 0xb4, 0x88, 0x11,
- 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xf8, 0x44,
- 0x19, 0x84, 0xf2, 0x73, 0x19, 0x84, 0xf4, 0x95,
- 0xe7, 0x16, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
- 0xf0, 0x00, 0x00, 0xb4, 0x88, 0x11, 0xf4, 0x95,
- 0x77, 0x12, 0x00, 0x02, 0x10, 0x81, 0xf8, 0x45,
- 0x19, 0x6f, 0x6e, 0xea, 0xff, 0xff, 0x19, 0x7c,
- 0x6d, 0xe9, 0x00, 0x05, 0x61, 0xf8, 0x00, 0x17,
- 0x00, 0x01, 0xfa, 0x20, 0x19, 0x8f, 0x76, 0x86,
- 0x00, 0x01, 0xfb, 0x80, 0x19, 0x97, 0xf4, 0x95,
- 0x48, 0x16, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01,
- 0x8a, 0x17, 0x48, 0x16, 0x8a, 0x16, 0x8a, 0x11,
- 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff, 0xfb, 0x80,
- 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10,
- 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30, 0x19, 0xcc,
- 0x71, 0xe1, 0x00, 0x02, 0x00, 0x12, 0x69, 0x82,
- 0x00, 0x10, 0x71, 0xe1, 0x00, 0x02, 0x00, 0x12,
- 0x68, 0x82, 0xf7, 0xff, 0x71, 0xe1, 0x00, 0x02,
- 0x00, 0x12, 0x68, 0x82, 0xfb, 0xff, 0x71, 0xe1,
- 0x00, 0x02, 0x00, 0x12, 0x68, 0x82, 0xff, 0xf0,
- 0x71, 0xe1, 0x00, 0x03, 0x00, 0x12, 0x76, 0x82,
- 0xff, 0xff, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x12,
- 0x76, 0x82, 0xff, 0xff, 0x71, 0xe1, 0x00, 0x02,
- 0x00, 0x12, 0x69, 0x82, 0x00, 0x20, 0x71, 0xe1,
- 0x00, 0x02, 0x00, 0x11, 0xf2, 0x73, 0x19, 0xda,
- 0x68, 0x81, 0xff, 0xef, 0x77, 0x11, 0x00, 0x7b,
- 0x10, 0x81, 0xfb, 0x80, 0x19, 0x97, 0xf0, 0x00,
- 0x00, 0xb4, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
- 0xfb, 0x80, 0x19, 0x97, 0xf0, 0x00, 0x00, 0xb9,
- 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11,
- 0xf4, 0xe4, 0x00, 0xa4, 0x00, 0x00, 0x19, 0xdf,
- 0x00, 0x01, 0x2a, 0xe6, 0x00, 0x00, 0x00, 0x01,
- 0x2a, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x2a, 0x12,
- 0x0c, 0x01, 0xc3, 0x4f, 0x00, 0x00, 0x00, 0x01,
- 0x2a, 0x15, 0x00, 0x00, 0x00, 0x02, 0x2a, 0x16,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x2a, 0x5d,
- 0x00, 0x43, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x79,
- 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68,
- 0x00, 0x74, 0x00, 0x20, 0x00, 0x54, 0x00, 0x65,
- 0x00, 0x63, 0x00, 0x68, 0x00, 0x6e, 0x00, 0x6f,
- 0x00, 0x54, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6e,
- 0x00, 0x64, 0x00, 0x20, 0x00, 0x41, 0x00, 0x47,
- 0x00, 0x00, 0x00, 0x04, 0x2a, 0x76, 0x00, 0x30,
- 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0c,
- 0x2a, 0x7a, 0x00, 0x46, 0x00, 0x65, 0x00, 0x62,
- 0x00, 0x20, 0x00, 0x32, 0x00, 0x37, 0x00, 0x20,
- 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x31,
- 0x00, 0x00, 0x00, 0x09, 0x2a, 0x86, 0x00, 0x31,
- 0x00, 0x34, 0x00, 0x3a, 0x00, 0x33, 0x00, 0x35,
- 0x00, 0x3a, 0x00, 0x33, 0x00, 0x33, 0x00, 0x00,
- 0x00, 0x0f, 0x2a, 0x8f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x2a, 0x9e, 0x00, 0x00,
- 0x00, 0x01, 0x2a, 0x9f, 0x00, 0x00, 0x00, 0x01,
- 0x2a, 0xa0, 0x00, 0x00, 0x00, 0x01, 0x2a, 0xa1,
- 0x00, 0x00, 0x00, 0x01, 0x2a, 0xa2, 0x00, 0x00,
- 0x00, 0x01, 0x29, 0x7e, 0x00, 0x00, 0x00, 0x02,
- 0x29, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x29, 0x82, 0xff, 0xff, 0x00, 0x01, 0x2a, 0xa7,
- 0x00, 0x00, 0x00, 0x05, 0x2a, 0xa8, 0x71, 0x41,
- 0x20, 0x00, 0x20, 0x00, 0x00, 0x23, 0x04, 0x00,
- 0x00, 0x0a, 0x2a, 0xad, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x0f, 0x2a, 0xb7, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x40, 0x00, 0xa0, 0x82, 0x40,
- 0x00, 0x08, 0x30, 0x7f, 0x00, 0x80, 0x01, 0x80,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x27, 0x6e, 0x00, 0x00,
- 0x00, 0x01, 0x27, 0x6f, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x09, 0x00, 0x00, 0x1a, 0x83, 0x04, 0xe8,
- 0x04, 0xcf, 0x04, 0xc5, 0x04, 0xba, 0x04, 0xb0,
- 0x04, 0xac, 0x04, 0x9c, 0x04, 0x8c, 0x04, 0x81,
- 0x00, 0x78, 0x00, 0x00, 0x01, 0x00, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xaa, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x02, 0x23, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x05, 0xe5, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x02, 0xb5, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x0e, 0x33, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
- 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0x00, 0x00,
-};
-
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig
deleted file mode 100644
index 83611012ef3..00000000000
--- a/drivers/media/dvb/ttusb-dec/Kconfig
+++ /dev/null
@@ -1,22 +0,0 @@
-config DVB_TTUSB_DEC
- tristate "Technotrend/Hauppauge USB DEC devices"
- depends on DVB_CORE && USB
- select FW_LOADER
- select CRC32
- help
- Support for external USB adapters designed by Technotrend and
- produced by Hauppauge, shipped under the brand name 'DEC2000-t'
- and 'DEC3000-s'.
-
- Even if these devices have a MPEG decoder built in, they transmit
- only compressed MPEG data over the USB bus, so you need
- an external software decoder to watch TV on your computer.
-
- This driver needs external firmware. Please use the commands
- "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2000t",
- "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2540t",
- "<kerneldir>/Documentation/dvb/get_dvb_firmware dec3000s",
- download/extract them, and then copy them to /usr/lib/hotplug/firmware
- or /lib/firmware (depending on configuration of firmware hotplug).
-
- Say Y if you own such a device and want to use it.
diff --git a/drivers/media/dvb/ttusb-dec/Makefile b/drivers/media/dvb/ttusb-dec/Makefile
deleted file mode 100644
index b41bf1f06a9..00000000000
--- a/drivers/media/dvb/ttusb-dec/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-$(CONFIG_DVB_TTUSB_DEC) += ttusb_dec.o ttusbdecfe.o
-
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
deleted file mode 100644
index 6c1cb770bcf..00000000000
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ /dev/null
@@ -1,1762 +0,0 @@
-/*
- * TTUSB DEC Driver
- *
- * Copyright (C) 2003-2004 Alex Woods <linux-dvb@giblets.org>
- * IR support by Peter Beutner <p.beutner@gmx.net>
- *
- * 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/mutex.h>
-
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include <linux/spinlock.h>
-#include <linux/usb.h>
-#include <linux/interrupt.h>
-#include <linux/firmware.h>
-#include <linux/crc32.h>
-#include <linux/init.h>
-#include <linux/input.h>
-
-#include "dmxdev.h"
-#include "dvb_demux.h"
-#include "dvb_filter.h"
-#include "dvb_frontend.h"
-#include "dvb_net.h"
-#include "ttusbdecfe.h"
-
-static int debug;
-static int output_pva;
-static int enable_rc;
-
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
-module_param(output_pva, int, 0444);
-MODULE_PARM_DESC(output_pva, "Output PVA from dvr device (default:off)");
-module_param(enable_rc, int, 0644);
-MODULE_PARM_DESC(enable_rc, "Turn on/off IR remote control(default: off)");
-
-#define dprintk if (debug) printk
-
-#define DRIVER_NAME "TechnoTrend/Hauppauge DEC USB"
-
-#define COMMAND_PIPE 0x03
-#define RESULT_PIPE 0x04
-#define IN_PIPE 0x08
-#define OUT_PIPE 0x07
-#define IRQ_PIPE 0x0A
-
-#define COMMAND_PACKET_SIZE 0x3c
-#define ARM_PACKET_SIZE 0x1000
-#define IRQ_PACKET_SIZE 0x8
-
-#define ISO_BUF_COUNT 0x04
-#define FRAMES_PER_ISO_BUF 0x04
-#define ISO_FRAME_SIZE 0x0380
-
-#define MAX_PVA_LENGTH 6144
-
-enum ttusb_dec_model {
- TTUSB_DEC2000T,
- TTUSB_DEC2540T,
- TTUSB_DEC3000S
-};
-
-enum ttusb_dec_packet_type {
- TTUSB_DEC_PACKET_PVA,
- TTUSB_DEC_PACKET_SECTION,
- TTUSB_DEC_PACKET_EMPTY
-};
-
-enum ttusb_dec_interface {
- TTUSB_DEC_INTERFACE_INITIAL,
- TTUSB_DEC_INTERFACE_IN,
- TTUSB_DEC_INTERFACE_OUT
-};
-
-struct ttusb_dec {
- enum ttusb_dec_model model;
- char *model_name;
- char *firmware_name;
- int can_playback;
-
- /* DVB bits */
- struct dvb_adapter adapter;
- struct dmxdev dmxdev;
- struct dvb_demux demux;
- struct dmx_frontend frontend;
- struct dvb_net dvb_net;
- struct dvb_frontend* fe;
-
- u16 pid[DMX_PES_OTHER];
-
- /* USB bits */
- struct usb_device *udev;
- u8 trans_count;
- unsigned int command_pipe;
- unsigned int result_pipe;
- unsigned int in_pipe;
- unsigned int out_pipe;
- unsigned int irq_pipe;
- enum ttusb_dec_interface interface;
- struct mutex usb_mutex;
-
- void *irq_buffer;
- struct urb *irq_urb;
- dma_addr_t irq_dma_handle;
- void *iso_buffer;
- dma_addr_t iso_dma_handle;
- struct urb *iso_urb[ISO_BUF_COUNT];
- int iso_stream_count;
- struct mutex iso_mutex;
-
- u8 packet[MAX_PVA_LENGTH + 4];
- enum ttusb_dec_packet_type packet_type;
- int packet_state;
- int packet_length;
- int packet_payload_length;
- u16 next_packet_id;
-
- int pva_stream_count;
- int filter_stream_count;
-
- struct dvb_filter_pes2ts a_pes2ts;
- struct dvb_filter_pes2ts v_pes2ts;
-
- u8 v_pes[16 + MAX_PVA_LENGTH];
- int v_pes_length;
- int v_pes_postbytes;
-
- struct list_head urb_frame_list;
- struct tasklet_struct urb_tasklet;
- spinlock_t urb_frame_list_lock;
-
- struct dvb_demux_filter *audio_filter;
- struct dvb_demux_filter *video_filter;
- struct list_head filter_info_list;
- spinlock_t filter_info_list_lock;
-
- struct input_dev *rc_input_dev;
- char rc_phys[64];
-
- int active; /* Loaded successfully */
-};
-
-struct urb_frame {
- u8 data[ISO_FRAME_SIZE];
- int length;
- struct list_head urb_frame_list;
-};
-
-struct filter_info {
- u8 stream_id;
- struct dvb_demux_filter *filter;
- struct list_head filter_info_list;
-};
-
-static u16 rc_keys[] = {
- KEY_POWER,
- KEY_MUTE,
- KEY_1,
- KEY_2,
- KEY_3,
- KEY_4,
- KEY_5,
- KEY_6,
- KEY_7,
- KEY_8,
- KEY_9,
- KEY_0,
- KEY_CHANNELUP,
- KEY_VOLUMEDOWN,
- KEY_OK,
- KEY_VOLUMEUP,
- KEY_CHANNELDOWN,
- KEY_PREVIOUS,
- KEY_ESC,
- KEY_RED,
- KEY_GREEN,
- KEY_YELLOW,
- KEY_BLUE,
- KEY_OPTION,
- KEY_M,
- KEY_RADIO
-};
-
-static void ttusb_dec_set_model(struct ttusb_dec *dec,
- enum ttusb_dec_model model);
-
-static void ttusb_dec_handle_irq( struct urb *urb, struct pt_regs *regs)
-{
- struct ttusb_dec * dec = urb->context;
- char *buffer = dec->irq_buffer;
- int retval;
-
- switch(urb->status) {
- case 0: /*success*/
- break;
- case -ECONNRESET:
- case -ENOENT:
- case -ESHUTDOWN:
- case -ETIMEDOUT:
- /* this urb is dead, cleanup */
- dprintk("%s:urb shutting down with status: %d\n",
- __FUNCTION__, urb->status);
- return;
- default:
- dprintk("%s:nonzero status received: %d\n",
- __FUNCTION__,urb->status);
- goto exit;
- }
-
- if( (buffer[0] == 0x1) && (buffer[2] == 0x15) ) {
- /* IR - Event */
- /* this is an fact a bit too simple implementation;
- * the box also reports a keyrepeat signal
- * (with buffer[3] == 0x40) in an intervall of ~100ms.
- * But to handle this correctly we had to imlemenent some
- * kind of timer which signals a 'key up' event if no
- * keyrepeat signal is recieved for lets say 200ms.
- * this should/could be added later ...
- * for now lets report each signal as a key down and up*/
- dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]);
- input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 1);
- input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 0);
- input_sync(dec->rc_input_dev);
- }
-
-exit: retval = usb_submit_urb(urb, GFP_ATOMIC);
- if(retval)
- printk("%s - usb_commit_urb failed with result: %d\n",
- __FUNCTION__, retval);
-}
-
-static u16 crc16(u16 crc, const u8 *buf, size_t len)
-{
- u16 tmp;
-
- while (len--) {
- crc ^= *buf++;
- crc ^= (u8)crc >> 4;
- tmp = (u8)crc;
- crc ^= (tmp ^ (tmp << 1)) << 4;
- }
- return crc;
-}
-
-static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command,
- int param_length, const u8 params[],
- int *result_length, u8 cmd_result[])
-{
- int result, actual_len, i;
- u8 *b;
-
- dprintk("%s\n", __FUNCTION__);
-
- b = kmalloc(COMMAND_PACKET_SIZE + 4, GFP_KERNEL);
- if (!b)
- return -ENOMEM;
-
- if ((result = mutex_lock_interruptible(&dec->usb_mutex))) {
- kfree(b);
- printk("%s: Failed to lock usb mutex.\n", __FUNCTION__);
- return result;
- }
-
- b[0] = 0xaa;
- b[1] = ++dec->trans_count;
- b[2] = command;
- b[3] = param_length;
-
- if (params)
- memcpy(&b[4], params, param_length);
-
- if (debug) {
- printk("%s: command: ", __FUNCTION__);
- for (i = 0; i < param_length + 4; i++)
- printk("0x%02X ", b[i]);
- printk("\n");
- }
-
- result = usb_bulk_msg(dec->udev, dec->command_pipe, b,
- COMMAND_PACKET_SIZE + 4, &actual_len, 1000);
-
- if (result) {
- printk("%s: command bulk message failed: error %d\n",
- __FUNCTION__, result);
- mutex_unlock(&dec->usb_mutex);
- kfree(b);
- return result;
- }
-
- result = usb_bulk_msg(dec->udev, dec->result_pipe, b,
- COMMAND_PACKET_SIZE + 4, &actual_len, 1000);
-
- if (result) {
- printk("%s: result bulk message failed: error %d\n",
- __FUNCTION__, result);
- mutex_unlock(&dec->usb_mutex);
- kfree(b);
- return result;
- } else {
- if (debug) {
- printk("%s: result: ", __FUNCTION__);
- for (i = 0; i < actual_len; i++)
- printk("0x%02X ", b[i]);
- printk("\n");
- }
-
- if (result_length)
- *result_length = b[3];
- if (cmd_result && b[3] > 0)
- memcpy(cmd_result, &b[4], b[3]);
-
- mutex_unlock(&dec->usb_mutex);
-
- kfree(b);
- return 0;
- }
-}
-
-static int ttusb_dec_get_stb_state (struct ttusb_dec *dec, unsigned int *mode,
- unsigned int *model, unsigned int *version)
-{
- u8 c[COMMAND_PACKET_SIZE];
- int c_length;
- int result;
- unsigned int tmp;
-
- dprintk("%s\n", __FUNCTION__);
-
- result = ttusb_dec_send_command(dec, 0x08, 0, NULL, &c_length, c);
- if (result)
- return result;
-
- if (c_length >= 0x0c) {
- if (mode != NULL) {
- memcpy(&tmp, c, 4);
- *mode = ntohl(tmp);
- }
- if (model != NULL) {
- memcpy(&tmp, &c[4], 4);
- *model = ntohl(tmp);
- }
- if (version != NULL) {
- memcpy(&tmp, &c[8], 4);
- *version = ntohl(tmp);
- }
- return 0;
- } else {
- return -1;
- }
-}
-
-static int ttusb_dec_audio_pes2ts_cb(void *priv, unsigned char *data)
-{
- struct ttusb_dec *dec = priv;
-
- dec->audio_filter->feed->cb.ts(data, 188, NULL, 0,
- &dec->audio_filter->feed->feed.ts,
- DMX_OK);
-
- return 0;
-}
-
-static int ttusb_dec_video_pes2ts_cb(void *priv, unsigned char *data)
-{
- struct ttusb_dec *dec = priv;
-
- dec->video_filter->feed->cb.ts(data, 188, NULL, 0,
- &dec->video_filter->feed->feed.ts,
- DMX_OK);
-
- return 0;
-}
-
-static void ttusb_dec_set_pids(struct ttusb_dec *dec)
-{
- u8 b[] = { 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff };
-
- u16 pcr = htons(dec->pid[DMX_PES_PCR]);
- u16 audio = htons(dec->pid[DMX_PES_AUDIO]);
- u16 video = htons(dec->pid[DMX_PES_VIDEO]);
-
- dprintk("%s\n", __FUNCTION__);
-
- memcpy(&b[0], &pcr, 2);
- memcpy(&b[2], &audio, 2);
- memcpy(&b[4], &video, 2);
-
- ttusb_dec_send_command(dec, 0x50, sizeof(b), b, NULL, NULL);
-
- dvb_filter_pes2ts_init(&dec->a_pes2ts, dec->pid[DMX_PES_AUDIO],
- ttusb_dec_audio_pes2ts_cb, dec);
- dvb_filter_pes2ts_init(&dec->v_pes2ts, dec->pid[DMX_PES_VIDEO],
- ttusb_dec_video_pes2ts_cb, dec);
- dec->v_pes_length = 0;
- dec->v_pes_postbytes = 0;
-}
-
-static void ttusb_dec_process_pva(struct ttusb_dec *dec, u8 *pva, int length)
-{
- if (length < 8) {
- printk("%s: packet too short - discarding\n", __FUNCTION__);
- return;
- }
-
- if (length > 8 + MAX_PVA_LENGTH) {
- printk("%s: packet too long - discarding\n", __FUNCTION__);
- return;
- }
-
- switch (pva[2]) {
-
- case 0x01: { /* VideoStream */
- int prebytes = pva[5] & 0x03;
- int postbytes = (pva[5] & 0x0c) >> 2;
- u16 v_pes_payload_length;
-
- if (output_pva) {
- dec->video_filter->feed->cb.ts(pva, length, NULL, 0,
- &dec->video_filter->feed->feed.ts, DMX_OK);
- return;
- }
-
- if (dec->v_pes_postbytes > 0 &&
- dec->v_pes_postbytes == prebytes) {
- memcpy(&dec->v_pes[dec->v_pes_length],
- &pva[12], prebytes);
-
- dvb_filter_pes2ts(&dec->v_pes2ts, dec->v_pes,
- dec->v_pes_length + prebytes, 1);
- }
-
- if (pva[5] & 0x10) {
- dec->v_pes[7] = 0x80;
- dec->v_pes[8] = 0x05;
-
- dec->v_pes[9] = 0x21 | ((pva[8] & 0xc0) >> 5);
- dec->v_pes[10] = ((pva[8] & 0x3f) << 2) |
- ((pva[9] & 0xc0) >> 6);
- dec->v_pes[11] = 0x01 |
- ((pva[9] & 0x3f) << 2) |
- ((pva[10] & 0x80) >> 6);
- dec->v_pes[12] = ((pva[10] & 0x7f) << 1) |
- ((pva[11] & 0xc0) >> 7);
- dec->v_pes[13] = 0x01 | ((pva[11] & 0x7f) << 1);
-
- memcpy(&dec->v_pes[14], &pva[12 + prebytes],
- length - 12 - prebytes);
- dec->v_pes_length = 14 + length - 12 - prebytes;
- } else {
- dec->v_pes[7] = 0x00;
- dec->v_pes[8] = 0x00;
-
- memcpy(&dec->v_pes[9], &pva[8], length - 8);
- dec->v_pes_length = 9 + length - 8;
- }
-
- dec->v_pes_postbytes = postbytes;
-
- if (dec->v_pes[9 + dec->v_pes[8]] == 0x00 &&
- dec->v_pes[10 + dec->v_pes[8]] == 0x00 &&
- dec->v_pes[11 + dec->v_pes[8]] == 0x01)
- dec->v_pes[6] = 0x84;
- else
- dec->v_pes[6] = 0x80;
-
- v_pes_payload_length = htons(dec->v_pes_length - 6 +
- postbytes);
- memcpy(&dec->v_pes[4], &v_pes_payload_length, 2);
-
- if (postbytes == 0)
- dvb_filter_pes2ts(&dec->v_pes2ts, dec->v_pes,
- dec->v_pes_length, 1);
-
- break;
- }
-
- case 0x02: /* MainAudioStream */
- if (output_pva) {
- dec->audio_filter->feed->cb.ts(pva, length, NULL, 0,
- &dec->audio_filter->feed->feed.ts, DMX_OK);
- return;
- }
-
- dvb_filter_pes2ts(&dec->a_pes2ts, &pva[8], length - 8,
- pva[5] & 0x10);
- break;
-
- default:
- printk("%s: unknown PVA type: %02x.\n", __FUNCTION__,
- pva[2]);
- break;
- }
-}
-
-static void ttusb_dec_process_filter(struct ttusb_dec *dec, u8 *packet,
- int length)
-{
- struct list_head *item;
- struct filter_info *finfo;
- struct dvb_demux_filter *filter = NULL;
- unsigned long flags;
- u8 sid;
-
- sid = packet[1];
- spin_lock_irqsave(&dec->filter_info_list_lock, flags);
- for (item = dec->filter_info_list.next; item != &dec->filter_info_list;
- item = item->next) {
- finfo = list_entry(item, struct filter_info, filter_info_list);
- if (finfo->stream_id == sid) {
- filter = finfo->filter;
- break;
- }
- }
- spin_unlock_irqrestore(&dec->filter_info_list_lock, flags);
-
- if (filter)
- filter->feed->cb.sec(&packet[2], length - 2, NULL, 0,
- &filter->filter, DMX_OK);
-}
-
-static void ttusb_dec_process_packet(struct ttusb_dec *dec)
-{
- int i;
- u16 csum = 0;
- u16 packet_id;
-
- if (dec->packet_length % 2) {
- printk("%s: odd sized packet - discarding\n", __FUNCTION__);
- return;
- }
-
- for (i = 0; i < dec->packet_length; i += 2)
- csum ^= ((dec->packet[i] << 8) + dec->packet[i + 1]);
-
- if (csum) {
- printk("%s: checksum failed - discarding\n", __FUNCTION__);
- return;
- }
-
- packet_id = dec->packet[dec->packet_length - 4] << 8;
- packet_id += dec->packet[dec->packet_length - 3];
-
- if ((packet_id != dec->next_packet_id) && dec->next_packet_id) {
- printk("%s: warning: lost packets between %u and %u\n",
- __FUNCTION__, dec->next_packet_id - 1, packet_id);
- }
-
- if (packet_id == 0xffff)
- dec->next_packet_id = 0x8000;
- else
- dec->next_packet_id = packet_id + 1;
-
- switch (dec->packet_type) {
- case TTUSB_DEC_PACKET_PVA:
- if (dec->pva_stream_count)
- ttusb_dec_process_pva(dec, dec->packet,
- dec->packet_payload_length);
- break;
-
- case TTUSB_DEC_PACKET_SECTION:
- if (dec->filter_stream_count)
- ttusb_dec_process_filter(dec, dec->packet,
- dec->packet_payload_length);
- break;
-
- case TTUSB_DEC_PACKET_EMPTY:
- break;
- }
-}
-
-static void swap_bytes(u8 *b, int length)
-{
- u8 c;
-
- length -= length % 2;
- for (; length; b += 2, length -= 2) {
- c = *b;
- *b = *(b + 1);
- *(b + 1) = c;
- }
-}
-
-static void ttusb_dec_process_urb_frame(struct ttusb_dec *dec, u8 *b,
- int length)
-{
- swap_bytes(b, length);
-
- while (length) {
- switch (dec->packet_state) {
-
- case 0:
- case 1:
- case 2:
- if (*b++ == 0xaa)
- dec->packet_state++;
- else
- dec->packet_state = 0;
-
- length--;
- break;
-
- case 3:
- if (*b == 0x00) {
- dec->packet_state++;
- dec->packet_length = 0;
- } else if (*b != 0xaa) {
- dec->packet_state = 0;
- }
-
- b++;
- length--;
- break;
-
- case 4:
- dec->packet[dec->packet_length++] = *b++;
-
- if (dec->packet_length == 2) {
- if (dec->packet[0] == 'A' &&
- dec->packet[1] == 'V') {
- dec->packet_type =
- TTUSB_DEC_PACKET_PVA;
- dec->packet_state++;
- } else if (dec->packet[0] == 'S') {
- dec->packet_type =
- TTUSB_DEC_PACKET_SECTION;
- dec->packet_state++;
- } else if (dec->packet[0] == 0x00) {
- dec->packet_type =
- TTUSB_DEC_PACKET_EMPTY;
- dec->packet_payload_length = 2;
- dec->packet_state = 7;
- } else {
- printk("%s: unknown packet type: "
- "%02x%02x\n", __FUNCTION__,
- dec->packet[0], dec->packet[1]);
- dec->packet_state = 0;
- }
- }
-
- length--;
- break;
-
- case 5:
- dec->packet[dec->packet_length++] = *b++;
-
- if (dec->packet_type == TTUSB_DEC_PACKET_PVA &&
- dec->packet_length == 8) {
- dec->packet_state++;
- dec->packet_payload_length = 8 +
- (dec->packet[6] << 8) +
- dec->packet[7];
- } else if (dec->packet_type ==
- TTUSB_DEC_PACKET_SECTION &&
- dec->packet_length == 5) {
- dec->packet_state++;
- dec->packet_payload_length = 5 +
- ((dec->packet[3] & 0x0f) << 8) +
- dec->packet[4];
- }
-
- length--;
- break;
-
- case 6: {
- int remainder = dec->packet_payload_length -
- dec->packet_length;
-
- if (length >= remainder) {
- memcpy(dec->packet + dec->packet_length,
- b, remainder);
- dec->packet_length += remainder;
- b += remainder;
- length -= remainder;
- dec->packet_state++;
- } else {
- memcpy(&dec->packet[dec->packet_length],
- b, length);
- dec->packet_length += length;
- length = 0;
- }
-
- break;
- }
-
- case 7: {
- int tail = 4;
-
- dec->packet[dec->packet_length++] = *b++;
-
- if (dec->packet_type == TTUSB_DEC_PACKET_SECTION &&
- dec->packet_payload_length % 2)
- tail++;
-
- if (dec->packet_length ==
- dec->packet_payload_length + tail) {
- ttusb_dec_process_packet(dec);
- dec->packet_state = 0;
- }
-
- length--;
- break;
- }
-
- default:
- printk("%s: illegal packet state encountered.\n",
- __FUNCTION__);
- dec->packet_state = 0;
- }
- }
-}
-
-static void ttusb_dec_process_urb_frame_list(unsigned long data)
-{
- struct ttusb_dec *dec = (struct ttusb_dec *)data;
- struct list_head *item;
- struct urb_frame *frame;
- unsigned long flags;
-
- while (1) {
- spin_lock_irqsave(&dec->urb_frame_list_lock, flags);
- if ((item = dec->urb_frame_list.next) != &dec->urb_frame_list) {
- frame = list_entry(item, struct urb_frame,
- urb_frame_list);
- list_del(&frame->urb_frame_list);
- } else {
- spin_unlock_irqrestore(&dec->urb_frame_list_lock,
- flags);
- return;
- }
- spin_unlock_irqrestore(&dec->urb_frame_list_lock, flags);
-
- ttusb_dec_process_urb_frame(dec, frame->data, frame->length);
- kfree(frame);
- }
-}
-
-static void ttusb_dec_process_urb(struct urb *urb, struct pt_regs *ptregs)
-{
- struct ttusb_dec *dec = urb->context;
-
- if (!urb->status) {
- int i;
-
- for (i = 0; i < FRAMES_PER_ISO_BUF; i++) {
- struct usb_iso_packet_descriptor *d;
- u8 *b;
- int length;
- struct urb_frame *frame;
-
- d = &urb->iso_frame_desc[i];
- b = urb->transfer_buffer + d->offset;
- length = d->actual_length;
-
- if ((frame = kmalloc(sizeof(struct urb_frame),
- GFP_ATOMIC))) {
- unsigned long flags;
-
- memcpy(frame->data, b, length);
- frame->length = length;
-
- spin_lock_irqsave(&dec->urb_frame_list_lock,
- flags);
- list_add_tail(&frame->urb_frame_list,
- &dec->urb_frame_list);
- spin_unlock_irqrestore(&dec->urb_frame_list_lock,
- flags);
-
- tasklet_schedule(&dec->urb_tasklet);
- }
- }
- } else {
- /* -ENOENT is expected when unlinking urbs */
- if (urb->status != -ENOENT)
- dprintk("%s: urb error: %d\n", __FUNCTION__,
- urb->status);
- }
-
- if (dec->iso_stream_count)
- usb_submit_urb(urb, GFP_ATOMIC);
-}
-
-static void ttusb_dec_setup_urbs(struct ttusb_dec *dec)
-{
- int i, j, buffer_offset = 0;
-
- dprintk("%s\n", __FUNCTION__);
-
- for (i = 0; i < ISO_BUF_COUNT; i++) {
- int frame_offset = 0;
- struct urb *urb = dec->iso_urb[i];
-
- urb->dev = dec->udev;
- urb->context = dec;
- urb->complete = ttusb_dec_process_urb;
- urb->pipe = dec->in_pipe;
- urb->transfer_flags = URB_ISO_ASAP;
- urb->interval = 1;
- urb->number_of_packets = FRAMES_PER_ISO_BUF;
- urb->transfer_buffer_length = ISO_FRAME_SIZE *
- FRAMES_PER_ISO_BUF;
- urb->transfer_buffer = dec->iso_buffer + buffer_offset;
- buffer_offset += ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF;
-
- for (j = 0; j < FRAMES_PER_ISO_BUF; j++) {
- urb->iso_frame_desc[j].offset = frame_offset;
- urb->iso_frame_desc[j].length = ISO_FRAME_SIZE;
- frame_offset += ISO_FRAME_SIZE;
- }
- }
-}
-
-static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec)
-{
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (mutex_lock_interruptible(&dec->iso_mutex))
- return;
-
- dec->iso_stream_count--;
-
- if (!dec->iso_stream_count) {
- for (i = 0; i < ISO_BUF_COUNT; i++)
- usb_kill_urb(dec->iso_urb[i]);
- }
-
- mutex_unlock(&dec->iso_mutex);
-}
-
-/* Setting the interface of the DEC tends to take down the USB communications
- * for a short period, so it's important not to call this function just before
- * trying to talk to it.
- */
-static int ttusb_dec_set_interface(struct ttusb_dec *dec,
- enum ttusb_dec_interface interface)
-{
- int result = 0;
- u8 b[] = { 0x05 };
-
- if (interface != dec->interface) {
- switch (interface) {
- case TTUSB_DEC_INTERFACE_INITIAL:
- result = usb_set_interface(dec->udev, 0, 0);
- break;
- case TTUSB_DEC_INTERFACE_IN:
- result = ttusb_dec_send_command(dec, 0x80, sizeof(b),
- b, NULL, NULL);
- if (result)
- return result;
- result = usb_set_interface(dec->udev, 0, 8);
- break;
- case TTUSB_DEC_INTERFACE_OUT:
- result = usb_set_interface(dec->udev, 0, 1);
- break;
- }
-
- if (result)
- return result;
-
- dec->interface = interface;
- }
-
- return 0;
-}
-
-static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec)
-{
- int i, result;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (mutex_lock_interruptible(&dec->iso_mutex))
- return -EAGAIN;
-
- if (!dec->iso_stream_count) {
- ttusb_dec_setup_urbs(dec);
-
- dec->packet_state = 0;
- dec->v_pes_postbytes = 0;
- dec->next_packet_id = 0;
-
- for (i = 0; i < ISO_BUF_COUNT; i++) {
- if ((result = usb_submit_urb(dec->iso_urb[i],
- GFP_ATOMIC))) {
- printk("%s: failed urb submission %d: "
- "error %d\n", __FUNCTION__, i, result);
-
- while (i) {
- usb_kill_urb(dec->iso_urb[i - 1]);
- i--;
- }
-
- mutex_unlock(&dec->iso_mutex);
- return result;
- }
- }
- }
-
- dec->iso_stream_count++;
-
- mutex_unlock(&dec->iso_mutex);
-
- return 0;
-}
-
-static int ttusb_dec_start_ts_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
- struct ttusb_dec *dec = dvbdmx->priv;
- u8 b0[] = { 0x05 };
- int result = 0;
-
- dprintk("%s\n", __FUNCTION__);
-
- dprintk(" ts_type:");
-
- if (dvbdmxfeed->ts_type & TS_DECODER)
- dprintk(" TS_DECODER");
-
- if (dvbdmxfeed->ts_type & TS_PACKET)
- dprintk(" TS_PACKET");
-
- if (dvbdmxfeed->ts_type & TS_PAYLOAD_ONLY)
- dprintk(" TS_PAYLOAD_ONLY");
-
- dprintk("\n");
-
- switch (dvbdmxfeed->pes_type) {
-
- case DMX_TS_PES_VIDEO:
- dprintk(" pes_type: DMX_TS_PES_VIDEO\n");
- dec->pid[DMX_PES_PCR] = dvbdmxfeed->pid;
- dec->pid[DMX_PES_VIDEO] = dvbdmxfeed->pid;
- dec->video_filter = dvbdmxfeed->filter;
- ttusb_dec_set_pids(dec);
- break;
-
- case DMX_TS_PES_AUDIO:
- dprintk(" pes_type: DMX_TS_PES_AUDIO\n");
- dec->pid[DMX_PES_AUDIO] = dvbdmxfeed->pid;
- dec->audio_filter = dvbdmxfeed->filter;
- ttusb_dec_set_pids(dec);
- break;
-
- case DMX_TS_PES_TELETEXT:
- dec->pid[DMX_PES_TELETEXT] = dvbdmxfeed->pid;
- dprintk(" pes_type: DMX_TS_PES_TELETEXT(not supported)\n");
- return -ENOSYS;
-
- case DMX_TS_PES_PCR:
- dprintk(" pes_type: DMX_TS_PES_PCR\n");
- dec->pid[DMX_PES_PCR] = dvbdmxfeed->pid;
- ttusb_dec_set_pids(dec);
- break;
-
- case DMX_TS_PES_OTHER:
- dprintk(" pes_type: DMX_TS_PES_OTHER(not supported)\n");
- return -ENOSYS;
-
- default:
- dprintk(" pes_type: unknown (%d)\n", dvbdmxfeed->pes_type);
- return -EINVAL;
-
- }
-
- result = ttusb_dec_send_command(dec, 0x80, sizeof(b0), b0, NULL, NULL);
- if (result)
- return result;
-
- dec->pva_stream_count++;
- return ttusb_dec_start_iso_xfer(dec);
-}
-
-static int ttusb_dec_start_sec_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct ttusb_dec *dec = dvbdmxfeed->demux->priv;
- u8 b0[] = { 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00 };
- u16 pid;
- u8 c[COMMAND_PACKET_SIZE];
- int c_length;
- int result;
- struct filter_info *finfo;
- unsigned long flags;
- u8 x = 1;
-
- dprintk("%s\n", __FUNCTION__);
-
- pid = htons(dvbdmxfeed->pid);
- memcpy(&b0[0], &pid, 2);
- memcpy(&b0[4], &x, 1);
- memcpy(&b0[5], &dvbdmxfeed->filter->filter.filter_value[0], 1);
-
- result = ttusb_dec_send_command(dec, 0x60, sizeof(b0), b0,
- &c_length, c);
-
- if (!result) {
- if (c_length == 2) {
- if (!(finfo = kmalloc(sizeof(struct filter_info),
- GFP_ATOMIC)))
- return -ENOMEM;
-
- finfo->stream_id = c[1];
- finfo->filter = dvbdmxfeed->filter;
-
- spin_lock_irqsave(&dec->filter_info_list_lock, flags);
- list_add_tail(&finfo->filter_info_list,
- &dec->filter_info_list);
- spin_unlock_irqrestore(&dec->filter_info_list_lock,
- flags);
-
- dvbdmxfeed->priv = finfo;
-
- dec->filter_stream_count++;
- return ttusb_dec_start_iso_xfer(dec);
- }
-
- return -EAGAIN;
- } else
- return result;
-}
-
-static int ttusb_dec_start_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct dvb_demux *dvbdmx = dvbdmxfeed->demux;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (!dvbdmx->dmx.frontend)
- return -EINVAL;
-
- dprintk(" pid: 0x%04X\n", dvbdmxfeed->pid);
-
- switch (dvbdmxfeed->type) {
-
- case DMX_TYPE_TS:
- return ttusb_dec_start_ts_feed(dvbdmxfeed);
- break;
-
- case DMX_TYPE_SEC:
- return ttusb_dec_start_sec_feed(dvbdmxfeed);
- break;
-
- default:
- dprintk(" type: unknown (%d)\n", dvbdmxfeed->type);
- return -EINVAL;
-
- }
-}
-
-static int ttusb_dec_stop_ts_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct ttusb_dec *dec = dvbdmxfeed->demux->priv;
- u8 b0[] = { 0x00 };
-
- ttusb_dec_send_command(dec, 0x81, sizeof(b0), b0, NULL, NULL);
-
- dec->pva_stream_count--;
-
- ttusb_dec_stop_iso_xfer(dec);
-
- return 0;
-}
-
-static int ttusb_dec_stop_sec_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- struct ttusb_dec *dec = dvbdmxfeed->demux->priv;
- u8 b0[] = { 0x00, 0x00 };
- struct filter_info *finfo = (struct filter_info *)dvbdmxfeed->priv;
- unsigned long flags;
-
- b0[1] = finfo->stream_id;
- spin_lock_irqsave(&dec->filter_info_list_lock, flags);
- list_del(&finfo->filter_info_list);
- spin_unlock_irqrestore(&dec->filter_info_list_lock, flags);
- kfree(finfo);
- ttusb_dec_send_command(dec, 0x62, sizeof(b0), b0, NULL, NULL);
-
- dec->filter_stream_count--;
-
- ttusb_dec_stop_iso_xfer(dec);
-
- return 0;
-}
-
-static int ttusb_dec_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
-{
- dprintk("%s\n", __FUNCTION__);
-
- switch (dvbdmxfeed->type) {
- case DMX_TYPE_TS:
- return ttusb_dec_stop_ts_feed(dvbdmxfeed);
- break;
-
- case DMX_TYPE_SEC:
- return ttusb_dec_stop_sec_feed(dvbdmxfeed);
- break;
- }
-
- return 0;
-}
-
-static void ttusb_dec_free_iso_urbs(struct ttusb_dec *dec)
-{
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- for (i = 0; i < ISO_BUF_COUNT; i++)
- if (dec->iso_urb[i])
- usb_free_urb(dec->iso_urb[i]);
-
- pci_free_consistent(NULL,
- ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF *
- ISO_BUF_COUNT),
- dec->iso_buffer, dec->iso_dma_handle);
-}
-
-static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec)
-{
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- dec->iso_buffer = pci_alloc_consistent(NULL,
- ISO_FRAME_SIZE *
- (FRAMES_PER_ISO_BUF *
- ISO_BUF_COUNT),
- &dec->iso_dma_handle);
-
- memset(dec->iso_buffer, 0,
- ISO_FRAME_SIZE * (FRAMES_PER_ISO_BUF * ISO_BUF_COUNT));
-
- for (i = 0; i < ISO_BUF_COUNT; i++) {
- struct urb *urb;
-
- if (!(urb = usb_alloc_urb(FRAMES_PER_ISO_BUF, GFP_ATOMIC))) {
- ttusb_dec_free_iso_urbs(dec);
- return -ENOMEM;
- }
-
- dec->iso_urb[i] = urb;
- }
-
- ttusb_dec_setup_urbs(dec);
-
- return 0;
-}
-
-static void ttusb_dec_init_tasklet(struct ttusb_dec *dec)
-{
- spin_lock_init(&dec->urb_frame_list_lock);
- INIT_LIST_HEAD(&dec->urb_frame_list);
- tasklet_init(&dec->urb_tasklet, ttusb_dec_process_urb_frame_list,
- (unsigned long)dec);
-}
-
-static int ttusb_init_rc( struct ttusb_dec *dec)
-{
- struct input_dev *input_dev;
- u8 b[] = { 0x00, 0x01 };
- int i;
-
- usb_make_path(dec->udev, dec->rc_phys, sizeof(dec->rc_phys));
- strlcpy(dec->rc_phys, "/input0", sizeof(dec->rc_phys));
-
- dec->rc_input_dev = input_dev = input_allocate_device();
- if (!input_dev)
- return -ENOMEM;
-
- input_dev->name = "ttusb_dec remote control";
- input_dev->phys = dec->rc_phys;
- input_dev->evbit[0] = BIT(EV_KEY);
- input_dev->keycodesize = sizeof(u16);
- input_dev->keycodemax = 0x1a;
- input_dev->keycode = rc_keys;
-
- for (i = 0; i < ARRAY_SIZE(rc_keys); i++)
- set_bit(rc_keys[i], input_dev->keybit);
-
- input_register_device(input_dev);
-
- if (usb_submit_urb(dec->irq_urb, GFP_KERNEL))
- printk("%s: usb_submit_urb failed\n",__FUNCTION__);
- /* enable irq pipe */
- ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL);
-
- return 0;
-}
-
-static void ttusb_dec_init_v_pes(struct ttusb_dec *dec)
-{
- dprintk("%s\n", __FUNCTION__);
-
- dec->v_pes[0] = 0x00;
- dec->v_pes[1] = 0x00;
- dec->v_pes[2] = 0x01;
- dec->v_pes[3] = 0xe0;
-}
-
-static int ttusb_dec_init_usb(struct ttusb_dec *dec)
-{
- dprintk("%s\n", __FUNCTION__);
-
- mutex_init(&dec->usb_mutex);
- mutex_init(&dec->iso_mutex);
-
- dec->command_pipe = usb_sndbulkpipe(dec->udev, COMMAND_PIPE);
- dec->result_pipe = usb_rcvbulkpipe(dec->udev, RESULT_PIPE);
- dec->in_pipe = usb_rcvisocpipe(dec->udev, IN_PIPE);
- dec->out_pipe = usb_sndisocpipe(dec->udev, OUT_PIPE);
- dec->irq_pipe = usb_rcvintpipe(dec->udev, IRQ_PIPE);
-
- if(enable_rc) {
- dec->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
- if(!dec->irq_urb) {
- return -ENOMEM;
- }
- dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE,
- SLAB_ATOMIC, &dec->irq_dma_handle);
- if(!dec->irq_buffer) {
- return -ENOMEM;
- }
- usb_fill_int_urb(dec->irq_urb, dec->udev,dec->irq_pipe,
- dec->irq_buffer, IRQ_PACKET_SIZE,
- ttusb_dec_handle_irq, dec, 1);
- dec->irq_urb->transfer_dma = dec->irq_dma_handle;
- dec->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
- }
-
- return ttusb_dec_alloc_iso_urbs(dec);
-}
-
-static int ttusb_dec_boot_dsp(struct ttusb_dec *dec)
-{
- int i, j, actual_len, result, size, trans_count;
- u8 b0[] = { 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x61, 0x00 };
- u8 b1[] = { 0x61 };
- u8 *b;
- char idstring[21];
- u8 *firmware = NULL;
- size_t firmware_size = 0;
- u16 firmware_csum = 0;
- u16 firmware_csum_ns;
- u32 firmware_size_nl;
- u32 crc32_csum, crc32_check, tmp;
- const struct firmware *fw_entry = NULL;
-
- dprintk("%s\n", __FUNCTION__);
-
- if (request_firmware(&fw_entry, dec->firmware_name, &dec->udev->dev)) {
- printk(KERN_ERR "%s: Firmware (%s) unavailable.\n",
- __FUNCTION__, dec->firmware_name);
- return 1;
- }
-
- firmware = fw_entry->data;
- firmware_size = fw_entry->size;
-
- if (firmware_size < 60) {
- printk("%s: firmware size too small for DSP code (%zu < 60).\n",
- __FUNCTION__, firmware_size);
- release_firmware(fw_entry);
- return -1;
- }
-
- /* a 32 bit checksum over the first 56 bytes of the DSP Code is stored
- at offset 56 of file, so use it to check if the firmware file is
- valid. */
- crc32_csum = crc32(~0L, firmware, 56) ^ ~0L;
- memcpy(&tmp, &firmware[56], 4);
- crc32_check = htonl(tmp);
- if (crc32_csum != crc32_check) {
- printk("%s: crc32 check of DSP code failed (calculated "
- "0x%08x != 0x%08x in file), file invalid.\n",
- __FUNCTION__, crc32_csum, crc32_check);
- release_firmware(fw_entry);
- return -1;
- }
- memcpy(idstring, &firmware[36], 20);
- idstring[20] = '\0';
- printk(KERN_INFO "ttusb_dec: found DSP code \"%s\".\n", idstring);
-
- firmware_size_nl = htonl(firmware_size);
- memcpy(b0, &firmware_size_nl, 4);
- firmware_csum = crc16(~0, firmware, firmware_size) ^ ~0;
- firmware_csum_ns = htons(firmware_csum);
- memcpy(&b0[6], &firmware_csum_ns, 2);
-
- result = ttusb_dec_send_command(dec, 0x41, sizeof(b0), b0, NULL, NULL);
-
- if (result) {
- release_firmware(fw_entry);
- return result;
- }
-
- trans_count = 0;
- j = 0;
-
- b = kmalloc(ARM_PACKET_SIZE, GFP_KERNEL);
- if (b == NULL) {
- release_firmware(fw_entry);
- return -ENOMEM;
- }
-
- for (i = 0; i < firmware_size; i += COMMAND_PACKET_SIZE) {
- size = firmware_size - i;
- if (size > COMMAND_PACKET_SIZE)
- size = COMMAND_PACKET_SIZE;
-
- b[j + 0] = 0xaa;
- b[j + 1] = trans_count++;
- b[j + 2] = 0xf0;
- b[j + 3] = size;
- memcpy(&b[j + 4], &firmware[i], size);
-
- j += COMMAND_PACKET_SIZE + 4;
-
- if (j >= ARM_PACKET_SIZE) {
- result = usb_bulk_msg(dec->udev, dec->command_pipe, b,
- ARM_PACKET_SIZE, &actual_len,
- 100);
- j = 0;
- } else if (size < COMMAND_PACKET_SIZE) {
- result = usb_bulk_msg(dec->udev, dec->command_pipe, b,
- j - COMMAND_PACKET_SIZE + size,
- &actual_len, 100);
- }
- }
-
- result = ttusb_dec_send_command(dec, 0x43, sizeof(b1), b1, NULL, NULL);
-
- release_firmware(fw_entry);
- kfree(b);
-
- return result;
-}
-
-static int ttusb_dec_init_stb(struct ttusb_dec *dec)
-{
- int result;
- unsigned int mode, model, version;
-
- dprintk("%s\n", __FUNCTION__);
-
- result = ttusb_dec_get_stb_state(dec, &mode, &model, &version);
-
- if (!result) {
- if (!mode) {
- if (version == 0xABCDEFAB)
- printk(KERN_INFO "ttusb_dec: no version "
- "info in Firmware\n");
- else
- printk(KERN_INFO "ttusb_dec: Firmware "
- "%x.%02x%c%c\n",
- version >> 24, (version >> 16) & 0xff,
- (version >> 8) & 0xff, version & 0xff);
-
- result = ttusb_dec_boot_dsp(dec);
- if (result)
- return result;
- else
- return 1;
- } else {
- /* We can't trust the USB IDs that some firmwares
- give the box */
- switch (model) {
- case 0x00070001:
- case 0x00070008:
- case 0x0007000c:
- ttusb_dec_set_model(dec, TTUSB_DEC3000S);
- break;
- case 0x00070009:
- case 0x00070013:
- ttusb_dec_set_model(dec, TTUSB_DEC2000T);
- break;
- case 0x00070011:
- ttusb_dec_set_model(dec, TTUSB_DEC2540T);
- break;
- default:
- printk(KERN_ERR "%s: unknown model returned "
- "by firmware (%08x) - please report\n",
- __FUNCTION__, model);
- return -1;
- break;
- }
-
- if (version >= 0x01770000)
- dec->can_playback = 1;
-
- return 0;
- }
- }
- else
- return result;
-}
-
-static int ttusb_dec_init_dvb(struct ttusb_dec *dec)
-{
- int result;
-
- dprintk("%s\n", __FUNCTION__);
-
- if ((result = dvb_register_adapter(&dec->adapter,
- dec->model_name, THIS_MODULE, &dec->udev->dev)) < 0) {
- printk("%s: dvb_register_adapter failed: error %d\n",
- __FUNCTION__, result);
-
- return result;
- }
-
- dec->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
-
- dec->demux.priv = (void *)dec;
- dec->demux.filternum = 31;
- dec->demux.feednum = 31;
- dec->demux.start_feed = ttusb_dec_start_feed;
- dec->demux.stop_feed = ttusb_dec_stop_feed;
- dec->demux.write_to_decoder = NULL;
-
- if ((result = dvb_dmx_init(&dec->demux)) < 0) {
- printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__,
- result);
-
- dvb_unregister_adapter(&dec->adapter);
-
- return result;
- }
-
- dec->dmxdev.filternum = 32;
- dec->dmxdev.demux = &dec->demux.dmx;
- dec->dmxdev.capabilities = 0;
-
- if ((result = dvb_dmxdev_init(&dec->dmxdev, &dec->adapter)) < 0) {
- printk("%s: dvb_dmxdev_init failed: error %d\n",
- __FUNCTION__, result);
-
- dvb_dmx_release(&dec->demux);
- dvb_unregister_adapter(&dec->adapter);
-
- return result;
- }
-
- dec->frontend.source = DMX_FRONTEND_0;
-
- if ((result = dec->demux.dmx.add_frontend(&dec->demux.dmx,
- &dec->frontend)) < 0) {
- printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__,
- result);
-
- dvb_dmxdev_release(&dec->dmxdev);
- dvb_dmx_release(&dec->demux);
- dvb_unregister_adapter(&dec->adapter);
-
- return result;
- }
-
- if ((result = dec->demux.dmx.connect_frontend(&dec->demux.dmx,
- &dec->frontend)) < 0) {
- printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__,
- result);
-
- dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend);
- dvb_dmxdev_release(&dec->dmxdev);
- dvb_dmx_release(&dec->demux);
- dvb_unregister_adapter(&dec->adapter);
-
- return result;
- }
-
- dvb_net_init(&dec->adapter, &dec->dvb_net, &dec->demux.dmx);
-
- return 0;
-}
-
-static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)
-{
- dprintk("%s\n", __FUNCTION__);
-
- dvb_net_release(&dec->dvb_net);
- dec->demux.dmx.close(&dec->demux.dmx);
- dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend);
- dvb_dmxdev_release(&dec->dmxdev);
- dvb_dmx_release(&dec->demux);
- if (dec->fe) dvb_unregister_frontend(dec->fe);
- dvb_unregister_adapter(&dec->adapter);
-}
-
-static void ttusb_dec_exit_rc(struct ttusb_dec *dec)
-{
-
- dprintk("%s\n", __FUNCTION__);
- /* we have to check whether the irq URB is already submitted.
- * As the irq is submitted after the interface is changed,
- * this is the best method i figured out.
- * Any others?*/
- if (dec->interface == TTUSB_DEC_INTERFACE_IN)
- usb_kill_urb(dec->irq_urb);
-
- usb_free_urb(dec->irq_urb);
-
- usb_buffer_free(dec->udev,IRQ_PACKET_SIZE,
- dec->irq_buffer, dec->irq_dma_handle);
-
- if (dec->rc_input_dev) {
- input_unregister_device(dec->rc_input_dev);
- dec->rc_input_dev = NULL;
- }
-}
-
-
-static void ttusb_dec_exit_usb(struct ttusb_dec *dec)
-{
- int i;
-
- dprintk("%s\n", __FUNCTION__);
-
- dec->iso_stream_count = 0;
-
- for (i = 0; i < ISO_BUF_COUNT; i++)
- usb_kill_urb(dec->iso_urb[i]);
-
- ttusb_dec_free_iso_urbs(dec);
-}
-
-static void ttusb_dec_exit_tasklet(struct ttusb_dec *dec)
-{
- struct list_head *item;
- struct urb_frame *frame;
-
- tasklet_kill(&dec->urb_tasklet);
-
- while ((item = dec->urb_frame_list.next) != &dec->urb_frame_list) {
- frame = list_entry(item, struct urb_frame, urb_frame_list);
- list_del(&frame->urb_frame_list);
- kfree(frame);
- }
-}
-
-static void ttusb_dec_init_filters(struct ttusb_dec *dec)
-{
- INIT_LIST_HEAD(&dec->filter_info_list);
- spin_lock_init(&dec->filter_info_list_lock);
-}
-
-static void ttusb_dec_exit_filters(struct ttusb_dec *dec)
-{
- struct list_head *item;
- struct filter_info *finfo;
-
- while ((item = dec->filter_info_list.next) != &dec->filter_info_list) {
- finfo = list_entry(item, struct filter_info, filter_info_list);
- list_del(&finfo->filter_info_list);
- kfree(finfo);
- }
-}
-
-static int fe_send_command(struct dvb_frontend* fe, const u8 command,
- int param_length, const u8 params[],
- int *result_length, u8 cmd_result[])
-{
- struct ttusb_dec* dec = fe->dvb->priv;
- return ttusb_dec_send_command(dec, command, param_length, params, result_length, cmd_result);
-}
-
-static struct ttusbdecfe_config fe_config = {
- .send_command = fe_send_command
-};
-
-static int ttusb_dec_probe(struct usb_interface *intf,
- const struct usb_device_id *id)
-{
- struct usb_device *udev;
- struct ttusb_dec *dec;
-
- dprintk("%s\n", __FUNCTION__);
-
- udev = interface_to_usbdev(intf);
-
- if (!(dec = kzalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) {
- printk("%s: couldn't allocate memory.\n", __FUNCTION__);
- return -ENOMEM;
- }
-
- usb_set_intfdata(intf, (void *)dec);
-
- switch (le16_to_cpu(id->idProduct)) {
- case 0x1006:
- ttusb_dec_set_model(dec, TTUSB_DEC3000S);
- break;
-
- case 0x1008:
- ttusb_dec_set_model(dec, TTUSB_DEC2000T);
- break;
-
- case 0x1009:
- ttusb_dec_set_model(dec, TTUSB_DEC2540T);
- break;
- }
-
- dec->udev = udev;
-
- if (ttusb_dec_init_usb(dec))
- return 0;
- if (ttusb_dec_init_stb(dec)) {
- ttusb_dec_exit_usb(dec);
- return 0;
- }
- ttusb_dec_init_dvb(dec);
-
- dec->adapter.priv = dec;
- switch (le16_to_cpu(id->idProduct)) {
- case 0x1006:
- dec->fe = ttusbdecfe_dvbs_attach(&fe_config);
- break;
-
- case 0x1008:
- case 0x1009:
- dec->fe = ttusbdecfe_dvbt_attach(&fe_config);
- break;
- }
-
- if (dec->fe == NULL) {
- printk("dvb-ttusb-dec: A frontend driver was not found for device %04x/%04x\n",
- le16_to_cpu(dec->udev->descriptor.idVendor),
- le16_to_cpu(dec->udev->descriptor.idProduct));
- } else {
- if (dvb_register_frontend(&dec->adapter, dec->fe)) {
- printk("budget-ci: Frontend registration failed!\n");
- if (dec->fe->ops.release)
- dec->fe->ops.release(dec->fe);
- dec->fe = NULL;
- }
- }
-
- ttusb_dec_init_v_pes(dec);
- ttusb_dec_init_filters(dec);
- ttusb_dec_init_tasklet(dec);
-
- dec->active = 1;
-
- ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN);
-
- if (enable_rc)
- ttusb_init_rc(dec);
-
- return 0;
-}
-
-static void ttusb_dec_disconnect(struct usb_interface *intf)
-{
- struct ttusb_dec *dec = usb_get_intfdata(intf);
-
- usb_set_intfdata(intf, NULL);
-
- dprintk("%s\n", __FUNCTION__);
-
- if (dec->active) {
- ttusb_dec_exit_tasklet(dec);
- ttusb_dec_exit_filters(dec);
- if(enable_rc)
- ttusb_dec_exit_rc(dec);
- ttusb_dec_exit_usb(dec);
- ttusb_dec_exit_dvb(dec);
- }
-
- kfree(dec);
-}
-
-static void ttusb_dec_set_model(struct ttusb_dec *dec,
- enum ttusb_dec_model model)
-{
- dec->model = model;
-
- switch (model) {
- case TTUSB_DEC2000T:
- dec->model_name = "DEC2000-t";
- dec->firmware_name = "dvb-ttusb-dec-2000t.fw";
- break;
-
- case TTUSB_DEC2540T:
- dec->model_name = "DEC2540-t";
- dec->firmware_name = "dvb-ttusb-dec-2540t.fw";
- break;
-
- case TTUSB_DEC3000S:
- dec->model_name = "DEC3000-s";
- dec->firmware_name = "dvb-ttusb-dec-3000s.fw";
- break;
- }
-}
-
-static struct usb_device_id ttusb_dec_table[] = {
- {USB_DEVICE(0x0b48, 0x1006)}, /* DEC3000-s */
- /*{USB_DEVICE(0x0b48, 0x1007)}, Unconfirmed */
- {USB_DEVICE(0x0b48, 0x1008)}, /* DEC2000-t */
- {USB_DEVICE(0x0b48, 0x1009)}, /* DEC2540-t */
- {}
-};
-
-static struct usb_driver ttusb_dec_driver = {
- .name = "ttusb-dec",
- .probe = ttusb_dec_probe,
- .disconnect = ttusb_dec_disconnect,
- .id_table = ttusb_dec_table,
-};
-
-static int __init ttusb_dec_init(void)
-{
- int result;
-
- if ((result = usb_register(&ttusb_dec_driver)) < 0) {
- printk("%s: initialisation failed: error %d.\n", __FUNCTION__,
- result);
- return result;
- }
-
- return 0;
-}
-
-static void __exit ttusb_dec_exit(void)
-{
- usb_deregister(&ttusb_dec_driver);
-}
-
-module_init(ttusb_dec_init);
-module_exit(ttusb_dec_exit);
-
-MODULE_AUTHOR("Alex Woods <linux-dvb@giblets.org>");
-MODULE_DESCRIPTION(DRIVER_NAME);
-MODULE_LICENSE("GPL");
-MODULE_DEVICE_TABLE(usb, ttusb_dec_table);
diff --git a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
deleted file mode 100644
index 42f39a89bc4..00000000000
--- a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * TTUSB DEC Frontend Driver
- *
- * Copyright (C) 2003-2004 Alex Woods <linux-dvb@giblets.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include "dvb_frontend.h"
-#include "ttusbdecfe.h"
-
-
-#define LOF_HI 10600000
-#define LOF_LO 9750000
-
-struct ttusbdecfe_state {
-
- /* configuration settings */
- const struct ttusbdecfe_config* config;
-
- struct dvb_frontend frontend;
-
- u8 hi_band;
- u8 voltage;
-};
-
-
-static int ttusbdecfe_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct ttusbdecfe_state* state = fe->demodulator_priv;
- u8 b[] = { 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00 };
- u8 result[4];
- int len, ret;
-
- *status=0;
-
- ret=state->config->send_command(fe, 0x73, sizeof(b), b, &len, result);
- if(ret)
- return ret;
-
- if(len != 4) {
- printk(KERN_ERR "%s: unexpected reply\n", __FUNCTION__);
- return -EIO;
- }
-
- switch(result[3]) {
- case 1: /* not tuned yet */
- case 2: /* no signal/no lock*/
- break;
- case 3: /* signal found and locked*/
- *status = FE_HAS_SIGNAL | FE_HAS_VITERBI |
- FE_HAS_SYNC | FE_HAS_CARRIER | FE_HAS_LOCK;
- break;
- case 4:
- *status = FE_TIMEDOUT;
- break;
- default:
- pr_info("%s: returned unknown value: %d\n",
- __FUNCTION__, result[3]);
- return -EIO;
- }
-
- return 0;
-}
-
-static int ttusbdecfe_dvbt_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
- u8 b[] = { 0x00, 0x00, 0x00, 0x03,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0xff,
- 0x00, 0x00, 0x00, 0xff };
-
- u32 freq = htonl(p->frequency / 1000);
- memcpy(&b[4], &freq, sizeof (u32));
- state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
-
- return 0;
-}
-
-static int ttusbdecfe_dvbt_get_tune_settings(struct dvb_frontend* fe,
- struct dvb_frontend_tune_settings* fesettings)
-{
- fesettings->min_delay_ms = 1500;
- /* Drift compensation makes no sense for DVB-T */
- fesettings->step_size = 0;
- fesettings->max_drift = 0;
- return 0;
-}
-
-static int ttusbdecfe_dvbs_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
-{
- struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
-
- u8 b[] = { 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00 };
- u32 freq;
- u32 sym_rate;
- u32 band;
- u32 lnb_voltage;
-
- freq = htonl(p->frequency +
- (state->hi_band ? LOF_HI : LOF_LO));
- memcpy(&b[4], &freq, sizeof(u32));
- sym_rate = htonl(p->u.qam.symbol_rate);
- memcpy(&b[12], &sym_rate, sizeof(u32));
- band = htonl(state->hi_band ? LOF_HI : LOF_LO);
- memcpy(&b[24], &band, sizeof(u32));
- lnb_voltage = htonl(state->voltage);
- memcpy(&b[28], &lnb_voltage, sizeof(u32));
-
- state->config->send_command(fe, 0x71, sizeof(b), b, NULL, NULL);
-
- return 0;
-}
-
-static int ttusbdecfe_dvbs_diseqc_send_master_cmd(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd)
-{
- struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
- u8 b[] = { 0x00, 0xff, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00 };
-
- memcpy(&b[4], cmd->msg, cmd->msg_len);
-
- state->config->send_command(fe, 0x72,
- sizeof(b) - (6 - cmd->msg_len), b,
- NULL, NULL);
-
- return 0;
-}
-
-
-static int ttusbdecfe_dvbs_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
-{
- struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
-
- state->hi_band = (SEC_TONE_ON == tone);
-
- return 0;
-}
-
-
-static int ttusbdecfe_dvbs_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
-{
- struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
-
- switch (voltage) {
- case SEC_VOLTAGE_13:
- state->voltage = 13;
- break;
- case SEC_VOLTAGE_18:
- state->voltage = 18;
- break;
- default:
- return -EINVAL;
- }
-
- return 0;
-}
-
-static void ttusbdecfe_release(struct dvb_frontend* fe)
-{
- struct ttusbdecfe_state* state = (struct ttusbdecfe_state*) fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops ttusbdecfe_dvbt_ops;
-
-struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* config)
-{
- struct ttusbdecfe_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
- if (state == NULL)
- return NULL;
-
- /* setup the state */
- state->config = config;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &ttusbdecfe_dvbt_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-}
-
-static struct dvb_frontend_ops ttusbdecfe_dvbs_ops;
-
-struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* config)
-{
- struct ttusbdecfe_state* state = NULL;
-
- /* allocate memory for the internal state */
- state = (struct ttusbdecfe_state*) kmalloc(sizeof(struct ttusbdecfe_state), GFP_KERNEL);
- if (state == NULL)
- return NULL;
-
- /* setup the state */
- state->config = config;
- state->voltage = 0;
- state->hi_band = 0;
-
- /* create dvb_frontend */
- memcpy(&state->frontend.ops, &ttusbdecfe_dvbs_ops, sizeof(struct dvb_frontend_ops));
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-}
-
-static struct dvb_frontend_ops ttusbdecfe_dvbt_ops = {
-
- .info = {
- .name = "TechnoTrend/Hauppauge DEC2000-t Frontend",
- .type = FE_OFDM,
- .frequency_min = 51000000,
- .frequency_max = 858000000,
- .frequency_stepsize = 62500,
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
- FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
- FE_CAN_HIERARCHY_AUTO,
- },
-
- .release = ttusbdecfe_release,
-
- .set_frontend = ttusbdecfe_dvbt_set_frontend,
-
- .get_tune_settings = ttusbdecfe_dvbt_get_tune_settings,
-
- .read_status = ttusbdecfe_read_status,
-};
-
-static struct dvb_frontend_ops ttusbdecfe_dvbs_ops = {
-
- .info = {
- .name = "TechnoTrend/Hauppauge DEC3000-s Frontend",
- .type = FE_QPSK,
- .frequency_min = 950000,
- .frequency_max = 2150000,
- .frequency_stepsize = 125,
- .symbol_rate_min = 1000000, /* guessed */
- .symbol_rate_max = 45000000, /* guessed */
- .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
- FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
- FE_CAN_QPSK
- },
-
- .release = ttusbdecfe_release,
-
- .set_frontend = ttusbdecfe_dvbs_set_frontend,
-
- .read_status = ttusbdecfe_read_status,
-
- .diseqc_send_master_cmd = ttusbdecfe_dvbs_diseqc_send_master_cmd,
- .set_voltage = ttusbdecfe_dvbs_set_voltage,
- .set_tone = ttusbdecfe_dvbs_set_tone,
-};
-
-MODULE_DESCRIPTION("TTUSB DEC DVB-T/S Demodulator driver");
-MODULE_AUTHOR("Alex Woods/Andrew de Quincey");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(ttusbdecfe_dvbt_attach);
-EXPORT_SYMBOL(ttusbdecfe_dvbs_attach);
diff --git a/drivers/media/dvb/ttusb-dec/ttusbdecfe.h b/drivers/media/dvb/ttusb-dec/ttusbdecfe.h
deleted file mode 100644
index 15ccc3d1a20..00000000000
--- a/drivers/media/dvb/ttusb-dec/ttusbdecfe.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * TTUSB DEC Driver
- *
- * Copyright (C) 2003-2004 Alex Woods <linux-dvb@giblets.org>
- *
- * 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.
- *
- */
-
-#ifndef TTUSBDECFE_H
-#define TTUSBDECFE_H
-
-#include <linux/dvb/frontend.h>
-
-struct ttusbdecfe_config
-{
- int (*send_command)(struct dvb_frontend* fe, const u8 command,
- int param_length, const u8 params[],
- int *result_length, u8 cmd_result[]);
-};
-
-extern struct dvb_frontend* ttusbdecfe_dvbs_attach(const struct ttusbdecfe_config* config);
-
-extern struct dvb_frontend* ttusbdecfe_dvbt_attach(const struct ttusbdecfe_config* config);
-
-#endif // TTUSBDECFE_H