FreeBSD kernel sound device code
atiixp.c File Reference
#include <dev/sound/pcm/sound.h>
#include <dev/sound/pcm/ac97.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <sys/sysctl.h>
#include <sys/endian.h>
#include <dev/sound/pci/atiixp.h>
Include dependency graph for atiixp.c:

Go to the source code of this file.

Data Structures

struct  atiixp_dma_op
 
struct  atiixp_chinfo
 
struct  atiixp_info
 

Macros

#define ATI_IXP_DMA_RETRY_MAX   100
 
#define ATI_IXP_BUFSZ_MIN   4096
 
#define ATI_IXP_BUFSZ_MAX   65536
 
#define ATI_IXP_BUFSZ_DEFAULT   16384
 
#define ATI_IXP_BLK_MIN   32
 
#define ATI_IXP_BLK_ALIGN   (~(ATI_IXP_BLK_MIN - 1))
 
#define ATI_IXP_CHN_RUNNING   0x00000001
 
#define ATI_IXP_CHN_SUSPEND   0x00000002
 
#define atiixp_rd(_sc, _reg)    bus_space_read_4((_sc)->st, (_sc)->sh, _reg)
 
#define atiixp_wr(_sc, _reg, _val)    bus_space_write_4((_sc)->st, (_sc)->sh, _reg, _val)
 
#define atiixp_lock(_sc)   snd_mtxlock((_sc)->lock)
 
#define atiixp_unlock(_sc)   snd_mtxunlock((_sc)->lock)
 
#define atiixp_assert(_sc)   snd_mtxassert((_sc)->lock)
 
#define atiixp_chan_active(sc)
 

Functions

 SND_DECLARE_FILE ("$FreeBSD$")
 
static void atiixp_enable_interrupts (struct atiixp_info *)
 
static void atiixp_disable_interrupts (struct atiixp_info *)
 
static void atiixp_reset_aclink (struct atiixp_info *)
 
static void atiixp_flush_dma (struct atiixp_chinfo *)
 
static void atiixp_enable_dma (struct atiixp_chinfo *)
 
static void atiixp_disable_dma (struct atiixp_chinfo *)
 
static int atiixp_waitready_codec (struct atiixp_info *)
 
static int atiixp_rdcd (kobj_t, void *, int)
 
static int atiixp_wrcd (kobj_t, void *, int, uint32_t)
 
static void * atiixp_chan_init (kobj_t, void *, struct snd_dbuf *, struct pcm_channel *, int)
 
static int atiixp_chan_setformat (kobj_t, void *, uint32_t)
 
static uint32_t atiixp_chan_setspeed (kobj_t, void *, uint32_t)
 
static int atiixp_chan_setfragments (kobj_t, void *, uint32_t, uint32_t)
 
static uint32_t atiixp_chan_setblocksize (kobj_t, void *, uint32_t)
 
static void atiixp_buildsgdt (struct atiixp_chinfo *)
 
static int atiixp_chan_trigger (kobj_t, void *, int)
 
static __inline uint32_t atiixp_dmapos (struct atiixp_chinfo *)
 
static uint32_t atiixp_chan_getptr (kobj_t, void *)
 
static struct pcmchan_capsatiixp_chan_getcaps (kobj_t, void *)
 
static void atiixp_intr (void *)
 
static void atiixp_dma_cb (void *, bus_dma_segment_t *, int, int)
 
static void atiixp_chip_pre_init (struct atiixp_info *)
 
static void atiixp_chip_post_init (void *)
 
static void atiixp_release_resource (struct atiixp_info *)
 
static int atiixp_pci_probe (device_t)
 
static int atiixp_pci_attach (device_t)
 
static int atiixp_pci_detach (device_t)
 
static int atiixp_pci_suspend (device_t)
 
static int atiixp_pci_resume (device_t)
 
 AC97_DECLARE (atiixp_ac97)
 
static __inline int atiixp_poll_channel (struct atiixp_chinfo *ch)
 
static void atiixp_poll_callback (void *arg)
 
 CHANNEL_DECLARE (atiixp_chan)
 
static int sysctl_atiixp_polling (SYSCTL_HANDLER_ARGS)
 
 DRIVER_MODULE (snd_atiixp, pci, atiixp_driver, pcm_devclass, 0, 0)
 
 MODULE_DEPEND (snd_atiixp, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER)
 
 MODULE_VERSION (snd_atiixp, 1)
 

