All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Fukawa <tomoharu.fukawa.eb@renesas.com>,
	Linux-ALSA <alsa-devel@alsa-project.org>,
	shiiba <naoya.shiiba.nx@renesas.com>,
	mitsuhiro.kimura.kc@renesas.com,
	sakato <ryusuke.sakato.bx@renesas.com>,
	hideya.tanaka.nx@renesas.com, tomohiro.komagata.aj@renesas.com,
	hiroki.negishi.bx@renesas.com, hien.dang.eb@renesas.com,
	ryo.kodama.vz@renesas.com, Kihara <takeshi.kihara.df@renesas.com>,
	ryo.kataoka.wt@renesas.com,
	honda <takamitsu.honda.pv@renesas.com>,
	hiroyuki.yokoyama.vx@renesas.com, Chris.Paterson2@renesas.com,
	kouei.abe.cp@renesas.com, ren.imaoka.vj@renesas.com,
	goda <yusuke.goda.sx@renesas.com>,
	takashi.minami.xb@bp.renesas.com, takahiko.gomi.yn@renesas.com,
	khiem.nguyen.xt@renesas.com, yuta.wakasawa.pv@renesas.com,
	atsushi.tamaki.ks@renesas.com, harunobu.kurokawa.dn@renesas.com
Subject: Re: Question about hw_param with Ctrl-Z + fg
Date: Tue, 4 Apr 2017 08:02:57 +0000	[thread overview]
Message-ID: <8760ikvc1q.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <5528bc36-e9f4-1cc0-9429-94545b7e1928@sakamocchi.jp>


Hi Sakamoto-san, Mark

> > Hmm...
> > Above .be_hw_params_fixup is used to convert sampling rate or channel
> > number or some other related things between SoC / Codec as DPCM feature.
> > Thus, I can't switch to .be_hw_params_fixup to .prepare I guess.
> > But Mark, am I misunderstanding ?
> 
> In 'struct snd_pcm_ops.prepare' callback, configured parameters of PCM
> substream are available via members of 'struct snd_pcm_runtime'. The
> runtime is a member of 'struct snd_pcm_substream'. It's available in
> any of .prepare callbacks in ALSA SoC part.

Thank you for detail explain.
I investigated this, and I tried to use .prepare with below system.

	[44.1kHz] -> CPU -> .be_hw_params_fixup[44.1kHz -> 48kHz] -> Codec

This means, CPU converts 44.1kHz to 48kHz, and
Codec want to receive 48kHz as parameter.
On CPU/Codec both side, these got 44.1kHz from runtime.

static int cpu/codec_prepare(struct snd_pcm_substream *substream)
{
	/*
	 * In 44.1kHz -> 48kHz convert case,
	 * .be_hw_params_fixup() do convert magic.
	 * but here .prepare, it still receive 44.1kHz
	 */
	printk("rate = %d\n", substream->runtime->rate);
}

On CPU side, I could get converted parameter somehow (see below),
but it has zero chance to get converted parameter on Codec side .prepare ?
Converted rate is located only struct snd_pcm_hw_params in my system (= simple-scu-card).
Current .be_hw_params_fixup() is saving converted rate/channel in struct snd_interval,
but it should save it to struct snd_soc_pcm_runtime ?

void asoc_simple_card_convert_fixup(...
				    struct snd_pcm_hw_params *hw_params)
{
	struct snd_interval *rate = hw_param_interval(hw_params,
						SNDRV_PCM_HW_PARAM_RATE);
	struct snd_interval *channels = hw_param_interval(hw_params,
						SNDRV_PCM_HW_PARAM_CHANNELS);
	printk("------fixup\n");
	if (data->convert_rate)
		rate->min =
		rate->max = data->convert_rate;

	if (data->convert_channels)
		channels->min =
		channels->max = data->convert_channels;
}


---- CPU could get converted rate --------------------------
static int cpu_prepare(struct snd_pcm_substream *substream)
{
	struct snd_soc_pcm_runtime *fe = substream->private_data;

	/* substream->runtime->rate is still 44.1kHz here */

	if (fe->dai_link->dynamic) {
		int stream = substream->stream;
		struct snd_soc_dpcm *dpcm;
		struct snd_pcm_hw_params *be_params;

		list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) {
			be_params = &dpcm->hw_params;

			/*
			 * I could receive 48kHz here as params_rate(be_params)
			 */
		}
	}

	return 0;
}


Best regards
---
Kuninori Morimoto

  reply	other threads:[~2017-04-04  8:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-119657.20170403030456@dm.renesas.com>
     [not found] ` <redmine.journal-967542.20170403100335.fbd6fae50d6ed2e5@dm.renesas.com>
2017-04-04  0:54   ` Question about hw_param with Ctrl-Z + fg Kuninori Morimoto
2017-04-04  4:10     ` Takashi Sakamoto
2017-04-04  5:57       ` Kuninori Morimoto
2017-04-04  6:14         ` Takashi Sakamoto
2017-04-04  8:02           ` Kuninori Morimoto [this message]
2017-04-05  4:50             ` Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8760ikvc1q.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=atsushi.tamaki.ks@renesas.com \
    --cc=harunobu.kurokawa.dn@renesas.com \
    --cc=hideya.tanaka.nx@renesas.com \
    --cc=hien.dang.eb@renesas.com \
    --cc=hiroki.negishi.bx@renesas.com \
    --cc=hiroyuki.yokoyama.vx@renesas.com \
    --cc=khiem.nguyen.xt@renesas.com \
    --cc=kouei.abe.cp@renesas.com \
    --cc=mitsuhiro.kimura.kc@renesas.com \
    --cc=naoya.shiiba.nx@renesas.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=ren.imaoka.vj@renesas.com \
    --cc=ryo.kataoka.wt@renesas.com \
    --cc=ryo.kodama.vz@renesas.com \
    --cc=ryusuke.sakato.bx@renesas.com \
    --cc=takahiko.gomi.yn@renesas.com \
    --cc=takamitsu.honda.pv@renesas.com \
    --cc=takashi.minami.xb@bp.renesas.com \
    --cc=takeshi.kihara.df@renesas.com \
    --cc=tomoharu.fukawa.eb@renesas.com \
    --cc=tomohiro.komagata.aj@renesas.com \
    --cc=yusuke.goda.sx@renesas.com \
    --cc=yuta.wakasawa.pv@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.