Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Extract intel_sprite_uapi.c

Move the sprite colorkey ioctl handler to its own file
so that intel_sprite.c becomes all about the low level
details of pre-skl sprite planes.

And drop a bunch of unnecessary includes while at it.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230314130255.23273-10-ville.syrjala@linux.intel.com
Reviewed-by: Jouni Högander <jouni.hogander@intel.com>

+143 -125
+1
drivers/gpu/drm/i915/Makefile
··· 267 267 display/intel_psr.o \ 268 268 display/intel_quirks.o \ 269 269 display/intel_sprite.o \ 270 + display/intel_sprite_uapi.o \ 270 271 display/intel_tc.o \ 271 272 display/intel_vblank.o \ 272 273 display/intel_vga.o \
-125
drivers/gpu/drm/i915/display/intel_sprite.c
··· 32 32 33 33 #include <linux/string_helpers.h> 34 34 35 - #include <drm/drm_atomic.h> 36 35 #include <drm/drm_atomic_helper.h> 37 36 #include <drm/drm_blend.h> 38 37 #include <drm/drm_color_mgmt.h> 39 - #include <drm/drm_crtc.h> 40 - #include <drm/drm_damage_helper.h> 41 38 #include <drm/drm_fourcc.h> 42 39 #include <drm/drm_rect.h> 43 40 44 41 #include "i915_drv.h" 45 42 #include "i915_reg.h" 46 - #include "i915_vgpu.h" 47 43 #include "i9xx_plane.h" 48 44 #include "intel_atomic_plane.h" 49 - #include "intel_crtc.h" 50 45 #include "intel_de.h" 51 46 #include "intel_display_types.h" 52 47 #include "intel_fb.h" 53 - #include "intel_frontbuffer.h" 54 48 #include "intel_sprite.h" 55 - #include "intel_vrr.h" 56 49 57 50 static void i9xx_plane_linear_gamma(u16 gamma[8]) 58 51 { ··· 1382 1389 plane_state->ctl = vlv_sprite_ctl(crtc_state, plane_state); 1383 1390 1384 1391 return 0; 1385 - } 1386 - 1387 - static bool has_dst_key_in_primary_plane(struct drm_i915_private *dev_priv) 1388 - { 1389 - return DISPLAY_VER(dev_priv) >= 9; 1390 - } 1391 - 1392 - static void intel_plane_set_ckey(struct intel_plane_state *plane_state, 1393 - const struct drm_intel_sprite_colorkey *set) 1394 - { 1395 - struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 1396 - struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 1397 - struct drm_intel_sprite_colorkey *key = &plane_state->ckey; 1398 - 1399 - *key = *set; 1400 - 1401 - /* 1402 - * We want src key enabled on the 1403 - * sprite and not on the primary. 1404 - */ 1405 - if (plane->id == PLANE_PRIMARY && 1406 - set->flags & I915_SET_COLORKEY_SOURCE) 1407 - key->flags = 0; 1408 - 1409 - /* 1410 - * On SKL+ we want dst key enabled on 1411 - * the primary and not on the sprite. 1412 - */ 1413 - if (DISPLAY_VER(dev_priv) >= 9 && plane->id != PLANE_PRIMARY && 1414 - set->flags & I915_SET_COLORKEY_DESTINATION) 1415 - key->flags = 0; 1416 - } 1417 - 1418 - int intel_sprite_set_colorkey_ioctl(struct drm_device *dev, void *data, 1419 - struct drm_file *file_priv) 1420 - { 1421 - struct drm_i915_private *dev_priv = to_i915(dev); 1422 - struct drm_intel_sprite_colorkey *set = data; 1423 - struct drm_plane *plane; 1424 - struct drm_plane_state *plane_state; 1425 - struct drm_atomic_state *state; 1426 - struct drm_modeset_acquire_ctx ctx; 1427 - int ret = 0; 1428 - 1429 - /* ignore the pointless "none" flag */ 1430 - set->flags &= ~I915_SET_COLORKEY_NONE; 1431 - 1432 - if (set->flags & ~(I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) 1433 - return -EINVAL; 1434 - 1435 - /* Make sure we don't try to enable both src & dest simultaneously */ 1436 - if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) 1437 - return -EINVAL; 1438 - 1439 - if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && 1440 - set->flags & I915_SET_COLORKEY_DESTINATION) 1441 - return -EINVAL; 1442 - 1443 - plane = drm_plane_find(dev, file_priv, set->plane_id); 1444 - if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY) 1445 - return -ENOENT; 1446 - 1447 - /* 1448 - * SKL+ only plane 2 can do destination keying against plane 1. 1449 - * Also multiple planes can't do destination keying on the same 1450 - * pipe simultaneously. 1451 - */ 1452 - if (DISPLAY_VER(dev_priv) >= 9 && 1453 - to_intel_plane(plane)->id >= PLANE_SPRITE1 && 1454 - set->flags & I915_SET_COLORKEY_DESTINATION) 1455 - return -EINVAL; 1456 - 1457 - drm_modeset_acquire_init(&ctx, 0); 1458 - 1459 - state = drm_atomic_state_alloc(plane->dev); 1460 - if (!state) { 1461 - ret = -ENOMEM; 1462 - goto out; 1463 - } 1464 - state->acquire_ctx = &ctx; 1465 - 1466 - while (1) { 1467 - plane_state = drm_atomic_get_plane_state(state, plane); 1468 - ret = PTR_ERR_OR_ZERO(plane_state); 1469 - if (!ret) 1470 - intel_plane_set_ckey(to_intel_plane_state(plane_state), set); 1471 - 1472 - /* 1473 - * On some platforms we have to configure 1474 - * the dst colorkey on the primary plane. 1475 - */ 1476 - if (!ret && has_dst_key_in_primary_plane(dev_priv)) { 1477 - struct intel_crtc *crtc = 1478 - intel_crtc_for_pipe(dev_priv, 1479 - to_intel_plane(plane)->pipe); 1480 - 1481 - plane_state = drm_atomic_get_plane_state(state, 1482 - crtc->base.primary); 1483 - ret = PTR_ERR_OR_ZERO(plane_state); 1484 - if (!ret) 1485 - intel_plane_set_ckey(to_intel_plane_state(plane_state), set); 1486 - } 1487 - 1488 - if (!ret) 1489 - ret = drm_atomic_commit(state); 1490 - 1491 - if (ret != -EDEADLK) 1492 - break; 1493 - 1494 - drm_atomic_state_clear(state); 1495 - drm_modeset_backoff(&ctx); 1496 - } 1497 - 1498 - drm_atomic_state_put(state); 1499 - out: 1500 - drm_modeset_drop_locks(&ctx); 1501 - drm_modeset_acquire_fini(&ctx); 1502 - return ret; 1503 1392 } 1504 1393 1505 1394 static const u32 g4x_sprite_formats[] = {
+127
drivers/gpu/drm/i915/display/intel_sprite_uapi.c
··· 1 + // SPDX-License-Identifier: MIT 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #include "i915_drv.h" 7 + #include "intel_crtc.h" 8 + #include "intel_display_types.h" 9 + #include "intel_sprite_uapi.h" 10 + 11 + static bool has_dst_key_in_primary_plane(struct drm_i915_private *dev_priv) 12 + { 13 + return DISPLAY_VER(dev_priv) >= 9; 14 + } 15 + 16 + static void intel_plane_set_ckey(struct intel_plane_state *plane_state, 17 + const struct drm_intel_sprite_colorkey *set) 18 + { 19 + struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); 20 + struct drm_i915_private *dev_priv = to_i915(plane->base.dev); 21 + struct drm_intel_sprite_colorkey *key = &plane_state->ckey; 22 + 23 + *key = *set; 24 + 25 + /* 26 + * We want src key enabled on the 27 + * sprite and not on the primary. 28 + */ 29 + if (plane->id == PLANE_PRIMARY && 30 + set->flags & I915_SET_COLORKEY_SOURCE) 31 + key->flags = 0; 32 + 33 + /* 34 + * On SKL+ we want dst key enabled on 35 + * the primary and not on the sprite. 36 + */ 37 + if (DISPLAY_VER(dev_priv) >= 9 && plane->id != PLANE_PRIMARY && 38 + set->flags & I915_SET_COLORKEY_DESTINATION) 39 + key->flags = 0; 40 + } 41 + 42 + int intel_sprite_set_colorkey_ioctl(struct drm_device *dev, void *data, 43 + struct drm_file *file_priv) 44 + { 45 + struct drm_i915_private *dev_priv = to_i915(dev); 46 + struct drm_intel_sprite_colorkey *set = data; 47 + struct drm_plane *plane; 48 + struct drm_plane_state *plane_state; 49 + struct drm_atomic_state *state; 50 + struct drm_modeset_acquire_ctx ctx; 51 + int ret = 0; 52 + 53 + /* ignore the pointless "none" flag */ 54 + set->flags &= ~I915_SET_COLORKEY_NONE; 55 + 56 + if (set->flags & ~(I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) 57 + return -EINVAL; 58 + 59 + /* Make sure we don't try to enable both src & dest simultaneously */ 60 + if ((set->flags & (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) == (I915_SET_COLORKEY_DESTINATION | I915_SET_COLORKEY_SOURCE)) 61 + return -EINVAL; 62 + 63 + if ((IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && 64 + set->flags & I915_SET_COLORKEY_DESTINATION) 65 + return -EINVAL; 66 + 67 + plane = drm_plane_find(dev, file_priv, set->plane_id); 68 + if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY) 69 + return -ENOENT; 70 + 71 + /* 72 + * SKL+ only plane 2 can do destination keying against plane 1. 73 + * Also multiple planes can't do destination keying on the same 74 + * pipe simultaneously. 75 + */ 76 + if (DISPLAY_VER(dev_priv) >= 9 && 77 + to_intel_plane(plane)->id >= PLANE_SPRITE1 && 78 + set->flags & I915_SET_COLORKEY_DESTINATION) 79 + return -EINVAL; 80 + 81 + drm_modeset_acquire_init(&ctx, 0); 82 + 83 + state = drm_atomic_state_alloc(plane->dev); 84 + if (!state) { 85 + ret = -ENOMEM; 86 + goto out; 87 + } 88 + state->acquire_ctx = &ctx; 89 + 90 + while (1) { 91 + plane_state = drm_atomic_get_plane_state(state, plane); 92 + ret = PTR_ERR_OR_ZERO(plane_state); 93 + if (!ret) 94 + intel_plane_set_ckey(to_intel_plane_state(plane_state), set); 95 + 96 + /* 97 + * On some platforms we have to configure 98 + * the dst colorkey on the primary plane. 99 + */ 100 + if (!ret && has_dst_key_in_primary_plane(dev_priv)) { 101 + struct intel_crtc *crtc = 102 + intel_crtc_for_pipe(dev_priv, 103 + to_intel_plane(plane)->pipe); 104 + 105 + plane_state = drm_atomic_get_plane_state(state, 106 + crtc->base.primary); 107 + ret = PTR_ERR_OR_ZERO(plane_state); 108 + if (!ret) 109 + intel_plane_set_ckey(to_intel_plane_state(plane_state), set); 110 + } 111 + 112 + if (!ret) 113 + ret = drm_atomic_commit(state); 114 + 115 + if (ret != -EDEADLK) 116 + break; 117 + 118 + drm_atomic_state_clear(state); 119 + drm_modeset_backoff(&ctx); 120 + } 121 + 122 + drm_atomic_state_put(state); 123 + out: 124 + drm_modeset_drop_locks(&ctx); 125 + drm_modeset_acquire_fini(&ctx); 126 + return ret; 127 + }
+15
drivers/gpu/drm/i915/display/intel_sprite_uapi.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef __INTEL_SPRITE_UAPI_H__ 7 + #define __INTEL_SPRITE_UAPI_H__ 8 + 9 + struct drm_device; 10 + struct drm_file; 11 + 12 + int intel_sprite_set_colorkey_ioctl(struct drm_device *dev, void *data, 13 + struct drm_file *file_priv); 14 + 15 + #endif /* __INTEL_SPRITE_UAPI_H__ */