summaryrefslogtreecommitdiffstats
path: root/audio/telephony.h
blob: 8334a3e107ae00dcc1eb61781d60b4ef8d5acaf5 (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
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
/*
 *
 *  BlueZ - Bluetooth protocol stack for Linux
 *
 *  Copyright (C) 2006-2007  Nokia Corporation
 *  Copyright (C) 2004-2008  Marcel Holtmann <marcel@holtmann.org>
 *
 *
 *  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 St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#include <stdint.h>
#include <errno.h>
#include <glib.h>

/* HFP feature bits */
#define AG_FEATURE_THREE_WAY_CALLING             0x0001
#define AG_FEATURE_EC_ANDOR_NR                   0x0002
#define AG_FEATURE_VOICE_RECOGNITION             0x0004
#define AG_FEATURE_INBAND_RINGTONE               0x0008
#define AG_FEATURE_ATTACH_NUMBER_TO_VOICETAG     0x0010
#define AG_FEATURE_REJECT_A_CALL                 0x0020
#define AG_FEATURE_ENHANCES_CALL_STATUS          0x0040
#define AG_FEATURE_ENHANCES_CALL_CONTROL         0x0080
#define AG_FEATURE_EXTENDED_ERROR_RESULT_CODES   0x0100

/* Indicator event values */
#define EV_SERVICE_NONE			0
#define EV_SERVICE_PRESENT		1

#define EV_CALL_INACTIVE		0
#define EV_CALL_ACTIVE			1

#define EV_CALLSETUP_INACTIVE		0
#define EV_CALLSETUP_INCOMING		1
#define EV_CALLSETUP_OUTGOING		2
#define EV_CALLSETUP_ALERTING		3

#define EV_CALLHELD_NONE		0
#define EV_CALLHELD_MULTIPLE		1
#define EV_CALLHELD_ON_HOLD		2

#define EV_ROAM_INACTIVE		0
#define EV_ROAM_ACTIVE			1

struct indicator {
	const char *desc;
	const char *range;
	int val;
};

int telephony_event_reporting_req(int ind);

int telephony_event_ind(int index);

int telephony_response_and_hold_req(int rh);

int telephony_response_and_hold_ind(int rh);

int telephony_last_dialed_number(void);

int telephony_terminate_call(void);

int telephony_answer_call(void);

int telephony_dial_number(const char *number);

int telephony_ready(uint32_t features, const struct indicator *indicators,
			int rh);

/* Helper function for quick indicator updates */
static inline int telephony_update_indicator(struct indicator *indicators,
						const char *desc,
						int new_val)
{
	int i;
	struct indicator *ind = NULL;

	for (i = 0; indicators[i].desc != NULL; i++) {
		if (g_str_equal(indicators[i].desc, desc)) {
			ind = &indicators[i];
			break;
		}
	}

	if (!ind)
		return -ENOENT;

	ind->val = new_val;

	return telephony_event_ind(i);
}

static inline int telephony_get_indicator(const struct indicator *indicators,
						const char *desc)
{
	int i;

	for (i = 0; indicators[i].desc != NULL; i++) {
		if (g_str_equal(indicators[i].desc, desc))
			return indicators[i].val;
	}

	return -ENOENT;
}

int telephony_init(void);
void telephony_exit(void);