History log of /linux-master/sound/x86/intel_hdmi_audio.c
Revision Date Author Comments
# 439590ac 30-Oct-2023 Jani Nikula <jani.nikula@intel.com>

drm/edid: include drm_eld.h only where required

Reduce the dependencies on drm_eld.h. Some files might be able to drop
the dependency on drm_edid.h too with the direct inclusion of drm_eld.h.

Cc: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/9f5963ce900d747f3279312c0cd1da599fd83f94.1698747331.git.jani.nikula@intel.com


# bb30b453 16-Jun-2022 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: x86: intel_hdmi_audio: use pm_runtime_resume_and_get()

The current code does not check for errors and does not release the
reference on errors.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220616222910.136854-3-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e87c65ae 16-Jun-2022 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: x86: intel_hdmi_audio: enable pm_runtime and set autosuspend delay

The existing code uses pm_runtime_get_sync/put_autosuspend, but
pm_runtime was not explicitly enabled. The autosuspend delay was not
set either, the value is set to 5s since HDMI is rather painful to
resume.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20220616222910.136854-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5e154dfb 11-Apr-2022 Takashi Iwai <tiwai@suse.de>

ALSA: intel_hdmi: Fix the missing snd_card_free() call at probe error

The previous cleanup with devres may lead to the incorrect release
orders at the probe error handling due to the devres's nature. Until
we register the card, snd_card_free() has to be called at first for
releasing the stuff properly when the driver tries to manage and
release the stuff via card->private_free().

This patch fixes it by calling snd_card_free() on the error from the
probe callback using a new helper function.

Fixes: 854577ac2aea ("ALSA: x86: Allocate resources with device-managed APIs")
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220412102636.16000-27-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fc4cf429 05-Mar-2022 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Use standard mmap helper for Intel HDMI LPE audio

Intel HDMI LPE audio driver has its own mmap callback that mimics with
the noncached page attributes, but this is rather superfluous and can
be replaced with the standard helper, as the device is only for
playback and the write-cache should suffice.

This patch drops the own code and just uses the standard helper.

Link: https://lore.kernel.org/r/20220305083308.15718-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0aa6b294 02-Mar-2022 Zhen Ni <nizhen@uniontech.com>

ALSA: intel_hdmi: Fix reference to PCM buffer address

PCM buffers might be allocated dynamically when the buffer
preallocation failed or a larger buffer is requested, and it's not
guaranteed that substream->dma_buffer points to the actually used
buffer. The driver needs to refer to substream->runtime->dma_addr
instead for the buffer address.

Signed-off-by: Zhen Ni <nizhen@uniontech.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220302074241.30469-1-nizhen@uniontech.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1b1f98dd 06-Jan-2022 Jiasheng Jiang <jiasheng@iscas.ac.cn>

ALSA: intel_hdmi: Check for error num after setting mask

To maintain the consistency of the code, it should be better to add the
sanity check after calling dma_set_mask_and_coherent(), like
tegra_pcm_dma_allocate() in `sound/soc/tegra/tegra_pcm.c`.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20220107020851.3095591-1-jiasheng@iscas.ac.cn
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 58a95dfa 02-Aug-2021 Takashi Iwai <tiwai@suse.de>

ALSA: memalloc: Correctly name as WC

SNDRV_DMA_TYPE_DEV_UC and SNDRV_DMA_TYPE_DEV_UC_SG are incorrectly
named as if they were for the uncached memory, while actually we set
the pages as write-combined. Rename them to reflect the right
attribute.

Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20210802072815.13551-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 854577ac 15-Jul-2021 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Allocate resources with device-managed APIs

This patch converts the resource management in x86 HDMI LPE audio
driver with devres as a clean up. Each manual resource management is
converted with the corresponding devres helper now.

Link: https://lore.kernel.org/r/20210715075941.23332-73-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 82a60352 12-Jul-2021 Takashi Iwai <tiwai@suse.de>

ALSA: x86: simplify with sync_stop PCM ops

The reset procedure in had_do_reset() is exactly for the recently
introduced PCM sync_stop ops. Replace the call with the new ops and
clean up the unnecessary code and flags.

Link: https://lore.kernel.org/r/20210712091915.28067-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1d7a0395 05-Jul-2021 gushengxian <gushengxian@yulong.com>

ALSA: x86: fix spelling mistakes

Fix some spelling mistakes as follows:
regiter ==> register
confgiuration ==> configuration
playabck ==> playback
platoform ==> platform

Signed-off-by: gushengxian <gushengxian@yulong.com>
Link: https://lore.kernel.org/r/20210705073736.662875-1-gushengxian507419@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6417f031 16-Mar-2021 Leon Romanovsky <leon@kernel.org>

module: remove never implemented MODULE_SUPPORTED_DEVICE

MODULE_SUPPORTED_DEVICE was added in pre-git era and never was
implemented. We can safely remove it, because the kernel has grown
to have many more reliable mechanisms to determine if device is
supported or not.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 915183b6 14-Jan-2021 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Simplify with dma_set_mask_and_coherent()

LPE driver still has explicit calls of dma_set_mask() and
dma_set_coherent_mask().

Let's simplify with dma_set_mask_and_coherent().

