From: John Stultz <john.stultz@linaro.org>
To: lkml <linux-kernel@vger.kernel.org>
Cc: John Stultz <john.stultz@linaro.org>,
Daniel Vetter <daniel.vetter@intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Sean Paul <seanpaul@chromium.org>,
David Airlie <airlied@linux.ie>, Rob Clark <robdclark@gmail.com>,
Xinliang Liu <xinliang.liu@linaro.org>,
Xinliang Liu <z.liuxinliang@hisilicon.com>,
Rongrong Zou <zourongrong@gmail.com>,
Xinwei Kong <kong.kongxinwei@hisilicon.com>,
Chen Feng <puck.chen@hisilicon.com>,
Archit Taneja <architt@codeaurora.org>,
dri-devel@lists.freedesktop.org
Subject: [RFC][PATCH 1/2] drm/probe-helper: Add mode_valid check to drm_crtc_helper_funcs
Date: Tue, 14 Feb 2017 11:25:01 -0800 [thread overview]
Message-ID: <1487100302-9445-2-git-send-email-john.stultz@linaro.org> (raw)
In-Reply-To: <1487100302-9445-1-git-send-email-john.stultz@linaro.org>
Currently, on the hikey board, we have the adv7511 bridge wired
up to the kirin ade drm driver. Unfortunately, the kirin ade
core cannot generate accurate byteclocks for all pixel clock
values.
Thus if a mode clock is selected that we cannot calculate a
matching byteclock, the device will boot with a blank screen.
Unfortunately, currently the only place we can properly check
potential modes for this issue in the connector mode_valid
helper. Again, hikey uses the adv7511 bridge, which is shared
between a number of different devices, so its improper to put
restrictions caused by the kirin drm driver in the adv7511
logic.
So this patch tries to correct for that, by adding some
infrastructure so that the drm_crtc_helper_funcs can optionally
implement a mode_valid check, so that the probe helpers can
check to make sure there are not any restrictions at the crtc
level as well.
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: David Airlie <airlied@linux.ie>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Xinliang Liu <xinliang.liu@linaro.org>
Cc: Xinliang Liu <z.liuxinliang@hisilicon.com>
Cc: Rongrong Zou <zourongrong@gmail.com>
Cc: Xinwei Kong <kong.kongxinwei@hisilicon.com>
Cc: Chen Feng <puck.chen@hisilicon.com>
Cc: Archit Taneja <architt@codeaurora.org>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz <john.stultz@linaro.org>
---
drivers/gpu/drm/drm_probe_helper.c | 24 ++++++++++++++++++++++++
include/drm/drm_modeset_helper_vtables.h | 26 ++++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index cf8f012..a808348 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -170,6 +170,28 @@ drm_connector_detect(struct drm_connector *connector, bool force)
connector_status_connected;
}
+static enum drm_mode_status
+drm_connector_check_crtc_modes(struct drm_connector *connector,
+ struct drm_display_mode *mode)
+{
+ struct drm_device *dev = connector->dev;
+ const struct drm_crtc_helper_funcs *crtc_funcs;
+ struct drm_crtc *c;
+
+ if (mode->status != MODE_OK)
+ return mode->status;
+
+ /* Check all the crtcs on a connector to make sure the mode is valid */
+ drm_for_each_crtc(c, dev) {
+ crtc_funcs = c->helper_private;
+ if (crtc_funcs && crtc_funcs->mode_valid)
+ mode->status = crtc_funcs->mode_valid(c, mode);
+ if (mode->status != MODE_OK)
+ break;
+ }
+ return mode->status;
+}
+
/**
* drm_helper_probe_single_connector_modes - get complete set of display modes
* @connector: connector to probe
@@ -338,6 +360,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
if (mode->status == MODE_OK && connector_funcs->mode_valid)
mode->status = connector_funcs->mode_valid(connector,
mode);
+
+ mode->status = drm_connector_check_crtc_modes(connector, mode);
}
prune:
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
index 69c3974..53ca0e4 100644
--- a/include/drm/drm_modeset_helper_vtables.h
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -105,6 +105,32 @@ struct drm_crtc_helper_funcs {
void (*commit)(struct drm_crtc *crtc);
/**
+ * @mode_valid:
+ *
+ * Callback to validate a mode for a crtc, irrespective of the
+ * specific display configuration.
+ *
+ * This callback is used by the probe helpers to filter the mode list
+ * (which is usually derived from the EDID data block from the sink).
+ * See e.g. drm_helper_probe_single_connector_modes().
+ *
+ * NOTE:
+ *
+ * This only filters the mode list supplied to userspace in the
+ * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and
+ * ask the kernel to use them. It this case the atomic helpers or legacy
+ * CRTC helpers will not call this function. Drivers therefore must
+ * still fully validate any mode passed in in a modeset request.
+ *
+ * RETURNS:
+ *
+ * Either MODE_OK or one of the failure reasons in enum
+ * &drm_mode_status.
+ */
+ enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
+ struct drm_display_mode *mode);
+
+ /**
* @mode_fixup:
*
* This callback is used to validate a mode. The parameter mode is the
--
2.7.4
next prev parent reply other threads:[~2017-02-14 19:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 19:25 [RFC][PATCH 0/2] Add mode_valid drm_crtc_helper_funcs for HiKey John Stultz
2017-02-14 19:25 ` John Stultz [this message]
2017-02-14 19:38 ` [RFC][PATCH 1/2] drm/probe-helper: Add mode_valid check to drm_crtc_helper_funcs Daniel Vetter
2017-02-14 19:45 ` John Stultz
2017-02-14 20:22 ` Daniel Vetter
2017-02-14 21:03 ` John Stultz
2017-02-14 21:42 ` Daniel Vetter
2017-02-15 16:54 ` Maxime Ripard
2017-02-14 19:51 ` Ville Syrjälä
2017-02-14 20:32 ` Daniel Stone
2017-02-14 21:07 ` John Stultz
2017-02-14 21:49 ` Daniel Vetter
2017-02-15 2:21 ` Rob Clark
2017-02-20 22:32 ` Daniel Vetter
2017-02-28 6:03 ` John Stultz
2017-02-28 9:34 ` Daniel Vetter
2017-02-14 19:25 ` [RFC][PATCH 2/2] drm: kirin: Restrict modes to known good mode clocks John Stultz
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=1487100302-9445-2-git-send-email-john.stultz@linaro.org \
--to=john.stultz@linaro.org \
--cc=airlied@linux.ie \
--cc=architt@codeaurora.org \
--cc=daniel.vetter@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=kong.kongxinwei@hisilicon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=puck.chen@hisilicon.com \
--cc=robdclark@gmail.com \
--cc=seanpaul@chromium.org \
--cc=xinliang.liu@linaro.org \
--cc=z.liuxinliang@hisilicon.com \
--cc=zourongrong@gmail.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
Powered by JetHome