aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-12-08 15:06:30 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:27 -0500
commitc7919d520f4c9a064ae14bc4dd170c4c12ead2af (patch)
treea7cbff8f2a09c710942783a84cb44098ed1507d8 /drivers
parent6881647cce09931f3d787ab83b5250436427ceb9 (diff)
V4L/DVB (6783): tuner: combine set_tv_freq and set_radio_freq into a single set_params method
We can tell whether we are tuning television or radio by testing for struct analog_parameters *params->mode == V4L2_TUNER_RADIO There is no longer any need for separate set_tv_freq and set_radio_freq functions in the analog tuner demodulator modules. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/tda8290.c53
-rw-r--r--drivers/media/video/tda9887.c6
-rw-r--r--drivers/media/video/tuner-core.c41
-rw-r--r--drivers/media/video/tuner-driver.h4
4 files changed, 49 insertions, 55 deletions
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index d5517bcf6ffe..245b202560b5 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -110,31 +110,32 @@ static int tda8295_i2c_bridge(struct dvb_frontend *fe, int close)
110 110
111/*---------------------------------------------------------------------*/ 111/*---------------------------------------------------------------------*/
112 112
113static void set_audio(struct dvb_frontend *fe) 113static void set_audio(struct dvb_frontend *fe,
114 struct analog_parameters *params)
114{ 115{
115 struct tda8290_priv *priv = fe->analog_demod_priv; 116 struct tda8290_priv *priv = fe->analog_demod_priv;
116 struct tuner *t = priv->t; 117 struct tuner *t = priv->t;
117 char* mode; 118 char* mode;
118 119
119 if (t->std & V4L2_STD_MN) { 120 if (params->std & V4L2_STD_MN) {
120 priv->tda8290_easy_mode = 0x01; 121 priv->tda8290_easy_mode = 0x01;
121 mode = "MN"; 122 mode = "MN";
122 } else if (t->std & V4L2_STD_B) { 123 } else if (params->std & V4L2_STD_B) {
123 priv->tda8290_easy_mode = 0x02; 124 priv->tda8290_easy_mode = 0x02;
124 mode = "B"; 125 mode = "B";
125 } else if (t->std & V4L2_STD_GH) { 126 } else if (params->std & V4L2_STD_GH) {
126 priv->tda8290_easy_mode = 0x04; 127 priv->tda8290_easy_mode = 0x04;
127 mode = "GH"; 128 mode = "GH";
128 } else if (t->std & V4L2_STD_PAL_I) { 129 } else if (params->std & V4L2_STD_PAL_I) {
129 priv->tda8290_easy_mode = 0x08; 130 priv->tda8290_easy_mode = 0x08;
130 mode = "I"; 131 mode = "I";
131 } else if (t->std & V4L2_STD_DK) { 132 } else if (params->std & V4L2_STD_DK) {
132 priv->tda8290_easy_mode = 0x10; 133 priv->tda8290_easy_mode = 0x10;
133 mode = "DK"; 134 mode = "DK";
134 } else if (t->std & V4L2_STD_SECAM_L) { 135 } else if (params->std & V4L2_STD_SECAM_L) {
135 priv->tda8290_easy_mode = 0x20; 136 priv->tda8290_easy_mode = 0x20;
136 mode = "L"; 137 mode = "L";
137 } else if (t->std & V4L2_STD_SECAM_LC) { 138 } else if (params->std & V4L2_STD_SECAM_LC) {
138 priv->tda8290_easy_mode = 0x40; 139 priv->tda8290_easy_mode = 0x40;
139 mode = "LC"; 140 mode = "LC";
140 } else { 141 } else {
@@ -145,7 +146,8 @@ static void set_audio(struct dvb_frontend *fe)
145 tuner_dbg("setting tda829x to system %s\n", mode); 146 tuner_dbg("setting tda829x to system %s\n", mode);
146} 147}
147 148
148static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq) 149static void tda8290_set_params(struct dvb_frontend *fe,
150 struct analog_parameters *params)
149{ 151{
150 struct tda8290_priv *priv = fe->analog_demod_priv; 152 struct tda8290_priv *priv = fe->analog_demod_priv;
151 struct tuner *t = priv->t; 153 struct tuner *t = priv->t;
@@ -172,14 +174,7 @@ static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq)
172 pll_stat; 174 pll_stat;
173 int i; 175 int i;
174 176
175 struct analog_parameters params = { 177 set_audio(fe, params);
176 .frequency = freq,
177 .mode = t->mode,
178 .audmode = t->audmode,
179 .std = t->std
180 };
181
182 set_audio(fe);
183 178
184 tuner_dbg("tda827xa config is 0x%02x\n", t->config); 179 tuner_dbg("tda827xa config is 0x%02x\n", t->config);
185 tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); 180 tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2);
@@ -200,7 +195,7 @@ static void tda8290_set_freq(struct dvb_frontend *fe, unsigned int freq)
200 tda8290_i2c_bridge(fe, 1); 195 tda8290_i2c_bridge(fe, 1);
201 196
202 if (fe->ops.tuner_ops.set_analog_params) 197 if (fe->ops.tuner_ops.set_analog_params)
203 fe->ops.tuner_ops.set_analog_params(fe, &params); 198 fe->ops.tuner_ops.set_analog_params(fe, params);
204 199
205 for (i = 0; i < 3; i++) { 200 for (i = 0; i < 3; i++) {
206 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1); 201 tuner_i2c_xfer_send(&priv->i2c_props, &addr_pll_stat, 1);
@@ -363,23 +358,17 @@ static int tda8295_has_signal(struct dvb_frontend *fe)
363 358
364/*---------------------------------------------------------------------*/ 359/*---------------------------------------------------------------------*/
365 360
366static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq) 361static void tda8295_set_params(struct dvb_frontend *fe,
362 struct analog_parameters *params)
367{ 363{
368 struct tda8290_priv *priv = fe->analog_demod_priv; 364 struct tda8290_priv *priv = fe->analog_demod_priv;
369 struct tuner *t = priv->t; 365 struct tuner *t = priv->t;
370 366
371 unsigned char blanking_mode[] = { 0x1d, 0x00 }; 367 unsigned char blanking_mode[] = { 0x1d, 0x00 };
372 368
373 struct analog_parameters params = { 369 set_audio(fe, params);
374 .frequency = freq,
375 .mode = t->mode,
376 .audmode = t->audmode,
377 .std = t->std
378 };
379
380 set_audio(fe);
381 370
382 tuner_dbg("%s: freq = %d\n", __FUNCTION__, freq); 371 tuner_dbg("%s: freq = %d\n", __FUNCTION__, params->frequency);
383 372
384 tda8295_power(fe, 1); 373 tda8295_power(fe, 1);
385 tda8295_agc1_out(fe, 1); 374 tda8295_agc1_out(fe, 1);
@@ -396,7 +385,7 @@ static void tda8295_set_freq(struct dvb_frontend *fe, unsigned int freq)
396 tda8295_i2c_bridge(fe, 1); 385 tda8295_i2c_bridge(fe, 1);
397 386
398 if (fe->ops.tuner_ops.set_analog_params) 387 if (fe->ops.tuner_ops.set_analog_params)
399 fe->ops.tuner_ops.set_analog_params(fe, &params); 388 fe->ops.tuner_ops.set_analog_params(fe, params);
400 389
401 if (priv->cfg.agcf) 390 if (priv->cfg.agcf)
402 priv->cfg.agcf(fe); 391 priv->cfg.agcf(fe);
@@ -673,8 +662,7 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props)
673} 662}
674 663
675static struct analog_tuner_ops tda8290_tuner_ops = { 664static struct analog_tuner_ops tda8290_tuner_ops = {
676 .set_tv_freq = tda8290_set_freq, 665 .set_params = tda8290_set_params,
677 .set_radio_freq = tda8290_set_freq,
678 .has_signal = tda8290_has_signal, 666 .has_signal = tda8290_has_signal,
679 .standby = tda8290_standby, 667 .standby = tda8290_standby,
680 .release = tda829x_release, 668 .release = tda829x_release,
@@ -682,8 +670,7 @@ static struct analog_tuner_ops tda8290_tuner_ops = {
682}; 670};
683 671
684static struct analog_tuner_ops tda8295_tuner_ops = { 672static struct analog_tuner_ops tda8295_tuner_ops = {
685 .set_tv_freq = tda8295_set_freq, 673 .set_params = tda8295_set_params,
686 .set_radio_freq = tda8295_set_freq,
687 .has_signal = tda8295_has_signal, 674 .has_signal = tda8295_has_signal,
688 .standby = tda8295_standby, 675 .standby = tda8295_standby,
689 .release = tda829x_release, 676 .release = tda829x_release,
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index dfa2964d7ef3..d506d4bf8253 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -622,7 +622,8 @@ static void tda9887_standby(struct dvb_frontend *fe)
622 tda9887_configure(fe); 622 tda9887_configure(fe);
623} 623}
624 624
625static void tda9887_set_freq(struct dvb_frontend *fe, unsigned int freq) 625static void tda9887_set_params(struct dvb_frontend *fe,
626 struct analog_parameters *params)
626{ 627{
627 tda9887_configure(fe); 628 tda9887_configure(fe);
628} 629}
@@ -634,8 +635,7 @@ static void tda9887_release(struct dvb_frontend *fe)
634} 635}
635 636
636static struct analog_tuner_ops tda9887_tuner_ops = { 637static struct analog_tuner_ops tda9887_tuner_ops = {
637 .set_tv_freq = tda9887_set_freq, 638 .set_params = tda9887_set_params,
638 .set_radio_freq = tda9887_set_freq,
639 .standby = tda9887_standby, 639 .standby = tda9887_standby,
640 .tuner_status = tda9887_tuner_status, 640 .tuner_status = tda9887_tuner_status,
641 .get_afc = tda9887_get_afc, 641 .get_afc = tda9887_get_afc,
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index e56a41941489..5f8bffc8209b 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -78,23 +78,17 @@ MODULE_LICENSE("GPL");
78 78
79/* ---------------------------------------------------------------------- */ 79/* ---------------------------------------------------------------------- */
80 80
81static void fe_set_freq(struct dvb_frontend *fe, unsigned int freq) 81static void fe_set_params(struct dvb_frontend *fe,
82 struct analog_parameters *params)
82{ 83{
83 struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops; 84 struct dvb_tuner_ops *fe_tuner_ops = &fe->ops.tuner_ops;
84 struct tuner *t = fe->analog_demod_priv; 85 struct tuner *t = fe->analog_demod_priv;
85 86
86 struct analog_parameters params = {
87 .frequency = freq,
88 .mode = t->mode,
89 .audmode = t->audmode,
90 .std = t->std
91 };
92
93 if (NULL == fe_tuner_ops->set_analog_params) { 87 if (NULL == fe_tuner_ops->set_analog_params) {
94 tuner_warn("Tuner frontend module has no way to set freq\n"); 88 tuner_warn("Tuner frontend module has no way to set freq\n");
95 return; 89 return;
96 } 90 }
97 fe_tuner_ops->set_analog_params(fe, &params); 91 fe_tuner_ops->set_analog_params(fe, params);
98} 92}
99 93
100static void fe_release(struct dvb_frontend *fe) 94static void fe_release(struct dvb_frontend *fe)
@@ -136,8 +130,7 @@ static int fe_has_signal(struct dvb_frontend *fe)
136static void tuner_status(struct dvb_frontend *fe); 130static void tuner_status(struct dvb_frontend *fe);
137 131
138static struct analog_tuner_ops tuner_core_ops = { 132static struct analog_tuner_ops tuner_core_ops = {
139 .set_tv_freq = fe_set_freq, 133 .set_params = fe_set_params,
140 .set_radio_freq = fe_set_freq,
141 .standby = fe_standby, 134 .standby = fe_standby,
142 .release = fe_release, 135 .release = fe_release,
143 .has_signal = fe_has_signal, 136 .has_signal = fe_has_signal,
@@ -150,11 +143,17 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
150 struct tuner *t = i2c_get_clientdata(c); 143 struct tuner *t = i2c_get_clientdata(c);
151 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; 144 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
152 145
146 struct analog_parameters params = {
147 .mode = t->mode,
148 .audmode = t->audmode,
149 .std = t->std
150 };
151
153 if (t->type == UNSET) { 152 if (t->type == UNSET) {
154 tuner_warn ("tuner type not set\n"); 153 tuner_warn ("tuner type not set\n");
155 return; 154 return;
156 } 155 }
157 if ((NULL == ops) || (NULL == ops->set_tv_freq)) { 156 if ((NULL == ops) || (NULL == ops->set_params)) {
158 tuner_warn ("Tuner has no way to set tv freq\n"); 157 tuner_warn ("Tuner has no way to set tv freq\n");
159 return; 158 return;
160 } 159 }
@@ -169,7 +168,9 @@ static void set_tv_freq(struct i2c_client *c, unsigned int freq)
169 else 168 else
170 freq = tv_range[1] * 16; 169 freq = tv_range[1] * 16;
171 } 170 }
172 ops->set_tv_freq(&t->fe, freq); 171 params.frequency = freq;
172
173 ops->set_params(&t->fe, &params);
173} 174}
174 175
175static void set_radio_freq(struct i2c_client *c, unsigned int freq) 176static void set_radio_freq(struct i2c_client *c, unsigned int freq)
@@ -177,11 +178,17 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
177 struct tuner *t = i2c_get_clientdata(c); 178 struct tuner *t = i2c_get_clientdata(c);
178 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; 179 struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
179 180
181 struct analog_parameters params = {
182 .mode = t->mode,
183 .audmode = t->audmode,
184 .std = t->std
185 };
186
180 if (t->type == UNSET) { 187 if (t->type == UNSET) {
181 tuner_warn ("tuner type not set\n"); 188 tuner_warn ("tuner type not set\n");
182 return; 189 return;
183 } 190 }
184 if ((NULL == ops) || (NULL == ops->set_radio_freq)) { 191 if ((NULL == ops) || (NULL == ops->set_params)) {
185 tuner_warn ("tuner has no way to set radio frequency\n"); 192 tuner_warn ("tuner has no way to set radio frequency\n");
186 return; 193 return;
187 } 194 }
@@ -196,8 +203,9 @@ static void set_radio_freq(struct i2c_client *c, unsigned int freq)
196 else 203 else
197 freq = radio_range[1] * 16000; 204 freq = radio_range[1] * 16000;
198 } 205 }
206 params.frequency = freq;
199 207
200 ops->set_radio_freq(&t->fe, freq); 208 ops->set_params(&t->fe, &params);
201} 209}
202 210
203static void set_freq(struct i2c_client *c, unsigned long freq) 211static void set_freq(struct i2c_client *c, unsigned long freq)
@@ -359,8 +367,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
359 367
360 ops = t->fe.ops.analog_demod_ops; 368 ops = t->fe.ops.analog_demod_ops;
361 369
362 if (((NULL == ops) || 370 if (((NULL == ops) || (NULL == ops->set_params)) &&
363 ((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) &&
364 (fe_tuner_ops->set_analog_params)) { 371 (fe_tuner_ops->set_analog_params)) {
365 strlcpy(t->i2c->name, fe_tuner_ops->info.name, 372 strlcpy(t->i2c->name, fe_tuner_ops->info.name,
366 sizeof(t->i2c->name)); 373 sizeof(t->i2c->name));
diff --git a/drivers/media/video/tuner-driver.h b/drivers/media/video/tuner-driver.h
index a4db32d97a12..91913ee08a07 100644
--- a/drivers/media/video/tuner-driver.h
+++ b/drivers/media/video/tuner-driver.h
@@ -32,8 +32,8 @@ extern unsigned const int tuner_count;
32struct tuner; 32struct tuner;
33 33
34struct analog_tuner_ops { 34struct analog_tuner_ops {
35 void (*set_tv_freq)(struct dvb_frontend *fe, unsigned int freq); 35 void (*set_params)(struct dvb_frontend *fe,
36 void (*set_radio_freq)(struct dvb_frontend *fe, unsigned int freq); 36 struct analog_parameters *params);
37 int (*has_signal)(struct dvb_frontend *fe); 37 int (*has_signal)(struct dvb_frontend *fe);
38 int (*is_stereo)(struct dvb_frontend *fe); 38 int (*is_stereo)(struct dvb_frontend *fe);
39 int (*get_afc)(struct dvb_frontend *fe); 39 int (*get_afc)(struct dvb_frontend *fe);