Commit b2083199 authored by Michael Krufky's avatar Michael Krufky Committed by Mauro Carvalho Chehab

V4L/DVB (5719): Tuner: Move device-specific private data out of tuner struct

Create private data struct for device specific private data.
Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 56584c9e
...@@ -37,6 +37,11 @@ static char *microtune_part[] = { ...@@ -37,6 +37,11 @@ static char *microtune_part[] = {
[ MT2050 ] = "MT2050", [ MT2050 ] = "MT2050",
}; };
struct microtune_priv {
unsigned int xogc;
unsigned int radio_if2;
};
// IsSpurInBand()? // IsSpurInBand()?
static int mt2032_spurcheck(struct i2c_client *c, static int mt2032_spurcheck(struct i2c_client *c,
int f1, int f2, int spectrum_from,int spectrum_to) int f1, int f2, int spectrum_from,int spectrum_to)
...@@ -218,6 +223,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin, ...@@ -218,6 +223,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
unsigned char buf[21]; unsigned char buf[21];
int lint_try,ret,sel,lock=0; int lint_try,ret,sel,lock=0;
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct microtune_priv *priv = t->priv;
tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n", tuner_dbg("mt2032_set_if_freq rfin=%d if1=%d if2=%d from=%d to=%d\n",
rfin,if1,if2,from,to); rfin,if1,if2,from,to);
...@@ -227,7 +233,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin, ...@@ -227,7 +233,7 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
i2c_master_recv(c,buf,21); i2c_master_recv(c,buf,21);
buf[0]=0; buf[0]=0;
ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,t->xogc); ret=mt2032_compute_freq(c,rfin,if1,if2,from,to,&buf[1],&sel,priv->xogc);
if (ret<0) if (ret<0)
return; return;
...@@ -251,10 +257,10 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin, ...@@ -251,10 +257,10 @@ static void mt2032_set_if_freq(struct i2c_client *c, unsigned int rfin,
tuner_dbg("mt2032: re-init PLLs by LINT\n"); tuner_dbg("mt2032: re-init PLLs by LINT\n");
buf[0]=7; buf[0]=7;
buf[1]=0x80 +8+t->xogc; // set LINT to re-init PLLs buf[1]=0x80 +8+priv->xogc; // set LINT to re-init PLLs
i2c_master_send(c,buf,2); i2c_master_send(c,buf,2);
mdelay(10); mdelay(10);
buf[1]=8+t->xogc; buf[1]=8+priv->xogc;
i2c_master_send(c,buf,2); i2c_master_send(c,buf,2);
} }
...@@ -294,7 +300,8 @@ static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -294,7 +300,8 @@ static void mt2032_set_tv_freq(struct i2c_client *c, unsigned int freq)
static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq) static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
int if2 = t->radio_if2; struct microtune_priv *priv = t->priv;
int if2 = priv->radio_if2;
// per Manual for FM tuning: first if center freq. 1085 MHz // per Manual for FM tuning: first if center freq. 1085 MHz
mt2032_set_if_freq(c, freq * 1000 / 16, mt2032_set_if_freq(c, freq * 1000 / 16,
...@@ -305,6 +312,7 @@ static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq) ...@@ -305,6 +312,7 @@ static void mt2032_set_radio_freq(struct i2c_client *c, unsigned int freq)
static int mt2032_init(struct i2c_client *c) static int mt2032_init(struct i2c_client *c)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct microtune_priv *priv = t->priv;
unsigned char buf[21]; unsigned char buf[21];
int ret,xogc,xok=0; int ret,xogc,xok=0;
...@@ -351,7 +359,7 @@ static int mt2032_init(struct i2c_client *c) ...@@ -351,7 +359,7 @@ static int mt2032_init(struct i2c_client *c)
if (ret!=2) if (ret!=2)
tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret); tuner_warn("i2c i/o error: rc == %d (should be 2)\n",ret);
} while (xok != 1 ); } while (xok != 1 );
t->xogc=xogc; priv->xogc=xogc;
t->set_tv_freq = mt2032_set_tv_freq; t->set_tv_freq = mt2032_set_tv_freq;
t->set_radio_freq = mt2032_set_radio_freq; t->set_radio_freq = mt2032_set_radio_freq;
...@@ -456,7 +464,8 @@ static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq) ...@@ -456,7 +464,8 @@ static void mt2050_set_tv_freq(struct i2c_client *c, unsigned int freq)
static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq) static void mt2050_set_radio_freq(struct i2c_client *c, unsigned int freq)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
int if2 = t->radio_if2; struct microtune_priv *priv = t->priv;
int if2 = priv->radio_if2;
mt2050_set_if_freq(c, freq * 1000 / 16, if2); mt2050_set_if_freq(c, freq * 1000 / 16, if2);
mt2050_set_antenna(c, radio_antenna); mt2050_set_antenna(c, radio_antenna);
...@@ -488,21 +497,29 @@ static int mt2050_init(struct i2c_client *c) ...@@ -488,21 +497,29 @@ static int mt2050_init(struct i2c_client *c)
int microtune_init(struct i2c_client *c) int microtune_init(struct i2c_client *c)
{ {
struct microtune_priv *priv = NULL;
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
char *name; char *name;
unsigned char buf[21]; unsigned char buf[21];
int company_code; int company_code;
priv = kzalloc(sizeof(struct microtune_priv), GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
t->priv = priv;
priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
memset(buf,0,sizeof(buf)); memset(buf,0,sizeof(buf));
t->set_tv_freq = NULL; t->set_tv_freq = NULL;
t->set_radio_freq = NULL; t->set_radio_freq = NULL;
t->standby = NULL; t->standby = NULL;
if (t->std & V4L2_STD_525_60) { if (t->std & V4L2_STD_525_60) {
tuner_dbg("pinnacle ntsc\n"); tuner_dbg("pinnacle ntsc\n");
t->radio_if2 = 41300 * 1000; priv->radio_if2 = 41300 * 1000;
} else { } else {
tuner_dbg("pinnacle pal\n"); tuner_dbg("pinnacle pal\n");
t->radio_if2 = 33300 * 1000; priv->radio_if2 = 33300 * 1000;
} }
name = "unknown"; name = "unknown";
......
...@@ -25,6 +25,16 @@ ...@@ -25,6 +25,16 @@
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
struct tda8290_priv {
unsigned char tda8290_easy_mode;
unsigned char tda827x_lpsel;
unsigned char tda827x_addr;
unsigned char tda827x_ver;
unsigned int sgIF;
};
/* ---------------------------------------------------------------------- */
struct tda827x_data { struct tda827x_data {
u32 lomax; u32 lomax;
u8 spd; u8 spd;
...@@ -76,7 +86,8 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -76,7 +86,8 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
u32 N; u32 N;
int i; int i;
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0}; struct tda8290_priv *priv = t->priv;
struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags = 0};
if (t->mode == V4L2_TUNER_RADIO) if (t->mode == V4L2_TUNER_RADIO)
freq = freq / 1000; freq = freq / 1000;
...@@ -95,7 +106,7 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -95,7 +106,7 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
tuner_reg[1] = (unsigned char)(N>>8); tuner_reg[1] = (unsigned char)(N>>8);
tuner_reg[2] = (unsigned char) N; tuner_reg[2] = (unsigned char) N;
tuner_reg[3] = 0x40; tuner_reg[3] = 0x40;
tuner_reg[4] = 0x52 + (t->tda827x_lpsel << 5); tuner_reg[4] = 0x52 + (priv->tda827x_lpsel << 5);
tuner_reg[5] = (tda827x_analog[i].spd << 6) + (tda827x_analog[i].div1p5 <<5) + tuner_reg[5] = (tda827x_analog[i].spd << 6) + (tda827x_analog[i].div1p5 <<5) +
(tda827x_analog[i].bs <<3) + tda827x_analog[i].bp; (tda827x_analog[i].bs <<3) + tda827x_analog[i].bp;
tuner_reg[6] = 0x8f + (tda827x_analog[i].gc3 << 4); tuner_reg[6] = 0x8f + (tda827x_analog[i].gc3 << 4);
...@@ -146,8 +157,9 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -146,8 +157,9 @@ static void tda827x_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
static void tda827x_agcf(struct i2c_client *c) static void tda827x_agcf(struct i2c_client *c)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct tda8290_priv *priv = t->priv;
unsigned char data[] = {0x80, 0x0c}; unsigned char data[] = {0x80, 0x0c};
struct i2c_msg msg = {.addr = t->tda827x_addr, .buf = data, struct i2c_msg msg = {.addr = priv->tda827x_addr, .buf = data,
.flags = 0, .len = 2}; .flags = 0, .len = 2};
i2c_transfer(c->adapter, &msg, 1); i2c_transfer(c->adapter, &msg, 1);
} }
...@@ -234,7 +246,8 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -234,7 +246,8 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
u32 N; u32 N;
int i; int i;
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct i2c_msg msg = {.addr = t->tda827x_addr, .flags = 0, .buf = tuner_reg}; struct tda8290_priv *priv = t->priv;
struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags = 0, .buf = tuner_reg};
tda827xa_lna_gain( c, 1); tda827xa_lna_gain( c, 1);
msleep(10); msleep(10);
...@@ -271,7 +284,7 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -271,7 +284,7 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
tuner_reg[1] = 0xff; tuner_reg[1] = 0xff;
tuner_reg[2] = 0xe0; tuner_reg[2] = 0xe0;
tuner_reg[3] = 0; tuner_reg[3] = 0;
tuner_reg[4] = 0x99 + (t->tda827x_lpsel << 1); tuner_reg[4] = 0x99 + (priv->tda827x_lpsel << 1);
msg.len = 5; msg.len = 5;
i2c_transfer(c->adapter, &msg, 1); i2c_transfer(c->adapter, &msg, 1);
...@@ -311,15 +324,16 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -311,15 +324,16 @@ static void tda827xa_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
i2c_transfer(c->adapter, &msg, 1); i2c_transfer(c->adapter, &msg, 1);
tuner_reg[0] = 0xc0; tuner_reg[0] = 0xc0;
tuner_reg[1] = 0x19 + (t->tda827x_lpsel << 1); tuner_reg[1] = 0x19 + (priv->tda827x_lpsel << 1);
i2c_transfer(c->adapter, &msg, 1); i2c_transfer(c->adapter, &msg, 1);
} }
static void tda827xa_agcf(struct i2c_client *c) static void tda827xa_agcf(struct i2c_client *c)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct tda8290_priv *priv = t->priv;
unsigned char data[] = {0x80, 0x2c}; unsigned char data[] = {0x80, 0x2c};
struct i2c_msg msg = {.addr = t->tda827x_addr, .buf = data, struct i2c_msg msg = {.addr = priv->tda827x_addr, .buf = data,
.flags = 0, .len = 2}; .flags = 0, .len = 2};
i2c_transfer(c->adapter, &msg, 1); i2c_transfer(c->adapter, &msg, 1);
} }
...@@ -347,8 +361,9 @@ static void tda8290_i2c_bridge(struct i2c_client *c, int close) ...@@ -347,8 +361,9 @@ static void tda8290_i2c_bridge(struct i2c_client *c, int close)
static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq) static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct tda8290_priv *priv = t->priv;
unsigned char soft_reset[] = { 0x00, 0x00 }; unsigned char soft_reset[] = { 0x00, 0x00 };
unsigned char easy_mode[] = { 0x01, t->tda8290_easy_mode }; unsigned char easy_mode[] = { 0x01, priv->tda8290_easy_mode };
unsigned char expert_mode[] = { 0x01, 0x80 }; unsigned char expert_mode[] = { 0x01, 0x80 };
unsigned char agc_out_on[] = { 0x02, 0x00 }; unsigned char agc_out_on[] = { 0x02, 0x00 };
unsigned char gainset_off[] = { 0x28, 0x14 }; unsigned char gainset_off[] = { 0x28, 0x14 };
...@@ -375,18 +390,18 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -375,18 +390,18 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
i2c_master_send(c, soft_reset, 2); i2c_master_send(c, soft_reset, 2);
msleep(1); msleep(1);
expert_mode[1] = t->tda8290_easy_mode + 0x80; expert_mode[1] = priv->tda8290_easy_mode + 0x80;
i2c_master_send(c, expert_mode, 2); i2c_master_send(c, expert_mode, 2);
i2c_master_send(c, gainset_off, 2); i2c_master_send(c, gainset_off, 2);
i2c_master_send(c, if_agc_spd, 2); i2c_master_send(c, if_agc_spd, 2);
if (t->tda8290_easy_mode & 0x60) if (priv->tda8290_easy_mode & 0x60)
i2c_master_send(c, adc_head_9, 2); i2c_master_send(c, adc_head_9, 2);
else else
i2c_master_send(c, adc_head_6, 2); i2c_master_send(c, adc_head_6, 2);
i2c_master_send(c, pll_bw_nom, 2); i2c_master_send(c, pll_bw_nom, 2);
tda8290_i2c_bridge(c, 1); tda8290_i2c_bridge(c, 1);
if (t->tda827x_ver != 0) if (priv->tda827x_ver != 0)
tda827xa_tune(c, ifc, freq); tda827xa_tune(c, ifc, freq);
else else
tda827x_tune(c, ifc, freq); tda827x_tune(c, ifc, freq);
...@@ -418,7 +433,7 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -418,7 +433,7 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
if ((agc_stat > 115) || !(pll_stat & 0x80)) { if ((agc_stat > 115) || !(pll_stat & 0x80)) {
tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n", tuner_dbg("adjust gain, step 2. Agc: %d, lock: %d\n",
agc_stat, pll_stat & 0x80); agc_stat, pll_stat & 0x80);
if (t->tda827x_ver != 0) if (priv->tda827x_ver != 0)
tda827xa_agcf(c); tda827xa_agcf(c);
else else
tda827x_agcf(c); tda827x_agcf(c);
...@@ -437,7 +452,7 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -437,7 +452,7 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
} }
/* l/ l' deadlock? */ /* l/ l' deadlock? */
if(t->tda8290_easy_mode & 0x60) { if(priv->tda8290_easy_mode & 0x60) {
i2c_master_send(c, &addr_adc_sat, 1); i2c_master_send(c, &addr_adc_sat, 1);
i2c_master_recv(c, &adc_sat, 1); i2c_master_recv(c, &adc_sat, 1);
i2c_master_send(c, &addr_pll_stat, 1); i2c_master_send(c, &addr_pll_stat, 1);
...@@ -459,41 +474,42 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq) ...@@ -459,41 +474,42 @@ static int tda8290_tune(struct i2c_client *c, u16 ifc, unsigned int freq)
static void set_audio(struct tuner *t) static void set_audio(struct tuner *t)
{ {
struct tda8290_priv *priv = t->priv;
char* mode; char* mode;
t->tda827x_lpsel = 0; priv->tda827x_lpsel = 0;
if (t->std & V4L2_STD_MN) { if (t->std & V4L2_STD_MN) {
t->sgIF = 92; priv->sgIF = 92;
t->tda8290_easy_mode = 0x01; priv->tda8290_easy_mode = 0x01;
t->tda827x_lpsel = 1; priv->tda827x_lpsel = 1;
mode = "MN"; mode = "MN";
} else if (t->std & V4L2_STD_B) { } else if (t->std & V4L2_STD_B) {
t->sgIF = 108; priv->sgIF = 108;
t->tda8290_easy_mode = 0x02; priv->tda8290_easy_mode = 0x02;
mode = "B"; mode = "B";
} else if (t->std & V4L2_STD_GH) { } else if (t->std & V4L2_STD_GH) {
t->sgIF = 124; priv->sgIF = 124;
t->tda8290_easy_mode = 0x04; priv->tda8290_easy_mode = 0x04;
mode = "GH"; mode = "GH";
} else if (t->std & V4L2_STD_PAL_I) { } else if (t->std & V4L2_STD_PAL_I) {
t->sgIF = 124; priv->sgIF = 124;
t->tda8290_easy_mode = 0x08; priv->tda8290_easy_mode = 0x08;
mode = "I"; mode = "I";
} else if (t->std & V4L2_STD_DK) { } else if (t->std & V4L2_STD_DK) {
t->sgIF = 124; priv->sgIF = 124;
t->tda8290_easy_mode = 0x10; priv->tda8290_easy_mode = 0x10;
mode = "DK"; mode = "DK";
} else if (t->std & V4L2_STD_SECAM_L) { } else if (t->std & V4L2_STD_SECAM_L) {
t->sgIF = 124; priv->sgIF = 124;
t->tda8290_easy_mode = 0x20; priv->tda8290_easy_mode = 0x20;
mode = "L"; mode = "L";
} else if (t->std & V4L2_STD_SECAM_LC) { } else if (t->std & V4L2_STD_SECAM_LC) {
t->sgIF = 20; priv->sgIF = 20;
t->tda8290_easy_mode = 0x40; priv->tda8290_easy_mode = 0x40;
mode = "LC"; mode = "LC";
} else { } else {
t->sgIF = 124; priv->sgIF = 124;
t->tda8290_easy_mode = 0x10; priv->tda8290_easy_mode = 0x10;
mode = "xx"; mode = "xx";
} }
tuner_dbg("setting tda8290 to system %s\n", mode); tuner_dbg("setting tda8290 to system %s\n", mode);
...@@ -502,9 +518,10 @@ static void set_audio(struct tuner *t) ...@@ -502,9 +518,10 @@ static void set_audio(struct tuner *t)
static void set_tv_freq(struct i2c_client *c, unsigned int freq) static void set_tv_freq(struct i2c_client *c, unsigned int freq)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct tda8290_priv *priv = t->priv;
set_audio(t); set_audio(t);
tda8290_tune(c, t->sgIF, freq); tda8290_tune(c, priv->sgIF, freq);
} }
static void set_radio_freq(struct i2c_client *c, unsigned int freq) static void set_radio_freq(struct i2c_client *c, unsigned int freq)
...@@ -528,13 +545,14 @@ static int has_signal(struct i2c_client *c) ...@@ -528,13 +545,14 @@ static int has_signal(struct i2c_client *c)
static void standby(struct i2c_client *c) static void standby(struct i2c_client *c)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct tda8290_priv *priv = t->priv;
unsigned char cb1[] = { 0x30, 0xD0 }; unsigned char cb1[] = { 0x30, 0xD0 };
unsigned char tda8290_standby[] = { 0x00, 0x02 }; unsigned char tda8290_standby[] = { 0x00, 0x02 };
unsigned char tda8290_agc_tri[] = { 0x02, 0x20 }; unsigned char tda8290_agc_tri[] = { 0x02, 0x20 };
struct i2c_msg msg = {.addr = t->tda827x_addr, .flags=0, .buf=cb1, .len = 2}; struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0, .buf=cb1, .len = 2};
tda8290_i2c_bridge(c, 1); tda8290_i2c_bridge(c, 1);
if (t->tda827x_ver != 0) if (priv->tda827x_ver != 0)
cb1[1] = 0x90; cb1[1] = 0x90;
i2c_transfer(c->adapter, &msg, 1); i2c_transfer(c->adapter, &msg, 1);
tda8290_i2c_bridge(c, 0); tda8290_i2c_bridge(c, 0);
...@@ -560,13 +578,14 @@ static void tda8290_init_if(struct i2c_client *c) ...@@ -560,13 +578,14 @@ static void tda8290_init_if(struct i2c_client *c)
static void tda8290_init_tuner(struct i2c_client *c) static void tda8290_init_tuner(struct i2c_client *c)
{ {
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
struct tda8290_priv *priv = t->priv;
unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf, unsigned char tda8275_init[] = { 0x00, 0x00, 0x00, 0x40, 0xdC, 0x04, 0xAf,
0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 }; 0x3F, 0x2A, 0x04, 0xFF, 0x00, 0x00, 0x40 };
unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b, unsigned char tda8275a_init[] = { 0x00, 0x00, 0x00, 0x00, 0xdC, 0x05, 0x8b,
0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b }; 0x0c, 0x04, 0x20, 0xFF, 0x00, 0x00, 0x4b };
struct i2c_msg msg = {.addr = t->tda827x_addr, .flags=0, struct i2c_msg msg = {.addr = priv->tda827x_addr, .flags=0,
.buf=tda8275_init, .len = 14}; .buf=tda8275_init, .len = 14};
if (t->tda827x_ver != 0) if (priv->tda827x_ver != 0)
msg.buf = tda8275a_init; msg.buf = tda8275a_init;
tda8290_i2c_bridge(c, 1); tda8290_i2c_bridge(c, 1);
...@@ -578,12 +597,18 @@ static void tda8290_init_tuner(struct i2c_client *c) ...@@ -578,12 +597,18 @@ static void tda8290_init_tuner(struct i2c_client *c)
int tda8290_init(struct i2c_client *c) int tda8290_init(struct i2c_client *c)
{ {
struct tda8290_priv *priv = NULL;
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
u8 data; u8 data;
int i, ret, tuners_found; int i, ret, tuners_found;
u32 tuner_addrs; u32 tuner_addrs;
struct i2c_msg msg = {.flags=I2C_M_RD, .buf=&data, .len = 1}; struct i2c_msg msg = {.flags=I2C_M_RD, .buf=&data, .len = 1};
priv = kzalloc(sizeof(struct tda8290_priv), GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
t->priv = priv;
tda8290_i2c_bridge(c, 1); tda8290_i2c_bridge(c, 1);
/* probe for tuner chip */ /* probe for tuner chip */
tuners_found = 0; tuners_found = 0;
...@@ -618,7 +643,7 @@ int tda8290_init(struct i2c_client *c) ...@@ -618,7 +643,7 @@ int tda8290_init(struct i2c_client *c)
tuner_addrs = tuner_addrs & 0xff; tuner_addrs = tuner_addrs & 0xff;
tuner_info ("setting tuner address to %x\n", tuner_addrs); tuner_info ("setting tuner address to %x\n", tuner_addrs);
} }
t->tda827x_addr = tuner_addrs; priv->tda827x_addr = tuner_addrs;
msg.addr = tuner_addrs; msg.addr = tuner_addrs;
tda8290_i2c_bridge(c, 1); tda8290_i2c_bridge(c, 1);
...@@ -627,10 +652,10 @@ int tda8290_init(struct i2c_client *c) ...@@ -627,10 +652,10 @@ int tda8290_init(struct i2c_client *c)
tuner_warn ("TDA827x access failed!\n"); tuner_warn ("TDA827x access failed!\n");
if ((data & 0x3c) == 0) { if ((data & 0x3c) == 0) {
strlcpy(c->name, "tda8290+75", sizeof(c->name)); strlcpy(c->name, "tda8290+75", sizeof(c->name));
t->tda827x_ver = 0; priv->tda827x_ver = 0;
} else { } else {
strlcpy(c->name, "tda8290+75a", sizeof(c->name)); strlcpy(c->name, "tda8290+75a", sizeof(c->name));
t->tda827x_ver = 2; priv->tda827x_ver = 2;
} }
tuner_info("type set to %s\n", c->name); tuner_info("type set to %s\n", c->name);
...@@ -638,7 +663,7 @@ int tda8290_init(struct i2c_client *c) ...@@ -638,7 +663,7 @@ int tda8290_init(struct i2c_client *c)
t->set_radio_freq = set_radio_freq; t->set_radio_freq = set_radio_freq;
t->has_signal = has_signal; t->has_signal = has_signal;
t->standby = standby; t->standby = standby;
t->tda827x_lpsel = 0; priv->tda827x_lpsel = 0;
t->mode = V4L2_TUNER_ANALOG_TV; t->mode = V4L2_TUNER_ANALOG_TV;
tda8290_init_tuner(c); tda8290_init_tuner(c);
......
...@@ -29,6 +29,9 @@ ...@@ -29,6 +29,9 @@
printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \ printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.name, \
i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0)
struct tda9887_priv {
unsigned char data[4];
};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
...@@ -508,10 +511,11 @@ static int tda9887_status(struct tuner *t) ...@@ -508,10 +511,11 @@ static int tda9887_status(struct tuner *t)
static void tda9887_configure(struct i2c_client *client) static void tda9887_configure(struct i2c_client *client)
{ {
struct tuner *t = i2c_get_clientdata(client); struct tuner *t = i2c_get_clientdata(client);
struct tda9887_priv *priv = t->priv;
int rc; int rc;
memset(t->tda9887_data,0,sizeof(t->tda9887_data)); memset(priv->data,0,sizeof(priv->data));
tda9887_set_tvnorm(t,t->tda9887_data); tda9887_set_tvnorm(t,priv->data);
/* A note on the port settings: /* A note on the port settings:
These settings tend to depend on the specifics of the board. These settings tend to depend on the specifics of the board.
...@@ -526,22 +530,22 @@ static void tda9887_configure(struct i2c_client *client) ...@@ -526,22 +530,22 @@ static void tda9887_configure(struct i2c_client *client)
the ports should be set to active (0), but, again, that may the ports should be set to active (0), but, again, that may
differ depending on the precise hardware configuration. differ depending on the precise hardware configuration.
*/ */
t->tda9887_data[1] |= cOutputPort1Inactive; priv->data[1] |= cOutputPort1Inactive;
t->tda9887_data[1] |= cOutputPort2Inactive; priv->data[1] |= cOutputPort2Inactive;
tda9887_set_config(t,t->tda9887_data); tda9887_set_config(t,priv->data);
tda9887_set_insmod(t,t->tda9887_data); tda9887_set_insmod(t,priv->data);
if (t->mode == T_STANDBY) { if (t->mode == T_STANDBY) {
t->tda9887_data[1] |= cForcedMuteAudioON; priv->data[1] |= cForcedMuteAudioON;
} }
tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n", tda9887_dbg("writing: b=0x%02x c=0x%02x e=0x%02x\n",
t->tda9887_data[1],t->tda9887_data[2],t->tda9887_data[3]); priv->data[1],priv->data[2],priv->data[3]);
if (tuner_debug > 1) if (tuner_debug > 1)
dump_write_message(t, t->tda9887_data); dump_write_message(t, priv->data);
if (4 != (rc = i2c_master_send(&t->i2c,t->tda9887_data,4))) if (4 != (rc = i2c_master_send(&t->i2c,priv->data,4)))
tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc); tda9887_info("i2c i/o error: rc == %d (should be 4)\n",rc);
if (tuner_debug > 2) { if (tuner_debug > 2) {
...@@ -555,7 +559,8 @@ static void tda9887_configure(struct i2c_client *client) ...@@ -555,7 +559,8 @@ static void tda9887_configure(struct i2c_client *client)
static void tda9887_tuner_status(struct i2c_client *client) static void tda9887_tuner_status(struct i2c_client *client)
{ {
struct tuner *t = i2c_get_clientdata(client); struct tuner *t = i2c_get_clientdata(client);
tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", t->tda9887_data[1], t->tda9887_data[2], t->tda9887_data[3]); struct tda9887_priv *priv = t->priv;
tda9887_info("Data bytes: b=0x%02x c=0x%02x e=0x%02x\n", priv->data[1], priv->data[2], priv->data[3]);
} }
static int tda9887_get_afc(struct i2c_client *client) static int tda9887_get_afc(struct i2c_client *client)
...@@ -588,8 +593,14 @@ static void tda9887_set_freq(struct i2c_client *client, unsigned int freq) ...@@ -588,8 +593,14 @@ static void tda9887_set_freq(struct i2c_client *client, unsigned int freq)
int tda9887_tuner_init(struct i2c_client *c) int tda9887_tuner_init(struct i2c_client *c)
{ {
struct tda9887_priv *priv = NULL;
struct tuner *t = i2c_get_clientdata(c); struct tuner *t = i2c_get_clientdata(c);
priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL);
if (priv == NULL)
return -ENOMEM;
t->priv = priv;
strlcpy(c->name, "tda9887", sizeof(c->name)); strlcpy(c->name, "tda9887", sizeof(c->name));
tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr,
......
...@@ -177,6 +177,9 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -177,6 +177,9 @@ static void set_type(struct i2c_client *c, unsigned int type,
return; return;
} }
/* discard private data, in case set_type() was previously called */
kfree(t->priv);
t->priv = NULL;
switch (t->type) { switch (t->type) {
case TUNER_MT2032: case TUNER_MT2032:
microtune_init(c); microtune_init(c);
...@@ -450,7 +453,6 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -450,7 +453,6 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
memcpy(&t->i2c, &client_template, sizeof(struct i2c_client)); memcpy(&t->i2c, &client_template, sizeof(struct i2c_client));
i2c_set_clientdata(&t->i2c, t); i2c_set_clientdata(&t->i2c, t);
t->type = UNSET; t->type = UNSET;
t->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */
t->audmode = V4L2_TUNER_MODE_STEREO; t->audmode = V4L2_TUNER_MODE_STEREO;
t->mode_mask = T_UNINITIALIZED; t->mode_mask = T_UNINITIALIZED;
t->tuner_status = tuner_status; t->tuner_status = tuner_status;
...@@ -559,6 +561,7 @@ static int tuner_detach(struct i2c_client *client) ...@@ -559,6 +561,7 @@ static int tuner_detach(struct i2c_client *client)
return err; return err;
} }
kfree(t->priv);
kfree(t); kfree(t);
return 0; return 0;
} }
......
...@@ -199,21 +199,10 @@ struct tuner { ...@@ -199,21 +199,10 @@ struct tuner {
v4l2_std_id std; v4l2_std_id std;
int using_v4l2; int using_v4l2;
void *priv;
/* used by tda9887 */ /* used by tda9887 */
unsigned int tda9887_config; unsigned int tda9887_config;
unsigned char tda9887_data[4];
/* used by MT2032 */
unsigned int xogc;
unsigned int radio_if2;
/* used by tda8290 */
unsigned char tda8290_easy_mode;
unsigned char tda827x_lpsel;
unsigned char tda827x_addr;
unsigned char tda827x_ver;
unsigned int sgIF;
unsigned int config; unsigned int config;
int (*tuner_callback) (void *dev, int command,int arg); int (*tuner_callback) (void *dev, int command,int arg);
......
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