mbox series

[v4,00/14] ASoC: Add support to WCD9335 Audio Codec

Message ID 20180917005727.32728-1-srinivas.kandagatla@linaro.org
Headers show
Series ASoC: Add support to WCD9335 Audio Codec | expand

Message

Srinivas Kandagatla Sept. 17, 2018, 12:57 a.m. UTC
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>


Thankyou for reviewing v3 patchset, here is v4 addressing comments from v3.

Qualcomm WCD9335 Codec is a standalone Hi-Fi audio codec IC.
It is integrated in multiple Qualcomm SoCs like: MSM8996, MSM8976,
and MSM8956 chipsets.

WCD9335 had multiple functional blocks, like: Soundwire controller,
interrupt mux, pin controller, Audio codec, MBHC, MAD(Mic activity Detection),
Ultrasonic proximity and pen detection, Battery-voltage monitoring and
Codec processing engine.

Currently this patchset has been only tested with SLIMbus interface due
to hardware avaiablity, but it can be easily made to work with both SLIMbus
and I2C/I2S.    

This patchset adds very basic playback and capture support witout much
fancy features. New features will be added once the basic support is in.
This patchset is tested on top of linux-next on DB820c for both playback
, capture paths and MBHC.

Some parts of the code has been inherited from Qualcomm andriod kernel,
so credits to various authors.

WCD9335 can be interfaced via I2S/I2C or SLIMbus. 

Here is my test branch incase someone want to try this out:
https://git.linaro.org/people/srinivas.kandagatla/linux.git/log/?h=wcd9335

Thanks,
Srini

Changes since v3 (https://lkml.org/lkml/2018/9/4/318/)
 - Updated mbhc dt bindings according to Robs Comments.
 - Added a cleanup patch to common up fixups.
 - Addressed various comments on mfd driver by Lee Jones.
 - Added acks on bindings and irq support.
 - fixed module loading

Srinivas Kandagatla (14):
  ASoC: dt-bindings: update wcd9335 bindings.
  mfd: wcd9335: add support to wcd9335 core
  mfd: wcd9335: add wcd irq support
  ASoC: wcd9335: add support to wcd9335 codec
  ASoC: wcd9335: add CLASS-H Controller support
  ASoC: wcd9335: add basic controls
  ASoC: wcd9335: add playback dapm widgets
  ASoC: wcd9335: add capture dapm widgets
  ASoC: wcd9335: add audio routings
  ASoC: dt-bindings: Add WCD9335 MBHC specific properties
  ASoC: wcd9335: add mbhc support
  ASoC: apq8096: add slim support
  ASoC: apq8096: add headset JACK support
  ASoC: qcom: common: move be_hw_fixup to common

 .../devicetree/bindings/sound/qcom,wcd9335.txt     |   30 +-
 drivers/mfd/Kconfig                                |   13 +
 drivers/mfd/Makefile                               |    4 +
 drivers/mfd/wcd9335-core.c                         |  394 ++
 include/linux/mfd/wcd9335/registers.h              |  640 +++
 include/linux/mfd/wcd9335/wcd9335.h                |   81 +
 sound/soc/codecs/Kconfig                           |    5 +
 sound/soc/codecs/Makefile                          |    2 +
 sound/soc/codecs/wcd-clsh-v2.c                     |  577 +++
 sound/soc/codecs/wcd-clsh-v2.h                     |   49 +
 sound/soc/codecs/wcd9335.c                         | 5241 ++++++++++++++++++++
 sound/soc/qcom/apq8096.c                           |  128 +-
 sound/soc/qcom/common.c                            |   17 +
 sound/soc/qcom/sdm845.c                            |   22 +-
 14 files changed, 7168 insertions(+), 35 deletions(-)
 create mode 100644 drivers/mfd/wcd9335-core.c
 create mode 100644 include/linux/mfd/wcd9335/registers.h
 create mode 100644 include/linux/mfd/wcd9335/wcd9335.h
 create mode 100644 sound/soc/codecs/wcd-clsh-v2.c
 create mode 100644 sound/soc/codecs/wcd-clsh-v2.h
 create mode 100644 sound/soc/codecs/wcd9335.c

-- 
2.9.3

Comments

Srinivas Kandagatla Sept. 26, 2018, 10:56 a.m. UTC | #1
On 19/09/18 06:49, Rohit Kumar wrote:
> Hello Srinivas,

> 

> 

> We will add support for vi feedback usecase in sdm845 machine driver 

> where we have to support 4 channel tx data for a particular backend. We 

> should probably keep be_hw_params_fixup in respective machine driver for 

> now to support such requirement.

> 

I agree, we can drop this patch!

thanks,
srini
> 

> Thanks,

> 

> Rohit

> 

> 

> On 9/17/2018 6:27 AM, srinivas.kandagatla@linaro.org wrote:

>> From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

>>

>> be_hw_fixup for qdsp is common across mutiple qcom machine drivers,

>> so move it to common file and remove the redundant code.

>>

>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

>> ---

>>   sound/soc/qcom/apq8096.c | 15 ---------------

>>   sound/soc/qcom/common.c  | 17 +++++++++++++++++

>>   sound/soc/qcom/sdm845.c  | 22 ++--------------------

>>   3 files changed, 19 insertions(+), 35 deletions(-)

>>

>> diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c

>> index daad43f..9cb26aee 100644

>> --- a/sound/soc/qcom/apq8096.c

>> +++ b/sound/soc/qcom/apq8096.c

>> @@ -20,20 +20,6 @@ struct apq8096_card_data {

>>       bool jack_setup;

>>   };

>> -static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,

>> -                      struct snd_pcm_hw_params *params)

>> -{

>> -    struct snd_interval *rate = hw_param_interval(params,

>> -                    SNDRV_PCM_HW_PARAM_RATE);

>> -    struct snd_interval *channels = hw_param_interval(params,

>> -                    SNDRV_PCM_HW_PARAM_CHANNELS);

>> -

>> -    rate->min = rate->max = 48000;

>> -    channels->min = channels->max = 2;

>> -

>> -    return 0;

>> -}

>> -

>>   static int msm_snd_hw_params(struct snd_pcm_substream *substream,

>>                    struct snd_pcm_hw_params *params)

>>   {

>> @@ -139,7 +125,6 @@ static void apq8096_add_be_ops(struct snd_soc_card 

>> *card)

>>       for (i = 0; i < num_links; i++) {

>>           if (link->no_pcm == 1) {

>> -            link->be_hw_params_fixup = apq8096_be_hw_params_fixup;

>>               link->init = apq8096_init;

>>               link->ops = &apq8096_ops;

>>           }

>> diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c

>> index eb1b9da..ce8e759 100644

>> --- a/sound/soc/qcom/common.c

>> +++ b/sound/soc/qcom/common.c

>> @@ -3,8 +3,24 @@

>>   // Copyright (c) 2018, The Linux Foundation. All rights reserved.

>>   #include <linux/module.h>

>> +#include <sound/pcm_params.h>

>>   #include "common.h"

>> +static int qcom_snd_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,

>> +                       struct snd_pcm_hw_params *params)

>> +{

>> +    struct snd_interval *rate = hw_param_interval(params,

>> +                    SNDRV_PCM_HW_PARAM_RATE);

>> +    struct snd_interval *channels = hw_param_interval(params,

>> +                    SNDRV_PCM_HW_PARAM_CHANNELS);

>> +

>> +    rate->min = rate->max = 48000;

>> +    channels->min = channels->max = 2;

>> +    params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);

>> +

>> +    return 0;

>> +}

>> +

>>   int qcom_snd_parse_of(struct snd_soc_card *card)

>>   {

>>       struct device_node *np;

>> @@ -79,6 +95,7 @@ int qcom_snd_parse_of(struct snd_soc_card *card)

>>               }

>>               link->no_pcm = 1;

>>               link->ignore_pmdown_time = 1;

>> +            link->be_hw_params_fixup = qcom_snd_be_hw_params_fixup;

>>           } else {

>>               link->platform_of_node = link->cpu_of_node;

>>               link->codec_dai_name = "snd-soc-dummy-dai";

>> diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c

>> index 2a781d8..87e150c 100644

>> --- a/sound/soc/qcom/sdm845.c

>> +++ b/sound/soc/qcom/sdm845.c

>> @@ -11,7 +11,6 @@

>>   #include "common.h"

>>   #include "qdsp6/q6afe.h"

>> -#define DEFAULT_SAMPLE_RATE_48K        48000

>>   #define DEFAULT_MCLK_RATE        24576000

>>   #define DEFAULT_BCLK_RATE        12288000

>> @@ -177,32 +176,15 @@ static struct snd_soc_ops sdm845_be_ops = {

>>       .shutdown = sdm845_snd_shutdown,

>>   };

>> -static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,

>> -                struct snd_pcm_hw_params *params)

>> -{

>> -    struct snd_interval *rate = hw_param_interval(params,

>> -                    SNDRV_PCM_HW_PARAM_RATE);

>> -    struct snd_interval *channels = hw_param_interval(params,

>> -                    SNDRV_PCM_HW_PARAM_CHANNELS);

>> -    struct snd_mask *fmt = hw_param_mask(params, 

>> SNDRV_PCM_HW_PARAM_FORMAT);

>> -

>> -    rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K;

>> -    channels->min = channels->max = 2;

>> -    snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);

>> -

>> -    return 0;

>> -}

>> -

>>   static void sdm845_add_be_ops(struct snd_soc_card *card)

>>   {

>>       struct snd_soc_dai_link *link = card->dai_link;

>>       int i, num_links = card->num_links;

>>       for (i = 0; i < num_links; i++) {

>> -        if (link->no_pcm == 1) {

>> +        if (link->no_pcm == 1)

>>               link->ops = &sdm845_be_ops;

>> -            link->be_hw_params_fixup = sdm845_be_hw_params_fixup;

>> -        }

>> +

>>           link++;

>>       }

>>   }

>
Srinivas Kandagatla Oct. 24, 2018, 10:50 a.m. UTC | #2
On 24/10/18 08:07, Lee Jones wrote:
>> +#define WCD9335_SLIM_INTERFACE_DEVICE_INDEX	0

>> +

>> +static const struct mfd_cell wcd9335_devices[] = {

>> +	{ .name = "wcd9335-codec", },

>> +};

> Any news on other devices?

> 

We are totally limited with hardware to test other devices on this 
codec. Given the fact that no one is actively working on adding support 
to other devices ATM.
Also IRC discussions with you suggested that I should move this driver 
to codecs for now and when a new device support comes up we can move it 
back to mfd.

Regarding other comments, I will make sure that address them if the code 
is still there after moving to codecs.

thanks,
srini

>> +static const struct regmap_range_cfg wcd9335_ranges[] = {

>> +	{

>> +		.name = "WCD9335",

>> +		.range_min =  0x0,

>> +		.range_max =  WCD9335_MAX_REGISTER,

>> +		.selector_reg = WCD9335_REG(0x0, 0),

>> +		.selector_mask = 0xff,

>> +		.selector_shift = 0,

>> +		.window_start = 0x0,

>> +		.window_len = 0x1000,

>> +	},

>> +};