ASoC: WCD9330: Add initial driver for WCD9330 codec

Add codec driver for WCD9330 audio codec. This driver
is an ALSA-compliant and constructs the internal codec
audio paths with DAPM widgets and controls. Provides the
controls to the upper layers to enable and configure
audio paths.

Change-Id: If0832f3dd7dc671d7a61a43a7a8683106ad84973
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
This commit is contained in:
Phani Kumar Uppalapati 2013-12-12 16:45:24 -08:00
parent 01f3b4c624
commit 59278338b1
6 changed files with 10573 additions and 1 deletions

File diff suppressed because it is too large Load diff

View file

@ -364,9 +364,12 @@ config SND_SOC_WCD9320
config SND_SOC_WCD9306
tristate
config SND_SOC_WCD9330
tristate
config SND_SOC_WCD9XXX
tristate
default y if SND_SOC_WCD9320=y || SND_SOC_WCD9306=y
default y if SND_SOC_WCD9320=y || SND_SOC_WCD9306=y || SND_SOC_WCD9330=y
config SND_SOC_MSM8X10_WCD
tristate

View file

@ -69,6 +69,7 @@ snd-soc-uda1380-objs := uda1380.o
snd-soc-wcd9310-objs := wcd9310.o wcd9310-tables.o
snd-soc-wcd9320-objs := wcd9320.o wcd9320-tables.o
snd-soc-wcd9306-objs := wcd9306.o wcd9306-tables.o
snd-soc-wcd9330-objs := wcd9330.o wcd9330-tables.o
snd-soc-wcd9xxx-objs := wcd9xxx-resmgr.o wcd9xxx-mbhc.o wcd9xxx-common.o
snd-soc-msm8x10-wcd-objs := msm8x10-wcd.o msm8x10-wcd-tables.o wcd9xxx-common.o
snd-soc-msm8x16-wcd-objs := msm8x16-wcd.o msm8x16-wcd-tables.o wcd-mbhc-v2.o
@ -202,6 +203,7 @@ obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o
obj-$(CONFIG_SND_SOC_WCD9310) += snd-soc-wcd9310.o
obj-$(CONFIG_SND_SOC_WCD9320) += snd-soc-wcd9320.o
obj-$(CONFIG_SND_SOC_WCD9306) += snd-soc-wcd9306.o
obj-$(CONFIG_SND_SOC_WCD9330) += snd-soc-wcd9330.o
obj-$(CONFIG_SND_SOC_MSM8X10_WCD) += snd-soc-msm8x10-wcd.o wcd9xxx-resmgr.o wcd9xxx-mbhc.o
obj-$(CONFIG_SND_SOC_WCD9XXX) += snd-soc-wcd9xxx.o
obj-$(CONFIG_SND_SOC_MSM8X16_WCD) += snd-soc-msm8x16-wcd.o msm8916-wcd-irq.o

File diff suppressed because it is too large Load diff

7167
sound/soc/codecs/wcd9330.c Normal file

File diff suppressed because it is too large Load diff

166
sound/soc/codecs/wcd9330.h Normal file
View file

