Lines Matching refs:codec

25 static int codec_pm_lock(struct hdac_device *codec)
27 return snd_hdac_keep_power_up(codec);
30 static void codec_pm_unlock(struct hdac_device *codec, int lock)
33 snd_hdac_power_down_pm(codec);
40 struct hdac_device *codec = dev_to_hdac_dev(dev);
45 return !codec->cache_coef;
67 struct hdac_device *codec = dev_to_hdac_dev(dev);
72 snd_array_for_each(&codec->vendor_verbs, i, v) {
77 if (codec->caps_overwriting)
85 return codec->cache_coef;
116 struct hdac_device *codec = dev_to_hdac_dev(dev);
119 if (codec->caps_overwriting)
156 static int hda_reg_read_stereo_amp(struct hdac_device *codec,
163 err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_LEFT, 0, &left);
166 err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_RIGHT, 0, &right);
174 static int hda_reg_write_stereo_amp(struct hdac_device *codec,
191 return snd_hdac_exec_verb(codec, reg | left, 0, NULL);
194 err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_LEFT | left, 0, NULL);
197 err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_RIGHT | right, 0, NULL);
204 static int hda_reg_read_coef(struct hdac_device *codec, unsigned int reg,
210 if (!codec->cache_coef)
214 err = snd_hdac_exec_verb(codec, verb, 0, NULL);
218 return snd_hdac_exec_verb(codec, verb, 0, val);
222 static int hda_reg_write_coef(struct hdac_device *codec, unsigned int reg,
228 if (!codec->cache_coef)
232 err = snd_hdac_exec_verb(codec, verb, 0, NULL);
237 return snd_hdac_exec_verb(codec, verb, 0, NULL);
242 struct hdac_device *codec = context;
248 pm_lock = codec_pm_lock(codec);
252 reg |= (codec->addr << 28);
254 err = hda_reg_read_stereo_amp(codec, reg, val);
258 err = hda_reg_read_coef(codec, reg, val);
264 err = snd_hdac_exec_verb(codec, reg, 0, val);
275 codec_pm_unlock(codec, pm_lock);
281 struct hdac_device *codec = context;
286 if (codec->caps_overwriting)
290 reg |= (codec->addr << 28);
294 pm_lock = codec_pm_lock(codec);
296 return codec->lazy_cache ? 0 : -EAGAIN;
300 err = hda_reg_write_stereo_amp(codec, reg, val);
305 err = hda_reg_write_coef(codec, reg, val);
342 err = snd_hdac_exec_verb(codec, reg, 0, NULL);
348 codec_pm_unlock(codec, pm_lock);
370 * @codec: the codec object
374 int snd_hdac_regmap_init(struct hdac_device *codec)
378 regmap = regmap_init(&codec->dev, NULL, codec, &hda_regmap_cfg);
381 codec->regmap = regmap;
382 snd_array_init(&codec->vendor_verbs, sizeof(unsigned int), 8);
388 * snd_hdac_regmap_exit - Release the regmap from HDA codec
389 * @codec: the codec object
391 void snd_hdac_regmap_exit(struct hdac_device *codec)
393 if (codec->regmap) {
394 regmap_exit(codec->regmap);
395 codec->regmap = NULL;
396 snd_array_free(&codec->vendor_verbs);
403 * @codec: the codec object
408 int snd_hdac_regmap_add_vendor_verb(struct hdac_device *codec,
411 unsigned int *p = snd_array_new(&codec->vendor_verbs);
425 static int reg_raw_write(struct hdac_device *codec, unsigned int reg,
430 mutex_lock(&codec->regmap_lock);
431 if (!codec->regmap)
432 err = hda_reg_write(codec, reg, val);
434 err = regmap_write(codec->regmap, reg, val);
435 mutex_unlock(&codec->regmap_lock);
440 #define CALL_RAW_FUNC(codec, func_call) \
444 _err = snd_hdac_power_up_pm(codec); \
447 snd_hdac_power_down_pm(codec); \
453 * @codec: the codec object
459 int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg,
462 return CALL_RAW_FUNC(codec, reg_raw_write(codec, reg, val));
466 static int reg_raw_read(struct hdac_device *codec, unsigned int reg,
471 mutex_lock(&codec->regmap_lock);
472 if (uncached || !codec->regmap)
473 err = hda_reg_read(codec, reg, val);
475 err = regmap_read(codec->regmap, reg, val);
476 mutex_unlock(&codec->regmap_lock);
480 static int __snd_hdac_regmap_read_raw(struct hdac_device *codec,
484 return CALL_RAW_FUNC(codec, reg_raw_read(codec, reg, val, uncached));
489 * @codec: the codec object
495 int snd_hdac_regmap_read_raw(struct hdac_device *codec, unsigned int reg,
498 return __snd_hdac_regmap_read_raw(codec, reg, val, false);
505 int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec,
508 return __snd_hdac_regmap_read_raw(codec, reg, val, true);
511 static int reg_raw_update(struct hdac_device *codec, unsigned int reg,
518 mutex_lock(&codec->regmap_lock);
519 if (codec->regmap) {
520 err = regmap_update_bits_check(codec->regmap, reg, mask, val,
525 err = hda_reg_read(codec, reg, &orig);
530 err = hda_reg_write(codec, reg, val);
536 mutex_unlock(&codec->regmap_lock);
542 * @codec: the codec object
549 int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg,
552 return CALL_RAW_FUNC(codec, reg_raw_update(codec, reg, mask, val));
556 static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg,
561 if (!codec->regmap)
562 return reg_raw_update(codec, reg, mask, val);
564 mutex_lock(&codec->regmap_lock);
566 if (!regcache_reg_cached(codec->regmap, reg))
567 err = regmap_update_bits(codec->regmap, reg, mask, val);
568 mutex_unlock(&codec->regmap_lock);
574 * @codec: the codec object
583 int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg,
586 return CALL_RAW_FUNC(codec, reg_raw_update_once(codec, reg, mask, val));
592 * @codec: the codec object
594 void snd_hdac_regmap_sync(struct hdac_device *codec)
596 mutex_lock(&codec->regmap_lock);
597 if (codec->regmap)
598 regcache_sync(codec->regmap);
599 mutex_unlock(&codec->regmap_lock);