aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2009-04-03 03:45:01 -0400
committerTakashi Iwai <tiwai@suse.de>2009-04-06 22:11:24 -0400
commit744b89e542b9a16c9afb8a88f623fbe059c88ccb (patch)
tree1d3937bd23db17d335bb3dbecb790bc3369da356 /sound
parent4608eb089b41386e96bd1410326073a6c1c221ba (diff)
sound: usb-audio: save data packet interval in audioformat structure
The data packet interval needs to be available in the audioformat structure, together with the other audio format parameters, so that it can be used to influence ALSA hardware parameters. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/usb/usbaudio.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index b7fa0b0b713d..3f974a64c55e 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 */
@@ -1350,12 +1351,7 @@ static int set_format(struct snd_usb_substream *subs, struct audioformat *fmt)
1350 subs->datapipe = usb_sndisocpipe(dev, ep); 1351 subs->datapipe = usb_sndisocpipe(dev, ep);
1351 else 1352 else
1352 subs->datapipe = usb_rcvisocpipe(dev, ep); 1353 subs->datapipe = usb_rcvisocpipe(dev, ep);
1353 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH && 1354 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; 1355 subs->syncpipe = subs->syncinterval = 0;
1360 subs->maxpacksize = fmt->maxpacksize; 1356 subs->maxpacksize = fmt->maxpacksize;
1361 subs->fill_max = 0; 1357 subs->fill_max = 0;
@@ -2070,6 +2066,9 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
2070 } 2066 }
2071 snd_iprintf(buffer, "\n"); 2067 snd_iprintf(buffer, "\n");
2072 } 2068 }
2069 if (snd_usb_get_speed(subs->dev) == USB_SPEED_HIGH)
2070 snd_iprintf(buffer, " Data packet interval: %d us\n",
2071 125 * (1 << fp->datainterval));
2073 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); 2072 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize);
2074 // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes); 2073 // snd_iprintf(buffer, " EP Attribute = %#x\n", fp->attributes);
2075 } 2074 }
@@ -2563,6 +2562,17 @@ static int parse_audio_format(struct snd_usb_audio *chip, struct audioformat *fp
2563 return 0; 2562 return 0;
2564} 2563}
2565 2564
2565static unsigned char parse_datainterval(struct snd_usb_audio *chip,
2566 struct usb_host_interface *alts)
2567{
2568 if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH &&
2569 get_endpoint(alts, 0)->bInterval >= 1 &&
2570 get_endpoint(alts, 0)->bInterval <= 4)
2571 return get_endpoint(alts, 0)->bInterval - 1;
2572 else
2573 return 0;
2574}
2575
2566static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip, 2576static int audiophile_skip_setting_quirk(struct snd_usb_audio *chip,
2567 int iface, int altno); 2577 int iface, int altno);
2568static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no) 2578static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
@@ -2668,6 +2678,7 @@ static int parse_audio_endpoints(struct snd_usb_audio *chip, int iface_no)
2668 fp->altset_idx = i; 2678 fp->altset_idx = i;
2669 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 2679 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
2670 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 2680 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
2681 fp->datainterval = parse_datainterval(chip, alts);
2671 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2682 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2672 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) 2683 if (snd_usb_get_speed(dev) == USB_SPEED_HIGH)
2673 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) 2684 fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1)
@@ -2859,6 +2870,7 @@ static int create_fixed_stream_quirk(struct snd_usb_audio *chip,
2859 return -EINVAL; 2870 return -EINVAL;
2860 } 2871 }
2861 alts = &iface->altsetting[fp->altset_idx]; 2872 alts = &iface->altsetting[fp->altset_idx];
2873 fp->datainterval = parse_datainterval(chip, alts);
2862 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2874 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2863 usb_set_interface(chip->dev, fp->iface, 0); 2875 usb_set_interface(chip->dev, fp->iface, 0);
2864 init_usb_pitch(chip->dev, fp->iface, alts, fp); 2876 init_usb_pitch(chip->dev, fp->iface, alts, fp);
@@ -2953,6 +2965,7 @@ static int create_uaxx_quirk(struct snd_usb_audio *chip,
2953 fp->iface = altsd->bInterfaceNumber; 2965 fp->iface = altsd->bInterfaceNumber;
2954 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 2966 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
2955 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 2967 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
2968 fp->datainterval = 0;
2956 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 2969 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
2957 2970
2958 switch (fp->maxpacksize) { 2971 switch (fp->maxpacksize) {
@@ -3020,6 +3033,7 @@ static int create_ua1000_quirk(struct snd_usb_audio *chip,
3020 fp->iface = altsd->bInterfaceNumber; 3033 fp->iface = altsd->bInterfaceNumber;
3021 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3034 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3022 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3035 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3036 fp->datainterval = parse_datainterval(chip, alts);
3023 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3037 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3024 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]); 3038 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[8]);
3025 3039
@@ -3072,6 +3086,7 @@ static int create_ua101_quirk(struct snd_usb_audio *chip,
3072 fp->iface = altsd->bInterfaceNumber; 3086 fp->iface = altsd->bInterfaceNumber;
3073 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; 3087 fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress;
3074 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; 3088 fp->ep_attr = get_endpoint(alts, 0)->bmAttributes;
3089 fp->datainterval = parse_datainterval(chip, alts);
3075 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); 3090 fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize);
3076 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]); 3091 fp->rate_max = fp->rate_min = combine_triple(&alts->extra[15]);
3077 3092