From: Philippe CORNU <philippe.cornu@st.com>
To: Yannick FERTRE <yannick.fertre@st.com>,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
Vincent ABRIOU <vincent.abriou@st.com>,
"David Airlie" <airlied@linux.ie>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Alexandre TORGUE <alexandre.torgue@st.com>
Subject: Re: [PATCH] drm/stm: ltdc: add mode_valid()
Date: Fri, 27 Apr 2018 12:59:50 +0000 [thread overview]
Message-ID: <e1f4db2b-a409-3557-5ebd-494fb08a95d1@st.com> (raw)
In-Reply-To: <c3470496-e7ff-18e6-633a-fc899ee15e17@st.com>
On 04/25/2018 09:12 AM, Yannick FERTRE wrote:
> Hi Philippe,
>
> Reviewed-by: Yannick Fertré <yannick.fertre@st.com>
>
Applied on drm-misc-next.
Many thanks,
Philippe :-)
> On 04/17/2018 01:40 PM, Philippe Cornu wrote:
>> Add mode_valid() function to filter modes according to available
>> pll clock values and "preferred" modes. It is particularly
>> useful for hdmi modes that require precise pixel clocks.
>>
>> Note that "preferred" modes are always accepted:
>> - this is important for panels because panel clock tolerances are
>> bigger than hdmi ones and there is no reason to not accept them
>> (the fps may vary a little but it is not a problem).
>> - the hdmi preferred mode will be accepted too, but userland will
>> be able to use others hdmi "valid" modes if necessary.
>>
>> Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
>> ---
>> drivers/gpu/drm/stm/ltdc.c | 38 ++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 38 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
>> index 014cef8cef37..616191fe98ae 100644
>> --- a/drivers/gpu/drm/stm/ltdc.c
>> +++ b/drivers/gpu/drm/stm/ltdc.c
>> @@ -445,6 +445,43 @@ static void ltdc_crtc_atomic_disable(struct drm_crtc *crtc,
>> reg_set(ldev->regs, LTDC_SRCR, SRCR_IMR);
>> }
>>
>> +#define CLK_TOLERANCE_HZ 50
>> +
>> +static enum drm_mode_status
>> +ltdc_crtc_mode_valid(struct drm_crtc *crtc,
>> + const struct drm_display_mode *mode)
>> +{
>> + struct ltdc_device *ldev = crtc_to_ltdc(crtc);
>> + int target = mode->clock * 1000;
>> + int target_min = target - CLK_TOLERANCE_HZ;
>> + int target_max = target + CLK_TOLERANCE_HZ;
>> + int result;
>> +
>> + /*
>> + * Accept all "preferred" modes:
>> + * - this is important for panels because panel clock tolerances are
>> + * bigger than hdmi ones and there is no reason to not accept them
>> + * (the fps may vary a little but it is not a problem).
>> + * - the hdmi preferred mode will be accepted too, but userland will
>> + * be able to use others hdmi "valid" modes if necessary.
>> + */
>> + if (mode->type & DRM_MODE_TYPE_PREFERRED)
>> + return MODE_OK;
>> +
>> + result = clk_round_rate(ldev->pixel_clk, target);
>> +
>> + DRM_DEBUG_DRIVER("clk rate target %d, available %d\n", target, result);
>> +
>> + /*
>> + * Filter modes according to the clock value, particularly useful for
>> + * hdmi modes that require precise pixel clocks.
>> + */
>> + if (result < target_min || result > target_max)
>> + return MODE_CLOCK_RANGE;
>> +
>> + return MODE_OK;
>> +}
>> +
>> static bool ltdc_crtc_mode_fixup(struct drm_crtc *crtc,
>> const struct drm_display_mode *mode,
>> struct drm_display_mode *adjusted_mode)
>> @@ -559,6 +596,7 @@ static void ltdc_crtc_atomic_flush(struct drm_crtc *crtc,
>> }
>>
>> static const struct drm_crtc_helper_funcs ltdc_crtc_helper_funcs = {
>> + .mode_valid = ltdc_crtc_mode_valid,
>> .mode_fixup = ltdc_crtc_mode_fixup,
>> .mode_set_nofb = ltdc_crtc_mode_set_nofb,
>> .atomic_flush = ltdc_crtc_atomic_flush,
prev parent reply other threads:[~2018-04-27 13:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 11:40 Philippe Cornu
2018-04-25 7:12 ` Yannick FERTRE
2018-04-27 12:59 ` Philippe CORNU [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1f4db2b-a409-3557-5ebd-494fb08a95d1@st.com \
--to=philippe.cornu@st.com \
--cc=airlied@linux.ie \
--cc=alexandre.torgue@st.com \
--cc=benjamin.gaignard@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vincent.abriou@st.com \
--cc=yannick.fertre@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®