2006-08-06 20:21:11 +04:00
|
|
|
/* $NetBSD: cs428x.h,v 1.11 2006/08/06 16:21:11 jmcneill Exp $ */
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 Tatoku Ogaito. 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Tatoku Ogaito
|
|
|
|
* for the NetBSD Project.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Common functions and variables for CS4280 and CS4281 */
|
|
|
|
|
|
|
|
#ifndef _CS428X_H_
|
|
|
|
#define _CS428X_H_
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
#define PCI_BA0 (0x10)
|
|
|
|
#define PCI_BA1 (0x14)
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
#define CS428X_SAVE_REG_MAX (0x10)
|
2005-01-15 18:19:51 +03:00
|
|
|
#define TYPE_CS4280 (0x4280)
|
|
|
|
#define TYPE_CS4281 (0x4281)
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
#define BA0READ4(sc, r) bus_space_read_4((sc)->ba0t, (sc)->ba0h, (r))
|
|
|
|
#define BA0WRITE4(sc, r, x) bus_space_write_4((sc)->ba0t, (sc)->ba0h, (r), (x))
|
|
|
|
|
|
|
|
/* DMA */
|
|
|
|
struct cs428x_dma {
|
|
|
|
bus_dmamap_t map;
|
2003-05-03 22:10:37 +04:00
|
|
|
caddr_t addr; /* real DMA buffer */
|
2001-01-22 04:34:42 +03:00
|
|
|
caddr_t dum; /* dummy buffer for audio driver */
|
|
|
|
bus_dma_segment_t segs[1];
|
|
|
|
int nsegs;
|
|
|
|
size_t size;
|
|
|
|
struct cs428x_dma *next;
|
|
|
|
};
|
|
|
|
#define DMAADDR(p) ((p)->map->dm_segs[0].ds_addr)
|
2003-05-03 22:10:37 +04:00
|
|
|
#define KERNADDR(p) ((void *)((p)->addr)) /* buffer for real DMA */
|
2001-01-22 04:34:42 +03:00
|
|
|
#define BUFADDR(p) ((void *)((p)->dum)) /* buffer for audio driver */
|
|
|
|
|
2006-04-16 01:20:47 +04:00
|
|
|
/*
|
|
|
|
* Flags (currently used only for CS4280)
|
|
|
|
*/
|
|
|
|
enum cs428x_flags {
|
|
|
|
CS428X_FLAG_NONE = 0x0,
|
|
|
|
CS428X_FLAG_INVAC97EAMP = 0x1, /* inverted AC97 external amp */
|
2006-08-06 20:21:11 +04:00
|
|
|
CS428X_FLAG_CLKRUNHACK = 0x2 /* needs CLKRUN hack */
|
2006-04-16 01:20:47 +04:00
|
|
|
};
|
|
|
|
|
2001-01-22 04:34:42 +03:00
|
|
|
/*
|
|
|
|
* Software state
|
|
|
|
*/
|
|
|
|
struct cs428x_softc {
|
|
|
|
struct device sc_dev;
|
|
|
|
|
|
|
|
pci_intr_handle_t * sc_ih;
|
|
|
|
|
|
|
|
/* I/O (BA0) */
|
|
|
|
bus_space_tag_t ba0t;
|
|
|
|
bus_space_handle_t ba0h;
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-22 04:34:42 +03:00
|
|
|
/* BA1 */
|
|
|
|
bus_space_tag_t ba1t;
|
|
|
|
bus_space_handle_t ba1h;
|
2005-01-15 18:19:51 +03:00
|
|
|
|
2001-01-22 04:34:42 +03:00
|
|
|
/* DMA */
|
|
|
|
bus_dma_tag_t sc_dmatag;
|
|
|
|
struct cs428x_dma *sc_dmas;
|
|
|
|
size_t dma_size;
|
|
|
|
size_t dma_align;
|
|
|
|
|
2005-01-15 18:19:51 +03:00
|
|
|
int hw_blocksize;
|
|
|
|
int type;
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
/* playback */
|
2003-05-03 22:10:37 +04:00
|
|
|
void (*sc_pintr)(void *); /* DMA completion intr handler */
|
2001-01-22 04:34:42 +03:00
|
|
|
void *sc_parg; /* arg for sc_intr() */
|
|
|
|
char *sc_ps, *sc_pe, *sc_pn;
|
|
|
|
int sc_pcount;
|
|
|
|
int sc_pi;
|
|
|
|
struct cs428x_dma *sc_pdma;
|
|
|
|
char *sc_pbuf;
|
2005-01-15 18:19:51 +03:00
|
|
|
int (*halt_output)(void *);
|
|
|
|
char sc_prun; /* playback status */
|
|
|
|
int sc_prate; /* playback sample rate */
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
/* capturing */
|
2003-05-03 22:10:37 +04:00
|
|
|
void (*sc_rintr)(void *); /* DMA completion intr handler */
|
2001-01-22 04:34:42 +03:00
|
|
|
void *sc_rarg; /* arg for sc_intr() */
|
|
|
|
char *sc_rs, *sc_re, *sc_rn;
|
|
|
|
int sc_rcount;
|
|
|
|
int sc_ri;
|
|
|
|
struct cs428x_dma *sc_rdma;
|
|
|
|
char *sc_rbuf;
|
|
|
|
int sc_rparam; /* record format */
|
2005-01-15 18:19:51 +03:00
|
|
|
int (*halt_input)(void *);
|
|
|
|
char sc_rrun; /* recording status */
|
|
|
|
int sc_rrate; /* recording sample rate */
|
2001-01-22 04:34:42 +03:00
|
|
|
|
2001-02-07 17:41:10 +03:00
|
|
|
/* Although cs4281 does not support midi (yet),
|
|
|
|
* don't remove these definition.
|
|
|
|
*/
|
2001-01-22 04:34:42 +03:00
|
|
|
void (*sc_iintr)(void *, int); /* midi input ready handler */
|
|
|
|
void (*sc_ointr)(void *); /* midi output ready handler */
|
|
|
|
void *sc_arg;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
2006-04-16 01:20:47 +04:00
|
|
|
* Actually these 3 variables are needed only for CS4280.
|
2001-01-22 04:34:42 +03:00
|
|
|
*/
|
2006-04-16 01:20:47 +04:00
|
|
|
enum cs428x_flags sc_flags;
|
2005-01-15 18:19:51 +03:00
|
|
|
uint32_t pctl;
|
|
|
|
uint32_t cctl;
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
/* AC97 CODEC */
|
|
|
|
struct ac97_codec_if *codec_if;
|
2005-01-15 18:19:51 +03:00
|
|
|
struct ac97_host_if host_if;
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
/* Power Management */
|
|
|
|
char sc_suspend;
|
|
|
|
void *sc_powerhook; /* Power Hook */
|
2006-08-06 20:21:11 +04:00
|
|
|
|
|
|
|
/* CLKRUN hack (CS428X_FLAG_CLKRUN), only for CS4280 */
|
|
|
|
int sc_active;
|
|
|
|
bus_space_tag_t sc_pm_iot;
|
|
|
|
bus_space_handle_t sc_pm_ioh;
|
2001-01-22 04:34:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
merge kent-audio1 branch, which introduces audio filter pipeline to the MI
audio framework
Summary of changes:
* struct audio_params
- remove sw_code, factor, factor_denom, hw_sample_rate,
hw_encoding ,hw_precision, and hw_channels. Conversion information
is conveyed by stream_filter_list_t.
- change the type of sample_rate: u_long -> u_int
- add `validbits,' which represents the valid data size in
precision bits. It is required in order to distinguish 24/32bit
from 24/24bit or 32/32bit.
* audio_hw_if
- add two parameters to set_params()
stream_filter_list_t *pfil, stream_filter_list *rfil
A HW driver should set filter recipes for requested formats
- constify audio_params parameters of trigger_output() and
trigger_input(). They represent audio formats for the hardware.
- make open() and close() optional
- add int (AUMODE_PLAY or AUMODE_RECORD) and audio_params_t parameters
to round_blocksize()
* sw_code is replaced with stream_filter_t.
stream_filer_t converts audio data in an input buffer and writes
into another output buffer unlike sw_code, which converts data in
single buffer.
converters in dev/auconv.c, dev/mulaw.c, dev/aurateconv.c,
dev/tc/bba.c, dev/ic/msm6258.c, and arch/arm/iomd/vidcaudio.c are
reimplemented as stream_filter_t
* MI audio
- audiosetinfo() builds filter pipelines from stream_filter_list_t
filled by audio_hw_if::set_params()
- audiosetinfo() returns with EINVAL if mmapped and set_params()
requests filters
- audio_write(), audio_pint(), and audio_rint() invoke a filter
pipeline.
- ioctl() for FIONREAD, AUDIO_WSEEK, AUDIO_GETIOFFS,
AUDIO_GETOOFFS, and audio_prinfo::{seek,samples} for
AUDIO_GETINFO handle values for a buffer nearest to userland.
* add `struct device *' parameter to ac97_attach()
* all of audio HW drivers follow audio_hw_if and ac97 changes
2005-01-11 01:01:36 +03:00
|
|
|
int cs428x_round_blocksize(void *, int, int, const audio_params_t *);
|
2001-01-22 04:34:42 +03:00
|
|
|
int cs428x_get_props(void *);
|
|
|
|
int cs428x_attach_codec(void *, struct ac97_codec_if *);
|
2001-02-07 17:41:10 +03:00
|
|
|
int cs428x_read_codec(void *, u_int8_t, u_int16_t *);
|
2001-01-22 04:34:42 +03:00
|
|
|
int cs428x_write_codec(void *, u_int8_t, u_int16_t);
|
|
|
|
|
|
|
|
int cs428x_mixer_set_port(void *, mixer_ctrl_t *);
|
|
|
|
int cs428x_mixer_get_port(void *, mixer_ctrl_t *);
|
|
|
|
int cs428x_query_devinfo(void *, mixer_devinfo_t *);
|
2003-02-01 09:23:35 +03:00
|
|
|
void *cs428x_malloc(void *, int, size_t, struct malloc_type *, int);
|
2001-01-22 04:34:42 +03:00
|
|
|
size_t cs428x_round_buffersize(void *, int, size_t);
|
2003-02-01 09:23:35 +03:00
|
|
|
void cs428x_free(void *, void *, struct malloc_type *);
|
2001-01-22 04:34:42 +03:00
|
|
|
paddr_t cs428x_mappage(void *, void *, off_t, int);
|
|
|
|
|
|
|
|
/* internal functions */
|
2003-02-01 09:23:35 +03:00
|
|
|
int cs428x_allocmem(struct cs428x_softc *, size_t, struct malloc_type *,
|
|
|
|
int, struct cs428x_dma *);
|
2001-01-22 04:34:42 +03:00
|
|
|
int cs428x_src_wait(struct cs428x_softc *);
|
|
|
|
|
|
|
|
|
|
|
|
/* DEBUG */
|
2001-02-07 17:41:10 +03:00
|
|
|
/* #define CS4280_DEBUG */
|
|
|
|
/* #define CS4281_DEBUG */
|
2001-01-22 04:34:42 +03:00
|
|
|
|
|
|
|
#if defined(CS4280_DEBUG) || defined(CS4281_DEBUG)
|
|
|
|
#define DPRINTF(x) if (cs428x_debug) printf x
|
|
|
|
#define DPRINTFN(n,x) if (cs428x_debug>(n)) printf x
|
|
|
|
extern int cs428x_debug;
|
|
|
|
#if CS4280_DEBUG + 0 == 0
|
|
|
|
#undef CS4280_DEBUG
|
|
|
|
#define CS4280_DEBUG 0
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define DPRINTF(x)
|
|
|
|
#define DPRINTFN(n,x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _CS428X_H_ */
|