Merge changes from topic "b37280010"

* changes:
  fused_location.h: vendor-only
  Add include/hardware/*.h symlinks.
  Split up headers.
This commit is contained in:
Steven Moreland 2023-06-22 23:48:23 +00:00 committed by Gerrit Code Review
commit db3bbfcbf1
101 changed files with 25442 additions and 25356 deletions

View file

@ -32,6 +32,7 @@ license {
cc_library_headers {
name: "libhardware_headers",
header_libs: [
"libaudio_system_headers",
"libsystem_headers",
@ -45,11 +46,22 @@ cc_library_headers {
"libbluetooth-types-header",
],
export_include_dirs: ["include"],
recovery_available: true,
vendor_available: true,
// TODO(b/153609531): remove when no longer needed.
native_bridge_supported: true,
// There are three include directories currently:
// - include: this directory is the original location of libhardware headers. It is globally
// available (even if you do not depend on libhardware). Many locations also use
// LOCAL_C_INCLUDES or include_dirs to access these from a global namespace. These processes
// should replace this dependency with a direct dependency on libhardware(_headers)?.
// - include_all: this directory is for system and vendor include files. Gradually, the number of
// files here should be reduced to 0 by moving them to vendor as old code is phased out.
// - include_vendor: this directory is the current designated resting place for these headers.
// They are kept around to try to help insure existing codebases can function.
export_include_dirs: ["include_all"],
target: {
recovery: {
exclude_header_libs: [
@ -60,6 +72,12 @@ cc_library_headers {
windows: {
enabled: true,
},
vendor: {
override_export_include_dirs: [
"include_all",
"include_vendor",
],
},
},
apex_available: [
"//apex_available:platform",

View file

@ -1,243 +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 <hardware/hardware.h>
__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.
*
* At the first detection after this function gets called, the hardware should know whether the
* user is in the activity.
* - If event_type is ACTIVITY_EVENT_ENTER and the user is in the activity, then an
* (ACTIVITY_EVENT_ENTER, activity) event should be added to the FIFO.
* - If event_type is ACTIVITY_EVENT_EXIT and the user is not in the activity, then an
* (ACTIVITY_EVENT_EXIT, activity) event should be added to the FIFO.
* For example, suppose get_supported_activities_list contains on_bicyle and running, and the
* user is biking. Consider the following four calls that could happen in any order.
* - When enable_activity_event(on_bicycle, ACTIVITY_EVENT_ENTER) is called,
* (ACTIVITY_EVENT_ENTER, on_bicycle) should be added to the FIFO.
* - When enable_activity_event(on_bicycle, ACTIVITY_EVENT_EXIT) is called, nothing should be
* added to the FIFO.
* - When enable_activity_event(running, ACTIVITY_EVENT_ENTER) is called, nothing should be
* added to the FIFO.
* - When enable_activity_event(running, ACTIVITY_EVENT_EXIT) is called,
* (ACTIVITY_EVENT_EXIT, running) should be added to the FIFO.
*
* 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. It should be
* either ACTIVITY_EVENT_ENTER or ACTIVITY_EVENT_EXIT.
* 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. All the (activity, event_type)
* events in the FIFO are discarded.
*/
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.
* activity_callback should be called before this function returns successfully.
* 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

View file

@ -0,0 +1 @@
../../include_all/hardware/activity_recognition.h

File diff suppressed because it is too large Load diff

1
include/hardware/audio.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/audio.h

View file

@ -1,103 +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 <log/log.h>
#include <system/audio.h>
#include <tinyalsa/asoundlib.h>
__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) {
#if 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 PCM_FORMAT_INVALID; /* doesn't get here, assert called above */
}
}
/* 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) {
#if 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 AUDIO_FORMAT_INVALID; /* doesn't get here, assert called above */
}
}
__END_DECLS
#endif /* ANDROID_AUDIO_ALSAOPS_H */

View file

@ -0,0 +1 @@
../../include_all/hardware/audio_alsaops.h

View file

@ -1,354 +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 <errno.h>
#include <stdint.h>
#include <strings.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <cutils/bitops.h>
#include <system/audio_effect.h>
__BEGIN_DECLS
/////////////////////////////////////////////////
// Common Definitions
/////////////////////////////////////////////////
#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;
// 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);
};
/////////////////////////////////////////////////
// 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 EFFECT_LIBRARY_API_VERSION_3_0 EFFECT_MAKE_API_VERSION(3,0)
#define EFFECT_LIBRARY_API_VERSION_3_1 EFFECT_MAKE_API_VERSION(3,1)
#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);
////////////////////////////////////////////////////////////////////////////////
//
// Function: create_effect_3_1
//
// 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
// deviceId: identifies the sink or source device this effect is directed to in
// audio HAL. Must be specified if sessionId is AUDIO_SESSION_DEVICE and is
// ignored otherwise.
// deviceId is the audio_port_handle_t used for the device when the audio
// patch is created at the audio HAL.
//
// 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_3_1)(const effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
int32_t deviceId,
effect_handle_t *pHandle);
} 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

View file

@ -0,0 +1 @@
../../include_all/hardware/audio_effect.h

View file

@ -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 <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
#include <system/audio.h>
#include <system/audio_policy.h>
__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,
audio_session_t 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,
audio_session_t 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,
audio_session_t 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,
audio_session_t 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

View file

@ -0,0 +1 @@
../../include_all/hardware/audio_policy.h

View file

@ -1,598 +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 <stdbool.h>
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <bluetooth/uuid.h>
#include <raw_address.h>
__BEGIN_DECLS
#define BLUETOOTH_INTERFACE_STRING "bluetoothInterface"
/** 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 BT_PROFILE_AV_RC_CTRL_ID "avrcp_ctrl"
/** Bluetooth test interface IDs */
#define BT_TEST_INTERFACE_MCAP_ID "mcap_test"
/** 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_JNI_ENVIRONMENT_ERROR,
BT_STATUS_JNI_THREAD_ATTACH_ERROR,
BT_STATUS_WAKELOCK_ERROR
} 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;
typedef struct {
int32_t app_uid;
uint64_t tx_bytes;
uint64_t rx_bytes;
} __attribute__((packed))bt_uid_traffic_t;
/** 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 SDP service record */
typedef struct
{
bluetooth::Uuid 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;
bool le_2m_phy_supported;
bool le_coded_phy_supported;
bool le_extended_advertising_supported;
bool le_periodic_advertising_supported;
uint16_t le_maximum_advertising_data_length;
}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 - RawAddress
*/
BT_PROPERTY_BDADDR,
/**
* Description - Bluetooth Service 128-bit UUIDs
* Access mode - Only GET.
* Data type - Array of bluetooth::Uuid (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 RawAddress 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;
/** Represents the actual Out of Band data itself */
typedef struct {
// Both
bool is_valid = false; /* Default to invalid data; force caller to verify */
uint8_t address[7]; /* Bluetooth Device Address (6) plus Address Type (1) */
uint8_t c[16]; /* Simple Pairing Hash C-192/256 (Classic or LE) */
uint8_t r[16]; /* Simple Pairing Randomizer R-192/256 (Classic or LE) */
uint8_t device_name[256]; /* Name of the device */
// Classic
uint8_t oob_data_length[2]; /* Classic only data Length. Value includes this
in length */
uint8_t class_of_device[2]; /* Class of Device (Classic or LE) */
// LE
uint8_t le_device_role; /* Supported and preferred role of device */
uint8_t sm_tk[16]; /* Security Manager TK Value (LE Only) */
uint8_t le_flags; /* LE Flags for discoverability and features */
uint8_t le_appearance[2]; /* For the appearance of the device */
} bt_oob_data_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,
RawAddress *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)(RawAddress *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)(RawAddress *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,
RawAddress *remote_bd_addr,
bt_bond_state_t state);
/** Bluetooth ACL connection state changed callback */
typedef void (*acl_state_changed_callback)(bt_status_t status, RawAddress *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);
/* 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
* uid_data provides an array of bt_uid_traffic_t, where the array is terminated by an element with
* app_uid set to -1.
*/
typedef void (*energy_info_callback)(bt_activity_energy_info *energy_info,
bt_uid_traffic_t *uid_data);
/** 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;
} 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.
* The |is_atv| flag indicates whether the local device is an Android TV
*/
int (*init)(bt_callbacks_t* callbacks, bool is_atv);
/** Enable Bluetooth. */
int (*enable)(bool guest_mode);
/** Disable Bluetooth. */
int (*disable)(void);
/** Closes the interface. */
void (*cleanup)(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
* RawAddress 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)(RawAddress *remote_addr);
/** Get Remote Device property of 'type' */
int (*get_remote_device_property)(RawAddress *remote_addr,
bt_property_type_t type);
/** Set Remote Device property of 'type' */
int (*set_remote_device_property)(RawAddress *remote_addr,
const bt_property_t *property);
/** Get Remote Device's service record for the given UUID */
int (*get_remote_service_record)(const RawAddress& remote_addr,
const bluetooth::Uuid& uuid);
/** Start SDP to get remote services */
int (*get_remote_services)(RawAddress *remote_addr);
/** Start Discovery */
int (*start_discovery)(void);
/** Cancel Discovery */
int (*cancel_discovery)(void);
/** Create Bluetooth Bonding */
int (*create_bond)(const RawAddress *bd_addr, int transport);
/** Create Bluetooth Bond using out of band data */
int (*create_bond_out_of_band)(const RawAddress *bd_addr, int transport,
const bt_oob_data_t *p192_data,
const bt_oob_data_t *p256_data);
/** Remove Bond */
int (*remove_bond)(const RawAddress *bd_addr);
/** Cancel Bond */
int (*cancel_bond)(const RawAddress *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 RawAddress *bd_addr);
/** BT Legacy PinKey Reply */
/** If accept==FALSE, then pin_len and pin_code shall be 0x0 */
int (*pin_reply)(const RawAddress *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 RawAddress *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);
/** 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);
/** 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.
* |arguments| are arguments which may affect the output, encoded as
* UTF-8 strings.
*/
void (*dump)(int fd, const char **arguments);
/**
* Clear /data/misc/bt_config.conf and erase all stored connections
*/
int (*config_clear)(void);
/**
* 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 RawAddress *addr, size_t len);
} bt_interface_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_BLUETOOTH_H */

View file

@ -0,0 +1 @@
../../include_all/hardware/bluetooth.h

View file

@ -1,141 +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_BOOT_CONTROL_H
#define ANDROID_INCLUDE_HARDWARE_BOOT_CONTROL_H
#include <hardware/hardware.h>
__BEGIN_DECLS
#define BOOT_CONTROL_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
/**
* The id of this module
*/
#define BOOT_CONTROL_HARDWARE_MODULE_ID "bootctrl"
/*
* The Boot Control HAL is designed to allow for managing sets of redundant
* partitions, called slots, that can be booted from independantly. Slots
* are sets of partitions whose names differ only by a given suffix.
* They are identified here by a 0 indexed number, and associated with their
* suffix, which can be appended to the base name for any particular partition
* to find the one associated with that slot. The bootloader must pass the suffix
* of the currently active slot either through a kernel command line property at
* androidboot.slot_suffix, or the device tree at /firmware/android/slot_suffix.
* The primary use of this set up is to allow for background updates while the
* device is running, and to provide a fallback in the event that the update fails.
*/
/**
* 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 boot_control_module {
struct hw_module_t common;
/*
* (*init)() perform any initialization tasks needed for the HAL.
* This is called only once.
*/
void (*init)(struct boot_control_module *module);
/*
* (*getNumberSlots)() returns the number of available slots.
* For instance, a system with a single set of partitions would return
* 1, a system with A/B would return 2, A/B/C -> 3...
*/
unsigned (*getNumberSlots)(struct boot_control_module *module);
/*
* (*getCurrentSlot)() returns the value letting the system know
* whether the current slot is A or B. The meaning of A and B is
* left up to the implementer. It is assumed that if the current slot
* is A, then the block devices underlying B can be accessed directly
* without any risk of corruption.
* The returned value is always guaranteed to be strictly less than the
* value returned by getNumberSlots. Slots start at 0 and
* finish at getNumberSlots() - 1
*/
unsigned (*getCurrentSlot)(struct boot_control_module *module);
/*
* (*markBootSuccessful)() marks the current slot
* as having booted successfully
*
* Returns 0 on success, -errno on error.
*/
int (*markBootSuccessful)(struct boot_control_module *module);
/*
* (*setActiveBootSlot)() marks the slot passed in parameter as
* the active boot slot (see getCurrentSlot for an explanation
* of the "slot" parameter). This overrides any previous call to
* setSlotAsUnbootable.
* Returns 0 on success, -errno on error.
*/
int (*setActiveBootSlot)(struct boot_control_module *module, unsigned slot);
/*
* (*setSlotAsUnbootable)() marks the slot passed in parameter as
* an unbootable. This can be used while updating the contents of the slot's
* partitions, so that the system will not attempt to boot a known bad set up.
* Returns 0 on success, -errno on error.
*/
int (*setSlotAsUnbootable)(struct boot_control_module *module, unsigned slot);
/*
* (*isSlotBootable)() returns if the slot passed in parameter is
* bootable. Note that slots can be made unbootable by both the
* bootloader and by the OS using setSlotAsUnbootable.
* Returns 1 if the slot is bootable, 0 if it's not, and -errno on
* error.
*/
int (*isSlotBootable)(struct boot_control_module *module, unsigned slot);
/*
* (*getSuffix)() returns the string suffix used by partitions that
* correspond to the slot number passed in parameter. The returned string
* is expected to be statically allocated and not need to be freed.
* Returns NULL if slot does not match an existing slot.
*/
const char* (*getSuffix)(struct boot_control_module *module, unsigned slot);
/*
* (*isSlotMarkedSucessful)() returns if the slot passed in parameter has
* been marked as successful using markBootSuccessful.
* Returns 1 if the slot has been marked as successful, 0 if it's
* not the case, and -errno on error.
*/
int (*isSlotMarkedSuccessful)(struct boot_control_module *module, unsigned slot);
/**
* Returns the active slot to boot into on the next boot. If
* setActiveBootSlot() has been called, the getter function should return
* the same slot as the one provided in the last setActiveBootSlot() call.
*/
unsigned (*getActiveBootSlot)(struct boot_control_module *module);
void* reserved[30];
} boot_control_module_t;
__END_DECLS
#endif // ANDROID_INCLUDE_HARDWARE_BOOT_CONTROL_H

View file

@ -0,0 +1 @@
../../include_all/hardware/boot_control.h

View file

@ -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 */

1
include/hardware/camera.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/camera.h

View file

@ -1,842 +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 ]
*
* NO LONGER SUPPORTED. The camera service will no longer load HAL modules that
* contain HAL v2.0 or v2.1 devices.
*
* 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;
} camera2_jpeg_blob_t;
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 */

1
include/hardware/camera2.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/camera2.h

File diff suppressed because it is too large Load diff

1
include/hardware/camera3.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/camera3.h

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
../../include_all/hardware/camera_common.h

View file

@ -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 <stdint.h>
#include <sys/cdefs.h>
#include <hardware/hardware.h>
#include <hardware/hwcomposer_defs.h>
#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 */

View file

@ -0,0 +1 @@
../../include_all/hardware/consumerir.h

View file

