Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp292639lqh; Thu, 28 Mar 2024 02:06:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLP/f5CKCTtlI6H47ulBXJ31mqv/ItSYpQphSAH85cVMmKzfsSiYwl/eSFMzXO03haAaLWXEFaFlKTy+6WmgeRYRKJAgzVrMszOAATSA== X-Google-Smtp-Source: AGHT+IE0V4PBQpdEVft+7Vcuq5NFJi/snD+l1a9Hpwy6+3Y+nt52gBfw1I2uF04eB1PdNZBqKcwR X-Received: by 2002:a17:902:ecd1:b0:1e0:297a:5321 with SMTP id a17-20020a170902ecd100b001e0297a5321mr2595588plh.44.1711616790342; Thu, 28 Mar 2024 02:06:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711616790; cv=pass; d=google.com; s=arc-20160816; b=vBelnqb84oXquiMEqFVrln0RYjSPS9yiyut70Q7VX9CFYaQyfd02RcB8NE71GgjQKt t1ETdW5+HKQ+1UpiN/76Tvh0fSsxCL8tGxbT+EM5bH8JtpXal0ISaHfh9zxNepaE76l1 DyY2vWmQnoBnmmgdvRZ3Jk+0jDJM1FHacco41rorRR/NVJNV4hJ1fxZAdqrx8l9jPSIl Qbwtt/rzB/zR7QX29LDiWqgbYUIA0m8SlFRyJx5HQ54Q87ba8XRB0MxMOmtcR6WLJan3 6EihCvoOpy589XBWEOUVJw/J5gwPmXrXZXjUEqQYP0eOWBHVuN54a1jdq98A9DsjaBiU HrzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ej5a9IQFoQqHvTI3GJWBtAiDj1LUxXCu6HCrPDjiH0A=; fh=O4AkdXn/HM9K33olYDHqnDlQ7vd/ruTiH2r1LtNQzL4=; b=YAxYFBFsU2OJHaWMHWAweQWImIE+VtoHKPeuKlbIN0C/Tg889AjVRFde622skUCLhb YMOn6L9R/lceS8FV9DJzsqOgTST4KsXW96gjArBNt2MPDWBJeDojdNoFlLvebxEhZPtv gRQk5RHrE9crKsQPnoKOSo44niqBbp8VomuEuj1/RYyDTwAelkXydpLaW9AtpsIPQIQ9 7OOL4HSeMtnk14iiLrPX8IZZLF6UHsriQkHkTRINUvt/ip3NCjrp4M1YG5yrgBQqFkxU 3CXQ2Q9m3r7h3SAt7tTXtX/AzFVORa0SUm0bRonwoyPDe3H3aFU1FTLYSRcxA2rMoJow cw5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=qLMtLBgU; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-122616-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122616-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9-20020a170902854900b001dddbe5ab7csi993451plo.640.2024.03.28.02.06.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 02:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122616-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@xff.cz header.s=mail header.b=qLMtLBgU; arc=pass (i=1 spf=pass spfdomain=xff.cz dkim=pass dkdomain=xff.cz dmarc=pass fromdomain=xff.cz); spf=pass (google.com: domain of linux-kernel+bounces-122616-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122616-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=xff.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2A5A5B26935 for ; Thu, 28 Mar 2024 08:54:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01B7C7BB1C; Thu, 28 Mar 2024 08:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b="qLMtLBgU" Received: from vps.xff.cz (vps.xff.cz [195.181.215.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 191A2651AB; Thu, 28 Mar 2024 08:52:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.181.215.36 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711615949; cv=none; b=dlXab0CJgUKJJgjMmDjsmLcOuAiLiEdnVk7TJrdzAYrVlFLP8hHAhb9TWAjt8+Cf5VEVuBZv6GhWA6iODgqfp6OL1caDCIl1iD4KhQd0MzKRHF7g80Ht6pY1PBo5DOLrhu7PgOv3nReGRIJSNQAEIChGjM+9FSGO5sTpR2JVEo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711615949; c=relaxed/simple; bh=dsKxujkndwuIXXBgJmltW299ZElFVf2kBrZ2ot/Sd3M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bBcPfmRw/wP+51uG/Em5whhD+vw9BFPJpnyqObuJ4RBFYDlOovh8jp9reBVahDHLha/o2nBxEiRUFx9NAyp5hh59ssapH60bzFllg3M3G91u560hVtMm2mjHD/6VjqEa02nR5nZVqOT15FNdKXTUSVS/OdrfxGw6FpOBiJ1Mcls= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz; spf=pass smtp.mailfrom=xff.cz; dkim=pass (1024-bit key) header.d=xff.cz header.i=@xff.cz header.b=qLMtLBgU; arc=none smtp.client-ip=195.181.215.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xff.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xff.cz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xff.cz; s=mail; t=1711615937; bh=dsKxujkndwuIXXBgJmltW299ZElFVf2kBrZ2ot/Sd3M=; h=Date:From:To:Cc:Subject:X-My-GPG-KeyId:References:From; b=qLMtLBgUyLgoz9elITROY3qv7nsVk9kkjyeA7hgjLP88rrbIKJo4w037UezGlX+4q qsLE6CCNy9EwLhvU2Mol0QwwTUzfkEEin6DGPlixWDqoYlK3sFxi6PXobZrVUMogrq FvL4AafmQLdbZ/NZyEyTFo9EqIT/0jYsOlxaHl+w= Date: Thu, 28 Mar 2024 09:52:17 +0100 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Jernej =?utf-8?Q?=C5=A0krabec?= Cc: linux-kernel@vger.kernel.org, kernel test robot , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Chen-Yu Tsai , Samuel Holland , Rob Herring , AngeloGioacchino Del Regno , Claudiu Beznea , Arnaud Ferraris , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , "moderated list:ARM/Allwinner sunXi SoC support" , "open list:ARM/Allwinner sunXi SoC support" Subject: Re: [PATCH] ASoC: sun8i-codec: Fix build with CONFIG_SND_JACK_INPUT_DEV disabled Message-ID: Mail-Followup-To: =?utf-8?Q?Ond=C5=99ej?= Jirman , Jernej =?utf-8?Q?=C5=A0krabec?= , linux-kernel@vger.kernel.org, kernel test robot , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Chen-Yu Tsai , Samuel Holland , Rob Herring , AngeloGioacchino Del Regno , Claudiu Beznea , Arnaud Ferraris , "open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , "moderated list:ARM/Allwinner sunXi SoC support" , "open list:ARM/Allwinner sunXi SoC support" X-My-GPG-KeyId: EBFBDDE11FB918D44D1F56C1F9F0A873BE9777ED References: <20240327080542.3649840-1-megi@xff.cz> <1785985.VLH7GnMWUR@jernej-laptop> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1785985.VLH7GnMWUR@jernej-laptop> Hello Jernej, On Wed, Mar 27, 2024 at 08:43:31PM +0100, Jernej Škrabec wrote: > Dne sreda, 27. marec 2024 ob 09:05:34 CET je Ondřej Jirman napisal(a): > > From: Ondrej Jirman > > > > When CONFIG_SND_JACK_INPUT_DEV is disabled, struct snd_jack doesn't > > have 'type' field. We can't rely on this field being always present, > > so store the jack_type in the codec driver itself. > > > > Signed-off-by: Ondrej Jirman > > Reported-by: kernel test robot > > Closes: https://lore.kernel.org/oe-kbuild-all/202403261243.kcXCPAYs-lkp@intel.com/ > > --- > > This is a followup for https://lore.kernel.org/lkml/2vhd45kylttgonosdcfn7ugwyy2vx56gijwf3ealz4tel65iqr@cs3kxrl6d2hh/ > > > > sound/soc/sunxi/sun8i-codec.c | 14 +++++++------- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c > > index 43795362fed0..b5dafb749c3f 100644 > > --- a/sound/soc/sunxi/sun8i-codec.c > > +++ b/sound/soc/sunxi/sun8i-codec.c > > @@ -232,6 +232,7 @@ struct sun8i_codec { > > struct delayed_work jack_work; > > int jack_irq; > > int jack_status; > > + int jack_type; > > Where is this variable set? Below I see just usage of its value. It's going to be set in probe function, once generic DT bindings for jack-type are figured out. This is mentioned in the v3 cover letter for https://lore.kernel.org/lkml/20240302140042.1990256-1-megi@xff.cz/ I plan on sending support for generic property mentioned here https://elixir.bootlin.com/linux/latest/source/sound/soc/soc-component.c#L288 but it may need several iterations, and fail to get merged for various reasons and I may need to fall back to vendor DT property, then. If you want to test/use the jack detection on some A64 board now, what's needed to enable this is to add: scodec->jack_type = SND_JACK_HEADSET | SUN8I_CODEC_BUTTONS; (or just SND_JACK_HEADPHONE, depednding on jack type) to probe function and add get_jack_type callback to sun8i_soc_component: static int sun8i_codec_component_get_jack_type(struct snd_soc_component *component) { struct sun8i_codec *scodec = snd_soc_component_get_drvdata(component); return scodec->jack_type; } Then detection will get enabled on A64 SoC based boards that use simple-audio-card. (if codec is in simple-audio-card,aux-devs) Simple card iterates through aux devices and adds jacks for the ones that return something from component's get_jack_type() callback: https://elixir.bootlin.com/linux/latest/source/sound/soc/generic/simple-card-utils.c#L822 kind regards, o. > Best regards, > Jernej > > > int jack_last_sample; > > ktime_t jack_hbias_ready; > > struct mutex jack_mutex; > > @@ -1352,7 +1353,6 @@ static void sun8i_codec_jack_work(struct work_struct *work) > > struct sun8i_codec *scodec = container_of(work, struct sun8i_codec, > > jack_work.work); > > unsigned int mdata; > > - int type_mask = scodec->jack->jack->type; > > int type; > > > > guard(mutex)(&scodec->jack_mutex); > > @@ -1363,7 +1363,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) > > > > scodec->jack_last_sample = -1; > > > > - if (type_mask & SND_JACK_MICROPHONE) { > > + if (scodec->jack_type & SND_JACK_MICROPHONE) { > > /* > > * If we were in disconnected state, we enable HBIAS and > > * wait 600ms before reading initial HDATA value. > > @@ -1376,7 +1376,7 @@ static void sun8i_codec_jack_work(struct work_struct *work) > > scodec->jack_status = SUN8I_JACK_STATUS_WAITING_HBIAS; > > } else { > > snd_soc_jack_report(scodec->jack, SND_JACK_HEADPHONE, > > - type_mask); > > + scodec->jack_type); > > scodec->jack_status = SUN8I_JACK_STATUS_CONNECTED; > > } > > } else if (scodec->jack_status == SUN8I_JACK_STATUS_WAITING_HBIAS) { > > @@ -1417,17 +1417,17 @@ static void sun8i_codec_jack_work(struct work_struct *work) > > if (type == SND_JACK_HEADPHONE) > > sun8i_codec_set_hmic_bias(scodec, false); > > > > - snd_soc_jack_report(scodec->jack, type, type_mask); > > + snd_soc_jack_report(scodec->jack, type, scodec->jack_type); > > scodec->jack_status = SUN8I_JACK_STATUS_CONNECTED; > > } else if (scodec->jack_status == SUN8I_JACK_STATUS_CONNECTED) { > > if (scodec->last_hmic_irq != SUN8I_HMIC_STS_JACK_OUT_IRQ_ST) > > return; > > > > scodec->jack_status = SUN8I_JACK_STATUS_DISCONNECTED; > > - if (type_mask & SND_JACK_MICROPHONE) > > + if (scodec->jack_type & SND_JACK_MICROPHONE) > > sun8i_codec_set_hmic_bias(scodec, false); > > > > - snd_soc_jack_report(scodec->jack, 0, type_mask); > > + snd_soc_jack_report(scodec->jack, 0, scodec->jack_type); > > } > > } > > > > @@ -1491,7 +1491,7 @@ static irqreturn_t sun8i_codec_jack_irq(int irq, void *dev_id) > > if (scodec->jack_last_sample >= 0 && > > scodec->jack_last_sample == value) > > snd_soc_jack_report(scodec->jack, type, > > - scodec->jack->jack->type); > > + scodec->jack_type); > > > > scodec->jack_last_sample = value; > > } > > > > > >