blob: 74b69a048dfbf3b8c4717c5ec12bc5ff8b7a9369 [file] [log] [blame]
Martijn Coenencbe590c2016-08-30 11:27:56 -07001/*
2 * Copyright (C) 2016 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
Andreas Hubera4831392016-07-29 15:05:03 -070017package android.hardware.nfc@1.0;
18
19import INfcClientCallback;
20
Andreas Hubera4831392016-07-29 15:05:03 -070021interface INfc {
Andreas Huber675ae492017-03-28 14:40:58 -070022 /**
Andreas Hubera4831392016-07-29 15:05:03 -070023 * Opens the NFC controller device and performs initialization.
24 * This may include patch download and other vendor-specific initialization.
25 *
26 * If open completes successfully, the controller should be ready to perform
27 * NCI initialization - ie accept CORE_RESET and subsequent commands through
28 * the write() call.
29 *
Ruchi Kandoi51068e02016-11-18 14:11:33 -080030 * If open() returns NfcStatus::OK, the NCI stack will wait for a
31 * NfcEvent.OPEN_CPLT before continuing.
Andreas Hubera4831392016-07-29 15:05:03 -070032 *
Ruchi Kandoi51068e02016-11-18 14:11:33 -080033 * If open() returns NfcStatus::FAILED, the NCI stack will stop.
Andreas Hubera4831392016-07-29 15:05:03 -070034 *
35 */
Ruchi Kandoi846d9ab2016-10-31 16:11:13 -070036 @entry
37 @callflow(next={"write", "coreInitialized", "prediscover", "powerCycle", "controlGranted"})
Ruchi Kandoi51068e02016-11-18 14:11:33 -080038 open(INfcClientCallback clientCallback) generates (NfcStatus status);
Andreas Hubera4831392016-07-29 15:05:03 -070039
Andreas Huber675ae492017-03-28 14:40:58 -070040 /**
Andreas Hubera4831392016-07-29 15:05:03 -070041 * Performs an NCI write.
42 *
43 * This method may queue writes and return immediately. The only
44 * requirement is that the writes are executed in order.
Ruchi Kandoi51068e02016-11-18 14:11:33 -080045 *
46 * @return number of bytes written to the NFCC
Andreas Hubera4831392016-07-29 15:05:03 -070047 */
Ruchi Kandoi846d9ab2016-10-31 16:11:13 -070048 @callflow(next={"write", "prediscover", "coreInitialized", "close", "powerCycle",
49 "controlGranted"})
Ruchi Kandoi51068e02016-11-18 14:11:33 -080050 write(NfcData data) generates (uint32_t retval);
Andreas Hubera4831392016-07-29 15:05:03 -070051
Andreas Huber675ae492017-03-28 14:40:58 -070052 /**
Ruchi Kandoi51068e02016-11-18 14:11:33 -080053 * coreInitialized() is called after the CORE_INIT_RSP is received from the
54 * NFCC. At this time, the HAL can do any chip-specific configuration.
Andreas Hubera4831392016-07-29 15:05:03 -070055 *
Ruchi Kandoi51068e02016-11-18 14:11:33 -080056 * If coreInitialized() returns NfcStatus::OK, the NCI stack will wait for a
57 * NfcEvent.POST_INIT_CPLT before continuing.
Andreas Hubera4831392016-07-29 15:05:03 -070058 *
Ruchi Kandoi51068e02016-11-18 14:11:33 -080059 * If coreInitialized() returns NfcStatus::FAILED, the NCI stack will
60 * continue immediately.
Andreas Hubera4831392016-07-29 15:05:03 -070061 */
Ruchi Kandoi846d9ab2016-10-31 16:11:13 -070062 @callflow(next={"write", "prediscover", "close"})
Ruchi Kandoi51068e02016-11-18 14:11:33 -080063 coreInitialized(NfcData data) generates (NfcStatus status);
Andreas Hubera4831392016-07-29 15:05:03 -070064
Andreas Huber675ae492017-03-28 14:40:58 -070065 /**
Steven Morelandcffe8d52016-09-26 12:40:29 -070066 * prediscover is called every time before starting RF discovery.
Andreas Hubera4831392016-07-29 15:05:03 -070067 * It is a good place to do vendor-specific configuration that must be
68 * performed every time RF discovery is about to be started.
69 *
Ruchi Kandoi51068e02016-11-18 14:11:33 -080070 * If prediscover() returns NfcStatus::OK, the NCI stack will wait for a
71 * NfcEvent.PREDISCOVER_CPLT before continuing.
Andreas Hubera4831392016-07-29 15:05:03 -070072 *
Ruchi Kandoi51068e02016-11-18 14:11:33 -080073 * If prediscover() returns NfcStatus::FAILED, the NCI stack will start
Andreas Hubera4831392016-07-29 15:05:03 -070074 * RF discovery immediately.
75 */
Ruchi Kandoi846d9ab2016-10-31 16:11:13 -070076 @callflow(next={"write", "close", "coreInitialized", "powerCycle", "controlGranted"})
Ruchi Kandoi51068e02016-11-18 14:11:33 -080077 prediscover() generates (NfcStatus status);
Andreas Hubera4831392016-07-29 15:05:03 -070078
Andreas Huber675ae492017-03-28 14:40:58 -070079 /**
Andreas Hubera4831392016-07-29 15:05:03 -070080 * Close the NFC controller. Should free all resources.
Ruchi Kandoi51068e02016-11-18 14:11:33 -080081 *
82 * @return NfcStatus::OK on success and NfcStatus::FAILED on error.
Andreas Hubera4831392016-07-29 15:05:03 -070083 */
Ruchi Kandoi846d9ab2016-10-31 16:11:13 -070084 @exit
Ruchi Kandoi51068e02016-11-18 14:11:33 -080085 close() generates (NfcStatus status);
Andreas Hubera4831392016-07-29 15:05:03 -070086
Andreas Huber675ae492017-03-28 14:40:58 -070087 /**
Andreas Hubera4831392016-07-29 15:05:03 -070088 * Grant HAL the exclusive control to send NCI commands.
Steven Morelandcffe8d52016-09-26 12:40:29 -070089 * Called in response to NfcEvent.REQUEST_CONTROL.
Andreas Hubera4831392016-07-29 15:05:03 -070090 * Must only be called when there are no NCI commands pending.
Steven Morelandcffe8d52016-09-26 12:40:29 -070091 * NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control.
Ruchi Kandoi51068e02016-11-18 14:11:33 -080092 *
93 * @return NfcStatus::OK on success and NfcStatus::FAILED on error.
Andreas Hubera4831392016-07-29 15:05:03 -070094 */
Ruchi Kandoi846d9ab2016-10-31 16:11:13 -070095 @callflow(next={"write", "close", "prediscover", "coreInitialized", "powerCycle"})
Ruchi Kandoi51068e02016-11-18 14:11:33 -080096 controlGranted() generates (NfcStatus status);
Andreas Hubera4831392016-07-29 15:05:03 -070097
Andreas Huber675ae492017-03-28 14:40:58 -070098 /**
Andreas Hubera4831392016-07-29 15:05:03 -070099 * Restart controller by power cyle;
Steven Morelandcffe8d52016-09-26 12:40:29 -0700100 * NfcEvent.OPEN_CPLT will notify when operation is complete.
Ruchi Kandoi51068e02016-11-18 14:11:33 -0800101 *
102 * @return NfcStatus::OK on success and NfcStatus::FAILED on error.
Andreas Hubera4831392016-07-29 15:05:03 -0700103 */
Ruchi Kandoi846d9ab2016-10-31 16:11:13 -0700104 @callflow(next={"write", "coreInitialized", "prediscover", "controlGranted", "close"})
Ruchi Kandoi51068e02016-11-18 14:11:33 -0800105 powerCycle() generates (NfcStatus status);
Andreas Hubera4831392016-07-29 15:05:03 -0700106};