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(
23 		struct cras_iodev *bt_iodev,
24 		enum cras_bt_device_profile profile);
25 
26 /* Appends a profile specific iodev to bt_iodev. */
27 int cras_bt_io_append(struct cras_iodev *bt_iodev,
28 		      struct cras_iodev *dev,
29 		      enum cras_bt_device_profile profile);
30 
31 /* Checks if the active node of bt_io matches a profile. */
32 int cras_bt_io_on_profile(struct cras_iodev *bt_iodev,
33 			  enum cras_bt_device_profile profile);
34 
35 /* Updates the buffer size to the profile specific iodev. */
36 int cras_bt_io_update_buffer_size(struct cras_iodev *bt_iodev);
37 
38 /* Dry-run the profile device removal from bt_iodev.
39  * Returns:
40  *    0 if the bt_iodev will be empty and should to be destroied
41  *    after the removal, othersie the value of the next preffered
42  *    profile to use.
43  */
44 unsigned int cras_bt_io_try_remove(struct cras_iodev *bt_iodev,
45 				   struct cras_iodev *dev);
46 
47 /* Removes a profile specific iodev from bt_iodev.
48  * Returns:
49  *    0 if dev is removed and bt_iodev successfully updated to
50  *    the new profile, otherwise return negative error code. */
51 int cras_bt_io_remove(struct cras_iodev *bt_iodev, struct cras_iodev *dev);
52 
53 #endif /* CRAS_BT_IODEV_H_ */
54