Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 1 | /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 12 | |
| 13 | #define pr_fmt(fmt) "[drm:%s:%d] " fmt, __func__, __LINE__ |
| 14 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 15 | #include <linux/debugfs.h> |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 16 | #include <uapi/drm/sde_drm.h> |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 17 | |
| 18 | #include "msm_prop.h" |
| 19 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 20 | #include "sde_kms.h" |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 21 | #include "sde_fence.h" |
Clarence Ip | c475b08 | 2016-06-26 09:27:23 -0400 | [diff] [blame] | 22 | #include "sde_formats.h" |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 23 | #include "sde_hw_sspp.h" |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 24 | #include "sde_trace.h" |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 25 | #include "sde_crtc.h" |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 26 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 27 | #define SDE_DEBUG_PLANE(pl, fmt, ...) SDE_DEBUG("plane%d " fmt,\ |
| 28 | (pl) ? (pl)->base.base.id : -1, ##__VA_ARGS__) |
| 29 | |
| 30 | #define SDE_ERROR_PLANE(pl, fmt, ...) SDE_ERROR("plane%d " fmt,\ |
| 31 | (pl) ? (pl)->base.base.id : -1, ##__VA_ARGS__) |
| 32 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 33 | #define DECIMATED_DIMENSION(dim, deci) (((dim) + ((1 << (deci)) - 1)) >> (deci)) |
| 34 | #define PHASE_STEP_SHIFT 21 |
| 35 | #define PHASE_STEP_UNIT_SCALE ((int) (1 << PHASE_STEP_SHIFT)) |
| 36 | #define PHASE_RESIDUAL 15 |
| 37 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 38 | #define SHARP_STRENGTH_DEFAULT 32 |
| 39 | #define SHARP_EDGE_THR_DEFAULT 112 |
| 40 | #define SHARP_SMOOTH_THR_DEFAULT 8 |
| 41 | #define SHARP_NOISE_THR_DEFAULT 2 |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 42 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 43 | #define SDE_NAME_SIZE 12 |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 44 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 45 | #define SDE_PLANE_COLOR_FILL_FLAG BIT(31) |
| 46 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 47 | /* dirty bits for update function */ |
| 48 | #define SDE_PLANE_DIRTY_RECTS 0x1 |
| 49 | #define SDE_PLANE_DIRTY_FORMAT 0x2 |
| 50 | #define SDE_PLANE_DIRTY_SHARPEN 0x4 |
| 51 | #define SDE_PLANE_DIRTY_ALL 0xFFFFFFFF |
| 52 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 53 | /** |
| 54 | * enum sde_plane_qos - Different qos configurations for each pipe |
| 55 | * |
| 56 | * @SDE_PLANE_QOS_VBLANK_CTRL: Setup VBLANK qos for the pipe. |
| 57 | * @SDE_PLANE_QOS_VBLANK_AMORTIZE: Enables Amortization within pipe. |
| 58 | * this configuration is mutually exclusive from VBLANK_CTRL. |
| 59 | * @SDE_PLANE_QOS_PANIC_CTRL: Setup panic for the pipe. |
| 60 | */ |
| 61 | enum sde_plane_qos { |
| 62 | SDE_PLANE_QOS_VBLANK_CTRL = BIT(0), |
| 63 | SDE_PLANE_QOS_VBLANK_AMORTIZE = BIT(1), |
| 64 | SDE_PLANE_QOS_PANIC_CTRL = BIT(2), |
| 65 | }; |
| 66 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 67 | /* |
| 68 | * struct sde_plane - local sde plane structure |
| 69 | * @csc_cfg: Decoded user configuration for csc |
| 70 | * @csc_usr_ptr: Points to csc_cfg if valid user config available |
| 71 | * @csc_ptr: Points to sde_csc_cfg structure to use for current |
| 72 | */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 73 | struct sde_plane { |
| 74 | struct drm_plane base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 75 | |
| 76 | int mmu_id; |
| 77 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 78 | struct mutex lock; |
| 79 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 80 | enum sde_sspp pipe; |
| 81 | uint32_t features; /* capabilities from catalog */ |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 82 | uint32_t nformats; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 83 | uint32_t formats[64]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 84 | |
| 85 | struct sde_hw_pipe *pipe_hw; |
| 86 | struct sde_hw_pipe_cfg pipe_cfg; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 87 | struct sde_hw_sharp_cfg sharp_cfg; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 88 | struct sde_hw_scaler3_cfg scaler3_cfg; |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 89 | struct sde_hw_pipe_qos_cfg pipe_qos_cfg; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 90 | uint32_t color_fill; |
| 91 | bool is_error; |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 92 | bool is_rt_pipe; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 93 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 94 | struct sde_hw_pixel_ext pixel_ext; |
| 95 | bool pixel_ext_usr; |
| 96 | |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 97 | struct sde_csc_cfg csc_cfg; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 98 | struct sde_csc_cfg *csc_usr_ptr; |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 99 | struct sde_csc_cfg *csc_ptr; |
| 100 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 101 | const struct sde_sspp_sub_blks *pipe_sblk; |
| 102 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 103 | char pipe_name[SDE_NAME_SIZE]; |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 104 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 105 | struct msm_property_info property_info; |
| 106 | struct msm_property_data property_data[PLANE_PROP_COUNT]; |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 107 | struct drm_property_blob *blob_info; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 108 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 109 | /* debugfs related stuff */ |
| 110 | struct dentry *debugfs_root; |
| 111 | struct sde_debugfs_regset32 debugfs_src; |
| 112 | struct sde_debugfs_regset32 debugfs_scaler; |
| 113 | struct sde_debugfs_regset32 debugfs_csc; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 114 | }; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 115 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 116 | #define to_sde_plane(x) container_of(x, struct sde_plane, base) |
| 117 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 118 | static bool sde_plane_enabled(struct drm_plane_state *state) |
| 119 | { |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 120 | return state && state->fb && state->crtc; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 121 | } |
| 122 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 123 | /** |
| 124 | * _sde_plane_calc_fill_level - calculate fill level of the given source format |
| 125 | * @plane: Pointer to drm plane |
| 126 | * @fmt: Pointer to source buffer format |
| 127 | * @src_wdith: width of source buffer |
| 128 | * Return: fill level corresponding to the source buffer/format or 0 if error |
| 129 | */ |
| 130 | static inline int _sde_plane_calc_fill_level(struct drm_plane *plane, |
| 131 | const struct sde_format *fmt, u32 src_width) |
| 132 | { |
| 133 | struct sde_plane *psde; |
| 134 | u32 fixed_buff_size; |
| 135 | u32 total_fl; |
| 136 | |
| 137 | if (!plane || !fmt) { |
| 138 | SDE_ERROR("invalid arguments\n"); |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | psde = to_sde_plane(plane); |
| 143 | fixed_buff_size = psde->pipe_sblk->pixel_ram_size; |
| 144 | |
| 145 | if (fmt->fetch_planes == SDE_PLANE_PSEUDO_PLANAR) { |
| 146 | if (fmt->chroma_sample == SDE_CHROMA_420) { |
| 147 | /* NV12 */ |
| 148 | total_fl = (fixed_buff_size / 2) / |
| 149 | ((src_width + 32) * fmt->bpp); |
| 150 | } else { |
| 151 | /* non NV12 */ |
| 152 | total_fl = (fixed_buff_size) / |
| 153 | ((src_width + 32) * fmt->bpp); |
| 154 | } |
| 155 | } else { |
| 156 | total_fl = (fixed_buff_size * 2) / |
| 157 | ((src_width + 32) * fmt->bpp); |
| 158 | } |
| 159 | |
| 160 | SDE_DEBUG("plane%u: pnum:%d fmt:%x w:%u fl:%u\n", |
| 161 | plane->base.id, psde->pipe - SSPP_VIG0, |
| 162 | fmt->base.pixel_format, src_width, total_fl); |
| 163 | |
| 164 | return total_fl; |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * _sde_plane_get_qos_lut_linear - get linear LUT mapping |
| 169 | * @total_fl: fill level |
| 170 | * Return: LUT setting corresponding to the fill level |
| 171 | */ |
| 172 | static inline u32 _sde_plane_get_qos_lut_linear(u32 total_fl) |
| 173 | { |
| 174 | u32 qos_lut; |
| 175 | |
| 176 | if (total_fl <= 4) |
| 177 | qos_lut = 0x1B; |
| 178 | else if (total_fl <= 5) |
| 179 | qos_lut = 0x5B; |
| 180 | else if (total_fl <= 6) |
| 181 | qos_lut = 0x15B; |
| 182 | else if (total_fl <= 7) |
| 183 | qos_lut = 0x55B; |
| 184 | else if (total_fl <= 8) |
| 185 | qos_lut = 0x155B; |
| 186 | else if (total_fl <= 9) |
| 187 | qos_lut = 0x555B; |
| 188 | else if (total_fl <= 10) |
| 189 | qos_lut = 0x1555B; |
| 190 | else if (total_fl <= 11) |
| 191 | qos_lut = 0x5555B; |
| 192 | else if (total_fl <= 12) |
| 193 | qos_lut = 0x15555B; |
| 194 | else |
| 195 | qos_lut = 0x55555B; |
| 196 | |
| 197 | return qos_lut; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * _sde_plane_get_qos_lut_macrotile - get macrotile LUT mapping |
| 202 | * @total_fl: fill level |
| 203 | * Return: LUT setting corresponding to the fill level |
| 204 | */ |
| 205 | static inline u32 _sde_plane_get_qos_lut_macrotile(u32 total_fl) |
| 206 | { |
| 207 | u32 qos_lut; |
| 208 | |
| 209 | if (total_fl <= 10) |
| 210 | qos_lut = 0x1AAff; |
| 211 | else if (total_fl <= 11) |
| 212 | qos_lut = 0x5AAFF; |
| 213 | else if (total_fl <= 12) |
| 214 | qos_lut = 0x15AAFF; |
| 215 | else |
| 216 | qos_lut = 0x55AAFF; |
| 217 | |
| 218 | return qos_lut; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * _sde_plane_is_rt_pipe - check if the given plane requires real-time QoS |
| 223 | * @plane: Pointer to drm plane |
| 224 | * @crtc: Pointer to drm crtc associated with the given plane |
| 225 | */ |
| 226 | static bool _sde_plane_is_rt_pipe(struct drm_plane *plane, |
| 227 | struct drm_crtc *crtc) |
| 228 | { |
| 229 | struct sde_plane *psde = to_sde_plane(plane); |
| 230 | struct drm_connector *connector; |
| 231 | bool is_rt = false; |
| 232 | |
| 233 | /* check if this plane has a physical connector interface */ |
Alan Kwong | 894837a | 2016-09-29 01:15:23 -0400 | [diff] [blame^] | 234 | mutex_lock(&plane->dev->mode_config.mutex); |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 235 | drm_for_each_connector(connector, plane->dev) |
| 236 | if (connector->state && |
| 237 | (connector->state->crtc == crtc) && |
| 238 | (connector->connector_type |
| 239 | != DRM_MODE_CONNECTOR_VIRTUAL)) { |
| 240 | is_rt = true; |
| 241 | break; |
| 242 | } |
Alan Kwong | 894837a | 2016-09-29 01:15:23 -0400 | [diff] [blame^] | 243 | mutex_unlock(&plane->dev->mode_config.mutex); |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 244 | |
| 245 | SDE_DEBUG("plane%u: pnum:%d rt:%d\n", |
| 246 | plane->base.id, psde->pipe - SSPP_VIG0, is_rt); |
| 247 | |
| 248 | return is_rt; |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * _sde_plane_set_qos_lut - set QoS LUT of the given plane |
| 253 | * @plane: Pointer to drm plane |
| 254 | * @fb: Pointer to framebuffer associated with the given plane |
| 255 | */ |
| 256 | static void _sde_plane_set_qos_lut(struct drm_plane *plane, |
| 257 | struct drm_framebuffer *fb) |
| 258 | { |
| 259 | struct sde_plane *psde; |
| 260 | const struct sde_format *fmt = NULL; |
| 261 | u32 qos_lut; |
| 262 | u32 total_fl = 0; |
| 263 | |
| 264 | if (!plane || !fb) { |
| 265 | SDE_ERROR("invalid arguments plane %d fb %d\n", |
| 266 | plane != 0, fb != 0); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | psde = to_sde_plane(plane); |
| 271 | |
| 272 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 273 | SDE_ERROR("invalid arguments\n"); |
| 274 | return; |
| 275 | } else if (!psde->pipe_hw->ops.setup_creq_lut) { |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | if (!psde->is_rt_pipe) { |
| 280 | qos_lut = psde->pipe_sblk->creq_lut_nrt; |
| 281 | } else { |
| 282 | fmt = sde_get_sde_format_ext( |
| 283 | fb->pixel_format, |
| 284 | fb->modifier, |
| 285 | drm_format_num_planes(fb->pixel_format)); |
| 286 | total_fl = _sde_plane_calc_fill_level(plane, fmt, |
| 287 | psde->pipe_cfg.src_rect.w); |
| 288 | |
| 289 | if (SDE_FORMAT_IS_LINEAR(fmt)) |
| 290 | qos_lut = _sde_plane_get_qos_lut_linear(total_fl); |
| 291 | else |
| 292 | qos_lut = _sde_plane_get_qos_lut_macrotile(total_fl); |
| 293 | } |
| 294 | |
| 295 | psde->pipe_qos_cfg.creq_lut = qos_lut; |
| 296 | |
| 297 | trace_sde_perf_set_qos_luts(psde->pipe - SSPP_VIG0, |
| 298 | (fmt) ? fmt->base.pixel_format : 0, |
| 299 | psde->is_rt_pipe, total_fl, qos_lut, |
| 300 | (fmt) ? SDE_FORMAT_IS_LINEAR(fmt) : 0); |
| 301 | |
| 302 | SDE_DEBUG("plane%u: pnum:%d fmt:%x rt:%d fl:%u lut:0x%x\n", |
| 303 | plane->base.id, |
| 304 | psde->pipe - SSPP_VIG0, |
| 305 | (fmt) ? fmt->base.pixel_format : 0, |
| 306 | psde->is_rt_pipe, total_fl, qos_lut); |
| 307 | |
| 308 | psde->pipe_hw->ops.setup_creq_lut(psde->pipe_hw, &psde->pipe_qos_cfg); |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * _sde_plane_set_panic_lut - set danger/safe LUT of the given plane |
| 313 | * @plane: Pointer to drm plane |
| 314 | * @fb: Pointer to framebuffer associated with the given plane |
| 315 | */ |
| 316 | static void _sde_plane_set_danger_lut(struct drm_plane *plane, |
| 317 | struct drm_framebuffer *fb) |
| 318 | { |
| 319 | struct sde_plane *psde; |
| 320 | const struct sde_format *fmt = NULL; |
| 321 | u32 danger_lut, safe_lut; |
| 322 | |
| 323 | if (!plane || !fb) { |
| 324 | SDE_ERROR("invalid arguments\n"); |
| 325 | return; |
| 326 | } |
| 327 | |
| 328 | psde = to_sde_plane(plane); |
| 329 | |
| 330 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 331 | SDE_ERROR("invalid arguments\n"); |
| 332 | return; |
| 333 | } else if (!psde->pipe_hw->ops.setup_danger_safe_lut) { |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | if (!psde->is_rt_pipe) { |
| 338 | danger_lut = psde->pipe_sblk->danger_lut_nrt; |
| 339 | safe_lut = psde->pipe_sblk->safe_lut_nrt; |
| 340 | } else { |
| 341 | fmt = sde_get_sde_format_ext( |
| 342 | fb->pixel_format, |
| 343 | fb->modifier, |
| 344 | drm_format_num_planes(fb->pixel_format)); |
| 345 | |
| 346 | if (SDE_FORMAT_IS_LINEAR(fmt)) { |
| 347 | danger_lut = psde->pipe_sblk->danger_lut_linear; |
| 348 | safe_lut = psde->pipe_sblk->safe_lut_linear; |
| 349 | } else { |
| 350 | danger_lut = psde->pipe_sblk->danger_lut_tile; |
| 351 | safe_lut = psde->pipe_sblk->safe_lut_tile; |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | psde->pipe_qos_cfg.danger_lut = danger_lut; |
| 356 | psde->pipe_qos_cfg.safe_lut = safe_lut; |
| 357 | |
| 358 | trace_sde_perf_set_danger_luts(psde->pipe - SSPP_VIG0, |
| 359 | (fmt) ? fmt->base.pixel_format : 0, |
| 360 | (fmt) ? fmt->fetch_mode : 0, |
| 361 | psde->pipe_qos_cfg.danger_lut, |
| 362 | psde->pipe_qos_cfg.safe_lut); |
| 363 | |
| 364 | SDE_DEBUG("plane%u: pnum:%d fmt:%x mode:%d luts[0x%x, 0x%x]\n", |
| 365 | plane->base.id, |
| 366 | psde->pipe - SSPP_VIG0, |
| 367 | fmt ? fmt->base.pixel_format : 0, |
| 368 | fmt ? fmt->fetch_mode : -1, |
| 369 | psde->pipe_qos_cfg.danger_lut, |
| 370 | psde->pipe_qos_cfg.safe_lut); |
| 371 | |
| 372 | psde->pipe_hw->ops.setup_danger_safe_lut(psde->pipe_hw, |
| 373 | &psde->pipe_qos_cfg); |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * _sde_plane_set_qos_ctrl - set QoS control of the given plane |
| 378 | * @plane: Pointer to drm plane |
| 379 | * @enable: true to enable QoS control |
| 380 | * @flags: QoS control mode (enum sde_plane_qos) |
| 381 | */ |
| 382 | static void _sde_plane_set_qos_ctrl(struct drm_plane *plane, |
| 383 | bool enable, u32 flags) |
| 384 | { |
| 385 | struct sde_plane *psde; |
| 386 | |
| 387 | if (!plane) { |
| 388 | SDE_ERROR("invalid arguments\n"); |
| 389 | return; |
| 390 | } |
| 391 | |
| 392 | psde = to_sde_plane(plane); |
| 393 | |
| 394 | if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 395 | SDE_ERROR("invalid arguments\n"); |
| 396 | return; |
| 397 | } else if (!psde->pipe_hw->ops.setup_qos_ctrl) { |
| 398 | return; |
| 399 | } |
| 400 | |
| 401 | if (flags & SDE_PLANE_QOS_VBLANK_CTRL) { |
| 402 | psde->pipe_qos_cfg.creq_vblank = psde->pipe_sblk->creq_vblank; |
| 403 | psde->pipe_qos_cfg.danger_vblank = |
| 404 | psde->pipe_sblk->danger_vblank; |
| 405 | psde->pipe_qos_cfg.vblank_en = enable; |
| 406 | } |
| 407 | |
| 408 | if (flags & SDE_PLANE_QOS_VBLANK_AMORTIZE) { |
| 409 | /* this feature overrules previous VBLANK_CTRL */ |
| 410 | psde->pipe_qos_cfg.vblank_en = false; |
| 411 | psde->pipe_qos_cfg.creq_vblank = 0; /* clear vblank bits */ |
| 412 | } |
| 413 | |
| 414 | if (flags & SDE_PLANE_QOS_PANIC_CTRL) |
| 415 | psde->pipe_qos_cfg.danger_safe_en = enable; |
| 416 | |
| 417 | if (!psde->is_rt_pipe) { |
| 418 | psde->pipe_qos_cfg.vblank_en = false; |
| 419 | psde->pipe_qos_cfg.danger_safe_en = false; |
| 420 | } |
| 421 | |
| 422 | SDE_DEBUG("plane%u: pnum:%d ds:%d vb:%d pri[0x%x, 0x%x]\n", |
| 423 | plane->base.id, |
| 424 | psde->pipe - SSPP_VIG0, |
| 425 | psde->pipe_qos_cfg.danger_safe_en, |
| 426 | psde->pipe_qos_cfg.vblank_en, |
| 427 | psde->pipe_qos_cfg.creq_vblank, |
| 428 | psde->pipe_qos_cfg.danger_vblank); |
| 429 | |
| 430 | psde->pipe_hw->ops.setup_qos_ctrl(psde->pipe_hw, |
| 431 | &psde->pipe_qos_cfg); |
| 432 | } |
| 433 | |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 434 | /** |
| 435 | * _sde_plane_set_ot_limit - set OT limit for the given plane |
| 436 | * @plane: Pointer to drm plane |
| 437 | * @crtc: Pointer to drm crtc |
| 438 | */ |
| 439 | static void _sde_plane_set_ot_limit(struct drm_plane *plane, |
| 440 | struct drm_crtc *crtc) |
| 441 | { |
| 442 | struct sde_plane *psde; |
| 443 | struct sde_vbif_set_ot_params ot_params; |
| 444 | struct msm_drm_private *priv; |
| 445 | struct sde_kms *sde_kms; |
| 446 | |
| 447 | if (!plane || !plane->dev || !crtc) { |
| 448 | SDE_ERROR("invalid arguments plane %d crtc %d\n", |
| 449 | plane != 0, crtc != 0); |
| 450 | return; |
| 451 | } |
| 452 | |
| 453 | priv = plane->dev->dev_private; |
| 454 | if (!priv || !priv->kms) { |
| 455 | SDE_ERROR("invalid KMS reference\n"); |
| 456 | return; |
| 457 | } |
| 458 | |
| 459 | sde_kms = to_sde_kms(priv->kms); |
| 460 | psde = to_sde_plane(plane); |
| 461 | if (!psde->pipe_hw) { |
| 462 | SDE_ERROR("invalid pipe reference\n"); |
| 463 | return; |
| 464 | } |
| 465 | |
| 466 | memset(&ot_params, 0, sizeof(ot_params)); |
| 467 | ot_params.xin_id = psde->pipe_hw->cap->xin_id; |
| 468 | ot_params.num = psde->pipe_hw->idx - SSPP_NONE; |
| 469 | ot_params.width = psde->pipe_cfg.src_rect.w; |
| 470 | ot_params.height = psde->pipe_cfg.src_rect.h; |
| 471 | ot_params.is_wfd = !psde->is_rt_pipe; |
| 472 | ot_params.frame_rate = crtc->mode.vrefresh; |
| 473 | ot_params.vbif_idx = VBIF_RT; |
| 474 | ot_params.clk_ctrl = psde->pipe_hw->cap->clk_ctrl; |
| 475 | ot_params.rd = true; |
| 476 | |
| 477 | sde_vbif_set_ot_limit(sde_kms, &ot_params); |
| 478 | } |
| 479 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 480 | /* helper to update a state's input fence pointer from the property */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 481 | static void _sde_plane_set_input_fence(struct sde_plane *psde, |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 482 | struct sde_plane_state *pstate, uint64_t fd) |
| 483 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 484 | if (!psde || !pstate) { |
| 485 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 486 | psde != 0, pstate != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 487 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 488 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 489 | |
| 490 | /* clear previous reference */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 491 | if (pstate->input_fence) |
| 492 | sde_sync_put(pstate->input_fence); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 493 | |
| 494 | /* get fence pointer for later */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 495 | pstate->input_fence = sde_sync_get(fd); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 496 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 497 | SDE_DEBUG_PLANE(psde, "0x%llX\n", fd); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 498 | } |
| 499 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 500 | int sde_plane_wait_input_fence(struct drm_plane *plane, uint32_t wait_ms) |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 501 | { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 502 | struct sde_plane *psde; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 503 | struct sde_plane_state *pstate; |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 504 | void *input_fence; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 505 | int ret = -EINVAL; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 506 | |
| 507 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 508 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 509 | } else if (!plane->state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 510 | SDE_ERROR_PLANE(to_sde_plane(plane), "invalid state\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 511 | } else { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 512 | psde = to_sde_plane(plane); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 513 | pstate = to_sde_plane_state(plane->state); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 514 | input_fence = pstate->input_fence; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 515 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 516 | if (input_fence) { |
| 517 | ret = sde_sync_wait(input_fence, wait_ms); |
| 518 | switch (ret) { |
| 519 | case 0: |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 520 | SDE_DEBUG_PLANE(psde, "signaled\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 521 | break; |
| 522 | case -ETIME: |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 523 | SDE_ERROR_PLANE(psde, "timeout, %ums\n", |
| 524 | wait_ms); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 525 | psde->is_error = true; |
| 526 | break; |
| 527 | default: |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 528 | SDE_ERROR_PLANE(psde, "error, %d\n", ret); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 529 | psde->is_error = true; |
| 530 | break; |
| 531 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 532 | } else { |
| 533 | ret = 0; |
| 534 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 535 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 536 | return ret; |
| 537 | } |
| 538 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 539 | static inline void _sde_plane_set_scanout(struct drm_plane *plane, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 540 | struct sde_plane_state *pstate, |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 541 | struct sde_hw_pipe_cfg *pipe_cfg, |
| 542 | struct drm_framebuffer *fb) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 543 | { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 544 | struct sde_plane *psde; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 545 | int ret; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 546 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 547 | if (!plane || !pstate || !pipe_cfg || !fb) { |
| 548 | SDE_ERROR( |
| 549 | "invalid arg(s), plane %d state %d cfg %d fb %d\n", |
| 550 | plane != 0, pstate != 0, pipe_cfg != 0, fb != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 551 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 552 | } |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 553 | |
| 554 | psde = to_sde_plane(plane); |
Clarence Ip | b6eb236 | 2016-09-08 16:18:13 -0400 | [diff] [blame] | 555 | if (!psde->pipe_hw) { |
| 556 | SDE_ERROR_PLANE(psde, "invalid pipe_hw\n"); |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 557 | return; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 558 | } |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 559 | |
Clarence Ip | b6eb236 | 2016-09-08 16:18:13 -0400 | [diff] [blame] | 560 | ret = sde_format_populate_layout(psde->mmu_id, fb, &pipe_cfg->layout); |
| 561 | if (ret == -EAGAIN) |
| 562 | SDE_DEBUG_PLANE(psde, "not updating same src addrs\n"); |
| 563 | else if (ret) |
| 564 | SDE_ERROR_PLANE(psde, "failed to get format layout, %d\n", ret); |
| 565 | else if (psde->pipe_hw->ops.setup_sourceaddress) |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 566 | psde->pipe_hw->ops.setup_sourceaddress(psde->pipe_hw, pipe_cfg); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 567 | } |
| 568 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 569 | static void _sde_plane_setup_scaler3(struct sde_plane *psde, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 570 | uint32_t src_w, uint32_t src_h, uint32_t dst_w, uint32_t dst_h, |
| 571 | struct sde_hw_scaler3_cfg *scale_cfg, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 572 | const struct sde_format *fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 573 | uint32_t chroma_subsmpl_h, uint32_t chroma_subsmpl_v) |
| 574 | { |
| 575 | } |
| 576 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 577 | /** |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 578 | * _sde_plane_setup_scaler2 - determine default scaler phase steps/filter type |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 579 | * @psde: Pointer to SDE plane object |
| 580 | * @src: Source size |
| 581 | * @dst: Destination size |
| 582 | * @phase_steps: Pointer to output array for phase steps |
| 583 | * @filter: Pointer to output array for filter type |
| 584 | * @fmt: Pointer to format definition |
| 585 | * @chroma_subsampling: Subsampling amount for chroma channel |
| 586 | * |
| 587 | * Returns: 0 on success |
| 588 | */ |
| 589 | static int _sde_plane_setup_scaler2(struct sde_plane *psde, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 590 | uint32_t src, uint32_t dst, uint32_t *phase_steps, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 591 | enum sde_hw_filter *filter, const struct sde_format *fmt, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 592 | uint32_t chroma_subsampling) |
| 593 | { |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 594 | if (!psde || !phase_steps || !filter || !fmt) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 595 | SDE_ERROR( |
| 596 | "invalid arg(s), plane %d phase %d filter %d fmt %d\n", |
| 597 | psde != 0, phase_steps != 0, filter != 0, fmt != 0); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 598 | return -EINVAL; |
| 599 | } |
| 600 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 601 | /* calculate phase steps, leave init phase as zero */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 602 | phase_steps[SDE_SSPP_COMP_0] = |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 603 | mult_frac(1 << PHASE_STEP_SHIFT, src, dst); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 604 | phase_steps[SDE_SSPP_COMP_1_2] = |
| 605 | phase_steps[SDE_SSPP_COMP_0] / chroma_subsampling; |
| 606 | phase_steps[SDE_SSPP_COMP_2] = phase_steps[SDE_SSPP_COMP_1_2]; |
| 607 | phase_steps[SDE_SSPP_COMP_3] = phase_steps[SDE_SSPP_COMP_0]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 608 | |
| 609 | /* calculate scaler config, if necessary */ |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 610 | if (SDE_FORMAT_IS_YUV(fmt) || src != dst) { |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 611 | filter[SDE_SSPP_COMP_3] = |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 612 | (src <= dst) ? SDE_SCALE_FILTER_BIL : |
| 613 | SDE_SCALE_FILTER_PCMN; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 614 | |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 615 | if (SDE_FORMAT_IS_YUV(fmt)) { |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 616 | filter[SDE_SSPP_COMP_0] = SDE_SCALE_FILTER_CA; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 617 | filter[SDE_SSPP_COMP_1_2] = filter[SDE_SSPP_COMP_3]; |
| 618 | } else { |
| 619 | filter[SDE_SSPP_COMP_0] = filter[SDE_SSPP_COMP_3]; |
| 620 | filter[SDE_SSPP_COMP_1_2] = |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 621 | SDE_SCALE_FILTER_NEAREST; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 622 | } |
| 623 | } else { |
| 624 | /* disable scaler */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 625 | filter[SDE_SSPP_COMP_0] = SDE_SCALE_FILTER_MAX; |
| 626 | filter[SDE_SSPP_COMP_1_2] = SDE_SCALE_FILTER_MAX; |
| 627 | filter[SDE_SSPP_COMP_3] = SDE_SCALE_FILTER_MAX; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 628 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 629 | return 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 630 | } |
| 631 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 632 | /** |
| 633 | * _sde_plane_setup_pixel_ext - determine default pixel extension values |
| 634 | * @psde: Pointer to SDE plane object |
| 635 | * @src: Source size |
| 636 | * @dst: Destination size |
| 637 | * @decimated_src: Source size after decimation, if any |
| 638 | * @phase_steps: Pointer to output array for phase steps |
| 639 | * @out_src: Output array for pixel extension values |
| 640 | * @out_edge1: Output array for pixel extension first edge |
| 641 | * @out_edge2: Output array for pixel extension second edge |
| 642 | * @filter: Pointer to array for filter type |
| 643 | * @fmt: Pointer to format definition |
| 644 | * @chroma_subsampling: Subsampling amount for chroma channel |
| 645 | * @post_compare: Whether to chroma subsampled source size for comparisions |
| 646 | */ |
| 647 | static void _sde_plane_setup_pixel_ext(struct sde_plane *psde, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 648 | uint32_t src, uint32_t dst, uint32_t decimated_src, |
| 649 | uint32_t *phase_steps, uint32_t *out_src, int *out_edge1, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 650 | int *out_edge2, enum sde_hw_filter *filter, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 651 | const struct sde_format *fmt, uint32_t chroma_subsampling, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 652 | bool post_compare) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 653 | { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 654 | int64_t edge1, edge2, caf; |
| 655 | uint32_t src_work; |
| 656 | int i, tmp; |
| 657 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 658 | if (psde && phase_steps && out_src && out_edge1 && |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 659 | out_edge2 && filter && fmt) { |
| 660 | /* handle CAF for YUV formats */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 661 | if (SDE_FORMAT_IS_YUV(fmt) && *filter == SDE_SCALE_FILTER_CA) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 662 | caf = PHASE_STEP_UNIT_SCALE; |
| 663 | else |
| 664 | caf = 0; |
| 665 | |
| 666 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 667 | src_work = decimated_src; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 668 | if (i == SDE_SSPP_COMP_1_2 || i == SDE_SSPP_COMP_2) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 669 | src_work /= chroma_subsampling; |
| 670 | if (post_compare) |
| 671 | src = src_work; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 672 | if (!SDE_FORMAT_IS_YUV(fmt) && (src == dst)) { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 673 | /* unity */ |
| 674 | edge1 = 0; |
| 675 | edge2 = 0; |
| 676 | } else if (dst >= src) { |
| 677 | /* upscale */ |
| 678 | edge1 = (1 << PHASE_RESIDUAL); |
| 679 | edge1 -= caf; |
| 680 | edge2 = (1 << PHASE_RESIDUAL); |
| 681 | edge2 += (dst - 1) * *(phase_steps + i); |
| 682 | edge2 -= (src_work - 1) * PHASE_STEP_UNIT_SCALE; |
| 683 | edge2 += caf; |
| 684 | edge2 = -(edge2); |
| 685 | } else { |
| 686 | /* downscale */ |
| 687 | edge1 = 0; |
| 688 | edge2 = (dst - 1) * *(phase_steps + i); |
| 689 | edge2 -= (src_work - 1) * PHASE_STEP_UNIT_SCALE; |
| 690 | edge2 += *(phase_steps + i); |
| 691 | edge2 = -(edge2); |
| 692 | } |
| 693 | |
| 694 | /* only enable CAF for luma plane */ |
| 695 | caf = 0; |
| 696 | |
| 697 | /* populate output arrays */ |
| 698 | *(out_src + i) = src_work; |
| 699 | |
| 700 | /* edge updates taken from __pxl_extn_helper */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 701 | if (edge1 >= 0) { |
| 702 | tmp = (uint32_t)edge1; |
| 703 | tmp >>= PHASE_STEP_SHIFT; |
| 704 | *(out_edge1 + i) = -tmp; |
| 705 | } else { |
| 706 | tmp = (uint32_t)(-edge1); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 707 | *(out_edge1 + i) = |
| 708 | (tmp + PHASE_STEP_UNIT_SCALE - 1) >> |
| 709 | PHASE_STEP_SHIFT; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 710 | } |
| 711 | if (edge2 >= 0) { |
| 712 | tmp = (uint32_t)edge2; |
| 713 | tmp >>= PHASE_STEP_SHIFT; |
| 714 | *(out_edge2 + i) = -tmp; |
| 715 | } else { |
| 716 | tmp = (uint32_t)(-edge2); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 717 | *(out_edge2 + i) = |
| 718 | (tmp + PHASE_STEP_UNIT_SCALE - 1) >> |
| 719 | PHASE_STEP_SHIFT; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 725 | static inline void _sde_plane_setup_csc(struct sde_plane *psde) |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 726 | { |
| 727 | static const struct sde_csc_cfg sde_csc_YUV2RGB_601L = { |
| 728 | { |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 729 | /* S15.16 format */ |
| 730 | 0x00012A00, 0x00000000, 0x00019880, |
| 731 | 0x00012A00, 0xFFFF9B80, 0xFFFF3000, |
| 732 | 0x00012A00, 0x00020480, 0x00000000, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 733 | }, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 734 | /* signed bias */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 735 | { 0xfff0, 0xff80, 0xff80,}, |
| 736 | { 0x0, 0x0, 0x0,}, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 737 | /* unsigned clamp */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 738 | { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0,}, |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 739 | { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,}, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 740 | }; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 741 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 742 | if (!psde) { |
| 743 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 744 | return; |
| 745 | } |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 746 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 747 | /* revert to kernel default if override not available */ |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 748 | if (psde->csc_usr_ptr) |
| 749 | psde->csc_ptr = psde->csc_usr_ptr; |
| 750 | else |
Clarence Ip | 373f859 | 2016-05-26 00:58:42 -0400 | [diff] [blame] | 751 | psde->csc_ptr = (struct sde_csc_cfg *)&sde_csc_YUV2RGB_601L; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 752 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 753 | SDE_DEBUG_PLANE(psde, "using 0x%X 0x%X 0x%X...\n", |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 754 | psde->csc_ptr->csc_mv[0], |
| 755 | psde->csc_ptr->csc_mv[1], |
| 756 | psde->csc_ptr->csc_mv[2]); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 757 | } |
| 758 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 759 | static void _sde_plane_setup_scaler(struct sde_plane *psde, |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 760 | const struct sde_format *fmt, |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 761 | struct sde_plane_state *pstate) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 762 | { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 763 | struct sde_hw_pixel_ext *pe; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 764 | uint32_t chroma_subsmpl_h, chroma_subsmpl_v; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 765 | uint32_t tmp, i; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 766 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 767 | if (!psde || !fmt) { |
| 768 | SDE_ERROR("invalid arg(s), plane %d fmt %d state %d\n", |
| 769 | psde != 0, fmt != 0, pstate != 0); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 770 | return; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 771 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 772 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 773 | pe = &(psde->pixel_ext); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 774 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 775 | psde->pipe_cfg.horz_decimation = |
| 776 | sde_plane_get_property(pstate, PLANE_PROP_H_DECIMATE); |
| 777 | psde->pipe_cfg.vert_decimation = |
| 778 | sde_plane_get_property(pstate, PLANE_PROP_V_DECIMATE); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 779 | |
| 780 | /* don't chroma subsample if decimating */ |
| 781 | chroma_subsmpl_h = psde->pipe_cfg.horz_decimation ? 1 : |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 782 | drm_format_horz_chroma_subsampling(fmt->base.pixel_format); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 783 | chroma_subsmpl_v = psde->pipe_cfg.vert_decimation ? 1 : |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 784 | drm_format_vert_chroma_subsampling(fmt->base.pixel_format); |
Clarence Ip | 04ec67d | 2016-05-26 01:16:15 -0400 | [diff] [blame] | 785 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 786 | /* update scaler */ |
| 787 | if (psde->features & BIT(SDE_SSPP_SCALER_QSEED3)) { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 788 | if (!psde->pixel_ext_usr) { |
| 789 | /* calculate default config for QSEED3 */ |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 790 | _sde_plane_setup_scaler3(psde, |
| 791 | psde->pipe_cfg.src_rect.w, |
| 792 | psde->pipe_cfg.src_rect.h, |
| 793 | psde->pipe_cfg.dst_rect.w, |
| 794 | psde->pipe_cfg.dst_rect.h, |
| 795 | &psde->scaler3_cfg, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 796 | chroma_subsmpl_h, chroma_subsmpl_v); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 797 | } |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 798 | } else if (!psde->pixel_ext_usr) { |
| 799 | /* calculate default configuration for QSEED2 */ |
| 800 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 801 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 802 | SDE_DEBUG_PLANE(psde, "default config\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 803 | _sde_plane_setup_scaler2(psde, |
| 804 | psde->pipe_cfg.src_rect.w, |
| 805 | psde->pipe_cfg.dst_rect.w, |
| 806 | pe->phase_step_x, |
| 807 | pe->horz_filter, fmt, chroma_subsmpl_h); |
| 808 | _sde_plane_setup_scaler2(psde, |
| 809 | psde->pipe_cfg.src_rect.h, |
| 810 | psde->pipe_cfg.dst_rect.h, |
| 811 | pe->phase_step_y, |
| 812 | pe->vert_filter, fmt, chroma_subsmpl_v); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 813 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 814 | /* calculate left/right/top/bottom pixel extensions */ |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 815 | tmp = DECIMATED_DIMENSION(psde->pipe_cfg.src_rect.w, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 816 | psde->pipe_cfg.horz_decimation); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 817 | if (SDE_FORMAT_IS_YUV(fmt)) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 818 | tmp &= ~0x1; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 819 | _sde_plane_setup_pixel_ext(psde, psde->pipe_cfg.src_rect.w, |
| 820 | psde->pipe_cfg.dst_rect.w, tmp, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 821 | pe->phase_step_x, |
| 822 | pe->roi_w, |
| 823 | pe->num_ext_pxls_left, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 824 | pe->num_ext_pxls_right, pe->horz_filter, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 825 | chroma_subsmpl_h, 0); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 826 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 827 | tmp = DECIMATED_DIMENSION(psde->pipe_cfg.src_rect.h, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 828 | psde->pipe_cfg.vert_decimation); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 829 | _sde_plane_setup_pixel_ext(psde, psde->pipe_cfg.src_rect.h, |
| 830 | psde->pipe_cfg.dst_rect.h, tmp, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 831 | pe->phase_step_y, |
| 832 | pe->roi_h, |
| 833 | pe->num_ext_pxls_top, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 834 | pe->num_ext_pxls_btm, pe->vert_filter, fmt, |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 835 | chroma_subsmpl_v, 1); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 836 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 837 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 838 | if (pe->num_ext_pxls_left[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 839 | pe->left_rpt[i] = pe->num_ext_pxls_left[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 840 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 841 | pe->left_ftch[i] = pe->num_ext_pxls_left[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 842 | |
| 843 | if (pe->num_ext_pxls_right[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 844 | pe->right_rpt[i] = pe->num_ext_pxls_right[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 845 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 846 | pe->right_ftch[i] = pe->num_ext_pxls_right[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 847 | |
| 848 | if (pe->num_ext_pxls_top[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 849 | pe->top_rpt[i] = pe->num_ext_pxls_top[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 850 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 851 | pe->top_ftch[i] = pe->num_ext_pxls_top[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 852 | |
| 853 | if (pe->num_ext_pxls_btm[i] >= 0) |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 854 | pe->btm_rpt[i] = pe->num_ext_pxls_btm[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 855 | else |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 856 | pe->btm_ftch[i] = pe->num_ext_pxls_btm[i]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 857 | } |
| 858 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 859 | } |
| 860 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 861 | /** |
| 862 | * _sde_plane_color_fill - enables color fill on plane |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 863 | * @psde: Pointer to SDE plane object |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 864 | * @color: RGB fill color value, [23..16] Blue, [15..8] Green, [7..0] Red |
| 865 | * @alpha: 8-bit fill alpha value, 255 selects 100% alpha |
| 866 | * Returns: 0 on success |
| 867 | */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 868 | static int _sde_plane_color_fill(struct sde_plane *psde, |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 869 | uint32_t color, uint32_t alpha) |
| 870 | { |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 871 | const struct sde_format *fmt; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 872 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 873 | if (!psde) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 874 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 875 | return -EINVAL; |
| 876 | } |
| 877 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 878 | if (!psde->pipe_hw) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 879 | SDE_ERROR_PLANE(psde, "invalid plane h/w pointer\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 880 | return -EINVAL; |
| 881 | } |
| 882 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 883 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 884 | |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 885 | /* |
| 886 | * select fill format to match user property expectation, |
| 887 | * h/w only supports RGB variants |
| 888 | */ |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 889 | fmt = sde_get_sde_format(DRM_FORMAT_ABGR8888); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 890 | |
| 891 | /* update sspp */ |
| 892 | if (fmt && psde->pipe_hw->ops.setup_solidfill) { |
| 893 | psde->pipe_hw->ops.setup_solidfill(psde->pipe_hw, |
| 894 | (color & 0xFFFFFF) | ((alpha & 0xFF) << 24)); |
| 895 | |
| 896 | /* override scaler/decimation if solid fill */ |
| 897 | psde->pipe_cfg.src_rect.x = 0; |
| 898 | psde->pipe_cfg.src_rect.y = 0; |
| 899 | psde->pipe_cfg.src_rect.w = psde->pipe_cfg.dst_rect.w; |
| 900 | psde->pipe_cfg.src_rect.h = psde->pipe_cfg.dst_rect.h; |
| 901 | |
| 902 | _sde_plane_setup_scaler(psde, fmt, 0); |
| 903 | |
| 904 | if (psde->pipe_hw->ops.setup_format) |
| 905 | psde->pipe_hw->ops.setup_format(psde->pipe_hw, |
| 906 | fmt, SDE_SSPP_SOLID_FILL); |
| 907 | |
| 908 | if (psde->pipe_hw->ops.setup_rects) |
| 909 | psde->pipe_hw->ops.setup_rects(psde->pipe_hw, |
| 910 | &psde->pipe_cfg, &psde->pixel_ext); |
| 911 | } |
| 912 | |
| 913 | return 0; |
| 914 | } |
| 915 | |
| 916 | static int _sde_plane_mode_set(struct drm_plane *plane, |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 917 | struct drm_plane_state *state) |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 918 | { |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 919 | uint32_t nplanes, src_flags, zpos, split_w; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 920 | struct sde_plane *psde; |
| 921 | struct sde_plane_state *pstate; |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 922 | const struct sde_format *fmt; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 923 | struct drm_crtc *crtc; |
| 924 | struct drm_framebuffer *fb; |
| 925 | struct sde_rect src, dst; |
| 926 | bool q16_data = true; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 927 | int idx; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 928 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 929 | if (!plane) { |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 930 | SDE_ERROR("invalid plane\n"); |
| 931 | return -EINVAL; |
| 932 | } else if (!plane->state) { |
| 933 | SDE_ERROR("invalid plane state\n"); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 934 | return -EINVAL; |
| 935 | } |
| 936 | |
| 937 | psde = to_sde_plane(plane); |
| 938 | pstate = to_sde_plane_state(plane->state); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 939 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 940 | crtc = state->crtc; |
| 941 | fb = state->fb; |
| 942 | if (!crtc || !fb) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 943 | SDE_ERROR_PLANE(psde, "invalid crtc %d or fb %d\n", |
| 944 | crtc != 0, fb != 0); |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 945 | return -EINVAL; |
| 946 | } |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 947 | fmt = to_sde_format(msm_framebuffer_format(fb)); |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 948 | nplanes = fmt->num_planes; |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 949 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 950 | /* determine what needs to be refreshed */ |
| 951 | while ((idx = msm_property_pop_dirty(&psde->property_info)) >= 0) { |
| 952 | switch (idx) { |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 953 | case PLANE_PROP_SCALER_V1: |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 954 | case PLANE_PROP_H_DECIMATE: |
| 955 | case PLANE_PROP_V_DECIMATE: |
| 956 | case PLANE_PROP_SRC_CONFIG: |
| 957 | case PLANE_PROP_ZPOS: |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 958 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
| 959 | break; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 960 | case PLANE_PROP_CSC_V1: |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 961 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT; |
| 962 | break; |
| 963 | case PLANE_PROP_COLOR_FILL: |
| 964 | /* potentially need to refresh everything */ |
| 965 | pstate->dirty = SDE_PLANE_DIRTY_ALL; |
| 966 | break; |
| 967 | case PLANE_PROP_ROTATION: |
| 968 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT; |
| 969 | break; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 970 | case PLANE_PROP_INFO: |
| 971 | case PLANE_PROP_ALPHA: |
| 972 | case PLANE_PROP_INPUT_FENCE: |
| 973 | case PLANE_PROP_BLEND_OP: |
| 974 | /* no special action required */ |
| 975 | break; |
| 976 | default: |
| 977 | /* unknown property, refresh everything */ |
| 978 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
| 979 | SDE_ERROR("executing full mode set, prp_idx %d\n", idx); |
| 980 | break; |
| 981 | } |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 982 | } |
| 983 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 984 | if (pstate->dirty & SDE_PLANE_DIRTY_RECTS) |
| 985 | memset(&(psde->pipe_cfg), 0, sizeof(struct sde_hw_pipe_cfg)); |
Clarence Ip | cb410d4 | 2016-06-26 22:52:33 -0400 | [diff] [blame] | 986 | |
| 987 | _sde_plane_set_scanout(plane, pstate, &psde->pipe_cfg, fb); |
| 988 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 989 | /* early out if nothing dirty */ |
| 990 | if (!pstate->dirty) |
| 991 | return 0; |
| 992 | pstate->pending = true; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 993 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 994 | psde->is_rt_pipe = _sde_plane_is_rt_pipe(plane, crtc); |
| 995 | _sde_plane_set_qos_ctrl(plane, false, SDE_PLANE_QOS_PANIC_CTRL); |
| 996 | |
| 997 | /* update roi config */ |
| 998 | if (pstate->dirty & SDE_PLANE_DIRTY_RECTS) { |
| 999 | POPULATE_RECT(&src, state->src_x, state->src_y, |
| 1000 | state->src_w, state->src_h, q16_data); |
| 1001 | POPULATE_RECT(&dst, state->crtc_x, state->crtc_y, |
| 1002 | state->crtc_w, state->crtc_h, !q16_data); |
| 1003 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1004 | SDE_DEBUG_PLANE(psde, |
| 1005 | "FB[%u] %u,%u,%ux%u->crtc%u %d,%d,%ux%u, %s ubwc %d\n", |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1006 | fb->base.id, src.x, src.y, src.w, src.h, |
| 1007 | crtc->base.id, dst.x, dst.y, dst.w, dst.h, |
| 1008 | drm_get_format_name(fmt->base.pixel_format), |
| 1009 | SDE_FORMAT_IS_UBWC(fmt)); |
| 1010 | |
| 1011 | if (sde_plane_get_property(pstate, PLANE_PROP_SRC_CONFIG) & |
| 1012 | BIT(SDE_DRM_DEINTERLACE)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1013 | SDE_DEBUG_PLANE(psde, "deinterlace\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1014 | for (idx = 0; idx < SDE_MAX_PLANES; ++idx) |
| 1015 | psde->pipe_cfg.layout.plane_pitch[idx] <<= 1; |
| 1016 | src.h /= 2; |
| 1017 | src.y = DIV_ROUND_UP(src.y, 2); |
| 1018 | src.y &= ~0x1; |
| 1019 | } |
| 1020 | |
| 1021 | psde->pipe_cfg.src_rect = src; |
| 1022 | psde->pipe_cfg.dst_rect = dst; |
| 1023 | |
| 1024 | /* check for color fill */ |
| 1025 | psde->color_fill = (uint32_t)sde_plane_get_property(pstate, |
| 1026 | PLANE_PROP_COLOR_FILL); |
| 1027 | if (psde->color_fill & SDE_PLANE_COLOR_FILL_FLAG) { |
| 1028 | /* skip remaining processing on color fill */ |
| 1029 | pstate->dirty = 0x0; |
| 1030 | } else if (psde->pipe_hw->ops.setup_rects) { |
| 1031 | _sde_plane_setup_scaler(psde, fmt, pstate); |
| 1032 | |
| 1033 | /* base layer source split needs update */ |
| 1034 | zpos = sde_plane_get_property(pstate, PLANE_PROP_ZPOS); |
| 1035 | if (zpos == SDE_STAGE_BASE) { |
| 1036 | split_w = get_crtc_split_width(crtc); |
| 1037 | if (psde->pipe_cfg.dst_rect.x >= split_w) |
| 1038 | psde->pipe_cfg.dst_rect.x -= split_w; |
| 1039 | } |
| 1040 | psde->pipe_hw->ops.setup_rects(psde->pipe_hw, |
| 1041 | &psde->pipe_cfg, &psde->pixel_ext); |
| 1042 | } |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 1043 | } |
| 1044 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1045 | if ((pstate->dirty & SDE_PLANE_DIRTY_FORMAT) && |
| 1046 | psde->pipe_hw->ops.setup_format) { |
| 1047 | src_flags = 0x0; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1048 | SDE_DEBUG_PLANE(psde, "rotation 0x%llX\n", |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1049 | sde_plane_get_property(pstate, PLANE_PROP_ROTATION)); |
| 1050 | if (sde_plane_get_property(pstate, PLANE_PROP_ROTATION) & |
| 1051 | BIT(DRM_REFLECT_X)) |
| 1052 | src_flags |= SDE_SSPP_FLIP_LR; |
| 1053 | if (sde_plane_get_property(pstate, PLANE_PROP_ROTATION) & |
| 1054 | BIT(DRM_REFLECT_Y)) |
| 1055 | src_flags |= SDE_SSPP_FLIP_UD; |
| 1056 | |
| 1057 | /* update format */ |
| 1058 | psde->pipe_hw->ops.setup_format(psde->pipe_hw, fmt, src_flags); |
| 1059 | |
| 1060 | /* update csc */ |
| 1061 | if (SDE_FORMAT_IS_YUV(fmt)) |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1062 | _sde_plane_setup_csc(psde); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1063 | else |
| 1064 | psde->csc_ptr = 0; |
| 1065 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1066 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1067 | /* update sharpening */ |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1068 | if ((pstate->dirty & SDE_PLANE_DIRTY_SHARPEN) && |
| 1069 | psde->pipe_hw->ops.setup_sharpening) { |
| 1070 | psde->sharp_cfg.strength = SHARP_STRENGTH_DEFAULT; |
| 1071 | psde->sharp_cfg.edge_thr = SHARP_EDGE_THR_DEFAULT; |
| 1072 | psde->sharp_cfg.smooth_thr = SHARP_SMOOTH_THR_DEFAULT; |
| 1073 | psde->sharp_cfg.noise_thr = SHARP_NOISE_THR_DEFAULT; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1074 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1075 | psde->pipe_hw->ops.setup_sharpening(psde->pipe_hw, |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1076 | &psde->sharp_cfg); |
| 1077 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1078 | |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1079 | _sde_plane_set_qos_lut(plane, fb); |
| 1080 | _sde_plane_set_danger_lut(plane, fb); |
| 1081 | |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 1082 | if (plane->type != DRM_PLANE_TYPE_CURSOR) { |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1083 | _sde_plane_set_qos_ctrl(plane, true, SDE_PLANE_QOS_PANIC_CTRL); |
Alan Kwong | 5d324e4 | 2016-07-28 22:56:18 -0400 | [diff] [blame] | 1084 | _sde_plane_set_ot_limit(plane, crtc); |
| 1085 | } |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1086 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1087 | /* clear dirty */ |
| 1088 | pstate->dirty = 0x0; |
| 1089 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1090 | return 0; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1091 | } |
| 1092 | |
| 1093 | static int sde_plane_prepare_fb(struct drm_plane *plane, |
| 1094 | const struct drm_plane_state *new_state) |
| 1095 | { |
| 1096 | struct drm_framebuffer *fb = new_state->fb; |
| 1097 | struct sde_plane *psde = to_sde_plane(plane); |
| 1098 | |
| 1099 | if (!new_state->fb) |
| 1100 | return 0; |
| 1101 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1102 | SDE_DEBUG_PLANE(psde, "FB[%u]\n", fb->base.id); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1103 | return msm_framebuffer_prepare(fb, psde->mmu_id); |
| 1104 | } |
| 1105 | |
| 1106 | static void sde_plane_cleanup_fb(struct drm_plane *plane, |
| 1107 | const struct drm_plane_state *old_state) |
| 1108 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1109 | struct drm_framebuffer *fb = old_state ? old_state->fb : NULL; |
| 1110 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1111 | |
| 1112 | if (!fb) |
| 1113 | return; |
| 1114 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1115 | SDE_DEBUG_PLANE(psde, "FB[%u]\n", fb->base.id); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1116 | msm_framebuffer_cleanup(fb, psde->mmu_id); |
| 1117 | } |
| 1118 | |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1119 | static void _sde_plane_atomic_check_mode_changed(struct sde_plane *psde, |
| 1120 | struct drm_plane_state *state, |
| 1121 | struct drm_plane_state *old_state) |
| 1122 | { |
| 1123 | struct sde_plane_state *pstate = to_sde_plane_state(state); |
| 1124 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1125 | /* no need to check it again */ |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1126 | if (pstate->dirty == SDE_PLANE_DIRTY_ALL) |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1127 | return; |
| 1128 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1129 | if (!sde_plane_enabled(state) || !sde_plane_enabled(old_state) |
| 1130 | || psde->is_error) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1131 | SDE_DEBUG_PLANE(psde, |
| 1132 | "enabling/disabling full modeset required\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1133 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1134 | } else if (to_sde_plane_state(old_state)->pending) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1135 | SDE_DEBUG_PLANE(psde, "still pending\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1136 | pstate->dirty |= SDE_PLANE_DIRTY_ALL; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1137 | } else if (state->src_w != old_state->src_w || |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1138 | state->src_h != old_state->src_h || |
| 1139 | state->src_x != old_state->src_x || |
| 1140 | state->src_y != old_state->src_y) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1141 | SDE_DEBUG_PLANE(psde, "src rect updated\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1142 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1143 | } else if (state->crtc_w != old_state->crtc_w || |
| 1144 | state->crtc_h != old_state->crtc_h || |
| 1145 | state->crtc_x != old_state->crtc_x || |
| 1146 | state->crtc_y != old_state->crtc_y) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1147 | SDE_DEBUG_PLANE(psde, "crtc rect updated\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1148 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
| 1149 | } |
| 1150 | |
| 1151 | if (!state->fb || !old_state->fb) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1152 | SDE_DEBUG_PLANE(psde, "can't compare fb handles\n"); |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1153 | } else if (state->fb->pixel_format != old_state->fb->pixel_format) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1154 | SDE_DEBUG_PLANE(psde, "format change\n"); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1155 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1156 | } else { |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1157 | uint64_t *new_mods = state->fb->modifier; |
| 1158 | uint64_t *old_mods = old_state->fb->modifier; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1159 | uint32_t *new_pitches = state->fb->pitches; |
| 1160 | uint32_t *old_pitches = old_state->fb->pitches; |
| 1161 | uint32_t *new_offset = state->fb->offsets; |
| 1162 | uint32_t *old_offset = old_state->fb->offsets; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1163 | int i; |
| 1164 | |
| 1165 | for (i = 0; i < ARRAY_SIZE(state->fb->modifier); i++) { |
| 1166 | if (new_mods[i] != old_mods[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1167 | SDE_DEBUG_PLANE(psde, |
| 1168 | "format modifiers change\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1169 | plane:%d new_mode:%llu old_mode:%llu\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1170 | i, new_mods[i], old_mods[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1171 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | |
| 1172 | SDE_PLANE_DIRTY_RECTS; |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1173 | break; |
| 1174 | } |
| 1175 | } |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 1176 | for (i = 0; i < ARRAY_SIZE(state->fb->pitches); i++) { |
| 1177 | if (new_pitches[i] != old_pitches[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1178 | SDE_DEBUG_PLANE(psde, |
| 1179 | "pitches change plane:%d\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1180 | old_pitches:%u new_pitches:%u\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1181 | i, old_pitches[i], new_pitches[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1182 | pstate->dirty |= SDE_PLANE_DIRTY_RECTS; |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 1183 | break; |
| 1184 | } |
| 1185 | } |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1186 | for (i = 0; i < ARRAY_SIZE(state->fb->offsets); i++) { |
| 1187 | if (new_offset[i] != old_offset[i]) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1188 | SDE_DEBUG_PLANE(psde, |
| 1189 | "offset change plane:%d\"\ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1190 | old_offset:%u new_offset:%u\n", |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1191 | i, old_offset[i], new_offset[i]); |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1192 | pstate->dirty |= SDE_PLANE_DIRTY_FORMAT | |
| 1193 | SDE_PLANE_DIRTY_RECTS; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1194 | break; |
| 1195 | } |
| 1196 | } |
Lloyd Atkinson | 3ab9ef7 | 2016-07-14 17:42:41 -0400 | [diff] [blame] | 1197 | } |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1198 | } |
| 1199 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1200 | static int sde_plane_atomic_check(struct drm_plane *plane, |
| 1201 | struct drm_plane_state *state) |
| 1202 | { |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 1203 | int ret = 0; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1204 | struct sde_plane *psde; |
| 1205 | struct sde_plane_state *pstate; |
Lloyd Atkinson | 9a67349 | 2016-07-05 11:41:57 -0400 | [diff] [blame] | 1206 | const struct sde_format *fmt; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1207 | struct sde_rect src, dst; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1208 | uint32_t deci_w, deci_h, src_deci_w, src_deci_h; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1209 | uint32_t max_upscale, max_downscale, min_src_size, max_linewidth; |
| 1210 | bool q16_data = true; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1211 | |
| 1212 | if (!plane || !state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1213 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 1214 | plane != 0, state != 0); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1215 | ret = -EINVAL; |
| 1216 | goto exit; |
| 1217 | } |
| 1218 | |
| 1219 | psde = to_sde_plane(plane); |
| 1220 | pstate = to_sde_plane_state(state); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1221 | |
| 1222 | if (!psde->pipe_sblk) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1223 | SDE_ERROR_PLANE(psde, "invalid catalog\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1224 | ret = -EINVAL; |
| 1225 | goto exit; |
| 1226 | } |
| 1227 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 1228 | deci_w = sde_plane_get_property(pstate, PLANE_PROP_H_DECIMATE); |
| 1229 | deci_h = sde_plane_get_property(pstate, PLANE_PROP_V_DECIMATE); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1230 | |
| 1231 | /* src values are in Q16 fixed point, convert to integer */ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1232 | POPULATE_RECT(&src, state->src_x, state->src_y, state->src_w, |
| 1233 | state->src_h, q16_data); |
| 1234 | POPULATE_RECT(&dst, state->crtc_x, state->crtc_y, state->crtc_w, |
| 1235 | state->crtc_h, !q16_data); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1236 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1237 | src_deci_w = DECIMATED_DIMENSION(src.w, deci_w); |
| 1238 | src_deci_h = DECIMATED_DIMENSION(src.h, deci_h); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1239 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1240 | max_upscale = psde->pipe_sblk->maxupscale; |
| 1241 | max_downscale = psde->pipe_sblk->maxdwnscale; |
| 1242 | max_linewidth = psde->pipe_sblk->maxlinewidth; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1243 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1244 | SDE_DEBUG_PLANE(psde, "check %d -> %d\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1245 | sde_plane_enabled(plane->state), sde_plane_enabled(state)); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1246 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1247 | if (!sde_plane_enabled(state)) |
| 1248 | goto modeset_update; |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1249 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1250 | fmt = to_sde_format(msm_framebuffer_format(state->fb)); |
| 1251 | |
| 1252 | min_src_size = SDE_FORMAT_IS_YUV(fmt) ? 2 : 1; |
| 1253 | |
| 1254 | if (SDE_FORMAT_IS_YUV(fmt) && |
| 1255 | (!(psde->features & SDE_SSPP_SCALER) || |
| 1256 | !(psde->features & BIT(SDE_SSPP_CSC)))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1257 | SDE_ERROR_PLANE(psde, |
| 1258 | "plane doesn't have scaler/csc for yuv\n"); |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1259 | ret = -EINVAL; |
| 1260 | |
| 1261 | /* check src bounds */ |
| 1262 | } else if (state->fb->width > MAX_IMG_WIDTH || |
| 1263 | state->fb->height > MAX_IMG_HEIGHT || |
| 1264 | src.w < min_src_size || src.h < min_src_size || |
| 1265 | CHECK_LAYER_BOUNDS(src.x, src.w, state->fb->width) || |
| 1266 | CHECK_LAYER_BOUNDS(src.y, src.h, state->fb->height)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1267 | SDE_ERROR_PLANE(psde, "invalid source %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1268 | src.x, src.y, src.w, src.h); |
| 1269 | ret = -E2BIG; |
| 1270 | |
| 1271 | /* valid yuv image */ |
| 1272 | } else if (SDE_FORMAT_IS_YUV(fmt) && ((src.x & 0x1) || (src.y & 0x1) || |
| 1273 | (src.w & 0x1) || (src.h & 0x1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1274 | SDE_ERROR_PLANE(psde, "invalid yuv source %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1275 | src.x, src.y, src.w, src.h); |
| 1276 | ret = -EINVAL; |
| 1277 | |
| 1278 | /* min dst support */ |
| 1279 | } else if (dst.w < 0x1 || dst.h < 0x1) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1280 | SDE_ERROR_PLANE(psde, "invalid dest rect %u, %u, %ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1281 | dst.x, dst.y, dst.w, dst.h); |
| 1282 | ret = -EINVAL; |
| 1283 | |
| 1284 | /* decimation validation */ |
| 1285 | } else if (deci_w || deci_h) { |
| 1286 | if ((deci_w > psde->pipe_sblk->maxhdeciexp) || |
| 1287 | (deci_h > psde->pipe_sblk->maxvdeciexp)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1288 | SDE_ERROR_PLANE(psde, |
| 1289 | "too much decimation requested\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1290 | ret = -EINVAL; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1291 | } else if (fmt->fetch_mode != SDE_FETCH_LINEAR) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1292 | SDE_ERROR_PLANE(psde, |
| 1293 | "decimation requires linear fetch\n"); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1294 | ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1295 | } |
| 1296 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1297 | } else if (!(psde->features & SDE_SSPP_SCALER) && |
| 1298 | ((src.w != dst.w) || (src.h != dst.h))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1299 | SDE_ERROR_PLANE(psde, |
| 1300 | "pipe doesn't support scaling %ux%u->%ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1301 | src.w, src.h, dst.w, dst.h); |
| 1302 | ret = -EINVAL; |
| 1303 | |
| 1304 | /* check decimated source width */ |
| 1305 | } else if (src_deci_w > max_linewidth) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1306 | SDE_ERROR_PLANE(psde, |
| 1307 | "invalid src w:%u, deci w:%u, line w:%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1308 | src.w, src_deci_w, max_linewidth); |
| 1309 | ret = -E2BIG; |
| 1310 | |
| 1311 | /* check max scaler capability */ |
| 1312 | } else if (((src_deci_w * max_upscale) < dst.w) || |
| 1313 | ((src_deci_h * max_upscale) < dst.h) || |
| 1314 | ((dst.w * max_downscale) < src_deci_w) || |
| 1315 | ((dst.h * max_downscale) < src_deci_h)) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1316 | SDE_ERROR_PLANE(psde, |
| 1317 | "too much scaling requested %ux%u->%ux%u\n", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1318 | src_deci_w, src_deci_h, dst.w, dst.h); |
| 1319 | ret = -E2BIG; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1320 | } |
| 1321 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1322 | modeset_update: |
Lloyd Atkinson | fa2489c | 2016-05-25 15:16:03 -0400 | [diff] [blame] | 1323 | if (!ret) |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1324 | _sde_plane_atomic_check_mode_changed(psde, state, plane->state); |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1325 | exit: |
| 1326 | return ret; |
| 1327 | } |
| 1328 | |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1329 | /** |
| 1330 | * sde_plane_flush - final plane operations before commit flush |
| 1331 | * @plane: Pointer to drm plane structure |
| 1332 | */ |
| 1333 | void sde_plane_flush(struct drm_plane *plane) |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1334 | { |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1335 | struct sde_plane *psde; |
| 1336 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1337 | if (!plane) { |
| 1338 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1339 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1340 | } |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1341 | |
| 1342 | psde = to_sde_plane(plane); |
| 1343 | |
| 1344 | /* |
| 1345 | * These updates have to be done immediately before the plane flush |
| 1346 | * timing, and may not be moved to the atomic_update/mode_set functions. |
| 1347 | */ |
| 1348 | if (psde->is_error) |
| 1349 | /* force white frame with 0% alpha pipe output on error */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1350 | _sde_plane_color_fill(psde, 0xFFFFFF, 0x0); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1351 | else if (psde->color_fill & SDE_PLANE_COLOR_FILL_FLAG) |
| 1352 | /* force 100% alpha */ |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1353 | _sde_plane_color_fill(psde, psde->color_fill, 0xFF); |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1354 | else if (psde->pipe_hw && psde->csc_ptr && psde->pipe_hw->ops.setup_csc) |
| 1355 | psde->pipe_hw->ops.setup_csc(psde->pipe_hw, psde->csc_ptr); |
| 1356 | |
| 1357 | /* flag h/w flush complete */ |
| 1358 | if (plane->state) |
Clarence Ip | dbde983 | 2016-06-26 09:48:36 -0400 | [diff] [blame] | 1359 | to_sde_plane_state(plane->state)->pending = false; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1360 | } |
| 1361 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1362 | static void sde_plane_atomic_update(struct drm_plane *plane, |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1363 | struct drm_plane_state *old_state) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1364 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1365 | struct sde_plane *psde; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1366 | struct drm_plane_state *state; |
| 1367 | struct sde_plane_state *pstate; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1368 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1369 | if (!plane) { |
| 1370 | SDE_ERROR("invalid plane\n"); |
| 1371 | return; |
| 1372 | } else if (!plane->state) { |
| 1373 | SDE_ERROR("invalid plane state\n"); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1374 | return; |
| 1375 | } |
| 1376 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1377 | psde = to_sde_plane(plane); |
| 1378 | psde->is_error = false; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1379 | state = plane->state; |
| 1380 | pstate = to_sde_plane_state(state); |
| 1381 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1382 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1383 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1384 | if (!sde_plane_enabled(state)) { |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1385 | pstate->pending = true; |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1386 | } else { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1387 | int ret; |
| 1388 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1389 | ret = _sde_plane_mode_set(plane, state); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1390 | /* atomic_check should have ensured that this doesn't fail */ |
| 1391 | WARN_ON(ret < 0); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1392 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1393 | } |
| 1394 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1395 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1396 | /* helper to install properties which are common to planes and crtcs */ |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1397 | static void _sde_plane_install_properties(struct drm_plane *plane, |
| 1398 | u32 max_blendstages) |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1399 | { |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1400 | static const struct drm_prop_enum_list e_blend_op[] = { |
| 1401 | {SDE_DRM_BLEND_OP_NOT_DEFINED, "not_defined"}, |
| 1402 | {SDE_DRM_BLEND_OP_OPAQUE, "opaque"}, |
| 1403 | {SDE_DRM_BLEND_OP_PREMULTIPLIED, "premultiplied"}, |
| 1404 | {SDE_DRM_BLEND_OP_COVERAGE, "coverage"} |
| 1405 | }; |
| 1406 | static const struct drm_prop_enum_list e_src_config[] = { |
| 1407 | {SDE_DRM_DEINTERLACE, "deinterlace"} |
| 1408 | }; |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1409 | const struct sde_format_extended *format_list; |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1410 | struct sde_kms_info *info; |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1411 | struct sde_plane *psde = to_sde_plane(plane); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1412 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1413 | if (!plane || !psde) { |
| 1414 | SDE_ERROR("invalid plane\n"); |
| 1415 | return; |
| 1416 | } else if (!psde->pipe_hw || !psde->pipe_sblk) { |
| 1417 | SDE_ERROR("invalid plane, pipe_hw %d pipe_sblk %d\n", |
| 1418 | psde->pipe_hw != 0, psde->pipe_sblk != 0); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1419 | return; |
| 1420 | } |
| 1421 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1422 | msm_property_install_range(&psde->property_info, "zpos", 0x0, 0, |
Dhaval Patel | 48c7602 | 2016-09-01 17:51:23 -0700 | [diff] [blame] | 1423 | max_blendstages, SDE_STAGE_BASE, PLANE_PROP_ZPOS); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1424 | |
Lloyd Atkinson | 38ad8c9 | 2016-07-06 10:39:32 -0400 | [diff] [blame] | 1425 | msm_property_install_range(&psde->property_info, "alpha", |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1426 | 0x0, 0, 255, 255, PLANE_PROP_ALPHA); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1427 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1428 | /* linux default file descriptor range on each process */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1429 | msm_property_install_range(&psde->property_info, "input_fence", |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1430 | 0x0, 0, INR_OPEN_MAX, 0, PLANE_PROP_INPUT_FENCE); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1431 | |
Clarence Ip | dedbba9 | 2016-09-27 17:43:10 -0400 | [diff] [blame] | 1432 | if (psde->pipe_sblk->maxhdeciexp) { |
| 1433 | msm_property_install_range(&psde->property_info, "h_decimate", |
| 1434 | 0x0, 0, psde->pipe_sblk->maxhdeciexp, 0, |
| 1435 | PLANE_PROP_H_DECIMATE); |
| 1436 | } |
| 1437 | |
| 1438 | if (psde->pipe_sblk->maxvdeciexp) { |
| 1439 | msm_property_install_range(&psde->property_info, "v_decimate", |
| 1440 | 0x0, 0, psde->pipe_sblk->maxvdeciexp, 0, |
| 1441 | PLANE_PROP_V_DECIMATE); |
| 1442 | } |
| 1443 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1444 | if (psde->features & SDE_SSPP_SCALER) { |
| 1445 | msm_property_install_volatile_range(&psde->property_info, |
| 1446 | "scaler_v1", 0x0, 0, ~0, 0, PLANE_PROP_SCALER_V1); |
| 1447 | } |
| 1448 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1449 | if (psde->features & BIT(SDE_SSPP_CSC)) { |
| 1450 | msm_property_install_volatile_range(&psde->property_info, |
| 1451 | "csc_v1", 0x0, 0, ~0, 0, PLANE_PROP_CSC_V1); |
| 1452 | } |
| 1453 | |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1454 | /* standard properties */ |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1455 | msm_property_install_rotation(&psde->property_info, |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1456 | BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y), PLANE_PROP_ROTATION); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1457 | |
Lloyd Atkinson | 38ad8c9 | 2016-07-06 10:39:32 -0400 | [diff] [blame] | 1458 | msm_property_install_enum(&psde->property_info, "blend_op", 0x0, 0, |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1459 | e_blend_op, ARRAY_SIZE(e_blend_op), PLANE_PROP_BLEND_OP); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1460 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1461 | msm_property_install_enum(&psde->property_info, "src_config", 0x0, 1, |
| 1462 | e_src_config, ARRAY_SIZE(e_src_config), PLANE_PROP_SRC_CONFIG); |
| 1463 | |
| 1464 | if (psde->pipe_hw->ops.setup_solidfill) |
| 1465 | msm_property_install_range(&psde->property_info, "color_fill", |
| 1466 | 0, 0, 0xFFFFFFFF, 0, PLANE_PROP_COLOR_FILL); |
| 1467 | |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1468 | info = kzalloc(sizeof(struct sde_kms_info), GFP_KERNEL); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1469 | if (!info) { |
| 1470 | SDE_ERROR("failed to allocate info memory\n"); |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1471 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1472 | } |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1473 | |
| 1474 | msm_property_install_blob(&psde->property_info, "capabilities", |
| 1475 | DRM_MODE_PROP_IMMUTABLE, PLANE_PROP_INFO); |
| 1476 | sde_kms_info_reset(info); |
| 1477 | |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1478 | format_list = psde->pipe_sblk->format_list; |
| 1479 | if (format_list) { |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1480 | sde_kms_info_start(info, "pixel_formats"); |
| 1481 | while (format_list->fourcc_format) { |
| 1482 | sde_kms_info_append_format(info, |
| 1483 | format_list->fourcc_format, |
| 1484 | format_list->modifier); |
| 1485 | ++format_list; |
| 1486 | } |
| 1487 | sde_kms_info_stop(info); |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1488 | } |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1489 | |
| 1490 | sde_kms_info_add_keyint(info, "max_linewidth", |
| 1491 | psde->pipe_sblk->maxlinewidth); |
| 1492 | sde_kms_info_add_keyint(info, "max_upscale", |
| 1493 | psde->pipe_sblk->maxupscale); |
| 1494 | sde_kms_info_add_keyint(info, "max_downscale", |
| 1495 | psde->pipe_sblk->maxdwnscale); |
| 1496 | sde_kms_info_add_keyint(info, "max_horizontal_deci", |
| 1497 | psde->pipe_sblk->maxhdeciexp); |
| 1498 | sde_kms_info_add_keyint(info, "max_vertical_deci", |
| 1499 | psde->pipe_sblk->maxvdeciexp); |
| 1500 | msm_property_set_blob(&psde->property_info, &psde->blob_info, |
| 1501 | info->data, info->len, PLANE_PROP_INFO); |
| 1502 | |
| 1503 | kfree(info); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1504 | } |
| 1505 | |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1506 | static inline void _sde_plane_set_csc_v1(struct sde_plane *psde, void *usr_ptr) |
| 1507 | { |
| 1508 | struct sde_drm_csc_v1 csc_v1; |
| 1509 | int i; |
| 1510 | |
| 1511 | if (!psde) { |
| 1512 | SDE_ERROR("invalid plane\n"); |
| 1513 | return; |
| 1514 | } |
| 1515 | |
| 1516 | psde->csc_usr_ptr = NULL; |
| 1517 | if (!usr_ptr) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1518 | SDE_DEBUG_PLANE(psde, "csc data removed\n"); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1519 | return; |
| 1520 | } |
| 1521 | |
| 1522 | if (copy_from_user(&csc_v1, usr_ptr, sizeof(csc_v1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1523 | SDE_ERROR_PLANE(psde, "failed to copy csc data\n"); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1524 | return; |
| 1525 | } |
| 1526 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1527 | /* populate from user space */ |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1528 | for (i = 0; i < SDE_CSC_MATRIX_COEFF_SIZE; ++i) |
| 1529 | psde->csc_cfg.csc_mv[i] = csc_v1.ctm_coeff[i] >> 16; |
| 1530 | for (i = 0; i < SDE_CSC_BIAS_SIZE; ++i) { |
| 1531 | psde->csc_cfg.csc_pre_bv[i] = csc_v1.pre_bias[i]; |
| 1532 | psde->csc_cfg.csc_post_bv[i] = csc_v1.post_bias[i]; |
| 1533 | } |
| 1534 | for (i = 0; i < SDE_CSC_CLAMP_SIZE; ++i) { |
| 1535 | psde->csc_cfg.csc_pre_lv[i] = csc_v1.pre_clamp[i]; |
| 1536 | psde->csc_cfg.csc_post_lv[i] = csc_v1.post_clamp[i]; |
| 1537 | } |
| 1538 | psde->csc_usr_ptr = &psde->csc_cfg; |
| 1539 | } |
| 1540 | |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1541 | static inline void _sde_plane_set_scaler_v1(struct sde_plane *psde, void *usr) |
| 1542 | { |
| 1543 | struct sde_drm_scaler_v1 scale_v1; |
| 1544 | struct sde_hw_pixel_ext *pe; |
| 1545 | int i; |
| 1546 | |
| 1547 | if (!psde) { |
| 1548 | SDE_ERROR("invalid plane\n"); |
| 1549 | return; |
| 1550 | } |
| 1551 | |
| 1552 | psde->pixel_ext_usr = false; |
| 1553 | if (!usr) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1554 | SDE_DEBUG_PLANE(psde, "scale data removed\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1555 | return; |
| 1556 | } |
| 1557 | |
| 1558 | if (copy_from_user(&scale_v1, usr, sizeof(scale_v1))) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1559 | SDE_ERROR_PLANE(psde, "failed to copy scale data\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1560 | return; |
| 1561 | } |
| 1562 | |
| 1563 | /* populate from user space */ |
| 1564 | pe = &(psde->pixel_ext); |
| 1565 | memset(pe, 0, sizeof(struct sde_hw_pixel_ext)); |
| 1566 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 1567 | pe->init_phase_x[i] = scale_v1.init_phase_x[i]; |
| 1568 | pe->phase_step_x[i] = scale_v1.phase_step_x[i]; |
| 1569 | pe->init_phase_y[i] = scale_v1.init_phase_y[i]; |
| 1570 | pe->phase_step_y[i] = scale_v1.phase_step_y[i]; |
| 1571 | |
| 1572 | pe->horz_filter[i] = scale_v1.horz_filter[i]; |
| 1573 | pe->vert_filter[i] = scale_v1.vert_filter[i]; |
| 1574 | } |
| 1575 | for (i = 0; i < SDE_MAX_PLANES; i++) { |
| 1576 | pe->num_ext_pxls_left[i] = scale_v1.lr.num_pxls_start[i]; |
| 1577 | pe->num_ext_pxls_right[i] = scale_v1.lr.num_pxls_end[i]; |
| 1578 | pe->left_ftch[i] = scale_v1.lr.ftch_start[i]; |
| 1579 | pe->right_ftch[i] = scale_v1.lr.ftch_end[i]; |
| 1580 | pe->left_rpt[i] = scale_v1.lr.rpt_start[i]; |
| 1581 | pe->right_rpt[i] = scale_v1.lr.rpt_end[i]; |
| 1582 | pe->roi_w[i] = scale_v1.lr.roi[i]; |
| 1583 | |
| 1584 | pe->num_ext_pxls_top[i] = scale_v1.tb.num_pxls_start[i]; |
| 1585 | pe->num_ext_pxls_btm[i] = scale_v1.tb.num_pxls_end[i]; |
| 1586 | pe->top_ftch[i] = scale_v1.tb.ftch_start[i]; |
| 1587 | pe->btm_ftch[i] = scale_v1.tb.ftch_end[i]; |
| 1588 | pe->top_rpt[i] = scale_v1.tb.rpt_start[i]; |
| 1589 | pe->btm_rpt[i] = scale_v1.tb.rpt_end[i]; |
| 1590 | pe->roi_h[i] = scale_v1.tb.roi[i]; |
| 1591 | } |
| 1592 | psde->pixel_ext_usr = true; |
| 1593 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1594 | SDE_DEBUG_PLANE(psde, "user property data copied\n"); |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1595 | } |
| 1596 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1597 | static int sde_plane_atomic_set_property(struct drm_plane *plane, |
| 1598 | struct drm_plane_state *state, struct drm_property *property, |
| 1599 | uint64_t val) |
| 1600 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1601 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1602 | struct sde_plane_state *pstate; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1603 | int idx, ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1604 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1605 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1606 | |
| 1607 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1608 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1609 | } else if (!state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1610 | SDE_ERROR_PLANE(psde, "invalid state\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1611 | } else { |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1612 | pstate = to_sde_plane_state(state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1613 | ret = msm_property_atomic_set(&psde->property_info, |
| 1614 | pstate->property_values, pstate->property_blobs, |
| 1615 | property, val); |
| 1616 | if (!ret) { |
| 1617 | idx = msm_property_index(&psde->property_info, |
| 1618 | property); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1619 | switch (idx) { |
| 1620 | case PLANE_PROP_INPUT_FENCE: |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1621 | _sde_plane_set_input_fence(psde, pstate, val); |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1622 | break; |
| 1623 | case PLANE_PROP_CSC_V1: |
| 1624 | _sde_plane_set_csc_v1(psde, (void *)val); |
| 1625 | break; |
Clarence Ip | b43d459 | 2016-09-08 14:21:35 -0400 | [diff] [blame] | 1626 | case PLANE_PROP_SCALER_V1: |
| 1627 | _sde_plane_set_scaler_v1(psde, (void *)val); |
| 1628 | break; |
Clarence Ip | 5fc00c5 | 2016-09-23 15:03:34 -0400 | [diff] [blame] | 1629 | default: |
| 1630 | /* nothing to do */ |
| 1631 | break; |
| 1632 | } |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1633 | } |
| 1634 | } |
| 1635 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1636 | return ret; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | static int sde_plane_set_property(struct drm_plane *plane, |
| 1640 | struct drm_property *property, uint64_t val) |
| 1641 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1642 | SDE_DEBUG("\n"); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1643 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1644 | return sde_plane_atomic_set_property(plane, |
| 1645 | plane->state, property, val); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | static int sde_plane_atomic_get_property(struct drm_plane *plane, |
| 1649 | const struct drm_plane_state *state, |
| 1650 | struct drm_property *property, uint64_t *val) |
| 1651 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1652 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1653 | struct sde_plane_state *pstate; |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1654 | int ret = -EINVAL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1655 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1656 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1657 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1658 | } else if (!state) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1659 | SDE_ERROR("invalid state\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1660 | } else { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1661 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1662 | pstate = to_sde_plane_state(state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1663 | ret = msm_property_atomic_get(&psde->property_info, |
| 1664 | pstate->property_values, pstate->property_blobs, |
| 1665 | property, val); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1666 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1667 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1668 | return ret; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | static void sde_plane_destroy(struct drm_plane *plane) |
| 1672 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1673 | struct sde_plane *psde = plane ? to_sde_plane(plane) : NULL; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1674 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1675 | SDE_DEBUG_PLANE(psde, "\n"); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1676 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1677 | if (psde) { |
Alan Kwong | 1a00e4d | 2016-07-18 09:42:30 -0400 | [diff] [blame] | 1678 | _sde_plane_set_qos_ctrl(plane, false, SDE_PLANE_QOS_PANIC_CTRL); |
| 1679 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1680 | debugfs_remove_recursive(psde->debugfs_root); |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1681 | |
Dhaval Patel | 4e57484 | 2016-08-23 15:11:37 -0700 | [diff] [blame] | 1682 | if (psde->blob_info) |
| 1683 | drm_property_unreference_blob(psde->blob_info); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1684 | msm_property_destroy(&psde->property_info); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1685 | mutex_destroy(&psde->lock); |
| 1686 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1687 | drm_plane_helper_disable(plane); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1688 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1689 | /* this will destroy the states as well */ |
| 1690 | drm_plane_cleanup(plane); |
| 1691 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1692 | if (psde->pipe_hw) |
| 1693 | sde_hw_sspp_destroy(psde->pipe_hw); |
| 1694 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1695 | kfree(psde); |
| 1696 | } |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1697 | } |
| 1698 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1699 | static void sde_plane_destroy_state(struct drm_plane *plane, |
| 1700 | struct drm_plane_state *state) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1701 | { |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1702 | struct sde_plane *psde; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1703 | struct sde_plane_state *pstate; |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1704 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1705 | if (!plane || !state) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1706 | SDE_ERROR("invalid arg(s), plane %d state %d\n", |
| 1707 | plane != 0, state != 0); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1708 | return; |
| 1709 | } |
| 1710 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1711 | psde = to_sde_plane(plane); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1712 | pstate = to_sde_plane_state(state); |
| 1713 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1714 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1715 | |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1716 | /* remove ref count for frame buffers */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1717 | if (state->fb) |
| 1718 | drm_framebuffer_unreference(state->fb); |
| 1719 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1720 | /* remove ref count for fence */ |
Clarence Ip | cae1bb6 | 2016-07-07 12:07:13 -0400 | [diff] [blame] | 1721 | if (pstate->input_fence) |
| 1722 | sde_sync_put(pstate->input_fence); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1723 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1724 | /* destroy value helper */ |
| 1725 | msm_property_destroy_state(&psde->property_info, pstate, |
| 1726 | pstate->property_values, pstate->property_blobs); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1727 | } |
| 1728 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1729 | static struct drm_plane_state * |
| 1730 | sde_plane_duplicate_state(struct drm_plane *plane) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1731 | { |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1732 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1733 | struct sde_plane_state *pstate; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1734 | struct sde_plane_state *old_state; |
Clarence Ip | 17e908b | 2016-09-29 15:58:00 -0400 | [diff] [blame] | 1735 | uint64_t input_fence_default; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1736 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1737 | if (!plane) { |
| 1738 | SDE_ERROR("invalid plane\n"); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1739 | return NULL; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1740 | } else if (!plane->state) { |
| 1741 | SDE_ERROR("invalid plane state\n"); |
| 1742 | return NULL; |
| 1743 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1744 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1745 | old_state = to_sde_plane_state(plane->state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1746 | psde = to_sde_plane(plane); |
| 1747 | pstate = msm_property_alloc_state(&psde->property_info); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1748 | if (!pstate) { |
| 1749 | SDE_ERROR_PLANE(psde, "failed to allocate state\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1750 | return NULL; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1751 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1752 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1753 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1754 | |
| 1755 | /* duplicate value helper */ |
| 1756 | msm_property_duplicate_state(&psde->property_info, old_state, pstate, |
| 1757 | pstate->property_values, pstate->property_blobs); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1758 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1759 | /* add ref count for frame buffer */ |
| 1760 | if (pstate->base.fb) |
| 1761 | drm_framebuffer_reference(pstate->base.fb); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1762 | |
Clarence Ip | 17e908b | 2016-09-29 15:58:00 -0400 | [diff] [blame] | 1763 | /* clear out any input fence */ |
| 1764 | pstate->input_fence = 0; |
| 1765 | input_fence_default = msm_property_get_default( |
| 1766 | &psde->property_info, PLANE_PROP_INPUT_FENCE); |
| 1767 | msm_property_set_property(&psde->property_info, pstate->property_values, |
| 1768 | PLANE_PROP_INPUT_FENCE, input_fence_default); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1769 | |
Clarence Ip | 282dad6 | 2016-09-27 17:07:35 -0400 | [diff] [blame] | 1770 | pstate->dirty = 0x0; |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1771 | pstate->pending = false; |
| 1772 | |
| 1773 | return &pstate->base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1774 | } |
| 1775 | |
| 1776 | static void sde_plane_reset(struct drm_plane *plane) |
| 1777 | { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1778 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1779 | struct sde_plane_state *pstate; |
| 1780 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1781 | if (!plane) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1782 | SDE_ERROR("invalid plane\n"); |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1783 | return; |
| 1784 | } |
| 1785 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1786 | psde = to_sde_plane(plane); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1787 | SDE_DEBUG_PLANE(psde, "\n"); |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1788 | |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1789 | /* remove previous state, if present */ |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1790 | if (plane->state) { |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1791 | sde_plane_destroy_state(plane, plane->state); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1792 | plane->state = 0; |
Clarence Ip | ae4e60c | 2016-06-26 22:44:04 -0400 | [diff] [blame] | 1793 | } |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1794 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1795 | pstate = msm_property_alloc_state(&psde->property_info); |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1796 | if (!pstate) { |
| 1797 | SDE_ERROR_PLANE(psde, "failed to allocate state\n"); |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1798 | return; |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1799 | } |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1800 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1801 | /* reset value helper */ |
| 1802 | msm_property_reset_state(&psde->property_info, pstate, |
| 1803 | pstate->property_values, pstate->property_blobs); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1804 | |
| 1805 | pstate->base.plane = plane; |
| 1806 | |
| 1807 | plane->state = &pstate->base; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1808 | } |
| 1809 | |
| 1810 | static const struct drm_plane_funcs sde_plane_funcs = { |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1811 | .update_plane = drm_atomic_helper_update_plane, |
| 1812 | .disable_plane = drm_atomic_helper_disable_plane, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1813 | .destroy = sde_plane_destroy, |
| 1814 | .set_property = sde_plane_set_property, |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1815 | .atomic_set_property = sde_plane_atomic_set_property, |
| 1816 | .atomic_get_property = sde_plane_atomic_get_property, |
| 1817 | .reset = sde_plane_reset, |
| 1818 | .atomic_duplicate_state = sde_plane_duplicate_state, |
| 1819 | .atomic_destroy_state = sde_plane_destroy_state, |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1820 | }; |
| 1821 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1822 | static const struct drm_plane_helper_funcs sde_plane_helper_funcs = { |
| 1823 | .prepare_fb = sde_plane_prepare_fb, |
| 1824 | .cleanup_fb = sde_plane_cleanup_fb, |
| 1825 | .atomic_check = sde_plane_atomic_check, |
| 1826 | .atomic_update = sde_plane_atomic_update, |
| 1827 | }; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1828 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1829 | enum sde_sspp sde_plane_pipe(struct drm_plane *plane) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1830 | { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1831 | return plane ? to_sde_plane(plane)->pipe : SSPP_NONE; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1832 | } |
| 1833 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1834 | static void _sde_plane_init_debugfs(struct sde_plane *psde, struct sde_kms *kms) |
| 1835 | { |
| 1836 | const struct sde_sspp_sub_blks *sblk = 0; |
| 1837 | const struct sde_sspp_cfg *cfg = 0; |
| 1838 | |
| 1839 | if (psde && psde->pipe_hw) |
| 1840 | cfg = psde->pipe_hw->cap; |
| 1841 | if (cfg) |
| 1842 | sblk = cfg->sblk; |
| 1843 | |
| 1844 | if (kms && sblk) { |
| 1845 | /* create overall sub-directory for the pipe */ |
| 1846 | psde->debugfs_root = |
| 1847 | debugfs_create_dir(psde->pipe_name, |
| 1848 | sde_debugfs_get_root(kms)); |
| 1849 | if (psde->debugfs_root) { |
| 1850 | /* don't error check these */ |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1851 | debugfs_create_x32("features", 0644, |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1852 | psde->debugfs_root, &psde->features); |
| 1853 | |
| 1854 | /* add register dump support */ |
| 1855 | sde_debugfs_setup_regset32(&psde->debugfs_src, |
| 1856 | sblk->src_blk.base + cfg->base, |
| 1857 | sblk->src_blk.len, |
Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 1858 | kms); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1859 | sde_debugfs_create_regset32("src_blk", 0444, |
| 1860 | psde->debugfs_root, &psde->debugfs_src); |
| 1861 | |
| 1862 | sde_debugfs_setup_regset32(&psde->debugfs_scaler, |
| 1863 | sblk->scaler_blk.base + cfg->base, |
| 1864 | sblk->scaler_blk.len, |
Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 1865 | kms); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1866 | sde_debugfs_create_regset32("scaler_blk", 0444, |
| 1867 | psde->debugfs_root, |
| 1868 | &psde->debugfs_scaler); |
| 1869 | |
| 1870 | sde_debugfs_setup_regset32(&psde->debugfs_csc, |
| 1871 | sblk->csc_blk.base + cfg->base, |
| 1872 | sblk->csc_blk.len, |
Clarence Ip | aac9f33 | 2016-08-31 15:46:35 -0400 | [diff] [blame] | 1873 | kms); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1874 | sde_debugfs_create_regset32("csc_blk", 0444, |
| 1875 | psde->debugfs_root, &psde->debugfs_csc); |
| 1876 | } |
| 1877 | } |
| 1878 | } |
| 1879 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1880 | /* initialize plane */ |
Clarence Ip | e78efb7 | 2016-06-24 18:35:21 -0400 | [diff] [blame] | 1881 | struct drm_plane *sde_plane_init(struct drm_device *dev, |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1882 | uint32_t pipe, bool primary_plane) |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1883 | { |
| 1884 | struct drm_plane *plane = NULL; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1885 | struct sde_plane *psde; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1886 | struct msm_drm_private *priv; |
| 1887 | struct sde_kms *kms; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1888 | enum drm_plane_type type; |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1889 | int ret = -EINVAL, max_blendstages = 255; |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1890 | |
| 1891 | if (!dev) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1892 | SDE_ERROR("[%u]device is NULL\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1893 | goto exit; |
| 1894 | } |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1895 | |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1896 | priv = dev->dev_private; |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 1897 | if (!priv) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1898 | SDE_ERROR("[%u]private data is NULL\n", pipe); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 1899 | goto exit; |
| 1900 | } |
| 1901 | |
| 1902 | if (!priv->kms) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1903 | SDE_ERROR("[%u]invalid KMS reference\n", pipe); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 1904 | goto exit; |
| 1905 | } |
| 1906 | kms = to_sde_kms(priv->kms); |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1907 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1908 | if (!kms->catalog) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1909 | SDE_ERROR("[%u]invalid catalog reference\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1910 | goto exit; |
| 1911 | } |
| 1912 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1913 | /* create and zero local structure */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1914 | psde = kzalloc(sizeof(*psde), GFP_KERNEL); |
| 1915 | if (!psde) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1916 | SDE_ERROR("[%u]failed to allocate local plane struct\n", pipe); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1917 | ret = -ENOMEM; |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1918 | goto exit; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1919 | } |
| 1920 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1921 | /* cache local stuff for later */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1922 | plane = &psde->base; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1923 | psde->pipe = pipe; |
Alan Kwong | 112a84f | 2016-05-24 20:49:21 -0400 | [diff] [blame] | 1924 | psde->mmu_id = kms->mmu_id[MSM_SMMU_DOMAIN_UNSECURE]; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1925 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1926 | /* initialize underlying h/w driver */ |
| 1927 | psde->pipe_hw = sde_hw_sspp_init(pipe, kms->mmio, kms->catalog); |
| 1928 | if (IS_ERR(psde->pipe_hw)) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1929 | SDE_ERROR("[%u]SSPP init failed\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1930 | ret = PTR_ERR(psde->pipe_hw); |
| 1931 | goto clean_plane; |
| 1932 | } else if (!psde->pipe_hw->cap || !psde->pipe_hw->cap->sblk) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1933 | SDE_ERROR("[%u]SSPP init returned invalid cfg\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1934 | goto clean_sspp; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1935 | } |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1936 | |
| 1937 | /* cache features mask for later */ |
| 1938 | psde->features = psde->pipe_hw->cap->features; |
| 1939 | psde->pipe_sblk = psde->pipe_hw->cap->sblk; |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1940 | if (!psde->pipe_sblk) { |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1941 | SDE_ERROR("[%u]invalid sblk\n", pipe); |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1942 | goto clean_sspp; |
| 1943 | } |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1944 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1945 | if (kms->catalog && kms->catalog->mixer_count && kms->catalog->mixer) |
| 1946 | max_blendstages = kms->catalog->mixer[0].sblk->maxblendstages; |
| 1947 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1948 | /* add plane to DRM framework */ |
Clarence Ip | ea3d626 | 2016-07-15 16:20:11 -0400 | [diff] [blame] | 1949 | psde->nformats = sde_populate_formats(psde->pipe_sblk->format_list, |
| 1950 | psde->formats, |
| 1951 | 0, |
| 1952 | ARRAY_SIZE(psde->formats)); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1953 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1954 | if (!psde->nformats) { |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1955 | SDE_ERROR("[%u]no valid formats for plane\n", pipe); |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1956 | goto clean_sspp; |
| 1957 | } |
| 1958 | |
| 1959 | if (psde->features & BIT(SDE_SSPP_CURSOR)) |
| 1960 | type = DRM_PLANE_TYPE_CURSOR; |
| 1961 | else if (primary_plane) |
| 1962 | type = DRM_PLANE_TYPE_PRIMARY; |
| 1963 | else |
| 1964 | type = DRM_PLANE_TYPE_OVERLAY; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1965 | ret = drm_universal_plane_init(dev, plane, 0xff, &sde_plane_funcs, |
| 1966 | psde->formats, psde->nformats, |
| 1967 | type); |
| 1968 | if (ret) |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1969 | goto clean_sspp; |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1970 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1971 | /* success! finalize initialization */ |
Abhijit Kulkarni | 3e3e0d2 | 2016-06-24 17:56:13 -0400 | [diff] [blame] | 1972 | drm_plane_helper_add(plane, &sde_plane_helper_funcs); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1973 | |
Clarence Ip | aa0faf4 | 2016-05-30 12:07:48 -0400 | [diff] [blame] | 1974 | msm_property_init(&psde->property_info, &plane->base, dev, |
| 1975 | priv->plane_property, psde->property_data, |
| 1976 | PLANE_PROP_COUNT, PLANE_PROP_BLOBCOUNT, |
| 1977 | sizeof(struct sde_plane_state)); |
| 1978 | |
Dhaval Patel | 47302cf | 2016-08-18 15:04:28 -0700 | [diff] [blame] | 1979 | _sde_plane_install_properties(plane, max_blendstages); |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1980 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1981 | /* save user friendly pipe name for later */ |
Clarence Ip | 5e2a922 | 2016-06-26 22:38:24 -0400 | [diff] [blame] | 1982 | snprintf(psde->pipe_name, SDE_NAME_SIZE, "plane%u", plane->base.id); |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1983 | |
Clarence Ip | 730e719 | 2016-06-26 22:45:09 -0400 | [diff] [blame] | 1984 | mutex_init(&psde->lock); |
| 1985 | |
Clarence Ip | 4ce5932 | 2016-06-26 22:27:51 -0400 | [diff] [blame] | 1986 | _sde_plane_init_debugfs(psde, kms); |
| 1987 | |
Clarence Ip | 13a8cf4 | 2016-09-29 17:27:47 -0400 | [diff] [blame] | 1988 | DRM_INFO("%s created for pipe %u\n", psde->pipe_name, pipe); |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1989 | return plane; |
| 1990 | |
Clarence Ip | 4c1d977 | 2016-06-26 09:35:38 -0400 | [diff] [blame] | 1991 | clean_sspp: |
| 1992 | if (psde && psde->pipe_hw) |
| 1993 | sde_hw_sspp_destroy(psde->pipe_hw); |
| 1994 | clean_plane: |
| 1995 | kfree(psde); |
Ben Chan | 78647cd | 2016-06-26 22:02:47 -0400 | [diff] [blame] | 1996 | exit: |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1997 | return ERR_PTR(ret); |
| 1998 | } |