11 Jun, 2015

1 commit

  • Yet another regression by the transition to regmap cache; for better
    usability, we had the fake mute control using the zero amp value for
    Conexant codecs, and this was forgotten in the new hda core code.

    Since the bits 4-7 are unused for the amp registers (as we follow the
    syntax of AMP_GET verb), the bit 4 is now used to indicate the fake
    mute. For setting this flag, snd_hda_codec_amp_update() becomes a
    function from a simple macro. The bonus is that it gained a proper
    function description.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

10 Jun, 2015

1 commit

  • Along with the transition to regmap for managing the cached parameter
    reads, the caps overwrite was also moved to regmap cache. The cache
    change itself works, but it still tries to write the non-existing verb
    (the HDA parameter is read-only) wrongly. It's harmless in most
    cases, but some chips are picky and may result in the codec
    communication stall.

    This patch avoids it just by adding the missing flag check in
    reg_write ops.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

14 Apr, 2015

1 commit

  • Some HD-A codecs may add their own vendor 'set' verb to the regmap, thru func
    snd_hdac_add_vendor_verb(). This patch sets the GET bit (bit 11) when adding
    the verb so that its peer vendor 'get' verb is actually added. This can avoid
    I/O error when writing the 'set' verb thru remap, since HD-A regmap internally
    looks up a writable vendor verb with GET bit set at first.

    Signed-off-by: Mengdong Lin
    Signed-off-by: Takashi Iwai

    Mengdong Lin
     

13 Apr, 2015

2 commits

  • Although some races in runtime PM refcount was fixed by the commit
    [664c715573c2: ALSA: hda - Work around races of power up/down with
    runtime PM], there is still a race in the following case:

    CPU0: CPU1 :
    runtime suspend:
    codec->in_pm = 1
    snd_hdac_power_up_pm():
    pm_runtime_get_sync() skipped
    suspend finished:
    codec->in_pm = 0
    snd_hdac_power_down_pm():
    pm_runtime_put_*() is called!

    For avoiding this situation, increment in_pm flag atomically when it's
    non-zero, and decrement accordingly, to ensure that in_pm is set
    consistently for the whole concurrent operations.

    Also, since atomic_inc_not_zero() and atomic_dec_if_positive() are
    lengthy inline functions, move snd_hdac_power_up_pm() and _down_pm()
    to sound/hda/hdac_device.c as no inline functions.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • The type field of HD-audio codec object should be exposed to
    user-space so that it can identify which driver type to bind (legacy /
    asoc).

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

09 Apr, 2015

1 commit


08 Apr, 2015

2 commits

  • 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=96271
    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • ... so that user-space can know that the whole nodes have been
    created. Unfortunately, this can't be implemented easily in race-free
    way, so it's a kind of compromise.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

04 Apr, 2015

2 commits


27 Mar, 2015

1 commit


26 Mar, 2015

1 commit

  • Although they can be written, handle a few verbs as read-only in
    regmap interface: CONFIG_DEFAULT, CONV and CVT_CHAN_COUNT. These are
    either updated in PCM or HDMI management code in a volatile manner, or
    just needed only as parameter, thus they don't need to be written at
    resume sync.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     

23 Mar, 2015

16 commits

  • The 16bit COEF read/write is pretty standard for many codecs, and they
    can be cached in most cases -- more importantly, they need to be
    restored at resume. For making this easier, add the cache support to
    regmap. If the codec driver wants to cache the COEF access, set
    codec->cache_coef flag and issue AC_VERB_GET_PROC_COEF with the coef
    index in LSB 8 bits.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • HD-audio has quite a few asymmetrical ways of accessing verbs, and one
    of typical ones is GET/SET_POWER_STATE verbs. While it takes only the
    power state for setting, it returns a combination of states for
    getting. For making the state handling simpler, this patch adds a
    code to translate the value returned from GET_POWER_STATE to return
    only the actual state or -1 for error. In that way, the driver can
    simplify the power state management.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • HD-audio spec is inconvenient regarding the handling of stereo volume
    controls. It can set and get only single channel at once (although
    there is a special option to set the same value to both channels).
    This patch provides a fake pseudo-register via the regmap access so
    that the stereo channels can be read and written by a single call.
    It'd be useful, for example, for implementing DAPM widgets.

    A stereo amp pseudo register consists of the encoding like the normal
    amp verbs but it has both SET_LEFT (bit 13) and SET_RIGHT (bit 12)
    bits set. The regmap reads and writes a 16bit value for this pseudo
    register where the upper 8bit is for the right chanel and the lower
    8bit for the left channel.

    Note that the driver doesn't recognize conflicts when both stereo and
    mono channel registers are mixed. Mixing them would certainly confuse
    the operation. So, use carefully.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Codecs may have own vendor-specific verbs, and we need to allow each
    driver to give such verbs for cached accesses. Here a verb can be put
    into a single array and looked through it at readable and writeable
    callbacks.

    Signed-off-by: Takashi Iwai

    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: Takashi Iwai

    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: Takashi Iwai

    Takashi Iwai
     
  • Let's start converting the access functions to regmap.
    The first one is the simplest, just converting the codec parameter
    read helper function snd_hda_param_read().

    Signed-off-by: Takashi Iwai

    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: Takashi Iwai

    Takashi Iwai
     
  • This will be used by the regmap support.

    Signed-off-by: Takashi Iwai

    Takashi Iwai
     
  • Now let's take the basic tracepoints back to the HD-audio driver.
    The three bus tracepoints, hda_send_cmd, hda_get_response and
    hda_unsol_event are revived but in a slightly different form.
    Since we don't assign the card number there, print the bus device name
    instead.

    Signed-off-by: Takashi Iwai

    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: Takashi Iwai

    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: Takashi Iwai

    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: Takashi Iwai

    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: Takashi Iwai

    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: Takashi Iwai

    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: Takashi Iwai

    Takashi Iwai