From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH 10/11] drm/i915: Add 180 degree primary plane rotation support Date: Mon, 3 Feb 2014 14:00:48 +0200 Message-ID: <20140203120048.GD3891@intel.com> References: <1391195447-8744-1-git-send-email-sagar.a.kamble@intel.com> <1391195447-8744-11-git-send-email-sagar.a.kamble@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id DDB266ED7 for ; Mon, 3 Feb 2014 06:38:43 -0800 (PST) Content-Disposition: inline In-Reply-To: <1391195447-8744-11-git-send-email-sagar.a.kamble@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: sagar.a.kamble@intel.com Cc: intel-gfx@lists.freedesktop.org, Uma Shankar List-Id: intel-gfx@lists.freedesktop.org On Sat, Feb 01, 2014 at 12:40:46AM +0530, sagar.a.kamble@intel.com wrote: > From: Sagar Kamble > = > Primary planes support 180 degree rotation. Expose the feature > through rotation drm property. > = > Signed-off-by: Uma Shankar > Signed-off-by: Sagar Kamble > Tested-by: Sagar Kamble > --- > drivers/gpu/drm/i915/i915_reg.h | 1 + > drivers/gpu/drm/i915/intel_display.c | 54 ++++++++++++++++++++++++++++++= ++++-- > drivers/gpu/drm/i915/intel_drv.h | 2 ++ > 3 files changed, 55 insertions(+), 2 deletions(-) > = > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_= reg.h > index 57906c5..d3000c4 100644 > --- a/drivers/gpu/drm/i915/i915_reg.h > +++ b/drivers/gpu/drm/i915/i915_reg.h > @@ -3553,6 +3553,7 @@ > #define DISPPLANE_NO_LINE_DOUBLE 0 > #define DISPPLANE_STEREO_POLARITY_FIRST 0 > #define DISPPLANE_STEREO_POLARITY_SECOND (1<<18) > +#define DISPPLANE_ROTATE_180 (1<<15) > #define DISPPLANE_TRICKLE_FEED_DISABLE (1<<14) /* Ironlake */ > #define DISPPLANE_TILED (1<<10) > #define _DSPAADDR (dev_priv->info->display_mmio_offset + 0x70184) > diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/= intel_display.c > index 4d4a0d9..483de59 100644 > --- a/drivers/gpu/drm/i915/intel_display.c > +++ b/drivers/gpu/drm/i915/intel_display.c > @@ -2037,6 +2037,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc,= struct drm_framebuffer *fb, > unsigned long linear_offset; > u32 dspcntr; > u32 reg; > + int pixel_size; > = > switch (plane) { > case 0: > @@ -2047,6 +2048,7 @@ static int i9xx_update_plane(struct drm_crtc *crtc,= struct drm_framebuffer *fb, > return -EINVAL; > } > = > + pixel_size =3D drm_format_plane_cpp(fb->pixel_format, 0); > intel_fb =3D to_intel_framebuffer(fb); > obj =3D intel_fb->obj; > = > @@ -2054,6 +2056,8 @@ static int i9xx_update_plane(struct drm_crtc *crtc,= struct drm_framebuffer *fb, > dspcntr =3D I915_READ(reg); > /* Mask out pixel format bits in case we change it */ > dspcntr &=3D ~DISPPLANE_PIXFORMAT_MASK; > + dspcntr &=3D ~DISPPLANE_ROTATE_180; > + > switch (fb->pixel_format) { > case DRM_FORMAT_C8: > dspcntr |=3D DISPPLANE_8BPP; > @@ -2095,8 +2099,6 @@ static int i9xx_update_plane(struct drm_crtc *crtc,= struct drm_framebuffer *fb, > if (IS_G4X(dev)) > dspcntr |=3D DISPPLANE_TRICKLE_FEED_DISABLE; > = > - I915_WRITE(reg, dspcntr); > - > linear_offset =3D y * fb->pitches[0] + x * (fb->bits_per_pixel / 8); > = > if (INTEL_INFO(dev)->gen >=3D 4) { > @@ -2109,6 +2111,17 @@ static int i9xx_update_plane(struct drm_crtc *crtc= , struct drm_framebuffer *fb, > intel_crtc->dspaddr_offset =3D linear_offset; > } > = > + if (intel_crtc->rotation =3D=3D BIT(DRM_ROTATE_180)) { > + dspcntr |=3D DISPPLANE_ROTATE_180; > + > + x +=3D (fb->width - 1); > + y +=3D (fb->height - 1); > + linear_offset +=3D (fb->height - 1) * fb->pitches[0] + > + fb->width * pixel_size; > + } > + > + I915_WRITE(reg, dspcntr); > + > DRM_DEBUG_KMS("Writing base %08lX %08lX %d %d %d\n", > i915_gem_obj_ggtt_offset(obj), linear_offset, x, y, > fb->pitches[0]); > @@ -8748,6 +8761,31 @@ free_work: > return ret; > } > = > +static int intel_crtc_set_property(struct drm_crtc *crtc, > + struct drm_property *prop, > + uint64_t val) > +{ > + struct drm_device *dev =3D crtc->dev; > + struct drm_i915_private *dev_priv =3D dev->dev_private; > + struct intel_crtc *intel_crtc =3D to_intel_crtc(crtc); > + uint64_t old_val; > + int ret =3D -ENOENT; > + > + if (prop =3D=3D dev_priv->rotation_property) { > + /* exactly one rotation angle please */ > + if (hweight32(val & 0xf) !=3D 1) > + return -EINVAL; > + > + old_val =3D intel_crtc->rotation; > + intel_crtc->rotation =3D val; Couple of other things we'd need to do here is check if the crtc is even active, since calling .update_plane() on an inactive crtc would oops. Also we need to wait for pending page flips to make sure we don't overtake them. Additionall the FBC code would need some rotation checks since FBC doesn't work with a rotated plane on certain generations. > + ret =3D dev_priv->display.update_plane(crtc, crtc->fb, 0, 0); > + if (ret) > + intel_crtc->rotation =3D old_val; > + } > + > + return ret; > +} > + > static struct drm_crtc_helper_funcs intel_helper_funcs =3D { > .mode_set_base_atomic =3D intel_pipe_set_base_atomic, > .load_lut =3D intel_crtc_load_lut, > @@ -10160,6 +10198,7 @@ static const struct drm_crtc_funcs intel_crtc_fun= cs =3D { > .set_config =3D intel_crtc_set_config, > .destroy =3D intel_crtc_destroy, > .page_flip =3D intel_crtc_page_flip, > + .set_property =3D intel_crtc_set_property > }; > = > static void intel_cpu_pll_init(struct drm_device *dev) > @@ -10288,6 +10327,7 @@ static void intel_crtc_init(struct drm_device *de= v, int pipe) > */ > intel_crtc->pipe =3D pipe; > intel_crtc->plane =3D pipe; > + intel_crtc->rotation =3D BIT(DRM_ROTATE_0); > if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4) { > DRM_DEBUG_KMS("swapping pipes & planes for FBC\n"); > intel_crtc->plane =3D !pipe; > @@ -10298,6 +10338,16 @@ static void intel_crtc_init(struct drm_device *d= ev, int pipe) > dev_priv->plane_to_crtc_mapping[intel_crtc->plane] =3D &intel_crtc->bas= e; > dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] =3D &intel_crtc->base; > = > + if (!dev_priv->rotation_property) > + dev_priv->rotation_property =3D > + drm_mode_create_rotation_property(dev, > + BIT(DRM_ROTATE_0) | > + BIT(DRM_ROTATE_180)); > + if (dev_priv->rotation_property) > + drm_object_attach_property(&intel_crtc->base.base, > + dev_priv->rotation_property, > + intel_crtc->rotation); > + > drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); > } > = > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/inte= l_drv.h > index 7a79b8e..02dfdb6 100644 > --- a/drivers/gpu/drm/i915/intel_drv.h > +++ b/drivers/gpu/drm/i915/intel_drv.h > @@ -331,6 +331,8 @@ struct intel_crtc { > struct drm_crtc base; > enum pipe pipe; > enum plane plane; > + unsigned int rotation; > + > u8 lut_r[256], lut_g[256], lut_b[256]; > /* > * Whether the crtc and the connected output pipeline is active. Implies > -- = > 1.8.5 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- = Ville Syrj=E4l=E4 Intel OTC