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#ifndef __DRM_CRTC_H__
26#define __DRM_CRTC_H__
27
28#include <linux/i2c.h>
29#include <linux/spinlock.h>
30#include <linux/types.h>
31#include <linux/idr.h>
32#include <linux/fb.h>
33#include <linux/hdmi.h>
34#include <drm/drm_mode.h>
35
36#include <drm/drm_fourcc.h>
37
38struct drm_device;
39struct drm_mode_set;
40struct drm_framebuffer;
41struct drm_object_properties;
42struct drm_file;
43struct drm_clip_rect;
44
45#define DRM_MODE_OBJECT_CRTC 0xcccccccc
46#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
47#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
48#define DRM_MODE_OBJECT_MODE 0xdededede
49#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
50#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
51#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
52#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
53#define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd
54
55struct drm_mode_object {
56 uint32_t id;
57 uint32_t type;
58 struct drm_object_properties *properties;
59};
60
61#define DRM_OBJECT_MAX_PROPERTY 24
62struct drm_object_properties {
63 int count;
64 uint32_t ids[DRM_OBJECT_MAX_PROPERTY];
65 uint64_t values[DRM_OBJECT_MAX_PROPERTY];
66};
67
68
69
70
71
72
73
74
75
76enum drm_mode_status {
77 MODE_OK = 0,
78 MODE_HSYNC,
79 MODE_VSYNC,
80 MODE_H_ILLEGAL,
81 MODE_V_ILLEGAL,
82 MODE_BAD_WIDTH,
83 MODE_NOMODE,
84 MODE_NO_INTERLACE,
85 MODE_NO_DBLESCAN,
86 MODE_NO_VSCAN,
87 MODE_MEM,
88 MODE_VIRTUAL_X,
89 MODE_VIRTUAL_Y,
90 MODE_MEM_VIRT,
91 MODE_NOCLOCK,
92 MODE_CLOCK_HIGH,
93 MODE_CLOCK_LOW,
94 MODE_CLOCK_RANGE,
95 MODE_BAD_HVALUE,
96 MODE_BAD_VVALUE,
97 MODE_BAD_VSCAN,
98 MODE_HSYNC_NARROW,
99 MODE_HSYNC_WIDE,
100 MODE_HBLANK_NARROW,
101 MODE_HBLANK_WIDE,
102 MODE_VSYNC_NARROW,
103 MODE_VSYNC_WIDE,
104 MODE_VBLANK_NARROW,
105 MODE_VBLANK_WIDE,
106 MODE_PANEL,
107 MODE_INTERLACE_WIDTH,
108 MODE_ONE_WIDTH,
109 MODE_ONE_HEIGHT,
110 MODE_ONE_SIZE,
111 MODE_NO_REDUCED,
112 MODE_NO_STEREO,
113 MODE_UNVERIFIED = -3,
114 MODE_BAD = -2,
115 MODE_ERROR = -1
116};
117
118#define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
119 DRM_MODE_TYPE_CRTC_C)
120
121#define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
122 .name = nm, .status = 0, .type = (t), .clock = (c), \
123 .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
124 .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
125 .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
126 .vscan = (vs), .flags = (f), \
127 .base.type = DRM_MODE_OBJECT_MODE
128
129#define CRTC_INTERLACE_HALVE_V (1 << 0)
130#define CRTC_STEREO_DOUBLE (1 << 1)
131
132#define DRM_MODE_FLAG_3D_MAX DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
133
134struct drm_display_mode {
135
136 struct list_head head;
137 struct drm_mode_object base;
138
139 char name[DRM_DISPLAY_MODE_LEN];
140
141 enum drm_mode_status status;
142 unsigned int type;
143
144
145 int clock;
146 int hdisplay;
147 int hsync_start;
148 int hsync_end;
149 int htotal;
150 int hskew;
151 int vdisplay;
152 int vsync_start;
153 int vsync_end;
154 int vtotal;
155 int vscan;
156 unsigned int flags;
157
158
159 int width_mm;
160 int height_mm;
161
162
163 int crtc_clock;
164 int crtc_hdisplay;
165 int crtc_hblank_start;
166 int crtc_hblank_end;
167 int crtc_hsync_start;
168 int crtc_hsync_end;
169 int crtc_htotal;
170 int crtc_hskew;
171 int crtc_vdisplay;
172 int crtc_vblank_start;
173 int crtc_vblank_end;
174 int crtc_vsync_start;
175 int crtc_vsync_end;
176 int crtc_vtotal;
177
178
179 int private_size;
180 int *private;
181 int private_flags;
182
183 int vrefresh;
184 int hsync;
185 enum hdmi_picture_aspect picture_aspect_ratio;
186};
187
188static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode)
189{
190 return mode->flags & DRM_MODE_FLAG_3D_MASK;
191}
192
193enum drm_connector_status {
194 connector_status_connected = 1,
195 connector_status_disconnected = 2,
196 connector_status_unknown = 3,
197};
198
199enum subpixel_order {
200 SubPixelUnknown = 0,
201 SubPixelHorizontalRGB,
202 SubPixelHorizontalBGR,
203 SubPixelVerticalRGB,
204 SubPixelVerticalBGR,
205 SubPixelNone,
206};
207
208#define DRM_COLOR_FORMAT_RGB444 (1<<0)
209#define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
210#define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
211
212
213
214struct drm_display_info {
215 char name[DRM_DISPLAY_INFO_LEN];
216
217
218 unsigned int width_mm;
219 unsigned int height_mm;
220
221
222 unsigned int min_vfreq, max_vfreq;
223 unsigned int min_hfreq, max_hfreq;
224 unsigned int pixel_clock;
225 unsigned int bpc;
226
227 enum subpixel_order subpixel_order;
228 u32 color_formats;
229
230 u8 cea_rev;
231};
232
233struct drm_framebuffer_funcs {
234
235 void (*destroy)(struct drm_framebuffer *framebuffer);
236 int (*create_handle)(struct drm_framebuffer *fb,
237 struct drm_file *file_priv,
238 unsigned int *handle);
239
240
241
242
243
244
245
246
247
248
249
250
251 int (*dirty)(struct drm_framebuffer *framebuffer,
252 struct drm_file *file_priv, unsigned flags,
253 unsigned color, struct drm_clip_rect *clips,
254 unsigned num_clips);
255};
256
257struct drm_framebuffer {
258 struct drm_device *dev;
259
260
261
262
263
264
265
266
267
268 struct kref refcount;
269
270
271
272
273 struct list_head head;
274 struct drm_mode_object base;
275 const struct drm_framebuffer_funcs *funcs;
276 unsigned int pitches[4];
277 unsigned int offsets[4];
278 unsigned int width;
279 unsigned int height;
280
281 unsigned int depth;
282 int bits_per_pixel;
283 int flags;
284 uint32_t pixel_format;
285 struct list_head filp_head;
286
287 void *helper_private;
288};
289
290struct drm_property_blob {
291 struct drm_mode_object base;
292 struct list_head head;
293 unsigned int length;
294 unsigned char data[];
295};
296
297struct drm_property_enum {
298 uint64_t value;
299 struct list_head head;
300 char name[DRM_PROP_NAME_LEN];
301};
302
303struct drm_property {
304 struct list_head head;
305 struct drm_mode_object base;
306 uint32_t flags;
307 char name[DRM_PROP_NAME_LEN];
308 uint32_t num_values;
309 uint64_t *values;
310
311 struct list_head enum_blob_list;
312};
313
314struct drm_crtc;
315struct drm_connector;
316struct drm_encoder;
317struct drm_pending_vblank_event;
318struct drm_plane;
319struct drm_bridge;
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343struct drm_crtc_funcs {
344
345 void (*save)(struct drm_crtc *crtc);
346
347 void (*restore)(struct drm_crtc *crtc);
348
349 void (*reset)(struct drm_crtc *crtc);
350
351
352 int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
353 uint32_t handle, uint32_t width, uint32_t height);
354 int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv,
355 uint32_t handle, uint32_t width, uint32_t height,
356 int32_t hot_x, int32_t hot_y);
357 int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
358
359
360 void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
361 uint32_t start, uint32_t size);
362
363 void (*destroy)(struct drm_crtc *crtc);
364
365 int (*set_config)(struct drm_mode_set *set);
366
367
368
369
370
371
372
373
374
375
376 int (*page_flip)(struct drm_crtc *crtc,
377 struct drm_framebuffer *fb,
378 struct drm_pending_vblank_event *event,
379 uint32_t flags);
380
381 int (*set_property)(struct drm_crtc *crtc,
382 struct drm_property *property, uint64_t val);
383};
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410struct drm_crtc {
411 struct drm_device *dev;
412 struct list_head head;
413
414
415
416
417
418
419
420
421 struct mutex mutex;
422
423 struct drm_mode_object base;
424
425
426 struct drm_framebuffer *fb;
427
428
429
430 struct drm_framebuffer *old_fb;
431
432 bool enabled;
433
434
435 struct drm_display_mode mode;
436
437
438
439
440 struct drm_display_mode hwmode;
441
442 bool invert_dimensions;
443
444 int x, y;
445 const struct drm_crtc_funcs *funcs;
446
447
448 uint32_t gamma_size;
449 uint16_t *gamma_store;
450
451
452 int framedur_ns, linedur_ns, pixeldur_ns;
453
454
455 void *helper_private;
456
457 struct drm_object_properties properties;
458};
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477struct drm_connector_funcs {
478 void (*dpms)(struct drm_connector *connector, int mode);
479 void (*save)(struct drm_connector *connector);
480 void (*restore)(struct drm_connector *connector);
481 void (*reset)(struct drm_connector *connector);
482
483
484
485
486
487
488
489 enum drm_connector_status (*detect)(struct drm_connector *connector,
490 bool force);
491 int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
492 int (*set_property)(struct drm_connector *connector, struct drm_property *property,
493 uint64_t val);
494 void (*destroy)(struct drm_connector *connector);
495 void (*force)(struct drm_connector *connector);
496};
497
498
499
500
501
502
503
504
505struct drm_encoder_funcs {
506 void (*reset)(struct drm_encoder *encoder);
507 void (*destroy)(struct drm_encoder *encoder);
508};
509
510#define DRM_CONNECTOR_MAX_ENCODER 3
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528struct drm_encoder {
529 struct drm_device *dev;
530 struct list_head head;
531
532 struct drm_mode_object base;
533 int encoder_type;
534 uint32_t possible_crtcs;
535 uint32_t possible_clones;
536
537 struct drm_crtc *crtc;
538 struct drm_bridge *bridge;
539 const struct drm_encoder_funcs *funcs;
540 void *helper_private;
541};
542
543enum drm_connector_force {
544 DRM_FORCE_UNSPECIFIED,
545 DRM_FORCE_OFF,
546 DRM_FORCE_ON,
547 DRM_FORCE_ON_DIGITAL,
548};
549
550
551
552#define DRM_CONNECTOR_POLL_HPD (1 << 0)
553
554#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
555
556
557#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
558
559#define MAX_ELD_BYTES 128
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598struct drm_connector {
599 struct drm_device *dev;
600 struct device *kdev;
601 struct device_attribute *attr;
602 struct list_head head;
603
604 struct drm_mode_object base;
605
606 int connector_type;
607 int connector_type_id;
608 bool interlace_allowed;
609 bool doublescan_allowed;
610 bool stereo_allowed;
611 struct list_head modes;
612
613 enum drm_connector_status status;
614
615
616 struct list_head probed_modes;
617
618 struct drm_display_info display_info;
619 const struct drm_connector_funcs *funcs;
620
621 struct drm_property_blob *edid_blob_ptr;
622 struct drm_object_properties properties;
623
624 uint8_t polled;
625
626
627 int dpms;
628
629 void *helper_private;
630
631
632 enum drm_connector_force force;
633 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
634 struct drm_encoder *encoder;
635
636
637 uint8_t eld[MAX_ELD_BYTES];
638 bool dvi_dual;
639 int max_tmds_clock;
640 bool latency_present[2];
641 int video_latency[2];
642 int audio_latency[2];
643 int null_edid_counter;
644 unsigned bad_edid_counter;
645};
646
647
648
649
650
651
652
653
654struct drm_plane_funcs {
655 int (*update_plane)(struct drm_plane *plane,
656 struct drm_crtc *crtc, struct drm_framebuffer *fb,
657 int crtc_x, int crtc_y,
658 unsigned int crtc_w, unsigned int crtc_h,
659 uint32_t src_x, uint32_t src_y,
660 uint32_t src_w, uint32_t src_h);
661 int (*disable_plane)(struct drm_plane *plane);
662 void (*destroy)(struct drm_plane *plane);
663
664 int (*set_property)(struct drm_plane *plane,
665 struct drm_property *property, uint64_t val);
666};
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681struct drm_plane {
682 struct drm_device *dev;
683 struct list_head head;
684
685 struct drm_mode_object base;
686
687 uint32_t possible_crtcs;
688 uint32_t *format_types;
689 uint32_t format_count;
690
691 struct drm_crtc *crtc;
692 struct drm_framebuffer *fb;
693
694 const struct drm_plane_funcs *funcs;
695
696 struct drm_object_properties properties;
697};
698
699
700
701
702
703
704
705
706
707
708
709struct drm_bridge_funcs {
710 bool (*mode_fixup)(struct drm_bridge *bridge,
711 const struct drm_display_mode *mode,
712 struct drm_display_mode *adjusted_mode);
713 void (*disable)(struct drm_bridge *bridge);
714 void (*post_disable)(struct drm_bridge *bridge);
715 void (*mode_set)(struct drm_bridge *bridge,
716 struct drm_display_mode *mode,
717 struct drm_display_mode *adjusted_mode);
718 void (*pre_enable)(struct drm_bridge *bridge);
719 void (*enable)(struct drm_bridge *bridge);
720 void (*destroy)(struct drm_bridge *bridge);
721};
722
723
724
725
726
727
728
729
730
731struct drm_bridge {
732 struct drm_device *dev;
733 struct list_head head;
734
735 struct drm_mode_object base;
736
737 const struct drm_bridge_funcs *funcs;
738 void *driver_private;
739};
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757struct drm_mode_set {
758 struct drm_framebuffer *fb;
759 struct drm_crtc *crtc;
760 struct drm_display_mode *mode;
761
762 uint32_t x;
763 uint32_t y;
764
765 struct drm_connector **connectors;
766 size_t num_connectors;
767};
768
769
770
771
772
773
774
775
776
777struct drm_mode_config_funcs {
778 struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
779 struct drm_file *file_priv,
780 struct drm_mode_fb_cmd2 *mode_cmd);
781 void (*output_poll_changed)(struct drm_device *dev);
782};
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797struct drm_mode_group {
798 uint32_t num_crtcs;
799 uint32_t num_encoders;
800 uint32_t num_connectors;
801 uint32_t num_bridges;
802
803
804 uint32_t *id_list;
805};
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836struct drm_mode_config {
837 struct mutex mutex;
838 struct mutex idr_mutex;
839 struct idr crtc_idr;
840
841
842
843
844
845
846
847
848
849 struct mutex fb_lock;
850 int num_fb;
851 struct list_head fb_list;
852
853 int num_connector;
854 struct list_head connector_list;
855 int num_bridge;
856 struct list_head bridge_list;
857 int num_encoder;
858 struct list_head encoder_list;
859 int num_plane;
860 struct list_head plane_list;
861
862 int num_crtc;
863 struct list_head crtc_list;
864
865 struct list_head property_list;
866
867 int min_width, min_height;
868 int max_width, max_height;
869 const struct drm_mode_config_funcs *funcs;
870 resource_size_t fb_base;
871
872
873 bool poll_enabled;
874 bool poll_running;
875 struct delayed_work output_poll_work;
876
877
878 struct list_head property_blob_list;
879 struct drm_property *edid_property;
880 struct drm_property *dpms_property;
881
882
883 struct drm_property *dvi_i_subconnector_property;
884 struct drm_property *dvi_i_select_subconnector_property;
885
886
887 struct drm_property *tv_subconnector_property;
888 struct drm_property *tv_select_subconnector_property;
889 struct drm_property *tv_mode_property;
890 struct drm_property *tv_left_margin_property;
891 struct drm_property *tv_right_margin_property;
892 struct drm_property *tv_top_margin_property;
893 struct drm_property *tv_bottom_margin_property;
894 struct drm_property *tv_brightness_property;
895 struct drm_property *tv_contrast_property;
896 struct drm_property *tv_flicker_reduction_property;
897 struct drm_property *tv_overscan_property;
898 struct drm_property *tv_saturation_property;
899 struct drm_property *tv_hue_property;
900
901
902 struct drm_property *scaling_mode_property;
903 struct drm_property *dirty_info_property;
904
905
906 uint32_t preferred_depth, prefer_shadow;
907
908
909 bool async_page_flip;
910
911
912 uint32_t cursor_width, cursor_height;
913};
914
915#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
916#define obj_to_connector(x) container_of(x, struct drm_connector, base)
917#define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
918#define obj_to_mode(x) container_of(x, struct drm_display_mode, base)
919#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
920#define obj_to_property(x) container_of(x, struct drm_property, base)
921#define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
922#define obj_to_plane(x) container_of(x, struct drm_plane, base)
923
924struct drm_prop_enum_list {
925 int type;
926 char *name;
927};
928
929extern void drm_modeset_lock_all(struct drm_device *dev);
930extern void drm_modeset_unlock_all(struct drm_device *dev);
931extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev);
932
933extern int drm_crtc_init(struct drm_device *dev,
934 struct drm_crtc *crtc,
935 const struct drm_crtc_funcs *funcs);
936extern void drm_crtc_cleanup(struct drm_crtc *crtc);
937extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
938
939
940
941
942
943
944
945
946static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc)
947{
948 return 1 << drm_crtc_index(crtc);
949}
950
951extern void drm_connector_ida_init(void);
952extern void drm_connector_ida_destroy(void);
953extern int drm_connector_init(struct drm_device *dev,
954 struct drm_connector *connector,
955 const struct drm_connector_funcs *funcs,
956 int connector_type);
957
958extern void drm_connector_cleanup(struct drm_connector *connector);
959
960extern void drm_connector_unplug_all(struct drm_device *dev);
961
962extern int drm_bridge_init(struct drm_device *dev, struct drm_bridge *bridge,
963 const struct drm_bridge_funcs *funcs);
964extern void drm_bridge_cleanup(struct drm_bridge *bridge);
965
966extern int drm_encoder_init(struct drm_device *dev,
967 struct drm_encoder *encoder,
968 const struct drm_encoder_funcs *funcs,
969 int encoder_type);
970
971
972
973
974
975
976
977
978static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
979 struct drm_crtc *crtc)
980{
981 return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
982}
983
984extern int drm_plane_init(struct drm_device *dev,
985 struct drm_plane *plane,
986 unsigned long possible_crtcs,
987 const struct drm_plane_funcs *funcs,
988 const uint32_t *formats, uint32_t format_count,
989 bool priv);
990extern void drm_plane_cleanup(struct drm_plane *plane);
991extern void drm_plane_force_disable(struct drm_plane *plane);
992
993extern void drm_encoder_cleanup(struct drm_encoder *encoder);
994
995extern const char *drm_get_connector_name(const struct drm_connector *connector);
996extern const char *drm_get_connector_status_name(enum drm_connector_status status);
997extern const char *drm_get_dpms_name(int val);
998extern const char *drm_get_dvi_i_subconnector_name(int val);
999extern const char *drm_get_dvi_i_select_name(int val);
1000extern const char *drm_get_tv_subconnector_name(int val);
1001extern const char *drm_get_tv_select_name(int val);
1002extern void drm_fb_release(struct drm_file *file_priv);
1003extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
1004extern bool drm_probe_ddc(struct i2c_adapter *adapter);
1005extern struct edid *drm_get_edid(struct drm_connector *connector,
1006 struct i2c_adapter *adapter);
1007extern struct edid *drm_edid_duplicate(const struct edid *edid);
1008extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
1009extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
1010extern void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);
1011extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
1012 const struct drm_display_mode *mode);
1013extern void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
1014extern void drm_mode_config_init(struct drm_device *dev);
1015extern void drm_mode_config_reset(struct drm_device *dev);
1016extern void drm_mode_config_cleanup(struct drm_device *dev);
1017extern void drm_mode_set_name(struct drm_display_mode *mode);
1018extern bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
1019extern bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
1020extern int drm_mode_width(const struct drm_display_mode *mode);
1021extern int drm_mode_height(const struct drm_display_mode *mode);
1022
1023
1024extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
1025extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
1026extern void drm_mode_validate_size(struct drm_device *dev,
1027 struct list_head *mode_list,
1028 int maxX, int maxY, int maxPitch);
1029extern void drm_mode_prune_invalid(struct drm_device *dev,
1030 struct list_head *mode_list, bool verbose);
1031extern void drm_mode_sort(struct list_head *mode_list);
1032extern int drm_mode_hsync(const struct drm_display_mode *mode);
1033extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
1034extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
1035 int adjust_flags);
1036extern void drm_mode_connector_list_update(struct drm_connector *connector);
1037extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
1038 struct edid *edid);
1039extern int drm_object_property_set_value(struct drm_mode_object *obj,
1040 struct drm_property *property,
1041 uint64_t val);
1042extern int drm_object_property_get_value(struct drm_mode_object *obj,
1043 struct drm_property *property,
1044 uint64_t *value);
1045extern int drm_framebuffer_init(struct drm_device *dev,
1046 struct drm_framebuffer *fb,
1047 const struct drm_framebuffer_funcs *funcs);
1048extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev,
1049 uint32_t id);
1050extern void drm_framebuffer_unreference(struct drm_framebuffer *fb);
1051extern void drm_framebuffer_reference(struct drm_framebuffer *fb);
1052extern void drm_framebuffer_remove(struct drm_framebuffer *fb);
1053extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb);
1054extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb);
1055
1056extern void drm_object_attach_property(struct drm_mode_object *obj,
1057 struct drm_property *property,
1058 uint64_t init_val);
1059extern struct drm_property *drm_property_create(struct drm_device *dev, int flags,
1060 const char *name, int num_values);
1061extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags,
1062 const char *name,
1063 const struct drm_prop_enum_list *props,
1064 int num_values);
1065struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
1066 int flags, const char *name,
1067 const struct drm_prop_enum_list *props,
1068 int num_values);
1069struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
1070 const char *name,
1071 uint64_t min, uint64_t max);
1072extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
1073extern int drm_property_add_enum(struct drm_property *property, int index,
1074 uint64_t value, const char *name);
1075extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
1076extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
1077 char *formats[]);
1078extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
1079extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
1080extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
1081
1082extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
1083 struct drm_encoder *encoder);
1084extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
1085 struct drm_encoder *encoder);
1086extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
1087 int gamma_size);
1088extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
1089 uint32_t id, uint32_t type);
1090
1091extern int drm_mode_getresources(struct drm_device *dev,
1092 void *data, struct drm_file *file_priv);
1093extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
1094 struct drm_file *file_priv);
1095extern int drm_mode_getcrtc(struct drm_device *dev,
1096 void *data, struct drm_file *file_priv);
1097extern int drm_mode_getconnector(struct drm_device *dev,
1098 void *data, struct drm_file *file_priv);
1099extern int drm_mode_set_config_internal(struct drm_mode_set *set);
1100extern int drm_mode_setcrtc(struct drm_device *dev,
1101 void *data, struct drm_file *file_priv);
1102extern int drm_mode_getplane(struct drm_device *dev,
1103 void *data, struct drm_file *file_priv);
1104extern int drm_mode_setplane(struct drm_device *dev,
1105 void *data, struct drm_file *file_priv);
1106extern int drm_mode_cursor_ioctl(struct drm_device *dev,
1107 void *data, struct drm_file *file_priv);
1108extern int drm_mode_cursor2_ioctl(struct drm_device *dev,
1109 void *data, struct drm_file *file_priv);
1110extern int drm_mode_addfb(struct drm_device *dev,
1111 void *data, struct drm_file *file_priv);
1112extern int drm_mode_addfb2(struct drm_device *dev,
1113 void *data, struct drm_file *file_priv);
1114extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
1115extern int drm_mode_rmfb(struct drm_device *dev,
1116 void *data, struct drm_file *file_priv);
1117extern int drm_mode_getfb(struct drm_device *dev,
1118 void *data, struct drm_file *file_priv);
1119extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
1120 void *data, struct drm_file *file_priv);
1121
1122extern int drm_mode_getproperty_ioctl(struct drm_device *dev,
1123 void *data, struct drm_file *file_priv);
1124extern int drm_mode_getblob_ioctl(struct drm_device *dev,
1125 void *data, struct drm_file *file_priv);
1126extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
1127 void *data, struct drm_file *file_priv);
1128extern int drm_mode_getencoder(struct drm_device *dev,
1129 void *data, struct drm_file *file_priv);
1130extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
1131 void *data, struct drm_file *file_priv);
1132extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
1133 void *data, struct drm_file *file_priv);
1134extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
1135extern bool drm_detect_hdmi_monitor(struct edid *edid);
1136extern bool drm_detect_monitor_audio(struct edid *edid);
1137extern bool drm_rgb_quant_range_selectable(struct edid *edid);
1138extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
1139 void *data, struct drm_file *file_priv);
1140extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
1141 int hdisplay, int vdisplay, int vrefresh,
1142 bool reduced, bool interlaced, bool margins);
1143extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
1144 int hdisplay, int vdisplay, int vrefresh,
1145 bool interlaced, int margins);
1146extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
1147 int hdisplay, int vdisplay, int vrefresh,
1148 bool interlaced, int margins, int GTF_M,
1149 int GTF_2C, int GTF_K, int GTF_2J);
1150extern int drm_add_modes_noedid(struct drm_connector *connector,
1151 int hdisplay, int vdisplay);
1152extern void drm_set_preferred_mode(struct drm_connector *connector,
1153 int hpref, int vpref);
1154
1155extern int drm_edid_header_is_valid(const u8 *raw_edid);
1156extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid);
1157extern bool drm_edid_is_valid(struct edid *edid);
1158struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
1159 int hsize, int vsize, int fresh,
1160 bool rb);
1161
1162extern int drm_mode_create_dumb_ioctl(struct drm_device *dev,
1163 void *data, struct drm_file *file_priv);
1164extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
1165 void *data, struct drm_file *file_priv);
1166extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
1167 void *data, struct drm_file *file_priv);
1168extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
1169 struct drm_file *file_priv);
1170extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
1171 struct drm_file *file_priv);
1172
1173extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
1174 int *bpp);
1175extern int drm_format_num_planes(uint32_t format);
1176extern int drm_format_plane_cpp(uint32_t format, int plane);
1177extern int drm_format_horz_chroma_subsampling(uint32_t format);
1178extern int drm_format_vert_chroma_subsampling(uint32_t format);
1179extern const char *drm_get_format_name(uint32_t format);
1180
1181
1182static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
1183 uint32_t id)
1184{
1185 struct drm_mode_object *mo;
1186 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC);
1187 return mo ? obj_to_crtc(mo) : NULL;
1188}
1189
1190static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
1191 uint32_t id)
1192{
1193 struct drm_mode_object *mo;
1194 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
1195 return mo ? obj_to_encoder(mo) : NULL;
1196}
1197
1198#endif
1199