/*
 * Created by jiaqiang.ye@lnxall.com
 *
 * Simple LNXALL Hardware Abstraction Layer
 *
 * 2024/11/12
 */

#ifndef LNXALL_HAL_H
#define LNXALL_HAL_H 1
#ifdef __cplusplus
extern "C" {
#endif

enum lnxhal_hwtype {
	LNXHAL_HWTYPE_UNKNOWN      = 0,
	LNXHAL_HWTYPE_RK3568,
	LNXHAL_HWTYPE_RK3568_BAU,
	LNXHAL_HWTYPE_RK3568_XDDL,
	LNXHAL_HWYTPE_IMX6UL_5F8280,
	LNXHAL_HWTYPE_EM1000,
	LNXHAL_HWTYPE_RK3588,
};

enum lnxhal_hwtype lnxhal_hw_gettype(void);

const char * lnxhal_hw_getname(enum lnxhal_hwtype hwt);

#define LNXHAL_HWCAP_POWER_DETECT    0x55AA0001

/*
 * return value:
 *          0 on negative
 *          1 when the hardware component `hwc does exists.
 */
int lnxhal_hw_has(int hwc);

typedef void * lnxhal_power_detect_t;

lnxhal_power_detect_t lnxhal_powerd_get(enum lnxhal_hwtype hwt);

/*
 * return value:
 *          -1 on error
 *          0 if device has external power on
 *          1 if device has external power off
 */
int lnxhal_powerd_poll(lnxhal_power_detect_t pdet,
	int timeout, int * ispowerdown);

void lnxhal_powerd_put(lnxhal_power_detect_t pdet);

#ifdef __cplusplus
};
#endif
#endif
