sde: Interfaces for Snapdragon Display Engine (SDE)
1. Define SDE interfaces for hwc. 2. Define strategy manager interfaces for composition manager. 3. Define utility classes used by SDE. Change-Id: I2985fbd05e824cb41ac9b03aa0114daac754d712
This commit is contained in:
committed by
Gerrit - the friendly Code Review server
parent
8f3e80c320
commit
f9ba485c78
183
displayengine/include/core/core_interface.h
Normal file
183
displayengine/include/core/core_interface.h
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! @file core_interface.h
|
||||
@brief Interface file for core of the display subsystem.
|
||||
|
||||
@details Display core is primarily used for loading and unloading different display device
|
||||
components viz primary, external and virtual. Display core is a statically linked library which
|
||||
runs in caller's process context.
|
||||
*/
|
||||
#ifndef __CORE_INTERFACE_H__
|
||||
#define __CORE_INTERFACE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "device_interface.h"
|
||||
#include "display_types.h"
|
||||
|
||||
/*! @brief Display core interface version.
|
||||
|
||||
@details Display core interfaces are version tagged to maintain backward compatibility. This
|
||||
version is supplied as a default argument during display core initialization.
|
||||
|
||||
Client may use an older version of interfaces and link to a higher version of display core
|
||||
library, but vice versa is not allowed.
|
||||
|
||||
A 32-bit client must use 32-bit display core library and a 64-bit client must use 64-bit display
|
||||
core library.
|
||||
|
||||
Display core interfaces follow default data structures alignment. Client must not override the
|
||||
default padding rules while using these interfaces.
|
||||
|
||||
@warning It is assumed that client upgrades or downgrades display core interface all at once
|
||||
and recompile all binaries which use these interfaces. Mix and match of these interfaces can
|
||||
lead to unpredictable behaviour.
|
||||
|
||||
@sa CoreInterface::CreateCore
|
||||
*/
|
||||
#define CORE_REVISION_MAJOR (1)
|
||||
#define CORE_REVISION_MINOR (0)
|
||||
|
||||
#define CORE_VERSION_TAG ((uint32_t) ((CORE_REVISION_MAJOR << 24) | (CORE_REVISION_MINOR << 16) \
|
||||
| (sizeof(DisplayCompatibility) << 8) | sizeof(int *)))
|
||||
|
||||
namespace sde {
|
||||
|
||||
/*! @brief Event data associated with hotplug event.
|
||||
|
||||
@sa CoreEventHandler::Hotplug
|
||||
*/
|
||||
struct CoreEventHotplug {
|
||||
bool connected; //!< True when device is connected.
|
||||
|
||||
CoreEventHotplug() : connected(false) { }
|
||||
};
|
||||
|
||||
/*! @brief Display core event handler implemented by the client.
|
||||
|
||||
@details This class declares prototype for display core event handler methods which must be
|
||||
implemented by the client. Display core will use these methods to notify events to the client.
|
||||
Client must post heavy-weight event handling to a separate thread and unblock display core thread
|
||||
instantly.
|
||||
|
||||
@sa CoreInterface::CreateCore
|
||||
*/
|
||||
class CoreEventHandler {
|
||||
public:
|
||||
/*! @brief Event handler for Hotplug event.
|
||||
|
||||
@details Event generated when a display device is connected or disconnected. Applicable to
|
||||
detachable displays only.
|
||||
|
||||
@param[in] \link CoreEventHotplug \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError Hotplug(const CoreEventHotplug &hotplug) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~CoreEventHandler() { }
|
||||
};
|
||||
|
||||
/*! @brief Display core interface.
|
||||
|
||||
@details This class defines display core interfaces. It contains methods which client shall use
|
||||
to create/destroy different display devices. This interface is created during display core
|
||||
CreateCore() and remains valid until DestroyCore().
|
||||
|
||||
@sa CoreInterface::CreateCore
|
||||
@sa CoreInterface::DestroyCore
|
||||
*/
|
||||
class CoreInterface {
|
||||
public:
|
||||
/*! @brief Method to create and get handle to display core interface.
|
||||
|
||||
@details This method is the entry point into the display core. Client can create and operate on
|
||||
different display devices only through a valid interface handle obtained using this method. An
|
||||
object of display core is created and handle to this object is returned via output parameter.
|
||||
This interface shall be called only once.
|
||||
|
||||
@param[in] event_handler \link CoreEventHandler \endlink
|
||||
@param[out] interface \link CoreInterface \endlink
|
||||
@param[in] version \link CORE_VERSION_TAG \endlink. Client must not override this argument.
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa DestroyCore
|
||||
*/
|
||||
static DisplayError CreateCore(CoreEventHandler *event_handler, CoreInterface **interface,
|
||||
uint32_t version = CORE_VERSION_TAG);
|
||||
|
||||
/*! @brief Method to release handle to display core interface.
|
||||
|
||||
@details The object of corresponding display core is destroyed when this method is invoked.
|
||||
Client must explicitly destroy all created display device objects associated with this handle
|
||||
before invoking this method.
|
||||
|
||||
@param[in] interface \link CoreInterface \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa CreateCore
|
||||
*/
|
||||
static DisplayError DestroyCore();
|
||||
|
||||
/*! @brief Method to create a display device for a given type.
|
||||
|
||||
@details Client shall use this method to create each of the connected display type. A handle to
|
||||
interface associated with this object is returned via output parameter which can be used to
|
||||
interact further with the display device.
|
||||
|
||||
@param[in] type \link DeviceType \endlink
|
||||
@param[in] event_handler \link DeviceEventHandler \endlink
|
||||
@param[out] interface \link DisplayInterface \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa DestroyDevice
|
||||
*/
|
||||
virtual DisplayError CreateDevice(DeviceType type, DeviceEventHandler *event_handler,
|
||||
DeviceInterface **interface) = 0;
|
||||
|
||||
/*! @brief Method to destroy a display device.
|
||||
|
||||
@details Client shall use this method to destroy each of the created display device objects.
|
||||
|
||||
@param[in] interface \link DisplayInterface \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa CreateDevice
|
||||
*/
|
||||
virtual DisplayError DestroyDevice(DeviceInterface *interface) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~CoreInterface() { }
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __CORE_INTERFACE_H__
|
||||
|
||||
65
displayengine/include/core/debug_interface.h
Normal file
65
displayengine/include/core/debug_interface.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! @file debug_interface.h
|
||||
@brief Interface file for debugging options provided by display engine.
|
||||
|
||||
*/
|
||||
#ifndef __DEBUG_INTERFACE_H__
|
||||
#define __DEBUG_INTERFACE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "display_types.h"
|
||||
|
||||
namespace sde {
|
||||
|
||||
/*! @brief Display debug interface.
|
||||
|
||||
@details This class defines debugging methods provided by display engine.
|
||||
|
||||
*/
|
||||
class DebugInterface {
|
||||
public:
|
||||
/*! @brief Method to get debugging information in form of a string.
|
||||
|
||||
@details Client shall use this method to get current snapshot of display engine context in form
|
||||
of a formatted string for logging or dumping purposes.
|
||||
|
||||
@param[out] buffer String buffer allocated by the client. Filled with debugging information
|
||||
upon return.
|
||||
@param[in] length Length of the string buffer. Length shall be offset adjusted if any.
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
static DisplayError GetDump(uint8_t *buffer, uint32_t length);
|
||||
|
||||
protected:
|
||||
virtual ~DebugInterface() { }
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __DEBUG_INTERFACE_H__
|
||||
|
||||
286
displayengine/include/core/device_interface.h
Normal file
286
displayengine/include/core/device_interface.h
Normal file
@@ -0,0 +1,286 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! @file device_interface.h
|
||||
@brief Interface file for display device which represents a physical panel or an output buffer
|
||||
where contents can be rendered.
|
||||
|
||||
@details Display device is used to send layer buffers for composition and get them rendered onto
|
||||
the target device. Each display device represents a unique display target which may be either a
|
||||
physical panel or an output buffer..
|
||||
*/
|
||||
#ifndef __DEVICE_INTERFACE_H__
|
||||
#define __DEVICE_INTERFACE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "layer_stack.h"
|
||||
#include "display_types.h"
|
||||
|
||||
namespace sde {
|
||||
|
||||
/*! @brief This enum represents display device types where contents can be rendered.
|
||||
|
||||
@sa CoreInterface::CreateDevice
|
||||
@sa CoreInterface::IsDeviceSupported
|
||||
*/
|
||||
enum DeviceType {
|
||||
kPrimary, //!< Main physical display which is attached to the handheld device.
|
||||
kHDMI, //!< HDMI physical display which is generally detachable.
|
||||
kVirtual, //!< Contents would be rendered into the output buffer provided by the client
|
||||
//!< e.g. wireless display.
|
||||
};
|
||||
|
||||
/*! @brief This enum represents states of a display device.
|
||||
|
||||
@sa DisplayInterface::GetDeviceState
|
||||
@sa DisplayInterface::SetDeviceState
|
||||
*/
|
||||
enum DeviceState {
|
||||
kStateOff, //!< Display is OFF. Contents are not rendered in this state. Client will not
|
||||
//!< receive VSync events in this state. This is default state as well.
|
||||
|
||||
kStateOn, //!< Display is ON. Contents are rendered in this state.
|
||||
|
||||
kStateDoze, //!< Display is ON but not updating contents. Client shall not push any contents
|
||||
//!< in this state.
|
||||
|
||||
kStateStandby, //!< Display is OFF. Client will continue to receive VSync events in this state
|
||||
//!< if VSync is enabled. Contents are not rendered in this state.
|
||||
};
|
||||
|
||||
/*! @brief This structure defines configuration for fixed properties of a display device.
|
||||
|
||||
@sa DisplayInterface::GetConfig
|
||||
@sa DisplayInterface::SetConfig
|
||||
*/
|
||||
struct DeviceConfigFixedInfo {
|
||||
bool underscan; //!< If display support CE underscan.
|
||||
bool secure; //!< If this display is capable of handling secure content.
|
||||
|
||||
DeviceConfigFixedInfo() : underscan(false), secure(false) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines configuration for variable properties of a display device.
|
||||
|
||||
@sa DisplayInterface::GetConfig
|
||||
@sa DisplayInterface::SetConfig
|
||||
*/
|
||||
struct DeviceConfigVariableInfo {
|
||||
uint32_t x_pixels; //!< Total number of pixels in X-direction on the display panel.
|
||||
uint32_t y_pixels; //!< Total number of pixels in Y-direction on the display panel.
|
||||
float x_dpi; //!< Dots per inch in X-direction.
|
||||
float y_dpi; //!< Dots per inch in Y-direction.
|
||||
float fps; //!< Frame rate per second.
|
||||
uint32_t vsync_period_ns; //!< VSync period in nanoseconds.
|
||||
|
||||
DeviceConfigVariableInfo() : x_pixels(0), y_pixels(0), x_dpi(0.0f), y_dpi(0.0f),
|
||||
fps(0.0f), vsync_period_ns(0) { }
|
||||
};
|
||||
|
||||
/*! @brief Event data associated with VSync event.
|
||||
|
||||
@sa DeviceEventHandler::VSync
|
||||
*/
|
||||
struct DeviceEventVSync {
|
||||
int64_t timestamp; //!< System monotonic clock timestamp in nanoseconds.
|
||||
|
||||
DeviceEventVSync() : timestamp(0) { }
|
||||
};
|
||||
|
||||
/*! @brief Display device event handler implemented by the client.
|
||||
|
||||
@details This class declares prototype for display device event handler methods which must be
|
||||
implemented by the client. Display device will use these methods to notify events to the client.
|
||||
Client must post heavy-weight event handling to a separate thread and unblock display engine
|
||||
thread instantly.
|
||||
|
||||
@sa CoreInterface::CreateDevice
|
||||
*/
|
||||
class DeviceEventHandler {
|
||||
public:
|
||||
/*! @brief Event handler for VSync event.
|
||||
|
||||
@details This event is dispatched on every vertical synchronization. The event is disabled by
|
||||
default.
|
||||
|
||||
@param[in] vsync \link DeviceEventVSync \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa DeviceInterface::GetDeviceState
|
||||
@sa DeviceInterface::SetDeviceState
|
||||
*/
|
||||
virtual DisplayError VSync(const DeviceEventVSync &vsync) = 0;
|
||||
|
||||
/*! @brief Event handler for Refresh event.
|
||||
|
||||
@details This event is dispatched to trigger a screen refresh. Client must call Prepare() and
|
||||
Commit() in response to it from a separate thread. There is no data associated with this
|
||||
event.
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa DeviceInterface::Prepare
|
||||
@sa DeviceInterface::Commit
|
||||
*/
|
||||
virtual DisplayError Refresh() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~DeviceEventHandler() { }
|
||||
};
|
||||
|
||||
/*! @brief Display device interface.
|
||||
|
||||
@details This class defines display device interface. It contains methods which client shall use
|
||||
to configure or submit layers for composition on the display device. This interface is created
|
||||
during display device creation and remains valid until destroyed.
|
||||
|
||||
@sa CoreInterface::CreateDevice
|
||||
@sa CoreInterface::DestroyDevice
|
||||
*/
|
||||
class DeviceInterface {
|
||||
public:
|
||||
/*! @brief Method to determine hardware capability to compose layers associated with given frame.
|
||||
|
||||
@details Client shall send all layers associated with a frame targeted for current display
|
||||
using this method and check the layers which can be handled completely in display engine.
|
||||
|
||||
Client shall mark composition type for one of the layer as kCompositionGPUTarget; the GPU
|
||||
composed output would be rendered at the specified layer if some of the layers are not handled
|
||||
by SDE.
|
||||
|
||||
Display engine will set each layer as kCompositionGPU or kCompositionSDE upon return. Client
|
||||
shall render all the layers marked as kCompositionGPU using GPU.
|
||||
|
||||
This method can be called multiple times but only last call prevails. This method must be
|
||||
followed by Commit().
|
||||
|
||||
@param[inout] layer_stack \link LayerStack \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa Commit
|
||||
*/
|
||||
virtual DisplayError Prepare(LayerStack *layer_stack) = 0;
|
||||
|
||||
/*! @brief Method to commit layers of a frame submitted in a former call to Prepare().
|
||||
|
||||
@details Client shall call this method to submit layers for final composition. The composed
|
||||
output would be displayed on the panel or written in output buffer.
|
||||
|
||||
Client must ensure that layer stack is same as previous call to Prepare.
|
||||
|
||||
This method shall be called only once for each frame.
|
||||
|
||||
In the event of an error as well, this call will cause any fences returned in the previous call
|
||||
to Commit() to eventually become signaled, so the client's wait on fences can be released to
|
||||
prevent deadlocks.
|
||||
|
||||
@param[in] layer_stack \link LayerStack \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa Prepare
|
||||
*/
|
||||
virtual DisplayError Commit(LayerStack *layer_stack) = 0;
|
||||
|
||||
/*! @brief Method to get current state of the display device.
|
||||
|
||||
@param[out] state \link DisplayState \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa SetDeviceState
|
||||
*/
|
||||
virtual DisplayError GetDeviceState(DeviceState *state) = 0;
|
||||
|
||||
/*! @brief Method to get number of configurations(variable properties) supported on the display
|
||||
device.
|
||||
|
||||
@param[out] count Number of modes supported; mode index starts with 0.
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError GetNumVariableInfoConfigs(uint32_t *count) = 0;
|
||||
|
||||
/*! @brief Method to get configuration for fixed properties of the display device.
|
||||
|
||||
@param[out] fixed_info \link DeviceConfigFixedInfo \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError GetConfig(DeviceConfigFixedInfo *fixed_info) = 0;
|
||||
|
||||
/*! @brief Method to get configuration for variable properties of the display device.
|
||||
|
||||
@param[in] mode index of the mode
|
||||
@param[out] variable_info \link DeviceConfigVariableInfo \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError GetConfig(DeviceConfigVariableInfo *variable_info, uint32_t mode) = 0;
|
||||
|
||||
/*! @brief Method to get VSync event state. Default event state is disabled.
|
||||
|
||||
@param[out] enabled vsync state
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError GetVSyncState(bool *enabled) = 0;
|
||||
|
||||
/*! @brief Method to set current state of the display device.
|
||||
|
||||
@param[in] state \link DisplayState \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
|
||||
@sa SetDeviceState
|
||||
*/
|
||||
virtual DisplayError SetDeviceState(DeviceState state) = 0;
|
||||
|
||||
/*! @brief Method to set configuration for variable properties of the display device.
|
||||
|
||||
@param[in] mode index of the mode corresponding to variable properties.
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError SetConfig(uint32_t mode) = 0;
|
||||
|
||||
/*! @brief Method to set VSync event state. Default event state is disabled.
|
||||
|
||||
@param[out] enabled vsync state
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError SetVSyncState(bool enabled) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~DeviceInterface() { }
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __DEVICE_INTERFACE_H__
|
||||
|
||||
65
displayengine/include/core/display_types.h
Normal file
65
displayengine/include/core/display_types.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! @file display_types.h
|
||||
@brief This file contains miscellaneous data types used across display interfaces.
|
||||
*/
|
||||
#ifndef __DISPLAY_TYPES_H__
|
||||
#define __DISPLAY_TYPES_H__
|
||||
|
||||
namespace sde {
|
||||
|
||||
/*! @brief This enum represents different error codes that display interfaces may return.
|
||||
*/
|
||||
enum DisplayError {
|
||||
kErrorNone = 0, //!< Call executed successfully.
|
||||
kErrorUndefined, //!< An unspecified error has occured.
|
||||
kErrorNotSupported, //!< Requested operation is not supported.
|
||||
kErrorVersion, //!< Client is using advanced version of interfaces and calling into an
|
||||
//!< older version of display library.
|
||||
kErrorDataAlignment, //!< Client data structures are not aligned on naturual boundaries.
|
||||
kErrorInstructionSet, //!< 32-bit client is calling into 64-bit library or vice versa.
|
||||
kErrorParameters, //!< Invalid parameters passed to a method.
|
||||
kErrorFileDescriptor, //!< Invalid file descriptor.
|
||||
kErrorMemory, //!< System is running low on memory.
|
||||
kErrorResources, //!< Not enough hardware resources available to execute call.
|
||||
kErrorHardware, //!< A hardware error has occured.
|
||||
kErrorTimeOut, //!< The operation has timed out to prevent client from waiting forever.
|
||||
};
|
||||
|
||||
/*! @brief This structure is defined for client and library compatibility check purpose only. This
|
||||
structure is used in CORE_VERSION_TAG definition only. Client should not refer it directly for
|
||||
any purpose.
|
||||
*/
|
||||
struct DisplayCompatibility {
|
||||
char c1;
|
||||
int i1;
|
||||
char c2;
|
||||
int i2;
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __DISPLAY_TYPES_H__
|
||||
|
||||
159
displayengine/include/core/layer_buffer.h
Normal file
159
displayengine/include/core/layer_buffer.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! @file layer_buffer.h
|
||||
@brief File for layer buffer structure.
|
||||
|
||||
*/
|
||||
#ifndef __LAYER_BUFFER_H__
|
||||
#define __LAYER_BUFFER_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "display_types.h"
|
||||
|
||||
namespace sde {
|
||||
|
||||
/*! @brief This enum represents different buffer formats supported by display engine.
|
||||
|
||||
@sa LayerBuffer
|
||||
*/
|
||||
enum LayerBufferFormat {
|
||||
/* All RGB formats, Any new format will be added towards end of this group to maintain backward
|
||||
compatibility.
|
||||
*/
|
||||
kFormatARGB8888, //!< 8-bits Alpha, Red, Green, Blue interleaved in ARGB order.
|
||||
kFormatRGBA8888, //!< 8-bits Red, Green, Blue, Alpha interleaved in RGBA order.
|
||||
kFormatBGRA8888, //!< 8-bits Blue, Green, Red, Alpha interleaved in BGRA order.
|
||||
kFormatXRGB8888, //!< 8-bits Padding, Red, Green, Blue interleaved in XRGB order. No Alpha.
|
||||
kFormatRGBX8888, //!< 8-bits Red, Green, Blue, Padding interleaved in RGBX order. No Alpha.
|
||||
kFormatBGRX8888, //!< 8-bits Blue, Green, Red, Padding interleaved in BGRX order. No Alpha.
|
||||
kFormatRGB888, //!< 8-bits Red, Green, Blue interleaved in RGB order. No Alpha.
|
||||
kFormatRGB565, //!< 5-bit Red, 6-bit Green, 5-bit Blue interleaved in RGB order. No Alpha.
|
||||
|
||||
/* All YUV-Planar formats, Any new format will be added towards end of this group to maintain
|
||||
backward compatibility.
|
||||
*/
|
||||
kFormatYCbCr420Planar = 0x100, //!< Y-plane: y(0), y(1), y(2) ... y(n)
|
||||
//!< 2x2 subsampled U-plane: u(0), u(2) ... u(n-1)
|
||||
//!< 2x2 subsampled V-plane: v(0), v(2) ... v(n-1)
|
||||
|
||||
kFormatYCrCb420Planar, //!< Y-plane: y(0), y(1), y(2) ... y(n)
|
||||
//!< 2x2 subsampled V-plane: v(0), v(2) ... v(n-1)
|
||||
//!< 2x2 subsampled U-plane: u(0), u(2) ... u(n-1)
|
||||
|
||||
/* All YUV-Semiplanar formats, Any new format will be added towards end of this group to
|
||||
maintain backward compatibility.
|
||||
*/
|
||||
kFormatYCbCr420SemiPlanar = 0x200, //!< Y-plane: y(0), y(1), y(2) ... y(n)
|
||||
//!< 2x2 subsampled interleaved UV-plane:
|
||||
//!< u(0), v(0), u(2), v(2) ... u(n-1), v(n-1)
|
||||
//!< aka NV12.
|
||||
|
||||
kFormatYCrCb420SemiPlanar, //!< Y-plane: y(0), y(1), y(2) ... y(n)
|
||||
//!< 2x2 subsampled interleaved VU-plane:
|
||||
//!< v(0), u(0), v(2), u(2) ... v(n-1), u(n-1)
|
||||
//!< aka NV21.
|
||||
|
||||
/* All YUV-Packed formats, Any new format will be added towards end of this group to maintain
|
||||
backward compatibility.
|
||||
*/
|
||||
kFormatYCbCr422Packed = 0x300, //!< Y-plane interleaved with horizontally subsampled U/V by
|
||||
//!< factor of 2
|
||||
//!< u(0), y(0), v(0), y(1), u(2), y(2), v(2), y(3)
|
||||
//!< u(n-1), y(n-1), v(n-1), y(n)
|
||||
};
|
||||
|
||||
/*! @brief This structure defines a color sample plane belonging to a buffer format. RGB buffer
|
||||
formats have 1 plane whereas YUV buffer formats may have upto 4 planes.
|
||||
|
||||
@sa LayerBuffer
|
||||
*/
|
||||
struct LayerBufferPlane {
|
||||
int fd; //!< File descriptor referring to the buffer associated with this plane.
|
||||
uint32_t offset; //!< Offset of the plane in bytes from beginning of the buffer.
|
||||
uint32_t stride; //!< Stride in bytes i.e. length of a scanline including padding.
|
||||
|
||||
LayerBufferPlane() : fd(-1), offset(0), stride(0) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines flags associated with a layer buffer. The 1-bit flag can be set
|
||||
to ON(1) or OFF(0).
|
||||
|
||||
@sa LayerBuffer
|
||||
*/
|
||||
struct LayerBufferFlags {
|
||||
uint64_t secure : 1; //!< This flag shall be set by client to indicate that the buffer need
|
||||
//!< to be handled securely.
|
||||
|
||||
LayerBufferFlags() : secure(0) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines a layer buffer handle which contains raw buffer and its associated
|
||||
properties.
|
||||
|
||||
@sa LayerBuffer
|
||||
@sa LayerStack
|
||||
*/
|
||||
struct LayerBuffer {
|
||||
uint32_t width; //!< Actual width of the Layer that this buffer is for.
|
||||
uint32_t height; //!< Actual height of the Layer that this buffer is for.
|
||||
LayerBufferFormat format; //!< Format of the buffer content.
|
||||
LayerBufferPlane planes[4]; //!< Array of planes that this buffer contains. RGB buffer formats
|
||||
//!< have 1 plane whereas YUV buffer formats may have upto 4 planes.
|
||||
//!< Total number of planes for the buffer will be interpreted based
|
||||
//!< on the buffer format specified.
|
||||
|
||||
int acquire_fence_fd; //!< File descriptor referring to a sync fence object which will be
|
||||
//!< signaled when buffer can be read/write by display engine.
|
||||
//!< This fence object is set by the client during Commit(). For
|
||||
//!< input buffers client shall signal this fence when buffer
|
||||
//!< content is available and can be read by display engine. For
|
||||
//!< output buffers, client shall signal fence when buffer is ready
|
||||
//!< to be written by display engine.
|
||||
|
||||
//!< This field is used only during Commit() and shall be set to -1
|
||||
//!< by the client when buffer is already available for read/write.
|
||||
|
||||
int release_fence_fd; //!< File descriptor referring to a sync fence object which will be
|
||||
//!< signaled when buffer has been read/written by display engine.
|
||||
//!< This fence object is set by display engine during Commit().
|
||||
//!< For input buffers display engine will signal this fence when
|
||||
//!< buffer has been consumed. For output buffers, display engine
|
||||
//!< will signal this fence when buffer is produced.
|
||||
|
||||
//!< This field is used only during Commit() and will be set to -1
|
||||
//!< by display engine when buffer is already available for
|
||||
//!< read/write.
|
||||
|
||||
LayerBufferFlags flags; //!< Flags associated with this buffer.
|
||||
|
||||
LayerBuffer() : width(0), height(0), format(kFormatRGBA8888), acquire_fence_fd(-1),
|
||||
release_fence_fd(-1) { }
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __LAYER_BUFFER_H__
|
||||
|
||||
227
displayengine/include/core/layer_stack.h
Normal file
227
displayengine/include/core/layer_stack.h
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! @file layer_stack.h
|
||||
@brief File for display layer stack structure which represents a drawing buffer.
|
||||
|
||||
@details Display layer is a drawing buffer object which will be blended with other drawing buffers
|
||||
under blending rules.
|
||||
*/
|
||||
#ifndef __LAYER_STACK_H__
|
||||
#define __LAYER_STACK_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "layer_buffer.h"
|
||||
#include "display_types.h"
|
||||
|
||||
namespace sde {
|
||||
|
||||
/*! @brief This enum represents display layer blending types.
|
||||
|
||||
@sa Layer
|
||||
*/
|
||||
enum LayerBlending {
|
||||
kBlendingNone = 0, //!< Blend operation is not specified.
|
||||
|
||||
kBlendingOpaque, //!< Pixel color is expressed using straight alpha in color tuples. It
|
||||
//!< is constant blend operation. The layer would appear opaque if plane
|
||||
//!< alpha is 0xFF.
|
||||
|
||||
kBlendingPremultiplied, //!< Pixel color is expressed using premultiplied alpha in RGBA tuples.
|
||||
//!< If plane alpha is less than 0xFF, apply modulation as well.
|
||||
//!< pixel.rgb = src.rgb + dest.rgb x (1 - src.a)
|
||||
|
||||
kBlendingCoverage, //!< Pixel color is expressed using straight alpha in color tuples. If
|
||||
//!< plane alpha is less than 0xff, apply modulation as well.
|
||||
//!< pixel.rgb = src.rgb x src.a + dest.rgb x (1 - src.a)
|
||||
};
|
||||
|
||||
/*! @brief This enum represents display layer composition types.
|
||||
|
||||
@sa Layer
|
||||
*/
|
||||
enum LayerComposition {
|
||||
kCompositionGPU, //!< This layer will be drawn into the target buffer by GPU. Display
|
||||
//!< device will mark the layer for SDE composition if it can handle it
|
||||
//!< or it will mark the layer for GPU composition.
|
||||
|
||||
kCompositionSDE, //!< This layer will be handled by SDE. It must not be composed by GPU.
|
||||
|
||||
kCompositionGPUTarget, //!< This layer will hold result of composition for layers marked for GPU
|
||||
//!< composition. If display device sets all other layers for SDE
|
||||
//!< composition then this layer would be ignored during Commit().
|
||||
//!< Only one layer shall be marked as target buffer by the caller.
|
||||
};
|
||||
|
||||
/*! @brief This structure defines rotation and flip values for a display layer.
|
||||
|
||||
@sa Layer
|
||||
*/
|
||||
struct LayerTransform {
|
||||
float rotation; //!< Left most pixel coordinate.
|
||||
bool flip_horizontal; //!< Mirror reversal of the layer across a horizontal axis.
|
||||
bool flip_vertical; //!< Mirror reversal of the layer across a vertical axis.
|
||||
|
||||
LayerTransform() : rotation(0.0f), flip_horizontal(false), flip_vertical(false) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines flags associated with a layer. The 1-bit flag can be set to ON(1)
|
||||
or OFF(0).
|
||||
|
||||
@sa LayerBuffer
|
||||
*/
|
||||
struct LayerFlags {
|
||||
uint64_t skip : 1; //!< This flag shall be set by client to indicate that this layer will be
|
||||
//!< handled by GPU. Device Device will not consider it for composition.
|
||||
|
||||
LayerFlags() : skip(0) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines flags associated with a layer stack. The 1-bit flag can be set to
|
||||
ON(1) or OFF(0).
|
||||
|
||||
@sa LayerBuffer
|
||||
*/
|
||||
struct LayerStackFlags {
|
||||
uint64_t geometry_changed : 1; //!< This flag shall be set by client to indicate that the layer
|
||||
//!< set passed to Prepare() has changed by more than just the
|
||||
//!< buffer handles and acquire fences.
|
||||
|
||||
LayerStackFlags() : geometry_changed(0) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines a rectanglular area inside a display layer.
|
||||
|
||||
@sa LayerRectArray
|
||||
*/
|
||||
struct LayerRect {
|
||||
float left; //!< Left-most pixel coordinate.
|
||||
float top; //!< Top-most pixel coordinate.
|
||||
float right; //!< Right-most pixel coordinate.
|
||||
float bottom; //!< Bottom-most pixel coordinate.
|
||||
|
||||
LayerRect() : left(0.0f), top(0.0f), right(0.0f), bottom(0.0f) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines an array of display layer rectangles.
|
||||
|
||||
@sa LayerRect
|
||||
*/
|
||||
struct LayerRectArray {
|
||||
LayerRect *rect; //!< Pointer to first element of array.
|
||||
size_t count; //!< Number of elements in the array.
|
||||
|
||||
LayerRectArray() : rect(NULL), count(0) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines display layer object which contains layer properties and a drawing
|
||||
buffer.
|
||||
|
||||
@sa LayerArray
|
||||
*/
|
||||
struct Layer {
|
||||
LayerBuffer *input_buffer; //!< Pointer to the buffer to be composed. If this remains
|
||||
//!< unchanged between two consecutive Prepare() calls and
|
||||
//!< geometry_changed flag is not set for the second call, then
|
||||
//!< the display device will assume that buffer content has not
|
||||
//!< changed.
|
||||
|
||||
LayerComposition composition; //!< Composition type which can be set by either the client or
|
||||
//!< the display device. This value should be preserved between
|
||||
//!< Prepare() and Commit() calls.
|
||||
|
||||
LayerRect src_rect; //!< Rectangular area of the layer buffer to consider for
|
||||
//!< composition.
|
||||
|
||||
LayerRect dst_rect; //!< The target position where the frame will be displayed.
|
||||
//!< Cropping rectangle is scaled to fit into this rectangle.
|
||||
//!< The origin is top-left corner of the screen.
|
||||
|
||||
LayerRectArray visible_regions; //!< Visible rectangular areas in screen space. The visible
|
||||
//!< region includes areas overlapped by a translucent layer.
|
||||
|
||||
LayerRectArray dirty_regions; //!< Rectangular areas in the current frames that have changed
|
||||
//!< in comparison to previous frame.
|
||||
|
||||
LayerBlending blending; //!< Blending operation which need to be applied on the layer
|
||||
//!< buffer during composition.
|
||||
|
||||
LayerTransform transform; //!< Rotation/Flip operations which need to be applied to the
|
||||
//!< layer buffer during composition.
|
||||
|
||||
uint8_t plane_alpha; //!< Alpha value applied to the whole layer. Value of each pixel
|
||||
//!< computed as:
|
||||
//!< if(kBlendingPremultiplied) {
|
||||
//!< pixel.RGB = pixel.RGB * planeAlpha / 255
|
||||
//!< }
|
||||
//!< pixel.a = pixel.a * planeAlpha
|
||||
|
||||
LayerFlags flags; //!< Flags associated with this layer.
|
||||
|
||||
Layer() : input_buffer(NULL), composition(kCompositionGPU), blending(kBlendingNone),
|
||||
plane_alpha(0) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines an array of display layers.
|
||||
|
||||
@sa LayerStack
|
||||
*/
|
||||
struct LayerArray {
|
||||
Layer *layer; //!< Pointer to first element of array.
|
||||
size_t count; //!< Number of elements in the array.
|
||||
|
||||
LayerArray() : layer(NULL), count(0) { }
|
||||
};
|
||||
|
||||
/*! @brief This structure defines a layer stack that contains layers which need to be composed and
|
||||
rendered onto the target.
|
||||
|
||||
@sa DisplayInterface::Prepare
|
||||
@sa DisplayInterface::Commit
|
||||
*/
|
||||
struct LayerStack {
|
||||
union {
|
||||
int retire_fence_fd; //!< File descriptor referring to a sync fence object which will
|
||||
//!< be signaled when this composited frame has been replaced on
|
||||
//!< screen by a subsequent frame on a physical display. The fence
|
||||
//!< object is created and returned during Commit(). Client shall
|
||||
//!< Client shall close the returned file descriptor.
|
||||
//!< NOTE: This field applies to a physical display only.
|
||||
|
||||
LayerBuffer *output_buffer; //!< Pointer to the buffer where composed buffer would be rendered
|
||||
//!< for virtual displays.
|
||||
//!< NOTE: This field applies to a virtual display only.
|
||||
};
|
||||
|
||||
LayerArray layers; //!< Array of layers.
|
||||
LayerStackFlags flags; //!< Flags associated with this layer set.
|
||||
|
||||
LayerStack() : output_buffer(NULL) { }
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __LAYER_STACK_H__
|
||||
|
||||
130
displayengine/include/private/strategy_interface.h
Normal file
130
displayengine/include/private/strategy_interface.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*! @file strategy_interface.h
|
||||
@brief Interface file for strategy manager which will be used by display core to select a
|
||||
composition strategy for a frame to be displayed on target.
|
||||
*/
|
||||
#ifndef __STRATEGY_INTERFACE_H__
|
||||
#define __STRATEGY_INTERFACE_H__
|
||||
|
||||
#include <core/display_types.h>
|
||||
|
||||
namespace sde {
|
||||
|
||||
/*! @brief Strategy library name
|
||||
|
||||
@details This macro defines name for the composition strategy library. This macro shall be used
|
||||
to load library using dlopen().
|
||||
|
||||
@sa GetStrategyInterface
|
||||
*/
|
||||
#define STRATEGY_LIBRARY_NAME "libsdestrategy.so"
|
||||
|
||||
/*! @brief Function name to get composer strategy interface
|
||||
|
||||
@details This macro defines function name for GetStrategyInterface() which will be implemented
|
||||
in the composition strategy library. This macro shall be used to specify name of the function
|
||||
in dlsym().
|
||||
|
||||
@sa GetStrategyInterface
|
||||
*/
|
||||
#define GET_STRATEGY_INTERFACE_NAME "GetStrategyInterface"
|
||||
|
||||
class StrategyInterface;
|
||||
|
||||
/*! @brief Function to get composer strategy interface.
|
||||
|
||||
@details This function is used to get StrategyInterface object which resides in the composer
|
||||
strategy library loaded at runtime.
|
||||
|
||||
@param[out] interface \link StrategyInterface \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
typedef DisplayError (*GetStrategyInterface)(StrategyInterface **interface);
|
||||
|
||||
/*! @brief Maximum number of layers that can be handled by hardware in a given layer stack.
|
||||
*/
|
||||
const int kNumLayersMax = 16;
|
||||
|
||||
/*! @brief This structure defines constraints and device properties that shall be considered for
|
||||
deciding a composition strategy.
|
||||
|
||||
@sa GetNextStrategy
|
||||
*/
|
||||
struct StrategyConstraints {
|
||||
bool gpu_only; //!< Select GPU only composition for this layer stack.
|
||||
uint32_t max_layers; //!< Maximum number of layers that shall be programmed on hardware for the
|
||||
//!< given layer stack.
|
||||
|
||||
StrategyConstraints() : gpu_only(false), max_layers(kNumLayersMax) { }
|
||||
};
|
||||
|
||||
/*! @brief Flag to denote that GPU composition is performed for the given layer stack.
|
||||
*/
|
||||
const uint32_t kFlagGPU = 0x1;
|
||||
|
||||
/*! @brief This structure encapsulates information about the input layer stack and the layers which
|
||||
shall be programmed on hardware.
|
||||
|
||||
@sa GetNextStrategy
|
||||
*/
|
||||
struct HWLayersInfo {
|
||||
LayerStack *stack; //!< Input layer stack. Set by the caller.
|
||||
|
||||
uint32_t index[kNumLayersMax];
|
||||
//!< Indexes of the layers from the layer stack which need to be
|
||||
//!< programmed on hardware.
|
||||
uint32_t count; //!< Total number of layers which need to be set on hardware.
|
||||
uint32_t flags; //!< Strategy flags. There is one flag set for each of the strategy
|
||||
//!< that has been selected for this layer stack. This flag is preserved
|
||||
//!< between multiple GetNextStrategy() calls. Composition manager
|
||||
//!< relies on the total flag count to check the number of strategies
|
||||
//!< that are attempted for this layer stack.
|
||||
|
||||
HWLayersInfo() : stack(NULL), count(0), flags(0) { }
|
||||
};
|
||||
|
||||
class StrategyInterface {
|
||||
public:
|
||||
/*! @brief Method to get strategy for a layer stack. Caller can loop through this method to try
|
||||
get all applicable strategies.
|
||||
|
||||
@param[in] constraints \link StrategyConstraints \endlink
|
||||
@param[inout] layers_info \link HWLayersInfo \endlink
|
||||
|
||||
@return \link DisplayError \endlink
|
||||
*/
|
||||
virtual DisplayError GetNextStrategy(StrategyConstraints *constraints,
|
||||
HWLayersInfo *hw_layers_info) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~StrategyInterface() { }
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __STRATEGY_INTERFACE_H__
|
||||
|
||||
53
displayengine/include/utils/constants.h
Normal file
53
displayengine/include/utils/constants.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __CONSTANTS_H__
|
||||
#define __CONSTANTS_H__
|
||||
|
||||
#define LIKELY(exp) __builtin_expect((exp) != 0, true)
|
||||
#define UNLIKELY(exp) __builtin_expect((exp) != 0, false)
|
||||
|
||||
#define INT(exp) static_cast<int>(exp)
|
||||
#define FLOAT(exp) static_cast<float>(exp)
|
||||
#define UINT32(exp) static_cast<uint32_t>(exp)
|
||||
#define INT32(exp) static_cast<int32_t>(exp)
|
||||
|
||||
#define STRUCT_VAR(struct_name, var_name) \
|
||||
struct struct_name var_name; \
|
||||
memset(&var_name, 0, sizeof(var_name));
|
||||
|
||||
#define STRUCT_VAR_ARRAY(struct_name, var_name, num_var) \
|
||||
struct struct_name var_name[num_var]; \
|
||||
memset(&var_name[0], 0, sizeof(var_name));
|
||||
|
||||
#define ROUND_UP(number, step) ((((number) + ((step) - 1)) / (step)) * (step))
|
||||
|
||||
namespace sde {
|
||||
|
||||
typedef void * Handle;
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __CONSTANTS_H__
|
||||
|
||||
56
displayengine/include/utils/debug.h
Normal file
56
displayengine/include/utils/debug.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __DEBUG_H__
|
||||
#define __DEBUG_H__
|
||||
|
||||
namespace sde {
|
||||
|
||||
enum LogTag {
|
||||
kTagNone = 0, //!< Log tag name is not specified.
|
||||
kTagCore, //!< Log is tagged for display core.
|
||||
kTagStrategy, //!< Log is tagged for composition strategy.
|
||||
};
|
||||
|
||||
class Debug {
|
||||
public:
|
||||
// Log handlers
|
||||
static void Error(const LogTag &tag, const char *format, ...);
|
||||
static void Warning(const LogTag &tag, const char *format, ...);
|
||||
static void Info(const LogTag &tag, const char *format, ...);
|
||||
static void Verbose(const LogTag &tag, const char *format, ...);
|
||||
|
||||
// Debug properties
|
||||
static bool IsVirtualDriver() { return debug_.virtual_driver_; }
|
||||
|
||||
private:
|
||||
Debug();
|
||||
bool virtual_driver_;
|
||||
static Debug debug_;
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __DEBUG_H__
|
||||
|
||||
85
displayengine/include/utils/locker.h
Normal file
85
displayengine/include/utils/locker.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __LOCKER_H__
|
||||
#define __LOCKER_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define SCOPE_LOCK(locker) Locker::ScopeLock scopeLock(locker)
|
||||
|
||||
namespace sde {
|
||||
|
||||
class Locker {
|
||||
public:
|
||||
class ScopeLock {
|
||||
public:
|
||||
explicit ScopeLock(Locker& locker) : locker_(locker) {
|
||||
locker_.Lock();
|
||||
}
|
||||
|
||||
~ScopeLock() {
|
||||
locker_.Unlock();
|
||||
}
|
||||
|
||||
private:
|
||||
Locker &locker_;
|
||||
};
|
||||
|
||||
Locker() {
|
||||
pthread_mutex_init(&mutex_, 0);
|
||||
pthread_cond_init(&condition_, 0);
|
||||
}
|
||||
|
||||
~Locker() {
|
||||
pthread_mutex_destroy(&mutex_);
|
||||
pthread_cond_destroy(&condition_);
|
||||
}
|
||||
|
||||
void Lock() { pthread_mutex_lock(&mutex_); }
|
||||
void Unlock() { pthread_mutex_unlock(&mutex_); }
|
||||
void Signal() { pthread_cond_signal(&condition_); }
|
||||
void Broadcast() { pthread_cond_broadcast(&condition_); }
|
||||
void Wait() { pthread_cond_wait(&condition_, &mutex_); }
|
||||
int WaitFinite(long int ms) {
|
||||
struct timespec ts;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
ts.tv_sec = tv.tv_sec + ms/1000;
|
||||
ts.tv_nsec = tv.tv_usec*1000 + (ms%1000)*1000000;
|
||||
ts.tv_sec += ts.tv_nsec/1000000000L;
|
||||
ts.tv_nsec += ts.tv_nsec%1000000000L;
|
||||
return pthread_cond_timedwait(&condition_, &mutex_, &ts);
|
||||
}
|
||||
|
||||
private:
|
||||
pthread_mutex_t mutex_;
|
||||
pthread_cond_t condition_;
|
||||
};
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __LOCKER_H__
|
||||
|
||||
53
displayengine/include/utils/logger.h
Normal file
53
displayengine/include/utils/logger.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||
* provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||
* conditions and the following disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* * Neither the name of The Linux Foundation nor the names of its contributors may be used to
|
||||
* endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __LOGGER_H__
|
||||
#define __LOGGER_H__
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
namespace sde {
|
||||
|
||||
#ifndef DISPLAY_LOG_TAG
|
||||
#define DISPLAY_LOG_TAG kLogTagNone
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_MODULE_NAME
|
||||
#define DISPLAY_MODULE_NAME "SDE"
|
||||
#endif
|
||||
|
||||
#define DLOG(method, format, ...) Debug::method(DISPLAY_LOG_TAG, \
|
||||
DISPLAY_MODULE_NAME ": " format, ##__VA_ARGS__)
|
||||
|
||||
// DISPLAY_LOG_TAG and DISPLAY_MODULE_NAME must be defined before #include this header file in
|
||||
// respective module, else default definitions are used.
|
||||
#define DLOGE(format, ...) DLOG(Error, format, ##__VA_ARGS__)
|
||||
#define DLOGW(format, ...) DLOG(Warning, format, ##__VA_ARGS__)
|
||||
#define DLOGI(format, ...) DLOG(Info, format, ##__VA_ARGS__)
|
||||
#define DLOGV(format, ...) DLOG(Verbose, format, ##__VA_ARGS__)
|
||||
|
||||
} // namespace sde
|
||||
|
||||
#endif // __LOGGER_H__
|
||||
|
||||
Reference in New Issue
Block a user