Lines Matching refs:codec
26 static int codec_pm_lock(struct hdac_device *codec)
28 return snd_hdac_keep_power_up(codec);
31 static void codec_pm_unlock(struct hdac_device *codec, int lock)
34 snd_hdac_power_down_pm(codec);
41 struct hdac_device *codec = dev_to_hdac_dev(dev);
46 return !codec->cache_coef;
68 struct hdac_device *codec = dev_to_hdac_dev(dev);
73 snd_array_for_each(&codec->vendor_verbs, i, v) {
78 if (codec->caps_overwriting)
86 return codec->cache_coef;
117 struct hdac_device *codec = dev_to_hdac_dev(dev);
120 if (codec->caps_overwriting)
157 static int hda_reg_read_stereo_amp(struct hdac_device *codec,
164 err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_LEFT, 0, &left);
167 err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_RIGHT, 0, &right);
175 static int hda_reg_write_stereo_amp(struct hdac_device *codec,
192 return snd_hdac_exec_verb(codec, reg | left, 0, NULL);
195 err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_LEFT | left, 0, NULL);
198 err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_RIGHT | right, 0, NULL);
205 static int hda_reg_read_coef(struct hdac_device *codec, unsigned int reg,
211 if (!codec->cache_coef)
215 err = snd_hdac_exec_verb(codec, verb, 0, NULL);
219 return snd_hdac_exec_verb(codec, verb, 0, val);
223 static int hda_reg_write_coef(struct hdac_device *codec, unsigned int reg,
229 if (!codec->cache_coef)
233 err = snd_hdac_exec_verb(codec, verb, 0, NULL);
238 return snd_hdac_exec_verb(codec, verb, 0, NULL);
243 struct hdac_device *codec = context;
249 pm_lock = codec_pm_lock(codec);
253 reg |= (codec->addr << 28);
255 err = hda_reg_read_stereo_amp(codec, reg, val);
259 err = hda_reg_read_coef(codec, reg, val);
265 err = snd_hdac_exec_verb(codec, reg, 0, val);
276 codec_pm_unlock(codec, pm_lock);
282 struct hdac_device *codec = context;
287 if (codec->caps_overwriting)
291 reg |= (codec->addr << 28);
295 pm_lock = codec_pm_lock(codec);
297 return codec->lazy_cache ? 0 : -EAGAIN;
301 err = hda_reg_write_stereo_amp(codec, reg, val);
306 err = hda_reg_write_coef(codec, reg, val);
343 err = snd_hdac_exec_verb(codec, reg, 0, NULL);
349 codec_pm_unlock(codec, pm_lock);
371 * @codec: the codec object
375 int snd_hdac_regmap_init(struct hdac_device *codec)
379 regmap = regmap_init(&codec->dev, NULL, codec, &hda_regmap_cfg);
382 codec->regmap = regmap;
383 snd_array_init(&codec->vendor_verbs, sizeof(unsigned int), 8);
389 * snd_hdac_regmap_init - Release the regmap from HDA codec
390 * @codec: the codec object
392 void snd_hdac_regmap_exit(struct hdac_device *codec)
394 if (codec->regmap) {
395 regmap_exit(codec->regmap);
396 codec->regmap = NULL;
397 snd_array_free(&codec->vendor_verbs);
404 * @codec: the codec object
409 int snd_hdac_regmap_add_vendor_verb(struct hdac_device *codec,
412 unsigned int *p = snd_array_new(&codec->vendor_verbs);
426 static int reg_raw_write(struct hdac_device *codec, unsigned int reg,
431 mutex_lock(&codec->regmap_lock);
432 if (!codec->regmap)
433 err = hda_reg_write(codec, reg, val);
435 err = regmap_write(codec->regmap, reg, val);
436 mutex_unlock(&codec->regmap_lock);
441 #define CALL_RAW_FUNC(codec, func_call) \
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,
463 return CALL_RAW_FUNC(codec, reg_raw_write(codec, reg, val));
467 static int reg_raw_read(struct hdac_device *codec, unsigned int reg,
472 mutex_lock(&codec->regmap_lock);
473 if (uncached || !codec->regmap)
474 err = hda_reg_read(codec, reg, val);
476 err = regmap_read(codec->regmap, reg, val);
477 mutex_unlock(&codec->regmap_lock);
481 static int __snd_hdac_regmap_read_raw(struct hdac_device *codec,
485 return CALL_RAW_FUNC(codec, reg_raw_read(codec, reg, val, uncached));
490 * @codec: the codec object
496 int snd_hdac_regmap_read_raw(struct hdac_device *codec, unsigned int reg,
499 return __snd_hdac_regmap_read_raw(codec, reg, val, false);
506 int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec,
509 return __snd_hdac_regmap_read_raw(codec, reg, val, true);
512 static int reg_raw_update(struct hdac_device *codec, unsigned int reg,
519 mutex_lock(&codec->regmap_lock);
520 if (codec->regmap) {
521 err = regmap_update_bits_check(codec->regmap, reg, mask, val,
526 err = hda_reg_read(codec, reg, &orig);
531 err = hda_reg_write(codec, reg, val);
537 mutex_unlock(&codec->regmap_lock);
543 * @codec: the codec object
550 int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg,
553 return CALL_RAW_FUNC(codec, reg_raw_update(codec, reg, mask, val));
557 static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg,
563 if (!codec->regmap)
564 return reg_raw_update(codec, reg, mask, val);
566 mutex_lock(&codec->regmap_lock);
567 regcache_cache_only(codec->regmap, true);
568 err = regmap_read(codec->regmap, reg, &orig);
569 regcache_cache_only(codec->regmap, false);
571 err = regmap_update_bits(codec->regmap, reg, mask, val);
572 mutex_unlock(&codec->regmap_lock);
578 * @codec: the codec object
587 int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg,
590 return CALL_RAW_FUNC(codec, reg_raw_update_once(codec, reg, mask, val));
596 * @codec: the codec object
598 void snd_hdac_regmap_sync(struct hdac_device *codec)
600 mutex_lock(&codec->regmap_lock);
601 if (codec->regmap)
602 regcache_sync(codec->regmap);
603 mutex_unlock(&codec->regmap_lock);