drm: rcar-du: Improve non-DPLL clock selection
authorJacopo Mondi <jacopo@jmondi.org>
Mon, 20 Aug 2018 15:26:17 +0000 (17:26 +0200)
committerLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Sat, 15 Sep 2018 14:28:26 +0000 (17:28 +0300)
commit8c74c4561f05f57fca2957b1d98676a0454df1ca
tree7e234939fdbe894baa09f33a57bb73d92b284fe2
parent7281e6c6a5bdbde9cae6eb3c6d2bf2706b94807d
drm: rcar-du: Improve non-DPLL clock selection

DU channels not equipped with a DPLL use an SoC internal (provided by
the CPG) or external clock source combined with a DU internal divider to
generate the desired output dot clock frequency.

The current clock selection procedure does not fully exploit the ability
of external clock sources to generate the exact dot clock frequency by
themselves, but relies instead on tuning the internal DU clock divider
only, resulting in a less precise clock generation process.

When possible, and desirable, ask the external clock source for the
exact output dot clock frequency, and select the clock source that
produces the frequency closest to the desired output dot clock.

This patch specifically targets platforms (like Salvator-X[S] and ULCBs)
where the DU's input dotclock.in is generated by the versaclock VC5
clock source, which is capable of generating the exact rate the DU needs
as pixel clock output.

This patch fixes higher resolution modes which requires an high pixel
clock output currently not working on non-HDMI DU channel (such as
1920x1080@60Hz on the VGA output).

Fixes: 1b30dbde8596 ("drm: rcar-du: Add support for external pixel clock")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
[Factor out code to a helper function]
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
drivers/gpu/drm/rcar-du/rcar_du_crtc.c