diff mbox

[3/3] ASoC: Intel: Add surface3 entry in CHT-RT5645 machine

Message ID 1467972591-29175-4-git-send-email-vinod.koul@intel.com (mailing list archive)
State Accepted
Commit 07d5c17b80f67d1b2cc2c8243590e2abed4bd7ae
Headers show

Commit Message

Vinod Koul July 8, 2016, 10:09 a.m. UTC
Surface3 device is a CHT machine, so add entry for it.
Also update the HID from BIOS.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=98001
Signed-off-by: Sachin Mokashi <sachinx.mokashi@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 sound/soc/intel/boards/cht_bsw_rt5645.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Bastien Nocera July 19, 2016, 2:56 p.m. UTC | #1
On Fri, 2016-07-08 at 15:39 +0530, Vinod Koul wrote:
> Surface3 device is a CHT machine, so add entry for it.
> Also update the HID from BIOS.
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=98001
> Signed-off-by: Sachin Mokashi <sachinx.mokashi@intel.com>
> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
> ---
>  sound/soc/intel/boards/cht_bsw_rt5645.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
> index d7ef292c402d..f26c7b8545ae 100644
> --- a/sound/soc/intel/boards/cht_bsw_rt5645.c
> +++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
> @@ -30,6 +30,7 @@
>  #include 
>  #include "../../codecs/rt5645.h"
>  #include "../atom/sst-atom-controls.h"
> +#include "../common/sst-acpi.h"
>  
>  #define CHT_PLAT_CLK_3_HZ	19200000
>  #define CHT_CODEC_DAI	"rt5645-aif1"
> @@ -340,10 +341,13 @@ static struct snd_soc_card snd_soc_card_chtrt5650 = {
>  };
>  
>  static struct cht_acpi_card snd_soc_cards[] = {
> +	{"10EC5640", CODEC_TYPE_RT5645, &snd_soc_card_chtrt5645},
>  	{"10EC5645", CODEC_TYPE_RT5645, &snd_soc_card_chtrt5645},
>  	{"10EC5650", CODEC_TYPE_RT5650, &snd_soc_card_chtrt5650},
>  };
>  
> +static char cht_rt5640_codec_name[16]; /* i2c-:00 with HID being 8 chars */
> +
>  static int snd_cht_mc_probe(struct platform_device *pdev)
>  {
>  	int ret_val = 0;
> @@ -351,6 +355,9 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
>  	struct cht_mc_private *drv;
>  	struct snd_soc_card *card = snd_soc_cards[0].soc_card;
>  	char codec_name[16];
> +	struct sst_acpi_mach *mach;
> +	const char *i2c_name = NULL;
> +	int dai_index;
>  
>  	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC);
>  	if (!drv)
> @@ -366,12 +373,23 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
>  		}
>  	}
>  	card->dev = &pdev->dev;
> +	mach = card->dev->platform_data;
>  	sprintf(codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
>  
>  	/* set correct codec name */
>  	for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
> -		if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00"))
> +		if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00")) {
>  			card->dai_link[i].codec_name = kstrdup(codec_name, GFP_KERNEL);
> +			dai_index = i;
> +		}
> +
> +	/* fixup codec name based on HID */
> +	i2c_name = sst_acpi_find_name_from_hid(mach->id);
> +	if (i2c_name != NULL) {
> +		snprintf(cht_rt5640_codec_name, sizeof(cht_rt5640_codec_name),
> +			"%s%s", "i2c-", i2c_name);
> +		cht_dailink[dai_index].codec_name = cht_rt5640_codec_name;

FWIW, I get:
sound/soc/intel/boards/cht_bsw_rt5645.c: In function 'snd_cht_mc_probe':
sound/soc/intel/boards/cht_bsw_rt5645.c:391:37: warning: 'dai_index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   cht_dailink[dai_index].codec_name = cht_rt5640_codec_name;
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

> +	}
>  
>  	snd_soc_card_set_drvdata(card, drv);
>  	ret_val = devm_snd_soc_register_card(&pdev->dev, card);
Vinod Koul July 20, 2016, 3:58 a.m. UTC | #2
On Tue, Jul 19, 2016 at 04:56:24PM +0200, Bastien Nocera wrote:
> > +	/* fixup codec name based on HID */
> > +	i2c_name = sst_acpi_find_name_from_hid(mach->id);
> > +	if (i2c_name != NULL) {
> > +		snprintf(cht_rt5640_codec_name, sizeof(cht_rt5640_codec_name),
> > +			"%s%s", "i2c-", i2c_name);
> > +		cht_dailink[dai_index].codec_name = cht_rt5640_codec_name;
> 
> FWIW, I get:
> sound/soc/intel/boards/cht_bsw_rt5645.c: In function 'snd_cht_mc_probe':
> sound/soc/intel/boards/cht_bsw_rt5645.c:391:37: warning: 'dai_index' may be used uninitialized in this function [-Wmaybe-uninitialized]
>    cht_dailink[dai_index].codec_name = cht_rt5640_codec_name;
>    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

Yeah I notice them a bit later. The fixes are already in mark's-next.
Bastien Nocera July 20, 2016, 11:27 a.m. UTC | #3
On Wed, 2016-07-20 at 09:28 +0530, Vinod Koul wrote:
> On Tue, Jul 19, 2016 at 04:56:24PM +0200, Bastien Nocera wrote:
> > > +	/* fixup codec name based on HID */
> > > +	i2c_name = sst_acpi_find_name_from_hid(mach->id);
> > > +	if (i2c_name != NULL) {
> > > +		snprintf(cht_rt5640_codec_name,
> > > sizeof(cht_rt5640_codec_name),
> > > +			"%s%s", "i2c-", i2c_name);
> > > +		cht_dailink[dai_index].codec_name =
> > > cht_rt5640_codec_name;
> > 
> > FWIW, I get:
> > sound/soc/intel/boards/cht_bsw_rt5645.c: In function
> > 'snd_cht_mc_probe':
> > sound/soc/intel/boards/cht_bsw_rt5645.c:391:37: warning:
> > 'dai_index' may be used uninitialized in this function [-Wmaybe-
> > uninitialized]
> >    cht_dailink[dai_index].codec_name = cht_rt5640_codec_name;
> >    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
> 
> Yeah I notice them a bit later. The fixes are already in mark's-next.

Care to be a bit more specific. Kind of hard to know which Mark you're
talking about when there's no one of that name in the CC: list above.
Mokashi, SachinX July 20, 2016, 11:33 a.m. UTC | #4
Mark Brown is the maintainer of sound tree. He is included in cc: broonie@kernel.org :)

-----Original Message-----
From: Bastien Nocera [mailto:hadess@hadess.net] 

Sent: Wednesday, July 20, 2016 4:57 PM
To: Koul, Vinod <vinod.koul@intel.com>
Cc: alsa-devel@alsa-project.org; broonie@kernel.org; liam.r.girdwood@linux.intel.com; Patches Audio <patches.audio@intel.com>; Stephen Just <stephenjust@gmail.com>; Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>; apterix@gmail.com; bugzilla@hadess.net; Mokashi, SachinX <sachinx.mokashi@intel.com>
Subject: Re: [PATCH 3/3] ASoC: Intel: Add surface3 entry in CHT-RT5645 machine

On Wed, 2016-07-20 at 09:28 +0530, Vinod Koul wrote:
> On Tue, Jul 19, 2016 at 04:56:24PM +0200, Bastien Nocera wrote:

> > > +	/* fixup codec name based on HID */

> > > +	i2c_name = sst_acpi_find_name_from_hid(mach->id);

> > > +	if (i2c_name != NULL) {

> > > +		snprintf(cht_rt5640_codec_name,

> > > sizeof(cht_rt5640_codec_name),

> > > +			"%s%s", "i2c-", i2c_name);

> > > +		cht_dailink[dai_index].codec_name =

> > > cht_rt5640_codec_name;

> > 

> > FWIW, I get:

> > sound/soc/intel/boards/cht_bsw_rt5645.c: In function

> > 'snd_cht_mc_probe':

> > sound/soc/intel/boards/cht_bsw_rt5645.c:391:37: warning:

> > 'dai_index' may be used uninitialized in this function [-Wmaybe- 

> > uninitialized]

> >    cht_dailink[dai_index].codec_name = cht_rt5640_codec_name;

> >    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~

> 

> Yeah I notice them a bit later. The fixes are already in mark's-next.


Care to be a bit more specific. Kind of hard to know which Mark you're talking about when there's no one of that name in the CC: list above.
Bastien Nocera July 20, 2016, 11:51 a.m. UTC | #5
On Wed, 2016-07-20 at 11:33 +0000, Mokashi, SachinX wrote:
> Mark Brown is the maintainer of sound tree.

Ha, the *ASoC* sound tree maintainer.

Picked up the 2 patches from:
https://git.kernel.org/cgit/linux/kernel/git/broonie/sound.git/commit/?h=for-next&id=5d554ea4f287665b839975ecb11bd29d49a5c9b5
https://git.kernel.org/cgit/linux/kernel/git/broonie/sound.git/commit/?h=for-next&id=24dad509ed5528bbbe31ff17f9fb39c0473ec8f4

>  He is included in cc: broonie@kernel.org :)

Cheers
diff mbox

Patch

diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c
index d7ef292c402d..f26c7b8545ae 100644
--- a/sound/soc/intel/boards/cht_bsw_rt5645.c
+++ b/sound/soc/intel/boards/cht_bsw_rt5645.c
@@ -30,6 +30,7 @@ 
 #include <sound/jack.h>
 #include "../../codecs/rt5645.h"
 #include "../atom/sst-atom-controls.h"
+#include "../common/sst-acpi.h"
 
 #define CHT_PLAT_CLK_3_HZ	19200000
 #define CHT_CODEC_DAI	"rt5645-aif1"
@@ -340,10 +341,13 @@  static struct snd_soc_card snd_soc_card_chtrt5650 = {
 };
 
 static struct cht_acpi_card snd_soc_cards[] = {
+	{"10EC5640", CODEC_TYPE_RT5645, &snd_soc_card_chtrt5645},
 	{"10EC5645", CODEC_TYPE_RT5645, &snd_soc_card_chtrt5645},
 	{"10EC5650", CODEC_TYPE_RT5650, &snd_soc_card_chtrt5650},
 };
 
+static char cht_rt5640_codec_name[16]; /* i2c-<HID>:00 with HID being 8 chars */
+
 static int snd_cht_mc_probe(struct platform_device *pdev)
 {
 	int ret_val = 0;
@@ -351,6 +355,9 @@  static int snd_cht_mc_probe(struct platform_device *pdev)
 	struct cht_mc_private *drv;
 	struct snd_soc_card *card = snd_soc_cards[0].soc_card;
 	char codec_name[16];
+	struct sst_acpi_mach *mach;
+	const char *i2c_name = NULL;
+	int dai_index;
 
 	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC);
 	if (!drv)
@@ -366,12 +373,23 @@  static int snd_cht_mc_probe(struct platform_device *pdev)
 		}
 	}
 	card->dev = &pdev->dev;
+	mach = card->dev->platform_data;
 	sprintf(codec_name, "i2c-%s:00", drv->acpi_card->codec_id);
 
 	/* set correct codec name */
 	for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
-		if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00"))
+		if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00")) {
 			card->dai_link[i].codec_name = kstrdup(codec_name, GFP_KERNEL);
+			dai_index = i;
+		}
+
+	/* fixup codec name based on HID */
+	i2c_name = sst_acpi_find_name_from_hid(mach->id);
+	if (i2c_name != NULL) {
+		snprintf(cht_rt5640_codec_name, sizeof(cht_rt5640_codec_name),
+			"%s%s", "i2c-", i2c_name);
+		cht_dailink[dai_index].codec_name = cht_rt5640_codec_name;
+	}
 
 	snd_soc_card_set_drvdata(card, drv);
 	ret_val = devm_snd_soc_register_card(&pdev->dev, card);