1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 #ifndef HDF_POWER_MANAGEMENT_H 9 #define HDF_POWER_MANAGEMENT_H 10 11 #include "hdf_device_desc.h" 12 #include "osal_sysevent.h" 13 14 enum PowerManagementMode { 15 HDF_POWER_SYS_CTRL, 16 HDF_POWER_DYNAMIC_CTRL, 17 HDF_POWER_MODE_MAX, 18 }; 19 20 /** 21 * @brief Defines the power management functions provided by the HDF for the driver. 22 * 23 * To use the power management mechanism provided by the HDF, implement operations of <b>IPowerEventListener</b> and 24 * invoke {@linkHdfDeviceRegisterPowerListener} to register the operations with the HDF. 25 * 26 * @since 1.0 27 */ 28 struct IPowerEventListener { 29 int (*DozeResume)(struct HdfDeviceObject *deviceObject); 30 int (*DozeSuspend)(struct HdfDeviceObject *deviceObject); 31 /** Wakes up the driver device. The driver developer implements the operation. */ 32 int (*Resume)(struct HdfDeviceObject *deviceObject); 33 /** Hibernates the driver device. The driver developer implements the operation. */ 34 int (*Suspend)(struct HdfDeviceObject *deviceObject); 35 }; 36 37 int HdfPmRegisterPowerListener(struct HdfDeviceObject *deviceObject, const struct IPowerEventListener *listener); 38 void HdfPmUnregisterPowerListener(struct HdfDeviceObject *deviceObject, const struct IPowerEventListener *listener); 39 void HdfPmAcquireDevice(struct HdfDeviceObject *deviceObject); 40 void HdfPmReleaseDevice(struct HdfDeviceObject *deviceObject); 41 #ifndef __LITEOS_M__ 42 void HdfPmAcquireDeviceAsync(struct HdfDeviceObject *deviceObject); 43 void HdfPmReleaseDeviceAsync(struct HdfDeviceObject *deviceObject); 44 #endif 45 void HdfPmSetMode(struct HdfDeviceObject *deviceObject, uint32_t mode); 46 #endif /* HDF_POWER_MANAGEMENT_H */ 47