static int msm_dai_q6_hdmi_dai_probe(struct snd_soc_dai *dai)
{
	struct msm_dai_q6_hdmi_dai_data *dai_data;
	const struct snd_kcontrol_new *kcontrol;
	int rc = 0;

	dai_data = kzalloc(sizeof(struct msm_dai_q6_hdmi_dai_data),
		GFP_KERNEL);

	if (!dai_data) {
		dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
		dai->id);
		rc = -ENOMEM;
	} else
		dev_set_drvdata(dai->dev, dai_data);

	kcontrol = &hdmi_config_controls[0];

	rc = snd_ctl_add(dai->card->snd_card,
					 snd_ctl_new1(kcontrol, dai_data));

	kcontrol = &hdmi_config_controls[1];

	rc = snd_ctl_add(dai->card->snd_card,
					 snd_ctl_new1(kcontrol, dai_data));

	return rc;
}
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;
}
int tegra_asoc_utils_register_ctls(struct tegra_asoc_utils_data *data)
{
	int ret = 0;
	int i;

	/* Add AVP related alsa controls */
	data->avp_device_id = -1;
	for (i = 0; i < ARRAY_SIZE(tegra_avp_controls); i++) {
		ret = snd_ctl_add(data->card->snd_card,
				snd_ctl_new1(&tegra_avp_controls[i], data));
		if (ret < 0) {
			dev_err(data->dev, "Can't add avp alsa controls");
			return ret;
		}
	}

	ret = snd_ctl_add(data->card->snd_card,
			snd_ctl_new1(&tegra_switch_controls, data));
	if (ret < 0) {
		dev_err(data->dev, "Can't add switch alsa control");
		return ret;
	}

	ret = snd_ctl_add(data->card->snd_card,
			snd_ctl_new1(&tegra_i2s_lpbk_control, data));
	if (ret < 0) {
		dev_err(data->dev, "Can't add i2s loopback control");
		return ret;
	}

	return ret;
}
Example #4
0
int vxp_add_mic_controls(vx_core_t *_chip)
{
	struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip;
	int err;

	/* mute input levels */
	chip->mic_level = 0;
	switch (_chip->type) {
	case VX_TYPE_VXPOCKET:
		vx_set_mic_level(_chip, 0);
		break;
	case VX_TYPE_VXP440:
		vx_set_mic_boost(_chip, 0);
		break;
	}

	/* mic level */
	switch (_chip->type) {
	case VX_TYPE_VXPOCKET:
		if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_level, chip))) < 0)
			return err;
		break;
	case VX_TYPE_VXP440:
		if ((err = snd_ctl_add(_chip->card, snd_ctl_new1(&vx_control_mic_boost, chip))) < 0)
			return err;
		break;
	}

	return 0;
}
static int msm_dai_q6_dai_mi2s_probe(struct snd_soc_dai *dai)
{
	struct msm_dai_q6_mi2s_dai_data *mi2s_dai_data =
		dev_get_drvdata(dai->dev);
	struct snd_kcontrol *kcontrol = NULL;
	int rc = 0;

	if (mi2s_dai_data->rx_dai.port_config.mi2s.line) {
		kcontrol = snd_ctl_new1(&mi2s_config_controls[0],
					&mi2s_dai_data->rx_dai);
		rc = snd_ctl_add(dai->card->snd_card, kcontrol);

		if (IS_ERR_VALUE(rc)) {
			dev_err(dai->dev, "%s: err add RX fmt ctl\n", __func__);
			goto rtn;
		}
	}

	if (mi2s_dai_data->tx_dai.port_config.mi2s.line) {
		rc = snd_ctl_add(dai->card->snd_card,
				 snd_ctl_new1(&mi2s_config_controls[2],
					      &mi2s_dai_data->tx_dai));

		if (IS_ERR_VALUE(rc)) {
			if (kcontrol)
				snd_ctl_remove(dai->card->snd_card, kcontrol);
			dev_err(dai->dev, "%s: err add TX fmt ctl\n", __func__);
		}
	}

rtn:
	return rc;
}
Example #6
0
int tegra_controls_init(struct snd_soc_codec *codec)
{
	struct tegra_audio_data* audio_data = codec->socdev->codec_data;
	int err;

	/* Add play route control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_play_route_control, audio_data));
	if (err < 0)
		return err;

	/* Add capture route control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_capture_route_control, audio_data));
	if (err < 0)
		return err;

	/* Add call mode switch control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_call_mode_control, audio_data));
	if (err < 0)
		return err;

	return 0;
}
Example #7
0
static int msm_new_mixer(struct snd_card *card)
{
	unsigned int idx;
	int err;
	int dev_cnt;

	strcpy(card->mixername, "MSM Mixer");
	for (idx = 0; idx < ARRAY_SIZE(snd_msm_controls); idx++) {
		err = snd_ctl_add(card,	snd_ctl_new1(&snd_msm_controls[idx],
					NULL));
		if (err < 0)
			MM_AUD_ERR("ERR adding ctl\n");
	}
	dev_cnt = msm_snddev_devcount();

	for (idx = 0; idx < dev_cnt; idx++) {
		if (!snd_dev_ctl_index(idx)) {
			err = snd_ctl_add(card, snd_ctl_new1(
				&snd_dev_controls[idx], NULL));
			if (err < 0)
				MM_AUD_ERR("ERR adding ctl\n");
		} else
			return 0;
	}
	simple_control = ARRAY_SIZE(snd_msm_controls);
	device_index = simple_control + 1;
	return 0;
}
Example #8
0
int snd_gf1_new_mixer(struct snd_gus_card * gus)
{
    struct snd_card *card;
    unsigned int idx, max;
    int err;

    snd_assert(gus != NULL, return -EINVAL);
    card = gus->card;
    snd_assert(card != NULL, return -EINVAL);

    if (gus->ics_flag)
        snd_component_add(card, "ICS2101");
    if (card->mixername[0] == '\0') {
        strcpy(card->mixername, gus->ics_flag ? "GF1,ICS2101" : "GF1");
    } else {
        if (gus->ics_flag)
            strcat(card->mixername, ",ICS2101");
        strcat(card->mixername, ",GF1");
    }

    if (!gus->ics_flag) {
        max = gus->ess_flag ? 1 : ARRAY_SIZE(snd_gf1_controls);
        for (idx = 0; idx < max; idx++) {
            if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_gf1_controls[idx], gus))) < 0)
                return err;
        }
    } else {
        for (idx = 0; idx < ARRAY_SIZE(snd_ics_controls); idx++) {
            if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ics_controls[idx], gus))) < 0)
                return err;
        }
    }
    return 0;
}
int tegra_controls_init(struct snd_soc_codec *codec)
{
	int err;
         if (codec == NULL)
                return -ENODEV;

	if (!audio_data) {
		audio_data = kzalloc(sizeof(*audio_data), GFP_KERNEL);
		if (!audio_data) {
		pr_err("failed to allocate tegra_audio_data \n");
		return -ENOMEM;
	}

	/* Add tegra specific controls */
	err = snd_soc_add_controls(codec, tegra_controls,
					ARRAY_SIZE(tegra_controls));
	if (err < 0)
		goto fail;

	/* Add tegra specific widgets */
	snd_soc_dapm_new_controls(codec, tegra_dapm_widgets,
					ARRAY_SIZE(tegra_dapm_widgets));

		/* Set up tegra specific audio path audio_map */
		snd_soc_dapm_add_routes(codec, audio_map,
				ARRAY_SIZE(audio_map));

	audio_data->codec = codec;
	/* Add play route control */
	err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_play_route_control, NULL));
	if (err < 0)
		goto fail;

	/* Add capture route control */
	err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_capture_route_control, NULL));
	if (err < 0)
		goto fail;

	/* Add call mode switch control */
	err = snd_ctl_add(codec->card,
			snd_ctl_new1(&tegra_call_mode_control, NULL));
	if (err < 0)
		goto fail;

	snd_soc_dapm_sync(codec);
	}

	return 0;