Link: https://lore.kernel.org/r/20210114125412.993-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 75b1a8f9 04-Jan-2021 Joe Perches <joe@perches.com>

ALSA: Convert strlcpy to strscpy when return value is unused

strlcpy is deprecated. see: Documentation/process/deprecated.rst

Change the calls that do not use the strlcpy return value to the
preferred strscpy.

Done with cocci script:

@@
expression e1, e2, e3;
@@

- strlcpy(
+ strscpy(
e1, e2, e3);

This cocci script leaves the instances where the return value is
used unchanged.

After this patch, sound/ has 3 uses of strlcpy() that need to be
manually inspected for conversion and changed one day.

$ git grep -w strlcpy sound/
sound/usb/card.c: len = strlcpy(card->longname, s, sizeof(card->longname));
sound/usb/mixer.c: return strlcpy(buf, p->name, buflen);
sound/usb/mixer.c: return strlcpy(buf, p->names[index], buflen);

Miscellenea:

o Remove trailing whitespace in conversion of sound/core/hwdep.c

Link: https://lore.kernel.org/lkml/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4bdc0d67 06-Jan-2020 Christoph Hellwig <hch@lst.de>

remove ioremap_nocache and devm_ioremap_nocache

ioremap has provided non-cached semantics by default since the Linux 2.6
days, so remove the additional ioremap_nocache interface.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>


# 63d5cda7 09-Dec-2019 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop superfluous ioctl PCM ops

PCM core deals the empty ioctl field now as default(*).
Let's kill the redundant lines.

(*) commit fc033cbf6fb7 ("ALSA: pcm: Allow NULL ioctl ops")

Link: https://lore.kernel.org/r/20191210061145.24641-23-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# cc6c6912 09-Dec-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hdml-lpe-audio: Use managed buffer allocation

Clean up the driver with the new managed buffer allocation API.
The superfluous snd_pcm_lib_malloc_pages() and
snd_pcm_lib_free_pages() calls are dropped.

Link: https://lore.kernel.org/r/20191209094943.14984-72-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0a671dc5 25-Oct-2019 YueHaibing <yuehaibing@huawei.com>

ALSA: intel_hdmi: Remove dev_err() on platform_get_irq() failure

platform_get_irq() will call dev_err() itself on failure,
so there is no need for the driver to also do this.
This is detected by coccinelle.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20191025093905.14888-1-yuehaibing@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 8e8e69d6 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 285

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation version 2 of the license this program
is distributed in the hope that it will be useful but without any
warranty without even the implied warranty of merchantability or
fitness for a particular purpose see the gnu general public license
for more details

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 100 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141900.918357685@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# c7c3fec8 04-Feb-2019 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Avoid passing NULL to memory allocators

We should pass a proper non-NULL device object to memory allocators
although it was accepted in the past. The card->dev points to the
most appropriate device object in such a case, so let's put it.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0c3df9ed 11-Jan-2019 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Remove superfluous snd_pcm_suspend*() calls

The call of snd_pcm_suspend_all() & co became superfluous since we
call it in the PCM PM ops. Let's remove them.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0019457e 24-Oct-2018 Ville Syrjälä <ville.syrjala@linux.intel.com>

ALSA: x86: Rip out the lpe audio runtime suspend/resume hooks

Ever since commit 46e831abe864 ("drm/i915/lpe: Mark LPE audio runtime
pm as "no callbacks"") the runtime suspend/resume hooks are no longer
used. Inline them into the system suspend hooks.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181024154825.18185-2-ville.syrjala@linux.intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Takashi Iwai <tiwai@suse.de>


# 8dfb839c 24-Oct-2018 Ville Syrjälä <ville.syrjala@linux.intel.com>

ALSA: x86: Fix runtime PM for hdmi-lpe-audio

Commit 46e831abe864 ("drm/i915/lpe: Mark LPE audio runtime pm as
"no callbacks"") broke runtime PM with lpe audio. We can no longer
runtime suspend the GPU since the sysfs power/control for the
lpe-audio device no longer exists and the device is considered
always active. We can fix this by not marking the device as
active.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fixes: 46e831abe864 ("drm/i915/lpe: Mark LPE audio runtime pm as "no callbacks"")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181024154825.18185-1-ville.syrjala@linux.intel.com
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Takashi Iwai <tiwai@suse.de>


# 87246f7f 08-Aug-2018 Takashi Iwai <tiwai@suse.de>

ALSA: intel_hdmi: Use the new non-cached allocation

The HDMI LPE audio driver requires the non-cached page allocations for
its buffers. With the recent support of SNDRV_DMA_TYPE_DEV_UC type,
we can reduce lots of codes in the driver side and let the memalloc
core doing it properly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d2f88461 01-Aug-2018 Colin Ian King <colin.king@canonical.com>

ALSA: intel_hdmi: remove redundant variable cfg_val

Variable cfg_val is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'cfg_val' set but not used [-Wunused-but-set-variable]

[ Background info about val_bit field from alsa-devel ML thread:
tiwai: Actually this made me wonder what is the definition of val_bit.
It seems always 1 in the current code after the commit
964ca8083c02. Pierre?
pbossart: This val_bit is only there for debug/test, it should be set
to one by default and has nothing to do with the lpcm_id.
This variable was set even in patches before upstream
submission and was never needed, I guess it must be a 9-yr
old issue. Good catch!
]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c288248f 27-Jun-2018 Takashi Iwai <tiwai@suse.de>

ALSA: intel_hdmi: Use strlcpy() instead of strncpy()

hdmi_lpe_audio_probe() copies the pcm name string via strncpy(), but
as a gcc8 warning suggests, it misses a NUL terminator, and unlikely
the expected result.

Use the proper one, strlcpy() instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c77a6edb 28-Feb-2018 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fix potential crash at error path

When LPE audio driver gets some error at probing, it may lead to a
crash because of canceling the pending work in hdmi_lpe_audio_free(),
since some of ports might be still not initialized.

For assuring the proper free of each port, initialize all ports at the
beginning of the probe.

Fixes: b4eb0d522fcb ("ALSA: x86: Split snd_intelhad into card and PCM specific structures")
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 35014406 28-Feb-2018 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fix missing spinlock and mutex initializations

The commit change for supporting the multiple ports moved involved
some code shuffling, and there the initializations of spinlock and
mutex in snd_intelhad object were dropped mistakenly.

This patch adds the missing initializations again for each port.

Fixes: b4eb0d522fcb ("ALSA: x86: Split snd_intelhad into card and PCM specific structures")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7229b12f 20-Feb-2018 Takashi Iwai <tiwai@suse.de>

ALSA: x86: hdmi: Add single_port option for compatible behavior

The recent support for the multiple PCM devices allowed user to use
multiple HDMI/DP outputs, but at the same time, the PCM stream
assignment has been changed, too. Due to that, the former PCM#0
(there was only one stream in the past) is likely assigned to a
different one (e.g. PCM#2), and it ends up with the regression when
user sticks with the fixed configuration using the device#0.

Although the multiple monitor support shouldn't matter when user
deploys the backend like PulseAudio that checks the jack detection
state, the behavior change isn't always acceptable for some users.

As a mitigation, this patch introduces an option to switch the
behavior back to the old-good-days: when the new option,
single_port=1, is passed, the driver creates only a single PCM device,
and it's assigned to the first connected one, like the earlier
versions did. The option is turned off as default still to support
the multiple monitors.

Fixes: 8a2d6ae1f737 ("ALSA: x86: Register multiple PCM devices for the LPE audio card")
Reported-and-tested-by: Hubert Mantel <mantel@metadox.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1967158f 30-Jun-2017 Gustavo A. R. Silva <garsilva@embeddedor.com>

ALSA: x86: fix error return code in hdmi_lpe_audio_probe()

platform_get_irq() returns an error code, but the intel_hdmi_audio
driver ignores it and always returns -ENODEV. This is not correct,
and prevents -EPROBE_DEFER from being propagated properly. Also,
notice that platform_get_irq() no longer returns 0 on error.

Print error message and propagate the return value of platform_get_irq
on failure.

Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 668e3b01 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm/i915: Fix runtime PM for LPE audio

Not calling pm_runtime_enable() means that runtime PM can't be
enabled at all via sysfs. So we definitely need to call it
from somewhere.

Calling it from the driver seems like a bad idea because it
would have to be paired with a pm_runtime_disable() at driver
unload time, otherwise the core gets upset. Also if there's
no LPE audio driver loaded then we couldn't runtime suspend
i915 either.

So it looks like a better plan is to call it from i915 when
we register the platform device. That seems to match how
pci generally does things. I cargo culted the
pm_runtime_forbid() and pm_runtime_set_active() calls from
pci as well.

The exposed runtime PM API is massive an thorougly misleading, so
I don't actually know if this is how you're supposed to use the API
or not. But it seems to work. I can now runtime suspend i915 again
with or without the LPE audio driver loaded, and reloading the
LPE audio driver also seems to work.

Note that powertop won't auto-tune runtime PM for platform devices,
which is a little annoying. So I'm not sure that leaving runtime
PM in "on" mode by default is the best choice here. But I've left
it like that for now at least.

Also remove the comment about there not being much benefit from
LPE audio runtime PM. Not allowing runtime PM blocks i915 runtime
PM, which will also block s0ix, and that could have a measurable
impact on power consumption.

Cc: stable@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fixes: 0b6b524f3915 ("ALSA: x86: Don't enable runtime PM as default")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-2-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>
(cherry picked from commit 183c00350ccda86781f6695840e6c5f5b22efbd1)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>


# 7f80f513 08-May-2017 Laura Abbott <labbott@redhat.com>

alsa: use set_memory.h header

set_memory_* functions have moved to set_memory.h. Switch to this
explicitly.

Link: http://lkml.kernel.org/r/1488920133-27229-14-git-send-email-labbott@redhat.com
Signed-off-by: Laura Abbott <labbott@redhat.com>
Acked-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 8a2d6ae1 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

ALSA: x86: Register multiple PCM devices for the LPE audio card

Now that everything is in place let's register a PCM device for
each port of the display engine. This will make it possible to
actually output audio to multiple displays at the same time. And
it avoids modesets on unrelated displays from clobbering up the
ELD and whatnot for the display currently doing the playback.

v2: Add a PCM per port instead of per pipe
v3: Fix off by one error with port numbers (Pierre-Louis)
Fix .notify_audio_lpe() prototype (Pierre-Louis)

Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-12-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# b4eb0d52 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

ALSA: x86: Split snd_intelhad into card and PCM specific structures

To allow multiple PCM devices to be registered for the LPE audio card,
split the private data into card and PCM specific chunks. For now we'll
stick to just one PCM device as before.

v2: Rework to do a pcm device per port instead of per pipe

Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-11-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# bb4ac5a0 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

ALSA: x86: Prepare LPE audio ctls for multiple PCMs

In preparation for register a PCM device for each pipe adjust
link up the ctl elements with the corresponding PCM device.

Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-10-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# a8562e4d 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm/i915: Clean up the LPE audio platform data

Split the LPE audio platform data into a port specific
chunk and device specific chunk. Eventually we'll have
a port specific chunk for each port, but for now we'll
stick to just one.

We'll also get rid of the intel_hdmi_lpe_audio_eld structure
which doesn't seem to have any real reason to exist.

v2: Organize per port instead of per pipe

Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-9-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# 265fa2e1 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm/i915: Remove hdmi_connected from LPE audio pdata

We can determine that the pipe was shut down from pipe<0, so there's
no point in duplicating that information as 'hdmi_connected'.

v2: Use pipe<0 instead of port<0 as we'll want to do per-port
PCM devices later
Initialize pipe to -1 to inidicate inactive initial state

Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-7-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# c98ec5ba 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm/i915: Replace tmds_clock_speed and link_rate with just ls_clock

There's no need to distinguish between the DP link rate and HDMI TMDS
clock for the purposes of the LPE audio. Both are actually the same
thing more or less, which is the link symbol clock. So let's just
call the thing ls_clock and simplify the code.

Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-6-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# d2205595 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm/i915: Remove the unused pending_notify from LPE platform data

The pending_notify flag in the LPE audio platform data is pointless,
actually unused. So let's kill it off.

v2: Fix typo in patch subject

Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-5-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# 8d5c3030 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

ALSA: x86: Clear the pdata.notify_lpe_audio pointer before teardown

Clear the notify function pointer in the platform data before we tear
down the driver. Otherwise i915 would end up calling a stale function
pointer and possibly explode.

Cc: stable@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-3-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# 183c0035 27-Apr-2017 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm/i915: Fix runtime PM for LPE audio

Not calling pm_runtime_enable() means that runtime PM can't be
enabled at all via sysfs. So we definitely need to call it
from somewhere.

Calling it from the driver seems like a bad idea because it
would have to be paired with a pm_runtime_disable() at driver
unload time, otherwise the core gets upset. Also if there's
no LPE audio driver loaded then we couldn't runtime suspend
i915 either.

So it looks like a better plan is to call it from i915 when
we register the platform device. That seems to match how
pci generally does things. I cargo culted the
pm_runtime_forbid() and pm_runtime_set_active() calls from
pci as well.

The exposed runtime PM API is massive an thorougly misleading, so
I don't actually know if this is how you're supposed to use the API
or not. But it seems to work. I can now runtime suspend i915 again
with or without the LPE audio driver loaded, and reloading the
LPE audio driver also seems to work.

Note that powertop won't auto-tune runtime PM for platform devices,
which is a little annoying. So I'm not sure that leaving runtime
PM in "on" mode by default is the best choice here. But I've left
it like that for now at least.

Also remove the comment about there not being much benefit from
LPE audio runtime PM. Not allowing runtime PM blocks i915 runtime
PM, which will also block s0ix, and that could have a measurable
impact on power consumption.

Cc: stable@vger.kernel.org
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fixes: 0b6b524f3915 ("ALSA: x86: Don't enable runtime PM as default")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170427160231.13337-2-ville.syrjala@linux.intel.com
Reviewed-by: Takashi Iwai <tiwai@suse.de>


# 0b6b524f 21-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Don't enable runtime PM as default

Unlike HSW and newer, BYT/CHT devices have no fine control of audio
power domain in i915 side. Since there is little gain by runtime PM
on BYT/CHT, so far, this commit removes the pm_runtime_enable() call
as default.

User who still wants the runtime PM may adjust the corresponding
sysfs files (power/control and power/autosuspend_delay_ms)
appropriately, of course.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3002b9fb 13-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Use runtime PM autosuspend

This patch adds a few lines to the driver to use autosuspend for the
runtime PM. It'll become useful with the combination of the keep-link
feature.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b1ef30e5 15-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Don't bail out from PCM ops when disconnected

Currently the driver returns -ENODEV when the monitor is disconnected.
But PA alsa module doesn't like this and it starts playing Juliet,
kills itself as if it were a fatal tragedy.

Since we protect the whole read/write at disconnection, just allow the
PCM accesses even during disconnection.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2d42c033 15-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Minor code rearrangement

Put the stuff in the right order; notification should be at the end of
the action.

Also dropped a superfluous debug print and incorrect comments.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# be9a2e93 15-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Stop the stream when buffer is processed after disconnection

This shouldn't happen, but just to be sure...

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 28ed125b 15-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Avoid register accesses during disconnection

It seems that accessing registers during disconnection often leads to
the GPU pipe error. The original driver had a similar check in the
past, but it was lost through refactoring. Now put a connection check
in the register access functions.

One exception is the irq handler: it still needs to access the raw
register even while disconnected, because it has to read and write to
ACK the irq mask. Although the irq shouldn't be raised while
disconnected (the stream should have been disabled), let's make it
safer for now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a72ccfba 15-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Don't return an error from chmap ctl at disconnected

It's not wise to return an error at info/get callback when
disconnected, which happens at any time.
The chmap ctl is supposed to fill zero for such a case, instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 18353192 15-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fix memory leak in had_build_channel_allocation_map()

The previously allocated chmap has to be released before setting the
new one.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5def9019 15-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Use snd_pcm_stop_xrun() for connection / disconnection paths

This seems more friendly to user-space, as it's notified at least as
an error, instead of forcibly moving the PCM state to SETUP out of
sudden.

Moreover, snd_pcm_stop() needs an extra PCM spinlock I forgot, while
snd_pcm_stop_xrun() takes the spinlock by itself.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b9bacf27 13-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Implement jack control

This patch implements a jack interface for notifying HDMI/DP
connection. PA listens to this, so it can handle the monitor
connection more gracefully.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# df42cb49 12-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop unused stream.running field

The pcm_stream_info.running field is only set in the PCM trigger
callback but never referred, thus it can be safely removed.

Also, properly cover the spinlock in both the trigger START and STOP
to protect had_enable_audio() calls.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e2acecf2 11-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Handle reset at prepare callback

Currently the driver handles some reset procedure at the trigger STOP
and the underrun functions, where both are executed in the interrupt
context. Especially the underrun function has a sync-loop to clear
the UNDERRUN status bit, and this is supposed to be one of plausible
causes of GPU hangup.

Since the job to be done in the interrupt handler should be minimum,
we move the reset function out of trigger and underrun, and push it
into the prepare (and hw_free) callbacks instead. Here a new flag,
need_reset, is introduced to indicate the requirement of the reset
procedure. This is for avoiding the multiple resets when PCM prepare
is called sequentially.

Also in the UNDERRUN bit-clear sync loop, take a longer pause to be in
the safer side. Taking a longer delay is no longer a problem now
because we're running in the normal context.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3fe2cf7e 07-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Support S16 format

Now we support S16 PCM format in addition. For this, we need to set
packet_mode=1 in AUD_CONFIG register.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 85bd8748 07-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Support S32 format

The hardware has the support for the left-aligned 24bit format in
32bit packet. This corresponds to S32 format in ALSA. We need to set
the msbits restriction as well to inform user-space that only MSB
24bit are available.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e8de9859 07-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Allow no-period-wakeup setup

In the current implementation, the driver may update the BDs even at
PCM pointer callback. This allows us to skip the period interrupt
effectively.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 8d48c016 07-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Allow single period PCM operation

This is an implementation of PCM streaming with only 1 period.
Since the hardware requires the refresh of BDs after each BD
processing finishes, we'd need at least two BDs. The trick is that
both BDs point to the same content: the address of the PCM buffer
head, and the whole buffer size. Then it loops over to the whole
buffer again after it finished once.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a9ebdd0e 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Don't pass SNDRV_PCM_INFO_BATCH flag

The PCM engine on LPE audio isn't like a batch-style process any
longer, but rather it deals with the standard ring buffer. Remove the
BATCH info flag so that PA can handle the buffer in timer-sched mode.

Similarly, the DOUBLE flag is also superfluous. Drop both bits.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 40ce4b5d 07-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Cache AUD_CONFIG register value

At enabling the audio, we modify AUD_CONFIG register bit 0. So far,
it does read-modify-write procedure with a special hack for the
channel bits due to the silicon bug. But we can optimize it by
remembering the AUD_CONFIG register value privately. This simplifies
the things a lot.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 77531bee 06-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Rearrange defines

We have two header files and everything is mixed up chaotically.
Move the chip-specific definitions like the hardware registers to
intel_hdmi_lpe_audio.h, and the rest, the implementation specific
stuff into intel_hdmi_audio.h.

In addition, put some more comments to the register fields, and fix
the incorrect name prefix for AUD_HDMI_STATUS bits, too.

The whole changes are merely a code shuffling, and there is no
functional change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1df98924 07-Feb-2017 Arnd Bergmann <arnd@arndb.de>

ALSA: x86: mark hdmi suspend/resume functions as __maybe_unused

The two functions are unused when CONFIG_PM_SLEEP is disabled:

sound/x86/intel_hdmi_audio.c:1633:12: error: 'hdmi_lpe_audio_resume' defined but not used [-Werror=unused-function]
sound/x86/intel_hdmi_audio.c:1622:12: error: 'hdmi_lpe_audio_suspend' defined but not used [-Werror=unused-function]

Marking them as __maybe_unused avoids the warning without introducing an
ugly #ifdef.

Fixes: 182cdf23dbf6 ("ALSA: x86: Implement runtime PM")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 873ab035 06-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fix driver name string overflow

The driver sets card->driver name string over its size (16 bytes).
Shorten the name string to fit with it.

Also, set more verbose string to card->shortname and ->longname.
This doesn't have to be identical with card->driver at all.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 075a1d46 06-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Rename had_enable_audio_int() to had_ack_irqs()

had_enable_audio_int() came from the LPE audio shell set_caps
callback with ENABLE_INT and DISABLE_INT caps. I interpreted as these
correspond to enabling / disabling the audio interface, but the actual
implementation is only to clear (send ACK) to both BUFFER_DONE and
BUFFER_UNDERRUN interrupts unconditionally. And, there is no
counterpart, DISABLE_INT, code at all.

For avoiding the further misunderstanding, rename the function to the
more fitting one, had_ack_irqs(), and drop the calls with enable=false
in allover places. There is no functional changes at all.

After this patch, there is only one caller at the PCM trigger start.
Then it's doubtful whether this call is still really needed or not; I
bet it not, but let's stay in the safer side for now and keep it as
was.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3e21a76c 07-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop suspicious U24 format support

U24 format is declared to be supported by the driver, but this looks
really doubtful, as there is no corresponding code. Better to drop
it. This format is very uncommon, so there should be practically no
impact by this change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e1b239f3 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Refactor PCM process engine

This is again a big rewrite of the driver; now it touches the code to
process PCM stream transfers.

The most fundamental change is that the driver may support more than
four periods. Instead of keeping the same index between both the ring
buffer (with the fixed four buffer descriptors) and the PCM buffer
periods, we keep difference indices for both (bd_head and pcm_head
fields). In addition, when the periods are more than four, we need to
track both head and next indices. That is, we now have three indices:
bd_head, pcm_head and pcm_filled.

Also, the driver works better for periods < 4, too: the remaining BDs
out of four are marked as invalid, so that the hardware skips those
BDs in its loop.

By this flexibility, we can use even ALSA-lib dmix plugin, which
requires 16 periods as default.

The buffer size could be up to 20bit, so the max buffer size was
increased accordingly. However, the buffer pre-allocation is kept as
the old value (600kB) as default. The reason is the limited number of
BDs: since it doesn't suffice for the useful SG page management that
can fit with the usual page allocator like some other drivers, we have
to still allocate continuous pages, hence we shouldn't take too big
memories there.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b556290f 04-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Unify local function prefix

Use had_ prefix consistently to all local helper functions, as well as
had_pcm_ for PCM ops.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f4566aa1 04-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Minor cleanup of reset buffer procedure

The procedure to reset buffer pointers is performed in two places and
still open-coded. Simplify the helper function and use it
consistently.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 83af57dd 03-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Don't check connection in lowlevel accessors

The lowlevel register read/write don't have to be careful about the
connection state. It should be checked in the caller side instead.
By dropping the check, we can simplify the code, and readability.

This patch also refacors the functions slightly: namely,
- drop the useless always-zero return values
- fold the inline functions to the main accessor functions themselves
- move the DP audio hack for AUD_CONFIG to the caller side
- simplify snd_intelhad_eanble_audio() and drop the unused
had_read_modify()

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 412bbe7d5 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Explicit specify 32bit DMA

LPE audio is capable only up to 32bit address, as it seems.
Then we should limit the DMA addresses accordingly via dma-mapping
API.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 91b0cb0c 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Rename drv_status to connected

After the rewrite of the runtime PM code, we have only two driver
status: CONNECTED and DISCONNECTED. So it's clearer to use a boolean
flag, and name it easier one, "connected".

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 73997b05 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Yet more tidy-up and clean-ups

- Add a few more comments to functions.

- Move the initialization of some PCM state variables to open and
prepare callbacks, where these are clearer places.

- Remove superfluous NULL checks.

- Get rid of the bogus drv_status change to CONNECTED at close;
this doesn't make any sense.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 44684f61 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Simplify comments

It's a stand-alone small driver code, and we don't have to describe
too much formalized comments in kernel-doc style for local functions
at all.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 36ed3466 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Set CA bits for DisplayPort too

This is a guess work. Usually the DP audio info frame is just 8-bit
shifted from HDMI AI, so let's try to put CA in DIP frame 2 [24-31].

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4aedb946 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Create ELD control element

Like other drivers, expose the ELD bytes via a control element so that
user-space can parse it.

For the simplicity, the code to register the ctl elements is
refactored using an array. Also, since ELD ctl read copies the bytes
also during disconnection, clear the ELD bytes at hot-unplug, in order
to avoid the leak of the previous bogus ELD.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 03c34377 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Clean up unused defines and inclusions

Many defines and constants are left unused. Clean them up.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7ceba75f 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Reduce redundant register field names

Currently each register definition contains the own prefix in the
union struct itself; for example, union aud_ch_status_0 has
status_0_regx and status_0_regval fields. These are simply
superfluous, since usually the type of the variable is seen in its
declaration or in its name.

In this patch, we cut off these prefixes. Now all register
definitions have regx and regval fields consistently, instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# df0435db 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Use the standard ELD bytes definitions

We have some constants defined in drm/drm_edid.h, and clean up our own
definitions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f69bd104 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Move stream status into pcm_stream_info

The only remaining field in struct had_stream_data is stream_type that
holds the current stream status. Such information fits better in
struct pcm_stream_info, so move it as a boolean "running" field to be
clearer.

This allows us to get rid or had_stream_data definition and
references.

Also, the superfluous status check get removed in a couple of places
where we can call PCM helpers in anyway.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 182cdf23 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Implement runtime PM

Although the driver has some PM callbacks, it doesn't do it right:
- the suspend callback doesn't handle to suspend the running PCM,
- the runtime PM ops are missing,
- pm_runtime_get_sync() isn't used at the right place.

This patch covers the above and provides the basic runtime PM
functionality.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 313d9f28 02-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Properly manage PCM substream lifetype

The PCM substream is referred not only in the PCM callbacks but also
in the irq handler and in the hotplug/unplug codes. The latter code
paths don't take the PCM lock, thus the PCM may be released
unexpectedly while calling PCM helper functions or accessing
pcm->runtime fields.

This patch implements a simple refcount to assure the PCM substream
accessibility while the other codes are accessing. It needed some
code refactoring in the relevant functions for avoiding the doubly
spinlocks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7d9e7986 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop unused fields from pcm_stream_info

The struct pcm_stream_info contains a few unused or useless fields.
str_id is always zero, buffer_ptr is volatile, never read, and sfreq
is nowhere referred. Kill them.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fa5dfe6a 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop redundant had_stream_pvt

The had_stream_pvt struct assigned to PCM runtime private data tracks
merely the stream running status, and the very same information is
carried by had_stream->stream_type. Kill it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0e9c67d7 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop superfluous state field

The state field keeps the connection state and it's basically as same
as drv_status field. Drop this redundancy.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d0e9b1a2 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop flag_underrun field

The flag_underrun flag is used to indicate to escalate the XRUN
reporting at the next position inquiry, but there is a much simpler
method to achieve it: just call snd_pcm_stop_xrun().

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 8f8d1d7f 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fix racy access to chmap

The access to chmap can be racy against the hotplug process, where it
recreates the chmap on the fly. For protecting against it, a mutex is
introduced in this patch. It's also used for protecting the change /
reference of eld and state fields, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bcce775c 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Remove superfluous irqsave flags

We don't need to use irqsave/irqrestore versions for each spin lock,
but judge the context properly and use the simpler versions.

Also add some (still simplistic) comments to functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4a5ddb2c 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Constfy tables

Some tables can be defined as const.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4151ee84 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Remove _v[12] suffices

Although we dropped the most of the obsoleted *_v1 definitions and
codes, some codes still keep the _v1 or _v2 suffices. Now they are
ripped off.

The only thing to be done carefully here is the definition of control
offsets. The original code defines enum hdmi_ctrl_reg_offset_v1 and
a few new elements just for v2 on its top. After this cleanup, we
remove the old AUD_HDMI_STATUS and AUD_HDMIW_INFOFR definitions and
replace with the v2 values.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2e52f5e5 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Tidy up codes

Clean up codes, fix indentations, correct comments, etc.
No functional change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 79f439ea 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop had_get_hwstate()

The helper function isn't clearer than the plain condition check
"if (drv_status == HDA_DRV_DISCONNECTED)". By expanding this, the
compiler could even catch the possible uninitialized cases, so we
could fix them, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# caa2a61a 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Remove superfluous check at resume

The had_get_hwstate() is identical with drv_status==DISCONECTED, which
was already checked before the call. And, returning an error at
resume is simply bad. That is, we should just kill this check.

Also, spewing an error at resume for drv_status!=SUSPENDED is also
annoying, as this is the normal case when the suspend was called
without the monitor connection. Make it debug, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 99b2ab9d 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fix sleep-in-atomic via i915 notification

i915 notification is executed in a spinlock, thus it must not sleep;
i.e. we can't use kmalloc with GFP_KERNEL or such.

For making it working properly, move the notification handler in a
work, and handle it gracefully. We have already such a work, and it
was used just at the start. This can be re-used in a more generic
hotplug handling.

Also, the patch adds the proper call of cancel_work_sync() to the
destructor.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f6a82a0c 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop superfluous PCM private_free

snd_pcm_lib_preallocate_free_for_all() doesn't have to be called from
each driver as it's called in the PCM core.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e9d65abf 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop unused fields from snd_intelhad struct

Also change the flag_underrun to bool to be clearer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# df76df12 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Remove indirect call of snd_pcm_period_elapsed()

Again another indirect call... Let's straighten it up.
Also define the had_stream field with a proper type instead of a void
pointer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e29c0f96 01-Feb-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fix for CONFIG_PM=n

The direct access to power.runtime_status is taboo, let's use a helper
macro to avoid the compile error with CONFIG_PM=n.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c75b0476 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Replace pr_xxx() with dev_xxx()

dev_xxx() helpers give a tidier output in general.

While we're at it, remove many useless debug prints (e.g. the ones at
each function entry), replace some too verbose errors with debugs, and
use WARN_ON() for some serious errors.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 372d855f 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Fold intel_hdmi_audio_if.c into main file

As the very last step, we fold intel_hdmi_audio_if.c into the main
file, intel_hdmi_audio.c. This is merely a cleanup, and no functional
change.

By this move, we can mark all functions and variables as static, which
allows the compiler more optimizations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# da864809 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Flatten two abstraction layers

This is the final stage for a big clean-up series. Here we flatten
the two layers into one. Formerly, the implementation was split to
HDMI "shell" that talks with the platform device, and HDMI audio part
that communicates via caps and other event handlers. All these would
be good if there were multiple instantiations or if there were data
protection. But neither are true in our case. That said, it'll be
easier to have a flat driver structure in the end.

In this patch, the former struct hdmi_lpe_audio_ctx is forged into the
existing struct snd_intelhad. The latter has already a few members
that are basically the copy from the former. Only a few new members
for the lowlevel I/O are added by this change.

Then, the had_get_caps() and had_set_caps() are simply replaced with
the direct calls to copy the data in the struct fields. Also, the
had_event_handler() calls are replaced with the direct call for each
event as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 36ec0d99 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Call snd_card_register() at the end

The card registration should be done at the last stage of the probe
procedure. Otherwise user-space may access to the device before the
whole initialization is done.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5647aec2 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Embed snd_intelhad into snd_card

Instead of allocating snd_intelhad struct, use the card's private_data
and embed it. It simplifies the code a lot.

While we're at it, embed had_stream into snd_intelhad struct instead
of individually allocating, and rename had_pvt_data to a bit more
specific name, had_stream_data.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# dae15a9d 31-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Move dma_mask debug print into intel_hdmi_lpe_audio.c

It belongs to the right place.

And, remove a few sanity checks (e.g. NULL card) and debug prints as
well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0e18060f 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop unused hw_silence field

It's nowhere used. Let's drop it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6ddb3ab6 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Move the global underrun_count to struct snd_intelhad

The last one is in intel_hdmi_audio.c, underrun_count: this can be
embedded in snd_intelhad object.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bf8b24f8 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop the global platform device reference

Instead of referring to the global hlpe_pdev variable, pass the
platform device object to each function properly. Accessing to the
global object is really ugly and error-prone.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 437af8f2 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Call event callback directly

Currently the driver calls the event callback stored in its ctx
pointer, but it's obviously inefficient. Replace it with the direct
calls.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# dd895f2e 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop useless mutex at probe

had_mutex is (supposedly) used to protect the concurrent calls of
hdmi_audio_probe(). But we may have only one device at most, so it's
utterly useless. Drop it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 79dda75a 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Pass snd_intelhad object to helpers

For reducing the global variable reference, keep snd_intelhad object
in the context and pass it to each helper. It's a preliminary change
for further cleanup.

This also includes the simplification of the probe procedure: the LPE
platform driver directly gets the created snd_intelhad object by
hdmi_audio_probe(), and passes it to each helper and destructor,
hdmi_audio_remove(). The hdmi_audio_probe() function doesn't call the
back-registration any longer, which is fairly useless. The LPE
platform driver initializes the stuff instead at the right place, and
calls the wq after the object creation in the probe function itself.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6f9ecc76 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop snd_intel_had_interface indirect calls

Yet another indirection is killed: at this time, it's
snd_intel_had_interface. It contains also the name string, but it's
nowhere used, thus we can kill it, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9eca88c8 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Replace indirect query_ops with direct calls

Like the previous patch, this replaces the indirect query_ops calls
via direct function calls. They are only get_caps and set_caps, so
fairly straightforward at this time.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f23df807 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Replace indirect register ops with direct calls

Now about the indirect register ops: they are replaced with direct
calls, too.

The read / write / modify ops are simply replaced with the
corresponding functions. The difference is that we calculate the
offset inside the function now. So all the had_config_offset
references in the caller side are dropped. This also simplifies the
DP-audio check in hdmi_audio_write() and hdmi_audio_rmw().

The hdmi_audio_get_register_base is dropped since it's no longer used
when the base address and config offset are referred in the read/write
functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 76296ef0 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Drop indirect calls of had_ops

We have only a single implementation of had_ops, hence there is no
merit to use the indirect calls at all. Let's replace it with the
direct calls -- which allows the compiler more optimizations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4812dcc4 30-Jan-2017 Takashi Iwai <tiwai@suse.de>

ALSA: x86: Remove v1 ops and structs

The v1 code refers to Medfield/Clovertrail. It's not used at all in
the current driver, and probably won't be ever. Let's clean this up,
then we can go to the next stage of cleanup tasks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 964ca808 31-Jan-2017 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: x86: intel_hdmi: add definitions and logic for DP audio

Imported from legacy patches

Note: the new code doesn't assume a modified ELD but
an explicit notification that DP is present. It appears
that the i915 code does change the ELD so we could use
the ELD-based tests to check for DP audio

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 232892fb 24-Jan-2017 Jerome Anand <jerome.anand@intel.com>

ALSA: x86: hdmi: continue playback even when display resolution changes

When the display resolution changes, the drm disables the
display pipes due to which audio rendering stops. At this
time, we need to ensure the existing audio pointers and
buffers are cleared out so that the playback can restarted
once the display pipe is enabled with a different N/CTS values

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jerome Anand <jerome.anand@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5dab11d8 24-Jan-2017 Jerome Anand <jerome.anand@intel.com>

ALSA: x86: hdmi: Add audio support for BYT and CHT

Hdmi audio driver based on the child platform device
created by gfx driver is implemented.
This audio driver is derived from legacy intel
hdmi audio driver.

The interfaces for interaction between gfx and audio
are updated and the driver implementation updated to
derive interrupts in its own address space based on
irq chip framework

The changes to calculate sub-period positions was triggered
by David Henningsson <david.henningsson@canonical.com> and is
accomodated in this patch

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jerome Anand <jerome.anand@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>