diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-13 21:41:36 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-14 06:53:02 +0100 |
commit | 981aafe797f25aca4977a22f271d387b7fb4ae63 (patch) | |
tree | d3d8296aef53a10db3ed7f78fe80fd0ef737b3b7 /src/sna | |
parent | b27837d5372facde0f9f69eb8df664d2798f0911 (diff) |
sna: Enable TearFree by default for systems with PSR
Panel Self-Refresh requires us to avoid frontbuffer rendering in order
to be power efficient. This is a job for TearFree!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna')
-rw-r--r-- | src/sna/sna.h | 1 | ||||
-rw-r--r-- | src/sna/sna_display.c | 19 | ||||
-rw-r--r-- | src/sna/sna_driver.c | 14 |
3 files changed, 33 insertions, 1 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index d0bb6556..a532b4af 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -419,6 +419,7 @@ struct sna { bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna); bool sna_mode_fake_init(struct sna *sna, int num_fake); +bool sna_mode_wants_tear_free(struct sna *sna); void sna_mode_adjust_frame(struct sna *sna, int x, int y); extern void sna_mode_discover(struct sna *sna); extern void sna_mode_check(struct sna *sna); diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index eeab3498..e1839fcc 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -5200,6 +5200,25 @@ bool sna_mode_pre_init(ScrnInfoPtr scrn, struct sna *sna) return scrn->modes != NULL; } +bool +sna_mode_wants_tear_free(struct sna *sna) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(sna->scrn); + int i; + + for (i = 0; i < sna->mode.num_real_output; i++) { + struct sna_output *output = to_sna_output(config->output[i]); + int id = find_property(sna, output, "Panel Self-Refresh"); + if (id !=-1 && output->prop_values[id] != -1) { + DBG(("%s: Panel Self-Refresh detected on %s\n", + __FUNCTION__, config->output[i]->name)); + return true; + } + } + + return false; +} + void sna_mode_close(struct sna *sna) { diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 4df93eb4..79572a17 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -475,6 +475,18 @@ static void setup_dri(struct sna *sna) #endif } +static bool enable_tear_free(struct sna *sna) +{ + /* Under certain conditions, we should enable TearFree by default, + * for example when the hardware requires pageflipping to run within + * its power/performance budget. + */ + if (sna_mode_wants_tear_free(sna)) + return true; + + return ENABLE_TEAR_FREE; +} + /** * This is called before ScreenInit to do any require probing of screen * configuration. @@ -654,7 +666,7 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags) scrn->currentMode = scrn->modes; if (sna->flags & SNA_HAS_FLIP && - xf86ReturnOptValBool(sna->Options, OPTION_TEAR_FREE, ENABLE_TEAR_FREE)) + xf86ReturnOptValBool(sna->Options, OPTION_TEAR_FREE, enable_tear_free(sna))) sna->flags |= SNA_TEAR_FREE; xf86DrvMsg(scrn->scrnIndex, X_CONFIG, "TearFree %sabled\n", sna->flags & SNA_TEAR_FREE ? "en" : "dis"); |