@ -1,450 +0,0 @@
/*
* Copyright (C) 2016 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 CONTEXT_HUB_H
#define CONTEXT_HUB_H
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
/**
* This header file defines the interface of a Context Hub Implementation to
* the Android service exposing Context hub capabilities to applications.
* The Context hub is expected to a low power compute domain with the following
* defining charecteristics -
*
* 1) Access to sensors like accelerometer, gyroscope, magenetometer.
* 2) Access to radios like GPS, Wifi, Bluetooth etc.
* 3) Access to low power audio sensing.
*
* Implementations of this HAL can add additional sensors not defined by the
* Android API. Such information sources shall be private to the implementation.
*
* The Context Hub HAL exposes the construct of code download. A piece of binary
* code can be pushed to the context hub through the supported APIs.
*
* This version of the HAL designs in the possibility of multiple context hubs.
*/
__BEGIN_DECLS
/*****************************************************************************/
#define CONTEXT_HUB_HEADER_MAJOR_VERSION 1
#define CONTEXT_HUB_HEADER_MINOR_VERSION 1
#define CONTEXT_HUB_DEVICE_API_VERSION \
HARDWARE_DEVICE_API_VERSION(CONTEXT_HUB_HEADER_MAJOR_VERSION, \
CONTEXT_HUB_HEADER_MINOR_VERSION)
#define CONTEXT_HUB_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
#define CONTEXT_HUB_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1)
/**
* The id of this module
*/
#define CONTEXT_HUB_MODULE_ID "context_hub"
/**
* Name of the device to open
*/
#define CONTEXT_HUB_HARDWARE_POLL "ctxt_poll"
/**
* Memory types for code upload. Device-specific. At least HUB_MEM_TYPE_MAIN must be supported
*/
#define HUB_MEM_TYPE_MAIN 0
#define HUB_MEM_TYPE_SECONDARY 1
#define HUB_MEM_TYPE_TCM 2
#define HUB_MEM_TYPE_FIRST_VENDOR 0x80000000ul
#define NANOAPP_VENDORS_ALL 0xFFFFFFFFFF000000ULL
#define NANOAPP_VENDOR_ALL_APPS 0x0000000000FFFFFFULL
#define NANOAPP_VENDOR(name) \
(((uint64_t)(name)[0] << 56) | \
((uint64_t)(name)[1] << 48) | \
((uint64_t)(name)[2] << 40) | \
((uint64_t)(name)[3] << 32) | \
((uint64_t)(name)[4] << 24))
/*
* generates the NANOAPP ID from vendor id and app seq# id
*/
#define NANO_APP_ID(vendor, seq_id) \
(((uint64_t)(vendor) & NANOAPP_VENDORS_ALL) | ((uint64_t)(seq_id) & NANOAPP_VENDOR_ALL_APPS))
struct hub_app_name_t {
uint64_t id;
};
/**
* Other memory types (likely not writeable, informational only)
*/
#define HUB_MEM_TYPE_BOOTLOADER 0xfffffffful
#define HUB_MEM_TYPE_OS 0xfffffffeul
#define HUB_MEM_TYPE_EEDATA 0xfffffffdul
#define HUB_MEM_TYPE_RAM 0xfffffffcul
/**
* Types of memory blocks on the context hub
* */
#define MEM_FLAG_READ 0x1 // Memory can be written to
#define MEM_FLAG_WRITE 0x2 // Memory can be written to
#define MEM_FLAG_EXEC 0x4 // Memory can be executed from
/**
* The following structure defines each memory block in detail
*/
struct mem_range_t {
uint32_t total_bytes;
uint32_t free_bytes;
uint32_t type; // HUB_MEM_TYPE_*
uint32_t mem_flags; // MEM_FLAG_*
};
#define NANOAPP_SIGNED_FLAG 0x1
#define NANOAPP_ENCRYPTED_FLAG 0x2
#define NANOAPP_MAGIC (((uint32_t)'N' << 0) | ((uint32_t)'A' << 8) | ((uint32_t)'N' << 16) | ((uint32_t)'O' << 24))
// The binary format below is in little endian format
struct nano_app_binary_t {
uint32_t header_version; // 0x1 for this version
uint32_t magic; // "NANO"
struct hub_app_name_t app_id; // App Id contains vendor id
uint32_t app_version; // Version of the app
uint32_t flags; // Signed, encrypted
uint64_t hw_hub_type; // which hub type is this compiled for
// The version of the CHRE API that this nanoapp was compiled against.
// If these values are both set to 0, then they must be interpreted the same
// as if major version were set to 1, and minor 0 (the first valid CHRE API
// version).
uint8_t target_chre_api_major_version;
uint8_t target_chre_api_minor_version;
uint8_t reserved[6]; // Should be all zeroes
uint8_t custom_binary[0]; // start of custom binary data
} __attribute__((packed));
struct hub_app_info {
struct hub_app_name_t app_name;
uint32_t version;
uint32_t num_mem_ranges;
struct mem_range_t mem_usage[2]; // Apps could only have RAM and SHARED_DATA
};
/**
* Following enum defines the types of sensors that a hub may declare support
* for. Declaration for support would mean that the hub can access and process
* data from that particular sensor type.
*/
typedef enum {
CONTEXT_SENSOR_RESERVED, // 0
CONTEXT_SENSOR_ACCELEROMETER, // 1
CONTEXT_SENSOR_GYROSCOPE, // 2
CONTEXT_SENSOR_MAGNETOMETER, // 3
CONTEXT_SENSOR_BAROMETER, // 4
CONTEXT_SENSOR_PROXIMITY_SENSOR, // 5
CONTEXT_SENSOR_AMBIENT_LIGHT_SENSOR, // 6
CONTEXT_SENSOR_GPS = 0x100, // 0x100
// Reserving this space for variants on GPS
CONTEXT_SENSOR_WIFI = 0x200, // 0x200
// Reserving this space for variants on WIFI
CONTEXT_SENSOR_AUDIO = 0x300, // 0x300
// Reserving this space for variants on Audio
CONTEXT_SENSOR_CAMERA = 0x400, // 0x400
// Reserving this space for variants on Camera
CONTEXT_SENSOR_BLE = 0x500, // 0x500
CONTEXT_SENSOR_MAX = 0xffffffff, //make sure enum size is set
} context_sensor_e;
/**
* Sensor types beyond CONTEXT_HUB_TYPE_PRIVATE_SENSOR_BASE are custom types
*/
#define CONTEXT_HUB_TYPE_PRIVATE_SENSOR_BASE 0x10000
/**
* The following structure describes a sensor
*/
struct physical_sensor_description_t {
uint32_t sensor_type; // From the definitions above eg: 100
const char *type_string; // Type as a string. eg: "GPS"
const char *name; // Identifier eg: "Bosch BMI160"
const char *vendor; // Vendor : eg "STM"
uint32_t version; // Version : eg 0x1001
uint32_t fifo_reserved_count; // Batching possible in hardware. Please
// note that here hardware does not include
// the context hub itself. Thus, this
// definition may be different from say the
// number advertised in the sensors HAL
// which allows for batching in a hub.
uint32_t fifo_max_count; // maximum number of batchable events.
uint64_t min_delay_ms; // in milliseconds, corresponding to highest
// sampling freq.
uint64_t max_delay_ms; // in milliseconds, corresponds to minimum
// sampling frequency
float peak_power_mw; // At max frequency & no batching, power
// in milliwatts
};
struct connected_sensor_t {
uint32_t sensor_id; // identifier for this sensor
/* This union may be extended to other sensor types */
union {
struct physical_sensor_description_t physical_sensor;
};
};
struct hub_message_t {
struct hub_app_name_t app_name; /* To/From this nanoapp */
uint32_t message_type;
uint32_t message_len;
const void *message;
};
/**
* Definition of a context hub. A device may contain more than one low
* power domain. In that case, please add an entry for each hub. However,
* it is perfectly OK for a device to declare one context hub and manage
* them internally as several
*/
struct context_hub_t {
const char *name; // descriptive name eg: "Awesome Hub #1"
const char *vendor; // hub hardware vendor eg: "Qualcomm"
const char *toolchain; // toolchain to make binaries eg:"gcc ARM"
uint32_t platform_version; // Version of the hardware : eg 0x20
uint32_t toolchain_version; // Version of the toolchain : eg: 0x484
uint32_t hub_id; // a device unique id for this hub
float peak_mips; // Peak MIPS platform can deliver
float stopped_power_draw_mw; // if stopped, retention power, milliwatts
float sleep_power_draw_mw; // if sleeping, retention power, milliwatts
float peak_power_draw_mw; // for a busy CPUm power in milliwatts
const struct connected_sensor_t *connected_sensors; // array of connected sensors
uint32_t num_connected_sensors; // number of connected sensors
const struct hub_app_name_t os_app_name; /* send msgs here for OS functions */
uint32_t max_supported_msg_len; // This is the maximum size of the message that can
// be sent to the hub in one chunk (in bytes)
};
/**
* Definitions of message payloads, see hub_messages_e
*/
struct status_response_t {
int32_t result; // 0 on success, < 0 : error on failure. > 0 for any descriptive status
};
struct apps_enable_request_t {
struct hub_app_name_t app_name;
};
struct apps_disable_request_t {
struct hub_app_name_t app_name;
};
struct load_app_request_t {
struct nano_app_binary_t app_binary;
};
struct unload_app_request_t {
struct hub_app_name_t app_name;
};
struct query_apps_request_t {
struct hub_app_name_t app_name;
};
/**
* CONTEXT_HUB_APPS_ENABLE
* Enables the specified nano-app(s)
*
* Payload : apps_enable_request_t
*
* Response : status_response_t
* On receipt of a successful response, it is
* expected that
*
* i) the app is executing and able to receive
* any messages.
*
* ii) the system should be able to respond to an
* CONTEXT_HUB_QUERY_APPS request.
*
*/
/**
* CONTEXT_HUB_APPS_DISABLE
* Stops the specified nano-app(s)
*
* Payload : apps_disable_request_t
*
* Response : status_response_t
* On receipt of a successful response,
* i) No further events are delivered to the
* nanoapp.
*
* ii) The app should not show up in a
* CONTEXT_HUB_QUERY_APPS request.
*/
/**
* CONTEXT_HUB_LOAD_APP
* Loads a nanoApp. Upon loading the nanoApp's init method is
* called.
*
*
* Payload : load_app_request_t
*
* Response : status_response_t On receipt of a successful
* response, it is expected that
* i) the app is executing and able to receive
* messages.
*
* ii) the system should be able to respond to a
* CONTEXT_HUB_QUERY_APPS.
*/
/**
* CONTEXT_HUB_UNLOAD_APP
* Unloads a nanoApp. Before the unload, the app's deinit method
* is called.
*
* Payload : unload_app_request_t.
*
* Response : status_response_t On receipt of a
* successful response, it is expected that
* i) No further events are delivered to the
* nanoapp.
*
* ii) the system does not list the app in a
* response to a CONTEXT_HUB_QUERY_APPS.
*
* iii) Any resources used by the app should be
* freed up and available to the system.
*/
/**
* CONTEXT_HUB_QUERY_APPS Queries for status of apps
*
* Payload : query_apps_request_t
*
* Response : struct hub_app_info[]
*/
/**
* CONTEXT_HUB_QUERY_MEMORY Queries for memory regions on the
* hub
*
* Payload : NULL
*
* Response : struct mem_range_t[]
*/
/**
* CONTEXT_HUB_OS_REBOOT
* Reboots context hub OS, restarts all the nanoApps.
* No reboot notification is sent to nanoApps; reboot happens immediately and
* unconditionally; all volatile FW state and any data is lost as a result
*
* Payload : none
*
* Response : status_response_t
* On receipt of a successful response, it is
* expected that
*
* i) system reboot has completed;
* status contains reboot reason code (platform-specific)
*
* Unsolicited response:
* System may send unsolicited response at any time;
* this should be interpreted as FW reboot, and necessary setup
* has to be done (same or similar to the setup done on system boot)
*/
/**
* All communication between the context hubs and the Context Hub Service is in
* the form of messages. Some message types are distinguished and their
* Semantics shall be well defined.
* Custom message types should be defined starting above
* CONTEXT_HUB_PRIVATE_MSG_BASE
*/
typedef enum {
CONTEXT_HUB_APPS_ENABLE = 1, // Enables loaded nano-app(s)
CONTEXT_HUB_APPS_DISABLE = 2, // Disables loaded nano-app(s)
CONTEXT_HUB_LOAD_APP = 3, // Load a supplied app
CONTEXT_HUB_UNLOAD_APP = 4, // Unload a specified app
CONTEXT_HUB_QUERY_APPS = 5, // Query for app(s) info on hub
CONTEXT_HUB_QUERY_MEMORY = 6, // Query for memory info
CONTEXT_HUB_OS_REBOOT = 7, // Request to reboot context HUB OS
} hub_messages_e;
#define CONTEXT_HUB_TYPE_PRIVATE_MSG_BASE 0x00400
/**
* A callback registers with the context hub service to pass messages
* coming from the hub to the service/clients.
*/
typedef int context_hub_callback(uint32_t hub_id, const struct hub_message_t *rxed_msg, void *cookie);
/**
* 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 context_hub_module_t {
struct hw_module_t common;
/**
* Enumerate all available hubs.The list is returned in "list".
* @return result : number of hubs in list or error (negative)
*
* This method shall be called at device bootup.
*/
int (*get_hubs)(struct context_hub_module_t* module, const struct context_hub_t ** list);
/**
* Registers a callback for the HAL implementation to communicate
* with the context hub service.
* @return result : 0 if successful, error code otherwise
*/
int (*subscribe_messages)(uint32_t hub_id, context_hub_callback cbk, void *cookie);
/**
* Send a message to a hub
* @return result : 0 if successful, error code otherwise
*/
int (*send_message)(uint32_t hub_id, const struct hub_message_t *msg);
};
__END_DECLS
#endif // CONTEXT_HUB_SENSORS_INTERFACE_H

View file

@ -0,0 +1 @@
../../include_all/hardware/context_hub.h

View file

@ -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 <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <cutils/native_handle.h>
#include <hardware/hardware.h>
__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 <buffer> 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, TO_HW_DEVICE_T_OPEN(device));
}
static inline int framebuffer_close(struct framebuffer_device_t* device) {
return device->common.close(&device->common);
}
__END_DECLS
#endif // ANDROID_FB_INTERFACE_H

1
include/hardware/fb.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/fb.h

View file

@ -1,277 +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 <hardware/hardware.h>
#include <hardware/hw_auth_token.h>
#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_MODULE_API_VERSION_2_1 HARDWARE_MODULE_API_VERSION(2, 1)
#define FINGERPRINT_MODULE_API_VERSION_3_0 HARDWARE_MODULE_API_VERSION(3, 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_TEMPLATE_ENUMERATING = 6,
} 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_LOCKOUT = 7, /* the fingerprint hardware is in lockout due to too many attempts */
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_DETECTED = 6, /* when the finger is first detected. Used to optimize wakeup.
Should be followed by one of the above messages */
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_iterator {
fingerprint_finger_id_t finger;
uint32_t remaining_templates;
} fingerprint_iterator_t;
typedef fingerprint_iterator_t fingerprint_enumerated_t;
typedef fingerprint_iterator_t 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_enumerated_t enumerated;
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()
* For each template found a notify() will be called with:
* fingerprint_msg.type == FINGERPRINT_TEMPLATE_ENUMERATED
* fingerprint_msg.data.enumerated.finger indicating a template id
* fingerprint_msg.data.enumerated.remaining_templates indicating how many more
* enumeration messages to expect.
* Note: If there are no fingerprints, then this should return 0 and the first fingerprint
* enumerated should have fingerid=0 and remaining=0
* Function return: 0 if enumerate request is accepted
* or a negative number in case of error, generally from the errno.h set.
*/
int (*enumerate)(struct fingerprint_device *dev);
/*
* Fingerprint remove request:
* Deletes a fingerprint template.
* Works only within the path set by set_active_group().
* The fid parameter can be used as a widcard:
* * fid == 0 -- delete all the templates in the group.
* * fid != 0 -- delete this specific template from the group.
* For each template found a notify() will be called with:
* fingerprint_msg.type == FINGERPRINT_TEMPLATE_REMOVED
* fingerprint_msg.data.removed.finger indicating a template id deleted
* fingerprint_msg.data.removed.remaining_templates indicating how many more
* templates will be deleted by this operation.
*
* 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 */

View file

@ -0,0 +1 @@
../../include_all/hardware/fingerprint.h

View file

@ -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 <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
__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

View file

@ -0,0 +1 @@
../../include_all/hardware/gatekeeper.h

View file

