Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2011 Samsung Electronics Co.Ltd |
| 4 | * Authors: Joonyoung Shim <jy0922.shim@samsung.com> |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 5 | */ |
| 6 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 7 | #include <drm/drmP.h> |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 8 | |
Andrzej Hajda | 81e50bc | 2016-03-15 12:38:02 +0100 | [diff] [blame] | 9 | #include <drm/drm_atomic.h> |
Gustavo Padovan | 4ea9526 | 2015-06-01 12:04:44 -0300 | [diff] [blame] | 10 | #include <drm/drm_atomic_helper.h> |
Andrzej Hajda | 81e50bc | 2016-03-15 12:38:02 +0100 | [diff] [blame] | 11 | #include <drm/drm_plane_helper.h> |
| 12 | #include <drm/exynos_drm.h> |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 13 | #include "exynos_drm_drv.h" |
Sean Paul | 080be03d | 2014-02-19 21:02:55 +0900 | [diff] [blame] | 14 | #include "exynos_drm_crtc.h" |
Joonyoung Shim | 4070d21 | 2012-06-27 14:27:05 +0900 | [diff] [blame] | 15 | #include "exynos_drm_fb.h" |
| 16 | #include "exynos_drm_gem.h" |
Mark Brown | e30655d | 2013-08-13 00:46:40 +0100 | [diff] [blame] | 17 | #include "exynos_drm_plane.h" |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 18 | |
Joonyoung Shim | 2ab9792 | 2012-09-27 19:25:21 +0900 | [diff] [blame] | 19 | /* |
| 20 | * This function is to get X or Y size shown via screen. This needs length and |
| 21 | * start position of CRTC. |
| 22 | * |
| 23 | * <--- length ---> |
| 24 | * CRTC ---------------- |
| 25 | * ^ start ^ end |
| 26 | * |
Joonyoung Shim | 60a705a | 2012-12-14 15:48:22 +0900 | [diff] [blame] | 27 | * There are six cases from a to f. |
Joonyoung Shim | 2ab9792 | 2012-09-27 19:25:21 +0900 | [diff] [blame] | 28 | * |
| 29 | * <----- SCREEN -----> |
| 30 | * 0 last |
| 31 | * ----------|------------------|---------- |
| 32 | * CRTCs |
| 33 | * a ------- |
| 34 | * b ------- |
| 35 | * c -------------------------- |
| 36 | * d -------- |
| 37 | * e ------- |
| 38 | * f ------- |
| 39 | */ |
| 40 | static int exynos_plane_get_size(int start, unsigned length, unsigned last) |
| 41 | { |
| 42 | int end = start + length; |
| 43 | int size = 0; |
| 44 | |
| 45 | if (start <= 0) { |
| 46 | if (end > 0) |
| 47 | size = min_t(unsigned, end, last); |
| 48 | } else if (start <= last) { |
| 49 | size = min_t(unsigned, last - start, length); |
| 50 | } |
| 51 | |
| 52 | return size; |
| 53 | } |
| 54 | |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 55 | static void exynos_plane_mode_set(struct exynos_drm_plane_state *exynos_state) |
Gustavo Padovan | adf5691 | 2014-11-27 14:56:09 -0200 | [diff] [blame] | 56 | { |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 57 | struct drm_plane_state *state = &exynos_state->base; |
Andrzej Hajda | 81e50bc | 2016-03-15 12:38:02 +0100 | [diff] [blame] | 58 | struct drm_crtc *crtc = state->crtc; |
| 59 | struct drm_crtc_state *crtc_state = |
| 60 | drm_atomic_get_existing_crtc_state(state->state, crtc); |
| 61 | struct drm_display_mode *mode = &crtc_state->adjusted_mode; |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 62 | int crtc_x, crtc_y; |
| 63 | unsigned int crtc_w, crtc_h; |
| 64 | unsigned int src_x, src_y; |
| 65 | unsigned int src_w, src_h; |
Gustavo Padovan | adf5691 | 2014-11-27 14:56:09 -0200 | [diff] [blame] | 66 | unsigned int actual_w; |
| 67 | unsigned int actual_h; |
| 68 | |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 69 | /* |
| 70 | * The original src/dest coordinates are stored in exynos_state->base, |
| 71 | * but we want to keep another copy internal to our driver that we can |
| 72 | * clip/modify ourselves. |
| 73 | */ |
| 74 | |
| 75 | crtc_x = state->crtc_x; |
| 76 | crtc_y = state->crtc_y; |
| 77 | crtc_w = state->crtc_w; |
| 78 | crtc_h = state->crtc_h; |
| 79 | |
| 80 | src_x = state->src_x >> 16; |
| 81 | src_y = state->src_y >> 16; |
| 82 | src_w = state->src_w >> 16; |
| 83 | src_h = state->src_h >> 16; |
| 84 | |
Marek Szyprowski | d16a11a | 2015-11-30 14:53:28 +0100 | [diff] [blame] | 85 | /* set ratio */ |
| 86 | exynos_state->h_ratio = (src_w << 16) / crtc_w; |
| 87 | exynos_state->v_ratio = (src_h << 16) / crtc_h; |
| 88 | |
| 89 | /* clip to visible area */ |
Joonyoung Shim | 020e79d | 2015-06-02 21:04:42 +0900 | [diff] [blame] | 90 | actual_w = exynos_plane_get_size(crtc_x, crtc_w, mode->hdisplay); |
| 91 | actual_h = exynos_plane_get_size(crtc_y, crtc_h, mode->vdisplay); |
Joonyoung Shim | 2ab9792 | 2012-09-27 19:25:21 +0900 | [diff] [blame] | 92 | |
| 93 | if (crtc_x < 0) { |
| 94 | if (actual_w) |
Marek Szyprowski | d16a11a | 2015-11-30 14:53:28 +0100 | [diff] [blame] | 95 | src_x += ((-crtc_x) * exynos_state->h_ratio) >> 16; |
Joonyoung Shim | 2ab9792 | 2012-09-27 19:25:21 +0900 | [diff] [blame] | 96 | crtc_x = 0; |
| 97 | } |
| 98 | |
| 99 | if (crtc_y < 0) { |
| 100 | if (actual_h) |
Marek Szyprowski | d16a11a | 2015-11-30 14:53:28 +0100 | [diff] [blame] | 101 | src_y += ((-crtc_y) * exynos_state->v_ratio) >> 16; |
Joonyoung Shim | 2ab9792 | 2012-09-27 19:25:21 +0900 | [diff] [blame] | 102 | crtc_y = 0; |
| 103 | } |
Joonyoung Shim | 4070d21 | 2012-06-27 14:27:05 +0900 | [diff] [blame] | 104 | |
| 105 | /* set drm framebuffer data. */ |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 106 | exynos_state->src.x = src_x; |
| 107 | exynos_state->src.y = src_y; |
| 108 | exynos_state->src.w = (actual_w * exynos_state->h_ratio) >> 16; |
| 109 | exynos_state->src.h = (actual_h * exynos_state->v_ratio) >> 16; |
Joonyoung Shim | 4070d21 | 2012-06-27 14:27:05 +0900 | [diff] [blame] | 110 | |
Gustavo Padovan | 8837dee | 2014-11-03 18:13:27 -0200 | [diff] [blame] | 111 | /* set plane range to be displayed. */ |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 112 | exynos_state->crtc.x = crtc_x; |
| 113 | exynos_state->crtc.y = crtc_y; |
| 114 | exynos_state->crtc.w = actual_w; |
| 115 | exynos_state->crtc.h = actual_h; |
Gustavo Padovan | d88d246 | 2015-07-16 12:23:38 -0300 | [diff] [blame] | 116 | |
Inki Dae | 6be9005 | 2019-04-15 16:25:12 +0900 | [diff] [blame] | 117 | DRM_DEV_DEBUG_KMS(crtc->dev->dev, |
| 118 | "plane : offset_x/y(%d,%d), width/height(%d,%d)", |
| 119 | exynos_state->crtc.x, exynos_state->crtc.y, |
| 120 | exynos_state->crtc.w, exynos_state->crtc.h); |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 121 | } |
Joonyoung Shim | 4070d21 | 2012-06-27 14:27:05 +0900 | [diff] [blame] | 122 | |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 123 | static void exynos_drm_plane_reset(struct drm_plane *plane) |
| 124 | { |
Marek Szyprowski | 0ea7240 | 2015-12-16 13:21:43 +0100 | [diff] [blame] | 125 | struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 126 | struct exynos_drm_plane_state *exynos_state; |
| 127 | |
| 128 | if (plane->state) { |
| 129 | exynos_state = to_exynos_plane_state(plane->state); |
Christoph Manszewski | a977726 | 2018-09-21 14:24:36 +0200 | [diff] [blame] | 130 | __drm_atomic_helper_plane_destroy_state(plane->state); |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 131 | kfree(exynos_state); |
| 132 | plane->state = NULL; |
| 133 | } |
| 134 | |
| 135 | exynos_state = kzalloc(sizeof(*exynos_state), GFP_KERNEL); |
| 136 | if (exynos_state) { |
Christoph Manszewski | a977726 | 2018-09-21 14:24:36 +0200 | [diff] [blame] | 137 | __drm_atomic_helper_plane_reset(plane, &exynos_state->base); |
Marek Szyprowski | e47726a | 2016-05-11 17:16:06 +0200 | [diff] [blame] | 138 | plane->state->zpos = exynos_plane->config->zpos; |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 139 | } |
| 140 | } |
| 141 | |
| 142 | static struct drm_plane_state * |
| 143 | exynos_drm_plane_duplicate_state(struct drm_plane *plane) |
| 144 | { |
| 145 | struct exynos_drm_plane_state *exynos_state; |
| 146 | struct exynos_drm_plane_state *copy; |
| 147 | |
| 148 | exynos_state = to_exynos_plane_state(plane->state); |
| 149 | copy = kzalloc(sizeof(*exynos_state), GFP_KERNEL); |
| 150 | if (!copy) |
| 151 | return NULL; |
| 152 | |
| 153 | __drm_atomic_helper_plane_duplicate_state(plane, ©->base); |
| 154 | return ©->base; |
| 155 | } |
| 156 | |
| 157 | static void exynos_drm_plane_destroy_state(struct drm_plane *plane, |
| 158 | struct drm_plane_state *old_state) |
| 159 | { |
| 160 | struct exynos_drm_plane_state *old_exynos_state = |
| 161 | to_exynos_plane_state(old_state); |
Daniel Vetter | 2f70169 | 2016-05-09 16:34:10 +0200 | [diff] [blame] | 162 | __drm_atomic_helper_plane_destroy_state(old_state); |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 163 | kfree(old_exynos_state); |
Joonyoung Shim | 4070d21 | 2012-06-27 14:27:05 +0900 | [diff] [blame] | 164 | } |
| 165 | |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 166 | static struct drm_plane_funcs exynos_plane_funcs = { |
Gustavo Padovan | 910874a | 2015-06-01 12:04:46 -0300 | [diff] [blame] | 167 | .update_plane = drm_atomic_helper_update_plane, |
| 168 | .disable_plane = drm_atomic_helper_disable_plane, |
Gustavo Padovan | 97464d7 | 2015-04-01 13:02:10 -0300 | [diff] [blame] | 169 | .destroy = drm_plane_cleanup, |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 170 | .reset = exynos_drm_plane_reset, |
| 171 | .atomic_duplicate_state = exynos_drm_plane_duplicate_state, |
| 172 | .atomic_destroy_state = exynos_drm_plane_destroy_state, |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 173 | }; |
| 174 | |
Marek Szyprowski | 6178d3d | 2015-11-30 14:53:26 +0100 | [diff] [blame] | 175 | static int |
Tobias Jakobi | f40031c | 2017-08-22 16:19:37 +0200 | [diff] [blame] | 176 | exynos_drm_plane_check_format(const struct exynos_drm_plane_config *config, |
| 177 | struct exynos_drm_plane_state *state) |
| 178 | { |
| 179 | struct drm_framebuffer *fb = state->base.fb; |
Inki Dae | 6f83d20 | 2019-04-15 14:24:36 +0900 | [diff] [blame] | 180 | struct drm_device *dev = fb->dev; |
Tobias Jakobi | f40031c | 2017-08-22 16:19:37 +0200 | [diff] [blame] | 181 | |
| 182 | switch (fb->modifier) { |
| 183 | case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: |
| 184 | if (!(config->capabilities & EXYNOS_DRM_PLANE_CAP_TILE)) |
| 185 | return -ENOTSUPP; |
| 186 | break; |
| 187 | |
| 188 | case DRM_FORMAT_MOD_LINEAR: |
| 189 | break; |
| 190 | |
| 191 | default: |
Inki Dae | 6f83d20 | 2019-04-15 14:24:36 +0900 | [diff] [blame] | 192 | DRM_DEV_ERROR(dev->dev, "unsupported pixel format modifier"); |
Tobias Jakobi | f40031c | 2017-08-22 16:19:37 +0200 | [diff] [blame] | 193 | return -ENOTSUPP; |
| 194 | } |
| 195 | |
| 196 | return 0; |
| 197 | } |
| 198 | |
| 199 | static int |
Marek Szyprowski | 6178d3d | 2015-11-30 14:53:26 +0100 | [diff] [blame] | 200 | exynos_drm_plane_check_size(const struct exynos_drm_plane_config *config, |
| 201 | struct exynos_drm_plane_state *state) |
| 202 | { |
Inki Dae | 6be9005 | 2019-04-15 16:25:12 +0900 | [diff] [blame] | 203 | struct drm_crtc *crtc = state->base.crtc; |
Marek Szyprowski | 6178d3d | 2015-11-30 14:53:26 +0100 | [diff] [blame] | 204 | bool width_ok = false, height_ok = false; |
| 205 | |
| 206 | if (config->capabilities & EXYNOS_DRM_PLANE_CAP_SCALE) |
| 207 | return 0; |
| 208 | |
| 209 | if (state->src.w == state->crtc.w) |
| 210 | width_ok = true; |
| 211 | |
| 212 | if (state->src.h == state->crtc.h) |
| 213 | height_ok = true; |
| 214 | |
| 215 | if ((config->capabilities & EXYNOS_DRM_PLANE_CAP_DOUBLE) && |
| 216 | state->h_ratio == (1 << 15)) |
| 217 | width_ok = true; |
| 218 | |
| 219 | if ((config->capabilities & EXYNOS_DRM_PLANE_CAP_DOUBLE) && |
| 220 | state->v_ratio == (1 << 15)) |
| 221 | height_ok = true; |
| 222 | |
Tobias Jakobi | 39bf86092 | 2016-05-25 14:30:07 +0200 | [diff] [blame] | 223 | if (width_ok && height_ok) |
Marek Szyprowski | 6178d3d | 2015-11-30 14:53:26 +0100 | [diff] [blame] | 224 | return 0; |
| 225 | |
Inki Dae | 6be9005 | 2019-04-15 16:25:12 +0900 | [diff] [blame] | 226 | DRM_DEV_DEBUG_KMS(crtc->dev->dev, "scaling mode is not supported"); |
Marek Szyprowski | 6178d3d | 2015-11-30 14:53:26 +0100 | [diff] [blame] | 227 | return -ENOTSUPP; |
| 228 | } |
| 229 | |
Gustavo Padovan | 43dbdad | 2015-06-01 12:04:41 -0300 | [diff] [blame] | 230 | static int exynos_plane_atomic_check(struct drm_plane *plane, |
| 231 | struct drm_plane_state *state) |
| 232 | { |
Gustavo Padovan | d5f5223 | 2015-06-01 12:04:49 -0300 | [diff] [blame] | 233 | struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 234 | struct exynos_drm_plane_state *exynos_state = |
| 235 | to_exynos_plane_state(state); |
| 236 | int ret = 0; |
Gustavo Padovan | d5f5223 | 2015-06-01 12:04:49 -0300 | [diff] [blame] | 237 | |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 238 | if (!state->crtc || !state->fb) |
Gustavo Padovan | d5f5223 | 2015-06-01 12:04:49 -0300 | [diff] [blame] | 239 | return 0; |
| 240 | |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 241 | /* translate state into exynos_state */ |
| 242 | exynos_plane_mode_set(exynos_state); |
Gustavo Padovan | d5f5223 | 2015-06-01 12:04:49 -0300 | [diff] [blame] | 243 | |
Tobias Jakobi | f40031c | 2017-08-22 16:19:37 +0200 | [diff] [blame] | 244 | ret = exynos_drm_plane_check_format(exynos_plane->config, exynos_state); |
| 245 | if (ret) |
| 246 | return ret; |
| 247 | |
Marek Szyprowski | 6178d3d | 2015-11-30 14:53:26 +0100 | [diff] [blame] | 248 | ret = exynos_drm_plane_check_size(exynos_plane->config, exynos_state); |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 249 | return ret; |
Gustavo Padovan | 43dbdad | 2015-06-01 12:04:41 -0300 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | static void exynos_plane_atomic_update(struct drm_plane *plane, |
| 253 | struct drm_plane_state *old_state) |
| 254 | { |
| 255 | struct drm_plane_state *state = plane->state; |
Gustavo Padovan | d5f5223 | 2015-06-01 12:04:49 -0300 | [diff] [blame] | 256 | struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(state->crtc); |
| 257 | struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); |
Gustavo Padovan | 43dbdad | 2015-06-01 12:04:41 -0300 | [diff] [blame] | 258 | |
| 259 | if (!state->crtc) |
| 260 | return; |
| 261 | |
Gustavo Padovan | 9cc7610 | 2015-08-03 14:38:05 +0900 | [diff] [blame] | 262 | if (exynos_crtc->ops->update_plane) |
Gustavo Padovan | 1e1d139 | 2015-08-03 14:39:36 +0900 | [diff] [blame] | 263 | exynos_crtc->ops->update_plane(exynos_crtc, exynos_plane); |
Gustavo Padovan | 43dbdad | 2015-06-01 12:04:41 -0300 | [diff] [blame] | 264 | } |
| 265 | |
Gustavo Padovan | b744868 | 2015-06-01 12:04:42 -0300 | [diff] [blame] | 266 | static void exynos_plane_atomic_disable(struct drm_plane *plane, |
| 267 | struct drm_plane_state *old_state) |
| 268 | { |
| 269 | struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); |
| 270 | struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(old_state->crtc); |
| 271 | |
| 272 | if (!old_state->crtc) |
| 273 | return; |
| 274 | |
Gustavo Padovan | 9cc7610 | 2015-08-03 14:38:05 +0900 | [diff] [blame] | 275 | if (exynos_crtc->ops->disable_plane) |
Marek Szyprowski | 0114f40 | 2015-11-30 14:53:22 +0100 | [diff] [blame] | 276 | exynos_crtc->ops->disable_plane(exynos_crtc, exynos_plane); |
Gustavo Padovan | b744868 | 2015-06-01 12:04:42 -0300 | [diff] [blame] | 277 | } |
| 278 | |
Gustavo Padovan | 43dbdad | 2015-06-01 12:04:41 -0300 | [diff] [blame] | 279 | static const struct drm_plane_helper_funcs plane_helper_funcs = { |
| 280 | .atomic_check = exynos_plane_atomic_check, |
| 281 | .atomic_update = exynos_plane_atomic_update, |
Gustavo Padovan | b744868 | 2015-06-01 12:04:42 -0300 | [diff] [blame] | 282 | .atomic_disable = exynos_plane_atomic_disable, |
Gustavo Padovan | 43dbdad | 2015-06-01 12:04:41 -0300 | [diff] [blame] | 283 | }; |
| 284 | |
Gustavo Padovan | 6e2a3b6 | 2015-04-03 21:05:52 +0900 | [diff] [blame] | 285 | static void exynos_plane_attach_zpos_property(struct drm_plane *plane, |
Marek Szyprowski | e9dfe83 | 2018-05-23 12:15:50 +0200 | [diff] [blame] | 286 | int zpos, bool immutable) |
Joonyoung Shim | 00ae67c | 2012-06-27 14:27:06 +0900 | [diff] [blame] | 287 | { |
Marek Szyprowski | e47726a | 2016-05-11 17:16:06 +0200 | [diff] [blame] | 288 | if (immutable) |
Marek Szyprowski | e9dfe83 | 2018-05-23 12:15:50 +0200 | [diff] [blame] | 289 | drm_plane_create_zpos_immutable_property(plane, zpos); |
Marek Szyprowski | e47726a | 2016-05-11 17:16:06 +0200 | [diff] [blame] | 290 | else |
Marek Szyprowski | e9dfe83 | 2018-05-23 12:15:50 +0200 | [diff] [blame] | 291 | drm_plane_create_zpos_property(plane, zpos, 0, MAX_PLANE - 1); |
Joonyoung Shim | 00ae67c | 2012-06-27 14:27:06 +0900 | [diff] [blame] | 292 | } |
| 293 | |
Gustavo Padovan | 7ee14cd | 2015-04-03 21:03:40 +0900 | [diff] [blame] | 294 | int exynos_plane_init(struct drm_device *dev, |
Andrzej Hajda | 2c82607 | 2017-03-15 15:41:05 +0100 | [diff] [blame] | 295 | struct exynos_drm_plane *exynos_plane, unsigned int index, |
Marek Szyprowski | fd2d2fc | 2015-11-30 14:53:25 +0100 | [diff] [blame] | 296 | const struct exynos_drm_plane_config *config) |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 297 | { |
Joonyoung Shim | b5d2eb3 | 2012-06-27 14:27:04 +0900 | [diff] [blame] | 298 | int err; |
Christoph Manszewski | 482582c | 2018-09-21 14:24:37 +0200 | [diff] [blame] | 299 | unsigned int supported_modes = BIT(DRM_MODE_BLEND_PIXEL_NONE) | |
| 300 | BIT(DRM_MODE_BLEND_PREMULTI) | |
| 301 | BIT(DRM_MODE_BLEND_COVERAGE); |
| 302 | struct drm_plane *plane = &exynos_plane->base; |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 303 | |
Marek Szyprowski | fd2d2fc | 2015-11-30 14:53:25 +0100 | [diff] [blame] | 304 | err = drm_universal_plane_init(dev, &exynos_plane->base, |
Andrzej Hajda | 2c82607 | 2017-03-15 15:41:05 +0100 | [diff] [blame] | 305 | 1 << dev->mode_config.num_crtc, |
Marek Szyprowski | fd2d2fc | 2015-11-30 14:53:25 +0100 | [diff] [blame] | 306 | &exynos_plane_funcs, |
| 307 | config->pixel_formats, |
| 308 | config->num_pixel_formats, |
Ben Widawsky | e6fc3b6 | 2017-07-23 20:46:38 -0700 | [diff] [blame] | 309 | NULL, config->type, NULL); |
Joonyoung Shim | b5d2eb3 | 2012-06-27 14:27:04 +0900 | [diff] [blame] | 310 | if (err) { |
Inki Dae | 6f83d20 | 2019-04-15 14:24:36 +0900 | [diff] [blame] | 311 | DRM_DEV_ERROR(dev->dev, "failed to initialize plane\n"); |
Gustavo Padovan | 7ee14cd | 2015-04-03 21:03:40 +0900 | [diff] [blame] | 312 | return err; |
Joonyoung Shim | b5d2eb3 | 2012-06-27 14:27:04 +0900 | [diff] [blame] | 313 | } |
| 314 | |
Gustavo Padovan | 43dbdad | 2015-06-01 12:04:41 -0300 | [diff] [blame] | 315 | drm_plane_helper_add(&exynos_plane->base, &plane_helper_funcs); |
| 316 | |
Marek Szyprowski | 40bdfb0 | 2015-12-16 13:21:42 +0100 | [diff] [blame] | 317 | exynos_plane->index = index; |
Marek Szyprowski | fd2d2fc | 2015-11-30 14:53:25 +0100 | [diff] [blame] | 318 | exynos_plane->config = config; |
Gustavo Padovan | 6e2a3b6 | 2015-04-03 21:05:52 +0900 | [diff] [blame] | 319 | |
Marek Szyprowski | e9dfe83 | 2018-05-23 12:15:50 +0200 | [diff] [blame] | 320 | exynos_plane_attach_zpos_property(&exynos_plane->base, config->zpos, |
Marek Szyprowski | e47726a | 2016-05-11 17:16:06 +0200 | [diff] [blame] | 321 | !(config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS)); |
Joonyoung Shim | 00ae67c | 2012-06-27 14:27:06 +0900 | [diff] [blame] | 322 | |
Christoph Manszewski | 482582c | 2018-09-21 14:24:37 +0200 | [diff] [blame] | 323 | if (config->capabilities & EXYNOS_DRM_PLANE_CAP_PIX_BLEND) |
| 324 | drm_plane_create_blend_mode_property(plane, supported_modes); |
| 325 | |
Christoph Manszewski | 6ac99a3 | 2018-09-21 14:24:38 +0200 | [diff] [blame] | 326 | if (config->capabilities & EXYNOS_DRM_PLANE_CAP_WIN_BLEND) |
| 327 | drm_plane_create_alpha_property(plane); |
| 328 | |
Gustavo Padovan | 7ee14cd | 2015-04-03 21:03:40 +0900 | [diff] [blame] | 329 | return 0; |
Joonyoung Shim | 864ee9e | 2011-12-08 17:54:07 +0900 | [diff] [blame] | 330 | } |