From: Damien Lespiau <damien.lespiau@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 12/22] drm: Factor out common CRTC viewport checking code
Date: Wed, 25 Sep 2013 16:45:30 +0100 [thread overview]
Message-ID: <1380123940-14340-13-git-send-email-damien.lespiau@intel.com> (raw)
In-Reply-To: <1380123940-14340-1-git-send-email-damien.lespiau@intel.com>
Both setcrtc and page_flip are checking that the framebuffer is big
enough for the defined crtc viewport (x, y, hdisplay, vdisplay). Factor
that code out in a single function.
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
drivers/gpu/drm/drm_crtc.c | 70 ++++++++++++++++++++++++----------------------
1 file changed, 37 insertions(+), 33 deletions(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 090415f..db05864 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2063,6 +2063,37 @@ int drm_mode_set_config_internal(struct drm_mode_set *set)
}
EXPORT_SYMBOL(drm_mode_set_config_internal);
+/*
+ * Checks that the framebuffer is big enough for the CRTC viewport
+ * (x, y, hdisplay, vdisplay)
+ */
+static int drm_crtc_check_viewport(const struct drm_crtc *crtc,
+ int x, int y,
+ const struct drm_display_mode *mode,
+ const struct drm_framebuffer *fb)
+
+{
+ int hdisplay, vdisplay;
+
+ hdisplay = mode->hdisplay;
+ vdisplay = mode->vdisplay;
+
+ if (crtc->invert_dimensions)
+ swap(hdisplay, vdisplay);
+
+ if (hdisplay > fb->width ||
+ vdisplay > fb->height ||
+ x > fb->width - hdisplay ||
+ y > fb->height - vdisplay) {
+ DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport %ux%u+%d+%d%s.\n",
+ fb->width, fb->height, hdisplay, vdisplay, x, y,
+ crtc->invert_dimensions ? " (inverted)" : "");
+ return -ENOSPC;
+ }
+
+ return 0;
+}
+
/**
* drm_mode_setcrtc - set CRTC configuration
* @dev: drm device for the ioctl
@@ -2110,7 +2141,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
DRM_DEBUG_KMS("[CRTC:%d]\n", crtc->base.id);
if (crtc_req->mode_valid) {
- int hdisplay, vdisplay;
/* If we have a mode we need a framebuffer. */
/* If we pass -1, set the mode with the currently bound fb */
if (crtc_req->fb_id == -1) {
@@ -2146,23 +2176,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
- hdisplay = mode->hdisplay;
- vdisplay = mode->vdisplay;
-
- if (crtc->invert_dimensions)
- swap(hdisplay, vdisplay);
-
- if (hdisplay > fb->width ||
- vdisplay > fb->height ||
- crtc_req->x > fb->width - hdisplay ||
- crtc_req->y > fb->height - vdisplay) {
- DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport %ux%u+%d+%d%s.\n",
- fb->width, fb->height,
- hdisplay, vdisplay, crtc_req->x, crtc_req->y,
- crtc->invert_dimensions ? " (inverted)" : "");
- ret = -ENOSPC;
+ ret = drm_crtc_check_viewport(crtc, crtc_req->x, crtc_req->y,
+ mode, fb);
+ if (ret)
goto out;
- }
+
}
if (crtc_req->count_connectors == 0 && mode) {
@@ -3579,7 +3597,6 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
struct drm_framebuffer *fb = NULL, *old_fb = NULL;
struct drm_pending_vblank_event *e = NULL;
unsigned long flags;
- int hdisplay, vdisplay;
int ret = -EINVAL;
if (page_flip->flags & ~DRM_MODE_PAGE_FLIP_FLAGS ||
@@ -3611,22 +3628,9 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
if (!fb)
goto out;
- hdisplay = crtc->mode.hdisplay;
- vdisplay = crtc->mode.vdisplay;
-
- if (crtc->invert_dimensions)
- swap(hdisplay, vdisplay);
-
- if (hdisplay > fb->width ||
- vdisplay > fb->height ||
- crtc->x > fb->width - hdisplay ||
- crtc->y > fb->height - vdisplay) {
- DRM_DEBUG_KMS("Invalid fb size %ux%u for CRTC viewport %ux%u+%d+%d%s.\n",
- fb->width, fb->height, hdisplay, vdisplay, crtc->x, crtc->y,
- crtc->invert_dimensions ? " (inverted)" : "");
- ret = -ENOSPC;
+ ret = drm_crtc_check_viewport(crtc, crtc->x, crtc->y, &crtc->mode, fb);
+ if (ret)
goto out;
- }
if (crtc->fb->pixel_format != fb->pixel_format) {
DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n");
--
1.8.3.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2013-09-25 15:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-25 15:45 HDMI stereo support v6 Damien Lespiau
2013-09-25 15:45 ` [PATCH 01/22] drm: Move the GET_CAP macros next to the corresponding ioctl structure Damien Lespiau
2013-09-25 15:45 ` [PATCH 02/22] drm: Add a SET_CLIENT_CAP ioctl Damien Lespiau
2013-09-25 15:45 ` [PATCH 03/22] drm: Add HDMI stereo 3D flags to struct drm_mode_modeinfo Damien Lespiau
2013-09-25 15:45 ` [PATCH 04/22] drm: Add a STEREO_3D capability to the SET_CLIENT_CAP ioctl Damien Lespiau
2013-09-25 15:45 ` [PATCH 05/22] drm/edid: Expose mandatory stereo modes for HDMI sinks Damien Lespiau
2013-09-25 15:45 ` [PATCH 06/22] drm: Extract add_hdmi_mode() out of do_hdmi_vsdb_modes() Damien Lespiau
2013-09-25 15:45 ` [PATCH 07/22] drm: Reject modes with more than 1 stereo flags set Damien Lespiau
2013-09-25 15:45 ` [PATCH 08/22] drm: Set the relevant infoframe field when scanning out a 3D mode Damien Lespiau
2013-09-25 15:45 ` [PATCH 09/22] drm: Make drm_match_cea_mode() return the underlying 2D VIC for 3d modes Damien Lespiau
2013-09-25 15:45 ` [PATCH 10/22] drm: Carry over the stereo flags when adding the alternate mode Damien Lespiau
2013-09-25 15:45 ` [PATCH 11/22] drm: Make exposing stereo modes a per-connector opt-in Damien Lespiau
2013-09-25 15:45 ` Damien Lespiau [this message]
2013-09-25 15:45 ` [PATCH 13/22] drm: Check the fb size against the adjusted v/hdisplay for stereo modes Damien Lespiau
2013-09-25 15:45 ` [PATCH 14/22] drm: Remove clock_index from struct drm_display_mode Damien Lespiau
2013-09-25 15:45 ` [PATCH 15/22] drm: Remove synth_clock " Damien Lespiau
2013-09-25 15:45 ` [PATCH 16/22] drm: Introduce a crtc_clock for " Damien Lespiau
2013-09-25 15:45 ` [PATCH 17/22] drm: Implement timings adjustments for frame packing Damien Lespiau
2013-09-25 15:45 ` [PATCH 18/22] drm/i915: Use crtc_clock in intel_dump_crtc_timings() Damien Lespiau
2013-09-25 15:45 ` [PATCH 19/22] drm/i915: Use crtc_clock with the adjusted mode Damien Lespiau
2013-09-25 15:45 ` [PATCH 20/22] drm/i915: Ask the DRM core do make stereo timings adjustements Damien Lespiau
2013-09-25 15:45 ` [PATCH 21/22] drm/i915: Prefer crtc_{h|v}display for pipe src dimensions Damien Lespiau
2013-09-25 15:45 ` [PATCH 22/22] drm/i915: Allow stereo modes on HDMI Damien Lespiau
2013-09-25 16:47 ` Upstreaming the stereo v6 series Damien Lespiau
2013-09-26 9:40 ` Daniel Vetter
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=1380123940-14340-13-git-send-email-damien.lespiau@intel.com \
--to=damien.lespiau@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
/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