Variables

static uint32_t atiixp_fmt_32bit []
 
static uint32_t atiixp_fmt []
 
static struct pcmchan_caps atiixp_caps_32bit
 
static struct pcmchan_caps atiixp_caps
 
struct {
   uint16_t   vendor
 
   uint16_t   devid
 
   char *   desc
 
atiixp_hw []
 
static kobj_method_t atiixp_ac97_methods []
 
static kobj_method_t atiixp_chan_methods []
 
static device_method_t atiixp_methods []
 
static driver_t atiixp_driver
 

Macro Definition Documentation

◆ ATI_IXP_BLK_ALIGN

#define ATI_IXP_BLK_ALIGN   (~(ATI_IXP_BLK_MIN - 1))

Definition at line 81 of file atiixp.c.

◆ ATI_IXP_BLK_MIN

#define ATI_IXP_BLK_MIN   32

Definition at line 80 of file atiixp.c.

◆ ATI_IXP_BUFSZ_DEFAULT

#define ATI_IXP_BUFSZ_DEFAULT   16384

Definition at line 78 of file atiixp.c.

◆ ATI_IXP_BUFSZ_MAX

#define ATI_IXP_BUFSZ_MAX   65536

Definition at line 77 of file atiixp.c.

◆ ATI_IXP_BUFSZ_MIN

#define ATI_IXP_BUFSZ_MIN   4096

Definition at line 76 of file atiixp.c.

◆ ATI_IXP_CHN_RUNNING

#define ATI_IXP_CHN_RUNNING   0x00000001

Definition at line 83 of file atiixp.c.

◆ ATI_IXP_CHN_SUSPEND

#define ATI_IXP_CHN_SUSPEND   0x00000002

Definition at line 84 of file atiixp.c.

◆ ATI_IXP_DMA_RETRY_MAX

#define ATI_IXP_DMA_RETRY_MAX   100

Definition at line 74 of file atiixp.c.

◆ atiixp_assert

#define atiixp_assert (   _sc)    snd_mtxassert((_sc)->lock)

Definition at line 146 of file atiixp.c.

◆ atiixp_chan_active

#define atiixp_chan_active (   sc)
Value:
(((sc)->pch.flags | (sc)->rch.flags) & \
#define ATI_IXP_CHN_RUNNING
Definition: atiixp.c:83

Definition at line 686 of file atiixp.c.

◆ atiixp_lock

#define atiixp_lock (   _sc)    snd_mtxlock((_sc)->lock)

Definition at line 144 of file atiixp.c.

◆ atiixp_rd

#define atiixp_rd (   _sc,
  _reg 
)     bus_space_read_4((_sc)->st, (_sc)->sh, _reg)

Definition at line 139 of file atiixp.c.

◆ atiixp_unlock

#define atiixp_unlock (   _sc)    snd_mtxunlock((_sc)->lock)

Definition at line 145 of file atiixp.c.

◆ atiixp_wr

#define atiixp_wr (   _sc,
  _reg,
  _val 
)     bus_space_write_4((_sc)->st, (_sc)->sh, _reg, _val)

Definition at line 141 of file atiixp.c.

Function Documentation

◆ AC97_DECLARE()

AC97_DECLARE ( atiixp_ac97  )

◆ atiixp_buildsgdt()

static void atiixp_buildsgdt ( struct atiixp_chinfo ch)
static

◆ atiixp_chan_getcaps()

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

Definition at line 845 of file atiixp.c.

References atiixp_caps, atiixp_caps_32bit, atiixp_chinfo::caps_32bit, and data.

◆ atiixp_chan_getptr()

static uint32_t atiixp_chan_getptr ( kobj_t  obj,
void *  data 
)
static

Definition at line 828 of file atiixp.c.

References atiixp_dmapos(), atiixp_lock, atiixp_unlock, data, atiixp_chinfo::parent, atiixp_info::polling, and atiixp_chinfo::ptr.

Here is the call graph for this function:

◆ atiixp_chan_init()

◆ atiixp_chan_setblocksize()

static uint32_t atiixp_chan_setblocksize ( kobj_t  obj,
void *  data,
uint32_t  blksz 
)
static

