Lines Matching full:aw88395

3 // aw88395.c --  ALSA SoC AW88395 codec support
16 #include "aw88395.h"
29 static void aw88395_start_pa(struct aw88395 *aw88395) in aw88395_start_pa() argument
34 ret = aw88395_dev_start(aw88395->aw_pa); in aw88395_start_pa()
36 dev_err(aw88395->aw_pa->dev, "aw88395 device start failed. retry = %d", i); in aw88395_start_pa()
37 ret = aw88395_dev_fw_update(aw88395->aw_pa, AW88395_DSP_FW_UPDATE_ON, true); in aw88395_start_pa()
39 dev_err(aw88395->aw_pa->dev, "fw update failed"); in aw88395_start_pa()
43 dev_info(aw88395->aw_pa->dev, "start success\n"); in aw88395_start_pa()
51 struct aw88395 *aw88395 = in aw88395_startup_work() local
52 container_of(work, struct aw88395, start_work.work); in aw88395_startup_work()
54 mutex_lock(&aw88395->lock); in aw88395_startup_work()
55 aw88395_start_pa(aw88395); in aw88395_startup_work()
56 mutex_unlock(&aw88395->lock); in aw88395_startup_work()
59 static void aw88395_start(struct aw88395 *aw88395, bool sync_start) in aw88395_start() argument
63 if (aw88395->aw_pa->fw_status != AW88395_DEV_FW_OK) in aw88395_start()
66 if (aw88395->aw_pa->status == AW88395_DEV_PW_ON) in aw88395_start()
69 ret = aw88395_dev_fw_update(aw88395->aw_pa, AW88395_DSP_FW_UPDATE_OFF, true); in aw88395_start()
71 dev_err(aw88395->aw_pa->dev, "fw update failed."); in aw88395_start()
76 aw88395_start_pa(aw88395); in aw88395_start()
79 &aw88395->start_work, in aw88395_start()
85 .name = "aw88395-aif",
108 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); in aw88395_get_fade_in_time() local
109 struct aw_device *aw_dev = aw88395->aw_pa; in aw88395_get_fade_in_time()
120 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); in aw88395_set_fade_in_time() local
123 struct aw_device *aw_dev = aw88395->aw_pa; in aw88395_set_fade_in_time()
143 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); in aw88395_get_fade_out_time() local
144 struct aw_device *aw_dev = aw88395->aw_pa; in aw88395_get_fade_out_time()
155 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); in aw88395_set_fade_out_time() local
158 struct aw_device *aw_dev = aw88395->aw_pa; in aw88395_set_fade_out_time()
177 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_profile_info() local
185 count = aw88395_dev_get_profile_count(aw88395->aw_pa); in aw88395_profile_info()
199 prof_name = aw88395_dev_get_prof_name(aw88395->aw_pa, count); in aw88395_profile_info()
215 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_profile_get() local
217 ucontrol->value.integer.value[0] = aw88395_dev_get_profile_index(aw88395->aw_pa); in aw88395_profile_get()
226 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_profile_set() local
230 mutex_lock(&aw88395->lock); in aw88395_profile_set()
231 ret = aw88395_dev_set_profile_index(aw88395->aw_pa, ucontrol->value.integer.value[0]); in aw88395_profile_set()
234 mutex_unlock(&aw88395->lock); in aw88395_profile_set()
238 if (aw88395->aw_pa->status) { in aw88395_profile_set()
239 aw88395_dev_stop(aw88395->aw_pa); in aw88395_profile_set()
240 aw88395_start(aw88395, AW88395_SYNC_START); in aw88395_profile_set()
243 mutex_unlock(&aw88395->lock); in aw88395_profile_set()
252 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_volume_get() local
253 struct aw_volume_desc *vol_desc = &aw88395->aw_pa->volume_desc; in aw88395_volume_get()
264 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_volume_set() local
265 struct aw_volume_desc *vol_desc = &aw88395->aw_pa->volume_desc; in aw88395_volume_set()
276 aw88395_dev_set_volume(aw88395->aw_pa, vol_desc->ctl_volume); in aw88395_volume_set()
288 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_get_fade_step() local
290 ucontrol->value.integer.value[0] = aw88395->aw_pa->fade_step; in aw88395_get_fade_step()
299 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_set_fade_step() local
308 if (aw88395->aw_pa->fade_step != value) { in aw88395_set_fade_step()
309 aw88395->aw_pa->fade_step = value; in aw88395_set_fade_step()
320 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_re_get() local
321 struct aw_device *aw_dev = aw88395->aw_pa; in aw88395_re_get()
332 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(codec); in aw88395_re_set() local
335 struct aw_device *aw_dev = aw88395->aw_pa; in aw88395_re_set()
370 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); in aw88395_playback_event() local
372 mutex_lock(&aw88395->lock); in aw88395_playback_event()
375 aw88395_start(aw88395, AW88395_ASYNC_START); in aw88395_playback_event()
378 aw88395_dev_stop(aw88395->aw_pa); in aw88395_playback_event()
383 mutex_unlock(&aw88395->lock); in aw88395_playback_event()
408 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(component); in aw88395_codec_probe() local
411 INIT_DELAYED_WORK(&aw88395->start_work, aw88395_startup_work); in aw88395_codec_probe()
433 struct aw88395 *aw88395 = snd_soc_component_get_drvdata(aw_codec); in aw88395_codec_remove() local
435 cancel_delayed_work_sync(&aw88395->start_work); in aw88395_codec_remove()
443 static struct aw88395 *aw88395_malloc_init(struct i2c_client *i2c) in aw88395_malloc_init()
445 struct aw88395 *aw88395 = devm_kzalloc(&i2c->dev, in aw88395_malloc_init() local
446 sizeof(struct aw88395), GFP_KERNEL); in aw88395_malloc_init()
447 if (!aw88395) in aw88395_malloc_init()
450 mutex_init(&aw88395->lock); in aw88395_malloc_init()
452 return aw88395; in aw88395_malloc_init()
455 static void aw88395_hw_reset(struct aw88395 *aw88395) in aw88395_hw_reset() argument
457 if (aw88395->reset_gpio) { in aw88395_hw_reset()
458 gpiod_set_value_cansleep(aw88395->reset_gpio, 0); in aw88395_hw_reset()
460 gpiod_set_value_cansleep(aw88395->reset_gpio, 1); in aw88395_hw_reset()
463 dev_err(aw88395->aw_pa->dev, "%s failed", __func__); in aw88395_hw_reset()
467 static int aw88395_request_firmware_file(struct aw88395 *aw88395) in aw88395_request_firmware_file() argument
472 aw88395->aw_pa->fw_status = AW88395_DEV_FW_FAILED; in aw88395_request_firmware_file()
474 ret = request_firmware(&cont, AW88395_ACF_FILE, aw88395->aw_pa->dev); in aw88395_request_firmware_file()
476 dev_err(aw88395->aw_pa->dev, "load [%s] failed!", AW88395_ACF_FILE); in aw88395_request_firmware_file()
480 dev_info(aw88395->aw_pa->dev, "loaded %s - size: %zu\n", in aw88395_request_firmware_file()
483 aw88395->aw_cfg = devm_kzalloc(aw88395->aw_pa->dev, cont->size + sizeof(int), GFP_KERNEL); in aw88395_request_firmware_file()
484 if (!aw88395->aw_cfg) { in aw88395_request_firmware_file()
488 aw88395->aw_cfg->len = (int)cont->size; in aw88395_request_firmware_file()
489 memcpy(aw88395->aw_cfg->data, cont->data, cont->size); in aw88395_request_firmware_file()
492 ret = aw88395_dev_load_acf_check(aw88395->aw_pa, aw88395->aw_cfg); in aw88395_request_firmware_file()
494 dev_err(aw88395->aw_pa->dev, "Load [%s] failed ....!", AW88395_ACF_FILE); in aw88395_request_firmware_file()
498 dev_dbg(aw88395->aw_pa->dev, "%s : bin load success\n", __func__); in aw88395_request_firmware_file()
500 mutex_lock(&aw88395->lock); in aw88395_request_firmware_file()
502 ret = aw88395_dev_init(aw88395->aw_pa, aw88395->aw_cfg); in aw88395_request_firmware_file()
504 dev_err(aw88395->aw_pa->dev, "dev init failed"); in aw88395_request_firmware_file()
505 mutex_unlock(&aw88395->lock); in aw88395_request_firmware_file()
512 struct aw88395 *aw88395; in aw88395_i2c_probe() local
520 aw88395 = aw88395_malloc_init(i2c); in aw88395_i2c_probe()
521 if (!aw88395) { in aw88395_i2c_probe()
522 dev_err(&i2c->dev, "malloc aw88395 failed"); in aw88395_i2c_probe()
525 i2c_set_clientdata(i2c, aw88395); in aw88395_i2c_probe()
527 aw88395->reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_LOW); in aw88395_i2c_probe()
528 if (IS_ERR(aw88395->reset_gpio)) in aw88395_i2c_probe()
532 aw88395_hw_reset(aw88395); in aw88395_i2c_probe()
534 aw88395->regmap = devm_regmap_init_i2c(i2c, &aw88395_remap_config); in aw88395_i2c_probe()
535 if (IS_ERR(aw88395->regmap)) { in aw88395_i2c_probe()
536 ret = PTR_ERR(aw88395->regmap); in aw88395_i2c_probe()
542 ret = aw88395_init(&aw88395->aw_pa, i2c, aw88395->regmap); in aw88395_i2c_probe()
546 ret = aw88395_request_firmware_file(aw88395); in aw88395_i2c_probe()
556 dev_err(&i2c->dev, "failed to register aw88395: %d", ret); in aw88395_i2c_probe()
578 MODULE_DESCRIPTION("ASoC AW88395 Smart PA Driver");