Skip to content

Commit

Permalink
Revert "Revert sound related patches from AU143 drop"
Browse files Browse the repository at this point in the history
This reverts commit f33fc5f.
Change-Id: Ida6250fd474f837edb3a886490db54bcb2fd756d
  • Loading branch information
dtwlin committed May 19, 2017
1 parent 013a5df commit c35edd8
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 121 deletions.
68 changes: 24 additions & 44 deletions drivers/soundwire/soundwire.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -67,6 +67,27 @@ static void swr_dev_release(struct device *dev)
kfree(swr_dev);
}

/**
* swr_remove_device - remove a soundwire device
* @swr_dev: soundwire device to remove
*
* Remove a soundwire device. Go through the soundwire
* device list that master has and remove swr_dev from
* it.
*/
void swr_remove_device(struct swr_device *swr_dev)
{
struct swr_device *swr_dev_loop, *safe;

list_for_each_entry_safe(swr_dev_loop, safe,
&swr_dev->master->devices,
dev_list) {
if (swr_dev == swr_dev_loop)
list_del(&swr_dev_loop->dev_list);
}
}
EXPORT_SYMBOL(swr_remove_device);

/**
* swr_new_device - instantiate a new soundwire device
* @master: Controller to which device is connected
Expand Down Expand Up @@ -128,47 +149,6 @@ struct swr_device *swr_new_device(struct swr_master *master,
}
EXPORT_SYMBOL(swr_new_device);

/**
* swr_startup_devices - perform additional initialization for child devices
*
* @swr_dev: pointer to soundwire slave device
*
* Performs any additional initialization needed for a soundwire slave device.
* This is a optional functionality defined by slave devices.
* Removes the slave node from the list, in case there is any failure.
*/
int swr_startup_devices(struct swr_device *swr_dev)
{
struct swr_driver *swr_drv;
struct device *dev;
int ret = 0;

if (!swr_dev)
return -EINVAL;

dev = &swr_dev->dev;
if (!dev)
return -EINVAL;

swr_drv = to_swr_driver(dev->driver);
if (!swr_drv)
return -EINVAL;

if (swr_drv->startup) {
ret = swr_drv->startup(swr_dev);
if (ret)
goto out;

dev_dbg(&swr_dev->dev,
"%s: startup complete for device %lx\n",
__func__, swr_dev->addr);
}

out:
return ret;
}
EXPORT_SYMBOL(swr_startup_devices);

/**
* of_register_swr_devices - register child devices on to the soundwire bus
* @master: pointer to soundwire master device
Expand Down Expand Up @@ -610,7 +590,7 @@ int swr_device_up(struct swr_device *swr_dev)
dev = &swr_dev->dev;
sdrv = to_swr_driver(dev->driver);
if (!sdrv)
return -EINVAL;
return 0;

if (sdrv->device_up)
return sdrv->device_up(to_swr_device(dev));
Expand Down Expand Up @@ -638,7 +618,7 @@ int swr_device_down(struct swr_device *swr_dev)
dev = &swr_dev->dev;
sdrv = to_swr_driver(dev->driver);
if (!sdrv)
return -EINVAL;
return 0;

if (sdrv->device_down)
return sdrv->device_down(to_swr_device(dev));
Expand Down
14 changes: 3 additions & 11 deletions drivers/soundwire/swr-wcd-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,6 @@ static int swrm_probe(struct platform_device *pdev)
{
struct swr_mstr_ctrl *swrm;
struct swr_ctrl_platform_data *pdata;
struct swr_device *swr_dev, *safe;
int ret;

/* Allocate soundwire master driver structure */
Expand Down Expand Up @@ -1472,9 +1471,6 @@ static int swrm_probe(struct platform_device *pdev)
goto err_mstr_fail;
}

if (pdev->dev.of_node)
of_register_swr_devices(&swrm->master);

/* Add devices registered with board-info as the
controller will be up now
*/
Expand All @@ -1491,15 +1487,11 @@ static int swrm_probe(struct platform_device *pdev)
}
swrm->version = swrm->read(swrm->handle, SWRM_COMP_HW_VERSION);

/* Enumerate slave devices */
list_for_each_entry_safe(swr_dev, safe, &swrm->master.devices,
dev_list) {
ret = swr_startup_devices(swr_dev);
if (ret)
list_del(&swr_dev->dev_list);
}
mutex_unlock(&swrm->mlock);

if (pdev->dev.of_node)
of_register_swr_devices(&swrm->master);

