Use HWC from 5.1.1

This commit is contained in:
Mr Jenkins 2016-09-02 13:58:01 +02:00
parent 8bf9a36de4
commit ed534d152d
7 changed files with 135 additions and 139 deletions

View file

@ -185,7 +185,6 @@ typedef struct {
int share_fd;//ion_handle share_fd
int size_buffer;
bool valid;
bool is_secure;
}hwc_cache_t;
typedef struct {
@ -208,7 +207,6 @@ typedef struct {
int share_fd;
bool needsync;//for sw_write
bool iscursor;
bool is_secure;
disp_layer_config hwc_layer_info;
}hwc_commit_layer_t;
@ -288,7 +286,6 @@ typedef struct layer_info {
bool is3D;
bool is_cursor;
bool need_sync;
bool is_secure;
int shared_fd;
format_info form_info;
AssignDUETO_T info;
@ -315,6 +312,7 @@ typedef struct{
bool VsyncEnable;
bool issecure;
bool active;
bool setblank;
int HwChannelNum;
int LayerNumofCH;
@ -462,7 +460,6 @@ typedef struct
int fb_pre_mem;
/* end mem limit */
int unblank_flag;
unsigned char has_secure;
}SUNXI_hwcdev_context_t;
@ -606,8 +603,6 @@ static inline int check_valid_format(int format)
//case HAL_PIXEL_FORMAT_RGB_888:
case HAL_PIXEL_FORMAT_RGB_565:
case HAL_PIXEL_FORMAT_BGRA_8888:
//case HAL_PIXEL_FORMAT_sRGB_A_8888:
//case HAL_PIXEL_FORMAT_sRGB_X_8888:
case HAL_PIXEL_FORMAT_YV12:
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
case HAL_PIXEL_FORMAT_BGRX_8888:
@ -693,8 +688,6 @@ static inline bool check_support_blending(int format)
case HAL_PIXEL_FORMAT_RGB_888:
case HAL_PIXEL_FORMAT_RGB_565:
case HAL_PIXEL_FORMAT_BGRA_8888:
//case HAL_PIXEL_FORMAT_sRGB_A_8888:
//case HAL_PIXEL_FORMAT_sRGB_X_8888:
case HAL_PIXEL_FORMAT_BGRX_8888:
return 1;
default:

View file

@ -22,6 +22,7 @@ typedef struct {
unsigned int phys_addr;
unsigned int size;
} sunxi_phys_data;
#define ION_IOC_SUNXI_PHYS_ADDR 7
ion_user_handle_t ion_alloc_buffer(int iAllocBytes, unsigned int heap_mask)

View file

@ -144,11 +144,6 @@ void hwc_down_limit(SUNXI_hwcdev_context_t *Globctx, int local_mem[NUMBEROFDISPL
{
HWC_UNREFERENCED_PARAMETER(local_mem);
int i = 0, tmp_mem_thruput0 = 0;
if(Globctx->has_secure != 0)
{
Globctx->memlimit = Globctx->max_mem_limit;
return;
}
if(Globctx->ForceGPUComp[0] == 0 && Globctx->CanForceGPUCom && force_gpu)
{
if(Globctx->psHwcProcs != NULL

View file

@ -129,6 +129,8 @@ int _hwc_device_set_enhancemode(int disp, bool on_off, bool half)
int _hwc_device_set_output_mode(int disp, int out_type, int out_mode)
{
SUNXI_hwcdev_context_t *Globctx = &gSunxiHwcDevice;
if(Globctx->SunxiDisplay[0].DisplayType == DISP_OUTPUT_TYPE_HDMI)
disp = 0;
DisplayInfo *PsDisplayInfo = &Globctx->SunxiDisplay[disp];
int disp_t;
@ -147,6 +149,8 @@ int _hwc_set_persent(int disp,int para0, int para1)
{
SUNXI_hwcdev_context_t *Globctx = &gSunxiHwcDevice;
DisplayInfo *PsDisplayInfo = NULL;
if(Globctx->SunxiDisplay[0].DisplayType == DISP_OUTPUT_TYPE_HDMI)
disp = 0;
PsDisplayInfo = &Globctx->SunxiDisplay[disp];
if(PsDisplayInfo->VirtualToHWDisplay != -1 && PsDisplayInfo->DisplayType == DISP_OUTPUT_TYPE_HDMI)

View file

@ -15,9 +15,6 @@
*/
#include "hwc.h"
#define ION_HEAP_TYPE_SECURE (ION_HEAP_TYPE_CUSTOM+1)
#define ION_HEAP_SECURE_MASK (1 << ION_HEAP_TYPE_SECURE)
int hwc_rotate_query(unsigned long tr_handle)
{
SUNXI_hwcdev_context_t *Globctx = &gSunxiHwcDevice;
@ -132,7 +129,7 @@ static rotate_cache_t *hwc_ratate_cache_manage(SUNXI_hwcdev_context_t *Globctx,
return ratate_cache;
}
static hwc_cache_t *hwc_tr_cache_get(rotate_cache_t *rotate_cache, int size, int fd, unsigned int sync_count, bool is_secure)
static hwc_cache_t *hwc_tr_cache_get(rotate_cache_t *rotate_cache, int size, int fd, unsigned int sync_count)
{
SUNXI_hwcdev_context_t *Globctx = &gSunxiHwcDevice;
hwc_cache_t *tr_cache = NULL;
@ -166,7 +163,7 @@ static hwc_cache_t *hwc_tr_cache_get(rotate_cache_t *rotate_cache, int size, int
close(tr_cache->fd);
tr_cache->fd = -1;
}
if(tr_cache->share_fd >= 0 && size <= tr_cache->size_buffer && tr_cache->is_secure == is_secure)
if(tr_cache->share_fd >= 0 && size <= tr_cache->size_buffer)
{
if(tr_cache->size_buffer - size > 4096)
{
@ -184,16 +181,6 @@ static hwc_cache_t *hwc_tr_cache_get(rotate_cache_t *rotate_cache, int size, int
}
if(tr_cache->share_fd == -1 || tr_cache->size_buffer == 0)
{
if(is_secure){
ret = ion_alloc_fd(Globctx->IonFd, size,
4096, ION_HEAP_SECURE_MASK, 0, &tr_cache->share_fd);
if(ret < 0)
{
ALOGD("alloc err from ION_HEAP_SECURE_MASK");
return NULL;
}
tr_cache->is_secure = 1;
}else{
ret = ion_alloc_fd(Globctx->IonFd, size,
4096, ION_HEAP_TYPE_DMA_MASK, 0, &tr_cache->share_fd);
if(ret < 0)
@ -209,10 +196,7 @@ static hwc_cache_t *hwc_tr_cache_get(rotate_cache_t *rotate_cache, int size, int
return NULL;
}
}
}
if(!is_secure){
ion_sync_fd(Globctx->IonFd, tr_cache->share_fd);
}
tr_cache->size_buffer = size;
}
tr_cache->sync_cnt = sync_count;
@ -661,7 +645,7 @@ bool hwc_rotate_layer_tr(hwc_dispc_data_t *hwc_layer,
goto translat_err;
}
tr_cache = hwc_tr_cache_get(rotate_cache, size,
commit_data->releasefencefd[disp], hwc_layer->sync_count,commit_layer->is_secure);
commit_data->releasefencefd[disp], hwc_layer->sync_count);
if(tr_cache != NULL)
{
memset(&tr_info, 0, sizeof(tr_info));
@ -738,3 +722,4 @@ translat_err:
return 0;
}

View file

@ -178,7 +178,6 @@ static bool reset_globle(SUNXI_hwcdev_context_t *Globctx,
Globctx->currentmem = 0;
Globctx->has_tr_mem = 0;
Globctx->has_tr_cnt = 0;
Globctx->has_secure = 0;
int tmp_mem_thruput0 = 0;
int all_mem_diff = 0, all_mem = 0, all_mem_fb = 0, ture_disp;
for(i = 0; i < (int)NumofDisp && i < Globctx->NumberofDisp; i++)
@ -925,6 +924,24 @@ static bool resize_layer(HwcDisContext_t *Localctx,
layer_info->fb.crop.y = fb_crop->top + ((cut_top == 1) ? cut_mod:0);
layer_info->fb.crop.height = srcdiff - cut_mod;
}
#if defined(HWC_DEBUG)
ALOGD("\nold:\n[%f,%f]#S[%lld,%lld,%lld,%lld] F[%lld,%lld,%lld,%lld]\n",
Localctx->WidthScaleFactor, Localctx->HighetScaleFactor,
layer_info->fb.crop.x, layer_info->fb.crop.y, layer_info->fb.crop.width,
layer_info->fb.crop.height, layer_info->screen_win.x, layer_info->screen_win.y,
layer_info->screen_win.width, layer_info->screen_win.height);
#endif
if(gSunxiHwcDevice.SunxiDisplay[0].DisplayType == DISP_OUTPUT_TYPE_HDMI) {
layer_info->fb.crop.x = (long long)(((long long)(psLayer->sourceCrop.left)) << 32);
layer_info->fb.crop.width = (long long)(((long long)(psLayer->sourceCrop.right)) << 32);
layer_info->fb.crop.width -= layer_info->fb.crop.x;
layer_info->fb.crop.y = (long long)(((long long)(psLayer->sourceCrop.top)) << 32);
layer_info->fb.crop.height = (long long)(((long long)(psLayer->sourceCrop.bottom)) << 32);
layer_info->fb.crop.height -= layer_info->fb.crop.y;
}
if(layer_info->b_trd_out == 1)
{
switch(PsDisplayInfo->Current3DMode)
@ -1028,7 +1045,7 @@ ret_ok:
HwcAssignStatus hwc_try_assign_layer(HwcDisContext_t *Localctx, size_t singcout, int zOrder)
{
bool needchannel = 1, isvideo = 0, isalpha = 0, isFB = 0, has_tr = 0, issecure = 0;
bool needchannel = 1, isvideo = 0, isalpha = 0, isFB = 0, has_tr = 0;
bool is3D = 0, need_sync = 0, is_cursor = 0;
float WscalFac = 1.0, HscaleFac = 1.0;
int CH= -1, tmCnt1 = 0, tmCnt2 = 0, addLayerCnt = 1;
@ -1078,16 +1095,11 @@ HwcAssignStatus hwc_try_assign_layer(HwcDisContext_t *Localctx, size_t singcout,
goto assign_gpu;
}
if(check_usage_protected(handle))
{
if(!PsDisplayInfo->issecure)
if(check_usage_protected(handle) && !PsDisplayInfo->issecure)
{
ALOGV("%s:Video Protected", __func__);
dueto = D_VIDEO_PD;
goto assign_gpu;
}else{
issecure = 1;
}
}
dueto = check_valid_layer(psLayer);
@ -1227,7 +1239,7 @@ needchannel:
}
}
/*check the mem thruput*/
if(!is_cursor && (Globctx->has_secure == 0))
if(!is_cursor)
{
dueto = calculate_memthruput(Localctx, &Localctx->psAllLayer[singcout],
WscalFac, HscaleFac, Localctx->HwCHUsedCnt - CHdiff, isFB, isvideo);
@ -1262,7 +1274,7 @@ needchannel:
if(!Localctx->force_gpu
&& (Localctx->UsedFB? isFB: ((int)singcout == Localctx->numberofLayer - 2)))
{
if(mem_ctrl_power_policy(Globctx, Localctx) && (Globctx->has_secure == 0))
if(mem_ctrl_power_policy(Globctx, Localctx))
{
Localctx->force_gpu = 1;
goto assigned_need_resigne;
@ -1281,7 +1293,6 @@ assign_overlay:
Globctx->has_tr_cnt += has_tr;
Localctx->tr_mem += has_tr ? (handle->width * handle->height) : 0;
Globctx->has_tr_mem += has_tr ? (handle->width * handle->height) : 0;
Globctx->has_secure += issecure;
psCH[Localctx->HwCHUsedCnt - CHdiff].hasVideo = isvideo;
psCH[Localctx->HwCHUsedCnt - CHdiff].iCHFormat =
@ -1304,9 +1315,8 @@ assign_overlay:
Localctx->psAllLayer[singcout].is3D = is3D;
Localctx->psAllLayer[singcout].info = dueto;
Localctx->psAllLayer[singcout].isvideo = isvideo;
Localctx->psAllLayer[singcout].need_sync = issecure?0:need_sync;
Localctx->psAllLayer[singcout].need_sync = need_sync;
Localctx->psAllLayer[singcout].is_cursor = is_cursor;
Localctx->psAllLayer[singcout].is_secure = issecure;
if(is_cursor)
{
return ASSIGN_CURSOR;
@ -1350,6 +1360,7 @@ int hwc_setup_layer(hwc_dispc_data_t *DisplayData, HwcDisContext_t *Localctx)
const DisplayInfo *PsDisplayInfo = Localctx->psDisplayInfo;
ChannelInfo_t *psChannelInfo = Localctx->ChannelInfo;
struct private_handle_t *handle = NULL;
bool enableLayer = !(PsDisplayInfo->setblank);
ture_disp = PsDisplayInfo->VirtualToHWDisplay;
if(ture_disp < 0 || ture_disp >= NUMBEROFDISPLAY)
@ -1402,7 +1413,6 @@ int hwc_setup_layer(hwc_dispc_data_t *DisplayData, HwcDisContext_t *Localctx)
}
hw_layer_config->needsync = psHwlayer_info->need_sync;
hw_layer_config->share_fd = dup(psHwlayer_info->shared_fd);
hw_layer_config->is_secure = psHwlayer_info->is_secure;
if(check_is_blending(psLayer))
{
layer_info->alpha_mode = 2;
@ -1420,7 +1430,7 @@ int hwc_setup_layer(hwc_dispc_data_t *DisplayData, HwcDisContext_t *Localctx)
layer_info->zorder = zOrder;
layer_info->alpha_value = psChannelInfo[CHCnt].planeAlpha;
psDisconfig->enable = 1;
psDisconfig->enable = enableLayer;
psDisconfig->layer_id = LCnt;
psDisconfig->channel = psChannelInfo[CHCnt].hasVideo ? VideoCnt : UiCnt;
psHwlayer_info->hwchannel = psDisconfig->channel;
@ -2023,9 +2033,10 @@ SUNXI_hwcdev_context_t* hwc_create_device(void)
&& Globctx->SunxiDisplay[1].VirtualToHWDisplay == -EINVAL)
{
hwc_hotplug_switch(1, 1, DISP_TV_MODE_NUM);
}
ALOGD("### init hdmi_plug: IN ###");
}
}else{
if(Globctx->SunxiDisplay[0].DisplayType != DISP_OUTPUT_TYPE_HDMI)
ALOGD("### init hdmi_plug: OUT ###");
}
close(open_fd);
@ -2109,7 +2120,6 @@ SUNXI_hwcdev_context_t* hwc_create_device(void)
Globctx->fBeginTime = 0.0;
Globctx->uiBeginFrame = 0;
Globctx->unblank_flag = 0;
Globctx->has_secure = 0;
hwc_list_init(&Globctx->rotate_cache_list);
Globctx->rotate_hold_cnt = 0;

View file

@ -146,12 +146,12 @@ int hwc_manage_display(DisplayInfo **retDisplayInfo, int DispInfo, ManageDisp mo
disp_tv_mode get_suitable_hdmi_mode(int select, disp_tv_mode lastmode)
{
ALOGI("get_suitable_hdmi_mode select=%d lastmode=%d", select, lastmode);
SUNXI_hwcdev_context_t *Globctx = &gSunxiHwcDevice;
unsigned long arg[4]={0};
arg[0] = select;
int ret, i, j = -1;
disp_tv_mode theMostMode = DISP_TV_MODE_NUM;
struct disp_output para;
i = sizeof(g_tv_para) / sizeof(g_tv_para[0]);
if(lastmode < DISP_TV_MODE_NUM)
{
@ -164,13 +164,15 @@ disp_tv_mode get_suitable_hdmi_mode(int select, disp_tv_mode lastmode)
}
}
theMostMode = DISP_TV_MOD_1080P_60HZ;
arg[1] = DISP_OUTPUT_TYPE_HDMI;
arg[2] = theMostMode;
ret = ioctl(Globctx->DisplayFd, DISP_DEVICE_SWITCH, arg);
return theMostMode;
if(Globctx->SunxiDisplay[0].DisplayType == DISP_OUTPUT_TYPE_HDMI)
{
arg[1] = (unsigned long)&para;
ret = ioctl(Globctx->DisplayFd, DISP_GET_OUTPUT, arg);
if(ret >= 0)
{
theMostMode = (disp_tv_mode)para.mode;
}
}else{
while(i > 0)
{
i--;
@ -196,6 +198,7 @@ theMostMode = DISP_TV_MOD_1080P_60HZ;
}
}
}
}
if(theMostMode != DISP_TV_MODE_NUM)
{
return theMostMode;
@ -210,8 +213,6 @@ int hwc_hotplug_switch(int DisplayNum, bool plug, disp_tv_mode set_mode)
int vir_disp = -1;
DisplayInfo *PsDisplayInfo = NULL;
ALOGE("hwc_hotplug_switch: displayNum=%d plug=%d set_mode=%d", DisplayNum, plug, set_mode);
unsigned long arg[4] = {0};
bool AllreadyPlugin = 0;
vir_disp = hwc_manage_display(&PsDisplayInfo, DisplayNum, FIND_HWDISPNUM);
@ -234,6 +235,7 @@ int hwc_hotplug_switch(int DisplayNum, bool plug, disp_tv_mode set_mode)
}
if(set_mode != DISP_TV_MODE_NUM)
{
PsDisplayInfo->setblank = 1;
PsDisplayInfo->VarDisplayWidth = get_info_mode(set_mode,WIDTH);
PsDisplayInfo->VarDisplayHeight = get_info_mode(set_mode,HEIGHT);
PsDisplayInfo->DisplayType = DISP_OUTPUT_TYPE_HDMI;
@ -250,11 +252,16 @@ int hwc_hotplug_switch(int DisplayNum, bool plug, disp_tv_mode set_mode)
PsDisplayInfo->InitDisplayWidth = PsDisplayInfo->VarDisplayWidth;
}
Globctx->memlimit += PsDisplayInfo->InitDisplayHeight * PsDisplayInfo->InitDisplayWidth * 4;
if(Globctx->SunxiDisplay[0].DisplayType != DISP_OUTPUT_TYPE_HDMI)
{
Globctx->hot_plug = 1;
}
arg[0] = DisplayNum;
arg[1] = DISP_OUTPUT_TYPE_HDMI;
arg[2] = set_mode;
ioctl(Globctx->DisplayFd, DISP_DEVICE_SWITCH, (unsigned long)arg);
PsDisplayInfo->setblank = 0;
Globctx->psHwcProcs->invalidate(Globctx->psHwcProcs);
arg[0] = DisplayNum;
arg[1] = 1;
ioctl(Globctx->DisplayFd, DISP_VSYNC_EVENT_EN,(unsigned long)arg);
@ -266,7 +273,8 @@ int hwc_hotplug_switch(int DisplayNum, bool plug, disp_tv_mode set_mode)
ALOGD( "###hdmi plug in, Type:%d, Mode:0x%08x###",
PsDisplayInfo->DisplayType, PsDisplayInfo->DisplayMode);
}else{
}
else if(Globctx->SunxiDisplay[0].DisplayType != DISP_OUTPUT_TYPE_HDMI){
Globctx->hot_plug = 0;
hwc_manage_display(NULL, DisplayNum ,FREE_DISP);
}
@ -281,7 +289,7 @@ int hwc_hotplug_switch(int DisplayNum, bool plug, disp_tv_mode set_mode)
}else{
ALOGD("###psHwcProcs No register.###");
}
if(!plug)
if(!plug && Globctx->SunxiDisplay[0].DisplayType != DISP_OUTPUT_TYPE_HDMI)
{
arg[0] = DisplayNum;
arg[1] = DISP_OUTPUT_TYPE_NONE;
@ -416,7 +424,7 @@ static int hwc_uevent(void)
}
}
if(IsHdmi)
if(IsHdmi && Globctx->SunxiDisplay[0].DisplayType != DISP_OUTPUT_TYPE_HDMI)
{
while(s)
{