Merge "Gralloc 1.0" into nyc-dev
diff --git a/include/hardware/context_hub.h b/include/hardware/context_hub.h
index 79054d2..62ffd06 100644
--- a/include/hardware/context_hub.h
+++ b/include/hardware/context_hub.h
@@ -74,6 +74,25 @@
#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)
@@ -100,17 +119,23 @@
uint32_t mem_flags; // MEM_FLAG_*
};
+#define NANOAPP_SIGNED_FLAG 0x1
+#define NANOAPP_ENCRYPTED_FLAG 0x2
-/**
- * App names may be strings, bytes, uints, etc. This caovers all types of app names
- */
-struct hub_app_name_t {
- uint32_t app_name_len;
- const void *app_name;
+// 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
+ uint32_t reserved[2]; // Should be all zeroes
+ uint8_t custom_binary[0]; // start of custom binary data
};
struct hub_app_info {
- const struct hub_app_name_t *name;
+ struct hub_app_name_t app_name;
uint32_t version;
uint32_t num_mem_ranges;
const struct mem_range_t *mem_usage;
@@ -182,26 +207,13 @@
};
};
-
-
-/**
- * Messages of this length or less must be supported by all implementations,
- * longer lengths are supported up to max_supported_msg_len. This is exposed
- * to third party apps, and since we do not know their msg data formats we
- * cannot fragment for them. Our own messages are allowed to be bigger and
- * this HAL will fragment as needed. "Our own" messages are messaegs defined
- * in this file.
- */
-#define HUB_REQUIRED_SUPPORTED_MSG_LEN 128
-
struct hub_message_t {
- const struct hub_app_name_t *app; /* To/From this nanoapp */
+ 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,
@@ -225,11 +237,126 @@
const struct connected_sensor_t *connected_sensors; // array of connected sensors
uint32_t num_connected_sensors; // number of connected sensors
- uint32_t max_supported_msg_len;
- const struct hub_app_name_t *os_app_name; /* send msgs here for OS functions */
+ 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[]
+ */
+
+/**
* 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.
@@ -238,18 +365,16 @@
*/
typedef enum {
- CONTEXT_HUB_APPS_ENABLE = 1, // 1: Enables the loaded nano-apps
- CONTEXT_HUB_APPS_DISABLE, // 2: Disables any loaded nano-apps
- 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 apps info on hub (gets struct hub_app_info[])
- CONTEXT_HUB_QUERY_MEMORY, // 5: Query for memory info (gets struct mem_range_t[])
- CONTEXT_HUB_LOAD_OS, // 6: Load up OS update
+ 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
} hub_messages_e;
#define CONTEXT_HUB_TYPE_PRIVATE_MSG_BASE 0x10000
-
/**
* A callback registers with the context hub service to pass messages
* coming from the hub to the service/clients.
diff --git a/include/hardware/gps.h b/include/hardware/gps.h
index a54948c..4fc06bc 100644
--- a/include/hardware/gps.h
+++ b/include/hardware/gps.h
@@ -1469,7 +1469,7 @@
/**
* Leap second data.
* The sign of the value is defined by the following equation:
- * utc_time_ns = time_ns + (full_bias_ns + bias_ns) - leap_second *
+ * utc_time_ns = time_ns - (full_bias_ns + bias_ns) - leap_second *
* 1,000,000,000
*
* If the data is available 'flags' must contain GNSS_CLOCK_HAS_LEAP_SECOND.
@@ -1483,8 +1483,9 @@
* For local hardware clock, this value is expected to be monotonically
* increasing while the hardware clock remains power on. (For the case of a
* HW clock that is not continuously on, see the
- * hw_clock_discontinuity_count field). The real GPS time can be derived by
- * adding the 'full_bias_ns + bias_ns' (when it is available) to this value.
+ * hw_clock_discontinuity_count field). The receiver's estimate of GPS time
+ * can be derived by substracting the sum of full_bias_ns and bias_ns (when
+ * available) from this value.
*
* This GPS time is expected to be the best estimate of current GPS time
* that GNSS receiver can achieve.
@@ -1513,20 +1514,22 @@
* and the true GPS time since 0000Z, January 6, 1980, in nanoseconds.
*
* The sign of the value is defined by the following equation:
- * local estimate of GPS time = time_ns + (full_bias_ns + bias_ns)
+ * local estimate of GPS time = time_ns - (full_bias_ns + bias_ns)
*
* This value is mandatory if the receiver has estimated GPS time. If the
* computed time is for a non-GPS constellation, the time offset of that
- * constellation to GPS has to be applied to fill this value. The value
- * contains the 'bias uncertainty' in it, and the caller is responsible of
- * using the uncertainty. If the data is available 'flags' must contain
- * GNSS_CLOCK_HAS_FULL_BIAS.
+ * constellation to GPS has to be applied to fill this value. The error
+ * estimate for the sum of this and the bias_ns is the bias_uncertainty_ns,
+ * and the caller is responsible for using this uncertainty (it can be very
+ * large before the GPS time has been solved for.) If the data is available
+ * 'flags' must contain GNSS_CLOCK_HAS_FULL_BIAS.
*/
int64_t full_bias_ns;
/**
* Sub-nanosecond bias.
- * The value contains the 'bias uncertainty' in it.
+ * The error estimate for the sum of this and the full_bias_ns is the
+ * bias_uncertainty_ns
*
* If the data is available 'flags' must contain GNSS_CLOCK_HAS_BIAS. If GPS
* has computed a position fix. This value is mandatory if the receiver has
@@ -1549,7 +1552,8 @@
* The clock's drift in nanoseconds (per second).
*
* A positive value means that the frequency is higher than the nominal
- * frequency.
+ * frequency, and that the (full_bias_ns + bias_ns) is growing more positive
+ * over time.
*
* The value contains the 'drift uncertainty' in it.
* If the data is available 'flags' must contain GNSS_CLOCK_HAS_DRIFT.
diff --git a/include/hardware/hwcomposer2.h b/include/hardware/hwcomposer2.h
index 9650ae1..095557a 100644
--- a/include/hardware/hwcomposer2.h
+++ b/include/hardware/hwcomposer2.h
@@ -206,6 +206,7 @@
HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
HWC2_FUNCTION_GET_DISPLAY_TYPE,
HWC2_FUNCTION_GET_DOZE_SUPPORT,
+ HWC2_FUNCTION_GET_HDR_CAPABILITIES,
HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
HWC2_FUNCTION_GET_RELEASE_FENCES,
HWC2_FUNCTION_PRESENT_DISPLAY,
@@ -234,7 +235,7 @@
HWC2_FUNCTION_VALIDATE_DISPLAY,
} hwc2_function_descriptor_t;
-/* Layer requests returned from getDisplayRequests. */
+/* Layer requests returned from getDisplayRequests */
typedef enum {
/* The client should clear its target with transparent pixels where this
* layer would be. The client may ignore this request if the layer must be
@@ -412,6 +413,7 @@
case HWC2_FUNCTION_GET_DISPLAY_REQUESTS: return "GetDisplayRequests";
case HWC2_FUNCTION_GET_DISPLAY_TYPE: return "GetDisplayType";
case HWC2_FUNCTION_GET_DOZE_SUPPORT: return "GetDozeSupport";
+ case HWC2_FUNCTION_GET_HDR_CAPABILITIES: return "GetHdrCapabilities";
case HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT:
return "GetMaxVirtualDisplayCount";
case HWC2_FUNCTION_GET_RELEASE_FENCES: return "GetReleaseFences";
@@ -603,6 +605,7 @@
GetDisplayRequests = HWC2_FUNCTION_GET_DISPLAY_REQUESTS,
GetDisplayType = HWC2_FUNCTION_GET_DISPLAY_TYPE,
GetDozeSupport = HWC2_FUNCTION_GET_DOZE_SUPPORT,
+ GetHdrCapabilities = HWC2_FUNCTION_GET_HDR_CAPABILITIES,
GetMaxVirtualDisplayCount = HWC2_FUNCTION_GET_MAX_VIRTUAL_DISPLAY_COUNT,
GetReleaseFences = HWC2_FUNCTION_GET_RELEASE_FENCES,
PresentDisplay = HWC2_FUNCTION_PRESENT_DISPLAY,
@@ -1244,6 +1247,42 @@
typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_DOZE_SUPPORT)(
hwc2_device_t* device, hwc2_display_t display, int32_t* outSupport);
+/* getHdrCapabilities(..., outNumTypes, outTypes, outMaxLuminance,
+ * outMaxAverageLuminance, outMinLuminance)
+ * Descriptor: HWC2_FUNCTION_GET_HDR_CAPABILITIES
+ * Must be provided by all HWC2 devices
+ *
+ * Returns the high dynamic range (HDR) capabilities of the given display, which
+ * are invariant with regard to the active configuration.
+ *
+ * Displays which are not HDR-capable must return no types in outTypes and set
+ * outNumTypes to 0.
+ *
+ * If outTypes is NULL, the required number of HDR types must be returned in
+ * outNumTypes.
+ *
+ * Parameters:
+ * outNumTypes - if outTypes was NULL, the number of types which would have
+ * been returned; if it was not NULL, the number of types stored in
+ * outTypes, which must not exceed the value stored in outNumTypes prior
+ * to the call; pointer will be non-NULL
+ * outTypes - an array of HDR types, may have 0 elements if the display is not
+ * HDR-capable
+ * outMaxLuminance - the desired content maximum luminance for this display in
+ * cd/m^2; pointer will be non-NULL
+ * outMaxAverageLuminance - the desired content maximum frame-average
+ * luminance for this display in cd/m^2; pointer will be non-NULL
+ * outMinLuminance - the desired content minimum luminance for this display in
+ * cd/m^2; pointer will be non-NULL
+ *
+ * Returns HWC2_ERROR_NONE or one of the following errors:
+ * HWC2_ERROR_BAD_DISPLAY - an invalid display handle was passed in
+ */
+typedef int32_t /*hwc2_error_t*/ (*HWC2_PFN_GET_HDR_CAPABILITIES)(
+ hwc2_device_t* device, hwc2_display_t display, uint32_t* outNumTypes,
+ int32_t* /*android_hdr_t*/ outTypes, float* outMaxLuminance,
+ float* outMaxAverageLuminance, float* outMinLuminance);
+
/* getReleaseFences(..., outNumElements, outLayers, outFences)
* Descriptor: HWC2_FUNCTION_GET_RELEASE_FENCES
* Must be provided by all HWC2 devices
diff --git a/modules/soundtrigger/sound_trigger_hw.c b/modules/soundtrigger/sound_trigger_hw.c
index 0492fd5..20d97f2 100644
--- a/modules/soundtrigger/sound_trigger_hw.c
+++ b/modules/soundtrigger/sound_trigger_hw.c
@@ -45,6 +45,7 @@
#define COMMAND_RECOGNITION_ABORT "abort" // Argument: model index.
#define COMMAND_RECOGNITION_FAILURE "fail" // Argument: model index.
#define COMMAND_UPDATE "update" // Argument: model index.
+#define COMMAND_CLEAR "clear" // Removes all models from the list.
#define COMMAND_CLOSE "close" // Close just closes the network port, keeps thread running.
#define COMMAND_END "end" // Closes connection and stops the thread.
@@ -99,6 +100,8 @@
recognition_callback_t recognition_callback;
void *recognition_cookie;
+ bool model_started;
+
// Next recognition_context in the linked list
struct recognition_context *next;
};
@@ -239,6 +242,7 @@
}
bool parse_socket_data(int conn_socket, struct stub_sound_trigger_device* stdev);
+static void unload_all_sound_models(struct stub_sound_trigger_device *stdev);
static char *sound_trigger_keyphrase_event_alloc(sound_model_handle_t handle,
struct sound_trigger_recognition_config *config,
@@ -472,6 +476,7 @@
ALOGI("%s", __func__);
struct recognition_context *last_model_context = stdev->root_model_context;
unsigned int model_index = 0;
+ write_string(conn_socket, "-----------------------\n");
if (!last_model_context) {
ALOGI("ZERO Models exist.");
write_string(conn_socket, "Zero models exist.\n");
@@ -495,8 +500,15 @@
write_vastr(conn_socket, "Unknown sound model type: %d\n", model_type);
ALOGI("Unknown sound model type: %d", model_type);
}
- write_string(conn_socket, "----\n\n");
- ALOGI("----");
+ if (last_model_context->model_started) {
+ write_string(conn_socket, "Model started.\n");
+ ALOGI("Model started.\n");
+ } else {
+ write_string(conn_socket, "Model stopped.\n");
+ ALOGI("Model stopped.\n");
+ }
+ write_string(conn_socket, "-----------------------\n\n");
+ ALOGI("----\n\n");
last_model_context = last_model_context->next;
model_index++;
}
@@ -524,6 +536,7 @@
// Note: Since we acquire a lock inside this loop, do not use break or other
// exit methods without releasing this lock.
+ write_string(conn_socket, "\n>>> ");
while(!input_done) {
if (fgets(buffer, PARSE_BUF_LEN, input_fp) != NULL) {
pthread_mutex_lock(&stdev->lock);
@@ -540,6 +553,8 @@
send_event(conn_socket, stdev, EVENT_RECOGNITION, RECOGNITION_STATUS_FAILURE);
} else if (strcmp(command, COMMAND_UPDATE) == 0) {
send_event(conn_socket, stdev, EVENT_SOUND_MODEL, SOUND_MODEL_STATUS_UPDATED);
+ } else if (strncmp(command, COMMAND_CLEAR, 5) == 0) {
+ unload_all_sound_models(stdev);
} else if (strncmp(command, COMMAND_CLOSE, 5) == 0) {
ALOGI("Closing this connection.");
write_string(conn_socket, "Closing this connection.");
@@ -550,13 +565,14 @@
continue_listening = false;
input_done = true;
} else {
- write_vastr(conn_socket, "Bad command %s.\n", command);
+ write_vastr(conn_socket, "\nBad command %s.\n\n", command);
}
pthread_mutex_unlock(&stdev->lock);
} else {
ALOGI("parse_socket_data done (got null)");
input_done = true; // break.
}
+ write_string(conn_socket, "\n>>> ");
}
return continue_listening;
}
@@ -651,18 +667,35 @@
model_context->recognition_callback = NULL;
model_context->recognition_cookie = NULL;
model_context->next = NULL;
+ model_context->model_started = false;
ALOGI("Sound model loaded: Handle %d ", *handle);
pthread_mutex_unlock(&stdev->lock);
return status;
}
+static void unload_all_sound_models(struct stub_sound_trigger_device *stdev) {
+ ALOGI("%s", __func__);
+ struct recognition_context *model_context = stdev->root_model_context;
+ stdev->root_model_context = NULL;
+ pthread_mutex_lock(&stdev->lock);
+ while (model_context) {
+ ALOGI("Deleting model with handle: %d", model_context->model_handle);
+ struct recognition_context *temp = model_context;
+ model_context = model_context->next;
+ free(temp->config);
+ free(temp);
+ }
+ pthread_mutex_unlock(&stdev->lock);
+}
+
static int stdev_unload_sound_model(const struct sound_trigger_hw_device *dev,
sound_model_handle_t handle) {
// If recognizing, stop_recognition must be called for a sound model before unload_sound_model
ALOGI("%s", __func__);
struct stub_sound_trigger_device *stdev = (struct stub_sound_trigger_device *)dev;
int status = 0;
+ ALOGI("unload_sound_model:%d", handle);
pthread_mutex_lock(&stdev->lock);
struct recognition_context *model_context = NULL;
@@ -683,7 +716,7 @@
pthread_mutex_unlock(&stdev->lock);
return -ENOSYS;
}
- if(previous_model_context) {
+ if (previous_model_context) {
previous_model_context->next = model_context->next;
} else {
stdev->root_model_context = model_context->next;
@@ -725,6 +758,7 @@
}
model_context->recognition_callback = callback;
model_context->recognition_cookie = cookie;
+ model_context->model_started = true;
pthread_mutex_unlock(&stdev->lock);
ALOGI("%s done for handle %d", __func__, handle);
@@ -748,6 +782,7 @@
model_context->config = NULL;
model_context->recognition_callback = NULL;
model_context->recognition_cookie = NULL;
+ model_context->model_started = false;
pthread_mutex_unlock(&stdev->lock);
ALOGI("%s done for handle %d", __func__, handle);
@@ -766,6 +801,7 @@
model_context->config = NULL;
model_context->recognition_callback = NULL;
model_context->recognition_cookie = NULL;
+ model_context->model_started = false;
ALOGI("%s stopped handle %d", __func__, model_context->model_handle);
model_context = model_context->next;