From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH 14/20] drm: Implement timings adjustments for frame packing Date: Fri, 20 Sep 2013 16:47:53 +0300 Message-ID: <20130920134753.GP4531@intel.com> References: <1379608835-11760-1-git-send-email-damien.lespiau@intel.com> <1379608835-11760-15-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1379608835-11760-15-git-send-email-damien.lespiau@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Damien Lespiau Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org 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 > Signed-off-by: Damien Lespiau > --- > 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 =3D DIV_ROUND_UP(mode->vtotal * mode->htotal * mode->vrefres= h, > + 1001); > + > + if (ntsc_clock =3D=3D mode->clock) > + return true; > + > + return false; > +} > + > +static void drm_mode_reconstruct_crtc_clock(struct drm_display_mode *mod= e) > +{ > + int clock; > + > + clock =3D mode->crtc_vtotal * mode->crtc_htotal * > + drm_mode_vrefresh(mode) / 1000; > + > + if (drm_mode_is_ntsc(mode)) > + mode->crtc_clock =3D DIV_ROUND_UP(clock * 1000, 1001); > + else > + mode->crtc_clock =3D 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 timin= gs 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, e= g. 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 *=3D p->vscan; > } > = > + if (adjust_flags & CRTC_STEREO_DOUBLE) { > + unsigned int layout =3D p->flags & DRM_MODE_FLAG_3D_MASK; > + int vactive_space; > + > + switch (layout) { > + case DRM_MODE_FLAG_3D_FRAME_PACKING: > + vactive_space =3D p->vtotal - p->vdisplay; > + > + p->crtc_vdisplay +=3D p->vdisplay + vactive_space; > + p->crtc_vsync_start +=3D p->vdisplay + vactive_space; > + p->crtc_vsync_end +=3D p->vdisplay + vactive_space; > + p->crtc_vtotal +=3D p->vdisplay + vactive_space; All of these are just '+=3D 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 +=3D crtc_vtotal, you should at least switch to 'vactive_space =3D 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 =3D min(p->crtc_vsync_start, p->crtc_vdisplay); > p->crtc_vblank_end =3D max(p->crtc_vsync_end, p->crtc_vtotal); > p->crtc_hblank_start =3D 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 =3D (vs), .flags =3D (f), \ > .base.type =3D 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 interlacin= g */ > +#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=E4l=E4 Intel OTC