fail:
	if (audio_data) {
		kfree(audio_data);
		audio_data = 0;
	}
	return err;
}
static int msm_dai_q6_hdmi_dai_probe(struct snd_soc_dai *dai)
{
	struct msm_dai_q6_hdmi_dai_data *dai_data;
	const struct snd_kcontrol_new *kcontrol;
	int rc = 0;
	struct snd_soc_dapm_route intercon;

	if (!dai) {
		pr_err("%s: dai not found\n", __func__);
		return -EINVAL;
	}
	dai_data = kzalloc(sizeof(struct msm_dai_q6_hdmi_dai_data),
		GFP_KERNEL);

	if (!dai_data) {
		dev_err(dai->dev, "DAI-%d: fail to allocate dai data\n",
		dai->id);
		rc = -ENOMEM;
	} else
		dev_set_drvdata(dai->dev, dai_data);

	kcontrol = &hdmi_config_controls[0];

	rc = snd_ctl_add(dai->card->snd_card,
					 snd_ctl_new1(kcontrol, dai_data));

	kcontrol = &hdmi_config_controls[1];

	rc = snd_ctl_add(dai->card->snd_card,
					 snd_ctl_new1(kcontrol, dai_data));

	memset(&intercon, 0 , sizeof(intercon));
	if (!rc && dai && dai->driver) {
		if (dai->driver->playback.stream_name &&
			dai->driver->playback.aif_name) {
			dev_dbg(dai->dev, "%s add route for widget %s",
				   __func__, dai->driver->playback.stream_name);
			intercon.source = dai->driver->playback.aif_name;
			intercon.sink = dai->driver->playback.stream_name;
			dev_dbg(dai->dev, "%s src %s sink %s\n",
				   __func__, intercon.source, intercon.sink);
			snd_soc_dapm_add_routes(&dai->dapm, &intercon, 1);
		}
		if (dai->driver->capture.stream_name &&
		   dai->driver->capture.aif_name) {
			dev_dbg(dai->dev, "%s add route for widget %s",
				   __func__, dai->driver->capture.stream_name);
			intercon.sink = dai->driver->capture.aif_name;
			intercon.source = dai->driver->capture.stream_name;
			dev_dbg(dai->dev, "%s src %s sink %s\n",
				   __func__, intercon.source, intercon.sink);
			snd_soc_dapm_add_routes(&dai->dapm, &intercon, 1);
		}
	}
	return rc;
}
Example #11
0
int snd_cs4236_mixer(struct snd_wss *chip)
{
	struct snd_card *card;
	unsigned int idx, count;
	int err;
	struct snd_kcontrol_new *kcontrol;

	if (snd_BUG_ON(!chip || !chip->card))
		return -EINVAL;
	card = chip->card;
	strcpy(card->mixername, snd_wss_chip_id(chip));

	if (chip->hardware == WSS_HW_CS4235 ||
	    chip->hardware == WSS_HW_CS4239) {
		for (idx = 0; idx < ARRAY_SIZE(snd_cs4235_controls); idx++) {
			if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4235_controls[idx], chip))) < 0)
				return err;
		}
	} else {
		for (idx = 0; idx < ARRAY_SIZE(snd_cs4236_controls); idx++) {
			if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4236_controls[idx], chip))) < 0)
				return err;
		}
	}
	switch (chip->hardware) {
	case WSS_HW_CS4235:
	case WSS_HW_CS4239:
		count = ARRAY_SIZE(snd_cs4236_3d_controls_cs4235);
		kcontrol = snd_cs4236_3d_controls_cs4235;
		break;
	case WSS_HW_CS4237B:
		count = ARRAY_SIZE(snd_cs4236_3d_controls_cs4237);
		kcontrol = snd_cs4236_3d_controls_cs4237;
		break;
	case WSS_HW_CS4238B:
		count = ARRAY_SIZE(snd_cs4236_3d_controls_cs4238);
		kcontrol = snd_cs4236_3d_controls_cs4238;
		break;
	default:
		count = 0;
		kcontrol = NULL;
	}
	for (idx = 0; idx < count; idx++, kcontrol++) {
		if ((err = snd_ctl_add(card, snd_ctl_new1(kcontrol, chip))) < 0)
			return err;
	}
	if (chip->hardware == WSS_HW_CS4237B ||
	    chip->hardware == WSS_HW_CS4238B) {
		for (idx = 0; idx < ARRAY_SIZE(snd_cs4236_iec958_controls); idx++) {
			if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_cs4236_iec958_controls[idx], chip))) < 0)
				return err;
		}
	}
	return 0;
}
int snd_ak4641_add_mixer_controls(struct snd_ak4641 *ak, struct snd_card *card)
{
	snd_ak4641_lock(ak);
	snd_ctl_add(card, snd_ctl_new1(&snd_ak4641_actl_playback_volume, ak));
	snd_ctl_add(card, snd_ctl_new1(&snd_ak4641_actl_playback_switch, ak));
	snd_ctl_add(card, snd_ctl_new1(&snd_ak4641_actl_mic_gain, ak));
	snd_ctl_add(card, snd_ctl_new1(&snd_ak4641_actl_mic_boost, ak));
	snd_ctl_add(card, snd_ctl_new1(&snd_ak4641_actl_mono_out, ak));
	snd_ak4641_unlock(ak);
	return 0;
}
Example #13
0
static int xonar_d1_mixer_init(struct oxygen *chip)
{
	int err;

	err = snd_ctl_add(chip->card, snd_ctl_new1(&front_panel_switch, chip));
	if (err < 0)
		return err;
	err = snd_ctl_add(chip->card, snd_ctl_new1(&rolloff_control, chip));
	if (err < 0)
		return err;
	return 0;
}
static int codec_soc_probe(struct platform_device *pdev)
{
	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
	struct snd_soc_codec *codec;
	int ret = 0;

	socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL);
	if (!socdev->card->codec)
		return -ENOMEM;

	codec = socdev->card->codec;
	mutex_init(&codec->mutex);

	codec->name = "tegra-generic-codec";
	codec->owner = THIS_MODULE;
	codec->dai = &tegra_generic_codec_dai;
	codec->num_dai = 1;
	codec->write = NULL;
	codec->read = NULL;
	INIT_LIST_HEAD(&codec->dapm_widgets);
	INIT_LIST_HEAD(&codec->dapm_paths);
	/* Register PCMs. */
	ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
	if (ret < 0) {
		printk(KERN_ERR "codec: failed to create pcms\n");
		goto pcm_err;
	}
	/* Register Card. */
	ret = snd_soc_init_card(socdev);
	if (ret < 0) {
		printk(KERN_ERR "codec: failed to register card\n");
		goto card_err;
	}
	/* Add volume control */
	ret = snd_ctl_add(codec->card,
			   snd_ctl_new1(&tegra_codec_ctrl_volume, codec));
	if (ret < 0) {
		printk(KERN_ERR "codec: failed to add control\n");
		goto card_err;
	}
	/* Add route control */
	return snd_ctl_add(codec->card,
			   snd_ctl_new1(&tegra_codec_ctrl_route, codec));

