summaryrefslogtreecommitdiff
path: root/sound/x86
AgeCommit message (Collapse)AuthorFilesLines
2017-05-09alsa: use set_memory.h headerLaura Abbott1-1/+1
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>
2017-03-21ALSA: x86: Make CONFIG_SND_X86 boolTakashi Iwai1-1/+2
CONFIG_SND_X86 is a menu config to filter only for x86-specific drivers in its sub-menu, and this doesn't have to be tristate but rather it should be a bool. Also, like other sub-menu configs, it's more user-friendly to be default=y; it's merely a menu config and the actual drivers are configured in the sub-menu, after all. Fixes: 287599cf2d77 ("ALSA: add Intel HDMI LPE audio driver for BYT/CHT-T") Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-22ALSA: x86: hdmi: select CONFIG_SND_PCMArnd Bergmann1-0/+1
The newly added driver uses the PCM helpers and fails to link if they are disabled: sound/built-in.o: In function `hdmi_lpe_audio_runtime_suspend': intel_hdmi_audio.c:(.text+0x15906): undefined reference to `snd_pcm_suspend' sound/built-in.o: In function `had_pcm_hw_params': intel_hdmi_audio.c:(.text+0x15ac7): undefined reference to `snd_pcm_lib_malloc_pages' sound/built-in.o: In function `had_pcm_open': intel_hdmi_audio.c:(.text+0x15d49): undefined reference to `snd_pcm_hw_constraint_integer' This uses a Kconfig 'select' statement to make sure they are enabled. Fixes: 5dab11d89777 ("ALSA: x86: hdmi: Add audio support for BYT and CHT") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-22ALSA: x86: Don't enable runtime PM as defaultTakashi Iwai1-2/+4
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>
2017-02-22ALSA: x86: Use runtime PM autosuspendTakashi Iwai1-4/+18
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>
2017-02-16ALSA: x86: Don't bail out from PCM ops when disconnectedTakashi Iwai1-22/+0
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>
2017-02-16ALSA: x86: Minor code rearrangementTakashi Iwai1-16/+11
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>
2017-02-16ALSA: x86: Stop the stream when buffer is processed after disconnectionTakashi Iwai1-3/+6
This shouldn't happen, but just to be sure... Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-16ALSA: x86: Avoid register accesses during disconnectionTakashi Iwai1-8/+26
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>
2017-02-16ALSA: x86: Don't return an error from chmap ctl at disconnectedTakashi Iwai1-9/+3
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>
2017-02-16ALSA: x86: Fix memory leak in had_build_channel_allocation_map()Takashi Iwai1-6/+5
The previously allocated chmap has to be released before setting the new one. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-16ALSA: x86: Use snd_pcm_stop_xrun() for connection / disconnection pathsTakashi Iwai1-2/+2
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>
2017-02-16ALSA: x86: Implement jack controlTakashi Iwai2-0/+24
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>
2017-02-13ALSA: x86: Drop unused stream.running fieldTakashi Iwai2-10/+2
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>
2017-02-13ALSA: x86: Handle reset at prepare callbackTakashi Iwai2-14/+26
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>
2017-02-10ALSA: x86: Support S16 formatTakashi Iwai1-3/+5
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>
2017-02-10ALSA: x86: Support S32 formatTakashi Iwai1-9/+19
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>
2017-02-10ALSA: x86: Allow no-period-wakeup setupTakashi Iwai1-2/+5
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>
2017-02-10ALSA: x86: Allow single period PCM operationTakashi Iwai2-3/+13
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>
2017-02-10ALSA: x86: Don't pass SNDRV_PCM_INFO_BATCH flagTakashi Iwai1-4/+2
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>
2017-02-07ALSA: x86: Cache AUD_CONFIG register valueTakashi Iwai2-27/+13
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>
2017-02-07ALSA: x86: Rearrange definesTakashi Iwai3-81/+83
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>
2017-02-07ALSA: x86: mark hdmi suspend/resume functions as __maybe_unusedArnd Bergmann1-2/+2
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>
2017-02-07ALSA: x86: Fix driver name string overflowTakashi Iwai2-2/+3
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>
2017-02-07ALSA: x86: Rename had_enable_audio_int() to had_ack_irqs()Takashi Iwai1-14/+7
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>
2017-02-07ALSA: x86: Drop suspicious U24 format supportTakashi Iwai1-2/+1
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>
2017-02-06ALSA: x86: Refactor PCM process engineTakashi Iwai3-354/+231
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>
2017-02-05ALSA: x86: Unify local function prefixTakashi Iwai1-67/+60
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>
2017-02-05ALSA: x86: Minor cleanup of reset buffer procedureTakashi Iwai1-7/+6
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>
2017-02-05ALSA: x86: Don't check connection in lowlevel accessorsTakashi Iwai1-66/+25
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>
2017-02-05ALSA: x86: Explicit specify 32bit DMATakashi Iwai1-2/+6
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>
2017-02-03ALSA: x86: Rename drv_status to connectedTakashi Iwai3-30/+22
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>
2017-02-03ALSA: x86: Yet more tidy-up and clean-upsTakashi Iwai1-32/+36
- 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>
2017-02-03ALSA: x86: Simplify commentsTakashi Iwai1-52/+14
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>
2017-02-03ALSA: x86: Set CA bits for DisplayPort tooTakashi Iwai1-4/+4
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>
2017-02-03ALSA: x86: Create ELD control elementTakashi Iwai1-21/+51
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>
2017-02-03ALSA: x86: Clean up unused defines and inclusionsTakashi Iwai3-69/+20
Many defines and constants are left unused. Clean them up. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Reduce redundant register field namesTakashi Iwai3-169/+90
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>
2017-02-03ALSA: x86: Use the standard ELD bytes definitionsTakashi Iwai3-127/+9
We have some constants defined in drm/drm_edid.h, and clean up our own definitions. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Move stream status into pcm_stream_infoTakashi Iwai3-50/+14
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>
2017-02-03ALSA: x86: Implement runtime PMTakashi Iwai1-77/+50
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>
2017-02-03ALSA: x86: Properly manage PCM substream lifetypeTakashi Iwai2-74/+98
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>
2017-02-03ALSA: x86: Drop unused fields from pcm_stream_infoTakashi Iwai2-21/+1
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>
2017-02-03ALSA: x86: Drop redundant had_stream_pvtTakashi Iwai3-63/+4
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>
2017-02-03ALSA: x86: Drop superfluous state fieldTakashi Iwai3-44/+21
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>
2017-02-03ALSA: x86: Drop flag_underrun fieldTakashi Iwai2-9/+1
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>
2017-02-03ALSA: x86: Fix racy access to chmapTakashi Iwai2-9/+24
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>
2017-02-03ALSA: x86: Remove superfluous irqsave flagsTakashi Iwai1-38/+33
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>
2017-02-03ALSA: x86: Constfy tablesTakashi Iwai1-3/+3
Some tables can be defined as const. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Remove _v[12] sufficesTakashi Iwai3-41/+31
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>