2007-04-27 15:31:14 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) 2005 Hartmut Hackmann
|
|
|
|
* (c) 2007 Michael Krufky
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2007-04-27 15:31:14 +00:00
|
|
|
#include <asm/types.h>
|
2007-08-25 22:08:45 +00:00
|
|
|
#include <linux/dvb/frontend.h>
|
|
|
|
#include <linux/videodev2.h>
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
#include "tda827x.h"
|
|
|
|
|
2008-04-22 17:41:48 +00:00
|
|
|
static int debug;
|
2007-08-25 22:08:45 +00:00
|
|
|
module_param(debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
#define dprintk(args...) \
|
|
|
|
do { \
|
|
|
|
if (debug) printk(KERN_DEBUG "tda827x: " args); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
struct tda827x_priv {
|
|
|
|
int i2c_addr;
|
|
|
|
struct i2c_adapter *i2c_adap;
|
|
|
|
struct tda827x_config *cfg;
|
2007-10-22 04:10:39 +00:00
|
|
|
|
|
|
|
unsigned int sgIF;
|
|
|
|
unsigned char lpsel;
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
u32 frequency;
|
|
|
|
u32 bandwidth;
|
|
|
|
};
|
|
|
|
|
2007-10-22 04:10:39 +00:00
|
|
|
static void tda827x_set_std(struct dvb_frontend *fe,
|
|
|
|
struct analog_parameters *params)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
char *mode;
|
|
|
|
|
|
|
|
priv->lpsel = 0;
|
|
|
|
if (params->std & V4L2_STD_MN) {
|
|
|
|
priv->sgIF = 92;
|
|
|
|
priv->lpsel = 1;
|
|
|
|
mode = "MN";
|
|
|
|
} else if (params->std & V4L2_STD_B) {
|
|
|
|
priv->sgIF = 108;
|
|
|
|
mode = "B";
|
|
|
|
} else if (params->std & V4L2_STD_GH) {
|
|
|
|
priv->sgIF = 124;
|
|
|
|
mode = "GH";
|
|
|
|
} else if (params->std & V4L2_STD_PAL_I) {
|
|
|
|
priv->sgIF = 124;
|
|
|
|
mode = "I";
|
|
|
|
} else if (params->std & V4L2_STD_DK) {
|
|
|
|
priv->sgIF = 124;
|
|
|
|
mode = "DK";
|
|
|
|
} else if (params->std & V4L2_STD_SECAM_L) {
|
|
|
|
priv->sgIF = 124;
|
|
|
|
mode = "L";
|
|
|
|
} else if (params->std & V4L2_STD_SECAM_LC) {
|
|
|
|
priv->sgIF = 20;
|
|
|
|
mode = "LC";
|
|
|
|
} else {
|
|
|
|
priv->sgIF = 124;
|
|
|
|
mode = "xx";
|
|
|
|
}
|
|
|
|
|
2008-12-08 02:01:57 +00:00
|
|
|
if (params->mode == V4L2_TUNER_RADIO) {
|
2007-10-22 04:10:39 +00:00
|
|
|
priv->sgIF = 88; /* if frequency is 5.5 MHz */
|
2008-12-08 02:01:57 +00:00
|
|
|
dprintk("setting tda827x to radio FM\n");
|
|
|
|
} else
|
|
|
|
dprintk("setting tda827x to system %s\n", mode);
|
2007-10-22 04:10:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
struct tda827x_data {
|
|
|
|
u32 lomax;
|
|
|
|
u8 spd;
|
|
|
|
u8 bs;
|
|
|
|
u8 bp;
|
|
|
|
u8 cp;
|
|
|
|
u8 gc3;
|
|
|
|
u8 div1p5;
|
|
|
|
};
|
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
static const struct tda827x_data tda827x_table[] = {
|
2007-04-27 15:31:14 +00:00
|
|
|
{ .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
|
|
|
|
{ .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
|
|
|
|
{ .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
|
|
|
|
{ .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
|
|
|
|
{ .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
|
|
|
|
{ .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
|
|
|
|
{ .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
|
|
|
|
{ .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
|
|
|
|
{ .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
|
|
|
|
{ .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
|
|
|
|
{ .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
|
|
|
|
{ .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
|
|
|
|
{ .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
|
|
|
|
{ .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
|
|
|
|
{ .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
|
|
|
|
{ .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
|
|
|
|
{ .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
|
|
|
|
{ .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
|
|
|
|
};
|
|
|
|
|
2009-02-08 11:34:43 +00:00
|
|
|
static int tuner_transfer(struct dvb_frontend *fe,
|
|
|
|
struct i2c_msg *msg,
|
|
|
|
const int size)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
|
|
|
|
if (fe->ops.i2c_gate_ctrl)
|
|
|
|
fe->ops.i2c_gate_ctrl(fe, 1);
|
|
|
|
rc = i2c_transfer(priv->i2c_adap, msg, size);
|
|
|
|
if (fe->ops.i2c_gate_ctrl)
|
|
|
|
fe->ops.i2c_gate_ctrl(fe, 0);
|
|
|
|
|
|
|
|
if (rc >= 0 && rc != size)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-24 15:24:33 +00:00
|
|
|
static int tda827xo_set_params(struct dvb_frontend *fe)
|
2007-04-27 15:31:14 +00:00
|
|
|
{
|
2011-12-21 11:39:44 +00:00
|
|
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
2007-04-27 15:31:14 +00:00
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
u8 buf[14];
|
2009-02-08 11:34:43 +00:00
|
|
|
int rc;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
|
|
|
|
.buf = buf, .len = sizeof(buf) };
|
|
|
|
int i, tuner_freq, if_freq;
|
|
|
|
u32 N;
|
|
|
|
|
2008-04-22 17:46:08 +00:00
|
|
|
dprintk("%s:\n", __func__);
|
2011-12-21 11:39:44 +00:00
|
|
|
if (c->bandwidth_hz == 0) {
|
|
|
|
if_freq = 5000000;
|
|
|
|
} else if (c->bandwidth_hz <= 6000000) {
|
2007-04-27 15:31:14 +00:00
|
|
|
if_freq = 4000000;
|
2011-12-21 11:39:44 +00:00
|
|
|
} else if (c->bandwidth_hz <= 7000000) {
|
2007-04-27 15:31:14 +00:00
|
|
|
if_freq = 4500000;
|
2011-12-21 11:39:44 +00:00
|
|
|
} else { /* 8 MHz */
|
2007-04-27 15:31:14 +00:00
|
|
|
if_freq = 5000000;
|
|
|
|
}
|
2011-12-21 11:39:44 +00:00
|
|
|
tuner_freq = c->frequency;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
i = 0;
|
2007-08-25 22:08:45 +00:00
|
|
|
while (tda827x_table[i].lomax < tuner_freq) {
|
|
|
|
if (tda827x_table[i + 1].lomax == 0)
|
2007-04-27 15:31:14 +00:00
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2011-07-16 11:38:13 +00:00
|
|
|
tuner_freq += if_freq;
|
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
N = ((tuner_freq + 125000) / 250000) << (tda827x_table[i].spd + 2);
|
2007-04-27 15:31:14 +00:00
|
|
|
buf[0] = 0;
|
|
|
|
buf[1] = (N>>8) | 0x40;
|
|
|
|
buf[2] = N & 0xff;
|
|
|
|
buf[3] = 0;
|
|
|
|
buf[4] = 0x52;
|
2007-08-25 22:08:45 +00:00
|
|
|
buf[5] = (tda827x_table[i].spd << 6) + (tda827x_table[i].div1p5 << 5) +
|
|
|
|
(tda827x_table[i].bs << 3) +
|
|
|
|
tda827x_table[i].bp;
|
|
|
|
buf[6] = (tda827x_table[i].gc3 << 4) + 0x8f;
|
2007-04-27 15:31:14 +00:00
|
|
|
buf[7] = 0xbf;
|
|
|
|
buf[8] = 0x2a;
|
|
|
|
buf[9] = 0x05;
|
|
|
|
buf[10] = 0xff;
|
|
|
|
buf[11] = 0x00;
|
|
|
|
buf[12] = 0x00;
|
|
|
|
buf[13] = 0x40;
|
|
|
|
|
|
|
|
msg.len = 14;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
msleep(500);
|
|
|
|
/* correct CP value */
|
|
|
|
buf[0] = 0x30;
|
2007-08-25 22:08:45 +00:00
|
|
|
buf[1] = 0x50 + tda827x_table[i].cp;
|
2007-04-27 15:31:14 +00:00
|
|
|
msg.len = 2;
|
|
|
|
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
2011-12-21 11:39:44 +00:00
|
|
|
priv->frequency = c->frequency;
|
2011-12-26 23:02:28 +00:00
|
|
|
priv->bandwidth = c->bandwidth_hz;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-02-08 11:34:43 +00:00
|
|
|
|
|
|
|
err:
|
|
|
|
printk(KERN_ERR "%s: could not write to tuner at addr: 0x%02x\n",
|
|
|
|
__func__, priv->i2c_addr << 1);
|
|
|
|
return rc;
|
2007-04-27 15:31:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int tda827xo_sleep(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
static u8 buf[] = { 0x30, 0xd0 };
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
|
|
|
|
.buf = buf, .len = sizeof(buf) };
|
|
|
|
|
2008-04-22 17:46:08 +00:00
|
|
|
dprintk("%s:\n", __func__);
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
if (priv->cfg && priv->cfg->sleep)
|
|
|
|
priv->cfg->sleep(fe);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
static int tda827xo_set_analog_params(struct dvb_frontend *fe,
|
|
|
|
struct analog_parameters *params)
|
|
|
|
{
|
|
|
|
unsigned char tuner_reg[8];
|
|
|
|
unsigned char reg2[2];
|
|
|
|
u32 N;
|
|
|
|
int i;
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0 };
|
|
|
|
unsigned int freq = params->frequency;
|
|
|
|
|
2007-10-22 04:10:39 +00:00
|
|
|
tda827x_set_std(fe, params);
|
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
if (params->mode == V4L2_TUNER_RADIO)
|
|
|
|
freq = freq / 1000;
|
|
|
|
|
2007-10-22 04:10:39 +00:00
|
|
|
N = freq + priv->sgIF;
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (tda827x_table[i].lomax < N * 62500) {
|
|
|
|
if (tda827x_table[i + 1].lomax == 0)
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
N = N << tda827x_table[i].spd;
|
|
|
|
|
|
|
|
tuner_reg[0] = 0;
|
|
|
|
tuner_reg[1] = (unsigned char)(N>>8);
|
|
|
|
tuner_reg[2] = (unsigned char) N;
|
|
|
|
tuner_reg[3] = 0x40;
|
2007-10-22 04:10:39 +00:00
|
|
|
tuner_reg[4] = 0x52 + (priv->lpsel << 5);
|
2007-08-25 22:08:45 +00:00
|
|
|
tuner_reg[5] = (tda827x_table[i].spd << 6) +
|
|
|
|
(tda827x_table[i].div1p5 << 5) +
|
|
|
|
(tda827x_table[i].bs << 3) + tda827x_table[i].bp;
|
|
|
|
tuner_reg[6] = 0x8f + (tda827x_table[i].gc3 << 4);
|
|
|
|
tuner_reg[7] = 0x8f;
|
|
|
|
|
|
|
|
msg.buf = tuner_reg;
|
|
|
|
msg.len = 8;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
msg.buf = reg2;
|
|
|
|
msg.len = 2;
|
|
|
|
reg2[0] = 0x80;
|
|
|
|
reg2[1] = 0;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
reg2[0] = 0x60;
|
|
|
|
reg2[1] = 0xbf;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
reg2[0] = 0x30;
|
|
|
|
reg2[1] = tuner_reg[4] + 0x80;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
msleep(1);
|
|
|
|
reg2[0] = 0x30;
|
|
|
|
reg2[1] = tuner_reg[4] + 4;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
msleep(1);
|
|
|
|
reg2[0] = 0x30;
|
|
|
|
reg2[1] = tuner_reg[4];
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
msleep(550);
|
|
|
|
reg2[0] = 0x30;
|
|
|
|
reg2[1] = (tuner_reg[4] & 0xfc) + tda827x_table[i].cp;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
reg2[0] = 0x60;
|
|
|
|
reg2[1] = 0x3f;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
reg2[0] = 0x80;
|
|
|
|
reg2[1] = 0x08; /* Vsync en */
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
2008-12-08 03:49:33 +00:00
|
|
|
priv->frequency = params->frequency;
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tda827xo_agcf(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
unsigned char data[] = { 0x80, 0x0c };
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
|
|
|
|
.buf = data, .len = 2};
|
|
|
|
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
struct tda827xa_data {
|
|
|
|
u32 lomax;
|
|
|
|
u8 svco;
|
|
|
|
u8 spd;
|
|
|
|
u8 scr;
|
|
|
|
u8 sbs;
|
|
|
|
u8 gc3;
|
|
|
|
};
|
|
|
|
|
2009-03-25 20:53:02 +00:00
|
|
|
static struct tda827xa_data tda827xa_dvbt[] = {
|
2007-04-27 15:31:14 +00:00
|
|
|
{ .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
|
|
|
|
{ .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
|
|
|
|
{ .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
|
|
|
|
{ .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
|
|
|
|
{ .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}
|
|
|
|
};
|
|
|
|
|
2009-03-25 20:53:02 +00:00
|
|
|
static struct tda827xa_data tda827xa_dvbc[] = {
|
|
|
|
{ .lomax = 50125000, .svco = 2, .spd = 4, .scr = 2, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 58500000, .svco = 3, .spd = 4, .scr = 2, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 69250000, .svco = 0, .spd = 3, .scr = 2, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 83625000, .svco = 1, .spd = 3, .scr = 2, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 97500000, .svco = 2, .spd = 3, .scr = 2, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 100250000, .svco = 2, .spd = 3, .scr = 2, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 117000000, .svco = 3, .spd = 3, .scr = 2, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 138500000, .svco = 0, .spd = 2, .scr = 2, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 167250000, .svco = 1, .spd = 2, .scr = 2, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 187000000, .svco = 2, .spd = 2, .scr = 2, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 200500000, .svco = 2, .spd = 2, .scr = 2, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 234000000, .svco = 3, .spd = 2, .scr = 2, .sbs = 2, .gc3 = 3},
|
|
|
|
{ .lomax = 277000000, .svco = 0, .spd = 1, .scr = 2, .sbs = 2, .gc3 = 3},
|
|
|
|
{ .lomax = 325000000, .svco = 1, .spd = 1, .scr = 2, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 334500000, .svco = 1, .spd = 1, .scr = 2, .sbs = 3, .gc3 = 3},
|
|
|
|
{ .lomax = 401000000, .svco = 2, .spd = 1, .scr = 2, .sbs = 3, .gc3 = 3},
|
|
|
|
{ .lomax = 468000000, .svco = 3, .spd = 1, .scr = 2, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 535000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 554000000, .svco = 0, .spd = 0, .scr = 2, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 638000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 1},
|
|
|
|
{ .lomax = 669000000, .svco = 1, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 1},
|
|
|
|
{ .lomax = 720000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 1},
|
|
|
|
{ .lomax = 802000000, .svco = 2, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 1},
|
|
|
|
{ .lomax = 835000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 1},
|
|
|
|
{ .lomax = 885000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 1},
|
|
|
|
{ .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 1},
|
|
|
|
{ .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}
|
|
|
|
};
|
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
static struct tda827xa_data tda827xa_analog[] = {
|
|
|
|
{ .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 3},
|
|
|
|
{ .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
|
|
|
|
{ .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 3},
|
|
|
|
{ .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 3},
|
|
|
|
{ .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
|
|
|
|
{ .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3},
|
|
|
|
{ .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 3},
|
|
|
|
{ .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 554000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
|
|
|
|
{ .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
|
|
|
|
{ .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}
|
|
|
|
};
|
|
|
|
|
2008-04-22 17:46:08 +00:00
|
|
|
static int tda827xa_sleep(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
static u8 buf[] = { 0x30, 0x90 };
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
|
|
|
|
.buf = buf, .len = sizeof(buf) };
|
|
|
|
|
|
|
|
dprintk("%s:\n", __func__);
|
|
|
|
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2008-04-22 17:46:08 +00:00
|
|
|
|
|
|
|
if (priv->cfg && priv->cfg->sleep)
|
|
|
|
priv->cfg->sleep(fe);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tda827xa_lna_gain(struct dvb_frontend *fe, int high,
|
|
|
|
struct analog_parameters *params)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
unsigned char buf[] = {0x22, 0x01};
|
|
|
|
int arg;
|
|
|
|
int gp_func;
|
2008-06-05 15:53:08 +00:00
|
|
|
struct i2c_msg msg = { .flags = 0, .buf = buf, .len = sizeof(buf) };
|
2008-04-22 17:46:08 +00:00
|
|
|
|
|
|
|
if (NULL == priv->cfg) {
|
|
|
|
dprintk("tda827x_config not defined, cannot set LNA gain!\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-06-05 15:53:08 +00:00
|
|
|
msg.addr = priv->cfg->switch_addr;
|
2008-04-22 17:46:08 +00:00
|
|
|
if (priv->cfg->config) {
|
|
|
|
if (high)
|
|
|
|
dprintk("setting LNA to high gain\n");
|
|
|
|
else
|
|
|
|
dprintk("setting LNA to low gain\n");
|
|
|
|
}
|
|
|
|
switch (priv->cfg->config) {
|
2013-04-06 17:29:29 +00:00
|
|
|
case TDA8290_LNA_OFF: /* no LNA */
|
2008-04-22 17:46:08 +00:00
|
|
|
break;
|
2013-04-06 17:29:29 +00:00
|
|
|
case TDA8290_LNA_GP0_HIGH_ON: /* switch is GPIO 0 of tda8290 */
|
|
|
|
case TDA8290_LNA_GP0_HIGH_OFF:
|
2008-04-22 17:46:08 +00:00
|
|
|
if (params == NULL) {
|
|
|
|
gp_func = 0;
|
|
|
|
arg = 0;
|
|
|
|
} else {
|
|
|
|
/* turn Vsync on */
|
|
|
|
gp_func = 1;
|
|
|
|
if (params->std & V4L2_STD_MN)
|
|
|
|
arg = 1;
|
|
|
|
else
|
|
|
|
arg = 0;
|
|
|
|
}
|
2008-09-12 16:31:45 +00:00
|
|
|
if (fe->callback)
|
|
|
|
fe->callback(priv->i2c_adap->algo_data,
|
|
|
|
DVB_FRONTEND_COMPONENT_TUNER,
|
|
|
|
gp_func, arg);
|
2008-04-22 17:46:08 +00:00
|
|
|
buf[1] = high ? 0 : 1;
|
2013-04-06 17:29:29 +00:00
|
|
|
if (priv->cfg->config == TDA8290_LNA_GP0_HIGH_OFF)
|
2008-04-22 17:46:08 +00:00
|
|
|
buf[1] = high ? 1 : 0;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2008-04-22 17:46:08 +00:00
|
|
|
break;
|
2013-04-06 17:29:29 +00:00
|
|
|
case TDA8290_LNA_ON_BRIDGE: /* switch with GPIO of saa713x */
|
2008-09-12 16:31:45 +00:00
|
|
|
if (fe->callback)
|
|
|
|
fe->callback(priv->i2c_adap->algo_data,
|
|
|
|
DVB_FRONTEND_COMPONENT_TUNER, 0, high);
|
2008-04-22 17:46:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-24 15:24:33 +00:00
|
|
|
static int tda827xa_set_params(struct dvb_frontend *fe)
|
2007-04-27 15:31:14 +00:00
|
|
|
{
|
2011-12-21 11:39:44 +00:00
|
|
|
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
|
2007-04-27 15:31:14 +00:00
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
2009-03-25 20:53:02 +00:00
|
|
|
struct tda827xa_data *frequency_map = tda827xa_dvbt;
|
2007-04-27 15:31:32 +00:00
|
|
|
u8 buf[11];
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
|
|
|
|
.buf = buf, .len = sizeof(buf) };
|
|
|
|
|
2009-02-08 11:34:43 +00:00
|
|
|
int i, tuner_freq, if_freq, rc;
|
2007-04-27 15:31:14 +00:00
|
|
|
u32 N;
|
|
|
|
|
2008-04-22 17:46:08 +00:00
|
|
|
dprintk("%s:\n", __func__);
|
|
|
|
|
|
|
|
tda827xa_lna_gain(fe, 1, NULL);
|
2007-04-27 15:31:14 +00:00
|
|
|
msleep(20);
|
|
|
|
|
2011-12-21 11:39:44 +00:00
|
|
|
if (c->bandwidth_hz == 0) {
|
|
|
|
if_freq = 5000000;
|
|
|
|
} else if (c->bandwidth_hz <= 6000000) {
|
2007-04-27 15:31:14 +00:00
|
|
|
if_freq = 4000000;
|
2011-12-21 11:39:44 +00:00
|
|
|
} else if (c->bandwidth_hz <= 7000000) {
|
2007-04-27 15:31:14 +00:00
|
|
|
if_freq = 4500000;
|
2011-12-21 11:39:44 +00:00
|
|
|
} else { /* 8 MHz */
|
2007-04-27 15:31:14 +00:00
|
|
|
if_freq = 5000000;
|
|
|
|
}
|
2011-12-21 11:39:44 +00:00
|
|
|
tuner_freq = c->frequency;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
[media] Don't test for ops->info.type inside drivers
Now, ops->info.type is handled inside the dvb_frontend
core, only for DVBv3 calls, and according with the
delivery system. So, drivers should not care or use it,
otherwise, it may have issues with DVBv5 calls.
The drivers that were still using it were detected via
this small temporary hack:
--- a/include/linux/dvb/frontend.h
+++ b/include/linux/dvb/frontend.h
@@ -29,13 +29,16 @@
#include <linux/types.h>
typedef enum fe_type {
+#if defined(__DVB_CORE__) || !defined (__KERNEL__)
FE_QPSK,
FE_QAM,
FE_OFDM,
FE_ATSC
+#else
+FE_FOOO
+#endif
} fe_type_t;
-
typedef enum fe_caps {
FE_IS_STUPID = 0,
FE_CAN_INVERSION_AUTO = 0x1,
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-01-05 01:10:19 +00:00
|
|
|
switch (c->delivery_system) {
|
|
|
|
case SYS_DVBC_ANNEX_A:
|
|
|
|
case SYS_DVBC_ANNEX_C:
|
2009-03-25 20:53:02 +00:00
|
|
|
dprintk("%s select tda827xa_dvbc\n", __func__);
|
|
|
|
frequency_map = tda827xa_dvbc;
|
[media] Don't test for ops->info.type inside drivers
Now, ops->info.type is handled inside the dvb_frontend
core, only for DVBv3 calls, and according with the
delivery system. So, drivers should not care or use it,
otherwise, it may have issues with DVBv5 calls.
The drivers that were still using it were detected via
this small temporary hack:
--- a/include/linux/dvb/frontend.h
+++ b/include/linux/dvb/frontend.h
@@ -29,13 +29,16 @@
#include <linux/types.h>
typedef enum fe_type {
+#if defined(__DVB_CORE__) || !defined (__KERNEL__)
FE_QPSK,
FE_QAM,
FE_OFDM,
FE_ATSC
+#else
+FE_FOOO
+#endif
} fe_type_t;
-
typedef enum fe_caps {
FE_IS_STUPID = 0,
FE_CAN_INVERSION_AUTO = 0x1,
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2012-01-05 01:10:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-03-25 20:53:02 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
i = 0;
|
2009-03-25 20:53:02 +00:00
|
|
|
while (frequency_map[i].lomax < tuner_freq) {
|
|
|
|
if (frequency_map[i + 1].lomax == 0)
|
2007-04-27 15:31:14 +00:00
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2011-07-16 11:38:13 +00:00
|
|
|
tuner_freq += if_freq;
|
|
|
|
|
2009-03-25 20:53:02 +00:00
|
|
|
N = ((tuner_freq + 31250) / 62500) << frequency_map[i].spd;
|
2007-04-27 15:31:14 +00:00
|
|
|
buf[0] = 0; // subaddress
|
|
|
|
buf[1] = N >> 8;
|
|
|
|
buf[2] = N & 0xff;
|
|
|
|
buf[3] = 0;
|
|
|
|
buf[4] = 0x16;
|
2009-03-25 20:53:02 +00:00
|
|
|
buf[5] = (frequency_map[i].spd << 5) + (frequency_map[i].svco << 3) +
|
|
|
|
frequency_map[i].sbs;
|
|
|
|
buf[6] = 0x4b + (frequency_map[i].gc3 << 4);
|
2007-04-27 15:31:14 +00:00
|
|
|
buf[7] = 0x1c;
|
|
|
|
buf[8] = 0x06;
|
|
|
|
buf[9] = 0x24;
|
|
|
|
buf[10] = 0x00;
|
|
|
|
msg.len = 11;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
buf[0] = 0x90;
|
|
|
|
buf[1] = 0xff;
|
|
|
|
buf[2] = 0x60;
|
|
|
|
buf[3] = 0x00;
|
|
|
|
buf[4] = 0x59; // lpsel, for 6MHz + 2
|
|
|
|
msg.len = 5;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
buf[0] = 0xa0;
|
|
|
|
buf[1] = 0x40;
|
|
|
|
msg.len = 2;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
msleep(11);
|
|
|
|
msg.flags = I2C_M_RD;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
msg.flags = 0;
|
|
|
|
|
|
|
|
buf[1] >>= 4;
|
|
|
|
dprintk("tda8275a AGC2 gain is: %d\n", buf[1]);
|
|
|
|
if ((buf[1]) < 2) {
|
2008-04-22 17:46:08 +00:00
|
|
|
tda827xa_lna_gain(fe, 0, NULL);
|
2007-04-27 15:31:14 +00:00
|
|
|
buf[0] = 0x60;
|
|
|
|
buf[1] = 0x0c;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
buf[0] = 0xc0;
|
|
|
|
buf[1] = 0x99; // lpsel, for 6MHz + 2
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
buf[0] = 0x60;
|
|
|
|
buf[1] = 0x3c;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
/* correct CP value */
|
|
|
|
buf[0] = 0x30;
|
2009-03-25 20:53:02 +00:00
|
|
|
buf[1] = 0x10 + frequency_map[i].scr;
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
msleep(163);
|
|
|
|
buf[0] = 0xc0;
|
|
|
|
buf[1] = 0x39; // lpsel, for 6MHz + 2
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
msleep(3);
|
|
|
|
/* freeze AGC1 */
|
|
|
|
buf[0] = 0x50;
|
2009-03-25 20:53:02 +00:00
|
|
|
buf[1] = 0x4f + (frequency_map[i].gc3 << 4);
|
2009-02-08 11:34:43 +00:00
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
if (rc < 0)
|
|
|
|
goto err;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
2011-12-21 11:39:44 +00:00
|
|
|
priv->frequency = c->frequency;
|
2011-12-26 23:02:28 +00:00
|
|
|
priv->bandwidth = c->bandwidth_hz;
|
2009-02-08 11:34:43 +00:00
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
return 0;
|
2009-02-08 11:34:43 +00:00
|
|
|
|
|
|
|
err:
|
|
|
|
printk(KERN_ERR "%s: could not write to tuner at addr: 0x%02x\n",
|
|
|
|
__func__, priv->i2c_addr << 1);
|
|
|
|
return rc;
|
2007-04-27 15:31:14 +00:00
|
|
|
}
|
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
static int tda827xa_set_analog_params(struct dvb_frontend *fe,
|
|
|
|
struct analog_parameters *params)
|
|
|
|
{
|
|
|
|
unsigned char tuner_reg[11];
|
|
|
|
u32 N;
|
|
|
|
int i;
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0,
|
|
|
|
.buf = tuner_reg, .len = sizeof(tuner_reg) };
|
|
|
|
unsigned int freq = params->frequency;
|
|
|
|
|
2007-10-22 04:10:39 +00:00
|
|
|
tda827x_set_std(fe, params);
|
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
tda827xa_lna_gain(fe, 1, params);
|
|
|
|
msleep(10);
|
|
|
|
|
|
|
|
if (params->mode == V4L2_TUNER_RADIO)
|
|
|
|
freq = freq / 1000;
|
|
|
|
|
2007-10-22 04:10:39 +00:00
|
|
|
N = freq + priv->sgIF;
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
while (tda827xa_analog[i].lomax < N * 62500) {
|
|
|
|
if (tda827xa_analog[i + 1].lomax == 0)
|
|
|
|
break;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
N = N << tda827xa_analog[i].spd;
|
|
|
|
|
|
|
|
tuner_reg[0] = 0;
|
|
|
|
tuner_reg[1] = (unsigned char)(N>>8);
|
|
|
|
tuner_reg[2] = (unsigned char) N;
|
|
|
|
tuner_reg[3] = 0;
|
|
|
|
tuner_reg[4] = 0x16;
|
|
|
|
tuner_reg[5] = (tda827xa_analog[i].spd << 5) +
|
|
|
|
(tda827xa_analog[i].svco << 3) +
|
|
|
|
tda827xa_analog[i].sbs;
|
|
|
|
tuner_reg[6] = 0x8b + (tda827xa_analog[i].gc3 << 4);
|
|
|
|
tuner_reg[7] = 0x1c;
|
|
|
|
tuner_reg[8] = 4;
|
|
|
|
tuner_reg[9] = 0x20;
|
|
|
|
tuner_reg[10] = 0x00;
|
|
|
|
msg.len = 11;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
tuner_reg[0] = 0x90;
|
|
|
|
tuner_reg[1] = 0xff;
|
|
|
|
tuner_reg[2] = 0xe0;
|
|
|
|
tuner_reg[3] = 0;
|
2007-10-22 04:10:39 +00:00
|
|
|
tuner_reg[4] = 0x99 + (priv->lpsel << 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
msg.len = 5;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
tuner_reg[0] = 0xa0;
|
|
|
|
tuner_reg[1] = 0xc0;
|
|
|
|
msg.len = 2;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
tuner_reg[0] = 0x30;
|
|
|
|
tuner_reg[1] = 0x10 + tda827xa_analog[i].scr;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
msg.flags = I2C_M_RD;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
msg.flags = 0;
|
|
|
|
tuner_reg[1] >>= 4;
|
|
|
|
dprintk("AGC2 gain is: %d\n", tuner_reg[1]);
|
|
|
|
if (tuner_reg[1] < 1)
|
|
|
|
tda827xa_lna_gain(fe, 0, params);
|
|
|
|
|
|
|
|
msleep(100);
|
|
|
|
tuner_reg[0] = 0x60;
|
|
|
|
tuner_reg[1] = 0x3c;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
msleep(163);
|
|
|
|
tuner_reg[0] = 0x50;
|
|
|
|
tuner_reg[1] = 0x8f + (tda827xa_analog[i].gc3 << 4);
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
tuner_reg[0] = 0x80;
|
|
|
|
tuner_reg[1] = 0x28;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
tuner_reg[0] = 0xb0;
|
|
|
|
tuner_reg[1] = 0x01;
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
tuner_reg[0] = 0xc0;
|
2007-10-22 04:10:39 +00:00
|
|
|
tuner_reg[1] = 0x19 + (priv->lpsel << 1);
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
|
2008-12-08 03:49:33 +00:00
|
|
|
priv->frequency = params->frequency;
|
2007-08-25 22:08:45 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tda827xa_agcf(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
unsigned char data[] = {0x80, 0x2c};
|
|
|
|
struct i2c_msg msg = {.addr = priv->i2c_addr, .flags = 0,
|
|
|
|
.buf = data, .len = 2};
|
2009-02-08 11:34:43 +00:00
|
|
|
tuner_transfer(fe, &msg, 1);
|
2007-08-25 22:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
static int tda827x_release(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
kfree(fe->tuner_priv);
|
|
|
|
fe->tuner_priv = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tda827x_get_frequency(struct dvb_frontend *fe, u32 *frequency)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
*frequency = priv->frequency;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tda827x_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
*bandwidth = priv->bandwidth;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tda827x_init(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
2008-04-22 17:46:08 +00:00
|
|
|
dprintk("%s:\n", __func__);
|
2007-04-27 15:31:14 +00:00
|
|
|
if (priv->cfg && priv->cfg->init)
|
|
|
|
priv->cfg->init(fe);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-24 00:00:07 +00:00
|
|
|
static int tda827x_probe_version(struct dvb_frontend *fe);
|
|
|
|
|
|
|
|
static int tda827x_initial_init(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
ret = tda827x_probe_version(fe);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return fe->ops.tuner_ops.init(fe);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tda827x_initial_sleep(struct dvb_frontend *fe)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
ret = tda827x_probe_version(fe);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
return fe->ops.tuner_ops.sleep(fe);
|
|
|
|
}
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
static struct dvb_tuner_ops tda827xo_tuner_ops = {
|
|
|
|
.info = {
|
|
|
|
.name = "Philips TDA827X",
|
2007-04-27 15:31:15 +00:00
|
|
|
.frequency_min = 55000000,
|
|
|
|
.frequency_max = 860000000,
|
|
|
|
.frequency_step = 250000
|
2007-04-27 15:31:14 +00:00
|
|
|
},
|
|
|
|
.release = tda827x_release,
|
2007-03-24 00:00:07 +00:00
|
|
|
.init = tda827x_initial_init,
|
|
|
|
.sleep = tda827x_initial_sleep,
|
2007-04-27 15:31:14 +00:00
|
|
|
.set_params = tda827xo_set_params,
|
2007-08-25 22:08:45 +00:00
|
|
|
.set_analog_params = tda827xo_set_analog_params,
|
2007-04-27 15:31:14 +00:00
|
|
|
.get_frequency = tda827x_get_frequency,
|
|
|
|
.get_bandwidth = tda827x_get_bandwidth,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct dvb_tuner_ops tda827xa_tuner_ops = {
|
|
|
|
.info = {
|
|
|
|
.name = "Philips TDA827XA",
|
2007-04-27 15:31:15 +00:00
|
|
|
.frequency_min = 44000000,
|
|
|
|
.frequency_max = 906000000,
|
|
|
|
.frequency_step = 62500
|
2007-04-27 15:31:14 +00:00
|
|
|
},
|
|
|
|
.release = tda827x_release,
|
|
|
|
.init = tda827x_init,
|
|
|
|
.sleep = tda827xa_sleep,
|
|
|
|
.set_params = tda827xa_set_params,
|
2007-08-25 22:08:45 +00:00
|
|
|
.set_analog_params = tda827xa_set_analog_params,
|
2007-04-27 15:31:14 +00:00
|
|
|
.get_frequency = tda827x_get_frequency,
|
|
|
|
.get_bandwidth = tda827x_get_bandwidth,
|
|
|
|
};
|
|
|
|
|
2007-03-24 00:00:07 +00:00
|
|
|
static int tda827x_probe_version(struct dvb_frontend *fe)
|
2009-02-08 11:34:43 +00:00
|
|
|
{
|
|
|
|
u8 data;
|
|
|
|
int rc;
|
2007-03-24 00:00:07 +00:00
|
|
|
struct tda827x_priv *priv = fe->tuner_priv;
|
|
|
|
struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = I2C_M_RD,
|
2007-04-27 15:31:14 +00:00
|
|
|
.buf = &data, .len = 1 };
|
2009-02-08 11:34:43 +00:00
|
|
|
|
|
|
|
rc = tuner_transfer(fe, &msg, 1);
|
|
|
|
|
|
|
|
if (rc < 0) {
|
2007-04-27 15:31:14 +00:00
|
|
|
printk("%s: could not read from tuner at addr: 0x%02x\n",
|
2008-04-22 17:46:08 +00:00
|
|
|
__func__, msg.addr << 1);
|
2009-02-08 11:34:43 +00:00
|
|
|
return rc;
|
2007-03-24 00:00:07 +00:00
|
|
|
}
|
|
|
|
if ((data & 0x3c) == 0) {
|
|
|
|
dprintk("tda827x tuner found\n");
|
|
|
|
fe->ops.tuner_ops.init = tda827x_init;
|
|
|
|
fe->ops.tuner_ops.sleep = tda827xo_sleep;
|
2007-11-18 17:15:42 +00:00
|
|
|
if (priv->cfg)
|
|
|
|
priv->cfg->agcf = tda827xo_agcf;
|
2007-03-24 00:00:07 +00:00
|
|
|
} else {
|
|
|
|
dprintk("tda827xa tuner found\n");
|
|
|
|
memcpy(&fe->ops.tuner_ops, &tda827xa_tuner_ops, sizeof(struct dvb_tuner_ops));
|
2007-11-18 17:15:42 +00:00
|
|
|
if (priv->cfg)
|
|
|
|
priv->cfg->agcf = tda827xa_agcf;
|
2007-04-27 15:31:14 +00:00
|
|
|
}
|
2007-03-24 00:00:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct dvb_frontend *tda827x_attach(struct dvb_frontend *fe, int addr,
|
|
|
|
struct i2c_adapter *i2c,
|
|
|
|
struct tda827x_config *cfg)
|
|
|
|
{
|
|
|
|
struct tda827x_priv *priv = NULL;
|
2007-04-27 15:31:14 +00:00
|
|
|
|
2008-04-22 17:46:08 +00:00
|
|
|
dprintk("%s:\n", __func__);
|
2007-04-27 15:31:14 +00:00
|
|
|
priv = kzalloc(sizeof(struct tda827x_priv), GFP_KERNEL);
|
|
|
|
if (priv == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
priv->i2c_addr = addr;
|
|
|
|
priv->i2c_adap = i2c;
|
|
|
|
priv->cfg = cfg;
|
2007-03-24 00:00:07 +00:00
|
|
|
memcpy(&fe->ops.tuner_ops, &tda827xo_tuner_ops, sizeof(struct dvb_tuner_ops));
|
2007-04-27 15:31:14 +00:00
|
|
|
fe->tuner_priv = priv;
|
2007-03-24 00:00:07 +00:00
|
|
|
|
2007-08-25 22:08:45 +00:00
|
|
|
dprintk("type set to %s\n", fe->ops.tuner_ops.info.name);
|
|
|
|
|
2007-04-27 15:31:14 +00:00
|
|
|
return fe;
|
|
|
|
}
|
2007-10-22 03:28:50 +00:00
|
|
|
EXPORT_SYMBOL_GPL(tda827x_attach);
|
2007-04-27 15:31:14 +00:00
|
|
|
|
|
|
|
MODULE_DESCRIPTION("DVB TDA827x driver");
|
2007-04-27 15:31:15 +00:00
|
|
|
MODULE_AUTHOR("Hartmut Hackmann <hartmut.hackmann@t-online.de>");
|
|
|
|
MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
|
2007-04-27 15:31:14 +00:00
|
|
|
MODULE_LICENSE("GPL");
|