/* * Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2019. All rights reserved. * Description: amp device and driver ad83583 * Author: audio * Create: 2019-05-30 */ #include "osal_ext.h" #include "soc_errno.h" #include "drv_amp_debug.h" #include "drv_amp_osal.h" #include "drv_amp_common.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ static td_s32 analog_init(const amp_platform_device *dev) { drv_amp_dev_hw_mute(dev, TD_FALSE); osal_msleep(DELAY_10_MS); return TD_SUCCESS; } static td_void analog_deinit(const amp_platform_device *dev) { drv_amp_dev_hw_mute(dev, TD_TRUE); osal_msleep(DELAY_10_MS); } static td_s32 analog_set_mute(const amp_platform_device *dev, amp_channel_type channel_type, td_bool mute) { drv_amp_dev_hw_mute(dev, mute); if (channel_type != AMP_CHANNEL_TYPE_ALL) { /* need add by custom for gain */ } return TD_SUCCESS; } static td_s32 analog_get_mute(const amp_platform_device *dev, amp_channel_type channel_type, td_bool *mute) { td_s32 ret; td_u32 value = 0; if (mute == TD_NULL) { return SOC_ERR_AMP_NULL_PTR; } ret = amp_osal_gpio_read_bit(&dev->mute_gpio, &value); if (ret != TD_SUCCESS) { soc_err_print_call_fun_err(amp_osal_gpio_read_bit, ret); return ret; } *mute = (value == dev->mute_gpio.value); if (channel_type != AMP_CHANNEL_TYPE_ALL) { /* need add by custom for mute */ } return TD_SUCCESS; } static amp_platform_driver g_analog_driver = { .dev_type = AMP_DEV_ANALOG, .deinit = analog_deinit, .init = analog_init, .get_mute = analog_get_mute, .set_mute = analog_set_mute, .hw_mute = drv_amp_dev_hw_mute, .reset = TD_NULL, }; td_s32 analog_register_driver(td_void) { return amp_platform_driver_register(&g_analog_driver); } #ifdef __cplusplus } #endif /* __cplusplus */