Soumya Managoli | bbeb8ee | 2019-03-18 17:05:29 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 2 | * |
| 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 Kasam | 605b42f | 2017-08-01 22:02:15 +0530 | [diff] [blame] | 17 | #include <dsp/q6afe-v2.h> |
| 18 | #include "codecs/wcd-mbhc-v2.h" |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 19 | |
Vatsal Bucha | 1b70f5b | 2017-10-23 16:17:49 +0530 | [diff] [blame] | 20 | #define DEFAULT_MCLK_RATE 9600000 |
| 21 | #define NATIVE_MCLK_RATE 11289600 |
| 22 | |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 23 | #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 Siddani | d70a4f7 | 2019-11-27 15:35:41 +0530 | [diff] [blame] | 37 | #define TDM_CHANNEL_MAX 16 |
| 38 | #define TDM_SLOT_OFFSET_MAX 32 |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 39 | |
| 40 | enum { |
| 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 | |
| 52 | enum { |
| 53 | TDM_PRI = 0, |
| 54 | TDM_SEC, |
| 55 | TDM_TERT, |
| 56 | TDM_QUAT, |
Rohit Kumar | d175448 | 2017-09-10 22:57:39 +0530 | [diff] [blame] | 57 | TDM_QUIN, |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 58 | TDM_INTERFACE_MAX, |
| 59 | }; |
| 60 | |
| 61 | struct tdm_port { |
| 62 | u32 mode; |
| 63 | u32 channel; |
| 64 | }; |
| 65 | |
Dhanalakshmi Siddani | d70a4f7 | 2019-11-27 15:35:41 +0530 | [diff] [blame] | 66 | struct dev_config { |
| 67 | u32 sample_rate; |
| 68 | u32 bit_format; |
| 69 | u32 channels; |
| 70 | }; |
| 71 | |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 72 | enum { |
Rohit Kumar | af88e4c | 2017-10-04 13:47:10 +0530 | [diff] [blame] | 73 | PRIM_MI2S = 0, |
| 74 | SEC_MI2S, |
| 75 | TERT_MI2S, |
| 76 | QUAT_MI2S, |
| 77 | QUIN_MI2S, |
| 78 | MI2S_MAX, |
| 79 | }; |
| 80 | |
| 81 | enum { |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 82 | DIG_CDC, |
| 83 | ANA_CDC, |
| 84 | CODECS_MAX, |
| 85 | }; |
| 86 | |
| 87 | extern const struct snd_kcontrol_new msm_common_snd_controls[]; |
| 88 | extern bool codec_reg_done; |
| 89 | struct sdm660_codec { |
| 90 | void* (*get_afe_config_fn)(struct snd_soc_codec *codec, |
| 91 | enum afe_config_type config_type); |
| 92 | }; |
| 93 | |
| 94 | enum { |
| 95 | INT_SND_CARD, |
Viraja Kommaraju | 6521c6e | 2018-01-02 23:29:45 +0530 | [diff] [blame] | 96 | INT_DIG_SND_CARD, |
| 97 | INT_MAX_SND_CARD = INT_DIG_SND_CARD, |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 98 | EXT_SND_CARD_TASHA, |
| 99 | EXT_SND_CARD_TAVIL, |
| 100 | }; |
| 101 | |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 102 | struct msm_asoc_mach_data { |
| 103 | int us_euro_gpio; /* used by gpio driver API */ |
Vatsal Bucha | 42dd402 | 2017-12-07 14:35:59 +0530 | [diff] [blame] | 104 | int usbc_en2_gpio; /* used by gpio driver API */ |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 105 | int hph_en1_gpio; |
| 106 | int hph_en0_gpio; |
| 107 | struct device_node *us_euro_gpio_p; /* used by pinctrl API */ |
Vatsal Bucha | 42dd402 | 2017-12-07 14:35:59 +0530 | [diff] [blame] | 108 | struct pinctrl *usbc_en2_gpio_p; /* used by pinctrl API */ |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 109 | 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 Kumar | af88e4c | 2017-10-04 13:47:10 +0530 | [diff] [blame] | 115 | struct device_node *mi2s_gpio_p[MI2S_MAX]; /* used by pinctrl API */ |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 116 | 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 Karka | 813c3d2 | 2018-11-05 13:46:17 +0530 | [diff] [blame] | 131 | int gpio_linein_det; |
| 132 | int gpio_lineout_det; |
| 133 | int linein_det_swh; |
| 134 | int lineout_det_swh; |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | int msm_common_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 138 | struct snd_pcm_hw_params *params); |
| 139 | int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream); |
| 140 | void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream); |
| 141 | int msm_mi2s_snd_startup(struct snd_pcm_substream *substream); |
| 142 | void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream); |
Soumya Managoli | bbeb8ee | 2019-03-18 17:05:29 +0530 | [diff] [blame] | 143 | int msm_tdm_snd_startup(struct snd_pcm_substream *substream); |
| 144 | void msm_tdm_snd_shutdown(struct snd_pcm_substream *substream); |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 145 | int msm_common_snd_controls_size(void); |
Laxminath Kasam | 38070be | 2017-08-17 18:21:59 +0530 | [diff] [blame] | 146 | void msm_set_codec_reg_done(bool done); |
Dhanalakshmi Siddani | d70a4f7 | 2019-11-27 15:35:41 +0530 | [diff] [blame] | 147 | int msm_tdm_snd_startup(struct snd_pcm_substream *substream); |
| 148 | void msm_tdm_snd_shutdown(struct snd_pcm_substream *substream); |
| 149 | int msm_tdm_snd_hw_params(struct snd_pcm_substream *substream, |
| 150 | struct snd_pcm_hw_params *params); |
| 151 | int msm_tdm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 152 | struct snd_pcm_hw_params *params); |
Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 153 | #endif |