The flag bus->shutdown implies that the control elements might have
been already destroyed. When a codec is resumed at this state and
tries to call vmaster hook (e.g. in snd_hda_gen_init()), it would
refer to a non-existing object, resulting in Oops in the end.
This patch just adds a check of the flag in the caller side for
avoiding such a crash.
Though, the best would be to clear hook->sw_kctl by the destructor of
the corresponding ctl element, but vmaster uses its own private_free,
it can't be done easily. So let it be for a while.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
A bunch of changes here, the most interesting one subsystem wise being
Morimoto-san's work to create snd_soc_component which doesn't do much
for now but will be pretty important going forwards:
- Add a new component object type which will form the basis of moving
to a more generic handling of SoC and off-SoC components, contributed
by Kuninori Morimoto.
- A fairly large set of cleanups for the dmaengine integration from
Lars-Peter Clausen, starting to move towards being able to have a
generic driver based on the library.
- Performance optimisations to DAPM from Ryo Tsutsui.
- Support for mixer control sharing in DAPM from Stephen Warren.
- Multiplatform ARM cleanups from Arnd Bergmann.
- New CODEC drivers for AK5385 and TAS5086 from Daniel Mack.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQIcBAABAgAGBQJRa//sAAoJELSic+t+oim95J8P/A0ia+ergNHjM7VuV89XyDxJ
qT+hciD2F7HGiGqCluyIxWTWY4NCG8JUMVj4j+qDltc+DZA7DGX654gUXOlyYIFb
Otbt7s8CNGIGRuUkRAzoSCewL2B/veFjOdnw6XW2w9YcYHeYbjl9BOlXOdCJtPRb
yroKHl6mzD99eD8y26QVjk7z3bJGmdBkckilYz+Fws+NACGZqu5KpzF11+DnrAL+
0Bl3F/fafDEUwFqDvWaQD2728aXxJL1pg0aR8mueRCcGBPnk3qWycj9kQZqVFBpV
i8Q+xNEnIVECfDKclT0j0bAL+2ftcg2Jm2lryupMtopGxR3Uii1kgGKSMwYHz82E
bvQ8y3phLc6u5VtIIJj0iPE7ZE5H/2///KgFEj6z/P2tZPWobMkURb+9bGQTJ8Qv
pUYGiOV0S/+59WAv0qnN4XpomA69EPPu5AuiPd30T+iNna998OjFEBRmIc/wJ519
QYlhj1ThWsa3Uoi1V0hmhAPHCXVtOKHnZfj95cyaD4Vq8zdqUmptJI+UvUJFgRUm
30eVVNwcIb0XE+0K4skMbVbpCkRA4m+pBGE7+Z+x72kYTfmg6uVET1T/sGgDFIAG
XCZ8QOXXYxpmpXMDqTKO30oBHdN6V0tClkSCuQ6H2PoICi0VYX3ZZWT8/Qno3JuN
bBxyWhz3gYL/MII6qJpE
=lx37
-----END PGP SIGNATURE-----
Merge tag 'asoc-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.10
A bunch of changes here, the most interesting one subsystem wise being
Morimoto-san's work to create snd_soc_component which doesn't do much
for now but will be pretty important going forwards:
- Add a new component object type which will form the basis of moving
to a more generic handling of SoC and off-SoC components, contributed
by Kuninori Morimoto.
- A fairly large set of cleanups for the dmaengine integration from
Lars-Peter Clausen, starting to move towards being able to have a
generic driver based on the library.
- Performance optimisations to DAPM from Ryo Tsutsui.
- Support for mixer control sharing in DAPM from Stephen Warren.
- Multiplatform ARM cleanups from Arnd Bergmann.
- New CODEC drivers for AK5385 and TAS5086 from Daniel Mack.
Rename "Digitial In" to "Digital In". This function is only used for
proc output, so should not cause any problems to change.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Merge back for-linus branch for the badness table adjustment for VIA codecs
* for-linus:
ALSA: hda - Fix DAC assignment for independent HP
ALSA: hda - Fix abuse of snd_hda_lock_devices() for DSP loader
ALSA: hda - Fix typo in checking IEC958 emphasis bit
ALSA: snd-usb: mixer: ignore -EINVAL in snd_usb_mixer_controls()
ALSA: snd-usb: mixer: propagate errors up the call chain
ALSA: usb: Parse UAC2 extension unit like for UAC1
ALSA: hda - Fix yet missing GPIO/EAPD setup in cirrus driver
There is a typo in convert_to_spdif_status() about checking the
emphasis IEC958 status bit. It should check the given value instead
of the resultant value.
Reported-by: Martin Weishart <martin.weishart@telosalliance.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
So far, the driver doesn't power down the widget at going down to D3
when the widget node has an EAPD capability and EAPD is actually set
on all codecs unless codec->power_filter is set explicitly.
This caused a problem on some Conexant codecs, leading to click
noises, and we set it as NULL there. But it is very unlikely that the
problem hits only these codecs.
Looking back at the development history, this workaround for EAPD was
introduced just for some laptops with STAC9200 codec, then we applied
it blindly for all. Now, since it's revealed to have an ill effect,
we should disable this workaround per default and apply only for the
known requiring systems.
The EAPD workaround is implemented now as snd_hda_codec_eapd_power_filter(),
and this has to be set explicitly by the codec driver when needed.
As of now, only patch_stac9200() sets this one.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
In the connection list expansion in hda_codec.c and hda_proc.c, the
value returned from snd_hda_get_num_raw_conns() is used as the array
size to store the connection list. However, the function returns
simply a raw value of the AC_PAR_CONNLIST_LEN parameter, and the
widget list with ranges isn't considered there. Thus it may return a
smaller size than the actual list, which results in -ENOSPC in
snd_hda_get_raw_conections().
This patch fixes the bug by parsing the connection list correctly also
for snd_hda_get_num_raw_conns().
Reported-and-tested-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
If the new control cannot be created, this function will return to avoid
snd_hda_ctl_add dereferencing a NULL control pointer.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
If the SPDIF control array cannot be reallocated, the function
will return to avoid dereferencing a NULL pointer.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The commit [dcda58061: ALSA: hda - Add workaround for conflicting
IEC958 controls] introduced a workaround for cards that have both
SPDIF and HDMI devices for giving device=1 to SPDIF control elements.
It turned out, however, that this workaround doesn't work well -
- The workaround checks only conflicts in a single codec, but SPDIF
and HDMI are provided by multiple codecs in many cases, and
- ALSA mixer abstraction doesn't care about the device number in ctl
elements, thus you'll get errors from amixer such as
% amixer scontrols -c 0
ALSA lib simple_none.c:1551:(simple_add1) helem (MIXER,'IEC958
Playback Switch',0,1,0) appears twice or more
amixer: Mixer hw:0 load error: Invalid argument
This patch fixes the previous broken workaround. Instead of changing
the device number of SPDIF ctl elements, shift the element indices of
such controls up to 16. Also, the conflict check is performed over
all codecs found on the bus.
HDMI devices will be put to dev=0,index=0 as before. Only the
conflicting SPDIF device is moved to a different place. The new place
of SPDIF device is supposed by the updated alsa-lib HDA-Intel.conf,
respectively.
Reported-by: Stephan Raue <stephan@openelec.tv>
Reported-by: Anssi Hannula <anssi.hannula@iki.fi>
Cc: <stable@vger.kernel.org> [v3.8]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
A codec may allow software to hide some unused pin/cvt widgets.
Sometimes BIOS does not enable the hidden widgets properly although they are
needed for the board. Thus the driver need to enable them as a board-specific
fixup and the whole tree will change.
This patch implements a common code for rereading codec widgets. So the fixup
code can call it after enabling the hidden widgets.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Currently we set the max number of connections to be 32, but there
seems codec that gives longer connection lists like AD1988, and we see
errors in proc output and else. (Though, in the case of AD1988, it's
a list of all codecs connected to a single vendor widget, so this must
be something fishy, but it's still valid from the h/w design POV.)
This patch tries to remove this restriction. For efficiency, we still
use the fixed size array in the parser, but takes a dynamic array when
the size is reported to be greater than that.
Now the fixed array size is found only in patch_hdmi.c, but it should
be fine, as the codec itself can't support so many pins.
Reported-by: Raymond Yau <superquad.vortex2@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Put the power state synchronization at the end of the parsing of
codec. This is necessary when the power filter is changed during the
codec probe. Since the first power-up sequence is performed without
the special filter, all widgets are supposed to be ON at this point.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a hook to struct hda_codec for filtering the target power state of
each widget when powering up/down. The current hackish EAPD check is
implemented as the default hook pointer, too.
This allows codec drivers to implement own power filter. In the
upcoming changes, the generic parser will have the better power filter
based on the active paths.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The commit [26a6cb6c: ALSA: hda - Implement a poll loop for jacks as a
module parameter] introduced the polling jack detection code, but it
also moved the call of snd_hda_jack_set_dirty_all() in the resume path
after resume/init ops call. This caused a regression when the jack
state has been changed during power-down (e.g. in the power save
mode). Since the driver doesn't probe the new jack state but keeps
using the cached value due to no dirty flag, the pin state remains
also as if the jack is still plugged.
The fix is simply moving snd_hda_jack_set_dirty_all() to the original
position.
Reported-by: Manolo Díaz <diaz.manolo@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since both snd_hda_codec_flush_amp_cache() and
snd_hda_codec_flush_cmd_cache() are called usually at the same time,
we can simply combine them to a single function,
snd_hda_codec_flush_cache().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The pincfgs, init_verbs and hints set by sysfs or patch might be
changed dynamically on the fly, thus we need to protect it.
Add a simple protection via a mutex.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Check more strictly about the validity of pinctl values in
snd_hda_set_pin_ctl() and correct the wrong bits automatically.
Also provide the helper function to correct pinctl bits to codec
drivers.
This automatically fixes the invalid pinctl writes that are found in
a few Realtek fixups for NID 0x0f amp like ASUS A6Rp.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
We already have the list of whole pin widgets and there is an unused
space in the list; let's use it for caching the current pinctl value.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Manage the connection list cache using linked lists instead of
snd_array, and revive snd_hda_get_conn_list() again, so that we don't
have to keep the expanded values locally.
This will reduce the stack usage by recursive call of
snd_hda_get_conn_index() or parse_nid_path() of the generic parser.
The list management doesn't include any mutex protection, thus the
caller needs to take care of race appropriately.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Old codecs like AD1986A tend to have long paths as they were just made
to be the way like AC97. The current max depth 5 can be too short for
such devices.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The access to a cache array element could be invalid outside the
mutex, so copy locally for the later references.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The dirty entry has to be checked at the beginning in the loop, not in
the inner loop for channels. This caused a regression that the right
channel isn't properly written.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add an overflow check of CORB in HD-audio controller and codec drivers
so that flood of sequential writes would work properly.
In the controller side, add a check of CORB read-pointer to make
returning -EAGAIN when it's full. Meanwhile in the codec side, when
-EAGAIN error is received, it retries the write after flushing the
pending verbs (calling get_response() essentially does it).
Signed-off-by: Takashi Iwai <tiwai@suse.de>
These functions are supposed to be called at finishing the cached
sequential writes, so clear the flag properly for lazy developers who
often forget details.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When verbs or amps are actually written to the hardware, we can clear
dirty flag so that the later snd_hda_codec_resume_*() calls can skip
these verbs / amps.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The commit [2e9bf24: ALSA: hda_codec: Check for invalid zero
connections] trims the whole connection list when an invalid value is
reported by the hardware. But some codecs (at least AD1986A) may give
a zero NID in the middle of the connection list, so dropping the whole
list isn't good for such cases.
In this patch, as a workaround, allow a single zero NID in the read
connection list. If it hits zero twice, it's handled as an error, so
that we can avoid "too many connections" errors.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since the fixup code is used commonly, it's worth to move it to the
common place, struct hda_codec, instead of keeping in hda_gen_spec.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The new function snd_hda_codec_amp_init() (and the stereo variant)
initializes the amp value only once at the first access. If the amp
was already initialized or updated, this won't do anything more.
It's useful for initializing the input amps that are in the part of
the path but never used.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
For optimizing the verb executions, a new mechanism to cache the verbs
and amp update commands is introduced. With the new "write to cache
and flush" way, you can reduce the same verbs that have been written
multiple times.
When codec->cached_write flag is set, the further
snd_hda_codec_write_cache() and snd_hda_codec_amp_stereo() calls will
be performed only on the command or amp cache table, but not sent to
the hardware yet. Once after you call all commands and update amps,
call snd_hda_codec_resume_amp() and snd_hda_codec_resume_cache().
Then all cached writes and amp updates will be written to the
hardware, and the dirty flags are cleared.
In this implementation, the existing cache table is reused, so
actually no big code change is seen here. Each cache entry has a new
dirty flag now (so the cache key is now reduced to 31bit).
As a good side-effect by this change, snd_hda_codec_resume_*() will no
longer execute verbs that have been already issued during the resume
phase by checking the dirty flags.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The vmaster hook sends 1 for enabled/unmuted and 0 for disabled/muted,
but "Mute-LED Mode" being "On" refers to the LED being on, not the
volume being on.
Therefore "On" and "Off" should be switched.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Remove the leftover __devinit* in comments.
They have been commented out because they couldn't fit with __dev*
although they should have matched.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Very quiet release for ASoC really:
- Standardisation of the logging.
- DT and dmaengine support for Atmel.
- Support for Wolfson ADSP cores.
- New drivers for Freescale/iVeia P1022 and Maxim MAX98090.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQIcBAABAgAGBQJQutrLAAoJELSic+t+oim9NVUP/3Y1YJjUADTy3w1d6L7zKaQb
dGVg2cdDBNgXCrIuyb3zUA9yNGrR1c7gzDGjTuiBrJKx917/DrF08pmgHAUv5e9B
+//xoy2lSwYgnPiWY7p6092+pYNI1hs4PDkV3zucrkkgQovIZOlebUM3MOrSf50+
abe9uPA11EyqPtmy8HrhtL2iJ3kUOq1y6YNbrDQaaWTL/lwBPS+LzxFAIE36LjN6
fIUOb8jtSE0rjOVo+jmuytdCnlugaEFfQzOebKMVYpB9LNv6hqISai/baaKFO1Fc
Jtkjv2xGuUuxP0kY6Fkbjabut7mS8oiVZfGmNUKbYoKStsk1t//xjay/2F0HsNgg
O7PsK6y1HD/iB87YNaO8Go/6lLSszeQ2WU7Fvynv/CTOpjO/8gjaQz3zDi3HsF5O
gyh/WYnj9jwnUJkaMDeEyjKBbKDxLuBeXBETVhNIWNgCwnj48TSYQwmGhtefNnS1
AM/CUrfXVsgCxPn8z/ep/hbkat8+PHENuPR9v81mUyQvVX9jTALVIYioTdxkc8Ul
y0p5UmgM/TsmnINGVUeFp5LkmfdyOhUhBtwovDhzDjR4RC1/otty1/9l4VHqw1ym
ETwqu7pl7bb9aDNsOEV9Z21kOMuTDbApHIT6crptNBllUvR0jDYfD4xOAs3zQLO5
JWOX2fPUHzFusINuA6fS
=2irt
-----END PGP SIGNATURE-----
Merge tag 'asoc-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Updates for v3.8
Very quiet release for ASoC really:
- Standardisation of the logging.
- DT and dmaengine support for Atmel.
- Support for Wolfson ADSP cores.
- New drivers for Freescale/iVeia P1022 and Maxim MAX98090.
The same type of code is being used in multiple places in various
codec drivers, so put it as a core library.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This is a preliminary patch for introducing a protection to access
races of snd_array instances. Call snd_array_init() appropriately
at the initialization time and don't call it twice.
Also the allocations of codec-spec structs are cleaned up by helper
functions in patch_sigmatel.c and patch_analog.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
I forgot this again... codec->in_pm is in #ifdef CONFIG_PM
Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since we keep the pin default config values anyway internally, we
don't have to set the values in the codec. This patch removes the
code writing the pincfg values.
As a gratis bonus, we can remove also the code restoring the original
pincfg values at PM resume or module free. This will give us more
benefit, as it can reduce the unnecessary power-up of codecs.
This won't change the driver functionality. The only difference would
be that the codec proc file will show the original pincfg values
instead of the actually referred values. The actually referred values
can be determined from sysfs *_pin_configs files.
(Also hda-emu was updated to follow this change.)
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When the bus reset is performed during the suspend/resume (including
the power-saving too), it calls snd_hda_suspend() and
snd_hda_resume() again, and deadlocks eventually.
For avoiding the recursive call, add a new flag indicating that the PM
is being performed, and don't go to the bus reset mode when it's on.
Reported-and-tested-by: Julian Wollrath <jwollrath@web.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When 2.1 speakers are detected, use the corresponding channel map
instead of the standard map with front+rear surrounds.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Starting audio or seeking in various music players causes
setup_dig_out_stream() to be called, which resets the SPDIF stream,
which caused one DAC (but not another) to make a clicking noise every
time.
This patch ensures the reset only happens when it needs to, which is
when the format changes, and makes the code a little more readable.
Signed-off-by: Laurence Darby <ldarby@tuffmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When both an SPDIF and an HDMI device are created on the same card
instance, multiple IEC958 controls are created with indices=0, 1, ...
But the alsa-lib configuration can't know which index corresponds
actually to which PCM device, and both the SPDIF and the HDMI
configurations point to the first IEC958 control wrongly.
This patch introduces a (hackish and ugly) workaround: the IEC958
controls for the SPDIF device are re-labeled with device=1 when HDMI
coexists. The device=1 corresponds to the actual PCM device for
SPDIF, so it's anyway a better representation. In future, HDMI
controls should be moved with the corresponding PCM device number,
too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Now that we have a generic unsol mechanism, we can implement a generic
poll loop, which can be used for debugging, or if a codec's unsol
mechanism is broken.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>