@ -0,0 +1,166 @@
/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef WCD9330_H
#define WCD9330_H
#include <sound/soc.h>
#include <sound/jack.h>
#include <sound/apr_audio-v2.h>
#include <linux/mfd/wcd9xxx/wcd9xxx-slimslave.h>
#include "wcd9xxx-mbhc.h"
#include "wcd9xxx-resmgr.h"
#include "wcd9xxx-common.h"
#define TOMTOM_NUM_REGISTERS 0x400
#define TOMTOM_MAX_REGISTER (TOMTOM_NUM_REGISTERS-1)
#define TOMTOM_CACHE_SIZE TOMTOM_NUM_REGISTERS
#define TOMTOM_REG_VAL(reg, val) {reg, 0, val}
#define TOMTOM_MCLK_ID 0
#define TOMTOM_REGISTER_START_OFFSET 0x800
#define TOMTOM_SB_PGD_PORT_RX_BASE 0x40
#define TOMTOM_SB_PGD_PORT_TX_BASE 0x50
#define WCD9330_DMIC_B1_CTL_DIV_2 0x00
#define WCD9330_DMIC_B1_CTL_DIV_3 0x20
#define WCD9330_DMIC_B1_CTL_DIV_4 0x40
#define WCD9330_DMIC_B2_CTL_DIV_2 0x00
#define WCD9330_DMIC_B2_CTL_DIV_3 0x12
#define WCD9330_DMIC_B2_CTL_DIV_4 0x24
extern const u8 tomtom_reg_readable[TOMTOM_CACHE_SIZE];
extern const u8 tomtom_reset_reg_defaults[TOMTOM_CACHE_SIZE];
struct tomtom_codec_dai_data {
u32 rate;
u32 *ch_num;
u32 ch_act;
u32 ch_tot;
};
enum tomtom_pid_current {
TOMTOM_PID_MIC_2P5_UA,
TOMTOM_PID_MIC_5_UA,
TOMTOM_PID_MIC_10_UA,
TOMTOM_PID_MIC_20_UA,
};
enum tomtom_mbhc_analog_pwr_cfg {
TOMTOM_ANALOG_PWR_COLLAPSED = 0,
TOMTOM_ANALOG_PWR_ON,
TOMTOM_NUM_ANALOG_PWR_CONFIGS,
};
/* Number of input and output Slimbus port */
enum {
TOMTOM_RX1 = 0,
TOMTOM_RX2,
TOMTOM_RX3,
TOMTOM_RX4,
TOMTOM_RX5,
TOMTOM_RX6,
TOMTOM_RX7,
TOMTOM_RX8,
TOMTOM_RX9,
TOMTOM_RX10,
TOMTOM_RX11,
TOMTOM_RX12,
TOMTOM_RX13,
TOMTOM_RX_MAX,
};
enum {
TOMTOM_TX1 = 0,
TOMTOM_TX2,
TOMTOM_TX3,
TOMTOM_TX4,
TOMTOM_TX5,
TOMTOM_TX6,
TOMTOM_TX7,
TOMTOM_TX8,
TOMTOM_TX9,
TOMTOM_TX10,
TOMTOM_TX11,
TOMTOM_TX12,
TOMTOM_TX13,
TOMTOM_TX14,
TOMTOM_TX15,
TOMTOM_TX16,
TOMTOM_TX_MAX,
};
struct mad_audio_header {
u32 reserved[3];
u32 num_reg_cfg;
};
struct mad_microphone_info {
uint8_t input_microphone;
uint8_t cycle_time;
uint8_t settle_time;
uint8_t padding;
} __packed;
struct mad_micbias_info {
uint8_t micbias;
uint8_t k_factor;
uint8_t external_bypass_capacitor;
uint8_t internal_biasing;
uint8_t cfilter;
uint8_t padding[3];
} __packed;
struct mad_rms_audio_beacon_info {
uint8_t rms_omit_samples;
uint8_t rms_comp_time;
uint8_t detection_mechanism;
uint8_t rms_diff_threshold;
uint8_t rms_threshold_lsb;
uint8_t rms_threshold_msb;
uint8_t padding[2];
uint8_t iir_coefficients[36];
} __packed;
struct mad_rms_ultrasound_info {
uint8_t rms_comp_time;
uint8_t detection_mechanism;
uint8_t rms_diff_threshold;
uint8_t rms_threshold_lsb;
uint8_t rms_threshold_msb;
uint8_t padding[3];
uint8_t iir_coefficients[36];
} __packed;
struct mad_audio_cal {
uint32_t version;
struct mad_microphone_info microphone_info;
struct mad_micbias_info micbias_info;
struct mad_rms_audio_beacon_info audio_info;
struct mad_rms_audio_beacon_info beacon_info;
struct mad_rms_ultrasound_info ultrasound_info;
} __packed;
extern int tomtom_mclk_enable(struct snd_soc_codec *codec, int mclk_enable,
bool dapm);
extern int tomtom_hs_detect(struct snd_soc_codec *codec,
struct wcd9xxx_mbhc_config *mbhc_cfg);
extern void tomtom_hs_detect_exit(struct snd_soc_codec *codec);
extern void *tomtom_get_afe_config(struct snd_soc_codec *codec,
enum afe_config_type config_type);
extern void tomtom_event_register(
int (*machine_event_cb)(struct snd_soc_codec *codec,
enum wcd9xxx_codec_event),
struct snd_soc_codec *codec);
#endif