Represent each port as machine DAPM pin widget. This helps in
enable/disable pin when monitor is connected/disconnected in case pcm
is rendered to multiple ports.
Create machine pin widgets and pin switch kcontrol for each port and
report based on the pin status
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Creates ASoC jack for HDMI PCM and calls hdmi codec API to initialize
jack in bxt_da7219_max98357 machine
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Creates ASoC jack for HDMI PCM and calls hdmi codec API to initialize
jack in bxt_rt298.c machine
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Creates ASoC jack for HDMI PCM and calls hdmi codec API to initialize
jack in skl_nau88l25_ssm4567 machine
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Creates ASoC jack for HDMI PCM and calls hdmi codec API to initialize
jack in skl_nau88l25_max98357a machine
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Creates ASoC jack for HDMI pcm and calls hdmi codec API to initialize
jack in skl_rt268 machine
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Use snd_soc_jack instead of snd_jack and create the jack in machine
driver and pass the jack pointer to hdac_hdmi driver for jack
reporting.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Since we have the MST feature enabled and Pin-Port mux for user to
select the converter routing, multiple port mapping to same converter
needs to be supported.
To support multiple port mapped to same converter following changes are
done for this:.
o Add port list to pcm, so that multiple ports can be mapped to a PCM.
o Jack reporting in case where multiple port are attached to same PCM.
o Change hdac_hdmi_get_port_from_cvt(), channel_map, remove functions
to parse through all ports mapped to same the PCM.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
To enable stream on a specific port of a MST capable pin, the port
needs to be selected before we configure the pin widget verb.
When port is selected, all the pin widget verb controlling the sink
device operation will be directed to selected port. So add port
selection before configuring the pin widget verb.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
The ELD notification can be received asynchronously from the graphics
side and this may happen just at the moment the sound driver is
initializing and notification will be missed. Similarly at system
resume, the notification is ignored as the ELD and connection states
are updated in anyway at the end of the resume.
So check the jack status in boot/resume by querying the port presence
based on pin caps and report the jack status.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
To support DP MST audio, new pin verbs/params are added. This patch
adds helper functions to do following:
o To set a specific port
o To get the currently selected port
o To get the length of port.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
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>
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>
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>
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>
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>
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>
The issue is the same as "dd9aa335c880 ALSA: hda/realtek - Can't adjust
speaker's volume on a Dell AIO", the output requires to connect to a node
with Amp-out capability.
Applying the same fixup "ALC298_FIXUP_SPK_VOLUME" can fix the issue.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
It seems that newer Intel chipsets have more than 15 I/O streams (total).
This patch forces the separate stream tags, when this hardware is detected
to avoid SDxCTL.STRM field overflow and an unexpected behaviour.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Like for Sunrise Point, the total stream number of Lewisburg's
input and output stream exceeds 15 (GCAP is 0x9701), which will
cause some streams do not work because of the overflow on
SDxCTL.STRM field if using the legacy stream tag allocation method.
Fixes: 5cf92c8b3d ("ALSA: hda - Add Intel Lewisburg device IDs Audio")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The AmigaOne X1000 has a Sigmatel STAC92HD700 attached to the HD Audio
on an ATI SB600. Add the required settings to enable sound.
Signed-off-by: Darren Stevens <darren@stevens-zone.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The FSL SAI can support up to 32 channels using TDM. Report that value so
they can actually be used.
Tested using 8 channels.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
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>
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>
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>
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>
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>
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>
The pclk is necessary for zx2967 I2S controller. the driver
currently doesn't handle it. This is something we need to fix.
In turn, the driver supports zx296718's I2S controller.
By the way, this patch also change the clock name from tx to wclk
to make it clear.
Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
Reviewed-by: Shawn Guo <shawnguo@kernel.org>
Reviewed-by: Jun Nie <jun.nie@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Without this change, the HDMI/DP codec will be recognised as a
generic codec, and there is no sound when playing through this codec.
As suggested by NVidia side, after adding the new ID in the driver,
the sound playing works well.
Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
While unregistering the hdmi-codec, the hdmi device list must be
cleaned up. It avoid kernel page fault when registering again the
hdmi-codec.
Signed-off-by: Vincent Abriou <vincent.abriou@st.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
As the 64-bit Allwinner H5 SoC has the same analog codec part (also the
same digital part) as H3, enable the driver to be built on ARM64
Allwinner platform, so that it can be used on H5.
Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
To handle jack event and configuration of the pin widget for MST
capable pin, this patch adds:
o Flag to identify the pin is MST capable.
o In notify callback(), based on the pipe and port information marks if
the port is mst_capable. In case of non MST, port is defaulted to zero.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
To support MST moved pin to port, this changes the routes based on
port. So change the route in nau88l25_ssm4567 machine.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
To support MST moved pin to port, this changes the routes based on
port. So change the route in nau88l25_max98357a machine.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
To support MST moved pin to port, this changes the routes based on
port. So change the route in bxt_rt298 machine.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
With MST each pin contains several ports to which device can be
connected.
As a preparatory work to support DP MST this patch adds below changes:
1. Defines the port structure and moves all stream related information
like ELD, converter list, chmap to port.
2. Creates ports for each pin based on the max_ports support.
3. Based on Pin-Port combination creates DAPM Mux widget instead of Pin
to allow user to select a converter.
4. Port zero is the default port when pin does not support MST.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
When a sequencer queue is created in snd_seq_queue_alloc(),it adds the
new queue element to the public list before referencing it. Thus the
queue might be deleted before the call of snd_seq_queue_use(), and it
results in the use-after-free error, as spotted by syzkaller.
The fix is to reference the queue object at the right time.
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
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: 182cdf23db ("ALSA: x86: Implement runtime PM")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
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>
While not all line6 devices currently support PCM, it causes no
harm to 'have it prepared'.
This also fixes toneport, which only has PCM - in which case
we previously skipped the USB transfer properties detection completely.
Signed-off-by: Andrej Krutak <dev@andree.sk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This reverts commit f6a0dd107a.
The commit caused a regression on LINE6 Transport that has no control
caps. Although reverting the commit may result back in a spurious
error message for some device again, it's the simplest regression fix,
hence it's taken as is at first. The further code fix will follow
later.
Fixes: f6a0dd107a ("ALSA: line6: Only determine control port properties if needed")
Reported-by: Igor Zinovev <zinigor@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The two front-ends to the codec can now be selected individually, but fail to
build when the bus support is missing:
sound/built-in.o: In function `es8328_spi_probe':
es8328-spi.c:(.text+0x125854): undefined reference to `__devm_regmap_init_spi'
sound/built-in.o: In function `es8328_spi_driver_init':
es8328-spi.c:(.init.text+0x3589): undefined reference to `__spi_register_driver'
Related to this, the added dependency on SND_SOC_ES8328 breaks:
warning: (SND_SOC_ALL_CODECS) selects SND_SOC_ES8328_I2C which has unmet direct dependencies (SOUND && !M68K && !UML && SND && SND_SOC && SND_SOC_ES8328 && I2C)
This adds the respective Kconfig dependencies and changes SND_SOC_ES8328 to a hidden
symbol that is selected implicitly by the two more specific options, as we do for
some other codecs. We have to remove the 'depends on' for SND_SOC_IMX_ES8328 in the
same step to avoid a recursive dependency.
Fixes: aa00f2c8af ("ASoC: Allow to select ES8328_I2C and ES8328_SPI directly")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
snd_seq_pool_done() syncs with closing of all opened threads, but it
aborts the wait loop with a timeout, and proceeds to the release
resource even if not all threads have been closed. The timeout was 5
seconds, and if you run a crazy stuff, it can exceed easily, and may
result in the access of the invalid memory address -- this is what
syzkaller detected in a bug report.
As a fix, let the code graduate from naiveness, simply remove the loop
timeout.
BugLink: http://lkml.kernel.org/r/CACT4Y+YdhDV2H5LLzDTJDVF-qiYHUHhtRaW4rbb4gUhTCQB81w@mail.gmail.com
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
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>
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>
This patch create entry in sysfs file system to report the
platform_id = "pci-id-oem_id-oem_table_id-oem_revision"
for board identification.
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Sodhi, VunnyX <vunnyx.sodhi@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
The driver is used for Rockchip rk3288-based boards using a configurable
analog output (can be an headphone) and the built-in HDMI audio output
that is part of the RK3288 SoCs and use the Alsa HDMI codec driver. For
some rk3288-based boards the analog output and the hdmi audio are plugged
on the same i2s line, so we have to do the same in the driver by using a
DAI link CPU to multicodecs. This configuration can be found for example
on the Radxa Rock2 or the Firefly-RK3288.
This commit is based on the initial work that was done by Sjoerd Simons
<sjoerd.simons@collabora.com> with some improvements.
Signed-off-by: Romain Perier <romain.perier@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Currently, we have to select these symbols explictly via Kconfig, from
another entry. If we plan to use generic audio drivers like
simple-audio-card, the user need to be able to enable these symbols
directly via the menuconfig.
This commit also fixes unmet dependencies to SND_SOC_IMX_ES8328 caused
by these changes.
Signed-off-by: Romain Perier <romain.perier@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Currently, the function that changes the DAI format only supports master
mode. Trying to use a slave mode exits the function with -EINVAL and
leave the codec misconfigured. This commits adds support for enabling
the slave mode.
Signed-off-by: Romain Perier <romain.perier@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
HDMI registers channel map controls per PCM. As PCMs are not
registered during dai_link init callback, store the pcm ids and
codec DAIs during this init callback.
Register for late probe and call the jack_init API which also
registers channel map in the late probe callback handler.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
To support MST moved pin to port, this changes the routes based on
port. So change the route in bxt_da7219_max98357a machine.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
To support MST moved pin to port, this changes the routes based on
port. So change the route in skl_rt286 machine.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
HDMI registers channel map controls per pcm. As PCMs are not
registered during dai_link init callback, store the pcm ids and
codec DAIs during this init callback.
Register for late probe and call the jack_init API which registers
channel map in the late probe callback handler.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Channel info is part of the pcm parameter and channel map control is
created for each pcm. So move channel info to pcm instead of pin
structure and the mutex lock to pcm.
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This is a relict of 6553bf06a3 ("ASoC: Don't try to register debugfs
entries if the parent does not exist").
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Just a minor optimization; check the presence of platform_data earlier
in the probe function before actually starting allocation, which makes
the error path easier.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since the config base offset is now set per pipe id, we don't have to
check Cherry Trail PCI IDs any longer. Currently it's used only for
debug prints. Let's drop it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
Similarly like the previous patch, drop the global variable to keep
the ELD copy. It can be embedded in hdmi_lpe_audio_ctx as well.
And this makes easier to code, it's just a memcpy(), after all.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Now it's the turn to drop the global hlpe_state variable. It can be
gracefully embedded in hdmi_lpe_audio_ctx struct.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
Registering the irq handler at the too early place may cause a system
stall because the irq handler may be triggered before the other
initializations. Move the irq handler registration to the later point.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
The error from hdmi_audio_probe() wasn't handled properly, and it may
leave some resources leaked or mapped. Fix it and also clean up the
error paths.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
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>
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>
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>
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>
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>
Theoretically setting the state to SNDRV_PCM_STATE_DISCONNECTED is
correct. But, unfortunately, PA gets confused by this action, and it
won't re-probe the device after HDMI/DP is re-plugged. (It reprobes
only when the card itself is recreated.)
As a workaround, set SNDRV_PCM_STATE_SETUP instead.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Some SoCs have a reset line that must be asserted/deasserted.
This patch adds a quirk to handle the new compatible
"allwinner,sun6i-a31-i2s" which will deassert the reset
line on probe function and assert it on remove's one.
This new compatible is useful in case of A33 codec driver, for example.
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Add the sun8i audio codec which handles the digital register of
A33 codec.
The driver handles only the basic playback from the DAC to headphones.
All other features (microphone, capture, etc) will be added later.
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
When playing a sound for the first time, a short delay, where the audio
file is not played, can be noticed.
On a second play (right after), the sound is played correctly.
If we wait a short time (~5 sec which corresponds to the aplay
timeout), the delay is back.
This patch fixes it by using an event on headphone amplifier.
It allows to keep the amplifier enable while playing a sound.
A delay of 700ms allows to wait that the amplifier is powered-up
before playing the sound.
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Sync convert rate settings should be availabled *after* Playing.
Thus, src->sync should be reset first of init function.
Otherwise, it will set remaining settings when it start playing.
This patch fixes it. Thanks to Yokoyama-san
Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Missed unused variable in previous changes, oops.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Optional gpio handling should not cause an error status and prevent
probing if it's missing. Remove error return for -ENOENT case and
move error message to dev_info
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
We can get audio errors if hitting deeper idle states on omaps:
[alsa.c:230] error: Fatal problem with alsa output, error -5.
[audio.c:614] error: Error in writing audio (Input/output error?)!
This seems to happen with off mode idle enabled as power for the
whole SoC may get cut off between filling the McBSP fifo using DMA.
While active DMA blocks deeper idle states in hardware, McBSP
activity does not seem to do so.
Basing the QoS latency calculation on the FIFO size, threshold,
sample rate, and channels.
Based on the original patch by Tony Lindgren
Link: https://patchwork.kernel.org/patch/9305867/
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
Tested-by: Tony Lindgren <tony@atomide.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This allows the LPE HDMI driver to clean up its global variable
reference.
Also drop to pass the eld pointer because the connection status and
the ELD bytes can be retrieved from the attached pdata.
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Now the pipe that is being used is passed over i915 notification, we
can re-setup the relevant register offset depending on pipe assignments
during hotplug.
This allows playback on single port machines such Zotac Pi330 or
dual-port machines such as Dell Wyse 3040 box
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
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>
The combination of dev_err() and __func__ make most of these log prints
over 100 chars long. Remove the usage of __func__ to clean the kernel
log and as the usage is not necessary to identify the individual log
prints.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Clean up the clock calling code by removing numerous IS_ERR() checks by
just assigning the clock NULL; as this turn all used functions in the
clk API to nops.
Also include the word "optional" in the error message when failing to acquire
the optional osr clocks.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
We never use the irq2dev[] array so we can remove this assignment.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This macro is unused since commit e369bd006f ("ASoC: wm8741: Allow master
clock switching").
Signed-off-by: Sergej Sawazki <ce3a@gmx.de>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
The snd_soc_card_jack_new function can call snd_soc_jack_add_pins for
you, so pass directly the pins struct when you create the new jack.
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Remove default and set I2S mode correctly both on codec and
cpu sides
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Use ACPI ID 10EC3270 to load machine driver for cht-bsw-rt5645
and add reference to 3270 to use the rt5645 mode
Tested on Asus T100HA
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Some platforms use AIF2, use routing information to set ASRC as needed
Suggested-by: Bard Liao <bardliao@realtek.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=95681
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This driver may be used on Baytrail CR platforms where SSP2 is
not available.
Add quirks and routing detection based on work done for RT5640.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
ALC3270 is a low-cost version of RT5645, add ACPI ID
to enable probe and use rt5645 codec driver
Tested on Asus T100HA
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
the BIOS reports this codec as RT5640 but it's a rt5670. Use the
quirk mechanism to use the cht_bsw_rt5672 machine driver
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Fix classic issue of having multiple codecs listed in DSDT
but a single one actually enabled. The previous code did
not handle such errors and could also lead to uninitalized
configurations
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Use machine driver initially defined for CherryTrail
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
add ACPI ID 10EC5648 found e.g on Asus X205TA and use
rt5645 driver
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
the BIOS incorrectly reports this codec as 5640 but it is
really a rt5670
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
RT5651 is used on some Cherrytrail platforms, add the ACPI
ID in machine table.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=156191
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>