mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
ALSA: usb-audio: work around corrupted TEAC UD-H01 feedback data
commit 7040b6d1febfdbd9c1595efb751d492cd2503f96 upstream. The TEAC UD-H01 firmware sends wrong feedback frequency values, thus causing the PC to send the samples at a wrong rate, which results in clicks and crackles in the output. Add a workaround to detect and fix the corruption. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> [mick37@gmx.de: use sender->udh01_fb_quirk rather than ep->udh01_fb_quirk in snd_usb_handle_sync_urb()] Reported-and-tested-by: Mick <mick37@gmx.de> Reported-and-tested-by: Andrea Messa <andr.messa@tiscali.it> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ce9f1d7670
commit
b365350303
2 changed files with 15 additions and 1 deletions
|
@ -90,6 +90,7 @@ struct snd_usb_endpoint {
|
||||||
unsigned int curframesize; /* current packet size in frames (for capture) */
|
unsigned int curframesize; /* current packet size in frames (for capture) */
|
||||||
unsigned int syncmaxsize; /* sync endpoint packet size */
|
unsigned int syncmaxsize; /* sync endpoint packet size */
|
||||||
unsigned int fill_max:1; /* fill max packet size always */
|
unsigned int fill_max:1; /* fill max packet size always */
|
||||||
|
unsigned int udh01_fb_quirk:1; /* corrupted feedback data */
|
||||||
unsigned int datainterval; /* log_2 of data packet interval */
|
unsigned int datainterval; /* log_2 of data packet interval */
|
||||||
unsigned int syncinterval; /* P for adaptive mode, 0 otherwise */
|
unsigned int syncinterval; /* P for adaptive mode, 0 otherwise */
|
||||||
unsigned char silence_value;
|
unsigned char silence_value;
|
||||||
|
|
|
@ -467,6 +467,10 @@ struct snd_usb_endpoint *snd_usb_add_endpoint(struct snd_usb_audio *chip,
|
||||||
ep->syncinterval = 3;
|
ep->syncinterval = 3;
|
||||||
|
|
||||||
ep->syncmaxsize = le16_to_cpu(get_endpoint(alts, 1)->wMaxPacketSize);
|
ep->syncmaxsize = le16_to_cpu(get_endpoint(alts, 1)->wMaxPacketSize);
|
||||||
|
|
||||||
|
if (chip->usb_id == USB_ID(0x0644, 0x8038) /* TEAC UD-H01 */ &&
|
||||||
|
ep->syncmaxsize == 4)
|
||||||
|
ep->udh01_fb_quirk = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
list_add_tail(&ep->list, &chip->ep_list);
|
list_add_tail(&ep->list, &chip->ep_list);
|
||||||
|
@ -1075,7 +1079,16 @@ void snd_usb_handle_sync_urb(struct snd_usb_endpoint *ep,
|
||||||
if (f == 0)
|
if (f == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (unlikely(ep->freqshift == INT_MIN)) {
|
if (unlikely(sender->udh01_fb_quirk)) {
|
||||||
|
/*
|
||||||
|
* The TEAC UD-H01 firmware sometimes changes the feedback value
|
||||||
|
* by +/- 0x1.0000.
|
||||||
|
*/
|
||||||
|
if (f < ep->freqn - 0x8000)
|
||||||
|
f += 0x10000;
|
||||||
|
else if (f > ep->freqn + 0x8000)
|
||||||
|
f -= 0x10000;
|
||||||
|
} else if (unlikely(ep->freqshift == INT_MIN)) {
|
||||||
/*
|
/*
|
||||||
* The first time we see a feedback value, determine its format
|
* The first time we see a feedback value, determine its format
|
||||||
* by shifting it left or right until it matches the nominal
|
* by shifting it left or right until it matches the nominal
|
||||||
|
|
Loading…
Reference in a new issue