overlay: use rc6_enable to drop useless information

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-08-20 11:08:13 +01:00
parent cf62d52eb4
commit c888507b68
3 changed files with 28 additions and 8 deletions

View File

@ -20,6 +20,8 @@
#include "power.h" #include "power.h"
#include "rc6.h" #include "rc6.h"
#define is_power_of_two(x) (((x) & ((x)-1)) == 0)
const cairo_user_data_key_t overlay_key; const cairo_user_data_key_t overlay_key;
static void overlay_show(cairo_surface_t *surface) static void overlay_show(cairo_surface_t *surface)
@ -417,7 +419,6 @@ static void init_gpu_freq(struct overlay_context *ctx,
} }
rc6_init(&gf->rc6); rc6_init(&gf->rc6);
} }
static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *gf) static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *gf)
@ -454,9 +455,25 @@ static void show_gpu_freq(struct overlay_context *ctx, struct overlay_gpu_freq *
sprintf(buf, "RC6: %d%%", gf->rc6.rc6_combined); sprintf(buf, "RC6: %d%%", gf->rc6.rc6_combined);
cairo_move_to(ctx->cr, 12, y); cairo_move_to(ctx->cr, 12, y);
cairo_show_text(ctx->cr, buf); cairo_show_text(ctx->cr, buf);
if (gf->rc6.rc6_combined) { if (gf->rc6.rc6_combined && !is_power_of_two(gf->rc6.enabled)) {
sprintf(buf, " [rc6=%d%%, rc6p=%d%%, rc6pp=%d%%]", len = 0;
gf->rc6.rc6, gf->rc6.rc6p, gf->rc6.rc6pp); sprintf(buf, " (");
if (gf->rc6.enabled & 1) {
if (len)
len += sprintf(buf + 3 + len, ", ");
len += sprintf(buf + 3 + len, "rc6=%d%%", gf->rc6.rc6);
}
if (gf->rc6.enabled & 2) {
if (len)
len += sprintf(buf + 3 + len, ", ");
len += sprintf(buf + 3 + len, "rc6p=%d%%", gf->rc6.rc6p);
}
if (gf->rc6.enabled & 4) {
if (len)
len += sprintf(buf + 3 + len, ", ");
len += sprintf(buf + 3 + len, "rc6pp=%d%%", gf->rc6.rc6pp);
}
sprintf(buf + 3 + len, ")");
cairo_show_text(ctx->cr, buf); cairo_show_text(ctx->cr, buf);
} }
y += 14; y += 14;

View File

@ -63,11 +63,12 @@ int rc6_update(struct rc6 *rc6)
if (rc6->error) if (rc6->error)
return rc6->error; return rc6->error;
if (stat("/sys/class/drm/card0/power", &st) < 0)
return rc6->error = errno;
if (stat("/sys/class/drm/card0/power/rc6_residency_ms", &st) < 0) if (stat("/sys/class/drm/card0/power/rc6_residency_ms", &st) < 0)
return ENOENT; return rc6->error = ENOENT;
rc6->enabled = file_to_u64("/sys/class/drm/card0/power/rc6_enable");
if (rc6->enabled == 0)
return EAGAIN;
s->rc6_residency = file_to_u64("/sys/class/drm/card0/power/rc6_residency_ms"); s->rc6_residency = file_to_u64("/sys/class/drm/card0/power/rc6_residency_ms");
s->rc6p_residency = file_to_u64("/sys/class/drm/card0/power/rc6p_residency_ms"); s->rc6p_residency = file_to_u64("/sys/class/drm/card0/power/rc6p_residency_ms");

View File

@ -11,6 +11,8 @@ struct rc6 {
int count; int count;
int error; int error;
unsigned enabled;
uint8_t rc6; uint8_t rc6;
uint8_t rc6p; uint8_t rc6p;
uint8_t rc6pp; uint8_t rc6pp;