Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Russell King |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
| 8 | #ifndef ARMADA_CRTC_H |
| 9 | #define ARMADA_CRTC_H |
| 10 | |
| 11 | struct armada_gem_object; |
| 12 | |
| 13 | struct armada_regs { |
| 14 | uint32_t offset; |
| 15 | uint32_t mask; |
| 16 | uint32_t val; |
| 17 | }; |
| 18 | |
| 19 | #define armada_reg_queue_mod(_r, _i, _v, _m, _o) \ |
| 20 | do { \ |
| 21 | struct armada_regs *__reg = _r; \ |
| 22 | __reg[_i].offset = _o; \ |
| 23 | __reg[_i].mask = ~(_m); \ |
| 24 | __reg[_i].val = _v; \ |
| 25 | _i++; \ |
| 26 | } while (0) |
| 27 | |
| 28 | #define armada_reg_queue_set(_r, _i, _v, _o) \ |
| 29 | armada_reg_queue_mod(_r, _i, _v, ~0, _o) |
| 30 | |
| 31 | #define armada_reg_queue_end(_r, _i) \ |
| 32 | armada_reg_queue_mod(_r, _i, 0, 0, ~0) |
| 33 | |
Russell King | 4b5dda8 | 2015-08-06 16:37:18 +0100 | [diff] [blame] | 34 | struct armada_crtc; |
| 35 | struct armada_plane; |
Russell King | 42e62ba | 2014-04-22 15:24:03 +0100 | [diff] [blame] | 36 | struct armada_variant; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 37 | |
Russell King | 4b5dda8 | 2015-08-06 16:37:18 +0100 | [diff] [blame] | 38 | struct armada_plane_work { |
| 39 | void (*fn)(struct armada_crtc *, |
| 40 | struct armada_plane *, |
| 41 | struct armada_plane_work *); |
| 42 | }; |
| 43 | |
Russell King | 8be523d | 2016-08-16 22:09:08 +0100 | [diff] [blame] | 44 | struct armada_plane_state { |
| 45 | u32 src_hw; |
| 46 | u32 dst_hw; |
| 47 | u32 dst_yx; |
| 48 | u32 ctrl0; |
| 49 | }; |
| 50 | |
Russell King | 561f60b | 2015-07-15 18:11:24 +0100 | [diff] [blame] | 51 | struct armada_plane { |
| 52 | struct drm_plane base; |
Russell King | 5740d27 | 2015-07-15 18:11:25 +0100 | [diff] [blame] | 53 | wait_queue_head_t frame_wait; |
Russell King | 4b5dda8 | 2015-08-06 16:37:18 +0100 | [diff] [blame] | 54 | struct armada_plane_work *work; |
Russell King | 8be523d | 2016-08-16 22:09:08 +0100 | [diff] [blame] | 55 | struct armada_plane_state state; |
Russell King | 561f60b | 2015-07-15 18:11:24 +0100 | [diff] [blame] | 56 | }; |
| 57 | #define drm_to_armada_plane(p) container_of(p, struct armada_plane, base) |
| 58 | |
Russell King | 5740d27 | 2015-07-15 18:11:25 +0100 | [diff] [blame] | 59 | int armada_drm_plane_init(struct armada_plane *plane); |
Russell King | 4b5dda8 | 2015-08-06 16:37:18 +0100 | [diff] [blame] | 60 | int armada_drm_plane_work_queue(struct armada_crtc *dcrtc, |
| 61 | struct armada_plane *plane, struct armada_plane_work *work); |
| 62 | int armada_drm_plane_work_wait(struct armada_plane *plane, long timeout); |
Russell King | 4a8506d | 2015-08-07 09:33:05 +0100 | [diff] [blame] | 63 | struct armada_plane_work *armada_drm_plane_work_cancel( |
| 64 | struct armada_crtc *dcrtc, struct armada_plane *plane); |
Russell King | f0b2487 | 2016-08-16 22:09:11 +0100 | [diff] [blame] | 65 | void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb, |
| 66 | int x, int y); |
Russell King | 5740d27 | 2015-07-15 18:11:25 +0100 | [diff] [blame] | 67 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 68 | struct armada_crtc { |
| 69 | struct drm_crtc crtc; |
Russell King | 42e62ba | 2014-04-22 15:24:03 +0100 | [diff] [blame] | 70 | const struct armada_variant *variant; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 71 | unsigned num; |
| 72 | void __iomem *base; |
| 73 | struct clk *clk; |
Russell King | 3ecea26 | 2014-04-22 15:21:30 +0100 | [diff] [blame] | 74 | struct clk *extclk[2]; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 75 | struct { |
| 76 | uint32_t spu_v_h_total; |
| 77 | uint32_t spu_v_porch; |
| 78 | uint32_t spu_adv_reg; |
| 79 | } v[2]; |
| 80 | bool interlaced; |
Russell King | 662af0d | 2013-05-19 10:55:17 +0100 | [diff] [blame] | 81 | bool cursor_update; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 82 | uint8_t csc_yuv_mode; |
| 83 | uint8_t csc_rgb_mode; |
| 84 | |
| 85 | struct drm_plane *plane; |
| 86 | |
Russell King | 662af0d | 2013-05-19 10:55:17 +0100 | [diff] [blame] | 87 | struct armada_gem_object *cursor_obj; |
| 88 | int cursor_x; |
| 89 | int cursor_y; |
| 90 | uint32_t cursor_hw_pos; |
| 91 | uint32_t cursor_hw_sz; |
| 92 | uint32_t cursor_w; |
| 93 | uint32_t cursor_h; |
| 94 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 95 | int dpms; |
| 96 | uint32_t cfg_dumb_ctrl; |
| 97 | uint32_t dumb_ctrl; |
| 98 | uint32_t spu_iopad_ctrl; |
| 99 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 100 | spinlock_t irq_lock; |
| 101 | uint32_t irq_ena; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 102 | }; |
| 103 | #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc) |
| 104 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 105 | void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *); |
| 106 | |
Russell King | 5832680 | 2015-07-15 18:11:25 +0100 | [diff] [blame] | 107 | void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc, |
| 108 | struct drm_plane *plane); |
| 109 | |
Russell King | d8c9608 | 2014-04-22 11:10:15 +0100 | [diff] [blame] | 110 | extern struct platform_driver armada_lcd_platform_driver; |
| 111 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 112 | #endif |