Kuninori Morimoto | 21 May 04:47 2013

How to specify data format if playback/capture were different ?


Hi Mark, and ALSA ML

Now, I'm creating ak4554 AD/DA.
My question is about data format.

If my understand is correct,
we can specify cpu/codec deivce data format by using

	snd_soc_dai_set_fmt(dai, SND_SOC_DAIFMT_xxx);

But, ak4554 case, data formats are
 playback : SND_SOC_DAIFMT_RIGHT_J
 capture  : SND_SOC_DAIFMT_LEFT_J
and, it can't exchange this data format.

CPU driver should set these information for ak4554 when playback/capture.

Then, how to specify these data format on ALSA SoC ?

Best regards
---
Kuninori Morimoto
Lars-Peter Clausen | 21 May 13:58 2013
Picon

Re: How to specify data format if playback/capture were different ?

On 05/21/2013 04:47 AM, Kuninori Morimoto wrote:
> 
> Hi Mark, and ALSA ML
> 
> Now, I'm creating ak4554 AD/DA.
> My question is about data format.
> 
> If my understand is correct,
> we can specify cpu/codec deivce data format by using
> 
> 	snd_soc_dai_set_fmt(dai, SND_SOC_DAIFMT_xxx);
> 
> But, ak4554 case, data formats are
>  playback : SND_SOC_DAIFMT_RIGHT_J
>  capture  : SND_SOC_DAIFMT_LEFT_J
> and, it can't exchange this data format.
> 
> CPU driver should set these information for ak4554 when playback/capture.
> 
> Then, how to specify these data format on ALSA SoC ?

You can add two different DAIs one for playback one for capture. Then you
can specify the format for each.

- Lars

Kuninori Morimoto | 22 May 03:02 2013

Re: How to specify data format if playback/capture were different ?


Hi Lars

Thank you for your comment

> > But, ak4554 case, data formats are
> >  playback : SND_SOC_DAIFMT_RIGHT_J
> >  capture  : SND_SOC_DAIFMT_LEFT_J
> > and, it can't exchange this data format.
> > 
> > CPU driver should set these information for ak4554 when playback/capture.
> > 
> > Then, how to specify these data format on ALSA SoC ?
> 
> You can add two different DAIs one for playback one for capture. Then you
> can specify the format for each.

I understand, but still 50%.

I'm creating new "cpu" driver now too.
And, fortunately, my current "cpu" can do it as flexibility.
But, my old cpu driver ${LINUX}/sound/soc/sh/fsi.c was this

