/******************************************************************************
 *
 * 2017 (c) Lattice Semiconductor Corporation
 * 
 * This program is free software; you can redistribute it and/or
 * modify it only under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation, and not any later version.
 * 
 * This program is distributed "AS IS" WITHOUT ANY WARRANTY of any kind,
 * whether express or implied, including without limitation the implied warranty
 * of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE or NON-INFRINGEMENT.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * You may contact Lattice Semiconductor Corporation at 
 * 111 SW 5th Ave, Suite 700, Portland, OR 97204.
 *
 *****************************************************************************/

/**
* @file sii9438_api.h
*
* @brief Driver API for SiI9438 Tx devices.
*
*******************************************************************************/

#ifndef SII9438_API_H
#define SII9438_API_H

#include "sii_datatypes.h"
#include "sii_lib_data.h"

#ifdef __cplusplus
extern "C" {
#endif

/***************************** API Return Codes *******************************/
/**
 * Return value for successful API execution
 */
#define SII_RETURN_VALUE__SUCCESS	0

/**
 * Error value returned when the device ID used to create instance
 * using Create API is not valid or duplicate.
 */
#define SII_RETURN_VALUE__DEV_ID_ERR		1
/**
 * Error value returned when the input channel status is invalid.
 */
#define SII_RETURN_VALUE__CH_STATUS_ERR		2

/**
 * Error value returned when the driver got asserted for an error and no more
 * in operational mode. Use sii9438_assert_query API to find out the assertion
 * details.
 */
#define SII_RETURN_VALUE_ASSERTION_ERR		255
/**
 * Return value for failure in API execution
 */
#define SII_RETURN_VALUE__FAIL			(-1)

/******************************************************************************/

typedef void (*sii9438_event_callback_func)(uint32_t *callback_param);

/*** Events to be notified ***/

/** Event when logging FIFO buffer becomes non-empty */
#define SII9438_EVENT_FLAGS__LOG_FIFO_CHNG		((uint32_t)1 << 0)

/** Event when incoming 'eARC_HPD' level is changed */
#define SII9438_EVENT_FLAGS__EARC_HPD_CHNG		((uint32_t)1 << 1)

/** Event when eARC link is established or lost */
#define SII9438_EVENT_FLAGS__EARC_LINK_CHNG		((uint32_t)1 << 2)

/** Event when SPDIF audio channel status is changed */
#define SII9438_EVENT_FLAGS__SPDIF_CHAN_STAT_CHNG	((uint32_t)1 << 3)

/** Event when new Capabilities Data Structure is available */
#define SII9438_EVENT_FLAGS__CAPS_DS_CHNG		((uint32_t)1 << 5)

/** Event when any one of the GPIOs, which is configured as input and enabled
 * for event notifications through sii9438_gpio_event_mask_set API, has
 * input level change either from low to high or from high to low*/
#define SII9438_EVENT_FLAGS__GPIO_CHNG			((uint32_t)1 << 6)

/** Event to notify an assertion failure in the driver. This event should
 * be handled by calling sii9438_assert_query API to get the details of
 * assertion failure. After this event, there will be no guarantee for the
 * driver to be functionally correct until it is restarted.
 */
#define SII9438_EVENT_FLAGS__ASSERT			((uint32_t)1 << 7)

/** Event to notify the eARC Rx erx audio latency change */
#define SII9438_EVENT_FLAGS__ERX_LATENCY_CHNG		((uint32_t)1 << 8)

/** Event to notify the eARC Discovery Failure due to No Comma from RX */
#define SII9438_EVENT_FLAGS__EARC_DISC_TIMEOUT		((uint32_t)1 << 9)

enum sii9438_insertion_mode {
	/* Insertion mode: None*/
	SII9438_INSERTION_MODE__NONE,
	/* Insertion mode: 2 channel SPDIF*/
	SII9438_INSERTION_MODE__SPDIF2,
	/* Insertion mode: Multi-channel SPDIF*/
	SII9438_INSERTION_MODE__SPDIF8,
	/* Insertion mode: 2 channel I2S*/
	SII9438_INSERTION_MODE__I2S2,
	/* Insertion mode: Multi-channel I2s*/
	SII9438_INSERTION_MODE__I2S8
};

enum sii9438_vbit {
	/* V bit value 0*/
	SII9438_VBIT_0,
	/* V bit value 1*/
	SII9438_VBIT_1,
	/* Bypass V bit value*/
	SII9438_VBIT_BYPASS
};

enum sii9438_mclk_div {
	/* No MCLK division required*/
	SII9438_MCLK_DIV__NO_DIV,
	/* Divide incoming MCLK by 2*/
	SII9438_MCLK_DIV__BY2,
	/* Divide incoming MCLK by 4*/
	SII9438_MCLK_DIV__BY4
};

struct sii9438_config {
	/* Hardware device instantiation identification number.
	* When the system includes more than one instance of
	* SiI9438, The user must make sure that each
	* instantiation is created with a unique dev_id.
	* dev_id is passed into the platform host interface
	* layer and is used to select a different I2C device
	* address or a different SPI chip select signal.
	*/
	uint32_t dev_id;

	/* Pointer to a call back function invoked by the
	* driver when any status change event happens.
	* If set as NULL, the callback is not invoked.
	*/
	sii9438_event_callback_func callback_func;

	/* Logging FIFO Queue size in bytes */
	uint32_t log_fifo_size;

	/* I2C address to access TX eARC registers */
	uint8_t i2c_addr_page1;

	/* I2C address to access TX HW TPI registers */
	uint8_t i2c_addr_page2;

	/* I2C address to access TX SW TPI registers */
	uint8_t i2c_addr_page3;

	/* I2C address to access PHY registers */
	uint8_t i2c_addr_page4;
};

/******************************************************************************/
/**
* @brief Adapter driver creation
*
* Allocates resources for Adapter Driver and all child modules.
* This function has to be called before using of any other module function.
* This function also registers a callback function provided in the
* the config structure that'll be called when any status change event occurs.
*
* @param[in]	p_config	Pointer to a static configuration structure
*				containing static configuration parameters for
*				this driver instantiation.
* @param[out]	p_inst		Pointer to driver instance handle required
*				by all other functions.Zero will be returned
*				when creation of instance has failed
*
* @retval	See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_create(const struct sii9438_config *p_config,
			sii_inst_t *p_inst);

/******************************************************************************/
/**
* @brief Adapter Driver deletion
*
* Frees resources allocated by sii9438_create for the driver instance identified
* by inst and shuts down the driver. After this function is called, no other
* module functions can be called for this driver instance until sii9438_create()
* is called again and a new driver handle is received.
*
* @param[in]	inst	Driver instance handle obtained from calling
*			sii9438_create. This is used by sii9438_delete to
*			identify the driver instance to delete.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_delete(sii_inst_t inst);

/******************************************************************************/
/**
* @brief Adapter Driver handle
*
* This function is expected to be called by the user application within 50msec
* after SiI9438 chip generates an interrupt (INT='1'). If the interrupt signal
* (INT) from the SiI9438 is not connected to application processor, this
* function must be called periodically with a time interval of
* no more than 50msec.
* This function checks if there are any pending notifications from the SiI9438
* chip, services them and may generate an SII9438_EVENT 'notifications' by
* calling the sii9438_event_callback_func callback function registered through
* sii9438_create().
*
* @param[in]	inst	Driver instance handle obtained by calling
			sii9438_create
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_handle(sii_inst_t inst);

/******************************************************************************/
/**
* @brief Chip ID inquiry
*
* p_chip_id_stat should contain 0x9438 after calling.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[out]	p_chip_id_stat	Pointer to a variable in which the chip ID
*				 information is returned.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_chip_id_query(sii_inst_t inst,
	uint32_t *p_chip_id_stat);

/******************************************************************************/
/**
* @brief Chip version
*
* Returns Chip version number.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[out]	p_chip_version	Pointer to a variable in which the chip
*				revision information is returned.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_chip_version_query(sii_inst_t inst, uint8_t *p_chip_version);

/******************************************************************************/
/**
* @brief Software Version Number
*
* Outputs software version number.
*
* @param[out]	version_str	Pointer to a string in which the software
*				version information is returned.
* @param[in]	size		Size of the version string to be returned
*
* @retval			The number of characters that were missed out
*				from the original string generated internally,
*				including missing string-end character ('0').
*
*				If the return value is zero then the version
*				string size was less than the 'size'.
*
*				If the return value is non-zero then
*				the returned string does not contain a
*				string-end character ('0').
*
*				The maximum number of returned characters by
*				design (including string-end character) is 65
*
*******************************************************************************/
uint32_t sii9438_software_version_query(char *version_str, uint8_t size);

/******************************************************************************/
/**
* @brief Log Queue Query
*
* Returns logging string stored in internal fifo. Size of logging fifo
* can be allocated upon sii9438_create.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[out]	log_string_str	Pointer the return string.
* @param[in]	size	Size of the string to be returned
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_log_queue_query(sii_inst_t inst,
	char *log_string_str, uint32_t size);

/******************************************************************************/
/**
* @brief Log Queue Size
*
* Returns unsigned number of characters stored in logging queue.
* Fifo overflow is indicated by all bits set to '1'.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create
* @param[out]	p_size	Pointer the log size value returned.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_log_queue_size(sii_inst_t inst, uint32_t *p_size);

/******************************************************************************/
/**
* @brief Assert Query
*
* Returns 32 bit integer defined as follow:
* Bit  0-23 : line number in source code
* Bit 24-31 : Module ID#.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create
* @param[out]	p_value	Pointer to the integer value returned.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_assert_query(sii_inst_t inst, uint32_t *p_value);

/******************************************************************************/
/**
* @brief Set/Get event flags mask
*
* Controls/Gets which events will cause notification handler to be called.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_flags_mask	Pointer to a variable which contains
*				mask information.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_event_flags_mask_set(sii_inst_t inst,
	uint32_t *p_flags_mask);
uint32_t sii9438_event_flags_mask_get(sii_inst_t inst,
	uint32_t *p_flags_mask);

/******************************************************************************/
/**
* @brief Event Flags clear request
*
* Clear internal event register bits.
* This function is only needed for unmasked events.
* Masked events are automatically cleared upon event call-back of
* sii9438_event_callback_func.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_flags_mask	Pointer to a variable containing the
*				notification mask to clear.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_event_flags_status_clear(sii_inst_t inst,
	uint32_t *p_flags_mask);

/******************************************************************************/
/**
* @brief Event Flags status inquiry
*
* Gets a bitmask of current events. Typically, only un-masked events are
* returned, since masked events get cleared upon event call-back of
* sii9438_event_callback_func.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_flags_status	Pointer to a variable in which the notification
*				mask information is returned.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_event_flags_query(sii_inst_t inst,
	uint32_t *p_flags_status);

/******************************************************************************/
/**
* @brief Set/Get standby mode
*
* Controls whether SiI9438 is in standby mode or full operational mode.
* In standby mode SiI9438 is configured for low power consumption.
* Note : User application can still change configuration while in standby mode.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_on	TRUE  : Put SiI9438 device in standby mode.
*			FALSE : Put SiI9438 in full operational mode.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_standby_set(sii_inst_t inst, bool_t *p_on);
uint32_t sii9438_standby_get(sii_inst_t inst, bool_t *p_on);

/******************************************************************************/
/**
* @brief Set/Get GPIO configuration
*
* Input / Output GPIO configuration.
* '1' enables GPIO to be an output,
* '0' enables GPIO to be an input.
* By default all GPIOs are configured as input.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_gpio_pin_mask	Each bit represents 1 GPIO pin based on the
*				following assignment:
*				Bit 0   : GPIO0
*				Bit 1   : GPIO1
*				Bit 2   : GPIO2
*				Bit 3   : GPIO3
*				Bit 4   : GPIO4
*				Bit 5   : GPIO5
*				Bit 6,7 : Unused
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_gpio_config_set(sii_inst_t inst,
	uint16_t *p_gpio_pin_mask);
uint32_t sii9438_gpio_config_get(sii_inst_t inst,
	uint16_t *p_gpio_pin_mask);

/******************************************************************************/
/**
* @brief Set/Clear level on GPIO pins configured as output
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_gpio_pin_mask	Each bit represents 1 GPIO pin based on the
*				following assignment:
*				Bit 0   : GPIO0
*				Bit 1   : GPIO1
*				Bit 2   : GPIO2
*				Bit 3   : GPIO3
*				Bit 4   : GPIO4
*				Bit 5   : GPIO5
*				Bit 6,7 : Unused
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_gpio_output_set(sii_inst_t inst,
	uint16_t *p_gpio_pin_mask);
uint32_t sii9438_gpio_output_clr(sii_inst_t inst,
	uint16_t *p_gpio_pin_mask);

/******************************************************************************/
/**
* @brief Set/Get mask related to GPIO event control
*
* Any bit that is set causes an event 'SII9438_EVENT_FLAGS__GPIO_CHNG'
* to be generated as soon if associated GPIO is configured as an input
* and input level was changed either from low to high or from high to low.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_gpio_pin_mask	Bit field in which each bit represents 1 GPIO
*				pin based on the following assignment:
*				Bit 0   : GPIO0
*				Bit 1   : GPIO1
*				Bit 2   : GPIO2
*				Bit 3   : GPIO3
*				Bit 4   : GPIO4
*				Bit 5   : GPIO5
*				Bit 6,7 : Unused
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_gpio_event_mask_set(sii_inst_t inst,
	uint16_t *p_gpio_pin_mask);
uint32_t sii9438_gpio_event_mask_get(sii_inst_t inst,
	uint16_t *p_gpio_pin_mask);

/******************************************************************************/
/**
* @brief Retrieve current levels on all input GPIO pins
*
* @param[in] inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in] p_gpio_status	Each bit represents 1 GPIO pin based on the
*				following assignment:
*				Bit 0   : GPIO0
*				Bit 1   : GPIO1
*				Bit 2   : GPIO2
*				Bit 3   : GPIO3
*				Bit 4   : GPIO4
*				Bit 5   : GPIO5
*				Bit 6,7 : Unused
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_gpio_query(sii_inst_t inst, uint16_t *p_gpio_status);

/******************************************************************************/
/**
* @brief Returns eARC capability data structure data
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
*
* @param[in]	offset	Capability Data Structure offset pointer.
*			Must be less than 256.
* @param[out]	p_data	Pointer to local array of bytes.
* @param[in]	length	Length of requested data transaction.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_earc_caps_ds_query(sii_inst_t inst, uint16_t offset,
	uint8_t *p_data, uint16_t length);

/******************************************************************************/
/**
* @brief Returns eARC_HPD status when in eARC mode
*
* @param[in]	inst		Driver instance handle obtained by calling
*				sii9438_create
* @param[out]	p_earc_hpd	Pointer to eARC HPD status.
*
* @retval			See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_earc_hpd_query(sii_inst_t inst, bool_t *p_earc_hpd);

/******************************************************************************/
/**
* @brief Set/Get ARC mode
*
* Configures/Returns ARC mode (NONE, Legacy ARC, eARC).
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[out]	p_arc_mode	Pointer to the ARC mode to configure
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_arc_mode_set(sii_inst_t inst,
	enum sii_arc_mode *p_arc_mode);
uint32_t sii9438_arc_mode_get(sii_inst_t inst,
	enum sii_arc_mode *p_arc_mode);

/******************************************************************************/
/**
* @brief Query eARC link status
*
* Returns TRUE if eARC link is active.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create
* @param[out]	p_on	Pointer to eARC link status
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_earc_link_query(sii_inst_t inst, bool_t *p_on);

/******************************************************************************/
/**
* @brief Set/Get preferred insertion mode
*
* Configures audio insertion mode (NONE, SPDIF2, SPDIF8, I2S2, I2S8)
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[in]	p_mode	Pointer to the prefrerred insertion mode value
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_insertion_mode_set(sii_inst_t inst,
	enum sii9438_insertion_mode *p_mode);
uint32_t sii9438_insertion_mode_get(sii_inst_t inst,
	enum sii9438_insertion_mode *p_mode);

/******************************************************************************/
/**
* @brief Set/Get channel status
*
* Configures/Returns channel status data.
* (only applicable to SPDIF2, SPDIF8, I2S2, I2S8 extraction modes).
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create.
* @param[out]	p_channel_status	Pointer to the channel status
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_channel_status_set(sii_inst_t inst,
	struct sii_channel_status *p_channel_status);
uint32_t sii9438_channel_status_get(sii_inst_t inst,
	struct sii_channel_status *p_channel_status);

/******************************************************************************/
/**
* @brief Set/Get channel status pass through via SPDIF insertion modes
*
* If disabled user must call 'sii9438_channel_status_set()' to configure
* channel status.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create
* @param[out]	p_on	Pointer the boolean value to enable or disable
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_spdif_cs_passthru_enable_set(sii_inst_t inst,
	bool_t *p_on);
uint32_t sii9438_spdif_cs_passthru_enable_get(sii_inst_t inst,
	bool_t *p_on);

/******************************************************************************/
/**
* @brief SPDIF channel status query
*
* Returns channel status received via SPDIF input.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			 sii9438_create.
* @param[out]	p_channel_status	Pointer to the channel status
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_spdif_channel_status_query(sii_inst_t inst,
	struct sii_channel_status *p_channel_status);

/******************************************************************************/
/**
* @brief Set/Get mute enable for audio data
*
* Mutes(zeroes)/Unmutes audio data.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create
* @param[in]	p_flag	Pointer to the boolean flag
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_mute_enable_set(sii_inst_t inst, bool_t *p_flag);
uint32_t sii9438_mute_enable_get(sii_inst_t inst, bool_t *p_flag);

/******************************************************************************/
/**
* @brief Set HDMI HPD
*	 HPD output signal is defined by a logical 'AND' function
*	 between hpd_set() and HPD input signal.
*
* @param[in]	inst	Driver instance handle obtained by calling
*			sii9438_create
* @param[in]	p_hpd	TRUE  : Current HPD level is high
*			FALSE : Current HPD level is low
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_hpd_set(sii_inst_t inst, bool_t *p_hpd);


/******************************************************************************/
/**
* @brief Set/Get channel count/speaker allocation/lfepbl from audio info
*  to channel status
*
* @param[in]	inst		Driver instance handle obtained by calling
*				sii9438_create
* @param[in]	p_audi_info	pointer to the cc/sa/lfe from audio info
*
* @retval			See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_audio_info_set(sii_inst_t inst,
		struct sii_audio_info *p_audio_info);
uint32_t sii9438_audio_info_get(sii_inst_t inst,
		struct sii_audio_info *p_audio_info);

/******************************************************************************/
/**
* @brief Set/Get the eARC erx latency request in milliseconds
*
* Sets/Gets the eARC erx latency request value for eARC RX to adjust
* the audio latency.
*
* @param[in]	inst		Driver instance handle obtained by calling
*				sii9438_create.
* @param[in]	p_erx_latency_get	Pointer to the erx latency data request
*				value.
*				The default value after entering the [RX eARC]
*				state is 0
*				= 0 to 250: The requested audio latency in
*				  milliseconds from eARC input to the speakers
*				= 251 to 253: Reserved
*				= 254: eARC audio is not synced with video
*				  (no synchronisation required)
*				= 255: eARC TX does not have latency information
*				  (unknown latency)
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_erx_latency_req_set(sii_inst_t inst,
				struct sii_erx_latency_req *p_erx_latency_req);
uint32_t sii9438_erx_latency_req_get(sii_inst_t inst,
				struct sii_erx_latency_req *p_erx_latency_req);

/******************************************************************************/
/**
* @brief Query eARC Rx erx latency.
*
* Queries the eARC Rx current audio latency in milliseconds
*
* @param[in]	inst		Driver instance handle obtained by calling
*				sii9438_create.
* @param[in]	p_erx_latency	Pointer to the erx latency data.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_erx_latency_query(sii_inst_t inst,
				struct sii_erx_latency *p_erx_latency);

/******************************************************************************/
/**
* @brief Set/Get the v-bit value.
*
* Sets/Gets the V-bit value
*
* @param[in]	inst		Driver instance handle obtained by calling
*				sii9438_create.
* @param[in]	p_vbit		Pointer to the v-bit value.
*				The default value is 0
*				= 0 : V-bit value 0
*				= 1 : V-bit value 1
*				= 2 : Bypass the V-bit value.
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_vbit_set(sii_inst_t inst, enum sii9438_vbit *p_vbit);
uint32_t sii9438_vbit_get(sii_inst_t inst, enum sii9438_vbit *p_vbit);

/******************************************************************************/
/**
* @brief Set/Get MCLK divider
*
* Configures/Returns MCLK divider value.(Div by 1, Div by 2, Div by 4)
*
* @param[in]	inst	Driver instance handle obtained by calling
			sii9438_create
* @param[in]	p_div	Pointer to the value of MCLK divider
*
* @retval		See general SII_RETURN_VALUE definitions
*
*******************************************************************************/
uint32_t sii9438_mclk_div_set(sii_inst_t inst,
	enum sii9438_mclk_div *p_div);
uint32_t sii9438_mclk_div_get(sii_inst_t inst,
	enum sii9438_mclk_div *p_div);

#ifdef __cplusplus
}
#endif
#endif /* SII9438_API_H */
