Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 1 | /* |
| 2 | * rcar_du_plane.c -- R-Car Display Unit Planes |
| 3 | * |
Laurent Pinchart | 36d5046 | 2014-02-06 18:13:52 +0100 | [diff] [blame] | 4 | * Copyright (C) 2013-2014 Renesas Electronics Corporation |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 5 | * |
| 6 | * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | */ |
| 13 | |
| 14 | #include <drm/drmP.h> |
Laurent Pinchart | 3e8da87 | 2015-02-20 11:30:59 +0200 | [diff] [blame] | 15 | #include <drm/drm_atomic_helper.h> |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 16 | #include <drm/drm_crtc.h> |
| 17 | #include <drm/drm_crtc_helper.h> |
| 18 | #include <drm/drm_fb_cma_helper.h> |
| 19 | #include <drm/drm_gem_cma_helper.h> |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 20 | #include <drm/drm_plane_helper.h> |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 21 | |
| 22 | #include "rcar_du_drv.h" |
| 23 | #include "rcar_du_kms.h" |
| 24 | #include "rcar_du_plane.h" |
| 25 | #include "rcar_du_regs.h" |
| 26 | |
| 27 | #define RCAR_DU_COLORKEY_NONE (0 << 24) |
| 28 | #define RCAR_DU_COLORKEY_SOURCE (1 << 24) |
| 29 | #define RCAR_DU_COLORKEY_MASK (1 << 24) |
| 30 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 31 | static inline struct rcar_du_plane *to_rcar_plane(struct drm_plane *plane) |
| 32 | { |
Laurent Pinchart | 917de18 | 2015-02-17 18:34:17 +0200 | [diff] [blame] | 33 | return container_of(plane, struct rcar_du_plane, plane); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 34 | } |
| 35 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 36 | static u32 rcar_du_plane_read(struct rcar_du_group *rgrp, |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 37 | unsigned int index, u32 reg) |
| 38 | { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 39 | return rcar_du_read(rgrp->dev, |
| 40 | rgrp->mmio_offset + index * PLANE_OFF + reg); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 41 | } |
| 42 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 43 | static void rcar_du_plane_write(struct rcar_du_group *rgrp, |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 44 | unsigned int index, u32 reg, u32 data) |
| 45 | { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 46 | rcar_du_write(rgrp->dev, rgrp->mmio_offset + index * PLANE_OFF + reg, |
| 47 | data); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 48 | } |
| 49 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 50 | static int rcar_du_plane_reserve_check(struct rcar_du_plane *plane, |
| 51 | const struct rcar_du_format_info *format) |
| 52 | { |
| 53 | struct rcar_du_group *rgrp = plane->group; |
| 54 | unsigned int free; |
| 55 | unsigned int i; |
| 56 | int ret; |
| 57 | |
| 58 | mutex_lock(&rgrp->planes.lock); |
| 59 | |
| 60 | free = rgrp->planes.free; |
| 61 | |
| 62 | if (plane->hwindex != -1) { |
| 63 | free |= 1 << plane->hwindex; |
| 64 | if (plane->format->planes == 2) |
| 65 | free |= 1 << ((plane->hwindex + 1) % 8); |
| 66 | } |
| 67 | |
| 68 | for (i = 0; i < ARRAY_SIZE(rgrp->planes.planes); ++i) { |
| 69 | if (!(free & (1 << i))) |
| 70 | continue; |
| 71 | |
| 72 | if (format->planes == 1 || free & (1 << ((i + 1) % 8))) |
| 73 | break; |
| 74 | } |
| 75 | |
| 76 | ret = i == ARRAY_SIZE(rgrp->planes.planes) ? -EBUSY : 0; |
| 77 | |
| 78 | mutex_unlock(&rgrp->planes.lock); |
| 79 | return ret; |
| 80 | } |
| 81 | |
Laurent Pinchart | 845f463 | 2015-02-18 15:47:27 +0200 | [diff] [blame] | 82 | static int rcar_du_plane_reserve(struct rcar_du_plane *plane, |
| 83 | const struct rcar_du_format_info *format) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 84 | { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 85 | struct rcar_du_group *rgrp = plane->group; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 86 | unsigned int i; |
| 87 | int ret = -EBUSY; |
| 88 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 89 | mutex_lock(&rgrp->planes.lock); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 90 | |
Laurent Pinchart | 3053460 | 2015-02-25 18:38:25 +0200 | [diff] [blame] | 91 | for (i = 0; i < RCAR_DU_NUM_HW_PLANES; ++i) { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 92 | if (!(rgrp->planes.free & (1 << i))) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 93 | continue; |
| 94 | |
| 95 | if (format->planes == 1 || |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 96 | rgrp->planes.free & (1 << ((i + 1) % 8))) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 97 | break; |
| 98 | } |
| 99 | |
Laurent Pinchart | 3053460 | 2015-02-25 18:38:25 +0200 | [diff] [blame] | 100 | if (i == RCAR_DU_NUM_HW_PLANES) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 101 | goto done; |
| 102 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 103 | rgrp->planes.free &= ~(1 << i); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 104 | if (format->planes == 2) |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 105 | rgrp->planes.free &= ~(1 << ((i + 1) % 8)); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 106 | |
| 107 | plane->hwindex = i; |
| 108 | |
| 109 | ret = 0; |
| 110 | |
| 111 | done: |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 112 | mutex_unlock(&rgrp->planes.lock); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 113 | return ret; |
| 114 | } |
| 115 | |
Laurent Pinchart | 845f463 | 2015-02-18 15:47:27 +0200 | [diff] [blame] | 116 | static void rcar_du_plane_release(struct rcar_du_plane *plane) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 117 | { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 118 | struct rcar_du_group *rgrp = plane->group; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 119 | |
| 120 | if (plane->hwindex == -1) |
| 121 | return; |
| 122 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 123 | mutex_lock(&rgrp->planes.lock); |
| 124 | rgrp->planes.free |= 1 << plane->hwindex; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 125 | if (plane->format->planes == 2) |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 126 | rgrp->planes.free |= 1 << ((plane->hwindex + 1) % 8); |
| 127 | mutex_unlock(&rgrp->planes.lock); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 128 | |
| 129 | plane->hwindex = -1; |
| 130 | } |
| 131 | |
Laurent Pinchart | d574664 | 2015-02-23 01:04:21 +0200 | [diff] [blame] | 132 | static void rcar_du_plane_update_base(struct rcar_du_plane *plane) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 133 | { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 134 | struct rcar_du_group *rgrp = plane->group; |
Laurent Pinchart | 287bdf0 | 2015-02-20 15:58:38 +0200 | [diff] [blame] | 135 | unsigned int src_x = plane->plane.state->src_x >> 16; |
| 136 | unsigned int src_y = plane->plane.state->src_y >> 16; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 137 | unsigned int index = plane->hwindex; |
Laurent Pinchart | 906eff7 | 2014-12-09 19:11:18 +0200 | [diff] [blame] | 138 | bool interlaced; |
Laurent Pinchart | eb86301 | 2013-11-13 14:26:01 +0100 | [diff] [blame] | 139 | u32 mwr; |
| 140 | |
Laurent Pinchart | 906eff7 | 2014-12-09 19:11:18 +0200 | [diff] [blame] | 141 | interlaced = plane->crtc->mode.flags & DRM_MODE_FLAG_INTERLACE; |
| 142 | |
| 143 | /* Memory pitch (expressed in pixels). Must be doubled for interlaced |
| 144 | * operation with 32bpp formats. |
| 145 | */ |
Laurent Pinchart | eb86301 | 2013-11-13 14:26:01 +0100 | [diff] [blame] | 146 | if (plane->format->planes == 2) |
| 147 | mwr = plane->pitch; |
| 148 | else |
| 149 | mwr = plane->pitch * 8 / plane->format->bpp; |
| 150 | |
Laurent Pinchart | 906eff7 | 2014-12-09 19:11:18 +0200 | [diff] [blame] | 151 | if (interlaced && plane->format->bpp == 32) |
| 152 | mwr *= 2; |
| 153 | |
Laurent Pinchart | eb86301 | 2013-11-13 14:26:01 +0100 | [diff] [blame] | 154 | rcar_du_plane_write(rgrp, index, PnMWR, mwr); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 155 | |
Laurent Pinchart | 9e7db06 | 2013-06-14 20:54:16 +0200 | [diff] [blame] | 156 | /* The Y position is expressed in raster line units and must be doubled |
| 157 | * for 32bpp formats, according to the R8A7790 datasheet. No mention of |
| 158 | * doubling the Y position is found in the R8A7779 datasheet, but the |
| 159 | * rule seems to apply there as well. |
| 160 | * |
Laurent Pinchart | 906eff7 | 2014-12-09 19:11:18 +0200 | [diff] [blame] | 161 | * Despite not being documented, doubling seem not to be needed when |
| 162 | * operating in interlaced mode. |
| 163 | * |
Laurent Pinchart | 9e7db06 | 2013-06-14 20:54:16 +0200 | [diff] [blame] | 164 | * Similarly, for the second plane, NV12 and NV21 formats seem to |
Laurent Pinchart | 906eff7 | 2014-12-09 19:11:18 +0200 | [diff] [blame] | 165 | * require a halved Y position value, in both progressive and interlaced |
| 166 | * modes. |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 167 | */ |
Laurent Pinchart | 287bdf0 | 2015-02-20 15:58:38 +0200 | [diff] [blame] | 168 | rcar_du_plane_write(rgrp, index, PnSPXR, src_x); |
| 169 | rcar_du_plane_write(rgrp, index, PnSPYR, src_y * |
Laurent Pinchart | 906eff7 | 2014-12-09 19:11:18 +0200 | [diff] [blame] | 170 | (!interlaced && plane->format->bpp == 32 ? 2 : 1)); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 171 | rcar_du_plane_write(rgrp, index, PnDSA0R, plane->dma[0]); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 172 | |
| 173 | if (plane->format->planes == 2) { |
| 174 | index = (index + 1) % 8; |
| 175 | |
Laurent Pinchart | 49785e2 | 2014-12-09 22:45:11 +0200 | [diff] [blame] | 176 | rcar_du_plane_write(rgrp, index, PnMWR, plane->pitch); |
| 177 | |
Laurent Pinchart | 287bdf0 | 2015-02-20 15:58:38 +0200 | [diff] [blame] | 178 | rcar_du_plane_write(rgrp, index, PnSPXR, src_x); |
| 179 | rcar_du_plane_write(rgrp, index, PnSPYR, src_y * |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 180 | (plane->format->bpp == 16 ? 2 : 1) / 2); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 181 | rcar_du_plane_write(rgrp, index, PnDSA0R, plane->dma[1]); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 182 | } |
| 183 | } |
| 184 | |
Laurent Pinchart | d574664 | 2015-02-23 01:04:21 +0200 | [diff] [blame] | 185 | static void rcar_du_plane_compute_base(struct rcar_du_plane *plane, |
| 186 | struct drm_framebuffer *fb) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 187 | { |
| 188 | struct drm_gem_cma_object *gem; |
| 189 | |
Laurent Pinchart | eb86301 | 2013-11-13 14:26:01 +0100 | [diff] [blame] | 190 | plane->pitch = fb->pitches[0]; |
| 191 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 192 | gem = drm_fb_cma_get_gem_obj(fb, 0); |
| 193 | plane->dma[0] = gem->paddr + fb->offsets[0]; |
| 194 | |
| 195 | if (plane->format->planes == 2) { |
| 196 | gem = drm_fb_cma_get_gem_obj(fb, 1); |
| 197 | plane->dma[1] = gem->paddr + fb->offsets[1]; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | static void rcar_du_plane_setup_mode(struct rcar_du_plane *plane, |
| 202 | unsigned int index) |
| 203 | { |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 204 | struct rcar_du_plane_state *state = |
| 205 | to_rcar_du_plane_state(plane->plane.state); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 206 | struct rcar_du_group *rgrp = plane->group; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 207 | u32 colorkey; |
| 208 | u32 pnmr; |
| 209 | |
| 210 | /* The PnALPHAR register controls alpha-blending in 16bpp formats |
| 211 | * (ARGB1555 and XRGB1555). |
| 212 | * |
| 213 | * For ARGB, set the alpha value to 0, and enable alpha-blending when |
| 214 | * the A bit is 0. This maps A=0 to alpha=0 and A=1 to alpha=255. |
| 215 | * |
| 216 | * For XRGB, set the alpha value to the plane-wide alpha value and |
| 217 | * enable alpha-blending regardless of the X bit value. |
| 218 | */ |
| 219 | if (plane->format->fourcc != DRM_FORMAT_XRGB1555) |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 220 | rcar_du_plane_write(rgrp, index, PnALPHAR, PnALPHAR_ABIT_0); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 221 | else |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 222 | rcar_du_plane_write(rgrp, index, PnALPHAR, |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 223 | PnALPHAR_ABIT_X | state->alpha); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 224 | |
| 225 | pnmr = PnMR_BM_MD | plane->format->pnmr; |
| 226 | |
| 227 | /* Disable color keying when requested. YUV formats have the |
| 228 | * PnMR_SPIM_TP_OFF bit set in their pnmr field, disabling color keying |
| 229 | * automatically. |
| 230 | */ |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 231 | if ((state->colorkey & RCAR_DU_COLORKEY_MASK) == RCAR_DU_COLORKEY_NONE) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 232 | pnmr |= PnMR_SPIM_TP_OFF; |
| 233 | |
| 234 | /* For packed YUV formats we need to select the U/V order. */ |
| 235 | if (plane->format->fourcc == DRM_FORMAT_YUYV) |
| 236 | pnmr |= PnMR_YCDF_YUYV; |
| 237 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 238 | rcar_du_plane_write(rgrp, index, PnMR, pnmr); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 239 | |
| 240 | switch (plane->format->fourcc) { |
| 241 | case DRM_FORMAT_RGB565: |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 242 | colorkey = ((state->colorkey & 0xf80000) >> 8) |
| 243 | | ((state->colorkey & 0x00fc00) >> 5) |
| 244 | | ((state->colorkey & 0x0000f8) >> 3); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 245 | rcar_du_plane_write(rgrp, index, PnTC2R, colorkey); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 246 | break; |
| 247 | |
| 248 | case DRM_FORMAT_ARGB1555: |
| 249 | case DRM_FORMAT_XRGB1555: |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 250 | colorkey = ((state->colorkey & 0xf80000) >> 9) |
| 251 | | ((state->colorkey & 0x00f800) >> 6) |
| 252 | | ((state->colorkey & 0x0000f8) >> 3); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 253 | rcar_du_plane_write(rgrp, index, PnTC2R, colorkey); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 254 | break; |
| 255 | |
| 256 | case DRM_FORMAT_XRGB8888: |
| 257 | case DRM_FORMAT_ARGB8888: |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 258 | rcar_du_plane_write(rgrp, index, PnTC3R, |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 259 | PnTC3R_CODE | (state->colorkey & 0xffffff)); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 260 | break; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | static void __rcar_du_plane_setup(struct rcar_du_plane *plane, |
| 265 | unsigned int index) |
| 266 | { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 267 | struct rcar_du_group *rgrp = plane->group; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 268 | u32 ddcr2 = PnDDCR2_CODE; |
| 269 | u32 ddcr4; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 270 | |
| 271 | /* Data format |
| 272 | * |
| 273 | * The data format is selected by the DDDF field in PnMR and the EDF |
| 274 | * field in DDCR4. |
| 275 | */ |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 276 | ddcr4 = rcar_du_plane_read(rgrp, index, PnDDCR4); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 277 | ddcr4 &= ~PnDDCR4_EDF_MASK; |
| 278 | ddcr4 |= plane->format->edf | PnDDCR4_CODE; |
| 279 | |
| 280 | rcar_du_plane_setup_mode(plane, index); |
| 281 | |
| 282 | if (plane->format->planes == 2) { |
| 283 | if (plane->hwindex != index) { |
| 284 | if (plane->format->fourcc == DRM_FORMAT_NV12 || |
| 285 | plane->format->fourcc == DRM_FORMAT_NV21) |
| 286 | ddcr2 |= PnDDCR2_Y420; |
| 287 | |
| 288 | if (plane->format->fourcc == DRM_FORMAT_NV21) |
| 289 | ddcr2 |= PnDDCR2_NV21; |
| 290 | |
| 291 | ddcr2 |= PnDDCR2_DIVU; |
| 292 | } else { |
| 293 | ddcr2 |= PnDDCR2_DIVY; |
| 294 | } |
| 295 | } |
| 296 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 297 | rcar_du_plane_write(rgrp, index, PnDDCR2, ddcr2); |
| 298 | rcar_du_plane_write(rgrp, index, PnDDCR4, ddcr4); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 299 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 300 | /* Destination position and size */ |
Laurent Pinchart | 287bdf0 | 2015-02-20 15:58:38 +0200 | [diff] [blame] | 301 | rcar_du_plane_write(rgrp, index, PnDSXR, plane->plane.state->crtc_w); |
| 302 | rcar_du_plane_write(rgrp, index, PnDSYR, plane->plane.state->crtc_h); |
| 303 | rcar_du_plane_write(rgrp, index, PnDPXR, plane->plane.state->crtc_x); |
| 304 | rcar_du_plane_write(rgrp, index, PnDPYR, plane->plane.state->crtc_y); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 305 | |
| 306 | /* Wrap-around and blinking, disabled */ |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 307 | rcar_du_plane_write(rgrp, index, PnWASPR, 0); |
| 308 | rcar_du_plane_write(rgrp, index, PnWAMWR, 4095); |
| 309 | rcar_du_plane_write(rgrp, index, PnBTR, 0); |
| 310 | rcar_du_plane_write(rgrp, index, PnMLR, 0); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | void rcar_du_plane_setup(struct rcar_du_plane *plane) |
| 314 | { |
| 315 | __rcar_du_plane_setup(plane, plane->hwindex); |
| 316 | if (plane->format->planes == 2) |
| 317 | __rcar_du_plane_setup(plane, (plane->hwindex + 1) % 8); |
| 318 | |
| 319 | rcar_du_plane_update_base(plane); |
| 320 | } |
| 321 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 322 | static int rcar_du_plane_atomic_check(struct drm_plane *plane, |
| 323 | struct drm_plane_state *state) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 324 | { |
| 325 | struct rcar_du_plane *rplane = to_rcar_plane(plane); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 326 | struct rcar_du_device *rcdu = rplane->group->dev; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 327 | const struct rcar_du_format_info *format; |
| 328 | unsigned int nplanes; |
| 329 | int ret; |
| 330 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 331 | if (!state->fb || !state->crtc) |
| 332 | return 0; |
Laurent Pinchart | 917de18 | 2015-02-17 18:34:17 +0200 | [diff] [blame] | 333 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 334 | if (state->src_w >> 16 != state->crtc_w || |
| 335 | state->src_h >> 16 != state->crtc_h) { |
| 336 | dev_dbg(rcdu->dev, "%s: scaling not supported\n", __func__); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 337 | return -EINVAL; |
| 338 | } |
| 339 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 340 | format = rcar_du_format_info(state->fb->pixel_format); |
| 341 | if (format == NULL) { |
| 342 | dev_dbg(rcdu->dev, "%s: unsupported format %08x\n", __func__, |
| 343 | state->fb->pixel_format); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 344 | return -EINVAL; |
| 345 | } |
| 346 | |
| 347 | nplanes = rplane->format ? rplane->format->planes : 0; |
| 348 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 349 | /* If the number of required planes has changed we will need to |
| 350 | * reallocate hardware planes. Ensure free planes are available. |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 351 | */ |
| 352 | if (format->planes != nplanes) { |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 353 | ret = rcar_du_plane_reserve_check(rplane, format); |
| 354 | if (ret < 0) { |
| 355 | dev_dbg(rcdu->dev, "%s: no available hardware plane\n", |
| 356 | __func__); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 357 | return ret; |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 358 | } |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 359 | } |
| 360 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 361 | return 0; |
| 362 | } |
| 363 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 364 | static void rcar_du_plane_disable(struct rcar_du_plane *rplane) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 365 | { |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 366 | if (!rplane->enabled) |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 367 | return; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 368 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 369 | mutex_lock(&rplane->group->planes.lock); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 370 | rplane->enabled = false; |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 371 | mutex_unlock(&rplane->group->planes.lock); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 372 | |
| 373 | rcar_du_plane_release(rplane); |
| 374 | |
| 375 | rplane->crtc = NULL; |
| 376 | rplane->format = NULL; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 377 | } |
| 378 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 379 | static void rcar_du_plane_atomic_update(struct drm_plane *plane, |
| 380 | struct drm_plane_state *old_state) |
| 381 | { |
| 382 | struct rcar_du_plane *rplane = to_rcar_plane(plane); |
| 383 | struct drm_plane_state *state = plane->state; |
| 384 | const struct rcar_du_format_info *format; |
| 385 | unsigned int nplanes; |
| 386 | |
| 387 | if (!state->crtc) { |
| 388 | rcar_du_plane_disable(rplane); |
| 389 | return; |
| 390 | } |
| 391 | |
| 392 | format = rcar_du_format_info(state->fb->pixel_format); |
| 393 | nplanes = rplane->format ? rplane->format->planes : 0; |
| 394 | |
| 395 | /* Reallocate hardware planes if the number of required planes has |
| 396 | * changed. |
| 397 | */ |
| 398 | if (format->planes != nplanes) { |
| 399 | rcar_du_plane_release(rplane); |
| 400 | rcar_du_plane_reserve(rplane, format); |
| 401 | } |
| 402 | |
| 403 | rplane->crtc = state->crtc; |
| 404 | rplane->format = format; |
| 405 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 406 | rcar_du_plane_compute_base(rplane, state->fb); |
| 407 | rcar_du_plane_setup(rplane); |
| 408 | |
| 409 | mutex_lock(&rplane->group->planes.lock); |
| 410 | rplane->enabled = true; |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 411 | mutex_unlock(&rplane->group->planes.lock); |
| 412 | } |
| 413 | |
| 414 | static const struct drm_plane_helper_funcs rcar_du_plane_helper_funcs = { |
| 415 | .atomic_check = rcar_du_plane_atomic_check, |
| 416 | .atomic_update = rcar_du_plane_atomic_update, |
| 417 | }; |
| 418 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 419 | static void rcar_du_plane_reset(struct drm_plane *plane) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 420 | { |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 421 | struct rcar_du_plane_state *state; |
| 422 | |
| 423 | if (plane->state && plane->state->fb) |
| 424 | drm_framebuffer_unreference(plane->state->fb); |
| 425 | |
| 426 | kfree(plane->state); |
| 427 | plane->state = NULL; |
| 428 | |
| 429 | state = kzalloc(sizeof(*state), GFP_KERNEL); |
| 430 | if (state == NULL) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 431 | return; |
| 432 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 433 | state->alpha = 255; |
| 434 | state->colorkey = RCAR_DU_COLORKEY_NONE; |
| 435 | state->zpos = plane->type == DRM_PLANE_TYPE_PRIMARY ? 0 : 1; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 436 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 437 | plane->state = &state->state; |
| 438 | plane->state->plane = plane; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 439 | } |
| 440 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 441 | static struct drm_plane_state * |
| 442 | rcar_du_plane_atomic_duplicate_state(struct drm_plane *plane) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 443 | { |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 444 | struct rcar_du_plane_state *state; |
| 445 | struct rcar_du_plane_state *copy; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 446 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 447 | state = to_rcar_du_plane_state(plane->state); |
| 448 | copy = kmemdup(state, sizeof(*state), GFP_KERNEL); |
| 449 | if (copy == NULL) |
| 450 | return NULL; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 451 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 452 | if (copy->state.fb) |
| 453 | drm_framebuffer_reference(copy->state.fb); |
| 454 | |
| 455 | return ©->state; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 456 | } |
| 457 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 458 | static void rcar_du_plane_atomic_destroy_state(struct drm_plane *plane, |
| 459 | struct drm_plane_state *state) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 460 | { |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 461 | kfree(to_rcar_du_plane_state(state)); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 462 | } |
| 463 | |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 464 | static int rcar_du_plane_atomic_set_property(struct drm_plane *plane, |
| 465 | struct drm_plane_state *state, |
| 466 | struct drm_property *property, |
| 467 | uint64_t val) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 468 | { |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 469 | struct rcar_du_plane_state *rstate = to_rcar_du_plane_state(state); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 470 | struct rcar_du_plane *rplane = to_rcar_plane(plane); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 471 | struct rcar_du_group *rgrp = rplane->group; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 472 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 473 | if (property == rgrp->planes.alpha) |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 474 | rstate->alpha = val; |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 475 | else if (property == rgrp->planes.colorkey) |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 476 | rstate->colorkey = val; |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 477 | else if (property == rgrp->planes.zpos) |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 478 | rstate->zpos = val; |
| 479 | else |
| 480 | return -EINVAL; |
| 481 | |
| 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | static int rcar_du_plane_atomic_get_property(struct drm_plane *plane, |
| 486 | const struct drm_plane_state *state, struct drm_property *property, |
| 487 | uint64_t *val) |
| 488 | { |
| 489 | const struct rcar_du_plane_state *rstate = |
| 490 | container_of(state, const struct rcar_du_plane_state, state); |
| 491 | struct rcar_du_plane *rplane = to_rcar_plane(plane); |
| 492 | struct rcar_du_group *rgrp = rplane->group; |
| 493 | |
| 494 | if (property == rgrp->planes.alpha) |
| 495 | *val = rstate->alpha; |
| 496 | else if (property == rgrp->planes.colorkey) |
| 497 | *val = rstate->colorkey; |
| 498 | else if (property == rgrp->planes.zpos) |
| 499 | *val = rstate->zpos; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 500 | else |
| 501 | return -EINVAL; |
| 502 | |
| 503 | return 0; |
| 504 | } |
| 505 | |
| 506 | static const struct drm_plane_funcs rcar_du_plane_funcs = { |
Laurent Pinchart | 336d04a | 2015-02-20 13:18:56 +0200 | [diff] [blame] | 507 | .update_plane = drm_atomic_helper_update_plane, |
| 508 | .disable_plane = drm_atomic_helper_disable_plane, |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 509 | .reset = rcar_du_plane_reset, |
| 510 | .set_property = drm_atomic_helper_plane_set_property, |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 511 | .destroy = drm_plane_cleanup, |
Laurent Pinchart | 4407cc0 | 2015-02-23 02:36:31 +0200 | [diff] [blame^] | 512 | .atomic_duplicate_state = rcar_du_plane_atomic_duplicate_state, |
| 513 | .atomic_destroy_state = rcar_du_plane_atomic_destroy_state, |
| 514 | .atomic_set_property = rcar_du_plane_atomic_set_property, |
| 515 | .atomic_get_property = rcar_du_plane_atomic_get_property, |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 516 | }; |
| 517 | |
| 518 | static const uint32_t formats[] = { |
| 519 | DRM_FORMAT_RGB565, |
| 520 | DRM_FORMAT_ARGB1555, |
| 521 | DRM_FORMAT_XRGB1555, |
| 522 | DRM_FORMAT_XRGB8888, |
| 523 | DRM_FORMAT_ARGB8888, |
| 524 | DRM_FORMAT_UYVY, |
| 525 | DRM_FORMAT_YUYV, |
| 526 | DRM_FORMAT_NV12, |
| 527 | DRM_FORMAT_NV21, |
| 528 | DRM_FORMAT_NV16, |
| 529 | }; |
| 530 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 531 | int rcar_du_planes_init(struct rcar_du_group *rgrp) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 532 | { |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 533 | struct rcar_du_planes *planes = &rgrp->planes; |
| 534 | struct rcar_du_device *rcdu = rgrp->dev; |
Laurent Pinchart | 917de18 | 2015-02-17 18:34:17 +0200 | [diff] [blame] | 535 | unsigned int num_planes; |
| 536 | unsigned int num_crtcs; |
| 537 | unsigned int crtcs; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 538 | unsigned int i; |
Laurent Pinchart | 917de18 | 2015-02-17 18:34:17 +0200 | [diff] [blame] | 539 | int ret; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 540 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 541 | mutex_init(&planes->lock); |
| 542 | planes->free = 0xff; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 543 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 544 | planes->alpha = |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 545 | drm_property_create_range(rcdu->ddev, 0, "alpha", 0, 255); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 546 | if (planes->alpha == NULL) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 547 | return -ENOMEM; |
| 548 | |
| 549 | /* The color key is expressed as an RGB888 triplet stored in a 32-bit |
| 550 | * integer in XRGB8888 format. Bit 24 is used as a flag to disable (0) |
| 551 | * or enable source color keying (1). |
| 552 | */ |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 553 | planes->colorkey = |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 554 | drm_property_create_range(rcdu->ddev, 0, "colorkey", |
| 555 | 0, 0x01ffffff); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 556 | if (planes->colorkey == NULL) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 557 | return -ENOMEM; |
| 558 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 559 | planes->zpos = |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 560 | drm_property_create_range(rcdu->ddev, 0, "zpos", 1, 7); |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 561 | if (planes->zpos == NULL) |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 562 | return -ENOMEM; |
| 563 | |
Laurent Pinchart | 917de18 | 2015-02-17 18:34:17 +0200 | [diff] [blame] | 564 | /* Create one primary plane per in this group CRTC and seven overlay |
| 565 | * planes. |
| 566 | */ |
| 567 | num_crtcs = min(rcdu->num_crtcs - 2 * rgrp->index, 2U); |
| 568 | num_planes = num_crtcs + 7; |
| 569 | |
| 570 | crtcs = ((1 << rcdu->num_crtcs) - 1) & (3 << (2 * rgrp->index)); |
| 571 | |
| 572 | for (i = 0; i < num_planes; ++i) { |
| 573 | enum drm_plane_type type = i < num_crtcs |
| 574 | ? DRM_PLANE_TYPE_PRIMARY |
| 575 | : DRM_PLANE_TYPE_OVERLAY; |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 576 | struct rcar_du_plane *plane = &planes->planes[i]; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 577 | |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 578 | plane->group = rgrp; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 579 | plane->hwindex = -1; |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 580 | |
Laurent Pinchart | 917de18 | 2015-02-17 18:34:17 +0200 | [diff] [blame] | 581 | ret = drm_universal_plane_init(rcdu->ddev, &plane->plane, crtcs, |
| 582 | &rcar_du_plane_funcs, formats, |
| 583 | ARRAY_SIZE(formats), type); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 584 | if (ret < 0) |
| 585 | return ret; |
| 586 | |
Laurent Pinchart | 920888a | 2015-02-18 12:18:05 +0200 | [diff] [blame] | 587 | drm_plane_helper_add(&plane->plane, |
| 588 | &rcar_du_plane_helper_funcs); |
| 589 | |
Laurent Pinchart | 917de18 | 2015-02-17 18:34:17 +0200 | [diff] [blame] | 590 | if (type == DRM_PLANE_TYPE_PRIMARY) |
| 591 | continue; |
| 592 | |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 593 | drm_object_attach_property(&plane->plane.base, |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 594 | planes->alpha, 255); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 595 | drm_object_attach_property(&plane->plane.base, |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 596 | planes->colorkey, |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 597 | RCAR_DU_COLORKEY_NONE); |
| 598 | drm_object_attach_property(&plane->plane.base, |
Laurent Pinchart | cb2025d | 2013-06-16 21:01:02 +0200 | [diff] [blame] | 599 | planes->zpos, 1); |
Laurent Pinchart | 4bf8e19 | 2013-06-19 13:54:11 +0200 | [diff] [blame] | 600 | } |
| 601 | |
| 602 | return 0; |
| 603 | } |