Definition at line 571 of file atiixp.c.

References atiixp_chan_setfragments(), atiixp_info::blkcnt, atiixp_chinfo::blksz, blksz, data, and atiixp_chinfo::parent.

Here is the call graph for this function:

◆ atiixp_chan_setformat()

static int atiixp_chan_setformat ( kobj_t  obj,
void *  data,
uint32_t  format 
)
static

◆ atiixp_chan_setfragments()

static int atiixp_chan_setfragments ( kobj_t  obj,
void *  data,
uint32_t  blksz,
uint32_t  blkcnt 
)
static

◆ atiixp_chan_setspeed()

static uint32_t atiixp_chan_setspeed ( kobj_t  obj,
void *  data,
uint32_t  spd 
)
static

Definition at line 525 of file atiixp.c.

References ATI_IXP_BASE_RATE.

◆ atiixp_chan_trigger()

◆ atiixp_chip_post_init()

◆ atiixp_chip_pre_init()

static void atiixp_chip_pre_init ( struct atiixp_info sc)
static

Definition at line 937 of file atiixp.c.

References ATI_REG_CMD, ATI_REG_CMD_IN_DMA_EN, ATI_REG_CMD_OUT_DMA_EN, ATI_REG_CMD_SPDF_OUT_EN, ATI_REG_IER, atiixp_disable_interrupts(), atiixp_lock, atiixp_rd, atiixp_reset_aclink(), atiixp_unlock, atiixp_wr, CODEC_CHECK_BITS, atiixp_info::codec_not_ready_bits, and value.

Referenced by atiixp_pci_attach().

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

◆ atiixp_disable_dma()

static void atiixp_disable_dma ( struct atiixp_chinfo ch)
static

Definition at line 348 of file atiixp.c.

References ATI_REG_CMD, atiixp_rd, atiixp_wr, atiixp_chinfo::enable_bit, atiixp_chinfo::parent, and value.

Referenced by atiixp_chan_init(), and atiixp_chan_trigger().

Here is the caller graph for this function:

◆ atiixp_disable_interrupts()

static void atiixp_disable_interrupts ( struct atiixp_info sc)
static

Definition at line 251 of file atiixp.c.

References ATI_REG_IER, ATI_REG_ISR, and atiixp_wr.

Referenced by atiixp_chip_post_init(), atiixp_chip_pre_init(), atiixp_pci_detach(), atiixp_pci_suspend(), and sysctl_atiixp_polling().

Here is the caller graph for this function:

◆ atiixp_dma_cb()

static void atiixp_dma_cb ( void *  p,
bus_dma_segment_t *  bds,
int  a,
int  b 
)
static

Definition at line 930 of file atiixp.c.

References atiixp_info::sgd_addr.

Referenced by atiixp_pci_attach().

Here is the caller graph for this function:

◆ atiixp_dmapos()

static __inline uint32_t atiixp_dmapos ( struct atiixp_chinfo ch)
static

◆ atiixp_enable_dma()

static void atiixp_enable_dma ( struct atiixp_chinfo ch)
static

Definition at line 336 of file atiixp.c.

References ATI_REG_CMD, atiixp_rd, atiixp_wr, atiixp_chinfo::enable_bit, atiixp_chinfo::parent, and value.

Referenced by atiixp_chan_trigger().

Here is the caller graph for this function:

◆ atiixp_enable_interrupts()

static void atiixp_enable_interrupts ( struct atiixp_info sc)
static

◆ atiixp_flush_dma()

static void atiixp_flush_dma ( struct atiixp_chinfo ch)
static

Definition at line 330 of file atiixp.c.

References ATI_REG_FIFO_FLUSH, atiixp_wr, atiixp_chinfo::flush_bit, and atiixp_chinfo::parent.

Referenced by atiixp_chan_trigger().

Here is the caller graph for this function:

◆ atiixp_intr()

◆ atiixp_pci_attach()

◆ atiixp_pci_detach()

static int atiixp_pci_detach ( device_t  dev)
static

Definition at line 1312 of file atiixp.c.

References atiixp_disable_interrupts(), atiixp_release_resource(), atiixp_info::codec, dev, pcm_getdevinfo(), pcm_unregister(), r, atiixp_info::sh, and atiixp_info::st.

Here is the call graph for this function:

