diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2012-06-13 16:25:44 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-06-25 10:08:33 -0400 |
commit | 6b39023a362ef9f12c29de6574fe2522e7ad2060 (patch) | |
tree | 4c7be3eb6561e331fc434eb58bf52cf935b9f696 /drivers/media/radio | |
parent | 39cca6b821d636f3f19c3f92c91b34a68f76f6d1 (diff) |
[media] radio-sf16fmi: Use LM7000 driver
Convert radio-sf16fmi to use generic LM7000 driver.
Tested with SF16-FMI, SF16-FMP and SF16-FMD.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/radio-sf16fmi.c | 61 |
1 files changed, 25 insertions, 36 deletions
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 @@ | |||
27 | #include <linux/io.h> /* outb, outb_p */ | 27 | #include <linux/io.h> /* outb, outb_p */ |
28 | #include <media/v4l2-device.h> | 28 | #include <media/v4l2-device.h> |
29 | #include <media/v4l2-ioctl.h> | 29 | #include <media/v4l2-ioctl.h> |
30 | #include "lm7000.h" | ||
30 | 31 | ||
31 | MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); | 32 | MODULE_AUTHOR("Petr Vandrovec, vandrove@vc.cvut.cz and M. Kirkwood"); |
32 | MODULE_DESCRIPTION("A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio."); | 33 | MODULE_DESCRIPTION("A driver for the SF16-FMI, SF16-FMP and SF16-FMD radio."); |
@@ -54,31 +55,33 @@ static struct fmi fmi_card; | |||
54 | static struct pnp_dev *dev; | 55 | static struct pnp_dev *dev; |
55 | bool pnp_attached; | 56 | bool pnp_attached; |
56 | 57 | ||
57 | /* freq is in 1/16 kHz to internal number, hw precision is 50 kHz */ | ||
58 | /* It is only useful to give freq in interval of 800 (=0.05Mhz), | ||
59 | * other bits will be truncated, e.g 92.7400016 -> 92.7, but | ||
60 | * 92.7400017 -> 92.75 | ||
61 | */ | ||
62 | #define RSF16_ENCODE(x) ((x) / 800 + 214) | ||
63 | #define RSF16_MINFREQ (87 * 16000) | 58 | #define RSF16_MINFREQ (87 * 16000) |
64 | #define RSF16_MAXFREQ (108 * 16000) | 59 | #define RSF16_MAXFREQ (108 * 16000) |
65 | 60 | ||
66 | static void outbits(int bits, unsigned int data, int io) | 61 | #define FMI_BIT_TUN_CE (1 << 0) |
62 | #define FMI_BIT_TUN_CLK (1 << 1) | ||
63 | #define FMI_BIT_TUN_DATA (1 << 2) | ||
64 | #define FMI_BIT_VOL_SW (1 << 3) | ||
65 | #define FMI_BIT_TUN_STRQ (1 << 4) | ||
66 | |||
67 | void fmi_set_pins(void *handle, u8 pins) | ||
67 | { | 68 | { |
68 | while (bits--) { | 69 | struct fmi *fmi = handle; |
69 | if (data & 1) { | 70 | u8 bits = FMI_BIT_TUN_STRQ; |
70 | outb(5, io); | 71 | |
71 | udelay(6); | 72 | if (!fmi->mute) |
72 | outb(7, io); | 73 | bits |= FMI_BIT_VOL_SW; |
73 | udelay(6); | 74 | |
74 | } else { | 75 | if (pins & LM7000_DATA) |
75 | outb(1, io); | 76 | bits |= FMI_BIT_TUN_DATA; |
76 | udelay(6); | 77 | if (pins & LM7000_CLK) |
77 | outb(3, io); | 78 | bits |= FMI_BIT_TUN_CLK; |
78 | udelay(6); | 79 | if (pins & LM7000_CE) |
79 | } | 80 | bits |= FMI_BIT_TUN_CE; |
80 | data >>= 1; | 81 | |
81 | } | 82 | mutex_lock(&fmi->lock); |
83 | outb_p(bits, fmi->io); | ||
84 | mutex_unlock(&fmi->lock); | ||
82 | } | 85 | } |
83 | 86 | ||
84 | static inline void fmi_mute(struct fmi *fmi) | 87 | static inline void fmi_mute(struct fmi *fmi) |
@@ -95,20 +98,6 @@ static inline void fmi_unmute(struct fmi *fmi) | |||
95 | mutex_unlock(&fmi->lock); | 98 | mutex_unlock(&fmi->lock); |
96 | } | 99 | } |
97 | 100 | ||
98 | static inline int fmi_setfreq(struct fmi *fmi, unsigned long freq) | ||
99 | { | ||
100 | mutex_lock(&fmi->lock); | ||
101 | fmi->curfreq = freq; | ||
102 | |||
103 | outbits(16, RSF16_ENCODE(freq), fmi->io); | ||
104 | outbits(8, 0xC0, fmi->io); | ||
105 | msleep(143); /* was schedule_timeout(HZ/7) */ | ||
106 | mutex_unlock(&fmi->lock); | ||
107 | if (!fmi->mute) | ||
108 | fmi_unmute(fmi); | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | static inline int fmi_getsigstr(struct fmi *fmi) | 101 | static inline int fmi_getsigstr(struct fmi *fmi) |
113 | { | 102 | { |
114 | int val; | 103 | int val; |
@@ -173,7 +162,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
173 | return -EINVAL; | 162 | return -EINVAL; |
174 | /* rounding in steps of 800 to match the freq | 163 | /* rounding in steps of 800 to match the freq |
175 | that will be used */ | 164 | that will be used */ |
176 | fmi_setfreq(fmi, (f->frequency / 800) * 800); | 165 | lm7000_set_freq((f->frequency / 800) * 800, fmi, fmi_set_pins); |
177 | return 0; | 166 | return 0; |
178 | } | 167 | } |
179 | 168 | ||