コード例 #1
0
static int build_input(struct hda_codec *codec)
{
	struct cs_spec *spec = codec->spec;
	int i, err;

	if (!spec->num_inputs)
		return 0;

	/* make bind-capture */
	spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw);
	spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol);
	for (i = 0; i < 2; i++) {
		struct snd_kcontrol *kctl;
		if (!spec->capture_bind[i])
			return -ENOMEM;
		kctl = snd_ctl_new1(&cs_capture_ctls[i], codec);
		if (!kctl)
			return -ENOMEM;
		kctl->private_value = (long)spec->capture_bind[i];
		err = snd_hda_ctl_add(codec, kctl);
		if (err < 0)
			return err;
	}
	
	if (spec->num_inputs > 1 && !spec->mic_detect) {
		err = snd_hda_ctl_add(codec,
				      snd_ctl_new1(&cs_capture_source, codec));
		if (err < 0)
			return err;
	}

	return 0;
}
コード例 #2
0
static int build_input(struct hda_codec *codec)
{
	struct cs_spec *spec = codec->spec;
	int i, err;

	if (!spec->num_inputs)
		return 0;

	/* make bind-capture */
	spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw);
	spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol);
	for (i = 0; i < 2; i++) {
		struct snd_kcontrol *kctl;
		int n;
		if (!spec->capture_bind[i])
			return -ENOMEM;
		kctl = snd_ctl_new1(&cs_capture_ctls[i], codec);
		if (!kctl)
			return -ENOMEM;
		kctl->private_value = (long)spec->capture_bind[i];
		err = snd_hda_ctl_add(codec, 0, kctl);
		if (err < 0)
			return err;
		for (n = 0; n < AUTO_PIN_LAST; n++) {
			if (!spec->adc_nid[n])
				continue;
			err = snd_hda_add_nid(codec, kctl, 0, spec->adc_nid[n]);
			if (err < 0)
				return err;
		}
	}
	
	if (spec->num_inputs > 1 && !spec->mic_detect) {
		struct snd_kcontrol *SND_CTL = snd_ctl_new1(&cs_capture_source, codec);
		if(!SND_CTL)
			return -1;
		err = snd_hda_ctl_add(codec, 0, SND_CTL);
		if (err < 0)
			return err;
	}

	for (i = 0; i < spec->num_inputs; i++) {
		err = add_input_volume_control(codec, &spec->autocfg, i);
		if (err < 0)
			return err;
	}

	return 0;
}