@ -1,276 +0,0 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
// Source: android.hardware.gnss@1.0
// Location: hardware/interfaces/gnss/1.0/
#ifndef HIDL_GENERATED_ANDROID_HARDWARE_GNSS_V1_0_EXPORTED_CONSTANTS_H_
#define HIDL_GENERATED_ANDROID_HARDWARE_GNSS_V1_0_EXPORTED_CONSTANTS_H_
#ifdef __cplusplus
extern "C" {
#endif
enum {
GNSS_MAX_SVS_COUNT = 64u,
};
enum {
GNSS_CONSTELLATION_UNKNOWN = 0,
GNSS_CONSTELLATION_GPS = 1,
GNSS_CONSTELLATION_SBAS = 2,
GNSS_CONSTELLATION_GLONASS = 3,
GNSS_CONSTELLATION_QZSS = 4,
GNSS_CONSTELLATION_BEIDOU = 5,
GNSS_CONSTELLATION_GALILEO = 6,
};
enum {
GPS_LOCATION_HAS_LAT_LONG = 1 /* 0x0001 */,
GPS_LOCATION_HAS_ALTITUDE = 2 /* 0x0002 */,
GPS_LOCATION_HAS_SPEED = 4 /* 0x0004 */,
GPS_LOCATION_HAS_BEARING = 8 /* 0x0008 */,
GPS_LOCATION_HAS_HORIZONTAL_ACCURACY = 16 /* 0x0010 */,
GPS_LOCATION_HAS_VERTICAL_ACCURACY = 32 /* 0x0020 */,
GPS_LOCATION_HAS_SPEED_ACCURACY = 64 /* 0x0040 */,
GPS_LOCATION_HAS_BEARING_ACCURACY = 128 /* 0x0080 */,
};
enum {
APN_IP_INVALID = 0,
APN_IP_IPV4 = 1,
APN_IP_IPV6 = 2,
APN_IP_IPV4V6 = 3,
};
enum {
AGPS_TYPE_SUPL = 1,
AGPS_TYPE_C2K = 2,
};
enum {
GNSS_REQUEST_AGNSS_DATA_CONN = 1,
GNSS_RELEASE_AGNSS_DATA_CONN = 2,
GNSS_AGNSS_DATA_CONNECTED = 3,
GNSS_AGNSS_DATA_CONN_DONE = 4,
GNSS_AGNSS_DATA_CONN_FAILED = 5,
};
enum {
AGPS_SETID_TYPE_NONE = 0,
AGPS_SETID_TYPE_IMSI = 1,
AGPS_SETID_TYPE_MSISDM = 2,
};
enum {
AGPS_RIL_NETWORK_TYPE_MOBILE = 0,
AGPS_RIL_NETWORK_TYPE_WIFI = 1,
AGPS_RIL_NETWORK_TYPE_MMS = 2,
AGPS_RIL_NETWORK_TYPE_SUPL = 3,
AGPS_RIL_NETWORK_TYPE_DUN = 4,
AGPS_RIL_NETWORK_TYPE_HIPRI = 5,
AGPS_RIL_NETWORK_TYPE_WIMAX = 6,
};
enum {
AGPS_REF_LOCATION_TYPE_GSM_CELLID = 1,
AGPS_REF_LOCATION_TYPE_UMTS_CELLID = 2,
AGPS_REF_LOCATION_TYPE_LTE_CELLID = 4,
};
enum {
AGPS_RIL_REQUEST_SETID_IMSI = 1u /* (1 << 0L) */,
AGPS_RIL_REQUEST_SETID_MSISDN = 2u /* (1 << 1L) */,
};
enum {
GPS_POSITION_MODE_STANDALONE = 0,
GPS_POSITION_MODE_MS_BASED = 1,
GPS_POSITION_MODE_MS_ASSISTED = 2,
};
enum {
GPS_POSITION_RECURRENCE_PERIODIC = 0u,
GPS_POSITION_RECURRENCE_SINGLE = 1u,
};
enum {
GPS_DELETE_EPHEMERIS = 1 /* 0x0001 */,
GPS_DELETE_ALMANAC = 2 /* 0x0002 */,
GPS_DELETE_POSITION = 4 /* 0x0004 */,
GPS_DELETE_TIME = 8 /* 0x0008 */,
GPS_DELETE_IONO = 16 /* 0x0010 */,
GPS_DELETE_UTC = 32 /* 0x0020 */,
GPS_DELETE_HEALTH = 64 /* 0x0040 */,
GPS_DELETE_SVDIR = 128 /* 0x0080 */,
GPS_DELETE_SVSTEER = 256 /* 0x0100 */,
GPS_DELETE_SADATA = 512 /* 0x0200 */,
GPS_DELETE_RTI = 1024 /* 0x0400 */,
GPS_DELETE_CELLDB_INFO = 32768 /* 0x8000 */,
GPS_DELETE_ALL = 65535 /* 0xFFFF */,
};
enum {
FLP_BATCH_WAKEUP_ON_FIFO_FULL = 1 /* 0x01 */,
};
enum {
GPS_CAPABILITY_SCHEDULING = 1u /* (1 << 0) */,
GPS_CAPABILITY_MSB = 2u /* (1 << 1) */,
GPS_CAPABILITY_MSA = 4u /* (1 << 2) */,
GPS_CAPABILITY_SINGLE_SHOT = 8u /* (1 << 3) */,
GPS_CAPABILITY_ON_DEMAND_TIME = 16u /* (1 << 4) */,
GPS_CAPABILITY_GEOFENCING = 32u /* (1 << 5) */,
GPS_CAPABILITY_MEASUREMENTS = 64u /* (1 << 6) */,
GPS_CAPABILITY_NAV_MESSAGES = 128u /* (1 << 7) */,
};
enum {
GPS_STATUS_NONE = 0,
GPS_STATUS_SESSION_BEGIN = 1,
GPS_STATUS_SESSION_END = 2,
GPS_STATUS_ENGINE_ON = 3,
GPS_STATUS_ENGINE_OFF = 4,
};
enum {
GNSS_SV_FLAGS_NONE = 0,
GNSS_SV_FLAGS_HAS_EPHEMERIS_DATA = 1 /* (1 << 0) */,
GNSS_SV_FLAGS_HAS_ALMANAC_DATA = 2 /* (1 << 1) */,
GNSS_SV_FLAGS_USED_IN_FIX = 4 /* (1 << 2) */,
GNSS_SV_FLAGS_HAS_CARRIER_FREQUENCY = 8 /* (1 << 3) */,
};
enum {
GPS_GEOFENCE_ENTERED = 1 /* (1 << 0L) */,
GPS_GEOFENCE_EXITED = 2 /* (1 << 1L) */,
GPS_GEOFENCE_UNCERTAIN = 4 /* (1 << 2L) */,
};
enum {
GPS_GEOFENCE_UNAVAILABLE = 1 /* (1 << 0L) */,
GPS_GEOFENCE_AVAILABLE = 2 /* (1 << 1L) */,
};
enum {
GPS_GEOFENCE_OPERATION_SUCCESS = 0,
GPS_GEOFENCE_ERROR_TOO_MANY_GEOFENCES = -100 /* (-100) */,
GPS_GEOFENCE_ERROR_ID_EXISTS = -101 /* (-101) */,
GPS_GEOFENCE_ERROR_ID_UNKNOWN = -102 /* (-102) */,
GPS_GEOFENCE_ERROR_INVALID_TRANSITION = -103 /* (-103) */,
GPS_GEOFENCE_ERROR_GENERIC = -149 /* (-149) */,
};
enum {
GPS_MEASUREMENT_SUCCESS = 0,
GPS_MEASUREMENT_ERROR_ALREADY_INIT = -100 /* (-100) */,
GPS_MEASUREMENT_ERROR_GENERIC = -101 /* (-101) */,
};
enum {
GNSS_CLOCK_HAS_LEAP_SECOND = 1 /* (1 << 0) */,
GNSS_CLOCK_HAS_TIME_UNCERTAINTY = 2 /* (1 << 1) */,
GNSS_CLOCK_HAS_FULL_BIAS = 4 /* (1 << 2) */,
GNSS_CLOCK_HAS_BIAS = 8 /* (1 << 3) */,
GNSS_CLOCK_HAS_BIAS_UNCERTAINTY = 16 /* (1 << 4) */,
GNSS_CLOCK_HAS_DRIFT = 32 /* (1 << 5) */,
GNSS_CLOCK_HAS_DRIFT_UNCERTAINTY = 64 /* (1 << 6) */,
};
enum {
GNSS_MEASUREMENT_HAS_SNR = 1u /* (1 << 0) */,
GNSS_MEASUREMENT_HAS_CARRIER_FREQUENCY = 512u /* (1 << 9) */,
GNSS_MEASUREMENT_HAS_CARRIER_CYCLES = 1024u /* (1 << 10) */,
GNSS_MEASUREMENT_HAS_CARRIER_PHASE = 2048u /* (1 << 11) */,
GNSS_MEASUREMENT_HAS_CARRIER_PHASE_UNCERTAINTY = 4096u /* (1 << 12) */,
GNSS_MEASUREMENT_HAS_AUTOMATIC_GAIN_CONTROL = 8192u /* (1 << 13) */,
};
enum {
GNSS_MULTIPATH_INDICATOR_UNKNOWN = 0,
GNSS_MULTIPATH_INDICATOR_PRESENT = 1,
GNSS_MULTIPATH_INDICATIOR_NOT_PRESENT = 2,
};
enum {
GNSS_MEASUREMENT_STATE_UNKNOWN = 0u,
GNSS_MEASUREMENT_STATE_CODE_LOCK = 1u /* (1 << 0) */,
GNSS_MEASUREMENT_STATE_BIT_SYNC = 2u /* (1 << 1) */,
GNSS_MEASUREMENT_STATE_SUBFRAME_SYNC = 4u /* (1 << 2) */,
GNSS_MEASUREMENT_STATE_TOW_DECODED = 8u /* (1 << 3) */,
GNSS_MEASUREMENT_STATE_MSEC_AMBIGUOUS = 16u /* (1 << 4) */,
GNSS_MEASUREMENT_STATE_SYMBOL_SYNC = 32u /* (1 << 5) */,
GNSS_MEASUREMENT_STATE_GLO_STRING_SYNC = 64u /* (1 << 6) */,
GNSS_MEASUREMENT_STATE_GLO_TOD_DECODED = 128u /* (1 << 7) */,
GNSS_MEASUREMENT_STATE_BDS_D2_BIT_SYNC = 256u /* (1 << 8) */,
GNSS_MEASUREMENT_STATE_BDS_D2_SUBFRAME_SYNC = 512u /* (1 << 9) */,
GNSS_MEASUREMENT_STATE_GAL_E1BC_CODE_LOCK = 1024u /* (1 << 10) */,
GNSS_MEASUREMENT_STATE_GAL_E1C_2ND_CODE_LOCK = 2048u /* (1 << 11) */,
GNSS_MEASUREMENT_STATE_GAL_E1B_PAGE_SYNC = 4096u /* (1 << 12) */,
GNSS_MEASUREMENT_STATE_SBAS_SYNC = 8192u /* (1 << 13) */,
GNSS_MEASUREMENT_STATE_TOW_KNOWN = 16384u /* (1 << 14) */,
GNSS_MEASUREMENT_STATE_GLO_TOD_KNOWN = 32768u /* (1 << 15) */,
};
enum {
GNSS_ADR_STATE_UNKNOWN = 0,
GNSS_ADR_STATE_VALID = 1 /* (1 << 0) */,
GNSS_ADR_STATE_RESET = 2 /* (1 << 1) */,
GNSS_ADR_STATE_CYCLE_SLIP = 4 /* (1 << 2) */,
};
enum {
GPS_NAVIGATION_MESSAGE_SUCCESS = 0,
GPS_NAVIGATION_MESSAGE_ERROR_ALREADY_INIT = -100 /* (-100) */,
GPS_NAVIGATION_MESSAGE_ERROR_GENERIC = -101 /* (-101) */,
};
enum {
GNSS_NAVIGATION_MESSAGE_TYPE_UNKNOWN = 0,
GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L1CA = 257 /* 0x0101 */,
GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L2CNAV = 258 /* 0x0102 */,
GNSS_NAVIGATION_MESSAGE_TYPE_GPS_L5CNAV = 259 /* 0x0103 */,
GNSS_NAVIGATION_MESSAGE_TYPE_GPS_CNAV2 = 260 /* 0x0104 */,
GNSS_NAVIGATION_MESSAGE_TYPE_GLO_L1CA = 769 /* 0x0301 */,
GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D1 = 1281 /* 0x0501 */,
GNSS_NAVIGATION_MESSAGE_TYPE_BDS_D2 = 1282 /* 0x0502 */,
GNSS_NAVIGATION_MESSAGE_TYPE_GAL_I = 1537 /* 0x0601 */,
GNSS_NAVIGATION_MESSAGE_TYPE_GAL_F = 1538 /* 0x0602 */,
};
typedef enum {
NAV_MESSAGE_STATUS_PARITY_PASSED = 1 /* (1 << 0) */,
NAV_MESSAGE_STATUS_PARITY_REBUILT = 2 /* (1 << 1) */,
NAV_MESSAGE_STATUS_UNKNOWN = 0,
} navigation_message_status;
enum {
GPS_NI_TYPE_VOICE = 1,
GPS_NI_TYPE_UMTS_SUPL = 2,
GPS_NI_TYPE_UMTS_CTRL_PLANE = 3,
GPS_NI_TYPE_EMERGENCY_SUPL = 4,
};
enum {
GPS_NI_NEED_NOTIFY = 1u /* 0x0001 */,
GPS_NI_NEED_VERIFY = 2u /* 0x0002 */,
GPS_NI_PRIVACY_OVERRIDE = 4u /* 0x0004 */,
};
enum {
GPS_NI_RESPONSE_ACCEPT = 1,
GPS_NI_RESPONSE_DENY = 2,
GPS_NI_RESPONSE_NORESP = 3,
};
enum {
GPS_ENC_NONE = 0,
GPS_ENC_SUPL_GSM_DEFAULT = 1,
GPS_ENC_SUPL_UTF8 = 2,
GPS_ENC_SUPL_UCS2 = 3,
GPS_ENC_UNKNOWN = -1 /* (-1) */,
};
#ifdef __cplusplus
}
#endif
#endif // HIDL_GENERATED_ANDROID_HARDWARE_GNSS_V1_0_EXPORTED_CONSTANTS_H_

View file

@ -0,0 +1 @@
../../include_all/hardware/gnss-base.h

File diff suppressed because it is too large Load diff

1
include/hardware/gps.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/gps.h

View file

@ -1,96 +0,0 @@
/*
* Copyright (C) 2016 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_INTERNAL_H
#define ANDROID_INCLUDE_HARDWARE_GPS_INTERNAL_H
#include "hardware/gps.h"
/****************************************************************************
* This file contains legacy structs that are deprecated/retired from gps.h *
****************************************************************************/
__BEGIN_DECLS
/**
* Legacy GPS callback structure.
* Deprecated, to be removed in the next Android release.
* Use GpsCallbacks instead.
*/
typedef struct {
/** set to sizeof(GpsCallbacks_v1) */
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_v1;
#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.
/**
* Legacy struct to represent the status of AGPS.
*/
typedef struct {
/** set to sizeof(AGpsStatus_v1) */
size_t size;
AGpsType type;
AGpsStatusValue status;
} AGpsStatus_v1;
#pragma pack(pop)
/**
* Legacy struct to represent the status of AGPS augmented with a IPv4 address
* field.
*/
typedef struct {
/** set to sizeof(AGpsStatus_v2) */
size_t size;
AGpsType type;
AGpsStatusValue status;
/*-------------------- New fields in _v2 --------------------*/
uint32_t ipaddr;
} AGpsStatus_v2;
/**
* Legacy extended interface for AGPS support.
* See AGpsInterface_v2 for more information.
*/
typedef struct {
/** set to sizeof(AGpsInterface_v1) */
size_t size;
void (*init)( AGpsCallbacks* callbacks );
int (*data_conn_open)( const char* apn );
int (*data_conn_closed)();
int (*data_conn_failed)();
int (*set_server)( AGpsType type, const char* hostname, int port );
} AGpsInterface_v1;
__END_DECLS
#endif /* ANDROID_INCLUDE_HARDWARE_GPS_INTERNAL_H */

View file

@ -0,0 +1 @@
../../include_all/hardware/gps_internal.h

View file

@ -1,448 +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 <system/graphics.h>
#include <hardware/hardware.h>
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <cutils/native_handle.h>
#include <hardware/hardware.h>
#include <hardware/fb.h>
__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 = 0x00000000U,
/* buffer is rarely read in software */
GRALLOC_USAGE_SW_READ_RARELY = 0x00000002U,
/* buffer is often read in software */
GRALLOC_USAGE_SW_READ_OFTEN = 0x00000003U,
/* mask for the software read values */
GRALLOC_USAGE_SW_READ_MASK = 0x0000000FU,
/* buffer is never written in software */
GRALLOC_USAGE_SW_WRITE_NEVER = 0x00000000U,
/* buffer is rarely written in software */
GRALLOC_USAGE_SW_WRITE_RARELY = 0x00000020U,
/* buffer is often written in software */
GRALLOC_USAGE_SW_WRITE_OFTEN = 0x00000030U,
/* mask for the software write values */
GRALLOC_USAGE_SW_WRITE_MASK = 0x000000F0U,
/* buffer will be used as an OpenGL ES texture */
GRALLOC_USAGE_HW_TEXTURE = 0x00000100U,
/* buffer will be used as an OpenGL ES render target */
GRALLOC_USAGE_HW_RENDER = 0x00000200U,
/* buffer will be used by the 2D hardware blitter */
GRALLOC_USAGE_HW_2D = 0x00000400U,
/* buffer will be used by the HWComposer HAL module */
GRALLOC_USAGE_HW_COMPOSER = 0x00000800U,
/* buffer will be used with the framebuffer device */
GRALLOC_USAGE_HW_FB = 0x00001000U,
/* buffer should be displayed full-screen on an external display when
* possible */
GRALLOC_USAGE_EXTERNAL_DISP = 0x00002000U,
/* 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 = 0x00004000U,
/* buffer may be used as a cursor */
GRALLOC_USAGE_CURSOR = 0x00008000U,
/* buffer will be used with the HW video encoder */
GRALLOC_USAGE_HW_VIDEO_ENCODER = 0x00010000U,
/* buffer will be written by the HW camera pipeline */
GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000U,
/* buffer will be read by the HW camera pipeline */
GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000U,
/* buffer will be used as part of zero-shutter-lag queue */
GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00060000U,
/* mask for the camera access values */
GRALLOC_USAGE_HW_CAMERA_MASK = 0x00060000U,
/* mask for the software usage bit-mask */
GRALLOC_USAGE_HW_MASK = 0x00071F00U,
/* buffer will be used as a RenderScript Allocation */
GRALLOC_USAGE_RENDERSCRIPT = 0x00100000U,
/* 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 = 0x00200000U,
/* buffer will be used as input to HW HEIC image encoder */
GRALLOC_USAGE_HW_IMAGE_ENCODER = 0x08000000U,
/* 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 = 0x10000000U,
GRALLOC_USAGE_PRIVATE_1 = 0x20000000U,
GRALLOC_USAGE_PRIVATE_2 = 0x40000000U,
GRALLOC_USAGE_PRIVATE_3 = 0x80000000U,
GRALLOC_USAGE_PRIVATE_MASK = 0xF0000000U,
};
/*****************************************************************************/
/**
* 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);
/* 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);
/* getTransportSize(..., outNumFds, outNumInts)
* This function is mandatory on devices running IMapper2.1 or higher.
*
* Get the transport size of a buffer. An imported buffer handle is a raw
* buffer handle with the process-local runtime data appended. This
* function, for example, allows a caller to omit the process-local
* runtime data at the tail when serializing the imported buffer handle.
*
* Note that a client might or might not omit the process-local runtime
* data when sending an imported buffer handle. The mapper must support
* both cases on the receiving end.
*/
int32_t (*getTransportSize)(
struct gralloc_module_t const* module, buffer_handle_t handle, uint32_t *outNumFds,
uint32_t *outNumInts);
/* validateBufferSize(..., w, h, format, usage, stride)
* This function is mandatory on devices running IMapper2.1 or higher.
*
* Validate that the buffer can be safely accessed by a caller who assumes
* the specified width, height, format, usage, and stride. This must at least validate
* that the buffer size is large enough. Validating the buffer against
* individual buffer attributes is optional.
*/
int32_t (*validateBufferSize)(
struct gralloc_module_t const* device, buffer_handle_t handle,
uint32_t w, uint32_t h, int32_t format, int usage,
uint32_t stride);
/* reserved for future use */
void* reserved_proc[1];
} 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, TO_HW_DEVICE_T_OPEN(device));
}
static inline int gralloc_close(struct alloc_device_t* device) {
return device->common.close(&device->common);
}
/**
* map_usage_to_memtrack should be called after allocating a gralloc buffer.
*
* @param usage - it is the flag used when alloc function is called.
*
* This function maps the gralloc usage flags to appropriate memtrack bucket.
* GrallocHAL implementers and users should make an additional ION_IOCTL_TAG
* call using the memtrack tag returned by this function. This will help the
* in-kernel memtack to categorize the memory allocated by different processes
* according to their usage.
*
*/
static inline const char* map_usage_to_memtrack(uint32_t usage) {
usage &= GRALLOC_USAGE_ALLOC_MASK;
if ((usage & GRALLOC_USAGE_HW_CAMERA_WRITE) != 0) {
return "camera";
} else if ((usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) != 0 ||
(usage & GRALLOC_USAGE_EXTERNAL_DISP) != 0) {
return "video";
} else if ((usage & GRALLOC_USAGE_HW_RENDER) != 0 ||
(usage & GRALLOC_USAGE_HW_TEXTURE) != 0) {
return "gl";
} else if ((usage & GRALLOC_USAGE_HW_CAMERA_READ) != 0) {
return "camera";
} else if ((usage & GRALLOC_USAGE_SW_READ_MASK) != 0 ||
(usage & GRALLOC_USAGE_SW_WRITE_MASK) != 0) {
return "cpu";
}
return "graphics";
}
__END_DECLS
#endif // ANDROID_GRALLOC_INTERFACE_H

