ak4535.c (cf0dbba515415bb19b11f9323d5f7bebd7f24fd6) | ak4535.c (b2c812e22de88bb79c290c0e718280f10b64a48d) |
---|---|
1/* 2 * ak4535.c -- AK4535 ALSA Soc Audio driver 3 * 4 * Copyright 2005 Openedhand Ltd. 5 * 6 * Author: Richard Purdie <richard@openedhand.com> 7 * 8 * Based on wm8753.c by Liam Girdwood --- 5 unchanged lines hidden (view full) --- 14 15#include <linux/module.h> 16#include <linux/moduleparam.h> 17#include <linux/init.h> 18#include <linux/delay.h> 19#include <linux/pm.h> 20#include <linux/i2c.h> 21#include <linux/platform_device.h> | 1/* 2 * ak4535.c -- AK4535 ALSA Soc Audio driver 3 * 4 * Copyright 2005 Openedhand Ltd. 5 * 6 * Author: Richard Purdie <richard@openedhand.com> 7 * 8 * Based on wm8753.c by Liam Girdwood --- 5 unchanged lines hidden (view full) --- 14 15#include <linux/module.h> 16#include <linux/moduleparam.h> 17#include <linux/init.h> 18#include <linux/delay.h> 19#include <linux/pm.h> 20#include <linux/i2c.h> 21#include <linux/platform_device.h> |
22#include <linux/slab.h> | |
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 "ak4535.h" --- 266 unchanged lines hidden (view full) --- 297 298 return 0; 299} 300 301static int ak4535_set_dai_sysclk(struct snd_soc_dai *codec_dai, 302 int clk_id, unsigned int freq, int dir) 303{ 304 struct snd_soc_codec *codec = codec_dai->codec; | 22#include <sound/core.h> 23#include <sound/pcm.h> 24#include <sound/pcm_params.h> 25#include <sound/soc.h> 26#include <sound/soc-dapm.h> 27#include <sound/initval.h> 28 29#include "ak4535.h" --- 266 unchanged lines hidden (view full) --- 296 297 return 0; 298} 299 300static int ak4535_set_dai_sysclk(struct snd_soc_dai *codec_dai, 301 int clk_id, unsigned int freq, int dir) 302{ 303 struct snd_soc_codec *codec = codec_dai->codec; |
305 struct ak4535_priv *ak4535 = codec->private_data; | 304 struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec); |
306 307 ak4535->sysclk = freq; 308 return 0; 309} 310 311static int ak4535_hw_params(struct snd_pcm_substream *substream, 312 struct snd_pcm_hw_params *params, 313 struct snd_soc_dai *dai) 314{ 315 struct snd_soc_pcm_runtime *rtd = substream->private_data; 316 struct snd_soc_device *socdev = rtd->socdev; 317 struct snd_soc_codec *codec = socdev->card->codec; | 305 306 ak4535->sysclk = freq; 307 return 0; 308} 309 310static int ak4535_hw_params(struct snd_pcm_substream *substream, 311 struct snd_pcm_hw_params *params, 312 struct snd_soc_dai *dai) 313{ 314 struct snd_soc_pcm_runtime *rtd = substream->private_data; 315 struct snd_soc_device *socdev = rtd->socdev; 316 struct snd_soc_codec *codec = socdev->card->codec; |
318 struct ak4535_priv *ak4535 = codec->private_data; | 317 struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec); |
319 u8 mode2 = ak4535_read_reg_cache(codec, AK4535_MODE2) & ~(0x3 << 5); 320 int rate = params_rate(params), fs = 256; 321 322 if (rate) 323 fs = ak4535->sysclk / rate; 324 325 /* set fs */ 326 switch (fs) { --- 268 unchanged lines hidden (view full) --- 595 return -ENOMEM; 596 597 ak4535 = kzalloc(sizeof(struct ak4535_priv), GFP_KERNEL); 598 if (ak4535 == NULL) { 599 kfree(codec); 600 return -ENOMEM; 601 } 602 | 318 u8 mode2 = ak4535_read_reg_cache(codec, AK4535_MODE2) & ~(0x3 << 5); 319 int rate = params_rate(params), fs = 256; 320 321 if (rate) 322 fs = ak4535->sysclk / rate; 323 324 /* set fs */ 325 switch (fs) { --- 268 unchanged lines hidden (view full) --- 594 return -ENOMEM; 595 596 ak4535 = kzalloc(sizeof(struct ak4535_priv), GFP_KERNEL); 597 if (ak4535 == NULL) { 598 kfree(codec); 599 return -ENOMEM; 600 } 601 |
603 codec->private_data = ak4535; | 602 snd_soc_codec_set_drvdata(codec, ak4535); |
604 socdev->card->codec = codec; 605 mutex_init(&codec->mutex); 606 INIT_LIST_HEAD(&codec->dapm_widgets); 607 INIT_LIST_HEAD(&codec->dapm_paths); 608 609 ak4535_socdev = socdev; 610 ret = -ENODEV; 611 612#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 613 if (setup->i2c_address) { 614 codec->hw_write = (hw_write_t)i2c_master_send; 615 ret = ak4535_add_i2c_device(pdev, setup); 616 } 617#endif 618 619 if (ret != 0) { | 603 socdev->card->codec = codec; 604 mutex_init(&codec->mutex); 605 INIT_LIST_HEAD(&codec->dapm_widgets); 606 INIT_LIST_HEAD(&codec->dapm_paths); 607 608 ak4535_socdev = socdev; 609 ret = -ENODEV; 610 611#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 612 if (setup->i2c_address) { 613 codec->hw_write = (hw_write_t)i2c_master_send; 614 ret = ak4535_add_i2c_device(pdev, setup); 615 } 616#endif 617 618 if (ret != 0) { |
620 kfree(codec->private_data); | 619 kfree(snd_soc_codec_get_drvdata(codec)); |
621 kfree(codec); 622 } 623 return ret; 624} 625 626/* power down chip */ 627static int ak4535_remove(struct platform_device *pdev) 628{ --- 5 unchanged lines hidden (view full) --- 634 635 snd_soc_free_pcms(socdev); 636 snd_soc_dapm_free(socdev); 637#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 638 if (codec->control_data) 639 i2c_unregister_device(codec->control_data); 640 i2c_del_driver(&ak4535_i2c_driver); 641#endif | 620 kfree(codec); 621 } 622 return ret; 623} 624 625/* power down chip */ 626static int ak4535_remove(struct platform_device *pdev) 627{ --- 5 unchanged lines hidden (view full) --- 633 634 snd_soc_free_pcms(socdev); 635 snd_soc_dapm_free(socdev); 636#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) 637 if (codec->control_data) 638 i2c_unregister_device(codec->control_data); 639 i2c_del_driver(&ak4535_i2c_driver); 640#endif |
642 kfree(codec->private_data); | 641 kfree(snd_soc_codec_get_drvdata(codec)); |
643 kfree(codec); 644 645 return 0; 646} 647 648struct snd_soc_codec_device soc_codec_dev_ak4535 = { 649 .probe = ak4535_probe, 650 .remove = ak4535_remove, --- 20 unchanged lines hidden --- | 642 kfree(codec); 643 644 return 0; 645} 646 647struct snd_soc_codec_device soc_codec_dev_ak4535 = { 648 .probe = ak4535_probe, 649 .remove = ak4535_remove, --- 20 unchanged lines hidden --- |