/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param volume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum volume value. return kStatus_Success is success, else configure failed.  */
status_t HAL_CODEC_DA7212_SetVolume(void *handle, uint32_t playChannel, uint32_t volume)
/* param handle codec handle. param channel audio codec play channel, can be a value or combine value of _codec_play_channel. param volume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum volume value. return kStatus_Success is success, else configure failed.  */
status_t HAL_CODEC_DA7212_SetVolume(void *handle, uint32_t playChannel, uint32_t volume)
{
    assert(handle != NULL);
    uint32_t mappedVolume = 0;
    status_t ret          = kStatus_Success;
    if (volume == 0U)
    {
        return DA7212_SetChannelMute((da7212_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)),
                                     playChannel, true);
    }
    mappedVolume = ((volume - 1U) * (DA7212_HEADPHONE_MAX_VOLUME_VALUE + 1U)) / 100U;
    ret = DA7212_SetChannelVolume((da7212_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)),
                                  playChannel, mappedVolume);
    if (ret == kStatus_Success)
    {
        ret = DA7212_SetChannelMute((da7212_handle_t *)((uint32_t)(((codec_handle_t *)handle)->codecDevHandle)),
                                    playChannel, false);
    }
    return ret;
}