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 | |
| 34 | struct armada_frame_work; |
Russell King | 42e62ba | 2014-04-22 15:24:03 +0100 | [diff] [blame] | 35 | struct armada_variant; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 36 | |
Russell King | 561f60b | 2015-07-15 18:11:24 +0100 | [diff] [blame^] | 37 | struct armada_plane { |
| 38 | struct drm_plane base; |
| 39 | }; |
| 40 | #define drm_to_armada_plane(p) container_of(p, struct armada_plane, base) |
| 41 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 42 | struct armada_crtc { |
| 43 | struct drm_crtc crtc; |
Russell King | 42e62ba | 2014-04-22 15:24:03 +0100 | [diff] [blame] | 44 | const struct armada_variant *variant; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 45 | unsigned num; |
| 46 | void __iomem *base; |
| 47 | struct clk *clk; |
Russell King | 3ecea26 | 2014-04-22 15:21:30 +0100 | [diff] [blame] | 48 | struct clk *extclk[2]; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 49 | struct { |
| 50 | uint32_t spu_v_h_total; |
| 51 | uint32_t spu_v_porch; |
| 52 | uint32_t spu_adv_reg; |
| 53 | } v[2]; |
| 54 | bool interlaced; |
Russell King | 662af0d | 2013-05-19 10:55:17 +0100 | [diff] [blame] | 55 | bool cursor_update; |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 56 | uint8_t csc_yuv_mode; |
| 57 | uint8_t csc_rgb_mode; |
| 58 | |
| 59 | struct drm_plane *plane; |
| 60 | |
Russell King | 662af0d | 2013-05-19 10:55:17 +0100 | [diff] [blame] | 61 | struct armada_gem_object *cursor_obj; |
| 62 | int cursor_x; |
| 63 | int cursor_y; |
| 64 | uint32_t cursor_hw_pos; |
| 65 | uint32_t cursor_hw_sz; |
| 66 | uint32_t cursor_w; |
| 67 | uint32_t cursor_h; |
| 68 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 69 | int dpms; |
| 70 | uint32_t cfg_dumb_ctrl; |
| 71 | uint32_t dumb_ctrl; |
| 72 | uint32_t spu_iopad_ctrl; |
| 73 | |
| 74 | wait_queue_head_t frame_wait; |
| 75 | struct armada_frame_work *frame_work; |
| 76 | |
| 77 | spinlock_t irq_lock; |
| 78 | uint32_t irq_ena; |
| 79 | struct list_head vbl_list; |
| 80 | }; |
| 81 | #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc) |
| 82 | |
Russell King | 7c8f7e1 | 2015-06-29 17:52:16 +0100 | [diff] [blame] | 83 | struct armada_vbl_event { |
| 84 | struct list_head node; |
| 85 | void *data; |
| 86 | void (*fn)(struct armada_crtc *, void *); |
| 87 | }; |
| 88 | |
| 89 | void armada_drm_vbl_event_add(struct armada_crtc *, |
| 90 | struct armada_vbl_event *); |
| 91 | void armada_drm_vbl_event_remove(struct armada_crtc *, |
| 92 | struct armada_vbl_event *); |
| 93 | #define armada_drm_vbl_event_init(_e, _f, _d) do { \ |
| 94 | struct armada_vbl_event *__e = _e; \ |
| 95 | INIT_LIST_HEAD(&__e->node); \ |
| 96 | __e->data = _d; \ |
| 97 | __e->fn = _f; \ |
| 98 | } while (0) |
| 99 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 100 | void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int); |
| 101 | void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int); |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 102 | void armada_drm_crtc_disable_irq(struct armada_crtc *, u32); |
| 103 | void armada_drm_crtc_enable_irq(struct armada_crtc *, u32); |
| 104 | void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *); |
| 105 | |
Russell King | d8c9608 | 2014-04-22 11:10:15 +0100 | [diff] [blame] | 106 | extern struct platform_driver armada_lcd_platform_driver; |
| 107 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 108 | #endif |