1
include/hardware/gralloc.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/gralloc.h

File diff suppressed because it is too large Load diff

1
include/hardware/gralloc1.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/gralloc1.h

View file

@ -1,244 +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 <stdint.h>
#include <sys/cdefs.h>
#include <cutils/native_handle.h>
#include <system/graphics.h>
__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;
#ifdef __cplusplus
#define TO_HW_DEVICE_T_OPEN(x) reinterpret_cast<struct hw_device_t**>(x)
#else
#define TO_HW_DEVICE_T_OPEN(x) (struct hw_device_t**)(x)
#endif
/**
* 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.<variant>.so and
* audio.a2dp.<variant>.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 */

1
include/hardware/hardware.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/hardware.h

View file

@ -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 <stdint.h>
#include <sys/cdefs.h>
#include <hardware/hardware.h>
__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
* <Image View On> or <Text View On>. 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 <Get Menu Language> 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, TO_HW_DEVICE_T_OPEN(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 */

1
include/hardware/hdmi_cec.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/hdmi_cec.h

View file

@ -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 <stdint.h>
#ifndef ANDROID_HARDWARE_HW_AUTH_TOKEN_H
#define ANDROID_HARDWARE_HW_AUTH_TOKEN_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define 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

View file

@ -0,0 +1 @@
../../include_all/hardware/hw_auth_token.h

View file

@ -1,798 +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 <stdint.h>
#include <sys/cdefs.h>
#include <hardware/gralloc.h>
#include <hardware/hardware.h>
#include <cutils/native_handle.h>
#include <hardware/hwcomposer_defs.h>
__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
/*****************************************************************************/
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;
#define HWC_ERROR (-1)
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, HWC_ERROR shall be returned.
*
* Returns the configuration index on success or HWC_ERROR 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, TO_HW_DEVICE_T_OPEN(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 */

View file

@ -0,0 +1 @@
../../include_all/hardware/hwcomposer.h

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
../../include_all/hardware/hwcomposer2.h

View file

@ -1,344 +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 <stdint.h>
#include <sys/cdefs.h>
#include <hardware/gralloc.h>
#include <hardware/hardware.h>
#include <cutils/native_handle.h>
__BEGIN_DECLS
/* Shared by HWC1 and HWC2 */
#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)
#define HWC_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION_2(2, 0, HWC_HEADER_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_color {
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} hwc_color_t;
typedef struct hwc_float_color {
float r;
float g;
float b;
float a;
} hwc_float_color_t;
typedef struct hwc_frect {
float left;
float top;
float right;
float bottom;
} hwc_frect_t;
typedef struct hwc_rect {
int left;
int top;
int right;
int bottom;
} hwc_rect_t;
typedef struct hwc_region {
size_t numRects;
hwc_rect_t const* rects;
} hwc_region_t;
/*
* hwc_layer_t::transform values
*/
typedef 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,
/* flip source image horizontally, the rotate 90 degrees clock-wise */
HWC_TRANSFORM_FLIP_H_ROT_90 = HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90,
/* flip source image vertically, the rotate 90 degrees clock-wise */
HWC_TRANSFORM_FLIP_V_ROT_90 = HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90,
} hwc_transform_t;
/* Constraints for changing vsync period */
typedef struct hwc_vsync_period_change_constraints {
/* Time in CLOCK_MONOTONIC after which the vsync period may change
* (i.e., the vsync period must not change before this time). */
int64_t desiredTimeNanos;
/*
* If true, requires that the vsync period change must happen seamlessly without
* a noticeable visual artifact. */
uint8_t seamlessRequired;
} hwc_vsync_period_change_constraints_t;
/* Timing for a vsync period change. */
typedef struct hwc_vsync_period_change_timeline {
/* The time in CLOCK_MONOTONIC when the new display will start to refresh at
* the new vsync period. */
int64_t newVsyncAppliedTimeNanos;
/* Set to true if the client is required to sent a frame to be displayed before
* the change can take place. */
uint8_t refreshRequired;
/* The time in CLOCK_MONOTONIC when the client is expected to send the new frame.
* Should be ignored if refreshRequired is false. */
int64_t refreshTimeNanos;
} hwc_vsync_period_change_timeline_t;
typedef struct hwc_client_target_property {
// The pixel format of client target requested by hardware composer.
int32_t pixelFormat;
// The dataspace of the client target requested by hardware composer.
int32_t dataspace;
} hwc_client_target_property_t;
/*******************************************************************************
* Beyond this point are things only used by HWC1, which should be ignored when
* implementing a HWC2 device
******************************************************************************/
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 SurfaceFlinger 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_FRAMEBUFFER).
*/
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
};
/* 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,
/* The configuration group this config is associated to. The groups are defined
* to mark certain configs as similar and changing configs within a certain group
* may be done seamlessly in some conditions. setActiveConfigWithConstraints. */
HWC_DISPLAY_CONFIG_GROUP = 7,
};
/* 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.
HWC_DISPLAY_VIRTUAL = 2,
HWC_NUM_PHYSICAL_DISPLAY_TYPES = 2,
HWC_NUM_DISPLAY_TYPES = 3,
};
enum {
HWC_DISPLAY_PRIMARY_BIT = 1 << HWC_DISPLAY_PRIMARY,
HWC_DISPLAY_EXTERNAL_BIT = 1 << HWC_DISPLAY_EXTERNAL,
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 */

View file

@ -0,0 +1 @@
../../include_all/hardware/hwcomposer_defs.h

View file

@ -1,573 +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 <hardware/hardware.h>
#include <stdint.h>
__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_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_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_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,
// switches
INPUT_USAGE_SWITCH_UNKNOWN,
INPUT_USAGE_SWITCH_LID,
INPUT_USAGE_SWITCH_KEYPAD_SLIDE,
INPUT_USAGE_SWITCH_HEADPHONE_INSERT,
INPUT_USAGE_SWITCH_MICROPHONE_INSERT,
INPUT_USAGE_SWITCH_LINEOUT_INSERT,
INPUT_USAGE_SWITCH_CAMERA_LENS_COVER,
// mouse buttons
// (see android.view.MotionEvent)
INPUT_USAGE_BUTTON_UNKNOWN,
INPUT_USAGE_BUTTON_PRIMARY, // left
INPUT_USAGE_BUTTON_SECONDARY, // right
INPUT_USAGE_BUTTON_TERTIARY, // middle
INPUT_USAGE_BUTTON_FORWARD,
INPUT_USAGE_BUTTON_BACK,
} input_usage_t;
typedef enum input_collection_id {
INPUT_COLLECTION_ID_TOUCH,
INPUT_COLLECTION_ID_KEYBOARD,
INPUT_COLLECTION_ID_MOUSE,
INPUT_COLLECTION_ID_TOUCHPAD,
INPUT_COLLECTION_ID_SWITCH,
// 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);
/**
* Frees the report definition.
*/
void (*free_report_definition)(input_host_t* host, input_report_definition_t* report_def);
/**
* 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 */

1
include/hardware/input.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/input.h

View file

@ -1,548 +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 <hardware/keymaster_common.h>
#include <hardware/keymaster_defs.h>
__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);
};
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, TO_HW_DEVICE_T_OPEN(device));
}
static inline int keymaster1_close(keymaster1_device_t* device) {
return device->common.close(&device->common);
}
__END_DECLS
#endif // ANDROID_HARDWARE_KEYMASTER1_H

View file

@ -0,0 +1 @@
../../include_all/hardware/keymaster1.h

View file