dbgswrm = swrm;
debugfs_swrm_dent = debugfs_create_dir(dev_name(&pdev->dev), 0);
if (!IS_ERR(debugfs_swrm_dent)) {
Expand Down
6 changes: 3 additions & 3 deletions include/linux/soundwire/soundwire.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -196,7 +196,6 @@ static inline struct swr_device *to_swr_device(struct device *dev)
* @shutdown: standard shutdown callback used during power down/halt
* @suspend: standard suspend callback used during system suspend
* @resume: standard resume callback used during system resume
* @startup: additional init operation for slave devices
* @driver: soundwire device drivers should initialize name and
* owner field of this structure
* @id_table: list of soundwire devices supported by this driver
Expand All @@ -210,7 +209,6 @@ struct swr_driver {
int (*device_up)(struct swr_device *swr);
int (*device_down)(struct swr_device *swr);
int (*reset_device)(struct swr_device *swr);
int (*startup)(struct swr_device *swr);
struct device_driver driver;
const struct swr_device_id *id_table;
};
Expand Down Expand Up @@ -309,4 +307,6 @@ extern int swr_reset_device(struct swr_device *swr_dev);
extern int swr_slvdev_datapath_control(struct swr_device *swr_dev, u8 dev_num,
bool enable);
extern int swr_remove_from_group(struct swr_device *dev, u8 dev_num);

extern void swr_remove_device(struct swr_device *swr_dev);
#endif /* _LINUX_SOUNDWIRE_H */
8 changes: 6 additions & 2 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,14 @@ config SND_SOC_WCD934X_MBHC
depends on SND_SOC_WCD934X
select SND_SOC_WCD_MBHC

config REGMAP_SWR
tristate
default y

config SND_SOC_WSA881X
tristate
depends on REGMAP_SWR
tristate
select MSM_CDC_PINCTRL
select REGMAP_SWR

config SND_SOC_WSA881X_ANALOG
tristate
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/codecs/wcd-mbhc-v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -2986,7 +2986,9 @@ void wcd_mbhc_deinit(struct wcd_mbhc *mbhc)
mbhc->mbhc_cb->free_irq(codec, mbhc->intr_ids->hph_right_ocp, mbhc);
if (mbhc->mbhc_cb && mbhc->mbhc_cb->register_notifier)
mbhc->mbhc_cb->register_notifier(mbhc, &mbhc->nblock, false);
WCD_MBHC_RSC_LOCK(mbhc);
wcd_cancel_hs_detect_plug(mbhc, &mbhc->correct_plug_swch);
WCD_MBHC_RSC_UNLOCK(mbhc);
mutex_destroy(&mbhc->codec_resource_lock);
mutex_destroy(&mbhc->hphl_pa_lock);
mutex_destroy(&mbhc->hphr_pa_lock);
Expand Down
1 change: 1 addition & 0 deletions sound/soc/codecs/wcd934x/wcd934x.c
Original file line number Diff line number Diff line change
Expand Up @@ -8581,6 +8581,7 @@ static const struct tavil_reg_mask_val tavil_codec_reg_init_common_val[] = {
{WCD934X_TLMM_DMIC3_CLK_PINCFG, 0xFF, 0x0a},
{WCD934X_TLMM_DMIC3_DATA_PINCFG, 0xFF, 0x0a},
{WCD934X_CPE_SS_SVA_CFG, 0x60, 0x00},
{WCD934X_CPE_SS_CPAR_CFG, 0x10, 0x10},
};

static void tavil_codec_init_reg(struct tavil_priv *priv)
Expand Down
87 changes: 38 additions & 49 deletions sound/soc/codecs/wsa881x.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,54 +1123,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wsa881x = {
.get_regmap = wsa881x_get_regmap,
};

static int wsa881x_swr_startup(struct swr_device *swr_dev)
{
int ret = 0;
u8 devnum = 0;
struct wsa881x_priv *wsa881x;

wsa881x = swr_get_dev_data(swr_dev);
if (!wsa881x) {
dev_err(&swr_dev->dev, "%s: wsa881x is NULL\n", __func__);
return -EINVAL;
}

/*
* Add 5msec delay to provide sufficient time for
* soundwire auto enumeration of slave devices as
* as per HW requirement.
*/
usleep_range(5000, 5010);
ret = swr_get_logical_dev_num(swr_dev, swr_dev->addr, &devnum);
if (ret) {
dev_dbg(&swr_dev->dev,
"%s get devnum %d for dev addr %lx failed\n",
__func__, devnum, swr_dev->addr);
goto err;
}
swr_dev->dev_num = devnum;

wsa881x->regmap = devm_regmap_init_swr(swr_dev,
&wsa881x_regmap_config);
if (IS_ERR(wsa881x->regmap)) {
ret = PTR_ERR(wsa881x->regmap);
dev_err(&swr_dev->dev, "%s: regmap_init failed %d\n",
__func__, ret);
goto err;
}

ret = snd_soc_register_codec(&swr_dev->dev, &soc_codec_dev_wsa881x,
NULL, 0);
if (ret) {
dev_err(&swr_dev->dev, "%s: Codec registration failed\n",
__func__);
goto err;
}

err:
return ret;
}

static int wsa881x_gpio_ctrl(struct wsa881x_priv *wsa881x, bool enable)
{
int ret = 0;
Expand Down Expand Up @@ -1232,6 +1184,7 @@ static int wsa881x_swr_probe(struct swr_device *pdev)
{
int ret = 0;
struct wsa881x_priv *wsa881x;
u8 devnum = 0;

wsa881x = devm_kzalloc(&pdev->dev, sizeof(struct wsa881x_priv),
GFP_KERNEL);
Expand Down Expand Up @@ -1291,8 +1244,43 @@ static int wsa881x_swr_probe(struct swr_device *pdev)
&codec_debug_ops);
}
}

/*
* Add 5msec delay to provide sufficient time for
* soundwire auto enumeration of slave devices as
* as per HW requirement.
*/
usleep_range(5000, 5010);
ret = swr_get_logical_dev_num(pdev, pdev->addr, &devnum);
if (ret) {
dev_dbg(&pdev->dev,
"%s get devnum %d for dev addr %lx failed\n",
__func__, devnum, pdev->addr);
goto dev_err;
}
pdev->dev_num = devnum;

wsa881x->regmap = devm_regmap_init_swr(pdev,
&wsa881x_regmap_config);
if (IS_ERR(wsa881x->regmap)) {
ret = PTR_ERR(wsa881x->regmap);
dev_err(&pdev->dev, "%s: regmap_init failed %d\n",
__func__, ret);
goto dev_err;
}

ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wsa881x,
NULL, 0);
if (ret) {
dev_err(&pdev->dev, "%s: Codec registration failed\n",
__func__);
goto dev_err;
}

return 0;

dev_err:
swr_remove_device(pdev);
err:
return ret;
}
Expand All @@ -1307,6 +1295,7 @@ static int wsa881x_swr_remove(struct swr_device *pdev)
return -EINVAL;
}
debugfs_remove_recursive(debugfs_wsa881x_dent);
debugfs_wsa881x_dent = NULL;
snd_soc_unregister_codec(&pdev->dev);
if (wsa881x->pd_gpio)
gpio_free(wsa881x->pd_gpio);
Expand Down Expand Up @@ -1371,6 +1360,7 @@ static int wsa881x_swr_reset(struct swr_device *pdev)
/* Retry after 1 msec delay */
usleep_range(1000, 1100);
}
pdev->dev_num = devnum;
regcache_mark_dirty(wsa881x->regmap);
regcache_sync(wsa881x->regmap);
return 0;
Expand Down Expand Up @@ -1425,7 +1415,6 @@ static struct swr_driver wsa881x_codec_driver = {
.device_up = wsa881x_swr_up,
.device_down = wsa881x_swr_down,
.reset_device = wsa881x_swr_reset,
.startup = wsa881x_swr_startup,
};

static int __init wsa881x_codec_init(void)
Expand Down
14 changes: 9 additions & 5 deletions sound/soc/msm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,17 @@ config SND_SOC_MSM8996
help
To add support for SoC audio on MSM8996.
This will enable sound soc drivers which
interfaces with DSP, also it will enable
the machine driver and the corresponding
DAI-links
interfaces with DSP

config SND_SOC_MSM8998
config SND_SOC_MACHINE_MSM8998
tristate "SoC Machine driver for MSM8998 boards"
select SND_SOC_WSA881X
help
To enable the machine driver and the
corresponding DAI-links

config SND_SOC_MSM8998
tristate "Sound SoC drivers to interface with DSP"
depends on ARCH_QCOM
select SND_SOC_COMPRESS
select SND_SOC_QDSP6V2
Expand All @@ -207,7 +212,6 @@ config SND_SOC_MSM8998
select MSM_QDSP6V2_CODECS
select SND_SOC_WCD9335
select SND_SOC_WCD934X
select SND_SOC_WSA881X
select SND_SOC_MSM_HDMI_CODEC_RX
select DTS_SRS_TM
select QTI_PP
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/msm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-msm8996.o

# for MSM8998 sound card driver
snd-soc-msm8998-objs := msm8998.o
obj-$(CONFIG_SND_SOC_MSM8998) += snd-soc-msm8998.o
obj-$(CONFIG_SND_SOC_MACHINE_MSM8998) += snd-soc-msm8998.o

# for SDM660 sound card driver
snd-soc-sdm660-common-objs := sdm660-common.o
Expand Down
4 changes: 3 additions & 1 deletion sound/soc/msm/msm8998.c
Original file line number Diff line number Diff line change
Expand Up @@ -7170,10 +7170,12 @@ static int msm_asoc_machine_remove(struct platform_device *pdev)
struct msm_asoc_mach_data *pdata =
snd_soc_card_get_drvdata(card);

gpio_free(pdata->us_euro_gpio);
if (gpio_is_valid(pdata->us_euro_gpio))
gpio_free(pdata->us_euro_gpio);
i2s_auxpcm_deinit();

snd_soc_unregister_card(card);
audio_notifier_deregister("msm8998");
return 0;
}

Expand Down
Loading

0 comments on commit c35edd8

Please sign in to comment.