diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2015-03-19 15:18:57 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-03-20 06:48:22 -0400 |
commit | 47ecbb208bf44be0e798495d08837fe7c4138201 (patch) | |
tree | 02f1a27c129040a96804f2ce58ac0ddf145da2bc | |
parent | 08fd59fcc8c0f9732214fb93ad5cb09f67cb1124 (diff) |
drm/i915: Eliminate the RMW sprite colorkey management
Store the colorkey in intel_plane and kill off all the RMW stuff
handling it.
This is just an intermediate step and eventually the colorkey needs to
be converted into some properties.
v2: Actually update the hardware state in the set_colorkey ioctl (Daniel)
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_sprite.c | 297 |
2 files changed, 69 insertions, 235 deletions
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index c06854df466d..6f20f3a01398 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -510,6 +510,9 @@ struct intel_plane { | |||
510 | bool can_scale; | 510 | bool can_scale; |
511 | int max_downscale; | 511 | int max_downscale; |
512 | 512 | ||
513 | /* FIXME convert to properties */ | ||
514 | struct drm_intel_sprite_colorkey ckey; | ||
515 | |||
513 | /* Since we need to change the watermarks before/after | 516 | /* Since we need to change the watermarks before/after |
514 | * enabling/disabling the planes, we need to store the parameters here | 517 | * enabling/disabling the planes, we need to store the parameters here |
515 | * as the other pieces of the struct may not reflect the values we want | 518 | * as the other pieces of the struct may not reflect the values we want |
@@ -536,10 +539,6 @@ struct intel_plane { | |||
536 | struct intel_plane_state *state); | 539 | struct intel_plane_state *state); |
537 | void (*commit_plane)(struct drm_plane *plane, | 540 | void (*commit_plane)(struct drm_plane *plane, |
538 | struct intel_plane_state *state); | 541 | struct intel_plane_state *state); |
539 | int (*update_colorkey)(struct drm_plane *plane, | ||
540 | struct drm_intel_sprite_colorkey *key); | ||
541 | void (*get_colorkey)(struct drm_plane *plane, | ||
542 | struct drm_intel_sprite_colorkey *key); | ||
543 | }; | 542 | }; |
544 | 543 | ||
545 | struct intel_watermark_params { | 544 | struct intel_watermark_params { |
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index cd531fa997de..d61e35d32e33 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c | |||
@@ -192,6 +192,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc, | |||
192 | const int plane = intel_plane->plane + 1; | 192 | const int plane = intel_plane->plane + 1; |
193 | u32 plane_ctl, stride_div; | 193 | u32 plane_ctl, stride_div; |
194 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); | 194 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
195 | const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey; | ||
195 | 196 | ||
196 | plane_ctl = I915_READ(PLANE_CTL(pipe, plane)); | 197 | plane_ctl = I915_READ(PLANE_CTL(pipe, plane)); |
197 | 198 | ||
@@ -202,6 +203,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc, | |||
202 | plane_ctl &= ~PLANE_CTL_TILED_MASK; | 203 | plane_ctl &= ~PLANE_CTL_TILED_MASK; |
203 | plane_ctl &= ~PLANE_CTL_ALPHA_MASK; | 204 | plane_ctl &= ~PLANE_CTL_ALPHA_MASK; |
204 | plane_ctl &= ~PLANE_CTL_ROTATE_MASK; | 205 | plane_ctl &= ~PLANE_CTL_ROTATE_MASK; |
206 | plane_ctl &= ~PLANE_CTL_KEY_ENABLE_MASK; | ||
205 | 207 | ||
206 | /* Trickle feed has to be enabled */ | 208 | /* Trickle feed has to be enabled */ |
207 | plane_ctl &= ~PLANE_CTL_TRICKLE_FEED_DISABLE; | 209 | plane_ctl &= ~PLANE_CTL_TRICKLE_FEED_DISABLE; |
@@ -281,6 +283,17 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc, | |||
281 | crtc_w--; | 283 | crtc_w--; |
282 | crtc_h--; | 284 | crtc_h--; |
283 | 285 | ||
286 | if (key->flags) { | ||
287 | I915_WRITE(PLANE_KEYVAL(pipe, plane), key->min_value); | ||
288 | I915_WRITE(PLANE_KEYMAX(pipe, plane), key->max_value); | ||
289 | I915_WRITE(PLANE_KEYMSK(pipe, plane), key->channel_mask); | ||
290 | } | ||
291 | |||
292 | if (key->flags & I915_SET_COLORKEY_DESTINATION) | ||
293 | plane_ctl |= PLANE_CTL_KEY_ENABLE_DESTINATION; | ||
294 | else if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
295 | plane_ctl |= PLANE_CTL_KEY_ENABLE_SOURCE; | ||
296 | |||
284 | I915_WRITE(PLANE_OFFSET(pipe, plane), (y << 16) | x); | 297 | I915_WRITE(PLANE_OFFSET(pipe, plane), (y << 16) | x); |
285 | I915_WRITE(PLANE_STRIDE(pipe, plane), fb->pitches[0] / stride_div); | 298 | I915_WRITE(PLANE_STRIDE(pipe, plane), fb->pitches[0] / stride_div); |
286 | I915_WRITE(PLANE_POS(pipe, plane), (crtc_y << 16) | crtc_x); | 299 | I915_WRITE(PLANE_POS(pipe, plane), (crtc_y << 16) | crtc_x); |
@@ -309,63 +322,6 @@ skl_disable_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc) | |||
309 | intel_update_sprite_watermarks(drm_plane, crtc, 0, 0, 0, false, false); | 322 | intel_update_sprite_watermarks(drm_plane, crtc, 0, 0, 0, false, false); |
310 | } | 323 | } |
311 | 324 | ||
312 | static int | ||
313 | skl_update_colorkey(struct drm_plane *drm_plane, | ||
314 | struct drm_intel_sprite_colorkey *key) | ||
315 | { | ||
316 | struct drm_device *dev = drm_plane->dev; | ||
317 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
318 | struct intel_plane *intel_plane = to_intel_plane(drm_plane); | ||
319 | const int pipe = intel_plane->pipe; | ||
320 | const int plane = intel_plane->plane; | ||
321 | u32 plane_ctl; | ||
322 | |||
323 | I915_WRITE(PLANE_KEYVAL(pipe, plane), key->min_value); | ||
324 | I915_WRITE(PLANE_KEYMAX(pipe, plane), key->max_value); | ||
325 | I915_WRITE(PLANE_KEYMSK(pipe, plane), key->channel_mask); | ||
326 | |||
327 | plane_ctl = I915_READ(PLANE_CTL(pipe, plane)); | ||
328 | plane_ctl &= ~PLANE_CTL_KEY_ENABLE_MASK; | ||
329 | if (key->flags & I915_SET_COLORKEY_DESTINATION) | ||
330 | plane_ctl |= PLANE_CTL_KEY_ENABLE_DESTINATION; | ||
331 | else if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
332 | plane_ctl |= PLANE_CTL_KEY_ENABLE_SOURCE; | ||
333 | I915_WRITE(PLANE_CTL(pipe, plane), plane_ctl); | ||
334 | |||
335 | POSTING_READ(PLANE_CTL(pipe, plane)); | ||
336 | |||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | static void | ||
341 | skl_get_colorkey(struct drm_plane *drm_plane, | ||
342 | struct drm_intel_sprite_colorkey *key) | ||
343 | { | ||
344 | struct drm_device *dev = drm_plane->dev; | ||
345 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
346 | struct intel_plane *intel_plane = to_intel_plane(drm_plane); | ||
347 | const int pipe = intel_plane->pipe; | ||
348 | const int plane = intel_plane->plane; | ||
349 | u32 plane_ctl; | ||
350 | |||
351 | key->min_value = I915_READ(PLANE_KEYVAL(pipe, plane)); | ||
352 | key->max_value = I915_READ(PLANE_KEYMAX(pipe, plane)); | ||
353 | key->channel_mask = I915_READ(PLANE_KEYMSK(pipe, plane)); | ||
354 | |||
355 | plane_ctl = I915_READ(PLANE_CTL(pipe, plane)); | ||
356 | |||
357 | switch (plane_ctl & PLANE_CTL_KEY_ENABLE_MASK) { | ||
358 | case PLANE_CTL_KEY_ENABLE_DESTINATION: | ||
359 | key->flags = I915_SET_COLORKEY_DESTINATION; | ||
360 | break; | ||
361 | case PLANE_CTL_KEY_ENABLE_SOURCE: | ||
362 | key->flags = I915_SET_COLORKEY_SOURCE; | ||
363 | break; | ||
364 | default: | ||
365 | key->flags = I915_SET_COLORKEY_NONE; | ||
366 | } | ||
367 | } | ||
368 | |||
369 | static void | 325 | static void |
370 | chv_update_csc(struct intel_plane *intel_plane, uint32_t format) | 326 | chv_update_csc(struct intel_plane *intel_plane, uint32_t format) |
371 | { | 327 | { |
@@ -423,6 +379,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, | |||
423 | u32 sprctl; | 379 | u32 sprctl; |
424 | unsigned long sprsurf_offset, linear_offset; | 380 | unsigned long sprsurf_offset, linear_offset; |
425 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); | 381 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
382 | const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey; | ||
426 | 383 | ||
427 | sprctl = I915_READ(SPCNTR(pipe, plane)); | 384 | sprctl = I915_READ(SPCNTR(pipe, plane)); |
428 | 385 | ||
@@ -431,6 +388,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, | |||
431 | sprctl &= ~SP_YUV_BYTE_ORDER_MASK; | 388 | sprctl &= ~SP_YUV_BYTE_ORDER_MASK; |
432 | sprctl &= ~SP_TILED; | 389 | sprctl &= ~SP_TILED; |
433 | sprctl &= ~SP_ROTATE_180; | 390 | sprctl &= ~SP_ROTATE_180; |
391 | sprctl &= ~SP_SOURCE_KEY; | ||
434 | 392 | ||
435 | switch (fb->pixel_format) { | 393 | switch (fb->pixel_format) { |
436 | case DRM_FORMAT_YUYV: | 394 | case DRM_FORMAT_YUYV: |
@@ -513,6 +471,15 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc, | |||
513 | 471 | ||
514 | intel_update_primary_plane(intel_crtc); | 472 | intel_update_primary_plane(intel_crtc); |
515 | 473 | ||
474 | if (key->flags) { | ||
475 | I915_WRITE(SPKEYMINVAL(pipe, plane), key->min_value); | ||
476 | I915_WRITE(SPKEYMAXVAL(pipe, plane), key->max_value); | ||
477 | I915_WRITE(SPKEYMSK(pipe, plane), key->channel_mask); | ||
478 | } | ||
479 | |||
480 | if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
481 | sprctl |= SP_SOURCE_KEY; | ||
482 | |||
516 | if (IS_CHERRYVIEW(dev) && pipe == PIPE_B) | 483 | if (IS_CHERRYVIEW(dev) && pipe == PIPE_B) |
517 | chv_update_csc(intel_plane, fb->pixel_format); | 484 | chv_update_csc(intel_plane, fb->pixel_format); |
518 | 485 | ||
@@ -556,56 +523,6 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc) | |||
556 | intel_update_sprite_watermarks(dplane, crtc, 0, 0, 0, false, false); | 523 | intel_update_sprite_watermarks(dplane, crtc, 0, 0, 0, false, false); |
557 | } | 524 | } |
558 | 525 | ||
559 | static int | ||
560 | vlv_update_colorkey(struct drm_plane *dplane, | ||
561 | struct drm_intel_sprite_colorkey *key) | ||
562 | { | ||
563 | struct drm_device *dev = dplane->dev; | ||
564 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
565 | struct intel_plane *intel_plane = to_intel_plane(dplane); | ||
566 | int pipe = intel_plane->pipe; | ||
567 | int plane = intel_plane->plane; | ||
568 | u32 sprctl; | ||
569 | |||
570 | if (key->flags & I915_SET_COLORKEY_DESTINATION) | ||
571 | return -EINVAL; | ||
572 | |||
573 | I915_WRITE(SPKEYMINVAL(pipe, plane), key->min_value); | ||
574 | I915_WRITE(SPKEYMAXVAL(pipe, plane), key->max_value); | ||
575 | I915_WRITE(SPKEYMSK(pipe, plane), key->channel_mask); | ||
576 | |||
577 | sprctl = I915_READ(SPCNTR(pipe, plane)); | ||
578 | sprctl &= ~SP_SOURCE_KEY; | ||
579 | if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
580 | sprctl |= SP_SOURCE_KEY; | ||
581 | I915_WRITE(SPCNTR(pipe, plane), sprctl); | ||
582 | |||
583 | POSTING_READ(SPKEYMSK(pipe, plane)); | ||
584 | |||
585 | return 0; | ||
586 | } | ||
587 | |||
588 | static void | ||
589 | vlv_get_colorkey(struct drm_plane *dplane, | ||
590 | struct drm_intel_sprite_colorkey *key) | ||
591 | { | ||
592 | struct drm_device *dev = dplane->dev; | ||
593 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
594 | struct intel_plane *intel_plane = to_intel_plane(dplane); | ||
595 | int pipe = intel_plane->pipe; | ||
596 | int plane = intel_plane->plane; | ||
597 | u32 sprctl; | ||
598 | |||
599 | key->min_value = I915_READ(SPKEYMINVAL(pipe, plane)); | ||
600 | key->max_value = I915_READ(SPKEYMAXVAL(pipe, plane)); | ||
601 | key->channel_mask = I915_READ(SPKEYMSK(pipe, plane)); | ||
602 | |||
603 | sprctl = I915_READ(SPCNTR(pipe, plane)); | ||
604 | if (sprctl & SP_SOURCE_KEY) | ||
605 | key->flags = I915_SET_COLORKEY_SOURCE; | ||
606 | else | ||
607 | key->flags = I915_SET_COLORKEY_NONE; | ||
608 | } | ||
609 | 526 | ||
610 | static void | 527 | static void |
611 | ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | 528 | ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
@@ -620,10 +537,11 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
620 | struct intel_plane *intel_plane = to_intel_plane(plane); | 537 | struct intel_plane *intel_plane = to_intel_plane(plane); |
621 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 538 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
622 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); | 539 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
623 | int pipe = intel_plane->pipe; | 540 | enum pipe pipe = intel_plane->pipe; |
624 | u32 sprctl, sprscale = 0; | 541 | u32 sprctl, sprscale = 0; |
625 | unsigned long sprsurf_offset, linear_offset; | 542 | unsigned long sprsurf_offset, linear_offset; |
626 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); | 543 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
544 | const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey; | ||
627 | 545 | ||
628 | sprctl = I915_READ(SPRCTL(pipe)); | 546 | sprctl = I915_READ(SPRCTL(pipe)); |
629 | 547 | ||
@@ -633,6 +551,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
633 | sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; | 551 | sprctl &= ~SPRITE_YUV_BYTE_ORDER_MASK; |
634 | sprctl &= ~SPRITE_TILED; | 552 | sprctl &= ~SPRITE_TILED; |
635 | sprctl &= ~SPRITE_ROTATE_180; | 553 | sprctl &= ~SPRITE_ROTATE_180; |
554 | sprctl &= ~(SPRITE_SOURCE_KEY | SPRITE_DEST_KEY); | ||
636 | 555 | ||
637 | switch (fb->pixel_format) { | 556 | switch (fb->pixel_format) { |
638 | case DRM_FORMAT_XBGR8888: | 557 | case DRM_FORMAT_XBGR8888: |
@@ -709,6 +628,17 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
709 | 628 | ||
710 | intel_update_primary_plane(intel_crtc); | 629 | intel_update_primary_plane(intel_crtc); |
711 | 630 | ||
631 | if (key->flags) { | ||
632 | I915_WRITE(SPRKEYVAL(pipe), key->min_value); | ||
633 | I915_WRITE(SPRKEYMAX(pipe), key->max_value); | ||
634 | I915_WRITE(SPRKEYMSK(pipe), key->channel_mask); | ||
635 | } | ||
636 | |||
637 | if (key->flags & I915_SET_COLORKEY_DESTINATION) | ||
638 | sprctl |= SPRITE_DEST_KEY; | ||
639 | else if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
640 | sprctl |= SPRITE_SOURCE_KEY; | ||
641 | |||
712 | I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); | 642 | I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]); |
713 | I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); | 643 | I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x); |
714 | 644 | ||
@@ -752,60 +682,6 @@ ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc) | |||
752 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); | 682 | intel_flush_primary_plane(dev_priv, intel_crtc->plane); |
753 | } | 683 | } |
754 | 684 | ||
755 | static int | ||
756 | ivb_update_colorkey(struct drm_plane *plane, | ||
757 | struct drm_intel_sprite_colorkey *key) | ||
758 | { | ||
759 | struct drm_device *dev = plane->dev; | ||
760 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
761 | struct intel_plane *intel_plane; | ||
762 | u32 sprctl; | ||
763 | int ret = 0; | ||
764 | |||
765 | intel_plane = to_intel_plane(plane); | ||
766 | |||
767 | I915_WRITE(SPRKEYVAL(intel_plane->pipe), key->min_value); | ||
768 | I915_WRITE(SPRKEYMAX(intel_plane->pipe), key->max_value); | ||
769 | I915_WRITE(SPRKEYMSK(intel_plane->pipe), key->channel_mask); | ||
770 | |||
771 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); | ||
772 | sprctl &= ~(SPRITE_SOURCE_KEY | SPRITE_DEST_KEY); | ||
773 | if (key->flags & I915_SET_COLORKEY_DESTINATION) | ||
774 | sprctl |= SPRITE_DEST_KEY; | ||
775 | else if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
776 | sprctl |= SPRITE_SOURCE_KEY; | ||
777 | I915_WRITE(SPRCTL(intel_plane->pipe), sprctl); | ||
778 | |||
779 | POSTING_READ(SPRKEYMSK(intel_plane->pipe)); | ||
780 | |||
781 | return ret; | ||
782 | } | ||
783 | |||
784 | static void | ||
785 | ivb_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) | ||
786 | { | ||
787 | struct drm_device *dev = plane->dev; | ||
788 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
789 | struct intel_plane *intel_plane; | ||
790 | u32 sprctl; | ||
791 | |||
792 | intel_plane = to_intel_plane(plane); | ||
793 | |||
794 | key->min_value = I915_READ(SPRKEYVAL(intel_plane->pipe)); | ||
795 | key->max_value = I915_READ(SPRKEYMAX(intel_plane->pipe)); | ||
796 | key->channel_mask = I915_READ(SPRKEYMSK(intel_plane->pipe)); | ||
797 | key->flags = 0; | ||
798 | |||
799 | sprctl = I915_READ(SPRCTL(intel_plane->pipe)); | ||
800 | |||
801 | if (sprctl & SPRITE_DEST_KEY) | ||
802 | key->flags = I915_SET_COLORKEY_DESTINATION; | ||
803 | else if (sprctl & SPRITE_SOURCE_KEY) | ||
804 | key->flags = I915_SET_COLORKEY_SOURCE; | ||
805 | else | ||
806 | key->flags = I915_SET_COLORKEY_NONE; | ||
807 | } | ||
808 | |||
809 | static void | 685 | static void |
810 | ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | 686 | ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
811 | struct drm_framebuffer *fb, | 687 | struct drm_framebuffer *fb, |
@@ -823,6 +699,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
823 | unsigned long dvssurf_offset, linear_offset; | 699 | unsigned long dvssurf_offset, linear_offset; |
824 | u32 dvscntr, dvsscale; | 700 | u32 dvscntr, dvsscale; |
825 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); | 701 | int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
702 | const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey; | ||
826 | 703 | ||
827 | dvscntr = I915_READ(DVSCNTR(pipe)); | 704 | dvscntr = I915_READ(DVSCNTR(pipe)); |
828 | 705 | ||
@@ -832,6 +709,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
832 | dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; | 709 | dvscntr &= ~DVS_YUV_BYTE_ORDER_MASK; |
833 | dvscntr &= ~DVS_TILED; | 710 | dvscntr &= ~DVS_TILED; |
834 | dvscntr &= ~DVS_ROTATE_180; | 711 | dvscntr &= ~DVS_ROTATE_180; |
712 | dvscntr &= ~(DVS_SOURCE_KEY | DVS_DEST_KEY); | ||
835 | 713 | ||
836 | switch (fb->pixel_format) { | 714 | switch (fb->pixel_format) { |
837 | case DRM_FORMAT_XBGR8888: | 715 | case DRM_FORMAT_XBGR8888: |
@@ -899,6 +777,17 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
899 | 777 | ||
900 | intel_update_primary_plane(intel_crtc); | 778 | intel_update_primary_plane(intel_crtc); |
901 | 779 | ||
780 | if (key->flags) { | ||
781 | I915_WRITE(DVSKEYVAL(pipe), key->min_value); | ||
782 | I915_WRITE(DVSKEYMAX(pipe), key->max_value); | ||
783 | I915_WRITE(DVSKEYMSK(pipe), key->channel_mask); | ||
784 | } | ||
785 | |||
786 | if (key->flags & I915_SET_COLORKEY_DESTINATION) | ||
787 | dvscntr |= DVS_DEST_KEY; | ||
788 | else if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
789 | dvscntr |= DVS_SOURCE_KEY; | ||
790 | |||
902 | I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]); | 791 | I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]); |
903 | I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x); | 792 | I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x); |
904 | 793 | ||
@@ -1004,67 +893,9 @@ intel_pre_disable_primary(struct drm_crtc *crtc) | |||
1004 | hsw_disable_ips(intel_crtc); | 893 | hsw_disable_ips(intel_crtc); |
1005 | } | 894 | } |
1006 | 895 | ||
1007 | static int | ||
1008 | ilk_update_colorkey(struct drm_plane *plane, | ||
1009 | struct drm_intel_sprite_colorkey *key) | ||
1010 | { | ||
1011 | struct drm_device *dev = plane->dev; | ||
1012 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1013 | struct intel_plane *intel_plane; | ||
1014 | u32 dvscntr; | ||
1015 | int ret = 0; | ||
1016 | |||
1017 | intel_plane = to_intel_plane(plane); | ||
1018 | |||
1019 | I915_WRITE(DVSKEYVAL(intel_plane->pipe), key->min_value); | ||
1020 | I915_WRITE(DVSKEYMAX(intel_plane->pipe), key->max_value); | ||
1021 | I915_WRITE(DVSKEYMSK(intel_plane->pipe), key->channel_mask); | ||
1022 | |||
1023 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); | ||
1024 | dvscntr &= ~(DVS_SOURCE_KEY | DVS_DEST_KEY); | ||
1025 | if (key->flags & I915_SET_COLORKEY_DESTINATION) | ||
1026 | dvscntr |= DVS_DEST_KEY; | ||
1027 | else if (key->flags & I915_SET_COLORKEY_SOURCE) | ||
1028 | dvscntr |= DVS_SOURCE_KEY; | ||
1029 | I915_WRITE(DVSCNTR(intel_plane->pipe), dvscntr); | ||
1030 | |||
1031 | POSTING_READ(DVSKEYMSK(intel_plane->pipe)); | ||
1032 | |||
1033 | return ret; | ||
1034 | } | ||
1035 | |||
1036 | static void | ||
1037 | ilk_get_colorkey(struct drm_plane *plane, struct drm_intel_sprite_colorkey *key) | ||
1038 | { | ||
1039 | struct drm_device *dev = plane->dev; | ||
1040 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1041 | struct intel_plane *intel_plane; | ||
1042 | u32 dvscntr; | ||
1043 | |||
1044 | intel_plane = to_intel_plane(plane); | ||
1045 | |||
1046 | key->min_value = I915_READ(DVSKEYVAL(intel_plane->pipe)); | ||
1047 | key->max_value = I915_READ(DVSKEYMAX(intel_plane->pipe)); | ||
1048 | key->channel_mask = I915_READ(DVSKEYMSK(intel_plane->pipe)); | ||
1049 | key->flags = 0; | ||
1050 | |||
1051 | dvscntr = I915_READ(DVSCNTR(intel_plane->pipe)); | ||
1052 | |||
1053 | if (dvscntr & DVS_DEST_KEY) | ||
1054 | key->flags = I915_SET_COLORKEY_DESTINATION; | ||
1055 | else if (dvscntr & DVS_SOURCE_KEY) | ||
1056 | key->flags = I915_SET_COLORKEY_SOURCE; | ||
1057 | else | ||
1058 | key->flags = I915_SET_COLORKEY_NONE; | ||
1059 | } | ||
1060 | |||
1061 | static bool colorkey_enabled(struct intel_plane *intel_plane) | 896 | static bool colorkey_enabled(struct intel_plane *intel_plane) |
1062 | { | 897 | { |
1063 | struct drm_intel_sprite_colorkey key; | 898 | return intel_plane->ckey.flags != I915_SET_COLORKEY_NONE; |
1064 | |||
1065 | intel_plane->get_colorkey(&intel_plane->base, &key); | ||
1066 | |||
1067 | return key.flags != I915_SET_COLORKEY_NONE; | ||
1068 | } | 899 | } |
1069 | 900 | ||
1070 | static int | 901 | static int |
@@ -1317,6 +1148,10 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data, | |||
1317 | if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) | 1148 | if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) |
1318 | return -EINVAL; | 1149 | return -EINVAL; |
1319 | 1150 | ||
1151 | if (IS_VALLEYVIEW(dev) && | ||
1152 | set->flags & I915_SET_COLORKEY_DESTINATION) | ||
1153 | return -EINVAL; | ||
1154 | |||
1320 | drm_modeset_lock_all(dev); | 1155 | drm_modeset_lock_all(dev); |
1321 | 1156 | ||
1322 | plane = drm_plane_find(dev, set->plane_id); | 1157 | plane = drm_plane_find(dev, set->plane_id); |
@@ -1326,7 +1161,15 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data, | |||
1326 | } | 1161 | } |
1327 | 1162 | ||
1328 | intel_plane = to_intel_plane(plane); | 1163 | intel_plane = to_intel_plane(plane); |
1329 | ret = intel_plane->update_colorkey(plane, set); | 1164 | intel_plane->ckey = *set; |
1165 | |||
1166 | /* | ||
1167 | * The only way this could fail would be due to | ||
1168 | * the current plane state being unsupportable already, | ||
1169 | * and we dont't consider that an error for the | ||
1170 | * colorkey ioctl. So just ignore any error. | ||
1171 | */ | ||
1172 | intel_plane_restore(plane); | ||
1330 | 1173 | ||
1331 | out_unlock: | 1174 | out_unlock: |
1332 | drm_modeset_unlock_all(dev); | 1175 | drm_modeset_unlock_all(dev); |
@@ -1350,7 +1193,7 @@ int intel_sprite_get_colorkey(struct drm_device *dev, void *data, | |||
1350 | } | 1193 | } |
1351 | 1194 | ||
1352 | intel_plane = to_intel_plane(plane); | 1195 | intel_plane = to_intel_plane(plane); |
1353 | intel_plane->get_colorkey(plane, get); | 1196 | *get = intel_plane->ckey; |
1354 | 1197 | ||
1355 | out_unlock: | 1198 | out_unlock: |
1356 | drm_modeset_unlock_all(dev); | 1199 | drm_modeset_unlock_all(dev); |
@@ -1443,8 +1286,6 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) | |||
1443 | intel_plane->max_downscale = 16; | 1286 | intel_plane->max_downscale = 16; |
1444 | intel_plane->update_plane = ilk_update_plane; | 1287 | intel_plane->update_plane = ilk_update_plane; |
1445 | intel_plane->disable_plane = ilk_disable_plane; | 1288 | intel_plane->disable_plane = ilk_disable_plane; |
1446 | intel_plane->update_colorkey = ilk_update_colorkey; | ||
1447 | intel_plane->get_colorkey = ilk_get_colorkey; | ||
1448 | 1289 | ||
1449 | if (IS_GEN6(dev)) { | 1290 | if (IS_GEN6(dev)) { |
1450 | plane_formats = snb_plane_formats; | 1291 | plane_formats = snb_plane_formats; |
@@ -1468,16 +1309,12 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) | |||
1468 | if (IS_VALLEYVIEW(dev)) { | 1309 | if (IS_VALLEYVIEW(dev)) { |
1469 | intel_plane->update_plane = vlv_update_plane; | 1310 | intel_plane->update_plane = vlv_update_plane; |
1470 | intel_plane->disable_plane = vlv_disable_plane; | 1311 | intel_plane->disable_plane = vlv_disable_plane; |
1471 | intel_plane->update_colorkey = vlv_update_colorkey; | ||
1472 | intel_plane->get_colorkey = vlv_get_colorkey; | ||
1473 | 1312 | ||
1474 | plane_formats = vlv_plane_formats; | 1313 | plane_formats = vlv_plane_formats; |
1475 | num_plane_formats = ARRAY_SIZE(vlv_plane_formats); | 1314 | num_plane_formats = ARRAY_SIZE(vlv_plane_formats); |
1476 | } else { | 1315 | } else { |
1477 | intel_plane->update_plane = ivb_update_plane; | 1316 | intel_plane->update_plane = ivb_update_plane; |
1478 | intel_plane->disable_plane = ivb_disable_plane; | 1317 | intel_plane->disable_plane = ivb_disable_plane; |
1479 | intel_plane->update_colorkey = ivb_update_colorkey; | ||
1480 | intel_plane->get_colorkey = ivb_get_colorkey; | ||
1481 | 1318 | ||
1482 | plane_formats = snb_plane_formats; | 1319 | plane_formats = snb_plane_formats; |
1483 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); | 1320 | num_plane_formats = ARRAY_SIZE(snb_plane_formats); |
@@ -1492,8 +1329,6 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane) | |||
1492 | intel_plane->max_downscale = 1; | 1329 | intel_plane->max_downscale = 1; |
1493 | intel_plane->update_plane = skl_update_plane; | 1330 | intel_plane->update_plane = skl_update_plane; |
1494 | intel_plane->disable_plane = skl_disable_plane; | 1331 | intel_plane->disable_plane = skl_disable_plane; |
1495 | intel_plane->update_colorkey = skl_update_colorkey; | ||
1496 | intel_plane->get_colorkey = skl_get_colorkey; | ||
1497 | 1332 | ||
1498 | plane_formats = skl_plane_formats; | 1333 | plane_formats = skl_plane_formats; |
1499 | num_plane_formats = ARRAY_SIZE(skl_plane_formats); | 1334 | num_plane_formats = ARRAY_SIZE(skl_plane_formats); |