@ -1,432 +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_KEYMASTER2_H
#define ANDROID_HARDWARE_KEYMASTER2_H
#include <hardware/keymaster_common.h>
#include <hardware/keymaster_defs.h>
__BEGIN_DECLS
/**
* Keymaster2 device definition
*/
struct keymaster2_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;
void* context;
/**
* See flags defined for keymaster0_devices::flags in keymaster_common.h. Used only for
* backward compatibility; keymaster2 hardware devices must set this to zero.
*/
uint32_t flags;
/**
* Configures keymaster. This method must be called once after the device is opened and before
* it is used. It's used to provide KM_TAG_OS_VERSION and KM_TAG_OS_PATCHLEVEL to keymaster.
* Until this method is called, all other methods will return KM_ERROR_KEYMASTER_NOT_CONFIGURED.
* The values provided by this method are only accepted by keymaster once per boot. Subsequent
* calls will return KM_ERROR_OK, but do nothing.
*
* If the keymaster implementation is in secure hardware and the OS version and patch level
* values provided do not match the values provided to the secure hardware by the bootloader (or
* if the bootloader did not provide values), then this method will return
* KM_ERROR_INVALID_ARGUMENT, and all other methods will continue returning
* KM_ERROR_KEYMASTER_NOT_CONFIGURED.
*/
keymaster_error_t (*configure)(const struct keymaster2_device* dev,
const keymaster_key_param_set_t* params);
/**
* 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 keymaster2_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 param
*
* \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 keymaster2_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_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. Must not be NULL. The caller assumes
* ownership of the contents and must deallocate with keymaster_free_characteristics().
*/
keymaster_error_t (*get_key_characteristics)(const struct keymaster2_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 of the contents and must deallocate with keymaster_free_characteristics(). Note
* that KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA are never returned.
*/
keymaster_error_t (*import_key)(const struct keymaster2_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 or symmetric key, returning a byte array in the specified format.
*
* Note that symmetric key export is allowed only if the key was created with KM_TAG_EXPORTABLE,
* and only if all of the requirements for key usage (e.g. authentication) are met.
*
* \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[in] client_id Client ID blob, which must match the blob provided in
* KM_TAG_APPLICATION_ID during key generation (if any).
*
* \param[in] app_data Appliation data blob, which must match the blob provided in
* KM_TAG_APPLICATION_DATA during key generation (if any).
*
* \param[out] export_data The exported key material. The caller assumes ownership.
*/
keymaster_error_t (*export_key)(const struct keymaster2_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);
/**
* Generates a signed X.509 certificate chain attesting to the presence of \p key_to_attest in
* keymaster (TODO(swillden): Describe certificate contents in more detail). The certificate
* will contain an extension with OID 1.3.6.1.4.1.11129.2.1.17 and value defined in
* <TODO:swillden -- insert link here> which contains the key description.
*
* \param[in] dev The keymaster device structure.
*
* \param[in] key_to_attest The keymaster key for which the attestation certificate will be
* generated.
*
* \param[in] attest_params Parameters defining how to do the attestation. At present the only
* parameter is KM_TAG_ALGORITHM, which must be either KM_ALGORITHM_EC or KM_ALGORITHM_RSA.
* This selects which of the provisioned attestation keys will be used to sign the certificate.
*
* \param[out] cert_chain An array of DER-encoded X.509 certificates. The first will be the
* certificate for \p key_to_attest. The remaining entries will chain back to the root. The
* caller takes ownership and must deallocate with keymaster_free_cert_chain.
*/
keymaster_error_t (*attest_key)(const struct keymaster2_device* dev,
const keymaster_key_blob_t* key_to_attest,
const keymaster_key_param_set_t* attest_params,
keymaster_cert_chain_t* cert_chain);
/**
* Upgrades an old key. Keys can become "old" in two ways: Keymaster can be upgraded to a new
* version, or the system can be updated to invalidate the OS version and/or patch level. In
* either case, attempts to use an old key will result in keymaster returning
* KM_ERROR_KEY_REQUIRES_UPGRADE. This method should then be called to upgrade the key.
*
* \param[in] dev The keymaster device structure.
*
* \param[in] key_to_upgrade The keymaster key to upgrade.
*
* \param[in] upgrade_params Parameters needed to complete the upgrade. In particular,
* KM_TAG_APPLICATION_ID and KM_TAG_APPLICATION_DATA will be required if they were defined for
* the key.
*
* \param[out] upgraded_key The upgraded key blob.
*/
keymaster_error_t (*upgrade_key)(const struct keymaster2_device* dev,
const keymaster_key_blob_t* key_to_upgrade,
const keymaster_key_param_set_t* upgrade_params,
keymaster_key_blob_t* upgraded_key);
/**
* 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 keymaster2_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 keymaster2_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.
*
* \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 keymaster2_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 keymaster2_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] 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] input Data to be processed, per the parameters established in the call to
* begin(). finish() must consume all provided data or return KM_ERROR_INVALID_INPUT_LENGTH.
*
* \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 keymaster2_device* dev,
keymaster_operation_handle_t operation_handle,
const keymaster_key_param_set_t* in_params,
const keymaster_blob_t* input, 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 keymaster2_device* dev,
keymaster_operation_handle_t operation_handle);
};
typedef struct keymaster2_device keymaster2_device_t;
/* Convenience API for opening and closing keymaster devices */
static inline int keymaster2_open(const struct hw_module_t* module, keymaster2_device_t** device) {
return module->methods->open(module, KEYSTORE_KEYMASTER, TO_HW_DEVICE_T_OPEN(device));
}
static inline int keymaster2_close(keymaster2_device_t* device) {
return device->common.close(&device->common);
}
__END_DECLS
#endif // ANDROID_HARDWARE_KEYMASTER2_H

View file

@ -0,0 +1 @@
../../include_all/hardware/keymaster2.h

View file

@ -1,191 +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 <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
__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)
/**
* Keymaster 2.0 module version provides third API, slightly modified and extended from 1.0.
*/
#define KEYMASTER_MODULE_API_VERSION_2_0 HARDWARE_MODULE_API_VERSION(2, 0)
#define KEYMASTER_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION(2, 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

View file

@ -0,0 +1 @@
../../include_all/hardware/keymaster_common.h

View file

@ -1,707 +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 <stdint.h>
#include <stdlib.h>
#include <string.h>
#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. */
KM_TAG_KDF = KM_ENUM_REP | 9, /* keymaster_kdf_t (keymaster2) */
KM_TAG_EC_CURVE = KM_ENUM | 10, /* keymaster_ec_curve_t (keymaster2) */
/* Algorithm-specific. */
KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200,
KM_TAG_ECIES_SINGLE_HASH_MODE = KM_BOOL | 201, /* Whether the ephemeral public key is fed into
* the KDF */
KM_TAG_INCLUDE_UNIQUE_ID = KM_BOOL | 202, /* If true, attestation certificates for this key
* will contain an application-scoped and
* time-bounded device-unique ID. (keymaster2) */
KM_TAG_RSA_OAEP_MGF_DIGEST = KM_ENUM_REP | 203, /* keymaster_digest_t. */
/* 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 */
KM_TAG_ROLLBACK_RESISTANCE = KM_BOOL | 303, /* Hardware enforced deletion with deleteKey
* or deleteAllKeys is supported */
KM_TAG_EARLY_BOOT_ONLY = KM_BOOL | 305, /* Key can only be used during early boot. */
/*
* 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. */
KM_TAG_USAGE_COUNT_LIMIT = KM_UINT | 405, /* Number of cryptographic operations left
with the key.*/
/* 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. */
KM_TAG_ALLOW_WHILE_ON_BODY = KM_BOOL | 506, /* Allow key to be used after authentication timeout
* if device is still on-body (requires secure
* on-body sensor. */
KM_TAG_TRUSTED_USER_PRESENCE_REQUIRED = KM_BOOL | 507,/* Require test of user presence
* to use this key. */
KM_TAG_TRUSTED_CONFIRMATION_REQUIRED = KM_BOOL | 508, /* Require user confirmation through a
* trusted UI to use this key. */
KM_TAG_UNLOCKED_DEVICE_REQUIRED = KM_BOOL | 509, /* Require the device screen to be unlocked if the
* key is used. */
/* Application access control */
KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600, /* Specified to indicate key is usable by all
* applications. */
KM_TAG_APPLICATION_ID = KM_BYTES | 601, /* Byte string identifying the authorized
* application. */
KM_TAG_EXPORTABLE = KM_BOOL | 602, /* If true, private/secret key can be exported, but
* only if all access control requirements for use are
* met. (keymaster2) */
/*
* 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. */
KM_TAG_OS_VERSION = KM_UINT | 705, /* Version of system (keymaster2) */
KM_TAG_OS_PATCHLEVEL = KM_UINT | 706, /* Patch level of system (keymaster2) */
KM_TAG_UNIQUE_ID = KM_BYTES | 707, /* Used to provide unique ID in attestation */
KM_TAG_ATTESTATION_CHALLENGE = KM_BYTES | 708, /* Used to provide challenge in attestation */
KM_TAG_ATTESTATION_APPLICATION_ID = KM_BYTES | 709, /* Used to identify the set of possible
* applications of which one has initiated
* a key attestation */
KM_TAG_ATTESTATION_ID_BRAND = KM_BYTES | 710, /* Used to provide the device's brand name to be
included in attestation */
KM_TAG_ATTESTATION_ID_DEVICE = KM_BYTES | 711, /* Used to provide the device's device name to be
included in attestation */
KM_TAG_ATTESTATION_ID_PRODUCT = KM_BYTES | 712, /* Used to provide the device's product name to
be included in attestation */
KM_TAG_ATTESTATION_ID_SERIAL = KM_BYTES | 713, /* Used to provide the device's serial number to
be included in attestation */
KM_TAG_ATTESTATION_ID_IMEI = KM_BYTES | 714, /* Used to provide the device's IMEI to be
included in attestation */
KM_TAG_ATTESTATION_ID_MEID = KM_BYTES | 715, /* Used to provide the device's MEID to be
included in attestation */
KM_TAG_ATTESTATION_ID_MANUFACTURER = KM_BYTES | 716, /* Used to provide the device's
manufacturer name to be included in
attestation */
KM_TAG_ATTESTATION_ID_MODEL = KM_BYTES | 717, /* Used to provide the device's model name to be
included in attestation */
KM_TAG_VENDOR_PATCHLEVEL = KM_UINT | 718, /* specifies the vendor image security patch
level with which the key may be used */
KM_TAG_BOOT_PATCHLEVEL = KM_UINT | 719, /* specifies the boot image (kernel) security
patch level with which the key may be used */
KM_TAG_DEVICE_UNIQUE_ATTESTATION = KM_BOOL | 720, /* Indicates StrongBox device-unique
attestation is requested. */
KM_TAG_IDENTITY_CREDENTIAL_KEY = KM_BOOL | 721, /* This is an identity credential key */
KM_TAG_STORAGE_KEY = KM_BOOL | 722, /* storage encryption key */
KM_TAG_ATTESTATION_ID_SECOND_IMEI = KM_BYTES | 723, /* Used to provide the device's second
IMEI to be included in attestation */
/* 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. */
KM_TAG_RESET_SINCE_ID_ROTATION = KM_BOOL | 1004, /* Whether the device has beeen factory reset
since the last unique ID rotation. Used
for key attestation. */
KM_TAG_CONFIRMATION_TOKEN = KM_BYTES | 1005, /* used to deliver a cryptographic token
proving that the user confirmed a signing
request. */
KM_TAG_CERTIFICATE_SERIAL = KM_BIGNUM | 1006, /* The serial number that should be
set in the attestation certificate
to be generated. */
KM_TAG_CERTIFICATE_SUBJECT = KM_BYTES | 1007, /* A DER-encoded X.500 subject that should be
set in the attestation certificate
to be generated. */
KM_TAG_CERTIFICATE_NOT_BEFORE = KM_DATE | 1008, /* Epoch time in milliseconds of the start of
the to be generated certificate's validity.
The value should interpreted as too's
complement signed integer. Negative values
indicate dates before Jan 1970 */
KM_TAG_CERTIFICATE_NOT_AFTER = KM_DATE | 1009, /* Epoch time in milliseconds of the end of
the to be generated certificate's validity.
The value should interpreted as too's
complement signed integer. Negative values
indicate dates before Jan 1970 */
KM_TAG_MAX_BOOT_LEVEL = KM_UINT | 1010, /* Specifies a maximum boot level at which a key
should function. */
} 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,
KM_ALGORITHM_TRIPLE_DES = 33,
/* 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;
/*
* Key derivation functions, mostly used in ECIES.
*/
typedef enum {
/* Do not apply a key derivation function; use the raw agreed key */
KM_KDF_NONE = 0,
/* HKDF defined in RFC 5869 with SHA256 */
KM_KDF_RFC5869_SHA256 = 1,
/* KDF1 defined in ISO 18033-2 with SHA1 */
KM_KDF_ISO18033_2_KDF1_SHA1 = 2,
/* KDF1 defined in ISO 18033-2 with SHA256 */
KM_KDF_ISO18033_2_KDF1_SHA256 = 3,
/* KDF2 defined in ISO 18033-2 with SHA1 */
KM_KDF_ISO18033_2_KDF2_SHA1 = 4,
/* KDF2 defined in ISO 18033-2 with SHA256 */
KM_KDF_ISO18033_2_KDF2_SHA256 = 5,
} keymaster_kdf_t;
/**
* Supported EC curves, used in ECDSA/ECIES.
*/
typedef enum {
KM_EC_CURVE_P_224 = 0,
KM_EC_CURVE_P_256 = 1,
KM_EC_CURVE_P_384 = 2,
KM_EC_CURVE_P_521 = 3,
KM_EC_CURVE_CURVE_25519 = 4,
} keymaster_ec_curve_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. Should not exist outside the TEE. */
KM_ORIGIN_DERIVED = 1, /* Derived inside keymaster. Likely exists off-device. */
KM_ORIGIN_IMPORTED = 2, /* Imported into keymaster. Existed as cleartext in Android. */
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.
*/
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).
*/
typedef enum {
KM_PURPOSE_ENCRYPT = 0, /* Usable with RSA, EC and AES keys. */
KM_PURPOSE_DECRYPT = 1, /* Usable with RSA, EC and AES keys. */
KM_PURPOSE_SIGN = 2, /* Usable with RSA, EC and HMAC keys. */
KM_PURPOSE_VERIFY = 3, /* Usable with RSA, EC and HMAC keys. */
KM_PURPOSE_DERIVE_KEY = 4, /* Usable with EC keys. */
KM_PURPOSE_WRAP = 5, /* Usable with wrapped keys. */
KM_PURPOSE_AGREE_KEY = 6, /* Usable with EC keys. */
KM_PURPOSE_ATTEST_KEY = 7 /* Usabe with RSA and EC keys */
} 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;
typedef struct {
keymaster_blob_t* entries;
size_t entry_count;
} keymaster_cert_chain_t;
typedef enum {
KM_VERIFIED_BOOT_VERIFIED = 0, /* Full chain of trust extending from the bootloader to
* verified partitions, including the bootloader, boot
* partition, and all verified partitions*/
KM_VERIFIED_BOOT_SELF_SIGNED = 1, /* The boot partition has been verified using the embedded
* certificate, and the signature is valid. The bootloader
* displays a warning and the fingerprint of the public
* key before allowing the boot process to continue.*/
KM_VERIFIED_BOOT_UNVERIFIED = 2, /* The device may be freely modified. Device integrity is left
* to the user to verify out-of-band. The bootloader
* displays a warning to the user before allowing the boot
* process to continue */
KM_VERIFIED_BOOT_FAILED = 3, /* The device failed verification. The bootloader displays a
* warning and stops the boot process, so no keymaster
* implementation should ever actually return this value,
* since it should not run. Included here only for
* completeness. */
} keymaster_verified_boot_t;
typedef enum {
KM_SECURITY_LEVEL_SOFTWARE = 0,
KM_SECURITY_LEVEL_TRUSTED_ENVIRONMENT = 1,
KM_SECURITY_LEVEL_STRONGBOX = 2,
} keymaster_security_level_t;
/**
* Formats for key import and 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 and export*/
} 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_UNSUPPORTED_KDF = -60,
KM_ERROR_UNSUPPORTED_EC_CURVE = -61,
KM_ERROR_KEY_REQUIRES_UPGRADE = -62,
KM_ERROR_ATTESTATION_CHALLENGE_MISSING = -63,
KM_ERROR_KEYMASTER_NOT_CONFIGURED = -64,
KM_ERROR_ATTESTATION_APPLICATION_ID_MISSING = -65,
KM_ERROR_CANNOT_ATTEST_IDS = -66,
KM_ERROR_ROLLBACK_RESISTANCE_UNAVAILABLE = -67,
KM_ERROR_NO_USER_CONFIRMATION = -71,
KM_ERROR_DEVICE_LOCKED = -72,
KM_ERROR_EARLY_BOOT_ENDED = -73,
KM_ERROR_ATTESTATION_KEYS_NOT_PROVISIONED = -74,
KM_ERROR_ATTESTATION_IDS_NOT_PROVISIONED = -75,
KM_ERROR_INCOMPATIBLE_MGF_DIGEST = -78,
KM_ERROR_UNSUPPORTED_MGF_DIGEST = -79,
KM_ERROR_MISSING_NOT_BEFORE = -80,
KM_ERROR_MISSING_NOT_AFTER = -81,
KM_ERROR_MISSING_ISSUER_SUBJECT = -82,
KM_ERROR_INVALID_ISSUER_SUBJECT = -83,
KM_ERROR_BOOT_LEVEL_EXCEEDED = -84,
KM_ERROR_UNIMPLEMENTED = -100,
KM_ERROR_VERSION_MISMATCH = -101,
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(&param, 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(&param, 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(&param, 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(&param, 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(&param, 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(&param, 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((uint32_t)a->tag, (uint32_t)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) {
param_count--;
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;
set->length = 0;
}
}
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);
}
}
inline void keymaster_free_cert_chain(keymaster_cert_chain_t* chain) {
if (chain) {
for (size_t i = 0; i < chain->entry_count; ++i) {
free((uint8_t*)chain->entries[i].data);
chain->entries[i].data = NULL;
chain->entries[i].data_length = 0;
}
free(chain->entries);
chain->entries = NULL;
chain->entry_count = 0;
}
}
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // ANDROID_HARDWARE_KEYMASTER_DEFS_H

View file

@ -0,0 +1 @@
../../include_all/hardware/keymaster_defs.h

View file

@ -1,192 +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 <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
__BEGIN_DECLS
/**
* The id of this module
*/
#define LIGHTS_HARDWARE_MODULE_ID "lights"
/**
* Header file version.
*/
#define LIGHTS_HEADER_VERSION 1
/**
* Device API version 0.0-1.0
*
* Base version for the device API in the lights HAL: all versions less than
* 2.0 are treated as being this version.
*/
#define LIGHTS_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION_2(1, 0, LIGHTS_HEADER_VERSION)
/**
* Device API version 2.0
*
* Devices reporting this version or higher may additionally support the
* following modes:
* - BRIGHTNESS_MODE_LOW_PERSISTENCE
*/
#define LIGHTS_DEVICE_API_VERSION_2_0 HARDWARE_DEVICE_API_VERSION_2(2, 0, LIGHTS_HEADER_VERSION)
/*
* 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"
/* ************************************************************************
* 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
/**
* Use a low-persistence mode for display backlights.
*
* When set, the device driver must switch to a mode optimized for low display
* persistence that is intended to be used when the device is being treated as a
* head mounted display (HMD). The actual display brightness in this mode is
* implementation dependent, and any value set for color in light_state may be
* overridden by the HAL implementation.
*
* For an optimal HMD viewing experience, the display must meet the following
* criteria in this mode:
* - Gray-to-Gray, White-to-Black, and Black-to-White switching time must be 3 ms.
* - The display must support low-persistence with 3.5 ms persistence.
* Persistence is defined as the amount of time for which a pixel is
* emitting light for a single frame.
* - Any "smart panel" or other frame buffering options that increase display
* latency are disabled.
* - Display brightness is set so that the display is still visible to the user
* under normal indoor lighting.
* - The display must update at 60 Hz at least, but higher refresh rates are
* recommended for low latency.
*
* This mode will only be used with light devices of type LIGHT_ID_BACKLIGHT,
* and will only be called by the Android framework for light_device_t
* implementations that report a version >= 2.0 in their hw_device_t common
* fields. If the device version is >= 2.0 and this mode is unsupported, calling
* set_light with this mode must return the negative error code -ENOSYS (-38)
* without altering any settings.
*
* Available only for version >= LIGHTS_DEVICE_API_VERSION_2_0
*/
#define BRIGHTNESS_MODE_LOW_PERSISTENCE 2
/**
* 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).
*/
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;
};
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

1
include/hardware/lights.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/lights.h

View file

@ -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 <stdint.h>
#include <hardware/hardware.h>
__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,
TO_HW_DEVICE_T_OPEN(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

View file

@ -0,0 +1 @@
../../include_all/hardware/local_time_hal.h

View file

@ -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 <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
__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(<pid>, 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/<pid>/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

1
include/hardware/memtrack.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/memtrack.h

View file

@ -1,34 +0,0 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
// Source: android.hardware.nfc@1.0
// Location: hardware/interfaces/nfc/1.0/
#ifndef HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_
#define HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_
#ifdef __cplusplus
extern "C" {
#endif
enum {
HAL_NFC_OPEN_CPLT_EVT = 0u,
HAL_NFC_CLOSE_CPLT_EVT = 1u,
HAL_NFC_POST_INIT_CPLT_EVT = 2u,
HAL_NFC_PRE_DISCOVER_CPLT_EVT = 3u,
HAL_NFC_REQUEST_CONTROL_EVT = 4u,
HAL_NFC_RELEASE_CONTROL_EVT = 5u,
HAL_NFC_ERROR_EVT = 6u,
};
enum {
HAL_NFC_STATUS_OK = 0u,
HAL_NFC_STATUS_FAILED = 1u,
HAL_NFC_STATUS_ERR_TRANSPORT = 2u,
HAL_NFC_STATUS_ERR_CMD_TIMEOUT = 3u,
HAL_NFC_STATUS_REFUSED = 4u,
};
#ifdef __cplusplus
}
#endif
#endif // HIDL_GENERATED_ANDROID_HARDWARE_NFC_V1_0_EXPORTED_CONSTANTS_H_

1
include/hardware/nfc-base.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/nfc-base.h

View file

@ -1,277 +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 <stdint.h>
#include <strings.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
#include "nfc-base.h"
__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_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;
typedef uint8_t nfc_event_t;
typedef uint8_t nfc_status_t;
/*
* 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

1
include/hardware/nfc.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/nfc.h

View file

@ -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 <stdint.h>
#include <hardware/hardware.h>
__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 <size> 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 <data> 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

1
include/hardware/nfc_tag.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/nfc_tag.h

View file

@ -1,338 +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_NVRAM_H
#define ANDROID_HARDWARE_NVRAM_H
#include <stdint.h>
#include <sys/cdefs.h>
#include <hardware/hardware.h>
#include <hardware/nvram_defs.h>
__BEGIN_DECLS
/* The id of this module. */
#define NVRAM_HARDWARE_MODULE_ID "nvram"
#define NVRAM_HARDWARE_DEVICE_ID "nvram-dev"
/* The version of this module. */
#define NVRAM_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
#define NVRAM_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1)
struct nvram_module {
/**
* Common methods of the nvram_module. This *must* be the first member of
* nvram_module as users of this structure will cast a hw_module_t to
* nvram_module pointer in contexts where it's known the hw_module_t
* references a nvram_module.
*/
hw_module_t common;
/* There are no module methods other than the common ones. */
};
struct nvram_device {
/**
* Common methods of the nvram_device. This *must* be the first member of
* nvram_device as users of this structure will cast a hw_device_t to
* nvram_device pointer in contexts where it's known the hw_device_t
* references a nvram_device.
*/
struct hw_device_t common;
/**
* Outputs the total number of bytes available in NVRAM. This will
* always be at least 2048. If an implementation does not know the
* total size it may provide an estimate or 2048.
*
* device - The nvram_device instance.
* total_size - Receives the output. Cannot be NULL.
*/
nvram_result_t (*get_total_size_in_bytes)(const struct nvram_device* device,
uint64_t* total_size);
/**
* Outputs the unallocated number of bytes available in NVRAM. If an
* implementation does not know the available size it may provide an
* estimate or the total size.
*
* device - The nvram_device instance.
* available_size - Receives the output. Cannot be NULL.
*/
nvram_result_t (*get_available_size_in_bytes)(
const struct nvram_device* device, uint64_t* available_size);
/**
* Outputs the maximum number of bytes that can be allocated for a single
* space. This will always be at least 32. If an implementation does not
* limit the maximum size it may provide the total size.
*
* device - The nvram_device instance.
* max_space_size - Receives the output. Cannot be NULL.
*/
nvram_result_t (*get_max_space_size_in_bytes)(
const struct nvram_device* device, uint64_t* max_space_size);
/**
* Outputs the maximum total number of spaces that may be allocated.
* This will always be at least 8. Outputs NV_UNLIMITED_SPACES if any
* number of spaces are supported (limited only to available NVRAM
* bytes).
*
* device - The nvram_device instance.
* num_spaces - Receives the output. Cannot be NULL.
*/
nvram_result_t (*get_max_spaces)(const struct nvram_device* device,
uint32_t* num_spaces);
/**
* Outputs a list of created space indices. If |max_list_size| is
* 0, only |list_size| is populated.
*
* device - The nvram_device instance.
* max_list_size - The number of items in the |space_index_list|
* array.
* space_index_list - Receives the list of created spaces up to the
* given |max_list_size|. May be NULL if
* |max_list_size| is 0.
* list_size - Receives the number of items populated in
* |space_index_list|, or the number of items available
* if |space_index_list| is NULL.
*/
nvram_result_t (*get_space_list)(const struct nvram_device* device,
uint32_t max_list_size,
uint32_t* space_index_list,
uint32_t* list_size);
/**
* Outputs the size, in bytes, of a given space.
*
* device - The nvram_device instance.
* index - The space index.
* size - Receives the output. Cannot be NULL.
*/
nvram_result_t (*get_space_size)(const struct nvram_device* device,
uint32_t index, uint64_t* size);
/**
* Outputs the list of controls associated with a given space.
*
* device - The nvram_device instance.
* index - The space index.
* max_list_size - The number of items in the |control_list| array.
* control_list - Receives the list of controls up to the given
* |max_list_size|. May be NULL if |max_list_size|
* is 0.
* list_size - Receives the number of items populated in
* |control_list|, or the number of items available if
* |control_list| is NULL.
*/
nvram_result_t (*get_space_controls)(const struct nvram_device* device,
uint32_t index, uint32_t max_list_size,
nvram_control_t* control_list,
uint32_t* list_size);
/**
* Outputs whether locks are enabled for the given space. When a lock
* is enabled, the operation is disabled and any attempt to perform that
* operation will result in NV_RESULT_OPERATION_DISABLED.
*
* device - The nvram_device instance.
* index - The space index.
* write_lock_enabled - Will be set to non-zero iff write
* operations are currently disabled.
* read_lock_enabled - Will be set to non-zero iff read operations
* are currently disabled.
*/
nvram_result_t (*is_space_locked)(const struct nvram_device* device,
uint32_t index, int* write_lock_enabled,
int* read_lock_enabled);
/**
* Creates a new space with the given index, size, controls, and
* authorization value.
*
* device - The nvram_device instance.
* index - An index for the new space. The index can be any 32-bit
* value but must not already be assigned to an existing
* space.
* size_in_bytes - The number of bytes to allocate for the space.
* control_list - An array of controls to enforce for the space.
* list_size - The number of items in |control_list|.
* authorization_value - If |control_list| contains
* NV_CONTROL_READ_AUTHORIZATION and / or
* NV_CONTROL_WRITE_AUTHORIZATION, then this
* parameter provides the authorization value
* for these policies (if both controls are
* set then this value applies to both).
* Otherwise, this value is ignored and may
* be NULL.
* authorization_value_size - The number of bytes in
* |authorization_value|.
*/
nvram_result_t (*create_space)(const struct nvram_device* device,
uint32_t index, uint64_t size_in_bytes,
const nvram_control_t* control_list,
uint32_t list_size,
const uint8_t* authorization_value,
uint32_t authorization_value_size);
/**
* Deletes a space.
*
* device - The nvram_device instance.
* index - The space index.
* authorization_value - If the space has the
* NV_CONTROL_WRITE_AUTHORIZATION policy,
* then this parameter provides the
* authorization value. Otherwise, this value
* is ignored and may be NULL.
* authorization_value_size - The number of bytes in
* |authorization_value|.
*/
nvram_result_t (*delete_space)(const struct nvram_device* device,
uint32_t index,
const uint8_t* authorization_value,
uint32_t authorization_value_size);
/**
* Disables any further creation of spaces until the next full device
* reset (as in factory reset, not reboot). Subsequent calls to
* NV_CreateSpace should return NV_RESULT_OPERATION_DISABLED.
*
* device - The nvram_device instance.
*/
nvram_result_t (*disable_create)(const struct nvram_device* device);
/**
* Writes the contents of a space. If the space is configured with
* NV_CONTROL_WRITE_EXTEND then the input data is used to extend the
* current data.
*
* device - The nvram_device instance.
* index - The space index.
* buffer - The data to write.
* buffer_size - The number of bytes in |buffer|. If this is less
* than the size of the space, the remaining bytes
* will be set to 0x00. If this is more than the size
* of the space, returns NV_RESULT_INVALID_PARAMETER.
* authorization_value - If the space has the
* NV_CONTROL_WRITE_AUTHORIZATION policy,
* then this parameter provides the
* authorization value. Otherwise, this value
* is ignored and may be NULL.
* authorization_value_size - The number of bytes in
* |authorization_value|.
*/
nvram_result_t (*write_space)(const struct nvram_device* device,
uint32_t index, const uint8_t* buffer,
uint64_t buffer_size,
const uint8_t* authorization_value,
uint32_t authorization_value_size);
/**
* Reads the contents of a space. If the space has never been
* written, all bytes read will be 0x00.
*
* device - The nvram_device instance.
* index - The space index.
* num_bytes_to_read - The number of bytes to read; |buffer| must
* be large enough to hold this many bytes. If
* this is more than the size of the space, the
* entire space is read. If this is less than
* the size of the space, the first bytes in
* the space are read.
* authorization_value - If the space has the
* NV_CONTROL_READ_AUTHORIZATION policy, then
* this parameter provides the authorization
* value. Otherwise, this value is ignored
* and may be NULL.
* authorization_value_size - The number of bytes in
* |authorization_value|.
* buffer - Receives the data read from the space. Must be at least
* |num_bytes_to_read| bytes in size.
* bytes_read - The number of bytes read. If NV_RESULT_SUCCESS is
* returned this will be set to the smaller of
* |num_bytes_to_read| or the size of the space.
*/
nvram_result_t (*read_space)(const struct nvram_device* device,
uint32_t index, uint64_t num_bytes_to_read,
const uint8_t* authorization_value,
uint32_t authorization_value_size,
uint8_t* buffer, uint64_t* bytes_read);
/**
* Enables a write lock for the given space according to its policy.
* If the space does not have NV_CONTROL_PERSISTENT_WRITE_LOCK or
* NV_CONTROL_BOOT_WRITE_LOCK set then this function has no effect
* and may return an error.
*
* device - The nvram_device instance.
* index - The space index.
* authorization_value - If the space has the
* NV_CONTROL_WRITE_AUTHORIZATION policy,
* then this parameter provides the
* authorization value. Otherwise, this value
* is ignored and may be NULL.
* authorization_value_size - The number of bytes in
* |authorization_value|.
*/
nvram_result_t (*enable_write_lock)(const struct nvram_device* device,
uint32_t index,
const uint8_t* authorization_value,
uint32_t authorization_value_size);
/**
* Enables a read lock for the given space according to its policy.
* If the space does not have NV_CONTROL_BOOT_READ_LOCK set then this
* function has no effect and may return an error.
*
* device - The nvram_device instance.
* index - The space index.
* authorization_value - If the space has the
* NV_CONTROL_READ_AUTHORIZATION policy, then
* this parameter provides the authorization
* value. (Note that there is no requirement
* for write access in order to lock for
* reading. A read lock is always volatile.)
* Otherwise, this value is ignored and may
* be NULL.
* authorization_value_size - The number of bytes in
* |authorization_value|.
*/
nvram_result_t (*enable_read_lock)(const struct nvram_device* device,
uint32_t index,
const uint8_t* authorization_value,
uint32_t authorization_value_size);
};
typedef struct nvram_device nvram_device_t;
/* Convenience API for opening and closing nvram devices. */
static inline int nvram_open(const struct hw_module_t* module,
nvram_device_t** device) {
return module->methods->open(module, NVRAM_HARDWARE_DEVICE_ID,
TO_HW_DEVICE_T_OPEN(device));
}
static inline int nvram_close(nvram_device_t* device) {
return device->common.close(&device->common);
}
__END_DECLS
#endif // ANDROID_HARDWARE_NVRAM_H

1
include/hardware/nvram.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/nvram.h

View file

@ -1,61 +0,0 @@
/*
* Copyright (C) 2016 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 data type definitions and constants that are useful to
* code interacting with and implementing the NVRAM HAL, even though it doesn't
* use the actual NVRAM HAL module interface. Keeping this in a separate file
* simplifies inclusion in low-level code which can't easily include the heavier
* hardware.h due to lacking standard headers.
*/
#ifndef ANDROID_HARDWARE_NVRAM_DEFS_H
#define ANDROID_HARDWARE_NVRAM_DEFS_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/* Values returned by nvram_device methods. */
typedef uint32_t nvram_result_t;
const nvram_result_t NV_RESULT_SUCCESS = 0;
const nvram_result_t NV_RESULT_INTERNAL_ERROR = 1;
const nvram_result_t NV_RESULT_ACCESS_DENIED = 2;
const nvram_result_t NV_RESULT_INVALID_PARAMETER = 3;
const nvram_result_t NV_RESULT_SPACE_DOES_NOT_EXIST = 4;
const nvram_result_t NV_RESULT_SPACE_ALREADY_EXISTS = 5;
const nvram_result_t NV_RESULT_OPERATION_DISABLED = 6;
/* Values describing available access controls. */
typedef uint32_t nvram_control_t;
const nvram_control_t NV_CONTROL_PERSISTENT_WRITE_LOCK = 1;
const nvram_control_t NV_CONTROL_BOOT_WRITE_LOCK = 2;
const nvram_control_t NV_CONTROL_BOOT_READ_LOCK = 3;
const nvram_control_t NV_CONTROL_WRITE_AUTHORIZATION = 4;
const nvram_control_t NV_CONTROL_READ_AUTHORIZATION = 5;
const nvram_control_t NV_CONTROL_WRITE_EXTEND = 6;
const uint32_t NV_UNLIMITED_SPACES = 0xFFFFFFFF;
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // ANDROID_HARDWARE_NVRAM_DEFS_H

View file

@ -0,0 +1 @@
../../include_all/hardware/nvram_defs.h

View file

@ -1,343 +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 <stdbool.h>
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
__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)
#define POWER_MODULE_API_VERSION_0_4 HARDWARE_MODULE_API_VERSION(0, 4)
#define POWER_MODULE_API_VERSION_0_5 HARDWARE_MODULE_API_VERSION(0, 5)
/**
* The id of this module
*/
#define POWER_HARDWARE_MODULE_ID "power"
/*
* Platform-level sleep state stats.
* Maximum length of Platform-level sleep state name.
*/
#define POWER_STATE_NAME_MAX_LENGTH 100
/*
* Platform-level sleep state stats.
* Maximum length of Platform-level sleep state voter name.
*/
#define POWER_STATE_VOTER_NAME_MAX_LENGTH 100
/*
* 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_SUSTAINED_PERFORMANCE = 0x00000006,
POWER_HINT_VR_MODE = 0x00000007,
POWER_HINT_LAUNCH = 0x00000008,
POWER_HINT_DISABLE_TOUCH = 0x00000009
} power_hint_t;
typedef enum {
POWER_FEATURE_DOUBLE_TAP_TO_WAKE = 0x00000001
} feature_t;
/*
* Platform-level sleep state stats:
* power_state_voter_t struct is useful for describing the individual voters when a
* Platform-level sleep state is chosen by aggregation of votes from multiple
* clients/system conditions.
*
* This helps in attirbuting what in the device is blocking the device from
* entering the lowest Platform-level sleep state.
*/
typedef struct {
/*
* Name of the voter.
*/
char name[POWER_STATE_VOTER_NAME_MAX_LENGTH];
/*
* Total time in msec the voter voted for the platform sleep state since boot.
*/
uint64_t total_time_in_msec_voted_for_since_boot;
/*
* Number of times the voter voted for the platform sleep state since boot.
*/
uint64_t total_number_of_times_voted_since_boot;
} power_state_voter_t;
/*
* Platform-level sleep state stats:
* power_state_platform_sleep_state_t represents the Platform-level sleep state the
* device is capable of getting into.
*
* SoCs usually have more than one Platform-level sleep state.
*
* The caller calls the get_number_of_platform_modes function to figure out the size
* of power_state_platform_sleep_state_t array where each array element represents
* a specific Platform-level sleep state.
*
* Higher the index deeper the state is i.e. lesser steady-state power is consumed
* by the platform to be resident in that state.
*
* Caller allocates power_state_voter_t *voters for each Platform-level sleep state by
* calling get_voter_list.
*/
typedef struct {
/*
* Platform-level Sleep state name.
*/
char name[POWER_STATE_NAME_MAX_LENGTH];
/*
* Time spent in msec at this platform-level sleep state since boot.
*/
uint64_t residency_in_msec_since_boot;
/*
* Total number of times system entered this state.
*/
uint64_t total_transitions;
/*
* This platform-level sleep state can only be reached during system suspend.
*/
bool supported_only_in_suspend;
/*
* The following fields are useful if the Platform-level sleep state
* is chosen by aggregation votes from multiple clients/system conditions.
* All the voters have to say yes or all the system conditions need to be
* met to enter a platform-level sleep state.
*
* Setting number_of_voters to zero implies either the info is not available
* or the system does not follow a voting mechanism to choose this
* Platform-level sleep state.
*/
uint32_t number_of_voters;
/*
* Voter list - Has to be allocated by the caller.
*
* Caller allocates power_state_voter_t *voters for each Platform-level sleep state
* by calling get_voter_list.
*/
power_state_voter_t *voters;
} power_state_platform_sleep_state_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.
*
* Platform-level sleep state stats:
* Can Also be used to initiate device specific Platform-level
* Sleep state nodes from version 0.5 onwards.
*/
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_SUSTAINED_PERFORMANCE
*
* Sustained Performance mode is actived or deactivated. Sustained
* performance mode is intended to provide a consistent level of
* performance for a prolonged amount of time. The data parameter is
* non-zero when sustained performance mode is activated, and zero
* when deactivated.
*
* POWER_HINT_VR_MODE
*
* VR Mode is activated or deactivated. VR mode is intended to
* provide minimum guarantee for performance for the amount of time the
* device can sustain it. The data parameter is non-zero when the mode
* is activated and zero when deactivated.
*
* POWER_HINT_DISABLE_TOUCH
*
* When device enters some special modes, e.g. theater mode in Android
* Wear, there is no touch interaction expected between device and user.
* Touch controller could be disabled in those modes to save power.
* The data parameter is non-zero when touch could be disabled, and zero
* when touch needs to be re-enabled.
*
* 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);
/*
* Platform-level sleep state stats:
* Report cumulative info on the statistics on platform-level sleep states since boot.
*
* Caller of the function queries the get_number_of_sleep_states and allocates the
* memory for the power_state_platform_sleep_state_t *list before calling this function.
*
* power_stats module is responsible to assign values to all the fields as
* necessary.
*
* Higher the index deeper the state is i.e. lesser steady-state power is consumed
* by the platform to be resident in that state.
*
* The function returns 0 on success or negative value -errno on error.
* EINVAL - *list is NULL.
* EIO - filesystem nodes access error.
*
* availability: version 0.5
*/
int (*get_platform_low_power_stats)(struct power_module *module,
power_state_platform_sleep_state_t *list);
/*
* Platform-level sleep state stats:
* This function is called to determine the number of platform-level sleep states
* for get_platform_low_power_stats.
*
* The value returned by this function is used to allocate memory for
* power_state_platform_sleep_state_t *list for get_platform_low_power_stats.
*
* The number of parameters must not change for successive calls.
*
* Return number of parameters on success or negative value -errno on error.
* EIO - filesystem nodes access error.
*
* availability: version 0.5
*/
ssize_t (*get_number_of_platform_modes)(struct power_module *module);
/*
* Platform-level sleep state stats:
* Provides the number of voters for each of the Platform-level sleep state.
*
* Caller uses this function to allocate memory for the power_state_voter_t list.
*
* Caller has to allocate the space for the *voter array which is
* get_number_of_platform_modes() long.
*
* Return 0 on success or negative value -errno on error.
* EINVAL - *voter is NULL.
* EIO - filesystem nodes access error.
*
* availability: version 0.5
*/
int (*get_voter_list)(struct power_module *module, size_t *voter);
} power_module_t;
__END_DECLS
#endif // ANDROID_INCLUDE_HARDWARE_POWER_H

