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; }
static int stac9766_codec_probe(struct snd_soc_codec *codec) { int ret = 0; printk(KERN_INFO "STAC9766 SoC Audio Codec %s\n", STAC9766_VERSION); ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); if (ret < 0) goto codec_err; /* do a cold reset for the controller and then try * a warm reset followed by an optional cold reset for codec */ stac9766_reset(codec, 0); ret = stac9766_reset(codec, 1); if (ret < 0) { printk(KERN_ERR "Failed to reset STAC9766: AC97 link error\n"); goto codec_err; } stac9766_set_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_add_controls(codec, stac9766_snd_ac97_controls, ARRAY_SIZE(stac9766_snd_ac97_controls)); return 0; codec_err: snd_soc_free_ac97_codec(codec); return ret; }
static int stac9766_codec_remove(struct snd_soc_codec *codec) { struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); snd_soc_free_ac97_codec(ac97); return 0; }
static int stac9766_codec_probe(struct snd_soc_codec *codec) { struct snd_ac97 *ac97; int ret = 0; ac97 = snd_soc_new_ac97_codec(codec); if (IS_ERR(ac97)) return PTR_ERR(ac97); snd_soc_codec_set_drvdata(codec, ac97); /* do a cold reset for the controller and then try * a warm reset followed by an optional cold reset for codec */ stac9766_reset(codec, 0); ret = stac9766_reset(codec, 1); if (ret < 0) { dev_err(codec->dev, "Failed to reset: AC97 link error\n"); goto codec_err; } return 0; codec_err: snd_soc_free_ac97_codec(ac97); return ret; }
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; }
static int ad1980_soc_probe(struct snd_soc_codec *codec) { int ret; u16 vendor_id2; u16 ext_status; printk(KERN_INFO "AD1980 SoC Audio Codec\n"); ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); if (ret < 0) { printk(KERN_ERR "ad1980: failed to register AC97 codec\n"); return ret; } ret = ad1980_reset(codec, 0); if (ret < 0) { printk(KERN_ERR "Failed to reset AD1980: AC97 link error\n"); goto reset_err; } if (ac97_read(codec, AC97_VENDOR_ID1) != 0x4144) { ret = -ENODEV; goto reset_err; } vendor_id2 = ac97_read(codec, AC97_VENDOR_ID2); if (vendor_id2 != 0x5370) { if (vendor_id2 != 0x5374) { ret = -ENODEV; goto reset_err; } else { printk(KERN_WARNING "ad1980: " "Found AD1981 - only 2/2 IN/OUT Channels " "supported\n"); } } ac97_write(codec, AC97_MASTER, 0x0000); ac97_write(codec, AC97_PCM, 0x0000); ac97_write(codec, AC97_REC_GAIN, 0x0000); ac97_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); ac97_write(codec, AC97_SURROUND_MASTER, 0x0000); ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); snd_soc_add_codec_controls(codec, ad1980_snd_ac97_controls, ARRAY_SIZE(ad1980_snd_ac97_controls)); return 0; reset_err: snd_soc_free_ac97_codec(codec); return ret; }
static int ad1980_soc_remove(struct snd_soc_codec *codec) { struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); snd_soc_codec_exit_regmap(codec); snd_soc_free_ac97_codec(ac97); return 0; }
static int wm9712_soc_remove(struct snd_soc_codec *codec) { struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); snd_soc_codec_exit_regmap(codec); snd_soc_free_ac97_codec(wm9712->ac97); return 0; }
static int ad1980_soc_probe(struct snd_soc_codec *codec) { int ret; u16 vendor_id2; u16 ext_status; ; ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); if (ret < 0) { ; return ret; } ret = ad1980_reset(codec, 0); if (ret < 0) { ; goto reset_err; } /* Read out vendor ID to make sure it is ad1980 */ if (ac97_read(codec, AC97_VENDOR_ID1) != 0x4144) goto reset_err; vendor_id2 = ac97_read(codec, AC97_VENDOR_ID2); if (vendor_id2 != 0x5370) { if (vendor_id2 != 0x5374) goto reset_err; else // printk(KERN_WARNING "ad1980: " // "Found AD1981 - only 2/2 IN/OUT Channels " ; } /* unmute captures and playbacks volume */ ac97_write(codec, AC97_MASTER, 0x0000); ac97_write(codec, AC97_PCM, 0x0000); ac97_write(codec, AC97_REC_GAIN, 0x0000); ac97_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); ac97_write(codec, AC97_SURROUND_MASTER, 0x0000); /*power on LFE/CENTER/Surround DACs*/ ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); snd_soc_add_controls(codec, ad1980_snd_ac97_controls, ARRAY_SIZE(ad1980_snd_ac97_controls)); return 0; reset_err: snd_soc_free_ac97_codec(codec); return ret; }
static int wm9712_soc_remove(struct snd_soc_codec *codec) { #ifdef CONFIG_SND_SOC_AC97_BUS struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); if (!wm9712->mfd_pdata) { snd_soc_codec_exit_regmap(codec); snd_soc_free_ac97_codec(wm9712->ac97); } #endif return 0; }
static int stac9766_codec_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = socdev->card->codec; if (codec == NULL) return 0; snd_soc_free_pcms(socdev); snd_soc_free_ac97_codec(codec); kfree(codec->reg_cache); kfree(codec); return 0; }
static int rt5611_ts_probe(struct platform_device *pdev) { struct rt5611_ts *rt; int ret = 0; RT5611_TS_DEBUG("rt5611_ts_probe\n"); rt = kzalloc(sizeof(struct rt5611_ts), GFP_KERNEL); if (!rt) return -ENOMEM; rt->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (rt->codec == NULL) return -ENOMEM; mutex_init(&rt->codec->mutex); ret = snd_soc_new_ac97_codec(rt->codec, &soc_ac97_ops, 0); if (ret < 0) goto alloc_err; rt->dev = &pdev->dev; platform_set_drvdata(pdev, rt); rt->pen_irq = platform_get_irq(pdev, 0); RT5611_TS_DEBUG("rt5611_ts: Pendown IRQ=%x\n", rt->pen_irq); rt5611_ts_reset(rt->codec, 0); /* Cold RESET */ ret = rt5611_ts_reset(rt->codec, 1); /* Warm RESET */ if (ret < 0) { printk(KERN_ERR "FAIL to reset rt5611\n"); goto reset_err; } rt->id = rt5611_ts_reg_read(rt, RT_VENDOR_ID2); RT5611_TS_DEBUG("rt5611_ts: Vendor id=%08X\n", rt->id); /* set up physical characteristics */ rt5611_ts_phy_init(rt); /* load gpio cache */ rt->input_dev = input_allocate_device(); if (rt->input_dev == NULL) { ret = -ENOMEM; goto alloc_err; } /* set up touch configuration */ rt->input_dev->name = "rt5611 touchscreen"; rt->input_dev->phys = "rt5611"; rt->input_dev->open = rt5611_ts_input_open; rt->input_dev->close = rt5611_ts_input_close; rt->input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); rt->input_dev->absbit[0] = BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | BIT_MASK(ABS_PRESSURE); rt->input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); input_set_abs_params(rt->input_dev, ABS_X, abs_x[0], abs_x[1], abs_x[2], 0); input_set_abs_params(rt->input_dev, ABS_Y, abs_y[0], abs_y[1], abs_y[2], 0); input_set_abs_params(rt->input_dev, ABS_PRESSURE, abs_p[0], abs_p[1], abs_p[2], 0); input_set_drvdata(rt->input_dev, rt); rt->input_dev->dev.parent = pdev->dev.parent; ret = input_register_device(rt->input_dev); if (ret < 0) goto dev_alloc_err; return ret; reset_err: snd_soc_free_ac97_codec(rt->codec); dev_alloc_err: input_free_device(rt->input_dev); alloc_err: kfree(rt); return ret; }
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; }
static int ad1980_soc_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; u16 vendor_id2; u16 ext_status; printk(KERN_INFO "AD1980 SoC Audio Codec\n"); socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (socdev->codec == NULL) return -ENOMEM; codec = socdev->codec; mutex_init(&codec->mutex); codec->reg_cache = kzalloc(sizeof(u16) * ARRAY_SIZE(ad1980_reg), GFP_KERNEL); if (codec->reg_cache == NULL) { ret = -ENOMEM; goto cache_err; } memcpy(codec->reg_cache, ad1980_reg, sizeof(u16) * \ ARRAY_SIZE(ad1980_reg)); codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(ad1980_reg); codec->reg_cache_step = 2; codec->name = "AD1980"; codec->owner = THIS_MODULE; codec->dai = &ad1980_dai; codec->num_dai = 1; codec->write = ac97_write; codec->read = ac97_read; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); if (ret < 0) { printk(KERN_ERR "ad1980: failed to register AC97 codec\n"); goto codec_err; } /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) goto pcm_err; ret = ad1980_reset(codec, 0); if (ret < 0) { printk(KERN_ERR "AC97 link error\n"); goto reset_err; } /* Read out vendor ID to make sure it is ad1980 */ if (ac97_read(codec, AC97_VENDOR_ID1) != 0x4144) goto reset_err; vendor_id2 = ac97_read(codec, AC97_VENDOR_ID2); if (vendor_id2 != 0x5370) { if (vendor_id2 != 0x5374) goto reset_err; else printk(KERN_WARNING "ad1980: " "Found AD1981 - only 2/2 IN/OUT Channels " "supported\n"); } /* unmute captures and playbacks volume */ ac97_write(codec, AC97_MASTER, 0x0000); ac97_write(codec, AC97_PCM, 0x0000); ac97_write(codec, AC97_REC_GAIN, 0x0000); ac97_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); ac97_write(codec, AC97_SURROUND_MASTER, 0x0000); /*power on LFE/CENTER/Surround DACs*/ ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); ad1980_add_controls(codec); ret = snd_soc_register_card(socdev); if (ret < 0) { printk(KERN_ERR "ad1980: failed to register card\n"); goto reset_err; } return 0; reset_err: snd_soc_free_pcms(socdev); pcm_err: snd_soc_free_ac97_codec(codec); codec_err: kfree(codec->reg_cache); cache_err: kfree(socdev->codec); socdev->codec = NULL; return ret; }
static int ad1980_soc_remove(struct snd_soc_codec *codec) { snd_soc_free_ac97_codec(codec); return 0; }
static int ad1980_soc_probe(struct snd_soc_codec *codec) { int ret; u16 vendor_id2; u16 ext_status; #ifdef CONFIG_DEBUG_PRINTK printk(KERN_INFO "AD1980 SoC Audio Codec\n"); #else ; #endif ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); if (ret < 0) { printk(KERN_ERR "ad1980: failed to register AC97 codec\n"); return ret; } ret = ad1980_reset(codec, 0); if (ret < 0) { printk(KERN_ERR "Failed to reset AD1980: AC97 link error\n"); goto reset_err; } /* Read out vendor ID to make sure it is ad1980 */ if (ac97_read(codec, AC97_VENDOR_ID1) != 0x4144) goto reset_err; vendor_id2 = ac97_read(codec, AC97_VENDOR_ID2); if (vendor_id2 != 0x5370) { if (vendor_id2 != 0x5374) goto reset_err; else #ifdef CONFIG_DEBUG_PRINTK printk(KERN_WARNING "ad1980: " "Found AD1981 - only 2/2 IN/OUT Channels " "supported\n"); #else ; #endif } /* unmute captures and playbacks volume */ ac97_write(codec, AC97_MASTER, 0x0000); ac97_write(codec, AC97_PCM, 0x0000); ac97_write(codec, AC97_REC_GAIN, 0x0000); ac97_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); ac97_write(codec, AC97_SURROUND_MASTER, 0x0000); /*power on LFE/CENTER/Surround DACs*/ ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); snd_soc_add_controls(codec, ad1980_snd_ac97_controls, ARRAY_SIZE(ad1980_snd_ac97_controls)); return 0; reset_err: snd_soc_free_ac97_codec(codec); return ret; }
static int stac9766_codec_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; int ret = 0; printk(KERN_INFO "STAC9766 SoC Audio Codec %s\n", STAC9766_VERSION); socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (socdev->card->codec == NULL) return -ENOMEM; codec = socdev->card->codec; mutex_init(&codec->mutex); codec->reg_cache = kmemdup(stac9766_reg, sizeof(stac9766_reg), GFP_KERNEL); if (codec->reg_cache == NULL) { ret = -ENOMEM; goto cache_err; } codec->reg_cache_size = sizeof(stac9766_reg); codec->reg_cache_step = 2; codec->name = "STAC9766"; codec->owner = THIS_MODULE; codec->dai = stac9766_dai; codec->num_dai = ARRAY_SIZE(stac9766_dai); codec->write = stac9766_ac97_write; codec->read = stac9766_ac97_read; codec->set_bias_level = stac9766_set_bias_level; INIT_LIST_HEAD(&codec->dapm_widgets); INIT_LIST_HEAD(&codec->dapm_paths); ret = snd_soc_new_ac97_codec(codec, &soc_ac97_ops, 0); if (ret < 0) goto codec_err; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) goto pcm_err; /* do a cold reset for the controller and then try * a warm reset followed by an optional cold reset for codec */ stac9766_reset(codec, 0); ret = stac9766_reset(codec, 1); if (ret < 0) { printk(KERN_ERR "Failed to reset STAC9766: AC97 link error\n"); goto reset_err; } stac9766_set_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_add_controls(codec, stac9766_snd_ac97_controls, ARRAY_SIZE(stac9766_snd_ac97_controls)); return 0; reset_err: snd_soc_free_pcms(socdev); pcm_err: snd_soc_free_ac97_codec(codec); codec_err: kfree(codec->private_data); cache_err: kfree(socdev->card->codec); socdev->card->codec = NULL; return ret; }