diff --git a/.github/PULL_REQUEST_TEMPLATE/car_port.md b/.github/PULL_REQUEST_TEMPLATE/car_port.md index d27546839..4264363ba 100644 --- a/.github/PULL_REQUEST_TEMPLATE/car_port.md +++ b/.github/PULL_REQUEST_TEMPLATE/car_port.md @@ -9,7 +9,7 @@ assignees: '' **Checklist** - [ ] added to README -- [ ] test route added to [test_routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/test/test_models.py) +- [ ] test route added to [routes.py](https://github.com/commaai/openpilot/blob/master/selfdrive/car/tests/routes.py) - [ ] route with openpilot: - [ ] route with stock system: - [ ] car harness used (if comma doesn't sell it, put N/A): diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 38a6c7864..efa947a91 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -22,8 +22,8 @@ Route: [a route with the bug fix] - * - * a00 a10 a20 ... aN0 ^ - * a01 a11 a21 ... aN1 | - * a02 a12 a22 ... aN2 M rows - * ... | - * a0M a1M a2M ... aNM v - * - * COL_SIZE = M - * ROW_SIZE = N - * m[0] = [a00 a01 a02 ... a01M] - */ - - col_type mValue[ROW_SIZE]; - -public: - // array access - inline col_type const& operator [] (size_t i) const { return mValue[i]; } - inline col_type& operator [] (size_t i) { return mValue[i]; } - - T const* asArray() const { return &mValue[0][0]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - /* - * constructors - */ - - // leaves object uninitialized. use with caution. - explicit tmat44(no_init) { } - - // initialize to identity - tmat44(); - - // initialize to Identity*scalar. - template - explicit tmat44(U v); - - // sets the diagonal to the passed vector - template - explicit tmat44(const tvec4& rhs); - - // construct from another matrix of the same size - template - explicit tmat44(const tmat44& rhs); - - // construct from 4 column vectors - template - tmat44(const tvec4& v0, const tvec4& v1, const tvec4& v2, const tvec4& v3); - - // construct from 16 scalars - template < - typename A, typename B, typename C, typename D, - typename E, typename F, typename G, typename H, - typename I, typename J, typename K, typename L, - typename M, typename N, typename O, typename P> - tmat44( A m00, B m01, C m02, D m03, - E m10, F m11, G m12, H m13, - I m20, J m21, K m22, L m23, - M m30, N m31, O m32, P m33); - - // construct from a C array - template - explicit tmat44(U const* rawArray); - - /* - * helpers - */ - - static tmat44 ortho(T left, T right, T bottom, T top, T near, T far); - - static tmat44 frustum(T left, T right, T bottom, T top, T near, T far); - - template - static tmat44 lookAt(const tvec3& eye, const tvec3& center, const tvec3& up); - - template - static tmat44 translate(const tvec4& t); - - template - static tmat44 scale(const tvec4& s); - - template - static tmat44 rotate(A radian, const tvec3& about); -}; - -// ---------------------------------------------------------------------------------------- -// Constructors -// ---------------------------------------------------------------------------------------- - -/* - * Since the matrix code could become pretty big quickly, we don't inline most - * operations. - */ - -template -tmat44::tmat44() { - mValue[0] = col_type(1,0,0,0); - mValue[1] = col_type(0,1,0,0); - mValue[2] = col_type(0,0,1,0); - mValue[3] = col_type(0,0,0,1); -} - -template -template -tmat44::tmat44(U v) { - mValue[0] = col_type(v,0,0,0); - mValue[1] = col_type(0,v,0,0); - mValue[2] = col_type(0,0,v,0); - mValue[3] = col_type(0,0,0,v); -} - -template -template -tmat44::tmat44(const tvec4& v) { - mValue[0] = col_type(v.x,0,0,0); - mValue[1] = col_type(0,v.y,0,0); - mValue[2] = col_type(0,0,v.z,0); - mValue[3] = col_type(0,0,0,v.w); -} - -// construct from 16 scalars -template -template < - typename A, typename B, typename C, typename D, - typename E, typename F, typename G, typename H, - typename I, typename J, typename K, typename L, - typename M, typename N, typename O, typename P> -tmat44::tmat44( A m00, B m01, C m02, D m03, - E m10, F m11, G m12, H m13, - I m20, J m21, K m22, L m23, - M m30, N m31, O m32, P m33) { - mValue[0] = col_type(m00, m01, m02, m03); - mValue[1] = col_type(m10, m11, m12, m13); - mValue[2] = col_type(m20, m21, m22, m23); - mValue[3] = col_type(m30, m31, m32, m33); -} - -template -template -tmat44::tmat44(const tmat44& rhs) { - for (size_t r=0 ; r -template -tmat44::tmat44(const tvec4& v0, const tvec4& v1, const tvec4& v2, const tvec4& v3) { - mValue[0] = v0; - mValue[1] = v1; - mValue[2] = v2; - mValue[3] = v3; -} - -template -template -tmat44::tmat44(U const* rawArray) { - for (size_t r=0 ; r -tmat44 tmat44::ortho(T left, T right, T bottom, T top, T near, T far) { - tmat44 m; - m[0][0] = 2 / (right - left); - m[1][1] = 2 / (top - bottom); - m[2][2] = -2 / (far - near); - m[3][0] = -(right + left) / (right - left); - m[3][1] = -(top + bottom) / (top - bottom); - m[3][2] = -(far + near) / (far - near); - return m; -} - -template -tmat44 tmat44::frustum(T left, T right, T bottom, T top, T near, T far) { - tmat44 m; - T A = (right + left) / (right - left); - T B = (top + bottom) / (top - bottom); - T C = (far + near) / (far - near); - T D = (2 * far * near) / (far - near); - m[0][0] = (2 * near) / (right - left); - m[1][1] = (2 * near) / (top - bottom); - m[2][0] = A; - m[2][1] = B; - m[2][2] = C; - m[2][3] =-1; - m[3][2] = D; - m[3][3] = 0; - return m; -} - -template -template -tmat44 tmat44::lookAt(const tvec3& eye, const tvec3& center, const tvec3& up) { - tvec3 L(normalize(center - eye)); - tvec3 S(normalize( cross(L, up) )); - tvec3 U(cross(S, L)); - return tmat44( - tvec4( S, 0), - tvec4( U, 0), - tvec4(-L, 0), - tvec4(-eye, 1)); -} - -template -template -tmat44 tmat44::translate(const tvec4& t) { - tmat44 r; - r[3] = t; - return r; -} - -template -template -tmat44 tmat44::scale(const tvec4& s) { - tmat44 r; - r[0][0] = s[0]; - r[1][1] = s[1]; - r[2][2] = s[2]; - r[3][3] = s[3]; - return r; -} - -template -template -tmat44 tmat44::rotate(A radian, const tvec3& about) { - tmat44 rotation; - T* r = const_cast(rotation.asArray()); - T c = cos(radian); - T s = sin(radian); - if (about.x==1 && about.y==0 && about.z==0) { - r[5] = c; r[10]= c; - r[6] = s; r[9] = -s; - } else if (about.x==0 && about.y==1 && about.z==0) { - r[0] = c; r[10]= c; - r[8] = s; r[2] = -s; - } else if (about.x==0 && about.y==0 && about.z==1) { - r[0] = c; r[5] = c; - r[1] = s; r[4] = -s; - } else { - tvec3 nabout = normalize(about); - B x = nabout.x; - B y = nabout.y; - B z = nabout.z; - T nc = 1 - c; - T xy = x * y; - T yz = y * z; - T zx = z * x; - T xs = x * s; - T ys = y * s; - T zs = z * s; - r[ 0] = x*x*nc + c; r[ 4] = xy*nc - zs; r[ 8] = zx*nc + ys; - r[ 1] = xy*nc + zs; r[ 5] = y*y*nc + c; r[ 9] = yz*nc - xs; - r[ 2] = zx*nc - ys; r[ 6] = yz*nc + xs; r[10] = z*z*nc + c; - } - return rotation; -} - -// ---------------------------------------------------------------------------------------- -// Arithmetic operators outside of class -// ---------------------------------------------------------------------------------------- - -/* We use non-friend functions here to prevent the compiler from using - * implicit conversions, for instance of a scalar to a vector. The result would - * not be what the caller expects. - * - * Also note that the order of the arguments in the inner loop is important since - * it determines the output type (only relevant when T != U). - */ - -// matrix * vector, result is a vector of the same type than the input vector -template -typename tmat44::col_type PURE operator *(const tmat44& lv, const tvec4& rv) { - typename tmat44::col_type result; - for (size_t r=0 ; r::row_size() ; r++) - result += rv[r]*lv[r]; - return result; -} - -// vector * matrix, result is a vector of the same type than the input vector -template -typename tmat44::row_type PURE operator *(const tvec4& rv, const tmat44& lv) { - typename tmat44::row_type result(tmat44::row_type::NO_INIT); - for (size_t r=0 ; r::row_size() ; r++) - result[r] = dot(rv, lv[r]); - return result; -} - -// matrix * scalar, result is a matrix of the same type than the input matrix -template -tmat44 PURE operator *(const tmat44& lv, U rv) { - tmat44 result(tmat44::NO_INIT); - for (size_t r=0 ; r::row_size() ; r++) - result[r] = lv[r]*rv; - return result; -} - -// scalar * matrix, result is a matrix of the same type than the input matrix -template -tmat44 PURE operator *(U rv, const tmat44& lv) { - tmat44 result(tmat44::NO_INIT); - for (size_t r=0 ; r::row_size() ; r++) - result[r] = lv[r]*rv; - return result; -} - -// ---------------------------------------------------------------------------------------- - -/* FIXME: this should go into TMatSquareFunctions<> but for some reason - * BASE::col_type is not accessible from there (???) - */ -template -typename tmat44::col_type PURE diag(const tmat44& m) { - return matrix::diag(m); -} - -// ---------------------------------------------------------------------------------------- - -typedef tmat44 mat4; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#undef PURE - -#endif /* UI_MAT4_H */ diff --git a/third_party/android_frameworks_native/include/ui/vec2.h b/third_party/android_frameworks_native/include/ui/vec2.h deleted file mode 100644 index c31d0e43e..000000000 --- a/third_party/android_frameworks_native/include/ui/vec2.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2013 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. - */ - -#ifndef UI_VEC2_H -#define UI_VEC2_H - -#include -#include - -#define TVEC_IMPLEMENTATION -#include - -namespace android { -// ------------------------------------------------------------------------------------- - -template -class tvec2 : public TVecProductOperators, - public TVecAddOperators, - public TVecUnaryOperators, - public TVecComparisonOperators, - public TVecFunctions -{ -public: - enum no_init { NO_INIT }; - typedef T value_type; - typedef T& reference; - typedef T const& const_reference; - typedef size_t size_type; - - union { - struct { T x, y; }; - struct { T s, t; }; - struct { T r, g; }; - }; - - enum { SIZE = 2 }; - inline static size_type size() { return SIZE; } - - // array access - inline T const& operator [] (size_t i) const { return (&x)[i]; } - inline T& operator [] (size_t i) { return (&x)[i]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - // constructors - - // leaves object uninitialized. use with caution. - explicit tvec2(no_init) { } - - // default constructor - tvec2() : x(0), y(0) { } - - // handles implicit conversion to a tvec4. must not be explicit. - template - tvec2(A v) : x(v), y(v) { } - - template - tvec2(A x, B y) : x(x), y(y) { } - - template - explicit tvec2(const tvec2& v) : x(v.x), y(v.y) { } - - template - tvec2(const Impersonator< tvec2 >& v) - : x(((const tvec2&)v).x), - y(((const tvec2&)v).y) { } -}; - -// ---------------------------------------------------------------------------------------- - -typedef tvec2 vec2; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#endif /* UI_VEC4_H */ diff --git a/third_party/android_frameworks_native/include/ui/vec3.h b/third_party/android_frameworks_native/include/ui/vec3.h deleted file mode 100644 index dde59a96f..000000000 --- a/third_party/android_frameworks_native/include/ui/vec3.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2013 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. - */ - -#ifndef UI_VEC3_H -#define UI_VEC3_H - -#include -#include - -#include - -namespace android { -// ------------------------------------------------------------------------------------- - -template -class tvec3 : public TVecProductOperators, - public TVecAddOperators, - public TVecUnaryOperators, - public TVecComparisonOperators, - public TVecFunctions -{ -public: - enum no_init { NO_INIT }; - typedef T value_type; - typedef T& reference; - typedef T const& const_reference; - typedef size_t size_type; - - union { - struct { T x, y, z; }; - struct { T s, t, p; }; - struct { T r, g, b; }; - Impersonator< tvec2 > xy; - Impersonator< tvec2 > st; - Impersonator< tvec2 > rg; - }; - - enum { SIZE = 3 }; - inline static size_type size() { return SIZE; } - - // array access - inline T const& operator [] (size_t i) const { return (&x)[i]; } - inline T& operator [] (size_t i) { return (&x)[i]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - // constructors - // leaves object uninitialized. use with caution. - explicit tvec3(no_init) { } - - // default constructor - tvec3() : x(0), y(0), z(0) { } - - // handles implicit conversion to a tvec4. must not be explicit. - template - tvec3(A v) : x(v), y(v), z(v) { } - - template - tvec3(A x, B y, C z) : x(x), y(y), z(z) { } - - template - tvec3(const tvec2& v, B z) : x(v.x), y(v.y), z(z) { } - - template - explicit tvec3(const tvec3& v) : x(v.x), y(v.y), z(v.z) { } - - template - tvec3(const Impersonator< tvec3 >& v) - : x(((const tvec3&)v).x), - y(((const tvec3&)v).y), - z(((const tvec3&)v).z) { } - - template - tvec3(const Impersonator< tvec2 >& v, B z) - : x(((const tvec2&)v).x), - y(((const tvec2&)v).y), - z(z) { } - - // cross product works only on vectors of size 3 - template - friend inline - tvec3 __attribute__((pure)) cross(const tvec3& u, const tvec3& v) { - return tvec3( - u.y*v.z - u.z*v.y, - u.z*v.x - u.x*v.z, - u.x*v.y - u.y*v.x); - } -}; - - -// ---------------------------------------------------------------------------------------- - -typedef tvec3 vec3; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#endif /* UI_VEC4_H */ diff --git a/third_party/android_frameworks_native/include/ui/vec4.h b/third_party/android_frameworks_native/include/ui/vec4.h deleted file mode 100644 index e03d331fb..000000000 --- a/third_party/android_frameworks_native/include/ui/vec4.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2013 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. - */ - -#ifndef UI_VEC4_H -#define UI_VEC4_H - -#include -#include - -#include - -namespace android { -// ------------------------------------------------------------------------------------- - -template -class tvec4 : public TVecProductOperators, - public TVecAddOperators, - public TVecUnaryOperators, - public TVecComparisonOperators, - public TVecFunctions -{ -public: - enum no_init { NO_INIT }; - typedef T value_type; - typedef T& reference; - typedef T const& const_reference; - typedef size_t size_type; - - union { - struct { T x, y, z, w; }; - struct { T s, t, p, q; }; - struct { T r, g, b, a; }; - Impersonator< tvec2 > xy; - Impersonator< tvec2 > st; - Impersonator< tvec2 > rg; - Impersonator< tvec3 > xyz; - Impersonator< tvec3 > stp; - Impersonator< tvec3 > rgb; - }; - - enum { SIZE = 4 }; - inline static size_type size() { return SIZE; } - - // array access - inline T const& operator [] (size_t i) const { return (&x)[i]; } - inline T& operator [] (size_t i) { return (&x)[i]; } - - // ----------------------------------------------------------------------- - // we don't provide copy-ctor and operator= on purpose - // because we want the compiler generated versions - - // constructors - - // leaves object uninitialized. use with caution. - explicit tvec4(no_init) { } - - // default constructor - tvec4() : x(0), y(0), z(0), w(0) { } - - // handles implicit conversion to a tvec4. must not be explicit. - template - tvec4(A v) : x(v), y(v), z(v), w(v) { } - - template - tvec4(A x, B y, C z, D w) : x(x), y(y), z(z), w(w) { } - - template - tvec4(const tvec2& v, B z, C w) : x(v.x), y(v.y), z(z), w(w) { } - - template - tvec4(const tvec3& v, B w) : x(v.x), y(v.y), z(v.z), w(w) { } - - template - explicit tvec4(const tvec4& v) : x(v.x), y(v.y), z(v.z), w(v.w) { } - - template - tvec4(const Impersonator< tvec4 >& v) - : x(((const tvec4&)v).x), - y(((const tvec4&)v).y), - z(((const tvec4&)v).z), - w(((const tvec4&)v).w) { } - - template - tvec4(const Impersonator< tvec3 >& v, B w) - : x(((const tvec3&)v).x), - y(((const tvec3&)v).y), - z(((const tvec3&)v).z), - w(w) { } - - template - tvec4(const Impersonator< tvec2 >& v, B z, C w) - : x(((const tvec2&)v).x), - y(((const tvec2&)v).y), - z(z), - w(w) { } -}; - -// ---------------------------------------------------------------------------------------- - -typedef tvec4 vec4; - -// ---------------------------------------------------------------------------------------- -}; // namespace android - -#endif /* UI_VEC4_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/activity_recognition.h b/third_party/android_hardware_libhardware/include/hardware/activity_recognition.h deleted file mode 100644 index 8f9945982..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/activity_recognition.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -/* - * Activity Recognition HAL. The goal is to provide low power, low latency, always-on activity - * recognition implemented in hardware (i.e. these activity recognition algorithms/classifers - * should NOT be run on the AP). By low power we mean that this may be activated 24/7 without - * impacting the battery drain speed (goal in order of 1mW including the power for sensors). - * This HAL does not specify the input sources that are used towards detecting these activities. - * It has one monitor interface which can be used to batch activities for always-on - * activity_recognition and if the latency is zero, the same interface can be used for low latency - * detection. - */ - -#ifndef ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H -#define ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H - -#include - -__BEGIN_DECLS - -#define ACTIVITY_RECOGNITION_HEADER_VERSION 1 -#define ACTIVITY_RECOGNITION_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, ACTIVITY_RECOGNITION_HEADER_VERSION) - -#define ACTIVITY_RECOGNITION_HARDWARE_MODULE_ID "activity_recognition" -#define ACTIVITY_RECOGNITION_HARDWARE_INTERFACE "activity_recognition_hw_if" - -/* - * Define types for various activities. Multiple activities may be active at the same time and - * sometimes none of these activities may be active. - * - * Each activity has a corresponding type. Only activities that are defined here should use - * android.activity_recognition.* prefix. OEM defined activities should not use this prefix. - * Activity type of OEM-defined activities should start with the reverse domain name of the entity - * defining the activity. - * - * When android introduces a new activity type that can potentially replace an OEM-defined activity - * type, the OEM must use the official activity type on versions of the HAL that support this new - * official activity type. - * - * Example (made up): Suppose Google's Glass team wants to detect nodding activity. - * - Such an activity is not officially supported in android L - * - Glass devices launching on L can implement a custom activity with - * type = "com.google.glass.nodding" - * - In M android release, if android decides to define ACITIVITY_TYPE_NODDING, those types - * should replace the Glass-team-specific types in all future launches. - * - When launching glass on the M release, Google should now use the official activity type - * - This way, other applications can use this activity. - */ - -#define ACTIVITY_TYPE_IN_VEHICLE "android.activity_recognition.in_vehicle" - -#define ACTIVITY_TYPE_ON_BICYCLE "android.activity_recognition.on_bicycle" - -#define ACTIVITY_TYPE_WALKING "android.activity_recognition.walking" - -#define ACTIVITY_TYPE_RUNNING "android.activity_recognition.running" - -#define ACTIVITY_TYPE_STILL "android.activity_recognition.still" - -#define ACTIVITY_TYPE_TILTING "android.activity_recognition.tilting" - -/* Values for activity_event.event_types. */ -enum { - /* - * A flush_complete event which indicates that a flush() has been successfully completed. This - * does not correspond to any activity/event. An event of this type should be added to the end - * of a batch FIFO and it indicates that all the events in the batch FIFO have been successfully - * reported to the framework. An event of this type should be generated only if flush() has been - * explicitly called and if the FIFO is empty at the time flush() is called it should trivially - * return a flush_complete_event to indicate that the FIFO is empty. - * - * A flush complete event should have the following parameters set. - * activity_event_t.event_type = ACTIVITY_EVENT_FLUSH_COMPLETE - * activity_event_t.activity = 0 - * activity_event_t.timestamp = 0 - * activity_event_t.reserved = 0 - * See (*flush)() for more details. - */ - ACTIVITY_EVENT_FLUSH_COMPLETE = 0, - - /* Signifies entering an activity. */ - ACTIVITY_EVENT_ENTER = 1, - - /* Signifies exiting an activity. */ - ACTIVITY_EVENT_EXIT = 2 -}; - -/* - * Each event is a separate activity with event_type indicating whether this activity has started - * or ended. Eg event: (event_type="enter", activity="ON_FOOT", timestamp) - */ -typedef struct activity_event { - /* One of the ACTIVITY_EVENT_* constants defined above. */ - uint32_t event_type; - - /* - * Index of the activity in the list returned by get_supported_activities_list. If this event - * is a flush complete event, this should be set to zero. - */ - uint32_t activity; - - /* Time at which the transition/event has occurred in nanoseconds using elapsedRealTimeNano. */ - int64_t timestamp; - - /* Set to zero. */ - int32_t reserved[4]; -} activity_event_t; - -typedef struct activity_recognition_module { - /** - * Common methods of the activity recognition module. This *must* be the first member of - * activity_recognition_module as users of this structure will cast a hw_module_t to - * activity_recognition_module pointer in contexts where it's known the hw_module_t - * references an activity_recognition_module. - */ - hw_module_t common; - - /* - * List of all activities supported by this module including OEM defined activities. Each - * activity is represented using a string defined above. Each string should be null terminated. - * The index of the activity in this array is used as a "handle" for enabling/disabling and - * event delivery. - * Return value is the size of this list. - */ - int (*get_supported_activities_list)(struct activity_recognition_module* module, - char const* const* *activity_list); -} activity_recognition_module_t; - -struct activity_recognition_device; - -typedef struct activity_recognition_callback_procs { - // Callback for activity_data. This is guaranteed to not invoke any HAL methods. - // Memory allocated for the events can be reused after this method returns. - // events - Array of activity_event_t s that are reported. - // count - size of the array. - void (*activity_callback)(const struct activity_recognition_callback_procs* procs, - const activity_event_t* events, int count); -} activity_recognition_callback_procs_t; - -typedef struct activity_recognition_device { - /** - * Common methods of the activity recognition device. This *must* be the first member of - * activity_recognition_device as users of this structure will cast a hw_device_t to - * activity_recognition_device pointer in contexts where it's known the hw_device_t - * references an activity_recognition_device. - */ - hw_device_t common; - - /* - * Sets the callback to invoke when there are events to report. This call overwrites the - * previously registered callback (if any). - */ - void (*register_activity_callback)(const struct activity_recognition_device* dev, - const activity_recognition_callback_procs_t* callback); - - /* - * Activates monitoring of activity transitions. Activities need not be reported as soon as they - * are detected. The detected activities are stored in a FIFO and reported in batches when the - * "max_batch_report_latency" expires or when the batch FIFO is full. The implementation should - * allow the AP to go into suspend mode while the activities are detected and stored in the - * batch FIFO. Whenever events need to be reported (like when the FIFO is full or when the - * max_batch_report_latency has expired for an activity, event pair), it should wake_up the AP - * so that no events are lost. Activities are stored as transitions and they are allowed to - * overlap with each other. Each (activity, event_type) pair can be activated or deactivated - * independently of the other. The HAL implementation needs to keep track of which pairs are - * currently active and needs to detect only those pairs. - * - * activity_handle - Index of the specific activity that needs to be detected in the list - * returned by get_supported_activities_list. - * event_type - Specific transition of the activity that needs to be detected. - * max_batch_report_latency_ns - a transition can be delayed by at most - * “max_batch_report_latency” nanoseconds. - * Return 0 on success, negative errno code otherwise. - */ - int (*enable_activity_event)(const struct activity_recognition_device* dev, - uint32_t activity_handle, uint32_t event_type, int64_t max_batch_report_latency_ns); - - /* - * Disables detection of a specific (activity, event_type) pair. - */ - int (*disable_activity_event)(const struct activity_recognition_device* dev, - uint32_t activity_handle, uint32_t event_type); - - /* - * Flush all the batch FIFOs. Report all the activities that were stored in the FIFO so far as - * if max_batch_report_latency had expired. This shouldn't change the latency in any way. Add - * a flush_complete_event to indicate the end of the FIFO after all events are delivered. - * See ACTIVITY_EVENT_FLUSH_COMPLETE for more details. - * Return 0 on success, negative errno code otherwise. - */ - int (*flush)(const struct activity_recognition_device* dev); - - // Must be set to NULL. - void (*reserved_procs[16 - 4])(void); -} activity_recognition_device_t; - -static inline int activity_recognition_open(const hw_module_t* module, - activity_recognition_device_t** device) { - return module->methods->open(module, - ACTIVITY_RECOGNITION_HARDWARE_INTERFACE, (hw_device_t**)device); -} - -static inline int activity_recognition_close(activity_recognition_device_t* device) { - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_ACTIVITY_RECOGNITION_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/audio.h b/third_party/android_hardware_libhardware/include/hardware/audio.h deleted file mode 100644 index 22e741976..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio.h +++ /dev/null @@ -1,700 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - - -#ifndef ANDROID_AUDIO_HAL_INTERFACE_H -#define ANDROID_AUDIO_HAL_INTERFACE_H - -#include -#include -#include -#include - -#include - -#include -#include -#include -#ifdef AUDIO_LISTEN_ENABLED -#include -#endif - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define AUDIO_HARDWARE_MODULE_ID "audio" - -/** - * Name of the audio devices to open - */ -#define AUDIO_HARDWARE_INTERFACE "audio_hw_if" - - -/* Use version 0.1 to be compatible with first generation of audio hw module with version_major - * hardcoded to 1. No audio module API change. - */ -#define AUDIO_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) -#define AUDIO_MODULE_API_VERSION_CURRENT AUDIO_MODULE_API_VERSION_0_1 - -/* First generation of audio devices had version hardcoded to 0. all devices with versions < 1.0 - * will be considered of first generation API. - */ -#define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0) -#define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) -#define AUDIO_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) -#define AUDIO_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) -#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_3_0 -/* Minimal audio HAL version supported by the audio framework */ -#define AUDIO_DEVICE_API_VERSION_MIN AUDIO_DEVICE_API_VERSION_2_0 - -/** - * List of known audio HAL modules. This is the base name of the audio HAL - * library composed of the "audio." prefix, one of the base names below and - * a suffix specific to the device. - * e.g: audio.primary.goldfish.so or audio.a2dp.default.so - */ - -#define AUDIO_HARDWARE_MODULE_ID_PRIMARY "primary" -#define AUDIO_HARDWARE_MODULE_ID_A2DP "a2dp" -#define AUDIO_HARDWARE_MODULE_ID_USB "usb" -#define AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX "r_submix" -#define AUDIO_HARDWARE_MODULE_ID_CODEC_OFFLOAD "codec_offload" - -/**************************************/ - -/** - * standard audio parameters that the HAL may need to handle - */ - -/** - * audio device parameters - */ - -/* BT SCO Noise Reduction + Echo Cancellation parameters */ -#define AUDIO_PARAMETER_KEY_BT_NREC "bt_headset_nrec" -#define AUDIO_PARAMETER_VALUE_ON "on" -#define AUDIO_PARAMETER_VALUE_OFF "off" - -/* TTY mode selection */ -#define AUDIO_PARAMETER_KEY_TTY_MODE "tty_mode" -#define AUDIO_PARAMETER_VALUE_TTY_OFF "tty_off" -#define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco" -#define AUDIO_PARAMETER_VALUE_TTY_HCO "tty_hco" -#define AUDIO_PARAMETER_VALUE_TTY_FULL "tty_full" - -/* Hearing Aid Compatibility - Telecoil (HAC-T) mode on/off - Strings must be in sync with CallFeaturesSetting.java */ -#define AUDIO_PARAMETER_KEY_HAC "HACSetting" -#define AUDIO_PARAMETER_VALUE_HAC_ON "ON" -#define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF" - -/* A2DP sink address set by framework */ -#define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address" - -/* A2DP source address set by framework */ -#define AUDIO_PARAMETER_A2DP_SOURCE_ADDRESS "a2dp_source_address" - -/* Screen state */ -#define AUDIO_PARAMETER_KEY_SCREEN_STATE "screen_state" - -/* Bluetooth SCO wideband */ -#define AUDIO_PARAMETER_KEY_BT_SCO_WB "bt_wbs" - -/* Get a new HW synchronization source identifier. - * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs - * or no HW sync is available. */ -#define AUDIO_PARAMETER_HW_AV_SYNC "hw_av_sync" - -/* Device state*/ -#define AUDIO_PARAMETER_KEY_DEV_SHUTDOWN "dev_shutdown" - -/** - * audio stream parameters - */ - -#define AUDIO_PARAMETER_STREAM_ROUTING "routing" /* audio_devices_t */ -#define AUDIO_PARAMETER_STREAM_FORMAT "format" /* audio_format_t */ -#define AUDIO_PARAMETER_STREAM_CHANNELS "channels" /* audio_channel_mask_t */ -#define AUDIO_PARAMETER_STREAM_FRAME_COUNT "frame_count" /* size_t */ -#define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source" /* audio_source_t */ -#define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */ - -#define AUDIO_PARAMETER_DEVICE_CONNECT "connect" /* audio_devices_t */ -#define AUDIO_PARAMETER_DEVICE_DISCONNECT "disconnect" /* audio_devices_t */ - -/* Query supported formats. The response is a '|' separated list of strings from - * audio_format_t enum e.g: "sup_formats=AUDIO_FORMAT_PCM_16_BIT" */ -#define AUDIO_PARAMETER_STREAM_SUP_FORMATS "sup_formats" -/* Query supported channel masks. The response is a '|' separated list of strings from - * audio_channel_mask_t enum e.g: "sup_channels=AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO" */ -#define AUDIO_PARAMETER_STREAM_SUP_CHANNELS "sup_channels" -/* Query supported sampling rates. The response is a '|' separated list of integer values e.g: - * "sup_sampling_rates=44100|48000" */ -#define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates" - -/* Set the HW synchronization source for an output stream. */ -#define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync" - -/** - * audio codec parameters - */ - -#define AUDIO_OFFLOAD_CODEC_PARAMS "music_offload_codec_param" -#define AUDIO_OFFLOAD_CODEC_BIT_PER_SAMPLE "music_offload_bit_per_sample" -#define AUDIO_OFFLOAD_CODEC_BIT_RATE "music_offload_bit_rate" -#define AUDIO_OFFLOAD_CODEC_AVG_BIT_RATE "music_offload_avg_bit_rate" -#define AUDIO_OFFLOAD_CODEC_ID "music_offload_codec_id" -#define AUDIO_OFFLOAD_CODEC_BLOCK_ALIGN "music_offload_block_align" -#define AUDIO_OFFLOAD_CODEC_SAMPLE_RATE "music_offload_sample_rate" -#define AUDIO_OFFLOAD_CODEC_ENCODE_OPTION "music_offload_encode_option" -#define AUDIO_OFFLOAD_CODEC_NUM_CHANNEL "music_offload_num_channels" -#define AUDIO_OFFLOAD_CODEC_DOWN_SAMPLING "music_offload_down_sampling" -#define AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES "delay_samples" -#define AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES "padding_samples" - -/**************************************/ - -/* common audio stream parameters and operations */ -struct audio_stream { - - /** - * Return the sampling rate in Hz - eg. 44100. - */ - uint32_t (*get_sample_rate)(const struct audio_stream *stream); - - /* currently unused - use set_parameters with key - * AUDIO_PARAMETER_STREAM_SAMPLING_RATE - */ - int (*set_sample_rate)(struct audio_stream *stream, uint32_t rate); - - /** - * Return size of input/output buffer in bytes for this stream - eg. 4800. - * It should be a multiple of the frame size. See also get_input_buffer_size. - */ - size_t (*get_buffer_size)(const struct audio_stream *stream); - - /** - * Return the channel mask - - * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO - */ - audio_channel_mask_t (*get_channels)(const struct audio_stream *stream); - - /** - * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT - */ - audio_format_t (*get_format)(const struct audio_stream *stream); - - /* currently unused - use set_parameters with key - * AUDIO_PARAMETER_STREAM_FORMAT - */ - int (*set_format)(struct audio_stream *stream, audio_format_t format); - - /** - * Put the audio hardware input/output into standby mode. - * Driver should exit from standby mode at the next I/O operation. - * Returns 0 on success and <0 on failure. - */ - int (*standby)(struct audio_stream *stream); - - /** dump the state of the audio input/output device */ - int (*dump)(const struct audio_stream *stream, int fd); - - /** Return the set of device(s) which this stream is connected to */ - audio_devices_t (*get_device)(const struct audio_stream *stream); - - /** - * Currently unused - set_device() corresponds to set_parameters() with key - * AUDIO_PARAMETER_STREAM_ROUTING for both input and output. - * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by - * input streams only. - */ - int (*set_device)(struct audio_stream *stream, audio_devices_t device); - - /** - * set/get audio stream parameters. The function accepts a list of - * parameter key value pairs in the form: key1=value1;key2=value2;... - * - * Some keys are reserved for standard parameters (See AudioParameter class) - * - * If the implementation does not accept a parameter change while - * the output is active but the parameter is acceptable otherwise, it must - * return -ENOSYS. - * - * The audio flinger will put the stream in standby and then change the - * parameter value. - */ - int (*set_parameters)(struct audio_stream *stream, const char *kv_pairs); - - /* - * Returns a pointer to a heap allocated string. The caller is responsible - * for freeing the memory for it using free(). - */ - char * (*get_parameters)(const struct audio_stream *stream, - const char *keys); - int (*add_audio_effect)(const struct audio_stream *stream, - effect_handle_t effect); - int (*remove_audio_effect)(const struct audio_stream *stream, - effect_handle_t effect); -}; -typedef struct audio_stream audio_stream_t; - -/* type of asynchronous write callback events. Mutually exclusive */ -typedef enum { - STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */ - STREAM_CBK_EVENT_DRAIN_READY /* drain completed */ -} stream_callback_event_t; - -typedef int (*stream_callback_t)(stream_callback_event_t event, void *param, void *cookie); - -/* type of drain requested to audio_stream_out->drain(). Mutually exclusive */ -typedef enum { - AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */ - AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data - from the current track has been played to - give time for gapless track switch */ -} audio_drain_type_t; - -/** - * audio_stream_out is the abstraction interface for the audio output hardware. - * - * It provides information about various properties of the audio output - * hardware driver. - */ - -struct audio_stream_out { - /** - * Common methods of the audio stream out. This *must* be the first member of audio_stream_out - * as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts - * where it's known the audio_stream references an audio_stream_out. - */ - struct audio_stream common; - - /** - * Return the audio hardware driver estimated latency in milliseconds. - */ - uint32_t (*get_latency)(const struct audio_stream_out *stream); - - /** - * Use this method in situations where audio mixing is done in the - * hardware. This method serves as a direct interface with hardware, - * allowing you to directly set the volume as apposed to via the framework. - * This method might produce multiple PCM outputs or hardware accelerated - * codecs, such as MP3 or AAC. - */ - int (*set_volume)(struct audio_stream_out *stream, float left, float right); - - /** - * Write audio buffer to driver. Returns number of bytes written, or a - * negative status_t. If at least one frame was written successfully prior to the error, - * it is suggested that the driver return that successful (short) byte count - * and then return an error in the subsequent call. - * - * If set_callback() has previously been called to enable non-blocking mode - * the write() is not allowed to block. It must write only the number of - * bytes that currently fit in the driver/hardware buffer and then return - * this byte count. If this is less than the requested write size the - * callback function must be called when more space is available in the - * driver/hardware buffer. - */ - ssize_t (*write)(struct audio_stream_out *stream, const void* buffer, - size_t bytes); - - /* return the number of audio frames written by the audio dsp to DAC since - * the output has exited standby - */ - int (*get_render_position)(const struct audio_stream_out *stream, - uint32_t *dsp_frames); - - /** - * get the local time at which the next write to the audio driver will be presented. - * The units are microseconds, where the epoch is decided by the local audio HAL. - */ - int (*get_next_write_timestamp)(const struct audio_stream_out *stream, - int64_t *timestamp); - - /** - * set the callback function for notifying completion of non-blocking - * write and drain. - * Calling this function implies that all future write() and drain() - * must be non-blocking and use the callback to signal completion. - */ - int (*set_callback)(struct audio_stream_out *stream, - stream_callback_t callback, void *cookie); - - /** - * Notifies to the audio driver to stop playback however the queued buffers are - * retained by the hardware. Useful for implementing pause/resume. Empty implementation - * if not supported however should be implemented for hardware with non-trivial - * latency. In the pause state audio hardware could still be using power. User may - * consider calling suspend after a timeout. - * - * Implementation of this function is mandatory for offloaded playback. - */ - int (*pause)(struct audio_stream_out* stream); - - /** - * Notifies to the audio driver to resume playback following a pause. - * Returns error if called without matching pause. - * - * Implementation of this function is mandatory for offloaded playback. - */ - int (*resume)(struct audio_stream_out* stream); - - /** - * Requests notification when data buffered by the driver/hardware has - * been played. If set_callback() has previously been called to enable - * non-blocking mode, the drain() must not block, instead it should return - * quickly and completion of the drain is notified through the callback. - * If set_callback() has not been called, the drain() must block until - * completion. - * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written - * data has been played. - * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all - * data for the current track has played to allow time for the framework - * to perform a gapless track switch. - * - * Drain must return immediately on stop() and flush() call - * - * Implementation of this function is mandatory for offloaded playback. - */ - int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type ); - - /** - * Notifies to the audio driver to flush the queued data. Stream must already - * be paused before calling flush(). - * - * Implementation of this function is mandatory for offloaded playback. - */ - int (*flush)(struct audio_stream_out* stream); - - /** - * Return a recent count of the number of audio frames presented to an external observer. - * This excludes frames which have been written but are still in the pipeline. - * The count is not reset to zero when output enters standby. - * Also returns the value of CLOCK_MONOTONIC as of this presentation count. - * The returned count is expected to be 'recent', - * but does not need to be the most recent possible value. - * However, the associated time should correspond to whatever count is returned. - * Example: assume that N+M frames have been presented, where M is a 'small' number. - * Then it is permissible to return N instead of N+M, - * and the timestamp should correspond to N rather than N+M. - * The terms 'recent' and 'small' are not defined. - * They reflect the quality of the implementation. - * - * 3.0 and higher only. - */ - int (*get_presentation_position)(const struct audio_stream_out *stream, - uint64_t *frames, struct timespec *timestamp); - -}; -typedef struct audio_stream_out audio_stream_out_t; - -struct audio_stream_in { - /** - * Common methods of the audio stream in. This *must* be the first member of audio_stream_in - * as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts - * where it's known the audio_stream references an audio_stream_in. - */ - struct audio_stream common; - - /** set the input gain for the audio driver. This method is for - * for future use */ - int (*set_gain)(struct audio_stream_in *stream, float gain); - - /** Read audio buffer in from audio driver. Returns number of bytes read, or a - * negative status_t. If at least one frame was read prior to the error, - * read should return that byte count and then return an error in the subsequent call. - */ - ssize_t (*read)(struct audio_stream_in *stream, void* buffer, - size_t bytes); - - /** - * Return the amount of input frames lost in the audio driver since the - * last call of this function. - * Audio driver is expected to reset the value to 0 and restart counting - * upon returning the current value by this function call. - * Such loss typically occurs when the user space process is blocked - * longer than the capacity of audio driver buffers. - * - * Unit: the number of input audio frames - */ - uint32_t (*get_input_frames_lost)(struct audio_stream_in *stream); -}; -typedef struct audio_stream_in audio_stream_in_t; - -/** - * return the frame size (number of bytes per sample). - * - * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead. - */ -__attribute__((__deprecated__)) -static inline size_t audio_stream_frame_size(const struct audio_stream *s) -{ - size_t chan_samp_sz; - audio_format_t format = s->get_format(s); - - if (audio_is_linear_pcm(format)) { - chan_samp_sz = audio_bytes_per_sample(format); - return popcount(s->get_channels(s)) * chan_samp_sz; - } - - return sizeof(int8_t); -} - -/** - * return the frame size (number of bytes per sample) of an output stream. - */ -static inline size_t audio_stream_out_frame_size(const struct audio_stream_out *s) -{ - size_t chan_samp_sz; - audio_format_t format = s->common.get_format(&s->common); - - if (audio_is_linear_pcm(format)) { - chan_samp_sz = audio_bytes_per_sample(format); - return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz; - } - - return sizeof(int8_t); -} - -/** - * return the frame size (number of bytes per sample) of an input stream. - */ -static inline size_t audio_stream_in_frame_size(const struct audio_stream_in *s) -{ - size_t chan_samp_sz; - audio_format_t format = s->common.get_format(&s->common); - - if (audio_is_linear_pcm(format)) { - chan_samp_sz = audio_bytes_per_sample(format); - return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz; - } - - return sizeof(int8_t); -} - -/**********************************************************************/ - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -struct audio_module { - struct hw_module_t common; -}; - -struct audio_hw_device { - /** - * Common methods of the audio device. This *must* be the first member of audio_hw_device - * as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts - * where it's known the hw_device_t references an audio_hw_device. - */ - struct hw_device_t common; - - /** - * used by audio flinger to enumerate what devices are supported by - * each audio_hw_device implementation. - * - * Return value is a bitmask of 1 or more values of audio_devices_t - * - * NOTE: audio HAL implementations starting with - * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function. - * All supported devices should be listed in audio_policy.conf - * file and the audio policy manager must choose the appropriate - * audio module based on information in this file. - */ - uint32_t (*get_supported_devices)(const struct audio_hw_device *dev); - - /** - * check to see if the audio hardware interface has been initialized. - * returns 0 on success, -ENODEV on failure. - */ - int (*init_check)(const struct audio_hw_device *dev); - - /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */ - int (*set_voice_volume)(struct audio_hw_device *dev, float volume); - - /** - * set the audio volume for all audio activities other than voice call. - * Range between 0.0 and 1.0. If any value other than 0 is returned, - * the software mixer will emulate this capability. - */ - int (*set_master_volume)(struct audio_hw_device *dev, float volume); - - /** - * Get the current master volume value for the HAL, if the HAL supports - * master volume control. AudioFlinger will query this value from the - * primary audio HAL when the service starts and use the value for setting - * the initial master volume across all HALs. HALs which do not support - * this method may leave it set to NULL. - */ - int (*get_master_volume)(struct audio_hw_device *dev, float *volume); - - /** - * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode - * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is - * playing, and AUDIO_MODE_IN_CALL when a call is in progress. - */ - int (*set_mode)(struct audio_hw_device *dev, audio_mode_t mode); - - /* mic mute */ - int (*set_mic_mute)(struct audio_hw_device *dev, bool state); - int (*get_mic_mute)(const struct audio_hw_device *dev, bool *state); - - /* set/get global audio parameters */ - int (*set_parameters)(struct audio_hw_device *dev, const char *kv_pairs); - - /* - * Returns a pointer to a heap allocated string. The caller is responsible - * for freeing the memory for it using free(). - */ - char * (*get_parameters)(const struct audio_hw_device *dev, - const char *keys); - - /* Returns audio input buffer size according to parameters passed or - * 0 if one of the parameters is not supported. - * See also get_buffer_size which is for a particular stream. - */ - size_t (*get_input_buffer_size)(const struct audio_hw_device *dev, - const struct audio_config *config); - - /** This method creates and opens the audio hardware output stream. - * The "address" parameter qualifies the "devices" audio device type if needed. - * The format format depends on the device type: - * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC" - * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y" - * - Other devices may use a number or any other string. - */ - - int (*open_output_stream)(struct audio_hw_device *dev, - audio_io_handle_t handle, - audio_devices_t devices, - audio_output_flags_t flags, - struct audio_config *config, - struct audio_stream_out **stream_out, - const char *address); - - void (*close_output_stream)(struct audio_hw_device *dev, - struct audio_stream_out* stream_out); - - /** This method creates and opens the audio hardware input stream */ - int (*open_input_stream)(struct audio_hw_device *dev, - audio_io_handle_t handle, - audio_devices_t devices, - struct audio_config *config, - struct audio_stream_in **stream_in, - audio_input_flags_t flags, - const char *address, - audio_source_t source); - - void (*close_input_stream)(struct audio_hw_device *dev, - struct audio_stream_in *stream_in); - - /** This method dumps the state of the audio hardware */ - int (*dump)(const struct audio_hw_device *dev, int fd); - - /** - * set the audio mute status for all audio activities. If any value other - * than 0 is returned, the software mixer will emulate this capability. - */ - int (*set_master_mute)(struct audio_hw_device *dev, bool mute); - - /** - * Get the current master mute status for the HAL, if the HAL supports - * master mute control. AudioFlinger will query this value from the primary - * audio HAL when the service starts and use the value for setting the - * initial master mute across all HALs. HALs which do not support this - * method may leave it set to NULL. - */ - int (*get_master_mute)(struct audio_hw_device *dev, bool *mute); - - /** - * Routing control - */ - - /* Creates an audio patch between several source and sink ports. - * The handle is allocated by the HAL and should be unique for this - * audio HAL module. */ - int (*create_audio_patch)(struct audio_hw_device *dev, - unsigned int num_sources, - const struct audio_port_config *sources, - unsigned int num_sinks, - const struct audio_port_config *sinks, - audio_patch_handle_t *handle); - - /* Release an audio patch */ - int (*release_audio_patch)(struct audio_hw_device *dev, - audio_patch_handle_t handle); - - /* Fills the list of supported attributes for a given audio port. - * As input, "port" contains the information (type, role, address etc...) - * needed by the HAL to identify the port. - * As output, "port" contains possible attributes (sampling rates, formats, - * channel masks, gain controllers...) for this port. - */ - int (*get_audio_port)(struct audio_hw_device *dev, - struct audio_port *port); - - /* Set audio port configuration */ - int (*set_audio_port_config)(struct audio_hw_device *dev, - const struct audio_port_config *config); - -#ifdef AUDIO_LISTEN_ENABLED - /** This method creates the listen session and returns handle */ - int (*open_listen_session)(struct audio_hw_device *dev, - listen_open_params_t *params, - struct listen_session** handle); - - /** This method closes the listen session */ - int (*close_listen_session)(struct audio_hw_device *dev, - struct listen_session* handle); - - /** This method sets the mad observer callback */ - int (*set_mad_observer)(struct audio_hw_device *dev, - listen_callback_t cb_func); - - /** - * This method is used for setting listen hal specfic parameters. - * If multiple paramets are set in one call and setting any one of them - * fails it will return failure. - */ - int (*listen_set_parameters)(struct audio_hw_device *dev, - const char *kv_pairs); -#endif -}; -typedef struct audio_hw_device audio_hw_device_t; - -/** convenience API for opening and closing a supported device */ - -static inline int audio_hw_device_open(const struct hw_module_t* module, - struct audio_hw_device** device) -{ - return module->methods->open(module, AUDIO_HARDWARE_INTERFACE, - (struct hw_device_t**)device); -} - -static inline int audio_hw_device_close(struct audio_hw_device* device) -{ - return device->common.close(&device->common); -} - - -__END_DECLS - -#endif // ANDROID_AUDIO_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h b/third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h deleted file mode 100644 index 0d266ff55..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_alsaops.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2014 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 contains shared utility functions to handle the tinyalsa - * implementation for Android internal audio, generally in the hardware layer. - * Some routines may log a fatal error on failure, as noted. - */ - -#ifndef ANDROID_AUDIO_ALSAOPS_H -#define ANDROID_AUDIO_ALSAOPS_H - -#include -#include -#include - -__BEGIN_DECLS - -/* Converts audio_format to pcm_format. - * Parameters: - * format the audio_format_t to convert - * - * Logs a fatal error if format is not a valid convertible audio_format_t. - */ -static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format) -{ - switch (format) { -#ifdef HAVE_BIG_ENDIAN - case AUDIO_FORMAT_PCM_16_BIT: - return PCM_FORMAT_S16_BE; - case AUDIO_FORMAT_PCM_24_BIT_PACKED: - return PCM_FORMAT_S24_3BE; - case AUDIO_FORMAT_PCM_32_BIT: - return PCM_FORMAT_S32_BE; - case AUDIO_FORMAT_PCM_8_24_BIT: - return PCM_FORMAT_S24_BE; -#else - case AUDIO_FORMAT_PCM_16_BIT: - return PCM_FORMAT_S16_LE; - case AUDIO_FORMAT_PCM_24_BIT_PACKED: - return PCM_FORMAT_S24_3LE; - case AUDIO_FORMAT_PCM_32_BIT: - return PCM_FORMAT_S32_LE; - case AUDIO_FORMAT_PCM_8_24_BIT: - return PCM_FORMAT_S24_LE; -#endif - case AUDIO_FORMAT_PCM_FLOAT: /* there is no equivalent for float */ - default: - LOG_ALWAYS_FATAL("pcm_format_from_audio_format: invalid audio format %#x", format); - return 0; - } -} - -/* Converts pcm_format to audio_format. - * Parameters: - * format the pcm_format to convert - * - * Logs a fatal error if format is not a valid convertible pcm_format. - */ -static inline audio_format_t audio_format_from_pcm_format(enum pcm_format format) -{ - switch (format) { -#ifdef HAVE_BIG_ENDIAN - case PCM_FORMAT_S16_BE: - return AUDIO_FORMAT_PCM_16_BIT; - case PCM_FORMAT_S24_3BE: - return AUDIO_FORMAT_PCM_24_BIT_PACKED; - case PCM_FORMAT_S24_BE: - return AUDIO_FORMAT_PCM_8_24_BIT; - case PCM_FORMAT_S32_BE: - return AUDIO_FORMAT_PCM_32_BIT; -#else - case PCM_FORMAT_S16_LE: - return AUDIO_FORMAT_PCM_16_BIT; - case PCM_FORMAT_S24_3LE: - return AUDIO_FORMAT_PCM_24_BIT_PACKED; - case PCM_FORMAT_S24_LE: - return AUDIO_FORMAT_PCM_8_24_BIT; - case PCM_FORMAT_S32_LE: - return AUDIO_FORMAT_PCM_32_BIT; -#endif - default: - LOG_ALWAYS_FATAL("audio_format_from_pcm_format: invalid pcm format %#x", format); - return 0; - } -} - -__END_DECLS - -#endif /* ANDROID_AUDIO_ALSAOPS_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h b/third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h deleted file mode 100644 index e3477d52a..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_amplifier.h +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2015, The CyanogenMod 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. - */ - -#ifndef CM_AUDIO_AMPLIFIER_INTERFACE_H -#define CM_AUDIO_AMPLIFIER_INTERFACE_H - -#include -#include -#include - -#include -#include - -#include - -__BEGIN_DECLS - -#define AMPLIFIER_HARDWARE_MODULE_ID "audio_amplifier" - -#define AMPLIFIER_HARDWARE_INTERFACE "audio_amplifier_hw_if" - -#define AMPLIFIER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) - -#define AMPLIFIER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) -#define AMPLIFIER_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) -#define AMPLIFIER_DEVICE_API_VERSION_CURRENT AMPLIFIER_DEVICE_API_VERSION_2_0 - -struct str_parms; - -typedef struct amplifier_device { - /** - * Common methods of the amplifier device. This *must* be the first member - * of amplifier_device as users of this structure will cast a hw_device_t - * to amplifier_device pointer in contexts where it's known - * the hw_device_t references a amplifier_device. - */ - struct hw_device_t common; - - /** - * Notify amplifier device of current input devices - * - * This function should handle only input devices. - */ - int (*set_input_devices)(struct amplifier_device *device, uint32_t devices); - - /** - * Notify amplifier device of current output devices - * - * This function should handle only output devices. - */ - int (*set_output_devices)(struct amplifier_device *device, uint32_t devices); - - /** - * Notify amplifier device of output device enable/disable - * - * This function should handle only output devices. - */ - int (*enable_output_devices)(struct amplifier_device *device, - uint32_t devices, bool enable); - - /** - * Notify amplifier device of input device enable/disable - * - * This function should handle only input devices. - */ - int (*enable_input_devices)(struct amplifier_device *device, - uint32_t devices, bool enable); - - /** - * Notify amplifier device about current audio mode - */ - int (*set_mode)(struct amplifier_device *device, audio_mode_t mode); - - /** - * Notify amplifier device that an output stream has started - */ - int (*output_stream_start)(struct amplifier_device *device, - struct audio_stream_out *stream, bool offload); - - /** - * Notify amplifier device that an input stream has started - */ - int (*input_stream_start)(struct amplifier_device *device, - struct audio_stream_in *stream); - - /** - * Notify amplifier device that an output stream has stopped - */ - int (*output_stream_standby)(struct amplifier_device *device, - struct audio_stream_out *stream); - - /** - * Notify amplifier device that an input stream has stopped - */ - int (*input_stream_standby)(struct amplifier_device *device, - struct audio_stream_in *stream); - - /** - * set/get output audio device parameters. - */ - int (*set_parameters)(struct amplifier_device *device, - struct str_parms *parms); -} amplifier_device_t; - -typedef struct amplifier_module { - /** - * Common methods of the amplifier module. This *must* be the first member - * of amplifier_module as users of this structure will cast a hw_module_t - * to amplifier_module pointer in contexts where it's known - * the hw_module_t references a amplifier_module. - */ - struct hw_module_t common; -} amplifier_module_t; - -/** convenience API for opening and closing a supported device */ - -static inline int amplifier_device_open(const struct hw_module_t *module, - struct amplifier_device **device) -{ - return module->methods->open(module, AMPLIFIER_HARDWARE_INTERFACE, - (struct hw_device_t **) device); -} - -static inline int amplifier_device_close(struct amplifier_device *device) -{ - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // CM_AUDIO_AMPLIFIER_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_effect.h b/third_party/android_hardware_libhardware/include/hardware/audio_effect.h deleted file mode 100644 index 41cd2e614..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_effect.h +++ /dev/null @@ -1,1014 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - - -#ifndef ANDROID_AUDIO_EFFECT_H -#define ANDROID_AUDIO_EFFECT_H - -#include -#include -#include -#include -#include - -#include - -#include - - -__BEGIN_DECLS - - -///////////////////////////////////////////////// -// Common Definitions -///////////////////////////////////////////////// - -// -//--- Effect descriptor structure effect_descriptor_t -// - -// Unique effect ID (can be generated from the following site: -// http://www.itu.int/ITU-T/asn1/uuid.html) -// This format is used for both "type" and "uuid" fields of the effect descriptor structure. -// - When used for effect type and the engine is implementing and effect corresponding to a standard -// OpenSL ES interface, this ID must be the one defined in OpenSLES_IID.h for that interface. -// - When used as uuid, it should be a unique UUID for this particular implementation. -typedef struct effect_uuid_s { - uint32_t timeLow; - uint16_t timeMid; - uint16_t timeHiAndVersion; - uint16_t clockSeq; - uint8_t node[6]; -} effect_uuid_t; - -// Maximum length of character strings in structures defines by this API. -#define EFFECT_STRING_LEN_MAX 64 - -// NULL UUID definition (matches SL_IID_NULL_) -#define EFFECT_UUID_INITIALIZER { 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, \ - { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } } -static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER; -static const effect_uuid_t * const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_; -static const char * const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210"; - - -// The effect descriptor contains necessary information to facilitate the enumeration of the effect -// engines present in a library. -typedef struct effect_descriptor_s { - effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect - effect_uuid_t uuid; // UUID for this particular implementation - uint32_t apiVersion; // Version of the effect control API implemented - uint32_t flags; // effect engine capabilities/requirements flags (see below) - uint16_t cpuLoad; // CPU load indication (see below) - uint16_t memoryUsage; // Data Memory usage (see below) - char name[EFFECT_STRING_LEN_MAX]; // human readable effect name - char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name -} effect_descriptor_t; - -// CPU load and memory usage indication: each effect implementation must provide an indication of -// its CPU and memory usage for the audio effect framework to limit the number of effects -// instantiated at a given time on a given platform. -// The CPU load is expressed in 0.1 MIPS units as estimated on an ARM9E core (ARMv5TE) with 0 WS. -// The memory usage is expressed in KB and includes only dynamically allocated memory - -// Definitions for flags field of effect descriptor. -// +---------------------------+-----------+----------------------------------- -// | description | bits | values -// +---------------------------+-----------+----------------------------------- -// | connection mode | 0..2 | 0 insert: after track process -// | | | 1 auxiliary: connect to track auxiliary -// | | | output and use send level -// | | | 2 replace: replaces track process function; -// | | | must implement SRC, volume and mono to stereo. -// | | | 3 pre processing: applied below audio HAL on input -// | | | 4 post processing: applied below audio HAL on output -// | | | 5 - 7 reserved -// +---------------------------+-----------+----------------------------------- -// | insertion preference | 3..5 | 0 none -// | | | 1 first of the chain -// | | | 2 last of the chain -// | | | 3 exclusive (only effect in the insert chain) -// | | | 4..7 reserved -// +---------------------------+-----------+----------------------------------- -// | Volume management | 6..8 | 0 none -// | | | 1 implements volume control -// | | | 2 requires volume indication -// | | | 4 reserved -// +---------------------------+-----------+----------------------------------- -// | Device indication | 9..11 | 0 none -// | | | 1 requires device updates -// | | | 2, 4 reserved -// +---------------------------+-----------+----------------------------------- -// | Sample input mode | 12..13 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG -// | | | command must specify a buffer descriptor -// | | | 2 provider: process() function uses the -// | | | bufferProvider indicated by the -// | | | EFFECT_CMD_SET_CONFIG command to request input. -// | | | buffers. -// | | | 3 both: both input modes are supported -// +---------------------------+-----------+----------------------------------- -// | Sample output mode | 14..15 | 1 direct: process() function or EFFECT_CMD_SET_CONFIG -// | | | command must specify a buffer descriptor -// | | | 2 provider: process() function uses the -// | | | bufferProvider indicated by the -// | | | EFFECT_CMD_SET_CONFIG command to request output -// | | | buffers. -// | | | 3 both: both output modes are supported -// +---------------------------+-----------+----------------------------------- -// | Hardware acceleration | 16..17 | 0 No hardware acceleration -// | | | 1 non tunneled hw acceleration: the process() function -// | | | reads the samples, send them to HW accelerated -// | | | effect processor, reads back the processed samples -// | | | and returns them to the output buffer. -// | | | 2 tunneled hw acceleration: the process() function is -// | | | transparent. The effect interface is only used to -// | | | control the effect engine. This mode is relevant for -// | | | global effects actually applied by the audio -// | | | hardware on the output stream. -// +---------------------------+-----------+----------------------------------- -// | Audio Mode indication | 18..19 | 0 none -// | | | 1 requires audio mode updates -// | | | 2..3 reserved -// +---------------------------+-----------+----------------------------------- -// | Audio source indication | 20..21 | 0 none -// | | | 1 requires audio source updates -// | | | 2..3 reserved -// +---------------------------+-----------+----------------------------------- -// | Effect offload supported | 22 | 0 The effect cannot be offloaded to an audio DSP -// | | | 1 The effect can be offloaded to an audio DSP -// +---------------------------+-----------+----------------------------------- - -// Insert mode -#define EFFECT_FLAG_TYPE_SHIFT 0 -#define EFFECT_FLAG_TYPE_SIZE 3 -#define EFFECT_FLAG_TYPE_MASK (((1 << EFFECT_FLAG_TYPE_SIZE) -1) \ - << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_INSERT (0 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_AUXILIARY (1 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_REPLACE (2 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_PRE_PROC (3 << EFFECT_FLAG_TYPE_SHIFT) -#define EFFECT_FLAG_TYPE_POST_PROC (4 << EFFECT_FLAG_TYPE_SHIFT) - -// Insert preference -#define EFFECT_FLAG_INSERT_SHIFT (EFFECT_FLAG_TYPE_SHIFT + EFFECT_FLAG_TYPE_SIZE) -#define EFFECT_FLAG_INSERT_SIZE 3 -#define EFFECT_FLAG_INSERT_MASK (((1 << EFFECT_FLAG_INSERT_SIZE) -1) \ - << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_ANY (0 << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_FIRST (1 << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_LAST (2 << EFFECT_FLAG_INSERT_SHIFT) -#define EFFECT_FLAG_INSERT_EXCLUSIVE (3 << EFFECT_FLAG_INSERT_SHIFT) - - -// Volume control -#define EFFECT_FLAG_VOLUME_SHIFT (EFFECT_FLAG_INSERT_SHIFT + EFFECT_FLAG_INSERT_SIZE) -#define EFFECT_FLAG_VOLUME_SIZE 3 -#define EFFECT_FLAG_VOLUME_MASK (((1 << EFFECT_FLAG_VOLUME_SIZE) -1) \ - << EFFECT_FLAG_VOLUME_SHIFT) -#define EFFECT_FLAG_VOLUME_CTRL (1 << EFFECT_FLAG_VOLUME_SHIFT) -#define EFFECT_FLAG_VOLUME_IND (2 << EFFECT_FLAG_VOLUME_SHIFT) -#define EFFECT_FLAG_VOLUME_NONE (0 << EFFECT_FLAG_VOLUME_SHIFT) - -// Device indication -#define EFFECT_FLAG_DEVICE_SHIFT (EFFECT_FLAG_VOLUME_SHIFT + EFFECT_FLAG_VOLUME_SIZE) -#define EFFECT_FLAG_DEVICE_SIZE 3 -#define EFFECT_FLAG_DEVICE_MASK (((1 << EFFECT_FLAG_DEVICE_SIZE) -1) \ - << EFFECT_FLAG_DEVICE_SHIFT) -#define EFFECT_FLAG_DEVICE_IND (1 << EFFECT_FLAG_DEVICE_SHIFT) -#define EFFECT_FLAG_DEVICE_NONE (0 << EFFECT_FLAG_DEVICE_SHIFT) - -// Sample input modes -#define EFFECT_FLAG_INPUT_SHIFT (EFFECT_FLAG_DEVICE_SHIFT + EFFECT_FLAG_DEVICE_SIZE) -#define EFFECT_FLAG_INPUT_SIZE 2 -#define EFFECT_FLAG_INPUT_MASK (((1 << EFFECT_FLAG_INPUT_SIZE) -1) \ - << EFFECT_FLAG_INPUT_SHIFT) -#define EFFECT_FLAG_INPUT_DIRECT (1 << EFFECT_FLAG_INPUT_SHIFT) -#define EFFECT_FLAG_INPUT_PROVIDER (2 << EFFECT_FLAG_INPUT_SHIFT) -#define EFFECT_FLAG_INPUT_BOTH (3 << EFFECT_FLAG_INPUT_SHIFT) - -// Sample output modes -#define EFFECT_FLAG_OUTPUT_SHIFT (EFFECT_FLAG_INPUT_SHIFT + EFFECT_FLAG_INPUT_SIZE) -#define EFFECT_FLAG_OUTPUT_SIZE 2 -#define EFFECT_FLAG_OUTPUT_MASK (((1 << EFFECT_FLAG_OUTPUT_SIZE) -1) \ - << EFFECT_FLAG_OUTPUT_SHIFT) -#define EFFECT_FLAG_OUTPUT_DIRECT (1 << EFFECT_FLAG_OUTPUT_SHIFT) -#define EFFECT_FLAG_OUTPUT_PROVIDER (2 << EFFECT_FLAG_OUTPUT_SHIFT) -#define EFFECT_FLAG_OUTPUT_BOTH (3 << EFFECT_FLAG_OUTPUT_SHIFT) - -// Hardware acceleration mode -#define EFFECT_FLAG_HW_ACC_SHIFT (EFFECT_FLAG_OUTPUT_SHIFT + EFFECT_FLAG_OUTPUT_SIZE) -#define EFFECT_FLAG_HW_ACC_SIZE 2 -#define EFFECT_FLAG_HW_ACC_MASK (((1 << EFFECT_FLAG_HW_ACC_SIZE) -1) \ - << EFFECT_FLAG_HW_ACC_SHIFT) -#define EFFECT_FLAG_HW_ACC_SIMPLE (1 << EFFECT_FLAG_HW_ACC_SHIFT) -#define EFFECT_FLAG_HW_ACC_TUNNEL (2 << EFFECT_FLAG_HW_ACC_SHIFT) - -// Audio mode indication -#define EFFECT_FLAG_AUDIO_MODE_SHIFT (EFFECT_FLAG_HW_ACC_SHIFT + EFFECT_FLAG_HW_ACC_SIZE) -#define EFFECT_FLAG_AUDIO_MODE_SIZE 2 -#define EFFECT_FLAG_AUDIO_MODE_MASK (((1 << EFFECT_FLAG_AUDIO_MODE_SIZE) -1) \ - << EFFECT_FLAG_AUDIO_MODE_SHIFT) -#define EFFECT_FLAG_AUDIO_MODE_IND (1 << EFFECT_FLAG_AUDIO_MODE_SHIFT) -#define EFFECT_FLAG_AUDIO_MODE_NONE (0 << EFFECT_FLAG_AUDIO_MODE_SHIFT) - -// Audio source indication -#define EFFECT_FLAG_AUDIO_SOURCE_SHIFT (EFFECT_FLAG_AUDIO_MODE_SHIFT + EFFECT_FLAG_AUDIO_MODE_SIZE) -#define EFFECT_FLAG_AUDIO_SOURCE_SIZE 2 -#define EFFECT_FLAG_AUDIO_SOURCE_MASK (((1 << EFFECT_FLAG_AUDIO_SOURCE_SIZE) -1) \ - << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) -#define EFFECT_FLAG_AUDIO_SOURCE_IND (1 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) -#define EFFECT_FLAG_AUDIO_SOURCE_NONE (0 << EFFECT_FLAG_AUDIO_SOURCE_SHIFT) - -// Effect offload indication -#define EFFECT_FLAG_OFFLOAD_SHIFT (EFFECT_FLAG_AUDIO_SOURCE_SHIFT + \ - EFFECT_FLAG_AUDIO_SOURCE_SIZE) -#define EFFECT_FLAG_OFFLOAD_SIZE 1 -#define EFFECT_FLAG_OFFLOAD_MASK (((1 << EFFECT_FLAG_OFFLOAD_SIZE) -1) \ - << EFFECT_FLAG_OFFLOAD_SHIFT) -#define EFFECT_FLAG_OFFLOAD_SUPPORTED (1 << EFFECT_FLAG_OFFLOAD_SHIFT) - -#define EFFECT_MAKE_API_VERSION(M, m) (((M)<<16) | ((m) & 0xFFFF)) -#define EFFECT_API_VERSION_MAJOR(v) ((v)>>16) -#define EFFECT_API_VERSION_MINOR(v) ((m) & 0xFFFF) - - - -///////////////////////////////////////////////// -// Effect control interface -///////////////////////////////////////////////// - -// Effect control interface version 2.0 -#define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2,0) - -// Effect control interface structure: effect_interface_s -// The effect control interface is exposed by each effect engine implementation. It consists of -// a set of functions controlling the configuration, activation and process of the engine. -// The functions are grouped in a structure of type effect_interface_s. -// -// Effect control interface handle: effect_handle_t -// The effect_handle_t serves two purposes regarding the implementation of the effect engine: -// - 1 it is the address of a pointer to an effect_interface_s structure where the functions -// of the effect control API for a particular effect are located. -// - 2 it is the address of the context of a particular effect instance. -// A typical implementation in the effect library would define a structure as follows: -// struct effect_module_s { -// const struct effect_interface_s *itfe; -// effect_config_t config; -// effect_context_t context; -// } -// The implementation of EffectCreate() function would then allocate a structure of this -// type and return its address as effect_handle_t -typedef struct effect_interface_s **effect_handle_t; - - -// Forward definition of type audio_buffer_t -typedef struct audio_buffer_s audio_buffer_t; - - - - - - -// Effect control interface definition -struct effect_interface_s { - //////////////////////////////////////////////////////////////////////////////// - // - // Function: process - // - // Description: Effect process function. Takes input samples as specified - // (count and location) in input buffer descriptor and output processed - // samples as specified in output buffer descriptor. If the buffer descriptor - // is not specified the function must use either the buffer or the - // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command. - // The effect framework will call the process() function after the EFFECT_CMD_ENABLE - // command is received and until the EFFECT_CMD_DISABLE is received. When the engine - // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully - // and when done indicate that it is OK to stop calling the process() function by - // returning the -ENODATA status. - // - // NOTE: the process() function implementation should be "real-time safe" that is - // it should not perform blocking calls: malloc/free, sleep, read/write/open/close, - // pthread_cond_wait/pthread_mutex_lock... - // - // Input: - // self: handle to the effect interface this function - // is called on. - // inBuffer: buffer descriptor indicating where to read samples to process. - // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. - // - // outBuffer: buffer descriptor indicating where to write processed samples. - // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command. - // - // Output: - // returned value: 0 successful operation - // -ENODATA the engine has finished the disable phase and the framework - // can stop calling process() - // -EINVAL invalid interface handle or - // invalid input/output buffer description - //////////////////////////////////////////////////////////////////////////////// - int32_t (*process)(effect_handle_t self, - audio_buffer_t *inBuffer, - audio_buffer_t *outBuffer); - //////////////////////////////////////////////////////////////////////////////// - // - // Function: command - // - // Description: Send a command and receive a response to/from effect engine. - // - // Input: - // self: handle to the effect interface this function - // is called on. - // cmdCode: command code: the command can be a standardized command defined in - // effect_command_e (see below) or a proprietary command. - // cmdSize: size of command in bytes - // pCmdData: pointer to command data - // pReplyData: pointer to reply data - // - // Input/Output: - // replySize: maximum size of reply data as input - // actual size of reply data as output - // - // Output: - // returned value: 0 successful operation - // -EINVAL invalid interface handle or - // invalid command/reply size or format according to - // command code - // The return code should be restricted to indicate problems related to this API - // specification. Status related to the execution of a particular command should be - // indicated as part of the reply field. - // - // *pReplyData updated with command response - // - //////////////////////////////////////////////////////////////////////////////// - int32_t (*command)(effect_handle_t self, - uint32_t cmdCode, - uint32_t cmdSize, - void *pCmdData, - uint32_t *replySize, - void *pReplyData); - //////////////////////////////////////////////////////////////////////////////// - // - // Function: get_descriptor - // - // Description: Returns the effect descriptor - // - // Input: - // self: handle to the effect interface this function - // is called on. - // - // Input/Output: - // pDescriptor: address where to return the effect descriptor. - // - // Output: - // returned value: 0 successful operation. - // -EINVAL invalid interface handle or invalid pDescriptor - // *pDescriptor: updated with the effect descriptor. - // - //////////////////////////////////////////////////////////////////////////////// - int32_t (*get_descriptor)(effect_handle_t self, - effect_descriptor_t *pDescriptor); - //////////////////////////////////////////////////////////////////////////////// - // - // Function: process_reverse - // - // Description: Process reverse stream function. This function is used to pass - // a reference stream to the effect engine. If the engine does not need a reference - // stream, this function pointer can be set to NULL. - // This function would typically implemented by an Echo Canceler. - // - // Input: - // self: handle to the effect interface this function - // is called on. - // inBuffer: buffer descriptor indicating where to read samples to process. - // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. - // - // outBuffer: buffer descriptor indicating where to write processed samples. - // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command. - // If the buffer and buffer provider in the configuration received by - // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse - // stream data - // - // Output: - // returned value: 0 successful operation - // -ENODATA the engine has finished the disable phase and the framework - // can stop calling process_reverse() - // -EINVAL invalid interface handle or - // invalid input/output buffer description - //////////////////////////////////////////////////////////////////////////////// - int32_t (*process_reverse)(effect_handle_t self, - audio_buffer_t *inBuffer, - audio_buffer_t *outBuffer); -}; - - -// -//--- Standardized command codes for command() function -// -enum effect_command_e { - EFFECT_CMD_INIT, // initialize effect engine - EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t) - EFFECT_CMD_RESET, // reset effect engine - EFFECT_CMD_ENABLE, // enable effect process - EFFECT_CMD_DISABLE, // disable effect process - EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t) - EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred - EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred - EFFECT_CMD_GET_PARAM, // get parameter - EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t) - EFFECT_CMD_SET_VOLUME, // set volume - EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...) - EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t) - EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t) - EFFECT_CMD_GET_CONFIG, // read effect engine configuration - EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration - EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS,// get all supported configurations for a feature. - EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration - EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration - EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t) - EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one, - // send the ioHandle of the effect thread - EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code -}; - -//================================================================================================== -// command: EFFECT_CMD_INIT -//-------------------------------------------------------------------------------------------------- -// description: -// Initialize effect engine: All configurations return to default -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Apply new audio parameters configurations for input and output buffers -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_RESET -//-------------------------------------------------------------------------------------------------- -// description: -// Reset the effect engine. Keep configuration but resets state and buffer content -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_ENABLE -//-------------------------------------------------------------------------------------------------- -// description: -// Enable the process. Called by the framework before the first call to process() -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_DISABLE -//-------------------------------------------------------------------------------------------------- -// description: -// Disable the process. Called by the framework after the last call to process() -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_PARAM -//-------------------------------------------------------------------------------------------------- -// description: -// Set a parameter and apply it immediately -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_param_t) + size of param and value -// data: effect_param_t + param + value. See effect_param_t definition below for value offset -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_PARAM_DEFERRED -//-------------------------------------------------------------------------------------------------- -// description: -// Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_param_t) + size of param and value -// data: effect_param_t + param + value. See effect_param_t definition below for value offset -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_SET_PARAM_COMMIT -//-------------------------------------------------------------------------------------------------- -// description: -// Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_GET_PARAM -//-------------------------------------------------------------------------------------------------- -// description: -// Get a parameter value -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_param_t) + size of param -// data: effect_param_t + param -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(effect_param_t) + size of param and value -// data: effect_param_t + param + value. See effect_param_t definition below for value offset -//================================================================================================== -// command: EFFECT_CMD_SET_DEVICE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the rendering device the audio output path is connected to. See audio.h, audio_devices_t -// for device values. -// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this -// command when the device changes -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_SET_VOLUME -//-------------------------------------------------------------------------------------------------- -// description: -// Set and get volume. Used by audio framework to delegate volume control to effect engine. -// The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in -// its descriptor to receive this command before every call to process() function -// If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return -// the volume that should be applied before the effect is processed. The overall volume (the volume -// actually applied by the effect engine multiplied by the returned value) should match the value -// indicated in the command. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: n * sizeof(uint32_t) -// data: volume for each channel defined in effect_config_t for output buffer expressed in -// 8.24 fixed point format -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: n * sizeof(uint32_t) / 0 -// data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor: -// volume for each channel defined in effect_config_t for output buffer expressed in -// 8.24 fixed point format -// - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor: -// N/A -// It is legal to receive a null pointer as pReplyData in which case the effect framework has -// delegated volume control to another effect -//================================================================================================== -// command: EFFECT_CMD_SET_AUDIO_MODE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its -// descriptor to receive this command when the audio mode changes. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: audio_mode_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_SET_CONFIG_REVERSE -//-------------------------------------------------------------------------------------------------- -// description: -// Apply new audio parameters configurations for input and output buffers of reverse stream. -// An example of reverse stream is the echo reference supplied to an Acoustic Echo Canceler. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(int) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_INPUT_DEVICE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the capture device the audio input path is connected to. See audio.h, audio_devices_t -// for device values. -// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this -// command when the device changes -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_GET_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Read audio parameters configurations for input and output buffers -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//================================================================================================== -// command: EFFECT_CMD_GET_CONFIG_REVERSE -//-------------------------------------------------------------------------------------------------- -// description: -// Read audio parameters configurations for input and output buffers of reverse stream -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 0 -// data: N/A -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(effect_config_t) -// data: effect_config_t -//================================================================================================== -// command: EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS -//-------------------------------------------------------------------------------------------------- -// description: -// Queries for supported configurations for a particular feature (e.g. get the supported -// combinations of main and auxiliary channels for a noise suppressor). -// The command parameter is the feature identifier (See effect_feature_e for a list of defined -// features) followed by the maximum number of configuration descriptor to return. -// The reply is composed of: -// - status (uint32_t): -// - 0 if feature is supported -// - -ENOSYS if the feature is not supported, -// - -ENOMEM if the feature is supported but the total number of supported configurations -// exceeds the maximum number indicated by the caller. -// - total number of supported configurations (uint32_t) -// - an array of configuration descriptors. -// The actual number of descriptors returned must not exceed the maximum number indicated by -// the caller. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: 2 x sizeof(uint32_t) -// data: effect_feature_e + maximum number of configurations to return -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 2 x sizeof(uint32_t) + n x sizeof () -// data: status + total number of configurations supported + array of n config descriptors -//================================================================================================== -// command: EFFECT_CMD_GET_FEATURE_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Retrieves current configuration for a given feature. -// The reply status is: -// - 0 if feature is supported -// - -ENOSYS if the feature is not supported, -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: effect_feature_e -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(uint32_t) + sizeof () -// data: status + config descriptor -//================================================================================================== -// command: EFFECT_CMD_SET_FEATURE_CONFIG -//-------------------------------------------------------------------------------------------------- -// description: -// Sets current configuration for a given feature. -// The reply status is: -// - 0 if feature is supported -// - -ENOSYS if the feature is not supported, -// - -EINVAL if the configuration is invalid -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) + sizeof () -// data: effect_feature_e + config descriptor -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(uint32_t) -// data: status -//================================================================================================== -// command: EFFECT_CMD_SET_AUDIO_SOURCE -//-------------------------------------------------------------------------------------------------- -// description: -// Set the audio source the capture path is configured for (Camcorder, voice recognition...). -// See audio.h, audio_source_t for values. -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: 0 -// data: N/A -//================================================================================================== -// command: EFFECT_CMD_OFFLOAD -//-------------------------------------------------------------------------------------------------- -// description: -// 1.indicate if the playback thread the effect is attached to is offloaded or not -// 2.update the io handle of the playback thread the effect is attached to -//-------------------------------------------------------------------------------------------------- -// command format: -// size: sizeof(effect_offload_param_t) -// data: effect_offload_param_t -//-------------------------------------------------------------------------------------------------- -// reply format: -// size: sizeof(uint32_t) -// data: uint32_t -//-------------------------------------------------------------------------------------------------- -// command: EFFECT_CMD_FIRST_PROPRIETARY -//-------------------------------------------------------------------------------------------------- -// description: -// All proprietary effect commands must use command codes above this value. The size and format of -// command and response fields is free in this case -//================================================================================================== - - -// Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t -// structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with -// regard to the channel mask definition in audio.h, audio_channel_mask_t e.g : -// Stereo: left, right -// 5 point 1: front left, front right, front center, low frequency, back left, back right -// The buffer size is expressed in frame count, a frame being composed of samples for all -// channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by -// definition -struct audio_buffer_s { - size_t frameCount; // number of frames in buffer - union { - void* raw; // raw pointer to start of buffer - int32_t* s32; // pointer to signed 32 bit data at start of buffer - int16_t* s16; // pointer to signed 16 bit data at start of buffer - uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer - }; -}; - -// The buffer_provider_s structure contains functions that can be used -// by the effect engine process() function to query and release input -// or output audio buffer. -// The getBuffer() function is called to retrieve a buffer where data -// should read from or written to by process() function. -// The releaseBuffer() function MUST be called when the buffer retrieved -// with getBuffer() is not needed anymore. -// The process function should use the buffer provider mechanism to retrieve -// input or output buffer if the inBuffer or outBuffer passed as argument is NULL -// and the buffer configuration (buffer_config_t) given by the EFFECT_CMD_SET_CONFIG -// command did not specify an audio buffer. - -typedef int32_t (* buffer_function_t)(void *cookie, audio_buffer_t *buffer); - -typedef struct buffer_provider_s { - buffer_function_t getBuffer; // retrieve next buffer - buffer_function_t releaseBuffer; // release used buffer - void *cookie; // for use by client of buffer provider functions -} buffer_provider_t; - - -// The buffer_config_s structure specifies the input or output audio format -// to be used by the effect engine. It is part of the effect_config_t -// structure that defines both input and output buffer configurations and is -// passed by the EFFECT_CMD_SET_CONFIG or EFFECT_CMD_SET_CONFIG_REVERSE command. -typedef struct buffer_config_s { - audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly - uint32_t samplingRate; // sampling rate - uint32_t channels; // channel mask (see audio_channel_mask_t in audio.h) - buffer_provider_t bufferProvider; // buffer provider - uint8_t format; // Audio format (see audio_format_t in audio.h) - uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e) - uint16_t mask; // indicates which of the above fields is valid -} buffer_config_t; - -// Values for "accessMode" field of buffer_config_t: -// overwrite, read only, accumulate (read/modify/write) -enum effect_buffer_access_e { - EFFECT_BUFFER_ACCESS_WRITE, - EFFECT_BUFFER_ACCESS_READ, - EFFECT_BUFFER_ACCESS_ACCUMULATE - -}; - -// feature identifiers for EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS command -enum effect_feature_e { - EFFECT_FEATURE_AUX_CHANNELS, // supports auxiliary channels (e.g. dual mic noise suppressor) - EFFECT_FEATURE_CNT -}; - -// EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combination -// of main and auxiliary channels supported -typedef struct channel_config_s { - audio_channel_mask_t main_channels; // channel mask for main channels - audio_channel_mask_t aux_channels; // channel mask for auxiliary channels -} channel_config_t; - - -// Values for bit field "mask" in buffer_config_t. If a bit is set, the corresponding field -// in buffer_config_t must be taken into account when executing the EFFECT_CMD_SET_CONFIG command -#define EFFECT_CONFIG_BUFFER 0x0001 // buffer field must be taken into account -#define EFFECT_CONFIG_SMP_RATE 0x0002 // samplingRate field must be taken into account -#define EFFECT_CONFIG_CHANNELS 0x0004 // channels field must be taken into account -#define EFFECT_CONFIG_FORMAT 0x0008 // format field must be taken into account -#define EFFECT_CONFIG_ACC_MODE 0x0010 // accessMode field must be taken into account -#define EFFECT_CONFIG_PROVIDER 0x0020 // bufferProvider field must be taken into account -#define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | EFFECT_CONFIG_SMP_RATE | \ - EFFECT_CONFIG_CHANNELS | EFFECT_CONFIG_FORMAT | \ - EFFECT_CONFIG_ACC_MODE | EFFECT_CONFIG_PROVIDER) - - -// effect_config_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_CONFIG -// command to configure audio parameters and buffers for effect engine input and output. -typedef struct effect_config_s { - buffer_config_t inputCfg; - buffer_config_t outputCfg; -} effect_config_t; - - -// effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM -// command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command. -// psize and vsize represent the actual size of parameter and value. -// -// NOTE: the start of value field inside the data field is always on a 32 bit boundary: -// -// +-----------+ -// | status | sizeof(int) -// +-----------+ -// | psize | sizeof(int) -// +-----------+ -// | vsize | sizeof(int) -// +-----------+ -// | | | | -// ~ parameter ~ > psize | -// | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int) -// +-----------+ | -// | padding | | -// +-----------+ -// | | | -// ~ value ~ > vsize -// | | | -// +-----------+ - -typedef struct effect_param_s { - int32_t status; // Transaction status (unused for command, used for reply) - uint32_t psize; // Parameter size - uint32_t vsize; // Value size - char data[]; // Start of Parameter + Value data -} effect_param_t; - -// structure used by EFFECT_CMD_OFFLOAD command -typedef struct effect_offload_param_s { - bool isOffload; // true if the playback thread the effect is attached to is offloaded - int ioHandle; // io handle of the playback thread the effect is attached to -} effect_offload_param_t; - - -///////////////////////////////////////////////// -// Effect library interface -///////////////////////////////////////////////// - -// Effect library interface version 3.0 -// Note that EffectsFactory.c only checks the major version component, so changes to the minor -// number can only be used for fully backwards compatible changes -#define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3,0) - -#define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T')) - -// Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM -// and the fields of this data structure must begin with audio_effect_library_t - -typedef struct audio_effect_library_s { - // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG - uint32_t tag; - // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor - uint32_t version; - // Name of this library - const char *name; - // Author/owner/implementor of the library - const char *implementor; - - //////////////////////////////////////////////////////////////////////////////// - // - // Function: create_effect - // - // Description: Creates an effect engine of the specified implementation uuid and - // returns an effect control interface on this engine. The function will allocate the - // resources for an instance of the requested effect engine and return - // a handle on the effect control interface. - // - // Input: - // uuid: pointer to the effect uuid. - // sessionId: audio session to which this effect instance will be attached. - // All effects created with the same session ID are connected in series and process - // the same signal stream. Knowing that two effects are part of the same effect - // chain can help the library implement some kind of optimizations. - // ioId: identifies the output or input stream this effect is directed to in - // audio HAL. - // For future use especially with tunneled HW accelerated effects - // - // Input/Output: - // pHandle: address where to return the effect interface handle. - // - // Output: - // returned value: 0 successful operation. - // -ENODEV library failed to initialize - // -EINVAL invalid pEffectUuid or pHandle - // -ENOENT no effect with this uuid found - // *pHandle: updated with the effect interface handle. - // - //////////////////////////////////////////////////////////////////////////////// - int32_t (*create_effect)(const effect_uuid_t *uuid, - int32_t sessionId, - int32_t ioId, - effect_handle_t *pHandle); - - //////////////////////////////////////////////////////////////////////////////// - // - // Function: release_effect - // - // Description: Releases the effect engine whose handle is given as argument. - // All resources allocated to this particular instance of the effect are - // released. - // - // Input: - // handle: handle on the effect interface to be released. - // - // Output: - // returned value: 0 successful operation. - // -ENODEV library failed to initialize - // -EINVAL invalid interface handle - // - //////////////////////////////////////////////////////////////////////////////// - int32_t (*release_effect)(effect_handle_t handle); - - //////////////////////////////////////////////////////////////////////////////// - // - // Function: get_descriptor - // - // Description: Returns the descriptor of the effect engine which implementation UUID is - // given as argument. - // - // Input/Output: - // uuid: pointer to the effect uuid. - // pDescriptor: address where to return the effect descriptor. - // - // Output: - // returned value: 0 successful operation. - // -ENODEV library failed to initialize - // -EINVAL invalid pDescriptor or uuid - // *pDescriptor: updated with the effect descriptor. - // - //////////////////////////////////////////////////////////////////////////////// - int32_t (*get_descriptor)(const effect_uuid_t *uuid, - effect_descriptor_t *pDescriptor); -} audio_effect_library_t; - -// Name of the hal_module_info -#define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI - -// Name of the hal_module_info as a string -#define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI" - -__END_DECLS - -#endif // ANDROID_AUDIO_EFFECT_H diff --git a/third_party/android_hardware_libhardware/include/hardware/audio_policy.h b/third_party/android_hardware_libhardware/include/hardware/audio_policy.h deleted file mode 100644 index 99cb0449f..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/audio_policy.h +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - - -#ifndef ANDROID_AUDIO_POLICY_INTERFACE_H -#define ANDROID_AUDIO_POLICY_INTERFACE_H - -#include -#include -#include - -#include - -#include -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define AUDIO_POLICY_HARDWARE_MODULE_ID "audio_policy" - -/** - * Name of the audio devices to open - */ -#define AUDIO_POLICY_INTERFACE "policy" - -/* ---------------------------------------------------------------------------- */ - -/* - * The audio_policy and audio_policy_service_ops structs define the - * communication interfaces between the platform specific audio policy manager - * and Android generic audio policy manager. - * The platform specific audio policy manager must implement methods of the - * audio_policy struct. - * This implementation makes use of the audio_policy_service_ops to control - * the activity and configuration of audio input and output streams. - * - * The platform specific audio policy manager is in charge of the audio - * routing and volume control policies for a given platform. - * The main roles of this module are: - * - keep track of current system state (removable device connections, phone - * state, user requests...). - * System state changes and user actions are notified to audio policy - * manager with methods of the audio_policy. - * - * - process get_output() queries received when AudioTrack objects are - * created: Those queries return a handler on an output that has been - * selected, configured and opened by the audio policy manager and that - * must be used by the AudioTrack when registering to the AudioFlinger - * with the createTrack() method. - * When the AudioTrack object is released, a release_output() query - * is received and the audio policy manager can decide to close or - * reconfigure the output depending on other streams using this output and - * current system state. - * - * - similarly process get_input() and release_input() queries received from - * AudioRecord objects and configure audio inputs. - * - process volume control requests: the stream volume is converted from - * an index value (received from UI) to a float value applicable to each - * output as a function of platform specific settings and current output - * route (destination device). It also make sure that streams are not - * muted if not allowed (e.g. camera shutter sound in some countries). - */ - -/* XXX: this should be defined OUTSIDE of frameworks/base */ -struct effect_descriptor_s; - -struct audio_policy { - /* - * configuration functions - */ - - /* indicate a change in device connection status */ - int (*set_device_connection_state)(struct audio_policy *pol, - audio_devices_t device, - audio_policy_dev_state_t state, - const char *device_address); - - /* retrieve a device connection status */ - audio_policy_dev_state_t (*get_device_connection_state)( - const struct audio_policy *pol, - audio_devices_t device, - const char *device_address); - - /* indicate a change in phone state. Valid phones states are defined - * by audio_mode_t */ - void (*set_phone_state)(struct audio_policy *pol, audio_mode_t state); - - /* deprecated, never called (was "indicate a change in ringer mode") */ - void (*set_ringer_mode)(struct audio_policy *pol, uint32_t mode, - uint32_t mask); - - /* force using a specific device category for the specified usage */ - void (*set_force_use)(struct audio_policy *pol, - audio_policy_force_use_t usage, - audio_policy_forced_cfg_t config); - - /* retrieve current device category forced for a given usage */ - audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy *pol, - audio_policy_force_use_t usage); - - /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE - * can still be muted. */ - void (*set_can_mute_enforced_audible)(struct audio_policy *pol, - bool can_mute); - - /* check proper initialization */ - int (*init_check)(const struct audio_policy *pol); - - /* - * Audio routing query functions - */ - - /* request an output appropriate for playback of the supplied stream type and - * parameters */ - audio_io_handle_t (*get_output)(struct audio_policy *pol, - audio_stream_type_t stream, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_output_flags_t flags, - const audio_offload_info_t *offloadInfo); - - /* indicates to the audio policy manager that the output starts being used - * by corresponding stream. */ - int (*start_output)(struct audio_policy *pol, - audio_io_handle_t output, - audio_stream_type_t stream, - int session); - - /* indicates to the audio policy manager that the output stops being used - * by corresponding stream. */ - int (*stop_output)(struct audio_policy *pol, - audio_io_handle_t output, - audio_stream_type_t stream, - int session); - - /* releases the output. */ - void (*release_output)(struct audio_policy *pol, audio_io_handle_t output); - - /* request an input appropriate for record from the supplied device with - * supplied parameters. */ - audio_io_handle_t (*get_input)(struct audio_policy *pol, audio_source_t inputSource, - uint32_t samplingRate, - audio_format_t format, - audio_channel_mask_t channelMask, - audio_in_acoustics_t acoustics); - - /* indicates to the audio policy manager that the input starts being used */ - int (*start_input)(struct audio_policy *pol, audio_io_handle_t input); - - /* indicates to the audio policy manager that the input stops being used. */ - int (*stop_input)(struct audio_policy *pol, audio_io_handle_t input); - - /* releases the input. */ - void (*release_input)(struct audio_policy *pol, audio_io_handle_t input); - - /* - * volume control functions - */ - - /* initialises stream volume conversion parameters by specifying volume - * index range. The index range for each stream is defined by AudioService. */ - void (*init_stream_volume)(struct audio_policy *pol, - audio_stream_type_t stream, - int index_min, - int index_max); - - /* sets the new stream volume at a level corresponding to the supplied - * index. The index is within the range specified by init_stream_volume() */ - int (*set_stream_volume_index)(struct audio_policy *pol, - audio_stream_type_t stream, - int index); - - /* retrieve current volume index for the specified stream */ - int (*get_stream_volume_index)(const struct audio_policy *pol, - audio_stream_type_t stream, - int *index); - - /* sets the new stream volume at a level corresponding to the supplied - * index for the specified device. - * The index is within the range specified by init_stream_volume() */ - int (*set_stream_volume_index_for_device)(struct audio_policy *pol, - audio_stream_type_t stream, - int index, - audio_devices_t device); - - /* retrieve current volume index for the specified stream for the specified device */ - int (*get_stream_volume_index_for_device)(const struct audio_policy *pol, - audio_stream_type_t stream, - int *index, - audio_devices_t device); - - /* return the strategy corresponding to a given stream type */ - uint32_t (*get_strategy_for_stream)(const struct audio_policy *pol, - audio_stream_type_t stream); - - /* return the enabled output devices for the given stream type */ - audio_devices_t (*get_devices_for_stream)(const struct audio_policy *pol, - audio_stream_type_t stream); - - /* Audio effect management */ - audio_io_handle_t (*get_output_for_effect)(struct audio_policy *pol, - const struct effect_descriptor_s *desc); - - int (*register_effect)(struct audio_policy *pol, - const struct effect_descriptor_s *desc, - audio_io_handle_t output, - uint32_t strategy, - int session, - int id); - - int (*unregister_effect)(struct audio_policy *pol, int id); - - int (*set_effect_enabled)(struct audio_policy *pol, int id, bool enabled); - - bool (*is_stream_active)(const struct audio_policy *pol, - audio_stream_type_t stream, - uint32_t in_past_ms); - - bool (*is_stream_active_remotely)(const struct audio_policy *pol, - audio_stream_type_t stream, - uint32_t in_past_ms); - - bool (*is_source_active)(const struct audio_policy *pol, - audio_source_t source); - - /* dump state */ - int (*dump)(const struct audio_policy *pol, int fd); - - /* check if offload is possible for given sample rate, bitrate, duration, ... */ - bool (*is_offload_supported)(const struct audio_policy *pol, - const audio_offload_info_t *info); -}; - - -struct audio_policy_service_ops { - /* - * Audio output Control functions - */ - - /* Opens an audio output with the requested parameters. - * - * The parameter values can indicate to use the default values in case the - * audio policy manager has no specific requirements for the output being - * opened. - * - * When the function returns, the parameter values reflect the actual - * values used by the audio hardware output stream. - * - * The audio policy manager can check if the proposed parameters are - * suitable or not and act accordingly. - */ - audio_io_handle_t (*open_output)(void *service, - audio_devices_t *pDevices, - uint32_t *pSamplingRate, - audio_format_t *pFormat, - audio_channel_mask_t *pChannelMask, - uint32_t *pLatencyMs, - audio_output_flags_t flags); - - /* creates a special output that is duplicated to the two outputs passed as - * arguments. The duplication is performed by - * a special mixer thread in the AudioFlinger. - */ - audio_io_handle_t (*open_duplicate_output)(void *service, - audio_io_handle_t output1, - audio_io_handle_t output2); - - /* closes the output stream */ - int (*close_output)(void *service, audio_io_handle_t output); - - /* suspends the output. - * - * When an output is suspended, the corresponding audio hardware output - * stream is placed in standby and the AudioTracks attached to the mixer - * thread are still processed but the output mix is discarded. - */ - int (*suspend_output)(void *service, audio_io_handle_t output); - - /* restores a suspended output. */ - int (*restore_output)(void *service, audio_io_handle_t output); - - /* */ - /* Audio input Control functions */ - /* */ - - /* opens an audio input - * deprecated - new implementations should use open_input_on_module, - * and the acoustics parameter is ignored - */ - audio_io_handle_t (*open_input)(void *service, - audio_devices_t *pDevices, - uint32_t *pSamplingRate, - audio_format_t *pFormat, - audio_channel_mask_t *pChannelMask, - audio_in_acoustics_t acoustics); - - /* closes an audio input */ - int (*close_input)(void *service, audio_io_handle_t input); - - /* */ - /* misc control functions */ - /* */ - - /* set a stream volume for a particular output. - * - * For the same user setting, a given stream type can have different - * volumes for each output (destination device) it is attached to. - */ - int (*set_stream_volume)(void *service, - audio_stream_type_t stream, - float volume, - audio_io_handle_t output, - int delay_ms); - - /* invalidate a stream type, causing a reroute to an unspecified new output */ - int (*invalidate_stream)(void *service, - audio_stream_type_t stream); - - /* function enabling to send proprietary informations directly from audio - * policy manager to audio hardware interface. */ - void (*set_parameters)(void *service, - audio_io_handle_t io_handle, - const char *kv_pairs, - int delay_ms); - - /* function enabling to receive proprietary informations directly from - * audio hardware interface to audio policy manager. - * - * Returns a pointer to a heap allocated string. The caller is responsible - * for freeing the memory for it using free(). - */ - - char * (*get_parameters)(void *service, audio_io_handle_t io_handle, - const char *keys); - - /* request the playback of a tone on the specified stream. - * used for instance to replace notification sounds when playing over a - * telephony device during a phone call. - */ - int (*start_tone)(void *service, - audio_policy_tone_t tone, - audio_stream_type_t stream); - - int (*stop_tone)(void *service); - - /* set down link audio volume. */ - int (*set_voice_volume)(void *service, - float volume, - int delay_ms); - - /* move effect to the specified output */ - int (*move_effects)(void *service, - int session, - audio_io_handle_t src_output, - audio_io_handle_t dst_output); - - /* loads an audio hw module. - * - * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp". - * The function returns a handle on the module that will be used to specify a particular - * module when calling open_output_on_module() or open_input_on_module() - */ - audio_module_handle_t (*load_hw_module)(void *service, - const char *name); - - /* Opens an audio output on a particular HW module. - * - * Same as open_output() but specifying a specific HW module on which the output must be opened. - */ - audio_io_handle_t (*open_output_on_module)(void *service, - audio_module_handle_t module, - audio_devices_t *pDevices, - uint32_t *pSamplingRate, - audio_format_t *pFormat, - audio_channel_mask_t *pChannelMask, - uint32_t *pLatencyMs, - audio_output_flags_t flags, - const audio_offload_info_t *offloadInfo); - - /* Opens an audio input on a particular HW module. - * - * Same as open_input() but specifying a specific HW module on which the input must be opened. - * Also removed deprecated acoustics parameter - */ - audio_io_handle_t (*open_input_on_module)(void *service, - audio_module_handle_t module, - audio_devices_t *pDevices, - uint32_t *pSamplingRate, - audio_format_t *pFormat, - audio_channel_mask_t *pChannelMask); - -}; - -/**********************************************************************/ - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct audio_policy_module { - struct hw_module_t common; -} audio_policy_module_t; - -struct audio_policy_device { - /** - * Common methods of the audio policy device. This *must* be the first member of - * audio_policy_device as users of this structure will cast a hw_device_t to - * audio_policy_device pointer in contexts where it's known the hw_device_t references an - * audio_policy_device. - */ - struct hw_device_t common; - - int (*create_audio_policy)(const struct audio_policy_device *device, - struct audio_policy_service_ops *aps_ops, - void *service, - struct audio_policy **ap); - - int (*destroy_audio_policy)(const struct audio_policy_device *device, - struct audio_policy *ap); -}; - -/** convenience API for opening and closing a supported device */ - -static inline int audio_policy_dev_open(const hw_module_t* module, - struct audio_policy_device** device) -{ - return module->methods->open(module, AUDIO_POLICY_INTERFACE, - (hw_device_t**)device); -} - -static inline int audio_policy_dev_close(struct audio_policy_device* device) -{ - return device->common.close(&device->common); -} - - -__END_DECLS - -#endif // ANDROID_AUDIO_POLICY_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/bluetooth.h b/third_party/android_hardware_libhardware/include/hardware/bluetooth.h deleted file mode 100644 index 5e8b468d6..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bluetooth.h +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BLUETOOTH_H -#define ANDROID_INCLUDE_BLUETOOTH_H - -#include -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The Bluetooth Hardware Module ID - */ - -#define BT_HARDWARE_MODULE_ID "bluetooth" -#define BT_STACK_MODULE_ID "bluetooth" -#define BT_STACK_TEST_MODULE_ID "bluetooth_test" - - -/* Bluetooth profile interface IDs */ - -#define BT_PROFILE_HANDSFREE_ID "handsfree" -#define BT_PROFILE_HANDSFREE_CLIENT_ID "handsfree_client" -#define BT_PROFILE_ADVANCED_AUDIO_ID "a2dp" -#define BT_PROFILE_ADVANCED_AUDIO_SINK_ID "a2dp_sink" -#define BT_PROFILE_HEALTH_ID "health" -#define BT_PROFILE_SOCKETS_ID "socket" -#define BT_PROFILE_HIDHOST_ID "hidhost" -#define BT_PROFILE_HIDDEV_ID "hiddev" -#define BT_PROFILE_PAN_ID "pan" -#define BT_PROFILE_MAP_CLIENT_ID "map_client" -#define BT_PROFILE_SDP_CLIENT_ID "sdp" -#define BT_PROFILE_GATT_ID "gatt" -#define BT_PROFILE_AV_RC_ID "avrcp" -#define WIPOWER_PROFILE_ID "wipower" -#define BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl" - -/** Bluetooth Address */ -typedef struct { - uint8_t address[6]; -} __attribute__((packed))bt_bdaddr_t; - -/** Bluetooth Device Name */ -typedef struct { - uint8_t name[249]; -} __attribute__((packed))bt_bdname_t; - -/** Bluetooth Adapter Visibility Modes*/ -typedef enum { - BT_SCAN_MODE_NONE, - BT_SCAN_MODE_CONNECTABLE, - BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE -} bt_scan_mode_t; - -/** Bluetooth Adapter State */ -typedef enum { - BT_STATE_OFF, - BT_STATE_ON -} bt_state_t; - -/** Bluetooth Error Status */ -/** We need to build on this */ - -typedef enum { - BT_STATUS_SUCCESS, - BT_STATUS_FAIL, - BT_STATUS_NOT_READY, - BT_STATUS_NOMEM, - BT_STATUS_BUSY, - BT_STATUS_DONE, /* request already completed */ - BT_STATUS_UNSUPPORTED, - BT_STATUS_PARM_INVALID, - BT_STATUS_UNHANDLED, - BT_STATUS_AUTH_FAILURE, - BT_STATUS_RMT_DEV_DOWN, - BT_STATUS_AUTH_REJECTED - -} bt_status_t; - -/** Bluetooth PinKey Code */ -typedef struct { - uint8_t pin[16]; -} __attribute__((packed))bt_pin_code_t; - -typedef struct { - uint8_t status; - uint8_t ctrl_state; /* stack reported state */ - uint64_t tx_time; /* in ms */ - uint64_t rx_time; /* in ms */ - uint64_t idle_time; /* in ms */ - uint64_t energy_used; /* a product of mA, V and ms */ -} __attribute__((packed))bt_activity_energy_info; - -/** Bluetooth Adapter Discovery state */ -typedef enum { - BT_DISCOVERY_STOPPED, - BT_DISCOVERY_STARTED -} bt_discovery_state_t; - -/** Bluetooth ACL connection state */ -typedef enum { - BT_ACL_STATE_CONNECTED, - BT_ACL_STATE_DISCONNECTED -} bt_acl_state_t; - -/** Bluetooth 128-bit UUID */ -typedef struct { - uint8_t uu[16]; -} bt_uuid_t; - -/** Bluetooth SDP service record */ -typedef struct -{ - bt_uuid_t uuid; - uint16_t channel; - char name[256]; // what's the maximum length -} bt_service_record_t; - - -/** Bluetooth Remote Version info */ -typedef struct -{ - int version; - int sub_ver; - int manufacturer; -} bt_remote_version_t; - -typedef struct -{ - uint16_t version_supported; - uint8_t local_privacy_enabled; - uint8_t max_adv_instance; - uint8_t rpa_offload_supported; - uint8_t max_irk_list_size; - uint8_t max_adv_filter_supported; - uint8_t activity_energy_info_supported; - uint16_t scan_result_storage_size; - uint16_t total_trackable_advertisers; - bool extended_scan_support; - bool debug_logging_supported; -}bt_local_le_features_t; - -/* Bluetooth Adapter and Remote Device property types */ -typedef enum { - /* Properties common to both adapter and remote device */ - /** - * Description - Bluetooth Device Name - * Access mode - Adapter name can be GET/SET. Remote device can be GET - * Data type - bt_bdname_t - */ - BT_PROPERTY_BDNAME = 0x1, - /** - * Description - Bluetooth Device Address - * Access mode - Only GET. - * Data type - bt_bdaddr_t - */ - BT_PROPERTY_BDADDR, - /** - * Description - Bluetooth Service 128-bit UUIDs - * Access mode - Only GET. - * Data type - Array of bt_uuid_t (Array size inferred from property length). - */ - BT_PROPERTY_UUIDS, - /** - * Description - Bluetooth Class of Device as found in Assigned Numbers - * Access mode - Only GET. - * Data type - uint32_t. - */ - BT_PROPERTY_CLASS_OF_DEVICE, - /** - * Description - Device Type - BREDR, BLE or DUAL Mode - * Access mode - Only GET. - * Data type - bt_device_type_t - */ - BT_PROPERTY_TYPE_OF_DEVICE, - /** - * Description - Bluetooth Service Record - * Access mode - Only GET. - * Data type - bt_service_record_t - */ - BT_PROPERTY_SERVICE_RECORD, - - /* Properties unique to adapter */ - /** - * Description - Bluetooth Adapter scan mode - * Access mode - GET and SET - * Data type - bt_scan_mode_t. - */ - BT_PROPERTY_ADAPTER_SCAN_MODE, - /** - * Description - List of bonded devices - * Access mode - Only GET. - * Data type - Array of bt_bdaddr_t of the bonded remote devices - * (Array size inferred from property length). - */ - BT_PROPERTY_ADAPTER_BONDED_DEVICES, - /** - * Description - Bluetooth Adapter Discovery timeout (in seconds) - * Access mode - GET and SET - * Data type - uint32_t - */ - BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT, - - /* Properties unique to remote device */ - /** - * Description - User defined friendly name of the remote device - * Access mode - GET and SET - * Data type - bt_bdname_t. - */ - BT_PROPERTY_REMOTE_FRIENDLY_NAME, - /** - * Description - RSSI value of the inquired remote device - * Access mode - Only GET. - * Data type - int32_t. - */ - BT_PROPERTY_REMOTE_RSSI, - /** - * Description - Remote version info - * Access mode - SET/GET. - * Data type - bt_remote_version_t. - */ - - BT_PROPERTY_REMOTE_VERSION_INFO, - - /** - * Description - Local LE features - * Access mode - GET. - * Data type - bt_local_le_features_t. - */ - BT_PROPERTY_LOCAL_LE_FEATURES, - - BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP = 0xFF, -} bt_property_type_t; - -/** Bluetooth Adapter Property data structure */ -typedef struct -{ - bt_property_type_t type; - int len; - void *val; -} bt_property_t; - - -/** Bluetooth Device Type */ -typedef enum { - BT_DEVICE_DEVTYPE_BREDR = 0x1, - BT_DEVICE_DEVTYPE_BLE, - BT_DEVICE_DEVTYPE_DUAL -} bt_device_type_t; -/** Bluetooth Bond state */ -typedef enum { - BT_BOND_STATE_NONE, - BT_BOND_STATE_BONDING, - BT_BOND_STATE_BONDED -} bt_bond_state_t; - -/** Bluetooth SSP Bonding Variant */ -typedef enum { - BT_SSP_VARIANT_PASSKEY_CONFIRMATION, - BT_SSP_VARIANT_PASSKEY_ENTRY, - BT_SSP_VARIANT_CONSENT, - BT_SSP_VARIANT_PASSKEY_NOTIFICATION -} bt_ssp_variant_t; - -#define BT_MAX_NUM_UUIDS 32 - -/** Bluetooth Interface callbacks */ - -/** Bluetooth Enable/Disable Callback. */ -typedef void (*adapter_state_changed_callback)(bt_state_t state); - -/** GET/SET Adapter Properties callback */ -/* TODO: For the GET/SET property APIs/callbacks, we may need a session - * identifier to associate the call with the callback. This would be needed - * whenever more than one simultaneous instance of the same adapter_type - * is get/set. - * - * If this is going to be handled in the Java framework, then we do not need - * to manage sessions here. - */ -typedef void (*adapter_properties_callback)(bt_status_t status, - int num_properties, - bt_property_t *properties); - -/** GET/SET Remote Device Properties callback */ -/** TODO: For remote device properties, do not see a need to get/set - * multiple properties - num_properties shall be 1 - */ -typedef void (*remote_device_properties_callback)(bt_status_t status, - bt_bdaddr_t *bd_addr, - int num_properties, - bt_property_t *properties); - -/** New device discovered callback */ -/** If EIR data is not present, then BD_NAME and RSSI shall be NULL and -1 - * respectively */ -typedef void (*device_found_callback)(int num_properties, - bt_property_t *properties); - -/** Discovery state changed callback */ -typedef void (*discovery_state_changed_callback)(bt_discovery_state_t state); - -/** Bluetooth Legacy PinKey Request callback */ -typedef void (*pin_request_callback)(bt_bdaddr_t *remote_bd_addr, - bt_bdname_t *bd_name, uint32_t cod, bool min_16_digit); - -/** Bluetooth SSP Request callback - Just Works & Numeric Comparison*/ -/** pass_key - Shall be 0 for BT_SSP_PAIRING_VARIANT_CONSENT & - * BT_SSP_PAIRING_PASSKEY_ENTRY */ -/* TODO: Passkey request callback shall not be needed for devices with display - * capability. We still need support this in the stack for completeness */ -typedef void (*ssp_request_callback)(bt_bdaddr_t *remote_bd_addr, - bt_bdname_t *bd_name, - uint32_t cod, - bt_ssp_variant_t pairing_variant, - uint32_t pass_key); - -/** Bluetooth Bond state changed callback */ -/* Invoked in response to create_bond, cancel_bond or remove_bond */ -typedef void (*bond_state_changed_callback)(bt_status_t status, - bt_bdaddr_t *remote_bd_addr, - bt_bond_state_t state); - -/** Bluetooth ACL connection state changed callback */ -typedef void (*acl_state_changed_callback)(bt_status_t status, bt_bdaddr_t *remote_bd_addr, - bt_acl_state_t state); - -typedef enum { - ASSOCIATE_JVM, - DISASSOCIATE_JVM -} bt_cb_thread_evt; - -/** Thread Associate/Disassociate JVM Callback */ -/* Callback that is invoked by the callback thread to allow upper layer to attach/detach to/from - * the JVM */ -typedef void (*callback_thread_event)(bt_cb_thread_evt evt); - -/** Bluetooth Test Mode Callback */ -/* Receive any HCI event from controller. Must be in DUT Mode for this callback to be received */ -typedef void (*dut_mode_recv_callback)(uint16_t opcode, uint8_t *buf, uint8_t len); - -/** Bluetooth HCI event Callback */ -/* Receive any HCI event from controller for raw commands */ -typedef void (*hci_event_recv_callback)(uint8_t event_code, uint8_t *buf, uint8_t len); - -/* LE Test mode callbacks -* This callback shall be invoked whenever the le_tx_test, le_rx_test or le_test_end is invoked -* The num_packets is valid only for le_test_end command */ -typedef void (*le_test_mode_callback)(bt_status_t status, uint16_t num_packets); - -/** Callback invoked when energy details are obtained */ -/* Ctrl_state-Current controller state-Active-1,scan-2,or idle-3 state as defined by HCI spec. - * If the ctrl_state value is 0, it means the API call failed - * Time values-In milliseconds as returned by the controller - * Energy used-Value as returned by the controller - * Status-Provides the status of the read_energy_info API call */ -typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info); - -/** TODO: Add callbacks for Link Up/Down and other generic - * notifications/callbacks */ - -/** Bluetooth DM callback structure. */ -typedef struct { - /** set to sizeof(bt_callbacks_t) */ - size_t size; - adapter_state_changed_callback adapter_state_changed_cb; - adapter_properties_callback adapter_properties_cb; - remote_device_properties_callback remote_device_properties_cb; - device_found_callback device_found_cb; - discovery_state_changed_callback discovery_state_changed_cb; - pin_request_callback pin_request_cb; - ssp_request_callback ssp_request_cb; - bond_state_changed_callback bond_state_changed_cb; - acl_state_changed_callback acl_state_changed_cb; - callback_thread_event thread_evt_cb; - dut_mode_recv_callback dut_mode_recv_cb; - le_test_mode_callback le_test_mode_cb; - energy_info_callback energy_info_cb; - hci_event_recv_callback hci_event_recv_cb; -} bt_callbacks_t; - -typedef void (*alarm_cb)(void *data); -typedef bool (*set_wake_alarm_callout)(uint64_t delay_millis, bool should_wake, alarm_cb cb, void *data); -typedef int (*acquire_wake_lock_callout)(const char *lock_name); -typedef int (*release_wake_lock_callout)(const char *lock_name); - -/** The set of functions required by bluedroid to set wake alarms and - * grab wake locks. This struct is passed into the stack through the - * |set_os_callouts| function on |bt_interface_t|. - */ -typedef struct { - /* set to sizeof(bt_os_callouts_t) */ - size_t size; - - set_wake_alarm_callout set_wake_alarm; - acquire_wake_lock_callout acquire_wake_lock; - release_wake_lock_callout release_wake_lock; -} bt_os_callouts_t; - -/** NOTE: By default, no profiles are initialized at the time of init/enable. - * Whenever the application invokes the 'init' API of a profile, then one of - * the following shall occur: - * - * 1.) If Bluetooth is not enabled, then the Bluetooth core shall mark the - * profile as enabled. Subsequently, when the application invokes the - * Bluetooth 'enable', as part of the enable sequence the profile that were - * marked shall be enabled by calling appropriate stack APIs. The - * 'adapter_properties_cb' shall return the list of UUIDs of the - * enabled profiles. - * - * 2.) If Bluetooth is enabled, then the Bluetooth core shall invoke the stack - * profile API to initialize the profile and trigger a - * 'adapter_properties_cb' with the current list of UUIDs including the - * newly added profile's UUID. - * - * The reverse shall occur whenever the profile 'cleanup' APIs are invoked - */ - -/** Represents the standard Bluetooth DM interface. */ -typedef struct { - /** set to sizeof(bt_interface_t) */ - size_t size; - /** - * Opens the interface and provides the callback routines - * to the implemenation of this interface. - */ - int (*init)(bt_callbacks_t* callbacks ); - - /** Enable Bluetooth. */ - int (*enable)(bool guest_mode); - - /** Disable Bluetooth. */ - int (*disable)(void); - - /** Closes the interface. */ - void (*cleanup)(void); - - /** SSR cleanup. */ - void (*ssrcleanup)(void); - - /** Get all Bluetooth Adapter properties at init */ - int (*get_adapter_properties)(void); - - /** Get Bluetooth Adapter property of 'type' */ - int (*get_adapter_property)(bt_property_type_t type); - - /** Set Bluetooth Adapter property of 'type' */ - /* Based on the type, val shall be one of - * bt_bdaddr_t or bt_bdname_t or bt_scanmode_t etc - */ - int (*set_adapter_property)(const bt_property_t *property); - - /** Get all Remote Device properties */ - int (*get_remote_device_properties)(bt_bdaddr_t *remote_addr); - - /** Get Remote Device property of 'type' */ - int (*get_remote_device_property)(bt_bdaddr_t *remote_addr, - bt_property_type_t type); - - /** Set Remote Device property of 'type' */ - int (*set_remote_device_property)(bt_bdaddr_t *remote_addr, - const bt_property_t *property); - - /** Get Remote Device's service record for the given UUID */ - int (*get_remote_service_record)(bt_bdaddr_t *remote_addr, - bt_uuid_t *uuid); - - /** Start SDP to get remote services */ - int (*get_remote_services)(bt_bdaddr_t *remote_addr); - - /** Start Discovery */ - int (*start_discovery)(void); - - /** Cancel Discovery */ - int (*cancel_discovery)(void); - - /** Create Bluetooth Bonding */ - int (*create_bond)(const bt_bdaddr_t *bd_addr, int transport); - - /** Remove Bond */ - int (*remove_bond)(const bt_bdaddr_t *bd_addr); - - /** Cancel Bond */ - int (*cancel_bond)(const bt_bdaddr_t *bd_addr); - - /** - * Get the connection status for a given remote device. - * return value of 0 means the device is not connected, - * non-zero return status indicates an active connection. - */ - int (*get_connection_state)(const bt_bdaddr_t *bd_addr); - - /** BT Legacy PinKey Reply */ - /** If accept==FALSE, then pin_len and pin_code shall be 0x0 */ - int (*pin_reply)(const bt_bdaddr_t *bd_addr, uint8_t accept, - uint8_t pin_len, bt_pin_code_t *pin_code); - - /** BT SSP Reply - Just Works, Numeric Comparison and Passkey - * passkey shall be zero for BT_SSP_VARIANT_PASSKEY_COMPARISON & - * BT_SSP_VARIANT_CONSENT - * For BT_SSP_VARIANT_PASSKEY_ENTRY, if accept==FALSE, then passkey - * shall be zero */ - int (*ssp_reply)(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant, - uint8_t accept, uint32_t passkey); - - /** Get Bluetooth profile interface */ - const void* (*get_profile_interface) (const char *profile_id); - - /** Bluetooth Test Mode APIs - Bluetooth must be enabled for these APIs */ - /* Configure DUT Mode - Use this mode to enter/exit DUT mode */ - int (*dut_mode_configure)(uint8_t enable); - - /* Send any test HCI (vendor-specific) command to the controller. Must be in DUT Mode */ - int (*dut_mode_send)(uint16_t opcode, uint8_t *buf, uint8_t len); - - /* Send any test HCI command to the controller. */ - int (*hci_cmd_send)(uint16_t opcode, uint8_t *buf, uint8_t len); - - /** BLE Test Mode APIs */ - /* opcode MUST be one of: LE_Receiver_Test, LE_Transmitter_Test, LE_Test_End */ - int (*le_test_mode)(uint16_t opcode, uint8_t *buf, uint8_t len); - - /* enable or disable bluetooth HCI snoop log */ - int (*config_hci_snoop_log)(uint8_t enable); - - /** Sets the OS call-out functions that bluedroid needs for alarms and wake locks. - * This should be called immediately after a successful |init|. - */ - int (*set_os_callouts)(bt_os_callouts_t *callouts); - - /** Read Energy info details - return value indicates BT_STATUS_SUCCESS or BT_STATUS_NOT_READY - * Success indicates that the VSC command was sent to controller - */ - int (*read_energy_info)(); - - /** - * Native support for dumpsys function - * Function is synchronous and |fd| is owned by caller. - */ - void (*dump)(int fd); - - /** - * Clear /data/misc/bt_config.conf and erase all stored connections - */ - int (*config_clear)(void); - - /** BT stack Test interface */ - const void* (*get_testapp_interface)(int test_app_profile); - - /** - * Clear (reset) the dynamic portion of the device interoperability database. - */ - void (*interop_database_clear)(void); - - /** - * Add a new device interoperability workaround for a remote device whose - * first |len| bytes of the its device address match |addr|. - * NOTE: |feature| has to match an item defined in interop_feature_t (interop.h). - */ - void (*interop_database_add)(uint16_t feature, const bt_bdaddr_t *addr, size_t len); -} bt_interface_t; - -/** TODO: Need to add APIs for Service Discovery, Service authorization and - * connection management. Also need to add APIs for configuring - * properties of remote bonded devices such as name, UUID etc. */ - -typedef struct { - struct hw_device_t common; - const bt_interface_t* (*get_bluetooth_interface)(); -} bluetooth_device_t; - -typedef bluetooth_device_t bluetooth_module_t; - - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BLUETOOTH_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_av.h b/third_party/android_hardware_libhardware/include/hardware/bt_av.h deleted file mode 100644 index be82fbeff..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_av.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved. - * Not a Contribution. - * - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BT_AV_H -#define ANDROID_INCLUDE_BT_AV_H - -__BEGIN_DECLS - -/* Bluetooth AV connection states */ -typedef enum { - BTAV_CONNECTION_STATE_DISCONNECTED = 0, - BTAV_CONNECTION_STATE_CONNECTING, - BTAV_CONNECTION_STATE_CONNECTED, - BTAV_CONNECTION_STATE_DISCONNECTING -} btav_connection_state_t; - -/* Bluetooth AV datapath states */ -typedef enum { - BTAV_AUDIO_STATE_REMOTE_SUSPEND = 0, - BTAV_AUDIO_STATE_STOPPED, - BTAV_AUDIO_STATE_STARTED, -} btav_audio_state_t; - - -/** Callback for connection state change. - * state will have one of the values from btav_connection_state_t - */ -typedef void (* btav_connection_state_callback)(btav_connection_state_t state, - bt_bdaddr_t *bd_addr); - -/** Callback for audiopath state change. - * state will have one of the values from btav_audio_state_t - */ -typedef void (* btav_audio_state_callback)(btav_audio_state_t state, - bt_bdaddr_t *bd_addr); - -/** Callback for connection priority of device for incoming connection - * btav_connection_priority_t - */ -typedef void (* btav_connection_priority_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for audio configuration change. - * Used only for the A2DP sink interface. - * state will have one of the values from btav_audio_state_t - * sample_rate: sample rate in Hz - * channel_count: number of channels (1 for mono, 2 for stereo) - */ -typedef void (* btav_audio_config_callback)(bt_bdaddr_t *bd_addr, - uint32_t sample_rate, - uint8_t channel_count); - -/** Callback for updating apps for A2dp multicast state. - */ - -typedef void (* btav_is_multicast_enabled_callback)(int state); - -/* - * Callback for audio focus request to be used only in - * case of A2DP Sink. This is required because we are using - * AudioTrack approach for audio data rendering. - */ -typedef void (* btav_audio_focus_request_callback)(bt_bdaddr_t *bd_addr); - -/** BT-AV callback structure. */ -typedef struct { - /** set to sizeof(btav_callbacks_t) */ - size_t size; - btav_connection_state_callback connection_state_cb; - btav_audio_state_callback audio_state_cb; - btav_audio_config_callback audio_config_cb; - btav_connection_priority_callback connection_priority_cb; - btav_is_multicast_enabled_callback multicast_state_cb; - btav_audio_focus_request_callback audio_focus_request_cb; -} btav_callbacks_t; - -/** - * NOTE: - * - * 1. AVRCP 1.0 shall be supported initially. AVRCP passthrough commands - * shall be handled internally via uinput - * - * 2. A2DP data path shall be handled via a socket pipe between the AudioFlinger - * android_audio_hw library and the Bluetooth stack. - * - */ -/** Represents the standard BT-AV interface. - * Used for both the A2DP source and sink interfaces. - */ -typedef struct { - - /** set to sizeof(btav_interface_t) */ - size_t size; - /** - * Register the BtAv callbacks - */ - bt_status_t (*init)( btav_callbacks_t* callbacks , int max_a2dp_connections, - int a2dp_multicast_state); - - /** connect to headset */ - bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); - - /** dis-connect from headset */ - bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); - - /** Closes the interface. */ - void (*cleanup)( void ); - - /** Send priority of device to stack*/ - void (*allow_connection)( int is_valid , bt_bdaddr_t *bd_addr); - - /** Sends Audio Focus State. */ - void (*audio_focus_state)( int focus_state ); -} btav_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_AV_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_common_types.h b/third_party/android_hardware_libhardware/include/hardware/bt_common_types.h deleted file mode 100644 index e30ac24e3..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_common_types.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2015 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 contains constants and definitions that can be used commonly between JNI and stack layer - * - ******************************************************************************/ -#ifndef ANDROID_INCLUDE_BT_COMMON_TYPES_H -#define ANDROID_INCLUDE_BT_COMMON_TYPES_H - -#include "bluetooth.h" - -typedef struct -{ - uint8_t client_if; - uint8_t filt_index; - uint8_t advertiser_state; - uint8_t advertiser_info_present; - uint8_t addr_type; - uint8_t tx_power; - int8_t rssi_value; - uint16_t time_stamp; - bt_bdaddr_t bd_addr; - uint8_t adv_pkt_len; - uint8_t *p_adv_pkt_data; - uint8_t scan_rsp_len; - uint8_t *p_scan_rsp_data; -} btgatt_track_adv_info_t; - -#endif /* ANDROID_INCLUDE_BT_COMMON_TYPES_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt.h deleted file mode 100644 index 42e14c2f1..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_H -#define ANDROID_INCLUDE_BT_GATT_H - -#include -#include "bt_gatt_client.h" -#include "bt_gatt_server.h" - -__BEGIN_DECLS - -/** BT-GATT callbacks */ -typedef struct { - /** Set to sizeof(btgatt_callbacks_t) */ - size_t size; - - /** GATT Client callbacks */ - const btgatt_client_callbacks_t* client; - - /** GATT Server callbacks */ - const btgatt_server_callbacks_t* server; -} btgatt_callbacks_t; - -/** Represents the standard Bluetooth GATT interface. */ -typedef struct { - /** Set to sizeof(btgatt_interface_t) */ - size_t size; - - /** - * Initializes the interface and provides callback routines - */ - bt_status_t (*init)( const btgatt_callbacks_t* callbacks ); - - /** Closes the interface */ - void (*cleanup)( void ); - - /** Pointer to the GATT client interface methods.*/ - const btgatt_client_interface_t* client; - - /** Pointer to the GATT server interface methods.*/ - const btgatt_server_interface_t* server; -} btgatt_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h deleted file mode 100644 index e7e8e82bb..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_client.h +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_CLIENT_H -#define ANDROID_INCLUDE_BT_GATT_CLIENT_H - -#include -#include "bt_gatt_types.h" -#include "bt_common_types.h" - -__BEGIN_DECLS - -/** - * Buffer sizes for maximum attribute length and maximum read/write - * operation buffer size. - */ -#define BTGATT_MAX_ATTR_LEN 600 - -/** Buffer type for unformatted reads/writes */ -typedef struct -{ - uint8_t value[BTGATT_MAX_ATTR_LEN]; - uint16_t len; -} btgatt_unformatted_value_t; - -/** Parameters for GATT read operations */ -typedef struct -{ - btgatt_srvc_id_t srvc_id; - btgatt_gatt_id_t char_id; - btgatt_gatt_id_t descr_id; - btgatt_unformatted_value_t value; - uint16_t value_type; - uint8_t status; -} btgatt_read_params_t; - -/** Parameters for GATT write operations */ -typedef struct -{ - btgatt_srvc_id_t srvc_id; - btgatt_gatt_id_t char_id; - btgatt_gatt_id_t descr_id; - uint8_t status; -} btgatt_write_params_t; - -/** Attribute change notification parameters */ -typedef struct -{ - uint8_t value[BTGATT_MAX_ATTR_LEN]; - bt_bdaddr_t bda; - btgatt_srvc_id_t srvc_id; - btgatt_gatt_id_t char_id; - uint16_t len; - uint8_t is_notify; -} btgatt_notify_params_t; - -typedef struct -{ - uint8_t client_if; - uint8_t action; - uint8_t filt_index; - uint16_t feat_seln; - uint16_t list_logic_type; - uint8_t filt_logic_type; - uint8_t rssi_high_thres; - uint8_t rssi_low_thres; - uint8_t dely_mode; - uint16_t found_timeout; - uint16_t lost_timeout; - uint8_t found_timeout_cnt; - uint16_t num_of_tracking_entries; -} btgatt_filt_param_setup_t; - -typedef struct -{ - bt_bdaddr_t *bda1; - bt_uuid_t *uuid1; - uint16_t u1; - uint16_t u2; - uint16_t u3; - uint16_t u4; - uint16_t u5; -} btgatt_test_params_t; - -/* BT GATT client error codes */ -typedef enum -{ - BT_GATTC_COMMAND_SUCCESS = 0, /* 0 Command succeeded */ - BT_GATTC_COMMAND_STARTED, /* 1 Command started OK. */ - BT_GATTC_COMMAND_BUSY, /* 2 Device busy with another command */ - BT_GATTC_COMMAND_STORED, /* 3 request is stored in control block */ - BT_GATTC_NO_RESOURCES, /* 4 No resources to issue command */ - BT_GATTC_MODE_UNSUPPORTED, /* 5 Request for 1 or more unsupported modes */ - BT_GATTC_ILLEGAL_VALUE, /* 6 Illegal command /parameter value */ - BT_GATTC_INCORRECT_STATE, /* 7 Device in wrong state for request */ - BT_GATTC_UNKNOWN_ADDR, /* 8 Unknown remote BD address */ - BT_GATTC_DEVICE_TIMEOUT, /* 9 Device timeout */ - BT_GATTC_INVALID_CONTROLLER_OUTPUT,/* 10 An incorrect value was received from HCI */ - BT_GATTC_SECURITY_ERROR, /* 11 Authorization or security failure or not authorized */ - BT_GATTC_DELAYED_ENCRYPTION_CHECK, /*12 Delayed encryption check */ - BT_GATTC_ERR_PROCESSING /* 12 Generic error */ -} btgattc_error_t; - -/** BT-GATT Client callback structure. */ - -/** Callback invoked in response to register_client */ -typedef void (*register_client_callback)(int status, int client_if, - bt_uuid_t *app_uuid); - -/** Callback for scan results */ -typedef void (*scan_result_callback)(bt_bdaddr_t* bda, int rssi, uint8_t* adv_data); - -/** GATT open callback invoked in response to open */ -typedef void (*connect_callback)(int conn_id, int status, int client_if, bt_bdaddr_t* bda); - -/** Callback invoked in response to close */ -typedef void (*disconnect_callback)(int conn_id, int status, - int client_if, bt_bdaddr_t* bda); - -/** - * Invoked in response to search_service when the GATT service search - * has been completed. - */ -typedef void (*search_complete_callback)(int conn_id, int status); - -/** Reports GATT services on a remote device */ -typedef void (*search_result_callback)( int conn_id, btgatt_srvc_id_t *srvc_id); - -/** GATT characteristic enumeration result callback */ -typedef void (*get_characteristic_callback)(int conn_id, int status, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, - int char_prop); - -/** GATT descriptor enumeration result callback */ -typedef void (*get_descriptor_callback)(int conn_id, int status, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, - btgatt_gatt_id_t *descr_id); - -/** GATT included service enumeration result callback */ -typedef void (*get_included_service_callback)(int conn_id, int status, - btgatt_srvc_id_t *srvc_id, btgatt_srvc_id_t *incl_srvc_id); - -/** Callback invoked in response to [de]register_for_notification */ -typedef void (*register_for_notification_callback)(int conn_id, - int registered, int status, btgatt_srvc_id_t *srvc_id, - btgatt_gatt_id_t *char_id); - -/** - * Remote device notification callback, invoked when a remote device sends - * a notification or indication that a client has registered for. - */ -typedef void (*notify_callback)(int conn_id, btgatt_notify_params_t *p_data); - -/** Reports result of a GATT read operation */ -typedef void (*read_characteristic_callback)(int conn_id, int status, - btgatt_read_params_t *p_data); - -/** GATT write characteristic operation callback */ -typedef void (*write_characteristic_callback)(int conn_id, int status, - btgatt_write_params_t *p_data); - -/** GATT execute prepared write callback */ -typedef void (*execute_write_callback)(int conn_id, int status); - -/** Callback invoked in response to read_descriptor */ -typedef void (*read_descriptor_callback)(int conn_id, int status, - btgatt_read_params_t *p_data); - -/** Callback invoked in response to write_descriptor */ -typedef void (*write_descriptor_callback)(int conn_id, int status, - btgatt_write_params_t *p_data); - -/** Callback triggered in response to read_remote_rssi */ -typedef void (*read_remote_rssi_callback)(int client_if, bt_bdaddr_t* bda, - int rssi, int status); - -/** - * Callback indicating the status of a listen() operation - */ -typedef void (*listen_callback)(int status, int server_if); - -/** Callback invoked when the MTU for a given connection changes */ -typedef void (*configure_mtu_callback)(int conn_id, int status, int mtu); - -/** Callback invoked when a scan filter configuration command has completed */ -typedef void (*scan_filter_cfg_callback)(int action, int client_if, int status, int filt_type, - int avbl_space); - -/** Callback invoked when scan param has been added, cleared, or deleted */ -typedef void (*scan_filter_param_callback)(int action, int client_if, int status, - int avbl_space); - -/** Callback invoked when a scan filter configuration command has completed */ -typedef void (*scan_filter_status_callback)(int enable, int client_if, int status); - -/** Callback invoked when multi-adv enable operation has completed */ -typedef void (*multi_adv_enable_callback)(int client_if, int status); - -/** Callback invoked when multi-adv param update operation has completed */ -typedef void (*multi_adv_update_callback)(int client_if, int status); - -/** Callback invoked when multi-adv instance data set operation has completed */ -typedef void (*multi_adv_data_callback)(int client_if, int status); - -/** Callback invoked when multi-adv disable operation has completed */ -typedef void (*multi_adv_disable_callback)(int client_if, int status); - -/** - * Callback notifying an application that a remote device connection is currently congested - * and cannot receive any more data. An application should avoid sending more data until - * a further callback is received indicating the congestion status has been cleared. - */ -typedef void (*congestion_callback)(int conn_id, bool congested); -/** Callback invoked when batchscan storage config operation has completed */ -typedef void (*batchscan_cfg_storage_callback)(int client_if, int status); - -/** Callback invoked when batchscan enable / disable operation has completed */ -typedef void (*batchscan_enable_disable_callback)(int action, int client_if, int status); - -/** Callback invoked when batchscan reports are obtained */ -typedef void (*batchscan_reports_callback)(int client_if, int status, int report_format, - int num_records, int data_len, uint8_t* rep_data); - -/** Callback invoked when batchscan storage threshold limit is crossed */ -typedef void (*batchscan_threshold_callback)(int client_if); - -/** Track ADV VSE callback invoked when tracked device is found or lost */ -typedef void (*track_adv_event_callback)(btgatt_track_adv_info_t *p_track_adv_info); - -/** Callback invoked when scan parameter setup has completed */ -typedef void (*scan_parameter_setup_completed_callback)(int client_if, - btgattc_error_t status); - -typedef struct { - register_client_callback register_client_cb; - scan_result_callback scan_result_cb; - connect_callback open_cb; - disconnect_callback close_cb; - search_complete_callback search_complete_cb; - search_result_callback search_result_cb; - get_characteristic_callback get_characteristic_cb; - get_descriptor_callback get_descriptor_cb; - get_included_service_callback get_included_service_cb; - register_for_notification_callback register_for_notification_cb; - notify_callback notify_cb; - read_characteristic_callback read_characteristic_cb; - write_characteristic_callback write_characteristic_cb; - read_descriptor_callback read_descriptor_cb; - write_descriptor_callback write_descriptor_cb; - execute_write_callback execute_write_cb; - read_remote_rssi_callback read_remote_rssi_cb; - listen_callback listen_cb; - configure_mtu_callback configure_mtu_cb; - scan_filter_cfg_callback scan_filter_cfg_cb; - scan_filter_param_callback scan_filter_param_cb; - scan_filter_status_callback scan_filter_status_cb; - multi_adv_enable_callback multi_adv_enable_cb; - multi_adv_update_callback multi_adv_update_cb; - multi_adv_data_callback multi_adv_data_cb; - multi_adv_disable_callback multi_adv_disable_cb; - congestion_callback congestion_cb; - batchscan_cfg_storage_callback batchscan_cfg_storage_cb; - batchscan_enable_disable_callback batchscan_enb_disable_cb; - batchscan_reports_callback batchscan_reports_cb; - batchscan_threshold_callback batchscan_threshold_cb; - track_adv_event_callback track_adv_event_cb; - scan_parameter_setup_completed_callback scan_parameter_setup_completed_cb; -} btgatt_client_callbacks_t; - -/** Represents the standard BT-GATT client interface. */ - -typedef struct { - /** Registers a GATT client application with the stack */ - bt_status_t (*register_client)( bt_uuid_t *uuid ); - - /** Unregister a client application from the stack */ - bt_status_t (*unregister_client)(int client_if ); - - /** Start or stop LE device scanning */ - bt_status_t (*scan)( bool start ); - - /** Create a connection to a remote LE or dual-mode device */ - bt_status_t (*connect)( int client_if, const bt_bdaddr_t *bd_addr, - bool is_direct, int transport ); - - /** Disconnect a remote device or cancel a pending connection */ - bt_status_t (*disconnect)( int client_if, const bt_bdaddr_t *bd_addr, - int conn_id); - - /** Start or stop advertisements to listen for incoming connections */ - bt_status_t (*listen)(int client_if, bool start); - - /** Clear the attribute cache for a given device */ - bt_status_t (*refresh)( int client_if, const bt_bdaddr_t *bd_addr ); - - /** - * Enumerate all GATT services on a connected device. - * Optionally, the results can be filtered for a given UUID. - */ - bt_status_t (*search_service)(int conn_id, bt_uuid_t *filter_uuid ); - - /** - * Enumerate included services for a given service. - * Set start_incl_srvc_id to NULL to get the first included service. - */ - bt_status_t (*get_included_service)( int conn_id, btgatt_srvc_id_t *srvc_id, - btgatt_srvc_id_t *start_incl_srvc_id); - - /** - * Enumerate characteristics for a given service. - * Set start_char_id to NULL to get the first characteristic. - */ - bt_status_t (*get_characteristic)( int conn_id, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *start_char_id); - - /** - * Enumerate descriptors for a given characteristic. - * Set start_descr_id to NULL to get the first descriptor. - */ - bt_status_t (*get_descriptor)( int conn_id, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, - btgatt_gatt_id_t *start_descr_id); - - /** Read a characteristic on a remote device */ - bt_status_t (*read_characteristic)( int conn_id, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, - int auth_req ); - - /** Write a remote characteristic */ - bt_status_t (*write_characteristic)(int conn_id, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, - int write_type, int len, int auth_req, - char* p_value); - - /** Read the descriptor for a given characteristic */ - bt_status_t (*read_descriptor)(int conn_id, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, - btgatt_gatt_id_t *descr_id, int auth_req); - - /** Write a remote descriptor for a given characteristic */ - bt_status_t (*write_descriptor)( int conn_id, - btgatt_srvc_id_t *srvc_id, btgatt_gatt_id_t *char_id, - btgatt_gatt_id_t *descr_id, int write_type, int len, - int auth_req, char* p_value); - - /** Execute a prepared write operation */ - bt_status_t (*execute_write)(int conn_id, int execute); - - /** - * Register to receive notifications or indications for a given - * characteristic - */ - bt_status_t (*register_for_notification)( int client_if, - const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, - btgatt_gatt_id_t *char_id); - - /** Deregister a previous request for notifications/indications */ - bt_status_t (*deregister_for_notification)( int client_if, - const bt_bdaddr_t *bd_addr, btgatt_srvc_id_t *srvc_id, - btgatt_gatt_id_t *char_id); - - /** Request RSSI for a given remote device */ - bt_status_t (*read_remote_rssi)( int client_if, const bt_bdaddr_t *bd_addr); - - /** Setup scan filter params */ - bt_status_t (*scan_filter_param_setup)(btgatt_filt_param_setup_t filt_param); - - - /** Configure a scan filter condition */ - bt_status_t (*scan_filter_add_remove)(int client_if, int action, int filt_type, - int filt_index, int company_id, - int company_id_mask, const bt_uuid_t *p_uuid, - const bt_uuid_t *p_uuid_mask, const bt_bdaddr_t *bd_addr, - char addr_type, int data_len, char* p_data, int mask_len, - char* p_mask); - - /** Clear all scan filter conditions for specific filter index*/ - bt_status_t (*scan_filter_clear)(int client_if, int filt_index); - - /** Enable / disable scan filter feature*/ - bt_status_t (*scan_filter_enable)(int client_if, bool enable); - - /** Determine the type of the remote device (LE, BR/EDR, Dual-mode) */ - int (*get_device_type)( const bt_bdaddr_t *bd_addr ); - - /** Set the advertising data or scan response data */ - bt_status_t (*set_adv_data)(int client_if, bool set_scan_rsp, bool include_name, - bool include_txpower, int min_interval, int max_interval, int appearance, - uint16_t manufacturer_len, char* manufacturer_data, - uint16_t service_data_len, char* service_data, - uint16_t service_uuid_len, char* service_uuid); - - /** Configure the MTU for a given connection */ - bt_status_t (*configure_mtu)(int conn_id, int mtu); - - /** Request a connection parameter update */ - bt_status_t (*conn_parameter_update)(const bt_bdaddr_t *bd_addr, int min_interval, - int max_interval, int latency, int timeout); - - /** Sets the LE scan interval and window in units of N*0.625 msec */ - bt_status_t (*set_scan_parameters)(int client_if, int scan_interval, int scan_window); - - /* Setup the parameters as per spec, user manual specified values and enable multi ADV */ - bt_status_t (*multi_adv_enable)(int client_if, int min_interval,int max_interval,int adv_type, - int chnl_map, int tx_power, int timeout_s); - - /* Update the parameters as per spec, user manual specified values and restart multi ADV */ - bt_status_t (*multi_adv_update)(int client_if, int min_interval,int max_interval,int adv_type, - int chnl_map, int tx_power, int timeout_s); - - /* Setup the data for the specified instance */ - bt_status_t (*multi_adv_set_inst_data)(int client_if, bool set_scan_rsp, bool include_name, - bool incl_txpower, int appearance, int manufacturer_len, - char* manufacturer_data, int service_data_len, - char* service_data, int service_uuid_len, char* service_uuid); - - /* Disable the multi adv instance */ - bt_status_t (*multi_adv_disable)(int client_if); - - /* Configure the batchscan storage */ - bt_status_t (*batchscan_cfg_storage)(int client_if, int batch_scan_full_max, - int batch_scan_trunc_max, int batch_scan_notify_threshold); - - /* Enable batchscan */ - bt_status_t (*batchscan_enb_batch_scan)(int client_if, int scan_mode, - int scan_interval, int scan_window, int addr_type, int discard_rule); - - /* Disable batchscan */ - bt_status_t (*batchscan_dis_batch_scan)(int client_if); - - /* Read out batchscan reports */ - bt_status_t (*batchscan_read_reports)(int client_if, int scan_mode); - - /** Test mode interface */ - bt_status_t (*test_command)( int command, btgatt_test_params_t* params); - -} btgatt_client_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h deleted file mode 100644 index 0d6cc1e8d..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_server.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_SERVER_H -#define ANDROID_INCLUDE_BT_GATT_SERVER_H - -#include - -#include "bt_gatt_types.h" - -__BEGIN_DECLS - -/** GATT value type used in response to remote read requests */ -typedef struct -{ - uint8_t value[BTGATT_MAX_ATTR_LEN]; - uint16_t handle; - uint16_t offset; - uint16_t len; - uint8_t auth_req; -} btgatt_value_t; - -/** GATT remote read request response type */ -typedef union -{ - btgatt_value_t attr_value; - uint16_t handle; -} btgatt_response_t; - -/** BT-GATT Server callback structure. */ - -/** Callback invoked in response to register_server */ -typedef void (*register_server_callback)(int status, int server_if, - bt_uuid_t *app_uuid); - -/** Callback indicating that a remote device has connected or been disconnected */ -typedef void (*connection_callback)(int conn_id, int server_if, int connected, - bt_bdaddr_t *bda); - -/** Callback invoked in response to create_service */ -typedef void (*service_added_callback)(int status, int server_if, - btgatt_srvc_id_t *srvc_id, int srvc_handle); - -/** Callback indicating that an included service has been added to a service */ -typedef void (*included_service_added_callback)(int status, int server_if, - int srvc_handle, int incl_srvc_handle); - -/** Callback invoked when a characteristic has been added to a service */ -typedef void (*characteristic_added_callback)(int status, int server_if, - bt_uuid_t *uuid, int srvc_handle, int char_handle); - -/** Callback invoked when a descriptor has been added to a characteristic */ -typedef void (*descriptor_added_callback)(int status, int server_if, - bt_uuid_t *uuid, int srvc_handle, int descr_handle); - -/** Callback invoked in response to start_service */ -typedef void (*service_started_callback)(int status, int server_if, - int srvc_handle); - -/** Callback invoked in response to stop_service */ -typedef void (*service_stopped_callback)(int status, int server_if, - int srvc_handle); - -/** Callback triggered when a service has been deleted */ -typedef void (*service_deleted_callback)(int status, int server_if, - int srvc_handle); - -/** - * Callback invoked when a remote device has requested to read a characteristic - * or descriptor. The application must respond by calling send_response - */ -typedef void (*request_read_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda, - int attr_handle, int offset, bool is_long); - -/** - * Callback invoked when a remote device has requested to write to a - * characteristic or descriptor. - */ -typedef void (*request_write_callback)(int conn_id, int trans_id, bt_bdaddr_t *bda, - int attr_handle, int offset, int length, - bool need_rsp, bool is_prep, uint8_t* value); - -/** Callback invoked when a previously prepared write is to be executed */ -typedef void (*request_exec_write_callback)(int conn_id, int trans_id, - bt_bdaddr_t *bda, int exec_write); - -/** - * Callback triggered in response to send_response if the remote device - * sends a confirmation. - */ -typedef void (*response_confirmation_callback)(int status, int handle); - -/** - * Callback confirming that a notification or indication has been sent - * to a remote device. - */ -typedef void (*indication_sent_callback)(int conn_id, int status); - -/** - * Callback notifying an application that a remote device connection is currently congested - * and cannot receive any more data. An application should avoid sending more data until - * a further callback is received indicating the congestion status has been cleared. - */ -typedef void (*congestion_callback)(int conn_id, bool congested); - -/** Callback invoked when the MTU for a given connection changes */ -typedef void (*mtu_changed_callback)(int conn_id, int mtu); - -typedef struct { - register_server_callback register_server_cb; - connection_callback connection_cb; - service_added_callback service_added_cb; - included_service_added_callback included_service_added_cb; - characteristic_added_callback characteristic_added_cb; - descriptor_added_callback descriptor_added_cb; - service_started_callback service_started_cb; - service_stopped_callback service_stopped_cb; - service_deleted_callback service_deleted_cb; - request_read_callback request_read_cb; - request_write_callback request_write_cb; - request_exec_write_callback request_exec_write_cb; - response_confirmation_callback response_confirmation_cb; - indication_sent_callback indication_sent_cb; - congestion_callback congestion_cb; - mtu_changed_callback mtu_changed_cb; -} btgatt_server_callbacks_t; - -/** Represents the standard BT-GATT server interface. */ -typedef struct { - /** Registers a GATT server application with the stack */ - bt_status_t (*register_server)( bt_uuid_t *uuid ); - - /** Unregister a server application from the stack */ - bt_status_t (*unregister_server)(int server_if ); - - /** Create a connection to a remote peripheral */ - bt_status_t (*connect)(int server_if, const bt_bdaddr_t *bd_addr, - bool is_direct, int transport); - - /** Disconnect an established connection or cancel a pending one */ - bt_status_t (*disconnect)(int server_if, const bt_bdaddr_t *bd_addr, - int conn_id ); - - /** Create a new service */ - bt_status_t (*add_service)( int server_if, btgatt_srvc_id_t *srvc_id, int num_handles); - - /** Assign an included service to it's parent service */ - bt_status_t (*add_included_service)( int server_if, int service_handle, int included_handle); - - /** Add a characteristic to a service */ - bt_status_t (*add_characteristic)( int server_if, - int service_handle, bt_uuid_t *uuid, - int properties, int permissions); - - /** Add a descriptor to a given service */ - bt_status_t (*add_descriptor)(int server_if, int service_handle, - bt_uuid_t *uuid, int permissions); - - /** Starts a local service */ - bt_status_t (*start_service)(int server_if, int service_handle, - int transport); - - /** Stops a local service */ - bt_status_t (*stop_service)(int server_if, int service_handle); - - /** Delete a local service */ - bt_status_t (*delete_service)(int server_if, int service_handle); - - /** Send value indication to a remote device */ - bt_status_t (*send_indication)(int server_if, int attribute_handle, - int conn_id, int len, int confirm, - char* p_value); - - /** Send a response to a read/write operation */ - bt_status_t (*send_response)(int conn_id, int trans_id, - int status, btgatt_response_t *response); - -} btgatt_server_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_CLIENT_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h b/third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h deleted file mode 100644 index e037ddcdb..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_gatt_types.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - - -#ifndef ANDROID_INCLUDE_BT_GATT_TYPES_H -#define ANDROID_INCLUDE_BT_GATT_TYPES_H - -#include -#include - -__BEGIN_DECLS - -/** - * GATT Service types - */ -#define BTGATT_SERVICE_TYPE_PRIMARY 0 -#define BTGATT_SERVICE_TYPE_SECONDARY 1 - -/** GATT ID adding instance id tracking to the UUID */ -typedef struct -{ - bt_uuid_t uuid; - uint8_t inst_id; -} btgatt_gatt_id_t; - -/** GATT Service ID also identifies the service type (primary/secondary) */ -typedef struct -{ - btgatt_gatt_id_t id; - uint8_t is_primary; -} btgatt_srvc_id_t; - -/** Preferred physical Transport for GATT connection */ -typedef enum -{ - GATT_TRANSPORT_AUTO, - GATT_TRANSPORT_BREDR, - GATT_TRANSPORT_LE -} btgatt_transport_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_GATT_TYPES_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hd.h b/third_party/android_hardware_libhardware/include/hardware/bt_hd.h deleted file mode 100644 index 6ba5b097d..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hd.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2013, The Linux Foundation. All rights reserved. - * Not a Contribution - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BT_HD_H -#define ANDROID_INCLUDE_BT_HD_H - -#include - -__BEGIN_DECLS - -typedef enum -{ - BTHD_REPORT_TYPE_OTHER = 0, - BTHD_REPORT_TYPE_INPUT, - BTHD_REPORT_TYPE_OUTPUT, - BTHD_REPORT_TYPE_FEATURE, - BTHD_REPORT_TYPE_INTRDATA // special value for reports to be sent on INTR (INPUT is assumed) -} bthd_report_type_t; - -typedef enum -{ - BTHD_APP_STATE_NOT_REGISTERED, - BTHD_APP_STATE_REGISTERED -} bthd_application_state_t; - -typedef enum -{ - BTHD_CONN_STATE_CONNECTED, - BTHD_CONN_STATE_CONNECTING, - BTHD_CONN_STATE_DISCONNECTED, - BTHD_CONN_STATE_DISCONNECTING, - BTHD_CONN_STATE_UNKNOWN -} bthd_connection_state_t; - -typedef struct -{ - const char *name; - const char *description; - const char *provider; - uint8_t subclass; - uint8_t *desc_list; - int desc_list_len; -} bthd_app_param_t; - -typedef struct -{ - uint8_t service_type; - uint32_t token_rate; - uint32_t token_bucket_size; - uint32_t peak_bandwidth; - uint32_t access_latency; - uint32_t delay_variation; -} bthd_qos_param_t; - -typedef void (* bthd_application_state_callback)(bt_bdaddr_t *bd_addr, bthd_application_state_t state); -typedef void (* bthd_connection_state_callback)(bt_bdaddr_t *bd_addr, bthd_connection_state_t state); -typedef void (* bthd_get_report_callback)(uint8_t type, uint8_t id, uint16_t buffer_size); -typedef void (* bthd_set_report_callback)(uint8_t type, uint8_t id, uint16_t len, uint8_t *p_data); -typedef void (* bthd_set_protocol_callback)(uint8_t protocol); -typedef void (* bthd_intr_data_callback)(uint8_t report_id, uint16_t len, uint8_t *p_data); -typedef void (* bthd_vc_unplug_callback)(void); - -/** BT-HD callbacks */ -typedef struct { - size_t size; - - bthd_application_state_callback application_state_cb; - bthd_connection_state_callback connection_state_cb; - bthd_get_report_callback get_report_cb; - bthd_set_report_callback set_report_cb; - bthd_set_protocol_callback set_protocol_cb; - bthd_intr_data_callback intr_data_cb; - bthd_vc_unplug_callback vc_unplug_cb; -} bthd_callbacks_t; - -/** BT-HD interface */ -typedef struct { - - size_t size; - - /** init interface and register callbacks */ - bt_status_t (*init)(bthd_callbacks_t* callbacks); - - /** close interface */ - void (*cleanup)(void); - - /** register application */ - bt_status_t (*register_app)(bthd_app_param_t *app_param, bthd_qos_param_t *in_qos, - bthd_qos_param_t *out_qos); - - /** unregister application */ - bt_status_t (*unregister_app)(void); - - /** connects to host with virtual cable */ - bt_status_t (*connect)(void); - - /** disconnects from currently connected host */ - bt_status_t (*disconnect)(void); - - /** send report */ - bt_status_t (*send_report)(bthd_report_type_t type, uint8_t id, uint16_t len, uint8_t *p_data); - - /** notifies error for invalid SET_REPORT */ - bt_status_t (*report_error)(uint8_t error); - - /** send Virtual Cable Unplug */ - bt_status_t (*virtual_cable_unplug)(void); - -} bthd_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HD_H */ - diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hf.h b/third_party/android_hardware_libhardware/include/hardware/bt_hf.h deleted file mode 100644 index dbac06130..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hf.h +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BT_HF_H -#define ANDROID_INCLUDE_BT_HF_H - -__BEGIN_DECLS - -/* AT response code - OK/Error */ -typedef enum { - BTHF_AT_RESPONSE_ERROR = 0, - BTHF_AT_RESPONSE_OK -} bthf_at_response_t; - -typedef enum { - BTHF_CONNECTION_STATE_DISCONNECTED = 0, - BTHF_CONNECTION_STATE_CONNECTING, - BTHF_CONNECTION_STATE_CONNECTED, - BTHF_CONNECTION_STATE_SLC_CONNECTED, - BTHF_CONNECTION_STATE_DISCONNECTING -} bthf_connection_state_t; - -typedef enum { - BTHF_AUDIO_STATE_DISCONNECTED = 0, - BTHF_AUDIO_STATE_CONNECTING, - BTHF_AUDIO_STATE_CONNECTED, - BTHF_AUDIO_STATE_DISCONNECTING -} bthf_audio_state_t; - -typedef enum { - BTHF_VR_STATE_STOPPED = 0, - BTHF_VR_STATE_STARTED -} bthf_vr_state_t; - -typedef enum { - BTHF_VOLUME_TYPE_SPK = 0, - BTHF_VOLUME_TYPE_MIC -} bthf_volume_type_t; - -/* Noise Reduction and Echo Cancellation */ -typedef enum -{ - BTHF_NREC_STOP, - BTHF_NREC_START -} bthf_nrec_t; - -/* WBS codec setting */ -typedef enum -{ - BTHF_WBS_NONE, - BTHF_WBS_NO, - BTHF_WBS_YES -}bthf_wbs_config_t; - -/* BIND type*/ -typedef enum -{ - BTHF_BIND_SET, - BTHF_BIND_READ, - BTHF_BIND_TEST -}bthf_bind_type_t; - - -/* CHLD - Call held handling */ -typedef enum -{ - BTHF_CHLD_TYPE_RELEASEHELD, // Terminate all held or set UDUB("busy") to a waiting call - BTHF_CHLD_TYPE_RELEASEACTIVE_ACCEPTHELD, // Terminate all active calls and accepts a waiting/held call - BTHF_CHLD_TYPE_HOLDACTIVE_ACCEPTHELD, // Hold all active calls and accepts a waiting/held call - BTHF_CHLD_TYPE_ADDHELDTOCONF, // Add all held calls to a conference -} bthf_chld_type_t; - -/** Callback for connection state change. - * state will have one of the values from BtHfConnectionState - */ -typedef void (* bthf_connection_state_callback)(bthf_connection_state_t state, bt_bdaddr_t *bd_addr); - -/** Callback for audio connection state change. - * state will have one of the values from BtHfAudioState - */ -typedef void (* bthf_audio_state_callback)(bthf_audio_state_t state, bt_bdaddr_t *bd_addr); - -/** Callback for VR connection state change. - * state will have one of the values from BtHfVRState - */ -typedef void (* bthf_vr_cmd_callback)(bthf_vr_state_t state, bt_bdaddr_t *bd_addr); - -/** Callback for answer incoming call (ATA) - */ -typedef void (* bthf_answer_call_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for disconnect call (AT+CHUP) - */ -typedef void (* bthf_hangup_call_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for disconnect call (AT+CHUP) - * type will denote Speaker/Mic gain (BtHfVolumeControl). - */ -typedef void (* bthf_volume_cmd_callback)(bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr); - -/** Callback for dialing an outgoing call - * If number is NULL, redial - */ -typedef void (* bthf_dial_call_cmd_callback)(char *number, bt_bdaddr_t *bd_addr); - -/** Callback for sending DTMF tones - * tone contains the dtmf character to be sent - */ -typedef void (* bthf_dtmf_cmd_callback)(char tone, bt_bdaddr_t *bd_addr); - -/** Callback for enabling/disabling noise reduction/echo cancellation - * value will be 1 to enable, 0 to disable - */ -typedef void (* bthf_nrec_cmd_callback)(bthf_nrec_t nrec, bt_bdaddr_t *bd_addr); - -/** Callback for AT+BCS and event from BAC - * WBS enable, WBS disable - */ -typedef void (* bthf_wbs_callback)(bthf_wbs_config_t wbs, bt_bdaddr_t *bd_addr); - -/** Callback for call hold handling (AT+CHLD) - * value will contain the call hold command (0, 1, 2, 3) - */ -typedef void (* bthf_chld_cmd_callback)(bthf_chld_type_t chld, bt_bdaddr_t *bd_addr); - -/** Callback for CNUM (subscriber number) - */ -typedef void (* bthf_cnum_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for indicators (CIND) - */ -typedef void (* bthf_cind_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for operator selection (COPS) - */ -typedef void (* bthf_cops_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for call list (AT+CLCC) - */ -typedef void (* bthf_clcc_cmd_callback) (bt_bdaddr_t *bd_addr); - -/** Callback for unknown AT command recd from HF - * at_string will contain the unparsed AT string - */ -typedef void (* bthf_unknown_at_cmd_callback)(char *at_string, bt_bdaddr_t *bd_addr); - -/** Callback for keypressed (HSP) event. - */ -typedef void (* bthf_key_pressed_cmd_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for HF indicators (BIND) - */ -typedef void (* bthf_bind_cmd_callback)(char* hf_ind, bthf_bind_type_t type, bt_bdaddr_t *bd_addr); - -/** Callback for HF indicator value (BIEV) - */ -typedef void (* bthf_biev_cmd_callback)(char* hf_ind_val, bt_bdaddr_t *bd_addr); - - -/** BT-HF callback structure. */ -typedef struct { - /** set to sizeof(BtHfCallbacks) */ - size_t size; - bthf_connection_state_callback connection_state_cb; - bthf_audio_state_callback audio_state_cb; - bthf_vr_cmd_callback vr_cmd_cb; - bthf_answer_call_cmd_callback answer_call_cmd_cb; - bthf_hangup_call_cmd_callback hangup_call_cmd_cb; - bthf_volume_cmd_callback volume_cmd_cb; - bthf_dial_call_cmd_callback dial_call_cmd_cb; - bthf_dtmf_cmd_callback dtmf_cmd_cb; - bthf_nrec_cmd_callback nrec_cmd_cb; - bthf_wbs_callback wbs_cb; - bthf_chld_cmd_callback chld_cmd_cb; - bthf_cnum_cmd_callback cnum_cmd_cb; - bthf_cind_cmd_callback cind_cmd_cb; - bthf_cops_cmd_callback cops_cmd_cb; - bthf_clcc_cmd_callback clcc_cmd_cb; - bthf_unknown_at_cmd_callback unknown_at_cmd_cb; - bthf_key_pressed_cmd_callback key_pressed_cmd_cb; - bthf_bind_cmd_callback bind_cmd_cb; - bthf_biev_cmd_callback biev_cmd_cb; -} bthf_callbacks_t; - -/** Network Status */ -typedef enum -{ - BTHF_NETWORK_STATE_NOT_AVAILABLE = 0, - BTHF_NETWORK_STATE_AVAILABLE -} bthf_network_state_t; - -/** Service type */ -typedef enum -{ - BTHF_SERVICE_TYPE_HOME = 0, - BTHF_SERVICE_TYPE_ROAMING -} bthf_service_type_t; - -typedef enum { - BTHF_CALL_STATE_ACTIVE = 0, - BTHF_CALL_STATE_HELD, - BTHF_CALL_STATE_DIALING, - BTHF_CALL_STATE_ALERTING, - BTHF_CALL_STATE_INCOMING, - BTHF_CALL_STATE_WAITING, - BTHF_CALL_STATE_IDLE -} bthf_call_state_t; - -typedef enum { - BTHF_CALL_DIRECTION_OUTGOING = 0, - BTHF_CALL_DIRECTION_INCOMING -} bthf_call_direction_t; - -typedef enum { - BTHF_CALL_TYPE_VOICE = 0, - BTHF_CALL_TYPE_DATA, - BTHF_CALL_TYPE_FAX -} bthf_call_mode_t; - -typedef enum { - BTHF_CALL_MPTY_TYPE_SINGLE = 0, - BTHF_CALL_MPTY_TYPE_MULTI -} bthf_call_mpty_type_t; - -typedef enum { - BTHF_HF_INDICATOR_STATE_DISABLED = 0, - BTHF_HF_INDICATOR_STATE_ENABLED -} bthf_hf_indicator_status_t; - -typedef enum { - BTHF_CALL_ADDRTYPE_UNKNOWN = 0x81, - BTHF_CALL_ADDRTYPE_INTERNATIONAL = 0x91 -} bthf_call_addrtype_t; - -typedef enum { - BTHF_VOIP_CALL_NETWORK_TYPE_MOBILE = 0, - BTHF_VOIP_CALL_NETWORK_TYPE_WIFI -} bthf_voip_call_network_type_t; - -typedef enum { - BTHF_VOIP_STATE_STOPPED = 0, - BTHF_VOIP_STATE_STARTED -} bthf_voip_state_t; - -/** Represents the standard BT-HF interface. */ -typedef struct { - - /** set to sizeof(BtHfInterface) */ - size_t size; - /** - * Register the BtHf callbacks - */ - bt_status_t (*init)( bthf_callbacks_t* callbacks, int max_hf_clients); - - /** connect to headset */ - bt_status_t (*connect)( bt_bdaddr_t *bd_addr ); - - /** dis-connect from headset */ - bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); - - /** create an audio connection */ - bt_status_t (*connect_audio)( bt_bdaddr_t *bd_addr ); - - /** close the audio connection */ - bt_status_t (*disconnect_audio)( bt_bdaddr_t *bd_addr ); - - /** start voice recognition */ - bt_status_t (*start_voice_recognition)( bt_bdaddr_t *bd_addr ); - - /** stop voice recognition */ - bt_status_t (*stop_voice_recognition)( bt_bdaddr_t *bd_addr ); - - /** volume control */ - bt_status_t (*volume_control) (bthf_volume_type_t type, int volume, bt_bdaddr_t *bd_addr ); - - /** Combined device status change notification */ - bt_status_t (*device_status_notification)(bthf_network_state_t ntk_state, bthf_service_type_t svc_type, int signal, - int batt_chg); - - /** Response for COPS command */ - bt_status_t (*cops_response)(const char *cops, bt_bdaddr_t *bd_addr ); - - /** Response for CIND command */ - bt_status_t (*cind_response)(int svc, int num_active, int num_held, bthf_call_state_t call_setup_state, - int signal, int roam, int batt_chg, bt_bdaddr_t *bd_addr ); - - /** Pre-formatted AT response, typically in response to unknown AT cmd */ - bt_status_t (*formatted_at_response)(const char *rsp, bt_bdaddr_t *bd_addr ); - - /** ok/error response - * ERROR (0) - * OK (1) - */ - bt_status_t (*at_response) (bthf_at_response_t response_code, int error_code, bt_bdaddr_t *bd_addr ); - - /** response for CLCC command - * Can be iteratively called for each call index - * Call index of 0 will be treated as NULL termination (Completes response) - */ - bt_status_t (*clcc_response) (int index, bthf_call_direction_t dir, - bthf_call_state_t state, bthf_call_mode_t mode, - bthf_call_mpty_type_t mpty, const char *number, - bthf_call_addrtype_t type, bt_bdaddr_t *bd_addr ); - - /** notify of a call state change - * Each update notifies - * 1. Number of active/held/ringing calls - * 2. call_state: This denotes the state change that triggered this msg - * This will take one of the values from BtHfCallState - * 3. number & type: valid only for incoming & waiting call - */ - bt_status_t (*phone_state_change) (int num_active, int num_held, bthf_call_state_t call_setup_state, - const char *number, bthf_call_addrtype_t type); - - /** Closes the interface. */ - void (*cleanup)( void ); - - /** configureation for the SCO codec */ - bt_status_t (*configure_wbs)( bt_bdaddr_t *bd_addr ,bthf_wbs_config_t config ); - - /** Response for BIND READ command and activation/deactivation of HF indicator */ - bt_status_t (*bind_response) (int anum, bthf_hf_indicator_status_t status, - bt_bdaddr_t *bd_addr); - - /** Response for BIND TEST command */ - bt_status_t (*bind_string_response) (const char* result, bt_bdaddr_t *bd_addr); - - /** Sends connectivity network type used by Voip currently to stack */ - bt_status_t (*voip_network_type_wifi) (bthf_voip_state_t is_voip_started, - bthf_voip_call_network_type_t is_network_wifi); -} bthf_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HF_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h b/third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h deleted file mode 100644 index 0577e97d4..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hf_client.h +++ /dev/null @@ -1,375 +0,0 @@ -/* - * Copyright (C) 2012-2014 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. - */ - -#ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H -#define ANDROID_INCLUDE_BT_HF_CLIENT_H - -__BEGIN_DECLS - -typedef enum { - BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0, - BTHF_CLIENT_CONNECTION_STATE_CONNECTING, - BTHF_CLIENT_CONNECTION_STATE_CONNECTED, - BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED, - BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING -} bthf_client_connection_state_t; - -typedef enum { - BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0, - BTHF_CLIENT_AUDIO_STATE_CONNECTING, - BTHF_CLIENT_AUDIO_STATE_CONNECTED, - BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC, -} bthf_client_audio_state_t; - -typedef enum { - BTHF_CLIENT_VR_STATE_STOPPED = 0, - BTHF_CLIENT_VR_STATE_STARTED -} bthf_client_vr_state_t; - -typedef enum { - BTHF_CLIENT_VOLUME_TYPE_SPK = 0, - BTHF_CLIENT_VOLUME_TYPE_MIC -} bthf_client_volume_type_t; - -typedef enum -{ - BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0, - BTHF_CLIENT_NETWORK_STATE_AVAILABLE -} bthf_client_network_state_t; - -typedef enum -{ - BTHF_CLIENT_SERVICE_TYPE_HOME = 0, - BTHF_CLIENT_SERVICE_TYPE_ROAMING -} bthf_client_service_type_t; - -typedef enum { - BTHF_CLIENT_CALL_STATE_ACTIVE = 0, - BTHF_CLIENT_CALL_STATE_HELD, - BTHF_CLIENT_CALL_STATE_DIALING, - BTHF_CLIENT_CALL_STATE_ALERTING, - BTHF_CLIENT_CALL_STATE_INCOMING, - BTHF_CLIENT_CALL_STATE_WAITING, - BTHF_CLIENT_CALL_STATE_HELD_BY_RESP_HOLD, -} bthf_client_call_state_t; - -typedef enum { - BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0, - BTHF_CLIENT_CALL_CALLS_IN_PROGRESS -} bthf_client_call_t; - -typedef enum { - BTHF_CLIENT_CALLSETUP_NONE = 0, - BTHF_CLIENT_CALLSETUP_INCOMING, - BTHF_CLIENT_CALLSETUP_OUTGOING, - BTHF_CLIENT_CALLSETUP_ALERTING - -} bthf_client_callsetup_t; - -typedef enum { - BTHF_CLIENT_CALLHELD_NONE = 0, - BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE, - BTHF_CLIENT_CALLHELD_HOLD, -} bthf_client_callheld_t; - -typedef enum { - BTHF_CLIENT_RESP_AND_HOLD_HELD = 0, - BTRH_CLIENT_RESP_AND_HOLD_ACCEPT, - BTRH_CLIENT_RESP_AND_HOLD_REJECT, -} bthf_client_resp_and_hold_t; - -typedef enum { - BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0, - BTHF_CLIENT_CALL_DIRECTION_INCOMING -} bthf_client_call_direction_t; - -typedef enum { - BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0, - BTHF_CLIENT_CALL_MPTY_TYPE_MULTI -} bthf_client_call_mpty_type_t; - -typedef enum { - BTHF_CLIENT_CMD_COMPLETE_OK = 0, - BTHF_CLIENT_CMD_COMPLETE_ERROR, - BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_CARRIER, - BTHF_CLIENT_CMD_COMPLETE_ERROR_BUSY, - BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_ANSWER, - BTHF_CLIENT_CMD_COMPLETE_ERROR_DELAYED, - BTHF_CLIENT_CMD_COMPLETE_ERROR_BLACKLISTED, - BTHF_CLIENT_CMD_COMPLETE_ERROR_CME -} bthf_client_cmd_complete_t; - -typedef enum { - BTHF_CLIENT_CALL_ACTION_CHLD_0 = 0, - BTHF_CLIENT_CALL_ACTION_CHLD_1, - BTHF_CLIENT_CALL_ACTION_CHLD_2, - BTHF_CLIENT_CALL_ACTION_CHLD_3, - BTHF_CLIENT_CALL_ACTION_CHLD_4, - BTHF_CLIENT_CALL_ACTION_CHLD_1x, - BTHF_CLIENT_CALL_ACTION_CHLD_2x, - BTHF_CLIENT_CALL_ACTION_ATA, - BTHF_CLIENT_CALL_ACTION_CHUP, - BTHF_CLIENT_CALL_ACTION_BTRH_0, - BTHF_CLIENT_CALL_ACTION_BTRH_1, - BTHF_CLIENT_CALL_ACTION_BTRH_2, -} bthf_client_call_action_t; - -typedef enum { - BTHF_CLIENT_SERVICE_UNKNOWN = 0, - BTHF_CLIENT_SERVICE_VOICE, - BTHF_CLIENT_SERVICE_FAX -} bthf_client_subscriber_service_type_t; - -typedef enum { - BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0, - BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED, -} bthf_client_in_band_ring_state_t; - -/* Peer features masks */ -#define BTHF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */ -#define BTHF_CLIENT_PEER_FEAT_ECNR 0x00000002 /* Echo cancellation and/or noise reduction */ -#define BTHF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */ -#define BTHF_CLIENT_PEER_FEAT_INBAND 0x00000008 /* In-band ring tone */ -#define BTHF_CLIENT_PEER_FEAT_VTAG 0x00000010 /* Attach a phone number to a voice tag */ -#define BTHF_CLIENT_PEER_FEAT_REJECT 0x00000020 /* Ability to reject incoming call */ -#define BTHF_CLIENT_PEER_FEAT_ECS 0x00000040 /* Enhanced Call Status */ -#define BTHF_CLIENT_PEER_FEAT_ECC 0x00000080 /* Enhanced Call Control */ -#define BTHF_CLIENT_PEER_FEAT_EXTERR 0x00000100 /* Extended error codes */ -#define BTHF_CLIENT_PEER_FEAT_CODEC 0x00000200 /* Codec Negotiation */ - -/* Peer call handling features masks */ -#define BTHF_CLIENT_CHLD_FEAT_REL 0x00000001 /* 0 Release waiting call or held calls */ -#define BTHF_CLIENT_CHLD_FEAT_REL_ACC 0x00000002 /* 1 Release active calls and accept other - (waiting or held) cal */ -#define BTHF_CLIENT_CHLD_FEAT_REL_X 0x00000004 /* 1x Release specified active call only */ -#define BTHF_CLIENT_CHLD_FEAT_HOLD_ACC 0x00000008 /* 2 Active calls on hold and accept other - (waiting or held) call */ -#define BTHF_CLIENT_CHLD_FEAT_PRIV_X 0x00000010 /* 2x Request private mode with specified - call (put the rest on hold) */ -#define BTHF_CLIENT_CHLD_FEAT_MERGE 0x00000020 /* 3 Add held call to multiparty */ -#define BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH 0x00000040 /* 4 Connect two calls and leave - (disconnect from) multiparty */ - -/** Callback for connection state change. - * state will have one of the values from BtHfConnectionState - * peer/chld_features are valid only for BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED state - */ -typedef void (* bthf_client_connection_state_callback)(bthf_client_connection_state_t state, - unsigned int peer_feat, - unsigned int chld_feat, - bt_bdaddr_t *bd_addr); - -/** Callback for audio connection state change. - * state will have one of the values from BtHfAudioState - */ -typedef void (* bthf_client_audio_state_callback)(bthf_client_audio_state_t state, - bt_bdaddr_t *bd_addr); - -/** Callback for VR connection state change. - * state will have one of the values from BtHfVRState - */ -typedef void (* bthf_client_vr_cmd_callback)(bthf_client_vr_state_t state); - -/** Callback for network state change - */ -typedef void (* bthf_client_network_state_callback) (bthf_client_network_state_t state); - -/** Callback for network roaming status change - */ -typedef void (* bthf_client_network_roaming_callback) (bthf_client_service_type_t type); - -/** Callback for signal strength indication - */ -typedef void (* bthf_client_network_signal_callback) (int signal_strength); - -/** Callback for battery level indication - */ -typedef void (* bthf_client_battery_level_callback) (int battery_level); - -/** Callback for current operator name - */ -typedef void (* bthf_client_current_operator_callback) (const char *name); - -/** Callback for call indicator - */ -typedef void (* bthf_client_call_callback) (bthf_client_call_t call); - -/** Callback for callsetup indicator - */ -typedef void (* bthf_client_callsetup_callback) (bthf_client_callsetup_t callsetup); - -/** Callback for callheld indicator - */ -typedef void (* bthf_client_callheld_callback) (bthf_client_callheld_t callheld); - -/** Callback for response and hold - */ -typedef void (* bthf_client_resp_and_hold_callback) (bthf_client_resp_and_hold_t resp_and_hold); - -/** Callback for Calling Line Identification notification - * Will be called only when there is an incoming call and number is provided. - */ -typedef void (* bthf_client_clip_callback) (const char *number); - -/** - * Callback for Call Waiting notification - */ -typedef void (* bthf_client_call_waiting_callback) (const char *number); - -/** - * Callback for listing current calls. Can be called multiple time. - * If number is unknown NULL is passed. - */ -typedef void (*bthf_client_current_calls) (int index, bthf_client_call_direction_t dir, - bthf_client_call_state_t state, - bthf_client_call_mpty_type_t mpty, - const char *number); - -/** Callback for audio volume change - */ -typedef void (*bthf_client_volume_change_callback) (bthf_client_volume_type_t type, int volume); - -/** Callback for command complete event - * cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type - */ -typedef void (*bthf_client_cmd_complete_callback) (bthf_client_cmd_complete_t type, int cme); - -/** Callback for subscriber information - */ -typedef void (* bthf_client_subscriber_info_callback) (const char *name, - bthf_client_subscriber_service_type_t type); - -/** Callback for in-band ring tone settings - */ -typedef void (* bthf_client_in_band_ring_tone_callback) (bthf_client_in_band_ring_state_t state); - -/** - * Callback for requested number from AG - */ -typedef void (* bthf_client_last_voice_tag_number_callback) (const char *number); - -/** - * Callback for sending ring indication to app - */ -typedef void (* bthf_client_ring_indication_callback) (void); - -/** - * Callback for sending cgmi indication to app - */ -typedef void (* bthf_client_cgmi_indication_callback) (const char *str); - -/** - * Callback for sending cgmm indication to app - */ -typedef void (* bthf_client_cgmm_indication_callback) (const char *str); - -/** BT-HF callback structure. */ -typedef struct { - /** set to sizeof(BtHfClientCallbacks) */ - size_t size; - bthf_client_connection_state_callback connection_state_cb; - bthf_client_audio_state_callback audio_state_cb; - bthf_client_vr_cmd_callback vr_cmd_cb; - bthf_client_network_state_callback network_state_cb; - bthf_client_network_roaming_callback network_roaming_cb; - bthf_client_network_signal_callback network_signal_cb; - bthf_client_battery_level_callback battery_level_cb; - bthf_client_current_operator_callback current_operator_cb; - bthf_client_call_callback call_cb; - bthf_client_callsetup_callback callsetup_cb; - bthf_client_callheld_callback callheld_cb; - bthf_client_resp_and_hold_callback resp_and_hold_cb; - bthf_client_clip_callback clip_cb; - bthf_client_call_waiting_callback call_waiting_cb; - bthf_client_current_calls current_calls_cb; - bthf_client_volume_change_callback volume_change_cb; - bthf_client_cmd_complete_callback cmd_complete_cb; - bthf_client_subscriber_info_callback subscriber_info_cb; - bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb; - bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback; - bthf_client_ring_indication_callback ring_indication_cb; - bthf_client_cgmi_indication_callback cgmi_cb; - bthf_client_cgmm_indication_callback cgmm_cb; -} bthf_client_callbacks_t; - -/** Represents the standard BT-HF interface. */ -typedef struct { - - /** set to sizeof(BtHfClientInterface) */ - size_t size; - /** - * Register the BtHf callbacks - */ - bt_status_t (*init)(bthf_client_callbacks_t* callbacks); - - /** connect to audio gateway */ - bt_status_t (*connect)(bt_bdaddr_t *bd_addr); - - /** disconnect from audio gateway */ - bt_status_t (*disconnect)(bt_bdaddr_t *bd_addr); - - /** create an audio connection */ - bt_status_t (*connect_audio)(bt_bdaddr_t *bd_addr); - - /** close the audio connection */ - bt_status_t (*disconnect_audio)(bt_bdaddr_t *bd_addr); - - /** start voice recognition */ - bt_status_t (*start_voice_recognition)(void); - - /** stop voice recognition */ - bt_status_t (*stop_voice_recognition)(void); - - /** volume control */ - bt_status_t (*volume_control) (bthf_client_volume_type_t type, int volume); - - /** place a call with number a number - * if number is NULL last called number is called (aka re-dial)*/ - bt_status_t (*dial) (const char *number); - - /** place a call with number specified by location (speed dial) */ - bt_status_t (*dial_memory) (int location); - - /** perform specified call related action - * idx is limited only for enhanced call control related action - */ - bt_status_t (*handle_call_action) (bthf_client_call_action_t action, int idx); - - /** query list of current calls */ - bt_status_t (*query_current_calls) (void); - - /** query name of current selected operator */ - bt_status_t (*query_current_operator_name) (void); - - /** Retrieve subscriber information */ - bt_status_t (*retrieve_subscriber_info) (void); - - /** Send DTMF code*/ - bt_status_t (*send_dtmf) (char code); - - /** Request a phone number from AG corresponding to last voice tag recorded */ - bt_status_t (*request_last_voice_tag_number) (void); - - /** Closes the interface. */ - void (*cleanup)(void); - - /** Send AT Command. */ - bt_status_t (*send_at_cmd) (int cmd, int val1, int val2, const char *arg); -} bthf_client_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hh.h b/third_party/android_hardware_libhardware/include/hardware/bt_hh.h deleted file mode 100644 index ece3c1142..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hh.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BT_HH_H -#define ANDROID_INCLUDE_BT_HH_H - -#include - -__BEGIN_DECLS - -#define BTHH_MAX_DSC_LEN 884 - -/* HH connection states */ -typedef enum -{ - BTHH_CONN_STATE_CONNECTED = 0, - BTHH_CONN_STATE_CONNECTING, - BTHH_CONN_STATE_DISCONNECTED, - BTHH_CONN_STATE_DISCONNECTING, - BTHH_CONN_STATE_FAILED_MOUSE_FROM_HOST, - BTHH_CONN_STATE_FAILED_KBD_FROM_HOST, - BTHH_CONN_STATE_FAILED_TOO_MANY_DEVICES, - BTHH_CONN_STATE_FAILED_NO_BTHID_DRIVER, - BTHH_CONN_STATE_FAILED_GENERIC, - BTHH_CONN_STATE_UNKNOWN -} bthh_connection_state_t; - -typedef enum -{ - BTHH_OK = 0, - BTHH_HS_HID_NOT_READY, /* handshake error : device not ready */ - BTHH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */ - BTHH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */ - BTHH_HS_INVALID_PARAM, /* handshake error : invalid paremter */ - BTHH_HS_ERROR, /* handshake error : unspecified HS error */ - BTHH_ERR, /* general BTA HH error */ - BTHH_ERR_SDP, /* SDP error */ - BTHH_ERR_PROTO, /* SET_Protocol error, - only used in BTA_HH_OPEN_EVT callback */ - BTHH_ERR_DB_FULL, /* device database full error, used */ - BTHH_ERR_TOD_UNSPT, /* type of device not supported */ - BTHH_ERR_NO_RES, /* out of system resources */ - BTHH_ERR_AUTH_FAILED, /* authentication fail */ - BTHH_ERR_HDL -}bthh_status_t; - -/* Protocol modes */ -typedef enum { - BTHH_REPORT_MODE = 0x00, - BTHH_BOOT_MODE = 0x01, - BTHH_UNSUPPORTED_MODE = 0xff -}bthh_protocol_mode_t; - -/* Report types */ -typedef enum { - BTHH_INPUT_REPORT = 1, - BTHH_OUTPUT_REPORT, - BTHH_FEATURE_REPORT -}bthh_report_type_t; - -typedef struct -{ - int attr_mask; - uint8_t sub_class; - uint8_t app_id; - int vendor_id; - int product_id; - int version; - uint8_t ctry_code; - int dl_len; - uint8_t dsc_list[BTHH_MAX_DSC_LEN]; -} bthh_hid_info_t; - -/** Callback for connection state change. - * state will have one of the values from bthh_connection_state_t - */ -typedef void (* bthh_connection_state_callback)(bt_bdaddr_t *bd_addr, bthh_connection_state_t state); - -/** Callback for vitual unplug api. - * the status of the vitual unplug - */ -typedef void (* bthh_virtual_unplug_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status); - -/** Callback for get hid info - * hid_info will contain attr_mask, sub_class, app_id, vendor_id, product_id, version, ctry_code, len - */ -typedef void (* bthh_hid_info_callback)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info); - -/** Callback for get protocol api. - * the protocol mode is one of the value from bthh_protocol_mode_t - */ -typedef void (* bthh_protocol_mode_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, bthh_protocol_mode_t mode); - -/** Callback for get/set_idle_time api. - */ -typedef void (* bthh_idle_time_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, int idle_rate); - - -/** Callback for get report api. - * if staus is ok rpt_data contains the report data - */ -typedef void (* bthh_get_report_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status, uint8_t* rpt_data, int rpt_size); - -/** Callback for set_report/set_protocol api and if error - * occurs for get_report/get_protocol api. - */ -typedef void (* bthh_handshake_callback)(bt_bdaddr_t *bd_addr, bthh_status_t hh_status); - - -/** BT-HH callback structure. */ -typedef struct { - /** set to sizeof(BtHfCallbacks) */ - size_t size; - bthh_connection_state_callback connection_state_cb; - bthh_hid_info_callback hid_info_cb; - bthh_protocol_mode_callback protocol_mode_cb; - bthh_idle_time_callback idle_time_cb; - bthh_get_report_callback get_report_cb; - bthh_virtual_unplug_callback virtual_unplug_cb; - bthh_handshake_callback handshake_cb; - -} bthh_callbacks_t; - - - -/** Represents the standard BT-HH interface. */ -typedef struct { - - /** set to sizeof(BtHhInterface) */ - size_t size; - - /** - * Register the BtHh callbacks - */ - bt_status_t (*init)( bthh_callbacks_t* callbacks ); - - /** connect to hid device */ - bt_status_t (*connect)( bt_bdaddr_t *bd_addr); - - /** dis-connect from hid device */ - bt_status_t (*disconnect)( bt_bdaddr_t *bd_addr ); - - /** Virtual UnPlug (VUP) the specified HID device */ - bt_status_t (*virtual_unplug)(bt_bdaddr_t *bd_addr); - - /** Set the HID device descriptor for the specified HID device. */ - bt_status_t (*set_info)(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid_info ); - - /** Get the HID proto mode. */ - bt_status_t (*get_protocol) (bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode); - - /** Set the HID proto mode. */ - bt_status_t (*set_protocol)(bt_bdaddr_t *bd_addr, bthh_protocol_mode_t protocolMode); - - /** Get the HID Idle Time */ - bt_status_t (*get_idle_time)(bt_bdaddr_t *bd_addr); - - /** Set the HID Idle Time */ - bt_status_t (*set_idle_time)(bt_bdaddr_t *bd_addr, uint8_t idleTime); - - /** Send a GET_REPORT to HID device. */ - bt_status_t (*get_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, uint8_t reportId, int bufferSize); - - /** Send a SET_REPORT to HID device. */ - bt_status_t (*set_report)(bt_bdaddr_t *bd_addr, bthh_report_type_t reportType, char* report); - - /** Send data to HID device. */ - bt_status_t (*send_data)(bt_bdaddr_t *bd_addr, char* data); - - /** Closes the interface. */ - void (*cleanup)( void ); - -} bthh_interface_t; -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HH_H */ - - diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_hl.h b/third_party/android_hardware_libhardware/include/hardware/bt_hl.h deleted file mode 100644 index bd29e3abf..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_hl.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BT_HL_H -#define ANDROID_INCLUDE_BT_HL_H - -__BEGIN_DECLS - -/* HL connection states */ - -typedef enum -{ - BTHL_MDEP_ROLE_SOURCE, - BTHL_MDEP_ROLE_SINK -} bthl_mdep_role_t; - -typedef enum { - BTHL_APP_REG_STATE_REG_SUCCESS, - BTHL_APP_REG_STATE_REG_FAILED, - BTHL_APP_REG_STATE_DEREG_SUCCESS, - BTHL_APP_REG_STATE_DEREG_FAILED -} bthl_app_reg_state_t; - -typedef enum -{ - BTHL_CHANNEL_TYPE_RELIABLE, - BTHL_CHANNEL_TYPE_STREAMING, - BTHL_CHANNEL_TYPE_ANY -} bthl_channel_type_t; - - -/* HL connection states */ -typedef enum { - BTHL_CONN_STATE_CONNECTING, - BTHL_CONN_STATE_CONNECTED, - BTHL_CONN_STATE_DISCONNECTING, - BTHL_CONN_STATE_DISCONNECTED, - BTHL_CONN_STATE_DESTROYED -} bthl_channel_state_t; - -typedef struct -{ - bthl_mdep_role_t mdep_role; - int data_type; - bthl_channel_type_t channel_type; - const char *mdep_description; /* MDEP description to be used in the SDP (optional); null terminated */ -} bthl_mdep_cfg_t; - -typedef struct -{ - const char *application_name; - const char *provider_name; /* provider name to be used in the SDP (optional); null terminated */ - const char *srv_name; /* service name to be used in the SDP (optional); null terminated*/ - const char *srv_desp; /* service description to be used in the SDP (optional); null terminated */ - int number_of_mdeps; - bthl_mdep_cfg_t *mdep_cfg; /* Dynamic array */ -} bthl_reg_param_t; - -/** Callback for application registration status. - * state will have one of the values from bthl_app_reg_state_t - */ -typedef void (* bthl_app_reg_state_callback)(int app_id, bthl_app_reg_state_t state); - -/** Callback for channel connection state change. - * state will have one of the values from - * bthl_connection_state_t and fd (file descriptor) - */ -typedef void (* bthl_channel_state_callback)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int channel_id, bthl_channel_state_t state, int fd); - -/** BT-HL callback structure. */ -typedef struct { - /** set to sizeof(bthl_callbacks_t) */ - size_t size; - bthl_app_reg_state_callback app_reg_state_cb; - bthl_channel_state_callback channel_state_cb; -} bthl_callbacks_t; - - -/** Represents the standard BT-HL interface. */ -typedef struct { - - /** set to sizeof(bthl_interface_t) */ - size_t size; - - /** - * Register the Bthl callbacks - */ - bt_status_t (*init)( bthl_callbacks_t* callbacks ); - - /** Register HL application */ - bt_status_t (*register_application) ( bthl_reg_param_t *p_reg_param, int *app_id); - - /** Unregister HL application */ - bt_status_t (*unregister_application) (int app_id); - - /** connect channel */ - bt_status_t (*connect_channel)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int *channel_id); - - /** destroy channel */ - bt_status_t (*destroy_channel)(int channel_id); - - /** Close the Bthl callback **/ - void (*cleanup)(void); - -} bthl_interface_t; -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_HL_H */ - - diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_mce.h b/third_party/android_hardware_libhardware/include/hardware/bt_mce.h deleted file mode 100644 index 5d159b336..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_mce.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#ifndef ANDROID_INCLUDE_BT_MCE_H -#define ANDROID_INCLUDE_BT_MCE_H - -__BEGIN_DECLS - -/** MAS instance description */ -typedef struct -{ - int id; - int scn; - int msg_types; - char *p_name; -} btmce_mas_instance_t; - -/** callback for get_remote_mas_instances */ -typedef void (*btmce_remote_mas_instances_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, - int num_instances, btmce_mas_instance_t *instances); - -typedef struct { - /** set to sizeof(btmce_callbacks_t) */ - size_t size; - btmce_remote_mas_instances_callback remote_mas_instances_cb; -} btmce_callbacks_t; - -typedef struct { - /** set to size of this struct */ - size_t size; - - /** register BT MCE callbacks */ - bt_status_t (*init)(btmce_callbacks_t *callbacks); - - /** search for MAS instances on remote device */ - bt_status_t (*get_remote_mas_instances)(bt_bdaddr_t *bd_addr); -} btmce_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_MCE_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_pan.h b/third_party/android_hardware_libhardware/include/hardware/bt_pan.h deleted file mode 100644 index 83e7949b2..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_pan.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BT_PAN_H -#define ANDROID_INCLUDE_BT_PAN_H - -__BEGIN_DECLS - -#define BTPAN_ROLE_NONE 0 -#define BTPAN_ROLE_PANNAP 1 -#define BTPAN_ROLE_PANU 2 - -typedef enum { - BTPAN_STATE_CONNECTED = 0, - BTPAN_STATE_CONNECTING = 1, - BTPAN_STATE_DISCONNECTED = 2, - BTPAN_STATE_DISCONNECTING = 3 -} btpan_connection_state_t; - -typedef enum { - BTPAN_STATE_ENABLED = 0, - BTPAN_STATE_DISABLED = 1 -} btpan_control_state_t; - -/** -* Callback for pan connection state -*/ -typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state, bt_status_t error, - const bt_bdaddr_t *bd_addr, int local_role, int remote_role); -typedef void (*btpan_control_state_callback)(btpan_control_state_t state, int local_role, - bt_status_t error, const char* ifname); - -typedef struct { - size_t size; - btpan_control_state_callback control_state_cb; - btpan_connection_state_callback connection_state_cb; -} btpan_callbacks_t; -typedef struct { - /** set to size of this struct*/ - size_t size; - /** - * Initialize the pan interface and register the btpan callbacks - */ - bt_status_t (*init)(const btpan_callbacks_t* callbacks); - /* - * enable the pan service by specified role. The result state of - * enabl will be returned by btpan_control_state_callback. when pan-nap is enabled, - * the state of connecting panu device will be notified by btpan_connection_state_callback - */ - bt_status_t (*enable)(int local_role); - /* - * get current pan local role - */ - int (*get_local_role)(void); - /** - * start bluetooth pan connection to the remote device by specified pan role. The result state will be - * returned by btpan_connection_state_callback - */ - bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, int local_role, int remote_role); - /** - * stop bluetooth pan connection. The result state will be returned by btpan_connection_state_callback - */ - bt_status_t (*disconnect)(const bt_bdaddr_t *bd_addr); - - /** - * Cleanup the pan interface - */ - void (*cleanup)(void); - -} btpan_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_PAN_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_rc.h b/third_party/android_hardware_libhardware/include/hardware/bt_rc.h deleted file mode 100644 index 6e1109d38..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_rc.h +++ /dev/null @@ -1,527 +0,0 @@ -/* - * Copyright (C) 2013-2014, The Linux Foundation. All rights reserved. - * Not a Contribution. - * - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_BT_RC_H -#define ANDROID_INCLUDE_BT_RC_H - -__BEGIN_DECLS - -/* Macros */ -#define BTRC_MAX_ATTR_STR_LEN 255 -#define BTRC_UID_SIZE 8 -#define BTRC_MAX_APP_SETTINGS 8 -#define BTRC_MAX_FOLDER_DEPTH 4 -#define BTRC_MAX_APP_ATTR_SIZE 16 -#define BTRC_MAX_ELEM_ATTR_SIZE 7 -#define BTRC_CHARSET_UTF8 0x006A - -typedef uint8_t btrc_uid_t[BTRC_UID_SIZE]; - -typedef enum { - BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */ - BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */ - BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */ - BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */ -} btrc_remote_features_t; - -typedef enum { - BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */ - BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */ - BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */ - BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/ - BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/ - BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */ -} btrc_play_status_t; - -typedef enum { - BTRC_EVT_PLAY_STATUS_CHANGED = 0x01, - BTRC_EVT_TRACK_CHANGE = 0x02, - BTRC_EVT_TRACK_REACHED_END = 0x03, - BTRC_EVT_TRACK_REACHED_START = 0x04, - BTRC_EVT_PLAY_POS_CHANGED = 0x05, - BTRC_EVT_APP_SETTINGS_CHANGED = 0x08, - BTRC_EVT_NOW_PLAYING_CONTENT_CHANGED = 0x09, - BTRC_EVT_AVAILABLE_PLAYERS_CHANGED = 0x0a, - BTRC_EVT_ADDRESSED_PLAYER_CHANGED = 0x0b, -} btrc_event_id_t; - -//used for Scope -typedef enum { - BTRC_EVT_MEDIA_PLAYLIST = 0, - BTRC_EVT_MEDIA_VIRTUALFILESYST = 1, - BTRC_EVT_SEARCH = 2, - BTRC_EVT_NOWPLAYING = 3, - BTRC_EVT_MAX_BROWSE = 4, -} btrc_browse_folderitem_t; - -typedef enum { - BTRC_NOTIFICATION_TYPE_INTERIM = 0, - BTRC_NOTIFICATION_TYPE_CHANGED = 1, - BTRC_NOTIFICATION_TYPE_REJECT = 2, -} btrc_notification_type_t; - -typedef enum { - BTRC_PLAYER_ATTR_EQUALIZER = 0x01, - BTRC_PLAYER_ATTR_REPEAT = 0x02, - BTRC_PLAYER_ATTR_SHUFFLE = 0x03, - BTRC_PLAYER_ATTR_SCAN = 0x04, -} btrc_player_attr_t; - -typedef enum { - BTRC_MEDIA_ATTR_TITLE = 0x01, - BTRC_MEDIA_ATTR_ARTIST = 0x02, - BTRC_MEDIA_ATTR_ALBUM = 0x03, - BTRC_MEDIA_ATTR_TRACK_NUM = 0x04, - BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05, - BTRC_MEDIA_ATTR_GENRE = 0x06, - BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07, -} btrc_media_attr_t; - -typedef enum { - BTRC_PLAYER_VAL_OFF_REPEAT = 0x01, - BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02, - BTRC_PLAYER_VAL_ALL_REPEAT = 0x03, - BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04 -} btrc_player_repeat_val_t; - -typedef enum { - BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01, - BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02, - BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03 -} btrc_player_shuffle_val_t; - -typedef enum { - BTRC_STS_BAD_CMD = 0x00, /* Invalid command */ - BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */ - BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */ - BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */ - BTRC_STS_NO_ERROR = 0x04 /* Operation Success */ -} btrc_status_t; - -typedef enum { - BTRC_TYPE_MEDIA_PLAYER = 0x01, - BTRC_TYPE_FOLDER = 0x02, - BTRC_TYPE_MEDIA_ELEMENT = 0x03 -} btrc_folder_list_item_type_t; - -typedef struct { - uint8_t num_attr; - uint8_t attr_ids[BTRC_MAX_APP_SETTINGS]; - uint8_t attr_values[BTRC_MAX_APP_SETTINGS]; -} btrc_player_settings_t; - -typedef struct { - uint32_t start_item; - uint32_t end_item; - uint32_t size; - uint32_t attrs[BTRC_MAX_ELEM_ATTR_SIZE]; - uint8_t attr_count; -}btrc_getfolderitem_t; - -typedef union -{ - btrc_play_status_t play_status; - btrc_uid_t track; /* queue position in NowPlaying */ - uint32_t song_pos; - btrc_player_settings_t player_setting; - uint16_t player_id; -} btrc_register_notification_t; - -typedef struct { - uint8_t id; /* can be attr_id or value_id */ - uint8_t text[BTRC_MAX_ATTR_STR_LEN]; -} btrc_player_setting_text_t; - -typedef struct { - uint32_t attr_id; - uint8_t text[BTRC_MAX_ATTR_STR_LEN]; -} btrc_element_attr_val_t; - -/** Callback for the controller's supported feautres */ -typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr, - btrc_remote_features_t features); -#define BTRC_FEATURE_MASK_SIZE 16 - -typedef uint8_t btrc_feature_mask_t[BTRC_FEATURE_MASK_SIZE]; - -typedef struct { - uint16_t charset_id; - uint16_t str_len; - uint8_t *p_str; -} btrc_player_full_name_t; - -typedef struct -{ - uint32_t sub_type; - uint16_t player_id; - uint8_t major_type; - uint8_t play_status; - btrc_feature_mask_t features; /* Supported feature bit mask*/ - btrc_player_full_name_t name; /* The player name, name length and character set id.*/ -} btrc_folder_list_item_player_t; - -typedef struct -{ - uint64_t uid; - uint8_t type; - uint8_t playable; - btrc_player_full_name_t name; -} btrc_folder_list_item_folder_t; - -typedef struct -{ - uint32_t attr_id; - btrc_player_full_name_t name; -} btrc_attr_entry_t; - -typedef struct -{ - uint64_t uid; - uint8_t type; - uint8_t attr_count; - btrc_player_full_name_t name; - btrc_attr_entry_t* p_attr_list; -} btrc_folder_list_item_media_t; - -typedef struct { - uint16_t str_len; - uint8_t *p_str; -} btrc_name_t; - -/* SetBrowsedPlayer */ -typedef struct -{ - uint32_t num_items; - uint16_t uid_counter; - uint16_t charset_id; - uint8_t status; - uint8_t folder_depth; - btrc_name_t *p_folders; -} btrc_set_browsed_player_rsp_t; - -typedef struct -{ - uint8_t item_type; - union - { - btrc_folder_list_item_player_t player; - btrc_folder_list_item_folder_t folder; - btrc_folder_list_item_media_t media; - } u; -} btrc_folder_list_item_t; - -/* GetFolderItems */ -typedef struct -{ - uint16_t uid_counter; - uint16_t item_count; - uint8_t status; - btrc_folder_list_item_t *p_item_list; -} btrc_folder_list_entries_t; - -/** Callback for play status request */ -typedef void (* btrc_get_play_status_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for list player application attributes (Shuffle, Repeat,...) */ -typedef void (* btrc_list_player_app_attr_callback)(bt_bdaddr_t *bd_addr); - -/** Callback for list player application attributes (Shuffle, Repeat,...) */ -typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id, - bt_bdaddr_t *bd_addr); - -/** Callback for getting the current player application settings value -** num_attr: specifies the number of attribute ids contained in p_attrs -*/ -typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs, - bt_bdaddr_t *bd_addr); - -/** Callback for getting the player application settings attributes' text -** num_attr: specifies the number of attribute ids contained in p_attrs -*/ -typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, - btrc_player_attr_t *p_attrs, bt_bdaddr_t *bd_addr); - -/** Callback for getting the player application settings values' text -** num_attr: specifies the number of value ids contained in p_vals -*/ -typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, - uint8_t num_val, uint8_t *p_vals, bt_bdaddr_t *bd_addr); - -/** Callback for setting the player application settings values */ -typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals, - bt_bdaddr_t *bd_addr); - -/** Callback to fetch the get element attributes of the current song -** num_attr: specifies the number of attributes requested in p_attrs -*/ -typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs, - bt_bdaddr_t *bd_addr); - -/** Callback for register notification (Play state change/track change/...) -** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED -*/ -typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param, - bt_bdaddr_t *bd_addr); - -/* AVRCP 1.4 Enhancements */ -/** Callback for volume change on CT -** volume: Current volume setting on the CT (0-127) -*/ -typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype, bt_bdaddr_t *bd_addr); - -/** Callback for passthrough commands */ -typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state, bt_bdaddr_t *bd_addr); - -/** BT-RC Target callback structure. */ - -typedef void (* btrc_get_folder_items_callback) (btrc_browse_folderitem_t id, - btrc_getfolderitem_t *param, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_set_addressed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_set_browsed_player_callback) (uint32_t player_id, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_change_path_callback) (uint8_t direction, uint64_t uid, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_play_item_callback) (uint8_t scope, uint64_t uid, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_get_item_attr_callback) (uint8_t scope, uint64_t uid, - uint8_t num_attr, btrc_media_attr_t *p_attrs, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); - -typedef struct { - /** set to sizeof(BtRcCallbacks) */ - size_t size; - btrc_remote_features_callback remote_features_cb; - btrc_get_play_status_callback get_play_status_cb; - btrc_list_player_app_attr_callback list_player_app_attr_cb; - btrc_list_player_app_values_callback list_player_app_values_cb; - btrc_get_player_app_value_callback get_player_app_value_cb; - btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb; - btrc_get_player_app_values_text_callback get_player_app_values_text_cb; - btrc_set_player_app_value_callback set_player_app_value_cb; - btrc_get_element_attr_callback get_element_attr_cb; - btrc_register_notification_callback register_notification_cb; - btrc_volume_change_callback volume_change_cb; - btrc_passthrough_cmd_callback passthrough_cmd_cb; - btrc_get_folder_items_callback get_folderitems_cb; - btrc_set_addressed_player_callback set_addrplayer_cb; - btrc_set_browsed_player_callback set_browsed_player_cb; - btrc_change_path_callback change_path_cb; - btrc_play_item_callback play_item_cb; - btrc_get_item_attr_callback get_item_attr_cb; - btrc_connection_state_callback connection_state_cb; -} btrc_callbacks_t; - -/** Represents the standard BT-RC AVRCP Target interface. */ -typedef struct { - - /** set to sizeof(BtRcInterface) */ - size_t size; - /** - * Register the BtRc callbacks - */ - bt_status_t (*init)( btrc_callbacks_t* callbacks , int max_avrcp_connections); - - /** Respose to GetPlayStatus request. Contains the current - ** 1. Play status - ** 2. Song duration/length - ** 3. Song position - */ - bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, - uint32_t song_pos, bt_bdaddr_t *bd_addr); - - /** Lists the support player application attributes (Shuffle/Repeat/...) - ** num_attr: Specifies the number of attributes contained in the pointer p_attrs - */ - bt_status_t (*list_player_app_attr_rsp)( uint8_t num_attr, btrc_player_attr_t *p_attrs, - bt_bdaddr_t *bd_addr); - - /** Lists the support player application attributes (Shuffle Off/On/Group) - ** num_val: Specifies the number of values contained in the pointer p_vals - */ - bt_status_t (*list_player_app_value_rsp)( uint8_t num_val, uint8_t *p_vals, - bt_bdaddr_t *bd_addr); - - /** Returns the current application attribute values for each of the specified attr_id */ - bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals, - bt_bdaddr_t *bd_addr); - - /** Returns the application attributes text ("Shuffle"/"Repeat"/...) - ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs - */ - bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs, - bt_bdaddr_t *bd_addr); - - /** Returns the application attributes text ("Shuffle"/"Repeat"/...) - ** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals - */ - bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals, - bt_bdaddr_t *bd_addr); - - /** Returns the current songs' element attributes text ("Title"/"Album"/"Artist") - ** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs - */ - bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs, - bt_bdaddr_t *bd_addr); - - /** Response to set player attribute request ("Shuffle"/"Repeat") - ** rsp_status: Status of setting the player attributes for the current media player - */ - bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status, bt_bdaddr_t *bd_addr); - - /* Response to the register notification request (Play state change/track change/...). - ** event_id: Refers to the event_id this notification change corresponds too - ** type: Response type - interim/changed - ** p_params: Based on the event_id, this parameter should be populated - */ - bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id, - btrc_notification_type_t type, - btrc_register_notification_t *p_param, - bt_bdaddr_t *bd_addr); - - /* AVRCP 1.4 enhancements */ - - /**Send current volume setting to remote side. Support limited to SetAbsoluteVolume - ** This can be enhanced to support Relative Volume (AVRCP 1.0). - ** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level - ** volume: Should be in the range 0-127. bit7 is reseved and cannot be set - */ - bt_status_t (*set_volume)(uint8_t volume, bt_bdaddr_t *bd_addr); - bt_status_t (*get_folder_items_rsp) (btrc_folder_list_entries_t *p_param, bt_bdaddr_t *bd_addr); - - bt_status_t (*set_addressed_player_rsp) (btrc_status_t status_code, bt_bdaddr_t *bd_addr); - bt_status_t (*set_browsed_player_rsp) (btrc_set_browsed_player_rsp_t *p_param, - bt_bdaddr_t *bd_addr); - bt_status_t (*change_path_rsp) (uint8_t status_code, uint32_t item_count, - bt_bdaddr_t *bd_addr); - bt_status_t (*play_item_rsp) (uint8_t status_code, bt_bdaddr_t *bd_addr); - bt_status_t (*get_item_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs, - bt_bdaddr_t *bd_addr); - bt_status_t (*is_device_active_in_handoff) (bt_bdaddr_t *bd_addr); - - /** Closes the interface. */ - void (*cleanup)( void ); -} btrc_interface_t; - - -typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state); - -typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr); - -typedef void (* btrc_ctrl_getrcfeatures_callback) (bt_bdaddr_t *bd_addr, int features); - -typedef void (* btrc_ctrl_getcapability_rsp_callback) (bt_bdaddr_t *bd_addr, int cap_id, - uint32_t* supported_values, int num_supported, uint8_t rsp_type); - -typedef void (* btrc_ctrl_listplayerappsettingattrib_rsp_callback) (bt_bdaddr_t *bd_addr, - uint8_t* supported_attribs, int num_attrib, uint8_t rsp_type); - -typedef void (* btrc_ctrl_listplayerappsettingvalue_rsp_callback) (bt_bdaddr_t *bd_addr, - uint8_t* supported_val, uint8_t num_supported, uint8_t rsp_type); - -typedef void (* btrc_ctrl_currentplayerappsetting_rsp_callback) (bt_bdaddr_t *bd_addr,uint8_t* supported_ids, - uint8_t* supported_val, uint8_t num_attrib, uint8_t rsp_type); - -typedef void (* btrc_ctrl_setplayerapplicationsetting_rsp_callback) (bt_bdaddr_t *bd_addr,uint8_t rsp_type); - -typedef void (* btrc_ctrl_notification_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t rsp_type, - int rsp_len, uint8_t* notification_rsp); - -typedef void (* btrc_ctrl_getelementattrib_rsp_callback) (bt_bdaddr_t *bd_addr, uint8_t num_attributes, - int rsp_len, uint8_t* attrib_rsp, uint8_t rsp_type); - -typedef void (* btrc_ctrl_getplaystatus_rsp_callback) (bt_bdaddr_t *bd_addr, int param_len, uint8_t* play_status_rsp - ,uint8_t rsp_type); - -typedef void (* btrc_ctrl_setabsvol_cmd_callback) (bt_bdaddr_t *bd_addr, uint8_t abs_vol); - -typedef void (* btrc_ctrl_registernotification_abs_vol_callback) (bt_bdaddr_t *bd_addr); -/** BT-RC Controller callback structure. */ -typedef struct { - /** set to sizeof(BtRcCallbacks) */ - size_t size; - btrc_passthrough_rsp_callback passthrough_rsp_cb; - btrc_connection_state_callback connection_state_cb; - btrc_ctrl_getrcfeatures_callback getrcfeatures_cb; - btrc_ctrl_getcapability_rsp_callback getcap_rsp_cb; - btrc_ctrl_listplayerappsettingattrib_rsp_callback listplayerappsettingattrib_rsp_cb; - btrc_ctrl_listplayerappsettingvalue_rsp_callback listplayerappsettingvalue_rsp_cb; - btrc_ctrl_currentplayerappsetting_rsp_callback currentplayerappsetting_rsp_cb; - btrc_ctrl_setplayerapplicationsetting_rsp_callback setplayerappsetting_rsp_cb; - btrc_ctrl_notification_rsp_callback notification_rsp_cb; - btrc_ctrl_getelementattrib_rsp_callback getelementattrib_rsp_cb; - btrc_ctrl_getplaystatus_rsp_callback getplaystatus_rsp_cb; - btrc_ctrl_setabsvol_cmd_callback setabsvol_cmd_cb; - btrc_ctrl_registernotification_abs_vol_callback registernotification_absvol_cb; -} btrc_ctrl_callbacks_t; - -/** Represents the standard BT-RC AVRCP Controller interface. */ -typedef struct { - - /** set to sizeof(BtRcInterface) */ - size_t size; - /** - * Register the BtRc callbacks - */ - bt_status_t (*init)( btrc_ctrl_callbacks_t* callbacks ); - - /** send pass through command to target */ - bt_status_t (*send_pass_through_cmd) ( bt_bdaddr_t *bd_addr, uint8_t key_code, - uint8_t key_state ); - - /** send get_cap command to target */ - bt_status_t (*getcapabilities_cmd) (uint8_t cap_id); - - /** send command to get supported player application settings to target */ - bt_status_t (*list_player_app_setting_attrib_cmd) (void); - - /** send command to get supported values of player application settings for a - * particular attribute to target */ - bt_status_t (*list_player_app_setting_value_cmd) (uint8_t attrib_id); - - /** send command to get current player attributes to target */ - bt_status_t (*get_player_app_setting_cmd) (uint8_t num_attrib, uint8_t* attrib_ids); - - /** send command to set player applicaiton setting attributes to target */ - bt_status_t (*set_player_app_setting_cmd) (uint8_t num_attrib, uint8_t* attrib_ids, uint8_t* attrib_vals); - - /** send command to register for supported notificaiton events to target */ - bt_status_t (*register_notification_cmd) (uint8_t event_id, uint32_t event_value); - - /** send command to get element attribute to target */ - bt_status_t (*get_element_attribute_cmd) (uint8_t num_attribute, uint32_t attribute_id); - - /** send command to get play status to target */ - bt_status_t (*get_play_status_cmd) (void); - - /** send rsp to set_abs_vol received from target */ - bt_status_t (*send_abs_vol_rsp) (uint8_t abs_vol); - - /** send notificaiton rsp for abs vol to target */ - bt_status_t (*send_register_abs_vol_rsp) (uint8_t rsp_type, uint8_t abs_vol); - - /** Closes the interface. */ - void (*cleanup)( void ); -} btrc_ctrl_interface_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_BT_RC_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_sdp.h b/third_party/android_hardware_libhardware/include/hardware/bt_sdp.h deleted file mode 100644 index 8f39bc5bd..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_sdp.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#pragma once - -#include "bluetooth.h" - -#define SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH 15 - -__BEGIN_DECLS - -/** - * These events are handled by the state machine - */ -typedef enum { - SDP_TYPE_RAW, // Used to carry raw SDP search data for unknown UUIDs - SDP_TYPE_MAP_MAS, // Message Access Profile - Server - SDP_TYPE_MAP_MNS, // Message Access Profile - Client (Notification Server) - SDP_TYPE_PBAP_PSE, // Phone Book Profile - Server - SDP_TYPE_PBAP_PCE, // Phone Book Profile - Client - SDP_TYPE_OPP_SERVER, // Object Push Profile - SDP_TYPE_SAP_SERVER // SIM Access Profile -} bluetooth_sdp_types; - -typedef struct _bluetooth_sdp_hdr { - bluetooth_sdp_types type; - bt_uuid_t uuid; - uint32_t service_name_length; - char *service_name; - int32_t rfcomm_channel_number; - int32_t l2cap_psm; - int32_t profile_version; -} bluetooth_sdp_hdr; - -/** - * Some signals need additional pointers, hence we introduce a - * generic way to handle these pointers. - */ -typedef struct _bluetooth_sdp_hdr_overlay { - bluetooth_sdp_types type; - bt_uuid_t uuid; - uint32_t service_name_length; - char *service_name; - int32_t rfcomm_channel_number; - int32_t l2cap_psm; - int32_t profile_version; - - // User pointers, only used for some signals - see bluetooth_sdp_ops_record - int user1_ptr_len; - uint8_t *user1_ptr; - int user2_ptr_len; - uint8_t *user2_ptr; -} bluetooth_sdp_hdr_overlay; - -typedef struct _bluetooth_sdp_mas_record { - bluetooth_sdp_hdr_overlay hdr; - uint32_t mas_instance_id; - uint32_t supported_features; - uint32_t supported_message_types; -} bluetooth_sdp_mas_record; - -typedef struct _bluetooth_sdp_mns_record { - bluetooth_sdp_hdr_overlay hdr; - uint32_t supported_features; -} bluetooth_sdp_mns_record; - -typedef struct _bluetooth_sdp_pse_record { - bluetooth_sdp_hdr_overlay hdr; - uint32_t supported_features; - uint32_t supported_repositories; -} bluetooth_sdp_pse_record; - -typedef struct _bluetooth_sdp_pce_record { - bluetooth_sdp_hdr_overlay hdr; -} bluetooth_sdp_pce_record; - -typedef struct _bluetooth_sdp_ops_record { - bluetooth_sdp_hdr_overlay hdr; - int supported_formats_list_len; - uint8_t supported_formats_list[SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH]; -} bluetooth_sdp_ops_record; - -typedef struct _bluetooth_sdp_sap_record { - bluetooth_sdp_hdr_overlay hdr; -} bluetooth_sdp_sap_record; - -typedef union { - bluetooth_sdp_hdr_overlay hdr; - bluetooth_sdp_mas_record mas; - bluetooth_sdp_mns_record mns; - bluetooth_sdp_pse_record pse; - bluetooth_sdp_pce_record pce; - bluetooth_sdp_ops_record ops; - bluetooth_sdp_sap_record sap; -} bluetooth_sdp_record; - - -/** Callback for SDP search */ -typedef void (*btsdp_search_callback)(bt_status_t status, bt_bdaddr_t *bd_addr, uint8_t* uuid, int num_records, bluetooth_sdp_record *records); - -typedef struct { - /** Set to sizeof(btsdp_callbacks_t) */ - size_t size; - btsdp_search_callback sdp_search_cb; -} btsdp_callbacks_t; - -typedef struct { - /** Set to size of this struct */ - size_t size; - - /** Register BT SDP search callbacks */ - bt_status_t (*init)(btsdp_callbacks_t *callbacks); - - /** Unregister BT SDP */ - bt_status_t (*deinit)(); - - /** Search for SDP records with specific uuid on remote device */ - bt_status_t (*sdp_search)(bt_bdaddr_t *bd_addr, const uint8_t* uuid); - - /** - * Use listen in the socket interface to create rfcomm and/or l2cap PSM channels, - * (without UUID and service_name and set the BTSOCK_FLAG_NO_SDP flag in flags). - * Then use createSdpRecord to create the SDP record associated with the rfcomm/l2cap channels. - * - * Returns a handle to the SDP record, which can be parsed to remove_sdp_record. - * - * record (in) The SDP record to create - * record_handle (out)The corresponding record handle will be written to this pointer. - */ - bt_status_t (*create_sdp_record)(bluetooth_sdp_record *record, int* record_handle); - - /** Remove a SDP record created by createSdpRecord */ - bt_status_t (*remove_sdp_record)(int sdp_handle); -} btsdp_interface_t; - -__END_DECLS - diff --git a/third_party/android_hardware_libhardware/include/hardware/bt_sock.h b/third_party/android_hardware_libhardware/include/hardware/bt_sock.h deleted file mode 100644 index 9dd83bb1c..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/bt_sock.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#pragma once - -__BEGIN_DECLS - -#define BTSOCK_FLAG_ENCRYPT 1 -#define BTSOCK_FLAG_AUTH (1 << 1) -#define BTSOCK_FLAG_NO_SDP (1 << 2) -#define BTSOCK_FLAG_AUTH_MITM (1 << 3) -#define BTSOCK_FLAG_AUTH_16_DIGIT (1 << 4) - -typedef enum { - BTSOCK_RFCOMM = 1, - BTSOCK_SCO = 2, - BTSOCK_L2CAP = 3 -} btsock_type_t; - -typedef enum { - BTSOCK_OPT_GET_MODEM_BITS = 1, - BTSOCK_OPT_SET_MODEM_BITS = 2, - BTSOCK_OPT_CLR_MODEM_BITS = 3, -} btsock_option_type_t; - -/** Represents the standard BT SOCKET interface. */ -typedef struct { - short size; - bt_bdaddr_t bd_addr; - int channel; - int status; - - // The writer must make writes using a buffer of this maximum size - // to avoid loosing data. (L2CAP only) - unsigned short max_tx_packet_size; - - // The reader must read using a buffer of at least this size to avoid - // loosing data. (L2CAP only) - unsigned short max_rx_packet_size; -} __attribute__((packed)) sock_connect_signal_t; - -typedef struct { - /** set to size of this struct*/ - size_t size; - - /** - * Listen to a RFCOMM UUID or channel. It returns the socket fd from which - * btsock_connect_signal can be read out when a remote device connected. - * If neither a UUID nor a channel is provided, a channel will be allocated - * and a service record can be created providing the channel number to - * create_sdp_record(...) in bt_sdp. - */ - bt_status_t (*listen)(btsock_type_t type, const char* service_name, - const uint8_t* service_uuid, int channel, int* sock_fd, int flags); - - /** - * Connect to a RFCOMM UUID channel of remote device, It returns the socket fd from which - * the btsock_connect_signal and a new socket fd to be accepted can be read out when connected - */ - bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, btsock_type_t type, const uint8_t* uuid, - int channel, int* sock_fd, int flags); - - /* - * get socket option of rfcomm channel socket. - */ - bt_status_t (*get_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, - void *option_value, int *option_len); - /* - - * set socket option of rfcomm channel socket. - */ - bt_status_t (*set_sock_opt)(btsock_type_t type, int channel, btsock_option_type_t option_name, - void *option_value, int option_len); - -} btsock_interface_t; - -__END_DECLS - diff --git a/third_party/android_hardware_libhardware/include/hardware/camera.h b/third_party/android_hardware_libhardware/include/hardware/camera.h deleted file mode 100644 index b1f18fffc..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (C) 2010-2011 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. - */ - -#ifndef ANDROID_INCLUDE_CAMERA_H -#define ANDROID_INCLUDE_CAMERA_H - -#include "camera_common.h" - -/** - * Camera device HAL, initial version [ CAMERA_DEVICE_API_VERSION_1_0 ] - * - * DEPRECATED. New devices should use Camera HAL v3.2 or newer. - * - * Supports the android.hardware.Camera API, and the android.hardware.camera2 - * API in legacy mode only. - * - * Camera devices that support this version of the HAL must return a value in - * the range HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF) in - * camera_device_t.common.version. CAMERA_DEVICE_API_VERSION_1_0 is the - * recommended value. - * - * Camera modules that implement version 2.0 or higher of camera_module_t must - * also return the value of camera_device_t.common.version in - * camera_info_t.device_version. - * - * See camera_common.h for more details. - */ - -__BEGIN_DECLS - -struct camera_memory; -typedef void (*camera_release_memory)(struct camera_memory *mem); - -typedef struct camera_memory { - void *data; - size_t size; - void *handle; - camera_release_memory release; -} camera_memory_t; - -typedef camera_memory_t* (*camera_request_memory)(int fd, size_t buf_size, unsigned int num_bufs, - void *user); - -typedef void (*camera_notify_callback)(int32_t msg_type, - int32_t ext1, - int32_t ext2, - void *user); - -typedef void (*camera_data_callback)(int32_t msg_type, - const camera_memory_t *data, unsigned int index, - camera_frame_metadata_t *metadata, void *user); - -typedef void (*camera_data_timestamp_callback)(int64_t timestamp, - int32_t msg_type, - const camera_memory_t *data, unsigned int index, - void *user); - -#define HAL_CAMERA_PREVIEW_WINDOW_TAG 0xcafed00d - -typedef struct preview_stream_ops { - int (*dequeue_buffer)(struct preview_stream_ops* w, - buffer_handle_t** buffer, int *stride); - int (*enqueue_buffer)(struct preview_stream_ops* w, - buffer_handle_t* buffer); - int (*cancel_buffer)(struct preview_stream_ops* w, - buffer_handle_t* buffer); - int (*set_buffer_count)(struct preview_stream_ops* w, int count); - int (*set_buffers_geometry)(struct preview_stream_ops* pw, - int w, int h, int format); - int (*set_crop)(struct preview_stream_ops *w, - int left, int top, int right, int bottom); - int (*set_usage)(struct preview_stream_ops* w, int usage); - int (*set_swap_interval)(struct preview_stream_ops *w, int interval); - int (*get_min_undequeued_buffer_count)(const struct preview_stream_ops *w, - int *count); - int (*lock_buffer)(struct preview_stream_ops* w, - buffer_handle_t* buffer); - // Timestamps are measured in nanoseconds, and must be comparable - // and monotonically increasing between two frames in the same - // preview stream. They do not need to be comparable between - // consecutive or parallel preview streams, cameras, or app runs. - int (*set_timestamp)(struct preview_stream_ops *w, int64_t timestamp); -} preview_stream_ops_t; - -struct camera_device; -typedef struct camera_device_ops { - /** Set the ANativeWindow to which preview frames are sent */ - int (*set_preview_window)(struct camera_device *, - struct preview_stream_ops *window); - - /** Set the notification and data callbacks */ - void (*set_callbacks)(struct camera_device *, - camera_notify_callback notify_cb, - camera_data_callback data_cb, - camera_data_timestamp_callback data_cb_timestamp, - camera_request_memory get_memory, - void *user); - - /** - * The following three functions all take a msg_type, which is a bitmask of - * the messages defined in include/ui/Camera.h - */ - - /** - * Enable a message, or set of messages. - */ - void (*enable_msg_type)(struct camera_device *, int32_t msg_type); - - /** - * Disable a message, or a set of messages. - * - * Once received a call to disableMsgType(CAMERA_MSG_VIDEO_FRAME), camera - * HAL should not rely on its client to call releaseRecordingFrame() to - * release video recording frames sent out by the cameral HAL before and - * after the disableMsgType(CAMERA_MSG_VIDEO_FRAME) call. Camera HAL - * clients must not modify/access any video recording frame after calling - * disableMsgType(CAMERA_MSG_VIDEO_FRAME). - */ - void (*disable_msg_type)(struct camera_device *, int32_t msg_type); - - /** - * Query whether a message, or a set of messages, is enabled. Note that - * this is operates as an AND, if any of the messages queried are off, this - * will return false. - */ - int (*msg_type_enabled)(struct camera_device *, int32_t msg_type); - - /** - * Start preview mode. - */ - int (*start_preview)(struct camera_device *); - - /** - * Stop a previously started preview. - */ - void (*stop_preview)(struct camera_device *); - - /** - * Returns true if preview is enabled. - */ - int (*preview_enabled)(struct camera_device *); - - /** - * Request the camera HAL to store meta data or real YUV data in the video - * buffers sent out via CAMERA_MSG_VIDEO_FRAME for a recording session. If - * it is not called, the default camera HAL behavior is to store real YUV - * data in the video buffers. - * - * This method should be called before startRecording() in order to be - * effective. - * - * If meta data is stored in the video buffers, it is up to the receiver of - * the video buffers to interpret the contents and to find the actual frame - * data with the help of the meta data in the buffer. How this is done is - * outside of the scope of this method. - * - * Some camera HALs may not support storing meta data in the video buffers, - * but all camera HALs should support storing real YUV data in the video - * buffers. If the camera HAL does not support storing the meta data in the - * video buffers when it is requested to do do, INVALID_OPERATION must be - * returned. It is very useful for the camera HAL to pass meta data rather - * than the actual frame data directly to the video encoder, since the - * amount of the uncompressed frame data can be very large if video size is - * large. - * - * @param enable if true to instruct the camera HAL to store - * meta data in the video buffers; false to instruct - * the camera HAL to store real YUV data in the video - * buffers. - * - * @return OK on success. - */ - int (*store_meta_data_in_buffers)(struct camera_device *, int enable); - - /** - * Start record mode. When a record image is available, a - * CAMERA_MSG_VIDEO_FRAME message is sent with the corresponding - * frame. Every record frame must be released by a camera HAL client via - * releaseRecordingFrame() before the client calls - * disableMsgType(CAMERA_MSG_VIDEO_FRAME). After the client calls - * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's - * responsibility to manage the life-cycle of the video recording frames, - * and the client must not modify/access any video recording frames. - */ - int (*start_recording)(struct camera_device *); - - /** - * Stop a previously started recording. - */ - void (*stop_recording)(struct camera_device *); - - /** - * Returns true if recording is enabled. - */ - int (*recording_enabled)(struct camera_device *); - - /** - * Release a record frame previously returned by CAMERA_MSG_VIDEO_FRAME. - * - * It is camera HAL client's responsibility to release video recording - * frames sent out by the camera HAL before the camera HAL receives a call - * to disableMsgType(CAMERA_MSG_VIDEO_FRAME). After it receives the call to - * disableMsgType(CAMERA_MSG_VIDEO_FRAME), it is the camera HAL's - * responsibility to manage the life-cycle of the video recording frames. - */ - void (*release_recording_frame)(struct camera_device *, - const void *opaque); - - /** - * Start auto focus, the notification callback routine is called with - * CAMERA_MSG_FOCUS once when focusing is complete. autoFocus() will be - * called again if another auto focus is needed. - */ - int (*auto_focus)(struct camera_device *); - - /** - * Cancels auto-focus function. If the auto-focus is still in progress, - * this function will cancel it. Whether the auto-focus is in progress or - * not, this function will return the focus position to the default. If - * the camera does not support auto-focus, this is a no-op. - */ - int (*cancel_auto_focus)(struct camera_device *); - - /** - * Take a picture. - */ - int (*take_picture)(struct camera_device *); - - /** - * Cancel a picture that was started with takePicture. Calling this method - * when no picture is being taken is a no-op. - */ - int (*cancel_picture)(struct camera_device *); - - /** - * Set the camera parameters. This returns BAD_VALUE if any parameter is - * invalid or not supported. - */ - int (*set_parameters)(struct camera_device *, const char *parms); - - /** Retrieve the camera parameters. The buffer returned by the camera HAL - must be returned back to it with put_parameters, if put_parameters - is not NULL. - */ - char *(*get_parameters)(struct camera_device *); - - /** The camera HAL uses its own memory to pass us the parameters when we - call get_parameters. Use this function to return the memory back to - the camera HAL, if put_parameters is not NULL. If put_parameters - is NULL, then you have to use free() to release the memory. - */ - void (*put_parameters)(struct camera_device *, char *); - - /** - * Send command to camera driver. - */ - int (*send_command)(struct camera_device *, - int32_t cmd, int32_t arg1, int32_t arg2); - - /** - * Release the hardware resources owned by this object. Note that this is - * *not* done in the destructor. - */ - void (*release)(struct camera_device *); - - /** - * Dump state of the camera hardware - */ - int (*dump)(struct camera_device *, int fd); -} camera_device_ops_t; - -typedef struct camera_device { - /** - * camera_device.common.version must be in the range - * HARDWARE_DEVICE_API_VERSION(0,0)-(1,FF). CAMERA_DEVICE_API_VERSION_1_0 is - * recommended. - */ - hw_device_t common; - camera_device_ops_t *ops; - void *priv; -} camera_device_t; - -__END_DECLS - -#endif /* #ifdef ANDROID_INCLUDE_CAMERA_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/camera2.h b/third_party/android_hardware_libhardware/include/hardware/camera2.h deleted file mode 100644 index d920d4b65..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera2.h +++ /dev/null @@ -1,839 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_CAMERA2_H -#define ANDROID_INCLUDE_CAMERA2_H - -#include "camera_common.h" -#include "system/camera_metadata.h" - -/** - * Camera device HAL 2.1 [ CAMERA_DEVICE_API_VERSION_2_0, CAMERA_DEVICE_API_VERSION_2_1 ] - * - * DEPRECATED. New devices should use Camera HAL v3.2 or newer. - * - * Supports the android.hardware.Camera API, and the android.hardware.camera2 - * API in legacy mode only. - * - * Camera devices that support this version of the HAL must return - * CAMERA_DEVICE_API_VERSION_2_1 in camera_device_t.common.version and in - * camera_info_t.device_version (from camera_module_t.get_camera_info). - * - * Camera modules that may contain version 2.x devices must implement at least - * version 2.0 of the camera module interface (as defined by - * camera_module_t.common.module_api_version). - * - * See camera_common.h for more versioning details. - * - * Version history: - * - * 2.0: CAMERA_DEVICE_API_VERSION_2_0. Initial release (Android 4.2): - * - Sufficient for implementing existing android.hardware.Camera API. - * - Allows for ZSL queue in camera service layer - * - Not tested for any new features such manual capture control, - * Bayer RAW capture, reprocessing of RAW data. - * - * 2.1: CAMERA_DEVICE_API_VERSION_2_1. Support per-device static metadata: - * - Add get_instance_metadata() method to retrieve metadata that is fixed - * after device open, but may be variable between open() calls. - */ - -__BEGIN_DECLS - -struct camera2_device; - -/********************************************************************** - * - * Input/output stream buffer queue interface definitions - * - */ - -/** - * Output image stream queue interface. A set of these methods is provided to - * the HAL device in allocate_stream(), and are used to interact with the - * gralloc buffer queue for that stream. They may not be called until after - * allocate_stream returns. - */ -typedef struct camera2_stream_ops { - /** - * Get a buffer to fill from the queue. The size and format of the buffer - * are fixed for a given stream (defined in allocate_stream), and the stride - * should be queried from the platform gralloc module. The gralloc buffer - * will have been allocated based on the usage flags provided by - * allocate_stream, and will be locked for use. - */ - int (*dequeue_buffer)(const struct camera2_stream_ops* w, - buffer_handle_t** buffer); - - /** - * Push a filled buffer to the stream to be used by the consumer. - * - * The timestamp represents the time at start of exposure of the first row - * of the image; it must be from a monotonic clock, and is measured in - * nanoseconds. The timestamps do not need to be comparable between - * different cameras, or consecutive instances of the same camera. However, - * they must be comparable between streams from the same camera. If one - * capture produces buffers for multiple streams, each stream must have the - * same timestamp for that buffer, and that timestamp must match the - * timestamp in the output frame metadata. - */ - int (*enqueue_buffer)(const struct camera2_stream_ops* w, - int64_t timestamp, - buffer_handle_t* buffer); - /** - * Return a buffer to the queue without marking it as filled. - */ - int (*cancel_buffer)(const struct camera2_stream_ops* w, - buffer_handle_t* buffer); - /** - * Set the crop window for subsequently enqueued buffers. The parameters are - * measured in pixels relative to the buffer width and height. - */ - int (*set_crop)(const struct camera2_stream_ops *w, - int left, int top, int right, int bottom); - -} camera2_stream_ops_t; - -/** - * Temporary definition during transition. - * - * These formats will be removed and replaced with - * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. To maximize forward compatibility, - * HAL implementations are strongly recommended to treat FORMAT_OPAQUE and - * FORMAT_ZSL as equivalent to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, and - * return HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED in the format_actual output - * parameter of allocate_stream, allowing the gralloc module to select the - * specific format based on the usage flags from the camera and the stream - * consumer. - */ -enum { - CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, - CAMERA2_HAL_PIXEL_FORMAT_ZSL = -1 -}; - -/** - * Transport header for compressed JPEG buffers in output streams. - * - * To capture JPEG images, a stream is created using the pixel format - * HAL_PIXEL_FORMAT_BLOB, and the static metadata field android.jpeg.maxSize is - * used as the buffer size. Since compressed JPEG images are of variable size, - * the HAL needs to include the final size of the compressed image using this - * structure inside the output stream buffer. The JPEG blob ID field must be set - * to CAMERA2_JPEG_BLOB_ID. - * - * Transport header should be at the end of the JPEG output stream buffer. That - * means the jpeg_blob_id must start at byte[android.jpeg.maxSize - - * sizeof(camera2_jpeg_blob)]. Any HAL using this transport header must - * account for it in android.jpeg.maxSize. The JPEG data itself starts at - * byte[0] and should be jpeg_size bytes long. - */ -typedef struct camera2_jpeg_blob { - uint16_t jpeg_blob_id; - uint32_t jpeg_size; -}; - -enum { - CAMERA2_JPEG_BLOB_ID = 0x00FF -}; - -/** - * Input reprocess stream queue management. A set of these methods is provided - * to the HAL device in allocate_reprocess_stream(); they are used to interact - * with the reprocess stream's input gralloc buffer queue. - */ -typedef struct camera2_stream_in_ops { - /** - * Get the next buffer of image data to reprocess. The width, height, and - * format of the buffer is fixed in allocate_reprocess_stream(), and the - * stride and other details should be queried from the platform gralloc - * module as needed. The buffer will already be locked for use. - */ - int (*acquire_buffer)(const struct camera2_stream_in_ops *w, - buffer_handle_t** buffer); - /** - * Return a used buffer to the buffer queue for reuse. - */ - int (*release_buffer)(const struct camera2_stream_in_ops *w, - buffer_handle_t* buffer); - -} camera2_stream_in_ops_t; - -/********************************************************************** - * - * Metadata queue management, used for requests sent to HAL module, and for - * frames produced by the HAL. - * - */ - -enum { - CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS = -1 -}; - -/** - * Request input queue protocol: - * - * The framework holds the queue and its contents. At start, the queue is empty. - * - * 1. When the first metadata buffer is placed into the queue, the framework - * signals the device by calling notify_request_queue_not_empty(). - * - * 2. After receiving notify_request_queue_not_empty, the device must call - * dequeue() once it's ready to handle the next buffer. - * - * 3. Once the device has processed a buffer, and is ready for the next buffer, - * it must call dequeue() again instead of waiting for a notification. If - * there are no more buffers available, dequeue() will return NULL. After - * this point, when a buffer becomes available, the framework must call - * notify_request_queue_not_empty() again. If the device receives a NULL - * return from dequeue, it does not need to query the queue again until a - * notify_request_queue_not_empty() call is received from the source. - * - * 4. If the device calls buffer_count() and receives 0, this does not mean that - * the framework will provide a notify_request_queue_not_empty() call. The - * framework will only provide such a notification after the device has - * received a NULL from dequeue, or on initial startup. - * - * 5. The dequeue() call in response to notify_request_queue_not_empty() may be - * on the same thread as the notify_request_queue_not_empty() call, and may - * be performed from within the notify call. - * - * 6. All dequeued request buffers must be returned to the framework by calling - * free_request, including when errors occur, a device flush is requested, or - * when the device is shutting down. - */ -typedef struct camera2_request_queue_src_ops { - /** - * Get the count of request buffers pending in the queue. May return - * CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS if a repeating request (stream - * request) is currently configured. Calling this method has no effect on - * whether the notify_request_queue_not_empty() method will be called by the - * framework. - */ - int (*request_count)(const struct camera2_request_queue_src_ops *q); - - /** - * Get a metadata buffer from the framework. Returns OK if there is no - * error. If the queue is empty, returns NULL in buffer. In that case, the - * device must wait for a notify_request_queue_not_empty() message before - * attempting to dequeue again. Buffers obtained in this way must be - * returned to the framework with free_request(). - */ - int (*dequeue_request)(const struct camera2_request_queue_src_ops *q, - camera_metadata_t **buffer); - /** - * Return a metadata buffer to the framework once it has been used, or if - * an error or shutdown occurs. - */ - int (*free_request)(const struct camera2_request_queue_src_ops *q, - camera_metadata_t *old_buffer); - -} camera2_request_queue_src_ops_t; - -/** - * Frame output queue protocol: - * - * The framework holds the queue and its contents. At start, the queue is empty. - * - * 1. When the device is ready to fill an output metadata frame, it must dequeue - * a metadata buffer of the required size. - * - * 2. It should then fill the metadata buffer, and place it on the frame queue - * using enqueue_frame. The framework takes ownership of the frame. - * - * 3. In case of an error, a request to flush the pipeline, or shutdown, the - * device must return any affected dequeued frames to the framework by - * calling cancel_frame. - */ -typedef struct camera2_frame_queue_dst_ops { - /** - * Get an empty metadata buffer to fill from the framework. The new metadata - * buffer will have room for entries number of metadata entries, plus - * data_bytes worth of extra storage. Frames dequeued here must be returned - * to the framework with either cancel_frame or enqueue_frame. - */ - int (*dequeue_frame)(const struct camera2_frame_queue_dst_ops *q, - size_t entries, size_t data_bytes, - camera_metadata_t **buffer); - - /** - * Return a dequeued metadata buffer to the framework for reuse; do not mark it as - * filled. Use when encountering errors, or flushing the internal request queue. - */ - int (*cancel_frame)(const struct camera2_frame_queue_dst_ops *q, - camera_metadata_t *buffer); - - /** - * Place a completed metadata frame on the frame output queue. - */ - int (*enqueue_frame)(const struct camera2_frame_queue_dst_ops *q, - camera_metadata_t *buffer); - -} camera2_frame_queue_dst_ops_t; - -/********************************************************************** - * - * Notification callback and message definition, and trigger definitions - * - */ - -/** - * Asynchronous notification callback from the HAL, fired for various - * reasons. Only for information independent of frame capture, or that require - * specific timing. The user pointer must be the same one that was passed to the - * device in set_notify_callback(). - */ -typedef void (*camera2_notify_callback)(int32_t msg_type, - int32_t ext1, - int32_t ext2, - int32_t ext3, - void *user); - -/** - * Possible message types for camera2_notify_callback - */ -enum { - /** - * An error has occurred. Argument ext1 contains the error code, and - * ext2 and ext3 contain any error-specific information. - */ - CAMERA2_MSG_ERROR = 0x0001, - /** - * The exposure of a given request has begun. Argument ext1 contains the - * frame number, and ext2 and ext3 contain the low-order and high-order - * bytes of the timestamp for when exposure began. - * (timestamp = (ext3 << 32 | ext2)) - */ - CAMERA2_MSG_SHUTTER = 0x0010, - /** - * The autofocus routine has changed state. Argument ext1 contains the new - * state; the values are the same as those for the metadata field - * android.control.afState. Ext2 contains the latest trigger ID passed to - * trigger_action(CAMERA2_TRIGGER_AUTOFOCUS) or - * trigger_action(CAMERA2_TRIGGER_CANCEL_AUTOFOCUS), or 0 if trigger has not - * been called with either of those actions. - */ - CAMERA2_MSG_AUTOFOCUS = 0x0020, - /** - * The autoexposure routine has changed state. Argument ext1 contains the - * new state; the values are the same as those for the metadata field - * android.control.aeState. Ext2 contains the latest trigger ID value passed to - * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method - * has not been called. - */ - CAMERA2_MSG_AUTOEXPOSURE = 0x0021, - /** - * The auto-whitebalance routine has changed state. Argument ext1 contains - * the new state; the values are the same as those for the metadata field - * android.control.awbState. Ext2 contains the latest trigger ID passed to - * trigger_action(CAMERA2_TRIGGER_PRECAPTURE_METERING), or 0 if that method - * has not been called. - */ - CAMERA2_MSG_AUTOWB = 0x0022 -}; - -/** - * Error codes for CAMERA_MSG_ERROR - */ -enum { - /** - * A serious failure occured. Camera device may not work without reboot, and - * no further frames or buffer streams will be produced by the - * device. Device should be treated as closed. - */ - CAMERA2_MSG_ERROR_HARDWARE = 0x0001, - /** - * A serious failure occured. No further frames or buffer streams will be - * produced by the device. Device should be treated as closed. The client - * must reopen the device to use it again. - */ - CAMERA2_MSG_ERROR_DEVICE, - /** - * An error has occurred in processing a request. No output (metadata or - * buffers) will be produced for this request. ext2 contains the frame - * number of the request. Subsequent requests are unaffected, and the device - * remains operational. - */ - CAMERA2_MSG_ERROR_REQUEST, - /** - * An error has occurred in producing an output frame metadata buffer for a - * request, but image buffers for it will still be available. Subsequent - * requests are unaffected, and the device remains operational. ext2 - * contains the frame number of the request. - */ - CAMERA2_MSG_ERROR_FRAME, - /** - * An error has occurred in placing an output buffer into a stream for a - * request. The frame metadata and other buffers may still be - * available. Subsequent requests are unaffected, and the device remains - * operational. ext2 contains the frame number of the request, and ext3 - * contains the stream id. - */ - CAMERA2_MSG_ERROR_STREAM, - /** - * Number of error types - */ - CAMERA2_MSG_NUM_ERRORS -}; - -/** - * Possible trigger ids for trigger_action() - */ -enum { - /** - * Trigger an autofocus cycle. The effect of the trigger depends on the - * autofocus mode in effect when the trigger is received, which is the mode - * listed in the latest capture request to be dequeued by the HAL. If the - * mode is OFF, EDOF, or FIXED, the trigger has no effect. In AUTO, MACRO, - * or CONTINUOUS_* modes, see below for the expected behavior. The state of - * the autofocus cycle can be tracked in android.control.afMode and the - * corresponding notifications. - * - ** - * In AUTO or MACRO mode, the AF state transitions (and notifications) - * when calling with trigger ID = N with the previous ID being K are: - * - * Initial state Transitions - * INACTIVE (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * AF_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * AF_NOT_FOCUSED (K) -> ACTIVE_SCAN (N) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * ACTIVE_SCAN (K) -> AF_FOCUSED(N) or AF_NOT_FOCUSED(N) - * PASSIVE_SCAN (K) Not used in AUTO/MACRO mode - * PASSIVE_FOCUSED (K) Not used in AUTO/MACRO mode - * - ** - * In CONTINUOUS_PICTURE mode, triggering AF must lock the AF to the current - * lens position and transition the AF state to either AF_FOCUSED or - * NOT_FOCUSED. If a passive scan is underway, that scan must complete and - * then lock the lens position and change AF state. TRIGGER_CANCEL_AUTOFOCUS - * will allow the AF to restart its operation. - * - * Initial state Transitions - * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * PASSIVE_SCAN (K) -> AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * AF_FOCUSED (K) no effect except to change next notification ID to N - * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N - * - ** - * In CONTINUOUS_VIDEO mode, triggering AF must lock the AF to the current - * lens position and transition the AF state to either AF_FOCUSED or - * NOT_FOCUSED. If a passive scan is underway, it must immediately halt, in - * contrast with CONTINUOUS_PICTURE mode. TRIGGER_CANCEL_AUTOFOCUS will - * allow the AF to restart its operation. - * - * Initial state Transitions - * INACTIVE (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * PASSIVE_FOCUSED (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * PASSIVE_SCAN (K) -> immediate AF_FOCUSED (N) or AF_NOT_FOCUSED (N) - * AF_FOCUSED (K) no effect except to change next notification ID to N - * AF_NOT_FOCUSED (K) no effect except to change next notification ID to N - * - * Ext1 is an ID that must be returned in subsequent auto-focus state change - * notifications through camera2_notify_callback() and stored in - * android.control.afTriggerId. - */ - CAMERA2_TRIGGER_AUTOFOCUS = 0x0001, - /** - * Send a cancel message to the autofocus algorithm. The effect of the - * cancellation depends on the autofocus mode in effect when the trigger is - * received, which is the mode listed in the latest capture request to be - * dequeued by the HAL. If the AF mode is OFF or EDOF, the cancel has no - * effect. For other modes, the lens should return to its default position, - * any current autofocus scan must be canceled, and the AF state should be - * set to INACTIVE. - * - * The state of the autofocus cycle can be tracked in android.control.afMode - * and the corresponding notification. Continuous autofocus modes may resume - * focusing operations thereafter exactly as if the camera had just been set - * to a continuous AF mode. - * - * Ext1 is an ID that must be returned in subsequent auto-focus state change - * notifications through camera2_notify_callback() and stored in - * android.control.afTriggerId. - */ - CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, - /** - * Trigger a pre-capture metering cycle, which may include firing the flash - * to determine proper capture parameters. Typically, this trigger would be - * fired for a half-depress of a camera shutter key, or before a snapshot - * capture in general. The state of the metering cycle can be tracked in - * android.control.aeMode and the corresponding notification. If the - * auto-exposure mode is OFF, the trigger does nothing. - * - * Ext1 is an ID that must be returned in subsequent - * auto-exposure/auto-white balance state change notifications through - * camera2_notify_callback() and stored in android.control.aePrecaptureId. - */ - CAMERA2_TRIGGER_PRECAPTURE_METERING -}; - -/** - * Possible template types for construct_default_request() - */ -enum { - /** - * Standard camera preview operation with 3A on auto. - */ - CAMERA2_TEMPLATE_PREVIEW = 1, - /** - * Standard camera high-quality still capture with 3A and flash on auto. - */ - CAMERA2_TEMPLATE_STILL_CAPTURE, - /** - * Standard video recording plus preview with 3A on auto, torch off. - */ - CAMERA2_TEMPLATE_VIDEO_RECORD, - /** - * High-quality still capture while recording video. Application will - * include preview, video record, and full-resolution YUV or JPEG streams in - * request. Must not cause stuttering on video stream. 3A on auto. - */ - CAMERA2_TEMPLATE_VIDEO_SNAPSHOT, - /** - * Zero-shutter-lag mode. Application will request preview and - * full-resolution data for each frame, and reprocess it to JPEG when a - * still image is requested by user. Settings should provide highest-quality - * full-resolution images without compromising preview frame rate. 3A on - * auto. - */ - CAMERA2_TEMPLATE_ZERO_SHUTTER_LAG, - - /* Total number of templates */ - CAMERA2_TEMPLATE_COUNT -}; - - -/********************************************************************** - * - * Camera device operations - * - */ -typedef struct camera2_device_ops { - - /********************************************************************** - * Request and frame queue setup and management methods - */ - - /** - * Pass in input request queue interface methods. - */ - int (*set_request_queue_src_ops)(const struct camera2_device *, - const camera2_request_queue_src_ops_t *request_src_ops); - - /** - * Notify device that the request queue is no longer empty. Must only be - * called when the first buffer is added a new queue, or after the source - * has returned NULL in response to a dequeue call. - */ - int (*notify_request_queue_not_empty)(const struct camera2_device *); - - /** - * Pass in output frame queue interface methods - */ - int (*set_frame_queue_dst_ops)(const struct camera2_device *, - const camera2_frame_queue_dst_ops_t *frame_dst_ops); - - /** - * Number of camera requests being processed by the device at the moment - * (captures/reprocesses that have had their request dequeued, but have not - * yet been enqueued onto output pipeline(s) ). No streams may be released - * by the framework until the in-progress count is 0. - */ - int (*get_in_progress_count)(const struct camera2_device *); - - /** - * Flush all in-progress captures. This includes all dequeued requests - * (regular or reprocessing) that have not yet placed any outputs into a - * stream or the frame queue. Partially completed captures must be completed - * normally. No new requests may be dequeued from the request queue until - * the flush completes. - */ - int (*flush_captures_in_progress)(const struct camera2_device *); - - /** - * Create a filled-in default request for standard camera use cases. - * - * The device must return a complete request that is configured to meet the - * requested use case, which must be one of the CAMERA2_TEMPLATE_* - * enums. All request control fields must be included, except for - * android.request.outputStreams. - * - * The metadata buffer returned must be allocated with - * allocate_camera_metadata. The framework takes ownership of the buffer. - */ - int (*construct_default_request)(const struct camera2_device *, - int request_template, - camera_metadata_t **request); - - /********************************************************************** - * Stream management - */ - - /** - * allocate_stream: - * - * Allocate a new output stream for use, defined by the output buffer width, - * height, target, and possibly the pixel format. Returns the new stream's - * ID, gralloc usage flags, minimum queue buffer count, and possibly the - * pixel format, on success. Error conditions: - * - * - Requesting a width/height/format combination not listed as - * supported by the sensor's static characteristics - * - * - Asking for too many streams of a given format type (2 bayer raw - * streams, for example). - * - * Input parameters: - * - * - width, height, format: Specification for the buffers to be sent through - * this stream. Format is a value from the HAL_PIXEL_FORMAT_* list. If - * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform - * gralloc module will select a format based on the usage flags provided - * by the camera HAL and the consumer of the stream. The camera HAL should - * inspect the buffers handed to it in the register_stream_buffers call to - * obtain the implementation-specific format if necessary. - * - * - stream_ops: A structure of function pointers for obtaining and queuing - * up buffers for this stream. The underlying stream will be configured - * based on the usage and max_buffers outputs. The methods in this - * structure may not be called until after allocate_stream returns. - * - * Output parameters: - * - * - stream_id: An unsigned integer identifying this stream. This value is - * used in incoming requests to identify the stream, and in releasing the - * stream. - * - * - usage: The gralloc usage mask needed by the HAL device for producing - * the requested type of data. This is used in allocating new gralloc - * buffers for the stream buffer queue. - * - * - max_buffers: The maximum number of buffers the HAL device may need to - * have dequeued at the same time. The device may not dequeue more buffers - * than this value at the same time. - * - */ - int (*allocate_stream)( - const struct camera2_device *, - // inputs - uint32_t width, - uint32_t height, - int format, - const camera2_stream_ops_t *stream_ops, - // outputs - uint32_t *stream_id, - uint32_t *format_actual, // IGNORED, will be removed - uint32_t *usage, - uint32_t *max_buffers); - - /** - * Register buffers for a given stream. This is called after a successful - * allocate_stream call, and before the first request referencing the stream - * is enqueued. This method is intended to allow the HAL device to map or - * otherwise prepare the buffers for later use. num_buffers is guaranteed to - * be at least max_buffers (from allocate_stream), but may be larger. The - * buffers will already be locked for use. At the end of the call, all the - * buffers must be ready to be returned to the queue. If the stream format - * was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL should - * inspect the passed-in buffers here to determine any platform-private - * pixel format information. - */ - int (*register_stream_buffers)( - const struct camera2_device *, - uint32_t stream_id, - int num_buffers, - buffer_handle_t *buffers); - - /** - * Release a stream. Returns an error if called when get_in_progress_count - * is non-zero, or if the stream id is invalid. - */ - int (*release_stream)( - const struct camera2_device *, - uint32_t stream_id); - - /** - * allocate_reprocess_stream: - * - * Allocate a new input stream for use, defined by the output buffer width, - * height, and the pixel format. Returns the new stream's ID, gralloc usage - * flags, and required simultaneously acquirable buffer count, on - * success. Error conditions: - * - * - Requesting a width/height/format combination not listed as - * supported by the sensor's static characteristics - * - * - Asking for too many reprocessing streams to be configured at once. - * - * Input parameters: - * - * - width, height, format: Specification for the buffers to be sent through - * this stream. Format must be a value from the HAL_PIXEL_FORMAT_* list. - * - * - reprocess_stream_ops: A structure of function pointers for acquiring - * and releasing buffers for this stream. The underlying stream will be - * configured based on the usage and max_buffers outputs. - * - * Output parameters: - * - * - stream_id: An unsigned integer identifying this stream. This value is - * used in incoming requests to identify the stream, and in releasing the - * stream. These ids are numbered separately from the input stream ids. - * - * - consumer_usage: The gralloc usage mask needed by the HAL device for - * consuming the requested type of data. This is used in allocating new - * gralloc buffers for the stream buffer queue. - * - * - max_buffers: The maximum number of buffers the HAL device may need to - * have acquired at the same time. The device may not have more buffers - * acquired at the same time than this value. - * - */ - int (*allocate_reprocess_stream)(const struct camera2_device *, - uint32_t width, - uint32_t height, - uint32_t format, - const camera2_stream_in_ops_t *reprocess_stream_ops, - // outputs - uint32_t *stream_id, - uint32_t *consumer_usage, - uint32_t *max_buffers); - - /** - * allocate_reprocess_stream_from_stream: - * - * Allocate a new input stream for use, which will use the buffers allocated - * for an existing output stream. That is, after the HAL enqueues a buffer - * onto the output stream, it may see that same buffer handed to it from - * this input reprocessing stream. After the HAL releases the buffer back to - * the reprocessing stream, it will be returned to the output queue for - * reuse. - * - * Error conditions: - * - * - Using an output stream of unsuitable size/format for the basis of the - * reprocessing stream. - * - * - Attempting to allocatee too many reprocessing streams at once. - * - * Input parameters: - * - * - output_stream_id: The ID of an existing output stream which has - * a size and format suitable for reprocessing. - * - * - reprocess_stream_ops: A structure of function pointers for acquiring - * and releasing buffers for this stream. The underlying stream will use - * the same graphics buffer handles as the output stream uses. - * - * Output parameters: - * - * - stream_id: An unsigned integer identifying this stream. This value is - * used in incoming requests to identify the stream, and in releasing the - * stream. These ids are numbered separately from the input stream ids. - * - * The HAL client must always release the reprocessing stream before it - * releases the output stream it is based on. - * - */ - int (*allocate_reprocess_stream_from_stream)(const struct camera2_device *, - uint32_t output_stream_id, - const camera2_stream_in_ops_t *reprocess_stream_ops, - // outputs - uint32_t *stream_id); - - /** - * Release a reprocessing stream. Returns an error if called when - * get_in_progress_count is non-zero, or if the stream id is not - * valid. - */ - int (*release_reprocess_stream)( - const struct camera2_device *, - uint32_t stream_id); - - /********************************************************************** - * Miscellaneous methods - */ - - /** - * Trigger asynchronous activity. This is used for triggering special - * behaviors of the camera 3A routines when they are in use. See the - * documentation for CAMERA2_TRIGGER_* above for details of the trigger ids - * and their arguments. - */ - int (*trigger_action)(const struct camera2_device *, - uint32_t trigger_id, - int32_t ext1, - int32_t ext2); - - /** - * Notification callback setup - */ - int (*set_notify_callback)(const struct camera2_device *, - camera2_notify_callback notify_cb, - void *user); - - /** - * Get methods to query for vendor extension metadata tag infomation. May - * set ops to NULL if no vendor extension tags are defined. - */ - int (*get_metadata_vendor_tag_ops)(const struct camera2_device*, - vendor_tag_query_ops_t **ops); - - /** - * Dump state of the camera hardware - */ - int (*dump)(const struct camera2_device *, int fd); - - /** - * Get device-instance-specific metadata. This metadata must be constant for - * a single instance of the camera device, but may be different between - * open() calls. The returned camera_metadata pointer must be valid until - * the device close() method is called. - * - * Version information: - * - * CAMERA_DEVICE_API_VERSION_2_0: - * - * Not available. Framework may not access this function pointer. - * - * CAMERA_DEVICE_API_VERSION_2_1: - * - * Valid. Can be called by the framework. - * - */ - int (*get_instance_metadata)(const struct camera2_device *, - camera_metadata **instance_metadata); - -} camera2_device_ops_t; - -/********************************************************************** - * - * Camera device definition - * - */ -typedef struct camera2_device { - /** - * common.version must equal CAMERA_DEVICE_API_VERSION_2_0 to identify - * this device as implementing version 2.0 of the camera device HAL. - */ - hw_device_t common; - camera2_device_ops_t *ops; - void *priv; -} camera2_device_t; - -__END_DECLS - -#endif /* #ifdef ANDROID_INCLUDE_CAMERA2_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/camera3.h b/third_party/android_hardware_libhardware/include/hardware/camera3.h deleted file mode 100644 index 3ef6d6fad..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera3.h +++ /dev/null @@ -1,3077 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_INCLUDE_CAMERA3_H -#define ANDROID_INCLUDE_CAMERA3_H - -#include -#include "camera_common.h" - -/** - * Camera device HAL 3.3 [ CAMERA_DEVICE_API_VERSION_3_3 ] - * - * This is the current recommended version of the camera device HAL. - * - * Supports the android.hardware.Camera API, and as of v3.2, the - * android.hardware.camera2 API in LIMITED or FULL modes. - * - * Camera devices that support this version of the HAL must return - * CAMERA_DEVICE_API_VERSION_3_3 in camera_device_t.common.version and in - * camera_info_t.device_version (from camera_module_t.get_camera_info). - * - * CAMERA_DEVICE_API_VERSION_3_3: - * Camera modules that may contain version 3.3 devices must implement at - * least version 2.2 of the camera module interface (as defined by - * camera_module_t.common.module_api_version). - * - * CAMERA_DEVICE_API_VERSION_3_2: - * Camera modules that may contain version 3.2 devices must implement at - * least version 2.2 of the camera module interface (as defined by - * camera_module_t.common.module_api_version). - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * Camera modules that may contain version 3.1 (or 3.0) devices must - * implement at least version 2.0 of the camera module interface - * (as defined by camera_module_t.common.module_api_version). - * - * See camera_common.h for more versioning details. - * - * Documentation index: - * S1. Version history - * S2. Startup and operation sequencing - * S3. Operational modes - * S4. 3A modes and state machines - * S5. Cropping - * S6. Error management - * S7. Key Performance Indicator (KPI) glossary - * S8. Sample Use Cases - * S9. Notes on Controls and Metadata - * S10. Reprocessing flow and controls - */ - -/** - * S1. Version history: - * - * 1.0: Initial Android camera HAL (Android 4.0) [camera.h]: - * - * - Converted from C++ CameraHardwareInterface abstraction layer. - * - * - Supports android.hardware.Camera API. - * - * 2.0: Initial release of expanded-capability HAL (Android 4.2) [camera2.h]: - * - * - Sufficient for implementing existing android.hardware.Camera API. - * - * - Allows for ZSL queue in camera service layer - * - * - Not tested for any new features such manual capture control, Bayer RAW - * capture, reprocessing of RAW data. - * - * 3.0: First revision of expanded-capability HAL: - * - * - Major version change since the ABI is completely different. No change to - * the required hardware capabilities or operational model from 2.0. - * - * - Reworked input request and stream queue interfaces: Framework calls into - * HAL with next request and stream buffers already dequeued. Sync framework - * support is included, necessary for efficient implementations. - * - * - Moved triggers into requests, most notifications into results. - * - * - Consolidated all callbacks into framework into one structure, and all - * setup methods into a single initialize() call. - * - * - Made stream configuration into a single call to simplify stream - * management. Bidirectional streams replace STREAM_FROM_STREAM construct. - * - * - Limited mode semantics for older/limited hardware devices. - * - * 3.1: Minor revision of expanded-capability HAL: - * - * - configure_streams passes consumer usage flags to the HAL. - * - * - flush call to drop all in-flight requests/buffers as fast as possible. - * - * 3.2: Minor revision of expanded-capability HAL: - * - * - Deprecates get_metadata_vendor_tag_ops. Please use get_vendor_tag_ops - * in camera_common.h instead. - * - * - register_stream_buffers deprecated. All gralloc buffers provided - * by framework to HAL in process_capture_request may be new at any time. - * - * - add partial result support. process_capture_result may be called - * multiple times with a subset of the available result before the full - * result is available. - * - * - add manual template to camera3_request_template. The applications may - * use this template to control the capture settings directly. - * - * - Rework the bidirectional and input stream specifications. - * - * - change the input buffer return path. The buffer is returned in - * process_capture_result instead of process_capture_request. - * - * 3.3: Minor revision of expanded-capability HAL: - * - * - OPAQUE and YUV reprocessing API updates. - * - * - Basic support for depth output buffers. - * - * - Addition of data_space field to camera3_stream_t. - * - * - Addition of rotation field to camera3_stream_t. - * - * - Addition of camera3 stream configuration operation mode to camera3_stream_configuration_t - * - */ - -/** - * S2. Startup and general expected operation sequence: - * - * 1. Framework calls camera_module_t->common.open(), which returns a - * hardware_device_t structure. - * - * 2. Framework inspects the hardware_device_t->version field, and instantiates - * the appropriate handler for that version of the camera hardware device. In - * case the version is CAMERA_DEVICE_API_VERSION_3_0, the device is cast to - * a camera3_device_t. - * - * 3. Framework calls camera3_device_t->ops->initialize() with the framework - * callback function pointers. This will only be called this one time after - * open(), before any other functions in the ops structure are called. - * - * 4. The framework calls camera3_device_t->ops->configure_streams() with a list - * of input/output streams to the HAL device. - * - * 5. <= CAMERA_DEVICE_API_VERSION_3_1: - * - * The framework allocates gralloc buffers and calls - * camera3_device_t->ops->register_stream_buffers() for at least one of the - * output streams listed in configure_streams. The same stream is registered - * only once. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * camera3_device_t->ops->register_stream_buffers() is not called and must - * be NULL. - * - * 6. The framework requests default settings for some number of use cases with - * calls to camera3_device_t->ops->construct_default_request_settings(). This - * may occur any time after step 3. - * - * 7. The framework constructs and sends the first capture request to the HAL, - * with settings based on one of the sets of default settings, and with at - * least one output stream, which has been registered earlier by the - * framework. This is sent to the HAL with - * camera3_device_t->ops->process_capture_request(). The HAL must block the - * return of this call until it is ready for the next request to be sent. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * The buffer_handle_t provided in the camera3_stream_buffer_t array - * in the camera3_capture_request_t may be new and never-before-seen - * by the HAL on any given new request. - * - * 8. The framework continues to submit requests, and call - * construct_default_request_settings to get default settings buffers for - * other use cases. - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * The framework may call register_stream_buffers() at this time for - * not-yet-registered streams. - * - * 9. When the capture of a request begins (sensor starts exposing for the - * capture) or processing a reprocess request begins, the HAL - * calls camera3_callback_ops_t->notify() with the SHUTTER event, including - * the frame number and the timestamp for start of exposure. For a reprocess - * request, the timestamp must be the start of exposure of the input image - * which can be looked up with android.sensor.timestamp from - * camera3_capture_request_t.settings when process_capture_request() is - * called. - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * This notify call must be made before the first call to - * process_capture_result() for that frame number. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * The camera3_callback_ops_t->notify() call with the SHUTTER event should - * be made as early as possible since the framework will be unable to - * deliver gralloc buffers to the application layer (for that frame) until - * it has a valid timestamp for the start of exposure (or the input image's - * start of exposure for a reprocess request). - * - * Both partial metadata results and the gralloc buffers may be sent to the - * framework at any time before or after the SHUTTER event. - * - * 10. After some pipeline delay, the HAL begins to return completed captures to - * the framework with camera3_callback_ops_t->process_capture_result(). These - * are returned in the same order as the requests were submitted. Multiple - * requests can be in flight at once, depending on the pipeline depth of the - * camera HAL device. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * Once a buffer is returned by process_capture_result as part of the - * camera3_stream_buffer_t array, and the fence specified by release_fence - * has been signaled (this is a no-op for -1 fences), the ownership of that - * buffer is considered to be transferred back to the framework. After that, - * the HAL must no longer retain that particular buffer, and the - * framework may clean up the memory for it immediately. - * - * process_capture_result may be called multiple times for a single frame, - * each time with a new disjoint piece of metadata and/or set of gralloc - * buffers. The framework will accumulate these partial metadata results - * into one result. - * - * In particular, it is legal for a process_capture_result to be called - * simultaneously for both a frame N and a frame N+1 as long as the - * above rule holds for gralloc buffers (both input and output). - * - * 11. After some time, the framework may stop submitting new requests, wait for - * the existing captures to complete (all buffers filled, all results - * returned), and then call configure_streams() again. This resets the camera - * hardware and pipeline for a new set of input/output streams. Some streams - * may be reused from the previous configuration; if these streams' buffers - * had already been registered with the HAL, they will not be registered - * again. The framework then continues from step 7, if at least one - * registered output stream remains (otherwise, step 5 is required first). - * - * 12. Alternatively, the framework may call camera3_device_t->common->close() - * to end the camera session. This may be called at any time when no other - * calls from the framework are active, although the call may block until all - * in-flight captures have completed (all results returned, all buffers - * filled). After the close call returns, no more calls to the - * camera3_callback_ops_t functions are allowed from the HAL. Once the - * close() call is underway, the framework may not call any other HAL device - * functions. - * - * 13. In case of an error or other asynchronous event, the HAL must call - * camera3_callback_ops_t->notify() with the appropriate error/event - * message. After returning from a fatal device-wide error notification, the - * HAL should act as if close() had been called on it. However, the HAL must - * either cancel or complete all outstanding captures before calling - * notify(), so that once notify() is called with a fatal error, the - * framework will not receive further callbacks from the device. Methods - * besides close() should return -ENODEV or NULL after the notify() method - * returns from a fatal error message. - */ - -/** - * S3. Operational modes: - * - * The camera 3 HAL device can implement one of two possible operational modes; - * limited and full. Full support is expected from new higher-end - * devices. Limited mode has hardware requirements roughly in line with those - * for a camera HAL device v1 implementation, and is expected from older or - * inexpensive devices. Full is a strict superset of limited, and they share the - * same essential operational flow, as documented above. - * - * The HAL must indicate its level of support with the - * android.info.supportedHardwareLevel static metadata entry, with 0 indicating - * limited mode, and 1 indicating full mode support. - * - * Roughly speaking, limited-mode devices do not allow for application control - * of capture settings (3A control only), high-rate capture of high-resolution - * images, raw sensor readout, or support for YUV output streams above maximum - * recording resolution (JPEG only for large images). - * - * ** Details of limited mode behavior: - * - * - Limited-mode devices do not need to implement accurate synchronization - * between capture request settings and the actual image data - * captured. Instead, changes to settings may take effect some time in the - * future, and possibly not for the same output frame for each settings - * entry. Rapid changes in settings may result in some settings never being - * used for a capture. However, captures that include high-resolution output - * buffers ( > 1080p ) have to use the settings as specified (but see below - * for processing rate). - * - * - Limited-mode devices do not need to support most of the - * settings/result/static info metadata. Specifically, only the following settings - * are expected to be consumed or produced by a limited-mode HAL device: - * - * android.control.aeAntibandingMode (controls and dynamic) - * android.control.aeExposureCompensation (controls and dynamic) - * android.control.aeLock (controls and dynamic) - * android.control.aeMode (controls and dynamic) - * android.control.aeRegions (controls and dynamic) - * android.control.aeTargetFpsRange (controls and dynamic) - * android.control.aePrecaptureTrigger (controls and dynamic) - * android.control.afMode (controls and dynamic) - * android.control.afRegions (controls and dynamic) - * android.control.awbLock (controls and dynamic) - * android.control.awbMode (controls and dynamic) - * android.control.awbRegions (controls and dynamic) - * android.control.captureIntent (controls and dynamic) - * android.control.effectMode (controls and dynamic) - * android.control.mode (controls and dynamic) - * android.control.sceneMode (controls and dynamic) - * android.control.videoStabilizationMode (controls and dynamic) - * android.control.aeAvailableAntibandingModes (static) - * android.control.aeAvailableModes (static) - * android.control.aeAvailableTargetFpsRanges (static) - * android.control.aeCompensationRange (static) - * android.control.aeCompensationStep (static) - * android.control.afAvailableModes (static) - * android.control.availableEffects (static) - * android.control.availableSceneModes (static) - * android.control.availableVideoStabilizationModes (static) - * android.control.awbAvailableModes (static) - * android.control.maxRegions (static) - * android.control.sceneModeOverrides (static) - * android.control.aeState (dynamic) - * android.control.afState (dynamic) - * android.control.awbState (dynamic) - * - * android.flash.mode (controls and dynamic) - * android.flash.info.available (static) - * - * android.info.supportedHardwareLevel (static) - * - * android.jpeg.gpsCoordinates (controls and dynamic) - * android.jpeg.gpsProcessingMethod (controls and dynamic) - * android.jpeg.gpsTimestamp (controls and dynamic) - * android.jpeg.orientation (controls and dynamic) - * android.jpeg.quality (controls and dynamic) - * android.jpeg.thumbnailQuality (controls and dynamic) - * android.jpeg.thumbnailSize (controls and dynamic) - * android.jpeg.availableThumbnailSizes (static) - * android.jpeg.maxSize (static) - * - * android.lens.info.minimumFocusDistance (static) - * - * android.request.id (controls and dynamic) - * - * android.scaler.cropRegion (controls and dynamic) - * android.scaler.availableStreamConfigurations (static) - * android.scaler.availableMinFrameDurations (static) - * android.scaler.availableStallDurations (static) - * android.scaler.availableMaxDigitalZoom (static) - * android.scaler.maxDigitalZoom (static) - * android.scaler.croppingType (static) - * - * android.sensor.orientation (static) - * android.sensor.timestamp (dynamic) - * - * android.statistics.faceDetectMode (controls and dynamic) - * android.statistics.info.availableFaceDetectModes (static) - * android.statistics.faceIds (dynamic) - * android.statistics.faceLandmarks (dynamic) - * android.statistics.faceRectangles (dynamic) - * android.statistics.faceScores (dynamic) - * - * android.sync.frameNumber (dynamic) - * android.sync.maxLatency (static) - * - * - Captures in limited mode that include high-resolution (> 1080p) output - * buffers may block in process_capture_request() until all the output buffers - * have been filled. A full-mode HAL device must process sequences of - * high-resolution requests at the rate indicated in the static metadata for - * that pixel format. The HAL must still call process_capture_result() to - * provide the output; the framework must simply be prepared for - * process_capture_request() to block until after process_capture_result() for - * that request completes for high-resolution captures for limited-mode - * devices. - * - * - Full-mode devices must support below additional capabilities: - * - 30fps at maximum resolution is preferred, more than 20fps is required. - * - Per frame control (android.sync.maxLatency == PER_FRAME_CONTROL). - * - Sensor manual control metadata. See MANUAL_SENSOR defined in - * android.request.availableCapabilities. - * - Post-processing manual control metadata. See MANUAL_POST_PROCESSING defined - * in android.request.availableCapabilities. - * - */ - -/** - * S4. 3A modes and state machines: - * - * While the actual 3A algorithms are up to the HAL implementation, a high-level - * state machine description is defined by the HAL interface, to allow the HAL - * device and the framework to communicate about the current state of 3A, and to - * trigger 3A events. - * - * When the device is opened, all the individual 3A states must be - * STATE_INACTIVE. Stream configuration does not reset 3A. For example, locked - * focus must be maintained across the configure() call. - * - * Triggering a 3A action involves simply setting the relevant trigger entry in - * the settings for the next request to indicate start of trigger. For example, - * the trigger for starting an autofocus scan is setting the entry - * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTROL_AF_TRIGGER_START for one - * request, and cancelling an autofocus scan is triggered by setting - * ANDROID_CONTROL_AF_TRIGGER to ANDROID_CONTRL_AF_TRIGGER_CANCEL. Otherwise, - * the entry will not exist, or be set to ANDROID_CONTROL_AF_TRIGGER_IDLE. Each - * request with a trigger entry set to a non-IDLE value will be treated as an - * independent triggering event. - * - * At the top level, 3A is controlled by the ANDROID_CONTROL_MODE setting, which - * selects between no 3A (ANDROID_CONTROL_MODE_OFF), normal AUTO mode - * (ANDROID_CONTROL_MODE_AUTO), and using the scene mode setting - * (ANDROID_CONTROL_USE_SCENE_MODE). - * - * - In OFF mode, each of the individual AE/AF/AWB modes are effectively OFF, - * and none of the capture controls may be overridden by the 3A routines. - * - * - In AUTO mode, Auto-focus, auto-exposure, and auto-whitebalance all run - * their own independent algorithms, and have their own mode, state, and - * trigger metadata entries, as listed in the next section. - * - * - In USE_SCENE_MODE, the value of the ANDROID_CONTROL_SCENE_MODE entry must - * be used to determine the behavior of 3A routines. In SCENE_MODEs other than - * FACE_PRIORITY, the HAL must override the values of - * ANDROId_CONTROL_AE/AWB/AF_MODE to be the mode it prefers for the selected - * SCENE_MODE. For example, the HAL may prefer SCENE_MODE_NIGHT to use - * CONTINUOUS_FOCUS AF mode. Any user selection of AE/AWB/AF_MODE when scene - * must be ignored for these scene modes. - * - * - For SCENE_MODE_FACE_PRIORITY, the AE/AWB/AF_MODE controls work as in - * ANDROID_CONTROL_MODE_AUTO, but the 3A routines must bias toward metering - * and focusing on any detected faces in the scene. - * - * S4.1. Auto-focus settings and result entries: - * - * Main metadata entries: - * - * ANDROID_CONTROL_AF_MODE: Control for selecting the current autofocus - * mode. Set by the framework in the request settings. - * - * AF_MODE_OFF: AF is disabled; the framework/app directly controls lens - * position. - * - * AF_MODE_AUTO: Single-sweep autofocus. No lens movement unless AF is - * triggered. - * - * AF_MODE_MACRO: Single-sweep up-close autofocus. No lens movement unless - * AF is triggered. - * - * AF_MODE_CONTINUOUS_VIDEO: Smooth continuous focusing, for recording - * video. Triggering immediately locks focus in current - * position. Canceling resumes cotinuous focusing. - * - * AF_MODE_CONTINUOUS_PICTURE: Fast continuous focusing, for - * zero-shutter-lag still capture. Triggering locks focus once currently - * active sweep concludes. Canceling resumes continuous focusing. - * - * AF_MODE_EDOF: Advanced extended depth of field focusing. There is no - * autofocus scan, so triggering one or canceling one has no effect. - * Images are focused automatically by the HAL. - * - * ANDROID_CONTROL_AF_STATE: Dynamic metadata describing the current AF - * algorithm state, reported by the HAL in the result metadata. - * - * AF_STATE_INACTIVE: No focusing has been done, or algorithm was - * reset. Lens is not moving. Always the state for MODE_OFF or MODE_EDOF. - * When the device is opened, it must start in this state. - * - * AF_STATE_PASSIVE_SCAN: A continuous focus algorithm is currently scanning - * for good focus. The lens is moving. - * - * AF_STATE_PASSIVE_FOCUSED: A continuous focus algorithm believes it is - * well focused. The lens is not moving. The HAL may spontaneously leave - * this state. - * - * AF_STATE_PASSIVE_UNFOCUSED: A continuous focus algorithm believes it is - * not well focused. The lens is not moving. The HAL may spontaneously - * leave this state. - * - * AF_STATE_ACTIVE_SCAN: A scan triggered by the user is underway. - * - * AF_STATE_FOCUSED_LOCKED: The AF algorithm believes it is focused. The - * lens is not moving. - * - * AF_STATE_NOT_FOCUSED_LOCKED: The AF algorithm has been unable to - * focus. The lens is not moving. - * - * ANDROID_CONTROL_AF_TRIGGER: Control for starting an autofocus scan, the - * meaning of which is mode- and state- dependent. Set by the framework in - * the request settings. - * - * AF_TRIGGER_IDLE: No current trigger. - * - * AF_TRIGGER_START: Trigger start of AF scan. Effect is mode and state - * dependent. - * - * AF_TRIGGER_CANCEL: Cancel current AF scan if any, and reset algorithm to - * default. - * - * Additional metadata entries: - * - * ANDROID_CONTROL_AF_REGIONS: Control for selecting the regions of the FOV - * that should be used to determine good focus. This applies to all AF - * modes that scan for focus. Set by the framework in the request - * settings. - * - * S4.2. Auto-exposure settings and result entries: - * - * Main metadata entries: - * - * ANDROID_CONTROL_AE_MODE: Control for selecting the current auto-exposure - * mode. Set by the framework in the request settings. - * - * AE_MODE_OFF: Autoexposure is disabled; the user controls exposure, gain, - * frame duration, and flash. - * - * AE_MODE_ON: Standard autoexposure, with flash control disabled. User may - * set flash to fire or to torch mode. - * - * AE_MODE_ON_AUTO_FLASH: Standard autoexposure, with flash on at HAL's - * discretion for precapture and still capture. User control of flash - * disabled. - * - * AE_MODE_ON_ALWAYS_FLASH: Standard autoexposure, with flash always fired - * for capture, and at HAL's discretion for precapture.. User control of - * flash disabled. - * - * AE_MODE_ON_AUTO_FLASH_REDEYE: Standard autoexposure, with flash on at - * HAL's discretion for precapture and still capture. Use a flash burst - * at end of precapture sequence to reduce redeye in the final - * picture. User control of flash disabled. - * - * ANDROID_CONTROL_AE_STATE: Dynamic metadata describing the current AE - * algorithm state, reported by the HAL in the result metadata. - * - * AE_STATE_INACTIVE: Initial AE state after mode switch. When the device is - * opened, it must start in this state. - * - * AE_STATE_SEARCHING: AE is not converged to a good value, and is adjusting - * exposure parameters. - * - * AE_STATE_CONVERGED: AE has found good exposure values for the current - * scene, and the exposure parameters are not changing. HAL may - * spontaneously leave this state to search for better solution. - * - * AE_STATE_LOCKED: AE has been locked with the AE_LOCK control. Exposure - * values are not changing. - * - * AE_STATE_FLASH_REQUIRED: The HAL has converged exposure, but believes - * flash is required for a sufficiently bright picture. Used for - * determining if a zero-shutter-lag frame can be used. - * - * AE_STATE_PRECAPTURE: The HAL is in the middle of a precapture - * sequence. Depending on AE mode, this mode may involve firing the - * flash for metering, or a burst of flash pulses for redeye reduction. - * - * ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER: Control for starting a metering - * sequence before capturing a high-quality image. Set by the framework in - * the request settings. - * - * PRECAPTURE_TRIGGER_IDLE: No current trigger. - * - * PRECAPTURE_TRIGGER_START: Start a precapture sequence. The HAL should - * use the subsequent requests to measure good exposure/white balance - * for an upcoming high-resolution capture. - * - * Additional metadata entries: - * - * ANDROID_CONTROL_AE_LOCK: Control for locking AE controls to their current - * values - * - * ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION: Control for adjusting AE - * algorithm target brightness point. - * - * ANDROID_CONTROL_AE_TARGET_FPS_RANGE: Control for selecting the target frame - * rate range for the AE algorithm. The AE routine cannot change the frame - * rate to be outside these bounds. - * - * ANDROID_CONTROL_AE_REGIONS: Control for selecting the regions of the FOV - * that should be used to determine good exposure levels. This applies to - * all AE modes besides OFF. - * - * S4.3. Auto-whitebalance settings and result entries: - * - * Main metadata entries: - * - * ANDROID_CONTROL_AWB_MODE: Control for selecting the current white-balance - * mode. - * - * AWB_MODE_OFF: Auto-whitebalance is disabled. User controls color matrix. - * - * AWB_MODE_AUTO: Automatic white balance is enabled; 3A controls color - * transform, possibly using more complex transforms than a simple - * matrix. - * - * AWB_MODE_INCANDESCENT: Fixed white balance settings good for indoor - * incandescent (tungsten) lighting, roughly 2700K. - * - * AWB_MODE_FLUORESCENT: Fixed white balance settings good for fluorescent - * lighting, roughly 5000K. - * - * AWB_MODE_WARM_FLUORESCENT: Fixed white balance settings good for - * fluorescent lighting, roughly 3000K. - * - * AWB_MODE_DAYLIGHT: Fixed white balance settings good for daylight, - * roughly 5500K. - * - * AWB_MODE_CLOUDY_DAYLIGHT: Fixed white balance settings good for clouded - * daylight, roughly 6500K. - * - * AWB_MODE_TWILIGHT: Fixed white balance settings good for - * near-sunset/sunrise, roughly 15000K. - * - * AWB_MODE_SHADE: Fixed white balance settings good for areas indirectly - * lit by the sun, roughly 7500K. - * - * ANDROID_CONTROL_AWB_STATE: Dynamic metadata describing the current AWB - * algorithm state, reported by the HAL in the result metadata. - * - * AWB_STATE_INACTIVE: Initial AWB state after mode switch. When the device - * is opened, it must start in this state. - * - * AWB_STATE_SEARCHING: AWB is not converged to a good value, and is - * changing color adjustment parameters. - * - * AWB_STATE_CONVERGED: AWB has found good color adjustment values for the - * current scene, and the parameters are not changing. HAL may - * spontaneously leave this state to search for better solution. - * - * AWB_STATE_LOCKED: AWB has been locked with the AWB_LOCK control. Color - * adjustment values are not changing. - * - * Additional metadata entries: - * - * ANDROID_CONTROL_AWB_LOCK: Control for locking AWB color adjustments to - * their current values. - * - * ANDROID_CONTROL_AWB_REGIONS: Control for selecting the regions of the FOV - * that should be used to determine good color balance. This applies only - * to auto-WB mode. - * - * S4.4. General state machine transition notes - * - * Switching between AF, AE, or AWB modes always resets the algorithm's state - * to INACTIVE. Similarly, switching between CONTROL_MODE or - * CONTROL_SCENE_MODE if CONTROL_MODE == USE_SCENE_MODE resets all the - * algorithm states to INACTIVE. - * - * The tables below are per-mode. - * - * S4.5. AF state machines - * - * when enabling AF or changing AF mode - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| Any | AF mode change| INACTIVE | | - *+--------------------+---------------+--------------------+------------------+ - * - * mode = AF_MODE_OFF or AF_MODE_EDOF - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | | INACTIVE | Never changes | - *+--------------------+---------------+--------------------+------------------+ - * - * mode = AF_MODE_AUTO or AF_MODE_MACRO - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | AF_TRIGGER | ACTIVE_SCAN | Start AF sweep | - *| | | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| ACTIVE_SCAN | AF sweep done | FOCUSED_LOCKED | If AF successful | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| ACTIVE_SCAN | AF sweep done | NOT_FOCUSED_LOCKED | If AF successful | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| ACTIVE_SCAN | AF_CANCEL | INACTIVE | Cancel/reset AF | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | - *+--------------------+---------------+--------------------+------------------+ - *| FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | - *| | | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Cancel/reset AF | - *+--------------------+---------------+--------------------+------------------+ - *| NOT_FOCUSED_LOCKED | AF_TRIGGER | ACTIVE_SCAN | Start new sweep | - *| | | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| All states | mode change | INACTIVE | | - *+--------------------+---------------+--------------------+------------------+ - * - * mode = AF_MODE_CONTINUOUS_VIDEO - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | - *| | new scan | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | - *| | current scan | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | - *| | current scan | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | - *| | | | if focus is good | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | - *| | | | if focus is bad | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | - *| | | | position | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | - *| | new scan | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | - *| | new scan | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | - *+--------------------+---------------+--------------------+------------------+ - *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | - *+--------------------+---------------+--------------------+------------------+ - *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | - *+--------------------+---------------+--------------------+------------------+ - *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | - *+--------------------+---------------+--------------------+------------------+ - * - * mode = AF_MODE_CONTINUOUS_PICTURE - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | HAL initiates | PASSIVE_SCAN | Start AF scan | - *| | new scan | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | AF_TRIGGER | NOT_FOCUSED_LOCKED | AF state query | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | HAL completes | PASSIVE_FOCUSED | End AF scan | - *| | current scan | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | HAL fails | PASSIVE_UNFOCUSED | End AF scan | - *| | current scan | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | AF_TRIGGER | FOCUSED_LOCKED | Eventual trans. | - *| | | | once focus good | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | AF_TRIGGER | NOT_FOCUSED_LOCKED | Eventual trans. | - *| | | | if cannot focus | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_SCAN | AF_CANCEL | INACTIVE | Reset lens | - *| | | | position | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_FOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | - *| | new scan | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_UNFOCUSED | HAL initiates | PASSIVE_SCAN | Start AF scan | - *| | new scan | | Lens now moving | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_FOCUSED | AF_TRIGGER | FOCUSED_LOCKED | Immediate trans. | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| PASSIVE_UNFOCUSED | AF_TRIGGER | NOT_FOCUSED_LOCKED | Immediate trans. | - *| | | | Lens now locked | - *+--------------------+---------------+--------------------+------------------+ - *| FOCUSED_LOCKED | AF_TRIGGER | FOCUSED_LOCKED | No effect | - *+--------------------+---------------+--------------------+------------------+ - *| FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | - *+--------------------+---------------+--------------------+------------------+ - *| NOT_FOCUSED_LOCKED | AF_TRIGGER | NOT_FOCUSED_LOCKED | No effect | - *+--------------------+---------------+--------------------+------------------+ - *| NOT_FOCUSED_LOCKED | AF_CANCEL | INACTIVE | Restart AF scan | - *+--------------------+---------------+--------------------+------------------+ - * - * S4.6. AE and AWB state machines - * - * The AE and AWB state machines are mostly identical. AE has additional - * FLASH_REQUIRED and PRECAPTURE states. So rows below that refer to those two - * states should be ignored for the AWB state machine. - * - * when enabling AE/AWB or changing AE/AWB mode - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| Any | mode change | INACTIVE | | - *+--------------------+---------------+--------------------+------------------+ - * - * mode = AE_MODE_OFF / AWB mode not AUTO - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | | INACTIVE | AE/AWB disabled | - *+--------------------+---------------+--------------------+------------------+ - * - * mode = AE_MODE_ON_* / AWB_MODE_AUTO - *| state | trans. cause | new state | notes | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | HAL initiates | SEARCHING | | - *| | AE/AWB scan | | | - *+--------------------+---------------+--------------------+------------------+ - *| INACTIVE | AE/AWB_LOCK | LOCKED | values locked | - *| | on | | | - *+--------------------+---------------+--------------------+------------------+ - *| SEARCHING | HAL finishes | CONVERGED | good values, not | - *| | AE/AWB scan | | changing | - *+--------------------+---------------+--------------------+------------------+ - *| SEARCHING | HAL finishes | FLASH_REQUIRED | converged but too| - *| | AE scan | | dark w/o flash | - *+--------------------+---------------+--------------------+------------------+ - *| SEARCHING | AE/AWB_LOCK | LOCKED | values locked | - *| | on | | | - *+--------------------+---------------+--------------------+------------------+ - *| CONVERGED | HAL initiates | SEARCHING | values locked | - *| | AE/AWB scan | | | - *+--------------------+---------------+--------------------+------------------+ - *| CONVERGED | AE/AWB_LOCK | LOCKED | values locked | - *| | on | | | - *+--------------------+---------------+--------------------+------------------+ - *| FLASH_REQUIRED | HAL initiates | SEARCHING | values locked | - *| | AE/AWB scan | | | - *+--------------------+---------------+--------------------+------------------+ - *| FLASH_REQUIRED | AE/AWB_LOCK | LOCKED | values locked | - *| | on | | | - *+--------------------+---------------+--------------------+------------------+ - *| LOCKED | AE/AWB_LOCK | SEARCHING | values not good | - *| | off | | after unlock | - *+--------------------+---------------+--------------------+------------------+ - *| LOCKED | AE/AWB_LOCK | CONVERGED | values good | - *| | off | | after unlock | - *+--------------------+---------------+--------------------+------------------+ - *| LOCKED | AE_LOCK | FLASH_REQUIRED | exposure good, | - *| | off | | but too dark | - *+--------------------+---------------+--------------------+------------------+ - *| All AE states | PRECAPTURE_ | PRECAPTURE | Start precapture | - *| | START | | sequence | - *+--------------------+---------------+--------------------+------------------+ - *| PRECAPTURE | Sequence done.| CONVERGED | Ready for high- | - *| | AE_LOCK off | | quality capture | - *+--------------------+---------------+--------------------+------------------+ - *| PRECAPTURE | Sequence done.| LOCKED | Ready for high- | - *| | AE_LOCK on | | quality capture | - *+--------------------+---------------+--------------------+------------------+ - * - */ - -/** - * S5. Cropping: - * - * Cropping of the full pixel array (for digital zoom and other use cases where - * a smaller FOV is desirable) is communicated through the - * ANDROID_SCALER_CROP_REGION setting. This is a per-request setting, and can - * change on a per-request basis, which is critical for implementing smooth - * digital zoom. - * - * The region is defined as a rectangle (x, y, width, height), with (x, y) - * describing the top-left corner of the rectangle. The rectangle is defined on - * the coordinate system of the sensor active pixel array, with (0,0) being the - * top-left pixel of the active pixel array. Therefore, the width and height - * cannot be larger than the dimensions reported in the - * ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY static info field. The minimum allowed - * width and height are reported by the HAL through the - * ANDROID_SCALER_MAX_DIGITAL_ZOOM static info field, which describes the - * maximum supported zoom factor. Therefore, the minimum crop region width and - * height are: - * - * {width, height} = - * { floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[0] / - * ANDROID_SCALER_MAX_DIGITAL_ZOOM), - * floor(ANDROID_SENSOR_ACTIVE_PIXEL_ARRAY[1] / - * ANDROID_SCALER_MAX_DIGITAL_ZOOM) } - * - * If the crop region needs to fulfill specific requirements (for example, it - * needs to start on even coordinates, and its width/height needs to be even), - * the HAL must do the necessary rounding and write out the final crop region - * used in the output result metadata. Similarly, if the HAL implements video - * stabilization, it must adjust the result crop region to describe the region - * actually included in the output after video stabilization is applied. In - * general, a camera-using application must be able to determine the field of - * view it is receiving based on the crop region, the dimensions of the image - * sensor, and the lens focal length. - * - * It is assumed that the cropping is applied after raw to other color space - * conversion. Raw streams (RAW16 and RAW_OPAQUE) don't have this conversion stage, - * and are not croppable. Therefore, the crop region must be ignored by the HAL - * for raw streams. - * - * Since the crop region applies to all non-raw streams, which may have different aspect - * ratios than the crop region, the exact sensor region used for each stream may - * be smaller than the crop region. Specifically, each stream should maintain - * square pixels and its aspect ratio by minimally further cropping the defined - * crop region. If the stream's aspect ratio is wider than the crop region, the - * stream should be further cropped vertically, and if the stream's aspect ratio - * is narrower than the crop region, the stream should be further cropped - * horizontally. - * - * In all cases, the stream crop must be centered within the full crop region, - * and each stream is only either cropped horizontally or vertical relative to - * the full crop region, never both. - * - * For example, if two streams are defined, a 640x480 stream (4:3 aspect), and a - * 1280x720 stream (16:9 aspect), below demonstrates the expected output regions - * for each stream for a few sample crop regions, on a hypothetical 3 MP (2000 x - * 1500 pixel array) sensor. - * - * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) - * - * 640x480 stream crop: (500, 375, 1000, 750) (equal to crop region) - * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) - * - * 0 1000 2000 - * +---------+---------+---------+----------+ - * | Active pixel array | - * | | - * | | - * + +-------------------+ + 375 - * | | | | - * | O===================O | - * | I 1280x720 stream I | - * + I I + 750 - * | I I | - * | O===================O | - * | | | | - * + +-------------------+ + 1125 - * | Crop region, 640x480 stream | - * | | - * | | - * +---------+---------+---------+----------+ 1500 - * - * Crop region: (500, 375, 1333, 750) (16:9 aspect ratio) - * - * 640x480 stream crop: (666, 375, 1000, 750) (marked with =) - * 1280x720 stream crop: (500, 375, 1333, 750) (equal to crop region) - * - * 0 1000 2000 - * +---------+---------+---------+----------+ - * | Active pixel array | - * | | - * | | - * + +---O==================O---+ + 375 - * | | I 640x480 stream I | | - * | | I I | | - * | | I I | | - * + | I I | + 750 - * | | I I | | - * | | I I | | - * | | I I | | - * + +---O==================O---+ + 1125 - * | Crop region, 1280x720 stream | - * | | - * | | - * +---------+---------+---------+----------+ 1500 - * - * Crop region: (500, 375, 750, 750) (1:1 aspect ratio) - * - * 640x480 stream crop: (500, 469, 750, 562) (marked with =) - * 1280x720 stream crop: (500, 543, 750, 414) (marged with #) - * - * 0 1000 2000 - * +---------+---------+---------+----------+ - * | Active pixel array | - * | | - * | | - * + +--------------+ + 375 - * | O==============O | - * | ################ | - * | # # | - * + # # + 750 - * | # # | - * | ################ 1280x720 | - * | O==============O 640x480 | - * + +--------------+ + 1125 - * | Crop region | - * | | - * | | - * +---------+---------+---------+----------+ 1500 - * - * And a final example, a 1024x1024 square aspect ratio stream instead of the - * 480p stream: - * - * Crop region: (500, 375, 1000, 750) (4:3 aspect ratio) - * - * 1024x1024 stream crop: (625, 375, 750, 750) (marked with #) - * 1280x720 stream crop: (500, 469, 1000, 562) (marked with =) - * - * 0 1000 2000 - * +---------+---------+---------+----------+ - * | Active pixel array | - * | | - * | 1024x1024 stream | - * + +--###############--+ + 375 - * | | # # | | - * | O===================O | - * | I 1280x720 stream I | - * + I I + 750 - * | I I | - * | O===================O | - * | | # # | | - * + +--###############--+ + 1125 - * | Crop region | - * | | - * | | - * +---------+---------+---------+----------+ 1500 - * - */ - -/** - * S6. Error management: - * - * Camera HAL device ops functions that have a return value will all return - * -ENODEV / NULL in case of a serious error. This means the device cannot - * continue operation, and must be closed by the framework. Once this error is - * returned by some method, or if notify() is called with ERROR_DEVICE, only - * the close() method can be called successfully. All other methods will return - * -ENODEV / NULL. - * - * If a device op is called in the wrong sequence, for example if the framework - * calls configure_streams() is called before initialize(), the device must - * return -ENOSYS from the call, and do nothing. - * - * Transient errors in image capture must be reported through notify() as follows: - * - * - The failure of an entire capture to occur must be reported by the HAL by - * calling notify() with ERROR_REQUEST. Individual errors for the result - * metadata or the output buffers must not be reported in this case. - * - * - If the metadata for a capture cannot be produced, but some image buffers - * were filled, the HAL must call notify() with ERROR_RESULT. - * - * - If an output image buffer could not be filled, but either the metadata was - * produced or some other buffers were filled, the HAL must call notify() with - * ERROR_BUFFER for each failed buffer. - * - * In each of these transient failure cases, the HAL must still call - * process_capture_result, with valid output and input (if an input buffer was - * submitted) buffer_handle_t. If the result metadata could not be produced, it - * should be NULL. If some buffers could not be filled, they must be returned with - * process_capture_result in the error state, their release fences must be set to - * the acquire fences passed by the framework, or -1 if they have been waited on by - * the HAL already. - * - * Invalid input arguments result in -EINVAL from the appropriate methods. In - * that case, the framework must act as if that call had never been made. - * - */ - -/** - * S7. Key Performance Indicator (KPI) glossary: - * - * This includes some critical definitions that are used by KPI metrics. - * - * Pipeline Latency: - * For a given capture request, the duration from the framework calling - * process_capture_request to the HAL sending capture result and all buffers - * back by process_capture_result call. To make the Pipeline Latency measure - * independent of frame rate, it is measured by frame count. - * - * For example, when frame rate is 30 (fps), the frame duration (time interval - * between adjacent frame capture time) is 33 (ms). - * If it takes 5 frames for framework to get the result and buffers back for - * a given request, then the Pipeline Latency is 5 (frames), instead of - * 5 x 33 = 165 (ms). - * - * The Pipeline Latency is determined by android.request.pipelineDepth and - * android.request.pipelineMaxDepth, see their definitions for more details. - * - */ - -/** - * S8. Sample Use Cases: - * - * This includes some typical use case examples the camera HAL may support. - * - * S8.1 Zero Shutter Lag (ZSL) with CAMERA3_STREAM_BIDIRECTIONAL stream. - * - * For this use case, the bidirectional stream will be used by the framework as follows: - * - * 1. The framework includes a buffer from this stream as output buffer in a - * request as normal. - * - * 2. Once the HAL device returns a filled output buffer to the framework, - * the framework may do one of two things with the filled buffer: - * - * 2. a. The framework uses the filled data, and returns the now-used buffer - * to the stream queue for reuse. This behavior exactly matches the - * OUTPUT type of stream. - * - * 2. b. The framework wants to reprocess the filled data, and uses the - * buffer as an input buffer for a request. Once the HAL device has - * used the reprocessing buffer, it then returns it to the - * framework. The framework then returns the now-used buffer to the - * stream queue for reuse. - * - * 3. The HAL device will be given the buffer again as an output buffer for - * a request at some future point. - * - * For ZSL use case, the pixel format for bidirectional stream will be - * HAL_PIXEL_FORMAT_RAW_OPAQUE or HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED if it - * is listed in android.scaler.availableInputOutputFormatsMap. When - * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, the gralloc - * usage flags for the consumer endpoint will be set to GRALLOC_USAGE_HW_CAMERA_ZSL. - * A configuration stream list that has BIDIRECTIONAL stream used as input, will - * usually also have a distinct OUTPUT stream to get the reprocessing data. For example, - * for the ZSL use case, the stream list might be configured with the following: - * - * - A HAL_PIXEL_FORMAT_RAW_OPAQUE bidirectional stream is used - * as input. - * - And a HAL_PIXEL_FORMAT_BLOB (JPEG) output stream. - * - * S8.2 ZSL (OPAQUE) reprocessing with CAMERA3_STREAM_INPUT stream. - * - * CAMERA_DEVICE_API_VERSION_3_3: - * When OPAQUE_REPROCESSING capability is supported by the camera device, the INPUT stream - * can be used for application/framework implemented use case like Zero Shutter Lag (ZSL). - * This kind of stream will be used by the framework as follows: - * - * 1. Application/framework configures an opaque (RAW or YUV based) format output stream that is - * used to produce the ZSL output buffers. The stream pixel format will be - * HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. - * - * 2. Application/framework configures an opaque format input stream that is used to - * send the reprocessing ZSL buffers to the HAL. The stream pixel format will - * also be HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED. - * - * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the - * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. - * - * 4. Application/framework picks a ZSL buffer from the ZSL output stream when a ZSL capture is - * issued by the application, and sends the data back as an input buffer in a - * reprocessing request, then sends to the HAL for reprocessing. - * - * 5. The HAL sends back the output YUV/JPEG result to framework. - * - * The HAL can select the actual opaque buffer format and configure the ISP pipeline - * appropriately based on the HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED format and - * the gralloc usage flag GRALLOC_USAGE_HW_CAMERA_ZSL. - - * S8.3 YUV reprocessing with CAMERA3_STREAM_INPUT stream. - * - * When YUV reprocessing is supported by the HAL, the INPUT stream - * can be used for the YUV reprocessing use cases like lucky-shot and image fusion. - * This kind of stream will be used by the framework as follows: - * - * 1. Application/framework configures an YCbCr_420 format output stream that is - * used to produce the output buffers. - * - * 2. Application/framework configures an YCbCr_420 format input stream that is used to - * send the reprocessing YUV buffers to the HAL. - * - * 3. Application/framework configures a YUV/JPEG output stream that is used to receive the - * reprocessed data. The stream pixel format will be YCbCr_420/HAL_PIXEL_FORMAT_BLOB. - * - * 4. Application/framework processes the output buffers (could be as simple as picking - * an output buffer directly) from the output stream when a capture is issued, and sends - * the data back as an input buffer in a reprocessing request, then sends to the HAL - * for reprocessing. - * - * 5. The HAL sends back the output YUV/JPEG result to framework. - * - */ - -/** - * S9. Notes on Controls and Metadata - * - * This section contains notes about the interpretation and usage of various metadata tags. - * - * S9.1 HIGH_QUALITY and FAST modes. - * - * Many camera post-processing blocks may be listed as having HIGH_QUALITY, - * FAST, and OFF operating modes. These blocks will typically also have an - * 'available modes' tag representing which of these operating modes are - * available on a given device. The general policy regarding implementing - * these modes is as follows: - * - * 1. Operating mode controls of hardware blocks that cannot be disabled - * must not list OFF in their corresponding 'available modes' tags. - * - * 2. OFF will always be included in their corresponding 'available modes' - * tag if it is possible to disable that hardware block. - * - * 3. FAST must always be included in the 'available modes' tags for all - * post-processing blocks supported on the device. If a post-processing - * block also has a slower and higher quality operating mode that does - * not meet the framerate requirements for FAST mode, HIGH_QUALITY should - * be included in the 'available modes' tag to represent this operating - * mode. - */ - -/** - * S10. Reprocessing flow and controls - * - * This section describes the OPAQUE and YUV reprocessing flow and controls. OPAQUE reprocessing - * uses an opaque format that is not directly application-visible, and the application can - * only select some of the output buffers and send back to HAL for reprocessing, while YUV - * reprocessing gives the application opportunity to process the buffers before reprocessing. - * - * S8 gives the stream configurations for the typical reprocessing uses cases, - * this section specifies the buffer flow and controls in more details. - * - * S10.1 OPAQUE (typically for ZSL use case) reprocessing flow and controls - * - * For OPAQUE reprocessing (e.g. ZSL) use case, after the application creates the specific - * output and input streams, runtime buffer flow and controls are specified as below: - * - * 1. Application starts output streaming by sending repeating requests for output - * opaque buffers and preview. The buffers are held by an application - * maintained circular buffer. The requests are based on CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG - * capture template, which should have all necessary settings that guarantee output - * frame rate is not slowed down relative to sensor output frame rate. - * - * 2. When a capture is issued, the application selects one output buffer based - * on application buffer selection logic, e.g. good AE and AF statistics etc. - * Application then creates an reprocess request based on the capture result associated - * with this selected buffer. The selected output buffer is now added to this reprocess - * request as an input buffer, the output buffer of this reprocess request should be - * either JPEG output buffer or YUV output buffer, or both, depending on the application - * choice. - * - * 3. Application then alters the reprocess settings to get best image quality. The HAL must - * support and only support below controls if the HAL support OPAQUE_REPROCESSING capability: - * - android.jpeg.* (if JPEG buffer is included as one of the output) - * - android.noiseReduction.mode (change to HIGH_QUALITY if it is supported) - * - android.edge.mode (change to HIGH_QUALITY if it is supported) - * All other controls must be ignored by the HAL. - * 4. HAL processed the input buffer and return the output buffers in the capture results - * as normal. - * - * S10.2 YUV reprocessing flow and controls - * - * The YUV reprocessing buffer flow is similar as OPAQUE reprocessing, with below difference: - * - * 1. Application may want to have finer granularity control of the intermediate YUV images - * (before reprocessing). For example, application may choose - * - android.noiseReduction.mode == MINIMAL - * to make sure the no YUV domain noise reduction has applied to the output YUV buffers, - * then it can do its own advanced noise reduction on them. For OPAQUE reprocessing case, this - * doesn't matter, as long as the final reprocessed image has the best quality. - * 2. Application may modify the YUV output buffer data. For example, for image fusion use - * case, where multiple output images are merged together to improve the signal-to-noise - * ratio (SNR). The input buffer may be generated from multiple buffers by the application. - * To avoid excessive amount of noise reduction and insufficient amount of edge enhancement - * being applied to the input buffer, the application can hint the HAL how much effective - * exposure time improvement has been done by the application, then the HAL can adjust the - * noise reduction and edge enhancement paramters to get best reprocessed image quality. - * Below tag can be used for this purpose: - * - android.reprocess.effectiveExposureFactor - * The value would be exposure time increase factor applied to the original output image, - * for example, if there are N image merged, the exposure time increase factor would be up - * to sqrt(N). See this tag spec for more details. - * - * S10.3 Reprocessing pipeline characteristics - * - * Reprocessing pipeline has below different characteristics comparing with normal output - * pipeline: - * - * 1. The reprocessing result can be returned ahead of the pending normal output results. But - * the FIFO ordering must be maintained for all reprocessing results. For example, there are - * below requests (A stands for output requests, B stands for reprocessing requests) - * being processed by the HAL: - * A1, A2, A3, A4, B1, A5, B2, A6... - * result of B1 can be returned before A1-A4, but result of B2 must be returned after B1. - * 2. Single input rule: For a given reprocessing request, all output buffers must be from the - * input buffer, rather than sensor output. For example, if a reprocess request include both - * JPEG and preview buffers, all output buffers must be produced from the input buffer - * included by the reprocessing request, rather than sensor. The HAL must not output preview - * buffers from sensor, while output JPEG buffer from the input buffer. - * 3. Input buffer will be from camera output directly (ZSL case) or indirectly(image fusion - * case). For the case where buffer is modified, the size will remain same. The HAL can - * notify CAMERA3_MSG_ERROR_REQUEST if buffer from unknown source is sent. - * 4. Result as reprocessing request: The HAL can expect that a reprocessing request is a copy - * of one of the output results with minor allowed setting changes. The HAL can notify - * CAMERA3_MSG_ERROR_REQUEST if a request from unknown source is issued. - * 5. Output buffers may not be used as inputs across the configure stream boundary, This is - * because an opaque stream like the ZSL output stream may have different actual image size - * inside of the ZSL buffer to save power and bandwidth for smaller resolution JPEG capture. - * The HAL may notify CAMERA3_MSG_ERROR_REQUEST if this case occurs. - * 6. HAL Reprocess requests error reporting during flush should follow the same rule specified - * by flush() method. - * - */ - -__BEGIN_DECLS - -struct camera3_device; - -/********************************************************************** - * - * Camera3 stream and stream buffer definitions. - * - * These structs and enums define the handles and contents of the input and - * output streams connecting the HAL to various framework and application buffer - * consumers. Each stream is backed by a gralloc buffer queue. - * - */ - -/** - * camera3_stream_type_t: - * - * The type of the camera stream, which defines whether the camera HAL device is - * the producer or the consumer for that stream, and how the buffers of the - * stream relate to the other streams. - */ -typedef enum camera3_stream_type { - /** - * This stream is an output stream; the camera HAL device will be - * responsible for filling buffers from this stream with newly captured or - * reprocessed image data. - */ - CAMERA3_STREAM_OUTPUT = 0, - - /** - * This stream is an input stream; the camera HAL device will be responsible - * for reading buffers from this stream and sending them through the camera - * processing pipeline, as if the buffer was a newly captured image from the - * imager. - * - * The pixel format for input stream can be any format reported by - * android.scaler.availableInputOutputFormatsMap. The pixel format of the - * output stream that is used to produce the reprocessing data may be any - * format reported by android.scaler.availableStreamConfigurations. The - * supported input/output stream combinations depends the camera device - * capabilities, see android.scaler.availableInputOutputFormatsMap for - * stream map details. - * - * This kind of stream is generally used to reprocess data into higher - * quality images (that otherwise would cause a frame rate performance - * loss), or to do off-line reprocessing. - * - * CAMERA_DEVICE_API_VERSION_3_3: - * The typical use cases are OPAQUE (typically ZSL) and YUV reprocessing, - * see S8.2, S8.3 and S10 for more details. - */ - CAMERA3_STREAM_INPUT = 1, - - /** - * This stream can be used for input and output. Typically, the stream is - * used as an output stream, but occasionally one already-filled buffer may - * be sent back to the HAL device for reprocessing. - * - * This kind of stream is meant generally for Zero Shutter Lag (ZSL) - * features, where copying the captured image from the output buffer to the - * reprocessing input buffer would be expensive. See S8.1 for more details. - * - * Note that the HAL will always be reprocessing data it produced. - * - */ - CAMERA3_STREAM_BIDIRECTIONAL = 2, - - /** - * Total number of framework-defined stream types - */ - CAMERA3_NUM_STREAM_TYPES - -} camera3_stream_type_t; - -/** - * camera3_stream_rotation_t: - * - * The required counterclockwise rotation of camera stream. - */ -typedef enum camera3_stream_rotation { - /* No rotation */ - CAMERA3_STREAM_ROTATION_0 = 0, - - /* Rotate by 90 degree counterclockwise */ - CAMERA3_STREAM_ROTATION_90 = 1, - - /* Rotate by 180 degree counterclockwise */ - CAMERA3_STREAM_ROTATION_180 = 2, - - /* Rotate by 270 degree counterclockwise */ - CAMERA3_STREAM_ROTATION_270 = 3 -} camera3_stream_rotation_t; - -/** - * camera3_stream_configuration_mode_t: - * - * This defines the general operation mode for the HAL (for a given stream configuration), where - * modes besides NORMAL have different semantics, and usually limit the generality of the API in - * exchange for higher performance in some particular area. - */ -typedef enum camera3_stream_configuration_mode { - /** - * Normal stream configuration operation mode. This is the default camera operation mode, - * where all semantics of HAL APIs and metadata controls apply. - */ - CAMERA3_STREAM_CONFIGURATION_NORMAL_MODE = 0, - - /** - * Special constrained high speed operation mode for devices that can not support high - * speed output in NORMAL mode. All streams in this configuration are operating at high speed - * mode and have different characteristics and limitations to achieve high speed output. - * The NORMAL mode can still be used for high speed output if the HAL can support high speed - * output while satisfying all the semantics of HAL APIs and metadata controls. It is - * recommended for the HAL to support high speed output in NORMAL mode (by advertising the high - * speed FPS ranges in android.control.aeAvailableTargetFpsRanges) if possible. - * - * This mode has below limitations/requirements: - * - * 1. The HAL must support up to 2 streams with sizes reported by - * android.control.availableHighSpeedVideoConfigurations. - * 2. In this mode, the HAL is expected to output up to 120fps or higher. This mode must - * support the targeted FPS range and size configurations reported by - * android.control.availableHighSpeedVideoConfigurations. - * 3. The HAL must support HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED output stream format. - * 4. To achieve efficient high speed streaming, the HAL may have to aggregate - * multiple frames together and send to camera device for processing where the request - * controls are same for all the frames in this batch (batch mode). The HAL must support - * max batch size and the max batch size requirements defined by - * android.control.availableHighSpeedVideoConfigurations. - * 5. In this mode, the HAL must override aeMode, awbMode, and afMode to ON, ON, and - * CONTINUOUS_VIDEO, respectively. All post-processing block mode controls must be - * overridden to be FAST. Therefore, no manual control of capture and post-processing - * parameters is possible. All other controls operate the same as when - * android.control.mode == AUTO. This means that all other android.control.* fields - * must continue to work, such as - * - * android.control.aeTargetFpsRange - * android.control.aeExposureCompensation - * android.control.aeLock - * android.control.awbLock - * android.control.effectMode - * android.control.aeRegions - * android.control.afRegions - * android.control.awbRegions - * android.control.afTrigger - * android.control.aePrecaptureTrigger - * - * Outside of android.control.*, the following controls must work: - * - * android.flash.mode (TORCH mode only, automatic flash for still capture will not work - * since aeMode is ON) - * android.lens.opticalStabilizationMode (if it is supported) - * android.scaler.cropRegion - * android.statistics.faceDetectMode (if it is supported) - * - * For more details about high speed stream requirements, see - * android.control.availableHighSpeedVideoConfigurations and CONSTRAINED_HIGH_SPEED_VIDEO - * capability defined in android.request.availableCapabilities. - * - * This mode only needs to be supported by HALs that include CONSTRAINED_HIGH_SPEED_VIDEO in - * the android.request.availableCapabilities static metadata. - */ - CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE = 1, - - /** - * First value for vendor-defined stream configuration modes. - */ - CAMERA3_VENDOR_STREAM_CONFIGURATION_MODE_START = 0x8000 -} camera3_stream_configuration_mode_t; - -/** - * camera3_stream_t: - * - * A handle to a single camera input or output stream. A stream is defined by - * the framework by its buffer resolution and format, and additionally by the - * HAL with the gralloc usage flags and the maximum in-flight buffer count. - * - * The stream structures are owned by the framework, but pointers to a - * camera3_stream passed into the HAL by configure_streams() are valid until the - * end of the first subsequent configure_streams() call that _does not_ include - * that camera3_stream as an argument, or until the end of the close() call. - * - * All camera3_stream framework-controlled members are immutable once the - * camera3_stream is passed into configure_streams(). The HAL may only change - * the HAL-controlled parameters during a configure_streams() call, except for - * the contents of the private pointer. - * - * If a configure_streams() call returns a non-fatal error, all active streams - * remain valid as if configure_streams() had not been called. - * - * The endpoint of the stream is not visible to the camera HAL device. - * In DEVICE_API_VERSION_3_1, this was changed to share consumer usage flags - * on streams where the camera is a producer (OUTPUT and BIDIRECTIONAL stream - * types) see the usage field below. - */ -typedef struct camera3_stream { - - /***** - * Set by framework before configure_streams() - */ - - /** - * The type of the stream, one of the camera3_stream_type_t values. - */ - int stream_type; - - /** - * The width in pixels of the buffers in this stream - */ - uint32_t width; - - /** - * The height in pixels of the buffers in this stream - */ - uint32_t height; - - /** - * The pixel format for the buffers in this stream. Format is a value from - * the HAL_PIXEL_FORMAT_* list in system/core/include/system/graphics.h, or - * from device-specific headers. - * - * If HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED is used, then the platform - * gralloc module will select a format based on the usage flags provided by - * the camera device and the other endpoint of the stream. - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * The camera HAL device must inspect the buffers handed to it in the - * subsequent register_stream_buffers() call to obtain the - * implementation-specific format details, if necessary. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * register_stream_buffers() won't be called by the framework, so the HAL - * should configure the ISP and sensor pipeline based purely on the sizes, - * usage flags, and formats for the configured streams. - */ - int format; - - /***** - * Set by HAL during configure_streams(). - */ - - /** - * The gralloc usage flags for this stream, as needed by the HAL. The usage - * flags are defined in gralloc.h (GRALLOC_USAGE_*), or in device-specific - * headers. - * - * For output streams, these are the HAL's producer usage flags. For input - * streams, these are the HAL's consumer usage flags. The usage flags from - * the producer and the consumer will be combined together and then passed - * to the platform gralloc HAL module for allocating the gralloc buffers for - * each stream. - * - * Version information: - * - * == CAMERA_DEVICE_API_VERSION_3_0: - * - * No initial value guaranteed when passed via configure_streams(). - * HAL may not use this field as input, and must write over this field - * with its usage flags. - * - * >= CAMERA_DEVICE_API_VERSION_3_1: - * - * For stream_type OUTPUT and BIDIRECTIONAL, when passed via - * configure_streams(), the initial value of this is the consumer's - * usage flags. The HAL may use these consumer flags to decide stream - * configuration. - * For stream_type INPUT, when passed via configure_streams(), the initial - * value of this is 0. - * For all streams passed via configure_streams(), the HAL must write - * over this field with its usage flags. - */ - uint32_t usage; - - /** - * The maximum number of buffers the HAL device may need to have dequeued at - * the same time. The HAL device may not have more buffers in-flight from - * this stream than this value. - */ - uint32_t max_buffers; - - /** - * A handle to HAL-private information for the stream. Will not be inspected - * by the framework code. - */ - void *priv; - - /** - * A field that describes the contents of the buffer. The format and buffer - * dimensions define the memory layout and structure of the stream buffers, - * while dataSpace defines the meaning of the data within the buffer. - * - * For most formats, dataSpace defines the color space of the image data. - * In addition, for some formats, dataSpace indicates whether image- or - * depth-based data is requested. See system/core/include/system/graphics.h - * for details of formats and valid dataSpace values for each format. - * - * Version information: - * - * < CAMERA_DEVICE_API_VERSION_3_3: - * - * Not defined and should not be accessed. dataSpace should be assumed to - * be HAL_DATASPACE_UNKNOWN, and the appropriate color space, etc, should - * be determined from the usage flags and the format. - * - * >= CAMERA_DEVICE_API_VERSION_3_3: - * - * Always set by the camera service. HAL must use this dataSpace to - * configure the stream to the correct colorspace, or to select between - * color and depth outputs if supported. - */ - android_dataspace_t data_space; - - /** - * The required output rotation of the stream, one of - * the camera3_stream_rotation_t values. This must be inspected by HAL along - * with stream width and height. For example, if the rotation is 90 degree - * and the stream width and height is 720 and 1280 respectively, camera service - * will supply buffers of size 720x1280, and HAL should capture a 1280x720 image - * and rotate the image by 90 degree counterclockwise. The rotation field is - * no-op when the stream type is input. Camera HAL must ignore the rotation - * field for an input stream. - * - * <= CAMERA_DEVICE_API_VERSION_3_2: - * - * Not defined and must not be accessed. HAL must not apply any rotation - * on output images. - * - * >= CAMERA_DEVICE_API_VERSION_3_3: - * - * Always set by camera service. HAL must inspect this field during stream - * configuration and returns -EINVAL if HAL cannot perform such rotation. - * HAL must always support CAMERA3_STREAM_ROTATION_0, so a - * configure_streams() call must not fail for unsupported rotation if - * rotation field of all streams is CAMERA3_STREAM_ROTATION_0. - * - */ - int rotation; - - /* reserved for future use */ - void *reserved[7]; - -} camera3_stream_t; - -/** - * camera3_stream_configuration_t: - * - * A structure of stream definitions, used by configure_streams(). This - * structure defines all the output streams and the reprocessing input - * stream for the current camera use case. - */ -typedef struct camera3_stream_configuration { - /** - * The total number of streams requested by the framework. This includes - * both input and output streams. The number of streams will be at least 1, - * and there will be at least one output-capable stream. - */ - uint32_t num_streams; - - /** - * An array of camera stream pointers, defining the input/output - * configuration for the camera HAL device. - * - * At most one input-capable stream may be defined (INPUT or BIDIRECTIONAL) - * in a single configuration. - * - * At least one output-capable stream must be defined (OUTPUT or - * BIDIRECTIONAL). - */ - camera3_stream_t **streams; - - /** - * >= CAMERA_DEVICE_API_VERSION_3_3: - * - * The operation mode of streams in this configuration, one of the value defined in - * camera3_stream_configuration_mode_t. - * The HAL can use this mode as an indicator to set the stream property (e.g., - * camera3_stream->max_buffers) appropriately. For example, if the configuration is - * CAMERA3_STREAM_CONFIGURATION_CONSTRAINED_HIGH_SPEED_MODE, the HAL may want to set aside more - * buffers for batch mode operation (see android.control.availableHighSpeedVideoConfigurations - * for batch mode definition). - * - */ - uint32_t operation_mode; -} camera3_stream_configuration_t; - -/** - * camera3_buffer_status_t: - * - * The current status of a single stream buffer. - */ -typedef enum camera3_buffer_status { - /** - * The buffer is in a normal state, and can be used after waiting on its - * sync fence. - */ - CAMERA3_BUFFER_STATUS_OK = 0, - - /** - * The buffer does not contain valid data, and the data in it should not be - * used. The sync fence must still be waited on before reusing the buffer. - */ - CAMERA3_BUFFER_STATUS_ERROR = 1 - -} camera3_buffer_status_t; - -/** - * camera3_stream_buffer_t: - * - * A single buffer from a camera3 stream. It includes a handle to its parent - * stream, the handle to the gralloc buffer itself, and sync fences - * - * The buffer does not specify whether it is to be used for input or output; - * that is determined by its parent stream type and how the buffer is passed to - * the HAL device. - */ -typedef struct camera3_stream_buffer { - /** - * The handle of the stream this buffer is associated with - */ - camera3_stream_t *stream; - - /** - * The native handle to the buffer - */ - buffer_handle_t *buffer; - - /** - * Current state of the buffer, one of the camera3_buffer_status_t - * values. The framework will not pass buffers to the HAL that are in an - * error state. In case a buffer could not be filled by the HAL, it must - * have its status set to CAMERA3_BUFFER_STATUS_ERROR when returned to the - * framework with process_capture_result(). - */ - int status; - - /** - * The acquire sync fence for this buffer. The HAL must wait on this fence - * fd before attempting to read from or write to this buffer. - * - * The framework may be set to -1 to indicate that no waiting is necessary - * for this buffer. - * - * When the HAL returns an output buffer to the framework with - * process_capture_result(), the acquire_fence must be set to -1. If the HAL - * never waits on the acquire_fence due to an error in filling a buffer, - * when calling process_capture_result() the HAL must set the release_fence - * of the buffer to be the acquire_fence passed to it by the framework. This - * will allow the framework to wait on the fence before reusing the buffer. - * - * For input buffers, the HAL must not change the acquire_fence field during - * the process_capture_request() call. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * When the HAL returns an input buffer to the framework with - * process_capture_result(), the acquire_fence must be set to -1. If the HAL - * never waits on input buffer acquire fence due to an error, the sync - * fences should be handled similarly to the way they are handled for output - * buffers. - */ - int acquire_fence; - - /** - * The release sync fence for this buffer. The HAL must set this fence when - * returning buffers to the framework, or write -1 to indicate that no - * waiting is required for this buffer. - * - * For the output buffers, the fences must be set in the output_buffers - * array passed to process_capture_result(). - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * For the input buffer, the release fence must be set by the - * process_capture_request() call. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * For the input buffer, the fences must be set in the input_buffer - * passed to process_capture_result(). - * - * After signaling the release_fence for this buffer, the HAL - * should not make any further attempts to access this buffer as the - * ownership has been fully transferred back to the framework. - * - * If a fence of -1 was specified then the ownership of this buffer - * is transferred back immediately upon the call of process_capture_result. - */ - int release_fence; - -} camera3_stream_buffer_t; - -/** - * camera3_stream_buffer_set_t: - * - * The complete set of gralloc buffers for a stream. This structure is given to - * register_stream_buffers() to allow the camera HAL device to register/map/etc - * newly allocated stream buffers. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * Deprecated (and not used). In particular, - * register_stream_buffers is also deprecated and will never be invoked. - * - */ -typedef struct camera3_stream_buffer_set { - /** - * The stream handle for the stream these buffers belong to - */ - camera3_stream_t *stream; - - /** - * The number of buffers in this stream. It is guaranteed to be at least - * stream->max_buffers. - */ - uint32_t num_buffers; - - /** - * The array of gralloc buffer handles for this stream. If the stream format - * is set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, the camera HAL device - * should inspect the passed-in buffers to determine any platform-private - * pixel format information. - */ - buffer_handle_t **buffers; - -} camera3_stream_buffer_set_t; - -/** - * camera3_jpeg_blob: - * - * Transport header for compressed JPEG buffers in output streams. - * - * To capture JPEG images, a stream is created using the pixel format - * HAL_PIXEL_FORMAT_BLOB. The buffer size for the stream is calculated by the - * framework, based on the static metadata field android.jpeg.maxSize. Since - * compressed JPEG images are of variable size, the HAL needs to include the - * final size of the compressed image using this structure inside the output - * stream buffer. The JPEG blob ID field must be set to CAMERA3_JPEG_BLOB_ID. - * - * Transport header should be at the end of the JPEG output stream buffer. That - * means the jpeg_blob_id must start at byte[buffer_size - - * sizeof(camera3_jpeg_blob)], where the buffer_size is the size of gralloc buffer. - * Any HAL using this transport header must account for it in android.jpeg.maxSize - * The JPEG data itself starts at the beginning of the buffer and should be - * jpeg_size bytes long. - */ -typedef struct camera3_jpeg_blob { - uint16_t jpeg_blob_id; - uint32_t jpeg_size; -} camera3_jpeg_blob_t; - -enum { - CAMERA3_JPEG_BLOB_ID = 0x00FF -}; - -/********************************************************************** - * - * Message definitions for the HAL notify() callback. - * - * These definitions are used for the HAL notify callback, to signal - * asynchronous events from the HAL device to the Android framework. - * - */ - -/** - * camera3_msg_type: - * - * Indicates the type of message sent, which specifies which member of the - * message union is valid. - * - */ -typedef enum camera3_msg_type { - /** - * An error has occurred. camera3_notify_msg.message.error contains the - * error information. - */ - CAMERA3_MSG_ERROR = 1, - - /** - * The exposure of a given request or processing a reprocess request has - * begun. camera3_notify_msg.message.shutter contains the information - * the capture. - */ - CAMERA3_MSG_SHUTTER = 2, - - /** - * Number of framework message types - */ - CAMERA3_NUM_MESSAGES - -} camera3_msg_type_t; - -/** - * Defined error codes for CAMERA_MSG_ERROR - */ -typedef enum camera3_error_msg_code { - /** - * A serious failure occured. No further frames or buffer streams will - * be produced by the device. Device should be treated as closed. The - * client must reopen the device to use it again. The frame_number field - * is unused. - */ - CAMERA3_MSG_ERROR_DEVICE = 1, - - /** - * An error has occurred in processing a request. No output (metadata or - * buffers) will be produced for this request. The frame_number field - * specifies which request has been dropped. Subsequent requests are - * unaffected, and the device remains operational. - */ - CAMERA3_MSG_ERROR_REQUEST = 2, - - /** - * An error has occurred in producing an output result metadata buffer - * for a request, but output stream buffers for it will still be - * available. Subsequent requests are unaffected, and the device remains - * operational. The frame_number field specifies the request for which - * result metadata won't be available. - */ - CAMERA3_MSG_ERROR_RESULT = 3, - - /** - * An error has occurred in placing an output buffer into a stream for a - * request. The frame metadata and other buffers may still be - * available. Subsequent requests are unaffected, and the device remains - * operational. The frame_number field specifies the request for which the - * buffer was dropped, and error_stream contains a pointer to the stream - * that dropped the frame.u - */ - CAMERA3_MSG_ERROR_BUFFER = 4, - - /** - * Number of error types - */ - CAMERA3_MSG_NUM_ERRORS - -} camera3_error_msg_code_t; - -/** - * camera3_error_msg_t: - * - * Message contents for CAMERA3_MSG_ERROR - */ -typedef struct camera3_error_msg { - /** - * Frame number of the request the error applies to. 0 if the frame number - * isn't applicable to the error. - */ - uint32_t frame_number; - - /** - * Pointer to the stream that had a failure. NULL if the stream isn't - * applicable to the error. - */ - camera3_stream_t *error_stream; - - /** - * The code for this error; one of the CAMERA_MSG_ERROR enum values. - */ - int error_code; - -} camera3_error_msg_t; - -/** - * camera3_shutter_msg_t: - * - * Message contents for CAMERA3_MSG_SHUTTER - */ -typedef struct camera3_shutter_msg { - /** - * Frame number of the request that has begun exposure or reprocessing. - */ - uint32_t frame_number; - - /** - * Timestamp for the start of capture. For a reprocess request, this must - * be input image's start of capture. This must match the capture result - * metadata's sensor exposure start timestamp. - */ - uint64_t timestamp; - -} camera3_shutter_msg_t; - -/** - * camera3_notify_msg_t: - * - * The message structure sent to camera3_callback_ops_t.notify() - */ -typedef struct camera3_notify_msg { - - /** - * The message type. One of camera3_notify_msg_type, or a private extension. - */ - int type; - - union { - /** - * Error message contents. Valid if type is CAMERA3_MSG_ERROR - */ - camera3_error_msg_t error; - - /** - * Shutter message contents. Valid if type is CAMERA3_MSG_SHUTTER - */ - camera3_shutter_msg_t shutter; - - /** - * Generic message contents. Used to ensure a minimum size for custom - * message types. - */ - uint8_t generic[32]; - } message; - -} camera3_notify_msg_t; - -/********************************************************************** - * - * Capture request/result definitions for the HAL process_capture_request() - * method, and the process_capture_result() callback. - * - */ - -/** - * camera3_request_template_t: - * - * Available template types for - * camera3_device_ops.construct_default_request_settings() - */ -typedef enum camera3_request_template { - /** - * Standard camera preview operation with 3A on auto. - */ - CAMERA3_TEMPLATE_PREVIEW = 1, - - /** - * Standard camera high-quality still capture with 3A and flash on auto. - */ - CAMERA3_TEMPLATE_STILL_CAPTURE = 2, - - /** - * Standard video recording plus preview with 3A on auto, torch off. - */ - CAMERA3_TEMPLATE_VIDEO_RECORD = 3, - - /** - * High-quality still capture while recording video. Application will - * include preview, video record, and full-resolution YUV or JPEG streams in - * request. Must not cause stuttering on video stream. 3A on auto. - */ - CAMERA3_TEMPLATE_VIDEO_SNAPSHOT = 4, - - /** - * Zero-shutter-lag mode. Application will request preview and - * full-resolution data for each frame, and reprocess it to JPEG when a - * still image is requested by user. Settings should provide highest-quality - * full-resolution images without compromising preview frame rate. 3A on - * auto. - */ - CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG = 5, - - /** - * A basic template for direct application control of capture - * parameters. All automatic control is disabled (auto-exposure, auto-white - * balance, auto-focus), and post-processing parameters are set to preview - * quality. The manual capture parameters (exposure, sensitivity, etc.) - * are set to reasonable defaults, but should be overridden by the - * application depending on the intended use case. - */ - CAMERA3_TEMPLATE_MANUAL = 6, - - /* Total number of templates */ - CAMERA3_TEMPLATE_COUNT, - - /** - * First value for vendor-defined request templates - */ - CAMERA3_VENDOR_TEMPLATE_START = 0x40000000 - -} camera3_request_template_t; - -/** - * camera3_capture_request_t: - * - * A single request for image capture/buffer reprocessing, sent to the Camera - * HAL device by the framework in process_capture_request(). - * - * The request contains the settings to be used for this capture, and the set of - * output buffers to write the resulting image data in. It may optionally - * contain an input buffer, in which case the request is for reprocessing that - * input buffer instead of capturing a new image with the camera sensor. The - * capture is identified by the frame_number. - * - * In response, the camera HAL device must send a camera3_capture_result - * structure asynchronously to the framework, using the process_capture_result() - * callback. - */ -typedef struct camera3_capture_request { - /** - * The frame number is an incrementing integer set by the framework to - * uniquely identify this capture. It needs to be returned in the result - * call, and is also used to identify the request in asynchronous - * notifications sent to camera3_callback_ops_t.notify(). - */ - uint32_t frame_number; - - /** - * The settings buffer contains the capture and processing parameters for - * the request. As a special case, a NULL settings buffer indicates that the - * settings are identical to the most-recently submitted capture request. A - * NULL buffer cannot be used as the first submitted request after a - * configure_streams() call. - */ - const camera_metadata_t *settings; - - /** - * The input stream buffer to use for this request, if any. - * - * If input_buffer is NULL, then the request is for a new capture from the - * imager. If input_buffer is valid, the request is for reprocessing the - * image contained in input_buffer. - * - * In the latter case, the HAL must set the release_fence of the - * input_buffer to a valid sync fence, or to -1 if the HAL does not support - * sync, before process_capture_request() returns. - * - * The HAL is required to wait on the acquire sync fence of the input buffer - * before accessing it. - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * Any input buffer included here will have been registered with the HAL - * through register_stream_buffers() before its inclusion in a request. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * The buffers will not have been pre-registered with the HAL. - * Subsequent requests may reuse buffers, or provide entirely new buffers. - */ - camera3_stream_buffer_t *input_buffer; - - /** - * The number of output buffers for this capture request. Must be at least - * 1. - */ - uint32_t num_output_buffers; - - /** - * An array of num_output_buffers stream buffers, to be filled with image - * data from this capture/reprocess. The HAL must wait on the acquire fences - * of each stream buffer before writing to them. - * - * The HAL takes ownership of the actual buffer_handle_t entries in - * output_buffers; the framework does not access them until they are - * returned in a camera3_capture_result_t. - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * All the buffers included here will have been registered with the HAL - * through register_stream_buffers() before their inclusion in a request. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * Any or all of the buffers included here may be brand new in this - * request (having never before seen by the HAL). - */ - const camera3_stream_buffer_t *output_buffers; - -} camera3_capture_request_t; - -/** - * camera3_capture_result_t: - * - * The result of a single capture/reprocess by the camera HAL device. This is - * sent to the framework asynchronously with process_capture_result(), in - * response to a single capture request sent to the HAL with - * process_capture_request(). Multiple process_capture_result() calls may be - * performed by the HAL for each request. - * - * Each call, all with the same frame - * number, may contain some subset of the output buffers, and/or the result - * metadata. The metadata may only be provided once for a given frame number; - * all other calls must set the result metadata to NULL. - * - * The result structure contains the output metadata from this capture, and the - * set of output buffers that have been/will be filled for this capture. Each - * output buffer may come with a release sync fence that the framework will wait - * on before reading, in case the buffer has not yet been filled by the HAL. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * The metadata may be provided multiple times for a single frame number. The - * framework will accumulate together the final result set by combining each - * partial result together into the total result set. - * - * If an input buffer is given in a request, the HAL must return it in one of - * the process_capture_result calls, and the call may be to just return the input - * buffer, without metadata and output buffers; the sync fences must be handled - * the same way they are done for output buffers. - * - * - * Performance considerations: - * - * Applications will also receive these partial results immediately, so sending - * partial results is a highly recommended performance optimization to avoid - * the total pipeline latency before sending the results for what is known very - * early on in the pipeline. - * - * A typical use case might be calculating the AF state halfway through the - * pipeline; by sending the state back to the framework immediately, we get a - * 50% performance increase and perceived responsiveness of the auto-focus. - * - */ -typedef struct camera3_capture_result { - /** - * The frame number is an incrementing integer set by the framework in the - * submitted request to uniquely identify this capture. It is also used to - * identify the request in asynchronous notifications sent to - * camera3_callback_ops_t.notify(). - */ - uint32_t frame_number; - - /** - * The result metadata for this capture. This contains information about the - * final capture parameters, the state of the capture and post-processing - * hardware, the state of the 3A algorithms, if enabled, and the output of - * any enabled statistics units. - * - * Only one call to process_capture_result() with a given frame_number may - * include the result metadata. All other calls for the same frame_number - * must set this to NULL. - * - * If there was an error producing the result metadata, result must be an - * empty metadata buffer, and notify() must be called with ERROR_RESULT. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * Multiple calls to process_capture_result() with a given frame_number - * may include the result metadata. - * - * Partial metadata submitted should not include any metadata key returned - * in a previous partial result for a given frame. Each new partial result - * for that frame must also set a distinct partial_result value. - * - * If notify has been called with ERROR_RESULT, all further partial - * results for that frame are ignored by the framework. - */ - const camera_metadata_t *result; - - /** - * The number of output buffers returned in this result structure. Must be - * less than or equal to the matching capture request's count. If this is - * less than the buffer count in the capture request, at least one more call - * to process_capture_result with the same frame_number must be made, to - * return the remaining output buffers to the framework. This may only be - * zero if the structure includes valid result metadata or an input buffer - * is returned in this result. - */ - uint32_t num_output_buffers; - - /** - * The handles for the output stream buffers for this capture. They may not - * yet be filled at the time the HAL calls process_capture_result(); the - * framework will wait on the release sync fences provided by the HAL before - * reading the buffers. - * - * The HAL must set the stream buffer's release sync fence to a valid sync - * fd, or to -1 if the buffer has already been filled. - * - * If the HAL encounters an error while processing the buffer, and the - * buffer is not filled, the buffer's status field must be set to - * CAMERA3_BUFFER_STATUS_ERROR. If the HAL did not wait on the acquire fence - * before encountering the error, the acquire fence should be copied into - * the release fence, to allow the framework to wait on the fence before - * reusing the buffer. - * - * The acquire fence must be set to -1 for all output buffers. If - * num_output_buffers is zero, this may be NULL. In that case, at least one - * more process_capture_result call must be made by the HAL to provide the - * output buffers. - * - * When process_capture_result is called with a new buffer for a frame, - * all previous frames' buffers for that corresponding stream must have been - * already delivered (the fences need not have yet been signaled). - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * Gralloc buffers for a frame may be sent to framework before the - * corresponding SHUTTER-notify. - * - * Performance considerations: - * - * Buffers delivered to the framework will not be dispatched to the - * application layer until a start of exposure timestamp has been received - * via a SHUTTER notify() call. It is highly recommended to - * dispatch that call as early as possible. - */ - const camera3_stream_buffer_t *output_buffers; - - /** - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * The handle for the input stream buffer for this capture. It may not - * yet be consumed at the time the HAL calls process_capture_result(); the - * framework will wait on the release sync fences provided by the HAL before - * reusing the buffer. - * - * The HAL should handle the sync fences the same way they are done for - * output_buffers. - * - * Only one input buffer is allowed to be sent per request. Similarly to - * output buffers, the ordering of returned input buffers must be - * maintained by the HAL. - * - * Performance considerations: - * - * The input buffer should be returned as early as possible. If the HAL - * supports sync fences, it can call process_capture_result to hand it back - * with sync fences being set appropriately. If the sync fences are not - * supported, the buffer can only be returned when it is consumed, which - * may take long time; the HAL may choose to copy this input buffer to make - * the buffer return sooner. - */ - const camera3_stream_buffer_t *input_buffer; - - /** - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * In order to take advantage of partial results, the HAL must set the - * static metadata android.request.partialResultCount to the number of - * partial results it will send for each frame. - * - * Each new capture result with a partial result must set - * this field (partial_result) to a distinct inclusive value between - * 1 and android.request.partialResultCount. - * - * HALs not wishing to take advantage of this feature must not - * set an android.request.partialResultCount or partial_result to a value - * other than 1. - * - * This value must be set to 0 when a capture result contains buffers only - * and no metadata. - */ - uint32_t partial_result; - -} camera3_capture_result_t; - -/********************************************************************** - * - * Callback methods for the HAL to call into the framework. - * - * These methods are used to return metadata and image buffers for a completed - * or failed captures, and to notify the framework of asynchronous events such - * as errors. - * - * The framework will not call back into the HAL from within these callbacks, - * and these calls will not block for extended periods. - * - */ -typedef struct camera3_callback_ops { - - /** - * process_capture_result: - * - * Send results from a completed capture to the framework. - * process_capture_result() may be invoked multiple times by the HAL in - * response to a single capture request. This allows, for example, the - * metadata and low-resolution buffers to be returned in one call, and - * post-processed JPEG buffers in a later call, once it is available. Each - * call must include the frame number of the request it is returning - * metadata or buffers for. - * - * A component (buffer or metadata) of the complete result may only be - * included in one process_capture_result call. A buffer for each stream, - * and the result metadata, must be returned by the HAL for each request in - * one of the process_capture_result calls, even in case of errors producing - * some of the output. A call to process_capture_result() with neither - * output buffers or result metadata is not allowed. - * - * The order of returning metadata and buffers for a single result does not - * matter, but buffers for a given stream must be returned in FIFO order. So - * the buffer for request 5 for stream A must always be returned before the - * buffer for request 6 for stream A. This also applies to the result - * metadata; the metadata for request 5 must be returned before the metadata - * for request 6. - * - * However, different streams are independent of each other, so it is - * acceptable and expected that the buffer for request 5 for stream A may be - * returned after the buffer for request 6 for stream B is. And it is - * acceptable that the result metadata for request 6 for stream B is - * returned before the buffer for request 5 for stream A is. - * - * The HAL retains ownership of result structure, which only needs to be - * valid to access during this call. The framework will copy whatever it - * needs before this call returns. - * - * The output buffers do not need to be filled yet; the framework will wait - * on the stream buffer release sync fence before reading the buffer - * data. Therefore, this method should be called by the HAL as soon as - * possible, even if some or all of the output buffers are still in - * being filled. The HAL must include valid release sync fences into each - * output_buffers stream buffer entry, or -1 if that stream buffer is - * already filled. - * - * If the result buffer cannot be constructed for a request, the HAL should - * return an empty metadata buffer, but still provide the output buffers and - * their sync fences. In addition, notify() must be called with an - * ERROR_RESULT message. - * - * If an output buffer cannot be filled, its status field must be set to - * STATUS_ERROR. In addition, notify() must be called with a ERROR_BUFFER - * message. - * - * If the entire capture has failed, then this method still needs to be - * called to return the output buffers to the framework. All the buffer - * statuses should be STATUS_ERROR, and the result metadata should be an - * empty buffer. In addition, notify() must be called with a ERROR_REQUEST - * message. In this case, individual ERROR_RESULT/ERROR_BUFFER messages - * should not be sent. - * - * Performance requirements: - * - * This is a non-blocking call. The framework will return this call in 5ms. - * - * The pipeline latency (see S7 for definition) should be less than or equal to - * 4 frame intervals, and must be less than or equal to 8 frame intervals. - * - */ - void (*process_capture_result)(const struct camera3_callback_ops *, - const camera3_capture_result_t *result); - - /** - * notify: - * - * Asynchronous notification callback from the HAL, fired for various - * reasons. Only for information independent of frame capture, or that - * require specific timing. The ownership of the message structure remains - * with the HAL, and the msg only needs to be valid for the duration of this - * call. - * - * Multiple threads may call notify() simultaneously. - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * The notification for the start of exposure for a given request must be - * sent by the HAL before the first call to process_capture_result() for - * that request is made. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * Buffers delivered to the framework will not be dispatched to the - * application layer until a start of exposure timestamp (or input image's - * start of exposure timestamp for a reprocess request) has been received - * via a SHUTTER notify() call. It is highly recommended to dispatch this - * call as early as possible. - * - * ------------------------------------------------------------------------ - * Performance requirements: - * - * This is a non-blocking call. The framework will return this call in 5ms. - */ - void (*notify)(const struct camera3_callback_ops *, - const camera3_notify_msg_t *msg); - -} camera3_callback_ops_t; - -/********************************************************************** - * - * Camera device operations - * - */ -typedef struct camera3_device_ops { - - /** - * initialize: - * - * One-time initialization to pass framework callback function pointers to - * the HAL. Will be called once after a successful open() call, before any - * other functions are called on the camera3_device_ops structure. - * - * Performance requirements: - * - * This should be a non-blocking call. The HAL should return from this call - * in 5ms, and must return from this call in 10ms. - * - * Return values: - * - * 0: On successful initialization - * - * -ENODEV: If initialization fails. Only close() can be called successfully - * by the framework after this. - */ - int (*initialize)(const struct camera3_device *, - const camera3_callback_ops_t *callback_ops); - - /********************************************************************** - * Stream management - */ - - /** - * configure_streams: - * - * CAMERA_DEVICE_API_VERSION_3_0 only: - * - * Reset the HAL camera device processing pipeline and set up new input and - * output streams. This call replaces any existing stream configuration with - * the streams defined in the stream_list. This method will be called at - * least once after initialize() before a request is submitted with - * process_capture_request(). - * - * The stream_list must contain at least one output-capable stream, and may - * not contain more than one input-capable stream. - * - * The stream_list may contain streams that are also in the currently-active - * set of streams (from the previous call to configure_stream()). These - * streams will already have valid values for usage, max_buffers, and the - * private pointer. - * - * If such a stream has already had its buffers registered, - * register_stream_buffers() will not be called again for the stream, and - * buffers from the stream can be immediately included in input requests. - * - * If the HAL needs to change the stream configuration for an existing - * stream due to the new configuration, it may rewrite the values of usage - * and/or max_buffers during the configure call. - * - * The framework will detect such a change, and will then reallocate the - * stream buffers, and call register_stream_buffers() again before using - * buffers from that stream in a request. - * - * If a currently-active stream is not included in stream_list, the HAL may - * safely remove any references to that stream. It will not be reused in a - * later configure() call by the framework, and all the gralloc buffers for - * it will be freed after the configure_streams() call returns. - * - * The stream_list structure is owned by the framework, and may not be - * accessed once this call completes. The address of an individual - * camera3_stream_t structure will remain valid for access by the HAL until - * the end of the first configure_stream() call which no longer includes - * that camera3_stream_t in the stream_list argument. The HAL may not change - * values in the stream structure outside of the private pointer, except for - * the usage and max_buffers members during the configure_streams() call - * itself. - * - * If the stream is new, the usage, max_buffer, and private pointer fields - * of the stream structure will all be set to 0. The HAL device must set - * these fields before the configure_streams() call returns. These fields - * are then used by the framework and the platform gralloc module to - * allocate the gralloc buffers for each stream. - * - * Before such a new stream can have its buffers included in a capture - * request, the framework will call register_stream_buffers() with that - * stream. However, the framework is not required to register buffers for - * _all_ streams before submitting a request. This allows for quick startup - * of (for example) a preview stream, with allocation for other streams - * happening later or concurrently. - * - * ------------------------------------------------------------------------ - * CAMERA_DEVICE_API_VERSION_3_1 only: - * - * Reset the HAL camera device processing pipeline and set up new input and - * output streams. This call replaces any existing stream configuration with - * the streams defined in the stream_list. This method will be called at - * least once after initialize() before a request is submitted with - * process_capture_request(). - * - * The stream_list must contain at least one output-capable stream, and may - * not contain more than one input-capable stream. - * - * The stream_list may contain streams that are also in the currently-active - * set of streams (from the previous call to configure_stream()). These - * streams will already have valid values for usage, max_buffers, and the - * private pointer. - * - * If such a stream has already had its buffers registered, - * register_stream_buffers() will not be called again for the stream, and - * buffers from the stream can be immediately included in input requests. - * - * If the HAL needs to change the stream configuration for an existing - * stream due to the new configuration, it may rewrite the values of usage - * and/or max_buffers during the configure call. - * - * The framework will detect such a change, and will then reallocate the - * stream buffers, and call register_stream_buffers() again before using - * buffers from that stream in a request. - * - * If a currently-active stream is not included in stream_list, the HAL may - * safely remove any references to that stream. It will not be reused in a - * later configure() call by the framework, and all the gralloc buffers for - * it will be freed after the configure_streams() call returns. - * - * The stream_list structure is owned by the framework, and may not be - * accessed once this call completes. The address of an individual - * camera3_stream_t structure will remain valid for access by the HAL until - * the end of the first configure_stream() call which no longer includes - * that camera3_stream_t in the stream_list argument. The HAL may not change - * values in the stream structure outside of the private pointer, except for - * the usage and max_buffers members during the configure_streams() call - * itself. - * - * If the stream is new, max_buffer, and private pointer fields of the - * stream structure will all be set to 0. The usage will be set to the - * consumer usage flags. The HAL device must set these fields before the - * configure_streams() call returns. These fields are then used by the - * framework and the platform gralloc module to allocate the gralloc - * buffers for each stream. - * - * Before such a new stream can have its buffers included in a capture - * request, the framework will call register_stream_buffers() with that - * stream. However, the framework is not required to register buffers for - * _all_ streams before submitting a request. This allows for quick startup - * of (for example) a preview stream, with allocation for other streams - * happening later or concurrently. - * - * ------------------------------------------------------------------------ - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * Reset the HAL camera device processing pipeline and set up new input and - * output streams. This call replaces any existing stream configuration with - * the streams defined in the stream_list. This method will be called at - * least once after initialize() before a request is submitted with - * process_capture_request(). - * - * The stream_list must contain at least one output-capable stream, and may - * not contain more than one input-capable stream. - * - * The stream_list may contain streams that are also in the currently-active - * set of streams (from the previous call to configure_stream()). These - * streams will already have valid values for usage, max_buffers, and the - * private pointer. - * - * If the HAL needs to change the stream configuration for an existing - * stream due to the new configuration, it may rewrite the values of usage - * and/or max_buffers during the configure call. - * - * The framework will detect such a change, and may then reallocate the - * stream buffers before using buffers from that stream in a request. - * - * If a currently-active stream is not included in stream_list, the HAL may - * safely remove any references to that stream. It will not be reused in a - * later configure() call by the framework, and all the gralloc buffers for - * it will be freed after the configure_streams() call returns. - * - * The stream_list structure is owned by the framework, and may not be - * accessed once this call completes. The address of an individual - * camera3_stream_t structure will remain valid for access by the HAL until - * the end of the first configure_stream() call which no longer includes - * that camera3_stream_t in the stream_list argument. The HAL may not change - * values in the stream structure outside of the private pointer, except for - * the usage and max_buffers members during the configure_streams() call - * itself. - * - * If the stream is new, max_buffer, and private pointer fields of the - * stream structure will all be set to 0. The usage will be set to the - * consumer usage flags. The HAL device must set these fields before the - * configure_streams() call returns. These fields are then used by the - * framework and the platform gralloc module to allocate the gralloc - * buffers for each stream. - * - * Newly allocated buffers may be included in a capture request at any time - * by the framework. Once a gralloc buffer is returned to the framework - * with process_capture_result (and its respective release_fence has been - * signaled) the framework may free or reuse it at any time. - * - * ------------------------------------------------------------------------ - * - * Preconditions: - * - * The framework will only call this method when no captures are being - * processed. That is, all results have been returned to the framework, and - * all in-flight input and output buffers have been returned and their - * release sync fences have been signaled by the HAL. The framework will not - * submit new requests for capture while the configure_streams() call is - * underway. - * - * Postconditions: - * - * The HAL device must configure itself to provide maximum possible output - * frame rate given the sizes and formats of the output streams, as - * documented in the camera device's static metadata. - * - * Performance requirements: - * - * This call is expected to be heavyweight and possibly take several hundred - * milliseconds to complete, since it may require resetting and - * reconfiguring the image sensor and the camera processing pipeline. - * Nevertheless, the HAL device should attempt to minimize the - * reconfiguration delay to minimize the user-visible pauses during - * application operational mode changes (such as switching from still - * capture to video recording). - * - * The HAL should return from this call in 500ms, and must return from this - * call in 1000ms. - * - * Return values: - * - * 0: On successful stream configuration - * - * -EINVAL: If the requested stream configuration is invalid. Some examples - * of invalid stream configurations include: - * - * - Including more than 1 input-capable stream (INPUT or - * BIDIRECTIONAL) - * - * - Not including any output-capable streams (OUTPUT or - * BIDIRECTIONAL) - * - * - Including streams with unsupported formats, or an unsupported - * size for that format. - * - * - Including too many output streams of a certain format. - * - * - Unsupported rotation configuration (only applies to - * devices with version >= CAMERA_DEVICE_API_VERSION_3_3) - * - * - Stream sizes/formats don't satisfy the - * camera3_stream_configuration_t->operation_mode requirements for non-NORMAL mode, - * or the requested operation_mode is not supported by the HAL. - * (only applies to devices with version >= CAMERA_DEVICE_API_VERSION_3_3) - * - * Note that the framework submitting an invalid stream - * configuration is not normal operation, since stream - * configurations are checked before configure. An invalid - * configuration means that a bug exists in the framework code, or - * there is a mismatch between the HAL's static metadata and the - * requirements on streams. - * - * -ENODEV: If there has been a fatal error and the device is no longer - * operational. Only close() can be called successfully by the - * framework after this error is returned. - */ - int (*configure_streams)(const struct camera3_device *, - camera3_stream_configuration_t *stream_list); - - /** - * register_stream_buffers: - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * DEPRECATED. This will not be called and must be set to NULL. - * - * <= CAMERA_DEVICE_API_VERSION_3_1: - * - * Register buffers for a given stream with the HAL device. This method is - * called by the framework after a new stream is defined by - * configure_streams, and before buffers from that stream are included in a - * capture request. If the same stream is listed in a subsequent - * configure_streams() call, register_stream_buffers will _not_ be called - * again for that stream. - * - * The framework does not need to register buffers for all configured - * streams before it submits the first capture request. This allows quick - * startup for preview (or similar use cases) while other streams are still - * being allocated. - * - * This method is intended to allow the HAL device to map or otherwise - * prepare the buffers for later use. The buffers passed in will already be - * locked for use. At the end of the call, all the buffers must be ready to - * be returned to the stream. The buffer_set argument is only valid for the - * duration of this call. - * - * If the stream format was set to HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, - * the camera HAL should inspect the passed-in buffers here to determine any - * platform-private pixel format information. - * - * Performance requirements: - * - * This should be a non-blocking call. The HAL should return from this call - * in 1ms, and must return from this call in 5ms. - * - * Return values: - * - * 0: On successful registration of the new stream buffers - * - * -EINVAL: If the stream_buffer_set does not refer to a valid active - * stream, or if the buffers array is invalid. - * - * -ENOMEM: If there was a failure in registering the buffers. The framework - * must consider all the stream buffers to be unregistered, and can - * try to register again later. - * - * -ENODEV: If there is a fatal error, and the device is no longer - * operational. Only close() can be called successfully by the - * framework after this error is returned. - */ - int (*register_stream_buffers)(const struct camera3_device *, - const camera3_stream_buffer_set_t *buffer_set); - - /********************************************************************** - * Request creation and submission - */ - - /** - * construct_default_request_settings: - * - * Create capture settings for standard camera use cases. - * - * The device must return a settings buffer that is configured to meet the - * requested use case, which must be one of the CAMERA3_TEMPLATE_* - * enums. All request control fields must be included. - * - * The HAL retains ownership of this structure, but the pointer to the - * structure must be valid until the device is closed. The framework and the - * HAL may not modify the buffer once it is returned by this call. The same - * buffer may be returned for subsequent calls for the same template, or for - * other templates. - * - * Performance requirements: - * - * This should be a non-blocking call. The HAL should return from this call - * in 1ms, and must return from this call in 5ms. - * - * Return values: - * - * Valid metadata: On successful creation of a default settings - * buffer. - * - * NULL: In case of a fatal error. After this is returned, only - * the close() method can be called successfully by the - * framework. - */ - const camera_metadata_t* (*construct_default_request_settings)( - const struct camera3_device *, - int type); - - /** - * process_capture_request: - * - * Send a new capture request to the HAL. The HAL should not return from - * this call until it is ready to accept the next request to process. Only - * one call to process_capture_request() will be made at a time by the - * framework, and the calls will all be from the same thread. The next call - * to process_capture_request() will be made as soon as a new request and - * its associated buffers are available. In a normal preview scenario, this - * means the function will be called again by the framework almost - * instantly. - * - * The actual request processing is asynchronous, with the results of - * capture being returned by the HAL through the process_capture_result() - * call. This call requires the result metadata to be available, but output - * buffers may simply provide sync fences to wait on. Multiple requests are - * expected to be in flight at once, to maintain full output frame rate. - * - * The framework retains ownership of the request structure. It is only - * guaranteed to be valid during this call. The HAL device must make copies - * of the information it needs to retain for the capture processing. The HAL - * is responsible for waiting on and closing the buffers' fences and - * returning the buffer handles to the framework. - * - * The HAL must write the file descriptor for the input buffer's release - * sync fence into input_buffer->release_fence, if input_buffer is not - * NULL. If the HAL returns -1 for the input buffer release sync fence, the - * framework is free to immediately reuse the input buffer. Otherwise, the - * framework will wait on the sync fence before refilling and reusing the - * input buffer. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * - * The input/output buffers provided by the framework in each request - * may be brand new (having never before seen by the HAL). - * - * ------------------------------------------------------------------------ - * Performance considerations: - * - * Handling a new buffer should be extremely lightweight and there should be - * no frame rate degradation or frame jitter introduced. - * - * This call must return fast enough to ensure that the requested frame - * rate can be sustained, especially for streaming cases (post-processing - * quality settings set to FAST). The HAL should return this call in 1 - * frame interval, and must return from this call in 4 frame intervals. - * - * Return values: - * - * 0: On a successful start to processing the capture request - * - * -EINVAL: If the input is malformed (the settings are NULL when not - * allowed, there are 0 output buffers, etc) and capture processing - * cannot start. Failures during request processing should be - * handled by calling camera3_callback_ops_t.notify(). In case of - * this error, the framework will retain responsibility for the - * stream buffers' fences and the buffer handles; the HAL should - * not close the fences or return these buffers with - * process_capture_result. - * - * -ENODEV: If the camera device has encountered a serious error. After this - * error is returned, only the close() method can be successfully - * called by the framework. - * - */ - int (*process_capture_request)(const struct camera3_device *, - camera3_capture_request_t *request); - - /********************************************************************** - * Miscellaneous methods - */ - - /** - * get_metadata_vendor_tag_ops: - * - * Get methods to query for vendor extension metadata tag information. The - * HAL should fill in all the vendor tag operation methods, or leave ops - * unchanged if no vendor tags are defined. - * - * The definition of vendor_tag_query_ops_t can be found in - * system/media/camera/include/system/camera_metadata.h. - * - * >= CAMERA_DEVICE_API_VERSION_3_2: - * DEPRECATED. This function has been deprecated and should be set to - * NULL by the HAL. Please implement get_vendor_tag_ops in camera_common.h - * instead. - */ - void (*get_metadata_vendor_tag_ops)(const struct camera3_device*, - vendor_tag_query_ops_t* ops); - - /** - * dump: - * - * Print out debugging state for the camera device. This will be called by - * the framework when the camera service is asked for a debug dump, which - * happens when using the dumpsys tool, or when capturing a bugreport. - * - * The passed-in file descriptor can be used to write debugging text using - * dprintf() or write(). The text should be in ASCII encoding only. - * - * Performance requirements: - * - * This must be a non-blocking call. The HAL should return from this call - * in 1ms, must return from this call in 10ms. This call must avoid - * deadlocks, as it may be called at any point during camera operation. - * Any synchronization primitives used (such as mutex locks or semaphores) - * should be acquired with a timeout. - */ - void (*dump)(const struct camera3_device *, int fd); - - /** - * flush: - * - * Flush all currently in-process captures and all buffers in the pipeline - * on the given device. The framework will use this to dump all state as - * quickly as possible in order to prepare for a configure_streams() call. - * - * No buffers are required to be successfully returned, so every buffer - * held at the time of flush() (whether successfully filled or not) may be - * returned with CAMERA3_BUFFER_STATUS_ERROR. Note the HAL is still allowed - * to return valid (CAMERA3_BUFFER_STATUS_OK) buffers during this call, - * provided they are successfully filled. - * - * All requests currently in the HAL are expected to be returned as soon as - * possible. Not-in-process requests should return errors immediately. Any - * interruptible hardware blocks should be stopped, and any uninterruptible - * blocks should be waited on. - * - * flush() may be called concurrently to process_capture_request(), with the expectation that - * process_capture_request will return quickly and the request submitted in that - * process_capture_request call is treated like all other in-flight requests. Due to - * concurrency issues, it is possible that from the HAL's point of view, a - * process_capture_request() call may be started after flush has been invoked but has not - * returned yet. If such a call happens before flush() returns, the HAL should treat the new - * capture request like other in-flight pending requests (see #4 below). - * - * More specifically, the HAL must follow below requirements for various cases: - * - * 1. For captures that are too late for the HAL to cancel/stop, and will be - * completed normally by the HAL; i.e. the HAL can send shutter/notify and - * process_capture_result and buffers as normal. - * - * 2. For pending requests that have not done any processing, the HAL must call notify - * CAMERA3_MSG_ERROR_REQUEST, and return all the output buffers with - * process_capture_result in the error state (CAMERA3_BUFFER_STATUS_ERROR). - * The HAL must not place the release fence into an error state, instead, - * the release fences must be set to the acquire fences passed by the framework, - * or -1 if they have been waited on by the HAL already. This is also the path - * to follow for any captures for which the HAL already called notify() with - * CAMERA3_MSG_SHUTTER but won't be producing any metadata/valid buffers for. - * After CAMERA3_MSG_ERROR_REQUEST, for a given frame, only process_capture_results with - * buffers in CAMERA3_BUFFER_STATUS_ERROR are allowed. No further notifys or - * process_capture_result with non-null metadata is allowed. - * - * 3. For partially completed pending requests that will not have all the output - * buffers or perhaps missing metadata, the HAL should follow below: - * - * 3.1. Call notify with CAMERA3_MSG_ERROR_RESULT if some of the expected result - * metadata (i.e. one or more partial metadata) won't be available for the capture. - * - * 3.2. Call notify with CAMERA3_MSG_ERROR_BUFFER for every buffer that won't - * be produced for the capture. - * - * 3.3 Call notify with CAMERA3_MSG_SHUTTER with the capture timestamp before - * any buffers/metadata are returned with process_capture_result. - * - * 3.4 For captures that will produce some results, the HAL must not call - * CAMERA3_MSG_ERROR_REQUEST, since that indicates complete failure. - * - * 3.5. Valid buffers/metadata should be passed to the framework as normal. - * - * 3.6. Failed buffers should be returned to the framework as described for case 2. - * But failed buffers do not have to follow the strict ordering valid buffers do, - * and may be out-of-order with respect to valid buffers. For example, if buffers - * A, B, C, D, E are sent, D and E are failed, then A, E, B, D, C is an acceptable - * return order. - * - * 3.7. For fully-missing metadata, calling CAMERA3_MSG_ERROR_RESULT is sufficient, no - * need to call process_capture_result with NULL metadata or equivalent. - * - * 4. If a flush() is invoked while a process_capture_request() invocation is active, that - * process call should return as soon as possible. In addition, if a process_capture_request() - * call is made after flush() has been invoked but before flush() has returned, the - * capture request provided by the late process_capture_request call should be treated like - * a pending request in case #2 above. - * - * flush() should only return when there are no more outstanding buffers or - * requests left in the HAL. The framework may call configure_streams (as - * the HAL state is now quiesced) or may issue new requests. - * - * Note that it's sufficient to only support fully-succeeded and fully-failed result cases. - * However, it is highly desirable to support the partial failure cases as well, as it - * could help improve the flush call overall performance. - * - * Performance requirements: - * - * The HAL should return from this call in 100ms, and must return from this - * call in 1000ms. And this call must not be blocked longer than pipeline - * latency (see S7 for definition). - * - * Version information: - * - * only available if device version >= CAMERA_DEVICE_API_VERSION_3_1. - * - * Return values: - * - * 0: On a successful flush of the camera HAL. - * - * -EINVAL: If the input is malformed (the device is not valid). - * - * -ENODEV: If the camera device has encountered a serious error. After this - * error is returned, only the close() method can be successfully - * called by the framework. - */ - int (*flush)(const struct camera3_device *); - - /* reserved for future use */ - void *reserved[8]; -} camera3_device_ops_t; - -/********************************************************************** - * - * Camera device definition - * - */ -typedef struct camera3_device { - /** - * common.version must equal CAMERA_DEVICE_API_VERSION_3_0 to identify this - * device as implementing version 3.0 of the camera device HAL. - * - * Performance requirements: - * - * Camera open (common.module->common.methods->open) should return in 200ms, and must return - * in 500ms. - * Camera close (common.close) should return in 200ms, and must return in 500ms. - * - */ - hw_device_t common; - camera3_device_ops_t *ops; - void *priv; -} camera3_device_t; - -__END_DECLS - -#endif /* #ifdef ANDROID_INCLUDE_CAMERA3_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/camera_common.h b/third_party/android_hardware_libhardware/include/hardware/camera_common.h deleted file mode 100644 index 7658dd406..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/camera_common.h +++ /dev/null @@ -1,916 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -// FIXME: add well-defined names for cameras - -#ifndef ANDROID_INCLUDE_CAMERA_COMMON_H -#define ANDROID_INCLUDE_CAMERA_COMMON_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define CAMERA_HARDWARE_MODULE_ID "camera" - -/** - * Module versioning information for the Camera hardware module, based on - * camera_module_t.common.module_api_version. The two most significant hex - * digits represent the major version, and the two least significant represent - * the minor version. - * - ******************************************************************************* - * Versions: 0.X - 1.X [CAMERA_MODULE_API_VERSION_1_0] - * - * Camera modules that report these version numbers implement the initial - * camera module HAL interface. All camera devices openable through this - * module support only version 1 of the camera device HAL. The device_version - * and static_camera_characteristics fields of camera_info are not valid. Only - * the android.hardware.Camera API can be supported by this module and its - * devices. - * - ******************************************************************************* - * Version: 2.0 [CAMERA_MODULE_API_VERSION_2_0] - * - * Camera modules that report this version number implement the second version - * of the camera module HAL interface. Camera devices openable through this - * module may support either version 1.0 or version 2.0 of the camera device - * HAL interface. The device_version field of camera_info is always valid; the - * static_camera_characteristics field of camera_info is valid if the - * device_version field is 2.0 or higher. - * - ******************************************************************************* - * Version: 2.1 [CAMERA_MODULE_API_VERSION_2_1] - * - * This camera module version adds support for asynchronous callbacks to the - * framework from the camera HAL module, which is used to notify the framework - * about changes to the camera module state. Modules that provide a valid - * set_callbacks() method must report at least this version number. - * - ******************************************************************************* - * Version: 2.2 [CAMERA_MODULE_API_VERSION_2_2] - * - * This camera module version adds vendor tag support from the module, and - * deprecates the old vendor_tag_query_ops that were previously only - * accessible with a device open. - * - ******************************************************************************* - * Version: 2.3 [CAMERA_MODULE_API_VERSION_2_3] - * - * This camera module version adds open legacy camera HAL device support. - * Framework can use it to open the camera device as lower device HAL version - * HAL device if the same device can support multiple device API versions. - * The standard hardware module open call (common.methods->open) continues - * to open the camera device with the latest supported version, which is - * also the version listed in camera_info_t.device_version. - * - ******************************************************************************* - * Version: 2.4 [CAMERA_MODULE_API_VERSION_2_4] - * - * This camera module version adds below API changes: - * - * 1. Torch mode support. The framework can use it to turn on torch mode for - * any camera device that has a flash unit, without opening a camera device. The - * camera device has a higher priority accessing the flash unit than the camera - * module; opening a camera device will turn off the torch if it had been enabled - * through the module interface. When there are any resource conflicts, such as - * open() is called to open a camera device, the camera HAL module must notify the - * framework through the torch mode status callback that the torch mode has been - * turned off. - * - * 2. External camera (e.g. USB hot-plug camera) support. The API updates specify that - * the camera static info is only available when camera is connected and ready to - * use for external hot-plug cameras. Calls to get static info will be invalid - * calls when camera status is not CAMERA_DEVICE_STATUS_PRESENT. The frameworks - * will only count on device status change callbacks to manage the available external - * camera list. - * - * 3. Camera arbitration hints. This module version adds support for explicitly - * indicating the number of camera devices that can be simultaneously opened and used. - * To specify valid combinations of devices, the resource_cost and conflicting_devices - * fields should always be set in the camera_info structure returned by the - * get_camera_info call. - * - * 4. Module initialization method. This will be called by the camera service - * right after the HAL module is loaded, to allow for one-time initialization - * of the HAL. It is called before any other module methods are invoked. - */ - -/** - * Predefined macros for currently-defined version numbers - */ - -/** - * All module versions <= HARDWARE_MODULE_API_VERSION(1, 0xFF) must be treated - * as CAMERA_MODULE_API_VERSION_1_0 - */ -#define CAMERA_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define CAMERA_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) -#define CAMERA_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1) -#define CAMERA_MODULE_API_VERSION_2_2 HARDWARE_MODULE_API_VERSION(2, 2) -#define CAMERA_MODULE_API_VERSION_2_3 HARDWARE_MODULE_API_VERSION(2, 3) -#define CAMERA_MODULE_API_VERSION_2_4 HARDWARE_MODULE_API_VERSION(2, 4) - -#define CAMERA_MODULE_API_VERSION_CURRENT CAMERA_MODULE_API_VERSION_2_4 - -/** - * All device versions <= HARDWARE_DEVICE_API_VERSION(1, 0xFF) must be treated - * as CAMERA_DEVICE_API_VERSION_1_0 - */ -#define CAMERA_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) -#define CAMERA_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 0) -#define CAMERA_DEVICE_API_VERSION_2_1 HARDWARE_DEVICE_API_VERSION(2, 1) -#define CAMERA_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0) -#define CAMERA_DEVICE_API_VERSION_3_1 HARDWARE_DEVICE_API_VERSION(3, 1) -#define CAMERA_DEVICE_API_VERSION_3_2 HARDWARE_DEVICE_API_VERSION(3, 2) -#define CAMERA_DEVICE_API_VERSION_3_3 HARDWARE_DEVICE_API_VERSION(3, 3) - -// Device version 3.3 is current, older HAL camera device versions are not -// recommended for new devices. -#define CAMERA_DEVICE_API_VERSION_CURRENT CAMERA_DEVICE_API_VERSION_3_3 - -/** - * Defined in /system/media/camera/include/system/camera_metadata.h - */ -typedef struct camera_metadata camera_metadata_t; - -typedef struct camera_info { - /** - * The direction that the camera faces to. See system/core/include/system/camera.h - * for camera facing definitions. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT. - * - * CAMERA_MODULE_API_VERSION_2_4 or higher: - * - * It should be CAMERA_FACING_BACK, CAMERA_FACING_FRONT or - * CAMERA_FACING_EXTERNAL. - */ - int facing; - - /** - * The orientation of the camera image. The value is the angle that the - * camera image needs to be rotated clockwise so it shows correctly on the - * display in its natural orientation. It should be 0, 90, 180, or 270. - * - * For example, suppose a device has a naturally tall screen. The - * back-facing camera sensor is mounted in landscape. You are looking at the - * screen. If the top side of the camera sensor is aligned with the right - * edge of the screen in natural orientation, the value should be 90. If the - * top side of a front-facing camera sensor is aligned with the right of the - * screen, the value should be 270. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * Valid in all camera_module versions. - * - * CAMERA_MODULE_API_VERSION_2_4 or higher: - * - * Valid if camera facing is CAMERA_FACING_BACK or CAMERA_FACING_FRONT, - * not valid if camera facing is CAMERA_FACING_EXTERNAL. - */ - int orientation; - - /** - * The value of camera_device_t.common.version. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_1_0: - * - * Not valid. Can be assumed to be CAMERA_DEVICE_API_VERSION_1_0. Do - * not read this field. - * - * CAMERA_MODULE_API_VERSION_2_0 or higher: - * - * Always valid - * - */ - uint32_t device_version; - - /** - * The camera's fixed characteristics, which include all static camera metadata - * specified in system/media/camera/docs/docs.html. This should be a sorted metadata - * buffer, and may not be modified or freed by the caller. The pointer should remain - * valid for the lifetime of the camera module, and values in it may not - * change after it is returned by get_camera_info(). - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_1_0: - * - * Not valid. Extra characteristics are not available. Do not read this - * field. - * - * CAMERA_MODULE_API_VERSION_2_0 or higher: - * - * Valid if device_version >= CAMERA_DEVICE_API_VERSION_2_0. Do not read - * otherwise. - * - */ - const camera_metadata_t *static_camera_characteristics; - - /** - * The total resource "cost" of using this camera, represented as an integer - * value in the range [0, 100] where 100 represents total usage of the shared - * resource that is the limiting bottleneck of the camera subsystem. This may - * be a very rough estimate, and is used as a hint to the camera service to - * determine when to disallow multiple applications from simultaneously - * opening different cameras advertised by the camera service. - * - * The camera service must be able to simultaneously open and use any - * combination of camera devices exposed by the HAL where the sum of - * the resource costs of these cameras is <= 100. For determining cost, - * each camera device must be assumed to be configured and operating at - * the maximally resource-consuming framerate and stream size settings - * available in the configuration settings exposed for that device through - * the camera metadata. - * - * The camera service may still attempt to simultaneously open combinations - * of camera devices with a total resource cost > 100. This may succeed or - * fail. If this succeeds, combinations of configurations that are not - * supported due to resource constraints from having multiple open devices - * should fail during the configure calls. If the total resource cost is - * <= 100, open and configure should never fail for any stream configuration - * settings or other device capabilities that would normally succeed for a - * device when it is the only open camera device. - * - * This field will be used to determine whether background applications are - * allowed to use this camera device while other applications are using other - * camera devices. Note: multiple applications will never be allowed by the - * camera service to simultaneously open the same camera device. - * - * Example use cases: - * - * Ex. 1: Camera Device 0 = Back Camera - * Camera Device 1 = Front Camera - * - Using both camera devices causes a large framerate slowdown due to - * limited ISP bandwidth. - * - * Configuration: - * - * Camera Device 0 - resource_cost = 51 - * conflicting_devices = null - * Camera Device 1 - resource_cost = 51 - * conflicting_devices = null - * - * Result: - * - * Since the sum of the resource costs is > 100, if a higher-priority - * application has either device open, no lower-priority applications will be - * allowed by the camera service to open either device. If a lower-priority - * application is using a device that a higher-priority subsequently attempts - * to open, the lower-priority application will be forced to disconnect the - * the device. - * - * If the highest-priority application chooses, it may still attempt to open - * both devices (since these devices are not listed as conflicting in the - * conflicting_devices fields), but usage of these devices may fail in the - * open or configure calls. - * - * Ex. 2: Camera Device 0 = Left Back Camera - * Camera Device 1 = Right Back Camera - * Camera Device 2 = Combined stereo camera using both right and left - * back camera sensors used by devices 0, and 1 - * Camera Device 3 = Front Camera - * - Due to do hardware constraints, up to two cameras may be open at once. The - * combined stereo camera may never be used at the same time as either of the - * two back camera devices (device 0, 1), and typically requires too much - * bandwidth to use at the same time as the front camera (device 3). - * - * Configuration: - * - * Camera Device 0 - resource_cost = 50 - * conflicting_devices = { 2 } - * Camera Device 1 - resource_cost = 50 - * conflicting_devices = { 2 } - * Camera Device 2 - resource_cost = 100 - * conflicting_devices = { 0, 1 } - * Camera Device 3 - resource_cost = 50 - * conflicting_devices = null - * - * Result: - * - * Based on the conflicting_devices fields, the camera service guarantees that - * the following sets of open devices will never be allowed: { 1, 2 }, { 0, 2 }. - * - * Based on the resource_cost fields, if a high-priority foreground application - * is using camera device 0, a background application would be allowed to open - * camera device 1 or 3 (but would be forced to disconnect it again if the - * foreground application opened another device). - * - * The highest priority application may still attempt to simultaneously open - * devices 0, 2, and 3, but the HAL may fail in open or configure calls for - * this combination. - * - * Ex. 3: Camera Device 0 = Back Camera - * Camera Device 1 = Front Camera - * Camera Device 2 = Low-power Front Camera that uses the same - * sensor as device 1, but only exposes image stream - * resolutions that can be used in low-power mode - * - Using both front cameras (device 1, 2) at the same time is impossible due - * a shared physical sensor. Using the back and "high-power" front camera - * (device 1) may be impossible for some stream configurations due to hardware - * limitations, but the "low-power" front camera option may always be used as - * it has special dedicated hardware. - * - * Configuration: - * - * Camera Device 0 - resource_cost = 100 - * conflicting_devices = null - * Camera Device 1 - resource_cost = 100 - * conflicting_devices = { 2 } - * Camera Device 2 - resource_cost = 0 - * conflicting_devices = { 1 } - * Result: - * - * Based on the conflicting_devices fields, the camera service guarantees that - * the following sets of open devices will never be allowed: { 1, 2 }. - * - * Based on the resource_cost fields, only the highest priority application - * may attempt to open both device 0 and 1 at the same time. If a higher-priority - * application is not using device 1 or 2, a low-priority background application - * may open device 2 (but will be forced to disconnect it if a higher-priority - * application subsequently opens device 1 or 2). - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * Not valid. Can be assumed to be 100. Do not read this field. - * - * CAMERA_MODULE_API_VERSION_2_4 or higher: - * - * Always valid. - */ - int resource_cost; - - /** - * An array of camera device IDs represented as NULL-terminated strings - * indicating other devices that cannot be simultaneously opened while this - * camera device is in use. - * - * This field is intended to be used to indicate that this camera device - * is a composite of several other camera devices, or otherwise has - * hardware dependencies that prohibit simultaneous usage. If there are no - * dependencies, a NULL may be returned in this field to indicate this. - * - * The camera service will never simultaneously open any of the devices - * in this list while this camera device is open. - * - * The strings pointed to in this field will not be cleaned up by the camera - * service, and must remain while this device is plugged in. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * Not valid. Can be assumed to be NULL. Do not read this field. - * - * CAMERA_MODULE_API_VERSION_2_4 or higher: - * - * Always valid. - */ - char** conflicting_devices; - - /** - * The length of the array given in the conflicting_devices field. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * Not valid. Can be assumed to be 0. Do not read this field. - * - * CAMERA_MODULE_API_VERSION_2_4 or higher: - * - * Always valid. - */ - size_t conflicting_devices_length; - -} camera_info_t; - -/** - * camera_device_status_t: - * - * The current status of the camera device, as provided by the HAL through the - * camera_module_callbacks.camera_device_status_change() call. - * - * At module load time, the framework will assume all camera devices are in the - * CAMERA_DEVICE_STATUS_PRESENT state. The HAL should invoke - * camera_module_callbacks::camera_device_status_change to inform the framework - * of any initially NOT_PRESENT devices. - * - * Allowed transitions: - * PRESENT -> NOT_PRESENT - * NOT_PRESENT -> ENUMERATING - * NOT_PRESENT -> PRESENT - * ENUMERATING -> PRESENT - * ENUMERATING -> NOT_PRESENT - */ -typedef enum camera_device_status { - /** - * The camera device is not currently connected, and opening it will return - * failure. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * Calls to get_camera_info must still succeed, and provide the same information - * it would if the camera were connected. - * - * CAMERA_MODULE_API_VERSION_2_4: - * - * The camera device at this status must return -EINVAL for get_camera_info call, - * as the device is not connected. - */ - CAMERA_DEVICE_STATUS_NOT_PRESENT = 0, - - /** - * The camera device is connected, and opening it will succeed. - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * The information returned by get_camera_info cannot change due to this status - * change. By default, the framework will assume all devices are in this state. - * - * CAMERA_MODULE_API_VERSION_2_4: - * - * The information returned by get_camera_info will become valid after a device's - * status changes to this. By default, the framework will assume all devices are in - * this state. - */ - CAMERA_DEVICE_STATUS_PRESENT = 1, - - /** - * The camera device is connected, but it is undergoing an enumeration and - * so opening the device will return -EBUSY. - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * Calls to get_camera_info must still succeed, as if the camera was in the - * PRESENT status. - * - * CAMERA_MODULE_API_VERSION_2_4: - * - * The camera device at this status must return -EINVAL for get_camera_info for call, - * as the device is not ready. - */ - CAMERA_DEVICE_STATUS_ENUMERATING = 2, - -} camera_device_status_t; - -/** - * torch_mode_status_t: - * - * The current status of the torch mode, as provided by the HAL through the - * camera_module_callbacks.torch_mode_status_change() call. - * - * The torch mode status of a camera device is applicable only when the camera - * device is present. The framework will not call set_torch_mode() to turn on - * torch mode of a camera device if the camera device is not present. At module - * load time, the framework will assume torch modes are in the - * TORCH_MODE_STATUS_AVAILABLE_OFF state if the camera device is present and - * android.flash.info.available is reported as true via get_camera_info() call. - * - * The behaviors of the camera HAL module that the framework expects in the - * following situations when a camera device's status changes: - * 1. A previously-disconnected camera device becomes connected. - * After camera_module_callbacks::camera_device_status_change() is invoked - * to inform the framework that the camera device is present, the framework - * will assume the camera device's torch mode is in - * TORCH_MODE_STATUS_AVAILABLE_OFF state. The camera HAL module does not need - * to invoke camera_module_callbacks::torch_mode_status_change() unless the - * flash unit is unavailable to use by set_torch_mode(). - * - * 2. A previously-connected camera becomes disconnected. - * After camera_module_callbacks::camera_device_status_change() is invoked - * to inform the framework that the camera device is not present, the - * framework will not call set_torch_mode() for the disconnected camera - * device until its flash unit becomes available again. The camera HAL - * module does not need to invoke - * camera_module_callbacks::torch_mode_status_change() separately to inform - * that the flash unit has become unavailable. - * - * 3. open() is called to open a camera device. - * The camera HAL module must invoke - * camera_module_callbacks::torch_mode_status_change() for all flash units - * that have entered TORCH_MODE_STATUS_NOT_AVAILABLE state and can not be - * turned on by calling set_torch_mode() anymore due to this open() call. - * open() must not trigger TORCH_MODE_STATUS_AVAILABLE_OFF before - * TORCH_MODE_STATUS_NOT_AVAILABLE for all flash units that have become - * unavailable. - * - * 4. close() is called to close a camera device. - * The camera HAL module must invoke - * camera_module_callbacks::torch_mode_status_change() for all flash units - * that have entered TORCH_MODE_STATUS_AVAILABLE_OFF state and can be turned - * on by calling set_torch_mode() again because of enough resources freed - * up by this close() call. - * - * Note that the framework calling set_torch_mode() successfully must trigger - * TORCH_MODE_STATUS_AVAILABLE_OFF or TORCH_MODE_STATUS_AVAILABLE_ON callback - * for the given camera device. Additionally it must trigger - * TORCH_MODE_STATUS_AVAILABLE_OFF callbacks for other previously-on torch - * modes if HAL cannot keep multiple torch modes on simultaneously. - */ -typedef enum torch_mode_status { - - /** - * The flash unit is no longer available and the torch mode can not be - * turned on by calling set_torch_mode(). If the torch mode is on, it - * will be turned off by HAL before HAL calls torch_mode_status_change(). - */ - TORCH_MODE_STATUS_NOT_AVAILABLE = 0, - - /** - * A torch mode has become off and available to be turned on via - * set_torch_mode(). This may happen in the following - * cases: - * 1. After the resources to turn on the torch mode have become available. - * 2. After set_torch_mode() is called to turn off the torch mode. - * 3. After the framework turned on the torch mode of some other camera - * device and HAL had to turn off the torch modes of any camera devices - * that were previously on. - */ - TORCH_MODE_STATUS_AVAILABLE_OFF = 1, - - /** - * A torch mode has become on and available to be turned off via - * set_torch_mode(). This can happen only after set_torch_mode() is called - * to turn on the torch mode. - */ - TORCH_MODE_STATUS_AVAILABLE_ON = 2, - -} torch_mode_status_t; - -/** - * Callback functions for the camera HAL module to use to inform the framework - * of changes to the camera subsystem. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * Each callback is called only by HAL modules implementing the indicated - * version or higher of the HAL module API interface. - * - * CAMERA_MODULE_API_VERSION_2_1: - * camera_device_status_change() - * - * CAMERA_MODULE_API_VERSION_2_4: - * torch_mode_status_change() - - */ -typedef struct camera_module_callbacks { - - /** - * camera_device_status_change: - * - * Callback to the framework to indicate that the state of a specific camera - * device has changed. At module load time, the framework will assume all - * camera devices are in the CAMERA_DEVICE_STATUS_PRESENT state. The HAL - * must call this method to inform the framework of any initially - * NOT_PRESENT devices. - * - * This callback is added for CAMERA_MODULE_API_VERSION_2_1. - * - * camera_module_callbacks: The instance of camera_module_callbacks_t passed - * to the module with set_callbacks. - * - * camera_id: The ID of the camera device that has a new status. - * - * new_status: The new status code, one of the camera_device_status_t enums, - * or a platform-specific status. - * - */ - void (*camera_device_status_change)(const struct camera_module_callbacks*, - int camera_id, - int new_status); - - /** - * torch_mode_status_change: - * - * Callback to the framework to indicate that the state of the torch mode - * of the flash unit associated with a specific camera device has changed. - * At module load time, the framework will assume the torch modes are in - * the TORCH_MODE_STATUS_AVAILABLE_OFF state if android.flash.info.available - * is reported as true via get_camera_info() call. - * - * This callback is added for CAMERA_MODULE_API_VERSION_2_4. - * - * camera_module_callbacks: The instance of camera_module_callbacks_t - * passed to the module with set_callbacks. - * - * camera_id: The ID of camera device whose flash unit has a new torch mode - * status. - * - * new_status: The new status code, one of the torch_mode_status_t enums. - */ - void (*torch_mode_status_change)(const struct camera_module_callbacks*, - const char* camera_id, - int new_status); - - -} camera_module_callbacks_t; - -typedef struct camera_module { - /** - * Common methods of the camera module. This *must* be the first member of - * camera_module as users of this structure will cast a hw_module_t to - * camera_module pointer in contexts where it's known the hw_module_t - * references a camera_module. - * - * The return values for common.methods->open for camera_module are: - * - * 0: On a successful open of the camera device. - * - * -ENODEV: The camera device cannot be opened due to an internal - * error. - * - * -EINVAL: The input arguments are invalid, i.e. the id is invalid, - * and/or the module is invalid. - * - * -EBUSY: The camera device was already opened for this camera id - * (by using this method or open_legacy), - * regardless of the device HAL version it was opened as. - * - * -EUSERS: The maximal number of camera devices that can be - * opened concurrently were opened already, either by - * this method or the open_legacy method. - * - * All other return values from common.methods->open will be treated as - * -ENODEV. - */ - hw_module_t common; - - /** - * get_number_of_cameras: - * - * Returns the number of camera devices accessible through the camera - * module. The camera devices are numbered 0 through N-1, where N is the - * value returned by this call. The name of the camera device for open() is - * simply the number converted to a string. That is, "0" for camera ID 0, - * "1" for camera ID 1. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_3 or lower: - * - * The value here must be static, and cannot change after the first call - * to this method. - * - * CAMERA_MODULE_API_VERSION_2_4 or higher: - * - * The value here must be static, and must count only built-in cameras, - * which have CAMERA_FACING_BACK or CAMERA_FACING_FRONT camera facing values - * (camera_info.facing). The HAL must not include the external cameras - * (camera_info.facing == CAMERA_FACING_EXTERNAL) into the return value - * of this call. Frameworks will use camera_device_status_change callback - * to manage number of external cameras. - */ - int (*get_number_of_cameras)(void); - - /** - * get_camera_info: - * - * Return the static camera information for a given camera device. This - * information may not change for a camera device. - * - * Return values: - * - * 0: On a successful operation - * - * -ENODEV: The information cannot be provided due to an internal - * error. - * - * -EINVAL: The input arguments are invalid, i.e. the id is invalid, - * and/or the module is invalid. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_2_4 or higher: - * - * When a camera is disconnected, its camera id becomes invalid. Calling this - * this method with this invalid camera id will get -EINVAL and NULL camera - * static metadata (camera_info.static_camera_characteristics). - */ - int (*get_camera_info)(int camera_id, struct camera_info *info); - - /** - * set_callbacks: - * - * Provide callback function pointers to the HAL module to inform framework - * of asynchronous camera module events. The framework will call this - * function once after initial camera HAL module load, after the - * get_number_of_cameras() method is called for the first time, and before - * any other calls to the module. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_1_0, CAMERA_MODULE_API_VERSION_2_0: - * - * Not provided by HAL module. Framework may not call this function. - * - * CAMERA_MODULE_API_VERSION_2_1: - * - * Valid to be called by the framework. - * - * Return values: - * - * 0: On a successful operation - * - * -ENODEV: The operation cannot be completed due to an internal - * error. - * - * -EINVAL: The input arguments are invalid, i.e. the callbacks are - * null - */ - int (*set_callbacks)(const camera_module_callbacks_t *callbacks); - - /** - * get_vendor_tag_ops: - * - * Get methods to query for vendor extension metadata tag information. The - * HAL should fill in all the vendor tag operation methods, or leave ops - * unchanged if no vendor tags are defined. - * - * The vendor_tag_ops structure used here is defined in: - * system/media/camera/include/system/vendor_tags.h - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1: - * Not provided by HAL module. Framework may not call this function. - * - * CAMERA_MODULE_API_VERSION_2_2: - * Valid to be called by the framework. - */ - void (*get_vendor_tag_ops)(vendor_tag_ops_t* ops); - - /** - * open_legacy: - * - * Open a specific legacy camera HAL device if multiple device HAL API - * versions are supported by this camera HAL module. For example, if the - * camera module supports both CAMERA_DEVICE_API_VERSION_1_0 and - * CAMERA_DEVICE_API_VERSION_3_2 device API for the same camera id, - * framework can call this function to open the camera device as - * CAMERA_DEVICE_API_VERSION_1_0 device. - * - * This is an optional method. A Camera HAL module does not need to support - * more than one device HAL version per device, and such modules may return - * -ENOSYS for all calls to this method. For all older HAL device API - * versions that are not supported, it may return -EOPNOTSUPP. When above - * cases occur, The normal open() method (common.methods->open) will be - * used by the framework instead. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2: - * Not provided by HAL module. Framework will not call this function. - * - * CAMERA_MODULE_API_VERSION_2_3: - * Valid to be called by the framework. - * - * Return values: - * - * 0: On a successful open of the camera device. - * - * -ENOSYS This method is not supported. - * - * -EOPNOTSUPP: The requested HAL version is not supported by this method. - * - * -EINVAL: The input arguments are invalid, i.e. the id is invalid, - * and/or the module is invalid. - * - * -EBUSY: The camera device was already opened for this camera id - * (by using this method or common.methods->open method), - * regardless of the device HAL version it was opened as. - * - * -EUSERS: The maximal number of camera devices that can be - * opened concurrently were opened already, either by - * this method or common.methods->open method. - */ - int (*open_legacy)(const struct hw_module_t* module, const char* id, - uint32_t halVersion, struct hw_device_t** device); - - /** - * set_torch_mode: - * - * Turn on or off the torch mode of the flash unit associated with a given - * camera ID. If the operation is successful, HAL must notify the framework - * torch state by invoking - * camera_module_callbacks.torch_mode_status_change() with the new state. - * - * The camera device has a higher priority accessing the flash unit. When - * there are any resource conflicts, such as open() is called to open a - * camera device, HAL module must notify the framework through - * camera_module_callbacks.torch_mode_status_change() that the - * torch mode has been turned off and the torch mode state has become - * TORCH_MODE_STATUS_NOT_AVAILABLE. When resources to turn on torch mode - * become available again, HAL module must notify the framework through - * camera_module_callbacks.torch_mode_status_change() that the torch mode - * state has become TORCH_MODE_STATUS_AVAILABLE_OFF for set_torch_mode() to - * be called. - * - * When the framework calls set_torch_mode() to turn on the torch mode of a - * flash unit, if HAL cannot keep multiple torch modes on simultaneously, - * HAL should turn off the torch mode that was turned on by - * a previous set_torch_mode() call and notify the framework that the torch - * mode state of that flash unit has become TORCH_MODE_STATUS_AVAILABLE_OFF. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: - * Not provided by HAL module. Framework will not call this function. - * - * CAMERA_MODULE_API_VERSION_2_4: - * Valid to be called by the framework. - * - * Return values: - * - * 0: On a successful operation. - * - * -ENOSYS: The camera device does not support this operation. It is - * returned if and only if android.flash.info.available is - * false. - * - * -EBUSY: The camera device is already in use. - * - * -EUSERS: The resources needed to turn on the torch mode are not - * available, typically because other camera devices are - * holding the resources to make using the flash unit not - * possible. - * - * -EINVAL: camera_id is invalid. - * - */ - int (*set_torch_mode)(const char* camera_id, bool enabled); - - /** - * init: - * - * This method is called by the camera service before any other methods - * are invoked, right after the camera HAL library has been successfully - * loaded. It may be left as NULL by the HAL module, if no initialization - * in needed. - * - * It can be used by HAL implementations to perform initialization and - * other one-time operations. - * - * Version information (based on camera_module_t.common.module_api_version): - * - * CAMERA_MODULE_API_VERSION_1_x/2_0/2_1/2_2/2_3: - * Not provided by HAL module. Framework will not call this function. - * - * CAMERA_MODULE_API_VERSION_2_4: - * If not NULL, will always be called by the framework once after the HAL - * module is loaded, before any other HAL module method is called. - * - * Return values: - * - * 0: On a successful operation. - * - * -ENODEV: Initialization cannot be completed due to an internal - * error. The HAL must be assumed to be in a nonfunctional - * state. - * - */ - int (*init)(); - - /* reserved for future use */ - void* reserved[5]; -} camera_module_t; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_CAMERA_COMMON_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/consumerir.h b/third_party/android_hardware_libhardware/include/hardware/consumerir.h deleted file mode 100644 index 15334c111..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/consumerir.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H -#define ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H - -#include -#include -#include -#include - -#define CONSUMERIR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define CONSUMERIR_HARDWARE_MODULE_ID "consumerir" -#define CONSUMERIR_TRANSMITTER "transmitter" - -typedef struct consumerir_freq_range { - int min; - int max; -} consumerir_freq_range_t; - -typedef struct consumerir_module { - /** - * Common methods of the consumer IR module. This *must* be the first member of - * consumerir_module as users of this structure will cast a hw_module_t to - * consumerir_module pointer in contexts where it's known the hw_module_t references a - * consumerir_module. - */ - struct hw_module_t common; -} consumerir_module_t; - -typedef struct consumerir_device { - /** - * Common methods of the consumer IR device. This *must* be the first member of - * consumerir_device as users of this structure will cast a hw_device_t to - * consumerir_device pointer in contexts where it's known the hw_device_t references a - * consumerir_device. - */ - struct hw_device_t common; - - /* - * (*transmit)() is called to by the ConsumerIrService to send an IR pattern - * at a given carrier_freq. - * - * The pattern is alternating series of carrier on and off periods measured in - * microseconds. The carrier should be turned off at the end of a transmit - * even if there are and odd number of entries in the pattern array. - * - * This call should return when the transmit is complete or encounters an error. - * - * returns: 0 on success. A negative error code on error. - */ - int (*transmit)(struct consumerir_device *dev, int carrier_freq, - const int pattern[], int pattern_len); - - /* - * (*get_num_carrier_freqs)() is called by the ConsumerIrService to get the - * number of carrier freqs to allocate space for, which is then filled by - * a subsequent call to (*get_carrier_freqs)(). - * - * returns: the number of ranges on success. A negative error code on error. - */ - int (*get_num_carrier_freqs)(struct consumerir_device *dev); - - /* - * (*get_carrier_freqs)() is called by the ConsumerIrService to enumerate - * which frequencies the IR transmitter supports. The HAL implementation - * should fill an array of consumerir_freq_range structs with the - * appropriate values for the transmitter, up to len elements. - * - * returns: the number of ranges on success. A negative error code on error. - */ - int (*get_carrier_freqs)(struct consumerir_device *dev, - size_t len, consumerir_freq_range_t *ranges); - - /* Reserved for future use. Must be NULL. */ - void* reserved[8 - 3]; -} consumerir_device_t; - -#endif /* ANDROID_INCLUDE_HARDWARE_CONSUMERIR_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/display_defs.h b/third_party/android_hardware_libhardware/include/hardware/display_defs.h deleted file mode 100644 index 669ef78c4..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/display_defs.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_INCLUDE_DISPLAY_DEFS_H -#define ANDROID_INCLUDE_DISPLAY_DEFS_H - -#include -#include - -#include - -__BEGIN_DECLS - -/* Will need to update below enums if hwcomposer_defs.h is updated */ - -/* Extended events for hwc_methods::eventControl() */ -enum { - HWC_EVENT_ORIENTATION = HWC_EVENT_VSYNC + 1 -}; - - -/* Extended hwc_layer_t::compositionType values */ -enum { - /* this layer will be handled in the HWC, using a blit engine */ - HWC_BLIT = 0xFF -}; - -/* Extended hwc_layer_t::flags values - * Flags are set by SurfaceFlinger and read by the HAL - */ -enum { - /* - * HWC_SCREENSHOT_ANIMATOR_LAYER is set by surfaceflinger to indicate - * that this layer is a screenshot animating layer. HWC uses this - * info to disable rotation animation on External Display - */ - HWC_SCREENSHOT_ANIMATOR_LAYER = 0x00000004 -}; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_DISPLAY_DEFS_H*/ diff --git a/third_party/android_hardware_libhardware/include/hardware/fb.h b/third_party/android_hardware_libhardware/include/hardware/fb.h deleted file mode 100644 index 9df94165b..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/fb.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - - -#ifndef ANDROID_FB_INTERFACE_H -#define ANDROID_FB_INTERFACE_H - -#include -#include -#include - -#include - -#include - -__BEGIN_DECLS - -#define GRALLOC_HARDWARE_FB0 "fb0" - -/*****************************************************************************/ - - -/*****************************************************************************/ - -typedef struct framebuffer_device_t { - /** - * Common methods of the framebuffer device. This *must* be the first member of - * framebuffer_device_t as users of this structure will cast a hw_device_t to - * framebuffer_device_t pointer in contexts where it's known the hw_device_t references a - * framebuffer_device_t. - */ - struct hw_device_t common; - - /* flags describing some attributes of the framebuffer */ - const uint32_t flags; - - /* dimensions of the framebuffer in pixels */ - const uint32_t width; - const uint32_t height; - - /* frambuffer stride in pixels */ - const int stride; - - /* framebuffer pixel format */ - const int format; - - /* resolution of the framebuffer's display panel in pixel per inch*/ - const float xdpi; - const float ydpi; - - /* framebuffer's display panel refresh rate in frames per second */ - const float fps; - - /* min swap interval supported by this framebuffer */ - const int minSwapInterval; - - /* max swap interval supported by this framebuffer */ - const int maxSwapInterval; - - /* Number of framebuffers supported*/ - const int numFramebuffers; - - int reserved[7]; - - /* - * requests a specific swap-interval (same definition than EGL) - * - * Returns 0 on success or -errno on error. - */ - int (*setSwapInterval)(struct framebuffer_device_t* window, - int interval); - - /* - * This hook is OPTIONAL. - * - * It is non NULL If the framebuffer driver supports "update-on-demand" - * and the given rectangle is the area of the screen that gets - * updated during (*post)(). - * - * This is useful on devices that are able to DMA only a portion of - * the screen to the display panel, upon demand -- as opposed to - * constantly refreshing the panel 60 times per second, for instance. - * - * Only the area defined by this rectangle is guaranteed to be valid, that - * is, the driver is not allowed to post anything outside of this - * rectangle. - * - * The rectangle evaluated during (*post)() and specifies which area - * of the buffer passed in (*post)() shall to be posted. - * - * return -EINVAL if width or height <=0, or if left or top < 0 - */ - int (*setUpdateRect)(struct framebuffer_device_t* window, - int left, int top, int width, int height); - - /* - * Post to the display (display it on the screen) - * The buffer must have been allocated with the - * GRALLOC_USAGE_HW_FB usage flag. - * buffer must be the same width and height as the display and must NOT - * be locked. - * - * The buffer is shown during the next VSYNC. - * - * If the same buffer is posted again (possibly after some other buffer), - * post() will block until the the first post is completed. - * - * Internally, post() is expected to lock the buffer so that a - * subsequent call to gralloc_module_t::(*lock)() with USAGE_RENDER or - * USAGE_*_WRITE will block until it is safe; that is typically once this - * buffer is shown and another buffer has been posted. - * - * Returns 0 on success or -errno on error. - */ - int (*post)(struct framebuffer_device_t* dev, buffer_handle_t buffer); - - - /* - * The (*compositionComplete)() method must be called after the - * compositor has finished issuing GL commands for client buffers. - */ - - int (*compositionComplete)(struct framebuffer_device_t* dev); - - /* - * This hook is OPTIONAL. - * - * If non NULL it will be caused by SurfaceFlinger on dumpsys - */ - void (*dump)(struct framebuffer_device_t* dev, char *buff, int buff_len); - - /* - * (*enableScreen)() is used to either blank (enable=0) or - * unblank (enable=1) the screen this framebuffer is attached to. - * - * Returns 0 on success or -errno on error. - */ - int (*enableScreen)(struct framebuffer_device_t* dev, int enable); - - void* reserved_proc[6]; - -} framebuffer_device_t; - - -/** convenience API for opening and closing a supported device */ - -static inline int framebuffer_open(const struct hw_module_t* module, - struct framebuffer_device_t** device) { - return module->methods->open(module, - GRALLOC_HARDWARE_FB0, (struct hw_device_t**)device); -} - -static inline int framebuffer_close(struct framebuffer_device_t* device) { - return device->common.close(&device->common); -} - - -__END_DECLS - -#endif // ANDROID_FB_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/fingerprint.h b/third_party/android_hardware_libhardware/include/hardware/fingerprint.h deleted file mode 100644 index ac88c1032..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/fingerprint.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H -#define ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H - -#include - -#define FINGERPRINT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define FINGERPRINT_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0) -#define FINGERPRINT_HARDWARE_MODULE_ID "fingerprint" - -typedef enum fingerprint_msg_type { - FINGERPRINT_ERROR = -1, - FINGERPRINT_ACQUIRED = 1, - FINGERPRINT_TEMPLATE_ENROLLING = 3, - FINGERPRINT_TEMPLATE_REMOVED = 4, - FINGERPRINT_AUTHENTICATED = 5 -} fingerprint_msg_type_t; - -/* - * Fingerprint errors are meant to tell the framework to terminate the current operation and ask - * for the user to correct the situation. These will almost always result in messaging and user - * interaction to correct the problem. - * - * For example, FINGERPRINT_ERROR_CANCELED should follow any acquisition message that results in - * a situation where the current operation can't continue without user interaction. For example, - * if the sensor is dirty during enrollment and no further enrollment progress can be made, - * send FINGERPRINT_ACQUIRED_IMAGER_DIRTY followed by FINGERPRINT_ERROR_CANCELED. - */ -typedef enum fingerprint_error { - FINGERPRINT_ERROR_HW_UNAVAILABLE = 1, /* The hardware has an error that can't be resolved. */ - FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2, /* Bad data; operation can't continue */ - FINGERPRINT_ERROR_TIMEOUT = 3, /* The operation has timed out waiting for user input. */ - FINGERPRINT_ERROR_NO_SPACE = 4, /* No space available to store a template */ - FINGERPRINT_ERROR_CANCELED = 5, /* The current operation can't proceed. See above. */ - FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6, /* fingerprint with given id can't be removed */ - FINGERPRINT_ERROR_VENDOR_BASE = 1000 /* vendor-specific error messages start here */ -} fingerprint_error_t; - -/* - * Fingerprint acquisition info is meant as feedback for the current operation. Anything but - * FINGERPRINT_ACQUIRED_GOOD will be shown to the user as feedback on how to take action on the - * current operation. For example, FINGERPRINT_ACQUIRED_IMAGER_DIRTY can be used to tell the user - * to clean the sensor. If this will cause the current operation to fail, an additional - * FINGERPRINT_ERROR_CANCELED can be sent to stop the operation in progress (e.g. enrollment). - * In general, these messages will result in a "Try again" message. - */ -typedef enum fingerprint_acquired_info { - FINGERPRINT_ACQUIRED_GOOD = 0, - FINGERPRINT_ACQUIRED_PARTIAL = 1, /* sensor needs more data, i.e. longer swipe. */ - FINGERPRINT_ACQUIRED_INSUFFICIENT = 2, /* image doesn't contain enough detail for recognition*/ - FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3, /* sensor needs to be cleaned */ - FINGERPRINT_ACQUIRED_TOO_SLOW = 4, /* mostly swipe-type sensors; not enough data collected */ - FINGERPRINT_ACQUIRED_TOO_FAST = 5, /* for swipe and area sensors; tell user to slow down*/ - FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000 /* vendor-specific acquisition messages start here */ -} fingerprint_acquired_info_t; - -typedef struct fingerprint_finger_id { - uint32_t gid; - uint32_t fid; -} fingerprint_finger_id_t; - -typedef struct fingerprint_enroll { - fingerprint_finger_id_t finger; - /* samples_remaining goes from N (no data collected, but N scans needed) - * to 0 (no more data is needed to build a template). */ - uint32_t samples_remaining; - uint64_t msg; /* Vendor specific message. Used for user guidance */ -} fingerprint_enroll_t; - -typedef struct fingerprint_removed { - fingerprint_finger_id_t finger; -} fingerprint_removed_t; - -typedef struct fingerprint_acquired { - fingerprint_acquired_info_t acquired_info; /* information about the image */ -} fingerprint_acquired_t; - -typedef struct fingerprint_authenticated { - fingerprint_finger_id_t finger; - hw_auth_token_t hat; -} fingerprint_authenticated_t; - -typedef struct fingerprint_msg { - fingerprint_msg_type_t type; - union { - fingerprint_error_t error; - fingerprint_enroll_t enroll; - fingerprint_removed_t removed; - fingerprint_acquired_t acquired; - fingerprint_authenticated_t authenticated; - } data; -} fingerprint_msg_t; - -/* Callback function type */ -typedef void (*fingerprint_notify_t)(const fingerprint_msg_t *msg); - -/* Synchronous operation */ -typedef struct fingerprint_device { - /** - * Common methods of the fingerprint device. This *must* be the first member - * of fingerprint_device as users of this structure will cast a hw_device_t - * to fingerprint_device pointer in contexts where it's known - * the hw_device_t references a fingerprint_device. - */ - struct hw_device_t common; - - /* - * Client provided callback function to receive notifications. - * Do not set by hand, use the function above instead. - */ - fingerprint_notify_t notify; - - /* - * Set notification callback: - * Registers a user function that would receive notifications from the HAL - * The call will block if the HAL state machine is in busy state until HAL - * leaves the busy state. - * - * Function return: 0 if callback function is successfuly registered - * or a negative number in case of error, generally from the errno.h set. - */ - int (*set_notify)(struct fingerprint_device *dev, fingerprint_notify_t notify); - - /* - * Fingerprint pre-enroll enroll request: - * Generates a unique token to upper layers to indicate the start of an enrollment transaction. - * This token will be wrapped by security for verification and passed to enroll() for - * verification before enrollment will be allowed. This is to ensure adding a new fingerprint - * template was preceded by some kind of credential confirmation (e.g. device password). - * - * Function return: 0 if function failed - * otherwise, a uint64_t of token - */ - uint64_t (*pre_enroll)(struct fingerprint_device *dev); - - /* - * Fingerprint enroll request: - * Switches the HAL state machine to collect and store a new fingerprint - * template. Switches back as soon as enroll is complete - * (fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENROLLING && - * fingerprint_msg.data.enroll.samples_remaining == 0) - * or after timeout_sec seconds. - * The fingerprint template will be assigned to the group gid. User has a choice - * to supply the gid or set it to 0 in which case a unique group id will be generated. - * - * Function return: 0 if enrollment process can be successfully started - * or a negative number in case of error, generally from the errno.h set. - * A notify() function may be called indicating the error condition. - */ - int (*enroll)(struct fingerprint_device *dev, const hw_auth_token_t *hat, - uint32_t gid, uint32_t timeout_sec); - - /* - * Finishes the enroll operation and invalidates the pre_enroll() generated challenge. - * This will be called at the end of a multi-finger enrollment session to indicate - * that no more fingers will be added. - * - * Function return: 0 if the request is accepted - * or a negative number in case of error, generally from the errno.h set. - */ - int (*post_enroll)(struct fingerprint_device *dev); - - /* - * get_authenticator_id: - * Returns a token associated with the current fingerprint set. This value will - * change whenever a new fingerprint is enrolled, thus creating a new fingerprint - * set. - * - * Function return: current authenticator id or 0 if function failed. - */ - uint64_t (*get_authenticator_id)(struct fingerprint_device *dev); - - /* - * Cancel pending enroll or authenticate, sending FINGERPRINT_ERROR_CANCELED - * to all running clients. Switches the HAL state machine back to the idle state. - * Unlike enroll_done() doesn't invalidate the pre_enroll() challenge. - * - * Function return: 0 if cancel request is accepted - * or a negative number in case of error, generally from the errno.h set. - */ - int (*cancel)(struct fingerprint_device *dev); - - /* - * Enumerate all the fingerprint templates found in the directory set by - * set_active_group() - * This is a synchronous call. The function takes: - * - A pointer to an array of fingerprint_finger_id_t. - * - The size of the array provided, in fingerprint_finger_id_t elements. - * Max_size is a bi-directional parameter and returns the actual number - * of elements copied to the caller supplied array. - * In the absence of errors the function returns the total number of templates - * in the user directory. - * If the caller has no good guess on the size of the array he should call this - * function witn *max_size == 0 and use the return value for the array allocation. - * The caller of this function has a complete list of the templates when *max_size - * is the same as the function return. - * - * Function return: Total number of fingerprint templates in the current storage directory. - * or a negative number in case of error, generally from the errno.h set. - */ - int (*enumerate)(struct fingerprint_device *dev, fingerprint_finger_id_t *results, - uint32_t *max_size); - - /* - * Fingerprint remove request: - * Deletes a fingerprint template. - * Works only within a path set by set_active_group(). - * notify() will be called with details on the template deleted. - * fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED and - * fingerprint_msg.data.removed.id indicating the template id removed. - * - * Function return: 0 if fingerprint template(s) can be successfully deleted - * or a negative number in case of error, generally from the errno.h set. - */ - int (*remove)(struct fingerprint_device *dev, uint32_t gid, uint32_t fid); - - /* - * Restricts the HAL operation to a set of fingerprints belonging to a - * group provided. - * The caller must provide a path to a storage location within the user's - * data directory. - * - * Function return: 0 on success - * or a negative number in case of error, generally from the errno.h set. - */ - int (*set_active_group)(struct fingerprint_device *dev, uint32_t gid, - const char *store_path); - - /* - * Authenticates an operation identifed by operation_id - * - * Function return: 0 on success - * or a negative number in case of error, generally from the errno.h set. - */ - int (*authenticate)(struct fingerprint_device *dev, uint64_t operation_id, uint32_t gid); - - /* Reserved for backward binary compatibility */ - void *reserved[4]; -} fingerprint_device_t; - -typedef struct fingerprint_module { - /** - * Common methods of the fingerprint module. This *must* be the first member - * of fingerprint_module as users of this structure will cast a hw_module_t - * to fingerprint_module pointer in contexts where it's known - * the hw_module_t references a fingerprint_module. - */ - struct hw_module_t common; -} fingerprint_module_t; - -#endif /* ANDROID_INCLUDE_HARDWARE_FINGERPRINT_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/fused_location.h b/third_party/android_hardware_libhardware/include/hardware/fused_location.h deleted file mode 100644 index 73360a12a..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/fused_location.h +++ /dev/null @@ -1,825 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H -#define ANDROID_INCLUDE_HARDWARE_FUSED_LOCATION_H - -#include - - -/** - * This header file defines the interface of the Fused Location Provider. - * Fused Location Provider is designed to fuse data from various sources - * like GPS, Wifi, Cell, Sensors, Bluetooth etc to provide a fused location to the - * upper layers. The advantage of doing fusion in hardware is power savings. - * The goal is to do this without waking up the AP to get additional data. - * The software implementation of FLP will decide when to use - * the hardware fused location. Other location features like geofencing will - * also be implemented using fusion in hardware. - */ -__BEGIN_DECLS - -#define FLP_HEADER_VERSION 1 -#define FLP_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) -#define FLP_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, FLP_HEADER_VERSION) - -/** - * The id of this module - */ -#define FUSED_LOCATION_HARDWARE_MODULE_ID "flp" - -/** - * Name for the FLP location interface - */ -#define FLP_LOCATION_INTERFACE "flp_location" - -/** - * Name for the FLP location interface - */ -#define FLP_DIAGNOSTIC_INTERFACE "flp_diagnostic" - -/** - * Name for the FLP_Geofencing interface. - */ -#define FLP_GEOFENCING_INTERFACE "flp_geofencing" - -/** - * Name for the FLP_device context interface. - */ -#define FLP_DEVICE_CONTEXT_INTERFACE "flp_device_context" - -/** - * Constants to indicate the various subsystems - * that will be used. - */ -#define FLP_TECH_MASK_GNSS (1U<<0) -#define FLP_TECH_MASK_WIFI (1U<<1) -#define FLP_TECH_MASK_SENSORS (1U<<2) -#define FLP_TECH_MASK_CELL (1U<<3) -#define FLP_TECH_MASK_BLUETOOTH (1U<<4) - -/** - * Set when your implementation can produce GNNS-derived locations, - * for use with flp_capabilities_callback. - * - * GNNS is a required capability for a particular feature to be used - * (batching or geofencing). If not supported that particular feature - * won't be used by the upper layer. - */ -#define CAPABILITY_GNSS (1U<<0) -/** - * Set when your implementation can produce WiFi-derived locations, for - * use with flp_capabilities_callback. - */ -#define CAPABILITY_WIFI (1U<<1) -/** - * Set when your implementation can produce cell-derived locations, for - * use with flp_capabilities_callback. - */ -#define CAPABILITY_CELL (1U<<3) - -/** - * Status to return in flp_status_callback when your implementation transitions - * from being unsuccessful in determining location to being successful. - */ -#define FLP_STATUS_LOCATION_AVAILABLE 0 -/** - * Status to return in flp_status_callback when your implementation transitions - * from being successful in determining location to being unsuccessful. - */ -#define FLP_STATUS_LOCATION_UNAVAILABLE 1 - -/** - * This constant is used with the batched locations - * APIs. Batching is mandatory when FLP implementation - * is supported. If the flag is set, the hardware implementation - * will wake up the application processor when the FIFO is full, - * If the flag is not set, the hardware implementation will drop - * the oldest data when the FIFO is full. - */ -#define FLP_BATCH_WAKEUP_ON_FIFO_FULL 0x0000001 - -/** - * While batching, the implementation should not call the - * flp_location_callback on every location fix. However, - * sometimes in high power mode, the system might need - * a location callback every single time the location - * fix has been obtained. This flag controls that option. - * Its the responsibility of the upper layers (caller) to switch - * it off, if it knows that the AP might go to sleep. - * When this bit is on amidst a batching session, batching should - * continue while location fixes are reported in real time. - */ -#define FLP_BATCH_CALLBACK_ON_LOCATION_FIX 0x0000002 - -/** Flags to indicate which values are valid in a FlpLocation. */ -typedef uint16_t FlpLocationFlags; - -// IMPORTANT: Note that the following values must match -// constants in the corresponding java file. - -/** FlpLocation has valid latitude and longitude. */ -#define FLP_LOCATION_HAS_LAT_LONG (1U<<0) -/** FlpLocation has valid altitude. */ -#define FLP_LOCATION_HAS_ALTITUDE (1U<<1) -/** FlpLocation has valid speed. */ -#define FLP_LOCATION_HAS_SPEED (1U<<2) -/** FlpLocation has valid bearing. */ -#define FLP_LOCATION_HAS_BEARING (1U<<4) -/** FlpLocation has valid accuracy. */ -#define FLP_LOCATION_HAS_ACCURACY (1U<<8) - - -typedef int64_t FlpUtcTime; - -/** Represents a location. */ -typedef struct { - /** set to sizeof(FlpLocation) */ - size_t size; - - /** Flags associated with the location object. */ - FlpLocationFlags flags; - - /** Represents latitude in degrees. */ - double latitude; - - /** Represents longitude in degrees. */ - double longitude; - - /** - * Represents altitude in meters above the WGS 84 reference - * ellipsoid. */ - double altitude; - - /** Represents speed in meters per second. */ - float speed; - - /** Represents heading in degrees. */ - float bearing; - - /** Represents expected accuracy in meters. */ - float accuracy; - - /** Timestamp for the location fix. */ - FlpUtcTime timestamp; - - /** Sources used, will be Bitwise OR of the FLP_TECH_MASK bits. */ - uint32_t sources_used; -} FlpLocation; - -typedef enum { - ASSOCIATE_JVM, - DISASSOCIATE_JVM, -} ThreadEvent; - -/** - * Callback with location information. - * Can only be called from a thread associated to JVM using set_thread_event_cb. - * Parameters: - * num_locations is the number of batched locations available. - * location is the pointer to an array of pointers to location objects. - */ -typedef void (*flp_location_callback)(int32_t num_locations, FlpLocation** location); - -/** - * Callback utility for acquiring a wakelock. - * This can be used to prevent the CPU from suspending while handling FLP events. - */ -typedef void (*flp_acquire_wakelock)(); - -/** - * Callback utility for releasing the FLP wakelock. - */ -typedef void (*flp_release_wakelock)(); - -/** - * Callback for associating a thread that can call into the Java framework code. - * This must be used to initialize any threads that report events up to the framework. - * Return value: - * FLP_RESULT_SUCCESS on success. - * FLP_RESULT_ERROR if the association failed in the current thread. - */ -typedef int (*flp_set_thread_event)(ThreadEvent event); - -/** - * Callback for technologies supported by this implementation. - * - * Parameters: capabilities is a bitmask of FLP_CAPABILITY_* values describing - * which features your implementation supports. You should support - * CAPABILITY_GNSS at a minimum for your implementation to be utilized. You can - * return 0 in FlpGeofenceCallbacks to indicate you don't support geofencing, - * or 0 in FlpCallbacks to indicate you don't support location batching. - */ -typedef void (*flp_capabilities_callback)(int capabilities); - -/** - * Callback with status information on the ability to compute location. - * To avoid waking up the application processor you should only send - * changes in status (you shouldn't call this method twice in a row - * with the same status value). As a guideline you should not call this - * more frequently then the requested batch period set with period_ns - * in FlpBatchOptions. For example if period_ns is set to 5 minutes and - * the status changes many times in that interval, you should only report - * one status change every 5 minutes. - * - * Parameters: - * status is one of FLP_STATUS_LOCATION_AVAILABLE - * or FLP_STATUS_LOCATION_UNAVAILABLE. - */ -typedef void (*flp_status_callback)(int32_t status); - -/** FLP callback structure. */ -typedef struct { - /** set to sizeof(FlpCallbacks) */ - size_t size; - flp_location_callback location_cb; - flp_acquire_wakelock acquire_wakelock_cb; - flp_release_wakelock release_wakelock_cb; - flp_set_thread_event set_thread_event_cb; - flp_capabilities_callback flp_capabilities_cb; - flp_status_callback flp_status_cb; -} FlpCallbacks; - - -/** Options with the batching FLP APIs */ -typedef struct { - /** - * Maximum power in mW that the underlying implementation - * can use for this batching call. - * If max_power_allocation_mW is 0, only fixes that are generated - * at no additional cost of power shall be reported. - */ - double max_power_allocation_mW; - - /** Bitwise OR of the FLP_TECH_MASKS to use */ - uint32_t sources_to_use; - - /** - * FLP_BATCH_WAKEUP_ON_FIFO_FULL - If set the hardware - * will wake up the AP when the buffer is full. If not set, the - * hardware will drop the oldest location object. - * - * FLP_BATCH_CALLBACK_ON_LOCATION_FIX - If set the location - * callback will be called every time there is a location fix. - * Its the responsibility of the upper layers (caller) to switch - * it off, if it knows that the AP might go to sleep. When this - * bit is on amidst a batching session, batching should continue - * while location fixes are reported in real time. - * - * Other flags to be bitwised ORed in the future. - */ - uint32_t flags; - - /** - * Frequency with which location needs to be batched in nano - * seconds. - */ - int64_t period_ns; - - /** - * The smallest displacement between reported locations in meters. - * - * If set to 0, then you should report locations at the requested - * interval even if the device is stationary. If positive, you - * can use this parameter as a hint to save power (e.g. throttling - * location period if the user hasn't traveled close to the displacement - * threshold). Even small positive values can be interpreted to mean - * that you don't have to compute location when the device is stationary. - * - * There is no need to filter location delivery based on this parameter. - * Locations can be delivered even if they have a displacement smaller than - * requested. This parameter can safely be ignored at the cost of potential - * power savings. - */ - float smallest_displacement_meters; -} FlpBatchOptions; - -#define FLP_RESULT_SUCCESS 0 -#define FLP_RESULT_ERROR -1 -#define FLP_RESULT_INSUFFICIENT_MEMORY -2 -#define FLP_RESULT_TOO_MANY_GEOFENCES -3 -#define FLP_RESULT_ID_EXISTS -4 -#define FLP_RESULT_ID_UNKNOWN -5 -#define FLP_RESULT_INVALID_GEOFENCE_TRANSITION -6 - -/** - * Represents the standard FLP interface. - */ -typedef struct { - /** - * set to sizeof(FlpLocationInterface) - */ - size_t size; - - /** - * Opens the interface and provides the callback routines - * to the implementation of this interface. Once called you should respond - * by calling the flp_capabilities_callback in FlpCallbacks to - * specify the capabilities that your implementation supports. - */ - int (*init)(FlpCallbacks* callbacks ); - - /** - * Return the batch size (in number of FlpLocation objects) - * available in the hardware. Note, different HW implementations - * may have different sample sizes. This shall return number - * of samples defined in the format of FlpLocation. - * This will be used by the upper layer, to decide on the batching - * interval and whether the AP should be woken up or not. - */ - int (*get_batch_size)(); - - /** - * Start batching locations. This API is primarily used when the AP is - * asleep and the device can batch locations in the hardware. - * flp_location_callback is used to return the locations. When the buffer - * is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is used, the AP is woken up. - * When the buffer is full and FLP_BATCH_WAKEUP_ON_FIFO_FULL is not set, - * the oldest location object is dropped. In this case the AP will not be - * woken up. The upper layer will use get_batched_location - * API to explicitly ask for the location. - * If FLP_BATCH_CALLBACK_ON_LOCATION_FIX is set, the implementation - * will call the flp_location_callback every single time there is a location - * fix. This overrides FLP_BATCH_WAKEUP_ON_FIFO_FULL flag setting. - * It's the responsibility of the upper layers (caller) to switch - * it off, if it knows that the AP might go to sleep. This is useful - * for nagivational applications when the system is in high power mode. - * Parameters: - * id - Id for the request. - * options - See FlpBatchOptions struct definition. - * Return value: - * FLP_RESULT_SUCCESS on success, FLP_RESULT_INSUFFICIENT_MEMORY, - * FLP_RESULT_ID_EXISTS, FLP_RESULT_ERROR on failure. - */ - int (*start_batching)(int id, FlpBatchOptions* options); - - /** - * Update FlpBatchOptions associated with a batching request. - * When a batching operation is in progress and a batching option - * such as FLP_BATCH_WAKEUP_ON_FIFO_FULL needs to be updated, this API - * will be used. For instance, this can happen when the AP is awake and - * the maps application is being used. - * Parameters: - * id - Id of an existing batch request. - * new_options - Updated FlpBatchOptions - * Return value: - * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN, - * FLP_RESULT_ERROR on error. - */ - int (*update_batching_options)(int id, FlpBatchOptions* new_options); - - /** - * Stop batching. - * Parameters: - * id - Id for the request. - * Return Value: - * FLP_RESULT_SUCCESS on success, FLP_RESULT_ID_UNKNOWN or - * FLP_RESULT_ERROR on failure. - */ - int (*stop_batching)(int id); - - /** - * Closes the interface. If any batch operations are in progress, - * they should be stopped. - */ - void (*cleanup)(); - - /** - * Get the fused location that was batched. - * flp_location_callback is used to return the location. The location object - * is dropped from the buffer only when the buffer is full. Do not remove it - * from the buffer just because it has been returned using the callback. - * In other words, when there is no new location object, two calls to - * get_batched_location(1) should return the same location object. - * Parameters: - * last_n_locations - Number of locations to get. This can be one or many. - * If the last_n_locations is 1, you get the latest location known to the - * hardware. - */ - void (*get_batched_location)(int last_n_locations); - - /** - * Injects current location from another location provider - * latitude and longitude are measured in degrees - * expected accuracy is measured in meters - * Parameters: - * location - The location object being injected. - * Return value: FLP_RESULT_SUCCESS or FLP_RESULT_ERROR. - */ - int (*inject_location)(FlpLocation* location); - - /** - * Get a pointer to extension information. - */ - const void* (*get_extension)(const char* name); - - /** - * Retrieve all batched locations currently stored and clear the buffer. - * flp_location_callback MUST be called in response, even if there are - * no locations to flush (in which case num_locations should be 0). - * Subsequent calls to get_batched_location or flush_batched_locations - * should not return any of the locations returned in this call. - */ - void (*flush_batched_locations)(); -} FlpLocationInterface; - -struct flp_device_t { - struct hw_device_t common; - - /** - * Get a handle to the FLP Interface. - */ - const FlpLocationInterface* (*get_flp_interface)(struct flp_device_t* dev); -}; - -/** - * Callback for reports diagnostic data into the Java framework code. -*/ -typedef void (*report_data)(char* data, int length); - -/** - * FLP diagnostic callback structure. - * Currently, not used - but this for future extension. - */ -typedef struct { - /** set to sizeof(FlpDiagnosticCallbacks) */ - size_t size; - - flp_set_thread_event set_thread_event_cb; - - /** reports diagnostic data into the Java framework code */ - report_data data_cb; -} FlpDiagnosticCallbacks; - -/** Extended interface for diagnostic support. */ -typedef struct { - /** set to sizeof(FlpDiagnosticInterface) */ - size_t size; - - /** - * Opens the diagnostic interface and provides the callback routines - * to the implemenation of this interface. - */ - void (*init)(FlpDiagnosticCallbacks* callbacks); - - /** - * Injects diagnostic data into the FLP subsystem. - * Return 0 on success, -1 on error. - **/ - int (*inject_data)(char* data, int length ); -} FlpDiagnosticInterface; - -/** - * Context setting information. - * All these settings shall be injected to FLP HAL at FLP init time. - * Following that, only the changed setting need to be re-injected - * upon changes. - */ - -#define FLP_DEVICE_CONTEXT_GPS_ENABLED (1U<<0) -#define FLP_DEVICE_CONTEXT_AGPS_ENABLED (1U<<1) -#define FLP_DEVICE_CONTEXT_NETWORK_POSITIONING_ENABLED (1U<<2) -#define FLP_DEVICE_CONTEXT_WIFI_CONNECTIVITY_ENABLED (1U<<3) -#define FLP_DEVICE_CONTEXT_WIFI_POSITIONING_ENABLED (1U<<4) -#define FLP_DEVICE_CONTEXT_HW_NETWORK_POSITIONING_ENABLED (1U<<5) -#define FLP_DEVICE_CONTEXT_AIRPLANE_MODE_ON (1U<<6) -#define FLP_DEVICE_CONTEXT_DATA_ENABLED (1U<<7) -#define FLP_DEVICE_CONTEXT_ROAMING_ENABLED (1U<<8) -#define FLP_DEVICE_CONTEXT_CURRENTLY_ROAMING (1U<<9) -#define FLP_DEVICE_CONTEXT_SENSOR_ENABLED (1U<<10) -#define FLP_DEVICE_CONTEXT_BLUETOOTH_ENABLED (1U<<11) -#define FLP_DEVICE_CONTEXT_CHARGER_ON (1U<<12) - -/** Extended interface for device context support. */ -typedef struct { - /** set to sizeof(FlpDeviceContextInterface) */ - size_t size; - - /** - * Injects debug data into the FLP subsystem. - * Return 0 on success, -1 on error. - **/ - int (*inject_device_context)(uint32_t enabledMask); -} FlpDeviceContextInterface; - - -/** - * There are 3 states associated with a Geofence: Inside, Outside, Unknown. - * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. - * - * An example state diagram with confidence level: 95% and Unknown time limit - * set as 30 secs is shown below. (confidence level and Unknown time limit are - * explained latter) - * ____________________________ - * | Unknown (30 secs) | - * """""""""""""""""""""""""""" - * ^ | | ^ - * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN - * | v v | - * ________ EXITED _________ - * | Inside | -----------> | Outside | - * | | <----------- | | - * """""""" ENTERED """"""""" - * - * Inside state: We are 95% confident that the user is inside the geofence. - * Outside state: We are 95% confident that the user is outside the geofence - * Unknown state: Rest of the time. - * - * The Unknown state is better explained with an example: - * - * __________ - * | c| - * | ___ | _______ - * | |a| | | b | - * | """ | """"""" - * | | - * """""""""" - * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy - * circle reported by the FLP subsystem. Now with regard to "b", the system is - * confident that the user is outside. But with regard to "a" is not confident - * whether it is inside or outside the geofence. If the accuracy remains the - * same for a sufficient period of time, the UNCERTAIN transition would be - * triggered with the state set to Unknown. If the accuracy improves later, an - * appropriate transition should be triggered. This "sufficient period of time" - * is defined by the parameter in the add_geofence_area API. - * In other words, Unknown state can be interpreted as a state in which the - * FLP subsystem isn't confident enough that the user is either inside or - * outside the Geofence. It moves to Unknown state only after the expiry of the - * timeout. - * - * The geofence callback needs to be triggered for the ENTERED and EXITED - * transitions, when the FLP system is confident that the user has entered - * (Inside state) or exited (Outside state) the Geofence. An implementation - * which uses a value of 95% as the confidence is recommended. The callback - * should be triggered only for the transitions requested by the - * add_geofence_area call. - * - * Even though the diagram and explanation talks about states and transitions, - * the callee is only interested in the transistions. The states are mentioned - * here for illustrative purposes. - * - * Startup Scenario: When the device boots up, if an application adds geofences, - * and then we get an accurate FLP location fix, it needs to trigger the - * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. - * By default, all the Geofences will be in the Unknown state. - * - * When the FLP system is unavailable, flp_geofence_status_callback should be - * called to inform the upper layers of the same. Similarly, when it becomes - * available the callback should be called. This is a global state while the - * UNKNOWN transition described above is per geofence. - * - */ -#define FLP_GEOFENCE_TRANSITION_ENTERED (1L<<0) -#define FLP_GEOFENCE_TRANSITION_EXITED (1L<<1) -#define FLP_GEOFENCE_TRANSITION_UNCERTAIN (1L<<2) - -#define FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE (1L<<0) -#define FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE (1L<<1) - -/** - * The callback associated with the geofence. - * Parameters: - * geofence_id - The id associated with the add_geofence_area. - * location - The current location as determined by the FLP subsystem. - * transition - Can be one of FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED, - * FLP_GEOFENCE_TRANSITION_UNCERTAIN. - * timestamp - Timestamp when the transition was detected; -1 if not available. - * sources_used - Bitwise OR of FLP_TECH_MASK flags indicating which - * subsystems were used. - * - * The callback should only be called when the caller is interested in that - * particular transition. For instance, if the caller is interested only in - * ENTERED transition, then the callback should NOT be called with the EXITED - * transition. - * - * IMPORTANT: If a transition is triggered resulting in this callback, the - * subsystem will wake up the application processor, if its in suspend state. - */ -typedef void (*flp_geofence_transition_callback) (int32_t geofence_id, FlpLocation* location, - int32_t transition, FlpUtcTime timestamp, uint32_t sources_used); - -/** - * The callback associated with the availablity of one the sources used for geofence - * monitoring by the FLP sub-system For example, if the GPS system determines that it cannot - * monitor geofences because of lack of reliability or unavailability of the GPS signals, - * it will call this callback with FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE parameter and the - * source set to FLP_TECH_MASK_GNSS. - * - * Parameters: - * status - FLP_GEOFENCE_MONITOR_STATUS_UNAVAILABLE or FLP_GEOFENCE_MONITOR_STATUS_AVAILABLE. - * source - One of the FLP_TECH_MASKS - * last_location - Last known location. - */ -typedef void (*flp_geofence_monitor_status_callback) (int32_t status, uint32_t source, - FlpLocation* last_location); - -/** - * The callback associated with the add_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * result - FLP_RESULT_SUCCESS - * FLP_RESULT_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. - * FLP_RESULT_ID_EXISTS - geofence with id already exists - * FLP_RESULT_INVALID_GEOFENCE_TRANSITION - the monitorTransition contains an - * invalid transition - * FLP_RESULT_ERROR - for other errors. - */ -typedef void (*flp_geofence_add_callback) (int32_t geofence_id, int32_t result); - -/** - * The callback associated with the remove_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * result - FLP_RESULT_SUCCESS - * FLP_RESULT_ID_UNKNOWN - for invalid id - * FLP_RESULT_ERROR for others. - */ -typedef void (*flp_geofence_remove_callback) (int32_t geofence_id, int32_t result); - - -/** - * The callback associated with the pause_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * result - FLP_RESULT_SUCCESS - * FLP_RESULT__ID_UNKNOWN - for invalid id - * FLP_RESULT_INVALID_TRANSITION - - * when monitor_transitions is invalid - * FLP_RESULT_ERROR for others. - */ -typedef void (*flp_geofence_pause_callback) (int32_t geofence_id, int32_t result); - -/** - * The callback associated with the resume_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * result - FLP_RESULT_SUCCESS - * FLP_RESULT_ID_UNKNOWN - for invalid id - * FLP_RESULT_ERROR for others. - */ -typedef void (*flp_geofence_resume_callback) (int32_t geofence_id, int32_t result); - -typedef struct { - /** set to sizeof(FlpGeofenceCallbacks) */ - size_t size; - flp_geofence_transition_callback geofence_transition_callback; - flp_geofence_monitor_status_callback geofence_status_callback; - flp_geofence_add_callback geofence_add_callback; - flp_geofence_remove_callback geofence_remove_callback; - flp_geofence_pause_callback geofence_pause_callback; - flp_geofence_resume_callback geofence_resume_callback; - flp_set_thread_event set_thread_event_cb; - flp_capabilities_callback flp_capabilities_cb; -} FlpGeofenceCallbacks; - - -/** Type of geofence */ -typedef enum { - TYPE_CIRCLE = 0, -} GeofenceType; - -/** Circular geofence is represented by lat / long / radius */ -typedef struct { - double latitude; - double longitude; - double radius_m; -} GeofenceCircle; - -/** Represents the type of geofence and data */ -typedef struct { - GeofenceType type; - union { - GeofenceCircle circle; - } geofence; -} GeofenceData; - -/** Geofence Options */ -typedef struct { - /** - * The current state of the geofence. For example, if - * the system already knows that the user is inside the geofence, - * this will be set to FLP_GEOFENCE_TRANSITION_ENTERED. In most cases, it - * will be FLP_GEOFENCE_TRANSITION_UNCERTAIN. */ - int last_transition; - - /** - * Transitions to monitor. Bitwise OR of - * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and - * FLP_GEOFENCE_TRANSITION_UNCERTAIN. - */ - int monitor_transitions; - - /** - * Defines the best-effort description - * of how soon should the callback be called when the transition - * associated with the Geofence is triggered. For instance, if set - * to 1000 millseconds with FLP_GEOFENCE_TRANSITION_ENTERED, the callback - * should be called 1000 milliseconds within entering the geofence. - * This parameter is defined in milliseconds. - * NOTE: This is not to be confused with the rate that the GPS is - * polled at. It is acceptable to dynamically vary the rate of - * sampling the GPS for power-saving reasons; thus the rate of - * sampling may be faster or slower than this. - */ - int notification_responsivenes_ms; - - /** - * The time limit after which the UNCERTAIN transition - * should be triggered. This paramter is defined in milliseconds. - */ - int unknown_timer_ms; - - /** - * The sources to use for monitoring geofences. Its a BITWISE-OR - * of FLP_TECH_MASK flags. - */ - uint32_t sources_to_use; -} GeofenceOptions; - -/** Geofence struct */ -typedef struct { - int32_t geofence_id; - GeofenceData* data; - GeofenceOptions* options; -} Geofence; - -/** Extended interface for FLP_Geofencing support */ -typedef struct { - /** set to sizeof(FlpGeofencingInterface) */ - size_t size; - - /** - * Opens the geofence interface and provides the callback routines - * to the implemenation of this interface. Once called you should respond - * by calling the flp_capabilities_callback in FlpGeofenceCallbacks to - * specify the capabilities that your implementation supports. - */ - void (*init)( FlpGeofenceCallbacks* callbacks ); - - /** - * Add a list of geofences. - * Parameters: - * number_of_geofences - The number of geofences that needed to be added. - * geofences - Pointer to array of pointers to Geofence structure. - */ - void (*add_geofences) (int32_t number_of_geofences, Geofence** geofences); - - /** - * Pause monitoring a particular geofence. - * Parameters: - * geofence_id - The id for the geofence. - */ - void (*pause_geofence) (int32_t geofence_id); - - /** - * Resume monitoring a particular geofence. - * Parameters: - * geofence_id - The id for the geofence. - * monitor_transitions - Which transitions to monitor. Bitwise OR of - * FLP_GEOFENCE_TRANSITION_ENTERED, FLP_GEOFENCE_TRANSITION_EXITED and - * FLP_GEOFENCE_TRANSITION_UNCERTAIN. - * This supersedes the value associated provided in the - * add_geofence_area call. - */ - void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); - - /** - * Modify a particular geofence option. - * Parameters: - * geofence_id - The id for the geofence. - * options - Various options associated with the geofence. See - * GeofenceOptions structure for details. - */ - void (*modify_geofence_option) (int32_t geofence_id, GeofenceOptions* options); - - /** - * Remove a list of geofences. After the function returns, no notifications - * should be sent. - * Parameter: - * number_of_geofences - The number of geofences that needed to be added. - * geofence_id - Pointer to array of geofence_ids to be removed. - */ - void (*remove_geofences) (int32_t number_of_geofences, int32_t* geofence_id); -} FlpGeofencingInterface; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_FLP_H */ - diff --git a/third_party/android_hardware_libhardware/include/hardware/gatekeeper.h b/third_party/android_hardware_libhardware/include/hardware/gatekeeper.h deleted file mode 100644 index 2bb2b08c3..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/gatekeeper.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef ANDROID_HARDWARE_GATEKEEPER_H -#define ANDROID_HARDWARE_GATEKEEPER_H - -#include -#include -#include - -__BEGIN_DECLS - -#define GATEKEEPER_HARDWARE_MODULE_ID "gatekeeper" - -#define GATEKEEPER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) - -#define HARDWARE_GATEKEEPER "gatekeeper" - -struct gatekeeper_module { - /** - * Comon methods of the gatekeeper module. This *must* be the first member of - * gatekeeper_module as users of this structure will cast a hw_module_t to - * a gatekeeper_module pointer in the appropriate context. - */ - hw_module_t common; -}; - -struct gatekeeper_device { - /** - * Common methods of the gatekeeper device. As above, this must be the first - * member of keymaster_device. - */ - hw_device_t common; - - /** - * Enrolls desired_password, which should be derived from a user selected pin or password, - * with the authentication factor private key used only for enrolling authentication - * factor data. - * - * If there was already a password enrolled, it should be provided in - * current_password_handle, along with the current password in current_password - * that should validate against current_password_handle. - * - * Parameters: - * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open - * - uid: the Android user identifier - * - * - current_password_handle: the currently enrolled password handle the user - * wants to replace. May be null if there's no currently enrolled password. - * - current_password_handle_length: the length in bytes of the buffer pointed - * at by current_password_handle. Must be 0 if current_password_handle is NULL. - * - * - current_password: the user's current password in plain text. If presented, - * it MUST verify against current_password_handle. - * - current_password_length: the size in bytes of the buffer pointed at by - * current_password. Must be 0 if the current_password is NULL. - * - * - desired_password: the new password the user wishes to enroll in plain-text. - * Cannot be NULL. - * - desired_password_length: the length in bytes of the buffer pointed at by - * desired_password. - * - * - enrolled_password_handle: on success, a buffer will be allocated with the - * new password handle referencing the password provided in desired_password. - * This buffer can be used on subsequent calls to enroll or verify. - * The caller is responsible for deallocating this buffer via a call to delete[] - * - enrolled_password_handle_length: pointer to the length in bytes of the buffer allocated - * by this function and pointed to by *enrolled_password_handle_length. - * - * Returns: - * - 0 on success - * - An error code < 0 on failure, or - * - A timeout value T > 0 if the call should not be re-attempted until T milliseconds - * have elapsed. - * - * On error, enrolled_password_handle will not be allocated. - */ - int (*enroll)(const struct gatekeeper_device *dev, uint32_t uid, - const uint8_t *current_password_handle, uint32_t current_password_handle_length, - const uint8_t *current_password, uint32_t current_password_length, - const uint8_t *desired_password, uint32_t desired_password_length, - uint8_t **enrolled_password_handle, uint32_t *enrolled_password_handle_length); - - /** - * Verifies provided_password matches enrolled_password_handle. - * - * Implementations of this module may retain the result of this call - * to attest to the recency of authentication. - * - * On success, writes the address of a verification token to auth_token, - * usable to attest password verification to other trusted services. Clients - * may pass NULL for this value. - * - * Parameters: - * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open - * - uid: the Android user identifier - * - * - challenge: An optional challenge to authenticate against, or 0. Used when a separate - * authenticator requests password verification, or for transactional - * password authentication. - * - * - enrolled_password_handle: the currently enrolled password handle that the - * user wishes to verify against. - * - enrolled_password_handle_length: the length in bytes of the buffer pointed - * to by enrolled_password_handle - * - * - provided_password: the plaintext password to be verified against the - * enrolled_password_handle - * - provided_password_length: the length in bytes of the buffer pointed to by - * provided_password - * - * - auth_token: on success, a buffer containing the authentication token - * resulting from this verification is assigned to *auth_token. The caller - * is responsible for deallocating this memory via a call to delete[] - * - auth_token_length: on success, the length in bytes of the authentication - * token assigned to *auth_token will be assigned to *auth_token_length - * - * - request_reenroll: a request to the upper layers to re-enroll the verified - * password due to a version change. Not set if verification fails. - * - * Returns: - * - 0 on success - * - An error code < 0 on failure, or - * - A timeout value T > 0 if the call should not be re-attempted until T milliseconds - * have elapsed. - * On error, auth token will not be allocated - */ - int (*verify)(const struct gatekeeper_device *dev, uint32_t uid, uint64_t challenge, - const uint8_t *enrolled_password_handle, uint32_t enrolled_password_handle_length, - const uint8_t *provided_password, uint32_t provided_password_length, - uint8_t **auth_token, uint32_t *auth_token_length, bool *request_reenroll); - - /* - * Deletes the enrolled_password_handle associated wth the uid. Once deleted - * the user cannot be verified anymore. - * This function is optional and should be set to NULL if it is not implemented. - * - * Parameters - * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open - * - uid: the Android user identifier - * - * Returns: - * - 0 on success - * - An error code < 0 on failure - */ - int (*delete_user)(const struct gatekeeper_device *dev, uint32_t uid); - - /* - * Deletes all the enrolled_password_handles for all uid's. Once called, - * no users will be enrolled on the device. - * This function is optional and should be set to NULL if it is not implemented. - * - * Parameters - * - dev: pointer to gatekeeper_device acquired via calls to gatekeeper_open - * - * Returns: - * - 0 on success - * - An error code < 0 on failure - */ - int (*delete_all_users)(const struct gatekeeper_device *dev); -}; - -typedef struct gatekeeper_device gatekeeper_device_t; - -static inline int gatekeeper_open(const struct hw_module_t *module, - gatekeeper_device_t **device) { - return module->methods->open(module, HARDWARE_GATEKEEPER, - (struct hw_device_t **) device); -} - -static inline int gatekeeper_close(gatekeeper_device_t *device) { - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_HARDWARE_GATEKEEPER_H diff --git a/third_party/android_hardware_libhardware/include/hardware/gps.h b/third_party/android_hardware_libhardware/include/hardware/gps.h deleted file mode 100644 index 76b6cb7ae..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/gps.h +++ /dev/null @@ -1,1871 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_GPS_H -#define ANDROID_INCLUDE_HARDWARE_GPS_H - -#include -#include -#include -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define GPS_HARDWARE_MODULE_ID "gps" - - -/** Milliseconds since January 1, 1970 */ -typedef int64_t GpsUtcTime; - -/** Maximum number of SVs for gps_sv_status_callback(). */ -#define GPS_MAX_SVS 32 - -/** Maximum number of Measurements in gps_measurement_callback(). */ -#define GPS_MAX_MEASUREMENT 32 - -/** Requested operational mode for GPS operation. */ -typedef uint32_t GpsPositionMode; -// IMPORTANT: Note that the following values must match -// constants in GpsLocationProvider.java. -/** Mode for running GPS standalone (no assistance). */ -#define GPS_POSITION_MODE_STANDALONE 0 -/** AGPS MS-Based mode. */ -#define GPS_POSITION_MODE_MS_BASED 1 -/** - * AGPS MS-Assisted mode. This mode is not maintained by the platform anymore. - * It is strongly recommended to use GPS_POSITION_MODE_MS_BASE instead. - */ -#define GPS_POSITION_MODE_MS_ASSISTED 2 - -/** Requested recurrence mode for GPS operation. */ -typedef uint32_t GpsPositionRecurrence; -// IMPORTANT: Note that the following values must match -// constants in GpsLocationProvider.java. -/** Receive GPS fixes on a recurring basis at a specified period. */ -#define GPS_POSITION_RECURRENCE_PERIODIC 0 -/** Request a single shot GPS fix. */ -#define GPS_POSITION_RECURRENCE_SINGLE 1 - -/** GPS status event values. */ -typedef uint16_t GpsStatusValue; -// IMPORTANT: Note that the following values must match -// constants in GpsLocationProvider.java. -/** GPS status unknown. */ -#define GPS_STATUS_NONE 0 -/** GPS has begun navigating. */ -#define GPS_STATUS_SESSION_BEGIN 1 -/** GPS has stopped navigating. */ -#define GPS_STATUS_SESSION_END 2 -/** GPS has powered on but is not navigating. */ -#define GPS_STATUS_ENGINE_ON 3 -/** GPS is powered off. */ -#define GPS_STATUS_ENGINE_OFF 4 - -/** Flags to indicate which values are valid in a GpsLocation. */ -typedef uint16_t GpsLocationFlags; -// IMPORTANT: Note that the following values must match -// constants in GpsLocationProvider.java. -/** GpsLocation has valid latitude and longitude. */ -#define GPS_LOCATION_HAS_LAT_LONG 0x0001 -/** GpsLocation has valid altitude. */ -#define GPS_LOCATION_HAS_ALTITUDE 0x0002 -/** GpsLocation has valid speed. */ -#define GPS_LOCATION_HAS_SPEED 0x0004 -/** GpsLocation has valid bearing. */ -#define GPS_LOCATION_HAS_BEARING 0x0008 -/** GpsLocation has valid accuracy. */ -#define GPS_LOCATION_HAS_ACCURACY 0x0010 - -/** Flags for the gps_set_capabilities callback. */ - -/** GPS HAL schedules fixes for GPS_POSITION_RECURRENCE_PERIODIC mode. - If this is not set, then the framework will use 1000ms for min_interval - and will start and call start() and stop() to schedule the GPS. - */ -#define GPS_CAPABILITY_SCHEDULING 0x0000001 -/** GPS supports MS-Based AGPS mode */ -#define GPS_CAPABILITY_MSB 0x0000002 -/** GPS supports MS-Assisted AGPS mode */ -#define GPS_CAPABILITY_MSA 0x0000004 -/** GPS supports single-shot fixes */ -#define GPS_CAPABILITY_SINGLE_SHOT 0x0000008 -/** GPS supports on demand time injection */ -#define GPS_CAPABILITY_ON_DEMAND_TIME 0x0000010 -/** GPS supports Geofencing */ -#define GPS_CAPABILITY_GEOFENCING 0x0000020 -/** GPS supports Measurements */ -#define GPS_CAPABILITY_MEASUREMENTS 0x0000040 -/** GPS supports Navigation Messages */ -#define GPS_CAPABILITY_NAV_MESSAGES 0x0000080 - -/** Flags used to specify which aiding data to delete - when calling delete_aiding_data(). */ -typedef uint16_t GpsAidingData; -// IMPORTANT: Note that the following values must match -// constants in GpsLocationProvider.java. -#define GPS_DELETE_EPHEMERIS 0x0001 -#define GPS_DELETE_ALMANAC 0x0002 -#define GPS_DELETE_POSITION 0x0004 -#define GPS_DELETE_TIME 0x0008 -#define GPS_DELETE_IONO 0x0010 -#define GPS_DELETE_UTC 0x0020 -#define GPS_DELETE_HEALTH 0x0040 -#define GPS_DELETE_SVDIR 0x0080 -#define GPS_DELETE_SVSTEER 0x0100 -#define GPS_DELETE_SADATA 0x0200 -#define GPS_DELETE_RTI 0x0400 -#define GPS_DELETE_CELLDB_INFO 0x8000 -#define GPS_DELETE_ALL 0xFFFF - -/** AGPS type */ -typedef uint16_t AGpsType; -#define AGPS_TYPE_SUPL 1 -#define AGPS_TYPE_C2K 2 - -typedef uint16_t AGpsSetIDType; -#define AGPS_SETID_TYPE_NONE 0 -#define AGPS_SETID_TYPE_IMSI 1 -#define AGPS_SETID_TYPE_MSISDN 2 - -typedef uint16_t ApnIpType; -#define APN_IP_INVALID 0 -#define APN_IP_IPV4 1 -#define APN_IP_IPV6 2 -#define APN_IP_IPV4V6 3 - -/** - * String length constants - */ -#define GPS_NI_SHORT_STRING_MAXLEN 256 -#define GPS_NI_LONG_STRING_MAXLEN 2048 - -/** - * GpsNiType constants - */ -typedef uint32_t GpsNiType; -#define GPS_NI_TYPE_VOICE 1 -#define GPS_NI_TYPE_UMTS_SUPL 2 -#define GPS_NI_TYPE_UMTS_CTRL_PLANE 3 - -/** - * GpsNiNotifyFlags constants - */ -typedef uint32_t GpsNiNotifyFlags; -/** NI requires notification */ -#define GPS_NI_NEED_NOTIFY 0x0001 -/** NI requires verification */ -#define GPS_NI_NEED_VERIFY 0x0002 -/** NI requires privacy override, no notification/minimal trace */ -#define GPS_NI_PRIVACY_OVERRIDE 0x0004 - -/** - * GPS NI responses, used to define the response in - * NI structures - */ -typedef int GpsUserResponseType; -#define GPS_NI_RESPONSE_ACCEPT 1 -#define GPS_NI_RESPONSE_DENY 2 -#define GPS_NI_RESPONSE_NORESP 3 - -/** - * NI data encoding scheme - */ -typedef int GpsNiEncodingType; -#define GPS_ENC_NONE 0 -#define GPS_ENC_SUPL_GSM_DEFAULT 1 -#define GPS_ENC_SUPL_UTF8 2 -#define GPS_ENC_SUPL_UCS2 3 -#define GPS_ENC_UNKNOWN -1 - -/** AGPS status event values. */ -typedef uint16_t AGpsStatusValue; -/** GPS requests data connection for AGPS. */ -#define GPS_REQUEST_AGPS_DATA_CONN 1 -/** GPS releases the AGPS data connection. */ -#define GPS_RELEASE_AGPS_DATA_CONN 2 -/** AGPS data connection initiated */ -#define GPS_AGPS_DATA_CONNECTED 3 -/** AGPS data connection completed */ -#define GPS_AGPS_DATA_CONN_DONE 4 -/** AGPS data connection failed */ -#define GPS_AGPS_DATA_CONN_FAILED 5 - -#define AGPS_REF_LOCATION_TYPE_GSM_CELLID 1 -#define AGPS_REF_LOCATION_TYPE_UMTS_CELLID 2 -#define AGPS_REG_LOCATION_TYPE_MAC 3 - -/** Network types for update_network_state "type" parameter */ -#define AGPS_RIL_NETWORK_TYPE_MOBILE 0 -#define AGPS_RIL_NETWORK_TYPE_WIFI 1 -#define AGPS_RIL_NETWORK_TYPE_MOBILE_MMS 2 -#define AGPS_RIL_NETWORK_TYPE_MOBILE_SUPL 3 -#define AGPS_RIL_NETWORK_TTYPE_MOBILE_DUN 4 -#define AGPS_RIL_NETWORK_TTYPE_MOBILE_HIPRI 5 -#define AGPS_RIL_NETWORK_TTYPE_WIMAX 6 - -/** - * Flags to indicate what fields in GpsClock are valid. - */ -typedef uint16_t GpsClockFlags; -/** A valid 'leap second' is stored in the data structure. */ -#define GPS_CLOCK_HAS_LEAP_SECOND (1<<0) -/** A valid 'time uncertainty' is stored in the data structure. */ -#define GPS_CLOCK_HAS_TIME_UNCERTAINTY (1<<1) -/** A valid 'full bias' is stored in the data structure. */ -#define GPS_CLOCK_HAS_FULL_BIAS (1<<2) -/** A valid 'bias' is stored in the data structure. */ -#define GPS_CLOCK_HAS_BIAS (1<<3) -/** A valid 'bias uncertainty' is stored in the data structure. */ -#define GPS_CLOCK_HAS_BIAS_UNCERTAINTY (1<<4) -/** A valid 'drift' is stored in the data structure. */ -#define GPS_CLOCK_HAS_DRIFT (1<<5) -/** A valid 'drift uncertainty' is stored in the data structure. */ -#define GPS_CLOCK_HAS_DRIFT_UNCERTAINTY (1<<6) - -/** - * Enumeration of the available values for the GPS Clock type. - */ -typedef uint8_t GpsClockType; -/** The type is not available ot it is unknown. */ -#define GPS_CLOCK_TYPE_UNKNOWN 0 -/** The source of the time value reported by GPS clock is the local hardware clock. */ -#define GPS_CLOCK_TYPE_LOCAL_HW_TIME 1 -/** - * The source of the time value reported by GPS clock is the GPS time derived from satellites - * (epoch = Jan 6, 1980) - */ -#define GPS_CLOCK_TYPE_GPS_TIME 2 - -/** - * Flags to indicate what fields in GpsMeasurement are valid. - */ -typedef uint32_t GpsMeasurementFlags; -/** A valid 'snr' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_SNR (1<<0) -/** A valid 'elevation' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_ELEVATION (1<<1) -/** A valid 'elevation uncertainty' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY (1<<2) -/** A valid 'azimuth' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_AZIMUTH (1<<3) -/** A valid 'azimuth uncertainty' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY (1<<4) -/** A valid 'pseudorange' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_PSEUDORANGE (1<<5) -/** A valid 'pseudorange uncertainty' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY (1<<6) -/** A valid 'code phase' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_CODE_PHASE (1<<7) -/** A valid 'code phase uncertainty' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY (1<<8) -/** A valid 'carrier frequency' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY (1<<9) -/** A valid 'carrier cycles' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_CARRIER_CYCLES (1<<10) -/** A valid 'carrier phase' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_CARRIER_PHASE (1<<11) -/** A valid 'carrier phase uncertainty' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY (1<<12) -/** A valid 'bit number' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_BIT_NUMBER (1<<13) -/** A valid 'time from last bit' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT (1<<14) -/** A valid 'doppler shift' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT (1<<15) -/** A valid 'doppler shift uncertainty' is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY (1<<16) -/** A valid 'used in fix' flag is stored in the data structure. */ -#define GPS_MEASUREMENT_HAS_USED_IN_FIX (1<<17) -/** The value of 'pseudorange rate' is uncorrected. */ -#define GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE (1<<18) - -/** - * Enumeration of the available values for the GPS Measurement's loss of lock. - */ -typedef uint8_t GpsLossOfLock; -/** The indicator is not available or it is unknown. */ -#define GPS_LOSS_OF_LOCK_UNKNOWN 0 -/** The measurement does not present any indication of loss of lock. */ -#define GPS_LOSS_OF_LOCK_OK 1 -/** Loss of lock between previous and current observation: cycle slip possible. */ -#define GPS_LOSS_OF_LOCK_CYCLE_SLIP 2 - -/** - * Enumeration of available values for the GPS Measurement's multipath indicator. - */ -typedef uint8_t GpsMultipathIndicator; -/** The indicator is not available or unknown. */ -#define GPS_MULTIPATH_INDICATOR_UNKNOWN 0 -/** The measurement has been indicated to use multipath. */ -#define GPS_MULTIPATH_INDICATOR_DETECTED 1 -/** The measurement has been indicated Not to use multipath. */ -#define GPS_MULTIPATH_INDICATOR_NOT_USED 2 - -/** - * Flags indicating the GPS measurement state. - * The expected behavior here is for GPS HAL to set all the flags that applies. For - * example, if the state for a satellite is only C/A code locked and bit synchronized, - * and there is still millisecond ambiguity, the state should be set as: - * GPS_MEASUREMENT_STATE_CODE_LOCK|GPS_MEASUREMENT_STATE_BIT_SYNC|GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS - * If GPS is still searching for a satellite, the corresponding state should be set to - * GPS_MEASUREMENT_STATE_UNKNOWN(0). - */ -typedef uint16_t GpsMeasurementState; -#define GPS_MEASUREMENT_STATE_UNKNOWN 0 -#define GPS_MEASUREMENT_STATE_CODE_LOCK (1<<0) -#define GPS_MEASUREMENT_STATE_BIT_SYNC (1<<1) -#define GPS_MEASUREMENT_STATE_SUBFRAME_SYNC (1<<2) -#define GPS_MEASUREMENT_STATE_TOW_DECODED (1<<3) -#define GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS (1<<4) - -/** - * Flags indicating the Accumulated Delta Range's states. - */ -typedef uint16_t GpsAccumulatedDeltaRangeState; -#define GPS_ADR_STATE_UNKNOWN 0 -#define GPS_ADR_STATE_VALID (1<<0) -#define GPS_ADR_STATE_RESET (1<<1) -#define GPS_ADR_STATE_CYCLE_SLIP (1<<2) - -/** - * Enumeration of available values to indicate the available GPS Navigation message types. - */ -typedef uint8_t GpsNavigationMessageType; -/** The message type is unknown. */ -#define GPS_NAVIGATION_MESSAGE_TYPE_UNKNOWN 0 -/** L1 C/A message contained in the structure. */ -#define GPS_NAVIGATION_MESSAGE_TYPE_L1CA 1 -/** L2-CNAV message contained in the structure. */ -#define GPS_NAVIGATION_MESSAGE_TYPE_L2CNAV 2 -/** L5-CNAV message contained in the structure. */ -#define GPS_NAVIGATION_MESSAGE_TYPE_L5CNAV 3 -/** CNAV-2 message contained in the structure. */ -#define GPS_NAVIGATION_MESSAGE_TYPE_CNAV2 4 - -/** - * Status of Navigation Message - * When a message is received properly without any parity error in its navigation words, the - * status should be set to NAV_MESSAGE_STATUS_PARITY_PASSED. But if a message is received - * with words that failed parity check, but GPS is able to correct those words, the status - * should be set to NAV_MESSAGE_STATUS_PARITY_REBUILT. - * No need to send any navigation message that contains words with parity error and cannot be - * corrected. - */ -typedef uint16_t NavigationMessageStatus; -#define NAV_MESSAGE_STATUS_UNKONW 0 -#define NAV_MESSAGE_STATUS_PARITY_PASSED (1<<0) -#define NAV_MESSAGE_STATUS_PARITY_REBUILT (1<<1) - -/** - * Name for the GPS XTRA interface. - */ -#define GPS_XTRA_INTERFACE "gps-xtra" - -/** - * Name for the GPS DEBUG interface. - */ -#define GPS_DEBUG_INTERFACE "gps-debug" - -/** - * Name for the AGPS interface. - */ -#define AGPS_INTERFACE "agps" - -/** - * Name of the Supl Certificate interface. - */ -#define SUPL_CERTIFICATE_INTERFACE "supl-certificate" - -/** - * Name for NI interface - */ -#define GPS_NI_INTERFACE "gps-ni" - -/** - * Name for the AGPS-RIL interface. - */ -#define AGPS_RIL_INTERFACE "agps_ril" - -/** - * Name for the GPS_Geofencing interface. - */ -#define GPS_GEOFENCING_INTERFACE "gps_geofencing" - -/** - * Name of the GPS Measurements interface. - */ -#define GPS_MEASUREMENT_INTERFACE "gps_measurement" - -/** - * Name of the GPS navigation message interface. - */ -#define GPS_NAVIGATION_MESSAGE_INTERFACE "gps_navigation_message" - -/** - * Name of the GNSS/GPS configuration interface. - */ -#define GNSS_CONFIGURATION_INTERFACE "gnss_configuration" - - -/** Represents a location. */ -typedef struct { - /** set to sizeof(GpsLocation) */ - size_t size; - /** Contains GpsLocationFlags bits. */ - uint16_t flags; - /** Represents latitude in degrees. */ - double latitude; - /** Represents longitude in degrees. */ - double longitude; - /** Represents altitude in meters above the WGS 84 reference - * ellipsoid. */ - double altitude; - /** Represents speed in meters per second. */ - float speed; - /** Represents heading in degrees. */ - float bearing; - /** Represents expected accuracy in meters. */ - float accuracy; - /** Timestamp for the location fix. */ - GpsUtcTime timestamp; -} GpsLocation; - -/** Represents the status. */ -typedef struct { - /** set to sizeof(GpsStatus) */ - size_t size; - GpsStatusValue status; -} GpsStatus; - -/** Represents SV information. */ -typedef struct { - /** set to sizeof(GpsSvInfo) */ - size_t size; - /** Pseudo-random number for the SV. */ - int prn; - /** Signal to noise ratio. */ - float snr; - /** Elevation of SV in degrees. */ - float elevation; - /** Azimuth of SV in degrees. */ - float azimuth; -} GpsSvInfo; - -/** Represents SV status. */ -typedef struct { - /** set to sizeof(GpsSvStatus) */ - size_t size; - - /** Number of SVs currently visible. */ - int num_svs; - - /** Contains an array of SV information. */ - GpsSvInfo sv_list[GPS_MAX_SVS]; - - /** Represents a bit mask indicating which SVs - * have ephemeris data. - */ - uint32_t ephemeris_mask; - - /** Represents a bit mask indicating which SVs - * have almanac data. - */ - uint32_t almanac_mask; - - /** - * Represents a bit mask indicating which SVs - * were used for computing the most recent position fix. - */ - uint32_t used_in_fix_mask; -} GpsSvStatus; - - -/* 2G and 3G */ -/* In 3G lac is discarded */ -typedef struct { - uint16_t type; - uint16_t mcc; - uint16_t mnc; - uint16_t lac; - uint32_t cid; -} AGpsRefLocationCellID; - -typedef struct { - uint8_t mac[6]; -} AGpsRefLocationMac; - -/** Represents ref locations */ -typedef struct { - uint16_t type; - union { - AGpsRefLocationCellID cellID; - AGpsRefLocationMac mac; - } u; -} AGpsRefLocation; - -/** Callback with location information. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* gps_location_callback)(GpsLocation* location); - -/** Callback with status information. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* gps_status_callback)(GpsStatus* status); - -/** - * Callback with SV status information. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); - -/** Callback for reporting NMEA sentences. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length); - -/** Callback to inform framework of the GPS engine's capabilities. - * Capability parameter is a bit field of GPS_CAPABILITY_* flags. - */ -typedef void (* gps_set_capabilities)(uint32_t capabilities); - -/** Callback utility for acquiring the GPS wakelock. - * This can be used to prevent the CPU from suspending while handling GPS events. - */ -typedef void (* gps_acquire_wakelock)(); - -/** Callback utility for releasing the GPS wakelock. */ -typedef void (* gps_release_wakelock)(); - -/** Callback for requesting NTP time */ -typedef void (* gps_request_utc_time)(); - -/** Callback for creating a thread that can call into the Java framework code. - * This must be used to create any threads that report events up to the framework. - */ -typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg); - -/** GPS callback structure. */ -typedef struct { - /** set to sizeof(GpsCallbacks) */ - size_t size; - gps_location_callback location_cb; - gps_status_callback status_cb; - gps_sv_status_callback sv_status_cb; - gps_nmea_callback nmea_cb; - gps_set_capabilities set_capabilities_cb; - gps_acquire_wakelock acquire_wakelock_cb; - gps_release_wakelock release_wakelock_cb; - gps_create_thread create_thread_cb; - gps_request_utc_time request_utc_time_cb; -} GpsCallbacks; - - -/** Represents the standard GPS interface. */ -typedef struct { - /** set to sizeof(GpsInterface) */ - size_t size; - /** - * Opens the interface and provides the callback routines - * to the implementation of this interface. - */ - int (*init)( GpsCallbacks* callbacks ); - - /** Starts navigating. */ - int (*start)( void ); - - /** Stops navigating. */ - int (*stop)( void ); - - /** Closes the interface. */ - void (*cleanup)( void ); - - /** Injects the current time. */ - int (*inject_time)(GpsUtcTime time, int64_t timeReference, - int uncertainty); - - /** Injects current location from another location provider - * (typically cell ID). - * latitude and longitude are measured in degrees - * expected accuracy is measured in meters - */ - int (*inject_location)(double latitude, double longitude, float accuracy); - - /** - * Specifies that the next call to start will not use the - * information defined in the flags. GPS_DELETE_ALL is passed for - * a cold start. - */ - void (*delete_aiding_data)(GpsAidingData flags); - - /** - * min_interval represents the time between fixes in milliseconds. - * preferred_accuracy represents the requested fix accuracy in meters. - * preferred_time represents the requested time to first fix in milliseconds. - * - * 'mode' parameter should be one of GPS_POSITION_MODE_MS_BASE - * or GPS_POSITION_MODE_STANDALONE. - * It is allowed by the platform (and it is recommended) to fallback to - * GPS_POSITION_MODE_MS_BASE if GPS_POSITION_MODE_MS_ASSISTED is passed in, and - * GPS_POSITION_MODE_MS_BASED is supported. - */ - int (*set_position_mode)(GpsPositionMode mode, GpsPositionRecurrence recurrence, - uint32_t min_interval, uint32_t preferred_accuracy, uint32_t preferred_time); - - /** Get a pointer to extension information. */ - const void* (*get_extension)(const char* name); -} GpsInterface; - -/** Callback to request the client to download XTRA data. - * The client should download XTRA data and inject it by calling inject_xtra_data(). - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* gps_xtra_download_request)(); - -/** Callback structure for the XTRA interface. */ -typedef struct { - gps_xtra_download_request download_request_cb; - gps_create_thread create_thread_cb; -} GpsXtraCallbacks; - -/** Extended interface for XTRA support. */ -typedef struct { - /** set to sizeof(GpsXtraInterface) */ - size_t size; - /** - * Opens the XTRA interface and provides the callback routines - * to the implementation of this interface. - */ - int (*init)( GpsXtraCallbacks* callbacks ); - /** Injects XTRA data into the GPS. */ - int (*inject_xtra_data)( char* data, int length ); -} GpsXtraInterface; - -/** Extended interface for DEBUG support. */ -typedef struct { - /** set to sizeof(GpsDebugInterface) */ - size_t size; - - /** - * This function should return any information that the native - * implementation wishes to include in a bugreport. - */ - size_t (*get_internal_state)(char* buffer, size_t bufferSize); -} GpsDebugInterface; - -#pragma pack(push,4) -// We need to keep the alignment of this data structure to 4-bytes, to ensure that in 64-bit -// environments the size of this legacy definition does not collide with _v2. Implementations should -// be using _v2 and _v3, so it's OK to pay the 'unaligned' penalty in 64-bit if an old -// implementation is still in use. - -/** Represents the status of AGPS. */ -typedef struct { - /** set to sizeof(AGpsStatus_v1) */ - size_t size; - - AGpsType type; - AGpsStatusValue status; -} AGpsStatus_v1; - -#pragma pack(pop) - -/** Represents the status of AGPS augmented with a IPv4 address field. */ -typedef struct { - /** set to sizeof(AGpsStatus_v2) */ - size_t size; - - AGpsType type; - AGpsStatusValue status; - uint32_t ipaddr; -} AGpsStatus_v2; - -/* Represents the status of AGPS augmented to support IPv4 and IPv6. */ -typedef struct { - /** set to sizeof(AGpsStatus_v3) */ - size_t size; - - AGpsType type; - AGpsStatusValue status; - - /** - * Must be set to a valid IPv4 address if the field 'addr' contains an IPv4 - * address, or set to INADDR_NONE otherwise. - */ - uint32_t ipaddr; - - /** - * Must contain the IPv4 (AF_INET) or IPv6 (AF_INET6) address to report. - * Any other value of addr.ss_family will be rejected. - * */ - struct sockaddr_storage addr; -} AGpsStatus_v3; - -typedef AGpsStatus_v3 AGpsStatus; - -/** Callback with AGPS status information. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (* agps_status_callback)(AGpsStatus* status); - -/** Callback structure for the AGPS interface. */ -typedef struct { - agps_status_callback status_cb; - gps_create_thread create_thread_cb; -} AGpsCallbacks; - - -/** Extended interface for AGPS support. */ -typedef struct { - /** set to sizeof(AGpsInterface_v1) */ - size_t size; - - /** - * Opens the AGPS interface and provides the callback routines - * to the implementation of this interface. - */ - void (*init)( AGpsCallbacks* callbacks ); - /** - * Notifies that a data connection is available and sets - * the name of the APN to be used for SUPL. - */ - int (*data_conn_open)( const char* apn ); - /** - * Notifies that the AGPS data connection has been closed. - */ - int (*data_conn_closed)(); - /** - * Notifies that a data connection is not available for AGPS. - */ - int (*data_conn_failed)(); - /** - * Sets the hostname and port for the AGPS server. - */ - int (*set_server)( AGpsType type, const char* hostname, int port ); -} AGpsInterface_v1; - -/** - * Extended interface for AGPS support, it is augmented to enable to pass - * extra APN data. - */ -typedef struct { - /** set to sizeof(AGpsInterface_v2) */ - size_t size; - - /** - * Opens the AGPS interface and provides the callback routines to the - * implementation of this interface. - */ - void (*init)(AGpsCallbacks* callbacks); - /** - * Deprecated. - * If the HAL supports AGpsInterface_v2 this API will not be used, see - * data_conn_open_with_apn_ip_type for more information. - */ - int (*data_conn_open)(const char* apn); - /** - * Notifies that the AGPS data connection has been closed. - */ - int (*data_conn_closed)(); - /** - * Notifies that a data connection is not available for AGPS. - */ - int (*data_conn_failed)(); - /** - * Sets the hostname and port for the AGPS server. - */ - int (*set_server)(AGpsType type, const char* hostname, int port); - - /** - * Notifies that a data connection is available and sets the name of the - * APN, and its IP type, to be used for SUPL connections. - */ - int (*data_conn_open_with_apn_ip_type)( - const char* apn, - ApnIpType apnIpType); -} AGpsInterface_v2; - -typedef AGpsInterface_v2 AGpsInterface; - -/** Error codes associated with certificate operations */ -#define AGPS_CERTIFICATE_OPERATION_SUCCESS 0 -#define AGPS_CERTIFICATE_ERROR_GENERIC -100 -#define AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES -101 - -/** A data structure that represents an X.509 certificate using DER encoding */ -typedef struct { - size_t length; - u_char* data; -} DerEncodedCertificate; - -/** - * A type definition for SHA1 Fingerprints used to identify X.509 Certificates - * The Fingerprint is a digest of the DER Certificate that uniquely identifies it. - */ -typedef struct { - u_char data[20]; -} Sha1CertificateFingerprint; - -/** AGPS Interface to handle SUPL certificate operations */ -typedef struct { - /** set to sizeof(SuplCertificateInterface) */ - size_t size; - - /** - * Installs a set of Certificates used for SUPL connections to the AGPS server. - * If needed the HAL should find out internally any certificates that need to be removed to - * accommodate the certificates to install. - * The certificates installed represent a full set of valid certificates needed to connect to - * AGPS SUPL servers. - * The list of certificates is required, and all must be available at the same time, when trying - * to establish a connection with the AGPS Server. - * - * Parameters: - * certificates - A pointer to an array of DER encoded certificates that are need to be - * installed in the HAL. - * length - The number of certificates to install. - * Returns: - * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully - * AGPS_CERTIFICATE_ERROR_TOO_MANY_CERTIFICATES if the HAL cannot store the number of - * certificates attempted to be installed, the state of the certificates stored should - * remain the same as before on this error case. - * - * IMPORTANT: - * If needed the HAL should find out internally the set of certificates that need to be - * removed to accommodate the certificates to install. - */ - int (*install_certificates) ( const DerEncodedCertificate* certificates, size_t length ); - - /** - * Notifies the HAL that a list of certificates used for SUPL connections are revoked. It is - * expected that the given set of certificates is removed from the internal store of the HAL. - * - * Parameters: - * fingerprints - A pointer to an array of SHA1 Fingerprints to identify the set of - * certificates to revoke. - * length - The number of fingerprints provided. - * Returns: - * AGPS_CERTIFICATE_OPERATION_SUCCESS if the operation is completed successfully. - * - * IMPORTANT: - * If any of the certificates provided (through its fingerprint) is not known by the HAL, - * it should be ignored and continue revoking/deleting the rest of them. - */ - int (*revoke_certificates) ( const Sha1CertificateFingerprint* fingerprints, size_t length ); -} SuplCertificateInterface; - -/** Represents an NI request */ -typedef struct { - /** set to sizeof(GpsNiNotification) */ - size_t size; - - /** - * An ID generated by HAL to associate NI notifications and UI - * responses - */ - int notification_id; - - /** - * An NI type used to distinguish different categories of NI - * events, such as GPS_NI_TYPE_VOICE, GPS_NI_TYPE_UMTS_SUPL, ... - */ - GpsNiType ni_type; - - /** - * Notification/verification options, combinations of GpsNiNotifyFlags constants - */ - GpsNiNotifyFlags notify_flags; - - /** - * Timeout period to wait for user response. - * Set to 0 for no time out limit. - */ - int timeout; - - /** - * Default response when time out. - */ - GpsUserResponseType default_response; - - /** - * Requestor ID - */ - char requestor_id[GPS_NI_SHORT_STRING_MAXLEN]; - - /** - * Notification message. It can also be used to store client_id in some cases - */ - char text[GPS_NI_LONG_STRING_MAXLEN]; - - /** - * Client name decoding scheme - */ - GpsNiEncodingType requestor_id_encoding; - - /** - * Client name decoding scheme - */ - GpsNiEncodingType text_encoding; - - /** - * A pointer to extra data. Format: - * key_1 = value_1 - * key_2 = value_2 - */ - char extras[GPS_NI_LONG_STRING_MAXLEN]; - -} GpsNiNotification; - -/** Callback with NI notification. - * Can only be called from a thread created by create_thread_cb. - */ -typedef void (*gps_ni_notify_callback)(GpsNiNotification *notification); - -/** GPS NI callback structure. */ -typedef struct -{ - /** - * Sends the notification request from HAL to GPSLocationProvider. - */ - gps_ni_notify_callback notify_cb; - gps_create_thread create_thread_cb; -} GpsNiCallbacks; - -/** - * Extended interface for Network-initiated (NI) support. - */ -typedef struct -{ - /** set to sizeof(GpsNiInterface) */ - size_t size; - - /** Registers the callbacks for HAL to use. */ - void (*init) (GpsNiCallbacks *callbacks); - - /** Sends a response to HAL. */ - void (*respond) (int notif_id, GpsUserResponseType user_response); -} GpsNiInterface; - -struct gps_device_t { - struct hw_device_t common; - - /** - * Set the provided lights to the provided values. - * - * Returns: 0 on succes, error code on failure. - */ - const GpsInterface* (*get_gps_interface)(struct gps_device_t* dev); -}; - -#define AGPS_RIL_REQUEST_SETID_IMSI (1<<0L) -#define AGPS_RIL_REQUEST_SETID_MSISDN (1<<1L) - -#define AGPS_RIL_REQUEST_REFLOC_CELLID (1<<0L) -#define AGPS_RIL_REQUEST_REFLOC_MAC (1<<1L) - -typedef void (*agps_ril_request_set_id)(uint32_t flags); -typedef void (*agps_ril_request_ref_loc)(uint32_t flags); - -typedef struct { - agps_ril_request_set_id request_setid; - agps_ril_request_ref_loc request_refloc; - gps_create_thread create_thread_cb; -} AGpsRilCallbacks; - -/** Extended interface for AGPS_RIL support. */ -typedef struct { - /** set to sizeof(AGpsRilInterface) */ - size_t size; - /** - * Opens the AGPS interface and provides the callback routines - * to the implementation of this interface. - */ - void (*init)( AGpsRilCallbacks* callbacks ); - - /** - * Sets the reference location. - */ - void (*set_ref_location) (const AGpsRefLocation *agps_reflocation, size_t sz_struct); - /** - * Sets the set ID. - */ - void (*set_set_id) (AGpsSetIDType type, const char* setid); - - /** - * Send network initiated message. - */ - void (*ni_message) (uint8_t *msg, size_t len); - - /** - * Notify GPS of network status changes. - * These parameters match values in the android.net.NetworkInfo class. - */ - void (*update_network_state) (int connected, int type, int roaming, const char* extra_info); - - /** - * Notify GPS of network status changes. - * These parameters match values in the android.net.NetworkInfo class. - */ - void (*update_network_availability) (int avaiable, const char* apn); -} AGpsRilInterface; - -/** - * GPS Geofence. - * There are 3 states associated with a Geofence: Inside, Outside, Unknown. - * There are 3 transitions: ENTERED, EXITED, UNCERTAIN. - * - * An example state diagram with confidence level: 95% and Unknown time limit - * set as 30 secs is shown below. (confidence level and Unknown time limit are - * explained latter) - * ____________________________ - * | Unknown (30 secs) | - * """""""""""""""""""""""""""" - * ^ | | ^ - * UNCERTAIN| |ENTERED EXITED| |UNCERTAIN - * | v v | - * ________ EXITED _________ - * | Inside | -----------> | Outside | - * | | <----------- | | - * """""""" ENTERED """"""""" - * - * Inside state: We are 95% confident that the user is inside the geofence. - * Outside state: We are 95% confident that the user is outside the geofence - * Unknown state: Rest of the time. - * - * The Unknown state is better explained with an example: - * - * __________ - * | c| - * | ___ | _______ - * | |a| | | b | - * | """ | """"""" - * | | - * """""""""" - * In the diagram above, "a" and "b" are 2 geofences and "c" is the accuracy - * circle reported by the GPS subsystem. Now with regard to "b", the system is - * confident that the user is outside. But with regard to "a" is not confident - * whether it is inside or outside the geofence. If the accuracy remains the - * same for a sufficient period of time, the UNCERTAIN transition would be - * triggered with the state set to Unknown. If the accuracy improves later, an - * appropriate transition should be triggered. This "sufficient period of time" - * is defined by the parameter in the add_geofence_area API. - * In other words, Unknown state can be interpreted as a state in which the - * GPS subsystem isn't confident enough that the user is either inside or - * outside the Geofence. It moves to Unknown state only after the expiry of the - * timeout. - * - * The geofence callback needs to be triggered for the ENTERED and EXITED - * transitions, when the GPS system is confident that the user has entered - * (Inside state) or exited (Outside state) the Geofence. An implementation - * which uses a value of 95% as the confidence is recommended. The callback - * should be triggered only for the transitions requested by the - * add_geofence_area call. - * - * Even though the diagram and explanation talks about states and transitions, - * the callee is only interested in the transistions. The states are mentioned - * here for illustrative purposes. - * - * Startup Scenario: When the device boots up, if an application adds geofences, - * and then we get an accurate GPS location fix, it needs to trigger the - * appropriate (ENTERED or EXITED) transition for every Geofence it knows about. - * By default, all the Geofences will be in the Unknown state. - * - * When the GPS system is unavailable, gps_geofence_status_callback should be - * called to inform the upper layers of the same. Similarly, when it becomes - * available the callback should be called. This is a global state while the - * UNKNOWN transition described above is per geofence. - * - * An important aspect to note is that users of this API (framework), will use - * other subsystems like wifi, sensors, cell to handle Unknown case and - * hopefully provide a definitive state transition to the third party - * application. GPS Geofence will just be a signal indicating what the GPS - * subsystem knows about the Geofence. - * - */ -#define GPS_GEOFENCE_ENTERED (1<<0L) -#define GPS_GEOFENCE_EXITED (1<<1L) -#define GPS_GEOFENCE_UNCERTAIN (1<<2L) - -#define GPS_GEOFENCE_UNAVAILABLE (1<<0L) -#define GPS_GEOFENCE_AVAILABLE (1<<1L) - -#define GPS_GEOFENCE_OPERATION_SUCCESS 0 -#define GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES -100 -#define GPS_GEOFENCE_ERROR_ID_EXISTS -101 -#define GPS_GEOFENCE_ERROR_ID_UNKNOWN -102 -#define GPS_GEOFENCE_ERROR_INVALID_TRANSITION -103 -#define GPS_GEOFENCE_ERROR_GENERIC -149 - -/** - * The callback associated with the geofence. - * Parameters: - * geofence_id - The id associated with the add_geofence_area. - * location - The current GPS location. - * transition - Can be one of GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED, - * GPS_GEOFENCE_UNCERTAIN. - * timestamp - Timestamp when the transition was detected. - * - * The callback should only be called when the caller is interested in that - * particular transition. For instance, if the caller is interested only in - * ENTERED transition, then the callback should NOT be called with the EXITED - * transition. - * - * IMPORTANT: If a transition is triggered resulting in this callback, the GPS - * subsystem will wake up the application processor, if its in suspend state. - */ -typedef void (*gps_geofence_transition_callback) (int32_t geofence_id, GpsLocation* location, - int32_t transition, GpsUtcTime timestamp); - -/** - * The callback associated with the availability of the GPS system for geofencing - * monitoring. If the GPS system determines that it cannot monitor geofences - * because of lack of reliability or unavailability of the GPS signals, it will - * call this callback with GPS_GEOFENCE_UNAVAILABLE parameter. - * - * Parameters: - * status - GPS_GEOFENCE_UNAVAILABLE or GPS_GEOFENCE_AVAILABLE. - * last_location - Last known location. - */ -typedef void (*gps_geofence_status_callback) (int32_t status, GpsLocation* last_location); - -/** - * The callback associated with the add_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES - geofence limit has been reached. - * GPS_GEOFENCE_ERROR_ID_EXISTS - geofence with id already exists - * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - the monitorTransition contains an - * invalid transition - * GPS_GEOFENCE_ERROR_GENERIC - for other errors. - */ -typedef void (*gps_geofence_add_callback) (int32_t geofence_id, int32_t status); - -/** - * The callback associated with the remove_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id - * GPS_GEOFENCE_ERROR_GENERIC for others. - */ -typedef void (*gps_geofence_remove_callback) (int32_t geofence_id, int32_t status); - - -/** - * The callback associated with the pause_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id - * GPS_GEOFENCE_ERROR_INVALID_TRANSITION - - * when monitor_transitions is invalid - * GPS_GEOFENCE_ERROR_GENERIC for others. - */ -typedef void (*gps_geofence_pause_callback) (int32_t geofence_id, int32_t status); - -/** - * The callback associated with the resume_geofence call. - * - * Parameter: - * geofence_id - Id of the geofence. - * status - GPS_GEOFENCE_OPERATION_SUCCESS - * GPS_GEOFENCE_ERROR_ID_UNKNOWN - for invalid id - * GPS_GEOFENCE_ERROR_GENERIC for others. - */ -typedef void (*gps_geofence_resume_callback) (int32_t geofence_id, int32_t status); - -typedef struct { - gps_geofence_transition_callback geofence_transition_callback; - gps_geofence_status_callback geofence_status_callback; - gps_geofence_add_callback geofence_add_callback; - gps_geofence_remove_callback geofence_remove_callback; - gps_geofence_pause_callback geofence_pause_callback; - gps_geofence_resume_callback geofence_resume_callback; - gps_create_thread create_thread_cb; -} GpsGeofenceCallbacks; - -/** Extended interface for GPS_Geofencing support */ -typedef struct { - /** set to sizeof(GpsGeofencingInterface) */ - size_t size; - - /** - * Opens the geofence interface and provides the callback routines - * to the implementation of this interface. - */ - void (*init)( GpsGeofenceCallbacks* callbacks ); - - /** - * Add a geofence area. This api currently supports circular geofences. - * Parameters: - * geofence_id - The id for the geofence. If a geofence with this id - * already exists, an error value (GPS_GEOFENCE_ERROR_ID_EXISTS) - * should be returned. - * latitude, longtitude, radius_meters - The lat, long and radius - * (in meters) for the geofence - * last_transition - The current state of the geofence. For example, if - * the system already knows that the user is inside the geofence, - * this will be set to GPS_GEOFENCE_ENTERED. In most cases, it - * will be GPS_GEOFENCE_UNCERTAIN. - * monitor_transition - Which transitions to monitor. Bitwise OR of - * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and - * GPS_GEOFENCE_UNCERTAIN. - * notification_responsiveness_ms - Defines the best-effort description - * of how soon should the callback be called when the transition - * associated with the Geofence is triggered. For instance, if set - * to 1000 millseconds with GPS_GEOFENCE_ENTERED, the callback - * should be called 1000 milliseconds within entering the geofence. - * This parameter is defined in milliseconds. - * NOTE: This is not to be confused with the rate that the GPS is - * polled at. It is acceptable to dynamically vary the rate of - * sampling the GPS for power-saving reasons; thus the rate of - * sampling may be faster or slower than this. - * unknown_timer_ms - The time limit after which the UNCERTAIN transition - * should be triggered. This parameter is defined in milliseconds. - * See above for a detailed explanation. - */ - void (*add_geofence_area) (int32_t geofence_id, double latitude, double longitude, - double radius_meters, int last_transition, int monitor_transitions, - int notification_responsiveness_ms, int unknown_timer_ms); - - /** - * Pause monitoring a particular geofence. - * Parameters: - * geofence_id - The id for the geofence. - */ - void (*pause_geofence) (int32_t geofence_id); - - /** - * Resume monitoring a particular geofence. - * Parameters: - * geofence_id - The id for the geofence. - * monitor_transitions - Which transitions to monitor. Bitwise OR of - * GPS_GEOFENCE_ENTERED, GPS_GEOFENCE_EXITED and - * GPS_GEOFENCE_UNCERTAIN. - * This supersedes the value associated provided in the - * add_geofence_area call. - */ - void (*resume_geofence) (int32_t geofence_id, int monitor_transitions); - - /** - * Remove a geofence area. After the function returns, no notifications - * should be sent. - * Parameter: - * geofence_id - The id for the geofence. - */ - void (*remove_geofence_area) (int32_t geofence_id); -} GpsGeofencingInterface; - - -/** - * Represents an estimate of the GPS clock time. - */ -typedef struct { - /** set to sizeof(GpsClock) */ - size_t size; - - /** A set of flags indicating the validity of the fields in this data structure. */ - GpsClockFlags flags; - - /** - * Leap second data. - * The sign of the value is defined by the following equation: - * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second * 1,000,000,000 - * - * If the data is available 'flags' must contain GPS_CLOCK_HAS_LEAP_SECOND. - */ - int16_t leap_second; - - /** - * Indicates the type of time reported by the 'time_ns' field. - * This is a Mandatory field. - */ - GpsClockType type; - - /** - * The GPS receiver internal clock value. This can be either the local hardware clock value - * (GPS_CLOCK_TYPE_LOCAL_HW_TIME), or the current GPS time derived inside GPS receiver - * (GPS_CLOCK_TYPE_GPS_TIME). The field 'type' defines the time reported. - * - * For local hardware clock, this value is expected to be monotonically increasing during - * the reporting session. The real GPS time can be derived by compensating the 'full bias' - * (when it is available) from this value. - * - * For GPS time, this value is expected to be the best estimation of current GPS time that GPS - * receiver can achieve. Set the 'time uncertainty' appropriately when GPS time is specified. - * - * Sub-nanosecond accuracy can be provided by means of the 'bias' field. - * The value contains the 'time uncertainty' in it. - * - * This is a Mandatory field. - */ - int64_t time_ns; - - /** - * 1-Sigma uncertainty associated with the clock's time in nanoseconds. - * The uncertainty is represented as an absolute (single sided) value. - * - * This value should be set if GPS_CLOCK_TYPE_GPS_TIME is set. - * If the data is available 'flags' must contain GPS_CLOCK_HAS_TIME_UNCERTAINTY. - */ - double time_uncertainty_ns; - - /** - * The difference between hardware clock ('time' field) inside GPS receiver and the true GPS - * time since 0000Z, January 6, 1980, in nanoseconds. - * This value is used if and only if GPS_CLOCK_TYPE_LOCAL_HW_TIME is set, and GPS receiver - * has solved the clock for GPS time. - * The caller is responsible for using the 'bias uncertainty' field for quality check. - * - * The sign of the value is defined by the following equation: - * true time (GPS time) = time_ns + (full_bias_ns + bias_ns) - * - * This value contains the 'bias uncertainty' in it. - * If the data is available 'flags' must contain GPS_CLOCK_HAS_FULL_BIAS. - - */ - int64_t full_bias_ns; - - /** - * Sub-nanosecond bias. - * The value contains the 'bias uncertainty' in it. - * - * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS. - */ - double bias_ns; - - /** - * 1-Sigma uncertainty associated with the clock's bias in nanoseconds. - * The uncertainty is represented as an absolute (single sided) value. - * - * If the data is available 'flags' must contain GPS_CLOCK_HAS_BIAS_UNCERTAINTY. - */ - double bias_uncertainty_ns; - - /** - * The clock's drift in nanoseconds (per second). - * A positive value means that the frequency is higher than the nominal frequency. - * - * The value contains the 'drift uncertainty' in it. - * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT. - * - * If GpsMeasurement's 'flags' field contains GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE, - * it is encouraged that this field is also provided. - */ - double drift_nsps; - - /** - * 1-Sigma uncertainty associated with the clock's drift in nanoseconds (per second). - * The uncertainty is represented as an absolute (single sided) value. - * - * If the data is available 'flags' must contain GPS_CLOCK_HAS_DRIFT_UNCERTAINTY. - */ - double drift_uncertainty_nsps; -} GpsClock; - -/** - * Represents a GPS Measurement, it contains raw and computed information. - */ -typedef struct { - /** set to sizeof(GpsMeasurement) */ - size_t size; - - /** A set of flags indicating the validity of the fields in this data structure. */ - GpsMeasurementFlags flags; - - /** - * Pseudo-random number in the range of [1, 32] - * This is a Mandatory value. - */ - int8_t prn; - - /** - * Time offset at which the measurement was taken in nanoseconds. - * The reference receiver's time is specified by GpsData::clock::time_ns and should be - * interpreted in the same way as indicated by GpsClock::type. - * - * The sign of time_offset_ns is given by the following equation: - * measurement time = GpsClock::time_ns + time_offset_ns - * - * It provides an individual time-stamp for the measurement, and allows sub-nanosecond accuracy. - * This is a Mandatory value. - */ - double time_offset_ns; - - /** - * Per satellite sync state. It represents the current sync state for the associated satellite. - * Based on the sync state, the 'received GPS tow' field should be interpreted accordingly. - * - * This is a Mandatory value. - */ - GpsMeasurementState state; - - /** - * Received GPS Time-of-Week at the measurement time, in nanoseconds. - * The value is relative to the beginning of the current GPS week. - * - * Given the highest sync state that can be achieved, per each satellite, valid range for - * this field can be: - * Searching : [ 0 ] : GPS_MEASUREMENT_STATE_UNKNOWN - * C/A code lock : [ 0 1ms ] : GPS_MEASUREMENT_STATE_CODE_LOCK is set - * Bit sync : [ 0 20ms ] : GPS_MEASUREMENT_STATE_BIT_SYNC is set - * Subframe sync : [ 0 6s ] : GPS_MEASUREMENT_STATE_SUBFRAME_SYNC is set - * TOW decoded : [ 0 1week ] : GPS_MEASUREMENT_STATE_TOW_DECODED is set - * - * However, if there is any ambiguity in integer millisecond, - * GPS_MEASUREMENT_STATE_MSEC_AMBIGUOUS should be set accordingly, in the 'state' field. - * - * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. - */ - int64_t received_gps_tow_ns; - - /** - * 1-Sigma uncertainty of the Received GPS Time-of-Week in nanoseconds. - * - * This value must be populated if 'state' != GPS_MEASUREMENT_STATE_UNKNOWN. - */ - int64_t received_gps_tow_uncertainty_ns; - - /** - * Carrier-to-noise density in dB-Hz, in the range [0, 63]. - * It contains the measured C/N0 value for the signal at the antenna input. - * - * This is a Mandatory value. - */ - double c_n0_dbhz; - - /** - * Pseudorange rate at the timestamp in m/s. - * The correction of a given Pseudorange Rate value includes corrections for receiver and - * satellite clock frequency errors. - * - * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is set in 'flags' field, this field must - * be populated with the 'uncorrected' reading. - * If GPS_MEASUREMENT_HAS_UNCORRECTED_PSEUDORANGE_RATE is not set in 'flags' field, this field - * must be populated with the 'corrected' reading. This is the default behavior. - * - * It is encouraged to provide the 'uncorrected' 'pseudorange rate', and provide GpsClock's - * 'drift' field as well. - * - * The value includes the 'pseudorange rate uncertainty' in it. - * A positive 'uncorrected' value indicates that the SV is moving away from the receiver. - * - * The sign of the 'uncorrected' 'pseudorange rate' and its relation to the sign of 'doppler - * shift' is given by the equation: - * pseudorange rate = -k * doppler shift (where k is a constant) - * - * This is a Mandatory value. - */ - double pseudorange_rate_mps; - - /** - * 1-Sigma uncertainty of the pseudurange rate in m/s. - * The uncertainty is represented as an absolute (single sided) value. - * - * This is a Mandatory value. - */ - double pseudorange_rate_uncertainty_mps; - - /** - * Accumulated delta range's state. It indicates whether ADR is reset or there is a cycle slip - * (indicating loss of lock). - * - * This is a Mandatory value. - */ - GpsAccumulatedDeltaRangeState accumulated_delta_range_state; - - /** - * Accumulated delta range since the last channel reset in meters. - * A positive value indicates that the SV is moving away from the receiver. - * - * The sign of the 'accumulated delta range' and its relation to the sign of 'carrier phase' - * is given by the equation: - * accumulated delta range = -k * carrier phase (where k is a constant) - * - * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. - * However, it is expected that the data is only accurate when: - * 'accumulated delta range state' == GPS_ADR_STATE_VALID. - */ - double accumulated_delta_range_m; - - /** - * 1-Sigma uncertainty of the accumulated delta range in meters. - * This value must be populated if 'accumulated delta range state' != GPS_ADR_STATE_UNKNOWN. - */ - double accumulated_delta_range_uncertainty_m; - - /** - * Best derived Pseudorange by the chip-set, in meters. - * The value contains the 'pseudorange uncertainty' in it. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE. - */ - double pseudorange_m; - - /** - * 1-Sigma uncertainty of the pseudorange in meters. - * The value contains the 'pseudorange' and 'clock' uncertainty in it. - * The uncertainty is represented as an absolute (single sided) value. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_PSEUDORANGE_UNCERTAINTY. - */ - double pseudorange_uncertainty_m; - - /** - * A fraction of the current C/A code cycle, in the range [0.0, 1023.0] - * This value contains the time (in Chip units) since the last C/A code cycle (GPS Msec epoch). - * - * The reference frequency is given by the field 'carrier_frequency_hz'. - * The value contains the 'code-phase uncertainty' in it. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE. - */ - double code_phase_chips; - - /** - * 1-Sigma uncertainty of the code-phase, in a fraction of chips. - * The uncertainty is represented as an absolute (single sided) value. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CODE_PHASE_UNCERTAINTY. - */ - double code_phase_uncertainty_chips; - - /** - * Carrier frequency at which codes and messages are modulated, it can be L1 or L2. - * If the field is not set, the carrier frequency is assumed to be L1. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_FREQUENCY. - */ - float carrier_frequency_hz; - - /** - * The number of full carrier cycles between the satellite and the receiver. - * The reference frequency is given by the field 'carrier_frequency_hz'. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_CYCLES. - */ - int64_t carrier_cycles; - - /** - * The RF phase detected by the receiver, in the range [0.0, 1.0]. - * This is usually the fractional part of the complete carrier phase measurement. - * - * The reference frequency is given by the field 'carrier_frequency_hz'. - * The value contains the 'carrier-phase uncertainty' in it. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE. - */ - double carrier_phase; - - /** - * 1-Sigma uncertainty of the carrier-phase. - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY. - */ - double carrier_phase_uncertainty; - - /** - * An enumeration that indicates the 'loss of lock' state of the event. - */ - GpsLossOfLock loss_of_lock; - - /** - * The number of GPS bits transmitted since Sat-Sun midnight (GPS week). - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_BIT_NUMBER. - */ - int32_t bit_number; - - /** - * The elapsed time since the last received bit in milliseconds, in the range [0, 20] - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_TIME_FROM_LAST_BIT. - */ - int16_t time_from_last_bit_ms; - - /** - * Doppler shift in Hz. - * A positive value indicates that the SV is moving toward the receiver. - * - * The reference frequency is given by the field 'carrier_frequency_hz'. - * The value contains the 'doppler shift uncertainty' in it. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT. - */ - double doppler_shift_hz; - - /** - * 1-Sigma uncertainty of the doppler shift in Hz. - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_DOPPLER_SHIFT_UNCERTAINTY. - */ - double doppler_shift_uncertainty_hz; - - /** - * An enumeration that indicates the 'multipath' state of the event. - */ - GpsMultipathIndicator multipath_indicator; - - /** - * Signal-to-noise ratio in dB. - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_SNR. - */ - double snr_db; - - /** - * Elevation in degrees, the valid range is [-90, 90]. - * The value contains the 'elevation uncertainty' in it. - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION. - */ - double elevation_deg; - - /** - * 1-Sigma uncertainty of the elevation in degrees, the valid range is [0, 90]. - * The uncertainty is represented as the absolute (single sided) value. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_ELEVATION_UNCERTAINTY. - */ - double elevation_uncertainty_deg; - - /** - * Azimuth in degrees, in the range [0, 360). - * The value contains the 'azimuth uncertainty' in it. - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH. - * */ - double azimuth_deg; - - /** - * 1-Sigma uncertainty of the azimuth in degrees, the valid range is [0, 180]. - * The uncertainty is represented as an absolute (single sided) value. - * - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_AZIMUTH_UNCERTAINTY. - */ - double azimuth_uncertainty_deg; - - /** - * Whether the GPS represented by the measurement was used for computing the most recent fix. - * If the data is available, 'flags' must contain GPS_MEASUREMENT_HAS_USED_IN_FIX. - */ - bool used_in_fix; -} GpsMeasurement; - -/** Represents a reading of GPS measurements. */ -typedef struct { - /** set to sizeof(GpsData) */ - size_t size; - - /** Number of measurements. */ - size_t measurement_count; - - /** The array of measurements. */ - GpsMeasurement measurements[GPS_MAX_MEASUREMENT]; - - /** The GPS clock time reading. */ - GpsClock clock; -} GpsData; - -/** - * The callback for to report measurements from the HAL. - * - * Parameters: - * data - A data structure containing the measurements. - */ -typedef void (*gps_measurement_callback) (GpsData* data); - -typedef struct { - /** set to sizeof(GpsMeasurementCallbacks) */ - size_t size; - gps_measurement_callback measurement_callback; -} GpsMeasurementCallbacks; - -#define GPS_MEASUREMENT_OPERATION_SUCCESS 0 -#define GPS_MEASUREMENT_ERROR_ALREADY_INIT -100 -#define GPS_MEASUREMENT_ERROR_GENERIC -101 - -/** - * Extended interface for GPS Measurements support. - */ -typedef struct { - /** Set to sizeof(GpsMeasurementInterface) */ - size_t size; - - /** - * Initializes the interface and registers the callback routines with the HAL. - * After a successful call to 'init' the HAL must begin to provide updates at its own phase. - * - * Status: - * GPS_MEASUREMENT_OPERATION_SUCCESS - * GPS_MEASUREMENT_ERROR_ALREADY_INIT - if a callback has already been registered without a - * corresponding call to 'close' - * GPS_MEASUREMENT_ERROR_GENERIC - if any other error occurred, it is expected that the HAL - * will not generate any updates upon returning this error code. - */ - int (*init) (GpsMeasurementCallbacks* callbacks); - - /** - * Stops updates from the HAL, and unregisters the callback routines. - * After a call to stop, the previously registered callbacks must be considered invalid by the - * HAL. - * If stop is invoked without a previous 'init', this function should perform no work. - */ - void (*close) (); - -} GpsMeasurementInterface; - - -/** Represents a GPS navigation message (or a fragment of it). */ -typedef struct { - /** set to sizeof(GpsNavigationMessage) */ - size_t size; - - /** - * Pseudo-random number in the range of [1, 32] - * This is a Mandatory value. - */ - int8_t prn; - - /** - * The type of message contained in the structure. - * This is a Mandatory value. - */ - GpsNavigationMessageType type; - - /** - * The status of the received navigation message. - * No need to send any navigation message that contains words with parity error and cannot be - * corrected. - */ - NavigationMessageStatus status; - - /** - * Message identifier. - * It provides an index so the complete Navigation Message can be assembled. i.e. fo L1 C/A - * subframe 4 and 5, this value corresponds to the 'frame id' of the navigation message. - * Subframe 1, 2, 3 does not contain a 'frame id' and this value can be set to -1. - */ - int16_t message_id; - - /** - * Sub-message identifier. - * If required by the message 'type', this value contains a sub-index within the current - * message (or frame) that is being transmitted. - * i.e. for L1 C/A the submessage id corresponds to the sub-frame id of the navigation message. - */ - int16_t submessage_id; - - /** - * The length of the data (in bytes) contained in the current message. - * If this value is different from zero, 'data' must point to an array of the same size. - * e.g. for L1 C/A the size of the sub-frame will be 40 bytes (10 words, 30 bits/word). - * - * This is a Mandatory value. - */ - size_t data_length; - - /** - * The data of the reported GPS message. - * The bytes (or words) specified using big endian format (MSB first). - * - * For L1 C/A, each subframe contains 10 30-bit GPS words. Each GPS word (30 bits) should be - * fitted into the last 30 bits in a 4-byte word (skip B31 and B32), with MSB first. - */ - uint8_t* data; - -} GpsNavigationMessage; - -/** - * The callback to report an available fragment of a GPS navigation messages from the HAL. - * - * Parameters: - * message - The GPS navigation submessage/subframe representation. - */ -typedef void (*gps_navigation_message_callback) (GpsNavigationMessage* message); - -typedef struct { - /** set to sizeof(GpsNavigationMessageCallbacks) */ - size_t size; - gps_navigation_message_callback navigation_message_callback; -} GpsNavigationMessageCallbacks; - -#define GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS 0 -#define GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT -100 -#define GPS_NAVIGATION_MESSAGE_ERROR_GENERIC -101 - -/** - * Extended interface for GPS navigation message reporting support. - */ -typedef struct { - /** Set to sizeof(GpsNavigationMessageInterface) */ - size_t size; - - /** - * Initializes the interface and registers the callback routines with the HAL. - * After a successful call to 'init' the HAL must begin to provide updates as they become - * available. - * - * Status: - * GPS_NAVIGATION_MESSAGE_OPERATION_SUCCESS - * GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT - if a callback has already been registered - * without a corresponding call to 'close'. - * GPS_NAVIGATION_MESSAGE_ERROR_GENERIC - if any other error occurred, it is expected that - * the HAL will not generate any updates upon returning this error code. - */ - int (*init) (GpsNavigationMessageCallbacks* callbacks); - - /** - * Stops updates from the HAL, and unregisters the callback routines. - * After a call to stop, the previously registered callbacks must be considered invalid by the - * HAL. - * If stop is invoked without a previous 'init', this function should perform no work. - */ - void (*close) (); - -} GpsNavigationMessageInterface; - -/** - * Interface for passing GNSS configuration contents from platform to HAL. - */ -typedef struct { - /** Set to sizeof(GnssConfigurationInterface) */ - size_t size; - - /** - * Deliver GNSS configuration contents to HAL. - * Parameters: - * config_data - a pointer to a char array which holds what usually is expected from - file(/etc/gps.conf), i.e., a sequence of UTF8 strings separated by '\n'. - * length - total number of UTF8 characters in configuraiton data. - * - * IMPORTANT: - * GPS HAL should expect this function can be called multiple times. And it may be - * called even when GpsLocationProvider is already constructed and enabled. GPS HAL - * should maintain the existing requests for various callback regardless the change - * in configuration data. - */ - void (*configuration_update) (const char* config_data, int32_t length); -} GnssConfigurationInterface; - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_GPS_H */ - diff --git a/third_party/android_hardware_libhardware/include/hardware/gralloc.h b/third_party/android_hardware_libhardware/include/hardware/gralloc.h deleted file mode 100644 index 07ac0290b..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/gralloc.h +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - - -#ifndef ANDROID_GRALLOC_INTERFACE_H -#define ANDROID_GRALLOC_INTERFACE_H - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -__BEGIN_DECLS - -/** - * Module versioning information for the Gralloc hardware module, based on - * gralloc_module_t.common.module_api_version. - * - * Version History: - * - * GRALLOC_MODULE_API_VERSION_0_1: - * Initial Gralloc hardware module API. - * - * GRALLOC_MODULE_API_VERSION_0_2: - * Add support for flexible YCbCr format with (*lock_ycbcr)() method. - * - * GRALLOC_MODULE_API_VERSION_0_3: - * Add support for fence passing to/from lock/unlock. - */ - -#define GRALLOC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) -#define GRALLOC_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) -#define GRALLOC_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) - -#define GRALLOC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) - -/** - * The id of this module - */ -#define GRALLOC_HARDWARE_MODULE_ID "gralloc" - -/** - * Name of the graphics device to open - */ - -#define GRALLOC_HARDWARE_GPU0 "gpu0" - -enum { - /* buffer is never read in software */ - GRALLOC_USAGE_SW_READ_NEVER = 0x00000000, - /* buffer is rarely read in software */ - GRALLOC_USAGE_SW_READ_RARELY = 0x00000002, - /* buffer is often read in software */ - GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003, - /* mask for the software read values */ - GRALLOC_USAGE_SW_READ_MASK = 0x0000000F, - - /* buffer is never written in software */ - GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000, - /* buffer is rarely written in software */ - GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020, - /* buffer is often written in software */ - GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030, - /* mask for the software write values */ - GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0, - - /* buffer will be used as an OpenGL ES texture */ - GRALLOC_USAGE_HW_TEXTURE = 0x00000100, - /* buffer will be used as an OpenGL ES render target */ - GRALLOC_USAGE_HW_RENDER = 0x00000200, - /* buffer will be used by the 2D hardware blitter */ - GRALLOC_USAGE_HW_2D = 0x00000400, - /* buffer will be used by the HWComposer HAL module */ - GRALLOC_USAGE_HW_COMPOSER = 0x00000800, - /* buffer will be used with the framebuffer device */ - GRALLOC_USAGE_HW_FB = 0x00001000, - - /* buffer should be displayed full-screen on an external display when - * possible */ - GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000, - - /* Must have a hardware-protected path to external display sink for - * this buffer. If a hardware-protected path is not available, then - * either don't composite only this buffer (preferred) to the - * external sink, or (less desirable) do not route the entire - * composition to the external sink. */ - GRALLOC_USAGE_PROTECTED = 0x00004000, - - /* buffer may be used as a cursor */ - GRALLOC_USAGE_CURSOR = 0x00008000, - - /* buffer will be used with the HW video encoder */ - GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000, - /* buffer will be written by the HW camera pipeline */ - GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000, - /* buffer will be read by the HW camera pipeline */ - GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000, - /* buffer will be used as part of zero-shutter-lag queue */ - GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000, - /* mask for the camera access values */ - GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000, - /* mask for the software usage bit-mask */ - GRALLOC_USAGE_HW_MASK = 0x00071F00, - - /* buffer will be used as a RenderScript Allocation */ - GRALLOC_USAGE_RENDERSCRIPT = 0x00100000, - - /* Set by the consumer to indicate to the producer that they may attach a - * buffer that they did not detach from the BufferQueue. Will be filtered - * out by GRALLOC_USAGE_ALLOC_MASK, so gralloc modules will not need to - * handle this flag. */ - GRALLOC_USAGE_FOREIGN_BUFFERS = 0x00200000, - - /* Mask of all flags which could be passed to a gralloc module for buffer - * allocation. Any flags not in this mask do not need to be handled by - * gralloc modules. */ - GRALLOC_USAGE_ALLOC_MASK = ~(GRALLOC_USAGE_FOREIGN_BUFFERS), - - /* implementation-specific private usage flags */ - GRALLOC_USAGE_PRIVATE_0 = 0x10000000, - GRALLOC_USAGE_PRIVATE_1 = 0x20000000, - GRALLOC_USAGE_PRIVATE_2 = 0x40000000, - GRALLOC_USAGE_PRIVATE_3 = 0x80000000, - GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000, - -#ifdef EXYNOS4_ENHANCEMENTS - /* SAMSUNG */ - GRALLOC_USAGE_PRIVATE_NONECACHE = 0x00800000, - - GRALLOC_USAGE_HW_FIMC1 = 0x01000000, - GRALLOC_USAGE_HW_ION = 0x02000000, - GRALLOC_USAGE_YUV_ADDR = 0x04000000, - GRALLOC_USAGE_CAMERA = 0x08000000, - - /* SEC Private usage , for Overlay path at HWC */ - GRALLOC_USAGE_HWC_HWOVERLAY = 0x20000000, -#endif -}; - -/*****************************************************************************/ - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct gralloc_module_t { - struct hw_module_t common; - - /* - * (*registerBuffer)() must be called before a buffer_handle_t that has not - * been created with (*alloc_device_t::alloc)() can be used. - * - * This is intended to be used with buffer_handle_t's that have been - * received in this process through IPC. - * - * This function checks that the handle is indeed a valid one and prepares - * it for use with (*lock)() and (*unlock)(). - * - * It is not necessary to call (*registerBuffer)() on a handle created - * with (*alloc_device_t::alloc)(). - * - * returns an error if this buffer_handle_t is not valid. - */ - int (*registerBuffer)(struct gralloc_module_t const* module, - buffer_handle_t handle); - - /* - * (*unregisterBuffer)() is called once this handle is no longer needed in - * this process. After this call, it is an error to call (*lock)(), - * (*unlock)(), or (*registerBuffer)(). - * - * This function doesn't close or free the handle itself; this is done - * by other means, usually through libcutils's native_handle_close() and - * native_handle_free(). - * - * It is an error to call (*unregisterBuffer)() on a buffer that wasn't - * explicitly registered first. - */ - int (*unregisterBuffer)(struct gralloc_module_t const* module, - buffer_handle_t handle); - - /* - * The (*lock)() method is called before a buffer is accessed for the - * specified usage. This call may block, for instance if the h/w needs - * to finish rendering or if CPU caches need to be synchronized. - * - * The caller promises to modify only pixels in the area specified - * by (l,t,w,h). - * - * The content of the buffer outside of the specified area is NOT modified - * by this call. - * - * If usage specifies GRALLOC_USAGE_SW_*, vaddr is filled with the address - * of the buffer in virtual memory. - * - * Note calling (*lock)() on HAL_PIXEL_FORMAT_YCbCr_*_888 buffers will fail - * and return -EINVAL. These buffers must be locked with (*lock_ycbcr)() - * instead. - * - * THREADING CONSIDERATIONS: - * - * It is legal for several different threads to lock a buffer from - * read access, none of the threads are blocked. - * - * However, locking a buffer simultaneously for write or read/write is - * undefined, but: - * - shall not result in termination of the process - * - shall not block the caller - * It is acceptable to return an error or to leave the buffer's content - * into an indeterminate state. - * - * If the buffer was created with a usage mask incompatible with the - * requested usage flags here, -EINVAL is returned. - * - */ - - int (*lock)(struct gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int l, int t, int w, int h, - void** vaddr); - - - /* - * The (*unlock)() method must be called after all changes to the buffer - * are completed. - */ - - int (*unlock)(struct gralloc_module_t const* module, - buffer_handle_t handle); - -#ifdef EXYNOS4_ENHANCEMENTS - int (*getphys) (struct gralloc_module_t const* module, - buffer_handle_t handle, void** paddr); -#endif - - /* reserved for future use */ - int (*perform)(struct gralloc_module_t const* module, - int operation, ... ); - - /* - * The (*lock_ycbcr)() method is like the (*lock)() method, with the - * difference that it fills a struct ycbcr with a description of the buffer - * layout, and zeroes out the reserved fields. - * - * If the buffer format is not compatible with a flexible YUV format (e.g. - * the buffer layout cannot be represented with the ycbcr struct), it - * will return -EINVAL. - * - * This method must work on buffers with HAL_PIXEL_FORMAT_YCbCr_*_888 - * if supported by the device, as well as with any other format that is - * requested by the multimedia codecs when they are configured with a - * flexible-YUV-compatible color-format with android native buffers. - * - * Note that this method may also be called on buffers of other formats, - * including non-YUV formats. - * - * Added in GRALLOC_MODULE_API_VERSION_0_2. - */ - - int (*lock_ycbcr)(struct gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int l, int t, int w, int h, - struct android_ycbcr *ycbcr); - - /* - * The (*lockAsync)() method is like the (*lock)() method except - * that the buffer's sync fence object is passed into the lock - * call instead of requiring the caller to wait for completion. - * - * The gralloc implementation takes ownership of the fenceFd and - * is responsible for closing it when no longer needed. - * - * Added in GRALLOC_MODULE_API_VERSION_0_3. - */ - int (*lockAsync)(struct gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int l, int t, int w, int h, - void** vaddr, int fenceFd); - - /* - * The (*unlockAsync)() method is like the (*unlock)() method - * except that a buffer sync fence object is returned from the - * lock call, representing the completion of any pending work - * performed by the gralloc implementation. - * - * The caller takes ownership of the fenceFd and is responsible - * for closing it when no longer needed. - * - * Added in GRALLOC_MODULE_API_VERSION_0_3. - */ - int (*unlockAsync)(struct gralloc_module_t const* module, - buffer_handle_t handle, int* fenceFd); - - /* - * The (*lockAsync_ycbcr)() method is like the (*lock_ycbcr)() - * method except that the buffer's sync fence object is passed - * into the lock call instead of requiring the caller to wait for - * completion. - * - * The gralloc implementation takes ownership of the fenceFd and - * is responsible for closing it when no longer needed. - * - * Added in GRALLOC_MODULE_API_VERSION_0_3. - */ - int (*lockAsync_ycbcr)(struct gralloc_module_t const* module, - buffer_handle_t handle, int usage, - int l, int t, int w, int h, - struct android_ycbcr *ycbcr, int fenceFd); - - /* reserved for future use */ - void* reserved_proc[3]; -} gralloc_module_t; - -/*****************************************************************************/ - -/** - * Every device data structure must begin with hw_device_t - * followed by module specific public methods and attributes. - */ - -typedef struct alloc_device_t { - struct hw_device_t common; - - /* - * (*alloc)() Allocates a buffer in graphic memory with the requested - * parameters and returns a buffer_handle_t and the stride in pixels to - * allow the implementation to satisfy hardware constraints on the width - * of a pixmap (eg: it may have to be multiple of 8 pixels). - * The CALLER TAKES OWNERSHIP of the buffer_handle_t. - * - * If format is HAL_PIXEL_FORMAT_YCbCr_420_888, the returned stride must be - * 0, since the actual strides are available from the android_ycbcr - * structure. - * - * Returns 0 on success or -errno on error. - */ - - int (*alloc)(struct alloc_device_t* dev, - int w, int h, int format, int usage, - buffer_handle_t* handle, int* stride); - - /* - * (*free)() Frees a previously allocated buffer. - * Behavior is undefined if the buffer is still mapped in any process, - * but shall not result in termination of the program or security breaches - * (allowing a process to get access to another process' buffers). - * THIS FUNCTION TAKES OWNERSHIP of the buffer_handle_t which becomes - * invalid after the call. - * - * Returns 0 on success or -errno on error. - */ - int (*free)(struct alloc_device_t* dev, - buffer_handle_t handle); - - /* This hook is OPTIONAL. - * - * If non NULL it will be caused by SurfaceFlinger on dumpsys - */ - void (*dump)(struct alloc_device_t *dev, char *buff, int buff_len); - - void* reserved_proc[7]; -} alloc_device_t; - - -/** convenience API for opening and closing a supported device */ - -static inline int gralloc_open(const struct hw_module_t* module, - struct alloc_device_t** device) { - return module->methods->open(module, - GRALLOC_HARDWARE_GPU0, (struct hw_device_t**)device); -} - -static inline int gralloc_close(struct alloc_device_t* device) { - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_GRALLOC_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/hardware.h b/third_party/android_hardware_libhardware/include/hardware/hardware.h deleted file mode 100644 index 74f57aa4c..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hardware.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_HARDWARE_H -#define ANDROID_INCLUDE_HARDWARE_HARDWARE_H - -#include -#include - -#include -#include - -__BEGIN_DECLS - -/* - * Value for the hw_module_t.tag field - */ - -#define MAKE_TAG_CONSTANT(A,B,C,D) (((A) << 24) | ((B) << 16) | ((C) << 8) | (D)) - -#define HARDWARE_MODULE_TAG MAKE_TAG_CONSTANT('H', 'W', 'M', 'T') -#define HARDWARE_DEVICE_TAG MAKE_TAG_CONSTANT('H', 'W', 'D', 'T') - -#define HARDWARE_MAKE_API_VERSION(maj,min) \ - ((((maj) & 0xff) << 8) | ((min) & 0xff)) - -#define HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) \ - ((((maj) & 0xff) << 24) | (((min) & 0xff) << 16) | ((hdr) & 0xffff)) -#define HARDWARE_API_VERSION_2_MAJ_MIN_MASK 0xffff0000 -#define HARDWARE_API_VERSION_2_HEADER_MASK 0x0000ffff - - -/* - * The current HAL API version. - * - * All module implementations must set the hw_module_t.hal_api_version field - * to this value when declaring the module with HAL_MODULE_INFO_SYM. - * - * Note that previous implementations have always set this field to 0. - * Therefore, libhardware HAL API will always consider versions 0.0 and 1.0 - * to be 100% binary compatible. - * - */ -#define HARDWARE_HAL_API_VERSION HARDWARE_MAKE_API_VERSION(1, 0) - -/* - * Helper macros for module implementors. - * - * The derived modules should provide convenience macros for supported - * versions so that implementations can explicitly specify module/device - * versions at definition time. - * - * Use this macro to set the hw_module_t.module_api_version field. - */ -#define HARDWARE_MODULE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) -#define HARDWARE_MODULE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) - -/* - * Use this macro to set the hw_device_t.version field - */ -#define HARDWARE_DEVICE_API_VERSION(maj,min) HARDWARE_MAKE_API_VERSION(maj,min) -#define HARDWARE_DEVICE_API_VERSION_2(maj,min,hdr) HARDWARE_MAKE_API_VERSION_2(maj,min,hdr) - -struct hw_module_t; -struct hw_module_methods_t; -struct hw_device_t; - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct hw_module_t { - /** tag must be initialized to HARDWARE_MODULE_TAG */ - uint32_t tag; - - /** - * The API version of the implemented module. The module owner is - * responsible for updating the version when a module interface has - * changed. - * - * The derived modules such as gralloc and audio own and manage this field. - * The module user must interpret the version field to decide whether or - * not to inter-operate with the supplied module implementation. - * For example, SurfaceFlinger is responsible for making sure that - * it knows how to manage different versions of the gralloc-module API, - * and AudioFlinger must know how to do the same for audio-module API. - * - * The module API version should include a major and a minor component. - * For example, version 1.0 could be represented as 0x0100. This format - * implies that versions 0x0100-0x01ff are all API-compatible. - * - * In the future, libhardware will expose a hw_get_module_version() - * (or equivalent) function that will take minimum/maximum supported - * versions as arguments and would be able to reject modules with - * versions outside of the supplied range. - */ - uint16_t module_api_version; -#define version_major module_api_version - /** - * version_major/version_minor defines are supplied here for temporary - * source code compatibility. They will be removed in the next version. - * ALL clients must convert to the new version format. - */ - - /** - * The API version of the HAL module interface. This is meant to - * version the hw_module_t, hw_module_methods_t, and hw_device_t - * structures and definitions. - * - * The HAL interface owns this field. Module users/implementations - * must NOT rely on this value for version information. - * - * Presently, 0 is the only valid value. - */ - uint16_t hal_api_version; -#define version_minor hal_api_version - - /** Identifier of module */ - const char *id; - - /** Name of this module */ - const char *name; - - /** Author/owner/implementor of the module */ - const char *author; - - /** Modules methods */ - struct hw_module_methods_t* methods; - - /** module's dso */ - void* dso; - -#ifdef __LP64__ - uint64_t reserved[32-7]; -#else - /** padding to 128 bytes, reserved for future use */ - uint32_t reserved[32-7]; -#endif - -} hw_module_t; - -typedef struct hw_module_methods_t { - /** Open a specific device */ - int (*open)(const struct hw_module_t* module, const char* id, - struct hw_device_t** device); - -} hw_module_methods_t; - -/** - * Every device data structure must begin with hw_device_t - * followed by module specific public methods and attributes. - */ -typedef struct hw_device_t { - /** tag must be initialized to HARDWARE_DEVICE_TAG */ - uint32_t tag; - - /** - * Version of the module-specific device API. This value is used by - * the derived-module user to manage different device implementations. - * - * The module user is responsible for checking the module_api_version - * and device version fields to ensure that the user is capable of - * communicating with the specific module implementation. - * - * One module can support multiple devices with different versions. This - * can be useful when a device interface changes in an incompatible way - * but it is still necessary to support older implementations at the same - * time. One such example is the Camera 2.0 API. - * - * This field is interpreted by the module user and is ignored by the - * HAL interface itself. - */ - uint32_t version; - - /** reference to the module this device belongs to */ - struct hw_module_t* module; - - /** padding reserved for future use */ -#ifdef __LP64__ - uint64_t reserved[12]; -#else - uint32_t reserved[12]; -#endif - - /** Close this device */ - int (*close)(struct hw_device_t* device); - -} hw_device_t; - -/** - * Name of the hal_module_info - */ -#define HAL_MODULE_INFO_SYM HMI - -/** - * Name of the hal_module_info as a string - */ -#define HAL_MODULE_INFO_SYM_AS_STR "HMI" - -/** - * Get the module info associated with a module by id. - * - * @return: 0 == success, <0 == error and *module == NULL - */ -int hw_get_module(const char *id, const struct hw_module_t **module); - -/** - * Get the module info associated with a module instance by class 'class_id' - * and instance 'inst'. - * - * Some modules types necessitate multiple instances. For example audio supports - * multiple concurrent interfaces and thus 'audio' is the module class - * and 'primary' or 'a2dp' are module interfaces. This implies that the files - * providing these modules would be named audio.primary..so and - * audio.a2dp..so - * - * @return: 0 == success, <0 == error and *module == NULL - */ -int hw_get_module_by_class(const char *class_id, const char *inst, - const struct hw_module_t **module); - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_HARDWARE_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h b/third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h deleted file mode 100644 index ab70f92e2..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hdmi_cec.h +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H -#define ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H - -#include -#include - -#include - -__BEGIN_DECLS - -#define HDMI_CEC_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define HDMI_CEC_MODULE_API_VERSION_CURRENT HDMI_MODULE_API_VERSION_1_0 - -#define HDMI_CEC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) -#define HDMI_CEC_DEVICE_API_VERSION_CURRENT HDMI_DEVICE_API_VERSION_1_0 - -#define HDMI_CEC_HARDWARE_MODULE_ID "hdmi_cec" -#define HDMI_CEC_HARDWARE_INTERFACE "hdmi_cec_hw_if" - -typedef enum cec_device_type { - CEC_DEVICE_INACTIVE = -1, - CEC_DEVICE_TV = 0, - CEC_DEVICE_RECORDER = 1, - CEC_DEVICE_RESERVED = 2, - CEC_DEVICE_TUNER = 3, - CEC_DEVICE_PLAYBACK = 4, - CEC_DEVICE_AUDIO_SYSTEM = 5, - CEC_DEVICE_MAX = CEC_DEVICE_AUDIO_SYSTEM -} cec_device_type_t; - -typedef enum cec_logical_address { - CEC_ADDR_TV = 0, - CEC_ADDR_RECORDER_1 = 1, - CEC_ADDR_RECORDER_2 = 2, - CEC_ADDR_TUNER_1 = 3, - CEC_ADDR_PLAYBACK_1 = 4, - CEC_ADDR_AUDIO_SYSTEM = 5, - CEC_ADDR_TUNER_2 = 6, - CEC_ADDR_TUNER_3 = 7, - CEC_ADDR_PLAYBACK_2 = 8, - CEC_ADDR_RECORDER_3 = 9, - CEC_ADDR_TUNER_4 = 10, - CEC_ADDR_PLAYBACK_3 = 11, - CEC_ADDR_RESERVED_1 = 12, - CEC_ADDR_RESERVED_2 = 13, - CEC_ADDR_FREE_USE = 14, - CEC_ADDR_UNREGISTERED = 15, - CEC_ADDR_BROADCAST = 15 -} cec_logical_address_t; - -/* - * HDMI CEC messages - */ -enum cec_message_type { - CEC_MESSAGE_FEATURE_ABORT = 0x00, - CEC_MESSAGE_IMAGE_VIEW_ON = 0x04, - CEC_MESSAGE_TUNER_STEP_INCREMENT = 0x05, - CEC_MESSAGE_TUNER_STEP_DECREMENT = 0x06, - CEC_MESSAGE_TUNER_DEVICE_STATUS = 0x07, - CEC_MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08, - CEC_MESSAGE_RECORD_ON = 0x09, - CEC_MESSAGE_RECORD_STATUS = 0x0A, - CEC_MESSAGE_RECORD_OFF = 0x0B, - CEC_MESSAGE_TEXT_VIEW_ON = 0x0D, - CEC_MESSAGE_RECORD_TV_SCREEN = 0x0F, - CEC_MESSAGE_GIVE_DECK_STATUS = 0x1A, - CEC_MESSAGE_DECK_STATUS = 0x1B, - CEC_MESSAGE_SET_MENU_LANGUAGE = 0x32, - CEC_MESSAGE_CLEAR_ANALOG_TIMER = 0x33, - CEC_MESSAGE_SET_ANALOG_TIMER = 0x34, - CEC_MESSAGE_TIMER_STATUS = 0x35, - CEC_MESSAGE_STANDBY = 0x36, - CEC_MESSAGE_PLAY = 0x41, - CEC_MESSAGE_DECK_CONTROL = 0x42, - CEC_MESSAGE_TIMER_CLEARED_STATUS = 0x043, - CEC_MESSAGE_USER_CONTROL_PRESSED = 0x44, - CEC_MESSAGE_USER_CONTROL_RELEASED = 0x45, - CEC_MESSAGE_GIVE_OSD_NAME = 0x46, - CEC_MESSAGE_SET_OSD_NAME = 0x47, - CEC_MESSAGE_SET_OSD_STRING = 0x64, - CEC_MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67, - CEC_MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70, - CEC_MESSAGE_GIVE_AUDIO_STATUS = 0x71, - CEC_MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72, - CEC_MESSAGE_REPORT_AUDIO_STATUS = 0x7A, - CEC_MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D, - CEC_MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E, - CEC_MESSAGE_ROUTING_CHANGE = 0x80, - CEC_MESSAGE_ROUTING_INFORMATION = 0x81, - CEC_MESSAGE_ACTIVE_SOURCE = 0x82, - CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83, - CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84, - CEC_MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85, - CEC_MESSAGE_SET_STREAM_PATH = 0x86, - CEC_MESSAGE_DEVICE_VENDOR_ID = 0x87, - CEC_MESSAGE_VENDOR_COMMAND = 0x89, - CEC_MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A, - CEC_MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B, - CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C, - CEC_MESSAGE_MENU_REQUEST = 0x8D, - CEC_MESSAGE_MENU_STATUS = 0x8E, - CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F, - CEC_MESSAGE_REPORT_POWER_STATUS = 0x90, - CEC_MESSAGE_GET_MENU_LANGUAGE = 0x91, - CEC_MESSAGE_SELECT_ANALOG_SERVICE = 0x92, - CEC_MESSAGE_SELECT_DIGITAL_SERVICE = 0x93, - CEC_MESSAGE_SET_DIGITAL_TIMER = 0x97, - CEC_MESSAGE_CLEAR_DIGITAL_TIMER = 0x99, - CEC_MESSAGE_SET_AUDIO_RATE = 0x9A, - CEC_MESSAGE_INACTIVE_SOURCE = 0x9D, - CEC_MESSAGE_CEC_VERSION = 0x9E, - CEC_MESSAGE_GET_CEC_VERSION = 0x9F, - CEC_MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0, - CEC_MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1, - CEC_MESSAGE_SET_EXTERNAL_TIMER = 0xA2, - CEC_MESSAGE_INITIATE_ARC = 0xC0, - CEC_MESSAGE_REPORT_ARC_INITIATED = 0xC1, - CEC_MESSAGE_REPORT_ARC_TERMINATED = 0xC2, - CEC_MESSAGE_REQUEST_ARC_INITIATION = 0xC3, - CEC_MESSAGE_REQUEST_ARC_TERMINATION = 0xC4, - CEC_MESSAGE_TERMINATE_ARC = 0xC5, - CEC_MESSAGE_ABORT = 0xFF -}; - -/* - * Operand description [Abort Reason] - */ -enum abort_reason { - ABORT_UNRECOGNIZED_MODE = 0, - ABORT_NOT_IN_CORRECT_MODE = 1, - ABORT_CANNOT_PROVIDE_SOURCE = 2, - ABORT_INVALID_OPERAND = 3, - ABORT_REFUSED = 4, - ABORT_UNABLE_TO_DETERMINE = 5 -}; - -/* - * HDMI event type. used for hdmi_event_t. - */ -enum { - HDMI_EVENT_CEC_MESSAGE = 1, - HDMI_EVENT_HOT_PLUG = 2, -}; - -/* - * HDMI hotplug event type. Used when the event - * type is HDMI_EVENT_HOT_PLUG. - */ -enum { - HDMI_NOT_CONNECTED = 0, - HDMI_CONNECTED = 1 -}; - -/* - * error code used for send_message. - */ -enum { - HDMI_RESULT_SUCCESS = 0, - HDMI_RESULT_NACK = 1, /* not acknowledged */ - HDMI_RESULT_BUSY = 2, /* bus is busy */ - HDMI_RESULT_FAIL = 3, -}; - -/* - * HDMI port type. - */ -typedef enum hdmi_port_type { - HDMI_INPUT = 0, - HDMI_OUTPUT = 1 -} hdmi_port_type_t; - -/* - * Flags used for set_option() - */ -enum { - /* When set to false, HAL does not wake up the system upon receiving - * or . Used when user changes the TV - * settings to disable the auto TV on functionality. - * True by default. - */ - HDMI_OPTION_WAKEUP = 1, - - /* When set to false, all the CEC commands are discarded. Used when - * user changes the TV settings to disable CEC functionality. - * True by default. - */ - HDMI_OPTION_ENABLE_CEC = 2, - - /* Setting this flag to false means Android system will stop handling - * CEC service and yield the control over to the microprocessor that is - * powered on through the standby mode. When set to true, the system - * will gain the control over, hence telling the microprocessor to stop - * handling the cec commands. This is called when system goes - * in and out of standby mode to notify the microprocessor that it should - * start/stop handling CEC commands on behalf of the system. - * False by default. - */ - HDMI_OPTION_SYSTEM_CEC_CONTROL = 3, - - /* Option 4 not used */ - - /* Passes the updated language information of Android system. - * Contains 3-byte ASCII code as defined in ISO/FDIS 639-2. Can be - * used for HAL to respond to while in standby mode. - * English(eng), for example, is converted to 0x656e67. - */ - HDMI_OPTION_SET_LANG = 5, -}; - -/* - * Maximum length in bytes of cec message body (exclude header block), - * should not exceed 16 (spec CEC 6 Frame Description) - */ -#define CEC_MESSAGE_BODY_MAX_LENGTH 16 - -typedef struct cec_message { - /* logical address of sender */ - cec_logical_address_t initiator; - - /* logical address of receiver */ - cec_logical_address_t destination; - - /* Length in bytes of body, range [0, CEC_MESSAGE_BODY_MAX_LENGTH] */ - size_t length; - unsigned char body[CEC_MESSAGE_BODY_MAX_LENGTH]; -} cec_message_t; - -typedef struct hotplug_event { - /* - * true if the cable is connected; otherwise false. - */ - int connected; - int port_id; -} hotplug_event_t; - -typedef struct tx_status_event { - int status; - int opcode; /* CEC opcode */ -} tx_status_event_t; - -/* - * HDMI event generated from HAL. - */ -typedef struct hdmi_event { - int type; - struct hdmi_cec_device* dev; - union { - cec_message_t cec; - hotplug_event_t hotplug; - }; -} hdmi_event_t; - -/* - * HDMI port descriptor - */ -typedef struct hdmi_port_info { - hdmi_port_type_t type; - // Port ID should start from 1 which corresponds to HDMI "port 1". - int port_id; - int cec_supported; - int arc_supported; - uint16_t physical_address; -} hdmi_port_info_t; - -/* - * Callback function type that will be called by HAL implementation. - * Services can not close/open the device in the callback. - */ -typedef void (*event_callback_t)(const hdmi_event_t* event, void* arg); - -typedef struct hdmi_cec_module { - /** - * Common methods of the HDMI CEC module. This *must* be the first member of - * hdmi_cec_module as users of this structure will cast a hw_module_t to hdmi_cec_module - * pointer in contexts where it's known the hw_module_t references a hdmi_cec_module. - */ - struct hw_module_t common; -} hdmi_module_t; - -/* - * HDMI-CEC HAL interface definition. - */ -typedef struct hdmi_cec_device { - /** - * Common methods of the HDMI CEC device. This *must* be the first member of - * hdmi_cec_device as users of this structure will cast a hw_device_t to hdmi_cec_device - * pointer in contexts where it's known the hw_device_t references a hdmi_cec_device. - */ - struct hw_device_t common; - - /* - * (*add_logical_address)() passes the logical address that will be used - * in this system. - * - * HAL may use it to configure the hardware so that the CEC commands addressed - * the given logical address can be filtered in. This method can be called - * as many times as necessary in order to support multiple logical devices. - * addr should be in the range of valid logical addresses for the call - * to succeed. - * - * Returns 0 on success or -errno on error. - */ - int (*add_logical_address)(const struct hdmi_cec_device* dev, cec_logical_address_t addr); - - /* - * (*clear_logical_address)() tells HAL to reset all the logical addresses. - * - * It is used when the system doesn't need to process CEC command any more, - * hence to tell HAL to stop receiving commands from the CEC bus, and change - * the state back to the beginning. - */ - void (*clear_logical_address)(const struct hdmi_cec_device* dev); - - /* - * (*get_physical_address)() returns the CEC physical address. The - * address is written to addr. - * - * The physical address depends on the topology of the network formed - * by connected HDMI devices. It is therefore likely to change if the cable - * is plugged off and on again. It is advised to call get_physical_address - * to get the updated address when hot plug event takes place. - * - * Returns 0 on success or -errno on error. - */ - int (*get_physical_address)(const struct hdmi_cec_device* dev, uint16_t* addr); - - /* - * (*send_message)() transmits HDMI-CEC message to other HDMI device. - * - * The method should be designed to return in a certain amount of time not - * hanging forever, which can happen if CEC signal line is pulled low for - * some reason. HAL implementation should take the situation into account - * so as not to wait forever for the message to get sent out. - * - * It should try retransmission at least once as specified in the standard. - * - * Returns error code. See HDMI_RESULT_SUCCESS, HDMI_RESULT_NACK, and - * HDMI_RESULT_BUSY. - */ - int (*send_message)(const struct hdmi_cec_device* dev, const cec_message_t*); - - /* - * (*register_event_callback)() registers a callback that HDMI-CEC HAL - * can later use for incoming CEC messages or internal HDMI events. - * When calling from C++, use the argument arg to pass the calling object. - * It will be passed back when the callback is invoked so that the context - * can be retrieved. - */ - void (*register_event_callback)(const struct hdmi_cec_device* dev, - event_callback_t callback, void* arg); - - /* - * (*get_version)() returns the CEC version supported by underlying hardware. - */ - void (*get_version)(const struct hdmi_cec_device* dev, int* version); - - /* - * (*get_vendor_id)() returns the identifier of the vendor. It is - * the 24-bit unique company ID obtained from the IEEE Registration - * Authority Committee (RAC). - */ - void (*get_vendor_id)(const struct hdmi_cec_device* dev, uint32_t* vendor_id); - - /* - * (*get_port_info)() returns the hdmi port information of underlying hardware. - * info is the list of HDMI port information, and 'total' is the number of - * HDMI ports in the system. - */ - void (*get_port_info)(const struct hdmi_cec_device* dev, - struct hdmi_port_info* list[], int* total); - - /* - * (*set_option)() passes flags controlling the way HDMI-CEC service works down - * to HAL implementation. Those flags will be used in case the feature needs - * update in HAL itself, firmware or microcontroller. - */ - void (*set_option)(const struct hdmi_cec_device* dev, int flag, int value); - - /* - * (*set_audio_return_channel)() configures ARC circuit in the hardware logic - * to start or stop the feature. Flag can be either 1 to start the feature - * or 0 to stop it. - * - * Returns 0 on success or -errno on error. - */ - void (*set_audio_return_channel)(const struct hdmi_cec_device* dev, int port_id, int flag); - - /* - * (*is_connected)() returns the connection status of the specified port. - * Returns HDMI_CONNECTED if a device is connected, otherwise HDMI_NOT_CONNECTED. - * The HAL should watch for +5V power signal to determine the status. - */ - int (*is_connected)(const struct hdmi_cec_device* dev, int port_id); - - /* Reserved for future use to maximum 16 functions. Must be NULL. */ - void* reserved[16 - 11]; -} hdmi_cec_device_t; - -/** convenience API for opening and closing a device */ - -static inline int hdmi_cec_open(const struct hw_module_t* module, - struct hdmi_cec_device** device) { - return module->methods->open(module, - HDMI_CEC_HARDWARE_INTERFACE, (struct hw_device_t**)device); -} - -static inline int hdmi_cec_close(struct hdmi_cec_device* device) { - return device->common.close(&device->common); -} - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_HDMI_CEC_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h b/third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h deleted file mode 100644 index f471d1ab7..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hw_auth_token.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#include - -#ifndef ANDROID_HARDWARE_HW_AUTH_TOKEN_H -#define ANDROID_HARDWARE_HW_AUTH_TOKEN_H - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -const uint8_t HW_AUTH_TOKEN_VERSION = 0; - -typedef enum { - HW_AUTH_NONE = 0, - HW_AUTH_PASSWORD = 1 << 0, - HW_AUTH_FINGERPRINT = 1 << 1, - // Additional entries should be powers of 2. - HW_AUTH_ANY = UINT32_MAX, -} hw_authenticator_type_t; - -/** - * Data format for an authentication record used to prove successful authentication. - */ -typedef struct __attribute__((__packed__)) { - uint8_t version; // Current version is 0 - uint64_t challenge; - uint64_t user_id; // secure user ID, not Android user ID - uint64_t authenticator_id; // secure authenticator ID - uint32_t authenticator_type; // hw_authenticator_type_t, in network order - uint64_t timestamp; // in network order - uint8_t hmac[32]; -} hw_auth_token_t; - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif // ANDROID_HARDWARE_HW_AUTH_TOKEN_H diff --git a/third_party/android_hardware_libhardware/include/hardware/hwcomposer.h b/third_party/android_hardware_libhardware/include/hardware/hwcomposer.h deleted file mode 100644 index aa466b300..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hwcomposer.h +++ /dev/null @@ -1,833 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H -#define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H - -#include -#include - -#include -#include -#include - -#include - -__BEGIN_DECLS - -/*****************************************************************************/ - -/* for compatibility */ -#define HWC_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1 -#define HWC_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1 -#define HWC_API_VERSION HWC_DEVICE_API_VERSION - -/*****************************************************************************/ - -/** - * The id of this module - */ -#define HWC_HARDWARE_MODULE_ID "hwcomposer" - -/** - * Name of the sensors device to open - */ -#define HWC_HARDWARE_COMPOSER "composer" - -typedef struct hwc_rect { - int left; - int top; - int right; - int bottom; -} hwc_rect_t; - -typedef struct hwc_frect { - float left; - float top; - float right; - float bottom; -} hwc_frect_t; - -typedef struct hwc_region { - size_t numRects; - hwc_rect_t const* rects; -} hwc_region_t; - -typedef struct hwc_color { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; -} hwc_color_t; - -typedef struct hwc_layer_1 { - /* - * compositionType is used to specify this layer's type and is set by either - * the hardware composer implementation, or by the caller (see below). - * - * This field is always reset to HWC_BACKGROUND or HWC_FRAMEBUFFER - * before (*prepare)() is called when the HWC_GEOMETRY_CHANGED flag is - * also set, otherwise, this field is preserved between (*prepare)() - * calls. - * - * HWC_BACKGROUND - * Always set by the caller before calling (*prepare)(), this value - * indicates this is a special "background" layer. The only valid field - * is backgroundColor. - * The HWC can toggle this value to HWC_FRAMEBUFFER to indicate it CANNOT - * handle the background color. - * - * - * HWC_FRAMEBUFFER_TARGET - * Always set by the caller before calling (*prepare)(), this value - * indicates this layer is the framebuffer surface used as the target of - * OpenGL ES composition. If the HWC sets all other layers to HWC_OVERLAY - * or HWC_BACKGROUND, then no OpenGL ES composition will be done, and - * this layer should be ignored during set(). - * - * This flag (and the framebuffer surface layer) will only be used if the - * HWC version is HWC_DEVICE_API_VERSION_1_1 or higher. In older versions, - * the OpenGL ES target surface is communicated by the (dpy, sur) fields - * in hwc_compositor_device_1_t. - * - * This value cannot be set by the HWC implementation. - * - * - * HWC_FRAMEBUFFER - * Set by the caller before calling (*prepare)() ONLY when the - * HWC_GEOMETRY_CHANGED flag is also set. - * - * Set by the HWC implementation during (*prepare)(), this indicates - * that the layer will be drawn into the framebuffer using OpenGL ES. - * The HWC can toggle this value to HWC_OVERLAY to indicate it will - * handle the layer. - * - * - * HWC_OVERLAY - * Set by the HWC implementation during (*prepare)(), this indicates - * that the layer will be handled by the HWC (ie: it must not be - * composited with OpenGL ES). - * - * - * HWC_SIDEBAND - * Set by the caller before calling (*prepare)(), this value indicates - * the contents of this layer come from a sideband video stream. - * - * The h/w composer is responsible for receiving new image buffers from - * the stream at the appropriate time (e.g. synchronized to a separate - * audio stream), compositing them with the current contents of other - * layers, and displaying the resulting image. This happens - * independently of the normal prepare/set cycle. The prepare/set calls - * only happen when other layers change, or when properties of the - * sideband layer such as position or size change. - * - * If the h/w composer can't handle the layer as a sideband stream for - * some reason (e.g. unsupported scaling/blending/rotation, or too many - * sideband layers) it can set compositionType to HWC_FRAMEBUFFER in - * (*prepare)(). However, doing so will result in the layer being shown - * as a solid color since the platform is not currently able to composite - * sideband layers with the GPU. This may be improved in future - * versions of the platform. - * - * - * HWC_CURSOR_OVERLAY - * Set by the HWC implementation during (*prepare)(), this value - * indicates the layer's composition will now be handled by the HWC. - * Additionally, the client can now asynchronously update the on-screen - * position of this layer using the setCursorPositionAsync() api. - */ - int32_t compositionType; - - /* - * hints is bit mask set by the HWC implementation during (*prepare)(). - * It is preserved between (*prepare)() calls, unless the - * HWC_GEOMETRY_CHANGED flag is set, in which case it is reset to 0. - * - * see hwc_layer_t::hints - */ - uint32_t hints; - - /* see hwc_layer_t::flags */ - uint32_t flags; - - union { - /* color of the background. hwc_color_t.a is ignored */ - hwc_color_t backgroundColor; - - struct { - union { - /* When compositionType is HWC_FRAMEBUFFER, HWC_OVERLAY, - * HWC_FRAMEBUFFER_TARGET, this is the handle of the buffer to - * compose. This handle is guaranteed to have been allocated - * from gralloc using the GRALLOC_USAGE_HW_COMPOSER usage flag. - * If the layer's handle is unchanged across two consecutive - * prepare calls and the HWC_GEOMETRY_CHANGED flag is not set - * for the second call then the HWComposer implementation may - * assume that the contents of the buffer have not changed. */ - buffer_handle_t handle; - - /* When compositionType is HWC_SIDEBAND, this is the handle - * of the sideband video stream to compose. */ - const native_handle_t* sidebandStream; - }; - - /* transformation to apply to the buffer during composition */ - uint32_t transform; - - /* blending to apply during composition */ - int32_t blending; - - /* area of the source to consider, the origin is the top-left corner of - * the buffer. As of HWC_DEVICE_API_VERSION_1_3, sourceRect uses floats. - * If the h/w can't support a non-integer source crop rectangle, it should - * punt to OpenGL ES composition. - */ - union { - // crop rectangle in integer (pre HWC_DEVICE_API_VERSION_1_3) - hwc_rect_t sourceCropi; - hwc_rect_t sourceCrop; // just for source compatibility - // crop rectangle in floats (as of HWC_DEVICE_API_VERSION_1_3) - hwc_frect_t sourceCropf; - }; - - /* where to composite the sourceCrop onto the display. The sourceCrop - * is scaled using linear filtering to the displayFrame. The origin is the - * top-left corner of the screen. - */ - hwc_rect_t displayFrame; - - /* visible region in screen space. The origin is the - * top-left corner of the screen. - * The visible region INCLUDES areas overlapped by a translucent layer. - */ - hwc_region_t visibleRegionScreen; - - /* Sync fence object that will be signaled when the buffer's - * contents are available. May be -1 if the contents are already - * available. This field is only valid during set(), and should be - * ignored during prepare(). The set() call must not wait for the - * fence to be signaled before returning, but the HWC must wait for - * all buffers to be signaled before reading from them. - * - * HWC_FRAMEBUFFER layers will never have an acquire fence, since - * reads from them are complete before the framebuffer is ready for - * display. - * - * HWC_SIDEBAND layers will never have an acquire fence, since - * synchronization is handled through implementation-defined - * sideband mechanisms. - * - * The HWC takes ownership of the acquireFenceFd and is responsible - * for closing it when no longer needed. - */ - int acquireFenceFd; - - /* During set() the HWC must set this field to a file descriptor for - * a sync fence object that will signal after the HWC has finished - * reading from the buffer. The field is ignored by prepare(). Each - * layer should have a unique file descriptor, even if more than one - * refer to the same underlying fence object; this allows each to be - * closed independently. - * - * If buffer reads can complete at significantly different times, - * then using independent fences is preferred. For example, if the - * HWC handles some layers with a blit engine and others with - * overlays, then the blit layers can be reused immediately after - * the blit completes, but the overlay layers can't be reused until - * a subsequent frame has been displayed. - * - * Since HWC doesn't read from HWC_FRAMEBUFFER layers, it shouldn't - * produce a release fence for them. The releaseFenceFd will be -1 - * for these layers when set() is called. - * - * Since HWC_SIDEBAND buffers don't pass through the HWC client, - * the HWC shouldn't produce a release fence for them. The - * releaseFenceFd will be -1 for these layers when set() is called. - * - * The HWC client taks ownership of the releaseFenceFd and is - * responsible for closing it when no longer needed. - */ - int releaseFenceFd; - - /* - * Availability: HWC_DEVICE_API_VERSION_1_2 - * - * Alpha value applied to the whole layer. The effective - * value of each pixel is computed as: - * - * if (blending == HWC_BLENDING_PREMULT) - * pixel.rgb = pixel.rgb * planeAlpha / 255 - * pixel.a = pixel.a * planeAlpha / 255 - * - * Then blending proceeds as usual according to the "blending" - * field above. - * - * NOTE: planeAlpha applies to YUV layers as well: - * - * pixel.rgb = yuv_to_rgb(pixel.yuv) - * if (blending == HWC_BLENDING_PREMULT) - * pixel.rgb = pixel.rgb * planeAlpha / 255 - * pixel.a = planeAlpha - * - * - * IMPLEMENTATION NOTE: - * - * If the source image doesn't have an alpha channel, then - * the h/w can use the HWC_BLENDING_COVERAGE equations instead of - * HWC_BLENDING_PREMULT and simply set the alpha channel to - * planeAlpha. - * - * e.g.: - * - * if (blending == HWC_BLENDING_PREMULT) - * blending = HWC_BLENDING_COVERAGE; - * pixel.a = planeAlpha; - * - */ - uint8_t planeAlpha; - - /* Pad to 32 bits */ - uint8_t _pad[3]; - - /* - * Availability: HWC_DEVICE_API_VERSION_1_5 - * - * This defines the region of the source buffer that has been - * modified since the last frame. - * - * If surfaceDamage.numRects > 0, then it may be assumed that any - * portion of the source buffer not covered by one of the rects has - * not been modified this frame. If surfaceDamage.numRects == 0, - * then the whole source buffer must be treated as if it had been - * modified. - * - * If the layer's contents are not modified relative to the prior - * prepare/set cycle, surfaceDamage will contain exactly one empty - * rect ([0, 0, 0, 0]). - * - * The damage rects are relative to the pre-transformed buffer, and - * their origin is the top-left corner. - */ - hwc_region_t surfaceDamage; - }; - }; - -#ifdef __LP64__ - /* - * For 64-bit mode, this struct is 120 bytes (and 8-byte aligned), and needs - * to be padded as such to maintain binary compatibility. - */ - uint8_t reserved[120 - 112]; -#else - /* - * For 32-bit mode, this struct is 96 bytes, and needs to be padded as such - * to maintain binary compatibility. - */ - uint8_t reserved[96 - 84]; -#endif - -} hwc_layer_1_t; - -/* This represents a display, typically an EGLDisplay object */ -typedef void* hwc_display_t; - -/* This represents a surface, typically an EGLSurface object */ -typedef void* hwc_surface_t; - -/* - * hwc_display_contents_1_t::flags values - */ -enum { - /* - * HWC_GEOMETRY_CHANGED is set by SurfaceFlinger to indicate that the list - * passed to (*prepare)() has changed by more than just the buffer handles - * and acquire fences. - */ - HWC_GEOMETRY_CHANGED = 0x00000001, -}; - -/* - * Description of the contents to output on a display. - * - * This is the top-level structure passed to the prepare and set calls to - * negotiate and commit the composition of a display image. - */ -typedef struct hwc_display_contents_1 { - /* File descriptor referring to a Sync HAL fence object which will signal - * when this composition is retired. For a physical display, a composition - * is retired when it has been replaced on-screen by a subsequent set. For - * a virtual display, the composition is retired when the writes to - * outputBuffer are complete and can be read. The fence object is created - * and returned by the set call; this field will be -1 on entry to prepare - * and set. SurfaceFlinger will close the returned file descriptor. - */ - int retireFenceFd; - - union { - /* Fields only relevant for HWC_DEVICE_VERSION_1_0. */ - struct { - /* (dpy, sur) is the target of SurfaceFlinger's OpenGL ES - * composition for HWC_DEVICE_VERSION_1_0. They aren't relevant to - * prepare. The set call should commit this surface atomically to - * the display along with any overlay layers. - */ - hwc_display_t dpy; - hwc_surface_t sur; - }; - - /* These fields are used for virtual displays when the h/w composer - * version is at least HWC_DEVICE_VERSION_1_3. */ - struct { - /* outbuf is the buffer that receives the composed image for - * virtual displays. Writes to the outbuf must wait until - * outbufAcquireFenceFd signals. A fence that will signal when - * writes to outbuf are complete should be returned in - * retireFenceFd. - * - * This field is set before prepare(), so properties of the buffer - * can be used to decide which layers can be handled by h/w - * composer. - * - * If prepare() sets all layers to FRAMEBUFFER, then GLES - * composition will happen directly to the output buffer. In this - * case, both outbuf and the FRAMEBUFFER_TARGET layer's buffer will - * be the same, and set() has no work to do besides managing fences. - * - * If the TARGET_FORCE_HWC_FOR_VIRTUAL_DISPLAYS board config - * variable is defined (not the default), then this behavior is - * changed: if all layers are marked for FRAMEBUFFER, GLES - * composition will take place to a scratch framebuffer, and - * h/w composer must copy it to the output buffer. This allows the - * h/w composer to do format conversion if there are cases where - * that is more desirable than doing it in the GLES driver or at the - * virtual display consumer. - * - * If some or all layers are marked OVERLAY, then the framebuffer - * and output buffer will be different. As with physical displays, - * the framebuffer handle will not change between frames if all - * layers are marked for OVERLAY. - */ - buffer_handle_t outbuf; - - /* File descriptor for a fence that will signal when outbuf is - * ready to be written. The h/w composer is responsible for closing - * this when no longer needed. - * - * Will be -1 whenever outbuf is NULL, or when the outbuf can be - * written immediately. - */ - int outbufAcquireFenceFd; - }; - }; - - /* List of layers that will be composed on the display. The buffer handles - * in the list will be unique. If numHwLayers is 0, all composition will be - * performed by SurfaceFlinger. - */ - uint32_t flags; - size_t numHwLayers; - hwc_layer_1_t hwLayers[0]; - -} hwc_display_contents_1_t; - -/* see hwc_composer_device::registerProcs() - * All of the callbacks are required and non-NULL unless otherwise noted. - */ -typedef struct hwc_procs { - /* - * (*invalidate)() triggers a screen refresh, in particular prepare and set - * will be called shortly after this call is made. Note that there is - * NO GUARANTEE that the screen refresh will happen after invalidate() - * returns (in particular, it could happen before). - * invalidate() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL and - * it is safe to call invalidate() from any of hwc_composer_device - * hooks, unless noted otherwise. - */ - void (*invalidate)(const struct hwc_procs* procs); - - /* - * (*vsync)() is called by the h/w composer HAL when a vsync event is - * received and HWC_EVENT_VSYNC is enabled on a display - * (see: hwc_event_control). - * - * the "disp" parameter indicates which display the vsync event is for. - * the "timestamp" parameter is the system monotonic clock timestamp in - * nanosecond of when the vsync event happened. - * - * vsync() is GUARANTEED TO NOT CALL BACK into the h/w composer HAL. - * - * It is expected that vsync() is called from a thread of at least - * HAL_PRIORITY_URGENT_DISPLAY with as little latency as possible, - * typically less than 0.5 ms. - * - * It is a (silent) error to have HWC_EVENT_VSYNC enabled when calling - * hwc_composer_device.set(..., 0, 0, 0) (screen off). The implementation - * can either stop or continue to process VSYNC events, but must not - * crash or cause other problems. - */ - void (*vsync)(const struct hwc_procs* procs, int disp, int64_t timestamp); - - /* - * (*hotplug)() is called by the h/w composer HAL when a display is - * connected or disconnected. The PRIMARY display is always connected and - * the hotplug callback should not be called for it. - * - * The disp parameter indicates which display type this event is for. - * The connected parameter indicates whether the display has just been - * connected (1) or disconnected (0). - * - * The hotplug() callback may call back into the h/w composer on the same - * thread to query refresh rate and dpi for the display. Additionally, - * other threads may be calling into the h/w composer while the callback - * is in progress. - * - * The h/w composer must serialize calls to the hotplug callback; only - * one thread may call it at a time. - * - * This callback will be NULL if the h/w composer is using - * HWC_DEVICE_API_VERSION_1_0. - */ - void (*hotplug)(const struct hwc_procs* procs, int disp, int connected); - -} hwc_procs_t; - - -/*****************************************************************************/ - -typedef struct hwc_module { - /** - * Common methods of the hardware composer module. This *must* be the first member of - * hwc_module as users of this structure will cast a hw_module_t to - * hwc_module pointer in contexts where it's known the hw_module_t references a - * hwc_module. - */ - struct hw_module_t common; -} hwc_module_t; - -typedef struct hwc_composer_device_1 { - /** - * Common methods of the hardware composer device. This *must* be the first member of - * hwc_composer_device_1 as users of this structure will cast a hw_device_t to - * hwc_composer_device_1 pointer in contexts where it's known the hw_device_t references a - * hwc_composer_device_1. - */ - struct hw_device_t common; - - /* - * (*prepare)() is called for each frame before composition and is used by - * SurfaceFlinger to determine what composition steps the HWC can handle. - * - * (*prepare)() can be called more than once, the last call prevails. - * - * The HWC responds by setting the compositionType field in each layer to - * either HWC_FRAMEBUFFER, HWC_OVERLAY, or HWC_CURSOR_OVERLAY. For the - * HWC_FRAMEBUFFER type, composition for the layer is handled by - * SurfaceFlinger with OpenGL ES. For the latter two overlay types, - * the HWC will have to handle the layer's composition. compositionType - * and hints are preserved between (*prepare)() calles unless the - * HWC_GEOMETRY_CHANGED flag is set. - * - * (*prepare)() is called with HWC_GEOMETRY_CHANGED to indicate that the - * list's geometry has changed, that is, when more than just the buffer's - * handles have been updated. Typically this happens (but is not limited to) - * when a window is added, removed, resized or moved. In this case - * compositionType and hints are reset to their default value. - * - * For HWC 1.0, numDisplays will always be one, and displays[0] will be - * non-NULL. - * - * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. - * Entries for unsupported or disabled/disconnected display types will be - * NULL. - * - * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra - * entries correspond to enabled virtual displays, and will be non-NULL. - * - * returns: 0 on success. An negative error code on error. If an error is - * returned, SurfaceFlinger will assume that none of the layer will be - * handled by the HWC. - */ - int (*prepare)(struct hwc_composer_device_1 *dev, - size_t numDisplays, hwc_display_contents_1_t** displays); - - /* - * (*set)() is used in place of eglSwapBuffers(), and assumes the same - * functionality, except it also commits the work list atomically with - * the actual eglSwapBuffers(). - * - * The layer lists are guaranteed to be the same as the ones returned from - * the last call to (*prepare)(). - * - * When this call returns the caller assumes that the displays will be - * updated in the near future with the content of their work lists, without - * artifacts during the transition from the previous frame. - * - * A display with zero layers indicates that the entire composition has - * been handled by SurfaceFlinger with OpenGL ES. In this case, (*set)() - * behaves just like eglSwapBuffers(). - * - * For HWC 1.0, numDisplays will always be one, and displays[0] will be - * non-NULL. - * - * For HWC 1.1, numDisplays will always be HWC_NUM_PHYSICAL_DISPLAY_TYPES. - * Entries for unsupported or disabled/disconnected display types will be - * NULL. - * - * In HWC 1.3, numDisplays may be up to HWC_NUM_DISPLAY_TYPES. The extra - * entries correspond to enabled virtual displays, and will be non-NULL. - * - * IMPORTANT NOTE: There is an implicit layer containing opaque black - * pixels behind all the layers in the list. It is the responsibility of - * the hwcomposer module to make sure black pixels are output (or blended - * from). - * - * IMPORTANT NOTE: In the event of an error this call *MUST* still cause - * any fences returned in the previous call to set to eventually become - * signaled. The caller may have already issued wait commands on these - * fences, and having set return without causing those fences to signal - * will likely result in a deadlock. - * - * returns: 0 on success. A negative error code on error: - * HWC_EGL_ERROR: eglGetError() will provide the proper error code (only - * allowed prior to HWComposer 1.1) - * Another code for non EGL errors. - */ - int (*set)(struct hwc_composer_device_1 *dev, - size_t numDisplays, hwc_display_contents_1_t** displays); - - /* - * eventControl(..., event, enabled) - * Enables or disables h/w composer events for a display. - * - * eventControl can be called from any thread and takes effect - * immediately. - * - * Supported events are: - * HWC_EVENT_VSYNC - * - * returns -EINVAL if the "event" parameter is not one of the value above - * or if the "enabled" parameter is not 0 or 1. - */ - int (*eventControl)(struct hwc_composer_device_1* dev, int disp, - int event, int enabled); - - union { - /* - * For HWC 1.3 and earlier, the blank() interface is used. - * - * blank(..., blank) - * Blanks or unblanks a display's screen. - * - * Turns the screen off when blank is nonzero, on when blank is zero. - * Multiple sequential calls with the same blank value must be - * supported. - * The screen state transition must be be complete when the function - * returns. - * - * returns 0 on success, negative on error. - */ - int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank); - - /* - * For HWC 1.4 and above, setPowerMode() will be used in place of - * blank(). - * - * setPowerMode(..., mode) - * Sets the display screen's power state. - * - * Refer to the documentation of the HWC_POWER_MODE_* constants - * for information about each power mode. - * - * The functionality is similar to the blank() command in previous - * versions of HWC, but with support for more power states. - * - * The display driver is expected to retain and restore the low power - * state of the display while entering and exiting from suspend. - * - * Multiple sequential calls with the same mode value must be supported. - * - * The screen state transition must be be complete when the function - * returns. - * - * returns 0 on success, negative on error. - */ - int (*setPowerMode)(struct hwc_composer_device_1* dev, int disp, - int mode); - }; - - /* - * Used to retrieve information about the h/w composer - * - * Returns 0 on success or -errno on error. - */ - int (*query)(struct hwc_composer_device_1* dev, int what, int* value); - - /* - * (*registerProcs)() registers callbacks that the h/w composer HAL can - * later use. It will be called immediately after the composer device is - * opened with non-NULL procs. It is FORBIDDEN to call any of the callbacks - * from within registerProcs(). registerProcs() must save the hwc_procs_t - * pointer which is needed when calling a registered callback. - */ - void (*registerProcs)(struct hwc_composer_device_1* dev, - hwc_procs_t const* procs); - - /* - * This field is OPTIONAL and can be NULL. - * - * If non NULL it will be called by SurfaceFlinger on dumpsys - */ - void (*dump)(struct hwc_composer_device_1* dev, char *buff, int buff_len); - - /* - * (*getDisplayConfigs)() returns handles for the configurations available - * on the connected display. These handles must remain valid as long as the - * display is connected. - * - * Configuration handles are written to configs. The number of entries - * allocated by the caller is passed in *numConfigs; getDisplayConfigs must - * not try to write more than this number of config handles. On return, the - * total number of configurations available for the display is returned in - * *numConfigs. If *numConfigs is zero on entry, then configs may be NULL. - * - * Hardware composers implementing HWC_DEVICE_API_VERSION_1_3 or prior - * shall choose one configuration to activate and report it as the first - * entry in the returned list. Reporting the inactive configurations is not - * required. - * - * HWC_DEVICE_API_VERSION_1_4 and later provide configuration management - * through SurfaceFlinger, and hardware composers implementing these APIs - * must also provide getActiveConfig and setActiveConfig. Hardware composers - * implementing these API versions may choose not to activate any - * configuration, leaving configuration selection to higher levels of the - * framework. - * - * Returns 0 on success or a negative error code on error. If disp is a - * hotpluggable display type and no display is connected, an error shall be - * returned. - * - * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. - * It shall be NULL for previous versions. - */ - int (*getDisplayConfigs)(struct hwc_composer_device_1* dev, int disp, - uint32_t* configs, size_t* numConfigs); - - /* - * (*getDisplayAttributes)() returns attributes for a specific config of a - * connected display. The config parameter is one of the config handles - * returned by getDisplayConfigs. - * - * The list of attributes to return is provided in the attributes - * parameter, terminated by HWC_DISPLAY_NO_ATTRIBUTE. The value for each - * requested attribute is written in order to the values array. The - * HWC_DISPLAY_NO_ATTRIBUTE attribute does not have a value, so the values - * array will have one less value than the attributes array. - * - * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later. - * It shall be NULL for previous versions. - * - * If disp is a hotpluggable display type and no display is connected, - * or if config is not a valid configuration for the display, a negative - * error code shall be returned. - */ - int (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp, - uint32_t config, const uint32_t* attributes, int32_t* values); - - /* - * (*getActiveConfig)() returns the index of the configuration that is - * currently active on the connected display. The index is relative to - * the list of configuration handles returned by getDisplayConfigs. If there - * is no active configuration, -1 shall be returned. - * - * Returns the configuration index on success or -1 on error. - * - * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. - * It shall be NULL for previous versions. - */ - int (*getActiveConfig)(struct hwc_composer_device_1* dev, int disp); - - /* - * (*setActiveConfig)() instructs the hardware composer to switch to the - * display configuration at the given index in the list of configuration - * handles returned by getDisplayConfigs. - * - * If this function returns without error, any subsequent calls to - * getActiveConfig shall return the index set by this function until one - * of the following occurs: - * 1) Another successful call of this function - * 2) The display is disconnected - * - * Returns 0 on success or a negative error code on error. If disp is a - * hotpluggable display type and no display is connected, or if index is - * outside of the range of hardware configurations returned by - * getDisplayConfigs, an error shall be returned. - * - * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_4 and later. - * It shall be NULL for previous versions. - */ - int (*setActiveConfig)(struct hwc_composer_device_1* dev, int disp, - int index); - /* - * Asynchronously update the location of the cursor layer. - * - * Within the standard prepare()/set() composition loop, the client - * (surfaceflinger) can request that a given layer uses dedicated cursor - * composition hardware by specifiying the HWC_IS_CURSOR_LAYER flag. Only - * one layer per display can have this flag set. If the layer is suitable - * for the platform's cursor hardware, hwcomposer will return from prepare() - * a composition type of HWC_CURSOR_OVERLAY for that layer. This indicates - * not only that the client is not responsible for compositing that layer, - * but also that the client can continue to update the position of that layer - * after a call to set(). This can reduce the visible latency of mouse - * movement to visible, on-screen cursor updates. Calls to - * setCursorPositionAsync() may be made from a different thread doing the - * prepare()/set() composition loop, but care must be taken to not interleave - * calls of setCursorPositionAsync() between calls of set()/prepare(). - * - * Notes: - * - Only one layer per display can be specified as a cursor layer with - * HWC_IS_CURSOR_LAYER. - * - hwcomposer will only return one layer per display as HWC_CURSOR_OVERLAY - * - This returns 0 on success or -errno on error. - * - This field is optional for HWC_DEVICE_API_VERSION_1_4 and later. It - * should be null for previous versions. - */ - int (*setCursorPositionAsync)(struct hwc_composer_device_1 *dev, int disp, int x_pos, int y_pos); - - /* - * Reserved for future use. Must be NULL. - */ - void* reserved_proc[1]; - -} hwc_composer_device_1_t; - -/** convenience API for opening and closing a device */ - -static inline int hwc_open_1(const struct hw_module_t* module, - hwc_composer_device_1_t** device) { - return module->methods->open(module, - HWC_HARDWARE_COMPOSER, (struct hw_device_t**)device); -} - -static inline int hwc_close_1(hwc_composer_device_1_t* device) { - return device->common.close(&device->common); -} - -/*****************************************************************************/ - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h b/third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h deleted file mode 100644 index a90822a4b..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/hwcomposer_defs.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H -#define ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H - -#include -#include - -#include -#include -#include - -__BEGIN_DECLS - -/*****************************************************************************/ - -#define HWC_HEADER_VERSION 1 - -#define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) - -#define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, HWC_HEADER_VERSION) -#define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, HWC_HEADER_VERSION) -#define HWC_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, HWC_HEADER_VERSION) -#define HWC_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, HWC_HEADER_VERSION) -#define HWC_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, HWC_HEADER_VERSION) -#define HWC_DEVICE_API_VERSION_1_5 HARDWARE_DEVICE_API_VERSION_2(1, 5, HWC_HEADER_VERSION) - -enum { - /* hwc_composer_device_t::set failed in EGL */ - HWC_EGL_ERROR = -1 -}; - -/* - * hwc_layer_t::hints values - * Hints are set by the HAL and read by SurfaceFlinger - */ -enum { - /* - * HWC can set the HWC_HINT_TRIPLE_BUFFER hint to indicate to SurfaceFlinger - * that it should triple buffer this layer. Typically HWC does this when - * the layer will be unavailable for use for an extended period of time, - * e.g. if the display will be fetching data directly from the layer and - * the layer can not be modified until after the next set(). - */ - HWC_HINT_TRIPLE_BUFFER = 0x00000001, - - /* - * HWC sets HWC_HINT_CLEAR_FB to tell SurfaceFlinger that it should clear the - * framebuffer with transparent pixels where this layer would be. - * SurfaceFlinger will only honor this flag when the layer has no blending - * - */ - HWC_HINT_CLEAR_FB = 0x00000002 -}; - -/* - * hwc_layer_t::flags values - * Flags are set by SurfaceFlinger and read by the HAL - */ -enum { - /* - * HWC_SKIP_LAYER is set by SurfaceFlnger to indicate that the HAL - * shall not consider this layer for composition as it will be handled - * by SurfaceFlinger (just as if compositionType was set to HWC_OVERLAY). - */ - HWC_SKIP_LAYER = 0x00000001, - - /* - * HWC_IS_CURSOR_LAYER is set by surfaceflinger to indicate that this - * layer is being used as a cursor on this particular display, and that - * surfaceflinger can potentially perform asynchronous position updates for - * this layer. If a call to prepare() returns HWC_CURSOR_OVERLAY for the - * composition type of this layer, then the hwcomposer will allow async - * position updates to this layer via setCursorPositionAsync(). - */ - HWC_IS_CURSOR_LAYER = 0x00000002 -}; - -/* - * hwc_layer_t::compositionType values - */ -enum { - /* this layer is to be drawn into the framebuffer by SurfaceFlinger */ - HWC_FRAMEBUFFER = 0, - - /* this layer will be handled in the HWC */ - HWC_OVERLAY = 1, - - /* this is the background layer. it's used to set the background color. - * there is only a single background layer */ - HWC_BACKGROUND = 2, - - /* this layer holds the result of compositing the HWC_FRAMEBUFFER layers. - * Added in HWC_DEVICE_API_VERSION_1_1. */ - HWC_FRAMEBUFFER_TARGET = 3, - - /* this layer's contents are taken from a sideband buffer stream. - * Added in HWC_DEVICE_API_VERSION_1_4. */ - HWC_SIDEBAND = 4, - - /* this layer's composition will be handled by hwcomposer by dedicated - cursor overlay hardware. hwcomposer will also all async position updates - of this layer outside of the normal prepare()/set() loop. Added in - HWC_DEVICE_API_VERSION_1_4. */ - HWC_CURSOR_OVERLAY = 5 - }; -/* - * hwc_layer_t::blending values - */ -enum { - /* no blending */ - HWC_BLENDING_NONE = 0x0100, - - /* ONE / ONE_MINUS_SRC_ALPHA */ - HWC_BLENDING_PREMULT = 0x0105, - - /* SRC_ALPHA / ONE_MINUS_SRC_ALPHA */ - HWC_BLENDING_COVERAGE = 0x0405 -}; - -/* - * hwc_layer_t::transform values - */ -enum { - /* flip source image horizontally */ - HWC_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H, - /* flip source image vertically */ - HWC_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, - /* rotate source image 90 degrees clock-wise */ - HWC_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, - /* rotate source image 180 degrees */ - HWC_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, - /* rotate source image 270 degrees clock-wise */ - HWC_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, -}; - -/* attributes queriable with query() */ -enum { - /* - * Must return 1 if the background layer is supported, 0 otherwise. - */ - HWC_BACKGROUND_LAYER_SUPPORTED = 0, - - /* - * Returns the vsync period in nanoseconds. - * - * This query is not used for HWC_DEVICE_API_VERSION_1_1 and later. - * Instead, the per-display attribute HWC_DISPLAY_VSYNC_PERIOD is used. - */ - HWC_VSYNC_PERIOD = 1, - - /* - * Availability: HWC_DEVICE_API_VERSION_1_1 - * Returns a mask of supported display types. - */ - HWC_DISPLAY_TYPES_SUPPORTED = 2, -}; - -/* display attributes returned by getDisplayAttributes() */ -enum { - /* Indicates the end of an attribute list */ - HWC_DISPLAY_NO_ATTRIBUTE = 0, - - /* The vsync period in nanoseconds */ - HWC_DISPLAY_VSYNC_PERIOD = 1, - - /* The number of pixels in the horizontal and vertical directions. */ - HWC_DISPLAY_WIDTH = 2, - HWC_DISPLAY_HEIGHT = 3, - - /* The number of pixels per thousand inches of this configuration. - * - * Scaling DPI by 1000 allows it to be stored in an int without losing - * too much precision. - * - * If the DPI for a configuration is unavailable or the HWC implementation - * considers it unreliable, it should set these attributes to zero. - */ - HWC_DISPLAY_DPI_X = 4, - HWC_DISPLAY_DPI_Y = 5, - - /* Indicates which of the vendor-defined color transforms is provided by - * this configuration. */ - HWC_DISPLAY_COLOR_TRANSFORM = 6, -}; - -/* Allowed events for hwc_methods::eventControl() */ -enum { - HWC_EVENT_VSYNC = 0 -}; - -/* Display types and associated mask bits. */ -enum { - HWC_DISPLAY_PRIMARY = 0, - HWC_DISPLAY_EXTERNAL = 1, // HDMI, DP, etc. -#ifdef QTI_BSP - HWC_DISPLAY_TERTIARY = 2, - HWC_DISPLAY_VIRTUAL = 3, - - HWC_NUM_PHYSICAL_DISPLAY_TYPES = 3, - HWC_NUM_DISPLAY_TYPES = 4, -#else - HWC_DISPLAY_VIRTUAL = 2, - - HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2, - HWC_NUM_DISPLAY_TYPES = 3, -#endif -}; - -enum { - HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY, - HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL, -#ifdef QTI_BSP - HWC_DISPLAY_TERTIARY_BIT = 1 << HWC_DISPLAY_TERTIARY, -#endif - HWC_DISPLAY_VIRTUAL_BIT = 1 << HWC_DISPLAY_VIRTUAL, -}; - -/* Display power modes */ -enum { - /* The display is turned off (blanked). */ - HWC_POWER_MODE_OFF = 0, - /* The display is turned on and configured in a low power state - * that is suitable for presenting ambient information to the user, - * possibly with lower fidelity than normal but greater efficiency. */ - HWC_POWER_MODE_DOZE = 1, - /* The display is turned on normally. */ - HWC_POWER_MODE_NORMAL = 2, - /* The display is configured as in HWC_POWER_MODE_DOZE but may - * stop applying frame buffer updates from the graphics subsystem. - * This power mode is effectively a hint from the doze dream to - * tell the hardware that it is done drawing to the display for the - * time being and that the display should remain on in a low power - * state and continue showing its current contents indefinitely - * until the mode changes. - * - * This mode may also be used as a signal to enable hardware-based doze - * functionality. In this case, the doze dream is effectively - * indicating that the hardware is free to take over the display - * and manage it autonomously to implement low power always-on display - * functionality. */ - HWC_POWER_MODE_DOZE_SUSPEND = 3, -}; - -/*****************************************************************************/ - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_HWCOMPOSER_DEFS_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/input.h b/third_party/android_hardware_libhardware/include/hardware/input.h deleted file mode 100644 index 969b8ce57..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/input.h +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_INPUT_H -#define ANDROID_INCLUDE_HARDWARE_INPUT_H - -#include -#include - -__BEGIN_DECLS - -#define INPUT_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define INPUT_HARDWARE_MODULE_ID "input" - -#define INPUT_INSTANCE_EVDEV "evdev" - -typedef enum input_bus { - INPUT_BUS_BT, - INPUT_BUS_USB, - INPUT_BUS_SERIAL, - INPUT_BUS_BUILTIN -} input_bus_t; - -typedef struct input_host input_host_t; - -typedef struct input_device_handle input_device_handle_t; - -typedef struct input_device_identifier input_device_identifier_t; - -typedef struct input_device_definition input_device_definition_t; - -typedef struct input_report_definition input_report_definition_t; - -typedef struct input_report input_report_t; - -typedef struct input_collection input_collection_t; - -typedef struct input_property_map input_property_map_t; - -typedef struct input_property input_property_t; - -typedef enum { - // keycodes - INPUT_USAGE_KEYCODE_UNKNOWN, - INPUT_USAGE_KEYCODE_SOFT_LEFT, - INPUT_USAGE_KEYCODE_SOFT_RIGHT, - INPUT_USAGE_KEYCODE_HOME, - INPUT_USAGE_KEYCODE_BACK, - INPUT_USAGE_KEYCODE_CALL, - INPUT_USAGE_KEYCODE_ENDCALL, - INPUT_USAGE_KEYCODE_0, - INPUT_USAGE_KEYCODE_1, - INPUT_USAGE_KEYCODE_2, - INPUT_USAGE_KEYCODE_3, - INPUT_USAGE_KEYCODE_4, - INPUT_USAGE_KEYCODE_5, - INPUT_USAGE_KEYCODE_6, - INPUT_USAGE_KEYCODE_7, - INPUT_USAGE_KEYCODE_8, - INPUT_USAGE_KEYCODE_9, - INPUT_USAGE_KEYCODE_STAR, - INPUT_USAGE_KEYCODE_POUND, - INPUT_USAGE_KEYCODE_DPAD_UP, - INPUT_USAGE_KEYCODE_DPAD_DOWN, - INPUT_USAGE_KEYCODE_DPAD_LEFT, - INPUT_USAGE_KEYCODE_DPAD_RIGHT, - INPUT_USAGE_KEYCODE_DPAD_CENTER, - INPUT_USAGE_KEYCODE_VOLUME_UP, - INPUT_USAGE_KEYCODE_VOLUME_DOWN, - INPUT_USAGE_KEYCODE_POWER, - INPUT_USAGE_KEYCODE_CAMERA, - INPUT_USAGE_KEYCODE_CLEAR, - INPUT_USAGE_KEYCODE_A, - INPUT_USAGE_KEYCODE_B, - INPUT_USAGE_KEYCODE_C, - INPUT_USAGE_KEYCODE_D, - INPUT_USAGE_KEYCODE_E, - INPUT_USAGE_KEYCODE_F, - INPUT_USAGE_KEYCODE_G, - INPUT_USAGE_KEYCODE_H, - INPUT_USAGE_KEYCODE_I, - INPUT_USAGE_KEYCODE_J, - INPUT_USAGE_KEYCODE_K, - INPUT_USAGE_KEYCODE_L, - INPUT_USAGE_KEYCODE_M, - INPUT_USAGE_KEYCODE_N, - INPUT_USAGE_KEYCODE_O, - INPUT_USAGE_KEYCODE_P, - INPUT_USAGE_KEYCODE_Q, - INPUT_USAGE_KEYCODE_R, - INPUT_USAGE_KEYCODE_S, - INPUT_USAGE_KEYCODE_T, - INPUT_USAGE_KEYCODE_U, - INPUT_USAGE_KEYCODE_V, - INPUT_USAGE_KEYCODE_W, - INPUT_USAGE_KEYCODE_X, - INPUT_USAGE_KEYCODE_Y, - INPUT_USAGE_KEYCODE_Z, - INPUT_USAGE_KEYCODE_COMMA, - INPUT_USAGE_KEYCODE_PERIOD, - INPUT_USAGE_KEYCODE_ALT_LEFT, - INPUT_USAGE_KEYCODE_ALT_RIGHT, - INPUT_USAGE_KEYCODE_SHIFT_LEFT, - INPUT_USAGE_KEYCODE_SHIFT_RIGHT, - INPUT_USAGE_KEYCODE_TAB, - INPUT_USAGE_KEYCODE_SPACE, - INPUT_USAGE_KEYCODE_SYM, - INPUT_USAGE_KEYCODE_EXPLORER, - INPUT_USAGE_KEYCODE_ENVELOPE, - INPUT_USAGE_KEYCODE_ENTER, - INPUT_USAGE_KEYCODE_DEL, - INPUT_USAGE_KEYCODE_GRAVE, - INPUT_USAGE_KEYCODE_MINUS, - INPUT_USAGE_KEYCODE_EQUALS, - INPUT_USAGE_KEYCODE_LEFT_BRACKET, - INPUT_USAGE_KEYCODE_RIGHT_BRACKET, - INPUT_USAGE_KEYCODE_BACKSLASH, - INPUT_USAGE_KEYCODE_SEMICOLON, - INPUT_USAGE_KEYCODE_APOSTROPHE, - INPUT_USAGE_KEYCODE_SLASH, - INPUT_USAGE_KEYCODE_AT, - INPUT_USAGE_KEYCODE_NUM, - INPUT_USAGE_KEYCODE_HEADSETHOOK, - INPUT_USAGE_KEYCODE_FOCUS, // *Camera* focus - INPUT_USAGE_KEYCODE_PLUS, - INPUT_USAGE_KEYCODE_MENU, - INPUT_USAGE_KEYCODE_NOTIFICATION, - INPUT_USAGE_KEYCODE_SEARCH, - INPUT_USAGE_KEYCODE_MEDIA_PLAY_PAUSE, - INPUT_USAGE_KEYCODE_MEDIA_STOP, - INPUT_USAGE_KEYCODE_MEDIA_NEXT, - INPUT_USAGE_KEYCODE_MEDIA_PREVIOUS, - INPUT_USAGE_KEYCODE_MEDIA_REWIND, - INPUT_USAGE_KEYCODE_MEDIA_FAST_FORWARD, - INPUT_USAGE_KEYCODE_MUTE, - INPUT_USAGE_KEYCODE_PAGE_UP, - INPUT_USAGE_KEYCODE_PAGE_DOWN, - INPUT_USAGE_KEYCODE_PICTSYMBOLS, - INPUT_USAGE_KEYCODE_SWITCH_CHARSET, - INPUT_USAGE_KEYCODE_BUTTON_A, - INPUT_USAGE_KEYCODE_BUTTON_B, - INPUT_USAGE_KEYCODE_BUTTON_C, - INPUT_USAGE_KEYCODE_BUTTON_X, - INPUT_USAGE_KEYCODE_BUTTON_Y, - INPUT_USAGE_KEYCODE_BUTTON_Z, - INPUT_USAGE_KEYCODE_BUTTON_L1, - INPUT_USAGE_KEYCODE_BUTTON_R1, - INPUT_USAGE_KEYCODE_BUTTON_L2, - INPUT_USAGE_KEYCODE_BUTTON_R2, - INPUT_USAGE_KEYCODE_BUTTON_THUMBL, - INPUT_USAGE_KEYCODE_BUTTON_THUMBR, - INPUT_USAGE_KEYCODE_BUTTON_START, - INPUT_USAGE_KEYCODE_BUTTON_SELECT, - INPUT_USAGE_KEYCODE_BUTTON_MODE, - INPUT_USAGE_KEYCODE_ESCAPE, - INPUT_USAGE_KEYCODE_FORWARD_DEL, - INPUT_USAGE_KEYCODE_CTRL_LEFT, - INPUT_USAGE_KEYCODE_CTRL_RIGHT, - INPUT_USAGE_KEYCODE_CAPS_LOCK, - INPUT_USAGE_KEYCODE_SCROLL_LOCK, - INPUT_USAGE_KEYCODE_META_LEFT, - INPUT_USAGE_KEYCODE_META_RIGHT, - INPUT_USAGE_KEYCODE_FUNCTION, - INPUT_USAGE_KEYCODE_SYSRQ, - INPUT_USAGE_KEYCODE_BREAK, - INPUT_USAGE_KEYCODE_MOVE_HOME, - INPUT_USAGE_KEYCODE_MOVE_END, - INPUT_USAGE_KEYCODE_INSERT, - INPUT_USAGE_KEYCODE_FORWARD, - INPUT_USAGE_KEYCODE_MEDIA_PLAY, - INPUT_USAGE_KEYCODE_MEDIA_PAUSE, - INPUT_USAGE_KEYCODE_MEDIA_CLOSE, - INPUT_USAGE_KEYCODE_MEDIA_EJECT, - INPUT_USAGE_KEYCODE_MEDIA_RECORD, - INPUT_USAGE_KEYCODE_F1, - INPUT_USAGE_KEYCODE_F2, - INPUT_USAGE_KEYCODE_F3, - INPUT_USAGE_KEYCODE_F4, - INPUT_USAGE_KEYCODE_F5, - INPUT_USAGE_KEYCODE_F6, - INPUT_USAGE_KEYCODE_F7, - INPUT_USAGE_KEYCODE_F8, - INPUT_USAGE_KEYCODE_F9, - INPUT_USAGE_KEYCODE_F10, - INPUT_USAGE_KEYCODE_F11, - INPUT_USAGE_KEYCODE_F12, - INPUT_USAGE_KEYCODE_NUM_LOCK, - INPUT_USAGE_KEYCODE_NUMPAD_0, - INPUT_USAGE_KEYCODE_NUMPAD_1, - INPUT_USAGE_KEYCODE_NUMPAD_2, - INPUT_USAGE_KEYCODE_NUMPAD_3, - INPUT_USAGE_KEYCODE_NUMPAD_4, - INPUT_USAGE_KEYCODE_NUMPAD_5, - INPUT_USAGE_KEYCODE_NUMPAD_6, - INPUT_USAGE_KEYCODE_NUMPAD_7, - INPUT_USAGE_KEYCODE_NUMPAD_8, - INPUT_USAGE_KEYCODE_NUMPAD_9, - INPUT_USAGE_KEYCODE_NUMPAD_DIVIDE, - INPUT_USAGE_KEYCODE_NUMPAD_MULTIPLY, - INPUT_USAGE_KEYCODE_NUMPAD_SUBTRACT, - INPUT_USAGE_KEYCODE_NUMPAD_ADD, - INPUT_USAGE_KEYCODE_NUMPAD_DOT, - INPUT_USAGE_KEYCODE_NUMPAD_COMMA, - INPUT_USAGE_KEYCODE_NUMPAD_ENTER, - INPUT_USAGE_KEYCODE_NUMPAD_EQUALS, - INPUT_USAGE_KEYCODE_NUMPAD_LEFT_PAREN, - INPUT_USAGE_KEYCODE_NUMPAD_RIGHT_PAREN, - INPUT_USAGE_KEYCODE_VOLUME_MUTE, - INPUT_USAGE_KEYCODE_INFO, - INPUT_USAGE_KEYCODE_CHANNEL_UP, - INPUT_USAGE_KEYCODE_CHANNEL_DOWN, - INPUT_USAGE_KEYCODE_ZOOM_IN, - INPUT_USAGE_KEYCODE_ZOOM_OUT, - INPUT_USAGE_KEYCODE_TV, - INPUT_USAGE_KEYCODE_WINDOW, - INPUT_USAGE_KEYCODE_GUIDE, - INPUT_USAGE_KEYCODE_DVR, - INPUT_USAGE_KEYCODE_BOOKMARK, - INPUT_USAGE_KEYCODE_CAPTIONS, - INPUT_USAGE_KEYCODE_SETTINGS, - INPUT_USAGE_KEYCODE_TV_POWER, - INPUT_USAGE_KEYCODE_TV_INPUT, - INPUT_USAGE_KEYCODE_STB_POWER, - INPUT_USAGE_KEYCODE_STB_INPUT, - INPUT_USAGE_KEYCODE_AVR_POWER, - INPUT_USAGE_KEYCODE_AVR_INPUT, - INPUT_USAGE_KEYCODE_PROG_RED, - INPUT_USAGE_KEYCODE_PROG_GREEN, - INPUT_USAGE_KEYCODE_PROG_YELLOW, - INPUT_USAGE_KEYCODE_PROG_BLUE, - INPUT_USAGE_KEYCODE_APP_SWITCH, - INPUT_USAGE_KEYCODE_BUTTON_1, - INPUT_USAGE_KEYCODE_BUTTON_2, - INPUT_USAGE_KEYCODE_BUTTON_3, - INPUT_USAGE_KEYCODE_BUTTON_4, - INPUT_USAGE_KEYCODE_BUTTON_5, - INPUT_USAGE_KEYCODE_BUTTON_6, - INPUT_USAGE_KEYCODE_BUTTON_7, - INPUT_USAGE_KEYCODE_BUTTON_8, - INPUT_USAGE_KEYCODE_BUTTON_9, - INPUT_USAGE_KEYCODE_BUTTON_10, - INPUT_USAGE_KEYCODE_BUTTON_11, - INPUT_USAGE_KEYCODE_BUTTON_12, - INPUT_USAGE_KEYCODE_BUTTON_13, - INPUT_USAGE_KEYCODE_BUTTON_14, - INPUT_USAGE_KEYCODE_BUTTON_15, - INPUT_USAGE_KEYCODE_BUTTON_16, - INPUT_USAGE_KEYCODE_LANGUAGE_SWITCH, - INPUT_USAGE_KEYCODE_MANNER_MODE, - INPUT_USAGE_KEYCODE_3D_MODE, - INPUT_USAGE_KEYCODE_CONTACTS, - INPUT_USAGE_KEYCODE_CALENDAR, - INPUT_USAGE_KEYCODE_MUSIC, - INPUT_USAGE_KEYCODE_CALCULATOR, - INPUT_USAGE_KEYCODE_ZENKAKU_HANKAKU, - INPUT_USAGE_KEYCODE_EISU, - INPUT_USAGE_KEYCODE_MUHENKAN, - INPUT_USAGE_KEYCODE_HENKAN, - INPUT_USAGE_KEYCODE_KATAKANA_HIRAGANA, - INPUT_USAGE_KEYCODE_YEN, - INPUT_USAGE_KEYCODE_RO, - INPUT_USAGE_KEYCODE_KANA, - INPUT_USAGE_KEYCODE_ASSIST, - INPUT_USAGE_KEYCODE_BRIGHTNESS_DOWN, - INPUT_USAGE_KEYCODE_BRIGHTNESS_UP, - INPUT_USAGE_KEYCODE_MEDIA_AUDIO_TRACK, - INPUT_USAGE_KEYCODE_SLEEP, - INPUT_USAGE_KEYCODE_WAKEUP, - INPUT_USAGE_KEYCODE_PAIRING, - INPUT_USAGE_KEYCODE_MEDIA_TOP_MENU, - INPUT_USAGE_KEYCODE_11, - INPUT_USAGE_KEYCODE_12, - INPUT_USAGE_KEYCODE_LAST_CHANNEL, - INPUT_USAGE_KEYCODE_TV_DATA_SERVICE, - INPUT_USAGE_KEYCODE_VOICE_ASSIST, - INPUT_USAGE_KEYCODE_TV_RADIO_SERVICE, - INPUT_USAGE_KEYCODE_TV_TELETEXT, - INPUT_USAGE_KEYCODE_TV_NUMBER_ENTRY, - INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_ANALOG, - INPUT_USAGE_KEYCODE_TV_TERRESTRIAL_DIGITAL, - INPUT_USAGE_KEYCODE_TV_SATELLITE, - INPUT_USAGE_KEYCODE_TV_SATELLITE_BS, - INPUT_USAGE_KEYCODE_TV_SATELLITE_CS, - INPUT_USAGE_KEYCODE_TV_SATELLITE_SERVICE, - INPUT_USAGE_KEYCODE_TV_NETWORK, - INPUT_USAGE_KEYCODE_TV_ANTENNA_CABLE, - INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_1, - INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_2, - INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_3, - INPUT_USAGE_KEYCODE_TV_INPUT_HDMI_4, - INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_1, - INPUT_USAGE_KEYCODE_TV_INPUT_COMPOSITE_2, - INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_1, - INPUT_USAGE_KEYCODE_TV_INPUT_COMPONENT_2, - INPUT_USAGE_KEYCODE_TV_INPUT_VGA_1, - INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION, - INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP, - INPUT_USAGE_KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN, - INPUT_USAGE_KEYCODE_TV_ZOOM_MODE, - INPUT_USAGE_KEYCODE_TV_CONTENTS_MENU, - INPUT_USAGE_KEYCODE_TV_MEDIA_CONTEXT_MENU, - INPUT_USAGE_KEYCODE_TV_TIMER_PROGRAMMING, - INPUT_USAGE_KEYCODE_HELP, - - // axes - INPUT_USAGE_AXIS_X, - INPUT_USAGE_AXIS_Y, - INPUT_USAGE_AXIS_PRESSURE, - INPUT_USAGE_AXIS_SIZE, - INPUT_USAGE_AXIS_TOUCH_MAJOR, - INPUT_USAGE_AXIS_TOUCH_MINOR, - INPUT_USAGE_AXIS_TOOL_MAJOR, - INPUT_USAGE_AXIS_TOOL_MINOR, - INPUT_USAGE_AXIS_ORIENTATION, - INPUT_USAGE_AXIS_VSCROLL, - INPUT_USAGE_AXIS_HSCROLL, - INPUT_USAGE_AXIS_Z, - INPUT_USAGE_AXIS_RX, - INPUT_USAGE_AXIS_RY, - INPUT_USAGE_AXIS_RZ, - INPUT_USAGE_AXIS_HAT_X, - INPUT_USAGE_AXIS_HAT_Y, - INPUT_USAGE_AXIS_LTRIGGER, - INPUT_USAGE_AXIS_RTRIGGER, - INPUT_USAGE_AXIS_THROTTLE, - INPUT_USAGE_AXIS_RUDDER, - INPUT_USAGE_AXIS_WHEEL, - INPUT_USAGE_AXIS_GAS, - INPUT_USAGE_AXIS_BRAKE, - INPUT_USAGE_AXIS_DISTANCE, - INPUT_USAGE_AXIS_TILT, - INPUT_USAGE_AXIS_GENERIC_1, - INPUT_USAGE_AXIS_GENERIC_2, - INPUT_USAGE_AXIS_GENERIC_3, - INPUT_USAGE_AXIS_GENERIC_4, - INPUT_USAGE_AXIS_GENERIC_5, - INPUT_USAGE_AXIS_GENERIC_6, - INPUT_USAGE_AXIS_GENERIC_7, - INPUT_USAGE_AXIS_GENERIC_8, - INPUT_USAGE_AXIS_GENERIC_9, - INPUT_USAGE_AXIS_GENERIC_10, - INPUT_USAGE_AXIS_GENERIC_11, - INPUT_USAGE_AXIS_GENERIC_12, - INPUT_USAGE_AXIS_GENERIC_13, - INPUT_USAGE_AXIS_GENERIC_14, - INPUT_USAGE_AXIS_GENERIC_15, - INPUT_USAGE_AXIS_GENERIC_16, - - // leds - INPUT_USAGE_LED_NUM_LOCK, - INPUT_USAGE_LED_CAPS_LOCK, - INPUT_USAGE_LED_SCROLL_LOCK, - INPUT_USAGE_LED_COMPOSE, - INPUT_USAGE_LED_KANA, - INPUT_USAGE_LED_SLEEP, - INPUT_USAGE_LED_SUSPEND, - INPUT_USAGE_LED_MUTE, - INPUT_USAGE_LED_MISC, - INPUT_USAGE_LED_MAIL, - INPUT_USAGE_LED_CHARGING, - INPUT_USAGE_LED_CONTROLLER_1, - INPUT_USAGE_LED_CONTROLLER_2, - INPUT_USAGE_LED_CONTROLLER_3, - INPUT_USAGE_LED_CONTROLLER_4, -} input_usage_t; - -typedef enum { - INPUT_COLLECTION_ID_TOUCH, - INPUT_COLLECTION_ID_KEYBOARD, - INPUT_COLLECTION_ID_MOUSE, - INPUT_COLLECTION_ID_TOUCHPAD, - // etc -} input_collection_id_t; - -typedef struct input_message input_message_t; - -typedef struct input_host_callbacks { - - /** - * Creates a device identifier with the given properties. - * The unique ID should be a string that precisely identifies a given piece of hardware. For - * example, an input device connected via Bluetooth could use its MAC address as its unique ID. - */ - input_device_identifier_t* (*create_device_identifier)(input_host_t* host, - const char* name, int32_t product_id, int32_t vendor_id, - input_bus_t bus, const char* unique_id); - - /** - * Allocates the device definition which will describe the input capabilities of a device. A - * device definition may be used to register as many devices as desired. - */ - input_device_definition_t* (*create_device_definition)(input_host_t* host); - - /** - * Allocate either an input report, which the HAL will use to tell the host of incoming input - * events, or an output report, which the host will use to tell the HAL of desired state - * changes (e.g. setting an LED). - */ - input_report_definition_t* (*create_input_report_definition)(input_host_t* host); - input_report_definition_t* (*create_output_report_definition)(input_host_t* host); - - /** - * Append the report to the given input device. - */ - void (*input_device_definition_add_report)(input_host_t* host, - input_device_definition_t* d, input_report_definition_t* r); - - /** - * Add a collection with the given arity and ID. A collection describes a set - * of logically grouped properties such as the X and Y coordinates of a single finger touch or - * the set of keys on a keyboard. The arity declares how many repeated instances of this - * collection will appear in whatever report it is attached to. The ID describes the type of - * grouping being represented by the collection. For example, a touchscreen capable of - * reporting up to 2 fingers simultaneously might have a collection with the X and Y - * coordinates, an arity of 2, and an ID of INPUT_COLLECTION_USAGE_TOUCHSCREEN. Any given ID - * may only be present once for a given report. - */ - void (*input_report_definition_add_collection)(input_host_t* host, - input_report_definition_t* report, input_collection_id_t id, int32_t arity); - - /** - * Declare an int usage with the given properties. The report and collection defines where the - * usage is being declared. - */ - void (*input_report_definition_declare_usage_int)(input_host_t* host, - input_report_definition_t* report, input_collection_id_t id, - input_usage_t usage, int32_t min, int32_t max, float resolution); - - /** - * Declare a set of boolean usages with the given properties. The report and collection - * defines where the usages are being declared. - */ - void (*input_report_definition_declare_usages_bool)(input_host_t* host, - input_report_definition_t* report, input_collection_id_t id, - input_usage_t* usage, size_t usage_count); - - - /** - * Register a given input device definition. This notifies the host that an input device has - * been connected and gives a description of all its capabilities. - */ - input_device_handle_t* (*register_device)(input_host_t* host, - input_device_identifier_t* id, input_device_definition_t* d); - - /** Unregister the given device */ - void (*unregister_device)(input_host_t* host, input_device_handle_t* handle); - - /** - * Allocate a report that will contain all of the state as described by the given report. - */ - input_report_t* (*input_allocate_report)(input_host_t* host, input_report_definition_t* r); - - /** - * Add an int usage value to a report. - */ - void (*input_report_set_usage_int)(input_host_t* host, input_report_t* r, - input_collection_id_t id, input_usage_t usage, int32_t value, int32_t arity_index); - - /** - * Add a boolean usage value to a report. - */ - void (*input_report_set_usage_bool)(input_host_t* host, input_report_t* r, - input_collection_id_t id, input_usage_t usage, bool value, int32_t arity_index); - - void (*report_event)(input_host_t* host, input_device_handle_t* d, input_report_t* report); - - /** - * Retrieve the set of properties for the device. The returned - * input_property_map_t* may be used to query specific properties via the - * input_get_device_property callback. - */ - input_property_map_t* (*input_get_device_property_map)(input_host_t* host, - input_device_identifier_t* id); - /** - * Retrieve a property for the device with the given key. Returns NULL if - * the key does not exist, or an input_property_t* that must be freed using - * input_free_device_property(). Using an input_property_t after the - * corresponding input_property_map_t is freed is undefined. - */ - input_property_t* (*input_get_device_property)(input_host_t* host, - input_property_map_t* map, const char* key); - - /** - * Get the key for the input property. Returns NULL if the property is NULL. - * The returned const char* is owned by the input_property_t. - */ - const char* (*input_get_property_key)(input_host_t* host, input_property_t* property); - - /** - * Get the value for the input property. Returns NULL if the property is - * NULL. The returned const char* is owned by the input_property_t. - */ - const char* (*input_get_property_value)(input_host_t* host, input_property_t* property); - - /** - * Frees the input_property_t*. - */ - void (*input_free_device_property)(input_host_t* host, input_property_t* property); - - /** - * Frees the input_property_map_t*. - */ - void (*input_free_device_property_map)(input_host_t* host, input_property_map_t* map); -} input_host_callbacks_t; - -typedef struct input_module input_module_t; - -struct input_module { - /** - * Common methods of the input module. This *must* be the first member - * of input_module as users of this structure will cast a hw_module_t - * to input_module pointer in contexts where it's known - * the hw_module_t references a input_module. - */ - struct hw_module_t common; - - /** - * Initialize the module with host callbacks. At this point the HAL should start up whatever - * infrastructure it needs to in order to process input events. - */ - void (*init)(const input_module_t* module, input_host_t* host, input_host_callbacks_t cb); - - /** - * Sends an output report with a new set of state the host would like the given device to - * assume. - */ - void (*notify_report)(const input_module_t* module, input_report_t* report); -}; - -static inline int input_open(const struct hw_module_t** module, const char* type) { - return hw_get_module_by_class(INPUT_HARDWARE_MODULE_ID, type, module); -} - -__END_DECLS - -#endif /* ANDROID_INCLUDE_HARDWARE_INPUT_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster0.h b/third_party/android_hardware_libhardware/include/hardware/keymaster0.h deleted file mode 100644 index f020e5b18..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster0.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ANDROID_HARDWARE_KEYMASTER_0_H -#define ANDROID_HARDWARE_KEYMASTER_0_H - -#include - -__BEGIN_DECLS - -/** - * Keymaster0 device definition. - */ -struct keymaster0_device { - /** - * Common methods of the keymaster device. This *must* be the first member of - * keymaster0_device as users of this structure will cast a hw_device_t to - * keymaster0_device pointer in contexts where it's known the hw_device_t references a - * keymaster0_device. - */ - struct hw_device_t common; - - /** - * THIS IS DEPRECATED. Use the new "module_api_version" and "hal_api_version" - * fields in the keymaster_module initialization instead. - */ - uint32_t client_version; - - /** - * See flags defined for keymaster0_device::flags in keymaster_common.h - */ - uint32_t flags; - - void* context; - - /** - * Generates a public and private key. The key-blob returned is opaque - * and must subsequently provided for signing and verification. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*generate_keypair)(const struct keymaster0_device* dev, - const keymaster_keypair_t key_type, const void* key_params, - uint8_t** key_blob, size_t* key_blob_length); - - /** - * Imports a public and private key pair. The imported keys will be in - * PKCS#8 format with DER encoding (Java standard). The key-blob - * returned is opaque and will be subsequently provided for signing - * and verification. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*import_keypair)(const struct keymaster0_device* dev, - const uint8_t* key, const size_t key_length, - uint8_t** key_blob, size_t* key_blob_length); - - /** - * Gets the public key part of a key pair. The public key must be in - * X.509 format (Java standard) encoded byte array. - * - * Returns: 0 on success or an error code less than 0. - * On error, x509_data should not be allocated. - */ - int (*get_keypair_public)(const struct keymaster0_device* dev, - const uint8_t* key_blob, const size_t key_blob_length, - uint8_t** x509_data, size_t* x509_data_length); - - /** - * Deletes the key pair associated with the key blob. - * - * This function is optional and should be set to NULL if it is not - * implemented. - * - * Returns 0 on success or an error code less than 0. - */ - int (*delete_keypair)(const struct keymaster0_device* dev, - const uint8_t* key_blob, const size_t key_blob_length); - - /** - * Deletes all keys in the hardware keystore. Used when keystore is - * reset completely. - * - * This function is optional and should be set to NULL if it is not - * implemented. - * - * Returns 0 on success or an error code less than 0. - */ - int (*delete_all)(const struct keymaster0_device* dev); - - /** - * Signs data using a key-blob generated before. This can use either - * an asymmetric key or a secret key. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*sign_data)(const struct keymaster0_device* dev, - const void* signing_params, - const uint8_t* key_blob, const size_t key_blob_length, - const uint8_t* data, const size_t data_length, - uint8_t** signed_data, size_t* signed_data_length); - - /** - * Verifies data signed with a key-blob. This can use either - * an asymmetric key or a secret key. - * - * Returns: 0 on successful verification or an error code less than 0. - */ - int (*verify_data)(const struct keymaster0_device* dev, - const void* signing_params, - const uint8_t* key_blob, const size_t key_blob_length, - const uint8_t* signed_data, const size_t signed_data_length, - const uint8_t* signature, const size_t signature_length); -}; -typedef struct keymaster0_device keymaster0_device_t; - - -/* Convenience API for opening and closing keymaster devices */ - -static inline int keymaster0_open(const struct hw_module_t* module, - keymaster0_device_t** device) -{ - int rc = module->methods->open(module, KEYSTORE_KEYMASTER, - (struct hw_device_t**) device); - - return rc; -} - -static inline int keymaster0_close(keymaster0_device_t* device) -{ - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_HARDWARE_KEYMASTER_0_H diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster1.h b/third_party/android_hardware_libhardware/include/hardware/keymaster1.h deleted file mode 100644 index ac2cc2b40..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster1.h +++ /dev/null @@ -1,597 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef ANDROID_HARDWARE_KEYMASTER1_H -#define ANDROID_HARDWARE_KEYMASTER1_H - -#include -#include - -__BEGIN_DECLS - -/** - * Keymaster1 device definition - */ -struct keymaster1_device { - /** - * Common methods of the keymaster device. This *must* be the first member of - * keymaster_device as users of this structure will cast a hw_device_t to - * keymaster_device pointer in contexts where it's known the hw_device_t references a - * keymaster_device. - */ - struct hw_device_t common; - - /** - * THIS IS DEPRECATED. Use the new "module_api_version" and "hal_api_version" - * fields in the keymaster_module initialization instead. - */ - uint32_t client_version; - - /** - * See flags defined for keymaster0_devices::flags in keymaster_common.h - */ - uint32_t flags; - - void* context; - - /** - * \deprecated Generates a public and private key. The key-blob returned is opaque and must - * subsequently provided for signing and verification. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*generate_keypair)(const struct keymaster1_device* dev, const keymaster_keypair_t key_type, - const void* key_params, uint8_t** key_blob, size_t* key_blob_length); - - /** - * \deprecated Imports a public and private key pair. The imported keys will be in PKCS#8 format - * with DER encoding (Java standard). The key-blob returned is opaque and will be subsequently - * provided for signing and verification. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*import_keypair)(const struct keymaster1_device* dev, const uint8_t* key, - const size_t key_length, uint8_t** key_blob, size_t* key_blob_length); - - /** - * \deprecated Gets the public key part of a key pair. The public key must be in X.509 format - * (Java standard) encoded byte array. - * - * Returns: 0 on success or an error code less than 0. On error, x509_data - * should not be allocated. - */ - int (*get_keypair_public)(const struct keymaster1_device* dev, const uint8_t* key_blob, - const size_t key_blob_length, uint8_t** x509_data, - size_t* x509_data_length); - - /** - * \deprecated Deletes the key pair associated with the key blob. - * - * This function is optional and should be set to NULL if it is not - * implemented. - * - * Returns 0 on success or an error code less than 0. - */ - int (*delete_keypair)(const struct keymaster1_device* dev, const uint8_t* key_blob, - const size_t key_blob_length); - - /** - * \deprecated Deletes all keys in the hardware keystore. Used when keystore is reset - * completely. - * - * This function is optional and should be set to NULL if it is not - * implemented. - * - * Returns 0 on success or an error code less than 0. - */ - int (*delete_all)(const struct keymaster1_device* dev); - - /** - * \deprecated Signs data using a key-blob generated before. This can use either an asymmetric - * key or a secret key. - * - * Returns: 0 on success or an error code less than 0. - */ - int (*sign_data)(const struct keymaster1_device* dev, const void* signing_params, - const uint8_t* key_blob, const size_t key_blob_length, const uint8_t* data, - const size_t data_length, uint8_t** signed_data, size_t* signed_data_length); - - /** - * \deprecated Verifies data signed with a key-blob. This can use either an asymmetric key or a - * secret key. - * - * Returns: 0 on successful verification or an error code less than 0. - */ - int (*verify_data)(const struct keymaster1_device* dev, const void* signing_params, - const uint8_t* key_blob, const size_t key_blob_length, - const uint8_t* signed_data, const size_t signed_data_length, - const uint8_t* signature, const size_t signature_length); - - /** - * Gets algorithms supported. - * - * \param[in] dev The keymaster device structure. - * - * \param[out] algorithms Array of algorithms supported. The caller takes ownership of the - * array and must free() it. - * - * \param[out] algorithms_length Length of \p algorithms. - */ - keymaster_error_t (*get_supported_algorithms)(const struct keymaster1_device* dev, - keymaster_algorithm_t** algorithms, - size_t* algorithms_length); - - /** - * Gets the block modes supported for the specified algorithm. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] algorithm The algorithm for which supported modes will be returned. - * - * \param[out] modes Array of modes supported. The caller takes ownership of the array and must - * free() it. - * - * \param[out] modes_length Length of \p modes. - */ - keymaster_error_t (*get_supported_block_modes)(const struct keymaster1_device* dev, - keymaster_algorithm_t algorithm, - keymaster_purpose_t purpose, - keymaster_block_mode_t** modes, - size_t* modes_length); - - /** - * Gets the padding modes supported for the specified algorithm. Caller assumes ownership of - * the allocated array. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] algorithm The algorithm for which supported padding modes will be returned. - * - * \param[out] modes Array of padding modes supported. The caller takes ownership of the array - * and must free() it. - * - * \param[out] modes_length Length of \p modes. - */ - keymaster_error_t (*get_supported_padding_modes)(const struct keymaster1_device* dev, - keymaster_algorithm_t algorithm, - keymaster_purpose_t purpose, - keymaster_padding_t** modes, - size_t* modes_length); - - /** - * Gets the digests supported for the specified algorithm. Caller assumes ownership of the - * allocated array. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] algorithm The algorithm for which supported digests will be returned. - * - * \param[out] digests Array of digests supported. The caller takes ownership of the array and - * must free() it. - * - * \param[out] digests_length Length of \p digests. - */ - keymaster_error_t (*get_supported_digests)(const struct keymaster1_device* dev, - keymaster_algorithm_t algorithm, - keymaster_purpose_t purpose, - keymaster_digest_t** digests, - size_t* digests_length); - - /** - * Gets the key import formats supported for keys of the specified algorithm. Caller assumes - * ownership of the allocated array. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] algorithm The algorithm for which supported formats will be returned. - * - * \param[out] formats Array of formats supported. The caller takes ownership of the array and - * must free() it. - * - * \param[out] formats_length Length of \p formats. - */ - keymaster_error_t (*get_supported_import_formats)(const struct keymaster1_device* dev, - keymaster_algorithm_t algorithm, - keymaster_key_format_t** formats, - size_t* formats_length); - - /** - * Gets the key export formats supported for keys of the specified algorithm. Caller assumes - * ownership of the allocated array. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] algorithm The algorithm for which supported formats will be returned. - * - * \param[out] formats Array of formats supported. The caller takes ownership of the array and - * must free() it. - * - * \param[out] formats_length Length of \p formats. - */ - keymaster_error_t (*get_supported_export_formats)(const struct keymaster1_device* dev, - keymaster_algorithm_t algorithm, - keymaster_key_format_t** formats, - size_t* formats_length); - - /** - * Adds entropy to the RNG used by keymaster. Entropy added through this method is guaranteed - * not to be the only source of entropy used, and the mixing function is required to be secure, - * in the sense that if the RNG is seeded (from any source) with any data the attacker cannot - * predict (or control), then the RNG output is indistinguishable from random. Thus, if the - * entropy from any source is good, the output will be good. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] data Random data to be mixed in. - * - * \param[in] data_length Length of \p data. - */ - keymaster_error_t (*add_rng_entropy)(const struct keymaster1_device* dev, const uint8_t* data, - size_t data_length); - - /** - * Generates a key, or key pair, returning a key blob and/or a description of the key. - * - * Key generation parameters are defined as keymaster tag/value pairs, provided in \p params. - * See keymaster_tag_t for the full list. Some values that are always required for generation - * of useful keys are: - * - * - KM_TAG_ALGORITHM; - * - KM_TAG_PURPOSE; and - * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED. - * - * KM_TAG_AUTH_TIMEOUT should generally be specified unless KM_TAG_NO_AUTH_REQUIRED is present, - * or the user will have to authenticate for every use. - * - * KM_TAG_BLOCK_MODE, KM_TAG_PADDING, KM_TAG_MAC_LENGTH and KM_TAG_DIGEST must be specified for - * algorithms that require them. - * - * The following tags may not be specified; their values will be provided by the implementation. - * - * - KM_TAG_ORIGIN, - * - KM_TAG_ROLLBACK_RESISTANT, - * - KM_TAG_CREATION_DATETIME - * - * \param[in] dev The keymaster device structure. - * - * \param[in] params Array of key generation parameters. - * - * \param[in] params_count Length of \p params. - * - * \param[out] key_blob returns the generated key. \p key_blob must not be NULL. The caller - * assumes ownership key_blob->key_material and must free() it. - * - * \param[out] characteristics returns the characteristics of the key that was, generated, if - * non-NULL. If non-NULL, the caller assumes ownership and must deallocate with - * keymaster_free_characteristics(). Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and - * KM_TAG_APPLICATION_DATA are never returned. - */ - keymaster_error_t (*generate_key)(const struct keymaster1_device* dev, - const keymaster_key_param_set_t* params, - keymaster_key_blob_t* key_blob, - keymaster_key_characteristics_t** characteristics); - - /** - * Returns the characteristics of the specified key, or KM_ERROR_INVALID_KEY_BLOB if the - * key_blob is invalid (implementations must fully validate the integrity of the key). - * client_id and app_data must be the ID and data provided when the key was generated or - * imported, or empty if KM_TAG_APPLICATION_ID and/or KM_TAG_APPLICATION_DATA were not provided - * during generation. Those values are not included in the returned characteristics. The - * caller assumes ownership of the allocated characteristics object, which must be deallocated - * with keymaster_free_characteristics(). - * - * Note that KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA are never - * returned. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] key_blob The key to retreive characteristics from. - * - * \param[in] client_id The client ID data, or NULL if none associated. - * - * \param[in] app_id The app data, or NULL if none associated. - * - * \param[out] characteristics The key characteristics. - */ - keymaster_error_t (*get_key_characteristics)(const struct keymaster1_device* dev, - const keymaster_key_blob_t* key_blob, - const keymaster_blob_t* client_id, - const keymaster_blob_t* app_data, - keymaster_key_characteristics_t** characteristics); - - /** - * Imports a key, or key pair, returning a key blob and/or a description of the key. - * - * Most key import parameters are defined as keymaster tag/value pairs, provided in "params". - * See keymaster_tag_t for the full list. Values that are always required for import of useful - * keys are: - * - * - KM_TAG_ALGORITHM; - * - KM_TAG_PURPOSE; and - * - (KM_TAG_USER_SECURE_ID and KM_TAG_USER_AUTH_TYPE) or KM_TAG_NO_AUTH_REQUIRED. - * - * KM_TAG_AUTH_TIMEOUT should generally be specified. If unspecified, the user will have to - * authenticate for every use. - * - * The following tags will take default values if unspecified: - * - * - KM_TAG_KEY_SIZE will default to the size of the key provided. - * - KM_TAG_RSA_PUBLIC_EXPONENT will default to the value in the key provided (for RSA keys) - * - * The following tags may not be specified; their values will be provided by the implementation. - * - * - KM_TAG_ORIGIN, - * - KM_TAG_ROLLBACK_RESISTANT, - * - KM_TAG_CREATION_DATETIME - * - * \param[in] dev The keymaster device structure. - * - * \param[in] params Parameters defining the imported key. - * - * \param[in] params_count The number of entries in \p params. - * - * \param[in] key_format specifies the format of the key data in key_data. - * - * \param[out] key_blob Used to return the opaque key blob. Must be non-NULL. The caller - * assumes ownership of the contained key_material. - * - * \param[out] characteristics Used to return the characteristics of the imported key. May be - * NULL, in which case no characteristics will be returned. If non-NULL, the caller assumes - * ownership and must deallocate with keymaster_free_characteristics(). Note that - * KM_TAG_ROOT_OF_TRUST, KM_TAG_APPLICATION_ID and - * KM_TAG_APPLICATION_DATA are never returned. - */ - keymaster_error_t (*import_key)(const struct keymaster1_device* dev, - const keymaster_key_param_set_t* params, - keymaster_key_format_t key_format, - const keymaster_blob_t* key_data, - keymaster_key_blob_t* key_blob, - keymaster_key_characteristics_t** characteristics); - - /** - * Exports a public key, returning a byte array in the specified format. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] export_format The format to be used for exporting the key. - * - * \param[in] key_to_export The key to export. - * - * \param[out] export_data The exported key material. The caller assumes ownership. - * - * \param[out] export_data_length The length of \p export_data. - */ - keymaster_error_t (*export_key)(const struct keymaster1_device* dev, - keymaster_key_format_t export_format, - const keymaster_key_blob_t* key_to_export, - const keymaster_blob_t* client_id, - const keymaster_blob_t* app_data, - keymaster_blob_t* export_data); - - /** - * Deletes the key, or key pair, associated with the key blob. After calling this function it - * will be impossible to use the key for any other operations. May be applied to keys from - * foreign roots of trust (keys not usable under the current root of trust). - * - * This function is optional and should be set to NULL if it is not implemented. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] key The key to be deleted. - */ - keymaster_error_t (*delete_key)(const struct keymaster1_device* dev, - const keymaster_key_blob_t* key); - - /** - * Deletes all keys in the hardware keystore. Used when keystore is reset completely. After - * calling this function it will be impossible to use any previously generated or imported key - * blobs for any operations. - * - * This function is optional and should be set to NULL if it is not implemented. - * - * \param[in] dev The keymaster device structure. - */ - keymaster_error_t (*delete_all_keys)(const struct keymaster1_device* dev); - - /** - * Begins a cryptographic operation using the specified key. If all is well, begin() will - * return KM_ERROR_OK and create an operation handle which must be passed to subsequent calls to - * update(), finish() or abort(). - * - * It is critical that each call to begin() be paired with a subsequent call to finish() or - * abort(), to allow the keymaster implementation to clean up any internal operation state. - * Failure to do this may leak internal state space or other internal resources and may - * eventually cause begin() to return KM_ERROR_TOO_MANY_OPERATIONS when it runs out of space for - * operations. Any result other than KM_ERROR_OK from begin(), update() or finish() implicitly - * aborts the operation, in which case abort() need not be called (and will return - * KM_ERROR_INVALID_OPERATION_HANDLE if called). - * - * \param[in] dev The keymaster device structure. - * - * \param[in] purpose The purpose of the operation, one of KM_PURPOSE_ENCRYPT, - * KM_PURPOSE_DECRYPT, KM_PURPOSE_SIGN or KM_PURPOSE_VERIFY. Note that for AEAD modes, - * encryption and decryption imply signing and verification, respectively, but should be - * specified as KM_PURPOSE_ENCRYPT and KM_PURPOSE_DECRYPT. - * - * \param[in] key The key to be used for the operation. \p key must have a purpose compatible - * with \p purpose and all of its usage requirements must be satisfied, or begin() will return - * an appropriate error code. - * - * \param[in] in_params Additional parameters for the operation. This is typically used to - * provide authentication data, with KM_TAG_AUTH_TOKEN. If KM_TAG_APPLICATION_ID or - * KM_TAG_APPLICATION_DATA were provided during generation, they must be provided here, or the - * operation will fail with KM_ERROR_INVALID_KEY_BLOB. For operations that require a nonce or - * IV, on keys that were generated with KM_TAG_CALLER_NONCE, in_params may contain a tag - * KM_TAG_NONCE. For AEAD operations KM_TAG_CHUNK_SIZE is specified here. - * - * \param[out] out_params Output parameters. Used to return additional data from the operation - * initialization, notably to return the IV or nonce from operations that generate an IV or - * nonce. The caller takes ownership of the output parameters array and must free it with - * keymaster_free_param_set(). out_params may be set to NULL if no output parameters are - * expected. If out_params is NULL, and output paramaters are generated, begin() will return - * KM_ERROR_OUTPUT_PARAMETER_NULL. - * - * \param[out] operation_handle The newly-created operation handle which must be passed to - * update(), finish() or abort(). If operation_handle is NULL, begin() will return - * KM_ERROR_OUTPUT_PARAMETER_NULL. - */ - keymaster_error_t (*begin)(const struct keymaster1_device* dev, keymaster_purpose_t purpose, - const keymaster_key_blob_t* key, - const keymaster_key_param_set_t* in_params, - keymaster_key_param_set_t* out_params, - keymaster_operation_handle_t* operation_handle); - - /** - * Provides data to, and possibly receives output from, an ongoing cryptographic operation begun - * with begin(). - * - * If operation_handle is invalid, update() will return KM_ERROR_INVALID_OPERATION_HANDLE. - * - * update() may not consume all of the data provided in the data buffer. update() will return - * the amount consumed in *data_consumed. The caller should provide the unconsumed data in a - * subsequent call. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] operation_handle The operation handle returned by begin(). - * - * \param[in] in_params Additional parameters for the operation. For AEAD modes, this is used - * to specify KM_TAG_ADDITIONAL_DATA. Note that additional data may be provided in multiple - * calls to update(), but only until input data has been provided. - * - * \param[in] input Data to be processed, per the parameters established in the call to begin(). - * Note that update() may or may not consume all of the data provided. See \p input_consumed. - * - * \param[out] input_consumed Amount of data that was consumed by update(). If this is less - * than the amount provided, the caller should provide the remainder in a subsequent call to - * update(). - * - * \param[out] out_params Output parameters. Used to return additional data from the operation - * The caller takes ownership of the output parameters array and must free it with - * keymaster_free_param_set(). out_params may be set to NULL if no output parameters are - * expected. If out_params is NULL, and output paramaters are generated, begin() will return - * KM_ERROR_OUTPUT_PARAMETER_NULL. - * - * \param[out] output The output data, if any. The caller assumes ownership of the allocated - * buffer. output must not be NULL. - * - * Note that update() may not provide any output, in which case output->data_length will be - * zero, and output->data may be either NULL or zero-length (so the caller should always free() - * it). - */ - keymaster_error_t (*update)(const struct keymaster1_device* dev, - keymaster_operation_handle_t operation_handle, - const keymaster_key_param_set_t* in_params, - const keymaster_blob_t* input, size_t* input_consumed, - keymaster_key_param_set_t* out_params, keymaster_blob_t* output); - - /** - * Finalizes a cryptographic operation begun with begin() and invalidates \p operation_handle. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] operation_handle The operation handle returned by begin(). This handle will be - * invalidated. - * - * \param[in] params Additional parameters for the operation. For AEAD modes, this is used to - * specify KM_TAG_ADDITIONAL_DATA, but only if no input data was provided to update(). - * - * \param[in] signature The signature to be verified if the purpose specified in the begin() - * call was KM_PURPOSE_VERIFY. - * - * \param[out] output The output data, if any. The caller assumes ownership of the allocated - * buffer. - * - * If the operation being finished is a signature verification or an AEAD-mode decryption and - * verification fails then finish() will return KM_ERROR_VERIFICATION_FAILED. - */ - keymaster_error_t (*finish)(const struct keymaster1_device* dev, - keymaster_operation_handle_t operation_handle, - const keymaster_key_param_set_t* in_params, - const keymaster_blob_t* signature, - keymaster_key_param_set_t* out_params, keymaster_blob_t* output); - - /** - * Aborts a cryptographic operation begun with begin(), freeing all internal resources and - * invalidating \p operation_handle. - */ - keymaster_error_t (*abort)(const struct keymaster1_device* dev, - keymaster_operation_handle_t operation_handle); - - /** - * Generates a pair of ATTK defined in SOTER. Save the private key into RPMB. - * Note that the ATTK generated will never be touched outside the keymaster. - * - * \param[in] dev The keymaster device structure. - * - * \param[in] copy_num The number of copies that will be saved in the RPMB. - */ - keymaster_error_t (*generate_attk_key_pair)(const struct keymaster1_device* dev, - const uint8_t copy_num); - - /** - * Verify the existance ATTK defined in SOTER. - * - * \param[in] dev The keymaster device structure. - * - * Returns: 0 if the ATTK exists. - */ - keymaster_error_t (*verify_attk_key_pair)(const struct keymaster1_device* dev); - - /** - * Export the public key of ATTK in PEM format. - * - * \param[in] dev The keymaster device structure. - * - * \param[out] pub_key_data The public key data in X.509v3 format PEM encoded - * - * \param[out] pub_key_data_length The length of the public key data. - */ - keymaster_error_t (*export_attk_public_key)(const struct keymaster1_device* dev, - const uint8_t* pub_key_data, - const size_t pub_key_data_length); - - /** - * Get Unique device ID. - * - * \param[in] dev The keymaster device structure. - * - * \param[out] device_id The unique id for each device, format as below: - * 1.bytes 0-3: Identify each silicon provider id. - * 2.bytes 4-7: SoC model ID, defined by each silicon provider - * 3.bytes 8-15: Public Chip Serial *Number of SoC, defined by each silicon provider - * - * \param[out] device_id_length The length of the device id. - */ - keymaster_error_t (*get_device_id)(const struct keymaster1_device* dev, - const uint8_t* device_id, - const size_t device_id_length); -}; -typedef struct keymaster1_device keymaster1_device_t; - -/* Convenience API for opening and closing keymaster devices */ - -static inline int keymaster1_open(const struct hw_module_t* module, keymaster1_device_t** device) { - return module->methods->open(module, KEYSTORE_KEYMASTER, (struct hw_device_t**)device); -} - -static inline int keymaster1_close(keymaster1_device_t* device) { - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_HARDWARE_KEYMASTER1_H diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster_common.h b/third_party/android_hardware_libhardware/include/hardware/keymaster_common.h deleted file mode 100644 index 772d7e4d2..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster_common.h +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef ANDROID_HARDWARE_KEYMASTER_COMMON_H -#define ANDROID_HARDWARE_KEYMASTER_COMMON_H - -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define KEYSTORE_HARDWARE_MODULE_ID "keystore" - -#define KEYSTORE_KEYMASTER "keymaster" - - -/** - * Settings for "module_api_version" and "hal_api_version" - * fields in the keymaster_module initialization. - */ - -/** - * Keymaster 0.X module version provide the same APIs, but later versions add more options - * for algorithms and flags. - */ -#define KEYMASTER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) -#define KEYMASTER_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION(0, 2) - -#define KEYMASTER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) -#define KEYMASTER_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION(0, 3) - -/** - * Keymaster 1.0 module version provides a completely different API, incompatible with 0.X. - */ -#define KEYMASTER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define KEYMASTER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) - -struct keystore_module { - /** - * Common methods of the keystore module. This *must* be the first member of keystore_module as - * users of this structure will cast a hw_module_t to keystore_module pointer in contexts where - * it's known the hw_module_t references a keystore_module. - */ - hw_module_t common; - - /* There are no keystore module methods other than the common ones. */ -}; - -/** - * Flags for keymaster0_device::flags - */ -enum { - /* - * Indicates this keymaster implementation does not have hardware that - * keeps private keys out of user space. - * - * This should not be implemented on anything other than the default - * implementation. - */ - KEYMASTER_SOFTWARE_ONLY = 1 << 0, - - /* - * This indicates that the key blobs returned via all the primitives - * are sufficient to operate on their own without the trusted OS - * querying userspace to retrieve some other data. Key blobs of - * this type are normally returned encrypted with a - * Key Encryption Key (KEK). - * - * This is currently used by "vold" to know whether the whole disk - * encryption secret can be unwrapped without having some external - * service started up beforehand since the "/data" partition will - * be unavailable at that point. - */ - KEYMASTER_BLOBS_ARE_STANDALONE = 1 << 1, - - /* - * Indicates that the keymaster module supports DSA keys. - */ - KEYMASTER_SUPPORTS_DSA = 1 << 2, - - /* - * Indicates that the keymaster module supports EC keys. - */ - KEYMASTER_SUPPORTS_EC = 1 << 3, -}; - -/** - * Asymmetric key pair types. - */ -typedef enum { - TYPE_RSA = 1, - TYPE_DSA = 2, - TYPE_EC = 3, -} keymaster_keypair_t; - -/** - * Parameters needed to generate an RSA key. - */ -typedef struct { - uint32_t modulus_size; - uint64_t public_exponent; -} keymaster_rsa_keygen_params_t; - -/** - * Parameters needed to generate a DSA key. - */ -typedef struct { - uint32_t key_size; - uint32_t generator_len; - uint32_t prime_p_len; - uint32_t prime_q_len; - const uint8_t* generator; - const uint8_t* prime_p; - const uint8_t* prime_q; -} keymaster_dsa_keygen_params_t; - -/** - * Parameters needed to generate an EC key. - * - * Field size is the only parameter in version 2. The sizes correspond to these required curves: - * - * 192 = NIST P-192 - * 224 = NIST P-224 - * 256 = NIST P-256 - * 384 = NIST P-384 - * 521 = NIST P-521 - * - * The parameters for these curves are available at: http://www.nsa.gov/ia/_files/nist-routines.pdf - * in Chapter 4. - */ -typedef struct { - uint32_t field_size; -} keymaster_ec_keygen_params_t; - - -/** - * Digest type. - */ -typedef enum { - DIGEST_NONE, -} keymaster_digest_algorithm_t; - -/** - * Type of padding used for RSA operations. - */ -typedef enum { - PADDING_NONE, -} keymaster_rsa_padding_t; - - -typedef struct { - keymaster_digest_algorithm_t digest_type; -} keymaster_dsa_sign_params_t; - -typedef struct { - keymaster_digest_algorithm_t digest_type; -} keymaster_ec_sign_params_t; - -typedef struct { - keymaster_digest_algorithm_t digest_type; - keymaster_rsa_padding_t padding_type; -} keymaster_rsa_sign_params_t; - -__END_DECLS - -#endif // ANDROID_HARDWARE_KEYMASTER_COMMON_H diff --git a/third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h b/third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h deleted file mode 100644 index 1a723c94a..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/keymaster_defs.h +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#ifndef ANDROID_HARDWARE_KEYMASTER_DEFS_H -#define ANDROID_HARDWARE_KEYMASTER_DEFS_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -/** - * Authorization tags each have an associated type. This enumeration facilitates tagging each with - * a type, by using the high four bits (of an implied 32-bit unsigned enum value) to specify up to - * 16 data types. These values are ORed with tag IDs to generate the final tag ID values. - */ -typedef enum { - KM_INVALID = 0 << 28, /* Invalid type, used to designate a tag as uninitialized */ - KM_ENUM = 1 << 28, - KM_ENUM_REP = 2 << 28, /* Repeatable enumeration value. */ - KM_UINT = 3 << 28, - KM_UINT_REP = 4 << 28, /* Repeatable integer value */ - KM_ULONG = 5 << 28, - KM_DATE = 6 << 28, - KM_BOOL = 7 << 28, - KM_BIGNUM = 8 << 28, - KM_BYTES = 9 << 28, - KM_ULONG_REP = 10 << 28, /* Repeatable long value */ -} keymaster_tag_type_t; - -typedef enum { - KM_TAG_INVALID = KM_INVALID | 0, - - /* - * Tags that must be semantically enforced by hardware and software implementations. - */ - - /* Crypto parameters */ - KM_TAG_PURPOSE = KM_ENUM_REP | 1, /* keymaster_purpose_t. */ - KM_TAG_ALGORITHM = KM_ENUM | 2, /* keymaster_algorithm_t. */ - KM_TAG_KEY_SIZE = KM_UINT | 3, /* Key size in bits. */ - KM_TAG_BLOCK_MODE = KM_ENUM_REP | 4, /* keymaster_block_mode_t. */ - KM_TAG_DIGEST = KM_ENUM_REP | 5, /* keymaster_digest_t. */ - KM_TAG_PADDING = KM_ENUM_REP | 6, /* keymaster_padding_t. */ - KM_TAG_CALLER_NONCE = KM_BOOL | 7, /* Allow caller to specify nonce or IV. */ - KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8, /* Minimum length of MAC or AEAD authentication tag in - * bits. */ - - /* Algorithm-specific. */ - KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200, - - /* Other hardware-enforced. */ - KM_TAG_BLOB_USAGE_REQUIREMENTS = KM_ENUM | 301, /* keymaster_key_blob_usage_requirements_t */ - KM_TAG_BOOTLOADER_ONLY = KM_BOOL | 302, /* Usable only by bootloader */ - - /* - * Tags that should be semantically enforced by hardware if possible and will otherwise be - * enforced by software (keystore). - */ - - /* Key validity period */ - KM_TAG_ACTIVE_DATETIME = KM_DATE | 400, /* Start of validity */ - KM_TAG_ORIGINATION_EXPIRE_DATETIME = KM_DATE | 401, /* Date when new "messages" should no - longer be created. */ - KM_TAG_USAGE_EXPIRE_DATETIME = KM_DATE | 402, /* Date when existing "messages" should no - longer be trusted. */ - KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_UINT | 403, /* Minimum elapsed time between - cryptographic operations with the key. */ - KM_TAG_MAX_USES_PER_BOOT = KM_UINT | 404, /* Number of times the key can be used per - boot. */ - - /* User authentication */ - KM_TAG_ALL_USERS = KM_BOOL | 500, /* Reserved for future use -- ignore */ - KM_TAG_USER_ID = KM_UINT | 501, /* Reserved for future use -- ignore */ - KM_TAG_USER_SECURE_ID = KM_ULONG_REP | 502, /* Secure ID of authorized user or authenticator(s). - Disallowed if KM_TAG_ALL_USERS or - KM_TAG_NO_AUTH_REQUIRED is present. */ - KM_TAG_NO_AUTH_REQUIRED = KM_BOOL | 503, /* If key is usable without authentication. */ - KM_TAG_USER_AUTH_TYPE = KM_ENUM | 504, /* Bitmask of authenticator types allowed when - * KM_TAG_USER_SECURE_ID contains a secure user ID, - * rather than a secure authenticator ID. Defined in - * hw_authenticator_type_t in hw_auth_token.h. */ - KM_TAG_AUTH_TIMEOUT = KM_UINT | 505, /* Required freshness of user authentication for - private/secret key operations, in seconds. - Public key operations require no authentication. - If absent, authentication is required for every - use. Authentication state is lost when the - device is powered off. */ - - /* Application access control */ - KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* Reserved for future use -- ignore */ - KM_TAG_APPLICATION_ID = KM_BYTES | 601, /* Reserved for fugure use -- ignore */ - - /* - * Semantically unenforceable tags, either because they have no specific meaning or because - * they're informational only. - */ - KM_TAG_APPLICATION_DATA = KM_BYTES | 700, /* Data provided by authorized application. */ - KM_TAG_CREATION_DATETIME = KM_DATE | 701, /* Key creation time */ - KM_TAG_ORIGIN = KM_ENUM | 702, /* keymaster_key_origin_t. */ - KM_TAG_ROLLBACK_RESISTANT = KM_BOOL | 703, /* Whether key is rollback-resistant. */ - KM_TAG_ROOT_OF_TRUST = KM_BYTES | 704, /* Root of trust ID. */ - - /* Tags used only to provide data to or receive data from operations */ - KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000, /* Used to provide associated data for AEAD modes. */ - KM_TAG_NONCE = KM_BYTES | 1001, /* Nonce or Initialization Vector */ - KM_TAG_AUTH_TOKEN = KM_BYTES | 1002, /* Authentication token that proves secure user - authentication has been performed. Structure - defined in hw_auth_token_t in hw_auth_token.h. */ - KM_TAG_MAC_LENGTH = KM_UINT | 1003, /* MAC or AEAD authentication tag length in bits. */ - - /* Tags used only for SOTER */ - /* Tags used only to check if the key is for SOTER */ - KM_TAG_SOTER_IS_FROM_SOTER = KM_BOOL | 11000, - /* Attach signature signed with ATTK[pri] while exporting public key */ - KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_ATTK_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11001, - /* Attach signature signed with specified private key while exporting public key */ - KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_COMMON_KEY_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11002, - /* keyalias for the keypair of KM_TAG_SOTER_IS_AUTO_SIGNED_WITH_COMMON_KEY_WHEN_GET_PUBLIC_KEY */ - KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY = KM_BYTES | 11003, - /* Attach counter while exporting publick key */ - KM_TAG_SOTER_AUTO_ADD_COUNTER_WHEN_GET_PUBLIC_KEY = KM_BOOL | 11004, - /* Attach secmsg(TEE_Name, TEE_Version, Fingerprint_Sensor_Name, Fingerprint_Sensor_Version) - fingerprint_id and counter while signing */ - KM_TAG_SOTER_IS_SECMSG_FID_COUNTER_SIGNED_WHEN_SIGN = KM_BOOL | 11005, - /* use and set ATTK index to next backup ATTK */ - KM_TAG_SOTER_USE_NEXT_ATTK = KM_BOOL | 11006, - /* attach soter uid */ - KM_TAG_SOTER_UID = KM_UINT | 11007, - /* attach key blob of KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY if needed */ - KM_TAG_SOTER_AUTO_SIGNED_COMMON_KEY_WHEN_GET_PUBLIC_KEY_BLOB = KM_BYTES | 11008, -} keymaster_tag_t; - -/** - * Algorithms that may be provided by keymaster implementations. Those that must be provided by all - * implementations are tagged as "required". - */ -typedef enum { - /* Asymmetric algorithms. */ - KM_ALGORITHM_RSA = 1, - // KM_ALGORITHM_DSA = 2, -- Removed, do not re-use value 2. - KM_ALGORITHM_EC = 3, - - /* Block ciphers algorithms */ - KM_ALGORITHM_AES = 32, - - /* MAC algorithms */ - KM_ALGORITHM_HMAC = 128, -} keymaster_algorithm_t; - -/** - * Symmetric block cipher modes provided by keymaster implementations. - */ -typedef enum { - /* Unauthenticated modes, usable only for encryption/decryption and not generally recommended - * except for compatibility with existing other protocols. */ - KM_MODE_ECB = 1, - KM_MODE_CBC = 2, - KM_MODE_CTR = 3, - - /* Authenticated modes, usable for encryption/decryption and signing/verification. Recommended - * over unauthenticated modes for all purposes. */ - KM_MODE_GCM = 32, -} keymaster_block_mode_t; - -/** - * Padding modes that may be applied to plaintext for encryption operations. This list includes - * padding modes for both symmetric and asymmetric algorithms. Note that implementations should not - * provide all possible combinations of algorithm and padding, only the - * cryptographically-appropriate pairs. - */ -typedef enum { - KM_PAD_NONE = 1, /* deprecated */ - KM_PAD_RSA_OAEP = 2, - KM_PAD_RSA_PSS = 3, - KM_PAD_RSA_PKCS1_1_5_ENCRYPT = 4, - KM_PAD_RSA_PKCS1_1_5_SIGN = 5, - KM_PAD_PKCS7 = 64, -} keymaster_padding_t; - -/** - * Digests provided by keymaster implementations. - */ -typedef enum { - KM_DIGEST_NONE = 0, - KM_DIGEST_MD5 = 1, /* Optional, may not be implemented in hardware, will be handled in software - * if needed. */ - KM_DIGEST_SHA1 = 2, - KM_DIGEST_SHA_2_224 = 3, - KM_DIGEST_SHA_2_256 = 4, - KM_DIGEST_SHA_2_384 = 5, - KM_DIGEST_SHA_2_512 = 6, -} keymaster_digest_t; - -/** - * The origin of a key (or pair), i.e. where it was generated. Note that KM_TAG_ORIGIN can be found - * in either the hardware-enforced or software-enforced list for a key, indicating whether the key - * is hardware or software-based. Specifically, a key with KM_ORIGIN_GENERATED in the - * hardware-enforced list is guaranteed never to have existed outide the secure hardware. - */ -typedef enum { - KM_ORIGIN_GENERATED = 0, /* Generated in keymaster */ - KM_ORIGIN_IMPORTED = 2, /* Imported, origin unknown */ - KM_ORIGIN_UNKNOWN = 3, /* Keymaster did not record origin. This value can only be seen on - * keys in a keymaster0 implementation. The keymaster0 adapter uses - * this value to document the fact that it is unkown whether the key - * was generated inside or imported into keymaster. */ -} keymaster_key_origin_t; - -/** - * Usability requirements of key blobs. This defines what system functionality must be available - * for the key to function. For example, key "blobs" which are actually handles referencing - * encrypted key material stored in the file system cannot be used until the file system is - * available, and should have BLOB_REQUIRES_FILE_SYSTEM. Other requirements entries will be added - * as needed for implementations. This type is new in 0_4. - */ -typedef enum { - KM_BLOB_STANDALONE = 0, - KM_BLOB_REQUIRES_FILE_SYSTEM = 1, -} keymaster_key_blob_usage_requirements_t; - -/** - * Possible purposes of a key (or pair). This type is new in 0_4. - */ -typedef enum { - KM_PURPOSE_ENCRYPT = 0, - KM_PURPOSE_DECRYPT = 1, - KM_PURPOSE_SIGN = 2, - KM_PURPOSE_VERIFY = 3, -} keymaster_purpose_t; - -typedef struct { - const uint8_t* data; - size_t data_length; -} keymaster_blob_t; - -typedef struct { - keymaster_tag_t tag; - union { - uint32_t enumerated; /* KM_ENUM and KM_ENUM_REP */ - bool boolean; /* KM_BOOL */ - uint32_t integer; /* KM_INT and KM_INT_REP */ - uint64_t long_integer; /* KM_LONG */ - uint64_t date_time; /* KM_DATE */ - keymaster_blob_t blob; /* KM_BIGNUM and KM_BYTES*/ - }; -} keymaster_key_param_t; - -typedef struct { - keymaster_key_param_t* params; /* may be NULL if length == 0 */ - size_t length; -} keymaster_key_param_set_t; - -/** - * Parameters that define a key's characteristics, including authorized modes of usage and access - * control restrictions. The parameters are divided into two categories, those that are enforced by - * secure hardware, and those that are not. For a software-only keymaster implementation the - * enforced array must NULL. Hardware implementations must enforce everything in the enforced - * array. - */ -typedef struct { - keymaster_key_param_set_t hw_enforced; - keymaster_key_param_set_t sw_enforced; -} keymaster_key_characteristics_t; - -typedef struct { - const uint8_t* key_material; - size_t key_material_size; -} keymaster_key_blob_t; - -/** - * Formats for key import and export. At present, only asymmetric key import/export is supported. - * In the future this list will expand greatly to accommodate asymmetric key import/export. - */ -typedef enum { - KM_KEY_FORMAT_X509 = 0, /* for public key export */ - KM_KEY_FORMAT_PKCS8 = 1, /* for asymmetric key pair import */ - KM_KEY_FORMAT_RAW = 3, /* for symmetric key import */ -} keymaster_key_format_t; - -/** - * The keymaster operation API consists of begin, update, finish and abort. This is the type of the - * handle used to tie the sequence of calls together. A 64-bit value is used because it's important - * that handles not be predictable. Implementations must use strong random numbers for handle - * values. - */ -typedef uint64_t keymaster_operation_handle_t; - -typedef enum { - KM_ERROR_OK = 0, - KM_ERROR_ROOT_OF_TRUST_ALREADY_SET = -1, - KM_ERROR_UNSUPPORTED_PURPOSE = -2, - KM_ERROR_INCOMPATIBLE_PURPOSE = -3, - KM_ERROR_UNSUPPORTED_ALGORITHM = -4, - KM_ERROR_INCOMPATIBLE_ALGORITHM = -5, - KM_ERROR_UNSUPPORTED_KEY_SIZE = -6, - KM_ERROR_UNSUPPORTED_BLOCK_MODE = -7, - KM_ERROR_INCOMPATIBLE_BLOCK_MODE = -8, - KM_ERROR_UNSUPPORTED_MAC_LENGTH = -9, - KM_ERROR_UNSUPPORTED_PADDING_MODE = -10, - KM_ERROR_INCOMPATIBLE_PADDING_MODE = -11, - KM_ERROR_UNSUPPORTED_DIGEST = -12, - KM_ERROR_INCOMPATIBLE_DIGEST = -13, - KM_ERROR_INVALID_EXPIRATION_TIME = -14, - KM_ERROR_INVALID_USER_ID = -15, - KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT = -16, - KM_ERROR_UNSUPPORTED_KEY_FORMAT = -17, - KM_ERROR_INCOMPATIBLE_KEY_FORMAT = -18, - KM_ERROR_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM = -19, /* For PKCS8 & PKCS12 */ - KM_ERROR_UNSUPPORTED_KEY_VERIFICATION_ALGORITHM = -20, /* For PKCS8 & PKCS12 */ - KM_ERROR_INVALID_INPUT_LENGTH = -21, - KM_ERROR_KEY_EXPORT_OPTIONS_INVALID = -22, - KM_ERROR_DELEGATION_NOT_ALLOWED = -23, - KM_ERROR_KEY_NOT_YET_VALID = -24, - KM_ERROR_KEY_EXPIRED = -25, - KM_ERROR_KEY_USER_NOT_AUTHENTICATED = -26, - KM_ERROR_OUTPUT_PARAMETER_NULL = -27, - KM_ERROR_INVALID_OPERATION_HANDLE = -28, - KM_ERROR_INSUFFICIENT_BUFFER_SPACE = -29, - KM_ERROR_VERIFICATION_FAILED = -30, - KM_ERROR_TOO_MANY_OPERATIONS = -31, - KM_ERROR_UNEXPECTED_NULL_POINTER = -32, - KM_ERROR_INVALID_KEY_BLOB = -33, - KM_ERROR_IMPORTED_KEY_NOT_ENCRYPTED = -34, - KM_ERROR_IMPORTED_KEY_DECRYPTION_FAILED = -35, - KM_ERROR_IMPORTED_KEY_NOT_SIGNED = -36, - KM_ERROR_IMPORTED_KEY_VERIFICATION_FAILED = -37, - KM_ERROR_INVALID_ARGUMENT = -38, - KM_ERROR_UNSUPPORTED_TAG = -39, - KM_ERROR_INVALID_TAG = -40, - KM_ERROR_MEMORY_ALLOCATION_FAILED = -41, - KM_ERROR_IMPORT_PARAMETER_MISMATCH = -44, - KM_ERROR_SECURE_HW_ACCESS_DENIED = -45, - KM_ERROR_OPERATION_CANCELLED = -46, - KM_ERROR_CONCURRENT_ACCESS_CONFLICT = -47, - KM_ERROR_SECURE_HW_BUSY = -48, - KM_ERROR_SECURE_HW_COMMUNICATION_FAILED = -49, - KM_ERROR_UNSUPPORTED_EC_FIELD = -50, - KM_ERROR_MISSING_NONCE = -51, - KM_ERROR_INVALID_NONCE = -52, - KM_ERROR_MISSING_MAC_LENGTH = -53, - KM_ERROR_KEY_RATE_LIMIT_EXCEEDED = -54, - KM_ERROR_CALLER_NONCE_PROHIBITED = -55, - KM_ERROR_KEY_MAX_OPS_EXCEEDED = -56, - KM_ERROR_INVALID_MAC_LENGTH = -57, - KM_ERROR_MISSING_MIN_MAC_LENGTH = -58, - KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = -59, - - KM_ERROR_UNIMPLEMENTED = -100, - KM_ERROR_VERSION_MISMATCH = -101, - - /* Additional error codes may be added by implementations, but implementers should coordinate - * with Google to avoid code collision. */ - KM_ERROR_UNKNOWN_ERROR = -1000, -} keymaster_error_t; - -/* Convenience functions for manipulating keymaster tag types */ - -static inline keymaster_tag_type_t keymaster_tag_get_type(keymaster_tag_t tag) { - return (keymaster_tag_type_t)(tag & (0xF << 28)); -} - -static inline uint32_t keymaster_tag_mask_type(keymaster_tag_t tag) { - return tag & 0x0FFFFFFF; -} - -static inline bool keymaster_tag_type_repeatable(keymaster_tag_type_t type) { - switch (type) { - case KM_UINT_REP: - case KM_ENUM_REP: - return true; - default: - return false; - } -} - -static inline bool keymaster_tag_repeatable(keymaster_tag_t tag) { - return keymaster_tag_type_repeatable(keymaster_tag_get_type(tag)); -} - -/* Convenience functions for manipulating keymaster_key_param_t structs */ - -inline keymaster_key_param_t keymaster_param_enum(keymaster_tag_t tag, uint32_t value) { - // assert(keymaster_tag_get_type(tag) == KM_ENUM || keymaster_tag_get_type(tag) == KM_ENUM_REP); - keymaster_key_param_t param; - memset(¶m, 0, sizeof(param)); - param.tag = tag; - param.enumerated = value; - return param; -} - -inline keymaster_key_param_t keymaster_param_int(keymaster_tag_t tag, uint32_t value) { - // assert(keymaster_tag_get_type(tag) == KM_INT || keymaster_tag_get_type(tag) == KM_INT_REP); - keymaster_key_param_t param; - memset(¶m, 0, sizeof(param)); - param.tag = tag; - param.integer = value; - return param; -} - -inline keymaster_key_param_t keymaster_param_long(keymaster_tag_t tag, uint64_t value) { - // assert(keymaster_tag_get_type(tag) == KM_LONG); - keymaster_key_param_t param; - memset(¶m, 0, sizeof(param)); - param.tag = tag; - param.long_integer = value; - return param; -} - -inline keymaster_key_param_t keymaster_param_blob(keymaster_tag_t tag, const uint8_t* bytes, - size_t bytes_len) { - // assert(keymaster_tag_get_type(tag) == KM_BYTES || keymaster_tag_get_type(tag) == KM_BIGNUM); - keymaster_key_param_t param; - memset(¶m, 0, sizeof(param)); - param.tag = tag; - param.blob.data = (uint8_t*)bytes; - param.blob.data_length = bytes_len; - return param; -} - -inline keymaster_key_param_t keymaster_param_bool(keymaster_tag_t tag) { - // assert(keymaster_tag_get_type(tag) == KM_BOOL); - keymaster_key_param_t param; - memset(¶m, 0, sizeof(param)); - param.tag = tag; - param.boolean = true; - return param; -} - -inline keymaster_key_param_t keymaster_param_date(keymaster_tag_t tag, uint64_t value) { - // assert(keymaster_tag_get_type(tag) == KM_DATE); - keymaster_key_param_t param; - memset(¶m, 0, sizeof(param)); - param.tag = tag; - param.date_time = value; - return param; -} - -#define KEYMASTER_SIMPLE_COMPARE(a, b) (a < b) ? -1 : ((a > b) ? 1 : 0) -inline int keymaster_param_compare(const keymaster_key_param_t* a, const keymaster_key_param_t* b) { - int retval = KEYMASTER_SIMPLE_COMPARE(a->tag, b->tag); - if (retval != 0) - return retval; - - switch (keymaster_tag_get_type(a->tag)) { - case KM_INVALID: - case KM_BOOL: - return 0; - case KM_ENUM: - case KM_ENUM_REP: - return KEYMASTER_SIMPLE_COMPARE(a->enumerated, b->enumerated); - case KM_UINT: - case KM_UINT_REP: - return KEYMASTER_SIMPLE_COMPARE(a->integer, b->integer); - case KM_ULONG: - case KM_ULONG_REP: - return KEYMASTER_SIMPLE_COMPARE(a->long_integer, b->long_integer); - case KM_DATE: - return KEYMASTER_SIMPLE_COMPARE(a->date_time, b->date_time); - case KM_BIGNUM: - case KM_BYTES: - // Handle the empty cases. - if (a->blob.data_length != 0 && b->blob.data_length == 0) - return -1; - if (a->blob.data_length == 0 && b->blob.data_length == 0) - return 0; - if (a->blob.data_length == 0 && b->blob.data_length > 0) - return 1; - - retval = memcmp(a->blob.data, b->blob.data, a->blob.data_length < b->blob.data_length - ? a->blob.data_length - : b->blob.data_length); - if (retval != 0) - return retval; - else if (a->blob.data_length != b->blob.data_length) { - // Equal up to the common length; longer one is larger. - if (a->blob.data_length < b->blob.data_length) - return -1; - if (a->blob.data_length > b->blob.data_length) - return 1; - }; - } - - return 0; -} -#undef KEYMASTER_SIMPLE_COMPARE - -inline void keymaster_free_param_values(keymaster_key_param_t* param, size_t param_count) { - while (param_count-- > 0) { - switch (keymaster_tag_get_type(param->tag)) { - case KM_BIGNUM: - case KM_BYTES: - free((void*)param->blob.data); - param->blob.data = NULL; - break; - default: - // NOP - break; - } - ++param; - } -} - -inline void keymaster_free_param_set(keymaster_key_param_set_t* set) { - if (set) { - keymaster_free_param_values(set->params, set->length); - free(set->params); - set->params = NULL; - } -} - -inline void keymaster_free_characteristics(keymaster_key_characteristics_t* characteristics) { - if (characteristics) { - keymaster_free_param_set(&characteristics->hw_enforced); - keymaster_free_param_set(&characteristics->sw_enforced); - } -} - -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - -#endif // ANDROID_HARDWARE_KEYMASTER_DEFS_H diff --git a/third_party/android_hardware_libhardware/include/hardware/lights.h b/third_party/android_hardware_libhardware/include/hardware/lights.h deleted file mode 100644 index 777c91593..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/lights.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -#ifndef ANDROID_LIGHTS_INTERFACE_H -#define ANDROID_LIGHTS_INTERFACE_H - -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define LIGHTS_HARDWARE_MODULE_ID "lights" - -/* - * These light IDs correspond to logical lights, not physical. - * So for example, if your INDICATOR light is in line with your - * BUTTONS, it might make sense to also light the INDICATOR - * light to a reasonable color when the BUTTONS are lit. - */ -#define LIGHT_ID_BACKLIGHT "backlight" -#define LIGHT_ID_KEYBOARD "keyboard" -#define LIGHT_ID_BUTTONS "buttons" -#define LIGHT_ID_BATTERY "battery" -#define LIGHT_ID_NOTIFICATIONS "notifications" -#define LIGHT_ID_ATTENTION "attention" - -/* - * These lights aren't currently supported by the higher - * layers, but could be someday, so we have the constants - * here now. - */ -#define LIGHT_ID_BLUETOOTH "bluetooth" -#define LIGHT_ID_WIFI "wifi" - -/* - * Additional hardware-specific lights - */ -#define LIGHT_ID_CAPS "caps" -#define LIGHT_ID_FUNC "func" - -/* ************************************************************************ - * Flash modes for the flashMode field of light_state_t. - */ - -#define LIGHT_FLASH_NONE 0 - -/** - * To flash the light at a given rate, set flashMode to LIGHT_FLASH_TIMED, - * and then flashOnMS should be set to the number of milliseconds to turn - * the light on, followed by the number of milliseconds to turn the light - * off. - */ -#define LIGHT_FLASH_TIMED 1 - -/** - * To flash the light using hardware assist, set flashMode to - * the hardware mode. - */ -#define LIGHT_FLASH_HARDWARE 2 - -/** - * Light brightness is managed by a user setting. - */ -#define BRIGHTNESS_MODE_USER 0 - -/** - * Light brightness is managed by a light sensor. - */ -#define BRIGHTNESS_MODE_SENSOR 1 - -/** - * Light mode allows multiple LEDs - */ -#define LIGHT_MODE_MULTIPLE_LEDS 0x01 - -/** - * The parameters that can be set for a given light. - * - * Not all lights must support all parameters. If you - * can do something backward-compatible, you should. - */ -struct light_state_t { - /** - * The color of the LED in ARGB. - * - * Do your best here. - * - If your light can only do red or green, if they ask for blue, - * you should do green. - * - If you can only do a brightness ramp, then use this formula: - * unsigned char brightness = ((77*((color>>16)&0x00ff)) - * + (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8; - * - If you can only do on or off, 0 is off, anything else is on. - * - * The high byte should be ignored. Callers will set it to 0xff (which - * would correspond to 255 alpha). - * - * CyanogenMod: The high byte value can be implemented to control the LEDs - * Brightness from the Lights settings. The value goes from 0x01 to 0xFF. - */ - unsigned int color; - - /** - * See the LIGHT_FLASH_* constants - */ - int flashMode; - int flashOnMS; - int flashOffMS; - - /** - * Policy used by the framework to manage the light's brightness. - * Currently the values are BRIGHTNESS_MODE_USER and BRIGHTNESS_MODE_SENSOR. - */ - int brightnessMode; - - /** - * Define the LEDs modes (multiple, ...). - * See the LIGHTS_MODE_* mask constants. - */ - unsigned int ledsModes; -}; - -struct light_device_t { - struct hw_device_t common; - - /** - * Set the provided lights to the provided values. - * - * Returns: 0 on succes, error code on failure. - */ - int (*set_light)(struct light_device_t* dev, - struct light_state_t const* state); -}; - - -__END_DECLS - -#endif // ANDROID_LIGHTS_INTERFACE_H - diff --git a/third_party/android_hardware_libhardware/include/hardware/local_time_hal.h b/third_party/android_hardware_libhardware/include/hardware/local_time_hal.h deleted file mode 100644 index 946e79978..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/local_time_hal.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - - -#ifndef ANDROID_LOCAL_TIME_HAL_INTERFACE_H -#define ANDROID_LOCAL_TIME_HAL_INTERFACE_H - -#include - -#include - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define LOCAL_TIME_HARDWARE_MODULE_ID "local_time" - -/** - * Name of the local time devices to open - */ -#define LOCAL_TIME_HARDWARE_INTERFACE "local_time_hw_if" - -/**********************************************************************/ - -/** - * A structure used to collect low level sync data in a lab environment. Most - * HAL implementations will never need this structure. - */ -struct local_time_debug_event { - int64_t local_timesync_event_id; - int64_t local_time; -}; - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -struct local_time_module { - struct hw_module_t common; -}; - -struct local_time_hw_device { - /** - * Common methods of the local time hardware device. This *must* be the first member of - * local_time_hw_device as users of this structure will cast a hw_device_t to - * local_time_hw_device pointer in contexts where it's known the hw_device_t references a - * local_time_hw_device. - */ - struct hw_device_t common; - - /** - * - * Returns the current value of the system wide local time counter - */ - int64_t (*get_local_time)(struct local_time_hw_device* dev); - - /** - * - * Returns the nominal frequency (in hertz) of the system wide local time - * counter - */ - uint64_t (*get_local_freq)(struct local_time_hw_device* dev); - - /** - * - * Sets the HW slew rate of oscillator which drives the system wide local - * time counter. On success, platforms should return 0. Platforms which - * do not support HW slew should leave this method set to NULL. - * - * Valid values for rate range from MIN_INT16 to MAX_INT16. Platform - * implementations should attempt map this range linearly to the min/max - * slew rate of their hardware. - */ - int (*set_local_slew)(struct local_time_hw_device* dev, int16_t rate); - - /** - * - * A method used to collect low level sync data in a lab environments. - * Most HAL implementations will simply set this member to NULL, or return - * -EINVAL to indicate that this functionality is not supported. - * Production HALs should never support this method. - */ - int (*get_debug_log)(struct local_time_hw_device* dev, - struct local_time_debug_event* records, - int max_records); -}; - -typedef struct local_time_hw_device local_time_hw_device_t; - -/** convenience API for opening and closing a supported device */ - -static inline int local_time_hw_device_open( - const struct hw_module_t* module, - struct local_time_hw_device** device) -{ - return module->methods->open(module, LOCAL_TIME_HARDWARE_INTERFACE, - (struct hw_device_t**)device); -} - -static inline int local_time_hw_device_close(struct local_time_hw_device* device) -{ - return device->common.close(&device->common); -} - - -__END_DECLS - -#endif // ANDROID_LOCAL_TIME_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/memtrack.h b/third_party/android_hardware_libhardware/include/hardware/memtrack.h deleted file mode 100644 index 57ba4ad79..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/memtrack.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_MEMTRACK_H -#define ANDROID_INCLUDE_HARDWARE_MEMTRACK_H - -#include -#include -#include - -#include - -__BEGIN_DECLS - -#define MEMTRACK_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) - -/** - * The id of this module - */ -#define MEMTRACK_HARDWARE_MODULE_ID "memtrack" - -/* - * The Memory Tracker HAL is designed to return information about device-specific - * memory usage. The primary goal is to be able to track memory that is not - * trackable in any other way, for example texture memory that is allocated by - * a process, but not mapped in to that process' address space. - * A secondary goal is to be able to categorize memory used by a process into - * GL, graphics, etc. All memory sizes should be in real memory usage, - * accounting for stride, bit depth, rounding up to page size, etc. - * - * A process collecting memory statistics will call getMemory for each - * combination of pid and memory type. For each memory type that it recognizes - * the HAL should fill out an array of memtrack_record structures breaking - * down the statistics of that memory type as much as possible. For example, - * getMemory(, MEMTRACK_TYPE_GL) might return: - * { { 4096, ACCOUNTED | PRIVATE | SYSTEM }, - * { 40960, UNACCOUNTED | PRIVATE | SYSTEM }, - * { 8192, ACCOUNTED | PRIVATE | DEDICATED }, - * { 8192, UNACCOUNTED | PRIVATE | DEDICATED } } - * If the HAL could not differentiate between SYSTEM and DEDICATED memory, it - * could return: - * { { 12288, ACCOUNTED | PRIVATE }, - * { 49152, UNACCOUNTED | PRIVATE } } - * - * Memory should not overlap between types. For example, a graphics buffer - * that has been mapped into the GPU as a surface should show up when - * MEMTRACK_TYPE_GRAPHICS is requested, and not when MEMTRACK_TYPE_GL - * is requested. - */ - -enum memtrack_type { - MEMTRACK_TYPE_OTHER = 0, - MEMTRACK_TYPE_GL = 1, - MEMTRACK_TYPE_GRAPHICS = 2, - MEMTRACK_TYPE_MULTIMEDIA = 3, - MEMTRACK_TYPE_CAMERA = 4, - MEMTRACK_NUM_TYPES, -}; - -struct memtrack_record { - size_t size_in_bytes; - unsigned int flags; -}; - -/** - * Flags to differentiate memory that can already be accounted for in - * /proc//smaps, - * (Shared_Clean + Shared_Dirty + Private_Clean + Private_Dirty = Size). - * In general, memory mapped in to a userspace process is accounted unless - * it was mapped with remap_pfn_range. - * Exactly one of these should be set. - */ -#define MEMTRACK_FLAG_SMAPS_ACCOUNTED (1 << 1) -#define MEMTRACK_FLAG_SMAPS_UNACCOUNTED (1 << 2) - -/** - * Flags to differentiate memory shared across multiple processes vs. memory - * used by a single process. Only zero or one of these may be set in a record. - * If none are set, record is assumed to count shared + private memory. - */ -#define MEMTRACK_FLAG_SHARED (1 << 3) -#define MEMTRACK_FLAG_SHARED_PSS (1 << 4) /* shared / num_procesess */ -#define MEMTRACK_FLAG_PRIVATE (1 << 5) - -/** - * Flags to differentiate memory taken from the kernel's allocation pool vs. - * memory that is dedicated to non-kernel allocations, for example a carveout - * or separate video memory. Only zero or one of these may be set in a record. - * If none are set, record is assumed to count system + dedicated memory. - */ -#define MEMTRACK_FLAG_SYSTEM (1 << 6) -#define MEMTRACK_FLAG_DEDICATED (1 << 7) - -/** - * Flags to differentiate memory accessible by the CPU in non-secure mode vs. - * memory that is protected. Only zero or one of these may be set in a record. - * If none are set, record is assumed to count secure + nonsecure memory. - */ -#define MEMTRACK_FLAG_NONSECURE (1 << 8) -#define MEMTRACK_FLAG_SECURE (1 << 9) - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct memtrack_module { - struct hw_module_t common; - - /** - * (*init)() performs memtrack management setup actions and is called - * once before any calls to getMemory(). - * Returns 0 on success, -errno on error. - */ - int (*init)(const struct memtrack_module *module); - - /** - * (*getMemory)() expects an array of record objects and populates up to - * *num_record structures with the sizes of memory plus associated flags for - * that memory. It also updates *num_records with the total number of - * records it could return if *num_records was large enough when passed in. - * Returning records with size 0 is expected, the number of records should - * not vary between calls to getMemory for the same memory type, even - * for different pids. - * - * The caller will often call getMemory for a type and pid with - * *num_records == 0 to determine how many records to allocate room for, - * this case should be a fast-path in the HAL, returning a constant and - * not querying any kernel files. If *num_records passed in is 0, - * then records may be NULL. - * - * This function must be thread-safe, it may get called from multiple - * threads at the same time. - * - * Returns 0 on success, -ENODEV if the type is not supported, -errno - * on other errors. - */ - int (*getMemory)(const struct memtrack_module *module, - pid_t pid, - int type, - struct memtrack_record *records, - size_t *num_records); -} memtrack_module_t; - -__END_DECLS - -#endif // ANDROID_INCLUDE_HARDWARE_MEMTRACK_H diff --git a/third_party/android_hardware_libhardware/include/hardware/nfc.h b/third_party/android_hardware_libhardware/include/hardware/nfc.h deleted file mode 100644 index 6002e34e8..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/nfc.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 2011, 2012 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. - */ - -#ifndef ANDROID_NFC_HAL_INTERFACE_H -#define ANDROID_NFC_HAL_INTERFACE_H - -#include -#include -#include -#include - -#include - -__BEGIN_DECLS - - -/* NFC device HAL for NCI-based NFC controllers. - * - * This HAL allows NCI silicon vendors to make use - * of the core NCI stack in Android for their own silicon. - * - * The responibilities of the NCI HAL implementation - * are as follows: - * - * - Implement the transport to the NFC controller - * - Implement each of the HAL methods specified below as applicable to their silicon - * - Pass up received NCI messages from the controller to the stack - * - * A simplified timeline of NCI HAL method calls: - * 1) Core NCI stack calls open() - * 2) Core NCI stack executes CORE_RESET and CORE_INIT through calls to write() - * 3) Core NCI stack calls core_initialized() to allow HAL to do post-init configuration - * 4) Core NCI stack calls pre_discover() to allow HAL to prepare for RF discovery - * 5) Core NCI stack starts discovery through calls to write() - * 6) Core NCI stack stops discovery through calls to write() (e.g. screen turns off) - * 7) Core NCI stack calls pre_discover() to prepare for RF discovery (e.g. screen turned back on) - * 8) Core NCI stack starts discovery through calls to write() - * ... - * ... - * 9) Core NCI stack calls close() - */ -#define NFC_NCI_HARDWARE_MODULE_ID "nfc_nci" -#define NFC_NCI_BCM2079X_HARDWARE_MODULE_ID "nfc_nci.bcm2079x" -#define NFC_NCI_NXP_PN54X_HARDWARE_MODULE_ID "nfc_nci.pn54x" -#define NFC_NCI_CONTROLLER "nci" - -/* - * nfc_nci_module_t should contain module-specific parameters - */ -typedef struct nfc_nci_module_t { - /** - * Common methods of the NFC NCI module. This *must* be the first member of - * nfc_nci_module_t as users of this structure will cast a hw_module_t to - * nfc_nci_module_t pointer in contexts where it's known the hw_module_t references a - * nfc_nci_module_t. - */ - struct hw_module_t common; -} nfc_nci_module_t; - -/* - * HAL events that can be passed back to the stack - */ -typedef uint8_t nfc_event_t; - -enum { - HAL_NFC_OPEN_CPLT_EVT = 0x00, - HAL_NFC_CLOSE_CPLT_EVT = 0x01, - HAL_NFC_POST_INIT_CPLT_EVT = 0x02, - HAL_NFC_PRE_DISCOVER_CPLT_EVT = 0x03, - HAL_NFC_REQUEST_CONTROL_EVT = 0x04, - HAL_NFC_RELEASE_CONTROL_EVT = 0x05, - HAL_NFC_ERROR_EVT = 0x06 -}; - -/* - * Allowed status return values for each of the HAL methods - */ -typedef uint8_t nfc_status_t; - -enum { - HAL_NFC_STATUS_OK = 0x00, - HAL_NFC_STATUS_FAILED = 0x01, - HAL_NFC_STATUS_ERR_TRANSPORT = 0x02, - HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 0x03, - HAL_NFC_STATUS_REFUSED = 0x04 -}; - -/* - * The callback passed in from the NFC stack that the HAL - * can use to pass events back to the stack. - */ -typedef void (nfc_stack_callback_t) (nfc_event_t event, nfc_status_t event_status); - -/* - * The callback passed in from the NFC stack that the HAL - * can use to pass incomming data to the stack. - */ -typedef void (nfc_stack_data_callback_t) (uint16_t data_len, uint8_t* p_data); - -/* nfc_nci_device_t starts with a hw_device_t struct, - * followed by device-specific methods and members. - * - * All methods in the NCI HAL are asynchronous. - */ -typedef struct nfc_nci_device { - /** - * Common methods of the NFC NCI device. This *must* be the first member of - * nfc_nci_device_t as users of this structure will cast a hw_device_t to - * nfc_nci_device_t pointer in contexts where it's known the hw_device_t references a - * nfc_nci_device_t. - */ - struct hw_device_t common; - /* - * (*open)() Opens the NFC controller device and performs initialization. - * This may include patch download and other vendor-specific initialization. - * - * If open completes successfully, the controller should be ready to perform - * NCI initialization - ie accept CORE_RESET and subsequent commands through - * the write() call. - * - * If open() returns 0, the NCI stack will wait for a HAL_NFC_OPEN_CPLT_EVT - * before continuing. - * - * If open() returns any other value, the NCI stack will stop. - * - */ - int (*open)(const struct nfc_nci_device *p_dev, nfc_stack_callback_t *p_cback, - nfc_stack_data_callback_t *p_data_cback); - - /* - * (*write)() Performs an NCI write. - * - * This method may queue writes and return immediately. The only - * requirement is that the writes are executed in order. - */ - int (*write)(const struct nfc_nci_device *p_dev, uint16_t data_len, const uint8_t *p_data); - - /* - * (*core_initialized)() is called after the CORE_INIT_RSP is received from the NFCC. - * At this time, the HAL can do any chip-specific configuration. - * - * If core_initialized() returns 0, the NCI stack will wait for a HAL_NFC_POST_INIT_CPLT_EVT - * before continuing. - * - * If core_initialized() returns any other value, the NCI stack will continue - * immediately. - */ - int (*core_initialized)(const struct nfc_nci_device *p_dev, uint8_t* p_core_init_rsp_params); - - /* - * (*pre_discover)() Is called every time before starting RF discovery. - * It is a good place to do vendor-specific configuration that must be - * performed every time RF discovery is about to be started. - * - * If pre_discover() returns 0, the NCI stack will wait for a HAL_NFC_PRE_DISCOVER_CPLT_EVT - * before continuing. - * - * If pre_discover() returns any other value, the NCI stack will start - * RF discovery immediately. - */ - int (*pre_discover)(const struct nfc_nci_device *p_dev); - - /* - * (*close)() Closed the NFC controller. Should free all resources. - */ - int (*close)(const struct nfc_nci_device *p_dev); - - /* - * (*control_granted)() Grant HAL the exclusive control to send NCI commands. - * Called in response to HAL_REQUEST_CONTROL_EVT. - * Must only be called when there are no NCI commands pending. - * HAL_RELEASE_CONTROL_EVT will notify when HAL no longer needs exclusive control. - */ - int (*control_granted)(const struct nfc_nci_device *p_dev); - - /* - * (*power_cycle)() Restart controller by power cyle; - * HAL_OPEN_CPLT_EVT will notify when operation is complete. - */ - int (*power_cycle)(const struct nfc_nci_device *p_dev); -} nfc_nci_device_t; - -/* - * Convenience methods that the NFC stack can use to open - * and close an NCI device - */ -static inline int nfc_nci_open(const struct hw_module_t* module, - nfc_nci_device_t** dev) { - return module->methods->open(module, NFC_NCI_CONTROLLER, - (struct hw_device_t**) dev); -} - -static inline int nfc_nci_close(nfc_nci_device_t* dev) { - return dev->common.close(&dev->common); -} -/* - * End NFC NCI HAL - */ - -/* - * This is a limited NFC HAL for NXP PN544-based devices. - * This HAL as Android is moving to - * an NCI-based NFC stack. - * - * All NCI-based NFC controllers should use the NFC-NCI - * HAL instead. - * Begin PN544 specific HAL - */ -#define NFC_HARDWARE_MODULE_ID "nfc" - -#define NFC_PN544_CONTROLLER "pn544" - -typedef struct nfc_module_t { - /** - * Common methods of the NFC NXP PN544 module. This *must* be the first member of - * nfc_module_t as users of this structure will cast a hw_module_t to - * nfc_module_t pointer in contexts where it's known the hw_module_t references a - * nfc_module_t. - */ - struct hw_module_t common; -} nfc_module_t; - -/* - * PN544 linktypes. - * UART - * I2C - * USB (uses UART DAL) - */ -typedef enum { - PN544_LINK_TYPE_UART, - PN544_LINK_TYPE_I2C, - PN544_LINK_TYPE_USB, - PN544_LINK_TYPE_INVALID, -} nfc_pn544_linktype; - -typedef struct { - /** - * Common methods of the NFC NXP PN544 device. This *must* be the first member of - * nfc_pn544_device_t as users of this structure will cast a hw_device_t to - * nfc_pn544_device_t pointer in contexts where it's known the hw_device_t references a - * nfc_pn544_device_t. - */ - struct hw_device_t common; - - /* The number of EEPROM registers to write */ - uint32_t num_eeprom_settings; - - /* The actual EEPROM settings - * For PN544, each EEPROM setting is a 4-byte entry, - * of the format [0x00, addr_msb, addr_lsb, value]. - */ - uint8_t* eeprom_settings; - - /* The link type to which the PN544 is connected */ - nfc_pn544_linktype linktype; - - /* The device node to which the PN544 is connected */ - const char* device_node; - - /* On Crespo we had an I2C issue that would cause us to sometimes read - * the I2C slave address (0x57) over the bus. libnfc contains - * a hack to ignore this byte and try to read the length byte - * again. - * Set to 0 to disable the workaround, 1 to enable it. - */ - uint8_t enable_i2c_workaround; - /* I2C slave address. Multiple I2C addresses are - * possible for PN544 module. Configure address according to - * board design. - */ - uint8_t i2c_device_address; -} nfc_pn544_device_t; - -static inline int nfc_pn544_open(const struct hw_module_t* module, - nfc_pn544_device_t** dev) { - return module->methods->open(module, NFC_PN544_CONTROLLER, - (struct hw_device_t**) dev); -} - -static inline int nfc_pn544_close(nfc_pn544_device_t* dev) { - return dev->common.close(&dev->common); -} -/* - * End PN544 specific HAL - */ - -__END_DECLS - -#endif // ANDROID_NFC_HAL_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/nfc_tag.h b/third_party/android_hardware_libhardware/include/hardware/nfc_tag.h deleted file mode 100644 index 040a07d8c..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/nfc_tag.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_NFC_TAG_HAL_INTERFACE_H -#define ANDROID_NFC_TAG_HAL_INTERFACE_H - -#include - -#include - -__BEGIN_DECLS - -/* - * HAL for programmable NFC tags. - * - */ - -#define NFC_TAG_HARDWARE_MODULE_ID "nfc_tag" -#define NFC_TAG_ID "tag" - -typedef struct nfc_tag_module_t { - /** - * Common methods of the NFC tag module. This *must* be the first member of - * nfc_tag_module_t as users of this structure will cast a hw_module_t to - * nfc_tag_module_t pointer in contexts where it's known the hw_module_t references a - * nfc_tag_module_t. - */ - struct hw_module_t common; -} nfc_tag_module_t; - -typedef struct nfc_tag_device { - /** - * Common methods of the NFC tag device. This *must* be the first member of - * nfc_tag_device_t as users of this structure will cast a hw_device_t to - * nfc_tag_device_t pointer in contexts where it's known the hw_device_t references a - * nfc_tag_device_t. - */ - struct hw_device_t common; - - /** - * Initialize the NFC tag. - * - * The driver must: - * * Set the static lock bytes to read only - * * Configure the Capability Container to disable write acess - * eg: 0xE1 0x10 0x0F - * - * This function is called once before any calls to setContent(). - * - * Return 0 on success or -errno on error. - */ - int (*init)(const struct nfc_tag_device *dev); - - /** - * Set the NFC tag content. - * - * The driver must write in the data area of the tag starting at - * byte 0 of block 4 and zero the rest of the data area. - * - * Returns 0 on success or -errno on error. - */ - int (*setContent)(const struct nfc_tag_device *dev, const uint8_t *data, size_t len); - - /** - * Returns the memory size of the data area. - */ - int (*getMemorySize)(const struct nfc_tag_device *dev); -} nfc_tag_device_t; - -static inline int nfc_tag_open(const struct hw_module_t* module, - nfc_tag_device_t** dev) { - return module->methods->open(module, NFC_TAG_ID, - (struct hw_device_t**)dev); -} - -static inline int nfc_tag_close(nfc_tag_device_t* dev) { - return dev->common.close(&dev->common); -} - -__END_DECLS - -#endif // ANDROID_NFC_TAG_HAL_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/power.h b/third_party/android_hardware_libhardware/include/hardware/power.h deleted file mode 100644 index 2eb98fe96..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/power.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_POWER_H -#define ANDROID_INCLUDE_HARDWARE_POWER_H - -#include -#include -#include - -#include - -__BEGIN_DECLS - -#define POWER_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) -#define POWER_MODULE_API_VERSION_0_2 HARDWARE_MODULE_API_VERSION(0, 2) -#define POWER_MODULE_API_VERSION_0_3 HARDWARE_MODULE_API_VERSION(0, 3) - -/** - * The id of this module - */ -#define POWER_HARDWARE_MODULE_ID "power" - -/* - * Power hint identifiers passed to (*powerHint) - */ - -typedef enum { - POWER_HINT_VSYNC = 0x00000001, - POWER_HINT_INTERACTION = 0x00000002, - /* DO NOT USE POWER_HINT_VIDEO_ENCODE/_DECODE! They will be removed in - * KLP. - */ - POWER_HINT_VIDEO_ENCODE = 0x00000003, - POWER_HINT_VIDEO_DECODE = 0x00000004, - POWER_HINT_LOW_POWER = 0x00000005, - POWER_HINT_CAM_PREVIEW = 0x00000006, - - POWER_HINT_CPU_BOOST = 0x00000010, - POWER_HINT_LAUNCH_BOOST = 0x00000011, - POWER_HINT_AUDIO = 0x00000020, - POWER_HINT_SET_PROFILE = 0x00000030 - -} power_hint_t; - -typedef enum { - POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001, - POWER_FEATURE_SUPPORTED_PROFILES = 0x00001000 -} feature_t; - -/** - * Process info, passed as an opaque handle when - * using POWER_HINT_LAUNCH_BOOST. - */ -typedef struct launch_boost_info { - pid_t pid; - const char* packageName; -} launch_boost_info_t; - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct power_module { - struct hw_module_t common; - - /* - * (*init)() performs power management setup actions at runtime - * startup, such as to set default cpufreq parameters. This is - * called only by the Power HAL instance loaded by - * PowerManagerService. - */ - void (*init)(struct power_module *module); - - /* - * (*setInteractive)() performs power management actions upon the - * system entering interactive state (that is, the system is awake - * and ready for interaction, often with UI devices such as - * display and touchscreen enabled) or non-interactive state (the - * system appears asleep, display usually turned off). The - * non-interactive state is usually entered after a period of - * inactivity, in order to conserve battery power during - * such inactive periods. - * - * Typical actions are to turn on or off devices and adjust - * cpufreq parameters. This function may also call the - * appropriate interfaces to allow the kernel to suspend the - * system to low-power sleep state when entering non-interactive - * state, and to disallow low-power suspend when the system is in - * interactive state. When low-power suspend state is allowed, the - * kernel may suspend the system whenever no wakelocks are held. - * - * on is non-zero when the system is transitioning to an - * interactive / awake state, and zero when transitioning to a - * non-interactive / asleep state. - * - * This function is called to enter non-interactive state after - * turning off the screen (if present), and called to enter - * interactive state prior to turning on the screen. - */ - void (*setInteractive)(struct power_module *module, int on); - - /* - * (*powerHint) is called to pass hints on power requirements, which - * may result in adjustment of power/performance parameters of the - * cpufreq governor and other controls. The possible hints are: - * - * POWER_HINT_VSYNC - * - * Foreground app has started or stopped requesting a VSYNC pulse - * from SurfaceFlinger. If the app has started requesting VSYNC - * then CPU and GPU load is expected soon, and it may be appropriate - * to raise speeds of CPU, memory bus, etc. The data parameter is - * non-zero to indicate VSYNC pulse is now requested, or zero for - * VSYNC pulse no longer requested. - * - * POWER_HINT_INTERACTION - * - * User is interacting with the device, for example, touchscreen - * events are incoming. CPU and GPU load may be expected soon, - * and it may be appropriate to raise speeds of CPU, memory bus, - * etc. The data parameter is the estimated length of the interaction - * in milliseconds, or 0 if unknown. - * - * POWER_HINT_LOW_POWER - * - * Low power mode is activated or deactivated. Low power mode - * is intended to save battery at the cost of performance. The data - * parameter is non-zero when low power mode is activated, and zero - * when deactivated. - * - * POWER_HINT_CPU_BOOST - * - * An operation is happening where it would be ideal for the CPU to - * be boosted for a specific duration. The data parameter is an - * integer value of the boost duration in microseconds. - * - * A particular platform may choose to ignore any hint. - * - * availability: version 0.2 - * - */ - void (*powerHint)(struct power_module *module, power_hint_t hint, - void *data); - - /* - * (*setFeature) is called to turn on or off a particular feature - * depending on the state parameter. The possible features are: - * - * FEATURE_DOUBLE_TAP_TO_WAKE - * - * Enabling/Disabling this feature will allow/disallow the system - * to wake up by tapping the screen twice. - * - * availability: version 0.3 - * - */ - void (*setFeature)(struct power_module *module, feature_t feature, int state); - - /* - * (*getFeature) is called to get the current value of a particular - * feature or capability from the hardware or PowerHAL - */ - int (*getFeature)(struct power_module *module, feature_t feature); - -} power_module_t; - -__END_DECLS - -#endif // ANDROID_INCLUDE_HARDWARE_POWER_H diff --git a/third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h b/third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h deleted file mode 100644 index 53aec97a0..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/qemu_pipe.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ -#ifndef ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H -#define ANDROID_INCLUDE_HARDWARE_QEMU_PIPE_H - -#include -#include -#include -#include -#include /* for pthread_once() */ -#include -#include -#include -#include - -#ifndef D -# define D(...) do{}while(0) -#endif - -/* Try to open a new Qemu fast-pipe. This function returns a file descriptor - * that can be used to communicate with a named service managed by the - * emulator. - * - * This file descriptor can be used as a standard pipe/socket descriptor. - * - * 'pipeName' is the name of the emulator service you want to connect to. - * E.g. 'opengles' or 'camera'. - * - * On success, return a valid file descriptor - * Returns -1 on error, and errno gives the error code, e.g.: - * - * EINVAL -> unknown/unsupported pipeName - * ENOSYS -> fast pipes not available in this system. - * - * ENOSYS should never happen, except if you're trying to run within a - * misconfigured emulator. - * - * You should be able to open several pipes to the same pipe service, - * except for a few special cases (e.g. GSM modem), where EBUSY will be - * returned if more than one client tries to connect to it. - */ -static __inline__ int -qemu_pipe_open(const char* pipeName) -{ - char buff[256]; - int buffLen; - int fd, ret; - - if (pipeName == NULL || pipeName[0] == '\0') { - errno = EINVAL; - return -1; - } - - snprintf(buff, sizeof buff, "pipe:%s", pipeName); - - fd = open("/dev/qemu_pipe", O_RDWR); - if (fd < 0 && errno == ENOENT) - fd = open("/dev/goldfish_pipe", O_RDWR); - if (fd < 0) { - D("%s: Could not open /dev/qemu_pipe: %s", __FUNCTION__, strerror(errno)); - //errno = ENOSYS; - return -1; - } - - buffLen = strlen(buff); - - ret = TEMP_FAILURE_RETRY(write(fd, buff, buffLen+1)); - if (ret != buffLen+1) { - D("%s: Could not connect to %s pipe service: %s", __FUNCTION__, pipeName, strerror(errno)); - if (ret == 0) { - errno = ECONNRESET; - } else if (ret > 0) { - errno = EINVAL; - } - return -1; - } - - return fd; -} - -#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_PIPE_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/qemud.h b/third_party/android_hardware_libhardware/include/hardware/qemud.h deleted file mode 100644 index 5c39f9c93..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/qemud.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -#ifndef ANDROID_INCLUDE_HARDWARE_QEMUD_H -#define ANDROID_INCLUDE_HARDWARE_QEMUD_H - -#include -#include "qemu_pipe.h" - -/* the following is helper code that is used by the QEMU-specific - * hardware HAL modules to communicate with the emulator program - * through the 'qemud' multiplexing daemon, or through the qemud - * pipe. - * - * see the documentation comments for details in - * development/emulator/qemud/qemud.c - * - * all definitions here are built into the HAL module to avoid - * having to write a tiny shared library for this. - */ - -/* we expect the D macro to be defined to a function macro - * that sends its formatted string argument(s) to the log. - * If not, ignore the traces. - */ -#ifndef D -# define D(...) ((void)0) -#endif - -static __inline__ int -qemud_fd_write(int fd, const void* buff, int len) -{ - int len2; - do { - len2 = write(fd, buff, len); - } while (len2 < 0 && errno == EINTR); - return len2; -} - -static __inline__ int -qemud_fd_read(int fd, void* buff, int len) -{ - int len2; - do { - len2 = read(fd, buff, len); - } while (len2 < 0 && errno == EINTR); - return len2; -} - -static __inline__ int -qemud_channel_open(const char* name) -{ - int fd; - int namelen = strlen(name); - char answer[2]; - char pipe_name[256]; - - /* First, try to connect to the pipe. */ - snprintf(pipe_name, sizeof(pipe_name), "qemud:%s", name); - fd = qemu_pipe_open(pipe_name); - if (fd < 0) { - D("QEMUD pipe is not available for %s: %s", name, strerror(errno)); - /* If pipe is not available, connect to qemud control socket */ - fd = socket_local_client( "qemud", - ANDROID_SOCKET_NAMESPACE_RESERVED, - SOCK_STREAM ); - if (fd < 0) { - D("no qemud control socket: %s", strerror(errno)); - return -1; - } - - /* send service name to connect */ - if (qemud_fd_write(fd, name, namelen) != namelen) { - D("can't send service name to qemud: %s", - strerror(errno)); - close(fd); - return -1; - } - - /* read answer from daemon */ - if (qemud_fd_read(fd, answer, 2) != 2 || - answer[0] != 'O' || answer[1] != 'K') { - D("cant' connect to %s service through qemud", name); - close(fd); - return -1; - } - } - return fd; -} - -static __inline__ int -qemud_channel_send(int fd, const void* msg, int msglen) -{ - char header[5]; - - if (msglen < 0) - msglen = strlen((const char*)msg); - - if (msglen == 0) - return 0; - - snprintf(header, sizeof header, "%04x", msglen); - if (qemud_fd_write(fd, header, 4) != 4) { - D("can't write qemud frame header: %s", strerror(errno)); - return -1; - } - - if (qemud_fd_write(fd, msg, msglen) != msglen) { - D("can4t write qemud frame payload: %s", strerror(errno)); - return -1; - } - return 0; -} - -static __inline__ int -qemud_channel_recv(int fd, void* msg, int msgsize) -{ - char header[5]; - int size, avail; - - if (qemud_fd_read(fd, header, 4) != 4) { - D("can't read qemud frame header: %s", strerror(errno)); - return -1; - } - header[4] = 0; - if (sscanf(header, "%04x", &size) != 1) { - D("malformed qemud frame header: '%.*s'", 4, header); - return -1; - } - if (size > msgsize) - return -1; - - if (qemud_fd_read(fd, msg, size) != size) { - D("can't read qemud frame payload: %s", strerror(errno)); - return -1; - } - return size; -} - -#endif /* ANDROID_INCLUDE_HARDWARE_QEMUD_H */ diff --git a/third_party/android_hardware_libhardware/include/hardware/radio.h b/third_party/android_hardware_libhardware/include/hardware/radio.h deleted file mode 100644 index 145deb573..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/radio.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#include -#include - -#ifndef ANDROID_RADIO_HAL_H -#define ANDROID_RADIO_HAL_H - - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define RADIO_HARDWARE_MODULE_ID "radio" - -/** - * Name of the audio devices to open - */ -#define RADIO_HARDWARE_DEVICE "radio_hw_device" - -#define RADIO_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define RADIO_MODULE_API_VERSION_CURRENT RADIO_MODULE_API_VERSION_1_0 - - -#define RADIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) -#define RADIO_DEVICE_API_VERSION_CURRENT RADIO_DEVICE_API_VERSION_1_0 - -/** - * List of known radio HAL modules. This is the base name of the radio HAL - * library composed of the "radio." prefix, one of the base names below and - * a suffix specific to the device. - * E.g: radio.fm.default.so - */ - -#define RADIO_HARDWARE_MODULE_ID_FM "fm" /* corresponds to RADIO_CLASS_AM_FM */ -#define RADIO_HARDWARE_MODULE_ID_SAT "sat" /* corresponds to RADIO_CLASS_SAT */ -#define RADIO_HARDWARE_MODULE_ID_DT "dt" /* corresponds to RADIO_CLASS_DT */ - - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -struct radio_module { - struct hw_module_t common; -}; - -/* - * Callback function called by the HAL when one of the following occurs: - * - event RADIO_EVENT_HW_FAILURE: radio chip of driver failure requiring - * closing and reopening of the tuner interface. - * - event RADIO_EVENT_CONFIG: new configuration applied in response to open_tuner(), - * or set_configuration(). The event status is 0 (no error) if the configuration has been applied, - * -EINVAL is not or -ETIMEDOUT in case of time out. - * - event RADIO_EVENT_TUNED: tune locked on new station/frequency following scan(), - * step(), tune() or auto AF switching. The event status is 0 (no error) if in tune, - * -EINVAL is not tuned and data in radio_program_info is not valid or -ETIMEDOUT if scan() - * timed out. - * - event RADIO_EVENT_TA: at the beginning and end of traffic announcement if current - * configuration enables TA. - * - event RADIO_EVENT_AF: after automatic switching to alternate frequency if current - * configuration enables AF switching. - * - event RADIO_EVENT_ANTENNA: when the antenna is connected or disconnected. - * - event RADIO_EVENT_METADATA: when new meta data are received from the tuned station. - * The callback MUST NOT be called synchronously while executing a HAL function but from - * a separate thread. - */ -typedef void (*radio_callback_t)(radio_hal_event_t *event, void *cookie); - -/* control interface for a radio tuner */ -struct radio_tuner { - /* - * Apply current radio band configuration (band, range, channel spacing ...). - * - * arguments: - * - config: the band configuration to apply - * - * returns: - * 0 if configuration could be applied - * -EINVAL if configuration requested is invalid - * - * Automatically cancels pending scan, step or tune. - * - * Callback function with event RADIO_EVENT_CONFIG MUST be called once the - * configuration is applied or a failure occurs or after a time out. - */ - int (*set_configuration)(const struct radio_tuner *tuner, - const radio_hal_band_config_t *config); - - /* - * Retrieve current radio band configuration. - * - * arguments: - * - config: where to return the band configuration - * - * returns: - * 0 if valid configuration is returned - * -EINVAL if invalid arguments are passed - */ - int (*get_configuration)(const struct radio_tuner *tuner, - radio_hal_band_config_t *config); - - /* - * Start scanning up to next valid station. - * Must be called when a valid configuration has been applied. - * - * arguments: - * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN - * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels - * (e.g SPS for HD radio). - * - * returns: - * 0 if scan successfully started - * -ENOSYS if called out of sequence - * -ENODEV if another error occurs - * - * Automatically cancels pending scan, step or tune. - * - * Callback function with event RADIO_EVENT_TUNED MUST be called once - * locked on a station or after a time out or full frequency scan if - * no station found. The event status should indicate if a valid station - * is tuned or not. - */ - int (*scan)(const struct radio_tuner *tuner, - radio_direction_t direction, bool skip_sub_channel); - - /* - * Move one channel spacing up or down. - * Must be called when a valid configuration has been applied. - * - * arguments: - * - direction: RADIO_DIRECTION_UP or RADIO_DIRECTION_DOWN - * - skip_sub_channel: valid for HD radio or digital radios only: ignore sub channels - * (e.g SPS for HD radio). - * - * returns: - * 0 if step successfully started - * -ENOSYS if called out of sequence - * -ENODEV if another error occurs - * - * Automatically cancels pending scan, step or tune. - * - * Callback function with event RADIO_EVENT_TUNED MUST be called once - * step completed or after a time out. The event status should indicate - * if a valid station is tuned or not. - */ - int (*step)(const struct radio_tuner *tuner, - radio_direction_t direction, bool skip_sub_channel); - - /* - * Tune to specified frequency. - * Must be called when a valid configuration has been applied. - * - * arguments: - * - channel: channel to tune to. A frequency in kHz for AM/FM/HD Radio bands. - * - sub_channel: valid for HD radio or digital radios only: (e.g SPS number for HD radio). - * - * returns: - * 0 if tune successfully started - * -ENOSYS if called out of sequence - * -EINVAL if invalid arguments are passed - * -ENODEV if another error occurs - * - * Automatically cancels pending scan, step or tune. - * - * Callback function with event RADIO_EVENT_TUNED MUST be called once - * tuned or after a time out. The event status should indicate - * if a valid station is tuned or not. - */ - int (*tune)(const struct radio_tuner *tuner, - unsigned int channel, unsigned int sub_channel); - - /* - * Cancel a scan, step or tune operation. - * Must be called while a scan, step or tune operation is pending - * (callback not yet sent). - * - * returns: - * 0 if successful - * -ENOSYS if called out of sequence - * -ENODEV if another error occurs - * - * The callback is not sent. - */ - int (*cancel)(const struct radio_tuner *tuner); - - /* - * Retrieve current station information. - * - * arguments: - * - info: where to return the program info. - * If info->metadata is NULL. no meta data should be returned. - * If meta data must be returned, they should be added to or cloned to - * info->metadata, not passed from a newly created meta data buffer. - * - * returns: - * 0 if tuned and information available - * -EINVAL if invalid arguments are passed - * -ENODEV if another error occurs - */ - int (*get_program_information)(const struct radio_tuner *tuner, - radio_program_info_t *info); -}; - -struct radio_hw_device { - struct hw_device_t common; - - /* - * Retrieve implementation properties. - * - * arguments: - * - properties: where to return the module properties - * - * returns: - * 0 if no error - * -EINVAL if invalid arguments are passed - */ - int (*get_properties)(const struct radio_hw_device *dev, - radio_hal_properties_t *properties); - - /* - * Open a tuner interface for the requested configuration. - * If no other tuner is opened, this will activate the radio module. - * - * arguments: - * - config: the band configuration to apply - * - audio: this tuner will be used for live radio listening and should be connected to - * the radio audio source. - * - callback: the event callback - * - cookie: the cookie to pass when calling the callback - * - tuner: where to return the tuner interface - * - * returns: - * 0 if HW was powered up and configuration could be applied - * -EINVAL if configuration requested is invalid - * -ENOSYS if called out of sequence - * - * Callback function with event RADIO_EVENT_CONFIG MUST be called once the - * configuration is applied or a failure occurs or after a time out. - */ - int (*open_tuner)(const struct radio_hw_device *dev, - const radio_hal_band_config_t *config, - bool audio, - radio_callback_t callback, - void *cookie, - const struct radio_tuner **tuner); - - /* - * Close a tuner interface. - * If the last tuner is closed, the radio module is deactivated. - * - * arguments: - * - tuner: the tuner interface to close - * - * returns: - * 0 if powered down successfully. - * -EINVAL if an invalid argument is passed - * -ENOSYS if called out of sequence - */ - int (*close_tuner)(const struct radio_hw_device *dev, const struct radio_tuner *tuner); - -}; - -typedef struct radio_hw_device radio_hw_device_t; - -/** convenience API for opening and closing a supported device */ - -static inline int radio_hw_device_open(const struct hw_module_t* module, - struct radio_hw_device** device) -{ - return module->methods->open(module, RADIO_HARDWARE_DEVICE, - (struct hw_device_t**)device); -} - -static inline int radio_hw_device_close(const struct radio_hw_device* device) -{ - return device->common.close((struct hw_device_t *)&device->common); -} - -__END_DECLS - -#endif // ANDROID_RADIO_HAL_H diff --git a/third_party/android_hardware_libhardware/include/hardware/sensors.h b/third_party/android_hardware_libhardware/include/hardware/sensors.h deleted file mode 100644 index 51bffe119..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/sensors.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_SENSORS_INTERFACE_H -#define ANDROID_SENSORS_INTERFACE_H - -#include -#include -#include - -#include -#include - -__BEGIN_DECLS - -/*****************************************************************************/ - -#define SENSORS_HEADER_VERSION 1 -#define SENSORS_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) -#define SENSORS_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION_2(1, 1, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION_2(1, 2, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION_2(1, 3, SENSORS_HEADER_VERSION) -#define SENSORS_DEVICE_API_VERSION_1_4 HARDWARE_DEVICE_API_VERSION_2(1, 4, SENSORS_HEADER_VERSION) - -/** - * Please see the Sensors section of source.android.com for an - * introduction to and detailed descriptions of Android sensor types: - * http://source.android.com/devices/sensors/index.html - */ - -/** - * The id of this module - */ -#define SENSORS_HARDWARE_MODULE_ID "sensors" - -/** - * Name of the sensors device to open - */ -#define SENSORS_HARDWARE_POLL "poll" - -/** - * Handles must be higher than SENSORS_HANDLE_BASE and must be unique. - * A Handle identifies a given sensors. The handle is used to activate - * and/or deactivate sensors. - * In this version of the API there can only be 256 handles. - */ -#define SENSORS_HANDLE_BASE 0 -#define SENSORS_HANDLE_BITS 8 -#define SENSORS_HANDLE_COUNT (1< 35 degrees - * - * Large accelerations without a change in phone orientation should not trigger a tilt event. - * For example, a sharp turn or strong acceleration while driving a car should not trigger a tilt - * event, even though the angle of the average acceleration might vary by more than 35 degrees. - * - * Typically, this sensor is implemented with the help of only an accelerometer. Other sensors can - * be used as well if they do not increase the power consumption significantly. This is a low power - * sensor that should allow the AP to go into suspend mode. Do not emulate this sensor in the HAL. - * Like other wake up sensors, the driver is expected to a hold a wake_lock with a timeout of 200 ms - * while reporting this event. The only allowed return value is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_TILT_DETECTOR (22) -#define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector" - -/* - * SENSOR_TYPE_WAKE_GESTURE - * reporting-mode: one-shot - * - * A sensor enabling waking up the device based on a device specific motion. - * - * When this sensor triggers, the device behaves as if the power button was - * pressed, turning the screen on. This behavior (turning on the screen when - * this sensor triggers) might be deactivated by the user in the device - * settings. Changes in settings do not impact the behavior of the sensor: - * only whether the framework turns the screen on when it triggers. - * - * The actual gesture to be detected is not specified, and can be chosen by - * the manufacturer of the device. - * This sensor must be low power, as it is likely to be activated 24/7. - * The only allowed value to return is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_WAKE_GESTURE (23) -#define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture" - -/* - * SENSOR_TYPE_GLANCE_GESTURE - * reporting-mode: one-shot - * - * A sensor enabling briefly turning the screen on to enable the user to - * glance content on screen based on a specific motion. The device should - * turn the screen off after a few moments. - * - * When this sensor triggers, the device turns the screen on momentarily - * to allow the user to glance notifications or other content while the - * device remains locked in a non-interactive state (dozing). This behavior - * (briefly turning on the screen when this sensor triggers) might be deactivated - * by the user in the device settings. Changes in settings do not impact the - * behavior of the sensor: only whether the framework briefly turns the screen on - * when it triggers. - * - * The actual gesture to be detected is not specified, and can be chosen by - * the manufacturer of the device. - * This sensor must be low power, as it is likely to be activated 24/7. - * The only allowed value to return is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_GLANCE_GESTURE (24) -#define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture" - -/** - * SENSOR_TYPE_PICK_UP_GESTURE - * reporting-mode: one-shot - * - * A sensor of this type triggers when the device is picked up regardless of wherever is was - * before (desk, pocket, bag). The only allowed return value is 1.0. - * This sensor de-activates itself immediately after it triggers. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_PICK_UP_GESTURE (25) -#define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture" - -/* - * SENSOR_TYPE_WRIST_TILT_GESTURE - * trigger-mode: special - * wake-up sensor: yes - * - * A sensor of this type triggers an event each time a tilt of the wrist-worn - * device is detected. - * - * This sensor must be low power, as it is likely to be activated 24/7. - * The only allowed value to return is 1.0. - * - * Implement only the wake-up version of this sensor. - */ -#define SENSOR_TYPE_WRIST_TILT_GESTURE (26) -#define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE "android.sensor.wrist_tilt_gesture" - -/** - * Values returned by the accelerometer in various locations in the universe. - * all values are in SI units (m/s^2) - */ -#define GRAVITY_SUN (275.0f) -#define GRAVITY_EARTH (9.80665f) - -/** Maximum magnetic field on Earth's surface */ -#define MAGNETIC_FIELD_EARTH_MAX (60.0f) - -/** Minimum magnetic field on Earth's surface */ -#define MAGNETIC_FIELD_EARTH_MIN (30.0f) - -/** - * Possible values of the status field of sensor events. - */ -#define SENSOR_STATUS_NO_CONTACT -1 -#define SENSOR_STATUS_UNRELIABLE 0 -#define SENSOR_STATUS_ACCURACY_LOW 1 -#define SENSOR_STATUS_ACCURACY_MEDIUM 2 -#define SENSOR_STATUS_ACCURACY_HIGH 3 - -/** - * sensor event data - */ -typedef struct { - union { - float v[3]; - struct { - float x; - float y; - float z; - }; - struct { - float azimuth; - float pitch; - float roll; - }; - }; - int8_t status; - uint8_t reserved[3]; -} sensors_vec_t; - -/** - * uncalibrated gyroscope and magnetometer event data - */ -typedef struct { - union { - float uncalib[3]; - struct { - float x_uncalib; - float y_uncalib; - float z_uncalib; - }; - }; - union { - float bias[3]; - struct { - float x_bias; - float y_bias; - float z_bias; - }; - }; -} uncalibrated_event_t; - -/** - * Meta data event data - */ -typedef struct meta_data_event { - int32_t what; - int32_t sensor; -} meta_data_event_t; - -/** - * Heart rate event data - */ -typedef struct { - // Heart rate in beats per minute. - // Set to 0 when status is SENSOR_STATUS_UNRELIABLE or ..._NO_CONTACT - float bpm; - // Status of the sensor for this reading. Set to one SENSOR_STATUS_... - // Note that this value should only be set for sensors that explicitly define - // the meaning of this field. This field is not piped through the framework - // for other sensors. - int8_t status; -} heart_rate_event_t; - -/** - * Union of the various types of sensor data - * that can be returned. - */ -typedef struct sensors_event_t { - /* must be sizeof(struct sensors_event_t) */ - int32_t version; - - /* sensor identifier */ - int32_t sensor; - - /* sensor type */ - int32_t type; - - /* reserved */ - int32_t reserved0; - - /* time is in nanosecond */ - int64_t timestamp; - - union { - union { - float data[16]; - - /* acceleration values are in meter per second per second (m/s^2) */ - sensors_vec_t acceleration; - - /* magnetic vector values are in micro-Tesla (uT) */ - sensors_vec_t magnetic; - - /* orientation values are in degrees */ - sensors_vec_t orientation; - - /* gyroscope values are in rad/s */ - sensors_vec_t gyro; - - /* temperature is in degrees centigrade (Celsius) */ - float temperature; - - /* distance in centimeters */ - float distance; - - /* light in SI lux units */ - float light; - - /* pressure in hectopascal (hPa) */ - float pressure; - - /* relative humidity in percent */ - float relative_humidity; - - /* uncalibrated gyroscope values are in rad/s */ - uncalibrated_event_t uncalibrated_gyro; - - /* uncalibrated magnetometer values are in micro-Teslas */ - uncalibrated_event_t uncalibrated_magnetic; - - /* heart rate data containing value in bpm and status */ - heart_rate_event_t heart_rate; - - /* this is a special event. see SENSOR_TYPE_META_DATA above. - * sensors_meta_data_event_t events are all reported with a type of - * SENSOR_TYPE_META_DATA. The handle is ignored and must be zero. - */ - meta_data_event_t meta_data; - }; - - union { - uint64_t data[8]; - - /* step-counter */ - uint64_t step_counter; - } u64; - }; - - /* Reserved flags for internal use. Set to zero. */ - uint32_t flags; - - uint32_t reserved1[3]; -} sensors_event_t; - - -/* see SENSOR_TYPE_META_DATA */ -typedef sensors_event_t sensors_meta_data_event_t; - - -struct sensor_t; - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -struct sensors_module_t { - struct hw_module_t common; - - /** - * Enumerate all available sensors. The list is returned in "list". - * @return number of sensors in the list - */ - int (*get_sensors_list)(struct sensors_module_t* module, - struct sensor_t const** list); - - /** - * Place the module in a specific mode. The following modes are defined - * - * 0 - Normal operation. Default state of the module. - * 1 - Loopback mode. Data is injected for the the supported - * sensors by the sensor service in this mode. - * @return 0 on success - * -EINVAL if requested mode is not supported - * -EPERM if operation is not allowed - */ - int (*set_operation_mode)(unsigned int mode); -}; - -struct sensor_t { - - /* Name of this sensor. - * All sensors of the same "type" must have a different "name". - */ - const char* name; - - /* vendor of the hardware part */ - const char* vendor; - - /* version of the hardware part + driver. The value of this field - * must increase when the driver is updated in a way that changes the - * output of this sensor. This is important for fused sensors when the - * fusion algorithm is updated. - */ - int version; - - /* handle that identifies this sensors. This handle is used to reference - * this sensor throughout the HAL API. - */ - int handle; - - /* this sensor's type. */ - int type; - - /* maximum range of this sensor's value in SI units */ - float maxRange; - - /* smallest difference between two values reported by this sensor */ - float resolution; - - /* rough estimate of this sensor's power consumption in mA */ - float power; - - /* this value depends on the reporting mode: - * - * continuous: minimum sample period allowed in microseconds - * on-change : 0 - * one-shot :-1 - * special : 0, unless otherwise noted - */ - int32_t minDelay; - - /* number of events reserved for this sensor in the batch mode FIFO. - * If there is a dedicated FIFO for this sensor, then this is the - * size of this FIFO. If the FIFO is shared with other sensors, - * this is the size reserved for that sensor and it can be zero. - */ - uint32_t fifoReservedEventCount; - - /* maximum number of events of this sensor that could be batched. - * This is especially relevant when the FIFO is shared between - * several sensors; this value is then set to the size of that FIFO. - */ - uint32_t fifoMaxEventCount; - - /* type of this sensor as a string. Set to corresponding - * SENSOR_STRING_TYPE_*. - * When defining an OEM specific sensor or sensor manufacturer specific - * sensor, use your reserve domain name as a prefix. - * ex: com.google.glass.onheaddetector - * For sensors of known type, the android framework might overwrite this - * string automatically. - */ - const char* stringType; - - /* permission required to see this sensor, register to it and receive data. - * Set to "" if no permission is required. Some sensor types like the - * heart rate monitor have a mandatory require_permission. - * For sensors that always require a specific permission, like the heart - * rate monitor, the android framework might overwrite this string - * automatically. - */ - const char* requiredPermission; - - /* This value is defined only for continuous mode and on-change sensors. It is the delay between - * two sensor events corresponding to the lowest frequency that this sensor supports. When lower - * frequencies are requested through batch()/setDelay() the events will be generated at this - * frequency instead. It can be used by the framework or applications to estimate when the batch - * FIFO may be full. - * - * NOTE: 1) period_ns is in nanoseconds where as maxDelay/minDelay are in microseconds. - * continuous, on-change: maximum sampling period allowed in microseconds. - * one-shot, special : 0 - * 2) maxDelay should always fit within a 32 bit signed integer. It is declared as 64 bit - * on 64 bit architectures only for binary compatibility reasons. - * Availability: SENSORS_DEVICE_API_VERSION_1_3 - */ - #ifdef __LP64__ - int64_t maxDelay; - #else - int32_t maxDelay; - #endif - - /* Flags for sensor. See SENSOR_FLAG_* above. Only the least significant 32 bits are used here. - * It is declared as 64 bit on 64 bit architectures only for binary compatibility reasons. - * Availability: SENSORS_DEVICE_API_VERSION_1_3 - */ - #ifdef __LP64__ - uint64_t flags; - #else - uint32_t flags; - #endif - - /* reserved fields, must be zero */ - void* reserved[2]; -}; - - -/* - * sensors_poll_device_t is used with SENSORS_DEVICE_API_VERSION_0_1 - * and is present for backward binary and source compatibility. - * See the Sensors HAL interface section for complete descriptions of the - * following functions: - * http://source.android.com/devices/sensors/index.html#hal - */ -struct sensors_poll_device_t { - struct hw_device_t common; - int (*activate)(struct sensors_poll_device_t *dev, - int sensor_handle, int enabled); - int (*setDelay)(struct sensors_poll_device_t *dev, - int sensor_handle, int64_t sampling_period_ns); - int (*poll)(struct sensors_poll_device_t *dev, - sensors_event_t* data, int count); -}; - -/* - * struct sensors_poll_device_1 is used in HAL versions >= SENSORS_DEVICE_API_VERSION_1_0 - */ -typedef struct sensors_poll_device_1 { - union { - /* sensors_poll_device_1 is compatible with sensors_poll_device_t, - * and can be down-cast to it - */ - struct sensors_poll_device_t v0; - - struct { - struct hw_device_t common; - - /* Activate/de-activate one sensor. Return 0 on success, negative - * - * sensor_handle is the handle of the sensor to change. - * enabled set to 1 to enable, or 0 to disable the sensor. - * - * Return 0 on success, negative errno code otherwise. - */ - int (*activate)(struct sensors_poll_device_t *dev, - int sensor_handle, int enabled); - - /** - * Set the events's period in nanoseconds for a given sensor. - * If sampling_period_ns > max_delay it will be truncated to - * max_delay and if sampling_period_ns < min_delay it will be - * replaced by min_delay. - */ - int (*setDelay)(struct sensors_poll_device_t *dev, - int sensor_handle, int64_t sampling_period_ns); - - /** - * Returns an array of sensor data. - */ - int (*poll)(struct sensors_poll_device_t *dev, - sensors_event_t* data, int count); - }; - }; - - - /* - * Sets a sensor’s parameters, including sampling frequency and maximum - * report latency. This function can be called while the sensor is - * activated, in which case it must not cause any sensor measurements to - * be lost: transitioning from one sampling rate to the other cannot cause - * lost events, nor can transitioning from a high maximum report latency to - * a low maximum report latency. - * See the Batching sensor results page for details: - * http://source.android.com/devices/sensors/batching.html - */ - int (*batch)(struct sensors_poll_device_1* dev, - int sensor_handle, int flags, int64_t sampling_period_ns, - int64_t max_report_latency_ns); - - /* - * Flush adds a META_DATA_FLUSH_COMPLETE event (sensors_event_meta_data_t) - * to the end of the "batch mode" FIFO for the specified sensor and flushes - * the FIFO. - * If the FIFO is empty or if the sensor doesn't support batching (FIFO size zero), - * it should return SUCCESS along with a trivial META_DATA_FLUSH_COMPLETE event added to the - * event stream. This applies to all sensors other than one-shot sensors. - * If the sensor is a one-shot sensor, flush must return -EINVAL and not generate - * any flush complete metadata. - * If the sensor is not active at the time flush() is called, flush() should return - * -EINVAL. - */ - int (*flush)(struct sensors_poll_device_1* dev, int sensor_handle); - - /* - * Inject a single sensor sample to be to this device. - * data points to the sensor event to be injected - * @return 0 on success - * -EPERM if operation is not allowed - * -EINVAL if sensor event cannot be injected - */ - int (*inject_sensor_data)(struct sensors_poll_device_1 *dev, const sensors_event_t *data); - - void (*reserved_procs[7])(void); - -} sensors_poll_device_1_t; - - -/** convenience API for opening and closing a device */ - -static inline int sensors_open(const struct hw_module_t* module, - struct sensors_poll_device_t** device) { - return module->methods->open(module, - SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); -} - -static inline int sensors_close(struct sensors_poll_device_t* device) { - return device->common.close(&device->common); -} - -static inline int sensors_open_1(const struct hw_module_t* module, - sensors_poll_device_1_t** device) { - return module->methods->open(module, - SENSORS_HARDWARE_POLL, (struct hw_device_t**)device); -} - -static inline int sensors_close_1(sensors_poll_device_1_t* device) { - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_SENSORS_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/sound_trigger.h b/third_party/android_hardware_libhardware/include/hardware/sound_trigger.h deleted file mode 100644 index 2a8db87ca..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/sound_trigger.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -#include -#include -#include - -#ifndef ANDROID_SOUND_TRIGGER_HAL_H -#define ANDROID_SOUND_TRIGGER_HAL_H - - -__BEGIN_DECLS - -/** - * The id of this module - */ -#define SOUND_TRIGGER_HARDWARE_MODULE_ID "sound_trigger" - -/** - * Name of the audio devices to open - */ -#define SOUND_TRIGGER_HARDWARE_INTERFACE "sound_trigger_hw_if" - -#define SOUND_TRIGGER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0) -#define SOUND_TRIGGER_MODULE_API_VERSION_CURRENT SOUND_TRIGGER_MODULE_API_VERSION_1_0 - - -#define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) -#define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_0 - -/** - * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL - * library composed of the "sound_trigger." prefix, one of the base names below and - * a suffix specific to the device. - * e.g: sondtrigger.primary.goldfish.so or sound_trigger.primary.default.so - */ - -#define SOUND_TRIGGER_HARDWARE_MODULE_ID_PRIMARY "primary" - - -/** - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -struct sound_trigger_module { - struct hw_module_t common; -}; - -typedef void (*recognition_callback_t)(struct sound_trigger_recognition_event *event, void *cookie); -typedef void (*sound_model_callback_t)(struct sound_trigger_model_event *event, void *cookie); - -struct sound_trigger_hw_device { - struct hw_device_t common; - - /* - * Retrieve implementation properties. - */ - int (*get_properties)(const struct sound_trigger_hw_device *dev, - struct sound_trigger_properties *properties); - - /* - * Load a sound model. Once loaded, recognition of this model can be started and stopped. - * Only one active recognition per model at a time. The SoundTrigger service will handle - * concurrent recognition requests by different users/applications on the same model. - * The implementation returns a unique handle used by other functions (unload_sound_model(), - * start_recognition(), etc... - */ - int (*load_sound_model)(const struct sound_trigger_hw_device *dev, - struct sound_trigger_sound_model *sound_model, - sound_model_callback_t callback, - void *cookie, - sound_model_handle_t *handle); - - /* - * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome - * implementation limitations. - */ - int (*unload_sound_model)(const struct sound_trigger_hw_device *dev, - sound_model_handle_t handle); - - /* Start recognition on a given model. Only one recognition active at a time per model. - * Once recognition succeeds of fails, the callback is called. - * TODO: group recognition configuration parameters into one struct and add key phrase options. - */ - int (*start_recognition)(const struct sound_trigger_hw_device *dev, - sound_model_handle_t sound_model_handle, - const struct sound_trigger_recognition_config *config, - recognition_callback_t callback, - void *cookie); - - /* Stop recognition on a given model. - * The implementation does not have to call the callback when stopped via this method. - */ - int (*stop_recognition)(const struct sound_trigger_hw_device *dev, - sound_model_handle_t sound_model_handle); -}; - -typedef struct sound_trigger_hw_device sound_trigger_hw_device_t; - -/** convenience API for opening and closing a supported device */ - -static inline int sound_trigger_hw_device_open(const struct hw_module_t* module, - struct sound_trigger_hw_device** device) -{ - return module->methods->open(module, SOUND_TRIGGER_HARDWARE_INTERFACE, - (struct hw_device_t**)device); -} - -static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) -{ - return device->common.close(&device->common); -} - -__END_DECLS - -#endif // ANDROID_SOUND_TRIGGER_HAL_H diff --git a/third_party/android_hardware_libhardware/include/hardware/tv_input.h b/third_party/android_hardware_libhardware/include/hardware/tv_input.h deleted file mode 100644 index 456b06e1f..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/tv_input.h +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright 2014 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. - */ - -#ifndef ANDROID_TV_INPUT_INTERFACE_H -#define ANDROID_TV_INPUT_INTERFACE_H - -#include -#include -#include - -#include -#include -#include - -__BEGIN_DECLS - -/* - * Module versioning information for the TV input hardware module, based on - * tv_input_module_t.common.module_api_version. - * - * Version History: - * - * TV_INPUT_MODULE_API_VERSION_0_1: - * Initial TV input hardware module API. - * - */ - -#define TV_INPUT_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) - -#define TV_INPUT_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1) - -/* - * The id of this module - */ -#define TV_INPUT_HARDWARE_MODULE_ID "tv_input" - -#define TV_INPUT_DEFAULT_DEVICE "default" - -/*****************************************************************************/ - -/* - * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM - * and the fields of this data structure must begin with hw_module_t - * followed by module specific information. - */ -typedef struct tv_input_module { - struct hw_module_t common; -} tv_input_module_t; - -/*****************************************************************************/ - -enum { - /* Generic hardware. */ - TV_INPUT_TYPE_OTHER_HARDWARE = 1, - /* Tuner. (e.g. built-in terrestrial tuner) */ - TV_INPUT_TYPE_TUNER = 2, - TV_INPUT_TYPE_COMPOSITE = 3, - TV_INPUT_TYPE_SVIDEO = 4, - TV_INPUT_TYPE_SCART = 5, - TV_INPUT_TYPE_COMPONENT = 6, - TV_INPUT_TYPE_VGA = 7, - TV_INPUT_TYPE_DVI = 8, - /* Physical HDMI port. (e.g. HDMI 1) */ - TV_INPUT_TYPE_HDMI = 9, - TV_INPUT_TYPE_DISPLAY_PORT = 10, -}; -typedef uint32_t tv_input_type_t; - -typedef struct tv_input_device_info { - /* Device ID */ - int device_id; - - /* Type of physical TV input. */ - tv_input_type_t type; - - union { - struct { - /* HDMI port ID number */ - uint32_t port_id; - } hdmi; - - /* TODO: add other type specific information. */ - - int32_t type_info_reserved[16]; - }; - - /* TODO: Add capability if necessary. */ - - /* - * Audio info - * - * audio_type == AUDIO_DEVICE_NONE if this input has no audio. - */ - audio_devices_t audio_type; - const char* audio_address; - - int32_t reserved[16]; -} tv_input_device_info_t; - -/* See tv_input_event_t for more details. */ -enum { - /* - * Hardware notifies the framework that a device is available. - * - * Note that DEVICE_AVAILABLE and DEVICE_UNAVAILABLE events do not represent - * hotplug events (i.e. plugging cable into or out of the physical port). - * These events notify the framework whether the port is available or not. - * For a concrete example, when a user plugs in or pulls out the HDMI cable - * from a HDMI port, it does not generate DEVICE_AVAILABLE and/or - * DEVICE_UNAVAILABLE events. However, if a user inserts a pluggable USB - * tuner into the Android device, it will generate a DEVICE_AVAILABLE event - * and when the port is removed, it should generate a DEVICE_UNAVAILABLE - * event. - * - * For hotplug events, please see STREAM_CONFIGURATION_CHANGED for more - * details. - * - * HAL implementation should register devices by using this event when the - * device boots up. The framework will recognize device reported via this - * event only. In addition, the implementation could use this event to - * notify the framework that a removable TV input device (such as USB tuner - * as stated in the example above) is attached. - */ - TV_INPUT_EVENT_DEVICE_AVAILABLE = 1, - /* - * Hardware notifies the framework that a device is unavailable. - * - * HAL implementation should generate this event when a device registered - * by TV_INPUT_EVENT_DEVICE_AVAILABLE is no longer available. For example, - * the event can indicate that a USB tuner is plugged out from the Android - * device. - * - * Note that this event is not for indicating cable plugged out of the port; - * for that purpose, the implementation should use - * STREAM_CONFIGURATION_CHANGED event. This event represents the port itself - * being no longer available. - */ - TV_INPUT_EVENT_DEVICE_UNAVAILABLE = 2, - /* - * Stream configurations are changed. Client should regard all open streams - * at the specific device are closed, and should call - * get_stream_configurations() again, opening some of them if necessary. - * - * HAL implementation should generate this event when the available stream - * configurations change for any reason. A typical use case of this event - * would be to notify the framework that the input signal has changed - * resolution, or that the cable is plugged out so that the number of - * available streams is 0. - * - * The implementation may use this event to indicate hotplug status of the - * port. the framework regards input devices with no available streams as - * disconnected, so the implementation can generate this event with no - * available streams to indicate that this device is disconnected, and vice - * versa. - */ - TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED = 3, - /* - * Hardware is done with capture request with the buffer. Client can assume - * ownership of the buffer again. - * - * HAL implementation should generate this event after request_capture() if - * it succeeded. The event shall have the buffer with the captured image. - */ - TV_INPUT_EVENT_CAPTURE_SUCCEEDED = 4, - /* - * Hardware met a failure while processing a capture request or client - * canceled the request. Client can assume ownership of the buffer again. - * - * The event is similar to TV_INPUT_EVENT_CAPTURE_SUCCEEDED, but HAL - * implementation generates this event upon a failure to process - * request_capture(), or a request cancellation. - */ - TV_INPUT_EVENT_CAPTURE_FAILED = 5, -}; -typedef uint32_t tv_input_event_type_t; - -typedef struct tv_input_capture_result { - /* Device ID */ - int device_id; - - /* Stream ID */ - int stream_id; - - /* Sequence number of the request */ - uint32_t seq; - - /* - * The buffer passed to hardware in request_capture(). The content of - * buffer is undefined (although buffer itself is valid) for - * TV_INPUT_CAPTURE_FAILED event. - */ - buffer_handle_t buffer; - - /* - * Error code for the request. -ECANCELED if request is cancelled; other - * error codes are unknown errors. - */ - int error_code; -} tv_input_capture_result_t; - -typedef struct tv_input_event { - tv_input_event_type_t type; - - union { - /* - * TV_INPUT_EVENT_DEVICE_AVAILABLE: all fields are relevant - * TV_INPUT_EVENT_DEVICE_UNAVAILABLE: only device_id is relevant - * TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED: only device_id is - * relevant - */ - tv_input_device_info_t device_info; - /* - * TV_INPUT_EVENT_CAPTURE_SUCCEEDED: error_code is not relevant - * TV_INPUT_EVENT_CAPTURE_FAILED: all fields are relevant - */ - tv_input_capture_result_t capture_result; - }; -} tv_input_event_t; - -typedef struct tv_input_callback_ops { - /* - * event contains the type of the event and additional data if necessary. - * The event object is guaranteed to be valid only for the duration of the - * call. - * - * data is an object supplied at device initialization, opaque to the - * hardware. -     */ - void (*notify)(struct tv_input_device* dev, - tv_input_event_t* event, void* data); -} tv_input_callback_ops_t; - -enum { - TV_STREAM_TYPE_INDEPENDENT_VIDEO_SOURCE = 1, - TV_STREAM_TYPE_BUFFER_PRODUCER = 2, -}; -typedef uint32_t tv_stream_type_t; - -typedef struct tv_stream_config { - /* - * ID number of the stream. This value is used to identify the whole stream - * configuration. - */ - int stream_id; - - /* Type of the stream */ - tv_stream_type_t type; - - /* Max width/height of the stream. */ - uint32_t max_video_width; - uint32_t max_video_height; -} tv_stream_config_t; - -typedef struct buffer_producer_stream { - /* - * IN/OUT: Width / height of the stream. Client may request for specific - * size but hardware may change it. Client must allocate buffers with - * specified width and height. - */ - uint32_t width; - uint32_t height; - - /* OUT: Client must set this usage when allocating buffer. */ - uint32_t usage; - - /* OUT: Client must allocate a buffer with this format. */ - uint32_t format; - - /* OUT: Client must allocate buffers based on this count. */ - uint32_t buffer_count; -} buffer_producer_stream_t; - -typedef struct tv_stream { - /* IN: ID in the stream configuration */ - int stream_id; - - /* OUT: Type of the stream (for convenience) */ - tv_stream_type_t type; - - /* Data associated with the stream for client's use */ - union { - /* OUT: A native handle describing the sideband stream source */ - native_handle_t* sideband_stream_source_handle; - - /* IN/OUT: Details are in buffer_producer_stream_t */ - buffer_producer_stream_t buffer_producer; - }; -} tv_stream_t; - -/* - * Every device data structure must begin with hw_device_t - * followed by module specific public methods and attributes. - */ -typedef struct tv_input_device { - struct hw_device_t common; - - /* - * initialize: - * - * Provide callbacks to the device and start operation. At first, no device - * is available and after initialize() completes, currently available - * devices including static devices should notify via callback. - * - * Framework owns callbacks object. - * - * data is a framework-owned object which would be sent back to the - * framework for each callback notifications. - * - * Return 0 on success. - */ - int (*initialize)(struct tv_input_device* dev, - const tv_input_callback_ops_t* callback, void* data); - - /* - * get_stream_configurations: - * - * Get stream configurations for a specific device. An input device may have - * multiple configurations. - * - * The configs object is guaranteed to be valid only until the next call to - * get_stream_configurations() or STREAM_CONFIGURATIONS_CHANGED event. - * - * Return 0 on success. - */ - int (*get_stream_configurations)(const struct tv_input_device* dev, - int device_id, int* num_configurations, - const tv_stream_config_t** configs); - - /* - * open_stream: - * - * Open a stream with given stream ID. Caller owns stream object, and the - * populated data is only valid until the stream is closed. - * - * Return 0 on success; -EBUSY if the client should close other streams to - * open the stream; -EEXIST if the stream with the given ID is already open; - * -EINVAL if device_id and/or stream_id are invalid; other non-zero value - * denotes unknown error. - */ - int (*open_stream)(struct tv_input_device* dev, int device_id, - tv_stream_t* stream); - - /* - * close_stream: - * - * Close a stream to a device. data in tv_stream_t* object associated with - * the stream_id is obsolete once this call finishes. - * - * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if - * device_id and/or stream_id are invalid. - */ - int (*close_stream)(struct tv_input_device* dev, int device_id, - int stream_id); - - /* - * request_capture: - * - * Request buffer capture for a stream. This is only valid for buffer - * producer streams. The buffer should be created with size, format and - * usage specified in the stream. Framework provides seq in an - * increasing sequence per each stream. Hardware should provide the picture - * in a chronological order according to seq. For example, if two - * requests are being processed at the same time, the request with the - * smaller seq should get an earlier frame. - * - * The framework releases the ownership of the buffer upon calling this - * function. When the buffer is filled, hardware notifies the framework - * via TV_INPUT_EVENT_CAPTURE_FINISHED callback, and the ownership is - * transferred back to framework at that time. - * - * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if - * device_id and/or stream_id are invalid; -EWOULDBLOCK if HAL cannot take - * additional requests until it releases a buffer. - */ - int (*request_capture)(struct tv_input_device* dev, int device_id, - int stream_id, buffer_handle_t buffer, uint32_t seq); - - /* - * cancel_capture: - * - * Cancel an ongoing capture. Hardware should release the buffer as soon as - * possible via TV_INPUT_EVENT_CAPTURE_FAILED callback. - * - * Return 0 on success; -ENOENT if the stream is not open; -EINVAL if - * device_id, stream_id, and/or seq are invalid. - */ - int (*cancel_capture)(struct tv_input_device* dev, int device_id, - int stream_id, uint32_t seq); - - void* reserved[16]; -} tv_input_device_t; - -__END_DECLS - -#endif // ANDROID_TV_INPUT_INTERFACE_H diff --git a/third_party/android_hardware_libhardware/include/hardware/vibrator.h b/third_party/android_hardware_libhardware/include/hardware/vibrator.h deleted file mode 100644 index 92b1fd005..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/vibrator.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef _HARDWARE_VIBRATOR_H -#define _HARDWARE_VIBRATOR_H - -#include - -__BEGIN_DECLS - -#define VIBRATOR_API_VERSION HARDWARE_MODULE_API_VERSION(1,0) - -/** - * The id of this module - */ -#define VIBRATOR_HARDWARE_MODULE_ID "vibrator" - -/** - * The id of the main vibrator device - */ -#define VIBRATOR_DEVICE_ID_MAIN "main_vibrator" - -struct vibrator_device; -typedef struct vibrator_device { - /** - * Common methods of the vibrator device. This *must* be the first member of - * vibrator_device as users of this structure will cast a hw_device_t to - * vibrator_device pointer in contexts where it's known the hw_device_t references a - * vibrator_device. - */ - struct hw_device_t common; - - /** Turn on vibrator - * - * What happens when this function is called while the the timeout of a - * previous call has not expired is implementation dependent. - * - * @param timeout_ms number of milliseconds to vibrate - * - * @return 0 in case of success, negative errno code else - */ - int (*vibrator_on)(struct vibrator_device* vibradev, unsigned int timeout_ms); - - /** Turn off vibrator - * - * It is not guaranteed that the vibrator will be immediately stopped: the - * behaviour is implementation dependent. - * - * @return 0 in case of success, negative errno code else - */ - int (*vibrator_off)(struct vibrator_device* vibradev); -} vibrator_device_t; - -static inline int vibrator_open(const struct hw_module_t* module, vibrator_device_t** device) -{ - return module->methods->open(module, VIBRATOR_DEVICE_ID_MAIN, (struct hw_device_t**)device); -} - -__END_DECLS - -#endif // _HARDWARE_VIBRATOR_H diff --git a/third_party/android_hardware_libhardware/include/hardware/wipower.h b/third_party/android_hardware_libhardware/include/hardware/wipower.h deleted file mode 100644 index eb3a0ee0d..000000000 --- a/third_party/android_hardware_libhardware/include/hardware/wipower.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of The Linux Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN - * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_INCLUDE_WIPOWER_H -#define ANDROID_INCLUDE_WIPOWER_H - -#include -#include -#include -#include - -#include -#include - -__BEGIN_DECLS - -typedef enum { - OFF =0, - ON -} wipower_state_t; - - -typedef struct { - -unsigned char optional; -unsigned short rect_voltage; -unsigned short rect_current; -unsigned short out_voltage; -unsigned short out_current; -unsigned char temp; -unsigned short rect_voltage_min; -unsigned short rect_voltage_set; -unsigned short rect_voltage_max; -unsigned char alert; -unsigned short rfu1; -unsigned char rfu2; - -}__attribute__((packed)) wipower_dyn_data_t; - -/** Bluetooth Enable/Disable Callback. */ -typedef void (*wipower_state_changed_callback)(wipower_state_t state); - - -typedef void (*wipower_alerts)(unsigned char alert); - - -typedef void (*wipower_dynamic_data)(wipower_dyn_data_t* alert_data); - - -typedef void (*wipower_power_apply)(unsigned char power_flag); - -typedef void (*callback_thread_event)(bt_cb_thread_evt evt); - -/** Bluetooth DM callback structure. */ -typedef struct { - /** set to sizeof(wipower_callbacks_t) */ - size_t size; - wipower_state_changed_callback wipower_state_changed_cb; - wipower_alerts wipower_alert; - wipower_dynamic_data wipower_data; - wipower_power_apply wipower_power_event; - callback_thread_event callback_thread_event; -} wipower_callbacks_t; - - -/** Represents the standard Wipower interface. */ -typedef struct { - /** set to sizeof(wipower_interface_t) */ - size_t size; - - /** Initialize Wipower modules*/ - int (*init)(wipower_callbacks_t *wp_callbacks); - - /** Enable/Disable Wipower charging */ - int (*enable)(bool enable); - - int (*set_current_limit)(short value); - - unsigned char (*get_current_limit)(void); - - wipower_state_t (*get_state)(void); - - /** Enable/Disable Wipower charging */ - int (*enable_alerts)(bool enable); - - int (*enable_data_notify)(bool enable); - int (*enable_power_apply)(bool enable, bool on, bool time_flag); -} wipower_interface_t; - - -__END_DECLS - -#endif /* ANDROID_INCLUDE_WIPOWER_H */ diff --git a/third_party/android_system_core/include/cutils/android_reboot.h b/third_party/android_system_core/include/cutils/android_reboot.h deleted file mode 100644 index a3861a02d..000000000 --- a/third_party/android_system_core/include/cutils/android_reboot.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2011, 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. - */ - -#ifndef __CUTILS_ANDROID_REBOOT_H__ -#define __CUTILS_ANDROID_REBOOT_H__ - -#include - -__BEGIN_DECLS - -/* Commands */ -#define ANDROID_RB_RESTART 0xDEAD0001 -#define ANDROID_RB_POWEROFF 0xDEAD0002 -#define ANDROID_RB_RESTART2 0xDEAD0003 - -/* Properties */ -#define ANDROID_RB_PROPERTY "sys.powerctl" - -int android_reboot(int cmd, int flags, const char *arg); -int android_reboot_with_callback( - int cmd, int flags, const char *arg, - void (*cb_on_remount)(const struct mntent*)); - -__END_DECLS - -#endif /* __CUTILS_ANDROID_REBOOT_H__ */ diff --git a/third_party/android_system_core/include/cutils/aref.h b/third_party/android_system_core/include/cutils/aref.h deleted file mode 100644 index 3bd36ea04..000000000 --- a/third_party/android_system_core/include/cutils/aref.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef _CUTILS_AREF_H_ -#define _CUTILS_AREF_H_ - -#include -#include - -#include - -__BEGIN_DECLS - -#define AREF_TO_ITEM(aref, container, member) \ - (container *) (((char*) (aref)) - offsetof(container, member)) - -struct aref -{ - volatile int32_t count; -}; - -static inline void aref_init(struct aref *r) -{ - r->count = 1; -} - -static inline int32_t aref_count(struct aref *r) -{ - return r->count; -} - -static inline void aref_get(struct aref *r) -{ - android_atomic_inc(&r->count); -} - -static inline void aref_put(struct aref *r, void (*release)(struct aref *)) -{ - if (android_atomic_dec(&r->count) == 1) - release(r); -} - -__END_DECLS - -#endif // _CUTILS_AREF_H_ diff --git a/third_party/android_system_core/include/cutils/ashmem.h b/third_party/android_system_core/include/cutils/ashmem.h deleted file mode 100644 index 25b233e6a..000000000 --- a/third_party/android_system_core/include/cutils/ashmem.h +++ /dev/null @@ -1,45 +0,0 @@ -/* cutils/ashmem.h - ** - ** Copyright 2008 The Android Open Source Project - ** - ** This file is dual licensed. It may be redistributed and/or modified - ** under the terms of the Apache 2.0 License OR version 2 of the GNU - ** General Public License. - */ - -#ifndef _CUTILS_ASHMEM_H -#define _CUTILS_ASHMEM_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int ashmem_create_region(const char *name, size_t size); -int ashmem_set_prot_region(int fd, int prot); -int ashmem_pin_region(int fd, size_t offset, size_t len); -int ashmem_unpin_region(int fd, size_t offset, size_t len); -int ashmem_get_size_region(int fd); - -#ifdef __cplusplus -} -#endif - -#ifndef __ASHMEMIOC /* in case someone included too */ - -#define ASHMEM_NAME_LEN 256 - -#define ASHMEM_NAME_DEF "dev/ashmem" - -/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ -#define ASHMEM_NOT_PURGED 0 -#define ASHMEM_WAS_PURGED 1 - -/* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ -#define ASHMEM_IS_UNPINNED 0 -#define ASHMEM_IS_PINNED 1 - -#endif /* ! __ASHMEMIOC */ - -#endif /* _CUTILS_ASHMEM_H */ diff --git a/third_party/android_system_core/include/cutils/atomic.h b/third_party/android_system_core/include/cutils/atomic.h deleted file mode 100644 index ded972acb..000000000 --- a/third_party/android_system_core/include/cutils/atomic.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef ANDROID_CUTILS_ATOMIC_H -#define ANDROID_CUTILS_ATOMIC_H - -#include -#include -#include - -#ifndef ANDROID_ATOMIC_INLINE -#define ANDROID_ATOMIC_INLINE static inline -#endif - -/* - * A handful of basic atomic operations. - * THESE ARE HERE FOR LEGACY REASONS ONLY. AVOID. - * - * PREFERRED ALTERNATIVES: - * - Use C++/C/pthread locks/mutexes whenever there is not a - * convincing reason to do otherwise. Note that very clever and - * complicated, but correct, lock-free code is often slower than - * using locks, especially where nontrivial data structures - * are involved. - * - C11 stdatomic.h. - * - Where supported, C++11 std::atomic . - * - * PLEASE STOP READING HERE UNLESS YOU ARE TRYING TO UNDERSTAND - * OR UPDATE OLD CODE. - * - * The "acquire" and "release" terms can be defined intuitively in terms - * of the placement of memory barriers in a simple lock implementation: - * - wait until compare-and-swap(lock-is-free --> lock-is-held) succeeds - * - barrier - * - [do work] - * - barrier - * - store(lock-is-free) - * In very crude terms, the initial (acquire) barrier prevents any of the - * "work" from happening before the lock is held, and the later (release) - * barrier ensures that all of the work happens before the lock is released. - * (Think of cached writes, cache read-ahead, and instruction reordering - * around the CAS and store instructions.) - * - * The barriers must apply to both the compiler and the CPU. Note it is - * legal for instructions that occur before an "acquire" barrier to be - * moved down below it, and for instructions that occur after a "release" - * barrier to be moved up above it. - * - * The ARM-driven implementation we use here is short on subtlety, - * and actually requests a full barrier from the compiler and the CPU. - * The only difference between acquire and release is in whether they - * are issued before or after the atomic operation with which they - * are associated. To ease the transition to C/C++ atomic intrinsics, - * you should not rely on this, and instead assume that only the minimal - * acquire/release protection is provided. - * - * NOTE: all int32_t* values are expected to be aligned on 32-bit boundaries. - * If they are not, atomicity is not guaranteed. - */ - -/* - * Basic arithmetic and bitwise operations. These all provide a - * barrier with "release" ordering, and return the previous value. - * - * These have the same characteristics (e.g. what happens on overflow) - * as the equivalent non-atomic C operations. - */ -ANDROID_ATOMIC_INLINE -int32_t android_atomic_inc(volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - /* Int32_t, if it exists, is the same as int_least32_t. */ - return atomic_fetch_add_explicit(a, 1, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_dec(volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_sub_explicit(a, 1, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_add(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_add_explicit(a, value, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_and(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_and_explicit(a, value, memory_order_release); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_or(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_fetch_or_explicit(a, value, memory_order_release); -} - -/* - * Perform an atomic load with "acquire" or "release" ordering. - * - * Note that the notion of a "release" ordering for a load does not - * really fit into the C11 or C++11 memory model. The extra ordering - * is normally observable only by code using memory_order_relaxed - * atomics, or data races. In the rare cases in which such ordering - * is called for, use memory_order_relaxed atomics and a leading - * atomic_thread_fence (typically with memory_order_acquire, - * not memory_order_release!) instead. If you do not understand - * this comment, you are in the vast majority, and should not be - * using release loads or replacing them with anything other than - * locks or default sequentially consistent atomics. - */ -ANDROID_ATOMIC_INLINE -int32_t android_atomic_acquire_load(volatile const int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return atomic_load_explicit(a, memory_order_acquire); -} - -ANDROID_ATOMIC_INLINE -int32_t android_atomic_release_load(volatile const int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - atomic_thread_fence(memory_order_seq_cst); - /* Any reasonable clients of this interface would probably prefer */ - /* something weaker. But some remaining clients seem to be */ - /* abusing this API in strange ways, e.g. by using it as a fence. */ - /* Thus we are conservative until we can get rid of remaining */ - /* clients (and this function). */ - return atomic_load_explicit(a, memory_order_relaxed); -} - -/* - * Perform an atomic store with "acquire" or "release" ordering. - * - * Note that the notion of an "acquire" ordering for a store does not - * really fit into the C11 or C++11 memory model. The extra ordering - * is normally observable only by code using memory_order_relaxed - * atomics, or data races. In the rare cases in which such ordering - * is called for, use memory_order_relaxed atomics and a trailing - * atomic_thread_fence (typically with memory_order_release, - * not memory_order_acquire!) instead. - */ -ANDROID_ATOMIC_INLINE -void android_atomic_acquire_store(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - atomic_store_explicit(a, value, memory_order_relaxed); - atomic_thread_fence(memory_order_seq_cst); - /* Again overly conservative to accomodate weird clients. */ -} - -ANDROID_ATOMIC_INLINE -void android_atomic_release_store(int32_t value, volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - atomic_store_explicit(a, value, memory_order_release); -} - -/* - * Compare-and-set operation with "acquire" or "release" ordering. - * - * This returns zero if the new value was successfully stored, which will - * only happen when *addr == oldvalue. - * - * (The return value is inverted from implementations on other platforms, - * but matches the ARM ldrex/strex result.) - * - * Implementations that use the release CAS in a loop may be less efficient - * than possible, because we re-issue the memory barrier on each iteration. - */ -ANDROID_ATOMIC_INLINE -int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue, - volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return (int)(!atomic_compare_exchange_strong_explicit( - a, &oldvalue, newvalue, - memory_order_acquire, - memory_order_acquire)); -} - -ANDROID_ATOMIC_INLINE -int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue, - volatile int32_t* addr) -{ - volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr; - return (int)(!atomic_compare_exchange_strong_explicit( - a, &oldvalue, newvalue, - memory_order_release, - memory_order_relaxed)); -} - -/* - * Fence primitives. - */ -ANDROID_ATOMIC_INLINE -void android_compiler_barrier(void) -{ - __asm__ __volatile__ ("" : : : "memory"); - /* Could probably also be: */ - /* atomic_signal_fence(memory_order_seq_cst); */ -} - -ANDROID_ATOMIC_INLINE -void android_memory_barrier(void) -{ - atomic_thread_fence(memory_order_seq_cst); -} - -/* - * Aliases for code using an older version of this header. These are now - * deprecated and should not be used. The definitions will be removed - * in a future release. - */ -#define android_atomic_write android_atomic_release_store -#define android_atomic_cmpxchg android_atomic_release_cas - -#endif // ANDROID_CUTILS_ATOMIC_H diff --git a/third_party/android_system_core/include/cutils/bitops.h b/third_party/android_system_core/include/cutils/bitops.h deleted file mode 100644 index 045830d90..000000000 --- a/third_party/android_system_core/include/cutils/bitops.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef __CUTILS_BITOPS_H -#define __CUTILS_BITOPS_H - -#include -#include -#include -#include - -__BEGIN_DECLS - -/* - * Bitmask Operations - * - * Note this doesn't provide any locking/exclusion, and isn't atomic. - * Additionally no bounds checking is done on the bitmask array. - * - * Example: - * - * int num_resources; - * unsigned int resource_bits[BITS_TO_WORDS(num_resources)]; - * bitmask_init(resource_bits, num_resources); - * ... - * int bit = bitmask_ffz(resource_bits, num_resources); - * bitmask_set(resource_bits, bit); - * ... - * if (bitmask_test(resource_bits, bit)) { ... } - * ... - * bitmask_clear(resource_bits, bit); - * - */ - -#define BITS_PER_WORD (sizeof(unsigned int) * 8) -#define BITS_TO_WORDS(x) (((x) + BITS_PER_WORD - 1) / BITS_PER_WORD) -#define BIT_IN_WORD(x) ((x) % BITS_PER_WORD) -#define BIT_WORD(x) ((x) / BITS_PER_WORD) -#define BIT_MASK(x) (1 << BIT_IN_WORD(x)) - -static inline void bitmask_init(unsigned int *bitmask, int num_bits) -{ - memset(bitmask, 0, BITS_TO_WORDS(num_bits)*sizeof(unsigned int)); -} - -static inline int bitmask_ffz(unsigned int *bitmask, int num_bits) -{ - int bit, result; - size_t i; - - for (i = 0; i < BITS_TO_WORDS(num_bits); i++) { - bit = ffs(~bitmask[i]); - if (bit) { - // ffs is 1-indexed, return 0-indexed result - bit--; - result = BITS_PER_WORD * i + bit; - if (result >= num_bits) - return -1; - return result; - } - } - return -1; -} - -static inline int bitmask_weight(unsigned int *bitmask, int num_bits) -{ - size_t i; - int weight = 0; - - for (i = 0; i < BITS_TO_WORDS(num_bits); i++) - weight += __builtin_popcount(bitmask[i]); - return weight; -} - -static inline void bitmask_set(unsigned int *bitmask, int bit) -{ - bitmask[BIT_WORD(bit)] |= BIT_MASK(bit); -} - -static inline void bitmask_clear(unsigned int *bitmask, int bit) -{ - bitmask[BIT_WORD(bit)] &= ~BIT_MASK(bit); -} - -static inline bool bitmask_test(unsigned int *bitmask, int bit) -{ - return bitmask[BIT_WORD(bit)] & BIT_MASK(bit); -} - -static inline int popcount(unsigned int x) -{ - return __builtin_popcount(x); -} - -static inline int popcountl(unsigned long x) -{ - return __builtin_popcountl(x); -} - -static inline int popcountll(unsigned long long x) -{ - return __builtin_popcountll(x); -} - -__END_DECLS - -#endif /* __CUTILS_BITOPS_H */ diff --git a/third_party/android_system_core/include/cutils/compiler.h b/third_party/android_system_core/include/cutils/compiler.h deleted file mode 100644 index 70f884a1e..000000000 --- a/third_party/android_system_core/include/cutils/compiler.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -#ifndef ANDROID_CUTILS_COMPILER_H -#define ANDROID_CUTILS_COMPILER_H - -/* - * helps the compiler's optimizer predicting branches - */ - -#ifdef __cplusplus -# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) -# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) -#else -# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) -# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) -#endif - -/** - * exports marked symbols - * - * if used on a C++ class declaration, this macro must be inserted - * after the "class" keyword. For instance: - * - * template - * class ANDROID_API Singleton { } - */ - -#define ANDROID_API __attribute__((visibility("default"))) - -#endif // ANDROID_CUTILS_COMPILER_H diff --git a/third_party/android_system_core/include/cutils/config_utils.h b/third_party/android_system_core/include/cutils/config_utils.h deleted file mode 100644 index 2dea6f19f..000000000 --- a/third_party/android_system_core/include/cutils/config_utils.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef __CUTILS_CONFIG_UTILS_H -#define __CUTILS_CONFIG_UTILS_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct cnode cnode; - - -struct cnode -{ - cnode *next; - cnode *first_child; - cnode *last_child; - const char *name; - const char *value; -}; - -/* parse a text string into a config node tree */ -void config_load(cnode *root, char *data); - -/* parse a file into a config node tree */ -void config_load_file(cnode *root, const char *fn); - -/* create a single config node */ -cnode* config_node(const char *name, const char *value); - -/* locate a named child of a config node */ -cnode* config_find(cnode *root, const char *name); - -/* look up a child by name and return the boolean value */ -int config_bool(cnode *root, const char *name, int _default); - -/* look up a child by name and return the string value */ -const char* config_str(cnode *root, const char *name, const char *_default); - -/* add a named child to a config node (or modify it if it already exists) */ -void config_set(cnode *root, const char *name, const char *value); - -/* free a config node tree */ -void config_free(cnode *root); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/android_system_core/include/cutils/debugger.h b/third_party/android_system_core/include/cutils/debugger.h deleted file mode 100644 index 285e1afcd..000000000 --- a/third_party/android_system_core/include/cutils/debugger.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef __CUTILS_DEBUGGER_H -#define __CUTILS_DEBUGGER_H - -#include -#include - -__BEGIN_DECLS - -#define DEBUGGER_SOCKET_NAME "android:debuggerd" -#define DEBUGGER32_SOCKET_NAME "android:debuggerd32" -#define DEBUGGER64_SOCKET_NAME DEBUGGER_SOCKET_NAME - -typedef enum { - // dump a crash - DEBUGGER_ACTION_CRASH, - // dump a tombstone file - DEBUGGER_ACTION_DUMP_TOMBSTONE, - // dump a backtrace only back to the socket - DEBUGGER_ACTION_DUMP_BACKTRACE, -} debugger_action_t; - -// Make sure that all values have a fixed size so that this structure -// is the same for 32 bit and 64 bit processes. -// NOTE: Any changes to this structure must also be reflected in -// bionic/linker/debugger.cpp. -typedef struct __attribute__((packed)) { - int32_t action; - pid_t tid; - uint64_t abort_msg_address; - int32_t original_si_code; -} debugger_msg_t; - -/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). - * Stores the tombstone path in the provided buffer. - * Returns 0 on success, -1 on error. - */ -int dump_tombstone(pid_t tid, char* pathbuf, size_t pathlen); - -/* Dumps a process backtrace, registers, and stack to a tombstone file (requires root). - * Stores the tombstone path in the provided buffer. - * If reading debugger data from debuggerd ever takes longer than timeout_secs - * seconds, then stop and return an error. - * Returns 0 on success, -1 on error. - */ -int dump_tombstone_timeout(pid_t tid, char* pathbuf, size_t pathlen, int timeout_secs); - -/* Dumps a process backtrace only to the specified file (requires root). - * Returns 0 on success, -1 on error. - */ -int dump_backtrace_to_file(pid_t tid, int fd); - -/* Dumps a process backtrace only to the specified file (requires root). - * If reading debugger data from debuggerd ever takes longer than timeout_secs - * seconds, then stop and return an error. - * Returns 0 on success, -1 on error. - */ -int dump_backtrace_to_file_timeout(pid_t tid, int fd, int timeout_secs); - -__END_DECLS - -#endif /* __CUTILS_DEBUGGER_H */ diff --git a/third_party/android_system_core/include/cutils/fs.h b/third_party/android_system_core/include/cutils/fs.h deleted file mode 100644 index 70f0b9291..000000000 --- a/third_party/android_system_core/include/cutils/fs.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef __CUTILS_FS_H -#define __CUTILS_FS_H - -#include -#include - -/* - * TEMP_FAILURE_RETRY is defined by some, but not all, versions of - * . (Alas, it is not as standard as we'd hoped!) So, if it's - * not already defined, then define it here. - */ -#ifndef TEMP_FAILURE_RETRY -/* Used to retry syscalls that can return EINTR. */ -#define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; }) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Ensure that directory exists with given mode and owners. - */ -extern int fs_prepare_dir(const char* path, mode_t mode, uid_t uid, gid_t gid); - -/* - * Read single plaintext integer from given file, correctly handling files - * partially written with fs_write_atomic_int(). - */ -extern int fs_read_atomic_int(const char* path, int* value); - -/* - * Write single plaintext integer to given file, creating backup while - * in progress. - */ -extern int fs_write_atomic_int(const char* path, int value); - -/* - * Ensure that all directories along given path exist, creating parent - * directories as needed. Validates that given path is absolute and that - * it contains no relative "." or ".." paths or symlinks. Last path segment - * is treated as filename and ignored, unless the path ends with "/". - */ -extern int fs_mkdirs(const char* path, mode_t mode); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_FS_H */ diff --git a/third_party/android_system_core/include/cutils/hashmap.h b/third_party/android_system_core/include/cutils/hashmap.h deleted file mode 100644 index 5cb344c15..000000000 --- a/third_party/android_system_core/include/cutils/hashmap.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -/** - * Hash map. - */ - -#ifndef __HASHMAP_H -#define __HASHMAP_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** A hash map. */ -typedef struct Hashmap Hashmap; - -/** - * Creates a new hash map. Returns NULL if memory allocation fails. - * - * @param initialCapacity number of expected entries - * @param hash function which hashes keys - * @param equals function which compares keys for equality - */ -Hashmap* hashmapCreate(size_t initialCapacity, - int (*hash)(void* key), bool (*equals)(void* keyA, void* keyB)); - -/** - * Frees the hash map. Does not free the keys or values themselves. - */ -void hashmapFree(Hashmap* map); - -/** - * Hashes the memory pointed to by key with the given size. Useful for - * implementing hash functions. - */ -int hashmapHash(void* key, size_t keySize); - -/** - * Puts value for the given key in the map. Returns pre-existing value if - * any. - * - * If memory allocation fails, this function returns NULL, the map's size - * does not increase, and errno is set to ENOMEM. - */ -void* hashmapPut(Hashmap* map, void* key, void* value); - -/** - * Gets a value from the map. Returns NULL if no entry for the given key is - * found or if the value itself is NULL. - */ -void* hashmapGet(Hashmap* map, void* key); - -/** - * Returns true if the map contains an entry for the given key. - */ -bool hashmapContainsKey(Hashmap* map, void* key); - -/** - * Gets the value for a key. If a value is not found, this function gets a - * value and creates an entry using the given callback. - * - * If memory allocation fails, the callback is not called, this function - * returns NULL, and errno is set to ENOMEM. - */ -void* hashmapMemoize(Hashmap* map, void* key, - void* (*initialValue)(void* key, void* context), void* context); - -/** - * Removes an entry from the map. Returns the removed value or NULL if no - * entry was present. - */ -void* hashmapRemove(Hashmap* map, void* key); - -/** - * Gets the number of entries in this map. - */ -size_t hashmapSize(Hashmap* map); - -/** - * Invokes the given callback on each entry in the map. Stops iterating if - * the callback returns false. - */ -void hashmapForEach(Hashmap* map, - bool (*callback)(void* key, void* value, void* context), - void* context); - -/** - * Concurrency support. - */ - -/** - * Locks the hash map so only the current thread can access it. - */ -void hashmapLock(Hashmap* map); - -/** - * Unlocks the hash map so other threads can access it. - */ -void hashmapUnlock(Hashmap* map); - -/** - * Key utilities. - */ - -/** - * Hashes int keys. 'key' is a pointer to int. - */ -int hashmapIntHash(void* key); - -/** - * Compares two int keys for equality. - */ -bool hashmapIntEquals(void* keyA, void* keyB); - -/** - * For debugging. - */ - -/** - * Gets current capacity. - */ -size_t hashmapCurrentCapacity(Hashmap* map); - -/** - * Counts the number of entry collisions. - */ -size_t hashmapCountCollisions(Hashmap* map); - -#ifdef __cplusplus -} -#endif - -#endif /* __HASHMAP_H */ diff --git a/third_party/android_system_core/include/cutils/iosched_policy.h b/third_party/android_system_core/include/cutils/iosched_policy.h deleted file mode 100644 index 25b87bac0..000000000 --- a/third_party/android_system_core/include/cutils/iosched_policy.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef __CUTILS_IOSCHED_POLICY_H -#define __CUTILS_IOSCHED_POLICY_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - IoSchedClass_NONE, - IoSchedClass_RT, - IoSchedClass_BE, - IoSchedClass_IDLE, -} IoSchedClass; - -extern int android_set_ioprio(int pid, IoSchedClass clazz, int ioprio); -extern int android_get_ioprio(int pid, IoSchedClass *clazz, int *ioprio); - -extern int android_set_rt_ioprio(int pid, int rt); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_IOSCHED_POLICY_H */ diff --git a/third_party/android_system_core/include/cutils/jstring.h b/third_party/android_system_core/include/cutils/jstring.h deleted file mode 100644 index a3426081a..000000000 --- a/third_party/android_system_core/include/cutils/jstring.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef __CUTILS_STRING16_H -#define __CUTILS_STRING16_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if __STDC_VERSION__ < 201112L && __cplusplus < 201103L - typedef uint16_t char16_t; -#endif - // otherwise char16_t is a keyword with the right semantics - -extern char * strndup16to8 (const char16_t* s, size_t n); -extern size_t strnlen16to8 (const char16_t* s, size_t n); -extern char * strncpy16to8 (char *dest, const char16_t*s, size_t n); - -extern char16_t * strdup8to16 (const char* s, size_t *out_len); -extern size_t strlen8to16 (const char* utf8Str); -extern char16_t * strcpy8to16 (char16_t *dest, const char*s, size_t *out_len); -extern char16_t * strcpylen8to16 (char16_t *dest, const char*s, int length, - size_t *out_len); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_STRING16_H */ diff --git a/third_party/android_system_core/include/cutils/klog.h b/third_party/android_system_core/include/cutils/klog.h deleted file mode 100644 index 295d62be3..000000000 --- a/third_party/android_system_core/include/cutils/klog.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef _CUTILS_KLOG_H_ -#define _CUTILS_KLOG_H_ - -#include -#include -#include - -__BEGIN_DECLS - -void klog_init(void); -int klog_get_level(void); -void klog_set_level(int level); -/* TODO: void klog_close(void); - and make klog_fd users thread safe. */ - -void klog_write(int level, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); -void klog_writev(int level, const struct iovec* iov, int iov_count); - -__END_DECLS - -#define KLOG_ERROR_LEVEL 3 -#define KLOG_WARNING_LEVEL 4 -#define KLOG_NOTICE_LEVEL 5 -#define KLOG_INFO_LEVEL 6 -#define KLOG_DEBUG_LEVEL 7 - -#define KLOG_ERROR(tag,x...) klog_write(KLOG_ERROR_LEVEL, "<3>" tag ": " x) -#define KLOG_WARNING(tag,x...) klog_write(KLOG_WARNING_LEVEL, "<4>" tag ": " x) -#define KLOG_NOTICE(tag,x...) klog_write(KLOG_NOTICE_LEVEL, "<5>" tag ": " x) -#define KLOG_INFO(tag,x...) klog_write(KLOG_INFO_LEVEL, "<6>" tag ": " x) -#define KLOG_DEBUG(tag,x...) klog_write(KLOG_DEBUG_LEVEL, "<7>" tag ": " x) - -#define KLOG_DEFAULT_LEVEL 3 /* messages <= this level are logged */ - -#endif diff --git a/third_party/android_system_core/include/cutils/list.h b/third_party/android_system_core/include/cutils/list.h deleted file mode 100644 index 4ba2cfd49..000000000 --- a/third_party/android_system_core/include/cutils/list.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2008-2013 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. - */ - -#ifndef _CUTILS_LIST_H_ -#define _CUTILS_LIST_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -struct listnode -{ - struct listnode *next; - struct listnode *prev; -}; - -#define node_to_item(node, container, member) \ - (container *) (((char*) (node)) - offsetof(container, member)) - -#define list_declare(name) \ - struct listnode name = { \ - .next = &name, \ - .prev = &name, \ - } - -#define list_for_each(node, list) \ - for (node = (list)->next; node != (list); node = node->next) - -#define list_for_each_reverse(node, list) \ - for (node = (list)->prev; node != (list); node = node->prev) - -#define list_for_each_safe(node, n, list) \ - for (node = (list)->next, n = node->next; \ - node != (list); \ - node = n, n = node->next) - -static inline void list_init(struct listnode *node) -{ - node->next = node; - node->prev = node; -} - -static inline void list_add_tail(struct listnode *head, struct listnode *item) -{ - item->next = head; - item->prev = head->prev; - head->prev->next = item; - head->prev = item; -} - -static inline void list_add_head(struct listnode *head, struct listnode *item) -{ - item->next = head->next; - item->prev = head; - head->next->prev = item; - head->next = item; -} - -static inline void list_remove(struct listnode *item) -{ - item->next->prev = item->prev; - item->prev->next = item->next; -} - -#define list_empty(list) ((list) == (list)->next) -#define list_head(list) ((list)->next) -#define list_tail(list) ((list)->prev) - -#ifdef __cplusplus -}; -#endif /* __cplusplus */ - -#endif diff --git a/third_party/android_system_core/include/cutils/log.h b/third_party/android_system_core/include/cutils/log.h deleted file mode 100644 index 0e0248e50..000000000 --- a/third_party/android_system_core/include/cutils/log.h +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/third_party/android_system_core/include/cutils/memory.h b/third_party/android_system_core/include/cutils/memory.h deleted file mode 100644 index 4d2688255..000000000 --- a/third_party/android_system_core/include/cutils/memory.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef ANDROID_CUTILS_MEMORY_H -#define ANDROID_CUTILS_MEMORY_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* size is given in bytes and must be multiple of 2 */ -void android_memset16(uint16_t* dst, uint16_t value, size_t size); - -/* size is given in bytes and must be multiple of 4 */ -void android_memset32(uint32_t* dst, uint32_t value, size_t size); - -#if defined(__GLIBC__) || defined(_WIN32) -/* Declaration of strlcpy() for platforms that don't already have it. */ -size_t strlcpy(char *dst, const char *src, size_t size); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // ANDROID_CUTILS_MEMORY_H diff --git a/third_party/android_system_core/include/cutils/misc.h b/third_party/android_system_core/include/cutils/misc.h deleted file mode 100644 index 0de505f27..000000000 --- a/third_party/android_system_core/include/cutils/misc.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef __CUTILS_MISC_H -#define __CUTILS_MISC_H - -#ifdef __cplusplus -extern "C" { -#endif - - /* Load an entire file into a malloc'd chunk of memory - * that is length_of_file + 1 (null terminator). If - * sz is non-zero, return the size of the file via sz. - * Returns 0 on failure. - */ -extern void *load_file(const char *fn, unsigned *sz); - - /* This is the range of UIDs (and GIDs) that are reserved - * for assigning to applications. - */ -#define FIRST_APPLICATION_UID 10000 -#define LAST_APPLICATION_UID 99999 - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_MISC_H */ diff --git a/third_party/android_system_core/include/cutils/multiuser.h b/third_party/android_system_core/include/cutils/multiuser.h deleted file mode 100644 index 635ddb135..000000000 --- a/third_party/android_system_core/include/cutils/multiuser.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef __CUTILS_MULTIUSER_H -#define __CUTILS_MULTIUSER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// NOTE: keep in sync with android.os.UserId - -#define MULTIUSER_APP_PER_USER_RANGE 100000 - -typedef uid_t userid_t; -typedef uid_t appid_t; - -extern userid_t multiuser_get_user_id(uid_t uid); -extern appid_t multiuser_get_app_id(uid_t uid); -extern uid_t multiuser_get_uid(userid_t userId, appid_t appId); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_MULTIUSER_H */ diff --git a/third_party/android_system_core/include/cutils/native_handle.h b/third_party/android_system_core/include/cutils/native_handle.h deleted file mode 100644 index 268c5d3f5..000000000 --- a/third_party/android_system_core/include/cutils/native_handle.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -#ifndef NATIVE_HANDLE_H_ -#define NATIVE_HANDLE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct native_handle -{ - int version; /* sizeof(native_handle_t) */ - int numFds; /* number of file-descriptors at &data[0] */ - int numInts; /* number of ints at &data[numFds] */ - int data[0]; /* numFds + numInts ints */ -} native_handle_t; - -/* - * native_handle_close - * - * closes the file descriptors contained in this native_handle_t - * - * return 0 on success, or a negative error code on failure - * - */ -int native_handle_close(const native_handle_t* h); - - -/* - * native_handle_create - * - * creates a native_handle_t and initializes it. must be destroyed with - * native_handle_delete(). - * - */ -native_handle_t* native_handle_create(int numFds, int numInts); - -/* - * native_handle_delete - * - * frees a native_handle_t allocated with native_handle_create(). - * This ONLY frees the memory allocated for the native_handle_t, but doesn't - * close the file descriptors; which can be achieved with native_handle_close(). - * - * return 0 on success, or a negative error code on failure - * - */ -int native_handle_delete(native_handle_t* h); - - -#ifdef __cplusplus -} -#endif - -#endif /* NATIVE_HANDLE_H_ */ diff --git a/third_party/android_system_core/include/cutils/open_memstream.h b/third_party/android_system_core/include/cutils/open_memstream.h deleted file mode 100644 index c1a81ebbc..000000000 --- a/third_party/android_system_core/include/cutils/open_memstream.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef __CUTILS_OPEN_MEMSTREAM_H__ -#define __CUTILS_OPEN_MEMSTREAM_H__ - -#include - -#if defined(__APPLE__) - -#ifdef __cplusplus -extern "C" { -#endif - -FILE* open_memstream(char** bufp, size_t* sizep); - -#ifdef __cplusplus -} -#endif - -#endif /* __APPLE__ */ - -#endif /*__CUTILS_OPEN_MEMSTREAM_H__*/ diff --git a/third_party/android_system_core/include/cutils/partition_utils.h b/third_party/android_system_core/include/cutils/partition_utils.h deleted file mode 100644 index 72ca80d35..000000000 --- a/third_party/android_system_core/include/cutils/partition_utils.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2011, 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. - */ - -#ifndef __CUTILS_PARTITION_WIPED_H__ -#define __CUTILS_PARTITION_WIPED_H__ - -__BEGIN_DECLS - -int partition_wiped(char *source); - -__END_DECLS - -#endif /* __CUTILS_PARTITION_WIPED_H__ */ diff --git a/third_party/android_system_core/include/cutils/process_name.h b/third_party/android_system_core/include/cutils/process_name.h deleted file mode 100644 index 1e72e5c3a..000000000 --- a/third_party/android_system_core/include/cutils/process_name.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -/** - * Gives the current process a name. - */ - -#ifndef __PROCESS_NAME_H -#define __PROCESS_NAME_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Sets the current process name. - * - * Warning: This leaks a string every time you call it. Use judiciously! - */ -void set_process_name(const char* process_name); - -/** Gets the current process name. */ -const char* get_process_name(void); - -#ifdef __cplusplus -} -#endif - -#endif /* __PROCESS_NAME_H */ diff --git a/third_party/android_system_core/include/cutils/properties.h b/third_party/android_system_core/include/cutils/properties.h deleted file mode 100644 index 24aa224f6..000000000 --- a/third_party/android_system_core/include/cutils/properties.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef __CUTILS_PROPERTIES_H -#define __CUTILS_PROPERTIES_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* System properties are *small* name value pairs managed by the -** property service. If your data doesn't fit in the provided -** space it is not appropriate for a system property. -** -** WARNING: system/bionic/include/sys/system_properties.h also defines -** these, but with different names. (TODO: fix that) -*/ -#define PROPERTY_KEY_MAX PROP_NAME_MAX -#define PROPERTY_VALUE_MAX PROP_VALUE_MAX - -/* property_get: returns the length of the value which will never be -** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated. -** (the length does not include the terminating zero). -** -** If the property read fails or returns an empty value, the default -** value is used (if nonnull). -*/ -int property_get(const char *key, char *value, const char *default_value); - -/* property_get_bool: returns the value of key coerced into a -** boolean. If the property is not set, then the default value is returned. -** -* The following is considered to be true (1): -** "1", "true", "y", "yes", "on" -** -** The following is considered to be false (0): -** "0", "false", "n", "no", "off" -** -** The conversion is whitespace-sensitive (e.g. " off" will not be false). -** -** If no property with this key is set (or the key is NULL) or the boolean -** conversion fails, the default value is returned. -**/ -int8_t property_get_bool(const char *key, int8_t default_value); - -/* property_get_int64: returns the value of key truncated and coerced into a -** int64_t. If the property is not set, then the default value is used. -** -** The numeric conversion is identical to strtoimax with the base inferred: -** - All digits up to the first non-digit characters are read -** - The longest consecutive prefix of digits is converted to a long -** -** Valid strings of digits are: -** - An optional sign character + or - -** - An optional prefix indicating the base (otherwise base 10 is assumed) -** -- 0 prefix is octal -** -- 0x / 0X prefix is hex -** -** Leading/trailing whitespace is ignored. Overflow/underflow will cause -** numeric conversion to fail. -** -** If no property with this key is set (or the key is NULL) or the numeric -** conversion fails, the default value is returned. -**/ -int64_t property_get_int64(const char *key, int64_t default_value); - -/* property_get_int32: returns the value of key truncated and coerced into an -** int32_t. If the property is not set, then the default value is used. -** -** The numeric conversion is identical to strtoimax with the base inferred: -** - All digits up to the first non-digit characters are read -** - The longest consecutive prefix of digits is converted to a long -** -** Valid strings of digits are: -** - An optional sign character + or - -** - An optional prefix indicating the base (otherwise base 10 is assumed) -** -- 0 prefix is octal -** -- 0x / 0X prefix is hex -** -** Leading/trailing whitespace is ignored. Overflow/underflow will cause -** numeric conversion to fail. -** -** If no property with this key is set (or the key is NULL) or the numeric -** conversion fails, the default value is returned. -**/ -int32_t property_get_int32(const char *key, int32_t default_value); - -/* property_set: returns 0 on success, < 0 on failure -*/ -int property_set(const char *key, const char *value); - -int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); - -#if defined(__BIONIC_FORTIFY) - -extern int __property_get_real(const char *, char *, const char *) - __asm__(__USER_LABEL_PREFIX__ "property_get"); -__errordecl(__property_get_too_small_error, "property_get() called with too small of a buffer"); - -__BIONIC_FORTIFY_INLINE -int property_get(const char *key, char *value, const char *default_value) { - size_t bos = __bos(value); - if (bos < PROPERTY_VALUE_MAX) { - __property_get_too_small_error(); - } - return __property_get_real(key, value, default_value); -} - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/third_party/android_system_core/include/cutils/qtaguid.h b/third_party/android_system_core/include/cutils/qtaguid.h deleted file mode 100644 index f8550fda8..000000000 --- a/third_party/android_system_core/include/cutils/qtaguid.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef __CUTILS_QTAGUID_H -#define __CUTILS_QTAGUID_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Set tags (and owning UIDs) for network sockets. -*/ -extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid); - -/* - * Untag a network socket before closing. -*/ -extern int qtaguid_untagSocket(int sockfd); - -/* - * For the given uid, switch counter sets. - * The kernel only keeps a limited number of sets. - * 2 for now. - */ -extern int qtaguid_setCounterSet(int counterSetNum, uid_t uid); - -/* - * Delete all tag info that relates to the given tag an uid. - * If the tag is 0, then ALL info about the uid is freeded. - * The delete data also affects active tagged socketd, which are - * then untagged. - * The calling process can only operate on its own tags. - * Unless it is part of the happy AID_NET_BW_ACCT group. - * In which case it can clobber everything. - */ -extern int qtaguid_deleteTagData(int tag, uid_t uid); - -/* - * Enable/disable qtaguid functionnality at a lower level. - * When pacified, the kernel will accept commands but do nothing. - */ -extern int qtaguid_setPacifier(int on); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_QTAG_UID_H */ diff --git a/third_party/android_system_core/include/cutils/record_stream.h b/third_party/android_system_core/include/cutils/record_stream.h deleted file mode 100644 index bfac87a53..000000000 --- a/third_party/android_system_core/include/cutils/record_stream.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -/* - * A simple utility for reading fixed records out of a stream fd - */ - -#ifndef _CUTILS_RECORD_STREAM_H -#define _CUTILS_RECORD_STREAM_H - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct RecordStream RecordStream; - -extern RecordStream *record_stream_new(int fd, size_t maxRecordLen); -extern void record_stream_free(RecordStream *p_rs); - -extern int record_stream_get_next (RecordStream *p_rs, void ** p_outRecord, - size_t *p_outRecordLen); - -#ifdef __cplusplus -} -#endif - - -#endif /*_CUTILS_RECORD_STREAM_H*/ - diff --git a/third_party/android_system_core/include/cutils/sched_policy.h b/third_party/android_system_core/include/cutils/sched_policy.h deleted file mode 100644 index 6a8d570b2..000000000 --- a/third_party/android_system_core/include/cutils/sched_policy.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef __CUTILS_SCHED_POLICY_H -#define __CUTILS_SCHED_POLICY_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */ -typedef enum { - SP_DEFAULT = -1, - SP_BACKGROUND = 0, - SP_FOREGROUND = 1, - SP_SYSTEM = 2, // can't be used with set_sched_policy() - SP_AUDIO_APP = 3, - SP_AUDIO_SYS = 4, - SP_CNT, - SP_MAX = SP_CNT - 1, - SP_SYSTEM_DEFAULT = SP_FOREGROUND, -} SchedPolicy; - -extern int set_cpuset_policy(int tid, SchedPolicy policy); - -/* Assign thread tid to the cgroup associated with the specified policy. - * If the thread is a thread group leader, that is it's gettid() == getpid(), - * then the other threads in the same thread group are _not_ affected. - * On platforms which support gettid(), zero tid means current thread. - * Return value: 0 for success, or -errno for error. - */ -extern int set_sched_policy(int tid, SchedPolicy policy); - -/* Return the policy associated with the cgroup of thread tid via policy pointer. - * On platforms which support gettid(), zero tid means current thread. - * Return value: 0 for success, or -1 for error and set errno. - */ -extern int get_sched_policy(int tid, SchedPolicy *policy); - -/* Return a displayable string corresponding to policy. - * Return value: non-NULL NUL-terminated name of unspecified length; - * the caller is responsible for displaying the useful part of the string. - */ -extern const char *get_sched_policy_name(SchedPolicy policy); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_SCHED_POLICY_H */ diff --git a/third_party/android_system_core/include/cutils/sockets.h b/third_party/android_system_core/include/cutils/sockets.h deleted file mode 100644 index f8076ca45..000000000 --- a/third_party/android_system_core/include/cutils/sockets.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef __CUTILS_SOCKETS_H -#define __CUTILS_SOCKETS_H - -#include -#include -#include -#include -#include - -#ifdef HAVE_WINSOCK -#include -typedef int socklen_t; -#else -#include -#endif - -#define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_" -#define ANDROID_SOCKET_DIR "/dev/socket" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * android_get_control_socket - simple helper function to get the file - * descriptor of our init-managed Unix domain socket. `name' is the name of the - * socket, as given in init.rc. Returns -1 on error. - * - * This is inline and not in libcutils proper because we want to use this in - * third-party daemons with minimal modification. - */ -static inline int android_get_control_socket(const char *name) -{ - char key[64]; - snprintf(key, sizeof(key), ANDROID_SOCKET_ENV_PREFIX "%s", name); - - const char* val = getenv(key); - if (!val) { - return -1; - } - - errno = 0; - int fd = strtol(val, NULL, 10); - if (errno) { - return -1; - } - - return fd; -} - -/* - * See also android.os.LocalSocketAddress.Namespace - */ -// Linux "abstract" (non-filesystem) namespace -#define ANDROID_SOCKET_NAMESPACE_ABSTRACT 0 -// Android "reserved" (/dev/socket) namespace -#define ANDROID_SOCKET_NAMESPACE_RESERVED 1 -// Normal filesystem namespace -#define ANDROID_SOCKET_NAMESPACE_FILESYSTEM 2 - -extern int socket_loopback_client(int port, int type); -extern int socket_network_client(const char *host, int port, int type); -extern int socket_network_client_timeout(const char *host, int port, int type, - int timeout); -extern int socket_loopback_server(int port, int type); -extern int socket_local_server(const char *name, int namespaceId, int type); -extern int socket_local_server_bind(int s, const char *name, int namespaceId); -extern int socket_local_client_connect(int fd, - const char *name, int namespaceId, int type); -extern int socket_local_client(const char *name, int namespaceId, int type); -extern int socket_inaddr_any_server(int port, int type); - -/* - * socket_peer_is_trusted - Takes a socket which is presumed to be a - * connected local socket (e.g. AF_LOCAL) and returns whether the peer - * (the userid that owns the process on the other end of that socket) - * is one of the two trusted userids, root or shell. - * - * Note: This only works as advertised on the Android OS and always - * just returns true when called on other operating systems. - */ -extern bool socket_peer_is_trusted(int fd); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_SOCKETS_H */ diff --git a/third_party/android_system_core/include/cutils/str_parms.h b/third_party/android_system_core/include/cutils/str_parms.h deleted file mode 100644 index aa1435a08..000000000 --- a/third_party/android_system_core/include/cutils/str_parms.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef __CUTILS_STR_PARMS_H -#define __CUTILS_STR_PARMS_H - -#include -#include - -__BEGIN_DECLS - -struct str_parms; - -struct str_parms *str_parms_create(void); -struct str_parms *str_parms_create_str(const char *_string); -void str_parms_destroy(struct str_parms *str_parms); - -void str_parms_del(struct str_parms *str_parms, const char *key); - -int str_parms_add_str(struct str_parms *str_parms, const char *key, - const char *value); -int str_parms_add_int(struct str_parms *str_parms, const char *key, int value); - -int str_parms_add_float(struct str_parms *str_parms, const char *key, - float value); - -// Returns non-zero if the str_parms contains the specified key. -int str_parms_has_key(struct str_parms *str_parms, const char *key); - -// Gets value associated with the specified key (if present), placing it in the buffer -// pointed to by the out_val parameter. Returns the length of the returned string value. -// If 'key' isn't in the parms, then return -ENOENT (-2) and leave 'out_val' untouched. -int str_parms_get_str(struct str_parms *str_parms, const char *key, - char *out_val, int len); -int str_parms_get_int(struct str_parms *str_parms, const char *key, - int *out_val); -int str_parms_get_float(struct str_parms *str_parms, const char *key, - float *out_val); - -char *str_parms_to_str(struct str_parms *str_parms); - -/* debug */ -void str_parms_dump(struct str_parms *str_parms); - -__END_DECLS - -#endif /* __CUTILS_STR_PARMS_H */ diff --git a/third_party/android_system_core/include/cutils/threads.h b/third_party/android_system_core/include/cutils/threads.h deleted file mode 100644 index 572749407..000000000 --- a/third_party/android_system_core/include/cutils/threads.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_CUTILS_THREADS_H -#define _LIBS_CUTILS_THREADS_H - -#include - -#if !defined(_WIN32) -#include -#else -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/***********************************************************************/ -/***********************************************************************/ -/***** *****/ -/***** local thread storage *****/ -/***** *****/ -/***********************************************************************/ -/***********************************************************************/ - -extern pid_t gettid(); - -#if !defined(_WIN32) - -typedef struct { - pthread_mutex_t lock; - int has_tls; - pthread_key_t tls; -} thread_store_t; - -#define THREAD_STORE_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, 0 } - -#else // !defined(_WIN32) - -typedef struct { - int lock_init; - int has_tls; - DWORD tls; - CRITICAL_SECTION lock; -} thread_store_t; - -#define THREAD_STORE_INITIALIZER { 0, 0, 0, {0, 0, 0, 0, 0, 0} } - -#endif // !defined(_WIN32) - -typedef void (*thread_store_destruct_t)(void* value); - -extern void* thread_store_get(thread_store_t* store); - -extern void thread_store_set(thread_store_t* store, - void* value, - thread_store_destruct_t destroy); - -/***********************************************************************/ -/***********************************************************************/ -/***** *****/ -/***** mutexes *****/ -/***** *****/ -/***********************************************************************/ -/***********************************************************************/ - -#if !defined(_WIN32) - -typedef pthread_mutex_t mutex_t; - -#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - -static __inline__ void mutex_lock(mutex_t* lock) -{ - pthread_mutex_lock(lock); -} -static __inline__ void mutex_unlock(mutex_t* lock) -{ - pthread_mutex_unlock(lock); -} -static __inline__ int mutex_init(mutex_t* lock) -{ - return pthread_mutex_init(lock, NULL); -} -static __inline__ void mutex_destroy(mutex_t* lock) -{ - pthread_mutex_destroy(lock); -} - -#else // !defined(_WIN32) - -typedef struct { - int init; - CRITICAL_SECTION lock[1]; -} mutex_t; - -#define MUTEX_INITIALIZER { 0, {{ NULL, 0, 0, NULL, NULL, 0 }} } - -static __inline__ void mutex_lock(mutex_t* lock) -{ - if (!lock->init) { - lock->init = 1; - InitializeCriticalSection( lock->lock ); - lock->init = 2; - } else while (lock->init != 2) - Sleep(10); - - EnterCriticalSection(lock->lock); -} - -static __inline__ void mutex_unlock(mutex_t* lock) -{ - LeaveCriticalSection(lock->lock); -} -static __inline__ int mutex_init(mutex_t* lock) -{ - InitializeCriticalSection(lock->lock); - lock->init = 2; - return 0; -} -static __inline__ void mutex_destroy(mutex_t* lock) -{ - if (lock->init) { - lock->init = 0; - DeleteCriticalSection(lock->lock); - } -} -#endif // !defined(_WIN32) - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBS_CUTILS_THREADS_H */ diff --git a/third_party/android_system_core/include/cutils/trace.h b/third_party/android_system_core/include/cutils/trace.h deleted file mode 100644 index e4ed17983..000000000 --- a/third_party/android_system_core/include/cutils/trace.h +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef _LIBS_CUTILS_TRACE_H -#define _LIBS_CUTILS_TRACE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -__BEGIN_DECLS - -/** - * The ATRACE_TAG macro can be defined before including this header to trace - * using one of the tags defined below. It must be defined to one of the - * following ATRACE_TAG_* macros. The trace tag is used to filter tracing in - * userland to avoid some of the runtime cost of tracing when it is not desired. - * - * Defining ATRACE_TAG to be ATRACE_TAG_ALWAYS will result in the tracing always - * being enabled - this should ONLY be done for debug code, as userland tracing - * has a performance cost even when the trace is not being recorded. Defining - * ATRACE_TAG to be ATRACE_TAG_NEVER or leaving ATRACE_TAG undefined will result - * in the tracing always being disabled. - * - * ATRACE_TAG_HAL should be bitwise ORed with the relevant tags for tracing - * within a hardware module. For example a camera hardware module would set: - * #define ATRACE_TAG (ATRACE_TAG_CAMERA | ATRACE_TAG_HAL) - * - * Keep these in sync with frameworks/base/core/java/android/os/Trace.java. - */ -#define ATRACE_TAG_NEVER 0 // This tag is never enabled. -#define ATRACE_TAG_ALWAYS (1<<0) // This tag is always enabled. -#define ATRACE_TAG_GRAPHICS (1<<1) -#define ATRACE_TAG_INPUT (1<<2) -#define ATRACE_TAG_VIEW (1<<3) -#define ATRACE_TAG_WEBVIEW (1<<4) -#define ATRACE_TAG_WINDOW_MANAGER (1<<5) -#define ATRACE_TAG_ACTIVITY_MANAGER (1<<6) -#define ATRACE_TAG_SYNC_MANAGER (1<<7) -#define ATRACE_TAG_AUDIO (1<<8) -#define ATRACE_TAG_VIDEO (1<<9) -#define ATRACE_TAG_CAMERA (1<<10) -#define ATRACE_TAG_HAL (1<<11) -#define ATRACE_TAG_APP (1<<12) -#define ATRACE_TAG_RESOURCES (1<<13) -#define ATRACE_TAG_DALVIK (1<<14) -#define ATRACE_TAG_RS (1<<15) -#define ATRACE_TAG_BIONIC (1<<16) -#define ATRACE_TAG_POWER (1<<17) -#define ATRACE_TAG_LAST ATRACE_TAG_POWER - -// Reserved for initialization. -#define ATRACE_TAG_NOT_READY (1LL<<63) - -#define ATRACE_TAG_VALID_MASK ((ATRACE_TAG_LAST - 1) | ATRACE_TAG_LAST) - -#ifndef ATRACE_TAG -#define ATRACE_TAG ATRACE_TAG_NEVER -#elif ATRACE_TAG > ATRACE_TAG_VALID_MASK -#error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h -#endif - -/** - * Opens the trace file for writing and reads the property for initial tags. - * The atrace.tags.enableflags property sets the tags to trace. - * This function should not be explicitly called, the first call to any normal - * trace function will cause it to be run safely. - */ -void atrace_setup(); - -/** - * If tracing is ready, set atrace_enabled_tags to the system property - * debug.atrace.tags.enableflags. Can be used as a sysprop change callback. - */ -void atrace_update_tags(); - -/** - * Set whether the process is debuggable. By default the process is not - * considered debuggable. If the process is not debuggable then application- - * level tracing is not allowed unless the ro.debuggable system property is - * set to '1'. - */ -void atrace_set_debuggable(bool debuggable); - -/** - * Set whether tracing is enabled for the current process. This is used to - * prevent tracing within the Zygote process. - */ -void atrace_set_tracing_enabled(bool enabled); - -/** - * Flag indicating whether setup has been completed, initialized to 0. - * Nonzero indicates setup has completed. - * Note: This does NOT indicate whether or not setup was successful. - */ -extern atomic_bool atrace_is_ready; - -/** - * Set of ATRACE_TAG flags to trace for, initialized to ATRACE_TAG_NOT_READY. - * A value of zero indicates setup has failed. - * Any other nonzero value indicates setup has succeeded, and tracing is on. - */ -extern uint64_t atrace_enabled_tags; - -/** - * Handle to the kernel's trace buffer, initialized to -1. - * Any other value indicates setup has succeeded, and is a valid fd for tracing. - */ -extern int atrace_marker_fd; - -/** - * atrace_init readies the process for tracing by opening the trace_marker file. - * Calling any trace function causes this to be run, so calling it is optional. - * This can be explicitly run to avoid setup delay on first trace function. - */ -#define ATRACE_INIT() atrace_init() -static inline void atrace_init() -{ - if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) { - atrace_setup(); - } -} - -/** - * Get the mask of all tags currently enabled. - * It can be used as a guard condition around more expensive trace calculations. - * Every trace function calls this, which ensures atrace_init is run. - */ -#define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags() -static inline uint64_t atrace_get_enabled_tags() -{ - atrace_init(); - return atrace_enabled_tags; -} - -/** - * Test if a given tag is currently enabled. - * Returns nonzero if the tag is enabled, otherwise zero. - * It can be used as a guard condition around more expensive trace calculations. - */ -#define ATRACE_ENABLED() atrace_is_tag_enabled(ATRACE_TAG) -static inline uint64_t atrace_is_tag_enabled(uint64_t tag) -{ - return atrace_get_enabled_tags() & tag; -} - -/** - * Trace the beginning of a context. name is used to identify the context. - * This is often used to time function execution. - */ -#define ATRACE_BEGIN(name) atrace_begin(ATRACE_TAG, name) -static inline void atrace_begin(uint64_t tag, const char* name) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_begin_body(const char*); - atrace_begin_body(name); - } -} - -/** - * Trace the end of a context. - * This should match up (and occur after) a corresponding ATRACE_BEGIN. - */ -#define ATRACE_END() atrace_end(ATRACE_TAG) -static inline void atrace_end(uint64_t tag) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - char c = 'E'; - write(atrace_marker_fd, &c, 1); - } -} - -/** - * Trace the beginning of an asynchronous event. Unlike ATRACE_BEGIN/ATRACE_END - * contexts, asynchronous events do not need to be nested. The name describes - * the event, and the cookie provides a unique identifier for distinguishing - * simultaneous events. The name and cookie used to begin an event must be - * used to end it. - */ -#define ATRACE_ASYNC_BEGIN(name, cookie) \ - atrace_async_begin(ATRACE_TAG, name, cookie) -static inline void atrace_async_begin(uint64_t tag, const char* name, - int32_t cookie) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_async_begin_body(const char*, int32_t); - atrace_async_begin_body(name, cookie); - } -} - -/** - * Trace the end of an asynchronous event. - * This should have a corresponding ATRACE_ASYNC_BEGIN. - */ -#define ATRACE_ASYNC_END(name, cookie) atrace_async_end(ATRACE_TAG, name, cookie) -static inline void atrace_async_end(uint64_t tag, const char* name, int32_t cookie) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_async_end_body(const char*, int32_t); - atrace_async_end_body(name, cookie); - } -} - -/** - * Traces an integer counter value. name is used to identify the counter. - * This can be used to track how a value changes over time. - */ -#define ATRACE_INT(name, value) atrace_int(ATRACE_TAG, name, value) -static inline void atrace_int(uint64_t tag, const char* name, int32_t value) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_int_body(const char*, int32_t); - atrace_int_body(name, value); - } -} - -/** - * Traces a 64-bit integer counter value. name is used to identify the - * counter. This can be used to track how a value changes over time. - */ -#define ATRACE_INT64(name, value) atrace_int64(ATRACE_TAG, name, value) -static inline void atrace_int64(uint64_t tag, const char* name, int64_t value) -{ - if (CC_UNLIKELY(atrace_is_tag_enabled(tag))) { - void atrace_int64_body(const char*, int64_t); - atrace_int64_body(name, value); - } -} - -__END_DECLS - -#endif // _LIBS_CUTILS_TRACE_H diff --git a/third_party/android_system_core/include/cutils/uevent.h b/third_party/android_system_core/include/cutils/uevent.h deleted file mode 100644 index da1c2aae6..000000000 --- a/third_party/android_system_core/include/cutils/uevent.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef __CUTILS_UEVENT_H -#define __CUTILS_UEVENT_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int uevent_open_socket(int buf_sz, bool passcred); -ssize_t uevent_kernel_multicast_recv(int socket, void *buffer, size_t length); -ssize_t uevent_kernel_multicast_uid_recv(int socket, void *buffer, size_t length, uid_t *uid); -ssize_t uevent_kernel_recv(int socket, void *buffer, size_t length, bool require_group, uid_t *uid); - -#ifdef __cplusplus -} -#endif - -#endif /* __CUTILS_UEVENT_H */ diff --git a/third_party/android_system_core/include/log/event_tag_map.h b/third_party/android_system_core/include/log/event_tag_map.h deleted file mode 100644 index 1653c61e9..000000000 --- a/third_party/android_system_core/include/log/event_tag_map.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_CUTILS_EVENTTAGMAP_H -#define _LIBS_CUTILS_EVENTTAGMAP_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags" - -struct EventTagMap; -typedef struct EventTagMap EventTagMap; - -/* - * Open the specified file as an event log tag map. - * - * Returns NULL on failure. - */ -EventTagMap* android_openEventTagMap(const char* fileName); - -/* - * Close the map. - */ -void android_closeEventTagMap(EventTagMap* map); - -/* - * Look up a tag by index. Returns the tag string, or NULL if not found. - */ -const char* android_lookupEventTag(const EventTagMap* map, int tag); - -#ifdef __cplusplus -} -#endif - -#endif /*_LIBS_CUTILS_EVENTTAGMAP_H*/ diff --git a/third_party/android_system_core/include/log/log.h b/third_party/android_system_core/include/log/log.h deleted file mode 100644 index 63a441a68..000000000 --- a/third_party/android_system_core/include/log/log.h +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright (C) 2005-2014 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. - */ - -// -// C/C++ logging functions. See the logging documentation for API details. -// -// We'd like these to be available from C code (in case we import some from -// somewhere), so this has a C interface. -// -// The output will be correct when the log file is shared between multiple -// threads and/or multiple processes so long as the operating system -// supports O_APPEND. These calls have mutex-protected data structures -// and so are NOT reentrant. Do not use LOG in a signal handler. -// -#ifndef _LIBS_LOG_LOG_H -#define _LIBS_LOG_LOG_H - -#include -#include -#include -#include -#include - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -// --------------------------------------------------------------------- - -/* - * Normally we strip ALOGV (VERBOSE messages) from release builds. - * You can modify this (for example with "#define LOG_NDEBUG 0" - * at the top of your source file) to change that behavior. - */ -#ifndef LOG_NDEBUG -#ifdef NDEBUG -#define LOG_NDEBUG 1 -#else -#define LOG_NDEBUG 0 -#endif -#endif - -/* - * This is the local tag used for the following simplified - * logging macros. You can change this preprocessor definition - * before using the other macros to change the tag. - */ -#ifndef LOG_TAG -#define LOG_TAG NULL -#endif - -// --------------------------------------------------------------------- - -#ifndef __predict_false -#define __predict_false(exp) __builtin_expect((exp) != 0, 0) -#endif - -/* - * -DLINT_RLOG in sources that you want to enforce that all logging - * goes to the radio log buffer. If any logging goes to any of the other - * log buffers, there will be a compile or link error to highlight the - * problem. This is not a replacement for a full audit of the code since - * this only catches compiled code, not ifdef'd debug code. Options to - * defining this, either temporarily to do a spot check, or permanently - * to enforce, in all the communications trees; We have hopes to ensure - * that by supplying just the radio log buffer that the communications - * teams will have their one-stop shop for triaging issues. - */ -#ifndef LINT_RLOG - -/* - * Simplified macro to send a verbose log message using the current LOG_TAG. - */ -#ifndef ALOGV -#define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define ALOGV(...) do { if (0) { __ALOGV(__VA_ARGS__); } } while (0) -#else -#define ALOGV(...) __ALOGV(__VA_ARGS__) -#endif -#endif - -#ifndef ALOGV_IF -#if LOG_NDEBUG -#define ALOGV_IF(cond, ...) ((void)0) -#else -#define ALOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug log message using the current LOG_TAG. - */ -#ifndef ALOGD -#define ALOGD(...) ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGD_IF -#define ALOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info log message using the current LOG_TAG. - */ -#ifndef ALOGI -#define ALOGI(...) ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGI_IF -#define ALOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning log message using the current LOG_TAG. - */ -#ifndef ALOGW -#define ALOGW(...) ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGW_IF -#define ALOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error log message using the current LOG_TAG. - */ -#ifndef ALOGE -#define ALOGE(...) ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef ALOGE_IF -#define ALOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -// --------------------------------------------------------------------- - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * verbose priority. - */ -#ifndef IF_ALOGV -#if LOG_NDEBUG -#define IF_ALOGV() if (false) -#else -#define IF_ALOGV() IF_ALOG(LOG_VERBOSE, LOG_TAG) -#endif -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * debug priority. - */ -#ifndef IF_ALOGD -#define IF_ALOGD() IF_ALOG(LOG_DEBUG, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * info priority. - */ -#ifndef IF_ALOGI -#define IF_ALOGI() IF_ALOG(LOG_INFO, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * warn priority. - */ -#ifndef IF_ALOGW -#define IF_ALOGW() IF_ALOG(LOG_WARN, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * error priority. - */ -#ifndef IF_ALOGE -#define IF_ALOGE() IF_ALOG(LOG_ERROR, LOG_TAG) -#endif - - -// --------------------------------------------------------------------- - -/* - * Simplified macro to send a verbose system log message using the current LOG_TAG. - */ -#ifndef SLOGV -#define __SLOGV(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0) -#else -#define SLOGV(...) __SLOGV(__VA_ARGS__) -#endif -#endif - -#ifndef SLOGV_IF -#if LOG_NDEBUG -#define SLOGV_IF(cond, ...) ((void)0) -#else -#define SLOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug system log message using the current LOG_TAG. - */ -#ifndef SLOGD -#define SLOGD(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGD_IF -#define SLOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info system log message using the current LOG_TAG. - */ -#ifndef SLOGI -#define SLOGI(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGI_IF -#define SLOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning system log message using the current LOG_TAG. - */ -#ifndef SLOGW -#define SLOGW(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGW_IF -#define SLOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error system log message using the current LOG_TAG. - */ -#ifndef SLOGE -#define SLOGE(...) \ - ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef SLOGE_IF -#define SLOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -#endif /* !LINT_RLOG */ - -// --------------------------------------------------------------------- - -/* - * Simplified macro to send a verbose radio log message using the current LOG_TAG. - */ -#ifndef RLOGV -#define __RLOGV(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#if LOG_NDEBUG -#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0) -#else -#define RLOGV(...) __RLOGV(__VA_ARGS__) -#endif -#endif - -#ifndef RLOGV_IF -#if LOG_NDEBUG -#define RLOGV_IF(cond, ...) ((void)0) -#else -#define RLOGV_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif -#endif - -/* - * Simplified macro to send a debug radio log message using the current LOG_TAG. - */ -#ifndef RLOGD -#define RLOGD(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGD_IF -#define RLOGD_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an info radio log message using the current LOG_TAG. - */ -#ifndef RLOGI -#define RLOGI(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGI_IF -#define RLOGI_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send a warning radio log message using the current LOG_TAG. - */ -#ifndef RLOGW -#define RLOGW(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGW_IF -#define RLOGW_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - -/* - * Simplified macro to send an error radio log message using the current LOG_TAG. - */ -#ifndef RLOGE -#define RLOGE(...) \ - ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef RLOGE_IF -#define RLOGE_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \ - : (void)0 ) -#endif - - -// --------------------------------------------------------------------- - -/* - * Log a fatal error. If the given condition fails, this stops program - * execution like a normal assertion, but also generating the given message. - * It is NOT stripped from release builds. Note that the condition test - * is -inverted- from the normal assert() semantics. - */ -#ifndef LOG_ALWAYS_FATAL_IF -#define LOG_ALWAYS_FATAL_IF(cond, ...) \ - ( (__predict_false(cond)) \ - ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \ - : (void)0 ) -#endif - -#ifndef LOG_ALWAYS_FATAL -#define LOG_ALWAYS_FATAL(...) \ - ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) ) -#endif - -/* - * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that - * are stripped out of release builds. - */ -#if LOG_NDEBUG - -#ifndef LOG_FATAL_IF -#define LOG_FATAL_IF(cond, ...) ((void)0) -#endif -#ifndef LOG_FATAL -#define LOG_FATAL(...) ((void)0) -#endif - -#else - -#ifndef LOG_FATAL_IF -#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__) -#endif -#ifndef LOG_FATAL -#define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__) -#endif - -#endif - -/* - * Assertion that generates a log message when the assertion fails. - * Stripped out of release builds. Uses the current LOG_TAG. - */ -#ifndef ALOG_ASSERT -#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__) -//#define ALOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) -#endif - -// --------------------------------------------------------------------- - -/* - * Basic log message macro. - * - * Example: - * ALOG(LOG_WARN, NULL, "Failed with error %d", errno); - * - * The second argument may be NULL or "" to indicate the "global" tag. - */ -#ifndef ALOG -#define ALOG(priority, tag, ...) \ - LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to specify a number for the priority. - */ -#ifndef LOG_PRI -#define LOG_PRI(priority, tag, ...) \ - android_printLog(priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to pass in a varargs ("args" is a va_list). - */ -#ifndef LOG_PRI_VA -#define LOG_PRI_VA(priority, tag, fmt, args) \ - android_vprintLog(priority, NULL, tag, fmt, args) -#endif - -/* - * Conditional given a desired logging priority and tag. - */ -#ifndef IF_ALOG -#define IF_ALOG(priority, tag) \ - if (android_testLog(ANDROID_##priority, tag)) -#endif - -// --------------------------------------------------------------------- - -/* - * Event logging. - */ - -/* - * Event log entry types. These must match up with the declarations in - * java/android/android/util/EventLog.java. - */ -typedef enum { - EVENT_TYPE_INT = 0, - EVENT_TYPE_LONG = 1, - EVENT_TYPE_STRING = 2, - EVENT_TYPE_LIST = 3, - EVENT_TYPE_FLOAT = 4, -} AndroidEventLogType; -#define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType) -#define typeof_AndroidEventLogType unsigned char - -#ifndef LOG_EVENT_INT -#define LOG_EVENT_INT(_tag, _value) { \ - int intBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, \ - sizeof(intBuf)); \ - } -#endif -#ifndef LOG_EVENT_LONG -#define LOG_EVENT_LONG(_tag, _value) { \ - long long longBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, \ - sizeof(longBuf)); \ - } -#endif -#ifndef LOG_EVENT_FLOAT -#define LOG_EVENT_FLOAT(_tag, _value) { \ - float floatBuf = _value; \ - (void) android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \ - sizeof(floatBuf)); \ - } -#endif -#ifndef LOG_EVENT_STRING -#define LOG_EVENT_STRING(_tag, _value) \ - (void) __android_log_bswrite(_tag, _value); -#endif -/* TODO: something for LIST */ - -/* - * =========================================================================== - * - * The stuff in the rest of this file should not be used directly. - */ - -#define android_printLog(prio, tag, fmt...) \ - __android_log_print(prio, tag, fmt) - -#define android_vprintLog(prio, cond, tag, fmt...) \ - __android_log_vprint(prio, tag, fmt) - -/* XXX Macros to work around syntax errors in places where format string - * arg is not passed to ALOG_ASSERT, LOG_ALWAYS_FATAL or LOG_ALWAYS_FATAL_IF - * (happens only in debug builds). - */ - -/* Returns 2nd arg. Used to substitute default value if caller's vararg list - * is empty. - */ -#define __android_second(dummy, second, ...) second - -/* If passed multiple args, returns ',' followed by all but 1st arg, otherwise - * returns nothing. - */ -#define __android_rest(first, ...) , ## __VA_ARGS__ - -#define android_printAssert(cond, tag, fmt...) \ - __android_log_assert(cond, tag, \ - __android_second(0, ## fmt, NULL) __android_rest(fmt)) - -#define android_writeLog(prio, tag, text) \ - __android_log_write(prio, tag, text) - -#define android_bWriteLog(tag, payload, len) \ - __android_log_bwrite(tag, payload, len) -#define android_btWriteLog(tag, type, payload, len) \ - __android_log_btwrite(tag, type, payload, len) - -#define android_errorWriteLog(tag, subTag) \ - __android_log_error_write(tag, subTag, -1, NULL, 0) - -#define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \ - __android_log_error_write(tag, subTag, uid, data, dataLen) - -/* - * IF_ALOG uses android_testLog, but IF_ALOG can be overridden. - * android_testLog will remain constant in its purpose as a wrapper - * for Android logging filter policy, and can be subject to - * change. It can be reused by the developers that override - * IF_ALOG as a convenient means to reimplement their policy - * over Android. - */ -#if LOG_NDEBUG /* Production */ -#define android_testLog(prio, tag) \ - (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0) -#else -#define android_testLog(prio, tag) \ - (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0) -#endif - -// TODO: remove these prototypes and their users -#define android_writevLog(vec,num) do{}while(0) -#define android_write1Log(str,len) do{}while (0) -#define android_setMinPriority(tag, prio) do{}while(0) -//#define android_logToCallback(func) do{}while(0) -#define android_logToFile(tag, file) (0) -#define android_logToFd(tag, fd) (0) - -#ifndef log_id_t_defined -#define log_id_t_defined - -typedef enum log_id { - LOG_ID_MIN = 0, - -#ifndef LINT_RLOG - LOG_ID_MAIN = 0, -#endif - LOG_ID_RADIO = 1, -#ifndef LINT_RLOG - LOG_ID_EVENTS = 2, - LOG_ID_SYSTEM = 3, - LOG_ID_CRASH = 4, - LOG_ID_KERNEL = 5, -#endif - - LOG_ID_MAX -} log_id_t; -#endif -#define sizeof_log_id_t sizeof(typeof_log_id_t) -#define typeof_log_id_t unsigned char - -/* - * Use the per-tag properties "log.tag." to generate a runtime - * result of non-zero to expose a log. - */ -int __android_log_is_loggable(int prio, const char *tag, int def); - -int __android_log_error_write(int tag, const char *subTag, int32_t uid, const char *data, - uint32_t dataLen); - -/* - * Send a simple string to the log. - */ -int __android_log_buf_write(int bufID, int prio, const char *tag, const char *text); -int __android_log_buf_print(int bufID, int prio, const char *tag, const char *fmt, ...) -#if defined(__GNUC__) - __attribute__((__format__(printf, 4, 5))) -#endif - ; - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBS_LOG_LOG_H */ diff --git a/third_party/android_system_core/include/log/log_read.h b/third_party/android_system_core/include/log/log_read.h deleted file mode 100644 index 1b70affc3..000000000 --- a/third_party/android_system_core/include/log/log_read.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2013-2014 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. - */ - -#ifndef _LIBS_LOG_LOG_READ_H -#define _LIBS_LOG_LOG_READ_H - -#include -#include - -/* struct log_time is a wire-format variant of struct timespec */ -#define NS_PER_SEC 1000000000ULL - -#ifdef __cplusplus - -// NB: do NOT define a copy constructor. This will result in structure -// no longer being compatible with pass-by-value which is desired -// efficient behavior. Also, pass-by-reference breaks C/C++ ABI. -struct log_time { -public: - uint32_t tv_sec; // good to Feb 5 2106 - uint32_t tv_nsec; - - static const uint32_t tv_sec_max = 0xFFFFFFFFUL; - static const uint32_t tv_nsec_max = 999999999UL; - - log_time(const timespec &T) - { - tv_sec = T.tv_sec; - tv_nsec = T.tv_nsec; - } - log_time(uint32_t sec, uint32_t nsec) - { - tv_sec = sec; - tv_nsec = nsec; - } - static const timespec EPOCH; - log_time() - { - } - log_time(clockid_t id) - { - timespec T; - clock_gettime(id, &T); - tv_sec = T.tv_sec; - tv_nsec = T.tv_nsec; - } - log_time(const char *T) - { - const uint8_t *c = (const uint8_t *) T; - tv_sec = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24); - tv_nsec = c[4] | (c[5] << 8) | (c[6] << 16) | (c[7] << 24); - } - - // timespec - bool operator== (const timespec &T) const - { - return (tv_sec == static_cast(T.tv_sec)) - && (tv_nsec == static_cast(T.tv_nsec)); - } - bool operator!= (const timespec &T) const - { - return !(*this == T); - } - bool operator< (const timespec &T) const - { - return (tv_sec < static_cast(T.tv_sec)) - || ((tv_sec == static_cast(T.tv_sec)) - && (tv_nsec < static_cast(T.tv_nsec))); - } - bool operator>= (const timespec &T) const - { - return !(*this < T); - } - bool operator> (const timespec &T) const - { - return (tv_sec > static_cast(T.tv_sec)) - || ((tv_sec == static_cast(T.tv_sec)) - && (tv_nsec > static_cast(T.tv_nsec))); - } - bool operator<= (const timespec &T) const - { - return !(*this > T); - } - log_time operator-= (const timespec &T); - log_time operator- (const timespec &T) const - { - log_time local(*this); - return local -= T; - } - log_time operator+= (const timespec &T); - log_time operator+ (const timespec &T) const - { - log_time local(*this); - return local += T; - } - - // log_time - bool operator== (const log_time &T) const - { - return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec); - } - bool operator!= (const log_time &T) const - { - return !(*this == T); - } - bool operator< (const log_time &T) const - { - return (tv_sec < T.tv_sec) - || ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec)); - } - bool operator>= (const log_time &T) const - { - return !(*this < T); - } - bool operator> (const log_time &T) const - { - return (tv_sec > T.tv_sec) - || ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec)); - } - bool operator<= (const log_time &T) const - { - return !(*this > T); - } - log_time operator-= (const log_time &T); - log_time operator- (const log_time &T) const - { - log_time local(*this); - return local -= T; - } - log_time operator+= (const log_time &T); - log_time operator+ (const log_time &T) const - { - log_time local(*this); - return local += T; - } - - uint64_t nsec() const - { - return static_cast(tv_sec) * NS_PER_SEC + tv_nsec; - } - - static const char default_format[]; - - // Add %#q for the fraction of a second to the standard library functions - char *strptime(const char *s, const char *format = default_format); -} __attribute__((__packed__)); - -#else - -typedef struct log_time { - uint32_t tv_sec; - uint32_t tv_nsec; -} __attribute__((__packed__)) log_time; - -#endif - -#endif /* define _LIBS_LOG_LOG_READ_H */ diff --git a/third_party/android_system_core/include/log/logd.h b/third_party/android_system_core/include/log/logd.h deleted file mode 100644 index 0fe515f2a..000000000 --- a/third_party/android_system_core/include/log/logd.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -#ifndef _ANDROID_CUTILS_LOGD_H -#define _ANDROID_CUTILS_LOGD_H - -/* the stable/frozen log-related definitions have been - * moved to this header, which is exposed by the NDK - */ -#include - -/* the rest is only used internally by the system */ -#if !defined(_WIN32) -#include -#endif -#include -#include -#include -#include -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -int __android_log_bwrite(int32_t tag, const void *payload, size_t len); -int __android_log_btwrite(int32_t tag, char type, const void *payload, - size_t len); -int __android_log_bswrite(int32_t tag, const char *payload); - -#ifdef __cplusplus -} -#endif - -#endif /* _LOGD_H */ diff --git a/third_party/android_system_core/include/log/logger.h b/third_party/android_system_core/include/log/logger.h deleted file mode 100644 index f030dab5a..000000000 --- a/third_party/android_system_core/include/log/logger.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -** -** Copyright 2007-2014, The Android Open Source Project -** -** This file is dual licensed. It may be redistributed and/or modified -** under the terms of the Apache 2.0 License OR version 2 of the GNU -** General Public License. -*/ - -#ifndef _LIBS_LOG_LOGGER_H -#define _LIBS_LOG_LOGGER_H - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * The userspace structure for version 1 of the logger_entry ABI. - * This structure is returned to userspace by the kernel logger - * driver unless an upgrade to a newer ABI version is requested. - */ -struct logger_entry { - uint16_t len; /* length of the payload */ - uint16_t __pad; /* no matter what, we get 2 bytes of padding */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -/* - * The userspace structure for version 2 of the logger_entry ABI. - * This structure is returned to userspace if ioctl(LOGGER_SET_VERSION) - * is called with version==2; or used with the user space log daemon. - */ -struct logger_entry_v2 { - uint16_t len; /* length of the payload */ - uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - uint32_t euid; /* effective UID of logger */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -struct logger_entry_v3 { - uint16_t len; /* length of the payload */ - uint16_t hdr_size; /* sizeof(struct logger_entry_v3) */ - int32_t pid; /* generating process's pid */ - int32_t tid; /* generating process's tid */ - int32_t sec; /* seconds since Epoch */ - int32_t nsec; /* nanoseconds */ - uint32_t lid; /* log id of the payload */ - char msg[0]; /* the entry's payload */ -} __attribute__((__packed__)); - -/* - * The maximum size of the log entry payload that can be - * written to the logger. An attempt to write more than - * this amount will result in a truncated log entry. - */ -#define LOGGER_ENTRY_MAX_PAYLOAD 4076 - -/* - * The maximum size of a log entry which can be read from the - * kernel logger driver. An attempt to read less than this amount - * may result in read() returning EINVAL. - */ -#define LOGGER_ENTRY_MAX_LEN (5*1024) - -#define NS_PER_SEC 1000000000ULL - -struct log_msg { - union { - unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1]; - struct logger_entry_v3 entry; - struct logger_entry_v3 entry_v3; - struct logger_entry_v2 entry_v2; - struct logger_entry entry_v1; - } __attribute__((aligned(4))); -#ifdef __cplusplus - /* Matching log_time operators */ - bool operator== (const log_msg &T) const - { - return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec); - } - bool operator!= (const log_msg &T) const - { - return !(*this == T); - } - bool operator< (const log_msg &T) const - { - return (entry.sec < T.entry.sec) - || ((entry.sec == T.entry.sec) - && (entry.nsec < T.entry.nsec)); - } - bool operator>= (const log_msg &T) const - { - return !(*this < T); - } - bool operator> (const log_msg &T) const - { - return (entry.sec > T.entry.sec) - || ((entry.sec == T.entry.sec) - && (entry.nsec > T.entry.nsec)); - } - bool operator<= (const log_msg &T) const - { - return !(*this > T); - } - uint64_t nsec() const - { - return static_cast(entry.sec) * NS_PER_SEC + entry.nsec; - } - - /* packet methods */ - log_id_t id() - { - return (log_id_t) entry.lid; - } - char *msg() - { - return entry.hdr_size ? (char *) buf + entry.hdr_size : entry_v1.msg; - } - unsigned int len() - { - return (entry.hdr_size ? entry.hdr_size : sizeof(entry_v1)) + entry.len; - } -#endif -}; - -struct logger; - -log_id_t android_logger_get_id(struct logger *logger); - -int android_logger_clear(struct logger *logger); -long android_logger_get_log_size(struct logger *logger); -int android_logger_set_log_size(struct logger *logger, unsigned long size); -long android_logger_get_log_readable_size(struct logger *logger); -int android_logger_get_log_version(struct logger *logger); - -struct logger_list; - -ssize_t android_logger_get_statistics(struct logger_list *logger_list, - char *buf, size_t len); -ssize_t android_logger_get_prune_list(struct logger_list *logger_list, - char *buf, size_t len); -int android_logger_set_prune_list(struct logger_list *logger_list, - char *buf, size_t len); - -#define ANDROID_LOG_RDONLY O_RDONLY -#define ANDROID_LOG_WRONLY O_WRONLY -#define ANDROID_LOG_RDWR O_RDWR -#define ANDROID_LOG_ACCMODE O_ACCMODE -#define ANDROID_LOG_NONBLOCK O_NONBLOCK -#define ANDROID_LOG_PSTORE 0x80000000 - -struct logger_list *android_logger_list_alloc(int mode, - unsigned int tail, - pid_t pid); -struct logger_list *android_logger_list_alloc_time(int mode, - log_time start, - pid_t pid); -void android_logger_list_free(struct logger_list *logger_list); -/* In the purest sense, the following two are orthogonal interfaces */ -int android_logger_list_read(struct logger_list *logger_list, - struct log_msg *log_msg); - -/* Multiple log_id_t opens */ -struct logger *android_logger_open(struct logger_list *logger_list, - log_id_t id); -#define android_logger_close android_logger_free -/* Single log_id_t open */ -struct logger_list *android_logger_list_open(log_id_t id, - int mode, - unsigned int tail, - pid_t pid); -#define android_logger_list_close android_logger_list_free - -/* - * log_id_t helpers - */ -log_id_t android_name_to_log_id(const char *logName); -const char *android_log_id_to_name(log_id_t log_id); - -#ifdef __cplusplus -} -#endif - -#endif /* _LIBS_LOG_LOGGER_H */ diff --git a/third_party/android_system_core/include/log/logprint.h b/third_party/android_system_core/include/log/logprint.h deleted file mode 100644 index 4b812cc94..000000000 --- a/third_party/android_system_core/include/log/logprint.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -#ifndef _LOGPRINT_H -#define _LOGPRINT_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum { - FORMAT_OFF = 0, - FORMAT_BRIEF, - FORMAT_PROCESS, - FORMAT_TAG, - FORMAT_THREAD, - FORMAT_RAW, - FORMAT_TIME, - FORMAT_THREADTIME, - FORMAT_LONG, - /* The following three are modifiers to above formats */ - FORMAT_MODIFIER_COLOR, /* converts priority to color */ - FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */ - FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */ -} AndroidLogPrintFormat; - -typedef struct AndroidLogFormat_t AndroidLogFormat; - -typedef struct AndroidLogEntry_t { - time_t tv_sec; - long tv_nsec; - android_LogPriority priority; - int32_t pid; - int32_t tid; - const char * tag; - size_t messageLen; - const char * message; -} AndroidLogEntry; - -AndroidLogFormat *android_log_format_new(); - -void android_log_format_free(AndroidLogFormat *p_format); - -/* currently returns 0 if format is a modifier, 1 if not */ -int android_log_setPrintFormat(AndroidLogFormat *p_format, - AndroidLogPrintFormat format); - -/** - * Returns FORMAT_OFF on invalid string - */ -AndroidLogPrintFormat android_log_formatFromString(const char *s); - -/** - * filterExpression: a single filter expression - * eg "AT:d" - * - * returns 0 on success and -1 on invalid expression - * - * Assumes single threaded execution - * - */ - -int android_log_addFilterRule(AndroidLogFormat *p_format, - const char *filterExpression); - - -/** - * filterString: a whitespace-separated set of filter expressions - * eg "AT:d *:i" - * - * returns 0 on success and -1 on invalid expression - * - * Assumes single threaded execution - * - */ - -int android_log_addFilterString(AndroidLogFormat *p_format, - const char *filterString); - - -/** - * returns 1 if this log line should be printed based on its priority - * and tag, and 0 if it should not - */ -int android_log_shouldPrintLine ( - AndroidLogFormat *p_format, const char *tag, android_LogPriority pri); - - -/** - * Splits a wire-format buffer into an AndroidLogEntry - * entry allocated by caller. Pointers will point directly into buf - * - * Returns 0 on success and -1 on invalid wire format (entry will be - * in unspecified state) - */ -int android_log_processLogBuffer(struct logger_entry *buf, - AndroidLogEntry *entry); - -/** - * Like android_log_processLogBuffer, but for binary logs. - * - * If "map" is non-NULL, it will be used to convert the log tag number - * into a string. - */ -int android_log_processBinaryLogBuffer(struct logger_entry *buf, - AndroidLogEntry *entry, const EventTagMap* map, char* messageBuf, - int messageBufLen); - - -/** - * Formats a log message into a buffer - * - * Uses defaultBuffer if it can, otherwise malloc()'s a new buffer - * If return value != defaultBuffer, caller must call free() - * Returns NULL on malloc error - */ - -char *android_log_formatLogLine ( - AndroidLogFormat *p_format, - char *defaultBuffer, - size_t defaultBufferSize, - const AndroidLogEntry *p_line, - size_t *p_outLength); - - -/** - * Either print or do not print log line, based on filter - * - * Assumes single threaded execution - * - */ -int android_log_printLogLine( - AndroidLogFormat *p_format, - int fd, - const AndroidLogEntry *entry); - - -#ifdef __cplusplus -} -#endif - - -#endif /*_LOGPRINT_H*/ diff --git a/third_party/android_system_core/include/log/uio.h b/third_party/android_system_core/include/log/uio.h deleted file mode 100644 index 7059da5f7..000000000 --- a/third_party/android_system_core/include/log/uio.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2007-2014 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. - */ - -#ifndef _LIBS_CUTILS_UIO_H -#define _LIBS_CUTILS_UIO_H - -#if !defined(_WIN32) - -#include - -#else - -#ifdef __cplusplus -extern "C" { -#endif - -// -// Implementation of sys/uio.h for Win32. -// - -#include - -struct iovec { - void* iov_base; - size_t iov_len; -}; - -extern int readv( int fd, struct iovec* vecs, int count ); -extern int writev( int fd, const struct iovec* vecs, int count ); - -#ifdef __cplusplus -} -#endif - -#endif - -#endif /* _LIBS_UTILS_UIO_H */ - diff --git a/third_party/android_system_core/include/system/camera.h b/third_party/android_system_core/include/system/camera.h deleted file mode 100644 index 0570ca04c..000000000 --- a/third_party/android_system_core/include/system/camera.h +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H -#define SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H - -#include -#include -#include -#include -#include -#include - -__BEGIN_DECLS - -/** - * A set of bit masks for specifying how the received preview frames are - * handled before the previewCallback() call. - * - * The least significant 3 bits of an "int" value are used for this purpose: - * - * ..... 0 0 0 - * ^ ^ ^ - * | | |---------> determine whether the callback is enabled or not - * | |-----------> determine whether the callback is one-shot or not - * |-------------> determine whether the frame is copied out or not - * - * WARNING: When a frame is sent directly without copying, it is the frame - * receiver's responsiblity to make sure that the frame data won't get - * corrupted by subsequent preview frames filled by the camera. This flag is - * recommended only when copying out data brings significant performance price - * and the handling/processing of the received frame data is always faster than - * the preview frame rate so that data corruption won't occur. - * - * For instance, - * 1. 0x00 disables the callback. In this case, copy out and one shot bits - * are ignored. - * 2. 0x01 enables a callback without copying out the received frames. A - * typical use case is the Camcorder application to avoid making costly - * frame copies. - * 3. 0x05 is enabling a callback with frame copied out repeatedly. A typical - * use case is the Camera application. - * 4. 0x07 is enabling a callback with frame copied out only once. A typical - * use case is the Barcode scanner application. - */ - -enum { - CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK = 0x01, - CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK = 0x02, - CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK = 0x04, - /** Typical use cases */ - CAMERA_FRAME_CALLBACK_FLAG_NOOP = 0x00, - CAMERA_FRAME_CALLBACK_FLAG_CAMCORDER = 0x01, - CAMERA_FRAME_CALLBACK_FLAG_CAMERA = 0x05, - CAMERA_FRAME_CALLBACK_FLAG_BARCODE_SCANNER = 0x07 -}; - -/** msgType in notifyCallback and dataCallback functions */ -enum { - CAMERA_MSG_ERROR = 0x0001, // notifyCallback - CAMERA_MSG_SHUTTER = 0x0002, // notifyCallback - CAMERA_MSG_FOCUS = 0x0004, // notifyCallback - CAMERA_MSG_ZOOM = 0x0008, // notifyCallback - CAMERA_MSG_PREVIEW_FRAME = 0x0010, // dataCallback - CAMERA_MSG_VIDEO_FRAME = 0x0020, // data_timestamp_callback - CAMERA_MSG_POSTVIEW_FRAME = 0x0040, // dataCallback - CAMERA_MSG_RAW_IMAGE = 0x0080, // dataCallback - CAMERA_MSG_COMPRESSED_IMAGE = 0x0100, // dataCallback - CAMERA_MSG_RAW_IMAGE_NOTIFY = 0x0200, // dataCallback - // Preview frame metadata. This can be combined with - // CAMERA_MSG_PREVIEW_FRAME in dataCallback. For example, the apps can - // request FRAME and METADATA. Or the apps can request only FRAME or only - // METADATA. - CAMERA_MSG_PREVIEW_METADATA = 0x0400, // dataCallback - // Notify on autofocus start and stop. This is useful in continuous - // autofocus - FOCUS_MODE_CONTINUOUS_VIDEO and FOCUS_MODE_CONTINUOUS_PICTURE. - CAMERA_MSG_FOCUS_MOVE = 0x0800, // notifyCallback - CAMERA_MSG_VENDOR_START = 0x1000, - CAMERA_MSG_STATS_DATA = CAMERA_MSG_VENDOR_START, - CAMERA_MSG_META_DATA = 0x2000, - CAMERA_MSG_VENDOR_END = 0x8000, - CAMERA_MSG_ALL_MSGS = 0xFFFF -}; - -/** meta data type in CameraMetaDataCallback */ -enum { - CAMERA_META_DATA_ASD = 0x001, //ASD data - CAMERA_META_DATA_FD = 0x002, //FD/FP data - CAMERA_META_DATA_HDR = 0x003, //Auto HDR data -}; - -/** cmdType in sendCommand functions */ -enum { - CAMERA_CMD_START_SMOOTH_ZOOM = 1, - CAMERA_CMD_STOP_SMOOTH_ZOOM = 2, - - /** - * Set the clockwise rotation of preview display (setPreviewDisplay) in - * degrees. This affects the preview frames and the picture displayed after - * snapshot. This method is useful for portrait mode applications. Note - * that preview display of front-facing cameras is flipped horizontally - * before the rotation, that is, the image is reflected along the central - * vertical axis of the camera sensor. So the users can see themselves as - * looking into a mirror. - * - * This does not affect the order of byte array of - * CAMERA_MSG_PREVIEW_FRAME, CAMERA_MSG_VIDEO_FRAME, - * CAMERA_MSG_POSTVIEW_FRAME, CAMERA_MSG_RAW_IMAGE, or - * CAMERA_MSG_COMPRESSED_IMAGE. This is allowed to be set during preview - * since API level 14. - */ - CAMERA_CMD_SET_DISPLAY_ORIENTATION = 3, - - /** - * cmdType to disable/enable shutter sound. In sendCommand passing arg1 = - * 0 will disable, while passing arg1 = 1 will enable the shutter sound. - */ - CAMERA_CMD_ENABLE_SHUTTER_SOUND = 4, - - /* cmdType to play recording sound */ - CAMERA_CMD_PLAY_RECORDING_SOUND = 5, - - /** - * Start the face detection. This should be called after preview is started. - * The camera will notify the listener of CAMERA_MSG_FACE and the detected - * faces in the preview frame. The detected faces may be the same as the - * previous ones. Apps should call CAMERA_CMD_STOP_FACE_DETECTION to stop - * the face detection. This method is supported if CameraParameters - * KEY_MAX_NUM_HW_DETECTED_FACES or KEY_MAX_NUM_SW_DETECTED_FACES is - * bigger than 0. Hardware and software face detection should not be running - * at the same time. If the face detection has started, apps should not send - * this again. - * - * In hardware face detection mode, CameraParameters KEY_WHITE_BALANCE, - * KEY_FOCUS_AREAS and KEY_METERING_AREAS have no effect. - * - * arg1 is the face detection type. It can be CAMERA_FACE_DETECTION_HW or - * CAMERA_FACE_DETECTION_SW. If the type of face detection requested is not - * supported, the HAL must return BAD_VALUE. - */ - CAMERA_CMD_START_FACE_DETECTION = 6, - - /** - * Stop the face detection. - */ - CAMERA_CMD_STOP_FACE_DETECTION = 7, - - /** - * Enable/disable focus move callback (CAMERA_MSG_FOCUS_MOVE). Passing - * arg1 = 0 will disable, while passing arg1 = 1 will enable the callback. - */ - CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG = 8, - - /** - * Ping camera service to see if camera hardware is released. - * - * When any camera method returns error, the client can use ping command - * to see if the camera has been taken away by other clients. If the result - * is NO_ERROR, it means the camera hardware is not released. If the result - * is not NO_ERROR, the camera has been released and the existing client - * can silently finish itself or show a dialog. - */ - CAMERA_CMD_PING = 9, - - /** - * Configure the number of video buffers used for recording. The intended - * video buffer count for recording is passed as arg1, which must be - * greater than 0. This command must be sent before recording is started. - * This command returns INVALID_OPERATION error if it is sent after video - * recording is started, or the command is not supported at all. This - * command also returns a BAD_VALUE error if the intended video buffer - * count is non-positive or too big to be realized. - */ - CAMERA_CMD_SET_VIDEO_BUFFER_COUNT = 10, - - /** - * Configure an explicit format to use for video recording metadata mode. - * This can be used to switch the format from the - * default IMPLEMENTATION_DEFINED gralloc format to some other - * device-supported format, and the default dataspace from the BT_709 color - * space to some other device-supported dataspace. arg1 is the HAL pixel - * format, and arg2 is the HAL dataSpace. This command returns - * INVALID_OPERATION error if it is sent after video recording is started, - * or the command is not supported at all. - * - * If the gralloc format is set to a format other than - * IMPLEMENTATION_DEFINED, then HALv3 devices will use gralloc usage flags - * of SW_READ_OFTEN. - */ -#ifndef CAMERA_VENDOR_L_COMPAT - CAMERA_CMD_SET_VIDEO_FORMAT = 11, - - CAMERA_CMD_VENDOR_START = 20, - /** - * Commands to enable/disable preview histogram - * - * Based on user's input to enable/disable histogram from the camera - * UI, send the appropriate command to the HAL to turn on/off the histogram - * stats and start sending the data to the application. - */ - CAMERA_CMD_HISTOGRAM_ON = CAMERA_CMD_VENDOR_START, - CAMERA_CMD_HISTOGRAM_OFF = CAMERA_CMD_VENDOR_START + 1, - CAMERA_CMD_HISTOGRAM_SEND_DATA = CAMERA_CMD_VENDOR_START + 2, - CAMERA_CMD_LONGSHOT_ON = CAMERA_CMD_VENDOR_START + 3, - CAMERA_CMD_LONGSHOT_OFF = CAMERA_CMD_VENDOR_START + 4, - CAMERA_CMD_STOP_LONGSHOT = CAMERA_CMD_VENDOR_START + 5, - CAMERA_CMD_METADATA_ON = CAMERA_CMD_VENDOR_START + 6, - CAMERA_CMD_METADATA_OFF = CAMERA_CMD_VENDOR_START + 7, - CAMERA_CMD_VENDOR_END = 200, -#else - - /** - * Values used by older HALs, provided as an option for compatibility - */ - CAMERA_CMD_HISTOGRAM_ON = 11, - CAMERA_CMD_HISTOGRAM_OFF = 12, - CAMERA_CMD_HISTOGRAM_SEND_DATA = 13, - CAMERA_CMD_LONGSHOT_ON = 14, - CAMERA_CMD_LONGSHOT_OFF = 15, - CAMERA_CMD_STOP_LONGSHOT = 16, - CAMERA_CMD_METADATA_ON = 100, - CAMERA_CMD_METADATA_OFF = 101, - CAMERA_CMD_SET_VIDEO_FORMAT = 102, -#endif -}; - -/** camera fatal errors */ -enum { - CAMERA_ERROR_UNKNOWN = 1, - /** - * Camera was released because another client has connected to the camera. - * The original client should call Camera::disconnect immediately after - * getting this notification. Otherwise, the camera will be released by - * camera service in a short time. The client should not call any method - * (except disconnect and sending CAMERA_CMD_PING) after getting this. - */ - CAMERA_ERROR_RELEASED = 2, - CAMERA_ERROR_SERVER_DIED = 100 -}; - -enum { - /** The facing of the camera is opposite to that of the screen. */ - CAMERA_FACING_BACK = 0, - /** The facing of the camera is the same as that of the screen. */ - CAMERA_FACING_FRONT = 1, - /** - * The facing of the camera is not fixed relative to the screen. - * The cameras with this facing are external cameras, e.g. USB cameras. - */ - CAMERA_FACING_EXTERNAL = 2 -}; - -enum { - /** Hardware face detection. It does not use much CPU. */ - CAMERA_FACE_DETECTION_HW = 0, - /** - * Software face detection. It uses some CPU. Applications must use - * Camera.setPreviewTexture for preview in this mode. - */ - CAMERA_FACE_DETECTION_SW = 1 -}; - -/** - * The information of a face from camera face detection. - */ -typedef struct camera_face { - /** - * Bounds of the face [left, top, right, bottom]. (-1000, -1000) represents - * the top-left of the camera field of view, and (1000, 1000) represents the - * bottom-right of the field of view. The width and height cannot be 0 or - * negative. This is supported by both hardware and software face detection. - * - * The direction is relative to the sensor orientation, that is, what the - * sensor sees. The direction is not affected by the rotation or mirroring - * of CAMERA_CMD_SET_DISPLAY_ORIENTATION. - */ - int32_t rect[4]; - - /** - * The confidence level of the face. The range is 1 to 100. 100 is the - * highest confidence. This is supported by both hardware and software - * face detection. - */ - int32_t score; - - /** - * An unique id per face while the face is visible to the tracker. If - * the face leaves the field-of-view and comes back, it will get a new - * id. If the value is 0, id is not supported. - */ - int32_t id; - - /** - * The coordinates of the center of the left eye. The range is -1000 to - * 1000. -2000, -2000 if this is not supported. - */ - int32_t left_eye[2]; - - /** - * The coordinates of the center of the right eye. The range is -1000 to - * 1000. -2000, -2000 if this is not supported. - */ - int32_t right_eye[2]; - - /** - * The coordinates of the center of the mouth. The range is -1000 to 1000. - * -2000, -2000 if this is not supported. - */ - int32_t mouth[2]; - int32_t smile_degree; - int32_t smile_score; - int32_t blink_detected; - int32_t face_recognised; - int32_t gaze_angle; - int32_t updown_dir; - int32_t leftright_dir; - int32_t roll_dir; - int32_t left_right_gaze; - int32_t top_bottom_gaze; - int32_t leye_blink; - int32_t reye_blink; - -} camera_face_t; - -/** - * The information of a data type received in a camera frame. - */ -typedef enum { - /** Data buffer */ - CAMERA_FRAME_DATA_BUF = 0x000, - /** File descriptor */ - CAMERA_FRAME_DATA_FD = 0x100 -} camera_frame_data_type_t; - -/** - * The metadata of the frame data. - */ -typedef struct camera_frame_metadata { - /** - * The number of detected faces in the frame. - */ - int32_t number_of_faces; - - /** - * An array of the detected faces. The length is number_of_faces. - */ - camera_face_t *faces; -} camera_frame_metadata_t; - -__END_DECLS - -#endif /* SYSTEM_CORE_INCLUDE_ANDROID_CAMERA_H */ diff --git a/third_party/android_system_core/include/system/graphics.h b/third_party/android_system_core/include/system/graphics.h deleted file mode 100644 index afd9f7bdb..000000000 --- a/third_party/android_system_core/include/system/graphics.h +++ /dev/null @@ -1,763 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H -#define SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * If the HAL needs to create service threads to handle graphics related - * tasks, these threads need to run at HAL_PRIORITY_URGENT_DISPLAY priority - * if they can block the main rendering thread in any way. - * - * the priority of the current thread can be set with: - * - * #include - * setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); - * - */ - -#define HAL_PRIORITY_URGENT_DISPLAY (-8) - -/** - * pixel format definitions - */ - -enum { - /* - * "linear" color pixel formats: - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - * - * The color space determines, for example, if the formats are linear or - * gamma-corrected; or whether any special operations are performed when - * reading or writing into a buffer in one of these formats. - */ - HAL_PIXEL_FORMAT_RGBA_8888 = 1, - HAL_PIXEL_FORMAT_RGBX_8888 = 2, - HAL_PIXEL_FORMAT_RGB_888 = 3, - HAL_PIXEL_FORMAT_RGB_565 = 4, - HAL_PIXEL_FORMAT_BGRA_8888 = 5, - - /* - * 0x100 - 0x1FF - * - * This range is reserved for pixel formats that are specific to the HAL - * implementation. Implementations can use any value in this range to - * communicate video pixel formats between their HAL modules. These formats - * must not have an alpha channel. Additionally, an EGLimage created from a - * gralloc buffer of one of these formats must be supported for use with the - * GL_OES_EGL_image_external OpenGL ES extension. - */ - - /* - * Android YUV format: - * - * This format is exposed outside of the HAL to software decoders and - * applications. EGLImageKHR must support it in conjunction with the - * OES_EGL_image_external extension. - * - * YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed - * by (W/2) x (H/2) Cr and Cb planes. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * y_size = stride * height - * c_stride = ALIGN(stride/2, 16) - * c_size = c_stride * height/2 - * size = y_size + c_size * 2 - * cr_offset = y_size - * cb_offset = y_size + c_size - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar - - - /* - * Android Y8 format: - * - * This format is exposed outside of the HAL to the framework. - * The expected gralloc usage flags are SW_* and HW_CAMERA_*, - * and no other HW_ flags will be used. - * - * Y8 is a YUV planar format comprised of a WxH Y plane, - * with each pixel being represented by 8 bits. - * - * It is equivalent to just the Y plane from YV12. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - * size = stride * height - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_Y8 = 0x20203859, - - /* - * Android Y16 format: - * - * This format is exposed outside of the HAL to the framework. - * The expected gralloc usage flags are SW_* and HW_CAMERA_*, - * and no other HW_ flags will be used. - * - * Y16 is a YUV planar format comprised of a WxH Y plane, - * with each pixel being represented by 16 bits. - * - * It is just like Y8, but has double the bits per pixel (little endian). - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer, except that dataSpace field - * HAL_DATASPACE_DEPTH indicates that this buffer contains a depth - * image where each sample is a distance value measured by a depth camera, - * plus an associated confidence value. - */ - HAL_PIXEL_FORMAT_Y16 = 0x20363159, - - /* - * Android RAW sensor format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW16 is a single-channel, 16-bit, little endian format, typically - * representing raw Bayer-pattern images from an image sensor, with minimal - * processing. - * - * The exact pixel layout of the data in the buffer is sensor-dependent, and - * needs to be queried from the camera device. - * - * Generally, not all 16 bits are used; more common values are 10 or 12 - * bits. If not all bits are used, the lower-order bits are filled first. - * All parameters to interpret the raw data (black and white points, - * color space, etc) must be queried from the camera device. - * - * This format assumes - * - an even width - * - an even height - * - a horizontal stride multiple of 16 pixels - * - a vertical stride equal to the height - * - strides are specified in pixels, not in bytes - * - * size = stride * height * 2 - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW16 = 0x20, - - /* - * Android RAW10 format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW10 is a single-channel, 10-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each 4 consecutive pixels are packed into 5 bytes (40 bits). Each one - * of the first 4 bytes contains the top 8 bits of each pixel, The fifth byte - * contains the 2 least significant bits of the 4 pixels, the exact layout data - * for each 4 consecutive pixels is illustrated below (Pi[j] stands for the jth - * bit of the ith pixel): - * - * bit 7 bit 0 - * =====|=====|=====|=====|=====|=====|=====|=====| - * Byte 0: |P0[9]|P0[8]|P0[7]|P0[6]|P0[5]|P0[4]|P0[3]|P0[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 1: |P1[9]|P1[8]|P1[7]|P1[6]|P1[5]|P1[4]|P1[3]|P1[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 2: |P2[9]|P2[8]|P2[7]|P2[6]|P2[5]|P2[4]|P2[3]|P2[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 3: |P3[9]|P3[8]|P3[7]|P3[6]|P3[5]|P3[4]|P3[3]|P3[2]| - * |-----|-----|-----|-----|-----|-----|-----|-----| - * Byte 4: |P3[1]|P3[0]|P2[1]|P2[0]|P1[1]|P1[0]|P0[1]|P0[0]| - * =============================================== - * - * This format assumes - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (10 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (10 / 8), padding bytes will be present at the end of each - * row (including the last row). - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW10 = 0x25, - - /* - * Android RAW12 format: - * - * This format is exposed outside of camera HAL to applications. - * - * RAW12 is a single-channel, 12-bit per pixel, densely packed in each row, - * unprocessed format, usually representing raw Bayer-pattern images coming from - * an image sensor. - * - * In an image buffer with this format, starting from the first pixel of each - * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first - * and second byte contains the top 8 bits of first and second pixel. The third - * byte contains the 4 least significant bits of the two pixels, the exact layout - * data for each two consecutive pixels is illustrated below (Pi[j] stands for - * the jth bit of the ith pixel): - * - * bit 7 bit 0 - * ======|======|======|======|======|======|======|======| - * Byte 0: |P0[11]|P0[10]|P0[ 9]|P0[ 8]|P0[ 7]|P0[ 6]|P0[ 5]|P0[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 1: |P1[11]|P1[10]|P1[ 9]|P1[ 8]|P1[ 7]|P1[ 6]|P1[ 5]|P1[ 4]| - * |------|------|------|------|------|------|------|------| - * Byte 2: |P1[ 3]|P1[ 2]|P1[ 1]|P1[ 0]|P0[ 3]|P0[ 2]|P0[ 1]|P0[ 0]| - * ======================================================= - * - * This format assumes: - * - a width multiple of 4 pixels - * - an even height - * - a vertical stride equal to the height - * - strides are specified in bytes, not in pixels - * - * size = stride * height - * - * When stride is equal to width * (12 / 8), there will be no padding bytes at - * the end of each row, the entire image data is densely packed. When stride is - * larger than width * (12 / 8), padding bytes will be present at the end of - * each row (including the last row). - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW12 = 0x26, - - /* - * Android opaque RAW format: - * - * This format is exposed outside of the camera HAL to applications. - * - * RAW_OPAQUE is a format for unprocessed raw image buffers coming from an - * image sensor. The actual structure of buffers of this format is - * implementation-dependent. - * - * This format must be accepted by the gralloc module when used with the - * following usage flags: - * - GRALLOC_USAGE_HW_CAMERA_* - * - GRALLOC_USAGE_SW_* - * - GRALLOC_USAGE_RENDERSCRIPT - * - * When used with ANativeWindow, the dataSpace field should be - * HAL_DATASPACE_ARBITRARY, as raw image sensor buffers require substantial - * extra metadata to define. - */ - HAL_PIXEL_FORMAT_RAW_OPAQUE = 0x24, - - /* - * Android binary blob graphics buffer format: - * - * This format is used to carry task-specific data which does not have a - * standard image structure. The details of the format are left to the two - * endpoints. - * - * A typical use case is for transporting JPEG-compressed images from the - * Camera HAL to the framework or to applications. - * - * Buffers of this format must have a height of 1, and width equal to their - * size in bytes. - * - * When used with ANativeWindow, the mapping of the dataSpace field to - * buffer contents for BLOB is as follows: - * - * dataSpace value | Buffer contents - * -------------------------------+----------------------------------------- - * HAL_DATASPACE_JFIF | An encoded JPEG image - * HAL_DATASPACE_DEPTH | An android_depth_points buffer - * Other | Unsupported - * - */ - HAL_PIXEL_FORMAT_BLOB = 0x21, - - /* - * Android format indicating that the choice of format is entirely up to the - * device-specific Gralloc implementation. - * - * The Gralloc implementation should examine the usage bits passed in when - * allocating a buffer with this format, and it should derive the pixel - * format from those usage flags. This format will never be used with any - * of the GRALLOC_USAGE_SW_* usage flags. - * - * If a buffer of this format is to be used as an OpenGL ES texture, the - * framework will assume that sampling the texture will always return an - * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values). - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED = 0x22, - - /* - * Android flexible YCbCr 4:2:0 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:0 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * struct android_ycbcr (below) is the the struct used to describe it. - * - * This format must be accepted by the gralloc module when - * USAGE_SW_WRITE_* or USAGE_SW_READ_* are set. - * - * This format is locked for use by gralloc's (*lock_ycbcr) method, and - * locking with the (*lock) method will return an error. - * - * When used with ANativeWindow, the dataSpace field describes the color - * space of the buffer. - */ - HAL_PIXEL_FORMAT_YCbCr_420_888 = 0x23, - - /* - * Android flexible YCbCr 4:2:2 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:2:2 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_YCbCr_422_888 = 0x27, - - /* - * Android flexible YCbCr 4:4:4 formats - * - * This format allows platforms to use an efficient YCbCr/YCrCb 4:4:4 - * buffer layout, while still describing the general format in a - * layout-independent manner. While called YCbCr, it can be - * used to describe formats with either chromatic ordering, as well as - * whole planar or semiplanar layouts. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_YCbCr_444_888 = 0x28, - - /* - * Android flexible RGB 888 formats - * - * This format allows platforms to use an efficient RGB/BGR/RGBX/BGRX - * buffer layout, while still describing the general format in a - * layout-independent manner. While called RGB, it can be - * used to describe formats with either color ordering and optional - * padding, as well as whole planar layout. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_FLEX_RGB_888 = 0x29, - - /* - * Android flexible RGBA 8888 formats - * - * This format allows platforms to use an efficient RGBA/BGRA/ARGB/ABGR - * buffer layout, while still describing the general format in a - * layout-independent manner. While called RGBA, it can be - * used to describe formats with any of the component orderings, as - * well as whole planar layout. - * - * This format is currently only used by SW readable buffers - * produced by MediaCodecs, so the gralloc module can ignore this format. - */ - HAL_PIXEL_FORMAT_FLEX_RGBA_8888 = 0x2A, - - /* Legacy formats (deprecated), used by ImageFormat.java */ - HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 - HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 - HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 -}; - -/* - * Structure for describing YCbCr formats for consumption by applications. - * This is used with HAL_PIXEL_FORMAT_YCbCr_*_888. - * - * Buffer chroma subsampling is defined in the format. - * e.g. HAL_PIXEL_FORMAT_YCbCr_420_888 has subsampling 4:2:0. - * - * Buffers must have a 8 bit depth. - * - * @y, @cb, and @cr point to the first byte of their respective planes. - * - * Stride describes the distance in bytes from the first value of one row of - * the image to the first value of the next row. It includes the width of the - * image plus padding. - * @ystride is the stride of the luma plane. - * @cstride is the stride of the chroma planes. - * - * @chroma_step is the distance in bytes from one chroma pixel value to the - * next. This is 2 bytes for semiplanar (because chroma values are interleaved - * and each chroma value is one byte) and 1 for planar. - */ - -struct android_ycbcr { - void *y; - void *cb; - void *cr; - size_t ystride; - size_t cstride; - size_t chroma_step; - - /** reserved for future use, set to 0 by gralloc's (*lock_ycbcr)() */ - uint32_t reserved[8]; -}; - -/** - * Structure used to define depth point clouds for format HAL_PIXEL_FORMAT_BLOB - * with dataSpace value of HAL_DATASPACE_DEPTH. - * When locking a native buffer of the above format and dataSpace value, - * the vaddr pointer can be cast to this structure. - * - * A variable-length list of (x,y,z, confidence) 3D points, as floats. (x, y, - * z) represents a measured point's position, with the coordinate system defined - * by the data source. Confidence represents the estimated likelihood that this - * measurement is correct. It is between 0.f and 1.f, inclusive, with 1.f == - * 100% confidence. - * - * @num_points is the number of points in the list - * - * @xyz_points is the flexible array of floating-point values. - * It contains (num_points) * 4 floats. - * - * For example: - * android_depth_points d = get_depth_buffer(); - * struct { - * float x; float y; float z; float confidence; - * } firstPoint, lastPoint; - * - * firstPoint.x = d.xyzc_points[0]; - * firstPoint.y = d.xyzc_points[1]; - * firstPoint.z = d.xyzc_points[2]; - * firstPoint.confidence = d.xyzc_points[3]; - * lastPoint.x = d.xyzc_points[(d.num_points - 1) * 4 + 0]; - * lastPoint.y = d.xyzc_points[(d.num_points - 1) * 4 + 1]; - * lastPoint.z = d.xyzc_points[(d.num_points - 1) * 4 + 2]; - * lastPoint.confidence = d.xyzc_points[(d.num_points - 1) * 4 + 3]; - */ - -struct android_depth_points { - uint32_t num_points; - - /** reserved for future use, set to 0 by gralloc's (*lock)() */ - uint32_t reserved[8]; - - float xyzc_points[]; -}; - -/** - * Transformation definitions - * - * IMPORTANT NOTE: - * HAL_TRANSFORM_ROT_90 is applied CLOCKWISE and AFTER HAL_TRANSFORM_FLIP_{H|V}. - * - */ - -enum { - /* flip source image horizontally (around the vertical axis) */ - HAL_TRANSFORM_FLIP_H = 0x01, - /* flip source image vertically (around the horizontal axis)*/ - HAL_TRANSFORM_FLIP_V = 0x02, - /* rotate source image 90 degrees clockwise */ - HAL_TRANSFORM_ROT_90 = 0x04, - /* rotate source image 180 degrees */ - HAL_TRANSFORM_ROT_180 = 0x03, - /* rotate source image 270 degrees clockwise */ - HAL_TRANSFORM_ROT_270 = 0x07, - /* don't use. see system/window.h */ - HAL_TRANSFORM_RESERVED = 0x08, -}; - -/** - * Dataspace Definitions - * ====================== - * - * Dataspace is the definition of how pixel values should be interpreted. - * - * For many formats, this is the colorspace of the image data, which includes - * primaries (including white point) and the transfer characteristic function, - * which describes both gamma curve and numeric range (within the bit depth). - * - * Other dataspaces include depth measurement data from a depth camera. - */ - -typedef enum android_dataspace { - /* - * Default-assumption data space, when not explicitly specified. - * - * It is safest to assume the buffer is an image with sRGB primaries and - * encoding ranges, but the consumer and/or the producer of the data may - * simply be using defaults. No automatic gamma transform should be - * expected, except for a possible display gamma transform when drawn to a - * screen. - */ - HAL_DATASPACE_UNKNOWN = 0x0, - - /* - * Arbitrary dataspace with manually defined characteristics. Definition - * for colorspaces or other meaning must be communicated separately. - * - * This is used when specifying primaries, transfer characteristics, - * etc. separately. - * - * A typical use case is in video encoding parameters (e.g. for H.264), - * where a colorspace can have separately defined primaries, transfer - * characteristics, etc. - */ - HAL_DATASPACE_ARBITRARY = 0x1, - - /* - * RGB Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - */ - - /* - * sRGB linear encoding: - * - * The red, green, and blue components are stored in sRGB space, but - * are linear, not gamma-encoded. - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - */ - HAL_DATASPACE_SRGB_LINEAR = 0x200, - - /* - * sRGB gamma encoding: - * - * The red, green and blue components are stored in sRGB space, and - * converted to linear space when read, using the standard sRGB to linear - * equation: - * - * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045 - * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045 - * - * When written the inverse transformation is performed: - * - * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308 - * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308 - * - * - * The alpha component, if present, is always stored in linear space and - * is left unmodified when read or written. - * - * The RGB primaries and the white point are the same as BT.709. - * - * The values are encoded using the full range ([0,255] for 8-bit) for all - * components. - * - */ - HAL_DATASPACE_SRGB = 0x201, - - /* - * YCbCr Colorspaces - * ----------------- - * - * Primaries are given using (x,y) coordinates in the CIE 1931 definition - * of x and y specified by ISO 11664-1. - * - * Transfer characteristics are the opto-electronic transfer characteristic - * at the source as a function of linear optical intensity (luminance). - */ - - /* - * JPEG File Interchange Format (JFIF) - * - * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 - * E = 4.500 L, 0.018 > L >= 0 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - * - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_JFIF = 0x101, - - /* - * ITU-R Recommendation 601 (BT.601) - 625-line - * - * Standard-definition television, 625 Lines (PAL) - * - * For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 - * E = 4.500 L, 0.018 > L >= 0 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - * - * Primaries: x y - * green 0.290 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_BT601_625 = 0x102, - - /* - * ITU-R Recommendation 601 (BT.601) - 525-line - * - * Standard-definition television, 525 Lines (NTSC) - * - * For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - * - * Transfer characteristic curve: - * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018 - * E = 4.500 L, 0.018 > L >= 0 - * L - luminance of image 0 <= L <= 1 for conventional colorimetry - * E - corresponding electrical signal - * - * Primaries: x y - * green 0.310 0.595 - * blue 0.155 0.070 - * red 0.630 0.340 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_BT601_525 = 0x103, - - /* - * ITU-R Recommendation 709 (BT.709) - * - * High-definition television - * - * For 8-bit-depth formats: - * Luma (Y) samples should range from 16 to 235, inclusive - * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive - * - * For 10-bit-depth formats: - * Luma (Y) samples should range from 64 to 940, inclusive - * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive - * - * Primaries: x y - * green 0.300 0.600 - * blue 0.150 0.060 - * red 0.640 0.330 - * white (D65) 0.3127 0.3290 - */ - HAL_DATASPACE_BT709 = 0x104, - - /* - * The buffer contains depth ranging measurements from a depth camera. - * This value is valid with formats: - * HAL_PIXEL_FORMAT_Y16: 16-bit samples, consisting of a depth measurement - * and an associated confidence value. The 3 MSBs of the sample make - * up the confidence value, and the low 13 LSBs of the sample make up - * the depth measurement. - * For the confidence section, 0 means 100% confidence, 1 means 0% - * confidence. The mapping to a linear float confidence value between - * 0.f and 1.f can be obtained with - * float confidence = (((depthSample >> 13) - 1) & 0x7) / 7.0f; - * The depth measurement can be extracted simply with - * uint16_t range = (depthSample & 0x1FFF); - * HAL_PIXEL_FORMAT_BLOB: A depth point cloud, as - * a variable-length float (x,y,z, confidence) coordinate point list. - * The point cloud will be represented with the android_depth_points - * structure. - */ - HAL_DATASPACE_DEPTH = 0x1000 - -} android_dataspace_t; - -#ifdef __cplusplus -} -#endif - -#endif /* SYSTEM_CORE_INCLUDE_ANDROID_GRAPHICS_H */ diff --git a/third_party/android_system_core/include/system/radio.h b/third_party/android_system_core/include/system/radio.h deleted file mode 100644 index a08852604..000000000 --- a/third_party/android_system_core/include/system/radio.h +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (C) 2015 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. - */ - -#ifndef ANDROID_RADIO_H -#define ANDROID_RADIO_H - -#include -#include -#include -#include -#include - - -#define RADIO_NUM_BANDS_MAX 16 -#define RADIO_NUM_SPACINGS_MAX 16 -#define RADIO_STRING_LEN_MAX 128 - -/* - * Radio hardware module class. A given radio hardware module HAL is of one class - * only. The platform can not have more than one hardware module of each class. - * Current version of the framework only supports RADIO_CLASS_AM_FM. - */ -typedef enum { - RADIO_CLASS_AM_FM = 0, /* FM (including HD radio) and AM */ - RADIO_CLASS_SAT = 1, /* Satellite Radio */ - RADIO_CLASS_DT = 2, /* Digital Radio (DAB) */ -} radio_class_t; - -/* value for field "type" of radio band described in struct radio_hal_band_config */ -typedef enum { - RADIO_BAND_AM = 0, /* Amplitude Modulation band: LW, MW, SW */ - RADIO_BAND_FM = 1, /* Frequency Modulation band: FM */ - RADIO_BAND_FM_HD = 2, /* FM HD Radio / DRM (IBOC) */ - RADIO_BAND_AM_HD = 3, /* AM HD Radio / DRM (IBOC) */ -} radio_band_t; - -/* RDS variant implemented. A struct radio_hal_fm_band_config can list none or several. */ -enum { - RADIO_RDS_NONE = 0x0, - RADIO_RDS_WORLD = 0x01, - RADIO_RDS_US = 0x02, -}; -typedef unsigned int radio_rds_t; - -/* FM deemphasis variant implemented. A struct radio_hal_fm_band_config can list one or more. */ -enum { - RADIO_DEEMPHASIS_50 = 0x1, - RADIO_DEEMPHASIS_75 = 0x2, -}; -typedef unsigned int radio_deemphasis_t; - -/* Region a particular radio band configuration corresponds to. Not used at the HAL. - * Derived by the framework when converting the band descriptors retrieved from the HAL to - * individual band descriptors for each supported region. */ -typedef enum { - RADIO_REGION_NONE = -1, - RADIO_REGION_ITU_1 = 0, - RADIO_REGION_ITU_2 = 1, - RADIO_REGION_OIRT = 2, - RADIO_REGION_JAPAN = 3, - RADIO_REGION_KOREA = 4, -} radio_region_t; - -/* scanning direction for scan() and step() tuner APIs */ -typedef enum { - RADIO_DIRECTION_UP, - RADIO_DIRECTION_DOWN -} radio_direction_t; - -/* unique handle allocated to a radio module */ -typedef unsigned int radio_handle_t; - -/* Opaque meta data structure used by radio meta data API (see system/radio_metadata.h) */ -typedef struct radio_medtadata radio_metadata_t; - - -/* Additional attributes for an FM band configuration */ -typedef struct radio_hal_fm_band_config { - radio_deemphasis_t deemphasis; /* deemphasis variant */ - bool stereo; /* stereo supported */ - radio_rds_t rds; /* RDS variants supported */ - bool ta; /* Traffic Announcement supported */ - bool af; /* Alternate Frequency supported */ -} radio_hal_fm_band_config_t; - -/* Additional attributes for an AM band configuration */ -typedef struct radio_hal_am_band_config { - bool stereo; /* stereo supported */ -} radio_hal_am_band_config_t; - -/* Radio band configuration. Describes a given band supported by the radio module. - * The HAL can expose only one band per type with the the maximum range supported and all options. - * THe framework will derive the actual regions were this module can operate and expose separate - * band configurations for applications to chose from. */ -typedef struct radio_hal_band_config { - radio_band_t type; - bool antenna_connected; - unsigned int lower_limit; - unsigned int upper_limit; - unsigned int num_spacings; - unsigned int spacings[RADIO_NUM_SPACINGS_MAX]; - union { - radio_hal_fm_band_config_t fm; - radio_hal_am_band_config_t am; - }; -} radio_hal_band_config_t; - -/* Used internally by the framework to represent a band for s specific region */ -typedef struct radio_band_config { - radio_region_t region; - radio_hal_band_config_t band; -} radio_band_config_t; - - -/* Exposes properties of a given hardware radio module. - * NOTE: current framework implementation supports only one audio source (num_audio_sources = 1). - * The source corresponds to AUDIO_DEVICE_IN_FM_TUNER. - * If more than one tuner is supported (num_tuners > 1), only one can be connected to the audio - * source. */ -typedef struct radio_hal_properties { - radio_class_t class_id; /* Class of this module. E.g RADIO_CLASS_AM_FM */ - char implementor[RADIO_STRING_LEN_MAX]; /* implementor name */ - char product[RADIO_STRING_LEN_MAX]; /* product name */ - char version[RADIO_STRING_LEN_MAX]; /* product version */ - char serial[RADIO_STRING_LEN_MAX]; /* serial number (for subscription services) */ - unsigned int num_tuners; /* number of tuners controllable independently */ - unsigned int num_audio_sources; /* number of audio sources driven simultaneously */ - bool supports_capture; /* the hardware supports capture of audio source audio HAL */ - unsigned int num_bands; /* number of band descriptors */ - radio_hal_band_config_t bands[RADIO_NUM_BANDS_MAX]; /* band descriptors */ -} radio_hal_properties_t; - -/* Used internally by the framework. Same information as in struct radio_hal_properties plus a - * unique handle and one band configuration per region. */ -typedef struct radio_properties { - radio_handle_t handle; - radio_class_t class_id; - char implementor[RADIO_STRING_LEN_MAX]; - char product[RADIO_STRING_LEN_MAX]; - char version[RADIO_STRING_LEN_MAX]; - char serial[RADIO_STRING_LEN_MAX]; - unsigned int num_tuners; - unsigned int num_audio_sources; - bool supports_capture; - unsigned int num_bands; - radio_band_config_t bands[RADIO_NUM_BANDS_MAX]; -} radio_properties_t; - -/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED. - * Contains information on currently tuned channel. - */ -typedef struct radio_program_info { - unsigned int channel; /* current channel. (e.g kHz for band type RADIO_BAND_FM) */ - unsigned int sub_channel; /* current sub channel. (used for RADIO_BAND_FM_HD) */ - bool tuned; /* tuned to a program or not */ - bool stereo; /* program is stereo or not */ - bool digital; /* digital program or not (e.g HD Radio program) */ - unsigned int signal_strength; /* signal strength from 0 to 100 */ - radio_metadata_t *metadata; /* non null if meta data are present (e.g PTY, song title ...) */ -} radio_program_info_t; - - -/* Events sent to the framework via the HAL callback. An event can notify the completion of an - * asynchronous command (configuration, tune, scan ...) or a spontaneous change (antenna connection, - * failure, AF switching, meta data reception... */ -enum { - RADIO_EVENT_HW_FAILURE = 0, /* hardware module failure. Requires reopening the tuner */ - RADIO_EVENT_CONFIG = 1, /* configuration change completed */ - RADIO_EVENT_ANTENNA = 2, /* Antenna connected, disconnected */ - RADIO_EVENT_TUNED = 3, /* tune, step, scan completed */ - RADIO_EVENT_METADATA = 4, /* New meta data received */ - RADIO_EVENT_TA = 5, /* Traffic announcement start or stop */ - RADIO_EVENT_AF_SWITCH = 6, /* Switch to Alternate Frequency */ - // begin framework only events - RADIO_EVENT_CONTROL = 100, /* loss/gain of tuner control */ - RADIO_EVENT_SERVER_DIED = 101, /* radio service died */ -}; -typedef unsigned int radio_event_type_t; - -/* Event passed to the framework by the HAL callback */ -typedef struct radio_hal_event { - radio_event_type_t type; /* event type */ - int status; /* used by RADIO_EVENT_CONFIG, RADIO_EVENT_TUNED */ - union { - bool on; /* RADIO_EVENT_ANTENNA, RADIO_EVENT_TA */ - radio_hal_band_config_t config; /* RADIO_EVENT_CONFIG */ - radio_program_info_t info; /* RADIO_EVENT_TUNED, RADIO_EVENT_AF_SWITCH */ - radio_metadata_t *metadata; /* RADIO_EVENT_METADATA */ - }; -} radio_hal_event_t; - -/* Used internally by the framework. Same information as in struct radio_hal_event */ -typedef struct radio_event { - radio_event_type_t type; - int status; - union { - bool on; - radio_band_config_t config; - radio_program_info_t info; - radio_metadata_t *metadata; /* offset from start of struct when in shared memory */ - }; -} radio_event_t; - - -static radio_rds_t radio_rds_for_region(bool rds, radio_region_t region) { - if (!rds) - return RADIO_RDS_NONE; - switch(region) { - case RADIO_REGION_ITU_1: - case RADIO_REGION_OIRT: - case RADIO_REGION_JAPAN: - case RADIO_REGION_KOREA: - return RADIO_RDS_WORLD; - case RADIO_REGION_ITU_2: - return RADIO_RDS_US; - default: - return RADIO_REGION_NONE; - } -} - -static radio_deemphasis_t radio_demephasis_for_region(radio_region_t region) { - switch(region) { - case RADIO_REGION_KOREA: - case RADIO_REGION_ITU_2: - return RADIO_DEEMPHASIS_75; - case RADIO_REGION_ITU_1: - case RADIO_REGION_OIRT: - case RADIO_REGION_JAPAN: - default: - return RADIO_DEEMPHASIS_50; - } -} - -#endif // ANDROID_RADIO_H diff --git a/third_party/android_system_core/include/system/thread_defs.h b/third_party/android_system_core/include/system/thread_defs.h deleted file mode 100644 index 377a48ce9..000000000 --- a/third_party/android_system_core/include/system/thread_defs.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_THREAD_DEFS_H -#define ANDROID_THREAD_DEFS_H - -#include "graphics.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -enum { - /* - * *********************************************** - * ** Keep in sync with android.os.Process.java ** - * *********************************************** - * - * This maps directly to the "nice" priorities we use in Android. - * A thread priority should be chosen inverse-proportionally to - * the amount of work the thread is expected to do. The more work - * a thread will do, the less favorable priority it should get so that - * it doesn't starve the system. Threads not behaving properly might - * be "punished" by the kernel. - * Use the levels below when appropriate. Intermediate values are - * acceptable, preferably use the {MORE|LESS}_FAVORABLE constants below. - */ - ANDROID_PRIORITY_LOWEST = 19, - - /* use for background tasks */ - ANDROID_PRIORITY_BACKGROUND = 10, - - /* most threads run at normal priority */ - ANDROID_PRIORITY_NORMAL = 0, - - /* threads currently running a UI that the user is interacting with */ - ANDROID_PRIORITY_FOREGROUND = -2, - - /* the main UI thread has a slightly more favorable priority */ - ANDROID_PRIORITY_DISPLAY = -4, - - /* ui service treads might want to run at a urgent display (uncommon) */ - ANDROID_PRIORITY_URGENT_DISPLAY = HAL_PRIORITY_URGENT_DISPLAY, - - /* all normal audio threads */ - ANDROID_PRIORITY_AUDIO = -16, - - /* service audio threads (uncommon) */ - ANDROID_PRIORITY_URGENT_AUDIO = -19, - - /* should never be used in practice. regular process might not - * be allowed to use this level */ - ANDROID_PRIORITY_HIGHEST = -20, - - ANDROID_PRIORITY_DEFAULT = ANDROID_PRIORITY_NORMAL, - ANDROID_PRIORITY_MORE_FAVORABLE = -1, - ANDROID_PRIORITY_LESS_FAVORABLE = +1, -}; - -#if defined(__cplusplus) -} -#endif - -#endif /* ANDROID_THREAD_DEFS_H */ diff --git a/third_party/android_system_core/include/system/window.h b/third_party/android_system_core/include/system/window.h deleted file mode 100644 index 508ce00ba..000000000 --- a/third_party/android_system_core/include/system/window.h +++ /dev/null @@ -1,954 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H -#define SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef __UNUSED -#define __UNUSED __attribute__((__unused__)) -#endif -#ifndef __deprecated -#define __deprecated __attribute__((__deprecated__)) -#endif - -__BEGIN_DECLS - -/*****************************************************************************/ - -#define ANDROID_NATIVE_MAKE_CONSTANT(a,b,c,d) \ - (((unsigned)(a)<<24)|((unsigned)(b)<<16)|((unsigned)(c)<<8)|(unsigned)(d)) - -#define ANDROID_NATIVE_WINDOW_MAGIC \ - ANDROID_NATIVE_MAKE_CONSTANT('_','w','n','d') - -#define ANDROID_NATIVE_BUFFER_MAGIC \ - ANDROID_NATIVE_MAKE_CONSTANT('_','b','f','r') - -// --------------------------------------------------------------------------- - -// This #define may be used to conditionally compile device-specific code to -// support either the prior ANativeWindow interface, which did not pass libsync -// fences around, or the new interface that does. This #define is only present -// when the ANativeWindow interface does include libsync support. -#define ANDROID_NATIVE_WINDOW_HAS_SYNC 1 - -// --------------------------------------------------------------------------- - -typedef const native_handle_t* buffer_handle_t; - -// --------------------------------------------------------------------------- - -typedef struct android_native_rect_t -{ - int32_t left; - int32_t top; - int32_t right; - int32_t bottom; -} android_native_rect_t; - -// --------------------------------------------------------------------------- - -typedef struct android_native_base_t -{ - /* a magic value defined by the actual EGL native type */ - int magic; - - /* the sizeof() of the actual EGL native type */ - int version; - - void* reserved[4]; - - /* reference-counting interface */ - void (*incRef)(struct android_native_base_t* base); - void (*decRef)(struct android_native_base_t* base); -} android_native_base_t; - -typedef struct ANativeWindowBuffer -{ -#ifdef __cplusplus - ANativeWindowBuffer() { - common.magic = ANDROID_NATIVE_BUFFER_MAGIC; - common.version = sizeof(ANativeWindowBuffer); - memset(common.reserved, 0, sizeof(common.reserved)); - } - - // Implement the methods that sp expects so that it - // can be used to automatically refcount ANativeWindowBuffer's. - void incStrong(const void* /*id*/) const { - common.incRef(const_cast(&common)); - } - void decStrong(const void* /*id*/) const { - common.decRef(const_cast(&common)); - } -#endif - - struct android_native_base_t common; - - int width; - int height; - int stride; - int format; - int usage; - - void* reserved[2]; - - buffer_handle_t handle; - - void* reserved_proc[8]; -} ANativeWindowBuffer_t; - -// Old typedef for backwards compatibility. -typedef ANativeWindowBuffer_t android_native_buffer_t; - -// --------------------------------------------------------------------------- - -/* attributes queriable with query() */ -enum { - NATIVE_WINDOW_WIDTH = 0, - NATIVE_WINDOW_HEIGHT = 1, - NATIVE_WINDOW_FORMAT = 2, - - /* The minimum number of buffers that must remain un-dequeued after a buffer - * has been queued. This value applies only if set_buffer_count was used to - * override the number of buffers and if a buffer has since been queued. - * Users of the set_buffer_count ANativeWindow method should query this - * value before calling set_buffer_count. If it is necessary to have N - * buffers simultaneously dequeued as part of the steady-state operation, - * and this query returns M then N+M buffers should be requested via - * native_window_set_buffer_count. - * - * Note that this value does NOT apply until a single buffer has been - * queued. In particular this means that it is possible to: - * - * 1. Query M = min undequeued buffers - * 2. Set the buffer count to N + M - * 3. Dequeue all N + M buffers - * 4. Cancel M buffers - * 5. Queue, dequeue, queue, dequeue, ad infinitum - */ - NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS = 3, - - /* Check whether queueBuffer operations on the ANativeWindow send the buffer - * to the window compositor. The query sets the returned 'value' argument - * to 1 if the ANativeWindow DOES send queued buffers directly to the window - * compositor and 0 if the buffers do not go directly to the window - * compositor. - * - * This can be used to determine whether protected buffer content should be - * sent to the ANativeWindow. Note, however, that a result of 1 does NOT - * indicate that queued buffers will be protected from applications or users - * capturing their contents. If that behavior is desired then some other - * mechanism (e.g. the GRALLOC_USAGE_PROTECTED flag) should be used in - * conjunction with this query. - */ - NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER = 4, - - /* Get the concrete type of a ANativeWindow. See below for the list of - * possible return values. - * - * This query should not be used outside the Android framework and will - * likely be removed in the near future. - */ - NATIVE_WINDOW_CONCRETE_TYPE = 5, - - - /* - * Default width and height of ANativeWindow buffers, these are the - * dimensions of the window buffers irrespective of the - * NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS call and match the native window - * size unless overridden by NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS. - */ - NATIVE_WINDOW_DEFAULT_WIDTH = 6, - NATIVE_WINDOW_DEFAULT_HEIGHT = 7, - - /* - * transformation that will most-likely be applied to buffers. This is only - * a hint, the actual transformation applied might be different. - * - * INTENDED USE: - * - * The transform hint can be used by a producer, for instance the GLES - * driver, to pre-rotate the rendering such that the final transformation - * in the composer is identity. This can be very useful when used in - * conjunction with the h/w composer HAL, in situations where it - * cannot handle arbitrary rotations. - * - * 1. Before dequeuing a buffer, the GL driver (or any other ANW client) - * queries the ANW for NATIVE_WINDOW_TRANSFORM_HINT. - * - * 2. The GL driver overrides the width and height of the ANW to - * account for NATIVE_WINDOW_TRANSFORM_HINT. This is done by querying - * NATIVE_WINDOW_DEFAULT_{WIDTH | HEIGHT}, swapping the dimensions - * according to NATIVE_WINDOW_TRANSFORM_HINT and calling - * native_window_set_buffers_dimensions(). - * - * 3. The GL driver dequeues a buffer of the new pre-rotated size. - * - * 4. The GL driver renders to the buffer such that the image is - * already transformed, that is applying NATIVE_WINDOW_TRANSFORM_HINT - * to the rendering. - * - * 5. The GL driver calls native_window_set_transform to apply - * inverse transformation to the buffer it just rendered. - * In order to do this, the GL driver needs - * to calculate the inverse of NATIVE_WINDOW_TRANSFORM_HINT, this is - * done easily: - * - * int hintTransform, inverseTransform; - * query(..., NATIVE_WINDOW_TRANSFORM_HINT, &hintTransform); - * inverseTransform = hintTransform; - * if (hintTransform & HAL_TRANSFORM_ROT_90) - * inverseTransform ^= HAL_TRANSFORM_ROT_180; - * - * - * 6. The GL driver queues the pre-transformed buffer. - * - * 7. The composer combines the buffer transform with the display - * transform. If the buffer transform happens to cancel out the - * display transform then no rotation is needed. - * - */ - NATIVE_WINDOW_TRANSFORM_HINT = 8, - - /* - * Boolean that indicates whether the consumer is running more than - * one buffer behind the producer. - */ - NATIVE_WINDOW_CONSUMER_RUNNING_BEHIND = 9, - - /* - * The consumer gralloc usage bits currently set by the consumer. - * The values are defined in hardware/libhardware/include/gralloc.h. - */ - NATIVE_WINDOW_CONSUMER_USAGE_BITS = 10, - - /** - * Transformation that will by applied to buffers by the hwcomposer. - * This must not be set or checked by producer endpoints, and will - * disable the transform hint set in SurfaceFlinger (see - * NATIVE_WINDOW_TRANSFORM_HINT). - * - * INTENDED USE: - * Temporary - Please do not use this. This is intended only to be used - * by the camera's LEGACY mode. - * - * In situations where a SurfaceFlinger client wishes to set a transform - * that is not visible to the producer, and will always be applied in the - * hardware composer, the client can set this flag with - * native_window_set_buffers_sticky_transform. This can be used to rotate - * and flip buffers consumed by hardware composer without actually changing - * the aspect ratio of the buffers produced. - */ - NATIVE_WINDOW_STICKY_TRANSFORM = 11, - - /** - * The default data space for the buffers as set by the consumer. - * The values are defined in graphics.h. - */ - NATIVE_WINDOW_DEFAULT_DATASPACE = 12, - - /* - * Returns the age of the contents of the most recently dequeued buffer as - * the number of frames that have elapsed since it was last queued. For - * example, if the window is double-buffered, the age of any given buffer in - * steady state will be 2. If the dequeued buffer has never been queued, its - * age will be 0. - */ - NATIVE_WINDOW_BUFFER_AGE = 13, -}; - -/* Valid operations for the (*perform)() hook. - * - * Values marked as 'deprecated' are supported, but have been superceded by - * other functionality. - * - * Values marked as 'private' should be considered private to the framework. - * HAL implementation code with access to an ANativeWindow should not use these, - * as it may not interact properly with the framework's use of the - * ANativeWindow. - */ -enum { - NATIVE_WINDOW_SET_USAGE = 0, - NATIVE_WINDOW_CONNECT = 1, /* deprecated */ - NATIVE_WINDOW_DISCONNECT = 2, /* deprecated */ - NATIVE_WINDOW_SET_CROP = 3, /* private */ - NATIVE_WINDOW_SET_BUFFER_COUNT = 4, - NATIVE_WINDOW_SET_BUFFERS_GEOMETRY = 5, /* deprecated */ - NATIVE_WINDOW_SET_BUFFERS_TRANSFORM = 6, - NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP = 7, - NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS = 8, - NATIVE_WINDOW_SET_BUFFERS_FORMAT = 9, - NATIVE_WINDOW_SET_SCALING_MODE = 10, /* private */ - NATIVE_WINDOW_LOCK = 11, /* private */ - NATIVE_WINDOW_UNLOCK_AND_POST = 12, /* private */ - NATIVE_WINDOW_API_CONNECT = 13, /* private */ - NATIVE_WINDOW_API_DISCONNECT = 14, /* private */ - NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS = 15, /* private */ - NATIVE_WINDOW_SET_POST_TRANSFORM_CROP = 16, /* private */ - NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM = 17,/* private */ - NATIVE_WINDOW_SET_SIDEBAND_STREAM = 18, - NATIVE_WINDOW_SET_BUFFERS_DATASPACE = 19, - NATIVE_WINDOW_SET_SURFACE_DAMAGE = 20, /* private */ -}; - -/* parameter for NATIVE_WINDOW_[API_][DIS]CONNECT */ -enum { - /* Buffers will be queued by EGL via eglSwapBuffers after being filled using - * OpenGL ES. - */ - NATIVE_WINDOW_API_EGL = 1, - - /* Buffers will be queued after being filled using the CPU - */ - NATIVE_WINDOW_API_CPU = 2, - - /* Buffers will be queued by Stagefright after being filled by a video - * decoder. The video decoder can either be a software or hardware decoder. - */ - NATIVE_WINDOW_API_MEDIA = 3, - - /* Buffers will be queued by the the camera HAL. - */ - NATIVE_WINDOW_API_CAMERA = 4, -}; - -/* parameter for NATIVE_WINDOW_SET_BUFFERS_TRANSFORM */ -enum { - /* flip source image horizontally */ - NATIVE_WINDOW_TRANSFORM_FLIP_H = HAL_TRANSFORM_FLIP_H , - /* flip source image vertically */ - NATIVE_WINDOW_TRANSFORM_FLIP_V = HAL_TRANSFORM_FLIP_V, - /* rotate source image 90 degrees clock-wise, and is applied after TRANSFORM_FLIP_{H|V} */ - NATIVE_WINDOW_TRANSFORM_ROT_90 = HAL_TRANSFORM_ROT_90, - /* rotate source image 180 degrees */ - NATIVE_WINDOW_TRANSFORM_ROT_180 = HAL_TRANSFORM_ROT_180, - /* rotate source image 270 degrees clock-wise */ - NATIVE_WINDOW_TRANSFORM_ROT_270 = HAL_TRANSFORM_ROT_270, - /* transforms source by the inverse transform of the screen it is displayed onto. This - * transform is applied last */ - NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY = 0x08 -}; - -/* parameter for NATIVE_WINDOW_SET_SCALING_MODE */ -enum { - /* the window content is not updated (frozen) until a buffer of - * the window size is received (enqueued) - */ - NATIVE_WINDOW_SCALING_MODE_FREEZE = 0, - /* the buffer is scaled in both dimensions to match the window size */ - NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW = 1, - /* the buffer is scaled uniformly such that the smaller dimension - * of the buffer matches the window size (cropping in the process) - */ - NATIVE_WINDOW_SCALING_MODE_SCALE_CROP = 2, - /* the window is clipped to the size of the buffer's crop rectangle; pixels - * outside the crop rectangle are treated as if they are completely - * transparent. - */ - NATIVE_WINDOW_SCALING_MODE_NO_SCALE_CROP = 3, -}; - -/* values returned by the NATIVE_WINDOW_CONCRETE_TYPE query */ -enum { - NATIVE_WINDOW_FRAMEBUFFER = 0, /* FramebufferNativeWindow */ - NATIVE_WINDOW_SURFACE = 1, /* Surface */ -}; - -/* parameter for NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP - * - * Special timestamp value to indicate that timestamps should be auto-generated - * by the native window when queueBuffer is called. This is equal to INT64_MIN, - * defined directly to avoid problems with C99/C++ inclusion of stdint.h. - */ -static const int64_t NATIVE_WINDOW_TIMESTAMP_AUTO = (-9223372036854775807LL-1); - -struct ANativeWindow -{ -#ifdef __cplusplus - ANativeWindow() - : flags(0), minSwapInterval(0), maxSwapInterval(0), xdpi(0), ydpi(0) - { - common.magic = ANDROID_NATIVE_WINDOW_MAGIC; - common.version = sizeof(ANativeWindow); - memset(common.reserved, 0, sizeof(common.reserved)); - } - - /* Implement the methods that sp expects so that it - can be used to automatically refcount ANativeWindow's. */ - void incStrong(const void* /*id*/) const { - common.incRef(const_cast(&common)); - } - void decStrong(const void* /*id*/) const { - common.decRef(const_cast(&common)); - } -#endif - - struct android_native_base_t common; - - /* flags describing some attributes of this surface or its updater */ - const uint32_t flags; - - /* min swap interval supported by this updated */ - const int minSwapInterval; - - /* max swap interval supported by this updated */ - const int maxSwapInterval; - - /* horizontal and vertical resolution in DPI */ - const float xdpi; - const float ydpi; - - /* Some storage reserved for the OEM's driver. */ - intptr_t oem[4]; - - /* - * Set the swap interval for this surface. - * - * Returns 0 on success or -errno on error. - */ - int (*setSwapInterval)(struct ANativeWindow* window, - int interval); - - /* - * Hook called by EGL to acquire a buffer. After this call, the buffer - * is not locked, so its content cannot be modified. This call may block if - * no buffers are available. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * Returns 0 on success or -errno on error. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but the new dequeueBuffer function that - * outputs a fence file descriptor should be used in its place. - */ - int (*dequeueBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer** buffer); - - /* - * hook called by EGL to lock a buffer. This MUST be called before modifying - * the content of a buffer. The buffer must have been acquired with - * dequeueBuffer first. - * - * Returns 0 on success or -errno on error. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but it is essentially a no-op, and calls - * to it should be removed. - */ - int (*lockBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer); - - /* - * Hook called by EGL when modifications to the render buffer are done. - * This unlocks and post the buffer. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * Buffers MUST be queued in the same order than they were dequeued. - * - * Returns 0 on success or -errno on error. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but the new queueBuffer function that - * takes a fence file descriptor should be used in its place (pass a value - * of -1 for the fence file descriptor if there is no valid one to pass). - */ - int (*queueBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer); - - /* - * hook used to retrieve information about the native window. - * - * Returns 0 on success or -errno on error. - */ - int (*query)(const struct ANativeWindow* window, - int what, int* value); - - /* - * hook used to perform various operations on the surface. - * (*perform)() is a generic mechanism to add functionality to - * ANativeWindow while keeping backward binary compatibility. - * - * DO NOT CALL THIS HOOK DIRECTLY. Instead, use the helper functions - * defined below. - * - * (*perform)() returns -ENOENT if the 'what' parameter is not supported - * by the surface's implementation. - * - * See above for a list of valid operations, such as - * NATIVE_WINDOW_SET_USAGE or NATIVE_WINDOW_CONNECT - */ - int (*perform)(struct ANativeWindow* window, - int operation, ... ); - - /* - * Hook used to cancel a buffer that has been dequeued. - * No synchronization is performed between dequeue() and cancel(), so - * either external synchronization is needed, or these functions must be - * called from the same thread. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * XXX: This function is deprecated. It will continue to work for some - * time for binary compatibility, but the new cancelBuffer function that - * takes a fence file descriptor should be used in its place (pass a value - * of -1 for the fence file descriptor if there is no valid one to pass). - */ - int (*cancelBuffer_DEPRECATED)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer); - - /* - * Hook called by EGL to acquire a buffer. This call may block if no - * buffers are available. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * The libsync fence file descriptor returned in the int pointed to by the - * fenceFd argument will refer to the fence that must signal before the - * dequeued buffer may be written to. A value of -1 indicates that the - * caller may access the buffer immediately without waiting on a fence. If - * a valid file descriptor is returned (i.e. any value except -1) then the - * caller is responsible for closing the file descriptor. - * - * Returns 0 on success or -errno on error. - */ - int (*dequeueBuffer)(struct ANativeWindow* window, - struct ANativeWindowBuffer** buffer, int* fenceFd); - - /* - * Hook called by EGL when modifications to the render buffer are done. - * This unlocks and post the buffer. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * The fenceFd argument specifies a libsync fence file descriptor for a - * fence that must signal before the buffer can be accessed. If the buffer - * can be accessed immediately then a value of -1 should be used. The - * caller must not use the file descriptor after it is passed to - * queueBuffer, and the ANativeWindow implementation is responsible for - * closing it. - * - * Returns 0 on success or -errno on error. - */ - int (*queueBuffer)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer, int fenceFd); - - /* - * Hook used to cancel a buffer that has been dequeued. - * No synchronization is performed between dequeue() and cancel(), so - * either external synchronization is needed, or these functions must be - * called from the same thread. - * - * The window holds a reference to the buffer between dequeueBuffer and - * either queueBuffer or cancelBuffer, so clients only need their own - * reference if they might use the buffer after queueing or canceling it. - * Holding a reference to a buffer after queueing or canceling it is only - * allowed if a specific buffer count has been set. - * - * The fenceFd argument specifies a libsync fence file decsriptor for a - * fence that must signal before the buffer can be accessed. If the buffer - * can be accessed immediately then a value of -1 should be used. - * - * Note that if the client has not waited on the fence that was returned - * from dequeueBuffer, that same fence should be passed to cancelBuffer to - * ensure that future uses of the buffer are preceded by a wait on that - * fence. The caller must not use the file descriptor after it is passed - * to cancelBuffer, and the ANativeWindow implementation is responsible for - * closing it. - * - * Returns 0 on success or -errno on error. - */ - int (*cancelBuffer)(struct ANativeWindow* window, - struct ANativeWindowBuffer* buffer, int fenceFd); -}; - - /* Backwards compatibility: use ANativeWindow (struct ANativeWindow in C). - * android_native_window_t is deprecated. - */ -typedef struct ANativeWindow ANativeWindow; -typedef struct ANativeWindow android_native_window_t __deprecated; - -/* - * native_window_set_usage(..., usage) - * Sets the intended usage flags for the next buffers - * acquired with (*lockBuffer)() and on. - * By default (if this function is never called), a usage of - * GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE - * is assumed. - * Calling this function will usually cause following buffers to be - * reallocated. - */ - -static inline int native_window_set_usage( - struct ANativeWindow* window, int usage) -{ - return window->perform(window, NATIVE_WINDOW_SET_USAGE, usage); -} - -/* deprecated. Always returns 0. Don't call. */ -static inline int native_window_connect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; - -static inline int native_window_connect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) { - return 0; -} - -/* deprecated. Always returns 0. Don't call. */ -static inline int native_window_disconnect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) __deprecated; - -static inline int native_window_disconnect( - struct ANativeWindow* window __UNUSED, int api __UNUSED) { - return 0; -} - -/* - * native_window_set_crop(..., crop) - * Sets which region of the next queued buffers needs to be considered. - * Depending on the scaling mode, a buffer's crop region is scaled and/or - * cropped to match the surface's size. This function sets the crop in - * pre-transformed buffer pixel coordinates. - * - * The specified crop region applies to all buffers queued after it is called. - * - * If 'crop' is NULL, subsequently queued buffers won't be cropped. - * - * An error is returned if for instance the crop region is invalid, out of the - * buffer's bound or if the window is invalid. - */ -static inline int native_window_set_crop( - struct ANativeWindow* window, - android_native_rect_t const * crop) -{ - return window->perform(window, NATIVE_WINDOW_SET_CROP, crop); -} - -/* - * native_window_set_post_transform_crop(..., crop) - * Sets which region of the next queued buffers needs to be considered. - * Depending on the scaling mode, a buffer's crop region is scaled and/or - * cropped to match the surface's size. This function sets the crop in - * post-transformed pixel coordinates. - * - * The specified crop region applies to all buffers queued after it is called. - * - * If 'crop' is NULL, subsequently queued buffers won't be cropped. - * - * An error is returned if for instance the crop region is invalid, out of the - * buffer's bound or if the window is invalid. - */ -static inline int native_window_set_post_transform_crop( - struct ANativeWindow* window, - android_native_rect_t const * crop) -{ - return window->perform(window, NATIVE_WINDOW_SET_POST_TRANSFORM_CROP, crop); -} - -/* - * native_window_set_active_rect(..., active_rect) - * - * This function is deprecated and will be removed soon. For now it simply - * sets the post-transform crop for compatibility while multi-project commits - * get checked. - */ -static inline int native_window_set_active_rect( - struct ANativeWindow* window, - android_native_rect_t const * active_rect) __deprecated; - -static inline int native_window_set_active_rect( - struct ANativeWindow* window, - android_native_rect_t const * active_rect) -{ - return native_window_set_post_transform_crop(window, active_rect); -} - -/* - * native_window_set_buffer_count(..., count) - * Sets the number of buffers associated with this native window. - */ -static inline int native_window_set_buffer_count( - struct ANativeWindow* window, - size_t bufferCount) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFER_COUNT, bufferCount); -} - -/* - * native_window_set_buffers_geometry(..., int w, int h, int format) - * All buffers dequeued after this call will have the dimensions and format - * specified. A successful call to this function has the same effect as calling - * native_window_set_buffers_size and native_window_set_buffers_format. - * - * XXX: This function is deprecated. The native_window_set_buffers_dimensions - * and native_window_set_buffers_format functions should be used instead. - */ -static inline int native_window_set_buffers_geometry( - struct ANativeWindow* window, - int w, int h, int format) __deprecated; - -static inline int native_window_set_buffers_geometry( - struct ANativeWindow* window, - int w, int h, int format) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_GEOMETRY, - w, h, format); -} - -/* - * native_window_set_buffers_dimensions(..., int w, int h) - * All buffers dequeued after this call will have the dimensions specified. - * In particular, all buffers will have a fixed-size, independent from the - * native-window size. They will be scaled according to the scaling mode - * (see native_window_set_scaling_mode) upon window composition. - * - * If w and h are 0, the normal behavior is restored. That is, dequeued buffers - * following this call will be sized to match the window's size. - * - * Calling this function will reset the window crop to a NULL value, which - * disables cropping of the buffers. - */ -static inline int native_window_set_buffers_dimensions( - struct ANativeWindow* window, - int w, int h) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS, - w, h); -} - -/* - * native_window_set_buffers_user_dimensions(..., int w, int h) - * - * Sets the user buffer size for the window, which overrides the - * window's size. All buffers dequeued after this call will have the - * dimensions specified unless overridden by - * native_window_set_buffers_dimensions. All buffers will have a - * fixed-size, independent from the native-window size. They will be - * scaled according to the scaling mode (see - * native_window_set_scaling_mode) upon window composition. - * - * If w and h are 0, the normal behavior is restored. That is, the - * default buffer size will match the windows's size. - * - * Calling this function will reset the window crop to a NULL value, which - * disables cropping of the buffers. - */ -static inline int native_window_set_buffers_user_dimensions( - struct ANativeWindow* window, - int w, int h) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_USER_DIMENSIONS, - w, h); -} - -/* - * native_window_set_buffers_format(..., int format) - * All buffers dequeued after this call will have the format specified. - * - * If the specified format is 0, the default buffer format will be used. - */ -static inline int native_window_set_buffers_format( - struct ANativeWindow* window, - int format) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_FORMAT, format); -} - -/* - * native_window_set_buffers_data_space(..., int dataSpace) - * All buffers queued after this call will be associated with the dataSpace - * parameter specified. - * - * dataSpace specifies additional information about the buffer that's dependent - * on the buffer format and the endpoints. For example, it can be used to convey - * the color space of the image data in the buffer, or it can be used to - * indicate that the buffers contain depth measurement data instead of color - * images. The default dataSpace is 0, HAL_DATASPACE_UNKNOWN, unless it has been - * overridden by the consumer. - */ -static inline int native_window_set_buffers_data_space( - struct ANativeWindow* window, - android_dataspace_t dataSpace) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_DATASPACE, - dataSpace); -} - -/* - * native_window_set_buffers_transform(..., int transform) - * All buffers queued after this call will be displayed transformed according - * to the transform parameter specified. - */ -static inline int native_window_set_buffers_transform( - struct ANativeWindow* window, - int transform) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TRANSFORM, - transform); -} - -/* - * native_window_set_buffers_sticky_transform(..., int transform) - * All buffers queued after this call will be displayed transformed according - * to the transform parameter specified applied on top of the regular buffer - * transform. Setting this transform will disable the transform hint. - * - * Temporary - This is only intended to be used by the LEGACY camera mode, do - * not use this for anything else. - */ -static inline int native_window_set_buffers_sticky_transform( - struct ANativeWindow* window, - int transform) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_STICKY_TRANSFORM, - transform); -} - -/* - * native_window_set_buffers_timestamp(..., int64_t timestamp) - * All buffers queued after this call will be associated with the timestamp - * parameter specified. If the timestamp is set to NATIVE_WINDOW_TIMESTAMP_AUTO - * (the default), timestamps will be generated automatically when queueBuffer is - * called. The timestamp is measured in nanoseconds, and is normally monotonically - * increasing. The timestamp should be unaffected by time-of-day adjustments, - * and for a camera should be strictly monotonic but for a media player may be - * reset when the position is set. - */ -static inline int native_window_set_buffers_timestamp( - struct ANativeWindow* window, - int64_t timestamp) -{ - return window->perform(window, NATIVE_WINDOW_SET_BUFFERS_TIMESTAMP, - timestamp); -} - -/* - * native_window_set_scaling_mode(..., int mode) - * All buffers queued after this call will be associated with the scaling mode - * specified. - */ -static inline int native_window_set_scaling_mode( - struct ANativeWindow* window, - int mode) -{ - return window->perform(window, NATIVE_WINDOW_SET_SCALING_MODE, - mode); -} - -/* - * native_window_api_connect(..., int api) - * connects an API to this window. only one API can be connected at a time. - * Returns -EINVAL if for some reason the window cannot be connected, which - * can happen if it's connected to some other API. - */ -static inline int native_window_api_connect( - struct ANativeWindow* window, int api) -{ - return window->perform(window, NATIVE_WINDOW_API_CONNECT, api); -} - -/* - * native_window_api_disconnect(..., int api) - * disconnect the API from this window. - * An error is returned if for instance the window wasn't connected in the - * first place. - */ -static inline int native_window_api_disconnect( - struct ANativeWindow* window, int api) -{ - return window->perform(window, NATIVE_WINDOW_API_DISCONNECT, api); -} - -/* - * native_window_dequeue_buffer_and_wait(...) - * Dequeue a buffer and wait on the fence associated with that buffer. The - * buffer may safely be accessed immediately upon this function returning. An - * error is returned if either of the dequeue or the wait operations fail. - */ -static inline int native_window_dequeue_buffer_and_wait(ANativeWindow *anw, - struct ANativeWindowBuffer** anb) { - return anw->dequeueBuffer_DEPRECATED(anw, anb); -} - -/* - * native_window_set_sideband_stream(..., native_handle_t*) - * Attach a sideband buffer stream to a native window. - */ -static inline int native_window_set_sideband_stream( - struct ANativeWindow* window, - native_handle_t* sidebandHandle) -{ - return window->perform(window, NATIVE_WINDOW_SET_SIDEBAND_STREAM, - sidebandHandle); -} - -/* - * native_window_set_surface_damage(..., android_native_rect_t* rects, int numRects) - * Set the surface damage (i.e., the region of the surface that has changed - * since the previous frame). The damage set by this call will be reset (to the - * default of full-surface damage) after calling queue, so this must be called - * prior to every frame with damage that does not cover the whole surface if the - * caller desires downstream consumers to use this optimization. - * - * The damage region is specified as an array of rectangles, with the important - * caveat that the origin of the surface is considered to be the bottom-left - * corner, as in OpenGL ES. - * - * If numRects is set to 0, rects may be NULL, and the surface damage will be - * set to the full surface (the same as if this function had not been called for - * this frame). - */ -static inline int native_window_set_surface_damage( - struct ANativeWindow* window, - const android_native_rect_t* rects, size_t numRects) -{ - return window->perform(window, NATIVE_WINDOW_SET_SURFACE_DAMAGE, - rects, numRects); -} - -__END_DECLS - -#endif /* SYSTEM_CORE_INCLUDE_ANDROID_WINDOW_H */ diff --git a/third_party/android_system_core/include/utils/AndroidThreads.h b/third_party/android_system_core/include/utils/AndroidThreads.h deleted file mode 100644 index aad1e82cb..000000000 --- a/third_party/android_system_core/include/utils/AndroidThreads.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_UTILS_ANDROID_THREADS_H -#define _LIBS_UTILS_ANDROID_THREADS_H - -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include - -// --------------------------------------------------------------------------- -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -// Create and run a new thread. -extern int androidCreateThread(android_thread_func_t, void *); - -// Create thread with lots of parameters -extern int androidCreateThreadEtc(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -// Get some sort of unique identifier for the current thread. -extern android_thread_id_t androidGetThreadId(); - -// Low-level thread creation -- never creates threads that can -// interact with the Java VM. -extern int androidCreateRawThreadEtc(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -// set the same of the running thread -extern void androidSetThreadName(const char* name); - -// Used by the Java Runtime to control how threads are created, so that -// they can be proper and lovely Java threads. -typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -extern void androidSetCreateThreadFunc(android_create_thread_fn func); - -// ------------------------------------------------------------------ -// Extra functions working with raw pids. - -#ifdef HAVE_ANDROID_OS -// Change the priority AND scheduling group of a particular thread. The priority -// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION -// if the priority set failed, else another value if just the group set failed; -// in either case errno is set. Thread ID zero means current thread. -extern int androidSetThreadPriority(pid_t tid, int prio); - -// Get the current priority of a particular thread. Returns one of the -// ANDROID_PRIORITY constants or a negative result in case of error. -extern int androidGetThreadPriority(pid_t tid); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -// ---------------------------------------------------------------------------- -// C++ API -#ifdef __cplusplus -namespace android { -// ---------------------------------------------------------------------------- - -// Create and run a new thread. -inline bool createThread(thread_func_t f, void *a) { - return androidCreateThread(f, a) ? true : false; -} - -// Create thread with lots of parameters -inline bool createThreadEtc(thread_func_t entryFunction, - void *userData, - const char* threadName = "android:unnamed_thread", - int32_t threadPriority = PRIORITY_DEFAULT, - size_t threadStackSize = 0, - thread_id_t *threadId = 0) -{ - return androidCreateThreadEtc(entryFunction, userData, threadName, - threadPriority, threadStackSize, threadId) ? true : false; -} - -// Get some sort of unique identifier for the current thread. -inline thread_id_t getThreadId() { - return androidGetThreadId(); -} - -// ---------------------------------------------------------------------------- -}; // namespace android -#endif // __cplusplus -// ---------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_ANDROID_THREADS_H diff --git a/third_party/android_system_core/include/utils/Atomic.h b/third_party/android_system_core/include/utils/Atomic.h deleted file mode 100644 index 7eb476c94..000000000 --- a/third_party/android_system_core/include/utils/Atomic.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_UTILS_ATOMIC_H -#define ANDROID_UTILS_ATOMIC_H - -#include - -#endif // ANDROID_UTILS_ATOMIC_H diff --git a/third_party/android_system_core/include/utils/BasicHashtable.h b/third_party/android_system_core/include/utils/BasicHashtable.h deleted file mode 100644 index c235d6252..000000000 --- a/third_party/android_system_core/include/utils/BasicHashtable.h +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ANDROID_BASIC_HASHTABLE_H -#define ANDROID_BASIC_HASHTABLE_H - -#include -#include -#include -#include - -namespace android { - -/* Implementation type. Nothing to see here. */ -class BasicHashtableImpl { -protected: - struct Bucket { - // The collision flag indicates that the bucket is part of a collision chain - // such that at least two entries both hash to this bucket. When true, we - // may need to seek further along the chain to find the entry. - static const uint32_t COLLISION = 0x80000000UL; - - // The present flag indicates that the bucket contains an initialized entry value. - static const uint32_t PRESENT = 0x40000000UL; - - // Mask for 30 bits worth of the hash code that are stored within the bucket to - // speed up lookups and rehashing by eliminating the need to recalculate the - // hash code of the entry's key. - static const uint32_t HASH_MASK = 0x3fffffffUL; - - // Combined value that stores the collision and present flags as well as - // a 30 bit hash code. - uint32_t cookie; - - // Storage for the entry begins here. - char entry[0]; - }; - - BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor, - size_t minimumInitialCapacity, float loadFactor); - BasicHashtableImpl(const BasicHashtableImpl& other); - virtual ~BasicHashtableImpl(); - - void dispose(); - - inline void edit() { - if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) { - clone(); - } - } - - void setTo(const BasicHashtableImpl& other); - void clear(); - - ssize_t next(ssize_t index) const; - ssize_t find(ssize_t index, hash_t hash, const void* __restrict__ key) const; - size_t add(hash_t hash, const void* __restrict__ entry); - void removeAt(size_t index); - void rehash(size_t minimumCapacity, float loadFactor); - - const size_t mBucketSize; // number of bytes per bucket including the entry - const bool mHasTrivialDestructor; // true if the entry type does not require destruction - size_t mCapacity; // number of buckets that can be filled before exceeding load factor - float mLoadFactor; // load factor - size_t mSize; // number of elements actually in the table - size_t mFilledBuckets; // number of buckets for which collision or present is true - size_t mBucketCount; // number of slots in the mBuckets array - void* mBuckets; // array of buckets, as a SharedBuffer - - inline const Bucket& bucketAt(const void* __restrict__ buckets, size_t index) const { - return *reinterpret_cast( - static_cast(buckets) + index * mBucketSize); - } - - inline Bucket& bucketAt(void* __restrict__ buckets, size_t index) const { - return *reinterpret_cast(static_cast(buckets) + index * mBucketSize); - } - - virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const = 0; - virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const = 0; - virtual void destroyBucketEntry(Bucket& bucket) const = 0; - -private: - void clone(); - - // Allocates a bucket array as a SharedBuffer. - void* allocateBuckets(size_t count) const; - - // Releases a bucket array's associated SharedBuffer. - void releaseBuckets(void* __restrict__ buckets, size_t count) const; - - // Destroys the contents of buckets (invokes destroyBucketEntry for each - // populated bucket if needed). - void destroyBuckets(void* __restrict__ buckets, size_t count) const; - - // Copies the content of buckets (copies the cookie and invokes copyBucketEntry - // for each populated bucket if needed). - void copyBuckets(const void* __restrict__ fromBuckets, - void* __restrict__ toBuckets, size_t count) const; - - // Determines the appropriate size of a bucket array to store a certain minimum - // number of entries and returns its effective capacity. - static void determineCapacity(size_t minimumCapacity, float loadFactor, - size_t* __restrict__ outBucketCount, size_t* __restrict__ outCapacity); - - // Trim a hash code to 30 bits to match what we store in the bucket's cookie. - inline static hash_t trimHash(hash_t hash) { - return (hash & Bucket::HASH_MASK) ^ (hash >> 30); - } - - // Returns the index of the first bucket that is in the collision chain - // for the specified hash code, given the total number of buckets. - // (Primary hash) - inline static size_t chainStart(hash_t hash, size_t count) { - return hash % count; - } - - // Returns the increment to add to a bucket index to seek to the next bucket - // in the collision chain for the specified hash code, given the total number of buckets. - // (Secondary hash) - inline static size_t chainIncrement(hash_t hash, size_t count) { - return ((hash >> 7) | (hash << 25)) % (count - 1) + 1; - } - - // Returns the index of the next bucket that is in the collision chain - // that is defined by the specified increment, given the total number of buckets. - inline static size_t chainSeek(size_t index, size_t increment, size_t count) { - return (index + increment) % count; - } -}; - -/* - * A BasicHashtable stores entries that are indexed by hash code in place - * within an array. The basic operations are finding entries by key, - * adding new entries and removing existing entries. - * - * This class provides a very limited set of operations with simple semantics. - * It is intended to be used as a building block to construct more complex - * and interesting data structures such as HashMap. Think very hard before - * adding anything extra to BasicHashtable, it probably belongs at a - * higher level of abstraction. - * - * TKey: The key type. - * TEntry: The entry type which is what is actually stored in the array. - * - * TKey must support the following contract: - * bool operator==(const TKey& other) const; // return true if equal - * bool operator!=(const TKey& other) const; // return true if unequal - * - * TEntry must support the following contract: - * const TKey& getKey() const; // get the key from the entry - * - * This class supports storing entries with duplicate keys. Of course, it can't - * tell them apart during removal so only the first entry will be removed. - * We do this because it means that operations like add() can't fail. - */ -template -class BasicHashtable : private BasicHashtableImpl { -public: - /* Creates a hashtable with the specified minimum initial capacity. - * The underlying array will be created when the first entry is added. - * - * minimumInitialCapacity: The minimum initial capacity for the hashtable. - * Default is 0. - * loadFactor: The desired load factor for the hashtable, between 0 and 1. - * Default is 0.75. - */ - BasicHashtable(size_t minimumInitialCapacity = 0, float loadFactor = 0.75f); - - /* Copies a hashtable. - * The underlying storage is shared copy-on-write. - */ - BasicHashtable(const BasicHashtable& other); - - /* Clears and destroys the hashtable. - */ - virtual ~BasicHashtable(); - - /* Making this hashtable a copy of the other hashtable. - * The underlying storage is shared copy-on-write. - * - * other: The hashtable to copy. - */ - inline BasicHashtable& operator =(const BasicHashtable & other) { - setTo(other); - return *this; - } - - /* Returns the number of entries in the hashtable. - */ - inline size_t size() const { - return mSize; - } - - /* Returns the capacity of the hashtable, which is the number of elements that can - * added to the hashtable without requiring it to be grown. - */ - inline size_t capacity() const { - return mCapacity; - } - - /* Returns the number of buckets that the hashtable has, which is the size of its - * underlying array. - */ - inline size_t bucketCount() const { - return mBucketCount; - } - - /* Returns the load factor of the hashtable. */ - inline float loadFactor() const { - return mLoadFactor; - }; - - /* Returns a const reference to the entry at the specified index. - * - * index: The index of the entry to retrieve. Must be a valid index within - * the bounds of the hashtable. - */ - inline const TEntry& entryAt(size_t index) const { - return entryFor(bucketAt(mBuckets, index)); - } - - /* Returns a non-const reference to the entry at the specified index. - * - * index: The index of the entry to edit. Must be a valid index within - * the bounds of the hashtable. - */ - inline TEntry& editEntryAt(size_t index) { - edit(); - return entryFor(bucketAt(mBuckets, index)); - } - - /* Clears the hashtable. - * All entries in the hashtable are destroyed immediately. - * If you need to do something special with the entries in the hashtable then iterate - * over them and do what you need before clearing the hashtable. - */ - inline void clear() { - BasicHashtableImpl::clear(); - } - - /* Returns the index of the next entry in the hashtable given the index of a previous entry. - * If the given index is -1, then returns the index of the first entry in the hashtable, - * if there is one, or -1 otherwise. - * If the given index is not -1, then returns the index of the next entry in the hashtable, - * in strictly increasing order, or -1 if there are none left. - * - * index: The index of the previous entry that was iterated, or -1 to begin - * iteration at the beginning of the hashtable. - */ - inline ssize_t next(ssize_t index) const { - return BasicHashtableImpl::next(index); - } - - /* Finds the index of an entry with the specified key. - * If the given index is -1, then returns the index of the first matching entry, - * otherwise returns the index of the next matching entry. - * If the hashtable contains multiple entries with keys that match the requested - * key, then the sequence of entries returned is arbitrary. - * Returns -1 if no entry was found. - * - * index: The index of the previous entry with the specified key, or -1 to - * find the first matching entry. - * hash: The hashcode of the key. - * key: The key. - */ - inline ssize_t find(ssize_t index, hash_t hash, const TKey& key) const { - return BasicHashtableImpl::find(index, hash, &key); - } - - /* Adds the entry to the hashtable. - * Returns the index of the newly added entry. - * If an entry with the same key already exists, then a duplicate entry is added. - * If the entry will not fit, then the hashtable's capacity is increased and - * its contents are rehashed. See rehash(). - * - * hash: The hashcode of the key. - * entry: The entry to add. - */ - inline size_t add(hash_t hash, const TEntry& entry) { - return BasicHashtableImpl::add(hash, &entry); - } - - /* Removes the entry with the specified index from the hashtable. - * The entry is destroyed immediately. - * The index must be valid. - * - * The hashtable is not compacted after an item is removed, so it is legal - * to continue iterating over the hashtable using next() or find(). - * - * index: The index of the entry to remove. Must be a valid index within the - * bounds of the hashtable, and it must refer to an existing entry. - */ - inline void removeAt(size_t index) { - BasicHashtableImpl::removeAt(index); - } - - /* Rehashes the contents of the hashtable. - * Grows the hashtable to at least the specified minimum capacity or the - * current number of elements, whichever is larger. - * - * Rehashing causes all entries to be copied and the entry indices may change. - * Although the hash codes are cached by the hashtable, rehashing can be an - * expensive operation and should be avoided unless the hashtable's size - * needs to be changed. - * - * Rehashing is the only way to change the capacity or load factor of the - * hashtable once it has been created. It can be used to compact the - * hashtable by choosing a minimum capacity that is smaller than the current - * capacity (such as 0). - * - * minimumCapacity: The desired minimum capacity after rehashing. - * loadFactor: The desired load factor after rehashing. - */ - inline void rehash(size_t minimumCapacity, float loadFactor) { - BasicHashtableImpl::rehash(minimumCapacity, loadFactor); - } - - /* Determines whether there is room to add another entry without rehashing. - * When this returns true, a subsequent add() operation is guaranteed to - * complete without performing a rehash. - */ - inline bool hasMoreRoom() const { - return mCapacity > mFilledBuckets; - } - -protected: - static inline const TEntry& entryFor(const Bucket& bucket) { - return reinterpret_cast(bucket.entry); - } - - static inline TEntry& entryFor(Bucket& bucket) { - return reinterpret_cast(bucket.entry); - } - - virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const; - virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const; - virtual void destroyBucketEntry(Bucket& bucket) const; - -private: - // For dumping the raw contents of a hashtable during testing. - friend class BasicHashtableTest; - inline uint32_t cookieAt(size_t index) const { - return bucketAt(mBuckets, index).cookie; - } -}; - -template -BasicHashtable::BasicHashtable(size_t minimumInitialCapacity, float loadFactor) : - BasicHashtableImpl(sizeof(TEntry), traits::has_trivial_dtor, - minimumInitialCapacity, loadFactor) { -} - -template -BasicHashtable::BasicHashtable(const BasicHashtable& other) : - BasicHashtableImpl(other) { -} - -template -BasicHashtable::~BasicHashtable() { - dispose(); -} - -template -bool BasicHashtable::compareBucketKey(const Bucket& bucket, - const void* __restrict__ key) const { - return entryFor(bucket).getKey() == *static_cast(key); -} - -template -void BasicHashtable::initializeBucketEntry(Bucket& bucket, - const void* __restrict__ entry) const { - if (!traits::has_trivial_copy) { - new (&entryFor(bucket)) TEntry(*(static_cast(entry))); - } else { - memcpy(&entryFor(bucket), entry, sizeof(TEntry)); - } -} - -template -void BasicHashtable::destroyBucketEntry(Bucket& bucket) const { - if (!traits::has_trivial_dtor) { - entryFor(bucket).~TEntry(); - } -} - -}; // namespace android - -#endif // ANDROID_BASIC_HASHTABLE_H diff --git a/third_party/android_system_core/include/utils/BitSet.h b/third_party/android_system_core/include/utils/BitSet.h deleted file mode 100644 index 8c612931d..000000000 --- a/third_party/android_system_core/include/utils/BitSet.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef UTILS_BITSET_H -#define UTILS_BITSET_H - -#include -#include - -/* - * Contains some bit manipulation helpers. - */ - -namespace android { - -// A simple set of 32 bits that can be individually marked or cleared. -struct BitSet32 { - uint32_t value; - - inline BitSet32() : value(0UL) { } - explicit inline BitSet32(uint32_t value) : value(value) { } - - // Gets the value associated with a particular bit index. - static inline uint32_t valueForBit(uint32_t n) { return 0x80000000UL >> n; } - - // Clears the bit set. - inline void clear() { clear(value); } - - static inline void clear(uint32_t& value) { value = 0UL; } - - // Returns the number of marked bits in the set. - inline uint32_t count() const { return count(value); } - - static inline uint32_t count(uint32_t value) { return __builtin_popcountl(value); } - - // Returns true if the bit set does not contain any marked bits. - inline bool isEmpty() const { return isEmpty(value); } - - static inline bool isEmpty(uint32_t value) { return ! value; } - - // Returns true if the bit set does not contain any unmarked bits. - inline bool isFull() const { return isFull(value); } - - static inline bool isFull(uint32_t value) { return value == 0xffffffffUL; } - - // Returns true if the specified bit is marked. - inline bool hasBit(uint32_t n) const { return hasBit(value, n); } - - static inline bool hasBit(uint32_t value, uint32_t n) { return value & valueForBit(n); } - - // Marks the specified bit. - inline void markBit(uint32_t n) { markBit(value, n); } - - static inline void markBit (uint32_t& value, uint32_t n) { value |= valueForBit(n); } - - // Clears the specified bit. - inline void clearBit(uint32_t n) { clearBit(value, n); } - - static inline void clearBit(uint32_t& value, uint32_t n) { value &= ~ valueForBit(n); } - - // Finds the first marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } - - static uint32_t firstMarkedBit(uint32_t value) { return clz_checked(value); } - - // Finds the first unmarked bit in the set. - // Result is undefined if all bits are marked. - inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } - - static inline uint32_t firstUnmarkedBit(uint32_t value) { return clz_checked(~ value); } - - // Finds the last marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } - - static inline uint32_t lastMarkedBit(uint32_t value) { return 31 - ctz_checked(value); } - - // Finds the first marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } - - static inline uint32_t clearFirstMarkedBit(uint32_t& value) { - uint32_t n = firstMarkedBit(value); - clearBit(value, n); - return n; - } - - // Finds the first unmarked bit in the set and marks it. Returns the bit index. - // Result is undefined if all bits are marked. - inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } - - static inline uint32_t markFirstUnmarkedBit(uint32_t& value) { - uint32_t n = firstUnmarkedBit(value); - markBit(value, n); - return n; - } - - // Finds the last marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } - - static inline uint32_t clearLastMarkedBit(uint32_t& value) { - uint32_t n = lastMarkedBit(value); - clearBit(value, n); - return n; - } - - // Gets the index of the specified bit in the set, which is the number of - // marked bits that appear before the specified bit. - inline uint32_t getIndexOfBit(uint32_t n) const { - return getIndexOfBit(value, n); - } - - static inline uint32_t getIndexOfBit(uint32_t value, uint32_t n) { - return __builtin_popcountl(value & ~(0xffffffffUL >> n)); - } - - inline bool operator== (const BitSet32& other) const { return value == other.value; } - inline bool operator!= (const BitSet32& other) const { return value != other.value; } - inline BitSet32 operator& (const BitSet32& other) const { - return BitSet32(value & other.value); - } - inline BitSet32& operator&= (const BitSet32& other) { - value &= other.value; - return *this; - } - inline BitSet32 operator| (const BitSet32& other) const { - return BitSet32(value | other.value); - } - inline BitSet32& operator|= (const BitSet32& other) { - value |= other.value; - return *this; - } - -private: - // We use these helpers as the signature of __builtin_c{l,t}z has "unsigned int" for the - // input, which is only guaranteed to be 16b, not 32. The compiler should optimize this away. - static inline uint32_t clz_checked(uint32_t value) { - if (sizeof(unsigned int) == sizeof(uint32_t)) { - return __builtin_clz(value); - } else { - return __builtin_clzl(value); - } - } - - static inline uint32_t ctz_checked(uint32_t value) { - if (sizeof(unsigned int) == sizeof(uint32_t)) { - return __builtin_ctz(value); - } else { - return __builtin_ctzl(value); - } - } -}; - -ANDROID_BASIC_TYPES_TRAITS(BitSet32) - -// A simple set of 64 bits that can be individually marked or cleared. -struct BitSet64 { - uint64_t value; - - inline BitSet64() : value(0ULL) { } - explicit inline BitSet64(uint64_t value) : value(value) { } - - // Gets the value associated with a particular bit index. - static inline uint64_t valueForBit(uint32_t n) { return 0x8000000000000000ULL >> n; } - - // Clears the bit set. - inline void clear() { clear(value); } - - static inline void clear(uint64_t& value) { value = 0ULL; } - - // Returns the number of marked bits in the set. - inline uint32_t count() const { return count(value); } - - static inline uint32_t count(uint64_t value) { return __builtin_popcountll(value); } - - // Returns true if the bit set does not contain any marked bits. - inline bool isEmpty() const { return isEmpty(value); } - - static inline bool isEmpty(uint64_t value) { return ! value; } - - // Returns true if the bit set does not contain any unmarked bits. - inline bool isFull() const { return isFull(value); } - - static inline bool isFull(uint64_t value) { return value == 0xffffffffffffffffULL; } - - // Returns true if the specified bit is marked. - inline bool hasBit(uint32_t n) const { return hasBit(value, n); } - - static inline bool hasBit(uint64_t value, uint32_t n) { return value & valueForBit(n); } - - // Marks the specified bit. - inline void markBit(uint32_t n) { markBit(value, n); } - - static inline void markBit(uint64_t& value, uint32_t n) { value |= valueForBit(n); } - - // Clears the specified bit. - inline void clearBit(uint32_t n) { clearBit(value, n); } - - static inline void clearBit(uint64_t& value, uint32_t n) { value &= ~ valueForBit(n); } - - // Finds the first marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } - - static inline uint32_t firstMarkedBit(uint64_t value) { return __builtin_clzll(value); } - - // Finds the first unmarked bit in the set. - // Result is undefined if all bits are marked. - inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } - - static inline uint32_t firstUnmarkedBit(uint64_t value) { return __builtin_clzll(~ value); } - - // Finds the last marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } - - static inline uint32_t lastMarkedBit(uint64_t value) { return 63 - __builtin_ctzll(value); } - - // Finds the first marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } - - static inline uint32_t clearFirstMarkedBit(uint64_t& value) { - uint64_t n = firstMarkedBit(value); - clearBit(value, n); - return n; - } - - // Finds the first unmarked bit in the set and marks it. Returns the bit index. - // Result is undefined if all bits are marked. - inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } - - static inline uint32_t markFirstUnmarkedBit(uint64_t& value) { - uint64_t n = firstUnmarkedBit(value); - markBit(value, n); - return n; - } - - // Finds the last marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } - - static inline uint32_t clearLastMarkedBit(uint64_t& value) { - uint64_t n = lastMarkedBit(value); - clearBit(value, n); - return n; - } - - // Gets the index of the specified bit in the set, which is the number of - // marked bits that appear before the specified bit. - inline uint32_t getIndexOfBit(uint32_t n) const { return getIndexOfBit(value, n); } - - static inline uint32_t getIndexOfBit(uint64_t value, uint32_t n) { - return __builtin_popcountll(value & ~(0xffffffffffffffffULL >> n)); - } - - inline bool operator== (const BitSet64& other) const { return value == other.value; } - inline bool operator!= (const BitSet64& other) const { return value != other.value; } - inline BitSet64 operator& (const BitSet64& other) const { - return BitSet64(value & other.value); - } - inline BitSet64& operator&= (const BitSet64& other) { - value &= other.value; - return *this; - } - inline BitSet64 operator| (const BitSet64& other) const { - return BitSet64(value | other.value); - } - inline BitSet64& operator|= (const BitSet64& other) { - value |= other.value; - return *this; - } -}; - -ANDROID_BASIC_TYPES_TRAITS(BitSet64) - -} // namespace android - -#endif // UTILS_BITSET_H diff --git a/third_party/android_system_core/include/utils/BlobCache.h b/third_party/android_system_core/include/utils/BlobCache.h deleted file mode 100644 index 65dca9fb4..000000000 --- a/third_party/android_system_core/include/utils/BlobCache.h +++ /dev/null @@ -1,249 +0,0 @@ -/* - ** Copyright 2011, 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. - */ - -#ifndef ANDROID_BLOB_CACHE_H -#define ANDROID_BLOB_CACHE_H - -#include - -#include -#include -#include -#include - -namespace android { - -// A BlobCache is an in-memory cache for binary key/value pairs. A BlobCache -// does NOT provide any thread-safety guarantees. -// -// The cache contents can be serialized to an in-memory buffer or mmap'd file -// and then reloaded in a subsequent execution of the program. This -// serialization is non-portable and the data should only be used by the device -// that generated it. -class BlobCache : public RefBase { - -public: - - // Create an empty blob cache. The blob cache will cache key/value pairs - // with key and value sizes less than or equal to maxKeySize and - // maxValueSize, respectively. The total combined size of ALL cache entries - // (key sizes plus value sizes) will not exceed maxTotalSize. - BlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize); - - // set inserts a new binary value into the cache and associates it with the - // given binary key. If the key or value are too large for the cache then - // the cache remains unchanged. This includes the case where a different - // value was previously associated with the given key - the old value will - // remain in the cache. If the given key and value are small enough to be - // put in the cache (based on the maxKeySize, maxValueSize, and maxTotalSize - // values specified to the BlobCache constructor), then the key/value pair - // will be in the cache after set returns. Note, however, that a subsequent - // call to set may evict old key/value pairs from the cache. - // - // Preconditions: - // key != NULL - // 0 < keySize - // value != NULL - // 0 < valueSize - void set(const void* key, size_t keySize, const void* value, - size_t valueSize); - - // get retrieves from the cache the binary value associated with a given - // binary key. If the key is present in the cache then the length of the - // binary value associated with that key is returned. If the value argument - // is non-NULL and the size of the cached value is less than valueSize bytes - // then the cached value is copied into the buffer pointed to by the value - // argument. If the key is not present in the cache then 0 is returned and - // the buffer pointed to by the value argument is not modified. - // - // Note that when calling get multiple times with the same key, the later - // calls may fail, returning 0, even if earlier calls succeeded. The return - // value must be checked for each call. - // - // Preconditions: - // key != NULL - // 0 < keySize - // 0 <= valueSize - size_t get(const void* key, size_t keySize, void* value, size_t valueSize); - - - // getFlattenedSize returns the number of bytes needed to store the entire - // serialized cache. - size_t getFlattenedSize() const; - - // flatten serializes the current contents of the cache into the memory - // pointed to by 'buffer'. The serialized cache contents can later be - // loaded into a BlobCache object using the unflatten method. The contents - // of the BlobCache object will not be modified. - // - // Preconditions: - // size >= this.getFlattenedSize() - status_t flatten(void* buffer, size_t size) const; - - // unflatten replaces the contents of the cache with the serialized cache - // contents in the memory pointed to by 'buffer'. The previous contents of - // the BlobCache will be evicted from the cache. If an error occurs while - // unflattening the serialized cache contents then the BlobCache will be - // left in an empty state. - // - status_t unflatten(void const* buffer, size_t size); - -private: - // Copying is disallowed. - BlobCache(const BlobCache&); - void operator=(const BlobCache&); - - // A random function helper to get around MinGW not having nrand48() - long int blob_random(); - - // clean evicts a randomly chosen set of entries from the cache such that - // the total size of all remaining entries is less than mMaxTotalSize/2. - void clean(); - - // isCleanable returns true if the cache is full enough for the clean method - // to have some effect, and false otherwise. - bool isCleanable() const; - - // A Blob is an immutable sized unstructured data blob. - class Blob : public RefBase { - public: - Blob(const void* data, size_t size, bool copyData); - ~Blob(); - - bool operator<(const Blob& rhs) const; - - const void* getData() const; - size_t getSize() const; - - private: - // Copying is not allowed. - Blob(const Blob&); - void operator=(const Blob&); - - // mData points to the buffer containing the blob data. - const void* mData; - - // mSize is the size of the blob data in bytes. - size_t mSize; - - // mOwnsData indicates whether or not this Blob object should free the - // memory pointed to by mData when the Blob gets destructed. - bool mOwnsData; - }; - - // A CacheEntry is a single key/value pair in the cache. - class CacheEntry { - public: - CacheEntry(); - CacheEntry(const sp& key, const sp& value); - CacheEntry(const CacheEntry& ce); - - bool operator<(const CacheEntry& rhs) const; - const CacheEntry& operator=(const CacheEntry&); - - sp getKey() const; - sp getValue() const; - - void setValue(const sp& value); - - private: - - // mKey is the key that identifies the cache entry. - sp mKey; - - // mValue is the cached data associated with the key. - sp mValue; - }; - - // A Header is the header for the entire BlobCache serialization format. No - // need to make this portable, so we simply write the struct out. - struct Header { - // mMagicNumber is the magic number that identifies the data as - // serialized BlobCache contents. It must always contain 'Blb$'. - uint32_t mMagicNumber; - - // mBlobCacheVersion is the serialization format version. - uint32_t mBlobCacheVersion; - - // mDeviceVersion is the device-specific version of the cache. This can - // be used to invalidate the cache. - uint32_t mDeviceVersion; - - // mNumEntries is number of cache entries following the header in the - // data. - size_t mNumEntries; - - // mBuildId is the build id of the device when the cache was created. - // When an update to the build happens (via an OTA or other update) this - // is used to invalidate the cache. - int mBuildIdLength; - char mBuildId[]; - }; - - // An EntryHeader is the header for a serialized cache entry. No need to - // make this portable, so we simply write the struct out. Each EntryHeader - // is followed imediately by the key data and then the value data. - // - // The beginning of each serialized EntryHeader is 4-byte aligned, so the - // number of bytes that a serialized cache entry will occupy is: - // - // ((sizeof(EntryHeader) + keySize + valueSize) + 3) & ~3 - // - struct EntryHeader { - // mKeySize is the size of the entry key in bytes. - size_t mKeySize; - - // mValueSize is the size of the entry value in bytes. - size_t mValueSize; - - // mData contains both the key and value data for the cache entry. The - // key comes first followed immediately by the value. - uint8_t mData[]; - }; - - // mMaxKeySize is the maximum key size that will be cached. Calls to - // BlobCache::set with a keySize parameter larger than mMaxKeySize will - // simply not add the key/value pair to the cache. - const size_t mMaxKeySize; - - // mMaxValueSize is the maximum value size that will be cached. Calls to - // BlobCache::set with a valueSize parameter larger than mMaxValueSize will - // simply not add the key/value pair to the cache. - const size_t mMaxValueSize; - - // mMaxTotalSize is the maximum size that all cache entries can occupy. This - // includes space for both keys and values. When a call to BlobCache::set - // would otherwise cause this limit to be exceeded, either the key/value - // pair passed to BlobCache::set will not be cached or other cache entries - // will be evicted from the cache to make room for the new entry. - const size_t mMaxTotalSize; - - // mTotalSize is the total combined size of all keys and values currently in - // the cache. - size_t mTotalSize; - - // mRandState is the pseudo-random number generator state. It is passed to - // nrand48 to generate random numbers when needed. - unsigned short mRandState[3]; - - // mCacheEntries stores all the cache entries that are resident in memory. - // Cache entries are added to it by the 'set' method. - SortedVector mCacheEntries; -}; - -} - -#endif // ANDROID_BLOB_CACHE_H diff --git a/third_party/android_system_core/include/utils/ByteOrder.h b/third_party/android_system_core/include/utils/ByteOrder.h deleted file mode 100644 index baa3a83dd..000000000 --- a/third_party/android_system_core/include/utils/ByteOrder.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -// - -#ifndef _LIBS_UTILS_BYTE_ORDER_H -#define _LIBS_UTILS_BYTE_ORDER_H - -#include -#include -#ifdef HAVE_WINSOCK -#include -#else -#include -#endif - -/* - * These macros are like the hton/ntoh byte swapping macros, - * except they allow you to swap to and from the "device" byte - * order. The device byte order is the endianness of the target - * device -- for the ARM CPUs we use today, this is little endian. - * - * Note that the byte swapping functions have not been optimized - * much; performance is currently not an issue for them since the - * intent is to allow us to avoid byte swapping on the device. - */ - -static inline uint32_t android_swap_long(uint32_t v) -{ - return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); -} - -static inline uint16_t android_swap_short(uint16_t v) -{ - return (v<<8) | (v>>8); -} - -#define DEVICE_BYTE_ORDER LITTLE_ENDIAN - -#if BYTE_ORDER == DEVICE_BYTE_ORDER - -#define dtohl(x) (x) -#define dtohs(x) (x) -#define htodl(x) (x) -#define htods(x) (x) - -#else - -#define dtohl(x) (android_swap_long(x)) -#define dtohs(x) (android_swap_short(x)) -#define htodl(x) (android_swap_long(x)) -#define htods(x) (android_swap_short(x)) - -#endif - -#if BYTE_ORDER == LITTLE_ENDIAN -#define fromlel(x) (x) -#define fromles(x) (x) -#define tolel(x) (x) -#define toles(x) (x) -#else -#define fromlel(x) (android_swap_long(x)) -#define fromles(x) (android_swap_short(x)) -#define tolel(x) (android_swap_long(x)) -#define toles(x) (android_swap_short(x)) -#endif - -#endif // _LIBS_UTILS_BYTE_ORDER_H diff --git a/third_party/android_system_core/include/utils/CallStack.h b/third_party/android_system_core/include/utils/CallStack.h deleted file mode 100644 index 27e89f462..000000000 --- a/third_party/android_system_core/include/utils/CallStack.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef ANDROID_CALLSTACK_H -#define ANDROID_CALLSTACK_H - -#include -#include -#include -#include - -#include -#include - -namespace android { - -class Printer; - -// Collect/print the call stack (function, file, line) traces for a single thread. -class CallStack { -public: - // Create an empty call stack. No-op. - CallStack(); - // Create a callstack with the current thread's stack trace. - // Immediately dump it to logcat using the given logtag. - CallStack(const char* logtag, int32_t ignoreDepth=1); - ~CallStack(); - - // Reset the stack frames (same as creating an empty call stack). - void clear() { mFrameLines.clear(); } - - // Immediately collect the stack traces for the specified thread. - // The default is to dump the stack of the current call. - void update(int32_t ignoreDepth=1, pid_t tid=BACKTRACE_CURRENT_THREAD); - - // Dump a stack trace to the log using the supplied logtag. - void log(const char* logtag, - android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0) const; - - // Dump a stack trace to the specified file descriptor. - void dump(int fd, int indent = 0, const char* prefix = 0) const; - - // Return a string (possibly very long) containing the complete stack trace. - String8 toString(const char* prefix = 0) const; - - // Dump a serialized representation of the stack trace to the specified printer. - void print(Printer& printer) const; - - // Get the count of stack frames that are in this call stack. - size_t size() const { return mFrameLines.size(); } - -private: - Vector mFrameLines; -}; - -}; // namespace android - -#endif // ANDROID_CALLSTACK_H diff --git a/third_party/android_system_core/include/utils/Compat.h b/third_party/android_system_core/include/utils/Compat.h deleted file mode 100644 index 7d9631027..000000000 --- a/third_party/android_system_core/include/utils/Compat.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef __LIB_UTILS_COMPAT_H -#define __LIB_UTILS_COMPAT_H - -#include - -#if defined(__APPLE__) - -/* Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */ - -typedef off_t off64_t; - -static inline off64_t lseek64(int fd, off64_t offset, int whence) { - return lseek(fd, offset, whence); -} - -static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { - return pread(fd, buf, nbytes, offset); -} - -#endif /* __APPLE__ */ - -#if defined(_WIN32) -#define O_CLOEXEC O_NOINHERIT -#define O_NOFOLLOW 0 -#define DEFFILEMODE 0666 -#endif /* _WIN32 */ - -#if defined(_WIN32) -#define ZD "%ld" -#define ZD_TYPE long -#else -#define ZD "%zd" -#define ZD_TYPE ssize_t -#endif - -/* - * Needed for cases where something should be constexpr if possible, but not - * being constexpr is fine if in pre-C++11 code (such as a const static float - * member variable). - */ -#if __cplusplus >= 201103L -#define CONSTEXPR constexpr -#else -#define CONSTEXPR -#endif - -/* - * TEMP_FAILURE_RETRY is defined by some, but not all, versions of - * . (Alas, it is not as standard as we'd hoped!) So, if it's - * not already defined, then define it here. - */ -#ifndef TEMP_FAILURE_RETRY -/* Used to retry syscalls that can return EINTR. */ -#define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; }) -#endif - -#endif /* __LIB_UTILS_COMPAT_H */ diff --git a/third_party/android_system_core/include/utils/Condition.h b/third_party/android_system_core/include/utils/Condition.h deleted file mode 100644 index 5a7251982..000000000 --- a/third_party/android_system_core/include/utils/Condition.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_UTILS_CONDITION_H -#define _LIBS_UTILS_CONDITION_H - -#include -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -/* - * Condition variable class. The implementation is system-dependent. - * - * Condition variables are paired up with mutexes. Lock the mutex, - * call wait(), then either re-wait() if things aren't quite what you want, - * or unlock the mutex and continue. All threads calling wait() must - * use the same mutex for a given Condition. - */ -class Condition { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - enum WakeUpType { - WAKE_UP_ONE = 0, - WAKE_UP_ALL = 1 - }; - - Condition(); - Condition(int type); - ~Condition(); - // Wait on the condition variable. Lock the mutex before calling. - status_t wait(Mutex& mutex); - // same with relative timeout - status_t waitRelative(Mutex& mutex, nsecs_t reltime); - // Signal the condition variable, allowing exactly one thread to continue. - void signal(); - // Signal the condition variable, allowing one or all threads to continue. - void signal(WakeUpType type) { - if (type == WAKE_UP_ONE) { - signal(); - } else { - broadcast(); - } - } - // Signal the condition variable, allowing all threads to continue. - void broadcast(); - -private: -#if !defined(_WIN32) - pthread_cond_t mCond; -#else - void* mState; -#endif -}; - -// --------------------------------------------------------------------------- - -#if !defined(_WIN32) - -inline Condition::Condition() { - pthread_cond_init(&mCond, NULL); -} -inline Condition::Condition(int type) { - if (type == SHARED) { - pthread_condattr_t attr; - pthread_condattr_init(&attr); - pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_cond_init(&mCond, &attr); - pthread_condattr_destroy(&attr); - } else { - pthread_cond_init(&mCond, NULL); - } -} -inline Condition::~Condition() { - pthread_cond_destroy(&mCond); -} -inline status_t Condition::wait(Mutex& mutex) { - return -pthread_cond_wait(&mCond, &mutex.mMutex); -} -inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) { -#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE) - struct timespec ts; - ts.tv_sec = reltime/1000000000; - ts.tv_nsec = reltime%1000000000; - return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts); -#else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE - struct timespec ts; -#if defined(__linux__) - clock_gettime(CLOCK_REALTIME, &ts); -#else // __APPLE__ - // we don't support the clocks here. - struct timeval t; - gettimeofday(&t, NULL); - ts.tv_sec = t.tv_sec; - ts.tv_nsec= t.tv_usec*1000; -#endif - ts.tv_sec += reltime/1000000000; - ts.tv_nsec+= reltime%1000000000; - if (ts.tv_nsec >= 1000000000) { - ts.tv_nsec -= 1000000000; - ts.tv_sec += 1; - } - return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts); -#endif // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE -} -inline void Condition::signal() { - /* - * POSIX says pthread_cond_signal wakes up "one or more" waiting threads. - * However bionic follows the glibc guarantee which wakes up "exactly one" - * waiting thread. - * - * man 3 pthread_cond_signal - * pthread_cond_signal restarts one of the threads that are waiting on - * the condition variable cond. If no threads are waiting on cond, - * nothing happens. If several threads are waiting on cond, exactly one - * is restarted, but it is not specified which. - */ - pthread_cond_signal(&mCond); -} -inline void Condition::broadcast() { - pthread_cond_broadcast(&mCond); -} - -#endif // !defined(_WIN32) - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_CONDITON_H diff --git a/third_party/android_system_core/include/utils/Debug.h b/third_party/android_system_core/include/utils/Debug.h deleted file mode 100644 index 08893bdaa..000000000 --- a/third_party/android_system_core/include/utils/Debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_UTILS_DEBUG_H -#define ANDROID_UTILS_DEBUG_H - -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -template struct CompileTimeAssert; -template<> struct CompileTimeAssert {}; -#define COMPILE_TIME_ASSERT(_exp) \ - template class CompileTimeAssert< (_exp) >; -#endif -#define COMPILE_TIME_ASSERT_FUNCTION_SCOPE(_exp) \ - CompileTimeAssert<( _exp )>(); - -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -template struct CompileTimeIfElse; -template -struct CompileTimeIfElse { typedef LHS TYPE; }; -template -struct CompileTimeIfElse { typedef RHS TYPE; }; -#endif - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_UTILS_DEBUG_H diff --git a/third_party/android_system_core/include/utils/Endian.h b/third_party/android_system_core/include/utils/Endian.h deleted file mode 100644 index 591cae0d3..000000000 --- a/third_party/android_system_core/include/utils/Endian.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Android endian-ness defines. -// -#ifndef _LIBS_UTILS_ENDIAN_H -#define _LIBS_UTILS_ENDIAN_H - -#if defined(__APPLE__) || defined(_WIN32) - -#define __BIG_ENDIAN 0x1000 -#define __LITTLE_ENDIAN 0x0001 -#define __BYTE_ORDER __LITTLE_ENDIAN - -#else - -#include - -#endif - -#endif /*_LIBS_UTILS_ENDIAN_H*/ diff --git a/third_party/android_system_core/include/utils/Errors.h b/third_party/android_system_core/include/utils/Errors.h deleted file mode 100644 index 46173db4a..000000000 --- a/third_party/android_system_core/include/utils/Errors.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef ANDROID_ERRORS_H -#define ANDROID_ERRORS_H - -#include -#include - -namespace android { - -// use this type to return error codes -#ifdef HAVE_MS_C_RUNTIME -typedef int status_t; -#else -typedef int32_t status_t; -#endif - -/* the MS C runtime lacks a few error codes */ - -/* - * Error codes. - * All error codes are negative values. - */ - -// Win32 #defines NO_ERROR as well. It has the same value, so there's no -// real conflict, though it's a bit awkward. -#ifdef _WIN32 -# undef NO_ERROR -#endif - -enum { - OK = 0, // Everything's swell. - NO_ERROR = 0, // No errors. - - UNKNOWN_ERROR = (-2147483647-1), // INT32_MIN value - - NO_MEMORY = -ENOMEM, - INVALID_OPERATION = -ENOSYS, - BAD_VALUE = -EINVAL, - BAD_TYPE = (UNKNOWN_ERROR + 1), - NAME_NOT_FOUND = -ENOENT, - PERMISSION_DENIED = -EPERM, - NO_INIT = -ENODEV, - ALREADY_EXISTS = -EEXIST, - DEAD_OBJECT = -EPIPE, - FAILED_TRANSACTION = (UNKNOWN_ERROR + 2), - JPARKS_BROKE_IT = -EPIPE, -#if !defined(HAVE_MS_C_RUNTIME) - BAD_INDEX = -EOVERFLOW, - NOT_ENOUGH_DATA = -ENODATA, - WOULD_BLOCK = -EWOULDBLOCK, - TIMED_OUT = -ETIMEDOUT, - UNKNOWN_TRANSACTION = -EBADMSG, -#else - BAD_INDEX = -E2BIG, - NOT_ENOUGH_DATA = (UNKNOWN_ERROR + 3), - WOULD_BLOCK = (UNKNOWN_ERROR + 4), - TIMED_OUT = (UNKNOWN_ERROR + 5), - UNKNOWN_TRANSACTION = (UNKNOWN_ERROR + 6), -#endif - FDS_NOT_ALLOWED = (UNKNOWN_ERROR + 7), -}; - -// Restore define; enumeration is in "android" namespace, so the value defined -// there won't work for Win32 code in a different namespace. -#ifdef _WIN32 -# define NO_ERROR 0L -#endif - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_ERRORS_H diff --git a/third_party/android_system_core/include/utils/FileMap.h b/third_party/android_system_core/include/utils/FileMap.h deleted file mode 100644 index f70fc927e..000000000 --- a/third_party/android_system_core/include/utils/FileMap.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2006 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. - */ - -// -// Encapsulate a shared file mapping. -// -#ifndef __LIBS_FILE_MAP_H -#define __LIBS_FILE_MAP_H - -#include - -#include - -#if defined(__MINGW32__) -// Ensure that we always pull in winsock2.h before windows.h -#ifdef HAVE_WINSOCK -#include -#endif -#include -#endif - -namespace android { - -/* - * This represents a memory-mapped file. It might be the entire file or - * only part of it. This requires a little bookkeeping because the mapping - * needs to be aligned on page boundaries, and in some cases we'd like to - * have multiple references to the mapped area without creating additional - * maps. - * - * This always uses MAP_SHARED. - * - * TODO: we should be able to create a new FileMap that is a subset of - * an existing FileMap and shares the underlying mapped pages. Requires - * completing the refcounting stuff and possibly introducing the notion - * of a FileMap hierarchy. - */ -class FileMap { -public: - FileMap(void); - - /* - * Create a new mapping on an open file. - * - * Closing the file descriptor does not unmap the pages, so we don't - * claim ownership of the fd. - * - * Returns "false" on failure. - */ - bool create(const char* origFileName, int fd, - off64_t offset, size_t length, bool readOnly); - - ~FileMap(void); - - /* - * Return the name of the file this map came from, if known. - */ - const char* getFileName(void) const { return mFileName; } - - /* - * Get a pointer to the piece of the file we requested. - */ - void* getDataPtr(void) const { return mDataPtr; } - - /* - * Get the length we requested. - */ - size_t getDataLength(void) const { return mDataLength; } - - /* - * Get the data offset used to create this map. - */ - off64_t getDataOffset(void) const { return mDataOffset; } - - /* - * This maps directly to madvise() values, but allows us to avoid - * including everywhere. - */ - enum MapAdvice { - NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED - }; - - /* - * Apply an madvise() call to the entire file. - * - * Returns 0 on success, -1 on failure. - */ - int advise(MapAdvice advice); - -protected: - -private: - // these are not implemented - FileMap(const FileMap& src); - const FileMap& operator=(const FileMap& src); - - char* mFileName; // original file name, if known - void* mBasePtr; // base of mmap area; page aligned - size_t mBaseLength; // length, measured from "mBasePtr" - off64_t mDataOffset; // offset used when map was created - void* mDataPtr; // start of requested data, offset from base - size_t mDataLength; // length, measured from "mDataPtr" -#if defined(__MINGW32__) - HANDLE mFileHandle; // Win32 file handle - HANDLE mFileMapping; // Win32 file mapping handle -#endif - - static long mPageSize; -}; - -}; // namespace android - -#endif // __LIBS_FILE_MAP_H diff --git a/third_party/android_system_core/include/utils/Flattenable.h b/third_party/android_system_core/include/utils/Flattenable.h deleted file mode 100644 index 882a8b249..000000000 --- a/third_party/android_system_core/include/utils/Flattenable.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef ANDROID_UTILS_FLATTENABLE_H -#define ANDROID_UTILS_FLATTENABLE_H - - -#include -#include -#include -#include - -namespace android { - - -class FlattenableUtils { -public: - template - static size_t align(size_t size) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); - return (size + (N-1)) & ~(N-1); - } - - template - static size_t align(void const*& buffer) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); - intptr_t b = intptr_t(buffer); - buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); - return size_t(intptr_t(buffer) - b); - } - - template - static size_t align(void*& buffer) { - return align( const_cast(buffer) ); - } - - static void advance(void*& buffer, size_t& size, size_t offset) { - buffer = reinterpret_cast( intptr_t(buffer) + offset ); - size -= offset; - } - - static void advance(void const*& buffer, size_t& size, size_t offset) { - buffer = reinterpret_cast( intptr_t(buffer) + offset ); - size -= offset; - } - - // write a POD structure - template - static void write(void*& buffer, size_t& size, const T& value) { - *static_cast(buffer) = value; - advance(buffer, size, sizeof(T)); - } - - // read a POD structure - template - static void read(void const*& buffer, size_t& size, T& value) { - value = *static_cast(buffer); - advance(buffer, size, sizeof(T)); - } -}; - - -/* - * The Flattenable protocol allows an object to serialize itself out - * to a byte-buffer and an array of file descriptors. - * Flattenable objects must implement this protocol. - */ - -template -class Flattenable { -public: - // size in bytes of the flattened object - inline size_t getFlattenedSize() const; - - // number of file descriptors to flatten - inline size_t getFdCount() const; - - // flattens the object into buffer. - // size should be at least of getFlattenedSize() - // file descriptors are written in the fds[] array but ownership is - // not transfered (ie: they must be dupped by the caller of - // flatten() if needed). - inline status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; - - // unflattens the object from buffer. - // size should be equal to the value of getFlattenedSize() when the - // object was flattened. - // unflattened file descriptors are found in the fds[] array and - // don't need to be dupped(). ie: the caller of unflatten doesn't - // keep ownership. If a fd is not retained by unflatten() it must be - // explicitly closed. - inline status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); -}; - -template -inline size_t Flattenable::getFlattenedSize() const { - return static_cast(this)->T::getFlattenedSize(); -} -template -inline size_t Flattenable::getFdCount() const { - return static_cast(this)->T::getFdCount(); -} -template -inline status_t Flattenable::flatten( - void*& buffer, size_t& size, int*& fds, size_t& count) const { - return static_cast(this)->T::flatten(buffer, size, fds, count); -} -template -inline status_t Flattenable::unflatten( - void const*& buffer, size_t& size, int const*& fds, size_t& count) { - return static_cast(this)->T::unflatten(buffer, size, fds, count); -} - -/* - * LightFlattenable is a protocol allowing object to serialize themselves out - * to a byte-buffer. Because it doesn't handle file-descriptors, - * LightFlattenable is usually more size efficient than Flattenable. - * LightFlattenable objects must implement this protocol. - */ -template -class LightFlattenable { -public: - // returns whether this object always flatten into the same size. - // for efficiency, this should always be inline. - inline bool isFixedSize() const; - - // returns size in bytes of the flattened object. must be a constant. - inline size_t getFlattenedSize() const; - - // flattens the object into buffer. - inline status_t flatten(void* buffer, size_t size) const; - - // unflattens the object from buffer of given size. - inline status_t unflatten(void const* buffer, size_t size); -}; - -template -inline bool LightFlattenable::isFixedSize() const { - return static_cast(this)->T::isFixedSize(); -} -template -inline size_t LightFlattenable::getFlattenedSize() const { - return static_cast(this)->T::getFlattenedSize(); -} -template -inline status_t LightFlattenable::flatten(void* buffer, size_t size) const { - return static_cast(this)->T::flatten(buffer, size); -} -template -inline status_t LightFlattenable::unflatten(void const* buffer, size_t size) { - return static_cast(this)->T::unflatten(buffer, size); -} - -/* - * LightFlattenablePod is an implementation of the LightFlattenable protocol - * for POD (plain-old-data) objects. - * Simply derive from LightFlattenablePod to make Foo flattenable; no - * need to implement any methods; obviously Foo must be a POD structure. - */ -template -class LightFlattenablePod : public LightFlattenable { -public: - inline bool isFixedSize() const { - return true; - } - - inline size_t getFlattenedSize() const { - return sizeof(T); - } - inline status_t flatten(void* buffer, size_t size) const { - if (size < sizeof(T)) return NO_MEMORY; - *reinterpret_cast(buffer) = *static_cast(this); - return NO_ERROR; - } - inline status_t unflatten(void const* buffer, size_t) { - *static_cast(this) = *reinterpret_cast(buffer); - return NO_ERROR; - } -}; - - -}; // namespace android - - -#endif /* ANDROID_UTILS_FLATTENABLE_H */ diff --git a/third_party/android_system_core/include/utils/Functor.h b/third_party/android_system_core/include/utils/Functor.h deleted file mode 100644 index 09ea614b6..000000000 --- a/third_party/android_system_core/include/utils/Functor.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef ANDROID_FUNCTOR_H -#define ANDROID_FUNCTOR_H - -#include - -namespace android { - -class Functor { -public: - Functor() {} - virtual ~Functor() {} - virtual status_t operator ()(int /*what*/, void* /*data*/) { return NO_ERROR; } -}; - -}; // namespace android - -#endif // ANDROID_FUNCTOR_H diff --git a/third_party/android_system_core/include/utils/JenkinsHash.h b/third_party/android_system_core/include/utils/JenkinsHash.h deleted file mode 100644 index 7da5dbd6a..000000000 --- a/third_party/android_system_core/include/utils/JenkinsHash.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -/* Implementation of Jenkins one-at-a-time hash function. These choices are - * optimized for code size and portability, rather than raw speed. But speed - * should still be quite good. - **/ - -#ifndef ANDROID_JENKINS_HASH_H -#define ANDROID_JENKINS_HASH_H - -#include - -namespace android { - -/* The Jenkins hash of a sequence of 32 bit words A, B, C is: - * Whiten(Mix(Mix(Mix(0, A), B), C)) */ - -inline uint32_t JenkinsHashMix(uint32_t hash, uint32_t data) { - hash += data; - hash += (hash << 10); - hash ^= (hash >> 6); - return hash; -} - -hash_t JenkinsHashWhiten(uint32_t hash); - -/* Helpful utility functions for hashing data in 32 bit chunks */ -uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size); - -uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size); - -} - -#endif // ANDROID_JENKINS_HASH_H diff --git a/third_party/android_system_core/include/utils/KeyedVector.h b/third_party/android_system_core/include/utils/KeyedVector.h deleted file mode 100644 index c4faae0b7..000000000 --- a/third_party/android_system_core/include/utils/KeyedVector.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_KEYED_VECTOR_H -#define ANDROID_KEYED_VECTOR_H - -#include -#include -#include - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class KeyedVector -{ -public: - typedef KEY key_type; - typedef VALUE value_type; - - inline KeyedVector(); - - /* - * empty the vector - */ - - inline void clear() { mVector.clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return mVector.size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return mVector.isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return mVector.capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return mVector.setCapacity(size); } - - // returns true if the arguments is known to be identical to this vector - inline bool isIdenticalTo(const KeyedVector& rhs) const; - - /*! - * accessors - */ - const VALUE& valueFor(const KEY& key) const; - const VALUE& valueAt(size_t index) const; - const KEY& keyAt(size_t index) const; - ssize_t indexOfKey(const KEY& key) const; - const VALUE& operator[] (size_t index) const; - - /*! - * modifying the array - */ - - VALUE& editValueFor(const KEY& key); - VALUE& editValueAt(size_t index); - - /*! - * add/insert/replace items - */ - - ssize_t add(const KEY& key, const VALUE& item); - ssize_t replaceValueFor(const KEY& key, const VALUE& item); - ssize_t replaceValueAt(size_t index, const VALUE& item); - - /*! - * remove items - */ - - ssize_t removeItem(const KEY& key); - ssize_t removeItemsAt(size_t index, size_t count = 1); - -private: - SortedVector< key_value_pair_t > mVector; -}; - -// KeyedVector can be trivially moved using memcpy() because its -// underlying SortedVector can be trivially moved. -template struct trait_trivial_move > { - enum { value = trait_trivial_move > >::value }; -}; - - -// --------------------------------------------------------------------------- - -/** - * Variation of KeyedVector that holds a default value to return when - * valueFor() is called with a key that doesn't exist. - */ -template -class DefaultKeyedVector : public KeyedVector -{ -public: - inline DefaultKeyedVector(const VALUE& defValue = VALUE()); - const VALUE& valueFor(const KEY& key) const; - -private: - VALUE mDefault; -}; - -// --------------------------------------------------------------------------- - -template inline -KeyedVector::KeyedVector() -{ -} - -template inline -bool KeyedVector::isIdenticalTo(const KeyedVector& rhs) const { - return mVector.array() == rhs.mVector.array(); -} - -template inline -ssize_t KeyedVector::indexOfKey(const KEY& key) const { - return mVector.indexOf( key_value_pair_t(key) ); -} - -template inline -const VALUE& KeyedVector::valueFor(const KEY& key) const { - ssize_t i = this->indexOfKey(key); - LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); - return mVector.itemAt(i).value; -} - -template inline -const VALUE& KeyedVector::valueAt(size_t index) const { - return mVector.itemAt(index).value; -} - -template inline -const VALUE& KeyedVector::operator[] (size_t index) const { - return valueAt(index); -} - -template inline -const KEY& KeyedVector::keyAt(size_t index) const { - return mVector.itemAt(index).key; -} - -template inline -VALUE& KeyedVector::editValueFor(const KEY& key) { - ssize_t i = this->indexOfKey(key); - LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); - return mVector.editItemAt(i).value; -} - -template inline -VALUE& KeyedVector::editValueAt(size_t index) { - return mVector.editItemAt(index).value; -} - -template inline -ssize_t KeyedVector::add(const KEY& key, const VALUE& value) { - return mVector.add( key_value_pair_t(key, value) ); -} - -template inline -ssize_t KeyedVector::replaceValueFor(const KEY& key, const VALUE& value) { - key_value_pair_t pair(key, value); - mVector.remove(pair); - return mVector.add(pair); -} - -template inline -ssize_t KeyedVector::replaceValueAt(size_t index, const VALUE& item) { - if (index inline -ssize_t KeyedVector::removeItem(const KEY& key) { - return mVector.remove(key_value_pair_t(key)); -} - -template inline -ssize_t KeyedVector::removeItemsAt(size_t index, size_t count) { - return mVector.removeItemsAt(index, count); -} - -// --------------------------------------------------------------------------- - -template inline -DefaultKeyedVector::DefaultKeyedVector(const VALUE& defValue) - : mDefault(defValue) -{ -} - -template inline -const VALUE& DefaultKeyedVector::valueFor(const KEY& key) const { - ssize_t i = this->indexOfKey(key); - return i >= 0 ? KeyedVector::valueAt(i) : mDefault; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_KEYED_VECTOR_H diff --git a/third_party/android_system_core/include/utils/LinearTransform.h b/third_party/android_system_core/include/utils/LinearTransform.h deleted file mode 100644 index 04cb355c7..000000000 --- a/third_party/android_system_core/include/utils/LinearTransform.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ - -#ifndef _LIBS_UTILS_LINEAR_TRANSFORM_H -#define _LIBS_UTILS_LINEAR_TRANSFORM_H - -#include - -namespace android { - -// LinearTransform defines a structure which hold the definition of a -// transformation from single dimensional coordinate system A into coordinate -// system B (and back again). Values in A and in B are 64 bit, the linear -// scale factor is expressed as a rational number using two 32 bit values. -// -// Specifically, let -// f(a) = b -// F(b) = f^-1(b) = a -// then -// -// f(a) = (((a - a_zero) * a_to_b_numer) / a_to_b_denom) + b_zero; -// -// and -// -// F(b) = (((b - b_zero) * a_to_b_denom) / a_to_b_numer) + a_zero; -// -struct LinearTransform { - int64_t a_zero; - int64_t b_zero; - int32_t a_to_b_numer; - uint32_t a_to_b_denom; - - // Transform from A->B - // Returns true on success, or false in the case of a singularity or an - // overflow. - bool doForwardTransform(int64_t a_in, int64_t* b_out) const; - - // Transform from B->A - // Returns true on success, or false in the case of a singularity or an - // overflow. - bool doReverseTransform(int64_t b_in, int64_t* a_out) const; - - // Helpers which will reduce the fraction N/D using Euclid's method. - template static void reduce(T* N, T* D); - static void reduce(int32_t* N, uint32_t* D); -}; - - -} - -#endif // _LIBS_UTILS_LINEAR_TRANSFORM_H diff --git a/third_party/android_system_core/include/utils/List.h b/third_party/android_system_core/include/utils/List.h deleted file mode 100644 index 403cd7f1e..000000000 --- a/third_party/android_system_core/include/utils/List.h +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Templated list class. Normally we'd use STL, but we don't have that. -// This class mimics STL's interfaces. -// -// Objects are copied into the list with the '=' operator or with copy- -// construction, so if the compiler's auto-generated versions won't work for -// you, define your own. -// -// The only class you want to use from here is "List". -// -#ifndef _LIBS_UTILS_LIST_H -#define _LIBS_UTILS_LIST_H - -#include -#include - -namespace android { - -/* - * Doubly-linked list. Instantiate with "List myList". - * - * Objects added to the list are copied using the assignment operator, - * so this must be defined. - */ -template -class List -{ -protected: - /* - * One element in the list. - */ - class _Node { - public: - explicit _Node(const T& val) : mVal(val) {} - ~_Node() {} - inline T& getRef() { return mVal; } - inline const T& getRef() const { return mVal; } - inline _Node* getPrev() const { return mpPrev; } - inline _Node* getNext() const { return mpNext; } - inline void setVal(const T& val) { mVal = val; } - inline void setPrev(_Node* ptr) { mpPrev = ptr; } - inline void setNext(_Node* ptr) { mpNext = ptr; } - private: - friend class List; - friend class _ListIterator; - T mVal; - _Node* mpPrev; - _Node* mpNext; - }; - - /* - * Iterator for walking through the list. - */ - - template - struct CONST_ITERATOR { - typedef _Node const * NodePtr; - typedef const TYPE Type; - }; - - template - struct NON_CONST_ITERATOR { - typedef _Node* NodePtr; - typedef TYPE Type; - }; - - template< - typename U, - template class Constness - > - class _ListIterator { - typedef _ListIterator _Iter; - typedef typename Constness::NodePtr _NodePtr; - typedef typename Constness::Type _Type; - - explicit _ListIterator(_NodePtr ptr) : mpNode(ptr) {} - - public: - _ListIterator() {} - _ListIterator(const _Iter& rhs) : mpNode(rhs.mpNode) {} - ~_ListIterator() {} - - // this will handle conversions from iterator to const_iterator - // (and also all convertible iterators) - // Here, in this implementation, the iterators can be converted - // if the nodes can be converted - template explicit - _ListIterator(const V& rhs) : mpNode(rhs.mpNode) {} - - - /* - * Dereference operator. Used to get at the juicy insides. - */ - _Type& operator*() const { return mpNode->getRef(); } - _Type* operator->() const { return &(mpNode->getRef()); } - - /* - * Iterator comparison. - */ - inline bool operator==(const _Iter& right) const { - return mpNode == right.mpNode; } - - inline bool operator!=(const _Iter& right) const { - return mpNode != right.mpNode; } - - /* - * handle comparisons between iterator and const_iterator - */ - template - inline bool operator==(const OTHER& right) const { - return mpNode == right.mpNode; } - - template - inline bool operator!=(const OTHER& right) const { - return mpNode != right.mpNode; } - - /* - * Incr/decr, used to move through the list. - */ - inline _Iter& operator++() { // pre-increment - mpNode = mpNode->getNext(); - return *this; - } - const _Iter operator++(int) { // post-increment - _Iter tmp(*this); - mpNode = mpNode->getNext(); - return tmp; - } - inline _Iter& operator--() { // pre-increment - mpNode = mpNode->getPrev(); - return *this; - } - const _Iter operator--(int) { // post-increment - _Iter tmp(*this); - mpNode = mpNode->getPrev(); - return tmp; - } - - inline _NodePtr getNode() const { return mpNode; } - - _NodePtr mpNode; /* should be private, but older gcc fails */ - private: - friend class List; - }; - -public: - List() { - prep(); - } - List(const List& src) { // copy-constructor - prep(); - insert(begin(), src.begin(), src.end()); - } - virtual ~List() { - clear(); - delete[] (unsigned char*) mpMiddle; - } - - typedef _ListIterator iterator; - typedef _ListIterator const_iterator; - - List& operator=(const List& right); - - /* returns true if the list is empty */ - inline bool empty() const { return mpMiddle->getNext() == mpMiddle; } - - /* return #of elements in list */ - size_t size() const { - return size_t(distance(begin(), end())); - } - - /* - * Return the first element or one past the last element. The - * _Node* we're returning is converted to an "iterator" by a - * constructor in _ListIterator. - */ - inline iterator begin() { - return iterator(mpMiddle->getNext()); - } - inline const_iterator begin() const { - return const_iterator(const_cast<_Node const*>(mpMiddle->getNext())); - } - inline iterator end() { - return iterator(mpMiddle); - } - inline const_iterator end() const { - return const_iterator(const_cast<_Node const*>(mpMiddle)); - } - - /* add the object to the head or tail of the list */ - void push_front(const T& val) { insert(begin(), val); } - void push_back(const T& val) { insert(end(), val); } - - /* insert before the current node; returns iterator at new node */ - iterator insert(iterator posn, const T& val) - { - _Node* newNode = new _Node(val); // alloc & copy-construct - newNode->setNext(posn.getNode()); - newNode->setPrev(posn.getNode()->getPrev()); - posn.getNode()->getPrev()->setNext(newNode); - posn.getNode()->setPrev(newNode); - return iterator(newNode); - } - - /* insert a range of elements before the current node */ - void insert(iterator posn, const_iterator first, const_iterator last) { - for ( ; first != last; ++first) - insert(posn, *first); - } - - /* remove one entry; returns iterator at next node */ - iterator erase(iterator posn) { - _Node* pNext = posn.getNode()->getNext(); - _Node* pPrev = posn.getNode()->getPrev(); - pPrev->setNext(pNext); - pNext->setPrev(pPrev); - delete posn.getNode(); - return iterator(pNext); - } - - /* remove a range of elements */ - iterator erase(iterator first, iterator last) { - while (first != last) - erase(first++); // don't erase than incr later! - return iterator(last); - } - - /* remove all contents of the list */ - void clear() { - _Node* pCurrent = mpMiddle->getNext(); - _Node* pNext; - - while (pCurrent != mpMiddle) { - pNext = pCurrent->getNext(); - delete pCurrent; - pCurrent = pNext; - } - mpMiddle->setPrev(mpMiddle); - mpMiddle->setNext(mpMiddle); - } - - /* - * Measure the distance between two iterators. On exist, "first" - * will be equal to "last". The iterators must refer to the same - * list. - * - * FIXME: This is actually a generic iterator function. It should be a - * template function at the top-level with specializations for things like - * vector<>, which can just do pointer math). Here we limit it to - * _ListIterator of the same type but different constness. - */ - template< - typename U, - template class CL, - template class CR - > - ptrdiff_t distance( - _ListIterator first, _ListIterator last) const - { - ptrdiff_t count = 0; - while (first != last) { - ++first; - ++count; - } - return count; - } - -private: - /* - * I want a _Node but don't need it to hold valid data. More - * to the point, I don't want T's constructor to fire, since it - * might have side-effects or require arguments. So, we do this - * slightly uncouth storage alloc. - */ - void prep() { - mpMiddle = (_Node*) new unsigned char[sizeof(_Node)]; - mpMiddle->setPrev(mpMiddle); - mpMiddle->setNext(mpMiddle); - } - - /* - * This node plays the role of "pointer to head" and "pointer to tail". - * It sits in the middle of a circular list of nodes. The iterator - * runs around the circle until it encounters this one. - */ - _Node* mpMiddle; -}; - -/* - * Assignment operator. - * - * The simplest way to do this would be to clear out the target list and - * fill it with the source. However, we can speed things along by - * re-using existing elements. - */ -template -List& List::operator=(const List& right) -{ - if (this == &right) - return *this; // self-assignment - iterator firstDst = begin(); - iterator lastDst = end(); - const_iterator firstSrc = right.begin(); - const_iterator lastSrc = right.end(); - while (firstSrc != lastSrc && firstDst != lastDst) - *firstDst++ = *firstSrc++; - if (firstSrc == lastSrc) // ran out of elements in source? - erase(firstDst, lastDst); // yes, erase any extras - else - insert(lastDst, firstSrc, lastSrc); // copy remaining over - return *this; -} - -}; // namespace android - -#endif // _LIBS_UTILS_LIST_H diff --git a/third_party/android_system_core/include/utils/Log.h b/third_party/android_system_core/include/utils/Log.h deleted file mode 100644 index 4259c86d1..000000000 --- a/third_party/android_system_core/include/utils/Log.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// C/C++ logging functions. See the logging documentation for API details. -// -// We'd like these to be available from C code (in case we import some from -// somewhere), so this has a C interface. -// -// The output will be correct when the log file is shared between multiple -// threads and/or multiple processes so long as the operating system -// supports O_APPEND. These calls have mutex-protected data structures -// and so are NOT reentrant. Do not use LOG in a signal handler. -// -#ifndef _LIBS_UTILS_LOG_H -#define _LIBS_UTILS_LOG_H - -#include -#include - -#ifdef __cplusplus - -namespace android { - -/* - * A very simple utility that yells in the log when an operation takes too long. - */ -class LogIfSlow { -public: - LogIfSlow(const char* tag, android_LogPriority priority, - int timeoutMillis, const char* message); - ~LogIfSlow(); - -private: - const char* const mTag; - const android_LogPriority mPriority; - const int mTimeoutMillis; - const char* const mMessage; - const int64_t mStart; -}; - -/* - * Writes the specified debug log message if this block takes longer than the - * specified number of milliseconds to run. Includes the time actually taken. - * - * { - * ALOGD_IF_SLOW(50, "Excessive delay doing something."); - * doSomething(); - * } - */ -#define ALOGD_IF_SLOW(timeoutMillis, message) \ - android::LogIfSlow _logIfSlow(LOG_TAG, ANDROID_LOG_DEBUG, timeoutMillis, message); - -} // namespace android - -#endif // __cplusplus - -#endif // _LIBS_UTILS_LOG_H diff --git a/third_party/android_system_core/include/utils/Looper.h b/third_party/android_system_core/include/utils/Looper.h deleted file mode 100644 index da2d5f2b5..000000000 --- a/third_party/android_system_core/include/utils/Looper.h +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef UTILS_LOOPER_H -#define UTILS_LOOPER_H - -#include -#include -#include -#include - -#include - -namespace android { - -/* - * NOTE: Since Looper is used to implement the NDK ALooper, the Looper - * enums and the signature of Looper_callbackFunc need to align with - * that implementation. - */ - -/** - * For callback-based event loops, this is the prototype of the function - * that is called when a file descriptor event occurs. - * It is given the file descriptor it is associated with, - * a bitmask of the poll events that were triggered (typically EVENT_INPUT), - * and the data pointer that was originally supplied. - * - * Implementations should return 1 to continue receiving callbacks, or 0 - * to have this file descriptor and callback unregistered from the looper. - */ -typedef int (*Looper_callbackFunc)(int fd, int events, void* data); - -/** - * A message that can be posted to a Looper. - */ -struct Message { - Message() : what(0) { } - Message(int what) : what(what) { } - - /* The message type. (interpretation is left up to the handler) */ - int what; -}; - - -/** - * Interface for a Looper message handler. - * - * The Looper holds a strong reference to the message handler whenever it has - * a message to deliver to it. Make sure to call Looper::removeMessages - * to remove any pending messages destined for the handler so that the handler - * can be destroyed. - */ -class MessageHandler : public virtual RefBase { -protected: - virtual ~MessageHandler() { } - -public: - /** - * Handles a message. - */ - virtual void handleMessage(const Message& message) = 0; -}; - - -/** - * A simple proxy that holds a weak reference to a message handler. - */ -class WeakMessageHandler : public MessageHandler { -protected: - virtual ~WeakMessageHandler(); - -public: - WeakMessageHandler(const wp& handler); - virtual void handleMessage(const Message& message); - -private: - wp mHandler; -}; - - -/** - * A looper callback. - */ -class LooperCallback : public virtual RefBase { -protected: - virtual ~LooperCallback() { } - -public: - /** - * Handles a poll event for the given file descriptor. - * It is given the file descriptor it is associated with, - * a bitmask of the poll events that were triggered (typically EVENT_INPUT), - * and the data pointer that was originally supplied. - * - * Implementations should return 1 to continue receiving callbacks, or 0 - * to have this file descriptor and callback unregistered from the looper. - */ - virtual int handleEvent(int fd, int events, void* data) = 0; -}; - -/** - * Wraps a Looper_callbackFunc function pointer. - */ -class SimpleLooperCallback : public LooperCallback { -protected: - virtual ~SimpleLooperCallback(); - -public: - SimpleLooperCallback(Looper_callbackFunc callback); - virtual int handleEvent(int fd, int events, void* data); - -private: - Looper_callbackFunc mCallback; -}; - -/** - * A polling loop that supports monitoring file descriptor events, optionally - * using callbacks. The implementation uses epoll() internally. - * - * A looper can be associated with a thread although there is no requirement that it must be. - */ -class Looper : public RefBase { -protected: - virtual ~Looper(); - -public: - enum { - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * The poll was awoken using wake() before the timeout expired - * and no callbacks were executed and no other file descriptors were ready. - */ - POLL_WAKE = -1, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * One or more callbacks were executed. - */ - POLL_CALLBACK = -2, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * The timeout expired. - */ - POLL_TIMEOUT = -3, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * An error occurred. - */ - POLL_ERROR = -4, - }; - - /** - * Flags for file descriptor events that a looper can monitor. - * - * These flag bits can be combined to monitor multiple events at once. - */ - enum { - /** - * The file descriptor is available for read operations. - */ - EVENT_INPUT = 1 << 0, - - /** - * The file descriptor is available for write operations. - */ - EVENT_OUTPUT = 1 << 1, - - /** - * The file descriptor has encountered an error condition. - * - * The looper always sends notifications about errors; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_ERROR = 1 << 2, - - /** - * The file descriptor was hung up. - * For example, indicates that the remote end of a pipe or socket was closed. - * - * The looper always sends notifications about hangups; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_HANGUP = 1 << 3, - - /** - * The file descriptor is invalid. - * For example, the file descriptor was closed prematurely. - * - * The looper always sends notifications about invalid file descriptors; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_INVALID = 1 << 4, - }; - - enum { - /** - * Option for Looper_prepare: this looper will accept calls to - * Looper_addFd() that do not have a callback (that is provide NULL - * for the callback). In this case the caller of Looper_pollOnce() - * or Looper_pollAll() MUST check the return from these functions to - * discover when data is available on such fds and process it. - */ - PREPARE_ALLOW_NON_CALLBACKS = 1<<0 - }; - - /** - * Creates a looper. - * - * If allowNonCallbaks is true, the looper will allow file descriptors to be - * registered without associated callbacks. This assumes that the caller of - * pollOnce() is prepared to handle callback-less events itself. - */ - Looper(bool allowNonCallbacks); - - /** - * Returns whether this looper instance allows the registration of file descriptors - * using identifiers instead of callbacks. - */ - bool getAllowNonCallbacks() const; - - /** - * Waits for events to be available, with optional timeout in milliseconds. - * Invokes callbacks for all file descriptors on which an event occurred. - * - * If the timeout is zero, returns immediately without blocking. - * If the timeout is negative, waits indefinitely until an event appears. - * - * Returns POLL_WAKE if the poll was awoken using wake() before - * the timeout expired and no callbacks were invoked and no other file - * descriptors were ready. - * - * Returns POLL_CALLBACK if one or more callbacks were invoked. - * - * Returns POLL_TIMEOUT if there was no data before the given - * timeout expired. - * - * Returns POLL_ERROR if an error occurred. - * - * Returns a value >= 0 containing an identifier if its file descriptor has data - * and it has no callback function (requiring the caller here to handle it). - * In this (and only this) case outFd, outEvents and outData will contain the poll - * events and data associated with the fd, otherwise they will be set to NULL. - * - * This method does not return until it has finished invoking the appropriate callbacks - * for all file descriptors that were signalled. - */ - int pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData); - inline int pollOnce(int timeoutMillis) { - return pollOnce(timeoutMillis, NULL, NULL, NULL); - } - - /** - * Like pollOnce(), but performs all pending callbacks until all - * data has been consumed or a file descriptor is available with no callback. - * This function will never return POLL_CALLBACK. - */ - int pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData); - inline int pollAll(int timeoutMillis) { - return pollAll(timeoutMillis, NULL, NULL, NULL); - } - - /** - * Wakes the poll asynchronously. - * - * This method can be called on any thread. - * This method returns immediately. - */ - void wake(); - - /** - * Adds a new file descriptor to be polled by the looper. - * If the same file descriptor was previously added, it is replaced. - * - * "fd" is the file descriptor to be added. - * "ident" is an identifier for this event, which is returned from pollOnce(). - * The identifier must be >= 0, or POLL_CALLBACK if providing a non-NULL callback. - * "events" are the poll events to wake up on. Typically this is EVENT_INPUT. - * "callback" is the function to call when there is an event on the file descriptor. - * "data" is a private data pointer to supply to the callback. - * - * There are two main uses of this function: - * - * (1) If "callback" is non-NULL, then this function will be called when there is - * data on the file descriptor. It should execute any events it has pending, - * appropriately reading from the file descriptor. The 'ident' is ignored in this case. - * - * (2) If "callback" is NULL, the 'ident' will be returned by Looper_pollOnce - * when its file descriptor has data available, requiring the caller to take - * care of processing it. - * - * Returns 1 if the file descriptor was added, 0 if the arguments were invalid. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - * - * The callback may either be specified as a bare function pointer or as a smart - * pointer callback object. The smart pointer should be preferred because it is - * easier to avoid races when the callback is removed from a different thread. - * See removeFd() for details. - */ - int addFd(int fd, int ident, int events, Looper_callbackFunc callback, void* data); - int addFd(int fd, int ident, int events, const sp& callback, void* data); - - /** - * Removes a previously added file descriptor from the looper. - * - * When this method returns, it is safe to close the file descriptor since the looper - * will no longer have a reference to it. However, it is possible for the callback to - * already be running or for it to run one last time if the file descriptor was already - * signalled. Calling code is responsible for ensuring that this case is safely handled. - * For example, if the callback takes care of removing itself during its own execution either - * by returning 0 or by calling this method, then it can be guaranteed to not be invoked - * again at any later time unless registered anew. - * - * A simple way to avoid this problem is to use the version of addFd() that takes - * a sp instead of a bare function pointer. The LooperCallback will - * be released at the appropriate time by the Looper. - * - * Returns 1 if the file descriptor was removed, 0 if none was previously registered. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - */ - int removeFd(int fd); - - /** - * Enqueues a message to be processed by the specified handler. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessage(const sp& handler, const Message& message); - - /** - * Enqueues a message to be processed by the specified handler after all pending messages - * after the specified delay. - * - * The time delay is specified in uptime nanoseconds. - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessageDelayed(nsecs_t uptimeDelay, const sp& handler, - const Message& message); - - /** - * Enqueues a message to be processed by the specified handler after all pending messages - * at the specified time. - * - * The time is specified in uptime nanoseconds. - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessageAtTime(nsecs_t uptime, const sp& handler, - const Message& message); - - /** - * Removes all messages for the specified handler from the queue. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void removeMessages(const sp& handler); - - /** - * Removes all messages of a particular type for the specified handler from the queue. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void removeMessages(const sp& handler, int what); - - /** - * Returns whether this looper's thread is currently polling for more work to do. - * This is a good signal that the loop is still alive rather than being stuck - * handling a callback. Note that this method is intrinsically racy, since the - * state of the loop can change before you get the result back. - */ - bool isPolling() const; - - /** - * Prepares a looper associated with the calling thread, and returns it. - * If the thread already has a looper, it is returned. Otherwise, a new - * one is created, associated with the thread, and returned. - * - * The opts may be PREPARE_ALLOW_NON_CALLBACKS or 0. - */ - static sp prepare(int opts); - - /** - * Sets the given looper to be associated with the calling thread. - * If another looper is already associated with the thread, it is replaced. - * - * If "looper" is NULL, removes the currently associated looper. - */ - static void setForThread(const sp& looper); - - /** - * Returns the looper associated with the calling thread, or NULL if - * there is not one. - */ - static sp getForThread(); - -private: - struct Request { - int fd; - int ident; - int events; - int seq; - sp callback; - void* data; - - void initEventItem(struct epoll_event* eventItem) const; - }; - - struct Response { - int events; - Request request; - }; - - struct MessageEnvelope { - MessageEnvelope() : uptime(0) { } - - MessageEnvelope(nsecs_t uptime, const sp handler, - const Message& message) : uptime(uptime), handler(handler), message(message) { - } - - nsecs_t uptime; - sp handler; - Message message; - }; - - const bool mAllowNonCallbacks; // immutable - - int mWakeEventFd; // immutable - Mutex mLock; - - Vector mMessageEnvelopes; // guarded by mLock - bool mSendingMessage; // guarded by mLock - - // Whether we are currently waiting for work. Not protected by a lock, - // any use of it is racy anyway. - volatile bool mPolling; - - int mEpollFd; // guarded by mLock but only modified on the looper thread - bool mEpollRebuildRequired; // guarded by mLock - - // Locked list of file descriptor monitoring requests. - KeyedVector mRequests; // guarded by mLock - int mNextRequestSeq; - - // This state is only used privately by pollOnce and does not require a lock since - // it runs on a single thread. - Vector mResponses; - size_t mResponseIndex; - nsecs_t mNextMessageUptime; // set to LLONG_MAX when none - - int pollInner(int timeoutMillis); - int removeFd(int fd, int seq); - void awoken(); - void pushResponse(int events, const Request& request); - void rebuildEpollLocked(); - void scheduleEpollRebuildLocked(); - - static void initTLSKey(); - static void threadDestructor(void *st); - static void initEpollEvent(struct epoll_event* eventItem); -}; - -} // namespace android - -#endif // UTILS_LOOPER_H diff --git a/third_party/android_system_core/include/utils/LruCache.h b/third_party/android_system_core/include/utils/LruCache.h deleted file mode 100644 index cd9d7f94a..000000000 --- a/third_party/android_system_core/include/utils/LruCache.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_UTILS_LRU_CACHE_H -#define ANDROID_UTILS_LRU_CACHE_H - -#include -#include - -namespace android { - -/** - * GenerationCache callback used when an item is removed - */ -template -class OnEntryRemoved { -public: - virtual ~OnEntryRemoved() { }; - virtual void operator()(EntryKey& key, EntryValue& value) = 0; -}; // class OnEntryRemoved - -template -class LruCache { -public: - explicit LruCache(uint32_t maxCapacity); - - enum Capacity { - kUnlimitedCapacity, - }; - - void setOnEntryRemovedListener(OnEntryRemoved* listener); - size_t size() const; - const TValue& get(const TKey& key); - bool put(const TKey& key, const TValue& value); - bool remove(const TKey& key); - bool removeOldest(); - void clear(); - const TValue& peekOldestValue(); - - class Iterator { - public: - Iterator(const LruCache& cache): mCache(cache), mIndex(-1) { - } - - bool next() { - mIndex = mCache.mTable->next(mIndex); - return (ssize_t)mIndex != -1; - } - - size_t index() const { - return mIndex; - } - - const TValue& value() const { - return mCache.mTable->entryAt(mIndex).value; - } - - const TKey& key() const { - return mCache.mTable->entryAt(mIndex).key; - } - private: - const LruCache& mCache; - size_t mIndex; - }; - -private: - LruCache(const LruCache& that); // disallow copy constructor - - struct Entry { - TKey key; - TValue value; - Entry* parent; - Entry* child; - - Entry(TKey key_, TValue value_) : key(key_), value(value_), parent(NULL), child(NULL) { - } - const TKey& getKey() const { return key; } - }; - - void attachToCache(Entry& entry); - void detachFromCache(Entry& entry); - void rehash(size_t newCapacity); - - UniquePtr > mTable; - OnEntryRemoved* mListener; - Entry* mOldest; - Entry* mYoungest; - uint32_t mMaxCapacity; - TValue mNullValue; -}; - -// Implementation is here, because it's fully templated -template -LruCache::LruCache(uint32_t maxCapacity) - : mTable(new BasicHashtable) - , mListener(NULL) - , mOldest(NULL) - , mYoungest(NULL) - , mMaxCapacity(maxCapacity) - , mNullValue(NULL) { -}; - -template -void LruCache::setOnEntryRemovedListener(OnEntryRemoved* listener) { - mListener = listener; -} - -template -size_t LruCache::size() const { - return mTable->size(); -} - -template -const TValue& LruCache::get(const TKey& key) { - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index == -1) { - return mNullValue; - } - Entry& entry = mTable->editEntryAt(index); - detachFromCache(entry); - attachToCache(entry); - return entry.value; -} - -template -bool LruCache::put(const TKey& key, const TValue& value) { - if (mMaxCapacity != kUnlimitedCapacity && size() >= mMaxCapacity) { - removeOldest(); - } - - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index >= 0) { - return false; - } - if (!mTable->hasMoreRoom()) { - rehash(mTable->capacity() * 2); - } - - // Would it be better to initialize a blank entry and assign key, value? - Entry initEntry(key, value); - index = mTable->add(hash, initEntry); - Entry& entry = mTable->editEntryAt(index); - attachToCache(entry); - return true; -} - -template -bool LruCache::remove(const TKey& key) { - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index < 0) { - return false; - } - Entry& entry = mTable->editEntryAt(index); - if (mListener) { - (*mListener)(entry.key, entry.value); - } - detachFromCache(entry); - mTable->removeAt(index); - return true; -} - -template -bool LruCache::removeOldest() { - if (mOldest != NULL) { - return remove(mOldest->key); - // TODO: should probably abort if false - } - return false; -} - -template -const TValue& LruCache::peekOldestValue() { - if (mOldest) { - return mOldest->value; - } - return mNullValue; -} - -template -void LruCache::clear() { - if (mListener) { - for (Entry* p = mOldest; p != NULL; p = p->child) { - (*mListener)(p->key, p->value); - } - } - mYoungest = NULL; - mOldest = NULL; - mTable->clear(); -} - -template -void LruCache::attachToCache(Entry& entry) { - if (mYoungest == NULL) { - mYoungest = mOldest = &entry; - } else { - entry.parent = mYoungest; - mYoungest->child = &entry; - mYoungest = &entry; - } -} - -template -void LruCache::detachFromCache(Entry& entry) { - if (entry.parent != NULL) { - entry.parent->child = entry.child; - } else { - mOldest = entry.child; - } - if (entry.child != NULL) { - entry.child->parent = entry.parent; - } else { - mYoungest = entry.parent; - } - - entry.parent = NULL; - entry.child = NULL; -} - -template -void LruCache::rehash(size_t newCapacity) { - UniquePtr > oldTable(mTable.release()); - Entry* oldest = mOldest; - - mOldest = NULL; - mYoungest = NULL; - mTable.reset(new BasicHashtable(newCapacity)); - for (Entry* p = oldest; p != NULL; p = p->child) { - put(p->key, p->value); - } -} - -} - -#endif // ANDROID_UTILS_LRU_CACHE_H diff --git a/third_party/android_system_core/include/utils/Mutex.h b/third_party/android_system_core/include/utils/Mutex.h deleted file mode 100644 index 757519b08..000000000 --- a/third_party/android_system_core/include/utils/Mutex.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_UTILS_MUTEX_H -#define _LIBS_UTILS_MUTEX_H - -#include -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -class Condition; - -/* - * Simple mutex class. The implementation is system-dependent. - * - * The mutex must be unlocked by the thread that locked it. They are not - * recursive, i.e. the same thread can't lock it multiple times. - */ -class Mutex { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - Mutex(); - Mutex(const char* name); - Mutex(int type, const char* name = NULL); - ~Mutex(); - - // lock or unlock the mutex - status_t lock(); - void unlock(); - - // lock if possible; returns 0 on success, error otherwise - status_t tryLock(); - -#if HAVE_ANDROID_OS - // lock the mutex, but don't wait longer than timeoutMilliseconds. - // Returns 0 on success, TIMED_OUT for failure due to timeout expiration. - // - // OSX doesn't have pthread_mutex_timedlock() or equivalent. To keep - // capabilities consistent across host OSes, this method is only available - // when building Android binaries. - status_t timedLock(nsecs_t timeoutMilliseconds); -#endif - - // Manages the mutex automatically. It'll be locked when Autolock is - // constructed and released when Autolock goes out of scope. - class Autolock { - public: - inline Autolock(Mutex& mutex) : mLock(mutex) { mLock.lock(); } - inline Autolock(Mutex* mutex) : mLock(*mutex) { mLock.lock(); } - inline ~Autolock() { mLock.unlock(); } - private: - Mutex& mLock; - }; - -private: - friend class Condition; - - // A mutex cannot be copied - Mutex(const Mutex&); - Mutex& operator = (const Mutex&); - -#if !defined(_WIN32) - pthread_mutex_t mMutex; -#else - void _init(); - void* mState; -#endif -}; - -// --------------------------------------------------------------------------- - -#if !defined(_WIN32) - -inline Mutex::Mutex() { - pthread_mutex_init(&mMutex, NULL); -} -inline Mutex::Mutex(__attribute__((unused)) const char* name) { - pthread_mutex_init(&mMutex, NULL); -} -inline Mutex::Mutex(int type, __attribute__((unused)) const char* name) { - if (type == SHARED) { - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_mutex_init(&mMutex, &attr); - pthread_mutexattr_destroy(&attr); - } else { - pthread_mutex_init(&mMutex, NULL); - } -} -inline Mutex::~Mutex() { - pthread_mutex_destroy(&mMutex); -} -inline status_t Mutex::lock() { - return -pthread_mutex_lock(&mMutex); -} -inline void Mutex::unlock() { - pthread_mutex_unlock(&mMutex); -} -inline status_t Mutex::tryLock() { - return -pthread_mutex_trylock(&mMutex); -} -#if HAVE_ANDROID_OS -inline status_t Mutex::timedLock(nsecs_t timeoutNs) { - const struct timespec ts = { - /* .tv_sec = */ static_cast(timeoutNs / 1000000000), - /* .tv_nsec = */ static_cast(timeoutNs % 1000000000), - }; - return -pthread_mutex_timedlock(&mMutex, &ts); -} -#endif - -#endif // !defined(_WIN32) - -// --------------------------------------------------------------------------- - -/* - * Automatic mutex. Declare one of these at the top of a function. - * When the function returns, it will go out of scope, and release the - * mutex. - */ - -typedef Mutex::Autolock AutoMutex; - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_MUTEX_H diff --git a/third_party/android_system_core/include/utils/NativeHandle.h b/third_party/android_system_core/include/utils/NativeHandle.h deleted file mode 100644 index b82516879..000000000 --- a/third_party/android_system_core/include/utils/NativeHandle.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014 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. - */ - -#ifndef ANDROID_NATIVE_HANDLE_H -#define ANDROID_NATIVE_HANDLE_H - -#include -#include - -typedef struct native_handle native_handle_t; - -namespace android { - -class NativeHandle: public LightRefBase { -public: - // Create a refcounted wrapper around a native_handle_t, and declare - // whether the wrapper owns the handle (so that it should clean up the - // handle upon destruction) or not. - // If handle is NULL, no NativeHandle will be created. - static sp create(native_handle_t* handle, bool ownsHandle); - - const native_handle_t* handle() const { - return mHandle; - } - -private: - // for access to the destructor - friend class LightRefBase; - - NativeHandle(native_handle_t* handle, bool ownsHandle); - virtual ~NativeHandle(); - - native_handle_t* mHandle; - bool mOwnsHandle; - - // non-copyable - NativeHandle(const NativeHandle&); - NativeHandle& operator=(const NativeHandle&); -}; - -} // namespace android - -#endif // ANDROID_NATIVE_HANDLE_H diff --git a/third_party/android_system_core/include/utils/Printer.h b/third_party/android_system_core/include/utils/Printer.h deleted file mode 100644 index bb6628767..000000000 --- a/third_party/android_system_core/include/utils/Printer.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_PRINTER_H -#define ANDROID_PRINTER_H - -#include - -namespace android { - -// Interface for printing to an arbitrary data stream -class Printer { -public: - // Print a new line specified by 'string'. \n is appended automatically. - // -- Assumes that the string has no new line in it. - virtual void printLine(const char* string = "") = 0; - - // Print a new line specified by the format string. \n is appended automatically. - // -- Assumes that the resulting string has no new line in it. - virtual void printFormatLine(const char* format, ...) __attribute__((format (printf, 2, 3))); - -protected: - Printer(); - virtual ~Printer(); -}; // class Printer - -// Print to logcat -class LogPrinter : public Printer { -public: - // Create a printer using the specified logcat and log priority - // - Unless ignoreBlankLines is false, print blank lines to logcat - // (Note that the default ALOG behavior is to ignore blank lines) - LogPrinter(const char* logtag, - android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0, - bool ignoreBlankLines = false); - - // Print the specified line to logcat. No \n at the end is necessary. - virtual void printLine(const char* string); - -private: - void printRaw(const char* string); - - const char* mLogTag; - android_LogPriority mPriority; - const char* mPrefix; - bool mIgnoreBlankLines; -}; // class LogPrinter - -// Print to a file descriptor -class FdPrinter : public Printer { -public: - // Create a printer using the specified file descriptor. - // - Each line will be prefixed with 'indent' number of blank spaces. - // - In addition, each line will be prefixed with the 'prefix' string. - FdPrinter(int fd, unsigned int indent = 0, const char* prefix = 0); - - // Print the specified line to the file descriptor. \n is appended automatically. - virtual void printLine(const char* string); - -private: - enum { - MAX_FORMAT_STRING = 20, - }; - - int mFd; - unsigned int mIndent; - const char* mPrefix; - char mFormatString[MAX_FORMAT_STRING]; -}; // class FdPrinter - -class String8; - -// Print to a String8 -class String8Printer : public Printer { -public: - // Create a printer using the specified String8 as the target. - // - In addition, each line will be prefixed with the 'prefix' string. - // - target's memory lifetime must be a superset of this String8Printer. - String8Printer(String8* target, const char* prefix = 0); - - // Append the specified line to the String8. \n is appended automatically. - virtual void printLine(const char* string); - -private: - String8* mTarget; - const char* mPrefix; -}; // class String8Printer - -// Print to an existing Printer by adding a prefix to each line -class PrefixPrinter : public Printer { -public: - // Create a printer using the specified printer as the target. - PrefixPrinter(Printer& printer, const char* prefix); - - // Print the line (prefixed with prefix) using the printer. - virtual void printLine(const char* string); - -private: - Printer& mPrinter; - const char* mPrefix; -}; - -}; // namespace android - -#endif // ANDROID_PRINTER_H diff --git a/third_party/android_system_core/include/utils/ProcessCallStack.h b/third_party/android_system_core/include/utils/ProcessCallStack.h deleted file mode 100644 index 32458b8b1..000000000 --- a/third_party/android_system_core/include/utils/ProcessCallStack.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -#ifndef ANDROID_PROCESS_CALLSTACK_H -#define ANDROID_PROCESS_CALLSTACK_H - -#include -#include -#include -#include - -#include -#include - -namespace android { - -class Printer; - -// Collect/print the call stack (function, file, line) traces for all threads in a process. -class ProcessCallStack { -public: - // Create an empty call stack. No-op. - ProcessCallStack(); - // Copy the existing process callstack (no other side effects). - ProcessCallStack(const ProcessCallStack& rhs); - ~ProcessCallStack(); - - // Immediately collect the stack traces for all threads. - void update(); - - // Print all stack traces to the log using the supplied logtag. - void log(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0) const; - - // Dump all stack traces to the specified file descriptor. - void dump(int fd, int indent = 0, const char* prefix = 0) const; - - // Return a string (possibly very long) containing all the stack traces. - String8 toString(const char* prefix = 0) const; - - // Dump a serialized representation of all the stack traces to the specified printer. - void print(Printer& printer) const; - - // Get the number of threads whose stack traces were collected. - size_t size() const; - -private: - void printInternal(Printer& printer, Printer& csPrinter) const; - - // Reset the process's stack frames and metadata. - void clear(); - - struct ThreadInfo { - CallStack callStack; - String8 threadName; - }; - - // tid -> ThreadInfo - KeyedVector mThreadMap; - // Time that update() was last called - struct tm mTimeUpdated; -}; - -}; // namespace android - -#endif // ANDROID_PROCESS_CALLSTACK_H diff --git a/third_party/android_system_core/include/utils/PropertyMap.h b/third_party/android_system_core/include/utils/PropertyMap.h deleted file mode 100644 index a9e674f9a..000000000 --- a/third_party/android_system_core/include/utils/PropertyMap.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef _UTILS_PROPERTY_MAP_H -#define _UTILS_PROPERTY_MAP_H - -#include -#include -#include -#include - -namespace android { - -/* - * Provides a mechanism for passing around string-based property key / value pairs - * and loading them from property files. - * - * The property files have the following simple structure: - * - * # Comment - * key = value - * - * Keys and values are any sequence of printable ASCII characters. - * The '=' separates the key from the value. - * The key and value may not contain whitespace. - * - * The '\' character is reserved for escape sequences and is not currently supported. - * The '"" character is reserved for quoting and is not currently supported. - * Files that contain the '\' or '"' character will fail to parse. - * - * The file must not contain duplicate keys. - * - * TODO Support escape sequences and quoted values when needed. - */ -class PropertyMap { -public: - /* Creates an empty property map. */ - PropertyMap(); - ~PropertyMap(); - - /* Clears the property map. */ - void clear(); - - /* Adds a property. - * Replaces the property with the same key if it is already present. - */ - void addProperty(const String8& key, const String8& value); - - /* Returns true if the property map contains the specified key. */ - bool hasProperty(const String8& key) const; - - /* Gets the value of a property and parses it. - * Returns true and sets outValue if the key was found and its value was parsed successfully. - * Otherwise returns false and does not modify outValue. (Also logs a warning.) - */ - bool tryGetProperty(const String8& key, String8& outValue) const; - bool tryGetProperty(const String8& key, bool& outValue) const; - bool tryGetProperty(const String8& key, int32_t& outValue) const; - bool tryGetProperty(const String8& key, float& outValue) const; - - /* Adds all values from the specified property map. */ - void addAll(const PropertyMap* map); - - /* Gets the underlying property map. */ - inline const KeyedVector& getProperties() const { return mProperties; } - - /* Loads a property map from a file. */ - static status_t load(const String8& filename, PropertyMap** outMap); - -private: - class Parser { - PropertyMap* mMap; - Tokenizer* mTokenizer; - - public: - Parser(PropertyMap* map, Tokenizer* tokenizer); - ~Parser(); - status_t parse(); - - private: - status_t parseType(); - status_t parseKey(); - status_t parseKeyProperty(); - status_t parseModifier(const String8& token, int32_t* outMetaState); - status_t parseCharacterLiteral(char16_t* outCharacter); - }; - - KeyedVector mProperties; -}; - -} // namespace android - -#endif // _UTILS_PROPERTY_MAP_H diff --git a/third_party/android_system_core/include/utils/RWLock.h b/third_party/android_system_core/include/utils/RWLock.h deleted file mode 100644 index e743b1c8c..000000000 --- a/third_party/android_system_core/include/utils/RWLock.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_UTILS_RWLOCK_H -#define _LIBS_UTILS_RWLOCK_H - -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -#if !defined(_WIN32) - -/* - * Simple mutex class. The implementation is system-dependent. - * - * The mutex must be unlocked by the thread that locked it. They are not - * recursive, i.e. the same thread can't lock it multiple times. - */ -class RWLock { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - RWLock(); - RWLock(const char* name); - RWLock(int type, const char* name = NULL); - ~RWLock(); - - status_t readLock(); - status_t tryReadLock(); - status_t writeLock(); - status_t tryWriteLock(); - void unlock(); - - class AutoRLock { - public: - inline AutoRLock(RWLock& rwlock) : mLock(rwlock) { mLock.readLock(); } - inline ~AutoRLock() { mLock.unlock(); } - private: - RWLock& mLock; - }; - - class AutoWLock { - public: - inline AutoWLock(RWLock& rwlock) : mLock(rwlock) { mLock.writeLock(); } - inline ~AutoWLock() { mLock.unlock(); } - private: - RWLock& mLock; - }; - -private: - // A RWLock cannot be copied - RWLock(const RWLock&); - RWLock& operator = (const RWLock&); - - pthread_rwlock_t mRWLock; -}; - -inline RWLock::RWLock() { - pthread_rwlock_init(&mRWLock, NULL); -} -inline RWLock::RWLock(__attribute__((unused)) const char* name) { - pthread_rwlock_init(&mRWLock, NULL); -} -inline RWLock::RWLock(int type, __attribute__((unused)) const char* name) { - if (type == SHARED) { - pthread_rwlockattr_t attr; - pthread_rwlockattr_init(&attr); - pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_rwlock_init(&mRWLock, &attr); - pthread_rwlockattr_destroy(&attr); - } else { - pthread_rwlock_init(&mRWLock, NULL); - } -} -inline RWLock::~RWLock() { - pthread_rwlock_destroy(&mRWLock); -} -inline status_t RWLock::readLock() { - return -pthread_rwlock_rdlock(&mRWLock); -} -inline status_t RWLock::tryReadLock() { - return -pthread_rwlock_tryrdlock(&mRWLock); -} -inline status_t RWLock::writeLock() { - return -pthread_rwlock_wrlock(&mRWLock); -} -inline status_t RWLock::tryWriteLock() { - return -pthread_rwlock_trywrlock(&mRWLock); -} -inline void RWLock::unlock() { - pthread_rwlock_unlock(&mRWLock); -} - -#endif // !defined(_WIN32) - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_RWLOCK_H diff --git a/third_party/android_system_core/include/utils/RefBase.h b/third_party/android_system_core/include/utils/RefBase.h deleted file mode 100644 index eac6a7840..000000000 --- a/third_party/android_system_core/include/utils/RefBase.h +++ /dev/null @@ -1,555 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_REF_BASE_H -#define ANDROID_REF_BASE_H - -#include - -#include -#include -#include -#include - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -class TextOutput; -TextOutput& printWeakPointer(TextOutput& to, const void* val); - -// --------------------------------------------------------------------------- - -#define COMPARE_WEAK(_op_) \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -inline bool operator _op_ (const T* o) const { \ - return m_ptr _op_ o; \ -} \ -template \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const U* o) const { \ - return m_ptr _op_ o; \ -} - -// --------------------------------------------------------------------------- - -class ReferenceRenamer { -protected: - // destructor is purposedly not virtual so we avoid code overhead from - // subclasses; we have to make it protected to guarantee that it - // cannot be called from this base class (and to make strict compilers - // happy). - ~ReferenceRenamer() { } -public: - virtual void operator()(size_t i) const = 0; -}; - -// --------------------------------------------------------------------------- - -class RefBase -{ -public: - void incStrong(const void* id) const; - void decStrong(const void* id) const; - - void forceIncStrong(const void* id) const; - - //! DEBUGGING ONLY: Get current strong ref count. - int32_t getStrongCount() const; - - class weakref_type - { - public: - RefBase* refBase() const; - - void incWeak(const void* id); - void decWeak(const void* id); - - // acquires a strong reference if there is already one. - bool attemptIncStrong(const void* id); - - // acquires a weak reference if there is already one. - // This is not always safe. see ProcessState.cpp and BpBinder.cpp - // for proper use. - bool attemptIncWeak(const void* id); - - //! DEBUGGING ONLY: Get current weak ref count. - int32_t getWeakCount() const; - - //! DEBUGGING ONLY: Print references held on object. - void printRefs() const; - - //! DEBUGGING ONLY: Enable tracking for this object. - // enable -- enable/disable tracking - // retain -- when tracking is enable, if true, then we save a stack trace - // for each reference and dereference; when retain == false, we - // match up references and dereferences and keep only the - // outstanding ones. - - void trackMe(bool enable, bool retain); - }; - - weakref_type* createWeak(const void* id) const; - - weakref_type* getWeakRefs() const; - - //! DEBUGGING ONLY: Print references held on object. - inline void printRefs() const { getWeakRefs()->printRefs(); } - - //! DEBUGGING ONLY: Enable tracking of object. - inline void trackMe(bool enable, bool retain) - { - getWeakRefs()->trackMe(enable, retain); - } - - typedef RefBase basetype; - -protected: - RefBase(); - virtual ~RefBase(); - - //! Flags for extendObjectLifetime() - enum { - OBJECT_LIFETIME_STRONG = 0x0000, - OBJECT_LIFETIME_WEAK = 0x0001, - OBJECT_LIFETIME_MASK = 0x0001 - }; - - void extendObjectLifetime(int32_t mode); - - //! Flags for onIncStrongAttempted() - enum { - FIRST_INC_STRONG = 0x0001 - }; - - virtual void onFirstRef(); - virtual void onLastStrongRef(const void* id); - virtual bool onIncStrongAttempted(uint32_t flags, const void* id); - virtual void onLastWeakRef(const void* id); - -private: - friend class weakref_type; - class weakref_impl; - - RefBase(const RefBase& o); - RefBase& operator=(const RefBase& o); - -private: - friend class ReferenceMover; - - static void renameRefs(size_t n, const ReferenceRenamer& renamer); - - static void renameRefId(weakref_type* ref, - const void* old_id, const void* new_id); - - static void renameRefId(RefBase* ref, - const void* old_id, const void* new_id); - - weakref_impl* const mRefs; -}; - -// --------------------------------------------------------------------------- - -template -class LightRefBase -{ -public: - inline LightRefBase() : mCount(0) { } - inline void incStrong(__attribute__((unused)) const void* id) const { - android_atomic_inc(&mCount); - } - inline void decStrong(__attribute__((unused)) const void* id) const { - if (android_atomic_dec(&mCount) == 1) { - delete static_cast(this); - } - } - //! DEBUGGING ONLY: Get current strong ref count. - inline int32_t getStrongCount() const { - return mCount; - } - - typedef LightRefBase basetype; - -protected: - inline ~LightRefBase() { } - -private: - friend class ReferenceMover; - inline static void renameRefs(size_t n, const ReferenceRenamer& renamer) { } - inline static void renameRefId(T* ref, - const void* old_id, const void* new_id) { } - -private: - mutable volatile int32_t mCount; -}; - -// This is a wrapper around LightRefBase that simply enforces a virtual -// destructor to eliminate the template requirement of LightRefBase -class VirtualLightRefBase : public LightRefBase { -public: - virtual ~VirtualLightRefBase() {} -}; - -// --------------------------------------------------------------------------- - -template -class wp -{ -public: - typedef typename RefBase::weakref_type weakref_type; - - inline wp() : m_ptr(0) { } - - wp(T* other); - wp(const wp& other); - wp(const sp& other); - template wp(U* other); - template wp(const sp& other); - template wp(const wp& other); - - ~wp(); - - // Assignment - - wp& operator = (T* other); - wp& operator = (const wp& other); - wp& operator = (const sp& other); - - template wp& operator = (U* other); - template wp& operator = (const wp& other); - template wp& operator = (const sp& other); - - void set_object_and_refs(T* other, weakref_type* refs); - - // promotion to sp - - sp promote() const; - - // Reset - - void clear(); - - // Accessors - - inline weakref_type* get_refs() const { return m_refs; } - - inline T* unsafe_get() const { return m_ptr; } - - // Operators - - COMPARE_WEAK(==) - COMPARE_WEAK(!=) - COMPARE_WEAK(>) - COMPARE_WEAK(<) - COMPARE_WEAK(<=) - COMPARE_WEAK(>=) - - inline bool operator == (const wp& o) const { - return (m_ptr == o.m_ptr) && (m_refs == o.m_refs); - } - template - inline bool operator == (const wp& o) const { - return m_ptr == o.m_ptr; - } - - inline bool operator > (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); - } - template - inline bool operator > (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); - } - - inline bool operator < (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); - } - template - inline bool operator < (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); - } - inline bool operator != (const wp& o) const { return m_refs != o.m_refs; } - template inline bool operator != (const wp& o) const { return !operator == (o); } - inline bool operator <= (const wp& o) const { return !operator > (o); } - template inline bool operator <= (const wp& o) const { return !operator > (o); } - inline bool operator >= (const wp& o) const { return !operator < (o); } - template inline bool operator >= (const wp& o) const { return !operator < (o); } - -private: - template friend class sp; - template friend class wp; - - T* m_ptr; - weakref_type* m_refs; -}; - -template -TextOutput& operator<<(TextOutput& to, const wp& val); - -#undef COMPARE_WEAK - -// --------------------------------------------------------------------------- -// No user serviceable parts below here. - -template -wp::wp(T* other) - : m_ptr(other) -{ - if (other) m_refs = other->createWeak(this); -} - -template -wp::wp(const wp& other) - : m_ptr(other.m_ptr), m_refs(other.m_refs) -{ - if (m_ptr) m_refs->incWeak(this); -} - -template -wp::wp(const sp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = m_ptr->createWeak(this); - } -} - -template template -wp::wp(U* other) - : m_ptr(other) -{ - if (other) m_refs = other->createWeak(this); -} - -template template -wp::wp(const wp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = other.m_refs; - m_refs->incWeak(this); - } -} - -template template -wp::wp(const sp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = m_ptr->createWeak(this); - } -} - -template -wp::~wp() -{ - if (m_ptr) m_refs->decWeak(this); -} - -template -wp& wp::operator = (T* other) -{ - weakref_type* newRefs = - other ? other->createWeak(this) : 0; - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = newRefs; - return *this; -} - -template -wp& wp::operator = (const wp& other) -{ - weakref_type* otherRefs(other.m_refs); - T* otherPtr(other.m_ptr); - if (otherPtr) otherRefs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = otherRefs; - return *this; -} - -template -wp& wp::operator = (const sp& other) -{ - weakref_type* newRefs = - other != NULL ? other->createWeak(this) : 0; - T* otherPtr(other.m_ptr); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = newRefs; - return *this; -} - -template template -wp& wp::operator = (U* other) -{ - weakref_type* newRefs = - other ? other->createWeak(this) : 0; - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = newRefs; - return *this; -} - -template template -wp& wp::operator = (const wp& other) -{ - weakref_type* otherRefs(other.m_refs); - U* otherPtr(other.m_ptr); - if (otherPtr) otherRefs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = otherRefs; - return *this; -} - -template template -wp& wp::operator = (const sp& other) -{ - weakref_type* newRefs = - other != NULL ? other->createWeak(this) : 0; - U* otherPtr(other.m_ptr); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = newRefs; - return *this; -} - -template -void wp::set_object_and_refs(T* other, weakref_type* refs) -{ - if (other) refs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = refs; -} - -template -sp wp::promote() const -{ - sp result; - if (m_ptr && m_refs->attemptIncStrong(&result)) { - result.set_pointer(m_ptr); - } - return result; -} - -template -void wp::clear() -{ - if (m_ptr) { - m_refs->decWeak(this); - m_ptr = 0; - } -} - -template -inline TextOutput& operator<<(TextOutput& to, const wp& val) -{ - return printWeakPointer(to, val.unsafe_get()); -} - -// --------------------------------------------------------------------------- - -// this class just serves as a namespace so TYPE::moveReferences can stay -// private. -class ReferenceMover { -public: - // it would be nice if we could make sure no extra code is generated - // for sp or wp when TYPE is a descendant of RefBase: - // Using a sp override doesn't work; it's a bit like we wanted - // a template template... - - template static inline - void move_references(sp* d, sp const* s, size_t n) { - - class Renamer : public ReferenceRenamer { - sp* d; - sp const* s; - virtual void operator()(size_t i) const { - // The id are known to be the sp<>'s this pointer - TYPE::renameRefId(d[i].get(), &s[i], &d[i]); - } - public: - Renamer(sp* d, sp const* s) : d(d), s(s) { } - virtual ~Renamer() { } - }; - - memmove(d, s, n*sizeof(sp)); - TYPE::renameRefs(n, Renamer(d, s)); - } - - - template static inline - void move_references(wp* d, wp const* s, size_t n) { - - class Renamer : public ReferenceRenamer { - wp* d; - wp const* s; - virtual void operator()(size_t i) const { - // The id are known to be the wp<>'s this pointer - TYPE::renameRefId(d[i].get_refs(), &s[i], &d[i]); - } - public: - Renamer(wp* d, wp const* s) : d(d), s(s) { } - virtual ~Renamer() { } - }; - - memmove(d, s, n*sizeof(wp)); - TYPE::renameRefs(n, Renamer(d, s)); - } -}; - -// specialization for moving sp<> and wp<> types. -// these are used by the [Sorted|Keyed]Vector<> implementations -// sp<> and wp<> need to be handled specially, because they do not -// have trivial copy operation in the general case (see RefBase.cpp -// when DEBUG ops are enabled), but can be implemented very -// efficiently in most cases. - -template inline -void move_forward_type(sp* d, sp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_backward_type(sp* d, sp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_forward_type(wp* d, wp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_backward_type(wp* d, wp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_REF_BASE_H diff --git a/third_party/android_system_core/include/utils/SharedBuffer.h b/third_party/android_system_core/include/utils/SharedBuffer.h deleted file mode 100644 index b6709537e..000000000 --- a/third_party/android_system_core/include/utils/SharedBuffer.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_SHARED_BUFFER_H -#define ANDROID_SHARED_BUFFER_H - -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class SharedBuffer -{ -public: - - /* flags to use with release() */ - enum { - eKeepStorage = 0x00000001 - }; - - /*! allocate a buffer of size 'size' and acquire() it. - * call release() to free it. - */ - static SharedBuffer* alloc(size_t size); - - /*! free the memory associated with the SharedBuffer. - * Fails if there are any users associated with this SharedBuffer. - * In other words, the buffer must have been release by all its - * users. - */ - static ssize_t dealloc(const SharedBuffer* released); - - //! access the data for read - inline const void* data() const; - - //! access the data for read/write - inline void* data(); - - //! get size of the buffer - inline size_t size() const; - - //! get back a SharedBuffer object from its data - static inline SharedBuffer* bufferFromData(void* data); - - //! get back a SharedBuffer object from its data - static inline const SharedBuffer* bufferFromData(const void* data); - - //! get the size of a SharedBuffer object from its data - static inline size_t sizeFromData(const void* data); - - //! edit the buffer (get a writtable, or non-const, version of it) - SharedBuffer* edit() const; - - //! edit the buffer, resizing if needed - SharedBuffer* editResize(size_t size) const; - - //! like edit() but fails if a copy is required - SharedBuffer* attemptEdit() const; - - //! resize and edit the buffer, loose it's content. - SharedBuffer* reset(size_t size) const; - - //! acquire/release a reference on this buffer - void acquire() const; - - /*! release a reference on this buffer, with the option of not - * freeing the memory associated with it if it was the last reference - * returns the previous reference count - */ - int32_t release(uint32_t flags = 0) const; - - //! returns wether or not we're the only owner - inline bool onlyOwner() const; - - -private: - inline SharedBuffer() { } - inline ~SharedBuffer() { } - SharedBuffer(const SharedBuffer&); - SharedBuffer& operator = (const SharedBuffer&); - - // 16 bytes. must be sized to preserve correct alignment. - mutable int32_t mRefs; - size_t mSize; - uint32_t mReserved[2]; -}; - -// --------------------------------------------------------------------------- - -const void* SharedBuffer::data() const { - return this + 1; -} - -void* SharedBuffer::data() { - return this + 1; -} - -size_t SharedBuffer::size() const { - return mSize; -} - -SharedBuffer* SharedBuffer::bufferFromData(void* data) { - return data ? static_cast(data)-1 : 0; -} - -const SharedBuffer* SharedBuffer::bufferFromData(const void* data) { - return data ? static_cast(data)-1 : 0; -} - -size_t SharedBuffer::sizeFromData(const void* data) { - return data ? bufferFromData(data)->mSize : 0; -} - -bool SharedBuffer::onlyOwner() const { - return (mRefs == 1); -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_H diff --git a/third_party/android_system_core/include/utils/Singleton.h b/third_party/android_system_core/include/utils/Singleton.h deleted file mode 100644 index ffc03cb5d..000000000 --- a/third_party/android_system_core/include/utils/Singleton.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef ANDROID_UTILS_SINGLETON_H -#define ANDROID_UTILS_SINGLETON_H - -#include -#include -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -template -class ANDROID_API Singleton -{ -public: - static TYPE& getInstance() { - Mutex::Autolock _l(sLock); - TYPE* instance = sInstance; - if (instance == 0) { - instance = new TYPE(); - sInstance = instance; - } - return *instance; - } - - static bool hasInstance() { - Mutex::Autolock _l(sLock); - return sInstance != 0; - } - -protected: - ~Singleton() { }; - Singleton() { }; - -private: - Singleton(const Singleton&); - Singleton& operator = (const Singleton&); - static Mutex sLock; - static TYPE* sInstance; -}; - -/* - * use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file - * (eg: .cpp) to create the static instance of Singleton<>'s attributes, - * and avoid to have a copy of them in each compilation units Singleton - * is used. - * NOTE: we use a version of Mutex ctor that takes a parameter, because - * for some unknown reason using the default ctor doesn't emit the variable! - */ - -#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \ - template<> ::android::Mutex \ - (::android::Singleton< TYPE >::sLock)(::android::Mutex::PRIVATE); \ - template<> TYPE* ::android::Singleton< TYPE >::sInstance(0); \ - template class ::android::Singleton< TYPE >; - - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_UTILS_SINGLETON_H - diff --git a/third_party/android_system_core/include/utils/SortedVector.h b/third_party/android_system_core/include/utils/SortedVector.h deleted file mode 100644 index 2d3e82a7c..000000000 --- a/third_party/android_system_core/include/utils/SortedVector.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_SORTED_VECTOR_H -#define ANDROID_SORTED_VECTOR_H - -#include -#include -#include - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class SortedVector : private SortedVectorImpl -{ - friend class Vector; - -public: - typedef TYPE value_type; - - /*! - * Constructors and destructors - */ - - SortedVector(); - SortedVector(const SortedVector& rhs); - virtual ~SortedVector(); - - /*! copy operator */ - const SortedVector& operator = (const SortedVector& rhs) const; - SortedVector& operator = (const SortedVector& rhs); - - /* - * empty the vector - */ - - inline void clear() { VectorImpl::clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return VectorImpl::size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return VectorImpl::isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return VectorImpl::capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } - - /*! - * C-style array access - */ - - //! read-only C-style access - inline const TYPE* array() const; - - //! read-write C-style access. BE VERY CAREFUL when modifying the array - //! you must keep it sorted! You usually don't use this function. - TYPE* editArray(); - - //! finds the index of an item - ssize_t indexOf(const TYPE& item) const; - - //! finds where this item should be inserted - size_t orderOf(const TYPE& item) const; - - - /*! - * accessors - */ - - //! read-only access to an item at a given index - inline const TYPE& operator [] (size_t index) const; - //! alternate name for operator [] - inline const TYPE& itemAt(size_t index) const; - //! stack-usage of the vector. returns the top of the stack (last element) - const TYPE& top() const; - - /*! - * modifying the array - */ - - //! add an item in the right place (and replace the one that is there) - ssize_t add(const TYPE& item); - - //! editItemAt() MUST NOT change the order of this item - TYPE& editItemAt(size_t index) { - return *( static_cast(VectorImpl::editItemLocation(index)) ); - } - - //! merges a vector into this one - ssize_t merge(const Vector& vector); - ssize_t merge(const SortedVector& vector); - - //! removes an item - ssize_t remove(const TYPE&); - - //! remove several items - inline ssize_t removeItemsAt(size_t index, size_t count = 1); - //! remove one item - inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } - -protected: - virtual void do_construct(void* storage, size_t num) const; - virtual void do_destroy(void* storage, size_t num) const; - virtual void do_copy(void* dest, const void* from, size_t num) const; - virtual void do_splat(void* dest, const void* item, size_t num) const; - virtual void do_move_forward(void* dest, const void* from, size_t num) const; - virtual void do_move_backward(void* dest, const void* from, size_t num) const; - virtual int do_compare(const void* lhs, const void* rhs) const; -}; - -// SortedVector can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -template struct trait_trivial_move > { enum { value = true }; }; - -// --------------------------------------------------------------------------- -// No user serviceable parts from here... -// --------------------------------------------------------------------------- - -template inline -SortedVector::SortedVector() - : SortedVectorImpl(sizeof(TYPE), - ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) - |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) - |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) - ) -{ -} - -template inline -SortedVector::SortedVector(const SortedVector& rhs) - : SortedVectorImpl(rhs) { -} - -template inline -SortedVector::~SortedVector() { - finish_vector(); -} - -template inline -SortedVector& SortedVector::operator = (const SortedVector& rhs) { - SortedVectorImpl::operator = (rhs); - return *this; -} - -template inline -const SortedVector& SortedVector::operator = (const SortedVector& rhs) const { - SortedVectorImpl::operator = (rhs); - return *this; -} - -template inline -const TYPE* SortedVector::array() const { - return static_cast(arrayImpl()); -} - -template inline -TYPE* SortedVector::editArray() { - return static_cast(editArrayImpl()); -} - - -template inline -const TYPE& SortedVector::operator[](size_t index) const { - LOG_FATAL_IF(index>=size(), - "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, - int(index), int(size())); - return *(array() + index); -} - -template inline -const TYPE& SortedVector::itemAt(size_t index) const { - return operator[](index); -} - -template inline -const TYPE& SortedVector::top() const { - return *(array() + size() - 1); -} - -template inline -ssize_t SortedVector::add(const TYPE& item) { - return SortedVectorImpl::add(&item); -} - -template inline -ssize_t SortedVector::indexOf(const TYPE& item) const { - return SortedVectorImpl::indexOf(&item); -} - -template inline -size_t SortedVector::orderOf(const TYPE& item) const { - return SortedVectorImpl::orderOf(&item); -} - -template inline -ssize_t SortedVector::merge(const Vector& vector) { - return SortedVectorImpl::merge(reinterpret_cast(vector)); -} - -template inline -ssize_t SortedVector::merge(const SortedVector& vector) { - return SortedVectorImpl::merge(reinterpret_cast(vector)); -} - -template inline -ssize_t SortedVector::remove(const TYPE& item) { - return SortedVectorImpl::remove(&item); -} - -template inline -ssize_t SortedVector::removeItemsAt(size_t index, size_t count) { - return VectorImpl::removeItemsAt(index, count); -} - -// --------------------------------------------------------------------------- - -template -void SortedVector::do_construct(void* storage, size_t num) const { - construct_type( reinterpret_cast(storage), num ); -} - -template -void SortedVector::do_destroy(void* storage, size_t num) const { - destroy_type( reinterpret_cast(storage), num ); -} - -template -void SortedVector::do_copy(void* dest, const void* from, size_t num) const { - copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void SortedVector::do_splat(void* dest, const void* item, size_t num) const { - splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); -} - -template -void SortedVector::do_move_forward(void* dest, const void* from, size_t num) const { - move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void SortedVector::do_move_backward(void* dest, const void* from, size_t num) const { - move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -int SortedVector::do_compare(const void* lhs, const void* rhs) const { - return compare_type( *reinterpret_cast(lhs), *reinterpret_cast(rhs) ); -} - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_SORTED_VECTOR_H diff --git a/third_party/android_system_core/include/utils/StopWatch.h b/third_party/android_system_core/include/utils/StopWatch.h deleted file mode 100644 index 693dd3ccf..000000000 --- a/third_party/android_system_core/include/utils/StopWatch.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_STOPWATCH_H -#define ANDROID_STOPWATCH_H - -#include -#include - -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class StopWatch -{ -public: - StopWatch( const char *name, - int clock = SYSTEM_TIME_MONOTONIC, - uint32_t flags = 0); - ~StopWatch(); - - const char* name() const; - nsecs_t lap(); - nsecs_t elapsedTime() const; - - void reset(); - -private: - const char* mName; - int mClock; - uint32_t mFlags; - - struct lap_t { - nsecs_t soFar; - nsecs_t thisLap; - }; - - nsecs_t mStartTime; - lap_t mLaps[8]; - int mNumLaps; -}; - - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STOPWATCH_H diff --git a/third_party/android_system_core/include/utils/String16.h b/third_party/android_system_core/include/utils/String16.h deleted file mode 100644 index d131bfc6a..000000000 --- a/third_party/android_system_core/include/utils/String16.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_STRING16_H -#define ANDROID_STRING16_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -extern "C" { - -} - -// --------------------------------------------------------------------------- - -namespace android { - -// --------------------------------------------------------------------------- - -class String8; -class TextOutput; - -//! This is a string holding UTF-16 characters. -class String16 -{ -public: - /* use String16(StaticLinkage) if you're statically linking against - * libutils and declaring an empty static String16, e.g.: - * - * static String16 sAStaticEmptyString(String16::kEmptyString); - * static String16 sAnotherStaticEmptyString(sAStaticEmptyString); - */ - enum StaticLinkage { kEmptyString }; - - String16(); - explicit String16(StaticLinkage); - String16(const String16& o); - String16(const String16& o, - size_t len, - size_t begin=0); - explicit String16(const char16_t* o); - explicit String16(const char16_t* o, size_t len); - explicit String16(const String8& o); - explicit String16(const char* o); - explicit String16(const char* o, size_t len); - - ~String16(); - - inline const char16_t* string() const; - inline size_t size() const; - - inline const SharedBuffer* sharedBuffer() const; - - void setTo(const String16& other); - status_t setTo(const char16_t* other); - status_t setTo(const char16_t* other, size_t len); - status_t setTo(const String16& other, - size_t len, - size_t begin=0); - - status_t append(const String16& other); - status_t append(const char16_t* other, size_t len); - - inline String16& operator=(const String16& other); - - inline String16& operator+=(const String16& other); - inline String16 operator+(const String16& other) const; - - status_t insert(size_t pos, const char16_t* chrs); - status_t insert(size_t pos, - const char16_t* chrs, size_t len); - - ssize_t findFirst(char16_t c) const; - ssize_t findLast(char16_t c) const; - - bool startsWith(const String16& prefix) const; - bool startsWith(const char16_t* prefix) const; - - status_t makeLower(); - - status_t replaceAll(char16_t replaceThis, - char16_t withThis); - - status_t remove(size_t len, size_t begin=0); - - inline int compare(const String16& other) const; - - inline bool operator<(const String16& other) const; - inline bool operator<=(const String16& other) const; - inline bool operator==(const String16& other) const; - inline bool operator!=(const String16& other) const; - inline bool operator>=(const String16& other) const; - inline bool operator>(const String16& other) const; - - inline bool operator<(const char16_t* other) const; - inline bool operator<=(const char16_t* other) const; - inline bool operator==(const char16_t* other) const; - inline bool operator!=(const char16_t* other) const; - inline bool operator>=(const char16_t* other) const; - inline bool operator>(const char16_t* other) const; - - inline operator const char16_t*() const; - -private: - const char16_t* mString; -}; - -// String16 can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -ANDROID_TRIVIAL_MOVE_TRAIT(String16) - -// --------------------------------------------------------------------------- -// No user servicable parts below. - -inline int compare_type(const String16& lhs, const String16& rhs) -{ - return lhs.compare(rhs); -} - -inline int strictly_order_type(const String16& lhs, const String16& rhs) -{ - return compare_type(lhs, rhs) < 0; -} - -inline const char16_t* String16::string() const -{ - return mString; -} - -inline size_t String16::size() const -{ - return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1; -} - -inline const SharedBuffer* String16::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); -} - -inline String16& String16::operator=(const String16& other) -{ - setTo(other); - return *this; -} - -inline String16& String16::operator+=(const String16& other) -{ - append(other); - return *this; -} - -inline String16 String16::operator+(const String16& other) const -{ - String16 tmp(*this); - tmp += other; - return tmp; -} - -inline int String16::compare(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()); -} - -inline bool String16::operator<(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) < 0; -} - -inline bool String16::operator<=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) <= 0; -} - -inline bool String16::operator==(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) == 0; -} - -inline bool String16::operator!=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) != 0; -} - -inline bool String16::operator>=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) >= 0; -} - -inline bool String16::operator>(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) > 0; -} - -inline bool String16::operator<(const char16_t* other) const -{ - return strcmp16(mString, other) < 0; -} - -inline bool String16::operator<=(const char16_t* other) const -{ - return strcmp16(mString, other) <= 0; -} - -inline bool String16::operator==(const char16_t* other) const -{ - return strcmp16(mString, other) == 0; -} - -inline bool String16::operator!=(const char16_t* other) const -{ - return strcmp16(mString, other) != 0; -} - -inline bool String16::operator>=(const char16_t* other) const -{ - return strcmp16(mString, other) >= 0; -} - -inline bool String16::operator>(const char16_t* other) const -{ - return strcmp16(mString, other) > 0; -} - -inline String16::operator const char16_t*() const -{ - return mString; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRING16_H diff --git a/third_party/android_system_core/include/utils/String8.h b/third_party/android_system_core/include/utils/String8.h deleted file mode 100644 index ecfcf10be..000000000 --- a/third_party/android_system_core/include/utils/String8.h +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_STRING8_H -#define ANDROID_STRING8_H - -#include -#include -#include -#include - -#include // for strcmp -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class String16; -class TextOutput; - -//! This is a string holding UTF-8 characters. Does not allow the value more -// than 0x10FFFF, which is not valid unicode codepoint. -class String8 -{ -public: - /* use String8(StaticLinkage) if you're statically linking against - * libutils and declaring an empty static String8, e.g.: - * - * static String8 sAStaticEmptyString(String8::kEmptyString); - * static String8 sAnotherStaticEmptyString(sAStaticEmptyString); - */ - enum StaticLinkage { kEmptyString }; - - String8(); - explicit String8(StaticLinkage); - String8(const String8& o); - explicit String8(const char* o); - explicit String8(const char* o, size_t numChars); - - explicit String8(const String16& o); - explicit String8(const char16_t* o); - explicit String8(const char16_t* o, size_t numChars); - explicit String8(const char32_t* o); - explicit String8(const char32_t* o, size_t numChars); - ~String8(); - - static inline const String8 empty(); - - static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2))); - static String8 formatV(const char* fmt, va_list args); - - inline const char* string() const; - inline size_t size() const; - inline size_t length() const; - inline size_t bytes() const; - inline bool isEmpty() const; - - inline const SharedBuffer* sharedBuffer() const; - - void clear(); - - void setTo(const String8& other); - status_t setTo(const char* other); - status_t setTo(const char* other, size_t numChars); - status_t setTo(const char16_t* other, size_t numChars); - status_t setTo(const char32_t* other, - size_t length); - - status_t append(const String8& other); - status_t append(const char* other); - status_t append(const char* other, size_t numChars); - - status_t appendFormat(const char* fmt, ...) - __attribute__((format (printf, 2, 3))); - status_t appendFormatV(const char* fmt, va_list args); - - // Note that this function takes O(N) time to calculate the value. - // No cache value is stored. - size_t getUtf32Length() const; - int32_t getUtf32At(size_t index, - size_t *next_index) const; - void getUtf32(char32_t* dst) const; - - inline String8& operator=(const String8& other); - inline String8& operator=(const char* other); - - inline String8& operator+=(const String8& other); - inline String8 operator+(const String8& other) const; - - inline String8& operator+=(const char* other); - inline String8 operator+(const char* other) const; - - inline int compare(const String8& other) const; - - inline bool operator<(const String8& other) const; - inline bool operator<=(const String8& other) const; - inline bool operator==(const String8& other) const; - inline bool operator!=(const String8& other) const; - inline bool operator>=(const String8& other) const; - inline bool operator>(const String8& other) const; - - inline bool operator<(const char* other) const; - inline bool operator<=(const char* other) const; - inline bool operator==(const char* other) const; - inline bool operator!=(const char* other) const; - inline bool operator>=(const char* other) const; - inline bool operator>(const char* other) const; - - inline operator const char*() const; - - char* lockBuffer(size_t size); - void unlockBuffer(); - status_t unlockBuffer(size_t size); - - // return the index of the first byte of other in this at or after - // start, or -1 if not found - ssize_t find(const char* other, size_t start = 0) const; - - // return true if this string contains the specified substring - inline bool contains(const char* other) const; - - // removes all occurrence of the specified substring - // returns true if any were found and removed - bool removeAll(const char* other); - - void toLower(); - void toLower(size_t start, size_t numChars); - void toUpper(); - void toUpper(size_t start, size_t numChars); - - - /* - * These methods operate on the string as if it were a path name. - */ - - /* - * Set the filename field to a specific value. - * - * Normalizes the filename, removing a trailing '/' if present. - */ - void setPathName(const char* name); - void setPathName(const char* name, size_t numChars); - - /* - * Get just the filename component. - * - * "/tmp/foo/bar.c" --> "bar.c" - */ - String8 getPathLeaf(void) const; - - /* - * Remove the last (file name) component, leaving just the directory - * name. - * - * "/tmp/foo/bar.c" --> "/tmp/foo" - * "/tmp" --> "" // ????? shouldn't this be "/" ???? XXX - * "bar.c" --> "" - */ - String8 getPathDir(void) const; - - /* - * Retrieve the front (root dir) component. Optionally also return the - * remaining components. - * - * "/tmp/foo/bar.c" --> "tmp" (remain = "foo/bar.c") - * "/tmp" --> "tmp" (remain = "") - * "bar.c" --> "bar.c" (remain = "") - */ - String8 walkPath(String8* outRemains = NULL) const; - - /* - * Return the filename extension. This is the last '.' and any number - * of characters that follow it. The '.' is included in case we - * decide to expand our definition of what constitutes an extension. - * - * "/tmp/foo/bar.c" --> ".c" - * "/tmp" --> "" - * "/tmp/foo.bar/baz" --> "" - * "foo.jpeg" --> ".jpeg" - * "foo." --> "" - */ - String8 getPathExtension(void) const; - - /* - * Return the path without the extension. Rules for what constitutes - * an extension are described in the comment for getPathExtension(). - * - * "/tmp/foo/bar.c" --> "/tmp/foo/bar" - */ - String8 getBasePath(void) const; - - /* - * Add a component to the pathname. We guarantee that there is - * exactly one path separator between the old path and the new. - * If there is no existing name, we just copy the new name in. - * - * If leaf is a fully qualified path (i.e. starts with '/', it - * replaces whatever was there before. - */ - String8& appendPath(const char* leaf); - String8& appendPath(const String8& leaf) { return appendPath(leaf.string()); } - - /* - * Like appendPath(), but does not affect this string. Returns a new one instead. - */ - String8 appendPathCopy(const char* leaf) const - { String8 p(*this); p.appendPath(leaf); return p; } - String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.string()); } - - /* - * Converts all separators in this string to /, the default path separator. - * - * If the default OS separator is backslash, this converts all - * backslashes to slashes, in-place. Otherwise it does nothing. - * Returns self. - */ - String8& convertToResPath(); - -private: - status_t real_append(const char* other, size_t numChars); - char* find_extension(void) const; - - const char* mString; -}; - -// String8 can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -ANDROID_TRIVIAL_MOVE_TRAIT(String8) - -// --------------------------------------------------------------------------- -// No user servicable parts below. - -inline int compare_type(const String8& lhs, const String8& rhs) -{ - return lhs.compare(rhs); -} - -inline int strictly_order_type(const String8& lhs, const String8& rhs) -{ - return compare_type(lhs, rhs) < 0; -} - -inline const String8 String8::empty() { - return String8(); -} - -inline const char* String8::string() const -{ - return mString; -} - -inline size_t String8::length() const -{ - return SharedBuffer::sizeFromData(mString)-1; -} - -inline size_t String8::size() const -{ - return length(); -} - -inline bool String8::isEmpty() const -{ - return length() == 0; -} - -inline size_t String8::bytes() const -{ - return SharedBuffer::sizeFromData(mString)-1; -} - -inline const SharedBuffer* String8::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); -} - -inline bool String8::contains(const char* other) const -{ - return find(other) >= 0; -} - -inline String8& String8::operator=(const String8& other) -{ - setTo(other); - return *this; -} - -inline String8& String8::operator=(const char* other) -{ - setTo(other); - return *this; -} - -inline String8& String8::operator+=(const String8& other) -{ - append(other); - return *this; -} - -inline String8 String8::operator+(const String8& other) const -{ - String8 tmp(*this); - tmp += other; - return tmp; -} - -inline String8& String8::operator+=(const char* other) -{ - append(other); - return *this; -} - -inline String8 String8::operator+(const char* other) const -{ - String8 tmp(*this); - tmp += other; - return tmp; -} - -inline int String8::compare(const String8& other) const -{ - return strcmp(mString, other.mString); -} - -inline bool String8::operator<(const String8& other) const -{ - return strcmp(mString, other.mString) < 0; -} - -inline bool String8::operator<=(const String8& other) const -{ - return strcmp(mString, other.mString) <= 0; -} - -inline bool String8::operator==(const String8& other) const -{ - return strcmp(mString, other.mString) == 0; -} - -inline bool String8::operator!=(const String8& other) const -{ - return strcmp(mString, other.mString) != 0; -} - -inline bool String8::operator>=(const String8& other) const -{ - return strcmp(mString, other.mString) >= 0; -} - -inline bool String8::operator>(const String8& other) const -{ - return strcmp(mString, other.mString) > 0; -} - -inline bool String8::operator<(const char* other) const -{ - return strcmp(mString, other) < 0; -} - -inline bool String8::operator<=(const char* other) const -{ - return strcmp(mString, other) <= 0; -} - -inline bool String8::operator==(const char* other) const -{ - return strcmp(mString, other) == 0; -} - -inline bool String8::operator!=(const char* other) const -{ - return strcmp(mString, other) != 0; -} - -inline bool String8::operator>=(const char* other) const -{ - return strcmp(mString, other) >= 0; -} - -inline bool String8::operator>(const char* other) const -{ - return strcmp(mString, other) > 0; -} - -inline String8::operator const char*() const -{ - return mString; -} - -} // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRING8_H diff --git a/third_party/android_system_core/include/utils/StrongPointer.h b/third_party/android_system_core/include/utils/StrongPointer.h deleted file mode 100644 index aba9577da..000000000 --- a/third_party/android_system_core/include/utils/StrongPointer.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_STRONG_POINTER_H -#define ANDROID_STRONG_POINTER_H - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -template class wp; - -// --------------------------------------------------------------------------- - -#define COMPARE(_op_) \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -inline bool operator _op_ (const T* o) const { \ - return m_ptr _op_ o; \ -} \ -template \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const U* o) const { \ - return m_ptr _op_ o; \ -} \ -inline bool operator _op_ (const wp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const wp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} - -// --------------------------------------------------------------------------- - -template -class sp { -public: - inline sp() : m_ptr(0) { } - - sp(T* other); - sp(const sp& other); - template sp(U* other); - template sp(const sp& other); - - ~sp(); - - // Assignment - - sp& operator = (T* other); - sp& operator = (const sp& other); - - template sp& operator = (const sp& other); - template sp& operator = (U* other); - - //! Special optimization for use by ProcessState (and nobody else). - void force_set(T* other); - - // Reset - - void clear(); - - // Accessors - - inline T& operator* () const { return *m_ptr; } - inline T* operator-> () const { return m_ptr; } - inline T* get() const { return m_ptr; } - - // Operators - - COMPARE(==) - COMPARE(!=) - COMPARE(>) - COMPARE(<) - COMPARE(<=) - COMPARE(>=) - -private: - template friend class sp; - template friend class wp; - void set_pointer(T* ptr); - T* m_ptr; -}; - -#undef COMPARE - -// --------------------------------------------------------------------------- -// No user serviceable parts below here. - -template -sp::sp(T* other) - : m_ptr(other) { - if (other) - other->incStrong(this); -} - -template -sp::sp(const sp& other) - : m_ptr(other.m_ptr) { - if (m_ptr) - m_ptr->incStrong(this); -} - -template template -sp::sp(U* other) - : m_ptr(other) { - if (other) - ((T*) other)->incStrong(this); -} - -template template -sp::sp(const sp& other) - : m_ptr(other.m_ptr) { - if (m_ptr) - m_ptr->incStrong(this); -} - -template -sp::~sp() { - if (m_ptr) - m_ptr->decStrong(this); -} - -template -sp& sp::operator =(const sp& other) { - T* otherPtr(other.m_ptr); - if (otherPtr) - otherPtr->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = otherPtr; - return *this; -} - -template -sp& sp::operator =(T* other) { - if (other) - other->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = other; - return *this; -} - -template template -sp& sp::operator =(const sp& other) { - T* otherPtr(other.m_ptr); - if (otherPtr) - otherPtr->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = otherPtr; - return *this; -} - -template template -sp& sp::operator =(U* other) { - if (other) - ((T*) other)->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = other; - return *this; -} - -template -void sp::force_set(T* other) { - other->forceIncStrong(this); - m_ptr = other; -} - -template -void sp::clear() { - if (m_ptr) { - m_ptr->decStrong(this); - m_ptr = 0; - } -} - -template -void sp::set_pointer(T* ptr) { - m_ptr = ptr; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRONG_POINTER_H diff --git a/third_party/android_system_core/include/utils/SystemClock.h b/third_party/android_system_core/include/utils/SystemClock.h deleted file mode 100644 index 01db34078..000000000 --- a/third_party/android_system_core/include/utils/SystemClock.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2008 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. - */ - -#ifndef ANDROID_UTILS_SYSTEMCLOCK_H -#define ANDROID_UTILS_SYSTEMCLOCK_H - -#include -#include - -namespace android { - -int64_t uptimeMillis(); -int64_t elapsedRealtime(); -int64_t elapsedRealtimeNano(); - -}; // namespace android - -#endif // ANDROID_UTILS_SYSTEMCLOCK_H - diff --git a/third_party/android_system_core/include/utils/Thread.h b/third_party/android_system_core/include/utils/Thread.h deleted file mode 100644 index 28839fded..000000000 --- a/third_party/android_system_core/include/utils/Thread.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_UTILS_THREAD_H -#define _LIBS_UTILS_THREAD_H - -#include -#include -#include - -#if !defined(_WIN32) -# include -#endif - -#include -#include -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -class Thread : virtual public RefBase -{ -public: - // Create a Thread object, but doesn't create or start the associated - // thread. See the run() method. - Thread(bool canCallJava = true); - virtual ~Thread(); - - // Start the thread in threadLoop() which needs to be implemented. - virtual status_t run( const char* name = 0, - int32_t priority = PRIORITY_DEFAULT, - size_t stack = 0); - - // Ask this object's thread to exit. This function is asynchronous, when the - // function returns the thread might still be running. Of course, this - // function can be called from a different thread. - virtual void requestExit(); - - // Good place to do one-time initializations - virtual status_t readyToRun(); - - // Call requestExit() and wait until this object's thread exits. - // BE VERY CAREFUL of deadlocks. In particular, it would be silly to call - // this function from this object's thread. Will return WOULD_BLOCK in - // that case. - status_t requestExitAndWait(); - - // Wait until this object's thread exits. Returns immediately if not yet running. - // Do not call from this object's thread; will return WOULD_BLOCK in that case. - status_t join(); - - // Indicates whether this thread is running or not. - bool isRunning() const; - -#ifdef HAVE_ANDROID_OS - // Return the thread's kernel ID, same as the thread itself calling gettid(), - // or -1 if the thread is not running. - pid_t getTid() const; -#endif - -protected: - // exitPending() returns true if requestExit() has been called. - bool exitPending() const; - -private: - // Derived class must implement threadLoop(). The thread starts its life - // here. There are two ways of using the Thread object: - // 1) loop: if threadLoop() returns true, it will be called again if - // requestExit() wasn't called. - // 2) once: if threadLoop() returns false, the thread will exit upon return. - virtual bool threadLoop() = 0; - -private: - Thread& operator=(const Thread&); - static int _threadLoop(void* user); - const bool mCanCallJava; - // always hold mLock when reading or writing - thread_id_t mThread; - mutable Mutex mLock; - Condition mThreadExitedCondition; - status_t mStatus; - // note that all accesses of mExitPending and mRunning need to hold mLock - volatile bool mExitPending; - volatile bool mRunning; - sp mHoldSelf; -#ifdef HAVE_ANDROID_OS - // legacy for debugging, not used by getTid() as it is set by the child thread - // and so is not initialized until the child reaches that point - pid_t mTid; -#endif -}; - - -}; // namespace android - -// --------------------------------------------------------------------------- -#endif // _LIBS_UTILS_THREAD_H -// --------------------------------------------------------------------------- diff --git a/third_party/android_system_core/include/utils/ThreadDefs.h b/third_party/android_system_core/include/utils/ThreadDefs.h deleted file mode 100644 index 9711c1379..000000000 --- a/third_party/android_system_core/include/utils/ThreadDefs.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_UTILS_THREAD_DEFS_H -#define _LIBS_UTILS_THREAD_DEFS_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* android_thread_id_t; - -typedef int (*android_thread_func_t)(void*); - -#ifdef __cplusplus -} // extern "C" -#endif - -// --------------------------------------------------------------------------- -// C++ API -#ifdef __cplusplus -namespace android { -// --------------------------------------------------------------------------- - -typedef android_thread_id_t thread_id_t; -typedef android_thread_func_t thread_func_t; - -enum { - PRIORITY_LOWEST = ANDROID_PRIORITY_LOWEST, - PRIORITY_BACKGROUND = ANDROID_PRIORITY_BACKGROUND, - PRIORITY_NORMAL = ANDROID_PRIORITY_NORMAL, - PRIORITY_FOREGROUND = ANDROID_PRIORITY_FOREGROUND, - PRIORITY_DISPLAY = ANDROID_PRIORITY_DISPLAY, - PRIORITY_URGENT_DISPLAY = ANDROID_PRIORITY_URGENT_DISPLAY, - PRIORITY_AUDIO = ANDROID_PRIORITY_AUDIO, - PRIORITY_URGENT_AUDIO = ANDROID_PRIORITY_URGENT_AUDIO, - PRIORITY_HIGHEST = ANDROID_PRIORITY_HIGHEST, - PRIORITY_DEFAULT = ANDROID_PRIORITY_DEFAULT, - PRIORITY_MORE_FAVORABLE = ANDROID_PRIORITY_MORE_FAVORABLE, - PRIORITY_LESS_FAVORABLE = ANDROID_PRIORITY_LESS_FAVORABLE, -}; - -// --------------------------------------------------------------------------- -}; // namespace android -#endif // __cplusplus -// --------------------------------------------------------------------------- - - -#endif // _LIBS_UTILS_THREAD_DEFS_H diff --git a/third_party/android_system_core/include/utils/Timers.h b/third_party/android_system_core/include/utils/Timers.h deleted file mode 100644 index 54ec47489..000000000 --- a/third_party/android_system_core/include/utils/Timers.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Timer functions. -// -#ifndef _LIBS_UTILS_TIMERS_H -#define _LIBS_UTILS_TIMERS_H - -#include -#include -#include - -#include - -// ------------------------------------------------------------------ -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int64_t nsecs_t; // nano-seconds - -static CONSTEXPR inline nsecs_t seconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000000000; -} - -static CONSTEXPR inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000000; -} - -static CONSTEXPR inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000; -} - -static CONSTEXPR inline nsecs_t nanoseconds_to_seconds(nsecs_t secs) -{ - return secs/1000000000; -} - -static CONSTEXPR inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs) -{ - return secs/1000000; -} - -static CONSTEXPR inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs) -{ - return secs/1000; -} - -static CONSTEXPR inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);} -static CONSTEXPR inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);} -static CONSTEXPR inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);} -static CONSTEXPR inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);} -static CONSTEXPR inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);} -static CONSTEXPR inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);} - -static CONSTEXPR inline nsecs_t seconds(nsecs_t v) { return s2ns(v); } -static CONSTEXPR inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); } -static CONSTEXPR inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); } - -enum { - SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock - SYSTEM_TIME_MONOTONIC = 1, // monotonic time since unspecified starting point - SYSTEM_TIME_PROCESS = 2, // high-resolution per-process clock - SYSTEM_TIME_THREAD = 3, // high-resolution per-thread clock - SYSTEM_TIME_BOOTTIME = 4 // same as SYSTEM_TIME_MONOTONIC, but including CPU suspend time -}; - -// return the system-time according to the specified clock -#ifdef __cplusplus -nsecs_t systemTime(int clock = SYSTEM_TIME_MONOTONIC); -#else -nsecs_t systemTime(int clock); -#endif // def __cplusplus - -/** - * Returns the number of milliseconds to wait between the reference time and the timeout time. - * If the timeout is in the past relative to the reference time, returns 0. - * If the timeout is more than INT_MAX milliseconds in the future relative to the reference time, - * such as when timeoutTime == LLONG_MAX, returns -1 to indicate an infinite timeout delay. - * Otherwise, returns the difference between the reference time and timeout time - * rounded up to the next millisecond. - */ -int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _LIBS_UTILS_TIMERS_H diff --git a/third_party/android_system_core/include/utils/Tokenizer.h b/third_party/android_system_core/include/utils/Tokenizer.h deleted file mode 100644 index bb25f374c..000000000 --- a/third_party/android_system_core/include/utils/Tokenizer.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#ifndef _UTILS_TOKENIZER_H -#define _UTILS_TOKENIZER_H - -#include -#include -#include -#include - -namespace android { - -/** - * A simple tokenizer for loading and parsing ASCII text files line by line. - */ -class Tokenizer { - Tokenizer(const String8& filename, FileMap* fileMap, char* buffer, - bool ownBuffer, size_t length); - -public: - ~Tokenizer(); - - /** - * Opens a file and maps it into memory. - * - * Returns NO_ERROR and a tokenizer for the file, if successful. - * Otherwise returns an error and sets outTokenizer to NULL. - */ - static status_t open(const String8& filename, Tokenizer** outTokenizer); - - /** - * Prepares to tokenize the contents of a string. - * - * Returns NO_ERROR and a tokenizer for the string, if successful. - * Otherwise returns an error and sets outTokenizer to NULL. - */ - static status_t fromContents(const String8& filename, - const char* contents, Tokenizer** outTokenizer); - - /** - * Returns true if at the end of the file. - */ - inline bool isEof() const { return mCurrent == getEnd(); } - - /** - * Returns true if at the end of the line or end of the file. - */ - inline bool isEol() const { return isEof() || *mCurrent == '\n'; } - - /** - * Gets the name of the file. - */ - inline String8 getFilename() const { return mFilename; } - - /** - * Gets a 1-based line number index for the current position. - */ - inline int32_t getLineNumber() const { return mLineNumber; } - - /** - * Formats a location string consisting of the filename and current line number. - * Returns a string like "MyFile.txt:33". - */ - String8 getLocation() const; - - /** - * Gets the character at the current position. - * Returns null at end of file. - */ - inline char peekChar() const { return isEof() ? '\0' : *mCurrent; } - - /** - * Gets the remainder of the current line as a string, excluding the newline character. - */ - String8 peekRemainderOfLine() const; - - /** - * Gets the character at the current position and advances past it. - * Returns null at end of file. - */ - inline char nextChar() { return isEof() ? '\0' : *(mCurrent++); } - - /** - * Gets the next token on this line stopping at the specified delimiters - * or the end of the line whichever comes first and advances past it. - * Also stops at embedded nulls. - * Returns the token or an empty string if the current character is a delimiter - * or is at the end of the line. - */ - String8 nextToken(const char* delimiters); - - /** - * Advances to the next line. - * Does nothing if already at the end of the file. - */ - void nextLine(); - - /** - * Skips over the specified delimiters in the line. - * Also skips embedded nulls. - */ - void skipDelimiters(const char* delimiters); - -private: - Tokenizer(const Tokenizer& other); // not copyable - - String8 mFilename; - FileMap* mFileMap; - char* mBuffer; - bool mOwnBuffer; - size_t mLength; - - const char* mCurrent; - int32_t mLineNumber; - - inline const char* getEnd() const { return mBuffer + mLength; } - -}; - -} // namespace android - -#endif // _UTILS_TOKENIZER_H diff --git a/third_party/android_system_core/include/utils/Trace.h b/third_party/android_system_core/include/utils/Trace.h deleted file mode 100644 index 6ee343d79..000000000 --- a/third_party/android_system_core/include/utils/Trace.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -#ifndef ANDROID_TRACE_H -#define ANDROID_TRACE_H - -#ifdef HAVE_ANDROID_OS - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// See for more ATRACE_* macros. - -// ATRACE_NAME traces the beginning and end of the current scope. To trace -// the correct start and end times this macro should be declared first in the -// scope body. -#define ATRACE_NAME(name) android::ScopedTrace ___tracer(ATRACE_TAG, name) -// ATRACE_CALL is an ATRACE_NAME that uses the current function name. -#define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) - -namespace android { - -class ScopedTrace { -public: -inline ScopedTrace(uint64_t tag, const char* name) - : mTag(tag) { - atrace_begin(mTag,name); -} - -inline ~ScopedTrace() { - atrace_end(mTag); -} - -private: - uint64_t mTag; -}; - -}; // namespace android - -#else // HAVE_ANDROID_OS - -#define ATRACE_NAME(...) -#define ATRACE_CALL() - -#endif // HAVE_ANDROID_OS - -#endif // ANDROID_TRACE_H diff --git a/third_party/android_system_core/include/utils/TypeHelpers.h b/third_party/android_system_core/include/utils/TypeHelpers.h deleted file mode 100644 index 13c908159..000000000 --- a/third_party/android_system_core/include/utils/TypeHelpers.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_TYPE_HELPERS_H -#define ANDROID_TYPE_HELPERS_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -/* - * Types traits - */ - -template struct trait_trivial_ctor { enum { value = false }; }; -template struct trait_trivial_dtor { enum { value = false }; }; -template struct trait_trivial_copy { enum { value = false }; }; -template struct trait_trivial_move { enum { value = false }; }; -template struct trait_pointer { enum { value = false }; }; -template struct trait_pointer { enum { value = true }; }; - -template -struct traits { - enum { - // whether this type is a pointer - is_pointer = trait_pointer::value, - // whether this type's constructor is a no-op - has_trivial_ctor = is_pointer || trait_trivial_ctor::value, - // whether this type's destructor is a no-op - has_trivial_dtor = is_pointer || trait_trivial_dtor::value, - // whether this type type can be copy-constructed with memcpy - has_trivial_copy = is_pointer || trait_trivial_copy::value, - // whether this type can be moved with memmove - has_trivial_move = is_pointer || trait_trivial_move::value - }; -}; - -template -struct aggregate_traits { - enum { - is_pointer = false, - has_trivial_ctor = - traits::has_trivial_ctor && traits::has_trivial_ctor, - has_trivial_dtor = - traits::has_trivial_dtor && traits::has_trivial_dtor, - has_trivial_copy = - traits::has_trivial_copy && traits::has_trivial_copy, - has_trivial_move = - traits::has_trivial_move && traits::has_trivial_move - }; -}; - -#define ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ - template<> struct trait_trivial_ctor< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ - template<> struct trait_trivial_dtor< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_COPY_TRAIT( T ) \ - template<> struct trait_trivial_copy< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_MOVE_TRAIT( T ) \ - template<> struct trait_trivial_move< T > { enum { value = true }; }; - -#define ANDROID_BASIC_TYPES_TRAITS( T ) \ - ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ - ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ - ANDROID_TRIVIAL_COPY_TRAIT( T ) \ - ANDROID_TRIVIAL_MOVE_TRAIT( T ) - -// --------------------------------------------------------------------------- - -/* - * basic types traits - */ - -ANDROID_BASIC_TYPES_TRAITS( void ) -ANDROID_BASIC_TYPES_TRAITS( bool ) -ANDROID_BASIC_TYPES_TRAITS( char ) -ANDROID_BASIC_TYPES_TRAITS( unsigned char ) -ANDROID_BASIC_TYPES_TRAITS( short ) -ANDROID_BASIC_TYPES_TRAITS( unsigned short ) -ANDROID_BASIC_TYPES_TRAITS( int ) -ANDROID_BASIC_TYPES_TRAITS( unsigned int ) -ANDROID_BASIC_TYPES_TRAITS( long ) -ANDROID_BASIC_TYPES_TRAITS( unsigned long ) -ANDROID_BASIC_TYPES_TRAITS( long long ) -ANDROID_BASIC_TYPES_TRAITS( unsigned long long ) -ANDROID_BASIC_TYPES_TRAITS( float ) -ANDROID_BASIC_TYPES_TRAITS( double ) - -// --------------------------------------------------------------------------- - - -/* - * compare and order types - */ - -template inline -int strictly_order_type(const TYPE& lhs, const TYPE& rhs) { - return (lhs < rhs) ? 1 : 0; -} - -template inline -int compare_type(const TYPE& lhs, const TYPE& rhs) { - return strictly_order_type(rhs, lhs) - strictly_order_type(lhs, rhs); -} - -/* - * create, destroy, copy and move types... - */ - -template inline -void construct_type(TYPE* p, size_t n) { - if (!traits::has_trivial_ctor) { - while (n--) { - new(p++) TYPE; - } - } -} - -template inline -void destroy_type(TYPE* p, size_t n) { - if (!traits::has_trivial_dtor) { - while (n--) { - p->~TYPE(); - p++; - } - } -} - -template inline -void copy_type(TYPE* d, const TYPE* s, size_t n) { - if (!traits::has_trivial_copy) { - while (n--) { - new(d) TYPE(*s); - d++, s++; - } - } else { - memcpy(d,s,n*sizeof(TYPE)); - } -} - -template inline -void splat_type(TYPE* where, const TYPE* what, size_t n) { - if (!traits::has_trivial_copy) { - while (n--) { - new(where) TYPE(*what); - where++; - } - } else { - while (n--) { - *where++ = *what; - } - } -} - -template inline -void move_forward_type(TYPE* d, const TYPE* s, size_t n = 1) { - if ((traits::has_trivial_dtor && traits::has_trivial_copy) - || traits::has_trivial_move) - { - memmove(d,s,n*sizeof(TYPE)); - } else { - d += n; - s += n; - while (n--) { - --d, --s; - if (!traits::has_trivial_copy) { - new(d) TYPE(*s); - } else { - *d = *s; - } - if (!traits::has_trivial_dtor) { - s->~TYPE(); - } - } - } -} - -template inline -void move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) { - if ((traits::has_trivial_dtor && traits::has_trivial_copy) - || traits::has_trivial_move) - { - memmove(d,s,n*sizeof(TYPE)); - } else { - while (n--) { - if (!traits::has_trivial_copy) { - new(d) TYPE(*s); - } else { - *d = *s; - } - if (!traits::has_trivial_dtor) { - s->~TYPE(); - } - d++, s++; - } - } -} - -// --------------------------------------------------------------------------- - -/* - * a key/value pair - */ - -template -struct key_value_pair_t { - typedef KEY key_t; - typedef VALUE value_t; - - KEY key; - VALUE value; - key_value_pair_t() { } - key_value_pair_t(const key_value_pair_t& o) : key(o.key), value(o.value) { } - key_value_pair_t(const KEY& k, const VALUE& v) : key(k), value(v) { } - key_value_pair_t(const KEY& k) : key(k) { } - inline bool operator < (const key_value_pair_t& o) const { - return strictly_order_type(key, o.key); - } - inline const KEY& getKey() const { - return key; - } - inline const VALUE& getValue() const { - return value; - } -}; - -template -struct trait_trivial_ctor< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_ctor }; }; -template -struct trait_trivial_dtor< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_dtor }; }; -template -struct trait_trivial_copy< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_copy }; }; -template -struct trait_trivial_move< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_move }; }; - -// --------------------------------------------------------------------------- - -/* - * Hash codes. - */ -typedef uint32_t hash_t; - -template -hash_t hash_type(const TKey& key); - -/* Built-in hash code specializations. - * Assumes pointers are 32bit. */ -#define ANDROID_INT32_HASH(T) \ - template <> inline hash_t hash_type(const T& value) { return hash_t(value); } -#define ANDROID_INT64_HASH(T) \ - template <> inline hash_t hash_type(const T& value) { \ - return hash_t((value >> 32) ^ value); } -#define ANDROID_REINTERPRET_HASH(T, R) \ - template <> inline hash_t hash_type(const T& value) { \ - return hash_type(*reinterpret_cast(&value)); } - -ANDROID_INT32_HASH(bool) -ANDROID_INT32_HASH(int8_t) -ANDROID_INT32_HASH(uint8_t) -ANDROID_INT32_HASH(int16_t) -ANDROID_INT32_HASH(uint16_t) -ANDROID_INT32_HASH(int32_t) -ANDROID_INT32_HASH(uint32_t) -ANDROID_INT64_HASH(int64_t) -ANDROID_INT64_HASH(uint64_t) -ANDROID_REINTERPRET_HASH(float, uint32_t) -ANDROID_REINTERPRET_HASH(double, uint64_t) - -template inline hash_t hash_type(T* const & value) { - return hash_type(uintptr_t(value)); -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_TYPE_HELPERS_H diff --git a/third_party/android_system_core/include/utils/Unicode.h b/third_party/android_system_core/include/utils/Unicode.h deleted file mode 100644 index 4e17cc3d9..000000000 --- a/third_party/android_system_core/include/utils/Unicode.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_UNICODE_H -#define ANDROID_UNICODE_H - -#include -#include - -extern "C" { - -// Standard string functions on char16_t strings. -int strcmp16(const char16_t *, const char16_t *); -int strncmp16(const char16_t *s1, const char16_t *s2, size_t n); -size_t strlen16(const char16_t *); -size_t strnlen16(const char16_t *, size_t); -char16_t *strcpy16(char16_t *, const char16_t *); -char16_t *strncpy16(char16_t *, const char16_t *, size_t); - -// Version of comparison that supports embedded nulls. -// This is different than strncmp() because we don't stop -// at a nul character and consider the strings to be different -// if the lengths are different (thus we need to supply the -// lengths of both strings). This can also be used when -// your string is not nul-terminated as it will have the -// equivalent result as strcmp16 (unlike strncmp16). -int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2); - -// Version of strzcmp16 for comparing strings in different endianness. -int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2); - -// Standard string functions on char32_t strings. -size_t strlen32(const char32_t *); -size_t strnlen32(const char32_t *, size_t); - -/** - * Measure the length of a UTF-32 string in UTF-8. If the string is invalid - * such as containing a surrogate character, -1 will be returned. - */ -ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len); - -/** - * Stores a UTF-8 string converted from "src" in "dst", if "dst_length" is not - * large enough to store the string, the part of the "src" string is stored - * into "dst" as much as possible. See the examples for more detail. - * Returns the size actually used for storing the string. - * dst" is not null-terminated when dst_len is fully used (like strncpy). - * - * Example 1 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" >= 7 - * -> - * Returned value == 6 - * "dst" becomes \xE3\x81\x82\xE3\x81\x84\0 - * (note that "dst" is null-terminated) - * - * Example 2 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" == 5 - * -> - * Returned value == 3 - * "dst" becomes \xE3\x81\x82\0 - * (note that "dst" is null-terminated, but \u3044 is not stored in "dst" - * since "dst" does not have enough size to store the character) - * - * Example 3 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" == 6 - * -> - * Returned value == 6 - * "dst" becomes \xE3\x81\x82\xE3\x81\x84 - * (note that "dst" is NOT null-terminated, like strncpy) - */ -void utf32_to_utf8(const char32_t* src, size_t src_len, char* dst, size_t dst_len); - -/** - * Returns the unicode value at "index". - * Returns -1 when the index is invalid (equals to or more than "src_len"). - * If returned value is positive, it is able to be converted to char32_t, which - * is unsigned. Then, if "next_index" is not NULL, the next index to be used is - * stored in "next_index". "next_index" can be NULL. - */ -int32_t utf32_from_utf8_at(const char *src, size_t src_len, size_t index, size_t *next_index); - - -/** - * Returns the UTF-8 length of UTF-16 string "src". - */ -ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len); - -/** - * Converts a UTF-16 string to UTF-8. The destination buffer must be large - * enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added - * NULL terminator. - */ -void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst, size_t dst_len); - -/** - * Returns the length of "src" when "src" is valid UTF-8 string. - * Returns 0 if src is NULL or 0-length string. Returns -1 when the source - * is an invalid string. - * - * This function should be used to determine whether "src" is valid UTF-8 - * characters with valid unicode codepoints. "src" must be null-terminated. - * - * If you are going to use other utf8_to_... functions defined in this header - * with string which may not be valid UTF-8 with valid codepoint (form 0 to - * 0x10FFFF), you should use this function before calling others, since the - * other functions do not check whether the string is valid UTF-8 or not. - * - * If you do not care whether "src" is valid UTF-8 or not, you should use - * strlen() as usual, which should be much faster. - */ -ssize_t utf8_length(const char *src); - -/** - * Measure the length of a UTF-32 string. - */ -size_t utf8_to_utf32_length(const char *src, size_t src_len); - -/** - * Stores a UTF-32 string converted from "src" in "dst". "dst" must be large - * enough to store the entire converted string as measured by - * utf8_to_utf32_length plus space for a NULL terminator. - */ -void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst); - -/** - * Returns the UTF-16 length of UTF-8 string "src". - */ -ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen); - -/** - * Convert UTF-8 to UTF-16 including surrogate pairs. - * Returns a pointer to the end of the string (where a null terminator might go - * if you wanted to add one). - */ -char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst); - -/** - * Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer - * must be large enough to hold the result as measured by utf8_to_utf16_length - * plus an added NULL terminator. - */ -void utf8_to_utf16(const uint8_t* src, size_t srcLen, char16_t* dst); - -/** - * Like utf8_to_utf16_no_null_terminator, but you can supply a maximum length of the - * decoded string. The decoded string will fill up to that length; if it is longer - * the returned pointer will be to the character after dstLen. - */ -char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen); - -} - -#endif diff --git a/third_party/android_system_core/include/utils/Vector.h b/third_party/android_system_core/include/utils/Vector.h deleted file mode 100644 index ed7b72521..000000000 --- a/third_party/android_system_core/include/utils/Vector.h +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_VECTOR_H -#define ANDROID_VECTOR_H - -#include -#include -#include - -#include - -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class SortedVector; - -/*! - * The main templated vector class ensuring type safety - * while making use of VectorImpl. - * This is the class users want to use. - */ - -template -class Vector : private VectorImpl -{ -public: - typedef TYPE value_type; - - /*! - * Constructors and destructors - */ - - Vector(); - Vector(const Vector& rhs); - explicit Vector(const SortedVector& rhs); - virtual ~Vector(); - - /*! copy operator */ - const Vector& operator = (const Vector& rhs) const; - Vector& operator = (const Vector& rhs); - - const Vector& operator = (const SortedVector& rhs) const; - Vector& operator = (const SortedVector& rhs); - - /* - * empty the vector - */ - - inline void clear() { VectorImpl::clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return VectorImpl::size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return VectorImpl::isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return VectorImpl::capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } - - /*! - * set the size of the vector. items are appended with the default - * constructor, or removed from the end as needed. - */ - inline ssize_t resize(size_t size) { return VectorImpl::resize(size); } - - /*! - * C-style array access - */ - - //! read-only C-style access - inline const TYPE* array() const; - //! read-write C-style access - TYPE* editArray(); - - /*! - * accessors - */ - - //! read-only access to an item at a given index - inline const TYPE& operator [] (size_t index) const; - //! alternate name for operator [] - inline const TYPE& itemAt(size_t index) const; - //! stack-usage of the vector. returns the top of the stack (last element) - const TYPE& top() const; - - /*! - * modifying the array - */ - - //! copy-on write support, grants write access to an item - TYPE& editItemAt(size_t index); - //! grants right access to the top of the stack (last element) - TYPE& editTop(); - - /*! - * append/insert another vector - */ - - //! insert another vector at a given index - ssize_t insertVectorAt(const Vector& vector, size_t index); - - //! append another vector at the end of this one - ssize_t appendVector(const Vector& vector); - - - //! insert an array at a given index - ssize_t insertArrayAt(const TYPE* array, size_t index, size_t length); - - //! append an array at the end of this vector - ssize_t appendArray(const TYPE* array, size_t length); - - /*! - * add/insert/replace items - */ - - //! insert one or several items initialized with their default constructor - inline ssize_t insertAt(size_t index, size_t numItems = 1); - //! insert one or several items initialized from a prototype item - ssize_t insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1); - //! pop the top of the stack (removes the last element). No-op if the stack's empty - inline void pop(); - //! pushes an item initialized with its default constructor - inline void push(); - //! pushes an item on the top of the stack - void push(const TYPE& item); - //! same as push() but returns the index the item was added at (or an error) - inline ssize_t add(); - //! same as push() but returns the index the item was added at (or an error) - ssize_t add(const TYPE& item); - //! replace an item with a new one initialized with its default constructor - inline ssize_t replaceAt(size_t index); - //! replace an item with a new one - ssize_t replaceAt(const TYPE& item, size_t index); - - /*! - * remove items - */ - - //! remove several items - inline ssize_t removeItemsAt(size_t index, size_t count = 1); - //! remove one item - inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } - - /*! - * sort (stable) the array - */ - - typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs); - typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state); - - inline status_t sort(compar_t cmp); - inline status_t sort(compar_r_t cmp, void* state); - - // for debugging only - inline size_t getItemSize() const { return itemSize(); } - - - /* - * these inlines add some level of compatibility with STL. eventually - * we should probably turn things around. - */ - typedef TYPE* iterator; - typedef TYPE const* const_iterator; - - inline iterator begin() { return editArray(); } - inline iterator end() { return editArray() + size(); } - inline const_iterator begin() const { return array(); } - inline const_iterator end() const { return array() + size(); } - inline void reserve(size_t n) { setCapacity(n); } - inline bool empty() const{ return isEmpty(); } - inline void push_back(const TYPE& item) { insertAt(item, size(), 1); } - inline void push_front(const TYPE& item) { insertAt(item, 0, 1); } - inline iterator erase(iterator pos) { - ssize_t index = removeItemsAt(pos-array()); - return begin() + index; - } - -protected: - virtual void do_construct(void* storage, size_t num) const; - virtual void do_destroy(void* storage, size_t num) const; - virtual void do_copy(void* dest, const void* from, size_t num) const; - virtual void do_splat(void* dest, const void* item, size_t num) const; - virtual void do_move_forward(void* dest, const void* from, size_t num) const; - virtual void do_move_backward(void* dest, const void* from, size_t num) const; -}; - -// Vector can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -template struct trait_trivial_move > { enum { value = true }; }; - -// --------------------------------------------------------------------------- -// No user serviceable parts from here... -// --------------------------------------------------------------------------- - -template inline -Vector::Vector() - : VectorImpl(sizeof(TYPE), - ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) - |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) - |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) - ) -{ -} - -template inline -Vector::Vector(const Vector& rhs) - : VectorImpl(rhs) { -} - -template inline -Vector::Vector(const SortedVector& rhs) - : VectorImpl(static_cast(rhs)) { -} - -template inline -Vector::~Vector() { - finish_vector(); -} - -template inline -Vector& Vector::operator = (const Vector& rhs) { - VectorImpl::operator = (rhs); - return *this; -} - -template inline -const Vector& Vector::operator = (const Vector& rhs) const { - VectorImpl::operator = (static_cast(rhs)); - return *this; -} - -template inline -Vector& Vector::operator = (const SortedVector& rhs) { - VectorImpl::operator = (static_cast(rhs)); - return *this; -} - -template inline -const Vector& Vector::operator = (const SortedVector& rhs) const { - VectorImpl::operator = (rhs); - return *this; -} - -template inline -const TYPE* Vector::array() const { - return static_cast(arrayImpl()); -} - -template inline -TYPE* Vector::editArray() { - return static_cast(editArrayImpl()); -} - - -template inline -const TYPE& Vector::operator[](size_t index) const { - LOG_FATAL_IF(index>=size(), - "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, - int(index), int(size())); - return *(array() + index); -} - -template inline -const TYPE& Vector::itemAt(size_t index) const { - return operator[](index); -} - -template inline -const TYPE& Vector::top() const { - return *(array() + size() - 1); -} - -template inline -TYPE& Vector::editItemAt(size_t index) { - return *( static_cast(editItemLocation(index)) ); -} - -template inline -TYPE& Vector::editTop() { - return *( static_cast(editItemLocation(size()-1)) ); -} - -template inline -ssize_t Vector::insertVectorAt(const Vector& vector, size_t index) { - return VectorImpl::insertVectorAt(reinterpret_cast(vector), index); -} - -template inline -ssize_t Vector::appendVector(const Vector& vector) { - return VectorImpl::appendVector(reinterpret_cast(vector)); -} - -template inline -ssize_t Vector::insertArrayAt(const TYPE* array, size_t index, size_t length) { - return VectorImpl::insertArrayAt(array, index, length); -} - -template inline -ssize_t Vector::appendArray(const TYPE* array, size_t length) { - return VectorImpl::appendArray(array, length); -} - -template inline -ssize_t Vector::insertAt(const TYPE& item, size_t index, size_t numItems) { - return VectorImpl::insertAt(&item, index, numItems); -} - -template inline -void Vector::push(const TYPE& item) { - return VectorImpl::push(&item); -} - -template inline -ssize_t Vector::add(const TYPE& item) { - return VectorImpl::add(&item); -} - -template inline -ssize_t Vector::replaceAt(const TYPE& item, size_t index) { - return VectorImpl::replaceAt(&item, index); -} - -template inline -ssize_t Vector::insertAt(size_t index, size_t numItems) { - return VectorImpl::insertAt(index, numItems); -} - -template inline -void Vector::pop() { - VectorImpl::pop(); -} - -template inline -void Vector::push() { - VectorImpl::push(); -} - -template inline -ssize_t Vector::add() { - return VectorImpl::add(); -} - -template inline -ssize_t Vector::replaceAt(size_t index) { - return VectorImpl::replaceAt(index); -} - -template inline -ssize_t Vector::removeItemsAt(size_t index, size_t count) { - return VectorImpl::removeItemsAt(index, count); -} - -template inline -status_t Vector::sort(Vector::compar_t cmp) { - return VectorImpl::sort((VectorImpl::compar_t)cmp); -} - -template inline -status_t Vector::sort(Vector::compar_r_t cmp, void* state) { - return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state); -} - -// --------------------------------------------------------------------------- - -template -void Vector::do_construct(void* storage, size_t num) const { - construct_type( reinterpret_cast(storage), num ); -} - -template -void Vector::do_destroy(void* storage, size_t num) const { - destroy_type( reinterpret_cast(storage), num ); -} - -template -void Vector::do_copy(void* dest, const void* from, size_t num) const { - copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void Vector::do_splat(void* dest, const void* item, size_t num) const { - splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); -} - -template -void Vector::do_move_forward(void* dest, const void* from, size_t num) const { - move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void Vector::do_move_backward(void* dest, const void* from, size_t num) const { - move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_H diff --git a/third_party/android_system_core/include/utils/VectorImpl.h b/third_party/android_system_core/include/utils/VectorImpl.h deleted file mode 100644 index 21ad71ce6..000000000 --- a/third_party/android_system_core/include/utils/VectorImpl.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -#ifndef ANDROID_VECTOR_IMPL_H -#define ANDROID_VECTOR_IMPL_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -// No user serviceable parts in here... -// --------------------------------------------------------------------------- - -namespace android { - -/*! - * Implementation of the guts of the vector<> class - * this ensures backward binary compatibility and - * reduces code size. - * For performance reasons, we expose mStorage and mCount - * so these fields are set in stone. - * - */ - -class VectorImpl -{ -public: - enum { // flags passed to the ctor - HAS_TRIVIAL_CTOR = 0x00000001, - HAS_TRIVIAL_DTOR = 0x00000002, - HAS_TRIVIAL_COPY = 0x00000004, - }; - - VectorImpl(size_t itemSize, uint32_t flags); - VectorImpl(const VectorImpl& rhs); - virtual ~VectorImpl(); - - /*! must be called from subclasses destructor */ - void finish_vector(); - - VectorImpl& operator = (const VectorImpl& rhs); - - /*! C-style array access */ - inline const void* arrayImpl() const { return mStorage; } - void* editArrayImpl(); - - /*! vector stats */ - inline size_t size() const { return mCount; } - inline bool isEmpty() const { return mCount == 0; } - size_t capacity() const; - ssize_t setCapacity(size_t size); - ssize_t resize(size_t size); - - /*! append/insert another vector or array */ - ssize_t insertVectorAt(const VectorImpl& vector, size_t index); - ssize_t appendVector(const VectorImpl& vector); - ssize_t insertArrayAt(const void* array, size_t index, size_t length); - ssize_t appendArray(const void* array, size_t length); - - /*! add/insert/replace items */ - ssize_t insertAt(size_t where, size_t numItems = 1); - ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); - void pop(); - void push(); - void push(const void* item); - ssize_t add(); - ssize_t add(const void* item); - ssize_t replaceAt(size_t index); - ssize_t replaceAt(const void* item, size_t index); - - /*! remove items */ - ssize_t removeItemsAt(size_t index, size_t count = 1); - void clear(); - - const void* itemLocation(size_t index) const; - void* editItemLocation(size_t index); - - typedef int (*compar_t)(const void* lhs, const void* rhs); - typedef int (*compar_r_t)(const void* lhs, const void* rhs, void* state); - status_t sort(compar_t cmp); - status_t sort(compar_r_t cmp, void* state); - -protected: - size_t itemSize() const; - void release_storage(); - - virtual void do_construct(void* storage, size_t num) const = 0; - virtual void do_destroy(void* storage, size_t num) const = 0; - virtual void do_copy(void* dest, const void* from, size_t num) const = 0; - virtual void do_splat(void* dest, const void* item, size_t num) const = 0; - virtual void do_move_forward(void* dest, const void* from, size_t num) const = 0; - virtual void do_move_backward(void* dest, const void* from, size_t num) const = 0; - -private: - void* _grow(size_t where, size_t amount); - void _shrink(size_t where, size_t amount); - - inline void _do_construct(void* storage, size_t num) const; - inline void _do_destroy(void* storage, size_t num) const; - inline void _do_copy(void* dest, const void* from, size_t num) const; - inline void _do_splat(void* dest, const void* item, size_t num) const; - inline void _do_move_forward(void* dest, const void* from, size_t num) const; - inline void _do_move_backward(void* dest, const void* from, size_t num) const; - - // These 2 fields are exposed in the inlines below, - // so they're set in stone. - void * mStorage; // base address of the vector - size_t mCount; // number of items - - const uint32_t mFlags; - const size_t mItemSize; -}; - - - -class SortedVectorImpl : public VectorImpl -{ -public: - SortedVectorImpl(size_t itemSize, uint32_t flags); - SortedVectorImpl(const VectorImpl& rhs); - virtual ~SortedVectorImpl(); - - SortedVectorImpl& operator = (const SortedVectorImpl& rhs); - - //! finds the index of an item - ssize_t indexOf(const void* item) const; - - //! finds where this item should be inserted - size_t orderOf(const void* item) const; - - //! add an item in the right place (or replaces it if there is one) - ssize_t add(const void* item); - - //! merges a vector into this one - ssize_t merge(const VectorImpl& vector); - ssize_t merge(const SortedVectorImpl& vector); - - //! removes an item - ssize_t remove(const void* item); - -protected: - virtual int do_compare(const void* lhs, const void* rhs) const = 0; - -private: - ssize_t _indexOrderOf(const void* item, size_t* order = 0) const; - - // these are made private, because they can't be used on a SortedVector - // (they don't have an implementation either) - ssize_t add(); - void pop(); - void push(); - void push(const void* item); - ssize_t insertVectorAt(const VectorImpl& vector, size_t index); - ssize_t appendVector(const VectorImpl& vector); - ssize_t insertArrayAt(const void* array, size_t index, size_t length); - ssize_t appendArray(const void* array, size_t length); - ssize_t insertAt(size_t where, size_t numItems = 1); - ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); - ssize_t replaceAt(size_t index); - ssize_t replaceAt(const void* item, size_t index); -}; - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_IMPL_H diff --git a/third_party/android_system_core/include/utils/ashmem.h b/third_party/android_system_core/include/utils/ashmem.h deleted file mode 100644 index 085477578..000000000 --- a/third_party/android_system_core/include/utils/ashmem.h +++ /dev/null @@ -1,41 +0,0 @@ -/* utils/ashmem.h - ** - ** Copyright 2008 The Android Open Source Project - ** - ** This file is dual licensed. It may be redistributed and/or modified - ** under the terms of the Apache 2.0 License OR version 2 of the GNU - ** General Public License. - */ - -#ifndef _UTILS_ASHMEM_H -#define _UTILS_ASHMEM_H - -#include -#include - -#define ASHMEM_NAME_LEN 256 - -#define ASHMEM_NAME_DEF "dev/ashmem" - -/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ -#define ASHMEM_NOT_REAPED 0 -#define ASHMEM_WAS_REAPED 1 - -/* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ -#define ASHMEM_NOW_UNPINNED 0 -#define ASHMEM_NOW_PINNED 1 - -#define __ASHMEMIOC 0x77 - -#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN]) -#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN]) -#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t) -#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4) -#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long) -#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6) -#define ASHMEM_PIN _IO(__ASHMEMIOC, 7) -#define ASHMEM_UNPIN _IO(__ASHMEMIOC, 8) -#define ASHMEM_ISPINNED _IO(__ASHMEMIOC, 9) -#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10) - -#endif /* _UTILS_ASHMEM_H */ diff --git a/third_party/android_system_core/include/utils/misc.h b/third_party/android_system_core/include/utils/misc.h deleted file mode 100644 index 6cccec387..000000000 --- a/third_party/android_system_core/include/utils/misc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2005 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. - */ - -// -// Handy utility functions and portability code. -// -#ifndef _LIBS_UTILS_MISC_H -#define _LIBS_UTILS_MISC_H - -#include - -/* get #of elements in a static array */ -#ifndef NELEM -# define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) -#endif - -namespace android { - -typedef void (*sysprop_change_callback)(void); -void add_sysprop_change_callback(sysprop_change_callback cb, int priority); -void report_sysprop_change(); - -}; // namespace android - -#endif // _LIBS_UTILS_MISC_H diff --git a/third_party/android_system_core/include/utils/threads.h b/third_party/android_system_core/include/utils/threads.h deleted file mode 100644 index 9de338211..000000000 --- a/third_party/android_system_core/include/utils/threads.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef _LIBS_UTILS_THREADS_H -#define _LIBS_UTILS_THREADS_H - -/* - * Please, DO NOT USE! - * - * This file is here only for legacy reasons. Instead, include directly - * the headers you need below. - * - */ - -#include - -#ifdef __cplusplus -#include -#include -#include -#include -#include -#endif - -#endif // _LIBS_UTILS_THREADS_H diff --git a/third_party/libgralloc/include/gralloc_priv.h b/third_party/libgralloc/include/gralloc_priv.h deleted file mode 100644 index 4aa47541b..000000000 --- a/third_party/libgralloc/include/gralloc_priv.h +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. - * - * 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. - */ - -#ifndef GRALLOC_PRIV_H_ -#define GRALLOC_PRIV_H_ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#define ROUND_UP_PAGESIZE(x) ( (((unsigned long)(x)) + PAGE_SIZE-1) & \ - (~(PAGE_SIZE-1)) ) - -/* Gralloc usage bits indicating the type of allocation that should be used */ -/* SYSTEM heap comes from kernel vmalloc (ION_SYSTEM_HEAP_ID) - * is cached by default and - * is not secured */ - -/* GRALLOC_USAGE_PRIVATE_0 is unused */ - -/* Non linear, Universal Bandwidth Compression */ -#define GRALLOC_USAGE_PRIVATE_ALLOC_UBWC GRALLOC_USAGE_PRIVATE_1 - -/* IOMMU heap comes from manually allocated pages, can be cached/uncached, - * is not secured */ -#define GRALLOC_USAGE_PRIVATE_IOMMU_HEAP GRALLOC_USAGE_PRIVATE_2 - -/* MM heap is a carveout heap for video, can be secured */ -#define GRALLOC_USAGE_PRIVATE_MM_HEAP GRALLOC_USAGE_PRIVATE_3 - -/* ADSP heap is a carveout heap, is not secured */ -#define GRALLOC_USAGE_PRIVATE_ADSP_HEAP 0x01000000 - -/* Set this for allocating uncached memory (using O_DSYNC), - * cannot be used with noncontiguous heaps */ -#define GRALLOC_USAGE_PRIVATE_UNCACHED 0x02000000 - -/* Buffer content should be displayed on an primary display only */ -#define GRALLOC_USAGE_PRIVATE_INTERNAL_ONLY 0x04000000 - -/* Buffer content should be displayed on an external display only */ -#define GRALLOC_USAGE_PRIVATE_EXTERNAL_ONLY 0x08000000 - -/* This flag is set for WFD usecase */ -#define GRALLOC_USAGE_PRIVATE_WFD 0x00200000 - -/* CAMERA heap is a carveout heap for camera, is not secured */ -#define GRALLOC_USAGE_PRIVATE_CAMERA_HEAP 0x00400000 - -/* This flag is used for SECURE display usecase */ -#define GRALLOC_USAGE_PRIVATE_SECURE_DISPLAY 0x00800000 - -/* define Gralloc perform */ -#define GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER 1 -// This will be used by the graphics drivers to know if certain features -// are defined in this display HAL. -// Ex: Newer GFX libraries + Older Display HAL -#define GRALLOC_MODULE_PERFORM_GET_STRIDE 2 -#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_FROM_HANDLE 3 -#define GRALLOC_MODULE_PERFORM_GET_CUSTOM_STRIDE_AND_HEIGHT_FROM_HANDLE 4 -#define GRALLOC_MODULE_PERFORM_GET_ATTRIBUTES 5 -#define GRALLOC_MODULE_PERFORM_GET_COLOR_SPACE_FROM_HANDLE 6 -#define GRALLOC_MODULE_PERFORM_GET_YUV_PLANE_INFO 7 -#define GRALLOC_MODULE_PERFORM_GET_MAP_SECURE_BUFFER_INFO 8 -#define GRALLOC_MODULE_PERFORM_GET_UBWC_FLAG 9 -#define GRALLOC_MODULE_PERFORM_GET_RGB_DATA_ADDRESS 10 -#define GRALLOC_MODULE_PERFORM_GET_IGC 11 -#define GRALLOC_MODULE_PERFORM_SET_IGC 12 -#define GRALLOC_MODULE_PERFORM_SET_SINGLE_BUFFER_MODE 13 - -/* OEM specific HAL formats */ - -#define HAL_PIXEL_FORMAT_RGBA_5551 6 -#define HAL_PIXEL_FORMAT_RGBA_4444 7 -#define HAL_PIXEL_FORMAT_NV12_ENCODEABLE 0x102 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS 0x7FA30C04 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED 0x7FA30C03 -#define HAL_PIXEL_FORMAT_YCbCr_420_SP 0x109 -#define HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO 0x7FA30C01 -#define HAL_PIXEL_FORMAT_YCrCb_422_SP 0x10B -#define HAL_PIXEL_FORMAT_R_8 0x10D -#define HAL_PIXEL_FORMAT_RG_88 0x10E -#define HAL_PIXEL_FORMAT_YCbCr_444_SP 0x10F -#define HAL_PIXEL_FORMAT_YCrCb_444_SP 0x110 -#define HAL_PIXEL_FORMAT_YCrCb_422_I 0x111 -#define HAL_PIXEL_FORMAT_BGRX_8888 0x112 -#define HAL_PIXEL_FORMAT_NV21_ZSL 0x113 -#define HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS 0x114 -#define HAL_PIXEL_FORMAT_BGR_565 0x115 -#define HAL_PIXEL_FORMAT_INTERLACE 0x180 - -//v4l2_fourcc('Y', 'U', 'Y', 'L'). 24 bpp YUYV 4:2:2 10 bit per component -#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT 0x4C595559 - -//v4l2_fourcc('Y', 'B', 'W', 'C'). 10 bit per component. This compressed -//format reduces the memory access bandwidth -#define HAL_PIXEL_FORMAT_YCbCr_422_I_10BIT_COMPRESSED 0x43574259 - -// UBWC aligned Venus format -#define HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC 0x7FA30C06 - -//Khronos ASTC formats -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define HAL_PIXEL_FORMAT_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define HAL_PIXEL_FORMAT_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD - -/* possible values for inverse gamma correction */ -#define HAL_IGC_NOT_SPECIFIED 0 -#define HAL_IGC_s_RGB 1 - -/* possible formats for 3D content*/ -enum { - HAL_NO_3D = 0x0, - HAL_3D_SIDE_BY_SIDE_L_R = 0x1, - HAL_3D_SIDE_BY_SIDE_R_L = 0x2, - HAL_3D_TOP_BOTTOM = 0x4, - HAL_3D_IN_SIDE_BY_SIDE_L_R = 0x10000, //unused legacy format -}; - -enum { - BUFFER_TYPE_UI = 0, - BUFFER_TYPE_VIDEO -}; - -#ifdef __cplusplus -struct private_handle_t : public native_handle { -#else - struct private_handle_t { - native_handle_t nativeHandle; -#endif - enum { - PRIV_FLAGS_FRAMEBUFFER = 0x00000001, - PRIV_FLAGS_USES_ION = 0x00000008, - PRIV_FLAGS_USES_ASHMEM = 0x00000010, - PRIV_FLAGS_NEEDS_FLUSH = 0x00000020, - PRIV_FLAGS_INTERNAL_ONLY = 0x00000040, - PRIV_FLAGS_NON_CPU_WRITER = 0x00000080, - PRIV_FLAGS_NONCONTIGUOUS_MEM = 0x00000100, - PRIV_FLAGS_CACHED = 0x00000200, - PRIV_FLAGS_SECURE_BUFFER = 0x00000400, - // Display on external only - PRIV_FLAGS_EXTERNAL_ONLY = 0x00002000, - // Set by HWC for protected non secure buffers - PRIV_FLAGS_PROTECTED_BUFFER = 0x00004000, - PRIV_FLAGS_VIDEO_ENCODER = 0x00010000, - PRIV_FLAGS_CAMERA_WRITE = 0x00020000, - PRIV_FLAGS_CAMERA_READ = 0x00040000, - PRIV_FLAGS_HW_COMPOSER = 0x00080000, - PRIV_FLAGS_HW_TEXTURE = 0x00100000, - PRIV_FLAGS_ITU_R_601 = 0x00200000, //Unused from display - PRIV_FLAGS_ITU_R_601_FR = 0x00400000, //Unused from display - PRIV_FLAGS_ITU_R_709 = 0x00800000, //Unused from display - PRIV_FLAGS_SECURE_DISPLAY = 0x01000000, - // Buffer is rendered in Tile Format - PRIV_FLAGS_TILE_RENDERED = 0x02000000, - // Buffer rendered using CPU/SW renderer - PRIV_FLAGS_CPU_RENDERED = 0x04000000, - // Buffer is allocated with UBWC alignment - PRIV_FLAGS_UBWC_ALIGNED = 0x08000000, - // Buffer allocated will be consumed by SF/HWC - PRIV_FLAGS_DISP_CONSUMER = 0x10000000 - }; - - // file-descriptors - int fd; - int fd_metadata; // fd for the meta-data - // ints - int magic; - int flags; - unsigned int size; - unsigned int offset; - int bufferType; - uint64_t base __attribute__((aligned(8))); - unsigned int offset_metadata; - // The gpu address mapped into the mmu. - uint64_t gpuaddr __attribute__((aligned(8))); - int format; - int width; // specifies aligned width - int height; // specifies aligned height - int real_width; - int real_height; - uint64_t base_metadata __attribute__((aligned(8))); - -#ifdef __cplusplus - static const int sNumFds = 2; - static inline int sNumInts() { - return ((sizeof(private_handle_t) - sizeof(native_handle_t)) / - sizeof(int)) - sNumFds; - } - static const int sMagic = 'gmsm'; - - private_handle_t(int fd, unsigned int size, int flags, int bufferType, - int format, int aligned_width, int aligned_height, - int width, int height, int eFd = -1, - unsigned int eOffset = 0, uint64_t eBase = 0) : - fd(fd), fd_metadata(eFd), magic(sMagic), - flags(flags), size(size), offset(0), bufferType(bufferType), - base(0), offset_metadata(eOffset), gpuaddr(0), - format(format), width(aligned_width), height(aligned_height), - real_width(width), real_height(height), base_metadata(eBase) - { - version = (int) sizeof(native_handle); - numInts = sNumInts(); - numFds = sNumFds; - } - ~private_handle_t() { - magic = 0; - } - - static int validate(const native_handle* h) { - const private_handle_t* hnd = (const private_handle_t*)h; - if (!h || h->version != sizeof(native_handle) || - h->numInts != sNumInts() || h->numFds != sNumFds || - hnd->magic != sMagic) - { - ALOGD("Invalid gralloc handle (at %p): " - "ver(%d/%zu) ints(%d/%d) fds(%d/%d)" - "magic(%c%c%c%c/%c%c%c%c)", - h, - h ? h->version : -1, sizeof(native_handle), - h ? h->numInts : -1, sNumInts(), - h ? h->numFds : -1, sNumFds, - hnd ? (((hnd->magic >> 24) & 0xFF)? - ((hnd->magic >> 24) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 16) & 0xFF)? - ((hnd->magic >> 16) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 8) & 0xFF)? - ((hnd->magic >> 8) & 0xFF) : '-') : '?', - hnd ? (((hnd->magic >> 0) & 0xFF)? - ((hnd->magic >> 0) & 0xFF) : '-') : '?', - (sMagic >> 24) & 0xFF, - (sMagic >> 16) & 0xFF, - (sMagic >> 8) & 0xFF, - (sMagic >> 0) & 0xFF); - return -EINVAL; - } - return 0; - } - - static private_handle_t* dynamicCast(const native_handle* in) { - if (validate(in) == 0) { - return (private_handle_t*) in; - } - return NULL; - } -#endif - }; - -#endif /* GRALLOC_PRIV_H_ */ diff --git a/third_party/libyuv/x64/lib/libyuv.a b/third_party/libyuv/x64/lib/libyuv.a index c6afc5643..ef786b117 100644 Binary files a/third_party/libyuv/x64/lib/libyuv.a and b/third_party/libyuv/x64/lib/libyuv.a differ diff --git a/third_party/snpe/aarch64 b/third_party/snpe/aarch64 deleted file mode 120000 index baf4e9cb6..000000000 --- a/third_party/snpe/aarch64 +++ /dev/null @@ -1 +0,0 @@ -aarch64-android-clang6.0 \ No newline at end of file diff --git a/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so b/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so deleted file mode 100644 index 5df5b07b1..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libPlatformValidatorShared.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libSNPE.so b/third_party/snpe/aarch64-android-clang6.0/libSNPE.so deleted file mode 100644 index 6ef777e15..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libSNPE.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so b/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so deleted file mode 100644 index 565c80bb6..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libSNPE_G.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so b/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so deleted file mode 100644 index 5b9a9cff6..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libc++_shared.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libcalculator.so b/third_party/snpe/aarch64-android-clang6.0/libcalculator.so deleted file mode 100644 index 3aa1ec3ac..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libcalculator.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so b/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so deleted file mode 100644 index bef3fc201..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libcalculator_domains.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libhta.so b/third_party/snpe/aarch64-android-clang6.0/libhta.so deleted file mode 100644 index bfd3554cf..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libhta.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so deleted file mode 100644 index 8a6b4e3fc..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libsnpe_adsp.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so deleted file mode 100644 index 0663d25e3..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so deleted file mode 100644 index 33d354ff7..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_system.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so deleted file mode 100644 index 5a6334459..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so b/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so deleted file mode 100644 index 2d74ae0f0..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libsnpe_dsp_domains_v2_system.so and /dev/null differ diff --git a/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so b/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so deleted file mode 100644 index 8dd26fb26..000000000 Binary files a/third_party/snpe/aarch64-android-clang6.0/libsymphony-cpu.so and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libPlatformValidatorShared.so b/third_party/snpe/aarch64-linux-gcc4.9/libPlatformValidatorShared.so deleted file mode 100644 index 32f8e2f60..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libPlatformValidatorShared.so and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libSNPE.so b/third_party/snpe/aarch64-linux-gcc4.9/libSNPE.so deleted file mode 100644 index 6f497cfa0..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libSNPE.so and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libatomic.so.1 b/third_party/snpe/aarch64-linux-gcc4.9/libatomic.so.1 deleted file mode 100644 index 809fd4ef6..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libatomic.so.1 and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libcalculator.so b/third_party/snpe/aarch64-linux-gcc4.9/libcalculator.so deleted file mode 100644 index dd3bfe5af..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libcalculator.so and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libcalculator_domains.so b/third_party/snpe/aarch64-linux-gcc4.9/libcalculator_domains.so deleted file mode 100644 index 05cf724b7..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libcalculator_domains.so and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_adsp.so b/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_adsp.so deleted file mode 100644 index 11db2cdf6..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_adsp.so and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_dsp_domains_v2.so b/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_dsp_domains_v2.so deleted file mode 100644 index cc8a8dc2a..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libsnpe_dsp_domains_v2.so and /dev/null differ diff --git a/third_party/snpe/aarch64-linux-gcc4.9/libsymphony-cpu.so b/third_party/snpe/aarch64-linux-gcc4.9/libsymphony-cpu.so deleted file mode 100644 index 202d7e971..000000000 Binary files a/third_party/snpe/aarch64-linux-gcc4.9/libsymphony-cpu.so and /dev/null differ diff --git a/third_party/snpe/aarch64-ubuntu-gcc7.5/libPlatformValidatorShared.so b/third_party/snpe/aarch64-ubuntu-gcc7.5/libPlatformValidatorShared.so new file mode 100644 index 000000000..d3872772b Binary files /dev/null and b/third_party/snpe/aarch64-ubuntu-gcc7.5/libPlatformValidatorShared.so differ diff --git a/third_party/snpe/aarch64-ubuntu-gcc7.5/libSNPE.so b/third_party/snpe/aarch64-ubuntu-gcc7.5/libSNPE.so new file mode 100644 index 000000000..be23b835a Binary files /dev/null and b/third_party/snpe/aarch64-ubuntu-gcc7.5/libSNPE.so differ diff --git a/third_party/snpe/aarch64-ubuntu-gcc7.5/libcalculator.so b/third_party/snpe/aarch64-ubuntu-gcc7.5/libcalculator.so new file mode 100644 index 000000000..3b8c33f3f Binary files /dev/null and b/third_party/snpe/aarch64-ubuntu-gcc7.5/libcalculator.so differ diff --git a/third_party/snpe/aarch64-ubuntu-gcc7.5/libhta.so b/third_party/snpe/aarch64-ubuntu-gcc7.5/libhta.so new file mode 100644 index 000000000..8358969ed Binary files /dev/null and b/third_party/snpe/aarch64-ubuntu-gcc7.5/libhta.so differ diff --git a/third_party/snpe/aarch64-ubuntu-gcc7.5/libsnpe_dsp_domains_v2.so b/third_party/snpe/aarch64-ubuntu-gcc7.5/libsnpe_dsp_domains_v2.so new file mode 100644 index 000000000..c4f3fa67a Binary files /dev/null and b/third_party/snpe/aarch64-ubuntu-gcc7.5/libsnpe_dsp_domains_v2.so differ diff --git a/third_party/snpe/dsp/libcalculator_domains_skel.so b/third_party/snpe/dsp/libcalculator_domains_skel.so deleted file mode 100644 index cb8897f23..000000000 Binary files a/third_party/snpe/dsp/libcalculator_domains_skel.so and /dev/null differ diff --git a/third_party/snpe/dsp/libcalculator_skel.so b/third_party/snpe/dsp/libcalculator_skel.so index 45515ea4f..020dbfe86 100644 Binary files a/third_party/snpe/dsp/libcalculator_skel.so and b/third_party/snpe/dsp/libcalculator_skel.so differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_domains_skel.so b/third_party/snpe/dsp/libsnpe_dsp_domains_skel.so deleted file mode 100644 index d4e341262..000000000 Binary files a/third_party/snpe/dsp/libsnpe_dsp_domains_skel.so and /dev/null differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_skel.so b/third_party/snpe/dsp/libsnpe_dsp_skel.so deleted file mode 100644 index cb37356a9..000000000 Binary files a/third_party/snpe/dsp/libsnpe_dsp_skel.so and /dev/null differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_v65_domains_v2_skel.so b/third_party/snpe/dsp/libsnpe_dsp_v65_domains_v2_skel.so index 97a1499a0..c1eb88fc6 100644 Binary files a/third_party/snpe/dsp/libsnpe_dsp_v65_domains_v2_skel.so and b/third_party/snpe/dsp/libsnpe_dsp_v65_domains_v2_skel.so differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_v66_domains_v2_skel.so b/third_party/snpe/dsp/libsnpe_dsp_v66_domains_v2_skel.so index 008e9e978..eeeb447c6 100644 Binary files a/third_party/snpe/dsp/libsnpe_dsp_v66_domains_v2_skel.so and b/third_party/snpe/dsp/libsnpe_dsp_v66_domains_v2_skel.so differ diff --git a/third_party/snpe/dsp/libsnpe_dsp_v68_domains_v3_skel.so b/third_party/snpe/dsp/libsnpe_dsp_v68_domains_v3_skel.so new file mode 100644 index 000000000..028979f11 Binary files /dev/null and b/third_party/snpe/dsp/libsnpe_dsp_v68_domains_v3_skel.so differ diff --git a/third_party/snpe/include/DlSystem/DlEnums.hpp b/third_party/snpe/include/DlSystem/DlEnums.hpp index 144706355..c9b3ef970 100644 --- a/third_party/snpe/include/DlSystem/DlEnums.hpp +++ b/third_party/snpe/include/DlSystem/DlEnums.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2014-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2014-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -76,6 +76,8 @@ enum class RuntimeCheckOption_t NORMAL_CHECK = 0, /// Perform basic runtime available check, may be runtime specific BASIC_CHECK = 1, + /// Perform unsignedPD runtime available check + UNSIGNEDPD_CHECK = 2, }; /** @@ -196,6 +198,36 @@ enum class ImageEncoding_t BGR = 6 }; +/** + * Enumeration that lists the supported LogLevels that can be set by users. + */ +enum class LogLevel_t +{ + /// Enumeration variable to be used by user to set logging level to FATAL. + LOG_FATAL = 0, + + /// Enumeration variable to be used by user to set logging level to ERROR. + LOG_ERROR = 1, + + /// Enumeration variable to be used by user to set logging level to WARN. + LOG_WARN = 2, + + /// Enumeration variable to be used by user to set logging level to INFO. + LOG_INFO = 3, + + /// Enumeration variable to be used by user to set logging level to VERBOSE. + LOG_VERBOSE = 4 +}; + +typedef enum : int +{ + UNSPECIFIED = 0, + FLOATING_POINT_32 = 1, + FLOATING_POINT_16 = 2, + FIXED_POINT_8 = 3, + FIXED_POINT_16 = 4 +} IOBufferDataType_t; + }} // namespaces end diff --git a/third_party/snpe/include/DlSystem/DlError.hpp b/third_party/snpe/include/DlSystem/DlError.hpp index f0a66e8e4..57592f01b 100644 --- a/third_party/snpe/include/DlSystem/DlError.hpp +++ b/third_party/snpe/include/DlSystem/DlError.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2016-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2016-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -59,6 +59,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_DLSYSTEM_BUFFER_CAST_FAILED = 216, SNPE_DLSYSTEM_WRONG_TRANSITION_TYPE = 217, SNPE_DLSYSTEM_LAYER_ALREADY_REGISTERED = 218, + SNPE_DLSYSTEM_TENSOR_DIM_INVALID = 219, SNPE_DLSYSTEM_BUFFERENCODING_UNKNOWN = 240, SNPE_DLSYSTEM_BUFFER_INVALID_PARAM = 241, @@ -89,6 +90,7 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_NETWORK_MISMATCH_BETWEEN_NAMES_AND_DIMS = 404, SNPE_NETWORK_MISSING_INPUT_NAMES = 405, SNPE_NETWORK_MISSING_OUTPUT_NAMES = 406, + SNPE_NETWORK_EXECUTION_FAILED = 407, // Host runtime errors SNPE_HOST_RUNTIME_TARGET_UNAVAILABLE = 500, @@ -140,6 +142,13 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { SNPE_DSP_RUNTIME_INVALID_PARAM_ERROR = 909, SNPE_DSP_RUNTIME_SYSTEM_ERROR = 910, SNPE_DSP_RUNTIME_CRASHED_ERROR = 911, + SNPE_DSP_BUFFER_SIZE_ERROR = 912, + SNPE_DSP_UDO_EXECUTE_ERROR = 913, + SNPE_DSP_UDO_LIB_NOT_REGISTERED_ERROR = 914, + SNPE_DSP_UDO_INVALID_QUANTIZATION_TYPE_ERROR = 915, + SNPE_DSP_RUNTIME_INVALID_RPC_DRIVER = 916, + SNPE_DSP_RUNTIME_RPC_PERMISSION_ERROR = 917, + SNPE_DSP_RUNTIME_DSP_FILE_OPEN_ERROR = 918, // Model validataion errors SNPE_MODEL_VALIDATION_LAYER_NOT_SUPPORTED = 1000, @@ -196,7 +205,10 @@ enum class ZDL_EXPORT ErrorCode : uint32_t { // Infrastructure Errors SNPE_INFRA_CLUSTERMGR_INSTANCE_INVALID = 1600, - SNPE_INFRA_CLUSTERMGR_EXECUTE_SYNC_FAILED = 1601 + SNPE_INFRA_CLUSTERMGR_EXECUTE_SYNC_FAILED = 1601, + + // Memory Errors + SNPE_MEMORY_CORRUPTION_ERROR = 1700 }; diff --git a/third_party/snpe/include/DlSystem/IOBufferDataTypeMap.hpp b/third_party/snpe/include/DlSystem/IOBufferDataTypeMap.hpp new file mode 100644 index 000000000..e36b1fbd7 --- /dev/null +++ b/third_party/snpe/include/DlSystem/IOBufferDataTypeMap.hpp @@ -0,0 +1,127 @@ +//============================================================================= +// +// Copyright (c) 2021-2022 Qualcomm Technologies, Inc. +// All Rights Reserved. +// Confidential and Proprietary - Qualcomm Technologies, Inc. +// +//============================================================================= + + +#ifndef DL_SYSTEM_IOBUFFER_DATATYPE_MAP_HPP +#define DL_SYSTEM_IOBUFFER_DATATYPE_MAP_HPP + +#include +#include +#include "DlSystem/DlEnums.hpp" + +namespace DlSystem +{ + // Forward declaration of IOBufferDataTypeMapImpl implementation. + class IOBufferDataTypeMapImpl; +} + +namespace zdl +{ +namespace DlSystem +{ +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * The IoBufferDataTypeMap class definition + */ +class ZDL_EXPORT IOBufferDataTypeMap final +{ +public: + + /** + * @brief . + * + * Creates a new Buffer Data type map + * + */ + IOBufferDataTypeMap(); + + /** + * @brief Adds a name and the corresponding buffer data type + * to the map + * + * @param[name] name The name of the buffer + * @param[bufferDataType] buffer Data Type of the buffer + * + * @note If a buffer with the same name already exists, no new + * buffer is added. + */ + void add(const char* name, zdl::DlSystem::IOBufferDataType_t bufferDataType); + + /** + * @brief Removes a buffer name from the map + * + * @param[name] name The name of the buffer + * + */ + void remove(const char* name); + + /** + * @brief Returns the type of the named buffer + * + * @param[name] name The name of the buffer + * + * @return The type of the buffer, or UNSPECIFIED if the buffer does not exist + * + */ + zdl::DlSystem::IOBufferDataType_t getBufferDataType(const char* name); + + /** + * @brief Returns the type of the first buffer + * + * @return The type of the first buffer, or UNSPECIFIED if the map is empty. + * + */ + zdl::DlSystem::IOBufferDataType_t getBufferDataType(); + + /** + * @brief Returns the size of the buffer type map. + * + * @return The size of the map + * + */ + size_t size(); + + /** + * @brief Checks the existence of the named buffer in the map + * + * @return True if the named buffer exists, false otherwise. + * + */ + bool find(const char* name); + + /** + * @brief Resets the map + * + */ + void clear(); + + /** + * @brief Checks whether the map is empty + * + * @return True if the map is empty, false otherwise. + * + */ + bool empty(); + + /** + * @brief Destroys the map + * + */ + ~IOBufferDataTypeMap(); + +private: + std::shared_ptr<::DlSystem::IOBufferDataTypeMapImpl> m_IOBufferDataTypeMapImpl; +}; +} + +} +#endif diff --git a/third_party/snpe/include/DlSystem/IUDL.hpp b/third_party/snpe/include/DlSystem/IUDL.hpp index 2e9dddc48..a171ac7e8 100644 --- a/third_party/snpe/include/DlSystem/IUDL.hpp +++ b/third_party/snpe/include/DlSystem/IUDL.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2016-2017 Qualcomm Technologies, Inc. +// Copyright (c) 2016-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -13,10 +13,10 @@ namespace zdl { namespace DlSystem { -/** @addtogroup c_plus_plus_apis C++ -@{ */ /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief . * * Base class user concrete UDL implementation. @@ -32,6 +32,8 @@ namespace DlSystem { class ZDL_EXPORT IUDL { public: /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief . * * Destructor @@ -39,6 +41,8 @@ public: virtual ~IUDL() = default; /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief Sets up the user's environment. * This is called by the SNPE framework to allow the user the * opportunity to setup anything which is needed for running @@ -66,6 +70,8 @@ public: size_t outsz, const size_t **outdim, const size_t *outdimsz) = 0; /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief Close the instance. Invoked by the SNPE * framework to allow the user the opportunity to release any resources * allocated during setup. @@ -75,6 +81,8 @@ public: virtual void close(void *cookie) noexcept = 0; /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief Execute the user defined layer * * @param cookie User provided opaque data returned by the SNPE @@ -89,7 +97,6 @@ public: */ virtual bool execute(void *cookie, const float **input, float **output) = 0; }; -/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ } // ns DlSystem diff --git a/third_party/snpe/include/DlSystem/IUserBuffer.hpp b/third_party/snpe/include/DlSystem/IUserBuffer.hpp index 5e5731dd8..ea491a545 100644 --- a/third_party/snpe/include/DlSystem/IUserBuffer.hpp +++ b/third_party/snpe/include/DlSystem/IUserBuffer.hpp @@ -151,101 +151,6 @@ public: * An encoding type where each element is represented by tf8, which is an * 8-bit quantizd value, which has an exact representation of 0.0 */ - -class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingUnsigned8Bit { -public: - UserBufferEncodingTf8() = delete; - UserBufferEncodingTf8(unsigned char stepFor0, float stepSize) : - UserBufferEncodingUnsigned8Bit(ElementType_t::TF8), - m_StepExactly0(stepFor0), - m_QuantizedStepSize(stepSize) {}; - - UserBufferEncodingTf8(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncodingUnsigned8Bit(ubEncoding.getElementType()){ - const zdl::DlSystem::UserBufferEncodingTf8* ubEncodingTf8 - = dynamic_cast (&ubEncoding); - if (ubEncodingTf8) { - m_StepExactly0 = ubEncodingTf8->getStepExactly0(); - m_QuantizedStepSize = ubEncodingTf8->getQuantizedStepSize(); - } - } - -/** - * @brief Sets the step value that represents 0 - * - * @param[in] stepExactly0 The step value that represents 0 - * - */ - - void setStepExactly0(const unsigned char stepExactly0) { - m_StepExactly0 = stepExactly0; - } - - -/** - * @brief Sets the float value that each step represents - * - * @param[in] quantizedStepSize The float value of each step size - * - */ - - void setQuantizedStepSize(const float quantizedStepSize) { - m_QuantizedStepSize = quantizedStepSize; - } - - -/** - * @brief Retrieves the step that represents 0.0 - * - * @return Step value - */ - - unsigned char getStepExactly0() const { - return m_StepExactly0; - } - - -/** - * Calculates the minimum floating point value that - * can be represented with this encoding. - * - * @return Minimum representable floating point value - */ - - float getMin() const { - return m_QuantizedStepSize * (0 - m_StepExactly0); - } - - -/** - * Calculates the maximum floating point value that - * can be represented with this encoding. - * - * @return Maximum representable floating point value - */ - - float getMax() const { - return m_QuantizedStepSize * (255 - m_StepExactly0); - } - - -/** - * @brief Retrieves the step size - * - * @return Step size - */ - - float getQuantizedStepSize() const { - return m_QuantizedStepSize; - } - -private: - unsigned char m_StepExactly0; - - float m_QuantizedStepSize; -}; - - - class ZDL_EXPORT UserBufferEncodingTfN : public UserBufferEncoding { public: UserBufferEncodingTfN() = delete; @@ -327,12 +232,44 @@ public: ElementType_t getTypeFromWidth(uint8_t width); uint8_t bitWidth; -private: +protected: uint64_t m_StepExactly0; float m_QuantizedStepSize; }; +class ZDL_EXPORT UserBufferEncodingTf8 : public UserBufferEncodingTfN { +public: + UserBufferEncodingTf8() = delete; + UserBufferEncodingTf8(unsigned char stepFor0, float stepSize) : + UserBufferEncodingTfN(stepFor0, stepSize) {}; + + UserBufferEncodingTf8(const zdl::DlSystem::UserBufferEncoding &ubEncoding) : UserBufferEncodingTfN(ubEncoding){} + +/** + * @brief Sets the step value that represents 0 + * + * @param[in] stepExactly0 The step value that represents 0 + * + */ + + void setStepExactly0(const unsigned char stepExactly0) { + UserBufferEncodingTfN::m_StepExactly0 = stepExactly0; + } + +/** + * @brief Retrieves the step that represents 0.0 + * + * @return Step value + */ + + unsigned char getStepExactly0() const { + return UserBufferEncodingTfN::m_StepExactly0; + } + +}; + + /** * @brief UserBuffer contains a pointer and info on how to walk it and interpret its content. */ diff --git a/third_party/snpe/include/DlSystem/PlatformConfig.hpp b/third_party/snpe/include/DlSystem/PlatformConfig.hpp index 3f15f177e..c7b85f43c 100644 --- a/third_party/snpe/include/DlSystem/PlatformConfig.hpp +++ b/third_party/snpe/include/DlSystem/PlatformConfig.hpp @@ -1,6 +1,6 @@ //============================================================================= // -// Copyright (c) 2017-2018 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2018,2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -190,10 +190,37 @@ public: */ std::string getPlatformOptions() const { return m_PlatformOptions; } + /** + * @brief Sets the platform options + * + * @param[in] optionName Name of platform options" + * @param[in] value Value of specified optionName + * + * @return If true, add "optionName:value" to platform options if optionName don't exist, otherwise update the + * value of specified optionName. + * If false, the platform options will not be changed. + */ + bool setPlatformOptionValue(const std::string& optionName, const std::string& value); + + /** + * @brief Removes the platform options + * + * @param[in] optionName Name of platform options" + * @param[in] value Value of specified optionName + * + * @return If true, removed "optionName:value" to platform options if optionName don't exist, do nothing. + * If false, the platform options will not be changed. + */ + bool removePlatformOptionValue(const std::string& optionName, const std::string& value); + + static void SetIsUserGLBuffer(bool isUserGLBuffer); + static bool GetIsUserGLBuffer(); + private: PlatformType_t m_PlatformType; PlatformConfigInfo m_PlatformConfigInfo; std::string m_PlatformOptions; + static bool m_IsUserGLBuffer; }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/third_party/snpe/include/DlSystem/UDLContext.hpp b/third_party/snpe/include/DlSystem/UDLContext.hpp index 6b7c07d3e..21fce1b04 100644 --- a/third_party/snpe/include/DlSystem/UDLContext.hpp +++ b/third_party/snpe/include/DlSystem/UDLContext.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2016 Qualcomm Technologies, Inc. +// Copyright (c) 2016-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -15,10 +15,10 @@ #include "ZdlExportDefine.hpp" namespace zdl { namespace DlSystem { -/** @addtogroup c_plus_plus_apis C++ -@{ */ /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief . * * UDLContext holds the user defined layer context which @@ -237,7 +237,6 @@ private: size_t m_Size = 0; int32_t m_Id = -1; }; -/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ }} diff --git a/third_party/snpe/include/DlSystem/UDLFunc.hpp b/third_party/snpe/include/DlSystem/UDLFunc.hpp index 633ce985b..6a95eef17 100644 --- a/third_party/snpe/include/DlSystem/UDLFunc.hpp +++ b/third_party/snpe/include/DlSystem/UDLFunc.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2015 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -21,9 +21,9 @@ namespace zdl { } namespace zdl { namespace DlSystem { -/** @addtogroup c_plus_plus_apis C++ -@{ */ /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief . * * Definition of UDLFactoyFunc, using/typedef and default FactoryFunction @@ -47,6 +47,8 @@ namespace zdl { namespace DlSystem { using UDLFactoryFunc = std::function; /** + * NOTE: DEPRECATED, MAY BE REMOVED IN THE FUTURE. + * * @brief . * * default UDL factory implementation @@ -65,6 +67,8 @@ using UDLFactoryFunc = std::function +#include "ZdlExportDefine.hpp" +#include "StringList.hpp" + +#ifndef DL_SYSTEM_USER_MEMORY_MAP_HPP +#define DL_SYSTEM_USER_MEMORY_MAP_HPP + +namespace DlSystem +{ + // Forward declaration of UserMemory map implementation. + class UserMemoryMapImpl; +} + +namespace zdl +{ +namespace DlSystem +{ +class IUserBuffer; + +/** @addtogroup c_plus_plus_apis C++ +@{ */ + +/** + * @brief . + * + * A class representing the map of UserMemory. + */ +class ZDL_EXPORT UserMemoryMap final +{ +public: + + /** + * @brief . + * + * Creates a new empty UserMemory map + */ + UserMemoryMap(); + + /** + * copy constructor. + * @param[in] other object to copy. + */ + UserMemoryMap(const UserMemoryMap& other); + + /** + * assignment operator. + */ + UserMemoryMap& operator=(const UserMemoryMap& other); + + /** + * @brief Adds a name and the corresponding buffer address + * to the map + * + * @param[in] name The name of the UserMemory + * @param[in] address The pointer to the Buffer Memory + * + * @note If a UserBuffer with the same name already exists, the new + * address would be updated. + */ + void add(const char *name, void *address); + + /** + * @brief Removes a mapping of one Buffer address and its name by its name + * + * @param[in] name The name of Memory address to be removed + * + * @note If no UserBuffer with the specified name is found, nothing + * is done. + */ + void remove(const char *name) noexcept; + + /** + * @brief Returns the number of User Memory addresses in the map + */ + size_t size() const noexcept; + + /** + * @brief . + * + * Removes all User Memory from the map + */ + void clear() noexcept; + + /** + * @brief . + * + * Returns the names of all User Memory + * + * @return A list of Buffer names. + */ + zdl::DlSystem::StringList getUserBufferNames() const; + + /** + * @brief Returns the no of UserMemory addresses mapped to the buffer + * + * @param[in] name The name of the UserMemory + * + */ + size_t getUserMemoryAddressCount(const char *name) const noexcept; + + /** + * @brief Returns address at a specified index corresponding to a UserMemory buffer name + * + * @param[in] name The name of the buffer + * @param[in] index The index in the list of addresses + * + */ + void* getUserMemoryAddressAtIndex(const char *name, uint32_t index) const noexcept; + + ~UserMemoryMap(); +private: + void swap(const UserMemoryMap &other); + std::unique_ptr<::DlSystem::UserMemoryMapImpl> m_UserMemoryMapImpl; +}; +/** @} */ /* end_addtogroup c_plus_plus_apis C++ */ + +} // DlSystem namespace +} // zdl namespace + + +#endif // DL_SYSTEM_TENSOR_MAP_HPP + diff --git a/third_party/snpe/include/PlatformValidator/PlatformValidator.hpp b/third_party/snpe/include/PlatformValidator/PlatformValidator.hpp index e74278ead..66097ba56 100644 --- a/third_party/snpe/include/PlatformValidator/PlatformValidator.hpp +++ b/third_party/snpe/include/PlatformValidator/PlatformValidator.hpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2018-2019 Qualcomm Technologies, Inc. +// Copyright (c) 2018-2020 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -10,7 +10,32 @@ #define SNPE_PLATFORMVALIDATOR_HPP #include "DlSystem/DlEnums.hpp" -#include "DlSystem/DlMacros.hpp" +#include "DlSystem/ZdlExportDefine.hpp" + +#define DO_PRAGMA(s) _Pragma(#s) +#define NO_WARNING "-Wunused-variable" + +#ifdef __clang__ +#define SNPE_DISABLE_WARNINGS(clang_warning,gcc_warning) \ +_Pragma("clang diagnostic push") \ +DO_PRAGMA(clang diagnostic ignored clang_warning) + +#define SNPE_ENABLE_WARNINGS \ +_Pragma("clang diagnostic pop") + +#elif defined __GNUC__ +#define SNPE_DISABLE_WARNINGS(clang_warning,gcc_warning) \ +_Pragma("GCC diagnostic push") \ +DO_PRAGMA(GCC diagnostic ignored gcc_warning) + +#define SNPE_ENABLE_WARNINGS \ +_Pragma("GCC diagnostic pop") + +#else +#define SNPE_DISABLE_WARNINGS(...) +#define SNPE_ENABLE_WARNINGS +#endif + SNPE_DISABLE_WARNINGS("-Wdelete-non-virtual-dtor","-Wdelete-non-virtual-dtor") #include #include @@ -34,7 +59,7 @@ namespace zdl * */ -class zdl::SNPE::PlatformValidator +class ZDL_EXPORT zdl::SNPE::PlatformValidator { public: /** diff --git a/third_party/snpe/include/SNPE/PSNPE.hpp b/third_party/snpe/include/SNPE/PSNPE.hpp index c0a6fb55d..a823c0c7f 100644 --- a/third_party/snpe/include/SNPE/PSNPE.hpp +++ b/third_party/snpe/include/SNPE/PSNPE.hpp @@ -1,6 +1,6 @@ // ============================================================================= // -// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2019-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -54,8 +54,9 @@ struct ZDL_EXPORT OutputAsyncCallbackParam { size_t dataIndex; bool executeStatus; - OutputAsyncCallbackParam(size_t _index,bool _status) - : dataIndex(_index),executeStatus(_status){}; + std::string errorMsg; + OutputAsyncCallbackParam(size_t _index,bool _status, const std::string& _errorMsg = std::string()) + : dataIndex(_index),executeStatus(_status), errorMsg(_errorMsg){}; }; /** * @brief A structure representing parameters of callback function of Async Input/Output mode @@ -65,12 +66,13 @@ struct ZDL_EXPORT InputOutputAsyncCallbackParam size_t dataIndex; const ApplicationBufferMap& outputMap; bool executeStatus; - InputOutputAsyncCallbackParam(size_t _index, const ApplicationBufferMap& output_map,bool _status) + std::string errorMsg; + InputOutputAsyncCallbackParam(size_t _index, const ApplicationBufferMap& output_map,bool _status, + const std::string _ErrorMsg = std::string()) : dataIndex(_index) , outputMap(output_map) - ,executeStatus(_status){ - - }; + , executeStatus(_status) + , errorMsg(_ErrorMsg){}; }; /** * @brief This callback is called when the output data is ready, only use for Output Async mode @@ -96,6 +98,7 @@ struct ZDL_EXPORT BuildConfig final BuildMode buildMode = BuildMode::SERIAL; ///< Specify build in serial mode or parallel mode zdl::DlContainer::IDlContainer* container;///< The opened container ptr zdl::DlSystem::StringList outputBufferNames;///< Specify the output layer name + zdl::DlSystem::StringList outputTensors;///< Specify the output layer name RuntimeConfigList runtimeConfigList;///< The runtime config list for PSNPE, @see RuntimeConfig size_t inputThreadNumbers = 1;///< Specify the number of threads used in the execution phase to process input data, only used in inputOutputAsync mode size_t outputThreadNumbers = 1;///< Specify the number of threads used in the execution phase to process output data, only used in inputOutputAsync and outputAsync mode @@ -106,6 +109,8 @@ struct ZDL_EXPORT BuildConfig final zdl::DlSystem::ProfilingLevel_t profilingLevel = zdl::DlSystem::ProfilingLevel_t::OFF;///< Specify profiling level for Diaglog uint64_t encode[2] = {0, 0}; bool enableInitCache = false; + std::string platformOptions; + std::string diaglogOutputDir = "./diaglogs/"; ///< Specify a diaglog output directory to save the generated Diaglog files. }; /** * @brief . @@ -170,6 +175,8 @@ class ZDL_EXPORT PSNPE final */ const zdl::DlSystem::TensorShape getInputDimensions() const noexcept; + const zdl::DlSystem::TensorShape getInputDimensions(const char *name) const noexcept; + /** * @brief Returns attributes of buffers. * @@ -180,6 +187,10 @@ class ZDL_EXPORT PSNPE final const zdl::DlSystem::TensorShape getBufferAttributesDims(const char *name) const noexcept; zdl::DlSystem::Optional getInputOutputBufferAttributes(const char *name) const noexcept; + bool registerIonBuffers(const zdl::DlSystem::UserMemoryMap& ionBufferMap) const noexcept; + bool deregisterIonBuffers(const zdl::DlSystem::StringList& ionBufferNames) const noexcept; + + const char* getLastErrorString(); private: PSNPE(const PSNPE&) = delete; diff --git a/third_party/snpe/include/SNPE/SNPE.hpp b/third_party/snpe/include/SNPE/SNPE.hpp index 239690ab2..5ab45b82e 100644 --- a/third_party/snpe/include/SNPE/SNPE.hpp +++ b/third_party/snpe/include/SNPE/SNPE.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -19,6 +19,7 @@ #include "DlSystem/StringList.hpp" #include "DlSystem/IUserBuffer.hpp" #include "DlSystem/UserBufferMap.hpp" +#include "DlSystem/UserMemoryMap.hpp" #include "DlSystem/ZdlExportDefine.hpp" namespace zdl { @@ -147,6 +148,21 @@ public: bool execute(const zdl::DlSystem::UserBufferMap &input, const zdl::DlSystem::UserBufferMap &output) noexcept; + + /** + * @brief Regiter Client ION Buffers + * @param[in] A UserMemoryMap of virtual addresses + * + */ + bool registerIonBuffers(const zdl::DlSystem::UserMemoryMap& ionBufferMap) noexcept; + + /** + * @brief Regiter Client ION Buffers + * @param[in] A StringList of ION Buffer names + * + */ + bool deregisterIonBuffers(const zdl::DlSystem::StringList& ionBufferNames) noexcept; + /** * @brief Returns the version string embedded at model conversion * time. @@ -215,8 +231,6 @@ public: */ zdl::DlSystem::Optional getInputOutputBufferAttributes(const char *name) const noexcept; - zdl::DlSystem::Optional getInputOutputBufferAttributesTf8(const char *name) const noexcept; - /** * @brief . * diff --git a/third_party/snpe/include/SNPE/SNPEBuilder.hpp b/third_party/snpe/include/SNPE/SNPEBuilder.hpp index f314d88bc..5fc7846ce 100644 --- a/third_party/snpe/include/SNPE/SNPEBuilder.hpp +++ b/third_party/snpe/include/SNPE/SNPEBuilder.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2017-2019 Qualcomm Technologies, Inc. +// Copyright (c) 2017-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -15,6 +15,7 @@ #include "DlSystem/DlOptional.hpp" #include "DlSystem/TensorShapeMap.hpp" #include "DlSystem/PlatformConfig.hpp" +#include "DlSystem/IOBufferDataTypeMap.hpp" #include "DlSystem/RuntimeList.hpp" namespace zdl { @@ -275,6 +276,28 @@ public: SNPEBuilder& setUnconsumedTensorsAsOutputs( bool setOutput); + /** + * @brief Execution terminated when exceeding time limit. + * Only valid for dsp runtime currently. + * + * @param[in] timeout Time limit value + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setTimeOut( + uint64_t timeout); + + + /** + * @brief Sets the datatype of the buffer. + * Only valid for dsp runtime currently. + * + * @param[in] Map of the buffer names and the datatype that needs to be set. + * + * @return The current instance of SNPEBuilder. + */ + SNPEBuilder& setBufferDataType(const zdl::DlSystem::IOBufferDataTypeMap& dataTypeMap); + }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/third_party/snpe/include/SNPE/SNPEFactory.hpp b/third_party/snpe/include/SNPE/SNPEFactory.hpp index 7bef45d87..2d78e81b1 100644 --- a/third_party/snpe/include/SNPE/SNPEFactory.hpp +++ b/third_party/snpe/include/SNPE/SNPEFactory.hpp @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2015-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2015-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -47,8 +47,6 @@ public: * * @param[in] runtime The target runtime to check. * - * @param[in] option Extent to perform runtime available check. - * * @return True if the supplied runtime is available; false, * otherwise. */ @@ -122,6 +120,97 @@ public: * otherwise. */ static bool isGLCLInteropSupported(); + + static const char* getLastError(); + + /** + * Initializes logging with the specified log level. + * initializeLogging with level, is used on Android platforms + * and after successful initialization, SNPE + * logs are printed in android logcat logs. + * + * It is recommended to initializeLogging before creating any + * SNPE instances, in order to capture information related to + * core initialization. If this is called again after first + * time initialization, subsequent calls are ignored. + * Also, Logging can be re-initialized after a call to + * terminateLogging API by calling initializeLogging again. + * + * A typical usage of Logging life cycle can be + * initializeLogging() + * any other SNPE API like isRuntimeAvailable() + * * setLogLevel() - optional - can be called anytime + * between initializeLogging & terminateLogging + * SNPE instance creation, inference, destroy + * terminateLogging(). + * + * Please note, enabling logging can have performance impact. + * + * @param[in] LogLevel_t Log level (LOG_INFO, LOG_WARN, etc.). + * + * @return True if successful, False otherwise. + */ + static bool initializeLogging(const zdl::DlSystem::LogLevel_t& level); + + /** + * Initializes logging with the specified log level and log path. + * initializeLogging with level & log path, is used on non Android + * platforms and after successful initialization, SNPE + * logs are printed in std output & into log files created in the + * log path. + * + * It is recommended to initializeLogging before creating any + * SNPE instances, in order to capture information related to + * core initialization. If this is called again after first + * time initialization, subsequent calls are ignored. + * Also, Logging can be re-initialized after a call to + * terminateLogging API by calling initializeLogging again. + * + * A typical usage of Logging life cycle can be + * initializeLogging() + * any other SNPE API like isRuntimeAvailable() + * * setLogLevel() - optional - can be called anytime + * between initializeLogging & terminateLogging + * SNPE instance creation, inference, destroy + * terminateLogging() + * + * Please note, enabling logging can have performance impact + * + * @param[in] LogLevel_t Log level (LOG_INFO, LOG_WARN, etc.). + * + * @param[in] Path of directory to store logs. + * If path is empty, the default path is "./Log". + * For android, the log path is ignored. + * + * @return True if successful, False otherwise. + */ + static bool initializeLogging(const zdl::DlSystem::LogLevel_t& level, const std::string& logPath); + + /** + * Updates the current logging level with the specified level. + * setLogLevel is optional, called anytime after initializeLogging + * and before terminateLogging, to update the log level set. + * Log levels can be updated multiple times by calling setLogLevel + * A call to setLogLevel() is ignored if it is made before + * initializeLogging() or after terminateLogging() + * + * @param[in] LogLevel_t Log level (LOG_INFO, LOG_WARN, etc.). + * + * @return True if successful, False otherwise. + */ + static bool setLogLevel(const zdl::DlSystem::LogLevel_t& level); + + /** + * Terminates logging. + * + * It is recommended to terminateLogging after initializeLogging + * in order to disable logging information. + * If this is called before initialization or after first time termination, + * calls are ignored. + * + * @return True if successful, False otherwise. + */ + static bool terminateLogging(void); }; /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ diff --git a/third_party/snpe/include/SnpeUdo/UdoBase.h b/third_party/snpe/include/SnpeUdo/UdoBase.h index be370e1ac..7b2567920 100644 --- a/third_party/snpe/include/SnpeUdo/UdoBase.h +++ b/third_party/snpe/include/SnpeUdo/UdoBase.h @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2019-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -13,7 +13,7 @@ // Provide values to use for API version. #define API_VERSION_MAJOR 1 -#define API_VERSION_MINOR 5 +#define API_VERSION_MINOR 6 #define API_VERSION_TEENY 0 /** @addtogroup c_plus_plus_apis C++ @@ -21,10 +21,12 @@ // Defines a bitmask of enum values. typedef uint32_t SnpeUdo_Bitmask_t; +typedef SnpeUdo_Bitmask_t Udo_Bitmask_t; // A string of characters, rather than an array of bytes. // Assumed to be UTF-8. typedef char* SnpeUdo_String_t; +typedef SnpeUdo_String_t Udo_String_t; // The maximum allowable length of a SnpeUdo_String_t in bytes, // including null terminator. SNPE will truncate strings longer @@ -41,32 +43,34 @@ typedef char* SnpeUdo_String_t; typedef enum { /// No Error - SNPE_UDO_NO_ERROR = 0, + SNPE_UDO_NO_ERROR = 0, UDO_NO_ERROR = 0, /// Unsupported value for core type - SNPE_UDO_WRONG_CORE = 1, + SNPE_UDO_WRONG_CORE = 1, UDO_WRONG_CORE = 1, /// Invalid attribute/argument passed into UDO API - SNPE_UDO_INVALID_ARGUMENT = 2, + SNPE_UDO_INVALID_ARGUMENT = 2, UDO_INVALID_ARGUMENT = 2, /// Unsupported feature error - SNPE_UDO_UNSUPPORTED_FEATURE = 3, + SNPE_UDO_UNSUPPORTED_FEATURE = 3, UDO_UNSUPPORTED_FEATURE = 3, /// Error relating to memory allocation - SNPE_UDO_MEM_ALLOC_ERROR = 4, + SNPE_UDO_MEM_ALLOC_ERROR = 4, UDO_MEM_ALLOC_ERROR = 4, /* Configuration Specific errors */ /// No op with given attributes available in library - SNPE_UDO_WRONG_OPERATION = 100, + SNPE_UDO_WRONG_OPERATION = 100, UDO_WRONG_OPERATION = 100, /// Unsupported value for core type in UDO configuration - SNPE_UDO_WRONG_CORE_TYPE = 101, + SNPE_UDO_WRONG_CORE_TYPE = 101, UDO_WRONG_CORE_TYPE = 101, /// Wrong number of params in UDO definition - SNPE_UDO_WRONG_NUM_OF_PARAMS = 102, + SNPE_UDO_WRONG_NUM_OF_PARAMS = 102, UDO_WRONG_NUM_OF_PARAMS = 102, /// Wrong number of dimensions for tensor(s) in UDO definition - SNPE_UDO_WRONG_NUM_OF_DIMENSIONS = 103, + SNPE_UDO_WRONG_NUM_OF_DIMENSIONS = 103, UDO_WRONG_NUM_OF_DIMENSIONS = 103, /// Wrong number of input tensors in UDO definition - SNPE_UDO_WRONG_NUM_OF_INPUTS = 104, + SNPE_UDO_WRONG_NUM_OF_INPUTS = 104, UDO_WRONG_NUM_OF_INPUTS = 104, /// Wrong number of output tensors in UDO definition - SNPE_UDO_WRONG_NUM_OF_OUTPUTS = 105, - SNPE_UDO_PROGRAM_CACHE_NOT_FOUND = 106, - SNPE_UDO_UNKNOWN_ERROR = 0xFFFFFFFF + SNPE_UDO_WRONG_NUM_OF_OUTPUTS = 105, UDO_WRONG_NUM_OF_OUTPUTS = 105, + SNPE_UDO_PROGRAM_CACHE_NOT_FOUND = 106, UDO_PROGRAM_CACHE_NOT_FOUND = 106, + SNPE_UDO_UNKNOWN_ERROR = 0xFFFFFFFF, UDO_UNKNOWN_ERROR = 0xFFFFFFFF } SnpeUdo_ErrorType_t; +typedef SnpeUdo_ErrorType_t Udo_ErrorType_t; + /** * An enum which holds the various data types. * Designed to be used as single values or combined into a bitfield parameter @@ -77,32 +81,34 @@ typedef enum typedef enum { /// data type: 16-bit floating point - SNPE_UDO_DATATYPE_FLOAT_16 = 0x01, + SNPE_UDO_DATATYPE_FLOAT_16 = 0x01, UDO_DATATYPE_FLOAT_16 = 0x01, /// data type: 32-bit floating point - SNPE_UDO_DATATYPE_FLOAT_32 = 0x02, + SNPE_UDO_DATATYPE_FLOAT_32 = 0x02, UDO_DATATYPE_FLOAT_32 = 0x02, /// data type: 4-bit fixed point - SNPE_UDO_DATATYPE_FIXED_4 = 0x04, + SNPE_UDO_DATATYPE_FIXED_4 = 0x04, UDO_DATATYPE_FIXED_4 = 0x04, /// data type: 8-bit fixed point - SNPE_UDO_DATATYPE_FIXED_8 = 0x08, + SNPE_UDO_DATATYPE_FIXED_8 = 0x08, UDO_DATATYPE_FIXED_8 = 0x08, /// data type: 16-bit fixed point - SNPE_UDO_DATATYPE_FIXED_16 = 0x10, + SNPE_UDO_DATATYPE_FIXED_16 = 0x10, UDO_DATATYPE_FIXED_16 = 0x10, /// data type: 32-bit fixed point - SNPE_UDO_DATATYPE_FIXED_32 = 0x20, + SNPE_UDO_DATATYPE_FIXED_32 = 0x20, UDO_DATATYPE_FIXED_32 = 0x20, /// data type: 8-bit unsigned integer - SNPE_UDO_DATATYPE_UINT_8 = 0x100, + SNPE_UDO_DATATYPE_UINT_8 = 0x100, UDO_DATATYPE_UINT_8 = 0x100, /// data type: 16-bit unsigned integer - SNPE_UDO_DATATYPE_UINT_16 = 0x200, + SNPE_UDO_DATATYPE_UINT_16 = 0x200, UDO_DATATYPE_UINT_16 = 0x200, /// data type: 32-bit unsigned integer - SNPE_UDO_DATATYPE_UINT_32 = 0x400, + SNPE_UDO_DATATYPE_UINT_32 = 0x400, UDO_DATATYPE_UINT_32 = 0x400, /// data type: 8-bit signed integer - SNPE_UDO_DATATYPE_INT_8 = 0x1000, + SNPE_UDO_DATATYPE_INT_8 = 0x1000, UDO_DATATYPE_INT_8 = 0x1000, /// data type: 16-bit signed integer - SNPE_UDO_DATATYPE_INT_16 = 0x2000, + SNPE_UDO_DATATYPE_INT_16 = 0x2000, UDO_DATATYPE_INT_16 = 0x2000, /// data type: 32-bit signed integer - SNPE_UDO_DATATYPE_INT_32 = 0x4000, - SNPE_UDO_DATATYPE_LAST = 0xFFFFFFFF + SNPE_UDO_DATATYPE_INT_32 = 0x4000, UDO_DATATYPE_INT_32 = 0x4000, + SNPE_UDO_DATATYPE_LAST = 0xFFFFFFFF, UDO_DATATYPE_LAST = 0xFFFFFFFF } SnpeUdo_DataType_t; +typedef SnpeUdo_DataType_t Udo_DataType_t; + /** * An enum which holds the various layouts. * Designed to be used as single values or combined into a bitfield parameter @@ -111,21 +117,23 @@ typedef enum typedef enum { /// data layout (4D): NHWC (batch-height-width-channel) - SNPE_UDO_LAYOUT_NHWC = 0x01, + SNPE_UDO_LAYOUT_NHWC = 0x01, UDO_LAYOUT_NHWC = 0x01, /// data layout (4D): NCHW (batch-channel-height-width) - SNPE_UDO_LAYOUT_NCHW = 0x02, + SNPE_UDO_LAYOUT_NCHW = 0x02, UDO_LAYOUT_NCHW = 0x02, /// data layout (5D): NDHWC (batch-dimension-height-width-channel) - SNPE_UDO_LAYOUT_NDHWC = 0x04, - SNPE_UDO_LAYOUT_GPU_OPTIMAL1 = 0x08, - SNPE_UDO_LAYOUT_GPU_OPTIMAL2 = 0x10, - SNPE_UDO_LAYOUT_DSP_OPTIMAL1 = 0x11, - SNPE_UDO_LAYOUT_DSP_OPTIMAL2 = 0x12, + SNPE_UDO_LAYOUT_NDHWC = 0x04, UDO_LAYOUT_NDHWC = 0x04, + SNPE_UDO_LAYOUT_GPU_OPTIMAL1 = 0x08, UDO_LAYOUT_GPU_OPTIMAL1 = 0x08, + SNPE_UDO_LAYOUT_GPU_OPTIMAL2 = 0x10, UDO_LAYOUT_GPU_OPTIMAL2 = 0x10, + SNPE_UDO_LAYOUT_DSP_OPTIMAL1 = 0x11, UDO_LAYOUT_DSP_OPTIMAL1 = 0x11, + SNPE_UDO_LAYOUT_DSP_OPTIMAL2 = 0x12, UDO_LAYOUT_DSP_OPTIMAL2 = 0x12, // Indicates no data will be allocated for this tensor. // Used to specify optional inputs/outputs positionally. - SNPE_UDO_LAYOUT_NULL = 0x13, - SNPE_UDO_LAYOUT_LAST = 0xFFFFFFFF + SNPE_UDO_LAYOUT_NULL = 0x13, UDO_LAYOUT_NULL = 0x13, + SNPE_UDO_LAYOUT_LAST = 0xFFFFFFFF, UDO_LAYOUT_LAST = 0xFFFFFFFF } SnpeUdo_TensorLayout_t; +typedef SnpeUdo_TensorLayout_t Udo_TensorLayout_t; + /** * An enum which holds the UDO library Core type . * Designed to be used as single values or combined into a bitfield parameter @@ -134,43 +142,49 @@ typedef enum typedef enum { /// Library target IP Core is undefined - SNPE_UDO_CORETYPE_UNDEFINED = 0x00, + SNPE_UDO_CORETYPE_UNDEFINED = 0x00, UDO_CORETYPE_UNDEFINED = 0x00, /// Library target IP Core is CPU - SNPE_UDO_CORETYPE_CPU = 0x01, + SNPE_UDO_CORETYPE_CPU = 0x01, UDO_CORETYPE_CPU = 0x01, /// Library target IP Core is GPU - SNPE_UDO_CORETYPE_GPU = 0x02, + SNPE_UDO_CORETYPE_GPU = 0x02, UDO_CORETYPE_GPU = 0x02, /// Library target IP Core is DSP - SNPE_UDO_CORETYPE_DSP = 0x04, - SNPE_UDO_CORETYPE_LAST = 0xFFFFFFFF + SNPE_UDO_CORETYPE_DSP = 0x04, UDO_CORETYPE_DSP = 0x04, + SNPE_UDO_CORETYPE_LAST = 0xFFFFFFFF, UDO_CORETYPE_LAST = 0xFFFFFFFF } SnpeUdo_CoreType_t; +typedef SnpeUdo_CoreType_t Udo_CoreType_t; + /** * An enum to specify the parameter type : Scalar or Tensor */ typedef enum { /// UDO static param type: scalar - SNPE_UDO_PARAMTYPE_SCALAR, + SNPE_UDO_PARAMTYPE_SCALAR = 0x00, UDO_PARAMTYPE_SCALAR = 0x00, /// UDO static param type: string - SNPE_UDO_PARAMTYPE_STRING, + SNPE_UDO_PARAMTYPE_STRING = 0x01, UDO_PARAMTYPE_STRING = 0x01, /// UDO static param type: tensor - SNPE_UDO_PARAMTYPE_TENSOR, - SNPE_UDO_PARAMTYPE_LAST = 0xFFFFFFFF + SNPE_UDO_PARAMTYPE_TENSOR = 0x02, UDO_PARAMTYPE_TENSOR = 0x02, + SNPE_UDO_PARAMTYPE_LAST = 0xFFFFFFFF, UDO_PARAMTYPE_LAST = 0xFFFFFFFF } SnpeUdo_ParamType_t; +typedef SnpeUdo_ParamType_t Udo_ParamType_t; + /** * An enum to specify quantization type */ typedef enum { /// Tensor Quantization type: NONE. Signifies unquantized tensor data - SNPE_UDO_QUANTIZATION_NONE, + SNPE_UDO_QUANTIZATION_NONE = 0x00, UDO_QUANTIZATION_NONE = 0x00, /// Tensor Quantization type: Tensorflow-style - SNPE_UDO_QUANTIZATION_TF, - SNPE_UDO_QUANTIZATION_QMN, - SNPE_UDO_QUANTIZATION_LAST = 0xFFFFFFFF + SNPE_UDO_QUANTIZATION_TF = 0x01, UDO_QUANTIZATION_TF = 0x01, + SNPE_UDO_QUANTIZATION_QMN = 0x02, UDO_QUANTIZATION_QMN = 0x02, + SNPE_UDO_QUANTIZATION_LAST = 0xFFFFFFFF, UDO_QUANTIZATION_LAST = 0xFFFFFFFF } SnpeUdo_QuantizationType_t; +typedef SnpeUdo_QuantizationType_t Udo_QuantizationType_t; + /** * @brief A struct which is used to provide a version number using 3 values : major, minor, teeny * @@ -185,6 +199,8 @@ typedef struct uint32_t teeny; } SnpeUdo_Version_t; +typedef SnpeUdo_Version_t Udo_Version_t; + /** * @brief A struct returned from version query, contains the Library version and API version * @@ -197,6 +213,16 @@ typedef struct SnpeUdo_Version_t apiVersion; } SnpeUdo_LibVersion_t; +/** + * @brief A struct returned from version query, contains the package version + * + */ +typedef struct +{ + /// Version of UDO API used in package. + Udo_Version_t apiVersion; +} Udo_PkgVersion_t; + /** * @brief A union to hold the value of a generic type. Allows defining a parameter struct * in a generic way, with a "value" location that holds the data regardless of the type. @@ -220,6 +246,8 @@ typedef union int8_t int8Value; } SnpeUdo_Value_t; +typedef SnpeUdo_Value_t Udo_Value_t; + /** * @brief A struct which defines a scalar parameter : name, data type, and union of values * @@ -232,6 +260,8 @@ typedef struct SnpeUdo_Value_t dataValue; } SnpeUdo_ScalarParam_t; +typedef SnpeUdo_ScalarParam_t Udo_ScalarParam_t; + /** * @brief A struct which defines the quantization parameters in case of Tensorflow style quantization * @@ -244,6 +274,8 @@ typedef struct float maxValue; } SnpeUdo_TFQuantize_t; +typedef SnpeUdo_TFQuantize_t Udo_TFQuantize_t; + /** * @brief A struct which defines the quantization type, and union of supported quantization structs * @@ -259,6 +291,8 @@ typedef struct }; } SnpeUdo_QuantizeParams_t; +typedef SnpeUdo_QuantizeParams_t Udo_QuantizeParams_t; + /** * @brief A struct which defines the datatype associated with a specified core-type * This should be used to denote the datatypes for a single tensor info, depending @@ -273,6 +307,8 @@ typedef struct SnpeUdo_DataType_t dataType; } SnpeUdo_PerCoreDatatype_t; +typedef SnpeUdo_PerCoreDatatype_t Udo_PerCoreDatatype_t; + /** * @brief A struct which defines a tensor parameter : name, data type, layout, quantization, more. * Also holds a pointer to the tensor data. @@ -303,6 +339,8 @@ typedef struct void* tensorData; } SnpeUdo_TensorParam_t; +typedef SnpeUdo_TensorParam_t Udo_TensorParam_t; + /** * @brief A struct which defines tensor information for activation tensors only * @@ -321,9 +359,11 @@ typedef struct SnpeUdo_PerCoreDatatype_t* perCoreDatatype; /// A boolean field indicating that this tensorinfo will be repeated e.x for ops such as Concat or Split bool repeated; - + /// A boolean field indicating whether input is static or not. + bool isStatic; } SnpeUdo_TensorInfo_t; +typedef SnpeUdo_TensorInfo_t Udo_TensorInfo_t; /** * @brief struct which defines a UDO parameter - a union of scalar, tensor and string parameters @@ -346,6 +386,8 @@ typedef struct }; } SnpeUdo_Param_t; +typedef SnpeUdo_Param_t Udo_Param_t; + /** * @brief A struct which defines Operation information which is specific for IP core (CPU, GPU, DSP ...) * @@ -359,6 +401,8 @@ typedef struct SnpeUdo_Bitmask_t operationCalculationTypes; } SnpeUdo_OpCoreInfo_t; +typedef SnpeUdo_OpCoreInfo_t Udo_OpCoreInfo_t; + /** * @brief A struct which defines the common and core-specific Operation information * @@ -392,6 +436,8 @@ typedef struct SnpeUdo_TensorInfo_t* outputInfos; } SnpeUdo_OperationInfo_t; +typedef SnpeUdo_OperationInfo_t Udo_OperationInfo_t; + /** * @brief A struct which provides the implementation library info : type, name * @@ -404,6 +450,8 @@ typedef struct SnpeUdo_String_t libraryName; } SnpeUdo_LibraryInfo_t; +typedef SnpeUdo_LibraryInfo_t Udo_LibraryInfo_t; + /** * @brief A struct returned by the registration library and contains information on the UDO package : * name, operations, libraries, etc. @@ -429,6 +477,8 @@ typedef struct SnpeUdo_OperationInfo_t* operationsInfo; } SnpeUdo_RegInfo_t; +typedef SnpeUdo_RegInfo_t Udo_RegInfo_t; + /** * @brief A struct returned by the implementation library and contains information on the * specific library: name, IP Core, operations, etc. @@ -446,6 +496,8 @@ typedef struct uint32_t numOfOperations; } SnpeUdo_ImpInfo_t; +typedef SnpeUdo_ImpInfo_t Udo_ImpInfo_t; + /** * @brief This struct defines an operation. It is used for validation * or creation of an operation. @@ -478,6 +530,8 @@ typedef struct SnpeUdo_TensorParam_t* outputs; } SnpeUdo_OpDefinition_t; +typedef SnpeUdo_OpDefinition_t Udo_OpDefinition_t; + /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif //SNPE_UDO_BASE_H diff --git a/third_party/snpe/include/SnpeUdo/UdoImpl.h b/third_party/snpe/include/SnpeUdo/UdoImpl.h index bd29bc251..a0cb648cf 100644 --- a/third_party/snpe/include/SnpeUdo/UdoImpl.h +++ b/third_party/snpe/include/SnpeUdo/UdoImpl.h @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2019-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -24,6 +24,9 @@ extern "C" typedef struct _SnpeUdo_OpFactory_t* SnpeUdo_OpFactory_t; typedef struct _SnpeUdo_Operation_t* SnpeUdo_Operation_t; +typedef SnpeUdo_OpFactory_t Udo_OpFactory_t; +typedef SnpeUdo_Operation_t Udo_Operation_t; + /** * @brief Initialize the shared library's data structures. Calling any other * library function before this one will result in error. @@ -92,6 +95,8 @@ SnpeUdo_getImpInfo(SnpeUdo_ImpInfo_t** implementationInfo); typedef SnpeUdo_ErrorType_t (*SnpeUdo_GetImpInfoFunction_t)(SnpeUdo_ImpInfo_t** implementationInfo); +typedef SnpeUdo_GetImpInfoFunction_t Udo_GetImpInfoFunction_t; + /** * @brief A function to create an operation factory. * The function receives the operation type, and an array of static parameters, @@ -130,6 +135,7 @@ typedef SnpeUdo_ErrorType_t SnpeUdo_Param_t*, SnpeUdo_OpFactory_t*); +typedef SnpeUdo_CreateOpFactoryFunction_t Udo_CreateOpFactoryFunction_t; /** * @brief A function to release the resources allocated for an operation factory @@ -145,6 +151,8 @@ SnpeUdo_releaseOpFactory(SnpeUdo_OpFactory_t opFactory); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ReleaseOpFactoryFunction_t)(SnpeUdo_OpFactory_t); +typedef SnpeUdo_ReleaseOpFactoryFunction_t Udo_ReleaseOpFactoryFunction_t; + /** * @brief A function to create an operation from the factory. * The function receives array of inputs and array of outputs, and creates an operation @@ -188,6 +196,8 @@ typedef SnpeUdo_ErrorType_t SnpeUdo_TensorParam_t*, SnpeUdo_Operation_t*); +typedef SnpeUdo_CreateOperationFunction_t Udo_CreateOperationFunction_t; + /** * @brief A pointer to notification function. * @@ -206,6 +216,8 @@ typedef SnpeUdo_ErrorType_t typedef SnpeUdo_ErrorType_t (*SnpeUdo_ExternalNotify_t)(const uint32_t ID); +typedef SnpeUdo_ExternalNotify_t Udo_ExternalNotify_t; + /** * @brief Operation execution function. * @@ -245,6 +257,8 @@ typedef SnpeUdo_ErrorType_t const uint32_t, SnpeUdo_ExternalNotify_t); +typedef SnpeUdo_ExecuteOpFunction_t Udo_ExecuteOpFunction_t; + /** * @brief A function to setting the inputs & outputs. part of SnpeUdo_Operation struct, * returned from creation of a new operation instance. @@ -277,6 +291,8 @@ typedef SnpeUdo_ErrorType_t SnpeUdo_TensorParam_t*, SnpeUdo_TensorParam_t*); +typedef SnpeUdo_SetOpIOFunction_t Udo_SetOpIOFunction_t; + /** * @brief A function to return execution times. * @@ -297,6 +313,8 @@ SnpeUdo_profileOp(SnpeUdo_Operation_t operation, uint32_t *executionTime); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ProfileOpFunction_t)(SnpeUdo_Operation_t, uint32_t*); +typedef SnpeUdo_ProfileOpFunction_t Udo_ProfileOpFunction_t; + /** * @brief A function to release the operation instance * \n When it is called, the implementation library needs to release all resources @@ -314,6 +332,8 @@ SnpeUdo_releaseOp(SnpeUdo_Operation_t operation); typedef SnpeUdo_ErrorType_t (*SnpeUdo_ReleaseOpFunction_t)(SnpeUdo_Operation_t); +typedef SnpeUdo_ReleaseOpFunction_t Udo_ReleaseOpFunction_t; + /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #ifdef __cplusplus diff --git a/third_party/snpe/include/SnpeUdo/UdoImplDsp.h b/third_party/snpe/include/SnpeUdo/UdoImplDsp.h index 7e85bf15d..b97a64932 100644 --- a/third_party/snpe/include/SnpeUdo/UdoImplDsp.h +++ b/third_party/snpe/include/SnpeUdo/UdoImplDsp.h @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2019-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -45,13 +45,16 @@ typedef SnpeUdo_ErrorType_t (*SnpeUdo_ValidateOperationFunction_t) (SnpeUdo_Stri uint32_t, const SnpeUdo_Param_t*); +typedef SnpeUdo_ValidateOperationFunction_t Udo_ValidateOperationFunction_t; // enum used for indicating input/outout tensor data layouts on DSP, plain vs d32 typedef enum { - SNPE_UDO_DSP_TENSOR_LAYOUT_PLAIN, - SNPE_UDO_DSP_TENSOR_LAYOUT_D32 + SNPE_UDO_DSP_TENSOR_LAYOUT_PLAIN = 0x00, UDO_DSP_TENSOR_LAYOUT_PLAIN = 0x00, + SNPE_UDO_DSP_TENSOR_LAYOUT_D32 = 0x01, UDO_DSP_TENSOR_LAYOUT_D32 = 0x01 } SnpeUdo_HexNNTensorLayout_t; +typedef SnpeUdo_HexNNTensorLayout_t Udo_HexNNTensorLayout_t; + /** * @brief A function to query numbers of inputs and outputs, * quantization type of each input and each output as arrays, @@ -96,7 +99,7 @@ typedef SnpeUdo_ErrorType_t (*SnpeUdo_QueryOperationFunction_t) (SnpeUdo_String_ SnpeUdo_QuantizationType_t**, SnpeUdo_HexNNTensorLayout_t**); - +typedef SnpeUdo_QueryOperationFunction_t Udo_QueryOperationFunction_t; // Global infrastructure functions supported by Hexagon-NN v2 typedef void (*workerThread_t) (void* perOpInfrastructure, void* userData); @@ -134,12 +137,25 @@ typedef struct hexNNv2GlobalInfra { udoRunWorkerThreads_t udoRunWorkerThreads; } SnpeUdo_HexNNv2GlobalInfra_t; +typedef SnpeUdo_HexNNv2GlobalInfra_t Udo_HexNNv2GlobalInfra_t; + // hexnn types typedef enum hexnnInfraType { UDO_INFRA_HEXNN_V2, UDO_INFRA_HEXNN_V3 // reserved, do not use } SnpeUdo_HexNNInfraType_t; +typedef SnpeUdo_HexNNInfraType_t Udo_HexNNInfraType_t; + +typedef struct { + Udo_CreateOpFactoryFunction_t create_op_factory; + Udo_CreateOperationFunction_t create_operation; + Udo_ExecuteOpFunction_t execute_op; + Udo_ReleaseOpFunction_t release_op; + Udo_ReleaseOpFactoryFunction_t release_op_factory; + Udo_ValidateOperationFunction_t validate_op; + Udo_QueryOperationFunction_t query_op; +} udo_func_package_t; /** * @brief Infrastructures needed by a developer of DSP Hexnn UDO Implementation library. @@ -156,6 +172,7 @@ typedef struct dspGlobalInfrastructure { SnpeUdo_HexNNv2GlobalInfra_t hexNNv2Infra; } SnpeUdo_DspGlobalInfrastructure_t; +typedef SnpeUdo_DspGlobalInfrastructure_t Udo_DspGlobalInfrastructure_t; /** * hexnn v2 per op factory infrastructure @@ -169,6 +186,7 @@ typedef struct hexnnv2OpFactoryInfra { unsigned long graphId; } SnpeUdo_HexNNv2OpFactoryInfra_t; +typedef SnpeUdo_HexNNv2OpFactoryInfra_t Udo_HexNNv2OpFactoryInfra_t; /** * hexnn v2 per operation infrastructure @@ -182,6 +200,8 @@ typedef struct hexnnv2OpFactoryInfra { */ typedef void* SnpeUdo_HexNNv2OpInfra_t; +typedef SnpeUdo_HexNNv2OpInfra_t Udo_HexNNv2OpInfra_t; + /** @} */ /* end_addtogroup c_plus_plus_apis C++ */ #endif // SNPE_UDO_IMPL_DSP_H diff --git a/third_party/snpe/include/SnpeUdo/UdoShared.h b/third_party/snpe/include/SnpeUdo/UdoShared.h index 6fd50c318..418d9db9e 100644 --- a/third_party/snpe/include/SnpeUdo/UdoShared.h +++ b/third_party/snpe/include/SnpeUdo/UdoShared.h @@ -1,6 +1,6 @@ //============================================================================== // -// Copyright (c) 2019-2020 Qualcomm Technologies, Inc. +// Copyright (c) 2019-2021 Qualcomm Technologies, Inc. // All Rights Reserved. // Confidential and Proprietary - Qualcomm Technologies, Inc. // @@ -37,6 +37,8 @@ SnpeUdo_getVersion (SnpeUdo_LibVersion_t** version); typedef SnpeUdo_ErrorType_t (*SnpeUdo_GetVersionFunction_t) (SnpeUdo_LibVersion_t** version); +typedef SnpeUdo_GetVersionFunction_t Udo_GetVersionFunction_t; + #ifdef __cplusplus } // extern "C" #endif diff --git a/third_party/snpe/larch64 b/third_party/snpe/larch64 index e5c222b1c..2e2a1c315 120000 --- a/third_party/snpe/larch64 +++ b/third_party/snpe/larch64 @@ -1 +1 @@ -aarch64-linux-gcc4.9 \ No newline at end of file +aarch64-ubuntu-gcc7.5 \ No newline at end of file diff --git a/third_party/snpe/x86_64-linux-clang/libHtpPrepare.so b/third_party/snpe/x86_64-linux-clang/libHtpPrepare.so new file mode 100644 index 000000000..0b0657dd3 Binary files /dev/null and b/third_party/snpe/x86_64-linux-clang/libHtpPrepare.so differ diff --git a/third_party/snpe/x86_64-linux-clang/libSNPE.so b/third_party/snpe/x86_64-linux-clang/libSNPE.so index 4975bff89..0cee9ac3a 100644 Binary files a/third_party/snpe/x86_64-linux-clang/libSNPE.so and b/third_party/snpe/x86_64-linux-clang/libSNPE.so differ diff --git a/third_party/snpe/x86_64-linux-clang/libomp.so b/third_party/snpe/x86_64-linux-clang/libomp.so index 38ab0c03f..567e6ae59 100755 Binary files a/third_party/snpe/x86_64-linux-clang/libomp.so and b/third_party/snpe/x86_64-linux-clang/libomp.so differ diff --git a/third_party/snpe/x86_64-linux-clang/libsymphony-cpu.so b/third_party/snpe/x86_64-linux-clang/libsymphony-cpu.so deleted file mode 100644 index 03ebe979a..000000000 Binary files a/third_party/snpe/x86_64-linux-clang/libsymphony-cpu.so and /dev/null differ diff --git a/tools/camerastream/compressed_vipc.py b/tools/camerastream/compressed_vipc.py new file mode 100755 index 000000000..68522d1eb --- /dev/null +++ b/tools/camerastream/compressed_vipc.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +import os +import sys +import numpy as np +import multiprocessing + +from cereal.visionipc.visionipc_pyx import VisionIpcServer, VisionStreamType # pylint: disable=no-name-in-module, import-error +W, H = 1928, 1208 + +def writer(fn, addr, sock_name): + import cereal.messaging as messaging + HEADER = b"\x00\x00\x00\x01\x40\x01\x0c\x01\xff\xff\x01\x60\x00\x00\x03\x00\xb0\x00\x00\x03\x00\x00\x03\x00\x96\xac\x09\x00\x00\x00\x01\x42\x01\x01\x01\x60\x00\x00\x03\x00\xb0\x00\x00\x03\x00\x00\x03\x00\x96\xa0\x03\xd0\x80\x13\x07\x1b\x2e\x5a\xee\x4c\x92\xea\x00\xbb\x42\x84\xa0\x00\x00\x00\x01\x44\x01\xc0\xe2\x4f\x09\xc1\x80\xc6\x08\x40\x00" + fifo_file = open(fn, "wb") + fifo_file.write(HEADER) + fifo_file.flush() + + os.environ["ZMQ"] = "1" + messaging.context = messaging.Context() + + sock = messaging.sub_sock(sock_name, None, addr=addr, conflate=False) + last_idx = -1 + seen_iframe = False + while 1: + msgs = messaging.drain_sock(sock, wait_for_one=True) + for evt in msgs: + evta = getattr(evt, evt.which()) + lat = ((evt.logMonoTime/1e9) - (evta.timestampEof/1e6))*1000 + print("%2d %4d %.3f %.3f latency %.2f ms" % (len(msgs), evta.idx, evt.logMonoTime/1e9, evta.timestampEof/1e6, lat), len(evta.data), sock_name) + if evta.idx != 0 and evta.idx != (last_idx+1): + print("DROP!") + last_idx = evta.idx + if len(evta.data) > 4 and evta.data[4] == 0x26: + seen_iframe = True + if not seen_iframe: + print("waiting for iframe") + continue + fifo_file.write(evta.data) + fifo_file.flush() + +def decoder_nvidia(fn, vipc_server, vst): + sys.path.append("/raid.dell2/PyNvCodec") + import PyNvCodec as nvc # pylint: disable=import-error + decoder = nvc.PyNvDecoder(fn, 0, {"probesize": "32"}) + conv = nvc.PySurfaceConverter(W, H, nvc.PixelFormat.NV12, nvc.PixelFormat.BGR, 0) + cc1 = nvc.ColorspaceConversionContext(nvc.ColorSpace.BT_709, nvc.ColorRange.JPEG) + nvDwn = nvc.PySurfaceDownloader(W, H, nvc.PixelFormat.BGR, 0) + + img = np.ndarray((H,W,3), dtype=np.uint8) + cnt = 0 + while 1: + rawSurface = decoder.DecodeSingleSurface() + if rawSurface.Empty(): + continue + convSurface = conv.Execute(rawSurface, cc1) + nvDwn.DownloadSingleSurface(convSurface, img) + vipc_server.send(vst, img.flatten().data, cnt, 0, 0) + cnt += 1 + +def decoder_ffmpeg(fn, vipc_server, vst): + import av # pylint: disable=import-error + container = av.open(fn, options={"probesize": "32"}) + cnt = 0 + for frame in container.decode(video=0): + img = frame.to_ndarray(format=av.video.format.VideoFormat('bgr24')) + vipc_server.send(vst, img.flatten().data, cnt, 0, 0) + cnt += 1 + +import argparse +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Decode video streams and broacast on VisionIPC') + parser.add_argument("addr", help="Address of comma 3") + parser.add_argument('--nvidia', action='store_true', help='Use nvidia instead of ffmpeg') + parser.add_argument("--cams", default="0,1,2", help="Cameras to decode") + args = parser.parse_args() + + all_cams = [ + ("roadEncodeData", VisionStreamType.VISION_STREAM_RGB_ROAD), + ("wideRoadEncodeData", VisionStreamType.VISION_STREAM_RGB_WIDE_ROAD), + ("driverEncodeData", VisionStreamType.VISION_STREAM_RGB_DRIVER), + ] + cams = dict([all_cams[int(x)] for x in args.cams.split(",")]) + + vipc_server = VisionIpcServer("camerad") + for vst in cams.values(): + vipc_server.create_buffers(vst, 4, True, W, H) + vipc_server.start_listener() + + for k,v in cams.items(): + FIFO_NAME = "/tmp/decodepipe_"+k + if os.path.exists(FIFO_NAME): + os.unlink(FIFO_NAME) + os.mkfifo(FIFO_NAME) + multiprocessing.Process(target=writer, args=(FIFO_NAME, sys.argv[1], k)).start() + if args.nvidia: + multiprocessing.Process(target=decoder_nvidia, args=(FIFO_NAME, vipc_server, v)).start() + else: + multiprocessing.Process(target=decoder_ffmpeg, args=(FIFO_NAME, vipc_server, v)).start() diff --git a/tools/camerastream/receive.py b/tools/camerastream/receive.py new file mode 100755 index 000000000..6f8d67c78 --- /dev/null +++ b/tools/camerastream/receive.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +import os +import sys +import numpy as np +os.environ['ZMQ'] = '1' + +from common.window import Window +import cereal.messaging as messaging + +# start camerad with 'SEND_ROAD=1 SEND_DRIVER=1 SEND_WIDE_ROAD=1 XMIN=771 XMAX=1156 YMIN=483 YMAX=724 ./camerad' +# also start bridge +# then run this "./receive.py " + +if "FULL" in os.environ: + SCALE = 2 + XMIN, XMAX = 0, 1927 + YMIN, YMAX = 0, 1207 +else: + SCALE = 1 + XMIN = 771 + XMAX = 1156 + YMIN = 483 + YMAX = 724 +H, W = ((YMAX-YMIN+1)//SCALE, (XMAX-XMIN+1)//SCALE) + +if __name__ == '__main__': + cameras = ['roadCameraState', 'wideRoadCameraState', 'driverCameraState'] + if "CAM" in os.environ: + cam = int(os.environ['CAM']) + cameras = cameras[cam:cam+1] + sm = messaging.SubMaster(cameras, addr=sys.argv[1]) + win = Window(W*len(cameras), H) + bdat = np.zeros((H, W*len(cameras), 3), dtype=np.uint8) + + while 1: + sm.update() + for i,k in enumerate(cameras): + if sm.updated[k]: + #print("update", k) + bgr_raw = sm[k].image + dat = np.frombuffer(bgr_raw, dtype=np.uint8).reshape(H, W, 3)[:, :, [2,1,0]] + bdat[:, W*i:W*(i+1)] = dat + win.draw(bdat) + diff --git a/tools/joystick/joystickd.py b/tools/joystick/joystickd.py index 5a8629344..6226038d5 100755 --- a/tools/joystick/joystickd.py +++ b/tools/joystick/joystickd.py @@ -1,9 +1,11 @@ #!/usr/bin/env python import os import argparse +import threading from inputs import get_gamepad import cereal.messaging as messaging +from common.realtime import Ratekeeper from common.numpy_fast import interp, clip from common.params import Params from tools.lib.kbhit import KBHit @@ -16,6 +18,8 @@ class Keyboard: self.axes_map = {'w': 'gb', 's': 'gb', 'a': 'steer', 'd': 'steer'} self.axes_values = {'gb': 0., 'steer': 0.} + self.axes_order = ['gb', 'steer'] + self.cancel = False def update(self): key = self.kb.getch().lower() @@ -35,42 +39,53 @@ class Keyboard: class Joystick: def __init__(self): - self.min_axis_value = 0 - self.max_axis_value = 255 + # TODO: find a way to get this from API, perhaps "inputs" doesn't support it + self.min_axis_value = {'ABS_Y': 0., 'ABS_RZ': 0.} + self.max_axis_value = {'ABS_Y': 1023., 'ABS_RZ': 255.} self.cancel_button = 'BTN_TRIGGER' self.axes_values = {'ABS_Y': 0., 'ABS_RZ': 0.} # gb, steer + self.axes_order = ['ABS_Y', 'ABS_RZ'] + self.cancel = False def update(self): joystick_event = get_gamepad()[0] event = (joystick_event.code, joystick_event.state) - self.cancel = False - if event[0] == self.cancel_button and event[1] == 0: # state 0 is falling edge - self.cancel = True + if event[0] == self.cancel_button: + if event[1] == 1: + self.cancel = True + elif event[1] == 0: # state 0 is falling edge + self.cancel = False elif event[0] in self.axes_values: - self.max_axis_value = max(event[1], self.max_axis_value) - self.min_axis_value = min(event[1], self.min_axis_value) + self.max_axis_value[event[0]] = max(event[1], self.max_axis_value[event[0]]) + self.min_axis_value[event[0]] = min(event[1], self.min_axis_value[event[0]]) - norm = -interp(event[1], [self.min_axis_value, self.max_axis_value], [-1., 1.]) + norm = -interp(event[1], [self.min_axis_value[event[0]], self.max_axis_value[event[0]]], [-1., 1.]) self.axes_values[event[0]] = norm if abs(norm) > 0.05 else 0. # center can be noisy, deadzone of 5% else: return False return True +def send_thread(joystick): + joystick_sock = messaging.pub_sock('testJoystick') + rk = Ratekeeper(100, print_delay_threshold=None) + while 1: + dat = messaging.new_message('testJoystick') + dat.testJoystick.axes = [joystick.axes_values[a] for a in joystick.axes_order] + dat.testJoystick.buttons = [joystick.cancel] + joystick_sock.send(dat.to_bytes()) + print('\n' + ', '.join(f'{name}: {round(v, 3)}' for name, v in joystick.axes_values.items())) + if "WEB" in os.environ: + import requests + requests.get("http://"+os.environ["WEB"]+":5000/control/%f/%f" % tuple([joystick.axes_values[a] for a in joystick.axes_order][::-1])) + rk.keep_time() + def joystick_thread(use_keyboard): Params().put_bool('JoystickDebugMode', True) - joystick_sock = messaging.pub_sock('testJoystick') joystick = Keyboard() if use_keyboard else Joystick() - + threading.Thread(target=send_thread, args=(joystick,), daemon=True).start() while True: - ret = joystick.update() - if ret: - dat = messaging.new_message('testJoystick') - dat.testJoystick.axes = [joystick.axes_values[a] for a in joystick.axes_values] - dat.testJoystick.buttons = [joystick.cancel] - joystick_sock.send(dat.to_bytes()) - print('\n' + ', '.join(f'{name}: {round(v, 3)}' for name, v in joystick.axes_values.items())) - + joystick.update() if __name__ == '__main__': parser = argparse.ArgumentParser(description='Publishes events from your joystick to control your car.\n' + @@ -79,7 +94,7 @@ if __name__ == '__main__': parser.add_argument('--keyboard', action='store_true', help='Use your keyboard instead of a joystick') args = parser.parse_args() - if not Params().get_bool("IsOffroad") and "ZMQ" not in os.environ: + if not Params().get_bool("IsOffroad") and "ZMQ" not in os.environ and "WEB" not in os.environ: print("The car must be off before running joystickd.") exit() diff --git a/tools/joystick/web.py b/tools/joystick/web.py new file mode 100755 index 000000000..403041362 --- /dev/null +++ b/tools/joystick/web.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +from flask import Flask +import time +import threading +import cereal.messaging as messaging + +app = Flask(__name__) +pm = messaging.PubMaster(['testJoystick']) + +index = """ + + + + + +
+ +""" + +@app.route("/") +def hello_world(): + return index + +last_send_time = time.time() +@app.route("/control//") +def control(x, y): + global last_send_time + x,y = float(x), float(y) + x = max(-1, min(1, x)) + y = max(-1, min(1, y)) + dat = messaging.new_message('testJoystick') + dat.testJoystick.axes = [y,x] + dat.testJoystick.buttons = [False] + pm.send('testJoystick', dat) + last_send_time = time.time() + return "" + +def handle_timeout(): + while 1: + this_time = time.time() + if (last_send_time+0.5) < this_time: + print("timeout, no web in %.2f s" % (this_time-last_send_time)) + dat = messaging.new_message('testJoystick') + dat.testJoystick.axes = [0,0] + dat.testJoystick.buttons = [False] + pm.send('testJoystick', dat) + time.sleep(0.1) + +if __name__ == '__main__': + threading.Thread(target=handle_timeout, daemon=True).start() + app.run(host="0.0.0.0") + diff --git a/tools/latencylogger/README.md b/tools/latencylogger/README.md new file mode 100644 index 000000000..20de8212a --- /dev/null +++ b/tools/latencylogger/README.md @@ -0,0 +1,88 @@ +# LatencyLogger + +LatencyLogger is a tool to track the time from first pixel to actuation. Timestamps are printed in a table as well as plotted in a graph. Start openpilot with `LOG_TIMESTAMPS=1` set to enable the necessary logging. + +## Usage + +``` +$ python latency_logger.py -h +usage: latency_logger.py [-h] [--relative] [--demo] [--plot] [route_or_segment_name] + +A tool for analyzing openpilot's end-to-end latency + +positional arguments: + route_or_segment_name + The route to print (default: None) + +optional arguments: + -h, --help show this help message and exit + --relative Make timestamps relative to the start of each frame (default: False) + --demo Use the demo route instead of providing one (default: False) + --plot If a plot should be generated (default: False) +``` + +## Examples +Plotting with relative starts each process at time=0 and gives a nice overview. Timestamps are visualized as diamonds. The opacity allows for visualization of overlapping services. +![relplot-1](https://user-images.githubusercontent.com/42323981/162108651-e0beee14-56e4-466d-8af1-cb37129fd94a.png) + +Plotting without relative provides info about the frames relative time. +![plot-1](https://user-images.githubusercontent.com/42323981/162108694-fbfe907b-a1ee-4cc7-bc8b-162a7d9305d4.png) + + +Printed timestamps of a frame with internal durations. +``` +Frame ID: 303 + camerad + roadCameraState start of frame 0.0 + wideRoadCameraState start of frame 0.091926 + RoadCamera: Image set 1.691696 + RoadCamera: Transformed 1.812841 + roadCameraState published 51.775466 + wideRoadCameraState published 54.935164 + roadCameraState.processingTime 1.6455530421808362 + wideRoadCameraState.processingTime 4.790564067661762 + modeld + Image added 56.628788 + Extra image added 57.459923 + Execution finished 75.091306 + modelV2 published 75.24797 + modelV2.modelExecutionTime 20.00947669148445 + modelV2.gpuExecutionTime 0.0 + plannerd + lateralPlan published 80.426861 + longitudinalPlan published 85.722781 + lateralPlan.solverExecutionTime 1.0600379901006818 + longitudinalPlan.solverExecutionTime 1.3830000534653664 + controlsd + Data sampled 89.436221 + Events updated 90.356522 + sendcan published 91.396092 + controlsState published 91.77843 + Data sampled 99.885876 + Events updated 100.696855 + sendcan published 101.600489 + controlsState published 101.941839 + Data sampled 110.087669 + Events updated 111.025365 + sendcan published 112.305921 + controlsState published 112.70451 + Data sampled 119.692803 + Events updated 120.56774 + sendcan published 121.735016 + controlsState published 122.142823 + Data sampled 129.264761 + Events updated 130.024282 + sendcan published 130.950364 + controlsState published 131.281558 + boardd + sending sendcan to panda: 250027001751393037323631 101.705487 + sendcan sent to panda: 250027001751393037323631 102.042462 + sending sendcan to panda: 250027001751393037323631 112.416961 + sendcan sent to panda: 250027001751393037323631 112.792269 + sending sendcan to panda: 250027001751393037323631 121.850952 + sendcan sent to panda: 250027001751393037323631 122.231103 + sending sendcan to panda: 250027001751393037323631 131.045206 + sendcan sent to panda: 250027001751393037323631 131.351296 + sending sendcan to panda: 250027001751393037323631 141.340592 + sendcan sent to panda: 250027001751393037323631 141.700744 +``` diff --git a/tools/latencylogger/latency_logger.py b/tools/latencylogger/latency_logger.py new file mode 100644 index 000000000..2994df2c5 --- /dev/null +++ b/tools/latencylogger/latency_logger.py @@ -0,0 +1,198 @@ +import argparse +import json +import matplotlib.patches as mpatches +import matplotlib.pyplot as plt +import mpld3 +import sys +from collections import defaultdict + +from tools.lib.logreader import logreader_from_route_or_segment + +DEMO_ROUTE = "9f583b1d93915c31|2022-04-06--11-34-03" + +SERVICES = ['camerad', 'modeld', 'plannerd', 'controlsd', 'boardd'] +# Retrive controlsd frameId from lateralPlan, mismatch with longitudinalPlan will be ignored +MONOTIME_KEYS = ['modelMonoTime', 'lateralPlanMonoTime'] +MSGQ_TO_SERVICE = { + 'roadCameraState': 'camerad', + 'wideRoadCameraState': 'camerad', + 'modelV2': 'modeld', + 'lateralPlan': 'plannerd', + 'longitudinalPlan': 'plannerd', + 'sendcan': 'controlsd', + 'controlsState': 'controlsd' +} +SERVICE_TO_DURATIONS = { + 'camerad': ['processingTime'], + 'modeld': ['modelExecutionTime', 'gpuExecutionTime'], + 'plannerd': ["solverExecutionTime"], +} + +def read_logs(lr): + data = defaultdict(lambda: defaultdict(lambda: defaultdict(list))) + mono_to_frame = {} + frame_mismatches = [] + latest_sendcan_monotime = 0 + for msg in lr: + if msg.which() == 'sendcan': + latest_sendcan_monotime = msg.logMonoTime + continue + + if msg.which() in MSGQ_TO_SERVICE: + service = MSGQ_TO_SERVICE[msg.which()] + msg_obj = getattr(msg, msg.which()) + + frame_id = -1 + if hasattr(msg_obj, "frameId"): + frame_id = msg_obj.frameId + else: + continue_outer = False + for key in MONOTIME_KEYS: + if hasattr(msg_obj, key): + if getattr(msg_obj, key) == 0: + # Filter out controlsd messages which arrive before the camera loop + continue_outer = True + elif getattr(msg_obj, key) in mono_to_frame: + frame_id = mono_to_frame[getattr(msg_obj, key)] + if continue_outer: + continue + mono_to_frame[msg.logMonoTime] = frame_id + data['timestamp'][frame_id][service].append((msg.which()+" published", msg.logMonoTime)) + + next_service = SERVICES[SERVICES.index(service)+1] + if not data['start'][frame_id][next_service]: + data['start'][frame_id][next_service] = msg.logMonoTime + data['end'][frame_id][service] = msg.logMonoTime + + if service in SERVICE_TO_DURATIONS: + for duration in SERVICE_TO_DURATIONS[service]: + data['duration'][frame_id][service].append((msg.which()+"."+duration, getattr(msg_obj, duration))) + + if service == SERVICES[0]: + data['timestamp'][frame_id][service].append((msg.which()+" start of frame", msg_obj.timestampSof)) + if not data['start'][frame_id][service]: + data['start'][frame_id][service] = msg_obj.timestampSof + elif msg.which() == 'controlsState': + # Sendcan is published before controlsState, but the frameId is retrived in CS + data['timestamp'][frame_id][service].append(("sendcan published", latest_sendcan_monotime)) + elif msg.which() == 'modelV2': + if msg_obj.frameIdExtra != frame_id: + frame_mismatches.append(frame_id) + + # Failed frameId fetches are stored in -1 + assert sum([len(data['timestamp'][-1][service]) for service in data['timestamp'][-1].keys()]) < 20, "Too many frameId fetch fails" + del data['timestamp'][-1] + assert len(frame_mismatches) < 20, "Too many frame mismatches" + return (data, frame_mismatches) + + +def find_frame_id(time, service, start_times, end_times): + for frame_id in reversed(start_times): + if start_times[frame_id][service] and end_times[frame_id][service]: + if start_times[frame_id][service] <= time <= end_times[frame_id][service]: + yield frame_id + +## ASSUMES THAT AT LEAST ONE CLOUDLOG IS MADE IN CONTROLSD +def insert_cloudlogs(lr, timestamps, start_times, end_times): + t0 = start_times[min(start_times.keys())][SERVICES[0]] + failed_inserts = 0 + latest_controls_frameid = 0 + for msg in lr: + if msg.which() == "logMessage": + jmsg = json.loads(msg.logMessage) + if "timestamp" in jmsg['msg']: + time = int(jmsg['msg']['timestamp']['time']) + service = jmsg['ctx']['daemon'] + event = jmsg['msg']['timestamp']['event'] + if time < t0: + # Filter out controlsd messages which arrive before the camera loop + continue + + if service == "boardd": + timestamps[latest_controls_frameid][service].append((event, time)) + end_times[latest_controls_frameid][service] = time + else: + frame_id_gen = find_frame_id(time, service, start_times, end_times) + frame_id = next(frame_id_gen, False) + if frame_id: + if service == 'controlsd': + latest_controls_frameid = frame_id + timestamps[frame_id][service].append((event, time)) + else: + failed_inserts += 1 + assert latest_controls_frameid > 0, "No timestamp in controlsd" + assert failed_inserts < len(timestamps), "Too many failed cloudlog inserts" + +def print_timestamps(timestamps, durations, start_times, relative): + t0 = start_times[min(start_times.keys())][SERVICES[0]] + for frame_id in timestamps.keys(): + print('='*80) + print("Frame ID:", frame_id) + if relative: + t0 = start_times[frame_id][SERVICES[0]] + for service in SERVICES: + print(" "+service) + events = timestamps[frame_id][service] + for event, time in sorted(events, key = lambda x: x[1]): + print(" "+'%-53s%-53s' %(event, str((time-t0)/1e6))) + for event, time in durations[frame_id][service]: + print(" "+'%-53s%-53s' %(event, str(time*1000))) + +def graph_timestamps(timestamps, start_times, end_times, relative): + t0 = start_times[min(start_times.keys())][SERVICES[0]] + fig, ax = plt.subplots() + ax.set_xlim(0, 150 if relative else 750) + ax.set_ylim(0, 15) + ax.set_xlabel('milliseconds') + ax.set_ylabel('Frame ID') + colors = ['blue', 'green', 'red', 'yellow', 'purple'] + assert len(colors) == len(SERVICES), 'Each service needs a color' + + points = {"x": [], "y": [], "labels": []} + for frame_id, services in timestamps.items(): + if relative: + t0 = start_times[frame_id][SERVICES[0]] + service_bars = [] + for service, events in services.items(): + if start_times[frame_id][service] and end_times[frame_id][service]: + start = start_times[frame_id][service] + end = end_times[frame_id][service] + service_bars.append(((start-t0)/1e6,(end-start)/1e6)) + for event in events: + points['x'].append((event[1]-t0)/1e6) + points['y'].append(frame_id) + points['labels'].append(event[0]) + ax.broken_barh(service_bars, (frame_id-0.45, 0.9), facecolors=(colors), alpha=0.5) + + scatter = ax.scatter(points['x'], points['y'], marker='d', edgecolor='black') + tooltip = mpld3.plugins.PointLabelTooltip(scatter, labels=points['labels']) + + mpld3.plugins.connect(fig, tooltip) + plt.legend(handles=[mpatches.Patch(color=colors[i], label=SERVICES[i]) for i in range(len(SERVICES))]) + return fig + +def get_timestamps(lr): + data, frame_mismatches = read_logs(lr) + lr.reset() + insert_cloudlogs(lr, data['timestamp'], data['start'], data['end']) + return data, frame_mismatches + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="A tool for analyzing openpilot's end-to-end latency", + formatter_class = argparse.ArgumentDefaultsHelpFormatter) + parser.add_argument("--relative", action="store_true", help="Make timestamps relative to the start of each frame") + parser.add_argument("--demo", action="store_true", help="Use the demo route instead of providing one") + parser.add_argument("--plot", action="store_true", help="If a plot should be generated") + parser.add_argument("route_or_segment_name", nargs='?', help="The route to print") + + if len(sys.argv) == 1: + parser.print_help() + sys.exit() + args = parser.parse_args() + + r = DEMO_ROUTE if args.demo else args.route_or_segment_name.strip() + lr = logreader_from_route_or_segment(r, sort_by_time=True) + data, _ = get_timestamps(lr) + print_timestamps(data['timestamp'], data['duration'], data['start'], args.relative) + if args.plot: + mpld3.show(graph_timestamps(data['timestamp'], data['start'], data['end'], args.relative)) diff --git a/tools/lib/README.md b/tools/lib/README.md index c681809ea..241232eae 100644 --- a/tools/lib/README.md +++ b/tools/lib/README.md @@ -31,3 +31,21 @@ for msg in lr: if msg.which() == "carState": print(msg.carState.steeringAngleDeg) ``` + +### MultiLogIterator + +`MultiLogIterator` is similar to `LogReader`, but reads multiple logs. + +```python +from tools.lib.route import Route +from tools.lib.logreader import MultiLogIterator + +# setup a MultiLogIterator to read all the logs in the route +r = Route("4cf7a6ad03080c90|2021-09-29--13-46-36") +lr = MultiLogIterator(r.log_paths()) + +# print all the steering angles values from all the logs in the route +for msg in lr: + if msg.which() == "carState": + print(msg.carState.steeringAngleDeg) +``` diff --git a/tools/lib/auth.py b/tools/lib/auth.py index 0e9e7705b..54fb81cc2 100755 --- a/tools/lib/auth.py +++ b/tools/lib/auth.py @@ -86,13 +86,13 @@ def auth_redirect_link(method): }) return 'https://github.com/login/oauth/authorize?' + urlencode(params) elif method == 'apple': - params.update({ - 'client_id': 'ai.comma.login', - 'response_type': 'code', - 'response_mode': 'form_post', - 'scope': 'name email', - }) - return 'https://appleid.apple.com/auth/authorize?' + urlencode(params) + params.update({ + 'client_id': 'ai.comma.login', + 'response_type': 'code', + 'response_mode': 'form_post', + 'scope': 'name email', + }) + return 'https://appleid.apple.com/auth/authorize?' + urlencode(params) else: raise NotImplementedError(f"no redirect implemented for method {method}") diff --git a/tools/lib/framereader.py b/tools/lib/framereader.py index bdf48bb43..e333683b5 100644 --- a/tools/lib/framereader.py +++ b/tools/lib/framereader.py @@ -348,6 +348,8 @@ class VideoStreamDecompressor: if len(r) == 0: break self.proc.stdin.write(r) + except BrokenPipeError: + pass finally: self.proc.stdin.close() diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py index c8d506b4b..06dd248bf 100755 --- a/tools/lib/logreader.py +++ b/tools/lib/logreader.py @@ -5,8 +5,9 @@ import bz2 import urllib.parse import capnp -from tools.lib.filereader import FileReader from cereal import log as capnp_log +from tools.lib.filereader import FileReader +from tools.lib.route import Route, SegmentName # this is an iterator itself, and uses private variables from LogReader class MultiLogIterator: @@ -66,6 +67,8 @@ class MultiLogIterator: self._inc() return True + def reset(self): + self.__init__(self._log_paths, sort_by_time=self.sort_by_time) class LogReader: def __init__(self, fn, canonicalize=True, only_union_types=False, sort_by_time=False): @@ -99,6 +102,16 @@ class LogReader: else: yield ent + +def logreader_from_route_or_segment(r, sort_by_time=False): + sn = SegmentName(r, allow_route_name=True) + route = Route(sn.route_name.canonical_name) + if sn.segment_num < 0: + return MultiLogIterator(route.log_paths(), sort_by_time) + else: + return LogReader(route.log_paths()[sn.segment_num], sort_by_time) + + if __name__ == "__main__": import codecs # capnproto <= 0.8.0 throws errors converting byte data to string diff --git a/tools/lib/tests/test_caching.py b/tools/lib/tests/test_caching.py index 953b47e95..d2a2a6872 100644 --- a/tools/lib/tests/test_caching.py +++ b/tools/lib/tests/test_caching.py @@ -66,4 +66,4 @@ class TestFileDownload(unittest.TestCase): if __name__ == "__main__": - unittest.main() + unittest.main() diff --git a/tools/mac_setup.sh b/tools/mac_setup.sh index fa1a23dd4..b85981dc0 100755 --- a/tools/mac_setup.sh +++ b/tools/mac_setup.sh @@ -4,16 +4,33 @@ set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" ROOT="$(cd $DIR/../ && pwd)" +ARCH=$(uname -m) + +if [[ $SHELL == "/bin/zsh" ]]; then + RC_FILE="$HOME/.zshrc" +elif [[ $SHELL == "/bin/bash" ]]; then + RC_FILE="$HOME/.bashrc" +fi # Install brew if required if [[ $(command -v brew) == "" ]]; then echo "Installing Hombrew" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" echo "[ ] installed brew t=$SECONDS" + + # make brew available now + if [[ $ARCH == "x86_64" ]]; then + echo 'eval "$(/usr/local/homebrew/bin/brew shellenv)"' >> $RC_FILE + eval "$(/usr/local/homebrew/bin/brew shellenv)" + else + echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $RC_FILE + eval "$(/opt/homebrew/bin/brew shellenv)" + fi fi # TODO: remove protobuf,protobuf-c,swig when casadi can be pip installed brew bundle --file=- <<-EOS +brew "catch2" brew "cmake" brew "cppcheck" brew "git-lfs" @@ -40,20 +57,18 @@ EOS echo "[ ] finished brew install t=$SECONDS" -if [[ $SHELL == "/bin/zsh" ]]; then - RC_FILE="$HOME/.zshrc" -elif [[ $SHELL == "/bin/bash" ]]; then - RC_FILE="$HOME/.bash_profile" -fi +BREW_PREFIX=$(brew --prefix) + +# archive backend tools for pip dependencies +export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/zlib/lib" +export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/bzip2/lib" +export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/zlib/include" +export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/bzip2/include" -export LDFLAGS="$LDFLAGS -L/usr/local/opt/zlib/lib" -export LDFLAGS="$LDFLAGS -L/usr/local/opt/bzip2/lib" -export LDFLAGS="$LDFLAGS -L/usr/local/opt/openssl@1.1/lib" -export CPPFLAGS="$CPPFLAGS -I/usr/local/opt/zlib/include" -export CPPFLAGS="$CPPFLAGS -I/usr/local/opt/bzip2/include" -export CPPFLAGS="$CPPFLAGS -I/usr/local/opt/openssl@1.1/include" -export PATH="$PATH:/usr/local/opt/openssl@1.1/bin" -export PATH="$PATH:/usr/local/bin" +# pycurl curl/openssl backend dependencies +export LDFLAGS="$LDFLAGS -L${BREW_PREFIX}/opt/openssl@3/lib" +export CPPFLAGS="$CPPFLAGS -I${BREW_PREFIX}/opt/openssl@3/include" +export PYCURL_SSL_LIBRARY=openssl # openpilot environment if [ -z "$OPENPILOT_ENV" ] && [ -n "$RC_FILE" ] && [ -z "$CI" ]; then diff --git a/tools/plotjuggler/README.md b/tools/plotjuggler/README.md index 2e79aecbc..e120edf2f 100644 --- a/tools/plotjuggler/README.md +++ b/tools/plotjuggler/README.md @@ -12,8 +12,7 @@ Once you've cloned and are in openpilot, this command will download PlotJuggler ``` $ ./juggle.py -h -usage: juggle.py [-h] [--demo] [--qlog] [--can] [--stream] [--layout [LAYOUT]] [--install] - [route_or_segment_name] [segment_count] +usage: juggle.py [-h] [--demo] [--qlog] [--can] [--stream] [--layout [LAYOUT]] [--install] [--dbc DBC] [route_or_segment_name] [segment_count] A helper to run PlotJuggler on openpilot routes @@ -23,13 +22,15 @@ positional arguments: segment_count The number of segments to plot (default: None) optional arguments: - -h, --help show this help message and exit - --demo Use the demo route instead of providing one (default: False) - --qlog Use qlogs (default: False) - --can Parse CAN data (default: False) - --stream Start PlotJuggler in streaming mode (default: False) - --layout [LAYOUT] Run PlotJuggler with a pre-defined layout (default: None) - --install Install or update PlotJuggler + plugins (default: False) + -h, --help show this help message and exit + --demo Use the demo route instead of providing one (default: False) + --qlog Use qlogs (default: False) + --can Parse CAN data (default: False) + --stream Start PlotJuggler in streaming mode (default: False) + --layout [LAYOUT] Run PlotJuggler with a pre-defined layout (default: None) + --install Install or update PlotJuggler + plugins (default: False) + --dbc DBC Set the DBC name to load for parsing CAN data. If not set, the DBC will be + automatically inferred from the logs. (default: None) ``` Examples using route name: @@ -62,7 +63,7 @@ If you create a layout that's useful for others, consider upstreaming it. ### Tuning -Use this layout to improve your car's tuning and generate plots for tuning PRs. Also see the tuning wiki and tuning PR template. +Use this layout to improve your car's tuning and generate plots for tuning PRs. Also see the [tuning wiki](https://github.com/commaai/openpilot/wiki/Tuning) and tuning PR template. `--layout layouts/tuning.xml` diff --git a/tools/plotjuggler/juggle.py b/tools/plotjuggler/juggle.py index 1dcbcae0c..3e8775eb8 100755 --- a/tools/plotjuggler/juggle.py +++ b/tools/plotjuggler/juggle.py @@ -12,8 +12,6 @@ import argparse from common.basedir import BASEDIR from selfdrive.test.process_replay.compare_logs import save_log -from tools.lib.api import CommaApi -from tools.lib.auth_config import get_token from tools.lib.robust_logreader import RobustLogReader from tools.lib.route import Route, SegmentName from urllib.parse import urlparse, parse_qs @@ -75,13 +73,13 @@ def start_juggler(fn=None, dbc=None, layout=None): subprocess.call(cmd, shell=True, env=env, cwd=juggle_dir) -def juggle_route(route_or_segment_name, segment_count, qlog, can, layout): +def juggle_route(route_or_segment_name, segment_count, qlog, can, layout, dbc=None): segment_start = 0 if 'cabana' in route_or_segment_name: query = parse_qs(urlparse(route_or_segment_name).query) - api = CommaApi(get_token()) - logs = api.get(f'v1/route/{query["route"][0]}/log_urls?sig={query["sig"][0]}&exp={query["exp"][0]}') - elif route_or_segment_name.startswith("http://") or route_or_segment_name.startswith("https://") or os.path.isfile(route_or_segment_name): + route_or_segment_name = query["route"][0] + + if route_or_segment_name.startswith(("http://", "https://")) or os.path.isfile(route_or_segment_name): logs = [route_or_segment_name] else: route_or_segment_name = SegmentName(route_or_segment_name, allow_route_name=True) @@ -93,7 +91,7 @@ def juggle_route(route_or_segment_name, segment_count, qlog, can, layout): r = Route(route_or_segment_name.route_name.canonical_name) logs = r.qlog_paths() if qlog else r.log_paths() - segment_end = segment_start + segment_count if segment_count else -1 + segment_end = segment_start + segment_count if segment_count else None logs = logs[segment_start:segment_end] if None in logs: @@ -113,14 +111,14 @@ def juggle_route(route_or_segment_name, segment_count, qlog, can, layout): all_data = [d for d in all_data if d.which() not in ['can', 'sendcan']] # Infer DBC name from logs - dbc = None - for cp in [m for m in all_data if m.which() == 'carParams']: - try: - DBC = __import__(f"selfdrive.car.{cp.carParams.carName}.values", fromlist=['DBC']).DBC - dbc = DBC[cp.carParams.carFingerprint]['pt'] - except Exception: - pass - break + if dbc is None: + for cp in [m for m in all_data if m.which() == 'carParams']: + try: + DBC = __import__(f"selfdrive.car.{cp.carParams.carName}.values", fromlist=['DBC']).DBC + dbc = DBC[cp.carParams.carFingerprint]['pt'] + except Exception: + pass + break with tempfile.NamedTemporaryFile(suffix='.rlog', dir=juggle_dir) as tmp: save_log(tmp.name, all_data, compress=False) @@ -138,6 +136,7 @@ if __name__ == "__main__": parser.add_argument("--stream", action="store_true", help="Start PlotJuggler in streaming mode") parser.add_argument("--layout", nargs='?', help="Run PlotJuggler with a pre-defined layout") parser.add_argument("--install", action="store_true", help="Install or update PlotJuggler + plugins") + parser.add_argument("--dbc", help="Set the DBC name to load for parsing CAN data. If not set, the DBC will be automatically inferred from the logs.") parser.add_argument("route_or_segment_name", nargs='?', help="The route or segment name to plot (cabana share URL accepted)") parser.add_argument("segment_count", type=int, nargs='?', help="The number of segments to plot") @@ -158,4 +157,4 @@ if __name__ == "__main__": start_juggler(layout=args.layout) else: route_or_segment_name = DEMO_ROUTE if args.demo else args.route_or_segment_name.strip() - juggle_route(route_or_segment_name, args.segment_count, args.qlog, args.can, args.layout) + juggle_route(route_or_segment_name, args.segment_count, args.qlog, args.can, args.layout, args.dbc) diff --git a/tools/plotjuggler/layouts/controls_mismatch_debug.xml b/tools/plotjuggler/layouts/controls_mismatch_debug.xml index e50b5ffb3..adca3eed2 100644 --- a/tools/plotjuggler/layouts/controls_mismatch_debug.xml +++ b/tools/plotjuggler/layouts/controls_mismatch_debug.xml @@ -1,27 +1,34 @@ - + - + - - + + - - + + - - + + + + + + + + + diff --git a/tools/plotjuggler/layouts/system_lag_debug.xml b/tools/plotjuggler/layouts/system_lag_debug.xml new file mode 100644 index 000000000..b1699348c --- /dev/null +++ b/tools/plotjuggler/layouts/system_lag_debug.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/plotjuggler/layouts/thermal_debug.xml b/tools/plotjuggler/layouts/thermal_debug.xml new file mode 100644 index 000000000..fbb89ddcf --- /dev/null +++ b/tools/plotjuggler/layouts/thermal_debug.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/replay/lib/ui_helpers.py b/tools/replay/lib/ui_helpers.py index 7410c107c..d66fe7930 100644 --- a/tools/replay/lib/ui_helpers.py +++ b/tools/replay/lib/ui_helpers.py @@ -10,8 +10,7 @@ from matplotlib.backends.backend_agg import FigureCanvasAgg from common.transformations.camera import (eon_f_frame_size, eon_f_focal_length, tici_f_frame_size, tici_f_focal_length, get_view_frame_from_calib_frame) -from selfdrive.config import UIParams as UP -from selfdrive.config import RADAR_TO_CAMERA +from selfdrive.controls.lib.radar_helpers import RADAR_TO_CAMERA RED = (255, 0, 0) @@ -24,6 +23,15 @@ WHITE = (255, 255, 255) _FULL_FRAME_SIZE = { } +class UIParams: + lidar_x, lidar_y, lidar_zoom = 384, 960, 6 + lidar_car_x, lidar_car_y = lidar_x / 2., lidar_y / 1.1 + car_hwidth = 1.7272 / 2 * lidar_zoom + car_front = 2.6924 * lidar_zoom + car_back = 1.8796 * lidar_zoom + car_color = 110 +UP = UIParams + _BB_TO_FULL_FRAME = {} _CALIB_BB_TO_FULL = {} _FULL_FRAME_TO_BB = {} @@ -185,12 +193,12 @@ def plot_model(m, img, calibration, top_down): if calibration is None or top_down is None: return - for lead in m.leads: + for lead in m.leadsV3: if lead.prob < 0.5: continue - x, y, _, _ = lead.xyva - x_std, _, _, _ = lead.xyvaStd + x, y = lead.x[0], lead.y[0] + x_std = lead.xStd[0] x -= RADAR_TO_CAMERA _, py_top = to_topdown_pt(x + x_std, y) diff --git a/tools/replay/ui.py b/tools/replay/ui.py index b39377ffd..729d4cd0d 100755 --- a/tools/replay/ui.py +++ b/tools/replay/ui.py @@ -10,8 +10,7 @@ import pygame # pylint: disable=import-error import cereal.messaging as messaging from common.numpy_fast import clip from common.basedir import BASEDIR -from selfdrive.config import UIParams as UP -from tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME, +from tools.replay.lib.ui_helpers import (_BB_TO_FULL_FRAME, UP, _INTRINSICS, BLACK, GREEN, YELLOW, Calibration, get_blank_lid_overlay, init_plots, @@ -100,7 +99,7 @@ def ui_thread(addr): draw_plots = init_plots(plot_arr, name_to_arr_idx, plot_xlims, plot_ylims, plot_names, plot_colors, plot_styles) - vipc_client = VisionIpcClient("camerad", VisionStreamType.VISION_STREAM_RGB_BACK, True) + vipc_client = VisionIpcClient("camerad", VisionStreamType.VISION_STREAM_RGB_ROAD, True) while 1: list(pygame.event.get()) diff --git a/tools/sim/Dockerfile.sim b/tools/sim/Dockerfile.sim index 4ffd5bea1..2e36085b7 100644 --- a/tools/sim/Dockerfile.sim +++ b/tools/sim/Dockerfile.sim @@ -63,3 +63,5 @@ COPY ./tools $HOME/openpilot/tools WORKDIR $HOME/openpilot RUN scons -j$(nproc) + +RUN python -c "from selfdrive.test.helpers import set_params_enabled; set_params_enabled()" diff --git a/tools/sim/bridge.py b/tools/sim/bridge.py index 2e19faefc..13f10af9c 100755 --- a/tools/sim/bridge.py +++ b/tools/sim/bridge.py @@ -48,6 +48,7 @@ class VehicleState: self.vel = carla.Vector3D() self.cruise_button = 0 self.is_engaged = False + self.ignition = True def steer_rate_limit(old, new): @@ -67,7 +68,7 @@ class Camerad: self.vipc_server = VisionIpcServer("camerad") # TODO: remove RGB buffers once the last RGB vipc subscriber is removed - self.vipc_server.create_buffers(VisionStreamType.VISION_STREAM_RGB_BACK, 4, True, W, H) + self.vipc_server.create_buffers(VisionStreamType.VISION_STREAM_RGB_ROAD, 4, True, W, H) self.vipc_server.create_buffers(VisionStreamType.VISION_STREAM_ROAD, 40, False, W, H) self.vipc_server.start_listener() @@ -94,10 +95,10 @@ class Camerad: yuv_cl = cl_array.empty_like(rgb_cl) self.krnl(self.queue, (np.int32(self.Wdiv4), np.int32(self.Hdiv4)), None, rgb_cl.data, yuv_cl.data).wait() yuv = np.resize(yuv_cl.get(), np.int32(rgb.size / 2)) - eof = self.frame_id * 0.05 + eof = int(self.frame_id * 0.05 * 1e9) # TODO: remove RGB send once the last RGB vipc subscriber is removed - self.vipc_server.send(VisionStreamType.VISION_STREAM_RGB_BACK, img.tobytes(), self.frame_id, eof, eof) + self.vipc_server.send(VisionStreamType.VISION_STREAM_RGB_ROAD, img.tobytes(), self.frame_id, eof, eof) self.vipc_server.send(VisionStreamType.VISION_STREAM_ROAD, yuv.data.tobytes(), self.frame_id, eof, eof) dat = messaging.new_message('roadCameraState') @@ -126,13 +127,13 @@ def imu_callback(imu, vehicle_state): pm.send('sensorEvents', dat) -def panda_state_function(exit_event: threading.Event): +def panda_state_function(vs: VehicleState, exit_event: threading.Event): pm = messaging.PubMaster(['pandaStates']) while not exit_event.is_set(): dat = messaging.new_message('pandaStates', 1) dat.valid = True dat.pandaStates[0] = { - 'ignitionLine': True, + 'ignitionLine': vs.ignition, 'pandaType': "blackPanda", 'controlsAllowed': True, 'safetyModel': 'hondaNidec' @@ -283,7 +284,7 @@ def bridge(q): # launch fake car threads threads = [] exit_event = threading.Event() - threads.append(threading.Thread(target=panda_state_function, args=(exit_event,))) + threads.append(threading.Thread(target=panda_state_function, args=(vehicle_state, exit_event,))) threads.append(threading.Thread(target=peripheral_state_function, args=(exit_event,))) threads.append(threading.Thread(target=fake_driver_monitoring, args=(exit_event,))) threads.append(threading.Thread(target=can_function_runner, args=(vehicle_state, exit_event,))) @@ -346,6 +347,8 @@ def bridge(q): elif m[1] == "cancel": cruise_button = CruiseButtons.CANCEL is_openpilot_engaged = False + elif m[0] == "ignition": + vehicle_state.ignition = not vehicle_state.ignition elif m[0] == "quit": break diff --git a/tools/sim/lib/keyboard_ctrl.py b/tools/sim/lib/keyboard_ctrl.py index 08d120d61..1c50b9b89 100644 --- a/tools/sim/lib/keyboard_ctrl.py +++ b/tools/sim/lib/keyboard_ctrl.py @@ -53,6 +53,8 @@ def keyboard_poll_thread(q: 'Queue[str]'): q.put("brake_%f" % 1.0) elif c == 'd': q.put("steer_%f" % -0.15) + elif c == 'i': + q.put("ignition") elif c == 'q': q.put("quit") break diff --git a/tools/sim/lib/manual_ctrl.py b/tools/sim/lib/manual_ctrl.py index 7c47e2ba4..8f1bcc2b5 100755 --- a/tools/sim/lib/manual_ctrl.py +++ b/tools/sim/lib/manual_ctrl.py @@ -9,8 +9,8 @@ from typing import NoReturn # Iterate over the joystick devices. print('Available devices:') for fn in os.listdir('/dev/input'): - if fn.startswith('js'): - print(f' /dev/input/{fn}') + if fn.startswith('js'): + print(f' /dev/input/{fn}') # We'll store the states here. axis_states = {} @@ -18,74 +18,74 @@ button_states = {} # These constants were borrowed from linux/input.h axis_names = { - 0x00 : 'x', - 0x01 : 'y', - 0x02 : 'z', - 0x03 : 'rx', - 0x04 : 'ry', - 0x05 : 'rz', - 0x06 : 'trottle', - 0x07 : 'rudder', - 0x08 : 'wheel', - 0x09 : 'gas', - 0x0a : 'brake', - 0x10 : 'hat0x', - 0x11 : 'hat0y', - 0x12 : 'hat1x', - 0x13 : 'hat1y', - 0x14 : 'hat2x', - 0x15 : 'hat2y', - 0x16 : 'hat3x', - 0x17 : 'hat3y', - 0x18 : 'pressure', - 0x19 : 'distance', - 0x1a : 'tilt_x', - 0x1b : 'tilt_y', - 0x1c : 'tool_width', - 0x20 : 'volume', - 0x28 : 'misc', + 0x00 : 'x', + 0x01 : 'y', + 0x02 : 'z', + 0x03 : 'rx', + 0x04 : 'ry', + 0x05 : 'rz', + 0x06 : 'trottle', + 0x07 : 'rudder', + 0x08 : 'wheel', + 0x09 : 'gas', + 0x0a : 'brake', + 0x10 : 'hat0x', + 0x11 : 'hat0y', + 0x12 : 'hat1x', + 0x13 : 'hat1y', + 0x14 : 'hat2x', + 0x15 : 'hat2y', + 0x16 : 'hat3x', + 0x17 : 'hat3y', + 0x18 : 'pressure', + 0x19 : 'distance', + 0x1a : 'tilt_x', + 0x1b : 'tilt_y', + 0x1c : 'tool_width', + 0x20 : 'volume', + 0x28 : 'misc', } button_names = { - 0x120 : 'trigger', - 0x121 : 'thumb', - 0x122 : 'thumb2', - 0x123 : 'top', - 0x124 : 'top2', - 0x125 : 'pinkie', - 0x126 : 'base', - 0x127 : 'base2', - 0x128 : 'base3', - 0x129 : 'base4', - 0x12a : 'base5', - 0x12b : 'base6', - 0x12f : 'dead', - 0x130 : 'a', - 0x131 : 'b', - 0x132 : 'c', - 0x133 : 'x', - 0x134 : 'y', - 0x135 : 'z', - 0x136 : 'tl', - 0x137 : 'tr', - 0x138 : 'tl2', - 0x139 : 'tr2', - 0x13a : 'select', - 0x13b : 'start', - 0x13c : 'mode', - 0x13d : 'thumbl', - 0x13e : 'thumbr', - - 0x220 : 'dpad_up', - 0x221 : 'dpad_down', - 0x222 : 'dpad_left', - 0x223 : 'dpad_right', - - # XBox 360 controller uses these codes. - 0x2c0 : 'dpad_left', - 0x2c1 : 'dpad_right', - 0x2c2 : 'dpad_up', - 0x2c3 : 'dpad_down', + 0x120 : 'trigger', + 0x121 : 'thumb', + 0x122 : 'thumb2', + 0x123 : 'top', + 0x124 : 'top2', + 0x125 : 'pinkie', + 0x126 : 'base', + 0x127 : 'base2', + 0x128 : 'base3', + 0x129 : 'base4', + 0x12a : 'base5', + 0x12b : 'base6', + 0x12f : 'dead', + 0x130 : 'a', + 0x131 : 'b', + 0x132 : 'c', + 0x133 : 'x', + 0x134 : 'y', + 0x135 : 'z', + 0x136 : 'tl', + 0x137 : 'tr', + 0x138 : 'tl2', + 0x139 : 'tr2', + 0x13a : 'select', + 0x13b : 'start', + 0x13c : 'mode', + 0x13d : 'thumbl', + 0x13e : 'thumbr', + + 0x220 : 'dpad_up', + 0x221 : 'dpad_down', + 0x222 : 'dpad_left', + 0x223 : 'dpad_right', + + # XBox 360 controller uses these codes. + 0x2c0 : 'dpad_left', + 0x2c1 : 'dpad_right', + 0x2c2 : 'dpad_up', + 0x2c3 : 'dpad_down', } axis_map = [] @@ -118,18 +118,18 @@ def wheel_poll_thread(q: 'Queue[str]') -> NoReturn: ioctl(jsdev, 0x80406a32, buf) # JSIOCGAXMAP for _axis in buf[:num_axes]: - axis_name = axis_names.get(_axis, f'unknown(0x{_axis:02x})') - axis_map.append(axis_name) - axis_states[axis_name] = 0.0 + axis_name = axis_names.get(_axis, f'unknown(0x{_axis:02x})') + axis_map.append(axis_name) + axis_states[axis_name] = 0.0 # Get the button map. buf = array.array('H', [0] * 200) ioctl(jsdev, 0x80406a34, buf) # JSIOCGBTNMAP for btn in buf[:num_buttons]: - btn_name = button_names.get(btn, f'unknown(0x{btn:03x})') - button_map.append(btn_name) - button_states[btn_name] = 0 + btn_name = button_names.get(btn, f'unknown(0x{btn:03x})') + button_map.append(btn_name) + button_states[btn_name] = 0 print('%d axes found: %s' % (num_axes, ', '.join(axis_map))) print('%d buttons found: %s' % (num_buttons, ', '.join(button_map))) diff --git a/tools/sim/start_carla.sh b/tools/sim/start_carla.sh index 6418dacae..8b2725950 100755 --- a/tools/sim/start_carla.sh +++ b/tools/sim/start_carla.sh @@ -2,16 +2,16 @@ # Requires nvidia docker - https://github.com/NVIDIA/nvidia-docker if ! $(apt list --installed | grep -q nvidia-container-toolkit); then - if [ -z "$INSTALL" ]; then - echo "Nvidia docker is required. Re-run with INSTALL=1 to automatically install." - exit 0 - else + read -p "Nvidia docker is required. Do you want to install it now? (y/n)"; + if [ "${REPLY}" == "y" ]; then distribution=$(. /etc/os-release;echo $ID$VERSION_ID) echo $distribution curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list - sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit + sudo apt-get update && sudo apt-get install -y nvidia-docker2 # Also installs docker-ce and nvidia-container-toolkit sudo systemctl restart docker + else + exit 0 fi fi diff --git a/tools/ssh/README.md b/tools/ssh/README.md index 5c7f3519b..66f030de5 100644 --- a/tools/ssh/README.md +++ b/tools/ssh/README.md @@ -7,7 +7,7 @@ In order to SSH into your device, you'll need a GitHub account with SSH keys. Se * Enable SSH in your device's settings * Enter your GitHub username in the device's settings * Connect to your device - * Username: `root` (comma two) or `comma` (comma three) + * Username: `comma` (comma three) * Port: `22` or `8022` Here's an example command for connecting to your device using its tethered connection: diff --git a/tools/zookeeper/enable_and_wait.py b/tools/zookeeper/enable_and_wait.py index 398ef412b..6907e6017 100755 --- a/tools/zookeeper/enable_and_wait.py +++ b/tools/zookeeper/enable_and_wait.py @@ -1,12 +1,16 @@ #!/usr/bin/env python3 - import os import sys import time +from socket import gethostbyname, gaierror from tools.zookeeper import Zookeeper def is_online(ip): - return (os.system(f"ping -c 1 {ip} > /dev/null") == 0) + try: + addr = gethostbyname(ip) + return (os.system(f"ping -c 1 {addr} > /dev/null") == 0) + except gaierror: + return False if __name__ == "__main__": z = Zookeeper() diff --git a/update_requirements.sh b/update_requirements.sh index ac9472dca..94b14496f 100755 --- a/update_requirements.sh +++ b/update_requirements.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -e DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" @@ -45,10 +44,11 @@ echo "pip packages install..." pipenv install --dev --deploy --clear pyenv rehash -if [ -f "$DIR/.pre-commit-config.yaml" ]; then - echo "precommit install ..." - $RUN pre-commit install - [ -d "./xx" ] && (cd xx && $RUN pre-commit install) - [ -d "./notebooks" ] && (cd notebooks && $RUN pre-commit install) - echo "pre-commit hooks installed" -fi +echo "pre-commit hooks install..." +shopt -s nullglob +for f in .pre-commit-config.yaml */.pre-commit-config.yaml; do + cd $DIR/$(dirname $f) + if [ -e ".git" ]; then + $RUN pre-commit install + fi +done