aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Seyfried <stefan.seyfried@googlemail.com>2007-12-19 14:18:24 +0000
committerStefan Seyfried <stefan.seyfried@googlemail.com>2007-12-19 14:18:24 +0000
commit6cd794e094075e4e4a6e72a5f57ae36a1398c5d9 (patch)
treeefd64ce1bf0286c2ecfced44e82593596180b96b
parent935d70b27b7937200e6ff8fa33e01f3602c4ad21 (diff)
downloadsuspend-utils-6cd794e094075e4e4a6e72a5f57ae36a1398c5d9.tar.gz
Add framebuffer suspension to s2ram, which should make s2ram more reliable
on some machines and prevent others from needing the NOFB quirk. For debugging (e.g. if the machines hangs before entering suspend), this can be disabled with "--nofbsuspend". Remove NOFB from the ACER Aspire 1690 whitelist entry, no longer needed.
-rw-r--r--s2ram-main.c2
-rw-r--r--s2ram-x86.c52
-rw-r--r--s2ram-x86.h4
-rw-r--r--whitelist.c4
4 files changed, 58 insertions, 4 deletions
diff --git a/s2ram-main.c b/s2ram-main.c
index c42e41d..7299077 100644
--- a/s2ram-main.c
+++ b/s2ram-main.c
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
HACKS_LONG_OPTS
{ NULL, 0, NULL, 0 }
};
- const char *optstring = "hVni" "fspmrva:";
+ const char *optstring = "hVni" "fspmrva:\8";
while ((i = getopt_long(argc, argv, optstring, options, NULL)) != -1) {
switch (i) {
diff --git a/s2ram-x86.c b/s2ram-x86.c
index 4091b3d..b8c097c 100644
--- a/s2ram-x86.c
+++ b/s2ram-x86.c
@@ -11,6 +11,9 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
#include <pci/pci.h>
@@ -30,6 +33,7 @@ static struct pci_access *pacc;
/* Flags set from whitelist */
static int flags = 0, vbe_mode = -1, dmi_scanned = 0;
int force;
+int fb_nosuspend = 0;
char bios_version[1024], sys_vendor[1024], sys_product[1024], sys_version[1024];
/* return codes for s2ram_is_supported */
@@ -116,6 +120,42 @@ static int machine_match(void)
return -1;
}
+static void fbcon_state(int state)
+{
+ DIR *d;
+ FILE *f;
+ struct dirent *entry;
+ char statefile[255];
+
+ if ((d = opendir("/sys/class/graphics")) == NULL)
+ return;
+ while ((entry = readdir(d)) != NULL) {
+ if (entry->d_name[0] == '.')
+ continue;
+ snprintf(statefile, 255, "/sys/class/graphics/%s/state", entry->d_name);
+ if (!access(statefile, W_OK)) {
+ printf("fbcon %s state %d\n", entry->d_name, state);
+ f = fopen(statefile, "w");
+ if (!f) {
+ printf("s2ram: cannot write to %s\n", statefile);
+ continue;
+ }
+ fprintf(f, "%d", state);
+ fclose(f);
+ }
+ }
+}
+
+static void suspend_fbcon(void)
+{
+ fbcon_state(1);
+}
+
+static void resume_fbcon(void)
+{
+ fbcon_state(0);
+}
+
int s2ram_check(int id)
{
int ret = S2RAM_OK;
@@ -243,6 +283,12 @@ int s2ram_hacks(void)
/* pci_save requested, no VGA device found => abort */
return 1;
}
+ if (fb_nosuspend)
+ printf("ATTENTION: --nofbsuspend is a debugging tool only.\n"
+ "\tIf your machine needs this to work, please report "
+ "this as a bug.\n");
+ else
+ suspend_fbcon();
return 0;
}
@@ -296,6 +342,8 @@ void s2ram_resume(void)
printf("Calling set_vbe_mode\n");
do_set_mode(vbe_mode, 0);
}
+ if (!fb_nosuspend)
+ resume_fbcon();
if (flags & RADEON_OFF) {
printf("Calling radeon_cmd_light(1)\n");
radeon_cmd_light(1);
@@ -335,6 +383,8 @@ void s2ram_add_flag(int opt, const char *opt_arg)
case 'a':
flags |= (atoi(optarg) & (S3_BIOS | S3_MODE));
break;
-
+ case 8:
+ fb_nosuspend = 1;
+ break;
}
}
diff --git a/s2ram-x86.h b/s2ram-x86.h
index b8ec976..0bc5171 100644
--- a/s2ram-x86.h
+++ b/s2ram-x86.h
@@ -7,6 +7,10 @@
*/
#define HACKS_LONG_OPTS \
+ {\
+ "nofbsuspend\0\tdo not suspend the framebuffer (debugging only!).",\
+ no_argument, NULL, 8 \
+ },\
{\
"force\0\tforce suspending, even on unknown machines.\n\nThe following options are only available with --force:",\
no_argument, NULL, 1 \
diff --git a/whitelist.c b/whitelist.c
index 78b7e35..899f4a5 100644
--- a/whitelist.c
+++ b/whitelist.c
@@ -7,7 +7,7 @@
#include <stdlib.h>
#include "whitelist.h"
-char *whitelist_version = "$Id: whitelist.c,v 1.116 2007/12/18 16:11:06 seife Exp $";
+char *whitelist_version = "$Id: whitelist.c,v 1.117 2007/12/19 14:18:24 seife Exp $";
struct machine_entry whitelist[] = {
{ "IBM", "", "ThinkPad X32", "", RADEON_OFF|S3_BIOS|S3_MODE },
@@ -27,7 +27,7 @@ struct machine_entry whitelist[] = {
{ "Acer", "Aspire 1520", "", "", VBE_POST|VBE_MODE },
/* Giorgio Lando <patroclo7@gmail.com> */
{ "Acer, inc.", "Aspire 1640 ", "", "", 0 },
- { "Acer, inc.", "Aspire 1690 ", "", "", VBE_POST|VBE_SAVE|NOFB },
+ { "Acer, inc.", "Aspire 1690 ", "", "", VBE_POST|VBE_SAVE },
/* Ricardo Garcia <sarbalap+freshmeat@gmail.com> */
{ "Acer, inc.", "Aspire 3000 *", "", "", VBE_POST|VBE_MODE },
/* Marek Stopka (M4r3k) <marekstopka@gmail.com> */