1 /* Copyright (c) 2013 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_HFP_SLC_H_ 7 #define CRAS_HFP_SLC_H_ 8 9 struct hfp_slc_handle; 10 struct cras_bt_device; 11 12 /* 13 * Hands-free HFP and AG supported features bits definition. 14 * Per HFP 1.7.1 specification section 4.34.1, command 15 * AT+BRSF (Bluetooth Retrieve Supported Features) 16 */ 17 #define HF_EC_ANDOR_NR 0x0001 18 #define HF_THREE_WAY_CALLING 0x0002 19 #define HF_CLI_PRESENTATION_CAP 0x0004 20 #define HF_VOICE_RECOGNITION 0x0008 21 #define HF_REMOVE_VOLUME_CTONTROL 0x0010 22 #define HF_ENHANCED_CALL_STATUS 0x0020 23 #define HF_ENHANCED_CALL_CONTROL 0x0040 24 #define HF_CODEC_NEGOTIATION 0x0080 25 #define HF_HF_INDICATORS 0x0100 26 #define HF_ESCO_S4_T2_SETTINGS 0x0200 27 28 #define AG_THREE_WAY_CALLING 0x0001 29 #define AG_EC_ANDOR_NR 0x0002 30 #define AG_VOICE_RECOGNITION 0x0004 31 #define AG_INBAND_RINGTONE 0x0008 32 #define AG_ATTACH_NUMBER_TO_VOICETAG 0x0010 33 #define AG_REJECT_A_CALL 0x0020 34 #define AG_ENHANCED_CALL_STATUS 0x0040 35 #define AG_ENHANCED_CALL_CONTROL 0x0080 36 #define AG_EXTENDED_ERROR_RESULT_CODES 0x0100 37 #define AG_CODEC_NEGOTIATION 0x0200 38 #define AG_HF_INDICATORS 0x0400 39 #define AG_ESCO_S4_T2_SETTINGS 0x0800 40 41 /* Codec ids for codec negotiation, per HFP 1.7.1 spec appendix B. */ 42 #define HFP_CODEC_UNUSED 0 43 #define HFP_CODEC_ID_CVSD 1 44 #define HFP_CODEC_ID_MSBC 2 45 #define HFP_MAX_CODECS 3 46 47 /* Callback to call when service level connection initialized. */ 48 typedef int (*hfp_slc_init_cb)(struct hfp_slc_handle *handle); 49 50 /* Callback to call when service level connection disconnected. */ 51 typedef int (*hfp_slc_disconnect_cb)(struct hfp_slc_handle *handle); 52 53 /* Creates an hfp_slc_handle to poll the RFCOMM file descriptor 54 * to read and handle received AT commands. 55 * Args: 56 * fd - the rfcomm fd used to initialize service level connection 57 * is_hsp - if the slc handle is created for headset profile 58 * ag_supported_features - Supported AG features bitmap. 59 * device - The bt device associated with the created slc object 60 * init_cb - the callback function to be triggered when a service level 61 * connection is initialized. 62 * disconnect_cb - the callback function to be triggered when the service 63 * level connection is disconnected. 64 */ 65 struct hfp_slc_handle *hfp_slc_create(int fd, int is_hsp, 66 int ag_supported_features, 67 struct cras_bt_device *device, 68 hfp_slc_init_cb init_cb, 69 hfp_slc_disconnect_cb disconnect_cb); 70 71 /* Destroys an hfp_slc_handle. */ 72 void hfp_slc_destroy(struct hfp_slc_handle *handle); 73 74 /* Sets the call status to notify handsfree device. */ 75 int hfp_set_call_status(struct hfp_slc_handle *handle, int call); 76 77 /* Fakes the incoming call event for qualification test. */ 78 int hfp_event_incoming_call(struct hfp_slc_handle *handle, const char *number, 79 int type); 80 81 /* Handles the call status changed event. 82 * AG will send notification to HF accordingly. */ 83 int hfp_event_update_call(struct hfp_slc_handle *handle); 84 85 /* Handles the call setup status changed event. 86 * AG will send notification to HF accordingly. */ 87 int hfp_event_update_callsetup(struct hfp_slc_handle *handle); 88 89 /* Handles the call held status changed event. 90 * AG will send notification to HF accordingly. */ 91 int hfp_event_update_callheld(struct hfp_slc_handle *handle); 92 93 /* Sets battery level which is required for qualification test. */ 94 int hfp_event_set_battery(struct hfp_slc_handle *handle, int value); 95 96 /* Sets signal strength which is required for qualification test. */ 97 int hfp_event_set_signal(struct hfp_slc_handle *handle, int value); 98 99 /* Sets service availability which is required for qualification test. */ 100 int hfp_event_set_service(struct hfp_slc_handle *handle, int value); 101 102 /* Sets speaker gain value to headsfree device. */ 103 int hfp_event_speaker_gain(struct hfp_slc_handle *handle, int gain); 104 105 /* Gets the selected codec for HFP, mSBC or CVSD. */ 106 int hfp_slc_get_selected_codec(struct hfp_slc_handle *handle); 107 108 /* Gets if the remote HF supports codec negotiation. */ 109 int hfp_slc_get_hf_codec_negotiation_supported(struct hfp_slc_handle *handle); 110 111 #endif /* CRAS_HFP_SLC_H_ */ 112