blob: b064879ecdbd1073a379dbb438854094cdd30f80 [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_DRM_H
9#define ARMADA_DRM_H
10
11#include <linux/kfifo.h>
12#include <linux/io.h>
13#include <linux/workqueue.h>
14#include <drm/drmP.h>
15
16struct armada_crtc;
17struct armada_gem_object;
18struct clk;
19struct drm_fb_helper;
20
21static inline void
22armada_updatel(uint32_t val, uint32_t mask, void __iomem *ptr)
23{
24 uint32_t ov, v;
25
26 ov = v = readl_relaxed(ptr);
27 v = (v & ~mask) | val;
28 if (ov != v)
29 writel_relaxed(v, ptr);
30}
31
32static inline uint32_t armada_pitch(uint32_t width, uint32_t bpp)
33{
34 uint32_t pitch = bpp != 4 ? width * ((bpp + 7) / 8) : width / 2;
35
36 /* 88AP510 spec recommends pitch be a multiple of 128 */
37 return ALIGN(pitch, 128);
38}
39
Russell King96f60e32012-08-15 13:59:49 +010040
41struct armada_private;
42
43struct armada_variant {
Russell King3ecea262014-04-22 15:21:30 +010044 bool has_spu_adv_reg;
Russell King662af0d2013-05-19 10:55:17 +010045 uint32_t spu_adv_reg;
Russell King42e62ba2014-04-22 15:24:03 +010046 int (*init)(struct armada_crtc *, struct device *);
47 int (*compute_clock)(struct armada_crtc *,
48 const struct drm_display_mode *,
49 uint32_t *);
Russell King96f60e32012-08-15 13:59:49 +010050};
51
52/* Variant ops */
53extern const struct armada_variant armada510_ops;
54
55struct armada_private {
Russell King917a3cb2016-11-01 20:05:47 +000056 struct drm_device drm;
Russell King96f60e32012-08-15 13:59:49 +010057 struct work_struct fb_unref_work;
58 DECLARE_KFIFO(fb_unref, struct drm_framebuffer *, 8);
59 struct drm_fb_helper *fbdev;
60 struct armada_crtc *dcrtc[2];
Daniel Vetter0b8ebea2015-11-24 10:00:36 +010061 struct drm_mm linear; /* protected by linear_lock */
62 struct mutex linear_lock;
Russell King96f60e32012-08-15 13:59:49 +010063 struct drm_property *csc_yuv_prop;
64 struct drm_property *csc_rgb_prop;
65 struct drm_property *colorkey_prop;
66 struct drm_property *colorkey_min_prop;
67 struct drm_property *colorkey_max_prop;
68 struct drm_property *colorkey_val_prop;
69 struct drm_property *colorkey_alpha_prop;
70 struct drm_property *colorkey_mode_prop;
71 struct drm_property *brightness_prop;
72 struct drm_property *contrast_prop;
73 struct drm_property *saturation_prop;
74#ifdef CONFIG_DEBUG_FS
75 struct dentry *de;
76#endif
77};
78
79void __armada_drm_queue_unref_work(struct drm_device *,
80 struct drm_framebuffer *);
81void armada_drm_queue_unref_work(struct drm_device *,
82 struct drm_framebuffer *);
83
84extern const struct drm_mode_config_funcs armada_drm_mode_config_funcs;
85
86int armada_fbdev_init(struct drm_device *);
Russell King2f5ae492013-10-27 15:26:33 +000087void armada_fbdev_lastclose(struct drm_device *);
Russell King96f60e32012-08-15 13:59:49 +010088void armada_fbdev_fini(struct drm_device *);
89
90int armada_overlay_plane_create(struct drm_device *, unsigned long);
91
92int armada_drm_debugfs_init(struct drm_minor *);
Russell King96f60e32012-08-15 13:59:49 +010093
94#endif