From 12ef2113031da1ebd7fe7c196960f2c5fee93c0a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 2 Jul 2018 12:22:53 -0500 Subject: [PATCH 01/18] ASoC: Intel: revert code related to TDF8532 Clean-up before re-adding latest code Signed-off-by: Pierre-Louis Bossart --- sound/soc/codecs/Kconfig | 5 - sound/soc/codecs/Makefile | 2 - sound/soc/codecs/tdf8532.c | 383 ----------------------- sound/soc/codecs/tdf8532.h | 101 ------ sound/soc/intel/boards/Kconfig | 10 - sound/soc/intel/boards/Makefile | 2 - sound/soc/intel/boards/bxt_tdf8532.c | 440 --------------------------- 7 files changed, 943 deletions(-) delete mode 100644 sound/soc/codecs/tdf8532.c delete mode 100644 sound/soc/codecs/tdf8532.h delete mode 100644 sound/soc/intel/boards/bxt_tdf8532.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index fbacaa0a724bd4..9548f63ca531c8 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -157,7 +157,6 @@ config SND_SOC_ALL_CODECS select SND_SOC_TAS5720 if I2C select SND_SOC_TAS6424 if I2C select SND_SOC_TDA7419 if I2C - select SND_SOC_TDF8532 if I2C select SND_SOC_TFA9879 if I2C select SND_SOC_TLV320AIC23_I2C if I2C select SND_SOC_TLV320AIC23_SPI if SPI_MASTER @@ -955,10 +954,6 @@ config SND_SOC_TDA7419 depends on I2C select REGMAP_I2C -config SND_SOC_TDF8532 - tristate - depends on I2C - config SND_SOC_TFA9879 tristate "NXP Semiconductors TFA9879 amplifier" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 40480a5243ff2e..e849d1495308f9 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -168,7 +168,6 @@ snd-soc-tas571x-objs := tas571x.o snd-soc-tas5720-objs := tas5720.o snd-soc-tas6424-objs := tas6424.o snd-soc-tda7419-objs := tda7419.o -snd-soc-tdf8532-objs := tdf8532.o snd-soc-tfa9879-objs := tfa9879.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o @@ -421,7 +420,6 @@ obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o -obj-$(CONFIG_SND_SOC_TDF8532) += snd-soc-tdf8532.o obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c deleted file mode 100644 index c7bdb3960eaf49..00000000000000 --- a/sound/soc/codecs/tdf8532.c +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Codec driver for NXP Semiconductors - TDF8532 - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tdf8532.h" - -static int __tdf8532_build_pkt(struct tdf8532_priv *dev_data, - va_list valist, u8 *payload) -{ - int param; - u8 len; - u8 *cmd_payload; - const u8 cmd_offset = 3; - - payload[HEADER_TYPE] = MSG_TYPE_STX; - payload[HEADER_PKTID] = dev_data->pkt_id; - - cmd_payload = &(payload[cmd_offset]); - - param = va_arg(valist, int); - len = 0; - - while (param != END) { - cmd_payload[len] = param; - - len++; - - param = va_arg(valist, int); - } - - payload[HEADER_LEN] = len; - - return len + cmd_offset; -} - -static int __tdf8532_single_write(struct tdf8532_priv *dev_data, - int dummy, ...) -{ - va_list valist; - int ret; - u8 len; - u8 payload[255]; - - va_start(valist, dummy); - - len = __tdf8532_build_pkt(dev_data, valist, payload); - - va_end(valist); - - print_hex_dump_debug("tdf8532-codec: Tx:", DUMP_PREFIX_NONE, 32, 1, - payload, len, false); - ret = i2c_master_send(dev_data->i2c, payload, len); - - dev_data->pkt_id++; - - if (ret < 0) { - dev_err(&(dev_data->i2c->dev), - "i2c send packet returned: %d\n", ret); - - return ret; - } - - return 0; -} - - -static uint8_t tdf8532_read_wait_ack(struct tdf8532_priv *dev_data, - unsigned long timeout) -{ - uint8_t ack_repl[HEADER_SIZE] = {0, 0, 0}; - unsigned long timeout_point = jiffies + timeout; - int ret; - - usleep_range(10000,20000); - do { - ret = i2c_master_recv(dev_data->i2c, ack_repl, HEADER_SIZE); - if (ret < 0) - goto out; - } while (time_before(jiffies, timeout_point) && - ack_repl[0] != MSG_TYPE_ACK); - - if (ack_repl[0] != MSG_TYPE_ACK) - return -ETIME; - else - return ack_repl[2]; - -out: - return ret; -} - -static uint8_t tdf8532_single_read(struct tdf8532_priv *dev_data, - char **repl_buff) -{ - int ret; - uint8_t len; - - struct device *dev = &(dev_data->i2c->dev); - - ret = tdf8532_read_wait_ack(dev_data, msecs_to_jiffies(ACK_TIMEOUT)); - - if (ret < 0) { - dev_err(dev, - "Error waiting for ACK reply: %d\n", ret); - goto out; - } - - len = ret + HEADER_SIZE; - - *repl_buff = kzalloc(len, GFP_KERNEL); - - ret = i2c_master_recv(dev_data->i2c, *repl_buff, len); - - print_hex_dump_debug("tdf8532-codec: Rx:", DUMP_PREFIX_NONE, 32, 1, - *repl_buff, len, false); - - if (ret < 0 || ret != len) { - dev_err(dev, - "i2c recv packet returned: %d (expected: %d)\n", - ret, len); - goto out_free; - } - - return len; - -out_free: - kfree(*repl_buff); - repl_buff = NULL; -out: - return ret; -} - -static int tdf8532_get_state(struct tdf8532_priv *dev_data, - struct get_dev_status_repl **status_repl) -{ - int ret = 0; - char *repl_buff = NULL; - - ret = tdf8532_amp_write(dev_data, GET_DEV_STATUS); - if (ret < 0) - goto out; - - ret = tdf8532_single_read(dev_data, &repl_buff); - if (ret < 0) - goto out; - - *status_repl = (struct get_dev_status_repl *) repl_buff; - -out: - return ret; -} - -static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state, - unsigned long timeout) -{ - unsigned long timeout_point = jiffies + msecs_to_jiffies(timeout); - int ret; - struct get_dev_status_repl *status_repl = NULL; - struct device *dev = &(dev_data->i2c->dev); - - do { - ret = tdf8532_get_state(dev_data, &status_repl); - if (ret < 0) - goto out; - - print_hex_dump_debug("tdf8532-codec: wait_state: ", - DUMP_PREFIX_NONE, 32, 1, status_repl, - 6, false); - } while (time_before(jiffies, timeout_point) - && status_repl->state != req_state); - - if (status_repl->state == req_state) - return 0; - - ret = -ETIME; - - dev_warn(dev, "tdf8532-codec: state: %u, req_state: %u, ret: %d\n", - status_repl->state, req_state, ret); - -out: - kfree(status_repl); - return ret; -} - -static int tdf8532_start_play(struct tdf8532_priv *tdf8532) -{ - int ret; - - ret = tdf8532_amp_write(tdf8532, SET_CLK_STATE, CLK_CONNECT); - if (ret < 0) - return ret; - - ret = tdf8532_amp_write(tdf8532, SET_CHNL_ENABLE, - CHNL_MASK(tdf8532->channels)); - - if (ret >= 0) - ret = tdf8532_wait_state(tdf8532, STATE_PLAY, ACK_TIMEOUT); - - return ret; -} - - -static int tdf8532_stop_play(struct tdf8532_priv *tdf8532) -{ - int ret; - - ret = tdf8532_amp_write(tdf8532, SET_CHNL_DISABLE, - CHNL_MASK(tdf8532->channels)); - if (ret < 0) - goto out; - - ret = tdf8532_wait_state(tdf8532, STATE_STBY, ACK_TIMEOUT); - - /* Refer to TDF8532 manual: - * If the wait_state result is ok, we should send CLK_DISCONNECT - * command to force codec from STANDBY(2) to IDLE(1). - * If the wait_state result is timeout, the codec state should be - * at Clockfail(7), we still should send CLK_DISCONNECT command - * force the codec from Clockfail(7) to Idle(1). - */ - - ret = tdf8532_amp_write(tdf8532, SET_CLK_STATE, CLK_DISCONNECT); - if (ret < 0) - goto out; - - ret = tdf8532_wait_state(tdf8532, STATE_IDLE, ACK_TIMEOUT); - -out: - return ret; -} - - -static int tdf8532_dai_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) -{ - int ret = 0; - struct snd_soc_codec *codec = dai->codec; - struct tdf8532_priv *tdf8532 = snd_soc_codec_get_drvdata(codec); - - dev_dbg(codec->dev, "%s: cmd = %d\n", __func__, cmd); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - case SNDRV_PCM_TRIGGER_RESUME: - ret = tdf8532_start_play(tdf8532); - break; - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_STOP: - ret = tdf8532_stop_play(tdf8532); - break; - } - - return ret; -} - -static int tdf8532_mute(struct snd_soc_dai *dai, int mute) -{ - struct snd_soc_codec *codec = dai->codec; - struct tdf8532_priv *tdf8532 = snd_soc_codec_get_drvdata(dai->codec); - - dev_dbg(codec->dev, "%s\n", __func__); - - if (mute) - return tdf8532_amp_write(tdf8532, SET_CHNL_MUTE, - CHNL_MASK(CHNL_MAX)); - else - return tdf8532_amp_write(tdf8532, SET_CHNL_UNMUTE, - CHNL_MASK(CHNL_MAX)); -} - -static const struct snd_soc_dai_ops tdf8532_dai_ops = { - .trigger = tdf8532_dai_trigger, - .digital_mute = tdf8532_mute, -}; - -static struct snd_soc_codec_driver soc_codec_tdf8532; - -static struct snd_soc_dai_driver tdf8532_dai[] = { - { - .name = "tdf8532-hifi", - .playback = { - .stream_name = "Playback", - .channels_min = 4, - .channels_max = 4, - .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, - }, - .ops = &tdf8532_dai_ops, - } -}; - -static int tdf8532_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) -{ - int ret; - struct tdf8532_priv *dev_data; - struct device *dev = &(i2c->dev); - - dev_dbg(&i2c->dev, "%s\n", __func__); - - dev_data = devm_kzalloc(dev, sizeof(struct tdf8532_priv), GFP_KERNEL); - - if (!dev_data) { - ret = -ENOMEM; - goto out; - } - - dev_data->i2c = i2c; - dev_data->pkt_id = 0; - dev_data->channels = 4; - - i2c_set_clientdata(i2c, dev_data); - - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_tdf8532, - tdf8532_dai, ARRAY_SIZE(tdf8532_dai)); - if (ret != 0) { - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); - goto out; - } - -out: - return ret; -} - -static int tdf8532_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - -static const struct i2c_device_id tdf8532_i2c_id[] = { - { "tdf8532", 0 }, - { } -}; - -MODULE_DEVICE_TABLE(i2c, tdf8532_i2c_id); - -#if CONFIG_ACPI -static const struct acpi_device_id tdf8532_acpi_match[] = { - {"INT34C3", 0}, - {}, -}; - -MODULE_DEVICE_TABLE(acpi, tdf8532_acpi_match); -#endif - -static struct i2c_driver tdf8532_i2c_driver = { - .driver = { - .name = "tdf8532-codec", - .owner = THIS_MODULE, - .acpi_match_table = ACPI_PTR(tdf8532_acpi_match), - }, - .probe = tdf8532_i2c_probe, - .remove = tdf8532_i2c_remove, - .id_table = tdf8532_i2c_id, -}; - -module_i2c_driver(tdf8532_i2c_driver); - -MODULE_DESCRIPTION("ASoC NXP Semiconductors TDF8532 driver"); -MODULE_AUTHOR("Steffen Wagner "); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/tdf8532.h b/sound/soc/codecs/tdf8532.h deleted file mode 100644 index 6e3f2c147eace9..00000000000000 --- a/sound/soc/codecs/tdf8532.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * tdf8532.h - Codec driver for NXP Semiconductors - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - - -#ifndef __TDF8532_H_ -#define __TDF8532_H_ - -#define ACK_TIMEOUT 300 - -#define CHNL_MAX 5 - -#define AMP_MOD 0x80 -#define END -1 - -#define MSG_TYPE_STX 0x02 -#define MSG_TYPE_NAK 0x15 -#define MSG_TYPE_ACK 0x6 - -#define HEADER_SIZE 3 -#define HEADER_TYPE 0 -#define HEADER_PKTID 1 -#define HEADER_LEN 2 - -/* Set commands */ -#define SET_CLK_STATE 0x1A -#define CLK_DISCONNECT 0x00 -#define CLK_CONNECT 0x01 - -#define SET_CHNL_ENABLE 0x26 -#define SET_CHNL_DISABLE 0x27 - -#define SET_CHNL_MUTE 0x42 -#define SET_CHNL_UNMUTE 0x43 - -struct header_repl { - u8 msg_type; - u8 pkt_id; - u8 len; -} __packed; - -#define GET_IDENT 0xE0 - -struct get_ident_repl { - struct header_repl header; - u8 module_id; - u8 cmd_id; - u8 type_name; - u8 hw_major; - u8 hw_minor; - u8 sw_major; - u8 sw_minor; - u8 sw_sub; -} __packed; - -#define GET_ERROR 0xE2 - -struct get_error_repl { - struct header_repl header; - u8 module_id; - u8 cmd_id; - u8 last_cmd_id; - u8 error; - u8 status; -} __packed; - -#define GET_DEV_STATUS 0x80 - -enum dev_state {STATE_BOOT, STATE_IDLE, STATE_STBY, STATE_LDAG, STATE_PLAY, - STATE_PROT, STATE_SDWN, STATE_CLFA, STATE_NONE }; - -struct get_dev_status_repl { - struct header_repl header; - u8 module_id; - u8 cmd_id; - u8 state; -} __packed; - -/* Helpers */ -#define CHNL_MASK(channels) (u8)((0x00FF << channels) >> 8) - -#define tdf8532_amp_write(dev_data, ...)\ - __tdf8532_single_write(dev_data, 0, AMP_MOD, __VA_ARGS__, END) - -struct tdf8532_priv { - struct i2c_client *i2c; - u8 channels; - u8 pkt_id; -}; - -#endif diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index 44168d6f0fd541..ee9179fd4f3857 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -260,16 +260,6 @@ config SND_SOC_INTEL_BXT_PCM512x_MACH with TI PCM512x I2S audio codec. Say Y or m if you have such a device. This is a recommended option. -config SND_SOC_INTEL_BXT_TDF8532_MACH - tristate "ASoC Audio driver for BXT with TDF8532 in I2S mode" - depends on X86 && ACPI && I2C - select SND_SOC_TDF8532 - select SND_SOC_COMPRESS - help - This adds support for ASoC machine driver for Broxton IVI GP MRB platform - Say Y if you have such a device. - If unsure select "N". - endif ## SND_SOC_INTEL_SKL || SND_SOC_SOF_APOLLOLAKE if SND_SOC_INTEL_SKL diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 8c7d03abeff397..f58a9bda911ddd 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -7,7 +7,6 @@ snd-soc-sst-broadwell-objs := broadwell.o snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o snd-soc-sst-bxt-rt298-objs := bxt_rt298.o snd-soc-sst-bxt-pcm512x-objs := bxt_pcm512x.o -snd-soc-sst_bxt_tdf8532-objs := bxt_tdf8532.o snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o @@ -31,7 +30,6 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += snd-soc-sst-bxt-da7219_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o obj-$(CONFIG_SND_SOC_INTEL_BXT_PCM512x_MACH) += snd-soc-sst-bxt-pcm512x.o -obj-$(CONFIG_SND_SOC_INTEL_BXT_TDF8532_MACH) += snd-soc-sst_bxt_tdf8532.o obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c deleted file mode 100644 index 1e0e633d493b6d..00000000000000 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ /dev/null @@ -1,440 +0,0 @@ -/* - * Intel Broxton-P I2S Machine Driver for IVI reference platform - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include -#include -#include -#include -#include -#include - -static const struct snd_kcontrol_new broxton_tdf8532_controls[] = { - SOC_DAPM_PIN_SWITCH("Speaker"), -}; - -static const struct snd_soc_dapm_widget broxton_tdf8532_widgets[] = { - SND_SOC_DAPM_SPK("Speaker", NULL), - SND_SOC_DAPM_MIC("DiranaCp", NULL), - SND_SOC_DAPM_HP("DiranaPb", NULL), - SND_SOC_DAPM_MIC("HdmiIn", NULL), - SND_SOC_DAPM_MIC("TestPinCp", NULL), - SND_SOC_DAPM_HP("TestPinPb", NULL), - SND_SOC_DAPM_MIC("BtHfpDl", NULL), - SND_SOC_DAPM_HP("BtHfpUl", NULL), - SND_SOC_DAPM_MIC("ModemDl", NULL), - SND_SOC_DAPM_HP("ModemUl", NULL), -}; - -static const struct snd_soc_dapm_route broxton_tdf8532_map[] = { - /* Speaker BE connections */ - { "Speaker", NULL, "ssp4 Tx"}, - { "ssp4 Tx", NULL, "codec0_out"}, - - { "dirana_in", NULL, "ssp2 Rx"}, - { "ssp2 Rx", NULL, "DiranaCp"}, - - { "dirana_aux_in", NULL, "ssp2 Rx"}, - { "ssp2 Rx", NULL, "DiranaCp"}, - - { "dirana_tuner_in", NULL, "ssp2 Rx"}, - { "ssp2 Rx", NULL, "DiranaCp"}, - - { "DiranaPb", NULL, "ssp2 Tx"}, - { "ssp2 Tx", NULL, "dirana_out"}, - - { "hdmi_ssp1_in", NULL, "ssp1 Rx"}, - { "ssp1 Rx", NULL, "HdmiIn"}, - - { "TestPin_ssp5_in", NULL, "ssp5 Rx"}, - { "ssp5 Rx", NULL, "TestPinCp"}, - - { "TestPinPb", NULL, "ssp5 Tx"}, - { "ssp5 Tx", NULL, "TestPin_ssp5_out"}, - - { "BtHfp_ssp0_in", NULL, "ssp0 Rx"}, - { "ssp0 Rx", NULL, "BtHfpDl"}, - - { "BtHfpUl", NULL, "ssp0 Tx"}, - { "ssp0 Tx", NULL, "BtHfp_ssp0_out"}, - - { "Modem_ssp3_in", NULL, "ssp3 Rx"}, - { "ssp3 Rx", NULL, "ModemDl"}, - - { "ModemUl", NULL, "ssp3 Tx"}, - { "ssp3 Tx", NULL, "Modem_ssp3_out"}, -}; - -static int bxt_tdf8532_ssp2_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) -{ - struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); - - /* set SSP to 32 bit */ - snd_mask_none(fmt); - snd_mask_set(fmt, SNDRV_PCM_FORMAT_S32_LE); - - return 0; -} - -/* broxton digital audio interface glue - connects codec <--> CPU */ -static struct snd_soc_dai_link broxton_tdf8532_dais[] = { - /* Front End DAI links */ - { - .name = "Speaker Port", - .stream_name = "Speaker", - .cpu_dai_name = "Speaker Pin", - .platform_name = "0000:00:0e.0", - .nonatomic = 1, - .dynamic = 1, - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .trigger = { - SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST - }, - .dpcm_playback = 1, - }, - { - .name = "Dirana Capture Port", - .stream_name = "Dirana Cp", - .cpu_dai_name = "Dirana Cp Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .dpcm_capture = 1, - .ignore_suspend = 1, - .nonatomic = 1, - .dynamic = 1, - }, - { - .name = "Dirana Playback Port", - .stream_name = "Dirana Pb", - .cpu_dai_name = "Dirana Pb Pin", - .platform_name = "0000:00:0e.0", - .nonatomic = 1, - .dynamic = 1, - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .trigger = { - SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST - }, - .dpcm_playback = 1, - }, - { - .name = "TestPin Capture Port", - .stream_name = "TestPin Cp", - .cpu_dai_name = "TestPin Cp Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .dpcm_capture = 1, - .ignore_suspend = 1, - .nonatomic = 1, - .dynamic = 1, - }, - { - .name = "TestPin Playback Port", - .stream_name = "TestPin Pb", - .cpu_dai_name = "TestPin Pb Pin", - .platform_name = "0000:00:0e.0", - .nonatomic = 1, - .dynamic = 1, - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .trigger = { - SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST - }, - .dpcm_playback = 1, - }, - { - .name = "BtHfp Capture Port", - .stream_name = "BtHfp Cp", - .cpu_dai_name = "BtHfp Cp Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .dpcm_capture = 1, - .ignore_suspend = 1, - .nonatomic = 1, - .dynamic = 1, - }, - { - .name = "BtHfp Playback Port", - .stream_name = "BtHfp Pb", - .cpu_dai_name = "BtHfp Pb Pin", - .platform_name = "0000:00:0e.0", - .nonatomic = 1, - .dynamic = 1, - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .trigger = { - SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST - }, - .dpcm_playback = 1, - }, - { - .name = "Modem Capture Port", - .stream_name = "Modem Cp", - .cpu_dai_name = "Modem Cp Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .dpcm_capture = 1, - .ignore_suspend = 1, - .nonatomic = 1, - .dynamic = 1, - }, - { - .name = "Modem Playback Port", - .stream_name = "Modem Pb", - .cpu_dai_name = "Modem Pb Pin", - .platform_name = "0000:00:0e.0", - .nonatomic = 1, - .dynamic = 1, - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .trigger = { - SND_SOC_DPCM_TRIGGER_POST, - SND_SOC_DPCM_TRIGGER_POST - }, - .dpcm_playback = 1, - }, - { - .name = "HDMI Capture Port", - .stream_name = "HDMI Cp", - .cpu_dai_name = "HDMI Cp Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .dpcm_capture = 1, - .ignore_suspend = 1, - .nonatomic = 1, - .dynamic = 1, - }, - { - .name = "Dirana Aux Capture Port", - .stream_name = "Dirana Aux Cp", - .cpu_dai_name = "Dirana Aux Cp Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .dpcm_capture = 1, - .ignore_suspend = 1, - .nonatomic = 1, - .dynamic = 1, - }, - { - .name = "Dirana Tuner Capture Port", - .stream_name = "Dirana Tuner Cp", - .cpu_dai_name = "Dirana Tuner Cp Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .dpcm_capture = 1, - .ignore_suspend = 1, - .nonatomic = 1, - .dynamic = 1, - }, - /* Probe DAI links*/ - { - .name = "Bxt Compress Probe playback", - .stream_name = "Probe Playback", - .cpu_dai_name = "Compress Probe0 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .nonatomic = 1, - .dynamic = 1, - }, - { - .name = "Bxt Compress Probe capture", - .stream_name = "Probe Capture", - .cpu_dai_name = "Compress Probe1 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .init = NULL, - .nonatomic = 1, - .dynamic = 1, - }, - /* Trace Buffer DAI links */ - { - .name = "Bxt Trace Buffer0", - .stream_name = "Core 0 Trace Buffer", - .cpu_dai_name = "TraceBuffer0 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .capture_only = true, - .ignore_suspend = 1, - .dynamic = 1, - }, - { - .name = "Bxt Trace Buffer1", - .stream_name = "Core 1 Trace Buffer", - .cpu_dai_name = "TraceBuffer1 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .capture_only = true, - .ignore_suspend = 1, - .dynamic = 1, - }, - /* Back End DAI links */ - { - /* SSP0 - BT */ - .name = "SSP0-Codec", - .id = 0, - .cpu_dai_name = "SSP0 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .ignore_suspend = 1, - .dpcm_capture = 1, - .dpcm_playback = 1, - .no_pcm = 1, - }, - { - /* SSP1 - HDMI-In */ - .name = "SSP1-Codec", - .id = 1, - .cpu_dai_name = "SSP1 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .ignore_suspend = 1, - .dpcm_capture = 1, - .no_pcm = 1, - }, - { - /* SSP2 - Dirana */ - .name = "SSP2-Codec", - .id = 2, - .cpu_dai_name = "SSP2 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .ignore_suspend = 1, - .dpcm_capture = 1, - .dpcm_playback = 1, - .no_pcm = 1, - .be_hw_params_fixup = bxt_tdf8532_ssp2_fixup, - }, - { - /* SSP3 - Modem */ - .name = "SSP3-Codec", - .id = 3, - .cpu_dai_name = "SSP3 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .ignore_suspend = 1, - .dpcm_capture = 1, - .dpcm_playback = 1, - .no_pcm = 1, - }, - { - /* SSP4 - Amplifier */ - .name = "SSP4-Codec", - .id = 4, - .cpu_dai_name = "SSP4 Pin", - .codec_name = "i2c-INT34C3:00", - .codec_dai_name = "tdf8532-hifi", - .platform_name = "0000:00:0e.0", - .ignore_suspend = 1, - .dpcm_playback = 1, - .no_pcm = 1, - }, - { - /* SSP5 - TestPin */ - .name = "SSP5-Codec", - .id = 5, - .cpu_dai_name = "SSP5 Pin", - .codec_name = "snd-soc-dummy", - .codec_dai_name = "snd-soc-dummy-dai", - .platform_name = "0000:00:0e.0", - .ignore_suspend = 1, - .dpcm_capture = 1, - .dpcm_playback = 1, - .no_pcm = 1, - }, -}; - -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL) -static int bxt_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *link) -{ - link->platform_name = "0000:00:0e.0"; - link->nonatomic = 1; - return 0; -} -#endif - -/* broxton audio machine driver for TDF8532 */ -static struct snd_soc_card broxton_tdf8532 = { - .name = "broxton_tdf8532", - .dai_link = broxton_tdf8532_dais, - .num_links = ARRAY_SIZE(broxton_tdf8532_dais), - .controls = broxton_tdf8532_controls, - .num_controls = ARRAY_SIZE(broxton_tdf8532_controls), - .dapm_widgets = broxton_tdf8532_widgets, - .num_dapm_widgets = ARRAY_SIZE(broxton_tdf8532_widgets), - .dapm_routes = broxton_tdf8532_map, - .num_dapm_routes = ARRAY_SIZE(broxton_tdf8532_map), - .fully_routed = true, -#if !IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL) - .add_dai_link = bxt_add_dai_link, -#endif -}; - -static int broxton_tdf8532_audio_probe(struct platform_device *pdev) -{ - dev_info(&pdev->dev, "%s registering %s\n", __func__, pdev->name); - broxton_tdf8532.dev = &pdev->dev; - return snd_soc_register_card(&broxton_tdf8532); -} - -static int broxton_tdf8532_audio_remove(struct platform_device *pdev) -{ - snd_soc_unregister_card(&broxton_tdf8532); - return 0; -} - -static struct platform_driver broxton_tdf8532_audio = { - .probe = broxton_tdf8532_audio_probe, - .remove = broxton_tdf8532_audio_remove, - .driver = { - .name = "bxt_tdf8532", - .pm = &snd_soc_pm_ops, - }, -}; - -module_platform_driver(broxton_tdf8532_audio) - -/* Module information */ -MODULE_DESCRIPTION("Intel SST Audio for Broxton GP MRB"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:gpmrb_machine"); -MODULE_ALIAS("platform:bxt_tdf8532"); From 75049e99e1a663dd68c2e1692a7285c3bbb7a591 Mon Sep 17 00:00:00 2001 From: "Wagner, Steffen" Date: Tue, 15 May 2018 17:14:50 +0800 Subject: [PATCH 02/18] ASoC: tdf8532: NXP TDF8532 audio class-D amplifier driver This is a basic driver to register the codec, expose the codec DAI and control the power mode of the amplifier. Change-Id: Ie6ab037cd4d6c87e8e139b6d8af6cd4295445bf2 Signed-off-by: Mohit Sinha Signed-off-by: Steffen Wagner Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/15296 Reviewed-by: B, Jayachandran Reviewed-by: Shaik, Kareem M Reviewed-by: Koul, Vinod Tested-by: Sm, Bhadur A --- sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tdf8532.c | 379 +++++++++++++++++++++++++++++++++++++ sound/soc/codecs/tdf8532.h | 101 ++++++++++ 4 files changed, 487 insertions(+) create mode 100644 sound/soc/codecs/tdf8532.c create mode 100644 sound/soc/codecs/tdf8532.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 9548f63ca531c8..fbacaa0a724bd4 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -157,6 +157,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_TAS5720 if I2C select SND_SOC_TAS6424 if I2C select SND_SOC_TDA7419 if I2C + select SND_SOC_TDF8532 if I2C select SND_SOC_TFA9879 if I2C select SND_SOC_TLV320AIC23_I2C if I2C select SND_SOC_TLV320AIC23_SPI if SPI_MASTER @@ -954,6 +955,10 @@ config SND_SOC_TDA7419 depends on I2C select REGMAP_I2C +config SND_SOC_TDF8532 + tristate + depends on I2C + config SND_SOC_TFA9879 tristate "NXP Semiconductors TFA9879 amplifier" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index e849d1495308f9..40480a5243ff2e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -168,6 +168,7 @@ snd-soc-tas571x-objs := tas571x.o snd-soc-tas5720-objs := tas5720.o snd-soc-tas6424-objs := tas6424.o snd-soc-tda7419-objs := tda7419.o +snd-soc-tdf8532-objs := tdf8532.o snd-soc-tfa9879-objs := tfa9879.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o @@ -420,6 +421,7 @@ obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o +obj-$(CONFIG_SND_SOC_TDF8532) += snd-soc-tdf8532.o obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c new file mode 100644 index 00000000000000..59db83da37587a --- /dev/null +++ b/sound/soc/codecs/tdf8532.c @@ -0,0 +1,379 @@ +/* + * Codec driver for NXP Semiconductors - TDF8532 + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tdf8532.h" + +static int __tdf8532_build_pkt(struct tdf8532_priv *dev_data, + va_list valist, u8 *payload) +{ + int param; + u8 len; + u8 *cmd_payload; + const u8 cmd_offset = 3; + + payload[HEADER_TYPE] = MSG_TYPE_STX; + payload[HEADER_PKTID] = dev_data->pkt_id; + + cmd_payload = &(payload[cmd_offset]); + + param = va_arg(valist, int); + len = 0; + + while (param != END) { + cmd_payload[len] = param; + + len++; + + param = va_arg(valist, int); + } + + payload[HEADER_LEN] = len; + + return len + cmd_offset; +} + +static int __tdf8532_single_write(struct tdf8532_priv *dev_data, + int dummy, ...) +{ + va_list valist; + int ret; + u8 len; + u8 payload[255]; + + va_start(valist, dummy); + + len = __tdf8532_build_pkt(dev_data, valist, payload); + + va_end(valist); + + print_hex_dump_debug("tdf8532-codec: Tx:", DUMP_PREFIX_NONE, 32, 1, + payload, len, false); + ret = i2c_master_send(dev_data->i2c, payload, len); + + dev_data->pkt_id++; + + if (ret < 0) { + dev_err(&(dev_data->i2c->dev), + "i2c send packet returned: %d\n", ret); + + return ret; + } + + return 0; +} + + +static uint8_t tdf8532_read_wait_ack(struct tdf8532_priv *dev_data, + unsigned long timeout) +{ + uint8_t ack_repl[HEADER_SIZE] = {0, 0, 0}; + unsigned long timeout_point = jiffies + timeout; + int ret; + + do { + ret = i2c_master_recv(dev_data->i2c, ack_repl, HEADER_SIZE); + if (ret < 0) + goto out; + } while (time_before(jiffies, timeout_point) && + ack_repl[0] != MSG_TYPE_ACK); + + if (ack_repl[0] != MSG_TYPE_ACK) + return -ETIME; + else + return ack_repl[2]; + +out: + return ret; +} + +static uint8_t tdf8532_single_read(struct tdf8532_priv *dev_data, + char **repl_buff) +{ + int ret; + uint8_t len; + + struct device *dev = &(dev_data->i2c->dev); + + ret = tdf8532_read_wait_ack(dev_data, msecs_to_jiffies(ACK_TIMEOUT)); + + if (ret < 0) { + dev_err(dev, + "Error waiting for ACK reply: %d\n", ret); + goto out; + } + + len = ret + HEADER_SIZE; + + *repl_buff = kzalloc(len, GFP_KERNEL); + + ret = i2c_master_recv(dev_data->i2c, *repl_buff, len); + + print_hex_dump_debug("tdf8532-codec: Rx:", DUMP_PREFIX_NONE, 32, 1, + *repl_buff, len, false); + + if (ret < 0 || ret != len) { + dev_err(dev, + "i2c recv packet returned: %d (expected: %d)\n", + ret, len); + goto out_free; + } + + return len; + +out_free: + kfree(*repl_buff); + repl_buff = NULL; +out: + return ret; +} + +static int tdf8532_get_state(struct tdf8532_priv *dev_data, + struct get_dev_status_repl **status_repl) +{ + int ret = 0; + char *repl_buff = NULL; + + ret = tdf8532_amp_write(dev_data, GET_DEV_STATUS); + if (ret < 0) + goto out; + + ret = tdf8532_single_read(dev_data, &repl_buff); + if (ret < 0) + goto out; + + *status_repl = (struct get_dev_status_repl *) repl_buff; + +out: + return ret; +} + +static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state, + unsigned long timeout) +{ + unsigned long timeout_point = jiffies + msecs_to_jiffies(timeout); + int ret; + struct get_dev_status_repl *status_repl; + struct device *dev = &(dev_data->i2c->dev); + + do { + ret = tdf8532_get_state(dev_data, &status_repl); + if (ret < 0) + goto out; + + print_hex_dump_debug("tdf8532-codec: wait_state: ", + DUMP_PREFIX_NONE, 32, 1, status_repl, + 6, false); + } while (time_before(jiffies, timeout_point) + && status_repl->state != req_state); + + if (status_repl->state == req_state) + return 0; + + ret = -ETIME; + + dev_err(dev, "tdf8532-codec: state: %u, req_state: %u, ret: %d\n", + status_repl->state, req_state, ret); + +out: + kfree(status_repl); + return ret; +} + +static int tdf8532_start_play(struct tdf8532_priv *tdf8532) +{ + int ret; + + ret = tdf8532_amp_write(tdf8532, SET_CLK_STATE, CLK_CONNECT); + if (ret < 0) + return ret; + + ret = tdf8532_amp_write(tdf8532, SET_CHNL_ENABLE, + CHNL_MASK(tdf8532->channels)); + + if (ret >= 0) + ret = tdf8532_wait_state(tdf8532, STATE_PLAY, ACK_TIMEOUT); + + return ret; +} + + +static int tdf8532_stop_play(struct tdf8532_priv *tdf8532) +{ + int ret; + + ret = tdf8532_amp_write(tdf8532, SET_CHNL_DISABLE, + CHNL_MASK(tdf8532->channels)); + if (ret < 0) + goto out; + + ret = tdf8532_wait_state(tdf8532, STATE_STBY, ACK_TIMEOUT); + if (ret < 0) + goto out; + + ret = tdf8532_amp_write(tdf8532, SET_CLK_STATE, CLK_DISCONNECT); + if (ret < 0) + goto out; + + ret = tdf8532_wait_state(tdf8532, STATE_IDLE, ACK_TIMEOUT); + +out: + return ret; +} + + +static int tdf8532_dai_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + int ret = 0; + struct snd_soc_codec *codec = dai->codec; + struct tdf8532_priv *tdf8532 = snd_soc_codec_get_drvdata(codec); + + dev_dbg(codec->dev, "%s: cmd = %d\n", __func__, cmd); + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + case SNDRV_PCM_TRIGGER_RESUME: + ret = tdf8532_start_play(tdf8532); + break; + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_STOP: + ret = tdf8532_stop_play(tdf8532); + break; + } + + return ret; +} + +static int tdf8532_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_codec *codec = dai->codec; + struct tdf8532_priv *tdf8532 = snd_soc_codec_get_drvdata(dai->codec); + + dev_dbg(codec->dev, "%s\n", __func__); + + if (mute) + return tdf8532_amp_write(tdf8532, SET_CHNL_MUTE, + CHNL_MASK(CHNL_MAX)); + else + return tdf8532_amp_write(tdf8532, SET_CHNL_UNMUTE, + CHNL_MASK(CHNL_MAX)); +} + +static const struct snd_soc_dai_ops tdf8532_dai_ops = { + .trigger = tdf8532_dai_trigger, + .digital_mute = tdf8532_mute, +}; + +static struct snd_soc_codec_driver soc_codec_tdf8532; + +static struct snd_soc_dai_driver tdf8532_dai[] = { + { + .name = "tdf8532-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 4, + .channels_max = 4, + .rates = SNDRV_PCM_RATE_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .ops = &tdf8532_dai_ops, + } +}; + +static int tdf8532_i2c_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + int ret; + struct tdf8532_priv *dev_data; + struct device *dev = &(i2c->dev); + + dev_dbg(&i2c->dev, "%s\n", __func__); + + dev_data = devm_kzalloc(dev, sizeof(struct tdf8532_priv), GFP_KERNEL); + + if (!dev_data) { + ret = -ENOMEM; + goto out; + } + + if (ret < 0) + dev_err(&i2c->dev, "Failed to set fast mute option: %d\n", ret); + + dev_data->i2c = i2c; + dev_data->pkt_id = 0; + dev_data->channels = 4; + + i2c_set_clientdata(i2c, dev_data); + + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_tdf8532, + tdf8532_dai, ARRAY_SIZE(tdf8532_dai)); + if (ret != 0) { + dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + goto out; + } + +out: + return ret; +} + +static int tdf8532_i2c_remove(struct i2c_client *i2c) +{ + snd_soc_unregister_codec(&i2c->dev); + + return 0; +} + +static const struct i2c_device_id tdf8532_i2c_id[] = { + { "tdf8532", 0 }, + { } +}; + +MODULE_DEVICE_TABLE(i2c, tdf8532_i2c_id); + +#if CONFIG_ACPI +static const struct acpi_device_id tdf8532_acpi_match[] = { + {"INT34C3", 0}, + {}, +}; + +MODULE_DEVICE_TABLE(acpi, tdf8532_acpi_match); +#endif + +static struct i2c_driver tdf8532_i2c_driver = { + .driver = { + .name = "tdf8532-codec", + .owner = THIS_MODULE, + .acpi_match_table = ACPI_PTR(tdf8532_acpi_match), + }, + .probe = tdf8532_i2c_probe, + .remove = tdf8532_i2c_remove, + .id_table = tdf8532_i2c_id, +}; + +module_i2c_driver(tdf8532_i2c_driver); + +MODULE_DESCRIPTION("ASoC NXP Semiconductors TDF8532 driver"); +MODULE_AUTHOR("Steffen Wagner "); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/tdf8532.h b/sound/soc/codecs/tdf8532.h new file mode 100644 index 00000000000000..6e3f2c147eace9 --- /dev/null +++ b/sound/soc/codecs/tdf8532.h @@ -0,0 +1,101 @@ +/* + * tdf8532.h - Codec driver for NXP Semiconductors + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + + +#ifndef __TDF8532_H_ +#define __TDF8532_H_ + +#define ACK_TIMEOUT 300 + +#define CHNL_MAX 5 + +#define AMP_MOD 0x80 +#define END -1 + +#define MSG_TYPE_STX 0x02 +#define MSG_TYPE_NAK 0x15 +#define MSG_TYPE_ACK 0x6 + +#define HEADER_SIZE 3 +#define HEADER_TYPE 0 +#define HEADER_PKTID 1 +#define HEADER_LEN 2 + +/* Set commands */ +#define SET_CLK_STATE 0x1A +#define CLK_DISCONNECT 0x00 +#define CLK_CONNECT 0x01 + +#define SET_CHNL_ENABLE 0x26 +#define SET_CHNL_DISABLE 0x27 + +#define SET_CHNL_MUTE 0x42 +#define SET_CHNL_UNMUTE 0x43 + +struct header_repl { + u8 msg_type; + u8 pkt_id; + u8 len; +} __packed; + +#define GET_IDENT 0xE0 + +struct get_ident_repl { + struct header_repl header; + u8 module_id; + u8 cmd_id; + u8 type_name; + u8 hw_major; + u8 hw_minor; + u8 sw_major; + u8 sw_minor; + u8 sw_sub; +} __packed; + +#define GET_ERROR 0xE2 + +struct get_error_repl { + struct header_repl header; + u8 module_id; + u8 cmd_id; + u8 last_cmd_id; + u8 error; + u8 status; +} __packed; + +#define GET_DEV_STATUS 0x80 + +enum dev_state {STATE_BOOT, STATE_IDLE, STATE_STBY, STATE_LDAG, STATE_PLAY, + STATE_PROT, STATE_SDWN, STATE_CLFA, STATE_NONE }; + +struct get_dev_status_repl { + struct header_repl header; + u8 module_id; + u8 cmd_id; + u8 state; +} __packed; + +/* Helpers */ +#define CHNL_MASK(channels) (u8)((0x00FF << channels) >> 8) + +#define tdf8532_amp_write(dev_data, ...)\ + __tdf8532_single_write(dev_data, 0, AMP_MOD, __VA_ARGS__, END) + +struct tdf8532_priv { + struct i2c_client *i2c; + u8 channels; + u8 pkt_id; +}; + +#endif From 820b3db8178e2f82642fbaf55255d471bbadfd39 Mon Sep 17 00:00:00 2001 From: "Gogineni, GiribabuX" Date: Tue, 15 May 2018 17:14:51 +0800 Subject: [PATCH 03/18] ASoC: tdf8532: Fix compilation warnings Initialized the reported variables, listed below warning: 'ret' may be used uninitialized in this function warning: 'status_repl' may be used uninitialized in this function Change-Id: I6ca5a6e017402a582239d75959c122ffaa9f7298 Signed-off-by: Gogineni, GiribabuX Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/17572 Reviewed-by: Singh, Guneshwor O Reviewed-by: Sinha, Mohit Reviewed-by: Shaik, Kareem M Reviewed-by: Koul, Vinod Tested-by: Sm, Bhadur A --- sound/soc/codecs/tdf8532.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c index 59db83da37587a..5f072079fbb76b 100644 --- a/sound/soc/codecs/tdf8532.c +++ b/sound/soc/codecs/tdf8532.c @@ -172,7 +172,7 @@ static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state, { unsigned long timeout_point = jiffies + msecs_to_jiffies(timeout); int ret; - struct get_dev_status_repl *status_repl; + struct get_dev_status_repl *status_repl = NULL; struct device *dev = &(dev_data->i2c->dev); do { @@ -318,9 +318,6 @@ static int tdf8532_i2c_probe(struct i2c_client *i2c, goto out; } - if (ret < 0) - dev_err(&i2c->dev, "Failed to set fast mute option: %d\n", ret); - dev_data->i2c = i2c; dev_data->pkt_id = 0; dev_data->channels = 4; From 4548d575ee3bb8ade888658c4240ba2dd5db41ff Mon Sep 17 00:00:00 2001 From: "Gogineni, GiribabuX" Date: Tue, 15 May 2018 17:14:52 +0800 Subject: [PATCH 04/18] ASoC: tdf8532: Add delay while reading a packet from I2C While doing the continuous play and stop, the codec may not be ready for I2C reading after successive writes. This triggers BE failure, because I2C reading value is incorrect. Fix this by adding 10ms delay to ensure the smooth I2C read and write. Change-Id: If918e263bc799fecc2c807229f5b4b165e011fa6 Signed-off-by: Gogineni, GiribabuX Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/20404 Reviewed-by: Shaik, Kareem M Reviewed-by: Sinha, Mohit Reviewed-by: Nc, Shreyas Reviewed-by: Periyasamy, SriramX Reviewed-by: Kale, Sanyog R Tested-by: Sm, Bhadur A --- sound/soc/codecs/tdf8532.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c index 5f072079fbb76b..1860e8264ebab8 100644 --- a/sound/soc/codecs/tdf8532.c +++ b/sound/soc/codecs/tdf8532.c @@ -90,6 +90,7 @@ static uint8_t tdf8532_read_wait_ack(struct tdf8532_priv *dev_data, unsigned long timeout_point = jiffies + timeout; int ret; + usleep_range(10000,20000); do { ret = i2c_master_recv(dev_data->i2c, ack_repl, HEADER_SIZE); if (ret < 0) From 39ccd4804d66fee7b9123d92c7bdc88619e510fb Mon Sep 17 00:00:00 2001 From: Liu Changcheng Date: Fri, 11 May 2018 17:24:01 +0800 Subject: [PATCH 05/18] ASoC: tdf8532: fix memleak in tdf8532_wait_state Fix kmemleak issue in tdf8532_wait_state function by releasing the memory getting allocated continuosly in instance of get_dev_status_repl i.e. status_repl before exiting the function. kernel memory leakage in audio stack/kmemleak backtrace: unreferenced object 0xffff88006227cc20 (size 32): comm "irq/25-snd_soc_", pid 2302, jiffies 4294679082 (age 5506.010s) hex dump (first 32 bytes): 02 00 03 80 80 02 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [] kmemleak_alloc+0x4a/0xa0 [] __kmalloc+0x128/0x210 [] tdf8532_wait_state.constprop.5+0x116/0x260 [snd_soc_tdf8532] [] tdf8532_dai_trigger+0xab/0x15a [snd_soc_tdf8532] [] soc_pcm_trigger+0x75/0x130 [] dpcm_do_trigger.isra.6+0x29/0x90 [] dpcm_be_dai_trigger+0x18d/0x350 Change-Id: I550897d6b1efbd5ebbe15ab47038adf99581a82f Tracked-On: https://jira01.devtools.intel.com/browse/OAM-62665 Signed-off-by: Liu Changcheng Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/23270 Reviewed-by: Shaik, ShahinaX Reviewed-by: Singh, Guneshwor O Reviewed-by: Gogineni, GiribabuX Reviewed-by: Tewani, Pradeep D Reviewed-by: Kesapragada, Pardha Saradhi Reviewed-by: Kp, Jeeja Tested-by: Madiwalar, MadiwalappaX --- sound/soc/codecs/tdf8532.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c index 1860e8264ebab8..aaf7254672cbeb 100644 --- a/sound/soc/codecs/tdf8532.c +++ b/sound/soc/codecs/tdf8532.c @@ -174,29 +174,31 @@ static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state, unsigned long timeout_point = jiffies + msecs_to_jiffies(timeout); int ret; struct get_dev_status_repl *status_repl = NULL; + u8 cur_state = STATE_NONE; struct device *dev = &(dev_data->i2c->dev); do { ret = tdf8532_get_state(dev_data, &status_repl); if (ret < 0) goto out; - + cur_state = status_repl->state; print_hex_dump_debug("tdf8532-codec: wait_state: ", DUMP_PREFIX_NONE, 32, 1, status_repl, 6, false); + + kfree(status_repl); + status_repl = NULL; } while (time_before(jiffies, timeout_point) - && status_repl->state != req_state); + && cur_state != req_state); - if (status_repl->state == req_state) + if (cur_state == req_state) return 0; +out: ret = -ETIME; dev_err(dev, "tdf8532-codec: state: %u, req_state: %u, ret: %d\n", - status_repl->state, req_state, ret); - -out: - kfree(status_repl); + cur_state, req_state, ret); return ret; } From ea8e1e418aa315d36a4b248ca86b3735212a7a63 Mon Sep 17 00:00:00 2001 From: Liu Changcheng Date: Fri, 11 May 2018 17:11:42 +0800 Subject: [PATCH 06/18] ASoC: tdf8532: right free allocated space in case of error 1. Check allocated space before using it. 2. The repl_buff parameter in tdf8523_single_read is used to store the read data from i2c interface. When the data isn't right read, the pre-allocate space should be freed and the content of repl_buff should be set as NULL in case of being wrong used by the caller. 3. In the wrong case i.e. ret != len, return -EINVAL Change-Id: I3d0e12a9fcb6516716efc92eb734a0248ab3fb28 Tracked-On: https://jira01.devtools.intel.com/browse/OAM-62665 Signed-off-by: Liu Changcheng Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/23266 Reviewed-by: Shaik, ShahinaX Reviewed-by: Kesapragada, Pardha Saradhi Reviewed-by: Gogineni, GiribabuX Reviewed-by: Singh, Guneshwor O Reviewed-by: Tewani, Pradeep D Reviewed-by: Kp, Jeeja Tested-by: Madiwalar, MadiwalappaX --- sound/soc/codecs/tdf8532.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c index aaf7254672cbeb..685a20d98b6b6a 100644 --- a/sound/soc/codecs/tdf8532.c +++ b/sound/soc/codecs/tdf8532.c @@ -107,11 +107,11 @@ static uint8_t tdf8532_read_wait_ack(struct tdf8532_priv *dev_data, return ret; } -static uint8_t tdf8532_single_read(struct tdf8532_priv *dev_data, +static int tdf8532_single_read(struct tdf8532_priv *dev_data, char **repl_buff) { int ret; - uint8_t len; + int len; struct device *dev = &(dev_data->i2c->dev); @@ -126,6 +126,10 @@ static uint8_t tdf8532_single_read(struct tdf8532_priv *dev_data, len = ret + HEADER_SIZE; *repl_buff = kzalloc(len, GFP_KERNEL); + if (*repl_buff == NULL) { + ret = -ENOMEM; + goto out; + } ret = i2c_master_recv(dev_data->i2c, *repl_buff, len); @@ -136,6 +140,8 @@ static uint8_t tdf8532_single_read(struct tdf8532_priv *dev_data, dev_err(dev, "i2c recv packet returned: %d (expected: %d)\n", ret, len); + + ret = -EINVAL; goto out_free; } @@ -143,7 +149,7 @@ static uint8_t tdf8532_single_read(struct tdf8532_priv *dev_data, out_free: kfree(*repl_buff); - repl_buff = NULL; + *repl_buff = NULL; out: return ret; } From 3141c269de8d8c6966c5a5b0b7abe5da85665f83 Mon Sep 17 00:00:00 2001 From: Wu Zhigang Date: Tue, 15 May 2018 17:14:53 +0800 Subject: [PATCH 07/18] ASoC: tdf8532: Fix the codec status error issue on APL-GPMRB Based on the TDF8532 manual: If the wait_state result is ok, we should send CLK_DISCONNECT command to force codec from STANDBY(2) to IDLE(1). If the wait_state result is timeout, the codec state should be at Clockfail(7), we still should send CLK_DISCONNECT command force the codec from Clockfail(7) to Idle(1). Signed-off-by: Wu Zhigang Reviewed-by: Keyon Jie --- sound/soc/codecs/tdf8532.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c index 685a20d98b6b6a..0ef8fe406270a5 100644 --- a/sound/soc/codecs/tdf8532.c +++ b/sound/soc/codecs/tdf8532.c @@ -236,8 +236,14 @@ static int tdf8532_stop_play(struct tdf8532_priv *tdf8532) goto out; ret = tdf8532_wait_state(tdf8532, STATE_STBY, ACK_TIMEOUT); - if (ret < 0) - goto out; + + /* Refer to TDF8532 manual: + * If the wait_state result is ok, we should send CLK_DISCONNECT + * command to force codec from STANDBY(2) to IDLE(1). + * If the wait_state result is timeout, the codec state should be + * at Clockfail(7), we still should send CLK_DISCONNECT command + * force the codec from Clockfail(7) to Idle(1). + */ ret = tdf8532_amp_write(tdf8532, SET_CLK_STATE, CLK_DISCONNECT); if (ret < 0) From 078d219050cf0bad39abedfbf07b79b3f4353998 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Sat, 23 Jun 2018 08:45:49 -0500 Subject: [PATCH 08/18] ASoC: codecs: tdf8532: move to component model Needs to be squashed for 4.18+ Signed-off-by: Pierre-Louis Bossart --- sound/soc/codecs/tdf8532.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c index 0ef8fe406270a5..8a5928a894ca24 100644 --- a/sound/soc/codecs/tdf8532.c +++ b/sound/soc/codecs/tdf8532.c @@ -260,10 +260,10 @@ static int tdf8532_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { int ret = 0; - struct snd_soc_codec *codec = dai->codec; - struct tdf8532_priv *tdf8532 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tdf8532_priv *tdf8532 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: cmd = %d\n", __func__, cmd); + dev_dbg(component->dev, "%s: cmd = %d\n", __func__, cmd); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -283,10 +283,10 @@ static int tdf8532_dai_trigger(struct snd_pcm_substream *substream, int cmd, static int tdf8532_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct tdf8532_priv *tdf8532 = snd_soc_codec_get_drvdata(dai->codec); + struct snd_soc_component *component = dai->component; + struct tdf8532_priv *tdf8532 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s\n", __func__); + dev_dbg(component->dev, "%s\n", __func__); if (mute) return tdf8532_amp_write(tdf8532, SET_CHNL_MUTE, @@ -301,7 +301,7 @@ static const struct snd_soc_dai_ops tdf8532_dai_ops = { .digital_mute = tdf8532_mute, }; -static struct snd_soc_codec_driver soc_codec_tdf8532; +static struct snd_soc_component_driver soc_component_tdf8532; static struct snd_soc_dai_driver tdf8532_dai[] = { { @@ -339,7 +339,7 @@ static int tdf8532_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, dev_data); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_tdf8532, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_tdf8532, tdf8532_dai, ARRAY_SIZE(tdf8532_dai)); if (ret != 0) { dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); @@ -352,8 +352,6 @@ static int tdf8532_i2c_probe(struct i2c_client *i2c, static int tdf8532_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); - return 0; } From 42f6c0b8530a4d9873819c72170fe235269eca9f Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Tue, 22 May 2018 18:23:43 +0800 Subject: [PATCH 09/18] ASoC: Intel: Boards: Add BXTP MRB machine driver for NXP TDF8532 This is the machine driver for NXP TDF8532 Change-Id: Ieee7ba1fc2dab6fbe43836b65def88c81360d48f Signed-off-by: Mohit Sinha Signed-off-by: Markus Schweikhardt Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/15375 Reviewed-by: Shaik, Kareem M Reviewed-by: B, Jayachandran Reviewed-by: Koul, Vinod Tested-by: Sm, Bhadur A --- sound/soc/intel/boards/Kconfig | 10 ++ sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/bxt_tdf8532.c | 209 +++++++++++++++++++++++++++ 3 files changed, 221 insertions(+) create mode 100644 sound/soc/intel/boards/bxt_tdf8532.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index ee9179fd4f3857..44168d6f0fd541 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -260,6 +260,16 @@ config SND_SOC_INTEL_BXT_PCM512x_MACH with TI PCM512x I2S audio codec. Say Y or m if you have such a device. This is a recommended option. +config SND_SOC_INTEL_BXT_TDF8532_MACH + tristate "ASoC Audio driver for BXT with TDF8532 in I2S mode" + depends on X86 && ACPI && I2C + select SND_SOC_TDF8532 + select SND_SOC_COMPRESS + help + This adds support for ASoC machine driver for Broxton IVI GP MRB platform + Say Y if you have such a device. + If unsure select "N". + endif ## SND_SOC_INTEL_SKL || SND_SOC_SOF_APOLLOLAKE if SND_SOC_INTEL_SKL diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index f58a9bda911ddd..8c7d03abeff397 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -7,6 +7,7 @@ snd-soc-sst-broadwell-objs := broadwell.o snd-soc-sst-bxt-da7219_max98357a-objs := bxt_da7219_max98357a.o snd-soc-sst-bxt-rt298-objs := bxt_rt298.o snd-soc-sst-bxt-pcm512x-objs := bxt_pcm512x.o +snd-soc-sst_bxt_tdf8532-objs := bxt_tdf8532.o snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o @@ -30,6 +31,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH) += snd-soc-sst-bxt-da7219_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_BXT_RT298_MACH) += snd-soc-sst-bxt-rt298.o obj-$(CONFIG_SND_SOC_INTEL_BXT_PCM512x_MACH) += snd-soc-sst-bxt-pcm512x.o +obj-$(CONFIG_SND_SOC_INTEL_BXT_TDF8532_MACH) += snd-soc-sst_bxt_tdf8532.o obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o obj-$(CONFIG_SND_SOC_INTEL_BDW_RT5677_MACH) += snd-soc-sst-bdw-rt5677-mach.o obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c new file mode 100644 index 00000000000000..027060b17322a3 --- /dev/null +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -0,0 +1,209 @@ +/* + * Intel Broxton-P I2S Machine Driver for IVI reference platform + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include + +static const struct snd_kcontrol_new broxton_tdf8532_controls[] = { + SOC_DAPM_PIN_SWITCH("Speaker"), +}; + +static const struct snd_soc_dapm_widget broxton_tdf8532_widgets[] = { + SND_SOC_DAPM_SPK("Speaker", NULL), + SND_SOC_DAPM_MIC("DiranaCp", NULL), + SND_SOC_DAPM_HP("DiranaPb", NULL), + SND_SOC_DAPM_MIC("HdmiIn", NULL), + SND_SOC_DAPM_MIC("TestPinCp", NULL), + SND_SOC_DAPM_HP("TestPinPb", NULL), + SND_SOC_DAPM_MIC("BtHfpDl", NULL), + SND_SOC_DAPM_HP("BtHfpUl", NULL), + SND_SOC_DAPM_MIC("ModemDl", NULL), + SND_SOC_DAPM_HP("ModemUl", NULL), +}; + +static const struct snd_soc_dapm_route broxton_tdf8532_map[] = { + + /* Speaker BE connections */ + { "Speaker", NULL, "ssp4 Tx"}, + { "ssp4 Tx", NULL, "codec0_out"}, + + { "dirana_in", NULL, "ssp2 Rx"}, + { "ssp2 Rx", NULL, "DiranaCp"}, + + { "dirana_aux_in", NULL, "ssp2 Rx"}, + { "ssp2 Rx", NULL, "DiranaCp"}, + + { "dirana_tuner_in", NULL, "ssp2 Rx"}, + { "ssp2 Rx", NULL, "DiranaCp"}, + + { "DiranaPb", NULL, "ssp2 Tx"}, + { "ssp2 Tx", NULL, "dirana_out"}, + + { "hdmi_ssp1_in", NULL, "ssp1 Rx"}, + { "ssp1 Rx", NULL, "HdmiIn"}, + + { "TestPin_ssp5_in", NULL, "ssp5 Rx"}, + { "ssp5 Rx", NULL, "TestPinCp"}, + + { "TestPinPb", NULL, "ssp5 Tx"}, + { "ssp5 Tx", NULL, "TestPin_ssp5_out"}, + + { "BtHfp_ssp0_in", NULL, "ssp0 Rx"}, + { "ssp0 Rx", NULL, "BtHfpDl"}, + + { "BtHfpUl", NULL, "ssp0 Tx"}, + { "ssp0 Tx", NULL, "BtHfp_ssp0_out"}, + + { "Modem_ssp3_in", NULL, "ssp3 Rx"}, + { "ssp3 Rx", NULL, "ModemDl"}, + + { "ModemUl", NULL, "ssp3 Tx"}, + { "ssp3 Tx", NULL, "Modem_ssp3_out"}, +}; + +/* broxton digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link broxton_tdf8532_dais[] = { + /* Back End DAI links */ + { + /* SSP0 - BT */ + .name = "SSP0-Codec", + .id = 0, + .cpu_dai_name = "SSP0 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .ignore_suspend = 1, + .dpcm_capture = 1, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + /* SSP1 - HDMI-In */ + .name = "SSP1-Codec", + .id = 1, + .cpu_dai_name = "SSP1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + }, + { + /* SSP2 - Dirana */ + .name = "SSP2-Codec", + .id = 2, + .cpu_dai_name = "SSP2 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .ignore_suspend = 1, + .dpcm_capture = 1, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + /* SSP3 - Modem */ + .name = "SSP3-Codec", + .id = 3, + .cpu_dai_name = "SSP3 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .ignore_suspend = 1, + .dpcm_capture = 1, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + /* SSP4 - Amplifier */ + .name = "SSP4-Codec", + .id = 4, + .cpu_dai_name = "SSP4 Pin", + .codec_name = "i2c-INT34C3:00", + .codec_dai_name = "tdf8532-hifi", + .platform_name = "0000:00:0e.0", + .ignore_suspend = 1, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + /* SSP5 - TestPin */ + .name = "SSP5-Codec", + .id = 5, + .cpu_dai_name = "SSP5 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .ignore_suspend = 1, + .dpcm_capture = 1, + .dpcm_playback = 1, + .no_pcm = 1, + }, +}; + +static int bxt_add_dai_link(struct snd_soc_card *card, + struct snd_soc_dai_link *link) +{ + link->platform_name = "0000:00:0e.0"; + link->nonatomic = 1; + return 0; +} + +/* broxton audio machine driver for TDF8532 */ +static struct snd_soc_card broxton_tdf8532 = { + .name = "broxton_tdf8532", + .dai_link = broxton_tdf8532_dais, + .num_links = ARRAY_SIZE(broxton_tdf8532_dais), + .controls = broxton_tdf8532_controls, + .num_controls = ARRAY_SIZE(broxton_tdf8532_controls), + .dapm_widgets = broxton_tdf8532_widgets, + .num_dapm_widgets = ARRAY_SIZE(broxton_tdf8532_widgets), + .dapm_routes = broxton_tdf8532_map, + .num_dapm_routes = ARRAY_SIZE(broxton_tdf8532_map), + .fully_routed = true, + .add_dai_link = bxt_add_dai_link, +}; + +static int broxton_tdf8532_audio_probe(struct platform_device *pdev) +{ + dev_info(&pdev->dev, "%s registering %s\n", __func__, pdev->name); + broxton_tdf8532.dev = &pdev->dev; + return snd_soc_register_card(&broxton_tdf8532); +} + +static int broxton_tdf8532_audio_remove(struct platform_device *pdev) +{ + snd_soc_unregister_card(&broxton_tdf8532); + return 0; +} + +static struct platform_driver broxton_tdf8532_audio = { + .probe = broxton_tdf8532_audio_probe, + .remove = broxton_tdf8532_audio_remove, + .driver = { + .name = "bxt_tdf8532", + }, +}; + +module_platform_driver(broxton_tdf8532_audio) + +/* Module information */ +MODULE_DESCRIPTION("Intel SST Audio for Broxton GP MRB"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:gpmrb_machine"); From 94d68e000c2810d59c3327c623efc7beb0980c2d Mon Sep 17 00:00:00 2001 From: "Sinha, Mohit" Date: Thu, 6 Jul 2017 16:10:32 +0530 Subject: [PATCH 10/18] ASoC: Intel: Board: DAI links for probe in GPMRB machine driver Added two DAI links for probe playback and capture Change-Id: I0bf364eba3b6a2b779625a6fd1b664c2530a1ab2 Signed-off-by: Sinha, Mohit --- sound/soc/intel/boards/bxt_tdf8532.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index 027060b17322a3..1e2b8be0012707 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -78,6 +78,27 @@ static const struct snd_soc_dapm_route broxton_tdf8532_map[] = { /* broxton digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { + /* Probe DAI links*/ + { + .name = "Bxt Compress Probe playback", + .stream_name = "Probe Playback", + .cpu_dai_name = "Compress Probe0 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .init = NULL, + .nonatomic = 1, + }, + { + .name = "Bxt Compress Probe capture", + .stream_name = "Probe Capture", + .cpu_dai_name = "Compress Probe1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .init = NULL, + .nonatomic = 1, + }, /* Back End DAI links */ { /* SSP0 - BT */ From d8be288913414e8c5925a3385635f570fb713c08 Mon Sep 17 00:00:00 2001 From: "Sinha, Mohit" Date: Thu, 6 Jul 2017 16:21:19 +0530 Subject: [PATCH 11/18] ASoC: Intel: Boards: Add FW logging DAI-links for GPMRB Add two FW logging DAI for each DSP core Change-Id: Ic825ecb4afbbcacabda6b74e2e5f2969fc722a1f Signed-off-by: Sinha, Mohit --- sound/soc/intel/boards/bxt_tdf8532.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index 1e2b8be0012707..325b59adaf1c05 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -99,6 +99,27 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { .init = NULL, .nonatomic = 1, }, + /* Trace Buffer DAI links */ + { + .name = "Bxt Trace Buffer0", + .stream_name = "Core 0 Trace Buffer", + .cpu_dai_name = "TraceBuffer0 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .capture_only = true, + .ignore_suspend = 1, + }, + { + .name = "Bxt Trace Buffer1", + .stream_name = "Core 1 Trace Buffer", + .cpu_dai_name = "TraceBuffer1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:0e.0", + .capture_only = true, + .ignore_suspend = 1, + }, /* Back End DAI links */ { /* SSP0 - BT */ From 8d04fe197f712d150c501c919650cbdbe132483d Mon Sep 17 00:00:00 2001 From: "Kareem,Shaik" Date: Wed, 30 Aug 2017 16:46:40 +0530 Subject: [PATCH 12/18] ASoC: Intel: Board: Add pm_ops to fix suspend/resume issue Audio playback not resumed after it is suspended. Add snd_soc_pm_ops to execute power management operation. Change-Id: I84ccf6a0ac7e35c1f79971ee59555f24024d4309 Signed-off-by: Mohit Sinha Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/17914 Reviewed-by: Shaik, Kareem M Reviewed-by: Prusty, Subhransu S Reviewed-by: H S, Vijay Reviewed-by: Kp, Jeeja Reviewed-by: audio_build Reviewed-by: Koul, Vinod Tested-by: Avati, Santosh Kumar --- sound/soc/intel/boards/bxt_tdf8532.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index 325b59adaf1c05..c7b7fe3f9ed7c4 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -240,6 +240,7 @@ static struct platform_driver broxton_tdf8532_audio = { .remove = broxton_tdf8532_audio_remove, .driver = { .name = "bxt_tdf8532", + .pm = &snd_soc_pm_ops, }, }; From c794c8d1ae306ae1f9e79d37a9c0ff66cbfaf02d Mon Sep 17 00:00:00 2001 From: Mohit Sinha Date: Mon, 4 Sep 2017 23:31:17 +0530 Subject: [PATCH 13/18] ASoC: Intel: Board: Add fixup for 32 bit masking Fixup function does the masking of the format to set the SSP2 to 32 bit Change-Id: I1c5f20ce1244f9c3a47a47342d46184fdd718290 Signed-off-by: Mohit Sinha Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/18076 Reviewed-by: Gogineni, GiribabuX Reviewed-by: Shaik, Kareem M Reviewed-by: Koul, Vinod Tested-by: Sm, Bhadur A --- sound/soc/intel/boards/bxt_tdf8532.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index c7b7fe3f9ed7c4..27361e8f72d3f0 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -76,6 +76,18 @@ static const struct snd_soc_dapm_route broxton_tdf8532_map[] = { { "ssp3 Tx", NULL, "Modem_ssp3_out"}, }; +static int bxt_tdf8532_ssp2_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* set SSP to 32 bit */ + snd_mask_none(fmt); + snd_mask_set(fmt, SNDRV_PCM_FORMAT_S32_LE); + + return 0; +} + /* broxton digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { /* Probe DAI links*/ @@ -158,6 +170,7 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { .dpcm_capture = 1, .dpcm_playback = 1, .no_pcm = 1, + .be_hw_params_fixup = bxt_tdf8532_ssp2_fixup, }, { /* SSP3 - Modem */ From 4ed2bb310fe489d655f5824c5a15b3c7ab615b30 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Tue, 22 May 2018 18:23:44 +0800 Subject: [PATCH 14/18] ASoC: Intel: bxt-tdf8532: reuse machine driver for GP-MRB Signed-off-by: Keyon Jie --- sound/soc/intel/boards/bxt_tdf8532.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index 27361e8f72d3f0..4dd73d356740f4 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -263,3 +263,4 @@ module_platform_driver(broxton_tdf8532_audio) MODULE_DESCRIPTION("Intel SST Audio for Broxton GP MRB"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:gpmrb_machine"); +MODULE_ALIAS("platform:bxt_tdf8532"); From df308620dae4f49ae87c894297e084d25db5c819 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 28 May 2018 13:43:18 +0800 Subject: [PATCH 15/18] ASoC: Intel: bxt-tdf8532: FIX: don't use add_dai_link() for SOF We set ignore_machine for SOF soc platform driver, which will trigger overriding FEs in soc_check_tplg_fes(), but this overriding may be overidden again by add_dai_link() in bxt_tdf8532, e.g. platform_name will be modified to be "0000:00:0e.0", which is not exist in SOF. Here add #ifdef to bypass add_dai_link() for using the machine driver with SOF to fix the overridden again issue. Signed-off-by: Keyon Jie --- sound/soc/intel/boards/bxt_tdf8532.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index 4dd73d356740f4..dd8bdfd352b2d1 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -212,6 +212,7 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { }, }; +#if !IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL) static int bxt_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *link) { @@ -219,6 +220,7 @@ static int bxt_add_dai_link(struct snd_soc_card *card, link->nonatomic = 1; return 0; } +#endif /* broxton audio machine driver for TDF8532 */ static struct snd_soc_card broxton_tdf8532 = { @@ -232,7 +234,9 @@ static struct snd_soc_card broxton_tdf8532 = { .dapm_routes = broxton_tdf8532_map, .num_dapm_routes = ARRAY_SIZE(broxton_tdf8532_map), .fully_routed = true, +#if !IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL) .add_dai_link = bxt_add_dai_link, +#endif }; static int broxton_tdf8532_audio_probe(struct platform_device *pdev) From 5c699155ccdae986c712e0e762fb1ae5f23d9e19 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 20 Jun 2018 16:50:51 +0800 Subject: [PATCH 16/18] ASoC: Intel: bxt-tdf8532: change probe and trace buffer dai_links to dynamic We should use .dynamic for all FE dai_links, so change probe and trace buffer ones here to align to that. Signed-off-by: Keyon Jie --- sound/soc/intel/boards/bxt_tdf8532.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index dd8bdfd352b2d1..abdc04e389a8fb 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -100,6 +100,7 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { .platform_name = "0000:00:0e.0", .init = NULL, .nonatomic = 1, + .dynamic = 1, }, { .name = "Bxt Compress Probe capture", @@ -110,6 +111,7 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { .platform_name = "0000:00:0e.0", .init = NULL, .nonatomic = 1, + .dynamic = 1, }, /* Trace Buffer DAI links */ { @@ -121,6 +123,7 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { .platform_name = "0000:00:0e.0", .capture_only = true, .ignore_suspend = 1, + .dynamic = 1, }, { .name = "Bxt Trace Buffer1", @@ -131,6 +134,7 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { .platform_name = "0000:00:0e.0", .capture_only = true, .ignore_suspend = 1, + .dynamic = 1, }, /* Back End DAI links */ { From f8bff0c0f74857a2da03b8ff36a7684fcdd9ea03 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 2 Jul 2018 13:31:56 -0500 Subject: [PATCH 17/18] ASoC: codecs: TDF8532: use Linux style Make checkpatch happy, no functionality change Signed-off-by: Pierre-Louis Bossart --- sound/soc/codecs/tdf8532.c | 82 ++++++++++++++++---------------------- sound/soc/codecs/tdf8532.h | 13 +----- 2 files changed, 37 insertions(+), 58 deletions(-) diff --git a/sound/soc/codecs/tdf8532.c b/sound/soc/codecs/tdf8532.c index 8a5928a894ca24..d8ae9ff441c8d9 100644 --- a/sound/soc/codecs/tdf8532.c +++ b/sound/soc/codecs/tdf8532.c @@ -1,15 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Codec driver for NXP Semiconductors - TDF8532 * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. */ #include @@ -24,7 +16,7 @@ #include "tdf8532.h" static int __tdf8532_build_pkt(struct tdf8532_priv *dev_data, - va_list valist, u8 *payload) + va_list valist, u8 *payload) { int param; u8 len; @@ -34,7 +26,7 @@ static int __tdf8532_build_pkt(struct tdf8532_priv *dev_data, payload[HEADER_TYPE] = MSG_TYPE_STX; payload[HEADER_PKTID] = dev_data->pkt_id; - cmd_payload = &(payload[cmd_offset]); + cmd_payload = &payload[cmd_offset]; param = va_arg(valist, int); len = 0; @@ -53,7 +45,7 @@ static int __tdf8532_build_pkt(struct tdf8532_priv *dev_data, } static int __tdf8532_single_write(struct tdf8532_priv *dev_data, - int dummy, ...) + int dummy, ...) { va_list valist; int ret; @@ -67,14 +59,14 @@ static int __tdf8532_single_write(struct tdf8532_priv *dev_data, va_end(valist); print_hex_dump_debug("tdf8532-codec: Tx:", DUMP_PREFIX_NONE, 32, 1, - payload, len, false); + payload, len, false); ret = i2c_master_send(dev_data->i2c, payload, len); dev_data->pkt_id++; if (ret < 0) { - dev_err(&(dev_data->i2c->dev), - "i2c send packet returned: %d\n", ret); + dev_err(&dev_data->i2c->dev, + "i2c send packet returned: %d\n", ret); return ret; } @@ -82,15 +74,14 @@ static int __tdf8532_single_write(struct tdf8532_priv *dev_data, return 0; } - -static uint8_t tdf8532_read_wait_ack(struct tdf8532_priv *dev_data, - unsigned long timeout) +static u8 tdf8532_read_wait_ack(struct tdf8532_priv *dev_data, + unsigned long timeout) { - uint8_t ack_repl[HEADER_SIZE] = {0, 0, 0}; + u8 ack_repl[HEADER_SIZE] = {0, 0, 0}; unsigned long timeout_point = jiffies + timeout; int ret; - usleep_range(10000,20000); + usleep_range(10000, 20000); do { ret = i2c_master_recv(dev_data->i2c, ack_repl, HEADER_SIZE); if (ret < 0) @@ -108,18 +99,18 @@ static uint8_t tdf8532_read_wait_ack(struct tdf8532_priv *dev_data, } static int tdf8532_single_read(struct tdf8532_priv *dev_data, - char **repl_buff) + char **repl_buff) { int ret; int len; - struct device *dev = &(dev_data->i2c->dev); + struct device *dev = &dev_data->i2c->dev; ret = tdf8532_read_wait_ack(dev_data, msecs_to_jiffies(ACK_TIMEOUT)); if (ret < 0) { dev_err(dev, - "Error waiting for ACK reply: %d\n", ret); + "Error waiting for ACK reply: %d\n", ret); goto out; } @@ -134,12 +125,12 @@ static int tdf8532_single_read(struct tdf8532_priv *dev_data, ret = i2c_master_recv(dev_data->i2c, *repl_buff, len); print_hex_dump_debug("tdf8532-codec: Rx:", DUMP_PREFIX_NONE, 32, 1, - *repl_buff, len, false); + *repl_buff, len, false); if (ret < 0 || ret != len) { dev_err(dev, - "i2c recv packet returned: %d (expected: %d)\n", - ret, len); + "i2c recv packet returned: %d (expected: %d)\n", + ret, len); ret = -EINVAL; goto out_free; @@ -155,10 +146,10 @@ static int tdf8532_single_read(struct tdf8532_priv *dev_data, } static int tdf8532_get_state(struct tdf8532_priv *dev_data, - struct get_dev_status_repl **status_repl) + struct get_dev_status_repl **status_repl) { - int ret = 0; char *repl_buff = NULL; + int ret = 0; ret = tdf8532_amp_write(dev_data, GET_DEV_STATUS); if (ret < 0) @@ -168,20 +159,20 @@ static int tdf8532_get_state(struct tdf8532_priv *dev_data, if (ret < 0) goto out; - *status_repl = (struct get_dev_status_repl *) repl_buff; + *status_repl = (struct get_dev_status_repl *)repl_buff; out: return ret; } static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state, - unsigned long timeout) + unsigned long timeout) { unsigned long timeout_point = jiffies + msecs_to_jiffies(timeout); - int ret; + struct device *dev = &dev_data->i2c->dev; struct get_dev_status_repl *status_repl = NULL; u8 cur_state = STATE_NONE; - struct device *dev = &(dev_data->i2c->dev); + int ret; do { ret = tdf8532_get_state(dev_data, &status_repl); @@ -189,13 +180,12 @@ static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state, goto out; cur_state = status_repl->state; print_hex_dump_debug("tdf8532-codec: wait_state: ", - DUMP_PREFIX_NONE, 32, 1, status_repl, - 6, false); + DUMP_PREFIX_NONE, 32, 1, status_repl, + 6, false); kfree(status_repl); status_repl = NULL; - } while (time_before(jiffies, timeout_point) - && cur_state != req_state); + } while (time_before(jiffies, timeout_point) && cur_state != req_state); if (cur_state == req_state) return 0; @@ -204,7 +194,7 @@ static int tdf8532_wait_state(struct tdf8532_priv *dev_data, u8 req_state, ret = -ETIME; dev_err(dev, "tdf8532-codec: state: %u, req_state: %u, ret: %d\n", - cur_state, req_state, ret); + cur_state, req_state, ret); return ret; } @@ -217,7 +207,7 @@ static int tdf8532_start_play(struct tdf8532_priv *tdf8532) return ret; ret = tdf8532_amp_write(tdf8532, SET_CHNL_ENABLE, - CHNL_MASK(tdf8532->channels)); + CHNL_MASK(tdf8532->channels)); if (ret >= 0) ret = tdf8532_wait_state(tdf8532, STATE_PLAY, ACK_TIMEOUT); @@ -225,13 +215,12 @@ static int tdf8532_start_play(struct tdf8532_priv *tdf8532) return ret; } - static int tdf8532_stop_play(struct tdf8532_priv *tdf8532) { int ret; ret = tdf8532_amp_write(tdf8532, SET_CHNL_DISABLE, - CHNL_MASK(tdf8532->channels)); + CHNL_MASK(tdf8532->channels)); if (ret < 0) goto out; @@ -255,13 +244,12 @@ static int tdf8532_stop_play(struct tdf8532_priv *tdf8532) return ret; } - static int tdf8532_dai_trigger(struct snd_pcm_substream *substream, int cmd, - struct snd_soc_dai *dai) + struct snd_soc_dai *dai) { - int ret = 0; struct snd_soc_component *component = dai->component; struct tdf8532_priv *tdf8532 = snd_soc_component_get_drvdata(component); + int ret = 0; dev_dbg(component->dev, "%s: cmd = %d\n", __func__, cmd); @@ -301,7 +289,7 @@ static const struct snd_soc_dai_ops tdf8532_dai_ops = { .digital_mute = tdf8532_mute, }; -static struct snd_soc_component_driver soc_component_tdf8532; +static const struct snd_soc_component_driver soc_component_tdf8532; static struct snd_soc_dai_driver tdf8532_dai[] = { { @@ -318,11 +306,11 @@ static struct snd_soc_dai_driver tdf8532_dai[] = { }; static int tdf8532_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *id) + const struct i2c_device_id *id) { int ret; struct tdf8532_priv *dev_data; - struct device *dev = &(i2c->dev); + struct device *dev = &i2c->dev; dev_dbg(&i2c->dev, "%s\n", __func__); @@ -340,7 +328,7 @@ static int tdf8532_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, dev_data); ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_tdf8532, - tdf8532_dai, ARRAY_SIZE(tdf8532_dai)); + tdf8532_dai, ARRAY_SIZE(tdf8532_dai)); if (ret != 0) { dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); goto out; diff --git a/sound/soc/codecs/tdf8532.h b/sound/soc/codecs/tdf8532.h index 6e3f2c147eace9..8818252dcda6fa 100644 --- a/sound/soc/codecs/tdf8532.h +++ b/sound/soc/codecs/tdf8532.h @@ -1,18 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * tdf8532.h - Codec driver for NXP Semiconductors * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. */ - #ifndef __TDF8532_H_ #define __TDF8532_H_ @@ -87,7 +78,7 @@ struct get_dev_status_repl { } __packed; /* Helpers */ -#define CHNL_MASK(channels) (u8)((0x00FF << channels) >> 8) +#define CHNL_MASK(channels) (u8)((0x00FF << (channels)) >> 8) #define tdf8532_amp_write(dev_data, ...)\ __tdf8532_single_write(dev_data, 0, AMP_MOD, __VA_ARGS__, END) From 22aa067b83fa2e60d2300b5cba4ec2d4935b51aa Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 2 Jul 2018 13:38:08 -0500 Subject: [PATCH 18/18] ASoC: Intel: bxt-tdf8532: use Linux style Make checkpatch happy, no functionality change Signed-off-by: Pierre-Louis Bossart --- sound/soc/intel/boards/bxt_tdf8532.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/sound/soc/intel/boards/bxt_tdf8532.c b/sound/soc/intel/boards/bxt_tdf8532.c index abdc04e389a8fb..336205309e2c8b 100644 --- a/sound/soc/intel/boards/bxt_tdf8532.c +++ b/sound/soc/intel/boards/bxt_tdf8532.c @@ -1,15 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Intel Broxton-P I2S Machine Driver for IVI reference platform * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. */ #include @@ -37,7 +29,6 @@ static const struct snd_soc_dapm_widget broxton_tdf8532_widgets[] = { }; static const struct snd_soc_dapm_route broxton_tdf8532_map[] = { - /* Speaker BE connections */ { "Speaker", NULL, "ssp4 Tx"}, { "ssp4 Tx", NULL, "codec0_out"}, @@ -77,7 +68,7 @@ static const struct snd_soc_dapm_route broxton_tdf8532_map[] = { }; static int bxt_tdf8532_ssp2_fixup(struct snd_soc_pcm_runtime *rtd, - struct snd_pcm_hw_params *params) + struct snd_pcm_hw_params *params) { struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); @@ -218,7 +209,7 @@ static struct snd_soc_dai_link broxton_tdf8532_dais[] = { #if !IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL) static int bxt_add_dai_link(struct snd_soc_card *card, - struct snd_soc_dai_link *link) + struct snd_soc_dai_link *link) { link->platform_name = "0000:00:0e.0"; link->nonatomic = 1;