Commit 1c72cfdc authored by Andrew de Quincey's avatar Andrew de Quincey Committed by Mauro Carvalho Chehab

V4L/DVB (4607): Port budget-av to use the new tua6100 driver

Port budget-av to use the new tua6100 driver
Signed-off-by: default avatarAndrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 00be2e7c
...@@ -113,6 +113,7 @@ config DVB_BUDGET_AV ...@@ -113,6 +113,7 @@ config DVB_BUDGET_AV
select DVB_STV0299 if !DVB_FE_CUSTOMISE select DVB_STV0299 if !DVB_FE_CUSTOMISE
select DVB_TDA1004X if !DVB_FE_CUSTOMISE select DVB_TDA1004X if !DVB_FE_CUSTOMISE
select DVB_TDA10021 if !DVB_FE_CUSTOMISE select DVB_TDA10021 if !DVB_FE_CUSTOMISE
select DVB_TUA6100 if !DVB_FE_CUSTOMISE
select FW_LOADER select FW_LOADER
help help
Support for simple SAA7146 based DVB cards Support for simple SAA7146 based DVB cards
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "stv0299.h" #include "stv0299.h"
#include "tda10021.h" #include "tda10021.h"
#include "tda1004x.h" #include "tda1004x.h"
#include "tua6100.h"
#include "dvb-pll.h" #include "dvb-pll.h"
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -548,144 +549,6 @@ static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe, ...@@ -548,144 +549,6 @@ static int philips_su1278_ty_ci_tuner_set_params(struct dvb_frontend *fe,
return 0; return 0;
} }
#define MIN2(a,b) ((a) < (b) ? (a) : (b))
#define MIN3(a,b,c) MIN2(MIN2(a,b),c)
static int philips_su1278sh2_tua6100_tuner_set_params(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params)
{
u8 reg0 [2] = { 0x00, 0x00 };
u8 reg1 [4] = { 0x01, 0x00, 0x00, 0x00 };
u8 reg2 [3] = { 0x02, 0x00, 0x00 };
int _fband;
int first_ZF;
int R, A, N, P, M;
struct i2c_msg msg = {.addr = 0x60,.flags = 0,.buf = NULL,.len = 0 };
int freq = params->frequency;
struct budget *budget = (struct budget *) fe->dvb->priv;
first_ZF = (freq) / 1000;
if (abs(MIN2(abs(first_ZF-1190),abs(first_ZF-1790))) <
abs(MIN3(abs(first_ZF-1202),abs(first_ZF-1542),abs(first_ZF-1890))))
_fband = 2;
else
_fband = 3;
if (_fband == 2) {
if (((first_ZF >= 950) && (first_ZF < 1350)) ||
((first_ZF >= 1430) && (first_ZF < 1950)))
reg0[1] = 0x07;
else if (((first_ZF >= 1350) && (first_ZF < 1430)) ||
((first_ZF >= 1950) && (first_ZF < 2150)))
reg0[1] = 0x0B;
}
if(_fband == 3) {
if (((first_ZF >= 950) && (first_ZF < 1350)) ||
((first_ZF >= 1455) && (first_ZF < 1950)))
reg0[1] = 0x07;
else if (((first_ZF >= 1350) && (first_ZF < 1420)) ||
((first_ZF >= 1950) && (first_ZF < 2150)))
reg0[1] = 0x0B;
else if ((first_ZF >= 1420) && (first_ZF < 1455))
reg0[1] = 0x0F;
}
if (first_ZF > 1525)
reg1[1] |= 0x80;
else
reg1[1] &= 0x7F;
if (_fband == 2) {
if (first_ZF > 1430) { /* 1430MHZ */
reg1[1] &= 0xCF; /* N2 */
reg2[1] &= 0xCF; /* R2 */
reg2[1] |= 0x10;
} else {
reg1[1] &= 0xCF; /* N2 */
reg1[1] |= 0x20;
reg2[1] &= 0xCF; /* R2 */
reg2[1] |= 0x10;
}
}
if (_fband == 3) {
if ((first_ZF >= 1455) &&
(first_ZF < 1630)) {
reg1[1] &= 0xCF; /* N2 */
reg1[1] |= 0x20;
reg2[1] &= 0xCF; /* R2 */
} else {
if (first_ZF < 1455) {
reg1[1] &= 0xCF; /* N2 */
reg1[1] |= 0x20;
reg2[1] &= 0xCF; /* R2 */
reg2[1] |= 0x10;
} else {
if (first_ZF >= 1630) {
reg1[1] &= 0xCF; /* N2 */
reg2[1] &= 0xCF; /* R2 */
reg2[1] |= 0x10;
}
}
}
}
/* set ports, enable P0 for symbol rates > 4Ms/s */
if (params->u.qpsk.symbol_rate >= 4000000)
reg1[1] |= 0x0c;
else
reg1[1] |= 0x04;
reg2[1] |= 0x0c;
R = 64;
A = 64;
P = 64; //32
M = (freq * R) / 4; /* in Mhz */
N = (M - A * 1000) / (P * 1000);
reg1[1] |= (N >> 9) & 0x03;
reg1[2] = (N >> 1) & 0xff;
reg1[3] = (N << 7) & 0x80;
reg2[1] |= (R >> 8) & 0x03;
reg2[2] = R & 0xFF; /* R */
reg1[3] |= A & 0x7f; /* A */
if (P == 64)
reg1[1] |= 0x40; /* Prescaler 64/65 */
reg0[1] |= 0x03;
/* already enabled - do not reenable i2c repeater or TX fails */
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
msg.buf = reg0;
msg.len = sizeof(reg0);
if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
return -EIO;
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
msg.buf = reg1;
msg.len = sizeof(reg1);
if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
return -EIO;
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
msg.buf = reg2;
msg.len = sizeof(reg2);
if (i2c_transfer(&budget->i2c_adap, &msg, 1) != 1)
return -EIO;
return 0;
}
static u8 typhoon_cinergy1200s_inittab[] = { static u8 typhoon_cinergy1200s_inittab[] = {
0x01, 0x15, 0x01, 0x15,
0x02, 0x30, 0x02, 0x30,
...@@ -1102,7 +965,7 @@ static void frontend_init(struct budget_av *budget_av) ...@@ -1102,7 +965,7 @@ static void frontend_init(struct budget_av *budget_av)
fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config, fe = dvb_attach(stv0299_attach, &cinergy_1200s_1894_0010_config,
&budget_av->budget.i2c_adap); &budget_av->budget.i2c_adap);
if (fe) { if (fe) {
fe->ops.tuner_ops.set_params = philips_su1278sh2_tua6100_tuner_set_params; dvb_attach(tua6100_attach, fe, 0x60, &budget_av->budget.i2c_adap);
} }
} else { } else {
fe = dvb_attach(stv0299_attach, &typhoon_config, fe = dvb_attach(stv0299_attach, &typhoon_config,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment