Asish Bhattacharya | 8e2277f | 2017-07-20 18:31:55 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
| 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 | |
| 20 | #define SAMPLING_RATE_8KHZ 8000 |
| 21 | #define SAMPLING_RATE_11P025KHZ 11025 |
| 22 | #define SAMPLING_RATE_16KHZ 16000 |
| 23 | #define SAMPLING_RATE_22P05KHZ 22050 |
| 24 | #define SAMPLING_RATE_32KHZ 32000 |
| 25 | #define SAMPLING_RATE_44P1KHZ 44100 |
| 26 | #define SAMPLING_RATE_48KHZ 48000 |
| 27 | #define SAMPLING_RATE_88P2KHZ 88200 |
| 28 | #define SAMPLING_RATE_96KHZ 96000 |
| 29 | #define SAMPLING_RATE_176P4KHZ 176400 |
| 30 | #define SAMPLING_RATE_192KHZ 192000 |
| 31 | #define SAMPLING_RATE_352P8KHZ 352800 |
| 32 | #define SAMPLING_RATE_384KHZ 384000 |
| 33 | |
| 34 | #define TDM_CHANNEL_MAX 8 |
| 35 | #define TDM_SLOT_OFFSET_MAX 8 |
| 36 | |
| 37 | enum { |
| 38 | TDM_0 = 0, |
| 39 | TDM_1, |
| 40 | TDM_2, |
| 41 | TDM_3, |
| 42 | TDM_4, |
| 43 | TDM_5, |
| 44 | TDM_6, |
| 45 | TDM_7, |
| 46 | TDM_PORT_MAX, |
| 47 | }; |
| 48 | |
| 49 | enum { |
| 50 | TDM_PRI = 0, |
| 51 | TDM_SEC, |
| 52 | TDM_TERT, |
| 53 | TDM_QUAT, |
| 54 | TDM_INTERFACE_MAX, |
| 55 | }; |
| 56 | |
| 57 | struct tdm_port { |
| 58 | u32 mode; |
| 59 | u32 channel; |
| 60 | }; |
| 61 | |
| 62 | enum { |
| 63 | DIG_CDC, |
| 64 | ANA_CDC, |
| 65 | CODECS_MAX, |
| 66 | }; |
| 67 | |
| 68 | extern const struct snd_kcontrol_new msm_common_snd_controls[]; |
| 69 | extern bool codec_reg_done; |
| 70 | struct sdm660_codec { |
| 71 | void* (*get_afe_config_fn)(struct snd_soc_codec *codec, |
| 72 | enum afe_config_type config_type); |
| 73 | }; |
| 74 | |
| 75 | enum { |
| 76 | INT_SND_CARD, |
| 77 | EXT_SND_CARD_TASHA, |
| 78 | EXT_SND_CARD_TAVIL, |
| 79 | }; |
| 80 | |
| 81 | struct msm_snd_interrupt { |
| 82 | void __iomem *mpm_wakeup; |
| 83 | void __iomem *intr1_cfg_apps; |
| 84 | void __iomem *lpi_gpio_intr_cfg; |
| 85 | void __iomem *lpi_gpio_cfg; |
| 86 | void __iomem *lpi_gpio_inout; |
| 87 | }; |
| 88 | |
| 89 | struct msm_asoc_mach_data { |
| 90 | int us_euro_gpio; /* used by gpio driver API */ |
| 91 | int hph_en1_gpio; |
| 92 | int hph_en0_gpio; |
| 93 | struct device_node *us_euro_gpio_p; /* used by pinctrl API */ |
| 94 | struct device_node *hph_en1_gpio_p; /* used by pinctrl API */ |
| 95 | struct device_node *hph_en0_gpio_p; /* used by pinctrl API */ |
| 96 | struct device_node *pdm_gpio_p; /* used by pinctrl API */ |
| 97 | struct device_node *comp_gpio_p; /* used by pinctrl API */ |
| 98 | struct device_node *dmic_gpio_p; /* used by pinctrl API */ |
| 99 | struct device_node *ext_spk_gpio_p; /* used by pinctrl API */ |
| 100 | struct snd_soc_codec *codec; |
| 101 | struct sdm660_codec sdm660_codec_fn; |
| 102 | struct snd_info_entry *codec_root; |
| 103 | int spk_ext_pa_gpio; |
| 104 | int mclk_freq; |
| 105 | bool native_clk_set; |
| 106 | int lb_mode; |
| 107 | int snd_card_val; |
| 108 | u8 micbias1_cap_mode; |
| 109 | u8 micbias2_cap_mode; |
| 110 | atomic_t int_mclk0_rsc_ref; |
| 111 | atomic_t int_mclk0_enabled; |
| 112 | struct mutex cdc_int_mclk0_mutex; |
| 113 | struct delayed_work disable_int_mclk0_work; |
| 114 | struct afe_clk_set digital_cdc_core_clk; |
| 115 | struct msm_snd_interrupt msm_snd_intr_lpi; |
| 116 | }; |
| 117 | |
| 118 | int msm_common_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, |
| 119 | struct snd_pcm_hw_params *params); |
| 120 | int msm_aux_pcm_snd_startup(struct snd_pcm_substream *substream); |
| 121 | void msm_aux_pcm_snd_shutdown(struct snd_pcm_substream *substream); |
| 122 | int msm_mi2s_snd_startup(struct snd_pcm_substream *substream); |
| 123 | void msm_mi2s_snd_shutdown(struct snd_pcm_substream *substream); |
| 124 | int msm_common_snd_controls_size(void); |
| 125 | #endif |