int rtii_get_info(void *v, struct radio_info *ri) { struct rtii_softc *sc = v; ri->mute = sc->mute; ri->volume = sc->vol ? 255 : 0; ri->stereo = sc->stereo == TEA5757_STEREO ? 1 : 0; ri->caps = RTII_CAPABILITIES; ri->rfreq = 0; 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.flags & TEA5757_TEA5759); switch (bus_space_read_1(sc->tea.iot, sc->tea.ioh, 0)) { case 0xFD: ri->info = RADIO_INFO_SIGNAL | RADIO_INFO_STEREO; break; case 0xFF: ri->info = 0; break; default: ri->info = RADIO_INFO_SIGNAL; } return (0); }
int rtii_find(bus_space_tag_t iot, bus_space_handle_t ioh, int flags) { struct rtii_softc sc; u_int32_t freq; 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; sc.tea.read = rtii_hw_read; sc.lock = TEA5757_S030; sc.stereo = TEA5757_STEREO; /* * Let's try to write and read a frequency. * If the written and read frequencies are * the same then success. */ sc.freq = MIN_FM_FREQ; 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.tea.flags & TEA5757_TEA5759) == sc.freq) return 1; return 0; }
int sf2r_find(bus_space_tag_t iot, bus_space_handle_t ioh) { struct sf2r_softc sc; u_int32_t freq; sc.tea.iot = iot; sc.tea.ioh = ioh; sc.tea.offset = 0; sc.tea.init = sf2r_init; sc.tea.rset = sf2r_rset; sc.tea.write_bit = sf2r_write_bit; sc.tea.read = sf2r_read_register; sc.lock = TEA5757_S030; sc.stereo = TEA5757_STEREO; if ((bus_space_read_1(iot, ioh, 0) & 0x70) == 0x30) { /* * Let's try to write and read a frequency. * If the written and read frequencies are * the same then success. */ sc.freq = MIN_FM_FREQ; 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, 0) == sc.freq) return 1; } return 0; }
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 sf2r_get_info(void *v, struct radio_info *ri) { struct sf2r_softc *sc = v; u_int32_t buf; ri->mute = sc->mute; ri->volume = sc->vol ? 255 : 0; ri->stereo = sc->stereo == TEA5757_STEREO ? 1 : 0; ri->caps = SF16FMR2_CAPABILITIES; ri->rfreq = 0; 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, 0); ri->info = 3 & (buf >> 24); return (0); }
/* 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; }