#define _GC_OBJ_ZONE gcvZONE_COMMAND
-#if gcdENABLE_FSCALE_VAL_ADJUST
-extern int thermal_hot;
-#endif
/******************************************************************************\
********************************* Support Code *********************************
\******************************************************************************/
/* 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));
#include <linux/device.h>
#include <linux/slab.h>
+#include <linux/notifier.h>
#include "gc_hal_kernel_linux.h"
#include "gc_hal_driver.h"
/* Zone used for header/footer. */
#define _GC_OBJ_ZONE gcvZONE_DRIVER
+#if gcdENABLE_FSCALE_VAL_ADJUST
+extern int register_thermal_notifier(struct notifier_block *nb);
+extern int unregister_thermal_notifier(struct notifier_block *nb);
+#endif
+
MODULE_DESCRIPTION("Vivante Graphics Driver");
MODULE_LICENSE("GPL");
# define DEVICE_NAME "galcore"
#endif
+#if gcdENABLE_FSCALE_VAL_ADJUST
+static int thermal_hot_pm_notify(struct notifier_block *nb, unsigned long event,
+ void *dummy)
+{
+ static gctUINT orgFscale, minFscale, maxFscale;
+ static gctBOOL bAlreadyTooHot = gcvFALSE;
+ gckHARDWARE hardware = galDevice->kernels[gcvCORE_MAJOR]->hardware;
+
+ if (event && !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 (!event && bAlreadyTooHot) {
+ gckHARDWARE_SetFscaleValue(hardware, orgFscale);
+ gckOS_Print("Hot alarm is canceled. GPU3D clock will return to %d/64\n", orgFscale);
+ bAlreadyTooHot = gcvFALSE;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block thermal_hot_pm_notifier = {
+ .notifier_call = thermal_hot_pm_notify,
+ };
+#endif
+
+
+
static int __devinit gpu_probe(struct platform_device *pdev)
{
int ret = -ENODEV;
{
platform_set_drvdata(pdev, galDevice);
+#if gcdENABLE_FSCALE_VAL_ADJUST
+ if(galDevice->kernels[gcvCORE_MAJOR])
+ register_thermal_notifier(&thermal_hot_pm_notifier);
+#endif
gcmkFOOTER_NO();
return ret;
}
-
+#if gcdENABLE_FSCALE_VAL_ADJUST
+ unregister_thermal_notifier(&thermal_hot_pm_notifier);
+#endif
gcmkFOOTER_ARG(KERN_INFO "Failed to register gpu driver: %d\n", ret);
return ret;
}
static int __devinit gpu_remove(struct platform_device *pdev)
{
gcmkHEADER();
+#if gcdENABLE_FSCALE_VAL_ADJUST
+ if(galDevice->kernels[gcvCORE_MAJOR])
+ unregister_thermal_notifier(&thermal_hot_pm_notifier);
+#endif
drv_exit();
gcmkFOOTER_NO();
return 0;