1 /** @file
2  *  @brief Internal APIs for Bluetooth Handsfree profile handling.
3  */
4 
5 /*
6  * Copyright (c) 2015-2016 Intel Corporation
7  *
8  * SPDX-License-Identifier: Apache-2.0
9  */
10 
11 #define BT_HFP_MAX_MTU       140
12 #define BT_HF_CLIENT_MAX_PDU BT_HFP_MAX_MTU
13 
14 /* HFP AG Features */
15 #define BT_HFP_AG_FEATURE_3WAY_CALL       0x00000001 /* Three-way calling */
16 #define BT_HFP_AG_FEATURE_ECNR            0x00000002 /* EC and/or NR function */
17 #define BT_HFP_AG_FEATURE_VOICE_RECG      0x00000004 /* Voice recognition */
18 #define BT_HFP_AG_FEATURE_INBAND_RINGTONE 0x00000008 /* In-band ring capability */
19 #define BT_HFP_AG_FEATURE_VOICE_TAG       0x00000010 /* Attach no. to voice tag */
20 #define BT_HFP_AG_FEATURE_REJECT_CALL     0x00000020 /* Ability to reject call */
21 #define BT_HFP_AG_FEATURE_ECS             0x00000040 /* Enhanced call status */
22 #define BT_HFP_AG_FEATURE_ECC             0x00000080 /* Enhanced call control */
23 #define BT_HFP_AG_FEATURE_EXT_ERR         0x00000100 /* Extended error codes */
24 #define BT_HFP_AG_FEATURE_CODEC_NEG       0x00000200 /* Codec negotiation */
25 #define BT_HFP_AG_FEATURE_HF_IND          0x00000400 /* HF Indicators */
26 #define BT_HFP_AG_FEATURE_ESCO_S4         0x00000800 /* eSCO S4 Settings */
27 #define BT_HFP_AG_FEATURE_ENH_VOICE_RECG  0x00001000 /* Enhanced Voice Recognition Status */
28 #define BT_HFP_AG_FEATURE_VOICE_RECG_TEXT 0x00002000 /* Voice Recognition Text */
29 
30 /* HFP HF Features */
31 #define BT_HFP_HF_FEATURE_ECNR            0x00000001 /* EC and/or NR function */
32 #define BT_HFP_HF_FEATURE_3WAY_CALL       0x00000002 /* Three-way calling */
33 #define BT_HFP_HF_FEATURE_CLI             0x00000004 /* CLI presentation */
34 #define BT_HFP_HF_FEATURE_VOICE_RECG      0x00000008 /* Voice recognition */
35 #define BT_HFP_HF_FEATURE_VOLUME          0x00000010 /* Remote volume control */
36 #define BT_HFP_HF_FEATURE_ECS             0x00000020 /* Enhanced call status */
37 #define BT_HFP_HF_FEATURE_ECC             0x00000040 /* Enhanced call control */
38 #define BT_HFP_HF_FEATURE_CODEC_NEG       0x00000080 /* CODEC Negotiation */
39 #define BT_HFP_HF_FEATURE_HF_IND          0x00000100 /* HF Indicators */
40 #define BT_HFP_HF_FEATURE_ESCO_S4         0x00000200 /* eSCO S4 Settings */
41 #define BT_HFP_HF_FEATURE_ENH_VOICE_RECG  0x00000400 /* Enhanced Voice Recognition Status */
42 #define BT_HFP_HF_FEATURE_VOICE_RECG_TEXT 0x00000800 /* Voice Recognition Text */
43 
44 /* HFP HF Supported features */
45 #define BT_HFP_HF_SUPPORTED_FEATURES (BT_HFP_HF_FEATURE_CLI | BT_HFP_HF_FEATURE_VOLUME)
46 
47 #define HF_MAX_BUF_LEN       BT_HF_CLIENT_MAX_PDU
48 #define HF_MAX_AG_INDICATORS 20
49 
50 struct bt_hfp_hf {
51 	struct bt_rfcomm_dlc rfcomm_dlc;
52 	/* ACL connection handle */
53 	struct bt_conn *acl;
54 	/* SCO Channel */
55 	struct bt_sco_chan chan;
56 	char hf_buffer[HF_MAX_BUF_LEN];
57 	struct at_client at;
58 	uint32_t hf_features;
59 	uint32_t ag_features;
60 	int8_t ind_table[HF_MAX_AG_INDICATORS];
61 };
62 
63 enum hfp_hf_ag_indicators {
64 	HF_SERVICE_IND,
65 	HF_CALL_IND,
66 	HF_CALL_SETUP_IND,
67 	HF_CALL_HELD_IND,
68 	HF_SINGNAL_IND,
69 	HF_ROAM_IND,
70 	HF_BATTERY_IND
71 };
72 
73 /* HFP call setup status */
74 #define BT_HFP_CALL_SETUP_NONE            0
75 #define BT_HFP_CALL_SETUP_INCOMING        1
76 #define BT_HFP_CALL_SETUP_OUTGOING        2
77 #define BT_HFP_CALL_SETUP_REMOTE_ALERTING 3
78