static struct snd_soc_dai_driver fsi_soc_dai[] = {
	{
		.name			= "fsia-dai",
		.playback = {
			...
		},
		.capture = {
(Continue reading)

Kuninori Morimoto | 22 May 03:12 2013

Re: How to specify data format if playback/capture were different ?


Hi again

> > > But, ak4554 case, data formats are
> > >  playback : SND_SOC_DAIFMT_RIGHT_J
> > >  capture  : SND_SOC_DAIFMT_LEFT_J
> > > and, it can't exchange this data format.
> > > 
> > > CPU driver should set these information for ak4554 when playback/capture.
> > > 
> > > Then, how to specify these data format on ALSA SoC ?
> > 
> > You can add two different DAIs one for playback one for capture. Then you
> > can specify the format for each.

1 more question.

On ak4554 side driver, I guess, it will be

struct snd_soc_dai_driver ak4554_playback_dai = {
	.name = "ak4554-playback",
	.playback = {
		...
	},
}

struct snd_soc_dai_driver ak4554_captrure_dai = {
	.name = "ak4554-captrure",
	.capture = {
		...
(Continue reading)

Lars-Peter Clausen | 22 May 10:43 2013
Picon

Re: How to specify data format if playback/capture were different ?

On 05/22/2013 03:12 AM, Kuninori Morimoto wrote:
> 
> Hi again
> 
>>>> But, ak4554 case, data formats are
>>>>  playback : SND_SOC_DAIFMT_RIGHT_J
>>>>  capture  : SND_SOC_DAIFMT_LEFT_J
>>>> and, it can't exchange this data format.
>>>>
>>>> CPU driver should set these information for ak4554 when playback/capture.
>>>>
>>>> Then, how to specify these data format on ALSA SoC ?
>>>
>>> You can add two different DAIs one for playback one for capture. Then you
>>> can specify the format for each.
> 
> 1 more question.
> 
> On ak4554 side driver, I guess, it will be
> 
> struct snd_soc_dai_driver ak4554_playback_dai = {
> 	.name = "ak4554-playback",
> 	.playback = {
> 		...
> 	},
> }
> 
> struct snd_soc_dai_driver ak4554_captrure_dai = {
> 	.name = "ak4554-captrure",
> 	.capture = {
(Continue reading)

Kuninori Morimoto | 22 May 10:54 2013

Re: How to specify data format if playback/capture were different ?


Hi Lars

> > struct snd_soc_dai_driver ak4554_playback_dai = {
> > 	.name = "ak4554-playback",
> > 	.playback = {
> > 		...
> > 	},
> > }
> > 
> > struct snd_soc_dai_driver ak4554_captrure_dai = {
> > 	.name = "ak4554-captrure",
> > 	.capture = {
> > 		...
> > 	},
> > };
> 
> You'll want to put both DAIs into an array which you can pass to
> snd_soc_register_codec, but otherwise it looks ok.
> 
> > 
> > But, ak4554 needs .symmetric_rates between playback <--> capture.
> > Is it possible ?
> > Or, am I misunderstanding ?
> 
> Yes, that won't work, you'd have to implement this by hand.

OK, I understand, thank you.

But do you know why snd_soc_dai_set_fmt() doesn't support
(Continue reading)

Lars-Peter Clausen | 22 May 13:41 2013
Picon

Re: How to specify data format if playback/capture were different ?

On 05/22/2013 10:54 AM, Kuninori Morimoto wrote:
> 
> Hi Lars
> 
>>> struct snd_soc_dai_driver ak4554_playback_dai = {
>>> 	.name = "ak4554-playback",
>>> 	.playback = {
>>> 		...
>>> 	},
>>> }
>>>
>>> struct snd_soc_dai_driver ak4554_captrure_dai = {
>>> 	.name = "ak4554-captrure",
>>> 	.capture = {
>>> 		...
>>> 	},
>>> };
>>
>> You'll want to put both DAIs into an array which you can pass to
>> snd_soc_register_codec, but otherwise it looks ok.
>>
>>>
>>> But, ak4554 needs .symmetric_rates between playback <--> capture.
>>> Is it possible ?
>>> Or, am I misunderstanding ?
>>
>> Yes, that won't work, you'd have to implement this by hand.
> 
> OK, I understand, thank you.
> 
(Continue reading)

Kuninori Morimoto | 24 May 05:18 2013

Re: How to specify data format if playback/capture were different ?


Hi Lars

Thank you for your comments

> > But do you know why snd_soc_dai_set_fmt() doesn't support
> > "setting for playback/capture only" ?
> > Historical reason or system reason ?
> 
> I think it is rather unusual that you want or need to set different formats
> for capture and playback. Especially when BCLK and LRCLK are shared. That's
> probably why it isn't supported yet.

This (playback and capture wer different format) is first case for me.
Maybe ak4554 is very special.
OK, I understand, thank you very much

Best regards
---
Kuninori Morimoto
Mark Brown | 25 May 22:03 2013

Re: How to specify data format if playback/capture were different ?

On Thu, May 23, 2013 at 08:18:09PM -0700, Kuninori Morimoto wrote:

> > I think it is rather unusual that you want or need to set different formats
> > for capture and playback. Especially when BCLK and LRCLK are shared. That's
> > probably why it isn't supported yet.

> This (playback and capture wer different format) is first case for me.
> Maybe ak4554 is very special.
> OK, I understand, thank you very much

The reason this is only supported is that there's an assumption that the
DAI will have the same clocks for both directions - if the clocks can be
formatted differently then it looks a lot like two separate interfaces.

It's also a bit odd to want to use different formats, there's rarely any
reason to do that.
On Thu, May 23, 2013 at 08:18:09PM -0700, Kuninori Morimoto wrote:

> > I think it is rather unusual that you want or need to set different formats
> > for capture and playback. Especially when BCLK and LRCLK are shared. That's
> > probably why it isn't supported yet.

> This (playback and capture wer different format) is first case for me.
> Maybe ak4554 is very special.
> OK, I understand, thank you very much

The reason this is only supported is that there's an assumption that the
DAI will have the same clocks for both directions - if the clocks can be
(Continue reading)


Gmane