Received: by 10.192.165.148 with SMTP id m20csp4564301imm; Tue, 8 May 2018 10:23:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqel7Ygd5/8oPqv6RAkpR133LeaCbaV2YxA/NPBPS1yWSrtGsebUEBrzsnIYeTPdvX+NHeb X-Received: by 2002:a65:5645:: with SMTP id m5-v6mr2804125pgs.175.1525800201977; Tue, 08 May 2018 10:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525800201; cv=none; d=google.com; s=arc-20160816; b=A09seBAt6geQ+1XTpfUoL+y36Vp9jaHKYpnGWouoOLPqoheh+VNpAVJ4XrbjQmN7bQ CAxaw8NizAYaw2wFHWlTHIcUQe9olH/KK0ALS5AE711HlMkEN6l7ZmF1hmuulMUpnKAA 3XWABUNKmyIdVG9yKY6w5q0dcuwJ/rYGmaO1pU4RE8qrR0zambWFtHu8NCmZb7OwCDdP gxQTNPxLojKjb3Bk3SZmKGovDp9PE2d4iXYdSf81jKD8KtW8u4eOqtvJG6DCUjaFVffs HwlyHPmKfP5yaE5/RuIfx0/v4hlf7vWIYdPBIDlotu6usEaysJKkJqn9w3tRNPZ7pApA VSSA== 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=bJpOmaATkRaW3vf6NpfbapKuWM3ruwW8nmQWPFaWUOA=; b=bwgmVmsI7V3wGQyR5t65eAIokfRPSOvVzyychVwCrXvfwnSoafayjJsLQFMu5fkB5c /3IPgKTkQgnjcRZq048QWp1vJ38HsMxXJOkZgAof+ix8eXxNmleCIGXDhKd1cwjFxfrK qqBV7l06KmntKdEIq8gOW0e8ACKfSQ1X5bfx+OSu5qO2rM7xsKXToaUfo5a58NvRmUp1 R1JlMmogD7nz+Vtf6ypee5k++VG+RaKZHqveNm4FpiCDmX6a7Gg+PRDXn1uOqF72hZ5M Myvmtn0YBpNNE4ecp33piaoQCNriBgz/crh1VjWcgQKWPU++lI2LSCJQRX5P5qepPhmx Aouw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=hJDo3aWz; 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 u3si26485036pfj.58.2018.05.08.10.23.07; Tue, 08 May 2018 10:23:21 -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=hJDo3aWz; 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 S932821AbeEHRVZ (ORCPT + 99 others); Tue, 8 May 2018 13:21:25 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:36017 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932675AbeEHRVM (ORCPT ); Tue, 8 May 2018 13:21:12 -0400 Received: by mail-io0-f193.google.com with SMTP id d73-v6so39355959iog.3 for ; Tue, 08 May 2018 10:21:11 -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=bJpOmaATkRaW3vf6NpfbapKuWM3ruwW8nmQWPFaWUOA=; b=hJDo3aWzQaGV8zUlmGyDwz2sdgBM3SM8FvrDHnYrY436mQgU2UL1DrmuoomshI9HjC ORQy0UEZFlRVo56NnjKseQvuWd0GyPFqGElZIHj161NY3l7LCtrDiwrc5zJdop6PDzkN NRPoRVeernpUQ5tQP0ptfuBxWD8CYAdTNFnu0o4/QnuIN9N8ujLU3EQh2S9n9yNHlPcV imF6RbSF4I2xoAiwqH0svPcygOmyCtLWNBQE69vfyuZ92DyxwBwCYzpZk77NoDf3++Pr nKk+5RXV+qX8vUsovQW1MXeYINZVdFbT80MnuDnWXOSoYhRDFbxa3RBA4eELq3MKsjxl 6gdQ== 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=bJpOmaATkRaW3vf6NpfbapKuWM3ruwW8nmQWPFaWUOA=; b=oYqoYVxwsAWbhmcNNeqe40LYsCrqTn/q9GL6pybuadBFNW0gPS7+UzGBUxK3bOdjHM EA0L2QPNs9gEH1vgRVOpDyavpKUG0Pk4Zlax+9mzPxOjpVYWFQTjK/g7n/eSp2QKNsJi QAdjgUh0K5xbc9YiK+0iKTwE1jl1GM2O7GOw9zYU0C2VV+Xy7fsAFSqbn2bVbwQWm5wq ex8O2ho7m2gmzvsY88xEi56xz1OWM/qi90wD2/K+xR9zksHM36FKVcdDn049nc4Txth+ 1D7rYggM9+MO1BWWH2TdreHqUFI1qlbjoCnf6AH/VtoO16yvbzbmSoj91vvucnidPhhf +odg== X-Gm-Message-State: ALKqPwd1DBhY7tCqVHnduw3Zh33JRdmUYLljWkHAZikB+93z1yaZY79f 8iLV5J0BA3fdh53MYyvtMIY= X-Received: by 2002:a6b:6d09:: with SMTP id a9-v6mr4032626iod.305.1525800071558; Tue, 08 May 2018 10:21:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 May 2018 10:21:11 -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 12/13] ALSA: hda/ca0132: add ca0132_alt_set_vipsource Date: Tue, 8 May 2018 13:20:12 -0400 Message-Id: <1525800015-2920-13-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 Add function to set vipsource on cards that use_alt_controls. Different sequence. Also, add cvoice_switch_set at end of ca0132_select_in so that when switching between inputs cvoice state is maintained. Signed-off-by: Connor McAdams --- sound/pci/hda/patch_ca0132.c | 74 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 311df61..9ab96ae 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -3934,6 +3934,9 @@ static void ca0132_unsol_hp_delayed(struct work_struct *work) static void ca0132_set_dmic(struct hda_codec *codec, int enable); static int ca0132_mic_boost_set(struct hda_codec *codec, long val); static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val); +static void resume_mic1(struct hda_codec *codec, unsigned int oldval); +static int stop_mic1(struct hda_codec *codec); +static int ca0132_cvoice_switch_set(struct hda_codec *codec); /* * Select the active VIP source @@ -3976,6 +3979,71 @@ static int ca0132_set_vipsource(struct hda_codec *codec, int val) return 1; } +static int ca0132_alt_set_vipsource(struct hda_codec *codec, int val) +{ + struct ca0132_spec *spec = codec->spec; + unsigned int tmp; + + if (spec->dsp_state != DSP_DOWNLOADED) + return 0; + + codec_dbg(codec, "%s\n", __func__); + + chipio_set_stream_control(codec, 0x03, 0); + chipio_set_stream_control(codec, 0x04, 0); + + /* if CrystalVoice is off, vipsource should be 0 */ + if (!spec->effects_switch[CRYSTAL_VOICE - EFFECT_START_NID] || + (val == 0) || spec->in_enum_val == REAR_LINE_IN) { + codec_dbg(codec, "%s: off.", __func__); + chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, 0); + + tmp = FLOAT_ZERO; + dspio_set_uint_param(codec, 0x80, 0x05, tmp); + + chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_96_000); + chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_96_000); + if (spec->quirk == QUIRK_R3DI) + chipio_set_conn_rate(codec, 0x0F, SR_96_000); + + + if (spec->in_enum_val == REAR_LINE_IN) + tmp = FLOAT_ZERO; + else { + if (spec->quirk == QUIRK_SBZ) + tmp = FLOAT_THREE; + else + tmp = FLOAT_ONE; + } + + dspio_set_uint_param(codec, 0x80, 0x00, tmp); + + } else { + codec_dbg(codec, "%s: on.", __func__); + chipio_set_conn_rate(codec, MEM_CONNID_MICIN1, SR_16_000); + chipio_set_conn_rate(codec, MEM_CONNID_MICOUT1, SR_16_000); + if (spec->quirk == QUIRK_R3DI) + chipio_set_conn_rate(codec, 0x0F, SR_16_000); + + if (spec->effects_switch[VOICE_FOCUS - EFFECT_START_NID]) + tmp = FLOAT_TWO; + else + tmp = FLOAT_ONE; + dspio_set_uint_param(codec, 0x80, 0x00, tmp); + + tmp = FLOAT_ONE; + dspio_set_uint_param(codec, 0x80, 0x05, tmp); + + msleep(20); + chipio_set_control_param(codec, CONTROL_PARAM_VIP_SOURCE, val); + } + + chipio_set_stream_control(codec, 0x03, 1); + chipio_set_stream_control(codec, 0x04, 1); + + return 1; +} + /* * Select the active microphone. * If autodetect is enabled, mic will be selected based on jack detection. @@ -4138,6 +4206,7 @@ static int ca0132_alt_select_in(struct hda_codec *codec) } break; } + ca0132_cvoice_switch_set(codec); snd_hda_power_down_pm(codec); return 0; @@ -4351,7 +4420,10 @@ static int ca0132_cvoice_switch_set(struct hda_codec *codec) /* set correct vipsource */ oldval = stop_mic1(codec); - ret |= ca0132_set_vipsource(codec, 1); + if (spec->use_alt_functions) + ret |= ca0132_alt_set_vipsource(codec, 1); + else + ret |= ca0132_set_vipsource(codec, 1); resume_mic1(codec, oldval); return ret; } -- 2.7.4