summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/hardware/camera2.h46
-rw-r--r--include/hardware/gralloc.h2
-rw-r--r--include/hardware/hardware.h8
-rw-r--r--include/hardware/hwcomposer.h69
-rw-r--r--include/hardware/hwcomposer_defs.h54
-rw-r--r--tests/camera2/camera2.cpp2
-rw-r--r--tests/camera2/camera2_utils.cpp9
-rw-r--r--tests/camera2/camera2_utils.h2
8 files changed, 137 insertions, 55 deletions
diff --git a/include/hardware/camera2.h b/include/hardware/camera2.h
index 518130b..8209985 100644
--- a/include/hardware/camera2.h
+++ b/include/hardware/camera2.h
@@ -96,22 +96,11 @@ typedef struct camera2_stream_ops {
} camera2_stream_ops_t;
+/**
+ * Temporary definition during transition. TODO: Remove once HALs no longer
+ * reference this */
enum {
- /**
- * Special pixel format value used to indicate that the framework does not care
- * what exact pixel format is to be used for an output stream. The device HAL is
- * free to select any pixel format, platform-specific and otherwise, and this
- * opaque value will be passed on to the platform gralloc module when buffers
- * need to be allocated for the stream.
- */
- CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = -1,
- /**
- * Special pixel format value used to indicate that the framework will use
- * the output buffers for zero-shutter-lag mode; these buffers should be
- * efficient to produce at full sensor resolution, and efficient to send
- * into a reprocess stream for final output processing.
- */
- CAMERA2_HAL_PIXEL_FORMAT_ZSL = -2
+ CAMERA2_HAL_PIXEL_FORMAT_OPAQUE = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
};
/**
@@ -564,11 +553,12 @@ typedef struct camera2_device_ops {
* 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, or
- * CAMERA2_HAL_PIXEL_FORMAT_OPAQUE. In the latter case, the camera device
- * must select an appropriate (possible platform-specific) HAL pixel
- * format to return in format_actual. In the former case, format_actual
- * must be set to match format.
+ * 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
@@ -581,15 +571,6 @@ typedef struct camera2_device_ops {
* used in incoming requests to identify the stream, and in releasing the
* stream.
*
- * - format_actual: If the input format is CAMERA2_HAL_PIXEL_FORMAT_OPAQUE,
- * then device must select the appropriate (possible platform-specific)
- * pixel format and return it in *format_actual. It will be treated as an
- * opaque value by the framework, and simply passed to the gralloc module
- * when new buffers need to be allocated. If the input format is one of
- * the values from HAL_PIXEL_FORMAT_* list, then *format_actual must be
- * set equal to format. In the latter case, format_actual may also be
- * NULL, in which case it can be ignored as an output.
- *
* - 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.
@@ -608,7 +589,7 @@ typedef struct camera2_device_ops {
const camera2_stream_ops_t *stream_ops,
// outputs
uint32_t *stream_id,
- uint32_t *format_actual,
+ uint32_t *format_actual, // IGNORED, will be removed
uint32_t *usage,
uint32_t *max_buffers);
@@ -619,7 +600,10 @@ typedef struct camera2_device_ops {
* 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.
+ * 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 *,
diff --git a/include/hardware/gralloc.h b/include/hardware/gralloc.h
index 86ed95c..4fdd2e6 100644
--- a/include/hardware/gralloc.h
+++ b/include/hardware/gralloc.h
@@ -80,6 +80,8 @@ enum {
GRALLOC_USAGE_HW_CAMERA_WRITE = 0x00020000,
/* buffer will be read by the HW camera pipeline */
GRALLOC_USAGE_HW_CAMERA_READ = 0x00040000,
+ /* buffer will be used as part of zero-shutter-lag queue */
+ GRALLOC_USAGE_HW_CAMERA_ZSL = 0x00080000,
/* mask for the software usage bit-mask */
GRALLOC_USAGE_HW_MASK = 0x00071F00,
diff --git a/include/hardware/hardware.h b/include/hardware/hardware.h
index 78c4572..416ae39 100644
--- a/include/hardware/hardware.h
+++ b/include/hardware/hardware.h
@@ -37,6 +37,12 @@ __BEGIN_DECLS
#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.
*
@@ -60,11 +66,13 @@ __BEGIN_DECLS
* 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;
diff --git a/include/hardware/hwcomposer.h b/include/hardware/hwcomposer.h
index 29ea54c..0a4d40d 100644
--- a/include/hardware/hwcomposer.h
+++ b/include/hardware/hwcomposer.h
@@ -270,7 +270,7 @@ typedef struct hwc_procs {
* received and HWC_EVENT_VSYNC is enabled on a display
* (see: hwc_event_control).
*
- * the "dpy" parameter indicates which display the vsync event is for.
+ * 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.
*
@@ -285,7 +285,27 @@ typedef struct hwc_procs {
* 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 dpy, int64_t timestamp);
+ 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.
+ *
+ * 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;
@@ -384,7 +404,7 @@ typedef struct hwc_composer_device_1 {
* 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 dpy,
+ int (*eventControl)(struct hwc_composer_device_1* dev, int disp,
int event, int enabled);
/*
@@ -398,7 +418,7 @@ typedef struct hwc_composer_device_1 {
*
* returns 0 on success, negative on error.
*/
- int (*blank)(struct hwc_composer_device_1* dev, int dpy, int blank);
+ int (*blank)(struct hwc_composer_device_1* dev, int disp, int blank);
/*
* Used to retrieve information about the h/w composer
@@ -425,6 +445,47 @@ typedef struct hwc_composer_device_1 {
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.
+ *
+ * HWC_DEVICE_API_VERSION_1_1 does not provide a way to choose a config.
+ * For displays that support multiple configurations, the h/w composer
+ * implementation should choose one and report it as the first config in
+ * the list. Reporting the not-chosen configs is not required.
+ *
+ * Returns 0 on success or -errno on error.
+ *
+ * This field is REQUIRED for HWC_DEVICE_API_VERSION_1_1 and later.
+ * It should 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 should be NULL for previous versions.
+ */
+ void (*getDisplayAttributes)(struct hwc_composer_device_1* dev, int disp,
+ uint32_t config, const uint32_t* attributes, int32_t* values);
+
+ /*
* Reserved for future use. Must be NULL.
*/
void* reserved_proc[4];
diff --git a/include/hardware/hwcomposer_defs.h b/include/hardware/hwcomposer_defs.h
index f0f97fc..04f4c2c 100644
--- a/include/hardware/hwcomposer_defs.h
+++ b/include/hardware/hwcomposer_defs.h
@@ -28,13 +28,16 @@ __BEGIN_DECLS
/*****************************************************************************/
-#define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1)
+#define HWC_HEADER_VERSION 1
-#define HWC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION(0, 1)
-#define HWC_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION(0, 2)
-#define HWC_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION(0, 3)
-#define HWC_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
-#define HWC_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1)
+#define HWC_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION_2(0, 1, HWC_HEADER_VERSION)
+
+#define HWC_DEVICE_API_VERSION_0_1 HARDWARE_DEVICE_API_VERSION_2(0, 1, HWC_HEADER_VERSION)
+#define HWC_DEVICE_API_VERSION_0_2 HARDWARE_DEVICE_API_VERSION_2(0, 2, HWC_HEADER_VERSION)
+#define HWC_DEVICE_API_VERSION_0_3 HARDWARE_DEVICE_API_VERSION_2(0, 3, HWC_HEADER_VERSION)
+#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)
enum {
/* hwc_composer_device_t::set failed in EGL */
@@ -129,24 +132,51 @@ enum {
/* attributes queriable with query() */
enum {
/*
- * availability: HWC_DEVICE_API_VERSION_0_2
- * must return 1 if the background layer is supported, 0 otherwise
+ * Availability: HWC_DEVICE_API_VERSION_0_2
+ * Must return 1 if the background layer is supported, 0 otherwise.
*/
HWC_BACKGROUND_LAYER_SUPPORTED = 0,
/*
- * availability: HWC_DEVICE_API_VERSION_0_3
- * returns the vsync period in nanosecond
+ * Availability: HWC_DEVICE_API_VERSION_0_3
+ * 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
+ * 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_RESOLUTION_X = 2,
+ HWC_DISPLAY_RESOLUTION_Y = 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,
+};
+
/* Allowed events for hwc_methods::eventControl() */
enum {
HWC_EVENT_VSYNC = 0
diff --git a/tests/camera2/camera2.cpp b/tests/camera2/camera2.cpp
index 29eef68..f43513e 100644
--- a/tests/camera2/camera2.cpp
+++ b/tests/camera2/camera2.cpp
@@ -240,7 +240,7 @@ class Camera2Test: public testing::Test {
size_t *count) {
ALOGV("Getting resolutions for format %x", format);
status_t res;
- if (format != CAMERA2_HAL_PIXEL_FORMAT_OPAQUE) {
+ if (format != HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED) {
camera_metadata_ro_entry_t availableFormats;
res = find_camera_metadata_ro_entry(mStaticInfo,
ANDROID_SCALER_AVAILABLE_FORMATS,
diff --git a/tests/camera2/camera2_utils.cpp b/tests/camera2/camera2_utils.cpp
index ba938d9..cefe29a 100644
--- a/tests/camera2/camera2_utils.cpp
+++ b/tests/camera2/camera2_utils.cpp
@@ -317,7 +317,7 @@ void NotifierListener::notify_callback_dispatch(int32_t msg_type,
StreamAdapter::StreamAdapter(sp<ISurfaceTexture> consumer):
mState(UNINITIALIZED), mDevice(NULL),
mId(-1),
- mWidth(0), mHeight(0), mFormatRequested(0)
+ mWidth(0), mHeight(0), mFormat(0)
{
mConsumerInterface = new SurfaceTextureClient(consumer);
camera2_stream_ops::dequeue_buffer = dequeue_buffer;
@@ -342,16 +342,16 @@ status_t StreamAdapter::connectToDevice(camera2_device_t *d,
mWidth = width;
mHeight = height;
- mFormatRequested = format;
+ mFormat = format;
// Allocate device-side stream interface
uint32_t id;
- uint32_t formatActual;
+ uint32_t formatActual; // ignored
uint32_t usage;
uint32_t maxBuffers = 2;
res = d->ops->allocate_stream(d,
- mWidth, mHeight, mFormatRequested, getStreamOps(),
+ mWidth, mHeight, mFormat, getStreamOps(),
&id, &formatActual, &usage, &maxBuffers);
if (res != OK) {
ALOGE("%s: Device stream allocation failed: %s (%d)",
@@ -362,7 +362,6 @@ status_t StreamAdapter::connectToDevice(camera2_device_t *d,
mDevice = d;
mId = id;
- mFormat = formatActual;
mUsage = usage;
mMaxProducerBuffers = maxBuffers;
diff --git a/tests/camera2/camera2_utils.h b/tests/camera2/camera2_utils.h
index 2c9f801..7822f5b 100644
--- a/tests/camera2/camera2_utils.h
+++ b/tests/camera2/camera2_utils.h
@@ -194,8 +194,6 @@ class StreamAdapter: public camera2_stream_ops {
uint32_t mMaxProducerBuffers;
uint32_t mMaxConsumerBuffers;
- int mFormatRequested;
-
const camera2_stream_ops *getStreamOps();
static ANativeWindow* toANW(const camera2_stream_ops_t *w);