114 lines
3.2 KiB
C
114 lines
3.2 KiB
C
/**
|
|
* @file sdrv_codec_tlv320.h
|
|
* @author your name (you@domain.com)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2022-08-24
|
|
*
|
|
* @copyright Copyright (c) 2022
|
|
*
|
|
*/
|
|
|
|
#ifndef _SDRV_CODEC_TLV320_H_
|
|
#define _SDRV_CODEC_TLV320_H_
|
|
|
|
#include <sdrv_gpio.h>
|
|
#include <sdrv_i2c.h>
|
|
|
|
#include "sdrv_codec.h"
|
|
|
|
typedef enum sdrv_codec_tlv320_input {
|
|
SDRV_CODEC_TLV320_INPUT_MIC_IN = 0,
|
|
SDRV_CODEC_TLV320_INPUT_LINE_IN,
|
|
} sdrv_codec_tlv320_input_t;
|
|
|
|
typedef enum sdrv_codec_tlv320_output {
|
|
SDRV_CODEC_TLV320_OUTPUT_PHONE_OUT = 0,
|
|
SDRV_CODEC_TLV320_OUTPUT_LINE_OUT,
|
|
} sdrv_codec_tlv320_output_t;
|
|
|
|
/**
|
|
* @brief codec device specific configuration , it is defined by specific codec
|
|
*
|
|
*/
|
|
typedef struct sdrv_codec_tlv320_cfg {
|
|
/*!< codec i2c control module. */
|
|
sdrv_i2c_t i2c_ctrl;
|
|
/*!< codec i2c device address. */
|
|
uint16_t slave_addr;
|
|
/*!< codec mclk rate which is defined in clock config. */
|
|
uint32_t clk_rate;
|
|
/*!< codec mclk rate which is defined in clock config. */
|
|
sdrv_codec_tlv320_input_t input_path;
|
|
sdrv_codec_tlv320_output_t output_path;
|
|
} sdrv_codec_tlv320_cfg_t;
|
|
|
|
/**
|
|
* @brief initializes codec module
|
|
*
|
|
* This fuction is used to initializes codec module.
|
|
*
|
|
* @param [in] codec sdrv codec device
|
|
* @param [in] cfg sdrv codec device configurations
|
|
* @return sdrv_codec_status_t
|
|
*
|
|
*/
|
|
sdrv_codec_status_t sdrv_codec_tlv320_init(sdrv_codec_t *codec,
|
|
sdrv_codec_cfg_t *cfg);
|
|
|
|
/**
|
|
* @brief set audio codec module params.
|
|
*
|
|
* This fuction set codec params
|
|
*
|
|
* @param [in] codec sdrv codec device
|
|
* @param [in] params sdrv codec params
|
|
* @param [in] type playback or capture type
|
|
* @ return sdrv_codec_status_t
|
|
*
|
|
*
|
|
*/
|
|
sdrv_codec_status_t sdrv_codec_tlv320_set_params(sdrv_codec_t *codec,
|
|
sdrv_codec_params_t *params,
|
|
sdrv_codec_stream_type_t type);
|
|
/**
|
|
* @brief start or stop audio codec module
|
|
*
|
|
* This fuction is used to start or stop audio codec module
|
|
*
|
|
* @param [in] codec sdrv codec device
|
|
* @param [in] cmd start or stop cmd
|
|
* @param [in] type playback or capture type
|
|
* @ return sdrv_codec_status_t
|
|
*
|
|
*
|
|
*/
|
|
sdrv_codec_status_t sdrv_codec_tlv320_trigger(sdrv_codec_t *codec,
|
|
sdrv_codec_trigger_op_t cmd,
|
|
sdrv_codec_stream_type_t type);
|
|
|
|
/**
|
|
* @brief set audio codec volume.
|
|
*
|
|
* @param codec sdrv codec device
|
|
* @param volume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum
|
|
* volume value.
|
|
*
|
|
* @return sdrv_codec_status_t is success, else configure failed.
|
|
*/
|
|
sdrv_codec_status_t sdrv_codec_tlv320_set_volume(sdrv_codec_t *codec,
|
|
uint8_t volume,
|
|
sdrv_codec_stream_type_t type);
|
|
|
|
/**
|
|
* @brief set audio codec mute.
|
|
*
|
|
* @param codec sdrv codec device
|
|
* @param mute true is mute, false is unmute
|
|
* @param type playback or capture type
|
|
* @return sdrv_codec_status_t
|
|
*/
|
|
sdrv_codec_status_t sdrv_codec_tlv320_set_mute(sdrv_codec_t *codec, bool mute,
|
|
sdrv_codec_stream_type_t type);
|
|
|
|
#endif //_SDRV_CODEC_TLV320_H_
|