mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Nfc: Change return types for Nfc hal to specified type.
am: 51068e0bd3
Change-Id: I46ba181e80ee2c16cfda07da6e1b3975f1e09717
This commit is contained in:
@@ -27,72 +27,80 @@ interface INfc {
|
|||||||
* NCI initialization - ie accept CORE_RESET and subsequent commands through
|
* NCI initialization - ie accept CORE_RESET and subsequent commands through
|
||||||
* the write() call.
|
* the write() call.
|
||||||
*
|
*
|
||||||
* If open() returns 0, the NCI stack will wait for a NfcEvent.OPEN_CPLT
|
* If open() returns NfcStatus::OK, the NCI stack will wait for a
|
||||||
* before continuing.
|
* NfcEvent.OPEN_CPLT before continuing.
|
||||||
*
|
*
|
||||||
* If open() returns any other value, the NCI stack will stop.
|
* If open() returns NfcStatus::FAILED, the NCI stack will stop.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@entry
|
@entry
|
||||||
@callflow(next={"write", "coreInitialized", "prediscover", "powerCycle", "controlGranted"})
|
@callflow(next={"write", "coreInitialized", "prediscover", "powerCycle", "controlGranted"})
|
||||||
open(INfcClientCallback clientCallback) generates (int32_t retval);
|
open(INfcClientCallback clientCallback) generates (NfcStatus status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Performs an NCI write.
|
* Performs an NCI write.
|
||||||
*
|
*
|
||||||
* This method may queue writes and return immediately. The only
|
* This method may queue writes and return immediately. The only
|
||||||
* requirement is that the writes are executed in order.
|
* requirement is that the writes are executed in order.
|
||||||
|
*
|
||||||
|
* @return number of bytes written to the NFCC
|
||||||
*/
|
*/
|
||||||
@callflow(next={"write", "prediscover", "coreInitialized", "close", "powerCycle",
|
@callflow(next={"write", "prediscover", "coreInitialized", "close", "powerCycle",
|
||||||
"controlGranted"})
|
"controlGranted"})
|
||||||
write(NfcData data) generates (int32_t retval);
|
write(NfcData data) generates (uint32_t retval);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* coreInitialized() is called after the CORE_INIT_RSP is received from the NFCC.
|
* coreInitialized() is called after the CORE_INIT_RSP is received from the
|
||||||
* At this time, the HAL can do any chip-specific configuration.
|
* NFCC. At this time, the HAL can do any chip-specific configuration.
|
||||||
*
|
*
|
||||||
* If coreInitialized() returns 0, the NCI stack will wait for a NfcEvent.POST_INIT_CPLT
|
* If coreInitialized() returns NfcStatus::OK, the NCI stack will wait for a
|
||||||
* before continuing.
|
* NfcEvent.POST_INIT_CPLT before continuing.
|
||||||
*
|
*
|
||||||
* If coreInitialized() returns any other value, the NCI stack will continue
|
* If coreInitialized() returns NfcStatus::FAILED, the NCI stack will
|
||||||
* immediately.
|
* continue immediately.
|
||||||
*/
|
*/
|
||||||
@callflow(next={"write", "prediscover", "close"})
|
@callflow(next={"write", "prediscover", "close"})
|
||||||
coreInitialized(NfcData data) generates (int32_t retval);
|
coreInitialized(NfcData data) generates (NfcStatus status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* prediscover is called every time before starting RF discovery.
|
* prediscover is called every time before starting RF discovery.
|
||||||
* It is a good place to do vendor-specific configuration that must be
|
* It is a good place to do vendor-specific configuration that must be
|
||||||
* performed every time RF discovery is about to be started.
|
* performed every time RF discovery is about to be started.
|
||||||
*
|
*
|
||||||
* If prediscover() returns 0, the NCI stack will wait for a NfcEvent.PREDISCOVER_CPLT
|
* If prediscover() returns NfcStatus::OK, the NCI stack will wait for a
|
||||||
* before continuing.
|
* NfcEvent.PREDISCOVER_CPLT before continuing.
|
||||||
*
|
*
|
||||||
* If prediscover() returns any other value, the NCI stack will start
|
* If prediscover() returns NfcStatus::FAILED, the NCI stack will start
|
||||||
* RF discovery immediately.
|
* RF discovery immediately.
|
||||||
*/
|
*/
|
||||||
@callflow(next={"write", "close", "coreInitialized", "powerCycle", "controlGranted"})
|
@callflow(next={"write", "close", "coreInitialized", "powerCycle", "controlGranted"})
|
||||||
prediscover() generates (int32_t retval);
|
prediscover() generates (NfcStatus status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close the NFC controller. Should free all resources.
|
* Close the NFC controller. Should free all resources.
|
||||||
|
*
|
||||||
|
* @return NfcStatus::OK on success and NfcStatus::FAILED on error.
|
||||||
*/
|
*/
|
||||||
@exit
|
@exit
|
||||||
close() generates (int32_t retval);
|
close() generates (NfcStatus status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grant HAL the exclusive control to send NCI commands.
|
* Grant HAL the exclusive control to send NCI commands.
|
||||||
* Called in response to NfcEvent.REQUEST_CONTROL.
|
* Called in response to NfcEvent.REQUEST_CONTROL.
|
||||||
* Must only be called when there are no NCI commands pending.
|
* Must only be called when there are no NCI commands pending.
|
||||||
* NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control.
|
* NfcEvent.RELEASE_CONTROL will notify when HAL no longer needs exclusive control.
|
||||||
|
*
|
||||||
|
* @return NfcStatus::OK on success and NfcStatus::FAILED on error.
|
||||||
*/
|
*/
|
||||||
@callflow(next={"write", "close", "prediscover", "coreInitialized", "powerCycle"})
|
@callflow(next={"write", "close", "prediscover", "coreInitialized", "powerCycle"})
|
||||||
controlGranted() generates (int32_t retval);
|
controlGranted() generates (NfcStatus status);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Restart controller by power cyle;
|
* Restart controller by power cyle;
|
||||||
* NfcEvent.OPEN_CPLT will notify when operation is complete.
|
* NfcEvent.OPEN_CPLT will notify when operation is complete.
|
||||||
|
*
|
||||||
|
* @return NfcStatus::OK on success and NfcStatus::FAILED on error.
|
||||||
*/
|
*/
|
||||||
@callflow(next={"write", "coreInitialized", "prediscover", "controlGranted", "close"})
|
@callflow(next={"write", "coreInitialized", "prediscover", "controlGranted", "close"})
|
||||||
powerCycle() generates (int32_t retval);
|
powerCycle() generates (NfcStatus status);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,34 +17,36 @@ Nfc::Nfc(nfc_nci_device_t* device) : mDevice(device) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Methods from ::android::hardware::nfc::V1_0::INfc follow.
|
// Methods from ::android::hardware::nfc::V1_0::INfc follow.
|
||||||
::android::hardware::Return<int32_t> Nfc::open(const sp<INfcClientCallback>& clientCallback) {
|
::android::hardware::Return<NfcStatus> Nfc::open(const sp<INfcClientCallback>& clientCallback) {
|
||||||
mCallback = clientCallback;
|
mCallback = clientCallback;
|
||||||
return mDevice->open(mDevice, eventCallback, dataCallback);
|
int ret = mDevice->open(mDevice, eventCallback, dataCallback);
|
||||||
|
return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
::android::hardware::Return<int32_t> Nfc::write(const hidl_vec<uint8_t>& data) {
|
::android::hardware::Return<uint32_t> Nfc::write(const hidl_vec<uint8_t>& data) {
|
||||||
return mDevice->write(mDevice, data.size(), &data[0]);
|
return mDevice->write(mDevice, data.size(), &data[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
::android::hardware::Return<int32_t> Nfc::coreInitialized(const hidl_vec<uint8_t>& data) {
|
::android::hardware::Return<NfcStatus> Nfc::coreInitialized(const hidl_vec<uint8_t>& data) {
|
||||||
hidl_vec<uint8_t> copy = data;
|
hidl_vec<uint8_t> copy = data;
|
||||||
return mDevice->core_initialized(mDevice, ©[0]);
|
int ret = mDevice->core_initialized(mDevice, ©[0]);
|
||||||
|
return ret == 0 ? NfcStatus::OK : NfcStatus::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
::android::hardware::Return<int32_t> Nfc::prediscover() {
|
::android::hardware::Return<NfcStatus> Nfc::prediscover() {
|
||||||
return mDevice->pre_discover(mDevice);
|
return mDevice->pre_discover(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
::android::hardware::Return<int32_t> Nfc::close() {
|
::android::hardware::Return<NfcStatus> Nfc::close() {
|
||||||
return mDevice->close(mDevice);
|
return mDevice->close(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
::android::hardware::Return<int32_t> Nfc::controlGranted() {
|
::android::hardware::Return<NfcStatus> Nfc::controlGranted() {
|
||||||
return mDevice->control_granted(mDevice);
|
return mDevice->control_granted(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
::android::hardware::Return<int32_t> Nfc::powerCycle() {
|
::android::hardware::Return<NfcStatus> Nfc::powerCycle() {
|
||||||
return mDevice->power_cycle(mDevice);
|
return mDevice->power_cycle(mDevice) ? NfcStatus::FAILED : NfcStatus::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,13 +21,13 @@ using ::android::sp;
|
|||||||
|
|
||||||
struct Nfc : public INfc {
|
struct Nfc : public INfc {
|
||||||
Nfc(nfc_nci_device_t* device);
|
Nfc(nfc_nci_device_t* device);
|
||||||
::android::hardware::Return<int32_t> open(const sp<INfcClientCallback>& clientCallback) override;
|
::android::hardware::Return<NfcStatus> open(const sp<INfcClientCallback>& clientCallback) override;
|
||||||
::android::hardware::Return<int32_t> write(const hidl_vec<uint8_t>& data) override;
|
::android::hardware::Return<uint32_t> write(const hidl_vec<uint8_t>& data) override;
|
||||||
::android::hardware::Return<int32_t> coreInitialized(const hidl_vec<uint8_t>& data) override;
|
::android::hardware::Return<NfcStatus> coreInitialized(const hidl_vec<uint8_t>& data) override;
|
||||||
::android::hardware::Return<int32_t> prediscover() override;
|
::android::hardware::Return<NfcStatus> prediscover() override;
|
||||||
::android::hardware::Return<int32_t> close() override;
|
::android::hardware::Return<NfcStatus> close() override;
|
||||||
::android::hardware::Return<int32_t> controlGranted() override;
|
::android::hardware::Return<NfcStatus> controlGranted() override;
|
||||||
::android::hardware::Return<int32_t> powerCycle() override;
|
::android::hardware::Return<NfcStatus> powerCycle() override;
|
||||||
|
|
||||||
static void eventCallback(uint8_t event, uint8_t status) {
|
static void eventCallback(uint8_t event, uint8_t status) {
|
||||||
if (mCallback != nullptr) {
|
if (mCallback != nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user