linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Add quirk for Focusrite Scarlett 2i2
@ 2020-04-20 20:19 Gregor Pintar
  2020-04-20 20:25 ` Alexander Tsoy
  0 siblings, 1 reply; 5+ messages in thread
From: Gregor Pintar @ 2020-04-20 20:19 UTC (permalink / raw)
  To: tiwai, perex; +Cc: linux-kernel, alsa-devel, grpintar

Force it to use asynchronous playback.

Same quirk has already been added for Focusrite Scarlett Solo (2nd gen)
with a commit 46f5710f0b88 ("ALSA: usb-audio: Add quirk for Focusrite
Scarlett Solo").

This also seems to prevent regular clicks when playing at 44100Hz
on Scarlett 2i2 (2nd gen). I did not notice any side effects.

Signed-off-by: Gregor Pintar <grpintar@gmail.com>
---
 sound/usb/quirks-table.h | 84 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index e009d584e..bc936bf79 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -2840,6 +2840,90 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 		}
 	}
 },
+{
+	/*
+	 * Focusrite Scarlett 2i2 2nd generation
+	 * Reports that playback should use Synch: Synchronous
+	 * while still providing a feedback endpoint. Synchronous causes
+	 * snapping on some sample rates.
+	 * Force it to use Synch: Asynchronous.
+	 */
+	USB_DEVICE(0x1235, 0x8202),
+	.driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
+		.ifnum = QUIRK_ANY_INTERFACE,
+		.type = QUIRK_COMPOSITE,
+		.data = (const struct snd_usb_audio_quirk[]) {
+			{
+				.ifnum = 1,
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = &(const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S32_LE,
+					.channels = 2,
+					.iface = 1,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.attributes = 0,
+					.endpoint = 0x01,
+					.ep_attr = USB_ENDPOINT_XFER_ISOC |
+						USB_ENDPOINT_SYNC_ASYNC,
+					.protocol = UAC_VERSION_2,
+					.rates = SNDRV_PCM_RATE_44100 |
+						SNDRV_PCM_RATE_48000 |
+						SNDRV_PCM_RATE_88200 |
+						SNDRV_PCM_RATE_96000 |
+						SNDRV_PCM_RATE_176400 |
+						SNDRV_PCM_RATE_192000,
+					.rate_min = 44100,
+					.rate_max = 192000,
+					.nr_rates = 6,
+					.rate_table = (unsigned int[]) {
+						44100, 48000, 88200,
+						96000, 176400, 192000
+					},
+					.clock = 41
+				}
+			},
+			{
+				.ifnum = 2,
+				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
+				.data = &(const struct audioformat) {
+					.formats = SNDRV_PCM_FMTBIT_S32_LE,
+					.channels = 2,
+					.iface = 2,
+					.altsetting = 1,
+					.altset_idx = 1,
+					.attributes = 0,
+					.endpoint = 0x82,
+					.ep_attr = USB_ENDPOINT_XFER_ISOC |
+						USB_ENDPOINT_SYNC_ASYNC |
+						USB_ENDPOINT_USAGE_IMPLICIT_FB,
+					.protocol = UAC_VERSION_2,
+					.rates = SNDRV_PCM_RATE_44100 |
+						SNDRV_PCM_RATE_48000 |
+						SNDRV_PCM_RATE_88200 |
+						SNDRV_PCM_RATE_96000 |
+						SNDRV_PCM_RATE_176400 |
+						SNDRV_PCM_RATE_192000,
+					.rate_min = 44100,
+					.rate_max = 192000,
+					.nr_rates = 6,
+					.rate_table = (unsigned int[]) {
+						44100, 48000, 88200,
+						96000, 176400, 192000
+					},
+					.clock = 41
+				}
+			},
+			{
+				.ifnum = 3,
+				.type = QUIRK_IGNORE_INTERFACE
+			},
+			{
+				.ifnum = -1
+			}
+		}
+	}
+},
 
 /* Access Music devices */
 {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ALSA: usb-audio: Add quirk for Focusrite Scarlett 2i2
  2020-04-20 20:19 [PATCH] ALSA: usb-audio: Add quirk for Focusrite Scarlett 2i2 Gregor Pintar
@ 2020-04-20 20:25 ` Alexander Tsoy
  2020-04-20 21:40   ` [PATCH v2] " Gregor Pintar
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Tsoy @ 2020-04-20 20:25 UTC (permalink / raw)
  To: Gregor Pintar, tiwai, perex; +Cc: alsa-devel, linux-kernel

В Пн, 20/04/2020 в 22:19 +0200, Gregor Pintar пишет:
> Force it to use asynchronous playback.

Can we use snd_usb_audioformat_attributes_quirk() for such fixes? See
the quirk for Griffin iMic as an example.

> 
> Same quirk has already been added for Focusrite Scarlett Solo (2nd
> gen)
> with a commit 46f5710f0b88 ("ALSA: usb-audio: Add quirk for Focusrite
> Scarlett Solo").
> 
> This also seems to prevent regular clicks when playing at 44100Hz
> on Scarlett 2i2 (2nd gen). I did not notice any side effects.
> 
> Signed-off-by: Gregor Pintar <grpintar@gmail.com>
> ---
>  sound/usb/quirks-table.h | 84
> ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
> 
> diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
> index e009d584e..bc936bf79 100644
> --- a/sound/usb/quirks-table.h
> +++ b/sound/usb/quirks-table.h
> @@ -2840,6 +2840,90 @@ YAMAHA_DEVICE(0x7010, "UB99"),
>  		}
>  	}
>  },
> +{
> +	/*
> +	 * Focusrite Scarlett 2i2 2nd generation
> +	 * Reports that playback should use Synch: Synchronous
> +	 * while still providing a feedback endpoint. Synchronous
> causes
> +	 * snapping on some sample rates.
> +	 * Force it to use Synch: Asynchronous.
> +	 */
> +	USB_DEVICE(0x1235, 0x8202),
> +	.driver_info = (unsigned long) &(const struct
> snd_usb_audio_quirk) {
> +		.ifnum = QUIRK_ANY_INTERFACE,
> +		.type = QUIRK_COMPOSITE,
> +		.data = (const struct snd_usb_audio_quirk[]) {
> +			{
> +				.ifnum = 1,
> +				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
> +				.data = &(const struct audioformat) {
> +					.formats =
> SNDRV_PCM_FMTBIT_S32_LE,
> +					.channels = 2,
> +					.iface = 1,
> +					.altsetting = 1,
> +					.altset_idx = 1,
> +					.attributes = 0,
> +					.endpoint = 0x01,
> +					.ep_attr =
> USB_ENDPOINT_XFER_ISOC |
> +						USB_ENDPOINT_SYNC_ASYNC
> ,
> +					.protocol = UAC_VERSION_2,
> +					.rates = SNDRV_PCM_RATE_44100 |
> +						SNDRV_PCM_RATE_48000 |
> +						SNDRV_PCM_RATE_88200 |
> +						SNDRV_PCM_RATE_96000 |
> +						SNDRV_PCM_RATE_176400 |
> +						SNDRV_PCM_RATE_192000,
> +					.rate_min = 44100,
> +					.rate_max = 192000,
> +					.nr_rates = 6,
> +					.rate_table = (unsigned int[])
> {
> +						44100, 48000, 88200,
> +						96000, 176400, 192000
> +					},
> +					.clock = 41
> +				}
> +			},
> +			{
> +				.ifnum = 2,
> +				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
> +				.data = &(const struct audioformat) {
> +					.formats =
> SNDRV_PCM_FMTBIT_S32_LE,
> +					.channels = 2,
> +					.iface = 2,
> +					.altsetting = 1,
> +					.altset_idx = 1,
> +					.attributes = 0,
> +					.endpoint = 0x82,
> +					.ep_attr =
> USB_ENDPOINT_XFER_ISOC |
> +						USB_ENDPOINT_SYNC_ASYNC
> |
> +						USB_ENDPOINT_USAGE_IMPL
> ICIT_FB,
> +					.protocol = UAC_VERSION_2,
> +					.rates = SNDRV_PCM_RATE_44100 |
> +						SNDRV_PCM_RATE_48000 |
> +						SNDRV_PCM_RATE_88200 |
> +						SNDRV_PCM_RATE_96000 |
> +						SNDRV_PCM_RATE_176400 |
> +						SNDRV_PCM_RATE_192000,
> +					.rate_min = 44100,
> +					.rate_max = 192000,
> +					.nr_rates = 6,
> +					.rate_table = (unsigned int[])
> {
> +						44100, 48000, 88200,
> +						96000, 176400, 192000
> +					},
> +					.clock = 41
> +				}
> +			},
> +			{
> +				.ifnum = 3,
> +				.type = QUIRK_IGNORE_INTERFACE
> +			},
> +			{
> +				.ifnum = -1
> +			}
> +		}
> +	}
> +},
>  
>  /* Access Music devices */
>  {


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] ALSA: usb-audio: Add quirk for Focusrite Scarlett 2i2
  2020-04-20 20:25 ` Alexander Tsoy
