Martijn Coenen | cbe590c | 2016-08-30 11:27:56 -0700 | [diff] [blame] | 1 | /* |
| 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 Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 17 | package android.hardware.nfc@1.0; |
| 18 | |
| 19 | import INfcClientCallback; |
| 20 | |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 21 | interface INfc { |
| 22 | /* |
| 23 | * 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 | * |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 30 | * If open() returns 0, the NCI stack will wait for a NfcEvent.OPEN_CPLT |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 31 | * before continuing. |
| 32 | * |
| 33 | * If open() returns any other value, the NCI stack will stop. |
| 34 | * |
| 35 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame^] | 36 | @entry |
| 37 | @callflow(next={"write", "coreInitialized", "prediscover", "powerCycle", "controlGranted"}) |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 38 | open(INfcClientCallback clientCallback) generates (int32_t retval); |
| 39 | |
| 40 | /* |
| 41 | * 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. |
| 45 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame^] | 46 | @callflow(next={"write", "prediscover", "coreInitialized", "close", "powerCycle", |
| 47 | "controlGranted"}) |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 48 | write(NfcData data) generates (int32_t retval); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 49 | |
| 50 | /* |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 51 | * coreInitialized() is called after the CORE_INIT_RSP is received from the NFCC. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 52 | * At this time, the HAL can do any chip-specific configuration. |
| 53 | * |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 54 | * If coreInitialized() returns 0, the NCI stack will wait for a NfcEvent.POST_INIT_CPLT |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 55 | * before continuing. |
| 56 | * |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 57 | * If coreInitialized() returns any other value, the NCI stack will continue |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 58 | * immediately. |
| 59 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame^] | 60 | @callflow(next={"write", "prediscover", "close"}) |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 61 | coreInitialized(NfcData data) generates (int32_t retval); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 62 | |
| 63 | /* |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 64 | * prediscover is called every time before starting RF discovery. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 65 | * It is a good place to do vendor-specific configuration that must be |
| 66 | * performed every time RF discovery is about to be started. |
| 67 | * |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 68 | * If prediscover() returns 0, the NCI stack will wait for a NfcEvent.PREDISCOVER_CPLT |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 69 | * before continuing. |
| 70 | * |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 71 | * If prediscover() returns any other value, the NCI stack will start |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 72 | * RF discovery immediately. |
| 73 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame^] | 74 | @callflow(next={"write", "close", "coreInitialized", "powerCycle", "controlGranted"}) |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 75 | prediscover() generates (int32_t retval); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * Close the NFC controller. Should free all resources. |
| 79 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame^] | 80 | @exit |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 81 | close() generates (int32_t retval); |
| 82 | |
| 83 | /* |
| 84 | * Grant HAL the exclusive control to send NCI commands. |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 85 | * Called in response to NfcEvent.REQUEST_CONTROL. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 86 | * Must only be called when there are no NCI commands pending. |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 87 | * NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 88 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame^] | 89 | @callflow(next={"write", "close", "prediscover", "coreInitialized", "powerCycle"}) |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 90 | controlGranted() generates (int32_t retval); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 91 | |
| 92 | /* |
| 93 | * Restart controller by power cyle; |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 94 | * NfcEvent.OPEN_CPLT will notify when operation is complete. |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 95 | */ |
Ruchi Kandoi | 846d9ab | 2016-10-31 16:11:13 -0700 | [diff] [blame^] | 96 | @callflow(next={"write", "coreInitialized", "prediscover", "controlGranted", "close"}) |
Steven Moreland | cffe8d5 | 2016-09-26 12:40:29 -0700 | [diff] [blame] | 97 | powerCycle() generates (int32_t retval); |
Andreas Huber | a483139 | 2016-07-29 15:05:03 -0700 | [diff] [blame] | 98 | }; |