1 /* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2  * Use of this source code is governed by a BSD-style license that can be
3  * found in the LICENSE file.
4  */
5 
6 #ifndef CRAS_IODEV_INFO_H_
7 #define CRAS_IODEV_INFO_H_
8 
9 #include <stddef.h>
10 #include <stdint.h>
11 
12 #define CRAS_IODEV_NAME_BUFFER_SIZE 64
13 #define CRAS_NODE_TYPE_BUFFER_SIZE 32
14 #define CRAS_NODE_MIC_POS_BUFFER_SIZE 128
15 #define CRAS_NODE_NAME_BUFFER_SIZE 64
16 #define CRAS_NODE_HOTWORD_MODEL_BUFFER_SIZE 16
17 
18 /* Identifying information about an IO device.
19  *    idx - iodev index.
20  *    name - Name displayed to the user.
21  *    stable_id - ID that does not change due to device plug/unplug or reboot.
22  *    max_supported_channels - Max supported channel count of this device.
23  */
24 struct __attribute__((__packed__)) cras_iodev_info {
25 	uint32_t idx;
26 	char name[CRAS_IODEV_NAME_BUFFER_SIZE];
27 	uint32_t stable_id;
28 	uint32_t max_supported_channels;
29 };
30 
31 /* Identifying information about an ionode on an iodev.
32  *    iodev_idx - Index of the device this node belongs.
33  *    ionode_idx - Index of this node on the device.
34  *    plugged - Set true if this node is known to be plugged in.
35  *    plugged_time - If plugged is true, this is the time it was attached.
36  *    active - If this is the node currently being used.
37  *    volume - per-node volume (0-100)
38  *    capture_gain - per-node capture gain/attenuation (in 100*dBFS)
39  *    ui_gain_scaler - Adjustable gain scaler set by Chrome.
40  *    left_right_swapped - Set true if left and right channels are swapped.
41  *    stable_id - ID that does not change due to device plug/unplug or reboot.
42  *    type - Type displayed to the user.
43  *    name - Name displayed to the user.
44  *    active_hotword_model - name of the currently selected hotword model.
45  */
46 struct __attribute__((__packed__)) cras_ionode_info {
47 	uint32_t iodev_idx;
48 	uint32_t ionode_idx;
49 	int32_t plugged;
50 	int32_t active;
51 	struct {
52 		int64_t tv_sec;
53 		int64_t tv_usec;
54 	} plugged_time;
55 	uint32_t volume;
56 	int32_t capture_gain;
57 	float ui_gain_scaler;
58 	int32_t left_right_swapped;
59 	uint32_t type_enum;
60 	uint32_t stable_id;
61 	char type[CRAS_NODE_TYPE_BUFFER_SIZE];
62 	char name[CRAS_NODE_NAME_BUFFER_SIZE];
63 	char active_hotword_model[CRAS_NODE_HOTWORD_MODEL_BUFFER_SIZE];
64 };
65 
66 /* This is used in the cras_client_set_node_attr API.
67  *    IONODE_ATTR_PLUGGED - set the node as plugged/unplugged.
68  *    IONODE_ATTR_VOLUME - set the node's output volume.
69  *    IONODE_ATTR_CAPTURE_GAIN - set the node's capture gain.
70  *    IONODE_ATTR_SWAP_LEFT_RIGHT - Swap the node's left and right channel.
71  */
72 enum ionode_attr {
73 	IONODE_ATTR_PLUGGED,
74 	IONODE_ATTR_VOLUME,
75 	IONODE_ATTR_CAPTURE_GAIN,
76 	IONODE_ATTR_SWAP_LEFT_RIGHT
77 };
78 
79 #endif /* CRAS_IODEV_INFO_H_ */
80