blob: 01914f04fa43a40498ee73ff280a1d133cf43e98 [file] [log] [blame]
Martijn Coenen1c970f12012-09-12 17:59:39 -04001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <errno.h>
17#include <string.h>
18
19#include <cutils/log.h>
20#include <hardware/hardware.h>
21#include <hardware/nfc.h>
22
23
24/*
25 * NCI HAL method implementations. These must be overriden
26 */
27static int hal_open(const struct nfc_nci_device *dev,
28 nfc_stack_callback_t *p_cback) {
29 ALOGE("NFC-NCI HAL: %s", __FUNCTION__);
30 return 0;
31}
32
33static int hal_write(const struct nfc_nci_device *dev,
34 uint16_t data_len, const uint8_t *p_data) {
35 ALOGE("NFC-NCI HAL: %s", __FUNCTION__);
36 return 0;
37}
38
39static int hal_core_initialized(const struct nfc_nci_device *dev,
40 uint8_t* p_core_init_rsp_params) {
41 ALOGE("NFC-NCI HAL: %s", __FUNCTION__);
42 return 0;
43}
44
45static int hal_pre_discover(const struct nfc_nci_device *dev) {
46 ALOGE("NFC-NCI HAL: %s", __FUNCTION__);
47 return 0;
48}
49
50static int hal_close(const struct nfc_nci_device *dev) {
51 ALOGE("NFC-NCI HAL: %s", __FUNCTION__);
52 return 0;
53}
54
55static int hal_control_granted (const struct nfc_nci_device *p_dev)
56{
57 ALOGE("NFC-NCI HAL: %s", __FUNCTION__);
58 return 0;
59}
60
61
62static int hal_power_cycle (const struct nfc_nci_device *p_dev)
63{
64 ALOGE("NFC-NCI HAL: %s", __FUNCTION__);
65 return 0;
66}
67
68/*
69 * Generic device handling below - can generally be left unchanged.
70 */
71/* Close an opened nfc device instance */
72static int nfc_close(hw_device_t *dev) {
73 free(dev);
74 return 0;
75}
76
77static int nfc_open(const hw_module_t* module, const char* name,
78 hw_device_t** device) {
79 if (strcmp(name, NFC_NCI_CONTROLLER) == 0) {
80 nfc_nci_device_t *dev = calloc(1, sizeof(nfc_nci_device_t));
81
82 dev->common.tag = HARDWARE_DEVICE_TAG;
83 dev->common.version = 0x00010000; // [31:16] major, [15:0] minor
84 dev->common.module = (struct hw_module_t*) module;
85 dev->common.close = nfc_close;
86
87 // NCI HAL method pointers
88 dev->open = hal_open;
89 dev->write = hal_write;
90 dev->core_initialized = hal_core_initialized;
91 dev->pre_discover = hal_pre_discover;
92 dev->close = hal_close;
93 dev->control_granted = hal_control_granted;
94 dev->power_cycle = hal_power_cycle;
95
96 *device = (hw_device_t*) dev;
97
98 return 0;
99 } else {
100 return -EINVAL;
101 }
102}
103
104
105static struct hw_module_methods_t nfc_module_methods = {
106 .open = nfc_open,
107};
108
109struct nfc_nci_module_t HAL_MODULE_INFO_SYM = {
110 .common = {
111 .tag = HARDWARE_MODULE_TAG,
112 .module_api_version = 0x0100, // [15:8] major, [7:0] minor (1.0)
113 .hal_api_version = 0x00, // 0 is only valid value
114 .id = NFC_NCI_HARDWARE_MODULE_ID,
115 .name = "Default NFC NCI HW HAL",
116 .author = "The Android Open Source Project",
117 .methods = &nfc_module_methods,
118 },
119};