Improve the structure of NNAPI AIDL Memory am: dd53d04d8c
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1666281 Change-Id: Ibcf677a263deaee456d311f8656df442c2aafada
This commit is contained in:
commit
a0f169b2c4
9 changed files with 213 additions and 18 deletions
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.common;
|
||||||
|
@VintfStability
|
||||||
|
parcelable Ashmem {
|
||||||
|
ParcelFileDescriptor fd;
|
||||||
|
long size;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
|
// two cases:
|
||||||
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
|
//
|
||||||
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
|
// with the aidl_interface module type with versions property set. The module
|
||||||
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
// with such a backward incompatible change, it has a high risk of breaking
|
||||||
|
// later when a module using the interface is updated, e.g., Mainline modules.
|
||||||
|
|
||||||
|
package android.hardware.common;
|
||||||
|
@VintfStability
|
||||||
|
parcelable MappableFile {
|
||||||
|
long length;
|
||||||
|
int prot;
|
||||||
|
ParcelFileDescriptor fd;
|
||||||
|
long offset;
|
||||||
|
}
|
|
@ -1,14 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// This file is a snapshot of an AIDL interface (or parcelable). Do not try to
|
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
|
||||||
// edit this file. It looks like you are doing that because you have modified
|
// two cases:
|
||||||
// an AIDL interface in a backward-incompatible way, e.g., deleting a function
|
// 1). this is a frozen version file - do not edit this in any case.
|
||||||
// from an interface or a field from a parcelable and it broke the build. That
|
// 2). this is a 'current' file. If you make a backwards compatible change to
|
||||||
// breakage is intended.
|
// the interface (from the latest frozen version), the build system will
|
||||||
|
// prompt you to update this file with `m <name>-update-api`.
|
||||||
//
|
//
|
||||||
// You must not make a backward incompatible changes to the AIDL files built
|
// You must not make a backward incompatible change to any AIDL file built
|
||||||
// with the aidl_interface module type with versions property set. The module
|
// with the aidl_interface module type with versions property set. The module
|
||||||
// type is used to build AIDL files in a way that they can be used across
|
// type is used to build AIDL files in a way that they can be used across
|
||||||
// independently updatable components of the system. If a device is shipped
|
// independently updatable components of the system. If a device is shipped
|
||||||
|
|
34
common/aidl/android/hardware/common/Ashmem.aidl
Normal file
34
common/aidl/android/hardware/common/Ashmem.aidl
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.common;
|
||||||
|
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type that holds same memory as the "ashmem" hidl_memory type from HIDL.
|
||||||
|
*/
|
||||||
|
@VintfStability
|
||||||
|
parcelable Ashmem {
|
||||||
|
/**
|
||||||
|
* A handle to a memory region.
|
||||||
|
*/
|
||||||
|
ParcelFileDescriptor fd;
|
||||||
|
/**
|
||||||
|
* Size of the memory region in bytes.
|
||||||
|
*/
|
||||||
|
long size;
|
||||||
|
}
|
53
common/aidl/android/hardware/common/MappableFile.aidl
Normal file
53
common/aidl/android/hardware/common/MappableFile.aidl
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package android.hardware.common;
|
||||||
|
|
||||||
|
import android.os.ParcelFileDescriptor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A region of a file that can be mapped into memory.
|
||||||
|
*
|
||||||
|
* In Linux, MappableFile may be used with mmap as `MAP_SHARED`.
|
||||||
|
*
|
||||||
|
* MappableFile is compatible with ::android::base::MappedFile.
|
||||||
|
*/
|
||||||
|
@VintfStability
|
||||||
|
parcelable MappableFile {
|
||||||
|
/**
|
||||||
|
* Length of the mapping region in bytes.
|
||||||
|
*/
|
||||||
|
long length;
|
||||||
|
/**
|
||||||
|
* The desired memory protection for the mapping.
|
||||||
|
*
|
||||||
|
* In Linux, prot is either `PROT_NONE` (indicating that mapped pages may not be accessed) or
|
||||||
|
* the bitwise OR of one or more of the following flags:
|
||||||
|
* - `PROT_READ` (indicating that the mapped pages may be read)
|
||||||
|
* - `PROT_WRITE` (indicating that the mapped pages may be written)
|
||||||
|
*/
|
||||||
|
int prot;
|
||||||
|
/**
|
||||||
|
* A handle to a mappable file.
|
||||||
|
*/
|
||||||
|
ParcelFileDescriptor fd;
|
||||||
|
/**
|
||||||
|
* The offset in the file to the beginning of the mapping region in number of bytes.
|
||||||
|
*
|
||||||
|
* Note: Some mapping functions require that the offset is aligned to the page size.
|
||||||
|
*/
|
||||||
|
long offset;
|
||||||
|
}
|
|
@ -34,6 +34,7 @@ aidl_interface {
|
||||||
apex_available: [
|
apex_available: [
|
||||||
"//apex_available:platform",
|
"//apex_available:platform",
|
||||||
"com.android.media.swcodec",
|
"com.android.media.swcodec",
|
||||||
|
"com.android.neuralnetworks",
|
||||||
],
|
],
|
||||||
min_sdk_version: "29",
|
min_sdk_version: "29",
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,6 +16,7 @@ aidl_interface {
|
||||||
stability: "vintf",
|
stability: "vintf",
|
||||||
imports: [
|
imports: [
|
||||||
"android.hardware.common",
|
"android.hardware.common",
|
||||||
|
"android.hardware.graphics.common",
|
||||||
],
|
],
|
||||||
backend: {
|
backend: {
|
||||||
java: {
|
java: {
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
|
|
||||||
package android.hardware.neuralnetworks;
|
package android.hardware.neuralnetworks;
|
||||||
@VintfStability
|
@VintfStability
|
||||||
parcelable Memory {
|
union Memory {
|
||||||
android.hardware.common.NativeHandle handle;
|
android.hardware.common.Ashmem ashmem;
|
||||||
long size;
|
android.hardware.common.MappableFile mappableFile;
|
||||||
String name;
|
android.hardware.graphics.common.HardwareBuffer hardwareBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,16 +15,26 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package android.hardware.neuralnetworks;
|
package android.hardware.neuralnetworks;
|
||||||
import android.hardware.common.NativeHandle;
|
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.hardware.common.Ashmem;
|
||||||
|
import android.hardware.common.MappableFile;
|
||||||
|
import android.hardware.graphics.common.HardwareBuffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type that is used to pass pieces of shared memory between processes.
|
* The different types of memory that can be shared across processes.
|
||||||
* The type structure mimics hidl_memory type from HIDL.
|
|
||||||
*/
|
*/
|
||||||
@VintfStability
|
@VintfStability
|
||||||
parcelable Memory {
|
union Memory {
|
||||||
NativeHandle handle;
|
/**
|
||||||
long size;
|
* Ashmem hidl_memory type from HIDL.
|
||||||
String name;
|
*/
|
||||||
|
Ashmem ashmem;
|
||||||
|
/**
|
||||||
|
* File that can be mapped.
|
||||||
|
*/
|
||||||
|
MappableFile mappableFile;
|
||||||
|
/**
|
||||||
|
* AIDL representation of AHardwareBuffer.
|
||||||
|
*/
|
||||||
|
HardwareBuffer hardwareBuffer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue