xref: /illumos-gate/usr/src/uts/common/io/audio/ac97/ac97_impl.h (revision 726fad2a65f16c200a03969c29cb5c86c2d427db)
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 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_AC97_IMPL_H
28 #define	_SYS_AC97_IMPL_H
29 
30 typedef void (*ac97_set_t)(ac97_ctrl_t *, uint64_t);
31 
32 /*
33  * Per control state
34  */
35 struct ac97_ctrl {
36 	list_node_t		actrl_linkage;  /* For private cntrls list */
37 	struct ac97		*actrl_ac97;
38 	int			actrl_bits;	/* Port width */
39 	audio_ctrl_t		*actrl_ctrl;    /* control framework handle */
40 	ac97_set_t		actrl_write_fn; /* control write function */
41 	uint64_t		actrl_value;    /* current value in port */
42 	uint64_t		actrl_initval;  /* initial value in port */
43 	uint16_t		actrl_muteable; /* if muteable, bits for it */
44 	boolean_t		actrl_suppress;	/* if true, do not register */
45 	audio_ctrl_desc_t	actrl_desc;	/* ctrl desc structure */
46 #define	actrl_name		actrl_desc.acd_name
47 #define	actrl_minval		actrl_desc.acd_minvalue
48 #define	actrl_maxval		actrl_desc.acd_maxvalue
49 #define	actrl_type		actrl_desc.acd_type
50 #define	actrl_flags		actrl_desc.acd_flags
51 #define	actrl_enum		actrl_desc.acd_enum
52 };
53 
54 /*
55  * Function Type used on controls that are optional
56  * This will return non-zero if the control should be
57  * installed and configured.
58  */
59 typedef int (*cp_probe_t)(ac97_t *ac);
60 
61 
62 /*
63  * This is used to enumerate and probe all controls that are
64  * supported and configurable on AC97 hardware
65  */
66 typedef struct ac97_ctrl_probe {
67 	const char	*cp_name;	/* name of control */
68 	uint64_t	cp_initval;	/* Initial value for control */
69 	uint64_t	cp_minval;	/* MIN value for control */
70 	uint64_t	cp_maxval;	/* MAX value for control */
71 	uint32_t	cp_type;	/* Type of control */
72 	uint32_t	cp_flags;	/* control type flags */
73 	uint16_t	cp_muteable;	/* Mute bit mask */
74 	ac97_set_t	cp_write_fn;	/* control write function */
75 	cp_probe_t	cp_probe;	/* Probe if control exists */
76 	int		cp_bits;	/* Bits for volume controls */
77 	const char	**cp_enum;	/* Enumeration value */
78 } ac97_ctrl_probe_t;
79 
80 /*
81  * These are the flags for most of our controls
82  */
83 #define	AC97_RW		(AUDIO_CTRL_FLAG_READABLE | AUDIO_CTRL_FLAG_WRITEABLE)
84 #define	AC97_FLAGS	(AC97_RW | AUDIO_CTRL_FLAG_POLL)
85 
86 void ac_wr(ac97_t *, uint8_t, uint16_t);
87 uint16_t ac_rd(ac97_t *, uint8_t);
88 void ac_clr(ac97_t *, uint8_t, uint16_t);
89 void ac_set(ac97_t *, uint8_t, uint16_t);
90 void ac_add_control(ac97_t *, ac97_ctrl_probe_t *);
91 uint16_t ac_val_scale(int left, int right, int bits);
92 uint16_t ac_mono_scale(int val, int bits);
93 audio_dev_t *ac_get_dev(ac97_t *);
94 int ac_get_prop(ac97_t *, char *, int);
95 
96 /* Codec specific initializations */
97 
98 void ad1981a_init(ac97_t *);
99 void ad1981b_init(ac97_t *);
100 
101 void alc650_init(ac97_t *);
102 void alc850_init(ac97_t *);
103 
104 void cmi9738_init(ac97_t *);
105 void cmi9739_init(ac97_t *);
106 void cmi9761_init(ac97_t *);
107 
108 #endif	/* _SYS_AC97_IMPL_H */
109