From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark Knecht Subject: Re: Maintaining sound card at a specific frequency Date: Tue, 18 Jan 2005 10:04:55 -0800 Message-ID: <5bdc1c8b0501181004455c8e36@mail.gmail.com> References: <1105938846.41eb499ec3527@www3.webhosting.cx> <5bdc1c8b05011809013ebf438e@mail.gmail.com> Reply-To: Mark Knecht Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Takashi Iwai Cc: Giuliano Pochini , Patrick Shirkey , alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org Takashi, Since I'm on a PlanetCCRMA box I don't even have Alsa source code. It would be quite difficult for me to test this in any short time. Possibly someone else out there with an HDSP box or card can do this? Sorry, Mark On Tue, 18 Jan 2005 18:48:32 +0100, Takashi Iwai wrote: > At Tue, 18 Jan 2005 18:08:50 +0100, > I wrote: > > > > If this works like you want, only the locking is missing... > > The attached is an experimental patch to add this feature. > You can lock system clock via > > amixer cset iface=PCM,name="System Clock Source Locking" on > > It's untested, as usual. > > > Takashi > > > Index: alsa-kernel/pci/rme9652/hdsp.c > =================================================================== > RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/rme9652/hdsp.c,v > retrieving revision 1.81 > diff -u -r1.81 hdsp.c > --- alsa-kernel/pci/rme9652/hdsp.c 14 Jan 2005 19:50:48 -0000 1.81 > +++ alsa-kernel/pci/rme9652/hdsp.c 18 Jan 2005 17:44:54 -0000 > @@ -450,6 +450,7 @@ > u32 control2_register; /* cached value */ > u32 creg_spdif; > u32 creg_spdif_stream; > + int clock_source_locked; > char *card_name; /* digiface/multiface */ > HDSP_IO_Type io_type; /* ditto, but for code use */ > unsigned short firmware_rev; > @@ -2159,7 +2160,7 @@ > if (val > 6) val = 6; > } > spin_lock_irq(&hdsp->lock); > - if (val != hdsp_clock_source(hdsp)) { > + if (val != hdsp_clock_source(hdsp) && ! hdsp->clock_source_locked) { > change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0; > } else { > change = 0; > @@ -2168,6 +2169,34 @@ > return change; > } > > +static int snd_hdsp_info_clock_source_lock(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) > +{ > + uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; > + uinfo->count = 1; > + uinfo->value.integer.min = 0; > + uinfo->value.integer.max = 1; > + return 0; > +} > + > +static int snd_hdsp_get_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) > +{ > + hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); > + > + ucontrol->value.integer.value[0] = hdsp->clock_source_locked; > + return 0; > +} > + > +static int snd_hdsp_put_clock_source_lock(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) > +{ > + hdsp_t *hdsp = snd_kcontrol_chip(kcontrol); > + int change; > + > + change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked; > + if (change) > + hdsp->clock_source_locked = ucontrol->value.integer.value[0]; > + return change; > +} > + > #define HDSP_DA_GAIN(xname, xindex) \ > { .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ > .name = xname, \ > @@ -3129,6 +3158,13 @@ > HDSP_SPDIF_NON_AUDIO("IEC958 Non-audio Bit", 0), > /* 'Sample Clock Source' complies with the alsa control naming scheme */ > HDSP_CLOCK_SOURCE("Sample Clock Source", 0), > +{ > + .iface = SNDRV_CTL_ELEM_IFACE_PCM, > + .name = "Sample Clock Source Locking", > + .info = snd_hdsp_info_clock_source_lock, > + .get = snd_hdsp_get_clock_source_lock, > + .put = snd_hdsp_put_clock_source_lock, > +}, > HDSP_SYSTEM_CLOCK_MODE("System Clock Mode", 0), > HDSP_PREF_SYNC_REF("Preferred Sync Reference", 0), > HDSP_AUTOSYNC_REF("AutoSync Reference", 0), > @@ -3360,6 +3396,7 @@ > snd_iprintf (buffer, "System Clock Mode: %s\n", system_clock_mode); > > snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); > + snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); > > snd_iprintf(buffer, "\n"); > > @@ -3882,21 +3919,19 @@ > spin_unlock_irq(&hdsp->lock); > return 0; > > - } else { > - spin_unlock_irq(&hdsp->lock); > } > > /* how to make sure that the rate matches an externally-set one ? > */ > > - spin_lock_irq(&hdsp->lock); > - if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { > - spin_unlock_irq(&hdsp->lock); > - _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE); > - return err; > - } else { > - spin_unlock_irq(&hdsp->lock); > + if (! hdsp->clock_source_locked) { > + if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { > + spin_unlock_irq(&hdsp->lock); > + _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE); > + return err; > + } > } > + spin_unlock_irq(&hdsp->lock); > > if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) { > _snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); > @@ -4318,13 +4353,17 @@ > > snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24); > snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hdsp_hw_constraints_period_sizes); > - if (hdsp->io_type == H9632) { > - runtime->hw.channels_min = hdsp->qs_out_channels; > - runtime->hw.channels_max = hdsp->ss_out_channels; > + if (hdsp->clock_source_locked) { > + runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate; > + } else if (hdsp->io_type == H9632) { > runtime->hw.rate_max = 192000; > runtime->hw.rates = SNDRV_PCM_RATE_KNOT; > snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hdsp_hw_constraints_9632_sample_rates); > } > + if (hdsp->io_type == H9632) { > + runtime->hw.channels_min = hdsp->qs_out_channels; > + runtime->hw.channels_max = hdsp->ss_out_channels; > + } > > snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, > snd_hdsp_hw_rule_out_channels, hdsp, > > > ------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt