Exemple #1
0
static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
                struct snd_ctl_elem_value *ucontrol)
{
    struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
    unsigned int clock_items = 3 + mgr->capture_chips;
    int rate, ret = 0;

    if (ucontrol->value.enumerated.item[0] >= clock_items)
        return -EINVAL;
    mutex_lock(&mgr->mixer_mutex);
    if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) {
        mutex_lock(&mgr->setup_mutex);
        mgr->use_clock_type = ucontrol->value.enumerated.item[0];
        if (mgr->use_clock_type)
            pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate);
        else
            rate = mgr->sample_rate;
        if (rate) {
            pcxhr_set_clock(mgr, rate);
            if (mgr->sample_rate)
                mgr->sample_rate = rate;
        }
        mutex_unlock(&mgr->setup_mutex);
        ret = 1;    /* return 1 even if the set was not done. ok ? */
    }
    mutex_unlock(&mgr->mixer_mutex);
    return ret;
}
static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{
	struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
	int rate, ret = 0;

	down(&mgr->mixer_mutex);
	if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) {
		down(&mgr->setup_mutex);
		mgr->use_clock_type = ucontrol->value.enumerated.item[0];
		if (mgr->use_clock_type)
			pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate);
		else
			rate = mgr->sample_rate;
		if (rate) {
			pcxhr_set_clock(mgr, rate);
			if (mgr->sample_rate)
				mgr->sample_rate = rate;
		}
		up(&mgr->setup_mutex);
		ret = 1;	/* return 1 even if the set was not done. ok ? */
	}
	up(&mgr->mixer_mutex);
	return ret;
}
static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{
	struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol);
	int rate, ret = 0;
	unsigned int clock_items = 2; 
	if (mgr->board_has_aes1) {
		clock_items += mgr->capture_chips;	
		if (!mgr->is_hr_stereo)
			clock_items += 1;		
	}
	if (ucontrol->value.enumerated.item[0] >= clock_items)
		return -EINVAL;
	mutex_lock(&mgr->mixer_mutex);
	if (mgr->use_clock_type != ucontrol->value.enumerated.item[0]) {
		mutex_lock(&mgr->setup_mutex);
		mgr->use_clock_type = ucontrol->value.enumerated.item[0];
		rate = 0;
		if (mgr->use_clock_type != PCXHR_CLOCK_TYPE_INTERNAL) {
			pcxhr_get_external_clock(mgr, mgr->use_clock_type,
						 &rate);
		} else {
			rate = mgr->sample_rate;
			if (!rate)
				rate = 48000;
		}
		if (rate) {
			pcxhr_set_clock(mgr, rate);
			if (mgr->sample_rate)
				mgr->sample_rate = rate;
		}
		mutex_unlock(&mgr->setup_mutex);
		ret = 1; 
	}
	mutex_unlock(&mgr->mixer_mutex);
	return ret;
}