forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/gpu/drm/qxl/qxl_drv.h
....@@ -23,7 +23,6 @@
2323 * Alon Levy
2424 */
2525
26
-
2726 #ifndef QXL_DRV_H
2827 #define QXL_DRV_H
2928
....@@ -32,21 +31,22 @@
3231 */
3332
3433 #include <linux/dma-fence.h>
35
-#include <linux/workqueue.h>
3634 #include <linux/firmware.h>
3735 #include <linux/platform_device.h>
36
+#include <linux/workqueue.h>
3837
3938 #include <drm/drm_crtc.h>
4039 #include <drm/drm_encoder.h>
40
+#include <drm/drm_fb_helper.h>
41
+#include <drm/drm_gem_ttm_helper.h>
42
+#include <drm/drm_ioctl.h>
4143 #include <drm/drm_gem.h>
42
-#include <drm/drmP.h>
44
+#include <drm/qxl_drm.h>
4345 #include <drm/ttm/ttm_bo_api.h>
4446 #include <drm/ttm/ttm_bo_driver.h>
45
-/* just for ttm_validate_buffer */
4647 #include <drm/ttm/ttm_execbuf_util.h>
4748 #include <drm/ttm/ttm_module.h>
4849 #include <drm/ttm/ttm_placement.h>
49
-#include <drm/qxl_drm.h>
5050
5151 #include "qxl_dev.h"
5252
....@@ -65,9 +65,6 @@
6565 extern int qxl_num_crtc;
6666 extern int qxl_max_ioctls;
6767
68
-#define DRM_FILE_OFFSET 0x100000000ULL
69
-#define DRM_FILE_PAGE_OFFSET (DRM_FILE_OFFSET >> PAGE_SHIFT)
70
-
7168 #define QXL_INTERRUPT_MASK (\
7269 QXL_INTERRUPT_DISPLAY |\
7370 QXL_INTERRUPT_CURSOR |\
....@@ -75,28 +72,29 @@
7572 QXL_INTERRUPT_CLIENT_MONITORS_CONFIG)
7673
7774 struct qxl_bo {
75
+ struct ttm_buffer_object tbo;
76
+
7877 /* Protected by gem.mutex */
7978 struct list_head list;
8079 /* Protected by tbo.reserved */
8180 struct ttm_place placements[3];
8281 struct ttm_placement placement;
83
- struct ttm_buffer_object tbo;
8482 struct ttm_bo_kmap_obj kmap;
85
- unsigned pin_count;
83
+ unsigned int pin_count;
8684 void *kptr;
85
+ unsigned int map_count;
8786 int type;
8887
8988 /* Constant after initialization */
90
- struct drm_gem_object gem_base;
91
- bool is_primary; /* is this now a primary surface */
92
- bool is_dumb;
89
+ unsigned int is_primary:1; /* is this now a primary surface */
90
+ unsigned int is_dumb:1;
9391 struct qxl_bo *shadow;
94
- bool hw_surf_alloc;
92
+ unsigned int hw_surf_alloc:1;
9593 struct qxl_surface surf;
9694 uint32_t surface_id;
9795 struct qxl_release *surf_create;
9896 };
99
-#define gem_to_qxl_bo(gobj) container_of((gobj), struct qxl_bo, gem_base)
97
+#define gem_to_qxl_bo(gobj) container_of((gobj), struct qxl_bo, tbo.base)
10098 #define to_qxl_bo(tobj) container_of((tobj), struct qxl_bo, tbo)
10199
102100 struct qxl_gem {
....@@ -121,35 +119,20 @@
121119 struct drm_encoder enc;
122120 };
123121
124
-struct qxl_framebuffer {
125
- struct drm_framebuffer base;
126
- struct drm_gem_object *obj;
127
-};
128
-
129122 #define to_qxl_crtc(x) container_of(x, struct qxl_crtc, base)
130123 #define drm_connector_to_qxl_output(x) container_of(x, struct qxl_output, base)
131124 #define drm_encoder_to_qxl_output(x) container_of(x, struct qxl_output, enc)
132
-#define to_qxl_framebuffer(x) container_of(x, struct qxl_framebuffer, base)
133125
134126 struct qxl_mman {
135
- struct ttm_bo_global_ref bo_global_ref;
136
- struct drm_global_reference mem_global_ref;
137
- bool mem_global_referenced;
138127 struct ttm_bo_device bdev;
139128 };
140129
141
-struct qxl_mode_info {
142
- bool mode_config_initialized;
143
-
144
- /* pointer to fbdev info structure */
145
- struct qxl_fbdev *qfbdev;
146
-};
147
-
148
-
149130 struct qxl_memslot {
131
+ int index;
132
+ const char *name;
150133 uint8_t generation;
151134 uint64_t start_phys_addr;
152
- uint64_t end_phys_addr;
135
+ uint64_t size;
153136 uint64_t high_bits;
154137 };
155138
....@@ -203,15 +186,10 @@
203186 */
204187 struct qxl_debugfs {
205188 struct drm_info_list *files;
206
- unsigned num_files;
189
+ unsigned int num_files;
207190 };
208191
209
-int qxl_debugfs_add_files(struct qxl_device *rdev,
210
- struct drm_info_list *files,
211
- unsigned nfiles);
212192 int qxl_debugfs_fence_init(struct qxl_device *rdev);
213
-
214
-struct qxl_device;
215193
216194 struct qxl_device {
217195 struct drm_device ddev;
....@@ -232,10 +210,7 @@
232210 void *ram;
233211 struct qxl_mman mman;
234212 struct qxl_gem gem;
235
- struct qxl_mode_info mode_info;
236213
237
- struct fb_info *fbdev_info;
238
- struct qxl_framebuffer *fbdev_qfb;
239214 void *ram_physical;
240215
241216 struct qxl_ring *release_ring;
....@@ -244,16 +219,12 @@
244219
245220 struct qxl_ram_header *ram_header;
246221
247
- bool primary_created;
222
+ struct qxl_bo *primary_bo;
223
+ struct qxl_bo *dumb_shadow_bo;
224
+ struct qxl_head *dumb_heads;
248225
249
- struct qxl_memslot *mem_slots;
250
- uint8_t n_mem_slots;
251
-
252
- uint8_t main_mem_slot;
253
- uint8_t surfaces_mem_slot;
254
- uint8_t slot_id_bits;
255
- uint8_t slot_gen_bits;
256
- uint64_t va_slot_mask;
226
+ struct qxl_memslot main_slot;
227
+ struct qxl_memslot surfaces_slot;
257228
258229 spinlock_t release_lock;
259230 struct idr release_idr;
....@@ -267,7 +238,7 @@
267238 atomic_t irq_received_display;
268239 atomic_t irq_received_cursor;
269240 atomic_t irq_received_io_cmd;
270
- unsigned irq_received_error;
241
+ unsigned int irq_received_error;
271242 wait_queue_head_t display_event;
272243 wait_queue_head_t cursor_event;
273244 wait_queue_head_t io_cmd_event;
....@@ -275,7 +246,7 @@
275246
276247 /* debugfs */
277248 struct qxl_debugfs debugfs[QXL_DEBUGFS_MAX_COMPONENTS];
278
- unsigned debugfs_count;
249
+ unsigned int debugfs_count;
279250
280251 struct mutex update_area_mutex;
281252
....@@ -299,11 +270,12 @@
299270 int monitors_config_height;
300271 };
301272
273
+#define to_qxl(dev) container_of(dev, struct qxl_device, ddev)
274
+
302275 extern const struct drm_ioctl_desc qxl_ioctls[];
303276 extern int qxl_max_ioctl;
304277
305
-int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
306
- struct pci_dev *pdev);
278
+int qxl_device_init(struct qxl_device *qdev, struct pci_dev *pdev);
307279 void qxl_device_fini(struct qxl_device *qdev);
308280
309281 int qxl_modeset_init(struct qxl_device *qdev);
....@@ -326,42 +298,20 @@
326298 void qxl_ring_init_hdr(struct qxl_ring *ring);
327299 int qxl_check_idle(struct qxl_ring *ring);
328300
329
-static inline void *
330
-qxl_fb_virtual_address(struct qxl_device *qdev, unsigned long physical)
331
-{
332
- DRM_DEBUG_DRIVER("not implemented (%lu)\n", physical);
333
- return 0;
334
-}
335
-
336301 static inline uint64_t
337302 qxl_bo_physical_address(struct qxl_device *qdev, struct qxl_bo *bo,
338303 unsigned long offset)
339304 {
340
- int slot_id = bo->type == QXL_GEM_DOMAIN_VRAM ? qdev->main_mem_slot : qdev->surfaces_mem_slot;
341
- struct qxl_memslot *slot = &(qdev->mem_slots[slot_id]);
305
+ struct qxl_memslot *slot =
306
+ (bo->tbo.mem.mem_type == TTM_PL_VRAM)
307
+ ? &qdev->main_slot : &qdev->surfaces_slot;
342308
343
- /* TODO - need to hold one of the locks to read tbo.offset */
344
- return slot->high_bits | (bo->tbo.offset + offset);
309
+ /* TODO - need to hold one of the locks to read bo->tbo.mem.start */
310
+
311
+ return slot->high_bits | ((bo->tbo.mem.start << PAGE_SHIFT) + offset);
345312 }
346313
347
-/* qxl_fb.c */
348
-#define QXLFB_CONN_LIMIT 1
349
-
350
-int qxl_fbdev_init(struct qxl_device *qdev);
351
-void qxl_fbdev_fini(struct qxl_device *qdev);
352
-int qxl_get_handle_for_primary_fb(struct qxl_device *qdev,
353
- struct drm_file *file_priv,
354
- uint32_t *handle);
355
-void qxl_fbdev_set_suspend(struct qxl_device *qdev, int state);
356
-
357314 /* qxl_display.c */
358
-void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb);
359
-int
360
-qxl_framebuffer_init(struct drm_device *dev,
361
- struct qxl_framebuffer *rfb,
362
- const struct drm_mode_fb_cmd2 *mode_cmd,
363
- struct drm_gem_object *obj,
364
- const struct drm_framebuffer_funcs *funcs);
365315 void qxl_display_read_client_monitors_config(struct qxl_device *qdev);
366316 int qxl_create_monitors_object(struct qxl_device *qdev);
367317 int qxl_destroy_monitors_object(struct qxl_device *qdev);
....@@ -396,11 +346,11 @@
396346 struct drm_device *dev,
397347 uint32_t handle, uint64_t *offset_p);
398348
399
-
400349 /* qxl ttm */
401350 int qxl_ttm_init(struct qxl_device *qdev);
402351 void qxl_ttm_fini(struct qxl_device *qdev);
403
-int qxl_mmap(struct file *filp, struct vm_area_struct *vma);
352
+int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
353
+ struct ttm_resource *mem);
404354
405355 /* qxl image */
406356
....@@ -422,7 +372,6 @@
422372 /* qxl io operations (qxl_cmd.c) */
423373
424374 void qxl_io_create_primary(struct qxl_device *qdev,
425
- unsigned offset,
426375 struct qxl_bo *bo);
427376 void qxl_io_destroy_primary(struct qxl_device *qdev);
428377 void qxl_io_memslot_add(struct qxl_device *qdev, uint8_t id);
....@@ -467,22 +416,13 @@
467416 struct qxl_bo **_bo);
468417 /* qxl drawing commands */
469418
470
-void qxl_draw_opaque_fb(const struct qxl_fb_image *qxl_fb_image,
471
- int stride /* filled in if 0 */);
472
-
473419 void qxl_draw_dirty_fb(struct qxl_device *qdev,
474
- struct qxl_framebuffer *qxl_fb,
420
+ struct drm_framebuffer *fb,
475421 struct qxl_bo *bo,
476
- unsigned flags, unsigned color,
422
+ unsigned int flags, unsigned int color,
477423 struct drm_clip_rect *clips,
478
- unsigned num_clips, int inc);
479
-
480
-void qxl_draw_fill(struct qxl_draw_fill *qxl_draw_fill_rec);
481
-
482
-void qxl_draw_copyarea(struct qxl_device *qdev,
483
- u32 width, u32 height,
484
- u32 sx, u32 sy,
485
- u32 dx, u32 dy);
424
+ unsigned int num_clips, int inc,
425
+ uint32_t dumb_shadow_offset);
486426
487427 void qxl_release_free(struct qxl_device *qdev,
488428 struct qxl_release *release);
....@@ -496,8 +436,8 @@
496436
497437 /* debugfs */
498438
499
-int qxl_debugfs_init(struct drm_minor *minor);
500
-int qxl_ttm_debugfs_init(struct qxl_device *qdev);
439
+void qxl_debugfs_init(struct drm_minor *minor);
440
+void qxl_ttm_debugfs_init(struct qxl_device *qdev);
501441
502442 /* qxl_prime.c */
503443 int qxl_gem_prime_pin(struct drm_gem_object *obj);
....@@ -515,20 +455,16 @@
515455 int qxl_irq_init(struct qxl_device *qdev);
516456 irqreturn_t qxl_irq_handler(int irq, void *arg);
517457
518
-/* qxl_fb.c */
519
-bool qxl_fbdev_qobj_is_fb(struct qxl_device *qdev, struct qxl_bo *qobj);
520
-
521
-int qxl_debugfs_add_files(struct qxl_device *qdev,
522
- struct drm_info_list *files,
523
- unsigned nfiles);
458
+void qxl_debugfs_add_files(struct qxl_device *qdev,
459
+ struct drm_info_list *files,
460
+ unsigned int nfiles);
524461
525462 int qxl_surface_id_alloc(struct qxl_device *qdev,
526463 struct qxl_bo *surf);
527464 void qxl_surface_id_dealloc(struct qxl_device *qdev,
528465 uint32_t surface_id);
529466 int qxl_hw_surface_alloc(struct qxl_device *qdev,
530
- struct qxl_bo *surf,
531
- struct ttm_mem_reg *mem);
467
+ struct qxl_bo *surf);
532468 int qxl_hw_surface_dealloc(struct qxl_device *qdev,
533469 struct qxl_bo *surf);
534470