2011-03-08 01:35:29 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2008 The Android Open Source Project
|
2011-12-16 23:46:50 +00:00
|
|
|
* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
|
2011-03-08 01:35:29 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDE_OVERLAY_LIB
|
|
|
|
#define INCLUDE_OVERLAY_LIB
|
|
|
|
|
|
|
|
#include <cutils/log.h>
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
#include <cutils/atomic.h>
|
|
|
|
|
|
|
|
#include <hardware/hardware.h>
|
|
|
|
#include <hardware/gralloc.h>
|
|
|
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include <linux/fb.h>
|
|
|
|
#include <linux/msm_mdp.h>
|
|
|
|
#include <linux/msm_rotator.h>
|
|
|
|
#include <linux/android_pmem.h>
|
|
|
|
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/ioctl.h>
|
2011-12-07 06:18:21 +00:00
|
|
|
#include <utils/threads.h>
|
2011-11-14 22:32:10 +00:00
|
|
|
#include <utils/RefBase.h>
|
|
|
|
#include <alloc_controller.h>
|
|
|
|
#include <memalloc.h>
|
2011-03-08 01:35:29 +00:00
|
|
|
|
2011-12-20 00:11:22 +00:00
|
|
|
#ifdef USES_POST_PROCESSING
|
|
|
|
#include "lib-postproc.h"
|
|
|
|
#endif
|
|
|
|
|
2011-03-08 01:35:29 +00:00
|
|
|
#define HW_OVERLAY_MAGNIFICATION_LIMIT 8
|
|
|
|
#define HW_OVERLAY_MINIFICATION_LIMIT HW_OVERLAY_MAGNIFICATION_LIMIT
|
|
|
|
|
2011-03-08 01:40:33 +00:00
|
|
|
#define EVEN_OUT(x) if (x & 0x0001) {x--;}
|
2011-12-07 06:18:21 +00:00
|
|
|
#define NO_PIPE -1
|
2011-01-28 06:07:16 +00:00
|
|
|
#define VG0_PIPE 0
|
|
|
|
#define VG1_PIPE 1
|
|
|
|
#define NUM_CHANNELS 2
|
2012-02-09 11:11:43 +00:00
|
|
|
#define NUM_FB_DEVICES 3
|
2011-01-28 06:07:16 +00:00
|
|
|
#define FRAMEBUFFER_0 0
|
|
|
|
#define FRAMEBUFFER_1 1
|
2011-12-16 23:46:50 +00:00
|
|
|
#define FRAMEBUFFER_2 2
|
2011-12-20 00:11:22 +00:00
|
|
|
#define NUM_SHARPNESS_VALS 256
|
|
|
|
#define SHARPNESS_RANGE 1.0f
|
|
|
|
#define HUE_RANGE 180
|
|
|
|
#define BRIGHTNESS_RANGE 255
|
|
|
|
#define CON_SAT_RANGE 1.0f
|
|
|
|
#define CAP_RANGE(value,max,min) do { if (value - min < -0.0001)\
|
|
|
|
{value = min;}\
|
|
|
|
else if(value - max > 0.0001)\
|
|
|
|
{value = max;}\
|
|
|
|
} while(0);
|
2011-04-21 23:33:39 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
HDMI_OFF,
|
|
|
|
HDMI_ON
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
OVERLAY_CHANNEL_DOWN,
|
|
|
|
OVERLAY_CHANNEL_UP
|
|
|
|
};
|
2011-05-26 19:51:11 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
NEW_REQUEST,
|
|
|
|
UPDATE_REQUEST
|
|
|
|
};
|
2012-01-26 02:16:07 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
WAIT_FOR_VSYNC = 1<<0,
|
|
|
|
DISABLE_FRAMEBUFFER_FETCH = 1<<1,
|
|
|
|
INTERLACED_CONTENT = 1<<2,
|
|
|
|
OVERLAY_PIPE_SHARE = 1<<3,
|
|
|
|
SECURE_OVERLAY_SESSION = 1<<4,
|
|
|
|
};
|
|
|
|
|
2011-03-08 01:40:33 +00:00
|
|
|
/* ------------------------------- 3D defines ---------------------------------------*/
|
|
|
|
// The compound format passed to the overlay is
|
|
|
|
// ABCCC where A is the input 3D format,
|
|
|
|
// B is the output 3D format
|
|
|
|
// CCC is the color format e.g YCbCr420SP YCrCb420SP etc.
|
|
|
|
#define FORMAT_3D(x) (x & 0xFF000)
|
|
|
|
#define COLOR_FORMAT(x) (x & 0xFFF)
|
|
|
|
// in the final 3D format, the MSB 2Bytes are the input format and the
|
|
|
|
// LSB 2bytes are the output format. Shift the output byte 12 bits.
|
2011-02-11 04:05:58 +00:00
|
|
|
#define SHIFT_OUTPUT_3D 12
|
|
|
|
#define FORMAT_3D_OUTPUT(x) ((x & 0xF000) >> SHIFT_OUTPUT_3D)
|
|
|
|
#define FORMAT_3D_INPUT(x) (x & 0xF0000)
|
|
|
|
#define INPUT_MASK_3D 0xFFFF0000
|
|
|
|
#define OUTPUT_MASK_3D 0x0000FFFF
|
|
|
|
#define SHIFT_3D 16
|
2011-03-08 01:40:33 +00:00
|
|
|
// The output format is the 2MSB bytes. Shift the format by 12 to reflect this
|
2011-02-11 04:05:58 +00:00
|
|
|
#define HAL_3D_OUT_SIDE_BY_SIDE_MASK (HAL_3D_OUT_SIDE_BY_SIDE >> SHIFT_OUTPUT_3D)
|
|
|
|
#define HAL_3D_OUT_TOP_BOTTOM_MASK (HAL_3D_OUT_TOP_BOTTOM >> SHIFT_OUTPUT_3D)
|
|
|
|
#define HAL_3D_OUT_INTERLEAVE_MASK (HAL_3D_OUT_INTERLEAVE >> SHIFT_OUTPUT_3D)
|
|
|
|
#define HAL_3D_OUT_MONOSCOPIC_MASK (HAL_3D_OUT_MONOSCOPIC >> SHIFT_OUTPUT_3D)
|
|
|
|
|
2011-02-12 02:05:39 +00:00
|
|
|
// 3D panel barrier orientation
|
|
|
|
#define BARRIER_LANDSCAPE 1
|
|
|
|
#define BARRIER_PORTRAIT 2
|
|
|
|
|
2011-10-15 01:03:04 +00:00
|
|
|
#ifdef HDMI_AS_PRIMARY
|
|
|
|
#define FORMAT_3D_FILE "/sys/class/graphics/fb0/format_3d"
|
|
|
|
#define EDID_3D_INFO_FILE "/sys/class/graphics/fb0/3d_present"
|
|
|
|
#else
|
2011-03-08 01:40:33 +00:00
|
|
|
#define FORMAT_3D_FILE "/sys/class/graphics/fb1/format_3d"
|
2011-02-11 04:05:58 +00:00
|
|
|
#define EDID_3D_INFO_FILE "/sys/class/graphics/fb1/3d_present"
|
2011-10-15 01:03:04 +00:00
|
|
|
#endif
|
2011-02-12 02:05:39 +00:00
|
|
|
#define BARRIER_FILE "/sys/devices/platform/mipi_novatek.0/enable_3d_barrier"
|
2011-03-08 01:40:33 +00:00
|
|
|
/* -------------------------- end 3D defines ----------------------------------------*/
|
|
|
|
|
2011-06-23 22:28:41 +00:00
|
|
|
// Struct to hold the buffer info: geometry and size
|
|
|
|
struct overlay_buffer_info {
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int format;
|
|
|
|
int size;
|
2011-12-29 09:47:39 +00:00
|
|
|
bool secure;
|
2011-06-23 22:28:41 +00:00
|
|
|
};
|
|
|
|
|
2011-12-07 06:18:21 +00:00
|
|
|
using android::Mutex;
|
2011-03-08 01:35:29 +00:00
|
|
|
namespace overlay {
|
2012-02-09 11:11:43 +00:00
|
|
|
|
|
|
|
#define FB_DEVICE_TEMPLATE "/dev/graphics/fb%u"
|
|
|
|
|
2011-12-07 06:18:21 +00:00
|
|
|
//Utility Class to query the framebuffer info
|
|
|
|
class FrameBufferInfo {
|
|
|
|
int mFBWidth;
|
|
|
|
int mFBHeight;
|
|
|
|
bool mBorderFillSupported;
|
|
|
|
static FrameBufferInfo *sFBInfoInstance;
|
|
|
|
|
|
|
|
FrameBufferInfo():mFBWidth(0),mFBHeight(0), mBorderFillSupported(false) {
|
|
|
|
char const * const device_name =
|
|
|
|
"/dev/graphics/fb0";
|
|
|
|
int fd = open(device_name, O_RDWR, 0);
|
|
|
|
mdp_overlay ov;
|
|
|
|
memset(&ov, 0, sizeof(ov));
|
|
|
|
if (fd < 0) {
|
|
|
|
LOGE("FrameBufferInfo: Cant open framebuffer ");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fb_var_screeninfo vinfo;
|
|
|
|
if (ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
|
|
|
|
LOGE("FrameBufferInfo: FBIOGET_VSCREENINFO on fb0 failed");
|
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ov.id = 1;
|
|
|
|
if(ioctl(fd, MSMFB_OVERLAY_GET, &ov)) {
|
|
|
|
LOGE("FrameBufferInfo: MSMFB_OVERLAY_GET on fb0 failed");
|
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
mFBWidth = vinfo.xres;
|
|
|
|
mFBHeight = vinfo.yres;
|
|
|
|
mBorderFillSupported = (ov.flags & MDP_BORDERFILL_SUPPORTED) ?
|
|
|
|
true : false;
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
static FrameBufferInfo* getInstance(){
|
|
|
|
if (!sFBInfoInstance){
|
|
|
|
sFBInfoInstance = new FrameBufferInfo;
|
|
|
|
}
|
|
|
|
return sFBInfoInstance;
|
|
|
|
}
|
|
|
|
int getWidth() const { return mFBWidth; }
|
|
|
|
int getHeight() const { return mFBHeight; }
|
|
|
|
bool canSupportTrueMirroring() const {
|
|
|
|
return mBorderFillSupported; }
|
|
|
|
};
|
2011-03-08 01:35:29 +00:00
|
|
|
|
2011-02-11 04:05:58 +00:00
|
|
|
enum {
|
2011-02-12 02:05:39 +00:00
|
|
|
OV_UI_MIRROR_TV = 0,
|
|
|
|
OV_2D_VIDEO_ON_PANEL,
|
2011-02-11 04:05:58 +00:00
|
|
|
OV_2D_VIDEO_ON_TV,
|
|
|
|
OV_3D_VIDEO_2D_PANEL,
|
|
|
|
OV_3D_VIDEO_2D_TV,
|
|
|
|
OV_3D_VIDEO_3D_PANEL,
|
|
|
|
OV_3D_VIDEO_3D_TV
|
2011-03-08 01:41:08 +00:00
|
|
|
};
|
2011-02-11 04:05:58 +00:00
|
|
|
bool isHDMIConnected();
|
|
|
|
bool is3DTV();
|
2011-02-12 02:05:39 +00:00
|
|
|
bool isPanel3D();
|
|
|
|
bool usePanel3D();
|
2011-02-11 04:05:58 +00:00
|
|
|
bool send3DInfoPacket(unsigned int format3D);
|
2011-02-12 02:05:39 +00:00
|
|
|
bool enableBarrier(unsigned int orientation);
|
|
|
|
unsigned int getOverlayConfig (unsigned int format3D, bool poll = true,
|
|
|
|
bool isHDMI = false);
|
2011-09-16 21:30:10 +00:00
|
|
|
int getColorFormat(int format);
|
2011-12-07 20:47:14 +00:00
|
|
|
bool isInterlacedContent(int format);
|
2011-03-05 17:30:05 +00:00
|
|
|
int get_mdp_format(int format);
|
|
|
|
int get_size(int format, int w, int h);
|
2011-09-16 21:30:10 +00:00
|
|
|
int get_rot_output_format(int format);
|
|
|
|
int get_mdp_orientation(int value);
|
2011-09-22 22:58:27 +00:00
|
|
|
void normalize_crop(uint32_t& xy, uint32_t& wh);
|
2012-02-09 11:11:43 +00:00
|
|
|
//Initializes the overlay - cleans up any existing overlay pipes
|
|
|
|
int initOverlay();
|
2011-03-05 17:30:05 +00:00
|
|
|
|
2011-08-18 05:03:40 +00:00
|
|
|
/* Print values being sent to driver in case of ioctl failures
|
|
|
|
These logs are enabled only if DEBUG_OVERLAY is true */
|
|
|
|
void dump(msm_rotator_img_info& mRotInfo);
|
|
|
|
void dump(mdp_overlay& mOvInfo);
|
|
|
|
const char* getFormatString(int format);
|
|
|
|
|
2011-12-07 06:18:21 +00:00
|
|
|
//singleton class to decide the z order of new overlay surfaces
|
|
|
|
class ZOrderManager {
|
|
|
|
bool mFB0Pipes[NUM_CHANNELS];
|
|
|
|
bool mFB1Pipes[NUM_CHANNELS+1]; //FB1 can have 3 pipes
|
|
|
|
int mPipesInuse; // Holds the number of pipes in use
|
|
|
|
int mMaxPipes; // Max number of pipes
|
|
|
|
static ZOrderManager *sInstance;
|
|
|
|
Mutex *mObjMutex;
|
|
|
|
ZOrderManager(){
|
|
|
|
mPipesInuse = 0;
|
|
|
|
// for true mirroring support there can be 3 pipes on secondary
|
|
|
|
mMaxPipes = FrameBufferInfo::getInstance()->canSupportTrueMirroring()?
|
|
|
|
NUM_CHANNELS+1 : NUM_CHANNELS;
|
|
|
|
for (int i = 0; i < NUM_CHANNELS; i++)
|
|
|
|
mFB0Pipes[i] = false;
|
|
|
|
for (int j = 0; j < mMaxPipes; j++)
|
|
|
|
mFB1Pipes[j] = false;
|
|
|
|
mObjMutex = new Mutex();
|
|
|
|
}
|
|
|
|
~ZOrderManager() {
|
|
|
|
delete sInstance;
|
|
|
|
delete mObjMutex;
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
static ZOrderManager* getInstance(){
|
|
|
|
if (!sInstance){
|
|
|
|
sInstance = new ZOrderManager;
|
|
|
|
}
|
|
|
|
return sInstance;
|
|
|
|
}
|
|
|
|
int getZ(int fbnum);
|
|
|
|
void decZ(int fbnum, int zorder);
|
|
|
|
};
|
2011-02-11 04:05:58 +00:00
|
|
|
const int max_num_buffers = 3;
|
|
|
|
typedef struct mdp_rect overlay_rect;
|
|
|
|
|
2011-03-08 01:35:29 +00:00
|
|
|
class OverlayControlChannel {
|
|
|
|
|
2011-12-20 00:11:22 +00:00
|
|
|
enum {
|
|
|
|
SET_NONE = 0,
|
|
|
|
SET_SHARPNESS,
|
|
|
|
#ifdef USES_POST_PROCESSING
|
|
|
|
SET_HUE,
|
|
|
|
SET_BRIGHTNESS,
|
|
|
|
SET_SATURATION,
|
|
|
|
SET_CONTRAST,
|
|
|
|
#endif
|
|
|
|
RESET_ALL,
|
|
|
|
};
|
2011-03-08 01:35:29 +00:00
|
|
|
bool mNoRot;
|
2011-12-07 06:18:21 +00:00
|
|
|
int mFBNum;
|
2011-03-08 01:35:29 +00:00
|
|
|
int mFBWidth;
|
|
|
|
int mFBHeight;
|
|
|
|
int mFBbpp;
|
|
|
|
int mFBystride;
|
2011-05-20 20:57:35 +00:00
|
|
|
int mFormat;
|
2011-03-08 01:35:29 +00:00
|
|
|
int mFD;
|
|
|
|
int mRotFD;
|
|
|
|
int mSize;
|
|
|
|
int mOrientation;
|
2011-03-08 01:40:33 +00:00
|
|
|
unsigned int mFormat3D;
|
2011-04-01 03:27:26 +00:00
|
|
|
bool mUIChannel;
|
2011-12-20 00:11:22 +00:00
|
|
|
#ifdef USES_POST_PROCESSING
|
|
|
|
struct display_pp_conv_cfg hsic_cfg;
|
|
|
|
#endif
|
2011-03-08 01:35:29 +00:00
|
|
|
mdp_overlay mOVInfo;
|
|
|
|
msm_rotator_img_info mRotInfo;
|
2011-02-12 02:05:39 +00:00
|
|
|
msmfb_overlay_3d m3DOVInfo;
|
2011-09-16 21:30:10 +00:00
|
|
|
bool mIsChannelUpdated;
|
2011-03-08 01:35:29 +00:00
|
|
|
bool openDevices(int fbnum = -1);
|
2011-06-23 22:28:41 +00:00
|
|
|
bool setOverlayInformation(const overlay_buffer_info& info,
|
2012-02-10 22:27:44 +00:00
|
|
|
int zorder = 0, int flags = 0,
|
2011-05-26 19:51:11 +00:00
|
|
|
int requestType = NEW_REQUEST);
|
2012-02-10 22:27:44 +00:00
|
|
|
bool startOVRotatorSessions(const overlay_buffer_info& info, int requestType);
|
2011-03-08 01:35:29 +00:00
|
|
|
void swapOVRotWidthHeight();
|
2011-12-20 00:11:22 +00:00
|
|
|
int commitVisualParam(int8_t paramType, float paramValue);
|
2012-01-26 02:16:07 +00:00
|
|
|
void setInformationFromFlags(int flags, mdp_overlay& ov);
|
2011-03-08 01:35:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
OverlayControlChannel();
|
|
|
|
~OverlayControlChannel();
|
|
|
|
bool startControlChannel(int w, int h, int format,
|
2011-03-08 01:40:33 +00:00
|
|
|
int fbnum, bool norot = false,
|
2011-04-01 03:27:26 +00:00
|
|
|
bool uichannel = false,
|
2011-01-15 21:44:54 +00:00
|
|
|
unsigned int format3D = 0, int zorder = 0,
|
2012-01-26 02:16:07 +00:00
|
|
|
int flags = 0);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool closeControlChannel();
|
|
|
|
bool setPosition(int x, int y, uint32_t w, uint32_t h);
|
2011-11-17 03:32:18 +00:00
|
|
|
bool setTransform(int value, bool fetch = true);
|
2011-06-23 22:28:41 +00:00
|
|
|
void setSize (int size) { mSize = size; }
|
2011-03-08 01:35:29 +00:00
|
|
|
bool getPosition(int& x, int& y, uint32_t& w, uint32_t& h);
|
|
|
|
bool getOvSessionID(int& sessionID) const;
|
|
|
|
bool getRotSessionID(int& sessionID) const;
|
|
|
|
bool getSize(int& size) const;
|
|
|
|
bool isChannelUP() const { return (mFD > 0); }
|
|
|
|
int getFBWidth() const { return mFBWidth; }
|
|
|
|
int getFBHeight() const { return mFBHeight; }
|
2011-03-08 01:40:33 +00:00
|
|
|
int getFormat3D() const { return mFormat3D; }
|
2011-03-08 01:35:29 +00:00
|
|
|
bool getOrientation(int& orientation) const;
|
2012-01-26 02:16:07 +00:00
|
|
|
bool updateOverlayFlags(int flags);
|
2011-05-20 20:57:35 +00:00
|
|
|
bool getAspectRatioPosition(int w, int h, overlay_rect *rect);
|
2011-12-07 06:18:21 +00:00
|
|
|
// Calculates the aspect ratio for video on HDMI based on primary
|
|
|
|
// aspect ratio used in case of true mirroring
|
|
|
|
bool getAspectRatioPosition(int w, int h, int orientation,
|
|
|
|
overlay_rect *inRect, overlay_rect *outRect);
|
2011-01-28 06:07:16 +00:00
|
|
|
bool getPositionS3D(int channel, int format, overlay_rect *rect);
|
2012-01-26 02:16:07 +00:00
|
|
|
bool updateOverlaySource(const overlay_buffer_info& info, int orientation, int flags);
|
2011-05-20 20:57:35 +00:00
|
|
|
bool getFormat() const { return mFormat; }
|
2011-12-20 00:11:22 +00:00
|
|
|
bool setVisualParam(int8_t paramType, float paramValue);
|
2011-02-12 02:05:39 +00:00
|
|
|
bool useVirtualFB ();
|
2012-01-26 02:16:07 +00:00
|
|
|
bool doFlagsNeedUpdate(int flags);
|
2011-03-08 01:35:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class OverlayDataChannel {
|
|
|
|
|
|
|
|
bool mNoRot;
|
2011-12-29 09:47:39 +00:00
|
|
|
bool mSecure;
|
2011-03-08 01:35:29 +00:00
|
|
|
int mFD;
|
|
|
|
int mRotFD;
|
|
|
|
int mPmemFD;
|
|
|
|
void* mPmemAddr;
|
|
|
|
uint32_t mPmemOffset;
|
2011-05-26 19:51:11 +00:00
|
|
|
uint32_t mNewPmemOffset;
|
2011-03-08 01:35:29 +00:00
|
|
|
msmfb_overlay_data mOvData;
|
|
|
|
msmfb_overlay_data mOvDataRot;
|
|
|
|
msm_rotator_data_info mRotData;
|
2011-01-15 21:44:54 +00:00
|
|
|
int mRotOffset[max_num_buffers];
|
|
|
|
int mCurrentItem;
|
|
|
|
int mNumBuffers;
|
2012-02-10 22:27:44 +00:00
|
|
|
bool mUpdateDataChannel;
|
2011-11-14 22:32:10 +00:00
|
|
|
android::sp<gralloc::IAllocController> mAlloc;
|
|
|
|
int mBufferType;
|
2011-03-08 01:35:29 +00:00
|
|
|
|
2011-01-15 21:44:54 +00:00
|
|
|
bool openDevices(int fbnum = -1, bool uichannel = false, int num_buffers = 2);
|
2011-05-26 19:51:11 +00:00
|
|
|
bool mapRotatorMemory(int num_buffers, bool uiChannel, int requestType);
|
|
|
|
bool queue(uint32_t offset);
|
2011-03-08 01:35:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
OverlayDataChannel();
|
|
|
|
~OverlayDataChannel();
|
|
|
|
bool startDataChannel(const OverlayControlChannel& objOvCtrlChannel,
|
2011-12-29 09:47:39 +00:00
|
|
|
int fbnum, bool norot = false, bool secure = false,
|
2011-01-15 21:44:54 +00:00
|
|
|
bool uichannel = false, int num_buffers = 2);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool startDataChannel(int ovid, int rotid, int size,
|
2011-01-15 21:44:54 +00:00
|
|
|
int fbnum, bool norot = false, bool uichannel = false,
|
|
|
|
int num_buffers = 2);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool closeDataChannel();
|
|
|
|
bool setFd(int fd);
|
|
|
|
bool queueBuffer(uint32_t offset);
|
2011-11-28 23:29:08 +00:00
|
|
|
bool waitForHdmiVsync();
|
2011-03-08 01:35:29 +00:00
|
|
|
bool setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
2011-01-28 06:07:16 +00:00
|
|
|
bool getCropS3D(overlay_rect *inRect, int channel, int format, overlay_rect *rect);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool isChannelUP() const { return (mFD > 0); }
|
2012-02-10 22:27:44 +00:00
|
|
|
bool updateDataChannel(int size);
|
2011-03-08 01:35:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Overlay class for single thread application
|
|
|
|
* A multiple thread/process application need to use Overlay HAL
|
|
|
|
*/
|
|
|
|
class Overlay {
|
|
|
|
|
|
|
|
bool mChannelUP;
|
2012-02-07 19:32:06 +00:00
|
|
|
//stores the connected external display Ex: HDMI(1) WFD(2)
|
|
|
|
int mExternalDisplay;
|
2011-02-11 04:05:58 +00:00
|
|
|
unsigned int mS3DFormat;
|
2011-06-01 23:41:33 +00:00
|
|
|
//Actual cropped source width and height of overlay
|
|
|
|
int mCroppedSrcWidth;
|
|
|
|
int mCroppedSrcHeight;
|
2011-06-23 22:28:41 +00:00
|
|
|
overlay_buffer_info mOVBufferInfo;
|
2011-02-12 02:05:39 +00:00
|
|
|
int mState;
|
2011-12-07 06:18:21 +00:00
|
|
|
// Stores the current device orientation
|
|
|
|
int mDevOrientation;
|
2011-03-08 01:41:08 +00:00
|
|
|
OverlayControlChannel objOvCtrlChannel[2];
|
|
|
|
OverlayDataChannel objOvDataChannel[2];
|
2011-03-08 01:35:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Overlay();
|
|
|
|
~Overlay();
|
|
|
|
|
2011-10-15 01:03:04 +00:00
|
|
|
static bool sHDMIAsPrimary;
|
2011-06-23 22:28:41 +00:00
|
|
|
bool startChannel(const overlay_buffer_info& info, int fbnum, bool norot = false,
|
2011-01-15 21:44:54 +00:00
|
|
|
bool uichannel = false, unsigned int format3D = 0,
|
2012-01-26 02:16:07 +00:00
|
|
|
int channel = 0, int flags = 0,
|
2011-01-28 06:07:16 +00:00
|
|
|
int num_buffers = 2);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool closeChannel();
|
2011-12-07 06:18:21 +00:00
|
|
|
bool setDeviceOrientation(int orientation);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool setPosition(int x, int y, uint32_t w, uint32_t h);
|
2011-11-17 03:32:18 +00:00
|
|
|
bool setTransform(int value);
|
2011-01-28 06:07:16 +00:00
|
|
|
bool setOrientation(int value, int channel = 0);
|
|
|
|
bool setFd(int fd, int channel = 0);
|
|
|
|
bool queueBuffer(uint32_t offset, int channel = 0);
|
|
|
|
bool getPosition(int& x, int& y, uint32_t& w, uint32_t& h, int channel = 0);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool isChannelUP() const { return mChannelUP; }
|
2011-03-08 01:41:08 +00:00
|
|
|
int getFBWidth(int channel = 0) const;
|
|
|
|
int getFBHeight(int channel = 0) const;
|
2011-01-28 06:07:16 +00:00
|
|
|
bool getOrientation(int& orientation, int channel = 0) const;
|
2011-03-08 01:35:29 +00:00
|
|
|
bool queueBuffer(buffer_handle_t buffer);
|
2011-12-16 23:46:50 +00:00
|
|
|
bool setSource(const overlay_buffer_info& info, int orientation, int hdmiConnected,
|
2012-01-26 02:16:07 +00:00
|
|
|
int flags, int numBuffers = 2);
|
2012-01-18 05:23:58 +00:00
|
|
|
bool getAspectRatioPosition(int w, int h, overlay_rect *rect, int channel = 0);
|
2011-03-08 01:35:29 +00:00
|
|
|
bool setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
|
2012-01-26 02:16:07 +00:00
|
|
|
bool updateOverlayFlags(int flags);
|
2011-12-20 00:11:22 +00:00
|
|
|
void setVisualParam(int8_t paramType, float paramValue);
|
2011-11-28 23:29:08 +00:00
|
|
|
bool waitForHdmiVsync(int channel);
|
2011-04-21 23:33:39 +00:00
|
|
|
int getChannelStatus() const { return (mChannelUP ? OVERLAY_CHANNEL_UP: OVERLAY_CHANNEL_DOWN); }
|
2012-01-28 03:08:01 +00:00
|
|
|
void closeExternalChannel();
|
2011-03-08 01:41:08 +00:00
|
|
|
private:
|
2011-01-28 06:07:16 +00:00
|
|
|
bool setChannelPosition(int x, int y, uint32_t w, uint32_t h, int channel = 0);
|
|
|
|
bool setChannelCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h, int channel);
|
|
|
|
bool queueBuffer(int fd, uint32_t offset, int channel);
|
2012-01-26 02:16:07 +00:00
|
|
|
bool updateOverlaySource(const overlay_buffer_info& info, int orientation, int flags);
|
2011-06-23 22:28:41 +00:00
|
|
|
int getS3DFormat(int format);
|
2011-03-08 01:35:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct overlay_shared_data {
|
2011-02-12 02:05:39 +00:00
|
|
|
volatile bool isControlSetup;
|
2011-02-11 04:05:58 +00:00
|
|
|
unsigned int state;
|
|
|
|
int rotid[2];
|
|
|
|
int ovid[2];
|
2011-03-08 01:35:29 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
#endif
|