...
1156 /*
1157 * process after playback sync complete
1158 *
1159 * Full speed devices report feedback values in 10.14 format as samples
1160 * per frame, high speed devices in 16.16 format as samples per
1161 * microframe.
1162 *
1163 * Because the Audio Class 1 spec was written before USB 2.0, many high
1164 * speed devices use a wrong interpretation, some others use an
1165 * entirely different format.
1166 *
1167 * Therefore, we cannot predict what format any particular device uses
1168 * and must detect it automatically.
1169 */
1170
1171 if (urb->iso_frame_desc[0].status != 0 ||
1172 urb->iso_frame_desc[0].actual_length < 3)
1173 return;
1174
1175 f = le32_to_cpup(urb->transfer_buffer);
1176 if (urb->iso_frame_desc[0].actual_length == 3)
1177 f &= 0x00ffffff;
1178 else
1179 f &= 0x0fffffff;
1180
1181 if (f == 0)
1182 return;
1183
1184 if (unlikely(sender->tenor_fb_quirk)) {
1185 /*
1186 * Devices based on Tenor 8802 chipsets (TEAC UD-H01
1187 * and others) sometimes change the feedback value
1188 * by +/- 0x1.0000.
1189 */
1190 if (f < ep->freqn - 0x8000)
1191 f += 0xf000;
1192 else if (f > ep->freqn + 0x8000)
1193 f -= 0xf000;
1194 } else if (unlikely(ep->freqshift == INT_MIN)) {
1195 /*
1196 * The first time we see a feedback value, determine its format
1197 * by shifting it left or right until it matches the nominal
1198 * frequency value. This assumes that the feedback does not
1199 * differ from the nominal value more than +50% or -25%.
1200 */
1201 shift = 0;
1202 while (f < ep->freqn - ep->freqn / 4) {
1203 f <<= 1;
1204 shift++;
1205 }
1206 while (f > ep->freqn + ep->freqn / 2) {
1207 f >>= 1;
1208 shift--;
1209 }
1210 ep->freqshift = shift;
1211 } else if (ep->freqshift >= 0)
1212 f <<= ep->freqshift;
1213 else
1214 f >>= -ep->freqshift;
1215
1216 if (likely(f >= ep->freqn - ep->freqn / 8 && f <= ep->freqmax)) {
1217 /*
1218 * If the frequency looks valid, set it.
1219 * This value is referred to in prepare_playback_urb().
1220 */
1221 spin_lock_irqsave(&ep->lock, flags);
1222 ep->freqm = f;
1223 spin_unlock_irqrestore(&ep->lock, flags);
1224 } else {
1225 /*
1226 * Out of range; maybe the shift value is wrong.
1227 * Reset it so that we autodetect again the next time.
1228 */
1229 ep->freqshift = INT_MIN;
1230 }
145 int snd_usb_endpoint_next_packet_size(struct snd_usb_endpoint *ep)
146 {
147 unsigned long flags;
148 int ret;
149
150 if (ep->fill_max)
151 return ep->maxframesize;
152
153 spin_lock_irqsave(&ep->lock, flags);
154 ep->phase = (ep->phase & 0xffff)
155 + (ep->freqm << ep->datainterval);
156 ret = min(ep->phase >> 16, ep->maxframesize);
157 spin_unlock_irqrestore(&ep->lock, flags);
158
159 return ret;
160 }
1451 static void prepare_playback_urb(struct snd_usb_substream *subs,
1452 struct urb *urb)
1453 {
1454 struct snd_pcm_runtime *runtime = subs->pcm_substream->runtime;
1455 struct snd_usb_endpoint *ep = subs->data_endpoint;
1456 struct snd_urb_ctx *ctx = urb->context;
1457 unsigned int counts, frames, bytes;
1458 int i, stride, period_elapsed = 0;
1459 unsigned long flags;
1460
1461 stride = runtime->frame_bits >> 3;
1462
1463 frames = 0;
1464 urb->number_of_packets = 0;
1465 spin_lock_irqsave(&subs->lock, flags);
1466 subs->frame_limit += ep->max_urb_frames;
1467 for (i = 0; i < ctx->packets; i++) {
1468 if (ctx->packet_size)
1469 counts = ctx->packet_size;
1470 else
1471 counts = snd_usb_endpoint_next_packet_size(ep);
...
欢迎光临 耳机网-耳机大家坛 (http://www2.erji.net/) | Powered by Discuz! X3.2 |