FreeBSD kernel sound device code
audio_soc.c File Reference
#include <sys/cdefs.h>
#include "opt_platform.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/clock.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/module.h>
#include <sys/endian.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/sound/fdt/audio_dai.h>
#include <dev/sound/pcm/sound.h>
#include "audio_dai_if.h"
Include dependency graph for audio_soc.c:

Go to the source code of this file.

Data Structures

struct  audio_soc_aux_node
 
struct  audio_soc_channel
 
struct  audio_soc_softc
 

Macros

#define AUDIO_BUFFER_SIZE   48000 * 4
 

Functions

 __FBSDID ("$FreeBSD$")
 
static int audio_soc_probe (device_t dev)
 
static int audio_soc_attach (device_t dev)
 
static int audio_soc_detach (device_t dev)
 
static uint32_t audio_soc_reverse_clocks (uint32_t format)
 
static uint32_t audio_soc_chan_setblocksize (kobj_t obj, void *data, uint32_t blocksz)
 
static int audio_soc_chan_setformat (kobj_t obj, void *data, uint32_t format)
 
static uint32_t audio_soc_chan_setspeed (kobj_t obj, void *data, uint32_t speed)
 
static uint32_t audio_soc_chan_getptr (kobj_t obj, void *data)
 
static void * audio_soc_chan_init (kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
 
static int audio_soc_chan_trigger (kobj_t obj, void *data, int go)
 
static int audio_soc_chan_free (kobj_t obj, void *data)
 
static struct pcmchan_capsaudio_soc_chan_getcaps (kobj_t obj, void *data)
 
 CHANNEL_DECLARE (audio_soc_chan)
 
static void audio_soc_intr (void *arg)
 
static void audio_soc_init (void *arg)
 
 DRIVER_MODULE (audio_soc, simplebus, audio_soc_driver, pcm_devclass, NULL, NULL)
 
 MODULE_VERSION (audio_soc, 1)
 

Variables

static struct ofw_compat_data compat_data []
 
struct {
   const char *   name
 
   unsigned int   fmt
 
ausoc_dai_formats []
 
static kobj_method_t audio_soc_chan_methods []
 
static device_method_t audio_soc_methods []
 
static driver_t audio_soc_driver
 

Macro Definition Documentation

◆ AUDIO_BUFFER_SIZE

#define AUDIO_BUFFER_SIZE   48000 * 4

Definition at line 47 of file audio_soc.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ audio_soc_attach()

◆ audio_soc_chan_free()

static int audio_soc_chan_free ( kobj_t  obj,
void *  data 
)
static

Definition at line 246 of file audio_soc.c.

References audio_soc_channel::buf, buffer, data, free, and sndbuf_getbuf().

Here is the call graph for this function:

◆ audio_soc_chan_getcaps()

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

Definition at line 262 of file audio_soc.c.

References audio_soc_softc::cpu_dev, data, and audio_soc_channel::sc.

◆ audio_soc_chan_getptr()

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

◆ audio_soc_chan_init()

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

Definition at line 207 of file audio_soc.c.

References AUDIO_BUFFER_SIZE, b, audio_soc_channel::buf, buffer, c, devinfo, audio_soc_channel::dir, dir, free, audio_soc_channel::pcm, and sndbuf_setup().

Here is the call graph for this function:

◆ audio_soc_chan_setblocksize()

static uint32_t audio_soc_chan_setblocksize ( kobj_t  obj,
void *  data,
uint32_t  blocksz 
)
static

Definition at line 137 of file audio_soc.c.

◆ audio_soc_chan_setformat()

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

Definition at line 144 of file audio_soc.c.

References audio_soc_softc::cpu_dev, data, format, and audio_soc_channel::sc.

◆ audio_soc_chan_setspeed()

static uint32_t audio_soc_chan_setspeed ( kobj_t  obj,
void *  data,
uint32_t  speed 
)
static

◆ audio_soc_chan_trigger()

static int audio_soc_chan_trigger ( kobj_t  obj,
void *  data,
int  go 
)
static

◆ audio_soc_detach()

static int audio_soc_detach ( device_t  dev)
static

Definition at line 507 of file audio_soc.c.

References dev, free, and audio_soc_softc::name.

◆ audio_soc_init()

static void audio_soc_init ( void *  arg)
static

Definition at line 316 of file audio_soc.c.

References audio_soc_intr(), audio_soc_reverse_clocks(), child, audio_soc_softc::codec_dev, audio_soc_softc::cpu_dev, audio_soc_softc::dev, audio_soc_softc::init_hook, pcm_addchan(), pcm_register(), pcm_setstatus(), PCMDIR_PLAY, and PCMDIR_REC.

Referenced by audio_soc_attach().

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

◆ audio_soc_intr()

static void audio_soc_intr ( void *  arg)
static

Definition at line 287 of file audio_soc.c.

References AUDIO_DAI_PLAY_INTR, AUDIO_DAI_REC_INTR, chn_intr(), and audio_soc_softc::cpu_dev.

Referenced by audio_soc_init().

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

◆ audio_soc_probe()

static int audio_soc_probe ( device_t  dev)
static

Definition at line 301 of file audio_soc.c.

References compat_data, and dev.

◆ audio_soc_reverse_clocks()

static uint32_t audio_soc_reverse_clocks ( uint32_t  format)
static

◆ CHANNEL_DECLARE()

CHANNEL_DECLARE ( audio_soc_chan  )

◆ DRIVER_MODULE()

DRIVER_MODULE ( audio_soc  ,
simplebus  ,
audio_soc_driver  ,
pcm_devclass  ,
NULL  ,
NULL   
)

◆ MODULE_VERSION()

MODULE_VERSION ( audio_soc  ,
 
)

Variable Documentation

◆ audio_soc_chan_methods

kobj_method_t audio_soc_chan_methods[]
static
Initial value:
= {
KOBJMETHOD(channel_init, audio_soc_chan_init),
KOBJMETHOD(channel_free, audio_soc_chan_free),
KOBJMETHOD(channel_setformat, audio_soc_chan_setformat),
KOBJMETHOD(channel_setspeed, audio_soc_chan_setspeed),
KOBJMETHOD(channel_setblocksize,audio_soc_chan_setblocksize),
KOBJMETHOD(channel_trigger, audio_soc_chan_trigger),
KOBJMETHOD(channel_getptr, audio_soc_chan_getptr),
KOBJMETHOD(channel_getcaps, audio_soc_chan_getcaps),
}
static int audio_soc_chan_free(kobj_t obj, void *data)
Definition: audio_soc.c:246
static void * audio_soc_chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir)
Definition: audio_soc.c:207
static struct pcmchan_caps * audio_soc_chan_getcaps(kobj_t obj, void *data)
Definition: audio_soc.c:262
static int audio_soc_chan_trigger(kobj_t obj, void *data, int go)
Definition: audio_soc.c:229
static int audio_soc_chan_setformat(kobj_t obj, void *data, uint32_t format)
Definition: audio_soc.c:144
static uint32_t audio_soc_chan_setblocksize(kobj_t obj, void *data, uint32_t blocksz)
Definition: audio_soc.c:137
static uint32_t audio_soc_chan_setspeed(kobj_t obj, void *data, uint32_t speed)
Definition: audio_soc.c:157
static uint32_t audio_soc_chan_getptr(kobj_t obj, void *data)
Definition: audio_soc.c:195
#define KOBJMETHOD_END
Definition: midi.c:76

Definition at line 273 of file audio_soc.c.

◆ audio_soc_driver

driver_t audio_soc_driver
static
Initial value:
= {
"pcm",
sizeof(struct audio_soc_softc),
}
static device_method_t audio_soc_methods[]
Definition: audio_soc.c:524

Definition at line 533 of file audio_soc.c.

◆ audio_soc_methods

device_method_t audio_soc_methods[]
static
Initial value:
= {
DEVMETHOD(device_probe, audio_soc_probe),
DEVMETHOD(device_attach, audio_soc_attach),
DEVMETHOD(device_detach, audio_soc_detach),
DEVMETHOD_END,
}
static int audio_soc_probe(device_t dev)
Definition: audio_soc.c:301
static int audio_soc_attach(device_t dev)
Definition: audio_soc.c:423
static int audio_soc_detach(device_t dev)
Definition: audio_soc.c:507

Definition at line 524 of file audio_soc.c.

◆ 

struct { ... } ausoc_dai_formats[]
Initial value:
= {
{ "right_j", AUDIO_DAI_FORMAT_RJ },
{ "left_j", AUDIO_DAI_FORMAT_LJ },
{ "dsp_a", AUDIO_DAI_FORMAT_DSPA },
{ "dsp_b", AUDIO_DAI_FORMAT_DSPB },
{ "ac97", AUDIO_DAI_FORMAT_AC97 },
}
#define AUDIO_DAI_FORMAT_LJ
Definition: audio_dai.h:32
#define AUDIO_DAI_FORMAT_DSPB
Definition: audio_dai.h:34
#define AUDIO_DAI_FORMAT_RJ
Definition: audio_dai.h:31
#define AUDIO_DAI_FORMAT_PDM
Definition: audio_dai.h:36
#define AUDIO_DAI_FORMAT_I2S
Definition: audio_dai.h:30
#define AUDIO_DAI_FORMAT_DSPA
Definition: audio_dai.h:33
#define AUDIO_DAI_FORMAT_AC97
Definition: audio_dai.h:35

Referenced by audio_soc_attach().

◆ compat_data

struct ofw_compat_data compat_data[]
static
Initial value:
= {
{"simple-audio-card", 1},
{NULL, 0},
}

Definition at line 84 of file audio_soc.c.

Referenced by audio_soc_probe().

◆ fmt

◆ name