1. 16 4月, 2015 1 次提交
  2. 08 4月, 2015 1 次提交
    • T
      ALSA: hda - Work around races of power up/down with runtime PM · 664c7155
      Takashi Iwai 提交于
      Currently, snd_hdac_power_up()/down() helpers checks whether the codec
      is being in pm (suspend/resume), and skips the call of runtime get/put
      during it.  This is needed as there are lots of power up/down
      sequences called in the paths that are also used in the PM itself.  An
      example is found in hda_codec.c::codec_exec_verb(), where this can
      power up the codec while it may be called again in its power up
      sequence, too.
      
      The above works in most cases, but sometimes we really want to wait
      for the real power up.  For example, the control element get/put may
      want explicit power up so that the value change is assured to reach to
      the hardware.   Using the current snd_hdac_power_up(), however,
      results in a race, e.g. when it's called during the runtime suspend is
      being performed.  In the worst case, as found in patch_ca0132.c, it
      can even lead to the deadlock because the code assumes the power up
      while it was skipped due to the check above.
      
      For dealing with such cases, this patch makes snd_hdac_power_up() and
      _down() to two variants: with and without in_pm flag check.  The
      version with pm flag check is named as snd_hdac_power_up_pm() while
      the version without pm flag check is still kept as
      snd_hdac_power_up().  (Just because the usage of the former is fewer.)
      
      Then finally, the patch replaces each call potentially done in PM with
      the new _pm() variant.
      
      In theory, we can implement a unified version -- if we can distinguish
      the current context whether it's in the pm path.  But such an
      implementation is cumbersome, so leave the code like this a bit messy
      way for now...
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=96271Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      664c7155
  3. 04 4月, 2015 1 次提交
  4. 23 3月, 2015 12 次提交
    • T
      ALSA: hda - Use regmap for command verb caches, too · a551d914
      Takashi Iwai 提交于
      Like the previous patches, this patch converts also to the regmap, at
      this time, the cached verb writes are the target.  But this conversion
      needs a bit more caution than before.
      
      - In the old code, we just record any verbs as is, and restore them at
        resume.  For the regmap scheme, this doesn't work, since a few verbs
        like AMP or DIGI_CONVERT are asymmetrical.  Such verbs are converted
        either to the dedicated function (snd_hda_regmap_xxx_amp()) or
        changed to the unified verb.
      
      - Some verbs have to be declared as vendor-specific ones before
        accessing via regmap.
      
      Also, the minor optimization with codec->cached_write flag is dropped
      in a few places, as this would confuse the operation.  Further
      optimizations will be brought in the later patches, if any.
      
      This conversion ends up with a drop of significant amount of codes,
      mostly the helper codes that are no longer used.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      a551d914
    • T
      ALSA: hda - Use regmap for parameter caches, too · faa75f8a
      Takashi Iwai 提交于
      The amp hash table was used for recording the cached reads of some
      capability values like pin caps or amp caps.  Now all these are moved
      to regmap as well.
      
      One addition to the regmap helper is codec->caps_overwriting flag.
      This is set in snd_hdac_override_parm(), and the regmap helper accepts
      any register while this flag is set, so that it can overwrite even the
      read-only verb like AC_VERB_PARAMETERS.  The flag is cleared
      immediately in snd_hdac_override_parm(), as it's a once-off flag.
      
      Along with these changes, the no longer needed amp hash and relevant
      fields are removed from hda_codec struct now.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      faa75f8a
    • T
      ALSA: hda - Use regmap for amp accesses · eeecd9d1
      Takashi Iwai 提交于
      This patch converts the amp access functions to the regmap helpers.
      The amp values were formerly cached in the own hash table.  Now it's
      dropped by the regmap's cache.
      
      The only tricky conversion is snd_hda_codec_amp_init().  This function
      shouldn't do anything if the amp was already initialized.  For
      achieving this behavior, a value is read once at first temporarily in
      the cache-only mode.  Only if it returns an error,  i.e. the item
      still doesn't exist in the cache, it proceeds to the update.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      eeecd9d1
    • T
      ALSA: hda - Implement uncached version of parameter reads · 9ba17b4d
      Takashi Iwai 提交于
      Sometimes we need the uncached reads, e.g. for refreshing the tree.
      This patch provides the helper function for that and uses it for
      refreshing widgets, reading subtrees and the whole proc reads.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      9ba17b4d
    • T
      ALSA: hda - Add regmap support · 4d75faa0
      Takashi Iwai 提交于
      This patch adds an infrastructure to support regmap-based verb
      accesses.  Because o the asymmetric nature of HD-audio verbs,
      especially the amp verbs, we need to translate the verbs as a sort of
      pseudo registers to be mapped uniquely in regmap.
      
      In this patch, a pseudo register is built from the NID, the
      AC_VERB_GET_* and 8bit parameters, i.e. almost in the form to be sent
      to HD-audio bus but without codec address field.  OTOH, for writing,
      the same pseudo register is translated to AC_VERB_SET_* automatically.
      The AC_VERB_SET_AMP_* verb is re-encoded from the corresponding
      AC_VERB_GET_AMP_* verb and parameter at writing.
      
      Some verbs has a single command for read but multiple for writes.  A
      write for such a verb is split automatically to multiple verbs.
      
      The patch provides also a few handy helper functions.  They are
      designed to be accessible even without regmap.  When no regmap is set
      up (e.g. before the codec device instantiation), the direct hardware
      access is used.  Also, it tries to avoid the unnecessary power-up.
      The power up/down sequence is performed only on demand.
      
      The codec driver needs to call snd_hdac_regmap_exit() and
      snd_hdac_regmap_exit() at probe and remove if it wants the regmap
      access.
      
      There is one flag added to hdac_device.  When the flag lazy_cache is
      set, regmap helper ignores a write for a suspended device and returns
      as if it was actually written.  It reduces the hardware access pretty
      much, e.g. when adjusting the mixer volume while in idle.  This
      assumes that the driver will sync the cache later at resume properly,
      so use it carefully.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      4d75faa0
    • T
      ALSA: hda - Move generic array helpers to core lib · 71fc4c7e
      Takashi Iwai 提交于
      This will be used by the regmap support.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      71fc4c7e
    • T
      ALSA: hda - Fix possible runtime PM refcount unbalance · c4c2533f
      Takashi Iwai 提交于
      When the driver is unloaded before the codec is bound, it still keeps
      the runtime PM refcount up, and results in the unbalance.  This patch
      covers these cases by introducing a flag indicating the runtime PM
      initialization and handling the codec registration procedure more
      properly.  It also fixes the missing input beep device as a gratis,
      too.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      c4c2533f
    • T
      ALSA: hda - Support indirect execution of verbs · 05852448
      Takashi Iwai 提交于
      Add an overriding exec_verb op to struct hdac_device so that the call
      via snd_hdac_exec_verb() can switch to a different route depending on
      the setup.  The codec driver sets this field so that it can handle the
      errors or applying quirks appropriately.  Furthermore, this mechanism
      will be used for smooth transition for the regmap support in later
      patches.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      05852448
    • T
      ALSA: hda - Add widget sysfs tree · 3256be65
      Takashi Iwai 提交于
      This patch changes the sysfs files assigned to the codec device on the
      bus which were formerly identical with hwdep sysfs files.  Now it
      shows only a few core parameter, vendor_id, subsystem_id, revision_id,
      afg, mfg, vendor_name and chip_name.
      
      In addition, now a widget tree is added to the bus device sysfs
      directory for showing the widget topology and attributes.  It's just a
      flat tree consisting of subdirectories named as the widget NID
      including various attributes like widget capability bits.  The AFG
      (usually NID 0x01) is always found there, and it contains always
      amp_in_caps, amp_out_caps and power_caps files.  Each of these
      attributes show a single value.  The rest are the widget nodes
      belonging to that AFG.  Note that the child node might not start from
      0x02 but from another value like 0x0a.
      
      Each child node may contain caps, pin_caps, amp_in_caps, amp_out_caps,
      power_caps and connections files.  The caps (representing the widget
      capability bits) always contain a value.  The rest may contain
      value(s) if the attribute exists on the node.  Only connections file
      show multiple values while other attributes have zero or one single
      value.
      
      An example of ls -R output is like below:
      % ls -R /sys/bus/hdaudio/devices/hdaudioC0D0/
      /sys/bus/hdaudio/devices/hdaudioC0D0/widgets/:
      01/  04/  07/  0a/  0d/  10/  13/  16/  19/  1c/  1f/  22/
      02/  05/  08/  0b/  0e/  11/  14/  17/  1a/  1d/  20/  23/
      03/  06/  09/  0c/  0f/  12/  15/  18/  1b/  1e/  21/
      
      /sys/bus/hdaudio/devices/hdaudioC0D0/widgets/01:
      amp_in_caps  amp_out_caps  power_caps
      
      /sys/bus/hdaudio/devices/hdaudioC0D0/widgets/02:
      amp_in_caps  amp_out_caps  caps  connections  pin_caps  pin_cfg
      power_caps
      
      /sys/bus/hdaudio/devices/hdaudioC0D0/widgets/03:
      .....
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      3256be65
    • T
      ALSA: hda - Move a part of hda_codec stuff into hdac_device · 7639a06c
      Takashi Iwai 提交于
      Now some codes and functionalities of hda_codec struct are moved to
      hdac_device struct.  A few basic attributes like the codec address,
      vendor ID number, FG numbers, etc are moved to hdac_device, and they
      are accessed like codec->core.addr.  The basic verb exec functions are
      moved, too.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      7639a06c
    • T
      ALSA: hda - Move some codes up to hdac_bus struct · d068ebc2
      Takashi Iwai 提交于
      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: NTakashi Iwai <tiwai@suse.de>
      d068ebc2
    • T
      ALSA: hda - Make snd_hda_bus_type public · e3d280fc
      Takashi Iwai 提交于
      Define the common hd-audio driver and device types to bind over
      snd_hda_bus_type publicly.  This allows to implement other type of
      device and driver code over hd-audio bus.
      
      Now both struct hda_codec and struct hda_codec_driver inherit these
      new struct hdac_device and struct hdac_driver, respectively.
      
      The bus registration is done in subsys_initcall() to assure it
      before any other driver registrations.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      e3d280fc
  5. 18 3月, 2015 1 次提交
    • T
      ALSA: hda - Support advanced power state controls · e6feb5d0
      Takashi Iwai 提交于
      This patch enables the finer power state control of each widget
      depending on the jack plug state and streaming state in addition to
      the existing power_down_unused power optimization.  The new feature is
      enabled only when codec->power_mgmt flag is set.
      
      Two new flags, pin_enabled and stream_enabled, are introduced in
      nid_path struct for marking the two individual power states: the pin
      plug/unplug and DAC/ADC stream, respectively.  They can be set
      statically in case they are static routes (e.g. some mixer paths),
      too.
      
      The power up and down events for each pin are triggered via the
      standard hda_jack table.  The call order is hard-coded, relying on the
      current implementation of jack event chain (a la FILO/stack order).
      
      One point to be dealt carefully is that DAC/ADC cannot be powered
      on/off while streaming.  They are pinned as long as the stream is
      running.  For controlling the power of DAC/ADC, a new patch_ops is
      added.  The generic parser provides the default callback for that.
      
      As of this patch, only IDT/Sigmatel codec driver enables the flag.
      The support on other codecs will follow.
      
      An assumption we made in this code is that the widget state (e.g. amp,
      pinctl, connections) remains after the widget power transition (not
      about FG power transition).  This is true for IDT codecs, at least.
      But if the widget state is lost at widget power transition, we'd need
      to implement additional code to sync the cached amp/verbs for the
      specific NID.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      e6feb5d0
  6. 13 3月, 2015 1 次提交
  7. 03 3月, 2015 9 次提交
  8. 26 2月, 2015 4 次提交
    • T
      ALSA: hda - Remove channel mode helper functions · 7e40b80d
      Takashi Iwai 提交于
      They are no longer used, let's kill them.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      7e40b80d
    • T
      ALSA: hda - Power down codec automatically at registration · 709949fb
      Takashi Iwai 提交于
      So far, we let the controller driver power down the all codecs at the
      end of probe.  But this can be done better in the codec's dev_register
      callback.  This results in the reduction of duplicated codes in each
      control driver.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      709949fb
    • T
      ALSA: hda - Replace bus pm_notify with the standard runtime PM framework · 55ed9cd1
      Takashi Iwai 提交于
      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: NTakashi Iwai <tiwai@suse.de>
      55ed9cd1
    • T
      ALSA: hda - Drop power_save value indirection in hda_bus · bb573928
      Takashi Iwai 提交于
      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: NTakashi Iwai <tiwai@suse.de>
      bb573928
  9. 23 2月, 2015 3 次提交
    • T
      ALSA: hda - Use standard runtime PM for codec power-save control · cc72da7d
      Takashi Iwai 提交于
      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: NTakashi Iwai <tiwai@suse.de>
      cc72da7d
    • T
      ALSA: hda - Move codec suspend/resume to codec driver · 59ed1ead
      Takashi Iwai 提交于
      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: NTakashi Iwai <tiwai@suse.de>
      59ed1ead
    • T
      ALSA: hda - Bind codecs via standard bus · d8a766a1
      Takashi Iwai 提交于
      Now we create the standard HD-audio bus (/sys/bus/hdaudio), and bind
      the codec driver with the codec device over there.  This is the first
      step of the whole transition so that the changes to each codec driver
      are kept as minimal as possible.
      
      Each codec driver needs to register hda_codec_driver struct containing
      the currently existing preset via the new helper macro
      module_hda_codec_driver().  The old hda_codec_preset_list is replaced
      with this infrastructure.  The generic parsers (for HDMI and other)
      are also included in the preset with the special IDs to bind
      uniquely.
      
      In HD-audio core side, the device binding code is split to
      hda_bind.c.  It provides the snd_hda_bus_type implementation to match
      the codec driver with the given codec vendor ID.  It also manages the
      module auto-loading by itself like before: when the matching isn't
      found, it tries to probe the corresponding codec modules, and finally
      falls back to the generic drivers.  (The special ID mentioned above is
      set at this stage.)
      
      The only visible change to outside is that the hdaudio sysfs entry now
      appears in /sys/bus/devices, not as a sound class device.
      
      More works to move the suspend/resume and remove ops will be
      (hopefully) done in later patches.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      d8a766a1
  10. 20 2月, 2015 1 次提交
  11. 17 2月, 2015 2 次提交
  12. 27 11月, 2014 1 次提交
  13. 17 11月, 2014 1 次提交
  14. 29 10月, 2014 2 次提交