Received: by 10.192.165.148 with SMTP id m20csp1439658imm; Sat, 5 May 2018 12:05:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqLVO+7AC20oQeMHzH3IvETxUkeNe4HVZYchecX/2KGJ829Zif8nXhPv8Pa0zkNqKGUt95R X-Received: by 2002:a17:902:f24:: with SMTP id 33-v6mr33327114ply.242.1525547148130; Sat, 05 May 2018 12:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525547148; cv=none; d=google.com; s=arc-20160816; b=KDBe5pD0NZlUzTuHTqgwhK5BUDUMuaX7RVSlupRb2VZIu6BwKtoQjv07eRh9bQU2r9 1D0sjONMtL8QnmpRrB2kkHHcxkpAQhVuHQuxu+6tzfWiUtzCaYp/7yoyr607VkJDrkMf qbOhD4zk83Lp4l234wEdftGQMOr3yJuQD8Hm27icBSepVaBBFwPrb4hZxF8hbaYtO04c uaKUnsx3DJV/T5SsR9IVzeALUKkUFdvWQJVzjl7K79cD/qk8i/cdZIbYoTeYfxMjSCW9 SGTZ66WKv3ARNORZLyTb/25E3UjwTI8NNVY8BuBF4p/xfgV1q9CbXIMBHu/QpuBJDRlI iEgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=og/dYdghapjzW0alJjW3W3ufbMju/hwkykzxNoCbvvg=; b=iiAq330evVQn8siggtrGLL5Cor3TCik4udiE1YnN10LPwubLtzRFSp/deD/ZtbN8YA Ivf6wQQEtGzq8qkvjxo38l9MXHWES3cnJdS3Nvgp/KWVU7ndXwNVgQHTXa3HkiiWwLf2 hagCjWHc1iCIEPMpMBfkgPVLvLv201WOwsdz8ofdZ7u9uHTh1kGShdM9abv4AfJQGuz5 q0lL1/luaIE3NoKq5Xr6uhsKODAnlikV9hB8GptI+9jaOFKPb+voxkDQLtLfDfQHQ2Wl B6m8nenDPTq/E8IsXNc9PbyvI9uQw+iFuEw5CXU+aEgimwYFacr6oqVKjKQHXWa8g6ty c9cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bv63aG/Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 88-v6si17881387pla.315.2018.05.05.12.05.33; Sat, 05 May 2018 12:05:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bv63aG/Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbeEETEN (ORCPT + 99 others); Sat, 5 May 2018 15:04:13 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:33380 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751252AbeEETEH (ORCPT ); Sat, 5 May 2018 15:04:07 -0400 Received: by mail-it0-f67.google.com with SMTP id t7-v6so7566060itf.0 for ; Sat, 05 May 2018 12:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=og/dYdghapjzW0alJjW3W3ufbMju/hwkykzxNoCbvvg=; b=bv63aG/YlPUPw711YtP8EmDpMCqdr/D6GhZvovo8+O4MlMuRnYrzURXi0ve0w0RU36 58DkZLfTBfjN/Tivzk3UYgnJQ5CvuIfkcVNChKvZrqEfl5oBzy4i0ykUDbiwFtfPczHb JvtHK/cPsUJiUGALOnVOfc+xNy9IZ/h6HygeqlEpsKzR1CFQ7ly9Kz4hOyAGTAKz7wiG cPo/mvtWeL5VFJxvP5m3dfKxLFzSWgAS7Rn1RKbBM6dGSV2WLbdlpvm69GLgTmcurm0V RLHjAlcrioqA78CyA/pD+IgNH+vQD59vAY5YOEIvyrCN3nmYvHFrAtB00uG0rR9GuqXJ J8Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=og/dYdghapjzW0alJjW3W3ufbMju/hwkykzxNoCbvvg=; b=RATM3th4OWLLv3gSaNJnOoICEBY9xsrdoMWpwTrqsv4u5VsiCXdqVWxanTDpc3vvlZ XCSoLTLiFttj8xhVPrQgWYqXdmKZRvPCUK+sR1GEL55gSFfJizPpNHK4+iYFp6OcjkCt EiIbhI/4XM5nz3XB/VAJXGHw6cz9PJiQUak9aq7rzd6O0q5j8kJZ65XYd/PrY3FuJFPd wM928FCaD1Q71S6UykEZF8PvESnmtfwhz6qf69F5PIpE33/fAvKNemVPd8QlFaSBhKJd eXYGhMvLZFZ29mw9a8RPDnSlj3WgjWGxKMzPz7kpeZT0LK6eoT7+m38WALrvh7ZOqJ8m hlZA== X-Gm-Message-State: ALQs6tCDPd8ZlPNY6sDMVlhXPMZ9J13nmCAJ1MMeBXJ/J+TBVxRBRm/P c5CVb3mXMQtELnQ/1+Q58eY= X-Received: by 2002:a24:4561:: with SMTP id y94-v6mr22185753ita.87.1525547046948; Sat, 05 May 2018 12:04:06 -0700 (PDT) Received: from localhost.localdomain ([2605:a000:1316:4462:961:633e:9990:7115]) by smtp.googlemail.com with ESMTPSA id q21-v6sm3314945itb.4.2018.05.05.12.04.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 May 2018 12:04:06 -0700 (PDT) From: Connor McAdams Cc: o-takashi@sakamocchi.jp, Connor McAdams , Jaroslav Kysela , Takashi Iwai , =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/9] ALSA: hda/ca0132: R3Di and SBZ quirk entires + alt firmware loading Date: Sat, 5 May 2018 15:03:12 -0400 Message-Id: <1525547001-17588-2-git-send-email-conmanx360@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525547001-17588-1-git-send-email-conmanx360@gmail.com> References: <1525547001-17588-1-git-send-email-conmanx360@gmail.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds PCI quirk ID's for the Sound Blaster Z and Recon3Di. Only the currently tested ID's have been added. This patch also adds the ability to load alternative firmwares for each card, the firmwares can be obtained from within the Windows driver. The Recon3Di uses "ctefx-r3di.bin" and the Sound Blaster Z uses "ctefx-sbz.bin". If the alternative firmware for the given quirk is not found, the original ctefx.bin will be used. This has been confirmed to work for both the R3Di and the SBZ. This patch also makes the character array *dirstr a const. Signed-off-by: Connor McAdams --- sound/pci/hda/patch_ca0132.c | 61 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 768ea86..8346100 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -72,12 +72,16 @@ #define SCP_GET 1 #define EFX_FILE "ctefx.bin" +#define SBZ_EFX_FILE "ctefx-sbz.bin" +#define R3DI_EFX_FILE "ctefx-r3di.bin" #ifdef CONFIG_SND_HDA_CODEC_CA0132_DSP MODULE_FIRMWARE(EFX_FILE); +MODULE_FIRMWARE(SBZ_EFX_FILE); +MODULE_FIRMWARE(R3DI_EFX_FILE); #endif -static char *dirstr[2] = { "Playback", "Capture" }; +static const char *dirstr[2] = { "Playback", "Capture" }; enum { SPEAKER_OUT, @@ -734,6 +738,7 @@ struct ca0132_spec { unsigned int scp_resp_header; unsigned int scp_resp_data[4]; unsigned int scp_resp_count; + bool alt_firmware_present; /* mixer and effects related */ unsigned char dmic_ctl; @@ -762,6 +767,8 @@ struct ca0132_spec { enum { QUIRK_NONE, QUIRK_ALIENWARE, + QUIRK_SBZ, + QUIRK_R3DI, }; static const struct hda_pintbl alienware_pincfgs[] = { @@ -782,6 +789,10 @@ static const struct snd_pci_quirk ca0132_quirks[] = { SND_PCI_QUIRK(0x1028, 0x0685, "Alienware 15 2015", QUIRK_ALIENWARE), SND_PCI_QUIRK(0x1028, 0x0688, "Alienware 17 2015", QUIRK_ALIENWARE), SND_PCI_QUIRK(0x1028, 0x0708, "Alienware 15 R2 2016", QUIRK_ALIENWARE), + SND_PCI_QUIRK(0x1102, 0x0010, "Sound Blaster Z", QUIRK_SBZ), + SND_PCI_QUIRK(0x1102, 0x0023, "Sound Blaster Z", QUIRK_SBZ), + SND_PCI_QUIRK(0x1458, 0xA016, "Recon3Di", QUIRK_R3DI), + SND_PCI_QUIRK(0x1458, 0xA036, "Recon3Di", QUIRK_R3DI), {} }; @@ -3207,7 +3218,7 @@ static int ca0132_select_out(struct hda_codec *codec) pin_ctl & ~PIN_HP); /* enable speaker node */ pin_ctl = snd_hda_codec_read(codec, spec->out_pins[0], 0, - AC_VERB_GET_PIN_WIDGET_CONTROL, 0); + AC_VERB_GET_PIN_WIDGET_CONTROL, 0); snd_hda_set_pin_ctl(codec, spec->out_pins[0], pin_ctl | PIN_OUT); } else { @@ -4370,11 +4381,49 @@ static void ca0132_set_dsp_msr(struct hda_codec *codec, bool is96k) static bool ca0132_download_dsp_images(struct hda_codec *codec) { bool dsp_loaded = false; + struct ca0132_spec *spec = codec->spec; const struct dsp_image_seg *dsp_os_image; const struct firmware *fw_entry; - - if (request_firmware(&fw_entry, EFX_FILE, codec->card->dev) != 0) - return false; + /* + * Alternate firmwares for different variants. The Recon3Di apparently + * can use the default firmware, but I'll leave the option in case + * it needs it again. + */ + switch (spec->quirk) { + case QUIRK_SBZ: + if (request_firmware(&fw_entry, SBZ_EFX_FILE, + codec->card->dev) != 0) { + codec_dbg(codec, "SBZ alt firmware not detected. "); + spec->alt_firmware_present = false; + } else { + codec_dbg(codec, "Sound Blaster Z firmware selected."); + spec->alt_firmware_present = true; + } + break; + case QUIRK_R3DI: + if (request_firmware(&fw_entry, R3DI_EFX_FILE, + codec->card->dev) != 0) { + codec_dbg(codec, "Recon3Di alt firmware not detected."); + spec->alt_firmware_present = false; + } else { + codec_dbg(codec, "Recon3Di firmware selected."); + spec->alt_firmware_present = true; + } + break; + default: + spec->alt_firmware_present = false; + break; + } + /* + * Use default ctefx.bin if no alt firmware is detected, or if none + * exists for your particular codec. + */ + if (!spec->alt_firmware_present) { + codec_dbg(codec, "Default firmware selected."); + if (request_firmware(&fw_entry, EFX_FILE, + codec->card->dev) != 0) + return false; + } dsp_os_image = (struct dsp_image_seg *)(fw_entry->data); if (dspload_image(codec, dsp_os_image, 0, 0, true, 0)) { @@ -4476,7 +4525,7 @@ static struct hda_verb ca0132_base_exit_verbs[] = { {} }; -/* Other verbs tables. Sends after DSP download. */ +/* Other verbs tables. Sends after DSP download. */ static struct hda_verb ca0132_init_verbs0[] = { /* chip init verbs */ {0x15, 0x70D, 0xF0}, -- 2.7.4