1
include/hardware/power.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/power.h

View file

@ -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 <system/radio.h>
#include <hardware/hardware.h>
#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,
TO_HW_DEVICE_T_OPEN(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

1
include/hardware/radio.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/radio.h

View file

@ -1,144 +0,0 @@
// This file is autogenerated by hidl-gen. Do not edit manually.
// Source: android.hardware.sensors@1.0
// Location: hardware/interfaces/sensors/1.0/
#ifndef HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_
#define HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_
#ifdef __cplusplus
extern "C" {
#endif
enum {
SENSOR_HAL_NORMAL_MODE = 0,
SENSOR_HAL_DATA_INJECTION_MODE = 1,
};
enum {
SENSOR_TYPE_META_DATA = 0,
SENSOR_TYPE_ACCELEROMETER = 1,
SENSOR_TYPE_MAGNETIC_FIELD = 2,
SENSOR_TYPE_ORIENTATION = 3,
SENSOR_TYPE_GYROSCOPE = 4,
SENSOR_TYPE_LIGHT = 5,
SENSOR_TYPE_PRESSURE = 6,
SENSOR_TYPE_TEMPERATURE = 7,
SENSOR_TYPE_PROXIMITY = 8,
SENSOR_TYPE_GRAVITY = 9,
SENSOR_TYPE_LINEAR_ACCELERATION = 10,
SENSOR_TYPE_ROTATION_VECTOR = 11,
SENSOR_TYPE_RELATIVE_HUMIDITY = 12,
SENSOR_TYPE_AMBIENT_TEMPERATURE = 13,
SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED = 14,
SENSOR_TYPE_GAME_ROTATION_VECTOR = 15,
SENSOR_TYPE_GYROSCOPE_UNCALIBRATED = 16,
SENSOR_TYPE_SIGNIFICANT_MOTION = 17,
SENSOR_TYPE_STEP_DETECTOR = 18,
SENSOR_TYPE_STEP_COUNTER = 19,
SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR = 20,
SENSOR_TYPE_HEART_RATE = 21,
SENSOR_TYPE_TILT_DETECTOR = 22,
SENSOR_TYPE_WAKE_GESTURE = 23,
SENSOR_TYPE_GLANCE_GESTURE = 24,
SENSOR_TYPE_PICK_UP_GESTURE = 25,
SENSOR_TYPE_WRIST_TILT_GESTURE = 26,
SENSOR_TYPE_DEVICE_ORIENTATION = 27,
SENSOR_TYPE_POSE_6DOF = 28,
SENSOR_TYPE_STATIONARY_DETECT = 29,
SENSOR_TYPE_MOTION_DETECT = 30,
SENSOR_TYPE_HEART_BEAT = 31,
SENSOR_TYPE_DYNAMIC_SENSOR_META = 32,
SENSOR_TYPE_ADDITIONAL_INFO = 33,
SENSOR_TYPE_LOW_LATENCY_OFFBODY_DETECT = 34,
SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED = 35,
SENSOR_TYPE_HINGE_ANGLE = 36,
SENSOR_TYPE_HEAD_TRACKER = 37,
SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES = 38,
SENSOR_TYPE_GYROSCOPE_LIMITED_AXES = 39,
SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED = 40,
SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED = 41,
SENSOR_TYPE_HEADING = 42,
SENSOR_TYPE_DEVICE_PRIVATE_BASE = 65536 /* 0x10000 */,
};
enum {
SENSOR_FLAG_WAKE_UP = 1u,
SENSOR_FLAG_CONTINUOUS_MODE = 0u,
SENSOR_FLAG_ON_CHANGE_MODE = 2u,
SENSOR_FLAG_ONE_SHOT_MODE = 4u,
SENSOR_FLAG_SPECIAL_REPORTING_MODE = 6u,
SENSOR_FLAG_DATA_INJECTION = 16u /* 0x10 */,
SENSOR_FLAG_DYNAMIC_SENSOR = 32u /* 0x20 */,
SENSOR_FLAG_ADDITIONAL_INFO = 64u /* 0x40 */,
SENSOR_FLAG_DIRECT_CHANNEL_ASHMEM = 1024u /* 0x400 */,
SENSOR_FLAG_DIRECT_CHANNEL_GRALLOC = 2048u /* 0x800 */,
SENSOR_FLAG_MASK_REPORTING_MODE = 14u /* 0xE */,
SENSOR_FLAG_MASK_DIRECT_REPORT = 896u /* 0x380 */,
SENSOR_FLAG_MASK_DIRECT_CHANNEL = 3072u /* 0xC00 */,
};
typedef enum {
SENSOR_FLAG_SHIFT_REPORTING_MODE = 1,
SENSOR_FLAG_SHIFT_DATA_INJECTION = 4,
SENSOR_FLAG_SHIFT_DYNAMIC_SENSOR = 5,
SENSOR_FLAG_SHIFT_ADDITIONAL_INFO = 6,
SENSOR_FLAG_SHIFT_DIRECT_REPORT = 7,
SENSOR_FLAG_SHIFT_DIRECT_CHANNEL = 10,
} sensor_flag_shift_t;
enum {
SENSOR_STATUS_NO_CONTACT = -1 /* -1 */,
SENSOR_STATUS_UNRELIABLE = 0,
SENSOR_STATUS_ACCURACY_LOW = 1,
SENSOR_STATUS_ACCURACY_MEDIUM = 2,
SENSOR_STATUS_ACCURACY_HIGH = 3,
};
enum {
META_DATA_FLUSH_COMPLETE = 1u,
};
typedef enum {
AINFO_BEGIN = 0u,
AINFO_END = 1u,
AINFO_UNTRACKED_DELAY = 65536u /* 0x10000 */,
AINFO_INTERNAL_TEMPERATURE = 65537u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_UNTRACKED_DELAY implicitly + 1 */,
AINFO_VEC3_CALIBRATION = 65538u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_INTERNAL_TEMPERATURE implicitly + 1 */,
AINFO_SENSOR_PLACEMENT = 65539u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_VEC3_CALIBRATION implicitly + 1 */,
AINFO_SAMPLING = 65540u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_SENSOR_PLACEMENT implicitly + 1 */,
AINFO_CHANNEL_NOISE = 131072u /* 0x20000 */,
AINFO_CHANNEL_SAMPLER = 131073u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_CHANNEL_NOISE implicitly + 1 */,
AINFO_CHANNEL_FILTER = 131074u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_CHANNEL_SAMPLER implicitly + 1 */,
AINFO_CHANNEL_LINEAR_TRANSFORM = 131075u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_CHANNEL_FILTER implicitly + 1 */,
AINFO_CHANNEL_NONLINEAR_MAP = 131076u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_CHANNEL_LINEAR_TRANSFORM implicitly + 1 */,
AINFO_CHANNEL_RESAMPLER = 131077u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_CHANNEL_NONLINEAR_MAP implicitly + 1 */,
AINFO_LOCAL_GEOMAGNETIC_FIELD = 196608u /* 0x30000 */,
AINFO_LOCAL_GRAVITY = 196609u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_LOCAL_GEOMAGNETIC_FIELD implicitly + 1 */,
AINFO_DOCK_STATE = 196610u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_LOCAL_GRAVITY implicitly + 1 */,
AINFO_HIGH_PERFORMANCE_MODE = 196611u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_DOCK_STATE implicitly + 1 */,
AINFO_MAGNETIC_FIELD_CALIBRATION = 196612u /* ::android::hardware::sensors::V1_0::AdditionalInfoType.AINFO_HIGH_PERFORMANCE_MODE implicitly + 1 */,
AINFO_CUSTOM_START = 268435456u /* 0x10000000 */,
AINFO_DEBUGGING_START = 1073741824u /* 0x40000000 */,
} additional_info_type_t;
typedef enum {
SENSOR_DIRECT_RATE_STOP = 0,
SENSOR_DIRECT_RATE_NORMAL = 1 /* ::android::hardware::sensors::V1_0::RateLevel.STOP implicitly + 1 */,
SENSOR_DIRECT_RATE_FAST = 2 /* ::android::hardware::sensors::V1_0::RateLevel.NORMAL implicitly + 1 */,
SENSOR_DIRECT_RATE_VERY_FAST = 3 /* ::android::hardware::sensors::V1_0::RateLevel.FAST implicitly + 1 */,
} direct_rate_level_t;
typedef enum {
SENSOR_DIRECT_MEM_TYPE_ASHMEM = 1,
SENSOR_DIRECT_MEM_TYPE_GRALLOC = 2 /* ::android::hardware::sensors::V1_0::SharedMemType.ASHMEM implicitly + 1 */,
} direct_mem_type_t;
typedef enum {
SENSOR_DIRECT_FMT_SENSORS_EVENT = 1,
} direct_format_t;
#ifdef __cplusplus
}
#endif
#endif // HIDL_GENERATED_ANDROID_HARDWARE_SENSORS_V1_0_EXPORTED_CONSTANTS_H_

View file

@ -0,0 +1 @@
../../include_all/hardware/sensors-base.h

View file

@ -1,836 +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 <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
#include <cutils/native_handle.h>
#include "sensors-base.h"
__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"
/**
* Sensor handle is greater than 0 and less than INT32_MAX.
*
* **** Deprecated ****
* Defined values below are kept for code compatibility. Note sensor handle can be as large as
* INT32_MAX.
*/
#define SENSORS_HANDLE_BASE 0
#define SENSORS_HANDLE_BITS 31
#define SENSORS_HANDLE_COUNT (1ull<<SENSORS_HANDLE_BITS)
/*
* **** Deprecated *****
* flags for (*batch)()
* Availability: SENSORS_DEVICE_API_VERSION_1_0
* see (*batch)() documentation for details.
* Deprecated as of SENSORS_DEVICE_API_VERSION_1_3.
* WAKE_UP_* sensors replace WAKE_UPON_FIFO_FULL concept.
*/
enum {
SENSORS_BATCH_DRY_RUN = 0x00000001,
SENSORS_BATCH_WAKE_UPON_FIFO_FULL = 0x00000002
};
/*
* what field for meta_data_event_t
*/
enum {
/* a previous flush operation has completed */
// META_DATA_FLUSH_COMPLETE = 1,
META_DATA_VERSION /* always last, leave auto-assigned */
};
/*
* The permission to use for body sensors (like heart rate monitors).
* See sensor types for more details on what sensors should require this
* permission.
*/
#define SENSOR_PERMISSION_BODY_SENSORS "android.permission.BODY_SENSORS"
/*
* sensor flags legacy names
*
* please use SENSOR_FLAG_* directly for new implementation.
* @see sensor_t
*/
#define SENSOR_FLAG_MASK(nbit, shift) (((1<<(nbit))-1)<<(shift))
#define SENSOR_FLAG_MASK_1(shift) SENSOR_FLAG_MASK(1, shift)
/*
* Mask and shift for reporting mode sensor flags defined above.
*/
#define REPORTING_MODE_SHIFT SENSOR_FLAG_SHIFT_REPORTING_MODE
#define REPORTING_MODE_NBIT (3)
#define REPORTING_MODE_MASK SENSOR_FLAG_MASK_REPORTING_MODE
/*
* Mask and shift for data_injection mode sensor flags defined above.
*/
#define DATA_INJECTION_SHIFT SENSOR_FLAG_SHIFT_DATA_INJECTION
#define DATA_INJECTION_MASK SENSOR_FLAG_DATA_INJECTION
/*
* Mask and shift for dynamic sensor flag.
*/
#define DYNAMIC_SENSOR_SHIFT SENSOR_FLAG_SHIFT_DYNAMIC_SENSOR
#define DYNAMIC_SENSOR_MASK SENSOR_FLAG_DYNAMIC_SENSOR
/*
* Mask and shift for sensor additional information support.
*/
#define ADDITIONAL_INFO_SHIFT SENSOR_FLAG_SHIFT_ADDITIONAL_INFO
#define ADDITIONAL_INFO_MASK SENSOR_FLAG_ADDITIONAL_INFO
/*
* Legacy alias of SENSOR_TYPE_MAGNETIC_FIELD.
*
* Previously, the type of a sensor measuring local magnetic field is named
* SENSOR_TYPE_GEOMAGNETIC_FIELD and SENSOR_TYPE_MAGNETIC_FIELD is its alias.
* SENSOR_TYPE_MAGNETIC_FIELD is redefined as primary name to avoid confusion.
* SENSOR_TYPE_GEOMAGNETIC_FIELD is the alias and is deprecating. New implementation must not use
* SENSOR_TYPE_GEOMAGNETIC_FIELD.
*/
#define SENSOR_TYPE_GEOMAGNETIC_FIELD SENSOR_TYPE_MAGNETIC_FIELD
/*
* Sensor string types for Android defined sensor types.
*
* For Android defined sensor types, string type will be override in sensor service and thus no
* longer needed to be added to sensor_t data structure.
*
* These definitions are going to be removed soon.
*/
#define SENSOR_STRING_TYPE_ACCELEROMETER "android.sensor.accelerometer"
#define SENSOR_STRING_TYPE_MAGNETIC_FIELD "android.sensor.magnetic_field"
#define SENSOR_STRING_TYPE_ORIENTATION "android.sensor.orientation"
#define SENSOR_STRING_TYPE_GYROSCOPE "android.sensor.gyroscope"
#define SENSOR_STRING_TYPE_LIGHT "android.sensor.light"
#define SENSOR_STRING_TYPE_PRESSURE "android.sensor.pressure"
#define SENSOR_STRING_TYPE_TEMPERATURE "android.sensor.temperature"
#define SENSOR_STRING_TYPE_PROXIMITY "android.sensor.proximity"
#define SENSOR_STRING_TYPE_GRAVITY "android.sensor.gravity"
#define SENSOR_STRING_TYPE_LINEAR_ACCELERATION "android.sensor.linear_acceleration"
#define SENSOR_STRING_TYPE_ROTATION_VECTOR "android.sensor.rotation_vector"
#define SENSOR_STRING_TYPE_RELATIVE_HUMIDITY "android.sensor.relative_humidity"
#define SENSOR_STRING_TYPE_AMBIENT_TEMPERATURE "android.sensor.ambient_temperature"
#define SENSOR_STRING_TYPE_MAGNETIC_FIELD_UNCALIBRATED "android.sensor.magnetic_field_uncalibrated"
#define SENSOR_STRING_TYPE_GAME_ROTATION_VECTOR "android.sensor.game_rotation_vector"
#define SENSOR_STRING_TYPE_GYROSCOPE_UNCALIBRATED "android.sensor.gyroscope_uncalibrated"
#define SENSOR_STRING_TYPE_SIGNIFICANT_MOTION "android.sensor.significant_motion"
#define SENSOR_STRING_TYPE_STEP_DETECTOR "android.sensor.step_detector"
#define SENSOR_STRING_TYPE_STEP_COUNTER "android.sensor.step_counter"
#define SENSOR_STRING_TYPE_GEOMAGNETIC_ROTATION_VECTOR "android.sensor.geomagnetic_rotation_vector"
#define SENSOR_STRING_TYPE_HEART_RATE "android.sensor.heart_rate"
#define SENSOR_STRING_TYPE_TILT_DETECTOR "android.sensor.tilt_detector"
#define SENSOR_STRING_TYPE_WAKE_GESTURE "android.sensor.wake_gesture"
#define SENSOR_STRING_TYPE_GLANCE_GESTURE "android.sensor.glance_gesture"
#define SENSOR_STRING_TYPE_PICK_UP_GESTURE "android.sensor.pick_up_gesture"
#define SENSOR_STRING_TYPE_WRIST_TILT_GESTURE "android.sensor.wrist_tilt_gesture"
#define SENSOR_STRING_TYPE_DEVICE_ORIENTATION "android.sensor.device_orientation"
#define SENSOR_STRING_TYPE_POSE_6DOF "android.sensor.pose_6dof"
#define SENSOR_STRING_TYPE_STATIONARY_DETECT "android.sensor.stationary_detect"
#define SENSOR_STRING_TYPE_MOTION_DETECT "android.sensor.motion_detect"
#define SENSOR_STRING_TYPE_HEART_BEAT "android.sensor.heart_beat"
#define SENSOR_STRING_TYPE_DYNAMIC_SENSOR_META "android.sensor.dynamic_sensor_meta"
#define SENSOR_STRING_TYPE_ADDITIONAL_INFO "android.sensor.additional_info"
#define SENSOR_STRING_TYPE_LOW_LATENCY_OFFBODY_DETECT "android.sensor.low_latency_offbody_detect"
#define SENSOR_STRING_TYPE_ACCELEROMETER_UNCALIBRATED "android.sensor.accelerometer_uncalibrated"
#define SENSOR_STRING_TYPE_HINGE_ANGLE "android.sensor.hinge_angle"
#define SENSOR_STRING_TYPE_HEAD_TRACKER "android.sensor.head_tracker"
#define SENSOR_STRING_TYPE_ACCELEROMETER_LIMITED_AXES "android.sensor.accelerometer_limited_axes"
#define SENSOR_STRING_TYPE_GYROSCOPE_LIMITED_AXES "android.sensor.gyroscope_limited_axes"
#define SENSOR_STRING_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED "android.sensor.accelerometer_limited_axes_uncalibrated"
#define SENSOR_STRING_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED "android.sensor.gyroscope_limited_axes_uncalibrated"
#define SENSOR_STRING_TYPE_HEADING "android.sensor.heading"
/**
* 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)
struct sensor_t;
/**
* 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 accelerometer, 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;
/**
* Dynamic sensor meta event. See the description of SENSOR_TYPE_DYNAMIC_SENSOR_META type for
* details.
*/
typedef struct dynamic_sensor_meta_event {
int32_t connected;
int32_t handle;
const struct sensor_t * sensor; // should be NULL if connected == false
uint8_t uuid[16]; // UUID of a dynamic sensor (using RFC 4122 byte order)
// For UUID 12345678-90AB-CDEF-1122-334455667788 the uuid field
// should be initialized as:
// {0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x11, ...}
} dynamic_sensor_meta_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;
typedef struct {
int32_t type; // type of payload data, see additional_info_type_t
int32_t serial; // sequence number of this frame for this type
union {
// for each frame, a single data type, either int32_t or float, should be used.
int32_t data_int32[14];
float data_float[14];
};
} additional_info_event_t;
typedef struct {
float rx;
float ry;
float rz;
float vx;
float vy;
float vz;
int32_t discontinuity_count;
} head_tracker_event_t;
/**
* limited axes imu event data
*/
typedef struct {
union {
float calib[3];
struct {
float x;
float y;
float z;
};
};
union {
float supported[3];
struct {
float x_supported;
float y_supported;
float z_supported;
};
};
} limited_axes_imu_event_t;
/**
* limited axes uncalibrated imu 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;
};
};
union {
float supported[3];
struct {
float x_supported;
float y_supported;
float z_supported;
};
};
} limited_axes_imu_uncalibrated_event_t;
/**
* Heading event data
*/
typedef struct {
float heading;
float accuracy;
} heading_event_t;
// LINT.IfChange
/**
* Union of the various types of sensor data
* that can be returned.
* This type needs to remain identical to ASensorEvent.
*/
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;
/* uncalibrated accelerometer values are in meter per second per second (m/s^2) */
uncalibrated_event_t uncalibrated_accelerometer;
/* 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;
/* dynamic sensor meta event. See SENSOR_TYPE_DYNAMIC_SENSOR_META type for details */
dynamic_sensor_meta_event_t dynamic_sensor_meta;
/*
* special additional sensor information frame, see
* SENSOR_TYPE_ADDITIONAL_INFO for details.
*/
additional_info_event_t additional_info;
/* vector describing head orientation (added for legacy code support only) */
head_tracker_event_t head_tracker;
/*
* limited axes imu event, See
* SENSOR_TYPE_GYROSCOPE_LIMITED_AXES and
* SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES for details.
*/
limited_axes_imu_event_t limited_axes_imu;
/*
* limited axes imu uncalibrated event, See
* SENSOR_TYPE_GYROSCOPE_LIMITED_AXES_UNCALIBRATED and
* SENSOR_TYPE_ACCELEROMETER_LIMITED_AXES_UNCALIBRATED for details.
*/
limited_axes_imu_uncalibrated_event_t limited_axes_imu_uncalibrated;
/* heading data containing value in degrees and its accuracy */
heading_event_t heading;
};
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;
// LINT.ThenChange (frameworks/native/include/android/sensor.h)
/* see SENSOR_TYPE_META_DATA */
typedef sensors_event_t sensors_meta_data_event_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 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.
*
* If type is OEM specific or sensor manufacturer specific type
* (>=SENSOR_TYPE_DEVICE_PRIVATE_BASE), this string must be defined with reserved domain of
* vendor/OEM as a prefix, e.g. com.google.glass.onheaddetector
*
* For sensors of Android defined types, Android framework will override this value. It is ok to
* leave it pointing to an empty string.
*/
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];
};
/**
* Shared memory information for a direct channel
*/
struct sensors_direct_mem_t {
int type; // enum SENSOR_DIRECT_MEM_...
int format; // enum SENSOR_DIRECT_FMT_...
size_t size; // size of the memory region, in bytes
const struct native_handle *handle; // shared memory handle, which is interpreted differently
// depending on type
};
/**
* Direct channel report configuration
*/
struct sensors_direct_cfg_t {
int rate_level; // enum SENSOR_DIRECT_RATE_...
};
/*
* 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.
*
* sensor_handle is the handle of the sensor to change.
* enabled set to 1 to enable, or 0 to disable the sensor.
*
* Before sensor activation, existing sensor events that have not
* been picked up by poll() should be abandoned so that application
* upon new activation request will not get stale events.
* (events that are generated during latter activation or during
* data injection mode after sensor deactivation)
*
* 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);
/**
* Write an array of sensor_event_t to data. The size of the
* available buffer is specified by count. Returns number of
* valid sensor_event_t.
*
* This function should block if there is no sensor event
* available when being called. Thus, return value should always be
* positive.
*/
int (*poll)(struct sensors_poll_device_t *dev,
sensors_event_t* data, int count);
};
};
/*
* Sets a sensors 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);
/*
* Register/unregister direct report channel.
*
* A HAL declares support for direct report by setting non-NULL values for both
* register_direct_channel and config_direct_report.
*
* This function has two operation modes:
*
* Register: mem != NULL, register a channel using supplied shared memory information. By the
* time this function returns, sensors must finish initializing shared memory content
* (format dependent, see SENSOR_DIRECT_FMT_*).
* Parameters:
* mem points to a valid struct sensors_direct_mem_t.
* channel_handle is ignored.
* Return value:
* A handle of channel (>0, <INT32_MAX) when success, which later can be referred in
* unregister or config_direct_report call, or error code (<0) when failed
* Unregister: mem == NULL, unregister a previously registered channel.
* Parameters:
* mem set to NULL
* channel_handle contains handle of channel to be unregistered
* Return value:
* 0, even if the channel_handle is invalid, in which case it will be a no-op.
*/
int (*register_direct_channel)(struct sensors_poll_device_1 *dev,
const struct sensors_direct_mem_t* mem, int channel_handle);
/*
* Configure direct sensor event report in direct channel.
*
* Start, modify rate or stop direct report of a sensor in a certain direct channel. A special
* case is setting sensor handle -1 to stop means to stop all active sensor report on the
* channel specified.
*
* A HAL declares support for direct report by setting non-NULL values for both
* register_direct_channel and config_direct_report.
*
* Parameters:
* sensor_handle sensor to be configured. The sensor has to support direct report
* mode by setting flags of sensor_t. Also, direct report mode is only
* defined for continuous reporting mode sensors.
* channel_handle channel handle to be configured.
* config direct report parameters, see sensor_direct_cfg_t.
* Return value:
* - when sensor is started or sensor rate level is changed: return positive identifier of
* sensor in specified channel if successful, otherwise return negative error code.
* - when sensor is stopped: return 0 for success or negative error code for failure.
*/
int (*config_direct_report)(struct sensors_poll_device_1 *dev,
int sensor_handle, int channel_handle, const struct sensors_direct_cfg_t *config);
/*
* Reserved for future use, must be zero.
*/
void (*reserved_procs[5])(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, TO_HW_DEVICE_T_OPEN(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, TO_HW_DEVICE_T_OPEN(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

1
include/hardware/sensors.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/sensors.h

View file

@ -1,201 +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 <system/audio.h>
#include <system/sound_trigger.h>
#include <hardware/hardware.h>
#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_1_1 HARDWARE_DEVICE_API_VERSION(1, 1)
#define SOUND_TRIGGER_DEVICE_API_VERSION_1_2 HARDWARE_DEVICE_API_VERSION(1, 2)
#define SOUND_TRIGGER_DEVICE_API_VERSION_1_3 HARDWARE_DEVICE_API_VERSION(1, 3)
#define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_3
/**
* 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);
/* Stop recognition on all models.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_1 or above.
* If no implementation is provided, stop_recognition will be called for each running model.
*/
int (*stop_all_recognitions)(const struct sound_trigger_hw_device* dev);
/* Get the current state of a given model.
* The state will be returned as a recognition event, via the callback that was registered
* in the start_recognition method.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_2 or above.
*/
int (*get_model_state)(const struct sound_trigger_hw_device *dev,
sound_model_handle_t sound_model_handle);
/* Set a model specific ModelParameter with the given value. This parameter
* will keep its value for the duration the model is loaded regardless of starting and stopping
* recognition. Once the model is unloaded, the value will be lost.
* Returns 0 or an error code.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_3 or above.
*/
int (*set_parameter)(const struct sound_trigger_hw_device *dev,
sound_model_handle_t sound_model_handle,
sound_trigger_model_parameter_t model_param, int32_t value);
/* Get a model specific ModelParameter. This parameter will keep its value
* for the duration the model is loaded regardless of starting and stopping recognition.
* Once the model is unloaded, the value will be lost. If the value is not set, a default
* value is returned. See sound_trigger_model_parameter_t for parameter default values.
* Returns 0 or an error code. On return 0, value pointer will be set.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_3 or above.
*/
int (*get_parameter)(const struct sound_trigger_hw_device *dev,
sound_model_handle_t sound_model_handle,
sound_trigger_model_parameter_t model_param, int32_t* value);
/* Get supported parameter attributes with respect to the provided model
* handle. Along with determining the valid range, this API is also used
* to determine if a given parameter ID is supported at all by the
* modelHandle for use with getParameter and setParameter APIs.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_3 or above.
*/
int (*query_parameter)(const struct sound_trigger_hw_device *dev,
sound_model_handle_t sound_model_handle,
sound_trigger_model_parameter_t model_param,
sound_trigger_model_parameter_range_t* param_range);
/*
* Retrieve verbose extended implementation properties.
* The header pointer is intented to be cast to the proper extended
* properties struct based on the header version.
* The returned pointer is valid throughout the lifetime of the driver.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_3 or above.
*/
const struct sound_trigger_properties_header* (*get_properties_extended)
(const struct sound_trigger_hw_device *dev);
/* Start recognition on a given model. Only one recognition active at a time per model.
* Once recognition succeeds of fails, the callback is called.
* Recognition API includes extended config fields. The header is intended to be base to
* the proper config struct based on the header version.
* Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_3 or above.
*/
int (*start_recognition_extended)(const struct sound_trigger_hw_device *dev,
sound_model_handle_t sound_model_handle,
const struct sound_trigger_recognition_config_header *header,
recognition_callback_t callback,
void *cookie);
};
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,
TO_HW_DEVICE_T_OPEN(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

View file

@ -0,0 +1 @@
../../include_all/hardware/sound_trigger.h

View file

@ -1,209 +0,0 @@
/*
* Copyright (C) 2016 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_THERMAL_H
#define ANDROID_INCLUDE_HARDWARE_THERMAL_H
#include <stdbool.h>
#include <stdint.h>
#include <float.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
__BEGIN_DECLS
#define THERMAL_HARDWARE_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
#define THERMAL_HARDWARE_MODULE_ID "thermal"
// This value is returned if a desired temperature is not available.
#define UNKNOWN_TEMPERATURE -FLT_MAX
/** Device temperature types. Must be kept in sync with
* framework/base/core/java/android/os/HardwarePropertiesManager.java
*/
enum temperature_type {
DEVICE_TEMPERATURE_UNKNOWN = -1,
DEVICE_TEMPERATURE_CPU = 0,
DEVICE_TEMPERATURE_GPU = 1,
DEVICE_TEMPERATURE_BATTERY = 2,
DEVICE_TEMPERATURE_SKIN = 3
};
enum cooling_type {
/** Fan cooling device speed in RPM. */
FAN_RPM = 0,
};
typedef struct {
/**
* This temperature's type.
*/
enum temperature_type type;
/**
* Name of this temperature.
* All temperatures of the same "type" must have a different "name".
*/
const char *name;
/**
* Current temperature in Celsius. If not available set by HAL to
* UNKNOWN_TEMPERATURE.
* Current temperature can be in any units if
* type=DEVICE_TEMPERATURE_UNKNOWN.
*/
float current_value;
/**
* Throttling temperature constant for this temperature.
* If not available, set by HAL to UNKNOWN_TEMPERATURE.
*/
float throttling_threshold;
/**
* Shutdown temperature constant for this temperature.
* If not available, set by HAL to UNKNOWN_TEMPERATURE.
*/
float shutdown_threshold;
/**
* Threshold temperature above which the VR mode clockrate minimums cannot
* be maintained for this device.
* If not available, set by HAL to UNKNOWN_TEMPERATURE.
*/
float vr_throttling_threshold;
} temperature_t;
typedef struct {
/**
* This cooling device type.
*/
enum cooling_type type;
/**
* Name of this cooling device.
* All cooling devices of the same "type" must have a different "name".
*/
const char *name;
/**
* Current cooling device value. Units depend on cooling device "type".
*/
float current_value;
} cooling_device_t;
typedef struct {
/**
* Name of this CPU.
* All CPUs must have a different "name".
*/
const char *name;
/**
* Active time since the last boot in ms.
*/
uint64_t active;
/**
* Total time since the last boot in ms.
*/
uint64_t total;
/**
* Is set to true when a core is online.
* If the core is offline, all other members except |name| should be ignored.
*/
bool is_online;
} cpu_usage_t;
typedef struct thermal_module {
struct hw_module_t common;
/*
* (*getTemperatures) is called to get temperatures in Celsius.
*
* @param list If NULL, this method only returns number of temperatures
* and caller should allocate a temperature_t array with that number
* of elements.
* Caller is responsible for allocating temperature_t array |list| of
* large enough size (not less than returned number of temperatures).
* If |list| is not NULL and this method returns non-negative value,
* it's filled with the current temperatures. If the resulting
* temperature list is longer than |size| elements, the remaining
* temperatures are discarded and not stored, but counted for the value
* returned by this method.
* The order of temperatures of built-in devices (such as CPUs, GPUs and
* etc.) in the |list| is kept the same regardless the number of calls
* to this method even if they go offline, if these devices exist on
* boot. The method always returns and never removes such temperatures.
* @param size The capacity of |list|, in elements, if |list| is not NULL.
*
* @return number of temperatures or negative value -errno on error.
*
*/
ssize_t (*getTemperatures)(struct thermal_module *module, temperature_t *list, size_t size);
/*
* (*getCpuUsages) is called to get CPU usage information of each core:
* active and total times in ms since first boot.
*
* @param list If NULL, this method only returns number of cores and caller
* should allocate a cpu_usage_t array with that number of elements.
* Caller is responsible for allocating cpu_usage_t array |list| of
* large enough size (not less than returned number of CPUs).
* If |list| is not NULL and this method returns non-negative value,
* it's filled with the current CPU usages.
* The order of CPUs in the |list| is kept the same regardless the
* number of calls to this method.
*
* @return constant number of CPUs or negative value -errno on error.
*
*/
ssize_t (*getCpuUsages)(struct thermal_module *module, cpu_usage_t *list);
/*
* (*getCoolingDevices) is called to get the cooling devices information.
*
* @param list If NULL, this method only returns number of cooling devices
* and caller should allocate a cooling_device_t array with that number
* of elements.
* Caller is responsible for allocating cooling_device_t array |list| of
* large enough size (not less than returned number of cooling devices).
* If |list| is not NULL and this method returns non-negative value,
* it's filled with the current cooling device information. If the
* resulting cooling device list is longer than |size| elements, the
* remaining cooling device informations are discarded and not stored,
* but counted for the value returned by this method.
* The order of built-in coolling devices in the |list| is kept the same
* regardless the number of calls to this method even if they go
* offline, if these devices exist on boot. The method always returns
* and never removes from the list such coolling devices.
* @param size The capacity of |list|, in elements, if |list| is not NULL.
*
* @return number of cooling devices or negative value -errno on error.
*
*/
ssize_t (*getCoolingDevices)(struct thermal_module *module, cooling_device_t *list,
size_t size);
} thermal_module_t;
__END_DECLS
#endif // ANDROID_INCLUDE_HARDWARE_THERMAL_H

1
include/hardware/thermal.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/thermal.h

View file

@ -1,405 +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 <stdint.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <hardware/hardware.h>
#include <system/audio.h>
#include <cutils/native_handle.h>
__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;
} 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

1
include/hardware/tv_input.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/tv_input.h

View file

@ -1,73 +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 <hardware/hardware.h>
__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
*
* This function must only be called after the previous timeout has expired or
* was canceled (through vibrator_off()).
*
* @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
*
* Cancel a previously-started vibration, if any.
*
* @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, TO_HW_DEVICE_T_OPEN(device));
}
__END_DECLS
#endif // _HARDWARE_VIBRATOR_H

