blob: 3f0e70bb2e9c853916f18ed6668f8342c9db5783 [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;
35
36struct armada_crtc {
37 struct drm_crtc crtc;
38 unsigned num;
39 void __iomem *base;
40 struct clk *clk;
Russell King3ecea262014-04-22 15:21:30 +010041 struct clk *extclk[2];
Russell King96f60e32012-08-15 13:59:49 +010042 struct {
43 uint32_t spu_v_h_total;
44 uint32_t spu_v_porch;
45 uint32_t spu_adv_reg;
46 } v[2];
47 bool interlaced;
Russell King662af0d2013-05-19 10:55:17 +010048 bool cursor_update;
Russell King96f60e32012-08-15 13:59:49 +010049 uint8_t csc_yuv_mode;
50 uint8_t csc_rgb_mode;
51
52 struct drm_plane *plane;
53
Russell King662af0d2013-05-19 10:55:17 +010054 struct armada_gem_object *cursor_obj;
55 int cursor_x;
56 int cursor_y;
57 uint32_t cursor_hw_pos;
58 uint32_t cursor_hw_sz;
59 uint32_t cursor_w;
60 uint32_t cursor_h;
61
Russell King96f60e32012-08-15 13:59:49 +010062 int dpms;
63 uint32_t cfg_dumb_ctrl;
64 uint32_t dumb_ctrl;
65 uint32_t spu_iopad_ctrl;
66
67 wait_queue_head_t frame_wait;
68 struct armada_frame_work *frame_work;
69
70 spinlock_t irq_lock;
71 uint32_t irq_ena;
72 struct list_head vbl_list;
73};
74#define drm_to_armada_crtc(c) container_of(c, struct armada_crtc, crtc)
75
Russell Kingd0165402014-04-22 11:02:23 +010076int armada_drm_crtc_create(struct drm_device *, struct resource *, int);
Russell King96f60e32012-08-15 13:59:49 +010077void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
78void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
Russell King96f60e32012-08-15 13:59:49 +010079void armada_drm_crtc_disable_irq(struct armada_crtc *, u32);
80void armada_drm_crtc_enable_irq(struct armada_crtc *, u32);
81void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
82
83#endif