diff options
Diffstat (limited to 'drivers/mxc/gpu-viv/hal/kernel')
21 files changed, 1118 insertions, 288 deletions
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c index b14bf79c038a..15ed52c75208 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c @@ -89,6 +89,18 @@ gctCONST_STRING _DispatchText[] = }; #endif +#if gcdENABLE_RECOVERY +void +_ResetFinishFunction( + gctPOINTER Data + ) +{ + gckKERNEL kernel = (gckKERNEL)Data; + + gckOS_AtomSet(kernel->os, kernel->resetAtom, 0); +} +#endif + /******************************************************************************* ** ** gckKERNEL_Construct @@ -246,6 +258,17 @@ gckKERNEL_Construct( /* Construct the gckMMU object. */ gcmkONERROR( gckMMU_Construct(kernel, gcdMMU_SIZE, &kernel->mmu)); + +#if gcdENABLE_RECOVERY + gcmkONERROR( + gckOS_AtomConstruct(Os, &kernel->resetAtom)); + + gcmkVERIFY_OK( + gckOS_CreateTimer(Os, + (gctTIMERFUNCTION)_ResetFinishFunction, + (gctPOINTER)kernel, + &kernel->resetFlagClearTimer)); +#endif } #if VIVANTE_PROFILER @@ -302,6 +325,19 @@ OnError: gcmkVERIFY_OK(gckOS_AtomDestroy(Os, kernel->atomClients)); } +#if gcdENABLE_RECOVERY + if (kernel->resetAtom != gcvNULL) + { + gcmkVERIFY_OK(gckOS_AtomDestroy(Os, kernel->resetAtom)); + } + + if (kernel->resetFlagClearTimer) + { + gcmkVERIFY_OK(gckOS_StopTimer(Os, kernel->resetFlagClearTimer)); + gcmkVERIFY_OK(gckOS_DestoryTimer(Os, kernel->resetFlagClearTimer)); + } +#endif + if (kernel->dbCreated && kernel->db != gcvNULL) { if (kernel->db->dbMutex != gcvNULL) @@ -409,6 +445,16 @@ gckKERNEL_Destroy( /* Destroy the gckHARDWARE object. */ gcmkVERIFY_OK(gckHARDWARE_Destroy(Kernel->hardware)); + +#if gcdENABLE_RECOVERY + gcmkVERIFY_OK(gckOS_AtomDestroy(Kernel->os, Kernel->resetAtom)); + + if (Kernel->resetFlagClearTimer) + { + gcmkVERIFY_OK(gckOS_StopTimer(Kernel->os, Kernel->resetFlagClearTimer)); + gcmkVERIFY_OK(gckOS_DestoryTimer(Kernel->os, Kernel->resetFlagClearTimer)); + } +#endif } /* Detsroy the client atom. */ @@ -787,6 +833,12 @@ gckKERNEL_Dispatch( case gcvHAL_FREE_NON_PAGED_MEMORY: physical = Interface->u.FreeNonPagedMemory.physical; + /* Unmap user logical out of physical memory first. */ + gcmkONERROR(gckOS_UnmapUserLogical(Kernel->os, + physical, + Interface->u.FreeNonPagedMemory.bytes, + Interface->u.FreeNonPagedMemory.logical)); + /* Free non-paged memory. */ gcmkONERROR( gckOS_FreeNonPagedMemory(Kernel->os, @@ -833,6 +885,12 @@ gckKERNEL_Dispatch( case gcvHAL_FREE_CONTIGUOUS_MEMORY: physical = Interface->u.FreeContiguousMemory.physical; + /* Unmap user logical out of physical memory first. */ + gcmkONERROR(gckOS_UnmapUserLogical(Kernel->os, + physical, + Interface->u.FreeContiguousMemory.bytes, + Interface->u.FreeContiguousMemory.logical)); + /* Free contiguous memory. */ gcmkONERROR( gckOS_FreeContiguous(Kernel->os, @@ -1124,10 +1182,70 @@ gckKERNEL_Dispatch( break; case gcvUSER_SIGNAL_WAIT: - /* Wait on the signal. */ - status = gckOS_WaitUserSignal(Kernel->os, - Interface->u.UserSignal.id, - Interface->u.UserSignal.wait); +#if gcdGPU_TIMEOUT + if (Interface->u.UserSignal.wait == gcvINFINITE) + { + gckHARDWARE hardware; + gctUINT32 timer = 0; + + for(;;) + { + /* Wait on the signal. */ + status = gckOS_WaitUserSignal(Kernel->os, + Interface->u.UserSignal.id, + gcdGPU_ADVANCETIMER); + + if (status == gcvSTATUS_TIMEOUT) + { + gcmkONERROR( + gckOS_SignalQueryHardware(Kernel->os, + (gctSIGNAL)Interface->u.UserSignal.id, + &hardware)); + + if (hardware) + { + /* This signal is bound to a hardware, + ** so the timeout is limited by gcdGPU_TIMEOUT. + */ + timer += gcdGPU_ADVANCETIMER; + } + + if (timer >= gcdGPU_TIMEOUT) + { + gcmkONERROR( + gckOS_Broadcast(Kernel->os, + hardware, + gcvBROADCAST_GPU_STUCK)); + + timer = 0; + + /* If a few process try to reset GPU, only one + ** of them can do the real reset, other processes + ** still need to wait for this signal is triggered, + ** which menas reset is finished. + */ + continue; + } + } + else + { + /* Bail out on other error. */ + gcmkONERROR(status); + + /* Wait for signal successfully. */ + break; + } + } + } + else +#endif + { + /* Wait on the signal. */ + status = gckOS_WaitUserSignal(Kernel->os, + Interface->u.UserSignal.id, + Interface->u.UserSignal.wait); + } + break; case gcvUSER_SIGNAL_MAP: @@ -1823,6 +1941,7 @@ gckKERNEL_Dispatch( status = gcvSTATUS_NOT_SUPPORTED; #endif break; + default: /* Invalid command. */ gcmkONERROR(gcvSTATUS_INVALID_ARGUMENT); @@ -1983,6 +2102,24 @@ gckKERNEL_AttachProcessEx( Kernel->db->lastProcessID = PID; } +#if gcdENABLE_VG + if (Kernel->vg == gcvNULL) +#endif + { + status = gckEVENT_Submit(Kernel->eventObj, gcvTRUE, gcvFALSE); + + if (status == gcvSTATUS_INTERRUPTED && Kernel->eventObj->submitTimer) + { + gcmkONERROR(gckOS_StartTimer(Kernel->os, + Kernel->eventObj->submitTimer, + 1)); + } + else + { + gcmkONERROR(status); + } + } + /* Decrement the number of clients attached. */ gcmkONERROR( gckOS_AtomDecrement(Kernel->os, Kernel->atomClients, &old)); @@ -2530,7 +2667,7 @@ gckKERNEL_Recovery( ) { #if gcdENABLE_RECOVERY -#define gcvEVENT_MASK 0x3FFFFFFF +#define gcdEVENT_MASK 0x3FFFFFFF gceSTATUS status; gckEVENT eventObj; gckHARDWARE hardware; @@ -2538,7 +2675,7 @@ gckKERNEL_Recovery( gctUINT32 processID; gcskSECURE_CACHE_PTR cache; #endif - + gctUINT32 oldValue; gcmkHEADER_ARG("Kernel=0x%x", Kernel); /* Validate the arguemnts. */ @@ -2552,22 +2689,6 @@ gckKERNEL_Recovery( hardware = Kernel->hardware; gcmkVERIFY_OBJECT(hardware, gcvOBJ_HARDWARE); - /* Handle all outstanding events now. */ -#if gcdSMP - gcmkONERROR(gckOS_AtomSet(Kernel->os, eventObj->pending, gcvEVENT_MASK)); -#else - eventObj->pending = gcvEVENT_MASK; -#endif - gcmkONERROR(gckEVENT_Notify(eventObj, 1)); - - /* Again in case more events got submitted. */ -#if gcdSMP - gcmkONERROR(gckOS_AtomSet(Kernel->os, eventObj->pending, gcvEVENT_MASK)); -#else - eventObj->pending = gcvEVENT_MASK; -#endif - gcmkONERROR(gckEVENT_Notify(eventObj, 2)); - #if gcdSECURE_USER /* Flush the secure mapping cache. */ gcmkONERROR(gckOS_GetProcessID(&processID)); @@ -2575,6 +2696,23 @@ gckKERNEL_Recovery( gcmkONERROR(gckKERNEL_FlushTranslationCache(Kernel, cache, gcvNULL, 0)); #endif + gcmkONERROR( + gckOS_AtomicExchange(Kernel->os, Kernel->resetAtom, 1, &oldValue)); + + if (oldValue) + { + /* Some one else will recovery GPU. */ + return gcvSTATUS_OK; + } + + /* Start a timer to clear reset flag, before timer is expired, + ** other recovery request is ignored. */ + gcmkVERIFY_OK( + gckOS_StartTimer(Kernel->os, + Kernel->resetFlagClearTimer, + gcdGPU_TIMEOUT - 500)); + + /* Try issuing a soft reset for the GPU. */ status = gckHARDWARE_Reset(hardware); if (status == gcvSTATUS_NOT_SUPPORTED) @@ -2591,6 +2729,22 @@ gckKERNEL_Recovery( gcmkONERROR(status); } + /* Handle all outstanding events now. */ +#if gcdSMP + gcmkONERROR(gckOS_AtomSet(Kernel->os, eventObj->pending, gcdEVENT_MASK)); +#else + eventObj->pending = gcdEVENT_MASK; +#endif + gcmkONERROR(gckEVENT_Notify(eventObj, 1)); + + /* Again in case more events got submitted. */ +#if gcdSMP + gcmkONERROR(gckOS_AtomSet(Kernel->os, eventObj->pending, gcdEVENT_MASK)); +#else + eventObj->pending = gcdEVENT_MASK; +#endif + gcmkONERROR(gckEVENT_Notify(eventObj, 2)); + /* Success. */ gcmkFOOTER_NO(); return gcvSTATUS_OK; diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h index b627f3b1d5f9..1f3c9ccc20a8 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h @@ -338,6 +338,11 @@ struct _gckKERNEL gckDB db; gctBOOL dbCreated; +#if gcdENABLE_RECOVERY + gctPOINTER resetFlagClearTimer; + gctPOINTER resetAtom; +#endif + /* Pointer to gckEVENT object. */ gcsTIMER timers[8]; gctUINT32 timeOut; @@ -525,6 +530,8 @@ struct _gckEVENT gcsEVENT_QUEUE_PTR freeList; gcsEVENT_QUEUE repoList[gcdREPO_LIST_COUNT]; gctPOINTER eventListMutex; + + gctPOINTER submitTimer; }; /* Free all events belonging to a process. */ diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command.c index 8cf0509cfd92..fbaff6666a10 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command.c @@ -30,6 +30,9 @@ #define _GC_OBJ_ZONE gcvZONE_COMMAND +#if gcdENABLE_FSCALE_VAL_ADJUST +extern int thermal_hot; +#endif /******************************************************************************\ ********************************* Support Code ********************************* \******************************************************************************/ @@ -1080,6 +1083,24 @@ gckCOMMAND_Commit( /* Extract the gckHARDWARE and gckEVENT objects. */ hardware = Command->kernel->hardware; +#if gcdENABLE_FSCALE_VAL_ADJUST + if(hardware->core == gcvCORE_MAJOR){ + static gctUINT orgFscale,minFscale,maxFscale; + static gctBOOL bAlreadyTooHot = gcvFALSE; + if((thermal_hot > 0) && (!bAlreadyTooHot)) { + gckHARDWARE_GetFscaleValue(hardware,&orgFscale,&minFscale, &maxFscale); + gckHARDWARE_SetFscaleValue(hardware, minFscale); + bAlreadyTooHot = gcvTRUE; + gckOS_Print("System is too hot. GPU3D will work at %d/64 clock.\n", minFscale); + } else if((!(thermal_hot > 0)) && bAlreadyTooHot) { + gckHARDWARE_SetFscaleValue(hardware, orgFscale); + gckOS_Print("Hot alarm is canceled. GPU3D clock will return to %d/64\n", orgFscale); + bAlreadyTooHot = gcvFALSE; + } + + } +#endif + /* Check wehther we need to copy the structures or not. */ gcmkONERROR(gckOS_QueryNeedCopy(Command->os, ProcessID, &needCopy)); @@ -2619,6 +2640,12 @@ gckCOMMAND_Detach( /* Construct a gckCONTEXT object. */ gcmkONERROR(gckCONTEXT_Destroy(Context)); + if (Command->currContext == Context) + { + /* Detach from gckCOMMAND object if the destoryed context is current context. */ + Command->currContext = gcvNULL; + } + /* Release the context switching mutex. */ gcmkONERROR(gckOS_ReleaseMutex(Command->os, Command->mutexContext)); acquired = gcvFALSE; diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command_vg.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command_vg.c index 227ab683778e..e5b659262a46 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command_vg.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_command_vg.c @@ -97,6 +97,30 @@ gcsQUEUE_UPDATE_CONTROL; /******************************************************************************\ ********************************* Support Code ********************************* \******************************************************************************/ +static gceSTATUS +_FlushMMU( + IN gckVGCOMMAND Command + ) +{ + gceSTATUS status; + gctUINT32 oldValue; + gckVGHARDWARE hardware = Command->hardware; + + gcmkONERROR(gckOS_AtomicExchange(Command->os, + hardware->pageTableDirty, + 0, + &oldValue)); + + if (oldValue) + { + /* Page Table is upated, flush mmu before commit. */ + gcmkONERROR(gckVGHARDWARE_FlushMMU(hardware)); + } + + return gcvSTATUS_OK; +OnError: + return status; +} static gceSTATUS _WaitForIdle( @@ -577,6 +601,67 @@ _FreeTaskContainer( } } +gceSTATUS +_RemoveRecordFromProcesDB( + IN gckVGCOMMAND Command, + IN gcsTASK_HEADER_PTR Task + ) +{ + gcsTASK_PTR task = (gcsTASK_PTR)((gctUINT8_PTR)Task - sizeof(gcsTASK)); + gcsTASK_FREE_VIDEO_MEMORY_PTR freeVideoMemory; + gcsTASK_UNLOCK_VIDEO_MEMORY_PTR unlockVideoMemory; + gctINT pid; + gctUINT32 size; + + /* Get the total size of all tasks. */ + size = task->size; + + gcmkVERIFY_OK(gckOS_GetProcessID((gctUINT32_PTR)&pid)); + + do + { + switch (Task->id) + { + case gcvTASK_FREE_VIDEO_MEMORY: + freeVideoMemory = (gcsTASK_FREE_VIDEO_MEMORY_PTR)Task; + + /* Remove record from process db. */ + gcmkVERIFY_OK(gckKERNEL_RemoveProcessDB( + Command->kernel->kernel, + pid, + gcvDB_VIDEO_MEMORY, + freeVideoMemory->node)); + + /* Advance to next task. */ + size -= sizeof(gcsTASK_FREE_VIDEO_MEMORY); + Task = (gcsTASK_HEADER_PTR)(freeVideoMemory + 1); + + break; + case gcvTASK_UNLOCK_VIDEO_MEMORY: + unlockVideoMemory = (gcsTASK_UNLOCK_VIDEO_MEMORY_PTR)Task; + + /* Remove record from process db. */ + gcmkVERIFY_OK(gckKERNEL_RemoveProcessDB( + Command->kernel->kernel, + pid, + gcvDB_VIDEO_MEMORY_LOCKED, + unlockVideoMemory->node)); + + /* Advance to next task. */ + size -= sizeof(gcsTASK_UNLOCK_VIDEO_MEMORY); + Task = (gcsTASK_HEADER_PTR)(unlockVideoMemory + 1); + + break; + default: + /* Skip the whole task. */ + size = 0; + break; + } + } + while(size); + + return gcvSTATUS_OK; +} /******************************************************************************\ ********************************* Task Scheduling ****************************** @@ -701,6 +786,8 @@ _ScheduleTasks( { gcsTASK_HEADER_PTR taskHeader = (gcsTASK_HEADER_PTR) (userTask + 1); + gcmkVERIFY_OK(_RemoveRecordFromProcesDB(Command, taskHeader)); + gcmkTRACE_ZONE( gcvLEVEL_VERBOSE, gcvZONE_COMMAND, " task ID = %d, size = %d\n", @@ -3363,6 +3450,8 @@ gckVGCOMMAND_Commit( break; } #endif + gcmkERR_BREAK(_FlushMMU(Command)); + do { /* Assign a context ID if not yet assigned. */ diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c index d94d8e2d6704..9dbb9d3cab25 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_db.c @@ -1144,6 +1144,12 @@ gckKERNEL_DestroyProcessDB( break; case gcvDB_NON_PAGED: + /* Unmap user logical memory first. */ + status = gckOS_UnmapUserLogical(Kernel->os, + record->physical, + record->bytes, + record->data); + /* Free the non paged memory. */ status = gckOS_FreeNonPagedMemory(Kernel->os, record->bytes, @@ -1156,11 +1162,18 @@ gckKERNEL_DestroyProcessDB( break; case gcvDB_CONTIGUOUS: + /* Unmap user logical memory first. */ + status = gckOS_UnmapUserLogical(Kernel->os, + record->physical, + record->bytes, + record->data); + /* Free the contiguous memory. */ - status = gckOS_FreeContiguous(Kernel->os, - record->physical, - record->data, - record->bytes); + status = gckEVENT_FreeContiguousMemory(Kernel->eventObj, + record->bytes, + record->physical, + record->data, + gcvKERNEL_PIXEL); gcmkTRACE_ZONE(gcvLEVEL_WARNING, gcvZONE_DATABASE, "DB: CONTIGUOUS 0x%x bytes=%lu (status=%d)", diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_event.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_event.c index e1b21a0df70b..d38312d3bf9b 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_event.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_event.c @@ -328,6 +328,12 @@ __RemoveRecordFromProcessDB( Record->info.u.UnmapUserMemory.info)); break; + case gcvHAL_SIGNAL: + gcmkVERIFY_OK(gckOS_SignalSetHardware(Event->os, + Record->info.u.Signal.signal, + Event->kernel->hardware)); + break; + default: break; } @@ -338,6 +344,15 @@ __RemoveRecordFromProcessDB( return gcvSTATUS_OK; } +void +_SubmitTimerFunction( + gctPOINTER Data + ) +{ + gckEVENT event = (gckEVENT)Data; + gcmkVERIFY_OK(gckEVENT_Submit(event, gcvTRUE, gcvFALSE)); +} + /******************************************************************************\ ******************************* gckEVENT API Code ******************************* \******************************************************************************/ @@ -430,6 +445,11 @@ gckEVENT_Construct( gcmkONERROR(gckOS_AtomConstruct(os, &eventObj->pending)); #endif + gcmkVERIFY_OK(gckOS_CreateTimer(os, + _SubmitTimerFunction, + (gctPOINTER)eventObj, + &eventObj->submitTimer)); + /* Return pointer to the gckEVENT object. */ *Event = eventObj; @@ -511,6 +531,12 @@ gckEVENT_Destroy( /* Verify the arguments. */ gcmkVERIFY_OBJECT(Event, gcvOBJ_EVENT); + if (Event->submitTimer != gcvNULL) + { + gcmkVERIFY_OK(gckOS_StopTimer(Event->os, Event->submitTimer)); + gcmkVERIFY_OK(gckOS_DestoryTimer(Event->os, Event->submitTimer)); + } + /* Delete the queue mutex. */ gcmkVERIFY_OK(gckOS_DeleteMutex(Event->os, Event->eventQueueMutex)); @@ -723,11 +749,6 @@ gckEVENT_GetEvent( __FUNCTION__, __LINE__ ); - /* Broadcast GPU stuck. */ - gcmkONERROR(gckOS_Broadcast(Event->os, - Event->kernel->hardware, - gcvBROADCAST_GPU_STUCK)); - /* Bail out. */ gcmkONERROR(gcvSTATUS_GPU_NOT_RESPONDING); } @@ -961,6 +982,31 @@ gckEVENT_AddList( queue->tail = record; } + /* Unmap user space logical address. + * Linux kernel does not support unmap the memory of other process any more since 3.5. + * Let's unmap memory of self process before submit the event to gpu. + * */ + switch(Interface->command) + { + case gcvHAL_FREE_NON_PAGED_MEMORY: + gcmkONERROR(gckOS_UnmapUserLogical( + Event->os, + Interface->u.FreeNonPagedMemory.physical, + Interface->u.FreeNonPagedMemory.bytes, + Interface->u.FreeNonPagedMemory.logical)); + break; + case gcvHAL_FREE_CONTIGUOUS_MEMORY: + gcmkONERROR(gckOS_UnmapUserLogical( + Event->os, + Interface->u.FreeContiguousMemory.physical, + Interface->u.FreeContiguousMemory.bytes, + Interface->u.FreeContiguousMemory.logical)); + break; + default: + break; + } + + /* Release the mutex. */ gcmkONERROR(gckOS_ReleaseMutex(Event->os, Event->eventListMutex)); @@ -1494,6 +1540,14 @@ OnError: Event->queues[id].head = gcvNULL; } + if (status == gcvSTATUS_GPU_NOT_RESPONDING) + { + /* Broadcast GPU stuck. */ + status = gckOS_Broadcast(Event->os, + Event->kernel->hardware, + gcvBROADCAST_GPU_STUCK); + } + /* Return the status. */ gcmkFOOTER(); return status; diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c index f7a70ac96f58..9012599b1bef 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu.c @@ -79,6 +79,23 @@ static gcsSharedPageTable_PTR sharedPageTable = gcvNULL; #endif static gceSTATUS +_FillPageTable( + IN gctUINT32_PTR PageTable, + IN gctUINT32 PageCount, + IN gctUINT32 EntryValue +) +{ + gctUINT i; + + for (i = 0; i < PageCount; i++) + { + PageTable[i] = EntryValue; + } + + return gcvSTATUS_OK; +} + +static gceSTATUS _Link( IN gckMMU Mmu, IN gctUINT32 Index, @@ -1036,7 +1053,7 @@ gckMMU_AllocatePages( } /* Mark node as used. */ - pageTable[index] = gcvMMU_USED; + gcmkONERROR(_FillPageTable(&pageTable[index], PageCount, gcvMMU_USED)); /* Return pointer to page table. */ *PageTable = &pageTable[index]; @@ -1112,6 +1129,8 @@ gckMMU_FreePages( ) { gctUINT32_PTR pageTable; + gceSTATUS status; + gctBOOL acquired = gcvFALSE; gcmkHEADER_ARG("Mmu=0x%x PageTable=0x%x PageCount=%lu", Mmu, PageTable, PageCount); @@ -1124,7 +1143,11 @@ gckMMU_FreePages( /* Convert the pointer. */ pageTable = (gctUINT32_PTR) PageTable; + gcmkONERROR(gckOS_AcquireMutex(Mmu->os, Mmu->pageTableMutex, gcvINFINITE)); + acquired = gcvTRUE; + #if gcdMMU_CLEAR_VALUE + if (Mmu->hardware->mmuVersion == 0) { gctUINT32 i; @@ -1150,9 +1173,21 @@ gckMMU_FreePages( /* We have free nodes. */ Mmu->freeNodes = gcvTRUE; + gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->pageTableMutex)); + acquired = gcvFALSE; + /* Success. */ gcmkFOOTER_NO(); return gcvSTATUS_OK; + +OnError: + if (acquired) + { + gcmkVERIFY_OK(gckOS_ReleaseMutex(Mmu->os, Mmu->pageTableMutex)); + } + + gcmkFOOTER(); + return status; } gceSTATUS diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu_vg.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu_vg.c index a4a5e0c802f5..46d1761dac2c 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu_vg.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_mmu_vg.c @@ -344,9 +344,6 @@ gceSTATUS gckVGMMU_AllocatePages( if (!allocated) { - /* Flush the MMU. */ - status = gckVGHARDWARE_FlushMMU(Mmu->hardware); - if (status >= 0) { /* Walk all entries until we find enough slots. */ @@ -506,4 +503,22 @@ gckVGMMU_SetPage( return gcvSTATUS_OK; } +gceSTATUS +gckVGMMU_Flush( + IN gckVGMMU Mmu + ) +{ + gckVGHARDWARE hardware; + + gcmkHEADER_ARG("Mmu=0x%x", Mmu); + + hardware = Mmu->hardware; + gcmkVERIFY_OK( + gckOS_AtomSet(hardware->os, hardware->pageTableDirty, 1)); + + /* Success. */ + gcmkFOOTER_NO(); + return gcvSTATUS_OK; +} + #endif /* gcdENABLE_VG */ diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_vg.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_vg.c index bb5330c2bbb0..ee63e9b59373 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_vg.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_vg.c @@ -438,6 +438,14 @@ gceSTATUS gckVGKERNEL_Dispatch( break; case gcvHAL_FREE_NON_PAGED_MEMORY: + /* Unmap user logical out of physical memory first. */ + gcmkERR_BREAK(gckOS_UnmapUserLogical( + Kernel->os, + kernelInterface->u.AllocateNonPagedMemory.physical, + kernelInterface->u.AllocateNonPagedMemory.bytes, + kernelInterface->u.AllocateNonPagedMemory.logical + )); + /* Free non-paged memory. */ gcmkERR_BREAK(gckOS_FreeNonPagedMemory( Kernel->os, @@ -459,6 +467,14 @@ gceSTATUS gckVGKERNEL_Dispatch( break; case gcvHAL_FREE_CONTIGUOUS_MEMORY: + /* Unmap user logical out of physical memory first. */ + gcmkERR_BREAK(gckOS_UnmapUserLogical( + Kernel->os, + kernelInterface->u.AllocateNonPagedMemory.physical, + kernelInterface->u.AllocateNonPagedMemory.bytes, + kernelInterface->u.AllocateNonPagedMemory.logical + )); + /* Free contiguous memory. */ gcmkERR_BREAK(gckOS_FreeContiguous( Kernel->os, @@ -522,6 +538,14 @@ gceSTATUS gckVGKERNEL_Dispatch( kernelInterface->u.AllocateLinearVideoMemory.type, &kernelInterface->u.AllocateLinearVideoMemory.node )); + + gcmkERR_BREAK(gckKERNEL_AddProcessDB(Kernel, + processID, gcvDB_VIDEO_MEMORY, + Interface->u.AllocateLinearVideoMemory.node, + gcvNULL, + kernelInterface->u.AllocateLinearVideoMemory.bytes + )); + break; case gcvHAL_FREE_VIDEO_MEMORY: @@ -544,6 +568,13 @@ gceSTATUS gckVGKERNEL_Dispatch( gcmkERR_BREAK(gckVIDMEM_Free( Interface->u.FreeVideoMemory.node )); + + gcmkERR_BREAK(gckKERNEL_RemoveProcessDB( + Kernel, + processID, gcvDB_VIDEO_MEMORY, + Interface->u.FreeVideoMemory.node + )); + break; case gcvHAL_MAP_MEMORY: @@ -637,6 +668,12 @@ gceSTATUS gckVGKERNEL_Dispatch( Interface->u.LockVideoMemory.address = gcmPTR2INT(Interface->u.LockVideoMemory.memory); #endif + gcmkERR_BREAK( + gckKERNEL_AddProcessDB(Kernel, + processID, gcvDB_VIDEO_MEMORY_LOCKED, + Interface->u.LockVideoMemory.node, + gcvNULL, + 0)); break; case gcvHAL_UNLOCK_VIDEO_MEMORY: @@ -674,6 +711,16 @@ gceSTATUS gckVGKERNEL_Dispatch( bytes)); } #endif + + if (Interface->u.UnlockVideoMemory.asynchroneous == gcvFALSE) + { + /* There isn't a event to unlock this node, remove record now */ + gcmkERR_BREAK( + gckKERNEL_RemoveProcessDB(Kernel, + processID, gcvDB_VIDEO_MEMORY_LOCKED, + Interface->u.UnlockVideoMemory.node)); + } + break; case gcvHAL_USER_SIGNAL: #if !USE_NEW_LINUX_SIGNAL diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c index 9d6da636755c..dc39b3927fff 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c +++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c @@ -1830,7 +1830,11 @@ gckVIDMEM_Lock( #endif #if gcdENABLE_VG - if (Kernel->core != gcvCORE_VG) + if (Kernel->core == gcvCORE_VG) + { + gcmkONERROR(gckVGMMU_Flush(Kernel->vg->mmu)); + } + else #endif { gcmkONERROR(gckMMU_Flush(Kernel->mmu)); diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal.h index 25ec3eab95f2..5bf887054e04 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal.h @@ -30,6 +30,9 @@ #include "gc_hal_base.h" #include "gc_hal_profiler.h" #include "gc_hal_driver.h" +#ifndef VIVANTE_NO_3D +#include "gc_hal_statistics.h" +#endif #ifdef __cplusplus extern "C" { @@ -503,6 +506,17 @@ gckOS_UnmapMemory( IN gctPOINTER Logical ); +/* Unmap user logical memory out of physical memory. + * This function is only supported in Linux currently. + */ +gceSTATUS +gckOS_UnmapUserLogical( + IN gckOS Os, + IN gctPHYS_ADDR Physical, + IN gctSIZE_T Bytes, + IN gctPOINTER Logical + ); + /* Create a new mutex. */ gceSTATUS gckOS_CreateMutex( @@ -1950,6 +1964,22 @@ gckHARDWARE_QueryPowerManagementState( OUT gceCHIPPOWERSTATE* State ); +#if gcdENABLE_FSCALE_VAL_ADJUST +gceSTATUS +gckHARDWARE_SetFscaleValue( + IN gckHARDWARE Hardware, + IN gctUINT32 FscaleValue + ); + +gceSTATUS +gckHARDWARE_GetFscaleValue( + IN gckHARDWARE Hardware, + IN gctUINT * FscaleValue, + IN gctUINT * MinFscaleValue, + IN gctUINT * MaxFscaleValue + ); +#endif + #if gcdPOWEROFF_TIMEOUT gceSTATUS gckHARDWARE_SetPowerOffTimeout( @@ -2361,7 +2391,19 @@ gckHARDWARE_QueryProfileRegisters( ); #endif +gceSTATUS +gckOS_SignalQueryHardware( + IN gckOS Os, + IN gctSIGNAL Signal, + OUT gckHARDWARE * Hardware + ); +gceSTATUS +gckOS_SignalSetHardware( + IN gckOS Os, + IN gctSIGNAL Signal, + gckHARDWARE Hardware + ); #ifdef __cplusplus } diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_base.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_base.h index 85b41312f772..7cfd2e119f00 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_base.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_base.h @@ -747,6 +747,25 @@ gcoOS_FreeContiguous( IN gctSIZE_T Bytes ); +/* Allocate video memory. */ +gceSTATUS +gcoOS_AllocateVideoMemory( + IN gcoOS Os, + IN gctBOOL InUserSpace, + IN gctBOOL InCacheable, + IN OUT gctSIZE_T * Bytes, + OUT gctUINT32 * Physical, + OUT gctPOINTER * Logical, + OUT gctPOINTER * Handle + ); + +/* Free video memory. */ +gceSTATUS +gcoOS_FreeVideoMemory( + IN gcoOS Os, + IN gctPOINTER Handle + ); + #if gcdENABLE_BANK_ALIGNMENT gceSTATUS gcoSURF_GetBankOffsetBytes( @@ -3659,6 +3678,42 @@ gckOS_DebugStatus2Name( #define MAX_LOOP_COUNT 0x7FFFFFFF +/******************************************************************************\ +****************************** User Debug Option ****************************** +\******************************************************************************/ + +/* User option. */ +typedef enum _gceDEBUG_MSG +{ + gcvDEBUG_MSG_NONE, + gcvDEBUG_MSG_ERROR, + gcvDEBUG_MSG_WARNING +} +gceDEBUG_MSG; + +typedef struct _gcsUSER_DEBUG_OPTION +{ + gceDEBUG_MSG debugMsg; +} +gcsUSER_DEBUG_OPTION; + +gcsUSER_DEBUG_OPTION * +gcGetUserDebugOption( + void + ); + +#define gcmUSER_DEBUG_MSG(level, ...) \ + do \ + { \ + if (level <= gcGetUserDebugOption()->debugMsg) \ + { \ + gcoOS_Print(__VA_ARGS__); \ + } \ + } while (gcvFALSE) + +#define gcmUSER_DEBUG_ERROR_MSG(...) gcmUSER_DEBUG_MSG(gcvDEBUG_MSG_ERROR, "Error: " __VA_ARGS__) +#define gcmUSER_DEBUG_WARNING_MSG(...) gcmUSER_DEBUG_MSG(gcvDEBUG_MSG_WARNING, "Warring: " __VA_ARGS__) + #ifdef __cplusplus } #endif diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform.h index d0a98a2b71c8..86ab105b389a 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform.h @@ -27,216 +27,11 @@ /* Include VDK types. */ #include "gc_hal_types.h" #include "gc_hal_base.h" +#include "gc_hal_eglplatform_type.h" #ifdef __cplusplus extern "C" { #endif -/******************************************************************************* -** Events. ********************************************************************* -*/ - -typedef enum _halEventType -{ - /* Keyboard event. */ - HAL_KEYBOARD, - - /* Mouse move event. */ - HAL_POINTER, - - /* Mouse button event. */ - HAL_BUTTON, - - /* Application close event. */ - HAL_CLOSE, - - /* Application window has been updated. */ - HAL_WINDOW_UPDATE -} -halEventType; - -/* Scancodes for keyboard. */ -typedef enum _halKeys -{ - HAL_UNKNOWN = -1, - - HAL_BACKSPACE = 0x08, - HAL_TAB, - HAL_ENTER = 0x0D, - HAL_ESCAPE = 0x1B, - - HAL_SPACE = 0x20, - HAL_SINGLEQUOTE = 0x27, - HAL_PAD_ASTERISK = 0x2A, - HAL_COMMA = 0x2C, - HAL_HYPHEN, - HAL_PERIOD, - HAL_SLASH, - HAL_0, - HAL_1, - HAL_2, - HAL_3, - HAL_4, - HAL_5, - HAL_6, - HAL_7, - HAL_8, - HAL_9, - HAL_SEMICOLON = 0x3B, - HAL_EQUAL = 0x3D, - HAL_A = 0x41, - HAL_B, - HAL_C, - HAL_D, - HAL_E, - HAL_F, - HAL_G, - HAL_H, - HAL_I, - HAL_J, - HAL_K, - HAL_L, - HAL_M, - HAL_N, - HAL_O, - HAL_P, - HAL_Q, - HAL_R, - HAL_S, - HAL_T, - HAL_U, - HAL_V, - HAL_W, - HAL_X, - HAL_Y, - HAL_Z, - HAL_LBRACKET, - HAL_BACKSLASH, - HAL_RBRACKET, - HAL_BACKQUOTE = 0x60, - - HAL_F1 = 0x80, - HAL_F2, - HAL_F3, - HAL_F4, - HAL_F5, - HAL_F6, - HAL_F7, - HAL_F8, - HAL_F9, - HAL_F10, - HAL_F11, - HAL_F12, - - HAL_LCTRL, - HAL_RCTRL, - HAL_LSHIFT, - HAL_RSHIFT, - HAL_LALT, - HAL_RALT, - HAL_CAPSLOCK, - HAL_NUMLOCK, - HAL_SCROLLLOCK, - HAL_PAD_0, - HAL_PAD_1, - HAL_PAD_2, - HAL_PAD_3, - HAL_PAD_4, - HAL_PAD_5, - HAL_PAD_6, - HAL_PAD_7, - HAL_PAD_8, - HAL_PAD_9, - HAL_PAD_HYPHEN, - HAL_PAD_PLUS, - HAL_PAD_SLASH, - HAL_PAD_PERIOD, - HAL_PAD_ENTER, - HAL_SYSRQ, - HAL_PRNTSCRN, - HAL_BREAK, - HAL_UP, - HAL_LEFT, - HAL_RIGHT, - HAL_DOWN, - HAL_HOME, - HAL_END, - HAL_PGUP, - HAL_PGDN, - HAL_INSERT, - HAL_DELETE, - HAL_LWINDOW, - HAL_RWINDOW, - HAL_MENU, - HAL_POWER, - HAL_SLEEP, - HAL_WAKE -} -halKeys; - -/* Structure that defined keyboard mapping. */ -typedef struct _halKeyMap -{ - /* Normal key. */ - halKeys normal; - - /* Extended key. */ - halKeys extended; -} -halKeyMap; - -/* Event structure. */ -typedef struct _halEvent -{ - /* Event type. */ - halEventType type; - - /* Event data union. */ - union _halEventData - { - /* Event data for keyboard. */ - struct _halKeyboard - { - /* Scancode. */ - halKeys scancode; - - /* ASCII characte of the key pressed. */ - gctCHAR key; - - /* Flag whether the key was pressed (1) or released (0). */ - gctCHAR pressed; - } - keyboard; - - /* Event data for pointer. */ - struct _halPointer - { - /* Current pointer coordinate. */ - gctINT x; - gctINT y; - } - pointer; - - /* Event data for mouse buttons. */ - struct _halButton - { - /* Left button state. */ - gctINT left; - - /* Middle button state. */ - gctINT middle; - - /* Right button state. */ - gctINT right; - - /* Current pointer coordinate. */ - gctINT x; - gctINT y; - } - button; - } - data; -} -halEvent; #if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and Windows CE platforms. */ @@ -379,7 +174,16 @@ typedef void * HALNativePixmapType; #endif - +/* define DUMMY according to the system */ +#if defined(EGL_API_WL) +# define WL_DUMMY (31415926) +# define EGL_DUMMY WL_DUMMY +#elif defined(__ANDROID__) || defined(ANDROID) +# define ANDROID_DUMMY (31415926) +# define EGL_DUMMY ANDROID_DUMMY +#else +# define EGL_DUMMY (31415926) +#endif /******************************************************************************* ** Display. ******************************************************************** @@ -408,51 +212,7 @@ gcoOS_GetDisplayInfo( OUT gctINT * BitsPerPixel ); -/* VFK_DISPLAY_INFO structure defining information returned by - vdkGetDisplayInfoEx. */ -typedef struct _halDISPLAY_INFO -{ - /* The size of the display in pixels. */ - gctINT width; - gctINT height; - - /* The stride of the dispay. -1 is returned if the stride is not known - ** for the specified display.*/ - gctINT stride; - - /* The color depth of the display in bits per pixel. */ - gctINT bitsPerPixel; - /* The logical pointer to the display memory buffer. NULL is returned - ** if the pointer is not known for the specified display. */ - gctPOINTER logical; - - /* The physical address of the display memory buffer. ~0 is returned - ** if the address is not known for the specified display. */ - gctSIZE_T physical; - - gctBOOL wrapFB; /* true if compositor, false otherwise. */ - -#ifndef __QNXNTO__ - /* 355_FB_MULTI_BUFFER */ - gctINT multiBuffer; - gctINT backBufferY; -#endif - - /* The color info of the display. */ - gctUINT alphaLength; - gctUINT alphaOffset; - gctUINT redLength; - gctUINT redOffset; - gctUINT greenLength; - gctUINT greenOffset; - gctUINT blueLength; - gctUINT blueOffset; - - /* Display flip support. */ - gctINT flip; -} -halDISPLAY_INFO; gceSTATUS gcoOS_GetDisplayInfoEx( @@ -498,6 +258,19 @@ gcoOS_SetDisplayVirtual( ); gceSTATUS +gcoOS_SetSwapInterval( + IN HALNativeDisplayType Display, + IN gctINT Interval +); + +gceSTATUS +gcoOS_GetSwapInterval( + IN HALNativeDisplayType Display, + IN gctINT_PTR Min, + IN gctINT_PTR Max +); + +gceSTATUS gcoOS_DisplayBufferRegions( IN HALNativeDisplayType Display, IN HALNativeWindowType Window, @@ -779,7 +552,48 @@ gcoOS_DestroyClientBuffer( IN gctPOINTER ClientBuffer ); +gceSTATUS +gcoOS_DestroyContext( + IN gctPOINTER Display, + IN gctPOINTER Context + ); +gceSTATUS +gcoOS_CreateContext( + IN gctPOINTER LocalDisplay, + IN gctPOINTER Context + ); + +gceSTATUS +gcoOS_MakeCurrent( + IN gctPOINTER LocalDisplay, + IN HALNativeWindowType DrawDrawable, + IN HALNativeWindowType ReadDrawable, + IN gctPOINTER Context, + IN gcoSURF ResolveTarget + ); + +gceSTATUS +gcoOS_CreateDrawable( + IN gctPOINTER LocalDisplay, + IN HALNativeWindowType Drawable + ); + +gceSTATUS +gcoOS_DestroyDrawable( + IN gctPOINTER LocalDisplay, + IN HALNativeWindowType Drawable + ); +gceSTATUS +gcoOS_SwapBuffers( + IN gctPOINTER LocalDisplay, + IN HALNativeWindowType Drawable, + IN gcoSURF RenderTarget, + IN gcoSURF ResolveTarget, + IN gctPOINTER ResolveBits, + OUT gctUINT *Width, + OUT gctUINT *Height + ); #ifdef __cplusplus } #endif diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform_type.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform_type.h new file mode 100644 index 000000000000..727758f4d39f --- /dev/null +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_eglplatform_type.h @@ -0,0 +1,287 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2012 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + +#ifndef __gc_hal_eglplatform_type_h_ +#define __gc_hal_eglplatform_type_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************* +** Events. ********************************************************************* +*/ + +typedef enum _halEventType +{ + /* Keyboard event. */ + HAL_KEYBOARD, + + /* Mouse move event. */ + HAL_POINTER, + + /* Mouse button event. */ + HAL_BUTTON, + + /* Application close event. */ + HAL_CLOSE, + + /* Application window has been updated. */ + HAL_WINDOW_UPDATE +} +halEventType; + +/* Scancodes for keyboard. */ +typedef enum _halKeys +{ + HAL_UNKNOWN = -1, + + HAL_BACKSPACE = 0x08, + HAL_TAB, + HAL_ENTER = 0x0D, + HAL_ESCAPE = 0x1B, + + HAL_SPACE = 0x20, + HAL_SINGLEQUOTE = 0x27, + HAL_PAD_ASTERISK = 0x2A, + HAL_COMMA = 0x2C, + HAL_HYPHEN, + HAL_PERIOD, + HAL_SLASH, + HAL_0, + HAL_1, + HAL_2, + HAL_3, + HAL_4, + HAL_5, + HAL_6, + HAL_7, + HAL_8, + HAL_9, + HAL_SEMICOLON = 0x3B, + HAL_EQUAL = 0x3D, + HAL_A = 0x41, + HAL_B, + HAL_C, + HAL_D, + HAL_E, + HAL_F, + HAL_G, + HAL_H, + HAL_I, + HAL_J, + HAL_K, + HAL_L, + HAL_M, + HAL_N, + HAL_O, + HAL_P, + HAL_Q, + HAL_R, + HAL_S, + HAL_T, + HAL_U, + HAL_V, + HAL_W, + HAL_X, + HAL_Y, + HAL_Z, + HAL_LBRACKET, + HAL_BACKSLASH, + HAL_RBRACKET, + HAL_BACKQUOTE = 0x60, + + HAL_F1 = 0x80, + HAL_F2, + HAL_F3, + HAL_F4, + HAL_F5, + HAL_F6, + HAL_F7, + HAL_F8, + HAL_F9, + HAL_F10, + HAL_F11, + HAL_F12, + + HAL_LCTRL, + HAL_RCTRL, + HAL_LSHIFT, + HAL_RSHIFT, + HAL_LALT, + HAL_RALT, + HAL_CAPSLOCK, + HAL_NUMLOCK, + HAL_SCROLLLOCK, + HAL_PAD_0, + HAL_PAD_1, + HAL_PAD_2, + HAL_PAD_3, + HAL_PAD_4, + HAL_PAD_5, + HAL_PAD_6, + HAL_PAD_7, + HAL_PAD_8, + HAL_PAD_9, + HAL_PAD_HYPHEN, + HAL_PAD_PLUS, + HAL_PAD_SLASH, + HAL_PAD_PERIOD, + HAL_PAD_ENTER, + HAL_SYSRQ, + HAL_PRNTSCRN, + HAL_BREAK, + HAL_UP, + HAL_LEFT, + HAL_RIGHT, + HAL_DOWN, + HAL_HOME, + HAL_END, + HAL_PGUP, + HAL_PGDN, + HAL_INSERT, + HAL_DELETE, + HAL_LWINDOW, + HAL_RWINDOW, + HAL_MENU, + HAL_POWER, + HAL_SLEEP, + HAL_WAKE +} +halKeys; + +/* Structure that defined keyboard mapping. */ +typedef struct _halKeyMap +{ + /* Normal key. */ + halKeys normal; + + /* Extended key. */ + halKeys extended; +} +halKeyMap; + +/* Event structure. */ +typedef struct _halEvent +{ + /* Event type. */ + halEventType type; + + /* Event data union. */ + union _halEventData + { + /* Event data for keyboard. */ + struct _halKeyboard + { + /* Scancode. */ + halKeys scancode; + + /* ASCII characte of the key pressed. */ + char key; + + /* Flag whether the key was pressed (1) or released (0). */ + char pressed; + } + keyboard; + + /* Event data for pointer. */ + struct _halPointer + { + /* Current pointer coordinate. */ + int x; + int y; + } + pointer; + + /* Event data for mouse buttons. */ + struct _halButton + { + /* Left button state. */ + int left; + + /* Middle button state. */ + int middle; + + /* Right button state. */ + int right; + + /* Current pointer coordinate. */ + int x; + int y; + } + button; + } + data; +} +halEvent; + +/* VFK_DISPLAY_INFO structure defining information returned by + vdkGetDisplayInfoEx. */ +typedef struct _halDISPLAY_INFO +{ + /* The size of the display in pixels. */ + int width; + int height; + + /* The stride of the dispay. -1 is returned if the stride is not known + ** for the specified display.*/ + int stride; + + /* The color depth of the display in bits per pixel. */ + int bitsPerPixel; + + /* The logical pointer to the display memory buffer. NULL is returned + ** if the pointer is not known for the specified display. */ + void * logical; + + /* The physical address of the display memory buffer. ~0 is returned + ** if the address is not known for the specified display. */ + unsigned long physical; + + int wrapFB; /* true if compositor, false otherwise. */ + +#ifndef __QNXNTO__ + /* 355_FB_MULTI_BUFFER */ + int multiBuffer; + int backBufferY; +#endif + + /* The color info of the display. */ + unsigned int alphaLength; + unsigned int alphaOffset; + unsigned int redLength; + unsigned int redOffset; + unsigned int greenLength; + unsigned int greenOffset; + unsigned int blueLength; + unsigned int blueOffset; + + /* Display flip support. */ + int flip; +} +halDISPLAY_INFO; + +#ifdef __cplusplus +} +#endif + +#endif /* __gc_hal_eglplatform_type_h_ */ diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_engine.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_engine.h index c7543072f349..7400b3201b91 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_engine.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_engine.h @@ -871,6 +871,19 @@ gco3D_SetAllEarlyDepthModes( IN gctBOOL Disable ); +/* Switch dynamic early mode */ +gceSTATUS +gco3D_SwitchDynamicEarlyDepthMode( + IN gco3D Engine + ); + +/* Set dynamic early mode */ +gceSTATUS +gco3D_DisableDynamicEarlyDepthMode( + IN gco3D Engine, + IN gctBOOL Disable + ); + /* Enable or disable depth-only mode. */ gceSTATUS gco3D_SetDepthOnly( @@ -1450,6 +1463,21 @@ gcoTEXTURE_UploadCompressed( IN gctSIZE_T Bytes ); +/* Upload compressed sub data to an gcoTEXTURE object. */ +gceSTATUS +gcoTEXTURE_UploadCompressedSub( + IN gcoTEXTURE Texture, + IN gctUINT MipMap, + IN gceTEXTURE_FACE Face, + IN gctUINT XOffset, + IN gctUINT YOffset, + IN gctUINT Width, + IN gctUINT Height, + IN gctUINT Slice, + IN gctCONST_POINTER Memory, + IN gctSIZE_T Size + ); + /* Get gcoSURF object for a mipmap level. */ gceSTATUS gcoTEXTURE_GetMipMap( @@ -1780,6 +1808,16 @@ gcoVERTEXARRAY_Bind( IN OUT gctUINT * PrimitiveCount ); +gctUINT +gcoVERTEXARRAY_GetMaxStream( + IN gcoVERTEXARRAY Vertex +); + +gceSTATUS +gcoVERTEXARRAY_SetMaxStream( + IN gcoVERTEXARRAY Vertex, + gctUINT maxStreams +); /******************************************************************************* ***** Composition *************************************************************/ diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_enum.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_enum.h index b2e36a258da8..d951c3a965d9 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_enum.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_enum.h @@ -209,10 +209,14 @@ typedef enum _gceSURF_TYPE #if gcdANDROID_UNALIGNED_LINEAR_COMPOSITION_ADJUST gcvSURF_FLIP = 0x800, /* The Resolve Target the will been flip resolve from RT */ #endif + gcvSURF_TILE_STATUS_DIRTY = 0x1000, /* Init tile status to all dirty */ gcvSURF_RENDER_TARGET_NO_TILE_STATUS = gcvSURF_RENDER_TARGET | gcvSURF_NO_TILE_STATUS, + gcvSURF_RENDER_TARGET_TS_DIRTY = gcvSURF_RENDER_TARGET + | gcvSURF_TILE_STATUS_DIRTY, + gcvSURF_DEPTH_NO_TILE_STATUS = gcvSURF_DEPTH | gcvSURF_NO_TILE_STATUS, @@ -646,6 +650,12 @@ typedef enum _gce2D_QUERY } gce2D_QUERY; +typedef enum _gce2D_STATE +{ + gcv2D_STATE_SPECIAL_FILTER_MIRROR_MODE = 1, +} +gce2D_STATE; + #ifndef VIVANTE_NO_3D /* Texture functions. */ typedef enum _gceTEXTURE_FUNCTION diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h index d1ddd004dc3c..33fddfbbfed2 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_options.h @@ -161,6 +161,14 @@ #endif /* + gcdENABLE_FSCALE_VAL_ADJUST + When non-zero, FSCALE_VAL when gcvPOWER_ON can be adjusted externally. + */ +#ifndef gcdENABLE_FSCALE_VAL_ADJUST +# define gcdENABLE_FSCALE_VAL_ADJUST 1 +#endif + +/* gcdDUMP_IN_KERNEL When set to 1, all dumps will happen in the kernel. This is handy if @@ -765,7 +773,7 @@ limited by gcdCONTIGUOUS_SIZE_LIMIT. */ #ifndef gcdCONTIGUOUS_SIZE_LIMIT -# define gcdCONTIGUOUS_SIZE_LIMIT 0 +# define gcdCONTIGUOUS_SIZE_LIMIT 4096 #endif /* gcdALPHA_KILL_IN_SHADER diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_raster.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_raster.h index 53e9cc6e760b..e3ceadfce7ee 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_raster.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_raster.h @@ -950,6 +950,13 @@ gco2D_QueryU32( OUT gctUINT32_PTR Value ); +gceSTATUS +gco2D_SetStateU32( + IN gco2D Engine, + IN gce2D_STATE State, + IN OUT gctUINT32_PTR Value + ); + #ifdef __cplusplus } #endif diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_statistics.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_statistics.h new file mode 100644 index 000000000000..1e85458625e7 --- /dev/null +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_statistics.h @@ -0,0 +1,116 @@ +/**************************************************************************** +* +* Copyright (C) 2005 - 2012 by Vivante Corp. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the license, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +* +*****************************************************************************/ + + + +#ifndef __gc_hal_statistics_h_ +#define __gc_hal_statistics_h_ + + +#define VIV_STAT_ENABLE_STATISTICS 0 + +/* Toal number of frames for which the frame time is accounted. We have storage + to keep frame times for last this many frames. +*/ +#define VIV_STAT_FRAME_BUFFER_SIZE 30 + +/* + Total number of frames sampled for a mode. This means + + # of frames for HZ Current : VIV_STAT_EARLY_Z_SAMPLE_FRAMES + # of frames for HZ Switched : VIV_STAT_EARLY_Z_SAMPLE_FRAMES + + + -------------------------------------------------------- + : (2 * VIV_STAT_EARLY_Z_SAMPLE_FRAMES) frames needed + + IMPORTANT: This total must be smaller than VIV_STAT_FRAME_BUFFER_SIZE +*/ +#define VIV_STAT_EARLY_Z_SAMPLE_FRAMES 7 +#define VIV_STAT_EARLY_Z_LATENCY_FRAMES 2 + +/* Multiplication factor for previous Hz off mode. Make it more than 1.0 to advertise HZ on.*/ +#define VIV_STAT_EARLY_Z_FACTOR (1.05f) + +/* Defines the statistical data keys monitored by the statistics module */ +typedef enum _gceSTATISTICS +{ + gcvFRAME_FPS = 1, +} +gceSTATISTICS; + +/* HAL statistics information. */ +typedef struct _gcsSTATISTICS_EARLYZ +{ + gctUINT switchBackCount; + gctUINT nextCheckPoint; + gctBOOL disabled; +} +gcsSTATISTICS_EARLYZ; + + +/* Defines the statistical data keys monitored by the statistics module */ +typedef enum _gceSTATISTICS_Call +{ + gcvSTAT_ES11_GLDRAWELEMENTS = 1, +} +gceSTATISTICS_Call; + + +/* HAL statistics information. */ +typedef struct _gcsSTATISTICS +{ + gctUINT64 frameTime[VIV_STAT_FRAME_BUFFER_SIZE]; + gctUINT64 previousFrameTime; + gctUINT frame; + gcsSTATISTICS_EARLYZ earlyZ; + gctUINT ES11_drawElementsCount; + gctBOOL applyRTestVAFix; +} +gcsSTATISTICS; + + +/* Add a frame based data into current statistics. */ +void +gcfSTATISTICS_AddData( + IN gceSTATISTICS Key, + IN gctUINT Value + ); + +/* Marks the frame end and triggers statistical calculations and decisions.*/ +void +gcfSTATISTICS_MarkFrameEnd ( + void + ); + +/* Sets whether the dynmaic HZ is disabled or not .*/ +void +gcfSTATISTICS_DisableDynamicEarlyZ ( + IN gctBOOL Disabled + ); + +/* Checks whether or not glDrawArray function call will be discarded */ +gctBOOL +gcfSTATISTICS_DiscardCall( + gceSTATISTICS_Call Function + ); + + +#endif /*__gc_hal_statistics_h_ */ + diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_types.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_types.h index e9ad6f611820..4e063776cd44 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_types.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_types.h @@ -285,6 +285,8 @@ typedef enum _gceSTATUS gcvSTATUS_EXECUTED = 18, gcvSTATUS_TERMINATE = 19, + gcvSTATUS_CONVERT_TO_SINGLE_STREAM = 20, + gcvSTATUS_INVALID_ARGUMENT = -1, gcvSTATUS_INVALID_OBJECT = -2, gcvSTATUS_OUT_OF_MEMORY = -3, diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_vg.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_vg.h index 372c8ac7817f..87311376e640 100644 --- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_vg.h +++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_vg.h @@ -895,6 +895,12 @@ gckVGMMU_SetPage( IN gctUINT32 *PageEntry ); +/* Flush MMU */ +gceSTATUS +gckVGMMU_Flush( + IN gckVGMMU Mmu + ); + #endif /* gcdENABLE_VG */ #ifdef __cplusplus |