Received: by 10.192.165.148 with SMTP id m20csp3774974imm; Mon, 7 May 2018 19:34:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZobYagNPBcDV5dl5fjw+Uripzm0m1P7OuI+VJTM2TmvaduQmhtiIxaCLJArmJVRVLW6Uthg X-Received: by 2002:a63:9c09:: with SMTP id f9-v6mr31715693pge.274.1525746849015; Mon, 07 May 2018 19:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525746848; cv=none; d=google.com; s=arc-20160816; b=VRMZ8yNbrolnD7ziF5ujtjudJfYWT7uVxBPLGOY1v/k0Wi5E1YoidjdoVF5gOAj/Kx 9qlDespOvgpjT2+AWS5vhEY/h1lCgOV/njzvuBXq9pnw+EwSP8wC5V91NFxodNnepz1K VOVXBT/fsxvD43qKi3y5Qz+2xUzMftd7+h4PIorfhFwlRYn6FKGVYy2MH/QWwq8KmsDr PYxcK/v+5ZE7oaxCGHXviVesbma4UbQ6wuLv3bYW4KmiBrihXq61S1Pe0pkrhYIWq/Ua /2m2iN9lJHUlwnZxMaoXXL3OgHcFEZlk1Wu1C66kJjWIyo+hpdFxZ+siOL51UvroeHvP n67w== 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=p3WgOhjfe7TCmBbvYATrByTXO0VO2b/IE3aoFEq5nUwyK3ViBE048cgLz0aJPkvkqJ w0ImGBqfXdwTRmujMvHc5LGqDsp3TJUE3dNbFWszFolRaplfVsTmMWH8gZtG7yrNHaXz HH4GX5cXn5gHI23NWXAxvFiYqr/g/mHgUQlisdEq8gchiKuRmgmSPsy3rqGp9aSK8pbe Xkj4b3XvHF/TJFAVRnVbjWG7msdhOYRFq6oVcOyrhQIN+E7Z6EDGIGE2rGMaYBUk1sF2 HOJtNtdZWq402i9a7domQATjvBTUDbnS5x9GAq93suBDvW62lagjUZRlpY0YRCBn/t1u qIUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ugfo6aCr; 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 t135-v6si18887312pgc.656.2018.05.07.19.33.54; Mon, 07 May 2018 19:34:08 -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=Ugfo6aCr; 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 S1754026AbeEHCc1 (ORCPT + 99 others); Mon, 7 May 2018 22:32:27 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:39861 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754018AbeEHCcW (ORCPT ); Mon, 7 May 2018 22:32:22 -0400 Received: by mail-io0-f193.google.com with SMTP id r9-v6so36609933iod.6 for ; Mon, 07 May 2018 19:32:22 -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=Ugfo6aCr/xCQQ6pUEn6/4oZPzpm80Ff/wfo8hw/FCFH/8eW8Kxz90ssCNaF+rKXhP+ QFXR1eb1LYdA0b7PgW7CCBDCR4To/Q9wDZBtPp7kkWZD6OFyhu6iajl0nHGC9RqS53PK 7T2TRIls+co7+G7P87dddOMufMcLYqjwQO20GIQVJxo8+a+ONv5lc6rYouHm56+EQU15 JhjdYAJwKxMdKbGG7X2s+Zv/pWKsuSZwNTEt3gX6QsudT1wEDgQc5h/8JYvvo8RMs4aS 2jGPkMdgd9th0FQV63QR9efuLVx36vttVrhXPo9RrdfX6t2QspaU3LggDwhDVm2eNBaQ b8oA== 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=TqYIb2M062f0x+fLJ5LvYKR2Q2ngGSTXHSU62RuxGshUnImCnWMCu0ojiV3q5YVHPn W73DGhDCBklPvN2EIrpcvLxwjwOlMrutaZdGva4/O/vuM6vunFQenIKt9vannhNY2JI9 Y39LnwsQigcoiaDL6GGK7o2S+Lb3/wEzaLZC0PRpJX2MTaryKC+BbgSSLNsUtz+9+jrT C0SrnZ0xz/iWy0/3j17psp3muGgQJdID4XAjD/0xpUQejgZ8IJ/w3smz+ZHPeqj8FBcO hvaaZjS7VRmFy/7JMM6i2GuIcGUWbwdKJilsMoYlD5OqE0HYV0Or9WXMYC0VUfzdCvX4 66mw== X-Gm-Message-State: ALQs6tB9eeLIi/FEScQIRme68s0wYb4ChLXFdYxTFE7UN1wBSpzL5kHr gUhBpEPlh0DoVjXh6jAWiwc= X-Received: by 2002:a6b:264d:: with SMTP id m74-v6mr42009029iom.154.1525746742146; Mon, 07 May 2018 19:32:22 -0700 (PDT) Received: from localhost.localdomain ([2605:a000:1316:4462:d951:8657:56b7:4002]) by smtp.googlemail.com with ESMTPSA id l22-v6sm4947954ita.8.2018.05.07.19.32.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 May 2018 19:32:21 -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 v4 09/13] ALSA: hda/ca0132: add the ability to set src_id on scp commands Date: Mon, 7 May 2018 22:31:17 -0400 Message-Id: <1525746683-18535-10-git-send-email-conmanx360@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525746683-18535-1-git-send-email-conmanx360@gmail.com> References: <1525746683-18535-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