From patchwork Thu May 3 21:42:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Connor McAdams X-Patchwork-Id: 10379323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69A126037D for ; Thu, 3 May 2018 21:43:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B56229150 for ; Thu, 3 May 2018 21:43:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F2632915B; Thu, 3 May 2018 21:43:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7516529150 for ; Thu, 3 May 2018 21:43:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6E9CA2675FA; Thu, 3 May 2018 23:43:26 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6677A2675DA; Thu, 3 May 2018 23:43:22 +0200 (CEST) Received: from mail-it0-f67.google.com (mail-it0-f67.google.com [209.85.214.67]) by alsa0.perex.cz (Postfix) with ESMTP id 220D22673A6 for ; Thu, 3 May 2018 23:43:17 +0200 (CEST) Received: by mail-it0-f67.google.com with SMTP id j186-v6so1098673ita.5 for ; Thu, 03 May 2018 14:43:17 -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=Mk/Jm9Wr3yGi2447Z7N928tIqtfalGvjk1BCz4TDQo8=; b=BukV75ncW+yQW9uUsbQN0U5L2pE+EZWKe/TwgRxiRAZymFBWYZ+gEdDYGvpv4pgsXB /jcm5FNYrN7oYRJ0dt8SGkavPetBKEywStTZGdjEdiO37ITzNIzEYyWhvG/+CAyIK9J/ 9mYn0HJOyKZp3yHnicuAvtX8/uad39M+6TarxB2RbT1Kbi2ngMP0/HKMTY+yjPFviHoD J09cX7YijeW1ZHdu9KffyTCNeW8rxXrno+I4sZ39QfmoyO35/FKASzRM9nkr8DGPVFSd JXtZUWt7qmFpKYHew6FzHEftYINoMlEbEFXAJqw35EKOHpTtQHZFZmQmZUelRW5n0uhV dl3w== 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=Mk/Jm9Wr3yGi2447Z7N928tIqtfalGvjk1BCz4TDQo8=; b=YA/6OsSp3KX6GdeyJ4u7P+5KSfii+igSN3l8HrZ4vkVcyv0uPHRdsQOtXyHWTxaF3a G0wMxGe8zFGgtZLNG8kEDkaHdpl92sCtvXeV6nCjiIBkLkUKq70XVbUu1qsFienvtAyb rPsEWsZTIAN2D5RQJiAc/Xf0hhQgdV/8SAIey0BY3L8x8cI6iRTMVkynvzI8CCv9KGzw K0DmfJ7YOi7xlHAumYLMDVwuI0uLOdxZrAdCKB58mk38i9p/xVFG6dGYaOl9E2SBvgj3 mDs0qL/d4ehRsqn9tJYSgjdeOfinRAymm1ca+TWCQfsa8ZtkHhjEizlP2MLnL/5I6JYJ Q+Yg== X-Gm-Message-State: ALQs6tCRdh2i7zECA0S0SLSdSAO81rhW38ducgTnVTFNOH1S81YfBrLC pQISogg1ilwkCC1TA3JwIqc= X-Google-Smtp-Source: AB8JxZqoIIdGBun5tZgDAOQKBx7PsspGSpnH4DxdGFMDvwlhPlcfQSGVjq5MRjXOJAmCAqZ0G+t4Ow== X-Received: by 2002:a24:61d0:: with SMTP id s199-v6mr28127341itc.66.1525383796231; Thu, 03 May 2018 14:43:16 -0700 (PDT) Received: from localhost.localdomain ([2605:a000:1316:4462:30e7:9a4b:7da5:3c1c]) by smtp.googlemail.com with ESMTPSA id u77-v6sm263119ita.30.2018.05.03.14.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 May 2018 14:43:15 -0700 (PDT) From: Connor McAdams To: Date: Thu, 3 May 2018 17:42:44 -0400 Message-Id: <1525383771-11105-3-git-send-email-conmanx360@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525383771-11105-1-git-send-email-conmanx360@gmail.com> References: <1525383771-11105-1-git-send-email-conmanx360@gmail.com> Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Takashi Iwai , =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= , Connor McAdams , o-takashi@sakamocchi.jp Subject: [alsa-devel] [PATCH 3/9] Add PCI region2 iomap for SBZ X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds iomapping for the region2 section of memory on the SBZ. This memory region is used in later patches for setting inputs and outputs. If the mapping fails, the quirk is changed back to QUIRK_NONE to avoid attempts to write to uninitialized memory. It also adds a new exit sequence to unmap the iomem for the SBZ. Signed-off-by: Connor McAdams --- sound/pci/hda/patch_ca0132.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 9347c9d..2f7f964 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -29,6 +29,9 @@ #include #include #include +#include +#include +#include #include "hda_codec.h" #include "hda_local.h" #include "hda_auto_parser.h" @@ -760,6 +763,11 @@ struct ca0132_spec { #ifdef ENABLE_TUNING_CONTROLS long cur_ctl_vals[TUNING_CTLS_COUNT]; #endif + /* + * Sound Blaster Z PCI region 2 iomem, used for input and output + * switching, and other unknown commands. + */ + void __iomem *mem_base; }; /* @@ -4691,8 +4699,17 @@ static void ca0132_free(struct hda_codec *codec) cancel_delayed_work_sync(&spec->unsol_hp_work); snd_hda_power_up(codec); - snd_hda_sequence_write(codec, spec->base_exit_verbs); - ca0132_exit_chip(codec); + switch (spec->quirk) { + case QUIRK_SBZ: + iounmap(spec->mem_base); + snd_hda_sequence_write(codec, spec->base_exit_verbs); + ca0132_exit_chip(codec); + break; + default: + snd_hda_sequence_write(codec, spec->base_exit_verbs); + ca0132_exit_chip(codec); + break; + } snd_hda_power_down(codec); kfree(spec->spec_init_verbs); kfree(codec->spec); @@ -4909,6 +4926,15 @@ static int patch_ca0132(struct hda_codec *codec) else spec->quirk = QUIRK_NONE; + /* Setup BAR Region 2 for Sound Blaster Z */ + if (spec->quirk == QUIRK_SBZ) { + spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20); + if (spec->mem_base == NULL) { + codec_dbg(codec, "pci_iomap failed!"); + codec_dbg(codec, "perhaps this is not an SBZ?"); + spec->quirk = QUIRK_NONE; + } + } spec->dsp_state = DSP_DOWNLOAD_INIT; spec->num_mixers = 1; spec->mixers[0] = ca0132_mixer;