card_err:
	snd_soc_free_pcms(socdev);
pcm_err:
	kfree(socdev->card->codec);

	return ret;
}
Example #15
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;
}
Example #16
0
static int add_aicamixer_controls(struct snd_card_aica *dreamcastcard)
{
	int err;
	err = snd_ctl_add
	    (dreamcastcard->card,
	     snd_ctl_new1(&snd_aica_pcmvolume_control, dreamcastcard));
	if (unlikely(err < 0))
		return err;
	err = snd_ctl_add
	    (dreamcastcard->card,
	     snd_ctl_new1(&snd_aica_pcmswitch_control, dreamcastcard));
	if (unlikely(err < 0))
		return err;
	return 0;
}
Example #17
0
/**
 * snd_intelmad_mixer- to setup mixer settings of the card
 *
 * @intelmaddata: pointer to internal context
 *
 * This function is called from probe function to set up mixer controls
 */
static int __devinit snd_intelmad_mixer(struct snd_intelmad *intelmaddata)
{
	struct snd_card *card;
	unsigned int idx;
	int ret_val = 0, max_controls = 0;
	char *mixername = "IntelMAD Controls";
	struct snd_kcontrol_new *controls;

	WARN_ON(!intelmaddata);

	card = intelmaddata->card;
	strncpy(card->mixername, mixername, sizeof(card->mixername)-1);
	/* add all widget controls and expose the same */
	if (intelmaddata->cpu_id == CPU_CHIP_PENWELL) {
		max_controls = MAX_CTRL_MFLD;
		controls = snd_intelmad_controls_mfld;
	} else {
		max_controls = MAX_CTRL_MRST;
		controls = snd_intelmad_controls_mrst;
	}
	for (idx = 0; idx < max_controls; idx++) {
		ret_val = snd_ctl_add(card,
				snd_ctl_new1(&controls[idx],
				intelmaddata));
		pr_debug("mixer[idx]=%d added\n", idx);
		if (ret_val) {
			pr_err("in adding of control index = %d\n", idx);
			break;
		}
	}
	return ret_val;
}
Example #18
0
int snd_ak4113_build(struct ak4113 *ak4113,
                     struct snd_pcm_substream *cap_substream)
{
    struct snd_kcontrol *kctl;
    unsigned int idx;
    int err;

