radiotrack.c revision 1.5.2.5 1 1.5.2.5 nathanw /* $NetBSD: radiotrack.c,v 1.5.2.5 2002/10/18 02:42:32 nathanw Exp $ */
2 1.5.2.2 nathanw /* $OpenBSD: radiotrack.c,v 1.1 2001/12/05 10:27:06 mickey Exp $ */
3 1.5.2.2 nathanw /* $RuOBSD: radiotrack.c,v 1.3 2001/10/18 16:51:36 pva Exp $ */
4 1.5.2.2 nathanw
5 1.5.2.2 nathanw /*
6 1.5.2.2 nathanw * Copyright (c) 2001 Maxim Tsyplakov <tm (at) oganer.net>,
7 1.5.2.2 nathanw * Vladimir Popov <jumbo (at) narod.ru>
8 1.5.2.2 nathanw * All rights reserved.
9 1.5.2.2 nathanw *
10 1.5.2.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.5.2.2 nathanw * modification, are permitted provided that the following conditions
12 1.5.2.2 nathanw * are met:
13 1.5.2.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.5.2.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.5.2.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.5.2.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.5.2.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.5.2.2 nathanw *
19 1.5.2.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
20 1.5.2.2 nathanw * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 1.5.2.2 nathanw * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 1.5.2.2 nathanw * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 1.5.2.2 nathanw * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 1.5.2.2 nathanw * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 1.5.2.2 nathanw * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 1.5.2.2 nathanw * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 1.5.2.2 nathanw * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 1.5.2.2 nathanw * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 1.5.2.2 nathanw */
30 1.5.2.2 nathanw
31 1.5.2.2 nathanw /* AIMS Lab Radiotrack FM Radio Card device driver */
32 1.5.2.2 nathanw
33 1.5.2.2 nathanw /*
34 1.5.2.2 nathanw * Sanyo LM7000 Direct PLL Frequency Synthesizer
35 1.5.2.2 nathanw */
36 1.5.2.2 nathanw
37 1.5.2.2 nathanw #include <sys/param.h>
38 1.5.2.2 nathanw #include <sys/systm.h>
39 1.5.2.2 nathanw #include <sys/proc.h>
40 1.5.2.2 nathanw #include <sys/errno.h>
41 1.5.2.2 nathanw #include <sys/ioctl.h>
42 1.5.2.2 nathanw #include <sys/device.h>
43 1.5.2.2 nathanw #include <sys/radioio.h>
44 1.5.2.2 nathanw
45 1.5.2.2 nathanw #include <machine/bus.h>
46 1.5.2.2 nathanw
47 1.5.2.2 nathanw #include <dev/isa/isavar.h>
48 1.5.2.2 nathanw #include <dev/ic/lm700x.h>
49 1.5.2.2 nathanw #include <dev/radio_if.h>
50 1.5.2.2 nathanw
51 1.5.2.2 nathanw #define RF_25K 25
52 1.5.2.2 nathanw #define RF_50K 50
53 1.5.2.2 nathanw #define RF_100K 100
54 1.5.2.2 nathanw
55 1.5.2.2 nathanw #define MAX_VOL 5 /* XXX Find real value */
56 1.5.2.2 nathanw #define VOLUME_RATIO(x) (255 * x / MAX_VOL)
57 1.5.2.2 nathanw
58 1.5.2.2 nathanw #define RT_BASE_VALID(x) \
59 1.5.2.2 nathanw ((x == 0x30C) || (x == 0x20C) || (x == 0x284) || (x == 0x384))
60 1.5.2.2 nathanw
61 1.5.2.2 nathanw #define CARD_RADIOTRACK 0x01
62 1.5.2.2 nathanw #define CARD_SF16FMI 0x02
63 1.5.2.2 nathanw #define CARD_UNKNOWN 0xFF
64 1.5.2.2 nathanw
65 1.5.2.2 nathanw #define RTRACK_CAPABILITIES RADIO_CAPS_DETECT_STEREO | \
66 1.5.2.2 nathanw RADIO_CAPS_DETECT_SIGNAL | \
67 1.5.2.2 nathanw RADIO_CAPS_SET_MONO | \
68 1.5.2.2 nathanw RADIO_CAPS_REFERENCE_FREQ
69 1.5.2.2 nathanw
70 1.5.2.2 nathanw #define RT_WREN_ON (1 << 0)
71 1.5.2.2 nathanw #define RT_WREN_OFF (0 << 0)
72 1.5.2.2 nathanw
73 1.5.2.2 nathanw #define RT_CLCK_ON (1 << 1)
74 1.5.2.2 nathanw #define RT_CLCK_OFF (0 << 1)
75 1.5.2.2 nathanw
76 1.5.2.2 nathanw #define RT_DATA_ON (1 << 2)
77 1.5.2.2 nathanw #define RT_DATA_OFF (0 << 2)
78 1.5.2.2 nathanw
79 1.5.2.2 nathanw #define RT_CARD_ON (1 << 3)
80 1.5.2.2 nathanw #define RT_CARD_OFF (0 << 3)
81 1.5.2.2 nathanw
82 1.5.2.2 nathanw #define RT_SIGNAL_METER (1 << 4)
83 1.5.2.2 nathanw #define RT_SIGNAL_METER_DELAY 150000
84 1.5.2.2 nathanw
85 1.5.2.2 nathanw #define RT_VOLUME_DOWN (1 << 6)
86 1.5.2.2 nathanw #define RT_VOLUME_UP (2 << 6)
87 1.5.2.2 nathanw #define RT_VOLUME_STEADY (3 << 6)
88 1.5.2.2 nathanw #define RT_VOLUME_DELAY 100000
89 1.5.2.2 nathanw
90 1.5.2.2 nathanw int rt_probe(struct device *, struct cfdata *, void *);
91 1.5.2.2 nathanw void rt_attach(struct device *, struct device * self, void *);
92 1.5.2.2 nathanw int rt_get_info(void *, struct radio_info *);
93 1.5.2.2 nathanw int rt_set_info(void *, struct radio_info *);
94 1.5.2.2 nathanw
95 1.5.2.2 nathanw struct radio_hw_if rt_hw_if = {
96 1.5.2.2 nathanw NULL, /* open */
97 1.5.2.2 nathanw NULL, /* close */
98 1.5.2.2 nathanw rt_get_info,
99 1.5.2.2 nathanw rt_set_info,
100 1.5.2.2 nathanw NULL
101 1.5.2.2 nathanw };
102 1.5.2.2 nathanw
103 1.5.2.2 nathanw struct rt_softc {
104 1.5.2.2 nathanw struct device sc_dev;
105 1.5.2.2 nathanw
106 1.5.2.2 nathanw int mute;
107 1.5.2.2 nathanw u_int8_t vol;
108 1.5.2.2 nathanw u_int8_t cardtype;
109 1.5.2.2 nathanw u_int32_t freq;
110 1.5.2.2 nathanw u_int32_t rf;
111 1.5.2.2 nathanw u_int32_t stereo;
112 1.5.2.2 nathanw
113 1.5.2.2 nathanw struct lm700x_t lm;
114 1.5.2.2 nathanw };
115 1.5.2.2 nathanw
116 1.5.2.5 nathanw CFATTACH_DECL(rt, sizeof(struct rt_softc),
117 1.5.2.5 nathanw rt_probe, rt_attach, NULL, NULL);
118 1.5.2.2 nathanw
119 1.5.2.2 nathanw int rt_find(bus_space_tag_t, bus_space_handle_t);
120 1.5.2.2 nathanw void rt_set_mute(struct rt_softc *, int);
121 1.5.2.2 nathanw void rt_set_freq(struct rt_softc *, u_int32_t);
122 1.5.2.2 nathanw u_int8_t rt_state(bus_space_tag_t, bus_space_handle_t);
123 1.5.2.2 nathanw
124 1.5.2.2 nathanw void rt_lm700x_init(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
125 1.5.2.2 nathanw void rt_lm700x_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
126 1.5.2.2 nathanw
127 1.5.2.2 nathanw u_int8_t rt_conv_vol(u_int8_t);
128 1.5.2.2 nathanw u_int8_t rt_unconv_vol(u_int8_t);
129 1.5.2.2 nathanw
130 1.5.2.2 nathanw int
131 1.5.2.2 nathanw rt_probe(struct device *parent, struct cfdata *cf, void *aux)
132 1.5.2.2 nathanw {
133 1.5.2.2 nathanw struct isa_attach_args *ia = aux;
134 1.5.2.2 nathanw bus_space_tag_t iot = ia->ia_iot;
135 1.5.2.2 nathanw bus_space_handle_t ioh;
136 1.5.2.3 nathanw u_int r;
137 1.5.2.3 nathanw int iosize = 1, iobase;
138 1.5.2.2 nathanw
139 1.5.2.3 nathanw if (ISA_DIRECT_CONFIG(ia))
140 1.5.2.3 nathanw return 0;
141 1.5.2.3 nathanw
142 1.5.2.3 nathanw if (ia->ia_nio < 1)
143 1.5.2.3 nathanw return (0);
144 1.5.2.3 nathanw
145 1.5.2.3 nathanw iobase = ia->ia_io[0].ir_addr;
146 1.5.2.2 nathanw
147 1.5.2.2 nathanw if (!RT_BASE_VALID(iobase)) {
148 1.5.2.2 nathanw printf("rt: configured iobase 0x%x invalid\n", iobase);
149 1.5.2.2 nathanw return 0;
150 1.5.2.2 nathanw }
151 1.5.2.2 nathanw
152 1.5.2.2 nathanw if (bus_space_map(iot, iobase, iosize, 0, &ioh))
153 1.5.2.2 nathanw return 0;
154 1.5.2.2 nathanw
155 1.5.2.3 nathanw r = rt_find(iot, ioh);
156 1.5.2.3 nathanw
157 1.5.2.2 nathanw bus_space_unmap(iot, ioh, iosize);
158 1.5.2.2 nathanw
159 1.5.2.3 nathanw if (r != 0) {
160 1.5.2.3 nathanw ia->ia_nio = 1;
161 1.5.2.3 nathanw ia->ia_io[0].ir_size = iosize;
162 1.5.2.3 nathanw
163 1.5.2.3 nathanw ia->ia_niomem = 0;
164 1.5.2.3 nathanw ia->ia_nirq = 0;
165 1.5.2.3 nathanw ia->ia_ndrq = 0;
166 1.5.2.3 nathanw
167 1.5.2.3 nathanw return (1);
168 1.5.2.3 nathanw }
169 1.5.2.2 nathanw
170 1.5.2.3 nathanw return (0);
171 1.5.2.2 nathanw }
172 1.5.2.2 nathanw
173 1.5.2.2 nathanw void
174 1.5.2.2 nathanw rt_attach(struct device *parent, struct device *self, void *aux)
175 1.5.2.2 nathanw {
176 1.5.2.2 nathanw struct rt_softc *sc = (void *) self;
177 1.5.2.2 nathanw struct isa_attach_args *ia = aux;
178 1.5.2.2 nathanw
179 1.5.2.2 nathanw sc->lm.iot = ia->ia_iot;
180 1.5.2.2 nathanw sc->rf = LM700X_REF_050;
181 1.5.2.2 nathanw sc->stereo = LM700X_STEREO;
182 1.5.2.2 nathanw sc->mute = 0;
183 1.5.2.2 nathanw sc->freq = MIN_FM_FREQ;
184 1.5.2.2 nathanw sc->vol = 0;
185 1.5.2.2 nathanw
186 1.5.2.2 nathanw /* remap I/O */
187 1.5.2.3 nathanw if (bus_space_map(sc->lm.iot, ia->ia_io[0].ir_addr,
188 1.5.2.3 nathanw ia->ia_io[0].ir_size, 0, &sc->lm.ioh))
189 1.5.2.2 nathanw panic(": bus_space_map() of %s failed", sc->sc_dev.dv_xname);
190 1.5.2.2 nathanw
191 1.5.2.3 nathanw switch (ia->ia_io[0].ir_addr) {
192 1.5.2.2 nathanw case 0x20C:
193 1.5.2.2 nathanw /* FALLTHROUGH */
194 1.5.2.2 nathanw case 0x30C:
195 1.5.2.2 nathanw sc->cardtype = CARD_RADIOTRACK;
196 1.5.2.3 nathanw printf(": AIMS Lab Radiotrack or compatible\n");
197 1.5.2.2 nathanw break;
198 1.5.2.2 nathanw case 0x284:
199 1.5.2.2 nathanw /* FALLTHROUGH */
200 1.5.2.2 nathanw case 0x384:
201 1.5.2.2 nathanw sc->cardtype = CARD_SF16FMI;
202 1.5.2.3 nathanw printf(": SoundForte RadioX SF16-FMI\n");
203 1.5.2.2 nathanw break;
204 1.5.2.2 nathanw default:
205 1.5.2.2 nathanw sc->cardtype = CARD_UNKNOWN;
206 1.5.2.3 nathanw printf(": Unknown card\n");
207 1.5.2.2 nathanw break;
208 1.5.2.2 nathanw }
209 1.5.2.2 nathanw
210 1.5.2.2 nathanw /* Configure struct lm700x_t lm */
211 1.5.2.2 nathanw sc->lm.offset = 0;
212 1.5.2.2 nathanw sc->lm.wzcl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_OFF;
213 1.5.2.2 nathanw sc->lm.wzch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_OFF;
214 1.5.2.2 nathanw sc->lm.wocl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_ON;
215 1.5.2.2 nathanw sc->lm.woch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_ON;
216 1.5.2.2 nathanw sc->lm.initdata = 0;
217 1.5.2.2 nathanw sc->lm.rsetdata = RT_DATA_ON | RT_CLCK_ON | RT_WREN_OFF;
218 1.5.2.2 nathanw sc->lm.init = rt_lm700x_init;
219 1.5.2.2 nathanw sc->lm.rset = rt_lm700x_rset;
220 1.5.2.2 nathanw
221 1.5.2.2 nathanw rt_set_freq(sc, sc->freq);
222 1.5.2.2 nathanw
223 1.5.2.2 nathanw radio_attach_mi(&rt_hw_if, sc, &sc->sc_dev);
224 1.5.2.2 nathanw }
225 1.5.2.2 nathanw
226 1.5.2.2 nathanw /*
227 1.5.2.2 nathanw * Mute the card
228 1.5.2.2 nathanw */
229 1.5.2.2 nathanw void
230 1.5.2.2 nathanw rt_set_mute(struct rt_softc *sc, int vol)
231 1.5.2.2 nathanw {
232 1.5.2.2 nathanw int val;
233 1.5.2.2 nathanw
234 1.5.2.2 nathanw if (sc->mute) {
235 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
236 1.5.2.2 nathanw RT_VOLUME_DOWN | RT_CARD_ON);
237 1.5.2.2 nathanw DELAY(MAX_VOL * RT_VOLUME_DELAY);
238 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
239 1.5.2.2 nathanw RT_VOLUME_STEADY | RT_CARD_ON);
240 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0, RT_CARD_OFF);
241 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0, RT_CARD_OFF);
242 1.5.2.2 nathanw } else {
243 1.5.2.2 nathanw val = sc->vol - vol;
244 1.5.2.2 nathanw if (val < 0) {
245 1.5.2.2 nathanw val *= -1;
246 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
247 1.5.2.2 nathanw RT_VOLUME_DOWN | RT_CARD_ON);
248 1.5.2.2 nathanw } else {
249 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
250 1.5.2.2 nathanw RT_VOLUME_UP | RT_CARD_ON);
251 1.5.2.2 nathanw }
252 1.5.2.2 nathanw DELAY(val * RT_VOLUME_DELAY);
253 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
254 1.5.2.2 nathanw RT_VOLUME_STEADY | RT_CARD_ON);
255 1.5.2.2 nathanw }
256 1.5.2.2 nathanw }
257 1.5.2.2 nathanw
258 1.5.2.2 nathanw void
259 1.5.2.2 nathanw rt_set_freq(struct rt_softc *sc, u_int32_t nfreq)
260 1.5.2.2 nathanw {
261 1.5.2.2 nathanw u_int32_t reg;
262 1.5.2.2 nathanw
263 1.5.2.2 nathanw if (nfreq > MAX_FM_FREQ)
264 1.5.2.2 nathanw nfreq = MAX_FM_FREQ;
265 1.5.2.2 nathanw if (nfreq < MIN_FM_FREQ)
266 1.5.2.2 nathanw nfreq = MIN_FM_FREQ;
267 1.5.2.2 nathanw
268 1.5.2.2 nathanw sc->freq = nfreq;
269 1.5.2.2 nathanw
270 1.5.2.2 nathanw reg = lm700x_encode_freq(nfreq, sc->rf);
271 1.5.2.2 nathanw reg |= sc->stereo | sc->rf | LM700X_DIVIDER_FM;
272 1.5.2.2 nathanw
273 1.5.2.2 nathanw lm700x_hardware_write(&sc->lm, reg, RT_VOLUME_STEADY);
274 1.5.2.2 nathanw
275 1.5.2.2 nathanw rt_set_mute(sc, sc->vol);
276 1.5.2.2 nathanw }
277 1.5.2.2 nathanw
278 1.5.2.2 nathanw /*
279 1.5.2.2 nathanw * Return state of the card - tuned/not tuned, mono/stereo
280 1.5.2.2 nathanw */
281 1.5.2.2 nathanw u_int8_t
282 1.5.2.2 nathanw rt_state(bus_space_tag_t iot, bus_space_handle_t ioh)
283 1.5.2.2 nathanw {
284 1.5.2.2 nathanw u_int8_t ret;
285 1.5.2.2 nathanw
286 1.5.2.2 nathanw bus_space_write_1(iot, ioh, 0,
287 1.5.2.2 nathanw RT_VOLUME_STEADY | RT_SIGNAL_METER | RT_CARD_ON);
288 1.5.2.2 nathanw DELAY(RT_SIGNAL_METER_DELAY);
289 1.5.2.2 nathanw ret = bus_space_read_1(iot, ioh, 0);
290 1.5.2.2 nathanw
291 1.5.2.2 nathanw switch (ret) {
292 1.5.2.2 nathanw case 0xFD:
293 1.5.2.2 nathanw ret = RADIO_INFO_SIGNAL | RADIO_INFO_STEREO;
294 1.5.2.2 nathanw break;
295 1.5.2.2 nathanw case 0xFF:
296 1.5.2.2 nathanw ret = 0;
297 1.5.2.2 nathanw break;
298 1.5.2.2 nathanw default:
299 1.5.2.2 nathanw ret = RADIO_INFO_SIGNAL;
300 1.5.2.2 nathanw break;
301 1.5.2.2 nathanw }
302 1.5.2.2 nathanw
303 1.5.2.2 nathanw return ret;
304 1.5.2.2 nathanw }
305 1.5.2.2 nathanw
306 1.5.2.2 nathanw /*
307 1.5.2.2 nathanw * Convert volume to hardware representation.
308 1.5.2.2 nathanw */
309 1.5.2.2 nathanw u_int8_t
310 1.5.2.2 nathanw rt_conv_vol(u_int8_t vol)
311 1.5.2.2 nathanw {
312 1.5.2.2 nathanw if (vol < VOLUME_RATIO(1))
313 1.5.2.2 nathanw return 0;
314 1.5.2.2 nathanw else if (vol >= VOLUME_RATIO(1) && vol < VOLUME_RATIO(2))
315 1.5.2.2 nathanw return 1;
316 1.5.2.2 nathanw else if (vol >= VOLUME_RATIO(2) && vol < VOLUME_RATIO(3))
317 1.5.2.2 nathanw return 2;
318 1.5.2.2 nathanw else if (vol >= VOLUME_RATIO(3) && vol < VOLUME_RATIO(4))
319 1.5.2.2 nathanw return 3;
320 1.5.2.2 nathanw else
321 1.5.2.2 nathanw return 4;
322 1.5.2.2 nathanw }
323 1.5.2.2 nathanw
324 1.5.2.2 nathanw /*
325 1.5.2.2 nathanw * Convert volume from hardware representation
326 1.5.2.2 nathanw */
327 1.5.2.2 nathanw u_int8_t
328 1.5.2.2 nathanw rt_unconv_vol(u_int8_t vol)
329 1.5.2.2 nathanw {
330 1.5.2.2 nathanw return VOLUME_RATIO(vol);
331 1.5.2.2 nathanw }
332 1.5.2.2 nathanw
333 1.5.2.2 nathanw int
334 1.5.2.2 nathanw rt_find(bus_space_tag_t iot, bus_space_handle_t ioh)
335 1.5.2.2 nathanw {
336 1.5.2.2 nathanw struct rt_softc sc;
337 1.5.2.2 nathanw #if 0
338 1.5.2.2 nathanw u_int i, scanres = 0;
339 1.5.2.2 nathanw #endif
340 1.5.2.2 nathanw
341 1.5.2.2 nathanw sc.lm.iot = iot;
342 1.5.2.2 nathanw sc.lm.ioh = ioh;
343 1.5.2.2 nathanw sc.lm.offset = 0;
344 1.5.2.2 nathanw sc.lm.wzcl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_OFF;
345 1.5.2.2 nathanw sc.lm.wzch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_OFF;
346 1.5.2.2 nathanw sc.lm.wocl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_ON;
347 1.5.2.2 nathanw sc.lm.woch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_ON;
348 1.5.2.2 nathanw sc.lm.initdata = 0;
349 1.5.2.2 nathanw sc.lm.rsetdata = RT_SIGNAL_METER;
350 1.5.2.2 nathanw sc.lm.init = rt_lm700x_init;
351 1.5.2.2 nathanw sc.lm.rset = rt_lm700x_rset;
352 1.5.2.2 nathanw sc.rf = LM700X_REF_050;
353 1.5.2.2 nathanw sc.mute = 0;
354 1.5.2.2 nathanw sc.stereo = LM700X_STEREO;
355 1.5.2.2 nathanw sc.vol = 0;
356 1.5.2.2 nathanw
357 1.5.2.2 nathanw /*
358 1.5.2.2 nathanw * Scan whole FM range. If there is a card it'll
359 1.5.2.2 nathanw * respond on some frequency.
360 1.5.2.2 nathanw */
361 1.5.2.2 nathanw return 0;
362 1.5.2.2 nathanw #if 0
363 1.5.2.2 nathanw for (i = MIN_FM_FREQ; !scanres && i < MAX_FM_FREQ; i += 10) {
364 1.5.2.2 nathanw rt_set_freq(&sc, i);
365 1.5.2.2 nathanw scanres += rt_state(iot, ioh);
366 1.5.2.2 nathanw }
367 1.5.2.2 nathanw
368 1.5.2.2 nathanw return scanres;
369 1.5.2.2 nathanw #endif
370 1.5.2.2 nathanw }
371 1.5.2.2 nathanw
372 1.5.2.2 nathanw void
373 1.5.2.2 nathanw rt_lm700x_init(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
374 1.5.2.2 nathanw u_int32_t data)
375 1.5.2.2 nathanw {
376 1.5.2.2 nathanw /* Do nothing */
377 1.5.2.2 nathanw return;
378 1.5.2.2 nathanw }
379 1.5.2.2 nathanw
380 1.5.2.2 nathanw void
381 1.5.2.2 nathanw rt_lm700x_rset(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
382 1.5.2.2 nathanw u_int32_t data)
383 1.5.2.2 nathanw {
384 1.5.2.2 nathanw DELAY(1000);
385 1.5.2.2 nathanw bus_space_write_1(iot, ioh, off, RT_CARD_OFF | data);
386 1.5.2.2 nathanw DELAY(50000);
387 1.5.2.2 nathanw bus_space_write_1(iot, ioh, off, RT_VOLUME_STEADY | RT_CARD_ON | data);
388 1.5.2.2 nathanw }
389 1.5.2.2 nathanw
390 1.5.2.2 nathanw int
391 1.5.2.2 nathanw rt_set_info(void *v, struct radio_info *ri)
392 1.5.2.2 nathanw {
393 1.5.2.2 nathanw struct rt_softc *sc = v;
394 1.5.2.2 nathanw
395 1.5.2.2 nathanw sc->mute = ri->mute ? 1 : 0;
396 1.5.2.2 nathanw sc->vol = rt_conv_vol(ri->volume);
397 1.5.2.2 nathanw sc->stereo = ri->stereo ? LM700X_STEREO : LM700X_MONO;
398 1.5.2.2 nathanw sc->rf = lm700x_encode_ref(ri->rfreq);
399 1.5.2.2 nathanw
400 1.5.2.2 nathanw rt_set_freq(sc, ri->freq);
401 1.5.2.2 nathanw rt_set_mute(sc, sc->vol);
402 1.5.2.2 nathanw
403 1.5.2.2 nathanw return (0);
404 1.5.2.2 nathanw }
405 1.5.2.2 nathanw
406 1.5.2.2 nathanw int
407 1.5.2.2 nathanw rt_get_info(void *v, struct radio_info *ri)
408 1.5.2.2 nathanw {
409 1.5.2.2 nathanw struct rt_softc *sc = v;
410 1.5.2.2 nathanw
411 1.5.2.2 nathanw ri->mute = sc->mute;
412 1.5.2.2 nathanw ri->volume = rt_unconv_vol(sc->vol);
413 1.5.2.2 nathanw ri->stereo = sc->stereo == LM700X_STEREO ? 0 : 1;
414 1.5.2.2 nathanw ri->caps = RTRACK_CAPABILITIES;
415 1.5.2.2 nathanw ri->rfreq = lm700x_decode_ref(sc->rf);
416 1.5.2.2 nathanw ri->info = 3 & rt_state(sc->lm.iot, sc->lm.ioh);
417 1.5.2.2 nathanw ri->freq = sc->freq;
418 1.5.2.2 nathanw
419 1.5.2.2 nathanw /* UNSUPPORTED */
420 1.5.2.2 nathanw ri->lock = 0;
421 1.5.2.2 nathanw
422 1.5.2.2 nathanw return (0);
423 1.5.2.2 nathanw }
424