Add basic support for the radio(4) interface.
This commit is contained in:
parent
e5a41e331a
commit
1eb3eee47c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bktr_os.c,v 1.22 2001/11/13 07:29:37 lukem Exp $ */
|
||||
/* $NetBSD: bktr_os.c,v 1.23 2002/01/06 02:42:45 jmcneill Exp $ */
|
||||
|
||||
/* FreeBSD: src/sys/dev/bktr/bktr_os.c,v 1.20 2000/10/20 08:16:53 roger Exp */
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: bktr_os.c,v 1.22 2001/11/13 07:29:37 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: bktr_os.c,v 1.23 2002/01/06 02:42:45 jmcneill Exp $");
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include "bktr.h"
|
||||
|
@ -149,6 +149,7 @@ SYSCTL_INT(_hw_bt848, OID_AUTO, slow_msp_audio, CTLFLAG_RW, &bt848_slow_msp_audi
|
|||
#include <sys/poll.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/radioio.h>
|
||||
|
||||
#ifndef __NetBSD__
|
||||
#include <vm/vm.h>
|
||||
|
@ -161,6 +162,7 @@ SYSCTL_INT(_hw_bt848, OID_AUTO, slow_msp_audio, CTLFLAG_RW, &bt848_slow_msp_audi
|
|||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
#include <dev/pci/pcidevs.h>
|
||||
#include <dev/radio_if.h>
|
||||
|
||||
#define BKTR_DEBUG
|
||||
#ifdef BKTR_DEBUG
|
||||
|
@ -1321,6 +1323,19 @@ struct cfdriver bktr_cd = {
|
|||
};
|
||||
#endif
|
||||
|
||||
|
||||
/* for radio(4) */
|
||||
int bktr_get_info(void *, struct radio_info *);
|
||||
int bktr_set_info(void *, struct radio_info *);
|
||||
|
||||
struct radio_hw_if bktr_hw_if = {
|
||||
NULL, /* open */
|
||||
NULL, /* close */
|
||||
bktr_get_info,
|
||||
bktr_set_info,
|
||||
NULL /* search */
|
||||
};
|
||||
|
||||
int
|
||||
bktr_probe(parent, match, aux)
|
||||
struct device *parent;
|
||||
|
@ -1502,6 +1517,9 @@ bktr_attach(struct device *parent, struct device *self, void *aux)
|
|||
rev = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG) & 0x000000ff;
|
||||
|
||||
common_bktr_attach(bktr, unit, fun, rev);
|
||||
|
||||
/* attach to radio(4) */
|
||||
radio_attach_mi(&bktr_hw_if, bktr, &bktr->bktr_dev);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1758,4 +1776,57 @@ bktr_mmap(dev_t dev, off_t offset, int nprot)
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
bktr_set_info(void *v, struct radio_info *ri)
|
||||
{
|
||||
struct bktr_softc *sc = v;
|
||||
u_int32_t freq;
|
||||
|
||||
if (ri->mute) {
|
||||
/* mute the audio stream by switching the mux */
|
||||
set_audio(sc, AUDIO_MUTE);
|
||||
|
||||
/* disable drivers on the GPIO port that controls the MUXes */
|
||||
OUTL(sc, BKTR_GPIO_OUT_EN, INL(sc, BKTR_GPIO_OUT_EN) &
|
||||
~sc->card.gpio_mux_bits);
|
||||
} else {
|
||||
/* enable drivers on the GPIO port that controls the MUXes */
|
||||
OUTL(sc, BKTR_GPIO_OUT_EN, INL(sc, BKTR_GPIO_OUT_EN) |
|
||||
sc->card.gpio_mux_bits);
|
||||
|
||||
/* unmute the audio stream */
|
||||
set_audio(sc, AUDIO_UNMUTE);
|
||||
init_audio_devices(sc);
|
||||
}
|
||||
|
||||
freq = ri->freq / 10;
|
||||
set_audio(sc, AUDIO_INTERN); /* use internal audio */
|
||||
temp_mute(sc, TRUE);
|
||||
ri->freq = tv_freq(sc, freq, FM_RADIO_FREQUENCY) * 10;
|
||||
temp_mute(sc, FALSE);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
bktr_get_info(void *v, struct radio_info *ri)
|
||||
{
|
||||
struct bktr_softc *sc = v;
|
||||
struct TVTUNER *tv = &sc->tuner;
|
||||
int status;
|
||||
|
||||
status = get_tuner_status(sc);
|
||||
|
||||
ri->mute = (int)sc->audio_mute_state ? 1 : 0;
|
||||
ri->stereo = (status & STATUSBIT_STEREO) ? 1 : 0;
|
||||
ri->caps = RADIO_CAPS_DETECT_STEREO | RADIO_CAPS_HW_AFC;
|
||||
ri->freq = tv->frequency * 10;
|
||||
ri->info = (status & STATUSBIT_STEREO) ? RADIO_INFO_STEREO : 0;
|
||||
|
||||
/* not yet supported */
|
||||
ri->volume = ri->rfreq = ri->lock = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif /* __NetBSD__ || __OpenBSD__ */
|
||||
|
|
Loading…
Reference in New Issue