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; } 
static int snd_hdsp_hw_params(snd_pcm_substream_t *substream,				 snd_pcm_hw_params_t *params){	hdsp_t *hdsp = snd_pcm_substream_chip(substream);	int err;	pid_t this_pid;	pid_t other_pid;	if (hdsp_check_for_iobox (hdsp)) {		return -EIO;	}	if (hdsp_check_for_firmware(hdsp)) {		if (hdsp->state & HDSP_FirmwareCached) {			if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) {				snd_printk("Hammerfall-DSP: Firmware loading from cache failed, please upload manually.\n");			}		} else {			snd_printk("Hammerfall-DSP: No firmware loaded nor cached, please upload firmware.\n");		}		return -EIO;	}	spin_lock_irq(&hdsp->lock);	if (substream->pstr->stream == SNDRV_PCM_STREAM_PLAYBACK) {		hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis);		hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= hdsp->creg_spdif_stream);		this_pid = hdsp->playback_pid;		other_pid = hdsp->capture_pid;	} else {		this_pid = hdsp->capture_pid;		other_pid = hdsp->playback_pid;	}	if ((other_pid > 0) && (this_pid != other_pid)) {		/* The other stream is open, and not by the same		   task as this one. Make sure that the parameters		   that matter are the same.		 */		if (params_rate(params) != hdsp->system_sample_rate) {			spin_unlock_irq(&hdsp->lock);			_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_RATE);			return -EBUSY;		}		if (params_period_size(params) != hdsp->period_bytes / 4) {			spin_unlock_irq(&hdsp->lock);			_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);			return -EBUSY;		}		/* We're fine. */		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 ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) {		_snd_pcm_hw_param_setempty(params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE);		return err;	}	return 0;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/e3ea4d896109edd64dc549ecaeeff8d89025fb57/hdsp.c/clean/sound/pci/rme9652/hdsp.c