diff options
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/lm7000.h | 43 | ||||
-rw-r--r-- | drivers/media/radio/radio-aimslab.c | 66 | ||||
-rw-r--r-- | drivers/media/radio/radio-mr800.c | 5 | ||||
-rw-r--r-- | drivers/media/radio/radio-sf16fmi.c | 61 | ||||
-rw-r--r-- | drivers/media/radio/radio-wl1273.c | 3 | ||||
-rw-r--r-- | drivers/media/radio/si470x/radio-si470x-common.c | 6 | ||||
-rw-r--r-- | drivers/media/radio/wl128x/fmdrv_rx.c | 2 | ||||
-rw-r--r-- | drivers/media/radio/wl128x/fmdrv_v4l2.c | 4 |
8 files changed, 106 insertions, 84 deletions
diff --git a/drivers/media/radio/lm7000.h b/drivers/media/radio/lm7000.h new file mode 100644 index 000000000000..139cd6b68824 --- /dev/null +++ b/drivers/media/radio/lm7000.h @@ -0,0 +1,43 @@ +#ifndef __LM7000_H +#define __LM7000_H + +/* Sanyo LM7000 tuner chip control + * + * Copyright 2012 Ondrej Zary <linux@rainbow-software.org> + * based on radio-aimslab.c by M. Kirkwood + * and radio-sf16fmi.c by M. Kirkwood and Petr Vandrovec + */ + +#define LM7000_DATA (1 << 0) +#define LM7000_CLK (1 << 1) +#define LM7000_CE (1 << 2) + +#define LM7000_FM_100 (0 << 20) +#define LM7000_FM_50 (1 << 20) +#define LM7000_FM_25 (2 << 20) +#define LM7000_BIT_FM (1 << 23) + +static inline void lm7000_set_freq(u32 freq, void *handle, + void (*set_pins)(void *handle, u8 pins)) +{ + int i; + u8 data; + u32 val; + + freq += 171200; /* Add 10.7 MHz IF */ + freq /= 400; /* Convert to 25 kHz units */ + val = freq | LM7000_FM_25 | LM7000_BIT_FM; + /* write the 24-bit register, starting with LSB */ + for (i = 0; i < 24; i++) { + data = val & (1 << i) ? LM7000_DATA : 0; + set_pins(handle, data | LM7000_CE); + udelay(2); + set_pins(handle, data | LM7000_CE | LM7000_CLK); + udelay(2); + set_pins(handle, data | LM7000_CE); + udelay(2); + } + set_pins(handle, 0); +} + +#endif /* __LM7000_H */ diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index 98e0c8c20312..12c70e876f58 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c @@ -37,6 +37,7 @@ #include <media/v4l2-ioctl.h> #include <media/v4l2-ctrls.h> #include "radio-isa.h" +#include "lm7000.h" MODULE_AUTHOR("M. Kirkwood"); MODULE_DESCRIPTION("A driver for the RadioTrack/RadioReveal radio card."); @@ -72,55 +73,38 @@ static struct radio_isa_card *rtrack_alloc(void) return rt ? &rt->isa : NULL; } -/* The 128+64 on these outb's is to keep the volume stable while tuning. - * Without them, the volume _will_ creep up with each frequency change - * and bit 4 (+16) is to keep the signal strength meter enabled. - */ +#define AIMS_BIT_TUN_CE (1 << 0) +#define AIMS_BIT_TUN_CLK (1 << 1) +#define AIMS_BIT_TUN_DATA (1 << 2) +#define AIMS_BIT_VOL_CE (1 << 3) +#define AIMS_BIT_TUN_STRQ (1 << 4) +/* bit 5 is not connected */ +#define AIMS_BIT_VOL_UP (1 << 6) /* active low */ +#define AIMS_BIT_VOL_DN (1 << 7) /* active low */ -static void send_0_byte(struct radio_isa_card *isa, int on) +void rtrack_set_pins(void *handle, u8 pins) { - outb_p(128+64+16+on+1, isa->io); /* wr-enable + data low */ - outb_p(128+64+16+on+2+1, isa->io); /* clock */ - msleep(1); -} + struct radio_isa_card *isa = handle; + struct rtrack *rt = container_of(isa, struct rtrack, isa); + u8 bits = AIMS_BIT_VOL_DN | AIMS_BIT_VOL_UP | AIMS_BIT_TUN_STRQ; -static void send_1_byte(struct radio_isa_card *isa, int on) -{ - outb_p(128+64+16+on+4+1, isa->io); /* wr-enable+data high */ - outb_p(128+64+16+on+4+2+1, isa->io); /* clock */ - msleep(1); + if (!v4l2_ctrl_g_ctrl(rt->isa.mute)) + bits |= AIMS_BIT_VOL_CE; + + if (pins & LM7000_DATA) + bits |= AIMS_BIT_TUN_DATA; + if (pins & LM7000_CLK) + bits |= AIMS_BIT_TUN_CLK; + if (pins & LM7000_CE) + bits |= AIMS_BIT_TUN_CE; + + outb_p(bits, rt->isa.io); } static int rtrack_s_frequency(struct radio_isa_card *isa, u32 freq) { - int on = v4l2_ctrl_g_ctrl(isa->mute) ? 0 : 8; - int i; - - freq += 171200; /* Add 10.7 MHz IF */ - freq /= 800; /* Convert to 50 kHz units */ - - send_0_byte(isa, on); /* 0: LSB of frequency */ - - for (i = 0; i < 13; i++) /* : frequency bits (1-13) */ - if (freq & (1 << i)) - send_1_byte(isa, on); - else - send_0_byte(isa, on); - - send_0_byte(isa, on); /* 14: test bit - always 0 */ - send_0_byte(isa, on); /* 15: test bit - always 0 */ - - send_0_byte(isa, on); /* 16: band data 0 - always 0 */ - send_0_byte(isa, on); /* 17: band data 1 - always 0 */ - send_0_byte(isa, on); /* 18: band data 2 - always 0 */ - send_0_byte(isa, on); /* 19: time base - always 0 */ - - send_0_byte(isa, on); /* 20: spacing (0 = 25 kHz) */ - send_1_byte(isa, on); /* 21: spacing (1 = 25 kHz) */ - send_0_byte(isa, on); /* 22: spacing (0 = 25 kHz) */ - send_1_byte(isa, on); /* 23: AM/FM (FM = 1, always) */ + lm7000_set_freq(freq, isa, rtrack_set_pins); - outb(0xd0 + on, isa->io); /* volume steady + sigstr */ return 0; } diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 94cb6bc690f5..3182b26d6efa 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -295,7 +295,8 @@ static int vidioc_g_tuner(struct file *file, void *priv, v->type = V4L2_TUNER_RADIO; v->rangelow = FREQ_MIN * FREQ_MUL; v->rangehigh = FREQ_MAX * FREQ_MUL; - v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO; + v->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | + V4L2_TUNER_CAP_HWSEEK_WRAP; v->rxsubchans = is_stereo ? V4L2_TUNER_SUB_STEREO : V4L2_TUNER_SUB_MONO; v->audmode = radio->stereo ? V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO; @@ -372,7 +373,7 @@ static int vidioc_s_hw_freq_seek(struct file *file, void *priv, timeout = jiffies + msecs_to_jiffies(30000); for (;;) { if (time_after(jiffies, timeout)) { - retval = -EAGAIN; + retval = -ENODATA; break; } if (schedule_timeout_interruptible(msecs_to_jiffies(10))) { diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index a81d723b8c77..8185d5fbfa89 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c @@ -27,6 +27,7 @@ #include <linux/io.h> /* outb, outb_p */ #include <media/v4l2-device.h> #include <media/v4l2-ioctl.h> +#include "lm7000.h" MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); MODULE_DESCRIPTION("A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio."); @@ -54,31 +55,33 @@ static struct fmi fmi_card; static struct pnp_dev *dev; bool pnp_attached; -/* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */ -/* It is only useful to give freq in interval of 800 (=0.05Mhz), - * other bits will be truncated, e.g 92.7400016 -> 92.7, but - * 92.7400017 -> 92.75 - */ -#define RSF16_ENCODE(x) ((x) / 800 + 214) #define RSF16_MINFREQ (87 * 16000) #define RSF16_MAXFREQ (108 * 16000) -static void outbits(int bits, unsigned int data, int io) +#define FMI_BIT_TUN_CE (1 << 0) +#define FMI_BIT_TUN_CLK (1 << 1) +#define FMI_BIT_TUN_DATA (1 << 2) +#define FMI_BIT_VOL_SW (1 << 3) +#define FMI_BIT_TUN_STRQ (1 << 4) + +void fmi_set_pins(void *handle, u8 pins) { - while (bits--) { - if (data & 1) { - outb(5, io); - udelay(6); - outb(7, io); - udelay(6); - } else { - outb(1, io); - udelay(6); - outb(3, io); - udelay(6); - } - data >>= 1; - } + struct fmi *fmi = handle; + u8 bits = FMI_BIT_TUN_STRQ; + + if (!fmi->mute) + bits |= FMI_BIT_VOL_SW; + + if (pins & LM7000_DATA) + bits |= FMI_BIT_TUN_DATA; + if (pins & LM7000_CLK) + bits |= FMI_BIT_TUN_CLK; + if (pins & LM7000_CE) + bits |= FMI_BIT_TUN_CE; + + mutex_lock(&fmi->lock); + outb_p(bits, fmi->io); + mutex_unlock(&fmi->lock); } static inline void fmi_mute(struct fmi *fmi) @@ -95,20 +98,6 @@ static inline void fmi_unmute(struct fmi *fmi) mutex_unlock(&fmi->lock); } -static inline int fmi_setfreq(struct fmi *fmi, unsigned long freq) -{ - mutex_lock(&fmi->lock); - fmi->curfreq = freq; - - outbits(16, RSF16_ENCODE(freq), fmi->io); - outbits(8, 0xC0, fmi->io); - msleep(143); /* was schedule_timeout(HZ/7) */ - mutex_unlock(&fmi->lock); - if (!fmi->mute) - fmi_unmute(fmi); - return 0; -} - static inline int fmi_getsigstr(struct fmi *fmi) { int val; @@ -173,7 +162,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, return -EINVAL; /* rounding in steps of 800 to match the freq that will be used */ - fmi_setfreq(fmi, (f->frequency / 800) * 800); + lm7000_set_freq((f->frequency / 800) * 800, fmi, fmi_set_pins); return 0; } diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c index f1b607099b6c..e8428f573ccd 100644 --- a/drivers/media/radio/radio-wl1273.c +++ b/drivers/media/radio/radio-wl1273.c @@ -1514,7 +1514,8 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv, tuner->rangehigh = WL1273_FREQ(WL1273_BAND_OTHER_HIGH); tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_RDS | - V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS_BLOCK_IO; + V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS_BLOCK_IO | + V4L2_TUNER_CAP_HWSEEK_BOUNDED | V4L2_TUNER_CAP_HWSEEK_WRAP; if (radio->stereo) tuner->audmode = V4L2_TUNER_MODE_STEREO; diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c index 969cf494d85b..d485b79222fd 100644 --- a/drivers/media/radio/si470x/radio-si470x-common.c +++ b/drivers/media/radio/si470x/radio-si470x-common.c @@ -363,7 +363,7 @@ stop: /* try again, if timed out */ if (retval == 0 && timed_out) - return -EAGAIN; + return -ENODATA; return retval; } @@ -596,7 +596,9 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, strcpy(tuner->name, "FM"); tuner->type = V4L2_TUNER_RADIO; tuner->capability = V4L2_TUNER_CAP_LOW | V4L2_TUNER_CAP_STEREO | - V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO; + V4L2_TUNER_CAP_RDS | V4L2_TUNER_CAP_RDS_BLOCK_IO | + V4L2_TUNER_CAP_HWSEEK_BOUNDED | + V4L2_TUNER_CAP_HWSEEK_WRAP; /* range limits */ switch ((radio->registers[SYSCONFIG2] & SYSCONFIG2_BAND) >> 6) { diff --git a/drivers/media/radio/wl128x/fmdrv_rx.c b/drivers/media/radio/wl128x/fmdrv_rx.c index 43fb72291bea..3dd9fc097c47 100644 --- a/drivers/media/radio/wl128x/fmdrv_rx.c +++ b/drivers/media/radio/wl128x/fmdrv_rx.c @@ -251,7 +251,7 @@ again: if (!timeleft) { fmerr("Timeout(%d sec),didn't get tune ended int\n", jiffies_to_msecs(FM_DRV_RX_SEEK_TIMEOUT) / 1000); - return -ETIMEDOUT; + return -ENODATA; } int_reason = fmdev->irq_info.flag & (FM_TUNE_COMPLETE | FM_BAND_LIMIT); diff --git a/drivers/media/radio/wl128x/fmdrv_v4l2.c b/drivers/media/radio/wl128x/fmdrv_v4l2.c index 080b96a61f1a..49a11ec1f449 100644 --- a/drivers/media/radio/wl128x/fmdrv_v4l2.c +++ b/drivers/media/radio/wl128x/fmdrv_v4l2.c @@ -285,7 +285,9 @@ static int fm_v4l2_vidioc_g_tuner(struct file *file, void *priv, tuner->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO | ((fmdev->rx.rds.flag == FM_RDS_ENABLE) ? V4L2_TUNER_SUB_RDS : 0); tuner->capability = V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_RDS | - V4L2_TUNER_CAP_LOW; + V4L2_TUNER_CAP_LOW | + V4L2_TUNER_CAP_HWSEEK_BOUNDED | + V4L2_TUNER_CAP_HWSEEK_WRAP; tuner->audmode = (stereo_mono_mode ? V4L2_TUNER_MODE_MONO : V4L2_TUNER_MODE_STEREO); |