summaryrefslogtreecommitdiff
path: root/cras/src/common/cras_iodev_info.h
blob: 85d20f903388f6c22d59b53caeaaffe1cdd8d3e2 (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
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
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef CRAS_IODEV_INFO_H_
#define CRAS_IODEV_INFO_H_

#include <stddef.h>
#include <stdint.h>

#define CRAS_IODEV_NAME_BUFFER_SIZE 64
#define CRAS_NODE_TYPE_BUFFER_SIZE 32
#define CRAS_NODE_MIC_POS_BUFFER_SIZE 128
#define CRAS_NODE_NAME_BUFFER_SIZE 64
#define CRAS_NODE_HOTWORD_MODEL_BUFFER_SIZE 16

/* Identifying information about an IO device.
 *    idx - iodev index.
 *    name - Name displayed to the user.
 *    stable_id - ID that does not change due to device plug/unplug or reboot.
 *    max_supported_channels - Max supported channel count of this device.
 */
struct __attribute__((__packed__)) cras_iodev_info {
	uint32_t idx;
	char name[CRAS_IODEV_NAME_BUFFER_SIZE];
	uint32_t stable_id;
	uint32_t max_supported_channels;
};

/* Identifying information about an ionode on an iodev.
 *    iodev_idx - Index of the device this node belongs.
 *    ionode_idx - Index of this node on the device.
 *    plugged - Set true if this node is known to be plugged in.
 *    plugged_time - If plugged is true, this is the time it was attached.
 *    active - If this is the node currently being used.
 *    volume - per-node volume (0-100)
 *    capture_gain - per-node capture gain/attenuation (in 100*dBFS)
 *    ui_gain_scaler - Adjustable gain scaler set by Chrome.
 *    left_right_swapped - Set true if left and right channels are swapped.
 *    stable_id - ID that does not change due to device plug/unplug or reboot.
 *    type - Type displayed to the user.
 *    name - Name displayed to the user.
 *    active_hotword_model - name of the currently selected hotword model.
 */
struct __attribute__((__packed__)) cras_ionode_info {
	uint32_t iodev_idx;
	uint32_t ionode_idx;
	int32_t plugged;
	int32_t active;
	struct {
		int64_t tv_sec;
		int64_t tv_usec;
	} plugged_time;
	uint32_t volume;
	int32_t capture_gain;
	float ui_gain_scaler;
	int32_t left_right_swapped;
	uint32_t type_enum;
	uint32_t stable_id;
	char type[CRAS_NODE_TYPE_BUFFER_SIZE];
	char name[CRAS_NODE_NAME_BUFFER_SIZE];
	char active_hotword_model[CRAS_NODE_HOTWORD_MODEL_BUFFER_SIZE];
};

/* This is used in the cras_client_set_node_attr API.
 *    IONODE_ATTR_PLUGGED - set the node as plugged/unplugged.
 *    IONODE_ATTR_VOLUME - set the node's output volume.
 *    IONODE_ATTR_CAPTURE_GAIN - set the node's capture gain.
 *    IONODE_ATTR_SWAP_LEFT_RIGHT - Swap the node's left and right channel.
 */
enum ionode_attr {
	IONODE_ATTR_PLUGGED,
	IONODE_ATTR_VOLUME,
	IONODE_ATTR_CAPTURE_GAIN,
	IONODE_ATTR_SWAP_LEFT_RIGHT
};

#endif /* CRAS_IODEV_INFO_H_ */