Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5253579pxv; Wed, 28 Jul 2021 06:47:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSFk9nj7kpGHRy8k496L+5+regUuklrdkCJVOMaQD61KvuFNvHaAqC/q2C6T4ekRmC+gIp X-Received: by 2002:a92:c849:: with SMTP id b9mr20634619ilq.63.1627480036090; Wed, 28 Jul 2021 06:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627480036; cv=none; d=google.com; s=arc-20160816; b=JTwqi/uXLl/rahNtZGPuPNVTeqcORQjpMBbdAguTIJ+mbTCoKib0QGbbBcBaX3Twkk ew2eaLX+ZzEYyX6BoNukcIyy5qQAakWbk7KdQVXA7ZTfwxOYOg2tUuOoiYUoYpwX6EP9 SUmtLt/KCHSE9EQAE160WAXK3oGmNpHCwyKEqhTE78DaYneoYG0vi+Yka3A1OBjhlj4W ECCFIFqfSYRC07QvPvj2kOB7e5gqKENW75R09I45BdrSrTl/5zHY5CoWaVYyBtXrygeC ADMU34hyka7zuoK3tP0ub/mxclFbN/oYQ11KgT52Qh6Kp0r66syCxAVbwsLsGvHZCw0l WxTw== 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=YdllO4dOaVEcV4spblJnXSctk/p1jkPBosuasafeUk0=; b=FPsb6PD+FxJEB5axfxl78NhmNDQNF9YGUo+hzAxjYSQxuEyrpjwJ23UOz/xPWxdWfO r2PdEU8sorVudAm93PziIKQGyjzYDgL1PINSUg1PRwWegXsKDO7q/d1VBG6SE51/UqfK FMub1ZH12S0A5ol+UgMg/9UeSHDV4PcMtOs8f5oqEAbvIOmUsHwxshO+YopkfWRCElo7 t0/P1jiYxqwGMHR4B/txwaLO52UZnya8MtxUxRwey88217jcxQzH14vhM4QLiCbheyf5 E37DrzpW+4QRpkiJMegfVMoHdAnqo3OcU3NLw5sk5b+SK2ku1ApLsyEgY1rjHPtWeZEr q/Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=cmnmoIGH; 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 n26si6558610jam.80.2021.07.28.06.47.03; Wed, 28 Jul 2021 06:47:16 -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=cmnmoIGH; 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 S236776AbhG1NpM (ORCPT + 99 others); Wed, 28 Jul 2021 09:45:12 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:6474 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236495AbhG1Not (ORCPT ); Wed, 28 Jul 2021 09:44:49 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 16S5XUqo014335; Wed, 28 Jul 2021 08:44:35 -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=YdllO4dOaVEcV4spblJnXSctk/p1jkPBosuasafeUk0=; b=cmnmoIGHz09eBEXeRrWGh6XLI8tyY2J0DYBIHJXPTlglWh3sQ6XR2A01r7oPT2uDZJ7c V9Xt4Y+xX/P5JiMRxkJZpTpc7NJOhXJ1eStQfpThsNwU1iCfWYbC7WvB5EG2WkMyFplz eYBXgotr0NTaY5wArXtSW9FRLM+hRejwEfl/bq0USWruZ7u65aNp0Uz/EM44Qb/fN/3J NwA4VCNWx0FR7mnofr4+sUjnjfu0HYyPvboatVyrtGQOKwNj9WVd+m3vQoGGTWWjO5jN fx+VLypXmve2cztbNkrRDCismIf5sBzd0Tpfl7zJCUo0iSBegFrJbz30jA8SXS1URYBY pA== Received: from ediex02.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3a30q20fxa-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 28 Jul 2021 08:44:35 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 28 Jul 2021 14:44:34 +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; Wed, 28 Jul 2021 14:44:34 +0100 Received: from vitaly-Inspiron-5415.ad.cirrus.com (unknown [198.90.238.32]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 332EE46E; Wed, 28 Jul 2021 13:44:34 +0000 (UTC) From: Vitaly Rodionov To: Jaroslav Kysela , Takashi Iwai CC: , , , Lucas Tanure Subject: [PATCH v2 14/27] ALSA: hda/cs8409: Avoid setting the same I2C address for every access Date: Wed, 28 Jul 2021 14:43:55 +0100 Message-ID: <20210728134408.369396-15-vitalyr@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210728134408.369396-1-vitalyr@opensource.cirrus.com> References: <20210728134408.369396-1-vitalyr@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: dvLHFuyTpjtZeHLHgaoGObBWE5-mHP0t X-Proofpoint-GUID: dvLHFuyTpjtZeHLHgaoGObBWE5-mHP0t X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 adultscore=0 clxscore=1015 spamscore=0 mlxlogscore=996 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2107280077 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lucas Tanure Signed-off-by: Lucas Tanure Signed-off-by: Vitaly Rodionov Changes in v2: - No changes --- sound/pci/hda/patch_cs8409.c | 19 +++++++++++++++++-- sound/pci/hda/patch_cs8409.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_cs8409.c b/sound/pci/hda/patch_cs8409.c index fafc0f309e70..bd43c42d5c74 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -132,6 +132,21 @@ static int cs8409_i2c_wait_complete(struct hda_codec *codec) return -1; } +/** + * cs8409_set_i2c_dev_addr - Set i2c address for transaction + * @codec: the codec instance + * @addr: I2C Address + */ +static void cs8409_set_i2c_dev_addr(struct hda_codec *codec, unsigned int addr) +{ + struct cs8409_spec *spec = codec->spec; + + if (spec->dev_addr != addr) { + cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, addr); + spec->dev_addr = addr; + } +} + /** * cs8409_i2c_read - CS8409 I2C Read. * @codec: the codec instance @@ -153,7 +168,7 @@ static int cs8409_i2c_read(struct hda_codec *codec, unsigned int i2c_address, un return -EPERM; cs8409_enable_i2c_clock(codec); - cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, i2c_address); + cs8409_set_i2c_dev_addr(codec, i2c_address); if (paged) { cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg >> 8); @@ -199,7 +214,7 @@ static int cs8409_i2c_write(struct hda_codec *codec, unsigned int i2c_address, u return -EPERM; cs8409_enable_i2c_clock(codec); - cs8409_vendor_coef_set(codec, CS8409_I2C_ADDR, i2c_address); + cs8409_set_i2c_dev_addr(codec, i2c_address); if (paged) { cs8409_vendor_coef_set(codec, CS8409_I2C_QWRITE, i2c_reg >> 8); diff --git a/sound/pci/hda/patch_cs8409.h b/sound/pci/hda/patch_cs8409.h index 542582c213d2..c2c208218e34 100644 --- a/sound/pci/hda/patch_cs8409.h +++ b/sound/pci/hda/patch_cs8409.h @@ -281,6 +281,7 @@ struct cs8409_spec { struct mutex cs8409_i2c_mux; unsigned int i2c_clck_enabled; + unsigned int dev_addr; struct delayed_work i2c_clk_work; /* verb exec op override */ -- 2.25.1