Wait for system event on display change

This commit is contained in:
Kamil Trzcinski 2016-09-03 23:27:58 +02:00
parent 8242cf443f
commit 5d7ae5121e
2 changed files with 32 additions and 32 deletions

View file

@ -93,12 +93,12 @@ static int hwc_setParameter(struct hwc_composer_device_1* dev, int cmd, int disp
break; break;
case DISPLAY_CMD_SETDISPLAYENHANCEDEMOMODE: case DISPLAY_CMD_SETDISPLAYENHANCEDEMOMODE:
ret = _hwc_device_set_enhancemode(disp, para0, 1); ret = _hwc_device_set_enhancemode(disp, para0, 1);
break; break;
case DISPLAY_CMD_SETOUTPUTMODE: case DISPLAY_CMD_SETOUTPUTMODE:
ret = _hwc_device_set_output_mode(disp, para0, para1); ret = _hwc_device_set_output_mode(disp, para0, para1);
break; break;
case DISPLAY_CMD_HDMIPERSENT: case DISPLAY_CMD_HDMIPERSENT:
ret = _hwc_set_persent(disp, para0, para1); ret = _hwc_set_persent(disp, para0, para1);
break; break;
default: default:
@ -149,13 +149,13 @@ static int hwc_eventControl(struct hwc_composer_device_1* dev, int disp,
unsigned long arg[4]={0}; unsigned long arg[4]={0};
HWC_UNREFERENCED_PARAMETER(dev); HWC_UNREFERENCED_PARAMETER(dev);
if(disp == 0) if(disp == 0)
{ {
DisplayInfo *PsDisplayInfo = &Globctx->SunxiDisplay[disp]; DisplayInfo *PsDisplayInfo = &Globctx->SunxiDisplay[disp];
if(PsDisplayInfo->VirtualToHWDisplay != -EINVAL) if(PsDisplayInfo->VirtualToHWDisplay != -EINVAL)
{ {
switch (event) switch (event)
{ {
case HWC_EVENT_VSYNC: case HWC_EVENT_VSYNC:
arg[0] = PsDisplayInfo->VirtualToHWDisplay; arg[0] = PsDisplayInfo->VirtualToHWDisplay;
@ -192,7 +192,7 @@ static int hwc_getDisplayConfigs(struct hwc_composer_device_1 *dev,
*numConfigs = 1; *numConfigs = 1;
*configs = 0; *configs = 0;
return PsDisplayInfo->VirtualToHWDisplay == -EINVAL; return PsDisplayInfo->VirtualToHWDisplay == -EINVAL;
} }
static int32_t hwc_get_attribute(const uint32_t attribute, static int32_t hwc_get_attribute(const uint32_t attribute,
@ -204,9 +204,9 @@ static int32_t hwc_get_attribute(const uint32_t attribute,
if(PsDisplayInfo->VirtualToHWDisplay != -EINVAL) if(PsDisplayInfo->VirtualToHWDisplay != -EINVAL)
{ {
switch(attribute) { switch(attribute) {
case HWC_DISPLAY_VSYNC_PERIOD: case HWC_DISPLAY_VSYNC_PERIOD:
return PsDisplayInfo->DisplayVsyncP; return PsDisplayInfo->DisplayVsyncP;
case HWC_DISPLAY_WIDTH: case HWC_DISPLAY_WIDTH:
#ifdef FORCE_SET_RESOLUTION #ifdef FORCE_SET_RESOLUTION
return FORCE_RESOLUTION_WIDTH; return FORCE_RESOLUTION_WIDTH;
@ -247,13 +247,13 @@ static int hwc_getDisplayAttributes(struct hwc_composer_device_1 *dev,
{ {
HWC_UNREFERENCED_PARAMETER(dev); HWC_UNREFERENCED_PARAMETER(dev);
HWC_UNREFERENCED_PARAMETER(config); HWC_UNREFERENCED_PARAMETER(config);
for (int i = 0; attributes[i] != HWC_DISPLAY_NO_ATTRIBUTE; i++) for (int i = 0; attributes[i] != HWC_DISPLAY_NO_ATTRIBUTE; i++)
{ {
if (disp <=2) if (disp <=2)
{ {
values[i]=hwc_get_attribute(attributes[i],disp); values[i]=hwc_get_attribute(attributes[i],disp);
}else }else
{ {
ALOGE("unknown display type %u", disp); ALOGE("unknown display type %u", disp);
@ -312,12 +312,12 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name,
hwc_composer_device_1_t *psHwcDevice; hwc_composer_device_1_t *psHwcDevice;
hw_device_t *psHwDevice; hw_device_t *psHwDevice;
int err = 0; int err = 0;
if (strcmp(name, HWC_HARDWARE_COMPOSER)) if (strcmp(name, HWC_HARDWARE_COMPOSER))
{ {
return -EINVAL; return -EINVAL;
} }
psHwcDevice = (hwc_composer_device_1_t *)malloc(sizeof(hwc_composer_device_1_t)); psHwcDevice = (hwc_composer_device_1_t *)malloc(sizeof(hwc_composer_device_1_t));
if(!psHwcDevice) if(!psHwcDevice)
{ {
@ -329,14 +329,14 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name,
psHwDevice = (hw_device_t *)psHwcDevice; psHwDevice = (hw_device_t *)psHwcDevice;
psHwcDevice->common.tag = HARDWARE_DEVICE_TAG; psHwcDevice->common.tag = HARDWARE_DEVICE_TAG;
#ifdef HWC_1_3 #ifdef HWC_1_3
psHwcDevice->common.version = HWC_DEVICE_API_VERSION_1_3; psHwcDevice->common.version = HWC_DEVICE_API_VERSION_1_3;
#else #else
psHwcDevice->common.version = HWC_DEVICE_API_VERSION_1_1; psHwcDevice->common.version = HWC_DEVICE_API_VERSION_1_1;
#endif #endif
psHwcDevice->common.module = const_cast<hw_module_t*>(module); psHwcDevice->common.module = const_cast<hw_module_t*>(module);
psHwcDevice->common.close = hwc_device_close; psHwcDevice->common.close = hwc_device_close;
psHwcDevice->prepare = hwc_prepare; psHwcDevice->prepare = hwc_prepare;
psHwcDevice->set = hwc_set; psHwcDevice->set = hwc_set;
psHwcDevice->setParameter = hwc_setParameter; psHwcDevice->setParameter = hwc_setParameter;
@ -347,7 +347,7 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name,
psHwcDevice->getDisplayConfigs = hwc_getDisplayConfigs; psHwcDevice->getDisplayConfigs = hwc_getDisplayConfigs;
psHwcDevice->getDisplayAttributes = hwc_getDisplayAttributes; psHwcDevice->getDisplayAttributes = hwc_getDisplayAttributes;
/* /*
open the hardware cursor ,you must modify the setIsCursorLayerHint() in Hwcomposer.cpp for open the hardware cursor ,you must modify the setIsCursorLayerHint() in Hwcomposer.cpp for
HWC_DEVICE_API_VERSION_1_4 to HWC_DEVICE_API_VERSION_1_1 HWC_DEVICE_API_VERSION_1_4 to HWC_DEVICE_API_VERSION_1_1
*/ */
psHwcDevice->setCursorPositionAsync = hwc_set_cursor_async; psHwcDevice->setCursorPositionAsync = hwc_set_cursor_async;
@ -356,7 +356,7 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name,
hwc_create_device(); hwc_create_device();
android::add_sysprop_change_callback(hwc_sysprop_changed, 1000); android::add_sysprop_change_callback(hwc_sysprop_changed, 1000);
hwc_sysprop_changed(); //hwc_sysprop_changed();
return err; return err;
} }

View file

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "hwc.h" #include "hwc.h"
SUNXI_hwcdev_context_t gSunxiHwcDevice; SUNXI_hwcdev_context_t gSunxiHwcDevice;
@ -28,14 +28,14 @@ static mem_speed_limit_t mem_speed_limit[3] =
{432000, 20736000}, {432000, 20736000},
}; };
static void reset_layer_type(HwcDisContext_t *Localctx, int hwctype) static void reset_layer_type(HwcDisContext_t *Localctx, int hwctype)
{ {
SUNXI_hwcdev_context_t *Globctx = &gSunxiHwcDevice; SUNXI_hwcdev_context_t *Globctx = &gSunxiHwcDevice;
int j = 0; int j = 0;
struct private_handle_t *handle = NULL; struct private_handle_t *handle = NULL;
layer_info_t *psAllLayer = Localctx->psAllLayer; layer_info_t *psAllLayer = Localctx->psAllLayer;
hwc_layer_1_t *psLayer = NULL; hwc_layer_1_t *psLayer = NULL;
for(j = 0; j < Localctx->numberofLayer; j++) for(j = 0; j < Localctx->numberofLayer; j++)
{ {
psLayer = psAllLayer[j].psLayer; psLayer = psAllLayer[j].psLayer;
if(psLayer != NULL && psLayer->compositionType != HWC_FRAMEBUFFER_TARGET) if(psLayer != NULL && psLayer->compositionType != HWC_FRAMEBUFFER_TARGET)
@ -62,7 +62,7 @@ static void reset_layer_type(HwcDisContext_t *Localctx, int hwctype)
static void calculate_factor(DisplayInfo *PsDisplayInfo, static void calculate_factor(DisplayInfo *PsDisplayInfo,
float *XWidthFactor, float *XHighetfactor) float *XWidthFactor, float *XHighetfactor)
{ {
float WidthFactor = (float)PsDisplayInfo->PersentWidth / 100; float WidthFactor = (float)PsDisplayInfo->PersentWidth / 100;
float Highetfactor = (float)PsDisplayInfo->PersentHeight / 100; float Highetfactor = (float)PsDisplayInfo->PersentHeight / 100;
if(PsDisplayInfo->InitDisplayWidth && PsDisplayInfo->InitDisplayHeight) if(PsDisplayInfo->InitDisplayWidth && PsDisplayInfo->InitDisplayHeight)
@ -119,7 +119,7 @@ static bool reset_local(HwcDisContext_t *Localctx)
while(j--) while(j--)
{ {
Localctx->ChannelInfo[i].HwLayer[j] = NULL; Localctx->ChannelInfo[i].HwLayer[j] = NULL;
} }
} }
return 0; return 0;
} }
@ -221,8 +221,8 @@ static bool reset_globle(SUNXI_hwcdev_context_t *Globctx,
if(Localctx->psAllLayer != NULL) if(Localctx->psAllLayer != NULL)
{ {
psAllLayer = Localctx->psAllLayer; psAllLayer = Localctx->psAllLayer;
memset(psAllLayer, 0, sizeof(layer_info_t) * Localctx->malloc_layer); memset(psAllLayer, 0, sizeof(layer_info_t) * Localctx->malloc_layer);
for(j = 0; j < psDisplay->numHwLayers; j++) for(j = 0; j < psDisplay->numHwLayers; j++)
{ {
psLayer = &psDisplay->hwLayers[j]; psLayer = &psDisplay->hwLayers[j];
psAllLayer[j].psLayer = psLayer; psAllLayer[j].psLayer = psLayer;
@ -241,7 +241,7 @@ static bool reset_globle(SUNXI_hwcdev_context_t *Globctx,
if(handle != NULL && check_video(handle->format)) if(handle != NULL && check_video(handle->format))
{ {
Localctx->video_mem += cal_layer_mem(&psAllLayer[j]); Localctx->video_mem += cal_layer_mem(&psAllLayer[j]);
Localctx->video_cnt++; Localctx->video_cnt++;
} }
if(handle != NULL if(handle != NULL
&& psLayer->transform != 0 && psLayer->transform != 0
@ -1094,7 +1094,7 @@ HwcAssignStatus hwc_try_assign_layer(HwcDisContext_t *Localctx, size_t singcout,
dueto = D_CONTIG_MEM; dueto = D_CONTIG_MEM;
goto assign_gpu; goto assign_gpu;
} }
if(check_usage_protected(handle) && !PsDisplayInfo->issecure) if(check_usage_protected(handle) && !PsDisplayInfo->issecure)
{ {
ALOGV("%s:Video Protected", __func__); ALOGV("%s:Video Protected", __func__);
@ -1120,7 +1120,7 @@ HwcAssignStatus hwc_try_assign_layer(HwcDisContext_t *Localctx, size_t singcout,
} }
if( !is_cursor if( !is_cursor
&& psLayer->transform != 0 && psLayer->transform != 0
&& (Globctx->stop_rotate_hw || !check_fix_rotate(Globctx, psLayer))) && (Globctx->stop_rotate_hw || !check_fix_rotate(Globctx, psLayer)))
{ {
ALOGD("Many tr_mem[%d,%d,%d] stop[%d]", Globctx->tr_mem_limit, ALOGD("Many tr_mem[%d,%d,%d] stop[%d]", Globctx->tr_mem_limit,
@ -1223,7 +1223,7 @@ HwcAssignStatus hwc_try_assign_layer(HwcDisContext_t *Localctx, size_t singcout,
needchannel: needchannel:
if(needchannel) if(needchannel)
{ {
/* here is a fix :UI has used video channel ,wether reasigend? /* here is a fix :UI has used video channel ,wether reasigend?
could add check video before hwc_try_assign_layer() could add check video before hwc_try_assign_layer()
but must check_cross_list() between the videos but must check_cross_list() between the videos
*/ */
@ -1438,7 +1438,7 @@ int hwc_setup_layer(hwc_dispc_data_t *DisplayData, HwcDisContext_t *Localctx)
hw_layer_config->iscursor = psHwlayer_info->is_cursor; hw_layer_config->iscursor = psHwlayer_info->is_cursor;
if(psHwlayer_info->is_cursor && !Localctx->fb_has_alpha) if(psHwlayer_info->is_cursor && !Localctx->fb_has_alpha)
{ {
/* /*
if cursor,we must set it to the the biggest z-order, if cursor,we must set it to the the biggest z-order,
if there is nothing alpha in fb, higher than fb if there is nothing alpha in fb, higher than fb
*/ */
@ -1714,7 +1714,7 @@ bool sunxi_set(hwc_display_contents_1_t **displays, size_t numDisplays)
close(mergfd); close(mergfd);
} }
} }
/* if miracast need tr we need sw_sync and merge the fence fd /* if miracast need tr we need sw_sync and merge the fence fd
the disp0 releasefencefd is the wb over,so don't need wb timeline. the disp0 releasefencefd is the wb over,so don't need wb timeline.
*/ */
deal_fence: deal_fence:
@ -1803,7 +1803,7 @@ static int hwc_init_display(void)
int arg[4] = {0}; int arg[4] = {0};
int DispCnt, outtype, permanentdisp, hasDispCnt = 0; int DispCnt, outtype, permanentdisp, hasDispCnt = 0;
if (ioctl(Globctx->FBFd, FBIOGET_VSCREENINFO, &info) == -1) if (ioctl(Globctx->FBFd, FBIOGET_VSCREENINFO, &info) == -1)
{ {
ALOGE("FBIOGET_VSCREENINFO ioctl failed: %s", strerror(errno)); ALOGE("FBIOGET_VSCREENINFO ioctl failed: %s", strerror(errno));
return -1; return -1;
@ -1939,7 +1939,7 @@ static int hwc_init_display(void)
default: default:
ALOGD("not support type"); ALOGD("not support type");
continue; continue;
} }
#ifdef FORCE_SET_RESOLUTION #ifdef FORCE_SET_RESOLUTION
PsDisplayInfo->VarDisplayWidth = FORCE_RESOLUTION_WIDTH; PsDisplayInfo->VarDisplayWidth = FORCE_RESOLUTION_WIDTH;