int pcxhr_create_mixer(struct pcxhr_mgr *mgr)
{
	struct snd_pcxhr *chip;
	int err, i;

	mutex_init(&mgr->mixer_mutex); 

	for (i = 0; i < mgr->num_cards; i++) {
		struct snd_kcontrol_new temp;
		chip = mgr->chip[i];

		if (chip->nb_streams_play) {
			
			temp = pcxhr_control_analog_level;
			temp.name = "Master Playback Volume";
			temp.private_value = 0; 
			if (mgr->is_hr_stereo)
				temp.tlv.p = db_scale_a_hr222_playback;
			else
				temp.tlv.p = db_scale_analog_playback;
			err = snd_ctl_add(chip->card,
					  snd_ctl_new1(&temp, chip));
			if (err < 0)
				return err;

			
			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_output_switch,
					     chip));
			if (err < 0)
				return err;

			temp = snd_pcxhr_pcm_vol;
			temp.name = "PCM Playback Volume";
			temp.count = PCXHR_PLAYBACK_STREAMS;
			temp.private_value = 0; 
			err = snd_ctl_add(chip->card,
					  snd_ctl_new1(&temp, chip));
			if (err < 0)
				return err;

			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_pcm_switch, chip));
			if (err < 0)
				return err;

			
			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_playback_iec958_mask,
					     chip));
			if (err < 0)
				return err;

			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_playback_iec958,
					     chip));
			if (err < 0)
				return err;
		}
		if (chip->nb_streams_capt) {
			
			temp = pcxhr_control_analog_level;
			temp.name = "Line Capture Volume";
			temp.private_value = 1; 
			if (mgr->is_hr_stereo)
				temp.tlv.p = db_scale_a_hr222_capture;
			else
				temp.tlv.p = db_scale_analog_capture;

			err = snd_ctl_add(chip->card,
					  snd_ctl_new1(&temp, chip));
			if (err < 0)
				return err;

			temp = snd_pcxhr_pcm_vol;
			temp.name = "PCM Capture Volume";
			temp.count = 1;
			temp.private_value = 1; 

			err = snd_ctl_add(chip->card,
					  snd_ctl_new1(&temp, chip));
			if (err < 0)
				return err;

			
			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_audio_src, chip));
			if (err < 0)
				return err;

			
			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_capture_iec958_mask,
					     chip));
			if (err < 0)
				return err;

			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_capture_iec958,
					     chip));
			if (err < 0)
				return err;

			if (mgr->is_hr_stereo) {
				err = hr222_add_mic_controls(chip);
				if (err < 0)
					return err;
			}
		}
		
		if (chip->nb_streams_capt > 0 && chip->nb_streams_play > 0) {
			
			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_monitor_vol, chip));
			if (err < 0)
				return err;

			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_monitor_sw, chip));
			if (err < 0)
				return err;
		}

		if (i == 0) {
			
			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_clock_type, mgr));
			if (err < 0)
				return err;
			err = snd_ctl_add(chip->card,
				snd_ctl_new1(&pcxhr_control_clock_rate, mgr));
			if (err < 0)
				return err;
		}

		
		pcxhr_init_audio_levels(chip);
	}

	return 0;
}
Example #2
0
int pcxhr_create_mixer(struct pcxhr_mgr *mgr)
{
    struct snd_pcxhr *chip;
    int err, i;

    mutex_init(&mgr->mixer_mutex); /* can be in another place */

    for (i = 0; i < mgr->num_cards; i++) {
        struct snd_kcontrol_new temp;
        chip = mgr->chip[i];

        if (chip->nb_streams_play) {
            /* analog output level control */
            temp = pcxhr_control_analog_level;
            temp.name = "Master Playback Volume";
            temp.private_value = 0; /* playback */
            temp.tlv.p = db_scale_analog_playback;
            if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
                return err;
            /* output mute controls */
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_output_switch,
                                chip))) < 0)
                return err;
            
            temp = snd_pcxhr_pcm_vol;
            temp.name = "PCM Playback Volume";
            temp.count = PCXHR_PLAYBACK_STREAMS;
            temp.private_value = 0; /* playback */
            if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
                return err;

            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_pcm_switch,
                                chip))) < 0)
                return err;

            /* IEC958 controls */
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_playback_iec958_mask,
                                chip))) < 0)
                return err;
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_playback_iec958,
                                chip))) < 0)
                return err;
        }
        if (chip->nb_streams_capt) {
            /* analog input level control only on first two chips !*/
            temp = pcxhr_control_analog_level;
            temp.name = "Master Capture Volume";
            temp.private_value = 1; /* capture */
            temp.tlv.p = db_scale_analog_capture;
            if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
                return err;

            temp = snd_pcxhr_pcm_vol;
            temp.name = "PCM Capture Volume";
            temp.count = 1;
            temp.private_value = 1; /* capture */
            if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0)
                return err;
            /* Audio source */
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_audio_src,
                                chip))) < 0)
                return err;
            /* IEC958 controls */
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_capture_iec958_mask,
                                chip))) < 0)
                return err;
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_capture_iec958,
                                chip))) < 0)
                return err;
        }
        /* monitoring only if playback and capture device available */
        if (chip->nb_streams_capt > 0 && chip->nb_streams_play > 0) {
            /* monitoring */
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_monitor_vol,
                                chip))) < 0)
                return err;
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_monitor_sw,
                                chip))) < 0)
                return err;
        }

        if (i == 0) {
            /* clock mode only one control per pcxhr */
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_clock_type,
                                mgr))) < 0)
                return err;
            /* non standard control used to scan the external clock presence/frequencies */
            if ((err = snd_ctl_add(chip->card,
                           snd_ctl_new1(&pcxhr_control_clock_rate,
                                mgr))) < 0)
                return err;
        }

        /* init values for the mixer data */
        pcxhr_init_audio_levels(chip);
    }

    return 0;
}