diff options
author | Michel Dänzer <michel.daenzer@amd.com> | 2016-11-10 12:28:03 +0900 |
---|---|---|
committer | Michel Dänzer <michel.daenzer@amd.com> | 2016-11-10 12:28:03 +0900 |
commit | 257be5b0853814a557a5337878a4311acbc89856 (patch) | |
tree | d5ff34ba023e309e212d5b093555d79c061c3254 /src | |
parent | 1352a1d2f78cb0433d421ef86bfce2a5a1646807 (diff) |
Refactor amdgpu_mode_hotplug
Preparation for the next change, no functional change intended.
(Cherry picked from radeon commit 35bec4937d89b48a79acfcb4f814b7370cb631b2)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/drmmode_display.c | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 2d36881..0ca78e0 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -2365,6 +2365,36 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn) return TRUE; } +static Bool +drmmode_find_output(ScrnInfoPtr scrn, int output_id, int *num_dvi, + int *num_hdmi) +{ + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i; + + for (i = 0; i < config->num_output; i++) { + xf86OutputPtr output = config->output[i]; + drmmode_output_private_ptr drmmode_output = output->driver_private; + + if (drmmode_output->output_id == output_id) { + switch(drmmode_output->mode_output->connector_type) { + case DRM_MODE_CONNECTOR_DVII: + case DRM_MODE_CONNECTOR_DVID: + case DRM_MODE_CONNECTOR_DVIA: + (*num_dvi)++; + break; + case DRM_MODE_CONNECTOR_HDMIA: + case DRM_MODE_CONNECTOR_HDMIB: + (*num_hdmi)++; + break; + } + + return TRUE; + } + } + + return FALSE; +} void amdgpu_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode) @@ -2413,35 +2443,14 @@ restart_destroy: for (s = 0; !found && s < xf86NumScreens; s++) { ScrnInfoPtr loop_scrn = xf86Screens[s]; - xf86CrtcConfigPtr loop_config = - XF86_CRTC_CONFIG_PTR(loop_scrn); if (strcmp(loop_scrn->driverName, scrn->driverName) || AMDGPUEntPriv(loop_scrn) != pAMDGPUEnt) continue; - for (j = 0; !found && j < loop_config->num_output; j++) { - xf86OutputPtr output = loop_config->output[j]; - drmmode_output_private_ptr drmmode_output; - - drmmode_output = output->driver_private; - if (mode_res->connectors[i] == - drmmode_output->output_id) { - found = TRUE; - - switch(drmmode_output->mode_output->connector_type) { - case DRM_MODE_CONNECTOR_DVII: - case DRM_MODE_CONNECTOR_DVID: - case DRM_MODE_CONNECTOR_DVIA: - num_dvi++; - break; - case DRM_MODE_CONNECTOR_HDMIA: - case DRM_MODE_CONNECTOR_HDMIB: - num_hdmi++; - break; - } - } - } + found = drmmode_find_output(loop_scrn, + mode_res->connectors[i], + &num_dvi, &num_hdmi); } if (found) continue; |