    if (snd_BUG_ON(!cap_substream))
        return -EINVAL;
    ak4113->substream = cap_substream;
    for (idx = 0; idx < AK4113_CONTROLS; idx++) {
        kctl = snd_ctl_new1(&snd_ak4113_iec958_controls[idx], ak4113);
        if (kctl == NULL)
            return -ENOMEM;
        kctl->id.device = cap_substream->pcm->device;
        kctl->id.subdevice = cap_substream->number;
        err = snd_ctl_add(ak4113->card, kctl);
        if (err < 0)
            return err;
        ak4113->kctls[idx] = kctl;
    }
    snd_ak4113_proc_init(ak4113);
    /* trigger workq */
    schedule_delayed_work(&ak4113->work, HZ / 10);
    return 0;
}
Example #19
0
int snd_ak4114_build(ak4114_t *ak4114,
		     snd_pcm_substream_t *ply_substream,
		     snd_pcm_substream_t *cap_substream)
{
	snd_kcontrol_t *kctl;
	unsigned int idx;
	int err;

	snd_assert(cap_substream, return -EINVAL);
	ak4114->playback_substream = ply_substream;
	ak4114->capture_substream = cap_substream;
	for (idx = 0; idx < AK4114_CONTROLS; idx++) {
		kctl = snd_ctl_new1(&snd_ak4114_iec958_controls[idx], ak4114);
		if (kctl == NULL)
			return -ENOMEM;
		if (!strstr(kctl->id.name, "Playback")) {
			if (ply_substream == NULL) {
				snd_ctl_free_one(kctl);
				ak4114->kctls[idx] = NULL;
				continue;
			}
			kctl->id.device = ply_substream->pcm->device;
			kctl->id.subdevice = ply_substream->number;
		} else {
			kctl->id.device = cap_substream->pcm->device;
			kctl->id.subdevice = cap_substream->number;
		}
		err = snd_ctl_add(ak4114->card, kctl);
		if (err < 0)
			return err;
		ak4114->kctls[idx] = kctl;
	}
	return 0;
}
Example #20
0
int snd_cs8427_iec958_build(struct snd_i2c_device *cs8427,
			    struct snd_pcm_substream *play_substream,
			    struct snd_pcm_substream *cap_substream)
{
	struct cs8427 *chip = cs8427->private_data;
	struct snd_kcontrol *kctl;
	unsigned int idx;
	int err;

