Line data Source code
1 0 : /* 2 : * Copyright 2024 Cirrus Logic, Inc. 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : #ifndef ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_ 8 : #define ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_ 9 : 10 : /** 11 : * @brief Haptics Interface 12 : * @defgroup haptics_interface Haptics Interface 13 : * @ingroup io_interfaces 14 : * @{ 15 : */ 16 : 17 : #include <zephyr/device.h> 18 : 19 : #ifdef __cplusplus 20 : extern "C" { 21 : #endif 22 : 23 : /** 24 : * @typedef haptics_stop_output_t 25 : * @brief Set the haptic device to stop output 26 : * @param dev Pointer to the device structure for haptic device instance 27 : */ 28 1 : typedef int (*haptics_stop_output_t)(const struct device *dev); 29 : 30 : /** 31 : * @typedef haptics_start_output_t 32 : * @brief Set the haptic device to start output for a playback event 33 : */ 34 1 : typedef int (*haptics_start_output_t)(const struct device *dev); 35 : 36 : /** 37 : * @brief Haptic device API 38 : */ 39 1 : __subsystem struct haptics_driver_api { 40 0 : haptics_start_output_t start_output; 41 0 : haptics_stop_output_t stop_output; 42 : }; 43 : 44 : /** 45 : * @brief Set the haptic device to start output for a playback event 46 : * 47 : * @param dev Pointer to the device structure for haptic device instance 48 : * 49 : * @retval 0 if successful 50 : * @retval <0 if failed 51 : */ 52 1 : __syscall int haptics_start_output(const struct device *dev); 53 : 54 : static inline int z_impl_haptics_start_output(const struct device *dev) 55 : { 56 : const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api; 57 : 58 : return api->start_output(dev); 59 : } 60 : 61 : /** 62 : * @brief Set the haptic device to stop output for a playback event 63 : * 64 : * @param dev Pointer to the device structure for haptic device instance 65 : * 66 : * @retval 0 if successful 67 : * @retval <0 if failed 68 : */ 69 1 : __syscall int haptics_stop_output(const struct device *dev); 70 : 71 : static inline int z_impl_haptics_stop_output(const struct device *dev) 72 : { 73 : const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api; 74 : 75 : return api->stop_output(dev); 76 : } 77 : 78 : /** 79 : * @} 80 : */ 81 : 82 : #ifdef __cplusplus 83 : } 84 : #endif /* __cplusplus */ 85 : 86 : #include <syscalls/haptics.h> 87 : 88 : #endif /* ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_ */