◆ atiixp_pci_probe()

static int atiixp_pci_probe ( device_t  dev)
static

Definition at line 1171 of file atiixp.c.

References atiixp_hw, desc, dev, devid, and vendor.

◆ atiixp_pci_resume()

◆ atiixp_pci_suspend()

◆ atiixp_poll_callback()

static void atiixp_poll_callback ( void *  arg)
static

Definition at line 690 of file atiixp.c.

References atiixp_chan_active, atiixp_lock, atiixp_poll_callback(), atiixp_poll_channel(), atiixp_unlock, atiixp_chinfo::channel, chn_intr(), atiixp_info::pch, atiixp_info::poll_timer, atiixp_info::polling, atiixp_info::rch, and trigger.

Referenced by atiixp_chan_trigger(), and atiixp_poll_callback().

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

◆ atiixp_poll_channel()

static __inline int atiixp_poll_channel ( struct atiixp_chinfo ch)
static

Definition at line 663 of file atiixp.c.

References ATI_IXP_CHN_RUNNING, atiixp_dmapos(), atiixp_chinfo::blkcnt, atiixp_chinfo::blksz, blksz, atiixp_chinfo::flags, atiixp_chinfo::prevptr, and atiixp_chinfo::ptr.

Referenced by atiixp_poll_callback().

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

◆ atiixp_rdcd()

static int atiixp_rdcd ( kobj_t  obj,
void *  devinfo,
int  reg 
)
static

◆ atiixp_release_resource()

◆ atiixp_reset_aclink()

static void atiixp_reset_aclink ( struct atiixp_info sc)
static

◆ atiixp_waitready_codec()

static int atiixp_waitready_codec ( struct atiixp_info sc)
static

Definition at line 363 of file atiixp.c.

References ATI_REG_PHYS_OUT_ADDR, ATI_REG_PHYS_OUT_ADDR_EN, and atiixp_rd.

Referenced by atiixp_rdcd(), and atiixp_wrcd().

Here is the caller graph for this function:

◆ atiixp_wrcd()

static int atiixp_wrcd ( kobj_t  obj,
void *  devinfo,
int  reg,
uint32_t  data 
)
static

◆ CHANNEL_DECLARE()

CHANNEL_DECLARE ( atiixp_chan  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( snd_atiixp  ,
pci  ,
atiixp_driver  ,
pcm_devclass  ,
,
 
)

◆ MODULE_DEPEND()

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

◆ MODULE_VERSION()

MODULE_VERSION ( snd_atiixp  ,
 
)

◆ SND_DECLARE_FILE()

SND_DECLARE_FILE ( "$FreeBSD$"  )

◆ sysctl_atiixp_polling()

static int sysctl_atiixp_polling ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 964 of file atiixp.c.

References atiixp_chan_active, atiixp_disable_interrupts(), atiixp_enable_interrupts(), atiixp_lock, atiixp_unlock, dev, pcm_getdevinfo(), atiixp_info::polling, req, and val.

Referenced by atiixp_chip_post_init().

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

Variable Documentation

◆ atiixp_ac97_methods

kobj_method_t atiixp_ac97_methods[]
static
Initial value:
= {
KOBJMETHOD(ac97_read, atiixp_rdcd),
KOBJMETHOD(ac97_write, atiixp_wrcd),
}
static int atiixp_wrcd(kobj_t, void *, int, uint32_t)
Definition: atiixp.c:410
static int atiixp_rdcd(kobj_t, void *, int)
Definition: atiixp.c:378
#define KOBJMETHOD_END
Definition: midi.c:76

Definition at line 426 of file atiixp.c.

◆ atiixp_caps

struct pcmchan_caps atiixp_caps
static
Initial value:
= {
}
static uint32_t atiixp_fmt[]
Definition: atiixp.c:154
#define ATI_IXP_BASE_RATE
Definition: atiixp.h:58

Definition at line 165 of file atiixp.c.

Referenced by atiixp_chan_getcaps().

◆ atiixp_caps_32bit

struct pcmchan_caps atiixp_caps_32bit
static
Initial value:
= {
}
static uint32_t atiixp_fmt_32bit[]
Definition: atiixp.c:148

Definition at line 159 of file atiixp.c.

Referenced by atiixp_chan_getcaps().

◆ atiixp_chan_methods

kobj_method_t atiixp_chan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, atiixp_chan_init),
KOBJMETHOD(channel_setformat, atiixp_chan_setformat),
KOBJMETHOD(channel_setspeed, atiixp_chan_setspeed),
KOBJMETHOD(channel_setblocksize, atiixp_chan_setblocksize),
KOBJMETHOD(channel_setfragments, atiixp_chan_setfragments),
KOBJMETHOD(channel_trigger, atiixp_chan_trigger),
KOBJMETHOD(channel_getptr, atiixp_chan_getptr),
KOBJMETHOD(channel_getcaps, atiixp_chan_getcaps),
}
static int atiixp_chan_trigger(kobj_t, void *, int)
Definition: atiixp.c:720
static uint32_t atiixp_chan_setspeed(kobj_t, void *, uint32_t)
Definition: atiixp.c:525
static int atiixp_chan_setfragments(kobj_t, void *, uint32_t, uint32_t)
Definition: atiixp.c:532
static struct pcmchan_caps * atiixp_chan_getcaps(kobj_t, void *)
Definition: atiixp.c:845
static void * atiixp_chan_init(kobj_t, void *, struct snd_dbuf *, struct pcm_channel *, int)
Definition: atiixp.c:437
static uint32_t atiixp_chan_setblocksize(kobj_t, void *, uint32_t)
Definition: atiixp.c:571
static int atiixp_chan_setformat(kobj_t, void *, uint32_t)
Definition: atiixp.c:488
static uint32_t atiixp_chan_getptr(kobj_t, void *)
Definition: atiixp.c:828