@ 2020-04-20 21:40   ` Gregor Pintar
  2020-04-20 23:47     ` Alexander Tsoy
  2020-04-21  6:06     ` Takashi Iwai
  0 siblings, 2 replies; 5+ messages in thread
From: Gregor Pintar @ 2020-04-20 21:40 UTC (permalink / raw)
  To: tiwai, perex, alexander; +Cc: linux-kernel, alsa-devel, grpintar

Force it to use asynchronous playback.

Same quirk has already been added for Focusrite Scarlett Solo (2nd gen)
with a commit 46f5710f0b88 ("ALSA: usb-audio: Add quirk for Focusrite
Scarlett Solo").

This also seems to prevent regular clicks when playing at 44100Hz
on Scarlett 2i2 (2nd gen). I did not notice any side effects.

Moved both quirks to snd_usb_audioformat_attributes_quirk() as suggested.

Signed-off-by: Gregor Pintar <grpintar@gmail.com>
---
 sound/usb/quirks-table.h | 84 ----------------------------------------
 sound/usb/quirks.c       | 13 +++++++
 2 files changed, 13 insertions(+), 84 deletions(-)

diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
index e009d584e..7e06ab108 100644
--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -2756,90 +2756,6 @@ YAMAHA_DEVICE(0x7010, "UB99"),
 		.type = QUIRK_MIDI_NOVATION
 	}
 },
-{
-	/*
-	 * Focusrite Scarlett Solo 2nd generation
-	 * Reports that playback should use Synch: Synchronous
-	 * while still providing a feedback endpoint. Synchronous causes
-	 * snapping on some sample rates.
-	 * Force it to use Synch: Asynchronous.
-	 */
-	USB_DEVICE(0x1235, 0x8205),
-	.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
-		.ifnum = QUIRK_ANY_INTERFACE,
-		.type = QUIRK_COMPOSITE,
-		.data = (const struct snd_usb_audio_quirk[]) {
-			{
-				.ifnum = 1,
-				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
-				.data = & (const struct audioformat) {
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 2,
-					.iface = 1,
-					.altsetting = 1,
-					.altset_idx = 1,
-					.attributes = 0,
-					.endpoint = 0x01,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC |
-						   USB_ENDPOINT_SYNC_ASYNC,
-					.protocol = UAC_VERSION_2,
-					.rates = SNDRV_PCM_RATE_44100 |
-						 SNDRV_PCM_RATE_48000 |
-						 SNDRV_PCM_RATE_88200 |
-						 SNDRV_PCM_RATE_96000 |
-						 SNDRV_PCM_RATE_176400 |
-						 SNDRV_PCM_RATE_192000,
-					.rate_min = 44100,
-					.rate_max = 192000,
-					.nr_rates = 6,
-					.rate_table = (unsigned int[]) {
-						44100, 48000, 88200,
-						96000, 176400, 192000
-					},
-					.clock = 41
-				}
-			},
-			{
-				.ifnum = 2,
-				.type = QUIRK_AUDIO_FIXED_ENDPOINT,
-				.data = & (const struct audioformat) {
-					.formats = SNDRV_PCM_FMTBIT_S32_LE,
-					.channels = 2,
-					.iface = 2,
-					.altsetting = 1,
-					.altset_idx = 1,
-					.attributes = 0,
-					.endpoint = 0x82,
-					.ep_attr = USB_ENDPOINT_XFER_ISOC |
-						   USB_ENDPOINT_SYNC_ASYNC |
-						   USB_ENDPOINT_USAGE_IMPLICIT_FB,
-					.protocol = UAC_VERSION_2,
-					.rates = SNDRV_PCM_RATE_44100 |
-						 SNDRV_PCM_RATE_48000 |
-						 SNDRV_PCM_RATE_88200 |
-						 SNDRV_PCM_RATE_96000 |
-						 SNDRV_PCM_RATE_176400 |
-						 SNDRV_PCM_RATE_192000,
-					.rate_min = 44100,
-					.rate_max = 192000,
-					.nr_rates = 6,
-					.rate_table = (unsigned int[]) {
-						44100, 48000, 88200,
-						96000, 176400, 192000
-					},
-					.clock = 41
-				}
-			},
-			{
-				.ifnum = 3,
-				.type = QUIRK_IGNORE_INTERFACE
-			},
-			{
-				.ifnum = -1
-			}
-		}
-	}
-},
 
 /* Access Music devices */
 {
diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
index a8ece1701..6c2dfd3bf 100644
--- a/sound/usb/quirks.c
+++ b/sound/usb/quirks.c
@@ -1806,6 +1806,19 @@ void snd_usb_audioformat_attributes_quirk(struct snd_usb_audio *chip,
 		 */
 		fp->attributes &= ~UAC_EP_CS_ATTR_FILL_MAX;
 		break;
+	case USB_ID(0x1235, 0x8202):  /* Focusrite Scarlett 2i2 2nd gen */
+	case USB_ID(0x1235, 0x8205):  /* Focusrite Scarlett Solo 2nd gen */
+		/*
+		 * Reports that playback should use Synch: Synchronous
+		 * while still providing a feedback endpoint.
+		 * Synchronous causes snapping on some sample rates.
+		 * Force it to use Synch: Asynchronous.
+		 */
+		if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
+			fp->ep_attr &= ~USB_ENDPOINT_SYNCTYPE;
+			fp->ep_attr |= USB_ENDPOINT_SYNC_ASYNC;
+		}
+		break;
 	}
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ALSA: usb-audio: Add quirk for Focusrite Scarlett 2i2
  2020-04-20 21:40   ` [PATCH v2] " Gregor Pintar
