From patchwork Wed Aug 2 17:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alper Nebi Yasak X-Patchwork-Id: 130121 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp690084vqx; Wed, 2 Aug 2023 12:52:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHS/6mYPO6Pe2SOc9ayopCPr2CUZ+qDxTSprOhjeRMbRc3/beAQZUV60gnsIlk8tmuilu8Q X-Received: by 2002:a17:907:75f6:b0:99c:6312:73ca with SMTP id jz22-20020a17090775f600b0099c631273camr99630ejc.71.1691005963204; Wed, 02 Aug 2023 12:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691005963; cv=none; d=google.com; s=arc-20160816; b=Lcn5gLEsfPHrZjfzBJgkC7wHUawQl7Qd3PNeTPOdDzqiAXvS6M9i+NTrUuSv6itsz7 JrxzYouS61t9aDNwuKohObcydPKt9H0vDCar8BJ/JwnKz6uwdF0guLjLOIxj7jOkUUB2 H4dFaAhtwCeOEc0zRjZ1URxB7C8Su3ZXwMUQpioHMWTF+A1UQOuI0cqfNKEn/CNYtF9m 5sug/OLtFPB+HVKnur6OzzMNgqtYXFHzxUUqX2S7L+Ars/vXireIfeKkwuiRht8P7Vgq 8io4fU+3Zei/IvZosb/Rd3GBRdRg3lXVVgNvcKDMxXXxNkf3R2tuchoWeSPu0RvyyWbv B4PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Z5e55/3niGxnTXERcmKYSB94dQwx71jJXMxMhyp26po=; fh=GUNhzEJfka7aU6InG/mqeUgtNKAejFmk0vy+CY7S+VM=; b=wvu4Gugye9zgjJFPiyZmvhJ4qmh+aO6PP/b2NdS5Z6Fn+63dGLZlN/xsuC7mpFFmNK 3TQS7+sNlSyTrCupjglX4fHaSx+ziP891KX7t/LQgjEuREItB02+/NdFp6l+JMV4xTf8 LxJOi3TFPLtrJM175/OPT955m3fgQEAVAOfx9T8wCsi+w4UTB8i46VffeaENrkFbJn2t IIOq9O0zh3VwM/FXqz9J3iz0luJgdhdRbwEkbyyzAllg7wxkJpI17XHLMCHRoYQWjRSo Kx3SK+ADr83BjJDJP02egaVfhJ/GUsy0yhFXHbr+NTSLDkqlglFLo2M+cccx6cZvmGq9 oVIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="RJ4Ld/iv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a170906078300b00992bbdebdbesi10145268ejc.785.2023.08.02.12.52.19; Wed, 02 Aug 2023 12:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="RJ4Ld/iv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234112AbjHBR6r (ORCPT + 99 others); Wed, 2 Aug 2023 13:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234129AbjHBR6H (ORCPT ); Wed, 2 Aug 2023 13:58:07 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE49170D for ; Wed, 2 Aug 2023 10:58:05 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3fe24dd8898so1324375e9.2 for ; Wed, 02 Aug 2023 10:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690999084; x=1691603884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z5e55/3niGxnTXERcmKYSB94dQwx71jJXMxMhyp26po=; b=RJ4Ld/ivmitOHIy6lTXMkEVG49CIs5bqeUEU0wDNDAPlLud4dF2xxgEXUSBvixy2mf UslIRyJGR5uGBgM3lFWPetavx6dTJZSYep4mSfril2gJvVWWCzK31xYK+sKaUnCxdgCj jwvspYMiCmFB96tmFahpDx9lBdpckAWCEBDmDpYTOea6N3KAiaa5CPg/iHqQOCQ3OpkQ WW5VI3oDYHeNjvv2XgkkY6FG7tqkphk7HvUQfMofDp+tiC5ZilzPifOY20Xp8oGrTXCv 2InKyYQ0LsfPa0vOisXg+/5DA+xQUIzSRtjW1IYmHgsCPDangDcbHMVHhVVpAgzJDV9Z q3tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690999084; x=1691603884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z5e55/3niGxnTXERcmKYSB94dQwx71jJXMxMhyp26po=; b=lR/NXcaySkS5f9UJTSDwQmPK5VMr7dUHRQT3IO9gS7s9nxHVUvIMMHAL8+SHT8zN2B delV/3QdcLabx+IAdi8+G1yHB5mBqwI3IswnyU5NpS+F9m+h8baDVStzbyEhxGjZFIRy 6TPDX+gBZZRRQhjmvXWjt7UGpWah/oDZFkTmahasa6iDVtNwUL4UVHloiRgxtU1hI2ri p5cv/wfWwFmKiR+IsxV1s9bT4tKWsmF8YBhbuQf1PNv9qFHK9fbubARejH1JDR369ScI kiG9GFdEmZmCYSRw79tJJWL7vFxX07+uLkf87ZscdsGiJ0fnsUAc9yQJFNSaP4aPcPvD qZiA== X-Gm-Message-State: ABy/qLZ4KEjNDu+fiaufr7zQEPlb2l6vaBIgv6UO34w4RPT4aAKmYEM4 YGJpY2EB6fAGkjt914DZEzs= X-Received: by 2002:a05:600c:2210:b0:3fe:ad4:27b1 with SMTP id z16-20020a05600c221000b003fe0ad427b1mr5437497wml.28.1690999084261; Wed, 02 Aug 2023 10:58:04 -0700 (PDT) Received: from ALPER-PC.. ([178.233.24.1]) by smtp.gmail.com with ESMTPSA id l23-20020a7bc457000000b003fe20db88ebsm2192439wmi.31.2023.08.02.10.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 10:58:03 -0700 (PDT) From: Alper Nebi Yasak To: alsa-devel@alsa-project.org Cc: Cezary Rojewski , Alper Nebi Yasak , Mark Brown , Liam Girdwood , Takashi Iwai , AngeloGioacchino Del Regno , Jaroslav Kysela , linux-kernel@vger.kernel.org, Akihiko Odaki , Pierre-Louis Bossart , Matthias Brugger , =?utf-8?q?N=C3=ADcolas_F_=2E_R_?= =?utf-8?q?=2E_A_=2E_Prado?= Subject: [PATCH 05/27] ASoC: Intel: avs: da7219: Map missing jack kcontrols Date: Wed, 2 Aug 2023 20:57:15 +0300 Message-Id: <20230802175737.263412-6-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230802175737.263412-1-alpernebiyasak@gmail.com> References: <20230802175737.263412-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773148268744742457 X-GMAIL-MSGID: 1773148268744742457 This driver does not properly map jack pins to kcontrols that PulseAudio and PipeWire need to handle jack detection events. The DA7219 codec used here can detect Headphones, Headset Mic and Line Out connections. Expose each to userspace as kcontrols and add the necessary widgets. Signed-off-by: Alper Nebi Yasak --- I'm not sure the use of devm_kmemdup is necessary here, but it's what avs/boards/nau8825.c does, I copied from that. Is it just to sidestep the "const" modifier on snd_soc_jack_pin? Also see a similar construct in nt8625.c (already in linux-next): https://lore.kernel.org/all/20230629112449.1755928-8-cezary.rojewski@intel.com/ sound/soc/intel/avs/boards/da7219.c | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/avs/boards/da7219.c b/sound/soc/intel/avs/boards/da7219.c index 964a763732ab..85014d98f7e8 100644 --- a/sound/soc/intel/avs/boards/da7219.c +++ b/sound/soc/intel/avs/boards/da7219.c @@ -22,6 +22,7 @@ static const struct snd_kcontrol_new card_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone Jack"), SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Line Out"), }; static int platform_clock_control(struct snd_soc_dapm_widget *w, @@ -55,6 +56,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, static const struct snd_soc_dapm_widget card_widgets[] = { SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_LINE("Line Out", NULL), SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, platform_clock_control, SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU), }; @@ -68,6 +70,22 @@ static const struct snd_soc_dapm_route card_base_routes[] = { { "Headphone Jack", NULL, "Platform Clock" }, { "Headset Mic", NULL, "Platform Clock" }, + { "Line Out", NULL, "Platform Clock" }, +}; + +static const struct snd_soc_jack_pin card_headset_pins[] = { + { + .pin = "Headphone Jack", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, + { + .pin = "Line Out", + .mask = SND_JACK_LINEOUT, + }, }; static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime) @@ -75,7 +93,9 @@ static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime) struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(runtime, 0); struct snd_soc_component *component = codec_dai->component; struct snd_soc_card *card = runtime->card; + struct snd_soc_jack_pin *pins; struct snd_soc_jack *jack; + int num_pins; int clk_freq; int ret; @@ -91,14 +111,20 @@ static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime) return ret; } + num_pins = ARRAY_SIZE(card_headset_pins); + pins = devm_kmemdup(card->dev, card_headset_pins, sizeof(*pins) * num_pins, GFP_KERNEL); + if (!pins) + return -ENOMEM; + /* * Headset buttons map to the google Reference headset. * These can be configured by userspace. */ - ret = snd_soc_card_jack_new(card, "Headset Jack", - SND_JACK_HEADSET | SND_JACK_BTN_0 | - SND_JACK_BTN_1 | SND_JACK_BTN_2 | - SND_JACK_BTN_3 | SND_JACK_LINEOUT, jack); + ret = snd_soc_card_jack_new_pins(card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_BTN_0 | + SND_JACK_BTN_1 | SND_JACK_BTN_2 | + SND_JACK_BTN_3 | SND_JACK_LINEOUT, + jack, pins, num_pins); if (ret) { dev_err(card->dev, "Headset Jack creation failed: %d\n", ret); return ret;