• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2014 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_BT_IODEV_H_
7 #define CRAS_BT_IODEV_H_
8 
9 #include "cras_bt_device.h"
10 
11 struct cras_iodev;
12 
13 /* Creates a bluetooth iodev. */
14 struct cras_iodev *cras_bt_io_create(struct cras_bt_device *device,
15 				     struct cras_iodev *dev,
16 				     enum cras_bt_device_profile profile);
17 
18 /* Destroys a bluetooth iodev. */
19 void cras_bt_io_destroy(struct cras_iodev *bt_iodev);
20 
21 /* Looks up for the node of given profile, returns NULL if doesn't exist. */
22 struct cras_ionode *cras_bt_io_get_profile(struct cras_iodev *bt_iodev,
23 					   enum cras_bt_device_profile profile);
24 
25 /* Appends a profile specific iodev to bt_iodev. */
26 int cras_bt_io_append(struct cras_iodev *bt_iodev, struct cras_iodev *dev,
27 		      enum cras_bt_device_profile profile);
28 
29 /* Checks if the active node of bt_io matches a profile. */
30 int cras_bt_io_on_profile(struct cras_iodev *bt_iodev,
31 			  enum cras_bt_device_profile profile);
32 
33 /* Returns A2DP, HFP or HSP that this bt_iodev is running for.
34  * Do NOT use this function except for logging.
35  */
36 enum cras_bt_device_profile
37 cras_bt_io_profile_to_log(struct cras_iodev *bt_iodev);
38 
39 /* Dry-run the profile device removal from bt_iodev.
40  * Returns:
41  *    0 if the bt_iodev will be empty and should to be destroied
42  *    after the removal, othersie the value of the next preffered
43  *    profile to use.
44  */
45 unsigned int cras_bt_io_try_remove(struct cras_iodev *bt_iodev,
46 				   struct cras_iodev *dev);
47 
48 /* Removes a profile specific iodev from bt_iodev.
49  * Returns:
50  *    0 if dev is removed and bt_iodev successfully updated to
51  *    the new profile, otherwise return negative error code. */
52 int cras_bt_io_remove(struct cras_iodev *bt_iodev, struct cras_iodev *dev);
53 
54 #endif /* CRAS_BT_IODEV_H_ */
55