/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
/*
 * Copyright (c) 2021 MediaTek Inc.
 */

#ifndef _VOC_MIC_CAP_IFACE_H
#define _VOC_MIC_CAP_IFACE_H

//------------------------------------------------------------------------------
//  Include Files
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Enumerate And Structure
//------------------------------------------------------------------------------
struct mic_iface_intclr_t {
	int mode;
	int overrun_flag;
	int full_flag;
	int timer_flag;
	int overrun_threshold;
};

struct mic_iface_intsts_t {
	int overrun;
	int full;
	int timer;
};

enum mic_iface_cmd {
	MIC_INPUT_MODE = 0,
	MIC_SWITCH,
	MIC_BCK_MODE,
	MIC_BCK_DRIVE,
	MIC_SAMPLE_RATE,
	MIC_BIT_WIDTH,
	MIC_CHANNELS,
	MIC_GAIN_STEP,
	MIC_MUTE_MODE,
	MIC_HPF_CONFIG,
	MIC_HPF_MODE,
	MIC_SINEGEN_MODE,
	MIC_INCGEN_MODE,
	MIC_MERGED_CHANNEL,
	MIC_MAX_CMD
};

enum mic_iface_status {
	MIC_STATUS_NONE = 0,
	MIC_STATUS_INITED,
	MIC_STATUS_STARTED,
	MIC_STATUS_STOPPED,
	MIC_STATUS_XRUN,
	MIC_STATUS_UNKNOWN
};

enum mic_iface_intclr {
	MIC_INT_NONE = 0,
	MIC_INT_OVERRUN,
	MIC_INT_FULL,
	MIC_INT_TIMER,
	MIC_INT_UNKNOWN
};

//------------------------------------------------------------------------------
// Global Function
//------------------------------------------------------------------------------
int voc_mic_cap_iface_init(void);
int voc_mic_cap_iface_open(uint32_t sample_rate, uint32_t bit_width, uint32_t channels);
int voc_mic_cap_iface_close(int handler);
int voc_mic_cap_iface_set_buf_addr(int handler, int map_mode,
					void *phyAddr, void *virtAddr, uint32_t size);
int voc_mic_cap_iface_get_status(int handler);
int voc_mic_cap_iface_set_attr(enum mic_iface_cmd cmd, void *param);
int voc_mic_cap_iface_get_attr(enum mic_iface_cmd cmd, void *param);
int voc_mic_cap_iface_start_channel(int handler);
int voc_mic_cap_iface_stop_channel(int handler);
uint32_t voc_mic_cap_iface_get_level_count(int handler);
uint32_t voc_mic_cap_iface_read_data(int handler, uint8_t *dst_buf, uint32_t buf_size);
int voc_mic_cap_iface_register_interrupt_callback(int handler, void *callback);
int voc_mic_cap_iface_enable_interrupt(int handler, struct mic_iface_intclr_t mode);
int voc_mic_cap_iface_clear_interrupt_status(int handler, enum mic_iface_intclr intclr);
int voc_mic_cap_iface_set_log_level(int level);

#endif /* _VOC_MIC_CAP_IFACE_H */
