pm-utils-1.3.0-suse-smart-uswsusp.patch 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. ---
  2. pm/defaults | 20 +++++++++++++++-
  3. pm/module.d/uswsusp | 64 +++++++++++++++++++++++++++++++++++++++++++++++-----
  4. 2 files changed, 78 insertions(+), 6 deletions(-)
  5. Index: pm-utils-1.3.0/pm/defaults
  6. ===================================================================
  7. --- pm-utils-1.3.0.orig/pm/defaults 2009-06-14 03:56:08.000000000 +0200
  8. +++ pm-utils-1.3.0/pm/defaults 2010-05-06 09:27:09.228673127 +0200
  9. @@ -27,8 +27,26 @@
  10. # tuxonice If your system has support for tuxonice, use this.
  11. #
  12. # The system defaults to "kernel" if this is commented out.
  13. -# SLEEP_MODULE="kernel"
  14. +SLEEP_MODULE="uswsusp"
  15. +#######################################################################
  16. +# the variables below here are specific to the SUSE package right now
  17. +# and are used only if SLEEP_MODULE is uswsusp
  18. +
  19. +# what options should be passed to s2ram?
  20. +# see http://en.opensuse.org/S2ram for more information
  21. +# If this option is set, it overrides S2RAM_QUIRKS_SOURCE below
  22. +S2RAM_OPTS=""
  23. +
  24. +# where should pm-utils get the s2ram quirks from?
  25. +# s2ram - use the whitelist in s2ram, if the machine is known.
  26. +# hal - ignored, exists only for comparibility purposes pm-utils 1.3.0+ has
  27. +# HAL quirks built-in
  28. +# everything else: try to be smart in figuring out the correct quirks.
  29. +# if S2RAM_OPTS is set, it overrides S2RAM_QUIRKS_SOURCE!
  30. +S2RAM_QUIRKS_SOURCE=""
  31. +
  32. +#######################################################################
  33. # These variables will be handled specially when we load files in
  34. # /etc/pm/config.d.
  35. # Multiple declarations of these environment variables will result in
  36. Index: pm-utils-1.3.0/pm/module.d/uswsusp
  37. ===================================================================
  38. --- pm-utils-1.3.0.orig/pm/module.d/uswsusp 2009-12-11 05:36:38.000000000 +0100
  39. +++ pm-utils-1.3.0/pm/module.d/uswsusp 2010-05-06 09:27:37.540671614 +0200
  40. @@ -5,6 +5,7 @@
  41. uswsusp_hooks()
  42. {
  43. disablehook 99video "disabled by uswsusp"
  44. + disablehook 90chvt "disabled by uswsusp"
  45. }
  46. # Since we disabled 99video, we need to take responsibility for proper
  47. @@ -35,8 +36,52 @@
  48. # if we were told to ignore quirks, do so.
  49. # This is arguably not the best way to do things, but...
  50. [ "$QUIRK_NONE" = "true" ] && OPTS=""
  51. + S2RAM_OPTS="$S2RAM_OPTS $OPTS"
  52. + echo "INFO: S2RAM_OPTS from HAL quirks: '$S2RAM_OPTS'."
  53. }
  54. +# this function tries to assemble the best s2ram options from various sources, falling back
  55. +# to other methods...
  56. +get_s2ram_opts()
  57. +{
  58. + # if S2RAM_OPTS is set - then use it. The user told us so. Obey his wish.
  59. + if [ -n "$S2RAM_OPTS" ]; then
  60. + echo "INFO: using user-supplied options: S2RAM_OPTS='$S2RAM_OPTS' for suspending."
  61. + return
  62. + fi
  63. +
  64. + # ... try to use s2ram as a source
  65. + if [ "$S2RAM_QUIRKS_SOURCE" = "s2ram" ]; then
  66. + if /usr/sbin/s2ram -n >/dev/null; then
  67. + echo "INFO: using s2ram built-in database, machine is supported."
  68. + return
  69. + else
  70. + echo "WARN: S2RAM_QUIRKS_SOURCE=s2ram, but machine is unknown, continuing..."
  71. + fi
  72. + fi
  73. +
  74. + # ... if is not known or not set as a source, use the built-in database
  75. + echo "INFO: using built-in quirks database from HAL."
  76. + uswsusp_get_quirks
  77. + if [ -n "$S2RAM_OPTS" ]; then
  78. + S2RAM_OPTS="--force "$S2RAM_OPTS
  79. + fi
  80. +
  81. + # ... in a case we still don't have any quirk, try s2ram for sure
  82. + if [ -z "$S2RAM_OPTS" ]; then
  83. + # ... machine could be in s2ram whitelist
  84. + if /usr/sbin/s2ram -n >/dev/null; then
  85. + echo "INFO: machine is in s2ram database, using it."
  86. + return;
  87. + else
  88. + # if we came here and S2RAM_OPTS is empty, suspend won't work :-(
  89. + echo "WARNING: smart uswsusp did not found any appropriate option, suspend probably don't work"
  90. + fi
  91. + fi
  92. +
  93. +}
  94. +
  95. +
  96. # Since we disabled 99video, we also need to handle displaying
  97. # help info for the quirks we handle.
  98. uswsusp_help()
  99. @@ -70,8 +115,8 @@
  100. SUSPEND_MODULE="uswsusp"
  101. do_suspend()
  102. {
  103. - uswsusp_get_quirks
  104. - s2ram --force $OPTS
  105. + get_s2ram_opts
  106. + s2ram $S2RAM_OPTS
  107. }
  108. if [ "$METHOD" = "suspend" ]; then
  109. add_before_hooks uswsusp_hooks
  110. @@ -87,7 +132,12 @@
  111. HIBERNATE_MODULE="uswsusp"
  112. do_hibernate()
  113. {
  114. - s2disk
  115. + get_s2ram_opts
  116. + if [ -z "${S2DISK_CONF}" ]; then
  117. + s2disk
  118. + else
  119. + s2disk --config $S2DISK_CONF
  120. + fi
  121. }
  122. fi
  123. @@ -98,8 +148,12 @@
  124. SUSPEND_HYBRID_MODULE="uswsusp"
  125. do_suspend_hybrid()
  126. {
  127. - uswsusp_get_quirks
  128. - s2both --force $OPTS
  129. + get_s2ram_opts
  130. + if [ -z "${S2DISK_CONF}" ]; then
  131. + s2both --force $S2RAM_OPTS
  132. + else
  133. + s2both --config $S2DISK_CONF $S2RAM_OPTS
  134. + fi
  135. }
  136. if [ "$METHOD" = "suspend_hybrid" ]; then
  137. add_before_hooks uswsusp_hooks