Lines Matching +full:sync +full:- +full:update +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Regmap support for HD-audio verbs
9 * - Provided for not all verbs but only subset standard non-volatile verbs.
10 * - For reading, only AC_VERB_GET_* variants can be used.
11 * - For writing, mapped to the *corresponding* AC_VERB_SET_* variants,
46 return !codec->cache_coef; in hda_volatile_reg()
59 case AC_VERB_GET_DEVICE_LIST: /* read-only volatile */ in hda_volatile_reg()
73 snd_array_for_each(&codec->vendor_verbs, i, v) { in hda_writeable_reg()
78 if (codec->caps_overwriting) in hda_writeable_reg()
86 return codec->cache_coef; in hda_writeable_reg()
120 if (codec->caps_overwriting) in hda_readable_reg()
129 * writes at sync in hda_readable_reg()
211 if (!codec->cache_coef) in hda_reg_read_coef()
212 return -EINVAL; in hda_reg_read_coef()
229 if (!codec->cache_coef) in hda_reg_write_coef()
230 return -EINVAL; in hda_reg_write_coef()
251 return -EAGAIN; in hda_reg_read()
253 reg |= (codec->addr << 28); in hda_reg_read()
271 *val = -1; in hda_reg_read()
287 if (codec->caps_overwriting) in hda_reg_write()
291 reg |= (codec->addr << 28); in hda_reg_write()
297 return codec->lazy_cache ? 0 : -EAGAIN; in hda_reg_write()
370 * snd_hdac_regmap_init - Initialize regmap for HDA register accesses
379 regmap = regmap_init(&codec->dev, NULL, codec, &hda_regmap_cfg); in snd_hdac_regmap_init()
382 codec->regmap = regmap; in snd_hdac_regmap_init()
383 snd_array_init(&codec->vendor_verbs, sizeof(unsigned int), 8); in snd_hdac_regmap_init()
389 * snd_hdac_regmap_init - Release the regmap from HDA codec
394 if (codec->regmap) { in snd_hdac_regmap_exit()
395 regmap_exit(codec->regmap); in snd_hdac_regmap_exit()
396 codec->regmap = NULL; in snd_hdac_regmap_exit()
397 snd_array_free(&codec->vendor_verbs); in snd_hdac_regmap_exit()
403 * snd_hdac_regmap_add_vendor_verb - add a vendor-specific verb to regmap
412 unsigned int *p = snd_array_new(&codec->vendor_verbs); in snd_hdac_regmap_add_vendor_verb()
415 return -ENOMEM; in snd_hdac_regmap_add_vendor_verb()
425 /* write a pseudo-register value (w/o power sequence) */
431 mutex_lock(&codec->regmap_lock); in reg_raw_write()
432 if (!codec->regmap) in reg_raw_write()
435 err = regmap_write(codec->regmap, reg, val); in reg_raw_write()
436 mutex_unlock(&codec->regmap_lock); in reg_raw_write()
440 /* a helper macro to call @func_call; retry with power-up if failed */
444 if (_err == -EAGAIN) { \
453 * snd_hdac_regmap_write_raw - write a pseudo register with power mgmt
472 mutex_lock(&codec->regmap_lock); in reg_raw_read()
473 if (uncached || !codec->regmap) in reg_raw_read()
476 err = regmap_read(codec->regmap, reg, val); in reg_raw_read()
477 mutex_unlock(&codec->regmap_lock); in reg_raw_read()
489 * snd_hdac_regmap_read_raw - read a pseudo register with power mgmt
513 unsigned int mask, unsigned int val) in reg_raw_update() argument
519 mutex_lock(&codec->regmap_lock); in reg_raw_update()
520 if (codec->regmap) { in reg_raw_update()
521 err = regmap_update_bits_check(codec->regmap, reg, mask, val, in reg_raw_update()
528 val &= mask; in reg_raw_update()
529 val |= orig & ~mask; in reg_raw_update()
537 mutex_unlock(&codec->regmap_lock); in reg_raw_update()
542 * snd_hdac_regmap_update_raw - update a pseudo register with power mgmt
545 * @mask: bit mask to update
546 * @val: value to update
551 unsigned int mask, unsigned int val) in snd_hdac_regmap_update_raw() argument
553 return CALL_RAW_FUNC(codec, reg_raw_update(codec, reg, mask, val)); in snd_hdac_regmap_update_raw()
558 unsigned int mask, unsigned int val) in reg_raw_update_once() argument
563 if (!codec->regmap) in reg_raw_update_once()
564 return reg_raw_update(codec, reg, mask, val); in reg_raw_update_once()
566 mutex_lock(&codec->regmap_lock); in reg_raw_update_once()
567 regcache_cache_only(codec->regmap, true); in reg_raw_update_once()
568 err = regmap_read(codec->regmap, reg, &orig); in reg_raw_update_once()
569 regcache_cache_only(codec->regmap, false); in reg_raw_update_once()
571 err = regmap_update_bits(codec->regmap, reg, mask, val); in reg_raw_update_once()
572 mutex_unlock(&codec->regmap_lock); in reg_raw_update_once()
577 * snd_hdac_regmap_update_raw_once - initialize the register value only once
580 * @mask: bit mask to update
581 * @val: value to update
583 * Performs the update of the register bits only once when the register
584 * hasn't been initialized yet. Used in HD-audio legacy driver.
588 unsigned int mask, unsigned int val) in snd_hdac_regmap_update_raw_once() argument
590 return CALL_RAW_FUNC(codec, reg_raw_update_once(codec, reg, mask, val)); in snd_hdac_regmap_update_raw_once()
595 * snd_hdac_regmap_sync - sync out the cached values for PM resume
600 mutex_lock(&codec->regmap_lock); in snd_hdac_regmap_sync()
601 if (codec->regmap) in snd_hdac_regmap_sync()
602 regcache_sync(codec->regmap); in snd_hdac_regmap_sync()
603 mutex_unlock(&codec->regmap_lock); in snd_hdac_regmap_sync()