Commit graph

27 commits

Author SHA1 Message Date
Takashi Iwai 03c3437755 ALSA: x86: Clean up unused defines and inclusions
Many defines and constants are left unused.  Clean them up.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:37:13 +01:00
Takashi Iwai 7ceba75f21 ALSA: x86: Reduce redundant register field names
Currently each register definition contains the own prefix in the
union struct itself; for example, union aud_ch_status_0 has
status_0_regx and status_0_regval fields.  These are simply
superfluous, since usually the type of the variable is seen in its
declaration or in its name.

In this patch, we cut off these prefixes.  Now all register
definitions have regx and regval fields consistently, instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:37:02 +01:00
Takashi Iwai df0435db1d ALSA: x86: Use the standard ELD bytes definitions
We have some constants defined in drm/drm_edid.h, and clean up our own
definitions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:36:53 +01:00
Takashi Iwai f69bd104b5 ALSA: x86: Move stream status into pcm_stream_info
The only remaining field in struct had_stream_data is stream_type that
holds the current stream status.  Such information fits better in
struct pcm_stream_info, so move it as a boolean "running" field to be
clearer.

This allows us to get rid or had_stream_data definition and
references.

Also, the superfluous status check get removed in a couple of places
where we can call PCM helpers in anyway.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:36:35 +01:00
Takashi Iwai 313d9f28c1 ALSA: x86: Properly manage PCM substream lifetype
The PCM substream is referred not only in the PCM callbacks but also
in the irq handler and in the hotplug/unplug codes.  The latter code
paths don't take the PCM lock, thus the PCM may be released
unexpectedly while calling PCM helper functions or accessing
pcm->runtime fields.

This patch implements a simple refcount to assure the PCM substream
accessibility while the other codes are accessing.  It needed some
code refactoring in the relevant functions for avoiding the doubly
spinlocks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:36:13 +01:00
Takashi Iwai 7d9e79869b ALSA: x86: Drop unused fields from pcm_stream_info
The struct pcm_stream_info contains a few unused or useless fields.
str_id is always zero, buffer_ptr is volatile, never read, and sfreq
is nowhere referred.  Kill them.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:35:56 +01:00
Takashi Iwai fa5dfe6a01 ALSA: x86: Drop redundant had_stream_pvt
The had_stream_pvt struct assigned to PCM runtime private data tracks
merely the stream running status, and the very same information is
carried by had_stream->stream_type.  Kill it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:35:42 +01:00
Takashi Iwai 0e9c67d7c8 ALSA: x86: Drop superfluous state field
The state field keeps the connection state and it's basically as same
as drv_status field.  Drop this redundancy.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:35:35 +01:00
Takashi Iwai d0e9b1a23c ALSA: x86: Drop flag_underrun field
The flag_underrun flag is used to indicate to escalate the XRUN
reporting at the next position inquiry, but there is a much simpler
method to achieve it: just call snd_pcm_stop_xrun().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:35:17 +01:00
Takashi Iwai 8f8d1d7fe0 ALSA: x86: Fix racy access to chmap
The access to chmap can be racy against the hotplug process, where it
recreates the chmap on the fly.  For protecting against it, a mutex is
introduced in this patch.  It's also used for protecting the change /
reference of eld and state fields, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:35:07 +01:00
Takashi Iwai 4151ee845a ALSA: x86: Remove _v[12] suffices
Although we dropped the most of the obsoleted *_v1 definitions and
codes, some codes still keep the _v1 or _v2 suffices.  Now they are
ripped off.

The only thing to be done carefully here is the definition of control
offsets.  The original code defines enum hdmi_ctrl_reg_offset_v1 and
a few new elements just for v2 on its top.  After this cleanup, we
remove the old AUD_HDMI_STATUS and AUD_HDMIW_INFOFR definitions and
replace with the v2 values.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:34:40 +01:00
Takashi Iwai e9d65abfa6 ALSA: x86: Drop unused fields from snd_intelhad struct
Also change the flag_underrun to bool to be clearer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:33:28 +01:00
Takashi Iwai df76df12f1 ALSA: x86: Remove indirect call of snd_pcm_period_elapsed()
Again another indirect call...  Let's straighten it up.
Also define the had_stream field with a proper type instead of a void
pointer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:33:13 +01:00
Takashi Iwai 372d855f87 ALSA: x86: Fold intel_hdmi_audio_if.c into main file
As the very last step, we fold intel_hdmi_audio_if.c into the main
file, intel_hdmi_audio.c.  This is merely a cleanup, and no functional
change.

