wm8731.c (cea82d8af3986508a05949cfbb6ad8e99ffc15eb) | wm8731.c (a51ff30f45473a80f78b2572666473887e010d91) |
---|---|
1/* 2 * wm8731.c -- WM8731 ALSA SoC Audio driver 3 * 4 * Copyright 2005 Openedhand Ltd. 5 * Copyright 2006-12 Wolfson Microelectronics, plc 6 * 7 * Author: Richard Purdie <richard@openedhand.com> 8 * --- 10 unchanged lines hidden (view full) --- 19#include <linux/delay.h> 20#include <linux/pm.h> 21#include <linux/i2c.h> 22#include <linux/slab.h> 23#include <linux/regmap.h> 24#include <linux/regulator/consumer.h> 25#include <linux/spi/spi.h> 26#include <linux/of_device.h> | 1/* 2 * wm8731.c -- WM8731 ALSA SoC Audio driver 3 * 4 * Copyright 2005 Openedhand Ltd. 5 * Copyright 2006-12 Wolfson Microelectronics, plc 6 * 7 * Author: Richard Purdie <richard@openedhand.com> 8 * --- 10 unchanged lines hidden (view full) --- 19#include <linux/delay.h> 20#include <linux/pm.h> 21#include <linux/i2c.h> 22#include <linux/slab.h> 23#include <linux/regmap.h> 24#include <linux/regulator/consumer.h> 25#include <linux/spi/spi.h> 26#include <linux/of_device.h> |
27#include <linux/mutex.h> |
|
27#include <sound/core.h> 28#include <sound/pcm.h> 29#include <sound/pcm_params.h> 30#include <sound/soc.h> 31#include <sound/initval.h> 32#include <sound/tlv.h> 33 34#include "wm8731.h" --- 10 unchanged lines hidden (view full) --- 45struct wm8731_priv { 46 struct regmap *regmap; 47 struct regulator_bulk_data supplies[WM8731_NUM_SUPPLIES]; 48 const struct snd_pcm_hw_constraint_list *constraints; 49 unsigned int sysclk; 50 int sysclk_type; 51 int playback_fs; 52 bool deemph; | 28#include <sound/core.h> 29#include <sound/pcm.h> 30#include <sound/pcm_params.h> 31#include <sound/soc.h> 32#include <sound/initval.h> 33#include <sound/tlv.h> 34 35#include "wm8731.h" --- 10 unchanged lines hidden (view full) --- 46struct wm8731_priv { 47 struct regmap *regmap; 48 struct regulator_bulk_data supplies[WM8731_NUM_SUPPLIES]; 49 const struct snd_pcm_hw_constraint_list *constraints; 50 unsigned int sysclk; 51 int sysclk_type; 52 int playback_fs; 53 bool deemph; |
54 55 struct mutex lock; |
|
53}; 54 55 56/* 57 * wm8731 register cache 58 */ 59static const struct reg_default wm8731_reg_defaults[] = { 60 { 0, 0x0097 }, --- 72 unchanged lines hidden (view full) --- 133 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 134 struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); 135 int deemph = ucontrol->value.enumerated.item[0]; 136 int ret = 0; 137 138 if (deemph > 1) 139 return -EINVAL; 140 | 56}; 57 58 59/* 60 * wm8731 register cache 61 */ 62static const struct reg_default wm8731_reg_defaults[] = { 63 { 0, 0x0097 }, --- 72 unchanged lines hidden (view full) --- 136 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 137 struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); 138 int deemph = ucontrol->value.enumerated.item[0]; 139 int ret = 0; 140 141 if (deemph > 1) 142 return -EINVAL; 143 |
141 mutex_lock(&codec->mutex); | 144 mutex_lock(&wm8731->lock); |
142 if (wm8731->deemph != deemph) { 143 wm8731->deemph = deemph; 144 145 wm8731_set_deemph(codec); 146 147 ret = 1; 148 } | 145 if (wm8731->deemph != deemph) { 146 wm8731->deemph = deemph; 147 148 wm8731_set_deemph(codec); 149 150 ret = 1; 151 } |
149 mutex_unlock(&codec->mutex); | 152 mutex_unlock(&wm8731->lock); |
150 151 return ret; 152} 153 154static const DECLARE_TLV_DB_SCALE(in_tlv, -3450, 150, 0); 155static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -1500, 300, 0); 156static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); 157static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 2000, 0); --- 517 unchanged lines hidden (view full) --- 675}; 676 677#if defined(CONFIG_SPI_MASTER) 678static int wm8731_spi_probe(struct spi_device *spi) 679{ 680 struct wm8731_priv *wm8731; 681 int ret; 682 | 153 154 return ret; 155} 156 157static const DECLARE_TLV_DB_SCALE(in_tlv, -3450, 150, 0); 158static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -1500, 300, 0); 159static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); 160static const DECLARE_TLV_DB_SCALE(mic_tlv, 0, 2000, 0); --- 517 unchanged lines hidden (view full) --- 678}; 679 680#if defined(CONFIG_SPI_MASTER) 681static int wm8731_spi_probe(struct spi_device *spi) 682{ 683 struct wm8731_priv *wm8731; 684 int ret; 685 |
683 wm8731 = devm_kzalloc(&spi->dev, sizeof(*wm8731), GFP_KERNEL); | 686 wm8731 = devm_kzalloc(&spi->dev, sizeof(struct wm8731_priv), 687 GFP_KERNEL); |
684 if (wm8731 == NULL) 685 return -ENOMEM; 686 | 688 if (wm8731 == NULL) 689 return -ENOMEM; 690 |
691 mutex_init(&wm8731->lock); 692 |
|
687 wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap); 688 if (IS_ERR(wm8731->regmap)) { 689 ret = PTR_ERR(wm8731->regmap); 690 dev_err(&spi->dev, "Failed to allocate register map: %d\n", 691 ret); 692 return ret; 693 } 694 --- 120 unchanged lines hidden --- | 693 wm8731->regmap = devm_regmap_init_spi(spi, &wm8731_regmap); 694 if (IS_ERR(wm8731->regmap)) { 695 ret = PTR_ERR(wm8731->regmap); 696 dev_err(&spi->dev, "Failed to allocate register map: %d\n", 697 ret); 698 return ret; 699 } 700 --- 120 unchanged lines hidden --- |