Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1543979rdb; Mon, 8 Jan 2024 02:39:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEk1Ic5QzYZujp6UOQIVELOcI7jDge3Ir9F4kvI5KYFdT9plHY/m4xHmgyqflIasuQKXafv X-Received: by 2002:a17:906:2743:b0:a28:d16d:5aab with SMTP id a3-20020a170906274300b00a28d16d5aabmr1132375ejd.157.1704710362979; Mon, 08 Jan 2024 02:39:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704710362; cv=none; d=google.com; s=arc-20160816; b=yOfmcM3900WjXvlUf6qbZkOuFLU4P82xg45mP/zJUnAOWub+mP7S1CFL8u65k1HD4Q kpgx7iMAS00+yeEIPsdvsn8PpWWjZ3GCFQnlL73KPa7dXvQoBv2EOVh2ZyICCaPIYo6R f8qsD94paQJg4vzdriSUQwBx5Kq0rCj71pBOeBLypVJuhk5binUsV7by1BpuRTKatk/W 8DJ05zzyhBdlYON3MJhe1garPz1VJLrSh9dFZnB6twkmgp/9+Q01lmtmJBdKE8+zty0Q TXuwtquZ6TL9fYvsTy4dJG+sAIrQ+sVnbUynLlqk1E2IYtWrhV2F+EIj8oLoONamc1st ayJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-language:thread-index:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:subject:cc:to:from; bh=sQBvbKP/UBt9JV8GbzVqu+fVRUUURwmn70UrfvcR7rg=; fh=wlOeyi/vXINWhzs/RevIByN3bxo+aFi7UPF5JXtlwQI=; b=JeQ1VTStFVyhSsn9cBcaRk0EH6Vdj9AHwScvuEz2GoPE7ua0fgZ/Mr91Tffy0BQctb B8hVYv4jj/itMc4aAE9h+NpE2z/uAdJmSBoiWCf81iUIfJss5zfx8qpdnh74aIC2vutD zvZgxDv00YdWgQcL5RAFoAx6b/BoOO2/bAcI2rZzIdpgkqtBGII+/gpS8npYMMhSJN1n dA0gpkcqUHQ4wstZ6S6KfYuJgnJZzXkSseTjmDixjT+paUcaHoDi+DDnbXVUvRZtxZQc Nd7GogPzY8tEHLanA4Ns5OuRPsz24UdBbNHxMBCQYzfplSV6v6RIes4HgguBPh/UZ7Jg l1yA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19340-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=senarytech.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u10-20020a170906c40a00b00a280c46d5afsi3089867ejz.697.2024.01.08.02.39.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 02:39:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19340-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19340-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=senarytech.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 813E21F22366 for ; Mon, 8 Jan 2024 10:39:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B2FA13FFC; Mon, 8 Jan 2024 10:39:14 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-m608.netease.com (mail-m608.netease.com [210.79.60.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EFEE13FF6; Mon, 8 Jan 2024 10:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=senarytech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=senarytech.com Received: from liubo (unknown [61.183.143.78]) by mail-m12756.qiye.163.com (Hmail) with ESMTPA id 8C244DC05F0; Mon, 8 Jan 2024 11:29:50 +0800 (CST) From: =?gb2312?B?wfWyqQ==?= To: "'Takashi Iwai'" Cc: , , , Subject: Re: [PATCH] ALSA: hda/conexant: Fix headset auto detect fail in cx8070 and SN6140 Date: Mon, 8 Jan 2024 11:29:51 +0800 Message-ID: <002401da41e2$f159f5f0$d40de1d0$@senarytech.com> 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="gb2312" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdpB4vBlAuC7K9/cRVGMODF0aT21Gg== Content-Language: zh-cn X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkaTksYVkwdGBhISB9KQkhOGVUTARMWGhIXJBQOD1 lXWRgSC1lBWU1KVUpDSFVKT0hVTENZV1kWGg8SFR0UWUFZT0tIVUpNT0lMTlVKS0tVSkJLS1kG X-HM-Tid: 0a8ce71e9649b223kuuu8c244dc05f0 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NC46Ghw4AzwdTTI2LzAsGiJJ QlZPCUlVSlVKTEtPTUNPTkJKTkxMVTMWGhIXVRkUVRcSDjsIHhUaCQIPHhgTVRgUFkVZV1kSC1lB WU1KVUpDSFVKT0hVTENZV1kIAVlBTElLTzcG hi Takashi Iwai, Thank you very much for your patient guidance. Below is the reply to the question, please kindly correct it, thanks. > +static void cx_fixup_headset_recog(struct hda_codec *codec) { > + unsigned int mic_persent; > + > + /* fix some headset type recognize fail issue, such as EDIFIER headset */ > + snd_hda_codec_write(codec, 0x1c, 0, 0x320, 0x010); > + snd_hda_codec_write(codec, 0x1c, 0, 0x3b0, 0xe10); > + snd_hda_codec_write(codec, 0x1c, 0, 0x4f0, 0x0eb); Please use the defined verbs in sound/hda_verbs.h. The arguments (0x320, 0x010) are (AC_VERB_SET_AMP_GAIN_MUTE, 0x2010) = etc. Re: (0x1c, 0x320) is not amp gain register, but vendor defined register = as rx control register. Use AC_VERB_SET_AMP_GAIN_MUTE will confused. It's similar to 0x4f0 and 0xca0. Also, it's still not clear what if other nodes are used for headphone = and mic pins -- or when either only headphone or only mic is present. A rare case, but we need to cover. Re: in cx8070 and sn6140, only 0x16 and 0x19 can be used together as headset. Other nodes can be used separately as headphones or = microphones, but not as headset,=20 so their configuration will not interfere with the type detection of headset. > + /* fix reboot headset type recognize fail issue */ > + mic_persent =3D snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0); > + if (mic_persent&0x80000000) A coding style problem. Similar issues seen in a few other places, too. Consult scripts/checkpatch.pl. Re: was & need space? I have checked with scripts/checkpatch.pl before submitting the patch and there are no warnings or errors. > +static void cx_process_headset_plugin(struct hda_codec *codec) { > + unsigned int val; > + unsigned int count =3D 0; > + > + /* Wait headset detect done. */ > + do { > + val =3D snd_hda_codec_read(codec, 0x1c, 0, 0xca0, 0x0); Use the verb: AC_VERB_GET_PROC_COEF, 0xa000. At best, define the COEF values 0xa000 and 0xb000, and the corresponding value bits, too. Re: (0x1c, 0xca0) is not COEF register, but vendor defined register as jacksense register. > +static void cx_update_headset_mic_vref(struct hda_codec *codec,=20 > +unsigned int res) { > + unsigned int phone_present, mic_persent, phone_tag, mic_tag; > + struct conexant_spec *spec =3D codec->spec; > + > + /* In cx8070 and sn6140, headset is fixed to use node 16 and node 19. Is it really guaranteed? IMO, we should check the pin configs = beforehand at the parsing time. Re: in cx8070 and sn6140, only 0x16 and 0x19 can be used together as headset. The node 16 can only be config to headphone or disable, The node 19 can only be config to microphone or disable. Only node 16 = and node 19 both enable, the patch will process. Best Regards Bo Liu =A1=A1 -----=D3=CA=BC=FE=D4=AD=BC=FE----- =B7=A2=BC=FE=C8=CB: Takashi Iwai =20 =B7=A2=CB=CD=CA=B1=BC=E4: 2024=C4=EA1=D4=C26=C8=D5 1:02 =CA=D5=BC=FE=C8=CB: bo liu =B3=AD=CB=CD: perex@perex.cz; tiwai@suse.com; = linux-sound@vger.kernel.org; linux-kernel@vger.kernel.org =D6=F7=CC=E2: Re: [PATCH] ALSA: hda/conexant: Fix headset auto detect = fail in cx8070 and SN6140 On Thu, 04 Jan 2024 12:10:44 +0100, bo liu wrote: >=20 > When OMTP headset plugin the headset jack of CX8070 and SN6160 sound=20 > cards, the headset type detection circuit will recognize the headset = type as CTIA. > At this point, plugout and plugin the headset will get the correct=20 > headset type as OMTP. > The reason for the failure of headset type recognition is that the=20 > sound card creation will enable the VREF voltage of the headset mic,=20 > which interferes with the headset type automatic detection circuit.=20 > Plugout and plugin the headset will restart the headset detection and=20 > get the correct headset type. > The patch is disable the VREF voltage when the headset is not present, = > and will enable the VREF voltage when the headset is present. >=20 > Signed-off-by: bo liu Please put the revision number to the subject prefix, i.e. "Subject: [PATCH v3] ALSA: hda/conexant: ...." > +static void cx_fixup_headset_recog(struct hda_codec *codec) { > + unsigned int mic_persent; > + > + /* fix some headset type recognize fail issue, such as EDIFIER headset */ > + snd_hda_codec_write(codec, 0x1c, 0, 0x320, 0x010); > + snd_hda_codec_write(codec, 0x1c, 0, 0x3b0, 0xe10); > + snd_hda_codec_write(codec, 0x1c, 0, 0x4f0, 0x0eb); Please use the defined verbs in sound/hda_verbs.h. The arguments (0x320, 0x010) are (AC_VERB_SET_AMP_GAIN_MUTE, 0x2010) = etc. Also, it's still not clear what if other nodes are used for headphone = and mic pins -- or when either only headphone or only mic is present. A rare case, but we need to cover. > + /* fix reboot headset type recognize fail issue */ > + mic_persent =3D snd_hda_codec_read(codec, 0x19, 0, AC_VERB_GET_PIN_SENSE, 0x0); > + if (mic_persent&0x80000000) A coding style problem. Similar issues seen in a few other places, too. Consult scripts/checkpatch.pl. > +enum { > + CX_HEADSET_NOPRESENT =3D 0, > + CX_HEADSET_PARTPRESENT, > + CX_HEADSET_ALLPRESENT, > +}; This should be defined earlier. You can use the enum type for spec->headset_present_flag, too. > +static void cx_process_headset_plugin(struct hda_codec *codec) { > + unsigned int val; > + unsigned int count =3D 0; > + > + /* Wait headset detect done. */ > + do { > + val =3D snd_hda_codec_read(codec, 0x1c, 0, 0xca0, 0x0); Use the verb: AC_VERB_GET_PROC_COEF, 0xa000. At best, define the COEF values 0xa000 and 0xb000, and the corresponding value bits, too. > +static void cx_update_headset_mic_vref(struct hda_codec *codec,=20 > +unsigned int res) { > + unsigned int phone_present, mic_persent, phone_tag, mic_tag; > + struct conexant_spec *spec =3D codec->spec; > + > + /* In cx8070 and sn6140, headset is fixed to use node 16 and node 19. Is it really guaranteed? IMO, we should check the pin configs = beforehand at the parsing time. thanks, Takashi