wm8971.c (cf0dbba515415bb19b11f9323d5f7bebd7f24fd6) | wm8971.c (b2c812e22de88bb79c290c0e718280f10b64a48d) |
---|---|
1/* 2 * wm8971.c -- WM8971 ALSA SoC Audio driver 3 * 4 * Copyright 2005 Lab126, Inc. 5 * 6 * Author: Kenneth Kiraly <kiraly@lab126.com> 7 * 8 * Based on wm8753.c by Liam Girdwood --- 6 unchanged lines hidden (view full) --- 15 16#include <linux/module.h> 17#include <linux/moduleparam.h> 18#include <linux/init.h> 19#include <linux/delay.h> 20#include <linux/pm.h> 21#include <linux/i2c.h> 22#include <linux/platform_device.h> | 1/* 2 * wm8971.c -- WM8971 ALSA SoC Audio driver 3 * 4 * Copyright 2005 Lab126, Inc. 5 * 6 * Author: Kenneth Kiraly <kiraly@lab126.com> 7 * 8 * Based on wm8753.c by Liam Girdwood --- 6 unchanged lines hidden (view full) --- 15 16#include <linux/module.h> 17#include <linux/moduleparam.h> 18#include <linux/init.h> 19#include <linux/delay.h> 20#include <linux/pm.h> 21#include <linux/i2c.h> 22#include <linux/platform_device.h> |
23#include <linux/slab.h> | |
24#include <sound/core.h> 25#include <sound/pcm.h> 26#include <sound/pcm_params.h> 27#include <sound/soc.h> 28#include <sound/soc-dapm.h> 29#include <sound/initval.h> 30 31#include "wm8971.h" --- 378 unchanged lines hidden (view full) --- 410 } 411 return -EINVAL; 412} 413 414static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, 415 int clk_id, unsigned int freq, int dir) 416{ 417 struct snd_soc_codec *codec = codec_dai->codec; | 23#include <sound/core.h> 24#include <sound/pcm.h> 25#include <sound/pcm_params.h> 26#include <sound/soc.h> 27#include <sound/soc-dapm.h> 28#include <sound/initval.h> 29 30#include "wm8971.h" --- 378 unchanged lines hidden (view full) --- 409 } 410 return -EINVAL; 411} 412 413static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, 414 int clk_id, unsigned int freq, int dir) 415{ 416 struct snd_soc_codec *codec = codec_dai->codec; |
418 struct wm8971_priv *wm8971 = codec->private_data; | 417 struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); |
419 420 switch (freq) { 421 case 11289600: 422 case 12000000: 423 case 12288000: 424 case 16934400: 425 case 18432000: 426 wm8971->sysclk = freq; --- 62 unchanged lines hidden (view full) --- 489 490static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, 491 struct snd_pcm_hw_params *params, 492 struct snd_soc_dai *dai) 493{ 494 struct snd_soc_pcm_runtime *rtd = substream->private_data; 495 struct snd_soc_device *socdev = rtd->socdev; 496 struct snd_soc_codec *codec = socdev->card->codec; | 418 419 switch (freq) { 420 case 11289600: 421 case 12000000: 422 case 12288000: 423 case 16934400: 424 case 18432000: 425 wm8971->sysclk = freq; --- 62 unchanged lines hidden (view full) --- 488 489static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, 490 struct snd_pcm_hw_params *params, 491 struct snd_soc_dai *dai) 492{ 493 struct snd_soc_pcm_runtime *rtd = substream->private_data; 494 struct snd_soc_device *socdev = rtd->socdev; 495 struct snd_soc_codec *codec = socdev->card->codec; |
497 struct wm8971_priv *wm8971 = codec->private_data; | 496 struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); |
498 u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3; 499 u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0; 500 int coeff = get_coeff(wm8971->sysclk, params_rate(params)); 501 502 /* bit size */ 503 switch (params_format(params)) { 504 case SNDRV_PCM_FORMAT_S16_LE: 505 break; --- 309 unchanged lines hidden (view full) --- 815 return -ENOMEM; 816 817 wm8971 = kzalloc(sizeof(struct wm8971_priv), GFP_KERNEL); 818 if (wm8971 == NULL) { 819 kfree(codec); 820 return -ENOMEM; 821 } 822 | 497 u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3; 498 u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0; 499 int coeff = get_coeff(wm8971->sysclk, params_rate(params)); 500 501 /* bit size */ 502 switch (params_format(params)) { 503 case SNDRV_PCM_FORMAT_S16_LE: 504 break; --- 309 unchanged lines hidden (view full) --- 814 return -ENOMEM; 815 816 wm8971 = kzalloc(sizeof(struct wm8971_priv), GFP_KERNEL); 817 if (wm8971 == NULL) { 818 kfree(codec); 819 return -ENOMEM; 820 } 821 |
823 codec->private_data = wm8971; | 822 snd_soc_codec_set_drvdata(codec, wm8971); |
824 socdev->card->codec = codec; 825 mutex_init(&codec->mutex); 826 INIT_LIST_HEAD(&codec->dapm_widgets); 827 INIT_LIST_HEAD(&codec->dapm_paths); 828 wm8971_socdev = socdev; 829 830 INIT_DELAYED_WORK(&codec->delayed_work, wm8971_work); 831 wm8971_workq = create_workqueue("wm8971"); 832 if (wm8971_workq == NULL) { | 823 socdev->card->codec = codec; 824 mutex_init(&codec->mutex); 825 INIT_LIST_HEAD(&codec->dapm_widgets); 826 INIT_LIST_HEAD(&codec->dapm_paths); 827 wm8971_socdev = socdev; 828 829 INIT_DELAYED_WORK(&codec->delayed_work, wm8971_work); 830 wm8971_workq = create_workqueue("wm8971"); 831 if (wm8971_workq == NULL) { |
833 kfree(codec->private_data); | 832 kfree(snd_soc_codec_get_drvdata(codec)); |
834 kfree(codec); 835 return -ENOMEM; 836 } 837 838#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 839 if (setup->i2c_address) { 840 ret = wm8971_add_i2c_device(pdev, setup); 841 } 842#endif 843 /* Add other interfaces here */ 844 845 if (ret != 0) { 846 destroy_workqueue(wm8971_workq); | 833 kfree(codec); 834 return -ENOMEM; 835 } 836 837#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 838 if (setup->i2c_address) { 839 ret = wm8971_add_i2c_device(pdev, setup); 840 } 841#endif 842 /* Add other interfaces here */ 843 844 if (ret != 0) { 845 destroy_workqueue(wm8971_workq); |
847 kfree(codec->private_data); | 846 kfree(snd_soc_codec_get_drvdata(codec)); |
848 kfree(codec); 849 } 850 851 return ret; 852} 853 854/* power down chip */ 855static int wm8971_remove(struct platform_device *pdev) --- 6 unchanged lines hidden (view full) --- 862 if (wm8971_workq) 863 destroy_workqueue(wm8971_workq); 864 snd_soc_free_pcms(socdev); 865 snd_soc_dapm_free(socdev); 866#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 867 i2c_unregister_device(codec->control_data); 868 i2c_del_driver(&wm8971_i2c_driver); 869#endif | 847 kfree(codec); 848 } 849 850 return ret; 851} 852 853/* power down chip */ 854static int wm8971_remove(struct platform_device *pdev) --- 6 unchanged lines hidden (view full) --- 861 if (wm8971_workq) 862 destroy_workqueue(wm8971_workq); 863 snd_soc_free_pcms(socdev); 864 snd_soc_dapm_free(socdev); 865#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE) 866 i2c_unregister_device(codec->control_data); 867 i2c_del_driver(&wm8971_i2c_driver); 868#endif |
870 kfree(codec->private_data); | 869 kfree(snd_soc_codec_get_drvdata(codec)); |
871 kfree(codec); 872 873 return 0; 874} 875 876struct snd_soc_codec_device soc_codec_dev_wm8971 = { 877 .probe = wm8971_probe, 878 .remove = wm8971_remove, --- 21 unchanged lines hidden --- | 870 kfree(codec); 871 872 return 0; 873} 874 875struct snd_soc_codec_device soc_codec_dev_wm8971 = { 876 .probe = wm8971_probe, 877 .remove = wm8971_remove, --- 21 unchanged lines hidden --- |