aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tuner-simple.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-08-11 14:42:12 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-09 21:05:01 -0400
commit6b1dde90de7f612805fbe8212a39264d7b868efc (patch)
tree3c824ed8452d46701d295816a264618565058922 /drivers/media/video/tuner-simple.c
parentafa76b392e10d37c9e717198b5c2686de26c629d (diff)
V4L/DVB (6006): tuner: move last_div to tuner-simple private data
tuner-simple is the only sub-driver that uses last_div, so we can free up two bytes of memory for all other tuners, by moving this into tuner-simple's private data area. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tuner-simple.c')
-rw-r--r--drivers/media/video/tuner-simple.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index 10a7d36a2646..572f22423b98 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -82,6 +82,10 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
82#define TUNER_PLL_LOCKED 0x40 82#define TUNER_PLL_LOCKED 0x40
83#define TUNER_STEREO_MK3 0x04 83#define TUNER_STEREO_MK3 0x04
84 84
85struct tuner_simple_priv {
86 u16 last_div;
87};
88
85/* ---------------------------------------------------------------------- */ 89/* ---------------------------------------------------------------------- */
86 90
87static int tuner_getstatus(struct i2c_client *c) 91static int tuner_getstatus(struct i2c_client *c)
@@ -126,6 +130,7 @@ static int tuner_stereo(struct i2c_client *c)
126static void default_set_tv_freq(struct i2c_client *c, unsigned int freq) 130static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
127{ 131{
128 struct tuner *t = i2c_get_clientdata(c); 132 struct tuner *t = i2c_get_clientdata(c);
133 struct tuner_simple_priv *priv = t->priv;
129 u8 config, cb, tuneraddr; 134 u8 config, cb, tuneraddr;
130 u16 div; 135 u16 div;
131 struct tunertype *tun; 136 struct tunertype *tun;
@@ -291,7 +296,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
291 break; 296 break;
292 } 297 }
293 298
294 if (params->cb_first_if_lower_freq && div < t->last_div) { 299 if (params->cb_first_if_lower_freq && div < priv->last_div) {
295 buffer[0] = config; 300 buffer[0] = config;
296 buffer[1] = cb; 301 buffer[1] = cb;
297 buffer[2] = (div>>8) & 0x7f; 302 buffer[2] = (div>>8) & 0x7f;
@@ -302,7 +307,7 @@ static void default_set_tv_freq(struct i2c_client *c, unsigned int freq)
302 buffer[2] = config; 307 buffer[2] = config;
303 buffer[3] = cb; 308 buffer[3] = cb;
304 } 309 }
305 t->last_div = div; 310 priv->last_div = div;
306 if (params->has_tda9887) { 311 if (params->has_tda9887) {
307 int config = 0; 312 int config = 0;
308 int is_secam_l = (t->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) && 313 int is_secam_l = (t->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) &&
@@ -399,6 +404,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
399{ 404{
400 struct tunertype *tun; 405 struct tunertype *tun;
401 struct tuner *t = i2c_get_clientdata(c); 406 struct tuner *t = i2c_get_clientdata(c);
407 struct tuner_simple_priv *priv = t->priv;
402 u8 buffer[4]; 408 u8 buffer[4];
403 u16 div; 409 u16 div;
404 int rc, j; 410 int rc, j;
@@ -464,7 +470,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
464 freq * (1/800) */ 470 freq * (1/800) */
465 div = (freq + 400) / 800; 471 div = (freq + 400) / 800;
466 472
467 if (params->cb_first_if_lower_freq && div < t->last_div) { 473 if (params->cb_first_if_lower_freq && div < priv->last_div) {
468 buffer[0] = buffer[2]; 474 buffer[0] = buffer[2];
469 buffer[1] = buffer[3]; 475 buffer[1] = buffer[3];
470 buffer[2] = (div>>8) & 0x7f; 476 buffer[2] = (div>>8) & 0x7f;
@@ -476,7 +482,7 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
476 482
477 tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n", 483 tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
478 buffer[0],buffer[1],buffer[2],buffer[3]); 484 buffer[0],buffer[1],buffer[2],buffer[3]);
479 t->last_div = div; 485 priv->last_div = div;
480 486
481 if (params->has_tda9887) { 487 if (params->has_tda9887) {
482 int config = 0; 488 int config = 0;
@@ -498,16 +504,31 @@ static void default_set_radio_freq(struct i2c_client *c, unsigned int freq)
498 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); 504 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc);
499} 505}
500 506
507static void tuner_release(struct i2c_client *c)
508{
509 struct tuner *t = i2c_get_clientdata(c);
510
511 kfree(t->priv);
512 t->priv = NULL;
513}
514
501static struct tuner_operations simple_tuner_ops = { 515static struct tuner_operations simple_tuner_ops = {
502 .set_tv_freq = default_set_tv_freq, 516 .set_tv_freq = default_set_tv_freq,
503 .set_radio_freq = default_set_radio_freq, 517 .set_radio_freq = default_set_radio_freq,
504 .has_signal = tuner_signal, 518 .has_signal = tuner_signal,
505 .is_stereo = tuner_stereo, 519 .is_stereo = tuner_stereo,
520 .release = tuner_release,
506}; 521};
507 522
508int default_tuner_init(struct i2c_client *c) 523int default_tuner_init(struct i2c_client *c)
509{ 524{
510 struct tuner *t = i2c_get_clientdata(c); 525 struct tuner *t = i2c_get_clientdata(c);
526 struct tuner_simple_priv *priv = NULL;
527
528 priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL);
529 if (priv == NULL)
530 return -ENOMEM;
531 t->priv = priv;
511 532
512 tuner_info("type set to %d (%s)\n", 533 tuner_info("type set to %d (%s)\n",
513 t->type, tuners[t->type].name); 534 t->type, tuners[t->type].name);