By this move, we can mark all functions and variables as static, which
allows the compiler more optimizations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:31:54 +01:00
Takashi Iwai da86480974 ALSA: x86: Flatten two abstraction layers
This is the final stage for a big clean-up series.  Here we flatten
the two layers into one.  Formerly, the implementation was split to
HDMI "shell" that talks with the platform device, and HDMI audio part
that communicates via caps and other event handlers.  All these would
be good if there were multiple instantiations or if there were data
protection.  But neither are true in our case.  That said, it'll be
easier to have a flat driver structure in the end.

In this patch, the former struct hdmi_lpe_audio_ctx is forged into the
existing struct snd_intelhad.  The latter has already a few members
that are basically the copy from the former.  Only a few new members
for the lowlevel I/O are added by this change.

Then, the had_get_caps() and had_set_caps() are simply replaced with
the direct calls to copy the data in the struct fields.  Also, the
had_event_handler() calls are replaced with the direct call for each
event as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:31:35 +01:00
Takashi Iwai eeb756c5bf ALSA: x86: Drop unused hdmi_audio_query()
It's used nowhere.  Kill it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:31:26 +01:00
Takashi Iwai 5647aec266 ALSA: x86: Embed snd_intelhad into snd_card
Instead of allocating snd_intelhad struct, use the card's private_data
and embed it.  It simplifies the code a lot.

While we're at it, embed had_stream into snd_intelhad struct instead
of individually allocating, and rename had_pvt_data to a bit more
specific name, had_stream_data.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:30:26 +01:00
Takashi Iwai 0e18060f99 ALSA: x86: Drop unused hw_silence field
It's nowhere used.  Let's drop it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:25:43 +01:00
Takashi Iwai 6ddb3ab66f ALSA: x86: Move the global underrun_count to struct snd_intelhad
The last one is in intel_hdmi_audio.c, underrun_count: this can be
embedded in snd_intelhad object.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-02-03 17:25:30 +01:00
Takashi Iwai 437af8f294 ALSA: x86: Call event callback directly
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>
2017-02-03 17:23:15 +01:00
Takashi Iwai 79dda75a2c ALSA: x86: Pass snd_intelhad object to helpers
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>
2017-02-03 17:22:16 +01:00
Takashi Iwai 6f9ecc76f4 ALSA: x86: Drop snd_intel_had_interface indirect calls
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>
2017-02-03 17:21:57 +01:00
Takashi Iwai 9eca88c881 ALSA: x86: Replace indirect query_ops with direct calls
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>
2017-02-03 17:21:41 +01:00
Takashi Iwai f23df8071b ALSA: x86: Replace indirect register ops with direct calls
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>
2017-02-03 17:21:17 +01:00
Takashi Iwai 76296ef0ec ALSA: x86: Drop indirect calls of had_ops
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>
2017-02-03 17:20:58 +01:00
Pierre-Louis Bossart 964ca8083c ALSA: x86: intel_hdmi: add definitions and logic for DP audio
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>
2017-02-01 16:22:24 +01:00
Jerome Anand 5dab11d897 ALSA: x86: hdmi: Add audio support for BYT and CHT
Hdmi audio driver based on the child platform device
created by gfx driver is implemented.
This audio driver is derived from legacy intel
hdmi audio driver.

The interfaces for interaction between gfx and audio
are updated and the driver implementation updated to
derive interrupts in its own address space based on
irq chip framework

The changes to calculate sub-period positions was triggered
by David Henningsson <david.henningsson@canonical.com> and is
accomodated in this patch

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Jerome Anand <jerome.anand@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-01-25 14:24:08 +01:00