FreeBSD kernel sound device code
fm801.c File Reference
Include dependency graph for fm801.c:

Go to the source code of this file.

Data Structures

struct  fm801_chinfo
 
struct  fm801_info
 

Macros

#define PCI_VENDOR_FORTEMEDIA   0x1319
 
#define PCI_DEVICE_FORTEMEDIA1   0x08011319 /* Audio controller */
 
#define PCI_DEVICE_FORTEMEDIA2   0x08021319 /* Joystick controller */
 
#define FM_PCM_VOLUME   0x00
 
#define FM_FM_VOLUME   0x02
 
#define FM_I2S_VOLUME   0x04
 
#define FM_RECORD_SOURCE   0x06
 
#define FM_PLAY_CTL   0x08
 
#define FM_PLAY_RATE_MASK   0x0f00
 
#define FM_PLAY_BUF1_LAST   0x0001
 
#define FM_PLAY_BUF2_LAST   0x0002
 
#define FM_PLAY_START   0x0020
 
#define FM_PLAY_PAUSE   0x0040
 
#define FM_PLAY_STOPNOW   0x0080
 
#define FM_PLAY_16BIT   0x4000
 
#define FM_PLAY_STEREO   0x8000
 
#define FM_PLAY_DMALEN   0x0a
 
#define FM_PLAY_DMABUF1   0x0c
 
#define FM_PLAY_DMABUF2   0x10
 
#define FM_REC_CTL   0x14
 
#define FM_REC_RATE_MASK   0x0f00
 
#define FM_REC_BUF1_LAST   0x0001
 
#define FM_REC_BUF2_LAST   0x0002
 
#define FM_REC_START   0x0020
 
#define FM_REC_PAUSE   0x0040
 
#define FM_REC_STOPNOW   0x0080
 
#define FM_REC_16BIT   0x4000
 
#define FM_REC_STEREO   0x8000
 
#define FM_REC_DMALEN   0x16
 
#define FM_REC_DMABUF1   0x18
 
#define FM_REC_DMABUF2   0x1c
 
#define FM_CODEC_CTL   0x22
 
#define FM_VOLUME   0x26
 
#define FM_VOLUME_MUTE   0x8000
 
#define FM_CODEC_CMD   0x2a
 
#define FM_CODEC_CMD_READ   0x0080
 
#define FM_CODEC_CMD_VALID   0x0100
 
#define FM_CODEC_CMD_BUSY   0x0200
 
#define FM_CODEC_DATA   0x2c
 
#define FM_IO_CTL   0x52
 
#define FM_CARD_CTL   0x54
 
#define FM_INTMASK   0x56
 
#define FM_INTMASK_PLAY   0x0001
 
#define FM_INTMASK_REC   0x0002
 
#define FM_INTMASK_VOL   0x0040
 
#define FM_INTMASK_MPU   0x0080
 
#define FM_INTSTATUS   0x5a
 
#define FM_INTSTATUS_PLAY   0x0100
 
#define FM_INTSTATUS_REC   0x0200
 
#define FM_INTSTATUS_VOL   0x4000
 
#define FM_INTSTATUS_MPU   0x8000
 
#define FM801_DEFAULT_BUFSZ   4096 /* Other values do not work!!! */
 
#define DPRINT   if(0) printf
 
#define TIMO   50
 
#define FM801_MAXPLAYCH   1
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static u_int32_t fm801_rd (struct fm801_info *fm801, int regno, int size)
 
static void fm801_wr (struct fm801_info *fm801, int regno, u_int32_t data, int size)
 
static int fm801_rdcd (kobj_t obj, void *devinfo, int regno)
 
static int fm801_wrcd (kobj_t obj, void *devinfo, int regno, u_int32_t data)
 
 AC97_DECLARE (fm801_ac97)
 
static void fm801_intr (void *p)
 
