From: Lars-Peter Clausen <lars@metafoo.de>
To: Tim Harvey <tharvey@gateworks.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: ASoC HDMI receiver driver
Date: Fri, 31 Oct 2014 18:03:02 +0100 [thread overview]
Message-ID: <5453C0C6.8010006@metafoo.de> (raw)
In-Reply-To: <CAJ+vNU1KEyYNYcZzCn_mcSrSVf+EVehLK0n0utPSZ9WCfEPEPQ@mail.gmail.com>
On 10/31/2014 12:13 AM, Tim Harvey wrote:
> On Thu, Oct 30, 2014 at 12:41 AM, Lars-Peter Clausen <lars@metafoo.de> wrote:
>> On 10/30/2014 04:34 AM, Tim Harvey wrote:
>>> Greetings,
>>>
>>> I'm working on an ASoC driver (an mfd driver for an HDMI receiver chip
>>> with an accompanying codec driver for the audio capture portion, and a
>>> cpu-dai driver for the specific SoC its hooked to). I can't seem to
>>> figure out what kind of hook I need in order to fill out the
>>> snd_pcm_substream fields specifying the rate/channels/sample-format of
>>> the receiving HDMI audio stream. In this case HDMI audio (and thus the
>>> codec) supports several rates but it doesn't make sense that the codec
>>> is told what rate to capture at as the rate is dictated by the current
>>> stream the receiver is being provided. I'm thinking there is some hook
>>> I'm missing that allows the codec to fill in the params dynamically
>>> when the capture device is opened.
>>>
>>> Any pointers to how I deal with this?
>>
>> In the startup() callback of the CODEC driver you can apply additional
>> constraints to the available parameter ranges. See
>> snd_pcm_hw_constraints_... in include/sound/pcm.h
>>
>> E.g. to constrain the rate to one fixed value you could do
>> snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, rate, rate);
>>
>> - Lars
>>
>
> Lars,
>
> Thanks for the tip!
>
> I found that if I add some validation into the hw_params function for
> the codec, that I can return an -EINVAL if the requested params don't
> match the incoming stream and that will cause the ALSA application to
> at least error out.
>
> However, when I saw your response I then also tried setting the
> constraint and found that an invalid sample-rate gets 'refined' to the
> available rate thus the hw_params sanity check passes, yet the user
> application apparently does not feedback that the rate has been
> changed.
>
> For example if I do the following on a capture stream which is
> actually 44.1kHz from the HDMI source with a constraint to set the
> rate to 44100 the audio is played back at 44100 and has all kinds of
> pops etc:
>
> gst-launch alsasrc device="my-hdmi-receiver-card" !
> audio/x-raw-int,rate=48000 ! queue ! alsasink device="playback-card"
>
> Where-as the following plays back fine:
>
> gst-launch alsasrc device="my-hdmi-receiver-card" !
> audio/x-raw-int,rate=44100 ! queue ! alsasink device="playback-card"
>
>
> I find that the value passed to startup in the substream is 48000
> which gets refined to 44100 if the constraints were set, which ends up
> passing hw_params 44100 but the 'application' still has issues.
>
> I think its more appropriate to validate the hw_params instead of
> using the constraints. Does this make sense?
No. By setting up the constraints you tell the userspace application which
parameters are supported. This allows the application to pick one of the
available parameters and then call hw_params() with it. Not setting up the
constraints and erroring out in hw_params() will cause applications to not
work. If the rate requested is not in the valid range the ALSA core should
actually already error out before the drivers hw_params() function is called.
- Lars
next prev parent reply other threads:[~2014-10-31 17:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-30 3:34 ASoC HDMI receiver driver Tim Harvey
[not found] ` <5451EB8E.9050203@metafoo.de>
2014-10-30 23:13 ` Tim Harvey
2014-10-31 17:03 ` Lars-Peter Clausen [this message]
2014-10-31 19:16 ` Tim Harvey
2014-10-31 19:42 ` Lars-Peter Clausen
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=5453C0C6.8010006@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=tharvey@gateworks.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.