blob: 2e9fd3cf6a5e3bc1cacf08db29a223f45c40f9c2 [file] [log] [blame]
Soumya Managolibbeb8ee2019-03-18 17:05:29 +05301/* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05302 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __MSM_COMMON
14#define __MSM_COMMON
15
16#include <sound/soc.h>
Laxminath Kasam605b42f2017-08-01 22:02:15 +053017#include <dsp/q6afe-v2.h>
18#include "codecs/wcd-mbhc-v2.h"
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053019
Vatsal Bucha1b70f5b2017-10-23 16:17:49 +053020#define DEFAULT_MCLK_RATE 9600000
21#define NATIVE_MCLK_RATE 11289600
22
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053023#define SAMPLING_RATE_8KHZ 8000
24#define SAMPLING_RATE_11P025KHZ 11025
25#define SAMPLING_RATE_16KHZ 16000
26#define SAMPLING_RATE_22P05KHZ 22050
27#define SAMPLING_RATE_32KHZ 32000
28#define SAMPLING_RATE_44P1KHZ 44100
29#define SAMPLING_RATE_48KHZ 48000
30#define SAMPLING_RATE_88P2KHZ 88200
31#define SAMPLING_RATE_96KHZ 96000
32#define SAMPLING_RATE_176P4KHZ 176400
33#define SAMPLING_RATE_192KHZ 192000
34#define SAMPLING_RATE_352P8KHZ 352800
35#define SAMPLING_RATE_384KHZ 384000
36
Dhanalakshmi Siddanid70a4f72019-11-27 15:35:41 +053037#define TDM_CHANNEL_MAX 16
38#define TDM_SLOT_OFFSET_MAX 32
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053039
40enum {
41 TDM_0 = 0,
42 TDM_1,
43 TDM_2,
44 TDM_3,
45 TDM_4,
46 TDM_5,
47 TDM_6,
48 TDM_7,
49 TDM_PORT_MAX,
50};
51
52enum {
53 TDM_PRI = 0,
54 TDM_SEC,
55 TDM_TERT,
56 TDM_QUAT,
Rohit Kumard1754482017-09-10 22:57:39 +053057 TDM_QUIN,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053058 TDM_INTERFACE_MAX,
59};
60
61struct tdm_port {
62 u32 mode;
63 u32 channel;
64};
65
Dhanalakshmi Siddanid70a4f72019-11-27 15:35:41 +053066struct dev_config {
67 u32 sample_rate;
68 u32 bit_format;
69 u32 channels;
70};
71
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053072enum {
Rohit Kumaraf88e4c2017-10-04 13:47:10 +053073 PRIM_MI2S = 0,
74 SEC_MI2S,
75 TERT_MI2S,
76 QUAT_MI2S,
77 QUIN_MI2S,
78 MI2S_MAX,
79};
80
81enum {
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053082 DIG_CDC,
83 ANA_CDC,
84 CODECS_MAX,
85};
86
87extern const struct snd_kcontrol_new msm_common_snd_controls[];
88extern bool codec_reg_done;
89struct sdm660_codec {
90 void* (*get_afe_config_fn)(struct snd_soc_codec *codec,
91 enum afe_config_type config_type);
92};
93
94enum {
95 INT_SND_CARD,
Viraja Kommaraju6521c6e2018-01-02 23:29:45 +053096 INT_DIG_SND_CARD,
97 INT_MAX_SND_CARD = INT_DIG_SND_CARD,
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053098 EXT_SND_CARD_TASHA,
99 EXT_SND_CARD_TAVIL,
100};
101
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530102struct msm_asoc_mach_data {
103 int us_euro_gpio; /* used by gpio driver API */
Vatsal Bucha42dd4022017-12-07 14:35:59 +0530104 int usbc_en2_gpio; /* used by gpio driver API */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530105 int hph_en1_gpio;
106 int hph_en0_gpio;
107 struct device_node *us_euro_gpio_p; /* used by pinctrl API */
Vatsal Bucha42dd4022017-12-07 14:35:59 +0530108 struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530109 struct device_node *hph_en1_gpio_p; /* used by pinctrl API */
110 struct device_node *hph_en0_gpio_p; /* used by pinctrl API */
111 struct device_node *pdm_gpio_p; /* used by pinctrl API */
112 struct device_node *comp_gpio_p; /* used by pinctrl API */
113 struct device_node *dmic_gpio_p; /* used by pinctrl API */
114 struct device_node *ext_spk_gpio_p; /* used by pinctrl API */
Rohit Kumaraf88e4c2017-10-04 13:47:10 +0530115 struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530116 struct snd_soc_codec *codec;
117 struct sdm660_codec sdm660_codec_fn;
118 struct snd_info_entry *codec_root;
119 int spk_ext_pa_gpio;
120 int mclk_freq;
121 bool native_clk_set;
122 int lb_mode;
123 int snd_card_val;
124 u8 micbias1_cap_mode;
125 u8 micbias2_cap_mode;
126 atomic_t int_mclk0_rsc_ref;
127 atomic_t int_mclk0_enabled;
128 struct mutex cdc_int_mclk0_mutex;
129 struct delayed_work disable_int_mclk0_work;
130 struct afe_clk_set digital_cdc_core_clk;
Surendar Karka813c3d22018-11-05 13:46:17 +0530131 int gpio_linein_det;
132 int gpio_lineout_det;
133 int linein_det_swh;
134 int lineout_det_swh;
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530135};
136
137int msm_common_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
138 struct snd_pcm_hw_params *params);
139int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream);
140void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream);
141int msm_mi2s_snd_startup(struct snd_pcm_substream *substream);
142void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream);
Soumya Managolibbeb8ee2019-03-18 17:05:29 +0530143int msm_tdm_snd_startup(struct snd_pcm_substream *substream);
144void msm_tdm_snd_shutdown(struct snd_pcm_substream *substream);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530145int msm_common_snd_controls_size(void);
Laxminath Kasam38070be2017-08-17 18:21:59 +0530146void msm_set_codec_reg_done(bool done);
Dhanalakshmi Siddanid70a4f72019-11-27 15:35:41 +0530147int msm_tdm_snd_startup(struct snd_pcm_substream *substream);
148void msm_tdm_snd_shutdown(struct snd_pcm_substream *substream);
149int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream,
150 struct snd_pcm_hw_params *params);
151int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
152 struct snd_pcm_hw_params *params);
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530153#endif