From patchwork Tue May 8 17:20:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Connor McAdams X-Patchwork-Id: 10386645 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 17AD460353 for ; Tue, 8 May 2018 17:22:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03FA9290B3 for ; Tue, 8 May 2018 17:22:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECA03290B9; Tue, 8 May 2018 17:22:11 +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=unavailable 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 316E1290B3 for ; Tue, 8 May 2018 17:22:11 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id AECDB2676DD; Tue, 8 May 2018 19:21:10 +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 1FD69267736; Tue, 8 May 2018 19:21:07 +0200 (CEST) Received: from mail-io0-f194.google.com (mail-io0-f194.google.com [209.85.223.194]) by alsa0.perex.cz (Postfix) with ESMTP id E26BB2676EC for ; Tue, 8 May 2018 19:21:04 +0200 (CEST) Received: by mail-io0-f194.google.com with SMTP id p124-v6so39364768iod.1 for ; Tue, 08 May 2018 10:21:04 -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=1HeBUl+vNqXqfiC2CxKRnt15SJ9SJZ1JAKP/K3UmUZI=; b=OZsGk+zpU4zs7WOOQf7fg39/HgWeQbIMItOEB+HLbRjthuwFQ6M+eVv1SBVEd77TxO DZuh/VIfoAWXgjVHwTUZLBUXZtakj/d4Lwr4Pn0Yi54CyFt4x7xjMTVuqITkwLykm0c2 A2Hh5pavDamg3UwIBOJaxuZ1h6FEyeKPawo0pYMjgCJvcBxO6kpZ5fF4aa4pHdysVj7z GcaHR2kUaX2f8nbckrrIVFqPobTrMY9/2gK7BHQTexLyEXj0RHDOgRuCNx/+lmYPg/UL 3/xRximnniBn5UiwvOkuo7MPftTbMNdryPhROhxT5oI6TxiAl/6D0XfExmsrTGCcL1Pj djOQ== 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=1HeBUl+vNqXqfiC2CxKRnt15SJ9SJZ1JAKP/K3UmUZI=; b=C8ceEZNgrWXp7oefGNXe8ilR2BCFK1TPg+Zp60HO0+DLP/eRLufnR/hXzrbKl6zNo1 BqKTxnRmMh1X1eLt37GVY7UqxzwQkHufoXkhE9HiN4ePn8mQFp4mJlX9j5U6DyD3fpPD 961Q1qliWRhnO5jD80B3kYYs1dU1oAGAyQq0OC9jxvk7EqTptLWyi2bsylv5ukajOUi6 OIshCPbLMEap9QwlrzNo8yGP5ze9vbcyyynq/CS/+t1CySGWj0c80c0nZXMq3d+u//NV IEz2pyb6cfCzOCLrNx8wjUBworqv0brL1qc8wtIAu61KbM1UwBBr1pS38RV04DkyYIaG kSng== X-Gm-Message-State: ALQs6tAsGayrDMInsHGOUJKROhgsYBiKuIcwUceIIIOZcHoG1vJFXSOb bo0kG5q4pf/pweIBEA1j1dU= X-Google-Smtp-Source: AB8JxZrJenvu6qqOKQ6y7plwMVzH7L3EpvWjopeNgVnD1dGIaZaNTwlBo0IDbxm+3+/19st2mrq+ew== X-Received: by 2002:a6b:19cd:: with SMTP id 196-v6mr48397748ioz.298.1525800064047; Tue, 08 May 2018 10:21:04 -0700 (PDT) Received: from localhost.localdomain ([2605:a000:1316:4462:80cc:335d:e307:b5cb]) by smtp.googlemail.com with ESMTPSA id k62-v6sm13160209ioo.23.2018.05.08.10.21.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 May 2018 10:21:03 -0700 (PDT) From: Connor McAdams To: Date: Tue, 8 May 2018 13:20:09 -0400 Message-Id: <1525800015-2920-10-git-send-email-conmanx360@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525800015-2920-1-git-send-email-conmanx360@gmail.com> References: <1525800015-2920-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 v5 09/13] ALSA: hda/ca0132: add the ability to set src_id on scp commands 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 the ability to change the src_id on scp commands, which is used in the dsp setup of the Recon3Di and the Sound Blaster Z. It also makes sure to maintain backwards compatibility with the older dspio_set_uint_param function, and sets it's src to the default 0x20. Signed-off-by: Connor McAdams --- sound/pci/hda/patch_ca0132.c | 86 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 74 insertions(+), 12 deletions(-) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 7a9d505..878bbf7 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -1579,8 +1579,8 @@ static int dspio_send_scp_message(struct hda_codec *codec, * Returns zero or a negative error code. */ static int dspio_scp(struct hda_codec *codec, - int mod_id, int req, int dir, void *data, unsigned int len, - void *reply, unsigned int *reply_len) + int mod_id, int src_id, int req, int dir, const void *data, + unsigned int len, void *reply, unsigned int *reply_len) { int status = 0; struct scp_msg scp_send, scp_reply; @@ -1604,7 +1604,7 @@ static int dspio_scp(struct hda_codec *codec, return -EINVAL; } - scp_send.hdr = make_scp_header(mod_id, 0x20, (dir == SCP_GET), req, + scp_send.hdr = make_scp_header(mod_id, src_id, (dir == SCP_GET), req, 0, 0, 0, len/sizeof(unsigned int)); if (data != NULL && len > 0) { len = min((unsigned int)(sizeof(scp_send.data)), len); @@ -1661,15 +1661,24 @@ static int dspio_scp(struct hda_codec *codec, * Set DSP parameters */ static int dspio_set_param(struct hda_codec *codec, int mod_id, - int req, void *data, unsigned int len) + int src_id, int req, const void *data, unsigned int len) { - return dspio_scp(codec, mod_id, req, SCP_SET, data, len, NULL, NULL); + return dspio_scp(codec, mod_id, src_id, req, SCP_SET, data, len, NULL, + NULL); } static int dspio_set_uint_param(struct hda_codec *codec, int mod_id, - int req, unsigned int data) + int req, const unsigned int data) { - return dspio_set_param(codec, mod_id, req, &data, sizeof(unsigned int)); + return dspio_set_param(codec, mod_id, 0x20, req, &data, + sizeof(unsigned int)); +} + +static int dspio_set_uint_param_no_source(struct hda_codec *codec, int mod_id, + int req, const unsigned int data) +{ + return dspio_set_param(codec, mod_id, 0x00, req, &data, + sizeof(unsigned int)); } /* @@ -1681,8 +1690,9 @@ static int dspio_alloc_dma_chan(struct hda_codec *codec, unsigned int *dma_chan) unsigned int size = sizeof(dma_chan); codec_dbg(codec, " dspio_alloc_dma_chan() -- begin\n"); - status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN, - SCP_GET, NULL, 0, dma_chan, &size); + status = dspio_scp(codec, MASTERCONTROL, 0x20, + MASTERCONTROL_ALLOC_DMA_CHAN, SCP_GET, NULL, 0, + dma_chan, &size); if (status < 0) { codec_dbg(codec, "dspio_alloc_dma_chan: SCP Failed\n"); @@ -1711,8 +1721,9 @@ static int dspio_free_dma_chan(struct hda_codec *codec, unsigned int dma_chan) codec_dbg(codec, " dspio_free_dma_chan() -- begin\n"); codec_dbg(codec, "dspio_free_dma_chan: chan=%d\n", dma_chan); - status = dspio_scp(codec, MASTERCONTROL, MASTERCONTROL_ALLOC_DMA_CHAN, - SCP_SET, &dma_chan, sizeof(dma_chan), NULL, &dummy); + status = dspio_scp(codec, MASTERCONTROL, 0x20, + MASTERCONTROL_ALLOC_DMA_CHAN, SCP_SET, &dma_chan, + sizeof(dma_chan), NULL, &dummy); if (status < 0) { codec_dbg(codec, "dspio_free_dma_chan: SCP Failed\n"); @@ -3226,7 +3237,7 @@ static int tuning_ctl_set(struct hda_codec *codec, hda_nid_t nid, break; snd_hda_power_up(codec); - dspio_set_param(codec, ca0132_tuning_ctls[i].mid, + dspio_set_param(codec, ca0132_tuning_ctls[i].mid, 0x20, ca0132_tuning_ctls[i].req, &(lookup[idx]), sizeof(unsigned int)); snd_hda_power_down(codec); @@ -4612,6 +4623,27 @@ static void ca0132_refresh_widget_caps(struct hda_codec *codec) * Recon3Di r3di_setup_defaults sub functions. */ +static void r3di_dsp_scp_startup(struct hda_codec *codec) +{ + unsigned int tmp; + + tmp = 0x00000000; + dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp); + + tmp = 0x00000001; + dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp); + + tmp = 0x00000004; + dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); + + tmp = 0x00000005; + dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); + + tmp = 0x00000000; + dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); + +} + static void r3di_dsp_initial_mic_setup(struct hda_codec *codec) { unsigned int tmp; @@ -4729,6 +4761,34 @@ static void sbz_chipio_startup_data(struct hda_codec *codec) mutex_unlock(&spec->chipio_mutex); } +/* + * Sound Blaster Z uses these after DSP is loaded. Weird SCP commands + * without a 0x20 source like normal. + */ +static void sbz_dsp_scp_startup(struct hda_codec *codec) +{ + unsigned int tmp; + + tmp = 0x00000003; + dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); + + tmp = 0x00000000; + dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp); + + tmp = 0x00000001; + dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp); + + tmp = 0x00000004; + dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); + + tmp = 0x00000005; + dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); + + tmp = 0x00000000; + dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp); + +} + static void sbz_dsp_initial_mic_setup(struct hda_codec *codec) { unsigned int tmp; @@ -4807,6 +4867,7 @@ static void r3di_setup_defaults(struct hda_codec *codec) if (spec->dsp_state != DSP_DOWNLOADED) return; + r3di_dsp_scp_startup(codec); r3di_dsp_initial_mic_setup(codec); @@ -4851,6 +4912,7 @@ static void sbz_setup_defaults(struct hda_codec *codec) if (spec->dsp_state != DSP_DOWNLOADED) return; + sbz_dsp_scp_startup(codec); sbz_init_analog_mics(codec);