#ifndef DBRI_VAR_H
#define DBRI_VAR_H
#define DBRI_NUM_COMMANDS 64
#define DBRI_NUM_DESCRIPTORS 32
#define DBRI_INT_BLOCKS 64
#define DBRI_PIPE_MAX 32
struct dbri_softc;
enum direction {
in,
out
};
struct dbri_xmit {
volatile uint32_t flags;
#define TX_EOF 0x80000000
#define TX_BCNT(x) ((x&0x3fff)<<16)
#define TX_BINT 0x00008000
#define TX_MINT 0x00004000
#define TX_IDLE 0x00002000
#define TX_FCNT(x) (x&0x1fff)
volatile uint32_t ba;
volatile uint32_t nda;
volatile uint32_t status;
#define TS_OK 0x0001
#define TS_ABORT 0x0004
#define TS_UNDERRUN 0x0008
};
struct dbri_recv {
volatile uint32_t status;
#define RX_EOF 0x80000000
#define RX_COMPLETED 0x40000000
#define RX_BCNT(x) ((x & 0x3fff) << 16)
#define RX_CRCERROR 0x00000080
#define RX_BBC 0x00000040
#define RX_ABORT 0x00000020
#define RX_OVERRUN 0x00000008
volatile uint32_t ba;
volatile uint32_t nda;
volatile uint32_t flags;
#define RX_BSIZE(x) (x & 0x3fff)
#define RX_FINAL 0x00008000
#define RX_MARKER 0x00004000
};
struct dbri_pipe {
uint32_t sdp;
enum direction direction;
int next;
int prev;
int cycle;
int length;
int desc;
volatile uint32_t *prec;
};
struct dbri_desc {
int busy;
void * buf;
void * buf_dvma;
bus_addr_t dmabase;
bus_dma_segment_t dmaseg;
bus_dmamap_t dmamap;
size_t len;
void (*callback)(void *);
void *callback_args;
void *softint;
struct dbri_softc *sc;
};
struct dbri_dma {
volatile uint32_t command[DBRI_NUM_COMMANDS];
volatile int32_t intr[DBRI_INT_BLOCKS];
struct dbri_xmit xmit[DBRI_NUM_DESCRIPTORS];
struct dbri_recv recv[DBRI_NUM_DESCRIPTORS];
};
struct dbri_softc {
device_t sc_dev;
bus_space_handle_t sc_ioh;
bus_space_tag_t sc_iot;
bus_dma_tag_t sc_dmat;
bus_dmamap_t sc_dmamap;
bus_dma_segment_t sc_dmaseg;
int sc_have_powerctl;
int sc_init_done;
int sc_powerstate;
int sc_pmgrstate;
int sc_burst;
bus_addr_t sc_dmabase;
void * sc_membase;
int sc_bufsiz;
int sc_locked;
int sc_irqp;
int sc_waitseen;
int sc_playing;
int sc_recording;
int sc_liu_state;
void (*sc_liu)(void *);
void *sc_liu_args;
struct dbri_pipe sc_pipe[DBRI_PIPE_MAX];
struct dbri_desc sc_desc[DBRI_NUM_DESCRIPTORS];
struct cs4215_state sc_mm;
int sc_latt, sc_ratt;
int sc_linp, sc_rinp;
int sc_monitor;
int sc_input;
int sc_whack_codec;
int sc_ctl_mode;
uint32_t sc_version;
int sc_chi_pipe_in;
int sc_chi_pipe_out;
int sc_chi_bpf;
int sc_desc_used;
struct audio_params sc_params;
struct dbri_dma *sc_dma;
kmutex_t sc_lock;
kmutex_t sc_intr_lock;
#ifndef DBRI_SPIN
kcondvar_t sc_cv;
#endif
};
#define dbri_dma_off(member, elem) \
((uint32_t)(unsigned long) \
(&(((struct dbri_dma *)0)->member[elem])))
#if 1
#define DBRI_CMD(cmd, intr, value) ((cmd << 28) | (intr << 27) | value)
#else
#define DBRI_CMD(cmd, intr, value) ((cmd << 28) | (1 << 27) | value)
#endif
#define DBRI_INTR_GETCHAN(v) (((v) >> 24) & 0x3f)
#define DBRI_INTR_GETCODE(v) (((v) >> 20) & 0xf)
#define DBRI_INTR_GETCMD(v) (((v) >> 16) & 0xf)
#define DBRI_INTR_GETVAL(v) ((v) & 0xffff)
#define DBRI_INTR_GETRVAL(v) ((v) & 0xfffff)
#define DBRI_SDP_MODE(v) ((v) & (7 << 13))
#define DBRI_PIPE(v) ((v) << 0)
#endif