108045defSGarrett D'Amore /*
208045defSGarrett D'Amore  * CDDL HEADER START
308045defSGarrett D'Amore  *
408045defSGarrett D'Amore  * The contents of this file are subject to the terms of the
508045defSGarrett D'Amore  * Common Development and Distribution License (the "License").
608045defSGarrett D'Amore  * You may not use this file except in compliance with the License.
708045defSGarrett D'Amore  *
808045defSGarrett D'Amore  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
908045defSGarrett D'Amore  * or http://www.opensolaris.org/os/licensing.
1008045defSGarrett D'Amore  * See the License for the specific language governing permissions
1108045defSGarrett D'Amore  * and limitations under the License.
1208045defSGarrett D'Amore  *
1308045defSGarrett D'Amore  * When distributing Covered Code, include this CDDL HEADER in each
1408045defSGarrett D'Amore  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1508045defSGarrett D'Amore  * If applicable, add the following below this CDDL HEADER, with the
1608045defSGarrett D'Amore  * fields enclosed by brackets "[]" replaced with your own identifying
1708045defSGarrett D'Amore  * information: Portions Copyright [yyyy] [name of copyright owner]
1808045defSGarrett D'Amore  *
1908045defSGarrett D'Amore  * CDDL HEADER END
2008045defSGarrett D'Amore  */
2108045defSGarrett D'Amore /*
22*68c47f65SGarrett D'Amore  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2308045defSGarrett D'Amore  * Use is subject to license terms.
2408045defSGarrett D'Amore  */
2508045defSGarrett D'Amore /*
2608045defSGarrett D'Amore  * Purpose: Driver for CMEDIA CM8738 PCI audio controller.
2708045defSGarrett D'Amore  */
2808045defSGarrett D'Amore /*
2908045defSGarrett D'Amore  * This file is part of Open Sound System
3008045defSGarrett D'Amore  *
3108045defSGarrett D'Amore  * Copyright (C) 4Front Technologies 1996-2008.
3208045defSGarrett D'Amore  *
3308045defSGarrett D'Amore  * This software is released under CDDL 1.0 source license.
3408045defSGarrett D'Amore  * See the COPYING file included in the main directory of this source
3508045defSGarrett D'Amore  * distribution for the license terms and conditions.
3608045defSGarrett D'Amore  */
3708045defSGarrett D'Amore 
3808045defSGarrett D'Amore #ifndef	_AUDIOCMI_H
3908045defSGarrett D'Amore #define	_AUDIOCMI_H
4008045defSGarrett D'Amore 
4108045defSGarrett D'Amore #define	CMEDIA_VENDOR_ID	0x13F6
4208045defSGarrett D'Amore #define	CMEDIA_CM8738		0x0111
4308045defSGarrett D'Amore #define	CMEDIA_CM8338A		0x0100
4408045defSGarrett D'Amore #define	CMEDIA_CM8338B		0x0101
4508045defSGarrett D'Amore 
4608045defSGarrett D'Amore /*
4708045defSGarrett D'Amore  * CM8338 registers definition
4808045defSGarrett D'Amore  */
4908045defSGarrett D'Amore 
5008045defSGarrett D'Amore #define	REG_FUNCTRL0		0x00
5108045defSGarrett D'Amore #define	REG_FUNCTRL1		0x04
5208045defSGarrett D'Amore #define	REG_CHFORMAT		0x08
5308045defSGarrett D'Amore #define	REG_INTCTRL		0x0C
5408045defSGarrett D'Amore #define	REG_INTSTAT		0x10
5508045defSGarrett D'Amore #define	REG_LEGACY		0x14
5608045defSGarrett D'Amore #define	REG_MISC		0x18
5708045defSGarrett D'Amore #define	REG_TDMAPOS		0x1C
5808045defSGarrett D'Amore #define	REG_SBVER		0x20	/* 8 bit access only */
5908045defSGarrett D'Amore #define	REG_IDXDATA		0x22	/* 8 bit access only */
6008045defSGarrett D'Amore #define	REG_IDXADDR		0x23	/* 8 bit access only */
6108045defSGarrett D'Amore #define	REG_MIX2		0x24
6208045defSGarrett D'Amore #define	REG_MIX3		0x25
6308045defSGarrett D'Amore #define	REG_VAUX		0x26
6408045defSGarrett D'Amore #define	REG_CH0_PADDR		0x80	/* buffer address (32b) */
6508045defSGarrett D'Amore #define	REG_CH0_BUFSZ		0x84	/* buffer size in samples (16b) */
6608045defSGarrett D'Amore #define	REG_CH0_FRAGSZ		0x86	/* fragment size in samples (16b) */
6708045defSGarrett D'Amore #define	REG_CH1_PADDR		0x88
6808045defSGarrett D'Amore #define	REG_CH1_BUFSZ		0x8C
6908045defSGarrett D'Amore #define	REG_CH1_FRAGSZ		0x8E
70af145792SGarrett D'Amore #define	REG_SPDIF_STAT		0x90
71af145792SGarrett D'Amore #define	REG_MISC2		0x92
7208045defSGarrett D'Amore 
7308045defSGarrett D'Amore #define	FUNCTRL0_CH1_RST	BIT(19)
7408045defSGarrett D'Amore #define	FUNCTRL0_CH0_RST	BIT(18)
7508045defSGarrett D'Amore #define	FUNCTRL0_CH1_EN		BIT(17)
7608045defSGarrett D'Amore #define	FUNCTRL0_CH0_EN		BIT(16)
7708045defSGarrett D'Amore #define	FUNCTRL0_CH1_PAUSE	BIT(3)
7808045defSGarrett D'Amore #define	FUNCTRL0_CH0_PAUSE	BIT(2)
7908045defSGarrett D'Amore #define	FUNCTRL0_CH1_REC	BIT(1)
8008045defSGarrett D'Amore #define	FUNCTRL0_CH0_REC	BIT(0)
8108045defSGarrett D'Amore 
8208045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_MASK	(0x7 << 13)
8308045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_48K	(0x7 << 13)
8408045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_32K	(0x6 << 13)
8508045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_16K	(0x5 << 13)
8608045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_8K	(0x4 << 13)
8708045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_44K	(0x3 << 13)
8808045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_22K	(0x2 << 13)
8908045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_11K	(0x1 << 13)
9008045defSGarrett D'Amore #define	FUNCTRL1_DAC_RATE_5K	(0x0 << 13)
9108045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_MASK	(0x7 << 10)
9208045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_48K	(0x7 << 10)
9308045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_32K	(0x6 << 10)
9408045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_16K	(0x5 << 10)
9508045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_8K	(0x4 << 10)
9608045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_44K	(0x3 << 10)
9708045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_22K	(0x2 << 10)
9808045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_11K	(0x1 << 10)
9908045defSGarrett D'Amore #define	FUNCTRL1_ADC_RATE_5K	(0x0 << 10)
10008045defSGarrett D'Amore #define	FUNCTRL1_INTRM		BIT(5)		/* enable MCB intr */
10108045defSGarrett D'Amore #define	FUNCTRL1_BREQ		BIT(4)		/* bus master enable */
10208045defSGarrett D'Amore #define	FUNCTRL1_VOICE_EN	BIT(3)
10308045defSGarrett D'Amore #define	FUNCTRL1_UART_EN	BIT(2)
10408045defSGarrett D'Amore #define	FUNCTRL1_JYSTK_EN	BIT(1)
10508045defSGarrett D'Amore 
106af145792SGarrett D'Amore #define	CHFORMAT_CHB3D5C	BIT(31)		/* 5 channel surround */
107af145792SGarrett D'Amore #define	CHFORMAT_CHB3D		BIT(29)		/* 4 channel surround */
108af145792SGarrett D'Amore #define	CHFORMAT_VER_MASK	(0x1f << 24)
109af145792SGarrett D'Amore #define	CHFORMAT_VER_033	0
110af145792SGarrett D'Amore #define	CHFORMAT_VER_037	1
11108045defSGarrett D'Amore #define	CHFORMAT_CH1_MASK	(0x3 << 2)
11208045defSGarrett D'Amore #define	CHFORMAT_CH1_16ST	(0x3 << 2)
11308045defSGarrett D'Amore #define	CHFORMAT_CH1_16MO	(0x2 << 2)
11408045defSGarrett D'Amore #define	CHFORMAT_CH1_8ST	(0x1 << 2)
11508045defSGarrett D'Amore #define	CHFORMAT_CH1_8MO	(0x0 << 2)
11608045defSGarrett D'Amore #define	CHFORMAT_CH0_MASK	(0x3 << 0)
11708045defSGarrett D'Amore #define	CHFORMAT_CH0_16ST	(0x3 << 0)
11808045defSGarrett D'Amore #define	CHFORMAT_CH0_16MO	(0x2 << 0)
11908045defSGarrett D'Amore #define	CHFORMAT_CH0_8ST	(0x1 << 0)
12008045defSGarrett D'Amore #define	CHFORMAT_CH0_8MO	(0x0 << 0)
12108045defSGarrett D'Amore 
122af145792SGarrett D'Amore #define	INTCTRL_MDL_MASK	(0xffU << 24)
123af145792SGarrett D'Amore #define	INTCTRL_MDL_068		(0x28 << 24)
124af145792SGarrett D'Amore #define	INTCTRL_MDL_055		(0x8 << 24)
125af145792SGarrett D'Amore #define	INTCTRL_MDL_039		(0x4 << 24)
12608045defSGarrett D'Amore #define	INTCTRL_TDMA_EN		BIT(18)
12708045defSGarrett D'Amore #define	INTCTRL_CH1_EN		BIT(17)
12808045defSGarrett D'Amore #define	INTCTRL_CH0_EN		BIT(16)
12908045defSGarrett D'Amore 
13008045defSGarrett D'Amore #define	INTSTAT_INTR		BIT(31)
13108045defSGarrett D'Amore #define	INTSTAT_MCB_INT		BIT(26)
13208045defSGarrett D'Amore #define	INTSTAT_UART_INT	BIT(16)
13308045defSGarrett D'Amore #define	INTSTAT_LTDMA_INT	BIT(15)
13408045defSGarrett D'Amore #define	INTSTAT_HTDMA_INT	BIT(14)
13508045defSGarrett D'Amore #define	INTSTAT_LHBTOG		BIT(7)
13608045defSGarrett D'Amore #define	INTSTAT_LEGDMA		BIT(6)
13708045defSGarrett D'Amore #define	INTSTAT_LEGHIGH		BIT(5)
13808045defSGarrett D'Amore #define	INTSTAT_LEGSTEREO	BIT(4)
13908045defSGarrett D'Amore #define	INTSTAT_CH1_BUSY	BIT(3)
14008045defSGarrett D'Amore #define	INTSTAT_CH0_BUSY	BIT(2)
14108045defSGarrett D'Amore #define	INTSTAT_CH1_INT		BIT(1)
14208045defSGarrett D'Amore #define	INTSTAT_CH0_INT		BIT(0)
14308045defSGarrett D'Amore 
144af145792SGarrett D'Amore #define	LEGACY_NXCHG		BIT(31)
145af145792SGarrett D'Amore #define	LEGACY_CHB3D6C		BIT(15)	/* 6 channel surround */
146af145792SGarrett D'Amore #define	LEGACY_CENTR2LN		BIT(14)	/* line in as center out */
147af145792SGarrett D'Amore #define	LEGACY_BASS2LN		BIT(13)	/* line in as lfe */
148af145792SGarrett D'Amore #define	LEGACY_EXBASSEN		BIT(12)	/* external bass input enable */
149af145792SGarrett D'Amore 
15008045defSGarrett D'Amore #define	MISC_PWD		BIT(31)	/* power down */
15108045defSGarrett D'Amore #define	MISC_RESET		BIT(30)
152af145792SGarrett D'Amore #define	MISC_N4SPK3D		BIT(26)	/* 4 channel emulation */
15308045defSGarrett D'Amore #define	MISC_ENDBDAC		BIT(23)	/* dual dac */
15408045defSGarrett D'Amore #define	MISC_XCHGDAC		BIT(22)	/* swap front/rear dacs */
155af145792SGarrett D'Amore #define	MISC_SPD32SEL		BIT(21)	/* 32-bit SPDIF (default 16-bit) */
15608045defSGarrett D'Amore #define	MISC_FM_EN		BIT(19)	/* enable legacy FM */
157af145792SGarrett D'Amore #define	MISC_SPDF_AC97		BIT(15)	/* spdif out 44.1k (0), 48 k (1) */
158af145792SGarrett D'Amore #define	MISC_ENCENTER		BIT(7)	/* enable center */
159af145792SGarrett D'Amore #define	MISC_REAR2LN		BIT(6)	/* send rear to line in */
16008045defSGarrett D'Amore 
16108045defSGarrett D'Amore #define	MIX2_FMMUTE		BIT(7)
16208045defSGarrett D'Amore #define	MIX2_WSMUTE		BIT(6)
163af145792SGarrett D'Amore #define	MIX2_SPK4		BIT(5)	/* line-in is rear out */
164af145792SGarrett D'Amore #define	MIX2_REAR2FRONT		BIT(4)	/* swap front and rear */
16508045defSGarrett D'Amore #define	MIX2_WAVEIN_L		BIT(3)	/* for recording wave out */
16608045defSGarrett D'Amore #define	MIX2_WAVEIN_R		BIT(2)	/* for recording wave out */
167af145792SGarrett D'Amore #define	MIX2_X3DEN		BIT(1)	/* 3D surround enable */
168af145792SGarrett D'Amore #define	MIX2_CDPLAY		BIT(0)	/* spdif-in PCM to DAC */
16908045defSGarrett D'Amore 
17008045defSGarrett D'Amore #define	MIX3_RAUXREN		BIT(7)
17108045defSGarrett D'Amore #define	MIX3_RAUXLEN		BIT(6)
17208045defSGarrett D'Amore #define	MIX3_VAUXRM		BIT(5)	/* r-aux mute */
17308045defSGarrett D'Amore #define	MIX3_VAUXLM		BIT(4)	/* l-aux mute */
17408045defSGarrett D'Amore #define	MIX3_VADCMIC_MASK	(0x7 << 1)	/* rec mic volume */
175af145792SGarrett D'Amore #define	MIX3_CEN2MIC		BIT(2)
17608045defSGarrett D'Amore #define	MIX3_MICGAINZ		BIT(0)	/* mic gain */
17708045defSGarrett D'Amore 
17808045defSGarrett D'Amore #define	VAUX_L_MASK		0xf0
17908045defSGarrett D'Amore #define	VAUX_R_MASK		0x0f
18008045defSGarrett D'Amore 
181af145792SGarrett D'Amore #define	MISC2_CHB3D8C		BIT(5)	/* 8 channel surround */
182af145792SGarrett D'Amore #define	MISC2_SPD32FMT		BIT(4)	/* spdif at 32 kHz */
183af145792SGarrett D'Amore #define	MISC2_ADC2SPDIF		BIT(3)	/* send adc to spdif out */
184af145792SGarrett D'Amore #define	MISC2_SHAREADC		BIT(2)	/* use adc for cen/lfe */
185af145792SGarrett D'Amore 
18608045defSGarrett D'Amore /* Indexes via SBINDEX */
18708045defSGarrett D'Amore #define	IDX_MASTER_LEFT		0x30
18808045defSGarrett D'Amore #define	IDX_MASTER_RIGHT	0x31
18908045defSGarrett D'Amore #define	IDX_VOICE_LEFT		0x32	/* PCM volume */
19008045defSGarrett D'Amore #define	IDX_VOICE_RIGHT		0x33
19108045defSGarrett D'Amore #define	IDX_CDDA_LEFT		0x36
19208045defSGarrett D'Amore #define	IDX_CDDA_RIGHT		0x37
19308045defSGarrett D'Amore #define	IDX_LINEIN_LEFT		0x38
19408045defSGarrett D'Amore #define	IDX_LINEIN_RIGHT	0x39
19508045defSGarrett D'Amore #define	IDX_MIC			0x3A
19608045defSGarrett D'Amore #define	IDX_SPEAKER		0x3B
19708045defSGarrett D'Amore #define	IDX_OUTMIX		0x3C
19808045defSGarrett D'Amore #define		OUTMIX_MIC	0x01
19908045defSGarrett D'Amore #define		OUTMIX_CD_R	0x02
20008045defSGarrett D'Amore #define		OUTMIX_CD_L	0x04
20108045defSGarrett D'Amore #define		OUTMIX_LINE_R	0x08
20208045defSGarrett D'Amore #define		OUTMIX_LINE_L	0x10
20308045defSGarrett D'Amore #define	IDX_INMIX_L		0x3D
20408045defSGarrett D'Amore #define	IDX_INMIX_R		0x3E
20508045defSGarrett D'Amore #define		INMIX_LINE_R	0x08
20608045defSGarrett D'Amore #define		INMIX_LINE_L	0x10
20708045defSGarrett D'Amore #define		INMIX_CD_R	0x20
20808045defSGarrett D'Amore #define		INMIX_CD_L	0x40
20908045defSGarrett D'Amore #define		INMIX_MIC	0x01
21008045defSGarrett D'Amore #define	IDX_IGAIN_L		0x3F
21108045defSGarrett D'Amore #define	IDX_IGAIN_R		0x40
21208045defSGarrett D'Amore #define	IDX_OGAIN_L		0x41
21308045defSGarrett D'Amore #define	IDX_OGAIN_R		0x42
21408045defSGarrett D'Amore #define	IDX_AGC			0x43
21508045defSGarrett D'Amore #define	IDX_TREBLE_L		0x44
21608045defSGarrett D'Amore #define	IDX_TREBLE_R		0x45
21708045defSGarrett D'Amore #define	IDX_BASS_L		0x46
21808045defSGarrett D'Amore #define	IDX_BASS_R		0x47
21908045defSGarrett D'Amore 
22008045defSGarrett D'Amore 
22108045defSGarrett D'Amore #define	IDX_EXTENSION		0xf0
22208045defSGarrett D'Amore 
22308045defSGarrett D'Amore #define	EXTENSION_VPHONE_MASK	(0x7 << 5)
22408045defSGarrett D'Amore #define	EXTENSION_VPHONE_MUTE	BIT(4)
22508045defSGarrett D'Amore #define	EXTENSION_BEEPER_MUTE	BIT(3)
22608045defSGarrett D'Amore #define	EXTENSION_VADCMIC3	BIT(0)
22708045defSGarrett D'Amore 
22808045defSGarrett D'Amore enum {
22908045defSGarrett D'Amore 	SRC_MIC = 0,
23008045defSGarrett D'Amore 	SRC_LINE,
23108045defSGarrett D'Amore 	SRC_CD,
23208045defSGarrett D'Amore 	SRC_AUX,
23308045defSGarrett D'Amore 	SRC_MIX,
23408045defSGarrett D'Amore };
23508045defSGarrett D'Amore 
23608045defSGarrett D'Amore enum {
23708045defSGarrett D'Amore 	CTL_VOLUME = 0,
23808045defSGarrett D'Amore 	CTL_LINEOUT,
23908045defSGarrett D'Amore 	CTL_SPEAKER,
24008045defSGarrett D'Amore 	CTL_MIC,
24108045defSGarrett D'Amore 	CTL_LINEIN,
24208045defSGarrett D'Amore 	CTL_CD,
24308045defSGarrett D'Amore 	CTL_AUX,
24408045defSGarrett D'Amore 	CTL_RECSRCS,
24508045defSGarrett D'Amore 	CTL_MONSRCS,
24608045defSGarrett D'Amore 	CTL_MICBOOST,
24708045defSGarrett D'Amore 	CTL_NUM
24808045defSGarrett D'Amore };
24908045defSGarrett D'Amore 
25008045defSGarrett D'Amore typedef struct cmpci_port cmpci_port_t;
25108045defSGarrett D'Amore typedef struct cmpci_dev cmpci_dev_t;
25208045defSGarrett D'Amore typedef struct cmpci_ctrl cmpci_ctrl_t;
25308045defSGarrett D'Amore 
25408045defSGarrett D'Amore struct cmpci_ctrl {
25508045defSGarrett D'Amore 	cmpci_dev_t		*dev;
25608045defSGarrett D'Amore 	audio_ctrl_t		*ctrl;
25708045defSGarrett D'Amore 	uint64_t		value;
25808045defSGarrett D'Amore };
25908045defSGarrett D'Amore 
26008045defSGarrett D'Amore struct cmpci_port {
26108045defSGarrett D'Amore 	cmpci_dev_t		*dev;
26208045defSGarrett D'Amore 	audio_engine_t		*engine;
26308045defSGarrett D'Amore 	int			num;
26408045defSGarrett D'Amore 	ddi_acc_handle_t	acch;
26508045defSGarrett D'Amore 	ddi_dma_handle_t	dmah;
26608045defSGarrett D'Amore 	caddr_t			kaddr;
26708045defSGarrett D'Amore 	uint32_t		paddr;
26808045defSGarrett D'Amore 	unsigned		nframes;
26908045defSGarrett D'Amore 	unsigned		bufsz;
270af145792SGarrett D'Amore 	unsigned		nchan;
27108045defSGarrett D'Amore 
27208045defSGarrett D'Amore 	boolean_t		capture;
27308045defSGarrett D'Amore 	boolean_t		open;
27408045defSGarrett D'Amore 
27508045defSGarrett D'Amore 	/* registers & bit masks */
27608045defSGarrett D'Amore 	uint8_t			reg_paddr;
27708045defSGarrett D'Amore 	uint8_t			reg_bufsz;
27808045defSGarrett D'Amore 	uint8_t			reg_fragsz;
27908045defSGarrett D'Amore 
28008045defSGarrett D'Amore 	uint32_t		fc0_rst_bit;
28108045defSGarrett D'Amore 	uint32_t		fc0_rec_bit;
28208045defSGarrett D'Amore 	uint32_t		fc0_en_bit;
28308045defSGarrett D'Amore 	uint32_t		int_en_bit;
28408045defSGarrett D'Amore 	uint32_t		fc1_rate_mask;
28508045defSGarrett D'Amore 	uint32_t		chformat_mask;
28608045defSGarrett D'Amore 	int			sync_dir;
28708045defSGarrett D'Amore 
28808045defSGarrett D'Amore 	uint32_t		offset;	/* in bytes */
28908045defSGarrett D'Amore 	uint64_t		count;	/* in bytes */
29008045defSGarrett D'Amore 
29108045defSGarrett D'Amore 	void			(*callb)(audio_engine_t *);
29208045defSGarrett D'Amore 	cmpci_ctrl_t		controls[CTL_NUM];
29308045defSGarrett D'Amore };
29408045defSGarrett D'Amore 
29508045defSGarrett D'Amore #define	PORT_MAX	2
29608045defSGarrett D'Amore 
29708045defSGarrett D'Amore struct cmpci_dev {
29808045defSGarrett D'Amore 	audio_dev_t		*adev;
29908045defSGarrett D'Amore 	dev_info_t		*dip;
30008045defSGarrett D'Amore 	ddi_acc_handle_t	acch;
30108045defSGarrett D'Amore 	caddr_t			regs;
30208045defSGarrett D'Amore 
3032be7def9SGarrett D'Amore 	boolean_t		softvol;
3042be7def9SGarrett D'Amore 
30508045defSGarrett D'Amore 	int			pintrs;
30608045defSGarrett D'Amore 	int			rintrs;
30708045defSGarrett D'Amore 	ddi_intr_handle_t	ihandle;
30808045defSGarrett D'Amore 	kstat_t			*ksp;
30908045defSGarrett D'Amore 
310af145792SGarrett D'Amore 	int			maxch;
31108045defSGarrett D'Amore 
31208045defSGarrett D'Amore 	kmutex_t		mutex;
31308045defSGarrett D'Amore 	cmpci_port_t		port[PORT_MAX];
31408045defSGarrett D'Amore 	cmpci_ctrl_t		controls[CTL_NUM];
31508045defSGarrett D'Amore };
31608045defSGarrett D'Amore 
31708045defSGarrett D'Amore /*
31808045defSGarrett D'Amore  * The hardware appears to be able to address up to 16-bits worth of samples,
31908045defSGarrett D'Amore  * giving a total address space of 256K.  Note, however, that we will restrict
32008045defSGarrett D'Amore  * this further when we do fragment and memory allocation.
32108045defSGarrett D'Amore  */
32208045defSGarrett D'Amore #define	DEFINTS		175
32308045defSGarrett D'Amore 
32408045defSGarrett D'Amore #define	GET8(dev, offset)	\
32508045defSGarrett D'Amore 	ddi_get8(dev->acch, (uint8_t *)(dev->regs + (offset)))
32608045defSGarrett D'Amore #define	GET16(dev, offset)	\
32708045defSGarrett D'Amore 	ddi_get16(dev->acch, (uint16_t *)(void *)(dev->regs + (offset)))
32808045defSGarrett D'Amore #define	GET32(dev, offset)	\
32908045defSGarrett D'Amore 	ddi_get32(dev->acch, (uint32_t *)(void *)(dev->regs + (offset)))
33008045defSGarrett D'Amore #define	PUT8(dev, offset, v)	\
33108045defSGarrett D'Amore 	ddi_put8(dev->acch, (uint8_t *)(dev->regs + (offset)), v)
33208045defSGarrett D'Amore #define	PUT16(dev, offset, v)	\
33308045defSGarrett D'Amore 	ddi_put16(dev->acch, (uint16_t *)(void *)(dev->regs + (offset)), v)
33408045defSGarrett D'Amore #define	PUT32(dev, offset, v)	\
33508045defSGarrett D'Amore 	ddi_put32(dev->acch, (uint32_t *)(void *)(dev->regs + (offset)), v)
33608045defSGarrett D'Amore 
33708045defSGarrett D'Amore #define	CLR8(dev, offset, v)	PUT8(dev, offset, GET8(dev, offset) & ~(v))
33808045defSGarrett D'Amore #define	SET8(dev, offset, v)	PUT8(dev, offset, GET8(dev, offset) | (v))
33908045defSGarrett D'Amore #define	CLR16(dev, offset, v)	PUT16(dev, offset, GET16(dev, offset) & ~(v))
34008045defSGarrett D'Amore #define	SET16(dev, offset, v)	PUT16(dev, offset, GET16(dev, offset) | (v))
34108045defSGarrett D'Amore #define	CLR32(dev, offset, v)	PUT32(dev, offset, GET32(dev, offset) & ~(v))
34208045defSGarrett D'Amore #define	SET32(dev, offset, v)	PUT32(dev, offset, GET32(dev, offset) | (v))
34308045defSGarrett D'Amore 
34408045defSGarrett D'Amore #define	BIT(n)		(1U << (n))
34508045defSGarrett D'Amore 
34608045defSGarrett D'Amore #endif	/* _AUDIOCMI_H */
347