xref: /linux/include/sound/sof/dai-intel.h (revision 68776b2fb06e7e438a2c4ebca5ca7f216e31d678)
1e149ca29SPierre-Louis Bossart /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
253e0c72dSLiam Girdwood /*
353e0c72dSLiam Girdwood  * This file is provided under a dual BSD/GPLv2 license.  When using or
453e0c72dSLiam Girdwood  * redistributing this file, you may do so under either license.
553e0c72dSLiam Girdwood  *
653e0c72dSLiam Girdwood  * Copyright(c) 2018 Intel Corporation. All rights reserved.
753e0c72dSLiam Girdwood  */
853e0c72dSLiam Girdwood 
953e0c72dSLiam Girdwood #ifndef __INCLUDE_SOUND_SOF_DAI_INTEL_H__
1053e0c72dSLiam Girdwood #define __INCLUDE_SOUND_SOF_DAI_INTEL_H__
1153e0c72dSLiam Girdwood 
1253e0c72dSLiam Girdwood #include <sound/sof/header.h>
1353e0c72dSLiam Girdwood 
1453e0c72dSLiam Girdwood  /* ssc1: TINTE */
1553e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_QUIRK_TINTE		(1 << 0)
1653e0c72dSLiam Girdwood  /* ssc1: PINTE */
1753e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_QUIRK_PINTE		(1 << 1)
1853e0c72dSLiam Girdwood  /* ssc2: SMTATF */
1953e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_QUIRK_SMTATF		(1 << 2)
2053e0c72dSLiam Girdwood  /* ssc2: MMRATF */
2153e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_QUIRK_MMRATF		(1 << 3)
2253e0c72dSLiam Girdwood  /* ssc2: PSPSTWFDFD */
2353e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_QUIRK_PSPSTWFDFD	(1 << 4)
2453e0c72dSLiam Girdwood  /* ssc2: PSPSRWFDFD */
2553e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_QUIRK_PSPSRWFDFD	(1 << 5)
2653e0c72dSLiam Girdwood /* ssc1: LBM */
2753e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_QUIRK_LBM		(1 << 6)
2853e0c72dSLiam Girdwood 
2953e0c72dSLiam Girdwood  /* here is the possibility to define others aux macros */
3053e0c72dSLiam Girdwood 
3153e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX		38
3253e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_SLOT_PADDING_MAX		31
3353e0c72dSLiam Girdwood 
3453e0c72dSLiam Girdwood /* SSP clocks control settings
3553e0c72dSLiam Girdwood  *
3653e0c72dSLiam Girdwood  * Macros for clks_control field in sof_ipc_dai_ssp_params struct.
3753e0c72dSLiam Girdwood  */
3853e0c72dSLiam Girdwood 
3953e0c72dSLiam Girdwood /* mclk 0 disable */
4053e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_MCLK_0_DISABLE		BIT(0)
4153e0c72dSLiam Girdwood /* mclk 1 disable */
4253e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_MCLK_1_DISABLE		BIT(1)
4353e0c72dSLiam Girdwood /* mclk keep active */
4453e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_KA		BIT(2)
4553e0c72dSLiam Girdwood /* bclk keep active */
4653e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_KA		BIT(3)
4753e0c72dSLiam Girdwood /* fs keep active */
4853e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_CLKCTRL_FS_KA			BIT(4)
4953e0c72dSLiam Girdwood /* bclk idle */
5053e0c72dSLiam Girdwood #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_IDLE_HIGH	BIT(5)
51*68776b2fSBard Liao /* mclk early start */
52*68776b2fSBard Liao #define SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_ES               BIT(6)
53*68776b2fSBard Liao /* bclk early start */
54*68776b2fSBard Liao #define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_ES               BIT(7)
5553e0c72dSLiam Girdwood 
5631be5337SSeppo Ingalsuo /* DMIC max. four controllers for eight microphone channels */
5731be5337SSeppo Ingalsuo #define SOF_DAI_INTEL_DMIC_NUM_CTRL			4
5831be5337SSeppo Ingalsuo 
5953e0c72dSLiam Girdwood /* SSP Configuration Request - SOF_IPC_DAI_SSP_CONFIG */
6053e0c72dSLiam Girdwood struct sof_ipc_dai_ssp_params {
6153e0c72dSLiam Girdwood 	struct sof_ipc_hdr hdr;
6253e0c72dSLiam Girdwood 	uint16_t reserved1;
6353e0c72dSLiam Girdwood 	uint16_t mclk_id;
6453e0c72dSLiam Girdwood 
6553e0c72dSLiam Girdwood 	uint32_t mclk_rate;	/* mclk frequency in Hz */
6653e0c72dSLiam Girdwood 	uint32_t fsync_rate;	/* fsync frequency in Hz */
6753e0c72dSLiam Girdwood 	uint32_t bclk_rate;	/* bclk frequency in Hz */
6853e0c72dSLiam Girdwood 
6953e0c72dSLiam Girdwood 	/* TDM */
7053e0c72dSLiam Girdwood 	uint32_t tdm_slots;
7153e0c72dSLiam Girdwood 	uint32_t rx_slots;
7253e0c72dSLiam Girdwood 	uint32_t tx_slots;
7353e0c72dSLiam Girdwood 
7453e0c72dSLiam Girdwood 	/* data */
7553e0c72dSLiam Girdwood 	uint32_t sample_valid_bits;
7653e0c72dSLiam Girdwood 	uint16_t tdm_slot_width;
7753e0c72dSLiam Girdwood 	uint16_t reserved2;	/* alignment */
7853e0c72dSLiam Girdwood 
7953e0c72dSLiam Girdwood 	/* MCLK */
8053e0c72dSLiam Girdwood 	uint32_t mclk_direction;
8153e0c72dSLiam Girdwood 
8253e0c72dSLiam Girdwood 	uint16_t frame_pulse_width;
8353e0c72dSLiam Girdwood 	uint16_t tdm_per_slot_padding_flag;
8453e0c72dSLiam Girdwood 	uint32_t clks_control;
8553e0c72dSLiam Girdwood 	uint32_t quirks;
866298b787SJanusz Jankowski 	uint32_t bclk_delay;	/* guaranteed time (ms) for which BCLK
876298b787SJanusz Jankowski 				 * will be driven, before sending data
886298b787SJanusz Jankowski 				 */
8953e0c72dSLiam Girdwood } __packed;
9053e0c72dSLiam Girdwood 
9153e0c72dSLiam Girdwood /* HDA Configuration Request - SOF_IPC_DAI_HDA_CONFIG */
9253e0c72dSLiam Girdwood struct sof_ipc_dai_hda_params {
9353e0c72dSLiam Girdwood 	struct sof_ipc_hdr hdr;
9453e0c72dSLiam Girdwood 	uint32_t link_dma_ch;
9518aaab64SBard Liao 	uint32_t rate;
9618aaab64SBard Liao 	uint32_t channels;
9753e0c72dSLiam Girdwood } __packed;
9853e0c72dSLiam Girdwood 
99f8e25018SPierre-Louis Bossart /* ALH Configuration Request - SOF_IPC_DAI_ALH_CONFIG */
100f8e25018SPierre-Louis Bossart struct sof_ipc_dai_alh_params {
101f8e25018SPierre-Louis Bossart 	struct sof_ipc_hdr hdr;
102f8e25018SPierre-Louis Bossart 	uint32_t stream_id;
1031f846505SBard Liao 	uint32_t rate;
1041f846505SBard Liao 	uint32_t channels;
105f8e25018SPierre-Louis Bossart 
106f8e25018SPierre-Louis Bossart 	/* reserved for future use */
1071f846505SBard Liao 	uint32_t reserved[13];
108f8e25018SPierre-Louis Bossart } __packed;
109f8e25018SPierre-Louis Bossart 
11053e0c72dSLiam Girdwood /* DMIC Configuration Request - SOF_IPC_DAI_DMIC_CONFIG */
11153e0c72dSLiam Girdwood 
11253e0c72dSLiam Girdwood /* This struct is defined per 2ch PDM controller available in the platform.
11353e0c72dSLiam Girdwood  * Normally it is sufficient to set the used microphone specific enables to 1
11453e0c72dSLiam Girdwood  * and keep other parameters as zero. The customizations are:
11553e0c72dSLiam Girdwood  *
11653e0c72dSLiam Girdwood  * 1. If a device mixes different microphones types with different polarity
11753e0c72dSLiam Girdwood  * and/or the absolute polarity matters the PCM signal from a microphone
11853e0c72dSLiam Girdwood  * can be inverted with the controls.
11953e0c72dSLiam Girdwood  *
12053e0c72dSLiam Girdwood  * 2. If the microphones in a stereo pair do not appear in captured stream
12153e0c72dSLiam Girdwood  * in desired order due to board schematics choises they can be swapped with
12253e0c72dSLiam Girdwood  * the clk_edge parameter.
12353e0c72dSLiam Girdwood  *
12453e0c72dSLiam Girdwood  * 3. If PDM bit errors are seen in capture (poor quality) the skew parameter
12553e0c72dSLiam Girdwood  * that delays the sampling time of data by half cycles of DMIC source clock
12653e0c72dSLiam Girdwood  * can be tried for improvement. However there is no guarantee for this to fix
12753e0c72dSLiam Girdwood  * data integrity problems.
12853e0c72dSLiam Girdwood  */
12953e0c72dSLiam Girdwood struct sof_ipc_dai_dmic_pdm_ctrl {
13053e0c72dSLiam Girdwood 	struct sof_ipc_hdr hdr;
13153e0c72dSLiam Girdwood 	uint16_t id;		/**< PDM controller ID */
13253e0c72dSLiam Girdwood 
13353e0c72dSLiam Girdwood 	uint16_t enable_mic_a;	/**< Use A (left) channel mic (0 or 1)*/
13453e0c72dSLiam Girdwood 	uint16_t enable_mic_b;	/**< Use B (right) channel mic (0 or 1)*/
13553e0c72dSLiam Girdwood 
13653e0c72dSLiam Girdwood 	uint16_t polarity_mic_a; /**< Optionally invert mic A signal (0 or 1) */
13753e0c72dSLiam Girdwood 	uint16_t polarity_mic_b; /**< Optionally invert mic B signal (0 or 1) */
13853e0c72dSLiam Girdwood 
13953e0c72dSLiam Girdwood 	uint16_t clk_edge;	/**< Optionally swap data clock edge (0 or 1) */
14053e0c72dSLiam Girdwood 	uint16_t skew;		/**< Adjust PDM data sampling vs. clock (0..15) */
14153e0c72dSLiam Girdwood 
14253e0c72dSLiam Girdwood 	uint16_t reserved[3];	/**< Make sure the total size is 4 bytes aligned */
14353e0c72dSLiam Girdwood } __packed;
14453e0c72dSLiam Girdwood 
14553e0c72dSLiam Girdwood /* This struct contains the global settings for all 2ch PDM controllers. The
14653e0c72dSLiam Girdwood  * version number used in configuration data is checked vs. version used by
14753e0c72dSLiam Girdwood  * device driver src/drivers/dmic.c need to match. It is incremented from
14853e0c72dSLiam Girdwood  * initial value 1 if updates done for the to driver would alter the operation
14979a4ff94SSeppo Ingalsuo  * of the microphone.
15053e0c72dSLiam Girdwood  *
15153e0c72dSLiam Girdwood  * Note: The microphone clock (pdmclk_min, pdmclk_max, duty_min, duty_max)
15253e0c72dSLiam Girdwood  * parameters need to be set as defined in microphone data sheet. E.g. clock
15353e0c72dSLiam Girdwood  * range 1.0 - 3.2 MHz is usually supported microphones. Some microphones are
15453e0c72dSLiam Girdwood  * multi-mode capable and there may be denied mic clock frequencies between
15553e0c72dSLiam Girdwood  * the modes. In such case set the clock range limits of the desired mode to
15653e0c72dSLiam Girdwood  * avoid the driver to set clock to an illegal rate.
15753e0c72dSLiam Girdwood  *
15853e0c72dSLiam Girdwood  * The duty cycle could be set to 48-52% if not known. Generally these
15953e0c72dSLiam Girdwood  * parameters can be altered within data sheet specified limits to match
16053e0c72dSLiam Girdwood  * required audio application performance power.
16153e0c72dSLiam Girdwood  *
16253e0c72dSLiam Girdwood  * The microphone clock needs to be usually about 50-80 times the used audio
16353e0c72dSLiam Girdwood  * sample rate. With highest sample rates above 48 kHz this can relaxed
16453e0c72dSLiam Girdwood  * somewhat.
16553e0c72dSLiam Girdwood  *
16653e0c72dSLiam Girdwood  * The parameter wake_up_time describes how long time the microphone needs
16753e0c72dSLiam Girdwood  * for the data line to produce valid output from mic clock start. The driver
16853e0c72dSLiam Girdwood  * will mute the captured audio for the given time. The min_clock_on_time
16953e0c72dSLiam Girdwood  * parameter is used to prevent too short clock bursts to happen. The driver
17053e0c72dSLiam Girdwood  * will keep the clock active after capture stop if this time is not yet
17153e0c72dSLiam Girdwood  * met. The unit for both is microseconds (us). Exceed of 100 ms will be
17253e0c72dSLiam Girdwood  * treated as an error.
17353e0c72dSLiam Girdwood  */
17453e0c72dSLiam Girdwood struct sof_ipc_dai_dmic_params {
17553e0c72dSLiam Girdwood 	struct sof_ipc_hdr hdr;
17653e0c72dSLiam Girdwood 	uint32_t driver_ipc_version;	/**< Version (1..N) */
17753e0c72dSLiam Girdwood 
17853e0c72dSLiam Girdwood 	uint32_t pdmclk_min;	/**< Minimum microphone clock in Hz (100000..N) */
17953e0c72dSLiam Girdwood 	uint32_t pdmclk_max;	/**< Maximum microphone clock in Hz (min...N) */
18053e0c72dSLiam Girdwood 
18153e0c72dSLiam Girdwood 	uint32_t fifo_fs;	/**< FIFO sample rate in Hz (8000..96000) */
18253e0c72dSLiam Girdwood 	uint32_t reserved_1;	/**< Reserved */
18353e0c72dSLiam Girdwood 	uint16_t fifo_bits;	/**< FIFO word length (16 or 32) */
1841993ba26SSeppo Ingalsuo 	uint16_t fifo_bits_b;	/**< Deprecated since firmware ABI 3.0.1 */
18553e0c72dSLiam Girdwood 
18653e0c72dSLiam Girdwood 	uint16_t duty_min;	/**< Min. mic clock duty cycle in % (20..80) */
18753e0c72dSLiam Girdwood 	uint16_t duty_max;	/**< Max. mic clock duty cycle in % (min..80) */
18853e0c72dSLiam Girdwood 
18931be5337SSeppo Ingalsuo 	uint32_t num_pdm_active; /**< Number of active pdm controllers. */
19031be5337SSeppo Ingalsuo 				 /**< Range is 1..SOF_DAI_INTEL_DMIC_NUM_CTRL */
19153e0c72dSLiam Girdwood 
19253e0c72dSLiam Girdwood 	uint32_t wake_up_time;      /**< Time from clock start to data (us) */
19353e0c72dSLiam Girdwood 	uint32_t min_clock_on_time; /**< Min. time that clk is kept on (us) */
1947df43911SSeppo Ingalsuo 	uint32_t unmute_ramp_time;  /**< Length of logarithmic gain ramp (ms) */
19553e0c72dSLiam Girdwood 
19653e0c72dSLiam Girdwood 	/* reserved for future use */
1977df43911SSeppo Ingalsuo 	uint32_t reserved[5];
19853e0c72dSLiam Girdwood 
19931be5337SSeppo Ingalsuo 	/**< PDM controllers configuration */
20031be5337SSeppo Ingalsuo 	struct sof_ipc_dai_dmic_pdm_ctrl pdm[SOF_DAI_INTEL_DMIC_NUM_CTRL];
20153e0c72dSLiam Girdwood } __packed;
20253e0c72dSLiam Girdwood 
20353e0c72dSLiam Girdwood #endif
204