	if (snd_BUG_ON(!play_substream || !cap_substream))
		return -EINVAL;
	for (idx = 0; idx < ARRAY_SIZE(snd_cs8427_iec958_controls); idx++) {
		kctl = snd_ctl_new1(&snd_cs8427_iec958_controls[idx], cs8427);
		if (kctl == NULL)
			return -ENOMEM;
		kctl->id.device = play_substream->pcm->device;
		kctl->id.subdevice = play_substream->number;
		err = snd_ctl_add(cs8427->bus->card, kctl);
		if (err < 0)
			return err;
		if (! strcmp(kctl->id.name,
			     SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM)))
			chip->playback.pcm_ctl = kctl;
	}

	chip->playback.substream = play_substream;
	chip->capture.substream = cap_substream;
	if (snd_BUG_ON(!chip->playback.pcm_ctl))
		return -EIO;
	return 0;
}
Example #21
0
/* Logic for a aic3x as connected on the s6105 ip camera ref design */
static int s6105_aic3x_init(struct snd_soc_codec *codec)
{
	/* Add s6105 specific widgets */
	snd_soc_dapm_new_controls(codec, aic3x_dapm_widgets,
				  ARRAY_SIZE(aic3x_dapm_widgets));

	/* Set up s6105 specific audio path audio_map */
	snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));

	/* not present */
	snd_soc_dapm_nc_pin(codec, "MONO_LOUT");
	snd_soc_dapm_nc_pin(codec, "LINE2L");
	snd_soc_dapm_nc_pin(codec, "LINE2R");

	/* not connected */
	snd_soc_dapm_nc_pin(codec, "MIC3L"); /* LINE2L on this chip */
	snd_soc_dapm_nc_pin(codec, "MIC3R"); /* LINE2R on this chip */
	snd_soc_dapm_nc_pin(codec, "LLOUT");
	snd_soc_dapm_nc_pin(codec, "RLOUT");
	snd_soc_dapm_nc_pin(codec, "HPRCOM");

	/* always connected */
	snd_soc_dapm_enable_pin(codec, "Audio In");

	/* must correspond to audio_out_mux.private_value initializer */
	snd_soc_dapm_disable_pin(codec, "Audio Out Differential");
	snd_soc_dapm_sync(codec);
	snd_soc_dapm_enable_pin(codec, "Audio Out Stereo");

	snd_soc_dapm_sync(codec);

	snd_ctl_add(codec->card, snd_ctl_new1(&audio_out_mux, codec));

	return 0;
}
Example #22
0
static int usb6fire_control_add_virtual(
	struct control_runtime *rt,
	struct snd_card *card,
	char *name,
	struct snd_kcontrol_new *elems)
{
	int ret;
	int i;
	struct snd_kcontrol *vmaster =
		snd_ctl_make_virtual_master(name, tlv_output);
	struct snd_kcontrol *control;

