1
2
3
4
5
6
7
8
9
10#ifndef HOST1X_DRM_H
11#define HOST1X_DRM_H 1
12
13#include <uapi/drm/tegra_drm.h>
14#include <linux/host1x.h>
15#include <linux/iova.h>
16#include <linux/of_gpio.h>
17
18#include <drm/drmP.h>
19#include <drm/drm_atomic.h>
20#include <drm/drm_crtc_helper.h>
21#include <drm/drm_edid.h>
22#include <drm/drm_encoder.h>
23#include <drm/drm_fb_helper.h>
24#include <drm/drm_fixed.h>
25
26#include "gem.h"
27#include "hub.h"
28#include "trace.h"
29
30struct reset_control;
31
32#ifdef CONFIG_DRM_FBDEV_EMULATION
33struct tegra_fbdev {
34 struct drm_fb_helper base;
35 struct drm_framebuffer *fb;
36};
37#endif
38
39struct tegra_drm {
40 struct drm_device *drm;
41
42 struct iommu_domain *domain;
43 struct iommu_group *group;
44 struct mutex mm_lock;
45 struct drm_mm mm;
46
47 struct {
48 struct iova_domain domain;
49 unsigned long shift;
50 unsigned long limit;
51 } carveout;
52
53 struct mutex clients_lock;
54 struct list_head clients;
55
56#ifdef CONFIG_DRM_FBDEV_EMULATION
57 struct tegra_fbdev *fbdev;
58#endif
59
60 unsigned int pitch_align;
61
62 struct tegra_display_hub *hub;
63
64 struct drm_atomic_state *state;
65};
66
67struct tegra_drm_client;
68
69struct tegra_drm_context {
70 struct tegra_drm_client *client;
71 struct host1x_channel *channel;
72 unsigned int id;
73};
74
75struct tegra_drm_client_ops {
76 int (*open_channel)(struct tegra_drm_client *client,
77 struct tegra_drm_context *context);
78 void (*close_channel)(struct tegra_drm_context *context);
79 int (*is_addr_reg)(struct device *dev, u32 class, u32 offset);
80 int (*is_valid_class)(u32 class);
81 int (*submit)(struct tegra_drm_context *context,
82 struct drm_tegra_submit *args, struct drm_device *drm,
83 struct drm_file *file);
84};
85
86int tegra_drm_submit(struct tegra_drm_context *context,
87 struct drm_tegra_submit *args, struct drm_device *drm,
88 struct drm_file *file);
89
90struct tegra_drm_client {
91 struct host1x_client base;
92 struct list_head list;
93
94 unsigned int version;
95 const struct tegra_drm_client_ops *ops;
96};
97
98static inline struct tegra_drm_client *
99host1x_to_drm_client(struct host1x_client *client)
100{
101 return container_of(client, struct tegra_drm_client, base);
102}
103
104int tegra_drm_register_client(struct tegra_drm *tegra,
105 struct tegra_drm_client *client);
106int tegra_drm_unregister_client(struct tegra_drm *tegra,
107 struct tegra_drm_client *client);
108struct iommu_group *host1x_client_iommu_attach(struct host1x_client *client,
109 bool shared);
110void host1x_client_iommu_detach(struct host1x_client *client,
111 struct iommu_group *group);
112
113int tegra_drm_init(struct tegra_drm *tegra, struct drm_device *drm);
114int tegra_drm_exit(struct tegra_drm *tegra);
115
116void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *iova);
117void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt,
118 dma_addr_t iova);
119
120struct cec_notifier;
121
122struct tegra_output {
123 struct device_node *of_node;
124 struct device *dev;
125
126 struct drm_panel *panel;
127 struct i2c_adapter *ddc;
128 const struct edid *edid;
129 struct cec_notifier *notifier;
130 unsigned int hpd_irq;
131 int hpd_gpio;
132 enum of_gpio_flags hpd_gpio_flags;
133
134 struct drm_encoder encoder;
135 struct drm_connector connector;
136};
137
138static inline struct tegra_output *encoder_to_output(struct drm_encoder *e)
139{
140 return container_of(e, struct tegra_output, encoder);
141}
142
143static inline struct tegra_output *connector_to_output(struct drm_connector *c)
144{
145 return container_of(c, struct tegra_output, connector);
146}
147
148
149int tegra_output_probe(struct tegra_output *output);
150void tegra_output_remove(struct tegra_output *output);
151int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
152void tegra_output_exit(struct tegra_output *output);
153void tegra_output_find_possible_crtcs(struct tegra_output *output,
154 struct drm_device *drm);
155
156int tegra_output_connector_get_modes(struct drm_connector *connector);
157enum drm_connector_status
158tegra_output_connector_detect(struct drm_connector *connector, bool force);
159void tegra_output_connector_destroy(struct drm_connector *connector);
160
161void tegra_output_encoder_destroy(struct drm_encoder *encoder);
162
163
164struct drm_dp_link;
165
166struct drm_dp_aux *drm_dp_aux_find_by_of_node(struct device_node *np);
167enum drm_connector_status drm_dp_aux_detect(struct drm_dp_aux *aux);
168int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output);
169int drm_dp_aux_detach(struct drm_dp_aux *aux);
170int drm_dp_aux_enable(struct drm_dp_aux *aux);
171int drm_dp_aux_disable(struct drm_dp_aux *aux);
172int drm_dp_aux_prepare(struct drm_dp_aux *aux, u8 encoding);
173int drm_dp_aux_train(struct drm_dp_aux *aux, struct drm_dp_link *link,
174 u8 pattern);
175
176
177struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
178 unsigned int index);
179bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
180int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
181 struct tegra_bo_tiling *tiling);
182struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
183 struct drm_file *file,
184 const struct drm_mode_fb_cmd2 *cmd);
185int tegra_drm_fb_prepare(struct drm_device *drm);
186void tegra_drm_fb_free(struct drm_device *drm);
187int tegra_drm_fb_init(struct drm_device *drm);
188void tegra_drm_fb_exit(struct drm_device *drm);
189void tegra_drm_fb_suspend(struct drm_device *drm);
190void tegra_drm_fb_resume(struct drm_device *drm);
191
192extern struct platform_driver tegra_display_hub_driver;
193extern struct platform_driver tegra_dc_driver;
194extern struct platform_driver tegra_hdmi_driver;
195extern struct platform_driver tegra_dsi_driver;
196extern struct platform_driver tegra_dpaux_driver;
197extern struct platform_driver tegra_sor_driver;
198extern struct platform_driver tegra_gr2d_driver;
199extern struct platform_driver tegra_gr3d_driver;
200extern struct platform_driver tegra_vic_driver;
201
202#endif
203