summaryrefslogtreecommitdiff
path: root/overlay
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-08-24 10:00:36 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-08-25 13:34:31 +0100
commit68c63ddd36bc8e5379bf9573c24894246f5d0aa7 (patch)
tree7ceaf87632cd0e77199928e58b91fac396ffec40 /overlay
parent09d9089ead9ceec19888251807db4ccd8017c9ff (diff)
overlay: Expose sampling period/frequency as a user parameter
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'overlay')
-rw-r--r--overlay/overlay.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/overlay/overlay.c b/overlay/overlay.c
index c99f58b0..3ec240db 100644
--- a/overlay/overlay.c
+++ b/overlay/overlay.c
@@ -708,6 +708,21 @@ static void signal_snapshot(int sig)
take_snapshot = sig;
}
+static int get_sample_period(struct config *config)
+{
+ const char *value;
+
+ value = config_get_value(config, "sampling", "period");
+ if (value && atoi(value) > 0)
+ return atoi(value);
+
+ value = config_get_value(config, "sampling", "frequency");
+ if (value && atoi(value) > 0)
+ return 1000000 / atoi(value);
+
+ return 500000;
+}
+
int main(int argc, char **argv)
{
static struct option long_options[] = {
@@ -718,7 +733,7 @@ int main(int argc, char **argv)
};
struct overlay_context ctx;
struct config config;
- int index;
+ int index, sample_period;
int i;
config_init(&config);
@@ -760,10 +775,10 @@ int main(int argc, char **argv)
init_gpu_freq(&ctx, &ctx.gpu_freq);
init_gem_objects(&ctx, &ctx.gem_objects);
+ sample_period = get_sample_period(&config);
+
i = 0;
while (1) {
- usleep(500*1000);
-
ctx.cr = cairo_create(ctx.surface);
cairo_set_operator(ctx.cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(ctx.cr);
@@ -797,6 +812,8 @@ int main(int argc, char **argv)
cairo_surface_write_to_png(ctx.surface, buf);
take_snapshot = 0;
}
+
+ usleep(sample_period);
}
return 0;