/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Audio Streams Interface Driver:
*
* usb_as is responsible for (1) Processing audio data messages during
* play and record and management of isoc pipe, (2) Selecting correct
* alternate that matches a set of parameters and management of control pipe.
* This driver is opened by usb_ac and interacts with usb_ac synchronously
* using ioctls. If the processing involves an async USBA command, the ioctl
* returns after completion of the command.
*
* directly for data (play) or sends data to mixer (record).
*
* Serialization: A competing thread can't be allowed to interfere with
* (1) pipe, (2) streams state.
* So we need some kind of serialization among the asynchronous
* threads that can run in the driver. The serialization is mostly
* etc. Once a routine grabs access, if checks if the resource (pipe or
* stream or dev state) is still accessible. If so, it proceeds with
* its job and until it completes, no other thread requiring the same
* resource can run.
*
* PM Model in usb_as: Raise power during attach and lower power in detach.
* If device is not fully powered, synchronous raise power in wsrv entry points.
*/
/* debug support */
/*
* Module linkage routines for the kernel
*/
static int usb_as_power(dev_info_t *, int, int);
/* support functions */
static int usb_as_handle_descriptors(usb_as_state_t *);
static void usb_as_prepare_registration_data(usb_as_state_t *);
static void usb_as_free_alts(usb_as_state_t *);
static int usb_as_disconnect_event_cb(dev_info_t *);
static int usb_as_reconnect_event_cb(dev_info_t *);
static int usb_as_cpr_suspend(dev_info_t *);
static void usb_as_cpr_resume(dev_info_t *);
static int usb_as_pwrlvl0(usb_as_state_t *);
static int usb_as_pwrlvl1(usb_as_state_t *);
static int usb_as_pwrlvl2(usb_as_state_t *);
static int usb_as_pwrlvl3(usb_as_state_t *);
static void usb_as_pm_busy_component(usb_as_state_t *);
static void usb_as_pm_idle_component(usb_as_state_t *);
static int usb_as_setup(usb_as_state_t *);
static void usb_as_teardown(usb_as_state_t *);
static void usb_as_continue_play(usb_as_state_t *);
static void usb_as_pause_play(usb_as_state_t *);
static int usb_as_set_sample_freq(usb_as_state_t *, int);
static int usb_as_start_record(usb_as_state_t *, void *);
static int usb_as_stop_record(usb_as_state_t *);
static void usb_as_handle_shutdown(usb_as_state_t *);
static int usb_as_play_isoc_data(usb_as_state_t *,
/* anchor for soft state structures */
static void *usb_as_statep;
/*
* DDI Structures
*/
/* Entry points structure */
usb_as_open, /* cb_open */
usb_as_close, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
nodev, /* cb_read */
nodev, /* cb_write */
usb_as_ioctl, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
NULL, /* cb_str */
CB_REV, /* cb_rev */
nodev, /* cb_aread */
nodev, /* cb_arwite */
};
/* Device operations structure */
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
usb_as_getinfo, /* devo_getinfo */
nulldev, /* devo_identify - obsolete */
nulldev, /* devo_probe - not needed */
usb_as_attach, /* devo_attach */
usb_as_detach, /* devo_detach */
nodev, /* devo_reset */
&usb_as_cb_ops, /* devi_cb_ops */
NULL, /* devo_busb_as_ops */
usb_as_power, /* devo_power */
ddi_quiesce_not_needed, /* devo_quiesce */
};
/* Linkage structure for loadable drivers */
&mod_driverops, /* drv_modops */
"USB Audio Streaming Driver", /* drv_linkinfo */
&usb_as_dev_ops /* drv_dev_ops */
};
/* Module linkage structure */
MODREV_1, /* ml_rev */
(void *)&usb_as_modldrv, /* ml_linkage */
NULL /* NULL terminates the list */
};
};
/*
* Mixer registration Management
* use defaults as much as possible
*/
int
_init(void)
{
int rval;
/* initialize the soft state */
return (rval);
}
}
return (rval);
}
int
_fini(void)
{
int rval;
/* Free the soft state internal structures */
}
return (rval);
}
int
{
}
/*ARGSUSED*/
static int
{
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
error = DDI_SUCCESS;
}
} else {
}
break;
case DDI_INFO_DEVT2INSTANCE:
error = DDI_SUCCESS;
break;
default:
break;
}
return (error);
}
static int
{
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/*
* Allocate soft state information.
*/
return (DDI_FAILURE);
}
/*
* get soft state space and initialize
*/
return (DDI_FAILURE);
}
&usb_as_errmask, &usb_as_instance_debug, 0);
"usb_client_attach failed");
return (DDI_FAILURE);
}
USB_PARSE_LVL_IF, 0) != USB_SUCCESS) {
"usb_get_dev_data failed");
return (DDI_FAILURE);
}
/* initialize mutex */
/* parse all descriptors */
goto fail;
}
NULL, 0)) != DDI_SUCCESS) {
"usb_as_attach: couldn't create minor node");
goto fail;
}
/* we are online */
/* create components to power manage this device */
/* Register for events */
"usb_as_attach: couldn't register for events");
goto fail;
}
/* report device */
"usb_as_attach: End");
return (DDI_SUCCESS);
fail:
if (uasp) {
"attach failed");
}
return (DDI_FAILURE);
}
/*ARGSUSED*/
static int
{
int rval;
switch (cmd) {
case DDI_DETACH:
return (DDI_SUCCESS);
case DDI_SUSPEND:
default:
return (DDI_FAILURE);
}
}
static void
{
return;
}
"usb_as_cleanup: uaspm=0x%p", (void *)uaspm);
if (uasp->usb_as_isoc_ph) {
}
/*
* Disable the event callbacks first, after this point, event
* callbacks will never get called. Note we shouldn't hold
* mutex while unregistering events because there may be a
* competing event callback thread. Event callbacks are done
* with ndi mutex held and this can cause a potential deadlock.
*/
if (uaspm->aspm_wakeup_enabled) {
/*
* We need to raise power first because
* we need to send down a command to disable
* remote wakeup
*/
"disable remote wake up failed");
}
} else {
}
}
if (uaspm) {
}
}
/*
* usb_as_open:
* Open entry point for plumbing only
*/
/*ARGSUSED*/
static int
{
return (ENXIO);
}
/* Do mux plumbing stuff */
"usb_as_open: start");
"usb_as_open:multiple opens or opens from userspace"
" not supported");
return (ENXIO);
}
/* fail open on a disconnected device */
"usb_as_open: disconnected");
return (ENODEV);
}
/* Initialize state */
/*
* go to full power, and remain pm_busy till close
*/
"usb_as_open:done");
return (0);
}
/*
* usb_as_close:
* Close entry point for plumbing
*/
/*ARGSUSED*/
static int
{
"usb_as_close: inst=%d", inst);
/*
* Avoid races with other routines.
* For example, if a control transfer is going on, wait
* for that to be completed
* At this point default pipe cannot be open.
*/
/* we can now power down */
uasp->usb_as_flag = 0;
return (0);
}
/*
*
*/
/*ARGSUSED*/
static int
int *rvalp)
{
"usb_as_ioctl: Begin inst=%d, cmd=0x%x, arg=0x%p",
"usb_as_ioctl: inst=%d, user space not supported", inst);
return (ENXIO);
}
switch (cmd) {
"usb_as_ioctl(mixer reg): inst=%d", inst);
/*
* Copy the usb_as_reg structure to the structure
* that usb_ac passed. Note that this is a structure
* assignment and not a pointer assignment!
*/
break;
case USB_AUDIO_SET_FORMAT:
break;
break;
case USB_AUDIO_SETUP:
break;
case USB_AUDIO_TEARDOWN:
break;
case USB_AUDIO_START_PLAY:
break;
case USB_AUDIO_STOP_PLAY:
case USB_AUDIO_PAUSE_PLAY:
break;
case USB_AUDIO_START_RECORD:
break;
case USB_AUDIO_STOP_RECORD:
break;
default:
"usb_as_ioctl: unknown IOCTL, cmd=%d", cmd);
break;
}
}
/*
* usb_as_set_sample_freq:
* Sets the sample freq by sending a control command to interface
* Although not required for continuous sample rate devices, some
* devices such as plantronics devices do need this.
* On the other hand, the TI chip which does not support continuous
* sample rate stalls on this request
* Therefore, we ignore errors and carry on regardless
*/
static int
{
"usb_as_set_sample_freq: inst=%d cont_sr=%d freq=%d",
if (data) {
USB_DEV_REQ_RCPT_EP, /* bmRequestType */
USB_AUDIO_SET_CUR, /* bRequest */
ep, /* wIndex */
3, /* wLength */
data,
ignore_errors)) != USB_SUCCESS) {
"usb_as_set_sample_freq: set sample freq failed");
}
}
return (rval);
}
/*
* usb_as_set_format:
* Matches channel, encoding and precision and find out
* the right alternate. Sets alternate interface and returns it.
*/
static int
{
int n;
if (uasp->usb_as_request_count) {
"usb_as_set_format: failing inst=%d, rq_cnt=%d",
return (USB_FAILURE);
}
"usb_as_set_format: inst=%d, reg=0x%p, format=0x%p",
for (n = 0; n < reg->reg_n_formats; n++) {
int i;
/* match sample rate */
for (i = 0; i < n_srs; i++) {
break;
}
}
if (i == n_srs) {
continue;
}
/*
* Found the alternate
*/
break;
}
}
if (n >= reg->reg_n_formats) {
"usb_as_set_format: Didn't find a matching alt");
return (USB_FAILURE);
}
"usb_as_set_format: interface=%d alternate=%d",
/* bmRequestType */
USB_REQ_SET_IF, /* bRequest */
alt, /* wValue */
interface, /* wIndex */
0, /* wLength */
if (rval != USB_SUCCESS) {
"usb_as_set_format: set_alternate failed");
} else {
}
return (rval);
}
/*
* usb_as_setup:
* Open isoc pipe. Will hang around till bandwidth
* is available.
*/
static int
{
int rval;
"usb_as_setup: Begin usb_as_setup, inst=%d",
/* Set record packet size to max packet size */
} else {
uasp->usb_as_record_pkt_size = 0;
}
while (uasp->usb_as_request_count) {
&uasp->usb_as_mutex);
}
/* close the isoc pipe which is opened before */
}
/* open isoc pipe, may fail if there is no bandwidth */
if (rval != USB_SUCCESS) {
switch (rval) {
case USB_NO_BANDWIDTH:
"no bandwidth available");
break;
case USB_NOT_SUPPORTED:
"high speed port is not supported");
break;
default:
"usb_as_setup: isoc pipe open failed (%d)",
rval);
}
return (USB_FAILURE);
}
uasp->usb_as_setup_cnt++;
"usb_as_setup: End");
return (USB_SUCCESS);
}
/*
* usb_as_teardown
*
*/
static void
{
"usb_as_teardown: Begin inst=%d",
/* reset setup flag */
uasp->usb_as_setup_cnt--;
"usb_as_teardown: End");
}
/*
* usb_as_start_play
*/
static int
{
int n_requests;
"usb_as_start_play: Begin inst=%d, req_cnt=%d",
"nothing to do or paused or idle (%d)",
rval = USB_SUCCESS;
} else {
"usb_as_start_play: samples=%d requestcount=%d ",
/* queue up as many requests as allowed */
USB_SUCCESS) {
break;
}
}
}
"usb_as_start_play: End");
return (rval);
}
/*
* usb_as_continue_play:
* this function is called from the play callbacks
*/
static void
{
int n_requests;
"usb_as_contine_play: Begin req_cnt=%d",
return;
}
"usb_as_continue_play: nothing to do (audio_state=%d)",
} else {
"usb_as_continue_play: samples=%d requestcount=%d ",
/* queue up as many requests as allowed */
USB_SUCCESS) {
break;
}
}
}
"usb_as_continue_play: End");
}
static void
{
void *ahdl;
"usb_as_handle_shutdown, inst=%d",
"usb_as_handle_shutdown: am_play_shutdown");
uasp->usb_as_pkt_count = 0;
}
static int
{
int precision;
/*
* calculate total bufsize by determining the pkt size for
* each frame
*/
}
"usb_as_play_isoc_data: Begin bufsize=0x%lx, inst=%d", bufsize,
"usb_as_play_isoc_data: allocb failed");
goto done;
}
/*
* restriction of Boomer: cannot call usb_ac_get_audio() in the context
* of start so we play a fragment of silence at first
*/
if (uasp->usb_as_request_count == 0) {
/* Don't return failure for 0 bytes of data sent */
if (play_req) {
/*
* Since we set rval to SUCCESS
* we treat it as a special case
* and free data here
*/
rval = USB_SUCCESS;
goto done;
}
} else {
"usb_as_play_isoc_data: no audio bytes, "
}
rval = USB_FAILURE;
goto done;
}
/* calculate how many frames we can actually fill */
}
}
"usb_as_play_isoc_data: n_pkts=%d, bufsize=%ld, n=%d",
/* allocate an isoc request packet */
goto done;
}
/* initialize the packet descriptor */
}
"usb_as_play_isoc_data: rq=0x%p data=0x%p cnt=0x%x "
isoc_req, 0)) != USB_SUCCESS) {
"usb_as_play_isoc_data: rval=%d", rval);
rval = USB_FAILURE;
} else {
}
done:
if (rval != USB_SUCCESS) {
if (isoc_req) {
}
}
"usb_as_play_isoc_data: SEND CNT=%d, RCV COUNT=%d",
return (rval);
}
static void
{
/* this will stop the isoc request in the play callback */
}
/*ARGSUSED*/
static void
{
int i;
"usb_as_play_cb: Begin ph=0x%p, isoc_req=0x%p",
for (i = 0; i < isoc_req->isoc_pkts_count; i++) {
USB_CR_OK) {
"usb_as_play_cb: \tpkt%d: len=%d status=%s", i,
}
}
if (isoc_req->isoc_error_count) {
"usb_as_play_cb: error_count = %d",
}
"usb_as_play_cb: SEND CNT=%d, RCV COUNT=%d",
}
static void
{
int i;
"usb_as_play_exc_cb: ph=0x%p, rq=0x%p data=0x%p pkts=0x%x "
for (i = 0; i < isoc_req->isoc_pkts_count; i++) {
USB_CR_OK) {
"usb_as_play_exc_cb: \tpkt%d: len=%d status=%d",
i,
}
}
"usb_as_play_exc_cb: SEND CNT=%d, RCV COUNT=%d",
"usb_as_play_exc_cb: End request_count=%d",
}
/*
* usb_as_start_record
*/
static int
{
"usb_as_start_record: inst=%d",
/*
* A start_record should not happen when stop polling is
* happening
*/
/* Initialize the packet descriptor */
}
isoc_req, 0);
} else {
"usb_as_start_record: Isoc req allocation failed");
}
} else {
"usb_as_start_record: Record in progress");
rval = USB_SUCCESS;
}
if (rval != USB_SUCCESS) {
if (isoc_req) {
}
}
"usb_as_start_record: rval=%d", rval);
return (rval);
}
static int
{
"usb_as_stop_record: ");
/* if we are disconnected, the pipe will be closed anyways */
return (USB_SUCCESS);
switch (uasp->usb_as_audio_state) {
case USB_AS_ACTIVE:
/*
* Stop polling. When the completion reason indicate that
* polling is over, return response message up.
*/
break;
/* A stop polling in progress, wait for completion and reply */
break;
default:
break;
}
return (USB_SUCCESS);
}
static void
{
int rval;
"usb_as_record_exc_cb: ph=0x%p, isoc_req=0x%p, cr=%d",
switch (completion_reason) {
case USB_CR_STOPPED_POLLING:
case USB_CR_PIPE_CLOSING:
case USB_CR_PIPE_RESET:
break;
case USB_CR_NO_RESOURCES:
/*
* keep the show going: Since we have the original
* request, we just resubmit it
*/
"usb_as_record_exc_cb: restart record rval=%d", rval);
return;
default:
/* Do not start if one is already in progress */
(void) usb_pipe_stop_isoc_polling(ph,
return;
} else {
}
break;
}
"usb_as_record_exc_cb: state=%d cr=0x%x",
}
/*ARGSUSED*/
static void
{
void * ahdl;
int precision;
"usb_as_record_cb: rq=0x%p data=0x%p pkts=0x%x",
"\tpkt%d: "
"offset=%d pktsize=%d len=%d status=%d resid=%d",
USB_CR_OK) {
"record: pkt=%d offset=0x%x status=%s",
}
}
}
}
/*
* Since the int_rate is 1000, we have to do special arithmetic for
* sample rates not multiple of 1K. For example,
* if the sample rate is 48000(i.e multiple of 1K), we can send 48000/1000
* = 48 samples every packet per channel. Since we have to support sample
* rate like 11025, 22050 and 44100, we will have some extra samples
* at the end that we need to spread among the 1000 cycles. So if we make
* the pktsize as below for these sample rates, at the end of 1000 cycles,
* we will be able to send all the data in the correct rate:
*
* 11025: 39 samples of 11, 1 of 12
* 22050: 19 samples of 22, 1 of 23
* 44100: 9 samples of 44, 1 of 45
*
* frameno is a simple counter maintained in the soft state structure.
* So the pkt size is:
* pkt_size = ((frameno % cycle) ? pkt : (pkt + extra));
*
*/
static int
{
static int extra;
int pkt_size = 0;
/* calculate once */
if (extra == 0) {
/* sample rate is a multiple of 1000 */
cycle = 1000;
} else {
/* find a common divisor of 1000 and extra */
int m = 1000;
int n = extra;
while (m != n) {
if (m > n) {
m = m - n;
} else {
n = n - m;
}
}
cycle = (1000 / n);
}
}
"usb_as_get_pktsize: %d", pkt_size);
return (pkt_size);
}
/*
* usb_as_send_ctrl_cmd:
* Opens the pipe; sends a control command down
*/
static int
{
"usb_as_send_ctrl_cmd: Begin bmRequestType=%d,\n\t"
"bRequest=%d, wValue=%d, wIndex=%d, wLength=%d, data=0x%p",
"usb_as_send_ctrl_cmd: usba xfer failed (req=%d), "
"completion reason: 0x%x, completion flags: 0x%x",
}
return (USB_SUCCESS);
}
/*
* Power management
*/
/*ARGSUSED*/
static void
{
"usb_as_create_pm_components: begin");
/* Allocate the state structure */
uaspm->aspm_capabilities = 0;
"usb_as_pm_components: remote Wakeup enabled");
USB_SUCCESS) {
"enable remote wakeup failed");
} else {
}
}
"usb_as_create_pm_components: end");
}
/*
* usb_as_power:
* power entry point
*/
static int
{
"usb_as_power: illegal level=%d pwr_states=%d",
goto done;
}
switch (level) {
case USB_DEV_OS_PWR_OFF:
break;
case USB_DEV_OS_PWR_1:
break;
case USB_DEV_OS_PWR_2:
break;
case USB_DEV_OS_FULL_PWR:
break;
default:
break;
}
done:
}
/*
* functions to handle power transition for various levels
* These functions act as place holders to issue USB commands
* to the devices to change their power levels
* Level 0 = Device is powered off
* Level 3 = Device if full powered
* Level 1,2 = Intermediate power level of the device as implemented
* by the hardware.
* Note that Level 0 is OS power-off and Level 3 is OS full-power.
*/
static int
{
int rval;
switch (uasp->usb_as_dev_state) {
case USB_DEV_ONLINE:
/* Deny the powerdown request if the device is busy */
if (uaspm->aspm_pm_busy != 0) {
return (USB_FAILURE);
}
return (USB_FAILURE);
}
/* Issue USB D3 command to the device here */
/* FALLTHRU */
case USB_DEV_DISCONNECTED:
case USB_DEV_SUSPENDED:
/* allow a disconnected/cpr'ed device to go to low power */
return (USB_SUCCESS);
case USB_DEV_PWRED_DOWN:
default:
"usb_as_pwrlvl0: Illegal dev_state");
return (USB_FAILURE);
}
}
/* ARGSUSED */
static int
{
int rval;
/* Issue USB D2 command to the device here */
return (USB_FAILURE);
}
/* ARGSUSED */
static int
{
int rval;
return (USB_FAILURE);
}
static int
{
int rval;
switch (uasp->usb_as_dev_state) {
case USB_DEV_PWRED_DOWN:
/* Issue USB D0 command to the device here */
/* FALLTHRU */
case USB_DEV_ONLINE:
/* we are already in full power */
/* fall thru */
case USB_DEV_DISCONNECTED:
case USB_DEV_SUSPENDED:
/* allow power change on a disconnected/cpr'ed device */
return (USB_SUCCESS);
default:
"usb_as_pwrlvl3: Illegal dev_state");
return (DDI_FAILURE);
}
}
/*
* Descriptor Management
*
* usb_as_handle_descriptors:
* read and parse all descriptors and build up usb_as_alts list
*
* the order is as follows:
* interface, general, format, endpoint, CV endpoint
*/
static int
{
"usb_as_handle_descriptors: cfg=%ld interface=%d",
/*
* find the number of alternates for this interface
* and allocate an array to store the descriptors for
* each alternate
*/
sizeof (usb_as_alt_descr_t), KM_SLEEP);
/*
* for each alternate read descriptors
*/
"interface (%d.%d):\n\t"
"l = 0x%x type = 0x%x n = 0x%x alt = 0x%x #ep = 0x%x\n\t"
"iclass = 0x%x subclass = 0x%x proto = 0x%x string = 0x%x",
/* read the general descriptor */
index = 0;
continue;
}
/* is this a sane header descriptor */
if (!((len >= AS_IF_DESCR_SIZE) &&
"invalid general cs interface descr");
continue;
}
"general (%d.%d): type=0x%x subtype=0x%x termlink=0x%x\n\t"
"delay=0x%x format=0x%x",
/*
* there should be one format descriptor of unknown size.
* the format descriptor contains just bytes, no need to
* parse
*/
index++;
/* is this a sane format descriptor */
"invalid format cs interface descr");
continue;
}
"format (%d.%d): len = %d "
"type = 0x%x subtype = 0x%x format = 0x%x\n\t"
"#channels = 0x%x subframe = 0x%x resolution = 0x%x\n\t"
"sample freq type = 0x%x",
if (format->bSamFreqType == 0) {
/* continuous sample rate limits */
n_srs = 2;
} else {
}
/* go thru all sample rates (3 bytes) each */
for (i = 0, j = 0, n = 0; n < n_srs; i += 3, n++) {
"sr = %d", sr);
sample_rates[n] = sr;
if (sr != 0) {
j++;
}
}
if (j == 0) {
"format cs interface descr has no valid rates");
continue;
}
"no endpoint descriptor found");
continue;
}
}
"endpoint (%d.%d):\n\t"
"len = 0x%x type = 0x%x add = 0x%x "
"attr = 0x%x mps = 0x%x\n\t"
"int = 0x%x",
"no cv ep descriptor");
continue;
}
if ((len < AS_ISOC_EP_DESCR_SIZE) ||
"cs endpoint descriptor invalid (%d)", len);
continue;
}
"cs isoc endpoint (%d.%d):\n\t"
"type=0x%x sub=0x%x attr=0x%x units=0x%x delay=%x",
cs_ep->wLockDelay);
/* we are done */
}
done:
return (rval);
}
/*
* usb_as_free_alts:
* cleanup alternate list and deallocate all descriptors
*/
static void
{
int alt;
if (uasp->usb_as_alts) {
if (altp) {
if (altp->alt_sample_rates) {
sizeof (uint_t));
}
sizeof (usb_if_descr_t));
}
if (altp->alt_general) {
sizeof (usb_audio_as_if_descr_t));
}
if (altp->alt_format) {
}
sizeof (usb_ep_descr_t));
}
}
}
}
sizeof (usb_as_alt_descr_t));
}
}
/*
* usb_as_prepare_registration_data
*/
static void
{
int alt, n;
"usb_as_prepare_registration_data:");
/* there has to be at least two alternates, ie 0 and 1 */
if (n_alternates < 2) {
"not enough alternates %d", n_alternates);
return;
}
/* all endpoints need to have the same direction */
continue;
}
"alternates have different direction");
return;
}
}
/*
* we assume that alternate 0 is not interesting (no bandwidth),
* we check all formats and use the formats that we can support
*/
continue;
}
(n < USB_AS_N_FORMATS) &&
}
}
if (n == 0) {
/* no valid formats */
"zero valid formats");
return;
}
/* dump what we have so far */
for (n = 0; n < reg->reg_n_formats; n++) {
"regformats[%d]: termlink = %d, alt=%d chns=%d"
" prec=%d enc=%d", n,
}
}
/*
* usb_as_valid_format:
* check if this format can be supported
*/
static int
{
"usb_as_valid_format: %d %d %d %d %d",
"alt=%d", alternate);
switch (format->bNrChannels) {
case 0:
return (USB_FAILURE);
default:
break;
}
switch (format->bSubFrameSize) {
case 1:
case 2:
break;
default:
return (USB_FAILURE);
}
switch (format->bBitResolution) {
case USB_AUDIO_PRECISION_8:
case USB_AUDIO_PRECISION_16:
case USB_AUDIO_PRECISION_24:
case USB_AUDIO_PRECISION_32:
break;
default:
return (USB_FAILURE);
}
switch (format->bFormatType) {
break;
default:
return (USB_FAILURE);
}
return (USB_SUCCESS);
}
/*
* Event Management
*
* usb_as_disconnect_event_cb:
* The device has been disconnected.
*/
static int
{
"usb_as_disconnect_event_cb: dip=0x%p", (void *)dip);
return (USB_SUCCESS);
}
/*
* usb_as_cpr_suspend:
*/
static int
{
"usb_as_cpr_suspend: Begin");
"usb_as_cpr_suspend: End");
return (USB_SUCCESS);
}
/*
* usb_as_reconnect_event_cb:
* The device was disconnected but this instance not detached, probably
* because the device was busy.
* if the same device, continue with restoring state
*/
static int
{
"usb_as_reconnect_event_cb: dip=0x%p", (void *)dip);
return (USB_SUCCESS);
}
/*
* usb_as_cpr_resume:
* recover this device from suspended state
*/
static void
{
"usb_as_cpr_resume: dip=0x%p", (void *)dip);
}
/*
* usb_as_restore_device_state:
* Set original configuration of the device
* enable wrq - this starts new transactions on the control pipe
*/
static void
{
"usb_as_restore_device_state:");
/* Check if we are talking to the same device */
/* change the device state from suspended to disconnected */
return;
}
if (uaspm) {
if (uaspm->aspm_wakeup_enabled) {
"enable remote wake up failed");
}
}
}
}
static void
{
"usb_as_pm_busy_component: %d",
DDI_SUCCESS) {
"usb_as_pm_busy_component failed: %d",
}
}
}
static void
{
DDI_SUCCESS) {
"usb_as_pm_idle_component: %d",
}
}
}