Skip to content

Commit

Permalink
STE OMX FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Rozic committed Jan 28, 2014
1 parent a8669f4 commit 0d16c1f
Show file tree
Hide file tree
Showing 21 changed files with 305 additions and 37 deletions.
3 changes: 3 additions & 0 deletions include/binder/MemoryBase.h
Expand Up @@ -38,6 +38,9 @@ class MemoryBase : public BnMemory
size_t getSize() const { return mSize; }
ssize_t getOffset() const { return mOffset; }
const sp<IMemoryHeap>& getHeap() const { return mHeap; }
#ifdef STE_HARDWARE
virtual sp<IMemoryHeap> getMemory(long* offset, unsigned int* size) const;
#endif

private:
size_t mSize;
Expand Down
29 changes: 6 additions & 23 deletions include/binder/Parcel.h
Expand Up @@ -27,8 +27,8 @@
// ---------------------------------------------------------------------------
namespace android {

template <typename T> class Flattenable;
template <typename T> class LightFlattenable;
class Flattenable;
class IBinder;
class IPCThreadState;
class ProcessState;
Expand Down Expand Up @@ -102,9 +102,7 @@ class Parcel {
status_t writeStrongBinder(const sp<IBinder>& val);
status_t writeWeakBinder(const wp<IBinder>& val);
status_t writeInt32Array(size_t len, const int32_t *val);

template<typename T>
status_t write(const Flattenable<T>& val);
status_t write(const Flattenable& val);

template<typename T>
status_t write(const LightFlattenable<T>& val);
Expand Down Expand Up @@ -159,9 +157,7 @@ class Parcel {
const char16_t* readString16Inplace(size_t* outLen) const;
sp<IBinder> readStrongBinder() const;
wp<IBinder> readWeakBinder() const;

template<typename T>
status_t read(Flattenable<T>& val) const;
status_t read(Flattenable& val) const;

template<typename T>
status_t read(LightFlattenable<T>& val) const;
Expand Down Expand Up @@ -274,11 +270,10 @@ class Parcel {
virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) = 0;
};

template<typename T>
class FlattenableHelper : public FlattenableHelperInterface {
friend class Parcel;
const Flattenable<T>& val;
explicit FlattenableHelper(const Flattenable<T>& val) : val(val) { }
const Flattenable& val;
explicit FlattenableHelper(const Flattenable& val) : val(val) { }

public:
virtual size_t getFlattenedSize() const {
Expand All @@ -291,7 +286,7 @@ class Parcel {
return val.flatten(buffer, size, fds, count);
}
virtual status_t unflatten(void const* buffer, size_t size, int const* fds, size_t count) {
return const_cast<Flattenable<T>&>(val).unflatten(buffer, size, fds, count);
return const_cast<Flattenable&>(val).unflatten(buffer, size, fds, count);
}
};
status_t write(const FlattenableHelperInterface& val);
Expand All @@ -313,12 +308,6 @@ class Parcel {

// ---------------------------------------------------------------------------

template<typename T>
status_t Parcel::write(const Flattenable<T>& val) {
const FlattenableHelper<T> helper(val);
return write(helper);
}

template<typename T>
status_t Parcel::write(const LightFlattenable<T>& val) {
size_t size(val.getFlattenedSize());
Expand All @@ -337,12 +326,6 @@ status_t Parcel::write(const LightFlattenable<T>& val) {
return NO_ERROR;
}

template<typename T>
status_t Parcel::read(Flattenable<T>& val) const {
FlattenableHelper<T> helper(val);
return read(helper);
}

template<typename T>
status_t Parcel::read(LightFlattenable<T>& val) const {
size_t size;
Expand Down
3 changes: 3 additions & 0 deletions include/gui/BufferQueue.h
Expand Up @@ -43,6 +43,9 @@ class BufferQueue : public BnGraphicBufferProducer,
public:
enum { MIN_UNDEQUEUED_BUFFERS = 2 };
enum { NUM_BUFFER_SLOTS = 32 };
#ifdef STE_HARDWARE
enum { NUM_BLIT_BUFFER_SLOTS = 2 };
#endif
enum { NO_CONNECTED_API = 0 };
enum { INVALID_BUFFER_SLOT = -1 };
enum { STALE_BUFFER_SLOT = 1, NO_BUFFER_AVAILABLE, PRESENT_LATER };
Expand Down
5 changes: 4 additions & 1 deletion include/gui/ConsumerBase.h
Expand Up @@ -164,7 +164,10 @@ class ConsumerBase : public virtual RefBase,
const sp<GraphicBuffer> graphicBuffer,
EGLDisplay display, EGLSyncKHR eglFence);

// returns true iff the slot still has the graphicBuffer in it.
// returns true if the slot still has the graphicBuffer in it.
#ifdef STE_HARDWARE
virtual
#endif
bool stillTracking(int slot, const sp<GraphicBuffer> graphicBuffer);

// addReleaseFence* adds the sync points associated with a fence to the set
Expand Down
36 changes: 36 additions & 0 deletions include/gui/GLConsumer.h
Expand Up @@ -30,6 +30,11 @@
#include <utils/Vector.h>
#include <utils/threads.h>

#ifdef STE_HARDWARE
#include <hardware/copybit.h>
#include <gui/IGraphicBufferAlloc.h>
#endif

namespace android {
// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -85,6 +90,11 @@ class GLConsumer : public ConsumerBase {
uint32_t tex, uint32_t texureTarget = TEXTURE_EXTERNAL,
bool useFenceSync = true, bool isControlledByApp = false);

#ifdef STE_HARDWARE
// Method for closing copybit device while abandoning the surface
virtual ~GLConsumer();
#endif

// updateTexImage acquires the most recently queued buffer, and sets the
// image contents of the target texture to it.
//
Expand Down Expand Up @@ -245,6 +255,11 @@ class GLConsumer : public ConsumerBase {
const sp<GraphicBuffer> graphicBuffer,
EGLDisplay display, EGLSyncKHR eglFence);

#ifdef STE_HARDWARE
// returns true if the slot still has the graphicBuffer in it.
virtual bool stillTracking(int slot, const sp<GraphicBuffer> graphicBuffer);
#endif

status_t releaseBufferLocked(int slot,
const sp<GraphicBuffer> graphicBuffer, EGLSyncKHR eglFence) {
return releaseBufferLocked(slot, graphicBuffer, mEglDisplay, eglFence);
Expand Down Expand Up @@ -275,6 +290,11 @@ class GLConsumer : public ConsumerBase {
EGLImageKHR createImage(EGLDisplay dpy,
const sp<GraphicBuffer>& graphicBuffer, const Rect& crop);

#ifdef STE_HARDWARE
// converts buffer to a suitable color format
status_t convert(sp<GraphicBuffer> &srcBuf, sp<GraphicBuffer> &dstBuf);
#endif

// freeBufferLocked frees up the given buffer slot. If the slot has been
// initialized this will release the reference to the GraphicBuffer in that
// slot and destroy the EGLImage in that slot. Otherwise it has no effect.
Expand Down Expand Up @@ -426,6 +446,22 @@ class GLConsumer : public ConsumerBase {
// reset mCurrentTexture to INVALID_BUFFER_SLOT.
int mCurrentTexture;

#ifdef STE_HARDWARE
// mBlitEngine is the handle to the copybit device which will be used in
// case color transform is needed before the EGL image is created.
copybit_device_t* mBlitEngine;

// mGraphicBufferAlloc is the connection to SurfaceFlinger that is used to
// allocate new GraphicBuffer objects.
sp<IGraphicBufferAlloc> mGraphicBufferAlloc;

// mBlitSlots stores the buffers that have been allocated int the case
// of color transform. It is initialised to null pointer,s and gets
// filled in with the result of GLConsumer::updateAndReleaseLocked
sp<GraphicBuffer> mBlitSlots[BufferQueue::NUM_BLIT_BUFFER_SLOTS];
int mNextBlitSlot;
#endif

// mAttached indicates whether the ConsumerBase is currently attached to
// an OpenGL ES context. For legacy reasons, this is initialized to true,
// indicating that the ConsumerBase is considered to be attached to
Expand Down
3 changes: 1 addition & 2 deletions include/gui/IGraphicBufferConsumer.h
Expand Up @@ -39,8 +39,7 @@ class IGraphicBufferConsumer : public IInterface {
public:

// public facing structure for BufferSlot
class BufferItem : public Flattenable<BufferItem> {
friend class Flattenable<BufferItem>;
class BufferItem : public Flattenable {
size_t getPodSize() const;
size_t getFlattenedSize() const;
size_t getFdCount() const;
Expand Down
3 changes: 1 addition & 2 deletions include/gui/IGraphicBufferProducer.h
Expand Up @@ -105,8 +105,7 @@ class IGraphicBufferProducer : public IInterface
// and height of the window and current transform applied to buffers,
// respectively.

struct QueueBufferInput : public Flattenable<QueueBufferInput> {
friend class Flattenable<QueueBufferInput>;
struct QueueBufferInput : public Flattenable {
inline QueueBufferInput(const Parcel& parcel);
inline QueueBufferInput(int64_t timestamp, bool isAutoTimestamp,
const Rect& crop, int scalingMode, uint32_t transform, bool async,
Expand Down
3 changes: 3 additions & 0 deletions include/media/openmax/OMX_IVCommon.h
Expand Up @@ -158,6 +158,9 @@ typedef enum OMX_COLOR_FORMATTYPE {
* */
OMX_COLOR_FormatAndroidOpaque = 0x7F000789,
OMX_TI_COLOR_FormatYUV420PackedSemiPlanar = 0x7F000100,
#ifdef STE_HARDWARE
OMX_STE_COLOR_FormatYUV420PackedSemiPlanarMB = 0x7FA00000,
#endif
OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00,
OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka = 0x7FA30C03,
OMX_SEC_COLOR_FormatNV12Tiled = 0x7FC00002,
Expand Down
2 changes: 1 addition & 1 deletion include/ui/Fence.h
Expand Up @@ -36,7 +36,7 @@ namespace android {
// ===========================================================================

class Fence
: public LightRefBase<Fence>, public Flattenable<Fence>
: public LightRefBase<Fence>, public Flattenable
{
public:
static const sp<Fence> NO_FENCE;
Expand Down
10 changes: 7 additions & 3 deletions include/ui/GraphicBuffer.h
Expand Up @@ -38,10 +38,14 @@ class GraphicBufferMapper;
// ===========================================================================

class GraphicBuffer
: public ANativeObjectBase< ANativeWindowBuffer, GraphicBuffer, RefBase >,
public Flattenable<GraphicBuffer>
: public ANativeObjectBase< ANativeWindowBuffer, GraphicBuffer,
#ifdef STE_HARDWARE
LightRefBase<GraphicBuffer> >,
#else
RefBase >,
#endif
public Flattenable
{
friend class Flattenable<GraphicBuffer>;
public:

enum {
Expand Down
7 changes: 7 additions & 0 deletions include/ui/PixelFormat.h
Expand Up @@ -63,6 +63,13 @@ enum {
PIXEL_FORMAT_BGRA_8888 = HAL_PIXEL_FORMAT_BGRA_8888, // 4x8-bit BGRA
PIXEL_FORMAT_RGBA_5551 = 6, // 16-bit ARGB
PIXEL_FORMAT_RGBA_4444 = 7, // 16-bit ARGB
#ifdef STE_HARDWARE
// Added Support for YUV42XMBN,
// Required for Copybit CC acceleration
PIXEL_FORMAT_YCBCR42XMBN = HAL_PIXEL_FORMAT_YCBCR42XMBN,
PIXEL_FORMAT_YCbCr_420_SP = HAL_PIXEL_FORMAT_YCbCr_420_SP,
PIXEL_FORMAT_YCbCr_420_P = HAL_PIXEL_FORMAT_YCbCr_420_P,
#endif
};

typedef int32_t PixelFormat;
Expand Down
24 changes: 24 additions & 0 deletions include/ui/Region.h
Expand Up @@ -25,6 +25,10 @@
#include <ui/Rect.h>
#include <utils/Flattenable.h>

#ifdef STE_HARDWARE
#include <hardware/copybit.h>
#endif

namespace android {
// ---------------------------------------------------------------------------

Expand Down Expand Up @@ -211,6 +215,26 @@ Region& Region::operator += (const Point& pt) {
return translateSelf(pt.x, pt.y);
}
// ---------------------------------------------------------------------------
#ifdef STE_HARDWARE
struct region_iterator : public copybit_region_t {
region_iterator(const Region& region)
: b(region.begin()), e(region.end()) {
this->next = iterate;
}
private:
static int iterate(copybit_region_t const * self, copybit_rect_t* rect) {
region_iterator const* me = static_cast<region_iterator const*>(self);
if (me->b != me->e) {
*reinterpret_cast<Rect*>(rect) = *me->b++;
return 1;
}
return 0;
}
mutable Region::const_iterator b;
Region::const_iterator const e;
};
#endif
// ---------------------------------------------------------------------------
}; // namespace android

#endif // ANDROID_UI_REGION_H
Expand Down
19 changes: 19 additions & 0 deletions libs/binder/MemoryBase.cpp
Expand Up @@ -26,6 +26,10 @@ namespace android {

// ---------------------------------------------------------------------------

#ifdef STE_HARDWARE
extern "C" void _ZN7android10MemoryBaseC2ERKNS_2spINS_11IMemoryHeapEEElj() __attribute__((alias("_ZN7android10MemoryBaseC1ERKNS_2spINS_11IMemoryHeapEEElj")));
#endif

MemoryBase::MemoryBase(const sp<IMemoryHeap>& heap,
ssize_t offset, size_t size)
: mSize(size), mOffset(offset), mHeap(heap)
Expand All @@ -43,6 +47,21 @@ MemoryBase::~MemoryBase()
{
}

#ifdef STE_HARDWARE
sp<IMemoryHeap> android::MemoryBase::getMemory(long* offset, unsigned int* size) const
{
ssize_t offset_o;
size_t size_o;
sp<IMemoryHeap> res;

res = getMemory(&offset_o, & size_o);
*offset = offset_o;
*size = size_o;

return res;
}
#endif

// ---------------------------------------------------------------------------
}; // namespace android

Expand Down
10 changes: 10 additions & 0 deletions libs/binder/Parcel.cpp
Expand Up @@ -808,6 +808,11 @@ status_t Parcel::writeBlob(size_t len, WritableBlob* outBlob)
return status;
}

status_t Parcel::write(const Flattenable& val) {
const FlattenableHelper helper(val);
return write(helper);
}

status_t Parcel::write(const FlattenableHelperInterface& val)
{
status_t err;
Expand Down Expand Up @@ -1184,6 +1189,11 @@ status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const
return NO_ERROR;
}

status_t Parcel::read(Flattenable& val) const {
FlattenableHelper helper(val);
return read(helper);
}

status_t Parcel::read(FlattenableHelperInterface& val) const
{
// size
Expand Down
1 change: 1 addition & 0 deletions libs/gui/Android.mk
Expand Up @@ -37,6 +37,7 @@ LOCAL_SHARED_LIBRARIES := \
libsync \
libui \
libutils \
libhardware \
liblog

# Executed only on QCOM BSPs
Expand Down
2 changes: 1 addition & 1 deletion libs/gui/ConsumerBase.cpp
Expand Up @@ -141,7 +141,7 @@ void ConsumerBase::abandon() {
}

void ConsumerBase::abandonLocked() {
CB_LOGV("abandonLocked");
CB_LOGV("abandonLocked");
for (int i =0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
freeBufferLocked(i);
}
Expand Down

1 comment on commit 0d16c1f

@iiD4x
Copy link

@iiD4x iiD4x commented on 0d16c1f Jan 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rox , u just my hero u know ?

Please sign in to comment.