diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-04-06 22:16:32 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-04-06 22:16:32 -0400 |
commit | 8c941de17679345a52fe53ac32d8aa53ebea369d (patch) | |
tree | 7aa781bc3c55d2d526ba78ab4af510a18dda6956 /sound | |
parent | 5f9c510e9e18cd029e15190d35dd4271f2ef393b (diff) | |
parent | a7d9c0990d5503775784fef7ff44d74d7e3294fd (diff) |
Merge branch 'topic/usb-audio' into for-linus
Diffstat (limited to 'sound')
-rw-r--r-- | sound/usb/usbaudio.c | 255 |
1 files changed, 120 insertions, 135 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index c2db0f959681..823296d7d578 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -121,6 +121,7 @@ struct audioformat { | |||
121 | unsigned char attributes; /* corresponding attributes of cs endpoint */ | 121 | unsigned char attributes; /* corresponding attributes of cs endpoint */ |
122 | unsigned char endpoint; /* endpoint */ | 122 | unsigned char endpoint; /* endpoint */ |
123 | unsigned char ep_attr; /* endpoint attributes */ | 123 | unsigned char ep_attr; /* endpoint attributes */ |
124 | unsigned char datainterval; /* log_2 of data packet interval */ | ||
124 | unsigned int maxpacksize; /* max. packet size */ | 125 | unsigned int maxpacksize; /* max. packet size */ |
125 | unsigned int rates; /* rate bitmasks */ | 126 | unsigned int rates; /* rate bitmasks */ |
126 | unsigned int rate_min, rate_max; /* min/max rates */ | 127 | unsigned int rate_min, rate_max; /* min/max rates */ |
@@ -170,7 +171,6 @@ struct snd_usb_substream { | |||
170 | unsigned int curframesize; /* current packet size in frames (for capture) */ | 171 | unsigned int curframesize; /* current packet size in frames (for capture) */ |
171 | unsigned int fill_max: 1; /* fill max packet size always */ | 172 | unsigned int fill_max: 1; /* fill max packet size always */ |
172 | unsigned int fmt_type; /* USB audio format type (1-3) */ | 173 | unsigned int fmt_type; /* USB audio format type (1-3) */ |
173 | unsigned int packs_per_ms; /* packets per millisecond (for playback) */ | ||
174 | 174 | ||
175 | unsigned int running: 1; /* running status */ | 175 | unsigned int running: 1; /* running status */ |
176 | 176 | ||
@@ -607,9 +607,7 @@ static int prepare_playback_urb(struct snd_usb_substream *subs, | |||
607 | break; | 607 | break; |
608 | } | 608 | } |
609 | } | 609 | } |
610 | /* finish at the frame boundary at/after the period boundary */ | 610 | if (period_elapsed) /* finish at the period boundary */ |
611 | if (period_elapsed && | ||
612 | (i & (subs->packs_per_ms - 1)) == subs->packs_per_ms - 1) | ||
613 | break; | 611 | break; |
614 | } | 612 | } |
615 | if (subs->hwptr_done + offs > runtime->buffer_size) { | 613 | if (subs->hwptr_done + offs > runtime->buffer_size) { |
@@ -1067,7 +1065,6 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1067 | packs_per_ms = 8 >> subs->datainterval; | 1065 | packs_per_ms = 8 >> subs->datainterval; |
1068 | else | 1066 | else |
1069 | packs_per_ms = 1; | 1067 | packs_per_ms = 1; |
1070 | subs->packs_per_ms = packs_per_ms; | ||
1071 | 1068 | ||
1072 | if (is_playback) { | 1069 | if (is_playback) { |
1073 | urb_packs = max(nrpacks, 1); | 1070 | urb_packs = max(nrpacks, 1); |
@@ -1087,18 +1084,17 @@ static int init_substream_urbs(struct snd_usb_substream *subs, unsigned int peri | |||
1087 | minsize -= minsize >> 3; | 1084 | minsize -= minsize >> 3; |
1088 | minsize = max(minsize, 1u); | 1085 | minsize = max(minsize, 1u); |
1089 | total_packs = (period_bytes + minsize - 1) / minsize; | 1086 | total_packs = (period_bytes + minsize - 1) / minsize; |
1090 | /* round up to multiple of packs_per_ms */ | ||
1091 | total_packs = (total_packs + packs_per_ms - 1) | ||
1092 | & ~(packs_per_ms - 1); | ||
1093 | /* we need at least two URBs for queueing */ | 1087 | /* we need at least two URBs for queueing */ |
1094 | if (total_packs < 2 * packs_per_ms) { | 1088 | if (total_packs < 2) { |
1095 | total_packs = 2 * packs_per_ms; | 1089 | total_packs = 2; |
1096 | } else { | 1090 | } else { |
1097 | /* and we don't want too long a queue either */ | 1091 | /* and we don't want too long a queue either */ |
1098 | maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2); | 1092 | maxpacks = max(MAX_QUEUE * packs_per_ms, urb_packs * 2); |
1099 | total_packs = min(total_packs, maxpacks); | 1093 | total_packs = min(total_packs, maxpacks); |
1100 | } | 1094 | } |
1101 | } else { | 1095 | } else { |
1096 | while (urb_packs > 1 && urb_packs * maxsize >= period_bytes) | ||
1097 | urb_packs >>= 1; | ||
1102 | total_packs = MAX_URBS * urb_packs; | 1098 | total_packs = MAX_URBS * urb_packs; |
1103 | } | 1099 | } |
1104 | subs->nurbs = (total_packs + urb_packs - 1) / urb_packs; | 1100 | subs->nurbs = (total_packs + urb_packs - 1) / urb_packs; |
@@ -1350,12 +1346,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt) | |||
1350 | subs->datapipe = usb_sndisocpipe(dev, ep); | 1346 | subs->datapipe = usb_sndisocpipe(dev, ep); |
1351 | else | 1347 | else |
1352 | subs->datapipe = usb_rcvisocpipe(dev, ep); | 1348 | subs->datapipe = usb_rcvisocpipe(dev, ep); |
1353 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH && | 1349 | subs->datainterval = fmt->datainterval; |
1354 | get_endpoint(alts, 0)->bInterval >= 1 && | ||
1355 | get_endpoint(alts, 0)->bInterval <= 4) | ||
1356 | subs->datainterval = get_endpoint(alts, 0)->bInterval - 1; | ||
1357 | else | ||
1358 | subs->datainterval = 0; | ||
1359 | subs->syncpipe = subs->syncinterval = 0; | 1350 | subs->syncpipe = subs->syncinterval = 0; |
1360 | subs->maxpacksize = fmt->maxpacksize; | 1351 | subs->maxpacksize = fmt->maxpacksize; |
1361 | subs->fill_max = 0; | 1352 | subs->fill_max = 0; |
@@ -1568,11 +1559,15 @@ static struct snd_pcm_hardware snd_usb_hardware = | |||
1568 | #define hwc_debug(fmt, args...) /**/ | 1559 | #define hwc_debug(fmt, args...) /**/ |
1569 | #endif | 1560 | #endif |
1570 | 1561 | ||
1571 | static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audioformat *fp) | 1562 | static int hw_check_valid_format(struct snd_usb_substream *subs, |
1563 | struct snd_pcm_hw_params *params, | ||
1564 | struct audioformat *fp) | ||
1572 | { | 1565 | { |
1573 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | 1566 | struct snd_interval *it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); |
1574 | struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | 1567 | struct snd_interval *ct = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); |
1575 | struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); | 1568 | struct snd_mask *fmts = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); |
1569 | struct snd_interval *pt = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME); | ||
1570 | unsigned int ptime; | ||
1576 | 1571 | ||
1577 | /* check the format */ | 1572 | /* check the format */ |
1578 | if (!snd_mask_test(fmts, fp->format)) { | 1573 | if (!snd_mask_test(fmts, fp->format)) { |
@@ -1593,6 +1588,14 @@ static int hw_check_valid_format(struct snd_pcm_hw_params *params, struct audiof | |||
1593 | hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min); | 1588 | hwc_debug(" > check: rate_max %d < min %d\n", fp->rate_max, it->min); |
1594 | return 0; | 1589 | return 0; |
1595 | } | 1590 | } |
1591 | /* check whether the period time is >= the data packet interval */ | ||
1592 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) { | ||
1593 | ptime = 125 * (1 << fp->datainterval); | ||
1594 | if (ptime > pt->max || (ptime == pt->max && pt->openmax)) { | ||
1595 | hwc_debug(" > check: ptime %u > max %u\n", ptime, pt->max); | ||
1596 | return 0; | ||
1597 | } | ||
1598 | } | ||
1596 | return 1; | 1599 | return 1; |
1597 | } | 1600 | } |
1598 | 1601 | ||
@@ -1611,7 +1614,7 @@ static int hw_rule_rate(struct snd_pcm_hw_params *params, | |||
1611 | list_for_each(p, &subs->fmt_list) { | 1614 | list_for_each(p, &subs->fmt_list) { |
1612 | struct audioformat *fp; | 1615 | struct audioformat *fp; |
1613 | fp = list_entry(p, struct audioformat, list); | 1616 | fp = list_entry(p, struct audioformat, list); |
1614 | if (!hw_check_valid_format(params, fp)) | 1617 | if (!hw_check_valid_format(subs, params, fp)) |
1615 | continue; | 1618 | continue; |
1616 | if (changed++) { | 1619 | if (changed++) { |
1617 | if (rmin > fp->rate_min) | 1620 | if (rmin > fp->rate_min) |
@@ -1665,7 +1668,7 @@ static int hw_rule_channels(struct snd_pcm_hw_params *params, | |||
1665 | list_for_each(p, &subs->fmt_list) { | 1668 | list_for_each(p, &subs->fmt_list) { |
1666 | struct audioformat *fp; | 1669 | struct audioformat *fp; |
1667 | fp = list_entry(p, struct audioformat, list); | 1670 | fp = list_entry(p, struct audioformat, list); |
1668 | if (!hw_check_valid_format(params, fp)) | 1671 | if (!hw_check_valid_format(subs, params, fp)) |
1669 | continue; | 1672 | continue; |
1670 | if (changed++) { | 1673 | if (changed++) { |
1671 | if (rmin > fp->channels) | 1674 | if (rmin > fp->channels) |
@@ -1718,7 +1721,7 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, | |||
1718 | list_for_each(p, &subs->fmt_list) { | 1721 | list_for_each(p, &subs->fmt_list) { |
1719 | struct audioformat *fp; | 1722 | struct audioformat *fp; |
1720 | fp = list_entry(p, struct audioformat, list); | 1723 | fp = list_entry(p, struct audioformat, list); |
1721 | if (!hw_check_valid_format(params, fp)) | 1724 | if (!hw_check_valid_format(subs, params, fp)) |
1722 | continue; | 1725 | continue; |
1723 | fbits |= (1ULL << fp->format); | 1726 | fbits |= (1ULL << fp->format); |
1724 | } | 1727 | } |
@@ -1736,95 +1739,42 @@ static int hw_rule_format(struct snd_pcm_hw_params *params, | |||
1736 | return changed; | 1739 | return changed; |
1737 | } | 1740 | } |
1738 | 1741 | ||
1739 | #define MAX_MASK 64 | 1742 | static int hw_rule_period_time(struct snd_pcm_hw_params *params, |
1740 | 1743 | struct snd_pcm_hw_rule *rule) | |
1741 | /* | ||
1742 | * check whether the registered audio formats need special hw-constraints | ||
1743 | */ | ||
1744 | static int check_hw_params_convention(struct snd_usb_substream *subs) | ||
1745 | { | 1744 | { |
1746 | int i; | 1745 | struct snd_usb_substream *subs = rule->private; |
1747 | u32 *channels; | 1746 | struct audioformat *fp; |
1748 | u32 *rates; | 1747 | struct snd_interval *it; |
1749 | u32 cmaster, rmaster; | 1748 | unsigned char min_datainterval; |
1750 | u32 rate_min = 0, rate_max = 0; | 1749 | unsigned int pmin; |
1751 | struct list_head *p; | 1750 | int changed; |
1752 | int err = 1; | ||
1753 | |||
1754 | channels = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL); | ||
1755 | rates = kcalloc(MAX_MASK, sizeof(u32), GFP_KERNEL); | ||
1756 | if (!channels || !rates) { | ||
1757 | err = -ENOMEM; | ||
1758 | goto __out; | ||
1759 | } | ||
1760 | 1751 | ||
1761 | list_for_each(p, &subs->fmt_list) { | 1752 | it = hw_param_interval(params, SNDRV_PCM_HW_PARAM_PERIOD_TIME); |
1762 | struct audioformat *f; | 1753 | hwc_debug("hw_rule_period_time: (%u,%u)\n", it->min, it->max); |
1763 | f = list_entry(p, struct audioformat, list); | 1754 | min_datainterval = 0xff; |
1764 | /* unconventional channels? */ | 1755 | list_for_each_entry(fp, &subs->fmt_list, list) { |
1765 | if (f->channels > 32) | 1756 | if (!hw_check_valid_format(subs, params, fp)) |
1766 | goto __out; | ||
1767 | /* continuous rate min/max matches? */ | ||
1768 | if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) { | ||
1769 | if (rate_min && f->rate_min != rate_min) | ||
1770 | goto __out; | ||
1771 | if (rate_max && f->rate_max != rate_max) | ||
1772 | goto __out; | ||
1773 | rate_min = f->rate_min; | ||
1774 | rate_max = f->rate_max; | ||
1775 | } | ||
1776 | /* combination of continuous rates and fixed rates? */ | ||
1777 | if (rates[f->format] & SNDRV_PCM_RATE_CONTINUOUS) { | ||
1778 | if (f->rates != rates[f->format]) | ||
1779 | goto __out; | ||
1780 | } | ||
1781 | if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) { | ||
1782 | if (rates[f->format] && rates[f->format] != f->rates) | ||
1783 | goto __out; | ||
1784 | } | ||
1785 | channels[f->format] |= 1 << (f->channels - 1); | ||
1786 | rates[f->format] |= f->rates; | ||
1787 | /* needs knot? */ | ||
1788 | if (f->rates & SNDRV_PCM_RATE_KNOT) | ||
1789 | goto __out; | ||
1790 | } | ||
1791 | /* check whether channels and rates match for all formats */ | ||
1792 | cmaster = rmaster = 0; | ||
1793 | for (i = 0; i < MAX_MASK; i++) { | ||
1794 | if (cmaster != channels[i] && cmaster && channels[i]) | ||
1795 | goto __out; | ||
1796 | if (rmaster != rates[i] && rmaster && rates[i]) | ||
1797 | goto __out; | ||
1798 | if (channels[i]) | ||
1799 | cmaster = channels[i]; | ||
1800 | if (rates[i]) | ||
1801 | rmaster = rates[i]; | ||
1802 | } | ||
1803 | /* check whether channels match for all distinct rates */ | ||
1804 | memset(channels, 0, MAX_MASK * sizeof(u32)); | ||
1805 | list_for_each(p, &subs->fmt_list) { | ||
1806 | struct audioformat *f; | ||
1807 | f = list_entry(p, struct audioformat, list); | ||
1808 | if (f->rates & SNDRV_PCM_RATE_CONTINUOUS) | ||
1809 | continue; | 1757 | continue; |
1810 | for (i = 0; i < 32; i++) { | 1758 | min_datainterval = min(min_datainterval, fp->datainterval); |
1811 | if (f->rates & (1 << i)) | ||
1812 | channels[i] |= 1 << (f->channels - 1); | ||
1813 | } | ||
1814 | } | 1759 | } |
1815 | cmaster = 0; | 1760 | if (min_datainterval == 0xff) { |
1816 | for (i = 0; i < 32; i++) { | 1761 | hwc_debug(" --> get emtpy\n"); |
1817 | if (cmaster != channels[i] && cmaster && channels[i]) | 1762 | it->empty = 1; |
1818 | goto __out; | 1763 | return -EINVAL; |
1819 | if (channels[i]) | ||
1820 | cmaster = channels[i]; | ||
1821 | } | 1764 | } |
1822 | err = 0; | 1765 | pmin = 125 * (1 << min_datainterval); |
1823 | 1766 | changed = 0; | |
1824 | __out: | 1767 | if (it->min < pmin) { |
1825 | kfree(channels); | 1768 | it->min = pmin; |
1826 | kfree(rates); | 1769 | it->openmin = 0; |
1827 | return err; | 1770 | changed = 1; |
1771 | } | ||
1772 | if (snd_interval_checkempty(it)) { | ||
1773 | it->empty = 1; | ||
1774 | return -EINVAL; | ||
1775 | } | ||
1776 | hwc_debug(" --> (%u,%u) (changed = %d)\n", it->min, it->max, changed); | ||
1777 | return changed; | ||
1828 | } | 1778 | } |
1829 | 1779 | ||
1830 | /* | 1780 | /* |
@@ -1872,6 +1822,8 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, | |||
1872 | static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) | 1822 | static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) |
1873 | { | 1823 | { |
1874 | struct list_head *p; | 1824 | struct list_head *p; |
1825 | unsigned int pt, ptmin; | ||
1826 | int param_period_time_if_needed; | ||
1875 | int err; | 1827 | int err; |
1876 | 1828 | ||
1877 | runtime->hw.formats = subs->formats; | 1829 | runtime->hw.formats = subs->formats; |
@@ -1881,6 +1833,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre | |||
1881 | runtime->hw.channels_min = 256; | 1833 | runtime->hw.channels_min = 256; |
1882 | runtime->hw.channels_max = 0; | 1834 | runtime->hw.channels_max = 0; |
1883 | runtime->hw.rates = 0; | 1835 | runtime->hw.rates = 0; |
1836 | ptmin = UINT_MAX; | ||
1884 | /* check min/max rates and channels */ | 1837 | /* check min/max rates and channels */ |
1885 | list_for_each(p, &subs->fmt_list) { | 1838 | list_for_each(p, &subs->fmt_list) { |
1886 | struct audioformat *fp; | 1839 | struct audioformat *fp; |
@@ -1899,42 +1852,54 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre | |||
1899 | runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = | 1852 | runtime->hw.period_bytes_min = runtime->hw.period_bytes_max = |
1900 | fp->frame_size; | 1853 | fp->frame_size; |
1901 | } | 1854 | } |
1855 | pt = 125 * (1 << fp->datainterval); | ||
1856 | ptmin = min(ptmin, pt); | ||
1902 | } | 1857 | } |
1903 | 1858 | ||
1904 | /* set the period time minimum 1ms */ | 1859 | param_period_time_if_needed = SNDRV_PCM_HW_PARAM_PERIOD_TIME; |
1905 | /* FIXME: high-speed mode allows 125us minimum period, but many parts | 1860 | if (snd_usb_get_speed(subs->dev) != USB_SPEED_HIGH) |
1906 | * in the current code assume the 1ms period. | 1861 | /* full speed devices have fixed data packet interval */ |
1907 | */ | 1862 | ptmin = 1000; |
1863 | if (ptmin == 1000) | ||
1864 | /* if period time doesn't go below 1 ms, no rules needed */ | ||
1865 | param_period_time_if_needed = -1; | ||
1908 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, | 1866 | snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_TIME, |
1909 | 1000, | 1867 | ptmin, UINT_MAX); |
1910 | /*(nrpacks * MAX_URBS) * 1000*/ UINT_MAX); | 1868 | |
1911 | 1869 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | |
1912 | err = check_hw_params_convention(subs); | 1870 | hw_rule_rate, subs, |
1913 | if (err < 0) | 1871 | SNDRV_PCM_HW_PARAM_FORMAT, |
1872 | SNDRV_PCM_HW_PARAM_CHANNELS, | ||
1873 | param_period_time_if_needed, | ||
1874 | -1)) < 0) | ||
1914 | return err; | 1875 | return err; |
1915 | else if (err) { | 1876 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, |
1916 | hwc_debug("setting extra hw constraints...\n"); | 1877 | hw_rule_channels, subs, |
1917 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, | 1878 | SNDRV_PCM_HW_PARAM_FORMAT, |
1918 | hw_rule_rate, subs, | 1879 | SNDRV_PCM_HW_PARAM_RATE, |
1919 | SNDRV_PCM_HW_PARAM_FORMAT, | 1880 | param_period_time_if_needed, |
1920 | SNDRV_PCM_HW_PARAM_CHANNELS, | 1881 | -1)) < 0) |
1921 | -1)) < 0) | 1882 | return err; |
1922 | return err; | 1883 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, |
1923 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, | 1884 | hw_rule_format, subs, |
1924 | hw_rule_channels, subs, | 1885 | SNDRV_PCM_HW_PARAM_RATE, |
1925 | SNDRV_PCM_HW_PARAM_FORMAT, | 1886 | SNDRV_PCM_HW_PARAM_CHANNELS, |
1926 | SNDRV_PCM_HW_PARAM_RATE, | 1887 | param_period_time_if_needed, |
1927 | -1)) < 0) | 1888 | -1)) < 0) |
1928 | return err; | 1889 | return err; |
1929 | if ((err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, | 1890 | if (param_period_time_if_needed >= 0) { |
1930 | hw_rule_format, subs, | 1891 | err = snd_pcm_hw_rule_add(runtime, 0, |
1931 | SNDRV_PCM_HW_PARAM_RATE, | 1892 | SNDRV_PCM_HW_PARAM_PERIOD_TIME, |
1932 | SNDRV_PCM_HW_PARAM_CHANNELS, | 1893 | hw_rule_period_time, subs, |
1933 | -1)) < 0) | 1894 | SNDRV_PCM_HW_PARAM_FORMAT, |
1934 | return err; | 1895 | SNDRV_PCM_HW_PARAM_CHANNELS, |
1935 | if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0) | 1896 | SNDRV_PCM_HW_PARAM_RATE, |
1897 | -1); | ||
1898 | if (err < 0) | ||
1936 | return err; | 1899 | return err; |
1937 | } | 1900 | } |
1901 | if ((err = snd_usb_pcm_check_knot(runtime, subs)) < 0) | ||
1902 | return err; | ||
1938 | return 0; | 1903 | return 0; |
1939 | } | 1904 | } |
1940 | 1905 | ||
@@ -2147,7 +2112,8 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s | |||
2147 | fp = list_entry(p, struct audioformat, list); | 2112 | fp = list_entry(p, struct audioformat, list); |
2148 | snd_iprintf(buffer, " Interface %d\n", fp->iface); | 2113 | snd_iprintf(buffer, " Interface %d\n", fp->iface); |
2149 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); | 2114 | snd_iprintf(buffer, " Altset %d\n", fp->altsetting); |
2150 | snd_iprintf(buffer, " Format: %#x\n", fp->format); | 2115 | snd_iprintf(buffer, " Format: %#x (%d bits)\n", |
2116 | fp->format, snd_pcm_format_width(fp->format)); | ||
2151 | snd_iprintf(buffer, " Channels: %d\n", fp->channels); | 2117 | snd_iprintf(buffer, " Channels: %d\n", fp->channels); |
2152 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", | 2118 | snd_iprintf(buffer, " Endpoint: %d %s (%s)\n", |
2153 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, | 2119 | fp->endpoint & USB_ENDPOINT_NUMBER_MASK, |
@@ -2166,6 +2132,9 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s | |||
2166 | } | 2132 | } |
2167 | snd_iprintf(buffer, "\n"); | 2133 | snd_iprintf(buffer, "\n"); |
2168 | } | 2134 | } |
2135 | if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH) | ||
2136 | snd_iprintf(buffer, " Data packet interval: %d us\n", | ||
2137 | 125 * (1 << fp->datainterval)); | ||
2169 | // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); | 2138 | // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); |
2170 | // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes); | 2139 | // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes); |
2171 | } | 2140 | } |
@@ -2659,6 +2628,17 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp | |||
2659 | return 0; | 2628 | return 0; |
2660 | } | 2629 | } |
2661 | 2630 | ||
2631 | static unsigned char parse_datainterval(struct snd_usb_audio *chip, | ||
2632 | struct usb_host_interface *alts) | ||
2633 | { | ||
2634 | if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH && | ||
2635 | get_endpoint(alts, 0)->bInterval >= 1 && | ||
2636 | get_endpoint(alts, 0)->bInterval <= 4) | ||
2637 | return get_endpoint(alts, 0)->bInterval - 1; | ||
2638 | else | ||
2639 | return 0; | ||
2640 | } | ||
2641 | |||
2662 | static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, | 2642 | static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, |
2663 | int iface, int altno); | 2643 | int iface, int altno); |
2664 | static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | 2644 | static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) |
@@ -2764,6 +2744,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) | |||
2764 | fp->altset_idx = i; | 2744 | fp->altset_idx = i; |
2765 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 2745 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
2766 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 2746 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
2747 | fp->datainterval = parse_datainterval(chip, alts); | ||
2767 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 2748 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
2768 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) | 2749 | if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) |
2769 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) | 2750 | fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) |
@@ -2955,6 +2936,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip, | |||
2955 | return -EINVAL; | 2936 | return -EINVAL; |
2956 | } | 2937 | } |
2957 | alts = &iface->altsetting[fp->altset_idx]; | 2938 | alts = &iface->altsetting[fp->altset_idx]; |
2939 | fp->datainterval = parse_datainterval(chip, alts); | ||
2958 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 2940 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
2959 | usb_set_interface(chip->dev, fp->iface, 0); | 2941 | usb_set_interface(chip->dev, fp->iface, 0); |
2960 | init_usb_pitch(chip->dev, fp->iface, alts, fp); | 2942 | init_usb_pitch(chip->dev, fp->iface, alts, fp); |
@@ -3049,6 +3031,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip, | |||
3049 | fp->iface = altsd->bInterfaceNumber; | 3031 | fp->iface = altsd->bInterfaceNumber; |
3050 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 3032 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
3051 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 3033 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
3034 | fp->datainterval = 0; | ||
3052 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 3035 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
3053 | 3036 | ||
3054 | switch (fp->maxpacksize) { | 3037 | switch (fp->maxpacksize) { |
@@ -3116,6 +3099,7 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip, | |||
3116 | fp->iface = altsd->bInterfaceNumber; | 3099 | fp->iface = altsd->bInterfaceNumber; |
3117 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 3100 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
3118 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 3101 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
3102 | fp->datainterval = parse_datainterval(chip, alts); | ||
3119 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 3103 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
3120 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); | 3104 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); |
3121 | 3105 | ||
@@ -3168,6 +3152,7 @@ static int create_ua101_quirk(struct snd_usb_audio *chip, | |||
3168 | fp->iface = altsd->bInterfaceNumber; | 3152 | fp->iface = altsd->bInterfaceNumber; |
3169 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; | 3153 | fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; |
3170 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; | 3154 | fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; |
3155 | fp->datainterval = parse_datainterval(chip, alts); | ||
3171 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); | 3156 | fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); |
3172 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); | 3157 | fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); |
3173 | 3158 | ||