blob: 401adf6e9707034649f10e471a7c711cfadfdcdc [file] [log] [blame]
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +02001/*
2 *
3 * BlueZ - Bluetooth protocol stack for Linux
4 *
5 * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +02006 *
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 Hedbergb8779d22012-12-07 12:46:04 +020023#ifdef HAVE_CONFIG_H
24#include <config.h>
25#endif
26
Johan Hedberg813b6742012-09-03 14:11:36 +030027#include <stdbool.h>
28
Marcel Holtmann318e32c2015-02-28 23:58:08 -080029#include "lib/sdp.h"
30#include "lib/sdp_lib.h"
31#include "lib/uuid.h"
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020032
Marcel Holtmann452eaaa2014-01-25 20:32:45 -080033#include "btio/btio.h"
Marcel Holtmann8c45ca32014-01-25 20:08:59 -080034#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-Nemesio2792e632010-07-27 16:11:29 +020040
41#include "hdp_types.h"
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020042#include "hdp_manager.h"
43#include "hdp.h"
44
Johan Hedberga3396702012-09-25 14:23:57 +030045static int hdp_adapter_probe(struct btd_profile *p,
46 struct btd_adapter *adapter)
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020047{
Andrzej Kaczmareke6de0fe2012-09-19 12:22:13 +020048 return hdp_adapter_register(adapter);
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020049}
50
Johan Hedberga3396702012-09-25 14:23:57 +030051static void hdp_adapter_remove(struct btd_profile *p,
52 struct btd_adapter *adapter)
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020053{
54 hdp_adapter_unregister(adapter);
55}
56
Mikel Astizd6254b42013-04-26 08:17:15 +020057static int hdp_driver_probe(struct btd_service *service)
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020058{
Mikel Astizd6254b42013-04-26 08:17:15 +020059 struct btd_device *device = btd_service_get_device(service);
60
Andrzej Kaczmareke6de0fe2012-09-19 12:22:13 +020061 return hdp_device_register(device);
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020062}
63
Mikel Astizd6254b42013-04-26 08:17:15 +020064static void hdp_driver_remove(struct btd_service *service)
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020065{
Mikel Astizd6254b42013-04-26 08:17:15 +020066 struct btd_device *device = btd_service_get_device(service);
67
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020068 hdp_device_unregister(device);
69}
70
Mikel Astiz48563e32013-03-01 14:59:12 +010071static struct btd_profile hdp_source_profile = {
72 .name = "hdp-source",
Mikel Astiz21723d62013-03-01 14:59:13 +010073 .remote_uuid = HDP_SOURCE_UUID,
Johan Hedberg813b6742012-09-03 14:11:36 +030074
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-Nemesio2792e632010-07-27 16:11:29 +020080};
81
Mikel Astiz48563e32013-03-01 14:59:12 +010082static struct btd_profile hdp_sink_profile = {
83 .name = "hdp-sink",
Mikel Astiz21723d62013-03-01 14:59:13 +010084 .remote_uuid = HDP_SINK_UUID,
Mikel Astiz48563e32013-03-01 14:59:12 +010085
86 .device_probe = hdp_driver_probe,
87 .device_remove = hdp_driver_remove,
88};
89
Andrzej Kaczmareke6de0fe2012-09-19 12:22:13 +020090int hdp_manager_init(void)
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020091{
Andrzej Kaczmareke6de0fe2012-09-19 12:22:13 +020092 if (hdp_manager_start() < 0)
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020093 return -1;
94
Mikel Astiz48563e32013-03-01 14:59:12 +010095 btd_profile_register(&hdp_source_profile);
96 btd_profile_register(&hdp_sink_profile);
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +020097
98 return 0;
99}
100
101void hdp_manager_exit(void)
102{
Mikel Astiz48563e32013-03-01 14:59:12 +0100103 btd_profile_unregister(&hdp_sink_profile);
104 btd_profile_unregister(&hdp_source_profile);
Johan Hedberg813b6742012-09-03 14:11:36 +0300105
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +0200106 hdp_manager_stop();
Santiago Carot-Nemesio2792e632010-07-27 16:11:29 +0200107}