some optimizing
Version 0.7 - slow down (in cooperation with Yank555)

Changelog:

        - reindroduced the 'old way' of hotplugging and scaling in form of the 'Legacy Mode' (macros for enabling/disabling this done by Yank555, thx)
          NOTE: this mode can only handle 4 cores and a scaling max frequency up to 1800mhz.
        - added hotplug idle threshold for a balanced load at CPU idle to reduce possible higher idle temperatures when running on just one core.
          (inspired by JustArchi's observations, thx)
        - added hotplug block cycles to reduce possible hotplugging overhead (credits to ktoonsez)
        - added possibility to disable hotplugging only at suspend (inspired by a request of STAticKY, thx for the idea)
        - introduced hotplug frequency thresholds (credits to Yank555)
        - hotplug tuneables handling optimized (credits to Yank555)
        - added version information tuneable (credits to Yank555)

          for this functions following new tuneables were indroduced:

          legacy_mode                   -> for switching to the 'old' method of scaling/hotplugging. possible values 0 to disable,
                                           any values above 0 to enable (default is 0)
                                           NOTE: the legacy mode has to be enabled by uncommenting the macro ENABLE_LEGACY_MODE below
          hotplug_idle_threshold        -> amount of load under which hotplugging should be disabled at idle times (respectively at scaling minimum).
                                           possible values 0 disable, from 1 to 100 (default is 0)
          hotplug_block_cycles          -> slow down hotplugging by waiting a given amount of cycles before plugging.
                                           possible values 0 disbale, any values above 0 (default is 0)
          disable_hotplug_sleep         -> same as disable_hotplug but will only take effect at suspend.
                                           possible values 0 disable, any values above 0 to enable (default is 0)
          up_threshold_hotplug_freq1    -> hotplug up frequency threshold for core1.
                                           possible values 0 disable and range from over down_threshold_hotplug_freq1 to max scaling freqency (default is 0)
          up_threshold_hotplug_freq2    -> hotplug up frequency threshold for core2.
                                           possible values 0 disable and range from over down_threshold_hotplug_freq2 to max scaling freqency (default is 0)
          up_threshold_hotplug_freq3    -> hotplug up frequency threshold for core3.
                                           possible values 0 disable and range from over down_threshold_hotplug_freq3 to max scaling freqency (default is 0)
          down_threshold_hotplug_freq1  -> hotplug down frequency threshold for core1.
                                           possible values 0 disable and range from min saling to under up_threshold_hotplug_freq1 freqency (default is 0)
          down_threshold_hotplug_freq2  -> hotplug down frequency threshold for core2.
                                           possible values 0 disable and range from min saling to under up_threshold_hotplug_freq2 freqency (default is 0)
          down_threshold_hotplug_freq3  -> hotplug down frequency threshold for core3.
                                           possible values 0 disable and range from min saling to under up_threshold_hotplug_freq3 freqency (default is 0)
          version                       -> show the version of zzmoove governor

Conflicts:
	drivers/cpufreq/cpufreq_zzmoove.c
Version 0.7a - little fix

Changelog:

        - fixed a glitch in hotplug freq threshold tuneables which prevented setting of values in hotplug down freq thresholds when hotplug
          up freq thresholds were set to 0
Version 0.7b - compatibility improved and forgotten things

Changelog:

        - fixed stuck at max scaling frequency when using stock kernel sources with unmodified cpufreq driver and without any oc capabilities.
        - readded forgotten frequency search optimisation in scaling logic (only effective when using governor soft frequency limit)
        - readded forgotten minor optimisation in dbs_check_cpu function
        - as forgotten to switch in last version Legacy Mode now again disabled by default
        - minor code format and comment fixes
Version 0.7c - again compatibility and optimisations

Changelog:

        - frequency search optimisation now fully compatible with ascending ordered system frequency tables (thx to psndna88 for testing)
        - again minor optimisations at multiple points in dbs_check_cpu function
        - code cleaning - removed some unnecessary things and whitespaces nuked (sry for the bigger diff but from now on it will be clean ;))
        - corrected changelog for previous version regarding limits
