From aa6f84521cc9ab5ced506352cb4e4336a4e83537 Mon Sep 17 00:00:00 2001 From: Louis Le Gall Date: Tue, 27 Mar 2012 13:17:35 +0200 Subject: [PATCH] Enable VOIP SSP Driver on CTP BZ: 21780 This patch modify the 'builtin' voip ssp driver to a format compatible with hw codecs (MSIC, but mostly Cirrus logic that is not able to provide master pcm format as legacy used on medfield platforms) In this new format, the SSP provides Master I2S 16 bits@48Khz First channel (Framesync low) : 16bits of channel 1 data second channel (framesync high) : 16bits of channel 2 data + 8 dummy bits (clk is running at 1.923Mhz need 40bits) This signal is comptatible with audience and two version of hw codecs as it is very close to signal provided by modem (i2s 48hz without dummy bits) Please note that platform modification is required to change hw codec configuration and audience firmware to take care of voip signal format modification. Change-Id: I73323201842345db85ab571df6f2f1a3f242b303 Signed-off-by: Louis Le Gall Reviewed-on: http://android.intel.com:8080/40931 Reviewed-by: Bellouard, Jean-marieX Reviewed-by: Centelles, Sylvain Reviewed-by: Gross, Mark Tested-by: Mendi, EduardoX Reviewed-by: buildbot Tested-by: buildbot --- sound/pci/Kconfig | 21 ++++++++-- .../pci/intel_mid_i2s/intel_alsa_ssp_hw_private.h | 45 +++++++++++++++++++++- sound/pci/intel_mid_i2s/intel_mid_i2s.c | 11 ++++-- 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index 700be8d..c24d6e5 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig @@ -887,7 +887,7 @@ config SND_INTEL_MID_I2S This interface is mostly used on Intel MID platforms and provide the low level interface for some upper layer drivers such as Alsa SoC, char device interfaces... depending of peripheral connected. - PCI Header should have ADID field set to I2S BT_FM or + PCI Header should have ADID field set to I2S BT_FM or I2S MODEM to be used by this driver (so it knows connected peripheral). NOTES : - This is a prototype driver and support for continuous @@ -903,19 +903,32 @@ config SND_INTEL_ALSA_SSP Say Y here to include support for ALSA SSP soundcard. To compile this driver as a module, choose M here: the module will be called snd-alsa-ssp.ko - This is a sound card driver for TI LNW1273 BT/FM Board + This is a sound card driver for BT/FM/Builtin devices This ALSA driver offers: + 1 built-in device with 1 capture and 1 playback substreams 1 BT device with 1 capture and 1 playback substreams 1 FM device with 1 capture substream config SND_INTEL_ALSA_SSP_MASTER_MODE depends on SND_INTEL_ALSA_SSP && SND_INTEL_MID_I2S - bool "Set the ALSA SSP in MASTER instead SLAVE by default" + bool "Set the ALSA SSP BT device in MASTER instead SLAVE by default" default n help - This an option to select ALSA SSP in MASTER instead of default + This is an option to select ALSA SSP BT in MASTER instead of default SLAVE. +config SND_INTEL_ALSA_SSP_BUILTIN_MASTER_MODE + depends on SND_INTEL_ALSA_SSP && SND_INTEL_MID_I2S + bool "Sets ALSA SSP BUILT IN device in MASTER instead SLAVE by default" + default n + help + Say Y here to include support for this option. + This is an option to select ALSA SSP BUILT IN in + Master I2S 16 bits 48Khz. + First channel (Framesync low) : 16bits of channel 1 data + second channel (framesync high) : 16bits of channel 2 data + + 8 dummy bits (clk is running at 1.923Mhz need 40bits) + config SND_INTEL_ALSA_IFX tristate "ALSA IFX modem SND Card Driver" depends on EXPERIMENTAL && SND_INTEL_MID_I2S diff --git a/sound/pci/intel_mid_i2s/intel_alsa_ssp_hw_private.h b/sound/pci/intel_mid_i2s/intel_alsa_ssp_hw_private.h index 9288ccd..33da871 100644 --- a/sound/pci/intel_mid_i2s/intel_alsa_ssp_hw_private.h +++ b/sound/pci/intel_mid_i2s/intel_alsa_ssp_hw_private.h @@ -146,7 +146,45 @@ const struct intel_mid_i2s_settings .ssp_active_rx_slots_map = 0x01 }, { - /* BUILTIN configuration (slave) for VOIP */ +#ifdef CONFIG_SND_INTEL_ALSA_SSP_BUILTIN_MASTER_MODE + /* BUILTIN configuration (I2S master 2x16bits 48Khz) for VOIP */ + .mode = SSP_IN_NETWORK_MODE, + .rx_fifo_interrupt = SSP_RX_FIFO_OVER_INT_ENABLE, + .tx_fifo_interrupt = SSP_TX_FIFO_UNDER_INT_ENABLE, + .frame_format = PSP_FORMAT, + .master_mode_clk_selection = SSP_ONCHIP_CLOCK, + .frame_rate_divider_control = 1, + .master_mode_standard_freq = SSP_FRM_FREQ_48_000, + .data_size = 32, + .tx_tristate_phase = TXD_TRISTATE_LAST_PHASE_OFF, + .tx_tristate_enable = TXD_TRISTATE_ON, + .slave_clk_free_running_status = + SLAVE_SSPCLK_ON_DURING_TRANSFER_ONLY, + .sspslclk_direction = SSPSCLK_MASTER_MODE, + .sspsfrm_direction = SSPSFRM_MASTER_MODE, + .ssp_duplex_mode = RX_WITHOUT_TX_MODE, + .ssp_trailing_byte_mode = SSP_TRAILING_BYTE_HDL_BY_IA, + .ssp_tx_dma = SSP_TX_DMA_ENABLE, + .ssp_rx_dma = SSP_RX_DMA_ENABLE, + .ssp_rx_timeout_interrupt_status = SSP_RX_TIMEOUT_INT_DISABLE, + .ssp_trailing_byte_interrupt_status = + SSP_TRAILING_BYTE_INT_DISABLE, + .ssp_loopback_mode_status = SSP_LOOPBACK_OFF, + .ssp_rx_fifo_threshold = 8, + .ssp_tx_fifo_threshold = 7, + .ssp_frmsync_timing_bit = NEXT_FRMS_ASS_AFTER_END_OF_T4, + .ssp_frmsync_pol_bit = SSP_FRMS_ACTIVE_LOW, + .ssp_end_transfer_state = SSP_END_DATA_TRANSFER_STATE_LOW, + .ssp_serial_clk_mode = SSP_CLK_MODE_0, + .ssp_psp_T1 = 6, + .ssp_psp_T2 = 2, + .ssp_psp_T4 = 0, + .ssp_psp_T5 = 14, + .ssp_psp_T6 = 16, + .ssp_active_tx_slots_map = 0x01, + .ssp_active_rx_slots_map = 0x01 +#else /* CONFIG_SND_INTEL_ALSA_SSP_BUILTIN_MASTER_MODE */ + /* BUILTIN configuration (slave PCM) for VOIP */ .mode = SSP_IN_NETWORK_MODE, .rx_fifo_interrupt = SSP_RX_FIFO_OVER_INT_ENABLE, .tx_fifo_interrupt = SSP_TX_FIFO_UNDER_INT_ENABLE, @@ -157,7 +195,8 @@ const struct intel_mid_i2s_settings .data_size = 32, .tx_tristate_phase = TXD_TRISTATE_LAST_PHASE_OFF, .tx_tristate_enable = TXD_TRISTATE_OFF, - .slave_clk_free_running_status = SLAVE_SSPCLK_ON_DURING_TRANSFER_ONLY, + .slave_clk_free_running_status = + SLAVE_SSPCLK_ON_DURING_TRANSFER_ONLY, .sspslclk_direction = SSPSCLK_SLAVE_MODE, .sspsfrm_direction = SSPSFRM_SLAVE_MODE, .ssp_duplex_mode = RX_AND_TX_MODE, @@ -181,6 +220,8 @@ const struct intel_mid_i2s_settings .ssp_psp_T6 = 1, .ssp_active_tx_slots_map = 0x01, .ssp_active_rx_slots_map = 0x01 +#endif /* CONFIG_SND_INTEL_ALSA_SSP_BUILTIN_MASTER_MODE */ + } }; diff --git a/sound/pci/intel_mid_i2s/intel_mid_i2s.c b/sound/pci/intel_mid_i2s/intel_mid_i2s.c index 803e1b7..f48fa4f 100644 --- a/sound/pci/intel_mid_i2s/intel_mid_i2s.c +++ b/sound/pci/intel_mid_i2s/intel_mid_i2s.c @@ -1963,7 +1963,9 @@ static u32 calculate_sscr0_scr(struct intel_mid_i2s_hdl *drv_data, u16 l_ssp_data_size = ps_settings->data_size; enum mrst_ssp_frm_freq freq = ps_settings->master_mode_standard_freq; struct device *ddbg = &(drv_data->pdev->dev); - u16 delay = ps_settings->ssp_psp_T2 + ps_settings->ssp_psp_T4; + u16 delay = ps_settings->ssp_psp_T2 + + ps_settings->ssp_psp_T4 + + ps_settings->ssp_psp_T1; int frame_sync_length, hw_freq, requested_freq; dev_dbg(ddbg, "delay=%d\n", delay); @@ -1977,9 +1979,10 @@ static u32 calculate_sscr0_scr(struct intel_mid_i2s_hdl *drv_data, dev_warn(ddbg, "Review SSP config, clock not accurate\n"); } - if (ps_settings->ssp_psp_T5 != 0) - dev_warn(ddbg, "T5 not null -> NOT SUPPORTED\n"); - + dev_dbg(ddbg, "T1=%d, T2=%d, T4=%d, T5=%d, T6=%d\n", + ps_settings->ssp_psp_T1, ps_settings->ssp_psp_T2, + ps_settings->ssp_psp_T4, ps_settings->ssp_psp_T5, + ps_settings->ssp_psp_T6); /* frequency */ switch (freq) { -- 2.7.4