@ 2020-04-20 23:47     ` Alexander Tsoy
  2020-04-21  6:06     ` Takashi Iwai
  1 sibling, 0 replies; 5+ messages in thread
From: Alexander Tsoy @ 2020-04-20 23:47 UTC (permalink / raw)
  To: Gregor Pintar, tiwai, perex; +Cc: linux-kernel, alsa-devel

В Пн, 20/04/2020 в 23:40 +0200, Gregor Pintar пишет:
> Force it to use asynchronous playback.
> 
> Same quirk has already been added for Focusrite Scarlett Solo (2nd
> gen)
> with a commit 46f5710f0b88 ("ALSA: usb-audio: Add quirk for Focusrite
> Scarlett Solo").
> 
> This also seems to prevent regular clicks when playing at 44100Hz
> on Scarlett 2i2 (2nd gen). I did not notice any side effects.
> 
> Moved both quirks to snd_usb_audioformat_attributes_quirk() as
> suggested.
> 
> Signed-off-by: Gregor Pintar <grpintar@gmail.com>

Thank you!

Reviewed-by: Alexander Tsoy <alexander@tsoy.me>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] ALSA: usb-audio: Add quirk for Focusrite Scarlett 2i2
  2020-04-20 21:40   ` [PATCH v2] " Gregor Pintar
  2020-04-20 23:47     ` Alexander Tsoy
