[ALSA] ice1724 - Fix the SPDIF input sample-rate on Juli@
authorTakashi Iwai <tiwai@suse.de>
Fri, 14 Mar 2008 16:17:09 +0000 (17:17 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 24 Apr 2008 10:00:25 +0000 (12:00 +0200)
AK4114 on Juli@ has the SPDIF input sample rate detection and
causes errors when an incompatible sample rate is chosen.
The patch adds the open hook to check the current rate and limit
the hw constraints.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/ice1712/ice1724.c
sound/pci/ice1712/juli.c

index f533850ec6e776377bffd69dac936ae61f32d4bb..3bfd70577d7a7f096d6baa1d2d4c722dcfd235bc 100644 (file)
@@ -970,6 +970,8 @@ static int snd_vt1724_playback_spdif_open(struct snd_pcm_substream *substream)
                                   VT1724_BUFFER_ALIGN);
        snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
                                   VT1724_BUFFER_ALIGN);
+       if (ice->spdif.ops.open)
+               ice->spdif.ops.open(ice, substream);
        return 0;
 }
 
@@ -980,6 +982,8 @@ static int snd_vt1724_playback_spdif_close(struct snd_pcm_substream *substream)
        if (PRO_RATE_RESET)
                snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
        ice->playback_con_substream = NULL;
+       if (ice->spdif.ops.close)
+               ice->spdif.ops.close(ice, substream);
 
        return 0;
 }
@@ -1002,6 +1006,8 @@ static int snd_vt1724_capture_spdif_open(struct snd_pcm_substream *substream)
                                   VT1724_BUFFER_ALIGN);
        snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES,
                                   VT1724_BUFFER_ALIGN);
+       if (ice->spdif.ops.open)
+               ice->spdif.ops.open(ice, substream);
        return 0;
 }
 
@@ -1012,6 +1018,8 @@ static int snd_vt1724_capture_spdif_close(struct snd_pcm_substream *substream)
        if (PRO_RATE_RESET)
                snd_vt1724_set_pro_rate(ice, PRO_RATE_DEFAULT, 0);
        ice->capture_con_substream = NULL;
+       if (ice->spdif.ops.close)
+               ice->spdif.ops.close(ice, substream);
 
        return 0;
 }
index e8038c0ceb721a0f9a3d881814f3bc40dcee34e2..4550609b4d478659c15c7213dafcb9d2d7886e7c 100644 (file)
@@ -77,6 +77,22 @@ static unsigned char juli_ak4114_read(void *private_data, unsigned char reg)
        return snd_vt1724_read_i2c((struct snd_ice1712 *)private_data, AK4114_ADDR, reg);
 }
 
+static void juli_spdif_in_open(struct snd_ice1712 *ice,
+                              struct snd_pcm_substream *substream)
+{
+       struct juli_spec *spec = ice->spec;
+       struct snd_pcm_runtime *runtime = substream->runtime;
+       int rate;
+
+       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
+               return;
+       rate = snd_ak4114_external_rate(spec->ak4114);
+       if (rate >= runtime->hw.rate_min && rate <= runtime->hw.rate_max) {
+               runtime->hw.rate_min = rate;
+               runtime->hw.rate_max = rate;
+       }
+}
+
 /*
  * AK4358 section
  */
@@ -210,6 +226,7 @@ static int __devinit juli_init(struct snd_ice1712 *ice)
                        return err;
        }
        
+       ice->spdif.ops.open = juli_spdif_in_open;
        return 0;
 }