Merge tag 'powerpc-4.15-7' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[sfrench/cifs-2.6.git] / drivers / gpu / drm / armada / armada_crtc.h
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_crtc;
35 struct armada_plane;
36 struct armada_variant;
37
38 struct armada_plane_work {
39         void                    (*fn)(struct armada_crtc *,
40                                       struct armada_plane *,
41                                       struct armada_plane_work *);
42 };
43
44 struct armada_plane_state {
45         u16 src_x;
46         u16 src_y;
47         u32 src_hw;
48         u32 dst_hw;
49         u32 dst_yx;
50         u32 ctrl0;
51 };
52
53 struct armada_plane {
54         struct drm_plane        base;
55         wait_queue_head_t       frame_wait;
56         struct armada_plane_work *work;
57         struct armada_plane_state state;
58 };
59 #define drm_to_armada_plane(p) container_of(p, struct armada_plane, base)
60
61 int armada_drm_plane_init(struct armada_plane *plane);
62 int armada_drm_plane_work_queue(struct armada_crtc *dcrtc,
63         struct armada_plane *plane, struct armada_plane_work *work);
64 int armada_drm_plane_work_wait(struct armada_plane *plane, long timeout);
65 struct armada_plane_work *armada_drm_plane_work_cancel(
66         struct armada_crtc *dcrtc, struct armada_plane *plane);
67 void armada_drm_plane_calc_addrs(u32 *addrs, struct drm_framebuffer *fb,
68         int x, int y);
69
70 struct armada_crtc {
71         struct drm_crtc         crtc;
72         const struct armada_variant *variant;
73         unsigned                num;
74         void __iomem            *base;
75         struct clk              *clk;
76         struct clk              *extclk[2];
77         struct {
78                 uint32_t        spu_v_h_total;
79                 uint32_t        spu_v_porch;
80                 uint32_t        spu_adv_reg;
81         } v[2];
82         bool                    interlaced;
83         bool                    cursor_update;
84         uint8_t                 csc_yuv_mode;
85         uint8_t                 csc_rgb_mode;
86
87         struct drm_plane        *plane;
88
89         struct armada_gem_object        *cursor_obj;
90         int                     cursor_x;
91         int                     cursor_y;
92         uint32_t                cursor_hw_pos;
93         uint32_t                cursor_hw_sz;
94         uint32_t                cursor_w;
95         uint32_t                cursor_h;
96
97         int                     dpms;
98         uint32_t                cfg_dumb_ctrl;
99         uint32_t                dumb_ctrl;
100         uint32_t                spu_iopad_ctrl;
101
102         spinlock_t              irq_lock;
103         uint32_t                irq_ena;
104 };
105 #define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
106
107 void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
108
109 void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc,
110         struct drm_plane *plane);
111
112 extern struct platform_driver armada_lcd_platform_driver;
113
114 #endif