forked from spkr-beep/beep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beep-driver.h
121 lines (92 loc) · 2.99 KB
/
beep-driver.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/** \file beep-driver.h
* \brief the interface all beep drivers implement
* \author Copyright (C) 2019 Hans Ulrich Niedermann
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*
* \defgroup beep_driver beep driver definition
*
* @{
*
*/
#ifndef BEEP_DRIVER_H
#define BEEP_DRIVER_H
#include <stdbool.h>
#include <stdint.h>
/**
* Abstract declaration of beep_driver.
*/
typedef struct _beep_driver beep_driver;
/**
* Driver function to detect whether the driver can actually work.
*/
typedef bool (*beep_driver_detect_func) (beep_driver *driver,
const char *console_device);
/**
* Driver function to initialize the driver.
*/
typedef void (*beep_driver_init_func) (beep_driver *driver);
/**
* Driver function to destroy and clean up the driver.
*/
typedef void (*beep_driver_fini_func) (beep_driver *driver);
/**
* Driver function to have the driver begin a tone.
*/
typedef void (*beep_driver_begin_tone_func) (beep_driver *driver,
const uint16_t freq);
/**
* Driver function to have the driver end a tone.
*/
typedef void (*beep_driver_end_tone_func) (beep_driver *driver);
/**
* Internal beep driver data structure.
*/
struct _beep_driver {
/** Unique name for the driver */
char *name;
/** Link to next driver in linked list of drivers.
*
* To be filled out by the beep_drivers_register() function once,
* and only be read from everywhere else.
*/
beep_driver *next;
/** beep driver detect function */
beep_driver_detect_func detect;
/** beep driver init function */
beep_driver_init_func init;
/** beep driver fini function */
beep_driver_fini_func fini;
/** beep driver begin_tone function */
beep_driver_begin_tone_func begin_tone;
/** beep driver end_tone function */
beep_driver_end_tone_func end_tone;
/* As long as all drivers need the following data items, we do not
* need to hide them in the driver implementation.
*/
/** device file descriptor for this driver */
int device_fd;
/** device file name for this driver */
const char *device_name;
};
#endif /* !defined(BEEP_DRIVER_H) */
/** @} */
/*
* Local Variables:
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*/