[1/6] fd passing: move interface code from daemon.
[platform/core/api/peripheral-io.git] / src / interface / include / pwm.h
1 /*
2  * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __PWM_H__
18 #define __PWM_H__
19
20 /**
21  * @brief Enumeration for Polarity
22  */
23 typedef enum {
24         PWM_POLARITY_NORMAL = 0,
25         PWM_POLARITY_INVERSED,
26 } pwm_polarity_e;
27
28 /**
29 * @brief pwm_open() init pwm pin.
30 *
31 * @param[in] chip pwm chip number
32 * @param[in] pin pwm pin number
33 * @return On success, 0 is returned. On failure, a negative value is returned.
34 */
35 int pwm_open(int chip, int pin);
36
37 /**
38 * @brief pwm_close() deinit pwm pin.
39 *
40 * @param[in] chip pwm chip number
41 * @param[in] pin pwm pin number
42 * @return On success, 0 is returned. On failure, a negative value is returned.
43 */
44 int pwm_close(int chip, int pin);
45
46 /**
47 * @brief pwm_set_period() sets the pwm period.
48 *
49 * @param[in] chip pwm chip number
50 * @param[in] pin pwm pin number
51 * @param[in] period pwm period
52 * @return On success, 0 is returned. On failure, a negative value is returned.
53 */
54 int pwm_set_period(int chip, int pin, int period);
55
56 /**
57 * @brief pwm_get_period() gets the pwm period.
58 *
59 * @param[in] chip pwm chip number
60 * @param[in] pin pwm pin number
61 * @param[out] period pwm period
62 * @return On success, 0 is returned. On failure, a negative value is returned.
63 */
64 int pwm_get_period(int chip, int pin, int *period);
65
66 /**
67 * @brief pwm_set_duty_cycle() sets the pwm duty cycle.
68 *
69 * @param[in] chip pwm chip number
70 * @param[in] pin pwm pin number
71 * @param[in] duty_cycle pwm duty cycle
72 * @return On success, 0 is returned. On failure, a negative value is returned.
73 */
74 int pwm_set_duty_cycle(int chip, int pin, int duty_cycle);
75
76 /**
77 * @brief pwm_get_duty_cycle() gets the pwm duty cycle.
78 *
79 * @param[in] chip pwm chip number
80 * @param[in] pin pwm pin number
81 * @param[out] duty_cycle pwm duty cycle
82 * @return On success, 0 is returned. On failure, a negative value is returned.
83 */
84 int pwm_get_duty_cycle(int chip, int pin, int *duty_cycle);
85
86 /**
87 * @brief pwm_set_polarity() sets the pwm polarity.
88 *
89 * @param[in] chip pwm chip number
90 * @param[in] pin pwm pin number
91 * @param[in] polarity pwm polarity
92 * @return On success, 0 is returned. On failure, a negative value is returned.
93 */
94 int pwm_set_polarity(int chip, int pin, pwm_polarity_e polarity);
95 /**
96 * @brief pwm_get_polarity() gets the pwm polarity.
97 *
98 * @param[in] chip pwm chip number
99 * @param[in] pin pwm pin number
100 * @param[out] polarity pwm polarity
101 * @return On success, 0 is returned. On failure, a negative value is returned.
102 */
103 int pwm_get_polarity(int chip, int pin, pwm_polarity_e *polarity);
104
105 /**
106 * @brief pwm_set_enable() sets the pwm state.
107 *
108 * @param[in] chip pwm chip number
109 * @param[in] pin pwm pin number
110 * @param[in] enable pwm enable/disabled state value
111 * @return On success, 0 is returned. On failure, a negative value is returned.
112 */
113 int pwm_set_enable(int chip, int pin, bool enable);
114
115 /**
116 * @brief pwm_get_enable() checks if pwm state is enabled.
117 *
118 * @param[in] chip pwm chip number
119 * @param[in] pin pwm pin number
120 * @param[out] enable pwm enable/disabled state value
121 * @return On success, 0 is returned. On failure, a negative value is returned.
122 */
123 int pwm_get_enable(int chip, int pin, bool *enable);
124
125 #endif /* __PWM_H__ */