Definition at line 854 of file atiixp.c.

◆ atiixp_driver

driver_t atiixp_driver
static
Initial value:
= {
"pcm",
}
static device_method_t atiixp_methods[]
Definition: atiixp.c:1408
#define PCM_SOFTC_SIZE
Definition: sound.h:96

Definition at line 1417 of file atiixp.c.

◆ atiixp_fmt

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

Definition at line 154 of file atiixp.c.

◆ atiixp_fmt_32bit

uint32_t atiixp_fmt_32bit[]
static
Initial value:
= {
SND_FORMAT(AFMT_S16_LE, 2, 0),
SND_FORMAT(AFMT_S32_LE, 2, 0),
0
}

Definition at line 148 of file atiixp.c.

◆ 

const struct { ... } atiixp_hw[]
Initial value:
= {
{ ATI_VENDOR_ID, ATI_IXP_200_ID, "ATI IXP 200" },
{ ATI_VENDOR_ID, ATI_IXP_300_ID, "ATI IXP 300" },
{ ATI_VENDOR_ID, ATI_IXP_400_ID, "ATI IXP 400" },
{ ATI_VENDOR_ID, ATI_IXP_SB600_ID, "ATI IXP SB600" },
}
#define ATI_IXP_SB600_ID
Definition: atiixp.h:56
#define ATI_VENDOR_ID
Definition: atiixp.h:51
#define ATI_IXP_300_ID
Definition: atiixp.h:54
#define ATI_IXP_200_ID
Definition: atiixp.h:53
#define ATI_IXP_400_ID
Definition: atiixp.h:55

Referenced by atiixp_pci_probe().

◆ atiixp_methods

device_method_t atiixp_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, atiixp_pci_probe),
DEVMETHOD(device_attach, atiixp_pci_attach),
DEVMETHOD(device_detach, atiixp_pci_detach),
DEVMETHOD(device_suspend, atiixp_pci_suspend),
DEVMETHOD(device_resume, atiixp_pci_resume),
{ 0, 0 }
}
static int atiixp_pci_suspend(device_t)
Definition: atiixp.c:1333
static int atiixp_pci_detach(device_t)
Definition: atiixp.c:1312
static int atiixp_pci_attach(device_t)
Definition: atiixp.c:1190
static int atiixp_pci_probe(device_t)
Definition: atiixp.c:1171
static int atiixp_pci_resume(device_t)
Definition: atiixp.c:1364

Definition at line 1408 of file atiixp.c.

◆ desc

◆ devid

◆ vendor

uint16_t vendor

Definition at line 172 of file atiixp.c.

Referenced by atiixp_pci_probe(), emu_pci_probe(), ich_pci_attach(), and ich_pci_probe().