Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * BlueZ - Bluetooth protocol stack for Linux |
| 4 | * |
| 5 | * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos. |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | * |
| 21 | */ |
| 22 | |
Johan Hedberg | b8779d2 | 2012-12-07 12:46:04 +0200 | [diff] [blame] | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include <config.h> |
| 25 | #endif |
| 26 | |
Johan Hedberg | 813b674 | 2012-09-03 14:11:36 +0300 | [diff] [blame] | 27 | #include <stdbool.h> |
| 28 | |
Marcel Holtmann | 318e32c | 2015-02-28 23:58:08 -0800 | [diff] [blame] | 29 | #include "lib/sdp.h" |
| 30 | #include "lib/sdp_lib.h" |
| 31 | #include "lib/uuid.h" |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 32 | |
Marcel Holtmann | 452eaaa | 2014-01-25 20:32:45 -0800 | [diff] [blame] | 33 | #include "btio/btio.h" |
Marcel Holtmann | 8c45ca3 | 2014-01-25 20:08:59 -0800 | [diff] [blame] | 34 | #include "src/adapter.h" |
| 35 | #include "src/device.h" |
| 36 | #include "src/profile.h" |
| 37 | #include "src/service.h" |
| 38 | #include "src/uuid-helper.h" |
| 39 | #include "src/log.h" |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 40 | |
| 41 | #include "hdp_types.h" |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 42 | #include "hdp_manager.h" |
| 43 | #include "hdp.h" |
| 44 | |
Johan Hedberg | a339670 | 2012-09-25 14:23:57 +0300 | [diff] [blame] | 45 | static int hdp_adapter_probe(struct btd_profile *p, |
| 46 | struct btd_adapter *adapter) |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 47 | { |
Andrzej Kaczmarek | e6de0fe | 2012-09-19 12:22:13 +0200 | [diff] [blame] | 48 | return hdp_adapter_register(adapter); |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 49 | } |
| 50 | |
Johan Hedberg | a339670 | 2012-09-25 14:23:57 +0300 | [diff] [blame] | 51 | static void hdp_adapter_remove(struct btd_profile *p, |
| 52 | struct btd_adapter *adapter) |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 53 | { |
| 54 | hdp_adapter_unregister(adapter); |
| 55 | } |
| 56 | |
Mikel Astiz | d6254b4 | 2013-04-26 08:17:15 +0200 | [diff] [blame] | 57 | static int hdp_driver_probe(struct btd_service *service) |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 58 | { |
Mikel Astiz | d6254b4 | 2013-04-26 08:17:15 +0200 | [diff] [blame] | 59 | struct btd_device *device = btd_service_get_device(service); |
| 60 | |
Andrzej Kaczmarek | e6de0fe | 2012-09-19 12:22:13 +0200 | [diff] [blame] | 61 | return hdp_device_register(device); |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 62 | } |
| 63 | |
Mikel Astiz | d6254b4 | 2013-04-26 08:17:15 +0200 | [diff] [blame] | 64 | static void hdp_driver_remove(struct btd_service *service) |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 65 | { |
Mikel Astiz | d6254b4 | 2013-04-26 08:17:15 +0200 | [diff] [blame] | 66 | struct btd_device *device = btd_service_get_device(service); |
| 67 | |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 68 | hdp_device_unregister(device); |
| 69 | } |
| 70 | |
Mikel Astiz | 48563e3 | 2013-03-01 14:59:12 +0100 | [diff] [blame] | 71 | static struct btd_profile hdp_source_profile = { |
| 72 | .name = "hdp-source", |
Mikel Astiz | 21723d6 | 2013-03-01 14:59:13 +0100 | [diff] [blame] | 73 | .remote_uuid = HDP_SOURCE_UUID, |
Johan Hedberg | 813b674 | 2012-09-03 14:11:36 +0300 | [diff] [blame] | 74 | |
| 75 | .device_probe = hdp_driver_probe, |
| 76 | .device_remove = hdp_driver_remove, |
| 77 | |
| 78 | .adapter_probe = hdp_adapter_probe, |
| 79 | .adapter_remove = hdp_adapter_remove, |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 80 | }; |
| 81 | |
Mikel Astiz | 48563e3 | 2013-03-01 14:59:12 +0100 | [diff] [blame] | 82 | static struct btd_profile hdp_sink_profile = { |
| 83 | .name = "hdp-sink", |
Mikel Astiz | 21723d6 | 2013-03-01 14:59:13 +0100 | [diff] [blame] | 84 | .remote_uuid = HDP_SINK_UUID, |
Mikel Astiz | 48563e3 | 2013-03-01 14:59:12 +0100 | [diff] [blame] | 85 | |
| 86 | .device_probe = hdp_driver_probe, |
| 87 | .device_remove = hdp_driver_remove, |
| 88 | }; |
| 89 | |
Andrzej Kaczmarek | e6de0fe | 2012-09-19 12:22:13 +0200 | [diff] [blame] | 90 | int hdp_manager_init(void) |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 91 | { |
Andrzej Kaczmarek | e6de0fe | 2012-09-19 12:22:13 +0200 | [diff] [blame] | 92 | if (hdp_manager_start() < 0) |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 93 | return -1; |
| 94 | |
Mikel Astiz | 48563e3 | 2013-03-01 14:59:12 +0100 | [diff] [blame] | 95 | btd_profile_register(&hdp_source_profile); |
| 96 | btd_profile_register(&hdp_sink_profile); |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | void hdp_manager_exit(void) |
| 102 | { |
Mikel Astiz | 48563e3 | 2013-03-01 14:59:12 +0100 | [diff] [blame] | 103 | btd_profile_unregister(&hdp_sink_profile); |
| 104 | btd_profile_unregister(&hdp_source_profile); |
Johan Hedberg | 813b674 | 2012-09-03 14:11:36 +0300 | [diff] [blame] | 105 | |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 106 | hdp_manager_stop(); |
Santiago Carot-Nemesio | 2792e63 | 2010-07-27 16:11:29 +0200 | [diff] [blame] | 107 | } |