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

drm/msm/mdp5: Add rotation (hflip/vflip) support to MDP5 planes (v2)

MDP5 SSPPs can flip the input source horizontally or vertically.
This change is to add this support to MDP5 planes.

v1: Initial change
v2: Use existing "rotation" property instead of creating msm specific
properties. In order to be compatiable with legacy non-atomic
set_property, switch to drm_atomic_helper_plane_set_property
helper function.

Signed-off-by: Jilai Wang <jilaiw@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>

authored by

jilai wang and committed by
Rob Clark
8089082f 095022b9

+41 -8
+41 -8
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
··· 66 66 kfree(mdp5_plane); 67 67 } 68 68 69 + static void mdp5_plane_install_rotation_property(struct drm_device *dev, 70 + struct drm_plane *plane) 71 + { 72 + struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane); 73 + 74 + if (!(mdp5_plane->caps & MDP_PIPE_CAP_HFLIP) && 75 + !(mdp5_plane->caps & MDP_PIPE_CAP_VFLIP)) 76 + return; 77 + 78 + if (!dev->mode_config.rotation_property) 79 + dev->mode_config.rotation_property = 80 + drm_mode_create_rotation_property(dev, 81 + BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y)); 82 + 83 + if (dev->mode_config.rotation_property) 84 + drm_object_attach_property(&plane->base, 85 + dev->mode_config.rotation_property, 86 + 0); 87 + } 88 + 69 89 /* helper to install properties which are common to planes and crtcs */ 70 90 static void mdp5_plane_install_properties(struct drm_plane *plane, 71 91 struct drm_mode_object *obj) ··· 121 101 122 102 INSTALL_RANGE_PROPERTY(zpos, ZPOS, 1, 255, 1); 123 103 104 + mdp5_plane_install_rotation_property(dev, plane); 105 + 124 106 #undef INSTALL_RANGE_PROPERTY 125 107 #undef INSTALL_ENUM_PROPERTY 126 108 #undef INSTALL_PROPERTY ··· 154 132 done: 155 133 return ret; 156 134 #undef SET_PROPERTY 157 - } 158 - 159 - static int mdp5_plane_set_property(struct drm_plane *plane, 160 - struct drm_property *property, uint64_t val) 161 - { 162 - return mdp5_plane_atomic_set_property(plane, plane->state, property, 163 - val); 164 135 } 165 136 166 137 static int mdp5_plane_atomic_get_property(struct drm_plane *plane, ··· 241 226 .update_plane = drm_atomic_helper_update_plane, 242 227 .disable_plane = drm_atomic_helper_disable_plane, 243 228 .destroy = mdp5_plane_destroy, 244 - .set_property = mdp5_plane_set_property, 229 + .set_property = drm_atomic_helper_plane_set_property, 245 230 .atomic_set_property = mdp5_plane_atomic_set_property, 246 231 .atomic_get_property = mdp5_plane_atomic_get_property, 247 232 .reset = mdp5_plane_reset, ··· 277 262 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane); 278 263 struct drm_plane_state *old_state = plane->state; 279 264 const struct mdp_format *format; 265 + bool vflip, hflip; 280 266 281 267 DBG("%s: check (%d -> %d)", mdp5_plane->name, 282 268 plane_enabled(old_state), plane_enabled(state)); ··· 299 283 "Pipe doesn't support scaling (%dx%d -> %dx%d)\n", 300 284 state->src_w >> 16, state->src_h >> 16, 301 285 state->crtc_w, state->crtc_h); 286 + 287 + return -EINVAL; 288 + } 289 + 290 + hflip = !!(state->rotation & BIT(DRM_REFLECT_X)); 291 + vflip = !!(state->rotation & BIT(DRM_REFLECT_Y)); 292 + if ((vflip && !(mdp5_plane->caps & MDP_PIPE_CAP_VFLIP)) || 293 + (hflip && !(mdp5_plane->caps & MDP_PIPE_CAP_HFLIP))) { 294 + dev_err(plane->dev->dev, 295 + "Pipe doesn't support flip\n"); 302 296 303 297 return -EINVAL; 304 298 } ··· 582 556 uint32_t src_w, uint32_t src_h) 583 557 { 584 558 struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane); 559 + struct drm_plane_state *pstate = plane->state; 585 560 struct mdp5_kms *mdp5_kms = get_kms(plane); 586 561 enum mdp5_pipe pipe = mdp5_plane->pipe; 587 562 const struct mdp_format *format; ··· 591 564 uint32_t phasex_step[2] = {0,}, phasey_step[2] = {0,}; 592 565 uint32_t hdecm = 0, vdecm = 0; 593 566 uint32_t pix_format; 567 + bool vflip, hflip; 594 568 unsigned long flags; 595 569 int ret; 596 570 ··· 643 615 config |= get_scale_config(format->chroma_sample, src_h, crtc_h, false); 644 616 DBG("scale config = %x", config); 645 617 618 + hflip = !!(pstate->rotation & BIT(DRM_REFLECT_X)); 619 + vflip = !!(pstate->rotation & BIT(DRM_REFLECT_Y)); 620 + 646 621 spin_lock_irqsave(&mdp5_plane->pipe_lock, flags); 647 622 648 623 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_IMG_SIZE(pipe), ··· 687 656 MDP5_PIPE_SRC_UNPACK_ELEM3(format->unpack[3])); 688 657 689 658 mdp5_write(mdp5_kms, REG_MDP5_PIPE_SRC_OP_MODE(pipe), 659 + (hflip ? MDP5_PIPE_SRC_OP_MODE_FLIP_LR : 0) | 660 + (vflip ? MDP5_PIPE_SRC_OP_MODE_FLIP_UD : 0) | 690 661 MDP5_PIPE_SRC_OP_MODE_BWC(BWC_LOSSLESS)); 691 662 692 663 /* not using secure mode: */