1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
/* $OpenBSD: fmsradio.c,v 1.6 2002/06/06 16:29:37 mickey Exp $ */
/*
* Copyright (c) 2002 Vladimir Popov <jumbo@narod.ru>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* Device Driver for FM Tuners attached to FM801 */
/* Currently supported tuners:
* o SoundForte RadioLink SF64-PCR PCI Radio Card
* o SoundForte Quad X-treme SF256-PCP-R PCI Sound Card with FM Radio
* o SoundForte Theatre X-treme 5.1 SF256-PCS-R PCI Sound Card with FM Radio
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/audioio.h>
#include <sys/radioio.h>
#include <machine/bus.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
#include <dev/audio_if.h>
#include <dev/radio_if.h>
#include <dev/ic/ac97.h>
#include <dev/pci/fmsreg.h>
#include <dev/pci/fmsvar.h>
#include <dev/ic/tea5757.h>
#define TUNER_UNKNOWN 0
#define TUNER_SF256PCPR 1
#define TUNER_SF64PCR 2
#define TUNER_SF256PCS 3
#define SF64PCR_CAPS RADIO_CAPS_DETECT_STEREO | \
RADIO_CAPS_DETECT_SIGNAL | \
RADIO_CAPS_SET_MONO | \
RADIO_CAPS_HW_SEARCH | \
RADIO_CAPS_HW_AFC | \
RADIO_CAPS_LOCK_SENSITIVITY
#define SF256PCPR_CAPS RADIO_CAPS_DETECT_STEREO | \
RADIO_CAPS_SET_MONO | \
RADIO_CAPS_HW_SEARCH | \
RADIO_CAPS_HW_AFC | \
RADIO_CAPS_LOCK_SENSITIVITY
#define SF256PCS_CAPS RADIO_CAPS_SET_MONO | \
RADIO_CAPS_HW_SEARCH | \
RADIO_CAPS_HW_AFC | \
RADIO_CAPS_LOCK_SENSITIVITY
#define PCR_WREN_ON 0
#define PCR_WREN_OFF FM_IO_PIN1
#define PCR_CLOCK_ON FM_IO_PIN0
#define PCR_CLOCK_OFF 0
#define PCR_DATA_ON FM_IO_PIN2
#define PCR_DATA_OFF 0
#define PCR_SIGNAL 0x80
#define PCR_STEREO 0x80
#define PCR_INFO_SIGNAL (1 << 24)
#define PCR_INFO_STEREO (1 << 25)
#define PCPR_WREN_ON 0
#define PCPR_WREN_OFF FM_IO_PIN2
#define PCPR_CLOCK_ON FM_IO_PIN0
#define PCPR_CLOCK_OFF 0
#define PCPR_DATA_ON FM_IO_PIN1
#define PCPR_DATA_OFF 0
#define PCPR_INFO_STEREO 0x04
#define PCS_WREN_ON 0
#define PCS_WREN_OFF FM_IO_PIN2
#define PCS_CLOCK_ON FM_IO_PIN3
#define PCS_CLOCK_OFF 0
#define PCS_DATA_ON FM_IO_PIN1
#define PCS_DATA_OFF 0
/*
* Function prototypes
*/
void fmsradio_set_mute(struct fms_softc *);
void sf64pcr_init(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void sf64pcr_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void sf64pcr_write_bit(bus_space_tag_t, bus_space_handle_t, bus_size_t, int);
u_int32_t sf64pcr_hw_read(bus_space_tag_t, bus_space_handle_t, bus_size_t);
int sf64pcr_probe(struct fms_softc *);
void sf256pcpr_init(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void sf256pcpr_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void sf256pcpr_write_bit(bus_space_tag_t, bus_space_handle_t, bus_size_t, int);
u_int32_t sf256pcpr_hw_read(bus_space_tag_t, bus_space_handle_t, bus_size_t);
int sf256pcpr_probe(struct fms_softc *);
void sf256pcs_init(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void sf256pcs_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
void sf256pcs_write_bit(bus_space_tag_t, bus_space_handle_t, bus_size_t, int);
u_int32_t sf256pcs_hw_read(bus_space_tag_t, bus_space_handle_t, bus_size_t);
int sf256pcs_probe(struct fms_softc *);
int fmsradio_get_info(void *, struct radio_info *);
int fmsradio_set_info(void *, struct radio_info *);
int fmsradio_search(void *, int);
struct radio_hw_if fmsradio_hw_if = {
NULL, /* open */
NULL, /* close */
fmsradio_get_info,
fmsradio_set_info,
fmsradio_search
};
struct fmsradio_if {
int type; /* Card type */
int mute;
u_int8_t vol;
u_int32_t freq;
u_int32_t stereo;
u_int32_t lock;
struct tea5757_t tea;
};
int
fmsradio_attach(struct fms_softc *sc)
{
struct fmsradio_if *r;
r = malloc(sizeof(struct fmsradio_if), M_DEVBUF, M_NOWAIT);
if (r == NULL) {
printf("%s: cannot allocate memory for FM tuner config\n",
sc->sc_dev.dv_xname);
return TUNER_UNKNOWN;
}
sc->radio = r;
r->tea.iot = sc->sc_iot;
r->tea.ioh = sc->sc_ioh;
r->tea.offset = FM_IO_CTL;
r->tea.flags = sc->sc_dev.dv_cfdata->cf_flags;
r->vol = 0;
r->mute = 0;
r->freq = MIN_FM_FREQ;
r->stereo = TEA5757_STEREO;
r->lock = TEA5757_S030;
r->type = TUNER_UNKNOWN;
if ((r->type = sf64pcr_probe(sc)) == TUNER_SF64PCR)
printf("%s: SF64-PCR FM Radio\n", sc->sc_dev.dv_xname);
else if ((r->type = sf256pcpr_probe(sc)) == TUNER_SF256PCPR)
printf("%s: SF256-PCP-R FM Radio\n", sc->sc_dev.dv_xname);
else if ((r->type = sf256pcs_probe(sc)) == TUNER_SF256PCS)
printf("%s: SF256-PCS-R FM Radio\n", sc->sc_dev.dv_xname);
else
return TUNER_UNKNOWN;
fmsradio_set_mute(sc);
radio_attach_mi(&fmsradio_hw_if, sc, &sc->sc_dev);
return r->type;
}
/* SF256-PCS specific routines */
int
sf256pcs_probe(struct fms_softc *sc)
{
struct fmsradio_if *radio = (struct fmsradio_if *)sc->radio;
u_int32_t freq;
radio->tea.init = sf256pcs_init;
radio->tea.rset = sf256pcs_rset;
radio->tea.write_bit = sf256pcs_write_bit;
radio->tea.read = sf256pcs_hw_read;
tea5757_set_freq(&radio->tea, radio->stereo,
radio->lock, radio->freq);
freq = tea5757_decode_freq(sf256pcs_hw_read(radio->tea.iot,
radio->tea.ioh, radio->tea.offset),
radio->tea.flags & TEA5757_TEA5759);
if (freq != radio->freq)
return TUNER_UNKNOWN;
return TUNER_SF256PCS;
}
u_int32_t
sf256pcs_hw_read(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t offset)
{
u_int32_t res = 0ul;
u_int16_t i, d;
d = FM_IO_GPIO(FM_IO_PIN1 | FM_IO_PIN2 | FM_IO_PIN3) | PCS_WREN_OFF;
/* Now read data in */
d |= FM_IO_GPIO_IN(PCS_DATA_ON) | PCS_DATA_ON;
bus_space_write_2(iot, ioh, offset, d | PCS_CLOCK_OFF);
/* Read the register */
i = 24;
while (i--) {
res <<= 1;
bus_space_write_2(iot, ioh, offset, d | PCS_CLOCK_ON);
bus_space_write_2(iot, ioh, offset, d | PCS_CLOCK_OFF);
res |= bus_space_read_2(iot, ioh, offset) &
PCS_DATA_ON ? 1 : 0;
}
return (res & (TEA5757_DATA | TEA5757_FREQ));
}
void
sf256pcs_write_bit(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t off, int bit)
{
u_int16_t data, wren;
wren = FM_IO_GPIO(FM_IO_PIN1 | FM_IO_PIN2 | FM_IO_PIN3);
wren |= PCS_WREN_ON;
data = bit ? PCPR_DATA_ON : PCS_DATA_OFF;
bus_space_write_2(iot, ioh, off, PCS_CLOCK_OFF | wren | data);
bus_space_write_2(iot, ioh, off, PCS_CLOCK_ON | wren | data);
bus_space_write_2(iot, ioh, off, PCS_CLOCK_OFF | wren | data);
}
void
sf256pcs_init(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset, u_int32_t d)
{
d = FM_IO_GPIO(FM_IO_PIN1 | FM_IO_PIN2 | FM_IO_PIN3);
d |= PCS_WREN_ON | PCS_DATA_OFF | PCS_CLOCK_OFF;
bus_space_write_2(iot, ioh, offset, d);
bus_space_write_2(iot, ioh, offset, d);
}
void
sf256pcs_rset(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset, u_int32_t d)
{
d = FM_IO_GPIO(FM_IO_PIN1 | FM_IO_PIN2 | FM_IO_PIN3);
d |= PCS_WREN_OFF | PCS_DATA_OFF | PCS_CLOCK_OFF;
bus_space_write_2(iot, ioh, offset, d);
bus_space_write_2(iot, ioh, offset, d);
}
/* SF256-PCP-R specific routines */
int
sf256pcpr_probe(struct fms_softc *sc)
{
struct fmsradio_if *radio = (struct fmsradio_if *)sc->radio;
u_int32_t freq;
radio->tea.init = sf256pcpr_init;
radio->tea.rset = sf256pcpr_rset;
radio->tea.write_bit = sf256pcpr_write_bit;
radio->tea.read = sf256pcpr_hw_read;
tea5757_set_freq(&radio->tea, radio->stereo,
radio->lock, radio->freq);
freq = tea5757_decode_freq(sf256pcpr_hw_read(radio->tea.iot,
radio->tea.ioh, radio->tea.offset),
radio->tea.flags & TEA5757_TEA5759);
if (freq != radio->freq)
return TUNER_UNKNOWN;
return TUNER_SF256PCPR;
}
u_int32_t
sf256pcpr_hw_read(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset)
{
u_int32_t res = 0ul;
u_int16_t i, d;
d = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(PCPR_DATA_ON | FM_IO_PIN3);
/* Now read data in */
d |= PCPR_WREN_OFF | PCPR_DATA_ON;
bus_space_write_2(iot, ioh, offset, d | PCPR_CLOCK_OFF);
/* Read the register */
i = 24;
while (i--) {
res <<= 1;
bus_space_write_2(iot, ioh, offset, d | PCPR_CLOCK_ON);
bus_space_write_2(iot, ioh, offset, d | PCPR_CLOCK_OFF);
res |= bus_space_read_2(iot, ioh, offset) &
PCPR_DATA_ON ? 1 : 0;
}
return (res & (TEA5757_DATA | TEA5757_FREQ));
}
void
sf256pcpr_write_bit(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t off, int bit)
{
u_int16_t data, wren;
wren = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(FM_IO_PIN3) | PCPR_WREN_ON;
data = bit ? PCPR_DATA_ON : PCPR_DATA_OFF;
bus_space_write_2(iot, ioh, off, PCPR_CLOCK_OFF | wren | data);
bus_space_write_2(iot, ioh, off, PCPR_CLOCK_ON | wren | data);
bus_space_write_2(iot, ioh, off, PCPR_CLOCK_OFF | wren | data);
}
void
sf256pcpr_init(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset, u_int32_t d)
{
d = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(FM_IO_PIN3);
d |= PCPR_WREN_ON | PCPR_DATA_OFF | PCPR_CLOCK_OFF;
bus_space_write_2(iot, ioh, offset, d);
bus_space_write_2(iot, ioh, offset, d);
}
void
sf256pcpr_rset(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset, u_int32_t d)
{
d = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(FM_IO_PIN3);
d |= PCPR_WREN_OFF | PCPR_DATA_OFF | PCPR_CLOCK_OFF;
bus_space_write_2(iot, ioh, offset, d);
bus_space_write_2(iot, ioh, offset, d);
}
/* SF64-PCR specific routines */
int
sf64pcr_probe(struct fms_softc *sc)
{
struct fmsradio_if *radio = (struct fmsradio_if *)sc->radio;
u_int32_t freq;
radio->tea.init = sf64pcr_init;
radio->tea.rset = sf64pcr_rset;
radio->tea.write_bit = sf64pcr_write_bit;
radio->tea.read = sf64pcr_hw_read;
tea5757_set_freq(&radio->tea, radio->stereo,
radio->lock, radio->freq);
freq = tea5757_decode_freq(sf64pcr_hw_read(radio->tea.iot,
radio->tea.ioh, radio->tea.offset),
radio->tea.flags & TEA5757_TEA5759);
if (freq != radio->freq)
return TUNER_UNKNOWN;
return TUNER_SF64PCR;
}
u_int32_t
sf64pcr_hw_read(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t offset)
{
u_int32_t res = 0ul;
u_int16_t d, i, ind = 0;
d = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(PCR_DATA_ON | FM_IO_PIN3);
/* Now read data in */
d |= PCR_WREN_OFF | PCR_DATA_ON;
bus_space_write_2(iot, ioh, offset, d | PCR_CLOCK_OFF);
DELAY(4);
/* Read the register */
i = 23;
while (i--) {
bus_space_write_2(iot, ioh, offset, d | PCR_CLOCK_ON);
DELAY(4);
bus_space_write_2(iot, ioh, offset, d | PCR_CLOCK_OFF);
DELAY(4);
res |= bus_space_read_2(iot, ioh, offset) & PCR_DATA_ON ? 1 : 0;
res <<= 1;
}
bus_space_write_2(iot, ioh, offset, d | PCR_CLOCK_ON);
DELAY(4);
i = bus_space_read_1(iot, ioh, offset);
ind = i & PCR_SIGNAL ? (1 << 1) : (0 << 1); /* Tuning */
bus_space_write_2(iot, ioh, offset, d | PCR_CLOCK_OFF);
i = bus_space_read_2(iot, ioh, offset);
ind |= i & PCR_STEREO ? (1 << 0) : (0 << 0); /* Mono */
res |= i & PCR_DATA_ON ? (1 << 0) : (0 << 0);
return (res & (TEA5757_DATA | TEA5757_FREQ)) | (ind << 24);
}
void
sf64pcr_write_bit(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t off, int bit)
{
u_int16_t data, wren;
wren = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(FM_IO_PIN3) | PCR_WREN_ON;
data = bit ? PCR_DATA_ON : PCR_DATA_OFF;
bus_space_write_2(iot, ioh, off, PCR_CLOCK_OFF | wren | data);
DELAY(4);
bus_space_write_2(iot, ioh, off, PCR_CLOCK_ON | wren | data);
DELAY(4);
bus_space_write_2(iot, ioh, off, PCR_CLOCK_OFF | wren | data);
DELAY(4);
}
void
sf64pcr_init(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset, u_int32_t d)
{
d = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(FM_IO_PIN3);
d |= PCR_WREN_ON | PCR_DATA_ON | PCR_CLOCK_OFF;
bus_space_write_2(iot, ioh, offset, d);
DELAY(4);
}
void
sf64pcr_rset(bus_space_tag_t iot, bus_space_handle_t ioh,
bus_size_t offset, u_int32_t d)
{
/* Do nothing */
return;
}
/* Common tuner routines */
/*
* Mute/unmute
*/
void
fmsradio_set_mute(struct fms_softc *sc)
{
struct fmsradio_if *radio = (struct fmsradio_if *)sc->radio;
u_int16_t v, mute, unmute;
switch (radio->type) {
case TUNER_SF256PCS:
mute = FM_IO_GPIO(FM_IO_PIN1 | FM_IO_PIN2 | FM_IO_PIN3);
unmute = mute | PCS_WREN_OFF;
break;
case TUNER_SF256PCPR:
mute = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(FM_IO_PIN3);
unmute = mute | PCPR_WREN_OFF;
break;
case TUNER_SF64PCR:
mute = FM_IO_GPIO_ALL | FM_IO_GPIO_IN(FM_IO_PIN3);
unmute = mute | PCR_WREN_OFF;
break;
default:
return;
}
v = (radio->mute || !radio->vol) ? mute : unmute;
bus_space_write_2(radio->tea.iot, radio->tea.ioh,
radio->tea.offset, v);
DELAY(64);
bus_space_write_2(radio->tea.iot, radio->tea.ioh,
radio->tea.offset, v);
}
int
fmsradio_get_info(void *v, struct radio_info *ri)
{
struct fms_softc *sc = v;
struct fmsradio_if *radio = (struct fmsradio_if *)sc->radio;
u_int32_t buf;
ri->mute = radio->mute;
ri->volume = radio->vol ? 255 : 0;
ri->stereo = radio->stereo == TEA5757_STEREO ? 1 : 0;
ri->lock = tea5757_decode_lock(radio->lock);
switch (radio->type) {
case TUNER_SF256PCS:
ri->caps = SF256PCS_CAPS;
buf = sf256pcs_hw_read(radio->tea.iot, radio->tea.ioh,
radio->tea.offset);
ri->info = 0; /* UNSUPPORTED */
break;
case TUNER_SF256PCPR:
ri->caps = SF256PCPR_CAPS;
buf = sf256pcpr_hw_read(radio->tea.iot, radio->tea.ioh,
radio->tea.offset);
ri->info = bus_space_read_2(radio->tea.iot, radio->tea.ioh,
FM_VOLUME) == PCPR_INFO_STEREO ?
RADIO_INFO_STEREO : 0;
break;
case TUNER_SF64PCR:
ri->caps = SF64PCR_CAPS;
buf = sf64pcr_hw_read(radio->tea.iot, radio->tea.ioh,
radio->tea.offset);
ri->info = buf & PCR_INFO_SIGNAL ? 0 : RADIO_INFO_SIGNAL;
ri->info |= buf & PCR_INFO_STEREO ? 0 : RADIO_INFO_STEREO;
break;
default:
break;
}
ri->freq = radio->freq = tea5757_decode_freq(buf,
sc->sc_dev.dv_cfdata->cf_flags & TEA5757_TEA5759);
fmsradio_set_mute(sc);
/* UNSUPPORTED */
ri->rfreq = 0;
return (0);
}
int
fmsradio_set_info(void *v, struct radio_info *ri)
{
struct fms_softc *sc = v;
struct fmsradio_if *radio = (struct fmsradio_if *)sc->radio;
radio->mute = ri->mute ? 1 : 0;
radio->vol = ri->volume ? 255 : 0;
radio->stereo = ri->stereo ? TEA5757_STEREO: TEA5757_MONO;
radio->lock = tea5757_encode_lock(ri->lock);
ri->freq = radio->freq = tea5757_set_freq(&radio->tea,
radio->lock, radio->stereo, ri->freq);
fmsradio_set_mute(sc);
return (0);
}
int
fmsradio_search(void *v, int f)
{
struct fms_softc *sc = v;
struct fmsradio_if *radio = (struct fmsradio_if *)sc->radio;
tea5757_search(&radio->tea, radio->lock,
radio->stereo, f);
fmsradio_set_mute(sc);
return (0);
}
|