Lines Matching full:codec

26 static int codec_pm_lock(struct hdac_device *codec)  in codec_pm_lock()  argument
28 return snd_hdac_keep_power_up(codec); in codec_pm_lock()
31 static void codec_pm_unlock(struct hdac_device *codec, int lock) in codec_pm_unlock() argument
34 snd_hdac_power_down_pm(codec); in codec_pm_unlock()
41 struct hdac_device *codec = dev_to_hdac_dev(dev); in hda_volatile_reg() local
46 return !codec->cache_coef; in hda_volatile_reg()
68 struct hdac_device *codec = dev_to_hdac_dev(dev); in hda_writeable_reg() local
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()
117 struct hdac_device *codec = dev_to_hdac_dev(dev); in hda_readable_reg() local
120 if (codec->caps_overwriting) in hda_readable_reg()
157 static int hda_reg_read_stereo_amp(struct hdac_device *codec, in hda_reg_read_stereo_amp() argument
164 err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_LEFT, 0, &left); in hda_reg_read_stereo_amp()
167 err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_RIGHT, 0, &right); in hda_reg_read_stereo_amp()
175 static int hda_reg_write_stereo_amp(struct hdac_device *codec, in hda_reg_write_stereo_amp() argument
192 return snd_hdac_exec_verb(codec, reg | left, 0, NULL); in hda_reg_write_stereo_amp()
195 err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_LEFT | left, 0, NULL); in hda_reg_write_stereo_amp()
198 err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_RIGHT | right, 0, NULL); in hda_reg_write_stereo_amp()
205 static int hda_reg_read_coef(struct hdac_device *codec, unsigned int reg, in hda_reg_read_coef() argument
211 if (!codec->cache_coef) in hda_reg_read_coef()
215 err = snd_hdac_exec_verb(codec, verb, 0, NULL); in hda_reg_read_coef()
219 return snd_hdac_exec_verb(codec, verb, 0, val); in hda_reg_read_coef()
223 static int hda_reg_write_coef(struct hdac_device *codec, unsigned int reg, in hda_reg_write_coef() argument
229 if (!codec->cache_coef) in hda_reg_write_coef()
233 err = snd_hdac_exec_verb(codec, verb, 0, NULL); in hda_reg_write_coef()
238 return snd_hdac_exec_verb(codec, verb, 0, NULL); in hda_reg_write_coef()
243 struct hdac_device *codec = context; in hda_reg_read() local
249 pm_lock = codec_pm_lock(codec); in hda_reg_read()
253 reg |= (codec->addr << 28); in hda_reg_read()
255 err = hda_reg_read_stereo_amp(codec, reg, val); in hda_reg_read()
259 err = hda_reg_read_coef(codec, reg, val); in hda_reg_read()
265 err = snd_hdac_exec_verb(codec, reg, 0, val); in hda_reg_read()
276 codec_pm_unlock(codec, pm_lock); in hda_reg_read()
282 struct hdac_device *codec = context; in hda_reg_write() local
287 if (codec->caps_overwriting) in hda_reg_write()
291 reg |= (codec->addr << 28); in hda_reg_write()
295 pm_lock = codec_pm_lock(codec); in hda_reg_write()
297 return codec->lazy_cache ? 0 : -EAGAIN; in hda_reg_write()
301 err = hda_reg_write_stereo_amp(codec, reg, val); in hda_reg_write()
306 err = hda_reg_write_coef(codec, reg, val); in hda_reg_write()
343 err = snd_hdac_exec_verb(codec, reg, 0, NULL); in hda_reg_write()
349 codec_pm_unlock(codec, pm_lock); in hda_reg_write()
371 * @codec: the codec object
375 int snd_hdac_regmap_init(struct hdac_device *codec) in snd_hdac_regmap_init() argument
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_exit - Release the regmap from HDA codec
390 * @codec: the codec object
392 void snd_hdac_regmap_exit(struct hdac_device *codec) in snd_hdac_regmap_exit() argument
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()
404 * @codec: the codec object
409 int snd_hdac_regmap_add_vendor_verb(struct hdac_device *codec, in snd_hdac_regmap_add_vendor_verb() argument
412 unsigned int *p = snd_array_new(&codec->vendor_verbs); in snd_hdac_regmap_add_vendor_verb()
426 static int reg_raw_write(struct hdac_device *codec, unsigned int reg, in reg_raw_write() argument
431 mutex_lock(&codec->regmap_lock); in reg_raw_write()
432 if (!codec->regmap) in reg_raw_write()
433 err = hda_reg_write(codec, reg, val); 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()
441 #define CALL_RAW_FUNC(codec, func_call) \ argument
445 _err = snd_hdac_power_up_pm(codec); \
448 snd_hdac_power_down_pm(codec); \
454 * @codec: the codec object
460 int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg, in snd_hdac_regmap_write_raw() argument
463 return CALL_RAW_FUNC(codec, reg_raw_write(codec, reg, val)); in snd_hdac_regmap_write_raw()
467 static int reg_raw_read(struct hdac_device *codec, unsigned int reg, in reg_raw_read() argument
472 mutex_lock(&codec->regmap_lock); in reg_raw_read()
473 if (uncached || !codec->regmap) in reg_raw_read()
474 err = hda_reg_read(codec, reg, val); 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()
481 static int __snd_hdac_regmap_read_raw(struct hdac_device *codec, in __snd_hdac_regmap_read_raw() argument
485 return CALL_RAW_FUNC(codec, reg_raw_read(codec, reg, val, uncached)); in __snd_hdac_regmap_read_raw()
490 * @codec: the codec object
496 int snd_hdac_regmap_read_raw(struct hdac_device *codec, unsigned int reg, in snd_hdac_regmap_read_raw() argument
499 return __snd_hdac_regmap_read_raw(codec, reg, val, false); in snd_hdac_regmap_read_raw()
506 int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec, in snd_hdac_regmap_read_raw_uncached() argument
509 return __snd_hdac_regmap_read_raw(codec, reg, val, true); in snd_hdac_regmap_read_raw_uncached()
512 static int reg_raw_update(struct hdac_device *codec, unsigned int reg, 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()
526 err = hda_reg_read(codec, reg, &orig); in reg_raw_update()
531 err = hda_reg_write(codec, reg, val); in reg_raw_update()
537 mutex_unlock(&codec->regmap_lock); in reg_raw_update()
543 * @codec: the codec object
550 int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg, 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()
557 static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg, 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()
578 * @codec: the codec object
587 int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg, 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()
596 * @codec: the codec object
598 void snd_hdac_regmap_sync(struct hdac_device *codec) in snd_hdac_regmap_sync() argument
600 if (codec->regmap) { in snd_hdac_regmap_sync()
601 mutex_lock(&codec->regmap_lock); 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()