Version 0.7d - broken things

Changelog:

    - fixed hotplug up threshold tuneables to be able again to disable cores manually via sysfs by setting them to 0
    - fixed the problem caused by a wrong tuneable apply order of non sticking values in hotplug down threshold tuneables when
      hotplug up values are lower than down values during apply.
      NOTE: due to this change right after start of the governor the full validation of given values to these tuneables is disabled till
      all the tuneables were set for the first time. so if you set them for example with an init.d script or let them set automatically
      with any tuning app be aware that there are illogical value combinations possible then which might not work properly!
      simply be sure that all up values are higher than the down values and vice versa. after first set full validation checks are enabled
      again and setting of values manually will be checked again.
    - fixed a typo in hotplug threshold tuneable macros (would have been only a issue in 8-core mode)
    - fixed unwanted disabling of cores when setting hotplug threshold tuneables to lowest or highest possible value
      which would be a load of 100%/11% in up/down_hotplug_threshold and/or scaling frequency min/max in up/down_hotplug_threshold_freq
Version 0.8 - cool down baby

Changelog:

- indroduced scaling block cycles (in normal and legacy mode) to reduce unwanted jumps to higher frequencies (how high depends on settings)
  when a load comes up just for a short peroid of time or is hitting the scaling up threshold more often because it is within some higher
  to mid load range. reducing these jumps lowers CPU temperature in general and may also save some juice. so with this function u can influence
  the little bit odd scaling behaving when you are running apps like for example games which are constantly 'holding' system load in
  some range and the freq is scaled up too high for that range. in fact it just looks like so, monitoring apps are mostly too slow to catch load in
  realtime so you are watching almost only 'the past'. so actually it's not really odd it's more like: an app is stressing the system and holding
  it on a higher load level, due to this load level scaling up threshold is more often reached (even if monitoring shows a lower load
  than up_threshold) the governor scales up very fast (usual zzmoove behaving) and almost never scales down again (even if monitoring shows
  a lower load than down_threshold). now in patricular these scaling block cycles are throttling up scaling by just skipping it
  for the amount of cycles that you have set up and after that are making a forced scale down in addition for the same amount of cycles. this
  should bring us down to a 'appropriate' frequency when load is hanging around near up threshold.
- indroduced (D)ynamic (S)ampling (R)ate - thx to hellsgod for having the same idea at the same time and pointing me to an example. even though
  at the end i did 'my way' :) DSR switches between two sampling rates depending on the given load threshold from an 'idle' to a 'normal' one.
- added read only tuneable 'sampling_rate_current' for DSR to show current SR and internally use this sampling rate instead of automatically
  changing 'sampling_rate' tuneable in DSR. this keeps things more compatible and avoids problems when governor tuneables are set with tuning
  apps which are saving actual shown values.
- changed setting of sampling rate in governor from 'sampling_rate' to 'sampling_rate_current' and the value at suspend to 'sampling_rate_idle'
  value instead of using current active sampling rate to avoid accidentally setting of 'normal operation' sampling rate in sampling rate idle mode
  which has usually a much lower value
- indroduced build-in profiles in seperate header file (credits to Yank555 for idea and prototype header file)
  you can switch between multible build in profiles by just piping a number into the tuneable 'profile_number'. all tuneable values of the set
  profile will be applied on-the-fly then. if a profile is active and you change any tuneable value from it to a custom one the profile will
  switch to '0' in 'profile_number' and 'custom' in 'profile' for information. with this profiles support developers can simplify their governor
  settings handling by adding all their desired and well proven governor settings into the governor itself instead of having to fiddle around with
  init.d scripts or tuning apps. NOTE: this is just an optional feature, you can still set all tuneables as usual just pay attention that the
  tuneable 'profile_number' is set to '0' then to avoid overwriting values by any build-in profile. for further details about profiles and
  adding own ones check provided 'cpufreq_zzmoove_profiles.h' file.
