| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright 2016 Linaro Ltd. |
|---|
| 3 | 4 | * Copyright 2016 ZTE Corporation. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 6 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 7 | | - * published by the Free Software Foundation. |
|---|
| 8 | | - * |
|---|
| 9 | 5 | */ |
|---|
| 10 | 6 | |
|---|
| 11 | 7 | #include <drm/drm_atomic.h> |
|---|
| 12 | 8 | #include <drm/drm_atomic_helper.h> |
|---|
| 13 | 9 | #include <drm/drm_fb_cma_helper.h> |
|---|
| 10 | +#include <drm/drm_fourcc.h> |
|---|
| 14 | 11 | #include <drm/drm_gem_cma_helper.h> |
|---|
| 15 | 12 | #include <drm/drm_modeset_helper_vtables.h> |
|---|
| 16 | 13 | #include <drm/drm_plane_helper.h> |
|---|
| 17 | | -#include <drm/drmP.h> |
|---|
| 18 | 14 | |
|---|
| 19 | 15 | #include "zx_common_regs.h" |
|---|
| 20 | 16 | #include "zx_drm_drv.h" |
|---|
| .. | .. |
|---|
| 58 | 54 | int min_scale = FRAC_16_16(1, 8); |
|---|
| 59 | 55 | int max_scale = FRAC_16_16(8, 1); |
|---|
| 60 | 56 | |
|---|
| 61 | | - if (!crtc || !fb) |
|---|
| 57 | + if (!crtc || WARN_ON(!fb)) |
|---|
| 62 | 58 | return 0; |
|---|
| 63 | 59 | |
|---|
| 64 | 60 | crtc_state = drm_atomic_get_existing_crtc_state(plane_state->state, |
|---|
| .. | .. |
|---|
| 199 | 195 | u32 dst_x, dst_y, dst_w, dst_h; |
|---|
| 200 | 196 | uint32_t format; |
|---|
| 201 | 197 | int fmt; |
|---|
| 202 | | - int num_planes; |
|---|
| 203 | 198 | int i; |
|---|
| 204 | 199 | |
|---|
| 205 | 200 | if (!fb) |
|---|
| .. | .. |
|---|
| 218 | 213 | dst_h = drm_rect_height(dst); |
|---|
| 219 | 214 | |
|---|
| 220 | 215 | /* Set up data address registers for Y, Cb and Cr planes */ |
|---|
| 221 | | - num_planes = drm_format_num_planes(format); |
|---|
| 222 | 216 | paddr_reg = layer + VL_Y; |
|---|
| 223 | | - for (i = 0; i < num_planes; i++) { |
|---|
| 217 | + for (i = 0; i < fb->format->num_planes; i++) { |
|---|
| 224 | 218 | cma_obj = drm_fb_cma_get_gem_obj(fb, i); |
|---|
| 225 | 219 | paddr = cma_obj->paddr + fb->offsets[i]; |
|---|
| 226 | 220 | paddr += src_y * fb->pitches[i]; |
|---|
| 227 | | - paddr += src_x * drm_format_plane_cpp(format, i); |
|---|
| 221 | + paddr += src_x * fb->format->cpp[i]; |
|---|
| 228 | 222 | zx_writel(paddr_reg, paddr); |
|---|
| 229 | 223 | paddr_reg += 4; |
|---|
| 230 | 224 | } |
|---|
| .. | .. |
|---|
| 287 | 281 | struct drm_crtc *crtc = plane_state->crtc; |
|---|
| 288 | 282 | struct drm_crtc_state *crtc_state; |
|---|
| 289 | 283 | |
|---|
| 290 | | - if (!crtc || !fb) |
|---|
| 284 | + if (!crtc || WARN_ON(!fb)) |
|---|
| 291 | 285 | return 0; |
|---|
| 292 | 286 | |
|---|
| 293 | 287 | crtc_state = drm_atomic_get_existing_crtc_state(plane_state->state, |
|---|
| .. | .. |
|---|
| 446 | 440 | |
|---|
| 447 | 441 | static void zx_plane_destroy(struct drm_plane *plane) |
|---|
| 448 | 442 | { |
|---|
| 449 | | - drm_plane_helper_disable(plane, NULL); |
|---|
| 450 | 443 | drm_plane_cleanup(plane); |
|---|
| 451 | 444 | } |
|---|
| 452 | 445 | |
|---|