2 * Copyright (C) 2012 Avionic Design GmbH
3 * Copyright (C) 2012-2013 NVIDIA CORPORATION. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
11 #define HOST1X_DRM_H 1
13 #include <uapi/drm/tegra_drm.h>
14 #include <linux/host1x.h>
15 #include <linux/iova.h>
16 #include <linux/of_gpio.h>
19 #include <drm/drm_crtc_helper.h>
20 #include <drm/drm_edid.h>
21 #include <drm/drm_encoder.h>
22 #include <drm/drm_fb_helper.h>
23 #include <drm/drm_fixed.h>
31 struct drm_framebuffer base
;
32 struct tegra_bo
**planes
;
33 unsigned int num_planes
;
36 #ifdef CONFIG_DRM_FBDEV_EMULATION
38 struct drm_fb_helper base
;
44 struct drm_device
*drm
;
46 struct iommu_domain
*domain
;
51 struct iova_domain domain
;
56 struct mutex clients_lock
;
57 struct list_head clients
;
59 #ifdef CONFIG_DRM_FBDEV_EMULATION
60 struct tegra_fbdev
*fbdev
;
63 unsigned int pitch_align
;
66 struct drm_atomic_state
*state
;
67 struct work_struct work
;
71 struct drm_atomic_state
*state
;
74 struct tegra_drm_client
;
76 struct tegra_drm_context
{
77 struct tegra_drm_client
*client
;
78 struct host1x_channel
*channel
;
82 struct tegra_drm_client_ops
{
83 int (*open_channel
)(struct tegra_drm_client
*client
,
84 struct tegra_drm_context
*context
);
85 void (*close_channel
)(struct tegra_drm_context
*context
);
86 int (*is_addr_reg
)(struct device
*dev
, u32
class, u32 offset
);
87 int (*is_valid_class
)(u32
class);
88 int (*submit
)(struct tegra_drm_context
*context
,
89 struct drm_tegra_submit
*args
, struct drm_device
*drm
,
90 struct drm_file
*file
);
93 int tegra_drm_submit(struct tegra_drm_context
*context
,
94 struct drm_tegra_submit
*args
, struct drm_device
*drm
,
95 struct drm_file
*file
);
97 struct tegra_drm_client
{
98 struct host1x_client base
;
99 struct list_head list
;
101 const struct tegra_drm_client_ops
*ops
;
104 static inline struct tegra_drm_client
*
105 host1x_to_drm_client(struct host1x_client
*client
)
107 return container_of(client
, struct tegra_drm_client
, base
);
110 int tegra_drm_register_client(struct tegra_drm
*tegra
,
111 struct tegra_drm_client
*client
);
112 int tegra_drm_unregister_client(struct tegra_drm
*tegra
,
113 struct tegra_drm_client
*client
);
115 int tegra_drm_init(struct tegra_drm
*tegra
, struct drm_device
*drm
);
116 int tegra_drm_exit(struct tegra_drm
*tegra
);
118 void *tegra_drm_alloc(struct tegra_drm
*tegra
, size_t size
, dma_addr_t
*iova
);
119 void tegra_drm_free(struct tegra_drm
*tegra
, size_t size
, void *virt
,
124 struct tegra_output
{
125 struct device_node
*of_node
;
128 struct drm_panel
*panel
;
129 struct i2c_adapter
*ddc
;
130 const struct edid
*edid
;
131 struct cec_notifier
*notifier
;
132 unsigned int hpd_irq
;
134 enum of_gpio_flags hpd_gpio_flags
;
136 struct drm_encoder encoder
;
137 struct drm_connector connector
;
140 static inline struct tegra_output
*encoder_to_output(struct drm_encoder
*e
)
142 return container_of(e
, struct tegra_output
, encoder
);
145 static inline struct tegra_output
*connector_to_output(struct drm_connector
*c
)
147 return container_of(c
, struct tegra_output
, connector
);
151 int tegra_output_probe(struct tegra_output
*output
);
152 void tegra_output_remove(struct tegra_output
*output
);
153 int tegra_output_init(struct drm_device
*drm
, struct tegra_output
*output
);
154 void tegra_output_exit(struct tegra_output
*output
);
156 int tegra_output_connector_get_modes(struct drm_connector
*connector
);
157 enum drm_connector_status
158 tegra_output_connector_detect(struct drm_connector
*connector
, bool force
);
159 void tegra_output_connector_destroy(struct drm_connector
*connector
);
161 void tegra_output_encoder_destroy(struct drm_encoder
*encoder
);
166 struct drm_dp_aux
*drm_dp_aux_find_by_of_node(struct device_node
*np
);
167 enum drm_connector_status
drm_dp_aux_detect(struct drm_dp_aux
*aux
);
168 int drm_dp_aux_attach(struct drm_dp_aux
*aux
, struct tegra_output
*output
);
169 int drm_dp_aux_detach(struct drm_dp_aux
*aux
);
170 int drm_dp_aux_enable(struct drm_dp_aux
*aux
);
171 int drm_dp_aux_disable(struct drm_dp_aux
*aux
);
172 int drm_dp_aux_prepare(struct drm_dp_aux
*aux
, u8 encoding
);
173 int drm_dp_aux_train(struct drm_dp_aux
*aux
, struct drm_dp_link
*link
,
177 struct tegra_bo
*tegra_fb_get_plane(struct drm_framebuffer
*framebuffer
,
179 bool tegra_fb_is_bottom_up(struct drm_framebuffer
*framebuffer
);
180 int tegra_fb_get_tiling(struct drm_framebuffer
*framebuffer
,
181 struct tegra_bo_tiling
*tiling
);
182 struct drm_framebuffer
*tegra_fb_create(struct drm_device
*drm
,
183 struct drm_file
*file
,
184 const struct drm_mode_fb_cmd2
*cmd
);
185 int tegra_drm_fb_prepare(struct drm_device
*drm
);
186 void tegra_drm_fb_free(struct drm_device
*drm
);
187 int tegra_drm_fb_init(struct drm_device
*drm
);
188 void tegra_drm_fb_exit(struct drm_device
*drm
);
189 void tegra_drm_fb_suspend(struct drm_device
*drm
);
190 void tegra_drm_fb_resume(struct drm_device
*drm
);
191 #ifdef CONFIG_DRM_FBDEV_EMULATION
192 void tegra_fbdev_restore_mode(struct tegra_fbdev
*fbdev
);
193 void tegra_fb_output_poll_changed(struct drm_device
*drm
);
196 extern struct platform_driver tegra_dc_driver
;
197 extern struct platform_driver tegra_hdmi_driver
;
198 extern struct platform_driver tegra_dsi_driver
;
199 extern struct platform_driver tegra_dpaux_driver
;
200 extern struct platform_driver tegra_sor_driver
;
201 extern struct platform_driver tegra_gr2d_driver
;
202 extern struct platform_driver tegra_gr3d_driver
;
203 extern struct platform_driver tegra_vic_driver
;
205 #endif /* HOST1X_DRM_H */