summaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_controller.c
Commit message (Collapse)AuthorAgeFilesLines
* ALSA: constify snd_pcm_ops structuresJulia Lawall2016-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check for snd_pcm_ops structures that are only stored in the ops field of a snd_soc_platform_driver structure or passed as the third argument to snd_pcm_set_ops. The corresponding field or parameter is declared const, so snd_pcm_ops structures that have this property can be declared as const also. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r disable optional_qualifier@ identifier i; position p; @@ static struct snd_pcm_ops i@p = { ... }; @ok1@ identifier r.i; struct snd_soc_platform_driver e; position p; @@ e.ops = &i@p; @ok2@ identifier r.i; expression e1, e2; position p; @@ snd_pcm_set_ops(e1, e2, &i@p) @bad@ position p != {r.p,ok1.p,ok2.p}; identifier r.i; struct snd_pcm_ops e; @@ e@i@p @depends on !bad disable optional_qualifier@ identifier r.i; @@ static +const struct snd_pcm_ops i = { ... }; // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA - hda: Add support for link audio time reportingGuneshwor Singh2016-08-091-1/+197
| | | | | | | | | | The HDA controller from SKL onwards support additional timestamp reporting of the link time. The link time is read from HW registers and converted to audio values. Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com> Signed-off-by: Hardik T Shah <hardik.t.shah@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA - hda: Add support for parsing new HDA capabilitiesGuneshwor Singh2016-08-091-0/+5
| | | | | | | | | | | Skylake onwards HDA controller supports new capabilities like Global Time Stamping (GTS) capability. So add support to parse these new capabilities. Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com> Signed-off-by: Hardik T Shah <hardik.t.shah@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Loop interrupt handling until really clearedTakashi Iwai2016-02-261-21/+26
| | | | | | | | | | | | | | | | | | | | | Currently the interrupt handler of HD-audio driver assumes that no irq update is needed while processing the irq. But in reality, it has been confirmed that the HW irq is issued even during the irq handling. Since we clear the irq status at the beginning, process the interrupt, then exits from the handler, the lately issued interrupt is left untouched without being properly processed. This patch changes the interrupt handler code to loop over the check-and-process. The handler tries repeatedly as long as the IRQ status are turned on, and either stream or CORB/RIRB is handled. For checking the stream handling, snd_hdac_bus_handle_stream_irq() returns a value indicating the stream indices bits. Other than that, the change is only in the irq handler itself. Reported-by: Libin Yang <libin.yang@linux.intel.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Raise AZX_DCAPS_RIRB_DELAY handling into top driversTakashi Iwai2015-12-171-5/+0
| | | | | | | | | | AZX_DCAPS_RIRB_DELAY is dedicated only for Nvidia and its purpose is just to set a flag in bus. So it's better to be set in the toplevel driver, either hda_intel.c or hda_tegra.c, instead of the common hda_controller.c. This also allows us to strip this flag from dcaps, so save one more bit there. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Merge RIRB_PRE_DELAY into CTX_WORKAROUND capsTakashi Iwai2015-12-171-1/+1
| | | | | | | | AZX_DCAPS_RIRB_PRE_DELAY is always tied with AZX_DCAPS_CTX_WORKAROUND, which is Creative's XFi specific. So, we can replace it and reduce one more bit free for DCAPS. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Clean up the code to check bdl_pos_adj optionTakashi Iwai2015-12-151-2/+1
| | | | | | | | | Just a minor cleanup; instead of passing an array, pass the assigned bdl_pos_adj option value directory in struct azx. Also split the code to get the default bdl_pos_adj value for the change that will follow after this. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Fix lost 4k BDL boundary workaroundTakashi Iwai2015-11-021-0/+3
| | | | | | | | | | | | | | During the migration to HDA core code, we lost the workaround for 4k BDL boundary. The flag exists in the new hdac_bus, but it's never set. This resulted in the sudden sound stall on some controllers that require this workaround like Creative Recon3D. This patch fixes the issue by setting the flag for such controllers properly. Fixes: ccc98865aa44 ('ALSA: hda - Migrate more hdac_stream codes') Cc: <stable@vger.kernel.org> # v4.2+ Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Fix bogus codec address check for mixer name assignmentTakashi Iwai2015-10-171-0/+1
| | | | | | | | | | | | | The recent commit [7fbe824a0f0e: ALSA: hda - Update mixer name for the lower codec address] tried to improve the mixer chip name assignment in the order of codec address. However, this fix was utterly bogus; it checks the field set in each codec, thus this value is reset at each codec creation, of course. For really handling this priority, the assignment has to be remembered in the common place, namely in hda_bus, instead of hda_codec. Fixes: 7fbe824a0f0e ('ALSA: hda - Update mixer name for the lower codec address') Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - rename hda_intel_trace.h to hda_controller_trace.hLibin Yang2015-05-181-1/+5
| | | | | | | | | | | | This patch does: 1. Rename the hda_intel_trace.h to hda_controller_trace.h as this trace is used in hda_controller.c 2. Add some trace function for pcm flow. Signed-off-by: Libin Yang <libin.yang@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - implement link_power ops for i915 display power controlMengdong Lin2015-04-291-0/+11
| | | | | | | | | This patch implements the bus link_power ops to request/release i915 display power well. It can be used by the display codec which shares this power well with GPU on Intel platforms. Signed-off-by: Mengdong Lin <mengdong.lin@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Replace open codes with snd_hdac_stream_set_params()Takashi Iwai2015-04-181-19/+4
| | | | Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Move prepared flag into struct hdac_streamTakashi Iwai2015-04-171-4/+4
| | | | | | This flag seems used commonly, so deserves to be located there. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Replace hda_bus_ops with static bindingTakashi Iwai2015-04-161-25/+17
| | | | | | | | | | | | | Originally hda_bus takes its own ops (hda_bus_ops) to allow different controller drivers giving individual implementations of PCM attachment, etc. But this never happened and we finally merged both codec and controller helper codes. Thus there is no merit to keep the indirect accesses to functions via hda_bus_ops. This patch replaces these calls with the direct local function calls for simplification. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Reenable tracepoints for controllerTakashi Iwai2015-04-161-0/+6
| | | | | | | After correcting the fields to point the right members, tracepoints can be reenabled again for the legacy controller code. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Move PCM format and rate handling code to core libraryTakashi Iwai2015-04-161-2/+1
| | | | Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Minor refactoringTakashi Iwai2015-04-161-3/+7
| | | | | | | Move the small portion of the common sequence in hda_intel.c and hda_tegra.c into hda_controller.c. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Embed bus into controller objectTakashi Iwai2015-04-161-454/+107
| | | | | | | | | | | | | | | ... and replace with the existing hda-core helper codes. This reduces lots of lines, finally. Since struct hda_bus is now embedded into struct azx, snd_hda_bus_new() is moved and expanded from hda_codec.c to hda_controller.c, accordingly. Also private_free bus ops and private_data field are removed because we no longer need to point azx object from bus (we can use container_of()) The spin locks are consolidated into the single one, bus->reg_lock. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Migrate more hdac_stream codesTakashi Iwai2015-04-161-379/+49
| | | | | | ... including dsp loader helpers. Lots of codes removed. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Migrate hdac_stream into legacy driverTakashi Iwai2015-04-161-259/+156
| | | | | | | | | | | Embed hdac_stream object into azx_dev, and use a few basic helper functions. The most of helper codes for hdac_stream aren't still used yet. Also this commit disables the tracepoints temporarily due to build problems. It'll be enabled again later. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Pass bus io_ops directly from the top-level driverTakashi Iwai2015-04-161-13/+13
| | | | | | | | | One less redirection again. This also requires the change of the call order in the toplevel divers. Namely, the bus has to be created at first before other initializations since the memory allocation ops are called through bus object now. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Move send_cmd / get_response to hdac_bus_opsTakashi Iwai2015-04-161-9/+15
| | | | | | One less redirection. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Merge codec and controller helpersTakashi Iwai2015-04-161-3/+0
| | | | | | | | | | | | There is no much merit to keep the HD-audio codec and controller helper codes in separate modules any longer. Let's merge them into a single helper module. This patch just changes Makefile entries to merge two individual modules to one. The only code change is the removal of superfluous MODULE_*() macros in one side. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Handle error from get_response bus ops directlyTakashi Iwai2015-04-141-23/+24
| | | | | | | | | ... and drop bus->rirb_error flag. This makes the code simpler. We treat -EAGAIN from get_response ops as a special meaning: it allows the caller to retry after bus reset. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda - Move some codes up to hdac_bus structTakashi Iwai2015-03-231-4/+4
| | | | | | | | | | | | A few basic codes for communicating over HD-audio bus are moved to struct hdac_bus now. It has only command and get_response ops in addition to the unsolicited event handling. Note that the codec-side tracing support is disabled temporarily during this transition due to the code shuffling. It will be re-enabled later once when all pieces are settled down. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* Merge branch 'topic/hda-unbind' into for-nextTakashi Iwai2015-03-161-52/+27
|\
| * ALSA: hda - Use shutdown driver ops instead of reboot notifierTakashi Iwai2015-03-131-26/+0
| | | | | | | | | | | | | | | | | | The driver shutdown ops is simpler than registering reboot notifier manually. There should be no functional change by this -- the codec driver calls its own callback while the bus driver just calls azx_stop() like before. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Implement unbind more safelyTakashi Iwai2015-03-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Now we have all pieces ready, and put them into places: - add the hda_pcm refcount to azx_pcm_open() and azx_pcm_close(), - call the most of cleanup code in hda_codec_reset() from the codec driver remove, - call the same code also from the hda_codec object free. Then the codec driver can be unbound more safely now. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Don't assume non-NULL PCM opsTakashi Iwai2015-03-031-11/+19
| | | | | | | | | | | | | | The PCM ops might be set NULL, or cleared to NULL when the driver is unbound. Give a proper NULL check at each place to be more robust. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Remove superfluous memory allocation error messagesTakashi Iwai2015-03-031-14/+4
| | | | | | | | | | | | | | The memory allocators should have already given the kernel warning messages, thus we don't have to annoy again. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Add card field to hda_codec structTakashi Iwai2015-03-031-1/+1
| | | | | | | | | | | | | | | | Allow the codec object to have an individual card pointer. Not only this simplifies the redirections in many places, also this will allow us to make each codec assigned to a different card object. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | Merge branch 'topic/hda-bus' into for-nextTakashi Iwai2015-03-161-43/+19
|\|
| * ALSA: hda - Clear pcm pointer assigned to hda_pcm at device removalTakashi Iwai2015-02-261-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We leave the pcm field of struct hda_pcm at removal of each device, so far. This hasn't been a problem since unbinding the codec driver isn't supposed to happen and another route via snd_hda_codec_reset() clears all the once. However, for a proper unbind implementation, we need to care about it. This patch does the thing above properly: - Include struct hda_pcm pointer instead of struct hda_pcm_stream pointers in struct azx_dev. This allows us to point the hda_pcm object at dev_free callback. - Introduce to_hda_pcm_stream() macro for better readability. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Replace bus pm_notify with the standard runtime PM frameworkTakashi Iwai2015-02-261-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now the final bit of runtime PM cleanup: instead of manual notification of the power up/down of the codec via hda_bus pm_notify ops, use the standard runtime PM feature. The child codec device will kick off the runtime PM of the parent (PCI) device upon suspend/resume automatically. For managing whether the link can be really turned off, we use the bit flags bus->codec_powered instead of the earlier bus->power_keep_link_on. flag. Each codec driver is responsible to set/clear the bit flag, and the controller device can be turned off only when all these bits are cleared. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Drop power_save value indirection in hda_busTakashi Iwai2015-02-261-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We used to pass the power_save option value to hda_bus via a given pointer. This was needed to refer to the value from the HD-audio core side. However, after the transition to the runtime PM, this is no longer needed. This patch drops the power_save value indirection in hda_bus above, and let the controller driver reprograms the autosuspend value explicitly by a new helper, snd_hda_set_power_save(). Without this call, the HD-audio core doesn't set up the autosuspend and flip the runtime PM. (User may still be able to set up via sysfs, though.) Along with this change, the pointer argument of azx_bus_create() is dropped as well. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Use standard runtime PM for codec power-save controlTakashi Iwai2015-02-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like the previous transition of suspend/resume, now move the power-save code to the standard runtime PM. As usual for runtime PM, it's a bit tricky, but this simplified codes a lot in the end. For keeping the usage compatibility, power_save module option still controls the whole power-saving behavior on all codecs. The value is translated to pm_runtime_*_autosuspend() and pm_runtime_allow() / pm_runtime_forbid() calls. snd_hda_power_up() and snd_hda_power_down() are translated to pm_runtime_get_sync() and pm_runtime_put_autosuspend(), respectively. Since we can do call pm_runtime_get_sync() more reliably, the sync version is used always and snd_hda_power_up_d3wait() is dropped. Another slight difference is that snd_hda_power_up()/down() don't call runtime_pm code during the suspend/resume transition phase. Calling them there isn't safe unlike our own code, resulted in unexpected behavior (endless wakeups). The hda_power_count tracepoint was removed, as it doesn't match well with the new code. Last but not least, we need to set ignore_children flag in the parent dev.power field so that the runtime PM of the controller chip won't get confused. The notification is still done in the bus pm_notify callback. We'll get rid of this hack in the later patch. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Move codec suspend/resume to codec driverTakashi Iwai2015-02-231-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch moves the suspend/resume mechanisms down to each codec driver level, as we have a proper codec driver bound on the bus now. Then we get the asynchronous PM gratis without fiddling much in the driver level. As a soft-landing transition, implement the common suspend/resume pm ops for hda_codec_driver and keep the each codec driver intact. Only the callers of suspend/resume in the controller side (azx_suspend() and azx_resume()) are removed. Another involved place is azx_bus_reset() calling the temporary suspend and resume as a hackish method of bus reset. The HD-audio core provide a helper function snd_hda_bus_reset() instead. Signed-off-by: Takashi Iwai <tiwai@suse.de>
| * ALSA: hda - Decouple PCM and hwdep devices from codec objectTakashi Iwai2015-02-231-3/+0
| | | | | | | | | | | | | | | | | | This is a preliminary patch for the hda_bus implementation, removing the parent device setup to codec device. Since the bus and the class devices can't be crossed over, leave the sound devices to the default parent device as is. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | Merge branch 'for-linus' into for-nextTakashi Iwai2015-03-091-1/+1
|\ \ | | | | | | | | | | | | Merging the HD-audio fixes back to base devel branch for further working on it.
| * | ALSA: hda - Fix regression of HD-audio controller fallback modesTakashi Iwai2015-03-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit [63e51fd708f5: ALSA: hda - Don't take unresponsive D3 transition too serious] introduced a conditional fallback behavior to the HD-audio controller depending on the flag set. However, it introduced a silly bug, too, that the flag was evaluated in a reverse way. This resulted in a regression of HD-audio controller driver where it can't go to the fallback mode at communication errors. Unfortunately (or fortunately?) this didn't come up until recently because the affected code path is an error handling that happens only on an unstable hardware chip. Most of recent chips work stably, thus they didn't hit this problem. Now, we've got a regression report with a VIA chip, and this seems indeed requiring the fallback to the polling mode, and finally the bug was revealed. The fix is a oneliner to remove the wrong logical NOT in the check. (Lesson learned - be careful about double negation.) The bug should be backported to stable, but the patch won't be applicable to 3.13 or earlier because of the code splits. The stable fix patches for earlier kernels will be posted later manually. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=94021 Fixes: 63e51fd708f5 ('ALSA: hda - Don't take unresponsive D3 transition too serious') Cc: <stable@vger.kernel.org> # v3.14+ Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | | Merge tag 'asoc-v4.1' of ↵Takashi Iwai2015-03-061-5/+0
|\| | | |/ |/| | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next ASoC: Changes for v4.1 A selection of changes for v4.1 so far. The main things are: - Move of jack registration to the card where it belongs. - Support for DAPM routes specified by both the machine driver and DT.
| * ALSA: hda: controller code - do not export static functionsJaroslav Kysela2015-02-241-5/+0
| | | | | | | | | | | | | | | | | | | | | | It is a bad idea to export static functions. GCC for some platforms shows errors like: error: __ksymtab_azx_get_response causes a section type conflict Signed-off-by: Jaroslav Kysela <perex@perex.cz> Cc: <stable@vger.kernel.org> # v3.15+ Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | Merge branch 'topic/timestamp' into for-nextTakashi Iwai2015-02-231-11/+29
|\ \
| * | ALSA: hda: replace .wallclock by .get_time_infoPierre-Louis Bossart2015-02-201-11/+29
| |/ | | | | | | | | | | | | | | No real functional change, only take wall clock and system time in same routine and add accuracy report. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | ALSA: hda - Split azx_codec_create() to two phasesTakashi Iwai2015-02-191-16/+24
| | | | | | | | | | | | | | | | azx_create_codec() function does actually two things: create a bus and probe codecs. For the future work, split this to two logical functions, azx_bus_create() and azx_probe_codecs(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | ALSA: hda - Drop azx_mixer_create()Takashi Iwai2015-02-191-7/+0
| | | | | | | | | | | | | | It's just an indirection, so let the caller directly calling snd_hda_build_controls(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | ALSA: hda - Fold hda_priv.h into hda_controller.hTakashi Iwai2015-02-191-1/+0
| | | | | | | | | | | | There is no big reason to keep them separately. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | ALSA: hda - Introduce azx_has_pm_runtime() macroTakashi Iwai2015-02-191-2/+2
| | | | | | | | | | | | | | | | For making the debugging of runtime PM easier, introduce azx_has_pm_runtime() and use it in all places checking the runtime pm driver capability. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* | ALSA: hda - Drop hda_bus_template for snd_hda_bus_new()Takashi Iwai2015-02-171-24/+30
|/ | | | | | | Instead of copying from the given template, let the caller fills the fields after creation. This simplifies the code after all. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ALSA: hda: read trigger_timestamp immediately after starting DMAPierre-Louis Bossart2015-02-091-0/+3
| | | | | | | | Make sure wallclock counter and trigger timestamp are read very close to each other for better alignment. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>