Version 0.5 - performance and fixes

Changelog:

    - completely reworked fast scaling functionality. now using a 'line jump' logic instead of fixed freq 'colums'.
      fast scaling now in 4 steps and 2 modes possible (mode 1: only fast scaling up and mode2: fast scaling up/down)
    - added support for 'Dynamic Screen Frequency Scaling' (original implementation into zzmoove governor highly improved by Yank555)
      originated by AndreiLux more info: http://forum.xda-developers.com/showpost.php?p=38499071&postcount=3
    - re-enabled broken conservative sampling down factor functionality ('down skip' method).
      originated by Stratosk - upstream kernel 3.10rc1:
      https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/?id=refs%2Ftags%2Fv3.10-rc1&qt=author&q=Stratos+Ka
    - changed down threshold check to act like it should.
      originated by Stratosk - upstream kernel 3.10rc1:
      https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/?id=refs%2Ftags%2Fv3.10-rc1&qt=author&q=Stratos+Ka
    - implemented/ported 'early demand' from ondemand governor.
      originated by Stratosk - more info: http://www.semaphore.gr/80-latests/98-ondemand-early-demand
    - implemented/ported 'sampling down momentum' from ondemand governor.
      originated by Stratosk - more info: http://www.semaphore.gr/80-latests/80-sampling-down-momentum
    - modified some original conservative code parts regarding frequency scaling which should work better now.
      originated by DerTeufel1980: https://github.com/DerTeufel/android_kernel_samsung_smdk4412/commit/6bab622344c548be853db19adf28c3917896f0a0
    - added the possibility to use sampling down momentum or conservative 'down skip' method.
    - increased possible max sampling rate sleep multiplier to 4 and sampling down factor to 100000
      accordingly to sampling down momentum implementation.
    - added frequency search limit for more efficient frequency searching in scaling 'table' and for improving
      frequency 'hard' and 'soft' limit handling.
    - added cpu idle exit time handling like it is in lulzactive
      again work from ktoonsez : https://github.com/ktoonsez/KT747-JB/commit/a5931bee6ea9e69f386a340229745da6f2443b78
      description in lulzactive governor:
      https://github.com/ktoonsez/KT747-JB/blob/a5931bee6ea9e69f386a340229745da6f2443b78/drivers/cpufreq/cpufreq_lulzactive.c
    - fixed a little scaling step mistake and added overclocking frequencies up to 1800 mhz in scaling frequency 'tables'.
    - fixed possible freezes during start/stop/reload of governor and frequency limit change.
    - fixed hotplugging logic at online core 0+3 or 0+2 situations and improved hotplugging in general by
      removing mutex locks and skipping hotplugging when it is not needed.
    - added possibility to disable hotplugging (that's a debugging relict but i thought maybe someone will find that usefull so i didn't remove it)
    - try to fix lags when coming from suspend if hotplug limitation at sleep was active by enabling all offline cores during resume.
    - code cleaning and documentation.

      for this functions following new tuneables were indroduced:

      Early Demand:
      -------------
      early_demand          -> switch to enable/disable early demand functionality (possible values 0 disable or 1 enable, default: 0)
      grad_up_threshold     -> scale up frequency if the load goes up in one step of grad up value (possible range from 11 to 100, default 50)
                               little example for understanding: when the load rises up in one big 50% step then the
                               frequency will be scaled up immediately instead of wating till up_threshold is reached.

      Fast Scaling (improved):
      ------------------------
      Fast scaling has now 8 levels which at the same time have 2 modes included. Values from 1-4 equals to scaling jumps in the frequency table
      and uses the Fast Scaling up but normal scaling down mode. Values from 5-8 equals to 1-4 scaling jumps but uses the fast scaling up and fast
      scaling down mode.

      Hotplugging switch:
      -------------------
      disable_hotplug       -> switch to enable/disable hotplugging (possible values are any value above 0 to disable hotplugging and 0 to
                               enable it, default 0)

      Sampling Down Factor and Sampling Down Momentum:
      ------------------------------------------------
      Description: From the original author of ondemand_sampling_factor David Niemi:
      'This improves performance by reducing the overhead of load evaluation and helping the CPU stay
      at its top speed when truly busy, rather than shifting back and forth in speed.'

      And that 'Sampling Down Momentum' function from stratosk does this dynamicly now! ;)

      sampling_down_max_momentum          -> max sampling down factor which should be set by momentum (0 disable momentum, possible range from
                                             sampling_down_factor up to MAX_SAMPLING_DOWN_FACTOR, default 0 disabled)
      sampling_down_momentum_sensitivity  -> how fast the sampling down factor should be switched (possible values from 1 to 500, default 50)
      sampling_down_factor                -> depending on which mode is active the factor for sampling rate multiplier which influences the whole
                                             sampling rate or the value for stock 'down skip' functionality which influences only the down scaling
                                             mechanism (possible values are from 1 to MAX_SMPLING_DOWN_FACTOR, default 1 disabled)

      Original conservative 'down skip' or 'stock' method can be enabled by setting the momentum tuneable to 0. so if momentum is inactive there will
      be a fallback to the stock method. as the name 'down skip' says this method works 'slightly' different from the ondemand stock sampling down method
      (on which momentum was based on). It just skips the scaling down code for the given samples. if u want to completely disable the sampling down
      functionality u can achieve this by setting sampling down factor to 1. so concluded: setting sampling_down_momentum = 0 and sampling_down_factor = 1
      will disable sampling down completely (that is also the governor default setting)

      Dynamic Screen Frequency Scaling:
      --------------------------------
      Dynamicly switches the screen frequency to 40hz or 60hz depending on cpu scaling and hotplug settings.
      For compiling and enabling this functionality u have to do some more modification to the kernel sources, please take a look at AndreiLux Perseus
      repository and there at following commit: https://github.com/AndreiLux/Perseus-S3/commit/3476799587d93189a091ba1db26a36603ee43519
      After adding this patch u can enable the feature by setting 'CPU_FREQ_LCD_FREQ_DFS=y' in your kernel config and if u want to check if it is
      really working at runtime u can also enable the accounting which AndreiLux added by setting LCD_FREQ_SWITCH_ACCOUNTING=y in the kernel config.
      If all goes well and u have the DFS up and running u can use following tuneables to do some screen magic:
      (thx to Yank555 for highly extend and improving this)

      lcdfreq_enable                     -> to enable/disable LCDFreq scaling (possible values 0 disable or 1 enable, default: 0)
      lcdfreq_kick_in_down_delay         -> the amount of samples to wait below the threshold frequency before entering low display frequency mode (40hz)
      lcdfreq_kick_in_up_delay           -> the amount of samples to wait over the threshold frequency before entering high display frequency mode (60hz)
      lcdfreq_kick_in_freq               -> the frequency threshold - below this cpu frequency the low display frequency will be active
      lcdfreq_kick_in_cores              -> the number of cores which should be online before switching will be active. (also useable in combination
                                            with kickin_freq)

      So this version is a kind of 'featured by' release as i took (again *g*) some ideas and work from other projects and even some of that work
      comes directly from other devs so i wanna thank and give credits:

      First of all to stratosk for his great work 'sampling down momentum' and 'early demand' and for all the code fixes which found their way into
      the upstream kernel version of conservative governor! congrats and props on that stratos, happy to see such a nice and talented dev directly
      contibuting to the upstream kernel, that is a real enrichment for all of us!

      Second to Yank555 for coming up with the idea and improving/completeing (leaves nothing to be desired now *g*) my first
      rudimentary implementation of Dynamic Screen Frequency Scaling from AndreiLux (credits for the idea/work also to him at this point).

      Third to DerTeufel1980 for his first implementation of stratosk's early demand functionality into version 0.3 of zzmoove governor
      (even though i had to modify the original implementation a 'little bit' to get it working properly ;)) and for some code optimizations/fixes
      regarding scaling.

      Last but not least again to ktoonsez - I 'cherry picked' again some code parts of his ktoonservative governor which should improve this governor
      too.