- added 'profiles_version' tuneable to be able to show seperate profiles header file version
- added enabling of offline cores on governor exit to avoid cores 'stucking' in offline state when switching to a non-hotplug-able governor
  and by the way reduced reduntant code by using an inline function for switching cores on and using the better 'sheduled_work_on-way'
  at all needed places in the code for that purpose
- moved some code parts to legacy mode macro which has only relevance when including the legacy mode in the governor and in addition
  excluded it during runtime if legacy mode is disabled.
- improved freq limit handling in tuneables and in dbs_check_cpu function
- changed value restriction from '11' to '1' in hotplug down threshold and grad up tuneables as this restriction is only nessesary in
  scaling down tuneable
- added missing fast scaling down/normal scaling up mode to fast scaling functionality (value range 9-12 and only available in non-legacy mode
  thx OldBoy.Gr for pointing me to that missing mode)
- added auto fast scaling aka 'insane' scaling mode to fast scaling functionality - lucky number 13 enables this mode in fast_scaling tuneable
  NOTE: a really funny mode, try it :) but keep in mind setting this in combination with a set freq limit (at sleep or awake)would not make much
  sense as there is not enough frequency range available to jump around then.
- back from the precautious 'mutex_try_lock' to normal 'mutex_lock' in governor 'LIMIT' case -> this should be save again,
  no deadlocks expected any more since hotplug logic has significantly changed in zzmoove version 0.6
- removed also the no longer required and precautious skipping of hotplugging and dbs_check_cpu on multiple places in code and removed
  the mutex locks at governor stop and early suspend/late resume
- added hotlug freq thresholds to legacy scaling mode (same usage as in normal scaling mode)
- seperated hotplug down and up block cycles to be more flexible. this replaces 'hotplug_block_cycles' with 'hotplug_block_up_cycles' tuneable
  and adds one new tunable 'hotplug_block_down_cycles'. functionality is the same as before but u can now differentiate the up and down value.
- added 'early demand sleep' combined with automatic fast scaling (fixed to scaling up mode 2) and if not set already automatic
  (depending on load) switching of sampling rate sleep multiplier to a fixed minimum possible multiplier of 2.
  this should avoid mostly audio or general device connection problems with 'resource hungrier' apps like some music players,
  skype, navigation apps etc. and/or in combination with using bluetooth equipment during screen is off.
  NOTE: this overwrites a possible fast 'scaling_sleep' setting so use either this or 'fast_scaling_sleep'
- added some missing governor tunebable default value definitions
- removed tuneable apply order exception and removed analog value checks in hotplug threshold and hotplug frequency tuneables to avoid
  tuneable values not changing issues. NOTE: keep in mind that all 'down' values should be lower then the analog 'up' values and vice versa.
- removed 200 mhz up hotplugging restriction, so up hotplugging starts at 200 mhz now
- removed some unnecessary macros in scaling logic
- added maximum fast scaling and frequency boost to late resume to react wakeup lags
- merged some improvements from ktoonservativeq governor version for the SGS4 (credits to ktoonsez)
  changes from here: https://github.com/ktoonsez/KT-SGS4/commits/aosp4.4/drivers/cpufreq/cpufreq_ktoonservativeq.c
  Use dedicated high-priority workqueues
  Use NEW high-priority workqueue for hotplugging
  Improved hotplugging in general by reducing calls to plugging functions if they are currently running,
  by reducing calls to external function in up plugging and by changing the down plug loop to an optimized one
- added hotplug boost switch to early demand functionality and up hotplugging function
- added 'hotplug_idle_freq' tuneable to be able to adjust at which frequency idle should begin
- transfered code for frequency table order detection and limit optimisation into a inline function
  and use this function in START,LIMIT case and early suspend/late resume instead of using redundant code
