From 7f9f88e90b8ab41a97a86fa4ff8a501e0e0eea27 Mon Sep 17 00:00:00 2001 From: aszlig Date: Fri, 16 Oct 2015 22:07:30 +0200 Subject: tishtushi: Patch quirk for AudioQuest Dragonfly. It's already in version 4.3-rc5, but the following patch seems to be more correct: http://mailman.alsa-project.org/pipermail/alsa-devel/2015-August/096516.html Signed-off-by: aszlig --- ...dio-Add-a-volume-scale-quirk-for-AudioQue.patch | 95 ++++++++++++++++++++++ ...dio-Add-sample-rate-inquiry-quirk-for-Aud.patch | 31 +++++++ ...Revert-add-dB-range-mapping-for-Dragonfly.patch | 49 +++++++++++ pkgs/kpatches/dragonfly/default.nix | 16 ++++ 4 files changed, 191 insertions(+) create mode 100644 pkgs/kpatches/dragonfly/0001-ALSA-usb-audio-Add-a-volume-scale-quirk-for-AudioQue.patch create mode 100644 pkgs/kpatches/dragonfly/0002-ALSA-usb-audio-Add-sample-rate-inquiry-quirk-for-Aud.patch create mode 100644 pkgs/kpatches/dragonfly/0003-ALSA-Revert-add-dB-range-mapping-for-Dragonfly.patch create mode 100644 pkgs/kpatches/dragonfly/default.nix (limited to 'pkgs/kpatches/dragonfly') diff --git a/pkgs/kpatches/dragonfly/0001-ALSA-usb-audio-Add-a-volume-scale-quirk-for-AudioQue.patch b/pkgs/kpatches/dragonfly/0001-ALSA-usb-audio-Add-a-volume-scale-quirk-for-AudioQue.patch new file mode 100644 index 00000000..e04df9ed --- /dev/null +++ b/pkgs/kpatches/dragonfly/0001-ALSA-usb-audio-Add-a-volume-scale-quirk-for-AudioQue.patch @@ -0,0 +1,95 @@ +From 8ccfffa0584532d9a98646bc39ead0e2361a86a2 Mon Sep 17 00:00:00 2001 +From: Anssi Hannula +Date: Sun, 16 Aug 2015 15:50:12 +0300 +Subject: [PATCH 1/3] ALSA: usb-audio: Add a volume scale quirk for AudioQuest + DragonFly + +AudioQuest DragonFly DAC reports a volume control range of 0..50 +(0x0000..0x0032) which in USB Audio means a range of 0 .. 0.2dB, which +is obviously incorrect and causes software using the dB information in +e.g. volume sliders to have a massive volume difference in 100..102% +range. + +The actual volume mapping seems to be neither linear volume nor linear +dB scale, but instead quite close to the cubic mapping e.g. alsamixer +uses, with a range of -53...0 dB. + +Add a quirk for DragonFly to use a custom dB mapping, based on my +measurements, using a 10-item range TLV (so it still fits in alsa-lib +MAX_TLV_RANGE_SIZE). + +Tested on AudioQuest DragonFly HW v1.2. The quirk is only applied if the +range is 0..50, so if this gets fixed/changed in later HW revisions it +will no longer be applied. + +Signed-off-by: Anssi Hannula +Cc: +--- + sound/usb/mixer_quirks.c | 37 +++++++++++++++++++++++++++++++++++++ + 1 file changed, 37 insertions(+) + +diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c +index d3608c0..dee73fa 100644 +--- a/sound/usb/mixer_quirks.c ++++ b/sound/usb/mixer_quirks.c +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + + #include "usbaudio.h" + #include "mixer.h" +@@ -1715,6 +1716,38 @@ static int snd_microii_controls_create(struct usb_mixer_interface *mixer) + return 0; + } + ++static void snd_dragonfly_quirk_db_scale(struct usb_mixer_interface *mixer) ++{ ++ struct usb_mixer_elem_list *list; ++ struct usb_mixer_elem_info *cval; ++ static const int unit_id = 7; ++ ++ /* approximation using 10 ranges based on output measurement on hw v1.2 */ ++ static const DECLARE_TLV_DB_RANGE(scale, ++ 0, 1, TLV_DB_MINMAX_ITEM(-5300, -4970), ++ 2, 5, TLV_DB_MINMAX_ITEM(-4710, -4160), ++ 6, 7, TLV_DB_MINMAX_ITEM(-3884, -3710), ++ 8, 14, TLV_DB_MINMAX_ITEM(-3443, -2560), ++ 15, 16, TLV_DB_MINMAX_ITEM(-2475, -2324), ++ 17, 19, TLV_DB_MINMAX_ITEM(-2228, -2031), ++ 20, 26, TLV_DB_MINMAX_ITEM(-1910, -1393), ++ 27, 31, TLV_DB_MINMAX_ITEM(-1322, -1032), ++ 32, 40, TLV_DB_MINMAX_ITEM(-968, -490), ++ 41, 50, TLV_DB_MINMAX_ITEM(-441, 0), ++ ); ++ ++ for (list = mixer->id_elems[unit_id]; list; list = list->next_id_elem) { ++ cval = (struct usb_mixer_elem_info *)list; ++ if (cval->control == UAC_FU_VOLUME && ++ cval->min == 0 && cval->max == 50) { ++ usb_audio_info(mixer->chip, "applying DragonFly dB scale quirk\n"); ++ list->kctl->tlv.p = scale; ++ list->kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ; ++ list->kctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK; ++ } ++ } ++} ++ + int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) + { + int err = 0; +@@ -1792,6 +1825,10 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) + case USB_ID(0x1235, 0x800c): /* Focusrite Scarlett 18i20 */ + err = snd_scarlett_controls_create(mixer); + break; ++ ++ case USB_ID(0x21b4, 0x0081): /* AudioQuest DragonFly */ ++ snd_dragonfly_quirk_db_scale(mixer); ++ break; + } + + return err; +-- +2.5.3 + diff --git a/pkgs/kpatches/dragonfly/0002-ALSA-usb-audio-Add-sample-rate-inquiry-quirk-for-Aud.patch b/pkgs/kpatches/dragonfly/0002-ALSA-usb-audio-Add-sample-rate-inquiry-quirk-for-Aud.patch new file mode 100644 index 00000000..60347325 --- /dev/null +++ b/pkgs/kpatches/dragonfly/0002-ALSA-usb-audio-Add-sample-rate-inquiry-quirk-for-Aud.patch @@ -0,0 +1,31 @@ +From 546503d2e0b621fc1ae4d4d99bc272f5f46e4de8 Mon Sep 17 00:00:00 2001 +From: Anssi Hannula +Date: Sun, 16 Aug 2015 15:50:13 +0300 +Subject: [PATCH 2/3] ALSA: usb-audio: Add sample rate inquiry quirk for + AudioQuest DragonFly + +Avoid getting sample rate on AudioQuest DragonFly as it is unsupported +and causes noisy "cannot get freq at ep 0x1" messages when playback +starts. + +Signed-off-by: Anssi Hannula +Cc: +--- + sound/usb/quirks.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index 00ebc0c..b2ff580 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1121,6 +1121,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) + case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */ + case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ + case USB_ID(0x074D, 0x3553): /* Outlaw RR2150 (Micronas UAC3553B) */ ++ case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ + return true; + } + return false; +-- +2.5.3 + diff --git a/pkgs/kpatches/dragonfly/0003-ALSA-Revert-add-dB-range-mapping-for-Dragonfly.patch b/pkgs/kpatches/dragonfly/0003-ALSA-Revert-add-dB-range-mapping-for-Dragonfly.patch new file mode 100644 index 00000000..69b42c38 --- /dev/null +++ b/pkgs/kpatches/dragonfly/0003-ALSA-Revert-add-dB-range-mapping-for-Dragonfly.patch @@ -0,0 +1,49 @@ +From b81246424561904823492aa551e7b22b16157a94 Mon Sep 17 00:00:00 2001 +From: aszlig +Date: Fri, 16 Oct 2015 18:31:41 +0200 +Subject: [PATCH 3/3] ALSA: Revert add dB range mapping for Dragonfly. + +This partially reverts commit 2d1cb7f658fb9c3ba8f9dab8aca297d4dfdec835. + +We now have a better patch coming from: + +http://mailman.alsa-project.org/pipermail/alsa-devel/2015-August/096516.html + +Signed-off-by: aszlig +--- + sound/usb/mixer_maps.c | 12 ------------ + 1 file changed, 12 deletions(-) + +diff --git a/sound/usb/mixer_maps.c b/sound/usb/mixer_maps.c +index 6a803ef..ddca654 100644 +--- a/sound/usb/mixer_maps.c ++++ b/sound/usb/mixer_maps.c +@@ -348,13 +348,6 @@ static struct usbmix_name_map bose_companion5_map[] = { + { 0 } /* terminator */ + }; + +-/* Dragonfly DAC 1.2, the dB conversion factor is 1 instead of 256 */ +-static struct usbmix_dB_map dragonfly_1_2_dB = {0, 5000}; +-static struct usbmix_name_map dragonfly_1_2_map[] = { +- { 7, NULL, .dB = &dragonfly_1_2_dB }, +- { 0 } /* terminator */ +-}; +- + /* + * Control map entries + */ +@@ -470,11 +463,6 @@ static struct usbmix_ctl_map usbmix_ctl_maps[] = { + .id = USB_ID(0x05a7, 0x1020), + .map = bose_companion5_map, + }, +- { +- /* Dragonfly DAC 1.2 */ +- .id = USB_ID(0x21b4, 0x0081), +- .map = dragonfly_1_2_map, +- }, + { 0 } /* terminator */ + }; + +-- +2.5.3 + diff --git a/pkgs/kpatches/dragonfly/default.nix b/pkgs/kpatches/dragonfly/default.nix new file mode 100644 index 00000000..2c5d88b0 --- /dev/null +++ b/pkgs/kpatches/dragonfly/default.nix @@ -0,0 +1,16 @@ +{ stdenv }: + +{ + name = "dragonfly"; + patch = stdenv.mkDerivation { + name = "dragonfly.patch"; + patches = [ + ./0001-ALSA-usb-audio-Add-a-volume-scale-quirk-for-AudioQue.patch + ./0002-ALSA-usb-audio-Add-sample-rate-inquiry-quirk-for-Aud.patch + ./0003-ALSA-Revert-add-dB-range-mapping-for-Dragonfly.patch + ]; + buildCommand = '' + cat $patches > "$out" + ''; + }; +} -- cgit 1.4.1