data[0] = 1;
if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
- PITCH_CONTROL << 8, ep, data, 1, HZ)) < 0) {
+ PITCH_CONTROL << 8, ep, data, 1, 1000)) < 0) {
snd_printk(KERN_ERR "%d:%d:%d: cannot set enable PITCH\n",
dev->devnum, iface, ep);
return err;
data[2] = rate >> 16;
if ((err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), SET_CUR,
USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_OUT,
- SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) {
+ SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
snd_printk(KERN_ERR "%d:%d:%d: cannot set freq %d to ep 0x%x\n",
dev->devnum, iface, fmt->altsetting, rate, ep);
return err;
}
if ((err = snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), GET_CUR,
USB_TYPE_CLASS|USB_RECIP_ENDPOINT|USB_DIR_IN,
- SAMPLING_FREQ_CONTROL << 8, ep, data, 3, HZ)) < 0) {
+ SAMPLING_FREQ_CONTROL << 8, ep, data, 3, 1000)) < 0) {
snd_printk(KERN_WARNING "%d:%d:%d: cannot get freq at ep 0x%x\n",
dev->devnum, iface, fmt->altsetting, ep);
return 0; /* some devices don't support reading */
return changed;
}
+#define MAX_MASK 64
+
/*
* check whether the registered audio formats need special hw-constraints
*/
static int check_hw_params_convention(snd_usb_substream_t *subs)
{
int i;
- u32 channels[64];
- u32 rates[64];
+ u32 *channels;
+ u32 *rates;
u32 cmaster, rmaster;
u32 rate_min = 0, rate_max = 0;
struct list_head *p;
+ int err = 1;
- memset(channels, 0, sizeof(channels));
- memset(rates, 0, sizeof(rates));
+ channels = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
+ rates = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL);
list_for_each(p, &subs->fmt_list) {
struct audioformat *f;
f = list_entry(p, struct audioformat, list);
/* unconventional channels? */
if (f->channels > 32)
- return 1;
+ goto __out;
/* continuous rate min/max matches? */
if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) {
if (rate_min && f->rate_min != rate_min)
- return 1;
+ goto __out;
if (rate_max && f->rate_max != rate_max)
- return 1;
+ goto __out;
rate_min = f->rate_min;
rate_max = f->rate_max;
}
/* combination of continuous rates and fixed rates? */
if (rates[f->format] & SNDRV_PCM_RATE_CONTINUOUS) {
if (f->rates != rates[f->format])
- return 1;
+ goto __out;
}
if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) {
if (rates[f->format] && rates[f->format] != f->rates)
- return 1;
+ goto __out;
}
channels[f->format] |= (1 << f->channels);
rates[f->format] |= f->rates;
}
/* check whether channels and rates match for all formats */
cmaster = rmaster = 0;
- for (i = 0; i < 64; i++) {
+ for (i = 0; i < MAX_MASK; i++) {
if (cmaster != channels[i] && cmaster && channels[i])
- return 1;
+ goto __out;
if (rmaster != rates[i] && rmaster && rates[i])
- return 1;
+ goto __out;
if (channels[i])
cmaster = channels[i];
if (rates[i])
rmaster = rates[i];
}
/* check whether channels match for all distinct rates */
- memset(channels, 0, sizeof(channels));
+ memset(channels, 0, MAX_MASK * sizeof(u32));
list_for_each(p, &subs->fmt_list) {
struct audioformat *f;
f = list_entry(p, struct audioformat, list);
cmaster = 0;
for (i = 0; i < 32; i++) {
if (cmaster != channels[i] && cmaster && channels[i])
- return 1;
+ goto __out;
if (channels[i])
cmaster = channels[i];
}
- return 0;
+ err = 0;
+
+ __out:
+ kfree(channels);
+ kfree(rates);
+ return err;
}
return; /* not initialized */
list_for_each_safe(p, n, &subs->fmt_list) {
struct audioformat *fp = list_entry(p, struct audioformat, list);
- if (fp->rate_table)
- kfree(fp->rate_table);
+ kfree(fp->rate_table);
kfree(fp);
}
}
static int is_big_endian_format(struct usb_device *dev, struct audioformat *fp)
{
/* M-Audio */
- if (dev->descriptor.idVendor == 0x0763) {
+ if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763) {
/* Quattro: captured data only */
- if (dev->descriptor.idProduct == 0x2001 &&
+ if (le16_to_cpu(dev->descriptor.idProduct) == 0x2001 &&
fp->endpoint & USB_DIR_IN)
return 1;
/* Audiophile USB */
- if (dev->descriptor.idProduct == 0x2003)
+ if (le16_to_cpu(dev->descriptor.idProduct) == 0x2003)
return 1;
}
return 0;
break;
case USB_AUDIO_FORMAT_PCM8:
/* Dallas DS4201 workaround */
- if (dev->descriptor.idVendor == 0x04fa && dev->descriptor.idProduct == 0x4201)
+ if (le16_to_cpu(dev->descriptor.idVendor) == 0x04fa &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x4201)
pcm_format = SNDRV_PCM_FORMAT_S8;
else
pcm_format = SNDRV_PCM_FORMAT_U8;
/* extigy apparently supports sample rates other than 48k
* but not in ordinary way. so we enable only 48k atm.
*/
- if (dev->descriptor.idVendor == 0x041e && dev->descriptor.idProduct == 0x3000) {
+ if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x3000) {
if (fmt[3] == USB_FORMAT_TYPE_I &&
stream == SNDRV_PCM_STREAM_PLAYBACK &&
fp->rates != SNDRV_PCM_RATE_48000)
(altsd->bInterfaceSubClass != USB_SUBCLASS_AUDIO_STREAMING &&
altsd->bInterfaceSubClass != USB_SUBCLASS_VENDOR_SPEC) ||
altsd->bNumEndpoints < 1 ||
- get_endpoint(alts, 0)->wMaxPacketSize == 0)
+ le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize) == 0)
continue;
/* must be isochronous */
if ((get_endpoint(alts, 0)->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) !=
fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
/* FIXME: decode wMaxPacketSize of high bandwith endpoints */
- fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize;
+ fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
fp->attributes = csep[3];
/* some quirks for attributes here */
/* workaround for AudioTrak Optoplay */
- if (dev->descriptor.idVendor == 0x0a92 &&
- dev->descriptor.idProduct == 0x0053) {
+ if (le16_to_cpu(dev->descriptor.idVendor) == 0x0a92 &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x0053) {
/* Optoplay sets the sample rate attribute although
* it seems not supporting it in fact.
*/
}
/* workaround for M-Audio Audiophile USB */
- if (dev->descriptor.idVendor == 0x0763 &&
- dev->descriptor.idProduct == 0x2003) {
+ if (le16_to_cpu(dev->descriptor.idVendor) == 0x0763 &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x2003) {
/* doesn't set the sample rate attribute, but supports it */
fp->attributes |= EP_CS_ATTR_SAMPLE_RATE;
}
* plantronics headset and Griffin iMic have set adaptive-in
* although it's really not...
*/
- if ((dev->descriptor.idVendor == 0x047f &&
- dev->descriptor.idProduct == 0x0ca1) ||
+ if ((le16_to_cpu(dev->descriptor.idVendor) == 0x047f &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x0ca1) ||
/* Griffin iMic (note that there is an older model 77d:223) */
- (dev->descriptor.idVendor == 0x077d &&
- dev->descriptor.idProduct == 0x07af)) {
+ (le16_to_cpu(dev->descriptor.idVendor) == 0x077d &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x07af)) {
fp->ep_attr &= ~EP_ATTR_MASK;
if (stream == SNDRV_PCM_STREAM_PLAYBACK)
fp->ep_attr |= EP_ATTR_ADAPTIVE;
/* ok, let's parse further... */
if (parse_audio_format(dev, fp, format, fmt, stream) < 0) {
- if (fp->rate_table)
- kfree(fp->rate_table);
+ kfree(fp->rate_table);
kfree(fp);
continue;
}
snd_printdd(KERN_INFO "%d:%u:%d: add audio endpoint 0x%x\n", dev->devnum, iface_no, i, fp->endpoint);
err = add_audio_endpoint(chip, stream, fp);
if (err < 0) {
- if (fp->rate_table)
- kfree(fp->rate_table);
+ kfree(fp->rate_table);
kfree(fp);
return err;
}
err = add_audio_endpoint(chip, stream, fp);
if (err < 0) {
kfree(fp);
- if (rate_table)
- kfree(rate_table);
+ kfree(rate_table);
return err;
}
if (fp->iface != get_iface_desc(&iface->altsetting[0])->bInterfaceNumber ||
fp->altset_idx >= iface->num_altsetting) {
kfree(fp);
- if (rate_table)
- kfree(rate_table);
+ kfree(rate_table);
return -EINVAL;
}
alts = &iface->altsetting[fp->altset_idx];
.type = QUIRK_MIDI_FIXED_ENDPOINT,
.data = &ua25_ep
};
- if (chip->dev->descriptor.idProduct == 0x002b)
+ if (le16_to_cpu(chip->dev->descriptor.idProduct) == 0x002b)
return snd_usb_create_midi_interface(chip, iface,
&ua700_quirk);
else
fp->iface = altsd->bInterfaceNumber;
fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
- fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize;
+ fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
switch (fp->maxpacksize) {
case 0x120:
fp->iface = altsd->bInterfaceNumber;
fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
- fp->maxpacksize = get_endpoint(alts, 0)->wMaxPacketSize;
+ fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]);
stream = (fp->endpoint & USB_DIR_IN)
struct usb_host_config *config = dev->actconfig;
int err;
- if (get_cfg_desc(config)->wTotalLength == EXTIGY_FIRMWARE_SIZE_OLD ||
- get_cfg_desc(config)->wTotalLength == EXTIGY_FIRMWARE_SIZE_NEW) {
+ if (le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_OLD ||
+ le16_to_cpu(get_cfg_desc(config)->wTotalLength) == EXTIGY_FIRMWARE_SIZE_NEW) {
snd_printdd("sending Extigy boot sequence...\n");
/* Send message to force it to reconnect with full interface. */
err = snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev,0),
- 0x10, 0x43, 0x0001, 0x000a, NULL, 0, HZ);
+ 0x10, 0x43, 0x0001, 0x000a, NULL, 0, 1000);
if (err < 0) snd_printdd("error sending boot message: %d\n", err);
err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
&dev->descriptor, sizeof(dev->descriptor));
if (err < 0) snd_printdd("error usb_get_descriptor: %d\n", err);
err = usb_reset_configuration(dev);
if (err < 0) snd_printdd("error usb_reset_configuration: %d\n", err);
- snd_printdd("extigy_boot: new boot length = %d\n", get_cfg_desc(config)->wTotalLength);
+ snd_printdd("extigy_boot: new boot length = %d\n",
+ le16_to_cpu(get_cfg_desc(config)->wTotalLength));
return -ENODEV; /* quit this anyway */
}
return 0;
case QUIRK_MIDI_FIXED_ENDPOINT:
case QUIRK_MIDI_YAMAHA:
case QUIRK_MIDI_MIDIMAN:
+ case QUIRK_MIDI_NOVATION:
+ case QUIRK_MIDI_MOTU:
+ case QUIRK_MIDI_EMAGIC:
return snd_usb_create_midi_interface(chip, iface, quirk);
case QUIRK_COMPOSITE:
return create_composite_quirk(chip, iface, quirk);
return create_ua700_ua25_quirk(chip, iface);
case QUIRK_AUDIO_EDIROL_UA1000:
return create_ua1000_quirk(chip, iface);
+ case QUIRK_IGNORE_INTERFACE:
+ return 0;
default:
snd_printd(KERN_ERR "invalid quirk type %d\n", quirk->type);
return -ENXIO;
{
snd_usb_audio_t *chip = entry->private_data;
if (! chip->shutdown)
- snd_iprintf(buffer, "%04x:%04x\n", chip->dev->descriptor.idVendor, chip->dev->descriptor.idProduct);
+ snd_iprintf(buffer, "%04x:%04x\n",
+ le16_to_cpu(chip->dev->descriptor.idVendor),
+ le16_to_cpu(chip->dev->descriptor.idProduct));
}
static void snd_usb_audio_create_proc(snd_usb_audio_t *chip)
strcpy(card->driver, "USB-Audio");
sprintf(component, "USB%04x:%04x",
- dev->descriptor.idVendor, dev->descriptor.idProduct);
+ le16_to_cpu(dev->descriptor.idVendor),
+ le16_to_cpu(dev->descriptor.idProduct));
snd_component_add(card, component);
/* retrieve the device string as shortname */
card->shortname, sizeof(card->shortname)) <= 0) {
/* no name available from anywhere, so use ID */
sprintf(card->shortname, "USB Device %#04x:%#04x",
- dev->descriptor.idVendor, dev->descriptor.idProduct);
+ le16_to_cpu(dev->descriptor.idVendor),
+ le16_to_cpu(dev->descriptor.idProduct));
}
}
/* SB Extigy needs special boot-up sequence */
/* if more models come, this will go to the quirk list. */
- if (dev->descriptor.idVendor == 0x041e && dev->descriptor.idProduct == 0x3000) {
+ if (le16_to_cpu(dev->descriptor.idVendor) == 0x041e &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x3000) {
if (snd_usb_extigy_boot_quirk(dev, intf) < 0)
goto __err_val;
config = dev->actconfig;
}
for (i = 0; i < SNDRV_CARDS; i++)
if (enable[i] && ! usb_chip[i] &&
- (vid[i] == -1 || vid[i] == dev->descriptor.idVendor) &&
- (pid[i] == -1 || pid[i] == dev->descriptor.idProduct)) {
+ (vid[i] == -1 || vid[i] == le16_to_cpu(dev->descriptor.idVendor)) &&
+ (pid[i] == -1 || pid[i] == le16_to_cpu(dev->descriptor.idProduct))) {
if (snd_usb_audio_create(dev, i, quirk, &chip) < 0) {
goto __error;
}
}
usb_chip[chip->index] = NULL;
up(®ister_mutex);
- snd_card_free_in_thread(card);
+ snd_card_free(card);
} else {
up(®ister_mutex);
}