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 : * @defgroup haptics_interface_ext Device-specific Haptics API extensions
17 : *
18 : * @{
19 : * @}
20 : */
21 :
22 : #include <zephyr/device.h>
23 :
24 : #ifdef __cplusplus
25 : extern "C" {
26 : #endif
27 :
28 : /**
29 : * @typedef haptics_stop_output_t
30 : * @brief Set the haptic device to stop output
31 : * @param dev Pointer to the device structure for haptic device instance
32 : */
33 1 : typedef int (*haptics_stop_output_t)(const struct device *dev);
34 :
35 : /**
36 : * @typedef haptics_start_output_t
37 : * @brief Set the haptic device to start output for a playback event
38 : */
39 1 : typedef int (*haptics_start_output_t)(const struct device *dev);
40 :
41 : /**
42 : * @brief Haptic device API
43 : */
44 1 : __subsystem struct haptics_driver_api {
45 0 : haptics_start_output_t start_output;
46 0 : haptics_stop_output_t stop_output;
47 : };
48 :
49 : /**
50 : * @brief Set the haptic device to start output for a playback event
51 : *
52 : * @param dev Pointer to the device structure for haptic device instance
53 : *
54 : * @retval 0 if successful
55 : * @retval <0 if failed
56 : */
57 1 : __syscall int haptics_start_output(const struct device *dev);
58 :
59 : static inline int z_impl_haptics_start_output(const struct device *dev)
60 : {
61 : const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
62 :
63 : return api->start_output(dev);
64 : }
65 :
66 : /**
67 : * @brief Set the haptic device to stop output for a playback event
68 : *
69 : * @param dev Pointer to the device structure for haptic device instance
70 : *
71 : * @retval 0 if successful
72 : * @retval <0 if failed
73 : */
74 1 : __syscall int haptics_stop_output(const struct device *dev);
75 :
76 : static inline int z_impl_haptics_stop_output(const struct device *dev)
77 : {
78 : const struct haptics_driver_api *api = (const struct haptics_driver_api *)dev->api;
79 :
80 : return api->stop_output(dev);
81 : }
82 :
83 : /**
84 : * @}
85 : */
86 :
87 : #ifdef __cplusplus
88 : }
89 : #endif /* __cplusplus */
90 :
91 : #include <syscalls/haptics.h>
92 :
93 : #endif /* ZEPHYR_INCLUDE_DRIVERS_HAPTICS_H_ */
|