aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/mixer.c (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2020-01-03ALSA: pci: Constify snd_device_ops definitionsTakashi Iwai44-45/+45
Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-10-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: hda: Constify snd_device_ops definitionsTakashi Iwai4-4/+4
Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-9-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: isa: Constify snd_device_ops definitionsTakashi Iwai8-8/+8
Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-8-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: i2c: Constify snd_device_ops definitionsTakashi Iwai4-4/+4
Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-7-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: drivers: Constify snd_device_ops definitionsTakashi Iwai5-5/+5
Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-6-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: core: Constify snd_device_ops definitionsTakashi Iwai8-9/+9
Now we may declare const for snd_device_ops definitions, so let's do it for optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-5-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: core: Treat snd_device_ops as constTakashi Iwai2-3/+3
This is a preliminary patch to allow const for snd_device_ops definitions in each driver's code. The ops reference is read-only, hence it can be declared as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: usb: Constify snd_pcm_hardware definitionsTakashi Iwai3-3/+3
Most of snd_pcm_hardware definitions are just copied to another object as-is, hence we can define them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-03ALSA: pci: Constify snd_pcm_hardware definitionsTakashi Iwai17-23/+23
Most of snd_pcm_hardware definitions are just copied to another object as-is, hence we can define them as const for further optimization. There should be no functional changes by this patch. Link: https://lore.kernel.org/r/20200103081714.9560-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-01ALSA: hda: constify copied structureJulia Lawall1-1/+1
The azx_pcm_hw structure is only copied into another structure, so make it const. The opportunity for this change was found using Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Link: https://lore.kernel.org/r/1577864614-5543-3-git-send-email-Julia.Lawall@inria.fr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-01-01ALSA: ad1816a: constify copied structureJulia Lawall1-1/+1
The snd_ad1816a_timer_table structure is only copied into another structure, so make it const. The opportunity for this change was found using Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Link: https://lore.kernel.org/r/1577864614-5543-2-git-send-email-Julia.Lawall@inria.fr Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-30ALSA: uapi: Add linux/types.h include back (but carefully)Takashi Iwai3-0/+12
A few uapi/sound/*.h headers have been corrected for recovering from the compile errors with the existing user-space code (alsa-lib) by the recent commits. OTOH, these introduced another regression, as now linux/types.h inclusion became mandatory for the uapi header checks. As a compromise, this patch re-adds linux/types.h inclusions again, but conditionally not to break other non-standard user-space stuff again. Fixes: 2e4688676392 ("ALSA: emu10k1: Make uapi/emu10k1.h compilable again") Fixes: d63e63d42107 ("ALSA: hdsp: Make uapi/hdsp.h compilable again") Fixes: 4fa406caf950 ("ALSA: hdspm: Drop linux/types.h inclusion in uapi header") Reported-by: kbuild test robot <lkp@intel.com> Link: https://lore.kernel.org/r/20191230212742.28925-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-28ALSA: usb-audio: fix Corsair Virtuoso mixer label collisionChris Boyle1-0/+20
The Corsair Virtuoso RGB Wireless is a USB headset with a mic and a sidetone feature. Label its mixer appropriately instead of all "Headset", so that applications such as Pulseaudio don't just move the sidetone control when they intend the main Headset control. Signed-off-by: Chris Boyle <chris@boyle.name> Link: https://lore.kernel.org/r/20191227094053.GA12167@nova.chris.boyle.name Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-26ALSA: control: Fix incompatible protocol errorTakashi Iwai1-1/+1
The recent change to bump the ALSA control API protocol version from 2.0.7 to 2.1.0 caused a regression on user-space; while the user-space expects both the major and the minor versions to be identical with the supported numbers, we changed the minor number from 0 to 1. For recovering from the incompatibility, this patch changes the protocol version again to 2.0.8, which is compatible, but yet higher than the original number 2.0.7, indicating that the protocol change. Fixes: bd3eb4e87eb3 ("ALSA: ctl: bump protocol version up to v2.1.0") Reported-by: Paul Menzel <pmenzel@molgen.mpg.de> Tested-by: Paul Menzel <pmenzel@molgen.mpg.de> Link: https://lore.kernel.org/r/s5h1rsr769i.wl-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-24ALSA: ctl: allow TLV read operation for callback type of element in locked caseTakashi Sakamoto1-2/+3
A design of ALSA control core allows applications to execute three operations for TLV feature; read, write and command. Furthermore, it allows driver developers to process the operations by two ways; allocated array or callback function. In the former, read operation is just allowed, thus developers uses the latter when device driver supports variety of models or the target model is expected to dynamically change information stored in TLV container. The core also allows applications to lock any element so that the other applications can't perform write operation to the element for element value and TLV information. When the element is locked, write and command operation for TLV information are prohibited as well as element value. Any read operation should be allowed in the case. At present, when an element has callback function for TLV information, TLV read operation returns EPERM if the element is locked. On the other hand, the read operation is success when an element has allocated array for TLV information. In both cases, read operation is success for element value expectedly. This commit fixes the bug. This change can be backported to v4.14 kernel or later. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Reviewed-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20191223093347.15279-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-23ALSA: ctl: bump protocol version up to v2.1.0Takashi Sakamoto1-1/+1
In a development period for v5.6 kernel, some changes are introduced to structures in ALSA control interface: - 'tstamp' member is removed from 'struct snd_ctl_elem_value - 'TSTAMP' flag is removed from a set of access flags for 'struct snd_ctl_elem_info' - 'dimen' member is removed from 'struct snd_ctl_elem_info Although these changes were introduced with enough consideration for backward compatibility, they include slightly lose of it. This commit bumps protocol version of ALSA control interface up to v2.1.0. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20191223023921.8151-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-23ALSA: ctl: remove dimen member from elem_info structureTakashi Sakamoto2-37/+1
The 'dimen' member of 'struct snd_ctl_elem_info' is designed to deliver information to use an array of value as multi-dimensional values. This feature is used just by echoaudio PCI driver, and fortunately it's not used by the other applications than 'echomixer' in alsa-tools. In a previous commit, usage of 'dimen' member is removed from echoaudio PCI driver. Nowadays no driver/application use the feature. This commit removes the member from structure. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20191223023921.8151-4-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-23ALSA: pci: echoaudio: remove usage of dimen menber of elem_value structureTakashi Sakamoto1-11/+0
In a couple of years ago, 'echomixer' userspace application was revised not to use 'dimen' member of 'struct snd_ctl_elem_info'. This commit removes usage of 'dimen' member from echoaudio PCI driver so that no implementation uses the member. Reference: 275353bb684e ("ALSA: echoaudio: purge contradictions between dimension matrix members and total number of members") Reference: 51db452df07b ("Revert "ALSA: echoaudio: purge contradictions between dimension matrix members and total number of members") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20191223023921.8151-3-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-23ALSA: ctl: remove unused macro for timestamping of elem_valueTakashi Sakamoto1-1/+1
In a former commit, 'tstamp' member was removed from 'struct snd_ctl_elem_value' in a middle way toward solution of Y2038 issue. In a protocol of ALSA control interface, this member is designed to deliver timestamp information in the value structure when the target element supports SNDRV_CTL_ELEM_ACCESS_TIMESTAMP flag. Actually, the feature is neither used by kernel space nor user space, especiall alsa-lib has no API for the feature. Therefore it's reasonable to remove both of them. Practically, the timestamp information corresponds to no information about type of clock ID. It can bring confusions to applications. Reference: a4e7dd35b9da ("ALSA: Avoid using timespec for struct snd_ctl_elem_value") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20191223023921.8151-2-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-20ALSA: uapi: Drop unneeded typedefsTakashi Iwai3-27/+0
We kept some typedefs in uapi/sound/*.h so that the programs in alsa-tools can be built. Now that alsa-lib takes these and applies the workarounds in its own, we don't need these typedefs any longer in the kernel uapi side. Let's drop them. Link: https://lore.kernel.org/r/20191220161555.20232-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-20ALSA: uapi: Drop asound.h inclusion from asoc.hTakashi Iwai1-1/+0
The asound.h isn't always available while asoc.h itself is distributed in alsa-lib package. So we need to avoid the unnecessary inclusion of asound.h from there. Link: https://lore.kernel.org/r/20191220153415.2740-6-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-20ALSA: uapi: Fix typos and header inclusion in asound.hTakashi Iwai1-3/+3
The recent changes in uapi/asoundlib.h caused some build errors in alsa-lib side because of a typo and the new included files. Basically asound.h is supposed to be usable also on non-Linux systems, so we've tried to avoid the Linux-specific include files. This patch is an attempt to recover from those changes. Fixes: 3ddee7f88aaf ("ALSA: Avoid using timespec for struct snd_pcm_status") Fixes: 80fe7430c708 ("ALSA: add new 32-bit layout for snd_pcm_mmap_status/control") Link: https://lore.kernel.org/r/20191220153415.2740-5-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-20ALSA: hdspm: Drop linux/types.h inclusion in uapi headerTakashi Iwai1-2/+0
The hdspm.h uapi header has been used also from non-Linux or platforms that don't have linux/*.h. It was OK in the past because alsa-lib contained the modified version of this header file, but now it tries to the verbatim copy, so it broke the build. This fixes it again. Link: https://lore.kernel.org/r/20191220153415.2740-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-20ALSA: hdsp: Make uapi/hdsp.h compilable againTakashi Iwai2-4/+2
Recently alsa-lib updated its content of sound/hdsp.h just by copying the latest Linus kernel uapi/*.h, and this broke the build of alsa-tools programs. We used to modify the headers so that they can be built without asoundlib.h and linux kernel headers, and the verbatim copy doesn't work as is. This patch removes again the linux/types.h inclusion and drop __user prefix that broke the build and adjusts the corresponding code. Link: https://lore.kernel.org/r/20191220153415.2740-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-20ALSA: emu10k1: Make uapi/emu10k1.h compilable againTakashi Iwai2-24/+40
Recently we updated the content in alsa-lib uapi header files by just copying from the latest Linus kernel uapi/*.h, and noticed that it broke the build of some alsa-tools programs. The reason is that we used to have a modified version in the past, so that the program can be built without referring to the unexported stuff like snd_ctl_elem_id or __user prefix. This patch attempts to restore that, i.e. dropping the stuff that can't be referred in the user-space. For adapting the changes in uapi/emu10k1.h, the emu10k1 driver code is also slightly modified. Most of changes are pointer cast. Link: https://lore.kernel.org/r/20191220153415.2740-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-18ALSA: usb-audio: set the interface format after resume on Dell WD19Hui Wang5-4/+35
Recently we found the headset-mic on the Dell Dock WD19 doesn't work anymore after s3 (s2i or deep), this problem could be workarounded by closing (pcm_close) the app and then reopening (pcm_open) the app, so this bug is not easy to be detected by users. When problem happens, retire_capture_urb() could still be called periodically, but the size of captured data is always 0, it could be a firmware bug on the dock. Anyway I found after resuming, the snd_usb_pcm_prepare() will be called, and if we forcibly run set_format() to set the interface and its endpoint, the capture size will be normal again. This problem and workaound also apply to playback. To fix it in the kernel, add a quirk to let set_format() run forcibly once after resume. Signed-off-by: Hui Wang <hui.wang@canonical.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20191218132650.6303-1-hui.wang@canonical.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-18ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_statusNathan Chancellor1-1/+1
Clang warns: ../sound/usb/usx2y/usX2Yhwdep.c:122:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation] info->version = USX2Y_DRIVER_VERSION; ^ ../sound/usb/usx2y/usX2Yhwdep.c:120:2: note: previous statement is here if (us428->chip_status & USX2Y_STAT_CHIP_INIT) ^ 1 warning generated. This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns. This was introduced before the beginning of git history so no fixes tag. Link: https://github.com/ClangBuiltLinux/linux/issues/831 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Link: https://lore.kernel.org/r/20191218034257.54535-1-natechancellor@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-17ALSA: cmipci: Allow disabling MPU port via module optionTakashi Iwai2-3/+5
Patrick May reported that his sound card with CMI8378 chip causes a crash / reboot when accessing the MIDI port that isn't actually present on the board. Moreover, despite of the documentation, passing mpu_port=0 doesn't disable the MIDI port on this board. It implies that the chip is a newer revision and the MPU401 port is integrated and mapped on the PCI register. For this chip model, the driver enables the MPU port unconditionally, so far. Although fixing the unexpected reboot would be the best solution, it's not so trivial to identify the cause. So, as a plan B, this patch extends the existing mpu_port option usage to allow disabling the port by specifying the value 0, just like we applied for fm_port option in commit 2f24d159d5ac ("[ALSA] cmipci - Allow to disable integrated FM port"). As default, the MPU port is still enabled, but user can pass mpu_port=0 to disable it. Reported-and-tested-by: Patrick May <dusthillresident@gmail.com> Link: https://lore.kernel.org/r/20191217081448.1144-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-16ALSA: hda - Downgrade error message for single-cmd fallbackTakashi Iwai1-1/+1
We made the error message for the CORB/RIRB communication clearer by upgrading to dev_WARN() so that user can notice better. But this struck us like a boomerang: now it caught syzbot and reported back as a fatal issue although it's not really any too serious bug that worth for stopping the whole system. OK, OK, let's be softy, downgrade it to the standard dev_err() again. Fixes: dd65f7e19c69 ("ALSA: hda - Show the fatal CORB/RIRB error more clearly") Reported-by: syzbot+b3028ac3933f5c466389@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/20191216151224.30013-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-16ASoC: wm8962: fix lambda valueShengjiu Wang1-2/+2
According to user manual, it is required that FLL_LAMBDA > 0 in all cases (Integer and Franctional modes). Fixes: 9a76f1ff6e29 ("ASoC: Add initial WM8962 CODEC driver") Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/1576065442-19763-1-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-12-14ALSA: hda: Comment about snd_hdac_bus_update_rirb() and spinlockTakashi Iwai1-0/+1
The call of snd_hdac_bus_update_rirb() needs the bus->reg_lock spinlock protection for concurrency. Comment about it more explicitly. Link: https://lore.kernel.org/r/20191213163005.19116-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-14ALSA: hda: Fix regression by strip mask fixTakashi Iwai2-3/+3
The commit e38e486d66e2 ("ALSA: hda: Modify stream stripe mask only when needed") tried to address the regression by the unconditional application of the stripe mask, but this caused yet another regression for the previously working devices. Namely, the patch clears the azx_dev->stripe flag at snd_hdac_stream_clear(), but this may be called multiple times before restarting the stream, so this ended up with clearance of the flag for the whole time. This patch fixes the regression by moving the azx_dev->stripe flag clearance at the counter-part, the close callback of HDMI codec driver instead. Fixes: e38e486d66e2 ("ALSA: hda: Modify stream stripe mask only when needed") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205855 BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204477 Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20191214175217.31852-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-14ALSA: hda/ca0132 - Fix work handling in delayed HP detectionTakashi Iwai1-2/+14
CA0132 has the delayed HP jack detection code that is invoked from the unsol handler, but it does a few weird things: it contains the cancel of a work inside the work handler, and yet it misses the cancel-sync call at (runtime-)suspend. This patch addresses those issues. Fixes: 15c2b3cc09a3 ("ALSA: hda/ca0132 - Fix possible workqueue stall") Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20191213085111.22855-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-14ALSA: hda/ca0132 - Avoid endless loopTakashi Iwai1-2/+3
Introduce a timeout to dspio_clear_response_queue() so that it won't be caught in an endless loop even if the hardware doesn't respond properly. Fixes: a73d511c4867 ("ALSA: hda/ca0132: Add unsol handler for DSP and jack detection") Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20191213085111.22855-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-14ALSA: hda/ca0132 - Keep power on during processing DSP responseTakashi Iwai1-0/+2
We need to keep power on while processing the DSP response via unsol event. Each snd_hda_codec_read() call does the power management, so it should work normally, but still it's safer to keep the power up for the whole function. Fixes: a73d511c4867 ("ALSA: hda/ca0132: Add unsol handler for DSP and jack detection") Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20191213085111.22855-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-14ALSA: pcm: Avoid possible info leaks from PCM stream buffersTakashi Iwai1-0/+4
The current PCM code doesn't initialize explicitly the buffers allocated for PCM streams, hence it might leak some uninitialized kernel data or previous stream contents by mmapping or reading the buffer before actually starting the stream. Since this is a common problem, this patch simply adds the clearance of the buffer data at hw_params callback. Although this does only zero-clear no matter which format is used, which doesn't mean the silence for some formats, but it should be OK because the intention is just to clear the previous data on the buffer. Reported-by: Lionel Koenig <lionel.koenig@gmail.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20191211155742.3213-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-14ALSA: control: remove useless assignment in .info callback of PCM chmap elementTakashi Sakamoto1-1/+0
Control elements for PCM chmap return information to userspace abount the maximum number of available PCM channels as the number of values in the element. In current implementation the number is once initialized to zero, then assigned to. This is useless and this commit fixes it. Fixes: 2d3391ec0ecc ("ALSA: PCM: channel mapping API implementation") Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Link: https://lore.kernel.org/r/20191214131351.28950-1-o-takashi@sakamocchi.jp Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-13ALSA: hda: Unify get_response handlingTakashi Iwai8-51/+19
Now most of the get_response handling became quite similar between HDA-core and legacy drivers, and the only differences are: - the handling of extra-long polling delay for some codecs - the debug message for the stalled communication and both are worth to share in the common code. This patch unifies the code into snd_hdac_bus_get_response(), and use this from the legacy get_response callback. It results in a good amount of code reduction in the end. Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20191212191101.19517-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-13ALSA: hda: Use waitqueue for RIRB in HDA-core helper, tooTakashi Iwai1-2/+14
This patch implements the same logic that was done for the legacy HD-audio controller driver by the commit 88452da92ba2 ("ALSA: hda: Use standard waitqueue for RIRB wakeup") to the HDA-core helper code, too. This makes snd_hdac_bus_get_response() waiting for the response with bus->rirb_wq instead of polling when bus->polling is false. It'll save both CPU time and response latency. Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> Link: https://lore.kernel.org/r/20191212191101.19517-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-13ALSA: bump uapi version numbersArnd Bergmann1-3/+3
Change SNDRV_PCM_VERSION, SNDRV_RAWMIDI_VERSION and SNDRV_TIMER_VERSION to indicate the addition of the time64 version of the mmap interface and these ioctl commands: SNDRV_PCM_IOCTL_SYNC SNDRV_RAWMIDI_IOCTL_STATUS SNDRV_PCM_IOCTL_STATUS SNDRV_PCM_IOCTL_STATUS_EXT SNDRV_TIMER_IOCTL_TREAD SNDRV_TIMER_IOCTL_STATUS 32-bit applications built with 64-bit time_t require both the headers and the running kernel to support at least the new API version. When built with earlier kernel headers, some of these may not work correctly, so applications are encouraged to fail compilation like #if SNDRV_PCM_VERSION < SNDRV_PROTOCOL_VERSION(2, 0, 15) extern int __fail_build_for_time_64[sizeof(long) - sizeof(time_t)]; #endif or provide their own updated copy of the header file. At runtime, the interface is unchanged for 32-bit time_t, but new kernels are required to work with user compiled with 64-bit time_t. A runtime check can be used to detect old kernel versions and warn about those. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-13ALSA: add new 32-bit layout for snd_pcm_mmap_status/controlArnd Bergmann4-41/+147
The snd_pcm_mmap_status and snd_pcm_mmap_control interfaces are one of the trickiest areas to get right when moving to 64-bit time_t in user space. The snd_pcm_mmap_status structure layout is incompatible with user space that uses a 64-bit time_t, so we need a new layout for it. Since the SNDRV_PCM_IOCTL_SYNC_PTR ioctl combines it with snd_pcm_mmap_control into snd_pcm_sync_ptr, we need to change those two as well. Both structures are also exported via an mmap() operation on certain architectures, and this suffers from incompatibility between 32-bit and 64-bit user space. As we have to change both structures anyway, this is a good opportunity to fix the mmap() problem as well, so let's standardize on the existing 64-bit layout of the structure where possible. The downside is that we lose mmap() support for existing 32-bit x86 and powerpc applications, adding that would introduce very noticeable runtime overhead and complexity. My assumption here is that not too many people will miss the removed feature, given that: - Almost all x86 and powerpc users these days are on 64-bit kernels, the majority of today's 32-bit users are on architectures that never supported mmap (ARM, MIPS, ...). - It never worked in compat mode (it was intentionally disabled there) - The application already needs to work with a fallback to SNDRV_PCM_IOCTL_SYNC_PTR, which will keep working with both the old and new structure layout. Both the ioctl() and mmap() based interfaces are changed at the same time, as they are based on the same structures. Unlike other interfaces, we change the uapi header to export both the traditional structure and a version that is portable between 32-bit and 64-bit user space code and that corresponds to the existing 64-bit layout. We further check the __USE_TIME_BITS64 macro that will be defined by future C library versions whenever we use the new time_t definition, so any existing user space source code will not see any changes until it gets rebuilt against a new C library. However, the new structures are all visible in addition to the old ones, allowing applications to explicitly request the new structures. In order to detect the difference between the old snd_pcm_mmap_status and the new __snd_pcm_mmap_status64 structure from the ioctl command number, we rely on one quirk in the structure definition: snd_pcm_mmap_status must be aligned to alignof(time_t), which leads the compiler to insert four bytes of padding in struct snd_pcm_sync_ptr after 'flags' and a corresponding change in the size of snd_pcm_sync_ptr itself. On x86-32 (and only there), the compiler doesn't use 64-bit alignment in structure, so I'm adding an explicit pad in the structure that has no effect on the existing 64-bit architectures but ensures that the layout matches for x86. The snd_pcm_uframes_t type compatibility requires another hack: we can't easily make that 64 bit wide, so I leave the type as 'unsigned long', but add padding before and after it, to ensure that the data is properly aligned to the respective 64-bit field in the in-kernel structure. For the SNDRV_PCM_MMAP_OFFSET_STATUS/CONTROL constants that are used as the virtual file offset in the mmap() function, we also have to introduce new constants that depend on hte __USE_TIME_BITS64 macro: The existing macros are renamed to SNDRV_PCM_MMAP_OFFSET_STATUS_OLD and SNDRV_PCM_MMAP_OFFSET_CONTROL_OLD, they continue to work fine on 64-bit architectures, but stop working on native 32-bit user space. The replacement _NEW constants are now used by default for user space built with __USE_TIME_BITS64, those now work on all new kernels for x86, ppc and alpha (32 and 64 bit, native and compat). It might be a good idea for a future alsa-lib to support both the _OLD and _NEW macros and use the corresponding structures directly. Unmodified alsa-lib source code will retain the current behavior, so it will no longer be able to use mmap() for the status/control structures on 32-bit systems, until either the C library gets updated to 64-bit time_t or alsa-lib gets updated to support both mmap() layouts. Co-developed-with: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-13ALSA: move snd_pcm_ioctl_sync_ptr_compat into pcm_native.cArnd Bergmann2-98/+100
This is a preparation patch, moving the compat handler for snd_pcm_ioctl_sync_ptr_compat from pcm_compat.c to pcm_native.c. No other changes are indented. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-13ALSA: Avoid using timespec for struct snd_timer_treadBaolin Wang3-39/+131
The struct snd_timer_tread will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Since the struct snd_timer_tread is passed through read() rather than ioctl(), and the read syscall has no command number that lets us pick between the 32-bit or 64-bit version of this structure. Thus we introduced one new command SNDRV_TIMER_IOCTL_TREAD64 and new struct snd_timer_tread64 replacing timespec with s64 type to handle 64bit time_t. That means we will set tu->tread = TREAD_FORMAT_64BIT when user space has a 64bit time_t, then we will copy to user with struct snd_timer_tread64. Otherwise we will use 32bit time_t variables when copying to user. Moreover this patch replaces timespec type with timespec64 type and related y2038 safe APIs. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-12ALSA: hda: tegra: Fix unused variable compile warningTakashi Iwai1-1/+0
Forgot to remove the variable declaration as well in the last commit. sound/pci/hda/hda_tegra.c: In function 'hda_tegra_runtime_suspend': sound/pci/hda/hda_tegra.c:169:19: warning: unused variable 'bus' [-Wunused-variable] Fixes: f36da9406e66 ("ALSA: hda: Support PCM sync_stop") Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Link: https://lore.kernel.org/r/20191212080518.6522-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-12-11ALSA: Avoid using timespec for struct snd_rawmidi_statusBaolin Wang3-94/+128
The struct snd_rawmidi_status will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Thus we introduced 'struct snd_rawmidi_status32' and 'struct snd_rawmidi_status64' to handle 32bit time_t and 64bit time_t in native mode, which replace timespec with s64 type. In compat mode, we renamed or introduced new structures to handle 32bit/64bit time_t in compatible mode. The 'struct snd_rawmidi_status32' and snd_rawmidi_ioctl_status32() are used to handle 32bit time_t in compat mode. 'struct compat_snd_rawmidi_status64' is used to handle 64bit time_t. When glibc changes time_t to 64-bit, any recompiled program will issue ioctl commands that the kernel does not understand without this patch. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-11ALSA: Avoid using timespec for struct snd_pcm_statusBaolin Wang5-126/+198
The struct snd_pcm_status will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Userspace will use SNDRV_PCM_IOCTL_STATUS and SNDRV_PCM_IOCTL_STATUS_EXT as commands to issue ioctl() to fill the 'snd_pcm_status' structure in userspace. The command number is always defined through _IOR/_IOW/IORW, so when userspace changes the definition of 'struct timespec' to use 64-bit types, the command number also changes. Thus in the kernel, we now need to define two versions of each such ioctl and corresponding ioctl commands to handle 32bit time_t and 64bit time_t in native mode: struct snd_pcm_status32 { ...... s32 trigger_tstamp_sec; s32 trigger_tstamp_nsec; ...... s32 audio_tstamp_sec; s32 audio_tstamp_nsec; ...... }; struct snd_pcm_status64 { ...... s32 trigger_tstamp_sec; s32 trigger_tstamp_nsec; ...... s32 audio_tstamp_sec; s32 audio_tstamp_nsec; ...... }; Moreover in compat file, we renamed or introduced new structures to handle 32bit/64bit time_t in compatible mode. The 'struct snd_pcm_status32' and snd_pcm_status_user32() are used to handle 32bit time_t in compat mode. 'struct compat_snd_pcm_status64' and snd_pcm_status_user_compat64() are used to handle 64bit time_t. The implicit padding before timespec is made explicit to avoid incompatible structure layout between 32-bit and 64-bit x86 due to the different alignment requirements, and the snd_pcm_status structure is now hidden from the kernel to avoid relying on the timespec definitio definitionn Finally we can replace SNDRV_PCM_IOCTL_STATUS and SNDRV_PCM_IOCTL_STATUS_EXT with new commands and introduce new functions to fill new 'struct snd_pcm_status64' instead of using unsafe 'struct snd_pcm_status'. Then in future, the new commands can be matched when userspace changes 'timespec' to 64bit type to make a size change of 'struct snd_pcm_status'. When glibc changes time_t to 64-bit, any recompiled program will issue ioctl commands that the kernel does not understand without this patch. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-11ALSA: Avoid using timespec for struct snd_ctl_elem_valueBaolin Wang1-2/+1
The struct snd_ctl_elem_value will use 'timespec' type variables to record timestamp, which is not year 2038 safe on 32bits system. Since there are no drivers will implemented the tstamp member of the struct snd_ctl_elem_value, and also the stucture size will not be changed if we change timespec to s64 for tstamp member of struct snd_ctl_elem_value. From Takashi's comments, "In the library, applications are not expected to access to this structure directly. The applications get opaque pointer to the structure and must use any control APIs to operate it. Actually the library produce no API to handle 'struct snd_ctl_elem_value.tstamp'. This means that we can drop this member from alsa-lib without decline of functionality." Thus we can simply remove the tstamp member to avoid using the type which is not year 2038 safe on 32bits system. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-11ALSA: Avoid using timespec for struct snd_timer_statusBaolin Wang3-57/+64
struct snd_timer_status uses 'timespec' type variables to record timestamp, which will be changed to an incompatible layout with updated user space using 64-bit time_t. To handle both the old and the new layout on 32-bit architectures, this patch introduces 'struct snd_timer_status32' and 'struct snd_timer_status64' to handle 32bit time_t and 64bit time_t in native mode and compat mode, which replaces timespec with s64 type. When glibc changes time_t to 64-bit, any recompiled program will issue ioctl commands that the kernel does not understand without this patch. In the public uapi header, snd_timer_status is now guarded by an #ifndef __KERNEL__ to avoid referencing 'struct timespec'. The timespec definition will be removed from the kernel to prevent new y2038 bugs and to avoid the conflict with an incompatible libc type of the same name. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-11ALSA: Replace timespec with timespec64Baolin Wang9-53/+65
Since timespec is not year 2038 safe on 32bit system, and we need to convert all timespec variables to timespec64 type for sound subsystem. This patch is used to do preparation for following patches, that will convert all structures defined in uapi/sound/asound.h to use 64-bit time_t. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2019-12-11ALSA: usb-audio: Support PCM sync_stopTakashi Iwai1-12/+25
USB-audio driver had some implementation of its own sync-stop mechanism. This patch moved a part of it to the common PCM sync_stop ops. Link: https://lore.kernel.org/r/20191210063454.31603-56-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>