Age | Commit message (Collapse) | Author | Files | Lines |
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Some tables can be defined as const.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
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>
|
|
Clean up codes, fix indentations, correct comments, etc.
No functional change.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Also change the flag_underrun to bool to be clearer.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
It's used nowhere. Kill it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
It's nowhere used. Let's drop it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
The function is nowhere used. Kill it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
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>
|
|
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>
|
|
had_mutex is (supposedly) used to protect the concurrent calls of
hdmi_audio_probe(). But we may have only one device at most, so it's
utterly useless. Drop it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
The error from hdmi_audio_probe() wasn't handled properly, and it may
leave some resources leaked or mapped. Fix it and also clean up the
error paths.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
For reducing the global variable reference, keep snd_intelhad object
in the context and pass it to each helper. It's a preliminary change
for further cleanup.
This also includes the simplification of the probe procedure: the LPE
platform driver directly gets the created snd_intelhad object by
hdmi_audio_probe(), and passes it to each helper and destructor,
hdmi_audio_remove(). The hdmi_audio_probe() function doesn't call the
back-registration any longer, which is fairly useless. The LPE
platform driver initializes the stuff instead at the right place, and
calls the wq after the object creation in the probe function itself.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
Yet another indirection is killed: at this time, it's
snd_intel_had_interface. It contains also the name string, but it's
nowhere used, thus we can kill it, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
Like the previous patch, this replaces the indirect query_ops calls
via direct function calls. They are only get_caps and set_caps, so
fairly straightforward at this time.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
Now about the indirect register ops: they are replaced with direct
calls, too.
The read / write / modify ops are simply replaced with the
corresponding functions. The difference is that we calculate the
offset inside the function now. So all the had_config_offset
references in the caller side are dropped. This also simplifies the
DP-audio check in hdmi_audio_write() and hdmi_audio_rmw().
The hdmi_audio_get_register_base is dropped since it's no longer used
when the base address and config offset are referred in the read/write
functions.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
We have only a single implementation of had_ops, hence there is no
merit to use the indirect calls at all. Let's replace it with the
direct calls -- which allows the compiler more optimizations.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
The v1 code refers to Medfield/Clovertrail. It's not used at all in
the current driver, and probably won't be ever. Let's clean this up,
then we can go to the next stage of cleanup tasks.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
Theoretically setting the state to SNDRV_PCM_STATE_DISCONNECTED is
correct. But, unfortunately, PA gets confused by this action, and it
won't re-probe the device after HDMI/DP is re-plugged. (It reprobes
only when the card itself is recreated.)
As a workaround, set SNDRV_PCM_STATE_SETUP instead.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
The audio chicken bit (register offset 0x62f38) seems required to make
DP audio working on some machines. At least, on Dell Wyse 3040, I
failed to get the audio unless this bit is set once.
Strangely, the bit seems necessary only once, and it persists after
that, even some power-off cycles. The register is supposedly
write-only, so it's no evidence whether the bit keeps effect
persistently. But, judging from the experiment, it looks enough to
set it up once at the device initialization.
The patch is basically a cut from the original patch by Pierre-Louis
Bossart.
v1->v2: drop read since it's a write-only reg.
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
This allows the LPE HDMI driver to clean up its global variable
reference.
Also drop to pass the eld pointer because the connection status and
the ELD bytes can be retrieved from the attached pdata.
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
Now the pipe that is being used is passed over i915 notification, we
can re-setup the relevant register offset depending on pipe assignments
during hotplug.
This allows playback on single port machines such Zotac Pi330 or
dual-port machines such as Dell Wyse 3040 box
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
Imported from legacy patches
Note: the new code doesn't assume a modified ELD but
an explicit notification that DP is present. It appears
that the i915 code does change the ELD so we could use
the ELD-based tests to check for DP audio
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
The LPE audio configuration depends on the pipe, thus we need to pass
the currently used pipe. It's now embedded in struct
intel_hdmi_lpe_audio_eld as well as port id.
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
The pipe gets cleared to -1 for non-MST before the ELD audio
notification due to the MST audio support. This makes sense for
HD-audio that received the MST handling, but it's useless for LPE
audio. Handle the MST pipe hack conditionally only for HD-audio.
Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
|
Enable unmute/mute amp notification. This doesn't seem to affect
HDMI support so this is done unconditionally.
An earlier version of this patch set a chicken bit at address 0x62F38
prior to the mute/unmute but this register doesn't seem to do anything
so this phase was removed.
v1->v2: Drop needless pipe A check, avoid temporary reg offset variable.
v2->v3: Add "_" prefix to VLV_AUD_PORT_EN_X_DBG as they are internal.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|