midi parsing fixes
This commit is contained in:
parent
f4b17d24c8
commit
196cd55787
|
|
@ -320,8 +320,7 @@ static void tascam_card_private_free(struct snd_card *card) {
|
|||
*
|
||||
* Return: 0 on success.
|
||||
*/
|
||||
static int tascam_suspend(struct usb_interface *intf, pm_message_t message)
|
||||
{
|
||||
static int tascam_suspend(struct usb_interface *intf, pm_message_t message) {
|
||||
struct tascam_card *tascam = usb_get_intfdata(intf);
|
||||
|
||||
if (!tascam)
|
||||
|
|
@ -458,7 +457,6 @@ static int tascam_probe(struct usb_interface *intf,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
|
||||
err = usb_set_interface(dev, 0, 1);
|
||||
if (err < 0) {
|
||||
dev_err(&dev->dev, "Failed to set alt setting 1 on interface 0: %d\n", err);
|
||||
|
|
|
|||
|
|
@ -196,7 +196,8 @@ void tascam_capture_work_handler(struct work_struct *work) {
|
|||
memcpy(raw_block, tascam->capture_ring_buffer + read_ptr,
|
||||
RAW_BYTES_PER_DECODE_BLOCK);
|
||||
} else {
|
||||
memcpy(raw_block, tascam->capture_ring_buffer + read_ptr, bytes_to_end);
|
||||
memcpy(raw_block, tascam->capture_ring_buffer + read_ptr,
|
||||
bytes_to_end);
|
||||
memcpy(raw_block + bytes_to_end, tascam->capture_ring_buffer,
|
||||
RAW_BYTES_PER_DECODE_BLOCK - bytes_to_end);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,35 +11,26 @@
|
|||
* the kfifo, processes it by stripping protocol-specific padding bytes, and
|
||||
* passes the clean MIDI data to the ALSA rawmidi subsystem.
|
||||
*/
|
||||
static void tascam_midi_in_work_handler(struct work_struct *work)
|
||||
{
|
||||
struct tascam_card *tascam = container_of(work, struct tascam_card, midi_in_work);
|
||||
u8 buf[MIDI_IN_BUF_SIZE];
|
||||
u8 clean_buf[MIDI_IN_BUF_SIZE];
|
||||
unsigned int len, clean_len;
|
||||
static void tascam_midi_in_work_handler(struct work_struct *work) {
|
||||
struct tascam_card *tascam =
|
||||
container_of(work, struct tascam_card, midi_in_work);
|
||||
u8 buf[9];
|
||||
u8 clean_buf[8];
|
||||
unsigned int count, clean_count;
|
||||
|
||||
if (!tascam->midi_in_substream)
|
||||
return;
|
||||
|
||||
while (!kfifo_is_empty(&tascam->midi_in_fifo)) {
|
||||
len = kfifo_out_spinlocked(&tascam->midi_in_fifo,
|
||||
buf, sizeof(buf), &tascam->midi_in_lock);
|
||||
|
||||
if (len == 0)
|
||||
continue;
|
||||
|
||||
if (!tascam->midi_in_substream)
|
||||
continue;
|
||||
|
||||
clean_len = 0;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (buf[i] == 0xfd) continue;
|
||||
if (i == (len - 1) && (buf[i] == 0x00 || buf[i] == 0xff)) continue;
|
||||
clean_buf[clean_len++] = buf[i];
|
||||
while (kfifo_out_spinlocked(&tascam->midi_in_fifo, buf, sizeof(buf),
|
||||
&tascam->midi_in_lock) == sizeof(buf)) {
|
||||
clean_count = 0;
|
||||
for (count = 0; count < 8; ++count) {
|
||||
if (buf[count] != 0xfd)
|
||||
clean_buf[clean_count++] = buf[count];
|
||||
}
|
||||
|
||||
if (clean_len > 0)
|
||||
snd_rawmidi_receive(tascam->midi_in_substream, clean_buf, clean_len);
|
||||
if (clean_count > 0)
|
||||
snd_rawmidi_receive(tascam->midi_in_substream, clean_buf, clean_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -413,4 +413,3 @@ int tascam_init_pcm(struct snd_pcm *pcm) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -187,8 +187,7 @@ void playback_urb_complete(struct urb *urb) {
|
|||
size_t bytes_for_packet;
|
||||
|
||||
if (tascam->feedback_synced) {
|
||||
frames_for_packet =
|
||||
tascam->feedback_accumulator_pattern
|
||||
frames_for_packet = tascam->feedback_accumulator_pattern
|
||||
[tascam->feedback_pattern_out_idx];
|
||||
tascam->feedback_pattern_out_idx =
|
||||
(tascam->feedback_pattern_out_idx + 1) % FEEDBACK_ACCUMULATOR_SIZE;
|
||||
|
|
@ -328,8 +327,8 @@ void feedback_urb_complete(struct urb *urb) {
|
|||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
unsigned int in_idx = (tascam->feedback_pattern_in_idx + i) %
|
||||
FEEDBACK_ACCUMULATOR_SIZE;
|
||||
unsigned int in_idx =
|
||||
(tascam->feedback_pattern_in_idx + i) % FEEDBACK_ACCUMULATOR_SIZE;
|
||||
|
||||
tascam->feedback_accumulator_pattern[in_idx] = pattern[i];
|
||||
total_frames_in_urb += pattern[i];
|
||||
|
|
@ -353,8 +352,8 @@ void feedback_urb_complete(struct urb *urb) {
|
|||
}
|
||||
}
|
||||
for (i = 0; i < 8; i++) {
|
||||
unsigned int in_idx = (tascam->feedback_pattern_in_idx + i) %
|
||||
FEEDBACK_ACCUMULATOR_SIZE;
|
||||
unsigned int in_idx =
|
||||
(tascam->feedback_pattern_in_idx + i) % FEEDBACK_ACCUMULATOR_SIZE;
|
||||
|
||||
tascam->feedback_accumulator_pattern[in_idx] = nominal_frames;
|
||||
total_frames_in_urb += nominal_frames;
|
||||
|
|
@ -388,8 +387,8 @@ void feedback_urb_complete(struct urb *urb) {
|
|||
}
|
||||
|
||||
if (playback_rt->period_size > 0) {
|
||||
u64 current_period = div_u64(tascam->playback_frames_consumed,
|
||||
playback_rt->period_size);
|
||||
u64 current_period =
|
||||
div_u64(tascam->playback_frames_consumed, playback_rt->period_size);
|
||||
|
||||
if (current_period > tascam->last_period_pos) {
|
||||
tascam->last_period_pos = current_period;
|
||||
|
|
@ -399,8 +398,8 @@ void feedback_urb_complete(struct urb *urb) {
|
|||
|
||||
if (atomic_read(&tascam->capture_active) && capture_rt &&
|
||||
capture_rt->period_size > 0) {
|
||||
u64 current_capture_period = div_u64(tascam->capture_frames_processed,
|
||||
capture_rt->period_size);
|
||||
u64 current_capture_period =
|
||||
div_u64(tascam->capture_frames_processed, capture_rt->period_size);
|
||||
|
||||
if (current_capture_period > tascam->last_capture_period_pos) {
|
||||
tascam->last_capture_period_pos = current_capture_period;
|
||||
|
|
|
|||
Loading…
Reference in New Issue