diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2013-07-19 12:46:17 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2013-07-26 12:33:49 -0400 |
commit | eb27fafef69568a82c46c27a1761f037e4272b87 (patch) | |
tree | e6ad584e38d5a980236227290973e50b6ed010ab | |
parent | cd2e34ead8bf530c45e0446dc4bbbd9e35f28af9 (diff) |
[media] radio-aztech: Convert to generic lm7000 implementation
Aztech radio card is based on LM7001 chip which is (software) compatible with LM7000.
So remove the LM7000-specific code from the driver and use generic code.
Also found that the card does not have A0..A2 ISA pins connected, which means that the region size is 8 bytes.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/radio/radio-aztech.c | 68 |
1 files changed, 24 insertions, 44 deletions
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c index 177bcbd7a7c1..2f5671f2e17e 100644 --- a/drivers/media/radio/radio-aztech.c +++ b/drivers/media/radio/radio-aztech.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <media/v4l2-ioctl.h> | 26 | #include <media/v4l2-ioctl.h> |
27 | #include <media/v4l2-ctrls.h> | 27 | #include <media/v4l2-ctrls.h> |
28 | #include "radio-isa.h" | 28 | #include "radio-isa.h" |
29 | #include "lm7000.h" | ||
29 | 30 | ||
30 | MODULE_AUTHOR("Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath"); | 31 | MODULE_AUTHOR("Russell Kroll, Quay Lu, Donald Song, Jason Lewis, Scott McGrath, William McGrath"); |
31 | MODULE_DESCRIPTION("A driver for the Aztech radio card."); | 32 | MODULE_DESCRIPTION("A driver for the Aztech radio card."); |
@@ -54,18 +55,29 @@ struct aztech { | |||
54 | int curvol; | 55 | int curvol; |
55 | }; | 56 | }; |
56 | 57 | ||
57 | static void send_0_byte(struct aztech *az) | 58 | /* bit definitions for register read */ |
58 | { | 59 | #define AZTECH_BIT_NOT_TUNED (1 << 0) |
59 | udelay(radio_wait_time); | 60 | #define AZTECH_BIT_MONO (1 << 1) |
60 | outb_p(2 + az->curvol, az->isa.io); | 61 | /* bit definitions for register write */ |
61 | outb_p(64 + 2 + az->curvol, az->isa.io); | 62 | #define AZTECH_BIT_TUN_CE (1 << 1) |
62 | } | 63 | #define AZTECH_BIT_TUN_CLK (1 << 6) |
64 | #define AZTECH_BIT_TUN_DATA (1 << 7) | ||
65 | /* bits 0 and 2 are volume control, bits 3..5 are not connected */ | ||
63 | 66 | ||
64 | static void send_1_byte(struct aztech *az) | 67 | static void aztech_set_pins(void *handle, u8 pins) |
65 | { | 68 | { |
66 | udelay(radio_wait_time); | 69 | struct radio_isa_card *isa = handle; |
67 | outb_p(128 + 2 + az->curvol, az->isa.io); | 70 | struct aztech *az = container_of(isa, struct aztech, isa); |
68 | outb_p(128 + 64 + 2 + az->curvol, az->isa.io); | 71 | u8 bits = az->curvol; |
72 | |||
73 | if (pins & LM7000_DATA) | ||
74 | bits |= AZTECH_BIT_TUN_DATA; | ||
75 | if (pins & LM7000_CLK) | ||
76 | bits |= AZTECH_BIT_TUN_CLK; | ||
77 | if (pins & LM7000_CE) | ||
78 | bits |= AZTECH_BIT_TUN_CE; | ||
79 | |||
80 | outb_p(bits, az->isa.io); | ||
69 | } | 81 | } |
70 | 82 | ||
71 | static struct radio_isa_card *aztech_alloc(void) | 83 | static struct radio_isa_card *aztech_alloc(void) |
@@ -77,39 +89,7 @@ static struct radio_isa_card *aztech_alloc(void) | |||
77 | 89 | ||
78 | static int aztech_s_frequency(struct radio_isa_card *isa, u32 freq) | 90 | static int aztech_s_frequency(struct radio_isa_card *isa, u32 freq) |
79 | { | 91 | { |
80 | struct aztech *az = container_of(isa, struct aztech, isa); | 92 | lm7000_set_freq(freq, isa, aztech_set_pins); |
81 | int i; | ||
82 | |||
83 | freq += 171200; /* Add 10.7 MHz IF */ | ||
84 | freq /= 800; /* Convert to 50 kHz units */ | ||
85 | |||
86 | send_0_byte(az); /* 0: LSB of frequency */ | ||
87 | |||
88 | for (i = 0; i < 13; i++) /* : frequency bits (1-13) */ | ||
89 | if (freq & (1 << i)) | ||
90 | send_1_byte(az); | ||
91 | else | ||
92 | send_0_byte(az); | ||
93 | |||
94 | send_0_byte(az); /* 14: test bit - always 0 */ | ||
95 | send_0_byte(az); /* 15: test bit - always 0 */ | ||
96 | send_0_byte(az); /* 16: band data 0 - always 0 */ | ||
97 | if (isa->stereo) /* 17: stereo (1 to enable) */ | ||
98 | send_1_byte(az); | ||
99 | else | ||
100 | send_0_byte(az); | ||
101 | |||
102 | send_1_byte(az); /* 18: band data 1 - unknown */ | ||
103 | send_0_byte(az); /* 19: time base - always 0 */ | ||
104 | send_0_byte(az); /* 20: spacing (0 = 25 kHz) */ | ||
105 | send_1_byte(az); /* 21: spacing (1 = 25 kHz) */ | ||
106 | send_0_byte(az); /* 22: spacing (0 = 25 kHz) */ | ||
107 | send_1_byte(az); /* 23: AM/FM (FM = 1, always) */ | ||
108 | |||
109 | /* latch frequency */ | ||
110 | |||
111 | udelay(radio_wait_time); | ||
112 | outb_p(128 + 64 + az->curvol, az->isa.io); | ||
113 | 93 | ||
114 | return 0; | 94 | return 0; |
115 | } | 95 | } |
@@ -165,7 +145,7 @@ static struct radio_isa_driver aztech_driver = { | |||
165 | .radio_nr_params = radio_nr, | 145 | .radio_nr_params = radio_nr, |
166 | .io_ports = aztech_ioports, | 146 | .io_ports = aztech_ioports, |
167 | .num_of_io_ports = ARRAY_SIZE(aztech_ioports), | 147 | .num_of_io_ports = ARRAY_SIZE(aztech_ioports), |
168 | .region_size = 2, | 148 | .region_size = 8, |
169 | .card = "Aztech Radio", | 149 | .card = "Aztech Radio", |
170 | .ops = &aztech_ops, | 150 | .ops = &aztech_ops, |
171 | .has_stereo = true, | 151 | .has_stereo = true, |