1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2023 Loongson Technology Corporation Limited
6 #include <linux/delay.h>
8 #include <drm/drm_atomic.h>
9 #include <drm/drm_atomic_helper.h>
10 #include <drm/drm_framebuffer.h>
11 #include <drm/drm_gem_atomic_helper.h>
14 #include "lsdc_regs.h"
17 static const u32 lsdc_primary_formats[] = {
21 static const u32 lsdc_cursor_formats[] = {
25 static const u64 lsdc_fb_format_modifiers[] = {
26 DRM_FORMAT_MOD_LINEAR,
27 DRM_FORMAT_MOD_INVALID
30 static unsigned int lsdc_get_fb_offset(struct drm_framebuffer *fb,
31 struct drm_plane_state *state)
33 unsigned int offset = fb->offsets[0];
35 offset += fb->format->cpp[0] * (state->src_x >> 16);
36 offset += fb->pitches[0] * (state->src_y >> 16);
41 static u64 lsdc_fb_base_addr(struct drm_framebuffer *fb)
43 struct lsdc_device *ldev = to_lsdc(fb->dev);
44 struct lsdc_bo *lbo = gem_to_lsdc_bo(fb->obj[0]);
46 return lsdc_bo_gpu_offset(lbo) + ldev->vram_base;
49 static int lsdc_primary_atomic_check(struct drm_plane *plane,
50 struct drm_atomic_state *state)
52 struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
53 struct drm_crtc *crtc = new_plane_state->crtc;
54 struct drm_crtc_state *new_crtc_state;
59 new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
61 return drm_atomic_helper_check_plane_state(new_plane_state,
68 static void lsdc_primary_atomic_update(struct drm_plane *plane,
69 struct drm_atomic_state *state)
71 struct lsdc_primary *primary = to_lsdc_primary(plane);
72 const struct lsdc_primary_plane_ops *ops = primary->ops;
73 struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
74 struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
75 struct drm_framebuffer *new_fb = new_plane_state->fb;
76 struct drm_framebuffer *old_fb = old_plane_state->fb;
77 u64 fb_addr = lsdc_fb_base_addr(new_fb);
79 fb_addr += lsdc_get_fb_offset(new_fb, new_plane_state);
81 ops->update_fb_addr(primary, fb_addr);
82 ops->update_fb_stride(primary, new_fb->pitches[0]);
84 if (!old_fb || old_fb->format != new_fb->format)
85 ops->update_fb_format(primary, new_fb->format);
88 static void lsdc_primary_atomic_disable(struct drm_plane *plane,
89 struct drm_atomic_state *state)
92 * Do nothing, just prevent call into atomic_update().
93 * Writing the format as LSDC_PF_NONE can disable the primary,
94 * But it seems not necessary...
96 drm_dbg(plane->dev, "%s disabled\n", plane->name);
99 static int lsdc_plane_prepare_fb(struct drm_plane *plane,
100 struct drm_plane_state *new_state)
102 struct drm_framebuffer *fb = new_state->fb;
110 lbo = gem_to_lsdc_bo(fb->obj[0]);
112 ret = lsdc_bo_reserve(lbo);
114 drm_err(plane->dev, "bo %p reserve failed\n", lbo);
118 ret = lsdc_bo_pin(lbo, LSDC_GEM_DOMAIN_VRAM, &gpu_vaddr);
120 lsdc_bo_unreserve(lbo);
123 drm_err(plane->dev, "bo %p pin failed\n", lbo);
129 if (plane->type != DRM_PLANE_TYPE_CURSOR)
131 "%s[%p] pin at 0x%llx, bo size: %zu\n",
132 plane->name, lbo, gpu_vaddr, lsdc_bo_size(lbo));
134 return drm_gem_plane_helper_prepare_fb(plane, new_state);
137 static void lsdc_plane_cleanup_fb(struct drm_plane *plane,
138 struct drm_plane_state *old_state)
140 struct drm_framebuffer *fb = old_state->fb;
147 lbo = gem_to_lsdc_bo(fb->obj[0]);
149 ret = lsdc_bo_reserve(lbo);
151 drm_err(plane->dev, "%p reserve failed\n", lbo);
157 lsdc_bo_unreserve(lbo);
161 if (plane->type != DRM_PLANE_TYPE_CURSOR)
162 drm_dbg(plane->dev, "%s unpin\n", plane->name);
165 static const struct drm_plane_helper_funcs lsdc_primary_helper_funcs = {
166 .prepare_fb = lsdc_plane_prepare_fb,
167 .cleanup_fb = lsdc_plane_cleanup_fb,
168 .atomic_check = lsdc_primary_atomic_check,
169 .atomic_update = lsdc_primary_atomic_update,
170 .atomic_disable = lsdc_primary_atomic_disable,
173 static int lsdc_cursor_plane_atomic_async_check(struct drm_plane *plane,
174 struct drm_atomic_state *state)
176 struct drm_plane_state *new_state;
177 struct drm_crtc_state *crtc_state;
179 new_state = drm_atomic_get_new_plane_state(state, plane);
181 if (!plane->state || !plane->state->fb) {
182 drm_dbg(plane->dev, "%s: state is NULL\n", plane->name);
186 if (new_state->crtc_w != new_state->crtc_h) {
187 drm_dbg(plane->dev, "unsupported cursor size: %ux%u\n",
188 new_state->crtc_w, new_state->crtc_h);
192 if (new_state->crtc_w != 64 && new_state->crtc_w != 32) {
193 drm_dbg(plane->dev, "unsupported cursor size: %ux%u\n",
194 new_state->crtc_w, new_state->crtc_h);
198 crtc_state = drm_atomic_get_existing_crtc_state(state, new_state->crtc);
199 if (!crtc_state->active)
202 if (plane->state->crtc != new_state->crtc ||
203 plane->state->src_w != new_state->src_w ||
204 plane->state->src_h != new_state->src_h ||
205 plane->state->crtc_w != new_state->crtc_w ||
206 plane->state->crtc_h != new_state->crtc_h)
209 if (new_state->visible != plane->state->visible)
212 return drm_atomic_helper_check_plane_state(plane->state,
214 DRM_PLANE_NO_SCALING,
215 DRM_PLANE_NO_SCALING,
219 static void lsdc_cursor_plane_atomic_async_update(struct drm_plane *plane,
220 struct drm_atomic_state *state)
222 struct lsdc_cursor *cursor = to_lsdc_cursor(plane);
223 const struct lsdc_cursor_plane_ops *ops = cursor->ops;
224 struct drm_framebuffer *old_fb = plane->state->fb;
225 struct drm_framebuffer *new_fb;
226 struct drm_plane_state *new_state;
228 new_state = drm_atomic_get_new_plane_state(state, plane);
230 new_fb = plane->state->fb;
232 plane->state->crtc_x = new_state->crtc_x;
233 plane->state->crtc_y = new_state->crtc_y;
234 plane->state->crtc_h = new_state->crtc_h;
235 plane->state->crtc_w = new_state->crtc_w;
236 plane->state->src_x = new_state->src_x;
237 plane->state->src_y = new_state->src_y;
238 plane->state->src_h = new_state->src_h;
239 plane->state->src_w = new_state->src_w;
240 swap(plane->state->fb, new_state->fb);
242 if (new_state->visible) {
243 enum lsdc_cursor_size cursor_size;
245 switch (new_state->crtc_w) {
247 cursor_size = CURSOR_SIZE_64X64;
250 cursor_size = CURSOR_SIZE_32X32;
253 cursor_size = CURSOR_SIZE_32X32;
257 ops->update_position(cursor, new_state->crtc_x, new_state->crtc_y);
259 ops->update_cfg(cursor, cursor_size, CURSOR_FORMAT_ARGB8888);
261 if (!old_fb || old_fb != new_fb)
262 ops->update_bo_addr(cursor, lsdc_fb_base_addr(new_fb));
266 /* ls7a1000 cursor plane helpers */
268 static int ls7a1000_cursor_plane_atomic_check(struct drm_plane *plane,
269 struct drm_atomic_state *state)
271 struct drm_plane_state *new_plane_state;
272 struct drm_crtc_state *new_crtc_state;
273 struct drm_crtc *crtc;
275 new_plane_state = drm_atomic_get_new_plane_state(state, plane);
277 crtc = new_plane_state->crtc;
279 drm_dbg(plane->dev, "%s is not bind to a crtc\n", plane->name);
283 if (new_plane_state->crtc_w != 32 || new_plane_state->crtc_h != 32) {
284 drm_dbg(plane->dev, "unsupported cursor size: %ux%u\n",
285 new_plane_state->crtc_w, new_plane_state->crtc_h);
289 new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
291 return drm_atomic_helper_check_plane_state(new_plane_state,
293 DRM_PLANE_NO_SCALING,
294 DRM_PLANE_NO_SCALING,
298 static void ls7a1000_cursor_plane_atomic_update(struct drm_plane *plane,
299 struct drm_atomic_state *state)
301 struct lsdc_cursor *cursor = to_lsdc_cursor(plane);
302 struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
303 struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
304 struct drm_framebuffer *new_fb = new_plane_state->fb;
305 struct drm_framebuffer *old_fb = old_plane_state->fb;
306 const struct lsdc_cursor_plane_ops *ops = cursor->ops;
307 u64 addr = lsdc_fb_base_addr(new_fb);
309 if (!new_plane_state->visible)
312 ops->update_position(cursor, new_plane_state->crtc_x, new_plane_state->crtc_y);
314 if (!old_fb || old_fb != new_fb)
315 ops->update_bo_addr(cursor, addr);
317 ops->update_cfg(cursor, CURSOR_SIZE_32X32, CURSOR_FORMAT_ARGB8888);
320 static void ls7a1000_cursor_plane_atomic_disable(struct drm_plane *plane,
321 struct drm_atomic_state *state)
323 struct lsdc_cursor *cursor = to_lsdc_cursor(plane);
324 const struct lsdc_cursor_plane_ops *ops = cursor->ops;
326 ops->update_cfg(cursor, CURSOR_SIZE_32X32, CURSOR_FORMAT_DISABLE);
329 static const struct drm_plane_helper_funcs ls7a1000_cursor_plane_helper_funcs = {
330 .prepare_fb = lsdc_plane_prepare_fb,
331 .cleanup_fb = lsdc_plane_cleanup_fb,
332 .atomic_check = ls7a1000_cursor_plane_atomic_check,
333 .atomic_update = ls7a1000_cursor_plane_atomic_update,
334 .atomic_disable = ls7a1000_cursor_plane_atomic_disable,
335 .atomic_async_check = lsdc_cursor_plane_atomic_async_check,
336 .atomic_async_update = lsdc_cursor_plane_atomic_async_update,
339 /* ls7a2000 cursor plane helpers */
341 static int ls7a2000_cursor_plane_atomic_check(struct drm_plane *plane,
342 struct drm_atomic_state *state)
344 struct drm_plane_state *new_plane_state;
345 struct drm_crtc_state *new_crtc_state;
346 struct drm_crtc *crtc;
348 new_plane_state = drm_atomic_get_new_plane_state(state, plane);
350 crtc = new_plane_state->crtc;
352 drm_dbg(plane->dev, "%s is not bind to a crtc\n", plane->name);
356 if (new_plane_state->crtc_w != new_plane_state->crtc_h) {
357 drm_dbg(plane->dev, "unsupported cursor size: %ux%u\n",
358 new_plane_state->crtc_w, new_plane_state->crtc_h);
362 if (new_plane_state->crtc_w != 64 && new_plane_state->crtc_w != 32) {
363 drm_dbg(plane->dev, "unsupported cursor size: %ux%u\n",
364 new_plane_state->crtc_w, new_plane_state->crtc_h);
368 new_crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
370 return drm_atomic_helper_check_plane_state(new_plane_state,
372 DRM_PLANE_NO_SCALING,
373 DRM_PLANE_NO_SCALING,
377 /* Update the format, size and location of the cursor */
379 static void ls7a2000_cursor_plane_atomic_update(struct drm_plane *plane,
380 struct drm_atomic_state *state)
382 struct lsdc_cursor *cursor = to_lsdc_cursor(plane);
383 struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane);
384 struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state, plane);
385 struct drm_framebuffer *new_fb = new_plane_state->fb;
386 struct drm_framebuffer *old_fb = old_plane_state->fb;
387 const struct lsdc_cursor_plane_ops *ops = cursor->ops;
388 enum lsdc_cursor_size cursor_size;
390 if (!new_plane_state->visible)
393 ops->update_position(cursor, new_plane_state->crtc_x, new_plane_state->crtc_y);
395 if (!old_fb || new_fb != old_fb) {
396 u64 addr = lsdc_fb_base_addr(new_fb);
398 ops->update_bo_addr(cursor, addr);
401 switch (new_plane_state->crtc_w) {
403 cursor_size = CURSOR_SIZE_64X64;
406 cursor_size = CURSOR_SIZE_32X32;
409 cursor_size = CURSOR_SIZE_64X64;
413 ops->update_cfg(cursor, cursor_size, CURSOR_FORMAT_ARGB8888);
416 static void ls7a2000_cursor_plane_atomic_disable(struct drm_plane *plane,
417 struct drm_atomic_state *state)
419 struct lsdc_cursor *cursor = to_lsdc_cursor(plane);
420 const struct lsdc_cursor_plane_ops *hw_ops = cursor->ops;
422 hw_ops->update_cfg(cursor, CURSOR_SIZE_64X64, CURSOR_FORMAT_DISABLE);
425 static const struct drm_plane_helper_funcs ls7a2000_cursor_plane_helper_funcs = {
426 .prepare_fb = lsdc_plane_prepare_fb,
427 .cleanup_fb = lsdc_plane_cleanup_fb,
428 .atomic_check = ls7a2000_cursor_plane_atomic_check,
429 .atomic_update = ls7a2000_cursor_plane_atomic_update,
430 .atomic_disable = ls7a2000_cursor_plane_atomic_disable,
431 .atomic_async_check = lsdc_cursor_plane_atomic_async_check,
432 .atomic_async_update = lsdc_cursor_plane_atomic_async_update,
435 static void lsdc_plane_atomic_print_state(struct drm_printer *p,
436 const struct drm_plane_state *state)
438 struct drm_framebuffer *fb = state->fb;
444 addr = lsdc_fb_base_addr(fb);
446 drm_printf(p, "\tdma addr=%llx\n", addr);
449 static const struct drm_plane_funcs lsdc_plane_funcs = {
450 .update_plane = drm_atomic_helper_update_plane,
451 .disable_plane = drm_atomic_helper_disable_plane,
452 .destroy = drm_plane_cleanup,
453 .reset = drm_atomic_helper_plane_reset,
454 .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
455 .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
456 .atomic_print_state = lsdc_plane_atomic_print_state,
459 /* Primary plane 0 hardware related ops */
461 static void lsdc_primary0_update_fb_addr(struct lsdc_primary *primary, u64 addr)
463 struct lsdc_device *ldev = primary->ldev;
467 /* 40-bit width physical address bus */
468 lo = addr & 0xFFFFFFFF;
469 hi = (addr >> 32) & 0xFF;
471 status = lsdc_rreg32(ldev, LSDC_CRTC0_CFG_REG);
472 if (status & FB_REG_IN_USING) {
473 lsdc_wreg32(ldev, LSDC_CRTC0_FB1_ADDR_LO_REG, lo);
474 lsdc_wreg32(ldev, LSDC_CRTC0_FB1_ADDR_HI_REG, hi);
476 lsdc_wreg32(ldev, LSDC_CRTC0_FB0_ADDR_LO_REG, lo);
477 lsdc_wreg32(ldev, LSDC_CRTC0_FB0_ADDR_HI_REG, hi);
481 static void lsdc_primary0_update_fb_stride(struct lsdc_primary *primary, u32 stride)
483 struct lsdc_device *ldev = primary->ldev;
485 lsdc_wreg32(ldev, LSDC_CRTC0_STRIDE_REG, stride);
488 static void lsdc_primary0_update_fb_format(struct lsdc_primary *primary,
489 const struct drm_format_info *format)
491 struct lsdc_device *ldev = primary->ldev;
494 status = lsdc_rreg32(ldev, LSDC_CRTC0_CFG_REG);
497 * TODO: add RGB565 support, only support XRBG8888 at present
499 status &= ~CFG_PIX_FMT_MASK;
500 status |= LSDC_PF_XRGB8888;
502 lsdc_wreg32(ldev, LSDC_CRTC0_CFG_REG, status);
505 /* Primary plane 1 hardware related ops */
507 static void lsdc_primary1_update_fb_addr(struct lsdc_primary *primary, u64 addr)
509 struct lsdc_device *ldev = primary->ldev;
513 /* 40-bit width physical address bus */
514 lo = addr & 0xFFFFFFFF;
515 hi = (addr >> 32) & 0xFF;
517 status = lsdc_rreg32(ldev, LSDC_CRTC1_CFG_REG);
518 if (status & FB_REG_IN_USING) {
519 lsdc_wreg32(ldev, LSDC_CRTC1_FB1_ADDR_LO_REG, lo);
520 lsdc_wreg32(ldev, LSDC_CRTC1_FB1_ADDR_HI_REG, hi);
522 lsdc_wreg32(ldev, LSDC_CRTC1_FB0_ADDR_LO_REG, lo);
523 lsdc_wreg32(ldev, LSDC_CRTC1_FB0_ADDR_HI_REG, hi);
527 static void lsdc_primary1_update_fb_stride(struct lsdc_primary *primary, u32 stride)
529 struct lsdc_device *ldev = primary->ldev;
531 lsdc_wreg32(ldev, LSDC_CRTC1_STRIDE_REG, stride);
534 static void lsdc_primary1_update_fb_format(struct lsdc_primary *primary,
535 const struct drm_format_info *format)
537 struct lsdc_device *ldev = primary->ldev;
540 status = lsdc_rreg32(ldev, LSDC_CRTC1_CFG_REG);
543 * TODO: add RGB565 support, only support XRBG8888 at present
545 status &= ~CFG_PIX_FMT_MASK;
546 status |= LSDC_PF_XRGB8888;
548 lsdc_wreg32(ldev, LSDC_CRTC1_CFG_REG, status);
551 static const struct lsdc_primary_plane_ops lsdc_primary_plane_hw_ops[2] = {
553 .update_fb_addr = lsdc_primary0_update_fb_addr,
554 .update_fb_stride = lsdc_primary0_update_fb_stride,
555 .update_fb_format = lsdc_primary0_update_fb_format,
558 .update_fb_addr = lsdc_primary1_update_fb_addr,
559 .update_fb_stride = lsdc_primary1_update_fb_stride,
560 .update_fb_format = lsdc_primary1_update_fb_format,
565 * Update location, format, enable and disable state of the cursor,
566 * For those who have two hardware cursor, let cursor 0 is attach to CRTC-0,
567 * cursor 1 is attach to CRTC-1. Compositing the primary plane and cursor
568 * plane is automatically done by hardware, the cursor is alway on the top of
569 * the primary plane. In other word, z-order is fixed in hardware and cannot
570 * be changed. For those old DC who has only one hardware cursor, we made it
571 * shared by the two screen, this works on extend screen mode.
574 /* cursor plane 0 (for pipe 0) related hardware ops */
576 static void lsdc_cursor0_update_bo_addr(struct lsdc_cursor *cursor, u64 addr)
578 struct lsdc_device *ldev = cursor->ldev;
580 /* 40-bit width physical address bus */
581 lsdc_wreg32(ldev, LSDC_CURSOR0_ADDR_HI_REG, (addr >> 32) & 0xFF);
582 lsdc_wreg32(ldev, LSDC_CURSOR0_ADDR_LO_REG, addr);
585 static void lsdc_cursor0_update_position(struct lsdc_cursor *cursor, int x, int y)
587 struct lsdc_device *ldev = cursor->ldev;
595 lsdc_wreg32(ldev, LSDC_CURSOR0_POSITION_REG, (y << 16) | x);
598 static void lsdc_cursor0_update_cfg(struct lsdc_cursor *cursor,
599 enum lsdc_cursor_size cursor_size,
600 enum lsdc_cursor_format fmt)
602 struct lsdc_device *ldev = cursor->ldev;
605 cfg = CURSOR_ON_CRTC0 << CURSOR_LOCATION_SHIFT |
606 cursor_size << CURSOR_SIZE_SHIFT |
607 fmt << CURSOR_FORMAT_SHIFT;
609 lsdc_wreg32(ldev, LSDC_CURSOR0_CFG_REG, cfg);
612 /* cursor plane 1 (for pipe 1) related hardware ops */
614 static void lsdc_cursor1_update_bo_addr(struct lsdc_cursor *cursor, u64 addr)
616 struct lsdc_device *ldev = cursor->ldev;
618 /* 40-bit width physical address bus */
619 lsdc_wreg32(ldev, LSDC_CURSOR1_ADDR_HI_REG, (addr >> 32) & 0xFF);
620 lsdc_wreg32(ldev, LSDC_CURSOR1_ADDR_LO_REG, addr);
623 static void lsdc_cursor1_update_position(struct lsdc_cursor *cursor, int x, int y)
625 struct lsdc_device *ldev = cursor->ldev;
633 lsdc_wreg32(ldev, LSDC_CURSOR1_POSITION_REG, (y << 16) | x);
636 static void lsdc_cursor1_update_cfg(struct lsdc_cursor *cursor,
637 enum lsdc_cursor_size cursor_size,
638 enum lsdc_cursor_format fmt)
640 struct lsdc_device *ldev = cursor->ldev;
643 cfg = CURSOR_ON_CRTC1 << CURSOR_LOCATION_SHIFT |
644 cursor_size << CURSOR_SIZE_SHIFT |
645 fmt << CURSOR_FORMAT_SHIFT;
647 lsdc_wreg32(ldev, LSDC_CURSOR1_CFG_REG, cfg);
650 /* The hardware cursors become normal since ls7a2000/ls2k2000 */
652 static const struct lsdc_cursor_plane_ops ls7a2000_cursor_hw_ops[2] = {
654 .update_bo_addr = lsdc_cursor0_update_bo_addr,
655 .update_cfg = lsdc_cursor0_update_cfg,
656 .update_position = lsdc_cursor0_update_position,
659 .update_bo_addr = lsdc_cursor1_update_bo_addr,
660 .update_cfg = lsdc_cursor1_update_cfg,
661 .update_position = lsdc_cursor1_update_position,
665 /* Quirks for cursor 1, only for old loongson display controller */
667 static void lsdc_cursor1_update_bo_addr_quirk(struct lsdc_cursor *cursor, u64 addr)
669 struct lsdc_device *ldev = cursor->ldev;
671 /* 40-bit width physical address bus */
672 lsdc_wreg32(ldev, LSDC_CURSOR0_ADDR_HI_REG, (addr >> 32) & 0xFF);
673 lsdc_wreg32(ldev, LSDC_CURSOR0_ADDR_LO_REG, addr);
676 static void lsdc_cursor1_update_position_quirk(struct lsdc_cursor *cursor, int x, int y)
678 struct lsdc_device *ldev = cursor->ldev;
686 lsdc_wreg32(ldev, LSDC_CURSOR0_POSITION_REG, (y << 16) | x);
689 static void lsdc_cursor1_update_cfg_quirk(struct lsdc_cursor *cursor,
690 enum lsdc_cursor_size cursor_size,
691 enum lsdc_cursor_format fmt)
693 struct lsdc_device *ldev = cursor->ldev;
696 cfg = CURSOR_ON_CRTC1 << CURSOR_LOCATION_SHIFT |
697 cursor_size << CURSOR_SIZE_SHIFT |
698 fmt << CURSOR_FORMAT_SHIFT;
700 lsdc_wreg32(ldev, LSDC_CURSOR0_CFG_REG, cfg);
704 * The unforgiving LS7A1000/LS2K1000 has only one hardware cursors plane
706 static const struct lsdc_cursor_plane_ops ls7a1000_cursor_hw_ops[2] = {
708 .update_bo_addr = lsdc_cursor0_update_bo_addr,
709 .update_cfg = lsdc_cursor0_update_cfg,
710 .update_position = lsdc_cursor0_update_position,
713 .update_bo_addr = lsdc_cursor1_update_bo_addr_quirk,
714 .update_cfg = lsdc_cursor1_update_cfg_quirk,
715 .update_position = lsdc_cursor1_update_position_quirk,
719 int lsdc_primary_plane_init(struct drm_device *ddev,
720 struct drm_plane *plane,
723 struct lsdc_primary *primary = to_lsdc_primary(plane);
726 ret = drm_universal_plane_init(ddev, plane, 1 << index,
728 lsdc_primary_formats,
729 ARRAY_SIZE(lsdc_primary_formats),
730 lsdc_fb_format_modifiers,
731 DRM_PLANE_TYPE_PRIMARY,
732 "ls-primary-plane-%u", index);
736 drm_plane_helper_add(plane, &lsdc_primary_helper_funcs);
738 primary->ldev = to_lsdc(ddev);
739 primary->ops = &lsdc_primary_plane_hw_ops[index];
744 int ls7a1000_cursor_plane_init(struct drm_device *ddev,
745 struct drm_plane *plane,
748 struct lsdc_cursor *cursor = to_lsdc_cursor(plane);
751 ret = drm_universal_plane_init(ddev, plane, 1 << index,
754 ARRAY_SIZE(lsdc_cursor_formats),
755 lsdc_fb_format_modifiers,
756 DRM_PLANE_TYPE_CURSOR,
757 "ls-cursor-plane-%u", index);
761 cursor->ldev = to_lsdc(ddev);
762 cursor->ops = &ls7a1000_cursor_hw_ops[index];
764 drm_plane_helper_add(plane, &ls7a1000_cursor_plane_helper_funcs);
769 int ls7a2000_cursor_plane_init(struct drm_device *ddev,
770 struct drm_plane *plane,
773 struct lsdc_cursor *cursor = to_lsdc_cursor(plane);
776 ret = drm_universal_plane_init(ddev, plane, 1 << index,
779 ARRAY_SIZE(lsdc_cursor_formats),
780 lsdc_fb_format_modifiers,
781 DRM_PLANE_TYPE_CURSOR,
782 "ls-cursor-plane-%u", index);
786 cursor->ldev = to_lsdc(ddev);
787 cursor->ops = &ls7a2000_cursor_hw_ops[index];
789 drm_plane_helper_add(plane, &ls7a2000_cursor_plane_helper_funcs);