Skip to content
Permalink
Browse files

odroid-c2:Support 'nrpacks' param for snd-usb-audio

Change-Id: I47cbd74ca4685113e8dd06d52643e8120be29f0b
  • Loading branch information...
ckkim
ckkim committed Oct 5, 2016
1 parent 135cacc commit 925e508d37c76848881a8c8f7e9b02abc5731d88
Showing with 125 additions and 172 deletions.
  1. +25 −19 sound/usb/card.c
  2. +4 −9 sound/usb/card.h
  3. +69 −118 sound/usb/endpoint.c
  4. +1 −4 sound/usb/endpoint.h
  5. +25 −22 sound/usb/pcm.c
  6. +1 −0 sound/usb/usbaudio.h
@@ -79,6 +79,7 @@ static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card *
/* Vendor/product IDs for this card */
static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 };
static int nrpacks = 8; /* max. number of packets per urb */
static int device_setup[SNDRV_CARDS]; /* device parameter for this card */
static bool ignore_ctl_error;
static bool autoclock = true;
@@ -93,6 +94,8 @@ module_param_array(vid, int, NULL, 0444);
MODULE_PARM_DESC(vid, "Vendor ID for the USB audio device.");
module_param_array(pid, int, NULL, 0444);
MODULE_PARM_DESC(pid, "Product ID for the USB audio device.");
module_param(nrpacks, int, 0644);
MODULE_PARM_DESC(nrpacks, "Max. number of packets per URB.");
module_param_array(device_setup, int, NULL, 0444);
MODULE_PARM_DESC(device_setup, "Specific device setup (if needed).");
module_param(ignore_ctl_error, bool, 0444);
@@ -304,11 +307,6 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)

static int snd_usb_audio_free(struct snd_usb_audio *chip)
{
struct list_head *p, *n;

list_for_each_safe(p, n, &chip->ep_list)
snd_usb_endpoint_free(p);

mutex_destroy(&chip->mutex);
kfree(chip);
return 0;
@@ -351,7 +349,6 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
case USB_SPEED_LOW:
case USB_SPEED_FULL:
case USB_SPEED_HIGH:
case USB_SPEED_WIRELESS:
case USB_SPEED_SUPER:
break;
default:
@@ -377,6 +374,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
chip->dev = dev;
chip->card = card;
chip->setup = device_setup[idx];
chip->nrpacks = nrpacks;
chip->autoclock = autoclock;
chip->probing = 1;

@@ -585,30 +583,27 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
struct snd_usb_audio *chip)
{
struct snd_card *card;
struct list_head *p;
bool was_shutdown;
struct list_head *p, *n;

if (chip == (void *)-1L)
return;

card = chip->card;
down_write(&chip->shutdown_rwsem);
was_shutdown = chip->shutdown;
chip->shutdown = 1;
up_write(&chip->shutdown_rwsem);

mutex_lock(&register_mutex);
if (!was_shutdown) {
struct snd_usb_endpoint *ep;

chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
snd_card_disconnect(card);
/* release the pcm resources */
list_for_each(p, &chip->pcm_list) {
snd_usb_stream_disconnect(p);
}
/* release the endpoint resources */
list_for_each_entry(ep, &chip->ep_list, list) {
snd_usb_endpoint_release(ep);
list_for_each_safe(p, n, &chip->ep_list) {
snd_usb_endpoint_free(p);
}
/* release the midi resources */
list_for_each(p, &chip->midi_list) {
@@ -618,10 +613,6 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
list_for_each(p, &chip->mixer_list) {
snd_usb_mixer_disconnect(p);
}
}

chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
usb_chip[chip->index] = NULL;
mutex_unlock(&register_mutex);
snd_card_free_when_closed(card);
@@ -763,4 +754,19 @@ static struct usb_driver usb_audio_driver = {
.supports_autosuspend = 1,
};

module_usb_driver(usb_audio_driver);
static int __init snd_usb_audio_init(void)
{
if (nrpacks < 1 || nrpacks > MAX_PACKS) {
pr_warn("invalid nrpacks value.\n");
return -EINVAL;
}
return usb_register(&usb_audio_driver);
}

static void __exit snd_usb_audio_cleanup(void)
{
usb_deregister(&usb_audio_driver);
}

module_init(snd_usb_audio_init);
module_exit(snd_usb_audio_cleanup);
@@ -2,11 +2,11 @@
#define __USBAUDIO_CARD_H

#define MAX_NR_RATES 1024
#define MAX_PACKS 6 /* per URB */
#define MAX_PACKS 20
#define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */
#define MAX_URBS 12
#define MAX_URBS 8
#define SYNC_URBS 4 /* always four urbs for sync */
#define MAX_QUEUE 18 /* try not to exceed this queue length, in ms */
#define MAX_QUEUE 24 /* try not to exceed this queue length, in ms */

struct audioformat {
struct list_head list;
@@ -87,17 +87,15 @@ struct snd_usb_endpoint {
unsigned int phase; /* phase accumulator */
unsigned int maxpacksize; /* max packet size in bytes */
unsigned int maxframesize; /* max packet size in frames */
unsigned int max_urb_frames; /* max URB size in frames */
unsigned int curpacksize; /* current packet size in bytes (for capture) */
unsigned int curframesize; /* current packet size in frames (for capture) */
unsigned int syncmaxsize; /* sync endpoint packet size */
unsigned int fill_max:1; /* fill max packet size always */
unsigned int udh01_fb_quirk:1; /* corrupted feedback data */
unsigned int datainterval; /* log_2 of data packet interval */
unsigned int syncinterval; /* P for adaptive mode, 0 otherwise */
unsigned char silence_value;
unsigned int stride;
int iface, altsetting;
int iface, alt_idx;
int skip_packets; /* quirks for devices to ignore the first n packets
in a stream */

@@ -118,8 +116,6 @@ struct snd_usb_substream {
unsigned int channels_max; /* max channels in the all audiofmts */
unsigned int cur_rate; /* current rate (for hw_params callback) */
unsigned int period_bytes; /* current period bytes (for hw_params callback) */
unsigned int period_frames; /* current frames per period */
unsigned int buffer_periods; /* current periods per buffer */
unsigned int altset_idx; /* USB data format: index of alternate setting */
unsigned int txfr_quirk:1; /* allow sub-frame alignment */
unsigned int fmt_type; /* USB audio format type (1-3) */
@@ -129,7 +125,6 @@ struct snd_usb_substream {

unsigned int hwptr_done; /* processed byte position in the buffer */
unsigned int transfer_done; /* processed frames since last period update */
unsigned int frame_limit; /* limits number of packets in URB */

/* data and sync endpoints for this stream */
unsigned int ep_num; /* the endpoint number */
Oops, something went wrong.

0 comments on commit 925e508

Please sign in to comment.
You can’t perform that action at this time.