summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <devnull@localhost>2005-07-15 20:37:50 +0000
committerMauro Carvalho Chehab <devnull@localhost>2005-07-15 20:37:50 +0000
commitc3a91da831ec27aeade07db0e0e8700e6207c7cb (patch)
tree909363ed3bd7ffec1cf8c5af37f7e5e1be9393f2
parenta8c58c30dad76eafb34d48937934d5f9793f885f (diff)
downloadmediapointer-dvb-s2-c3a91da831ec27aeade07db0e0e8700e6207c7cb.tar.gz
mediapointer-dvb-s2-c3a91da831ec27aeade07db0e0e8700e6207c7cb.tar.bz2
DVB Stuff removed. Makefile now doesn't need it also.
compat.h changed to reflect latest API change. Included a script to make ChangeLog Generation easier. Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
-rw-r--r--v4l/.bp/2.6/dvb-cx227023
-rw-r--r--v4l/.bp/2.6/dvb-mt3522
-rw-r--r--v4l/.bp/2.6/dvb-or511322
-rw-r--r--v4l/.buildpatch100
-rw-r--r--v4l/ChangeLog28
-rw-r--r--v4l/Makefile14
-rw-r--r--v4l/compat.h8
-rw-r--r--v4l/lgdt3302.c601
-rw-r--r--v4l/lgdt3302.h49
-rw-r--r--v4l/lgdt3302_priv.h72
-rw-r--r--v4l/mt352.c633
-rw-r--r--v4l/mt352.h72
-rw-r--r--v4l/mt352_priv.h127
-rw-r--r--v4l/or51132.c637
-rw-r--r--v4l/or51132.h50
-rw-r--r--v4l/scripts/prepare-ChangeLog.pl588
-rw-r--r--v4l/tda1004x.c1281
-rw-r--r--v4l/tda1004x.h86
18 files changed, 725 insertions, 3628 deletions
diff --git a/v4l/.bp/2.6/dvb-cx22702 b/v4l/.bp/2.6/dvb-cx22702
deleted file mode 100644
index bf4c6b67c..000000000
--- a/v4l/.bp/2.6/dvb-cx22702
+++ /dev/null
@@ -1,3 +0,0 @@
-#DVB stuff
-#srcdiff cx22702.h drivers/media/dvb/frontends/cx22702.h
-#srcdiff cx22702.c drivers/media/dvb/frontends/cx22702.c
diff --git a/v4l/.bp/2.6/dvb-mt352 b/v4l/.bp/2.6/dvb-mt352
deleted file mode 100644
index 88966c7f6..000000000
--- a/v4l/.bp/2.6/dvb-mt352
+++ /dev/null
@@ -1,2 +0,0 @@
-srcdiff mt352.h drivers/media/dvb/frontends/mt352.h
-srcdiff mt352.c drivers/media/dvb/frontends/mt352.c
diff --git a/v4l/.bp/2.6/dvb-or51132 b/v4l/.bp/2.6/dvb-or51132
deleted file mode 100644
index f5c5d8d57..000000000
--- a/v4l/.bp/2.6/dvb-or51132
+++ /dev/null
@@ -1,2 +0,0 @@
-srcdiff or51132.h drivers/media/dvb/frontends/or51132.h
-srcdiff or51132.c drivers/media/dvb/frontends/or51132.c
diff --git a/v4l/.buildpatch b/v4l/.buildpatch
index acbce9ad0..e8001bc62 100644
--- a/v4l/.buildpatch
+++ b/v4l/.buildpatch
@@ -1,3 +1,60 @@
+srcdiff ir-kbd-i2c.c drivers/media/video/ir-kbd-i2c.c
+srcdiff ir-kbd-gpio.c drivers/media/video/ir-kbd-gpio.c
+srcdiff bt848.h drivers/media/video/bt848.h
+srcdiff bttv.h drivers/media/video/bttv.h
+srcdiff bttvp.h drivers/media/video/bttvp.h
+srcdiff bttv-driver.c drivers/media/video/bttv-driver.c
+srcdiff bttv-cards.c drivers/media/video/bttv-cards.c
+srcdiff bttv-if.c drivers/media/video/bttv-if.c
+srcdiff bttv-risc.c drivers/media/video/bttv-risc.c
+srcdiff bttv-vbi.c drivers/media/video/bttv-vbi.c
+srcdiff bttv-gpio.c drivers/media/video/bttv-gpio.c
+srcdiff bttv-i2c.c drivers/media/video/bttv-i2c.c
+
+srcdiff btcx-risc.h drivers/media/video/btcx-risc.h
+srcdiff btcx-risc.c drivers/media/video/btcx-risc.c
+srcdiff cx88.h drivers/media/video/cx88/cx88.h
+srcdiff cx88-reg.h drivers/media/video/cx88/cx88-reg.h
+
+srcdiff cx88-cards.c drivers/media/video/cx88/cx88-cards.c
+srcdiff cx88-core.c drivers/media/video/cx88/cx88-core.c
+srcdiff cx88-i2c.c drivers/media/video/cx88/cx88-i2c.c
+srcdiff cx88-tvaudio.c drivers/media/video/cx88/cx88-tvaudio.c
+srcdiff cx88-video.c drivers/media/video/cx88/cx88-video.c
+srcdiff cx88-vbi.c drivers/media/video/cx88/cx88-vbi.c
+srcdiff cx88-input.c drivers/media/video/cx88/cx88-input.c
+
+srcdiff cx88-mpeg.c drivers/media/video/cx88/cx88-mpeg.c
+srcdiff cx88-dvb.c drivers/media/video/cx88/cx88-dvb.c
+srcdiff cx88-blackbird.c drivers/media/video/cx88/cx88-blackbird.c
+# It looks it is part of DVB stuff
+#srcdiff dvb-pll.h drivers/media/dvb/frontends/dvb-pll.h
+#srcdiff dvb-pll.c drivers/media/dvb/frontends/dvb-pll.c
+srcdiff saa7134-dvb.c drivers/media/video/saa7134/saa7134-dvb.c
+
+srcdiff saa6752hs.h include/media/saa6752hs.h
+srcdiff saa6752hs.c drivers/media/video/saa7134/saa6752hs.c
+srcdiff bt832.c drivers/media/video/bt832.c
+srcdiff bt832.h drivers/media/video/bt832.h
+srcdiff ir-common.h include/media/ir-common.h
+srcdiff ir-common.c drivers/media/common/ir-common.c
+srcdiff audiochip.h include/media/audiochip.h
+srcdiff id.h include/media/id.h
+srcdiff msp3400.c drivers/media/video/msp3400.c
+srcdiff msp3400.h drivers/media/video/msp3400.h
+srcdiff tda7432.c drivers/media/video/tda7432.c
+srcdiff tda9875.c drivers/media/video/tda9875.c
+srcdiff tvaudio.h drivers/media/video/tvaudio.h
+srcdiff tvaudio.c drivers/media/video/tvaudio.c
+srcdiff tvmixer.c drivers/media/video/tvmixer.c
+srcdiff tuner.h include/media/tuner.h
+srcdiff tuner-core.c drivers/media/video/tuner-core.c
+srcdiff tuner-simple.c drivers/media/video/tuner-simple.c
+srcdiff mt20xx.c drivers/media/video/mt20xx.c
+srcdiff tda8290.c drivers/media/video/tda8290.c
+srcdiff tda9887.c drivers/media/video/tda9887.c
+srcdiff tea5767.c drivers/media/video/tea5767.c
+
srcdiff saa7134.h drivers/media/video/saa7134/saa7134.h
srcdiff saa7134-reg.h drivers/media/video/saa7134/saa7134-reg.h
@@ -12,12 +69,49 @@ srcdiff saa7134-ts.c drivers/media/video/saa7134/saa7134-ts.c
srcdiff saa7134-input.c drivers/media/video/saa7134/saa7134-input.c
srcdiff saa7134-empress.c drivers/media/video/saa7134/saa7134-empress.c
-srcdiff saa7134-dvb.c drivers/media/video/saa7134/saa7134-dvb.c
-srcdiff saa6752hs.h include/media/saa6752hs.h
-srcdiff saa6752hs.c drivers/media/video/saa7134/saa6752hs.c
+# Already at dvb-saa7134
+# srcdiff saa7134-dvb.c drivers/media/video/saa7134/saa7134-dvb.c
+# srcdiff saa6752hs.h include/media/saa6752hs.h
+# srcdiff saa6752hs.c drivers/media/video/saa7134/saa6752hs.c
srcdiff tveeprom.h include/media/tveeprom.h
srcdiff tveeprom.c drivers/media/video/tveeprom.c
srcdiff videodev.h include/linux/videodev.h
srcdiff videodev2.h include/linux/videodev2.h
+#srcdiff videodev.c drivers/media/video/videodev.c
+srcdiff v4l1-compat.c drivers/media/video/v4l1-compat.c
+srcdiff v4l2-common.c drivers/media/video/v4l2-common.c
+# bttv
+srcdiff doc/README.bttv Documentation/video4linux/bttv/README
+srcdiff doc/insmod-options Documentation/video4linux/bttv/Insmod-options
+srcdiff doc/MAKEDEV Documentation/video4linux/bttv/MAKEDEV
+srcdiff doc/Sound-FAQ Documentation/video4linux/bttv/Sound-FAQ
+srcdiff doc/Tuners Documentation/video4linux/bttv/Tuners
+srcdiff doc/Cards Documentation/video4linux/bttv/Cards
+
+# other
+srcdiff /dev/null Documentation/video4linux/MAKEDEV
+srcdiff /dev/null Documentation/video4linux/bttv/CARDLIST
+srcdiff doc/README.cx88 Documentation/video4linux/README.cx88
+srcdiff doc/README.saa7134 Documentation/video4linux/README.saa7134
+srcdiff doc/README.ir Documentation/video4linux/README.ir
+srcdiff doc/not-in-cx2388x-datasheet.txt Documentation/video4linux/not-in-cx2388x-datasheet.txt
+
+# cardlists
+srcdiff doc/CARDLIST.bttv Documentation/video4linux/CARDLIST.bttv
+srcdiff doc/CARDLIST.saa7134 Documentation/video4linux/CARDLIST.saa7134
+srcdiff doc/CARDLIST.tuner Documentation/video4linux/CARDLIST.tuner
+srcdiff doc/CARDLIST.cx88 Documentation/video4linux/CARDLIST.cx88
+
+# API
+srcdiff doc/API.html Documentation/video4linux/API.html
+# obsolete / fixme
+#srcdiff doc/Specs Documentation/video4linux/bttv/Specs
+#srcdiff README.freeze Documentation/video4linux/bttv/README.freeze
+#srcdiff README.quirks Documentation/video4linux/bttv/README.quirks
+#srcdiff Modules.conf Documentation/video4linux/bttv/Modules.conf
+srcdiff video-buf.h include/media/video-buf.h
+srcdiff video-buf-dvb.h include/media/video-buf-dvb.h
+srcdiff video-buf.c drivers/media/video/video-buf.c
+srcdiff video-buf-dvb.c drivers/media/video/video-buf-dvb.c
diff --git a/v4l/ChangeLog b/v4l/ChangeLog
index 2c2347a35..ed8cd8a43 100644
--- a/v4l/ChangeLog
+++ b/v4l/ChangeLog
@@ -1,3 +1,31 @@
+2005-07-15 20:31 mchehab
+
+ * .bp/2.6/dvb-cx22702,.bp/2.6/dvb-mt352, .bp/2.6/dvb-or51132,
+ dvb-pll.c,dvb-pll.h,lgdt3302.c,lgdt3302.h,lgdt3302_priv.h,
+ mt352.c,mt352.h,mt352_priv.h,or51132.c,or51132.h,tda1004x.c,
+ tda1004x.h:
+ - DVB stuff. Removed from V4L tree. DVB support is only after
+ 2.6.11 (Make.config). Kernel does provide interfaces.
+
+ * .buildpatch:
+ - Includes all V4L stuff.
+
+ * compat.h:
+ - Fixed a small bug when compiling with newer linux/version.h.
+
+ * Makefile:
+ - Modified to work without DVB code.
+
+ * scripts/prepare-Changelog.pl:
+ - New script to help adding a new log file.
+ - To use, it is needed some env vars like these:
+ export CHANGE_LOG_NAME="My Full Name"
+ export CHANGE_LOG_EMAIL_ADDRESS="my_addr@my_provider.com"
+ export CHANGE_LOG_LOGIN="my_login"
+ You can include it at .bashrc, .profile or .bash_profile
+
+ Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
+
2005-07-15 20:08 mchehab
* bttv-driver.c, msp3400.c, tda9887.c, tuner-core.c:
diff --git a/v4l/Makefile b/v4l/Makefile
index d4ee58c1e..1860c169a 100644
--- a/v4l/Makefile
+++ b/v4l/Makefile
@@ -39,8 +39,8 @@ obj-$(CONFIG_VIDEO_IR) += ir-common.o
obj-$(CONFIG_VIDEO_TUNER) += tuner.o tda9887.o
obj-$(CONFIG_VIDEO_TVAUDIO) += msp3400.o tvaudio.o tvmixer.o
-obj-$(CONFIG_VIDEO_CX88_DVB) += video-buf-dvb.o cx88-dvb.o cx22702.o dvb-pll.o or51132.o lgdt3302.o mt352.o
-obj-$(CONFIG_VIDEO_SAA7134_DVB) += video-buf-dvb.o saa7134-dvb.o mt352.o tda1004x.o
+obj-$(CONFIG_VIDEO_CX88_DVB) += video-buf-dvb.o cx88-dvb.o
+obj-$(CONFIG_VIDEO_SAA7134_DVB) += video-buf-dvb.o saa7134-dvb.o
# 2.6-only stuff
ifeq ($(VERSION).$(PATCHLEVEL),2.6)
@@ -123,14 +123,13 @@ ifeq ($(inst-m),)
endif
inst_common := ir-common.ko
-inst_frontends := cx22702.ko dvb-pll.ko mt352.ko lgdt3302.ko or51132.ko tda1004x.ko
inst_video := btcx-risc.ko bttv.ko tda9887.ko tuner.ko tvaudio.ko tveeprom.ko
inst_video += tvmixer.ko v4l1-compat.ko v4l2-common.ko
inst_video += video-buf.ko video-buf-dvb.ko
inst_video += ir-kbd-gpio.ko ir-kbd-i2c.ko msp3400.ko
-inst_cx88 := cx8800.ko cx8801.ko cx88-dvb.ko cx8802.ko
-inst_cx88 += cx88-blackbird.ko cx88xx.ko
-inst_saa7134 := saa6752hs.ko saa7134.ko saa7134-dvb.ko saa7134-empress.ko
+inst_cx88 := cx8800.ko cx8801.ko cx8802.ko
+inst_cx88 += cx88-blackbird.ko cx88xx.ko cx88-dvb.ko
+inst_saa7134 := saa6752hs.ko saa7134.ko saa7134-empress.ko saa7134-dvb.ko
v4l_modules := $(shell lsmod|cut -d' ' -f1 ) $(patsubst %.ko,%,$(inst-m))
@@ -150,9 +149,6 @@ install:: rminstall
-install -d $(KDIR26)/common
-install -m 644 -c $(inst_common) $(KDIR26)/common
- -install -d $(KDIR26)/dvb/frontends
- -install -m 644 -c $(inst_frontends) $(KDIR26)/dvb/frontends
-
-install -d $(KDIR26)/video
-install -m 644 -c $(inst_video) $(KDIR26)/video
diff --git a/v4l/compat.h b/v4l/compat.h
index 5b80bb6ad..81eb75f7a 100644
--- a/v4l/compat.h
+++ b/v4l/compat.h
@@ -1,12 +1,14 @@
/*
- * $Id: compat.h,v 1.13 2005/07/13 17:25:25 mchehab Exp $
+ * $Id: compat.h,v 1.14 2005/07/15 20:37:50 mchehab Exp $
*/
#ifndef _COMPAT_H
#define _COMPAT_H
#include <linux/i2c-id.h>
+#include <linux/pm.h>
#include <linux/version.h>
+#include <linux/utsname.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
# define minor(x) MINOR(x)
@@ -101,6 +103,10 @@ static inline unsigned long msleep_interruptible(unsigned int msecs)
}
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
+#define pm_message_t u32
+#endif
+
#endif
/*
* Local variables:
diff --git a/v4l/lgdt3302.c b/v4l/lgdt3302.c
deleted file mode 100644
index c04ea4c12..000000000
--- a/v4l/lgdt3302.c
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * $Id: lgdt3302.c,v 1.18 2005/07/14 01:34:46 mkrufky Exp $
- *
- * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - VSB/QAM
- *
- * Copyright (C) 2005 Wilson Michaels <wilsonmichaels@earthlink.net>
- *
- * Based on code from Kirk Lapray <kirk_lapray@bigfoot.com>
- * Copyright (C) 2005
- *
- * 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 driver supports DViCO FusionHDTV 3 Gold under Linux.
- *
- * TODO:
- * BER and signal strength always return 0.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <asm/byteorder.h>
-
-#include "dvb_frontend.h"
-#include "dvb-pll.h"
-#include "lgdt3302_priv.h"
-#include "lgdt3302.h"
-
-static int debug = 0;
-module_param(debug, int, 0644);
-MODULE_PARM_DESC(debug,"Turn on/off lgdt3302 frontend debugging (default:off).");
-#define dprintk(args...) \
-do { \
-if (debug) printk(KERN_DEBUG "lgdt3302: " args); \
-} while (0)
-
-struct lgdt3302_state
-{
- struct i2c_adapter* i2c;
- struct dvb_frontend_ops ops;
-
- /* Configuration settings */
- const struct lgdt3302_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 lgdt3302_state* state,
- u8 addr, /* demod_address or pll_address */
- u8 *buf, /* data bytes to send */
- int len /* number of bytes to send */ )
-{
- if (addr == state->config->pll_address) {
- struct i2c_msg msg =
- { .addr = addr, .flags = 0, .buf = buf, .len = len };
- int err;
-
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
- if (err < 0)
- return err;
- else
- return -EREMOTEIO;
- }
- } else {
- u8 tmp[] = { buf[0], buf[1] };
- struct i2c_msg msg =
- { .addr = addr, .flags = 0, .buf = tmp, .len = 2 };
- int err;
- int i;
-
- for (i=1; i<len; i++) {
- tmp[1] = buf[i];
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "lgdt3302: %s error (addr %02x <- %02x, err == %i)\n", __FUNCTION__, addr, buf[0], err);
- if (err < 0)
- return err;
- else
- return -EREMOTEIO;
- }
- tmp[0]++;
- }
- }
- return 0;
-}
-static int i2c_readbytes (struct lgdt3302_state* state,
- u8 addr, /* demod_address or pll_address */
- u8 *buf, /* holds data bytes read */
- int len /* number of bytes to read */ )
-{
- struct i2c_msg msg =
- { .addr = addr, .flags = I2C_M_RD, .buf = buf, .len = len };
- int err;
-
- if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
- printk(KERN_WARNING "lgdt3302: %s error (addr %02x, err == %i)\n", __FUNCTION__, addr, err);
- return -EREMOTEIO;
- }
- return 0;
-}
-
-/*
- * This routine writes the register (reg) to the demod bus
- * then reads the data returned for (len) bytes.
- */
-
-static u8 i2c_selectreadbytes (struct lgdt3302_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 "lgdt3302: %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 */
-int lgdt3302_SwReset(struct lgdt3302_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_writebytes(state,
- state->config->demod_address,
- reset, sizeof(reset));
- if (ret == 0) {
- /* spec says reset takes 100 ns why wait */
- /* mdelay(100); */ /* keep low for 100mS */
- reset[1] = 0x7f; /* force reset high (inactive)
- * and unmask interrupts */
- ret = i2c_writebytes(state,
- state->config->demod_address,
- reset, sizeof(reset));
- }
- /* Spec does not indicate a need for this either */
- /*mdelay(5); */ /* wait 5 msec before doing more */
- return ret;
-}
-
-static int lgdt3302_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. */
-
- dprintk("%s entered\n", __FUNCTION__);
- return lgdt3302_SwReset((struct lgdt3302_state*) fe->demodulator_priv);
-}
-
-static int lgdt3302_read_ber(struct dvb_frontend* fe, u32* ber)
-{
- *ber = 0; /* Dummy out for now */
- return 0;
-}
-
-static int lgdt3302_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
-{
- struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
- u8 buf[2];
-
- i2c_selectreadbytes(state, PACKET_ERR_COUNTER1, buf, sizeof(buf));
-
- *ucblocks = (buf[0] << 8) | buf[1];
- return 0;
-}
-
-static int lgdt3302_set_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- u8 buf[4];
- struct lgdt3302_state* state =
- (struct lgdt3302_state*) fe->demodulator_priv;
-
- /* Use 50MHz parameter values from spec sheet since xtal is 50 */
- static u8 top_ctrl_cfg[] = { TOP_CONTROL, 0x03 };
- static u8 vsb_freq_cfg[] = { VSB_CARRIER_FREQ0, 0x00, 0x87, 0x8e, 0x01 };
- static u8 demux_ctrl_cfg[] = { DEMUX_CONTROL, 0xfb };
- static u8 agc_rf_cfg[] = { AGC_RF_BANDWIDTH0, 0x40, 0x93, 0x00 };
- static u8 agc_ctrl_cfg[] = { AGC_FUNC_CTRL2, 0xc6, 0x40 };
- static u8 agc_delay_cfg[] = { AGC_DELAY0, 0x07, 0x00, 0xfe };
- static u8 agc_loop_cfg[] = { AGC_LOOP_BANDWIDTH0, 0x08, 0x9a };
-
- /* 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 and serial MPEG interface */
- top_ctrl_cfg[1] = 0x07;
- break;
-
- case QAM_64:
- dprintk("%s: QAM_64 MODE\n", __FUNCTION__);
-
- /* Select QAM_64 mode and serial MPEG interface */
- top_ctrl_cfg[1] = 0x04;
- break;
-
- case QAM_256:
- dprintk("%s: QAM_256 MODE\n", __FUNCTION__);
-
- /* Select QAM_256 mode and serial MPEG interface */
- top_ctrl_cfg[1] = 0x05;
- break;
- default:
- printk(KERN_WARNING "lgdt3302: %s: Modulation type(%d) UNSUPPORTED\n", __FUNCTION__, param->u.vsb.modulation);
- return -1;
- }
- /* Initializations common to all modes */
-
- /* Select the requested mode */
- i2c_writebytes(state, state->config->demod_address,
- top_ctrl_cfg, sizeof(top_ctrl_cfg));
-
- /* Change the value of IFBW[11:0]
- of AGC IF/RF loop filter bandwidth register */
- i2c_writebytes(state, state->config->demod_address,
- agc_rf_cfg, sizeof(agc_rf_cfg));
-
- /* Change the value of bit 6, 'nINAGCBY' and
- 'NSSEL[1:0] of ACG function control register 2 */
- /* Change the value of bit 6 'RFFIX'
- of AGC function control register 3 */
- i2c_writebytes(state, state->config->demod_address,
- agc_ctrl_cfg, sizeof(agc_ctrl_cfg));
-
- /* Change the TPCLK pin polarity
- data is valid on falling clock */
- i2c_writebytes(state, state->config->demod_address,
- demux_ctrl_cfg, sizeof(demux_ctrl_cfg));
-
- /* Change the value of NCOCTFV[25:0] of carrier
- recovery center frequency register */
- i2c_writebytes(state, state->config->demod_address,
- vsb_freq_cfg, sizeof(vsb_freq_cfg));
-
- /* Set the value of 'INLVTHD' register 0x2a/0x2c to 0x7fe */
- i2c_writebytes(state, state->config->demod_address,
- agc_delay_cfg, sizeof(agc_delay_cfg));
-
- /* Change the value of IAGCBW[15:8]
- of inner AGC loop filter bandwith */
- i2c_writebytes(state, state->config->demod_address,
- agc_loop_cfg, sizeof(agc_loop_cfg));
-
- state->config->set_ts_params(fe, 0);
- state->current_modulation = param->u.vsb.modulation;
- }
-
- /* Change only if we are actually changing the channel */
- if (state->current_frequency != param->frequency) {
- dvb_pll_configure(state->config->pll_desc, buf,
- param->frequency, 0);
- dprintk("%s: tuner bytes: 0x%02x 0x%02x "
- "0x%02x 0x%02x\n", __FUNCTION__, buf[0],buf[1],buf[2],buf[3]);
- i2c_writebytes(state, state->config->pll_address ,buf, 4);
-
- /* Check the status of the tuner pll */
- i2c_readbytes(state, state->config->pll_address, buf, 1);
- dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]);
-
- /* Update current frequency */
- state->current_frequency = param->frequency;
- }
- lgdt3302_SwReset(state);
- return 0;
-}
-
-static int lgdt3302_get_frontend(struct dvb_frontend* fe,
- struct dvb_frontend_parameters* param)
-{
- struct lgdt3302_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 lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
- u8 buf[3];
-
- *status = 0; /* Reset status result */
-
- /* Check the status of the tuner pll */
- i2c_readbytes(state, state->config->pll_address, buf, 1);
- dprintk("%s: tuner status byte = 0x%02x\n", __FUNCTION__, buf[0]);
- if ((buf[0] & 0xc0) != 0x40)
- return 0; /* Tuner PLL not locked or not powered on */
-
- /*
- * 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();
- */
-
- /* AGC status register */
- i2c_selectreadbytes(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;
- }
-
- /* signal status */
- i2c_selectreadbytes(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]);
-
-#if 0
- /* Alternative method to check for a signal */
- /* using the SNR good/bad interrupts. */
- if ((buf[2] & 0x30) == 0x10)
- *status |= FE_HAS_SIGNAL;
-#endif
-
- /* 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_selectreadbytes(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 lgdt3302: %s: Modulation set to unsupported value\n", __FUNCTION__);
- }
-
- return 0;
-}
-
-static int lgdt3302_read_signal_strength(struct dvb_frontend* fe, u16* strength)
-{
- /* not directly available. */
- 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, 0x040000
- };
-
- static u8 buf[5];/* read data buffer */
- static u32 noise; /* noise value */
- static u32 snr_db; /* index into SNR_EQ[] */
- struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
-
- /* read both equalizer and pase tracker noise data */
- i2c_selectreadbytes(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 lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
-
- /* read both equalizer and pase tracker noise data */
- i2c_selectreadbytes(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];
- } else {
- /* Phase Tracker Mean-Square Error Register for QAM */
- noise = ((buf[0] & 7<<3) << 13) | (buf[3] << 8) | buf[4];
- }
-
- /* Small values for noise mean signal is better so invert noise */
- /* Noise is 19 bit value so discard 3 LSB*/
- *snr = ~noise>>3;
-#endif
-
- dprintk("%s: noise = 0x%05x, snr = %idb\n",__FUNCTION__, noise, *snr);
-
- return 0;
-}
-
-static int lgdt3302_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 lgdt3302_release(struct dvb_frontend* fe)
-{
- struct lgdt3302_state* state = (struct lgdt3302_state*) fe->demodulator_priv;
- kfree(state);
-}
-
-static struct dvb_frontend_ops lgdt3302_ops;
-
-struct dvb_frontend* lgdt3302_attach(const struct lgdt3302_config* config,
- struct i2c_adapter* i2c)
-{
- struct lgdt3302_state* state = NULL;
- u8 buf[1];
-
- /* Allocate memory for the internal state */
- state = (struct lgdt3302_state*) kmalloc(sizeof(struct lgdt3302_state), GFP_KERNEL);
- if (state == NULL)
- goto error;
- memset(state,0,sizeof(*state));
-
- /* Setup the state */
- state->config = config;
- state->i2c = i2c;
- memcpy(&state->ops, &lgdt3302_ops, sizeof(struct dvb_frontend_ops));
- /* Verify communication with demod chip */
- if (i2c_selectreadbytes(state, 2, buf, 1))
- goto error;
-
- state->current_frequency = -1;
- state->current_modulation = -1;
-
- /* Create dvb_frontend */
- state->frontend.ops = &state->ops;
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- if (state)
- 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 is for all VSB modes need to check QAM */
- .symbol_rate_min = 10762000,
- .symbol_rate_max = 10762000,
- .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB
- },
- .init = lgdt3302_init,
- .set_frontend = lgdt3302_set_parameters,
- .get_frontend = lgdt3302_get_frontend,
- .get_tune_settings = lgdt3302_get_tune_settings,
- .read_status = lgdt3302_read_status,
- .read_ber = lgdt3302_read_ber,
- .read_signal_strength = lgdt3302_read_signal_strength,
- .read_snr = lgdt3302_read_snr,
- .read_ucblocks = lgdt3302_read_ucblocks,
- .release = lgdt3302_release,
-};
-
-MODULE_DESCRIPTION("LGDT3302 [DViCO FusionHDTV 3 Gold] (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
-MODULE_AUTHOR("Wilson Michaels");
-MODULE_LICENSE("GPL");
-
-EXPORT_SYMBOL(lgdt3302_attach);
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * compile-command: "make DVB=1"
- * End:
- */
diff --git a/v4l/lgdt3302.h b/v4l/lgdt3302.h
deleted file mode 100644
index 3b7e2cf47..000000000
--- a/v4l/lgdt3302.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * $Id: lgdt3302.h,v 1.4 2005/06/28 12:34:14 mkrufky Exp $
- *
- * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - 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 LGDT3302_H
-#define LGDT3302_H
-
-#include <linux/dvb/frontend.h>
-
-struct lgdt3302_config
-{
- /* The demodulator's i2c address */
- u8 demod_address;
- u8 pll_address;
- struct dvb_pll_desc *pll_desc;
-
- /* Need to set device param for start_dma */
- int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured);
-};
-
-extern struct dvb_frontend* lgdt3302_attach(const struct lgdt3302_config* config,
- struct i2c_adapter* i2c);
-
-#endif /* LGDT3302_H */
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/v4l/lgdt3302_priv.h b/v4l/lgdt3302_priv.h
deleted file mode 100644
index cfbf23462..000000000
--- a/v4l/lgdt3302_priv.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * $Id: lgdt3302_priv.h,v 1.4 2005/06/28 23:41:47 mkrufky Exp $
- *
- * Support for LGDT3302 (DViCO FustionHDTV 3 Gold) - 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 _LGDT3302_PRIV_
-#define _LGDT3302_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,
- PACKET_ERR_COUNTER1= 0x6a,
- PACKET_ERR_COUNTER2= 0x6b,
-};
-
-#endif /* _LGDT3302_PRIV_ */
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/v4l/mt352.c b/v4l/mt352.c
deleted file mode 100644
index 46d9587a3..000000000
--- a/v4l/mt352.c
+++ /dev/null
@@ -1,633 +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 "dvb_frontend.h"
-#include "mt352_priv.h"
-#include "mt352.h"
-
-struct mt352_state {
- struct i2c_adapter* i2c;
- struct dvb_frontend_ops ops;
-
- /* configuration settings */
- const struct mt352_config* config;
- int s0,s1,s3;
-
- struct dvb_frontend frontend;
-};
-
-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 = (struct mt352_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];
-}
-
-int mt352_read(struct dvb_frontend *fe, u8 reg)
-{
- return mt352_read_register(fe->demodulator_priv,reg);
-}
-
-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 = (struct mt352_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);
- state->config->pll_set(fe, param, buf+8);
-
-#if 0 /* FIXME: should be catched elsewhere ... */
- /* Only send the tuning request if the tuner doesn't have the requested
- * parameters already set. Enhances tuning time and prevents stream
- * breakup when retuning the same transponder. */
- for (i = 1; i < 13; i++)
- if (buf[i] != mt352_read_register(state, i + 0x50))
- break;
- if (13 == i)
- /* no changes */
- return 0;
-#endif
-
- mt352_write(fe, buf, sizeof(buf));
- if (state->config->no_tuner) {
- /* start decoding */
- mt352_write(fe, fsm_go, 2);
- } else {
- /* start tuning */
- 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 = (struct mt352_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 = (struct mt352_state*) fe->demodulator_priv;
-#if 1
- int val;
-
- if (0 != mt352_read_register(state, INTERRUPT_0)) {
- val = mt352_read_register(state, STATUS_0);
- if (-1 != val)
- state->s0 = val;
- val = mt352_read_register(state, STATUS_1);
- if (-1 != val)
- state->s1 = val;
- val = mt352_read_register(state, STATUS_3);
- if (-1 != val)
- state->s3 = val;
- }
-#else
- state->s0 = mt352_read_register(state, STATUS_0);
- state->s1 = mt352_read_register(state, STATUS_1);
- state->s3 = mt352_read_register(state, STATUS_3);
- if (-1 == state->s0 || -1 == state->s1 || -1 == state->s3)
- return -EIO;
-#endif
-
- *status = 0;
- if (state->s0 & (1 << 4))
- *status |= FE_HAS_CARRIER;
- if (state->s0 & (1 << 1))
- *status |= FE_HAS_VITERBI;
- if (state->s0 & (1 << 5))
- *status |= FE_HAS_LOCK;
- if (state->s1 & (1 << 1))
- *status |= FE_HAS_SYNC;
- if (state->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 = (struct mt352_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 = (struct mt352_state*) fe->demodulator_priv;
-
- u16 signal = (mt352_read_register (state, AGC_GAIN_3) << 8) |
- (mt352_read_register (state, AGC_GAIN_2));
-
- *strength = ~signal;
- return 0;
-}
-
-static int mt352_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct mt352_state* state = (struct mt352_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 = (struct mt352_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 = (struct mt352_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 = (struct mt352_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 = (struct mt352_state*) kmalloc(sizeof(struct mt352_state), GFP_KERNEL);
- if (state == NULL) goto error;
- memset(state,0,sizeof(*state));
-
- /* setup the state */
- state->config = config;
- state->i2c = i2c;
- memcpy(&state->ops, &mt352_ops, sizeof(struct dvb_frontend_ops));
-
- /* check if the demod is there */
- if (mt352_read_register(state, CHIP_ID) != ID_MT352) goto error;
-
- /* create dvb_frontend */
- state->frontend.ops = &state->ops;
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- if (state) 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);
-EXPORT_SYMBOL(mt352_read);
-/*
- * Local variables:
- * c-basic-offset: 8
- * compile-command: "make DVB=1"
- * End:
- */
diff --git a/v4l/mt352.h b/v4l/mt352.h
deleted file mode 100644
index f5d8a5aed..000000000
--- a/v4l/mt352.h
+++ /dev/null
@@ -1,72 +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);
-
- /* PLL setup - fill out the supplied 5 byte buffer with your PLL settings.
- * byte0: Set to pll i2c address (nonlinux; left shifted by 1)
- * byte1-4: PLL configuration.
- */
- int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf);
-};
-
-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);
-extern int mt352_read(struct dvb_frontend *fe, u8 reg);
-
-#endif // MT352_H
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */
diff --git a/v4l/mt352_priv.h b/v4l/mt352_priv.h
deleted file mode 100644
index 44ad0d4c8..000000000
--- a/v4l/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/v4l/or51132.c b/v4l/or51132.c
deleted file mode 100644
index 794608f16..000000000
--- a/v4l/or51132.c
+++ /dev/null
@@ -1,637 +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/version.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/init.h>
-#include <linux/delay.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;
- struct dvb_frontend_ops ops;
-
- /* 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 = (struct or51132_state*) fe->demodulator_priv;
- static u8 run_buf[] = {0x7F,0x01};
- static u8 get_ver_buf[] = {0x04,0x00,0x30,0x00,0x00};
- u8 rec_buf[14];
- u8 cmd_buf[14];
- 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;
- cmd_buf[3] = 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;
- cmd_buf[2] = 0x00;
- cmd_buf[3] = 0x00;
- 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;
- cmd_buf[2] = 0x00;
- cmd_buf[3] = 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 */
- get_ver_buf[4] = i+1;
- 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;
- cmd_buf[3] = 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 = (struct or51132_state*) fe->demodulator_priv;
- unsigned char cmd_buf[4];
-
- 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;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
- case VSB_8:
- /* Auto CH, Auto NTSC rej, MPEGser, MPEG2tr, phase noise-high*/
- cmd_buf[2] = 0x50;
- break;
-#endif
- default:
- printk("setmode:Modulation set to unsupported value\n");
- };
- cmd_buf[3] = 0x00;
- 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;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
- case VSB_8:
- /* REC MODE inv IF spectrum, Normal */
- cmd_buf[1] = 0x03;
- /* Channel MODE ATSC/VSB8 */
- cmd_buf[2] = 0x06;
- break;
-#endif
- default:
- printk("setmode: Modulation set to unsupported value\n");
- };
- cmd_buf[3] = 0x00;
- 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;
-}
-
-static int or51132_set_parameters(struct dvb_frontend* fe,
- struct dvb_frontend_parameters *param)
-{
- int ret;
- u8 buf[4];
- struct or51132_state* state = (struct or51132_state*) fe->demodulator_priv;
- const struct firmware *fw;
-
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10)
- /* 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("set_parameters VSB MODE\n");
- printk("or51132: Waiting for firmware upload(%s)...\n",
- OR51132_VSB_FIRMWARE);
- ret = request_firmware(&fw, OR51132_VSB_FIRMWARE,
- &state->i2c->dev);
- if (ret){
- printk(KERN_WARNING "or51132: No firmware up"
- "loaded(timeout or file not found?)\n");
- return ret;
- }
- /* Set non-punctured clock for VSB */
- state->config->set_ts_params(fe, 0);
- break;
- case QAM_AUTO:
- case QAM_64:
- case QAM_256:
- dprintk("set_parameters QAM MODE\n");
- printk("or51132: Waiting for firmware upload(%s)...\n",
- OR51132_QAM_FIRMWARE);
- ret = request_firmware(&fw, OR51132_QAM_FIRMWARE,
- &state->i2c->dev);
- if (ret){
- printk(KERN_WARNING "or51132: No firmware up"
- "loaded(timeout or file not found?)\n");
- return ret;
- }
- /* Set punctured clock for QAM */
- state->config->set_ts_params(fe, 1);
- break;
- default:
- printk("or51132:Modulation type(%d) UNSUPPORTED\n",
- param->u.vsb.modulation);
- return -1;
- };
- 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->current_modulation = param->u.vsb.modulation;
- or51132_setmode(fe);
- }
-#else
- printk("%s: you need a newer kernel for this, sorry\n",__FUNCTION__);
-#endif
-
- /* Change only if we are actually changing the channel */
- if (state->current_frequency != param->frequency) {
- dvb_pll_configure(state->config->pll_desc, buf,
- param->frequency, 0);
- 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, state->config->pll_address ,buf, 4))
- printk(KERN_WARNING "or51132: set_parameters error "
- "writing to tuner\n");
-
- /* Set to current mode */
- or51132_setmode(fe);
-
- /* Update current frequency */
- state->current_frequency = param->frequency;
- }
- return 0;
-}
-
-static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status)
-{
- struct or51132_state* state = (struct or51132_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 */
-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};
-
-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 = (struct or51132_state*) fe->demodulator_priv;
- unsigned char rec_buf[2];
- unsigned char snd_buf[2];
- u8 rcvr_stat;
- u16 snr_equ;
- 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% */
- *strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000;
- dprintk("read_signal_strength %i\n",*strength);
-
- return 0;
-}
-
-static int or51132_read_snr(struct dvb_frontend* fe, u16* snr)
-{
- struct or51132_state* state = (struct or51132_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 = (struct or51132_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;
- memcpy(&state->ops, &or51132_ops, sizeof(struct dvb_frontend_ops));
- state->current_frequency = -1;
- state->current_modulation = -1;
-
- /* Create dvb_frontend */
- state->frontend.ops = &state->ops;
- state->frontend.demodulator_priv = state;
- return &state->frontend;
-
-error:
- if (state)
- 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_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/v4l/or51132.h b/v4l/or51132.h
deleted file mode 100644
index 9450bd568..000000000
--- a/v4l/or51132.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * $Id: or51132.h,v 1.5 2005/06/12 04:19:19 mchehab Exp $
- *
- * 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;
- u8 pll_address;
- struct dvb_pll_desc *pll_desc;
-
- /* 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/v4l/scripts/prepare-ChangeLog.pl b/v4l/scripts/prepare-ChangeLog.pl
new file mode 100644
index 000000000..1e5d2e743
--- /dev/null
+++ b/v4l/scripts/prepare-ChangeLog.pl
@@ -0,0 +1,588 @@
+#!/usr/bin/perl -w
+# -*- Mode: perl; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+# Perl script to create a ChangeLog entry with names of files
+# and functions from a cvs diff.
+#
+# Darin Adler <darin@eazel.com>, started 20 April 2000
+# Java support added by Maciej Stachowiak <mjs@eazel.com>
+# last updated 28 December 2000
+#
+# Mauro Carvalho Chehab <mchehab@brturbo.com.br>: modified to
+# allow signed-off-by tags, GMT Time and V4L format.
+# CHANVE_LOG Env variables now are mandatory.
+# Updated at 15 January 2005
+#
+# (Someone put a license in here, like maybe GPL.)
+#
+# TODO:
+# Provide option to put new ChangeLog into a separate file
+# instead of editing the ChangeLog.
+# For new files, just say "New file" instead of listing
+# function names.
+# List functions that have been removed too.
+# Decide what a good logical order is for the changed files
+# other than a normal text "sort" (top level first?)
+# (group directories?) (.h before .c?)
+# Leave a diff file behind if asked, but in unified format.
+# Handle C++ and yacc source files too (other languages?).
+# Help merge when there are ChangeLog conflicts or if there's
+# already a partly written ChangeLog entry.
+# Find appropriate ChangeLog to edit for each changed file
+# instead of always using ChangeLog in current directory.
+# Add command line option to put the ChangeLog into a separate
+# file or just spew it out stdout.
+# Figure out how to allow -z options from .cvsrc to work without
+# letting other bad options work. Currently the -f disables
+# everything from the .cvsrc.
+# Add CVS version numbers for each file too (can't do that until
+# the changes are checked in, though).
+# Work around diff stupidity where deleting a function that starts
+# with a comment makes diff think that the following function
+# has been changed (if the following function starts with a comment
+# with the same first line, such as /**)
+# Work around diff stupidity where deleting an entire function and
+# the blank lines before it makes diff think you've changed the
+# previous function.
+
+use diagnostics;
+use strict;
+
+use English;
+use Text::Wrap;
+
+# Get environment variables required.
+my $name = $ENV{CHANGE_LOG_NAME};
+my $email_address = $ENV{CHANGE_LOG_EMAIL_ADDRESS};
+my $login = $ENV{CHANGE_LOG_LOGIN};
+
+if (!defined $name)
+ {
+ print STDERR "Please, define env var CHANGE_LOG_NAME.\n";
+ exit;
+ }
+if (!defined $email_address)
+ {
+ print STDERR "Please, define env var CHANGE_LOG_EMAIL_ADDRESS.\n";
+ exit;
+ }
+if (!defined $login)
+ {
+ print STDERR "Please, define env var CHANGE_LOG_LOGIN.\n";
+ exit;
+ }
+
+
+
+# Read the old change log file.
+# It's less efficient to read the whole thing into memory than it would be
+# to read it while we prepend to it later, but I like doing this part first.
+print STDERR " Updating ChangeLog from cvs repository.\n";
+open ERRORS, "cvs update ChangeLog |" or die "The cvs update of ChangeLog failed: $OS_ERROR.\n";
+print STDERR " $ARG" while <ERRORS>;
+close ERRORS;
+open OLD_CHANGE_LOG, "ChangeLog" or die "Could not open ChangeLog file: $OS_ERROR.\n";
+my @old_change_log = <OLD_CHANGE_LOG>;
+close OLD_CHANGE_LOG;
+
+# For each file, build a list of modified lines.
+# Use line numbers from the "after" side of each diff.
+print STDERR " Running cvs diff to find changes.\n";
+my %changed_line_ranges;
+my $file;
+open DIFF, "cvs -fq diff -N |" or die "The cvs diff failed: $OS_ERROR.\n";
+while (<DIFF>)
+ {
+ $file = $1 if /^Index: (\S+)$/;
+ if (defined $file
+ and $file ne "ChangeLog"
+ and (/^\d+(,\d+)?[acd](\d+)(,(\d+))?/ or /^Binary files/) )
+ {
+ push @{$changed_line_ranges{$file}}, [ $2, $4 || $2 ];
+ }
+ }
+close DIFF;
+if (!%changed_line_ranges)
+ {
+ print STDERR " No changes found.\n";
+ exit;
+ }
+
+# For each ".c" file, convert line range to function list.
+print STDERR " Extracting affected function names from C source files.\n";
+my %function_lists;
+foreach my $file (keys %changed_line_ranges)
+ {
+ # An empty function list still indicates that something changed.
+ $function_lists{$file} = "";
+
+ # Only look for function names in .c files.
+ next unless $file =~ /\.(c|java)/;
+
+ # Find all the functions in the file.
+ open SOURCE, $file or next;
+ my @function_ranges = get_function_line_ranges(\*SOURCE, $file);
+ close SOURCE;
+
+ # Find all the modified functions.
+ my @functions;
+ my %saw_function;
+ my @change_ranges = (@{$changed_line_ranges{$file}}, []);
+ my @change_range = (0, 0);
+ FUNCTION: foreach my $function_range_ref (@function_ranges)
+ {
+ my @function_range = @$function_range_ref;
+
+ # Advance to successive change ranges.
+ for (;; @change_range = @{shift @change_ranges})
+ {
+ last FUNCTION unless @change_range;
+
+ # If past this function, move on to the next one.
+ next FUNCTION if $change_range[0] > $function_range[1];
+
+ # If an overlap with this function range, record the function name.
+ if ($change_range[1] >= $function_range[0]
+ and $change_range[0] <= $function_range[1])
+ {
+ if (!$saw_function{$function_range[2]})
+ {
+ $saw_function{$function_range[2]} = 1;
+ push @functions, $function_range[2];
+ }
+ next FUNCTION;
+ }
+ }
+ }
+
+ # Format the list of functions now.
+ $function_lists{$file} = " (" . join("), (", @functions) . "):" if @functions;
+ }
+
+# Write out a new ChangeLog file.
+print STDERR " Editing the ChangeLog file.\n";
+my $date = sprintf "%d-%02d-%02d %02d:%02d",
+ 1900 + (gmtime $BASETIME)[5], # year
+ 1 + (gmtime $BASETIME)[4], # month
+ (gmtime $BASETIME)[3], # day within month
+ (gmtime $BASETIME)[2], # hour
+ (gmtime $BASETIME)[1]; # min
+
+open CHANGE_LOG, "> ChangeLog" or die "Could not write ChangeLog\n.";
+print CHANGE_LOG "$date $login\n\n";
+foreach my $file (sort keys %function_lists)
+ {
+ my $lines = wrap("\t", "\t", "XX$file:$function_lists{$file}");
+ $lines =~ s/^\tXX/\t* /;
+ print CHANGE_LOG "$lines\n";
+ }
+print CHANGE_LOG "\n\tSigned-off-by: $name <$email_address>\n";
+print CHANGE_LOG "\n", @old_change_log;
+close CHANGE_LOG;
+
+# Done.
+print STDERR " Done editing ChangeLog.\n";
+exit;
+
+
+
+sub get_function_line_ranges
+ {
+ my ($file_handle, $file_name) = @_;
+
+ if ($file_name =~ /\.c$/) {
+ return get_function_line_ranges_for_c ($file_handle, $file_name);
+ } elsif ($file_name =~ /\.java$/) {
+ return get_function_line_ranges_for_java ($file_handle, $file_name);
+ }
+ return ();
+ }
+
+# Read a file and get all the line ranges of the things that look like C functions.
+# A function name is the last word before an open parenthesis before the outer
+# level open brace. A function starts at the first character after the last close
+# brace or semicolon before the function name and ends at the close brace.
+# Comment handling is simple-minded but will work for all but pathological cases.
+#
+# Result is a list of triples: [ start_line, end_line, function_name ].
+
+sub get_function_line_ranges_for_c
+ {
+ my ($file_handle, $file_name) = @_;
+
+ my @ranges;
+
+ my $in_comment = 0;
+ my $in_macro = 0;
+ my $in_parentheses = 0;
+ my $in_braces = 0;
+
+ my $word = "";
+
+ my $potential_start = 0;
+ my $potential_name = "";
+
+ my $start = 0;
+ my $name = "";
+
+ while (<$file_handle>)
+ {
+ # Handle continued multi-line comment.
+ if ($in_comment)
+ {
+ next unless s-.*\*/--;
+ $in_comment = 0;
+ }
+
+ # Handle continued macro.
+ if ($in_macro)
+ {
+ $in_macro = 0 unless /\\$/;
+ next;
+ }
+
+ # Handle start of macro (or any preprocessor directive).
+ if (/^\s*\#/)
+ {
+ $in_macro = 1 if /^([^\\]|\\.)*\\$/;
+ next;
+ }
+
+ # Handle comments and quoted text.
+ while (m-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy
+ {
+ my $match = $1;
+ if ($match eq "/*")
+ {
+ if (!s-/\*.*?\*/--)
+ {
+ s-/\*.*--;
+ $in_comment = 1;
+ }
+ }
+ elsif ($match eq "//")
+ {
+ s-//.*--;
+ }
+ else # ' or "
+ {
+ if (!s-$match([^\\]|\\.)*?$match--)
+ {
+ warn "mismatched quotes at line $INPUT_LINE_NUMBER in $file_name\n";
+ s-$match.*--;
+ }
+ }
+ }
+
+ # Find function names.
+ while (m-(\w+|[(){};])-g)
+ {
+ # Open parenthesis.
+ if ($1 eq "(")
+ {
+ $potential_name = $word unless $in_parentheses;
+ $in_parentheses++;
+ next;
+ }
+
+ # Close parenthesis.
+ if ($1 eq ")")
+ {
+ $in_parentheses--;
+ next;
+ }
+
+ # Open brace.
+ if ($1 eq "{")
+ {
+ # Promote potiential name to real function name at the
+ # start of the outer level set of braces (function body?).
+ if (!$in_braces and $potential_start)
+ {
+ $start = $potential_start;
+ $name = $potential_name;
+ }
+
+ $in_braces++;
+ next;
+ }
+
+ # Close brace.
+ if ($1 eq "}")
+ {
+ $in_braces--;
+
+ # End of an outer level set of braces.
+ # This could be a function body.
+ if (!$in_braces and $name)
+ {
+ push @ranges, [ $start, $INPUT_LINE_NUMBER, $name ];
+ $name = "";
+ }
+
+ $potential_start = 0;
+ $potential_name = "";
+ next;
+ }
+
+ # Semicolon.
+ if ($1 eq ";")
+ {
+ $potential_start = 0;
+ $potential_name = "";
+ next;
+ }
+
+ # Word.
+ $word = $1;
+ if (!$in_parentheses)
+ {
+ $potential_start = 0;
+ $potential_name = "";
+ }
+ if (!$potential_start)
+ {
+ $potential_start = $INPUT_LINE_NUMBER;
+ $potential_name = "";
+ }
+ }
+ }
+
+ warn "mismatched braces in $file_name\n" if $in_braces;
+ warn "mismatched parentheses in $file_name\n" if $in_parentheses;
+
+ return @ranges;
+ }
+
+
+
+# Read a file and get all the line ranges of the things that look like Java
+# classes, interfaces and methods.
+#
+# A class or interface name is the word that immediately follows
+# `class' or `interface' when followed by an open curly brace and not
+# a semicolon. It can appear at the top level, or inside another class
+# or interface block, but not inside a function block
+#
+# A class or interface starts at the first character after the first close
+# brace or after the function name and ends at the close brace.
+#
+# A function name is the last word before an open parenthesis before
+# an open brace rather than a semicolon. It can appear at top level or
+# inside a class or interface block, but not inside a function block.
+#
+# A function starts at the first character after the first close
+# brace or after the function name and ends at the close brace.
+#
+# Comment handling is simple-minded but will work for all but pathological cases.
+#
+# Result is a list of triples: [ start_line, end_line, function_name ].
+
+sub get_function_line_ranges_for_java
+ {
+ my ($file_handle, $file_name) = @_;
+
+ my @current_scopes;
+
+ my @ranges;
+
+ my $in_comment = 0;
+ my $in_macro = 0;
+ my $in_parentheses = 0;
+ my $in_braces = 0;
+ my $in_non_block_braces = 0;
+ my $class_or_interface_just_seen = 0;
+
+ my $word = "";
+
+ my $potential_start = 0;
+ my $potential_name = "";
+ my $potential_name_is_class_or_interface = 0;
+
+ my $start = 0;
+ my $name = "";
+ my $current_name_is_class_or_interface = 0;
+
+ while (<$file_handle>)
+ {
+ # Handle continued multi-line comment.
+ if ($in_comment)
+ {
+ next unless s-.*\*/--;
+ $in_comment = 0;
+ }
+
+ # Handle continued macro.
+ if ($in_macro)
+ {
+ $in_macro = 0 unless /\\$/;
+ next;
+ }
+
+ # Handle start of macro (or any preprocessor directive).
+ if (/^\s*\#/)
+ {
+ $in_macro = 1 if /^([^\\]|\\.)*\\$/;
+ next;
+ }
+
+ # Handle comments and quoted text.
+ while (m-(/\*|//|\'|\")-) # \' and \" keep emacs perl mode happy
+ {
+ my $match = $1;
+ if ($match eq "/*")
+ {
+ if (!s-/\*.*?\*/--)
+ {
+ s-/\*.*--;
+ $in_comment = 1;
+ }
+ }
+ elsif ($match eq "//")
+ {
+ s-//.*--;
+ }
+ else # ' or "
+ {
+ if (!s-$match([^\\]|\\.)*?$match--)
+ {
+ warn "mismatched quotes at line $INPUT_LINE_NUMBER in $file_name\n";
+ s-$match.*--;
+ }
+ }
+ }
+
+ # Find function names.
+ while (m-(\w+|[(){};])-g)
+ {
+ # Open parenthesis.
+ if ($1 eq "(")
+ {
+ if (!$in_parentheses) {
+ $potential_name = $word;
+ $potential_name_is_class_or_interface = 0;
+ }
+ $in_parentheses++;
+ next;
+ }
+
+ # Close parenthesis.
+ if ($1 eq ")")
+ {
+ $in_parentheses--;
+ next;
+ }
+
+ # Open brace.
+ if ($1 eq "{")
+ {
+ # Promote potiential name to real function name at the
+ # start of the outer level set of braces (function/class/interface body?).
+ if (!$in_non_block_braces
+ and (!$in_braces or $current_name_is_class_or_interface)
+ and $potential_start)
+ {
+ if ($name)
+ {
+ push @ranges, [ $start, ($INPUT_LINE_NUMBER - 1),
+ join ('.', @current_scopes) ];
+ }
+
+
+ $current_name_is_class_or_interface = $potential_name_is_class_or_interface;
+
+ $start = $potential_start;
+ $name = $potential_name;
+
+ push (@current_scopes, $name);
+ } else {
+ $in_non_block_braces++;
+ }
+
+ $potential_name = "";
+ $potential_start = 0;
+
+ $in_braces++;
+ next;
+ }
+
+ # Close brace.
+ if ($1 eq "}")
+ {
+ $in_braces--;
+
+ # End of an outer level set of braces.
+ # This could be a function body.
+ if (!$in_non_block_braces)
+ {
+ if ($name)
+ {
+ push @ranges, [ $start, $INPUT_LINE_NUMBER,
+ join ('.', @current_scopes) ];
+
+ pop (@current_scopes);
+
+ if (@current_scopes)
+ {
+ $current_name_is_class_or_interface = 1;
+
+ $start = $INPUT_LINE_NUMBER + 1;
+ $name = $current_scopes[$#current_scopes-1];
+ }
+ else
+ {
+ $current_name_is_class_or_interface = 0;
+ $start = 0;
+ $name = "";
+ }
+ }
+ }
+ else
+ {
+ $in_non_block_braces-- if $in_non_block_braces;
+ }
+
+ $potential_start = 0;
+ $potential_name = "";
+ next;
+ }
+
+ # Semicolon.
+ if ($1 eq ";")
+ {
+ $potential_start = 0;
+ $potential_name = "";
+ next;
+ }
+
+ if ($1 eq "class" or $1 eq "interface") {
+ $class_or_interface_just_seen = 1;
+ next;
+ }
+
+ # Word.
+ $word = $1;
+ if (!$in_parentheses)
+ {
+ if ($class_or_interface_just_seen) {
+ $potential_name = $word;
+ $potential_start = $INPUT_LINE_NUMBER;
+ $class_or_interface_just_seen = 0;
+ $potential_name_is_class_or_interface = 1;
+ next;
+ }
+ }
+ if (!$potential_start)
+ {
+ $potential_start = $INPUT_LINE_NUMBER;
+ $potential_name = "";
+ }
+ $class_or_interface_just_seen = 0;
+ }
+ }
+
+ warn "mismatched braces in $file_name\n" if $in_braces;
+ warn "mismatched parentheses in $file_name\n" if $in_parentheses;
+
+ return @ranges;
+ }
diff --git a/v4l/tda1004x.c b/v4l/tda1004x.c
deleted file mode 100644
index ab0c03247..000000000
--- a/v4l/tda1004x.c
+++ /dev/null
@@ -1,1281 +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.
- */
-#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 "dvb_frontend.h"
-#include "tda1004x.h"
-
-enum tda1004x_demod {
- TDA1004X_DEMOD_TDA10045,
- TDA1004X_DEMOD_TDA10046,
-};
-
-struct tda1004x_state {
- struct i2c_adapter* i2c;
- struct dvb_frontend_ops ops;
- const struct tda1004x_config* config;
- struct dvb_frontend frontend;
-
- /* private demod data */
- u8 initialised;
- 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(1);
- 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[] = { 0x80, 0x15, 0xfe, 0xab, 0x8e };
- static u8 bandwidth_7mhz[] = { 0x6e, 0x02, 0x53, 0xc8, 0x25 };
- static u8 bandwidth_8mhz[] = { 0x60, 0x12, 0xa8, 0xe4, 0xbd };
-
- switch (bandwidth) {
- case BANDWIDTH_6_MHZ:
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_6mhz, sizeof(bandwidth_6mhz));
- if (state->config->if_freq == TDA10046_FREQ_045) {
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x09);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x4f);
- }
- break;
-
- case BANDWIDTH_7_MHZ:
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_7mhz, sizeof(bandwidth_7mhz));
- 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, 0x79);
- }
- break;
-
- case BANDWIDTH_8_MHZ:
- tda1004x_write_buf(state, TDA10046H_TIME_WREF1, bandwidth_8mhz, sizeof(bandwidth_8mhz));
- if (state->config->if_freq == TDA10046_FREQ_045) {
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3);
- }
- 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;
-
- tda1004x_write_byteI(state, TDA10046H_CONFPLL1, 0xf0);
- tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 10); // PLL M = 10
- 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
- }
- tda1004x_write_byteI(state, TDA10046H_FREQ_OFFSET, 99);
- switch (state->config->if_freq) {
- case TDA10046_FREQ_3617:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x2c);
- break;
- case TDA10046_FREQ_3613:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0xd4);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x13);
- break;
- case TDA10046_FREQ_045:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0b);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0xa3);
- break;
- case TDA10046_FREQ_052:
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_MSB, 0x0c);
- tda1004x_write_byteI(state, TDA10046H_FREQ_PHY2_LSB, 0x06);
- break;
- }
- tda10046h_set_bandwidth(state, BANDWIDTH_8_MHZ); // default bandwidth 8 MHz
-}
-
-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 */
- tda1004x_write_byteI(state, TDA1004X_CONFC4, 0);
- tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0);
- /* let the clocks recover from sleep */
- msleep(5);
-
- /* don't re-upload unless necessary */
- if (tda1004x_check_upload_ok(state) == 0)
- return 0;
-
- /* set parameters */
- tda10046_init_plls(fe);
-
- 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 */
- /* Hac Note: we might need to do some GPIO Magic here */
- 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 (state->initialised)
- return 0;
-
- if (tda10045_fwupload(fe)) {
- printk("tda1004x: firmware upload failed\n");
- return -EIO;
- }
-
- tda1004x_write_mask(state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC
-
- // Init the PLL
- if (state->config->pll_init) {
- tda1004x_enable_tuner_i2c(state);
- state->config->pll_init(fe);
- tda1004x_disable_tuner_i2c(state);
- }
-
- // 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);
-
- state->initialised = 1;
- return 0;
-}
-
-static int tda10046_init(struct dvb_frontend* fe)
-{
- struct tda1004x_state* state = fe->demodulator_priv;
- dprintk("%s\n", __FUNCTION__);
-
- if (state->initialised)
- return 0;
-
- if (tda10046_fwupload(fe)) {
- printk("tda1004x: firmware upload failed\n");
- return -EIO;
- }
-
- // Init the tuner PLL
- if (state->config->pll_init) {
- tda1004x_enable_tuner_i2c(state);
- state->config->pll_init(fe);
- tda1004x_disable_tuner_i2c(state);
- }
-
- // tda setup
- tda1004x_write_mask(state, TDA1004X_CONFC4, 0x20, 0); // disable DSP watchdog timer
- tda1004x_write_byteI(state, TDA1004X_AUTO, 7); // select HP stream
- tda1004x_write_byteI(state, TDA1004X_CONFC1, 8); // disable pulse killer
-
- tda10046_init_plls(fe);
- 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, 0x0E); // Gain Renormalize
- tda1004x_write_byteI(state, TDA10046H_CONF_POLARITY, 0x60); // set AGC polarities
- break;
- }
- 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, 1); // 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, 0x3a, 0x80, state->config->invert_oclk << 7);
-
- tda1004x_write_byteI(state, TDA10046H_CONF_TRISTATE2, 0xe1); // tristate setup
- tda1004x_write_byteI(state, TDA10046H_GPIO_OUT_SEL, 0xcc); // GPIO output config
- tda1004x_write_byteI(state, TDA10046H_GPIO_SELECT, 8); // GPIO select
-
- state->initialised = 1;
- 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
- tda1004x_enable_tuner_i2c(state);
- state->config->pll_set(fe, fe_params);
- tda1004x_disable_tuner_i2c(state);
-
- // 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);
- 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 0x60:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
- break;
- case 0x6e:
- fe_params->u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
- break;
- case 0x80:
- 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);
- 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 << 16) & 0x0f);
- 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;
- if (tmp)
- 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);
- 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:
- if (state->config->pll_sleep != NULL) {
- tda1004x_enable_tuner_i2c(state);
- state->config->pll_sleep(fe);
- tda1004x_disable_tuner_i2c(state);
- }
- tda1004x_write_mask(state, TDA1004X_CONFC4, 1, 1);
- break;
- }
- state->initialised = 0;
-
- return 0;
-}
-
-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,
-
- .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;
- memcpy(&state->ops, &tda10045_ops, sizeof(struct dvb_frontend_ops));
- state->initialised = 0;
- 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 */
- state->frontend.ops = &state->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,
-
- .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;
- memcpy(&state->ops, &tda10046_ops, sizeof(struct dvb_frontend_ops));
- state->initialised = 0;
- 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 */
- state->frontend.ops = &state->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/v4l/tda1004x.h b/v4l/tda1004x.h
deleted file mode 100644
index 8659c5264..000000000
--- a/v4l/tda1004x.h
+++ /dev/null
@@ -1,86 +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 */
-};
-
-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;
-
- /* PLL maintenance */
- int (*pll_init)(struct dvb_frontend* fe);
- void (*pll_sleep)(struct dvb_frontend* fe);
- int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
-
- /* 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