]> Git Repo - linux.git/blob - drivers/gpu/drm/tegra/drm.h
Linux 6.14-rc3
[linux.git] / drivers / gpu / drm / tegra / drm.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (C) 2012 Avionic Design GmbH
4  * Copyright (C) 2012-2013 NVIDIA CORPORATION.  All rights reserved.
5  */
6
7 #ifndef HOST1X_DRM_H
8 #define HOST1X_DRM_H 1
9
10 #include <linux/host1x.h>
11 #include <linux/iova.h>
12 #include <linux/gpio/consumer.h>
13
14 #include <drm/drm_atomic.h>
15 #include <drm/drm_bridge.h>
16 #include <drm/drm_encoder.h>
17 #include <drm/drm_fixed.h>
18 #include <drm/drm_probe_helper.h>
19 #include <uapi/drm/tegra_drm.h>
20
21 #include "gem.h"
22 #include "hub.h"
23 #include "trace.h"
24
25 /* XXX move to include/uapi/drm/drm_fourcc.h? */
26 #define DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT BIT_ULL(22)
27
28 struct drm_fb_helper;
29 struct drm_fb_helper_surface_size;
30
31 struct edid;
32 struct reset_control;
33
34 struct tegra_drm {
35         struct drm_device *drm;
36
37         struct iommu_domain *domain;
38         bool use_explicit_iommu;
39         struct mutex mm_lock;
40         struct drm_mm mm;
41
42         struct {
43                 struct iova_domain domain;
44                 unsigned long shift;
45                 unsigned long limit;
46         } carveout;
47
48         struct mutex clients_lock;
49         struct list_head clients;
50
51         unsigned int hmask, vmask;
52         unsigned int pitch_align;
53         unsigned int num_crtcs;
54
55         struct tegra_display_hub *hub;
56 };
57
58 static inline struct host1x *tegra_drm_to_host1x(struct tegra_drm *tegra)
59 {
60         return dev_get_drvdata(tegra->drm->dev->parent);
61 }
62
63 struct tegra_drm_client;
64
65 struct tegra_drm_context {
66         struct tegra_drm_client *client;
67         struct host1x_channel *channel;
68
69         /* Only used by legacy UAPI. */
70         unsigned int id;
71
72         /* Only used by new UAPI. */
73         struct xarray mappings;
74         struct host1x_memory_context *memory_context;
75 };
76
77 struct tegra_drm_client_ops {
78         int (*open_channel)(struct tegra_drm_client *client,
79                             struct tegra_drm_context *context);
80         void (*close_channel)(struct tegra_drm_context *context);
81         int (*is_addr_reg)(struct device *dev, u32 class, u32 offset);
82         int (*is_valid_class)(u32 class);
83         int (*submit)(struct tegra_drm_context *context,
84                       struct drm_tegra_submit *args, struct drm_device *drm,
85                       struct drm_file *file);
86         int (*get_streamid_offset)(struct tegra_drm_client *client, u32 *offset);
87         int (*can_use_memory_ctx)(struct tegra_drm_client *client, bool *supported);
88 };
89
90 int tegra_drm_submit(struct tegra_drm_context *context,
91                      struct drm_tegra_submit *args, struct drm_device *drm,
92                      struct drm_file *file);
93
94 static inline int
95 tegra_drm_get_streamid_offset_thi(struct tegra_drm_client *client, u32 *offset)
96 {
97         *offset = 0x30;
98
99         return 0;
100 }
101
102 struct tegra_drm_client {
103         struct host1x_client base;
104         struct list_head list;
105         struct tegra_drm *drm;
106         struct host1x_channel *shared_channel;
107
108         /* Set by driver */
109         unsigned int version;
110         const struct tegra_drm_client_ops *ops;
111 };
112
113 static inline struct tegra_drm_client *
114 host1x_to_drm_client(struct host1x_client *client)
115 {
116         return container_of(client, struct tegra_drm_client, base);
117 }
118
119 int tegra_drm_register_client(struct tegra_drm *tegra,
120                               struct tegra_drm_client *client);
121 int tegra_drm_unregister_client(struct tegra_drm *tegra,
122                                 struct tegra_drm_client *client);
123 int host1x_client_iommu_attach(struct host1x_client *client);
124 void host1x_client_iommu_detach(struct host1x_client *client);
125
126 void *tegra_drm_alloc(struct tegra_drm *tegra, size_t size, dma_addr_t *iova);
127 void tegra_drm_free(struct tegra_drm *tegra, size_t size, void *virt,
128                     dma_addr_t iova);
129
130 struct cec_notifier;
131
132 struct tegra_output {
133         struct device_node *of_node;
134         struct device *dev;
135
136         struct drm_bridge *bridge;
137         struct drm_panel *panel;
138         struct i2c_adapter *ddc;
139         const struct drm_edid *drm_edid;
140         struct cec_notifier *cec;
141         unsigned int hpd_irq;
142         struct gpio_desc *hpd_gpio;
143
144         struct drm_encoder encoder;
145         struct drm_connector connector;
146 };
147
148 static inline struct tegra_output *encoder_to_output(struct drm_encoder *e)
149 {
150         return container_of(e, struct tegra_output, encoder);
151 }
152
153 static inline struct tegra_output *connector_to_output(struct drm_connector *c)
154 {
155         return container_of(c, struct tegra_output, connector);
156 }
157
158 /* from output.c */
159 int tegra_output_probe(struct tegra_output *output);
160 void tegra_output_remove(struct tegra_output *output);
161 int tegra_output_init(struct drm_device *drm, struct tegra_output *output);
162 void tegra_output_exit(struct tegra_output *output);
163 void tegra_output_find_possible_crtcs(struct tegra_output *output,
164                                       struct drm_device *drm);
165 int tegra_output_suspend(struct tegra_output *output);
166 int tegra_output_resume(struct tegra_output *output);
167
168 int tegra_output_connector_get_modes(struct drm_connector *connector);
169 enum drm_connector_status
170 tegra_output_connector_detect(struct drm_connector *connector, bool force);
171 void tegra_output_connector_destroy(struct drm_connector *connector);
172
173 /* from dpaux.c */
174 struct drm_dp_aux *drm_dp_aux_find_by_of_node(struct device_node *np);
175 enum drm_connector_status drm_dp_aux_detect(struct drm_dp_aux *aux);
176 int drm_dp_aux_attach(struct drm_dp_aux *aux, struct tegra_output *output);
177 int drm_dp_aux_detach(struct drm_dp_aux *aux);
178 int drm_dp_aux_enable(struct drm_dp_aux *aux);
179 int drm_dp_aux_disable(struct drm_dp_aux *aux);
180
181 /* from fb.c */
182 struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer,
183                                     unsigned int index);
184 bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer);
185 int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
186                         struct tegra_bo_tiling *tiling);
187 struct drm_framebuffer *tegra_fb_alloc(struct drm_device *drm,
188                                        const struct drm_mode_fb_cmd2 *mode_cmd,
189                                        struct tegra_bo **planes,
190                                        unsigned int num_planes);
191 struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
192                                         struct drm_file *file,
193                                         const struct drm_mode_fb_cmd2 *cmd);
194
195 #ifdef CONFIG_DRM_FBDEV_EMULATION
196 int tegra_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
197                                    struct drm_fb_helper_surface_size *sizes);
198 #define TEGRA_FBDEV_DRIVER_OPS \
199         .fbdev_probe = tegra_fbdev_driver_fbdev_probe
200 #else
201 #define TEGRA_FBDEV_DRIVER_OPS \
202         .fbdev_probe = NULL
203 #endif
204
205 extern struct platform_driver tegra_display_hub_driver;
206 extern struct platform_driver tegra_dc_driver;
207 extern struct platform_driver tegra_hdmi_driver;
208 extern struct platform_driver tegra_dsi_driver;
209 extern struct platform_driver tegra_dpaux_driver;
210 extern struct platform_driver tegra_sor_driver;
211 extern struct platform_driver tegra_gr2d_driver;
212 extern struct platform_driver tegra_gr3d_driver;
213 extern struct platform_driver tegra_vic_driver;
214 extern struct platform_driver tegra_nvdec_driver;
215
216 #endif /* HOST1X_DRM_H */
This page took 0.040681 seconds and 4 git commands to generate.