aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-06 09:49:14 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 12:02:58 -0500
commit76ea992a036c4a5d3bc606a79ef775dd32fd3daa (patch)
treedaf867d8f5b1a7a27316c5373e8ea38bcb99e0f4 /drivers/media/pci
parentd9b6707673b6590bb6b984af6c435c807335a459 (diff)
[media] bttv: set initial tv/radio frequencies
Set an initial frequencies when the driver is loaded. That way G_FREQUENCY will give a frequency that corresponds with reality. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c34
-rw-r--r--drivers/media/pci/bt8xx/bttvp.h3
2 files changed, 30 insertions, 7 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index f6f2b009bb6f..546a9f55b809 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -2007,10 +2007,27 @@ static int bttv_g_frequency(struct file *file, void *priv,
2007 if (f->tuner) 2007 if (f->tuner)
2008 return -EINVAL; 2008 return -EINVAL;
2009 2009
2010 f->frequency = btv->freq; 2010 f->frequency = f->type == V4L2_TUNER_RADIO ?
2011 btv->radio_freq : btv->tv_freq;
2012
2011 return 0; 2013 return 0;
2012} 2014}
2013 2015
2016static void bttv_set_frequency(struct bttv *btv, struct v4l2_frequency *f)
2017{
2018 bttv_call_all(btv, tuner, s_frequency, f);
2019 /* s_frequency may clamp the frequency, so get the actual
2020 frequency before assigning radio/tv_freq. */
2021 bttv_call_all(btv, tuner, g_frequency, f);
2022 if (f->type == V4L2_TUNER_RADIO) {
2023 btv->radio_freq = f->frequency;
2024 if (btv->has_matchbox)
2025 tea5757_set_freq(btv, btv->radio_freq);
2026 } else {
2027 btv->tv_freq = f->frequency;
2028 }
2029}
2030
2014static int bttv_s_frequency(struct file *file, void *priv, 2031static int bttv_s_frequency(struct file *file, void *priv,
2015 struct v4l2_frequency *f) 2032 struct v4l2_frequency *f)
2016{ 2033{
@@ -2024,11 +2041,7 @@ static int bttv_s_frequency(struct file *file, void *priv,
2024 err = v4l2_prio_check(&btv->prio, fh->prio); 2041 err = v4l2_prio_check(&btv->prio, fh->prio);
2025 if (err) 2042 if (err)
2026 return err; 2043 return err;
2027 2044 bttv_set_frequency(btv, f);
2028 btv->freq = f->frequency;
2029 bttv_call_all(btv, tuner, s_frequency, f);
2030 if (btv->has_matchbox && btv->radio_user)
2031 tea5757_set_freq(btv, btv->freq);
2032 return 0; 2045 return 0;
2033} 2046}
2034 2047
@@ -4235,6 +4248,11 @@ static void pci_set_command(struct pci_dev *dev)
4235 4248
4236static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) 4249static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4237{ 4250{
4251 struct v4l2_frequency init_freq = {
4252 .tuner = 0,
4253 .type = V4L2_TUNER_ANALOG_TV,
4254 .frequency = 980,
4255 };
4238 int result; 4256 int result;
4239 unsigned char lat; 4257 unsigned char lat;
4240 struct bttv *btv; 4258 struct bttv *btv;
@@ -4375,6 +4393,10 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4375 /* some card-specific stuff (needs working i2c) */ 4393 /* some card-specific stuff (needs working i2c) */
4376 bttv_init_card2(btv); 4394 bttv_init_card2(btv);
4377 bttv_init_tuner(btv); 4395 bttv_init_tuner(btv);
4396 if (btv->tuner_type != TUNER_ABSENT) {
4397 bttv_set_frequency(btv, &init_freq);
4398 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */
4399 }
4378 init_irqreg(btv); 4400 init_irqreg(btv);
4379 4401
4380 /* register video4linux + input */ 4402 /* register video4linux + input */
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index 9ec0adba236c..528e03ec19e8 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -418,7 +418,7 @@ struct bttv {
418 unsigned int input; 418 unsigned int input;
419 unsigned int audio; 419 unsigned int audio;
420 unsigned int mute; 420 unsigned int mute;
421 unsigned long freq; 421 unsigned long tv_freq;
422 unsigned int tvnorm; 422 unsigned int tvnorm;
423 int hue, contrast, bright, saturation; 423 int hue, contrast, bright, saturation;
424 struct v4l2_framebuffer fbuf; 424 struct v4l2_framebuffer fbuf;
@@ -442,6 +442,7 @@ struct bttv {
442 int has_radio; 442 int has_radio;
443 int radio_user; 443 int radio_user;
444 int radio_uses_msp_demodulator; 444 int radio_uses_msp_demodulator;
445 unsigned long radio_freq;
445 446
446 /* miro/pinnacle + Aimslab VHX 447 /* miro/pinnacle + Aimslab VHX
447 philips matchbox (tea5757 radio tuner) support */ 448 philips matchbox (tea5757 radio tuner) support */