aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2014-12-22 01:30:13 -0500
committerBen Skeggs <bskeggs@redhat.com>2015-01-21 21:14:57 -0500
commita91d322120a65ec5ada5518d948fda84aa87796f (patch)
tree421cbf7b775f1f32f51bcf1ddbaa6d77af7647a6
parent495b21761a4bf50c0453766ed8fdcfed075d43ff (diff)
drm/nv50-/kms: move identical scaler mode fixup code into a function
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c78
1 files changed, 24 insertions, 54 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index 490b90866baf..4f544f3683db 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -1466,6 +1466,26 @@ out:
1466} 1466}
1467 1467
1468/****************************************************************************** 1468/******************************************************************************
1469 * Encoder helpers
1470 *****************************************************************************/
1471static bool
1472nv50_encoder_mode_fixup(struct drm_encoder *encoder,
1473 const struct drm_display_mode *mode,
1474 struct drm_display_mode *adjusted_mode)
1475{
1476 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1477 struct nouveau_connector *nv_connector;
1478
1479 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1480 if (nv_connector && nv_connector->native_mode) {
1481 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE)
1482 drm_mode_copy(adjusted_mode, nv_connector->native_mode);
1483 }
1484
1485 return true;
1486}
1487
1488/******************************************************************************
1469 * DAC 1489 * DAC
1470 *****************************************************************************/ 1490 *****************************************************************************/
1471static void 1491static void
@@ -1492,26 +1512,6 @@ nv50_dac_dpms(struct drm_encoder *encoder, int mode)
1492 nvif_mthd(disp->disp, 0, &args, sizeof(args)); 1512 nvif_mthd(disp->disp, 0, &args, sizeof(args));
1493} 1513}
1494 1514
1495static bool
1496nv50_dac_mode_fixup(struct drm_encoder *encoder,
1497 const struct drm_display_mode *mode,
1498 struct drm_display_mode *adjusted_mode)
1499{
1500 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1501 struct nouveau_connector *nv_connector;
1502
1503 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1504 if (nv_connector && nv_connector->native_mode) {
1505 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
1506 int id = adjusted_mode->base.id;
1507 *adjusted_mode = *nv_connector->native_mode;
1508 adjusted_mode->base.id = id;
1509 }
1510 }
1511
1512 return true;
1513}
1514
1515static void 1515static void
1516nv50_dac_commit(struct drm_encoder *encoder) 1516nv50_dac_commit(struct drm_encoder *encoder)
1517{ 1517{
@@ -1629,7 +1629,7 @@ nv50_dac_destroy(struct drm_encoder *encoder)
1629 1629
1630static const struct drm_encoder_helper_funcs nv50_dac_hfunc = { 1630static const struct drm_encoder_helper_funcs nv50_dac_hfunc = {
1631 .dpms = nv50_dac_dpms, 1631 .dpms = nv50_dac_dpms,
1632 .mode_fixup = nv50_dac_mode_fixup, 1632 .mode_fixup = nv50_encoder_mode_fixup,
1633 .prepare = nv50_dac_disconnect, 1633 .prepare = nv50_dac_disconnect,
1634 .commit = nv50_dac_commit, 1634 .commit = nv50_dac_commit,
1635 .mode_set = nv50_dac_mode_set, 1635 .mode_set = nv50_dac_mode_set,
@@ -1834,26 +1834,6 @@ nv50_sor_dpms(struct drm_encoder *encoder, int mode)
1834 } 1834 }
1835} 1835}
1836 1836
1837static bool
1838nv50_sor_mode_fixup(struct drm_encoder *encoder,
1839 const struct drm_display_mode *mode,
1840 struct drm_display_mode *adjusted_mode)
1841{
1842 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1843 struct nouveau_connector *nv_connector;
1844
1845 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1846 if (nv_connector && nv_connector->native_mode) {
1847 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
1848 int id = adjusted_mode->base.id;
1849 *adjusted_mode = *nv_connector->native_mode;
1850 adjusted_mode->base.id = id;
1851 }
1852 }
1853
1854 return true;
1855}
1856
1857static void 1837static void
1858nv50_sor_ctrl(struct nouveau_encoder *nv_encoder, u32 mask, u32 data) 1838nv50_sor_ctrl(struct nouveau_encoder *nv_encoder, u32 mask, u32 data)
1859{ 1839{
@@ -2035,7 +2015,7 @@ nv50_sor_destroy(struct drm_encoder *encoder)
2035 2015
2036static const struct drm_encoder_helper_funcs nv50_sor_hfunc = { 2016static const struct drm_encoder_helper_funcs nv50_sor_hfunc = {
2037 .dpms = nv50_sor_dpms, 2017 .dpms = nv50_sor_dpms,
2038 .mode_fixup = nv50_sor_mode_fixup, 2018 .mode_fixup = nv50_encoder_mode_fixup,
2039 .prepare = nv50_sor_disconnect, 2019 .prepare = nv50_sor_disconnect,
2040 .commit = nv50_sor_commit, 2020 .commit = nv50_sor_commit,
2041 .mode_set = nv50_sor_mode_set, 2021 .mode_set = nv50_sor_mode_set,
@@ -2112,18 +2092,8 @@ nv50_pior_mode_fixup(struct drm_encoder *encoder,
2112 const struct drm_display_mode *mode, 2092 const struct drm_display_mode *mode,
2113 struct drm_display_mode *adjusted_mode) 2093 struct drm_display_mode *adjusted_mode)
2114{ 2094{
2115 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 2095 if (!nv50_encoder_mode_fixup(encoder, mode, adjusted_mode))
2116 struct nouveau_connector *nv_connector; 2096 return false;
2117
2118 nv_connector = nouveau_encoder_connector_get(nv_encoder);
2119 if (nv_connector && nv_connector->native_mode) {
2120 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
2121 int id = adjusted_mode->base.id;
2122 *adjusted_mode = *nv_connector->native_mode;
2123 adjusted_mode->base.id = id;
2124 }
2125 }
2126
2127 adjusted_mode->clock *= 2; 2097 adjusted_mode->clock *= 2;
2128 return true; 2098 return true;
2129} 2099}