[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210730151844.7873-15-vitalyr@opensource.cirrus.com>
Date: Fri, 30 Jul 2021 16:18:31 +0100
From: Vitaly Rodionov <vitalyr@...nsource.cirrus.com>
To: Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>
CC: <alsa-devel@...a-project.org>, <patches@...nsource.cirrus.com>,
<linux-kernel@...r.kernel.org>,
Lucas Tanure <tanureal@...nsource.cirrus.com>
Subject: [PATCH v3 14/27] ALSA: hda/cs8409: Avoid setting the same I2C address for every access
From: Lucas Tanure <tanureal@...nsource.cirrus.com>
Signed-off-by: Lucas Tanure <tanureal@...nsource.cirrus.com>
Signed-off-by: Vitaly Rodionov <vitalyr@...nsource.cirrus.com>
---
Changes in v2:
- No changes
Changes in v3:
- 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 1c75aa262ebc..194d336cb060 100644
--- a/sound/pci/hda/patch_cs8409.c
+++ b/sound/pci/hda/patch_cs8409.c
@@ -140,6 +140,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
@@ -161,7 +176,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);
@@ -207,7 +222,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
Powered by blists - more mailing lists