- execute table order detection and freq limit optimization calculations at 'START' and 'LIMIT' case to avoid possible wrong setting of freq
  max after governor start (currently set max frequency value was sometimes not applied) and a wrong soft limit optimization setting
  after undercutting the soft limit with a lower hard limit value
- minor optimisation in hotplug, hotplug block and in all freq search logic parts
- added debugging sysfs interface (can be included/excluded using #define ZZMOOVE_DEBUG) - credits to Yank555
- added some missing annotation as a prepareation and mainly to avoid some errors when compiling zzmoove in combination with 3.4+ kernel sources
- fixed hotplugging issues when cpufreq limit was set under one or more hotplugging frequency thresholds
  NOTE: now hotplugging frequency thresholds will be completely disabled and a fall back to normal load thresholds will happen
  if the maximal possible frequency will undercut any frequency thresholds
- fixed stopping of up scaling at 100% load when up threshold tuneable is set to the max value of 100
- fixed smooth up not active at 100% load when smooth up tuneable is set to the max value of 100
- fixed many code style and dokumentation issues and made a massive code re-arrangement

for this functions following new tuneables were indroduced:

early_demand_sleep -> same function as early demand on awake but in addition combined with fast scaling and sampling rate
switch and only active at sleep. (possible values 0 disable or 1 enable, default is 1)

grad_up_threshold_sleep -> 2 way functionality: early demand sleep grad up (load gradient) threshold and at the same time load threshold
for switching internally (tuneables are staying at set values) sampling_rate_sleep_multiplier to 2 and
fast_scaling to 2 (possible values from 1 to 100, default is 35)

hotplug_block_up_cycles -> (replaces hotplug_block_cycles) slow down up hotplugging by waiting a given amount of cycles before plugging.
possible values 0 disable, any values above 0 (default is 0)

hotplug_block_down_cycles -> (replaces hotplug_block_cycles) slow down down hotplugging by waiting a given amount of cycles before plugging.
possible values 0 disable, any values above 0 (default is 0)

hotplug_idle_freq -> freq at which the idle should be active (possible values 0 disable and any possible scaling freq, default is 0)

sampling_rate_current -> read only and shows currently active sampling rate

sampling_rate_idle -> sampling rate which should be used at 'idle times'
(possible values are any sampling rate > 'min_sampling_rate', 0 to disable whole function, default is 0)

sampling_rate_idle_delay -> delay in cycles for switching from idle to normal sampling rate and vice versa
(possible values are any value and 0 to disable delay, default is 0)

sampling_rate_idle_threshold -> threshold under which idle sampling rate should be active
(possible values 1 to 100, 0 to disable function, default is 0)

scaling_block_cycles -> amount of gradients which should be counted (if block threshold is set) and at the same time up scaling should be
blocked and after that a forced down scaling should happen (possible values are any value, 0 to disable that
function, default is 0)

scaling_bock_freq -> frequency at and above the blocking should be active
(possible values are any possible scaling freq, 0 to enable blocking permanently at every frequency, default is 0)

scaling_block_threshold -> gradient (min value) of load in both directions (up/down) to count-up cycles
(possible value are 1 to 100, 0 to disable gradient counting)

scaling_block_force_down -> multiplicator for the maximal amount of forced down scaling cycles (force down cycles = block_cycles * force_down)
therefore the forced down scaling duration (possible value are 2 to any value, 0 to disable forced down scaling
and use only scaling up blocks)

profile -> read only and shows name of currently active profile ('none' = no profile, 'custom' = a profile value has changed)

profile_number -> switches profile (possible value depends on amount of profiles in cpufreq_zzmoove_profiles.h file,

please check this file for futher details) 0 no profile set = tuneable mode, default 0)

version_profiles -> read only and shows version of profile header file

if ZZMOOVE_DEBUG is defined:
debug -> read only and shows various usefull debugging infos