diff options
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"); |