Received: by 10.192.165.148 with SMTP id m20csp4564140imm; Tue, 8 May 2018 10:23:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp3YmxS+lRSV/72zuN4xvzsSHr9l2hdC3NBy3fS7XBTm7Xasa0gVqaAWjr0+EJvOKkv6Ryw X-Received: by 2002:a17:902:ab98:: with SMTP id f24-v6mr15564184plr.144.1525800193010; Tue, 08 May 2018 10:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525800192; cv=none; d=google.com; s=arc-20160816; b=uyWJg9f1gA2VlnrdGY8hxzAGYqivsAeLqUpl/oq/swi1Li1Zb2on0D8CvKpDpjbKjJ Qw87E5Qc56vf5AwR6Jpd6JEju5SxbijCPeMxShFqjx3FJoDwtR0bNaek2I/IbaYsPBmd P05Gce1WMaRbnEnIPgM3iEW7GivYqszG0277faiL1g2x7VRCd2S9gHWbhiRic7LWVYTL zAbuWVbUxWK+Nx9ZWLdduwbHnFJwx88MU/7Z8pfu/2ONgE5E9tqt2XnrcLB3GCdxZ924 6/z9HKJ8n7ldcEB/zzD3AGwIT/e9sRJeOLd5Pv8peRCdMBDogBEAvZ+MJROyRYJBba4g uO/w== 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=1HeBUl+vNqXqfiC2CxKRnt15SJ9SJZ1JAKP/K3UmUZI=; b=uMys5XLm1+stsJDJ4Za7z4olnti6mY6x2s5wszsO16NKv+5CaZ6ThCXUfVWYK9opKy on87onJF9NtmEWkUH5jaG6x5QWi1rE9MlQA3WVWgWIppn/LEETv0olGLfzDsWKi3ptmd pr5DM0UFxrEZ8OMQxDbRQO4RuuyYRCJRAPsEKUBj6aRwYg4y8v+J4qBhY8rsqq/u1iTW aoQjpMHWtli14Sx0wlELRlYS4R32ByWTCNeYd3nN9RdkAKirVQsaTsth+pszRtGvwr2J cFl4DmpkdbTKmqWbSJiRFGkMNd0kcWKYUltXttA0DYoZewmqUU4kd5oxhq1HBEM6bdC2 PhXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OZsGk+zp; 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 g59-v6si25641138plb.381.2018.05.08.10.22.58; Tue, 08 May 2018 10:23:12 -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=OZsGk+zp; 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 S932658AbeEHRVI (ORCPT + 99 others); Tue, 8 May 2018 13:21:08 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:42079 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbeEHRVE (ORCPT ); Tue, 8 May 2018 13:21:04 -0400 Received: by mail-io0-f195.google.com with SMTP id a10-v6so39349654ioc.9 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=JowNouz6kQVLwZXfIq/JQQEXHfUO4X7XaJKfQE3EE1GrQttw6D+GvfEDxIPA6v5eDI gX5y8Ws/3MvFSaJv/r2YniA7amwBA2YvtKvl5AH9+ZqRKoPiWloYCe85sMO0eJZfaE/q oFJWRSA+iSjwb093IdXvdrAMRnxAgRo8larFXfjbgINfT8dDv1cVsV7IAJR0XetGKDE6 LIOteYe3IAuWD80CWvYBMpbq2aF5eqb3UxhsEFMHZr/vRedZQXmhYMk1tTcPc4E/m7K8 /ZB51tHxSf/hWDaoqhtoBSSNGj7yRErEL4w5SWf64wbJgdEasyR0ybohUnthKW9Fmiz6 LXPg== X-Gm-Message-State: ALQs6tD3CUgasDgoRyJNvmOxWbQ9kGcv3BnU5ADDns0VfgS4gsa0Y2wa U2CTMKOWZHX4zvky13XlGEg= 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 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 v5 09/13] ALSA: hda/ca0132: add the ability to set src_id on scp commands 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> 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 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); -- 2.7.4