blob: 3ec5101e13f7a6bfb41077c38efd2dce3c523204 [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;
Russell King5740d272015-07-15 18:11:25 +010039 wait_queue_head_t frame_wait;
Russell King561f60b2015-07-15 18:11:24 +010040};
41#define drm_to_armada_plane(p) container_of(p, struct armada_plane, base)
42
Russell King5740d272015-07-15 18:11:25 +010043int armada_drm_plane_init(struct armada_plane *plane);
44
Russell King96f60e32012-08-15 13:59:49 +010045struct armada_crtc {
46 struct drm_crtc crtc;
Russell King42e62ba2014-04-22 15:24:03 +010047 const struct armada_variant *variant;
Russell King96f60e32012-08-15 13:59:49 +010048 unsigned num;
49 void __iomem *base;
50 struct clk *clk;
Russell King3ecea262014-04-22 15:21:30 +010051 struct clk *extclk[2];
Russell King96f60e32012-08-15 13:59:49 +010052 struct {
53 uint32_t spu_v_h_total;
54 uint32_t spu_v_porch;
55 uint32_t spu_adv_reg;
56 } v[2];
57 bool interlaced;
Russell King662af0d2013-05-19 10:55:17 +010058 bool cursor_update;
Russell King96f60e32012-08-15 13:59:49 +010059 uint8_t csc_yuv_mode;
60 uint8_t csc_rgb_mode;
61
62 struct drm_plane *plane;
63
Russell King662af0d2013-05-19 10:55:17 +010064 struct armada_gem_object *cursor_obj;
65 int cursor_x;
66 int cursor_y;
67 uint32_t cursor_hw_pos;
68 uint32_t cursor_hw_sz;
69 uint32_t cursor_w;
70 uint32_t cursor_h;
71
Russell King96f60e32012-08-15 13:59:49 +010072 int dpms;
73 uint32_t cfg_dumb_ctrl;
74 uint32_t dumb_ctrl;
75 uint32_t spu_iopad_ctrl;
76
Russell King96f60e32012-08-15 13:59:49 +010077 struct armada_frame_work *frame_work;
78
79 spinlock_t irq_lock;
80 uint32_t irq_ena;
81 struct list_head vbl_list;
82};
83#define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
84
Russell King7c8f7e12015-06-29 17:52:16 +010085struct armada_vbl_event {
86 struct list_head node;
87 void *data;
88 void (*fn)(struct armada_crtc *, void *);
89};
90
91void armada_drm_vbl_event_add(struct armada_crtc *,
92 struct armada_vbl_event *);
93void armada_drm_vbl_event_remove(struct armada_crtc *,
94 struct armada_vbl_event *);
95#define armada_drm_vbl_event_init(_e, _f, _d) do { \
96 struct armada_vbl_event *__e = _e; \
97 INIT_LIST_HEAD(&__e->node); \
98 __e->data = _d; \
99 __e->fn = _f; \
100} while (0)
101
Russell King96f60e32012-08-15 13:59:49 +0100102void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
103void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
Russell King96f60e32012-08-15 13:59:49 +0100104void armada_drm_crtc_disable_irq(struct armada_crtc *, u32);
105void armada_drm_crtc_enable_irq(struct armada_crtc *, u32);
106void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
107
Russell King58326802015-07-15 18:11:25 +0100108void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc,
109 struct drm_plane *plane);
110
Russell Kingd8c96082014-04-22 11:10:15 +0100111extern struct platform_driver armada_lcd_platform_driver;
112
Russell King96f60e32012-08-15 13:59:49 +0100113#endif