aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c4
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h1
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h57
-rw-r--r--drivers/gpu/drm/i915/intel_display.c11
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h3
-rw-r--r--drivers/gpu/drm/i915/intel_sprite.c213
6 files changed, 275 insertions, 14 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index ebcfe2e9497f..4be58e3b8e4f 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1630,6 +1630,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1630 mutex_init(&dev_priv->rps.hw_lock); 1630 mutex_init(&dev_priv->rps.hw_lock);
1631 mutex_init(&dev_priv->modeset_restore_lock); 1631 mutex_init(&dev_priv->modeset_restore_lock);
1632 1632
1633 dev_priv->num_plane = 1;
1634 if (IS_VALLEYVIEW(dev))
1635 dev_priv->num_plane = 2;
1636
1633 ret = drm_vblank_init(dev, INTEL_INFO(dev)->num_pipes); 1637 ret = drm_vblank_init(dev, INTEL_INFO(dev)->num_pipes);
1634 if (ret) 1638 if (ret)
1635 goto out_gem_unload; 1639 goto out_gem_unload;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 5e38a2cf95f4..c895a8465611 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -926,6 +926,7 @@ typedef struct drm_i915_private {
926 bool enable_hotplug_processing; 926 bool enable_hotplug_processing;
927 927
928 int num_pch_pll; 928 int num_pch_pll;
929 int num_plane;
929 930
930 unsigned long cfb_size; 931 unsigned long cfb_size;
931 unsigned int cfb_fb; 932 unsigned int cfb_fb;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 95ad87c2981d..70d7949ecca0 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3288,6 +3288,63 @@
3288#define SPRGAMC(pipe) _PIPE(pipe, _SPRA_GAMC, _SPRB_GAMC) 3288#define SPRGAMC(pipe) _PIPE(pipe, _SPRA_GAMC, _SPRB_GAMC)
3289#define SPRSURFLIVE(pipe) _PIPE(pipe, _SPRA_SURFLIVE, _SPRB_SURFLIVE) 3289#define SPRSURFLIVE(pipe) _PIPE(pipe, _SPRA_SURFLIVE, _SPRB_SURFLIVE)
3290 3290
3291#define _SPACNTR 0x72180
3292#define SP_ENABLE (1<<31)
3293#define SP_GEAMMA_ENABLE (1<<30)
3294#define SP_PIXFORMAT_MASK (0xf<<26)
3295#define SP_FORMAT_YUV422 (0<<26)
3296#define SP_FORMAT_BGR565 (5<<26)
3297#define SP_FORMAT_BGRX8888 (6<<26)
3298#define SP_FORMAT_BGRA8888 (7<<26)
3299#define SP_FORMAT_RGBX1010102 (8<<26)
3300#define SP_FORMAT_RGBA1010102 (9<<26)
3301#define SP_FORMAT_RGBX8888 (0xe<<26)
3302#define SP_FORMAT_RGBA8888 (0xf<<26)
3303#define SP_SOURCE_KEY (1<<22)
3304#define SP_YUV_BYTE_ORDER_MASK (3<<16)
3305#define SP_YUV_ORDER_YUYV (0<<16)
3306#define SP_YUV_ORDER_UYVY (1<<16)
3307#define SP_YUV_ORDER_YVYU (2<<16)
3308#define SP_YUV_ORDER_VYUY (3<<16)
3309#define SP_TILED (1<<10)
3310#define _SPALINOFF 0x72184
3311#define _SPASTRIDE 0x72188
3312#define _SPAPOS 0x7218c
3313#define _SPASIZE 0x72190
3314#define _SPAKEYMINVAL 0x72194
3315#define _SPAKEYMSK 0x72198
3316#define _SPASURF 0x7219c
3317#define _SPAKEYMAXVAL 0x721a0
3318#define _SPATILEOFF 0x721a4
3319#define _SPACONSTALPHA 0x721a8
3320#define _SPAGAMC 0x721f4
3321
3322#define _SPBCNTR 0x72280
3323#define _SPBLINOFF 0x72284
3324#define _SPBSTRIDE 0x72288
3325#define _SPBPOS 0x7228c
3326#define _SPBSIZE 0x72290
3327#define _SPBKEYMINVAL 0x72294
3328#define _SPBKEYMSK 0x72298
3329#define _SPBSURF 0x7229c
3330#define _SPBKEYMAXVAL 0x722a0
3331#define _SPBTILEOFF 0x722a4
3332#define _SPBCONSTALPHA 0x722a8
3333#define _SPBGAMC 0x722f4
3334
3335#define SPCNTR(pipe, plane) _PIPE(pipe * 2 + plane, _SPACNTR, _SPBCNTR)
3336#define SPLINOFF(pipe, plane) _PIPE(pipe * 2 + plane, _SPALINOFF, _SPBLINOFF)
3337#define SPSTRIDE(pipe, plane) _PIPE(pipe * 2 + plane, _SPASTRIDE, _SPBSTRIDE)
3338#define SPPOS(pipe, plane) _PIPE(pipe * 2 + plane, _SPAPOS, _SPBPOS)
3339#define SPSIZE(pipe, plane) _PIPE(pipe * 2 + plane, _SPASIZE, _SPBSIZE)
3340#define SPKEYMINVAL(pipe, plane) _PIPE(pipe * 2 + plane, _SPAKEYMINVAL, _SPBKEYMINVAL)
3341#define SPKEYMSK(pipe, plane) _PIPE(pipe * 2 + plane, _SPAKEYMSK, _SPBKEYMSK)
3342#define SPSURF(pipe, plane) _PIPE(pipe * 2 + plane, _SPASURF, _SPBSURF)
3343#define SPKEYMAXVAL(pipe, plane) _PIPE(pipe * 2 + plane, _SPAKEYMAXVAL, _SPBKEYMAXVAL)
3344#define SPTILEOFF(pipe, plane) _PIPE(pipe * 2 + plane, _SPATILEOFF, _SPBTILEOFF)
3345#define SPCONSTALPHA(pipe, plane) _PIPE(pipe * 2 + plane, _SPACONSTALPHA, _SPBCONSTALPHA)
3346#define SPGAMC(pipe, plane) _PIPE(pipe * 2 + plane, _SPAGAMC, _SPBGAMC)
3347
3291/* VBIOS regs */ 3348/* VBIOS regs */
3292#define VGACNTRL 0x71400 3349#define VGACNTRL 0x71400
3293# define VGA_DISP_DISABLE (1 << 31) 3350# define VGA_DISP_DISABLE (1 << 31)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 0e172ced8f0e..2ee38660a5a5 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8867,7 +8867,7 @@ void intel_modeset_init_hw(struct drm_device *dev)
8867void intel_modeset_init(struct drm_device *dev) 8867void intel_modeset_init(struct drm_device *dev)
8868{ 8868{
8869 struct drm_i915_private *dev_priv = dev->dev_private; 8869 struct drm_i915_private *dev_priv = dev->dev_private;
8870 int i, ret; 8870 int i, j, ret;
8871 8871
8872 drm_mode_config_init(dev); 8872 drm_mode_config_init(dev);
8873 8873
@@ -8903,9 +8903,12 @@ void intel_modeset_init(struct drm_device *dev)
8903 8903
8904 for (i = 0; i < INTEL_INFO(dev)->num_pipes; i++) { 8904 for (i = 0; i < INTEL_INFO(dev)->num_pipes; i++) {
8905 intel_crtc_init(dev, i); 8905 intel_crtc_init(dev, i);
8906 ret = intel_plane_init(dev, i); 8906 for (j = 0; j < dev_priv->num_plane; j++) {
8907 if (ret) 8907 ret = intel_plane_init(dev, i, j);
8908 DRM_DEBUG_KMS("plane %d init failed: %d\n", i, ret); 8908 if (ret)
8909 DRM_DEBUG_KMS("pipe %d plane %d init failed: %d\n",
8910 i, j, ret);
8911 }
8909 } 8912 }
8910 8913
8911 intel_cpu_pll_init(dev); 8914 intel_cpu_pll_init(dev);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 18bba6e25e1e..2f451c2a14f5 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -241,6 +241,7 @@ struct intel_crtc {
241 241
242struct intel_plane { 242struct intel_plane {
243 struct drm_plane base; 243 struct drm_plane base;
244 int plane;
244 enum pipe pipe; 245 enum pipe pipe;
245 struct drm_i915_gem_object *obj; 246 struct drm_i915_gem_object *obj;
246 bool can_scale; 247 bool can_scale;
@@ -489,7 +490,7 @@ extern void intel_edp_link_config(struct intel_encoder *, int *, int *);
489extern int intel_edp_target_clock(struct intel_encoder *, 490extern int intel_edp_target_clock(struct intel_encoder *,
490 struct drm_display_mode *mode); 491 struct drm_display_mode *mode);
491extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder); 492extern bool intel_encoder_is_pch_edp(struct drm_encoder *encoder);
492extern int intel_plane_init(struct drm_device *dev, enum pipe pipe); 493extern int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
493extern void intel_flush_display_plane(struct drm_i915_private *dev_priv, 494extern void intel_flush_display_plane(struct drm_i915_private *dev_priv,
494 enum plane plane); 495 enum plane plane);
495 496
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 27df5b871be5..c7d25c5dd4e6 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -37,6 +37,174 @@
37#include "i915_drv.h" 37#include "i915_drv.h"
38 38
39static void 39static void
40vlv_update_plane(struct drm_plane *dplane, struct drm_framebuffer *fb,
41 struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
42 unsigned int crtc_w, unsigned int crtc_h,
43 uint32_t x, uint32_t y,
44 uint32_t src_w, uint32_t src_h)
45{
46 struct drm_device *dev = dplane->dev;
47 struct drm_i915_private *dev_priv = dev->dev_private;
48 struct intel_plane *intel_plane = to_intel_plane(dplane);
49 int pipe = intel_plane->pipe;
50 int plane = intel_plane->plane;
51 u32 sprctl;
52 unsigned long sprsurf_offset, linear_offset;
53 int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
54
55 sprctl = I915_READ(SPCNTR(pipe, plane));
56
57 /* Mask out pixel format bits in case we change it */
58 sprctl &= ~SP_PIXFORMAT_MASK;
59 sprctl &= ~SP_YUV_BYTE_ORDER_MASK;
60 sprctl &= ~SP_TILED;
61
62 switch (fb->pixel_format) {
63 case DRM_FORMAT_YUYV:
64 sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YUYV;
65 break;
66 case DRM_FORMAT_YVYU:
67 sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_YVYU;
68 break;
69 case DRM_FORMAT_UYVY:
70 sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_UYVY;
71 break;
72 case DRM_FORMAT_VYUY:
73 sprctl |= SP_FORMAT_YUV422 | SP_YUV_ORDER_VYUY;
74 break;
75 case DRM_FORMAT_RGB565:
76 sprctl |= SP_FORMAT_BGR565;
77 break;
78 case DRM_FORMAT_XRGB8888:
79 sprctl |= SP_FORMAT_BGRX8888;
80 break;
81 case DRM_FORMAT_ARGB8888:
82 sprctl |= SP_FORMAT_BGRA8888;
83 break;
84 case DRM_FORMAT_XBGR2101010:
85 sprctl |= SP_FORMAT_RGBX1010102;
86 break;
87 case DRM_FORMAT_ABGR2101010:
88 sprctl |= SP_FORMAT_RGBA1010102;
89 break;
90 case DRM_FORMAT_XBGR8888:
91 sprctl |= SP_FORMAT_RGBX8888;
92 break;
93 case DRM_FORMAT_ABGR8888:
94 sprctl |= SP_FORMAT_RGBA8888;
95 break;
96 default:
97 /*
98 * If we get here one of the upper layers failed to filter
99 * out the unsupported plane formats
100 */
101 BUG();
102 break;
103 }
104
105 if (obj->tiling_mode != I915_TILING_NONE)
106 sprctl |= SP_TILED;
107
108 sprctl |= SP_ENABLE;
109
110 /* Sizes are 0 based */
111 src_w--;
112 src_h--;
113 crtc_w--;
114 crtc_h--;
115
116 intel_update_sprite_watermarks(dev, pipe, crtc_w, pixel_size);
117
118 I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]);
119 I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x);
120
121 linear_offset = y * fb->pitches[0] + x * pixel_size;
122 sprsurf_offset = intel_gen4_compute_page_offset(&x, &y,
123 obj->tiling_mode,
124 pixel_size,
125 fb->pitches[0]);
126 linear_offset -= sprsurf_offset;
127
128 if (obj->tiling_mode != I915_TILING_NONE)
129 I915_WRITE(SPTILEOFF(pipe, plane), (y << 16) | x);
130 else
131 I915_WRITE(SPLINOFF(pipe, plane), linear_offset);
132
133 I915_WRITE(SPSIZE(pipe, plane), (crtc_h << 16) | crtc_w);
134 I915_WRITE(SPCNTR(pipe, plane), sprctl);
135 I915_MODIFY_DISPBASE(SPSURF(pipe, plane), obj->gtt_offset +
136 sprsurf_offset);
137 POSTING_READ(SPSURF(pipe, plane));
138}
139
140static void
141vlv_disable_plane(struct drm_plane *dplane)
142{
143 struct drm_device *dev = dplane->dev;
144 struct drm_i915_private *dev_priv = dev->dev_private;
145 struct intel_plane *intel_plane = to_intel_plane(dplane);
146 int pipe = intel_plane->pipe;
147 int plane = intel_plane->plane;
148
149 I915_WRITE(SPCNTR(pipe, plane), I915_READ(SPCNTR(pipe, plane)) &
150 ~SP_ENABLE);
151 /* Activate double buffered register update */
152 I915_MODIFY_DISPBASE(SPSURF(pipe, plane), 0);
153 POSTING_READ(SPSURF(pipe, plane));
154}
155
156static int
157vlv_update_colorkey(struct drm_plane *dplane,
158 struct drm_intel_sprite_colorkey *key)
159{
160 struct drm_device *dev = dplane->dev;
161 struct drm_i915_private *dev_priv = dev->dev_private;
162 struct intel_plane *intel_plane = to_intel_plane(dplane);
163 int pipe = intel_plane->pipe;
164 int plane = intel_plane->plane;
165 u32 sprctl;
166
167 if (key->flags & I915_SET_COLORKEY_DESTINATION)
168 return -EINVAL;
169
170 I915_WRITE(SPKEYMINVAL(pipe, plane), key->min_value);
171 I915_WRITE(SPKEYMAXVAL(pipe, plane), key->max_value);
172 I915_WRITE(SPKEYMSK(pipe, plane), key->channel_mask);
173
174 sprctl = I915_READ(SPCNTR(pipe, plane));
175 sprctl &= ~SP_SOURCE_KEY;
176 if (key->flags & I915_SET_COLORKEY_SOURCE)
177 sprctl |= SP_SOURCE_KEY;
178 I915_WRITE(SPCNTR(pipe, plane), sprctl);
179
180 POSTING_READ(SPKEYMSK(pipe, plane));
181
182 return 0;
183}
184
185static void
186vlv_get_colorkey(struct drm_plane *dplane,
187 struct drm_intel_sprite_colorkey *key)
188{
189 struct drm_device *dev = dplane->dev;
190 struct drm_i915_private *dev_priv = dev->dev_private;
191 struct intel_plane *intel_plane = to_intel_plane(dplane);
192 int pipe = intel_plane->pipe;
193 int plane = intel_plane->plane;
194 u32 sprctl;
195
196 key->min_value = I915_READ(SPKEYMINVAL(pipe, plane));
197 key->max_value = I915_READ(SPKEYMAXVAL(pipe, plane));
198 key->channel_mask = I915_READ(SPKEYMSK(pipe, plane));
199
200 sprctl = I915_READ(SPCNTR(pipe, plane));
201 if (sprctl & SP_SOURCE_KEY)
202 key->flags = I915_SET_COLORKEY_SOURCE;
203 else
204 key->flags = I915_SET_COLORKEY_NONE;
205}
206
207static void
40ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb, 208ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
41 struct drm_i915_gem_object *obj, int crtc_x, int crtc_y, 209 struct drm_i915_gem_object *obj, int crtc_x, int crtc_y,
42 unsigned int crtc_w, unsigned int crtc_h, 210 unsigned int crtc_w, unsigned int crtc_h,
@@ -700,8 +868,22 @@ static uint32_t snb_plane_formats[] = {
700 DRM_FORMAT_VYUY, 868 DRM_FORMAT_VYUY,
701}; 869};
702 870
871static uint32_t vlv_plane_formats[] = {
872 DRM_FORMAT_RGB565,
873 DRM_FORMAT_ABGR8888,
874 DRM_FORMAT_ARGB8888,
875 DRM_FORMAT_XBGR8888,
876 DRM_FORMAT_XRGB8888,
877 DRM_FORMAT_XBGR2101010,
878 DRM_FORMAT_ABGR2101010,
879 DRM_FORMAT_YUYV,
880 DRM_FORMAT_YVYU,
881 DRM_FORMAT_UYVY,
882 DRM_FORMAT_VYUY,
883};
884
703int 885int
704intel_plane_init(struct drm_device *dev, enum pipe pipe) 886intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
705{ 887{
706 struct intel_plane *intel_plane; 888 struct intel_plane *intel_plane;
707 unsigned long possible_crtcs; 889 unsigned long possible_crtcs;
@@ -740,14 +922,26 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
740 intel_plane->can_scale = false; 922 intel_plane->can_scale = false;
741 else 923 else
742 intel_plane->can_scale = true; 924 intel_plane->can_scale = true;
743 intel_plane->max_downscale = 2; 925
744 intel_plane->update_plane = ivb_update_plane; 926 if (IS_VALLEYVIEW(dev)) {
745 intel_plane->disable_plane = ivb_disable_plane; 927 intel_plane->max_downscale = 1;
746 intel_plane->update_colorkey = ivb_update_colorkey; 928 intel_plane->update_plane = vlv_update_plane;
747 intel_plane->get_colorkey = ivb_get_colorkey; 929 intel_plane->disable_plane = vlv_disable_plane;
748 930 intel_plane->update_colorkey = vlv_update_colorkey;
749 plane_formats = snb_plane_formats; 931 intel_plane->get_colorkey = vlv_get_colorkey;
750 num_plane_formats = ARRAY_SIZE(snb_plane_formats); 932
933 plane_formats = vlv_plane_formats;
934 num_plane_formats = ARRAY_SIZE(vlv_plane_formats);
935 } else {
936 intel_plane->max_downscale = 2;
937 intel_plane->update_plane = ivb_update_plane;
938 intel_plane->disable_plane = ivb_disable_plane;
939 intel_plane->update_colorkey = ivb_update_colorkey;
940 intel_plane->get_colorkey = ivb_get_colorkey;
941
942 plane_formats = snb_plane_formats;
943 num_plane_formats = ARRAY_SIZE(snb_plane_formats);
944 }
751 break; 945 break;
752 946
753 default: 947 default:
@@ -756,6 +950,7 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
756 } 950 }
757 951
758 intel_plane->pipe = pipe; 952 intel_plane->pipe = pipe;
953 intel_plane->plane = plane;
759 possible_crtcs = (1 << pipe); 954 possible_crtcs = (1 << pipe);
760 ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs, 955 ret = drm_plane_init(dev, &intel_plane->base, possible_crtcs,
761 &intel_plane_funcs, 956 &intel_plane_funcs,