diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-01-23 16:30:21 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-01-26 16:19:24 -0800 |
commit | 44ef6f0c4cbfdc16c1b88f2f16d4926dd8ba8fcb (patch) | |
tree | 087892e5e6baf8daf4f6dd2353e195b781a3af3d /android/hal-avrcp.c | |
parent | c466e79d6bb6cc6942baa564ffdb46ffd83da0ec (diff) | |
download | bluez-44ef6f0c4cbfdc16c1b88f2f16d4926dd8ba8fcb.tar.gz |
android: Add initial skeleton for AVRCP in the HAL
Diffstat (limited to 'android/hal-avrcp.c')
-rw-r--r-- | android/hal-avrcp.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/android/hal-avrcp.c b/android/hal-avrcp.c new file mode 100644 index 000000000..01d233b53 --- /dev/null +++ b/android/hal-avrcp.c @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2014 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include <stdbool.h> +#include <stddef.h> +#include <string.h> + +#include "hal-log.h" +#include "hal.h" +#include "hal-msg.h" +#include "hal-ipc.h" + +static const btrc_callbacks_t *cbs = NULL; + +static bool interface_ready(void) +{ + return cbs != NULL; +} + +static bt_status_t init(btrc_callbacks_t *callbacks) +{ + struct hal_cmd_register_module cmd; + int ret; + + DBG(""); + + if (interface_ready()) + return BT_STATUS_DONE; + + cbs = callbacks; + + cmd.service_id = HAL_SERVICE_ID_AVRCP; + + ret = hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_REGISTER_MODULE, + sizeof(cmd), &cmd, 0, NULL, NULL); + + if (ret != BT_STATUS_SUCCESS) { + cbs = NULL; + hal_ipc_unregister(HAL_SERVICE_ID_AVRCP); + } + + return ret; +} + +static void cleanup() +{ + struct hal_cmd_unregister_module cmd; + + DBG(""); + + if (!interface_ready()) + return; + + cbs = NULL; + + cmd.service_id = HAL_SERVICE_ID_AVRCP; + + hal_ipc_cmd(HAL_SERVICE_ID_CORE, HAL_OP_UNREGISTER_MODULE, + sizeof(cmd), &cmd, 0, NULL, NULL); + + hal_ipc_unregister(HAL_SERVICE_ID_AVRCP); +} + +static btrc_interface_t iface = { + .size = sizeof(iface), + .init = init, + .cleanup = cleanup +}; + +btrc_interface_t *bt_get_avrcp_interface() +{ + return &iface; +} |