Change-Id: I082c6658994769d60664ec4bba65adce471188c9
Version 0.5.1b - bugfixes and more optimisations (in cooperation with Yank555)

Changelog:

    - highly optimised scaling logic (thx and credits to Yank555)
    - simplified some tuneables by using already available stuff instead of using redundant code (thx Yank555)
    - reduced/optimised hotplug logic and preperation for automatic detection of available cores
      (maybe this fixes also the scaling/core stuck problems)
    - finally fixed the freezing issue on governor stop!

Change-Id: Icc0e495c0bff0d91f9a9db34131cbf086c47bfd8
Version 0.6 - flexibility (in cooperation with Yank555)

Changelog:

       - removed fixed scaling lookup tables and use the system frequency table instead
         changed scaling logic accordingly for this modification (thx and credits to Yank555)
       - reduced new hotplug logic loop to a minimum
       - again try to fix stuck issues by using seperate hotplug functions out of dbs_check_cpu (credits to ktoonesz)
       - added support for 2 and 8 core systems and added automatic detection of cores were it is needed
         (for setting the different core modes you can use the macro 'MAX_CORES'. possible values are: 2,4 or 8, default are 4 cores)
         reduced core threshold defaults to only one up/down default and use an array to hold all threshold values
       - fixed some mistakes in 'frequency tuneables' (Yank555):
         stop looping once the frequency has been found
         return invalid error if new frequency is not found in the frequency table

Change-Id: Ifa4d66f3ef87c3026c6fdee68b5ca77d7abcf402