]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: tea6330t: add mixer state restore helper
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Tue, 7 Apr 2026 15:35:42 +0000 (12:35 -0300)
committerTakashi Iwai <tiwai@suse.de>
Wed, 8 Apr 2026 07:55:03 +0000 (09:55 +0200)
The InterWave STB variant uses a TEA6330T mixer on its private
I2C bus. The mixer state is cached in software, but there is no
helper to push that register image back to hardware after system
resume.

Add a small restore helper that reapplies the cached TEA6330T
register image to the device so board drivers can restore the
external mixer state as part of their PM resume path.

Take snd_i2c_lock() around the full device lookup and restore
sequence so the bus device list traversal is also protected.

Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260407-alsa-interwave-pm-v2-2-8dd96c6129e9@gmail.com
include/sound/tea6330t.h
sound/i2c/tea6330t.c

index 1c77b78f65332a93d86d610277eecbcb7507ce13..3a34033d2aa307462b8726ea85b8b56a4739bcdf 100644 (file)
@@ -12,5 +12,6 @@
 int snd_tea6330t_detect(struct snd_i2c_bus *bus, int equalizer);
 int snd_tea6330t_update_mixer(struct snd_card *card, struct snd_i2c_bus *bus,
                              int equalizer, int fader);
+int snd_tea6330t_restore_mixer(struct snd_i2c_bus *bus);
 
 #endif /* __SOUND_TEA6330T_H */
index 5341907b85d190e300825a8accc15ff84551fa2f..39c5e87c6ab050822ca3009d73746d760d24eeac 100644 (file)
@@ -356,5 +356,42 @@ int snd_tea6330t_update_mixer(struct snd_card *card,
        snd_i2c_device_free(device);
        return err;
 }
-
 EXPORT_SYMBOL(snd_tea6330t_update_mixer);
+
+int snd_tea6330t_restore_mixer(struct snd_i2c_bus *bus)
+{
+       struct snd_i2c_device *device;
+       struct tea6330t *tea;
+       unsigned char bytes[7];
+       unsigned int idx;
+       int err;
+
+       if (!bus)
+               return -EINVAL;
+
+       snd_i2c_lock(bus);
+       list_for_each_entry(device, &bus->devices, list) {
+               if (device->addr != TEA6330T_ADDR)
+                       continue;
+
+               tea = device->private_data;
+               if (!tea) {
+                       err = -EINVAL;
+                       goto unlock;
+               }
+
+               bytes[0] = TEA6330T_SADDR_VOLUME_LEFT;
+               for (idx = 0; idx < 6; idx++)
+                       bytes[idx + 1] = tea->regs[idx];
+               err = snd_i2c_sendbytes(device, bytes, 7);
+               err = err < 0 ? err : 0;
+               goto unlock;
+       }
+
+       err = -ENODEV;
+
+unlock:
+       snd_i2c_unlock(bus);
+       return err;
+}
+EXPORT_SYMBOL(snd_tea6330t_restore_mixer);