summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-10-31 16:09:46 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-11-01 21:10:59 +0100
commit0369fe19b8b8e19e0815361b5187eba81cb2d71a (patch)
tree9deae55c52894d7f240fb0c566ef717288efc99b /lib
parent43def94f3213634c2c798049cb17efc14801a9ed (diff)
lib: consolidate pipe crc exit handler
No need to sprinkle this all over: - exit handlers will only be registered once - they're always called when exiting, so no need to explictly call them. This allows us to hide all the pipe crc cleanup in the library. Cc: Damien Lespiau <damien.lespiau@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_debugfs.c56
-rw-r--r--lib/igt_debugfs.h1
2 files changed, 30 insertions, 27 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 167b50ec..7d710e24 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -177,6 +177,34 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
return true;
}
+static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
+{
+ char buf[32];
+
+ sprintf(buf, "pipe %c none", pipe_name(pipe));
+ write(fd, buf, strlen(buf));
+}
+
+static void igt_pipe_crc_reset(void)
+{
+ igt_debugfs_t debugfs;
+ int fd;
+
+ igt_debugfs_init(&debugfs);
+ fd = igt_debugfs_open(&debugfs, "i915_display_crc_ctl", O_WRONLY);
+
+ igt_pipe_crc_pipe_off(fd, PIPE_A);
+ igt_pipe_crc_pipe_off(fd, PIPE_B);
+ igt_pipe_crc_pipe_off(fd, PIPE_C);
+
+ close(fd);
+}
+
+static void pipe_crc_exit_handler(int sig)
+{
+ igt_pipe_crc_reset();
+}
+
igt_pipe_crc_t *
igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
enum intel_pipe_crc_source source)
@@ -184,6 +212,8 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
igt_pipe_crc_t *pipe_crc;
char buf[128];
+ do_or_die(igt_install_exit_handler(pipe_crc_exit_handler));
+
pipe_crc = calloc(1, sizeof(struct _igt_pipe_crc));
pipe_crc->ctl_fd = igt_debugfs_open(debugfs,
@@ -211,32 +241,6 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
return pipe_crc;
}
-static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
-{
- char buf[32];
-
- sprintf(buf, "pipe %c none", pipe_name(pipe));
- write(fd, buf, strlen(buf));
-}
-
-/*
- * Turn off everything
- */
-void igt_pipe_crc_reset(void)
-{
- igt_debugfs_t debugfs;
- int fd;
-
- igt_debugfs_init(&debugfs);
- fd = igt_debugfs_open(&debugfs, "i915_display_crc_ctl", O_WRONLY);
-
- igt_pipe_crc_pipe_off(fd, PIPE_A);
- igt_pipe_crc_pipe_off(fd, PIPE_B);
- igt_pipe_crc_pipe_off(fd, PIPE_C);
-
- close(fd);
-}
-
void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)
{
if (!pipe_crc)
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 4e82a2cb..c2810ee3 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -73,7 +73,6 @@ char *igt_crc_to_string(igt_crc_t *crc);
igt_pipe_crc_t *
igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
enum intel_pipe_crc_source source);
-void igt_pipe_crc_reset(void);
void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);