Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp7028647pxv; Fri, 30 Jul 2021 08:21:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUaspl59+Slu4S4nL6T26S8fTuoMej3eyqHa2K0hPheKCP5eRp6CoPYEAtyhin8WixFJSM X-Received: by 2002:aa7:cb86:: with SMTP id r6mr3545259edt.181.1627658488756; Fri, 30 Jul 2021 08:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627658488; cv=none; d=google.com; s=arc-20160816; b=F5mIsU1l/IW7cLqGYZPdPgX9fdiM/gCBEtQ4IClwDU3vGgAU+QikQ84gslL3yLD+XM EUG/U4dYCOgcmg7yFCUwwx/MeZ96yyb466XSdsxq7j8GBNgoBAObQDaqmgzVUbQhMLPq +/tVmEEu1Bw4vo0yhZpv6EUc9zt7rO0lTriD/qeIFXbTVbH2T/xsQ7vtVSwVMq1kKEQU zspLI7E9lqy/3fIIJdq6vu2O65P9ddUmfjcyyQiXlTDxF742JAUQ8kZ9IfbdN9gw8dwc 6GDryBkifcepEx44MGUTFk9wS9cF/UCXgfW6p0Fz/TajD2H5yYb10g7HZnVSx+GPazIg bLwQ== 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=uJiDGgAZuNVUz1HRRzwVIuea32lseF95YXkiOXKc9ug=; b=TQ8eB9F7pbRutyWbwd5BBPxmH8TCicpByQg3hFvssQNnwBLc4HWfJk9cKOo/++shx0 Fe1xDTY37D4neNSO5p/OWtu0fG8AjClWNHaQ02+os5c9dqdGVAanQr+wM8JvzYVhZec7 U8zR6lvGLVWI7niietI0gJ4w6dfTlENZDCzTgLYaxmosKU0S7Gt2PqTSEb+yrWpYrx4M XIcHXEL7yAnJT8rvJSKW8kH7ZDYb/9PBFt1hmHBPsR14B/zQQmy/cOpl5L7xrncf1Gkp 4QgK+2n4rjgngWG/Zoos2HEn+oDw/kXjiM59d2kB3mui/IVwphAiU2Hnf7lNrtsA+8l1 ZDUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=TSjBtv0F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si2054383edu.115.2021.07.30.08.21.06; Fri, 30 Jul 2021 08:21:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=TSjBtv0F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239710AbhG3PTi (ORCPT + 99 others); Fri, 30 Jul 2021 11:19:38 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:3250 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239559AbhG3PTc (ORCPT ); Fri, 30 Jul 2021 11:19:32 -0400 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 16UEL0dj003614; Fri, 30 Jul 2021 10:19:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=uJiDGgAZuNVUz1HRRzwVIuea32lseF95YXkiOXKc9ug=; b=TSjBtv0Fsl/3sNywHLpc1/2TPtW+wETG9ilyLexwPf7BM6lzdW7AFb7s7NmFm95S07cI 4YtOfDi6/ME09OYVH7zl0vpT0zMuUsFUmfPDc1i+bejc5K4kboXPyazdaELm8SK96ygm pQS1aIP5GuukAsVn4t3gsKDoR3/0f9yzNqrbnIO1FJ8nzLov2M+hkiHN04oMOIQBWQTZ SBvhD3lc18oaQ2RWoqLpEXAZr+dlThtGw7JjgqjBNxWSaVtzVKSWDK68J6MCjh+GjHVk edrOz8cKreHiMzJZYVPq4fc3xpDmHvzzSJx+KkRcnPAvjX2NmKhIpRFqiGGkX+cq2nCo lQ== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 3a41wd181n-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 30 Jul 2021 10:19:20 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Fri, 30 Jul 2021 16:19:11 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.4 via Frontend Transport; Fri, 30 Jul 2021 16:19:11 +0100 Received: from vitaly-Inspiron-5415.ad.cirrus.com (unknown [198.90.238.32]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 8FE46478; Fri, 30 Jul 2021 15:19:11 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai CC: , , , Stefan Binding Subject: [PATCH v3 20/27] ALSA: hda/cs8409: Add Support to disable jack type detection for CS42L42 Date: Fri, 30 Jul 2021 16:18:37 +0100 Message-ID: <20210730151844.7873-21-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210730151844.7873-1-vitalyr@opensource.cirrus.com> References: <20210730151844.7873-1-vitalyr@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: DTeWFsHqg1ET8z8txKButRkPOH-k6J7f X-Proofpoint-ORIG-GUID: DTeWFsHqg1ET8z8txKButRkPOH-k6J7f X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 impostorscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107300102 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Binding Some hardware configurations do not support jack type detection. Instead, for those configurations, only tip detection is supported. Signed-off-by: Stefan Binding Signed-off-by: Vitaly Rodionov --- Changes in v2: - No changes Changes in v3: - No changes sound/pci/hda/patch_cs8409-tables.c | 1 + sound/pci/hda/patch_cs8409.c | 72 ++++++++++++++++------------- sound/pci/hda/patch_cs8409.h | 1 + 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/sound/pci/hda/patch_cs8409-tables.c b/sound/pci/hda/patch_cs8409-tables.c index 117c70536ff0..be9feb84aaa2 100644 --- a/sound/pci/hda/patch_cs8409-tables.c +++ b/sound/pci/hda/patch_cs8409-tables.c @@ -246,6 +246,7 @@ struct sub_codec cs8409_cs42l42_codec = { .mic_jack_in = 0, .paged = 1, .suspended = 1, + .no_type_dect = 0, }; /****************************************************************************** diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index 8b048ff12eb7..10903bcc3fcd 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -546,6 +546,39 @@ static void cs42l42_run_jack_detect(struct sub_codec *cs42l42) usleep_range(10000, 25000); } +static int cs42l42_handle_tip_sense(struct sub_codec *cs42l42, unsigned int reg_ts_status) +{ + int status_changed = 0; + + /* TIP_SENSE INSERT/REMOVE */ + switch (reg_ts_status) { + case CS42L42_JACK_INSERTED: + if (!cs42l42->hp_jack_in) { + if (cs42l42->no_type_dect) { + status_changed = 1; + cs42l42->hp_jack_in = 1; + cs42l42->mic_jack_in = 0; + } else { + cs42l42_run_jack_detect(cs42l42); + } + } + break; + + case CS42L42_JACK_REMOVED: + if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) { + status_changed = 1; + cs42l42->hp_jack_in = 0; + cs42l42->mic_jack_in = 0; + } + break; + default: + /* jack in transition */ + break; + } + + return status_changed; +} + static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42) { int status_changed = 0; @@ -570,10 +603,13 @@ static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42) cs8409_i2c_write(cs42l42, 0x131b, 0xFF); type = ((reg_hs_status & CS42L42_HSTYPE_MASK) + 1); - /* CS42L42 reports optical jack as type 4 - * We don't handle optical jack - */ - if (type != 4) { + + if (cs42l42->no_type_dect) { + status_changed = cs42l42_handle_tip_sense(cs42l42, reg_ts_status); + } else if (type == 4) { + /* Type 4 not supported */ + status_changed = cs42l42_handle_tip_sense(cs42l42, CS42L42_JACK_REMOVED); + } else { if (!cs42l42->hp_jack_in) { status_changed = 1; cs42l42->hp_jack_in = 1; @@ -583,37 +619,11 @@ static int cs42l42_jack_unsol_event(struct sub_codec *cs42l42) status_changed = 1; cs42l42->mic_jack_in = 1; } - } else { - if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) { - status_changed = 1; - cs42l42->hp_jack_in = 0; - cs42l42->mic_jack_in = 0; - } } - /* Re-Enable Tip Sense Interrupt */ cs8409_i2c_write(cs42l42, 0x1320, 0xF3); - } else { - /* TIP_SENSE INSERT/REMOVE */ - switch (reg_ts_status) { - case CS42L42_JACK_INSERTED: - cs42l42_run_jack_detect(cs42l42); - break; - - case CS42L42_JACK_REMOVED: - if (cs42l42->hp_jack_in || cs42l42->mic_jack_in) { - status_changed = 1; - cs42l42->hp_jack_in = 0; - cs42l42->mic_jack_in = 0; - } - break; - - default: - /* jack in transition */ - status_changed = 0; - break; - } + status_changed = cs42l42_handle_tip_sense(cs42l42, reg_ts_status); } return status_changed; diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index 817df295d594..a105c3c9023d 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -285,6 +285,7 @@ struct sub_codec { unsigned int last_page; unsigned int hsbias_hiz; unsigned int full_scale_vol:1; + unsigned int no_type_dect:1; s8 vol[CS42L42_VOLUMES]; }; -- 2.25.1