From: Takashi Iwai <tiwai@suse.de>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: alsa-devel@alsa-project.org, patches.audio@intel.com,
lgirdwood@gmail.com, Ramesh Babu <ramesh.babu@intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
broonie@kernel.org,
Jaikrishna Nemallapudi <jaikrishnax.nemallapudi@intel.com>,
"Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Subject: Re: [PATCH 3/3] ALSA: pcm: conditionally avoid mmap of control data
Date: Tue, 16 May 2017 08:34:35 +0200 [thread overview]
Message-ID: <s5hd1b91f9g.wl-tiwai@suse.de> (raw)
In-Reply-To: <8778c2f1-440e-a622-fd38-6eeac2669f8b@sakamocchi.jp>
On Tue, 16 May 2017 08:24:39 +0200,
Takashi Sakamoto wrote:
>
> On May 16 2017 15:18, Takashi Iwai wrote:
> > On Tue, 16 May 2017 07:57:30 +0200,
> > Takashi Sakamoto wrote:
> >>
> >> On May 16 2017 14:46, Takashi Iwai wrote:
> >>> In this case, the problem is that the mmap control allows the appl_ptr
> >>> being changed silently without interaction with the driver. If the
> >>> driver requires some explicit action for changing the appl_ptr, it
> >>> won't work.
> >>
> >> I think 'struct snd_pcm_ops.pointer' is available for this purpose, too.
> >>
> >> static snd_pcm_sframes_t snd_pcm_playback_rewind(...)
> >> {
> >> ...
> >> hw_avail = snd_pcm_playback_hw_avail(runtime);
> >> (->struct snd_pcm_ops.pointer())
> >> ...
> >> (rewind PCM frames)
> >> ...
> >> + substream->ops->pointer(...);
> >> (->struct snd_pcm_ops.pointer())
> >> ...
> >> }
> >>
> >> If drivers need to handle event to update the appl_ptr, it records
> >> value of the appl_ptr, then compare it to current value to get the
> >> updates.
> >
> > IIRC, the problem isn't about the forward / rewind but about the
> > normal data transfer. In mmap mode, we transfer data on the mmap
> > buffer, and update appl_ptr via mmap control. Both are done without
> > notification to the driver (which is intentional for avoiding the
> > context switching).
> >
> > So we want to disable this optimization and always notify to the
> > driver. Disabling mmap status/control is the straight hack as it
> > falls back to ioctl and then the driver can know the change.
>
> There's SNDRV_PCM_IOCTL_HW_SYNC command. In kernel land
> implementation, this command is handled with a call of 'struct
> snd_pcm_ops.pointer'.
>
> In alsa-lib, this command is often executed in most cases to handle
> PCM frames.
The HWSYNC or SYNC_PTR ioctls are used only as the fallback when mmap
failed. It's the exact goal of this patch :)
Takashi
next prev parent reply other threads:[~2017-05-16 6:34 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 1:01 [PATCH 0/3] ALSA: Add rewind disable support Subhransu S. Prusty
2017-05-16 1:01 ` [PATCH 1/3] ALSA: core: let low-level driver or userspace disable rewinds Subhransu S. Prusty
2017-05-16 5:53 ` Takashi Iwai
2017-05-16 7:40 ` Subhransu S. Prusty
2017-05-16 1:01 ` [PATCH 2/3] ALSA: core: modify .ack callback to take arguments for updating appl ptr Subhransu S. Prusty
2017-05-16 5:56 ` Takashi Iwai
2017-05-16 7:36 ` Subhransu S. Prusty
2017-05-18 6:18 ` Subhransu S. Prusty
2017-05-18 8:09 ` Takashi Iwai
2017-05-19 13:11 ` Takashi Iwai
2017-05-22 5:41 ` Vinod Koul
2017-05-16 16:11 ` Pierre-Louis Bossart
2017-05-19 3:57 ` Takashi Sakamoto
2017-05-19 6:27 ` Takashi Iwai
2017-05-19 15:01 ` Pierre-Louis Bossart
2017-05-22 5:22 ` Vinod Koul
2017-05-22 7:16 ` Takashi Iwai
2017-05-26 7:42 ` Vinod Koul
2017-05-26 7:47 ` Takashi Iwai
2017-05-26 8:01 ` Vinod Koul
2017-05-22 5:21 ` Vinod Koul
2017-05-16 1:01 ` [PATCH 3/3] ALSA: pcm: conditionally avoid mmap of control data Subhransu S. Prusty
2017-05-16 5:38 ` Takashi Sakamoto
2017-05-16 5:46 ` Takashi Iwai
2017-05-16 5:57 ` Takashi Sakamoto
2017-05-16 6:18 ` Takashi Iwai
2017-05-16 6:24 ` Takashi Sakamoto
2017-05-16 6:34 ` Takashi Iwai [this message]
2017-05-16 6:54 ` Takashi Sakamoto
2017-05-16 7:02 ` Takashi Iwai
2017-05-16 10:55 ` Takashi Sakamoto
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=s5hd1b91f9g.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=jaikrishnax.nemallapudi@intel.com \
--cc=lgirdwood@gmail.com \
--cc=o-takashi@sakamocchi.jp \
--cc=patches.audio@intel.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ramesh.babu@intel.com \
--cc=subhransu.s.prusty@intel.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.