diff options
Diffstat (limited to 'sound/usb/usbaudio.c')
| -rw-r--r-- | sound/usb/usbaudio.c | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 1b7f499c54..49248fa7ae 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
| @@ -68,7 +68,7 @@ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | |||
| 68 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ | 68 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ |
| 69 | static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; /* Vendor ID for this card */ | 69 | static int vid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; /* Vendor ID for this card */ |
| 70 | static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; /* Product ID for this card */ | 70 | static int pid[SNDRV_CARDS] = { [0 ... (SNDRV_CARDS-1)] = -1 }; /* Product ID for this card */ |
| 71 | static int nrpacks = 4; /* max. number of packets per urb */ | 71 | static int nrpacks = 8; /* max. number of packets per urb */ |
| 72 | static int async_unlink = 1; | 72 | static int async_unlink = 1; |
| 73 | static int device_setup[SNDRV_CARDS]; /* device parameter for this card*/ | 73 | static int device_setup[SNDRV_CARDS]; /* device parameter for this card*/ |
| 74 | 74 | ||
| @@ -100,7 +100,7 @@ MODULE_PARM_DESC(device_setup, "Specific device setup (if needed)."); | |||
| 100 | * | 100 | * |
| 101 | */ | 101 | */ |
| 102 | 102 | ||
| 103 | #define MAX_PACKS 10 | 103 | #define MAX_PACKS 20 |
| 104 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ | 104 | #define MAX_PACKS_HS (MAX_PACKS * 8) /* in high speed mode */ |
| 105 | #define MAX_URBS 8 | 105 | #define MAX_URBS 8 |
| 106 | #define SYNC_URBS 4 /* always four urbs for sync */ | 106 | #define SYNC_URBS 4 /* always four urbs for sync */ |
| @@ -123,6 +123,7 @@ struct audioformat { | |||
| 123 | unsigned int rate_min, rate_max; /* min/max rates */ | 123 | unsigned int rate_min, rate_max; /* min/max rates */ |
| 124 | unsigned int nr_rates; /* number of rate table entries */ | 124 | unsigned int nr_rates; /* number of rate table entries */ |
| 125 | unsigned int *rate_table; /* rate table */ | 125 | unsigned int *rate_table; /* rate table */ |
| 126 | unsigned int needs_knot; /* any unusual rates? */ | ||
| 126 | }; | 127 | }; |
| 127 | 128 | ||
| 128 | struct snd_usb_substream; | 129 | struct snd_usb_substream; |
| @@ -1759,6 +1760,9 @@ static int check_hw_params_convention(struct snd_usb_substream *subs) | |||
| 1759 | } | 1760 | } |
| 1760 | channels[f->format] |= (1 << f->channels); | 1761 | channels[f->format] |= (1 << f->channels); |
| 1761 | rates[f->format] |= f->rates; | 1762 | rates[f->format] |= f->rates; |
| 1763 | /* needs knot? */ | ||
| 1764 | if (f->needs_knot) | ||
| 1765 | goto __out; | ||
| 1762 | } | 1766 | } |
| 1763 | /* check whether channels and rates match for all formats */ | 1767 | /* check whether channels and rates match for all formats */ |
| 1764 | cmaster = rmaster = 0; | 1768 | cmaster = rmaster = 0; |
| @@ -1799,6 +1803,38 @@ static int check_hw_params_convention(struct snd_usb_substream *subs) | |||
| 1799 | return err; | 1803 | return err; |
| 1800 | } | 1804 | } |
| 1801 | 1805 | ||
| 1806 | /* | ||
| 1807 | * If the device supports unusual bit rates, does the request meet these? | ||
| 1808 | */ | ||
| 1809 | static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, | ||
| 1810 | struct snd_usb_substream *subs) | ||
| 1811 | { | ||
| 1812 | struct list_head *p; | ||
| 1813 | struct snd_pcm_hw_constraint_list constraints_rates; | ||
| 1814 | int err; | ||
| 1815 | |||
| 1816 | list_for_each(p, &subs->fmt_list) { | ||
| 1817 | struct audioformat *fp; | ||
| 1818 | fp = list_entry(p, struct audioformat, list); | ||
| 1819 | |||
| 1820 | if (!fp->needs_knot) | ||
| 1821 | continue; | ||
| 1822 | |||
| 1823 | constraints_rates.count = fp->nr_rates; | ||
| 1824 | constraints_rates.list = fp->rate_table; | ||
| 1825 | constraints_rates.mask = 0; | ||
| 1826 | |||
| 1827 | err = snd_pcm_hw_constraint_list(runtime, 0, | ||
| 1828 | SNDRV_PCM_HW_PARAM_RATE, | ||
| 1829 | &constraints_rates); | ||
| 1830 | |||
| 1831 | if (err < 0) | ||
| 1832 | return err; | ||
| 1833 | } | ||
| 1834 | |||
| 1835 | return 0; | ||
| 1836 | } | ||
| 1837 | |||
| 1802 | 1838 | ||
| 1803 | /* | 1839 | /* |
| 1804 | * set up the runtime hardware information. | 1840 | * set up the runtime hardware information. |
| @@ -1861,6 +1897,8 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre | |||
| 1861 | SNDRV_PCM_HW_PARAM_CHANNELS, | 1897 | SNDRV_PCM_HW_PARAM_CHANNELS, |
| 1862 | -1)) < 0) | 1898 | -1)) < 0) |
| 1863 | return err; | 1899 | return err; |
| 1900 | if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0) | ||
| 1901 | return err; | ||
| 1864 | } | 1902 | } |
| 1865 | return 0; | 1903 | return 0; |
| 1866 | } | 1904 | } |
| @@ -2049,7 +2087,7 @@ static struct usb_driver usb_audio_driver = { | |||
| 2049 | }; | 2087 | }; |
| 2050 | 2088 | ||
| 2051 | 2089 | ||
| 2052 | #if defined(CONFIG_PROCFS) && defined(CONFIG_SND_VERBOSE_PROCFS) | 2090 | #if defined(CONFIG_PROC_FS) && defined(CONFIG_SND_VERBOSE_PROCFS) |
| 2053 | 2091 | ||
| 2054 | /* | 2092 | /* |
| 2055 | * proc interface for list the supported pcm formats | 2093 | * proc interface for list the supported pcm formats |
| @@ -2406,6 +2444,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
| 2406 | unsigned char *fmt, int offset) | 2444 | unsigned char *fmt, int offset) |
| 2407 | { | 2445 | { |
| 2408 | int nr_rates = fmt[offset]; | 2446 | int nr_rates = fmt[offset]; |
| 2447 | int found; | ||
| 2409 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { | 2448 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { |
| 2410 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", | 2449 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", |
| 2411 | chip->dev->devnum, fp->iface, fp->altsetting); | 2450 | chip->dev->devnum, fp->iface, fp->altsetting); |
| @@ -2428,6 +2467,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
| 2428 | return -1; | 2467 | return -1; |
| 2429 | } | 2468 | } |
| 2430 | 2469 | ||
| 2470 | fp->needs_knot = 0; | ||
| 2431 | fp->nr_rates = nr_rates; | 2471 | fp->nr_rates = nr_rates; |
| 2432 | fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); | 2472 | fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); |
| 2433 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { | 2473 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { |
| @@ -2436,13 +2476,19 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
| 2436 | fp->rate_min = rate; | 2476 | fp->rate_min = rate; |
| 2437 | else if (rate > fp->rate_max) | 2477 | else if (rate > fp->rate_max) |
| 2438 | fp->rate_max = rate; | 2478 | fp->rate_max = rate; |
| 2479 | found = 0; | ||
| 2439 | for (c = 0; c < (int)ARRAY_SIZE(conv_rates); c++) { | 2480 | for (c = 0; c < (int)ARRAY_SIZE(conv_rates); c++) { |
| 2440 | if (rate == conv_rates[c]) { | 2481 | if (rate == conv_rates[c]) { |
| 2482 | found = 1; | ||
| 2441 | fp->rates |= (1 << c); | 2483 | fp->rates |= (1 << c); |
| 2442 | break; | 2484 | break; |
| 2443 | } | 2485 | } |
| 2444 | } | 2486 | } |
| 2487 | if (!found) | ||
| 2488 | fp->needs_knot = 1; | ||
| 2445 | } | 2489 | } |
| 2490 | if (fp->needs_knot) | ||
| 2491 | fp->rates |= SNDRV_PCM_RATE_KNOT; | ||
| 2446 | } else { | 2492 | } else { |
| 2447 | /* continuous rates */ | 2493 | /* continuous rates */ |
| 2448 | fp->rates = SNDRV_PCM_RATE_CONTINUOUS; | 2494 | fp->rates = SNDRV_PCM_RATE_CONTINUOUS; |
| @@ -3499,7 +3545,7 @@ static void snd_usb_audio_disconnect(struct usb_device *dev, void *ptr) | |||
| 3499 | } | 3545 | } |
| 3500 | usb_chip[chip->index] = NULL; | 3546 | usb_chip[chip->index] = NULL; |
| 3501 | mutex_unlock(®ister_mutex); | 3547 | mutex_unlock(®ister_mutex); |
| 3502 | snd_card_free(card); | 3548 | snd_card_free_when_closed(card); |
| 3503 | } else { | 3549 | } else { |
| 3504 | mutex_unlock(®ister_mutex); | 3550 | mutex_unlock(®ister_mutex); |
| 3505 | } | 3551 | } |
