| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2011 Samsung Electronics Co.Ltd |
|---|
| 3 | 4 | * Authors: Joonyoung Shim <jy0922.shim@samsung.com> |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 6 | | - * under the terms of the GNU General Public License as published by the |
|---|
| 7 | | - * Free Software Foundation; either version 2 of the License, or (at your |
|---|
| 8 | | - * option) any later version. |
|---|
| 9 | | - * |
|---|
| 10 | 5 | */ |
|---|
| 11 | 6 | |
|---|
| 12 | | -#include <drm/drmP.h> |
|---|
| 13 | 7 | |
|---|
| 14 | 8 | #include <drm/drm_atomic.h> |
|---|
| 15 | 9 | #include <drm/drm_atomic_helper.h> |
|---|
| 16 | 10 | #include <drm/drm_plane_helper.h> |
|---|
| 17 | 11 | #include <drm/exynos_drm.h> |
|---|
| 18 | | -#include "exynos_drm_drv.h" |
|---|
| 12 | + |
|---|
| 19 | 13 | #include "exynos_drm_crtc.h" |
|---|
| 14 | +#include "exynos_drm_drv.h" |
|---|
| 20 | 15 | #include "exynos_drm_fb.h" |
|---|
| 21 | 16 | #include "exynos_drm_gem.h" |
|---|
| 22 | 17 | #include "exynos_drm_plane.h" |
|---|
| .. | .. |
|---|
| 119 | 114 | exynos_state->crtc.w = actual_w; |
|---|
| 120 | 115 | exynos_state->crtc.h = actual_h; |
|---|
| 121 | 116 | |
|---|
| 122 | | - DRM_DEBUG_KMS("plane : offset_x/y(%d,%d), width/height(%d,%d)", |
|---|
| 123 | | - exynos_state->crtc.x, exynos_state->crtc.y, |
|---|
| 124 | | - exynos_state->crtc.w, exynos_state->crtc.h); |
|---|
| 117 | + DRM_DEV_DEBUG_KMS(crtc->dev->dev, |
|---|
| 118 | + "plane : offset_x/y(%d,%d), width/height(%d,%d)", |
|---|
| 119 | + exynos_state->crtc.x, exynos_state->crtc.y, |
|---|
| 120 | + exynos_state->crtc.w, exynos_state->crtc.h); |
|---|
| 125 | 121 | } |
|---|
| 126 | 122 | |
|---|
| 127 | 123 | static void exynos_drm_plane_reset(struct drm_plane *plane) |
|---|
| .. | .. |
|---|
| 131 | 127 | |
|---|
| 132 | 128 | if (plane->state) { |
|---|
| 133 | 129 | exynos_state = to_exynos_plane_state(plane->state); |
|---|
| 134 | | - if (exynos_state->base.fb) |
|---|
| 135 | | - drm_framebuffer_put(exynos_state->base.fb); |
|---|
| 130 | + __drm_atomic_helper_plane_destroy_state(plane->state); |
|---|
| 136 | 131 | kfree(exynos_state); |
|---|
| 137 | 132 | plane->state = NULL; |
|---|
| 138 | 133 | } |
|---|
| 139 | 134 | |
|---|
| 140 | 135 | exynos_state = kzalloc(sizeof(*exynos_state), GFP_KERNEL); |
|---|
| 141 | 136 | if (exynos_state) { |
|---|
| 142 | | - plane->state = &exynos_state->base; |
|---|
| 143 | | - plane->state->plane = plane; |
|---|
| 137 | + __drm_atomic_helper_plane_reset(plane, &exynos_state->base); |
|---|
| 144 | 138 | plane->state->zpos = exynos_plane->config->zpos; |
|---|
| 145 | 139 | } |
|---|
| 146 | 140 | } |
|---|
| .. | .. |
|---|
| 183 | 177 | struct exynos_drm_plane_state *state) |
|---|
| 184 | 178 | { |
|---|
| 185 | 179 | struct drm_framebuffer *fb = state->base.fb; |
|---|
| 180 | + struct drm_device *dev = fb->dev; |
|---|
| 186 | 181 | |
|---|
| 187 | 182 | switch (fb->modifier) { |
|---|
| 188 | 183 | case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: |
|---|
| .. | .. |
|---|
| 194 | 189 | break; |
|---|
| 195 | 190 | |
|---|
| 196 | 191 | default: |
|---|
| 197 | | - DRM_ERROR("unsupported pixel format modifier"); |
|---|
| 192 | + DRM_DEV_ERROR(dev->dev, "unsupported pixel format modifier"); |
|---|
| 198 | 193 | return -ENOTSUPP; |
|---|
| 199 | 194 | } |
|---|
| 200 | 195 | |
|---|
| .. | .. |
|---|
| 205 | 200 | exynos_drm_plane_check_size(const struct exynos_drm_plane_config *config, |
|---|
| 206 | 201 | struct exynos_drm_plane_state *state) |
|---|
| 207 | 202 | { |
|---|
| 203 | + struct drm_crtc *crtc = state->base.crtc; |
|---|
| 208 | 204 | bool width_ok = false, height_ok = false; |
|---|
| 209 | 205 | |
|---|
| 210 | 206 | if (config->capabilities & EXYNOS_DRM_PLANE_CAP_SCALE) |
|---|
| .. | .. |
|---|
| 227 | 223 | if (width_ok && height_ok) |
|---|
| 228 | 224 | return 0; |
|---|
| 229 | 225 | |
|---|
| 230 | | - DRM_DEBUG_KMS("scaling mode is not supported"); |
|---|
| 226 | + DRM_DEV_DEBUG_KMS(crtc->dev->dev, "scaling mode is not supported"); |
|---|
| 231 | 227 | return -ENOTSUPP; |
|---|
| 232 | 228 | } |
|---|
| 233 | 229 | |
|---|
| .. | .. |
|---|
| 300 | 296 | const struct exynos_drm_plane_config *config) |
|---|
| 301 | 297 | { |
|---|
| 302 | 298 | int err; |
|---|
| 299 | + unsigned int supported_modes = BIT(DRM_MODE_BLEND_PIXEL_NONE) | |
|---|
| 300 | + BIT(DRM_MODE_BLEND_PREMULTI) | |
|---|
| 301 | + BIT(DRM_MODE_BLEND_COVERAGE); |
|---|
| 302 | + struct drm_plane *plane = &exynos_plane->base; |
|---|
| 303 | 303 | |
|---|
| 304 | 304 | err = drm_universal_plane_init(dev, &exynos_plane->base, |
|---|
| 305 | 305 | 1 << dev->mode_config.num_crtc, |
|---|
| .. | .. |
|---|
| 308 | 308 | config->num_pixel_formats, |
|---|
| 309 | 309 | NULL, config->type, NULL); |
|---|
| 310 | 310 | if (err) { |
|---|
| 311 | | - DRM_ERROR("failed to initialize plane\n"); |
|---|
| 311 | + DRM_DEV_ERROR(dev->dev, "failed to initialize plane\n"); |
|---|
| 312 | 312 | return err; |
|---|
| 313 | 313 | } |
|---|
| 314 | 314 | |
|---|
| .. | .. |
|---|
| 320 | 320 | exynos_plane_attach_zpos_property(&exynos_plane->base, config->zpos, |
|---|
| 321 | 321 | !(config->capabilities & EXYNOS_DRM_PLANE_CAP_ZPOS)); |
|---|
| 322 | 322 | |
|---|
| 323 | + if (config->capabilities & EXYNOS_DRM_PLANE_CAP_PIX_BLEND) |
|---|
| 324 | + drm_plane_create_blend_mode_property(plane, supported_modes); |
|---|
| 325 | + |
|---|
| 326 | + if (config->capabilities & EXYNOS_DRM_PLANE_CAP_WIN_BLEND) |
|---|
| 327 | + drm_plane_create_alpha_property(plane); |
|---|
| 328 | + |
|---|
| 323 | 329 | return 0; |
|---|
| 324 | 330 | } |
|---|