2 * Copyright (C) 2015 Broadcom
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.
10 #include "drm_gem_cma_helper.h"
13 struct drm_device *dev;
15 struct vc4_hdmi *hdmi;
17 struct vc4_crtc *crtc[3];
19 struct drm_fbdev_cma *fbdev;
22 static inline struct vc4_dev *
23 to_vc4_dev(struct drm_device *dev)
25 return (struct vc4_dev *)dev->dev_private;
29 struct drm_gem_cma_object base;
32 static inline struct vc4_bo *
33 to_vc4_bo(struct drm_gem_object *bo)
35 return (struct vc4_bo *)bo;
39 struct platform_device *pdev;
45 struct drm_plane base;
48 static inline struct vc4_plane *
49 to_vc4_plane(struct drm_plane *plane)
51 return (struct vc4_plane *)plane;
54 enum vc4_encoder_type {
55 VC4_ENCODER_TYPE_HDMI,
57 VC4_ENCODER_TYPE_DSI0,
58 VC4_ENCODER_TYPE_DSI1,
64 struct drm_encoder base;
65 enum vc4_encoder_type type;
69 static inline struct vc4_encoder *
70 to_vc4_encoder(struct drm_encoder *encoder)
72 return container_of(encoder, struct vc4_encoder, base);
75 #define HVS_READ(offset) readl(vc4->hvs->regs + offset)
76 #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
79 * _wait_for - magic (register) wait macro
81 * Does the right thing for modeset paths when run under kdgb or similar atomic
82 * contexts. Note that it's important that we check the condition again after
83 * having timed out, since the timeout could be due to preemption or similar and
84 * we've never had a chance to check the condition before the timeout.
86 #define _wait_for(COND, MS, W) ({ \
87 unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1; \
90 if (time_after(jiffies, timeout__)) { \
95 if (W && drm_can_sleep()) { \
104 #define wait_for(COND, MS) _wait_for(COND, MS, 1)
107 void vc4_free_object(struct drm_gem_object *gem_obj);
108 struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size);
109 int vc4_dumb_create(struct drm_file *file_priv,
110 struct drm_device *dev,
111 struct drm_mode_create_dumb *args);
112 struct dma_buf *vc4_prime_export(struct drm_device *dev,
113 struct drm_gem_object *obj, int flags);
116 extern struct platform_driver vc4_crtc_driver;
117 int vc4_enable_vblank(struct drm_device *dev, unsigned int crtc_id);
118 void vc4_disable_vblank(struct drm_device *dev, unsigned int crtc_id);
119 void vc4_cancel_page_flip(struct drm_crtc *crtc, struct drm_file *file);
120 int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
123 int vc4_debugfs_init(struct drm_minor *minor);
124 void vc4_debugfs_cleanup(struct drm_minor *minor);
127 void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
130 extern struct platform_driver vc4_hdmi_driver;
131 int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);
134 extern struct platform_driver vc4_hvs_driver;
135 void vc4_hvs_dump_state(struct drm_device *dev);
136 int vc4_hvs_debugfs_regs(struct seq_file *m, void *unused);
139 int vc4_kms_load(struct drm_device *dev);
142 struct drm_plane *vc4_plane_init(struct drm_device *dev,
143 enum drm_plane_type type);
144 u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
145 u32 vc4_plane_dlist_size(struct drm_plane_state *state);