summaryrefslogtreecommitdiff
path: root/sound/x86
AgeCommit message (Collapse)AuthorFilesLines
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>
2017-02-03ALSA: x86: Tidy up codesTakashi Iwai1-89/+59
Clean up codes, fix indentations, correct comments, etc. No functional change. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Drop had_get_hwstate()Takashi Iwai1-28/+14
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>
2017-02-03ALSA: x86: Remove superfluous check at resumeTakashi Iwai1-9/+1
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>
2017-02-03ALSA: x86: Fix sleep-in-atomic via i915 notificationTakashi Iwai1-27/+24
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>
2017-02-03ALSA: x86: Drop superfluous PCM private_freeTakashi Iwai1-12/+0
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>
2017-02-03ALSA: x86: Drop unused fields from snd_intelhad structTakashi Iwai2-22/+6
Also change the flag_underrun to bool to be clearer. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Remove indirect call of snd_pcm_period_elapsed()Takashi Iwai2-11/+7
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>
2017-02-03ALSA: x86: Fix for CONFIG_PM=nTakashi Iwai1-1/+1
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>
2017-02-03ALSA: x86: Replace pr_xxx() with dev_xxx()Takashi Iwai1-121/+84
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>
2017-02-03ALSA: x86: Fold intel_hdmi_audio_if.c into main fileTakashi Iwai4-439/+376
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>
2017-02-03ALSA: x86: Flatten two abstraction layersTakashi Iwai6-771/+358
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>
2017-02-03ALSA: x86: Drop unused hdmi_audio_query()Takashi Iwai2-55/+0
It's used nowhere. Kill it. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Call snd_card_register() at the endTakashi Iwai1-5/+5
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>
2017-02-03ALSA: x86: Check platform_data earlierTakashi Iwai1-8/+6
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>
2017-02-03ALSA: x86: Drop superfluous CHT PCI ID checkTakashi Iwai1-14/+0
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>
2017-02-03ALSA: x86: Embed snd_intelhad into snd_cardTakashi Iwai3-82/+31
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>
2017-02-03ALSA: x86: Move dma_mask debug print into intel_hdmi_lpe_audio.cTakashi Iwai2-11/+1
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>
2017-02-03ALSA: x86: Drop unused hw_silence fieldTakashi Iwai2-3/+0
It's nowhere used. Let's drop it. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Move the global underrun_count to struct snd_intelhadTakashi Iwai2-8/+9
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>
2017-02-03ALSA: x86: Drop global ELD copyTakashi Iwai1-26/+5
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>
2017-02-03ALSA: x86: Drop global hlpe_stateTakashi Iwai1-12/+9
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>
2017-02-03ALSA: x86: Drop the global platform device referenceTakashi Iwai3-91/+87
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>
2017-02-03ALSA: x86: Drop unused mid_hdmi_audio_is_busy()Takashi Iwai2-24/+0
The function is nowhere used. Kill it. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03ALSA: x86: Fix possible stale interrupt callsTakashi Iwai1-13/+13
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>
2017-02-03ALSA: x86: Call event callback directlyTakashi Iwai4-35/+1
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>