Lines Matching +full:pdm +full:- +full:mute

1 // SPDX-License-Identifier: GPL-2.0+
71 aw883xx->aw_pa->platform = AW_QCOM; in aw883xx_platform_init()
74 aw883xx->aw_pa->platform = AW_MTK; in aw883xx_platform_init()
77 aw883xx->aw_pa->platform = AW_SPRD; in aw883xx_platform_init()
80 return -EINVAL; in aw883xx_platform_init()
90 return -ENOMEM; in aw883xx_get_version()
116 int i2cbus = aw883xx->i2c->adapter->nr; in aw883xx_append_i2c_suffix()
117 int addr = aw883xx->i2c->addr; in aw883xx_append_i2c_suffix()
120 *change_name = aw883xx_devm_kstrdup(aw883xx->dev, buf); in aw883xx_append_i2c_suffix()
122 return -ENOMEM; in aw883xx_append_i2c_suffix()
124 aw_dev_info(aw883xx->dev, "change name :%s", *change_name); in aw883xx_append_i2c_suffix()
155 return dai->component; in aw883xx_get_codec()
157 return dai->codec; in aw883xx_get_codec()
170 int ret = -1; in aw883xx_i2c_writes()
175 aw_dev_err(aw883xx->dev, "can not allocate memory"); in aw883xx_i2c_writes()
176 return -ENOMEM; in aw883xx_i2c_writes()
182 ret = i2c_master_send(aw883xx->i2c, data, len + 1); in aw883xx_i2c_writes()
184 aw_dev_err(aw883xx->dev, "i2c master send error"); in aw883xx_i2c_writes()
187 aw_dev_err(aw883xx->dev, "i2c master send error(size error)"); in aw883xx_i2c_writes()
188 ret = -ENXIO; in aw883xx_i2c_writes()
209 .addr = aw883xx->i2c->addr, in aw883xx_i2c_reads()
215 .addr = aw883xx->i2c->addr, in aw883xx_i2c_reads()
222 ret = i2c_transfer(aw883xx->i2c->adapter, msg, ARRAY_SIZE(msg)); in aw883xx_i2c_reads()
224 aw_dev_err(aw883xx->dev, "i2c_transfer failed"); in aw883xx_i2c_reads()
227 aw_dev_err(aw883xx->dev, "transfer failed(size error)"); in aw883xx_i2c_reads()
228 return -ENXIO; in aw883xx_i2c_reads()
237 int ret = -1; in aw883xx_i2c_write()
247 aw_dev_err(aw883xx->dev, "i2c_write cnt=%d error=%d", in aw883xx_i2c_write()
254 if (aw883xx->i2c_log_en) in aw883xx_i2c_write()
255 aw_dev_info(aw883xx->dev, "write: reg = 0x%02x, val = 0x%04x", in aw883xx_i2c_write()
264 int ret = -1; in aw883xx_i2c_read()
271 aw_dev_err(aw883xx->dev, "i2c_read cnt=%d error=%d", in aw883xx_i2c_read()
280 if (aw883xx->i2c_log_en) in aw883xx_i2c_read()
281 aw_dev_info(aw883xx->dev, "read: reg = 0x%02x, val = 0x%04x", in aw883xx_i2c_read()
291 int ret = -1; in aw883xx_i2c_write_bits()
296 aw_dev_err(aw883xx->dev, "i2c read error, ret=%d", ret); in aw883xx_i2c_write_bits()
303 aw_dev_err(aw883xx->dev, "i2c read error, ret=%d", ret); in aw883xx_i2c_write_bits()
313 int ret = -1; in aw883xx_reg_write()
315 mutex_lock(&aw883xx->i2c_lock); in aw883xx_reg_write()
318 aw_dev_err(aw883xx->dev, in aw883xx_reg_write()
321 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_reg_write()
329 int ret = -1; in aw883xx_reg_read()
331 mutex_lock(&aw883xx->i2c_lock); in aw883xx_reg_read()
334 aw_dev_err(aw883xx->dev, in aw883xx_reg_read()
337 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_reg_read()
345 int ret = -1; in aw883xx_reg_write_bits()
347 mutex_lock(&aw883xx->i2c_lock); in aw883xx_reg_write_bits()
350 aw_dev_err(aw883xx->dev,"fail, ret=%d", ret); in aw883xx_reg_write_bits()
351 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_reg_write_bits()
360 struct aw_dsp_mem_desc *desc = &aw883xx->aw_pa->dsp_mem_desc; in aw883xx_dsp_write_16bit()
362 ret = aw883xx_i2c_write(aw883xx, desc->dsp_madd_reg, dsp_addr); in aw883xx_dsp_write_16bit()
364 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_write_16bit()
368 ret = aw883xx_i2c_write(aw883xx, desc->dsp_mdat_reg, (uint16_t)dsp_data); in aw883xx_dsp_write_16bit()
370 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_write_16bit()
382 struct aw_dsp_mem_desc *desc = &aw883xx->aw_pa->dsp_mem_desc; in aw883xx_dsp_write_32bit()
384 ret = aw883xx_i2c_write(aw883xx, desc->dsp_madd_reg, dsp_addr); in aw883xx_dsp_write_32bit()
386 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_write_32bit()
391 ret = aw883xx_i2c_write(aw883xx, desc->dsp_mdat_reg, temp_data); in aw883xx_dsp_write_32bit()
393 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_write_32bit()
398 ret = aw883xx_i2c_write(aw883xx, desc->dsp_mdat_reg, temp_data); in aw883xx_dsp_write_32bit()
400 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_write_32bit()
413 uint8_t reg = aw883xx->aw_pa->soft_rst.reg; in aw883xx_clear_dsp_sel_st()
421 int ret = -1; in aw883xx_dsp_write()
423 mutex_lock(&aw883xx->i2c_lock); in aw883xx_dsp_write()
427 aw_dev_err(aw883xx->dev, "write dsp_addr[0x%04x] 16 bit dsp_data[%04x] failed", in aw883xx_dsp_write()
434 aw_dev_err(aw883xx->dev, "write dsp_addr[0x%04x] 32 bit dsp_data[%08x] failed", in aw883xx_dsp_write()
439 aw_dev_err(aw883xx->dev, "data type[%d] unsupported", data_type); in aw883xx_dsp_write()
440 ret = -EINVAL; in aw883xx_dsp_write()
446 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_dsp_write()
456 struct aw_dsp_mem_desc *desc = &aw883xx->aw_pa->dsp_mem_desc; in aw883xx_dsp_read_16bit()
458 ret = aw883xx_i2c_write(aw883xx, desc->dsp_madd_reg, dsp_addr); in aw883xx_dsp_read_16bit()
460 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_read_16bit()
464 ret = aw883xx_i2c_read(aw883xx, desc->dsp_mdat_reg, &temp_data); in aw883xx_dsp_read_16bit()
466 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_read_16bit()
480 struct aw_dsp_mem_desc *desc = &aw883xx->aw_pa->dsp_mem_desc; in aw883xx_dsp_read_32bit()
483 ret = aw883xx_i2c_write(aw883xx, desc->dsp_madd_reg, dsp_addr); in aw883xx_dsp_read_32bit()
485 aw_dev_err(aw883xx->dev, "i2c write error, ret=%d", ret); in aw883xx_dsp_read_32bit()
490 ret = aw883xx_i2c_read(aw883xx, desc->dsp_mdat_reg, &temp_data); in aw883xx_dsp_read_32bit()
492 aw_dev_err(aw883xx->dev, "i2c read error, ret=%d", ret); in aw883xx_dsp_read_32bit()
499 ret = aw883xx_i2c_read(aw883xx, desc->dsp_mdat_reg, &temp_data); in aw883xx_dsp_read_32bit()
501 aw_dev_err(aw883xx->dev, "i2c read error, ret=%d", ret); in aw883xx_dsp_read_32bit()
512 int ret = -1; in aw883xx_dsp_read()
514 mutex_lock(&aw883xx->i2c_lock); in aw883xx_dsp_read()
518 aw_dev_err(aw883xx->dev, "read dsp_addr[0x%04x] 16 bit dsp_data[%04x] failed", in aw883xx_dsp_read()
525 aw_dev_err(aw883xx->dev, "read dsp_addr[0x%04x] 32 bit dsp_data[%08x] failed", in aw883xx_dsp_read()
530 aw_dev_err(aw883xx->dev, "data type[%d] unsupported", data_type); in aw883xx_dsp_read()
531 ret = -EINVAL; in aw883xx_dsp_read()
537 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_dsp_read()
559 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_interrupt_work()
562 ret = aw_dev_get_int_status(aw883xx->aw_pa, &reg_value); in aw883xx_interrupt_work()
564 aw_dev_err(aw883xx->dev, "get init_reg value failed"); in aw883xx_interrupt_work()
566 aw_dev_info(aw883xx->dev, "int value 0x%x", reg_value); in aw883xx_interrupt_work()
569 aw_dev_clear_int_status(aw883xx->aw_pa); in aw883xx_interrupt_work()
572 aw_dev_set_intmask(aw883xx->aw_pa, true); in aw883xx_interrupt_work()
587 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in aw883xx_startup()
588 aw_dev_info(aw883xx->dev, "playback enter"); in aw883xx_startup()
590 if (AW_ERRO_CALI_RE_VALUE == aw883xx->aw_pa->cali_desc.cali_re) in aw883xx_startup()
591 aw_cali_get_cali_re(&aw883xx->aw_pa->cali_desc); in aw883xx_startup()
593 aw_dev_info(aw883xx->dev, "capture enter"); in aw883xx_startup()
605 aw_dev_info(codec->dev, "fmt=0x%x", fmt); in aw883xx_set_fmt()
607 /* supported mode: regular I2S, slave, or PDM */ in aw883xx_set_fmt()
612 aw_dev_err(codec->dev, "invalid codec master mode"); in aw883xx_set_fmt()
613 return -EINVAL; in aw883xx_set_fmt()
617 aw_dev_err(codec->dev, "unsupported DAI format %d", in aw883xx_set_fmt()
619 return -EINVAL; in aw883xx_set_fmt()
632 aw_dev_info(aw883xx->dev, "freq=%d", freq); in aw883xx_set_dai_sysclk()
634 aw883xx->sysclk = freq; in aw883xx_set_dai_sysclk()
647 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in aw883xx_hw_params()
648 aw_dev_info(aw883xx->dev, in aw883xx_hw_params()
654 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in aw883xx_hw_params()
655 aw_dev_info(aw883xx->dev, in aw883xx_hw_params()
667 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_start_pa()
669 if (aw883xx->allow_pw == false) { in aw883xx_start_pa()
670 aw_dev_info(aw883xx->dev, "dev can not allow power"); in aw883xx_start_pa()
674 if (aw883xx->pstream == AW883XX_STREAM_CLOSE) { in aw883xx_start_pa()
675 aw_dev_info(aw883xx->dev, "pstream is close"); in aw883xx_start_pa()
680 ret = aw_device_start(aw883xx->aw_pa); in aw883xx_start_pa()
682 aw_dev_err(aw883xx->dev, "start failed"); in aw883xx_start_pa()
683 ret = aw_dev_fw_update(aw883xx->aw_pa, AW_DSP_FW_UPDATE_ON, true); in aw883xx_start_pa()
685 aw_dev_err(aw883xx->dev, "fw update failed"); in aw883xx_start_pa()
689 aw_dev_info(aw883xx->dev, "start success"); in aw883xx_start_pa()
700 mutex_lock(&aw883xx->lock); in aw883xx_startup_work()
702 mutex_unlock(&aw883xx->lock); in aw883xx_startup_work()
710 if (aw883xx->aw_pa->fw_status == AW_DEV_FW_OK) { in aw883xx_start()
711 if (aw883xx->allow_pw == false) { in aw883xx_start()
712 aw_dev_info(aw883xx->dev, "dev can not allow power"); in aw883xx_start()
716 if (aw883xx->aw_pa->status == AW_DEV_PW_ON) in aw883xx_start()
720 ret = aw_dev_fw_update(aw883xx->aw_pa, AW_DSP_FW_UPDATE_OFF, in aw883xx_start()
721 aw883xx->phase_sync); in aw883xx_start()
723 aw_dev_err(aw883xx->dev, "fw update failed"); in aw883xx_start()
730 queue_delayed_work(aw883xx->work_queue, in aw883xx_start()
731 &aw883xx->start_work, in aw883xx_start()
740 static int aw883xx_mute(struct snd_soc_dai *dai, int mute, int stream) in aw883xx_mute() argument
746 aw_dev_info(aw883xx->dev, "mute state=%d", mute); in aw883xx_mute()
749 aw_dev_info(aw883xx->dev, "capture"); in aw883xx_mute()
753 if (mute) { in aw883xx_mute()
754 aw883xx->pstream = AW883XX_STREAM_CLOSE; in aw883xx_mute()
755 cancel_delayed_work_sync(&aw883xx->start_work); in aw883xx_mute()
756 mutex_lock(&aw883xx->lock); in aw883xx_mute()
757 aw_device_stop(aw883xx->aw_pa); in aw883xx_mute()
758 mutex_unlock(&aw883xx->lock); in aw883xx_mute()
760 aw883xx->pstream = AW883XX_STREAM_OPEN; in aw883xx_mute()
761 mutex_lock(&aw883xx->lock); in aw883xx_mute()
763 aw_hold_dsp_spin_st(&aw883xx->aw_pa->spin_desc); in aw883xx_mute()
764 mutex_unlock(&aw883xx->lock); in aw883xx_mute()
777 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in aw883xx_shutdown()
778 aw_dev_info(aw883xx->dev, "stream playback"); in aw883xx_shutdown()
780 aw_dev_info(aw883xx->dev, "stream capture"); in aw883xx_shutdown()
794 .name = "aw883xx-aif",
824 ret = aw883xx_append_i2c_suffix("%s-%x-%x", in aw883xx_dai_drv_append_suffix()
825 &dai_drv->name, aw883xx); in aw883xx_dai_drv_append_suffix()
829 &dai_drv->playback.stream_name, aw883xx); in aw883xx_dai_drv_append_suffix()
833 &dai_drv->capture.stream_name, aw883xx); in aw883xx_dai_drv_append_suffix()
837 aw_dev_info(aw883xx->dev, "dai name [%s]", dai_drv[i].name); in aw883xx_dai_drv_append_suffix()
838 aw_dev_info(aw883xx->dev, "pstream_name [%s]", in aw883xx_dai_drv_append_suffix()
840 aw_dev_info(aw883xx->dev, "cstream_name [%s]", in aw883xx_dai_drv_append_suffix()
859 ucontrol->value.integer.value[0] = time; in aw883xx_get_fade_in_time()
861 aw_pr_dbg("step time %ld", ucontrol->value.integer.value[0]); in aw883xx_get_fade_in_time()
871 (struct soc_mixer_control *)kcontrol->private_value; in aw883xx_set_fade_in_time()
873 if ((ucontrol->value.integer.value[0] > mc->max) || in aw883xx_set_fade_in_time()
874 (ucontrol->value.integer.value[0] < mc->min)) { in aw883xx_set_fade_in_time()
876 ucontrol->value.integer.value[0], mc->max, mc->min); in aw883xx_set_fade_in_time()
879 aw_dev_set_fade_time(ucontrol->value.integer.value[0], true); in aw883xx_set_fade_in_time()
881 aw_pr_dbg("step time %ld", ucontrol->value.integer.value[0]); in aw883xx_set_fade_in_time()
891 ucontrol->value.integer.value[0] = time; in aw883xx_get_fade_out_time()
893 aw_pr_dbg("step time %ld", ucontrol->value.integer.value[0]); in aw883xx_get_fade_out_time()
902 (struct soc_mixer_control *)kcontrol->private_value; in aw883xx_set_fade_out_time()
904 if ((ucontrol->value.integer.value[0] > mc->max) || in aw883xx_set_fade_out_time()
905 (ucontrol->value.integer.value[0] < mc->min)) { in aw883xx_set_fade_out_time()
907 ucontrol->value.integer.value[0], mc->max, mc->min); in aw883xx_set_fade_out_time()
911 aw_dev_set_fade_time(ucontrol->value.integer.value[0], false); in aw883xx_set_fade_out_time()
913 aw_pr_dbg("step time %ld", ucontrol->value.integer.value[0]); in aw883xx_set_fade_out_time()
928 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_add_codec_controls()
930 if (aw883xx->aw_pa->channel == 0) { in aw883xx_add_codec_controls()
931 aw_componet_codec_ops.add_codec_controls(aw883xx->codec, in aw883xx_add_codec_controls()
948 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in aw883xx_profile_info()
949 uinfo->count = 1; in aw883xx_profile_info()
951 count = aw_dev_get_profile_count(aw883xx->aw_pa); in aw883xx_profile_info()
953 uinfo->value.enumerated.items = 0; in aw883xx_profile_info()
954 aw_dev_err(aw883xx->dev, "get count[%d] failed", count); in aw883xx_profile_info()
958 uinfo->value.enumerated.items = count; in aw883xx_profile_info()
960 if (uinfo->value.enumerated.item >= count) in aw883xx_profile_info()
961 uinfo->value.enumerated.item = count - 1; in aw883xx_profile_info()
963 name = uinfo->value.enumerated.name; in aw883xx_profile_info()
964 count = uinfo->value.enumerated.item; in aw883xx_profile_info()
966 prof_name = aw_dev_get_prof_name(aw883xx->aw_pa, count); in aw883xx_profile_info()
968 strlcpy(uinfo->value.enumerated.name, "null", in aw883xx_profile_info()
973 strlcpy(name, prof_name, sizeof(uinfo->value.enumerated.name)); in aw883xx_profile_info()
986 ucontrol->value.integer.value[0] = aw_dev_get_profile_index(aw883xx->aw_pa); in aw883xx_profile_get()
987 aw_dev_dbg(codec->dev, "profile index [%d]", in aw883xx_profile_get()
988 aw_dev_get_profile_index(aw883xx->aw_pa)); in aw883xx_profile_get()
1003 if (aw883xx->dbg_en_prof == false) { in aw883xx_profile_set()
1004 aw_dev_info(codec->dev, "profile close"); in aw883xx_profile_set()
1009 ret = aw_dev_check_profile_index(aw883xx->aw_pa, ucontrol->value.integer.value[0]); in aw883xx_profile_set()
1011 aw_dev_info(codec->dev, "unsupported index %ld", in aw883xx_profile_set()
1012 ucontrol->value.integer.value[0]); in aw883xx_profile_set()
1017 cur_index = aw_dev_get_profile_index(aw883xx->aw_pa); in aw883xx_profile_set()
1018 if (cur_index == ucontrol->value.integer.value[0]) { in aw883xx_profile_set()
1019 aw_dev_info(codec->dev, "index no change"); in aw883xx_profile_set()
1024 mutex_lock(&aw883xx->lock); in aw883xx_profile_set()
1025 aw_dev_set_profile_index(aw883xx->aw_pa, ucontrol->value.integer.value[0]); in aw883xx_profile_set()
1027 if (aw883xx->pstream) { in aw883xx_profile_set()
1028 aw_device_stop(aw883xx->aw_pa); in aw883xx_profile_set()
1032 mutex_unlock(&aw883xx->lock); in aw883xx_profile_set()
1034 aw_dev_info(codec->dev, "profile id %ld", ucontrol->value.integer.value[0]); in aw883xx_profile_set()
1043 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in aw883xx_switch_info()
1044 uinfo->count = 1; in aw883xx_switch_info()
1047 uinfo->value.enumerated.items = count; in aw883xx_switch_info()
1049 if (uinfo->value.enumerated.item >= count) in aw883xx_switch_info()
1050 uinfo->value.enumerated.item = count - 1; in aw883xx_switch_info()
1052 strlcpy(uinfo->value.enumerated.name, in aw883xx_switch_info()
1053 aw883xx_switch[uinfo->value.enumerated.item], in aw883xx_switch_info()
1054 strlen(aw883xx_switch[uinfo->value.enumerated.item]) + 1); in aw883xx_switch_info()
1067 ucontrol->value.integer.value[0] = aw883xx->allow_pw; in aw883xx_switch_get()
1080 aw_dev_info(codec->dev, "set value:%ld", ucontrol->value.integer.value[0]); in aw883xx_switch_set()
1082 if (ucontrol->value.integer.value[0] == aw883xx->allow_pw) { in aw883xx_switch_set()
1083 aw_dev_info(aw883xx->dev, "PA switch not change"); in aw883xx_switch_set()
1087 if (aw883xx->pstream) { in aw883xx_switch_set()
1088 if (ucontrol->value.integer.value[0] == 0) { in aw883xx_switch_set()
1089 cancel_delayed_work_sync(&aw883xx->start_work); in aw883xx_switch_set()
1090 mutex_lock(&aw883xx->lock); in aw883xx_switch_set()
1091 aw_device_stop(aw883xx->aw_pa); in aw883xx_switch_set()
1092 aw883xx->allow_pw = false; in aw883xx_switch_set()
1093 mutex_unlock(&aw883xx->lock); in aw883xx_switch_set()
1095 cancel_delayed_work_sync(&aw883xx->start_work); in aw883xx_switch_set()
1096 mutex_lock(&aw883xx->lock); in aw883xx_switch_set()
1097 aw883xx->allow_pw = true; in aw883xx_switch_set()
1099 mutex_unlock(&aw883xx->lock); in aw883xx_switch_set()
1102 mutex_lock(&aw883xx->lock); in aw883xx_switch_set()
1103 if (ucontrol->value.integer.value[0]) in aw883xx_switch_set()
1104 aw883xx->allow_pw = true; in aw883xx_switch_set()
1106 aw883xx->allow_pw = false; in aw883xx_switch_set()
1107 mutex_unlock(&aw883xx->lock); in aw883xx_switch_set()
1118 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in aw883xx_monitor_switch_info()
1119 uinfo->count = 1; in aw883xx_monitor_switch_info()
1122 uinfo->value.enumerated.items = count; in aw883xx_monitor_switch_info()
1124 if (uinfo->value.enumerated.item >= count) in aw883xx_monitor_switch_info()
1125 uinfo->value.enumerated.item = count - 1; in aw883xx_monitor_switch_info()
1127 strlcpy(uinfo->value.enumerated.name, in aw883xx_monitor_switch_info()
1128 aw883xx_switch[uinfo->value.enumerated.item], in aw883xx_monitor_switch_info()
1129 strlen(aw883xx_switch[uinfo->value.enumerated.item]) + 1); in aw883xx_monitor_switch_info()
1141 struct aw_monitor_desc *monitor_desc = &aw883xx->aw_pa->monitor_desc; in aw883xx_monitor_switch_get()
1143 ucontrol->value.integer.value[0] = monitor_desc->monitor_cfg.monitor_switch; in aw883xx_monitor_switch_get()
1155 struct aw_monitor_desc *monitor_desc = &aw883xx->aw_pa->monitor_desc; in aw883xx_monitor_switch_set()
1158 aw_dev_info(codec->dev, "set monitor_switch:%ld", ucontrol->value.integer.value[0]); in aw883xx_monitor_switch_set()
1160 enable = ucontrol->value.integer.value[0]; in aw883xx_monitor_switch_set()
1162 if (monitor_desc->monitor_cfg.monitor_switch == enable) { in aw883xx_monitor_switch_set()
1163 aw_dev_info(aw883xx->dev, "monitor_switch not change"); in aw883xx_monitor_switch_set()
1166 monitor_desc->monitor_cfg.monitor_switch = enable; in aw883xx_monitor_switch_set()
1179 aw883xx_dev_control = devm_kzalloc(aw883xx->codec->dev, in aw883xx_dynamic_create_controls()
1182 aw_dev_err(aw883xx->codec->dev, "kcontrol malloc failed!"); in aw883xx_dynamic_create_controls()
1183 return -ENOMEM; in aw883xx_dynamic_create_controls()
1186 kctl_name = devm_kzalloc(aw883xx->codec->dev, AW_NAME_BUF_MAX, GFP_KERNEL); in aw883xx_dynamic_create_controls()
1188 return -ENOMEM; in aw883xx_dynamic_create_controls()
1191 aw883xx->aw_pa->channel); in aw883xx_dynamic_create_controls()
1199 kctl_name = devm_kzalloc(aw883xx->codec->dev, AW_NAME_BUF_MAX, GFP_KERNEL); in aw883xx_dynamic_create_controls()
1201 return -ENOMEM; in aw883xx_dynamic_create_controls()
1203 snprintf(kctl_name, AW_NAME_BUF_MAX, "aw_dev_%u_switch", aw883xx->aw_pa->channel); in aw883xx_dynamic_create_controls()
1211 kctl_name = devm_kzalloc(aw883xx->codec->dev, AW_NAME_BUF_MAX, GFP_KERNEL); in aw883xx_dynamic_create_controls()
1213 return -ENOMEM; in aw883xx_dynamic_create_controls()
1215 snprintf(kctl_name, AW_NAME_BUF_MAX, "aw_dev_%u_monitor_switch", aw883xx->aw_pa->channel); in aw883xx_dynamic_create_controls()
1223 aw_componet_codec_ops.add_codec_controls(aw883xx->codec, in aw883xx_dynamic_create_controls()
1233 int ret = -1; in aw883xx_request_firmware_file()
1236 aw883xx->aw_pa->fw_status = AW_DEV_FW_FAILED; in aw883xx_request_firmware_file()
1239 ret = request_firmware(&cont, AW883XX_ACF_FILE, aw883xx->dev); in aw883xx_request_firmware_file()
1241 aw883xx->fw_retry_cnt++; in aw883xx_request_firmware_file()
1242 aw_dev_err(aw883xx->dev, "load [%s] try [%d]!", in aw883xx_request_firmware_file()
1243 AW883XX_ACF_FILE, aw883xx->fw_retry_cnt); in aw883xx_request_firmware_file()
1245 if (aw883xx->fw_retry_cnt == AW_REQUEST_FW_RETRIES) { in aw883xx_request_firmware_file()
1246 aw883xx->fw_retry_cnt = 0; in aw883xx_request_firmware_file()
1256 return -ENOMEM; in aw883xx_request_firmware_file()
1258 aw_dev_info(aw883xx->dev, "loaded %s - size: %zu", in aw883xx_request_firmware_file()
1259 AW883XX_ACF_FILE, cont ? cont->size : 0); in aw883xx_request_firmware_file()
1263 aw_cfg = vzalloc(cont->size + sizeof(int)); in aw883xx_request_firmware_file()
1265 aw_dev_err(aw883xx->dev, "aw883xx_cfg devm_kzalloc failed"); in aw883xx_request_firmware_file()
1268 return -ENOMEM; in aw883xx_request_firmware_file()
1270 aw_cfg->len = cont->size; in aw883xx_request_firmware_file()
1271 memcpy(aw_cfg->data, cont->data, cont->size); in aw883xx_request_firmware_file()
1274 aw_dev_err(aw883xx->dev, "Load [%s] failed ....!", AW883XX_ACF_FILE); in aw883xx_request_firmware_file()
1284 aw_dev_info(aw883xx->dev, "[%s] already loaded...", AW883XX_ACF_FILE); in aw883xx_request_firmware_file()
1289 mutex_lock(&aw883xx->lock); in aw883xx_request_firmware_file()
1291 ret = aw_device_init(aw883xx->aw_pa, aw_cfg); in aw883xx_request_firmware_file()
1293 aw_dev_info(aw883xx->dev, "dev init failed"); in aw883xx_request_firmware_file()
1294 mutex_unlock(&aw883xx->lock); in aw883xx_request_firmware_file()
1300 aw_check_spin_mode(&aw883xx->aw_pa->spin_desc); in aw883xx_request_firmware_file()
1302 mutex_unlock(&aw883xx->lock); in aw883xx_request_firmware_file()
1315 aw_dev_err(aw883xx->dev, "load profile failed"); in aw883xx_fw_wrok()
1322 if (aw883xx->aw_pa->platform == AW_QCOM) { in aw883xx_load_fw()
1327 queue_delayed_work(aw883xx->work_queue, in aw883xx_load_fw()
1328 &aw883xx->acf_work, in aw883xx_load_fw()
1352 return &codec->dapm; in snd_soc_codec_get_dapm()
1363 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(aw883xx->codec); in aw883xx_add_widgets()
1365 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(aw883xx->codec); in aw883xx_add_widgets()
1369 aw_widgets = devm_kzalloc(aw883xx->dev, in aw883xx_add_widgets()
1373 return -ENOMEM; in aw883xx_add_widgets()
1382 aw_dev_err(aw883xx->dev, "aw_widgets.name append i2c suffix failed!\n"); in aw883xx_add_widgets()
1390 aw_dev_err(aw883xx->dev, "aw_widgets.name append i2c suffix failed!"); in aw883xx_add_widgets()
1399 aw_route = devm_kzalloc(aw883xx->dev, in aw883xx_add_widgets()
1403 return -ENOMEM; in aw883xx_add_widgets()
1412 aw_dev_err(aw883xx->dev, "aw_route.sink append i2c suffix failed!"); in aw883xx_add_widgets()
1420 aw_dev_err(aw883xx->dev, "aw_route.source append i2c suffix failed!"); in aw883xx_add_widgets()
1436 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_codec_probe()
1439 aw883xx->work_queue = create_singlethread_workqueue("aw883xx"); in aw883xx_codec_probe()
1440 if (!aw883xx->work_queue) { in aw883xx_codec_probe()
1441 aw_dev_err(aw883xx->dev, "create workqueue failed !"); in aw883xx_codec_probe()
1442 return -EINVAL; in aw883xx_codec_probe()
1445 INIT_DELAYED_WORK(&aw883xx->interrupt_work, aw883xx_interrupt_work); in aw883xx_codec_probe()
1446 INIT_DELAYED_WORK(&aw883xx->start_work, aw883xx_startup_work); in aw883xx_codec_probe()
1447 INIT_DELAYED_WORK(&aw883xx->acf_work, aw883xx_fw_wrok); in aw883xx_codec_probe()
1449 aw883xx->codec = aw_codec; in aw883xx_codec_probe()
1466 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_codec_remove()
1468 cancel_delayed_work_sync(&aw883xx->interrupt_work); in aw883xx_codec_remove()
1469 cancel_delayed_work_sync(&aw883xx->acf_work); in aw883xx_codec_remove()
1470 cancel_delayed_work_sync(&aw883xx->aw_pa->monitor_desc.delay_work); in aw883xx_codec_remove()
1471 cancel_delayed_work_sync(&aw883xx->start_work); in aw883xx_codec_remove()
1473 if (aw883xx->work_queue) in aw883xx_codec_remove()
1474 destroy_workqueue(aw883xx->work_queue); in aw883xx_codec_remove()
1476 aw_dev_deinit(aw883xx->aw_pa); in aw883xx_codec_remove()
1484 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_codec_remove()
1486 cancel_delayed_work_sync(&aw883xx->interrupt_work); in aw883xx_codec_remove()
1487 cancel_delayed_work_sync(&aw883xx->acf_work); in aw883xx_codec_remove()
1488 cancel_delayed_work_sync(&aw883xx->aw_pa->monitor_desc.delay_work); in aw883xx_codec_remove()
1489 cancel_delayed_work_sync(&aw883xx->start_work); in aw883xx_codec_remove()
1491 if (aw883xx->work_queue) in aw883xx_codec_remove()
1492 destroy_workqueue(aw883xx->work_queue); in aw883xx_codec_remove()
1494 aw_dev_deinit(aw883xx->aw_pa); in aw883xx_codec_remove()
1517 dai_drv = devm_kzalloc(aw883xx->dev, sizeof(aw883xx_dai), GFP_KERNEL); in aw883xx_componet_codec_register()
1519 aw_dev_err(aw883xx->dev, "dai_driver malloc failed"); in aw883xx_componet_codec_register()
1520 return -ENOMEM; in aw883xx_componet_codec_register()
1529 ret = aw883xx->codec_ops->register_codec(aw883xx->dev, in aw883xx_componet_codec_register()
1533 aw_dev_err(aw883xx->dev, "failed to register aw883xx: %d", ret); in aw883xx_componet_codec_register()
1543 struct aw883xx *aw883xx = devm_kzalloc(&i2c->dev, in aw883xx_malloc_init()
1546 aw_dev_err(&i2c->dev, "devm_kzalloc failed"); in aw883xx_malloc_init()
1550 aw883xx->dev = &i2c->dev; in aw883xx_malloc_init()
1551 aw883xx->i2c = i2c; in aw883xx_malloc_init()
1552 aw883xx->aw_pa = NULL; in aw883xx_malloc_init()
1553 aw883xx->codec = NULL; in aw883xx_malloc_init()
1554 aw883xx->codec_ops = &aw_componet_codec_ops; in aw883xx_malloc_init()
1555 aw883xx->dbg_en_prof = true; in aw883xx_malloc_init()
1556 aw883xx->allow_pw = true; in aw883xx_malloc_init()
1557 aw883xx->work_queue = NULL; in aw883xx_malloc_init()
1558 aw883xx->i2c_log_en = 0; in aw883xx_malloc_init()
1559 mutex_init(&aw883xx->lock); in aw883xx_malloc_init()
1560 mutex_init(&aw883xx->i2c_lock); in aw883xx_malloc_init()
1569 if (gpio_is_valid(aw883xx->reset_gpio)) { in aw883xx_gpio_request()
1570 ret = devm_gpio_request_one(aw883xx->dev, aw883xx->reset_gpio, in aw883xx_gpio_request()
1573 aw_dev_err(aw883xx->dev, "rst request failed"); in aw883xx_gpio_request()
1578 if (gpio_is_valid(aw883xx->irq_gpio)) { in aw883xx_gpio_request()
1579 ret = devm_gpio_request_one(aw883xx->dev, aw883xx->irq_gpio, in aw883xx_gpio_request()
1582 aw_dev_err(aw883xx->dev, "int request failed"); in aw883xx_gpio_request()
1597 struct device_node *np = aw883xx->dev->of_node; in aw883xx_parse_gpio_dt()
1599 aw883xx->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); in aw883xx_parse_gpio_dt()
1600 if (aw883xx->reset_gpio < 0) { in aw883xx_parse_gpio_dt()
1601 aw_dev_err(aw883xx->dev, "no reset gpio provided, will not hw reset"); in aw883xx_parse_gpio_dt()
1602 /* return -EIO; */ in aw883xx_parse_gpio_dt()
1604 aw_dev_info(aw883xx->dev, "reset gpio provided ok"); in aw883xx_parse_gpio_dt()
1607 aw883xx->irq_gpio = of_get_named_gpio(np, "irq-gpio", 0); in aw883xx_parse_gpio_dt()
1608 if (aw883xx->irq_gpio < 0) in aw883xx_parse_gpio_dt()
1609 aw_dev_info(aw883xx->dev, "no irq gpio provided."); in aw883xx_parse_gpio_dt()
1611 aw_dev_info(aw883xx->dev, "irq gpio provided ok."); in aw883xx_parse_gpio_dt()
1620 struct device_node *np = aw883xx->dev->of_node; in aw883xx_parse_sync_flag_dt()
1622 ret = of_property_read_u32(np, "sync-flag", &sync_enable); in aw883xx_parse_sync_flag_dt()
1624 aw_dev_info(aw883xx->dev, in aw883xx_parse_sync_flag_dt()
1628 aw_dev_info(aw883xx->dev, in aw883xx_parse_sync_flag_dt()
1632 aw883xx->phase_sync = sync_enable; in aw883xx_parse_sync_flag_dt()
1644 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_hw_reset()
1646 if (gpio_is_valid(aw883xx->reset_gpio)) { in aw883xx_hw_reset()
1647 gpio_set_value_cansleep(aw883xx->reset_gpio, 0); in aw883xx_hw_reset()
1649 gpio_set_value_cansleep(aw883xx->reset_gpio, 1); in aw883xx_hw_reset()
1652 aw_dev_err(aw883xx->dev, "failed"); in aw883xx_hw_reset()
1659 int ret = -1; in aw883xx_read_chipid()
1664 aw_dev_err(aw883xx->dev, in aw883xx_read_chipid()
1666 return -EIO; in aw883xx_read_chipid()
1669 aw883xx->chip_id = reg_val; in aw883xx_read_chipid()
1670 aw_dev_info(aw883xx->dev, in aw883xx_read_chipid()
1687 return -EINVAL; in aw883xx_irq()
1690 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_irq()
1692 aw_dev_set_intmask(aw883xx->aw_pa, false); in aw883xx_irq()
1695 if (aw883xx->work_queue) in aw883xx_irq()
1696 queue_delayed_work(aw883xx->work_queue, in aw883xx_irq()
1697 &aw883xx->interrupt_work, 0); in aw883xx_irq()
1707 if (gpio_is_valid(aw883xx->irq_gpio)) { in aw883xx_interrupt_init()
1709 ret = devm_request_threaded_irq(aw883xx->dev, in aw883xx_interrupt_init()
1710 gpio_to_irq(aw883xx->irq_gpio), in aw883xx_interrupt_init()
1714 aw_dev_err(aw883xx->dev, "Failed to request IRQ %d: %d", in aw883xx_interrupt_init()
1715 gpio_to_irq(aw883xx->irq_gpio), ret); in aw883xx_interrupt_init()
1719 aw_dev_info(aw883xx->dev, "skipping IRQ registration"); in aw883xx_interrupt_init()
1735 int reg_num = aw883xx->aw_pa->ops.aw_get_reg_num(); in aw883xx_reg_show()
1741 if (aw883xx->aw_pa->ops.aw_check_rd_access(i)) { in aw883xx_reg_show()
1743 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_reg_show()
1772 aw883xx->reg_addr = (uint8_t)databuf[0]; in aw883xx_rw_store()
1773 if (aw883xx->aw_pa->ops.aw_check_rd_access(databuf[0])) in aw883xx_rw_store()
1776 aw883xx->reg_addr = (uint8_t)databuf[0]; in aw883xx_rw_store()
1789 if (aw883xx->aw_pa->ops.aw_check_rd_access(aw883xx->reg_addr)) { in aw883xx_rw_show()
1790 aw883xx_reg_read(aw883xx, aw883xx->reg_addr, &reg_val); in aw883xx_rw_show()
1791 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_rw_show()
1792 "reg:0x%02x=0x%04x\n", aw883xx->reg_addr, in aw883xx_rw_show()
1804 len += snprintf(buf+len, PAGE_SIZE-len, in aw883xx_drv_ver_show()
1817 mutex_lock(&aw883xx->i2c_lock); in aw883xx_dsp_rw_show()
1818 aw883xx_i2c_write(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_madd_reg, aw883xx->dsp_addr); in aw883xx_dsp_rw_show()
1819 aw883xx_i2c_read(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_mdat_reg, &reg_val); in aw883xx_dsp_rw_show()
1820 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_dsp_rw_show()
1821 "dsp:0x%04x=0x%04x\n", aw883xx->dsp_addr, reg_val); in aw883xx_dsp_rw_show()
1822 aw883xx_i2c_read(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_mdat_reg, &reg_val); in aw883xx_dsp_rw_show()
1823 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_dsp_rw_show()
1824 "dsp:0x%04x=0x%04x\n", aw883xx->dsp_addr + 1, reg_val); in aw883xx_dsp_rw_show()
1826 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_dsp_rw_show()
1839 aw883xx->dsp_addr = (unsigned int)databuf[0]; in aw883xx_dsp_rw_store()
1841 aw_dev_dbg(aw883xx->dev, "get param: %x %x", in aw883xx_dsp_rw_store()
1844 aw883xx->dsp_addr = (unsigned int)databuf[0]; in aw883xx_dsp_rw_store()
1845 aw_dev_dbg(aw883xx->dev, "get param: %x", in aw883xx_dsp_rw_store()
1858 struct aw883xx_i2c_packet *packet = &aw883xx->i2c_packet; in aw883xx_awrw_write()
1861 data_len = AWRW_DATA_BYTES * packet->reg_num; in aw883xx_awrw_write()
1863 str_len = count - AWRW_HDR_LEN - 1; in aw883xx_awrw_write()
1864 if ((data_len * 5 - 1) > str_len) { in aw883xx_awrw_write()
1865 aw_dev_err(aw883xx->dev, "data_str_len [%d], requeset len [%d]", in aw883xx_awrw_write()
1866 str_len, (data_len * 5 - 1)); in aw883xx_awrw_write()
1867 return -EINVAL; in aw883xx_awrw_write()
1870 if (packet->reg_addr == aw883xx->aw_pa->dsp_mem_desc.dsp_madd_reg) { in aw883xx_awrw_write()
1872 packet->dsp_addr = (dsp_addr_h << 8) | dsp_addr_l; in aw883xx_awrw_write()
1873 packet->dsp_status = AWRW_DSP_READY; in aw883xx_awrw_write()
1874 aw_dev_dbg(aw883xx->dev, "write:reg_addr[0x%02x], dsp_base_addr:[0x%02x]", in aw883xx_awrw_write()
1875 packet->reg_addr, packet->dsp_addr); in aw883xx_awrw_write()
1878 aw_dev_err(aw883xx->dev, "get reg 0x%x data failed", packet->reg_addr); in aw883xx_awrw_write()
1879 return -EINVAL; in aw883xx_awrw_write()
1883 mutex_lock(&aw883xx->i2c_lock); in aw883xx_awrw_write()
1884 if (packet->reg_addr == aw883xx->aw_pa->dsp_mem_desc.dsp_mdat_reg) { in aw883xx_awrw_write()
1885 if (packet->dsp_status != AWRW_DSP_READY) { in aw883xx_awrw_write()
1886 aw_dev_err(aw883xx->dev, "please write reg[0x40] first"); in aw883xx_awrw_write()
1887 ret = -EINVAL; in aw883xx_awrw_write()
1890 aw883xx_i2c_write(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_madd_reg, packet->dsp_addr); in aw883xx_awrw_write()
1891 packet->dsp_status = AWRW_DSP_ST_NONE; in aw883xx_awrw_write()
1894 aw_dev_info(aw883xx->dev, "write:reg_addr[0x%02x], reg_num[%d]", in aw883xx_awrw_write()
1895 packet->reg_addr, packet->reg_num); in aw883xx_awrw_write()
1897 data_buf = devm_kzalloc(aw883xx->dev, data_len, GFP_KERNEL); in aw883xx_awrw_write()
1899 aw_dev_err(aw883xx->dev, "alloc memory failed"); in aw883xx_awrw_write()
1900 ret = -ENOMEM; in aw883xx_awrw_write()
1910 ret = aw883xx_i2c_writes(aw883xx, packet->reg_addr, data_buf, data_len); in aw883xx_awrw_write()
1912 aw_dev_err(aw883xx->dev, "write failed"); in aw883xx_awrw_write()
1913 devm_kfree(aw883xx->dev, data_buf); in aw883xx_awrw_write()
1918 devm_kfree(aw883xx->dev, data_buf); in aw883xx_awrw_write()
1920 aw_dev_info(aw883xx->dev, "write success"); in aw883xx_awrw_write()
1922 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_awrw_write()
1930 aw_dev_err(aw883xx->dev, "addr_bytes [%d] or data_bytes [%d] unsupport", in aw883xx_awrw_data_check()
1932 return -EINVAL; in aw883xx_awrw_data_check()
1942 struct aw883xx_i2c_packet *packet = &aw883xx->i2c_packet; in aw883xx_awrw_parse_buf()
1953 packet->reg_addr = data[AWRW_HDR_REG_ADDR]; in aw883xx_awrw_parse_buf()
1954 packet->reg_num = data[AWRW_HDR_REG_NUM]; in aw883xx_awrw_parse_buf()
1959 packet->i2c_status = AWRW_I2C_ST_READ; in aw883xx_awrw_parse_buf()
1960 aw_dev_info(aw883xx->dev, "read_cmd:reg_addr[0x%02x], reg_num[%d]", in aw883xx_awrw_parse_buf()
1961 packet->reg_addr, packet->reg_num); in aw883xx_awrw_parse_buf()
1964 aw_dev_err(aw883xx->dev, "please check str format, unsupport flag %d", data[AWRW_HDR_WR_FLAG]); in aw883xx_awrw_parse_buf()
1965 return -EINVAL; in aw883xx_awrw_parse_buf()
1968 aw_dev_err(aw883xx->dev, "can not parse string"); in aw883xx_awrw_parse_buf()
1969 return -EINVAL; in aw883xx_awrw_parse_buf()
1984 return -EINVAL; in aw883xx_awrw_store()
1989 return -EINVAL; in aw883xx_awrw_store()
1999 struct aw883xx_i2c_packet *packet = &aw883xx->i2c_packet; in aw883xx_awrw_show()
2004 if (packet->i2c_status != AWRW_I2C_ST_READ) { in aw883xx_awrw_show()
2005 aw_dev_err(aw883xx->dev, "please write read cmd first"); in aw883xx_awrw_show()
2006 return -EINVAL; in aw883xx_awrw_show()
2009 mutex_lock(&aw883xx->i2c_lock); in aw883xx_awrw_show()
2010 if (packet->reg_addr == aw883xx->aw_pa->dsp_mem_desc.dsp_mdat_reg) { in aw883xx_awrw_show()
2011 if (packet->dsp_status != AWRW_DSP_READY) { in aw883xx_awrw_show()
2012 aw_dev_err(aw883xx->dev, "please write reg[0x40] first"); in aw883xx_awrw_show()
2013 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_awrw_show()
2014 return -EINVAL; in aw883xx_awrw_show()
2016 ret = aw883xx_i2c_write(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_madd_reg, packet->dsp_addr); in aw883xx_awrw_show()
2018 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_awrw_show()
2021 packet->dsp_status = AWRW_DSP_ST_NONE; in aw883xx_awrw_show()
2024 data_len = AWRW_DATA_BYTES * packet->reg_num; in aw883xx_awrw_show()
2027 aw_dev_err(aw883xx->dev, "memory alloc failed"); in aw883xx_awrw_show()
2028 ret = -EINVAL; in aw883xx_awrw_show()
2032 ret = aw883xx_i2c_reads(aw883xx, packet->reg_addr, reg_data, data_len); in aw883xx_awrw_show()
2034 ret = -EFAULT; in aw883xx_awrw_show()
2038 aw_dev_info(aw883xx->dev, "reg_addr 0x%02x, reg_num %d", in aw883xx_awrw_show()
2039 packet->reg_addr, packet->reg_num); in aw883xx_awrw_show()
2042 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_awrw_show()
2053 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_awrw_show()
2054 packet->i2c_status = AWRW_I2C_ST_NONE; in aw883xx_awrw_show()
2065 if (databuf > (aw883xx->aw_pa->volume_desc.mute_volume)) { in aw883xx_fade_step_store()
2066 aw_dev_info(aw883xx->dev, "step overflow %d Db", databuf); in aw883xx_fade_step_store()
2069 aw_dev_set_fade_vol_step(aw883xx->aw_pa, databuf); in aw883xx_fade_step_store()
2071 aw_dev_info(aw883xx->dev, "set step %d DB Done", databuf); in aw883xx_fade_step_store()
2082 len += snprintf(buf+len, PAGE_SIZE-len, in aw883xx_fade_step_show()
2083 "step: %d \n", aw_dev_get_fade_vol_step(aw883xx->aw_pa)); in aw883xx_fade_step_show()
2096 aw883xx->dbg_en_prof = true; in aw883xx_dbg_prof_store()
2098 aw883xx->dbg_en_prof = false; in aw883xx_dbg_prof_store()
2100 aw_dev_info(aw883xx->dev, "en_prof %d Done", databuf); in aw883xx_dbg_prof_store()
2111 len += snprintf(buf+len, PAGE_SIZE-len, in aw883xx_dbg_prof_show()
2112 " %d\n", aw883xx->dbg_en_prof); in aw883xx_dbg_prof_show()
2125 ret = aw_cali_svc_get_dev_te(&aw883xx->aw_pa->cali_desc, &te); in aw883xx_spk_temp_show()
2129 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_spk_temp_show()
2149 aw_dev_info(aw883xx->dev, "set phase sync flag : [%d]", flag); in aw883xx_sync_flag_store()
2151 aw883xx->phase_sync = flag; in aw883xx_sync_flag_store()
2162 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_sync_flag_show()
2163 "sync flag : %d\n", aw883xx->phase_sync); in aw883xx_sync_flag_show()
2175 aw883xx->aw_pa->fade_en = fade_en; in aw883xx_fade_enable_store()
2177 aw_dev_info(aw883xx->dev, "set fade_en %d", aw883xx->aw_pa->fade_en); in aw883xx_fade_enable_store()
2188 len += snprintf(buf+len, PAGE_SIZE-len, in aw883xx_fade_enable_show()
2189 "fade_en: %d\n", aw883xx->aw_pa->fade_en); in aw883xx_fade_enable_show()
2202 ret = aw_cali_read_cali_re_from_dsp(&aw883xx->aw_pa->cali_desc, &read_re); in aw883xx_dsp_re_show()
2204 aw_dev_err(aw883xx->dev, "%s:read dsp re fail\n", __func__); in aw883xx_dsp_re_show()
2209 PAGE_SIZE - len, in aw883xx_dsp_re_show()
2221 len += snprintf(buf + len, PAGE_SIZE - len, "i2c_log_en: %d\n", in aw883xx_log_en_show()
2222 aw883xx->i2c_log_en); in aw883xx_log_en_show()
2234 aw883xx->i2c_log_en = log_en; in aw883xx_log_en_store()
2236 aw_dev_info(aw883xx->dev, "set i2c_log_en: %d", in aw883xx_log_en_store()
2237 aw883xx->i2c_log_en); in aw883xx_log_en_store()
2250 dsp_reg_info = devm_kzalloc(aw883xx->dev, AW_NAME_BUF_MAX, GFP_KERNEL); in aw883xx_dsp_log_info()
2252 aw_dev_err(aw883xx->dev, "dsp_reg_info kzalloc failed"); in aw883xx_dsp_log_info()
2253 return -ENOMEM; in aw883xx_dsp_log_info()
2256 mutex_lock(&aw883xx->i2c_lock); in aw883xx_dsp_log_info()
2257 aw883xx_i2c_write(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_madd_reg, base_addr); in aw883xx_dsp_log_info()
2260 aw883xx_i2c_read(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_mdat_reg, &reg_val); in aw883xx_dsp_log_info()
2261 dsp_info_len += snprintf(dsp_reg_info + dsp_info_len, AW_NAME_BUF_MAX - dsp_info_len, in aw883xx_dsp_log_info()
2265 aw_dev_info(aw883xx->dev, "%s: %s", format, dsp_reg_info); in aw883xx_dsp_log_info()
2271 (i == (data_len - 2))) { in aw883xx_dsp_log_info()
2272 aw_dev_info(aw883xx->dev, "%s: %s", format, dsp_reg_info); in aw883xx_dsp_log_info()
2279 devm_kfree(aw883xx->dev, dsp_reg_info); in aw883xx_dsp_log_info()
2281 mutex_unlock(&aw883xx->i2c_lock); in aw883xx_dsp_log_info()
2291 int ret = -1; in aw883xx_dsp_show()
2294 if (aw883xx->aw_pa->dsp_cfg == AW_DEV_DSP_BYPASS) { in aw883xx_dsp_show()
2295 len += snprintf((char *)(buf + len), PAGE_SIZE - len, in aw883xx_dsp_show()
2298 len += snprintf((char *)(buf + len), PAGE_SIZE - len, in aw883xx_dsp_show()
2300 ret = aw_dev_get_iis_status(aw883xx->aw_pa); in aw883xx_dsp_show()
2303 PAGE_SIZE - len, in aw883xx_dsp_show()
2306 aw_dev_err(aw883xx->dev, "no iis signal, dsp show failed"); in aw883xx_dsp_show()
2310 len += snprintf(buf + len, PAGE_SIZE - len, in aw883xx_dsp_show()
2313 aw_dev_info(aw883xx->dev, "dsp_firmware_len:%d", aw883xx->aw_pa->dsp_fw_len); in aw883xx_dsp_show()
2314 ret = aw883xx_dsp_log_info(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_fw_base_addr, in aw883xx_dsp_show()
2315 aw883xx->aw_pa->dsp_fw_len, "dsp_fw"); in aw883xx_dsp_show()
2317 aw_dev_err(aw883xx->dev, "dsp_fw display failed"); in aw883xx_dsp_show()
2321 aw_dev_info(aw883xx->dev, "dsp_config_len:%d", aw883xx->aw_pa->dsp_cfg_len); in aw883xx_dsp_show()
2322 ret = aw883xx_dsp_log_info(aw883xx, aw883xx->aw_pa->dsp_mem_desc.dsp_cfg_base_addr, in aw883xx_dsp_show()
2323 aw883xx->aw_pa->dsp_cfg_len, "dsp_config"); in aw883xx_dsp_show()
2325 aw_dev_err(aw883xx->dev, "dsp_config display failed"); in aw883xx_dsp_show()
2329 aw_dev_info(aw883xx->dev, "dsp_config:0x8180-0x83fc"); in aw883xx_dsp_show()
2330 data_len = 2 * (aw883xx->aw_pa->dsp_st_desc.dsp_reg_e1 - in aw883xx_dsp_show()
2331 aw883xx->aw_pa->dsp_st_desc.dsp_reg_s1); in aw883xx_dsp_show()
2332 ret = aw883xx_dsp_log_info(aw883xx, aw883xx->aw_pa->dsp_st_desc.dsp_reg_s1, in aw883xx_dsp_show()
2335 aw_dev_err(aw883xx->dev, "dsp_config:0x8180-0x83fc failed"); in aw883xx_dsp_show()
2339 aw_dev_info(aw883xx->dev, "dsp_config:0x9c00-0x9c5c"); in aw883xx_dsp_show()
2340 data_len = 2 * (aw883xx->aw_pa->dsp_st_desc.dsp_reg_e2 - in aw883xx_dsp_show()
2341 aw883xx->aw_pa->dsp_st_desc.dsp_reg_s2); in aw883xx_dsp_show()
2342 ret = aw883xx_dsp_log_info(aw883xx, aw883xx->aw_pa->dsp_st_desc.dsp_reg_s2, in aw883xx_dsp_show()
2345 aw_dev_err(aw883xx->dev, "dsp_config:0x9c00-0x9c5c display failed"); in aw883xx_dsp_show()
2412 int ret = -1; in aw883xx_i2c_probe()
2414 aw_dev_info(&i2c->dev, "enter"); in aw883xx_i2c_probe()
2416 if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_I2C)) { in aw883xx_i2c_probe()
2417 aw_dev_err(&i2c->dev, "check_functionality failed"); in aw883xx_i2c_probe()
2418 return -EIO; in aw883xx_i2c_probe()
2423 aw_dev_err(&i2c->dev, "malloc aw883xx failed"); in aw883xx_i2c_probe()
2424 return -ENOMEM; in aw883xx_i2c_probe()
2430 aw_dev_err(&i2c->dev, "parse dts failed"); in aw883xx_i2c_probe()
2445 aw_dev_err(&i2c->dev, "aw883xx_read_chipid failed ret=%d", ret); in aw883xx_i2c_probe()
2456 aw_dev_err(&i2c->dev, "get platform failed"); in aw883xx_i2c_probe()
2466 aw_dev_err(&i2c->dev, "codec register failed"); in aw883xx_i2c_probe()
2470 ret = sysfs_create_group(&i2c->dev.kobj, &aw883xx_attribute_group); in aw883xx_i2c_probe()
2472 aw_dev_info(&i2c->dev, "error creating sysfs attr files"); in aw883xx_i2c_probe()
2476 dev_set_drvdata(&i2c->dev, aw883xx); in aw883xx_i2c_probe()
2483 aw_dev_info(&i2c->dev, "dev_cnt %d probe completed successfully", in aw883xx_i2c_probe()
2490 aw_componet_codec_ops.unregister_codec(&i2c->dev); in aw883xx_i2c_probe()
2498 aw_dev_info(aw883xx->dev, "enter"); in aw883xx_i2c_remove()
2500 if (gpio_to_irq(aw883xx->irq_gpio)) in aw883xx_i2c_remove()
2501 devm_free_irq(&i2c->dev, in aw883xx_i2c_remove()
2502 gpio_to_irq(aw883xx->irq_gpio), in aw883xx_i2c_remove()
2505 if (gpio_is_valid(aw883xx->irq_gpio)) in aw883xx_i2c_remove()
2506 devm_gpio_free(&i2c->dev, aw883xx->irq_gpio); in aw883xx_i2c_remove()
2507 if (gpio_is_valid(aw883xx->reset_gpio)) in aw883xx_i2c_remove()
2508 devm_gpio_free(&i2c->dev, aw883xx->reset_gpio); in aw883xx_i2c_remove()
2510 sysfs_remove_group(&aw883xx->dev->kobj, in aw883xx_i2c_remove()
2514 aw_device_remove(aw883xx->aw_pa); in aw883xx_i2c_remove()
2516 aw_componet_codec_ops.unregister_codec(&i2c->dev); in aw883xx_i2c_remove()
2519 g_aw883xx_dev_cnt--; in aw883xx_i2c_remove()
2554 int ret = -1; in aw883xx_i2c_init()