diff options
-rw-r--r-- | sys/dev/ic/tea5757.c | 31 | ||||
-rw-r--r-- | sys/dev/ic/tea5757.h | 9 | ||||
-rw-r--r-- | sys/dev/isa/radiotrack.c | 4 | ||||
-rw-r--r-- | sys/dev/isa/radiotrack2.c | 20 | ||||
-rw-r--r-- | sys/dev/isa/sf16fmr2.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/maxiradio.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/sf64pcr.c | 20 |
7 files changed, 69 insertions, 46 deletions
diff --git a/sys/dev/ic/tea5757.c b/sys/dev/ic/tea5757.c index 3a2be1c0e17..3a4bafa3dc6 100644 --- a/sys/dev/ic/tea5757.c +++ b/sys/dev/ic/tea5757.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tea5757.c,v 1.2 2001/12/06 16:28:18 mickey Exp $ */ +/* $OpenBSD: tea5757.c,v 1.3 2002/01/07 18:32:19 mickey Exp $ */ /* * Copyright (c) 2001 Vladimir Popov <jumbo@narod.ru> @@ -60,18 +60,19 @@ * Convert frequency to hardware representation */ u_int32_t -tea5757_encode_freq(u_int32_t freq) +tea5757_encode_freq(u_int32_t freq, int tea5759) { -#ifdef RADIO_TEA5759 - freq -= IF_FREQ; -#else - freq += IF_FREQ; -#endif /* RADIO_TEA5759 */ + if (tea5759) + freq -= IF_FREQ; + else + freq += IF_FREQ; + /* * NO FLOATING POINT! */ freq *= 10; freq /= 125; + return freq & TEA5757_FREQ; } @@ -79,16 +80,17 @@ tea5757_encode_freq(u_int32_t freq) * Convert frequency from hardware representation */ u_int32_t -tea5757_decode_freq(u_int32_t freq) +tea5757_decode_freq(u_int32_t freq, int tea5759) { freq &= TEA5757_FREQ; freq *= 125; /* 12.5 kHz */ freq /= 10; -#ifdef RADIO_TEA5759 - freq += IF_FREQ; -#else - freq -= IF_FREQ; -#endif /* RADIO_TEA5759 */ + + if (tea5759) + freq += IF_FREQ; + else + freq -= IF_FREQ; + return freq; } @@ -139,7 +141,8 @@ tea5757_set_freq(struct tea5757_t *tea, u_int32_t stereo, u_int32_t lock, u_int3 if (freq > MAX_FM_FREQ) freq = MAX_FM_FREQ; - data = tea5757_encode_freq(freq) | stereo | lock | TEA5757_SEARCH_END; + data |= tea5757_encode_freq(freq, tea->flags & TEA5757_TEA5759); + data |= stereo | lock | TEA5757_SEARCH_END; tea5757_hardware_write(tea, data); return freq; diff --git a/sys/dev/ic/tea5757.h b/sys/dev/ic/tea5757.h index 0b1aa349fdb..7f5af70cdce 100644 --- a/sys/dev/ic/tea5757.h +++ b/sys/dev/ic/tea5757.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tea5757.h,v 1.2 2001/12/06 16:28:18 mickey Exp $ */ +/* $OpenBSD: tea5757.h,v 1.3 2002/01/07 18:32:19 mickey Exp $ */ /* $RuOBSD: tea5757.h,v 1.2 2001/10/18 16:51:36 pva Exp $ */ /* @@ -61,10 +61,13 @@ #define TEA5757_S030 (1 << 16) /* 0x0010000 * > 30 mkV */ #define TEA5757_S150 (3 << 16) /* 0x0030000 * > 150 mkV */ +#define TEA5757_TEA5759 (1 << 0) + struct tea5757_t { bus_space_tag_t iot; bus_space_handle_t ioh; bus_size_t offset; + int flags; void (*init)(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t); /* init value */ @@ -75,8 +78,8 @@ struct tea5757_t { u_int32_t (*read)(bus_space_tag_t, bus_space_handle_t, bus_size_t); }; -u_int32_t tea5757_encode_freq(u_int32_t); -u_int32_t tea5757_decode_freq(u_int32_t); +u_int32_t tea5757_encode_freq(u_int32_t, int); +u_int32_t tea5757_decode_freq(u_int32_t, int); u_int32_t tea5757_encode_lock(u_int8_t); u_int8_t tea5757_decode_lock(u_int32_t); diff --git a/sys/dev/isa/radiotrack.c b/sys/dev/isa/radiotrack.c index 4e66b89c792..a2534459bee 100644 --- a/sys/dev/isa/radiotrack.c +++ b/sys/dev/isa/radiotrack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiotrack.c,v 1.2 2002/01/02 19:36:50 mickey Exp $ */ +/* $OpenBSD: radiotrack.c,v 1.3 2002/01/07 18:32:19 mickey Exp $ */ /* $RuOBSD: radiotrack.c,v 1.3 2001/10/18 16:51:36 pva Exp $ */ /* @@ -132,7 +132,7 @@ u_int8_t rt_conv_vol(u_int8_t); u_int8_t rt_unconv_vol(u_int8_t); int -rt_probe(struct device *parent, void *self, void *aux) +rt_probe(struct device *parent, void *match, void *aux) { struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; diff --git a/sys/dev/isa/radiotrack2.c b/sys/dev/isa/radiotrack2.c index 99c4345392b..0a78c8ee6d6 100644 --- a/sys/dev/isa/radiotrack2.c +++ b/sys/dev/isa/radiotrack2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: radiotrack2.c,v 1.2 2002/01/02 19:36:51 mickey Exp $ */ +/* $OpenBSD: radiotrack2.c,v 1.3 2002/01/07 18:32:19 mickey Exp $ */ /* $RuOBSD: radiotrack2.c,v 1.2 2001/10/18 16:51:36 pva Exp $ */ /* @@ -113,7 +113,7 @@ struct cfdriver rtii_cd = { }; void rtii_set_mute(struct rtii_softc *); -int rtii_find(bus_space_tag_t, bus_space_handle_t); +int rtii_find(bus_space_tag_t, bus_space_handle_t, int); u_int32_t rtii_hw_read(bus_space_tag_t, bus_space_handle_t, bus_size_t); @@ -122,12 +122,12 @@ void rtii_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t); void rtii_write_bit(bus_space_tag_t, bus_space_handle_t, bus_size_t, int); int -rtii_probe(struct device *parent, void *self, void *aux) +rtii_probe(struct device *parent, void *match, void *aux) { struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; - + struct cfdata *cf = match; int iosize = 1, iobase = ia->ia_iobase; if (!RTII_BASE_VALID(iobase)) { @@ -138,7 +138,7 @@ rtii_probe(struct device *parent, void *self, void *aux) if (bus_space_map(iot, iobase, iosize, 0, &ioh)) return (0); - if (!rtii_find(iot, ioh)) { + if (!rtii_find(iot, ioh, cf->cf_flags)) { bus_space_unmap(iot, ioh, iosize); return (0); } @@ -153,6 +153,7 @@ rtii_attach(struct device *parent, struct device *self, void *aux) { struct rtii_softc *sc = (void *) self; struct isa_attach_args *ia = aux; + struct cfdata *cf = sc->dev.dv_cfdata; sc->tea.iot = ia->ia_iot; sc->mute = 0; @@ -169,6 +170,7 @@ rtii_attach(struct device *parent, struct device *self, void *aux) } sc->tea.offset = 0; + sc->tea.flags = cf->cf_flags; sc->tea.init = rtii_init; sc->tea.rset = rtii_rset; @@ -211,7 +213,7 @@ rtii_rset(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, u_int32_t } int -rtii_find(bus_space_tag_t iot, bus_space_handle_t ioh) +rtii_find(bus_space_tag_t iot, bus_space_handle_t ioh, int flags) { struct rtii_softc sc; u_int32_t freq; @@ -219,6 +221,7 @@ rtii_find(bus_space_tag_t iot, bus_space_handle_t ioh) sc.tea.iot = iot; sc.tea.ioh = ioh; sc.tea.offset = 0; + sc.tea.flags = flags; sc.tea.init = rtii_init; sc.tea.rset = rtii_rset; sc.tea.write_bit = rtii_write_bit; @@ -235,7 +238,8 @@ rtii_find(bus_space_tag_t iot, bus_space_handle_t ioh) tea5757_set_freq(&sc.tea, sc.stereo, sc.lock, sc.freq); rtii_set_mute(&sc); freq = rtii_hw_read(iot, ioh, sc.tea.offset); - if (tea5757_decode_freq(freq) == sc.freq) + if (tea5757_decode_freq(freq, sc.tea.flags & TEA5757_TEA5759) + == sc.freq) return 1; return 0; @@ -288,7 +292,7 @@ rtii_get_info(void *v, struct radio_info *ri) ri->lock = tea5757_decode_lock(sc->lock); ri->freq = sc->freq = tea5757_decode_freq(rtii_hw_read(sc->tea.iot, - sc->tea.ioh, sc->tea.offset)); + sc->tea.ioh, sc->tea.offset), sc->tea.flags & TEA5757_TEA5759); switch (bus_space_read_1(sc->tea.iot, sc->tea.ioh, 0)) { case 0xFD: diff --git a/sys/dev/isa/sf16fmr2.c b/sys/dev/isa/sf16fmr2.c index 1362823b21d..42a22076d76 100644 --- a/sys/dev/isa/sf16fmr2.c +++ b/sys/dev/isa/sf16fmr2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sf16fmr2.c,v 1.4 2002/01/02 19:36:51 mickey Exp $ */ +/* $OpenBSD: sf16fmr2.c,v 1.5 2002/01/07 18:32:19 mickey Exp $ */ /* $RuOBSD: sf16fmr2.c,v 1.12 2001/10/18 16:51:36 pva Exp $ */ /* @@ -113,7 +113,7 @@ struct cfdriver sf2r_cd = { }; void sf2r_set_mute(struct sf2r_softc *); -int sf2r_find(bus_space_tag_t, bus_space_handle_t); +int sf2r_find(bus_space_tag_t, bus_space_handle_t, int); u_int32_t sf2r_read_register(bus_space_tag_t, bus_space_handle_t, bus_size_t); @@ -122,12 +122,12 @@ void sf2r_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t); void sf2r_write_bit(bus_space_tag_t, bus_space_handle_t, bus_size_t, int); int -sf2r_probe(struct device *parent, void *self, void *aux) +sf2r_probe(struct device *parent, void *match, void *aux) { struct isa_attach_args *ia = aux; bus_space_tag_t iot = ia->ia_iot; bus_space_handle_t ioh; - + struct cfdata *cf = match; int iosize = 1, iobase = ia->ia_iobase; if (!SF16FMR2_BASE_VALID(iobase)) { @@ -138,7 +138,7 @@ sf2r_probe(struct device *parent, void *self, void *aux) if (bus_space_map(iot, iobase, iosize, 0, &ioh)) return (0); - if (!sf2r_find(iot, ioh)) { + if (!sf2r_find(iot, ioh, cf->cf_flags)) { bus_space_unmap(iot, ioh, iosize); return (0); } @@ -153,6 +153,7 @@ sf2r_attach(struct device *parent, struct device *self, void *aux) { struct sf2r_softc *sc = (void *) self; struct isa_attach_args *ia = aux; + struct cfdata *cf = sc->sc_dev.dv_cfdata; sc->tea.iot = ia->ia_iot; sc->mute = 0; @@ -169,6 +170,7 @@ sf2r_attach(struct device *parent, struct device *self, void *aux) } sc->tea.offset = 0; + sc->tea.flags = cf->cf_flags; sc->tea.init = sf2r_init; sc->tea.rset = sf2r_rset; @@ -210,7 +212,7 @@ sf2r_rset(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, u_int32_t } int -sf2r_find(bus_space_tag_t iot, bus_space_handle_t ioh) +sf2r_find(bus_space_tag_t iot, bus_space_handle_t ioh, int flags) { struct sf2r_softc sc; u_int32_t freq; @@ -218,6 +220,7 @@ sf2r_find(bus_space_tag_t iot, bus_space_handle_t ioh) sc.tea.iot = iot; sc.tea.ioh = ioh; sc.tea.offset = 0; + sc.tea.flags = flags; sc.tea.init = sf2r_init; sc.tea.rset = sf2r_rset; sc.tea.write_bit = sf2r_write_bit; @@ -235,7 +238,8 @@ sf2r_find(bus_space_tag_t iot, bus_space_handle_t ioh) tea5757_set_freq(&sc.tea, sc.stereo, sc.lock, sc.freq); sf2r_set_mute(&sc); freq = sf2r_read_register(iot, ioh, sc.tea.offset); - if (tea5757_decode_freq(freq) == sc.freq) + if (tea5757_decode_freq(freq, sc.tea.flags & TEA5757_TEA5759) + == sc.freq) return 1; } @@ -307,7 +311,8 @@ sf2r_get_info(void *v, struct radio_info *ri) ri->lock = tea5757_decode_lock(sc->lock); buf = sf2r_read_register(sc->tea.iot, sc->tea.ioh, sc->tea.offset); - ri->freq = sc->freq = tea5757_decode_freq(buf); + ri->freq = sc->freq = tea5757_decode_freq(buf, + sc->tea.flags & TEA5757_TEA5759); ri->info = 3 & (buf >> 24); return (0); diff --git a/sys/dev/pci/maxiradio.c b/sys/dev/pci/maxiradio.c index a507d42a529..f0f2461d421 100644 --- a/sys/dev/pci/maxiradio.c +++ b/sys/dev/pci/maxiradio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: maxiradio.c,v 1.3 2002/01/02 22:25:25 mickey Exp $ */ +/* $OpenBSD: maxiradio.c,v 1.4 2002/01/07 18:32:19 mickey Exp $ */ /* $RuOBSD: maxiradio.c,v 1.5 2001/10/18 16:51:36 pva Exp $ */ /* @@ -135,6 +135,7 @@ mr_attach(struct device *parent, struct device *self, void *aux) { struct mr_softc *sc = (struct mr_softc *) self; struct pci_attach_args *pa = aux; + struct cfdata *cf = sc->sc_dev.dv_cfdata; pci_chipset_tag_t pc = pa->pa_pc; pcireg_t csr; @@ -155,11 +156,14 @@ mr_attach(struct device *parent, struct device *self, void *aux) sc->stereo = TEA5757_STEREO; sc->lock = TEA5757_S030; sc->tea.offset = 0; + sc->tea.flags = cf->cf_flags; sc->tea.init = mr_init; sc->tea.rset = mr_rset; sc->tea.write_bit = mr_write_bit; sc->tea.read = mr_hardware_read; + printf(": Guillemot MaxiRadio FM2000 PCI\n"); + radio_attach_mi(&mr_hw_if, sc, &sc->sc_dev); } @@ -176,7 +180,7 @@ mr_get_info(void *v, struct radio_info *ri) ri->lock = tea5757_decode_lock(sc->lock); ri->freq = sc->freq = tea5757_decode_freq(mr_hardware_read(sc->tea.iot, - sc->tea.ioh, sc->tea.offset)); + sc->tea.ioh, sc->tea.offset), sc->tea.flags & TEA5757_TEA5759); ri->info = mr_state(sc->tea.iot, sc->tea.ioh); @@ -193,7 +197,7 @@ mr_set_info(void *v, struct radio_info *ri) sc->stereo = ri->stereo ? TEA5757_STEREO: TEA5757_MONO; sc->lock = tea5757_encode_lock(ri->lock); ri->freq = sc->freq = tea5757_set_freq(&sc->tea, - sc->lock, sc->stereo, ri->freq); + sc->lock, sc->stereo, ri->freq); mr_set_mute(sc); return (0); diff --git a/sys/dev/pci/sf64pcr.c b/sys/dev/pci/sf64pcr.c index 281ba3305a4..1f2d841b0f1 100644 --- a/sys/dev/pci/sf64pcr.c +++ b/sys/dev/pci/sf64pcr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sf64pcr.c,v 1.3 2002/01/02 22:25:25 mickey Exp $ */ +/* $OpenBSD: sf64pcr.c,v 1.4 2002/01/07 18:32:19 mickey Exp $ */ /* $RuOBSD: sf64pcr.c,v 1.11 2001/12/05 10:19:40 mickey Exp $ */ /* @@ -149,12 +149,12 @@ struct cfdriver sf4r_cd = { /* * Function prototypes */ -void sf64pcr_set_mute(struct sf64pcr_softc *); +void sf64pcr_set_mute(struct sf64pcr_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); +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); /* * PCI initialization stuff @@ -164,7 +164,6 @@ sf64pcr_match(struct device *parent, void *match, void *aux) { struct pci_attach_args *pa = aux; /* FIXME: more thorough testing */ - /* desc = "SoundForte RadioLink SF64-PCR PCI"; */ if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_FORTEMEDIA && PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_FORTEMEDIA_FM801) return (1); @@ -176,6 +175,7 @@ sf64pcr_attach(struct device *parent, struct device *self, void *aux) { struct sf64pcr_softc *sc = (struct sf64pcr_softc *) self; struct pci_attach_args *pa = aux; + struct cfdata *cf = sc->dev.dv_cfdata; pci_chipset_tag_t pc = pa->pa_pc; pcireg_t csr; @@ -196,11 +196,14 @@ sf64pcr_attach(struct device *parent, struct device *self, void *aux) sc->stereo = TEA5757_STEREO; sc->lock = TEA5757_S030; sc->tea.offset = SF64PCR_PCI_OFFSET; + sc->tea.flags = cf->cf_flags; sc->tea.init = sf64pcr_init; sc->tea.rset = sf64pcr_rset; sc->tea.write_bit = sf64pcr_write_bit; sc->tea.read = sf64pcr_hw_read; + printf(": SoundForte RadioLink SF64-PCR PCI\n"); + tea5757_set_freq(&sc->tea, sc->lock, sc->stereo, sc->freq); sf64pcr_set_mute(sc); @@ -309,7 +312,8 @@ sf64pcr_get_info(void *v, struct radio_info *ri) ri->lock = tea5757_decode_lock(sc->lock); buf = sf64pcr_hw_read(sc->tea.iot, sc->tea.ioh, sc->tea.offset); - ri->freq = sc->freq = tea5757_decode_freq(buf); + ri->freq = sc->freq = tea5757_decode_freq(buf, + sc->tea.flags & TEA5757_TEA5759); ri->info = buf & SF64PCR_INFO_SIGNAL ? 0 : RADIO_INFO_SIGNAL; ri->info |= buf & SF64PCR_INFO_STEREO ? 0 : RADIO_INFO_STEREO; |