Beispiel #1
0
static int wm9712_soc_probe(struct snd_soc_codec *codec)
{
	struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
	struct regmap *regmap;
	int ret;

	if (wm9712->mfd_pdata) {
		wm9712->ac97 = wm9712->mfd_pdata->ac97;
		regmap = wm9712->mfd_pdata->regmap;
	} else {
#ifdef CONFIG_SND_SOC_AC97_BUS
		wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID,
						      WM9712_VENDOR_ID_MASK);
		if (IS_ERR(wm9712->ac97)) {
			ret = PTR_ERR(wm9712->ac97);
			dev_err(codec->dev,
				"Failed to register AC97 codec: %d\n", ret);
			return ret;
		}

		regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config);
		if (IS_ERR(regmap)) {
			snd_soc_free_ac97_codec(wm9712->ac97);
			return PTR_ERR(regmap);
		}
#endif
	}

	snd_soc_codec_init_regmap(codec, regmap);

	/* set alc mux to none */
	snd_soc_update_bits(codec, AC97_VIDEO, 0x3000, 0x3000);

	return 0;
}
Beispiel #2
0
static int wm9712_soc_probe(struct snd_soc_codec *codec)
{
	struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec);
	struct regmap *regmap;
	int ret;

	wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID,
		WM9712_VENDOR_ID_MASK);
	if (IS_ERR(wm9712->ac97)) {
		ret = PTR_ERR(wm9712->ac97);
		dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
		return ret;
	}

	regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config);
	if (IS_ERR(regmap)) {
		ret = PTR_ERR(regmap);
		goto err_free_ac97_codec;
	}

	snd_soc_codec_init_regmap(codec, regmap);

	/* set alc mux to none */
	snd_soc_update_bits(codec, AC97_VIDEO, 0x3000, 0x3000);

	return 0;
err_free_ac97_codec:
	snd_soc_free_ac97_codec(wm9712->ac97);
	return ret;
}
Beispiel #3
0
static int ad1980_soc_probe(struct snd_soc_component *component)
{
	struct snd_ac97 *ac97;
	struct regmap *regmap;
	int ret;
	u16 vendor_id2;
	u16 ext_status;

	ac97 = snd_soc_new_ac97_component(component, 0, 0);
	if (IS_ERR(ac97)) {
		ret = PTR_ERR(ac97);
		dev_err(component->dev, "Failed to register AC97 component: %d\n", ret);
		return ret;
	}

	regmap = regmap_init_ac97(ac97, &ad1980_regmap_config);
	if (IS_ERR(regmap)) {
		ret = PTR_ERR(regmap);
		goto err_free_ac97;
	}

	snd_soc_component_init_regmap(component, regmap);
	snd_soc_component_set_drvdata(component, ac97);

	ret = ad1980_reset(component, 0);
	if (ret < 0)
		goto reset_err;

	vendor_id2 = snd_soc_component_read32(component, AC97_VENDOR_ID2);
	if (vendor_id2 == 0x5374) {
		dev_warn(component->dev,
			"Found AD1981 - only 2/2 IN/OUT Channels supported\n");
	}

	/* unmute captures and playbacks volume */
	snd_soc_component_write(component, AC97_MASTER, 0x0000);
	snd_soc_component_write(component, AC97_PCM, 0x0000);
	snd_soc_component_write(component, AC97_REC_GAIN, 0x0000);
	snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, 0x0000);
	snd_soc_component_write(component, AC97_SURROUND_MASTER, 0x0000);

	/*power on LFE/CENTER/Surround DACs*/
	ext_status = snd_soc_component_read32(component, AC97_EXTENDED_STATUS);
	snd_soc_component_write(component, AC97_EXTENDED_STATUS, ext_status&~0x3800);

	return 0;

reset_err:
	snd_soc_component_exit_regmap(component);
err_free_ac97:
	snd_soc_free_ac97_component(ac97);
	return ret;
}
Beispiel #4
0
static int ad1980_soc_probe(struct snd_soc_codec *codec)
{
    struct snd_ac97 *ac97;
    struct regmap *regmap;
    int ret;
    u16 vendor_id2;
    u16 ext_status;

    ac97 = snd_soc_new_ac97_codec(codec);
    if (IS_ERR(ac97)) {
        ret = PTR_ERR(ac97);
        dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret);
        return ret;
    }

    regmap = regmap_init_ac97(ac97, &ad1980_regmap_config);
    if (IS_ERR(regmap)) {
        ret = PTR_ERR(regmap);
        goto err_free_ac97;
    }

    snd_soc_codec_init_regmap(codec, regmap);
    snd_soc_codec_set_drvdata(codec, ac97);

    ret = ad1980_reset(codec, 0);
    if (ret < 0)
        goto reset_err;

    /* Read out vendor ID to make sure it is ad1980 */
    if (snd_soc_read(codec, AC97_VENDOR_ID1) != 0x4144) {
        ret = -ENODEV;
        goto reset_err;
    }

    vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2);

    if (vendor_id2 != 0x5370) {
        if (vendor_id2 != 0x5374) {
            ret = -ENODEV;
            goto reset_err;
        } else {
            dev_warn(codec->dev,
                     "Found AD1981 - only 2/2 IN/OUT Channels supported\n");
        }
    }

    /* unmute captures and playbacks volume */
    snd_soc_write(codec, AC97_MASTER, 0x0000);
    snd_soc_write(codec, AC97_PCM, 0x0000);
    snd_soc_write(codec, AC97_REC_GAIN, 0x0000);
    snd_soc_write(codec, AC97_CENTER_LFE_MASTER, 0x0000);
    snd_soc_write(codec, AC97_SURROUND_MASTER, 0x0000);

    /*power on LFE/CENTER/Surround DACs*/
    ext_status = snd_soc_read(codec, AC97_EXTENDED_STATUS);
    snd_soc_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800);

    return 0;

reset_err:
    snd_soc_codec_exit_regmap(codec);
err_free_ac97:
    snd_soc_free_ac97_codec(ac97);
    return ret;
}