188447a05SGarrett D'Amore /* 288447a05SGarrett D'Amore * CDDL HEADER START 388447a05SGarrett D'Amore * 488447a05SGarrett D'Amore * The contents of this file are subject to the terms of the 588447a05SGarrett D'Amore * Common Development and Distribution License (the "License"). 688447a05SGarrett D'Amore * You may not use this file except in compliance with the License. 788447a05SGarrett D'Amore * 888447a05SGarrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 988447a05SGarrett D'Amore * or http://www.opensolaris.org/os/licensing. 1088447a05SGarrett D'Amore * See the License for the specific language governing permissions 1188447a05SGarrett D'Amore * and limitations under the License. 1288447a05SGarrett D'Amore * 1388447a05SGarrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each 1488447a05SGarrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1588447a05SGarrett D'Amore * If applicable, add the following below this CDDL HEADER, with the 1688447a05SGarrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying 1788447a05SGarrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner] 1888447a05SGarrett D'Amore * 1988447a05SGarrett D'Amore * CDDL HEADER END 2088447a05SGarrett D'Amore */ 2188447a05SGarrett D'Amore 2288447a05SGarrett D'Amore /* 2388447a05SGarrett D'Amore * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2488447a05SGarrett D'Amore * Use is subject to license terms. 2588447a05SGarrett D'Amore */ 2688447a05SGarrett D'Amore 2788447a05SGarrett D'Amore #ifndef _SYS_AC97_IMPL_H 2888447a05SGarrett D'Amore #define _SYS_AC97_IMPL_H 2988447a05SGarrett D'Amore 3088447a05SGarrett D'Amore typedef void (*ac97_set_t)(ac97_ctrl_t *, uint64_t); 3188447a05SGarrett D'Amore 3288447a05SGarrett D'Amore /* 3388447a05SGarrett D'Amore * Per control state 3488447a05SGarrett D'Amore */ 3588447a05SGarrett D'Amore struct ac97_ctrl { 3688447a05SGarrett D'Amore list_node_t actrl_linkage; /* For private cntrls list */ 3788447a05SGarrett D'Amore struct ac97 *actrl_ac97; 3888447a05SGarrett D'Amore int actrl_bits; /* Port width */ 3988447a05SGarrett D'Amore audio_ctrl_t *actrl_ctrl; /* control framework handle */ 4088447a05SGarrett D'Amore ac97_set_t actrl_write_fn; /* control write function */ 4188447a05SGarrett D'Amore uint64_t actrl_value; /* current value in port */ 4288447a05SGarrett D'Amore uint64_t actrl_initval; /* initial value in port */ 43*33ab04abSGarrett D'Amore uint16_t actrl_muteable; /* if muteable, bits for it */ 44*33ab04abSGarrett D'Amore boolean_t actrl_suppress; /* if true, do not register */ 45*33ab04abSGarrett D'Amore audio_ctrl_desc_t actrl_desc; /* ctrl desc structure */ 46*33ab04abSGarrett D'Amore #define actrl_name actrl_desc.acd_name 47*33ab04abSGarrett D'Amore #define actrl_minval actrl_desc.acd_minvalue 48*33ab04abSGarrett D'Amore #define actrl_maxval actrl_desc.acd_maxvalue 49*33ab04abSGarrett D'Amore #define actrl_type actrl_desc.acd_type 50*33ab04abSGarrett D'Amore #define actrl_flags actrl_desc.acd_flags 51*33ab04abSGarrett D'Amore #define actrl_enum actrl_desc.acd_enum 5288447a05SGarrett D'Amore }; 5388447a05SGarrett D'Amore 5488447a05SGarrett D'Amore /* 5588447a05SGarrett D'Amore * Function Type used on controls that are optional 5688447a05SGarrett D'Amore * This will return non-zero if the control should be 5788447a05SGarrett D'Amore * installed and configured. 5888447a05SGarrett D'Amore */ 5988447a05SGarrett D'Amore typedef int (*cp_probe_t)(ac97_t *ac); 6088447a05SGarrett D'Amore 6188447a05SGarrett D'Amore 6288447a05SGarrett D'Amore /* 6388447a05SGarrett D'Amore * This is used to enumerate and probe all controls that are 6488447a05SGarrett D'Amore * supported and configurable on AC97 hardware 6588447a05SGarrett D'Amore */ 6688447a05SGarrett D'Amore typedef struct ac97_ctrl_probe { 6788447a05SGarrett D'Amore const char *cp_name; /* name of control */ 6888447a05SGarrett D'Amore uint64_t cp_initval; /* Initial value for control */ 6988447a05SGarrett D'Amore uint64_t cp_minval; /* MIN value for control */ 7088447a05SGarrett D'Amore uint64_t cp_maxval; /* MAX value for control */ 7188447a05SGarrett D'Amore uint32_t cp_type; /* Type of control */ 7288447a05SGarrett D'Amore uint32_t cp_flags; /* control type flags */ 7388447a05SGarrett D'Amore uint16_t cp_muteable; /* Mute bit mask */ 7488447a05SGarrett D'Amore ac97_set_t cp_write_fn; /* control write function */ 7588447a05SGarrett D'Amore cp_probe_t cp_probe; /* Probe if control exists */ 7688447a05SGarrett D'Amore int cp_bits; /* Bits for volume controls */ 7788447a05SGarrett D'Amore const char **cp_enum; /* Enumeration value */ 7888447a05SGarrett D'Amore } ac97_ctrl_probe_t; 7988447a05SGarrett D'Amore 8088447a05SGarrett D'Amore /* 8188447a05SGarrett D'Amore * These are the flags for most of our controls 8288447a05SGarrett D'Amore */ 8388447a05SGarrett D'Amore #define AC97_RW (AUDIO_CTRL_FLAG_READABLE | AUDIO_CTRL_FLAG_WRITEABLE) 8488447a05SGarrett D'Amore #define AC97_FLAGS (AC97_RW | AUDIO_CTRL_FLAG_POLL) 8588447a05SGarrett D'Amore 86*33ab04abSGarrett D'Amore void ac_wr(ac97_t *, uint8_t, uint16_t); 87*33ab04abSGarrett D'Amore uint16_t ac_rd(ac97_t *, uint8_t); 88*33ab04abSGarrett D'Amore void ac_clr(ac97_t *, uint8_t, uint16_t); 89*33ab04abSGarrett D'Amore void ac_set(ac97_t *, uint8_t, uint16_t); 90*33ab04abSGarrett D'Amore void ac_add_control(ac97_t *, ac97_ctrl_probe_t *); 91*33ab04abSGarrett D'Amore uint16_t ac_val_scale(int left, int right, int bits); 92*33ab04abSGarrett D'Amore uint16_t ac_mono_scale(int val, int bits); 93*33ab04abSGarrett D'Amore audio_dev_t *ac_get_dev(ac97_t *); 94*33ab04abSGarrett D'Amore int ac_get_prop(ac97_t *, char *, int); 9588447a05SGarrett D'Amore 9688447a05SGarrett D'Amore /* Codec specific initializations */ 9788447a05SGarrett D'Amore 9888447a05SGarrett D'Amore void ad1981a_init(ac97_t *); 9988447a05SGarrett D'Amore void ad1981b_init(ac97_t *); 10088447a05SGarrett D'Amore 10188447a05SGarrett D'Amore void alc650_init(ac97_t *); 10288447a05SGarrett D'Amore void alc850_init(ac97_t *); 10388447a05SGarrett D'Amore 10488447a05SGarrett D'Amore void cmi9738_init(ac97_t *); 10588447a05SGarrett D'Amore void cmi9739_init(ac97_t *); 10688447a05SGarrett D'Amore void cmi9761_init(ac97_t *); 10788447a05SGarrett D'Amore 10888447a05SGarrett D'Amore #endif /* _SYS_AC97_IMPL_H */ 109