PipeWire  0.3.66
spa/include/spa/monitor/device.h
Go to the documentation of this file.
1 /* Simple Plugin API */
2 /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4 
5 #ifndef SPA_DEVICE_H
6 #define SPA_DEVICE_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <spa/utils/defs.h>
13 #include <spa/utils/hook.h>
14 #include <spa/utils/dict.h>
15 #include <spa/pod/event.h>
16 
30 #define SPA_TYPE_INTERFACE_Device SPA_TYPE_INFO_INTERFACE_BASE "Device"
31 
32 #define SPA_VERSION_DEVICE 0
33 struct spa_device { struct spa_interface iface; };
34 
41 #define SPA_VERSION_DEVICE_INFO 0
42  uint32_t version;
43 
44 #define SPA_DEVICE_CHANGE_MASK_FLAGS (1u<<0)
45 #define SPA_DEVICE_CHANGE_MASK_PROPS (1u<<1)
46 #define SPA_DEVICE_CHANGE_MASK_PARAMS (1u<<2)
47  uint64_t change_mask;
48  uint64_t flags;
49  const struct spa_dict *props;
51  uint32_t n_params;
52 };
53 
54 #define SPA_DEVICE_INFO_INIT() ((struct spa_device_info){ SPA_VERSION_DEVICE_INFO, })
55 
62 #define SPA_VERSION_DEVICE_OBJECT_INFO 0
63  uint32_t version;
64 
65  const char *type;
66  const char *factory_name;
68 #define SPA_DEVICE_OBJECT_CHANGE_MASK_FLAGS (1u<<0)
69 #define SPA_DEVICE_OBJECT_CHANGE_MASK_PROPS (1u<<1)
70  uint64_t change_mask;
71  uint64_t flags;
72  const struct spa_dict *props;
73 };
74 
75 #define SPA_DEVICE_OBJECT_INFO_INIT() ((struct spa_device_object_info){ SPA_VERSION_DEVICE_OBJECT_INFO, })
76 
78 #define SPA_RESULT_TYPE_DEVICE_PARAMS 1
80  uint32_t id;
81  uint32_t index;
82  uint32_t next;
83  struct spa_pod *param;
84 };
85 
86 #define SPA_DEVICE_EVENT_INFO 0
87 #define SPA_DEVICE_EVENT_RESULT 1
88 #define SPA_DEVICE_EVENT_EVENT 2
89 #define SPA_DEVICE_EVENT_OBJECT_INFO 3
90 #define SPA_DEVICE_EVENT_NUM 4
91 
99 #define SPA_VERSION_DEVICE_EVENTS 0
100  uint32_t version;
101 
103  void (*info) (void *data, const struct spa_device_info *info);
104 
106  void (*result) (void *data, int seq, int res, uint32_t type, const void *result);
107 
109  void (*event) (void *data, const struct spa_event *event);
110 
113  void (*object_info) (void *data, uint32_t id,
114  const struct spa_device_object_info *info);
115 };
116 
117 #define SPA_DEVICE_METHOD_ADD_LISTENER 0
118 #define SPA_DEVICE_METHOD_SYNC 1
119 #define SPA_DEVICE_METHOD_ENUM_PARAMS 2
120 #define SPA_DEVICE_METHOD_SET_PARAM 3
121 #define SPA_DEVICE_METHOD_NUM 4
122 
127  /* the version of the methods. This can be used to expand this
128  * structure in the future */
129 #define SPA_VERSION_DEVICE_METHODS 0
130  uint32_t version;
131 
147  int (*add_listener) (void *object,
148  struct spa_hook *listener,
149  const struct spa_device_events *events,
150  void *data);
166  int (*sync) (void *object, int seq);
167 
193  int (*enum_params) (void *object, int seq,
194  uint32_t id, uint32_t index, uint32_t max,
195  const struct spa_pod *filter);
196 
218  int (*set_param) (void *object,
219  uint32_t id, uint32_t flags,
220  const struct spa_pod *param);
221 };
222 
223 #define spa_device_method(o,method,version,...) \
224 ({ \
225  int _res = -ENOTSUP; \
226  struct spa_device *_o = (o); \
227  spa_interface_call_res(&_o->iface, \
228  struct spa_device_methods, _res, \
229  method, (version), ##__VA_ARGS__); \
230  _res; \
231 })
232 
233 #define spa_device_add_listener(d,...) spa_device_method(d, add_listener, 0, __VA_ARGS__)
234 #define spa_device_sync(d,...) spa_device_method(d, sync, 0, __VA_ARGS__)
235 #define spa_device_enum_params(d,...) spa_device_method(d, enum_params, 0, __VA_ARGS__)
236 #define spa_device_set_param(d,...) spa_device_method(d, set_param, 0, __VA_ARGS__)
237 
238 #define SPA_KEY_DEVICE_ENUM_API "device.enum.api"
240 #define SPA_KEY_DEVICE_API "device.api"
242 #define SPA_KEY_DEVICE_NAME "device.name"
243 #define SPA_KEY_DEVICE_ALIAS "device.alias"
244 #define SPA_KEY_DEVICE_NICK "device.nick"
245 #define SPA_KEY_DEVICE_DESCRIPTION "device.description"
246 #define SPA_KEY_DEVICE_ICON "device.icon"
248 #define SPA_KEY_DEVICE_ICON_NAME "device.icon-name"
250 #define SPA_KEY_DEVICE_PLUGGED_USEC "device.plugged.usec"
252 #define SPA_KEY_DEVICE_BUS_ID "device.bus-id"
253 #define SPA_KEY_DEVICE_BUS_PATH "device.bus-path"
256 #define SPA_KEY_DEVICE_BUS "device.bus"
259 #define SPA_KEY_DEVICE_SUBSYSTEM "device.subsystem"
260 #define SPA_KEY_DEVICE_SYSFS_PATH "device.sysfs.path"
262 #define SPA_KEY_DEVICE_VENDOR_ID "device.vendor.id"
263 #define SPA_KEY_DEVICE_VENDOR_NAME "device.vendor.name"
264 #define SPA_KEY_DEVICE_PRODUCT_ID "device.product.id"
265 #define SPA_KEY_DEVICE_PRODUCT_NAME "device.product.name"
266 #define SPA_KEY_DEVICE_SERIAL "device.serial"
267 #define SPA_KEY_DEVICE_CLASS "device.class"
268 #define SPA_KEY_DEVICE_CAPABILITIES "device.capabilities"
269 #define SPA_KEY_DEVICE_FORM_FACTOR "device.form-factor"
274 #define SPA_KEY_DEVICE_PROFILE "device.profile "
275 #define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set"
276 #define SPA_KEY_DEVICE_STRING "device.string"
283 #ifdef __cplusplus
284 } /* extern "C" */
285 #endif
286 
287 #endif /* SPA_DEVICE_H */
spa/utils/defs.h
spa/utils/hook.h
spa/pod/event.h
spa_device_events:
Definition: spa/include/spa/monitor/device.h:119
void(* result)(void *data, int seq, int res, uint32_t type, const void *result)
notify a result
Definition: spa/include/spa/monitor/device.h:129
void(* event)(void *data, const struct spa_event *event)
a device event
Definition: spa/include/spa/monitor/device.h:132
void(* info)(void *data, const struct spa_device_info *info)
notify extra information about the device
Definition: spa/include/spa/monitor/device.h:126
void(* object_info)(void *data, uint32_t id, const struct spa_device_object_info *info)
info changed for an object managed by the device, info is NULL when the object is removed
Definition: spa/include/spa/monitor/device.h:136
uint32_t version
Definition: spa/include/spa/monitor/device.h:123
Information about the device and parameters it supports.
Definition: spa/include/spa/monitor/device.h:47
uint64_t flags
Definition: spa/include/spa/monitor/device.h:59
struct spa_param_info * params
supported parameters
Definition: spa/include/spa/monitor/device.h:61
uint32_t version
Definition: spa/include/spa/monitor/device.h:50
uint32_t n_params
number of elements in params
Definition: spa/include/spa/monitor/device.h:62
uint64_t change_mask
Definition: spa/include/spa/monitor/device.h:58
spa_device_methods:
Definition: spa/include/spa/monitor/device.h:154
uint32_t version
Definition: spa/include/spa/monitor/device.h:159
int(* sync)(void *object, int seq)
Perform a sync operation.
Definition: spa/include/spa/monitor/device.h:195
int(* enum_params)(void *object, int seq, uint32_t id, uint32_t index, uint32_t max, const struct spa_pod *filter)
Enumerate the parameters of a device.
Definition: spa/include/spa/monitor/device.h:222
int(* set_param)(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
Set the configurable parameter in device.
Definition: spa/include/spa/monitor/device.h:247
int(* add_listener)(void *object, struct spa_hook *listener, const struct spa_device_events *events, void *data)
Set events to receive asynchronous notifications from the device.
Definition: spa/include/spa/monitor/device.h:176
Information about a device object.
Definition: spa/include/spa/monitor/device.h:73
uint32_t version
Definition: spa/include/spa/monitor/device.h:76
const char * type
the object type managed by this device
Definition: spa/include/spa/monitor/device.h:78
uint64_t change_mask
Definition: spa/include/spa/monitor/device.h:85
const char * factory_name
a factory name that implements the object
Definition: spa/include/spa/monitor/device.h:79
uint64_t flags
Definition: spa/include/spa/monitor/device.h:86
Definition: spa/include/spa/monitor/device.h:40
struct spa_interface iface
Definition: spa/include/spa/monitor/device.h:40
Definition: utils/dict.h:39
Definition: pod/event.h:28
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:331
Definition: hook.h:138
information about a parameter
Definition: param.h:50
Definition: pod/pod.h:43
Definition: spa/include/spa/monitor/device.h:96
uint32_t id
Definition: spa/include/spa/monitor/device.h:97
uint32_t index
Definition: spa/include/spa/monitor/device.h:98
uint32_t next
Definition: spa/include/spa/monitor/device.h:99
struct spa_pod * param
Definition: spa/include/spa/monitor/device.h:100
spa/utils/dict.h