static void * fm801ch_init (kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
 
static int fm801ch_setformat (kobj_t obj, void *data, u_int32_t format)
 
static u_int32_t fm801ch_setspeed (kobj_t obj, void *data, u_int32_t speed)
 
static u_int32_t fm801ch_setblocksize (kobj_t obj, void *data, u_int32_t blocksize)
 
static int fm801ch_trigger (kobj_t obj, void *data, int go)
 
static u_int32_t fm801ch_getptr (kobj_t obj, void *data)
 
static struct pcmchan_capsfm801ch_getcaps (kobj_t obj, void *data)
 
 CHANNEL_DECLARE (fm801ch)
 
static int fm801_init (struct fm801_info *fm801)
 
static int fm801_pci_attach (device_t dev)
 
static int fm801_pci_detach (device_t dev)
 
static int fm801_pci_probe (device_t dev)
 
static struct resource * fm801_alloc_resource (device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
 
static int fm801_release_resource (device_t bus, device_t child, int type, int rid, struct resource *r)
 
 DRIVER_MODULE (snd_fm801, pci, fm801_driver, pcm_devclass, 0, 0)
 
 MODULE_DEPEND (snd_fm801, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
 
 MODULE_VERSION (snd_fm801, 1)
 

Variables

static u_int32_t fmts []
 
static struct pcmchan_caps fm801ch_caps
 
static kobj_method_t fm801_ac97_methods []
 
struct {
   u_int32_t   limit
 
   u_int32_t   rate
 
fm801_rates [11]
 
static kobj_method_t fm801ch_methods []
 
static device_method_t fm801_methods []
 
static driver_t fm801_driver
 

Macro Definition Documentation

◆ DPRINT

#define DPRINT   if(0) printf

Definition at line 106 of file fm801.c.

◆ FM801_DEFAULT_BUFSZ

#define FM801_DEFAULT_BUFSZ   4096 /* Other values do not work!!! */

Definition at line 103 of file fm801.c.

◆ FM801_MAXPLAYCH

#define FM801_MAXPLAYCH   1

◆ FM_CARD_CTL

#define FM_CARD_CTL   0x54

Definition at line 89 of file fm801.c.

◆ FM_CODEC_CMD

#define FM_CODEC_CMD   0x2a

Definition at line 81 of file fm801.c.

◆ FM_CODEC_CMD_BUSY

#define FM_CODEC_CMD_BUSY   0x0200

Definition at line 84 of file fm801.c.

◆ FM_CODEC_CMD_READ

#define FM_CODEC_CMD_READ   0x0080

Definition at line 82 of file fm801.c.

◆ FM_CODEC_CMD_VALID

#define FM_CODEC_CMD_VALID   0x0100

Definition at line 83 of file fm801.c.

◆ FM_CODEC_CTL

#define FM_CODEC_CTL   0x22

Definition at line 77 of file fm801.c.

◆ FM_CODEC_DATA

#define FM_CODEC_DATA   0x2c

Definition at line 86 of file fm801.c.

◆ FM_FM_VOLUME

#define FM_FM_VOLUME   0x02

Definition at line 45 of file fm801.c.

◆ FM_I2S_VOLUME

#define FM_I2S_VOLUME   0x04

Definition at line 46 of file fm801.c.

◆ FM_INTMASK

#define FM_INTMASK   0x56

Definition at line 91 of file fm801.c.

◆ FM_INTMASK_MPU

#define FM_INTMASK_MPU   0x0080

Definition at line 95 of file fm801.c.

◆ FM_INTMASK_PLAY

#define FM_INTMASK_PLAY   0x0001

Definition at line 92 of file fm801.c.

◆ FM_INTMASK_REC

#define FM_INTMASK_REC   0x0002

Definition at line 93 of file fm801.c.

◆ FM_INTMASK_VOL

#define FM_INTMASK_VOL   0x0040

Definition at line 94 of file fm801.c.

◆ FM_INTSTATUS

#define FM_INTSTATUS   0x5a

Definition at line 97 of file fm801.c.

◆ FM_INTSTATUS_MPU

#define FM_INTSTATUS_MPU   0x8000

Definition at line 101 of file fm801.c.

◆ FM_INTSTATUS_PLAY

#define FM_INTSTATUS_PLAY   0x0100

Definition at line 98 of file fm801.c.

◆ FM_INTSTATUS_REC

#define FM_INTSTATUS_REC   0x0200

Definition at line 99 of file fm801.c.

◆ FM_INTSTATUS_VOL

#define FM_INTSTATUS_VOL   0x4000

Definition at line 100 of file fm801.c.

◆ FM_IO_CTL

#define FM_IO_CTL   0x52

Definition at line 88 of file fm801.c.

◆ FM_PCM_VOLUME

#define FM_PCM_VOLUME   0x00

Definition at line 44 of file fm801.c.

◆ FM_PLAY_16BIT

#define FM_PLAY_16BIT   0x4000

Definition at line 56 of file fm801.c.

◆ FM_PLAY_BUF1_LAST

#define FM_PLAY_BUF1_LAST   0x0001

Definition at line 51 of file fm801.c.

◆ FM_PLAY_BUF2_LAST

#define FM_PLAY_BUF2_LAST   0x0002

Definition at line 52 of file fm801.c.

◆ FM_PLAY_CTL

#define FM_PLAY_CTL   0x08

Definition at line 49 of file fm801.c.

◆ FM_PLAY_DMABUF1

#define FM_PLAY_DMABUF1   0x0c

Definition at line 60 of file fm801.c.

◆ FM_PLAY_DMABUF2

#define FM_PLAY_DMABUF2   0x10

Definition at line 61 of file fm801.c.

◆ FM_PLAY_DMALEN

#define FM_PLAY_DMALEN   0x0a

Definition at line 59 of file fm801.c.

◆ FM_PLAY_PAUSE

#define FM_PLAY_PAUSE   0x0040

Definition at line 54 of file fm801.c.

◆ FM_PLAY_RATE_MASK

#define FM_PLAY_RATE_MASK   0x0f00

Definition at line 50 of file fm801.c.

◆ FM_PLAY_START

#define FM_PLAY_START   0x0020

Definition at line 53 of file fm801.c.

◆ FM_PLAY_STEREO

#define FM_PLAY_STEREO   0x8000

Definition at line 57 of file fm801.c.

◆ FM_PLAY_STOPNOW

#define FM_PLAY_STOPNOW   0x0080

Definition at line 55 of file fm801.c.

◆ FM_REC_16BIT

#define FM_REC_16BIT   0x4000

Definition at line 70 of file fm801.c.

◆ FM_REC_BUF1_LAST

#define FM_REC_BUF1_LAST   0x0001

Definition at line 65 of file fm801.c.

◆ FM_REC_BUF2_LAST

#define FM_REC_BUF2_LAST   0x0002

Definition at line 66 of file fm801.c.

◆ FM_REC_CTL

#define FM_REC_CTL   0x14

Definition at line 63 of file fm801.c.

◆ FM_REC_DMABUF1

#define FM_REC_DMABUF1   0x18

Definition at line 74 of file fm801.c.

◆ FM_REC_DMABUF2

#define FM_REC_DMABUF2   0x1c

Definition at line 75 of file fm801.c.

◆ FM_REC_DMALEN

#define FM_REC_DMALEN   0x16

Definition at line 73 of file fm801.c.

◆ FM_REC_PAUSE

#define FM_REC_PAUSE   0x0040

Definition at line 68 of file fm801.c.

◆ FM_REC_RATE_MASK

#define FM_REC_RATE_MASK   0x0f00

Definition at line 64 of file fm801.c.

◆ FM_REC_START

#define FM_REC_START   0x0020

Definition at line 67 of file fm801.c.

◆ FM_REC_STEREO

#define FM_REC_STEREO   0x8000

Definition at line 71 of file fm801.c.

◆ FM_REC_STOPNOW

#define FM_REC_STOPNOW   0x0080

Definition at line 69 of file fm801.c.

◆ FM_RECORD_SOURCE

#define FM_RECORD_SOURCE   0x06

Definition at line 47 of file fm801.c.

◆ FM_VOLUME

#define FM_VOLUME   0x26

Definition at line 78 of file fm801.c.

◆ FM_VOLUME_MUTE

#define FM_VOLUME_MUTE   0x8000

Definition at line 79 of file fm801.c.

◆ PCI_DEVICE_FORTEMEDIA1

#define PCI_DEVICE_FORTEMEDIA1   0x08011319 /* Audio controller */

Definition at line 41 of file fm801.c.

◆ PCI_DEVICE_FORTEMEDIA2

#define PCI_DEVICE_FORTEMEDIA2   0x08021319 /* Joystick controller */

Definition at line 42 of file fm801.c.

◆ PCI_VENDOR_FORTEMEDIA

#define PCI_VENDOR_FORTEMEDIA   0x1319

Definition at line 40 of file fm801.c.

◆ TIMO

#define TIMO   50

Definition at line 209 of file fm801.c.

Function Documentation

◆ AC97_DECLARE()

AC97_DECLARE ( fm801_ac97  )

◆ CHANNEL_DECLARE()

CHANNEL_DECLARE ( fm801ch  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( snd_fm801  ,
pci  ,
fm801_driver  ,
pcm_devclass  ,
,
 
)

◆ fm801_alloc_resource()

static struct resource * fm801_alloc_resource ( device_t  bus,
device_t  child,
int  type,
int *  rid,
rman_res_t  start,
rman_res_t  end,
rman_res_t  count,
u_int  flags 
)
static

Definition at line 717 of file fm801.c.

References bus, PCIR_BAR, pcm_getdevinfo(), fm801_info::reg, rid, and type.

Here is the call graph for this function:

◆ fm801_init()

static int fm801_init ( struct fm801_info fm801)
static

Definition at line 541 of file fm801.c.

References DPRINT, fm801_rd(), fm801_wr(), FM_CODEC_CTL, FM_FM_VOLUME, FM_I2S_VOLUME, FM_INTMASK, FM_INTMASK_MPU, FM_INTMASK_PLAY, FM_INTMASK_REC, FM_INTMASK_VOL, FM_INTSTATUS, FM_INTSTATUS_MPU, FM_INTSTATUS_PLAY, FM_INTSTATUS_REC, FM_INTSTATUS_VOL, FM_PCM_VOLUME, and FM_RECORD_SOURCE.

Referenced by fm801_pci_attach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fm801_intr()

◆ fm801_pci_attach()

◆ fm801_pci_detach()

static int fm801_pci_detach ( device_t  dev)
static

◆ fm801_pci_probe()

static int fm801_pci_probe ( device_t  dev)
static

Definition at line 699 of file fm801.c.

References dev, id, and PCI_DEVICE_FORTEMEDIA1.

◆ fm801_rd()

static u_int32_t fm801_rd ( struct fm801_info fm801,
int  regno,
int  size 
)
static

Definition at line 174 of file fm801.c.

References regno, fm801_info::sh, size, and fm801_info::st.

Referenced by fm801_init(), fm801_intr(), fm801_rdcd(), fm801_wrcd(), fm801ch_getptr(), and fm801ch_trigger().

Here is the caller graph for this function:

◆ fm801_rdcd()

static int fm801_rdcd ( kobj_t  obj,
void *  devinfo,
int  regno 
)
static

Definition at line 211 of file fm801.c.

References devinfo, DPRINT, fm801_rd(), fm801_wr(), FM_CODEC_CMD, FM_CODEC_CMD_BUSY, FM_CODEC_CMD_READ, FM_CODEC_CMD_VALID, FM_CODEC_DATA, regno, and TIMO.

Here is the call graph for this function:

◆ fm801_release_resource()

static int fm801_release_resource ( device_t  bus,
device_t  child,
int  type,
int  rid,
struct resource *  r 
)
static

Definition at line 732 of file fm801.c.

◆ fm801_wr()

static void fm801_wr ( struct fm801_info fm801,
int  regno,
u_int32_t  data,
int  size 
)
static

Definition at line 189 of file fm801.c.

References data, regno, fm801_info::sh, size, and fm801_info::st.

Referenced by fm801_init(), fm801_intr(), fm801_rdcd(), fm801_wrcd(), and fm801ch_trigger().

Here is the caller graph for this function:

◆ fm801_wrcd()

static int fm801_wrcd ( kobj_t  obj,
void *  devinfo,
int  regno,
u_int32_t  data 
)
static

Definition at line 241 of file fm801.c.

References data, devinfo, DPRINT, fm801_rd(), fm801_wr(), FM_CODEC_CMD, FM_CODEC_CMD_BUSY, FM_CODEC_DATA, regno, and TIMO.

Here is the call graph for this function:

◆ fm801ch_getcaps()

static struct pcmchan_caps * fm801ch_getcaps ( kobj_t  obj,
void *  data 
)
static

Definition at line 518 of file fm801.c.

References fm801ch_caps.

◆ fm801ch_getptr()

static u_int32_t fm801ch_getptr ( kobj_t  obj,
void *  data 
)
static

◆ fm801ch_init()

static void * fm801ch_init ( kobj_t  obj,
void *  devinfo,
struct snd_dbuf b,
struct pcm_channel c,
int  dir 
)
static

◆ fm801ch_setblocksize()

static u_int32_t fm801ch_setblocksize ( kobj_t  obj,
void *  data,
u_int32_t  blocksize 
)
static

◆ fm801ch_setformat()

static int fm801ch_setformat ( kobj_t  obj,
void *  data,
u_int32_t  format 
)
static

◆ fm801ch_setspeed()

static u_int32_t fm801ch_setspeed ( kobj_t  obj,
void *  data,
u_int32_t  speed 
)
static

◆ fm801ch_trigger()

◆ MODULE_DEPEND()

MODULE_DEPEND ( snd_fm801  ,
sound  ,
SOUND_MINVER  ,
SOUND_PREFVER  ,
SOUND_MAXVER   
)

◆ MODULE_VERSION()

MODULE_VERSION ( snd_fm801  ,
 
)

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

Variable Documentation

◆ fm801_ac97_methods

kobj_method_t fm801_ac97_methods[]
static
Initial value:
= {
KOBJMETHOD(ac97_read, fm801_rdcd),
KOBJMETHOD(ac97_write, fm801_wrcd),
DEVMETHOD_END
}
static int fm801_rdcd(kobj_t obj, void *devinfo, int regno)
Definition: fm801.c:211
static int fm801_wrcd(kobj_t obj, void *devinfo, int regno, u_int32_t data)
Definition: fm801.c:241

Definition at line 276 of file fm801.c.

◆ fm801_driver

driver_t fm801_driver
static
Initial value:
= {
"pcm",
}
static device_method_t fm801_methods[]
Definition: fm801.c:738
#define PCM_SOFTC_SIZE
Definition: sound.h:96

Definition at line 756 of file fm801.c.

◆ fm801_methods

device_method_t fm801_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, fm801_pci_probe),
DEVMETHOD(device_attach, fm801_pci_attach),
DEVMETHOD(device_detach, fm801_pci_detach),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
DEVMETHOD(bus_alloc_resource, fm801_alloc_resource),
DEVMETHOD(bus_release_resource, fm801_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD_END
}
static int fm801_pci_probe(device_t dev)
Definition: fm801.c:699
static int fm801_pci_detach(device_t dev)
Definition: fm801.c:667
static int fm801_release_resource(device_t bus, device_t child, int type, int rid, struct resource *r)
Definition: fm801.c:732
static struct resource * fm801_alloc_resource(device_t bus, device_t child, int type, int *rid, rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
Definition: fm801.c:717
static int fm801_pci_attach(device_t dev)
Definition: fm801.c:572

Definition at line 738 of file fm801.c.

◆ 

struct { ... } fm801_rates[11]
Initial value:
= {
{ 6600, 5500 },
{ 8750, 8000 },
{ 10250, 9600 },
{ 13200, 11025 },
{ 17500, 16000 },
{ 20500, 19200 },
{ 26500, 22050 },
{ 35000, 32000 },
{ 41000, 38400 },
{ 46000, 44100 },
{ 48000, 48000 },
}

Referenced by fm801ch_setspeed().

◆ fm801ch_caps

struct pcmchan_caps fm801ch_caps
static
Initial value:
= {
5500, 48000,
fmts, 0
}
static u_int32_t fmts[]
Definition: fm801.c:112

Definition at line 120 of file fm801.c.

Referenced by fm801ch_getcaps().

◆ fm801ch_methods

kobj_method_t fm801ch_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, fm801ch_init),
KOBJMETHOD(channel_setformat, fm801ch_setformat),
KOBJMETHOD(channel_setspeed, fm801ch_setspeed),
KOBJMETHOD(channel_setblocksize, fm801ch_setblocksize),
KOBJMETHOD(channel_trigger, fm801ch_trigger),
KOBJMETHOD(channel_getptr, fm801ch_getptr),
KOBJMETHOD(channel_getcaps, fm801ch_getcaps),
DEVMETHOD_END
}
static int fm801ch_trigger(kobj_t obj, void *data, int go)
Definition: fm801.c:441
static void * fm801ch_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: fm801.c:331
static u_int32_t fm801ch_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
Definition: fm801.c:419
static int fm801ch_setformat(kobj_t obj, void *data, u_int32_t format)
Definition: fm801.c:347
static u_int32_t fm801ch_setspeed(kobj_t obj, void *data, u_int32_t speed)
Definition: fm801.c:393
static u_int32_t fm801ch_getptr(kobj_t obj, void *data)
Definition: fm801.c:496
static struct pcmchan_caps * fm801ch_getcaps(kobj_t obj, void *data)
Definition: fm801.c:518

Definition at line 523 of file fm801.c.

◆ fmts

u_int32_t fmts[]
static
Initial value:
= {
SND_FORMAT(AFMT_U8, 1, 0),
SND_FORMAT(AFMT_U8, 2, 0),
SND_FORMAT(AFMT_S16_LE, 1, 0),
SND_FORMAT(AFMT_S16_LE, 2, 0),
0
}
#define SND_FORMAT(f, c, e)
Definition: sound.h:238

Definition at line 112 of file fm801.c.

Referenced by chn_getformats(), dsp_oss_audioinfo(), mss_format(), snd_fmtbest(), snd_fmtbestbit(), snd_fmtbestchannel(), snd_fmtbestfunc(), sndstat_build_sound4_nvlist(), and sndstat_get_caps().

◆ limit

u_int32_t limit

Definition at line 375 of file fm801.c.

Referenced by chn_resizebuf().

◆ rate

u_int32_t rate

Definition at line 376 of file fm801.c.