@ 2020-04-21  6:06     ` Takashi Iwai
  1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2020-04-21  6:06 UTC (permalink / raw)
  To: Gregor Pintar; +Cc: tiwai, perex, alexander, linux-kernel, alsa-devel

On Mon, 20 Apr 2020 23:40:30 +0200,
Gregor Pintar wrote:
> 
> Force it to use asynchronous playback.
> 
> Same quirk has already been added for Focusrite Scarlett Solo (2nd gen)
> with a commit 46f5710f0b88 ("ALSA: usb-audio: Add quirk for Focusrite
> Scarlett Solo").
> 
> This also seems to prevent regular clicks when playing at 44100Hz
> on Scarlett 2i2 (2nd gen). I did not notice any side effects.
> 
> Moved both quirks to snd_usb_audioformat_attributes_quirk() as suggested.
> 
> Signed-off-by: Gregor Pintar <grpintar@gmail.com>

Applied it now to for-linus branch.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-21  6:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-20 20:19 [PATCH] ALSA: usb-audio: Add quirk for Focusrite Scarlett 2i2 Gregor Pintar
2020-04-20 20:25 ` Alexander Tsoy
2020-04-20 21:40   ` [PATCH v2] " Gregor Pintar
2020-04-20 23:47     ` Alexander Tsoy
2020-04-21  6:06     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).