[PATCH v2 xf86-video-amdgpu] Don't bail from drmmode_set_desired_modes immediately

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 15, 2018 at 12:49 PM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> If we fail to find or set the mode for a CRTC, keep trying for the
> remaining CRTCs, and only return FALSE if we failed for all CRTCs that
> should be on.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>
> v2:
> Print warning messages for trouble with a particular CRTC, and an error
> message only when returning FALSE.
>
>  src/drmmode_display.c | 34 +++++++++++++++++++++++++---------
>  1 file changed, 25 insertions(+), 9 deletions(-)
>
> diff --git a/src/drmmode_display.c b/src/drmmode_display.c
> index 8ccbf735d..a17909876 100644
> --- a/src/drmmode_display.c
> +++ b/src/drmmode_display.c
> @@ -2523,6 +2523,7 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
>  {
>         xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
>         AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
> +       unsigned num_desired = 0, num_on = 0;
>         int c;
>
>         for (c = 0; c < config->num_crtc; c++) {
> @@ -2557,6 +2558,8 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
>                 if (!output)
>                         continue;
>
> +               num_desired++;
> +
>                 /* Mark that we'll need to re-set the mode for sure */
>                 memset(&crtc->mode, 0, sizeof(crtc->mode));
>                 if (!crtc->desiredMode.CrtcHDisplay) {
> @@ -2564,8 +2567,11 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
>                                                                         pScrn->
>                                                                         currentMode);
>
> -                       if (!mode)
> -                               return FALSE;
> +                       if (!mode) {
> +                               xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
> +                                          "Failed to find mode for CRTC %d\n", c);
> +                               continue;
> +                       }
>                         crtc->desiredMode = *mode;
>                         crtc->desiredRotation = RR_Rotate_0;
>                         crtc->desiredX = 0;
> @@ -2573,20 +2579,30 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode,
>                 }
>
>                 if (set_hw) {
> -                       if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode,
> -                                                        crtc->desiredRotation,
> -                                                        crtc->desiredX,
> -                                                        crtc->desiredY))
> -                               return FALSE;
> +                       if (crtc->funcs->set_mode_major(crtc, &crtc->desiredMode,
> +                                                       crtc->desiredRotation,
> +                                                       crtc->desiredX,
> +                                                       crtc->desiredY)) {
> +                               num_on++;
> +                       } else {
> +                               xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
> +                                          "Failed to set mode on CRTC %d\n", c);
> +                       }
>                 } else {
>                         crtc->mode = crtc->desiredMode;
>                         crtc->rotation = crtc->desiredRotation;
>                         crtc->x = crtc->desiredX;
>                         crtc->y = crtc->desiredY;
> -                       if (!drmmode_handle_transform(crtc))
> -                               return FALSE;
> +                       if (drmmode_handle_transform(crtc))
> +                               num_on++;
>                 }
>         }
> +
> +       if (num_on == 0 && num_desired > 0) {
> +               xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to enable any CRTC\n");
> +               return FALSE;
> +       }
> +
>         return TRUE;
>  }
>
> --
> 2.16.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux