]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
ALSA: hda - Fix dynamic ADC change working again
authorTakashi Iwai <tiwai@suse.de>
Fri, 13 Aug 2010 09:56:53 +0000 (11:56 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 13 Aug 2010 09:56:53 +0000 (11:56 +0200)
The commit eb541337b7a43822fce7d0c9d967ee149b2d9a96
    ALSA: hda - Make converter setups sticky
changes the semantics of snd_hda_codec_cleanup_stream() not to clean up
the stream at that moment but delay the action.  This broke the codes
expecting that the clean-up is done immediately, such as dynamic ADC
changes in some codec drivers.

This patch fixes the issue by introducing a lower helper,
__snd_hda_codec_cleanup_stream(), to allow the immediate clean up.
The original snd_hda_codec_cleanup_stream() is kept as is now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_codec.h
sound/pci/hda/patch_cirrus.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_realtek.c

index 720a81d711e3c9007dbcd9b0ef0eb562ec3d32af..dd8fb86c842b85feef9a3018f2dcf42b2a06dba4 100644 (file)
@@ -1261,12 +1261,17 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
 }
 EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream);
 
+static void really_cleanup_stream(struct hda_codec *codec,
+                                 struct hda_cvt_setup *q);
+
 /**
- * snd_hda_codec_cleanup_stream - clean up the codec for closing
+ * __snd_hda_codec_cleanup_stream - clean up the codec for closing
  * @codec: the CODEC to clean up
  * @nid: the NID to clean up
+ * @do_now: really clean up the stream instead of clearing the active flag
  */
-void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
+void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
+                                   int do_now)
 {
        struct hda_cvt_setup *p;
 
@@ -1274,14 +1279,19 @@ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid)
                return;
 
        snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid);
-       /* here we just clear the active flag; actual clean-ups will be done
-        * in purify_inactive_streams()
-        */
        p = get_hda_cvt_setup(codec, nid);
-       if (p)
-               p->active = 0;
+       if (p) {
+               /* here we just clear the active flag when do_now isn't set;
+                * actual clean-ups will be done later in
+                * purify_inactive_streams() called from snd_hda_codec_prpapre()
+                */
+               if (do_now)
+                       really_cleanup_stream(codec, p);
+               else
+                       p->active = 0;
+       }
 }
-EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream);
+EXPORT_SYMBOL_HDA(__snd_hda_codec_cleanup_stream);
 
 static void really_cleanup_stream(struct hda_codec *codec,
                                  struct hda_cvt_setup *q)
index 3f7a479881e501a7f6291c2ff98911d411966a84..4303353feda99af99b63b63ed0a9bb6a404f8fdc 100644 (file)
@@ -963,7 +963,10 @@ void snd_hda_codec_cleanup(struct hda_codec *codec,
 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
                                u32 stream_tag,
                                int channel_id, int format);
-void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid);
+void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
+                                   int do_now);
+#define snd_hda_codec_cleanup_stream(codec, nid) \
+       __snd_hda_codec_cleanup_stream(codec, nid, 0)
 unsigned int snd_hda_calc_stream_format(unsigned int rate,
                                        unsigned int channels,
                                        unsigned int format,
index 350ee8ac415382b5f53a536a61f2422f44ac0ec3..4ef5efaaaef1a81d29290d5d9618097634957c10 100644 (file)
@@ -656,7 +656,7 @@ static int change_cur_input(struct hda_codec *codec, unsigned int idx,
                return 0;
        if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) {
                /* stream is running, let's swap the current ADC */
-               snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
+               __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
                spec->cur_adc = spec->adc_nid[idx];
                snd_hda_codec_setup_stream(codec, spec->cur_adc,
                                           spec->cur_adc_stream_tag, 0,
index f7e234e5ee96bf6c3439312df50a0491be4dfe40..31b5d9eeba68655db32a631160bcf95049b4f1d0 100644 (file)
@@ -1733,7 +1733,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec)
        new_adc = spec->adc_nids[spec->cur_adc_idx];
        if (spec->cur_adc && spec->cur_adc != new_adc) {
                /* stream is running, let's swap the current ADC */
-               snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
+               __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
                spec->cur_adc = new_adc;
                snd_hda_codec_setup_stream(codec, new_adc,
                                           spec->cur_adc_stream_tag, 0,
index 55d6e5b6bb7d3d7da0209a9e436e86be5dd41411..2cd1ae809e4677a84834654bcdafa3e07ddaf06a 100644 (file)
@@ -1037,7 +1037,7 @@ static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
        new_adc = spec->adc_nids[spec->cur_adc_idx];
        if (spec->cur_adc && spec->cur_adc != new_adc) {
                /* stream is running, let's swap the current ADC */
-               snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
+               __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
                spec->cur_adc = new_adc;
                snd_hda_codec_setup_stream(codec, new_adc,
                                           spec->cur_adc_stream_tag, 0,