/* Find a free URB and submit it. must be called in line6pcm->in.lock context
*/ staticint submit_audio_in_urb(struct snd_line6_pcm *line6pcm)
{ int index; int i, urb_size; int ret; struct urb *urb_in;
index = find_first_zero_bit(&line6pcm->in.active_urbs,
line6pcm->line6->iso_buffers);
if (index < 0 || index >= line6pcm->line6->iso_buffers) {
dev_err(line6pcm->line6->ifcdev, "no free URB found\n"); return -EINVAL;
}
urb_in = line6pcm->in.urbs[index];
urb_size = 0;
for (i = 0; i < LINE6_ISO_PACKETS; ++i) { struct usb_iso_packet_descriptor *fin =
&urb_in->iso_frame_desc[i];
fin->offset = urb_size;
fin->length = line6pcm->max_packet_size_in;
urb_size += line6pcm->max_packet_size_in;
}
if (ret == 0)
set_bit(index, &line6pcm->in.active_urbs); else
dev_err(line6pcm->line6->ifcdev, "URB in #%d submission failed (%d)\n", index, ret);
return 0;
}
/* Submit all currently available capture URBs. must be called in line6pcm->in.lock context
*/ int line6_submit_audio_in_all_urbs(struct snd_line6_pcm *line6pcm)
{ int ret = 0, i;
for (i = 0; i < line6pcm->line6->iso_buffers; ++i) {
ret = submit_audio_in_urb(line6pcm); if (ret < 0) break;
}
return ret;
}
/* Copy data into ALSA capture buffer.
*/ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize)
{ struct snd_pcm_substream *substream =
get_substream(line6pcm, SNDRV_PCM_STREAM_CAPTURE); struct snd_pcm_runtime *runtime = substream->runtime; constint bytes_per_frame =
line6pcm->properties->bytes_per_channel *
line6pcm->properties->capture_hw.channels_max; int frames = fsize / bytes_per_frame;
if (runtime == NULL) return;
if (line6pcm->in.pos_done + frames > runtime->buffer_size) { /* The transferred area goes over buffer boundary, copy two separate chunks.
*/ int len;
len = runtime->buffer_size - line6pcm->in.pos_done;
if (len > 0) {
memcpy(runtime->dma_area +
line6pcm->in.pos_done * bytes_per_frame, fbuf,
len * bytes_per_frame);
memcpy(runtime->dma_area, fbuf + len * bytes_per_frame,
(frames - len) * bytes_per_frame);
} else { /* this is somewhat paranoid */
dev_err(line6pcm->line6->ifcdev, "driver bug: len = %d\n", len);
}
} else { /* copy single chunk */
memcpy(runtime->dma_area +
line6pcm->in.pos_done * bytes_per_frame, fbuf, fsize);
}
if (fsize > line6pcm->max_packet_size_in) {
dev_err(line6pcm->line6->ifcdev, "driver and/or device bug: packet too large (%d > %d)\n",
fsize, line6pcm->max_packet_size_in);
}
length += fsize;
BUILD_BUG_ON_MSG(LINE6_ISO_PACKETS != 1, "The following code assumes LINE6_ISO_PACKETS == 1"); /* TODO: * Also, if iso_buffers != 2, the prev frame is almost random at * playback side. * This needs to be redesigned. It should be "stable", but we may * experience sync problems on such high-speed configs.
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.