From 2f5aeb92d37ac8584eaf6163a26fc1403e60ecc6 Mon Sep 17 00:00:00 2001 From: augustss Date: Tue, 3 Sep 2002 18:53:40 +0000 Subject: [PATCH] Use a different way to recognize tea5759 chips. From OpenBSD. --- sys/dev/ic/tea5757.c | 33 ++++++++++++++++++--------------- sys/dev/ic/tea5757.h | 11 +++++++---- sys/dev/isa/radiotrack2.c | 3 ++- sys/dev/isa/sf16fmr2.c | 3 ++- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/sys/dev/ic/tea5757.c b/sys/dev/ic/tea5757.c index a1e0be3a4699..5968840a4f1c 100644 --- a/sys/dev/ic/tea5757.c +++ b/sys/dev/ic/tea5757.c @@ -1,5 +1,5 @@ -/* $NetBSD: tea5757.c,v 1.1 2002/01/01 21:51:40 augustss Exp $ */ -/* $OpenBSD: tea5757.c,v 1.2 2001/12/06 16:28:18 mickey Exp $ */ +/* $NetBSD: tea5757.c,v 1.2 2002/09/03 18:53:40 augustss Exp $ */ +/* $OpenBSD: tea5757.c,v 1.3 2002/01/07 18:32:19 mickey Exp $ */ /* * Copyright (c) 2001 Vladimir Popov @@ -61,18 +61,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; } @@ -80,16 +81,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; } @@ -140,7 +142,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 494f8b81a196..bc1e95768e5b 100644 --- a/sys/dev/ic/tea5757.h +++ b/sys/dev/ic/tea5757.h @@ -1,5 +1,5 @@ -/* $NetBSD: tea5757.h,v 1.1 2002/01/01 21:51:40 augustss Exp $ */ -/* $OpenBSD: tea5757.h,v 1.2 2001/12/06 16:28:18 mickey Exp $ */ +/* $NetBSD: tea5757.h,v 1.2 2002/09/03 18:53:40 augustss 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 $ */ /* @@ -62,10 +62,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 */ @@ -76,8 +79,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/radiotrack2.c b/sys/dev/isa/radiotrack2.c index f1c32711d7c9..8dbffcc061c5 100644 --- a/sys/dev/isa/radiotrack2.c +++ b/sys/dev/isa/radiotrack2.c @@ -1,4 +1,4 @@ -/* $NetBSD: radiotrack2.c,v 1.4 2002/01/07 21:47:14 thorpej Exp $ */ +/* $NetBSD: radiotrack2.c,v 1.5 2002/09/03 18:53:41 augustss Exp $ */ /* $OpenBSD: radiotrack2.c,v 1.1 2001/12/05 10:27:06 mickey Exp $ */ /* $RuOBSD: radiotrack2.c,v 1.2 2001/10/18 16:51:36 pva Exp $ */ @@ -168,6 +168,7 @@ rtii_attach(struct device *parent, struct device *self, void *aux) struct isa_attach_args *ia = aux; sc->tea.iot = ia->ia_iot; + sc->tea.flags = 0; sc->mute = 0; sc->vol = 0; sc->freq = MIN_FM_FREQ; diff --git a/sys/dev/isa/sf16fmr2.c b/sys/dev/isa/sf16fmr2.c index 89b07064ec30..ed3737704ad6 100644 --- a/sys/dev/isa/sf16fmr2.c +++ b/sys/dev/isa/sf16fmr2.c @@ -1,4 +1,4 @@ -/* $NetBSD: sf16fmr2.c,v 1.4 2002/01/07 21:47:15 thorpej Exp $ */ +/* $NetBSD: sf16fmr2.c,v 1.5 2002/09/03 18:53:41 augustss Exp $ */ /* $OpenBSD: sf16fmr2.c,v 1.3 2001/12/18 18:48:08 mickey Exp $ */ /* $RuOBSD: sf16fmr2.c,v 1.12 2001/10/18 16:51:36 pva Exp $ */ @@ -168,6 +168,7 @@ sf2r_attach(struct device *parent, struct device *self, void *aux) struct isa_attach_args *ia = aux; sc->tea.iot = ia->ia_iot; + sc->tea.flags = 0; sc->mute = 0; sc->vol = 0; sc->freq = MIN_FM_FREQ;