wm8400.c (cf0dbba515415bb19b11f9323d5f7bebd7f24fd6) | wm8400.c (b2c812e22de88bb79c290c0e718280f10b64a48d) |
---|---|
1/* 2 * wm8400.c -- WM8400 ALSA Soc Audio driver 3 * 4 * Copyright 2008, 2009 Wolfson Microelectronics PLC. 5 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the 9 * Free Software Foundation; either version 2 of the License, or (at your 10 * option) any later version. 11 * 12 */ 13 14#include <linux/module.h> 15#include <linux/moduleparam.h> 16#include <linux/kernel.h> | 1/* 2 * wm8400.c -- WM8400 ALSA Soc Audio driver 3 * 4 * Copyright 2008, 2009 Wolfson Microelectronics PLC. 5 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the 9 * Free Software Foundation; either version 2 of the License, or (at your 10 * option) any later version. 11 * 12 */ 13 14#include <linux/module.h> 15#include <linux/moduleparam.h> 16#include <linux/kernel.h> |
17#include <linux/slab.h> | |
18#include <linux/init.h> 19#include <linux/delay.h> 20#include <linux/pm.h> 21#include <linux/platform_device.h> 22#include <linux/regulator/consumer.h> 23#include <linux/mfd/wm8400-audio.h> 24#include <linux/mfd/wm8400-private.h> 25#include <sound/core.h> --- 46 unchanged lines hidden (view full) --- 72 unsigned int pcmclk; 73 struct work_struct work; 74 int fll_in, fll_out; 75}; 76 77static inline unsigned int wm8400_read(struct snd_soc_codec *codec, 78 unsigned int reg) 79{ | 17#include <linux/init.h> 18#include <linux/delay.h> 19#include <linux/pm.h> 20#include <linux/platform_device.h> 21#include <linux/regulator/consumer.h> 22#include <linux/mfd/wm8400-audio.h> 23#include <linux/mfd/wm8400-private.h> 24#include <sound/core.h> --- 46 unchanged lines hidden (view full) --- 71 unsigned int pcmclk; 72 struct work_struct work; 73 int fll_in, fll_out; 74}; 75 76static inline unsigned int wm8400_read(struct snd_soc_codec *codec, 77 unsigned int reg) 78{ |
80 struct wm8400_priv *wm8400 = codec->private_data; | 79 struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
81 82 if (reg == WM8400_INTDRIVBITS) 83 return wm8400->fake_register; 84 else 85 return wm8400_reg_read(wm8400->wm8400, reg); 86} 87 88/* 89 * write to the wm8400 register space 90 */ 91static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg, 92 unsigned int value) 93{ | 80 81 if (reg == WM8400_INTDRIVBITS) 82 return wm8400->fake_register; 83 else 84 return wm8400_reg_read(wm8400->wm8400, reg); 85} 86 87/* 88 * write to the wm8400 register space 89 */ 90static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg, 91 unsigned int value) 92{ |
94 struct wm8400_priv *wm8400 = codec->private_data; | 93 struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
95 96 if (reg == WM8400_INTDRIVBITS) { 97 wm8400->fake_register = value; 98 return 0; 99 } else 100 return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); 101} 102 103static void wm8400_codec_reset(struct snd_soc_codec *codec) 104{ | 94 95 if (reg == WM8400_INTDRIVBITS) { 96 wm8400->fake_register = value; 97 return 0; 98 } else 99 return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); 100} 101 102static void wm8400_codec_reset(struct snd_soc_codec *codec) 103{ |
105 struct wm8400_priv *wm8400 = codec->private_data; | 104 struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
106 107 wm8400_reset_codec_reg_cache(wm8400->wm8400); 108} 109 110static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600); 111 112static const DECLARE_TLV_DB_LINEAR(in_pga_tlv, -1650, 3000); 113 --- 807 unchanged lines hidden (view full) --- 921 922/* 923 * Clock after FLL and dividers 924 */ 925static int wm8400_set_dai_sysclk(struct snd_soc_dai *codec_dai, 926 int clk_id, unsigned int freq, int dir) 927{ 928 struct snd_soc_codec *codec = codec_dai->codec; | 105 106 wm8400_reset_codec_reg_cache(wm8400->wm8400); 107} 108 109static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv, -1500, 600); 110 111static const DECLARE_TLV_DB_LINEAR(in_pga_tlv, -1650, 3000); 112 --- 807 unchanged lines hidden (view full) --- 920 921/* 922 * Clock after FLL and dividers 923 */ 924static int wm8400_set_dai_sysclk(struct snd_soc_dai *codec_dai, 925 int clk_id, unsigned int freq, int dir) 926{ 927 struct snd_soc_codec *codec = codec_dai->codec; |
929 struct wm8400_priv *wm8400 = codec->private_data; | 928 struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
930 931 wm8400->sysclk = freq; 932 return 0; 933} 934 935struct fll_factors { 936 u16 n; 937 u16 k; --- 72 unchanged lines hidden (view full) --- 1010 return 0; 1011} 1012 1013static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 1014 int source, unsigned int freq_in, 1015 unsigned int freq_out) 1016{ 1017 struct snd_soc_codec *codec = codec_dai->codec; | 929 930 wm8400->sysclk = freq; 931 return 0; 932} 933 934struct fll_factors { 935 u16 n; 936 u16 k; --- 72 unchanged lines hidden (view full) --- 1009 return 0; 1010} 1011 1012static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, 1013 int source, unsigned int freq_in, 1014 unsigned int freq_out) 1015{ 1016 struct snd_soc_codec *codec = codec_dai->codec; |
1018 struct wm8400_priv *wm8400 = codec->private_data; | 1017 struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
1019 struct fll_factors factors; 1020 int ret; 1021 u16 reg; 1022 1023 if (freq_in == wm8400->fll_in && freq_out == wm8400->fll_out) 1024 return 0; 1025 1026 if (freq_out) { --- 172 unchanged lines hidden (view full) --- 1199 1200 return 0; 1201} 1202 1203/* TODO: set bias for best performance at standby */ 1204static int wm8400_set_bias_level(struct snd_soc_codec *codec, 1205 enum snd_soc_bias_level level) 1206{ | 1018 struct fll_factors factors; 1019 int ret; 1020 u16 reg; 1021 1022 if (freq_in == wm8400->fll_in && freq_out == wm8400->fll_out) 1023 return 0; 1024 1025 if (freq_out) { --- 172 unchanged lines hidden (view full) --- 1198 1199 return 0; 1200} 1201 1202/* TODO: set bias for best performance at standby */ 1203static int wm8400_set_bias_level(struct snd_soc_codec *codec, 1204 enum snd_soc_bias_level level) 1205{ |
1207 struct wm8400_priv *wm8400 = codec->private_data; | 1206 struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
1208 u16 val; 1209 int ret; 1210 1211 switch (level) { 1212 case SND_SOC_BIAS_ON: 1213 break; 1214 1215 case SND_SOC_BIAS_PREPARE: --- 246 unchanged lines hidden (view full) --- 1462 u16 reg; 1463 struct snd_soc_codec *codec; 1464 1465 priv = kzalloc(sizeof(struct wm8400_priv), GFP_KERNEL); 1466 if (priv == NULL) 1467 return -ENOMEM; 1468 1469 codec = &priv->codec; | 1207 u16 val; 1208 int ret; 1209 1210 switch (level) { 1211 case SND_SOC_BIAS_ON: 1212 break; 1213 1214 case SND_SOC_BIAS_PREPARE: --- 246 unchanged lines hidden (view full) --- 1461 u16 reg; 1462 struct snd_soc_codec *codec; 1463 1464 priv = kzalloc(sizeof(struct wm8400_priv), GFP_KERNEL); 1465 if (priv == NULL) 1466 return -ENOMEM; 1467 1468 codec = &priv->codec; |
1470 codec->private_data = priv; | 1469 snd_soc_codec_set_drvdata(codec, priv); |
1471 codec->control_data = dev_get_drvdata(&dev->dev); 1472 priv->wm8400 = dev_get_drvdata(&dev->dev); 1473 1474 ret = regulator_bulk_get(priv->wm8400->dev, 1475 ARRAY_SIZE(power), &power[0]); 1476 if (ret != 0) { 1477 dev_err(&dev->dev, "Failed to get regulators: %d\n", ret); 1478 goto err; --- 46 unchanged lines hidden (view full) --- 1525 regulator_bulk_free(ARRAY_SIZE(power), power); 1526err: 1527 kfree(priv); 1528 return ret; 1529} 1530 1531static int __exit wm8400_codec_remove(struct platform_device *dev) 1532{ | 1470 codec->control_data = dev_get_drvdata(&dev->dev); 1471 priv->wm8400 = dev_get_drvdata(&dev->dev); 1472 1473 ret = regulator_bulk_get(priv->wm8400->dev, 1474 ARRAY_SIZE(power), &power[0]); 1475 if (ret != 0) { 1476 dev_err(&dev->dev, "Failed to get regulators: %d\n", ret); 1477 goto err; --- 46 unchanged lines hidden (view full) --- 1524 regulator_bulk_free(ARRAY_SIZE(power), power); 1525err: 1526 kfree(priv); 1527 return ret; 1528} 1529 1530static int __exit wm8400_codec_remove(struct platform_device *dev) 1531{ |
1533 struct wm8400_priv *priv = wm8400_codec->private_data; | 1532 struct wm8400_priv *priv = snd_soc_codec_get_drvdata(wm8400_codec); |
1534 u16 reg; 1535 1536 snd_soc_unregister_dai(&wm8400_dai); 1537 snd_soc_unregister_codec(wm8400_codec); 1538 1539 reg = wm8400_read(wm8400_codec, WM8400_POWER_MANAGEMENT_1); 1540 wm8400_write(wm8400_codec, WM8400_POWER_MANAGEMENT_1, 1541 reg & (~WM8400_CODEC_ENA)); --- 36 unchanged lines hidden --- | 1533 u16 reg; 1534 1535 snd_soc_unregister_dai(&wm8400_dai); 1536 snd_soc_unregister_codec(wm8400_codec); 1537 1538 reg = wm8400_read(wm8400_codec, WM8400_POWER_MANAGEMENT_1); 1539 wm8400_write(wm8400_codec, WM8400_POWER_MANAGEMENT_1, 1540 reg & (~WM8400_CODEC_ENA)); --- 36 unchanged lines hidden --- |