	if (!vmaster)
		return -ENOMEM;
	ret = snd_ctl_add(card, vmaster);
	if (ret < 0)
		return ret;

	i = 0;
	while (elems[i].name) {
		control = snd_ctl_new1(&elems[i], rt);
		if (!control)
			return -ENOMEM;
		ret = snd_ctl_add(card, control);
		if (ret < 0)
			return ret;
		ret = snd_ctl_add_slave(vmaster, control);
		if (ret < 0)
			return ret;
		i++;
	}
	return 0;
}
Example #23
0
int tegra_controls_init(struct snd_soc_codec *codec)
{
	struct tegra_audio_data* audio_data = codec->socdev->codec_data;
	int err;

	/* Add play route control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_play_route_control, audio_data));
	if (err < 0)
		return err;

	/* Add capture route control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_capture_route_control, audio_data));
	if (err < 0)
		return err;

	/* Add call mode switch control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_call_mode_control, audio_data));
	if (err < 0)
		return err;

#if defined(CONFIG_MACH_ACER_PICASSO) || defined(CONFIG_MACH_ACER_MAYA) || defined(CONFIG_MACH_ACER_VANGOGH)
	/* Add mic mode switch control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_mic_mode_control, audio_data));
	if (err < 0)
		return err;

	/* Add shutdown mode switch control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_shutdown_mode_control, audio_data));
	if (err < 0)
		return err;

	/* Add ringtone mode switch control */
        err = snd_ctl_add(codec->card,
                snd_ctl_new1(&tegra_ringtone_mode_control, audio_data));
        if (err < 0)
                return err;

	/* Add video call mode switch control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_video_call_mode_control, audio_data));
	if (err < 0)
		return err;

	/* Add automatic speech recognition mode switch control */
	err = snd_ctl_add(codec->card,
		snd_ctl_new1(&tegra_speech_mode_control, audio_data));
	if (err < 0)
		return err;
#endif

	return 0;
}
Example #24
0
int __devinit usb6fire_control_init(struct sfire_chip *chip)
{
	int i;
	int ret;
	struct control_runtime *rt = kzalloc(sizeof(struct control_runtime),
			GFP_KERNEL);
	struct comm_runtime *comm_rt = chip->comm;

	if (!rt)
		return -ENOMEM;

	rt->chip = chip;
	rt->update_streaming = usb6fire_control_streaming_update;
	rt->set_rate = usb6fire_control_set_rate;
	rt->set_channels = usb6fire_control_set_channels;

	i = 0;
	while (init_data[i].type) {
		comm_rt->write8(comm_rt, init_data[i].type, init_data[i].reg,
				init_data[i].value);
		i++;
	}

	usb6fire_control_opt_coax_update(rt);
	usb6fire_control_line_phono_update(rt);
	usb6fire_control_output_vol_update(rt);
	usb6fire_control_output_mute_update(rt);
	usb6fire_control_input_vol_update(rt);
	usb6fire_control_streaming_update(rt);

	ret = usb6fire_control_add_virtual(rt, chip->card,
		"Master Playback Volume", vol_elements);
	if (ret) {
		snd_printk(KERN_ERR PREFIX "cannot add control.\n");
		kfree(rt);
		return ret;
	}
	ret = usb6fire_control_add_virtual(rt, chip->card,
		"Master Playback Switch", mute_elements);
	if (ret) {
		snd_printk(KERN_ERR PREFIX "cannot add control.\n");
		kfree(rt);
		return ret;
	}

	i = 0;
	while (elements[i].name) {
		ret = snd_ctl_add(chip->card, snd_ctl_new1(&elements[i], rt));
		if (ret < 0) {
			kfree(rt);
			snd_printk(KERN_ERR PREFIX "cannot add control.\n");
			return ret;
		}
		i++;
	}

	chip->control = rt;
	return 0;
}
Example #25
0
static int create_src_gain_mixer(struct lola *chip,
				 int num, int ofs, char *name)
{
	lola_src_gain_mixer.name = name;
	lola_src_gain_mixer.private_value = ofs + (num << 8);
	return snd_ctl_add(chip->card,
			   snd_ctl_new1(&lola_src_gain_mixer, chip));
}
Example #26
0
/*
 * Lola16161 or Lola881 can have Hardware sample rate converters
 * on its digital input pins
 */
