1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#ifndef _DRM_P_H_
33#define _DRM_P_H_
34
35#include <linux/agp_backend.h>
36#include <linux/cdev.h>
37#include <linux/dma-mapping.h>
38#include <linux/file.h>
39#include <linux/fs.h>
40#include <linux/highmem.h>
41#include <linux/idr.h>
42#include <linux/init.h>
43#include <linux/io.h>
44#include <linux/jiffies.h>
45#include <linux/kernel.h>
46#include <linux/kref.h>
47#include <linux/miscdevice.h>
48#include <linux/mm.h>
49#include <linux/mutex.h>
50#include <linux/pci.h>
51#include <linux/platform_device.h>
52#include <linux/poll.h>
53#include <linux/ratelimit.h>
54#include <linux/sched.h>
55#include <linux/slab.h>
56#include <linux/types.h>
57#include <linux/vmalloc.h>
58#include <linux/workqueue.h>
59#include <linux/fence.h>
60
61#include <asm/mman.h>
62#include <asm/pgalloc.h>
63#include <asm/uaccess.h>
64
65#include <uapi/drm/drm.h>
66#include <uapi/drm/drm_mode.h>
67
68#include <drm/drm_agpsupport.h>
69#include <drm/drm_crtc.h>
70#include <drm/drm_fourcc.h>
71#include <drm/drm_global.h>
72#include <drm/drm_hashtab.h>
73#include <drm/drm_mem_util.h>
74#include <drm/drm_mm.h>
75#include <drm/drm_os_linux.h>
76#include <drm/drm_sarea.h>
77#include <drm/drm_vma_manager.h>
78
79struct module;
80
81struct drm_file;
82struct drm_device;
83struct drm_agp_head;
84struct drm_local_map;
85struct drm_device_dma;
86struct drm_dma_handle;
87struct drm_gem_object;
88struct drm_master;
89struct drm_vblank_crtc;
90
91struct device_node;
92struct videomode;
93struct reservation_object;
94struct dma_buf_attachment;
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130#define DRM_UT_CORE 0x01
131#define DRM_UT_DRIVER 0x02
132#define DRM_UT_KMS 0x04
133#define DRM_UT_PRIME 0x08
134#define DRM_UT_ATOMIC 0x10
135#define DRM_UT_VBL 0x20
136
137extern __printf(2, 3)
138void drm_ut_debug_printk(const char *function_name,
139 const char *format, ...);
140extern __printf(1, 2)
141void drm_err(const char *format, ...);
142
143
144
145
146
147
148#define DRIVER_USE_AGP 0x1
149#define DRIVER_PCI_DMA 0x8
150#define DRIVER_SG 0x10
151#define DRIVER_HAVE_DMA 0x20
152#define DRIVER_HAVE_IRQ 0x40
153#define DRIVER_IRQ_SHARED 0x80
154#define DRIVER_GEM 0x1000
155#define DRIVER_MODESET 0x2000
156#define DRIVER_PRIME 0x4000
157#define DRIVER_RENDER 0x8000
158#define DRIVER_ATOMIC 0x10000
159#define DRIVER_KMS_LEGACY_CONTEXT 0x20000
160
161
162
163
164
165
166
167
168
169
170
171#define DRM_ERROR(fmt, ...) \
172 drm_err(fmt, ##__VA_ARGS__)
173
174
175
176
177
178
179
180#define DRM_ERROR_RATELIMITED(fmt, ...) \
181({ \
182 static DEFINE_RATELIMIT_STATE(_rs, \
183 DEFAULT_RATELIMIT_INTERVAL, \
184 DEFAULT_RATELIMIT_BURST); \
185 \
186 if (__ratelimit(&_rs)) \
187 drm_err(fmt, ##__VA_ARGS__); \
188})
189
190#define DRM_INFO(fmt, ...) \
191 printk(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
192
193#define DRM_INFO_ONCE(fmt, ...) \
194 printk_once(KERN_INFO "[" DRM_NAME "] " fmt, ##__VA_ARGS__)
195
196
197
198
199
200
201
202#define DRM_DEBUG(fmt, args...) \
203 do { \
204 if (unlikely(drm_debug & DRM_UT_CORE)) \
205 drm_ut_debug_printk(__func__, fmt, ##args); \
206 } while (0)
207
208#define DRM_DEBUG_DRIVER(fmt, args...) \
209 do { \
210 if (unlikely(drm_debug & DRM_UT_DRIVER)) \
211 drm_ut_debug_printk(__func__, fmt, ##args); \
212 } while (0)
213#define DRM_DEBUG_KMS(fmt, args...) \
214 do { \
215 if (unlikely(drm_debug & DRM_UT_KMS)) \
216 drm_ut_debug_printk(__func__, fmt, ##args); \
217 } while (0)
218#define DRM_DEBUG_PRIME(fmt, args...) \
219 do { \
220 if (unlikely(drm_debug & DRM_UT_PRIME)) \
221 drm_ut_debug_printk(__func__, fmt, ##args); \
222 } while (0)
223#define DRM_DEBUG_ATOMIC(fmt, args...) \
224 do { \
225 if (unlikely(drm_debug & DRM_UT_ATOMIC)) \
226 drm_ut_debug_printk(__func__, fmt, ##args); \
227 } while (0)
228#define DRM_DEBUG_VBL(fmt, args...) \
229 do { \
230 if (unlikely(drm_debug & DRM_UT_VBL)) \
231 drm_ut_debug_printk(__func__, fmt, ##args); \
232 } while (0)
233
234
235
236
237
238
239
240#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
241
242
243
244
245
246
247
248
249
250typedef int drm_ioctl_t(struct drm_device *dev, void *data,
251 struct drm_file *file_priv);
252
253typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
254 unsigned long arg);
255
256#define DRM_IOCTL_NR(n) _IOC_NR(n)
257#define DRM_MAJOR 226
258
259#define DRM_AUTH 0x1
260#define DRM_MASTER 0x2
261#define DRM_ROOT_ONLY 0x4
262#define DRM_CONTROL_ALLOW 0x8
263#define DRM_UNLOCKED 0x10
264#define DRM_RENDER_ALLOW 0x20
265
266struct drm_ioctl_desc {
267 unsigned int cmd;
268 int flags;
269 drm_ioctl_t *func;
270 const char *name;
271};
272
273
274
275
276
277
278#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
279 [DRM_IOCTL_NR(DRM_IOCTL_##ioctl) - DRM_COMMAND_BASE] = { \
280 .cmd = DRM_IOCTL_##ioctl, \
281 .func = _func, \
282 .flags = _flags, \
283 .name = #ioctl \
284 }
285
286
287struct drm_pending_event {
288 struct completion *completion;
289 struct drm_event *event;
290 struct fence *fence;
291 struct list_head link;
292 struct list_head pending_link;
293 struct drm_file *file_priv;
294 pid_t pid;
295
296};
297
298
299struct drm_prime_file_private {
300 struct list_head head;
301 struct mutex lock;
302};
303
304
305struct drm_file {
306 unsigned authenticated :1;
307
308 unsigned stereo_allowed :1;
309
310
311
312
313 unsigned universal_planes:1;
314
315 unsigned atomic:1;
316
317
318
319
320 unsigned is_master:1;
321
322 struct pid *pid;
323 kuid_t uid;
324 drm_magic_t magic;
325 struct list_head lhead;
326 struct drm_minor *minor;
327 unsigned long lock_count;
328
329
330 struct idr object_idr;
331
332 spinlock_t table_lock;
333
334 struct file *filp;
335 void *driver_priv;
336
337 struct drm_master *master;
338
339
340
341
342
343
344
345 struct list_head fbs;
346 struct mutex fbs_lock;
347
348
349
350 struct list_head blobs;
351
352 wait_queue_head_t event_wait;
353 struct list_head pending_event_list;
354 struct list_head event_list;
355 int event_space;
356
357 struct mutex event_read_lock;
358
359 struct drm_prime_file_private prime;
360};
361
362
363
364
365struct drm_lock_data {
366 struct drm_hw_lock *hw_lock;
367
368 struct drm_file *file_priv;
369 wait_queue_head_t lock_queue;
370 unsigned long lock_time;
371 spinlock_t spinlock;
372 uint32_t kernel_waiters;
373 uint32_t user_waiters;
374 int idle_has_lock;
375};
376
377
378#define DRM_CALLED_FROM_VBLIRQ 1
379#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
380#define DRM_VBLANKTIME_IN_VBLANK (1 << 1)
381
382
383#define DRM_SCANOUTPOS_VALID (1 << 0)
384#define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
385#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
386
387
388
389
390
391
392struct drm_driver {
393 int (*load) (struct drm_device *, unsigned long flags);
394 int (*firstopen) (struct drm_device *);
395 int (*open) (struct drm_device *, struct drm_file *);
396 void (*preclose) (struct drm_device *, struct drm_file *file_priv);
397 void (*postclose) (struct drm_device *, struct drm_file *);
398 void (*lastclose) (struct drm_device *);
399 int (*unload) (struct drm_device *);
400 int (*dma_ioctl) (struct drm_device *dev, void *data, struct drm_file *file_priv);
401 int (*dma_quiescent) (struct drm_device *);
402 int (*context_dtor) (struct drm_device *dev, int context);
403 int (*set_busid)(struct drm_device *dev, struct drm_master *master);
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422 u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437 int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
438
439
440
441
442
443
444
445
446
447
448 void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
449
450
451
452
453
454
455
456
457
458
459
460
461 int (*device_is_agp) (struct drm_device *dev);
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494 int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
495 unsigned int flags, int *vpos, int *hpos,
496 ktime_t *stime, ktime_t *etime,
497 const struct drm_display_mode *mode);
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529 int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
530 int *max_error,
531 struct timeval *vblank_time,
532 unsigned flags);
533
534
535
536 irqreturn_t(*irq_handler) (int irq, void *arg);
537 void (*irq_preinstall) (struct drm_device *dev);
538 int (*irq_postinstall) (struct drm_device *dev);
539 void (*irq_uninstall) (struct drm_device *dev);
540
541
542 int (*master_create)(struct drm_device *dev, struct drm_master *master);
543 void (*master_destroy)(struct drm_device *dev, struct drm_master *master);
544
545
546
547
548
549 int (*master_set)(struct drm_device *dev, struct drm_file *file_priv,
550 bool from_open);
551 void (*master_drop)(struct drm_device *dev, struct drm_file *file_priv);
552
553 int (*debugfs_init)(struct drm_minor *minor);
554 void (*debugfs_cleanup)(struct drm_minor *minor);
555
556
557
558
559
560
561
562 void (*gem_free_object) (struct drm_gem_object *obj);
563
564
565
566
567
568
569
570 void (*gem_free_object_unlocked) (struct drm_gem_object *obj);
571
572 int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
573 void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
574
575
576
577
578
579 struct drm_gem_object *(*gem_create_object)(struct drm_device *dev,
580 size_t size);
581
582
583
584 int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
585 uint32_t handle, uint32_t flags, int *prime_fd);
586
587 int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
588 int prime_fd, uint32_t *handle);
589
590 struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
591 struct drm_gem_object *obj, int flags);
592
593 struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
594 struct dma_buf *dma_buf);
595
596 int (*gem_prime_pin)(struct drm_gem_object *obj);
597 void (*gem_prime_unpin)(struct drm_gem_object *obj);
598 struct reservation_object * (*gem_prime_res_obj)(
599 struct drm_gem_object *obj);
600 struct sg_table *(*gem_prime_get_sg_table)(struct drm_gem_object *obj);
601 struct drm_gem_object *(*gem_prime_import_sg_table)(
602 struct drm_device *dev,
603 struct dma_buf_attachment *attach,
604 struct sg_table *sgt);
605 void *(*gem_prime_vmap)(struct drm_gem_object *obj);
606 void (*gem_prime_vunmap)(struct drm_gem_object *obj, void *vaddr);
607 int (*gem_prime_mmap)(struct drm_gem_object *obj,
608 struct vm_area_struct *vma);
609
610
611 void (*vgaarb_irq)(struct drm_device *dev, bool state);
612
613
614 int (*dumb_create)(struct drm_file *file_priv,
615 struct drm_device *dev,
616 struct drm_mode_create_dumb *args);
617 int (*dumb_map_offset)(struct drm_file *file_priv,
618 struct drm_device *dev, uint32_t handle,
619 uint64_t *offset);
620 int (*dumb_destroy)(struct drm_file *file_priv,
621 struct drm_device *dev,
622 uint32_t handle);
623
624
625 const struct vm_operations_struct *gem_vm_ops;
626
627 int major;
628 int minor;
629 int patchlevel;
630 char *name;
631 char *desc;
632 char *date;
633
634 u32 driver_features;
635 int dev_priv_size;
636 const struct drm_ioctl_desc *ioctls;
637 int num_ioctls;
638 const struct file_operations *fops;
639
640
641 struct list_head legacy_dev_list;
642};
643
644enum drm_minor_type {
645 DRM_MINOR_LEGACY,
646 DRM_MINOR_CONTROL,
647 DRM_MINOR_RENDER,
648 DRM_MINOR_CNT,
649};
650
651
652
653
654
655struct drm_info_list {
656 const char *name;
657 int (*show)(struct seq_file*, void*);
658 u32 driver_features;
659 void *data;
660};
661
662
663
664
665struct drm_info_node {
666 struct list_head list;
667 struct drm_minor *minor;
668 const struct drm_info_list *info_ent;
669 struct dentry *dent;
670};
671
672
673
674
675struct drm_minor {
676 int index;
677 int type;
678 struct device *kdev;
679 struct drm_device *dev;
680
681 struct dentry *debugfs_root;
682
683 struct list_head debugfs_list;
684 struct mutex debugfs_lock;
685};
686
687
688
689
690
691struct drm_device {
692 struct list_head legacy_dev_list;
693 int if_version;
694
695
696
697 struct kref ref;
698 struct device *dev;
699 struct drm_driver *driver;
700 void *dev_private;
701 struct drm_minor *control;
702 struct drm_minor *primary;
703 struct drm_minor *render;
704
705
706 struct drm_master *master;
707
708 atomic_t unplugged;
709 struct inode *anon_inode;
710 char *unique;
711
712
713
714
715 struct mutex struct_mutex;
716 struct mutex master_mutex;
717
718
719
720
721 int open_count;
722 spinlock_t buf_lock;
723 int buf_use;
724 atomic_t buf_alloc;
725
726
727 struct mutex filelist_mutex;
728 struct list_head filelist;
729
730
731
732 struct list_head maplist;
733 struct drm_open_hash map_hash;
734
735
736
737 struct list_head ctxlist;
738 struct mutex ctxlist_mutex;
739
740 struct idr ctx_idr;
741
742 struct list_head vmalist;
743
744
745
746
747
748 struct drm_device_dma *dma;
749
750
751
752
753
754 __volatile__ long context_flag;
755 int last_context;
756
757
758
759
760 bool irq_enabled;
761 int irq;
762
763
764
765
766
767
768
769
770
771 bool vblank_disable_immediate;
772
773
774 struct drm_vblank_crtc *vblank;
775
776 spinlock_t vblank_time_lock;
777 spinlock_t vbl_lock;
778
779 u32 max_vblank_count;
780
781
782
783
784 struct list_head vblank_event_list;
785 spinlock_t event_lock;
786
787
788
789 struct drm_agp_head *agp;
790
791 struct pci_dev *pdev;
792#ifdef __alpha__
793 struct pci_controller *hose;
794#endif
795
796 struct platform_device *platformdev;
797 struct virtio_device *virtdev;
798
799 struct drm_sg_mem *sg;
800 unsigned int num_crtcs;
801
802 struct {
803 int context;
804 struct drm_hw_lock *lock;
805 } sigdata;
806
807 struct drm_local_map *agp_buffer_map;
808 unsigned int agp_buffer_token;
809
810 struct drm_mode_config mode_config;
811
812
813
814 struct mutex object_name_lock;
815 struct idr object_name_idr;
816 struct drm_vma_offset_manager *vma_offset_manager;
817
818 int switch_power_state;
819};
820
821#include <drm/drm_irq.h>
822
823#define DRM_SWITCH_POWER_ON 0
824#define DRM_SWITCH_POWER_OFF 1
825#define DRM_SWITCH_POWER_CHANGING 2
826#define DRM_SWITCH_POWER_DYNAMIC_OFF 3
827
828static __inline__ int drm_core_check_feature(struct drm_device *dev,
829 int feature)
830{
831 return ((dev->driver->driver_features & feature) ? 1 : 0);
832}
833
834static inline void drm_device_set_unplugged(struct drm_device *dev)
835{
836 smp_wmb();
837 atomic_set(&dev->unplugged, 1);
838}
839
840static inline int drm_device_is_unplugged(struct drm_device *dev)
841{
842 int ret = atomic_read(&dev->unplugged);
843 smp_rmb();
844 return ret;
845}
846
847static inline bool drm_is_render_client(const struct drm_file *file_priv)
848{
849 return file_priv->minor->type == DRM_MINOR_RENDER;
850}
851
852static inline bool drm_is_control_client(const struct drm_file *file_priv)
853{
854 return file_priv->minor->type == DRM_MINOR_CONTROL;
855}
856
857static inline bool drm_is_primary_client(const struct drm_file *file_priv)
858{
859 return file_priv->minor->type == DRM_MINOR_LEGACY;
860}
861
862
863
864
865
866
867extern int drm_ioctl_permit(u32 flags, struct drm_file *file_priv);
868extern long drm_ioctl(struct file *filp,
869 unsigned int cmd, unsigned long arg);
870extern long drm_compat_ioctl(struct file *filp,
871 unsigned int cmd, unsigned long arg);
872extern bool drm_ioctl_flags(unsigned int nr, unsigned int *flags);
873
874
875int drm_open(struct inode *inode, struct file *filp);
876ssize_t drm_read(struct file *filp, char __user *buffer,
877 size_t count, loff_t *offset);
878int drm_release(struct inode *inode, struct file *filp);
879unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait);
880int drm_event_reserve_init_locked(struct drm_device *dev,
881 struct drm_file *file_priv,
882 struct drm_pending_event *p,
883 struct drm_event *e);
884int drm_event_reserve_init(struct drm_device *dev,
885 struct drm_file *file_priv,
886 struct drm_pending_event *p,
887 struct drm_event *e);
888void drm_event_cancel_free(struct drm_device *dev,
889 struct drm_pending_event *p);
890void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e);
891void drm_send_event(struct drm_device *dev, struct drm_pending_event *e);
892
893
894int drm_noop(struct drm_device *dev, void *data,
895 struct drm_file *file_priv);
896int drm_invalid_op(struct drm_device *dev, void *data,
897 struct drm_file *file_priv);
898
899
900void drm_clflush_pages(struct page *pages[], unsigned long num_pages);
901void drm_clflush_sg(struct sg_table *st);
902void drm_clflush_virt_range(void *addr, unsigned long length);
903
904
905
906
907
908
909
910extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
911extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
912
913
914void drm_put_dev(struct drm_device *dev);
915void drm_unplug_dev(struct drm_device *dev);
916extern unsigned int drm_debug;
917
918
919#if defined(CONFIG_DEBUG_FS)
920extern int drm_debugfs_create_files(const struct drm_info_list *files,
921 int count, struct dentry *root,
922 struct drm_minor *minor);
923extern int drm_debugfs_remove_files(const struct drm_info_list *files,
924 int count, struct drm_minor *minor);
925#else
926static inline int drm_debugfs_create_files(const struct drm_info_list *files,
927 int count, struct dentry *root,
928 struct drm_minor *minor)
929{
930 return 0;
931}
932
933static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
934 int count, struct drm_minor *minor)
935{
936 return 0;
937}
938#endif
939
940extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
941 struct drm_gem_object *obj, int flags);
942extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
943 struct drm_file *file_priv, uint32_t handle, uint32_t flags,
944 int *prime_fd);
945extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
946 struct dma_buf *dma_buf);
947extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
948 struct drm_file *file_priv, int prime_fd, uint32_t *handle);
949extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
950
951extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages,
952 dma_addr_t *addrs, int max_pages);
953extern struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages);
954extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
955
956
957extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
958 size_t align);
959extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
960
961
962extern void drm_sysfs_hotplug_event(struct drm_device *dev);
963
964
965struct drm_device *drm_dev_alloc(struct drm_driver *driver,
966 struct device *parent);
967int drm_dev_init(struct drm_device *dev,
968 struct drm_driver *driver,
969 struct device *parent);
970void drm_dev_ref(struct drm_device *dev);
971void drm_dev_unref(struct drm_device *dev);
972int drm_dev_register(struct drm_device *dev, unsigned long flags);
973void drm_dev_unregister(struct drm_device *dev);
974
975struct drm_minor *drm_minor_acquire(unsigned int minor_id);
976void drm_minor_release(struct drm_minor *minor);
977
978
979
980
981static __inline__ int drm_pci_device_is_agp(struct drm_device *dev)
982{
983 if (dev->driver->device_is_agp != NULL) {
984 int err = (*dev->driver->device_is_agp) (dev);
985
986 if (err != 2) {
987 return err;
988 }
989 }
990
991 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
992}
993void drm_pci_agp_destroy(struct drm_device *dev);
994
995extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
996extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
997#ifdef CONFIG_PCI
998extern int drm_get_pci_dev(struct pci_dev *pdev,
999 const struct pci_device_id *ent,
1000 struct drm_driver *driver);
1001extern int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);
1002#else
1003static inline int drm_get_pci_dev(struct pci_dev *pdev,
1004 const struct pci_device_id *ent,
1005 struct drm_driver *driver)
1006{
1007 return -ENOSYS;
1008}
1009
1010static inline int drm_pci_set_busid(struct drm_device *dev,
1011 struct drm_master *master)
1012{
1013 return -ENOSYS;
1014}
1015#endif
1016
1017#define DRM_PCIE_SPEED_25 1
1018#define DRM_PCIE_SPEED_50 2
1019#define DRM_PCIE_SPEED_80 4
1020
1021extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1022extern int drm_pcie_get_max_link_width(struct drm_device *dev, u32 *mlw);
1023
1024
1025extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
1026
1027
1028static __inline__ bool drm_can_sleep(void)
1029{
1030 if (in_atomic() || in_dbg_master() || irqs_disabled())
1031 return false;
1032 return true;
1033}
1034
1035
1036#define for_each_if(condition) if (!(condition)) {} else
1037
1038#endif
1039