audiovia97.h revision 11936:54dc8a89ba0d
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27/*
28 * Purpose: Definitions for the VIA VT82C686A AC97 driver
29 */
30/*
31 * Copyright (C) 4Front Technologies 1996-2009.
32 */
33#ifndef	AUDIOVIA97_H
34#define	AUDIOVIA97_H
35
36#define	VIA97_NAME		"audiovia97"
37
38#define	VIA97_NUM_PORTC		2
39#define	VIA97_PLAY_SGD_NUM	0
40#define	VIA97_REC_SGD_NUM	1
41
42#define	VIA_VENDOR_ID		0x1106
43#define	VIA_82C686		0x3058
44
45#define	CODEC_TIMEOUT_COUNT	500
46#define	AC97CODEC	0x80	/* Access AC97 Codec */
47#define	IN_CMD		0x01000000	/* busy in sending */
48#define	STA_VALID	0x02000000	/* 1:status data is valid */
49#define	CODEC_RD	0x00800000	/* Read CODEC status */
50#define	CODEC_INDEX	0x007F0000	/* Index of command register */
51#define	CODEC_DATA	0x0000FFFF	/* AC97 status register data */
52
53typedef struct _via97_devc_t via97_devc_t;
54typedef struct _via97_portc_t via97_portc_t;
55
56struct _via97_portc_t
57{
58	via97_devc_t *devc;
59	audio_engine_t *engine;
60
61	int			started;
62	unsigned		nframes;
63	unsigned		pos;
64	caddr_t			base;
65
66	ddi_dma_handle_t	sgd_dmah;	/* dma for descriptors */
67	ddi_acc_handle_t	sgd_acch;
68	uint32_t		sgd_paddr;
69	caddr_t			sgd_kaddr;
70
71	ddi_dma_handle_t	buf_dmah;	/* dma for buffers */
72	ddi_acc_handle_t	buf_acch;
73	uint32_t		buf_paddr;
74	caddr_t			buf_kaddr;
75	size_t			buf_size;
76	int			syncdir;
77	uint64_t		count;
78};
79
80struct _via97_devc_t
81{
82	dev_info_t		*dip;
83	audio_dev_t		*adev;
84	ac97_t			*ac97;
85
86	ddi_acc_handle_t	pcih;
87	ddi_acc_handle_t	regsh;
88	caddr_t			base;
89
90	via97_portc_t *portc[VIA97_NUM_PORTC];
91};
92
93#define	INL(devc, reg)		ddi_get32(devc->regsh, (void *)(reg))
94
95#define	INB(devc, reg)		ddi_get8(devc->regsh, (void *)(reg))
96
97#define	OUTL(devc, reg, val)	ddi_put32(devc->regsh, (void *)(reg), (val))
98
99#define	OUTB(devc, reg, val)	ddi_put8(devc->regsh, (void *)(reg), (val))
100#define	VIA97_KIOP(X)	((kstat_intr_t *)(X->ksp->ks_data))
101
102#endif /* AUDIOVIA97_H */
103