From patchwork Wed Dec 27 07:10:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bo liu X-Patchwork-Id: 183463 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1384901dyb; Wed, 27 Dec 2023 03:59:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFg1MIF7e0J+W4lK78e2go087VO0iZyD9A4+lSdoZjczxAKm3D80Z+BXgHawONvqYyemyfq X-Received: by 2002:a17:90a:b38f:b0:28b:512a:858b with SMTP id e15-20020a17090ab38f00b0028b512a858bmr10177695pjr.9.1703678387195; Wed, 27 Dec 2023 03:59:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703678387; cv=none; d=google.com; s=arc-20160816; b=pPHCPJX8avacdNN9PWVvDX4edho5KfgeK674OmZmqIRqOtZWvXwbpA9aN6Xx/639ex Vu5/pQrLTwbGJMAaQ982V7AwaSJMnkrYAxGNGn5CKKTDfaKwPwfx1KaVJqR9I9dEVb0L Yl3XtYpXtMYpniCvTU/cf29SbMty5ByGUKoMGksJBnoMBcTqEKyxsd3Lqw67ylXI7MBy NDpr4dwd61c/lGercVy6fSIVcXelJFtmgWPNgvgTYSNs8MT1nKTFDBKc+YYVDq3DfP6A ZFi/wYHamMEjMTYgkUnXKNTB4fswzw+ANT7PLfVH4m7c8sXxe+GfXw4/EZXO6XXnNb1h c31Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=5Xm9MoNIlhWBv8vU0RwpX/cH5M5u3g7+XuHw9w6EVHY=; fh=YHDWZyeNx+1qLcLwiupLhFJjc+OL9V81fofGon++hts=; b=e1WXOMDZqDk9PkCt/oJn8yFkS8nFJU7FYFHYctNIDGgy4wJY25A1RtRz/6sFh7y1Bj /J0JlfuI++W3mAeBAO6x6tgpVMuSicGxeOn5BFQPNGG4NIccKDIFYCaFDgbrJc2t5nWH UKJpeSPAlMEN/NUGn6A7otZX4dGsBhH+CKHiyAZTLCa/leon6y9Mc7AftfTxuZfQIu0M 2Wd/8U1fdkOhOmihmWeofCP57SUoZ9V8o1cWHmI7ydGABsD9p5S0hVjxzgtZdYhlWUHb OQ/q3ncnHZU38HJA8GQVy66lqkIm2jN2KNRgWH1dSg3CAb/e9ykeL6D9sQKFsdDE0Pqs QePA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12002-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12002-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=senarytech.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id kk9-20020a17090b4a0900b0028be98b7b21si11365168pjb.145.2023.12.27.03.59.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 03:59:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12002-ouuuleilei=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; spf=pass (google.com: domain of linux-kernel+bounces-12002-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12002-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6B248B20CC9 for ; Wed, 27 Dec 2023 11:59:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C029744C61; Wed, 27 Dec 2023 11:59:11 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-m49208.qiye.163.com (mail-m49208.qiye.163.com [45.254.49.208]) (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 8CA9F446B3; Wed, 27 Dec 2023 11:59: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 book-ThinkStation-P328.. (unknown [61.183.143.78]) by mail-m12756.qiye.163.com (Hmail) with ESMTPA id 459A0DC0636; Wed, 27 Dec 2023 15:10:20 +0800 (CST) From: bo liu To: perex@perex.cz, tiwai@suse.com Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, bo liu Subject: [PATCH 2/3] Fix headset auto detect fail in cx8070 and SN6140 Date: Wed, 27 Dec 2023 15:10:07 +0800 Message-Id: <20231227071008.13665-2-bo.liu@senarytech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231227071008.13665-1-bo.liu@senarytech.com> References: <20231227071008.13665-1-bo.liu@senarytech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkZQ0gdVkhMTBoaSUNJSE5MQ1UTARMWGhIXJBQOD1 lXWRgSC1lBWU1KVUpDSFVKT0hVTENZV1kWGg8SFR0UWUFZT0tIVUpNT0lMTlVKS0tVSkJLS1kG X-HM-Tid: 0a8caa1c2524b223kuuu459a0dc0636 X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NTo6Dio5MDwrAQkJODg#HAxL IyJPFAlVSlVKTEtITU1KS0lKSU9JVTMWGhIXVRkUVRcSDjsIHhUaCQIPHhgTVRgUFkVZV1kSC1lB WU1KVUpDSFVKT0hVTENZV1kIAVlBT0lOSDcG X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786418593140250565 X-GMAIL-MSGID: 1786436268272666406 CX8070 and SN6140 will get wrong headset type when use OMTP headset, then the headset mic will not work. Signed-off-by: bo liu --- sound/pci/hda/patch_conexant.c | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index 2d58595bfbdd..9ebc0709a202 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c @@ -184,11 +184,10 @@ static int cx_auto_init(struct hda_codec *codec) snd_hda_codec_write(codec, 0x1c, 0, 0x4f0, 0x0eb); /* fix reboot headset recognize fail issue */ mic_persent = snd_hda_codec_read(codec, 0x19, 0, 0xf09, 0x0); - if (mic_persent&0x80000000) { + if (mic_persent&0x80000000) snd_hda_codec_write(codec, 0x19, 0, 0x707, 0x24); - } else { + else snd_hda_codec_write(codec, 0x19, 0, 0x707, 0x20); - } break; } @@ -209,46 +208,46 @@ static void cx_auto_free(struct hda_codec *codec) cx_auto_shutdown(codec); snd_hda_gen_free(codec); } - + static int headset_present_flag; static void cx_jack_unsol_event(struct hda_codec *codec, unsigned int res) { - unsigned int val,phone_present,mic_persent,phone_tag,mic_tag; + unsigned int val, phone_present, mic_persent,phone_tag, mic_tag; unsigned int count=0; - + switch (codec->core.vendor_id) { case 0x14f11f86: case 0x14f11f87: /* check hp&mic tag to process headset pulgin&plugout */ phone_tag = snd_hda_codec_read(codec, 0x16, 0, 0xf08, 0x0); mic_tag = snd_hda_codec_read(codec, 0x19, 0, 0xf08, 0x0); - if((phone_tag&(res>>26)) || (mic_tag&(res>>26))) { - //msleep(600); + if ((phone_tag&(res>>26)) || (mic_tag&(res>>26))) { phone_present = snd_hda_codec_read(codec, 0x16, 0, 0xf09, 0x0); - if(!(phone_present&0x80000000)) {/* headphone plugout */ + if (!(phone_present&0x80000000)) {/* headphone plugout */ headset_present_flag = 0; snd_hda_codec_write(codec, 0x19, 0, 0x707, 0x20); break; } if (headset_present_flag == 0) { headset_present_flag = 1; - } else if(headset_present_flag == 1) { + } else if (headset_present_flag == 1) { mic_persent = snd_hda_codec_read(codec, 0x19, 0, 0xf09, 0x0); - if ((phone_present&0x80000000)&&(mic_persent&0x80000000)) {/* headset is present */ + /* headset is present */ + if ((phone_present&0x80000000) && (mic_persent&0x80000000)) { /* wait headset detect done */ do { - val = snd_hda_codec_read(codec, 0x1c, 0, 0xca0, 0x0); - if(val&0x080) { + val = snd_hda_codec_read(codec, 0x1c, + 0, 0xca0, 0x0); + if (val&0x080) break; - } - msleep(10); + msleep(20); count += 1; - } while(count > 5); + } while (count > 3); val = snd_hda_codec_read(codec, 0x1c, 0, 0xcb0, 0x0); - if(val&0x800) { + if (val&0x800) { codec_dbg(codec, "headset plugin, type is CTIA\n"); snd_hda_codec_write(codec, 0x19, 0, 0x707, 0x24); - } else if(val&0x400) { + } else if (val&0x400) { codec_dbg(codec, "headset plugin, type is OMTP\n"); snd_hda_codec_write(codec, 0x19, 0, 0x707, 0x24); } else {