blob: 549b5f53826605fc045378dacd86908b2693750e [file] [log] [blame]
Russell King96f60e32012-08-15 13:59:49 +01001/*
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
11struct armada_gem_object;
12
13struct 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
34struct armada_frame_work;
Russell King42e62ba2014-04-22 15:24:03 +010035struct armada_variant;
Russell King96f60e32012-08-15 13:59:49 +010036
Russell King561f60b2015-07-15 18:11:24 +010037struct armada_plane {
38 struct drm_plane base;
39};
40#define drm_to_armada_plane(p) container_of(p, struct armada_plane, base)
41
Russell King96f60e32012-08-15 13:59:49 +010042struct armada_crtc {
43 struct drm_crtc crtc;
Russell King42e62ba2014-04-22 15:24:03 +010044 const struct armada_variant *variant;
Russell King96f60e32012-08-15 13:59:49 +010045 unsigned num;
46 void __iomem *base;
47 struct clk *clk;
Russell King3ecea262014-04-22 15:21:30 +010048 struct clk *extclk[2];
Russell King96f60e32012-08-15 13:59:49 +010049 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 King662af0d2013-05-19 10:55:17 +010055 bool cursor_update;
Russell King96f60e32012-08-15 13:59:49 +010056 uint8_t csc_yuv_mode;
57 uint8_t csc_rgb_mode;
58
59 struct drm_plane *plane;
60
Russell King662af0d2013-05-19 10:55:17 +010061 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 King96f60e32012-08-15 13:59:49 +010069 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 King7c8f7e12015-06-29 17:52:16 +010083struct armada_vbl_event {
84 struct list_head node;
85 void *data;
86 void (*fn)(struct armada_crtc *, void *);
87};
88
89void armada_drm_vbl_event_add(struct armada_crtc *,
90 struct armada_vbl_event *);
91void 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 King96f60e32012-08-15 13:59:49 +0100100void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
101void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
Russell King96f60e32012-08-15 13:59:49 +0100102void armada_drm_crtc_disable_irq(struct armada_crtc *, u32);
103void armada_drm_crtc_enable_irq(struct armada_crtc *, u32);
104void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
105
Russell Kingd8c96082014-04-22 11:10:15 +0100106extern struct platform_driver armada_lcd_platform_driver;
107
Russell King96f60e32012-08-15 13:59:49 +0100108#endif