radiotrack.c revision 1.5.2.3 1 1.5.2.3 nathanw /* $NetBSD: radiotrack.c,v 1.5.2.3 2002/01/11 23:39:11 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.2 nathanw struct cfattach rt_ca = {
117 1.5.2.2 nathanw sizeof(struct rt_softc), rt_probe, rt_attach
118 1.5.2.2 nathanw };
119 1.5.2.2 nathanw
120 1.5.2.2 nathanw int rt_find(bus_space_tag_t, bus_space_handle_t);
121 1.5.2.2 nathanw void rt_set_mute(struct rt_softc *, int);
122 1.5.2.2 nathanw void rt_set_freq(struct rt_softc *, u_int32_t);
123 1.5.2.2 nathanw u_int8_t rt_state(bus_space_tag_t, bus_space_handle_t);
124 1.5.2.2 nathanw
125 1.5.2.2 nathanw void rt_lm700x_init(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
126 1.5.2.2 nathanw void rt_lm700x_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
127 1.5.2.2 nathanw
128 1.5.2.2 nathanw u_int8_t rt_conv_vol(u_int8_t);
129 1.5.2.2 nathanw u_int8_t rt_unconv_vol(u_int8_t);
130 1.5.2.2 nathanw
131 1.5.2.2 nathanw int
132 1.5.2.2 nathanw rt_probe(struct device *parent, struct cfdata *cf, void *aux)
133 1.5.2.2 nathanw {
134 1.5.2.2 nathanw struct isa_attach_args *ia = aux;
135 1.5.2.2 nathanw bus_space_tag_t iot = ia->ia_iot;
136 1.5.2.2 nathanw bus_space_handle_t ioh;
137 1.5.2.3 nathanw u_int r;
138 1.5.2.3 nathanw int iosize = 1, iobase;
139 1.5.2.2 nathanw
140 1.5.2.3 nathanw if (ISA_DIRECT_CONFIG(ia))
141 1.5.2.3 nathanw return 0;
142 1.5.2.3 nathanw
143 1.5.2.3 nathanw if (ia->ia_nio < 1)
144 1.5.2.3 nathanw return (0);
145 1.5.2.3 nathanw
146 1.5.2.3 nathanw iobase = ia->ia_io[0].ir_addr;
147 1.5.2.2 nathanw
148 1.5.2.2 nathanw if (!RT_BASE_VALID(iobase)) {
149 1.5.2.2 nathanw printf("rt: configured iobase 0x%x invalid\n", iobase);
150 1.5.2.2 nathanw return 0;
151 1.5.2.2 nathanw }
152 1.5.2.2 nathanw
153 1.5.2.2 nathanw if (bus_space_map(iot, iobase, iosize, 0, &ioh))
154 1.5.2.2 nathanw return 0;
155 1.5.2.2 nathanw
156 1.5.2.3 nathanw r = rt_find(iot, ioh);
157 1.5.2.3 nathanw
158 1.5.2.2 nathanw bus_space_unmap(iot, ioh, iosize);
159 1.5.2.2 nathanw
160 1.5.2.3 nathanw if (r != 0) {
161 1.5.2.3 nathanw ia->ia_nio = 1;
162 1.5.2.3 nathanw ia->ia_io[0].ir_size = iosize;
163 1.5.2.3 nathanw
164 1.5.2.3 nathanw ia->ia_niomem = 0;
165 1.5.2.3 nathanw ia->ia_nirq = 0;
166 1.5.2.3 nathanw ia->ia_ndrq = 0;
167 1.5.2.3 nathanw
168 1.5.2.3 nathanw return (1);
169 1.5.2.3 nathanw }
170 1.5.2.2 nathanw
171 1.5.2.3 nathanw return (0);
172 1.5.2.2 nathanw }
173 1.5.2.2 nathanw
174 1.5.2.2 nathanw void
175 1.5.2.2 nathanw rt_attach(struct device *parent, struct device *self, void *aux)
176 1.5.2.2 nathanw {
177 1.5.2.2 nathanw struct rt_softc *sc = (void *) self;
178 1.5.2.2 nathanw struct isa_attach_args *ia = aux;
179 1.5.2.2 nathanw
180 1.5.2.2 nathanw sc->lm.iot = ia->ia_iot;
181 1.5.2.2 nathanw sc->rf = LM700X_REF_050;
182 1.5.2.2 nathanw sc->stereo = LM700X_STEREO;
183 1.5.2.2 nathanw sc->mute = 0;
184 1.5.2.2 nathanw sc->freq = MIN_FM_FREQ;
185 1.5.2.2 nathanw sc->vol = 0;
186 1.5.2.2 nathanw
187 1.5.2.2 nathanw /* remap I/O */
188 1.5.2.3 nathanw if (bus_space_map(sc->lm.iot, ia->ia_io[0].ir_addr,
189 1.5.2.3 nathanw ia->ia_io[0].ir_size, 0, &sc->lm.ioh))
190 1.5.2.2 nathanw panic(": bus_space_map() of %s failed", sc->sc_dev.dv_xname);
191 1.5.2.2 nathanw
192 1.5.2.3 nathanw switch (ia->ia_io[0].ir_addr) {
193 1.5.2.2 nathanw case 0x20C:
194 1.5.2.2 nathanw /* FALLTHROUGH */
195 1.5.2.2 nathanw case 0x30C:
196 1.5.2.2 nathanw sc->cardtype = CARD_RADIOTRACK;
197 1.5.2.3 nathanw printf(": AIMS Lab Radiotrack or compatible\n");
198 1.5.2.2 nathanw break;
199 1.5.2.2 nathanw case 0x284:
200 1.5.2.2 nathanw /* FALLTHROUGH */
201 1.5.2.2 nathanw case 0x384:
202 1.5.2.2 nathanw sc->cardtype = CARD_SF16FMI;
203 1.5.2.3 nathanw printf(": SoundForte RadioX SF16-FMI\n");
204 1.5.2.2 nathanw break;
205 1.5.2.2 nathanw default:
206 1.5.2.2 nathanw sc->cardtype = CARD_UNKNOWN;
207 1.5.2.3 nathanw printf(": Unknown card\n");
208 1.5.2.2 nathanw break;
209 1.5.2.2 nathanw }
210 1.5.2.2 nathanw
211 1.5.2.2 nathanw /* Configure struct lm700x_t lm */
212 1.5.2.2 nathanw sc->lm.offset = 0;
213 1.5.2.2 nathanw sc->lm.wzcl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_OFF;
214 1.5.2.2 nathanw sc->lm.wzch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_OFF;
215 1.5.2.2 nathanw sc->lm.wocl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_ON;
216 1.5.2.2 nathanw sc->lm.woch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_ON;
217 1.5.2.2 nathanw sc->lm.initdata = 0;
218 1.5.2.2 nathanw sc->lm.rsetdata = RT_DATA_ON | RT_CLCK_ON | RT_WREN_OFF;
219 1.5.2.2 nathanw sc->lm.init = rt_lm700x_init;
220 1.5.2.2 nathanw sc->lm.rset = rt_lm700x_rset;
221 1.5.2.2 nathanw
222 1.5.2.2 nathanw rt_set_freq(sc, sc->freq);
223 1.5.2.2 nathanw
224 1.5.2.2 nathanw radio_attach_mi(&rt_hw_if, sc, &sc->sc_dev);
225 1.5.2.2 nathanw }
226 1.5.2.2 nathanw
227 1.5.2.2 nathanw /*
228 1.5.2.2 nathanw * Mute the card
229 1.5.2.2 nathanw */
230 1.5.2.2 nathanw void
231 1.5.2.2 nathanw rt_set_mute(struct rt_softc *sc, int vol)
232 1.5.2.2 nathanw {
233 1.5.2.2 nathanw int val;
234 1.5.2.2 nathanw
235 1.5.2.2 nathanw if (sc->mute) {
236 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
237 1.5.2.2 nathanw RT_VOLUME_DOWN | RT_CARD_ON);
238 1.5.2.2 nathanw DELAY(MAX_VOL * RT_VOLUME_DELAY);
239 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
240 1.5.2.2 nathanw RT_VOLUME_STEADY | RT_CARD_ON);
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 bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0, RT_CARD_OFF);
243 1.5.2.2 nathanw } else {
244 1.5.2.2 nathanw val = sc->vol - vol;
245 1.5.2.2 nathanw if (val < 0) {
246 1.5.2.2 nathanw val *= -1;
247 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
248 1.5.2.2 nathanw RT_VOLUME_DOWN | RT_CARD_ON);
249 1.5.2.2 nathanw } else {
250 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
251 1.5.2.2 nathanw RT_VOLUME_UP | RT_CARD_ON);
252 1.5.2.2 nathanw }
253 1.5.2.2 nathanw DELAY(val * RT_VOLUME_DELAY);
254 1.5.2.2 nathanw bus_space_write_1(sc->lm.iot, sc->lm.ioh, 0,
255 1.5.2.2 nathanw RT_VOLUME_STEADY | RT_CARD_ON);
256 1.5.2.2 nathanw }
257 1.5.2.2 nathanw }
258 1.5.2.2 nathanw
259 1.5.2.2 nathanw void
260 1.5.2.2 nathanw rt_set_freq(struct rt_softc *sc, u_int32_t nfreq)
261 1.5.2.2 nathanw {
262 1.5.2.2 nathanw u_int32_t reg;
263 1.5.2.2 nathanw
264 1.5.2.2 nathanw if (nfreq > MAX_FM_FREQ)
265 1.5.2.2 nathanw nfreq = MAX_FM_FREQ;
266 1.5.2.2 nathanw if (nfreq < MIN_FM_FREQ)
267 1.5.2.2 nathanw nfreq = MIN_FM_FREQ;
268 1.5.2.2 nathanw
269 1.5.2.2 nathanw sc->freq = nfreq;
270 1.5.2.2 nathanw
271 1.5.2.2 nathanw reg = lm700x_encode_freq(nfreq, sc->rf);
272 1.5.2.2 nathanw reg |= sc->stereo | sc->rf | LM700X_DIVIDER_FM;
273 1.5.2.2 nathanw
274 1.5.2.2 nathanw lm700x_hardware_write(&sc->lm, reg, RT_VOLUME_STEADY);
275 1.5.2.2 nathanw
276 1.5.2.2 nathanw rt_set_mute(sc, sc->vol);
277 1.5.2.2 nathanw }
278 1.5.2.2 nathanw
279 1.5.2.2 nathanw /*
280 1.5.2.2 nathanw * Return state of the card - tuned/not tuned, mono/stereo
281 1.5.2.2 nathanw */
282 1.5.2.2 nathanw u_int8_t
283 1.5.2.2 nathanw rt_state(bus_space_tag_t iot, bus_space_handle_t ioh)
284 1.5.2.2 nathanw {
285 1.5.2.2 nathanw u_int8_t ret;
286 1.5.2.2 nathanw
287 1.5.2.2 nathanw bus_space_write_1(iot, ioh, 0,
288 1.5.2.2 nathanw RT_VOLUME_STEADY | RT_SIGNAL_METER | RT_CARD_ON);
289 1.5.2.2 nathanw DELAY(RT_SIGNAL_METER_DELAY);
290 1.5.2.2 nathanw ret = bus_space_read_1(iot, ioh, 0);
291 1.5.2.2 nathanw
292 1.5.2.2 nathanw switch (ret) {
293 1.5.2.2 nathanw case 0xFD:
294 1.5.2.2 nathanw ret = RADIO_INFO_SIGNAL | RADIO_INFO_STEREO;
295 1.5.2.2 nathanw break;
296 1.5.2.2 nathanw case 0xFF:
297 1.5.2.2 nathanw ret = 0;
298 1.5.2.2 nathanw break;
299 1.5.2.2 nathanw default:
300 1.5.2.2 nathanw ret = RADIO_INFO_SIGNAL;
301 1.5.2.2 nathanw break;
302 1.5.2.2 nathanw }
303 1.5.2.2 nathanw
304 1.5.2.2 nathanw return ret;
305 1.5.2.2 nathanw }
306 1.5.2.2 nathanw
307 1.5.2.2 nathanw /*
308 1.5.2.2 nathanw * Convert volume to hardware representation.
309 1.5.2.2 nathanw */
310 1.5.2.2 nathanw u_int8_t
311 1.5.2.2 nathanw rt_conv_vol(u_int8_t vol)
312 1.5.2.2 nathanw {
313 1.5.2.2 nathanw if (vol < VOLUME_RATIO(1))
314 1.5.2.2 nathanw return 0;
315 1.5.2.2 nathanw else if (vol >= VOLUME_RATIO(1) && vol < VOLUME_RATIO(2))
316 1.5.2.2 nathanw return 1;
317 1.5.2.2 nathanw else if (vol >= VOLUME_RATIO(2) && vol < VOLUME_RATIO(3))
318 1.5.2.2 nathanw return 2;
319 1.5.2.2 nathanw else if (vol >= VOLUME_RATIO(3) && vol < VOLUME_RATIO(4))
320 1.5.2.2 nathanw return 3;
321 1.5.2.2 nathanw else
322 1.5.2.2 nathanw return 4;
323 1.5.2.2 nathanw }
324 1.5.2.2 nathanw
325 1.5.2.2 nathanw /*
326 1.5.2.2 nathanw * Convert volume from hardware representation
327 1.5.2.2 nathanw */
328 1.5.2.2 nathanw u_int8_t
329 1.5.2.2 nathanw rt_unconv_vol(u_int8_t vol)
330 1.5.2.2 nathanw {
331 1.5.2.2 nathanw return VOLUME_RATIO(vol);
332 1.5.2.2 nathanw }
333 1.5.2.2 nathanw
334 1.5.2.2 nathanw int
335 1.5.2.2 nathanw rt_find(bus_space_tag_t iot, bus_space_handle_t ioh)
336 1.5.2.2 nathanw {
337 1.5.2.2 nathanw struct rt_softc sc;
338 1.5.2.2 nathanw #if 0
339 1.5.2.2 nathanw u_int i, scanres = 0;
340 1.5.2.2 nathanw #endif
341 1.5.2.2 nathanw
342 1.5.2.2 nathanw sc.lm.iot = iot;
343 1.5.2.2 nathanw sc.lm.ioh = ioh;
344 1.5.2.2 nathanw sc.lm.offset = 0;
345 1.5.2.2 nathanw sc.lm.wzcl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_OFF;
346 1.5.2.2 nathanw sc.lm.wzch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_OFF;
347 1.5.2.2 nathanw sc.lm.wocl = RT_WREN_ON | RT_CLCK_OFF | RT_DATA_ON;
348 1.5.2.2 nathanw sc.lm.woch = RT_WREN_ON | RT_CLCK_ON | RT_DATA_ON;
349 1.5.2.2 nathanw sc.lm.initdata = 0;
350 1.5.2.2 nathanw sc.lm.rsetdata = RT_SIGNAL_METER;
351 1.5.2.2 nathanw sc.lm.init = rt_lm700x_init;
352 1.5.2.2 nathanw sc.lm.rset = rt_lm700x_rset;
353 1.5.2.2 nathanw sc.rf = LM700X_REF_050;
354 1.5.2.2 nathanw sc.mute = 0;
355 1.5.2.2 nathanw sc.stereo = LM700X_STEREO;
356 1.5.2.2 nathanw sc.vol = 0;
357 1.5.2.2 nathanw
358 1.5.2.2 nathanw /*
359 1.5.2.2 nathanw * Scan whole FM range. If there is a card it'll
360 1.5.2.2 nathanw * respond on some frequency.
361 1.5.2.2 nathanw */
362 1.5.2.2 nathanw return 0;
363 1.5.2.2 nathanw #if 0
364 1.5.2.2 nathanw for (i = MIN_FM_FREQ; !scanres && i < MAX_FM_FREQ; i += 10) {
365 1.5.2.2 nathanw rt_set_freq(&sc, i);
366 1.5.2.2 nathanw scanres += rt_state(iot, ioh);
367 1.5.2.2 nathanw }
368 1.5.2.2 nathanw
369 1.5.2.2 nathanw return scanres;
370 1.5.2.2 nathanw #endif
371 1.5.2.2 nathanw }
372 1.5.2.2 nathanw
373 1.5.2.2 nathanw void
374 1.5.2.2 nathanw rt_lm700x_init(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
375 1.5.2.2 nathanw u_int32_t data)
376 1.5.2.2 nathanw {
377 1.5.2.2 nathanw /* Do nothing */
378 1.5.2.2 nathanw return;
379 1.5.2.2 nathanw }
380 1.5.2.2 nathanw
381 1.5.2.2 nathanw void
382 1.5.2.2 nathanw rt_lm700x_rset(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
383 1.5.2.2 nathanw u_int32_t data)
384 1.5.2.2 nathanw {
385 1.5.2.2 nathanw DELAY(1000);
386 1.5.2.2 nathanw bus_space_write_1(iot, ioh, off, RT_CARD_OFF | data);
387 1.5.2.2 nathanw DELAY(50000);
388 1.5.2.2 nathanw bus_space_write_1(iot, ioh, off, RT_VOLUME_STEADY | RT_CARD_ON | data);
389 1.5.2.2 nathanw }
390 1.5.2.2 nathanw
391 1.5.2.2 nathanw int
392 1.5.2.2 nathanw rt_set_info(void *v, struct radio_info *ri)
393 1.5.2.2 nathanw {
394 1.5.2.2 nathanw struct rt_softc *sc = v;
395 1.5.2.2 nathanw
396 1.5.2.2 nathanw sc->mute = ri->mute ? 1 : 0;
397 1.5.2.2 nathanw sc->vol = rt_conv_vol(ri->volume);
398 1.5.2.2 nathanw sc->stereo = ri->stereo ? LM700X_STEREO : LM700X_MONO;
399 1.5.2.2 nathanw sc->rf = lm700x_encode_ref(ri->rfreq);
400 1.5.2.2 nathanw
401 1.5.2.2 nathanw rt_set_freq(sc, ri->freq);
402 1.5.2.2 nathanw rt_set_mute(sc, sc->vol);
403 1.5.2.2 nathanw
404 1.5.2.2 nathanw return (0);
405 1.5.2.2 nathanw }
406 1.5.2.2 nathanw
407 1.5.2.2 nathanw int
408 1.5.2.2 nathanw rt_get_info(void *v, struct radio_info *ri)
409 1.5.2.2 nathanw {
410 1.5.2.2 nathanw struct rt_softc *sc = v;
411 1.5.2.2 nathanw
412 1.5.2.2 nathanw ri->mute = sc->mute;
413 1.5.2.2 nathanw ri->volume = rt_unconv_vol(sc->vol);
414 1.5.2.2 nathanw ri->stereo = sc->stereo == LM700X_STEREO ? 0 : 1;
415 1.5.2.2 nathanw ri->caps = RTRACK_CAPABILITIES;
416 1.5.2.2 nathanw ri->rfreq = lm700x_decode_ref(sc->rf);
417 1.5.2.2 nathanw ri->info = 3 & rt_state(sc->lm.iot, sc->lm.ioh);
418 1.5.2.2 nathanw ri->freq = sc->freq;
419 1.5.2.2 nathanw
420 1.5.2.2 nathanw /* UNSUPPORTED */
421 1.5.2.2 nathanw ri->lock = 0;
422 1.5.2.2 nathanw
423 1.5.2.2 nathanw return (0);
424 1.5.2.2 nathanw }
425