From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Damien Lespiau <damien.lespiau@intel.com>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 14/20] drm: Implement timings adjustments for frame packing
Date: Fri, 20 Sep 2013 16:47:53 +0300 [thread overview]
Message-ID: <20130920134753.GP4531@intel.com> (raw)
In-Reply-To: <1379608835-11760-15-git-send-email-damien.lespiau@intel.com>
On Thu, Sep 19, 2013 at 05:40:29PM +0100, Damien Lespiau wrote:
> When using the frame packing and a single big framebuffer, some hardware
> requires that we do everything like if we were scanning out the big
> buffer itself. Let's instrument drm_mode_set_crtcinfo() to be able to do
> this adjustement if the driver is asking for it.
>
> Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
> drivers/gpu/drm/drm_modes.c | 51 ++++++++++++++++++++++++++++++++++++++++++++-
> include/drm/drm_crtc.h | 3 ++-
> 2 files changed, 52 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index ef26eb2..d9c5a34 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -704,15 +704,47 @@ int drm_mode_vrefresh(const struct drm_display_mode *mode)
> }
> EXPORT_SYMBOL(drm_mode_vrefresh);
>
> +static bool drm_mode_is_ntsc(const struct drm_display_mode *mode)
> +{
> + int ntsc_clock;
> +
> + ntsc_clock = DIV_ROUND_UP(mode->vtotal * mode->htotal * mode->vrefresh,
> + 1001);
> +
> + if (ntsc_clock == mode->clock)
> + return true;
> +
> + return false;
> +}
> +
> +static void drm_mode_reconstruct_crtc_clock(struct drm_display_mode *mode)
> +{
> + int clock;
> +
> + clock = mode->crtc_vtotal * mode->crtc_htotal *
> + drm_mode_vrefresh(mode) / 1000;
> +
> + if (drm_mode_is_ntsc(mode))
> + mode->crtc_clock = DIV_ROUND_UP(clock * 1000, 1001);
> + else
> + mode->crtc_clock = clock;
> +}
> +
> /**
> * drm_mode_set_crtcinfo - set CRTC modesetting parameters
> * @p: mode
> - * @adjust_flags: unused? (FIXME)
> + * @adjust_flags: a combination of adjustment flags
> *
> * LOCKING:
> * None.
> *
> * Setup the CRTC modesetting parameters for @p, adjusting if necessary.
> + *
> + * - The CRTC_INTERLACE_HALVE_V flag can be used to halve vertical timings of
> + * interlaced modes.
> + * - The CRTC_STEREO_DOUBLE flag can be used to compute the timings for
> + * buffers containing two eyes (only adjust the timings when needed, eg. for
> + * "frame packing" or "side by side full").
> */
> void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
> {
> @@ -753,6 +785,23 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
> p->crtc_vtotal *= p->vscan;
> }
>
> + if (adjust_flags & CRTC_STEREO_DOUBLE) {
> + unsigned int layout = p->flags & DRM_MODE_FLAG_3D_MASK;
> + int vactive_space;
> +
> + switch (layout) {
> + case DRM_MODE_FLAG_3D_FRAME_PACKING:
> + vactive_space = p->vtotal - p->vdisplay;
> +
> + p->crtc_vdisplay += p->vdisplay + vactive_space;
> + p->crtc_vsync_start += p->vdisplay + vactive_space;
> + p->crtc_vsync_end += p->vdisplay + vactive_space;
> + p->crtc_vtotal += p->vdisplay + vactive_space;
All of these are just '+= votal'. Maybe just write it that way and add a
comment to help the uninformed.
In fact it should be crtc_vtotal to maintain the CRTC_INTERLACE_HALVE_V
etc. adjustments already done. So even if you don't take my suggestion
of using just += crtc_vtotal, you should at least switch to
'vactive_space = p->crtc_vtotal - p->crtc_vdisplay;'
> + drm_mode_reconstruct_crtc_clock(p);
This thing loses precision and shouldn't even be needed. Just double
crtc_clock.
> + break;
> + }
> + }
> +
> p->crtc_vblank_start = min(p->crtc_vsync_start, p->crtc_vdisplay);
> p->crtc_vblank_end = max(p->crtc_vsync_end, p->crtc_vtotal);
> p->crtc_hblank_start = min(p->crtc_hsync_start, p->crtc_hdisplay);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index 73478bc..b2d08ca 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -125,7 +125,8 @@ enum drm_mode_status {
> .vscan = (vs), .flags = (f), \
> .base.type = DRM_MODE_OBJECT_MODE
>
> -#define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */
> +#define CRTC_INTERLACE_HALVE_V (1 << 0) /* halve V values for interlacing */
> +#define CRTC_STEREO_DOUBLE (1 << 1) /* adjust timings for stereo modes */
>
> struct drm_display_mode {
> /* Header */
> --
> 1.8.3.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Ville Syrjälä
Intel OTC
next prev parent reply other threads:[~2013-09-20 13:47 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 16:40 HDMI stereo support v5 Damien Lespiau
2013-09-19 16:40 ` [PATCH 01/20] drm: Add a SET_CLIENT_CAP ioctl Damien Lespiau
2013-09-19 16:40 ` [PATCH 02/20] drm: Add HDMI stereo 3D flags to struct drm_mode_modeinfo Damien Lespiau
2013-09-19 16:40 ` [PATCH 03/20] drm: Add a STEREO_3D capability to the SET_CLIENT_CAP ioctl Damien Lespiau
2013-09-19 16:40 ` [PATCH 04/20] drm/edid: Expose mandatory stereo modes for HDMI sinks Damien Lespiau
2013-09-19 16:40 ` [PATCH 05/20] drm: Extract add_hdmi_mode() out of do_hdmi_vsdb_modes() Damien Lespiau
2013-09-19 16:40 ` [PATCH 06/20] drm: Reject modes with more than 1 stereo flags set Damien Lespiau
2013-09-19 16:40 ` [PATCH 07/20] drm: Set the relevant infoframe field when scanning out a 3D mode Damien Lespiau
2013-09-19 16:40 ` [PATCH 08/20] drm: Make drm_match_cea_mode() return the underlying 2D VIC for 3d modes Damien Lespiau
2013-09-19 16:40 ` [PATCH 09/20] drm: Carry over the stereo flags when adding the alternate mode Damien Lespiau
2013-09-19 16:40 ` [PATCH 10/20] drm: Make exposing stereo modes a per-connector opt-in Damien Lespiau
2013-09-19 16:40 ` [PATCH 11/20] drm: Remove clock_index from struct drm_display_mode Damien Lespiau
2013-09-19 22:20 ` Ben Skeggs
2013-09-19 16:40 ` [PATCH 12/20] drm: Remove synth_clock " Damien Lespiau
2013-09-19 16:40 ` [PATCH 13/20] drm: Introduce a crtc_clock for " Damien Lespiau
2013-09-19 16:40 ` [PATCH 14/20] drm: Implement timings adjustments for frame packing Damien Lespiau
2013-09-20 13:47 ` Ville Syrjälä [this message]
2013-09-23 15:09 ` [PATCH] " Damien Lespiau
2013-09-19 16:40 ` [PATCH 15/20] drm/i915: Use crtc_clock in intel_dump_crtc_timings() Damien Lespiau
2013-09-19 16:40 ` [PATCH 16/20] drm/i915: Use crtc_clock with the adjusted mode Damien Lespiau
2013-09-19 16:40 ` [PATCH 17/20] drm/i915: Use adjusted_mode in the fastboot hack to disable pfit Damien Lespiau
2013-09-20 14:54 ` Ville Syrjälä
2013-09-20 15:33 ` Damien Lespiau
2013-09-20 17:01 ` Jesse Barnes
2013-09-19 16:40 ` [PATCH 18/20] drm/i915: Ask the DRM core do make stereo timings adjustements Damien Lespiau
2013-09-19 16:40 ` [PATCH 19/20] drm/i915: Prefer crtc_{h|v}display for pipe src dimensions Damien Lespiau
2013-09-19 18:49 ` [Intel-gfx] " Daniel Vetter
2013-09-19 16:40 ` [PATCH 20/20] drm/i915: Allow stereo modes on HDMI Damien Lespiau
2013-09-20 15:18 ` HDMI stereo support v5 Ville Syrjälä
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=20130920134753.GP4531@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=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;
as well as URLs for NNTP newsgroup(s).