1
include/hardware/vibrator.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/vibrator.h

View file

@ -1,115 +0,0 @@
/*
* Copyright (C) 2016 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_VR_H
#define ANDROID_INCLUDE_HARDWARE_VR_H
#include <stdbool.h>
#include <sys/cdefs.h>
#include <hardware/hardware.h>
__BEGIN_DECLS
#define VR_HARDWARE_MODULE_ID "vr"
#define VR_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
/**
* Implement this HAL to receive callbacks when a virtual reality (VR)
* application is being used. VR applications characteristically have a number
* of special display and performance requirements, including:
* - Low sensor latency - Total end-to-end latency from the IMU, accelerometer,
* and gyro to an application-visible callback must be extremely low (<5ms
* typically). This is required for HIFI sensor support.
* - Low display latency - Total end-to-end latency from the GPU draw calls to
* the actual display update must be as low as possible. This is achieved by
* using SurfaceFlinger in a single-buffered mode, and assuring that draw calls
* are synchronized with the display scanout correctly. This behavior is
* exposed via an EGL extension to applications. See below for the EGL
* extensions needed for this.
* - Low-persistence display - Display persistence settings must be set as low as
* possible while still maintaining a reasonable brightness. For a typical
* display running at 60Hz, pixels should be illuminated for <=3.5ms to be
* considered low-persistence. This avoids ghosting during movements in a VR
* setting, and should be enabled from the lights.h HAL when
* BRIGHTNESS_MODE_LOW_PERSISTENCE is set.
* - Consistent performance of the GPU and CPU - When given a mixed GPU/CPU
* workload for a VR application with bursts of work at regular intervals
* several times a frame, the CPU scheduling should ensure that the application
* render thread work is run consistently within 1ms of when scheduled, and
* completed before the end of the draw window. To this end, a single CPU core
* must be reserved for solely for the currently running VR application's render
* thread while in VR mode, and made available in the "top-app" cpuset.
* Likewise, an appropriate CPU, GPU, and bus clockrate must be maintained to
* ensure that the rendering workload finishes within the time allotted to
* render each frame when the POWER_HINT_SUSTAINED_PERFORMANCE flag has been
* set in the power.h HAL while in VR mode when the device is not being
* thermally throttled.
* - Required EGL extensions must be present - Any GPU settings required to allow
* the above capabilities are required, including the EGL extensions:
* EGL_ANDROID_create_native_client_buffer, EGL_ANDROID_front_buffer_auto_refresh,
* EGL_EXT_protected_content, EGL_KHR_mutable_render_buffer,
* EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.
* - Accurate thermal reporting - Accurate thermal temperatures and limits must be
* reported in the thermal.h HAL. Specifically, the current skin temperature
* must accurately be reported for DEVICE_TEMPERATURE_SKIN and the
* vr_throttling_threshold reported for this device must accurately report the
* temperature limit above which the device's thermal governor throttles the
* CPU, GPU, and/or bus clockrates below the minimum necessary for consistent
* performance (see previous bullet point).
*
* In general, vendors implementing this HAL are expected to use set_vr_mode as a
* hint to enable VR-specific performance tuning needed for any of the above
* requirements, and to turn on any device features optimal for VR display
* modes. The set_vr_mode call may simply do nothing if no optimizations are
* available or necessary to meet the above requirements.
*
* No methods in this HAL will be called concurrently from the Android framework.
*/
typedef struct vr_module {
/**
* Common methods of the module. This *must* be the first member of
* vr_module as users of this structure may cast a hw_module_t to a
* vr_module pointer in contexts where it's known that the hw_module_t
* references a vr_module.
*/
struct hw_module_t common;
/**
* Convenience method for the HAL implementation to set up any state needed
* at runtime startup. This is called once from the VrManagerService during
* its boot phase. No methods from this HAL will be called before init.
*/
void (*init)(struct vr_module *module);
/**
* Set the VR mode state. Possible states of the enabled parameter are:
* false - VR mode is disabled, turn off all VR-specific settings.
* true - VR mode is enabled, turn on all VR-specific settings.
*
* This is called whenever the the Android system enters or leaves VR mode.
* This will typically occur when the user switches to or from a VR application
* that is doing stereoscopic rendering.
*/
void (*set_vr_mode)(struct vr_module *module, bool enabled);
/* Reserved for future use. Must be NULL. */
void* reserved[8 - 2];
} vr_module_t;
__END_DECLS
#endif /* ANDROID_INCLUDE_HARDWARE_VR_H */

