/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
+
+
+
+
#include "gc_hal.h"
#include "gc_hal_kernel.h"
gcmkONERROR(gckHARDWARE_SetFastClear(hardware, -1, -1));
/* Set power state to ON. */
- hardware->chipPowerState = gcvPOWER_ON;
+ hardware->chipPowerState = gcvPOWER_ON;
+ hardware->broadcast = gcvFALSE;
+ hardware->settingPowerState = gcvFALSE;
+
hardware->lastWaitLink = ~0U;
gcmkONERROR(gckOS_CreateMutex(Os, &hardware->powerMutex));
gckCOMMAND command = gcvNULL;
gckOS os;
gctUINT flag, clock;
-#if 0 // dkm del
gctPOINTER buffer;
gctSIZE_T bytes, requested;
-#endif
gctBOOL acquired = gcvFALSE;
gctBOOL reserved = gcvFALSE;
gctBOOL mutexAcquired = gcvFALSE;
/* Convert the broadcast power state. */
switch (State)
{
+ case gcvPOWER_ON_BROADCAST:
+ /* Convert to ON and and not we are inside broadcast. */
+ State = gcvPOWER_ON;
+ stall = gcvFALSE;
+ broadcast = gcvTRUE;
+ break;
+
case gcvPOWER_SUSPEND_ATPOWERON:
/* Convert to SUSPEND and don't wait for STALL. */
State = gcvPOWER_SUSPEND;
break;
case gcvPOWER_IDLE_BROADCAST:
- /* Convert to IDLE and note we are inside breoadcast. */
+ /* Convert to IDLE and note we are inside broadcast. */
State = gcvPOWER_IDLE;
broadcast = gcvTRUE;
break;
case gcvPOWER_SUSPEND_BROADCAST:
- /* Convert to SUSPEND and note we are inside breoadcast. */
+ /* Convert to SUSPEND and note we are inside broadcast. */
State = gcvPOWER_SUSPEND;
broadcast = gcvTRUE;
break;
case gcvPOWER_OFF_BROADCAST:
- /* Convert to OFF and note we are inside breoadcast. */
+ /* Convert to OFF and note we are inside broadcast. */
State = gcvPOWER_OFF;
broadcast = gcvTRUE;
break;
case gcvPOWER_OFF_RECOVERY:
- /* Convert to OFF and note we are inside breoadcast. */
+ /* Convert to OFF and note we are inside broadcast. */
State = gcvPOWER_OFF;
stall = gcvFALSE;
broadcast = gcvTRUE;
flag = flags[Hardware->chipPowerState][State];
clock = clocks[State];
- if (flag == 0)
+ if ((flag == 0) || (Hardware->settingPowerState))
{
/* Release the power mutex. */
gcmkONERROR(gckOS_ReleaseMutex(os, Hardware->powerMutex));
return gcvSTATUS_OK;
}
+ if (broadcast && !Hardware->broadcast
+ && (Hardware->chipPowerState == gcvPOWER_OFF)
+ )
+ {
+ /* Release the power mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(os, Hardware->powerMutex));
+
+ /* No broadcast while GPU is forced power off. */
+ gcmkFOOTER_NO();
+ return gcvSTATUS_CHIP_NOT_READY;
+ }
+
+ Hardware->settingPowerState = gcvTRUE;
+
gcmkASSERT(Hardware->kernel != gcvNULL);
gcmkASSERT(Hardware->kernel->command != gcvNULL);
command = Hardware->kernel->command;
else
{
-#if 0 // dkm del
/* Get the size of the flush command. */
gcmkONERROR(gckHARDWARE_Flush(Hardware,
gcvFLUSH_ALL,
/* Wait to finish all commands. */
gcmkONERROR(gckCOMMAND_Stall(command));
-#endif
}
}
}
/* Save the new power state. */
- Hardware->chipPowerState = State;
+ Hardware->chipPowerState = State;
+ Hardware->broadcast = broadcast;
+ Hardware->settingPowerState = gcvFALSE;
/* Release the power mutex. */
gcmkONERROR(gckOS_ReleaseMutex(os, Hardware->powerMutex));
if (mutexAcquired)
{
+ Hardware->settingPowerState = gcvFALSE;
+
gcmkVERIFY_OK(gckOS_ReleaseMutex(Hardware->os, Hardware->powerMutex));
}
/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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
gctUINT32 powerProcess;
gctUINT32 powerThread;
gceCHIPPOWERSTATE chipPowerState;
+ gctBOOL broadcast;
+ gctBOOL settingPowerState;
gctUINT32 lastWaitLink;
};
/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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
gcvFEATURE_VG_DOUBLE_BUFFER,
gcvFEATURE_MC20,
gcvFEATURE_SUPER_TILED,
+ gcvFEATURE_2D_DITHER,
+ gcvFEATURE_WIDE_LINE,
}
gceFEATURE;
gcvPOWER_OFF,
gcvPOWER_IDLE,
gcvPOWER_SUSPEND,
+ gcvPOWER_ON_BROADCAST,
gcvPOWER_SUSPEND_ATPOWERON,
gcvPOWER_OFF_ATPOWERON,
gcvPOWER_IDLE_BROADCAST,
*/
#define gcdENABLE_AUTO_FREQ 0
+
+/*
+ gcdENABLE_MEM_CACHE
+
+ ÅäÖÃGPUËùʹÓõÄmemoryÊÇ·ñ±»ARM Cacheס
+*/
+#define gcdENABLE_MEM_CACHE 1
+
#endif /* __gc_hal_options_h_ */
/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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
OPTIONAL gcs2D_PROFILE_PTR Profile
);
+/* Enable or disable 2D dithering. */
+gceSTATUS
+gco2D_EnableDither(
+ IN gco2D Engine,
+ IN gctBOOL Enable
+ );
+
#ifdef __cplusplus
}
#endif
/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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
gctBOOL semaAcquired = gcvFALSE;
gctINT32 atomValue;
gctBOOL atomIncremented = gcvFALSE;
+ gctUINT32 process, thread;
gctBOOL powerAcquired = gcvFALSE;
gcmkHEADER_ARG("Command=0x%x CommandBuffer=0x%x Context=0x%x",
hardware = Command->kernel->hardware;
gcmkVERIFY_OBJECT(hardware, gcvOBJ_HARDWARE);
- /* Grab the power mutex. */
- gcmkONERROR(
- gckOS_AcquireMutex(Command->os, hardware->powerMutex, gcvINFINITE));
- powerAcquired = gcvTRUE;
+ /* Get current process and thread IDs. */
+ gcmkONERROR(gckOS_GetProcessID(&process));
+ gcmkONERROR(gckOS_GetThreadID(&thread));
+
+ /* Try to acquire the power mutex. */
+ status = gckOS_AcquireMutex(Command->os, hardware->powerMutex, 0);
+
+ if (status == gcvSTATUS_OK)
+ {
+ hardware->powerProcess = process;
+ hardware->powerThread = thread;
+ powerAcquired = gcvTRUE;
+ }
+ else if (status == gcvSTATUS_TIMEOUT)
+ {
+ /* Check if we already own this mutex. */
+ if ((hardware->powerProcess != process)
+ || (hardware->powerThread != thread)
+ )
+ {
+ /* Acquire the power mutex. */
+ gcmkONERROR(
+ gckOS_AcquireMutex(Command->os,
+ hardware->powerMutex, gcvINFINITE));
+
+ hardware->powerProcess = process;
+ hardware->powerThread = thread;
+ powerAcquired = gcvTRUE;
+ }
+ }
+ else
+ {
+ gcmkONERROR(status);
+ }
/* Increment the commit atom. */
gcmkONERROR(gckOS_AtomIncrement(Command->os,
&atomValue));
atomIncremented = gcvTRUE;
- /* Release the power mutex. */
- gcmkONERROR(gckOS_ReleaseMutex(Command->os, hardware->powerMutex));
- powerAcquired = gcvFALSE;
+ if (powerAcquired)
+ {
+ /* Release the power mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Command->os, hardware->powerMutex));
+ powerAcquired = gcvFALSE;
+ }
/* Notify the system the GPU has a commit. */
gcmkONERROR(gckOS_Broadcast(Command->os,
gctSIZE_T requiredBytes, bytes;
gctBOOL acquired = gcvFALSE;
gctBOOL semaAcquired = gcvTRUE;
+ gckHARDWARE hardware = gcvNULL;
gctINT32 atomValue;
gctBOOL atomIncremented = gcvFALSE;
+ gctUINT32 process, thread;
gctBOOL powerAcquired = gcvFALSE;
gcmkHEADER_ARG("Command=0x%x RequestedBytes=%lu", Command, RequestedBytes);
/* Verify the arguments. */
gcmkVERIFY_OBJECT(Command, gcvOBJ_COMMAND);
- /* Grab the power mutex. */
- gcmkONERROR(gckOS_AcquireMutex(Command->os,
- Command->kernel->hardware->powerMutex,
- gcvINFINITE));
- powerAcquired = gcvTRUE;
+ /* Extract the gckHARDWARE objects. */
+ hardware = Command->kernel->hardware;
+ gcmkVERIFY_OBJECT(hardware, gcvOBJ_HARDWARE);
+
+ /* Get current process and thread IDs. */
+ gcmkONERROR(gckOS_GetProcessID(&process));
+ gcmkONERROR(gckOS_GetThreadID(&thread));
+
+ /* Try to acquire the power mutex. */
+ status = gckOS_AcquireMutex(Command->os, hardware->powerMutex, 0);
+
+ if (status == gcvSTATUS_OK)
+ {
+ hardware->powerProcess = process;
+ hardware->powerThread = thread;
+ powerAcquired = gcvTRUE;
+ }
+ else if (status == gcvSTATUS_TIMEOUT)
+ {
+ /* Check if we already own this mutex. */
+ if ((hardware->powerProcess != process)
+ || (hardware->powerThread != thread)
+ )
+ {
+ /* Acquire the power mutex. */
+ gcmkONERROR(
+ gckOS_AcquireMutex(Command->os,
+ hardware->powerMutex, gcvINFINITE));
+
+ hardware->powerProcess = process;
+ hardware->powerThread = thread;
+ powerAcquired = gcvTRUE;
+ }
+ }
+ else
+ {
+ gcmkONERROR(status);
+ }
/* Increment the commit atom. */
gcmkONERROR(
gckOS_AtomIncrement(Command->os, Command->atomCommit, &atomValue));
atomIncremented = gcvTRUE;
- /* Release the power mutex. */
- gcmkONERROR(gckOS_ReleaseMutex(Command->os,
- Command->kernel->hardware->powerMutex));
- powerAcquired = gcvFALSE;
+ if (powerAcquired)
+ {
+ /* Release the power mutex. */
+ gcmkONERROR(gckOS_ReleaseMutex(Command->os,
+ Command->kernel->hardware->powerMutex));
+ powerAcquired = gcvFALSE;
+ }
/* Notify the system the GPU has a commit. */
gcmkONERROR(gckOS_Broadcast(Command->os,
##############################################################################
#
-# Copyright (c) 2005 - 2010 by Vivante Corp. All rights reserved.
+# Copyright (c) 2005 - 2011 by Vivante Corp. All rights reserved.
#
# The material in this file is confidential and contains trade secrets
# of Vivante Corporation. This is proprietary information owned by
-# Vivante Corporation. No part of this work may be disclosed,
-# reproduced, copied, transmitted, or used in any way for any purpose,
+# Vivante Corporation. No part of this work may be disclosed,
+# reproduced, copied, transmitted, or used in any way for any purpose,
# without the express written permission of Vivante Corporation.
#
##############################################################################
#
-# Auto-generated file on 12/17/2010. Do not edit!!!
+# Auto-generated file on 1/7/2011. Do not edit!!!
#
##############################################################################
gco2D_SetAutoFlushCycles
gco2D_ProfileEngine
gco2D_GetMaximumDataCount
+ gco2D_EnableDither
!IFNDEF VIVANTE_NO_3D
{
/* map internal memory */
device->internalPhysical = (gctPHYS_ADDR)physical;
+#if gcdENABLE_MEM_CACHE
+ device->internalLogical = (gctPOINTER)ioremap_cached(
+ physical, device->internalSize);
+#else
device->internalLogical = (gctPOINTER)ioremap_nocache(
physical, device->internalSize);
+#endif
gcmkASSERT(device->internalLogical != NULL);
{
/* map internal memory */
device->externalPhysical = (gctPHYS_ADDR)physical;
+#if gcdENABLE_MEM_CACHE
+ device->externalLogical = (gctPOINTER)ioremap_cached(
+ physical, device->externalSize);
+#else
device->externalLogical = (gctPOINTER)ioremap_nocache(
physical, device->externalSize);
-
+#endif
gcmkASSERT(device->externalLogical != NULL);
physical += device->externalSize;
device->contiguousPhysical = (gctPHYS_ADDR) ContiguousBase;
device->contiguousSize = ContiguousSize;
+#if gcdENABLE_MEM_CACHE
+ device->contiguousBase = (gctPOINTER) ioremap_cached(ContiguousBase, ContiguousSize);
+#else
device->contiguousBase = (gctPOINTER) ioremap_nocache(ContiguousBase, ContiguousSize);
+#endif
device->contiguousMapped = gcvTRUE;
if (device->contiguousBase == gcvNULL)
/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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
#include <linux/miscdevice.h>
#include <linux/slab.h>
-
#include "gc_hal_kernel_linux.h"
#include "gc_hal_driver.h"
#include "gc_hal_user_context.h"
if(freq!=last_freq) {
last_freq = freq;
- set_nextfreq(freq);
+ //set_nextfreq(freq);
}
- //printk("%8d /%8d = %3d %%, needfreq = %dM (%d)\n", (int)run, (int)(run+idle), precent, freq, power_cnt);
+ printk("%8d /%8d = %3d %%, needfreq = %dM (%d)\n", (int)run, (int)(run+idle), precent, freq, power_cnt);
}
#endif
FreeAllMemoryRecord(galDevice->os, &private->memoryRecordList);
#ifdef ANDROID
- gcmkVERIFY_OK(gckOS_Delay(galDevice->os, 1000));
+ /* gcmkVERIFY_OK(gckOS_Delay(galDevice->os, 1000)); */
#else
gcmkVERIFY_OK(gckCOMMAND_Stall(device->kernel->command));
#endif
return -ENOTTY;
}
+#if !gcdENABLE_MEM_CACHE
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+#endif
vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND;
vma->vm_pgoff = 0;
return 0;
}
+static void __devinit gpu_shutdown(struct platform_device *dev)
+{
+ gceSTATUS status;
+ gckGALDEVICE device;
+
+ printk("Enter %s \n", __func__);
+
+ device = platform_get_drvdata(dev);
+
+ status = gckHARDWARE_SetPowerManagementState(device->kernel->hardware, gcvPOWER_OFF);
+
+ if (gcmIS_ERROR(status))
+ {
+ printk("%s fail!\n", __func__);
+ }
+}
+
static struct platform_driver gpu_driver = {
.probe = gpu_probe,
.remove = gpu_remove,
-
+ .shutdown = gpu_shutdown,
.suspend = gpu_suspend,
.resume = gpu_resume,
/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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
return gcvSTATUS_OUT_OF_RESOURCES;
}
#else
+
+#if !gcdENABLE_MEM_CACHE
mdlMap->vma->vm_page_prot = pgprot_noncached(mdlMap->vma->vm_page_prot);
+#endif
mdlMap->vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_RESERVED;
mdlMap->vma->vm_pgoff = 0;
}
vaddr = (gctPOINTER)page_address(page);
+#if gcdENABLE_MEM_CACHE
+ addr = ioremap_cached(virt_to_phys(vaddr), size);
+#else
addr = ioremap_nocache(virt_to_phys(vaddr), size);
+#endif
mdl->dmaHandle = virt_to_phys(vaddr);
mdl->kaddr = vaddr;
return gcvSTATUS_OUT_OF_RESOURCES;
}
#else
+
+#if !gcdENABLE_MEM_CACHE
mdlMap->vma->vm_page_prot = pgprot_noncached(mdlMap->vma->vm_page_prot);
+#endif
mdlMap->vma->vm_flags |= VM_IO | VM_DONTCOPY | VM_DONTEXPAND | VM_RESERVED;
mdlMap->vma->vm_pgoff = 0;
{
/* Map memory as cached memory. */
request_mem_region(physical, Bytes, "MapRegion");
+#if gcdENABLE_MEM_CACHE
+ logical = (gctPOINTER) ioremap_cached(physical, Bytes);
+#else
logical = (gctPOINTER) ioremap_nocache(physical, Bytes);
-
+#endif
if (logical == NULL)
{
gcmkTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_OS,
mdlMap->vma->vm_flags |= VM_RESERVED;
/* Make this mapping non-cached. */
+#if !gcdENABLE_MEM_CACHE
mdlMap->vma->vm_page_prot = pgprot_noncached(mdlMap->vma->vm_page_prot);
+#endif
addr = mdl->addr;
IN gctSIZE_T Bytes
)
{
+#if gcdENABLE_MEM_CACHE
+ dmac_clean_range(Logical, Logical+Bytes);
+#endif
return gcvSTATUS_OK;
}
IN gctSIZE_T Bytes
)
{
+#if gcdENABLE_MEM_CACHE
+ dmac_flush_range(Logical, Logical+Bytes);
+#endif
return gcvSTATUS_OK;
}
/* Put GPU ON. */
gcmkONERROR(
- gckHARDWARE_SetPowerManagementState(Hardware, gcvPOWER_ON));
+ gckHARDWARE_SetPowerManagementState(Hardware,
+ gcvPOWER_ON_BROADCAST));
break;
case gcvBROADCAST_GPU_STUCK:
/****************************************************************************
*
-* Copyright (C) 2005 - 2010 by Vivante Corp.
+* Copyright (C) 2005 - 2011 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