[ALSA] usb-audio - sanity-check sync feedback frequency values
USB generic driver Check that the synchronization feedback frequency values returned by the device are more or less near the nominal frequency. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
This commit is contained in:
parent
7291548df6
commit
50cdbf1519
|
@ -452,18 +452,12 @@ static int retire_playback_sync_urb(snd_usb_substream_t *subs,
|
||||||
if (urb->iso_frame_desc[0].status == 0 &&
|
if (urb->iso_frame_desc[0].status == 0 &&
|
||||||
urb->iso_frame_desc[0].actual_length == 3) {
|
urb->iso_frame_desc[0].actual_length == 3) {
|
||||||
f = combine_triple((u8*)urb->transfer_buffer) << 2;
|
f = combine_triple((u8*)urb->transfer_buffer) << 2;
|
||||||
#if 0
|
if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) {
|
||||||
if (f < subs->freqn - (subs->freqn>>3) || f > subs->freqmax) {
|
|
||||||
snd_printd(KERN_WARNING "requested frequency %d (%u,%03uHz) out of range (current nominal %d (%u,%03uHz))\n",
|
|
||||||
f, f >> 14, (f & ((1 << 14) - 1) * 1000) / ((1 << 14) - 1),
|
|
||||||
subs->freqn, subs->freqn >> 14, (subs->freqn & ((1 << 14) - 1) * 1000) / ((1 << 14) - 1));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
spin_lock_irqsave(&subs->lock, flags);
|
spin_lock_irqsave(&subs->lock, flags);
|
||||||
subs->freqm = f;
|
subs->freqm = f;
|
||||||
spin_unlock_irqrestore(&subs->lock, flags);
|
spin_unlock_irqrestore(&subs->lock, flags);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -484,10 +478,12 @@ static int retire_playback_sync_urb_hs(snd_usb_substream_t *subs,
|
||||||
if (urb->iso_frame_desc[0].status == 0 &&
|
if (urb->iso_frame_desc[0].status == 0 &&
|
||||||
urb->iso_frame_desc[0].actual_length == 4) {
|
urb->iso_frame_desc[0].actual_length == 4) {
|
||||||
f = combine_quad((u8*)urb->transfer_buffer) & 0x0fffffff;
|
f = combine_quad((u8*)urb->transfer_buffer) & 0x0fffffff;
|
||||||
|
if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) {
|
||||||
spin_lock_irqsave(&subs->lock, flags);
|
spin_lock_irqsave(&subs->lock, flags);
|
||||||
subs->freqm = f;
|
subs->freqm = f;
|
||||||
spin_unlock_irqrestore(&subs->lock, flags);
|
spin_unlock_irqrestore(&subs->lock, flags);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue