diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2012-06-12 13:37:54 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-06-21 11:12:03 -0400 |
commit | 4ecbb69414c61af3594209e081d6e834ea68a16d (patch) | |
tree | 3af05249ef46680174185336c5dd200d724eb511 /drivers/media/radio | |
parent | 61bdbef063d2300f706133e677c61a1bec097ff8 (diff) |
[media] radio: Add Sanyo LM7000 tuner driver
Add very simple driver for Sanyo LM7000 AM/FM tuner chip. Only FM is supported
as there is no known HW with AM implemented.
This will be used by radio-aimslab and radio-sf16fmi.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/Kconfig | 3 | ||||
-rw-r--r-- | drivers/media/radio/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/radio/lm7000.c | 52 | ||||
-rw-r--r-- | drivers/media/radio/lm7000.h | 32 |
4 files changed, 88 insertions, 0 deletions
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index c257da13d766..5bcce129d718 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -191,6 +191,9 @@ config RADIO_CADET | |||
191 | To compile this driver as a module, choose M here: the | 191 | To compile this driver as a module, choose M here: the |
192 | module will be called radio-cadet. | 192 | module will be called radio-cadet. |
193 | 193 | ||
194 | config RADIO_LM7000 | ||
195 | tristate | ||
196 | |||
194 | config RADIO_RTRACK | 197 | config RADIO_RTRACK |
195 | tristate "AIMSlab RadioTrack (aka RadioReveal) support" | 198 | tristate "AIMSlab RadioTrack (aka RadioReveal) support" |
196 | depends on ISA && VIDEO_V4L2 | 199 | depends on ISA && VIDEO_V4L2 |
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile index ca8c7d134b95..7f6aa63117c0 100644 --- a/drivers/media/radio/Makefile +++ b/drivers/media/radio/Makefile | |||
@@ -28,5 +28,6 @@ obj-$(CONFIG_RADIO_TEF6862) += tef6862.o | |||
28 | obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o | 28 | obj-$(CONFIG_RADIO_TIMBERDALE) += radio-timb.o |
29 | obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o | 29 | obj-$(CONFIG_RADIO_WL1273) += radio-wl1273.o |
30 | obj-$(CONFIG_RADIO_WL128X) += wl128x/ | 30 | obj-$(CONFIG_RADIO_WL128X) += wl128x/ |
31 | obj-$(CONFIG_RADIO_LM7000) += lm7000.o | ||
31 | 32 | ||
32 | ccflags-y += -Isound | 33 | ccflags-y += -Isound |
diff --git a/drivers/media/radio/lm7000.c b/drivers/media/radio/lm7000.c new file mode 100644 index 000000000000..681f3af89260 --- /dev/null +++ b/drivers/media/radio/lm7000.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* Sanyo LM7000 tuner chip driver | ||
2 | * | ||
3 | * Copyright 2012 Ondrej Zary <linux@rainbow-software.org> | ||
4 | * based on radio-aimslab.c by M. Kirkwood | ||
5 | * and radio-sf16fmi.c by M. Kirkwood and Petr Vandrovec | ||
6 | */ | ||
7 | |||
8 | #include <linux/delay.h> | ||
9 | #include <linux/module.h> | ||
10 | #include "lm7000.h" | ||
11 | |||
12 | MODULE_AUTHOR("Ondrej Zary <linux@rainbow-software.org>"); | ||
13 | MODULE_DESCRIPTION("Routines for Sanyo LM7000 AM/FM radio tuner chip"); | ||
14 | MODULE_LICENSE("GPL"); | ||
15 | |||
16 | /* write the 24-bit register, starting with LSB */ | ||
17 | static void lm7000_write(struct lm7000 *lm, u32 val) | ||
18 | { | ||
19 | int i; | ||
20 | u8 data; | ||
21 | |||
22 | for (i = 0; i < 24; i++) { | ||
23 | data = val & (1 << i) ? LM7000_DATA : 0; | ||
24 | lm->set_pins(lm, data | LM7000_CE); | ||
25 | udelay(2); | ||
26 | lm->set_pins(lm, data | LM7000_CE | LM7000_CLK); | ||
27 | udelay(2); | ||
28 | lm->set_pins(lm, data | LM7000_CE); | ||
29 | udelay(2); | ||
30 | } | ||
31 | lm->set_pins(lm, 0); | ||
32 | } | ||
33 | |||
34 | void lm7000_set_freq(struct lm7000 *lm, u32 freq) | ||
35 | { | ||
36 | freq += 171200; /* Add 10.7 MHz IF */ | ||
37 | freq /= 400; /* Convert to 25 kHz units */ | ||
38 | lm7000_write(lm, freq | LM7000_FM_25 | LM7000_BIT_FM); | ||
39 | } | ||
40 | EXPORT_SYMBOL(lm7000_set_freq); | ||
41 | |||
42 | static int __init lm7000_module_init(void) | ||
43 | { | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static void __exit lm7000_module_exit(void) | ||
48 | { | ||
49 | } | ||
50 | |||
51 | module_init(lm7000_module_init) | ||
52 | module_exit(lm7000_module_exit) | ||
diff --git a/drivers/media/radio/lm7000.h b/drivers/media/radio/lm7000.h new file mode 100644 index 000000000000..a5bc7d632f1d --- /dev/null +++ b/drivers/media/radio/lm7000.h | |||
@@ -0,0 +1,32 @@ | |||
1 | #ifndef __LM7000_H | ||
2 | #define __LM7000_H | ||
3 | |||
4 | #define LM7000_DATA (1 << 0) | ||
5 | #define LM7000_CLK (1 << 1) | ||
6 | #define LM7000_CE (1 << 2) | ||
7 | |||
8 | #define LM7000_FREQ_MASK 0x3fff | ||
9 | #define LM7000_BIT_T0 (1 << 14) | ||
10 | #define LM7000_BIT_T1 (1 << 15) | ||
11 | #define LM7000_BIT_B0 (1 << 16) | ||
12 | #define LM7000_BIT_B1 (1 << 17) | ||
13 | #define LM7000_BIT_B2 (1 << 18) | ||
14 | #define LM7000_BIT_TB (1 << 19) | ||
15 | #define LM7000_FM_100 (0 << 20) | ||
16 | #define LM7000_FM_50 (1 << 20) | ||
17 | #define LM7000_FM_25 (2 << 20) | ||
18 | #define LM7000_AM_5 (3 << 20) | ||
19 | #define LM7000_AM_10 (4 << 20) | ||
20 | #define LM7000_AM_9 (5 << 20) | ||
21 | #define LM7000_AM_1 (6 << 20) | ||
22 | #define LM7000_AM_5_ (7 << 20) | ||
23 | #define LM7000_BIT_FM (1 << 23) | ||
24 | |||
25 | |||
26 | struct lm7000 { | ||
27 | void (*set_pins)(struct lm7000 *lm, u8 pins); | ||
28 | }; | ||
29 | |||
30 | void lm7000_set_freq(struct lm7000 *lm, u32 freq); | ||
31 | |||
32 | #endif /* __LM7000_H */ | ||