From patchwork Thu Aug 19 06:14:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1518441 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gqvds5m4tz9sVw; Thu, 19 Aug 2021 16:15:45 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mGbL2-0000Wb-L4; Thu, 19 Aug 2021 06:15:40 +0000 Received: from mail-pf1-f172.google.com ([209.85.210.172]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mGbKK-0008Pv-Vl for kernel-team@lists.ubuntu.com; Thu, 19 Aug 2021 06:14:57 +0000 Received: by mail-pf1-f172.google.com with SMTP id t42so1938732pfg.12 for ; Wed, 18 Aug 2021 23:14:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=220ztHRUNictm/zVyj3/Bg8a8XwBFj8yX2Xk3Vb5Tsg=; b=Z1Wej8go/fHxsGCWyDTKK54QMMcIh2obwX4zc3bnbWPonH4pVYxLA9OG5gsV6Z6dzy SxAEs6BLlpdH/IMEtLU4DAgGg1uO3jYyCdseNFL6o3YoxxOmNnMB00WReRWxkJgspYih CJtUyxjt8veJ5YSUEl08dUChDQCNK88RviFS/UiMzj7q2cM2OfAvP84+qwKwS98ddtEg tw+rh4KCk3PHdKm4EVVoOtgpxCe7rT6sNLXzko4RF72gWSz5VjAMDPllQvZU8B0W6e3W Io2duDPhjPVggCTi9hWHU7RjjnGlDc85gSHMxigyWmENCLnLb9yk3gDGWSHqu0Ql0OWW bR+Q== X-Gm-Message-State: AOAM531Eu9n23jb8+Z8bQe3V0QxRayVF6ddedN+AZ/SmwZlA0AWyVbdA jXoLQtgPYXDhRnDpG3D5ilO61nWqCVWTPA== X-Google-Smtp-Source: ABdhPJwBP2GpmzcNkCLFVO/6A6iVKngNC8tr3HgTaXlcaUCXlpm7Ma/wiQ/PLR/ShDBcX4aCUqR28w== X-Received: by 2002:a05:6a00:23cf:b0:3e2:4622:da6d with SMTP id g15-20020a056a0023cf00b003e24622da6dmr12918465pfc.18.1629353694943; Wed, 18 Aug 2021 23:14:54 -0700 (PDT) Received: from localhost (114-47-140-65.dynamic-ip.hinet.net. [114.47.140.65]) by smtp.gmail.com with ESMTPSA id r17sm2309114pgu.8.2021.08.18.23.14.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 23:14:54 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 14/30][SRU][OEM-5.13][I][U] ALSA: hda/cs8409: Avoid setting the same I2C address for every access Date: Thu, 19 Aug 2021 14:14:10 +0800 Message-Id: <20210819061427.900601-15-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210819061427.900601-1-vicamo.yang@canonical.com> References: <20210819061427.900601-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.172; envelope-from=vicamo@gmail.com; helo=mail-pf1-f172.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Lucas Tanure BugLink: https://bugs.launchpad.net/bugs/1939541 Signed-off-by: Lucas Tanure Signed-off-by: Vitaly Rodionov Link: https://lore.kernel.org/r/20210811185654.6837-15-vitalyr@opensource.cirrus.com Signed-off-by: Takashi Iwai (cherry picked from commit d395fd7864c553908a83e10112184febbb9cf81c) Signed-off-by: You-Sheng Yang --- 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 420f3a612fc4..e683349ebd50 100644 --- a/sound/pci/hda/patch_cs8409.c +++ b/sound/pci/hda/patch_cs8409.c @@ -155,6 +155,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 @@ -176,7 +191,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); @@ -222,7 +237,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 */