* [PATCH] save sound mixer state over suspend
@ 2001-11-11 20:42 Kai Germaschewski
2001-11-12 5:47 ` Pete Zaitcev
0 siblings, 1 reply; 4+ messages in thread
From: Kai Germaschewski @ 2001-11-11 20:42 UTC (permalink / raw)
To: linux-kernel; +Cc: Linus Torvalds, Pete Zaitcev
The appended patch introduces two new functions to the ac97_codec
handling: ac97_save_state() and ac97_restore_state().
These functions save/restore the mixer state over suspend. (So after
resume the volume is the same it was before)
As an example, I changed the ymfpci driver to use the new functionality -
works fine here.
--Kai
diff -ur linux-2.4.15-pre2/drivers/sound/ac97_codec.c linux-2.4.15-pre2.x/drivers/sound/ac97_codec.c
--- linux-2.4.15-pre2/drivers/sound/ac97_codec.c Sat Nov 10 19:08:12 2001
+++ linux-2.4.15-pre2.x/drivers/sound/ac97_codec.c Sun Nov 11 20:39:15 2001
@@ -1019,4 +1019,31 @@
}
EXPORT_SYMBOL(ac97_set_adc_rate);
+
+int ac97_save_state(struct ac97_codec *codec)
+{
+ return 0;
+}
+
+EXPORT_SYMBOL(ac97_save_state);
+
+int ac97_restore_state(struct ac97_codec *codec)
+{
+ int i;
+ unsigned int left, right, val;
+
+ for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
+ if (!supported_mixer(codec, i))
+ continue;
+
+ val = codec->mixer_state[i];
+ right = val >> 8;
+ left = val & 0xff;
+ codec->write_mixer(codec, i, left, right);
+ }
+ return 0;
+}
+
+EXPORT_SYMBOL(ac97_restore_state);
+
MODULE_LICENSE("GPL");
diff -ur linux-2.4.15-pre2/drivers/sound/ymfpci.c linux-2.4.15-pre2.x/drivers/sound/ymfpci.c
--- linux-2.4.15-pre2/drivers/sound/ymfpci.c Wed Oct 24 22:51:49 2001
+++ linux-2.4.15-pre2.x/drivers/sound/ymfpci.c Sun Nov 11 20:40:46 2001
@@ -1824,7 +1824,7 @@
}
unit = NULL; /* gcc warns */
- for (list = ymf_devs.next; list != &ymf_devs; list = list->next) {
+ list_for_each(list, &ymf_devs) {
unit = list_entry(list, ymfpci_t, ymf_devs);
if (((unit->dev_audio ^ minor) & ~0x0F) == 0)
break;
@@ -1935,7 +1935,7 @@
struct list_head *list;
ymfpci_t *unit;
- for (list = ymf_devs.next; list != &ymf_devs; list = list->next) {
+ list_for_each(list, &ymf_devs) {
unit = list_entry(list, ymfpci_t, ymf_devs);
for (i = 0; i < NR_AC97; i++) {
if (unit->ac97_codec[i] != NULL &&
@@ -1990,16 +1990,25 @@
static int ymf_suspend(struct pci_dev *pcidev, u32 unused)
{
+ int i;
struct ymf_unit *unit = pci_get_drvdata(pcidev);
unsigned long flags;
struct ymf_dmabuf *dmabuf;
struct list_head *p;
struct ymf_state *state;
+ struct ac97_codec *codec;
spin_lock_irqsave(&unit->reg_lock, flags);
unit->suspended = 1;
+ for (i = 0; i < NR_AC97; i++) {
+ codec = unit->ac97_codec[i];
+ if (!codec)
+ continue;
+ ac97_save_state(codec);
+ }
+
list_for_each(p, &unit->states) {
state = list_entry(p, struct ymf_state, chain);
@@ -2024,13 +2033,22 @@
static int ymf_resume(struct pci_dev *pcidev)
{
+ int i;
struct ymf_unit *unit = pci_get_drvdata(pcidev);
unsigned long flags;
struct list_head *p;
struct ymf_state *state;
+ struct ac97_codec *codec;
ymfpci_aclink_reset(unit->pci);
ymfpci_codec_ready(unit, 0, 1); /* prints diag if not ready. */
+
+ for (i = 0; i < NR_AC97; i++) {
+ codec = unit->ac97_codec[i];
+ if (!codec)
+ continue;
+ ac97_restore_state(codec);
+ }
#ifdef CONFIG_SOUND_YMFPCI_LEGACY
/* XXX At this time the legacy registers are probably deprogrammed. */
diff -ur linux-2.4.15-pre2/include/linux/ac97_codec.h linux-2.4.15-pre2.x/include/linux/ac97_codec.h
--- linux-2.4.15-pre2/include/linux/ac97_codec.h Sun Nov 11 13:12:47 2001
+++ linux-2.4.15-pre2.x/include/linux/ac97_codec.h Sun Nov 11 20:40:29 2001
@@ -239,6 +239,7 @@
extern int ac97_probe_codec(struct ac97_codec *);
extern unsigned int ac97_set_adc_rate(struct ac97_codec *codec, unsigned int rate);
extern unsigned int ac97_set_dac_rate(struct ac97_codec *codec, unsigned int rate);
-
+extern int ac97_save_state(struct ac97_codec *codec);
+extern int ac97_restore_state(struct ac97_codec *codec);
#endif /* _AC97_CODEC_H_ */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] save sound mixer state over suspend
2001-11-11 20:42 [PATCH] save sound mixer state over suspend Kai Germaschewski
@ 2001-11-12 5:47 ` Pete Zaitcev
2001-11-12 6:03 ` Jeff Garzik
0 siblings, 1 reply; 4+ messages in thread
From: Pete Zaitcev @ 2001-11-12 5:47 UTC (permalink / raw)
To: Kai Germaschewski; +Cc: linux-kernel, Linus Torvalds, Pete Zaitcev
> Date: Sun, 11 Nov 2001 21:42:27 +0100 (CET)
> From: Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
> To: <linux-kernel@vger.kernel.org>
> cc: Linus Torvalds <torvalds@transmeta.com>, Pete Zaitcev <zaitcev@redhat.com>
> The appended patch introduces two new functions to the ac97_codec
> handling: ac97_save_state() and ac97_restore_state().
> These functions save/restore the mixer state over suspend. (So after
> resume the volume is the same it was before)
The patch itself looks ok, but I am wondering what is
the difference between your ac97_restore_state and ac97_reset.
I think you may be reinventing the wheel here.
I cannot test the patch because my suspend/resume cycle
retains mixer levels without it (2.2.14 stock, PCG-Z505JE),
so I would not see any difference.
-- Pete
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] save sound mixer state over suspend
2001-11-12 5:47 ` Pete Zaitcev
@ 2001-11-12 6:03 ` Jeff Garzik
2001-11-12 8:40 ` Kai Germaschewski
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2001-11-12 6:03 UTC (permalink / raw)
To: Pete Zaitcev; +Cc: Kai Germaschewski, linux-kernel, Linus Torvalds
Pete Zaitcev wrote:
>
> > Date: Sun, 11 Nov 2001 21:42:27 +0100 (CET)
> > From: Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
> > To: <linux-kernel@vger.kernel.org>
> > cc: Linus Torvalds <torvalds@transmeta.com>, Pete Zaitcev <zaitcev@redhat.com>
>
> > The appended patch introduces two new functions to the ac97_codec
> > handling: ac97_save_state() and ac97_restore_state().
> > These functions save/restore the mixer state over suspend. (So after
> > resume the volume is the same it was before)
>
> The patch itself looks ok, but I am wondering what is
> the difference between your ac97_restore_state and ac97_reset.
> I think you may be reinventing the wheel here.
As we mentioned on IRC, ymfpci uses ac97_codec, which does not contain
the ac97_reset function.
> I cannot test the patch because my suspend/resume cycle
> retains mixer levels without it (2.2.14 stock, PCG-Z505JE),
> so I would not see any difference.
2.2.14? Is that a typo? His was patch for 2.4.15-pre2...
Anyway, my comments per request:
The patch looks ok, but I wonder about the order in ymfpci_resume. You
load the mixer values -then- call ymfpci_download_image and
ymfpci_memload. It seems for the purposes of general sanity and
stability you would want to load the mixer values after doing those two
operations.
Jeff
--
Jeff Garzik | Only so many songs can be sung
Building 1024 | with two lips, two lungs, and one tongue.
MandrakeSoft | - nomeansno
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] save sound mixer state over suspend
2001-11-12 6:03 ` Jeff Garzik
@ 2001-11-12 8:40 ` Kai Germaschewski
0 siblings, 0 replies; 4+ messages in thread
From: Kai Germaschewski @ 2001-11-12 8:40 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Pete Zaitcev, linux-kernel, Linus Torvalds
On Mon, 12 Nov 2001, Jeff Garzik wrote:
> As we mentioned on IRC, ymfpci uses ac97_codec, which does not contain
> the ac97_reset function.
Being curious: Which IRC channel? - I checked the #kernelnewbies log, but
that's apparently not it.
> > I cannot test the patch because my suspend/resume cycle
> > retains mixer levels without it (2.2.14 stock, PCG-Z505JE),
> > so I would not see any difference.
Interesting. My notebook is pretty much the European variant (PCG-Z600NE),
but it doesn't retain the mixer levels.
> The patch looks ok, but I wonder about the order in ymfpci_resume. You
> load the mixer values -then- call ymfpci_download_image and
> ymfpci_memload. It seems for the purposes of general sanity and
> stability you would want to load the mixer values after doing those two
> operations.
Okay. I figured the ac97 codec and programming the chip itself wouldn't
interfere, but I agree that it looks saner to have the ac97_restore_state
at a later point. I'll change the patch accordingly.
--Kai
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-11-12 8:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-11 20:42 [PATCH] save sound mixer state over suspend Kai Germaschewski
2001-11-12 5:47 ` Pete Zaitcev
2001-11-12 6:03 ` Jeff Garzik
2001-11-12 8:40 ` Kai Germaschewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).