Subject: Re: mr radio 'can't map io space'
To: George Sollish <gsollish@autogear.net>
From: Lennart Augustsson <lennart@augustsson.net>
List: port-i386
Date: 08/31/2002 20:22:29
It doesn't look like the card needs an irq (from a quick look at the
driver).
Have you tried using radioctl to set the frequency etc?
The xmradio program seems to try and open the wrong device (/dev/tuner).
-- Lennart
George Sollish wrote:
>Back to trying the GUILLEMOT Maxiradio/GEMTEK PR103 pci radio card after
>two weeks vacation. Beginning with Lennart's suggestion that "can't map
>io space" is usually indicative of a BIOS problem (which is true -- the
>BIOS sees the card but assigns no irq) I tried turning on all the pcibios
>kernel options in a 1.6rc2 kernel. This boots, provides much information,
>and confirms that io space has been allocated, but does not assign an irq
>or open /dev/radio.
>
>Remembering that OpenBSD had replaced the untested mr driver with a new
>gtp driver for the same card (it seems none of the developers had an mr
>card for testing), I thought I'd try compiling the gtp driver into another
>test kernel; after a bit I did get a kernel built and it does open
>/dev/radio (the modified /dev/pci/maxiradio_mod.c is attached).
>Unfortunately, it does not seem to activate the tuner. Am I missing
>something obvious -- the card (0x5046) does need an irq, right?
>
>This is the new kernel with my modified OpenBSD gtp driver patched in as
>mr:
>
>NetBSD 1.6_RC2 (MIDDLETON.MP) #21: Fri Aug 30 14:38:48 EDT 2002
> gsollish@labrador.autogear.net:/usr/src/syssrc/sys/arch/i386/compile/
>MIDDLETON.MP
>total memory = 255 MB
>avail memory = 231 MB
>using 3297 buffers containing 13188 KB of memory
>BIOS32 rev. 0 found at 0xfdb60
>PCI BIOS rev. 2.1 found at 0xfdb81
>pcibios: config mechanism [1][x], special cycles [x][x], last bus 1
>PCI BIOS has 9 Interrupt Routing table entries
>PIR Entry 0:
> Bus: 0 Device: 0
> INTA: link 0x00 bitmap 0xdeb8
> INTB: link 0x00 bitmap 0xdeb8
> INTC: link 0x00 bitmap 0xdeb8
> INTD: link 0x00 bitmap 0xdeb8
>PIR Entry 1:
> Bus: 0 Device: 1
> INTA: link 0x61 bitmap 0xdeb8
> INTB: link 0x62 bitmap 0xdeb8
> INTC: link 0x00 bitmap 0xdeb8
> INTD: link 0x00 bitmap 0xdeb8
>PIR Entry 2:
> Bus: 0 Device: 7
> INTA: link 0xfe bitmap 0x4000
> INTB: link 0xff bitmap 0x8000
> INTC: link 0x00 bitmap 0x0000
> INTD: link 0x63 bitmap 0xdeb8
>PIR Entry 3:
> Bus: 0 Device: 13
> INTA: link 0x62 bitmap 0xdeb8
> INTB: link 0x63 bitmap 0xdeb8
> INTC: link 0x60 bitmap 0xdeb8
> INTD: link 0x61 bitmap 0xdeb8
>PIR Entry 4:
> Bus: 0 Device: 15
> INTA: link 0x60 bitmap 0xdeb8
> INTB: link 0x61 bitmap 0xdeb8
> INTC: link 0x62 bitmap 0xdeb8
> INTD: link 0x63 bitmap 0xdeb8
>PIR Entry 5:
> Bus: 0 Device: 16
> INTA: link 0x61 bitmap 0xdeb8
> INTB: link 0x62 bitmap 0xdeb8
> INTC: link 0x63 bitmap 0xdeb8
> INTD: link 0x60 bitmap 0xdeb8
>PIR Entry 6:
> Bus: 0 Device: 18
> INTA: link 0x62 bitmap 0xdeb8
> INTB: link 0x63 bitmap 0xdeb8
> INTC: link 0x60 bitmap 0xdeb8
> INTD: link 0x61 bitmap 0xdeb8
>PIR Entry 7:
> Bus: 0 Device: 20
> INTA: link 0x63 bitmap 0xdeb8
> INTB: link 0x60 bitmap 0xdeb8
> INTC: link 0x61 bitmap 0xdeb8
> INTD: link 0x62 bitmap 0xdeb8
>PIR Entry 8:
> Bus: 1 Device: 0
> INTA: link 0x61 bitmap 0xdeb8
> INTB: link 0x62 bitmap 0xdeb8
> INTC: link 0x00 bitmap 0xdeb8
> INTD: link 0x00 bitmap 0xdeb8
>pciintr_link_fixup: PIRQ 0x00 already connected to IRQ 10
>pciintr_link_fixup: PIRQ 0x01 already connected to IRQ 10
>pciintr_link_fixup: PIRQ 0x02 already connected to IRQ 5
>pciintr_link_fixup: PIRQ 0x03 already connected to IRQ 9
>pciintr_link_route: route of PIRQ 0x00 -> IRQ 10 preserved BIOS setting
>pciintr_link_route: route of PIRQ 0x01 -> IRQ 10 preserved BIOS setting
>pciintr_link_route: route of PIRQ 0x02 -> IRQ 5 preserved BIOS setting
>pciintr_link_route: route of PIRQ 0x03 -> IRQ 9 preserved BIOS setting
>------------------------------------------
> device vendor product pin PIRQ IRQ stage
>------------------------------------------
>000:07:2 0x8086 0x7112 D 0x03 9 0 already assigned
>000:13:0 0x11f6 0x1401 A 0x02 5 0 already assigned
>000:15:0 0x1274 0x5880 A 0x00 10 0 already assigned
>000:16:0 0x1002 0x5050 A 0x01 10 0 already assigned
>000:20:0 0x1260 0x3873 A 0x03 9 0 already assigned
>------------------------------------------
>PCI fixup examining 8086:71a0
>PCI fixup examining 8086:71a1
>PCI bridge 0: primary 0, secondary 1, subordinate 1
>PCI fixup examining 8086:7110
>PCI fixup examining 8086:7111
>PCI fixup examining 8086:7112
>PCI fixup examining 8086:7113
>PCI fixup examining 11f6:1401
>PCI fixup examining 1274:5880
>PCI fixup examining 1002:5050
>PCI fixup examining 5046:1001
>PCI fixup examining 1260:3873
>PCI bus #1 is the last bus
>[System BIOS Setting]-----------------------
> device vendor product
> register space address size
>--------------------------------------------
>000:00:0 0x8086 0x71a0
> 10h mem 0xf4000000 0x04000000
> [OK]
>000:01:0 0x8086 0x71a1
> [OK]
>000:07:0 0x8086 0x7110
> [OK]
>000:07:1 0x8086 0x7111
> 20h port 0x0000ffa0 0x00000010
> [OK]
>000:07:2 0x8086 0x7112
> 20h port 0x0000ef80 0x00000020
> [OK]
>000:07:3 0x8086 0x7113
> [OK]
>000:13:0 0x11f6 0x1401
> 10h port 0x0000ef40 0x00000020
> [OK]
>000:15:0 0x1274 0x5880
> 10h port 0x0000ef00 0x00000040
> [OK]
>000:16:0 0x1002 0x5050
> 10h mem 0xf8000000 0x04000000
> 14h port 0x0000e800 0x00000100
> 18h mem 0xffafc000 0x00004000
> [OK]
>000:18:0 0x5046 0x1001
> 10h port 0x0000eff4 0x00000004
> [OK]
>000:20:0 0x1260 0x3873
> 10h mem 0xfebff000 0x00001000
> [OK]
>--------------------------[ 0 devices bogus]
> Physical memory end: 0x0fffc000
> PCI memory mapped I/O space start: 0x10000000
>mainbus0 (root)
>mainbus0: Intel MP Specification (Version 1.4) (INTEL 440BX )
>cpu0 at mainbus0: apid 0 (boot processor)
>cpu0: Intel Pentium III (Coppermine) Pentium III (686-class), 851.98 MHz
>cpu0: features 383fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
>cpu0: features 383fbff<PGE,MCA,CMOV,FGPAT,PSE36,MMX>
>cpu0: features 383fbff<FXSR,SSE>
>cpu0: I-cache 16 KB 32b/line 4-way, D-cache 16 KB 32b/line 4-way
>cpu0: L2 cache 256 KB 32b/line 8-way
>cpu0: ITLB 32 4 KB entries 4-way, 2 4 MB entries fully associative
>cpu0: DTLB 64 4 KB entries 4-way, 8 4 MB entries 4-way
>cpu0: calibrating local timer
>cpu0: apic clock running at 100 MHz
>cpu0: 8 page colors
>cpu1 at mainbus0: apid 1 (application processor)
>cpu1: starting
>cpu1: Intel Pentium III (Coppermine) Pentium III (686-class), 851.94 MHz
>cpu1: features 383fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
>cpu1: features 383fbff<PGE,MCA,CMOV,FGPAT,PSE36,MMX>
>cpu1: features 383fbff<FXSR,SSE>
>cpu1: I-cache 16 KB 32b/line 4-way, D-cache 16 KB 32b/line 4-way
>cpu1: L2 cache 256 KB 32b/line 8-way
>cpu1: ITLB 32 4 KB entries 4-way, 2 4 MB entries fully associative
>cpu1: DTLB 64 4 KB entries 4-way, 8 4 MB entries 4-way
>mpbios: bus 0 is type PCI
>mpbios: bus 1 is type PCI
>mpbios: bus 2 is type ISA
>ioapic0 at mainbus0 apid 2 (I/O APIC)
>ioapic0: pa 0xfec00000, version 11, 24 pins
>pci0 at mainbus0 bus 0: configuration mode 1
>pci0: i/o space, memory space enabled, rd/line, rd/mult, wr/inv ok
>pchb0 at pci0 dev 0 function 0
>pchb0: Intel 82443GX Host Bridge/Controller (rev. 0x00)
>agp0 at pchb0: aperture at 0xf4000000, size 0x4000000
>ppb0 at pci0 dev 1 function 0: Intel 82443GX AGP Interface (rev. 0x00)
>pci1 at ppb0 bus 1
>pci1: i/o space, memory space enabled
>pcib0 at pci0 dev 7 function 0
>pcib0: Intel 82371AB PCI-to-ISA Bridge (PIIX4) (rev. 0x02)
>pciide0 at pci0 dev 7 function 1: Intel 82371AB IDE controller (PIIX4) (rev. 0x01)
>pciide0: bus-master DMA support present
>pciide0: primary channel wired to compatibility mode
>wd0 at pciide0 channel 0 drive 0: <WDC WD136AA>
>wd0: drive supports 16-sector PIO transfers, LBA addressing
>wd0: 12971 MB, 16383 cyl, 16 head, 63 sec, 512 bytes/sect x 26564832 sectors
>wd0: 32-bit data port
>wd0: drive supports PIO mode 4, DMA mode 2, Ultra-DMA mode 4 (Ultra/66)
>pciide0: primary channel interrupting at irq 14
>wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2 (Ultra/33) (using DMA data transfers)
>pciide0: secondary channel wired to compatibility mode
>pciide0: disabling secondary channel (no drives)
>uhci0 at pci0 dev 7 function 2: Intel 82371AB USB Host Controller (PIIX4) (rev. 0x01)
>pci_intr_map: bus 0 dev 7 func 2 pin 4; line 9
>pci_intr_map: no MP mapping found
>uhci0: interrupting at irq 9
>usb0 at uhci0: USB revision 1.0
>uhub0 at usb0
>uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1
>uhub0: 2 ports with 2 removable, self powered
>Intel 82371AB Power Management Controller (PIIX4) (miscellaneous bridge, revision 0x02) at pci0 dev 7 function 3 not configured
>ne2 at pci0 dev 13 function 0: Compex Ethernet
>ne2: Ethernet address 00:80:48:c7:62:24
>pci_intr_map: bus 0 dev 13 func 0 pin 1; line 5
>pci_intr_map: no MP mapping found
>ne2: interrupting at irq 5
>eap0 at pci0 dev 15 function 0: Ensoniq CT5880 CT5880C (rev. 0x02)
>pci_intr_map: bus 0 dev 15 func 0 pin 1; line 10
>pci_intr_map: no MP mapping found
>eap0: interrupting at irq 10
>eap0: SigmaTel STAC9721/23 codec; 18 bit DAC, 18 bit ADC, SigmaTel 3D
>audio0 at eap0: full duplex, mmap, independent
>midi0 at eap0: AudioPCI MIDI UART
>vga1 at pci0 dev 16 function 0: ATI Technologies Rage 128 Pro PCI (TMDS) (rev. 0x00)
>wsdisplay0 at vga1 kbdmux 1: console (80x25, vt100 emulation)
>wsmux1: connecting to wsdisplay0
>mr0 at pci0 dev 18 function 0: Gemtek PR103
>radio0 at mr0
>wi0 at pci0 dev 20 function 0: Intersil Prism2.5 Wireless Lan
>pci_intr_map: bus 0 dev 20 func 0 pin 1; line 9
>pci_intr_map: no MP mapping found
>wi0: interrupting at irq 9
>wi0:wi0: command timed out, cmd=0x0
>wi0: init failed
> 802.11 address 00:05:5d:ee:59:06
>wi0: using Unknown Lucent chip
>wi0: Lucent Firmware: Station (0.0.0)
>isa0 at pcib0
>aha0 at isa0 port 0x330-0x333 irq 11 drq 5
>aha0: model AHA-1542CF, firmware B.0
>aha0: unlocking mailbox interface
>aha0: async, parity
>scsibus0 at aha0: 8 targets, 8 luns per target
>com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
>com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
>pckbc0 at isa0 port 0x60-0x64
>pckbd0 at pckbc0 (kbd slot)
>pckbc0: using irq 1 for kbd slot
>wskbd0 at pckbd0: console keyboard, using wsdisplay0
>pms0 at pckbc0 (aux slot)
>pckbc0: using irq 12 for aux slot
>wsmouse0 at pms0 mux 0
>lm0 at isa0 port 0x290-0x297: W83781D
>lpt0 at isa0 port 0x378-0x37b irq 7
>pcppi0 at isa0 port 0x61
>midi1 at pcppi0: PC speaker
>sysbeep0 at pcppi0
>isapnp0 at isa0 port 0x279: ISA Plug 'n Play device support
>npx0 at isa0 port 0xf0-0xff: using exception 16
>fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
>fd0 at fdc0 drive 0: 1.44MB, 80 cyl, 2 head, 18 sec
>isapnp0: no ISA Plug 'n Play devices found
>apm0 at mainbus0: Power Management spec V1.2
>biomask 0 netmask 0 ttymask 0
>ioapic0: enabling
>ioapic0: WARNING: sharing interrupt between different IPLs (currently broken)
>ioapic0: pin 19, ipls 70..80
>scsibus0: waiting 2 seconds for devices to settle...
>st0 at scsibus0 target 2 lun 0: <TANDBERG, TDC 4100, =05:> SCSI2 1/sequential removable
>st0: drive empty
>cd0 at scsibus0 target 3 lun 0: <PLEXTOR, CD-ROM PX-20TS, 1.02> SCSI2 5/cdrom removable
>boot device: wd0
>root on wd0a dumps on wd0b
>root file system type: ffs
>cpu1: CPU 1 running
>in6_ifattach: bridge0 is not multicast capable, IPv6 not enabled
>in6_ifattach: bridge0 is not multicast capable, IPv6 not enabled
>wsdisplay0: screen 1 added (80x25, vt100 emulation)
>wsdisplay0: screen 2 added (80x25, vt100 emulation)
>wsdisplay0: screen 3 added (80x25, vt100 emulation)
>wsdisplay0: screen 4 added (80x25, vt100 emulation)
>
>This is what radioctl -a reports:
>
>volume=0
>frequency=87.50MHz
>mute=off
>sensitivity=30mkV
>signal=off
>stereo=off
>card capabilities: stereo detect, signal detect, manageable mono/stereo, hardware search, hardware AFC
>
>This is what xmradio reports on startup:
>
>Couldn't find starting station, using default one.
>could not open /dev/tuner: Device not configured
>FAILED TO INIT TUNER!
>Can't control bass via /dev/mixer: Device not configured
>Can't control treble via /dev/mixer: Device not configured
>
>George E Sollish Chief Engineer Auto Gear Equipment
> Project Manager The Payne Lake Project
>
>
>
>------------------------------------------------------------------------
>
>/* $OpenBSD: gtp.c,v 1.1.2.1 2002/06/11 03:42:24 art 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 AUTHORS ``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 AUTHORS 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.
> */
>
>/* Gemtek PCI Radio Card Device Driver */
>
>#include <sys/param.h>
>#include <sys/systm.h>
>#include <sys/device.h>
>#include <sys/errno.h>
>#include <sys/ioctl.h>
>#include <sys/proc.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/ic/tea5757.h>
>#include <dev/radio_if.h>
>
>int mr_match(struct device *, struct cfdata *, void *);
>void mr_attach(struct device *, struct device *, void *);
>
>int mr_get_info(void *, struct radio_info *);
>int mr_set_info(void *, struct radio_info *);
>int mr_search(void *, int);
>
>#define GEMTEK_PCI_CAPS RADIO_CAPS_DETECT_SIGNAL | \
> RADIO_CAPS_DETECT_STEREO | \
> RADIO_CAPS_SET_MONO | \
> RADIO_CAPS_HW_SEARCH | \
> RADIO_CAPS_HW_AFC | \
> RADIO_CAPS_LOCK_SENSITIVITY
>
>#define GEMTEK_PCI_MUTE 0x00
>#define GEMTEK_PCI_RSET 0x10
>
>#define GEMTEK_PCI_SIGNAL 0x08
>#define GEMTEK_PCI_STEREO 0x08
>
>#define GTP_WREN_ON (1 << 2)
>#define GTP_WREN_OFF (0 << 2)
>
>#define GTP_DATA_ON (1 << 1)
>#define GTP_DATA_OFF (0 << 1)
>
>#define GTP_CLCK_ON (1 << 0)
>#define GTP_CLCK_OFF (0 << 0)
>
>#define GTP_READ_CLOCK_LOW (GTP_WREN_OFF | GTP_DATA_ON | GTP_CLCK_OFF)
>#define GTP_READ_CLOCK_HIGH (GTP_WREN_OFF | GTP_DATA_ON | GTP_CLCK_ON)
>
>/* define our interface to the high-level radio driver */
>
>struct radio_hw_if mr_hw_if = {
> NULL, /* open */
> NULL, /* close */
> mr_get_info,
> mr_set_info,
> mr_search
>};
>
>struct mr_softc {
> struct device sc_dev;
>
> int mute;
> u_int8_t vol;
> u_int32_t freq;
> u_int32_t stereo;
> u_int32_t lock;
>
> struct tea5757_t tea;
>};
>
>struct cfattach mr_ca = {
> sizeof(struct mr_softc), mr_match, mr_attach
>};
>
>void mr_set_mute(struct mr_softc *);
>void mr_write_bit(bus_space_tag_t, bus_space_handle_t, bus_size_t, int);
>void mr_init(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
>void mr_rset(bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t);
>int mr_state(bus_space_tag_t, bus_space_handle_t);
>u_int32_t mr_hardware_read(bus_space_tag_t, bus_space_handle_t,
> bus_size_t);
>
>int
>mr_match(struct device *parent, struct cfdata *cf, void *aux)
>{
> struct pci_attach_args *pa = aux;
> /* FIXME:
> * Guillemot produces the card that
> * was originally developed by Gemtek
> */
> if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_GEMTEK &&
> PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_GEMTEK_PR103)
> return (1);
> return (0);
>}
>
>void
>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;
>
> if (pci_mapreg_map(pa, 0x10, PCI_MAPREG_TYPE_IO, 0, &sc->tea.iot,
> &sc->tea.ioh, NULL, 0)) {
> printf(": can't map i/o space\n");
> return;
> }
>
> /* Enable the card */
> csr = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
> pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
> csr | PCI_COMMAND_MASTER_ENABLE);
>
> sc->vol = 0;
> sc->mute = 0;
> sc->freq = MIN_FM_FREQ;
> 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(": Gemtek PR103\n");
>
> radio_attach_mi(&mr_hw_if, sc, &sc->sc_dev);
>}
>
>int
>mr_get_info(void *v, struct radio_info *ri)
>{
> struct mr_softc *sc = v;
>
> ri->mute = sc->mute;
> ri->volume = sc->vol ? 255 : 0;
> ri->stereo = sc->stereo == TEA5757_STEREO ? 1 : 0;
> ri->caps = GEMTEK_PCI_CAPS;
> ri->rfreq = 0;
> ri->lock = tea5757_decode_lock(sc->lock);
>
> /* Frequency read unsupported */
> ri->freq = sc->freq;
>
> ri->info = mr_state(sc->tea.iot, sc->tea.ioh);
> mr_set_mute(sc);
>
> return (0);
>}
>
>int
>mr_set_info(void *v, struct radio_info *ri)
>{
> struct mr_softc *sc = v;
>
> sc->mute = ri->mute ? 1 : 0;
> sc->vol = ri->volume ? 255 : 0;
> 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);
> mr_set_mute(sc);
>
> return (0);
>}
>
>int
>mr_search(void *v, int f)
>{
> struct mr_softc *sc = v;
>
> tea5757_search(&sc->tea, sc->lock, sc->stereo, f);
> mr_set_mute(sc);
>
> return (0);
>}
>
>void
>mr_set_mute(struct mr_softc *sc)
>{
> if (sc->mute || !sc->vol)
> bus_space_write_2(sc->tea.iot, sc->tea.ioh, 0, GEMTEK_PCI_MUTE);
> else
> sc->freq = tea5757_set_freq(&sc->tea,
> sc->lock, sc->stereo, sc->freq);
>}
>
>void
>mr_write_bit(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off,
> int bit)
>{
> u_int8_t data;
>
> data = bit ? GTP_DATA_ON : GTP_DATA_OFF;
> bus_space_write_1(iot, ioh, off, GTP_WREN_ON | GTP_CLCK_OFF | data);
> bus_space_write_1(iot, ioh, off, GTP_WREN_ON | GTP_CLCK_ON | data);
> bus_space_write_1(iot, ioh, off, GTP_WREN_ON | GTP_CLCK_OFF | data);
>}
>
>void
>mr_init(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, u_int32_t d)
>{
> bus_space_write_1(iot, ioh, off, GTP_WREN_ON | GTP_DATA_ON | GTP_CLCK_OFF);
>}
>
>void
>mr_rset(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off, u_int32_t d)
>{
> bus_space_write_1(iot, ioh, off, GEMTEK_PCI_RSET);
>}
>
>u_int32_t
>mr_hardware_read(bus_space_tag_t iot, bus_space_handle_t ioh, bus_size_t off)
>{
> /* UNSUPPORTED */
> return 0;
>}
>
>int
>mr_state(bus_space_tag_t iot, bus_space_handle_t ioh)
>{
> int ret;
>
> bus_space_write_2(iot, ioh, 0,
> GTP_DATA_ON | GTP_WREN_OFF | GTP_CLCK_OFF);
> ret = bus_space_read_2(iot, ioh, 0) &
> GEMTEK_PCI_STEREO? 0 : RADIO_INFO_STEREO;
> bus_space_write_2(iot, ioh, 0,
> GTP_DATA_ON | GTP_WREN_OFF | GTP_CLCK_ON);
> ret |= bus_space_read_2(iot, ioh, 0) &
> GEMTEK_PCI_SIGNAL? 0 : RADIO_INFO_SIGNAL;
>
> return ret;
>}
>
>