: improvements to hda-intel sigmatel codec S3 resume
PATCH 1/1 : improvements to hda-intel sigmatel codec S3 resume
Hi all,
I noticed a problem with S3 resume and my STAC9200 Intel HDA chip. If I restart alsa after resuming, the pin configurations are wrong. My specific system isn't recognized, so it ends up using the BIOS configuration, but the BIOS doesn't fix up the config registers on resume. The debug messages with --with-debug=detect after boot are:
.../patch_sigmatel.c:1279: hda_codec: Unknown model for STAC9200, using BIOS defaults.../hda_codec.c:2150: autoconfig: line_outs=0 (0x0/0x0/0x0/0x0/0x0)
.../hda_codec.c:2154: speaker_outs=2 (0xe/0x11/0x0/0x0/0x0) .../hda_codec.c:2156: hp=0xd, dig_out=0x9, din_in=0x0 .../hda_codec.c:2164: inputs: mic=0x10, fmic=0x0, line=0x0,
fline=0x0, cd=0x0, aux=0x0
While reloading after an S3 resume produces:
.../patch_sigmatel.c:1279: hda_codec: Unknown model for STAC9200, using BIOS defaults.../hda_codec.c:2150: autoconfig: line_outs=1 (0xe/0x0/0x0/0x0/0x0)
.../hda_codec.c:2154: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) .../hda_codec.c:2156: hp=0xd, dig_out=0x9, din_in=0x8 .../hda_codec.c:2164: inputs: mic=0x0, fmic=0x10, line=0xf,
fline=0x0, cd=0x12, aux=0x0
Note that I am not talking about unloading the drivers before suspend, and reloading them afterwards...there is really nothing that can be done for that case obviously. I'm just looking to be able to do an "alsasound restart" or driver update without having to reboot.
So, my proposed and attached patch stores off the BIOS configuration, and restores it on resume. Please review and comment. One thing it does that may not be correct is that it uses the STAC_REF slot in the tables to store the BIOS configuration. If this is a problem, it should be easy enough to just add a STAC_BIOS slot to the tables.
Please CC me on any replies.
Regards,
-Richard
pci/hda/patch_sigmatel.c renamed from pci/hda/patch_sigmatel.c.orig +49 -17
@@ -469,6 +469,25 @@ {}/* terminator */ }; +static void stac92xx_save_bios_config_regs (struct hda_codec *codec) +{ +int i; +struct sigmatel_spec *spec = codec->spec; + +for (i =0 ; i < spec->num_pins; i++) { +hda_nid_t nid = spec->pin_nids[i]; +unsigned int pin_cfg; + + pin_cfg =snd_hda_codec_read (codec, nid,0 , +AC_VERB_GET_CONFIG_DEFAULT ,0x00 ); +snd_printdd (KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n" , + nid, pin_cfg); + spec->pin_configs[i] = pin_cfg; + } + +return ; +} +static void stac92xx_set_config_regs (struct hda_codec *codec) {int i;
@@ -1242,6 +1261,7 @@int i;stac92xx_init (codec); +stac92xx_set_config_regs (codec);for (i =0 ; i < spec->num_mixers; i++)snd_hda_resume_ctls (codec, spec->mixers[i]);if (spec->multiout.dig_out_nid)
@@ -1274,12 +1294,15 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =8 ; + spec->pin_nids = stac9200_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac9200_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n" ); + spec->pin_configs = stac9200_brd_tbl[STAC_REF ]; +stac92xx_save_bios_config_regs (codec); + }else { - spec->num_pins =8 ; - spec->pin_nids = stac9200_pin_nids; spec->pin_configs = stac9200_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
@@ -1315,13 +1338,16 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =10 ; + spec->pin_nids = stac922x_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac922x_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC922x, " -"using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC922x, " +"using BIOS defaults\n" ); + spec->pin_configs = stac922x_brd_tbl[STAC_REF ]; +stac92xx_save_bios_config_regs (codec); + }else if (stac922x_brd_tbl[spec->board_config] !=NULL ) { - spec->num_pins =10 ; - spec->pin_nids = stac922x_pin_nids; spec->pin_configs = stac922x_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
@@ -1378,12 +1404,15 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =14 ; + spec->pin_nids = stac927x_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac927x_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n" ); + spec->pin_configs = stac927x_brd_tbl[STAC_REF ]; +stac92xx_save_bios_config_regs (codec); + }else { - spec->num_pins =14 ; - spec->pin_nids = stac927x_pin_nids; spec->pin_configs = stac927x_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
@@ -1418,12 +1447,15 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =14 ; + spec->pin_nids = stac9205_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac9205_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n" ); + spec->pin_configs = stac9205_brd_tbl[STAC_REF ]; +stac92xx_save_bios_config_regs (codec); + }else { - spec->num_pins =14 ; - spec->pin_nids = stac9205_pin_nids; spec->pin_configs = stac9205_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
At Sun, 13 Aug 2006 02:01:53 -0700,
Quoted 32 lines · Richard Fish
Hi all,
I noticed a problem with S3 resume and my STAC9200 Intel HDA chip. If I restart alsa after resuming, the pin configurations are wrong. My specific system isn't recognized, so it ends up using the BIOS configuration, but the BIOS doesn't fix up the config registers on resume. The debug messages with --with-debug=detect after boot are:
.../patch_sigmatel.c:1279:hda_codec: Unknown model for STAC9200, using BIOS defaults.../hda_codec.c:2150: autoconfig: line_outs=0 (0x0/0x0/0x0/0x0/0x0).../hda_codec.c:2154: speaker_outs=2 (0xe/0x11/0x0/0x0/0x0) .../hda_codec.c:2156: hp=0xd, dig_out=0x9, din_in=0x0 .../hda_codec.c:2164: inputs: mic=0x10, fmic=0x0, line=0x0,fline=0x0, cd=0x0, aux=0x0
While reloading after an S3 resume produces:
.../patch_sigmatel.c:1279:hda_codec: Unknown model for STAC9200, using BIOS defaults.../hda_codec.c:2150: autoconfig: line_outs=1 (0xe/0x0/0x0/0x0/0x0).../hda_codec.c:2154: speaker_outs=0 (0x0/0x0/0x0/0x0/0x0) .../hda_codec.c:2156: hp=0xd, dig_out=0x9, din_in=0x8 .../hda_codec.c:2164: inputs: mic=0x0, fmic=0x10, line=0xf,fline=0x0, cd=0x12, aux=0x0
Note that I am not talking about unloading the drivers before suspend, and reloading them afterwards...there is really nothing that can be done for that case obviously. I'm just looking to be able to do an "alsasound restart" or driver update without having to reboot.
Quoted 5 lines
So, my proposed and attached patch stores off the BIOS configuration, and restores it on resume. Please review and comment. One thing it does that may not be correct is that it uses the
STAC_REFslot in the tables to store the BIOS configuration. If this is a problem, it should be easy enough to just add aSTAC_BIOSslot to the tables.
Yes, it's better to avoid such an overwrite of a static array since we may have multiple same codecs and the saved configurations may collide.
I vote for making pin_configs either a fixed-size or a kmalloced array in the spec struct, and copying the pin table entries to there.
Care to rewrite the patch in that manner, and provide a proper changelog and a signed-off-by line?
Thanks,
Takashi
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Quoted 10 lines · Takashi Iwai
At Sun, 13 Aug 2006 02:01:53 -0700,
Quoted 5 lines · Richard Fish
Hi all,
I noticed a problem with S3 resume and my STAC9200 Intel HDA chip. If I restart alsa after resuming, the pin configurations are wrong. My
Care to rewrite the patch in that manner, and provide a proper changelog and a signed-off-by line?
Updated patch attached. This one dynamically allocates memory for the bios pin configs.
Regards,
-Richard
[snd-intel-hda] restore HDA sigmatel pin configs on resume
This patch restores the Intel HDA Sigmatel codec pin configuration on resume. Most of it is dedicated to saving the BIOS pin configuration if necessary, so that even unrecognized chips can be resumed correctly.
pci/hda/patch_sigmatel.c renamed from pci/hda/patch_sigmatel.c.orig +76 -17
@@ -73,6 +73,7 @@hda_nid_t *pin_nids;unsigned int num_pins;unsigned int *pin_configs; +unsigned int *bios_pin_configs;/* codec specific stuff */ struct hda_verb *init;
@@ -469,6 +470,32 @@ {}/* terminator */ }; +static int stac92xx_save_bios_config_regs (struct hda_codec *codec) +{ +int i; +struct sigmatel_spec *spec = codec->spec; + +if (! spec->bios_pin_configs) { + spec->bios_pin_configs =kcalloc (spec->num_pins, +sizeof (*spec->bios_pin_configs),GFP_KERNEL ); +if (! spec->bios_pin_configs) +return -ENOMEM ; + } + +for (i =0 ; i < spec->num_pins; i++) { +hda_nid_t nid = spec->pin_nids[i]; +unsigned int pin_cfg; + + pin_cfg =snd_hda_codec_read (codec, nid,0 , +AC_VERB_GET_CONFIG_DEFAULT ,0x00 ); +snd_printdd (KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n" , + nid, pin_cfg); + spec->bios_pin_configs[i] = pin_cfg; + } + +return 0 ; +} +static void stac92xx_set_config_regs (struct hda_codec *codec) {int i;
@@ -1185,6 +1212,9 @@kfree (spec->kctl_alloc); } +if (spec->bios_pin_configs) +kfree (spec->bios_pin_configs); +kfree (spec); }
@@ -1242,6 +1272,7 @@int i;stac92xx_init (codec); +stac92xx_set_config_regs (codec);for (i =0 ; i < spec->num_mixers; i++)snd_hda_resume_ctls (codec, spec->mixers[i]);if (spec->multiout.dig_out_nid)
@@ -1274,12 +1305,19 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =8 ; + spec->pin_nids = stac9200_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac9200_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n" ); + err =stac92xx_save_bios_config_regs (codec); +if (err <0 ) { +stac92xx_free (codec); +return err; + } + spec->pin_configs = spec->bios_pin_configs; + }else { - spec->num_pins =8 ; - spec->pin_nids = stac9200_pin_nids; spec->pin_configs = stac9200_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
@@ -1315,13 +1353,20 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =10 ; + spec->pin_nids = stac922x_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac922x_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC922x, " -"using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC922x, " +"using BIOS defaults\n" ); + err =stac92xx_save_bios_config_regs (codec); +if (err <0 ) { +stac92xx_free (codec); +return err; + } + spec->pin_configs = spec->bios_pin_configs; + }else if (stac922x_brd_tbl[spec->board_config] !=NULL ) { - spec->num_pins =10 ; - spec->pin_nids = stac922x_pin_nids; spec->pin_configs = stac922x_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
@@ -1378,12 +1423,19 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =14 ; + spec->pin_nids = stac927x_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac927x_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n" ); + err =stac92xx_save_bios_config_regs (codec); +if (err <0 ) { +stac92xx_free (codec); +return err; + } + spec->pin_configs = spec->bios_pin_configs; + }else { - spec->num_pins =14 ; - spec->pin_nids = stac927x_pin_nids; spec->pin_configs = stac927x_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
@@ -1418,12 +1470,19 @@return -ENOMEM ; codec->spec = spec; + spec->num_pins =14 ; + spec->pin_nids = stac9205_pin_nids; spec->board_config =snd_hda_check_board_config (codec, stac9205_cfg_tbl); -if (spec->board_config <0 ) -snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n" ); +if (spec->board_config <0 ) { +snd_printdd (KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n" ); + err =stac92xx_save_bios_config_regs (codec); +if (err <0 ) { +stac92xx_free (codec); +return err; + } + spec->pin_configs = spec->bios_pin_configs; + }else { - spec->num_pins =14 ; - spec->pin_nids = stac9205_pin_nids; spec->pin_configs = stac9205_brd_tbl[spec->board_config];stac92xx_set_config_regs (codec); }
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
At Sun, 20 Aug 2006 00:23:54 -0700,
Quoted 7 lines · Richard Fish
Quoted 5 lines · Takashi Iwai
At Sun, 13 Aug 2006 02:01:53 -0700,
Quoted 3 lines · Richard Fish
Hi all,
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I noticed a problem with S3 resume and my STAC9200 Intel HDA chip. If I restart alsa after resuming, the pin configurations are wrong. My
Care to rewrite the patch in that manner, and provide a proper changelog and a signed-off-by line?
Updated patch attached. This one dynamically allocates memory for the bios pin configs.
Thanks, the patch looks OK. I'll merge it after we release ALSA 1.0.12-final.
Takashi
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642