hdp_manager.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
  7. *
  8. */
  9. #ifdef HAVE_CONFIG_H
  10. #include <config.h>
  11. #endif
  12. #include <stdbool.h>
  13. #include "lib/sdp.h"
  14. #include "lib/sdp_lib.h"
  15. #include "lib/uuid.h"
  16. #include "btio/btio.h"
  17. #include "src/adapter.h"
  18. #include "src/device.h"
  19. #include "src/profile.h"
  20. #include "src/service.h"
  21. #include "src/uuid-helper.h"
  22. #include "src/log.h"
  23. #include "hdp_types.h"
  24. #include "hdp_manager.h"
  25. #include "hdp.h"
  26. static int hdp_adapter_probe(struct btd_profile *p,
  27. struct btd_adapter *adapter)
  28. {
  29. return hdp_adapter_register(adapter);
  30. }
  31. static void hdp_adapter_remove(struct btd_profile *p,
  32. struct btd_adapter *adapter)
  33. {
  34. hdp_adapter_unregister(adapter);
  35. }
  36. static int hdp_driver_probe(struct btd_service *service)
  37. {
  38. struct btd_device *device = btd_service_get_device(service);
  39. return hdp_device_register(device);
  40. }
  41. static void hdp_driver_remove(struct btd_service *service)
  42. {
  43. struct btd_device *device = btd_service_get_device(service);
  44. hdp_device_unregister(device);
  45. }
  46. static struct btd_profile hdp_source_profile = {
  47. .name = "hdp-source",
  48. .remote_uuid = HDP_SOURCE_UUID,
  49. .device_probe = hdp_driver_probe,
  50. .device_remove = hdp_driver_remove,
  51. .adapter_probe = hdp_adapter_probe,
  52. .adapter_remove = hdp_adapter_remove,
  53. };
  54. static struct btd_profile hdp_sink_profile = {
  55. .name = "hdp-sink",
  56. .remote_uuid = HDP_SINK_UUID,
  57. .device_probe = hdp_driver_probe,
  58. .device_remove = hdp_driver_remove,
  59. };
  60. int hdp_manager_init(void)
  61. {
  62. if (hdp_manager_start() < 0)
  63. return -1;
  64. btd_profile_register(&hdp_source_profile);
  65. btd_profile_register(&hdp_sink_profile);
  66. return 0;
  67. }
  68. void hdp_manager_exit(void)
  69. {
  70. btd_profile_unregister(&hdp_sink_profile);
  71. btd_profile_unregister(&hdp_source_profile);
  72. hdp_manager_stop();
  73. }