aboutsummaryrefslogtreecommitdiffstats
path: root/pwm.h
blob: 30eb91ebe2e40255f64d4c915b864b3c8de53a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* SPDX-License-Identifier: LGPL-2.1-only */
/* SPDX-FileCopyrightText: 2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> */

#ifndef __LIBPWM_PWM_H__
#define __LIBPWM_PWM_H__

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

struct pwm_chip;
struct pwm;

struct pwm_state {
	uint64_t period;
	uint64_t duty_cycle;
	uint64_t duty_offset;
};

struct pwm_chip *pwm_chip_open_by_number(unsigned int num);
void pwm_chip_close(struct pwm_chip *chip);

int pwm_chip_num_pwms(struct pwm_chip *chip);

struct pwm *pwm_chip_get_pwm(struct pwm_chip *chip, unsigned int offset);

int pwm_apply_state(struct pwm *pwm, const struct pwm_state *state);

int pwm_get_state(struct pwm *pwm, struct pwm_state *state);

#ifdef __cplusplus
}
#endif

#endif /* ifndef __LIBPWM_PWM_H__ */