static int create_input_src_mixer(struct lola *chip)
{
	if (!chip->input_src_caps_mask)
		return 0;

	return snd_ctl_add(chip->card,
			   snd_ctl_new1(&lola_input_src_mixer, chip));
}
Example #27
0
/*!
  * This function registers the control components of ALSA Mixer
  * It is called by ALSA PCM init.
  *
  * @param	card pointer to the ALSA sound card structure.
  *
  * @return              0 on success, -ve otherwise.
  */
int __devinit mxc_alsa_create_ctl(struct snd_card *card, void *p_value)
{
	int err = 0;

	err = snd_ctl_add(card, snd_ctl_new1(&pmic_control_op_sw, p_value));
	if (err < 0)
		return err;

	err = snd_ctl_add(card, snd_ctl_new1(&pmic_control_pb_vol, p_value));
	if (err < 0)
		return err;

	err = snd_ctl_add(card, snd_ctl_new1(&pmic_control_pb_monoconfig, p_value));
	if (err < 0)
		return err;

	err = snd_ctl_add(card, snd_ctl_new1(&pmic_control_pb_bal, p_value));
	if (err < 0)
		return err;

	err = snd_ctl_add(card, snd_ctl_new1(&pmic_control_cap_vol, p_value));
	if (err < 0)
		return err;

	err = snd_ctl_add(card, snd_ctl_new1(&pmic_control_ip_sw, p_value));
	if (err < 0)
		return err;

	err = snd_ctl_add(card, snd_ctl_new1(&pmic_control_loop_out, p_value));
	if (err < 0)
		return err;

	return 0;
}
Example #28
0
/* Initialize beep stuff */
int snd_pmac_attach_beep(struct snd_pmac *chip)
{
	struct pmac_beep *beep;
	struct input_dev *input_dev;
	struct snd_kcontrol *beep_ctl;
	void *dmabuf;
	int err = -ENOMEM;

	beep = kzalloc(sizeof(*beep), GFP_KERNEL);
	if (! beep)
		return -ENOMEM;
	dmabuf = dma_alloc_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
				    &beep->addr, GFP_KERNEL);
	input_dev = input_allocate_device();
	if (! dmabuf || ! input_dev)
		goto fail1;

	/* FIXME: set more better values */
	input_dev->name = "PowerMac Beep";
	input_dev->phys = "powermac/beep";
	input_dev->id.bustype = BUS_ADB;
	input_dev->id.vendor = 0x001f;
	input_dev->id.product = 0x0001;
	input_dev->id.version = 0x0100;

	input_dev->evbit[0] = BIT_MASK(EV_SND);
	input_dev->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE);
	input_dev->event = snd_pmac_beep_event;
	input_dev->dev.parent = &chip->pdev->dev;
	input_set_drvdata(input_dev, chip);

	beep->dev = input_dev;
	beep->buf = dmabuf;
	beep->volume = BEEP_VOLUME;
	beep->running = 0;

	beep_ctl = snd_ctl_new1(&snd_pmac_beep_mixer, chip);
	err = snd_ctl_add(chip->card, beep_ctl);
	if (err < 0)
		goto fail1;

	chip->beep = beep;

	err = input_register_device(beep->dev);
	if (err)
		goto fail2;
 
 	return 0;
 
 fail2:	snd_ctl_remove(chip->card, beep_ctl);
 fail1:	input_free_device(input_dev);
	if (dmabuf)
		dma_free_coherent(&chip->pdev->dev, BEEP_BUFLEN * 4,
				  dmabuf, beep->addr);
	kfree(beep);
	return err;
}
Example #29
0
static int _add_volume(struct hda_codec *codec, hda_nid_t nid, const char *pfx,
		       int chan, int dir)
{
	char namestr[44];
	int type = dir ? HDA_INPUT : HDA_OUTPUT;
	struct snd_kcontrol_new knew =
		HDA_CODEC_VOLUME_MONO(namestr, nid, chan, 0, type);
	sprintf(namestr, "%s %s Volume", pfx, dirstr[dir]);
	return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec));
}
Example #30
0
static int __devinit phase28_add_controls(struct snd_ice1712 *ice)
{
	unsigned int i, counts;
	int err;

	counts = ARRAY_SIZE(phase28_dac_controls);
	for (i = 0; i < counts; i++) {
		err = snd_ctl_add(ice->card, snd_ctl_new1(&phase28_dac_controls[i], ice));
		if (err < 0)
			return err;
	}

	for (i = 0; i < ARRAY_SIZE(wm_controls); i++) {
		err = snd_ctl_add(ice->card, snd_ctl_new1(&wm_controls[i], ice));
		if (err < 0)
			return err;
	}

	return 0;
}