1
include/hardware/vr.h Symbolic link
View file

@ -0,0 +1 @@
../../include_all/hardware/vr.h

View file

@ -0,0 +1,243 @@
/*
* 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 <hardware/hardware.h>
__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.
*
* At the first detection after this function gets called, the hardware should know whether the
* user is in the activity.
* - If event_type is ACTIVITY_EVENT_ENTER and the user is in the activity, then an
* (ACTIVITY_EVENT_ENTER, activity) event should be added to the FIFO.
* - If event_type is ACTIVITY_EVENT_EXIT and the user is not in the activity, then an
* (ACTIVITY_EVENT_EXIT, activity) event should be added to the FIFO.
* For example, suppose get_supported_activities_list contains on_bicyle and running, and the
* user is biking. Consider the following four calls that could happen in any order.
* - When enable_activity_event(on_bicycle, ACTIVITY_EVENT_ENTER) is called,
* (ACTIVITY_EVENT_ENTER, on_bicycle) should be added to the FIFO.
* - When enable_activity_event(on_bicycle, ACTIVITY_EVENT_EXIT) is called, nothing should be
* added to the FIFO.
* - When enable_activity_event(running, ACTIVITY_EVENT_ENTER) is called, nothing should be
* added to the FIFO.
* - When enable_activity_event(running, ACTIVITY_EVENT_EXIT) is called,
* (ACTIVITY_EVENT_EXIT, running) should be added to the FIFO.
*
* 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. It should be
* either ACTIVITY_EVENT_ENTER or ACTIVITY_EVENT_EXIT.
* 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. All the (activity, event_type)
* events in the FIFO are discarded.
*/
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.
* activity_callback should be called before this function returns successfully.
* 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

Some files were not shown because too many files have changed in this diff Show more