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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_USB_AS_H 28 #define _SYS_USB_AS_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #include <sys/usb/usba/usbai_private.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* driver specific macros */ 39 #define USB_AS_HIWATER (AM_MAX_QUEUED_MSGS_SIZE) 40 #define USB_AS_LOWATER (32*1024) 41 42 43 /* this structure is built from the descriptors */ 44 typedef struct usb_as_alt_descr { 45 uchar_t alt_mode; /* USB_AUDIO_PLAY/RECORD */ 46 uchar_t alt_valid; 47 uchar_t alt_format_len; 48 49 uchar_t alt_n_sample_rates; 50 uint_t *alt_sample_rates; 51 uint_t alt_continuous_sr; 52 53 usb_if_descr_t *alt_if; 54 usb_audio_as_if_descr_t *alt_general; 55 usb_audio_type1_format_descr_t *alt_format; 56 usb_ep_descr_t *alt_ep; 57 usb_audio_as_isoc_ep_descr_t *alt_cs_ep; 58 } usb_as_alt_descr_t; 59 60 61 typedef struct usb_as_power { 62 void *aspm_state; /* points back to usb_as_state */ 63 int aspm_pm_busy; /* device busy accounting */ 64 uint8_t aspm_wakeup_enabled; 65 66 /* this is the bit mask of the power states that device has */ 67 uint8_t aspm_pwr_states; 68 69 /* wakeup and power transistion capabilites of an interface */ 70 uint8_t aspm_capabilities; 71 72 /* current power level the device is in */ 73 uint8_t aspm_current_power; 74 } usb_as_power_t; 75 76 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_power_t::aspm_state)) 77 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_power_t::aspm_wakeup_enabled)) 78 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_power_t::aspm_pwr_states)) 79 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_power_t::aspm_capabilities)) 80 _NOTE(SCHEME_PROTECTS_DATA("unshared", usb_ctrl_req)) 81 82 83 /* usb_as soft state */ 84 typedef struct usb_as_state { 85 dev_info_t *usb_as_dip; 86 uint_t usb_as_instance; 87 usb_log_handle_t usb_as_log_handle; 88 uint_t usb_as_dev_state; 89 uint_t usb_as_ifno; 90 kmutex_t usb_as_mutex; 91 queue_t *usb_as_rq; /* read q ptr */ 92 queue_t *usb_as_wq; /* write q ptr */ 93 uint_t usb_as_streams_flag; /* streams status */ 94 95 /* mblk containing the current control command */ 96 mblk_t *usb_as_def_mblk; 97 98 /* serialization */ 99 usb_serialization_t usb_as_ser_acc; 100 101 /* registration data */ 102 usb_client_dev_data_t *usb_as_dev_data; 103 104 /* info from descriptors per alternate */ 105 uint_t usb_as_n_alternates; 106 usb_as_alt_descr_t *usb_as_alts; 107 uint_t usb_as_alternate; 108 109 /* pipe handle */ 110 usb_pipe_handle_t usb_as_default_ph; 111 112 /* See below for flags */ 113 uchar_t usb_as_xfer_cr; 114 115 /* Isoc pipe stuff */ 116 usb_pipe_handle_t usb_as_isoc_ph; 117 usb_pipe_policy_t usb_as_isoc_pp; 118 audiohdl_t usb_as_ahdl; 119 120 uint_t usb_as_request_count; 121 uint_t usb_as_request_samples; 122 usb_audio_formats_t usb_as_curr_format; 123 124 uint_t usb_as_pkt_count; 125 ushort_t usb_as_record_pkt_size; 126 127 uchar_t usb_as_audio_state; 128 uchar_t usb_as_setup_cnt; 129 130 usb_as_power_t *usb_as_pm; /* power capabilities */ 131 132 /* registration data */ 133 usb_as_registration_t usb_as_reg; 134 135 /* debug support */ 136 uint_t usb_as_send_debug_count; 137 uint_t usb_as_rcv_debug_count; 138 } usb_as_state_t; 139 140 /* warlock directives, stable data */ 141 _NOTE(MUTEX_PROTECTS_DATA(usb_as_state_t::usb_as_mutex, usb_as_state_t)) 142 _NOTE(MUTEX_PROTECTS_DATA(usb_as_state_t::usb_as_mutex, usb_as_power_t)) 143 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_dip)) 144 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_pm)) 145 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_instance)) 146 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_rq)) 147 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_wq)) 148 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_default_ph)) 149 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_isoc_ph)) 150 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_log_handle)) 151 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_dev_data)) 152 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_as_state_t::usb_as_ser_acc)) 153 154 typedef struct usb_as_tq_arg { 155 usb_as_state_t *usb_as_tq_arg_statep; 156 int usb_as_tq_arg_cr; 157 } usb_as_tq_arg_t; 158 159 _NOTE(SCHEME_PROTECTS_DATA("unique per call", usb_as_tq_arg_t)) 160 161 162 /* Default pipe states */ 163 #define USB_AS_DEF_AVAILABLE 0 164 #define USB_AS_DEF_INUSE 1 165 #define USB_AS_DEF_UNAVAILABLE 2 166 167 168 /* 169 * If a command has been initiated, the close callback should know 170 * how it finished. If there has been an error and ex cb initiaited 171 * the async pipe close, an M_ERROR should be sent up. If no error and 172 * default xfer cb had initiated close, M_CTL should be sent up. In 173 * some other cases, close callback may not send anything up. 174 */ 175 #define USB_AS_SEND_MERR 1 176 #define USB_AS_SEND_MCTL 2 177 #define USB_AS_SEND_NONE 3 178 179 180 /* 181 * States of playing/recording flag 182 */ 183 #define USB_AS_IDLE 0 184 #define USB_AS_ACTIVE 1 185 #define USB_AS_PLAY_PAUSED 2 186 #define USB_AS_STOP_POLLING_STARTED 3 187 188 /* 189 * Define constants needed for isoc transfer 190 */ 191 #define USB_AS_N_FRAMES 8 192 #define USB_AS_MAX_REQUEST_COUNT 3 193 194 /* 195 * usb_as turns the M_CTL request into a request control request on the 196 * default pipe. usb_as needs the following information in the usb_as_req_t 197 * structure. See the details below for specific values for each command. 198 */ 199 typedef struct usb_as_req { 200 uint16_t usb_as_req_wValue; /* wValue field of request */ 201 uint16_t usb_as_req_wIndex; /* wIndex field of request */ 202 uint16_t usb_as_req_wLength; /* wLength of request */ 203 mblk_t *usb_as_req_data; /* data for send case */ 204 } usb_as_req_t; 205 206 207 /* Streams status */ 208 #define USB_AS_STREAMS_OPEN 1 209 #define USB_AS_STREAMS_DISMANTLING 2 210 211 #define USB_AS_BUFFER_SIZE 256 /* descriptor buffer size */ 212 213 /* minor node */ 214 #define USB_AS_CONSTRUCT_MINOR(inst) (inst) 215 #define USB_AS_MINOR_TO_INSTANCE(inst) (inst) 216 217 #ifdef __cplusplus 218 } 219 #endif 220 221 #endif /* _SYS_USB_AS_H */ 222