ALSA: Echoaudio - Add suspend support #1
authorGiuliano Pochini <pochini@shiny.it>
Sun, 14 Feb 2010 17:15:59 +0000 (18:15 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 15 Feb 2010 09:39:22 +0000 (10:39 +0100)
Move the controls init code outside the init_hw() function because is must
not be called during resume.

This patch moves the code that initializes the card's controls with
default valued from the init_hw() function into a separated
set_mixer_defaults() function (one for each of the 16 supported
cards). This change is necessary because during resume we must
resurrect the hardware without losing the previous
settings. set_mixer_defaults() must be called only once when the
module is loaded.

Signed-off-by: Giuliano Pochini <pochini@shiny.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
15 files changed:
sound/pci/echoaudio/darla20_dsp.c
sound/pci/echoaudio/darla24_dsp.c
sound/pci/echoaudio/echo3g_dsp.c
sound/pci/echoaudio/gina20_dsp.c
sound/pci/echoaudio/gina24_dsp.c
sound/pci/echoaudio/indigo_dsp.c
sound/pci/echoaudio/indigo_express_dsp.c
sound/pci/echoaudio/indigodj_dsp.c
sound/pci/echoaudio/indigodjx_dsp.c
sound/pci/echoaudio/indigoio_dsp.c
sound/pci/echoaudio/indigoiox_dsp.c
sound/pci/echoaudio/layla20_dsp.c
sound/pci/echoaudio/layla24_dsp.c
sound/pci/echoaudio/mia_dsp.c
sound/pci/echoaudio/mona_dsp.c

index a44135d6acbb8955dad38d974b25f9f929c85416..20c7cbc89bb38aff3042e5b5a603de7af286a7f5 100644 (file)
@@ -57,15 +57,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
+
+
+
 /* The Darla20 has no external clock sources */
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
index d681da1808298203a9db474250533912eae5a2d4..6da6663e9176eb467c794b5772acaf0b3fb271ab 100644 (file)
@@ -56,15 +56,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        u32 clocks_from_dsp, clock_bits;
index f0071935c0cb3183dea6e230cd394da4236d6643..3cdc2ee2d1dd900d97c431a3180a405230f70b5a 100644 (file)
@@ -97,20 +97,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        chip->digital_modes =   ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
                                ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
                                ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
-       chip->digital_mode =    DIGITAL_MODE_SPDIF_RCA;
-       chip->professional_spdif = FALSE;
-       chip->non_audio_spdif = FALSE;
-       chip->bad_board = FALSE;
-
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-       err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       if (err < 0)
-               return err;
-       err = set_phantom_power(chip, 0);
-       if (err < 0)
-               return err;
-       err = set_professional_spdif(chip, TRUE);
 
        DE_INIT(("init_hw done\n"));
        return err;
@@ -118,6 +104,18 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
+       chip->professional_spdif = FALSE;
+       chip->non_audio_spdif = FALSE;
+       chip->bad_board = FALSE;
+       chip->phantom_power = FALSE;
+       return init_line_levels(chip);
+}
+
+
+
 static int set_phantom_power(struct echoaudio *chip, char on)
 {
        u32 control_reg = le32_to_cpu(chip->comm_page->control_register);
index c5de88b6792d4ed37a83012df38c3bfa03e84ab5..d1615a0579d17f50fe9563e837631ab89161b6ab 100644 (file)
@@ -62,17 +62,20 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
-       err = set_professional_spdif(chip, TRUE);
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       chip->professional_spdif = FALSE;
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        u32 clocks_from_dsp, clock_bits;
index 093dd7ba0e8178a9ce264de61531f06385e47bff..98f7cfa81b5f3bb0fcbd660c3b1f9527e390bde7 100644 (file)
@@ -57,9 +57,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                ECHO_CLOCK_BIT_INTERNAL | ECHO_CLOCK_BIT_SPDIF |
                ECHO_CLOCK_BIT_ESYNC | ECHO_CLOCK_BIT_ESYNC96 |
                ECHO_CLOCK_BIT_ADAT;
-       chip->professional_spdif = FALSE;
-       chip->digital_in_automute = TRUE;
-       chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
 
        /* Gina24 comes in both '301 and '361 flavors */
        if (chip->device_id == DEVICE_ID_56361) {
@@ -81,19 +78,22 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-       err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       if (err < 0)
-               return err;
-       err = set_professional_spdif(chip, TRUE);
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
+       chip->professional_spdif = FALSE;
+       chip->digital_in_automute = TRUE;
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        u32 clocks_from_dsp, clock_bits;
index 8799d2e6536af219131ee0a86e10339296752288..5e85f14fe5a8c83e78e3d59b5321674f3157136f 100644 (file)
@@ -60,15 +60,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        return ECHO_CLOCK_BIT_INTERNAL;
index 9ab625e15652512305bf1b3089a319bbe2efa2a0..2e4ab3e34a7454e1053d131d768aadc8a12d4aab 100644 (file)
@@ -61,6 +61,7 @@ static int set_sample_rate(struct echoaudio *chip, u32 rate)
 
        control_reg |= clock;
        if (control_reg != old_control_reg) {
+               DE_ACT(("set_sample_rate: %d clock %d\n", rate, clock));
                chip->comm_page->control_register = cpu_to_le32(control_reg);
                chip->sample_rate = rate;
                clear_handshake(chip);
index cb1c92ca9fef8296737229fc50bd0ecf4713cea8..68f3c8ccc1bf83375bb6873bbe62c3237b415e11 100644 (file)
@@ -60,15 +60,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        return ECHO_CLOCK_BIT_INTERNAL;
index 91dbfeb586a7d23dfc8c72845d76fd09d73eb835..bb9632c752a953e873bb0d85c32efa80c7021ab1 100644 (file)
@@ -59,10 +59,13 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       err = init_line_levels(chip);
-       if (err < 0)
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
+
+
+
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
index 134e783d3486b73a2aa0098ba03db759912df1ff..beb9a5b69892e496a9717b917263a7fcef230cab 100644 (file)
@@ -60,15 +60,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        return ECHO_CLOCK_BIT_INTERNAL;
index 766cf501799dc47ffef20bea9acf36acc241dc64..394c6e76bcbcba5a377d7d7ed38e8957ccf1f2ed 100644 (file)
@@ -59,10 +59,13 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       err = init_line_levels(chip);
-       if (err < 0)
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
+
+
+
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
index 07f32454757ef8c8dc1cec72e8216f5e003968ba..53ce9460504413a0fabbc705623a0832cb8f188d 100644 (file)
@@ -64,17 +64,20 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
-       err = set_professional_spdif(chip, TRUE);
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       chip->professional_spdif = FALSE;
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        u32 clocks_from_dsp, clock_bits;
index 12dc00adca9f3e2bd8cfde1f2fdbf280ab80451d..8c041647f285e0fe44afb3eb853c96c6dd27dac7 100644 (file)
@@ -61,9 +61,6 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA |
                ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL |
                ECHOCAPS_HAS_DIGITAL_MODE_ADAT;
-       chip->digital_mode =            DIGITAL_MODE_SPDIF_RCA;
-       chip->professional_spdif = FALSE;
-       chip->digital_in_automute = TRUE;
 
        if ((err = load_firmware(chip)) < 0)
                return err;
@@ -72,17 +69,22 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        if ((err = init_line_levels(chip)) < 0)
                return err;
 
-       err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       if (err < 0)
-               return err;
-       err = set_professional_spdif(chip, TRUE);
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
+       chip->professional_spdif = FALSE;
+       chip->digital_in_automute = TRUE;
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        u32 clocks_from_dsp, clock_bits;
index d0302f2f00db2fbe2cde402a2df45d1cf5d98d7b..6ebfa6e7ab9e28bd1301bd75ab0ff4334c7bd40a 100644 (file)
@@ -66,15 +66,19 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)))
-               return err;
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        u32 clocks_from_dsp, clock_bits;
index b28b8e4703cf184d2bcbf40d9a6445a293748988..6e6a7eb555b8103f455d5c65fd056d94f320917f 100644 (file)
@@ -67,28 +67,26 @@ static int init_hw(struct echoaudio *chip, u16 device_id, u16 subdevice_id)
        else
                chip->dsp_code_to_load = FW_MONA_301_DSP;
 
-       chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
-       chip->professional_spdif = FALSE;
-       chip->digital_in_automute = TRUE;
-
        if ((err = load_firmware(chip)) < 0)
                return err;
        chip->bad_board = FALSE;
 
-       if ((err = init_line_levels(chip)) < 0)
-               return err;
-
-       err = set_digital_mode(chip, DIGITAL_MODE_SPDIF_RCA);
-       if (err < 0)
-               return err;
-       err = set_professional_spdif(chip, TRUE);
-
        DE_INIT(("init_hw done\n"));
        return err;
 }
 
 
 
+static int set_mixer_defaults(struct echoaudio *chip)
+{
+       chip->digital_mode = DIGITAL_MODE_SPDIF_RCA;
+       chip->professional_spdif = FALSE;
+       chip->digital_in_automute = TRUE;
+       return init_line_levels(chip);
+}
+
+
+
 static u32 detect_input_clocks(const struct echoaudio *chip)
 {
        u32 clocks_from_dsp, clock_bits;