Subversion Repositories Kolibri OS

Rev

Rev 4559 | Rev 5270 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4559 Rev 5056
Line 30... Line 30...
30
#include 
30
#include 
31
#include 
31
#include 
32
#include 
32
#include 
33
#include 
33
#include 
34
#include 
34
#include 
35
 
-
 
36
#include 
35
#include 
-
 
36
#include 
Line 37... Line 37...
37
 
37
 
38
struct drm_device;
38
struct drm_device;
39
struct drm_mode_set;
39
struct drm_mode_set;
40
struct drm_framebuffer;
40
struct drm_framebuffer;
41
struct drm_object_properties;
41
struct drm_object_properties;
42
struct drm_file;
42
struct drm_file;
-
 
43
struct drm_clip_rect;
Line 43... Line 44...
43
struct drm_clip_rect;
44
struct device_node;
44
 
45
 
45
#define DRM_MODE_OBJECT_CRTC 0xcccccccc
46
#define DRM_MODE_OBJECT_CRTC 0xcccccccc
46
#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
47
#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
47
#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
48
#define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0
48
#define DRM_MODE_OBJECT_MODE 0xdededede
49
#define DRM_MODE_OBJECT_MODE 0xdededede
49
#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
50
#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
50
#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
51
#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
51
#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
52
#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
-
 
53
#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
Line 52... Line 54...
52
#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
54
#define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd
53
#define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd
55
#define DRM_MODE_OBJECT_ANY 0
54
 
56
 
55
struct drm_mode_object {
57
struct drm_mode_object {
Line 63... Line 65...
63
	int count;
65
	int count;
64
	uint32_t ids[DRM_OBJECT_MAX_PROPERTY];
66
	uint32_t ids[DRM_OBJECT_MAX_PROPERTY];
65
	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
67
	uint64_t values[DRM_OBJECT_MAX_PROPERTY];
66
};
68
};
Line 67... Line -...
67
 
-
 
68
/*
-
 
69
 * Note on terminology:  here, for brevity and convenience, we refer to connector
-
 
70
 * control chips as 'CRTCs'.  They can control any type of connector, VGA, LVDS,
-
 
71
 * DVI, etc.  And 'screen' refers to the whole of the visible display, which
69
 
72
 * may span multiple monitors (and therefore multiple CRTC and connector
-
 
73
 * structures).
-
 
74
 */
70
static inline int64_t U642I64(uint64_t val)
75
 
-
 
76
enum drm_mode_status {
-
 
77
    MODE_OK	= 0,	/* Mode OK */
71
{
78
    MODE_HSYNC,		/* hsync out of range */
-
 
79
    MODE_VSYNC,		/* vsync out of range */
-
 
80
    MODE_H_ILLEGAL,	/* mode has illegal horizontal timings */
-
 
81
    MODE_V_ILLEGAL,	/* mode has illegal horizontal timings */
-
 
82
    MODE_BAD_WIDTH,	/* requires an unsupported linepitch */
-
 
83
    MODE_NOMODE,	/* no mode with a matching name */
-
 
84
    MODE_NO_INTERLACE,	/* interlaced mode not supported */
-
 
85
    MODE_NO_DBLESCAN,	/* doublescan mode not supported */
-
 
86
    MODE_NO_VSCAN,	/* multiscan mode not supported */
-
 
87
    MODE_MEM,		/* insufficient video memory */
-
 
88
    MODE_VIRTUAL_X,	/* mode width too large for specified virtual size */
-
 
89
    MODE_VIRTUAL_Y,	/* mode height too large for specified virtual size */
-
 
90
    MODE_MEM_VIRT,	/* insufficient video memory given virtual size */
-
 
91
    MODE_NOCLOCK,	/* no fixed clock available */
-
 
92
    MODE_CLOCK_HIGH,	/* clock required is too high */
-
 
93
    MODE_CLOCK_LOW,	/* clock required is too low */
-
 
94
    MODE_CLOCK_RANGE,	/* clock/mode isn't in a ClockRange */
-
 
95
    MODE_BAD_HVALUE,	/* horizontal timing was out of range */
-
 
96
    MODE_BAD_VVALUE,	/* vertical timing was out of range */
-
 
97
    MODE_BAD_VSCAN,	/* VScan value out of range */
-
 
98
    MODE_HSYNC_NARROW,	/* horizontal sync too narrow */
-
 
99
    MODE_HSYNC_WIDE,	/* horizontal sync too wide */
-
 
100
    MODE_HBLANK_NARROW,	/* horizontal blanking too narrow */
-
 
101
    MODE_HBLANK_WIDE,	/* horizontal blanking too wide */
-
 
102
    MODE_VSYNC_NARROW,	/* vertical sync too narrow */
-
 
103
    MODE_VSYNC_WIDE,	/* vertical sync too wide */
-
 
104
    MODE_VBLANK_NARROW,	/* vertical blanking too narrow */
-
 
105
    MODE_VBLANK_WIDE,	/* vertical blanking too wide */
-
 
106
    MODE_PANEL,         /* exceeds panel dimensions */
-
 
107
    MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
-
 
108
    MODE_ONE_WIDTH,     /* only one width is supported */
-
 
109
    MODE_ONE_HEIGHT,    /* only one height is supported */
-
 
110
    MODE_ONE_SIZE,      /* only one resolution is supported */
-
 
111
    MODE_NO_REDUCED,    /* monitor doesn't accept reduced blanking */
-
 
112
    MODE_NO_STEREO,	/* stereo modes not supported */
-
 
113
    MODE_UNVERIFIED = -3, /* mode needs to reverified */
-
 
114
    MODE_BAD = -2,	/* unspecified reason */
-
 
115
    MODE_ERROR	= -1	/* error condition */
72
	return (int64_t)*((int64_t *)&val);
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), \
73
}
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) /* halve V values for interlacing */
-
 
130
#define CRTC_STEREO_DOUBLE	(1 << 1) /* adjust timings for stereo modes */
-
 
131
 
-
 
132
#define DRM_MODE_FLAG_3D_MAX	DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
74
static inline uint64_t I642U64(int64_t val)
133
 
-
 
134
struct drm_display_mode {
-
 
135
	/* Header */
-
 
136
	struct list_head head;
75
{
137
	struct drm_mode_object base;
76
	return (uint64_t)*((uint64_t *)&val);
138
 
-
 
Line 139... Line 77...
139
	char name[DRM_DISPLAY_MODE_LEN];
77
}
140
 
78
 
-
 
79
/* rotation property bits */
-
 
80
#define DRM_ROTATE_0	0
-
 
81
#define DRM_ROTATE_90	1
-
 
82
#define DRM_ROTATE_180	2
-
 
83
#define DRM_ROTATE_270	3
Line 141... Line 84...
141
	enum drm_mode_status status;
84
#define DRM_REFLECT_X	4
142
	unsigned int type;
85
#define DRM_REFLECT_Y	5
143
 
-
 
144
	/* Proposed mode values */
-
 
145
	int clock;		/* in kHz */
-
 
146
	int hdisplay;
-
 
147
	int hsync_start;
-
 
148
	int hsync_end;
-
 
149
	int htotal;
-
 
150
	int hskew;
86
 
151
	int vdisplay;
-
 
152
	int vsync_start;
-
 
153
	int vsync_end;
-
 
154
	int vtotal;
-
 
155
	int vscan;
87
enum drm_connector_force {
156
	unsigned int flags;
-
 
157
 
-
 
158
	/* Addressable image size (may be 0 for projectors, etc.) */
-
 
159
	int width_mm;
-
 
160
	int height_mm;
-
 
161
 
-
 
162
	/* Actual mode we give to hw */
-
 
163
	int crtc_clock;		/* in KHz */
-
 
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
	/* Driver private mode info */
-
 
179
	int private_size;
-
 
180
	int *private;
-
 
181
	int private_flags;
-
 
182
 
88
	DRM_FORCE_UNSPECIFIED,
183
	int vrefresh;		/* in Hz */
89
	DRM_FORCE_OFF,
Line 184... Line -...
184
	int hsync;		/* in kHz */
-
 
185
	enum hdmi_picture_aspect picture_aspect_ratio;
-
 
186
};
90
	DRM_FORCE_ON,         /* force on analog part normally */
187
 
-
 
Line 188... Line 91...
188
static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode)
91
	DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
189
{
92
};
190
	return mode->flags & DRM_MODE_FLAG_3D_MASK;
93
 
191
}
94
#include 
Line 225... Line 128...
225
	unsigned int bpc;
128
	unsigned int bpc;
Line 226... Line 129...
226
 
129
 
227
	enum subpixel_order subpixel_order;
130
	enum subpixel_order subpixel_order;
Line -... Line 131...
-
 
131
	u32 color_formats;
-
 
132
 
-
 
133
	/* Mask of supported hdmi deep color modes */
228
	u32 color_formats;
134
	u8 edid_hdmi_dc_modes;
229
 
135
 
Line 230... Line 136...
230
	u8 cea_rev;
136
	u8 cea_rev;
231
};
137
};
Line 305... Line 211...
305
    struct      drm_mode_object base;
211
    struct      drm_mode_object base;
306
    uint32_t    flags;
212
    uint32_t    flags;
307
    char        name[DRM_PROP_NAME_LEN];
213
    char        name[DRM_PROP_NAME_LEN];
308
    uint32_t    num_values;
214
    uint32_t    num_values;
309
    uint64_t    *values;
215
    uint64_t    *values;
-
 
216
	struct drm_device *dev;
Line 310... Line 217...
310
 
217
 
311
	struct list_head enum_blob_list;
218
	struct list_head enum_blob_list;
Line -... Line 219...
-
 
219
};
-
 
220
 
-
 
221
void drm_modeset_lock_all(struct drm_device *dev);
-
 
222
void drm_modeset_unlock_all(struct drm_device *dev);
312
};
223
void drm_warn_on_modeset_not_all_locked(struct drm_device *dev);
313
 
224
 
314
struct drm_crtc;
225
struct drm_crtc;
315
struct drm_connector;
226
struct drm_connector;
316
struct drm_encoder;
227
struct drm_encoder;
Line 384... Line 295...
384
 
295
 
385
/**
296
/**
386
 * drm_crtc - central CRTC control structure
297
 * drm_crtc - central CRTC control structure
387
 * @dev: parent DRM device
298
 * @dev: parent DRM device
-
 
299
 * @head: list management
388
 * @head: list management
300
 * @mutex: per-CRTC locking
-
 
301
 * @base: base KMS object for ID tracking etc.
-
 
302
 * @primary: primary plane for this CRTC
389
 * @base: base KMS object for ID tracking etc.
303
 * @cursor: cursor plane for this CRTC
390
 * @enabled: is this CRTC enabled?
304
 * @enabled: is this CRTC enabled?
391
 * @mode: current mode timings
305
 * @mode: current mode timings
392
 * @hwmode: mode timings as programmed to hw regs
306
 * @hwmode: mode timings as programmed to hw regs
393
 * @invert_dimensions: for purposes of error checking crtc vs fb sizes,
307
 * @invert_dimensions: for purposes of error checking crtc vs fb sizes,
Line 407... Line 321...
407
 * Each CRTC may have one or more connectors associated with it.  This structure
321
 * Each CRTC may have one or more connectors associated with it.  This structure
408
 * allows the CRTC to be controlled.
322
 * allows the CRTC to be controlled.
409
 */
323
 */
410
struct drm_crtc {
324
struct drm_crtc {
411
	struct drm_device *dev;
325
	struct drm_device *dev;
-
 
326
	struct device_node *port;
412
	struct list_head head;
327
	struct list_head head;
Line 413... Line 328...
413
 
328
 
414
	/**
329
	/**
415
	 * crtc mutex
330
	 * crtc mutex
416
	 *
331
	 *
417
	 * This provides a read lock for the overall crtc state (mode, dpms
332
	 * This provides a read lock for the overall crtc state (mode, dpms
418
	 * state, ...) and a write lock for everything which can be update
333
	 * state, ...) and a write lock for everything which can be update
419
	 * without a full modeset (fb, cursor data, ...)
334
	 * without a full modeset (fb, cursor data, ...)
420
	 */
335
	 */
Line 421... Line 336...
421
	struct mutex mutex;
336
	struct drm_modeset_lock mutex;
Line 422... Line 337...
422
 
337
 
-
 
338
	struct drm_mode_object base;
423
	struct drm_mode_object base;
339
 
-
 
340
	/* primary and cursor planes for CRTC */
-
 
341
	struct drm_plane *primary;
-
 
342
	struct drm_plane *cursor;
-
 
343
 
Line 424... Line 344...
424
 
344
	/* position of cursor plane on crtc */
425
	/* framebuffer the connector is currently bound to */
345
	int cursor_x;
426
	struct drm_framebuffer *fb;
346
	int cursor_y;
Line 512... Line 432...
512
/**
432
/**
513
 * drm_encoder - central DRM encoder structure
433
 * drm_encoder - central DRM encoder structure
514
 * @dev: parent DRM device
434
 * @dev: parent DRM device
515
 * @head: list management
435
 * @head: list management
516
 * @base: base KMS object
436
 * @base: base KMS object
-
 
437
 * @name: encoder name
517
 * @encoder_type: one of the %DRM_MODE_ENCODER_ types in drm_mode.h
438
 * @encoder_type: one of the %DRM_MODE_ENCODER_ types in drm_mode.h
518
 * @possible_crtcs: bitmask of potential CRTC bindings
439
 * @possible_crtcs: bitmask of potential CRTC bindings
519
 * @possible_clones: bitmask of potential sibling encoders for cloning
440
 * @possible_clones: bitmask of potential sibling encoders for cloning
520
 * @crtc: currently bound CRTC
441
 * @crtc: currently bound CRTC
521
 * @bridge: bridge associated to the encoder
442
 * @bridge: bridge associated to the encoder
Line 528... Line 449...
528
struct drm_encoder {
449
struct drm_encoder {
529
	struct drm_device *dev;
450
	struct drm_device *dev;
530
	struct list_head head;
451
	struct list_head head;
Line 531... Line 452...
531
 
452
 
-
 
453
	struct drm_mode_object base;
532
	struct drm_mode_object base;
454
	char *name;
533
	int encoder_type;
455
	int encoder_type;
534
	uint32_t possible_crtcs;
456
	uint32_t possible_crtcs;
Line 535... Line 457...
535
	uint32_t possible_clones;
457
	uint32_t possible_clones;
536
 
458
 
537
	struct drm_crtc *crtc;
459
	struct drm_crtc *crtc;
538
	struct drm_bridge *bridge;
460
	struct drm_bridge *bridge;
539
	const struct drm_encoder_funcs *funcs;
461
	const struct drm_encoder_funcs *funcs;
Line 540... Line -...
540
	void *helper_private;
-
 
541
};
-
 
542
 
-
 
543
enum drm_connector_force {
-
 
544
	DRM_FORCE_UNSPECIFIED,
-
 
545
	DRM_FORCE_OFF,
-
 
546
	DRM_FORCE_ON,         /* force on analog part normally */
-
 
547
	DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
462
	void *helper_private;
548
};
463
};
549
 
464
 
550
/* should we poll this connector for connects and disconnects */
465
/* should we poll this connector for connects and disconnects */
551
/* hot plug detectable */
466
/* hot plug detectable */
Line 563... Line 478...
563
 * @dev: parent DRM device
478
 * @dev: parent DRM device
564
 * @kdev: kernel device for sysfs attributes
479
 * @kdev: kernel device for sysfs attributes
565
 * @attr: sysfs attributes
480
 * @attr: sysfs attributes
566
 * @head: list management
481
 * @head: list management
567
 * @base: base KMS object
482
 * @base: base KMS object
-
 
483
 * @name: connector name
568
 * @connector_type: one of the %DRM_MODE_CONNECTOR_ types from drm_mode.h
484
 * @connector_type: one of the %DRM_MODE_CONNECTOR_ types from drm_mode.h
569
 * @connector_type_id: index into connector type enum
485
 * @connector_type_id: index into connector type enum
570
 * @interlace_allowed: can this connector handle interlaced modes?
486
 * @interlace_allowed: can this connector handle interlaced modes?
571
 * @doublescan_allowed: can this connector handle doublescan?
487
 * @doublescan_allowed: can this connector handle doublescan?
572
 * @modes: modes available on this connector (from fill_modes() + user)
488
 * @modes: modes available on this connector (from fill_modes() + user)
Line 601... Line 517...
601
	struct device_attribute *attr;
517
	struct device_attribute *attr;
602
	struct list_head head;
518
	struct list_head head;
Line 603... Line 519...
603
 
519
 
Line -... Line 520...
-
 
520
	struct drm_mode_object base;
604
	struct drm_mode_object base;
521
 
605
 
522
	char *name;
606
	int connector_type;
523
	int connector_type;
607
	int connector_type_id;
524
	int connector_type_id;
608
	bool interlace_allowed;
525
	bool interlace_allowed;
Line 619... Line 536...
619
	const struct drm_connector_funcs *funcs;
536
	const struct drm_connector_funcs *funcs;
Line 620... Line 537...
620
 
537
 
621
	struct drm_property_blob *edid_blob_ptr;
538
	struct drm_property_blob *edid_blob_ptr;
Line -... Line 539...
-
 
539
	struct drm_object_properties properties;
-
 
540
 
622
	struct drm_object_properties properties;
541
	struct drm_property_blob *path_blob_ptr;
Line 623... Line 542...
623
 
542
 
624
	uint8_t polled; /* DRM_CONNECTOR_POLL_* */
543
	uint8_t polled; /* DRM_CONNECTOR_POLL_* */
Line 625... Line 544...
625
 
544
 
Line 626... Line 545...
626
	/* requested DPMS state */
545
	/* requested DPMS state */
627
	int dpms;
546
	int dpms;
-
 
547
 
628
 
548
	void *helper_private;
629
	void *helper_private;
549
 
Line 630... Line 550...
630
 
550
	/* forced on connector */
631
	/* forced on connector */
551
	enum drm_connector_force force;
Line 640... Line 560...
640
	bool latency_present[2];
560
	bool latency_present[2];
641
	int video_latency[2];	/* [0]: progressive, [1]: interlaced */
561
	int video_latency[2];	/* [0]: progressive, [1]: interlaced */
642
	int audio_latency[2];
562
	int audio_latency[2];
643
	int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
563
	int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
644
	unsigned bad_edid_counter;
564
	unsigned bad_edid_counter;
-
 
565
 
-
 
566
	struct dentry *debugfs_entry;
645
};
567
};
Line 646... Line 568...
646
 
568
 
647
/**
569
/**
648
 * drm_plane_funcs - driver plane control functions
570
 * drm_plane_funcs - driver plane control functions
Line 663... Line 585...
663
 
585
 
664
	int (*set_property)(struct drm_plane *plane,
586
	int (*set_property)(struct drm_plane *plane,
665
			    struct drm_property *property, uint64_t val);
587
			    struct drm_property *property, uint64_t val);
Line -... Line 588...
-
 
588
};
-
 
589
 
-
 
590
enum drm_plane_type {
-
 
591
	DRM_PLANE_TYPE_OVERLAY,
-
 
592
	DRM_PLANE_TYPE_PRIMARY,
-
 
593
	DRM_PLANE_TYPE_CURSOR,
666
};
594
};
667
 
595
 
668
/**
596
/**
669
 * drm_plane - central DRM plane control structure
597
 * drm_plane - central DRM plane control structure
670
 * @dev: DRM device this plane belongs to
598
 * @dev: DRM device this plane belongs to
Line 675... Line 603...
675
 * @format_count: number of formats supported
603
 * @format_count: number of formats supported
676
 * @crtc: currently bound CRTC
604
 * @crtc: currently bound CRTC
677
 * @fb: currently bound fb
605
 * @fb: currently bound fb
678
 * @funcs: helper functions
606
 * @funcs: helper functions
679
 * @properties: property tracking for this plane
607
 * @properties: property tracking for this plane
-
 
608
 * @type: type of plane (overlay, primary, cursor)
680
 */
609
 */
681
struct drm_plane {
610
struct drm_plane {
682
	struct drm_device *dev;
611
	struct drm_device *dev;
683
	struct list_head head;
612
	struct list_head head;
Line 692... Line 621...
692
	struct drm_framebuffer *fb;
621
	struct drm_framebuffer *fb;
Line 693... Line 622...
693
 
622
 
Line 694... Line 623...
694
	const struct drm_plane_funcs *funcs;
623
	const struct drm_plane_funcs *funcs;
-
 
624
 
-
 
625
	struct drm_object_properties properties;
695
 
626
 
Line 696... Line 627...
696
	struct drm_object_properties properties;
627
	enum drm_plane_type type;
697
};
628
};
698
 
629
 
Line 833... Line 764...
833
 * enumerated by the driver are added here, as are global properties.  Some
764
 * enumerated by the driver are added here, as are global properties.  Some
834
 * global restrictions are also here, e.g. dimension restrictions.
765
 * global restrictions are also here, e.g. dimension restrictions.
835
 */
766
 */
836
struct drm_mode_config {
767
struct drm_mode_config {
837
	struct mutex mutex; /* protects configuration (mode lists etc.) */
768
	struct mutex mutex; /* protects configuration (mode lists etc.) */
-
 
769
	struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */
-
 
770
	struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */
838
	struct mutex idr_mutex; /* for IDR management */
771
	struct mutex idr_mutex; /* for IDR management */
839
    struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
772
    struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
840
	/* this is limited to one for now */
773
	/* this is limited to one for now */
Line 854... Line 787...
854
	struct list_head connector_list;
787
	struct list_head connector_list;
855
	int num_bridge;
788
	int num_bridge;
856
	struct list_head bridge_list;
789
	struct list_head bridge_list;
857
	int num_encoder;
790
	int num_encoder;
858
	struct list_head encoder_list;
791
	struct list_head encoder_list;
-
 
792
 
-
 
793
	/*
-
 
794
	 * Track # of overlay planes separately from # of total planes.  By
-
 
795
	 * default we only advertise overlay planes to userspace; if userspace
-
 
796
	 * sets the "universal plane" capability bit, we'll go ahead and
-
 
797
	 * expose all planes.
-
 
798
	 */
-
 
799
	int num_overlay_plane;
859
	int num_plane;
800
	int num_total_plane;
860
	struct list_head plane_list;
801
	struct list_head plane_list;
Line 861... Line 802...
861
 
802
 
862
	int num_crtc;
803
	int num_crtc;
Line 876... Line 817...
876
 
817
 
877
	/* pointers to standard properties */
818
	/* pointers to standard properties */
878
	struct list_head property_blob_list;
819
	struct list_head property_blob_list;
879
	struct drm_property *edid_property;
820
	struct drm_property *edid_property;
-
 
821
	struct drm_property *dpms_property;
-
 
822
	struct drm_property *path_property;
Line 880... Line 823...
880
	struct drm_property *dpms_property;
823
	struct drm_property *plane_type_property;
881
 
824
 
882
	/* DVI-I properties */
825
	/* DVI-I properties */
Line 898... Line 841...
898
	struct drm_property *tv_saturation_property;
841
	struct drm_property *tv_saturation_property;
899
	struct drm_property *tv_hue_property;
842
	struct drm_property *tv_hue_property;
Line 900... Line 843...
900
 
843
 
901
	/* Optional properties */
844
	/* Optional properties */
-
 
845
	struct drm_property *scaling_mode_property;
902
	struct drm_property *scaling_mode_property;
846
	struct drm_property *aspect_ratio_property;
Line 903... Line 847...
903
	struct drm_property *dirty_info_property;
847
	struct drm_property *dirty_info_property;
904
 
848
 
Line 905... Line 849...
905
	/* dumb ioctl parameters */
849
	/* dumb ioctl parameters */
906
	uint32_t preferred_depth, prefer_shadow;
850
	uint32_t preferred_depth, prefer_shadow;
-
 
851
 
-
 
852
	/* whether async page flip is supported or not */
-
 
853
	bool async_page_flip;
907
 
854
 
Line 908... Line 855...
908
	/* whether async page flip is supported or not */
855
	/* cursor size */
909
	bool async_page_flip;
856
	uint32_t cursor_width, cursor_height;
910
};
857
};
Line 921... Line 868...
921
struct drm_prop_enum_list {
868
struct drm_prop_enum_list {
922
	int type;
869
	int type;
923
	char *name;
870
	char *name;
924
};
871
};
Line 925... Line 872...
925
 
872
 
926
extern void drm_modeset_lock_all(struct drm_device *dev);
873
extern int drm_crtc_init_with_planes(struct drm_device *dev,
-
 
874
				     struct drm_crtc *crtc,
-
 
875
				     struct drm_plane *primary,
927
extern void drm_modeset_unlock_all(struct drm_device *dev);
876
				     struct drm_plane *cursor,
928
extern void drm_warn_on_modeset_not_all_locked(struct drm_device *dev);
-
 
929
 
877
				     const struct drm_crtc_funcs *funcs);
930
extern int drm_crtc_init(struct drm_device *dev,
878
extern int drm_crtc_init(struct drm_device *dev,
931
			  struct drm_crtc *crtc,
879
			  struct drm_crtc *crtc,
932
			  const struct drm_crtc_funcs *funcs);
880
			  const struct drm_crtc_funcs *funcs);
933
extern void drm_crtc_cleanup(struct drm_crtc *crtc);
881
extern void drm_crtc_cleanup(struct drm_crtc *crtc);
Line 949... Line 897...
949
extern void drm_connector_ida_destroy(void);
897
extern void drm_connector_ida_destroy(void);
950
extern int drm_connector_init(struct drm_device *dev,
898
extern int drm_connector_init(struct drm_device *dev,
951
			    struct drm_connector *connector,
899
			    struct drm_connector *connector,
952
			    const struct drm_connector_funcs *funcs,
900
			    const struct drm_connector_funcs *funcs,
953
			    int connector_type);
901
			    int connector_type);
-
 
902
int drm_connector_register(struct drm_connector *connector);
-
 
903
void drm_connector_unregister(struct drm_connector *connector);
Line 954... Line 904...
954
 
904
 
955
extern void drm_connector_cleanup(struct drm_connector *connector);
905
extern void drm_connector_cleanup(struct drm_connector *connector);
956
/* helper to unplug all connectors from sysfs for device */
906
/* helper to unplug all connectors from sysfs for device */
Line 976... Line 926...
976
				       struct drm_crtc *crtc)
926
				       struct drm_crtc *crtc)
977
{
927
{
978
	return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
928
	return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
979
}
929
}
Line -... Line 930...
-
 
930
 
-
 
931
extern int drm_universal_plane_init(struct drm_device *dev,
-
 
932
				    struct drm_plane *plane,
-
 
933
				    unsigned long possible_crtcs,
-
 
934
				    const struct drm_plane_funcs *funcs,
-
 
935
				    const uint32_t *formats,
-
 
936
				    uint32_t format_count,
980
 
937
				    enum drm_plane_type type);
981
extern int drm_plane_init(struct drm_device *dev,
938
extern int drm_plane_init(struct drm_device *dev,
982
			  struct drm_plane *plane,
939
			  struct drm_plane *plane,
983
			  unsigned long possible_crtcs,
940
			  unsigned long possible_crtcs,
984
			  const struct drm_plane_funcs *funcs,
941
			  const struct drm_plane_funcs *funcs,
985
			  const uint32_t *formats, uint32_t format_count,
942
			  const uint32_t *formats, uint32_t format_count,
986
			  bool priv);
943
			  bool is_primary);
987
extern void drm_plane_cleanup(struct drm_plane *plane);
944
extern void drm_plane_cleanup(struct drm_plane *plane);
-
 
945
extern void drm_plane_force_disable(struct drm_plane *plane);
-
 
946
extern int drm_crtc_check_viewport(const struct drm_crtc *crtc,
-
 
947
				   int x, int y,
-
 
948
				   const struct drm_display_mode *mode,
Line 988... Line 949...
988
extern void drm_plane_force_disable(struct drm_plane *plane);
949
				   const struct drm_framebuffer *fb);
Line 989... Line -...
989
 
-
 
990
extern void drm_encoder_cleanup(struct drm_encoder *encoder);
950
 
-
 
951
extern void drm_encoder_cleanup(struct drm_encoder *encoder);
991
 
952
 
992
extern const char *drm_get_connector_name(const struct drm_connector *connector);
953
extern const char *drm_get_connector_status_name(enum drm_connector_status status);
993
extern const char *drm_get_connector_status_name(enum drm_connector_status status);
954
extern const char *drm_get_subpixel_order_name(enum subpixel_order order);
994
extern const char *drm_get_dpms_name(int val);
955
extern const char *drm_get_dpms_name(int val);
995
extern const char *drm_get_dvi_i_subconnector_name(int val);
956
extern const char *drm_get_dvi_i_subconnector_name(int val);
996
extern const char *drm_get_dvi_i_select_name(int val);
957
extern const char *drm_get_dvi_i_select_name(int val);
997
extern const char *drm_get_tv_subconnector_name(int val);
958
extern const char *drm_get_tv_subconnector_name(int val);
-
 
959
extern const char *drm_get_tv_select_name(int val);
-
 
960
extern void drm_fb_release(struct drm_file *file_priv);
998
extern const char *drm_get_tv_select_name(int val);
961
extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
999
extern void drm_fb_release(struct drm_file *file_priv);
962
extern void drm_mode_group_destroy(struct drm_mode_group *group);
1000
extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group);
963
extern void drm_reinit_primary_mode_group(struct drm_device *dev);
1001
extern bool drm_probe_ddc(struct i2c_adapter *adapter);
964
extern bool drm_probe_ddc(struct i2c_adapter *adapter);
1002
extern struct edid *drm_get_edid(struct drm_connector *connector,
965
extern struct edid *drm_get_edid(struct drm_connector *connector,
1003
				 struct i2c_adapter *adapter);
-
 
1004
extern struct edid *drm_edid_duplicate(const struct edid *edid);
-
 
1005
extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
-
 
1006
extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
-
 
1007
extern void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);
-
 
1008
extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
966
				 struct i2c_adapter *adapter);
1009
						   const struct drm_display_mode *mode);
967
extern struct edid *drm_edid_duplicate(const struct edid *edid);
1010
extern void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
968
extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
1011
extern void drm_mode_config_init(struct drm_device *dev);
-
 
1012
extern void drm_mode_config_reset(struct drm_device *dev);
-
 
1013
extern void drm_mode_config_cleanup(struct drm_device *dev);
-
 
1014
extern void drm_mode_set_name(struct drm_display_mode *mode);
-
 
1015
extern bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
-
 
1016
extern bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
969
extern void drm_mode_config_init(struct drm_device *dev);
1017
extern int drm_mode_width(const struct drm_display_mode *mode);
-
 
1018
extern int drm_mode_height(const struct drm_display_mode *mode);
-
 
1019
 
-
 
1020
/* for us by fb module */
-
 
1021
extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
-
 
1022
extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
-
 
1023
extern void drm_mode_validate_size(struct drm_device *dev,
-
 
1024
                  struct list_head *mode_list,
-
 
1025
                  int maxX, int maxY, int maxPitch);
-
 
1026
extern void drm_mode_prune_invalid(struct drm_device *dev,
-
 
1027
                  struct list_head *mode_list, bool verbose);
970
extern void drm_mode_config_reset(struct drm_device *dev);
1028
extern void drm_mode_sort(struct list_head *mode_list);
-
 
1029
extern int drm_mode_hsync(const struct drm_display_mode *mode);
971
extern void drm_mode_config_cleanup(struct drm_device *dev);
1030
extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
-
 
1031
extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
972
 
1032
				  int adjust_flags);
973
extern int drm_mode_connector_set_path_property(struct drm_connector *connector,
-
 
974
						char *path);
-
 
975
extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
-
 
976
                       struct edid *edid);
-
 
977
 
-
 
978
static inline bool drm_property_type_is(struct drm_property *property,
-
 
979
		uint32_t type)
-
 
980
{
-
 
981
	/* instanceof for props.. handles extended type vs original types: */
-
 
982
	if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
-
 
983
		return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type;
-
 
984
	return property->flags & type;
-
 
985
}
-
 
986
 
-
 
987
static inline bool drm_property_type_valid(struct drm_property *property)
-
 
988
{
-
 
989
	if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE)
-
 
990
		return !(property->flags & DRM_MODE_PROP_LEGACY_TYPE);
1033
extern void drm_mode_connector_list_update(struct drm_connector *connector);
991
	return !!(property->flags & DRM_MODE_PROP_LEGACY_TYPE);
1034
extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
992
}
1035
                       struct edid *edid);
993
 
1036
extern int drm_object_property_set_value(struct drm_mode_object *obj,
994
extern int drm_object_property_set_value(struct drm_mode_object *obj,
1037
					 struct drm_property *property,
995
					 struct drm_property *property,
Line 1060... Line 1018...
1060
					 const struct drm_prop_enum_list *props,
1018
					 const struct drm_prop_enum_list *props,
1061
					 int num_values);
1019
					 int num_values);
1062
struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
1020
struct drm_property *drm_property_create_bitmask(struct drm_device *dev,
1063
					 int flags, const char *name,
1021
					 int flags, const char *name,
1064
					 const struct drm_prop_enum_list *props,
1022
					 const struct drm_prop_enum_list *props,
1065
					 int num_values);
1023
					 int num_props,
-
 
1024
					 uint64_t supported_bits);
1066
struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
1025
struct drm_property *drm_property_create_range(struct drm_device *dev, int flags,
1067
					 const char *name,
1026
					 const char *name,
1068
					 uint64_t min, uint64_t max);
1027
					 uint64_t min, uint64_t max);
-
 
1028
struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
-
 
1029
					 int flags, const char *name,
-
 
1030
					 int64_t min, int64_t max);
-
 
1031
struct drm_property *drm_property_create_object(struct drm_device *dev,
-
 
1032
					 int flags, const char *name, uint32_t type);
1069
extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
1033
extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
1070
extern int drm_property_add_enum(struct drm_property *property, int index,
1034
extern int drm_property_add_enum(struct drm_property *property, int index,
1071
				 uint64_t value, const char *name);
1035
				 uint64_t value, const char *name);
1072
extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
1036
extern int drm_mode_create_dvi_i_properties(struct drm_device *dev);
1073
extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
1037
extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats,
1074
				     char *formats[]);
1038
				     char *formats[]);
1075
extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
1039
extern int drm_mode_create_scaling_mode_property(struct drm_device *dev);
-
 
1040
extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
1076
extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
1041
extern int drm_mode_create_dirty_info_property(struct drm_device *dev);
1077
extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
-
 
Line 1078... Line 1042...
1078
 
1042
 
1079
extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
1043
extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
1080
					     struct drm_encoder *encoder);
-
 
1081
extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
-
 
1082
					   struct drm_encoder *encoder);
1044
					     struct drm_encoder *encoder);
1083
extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
1045
extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
1084
					 int gamma_size);
1046
					 int gamma_size);
1085
extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
1047
extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
-
 
1048
		uint32_t id, uint32_t type);
1086
		uint32_t id, uint32_t type);
1049
 
1087
/* IOCTLs */
1050
/* IOCTLs */
1088
extern int drm_mode_getresources(struct drm_device *dev,
1051
extern int drm_mode_getresources(struct drm_device *dev,
1089
				 void *data, struct drm_file *file_priv);
1052
				 void *data, struct drm_file *file_priv);
1090
extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
1053
extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
Line 1127... Line 1090...
1127
extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
1090
extern int drm_mode_gamma_get_ioctl(struct drm_device *dev,
1128
				    void *data, struct drm_file *file_priv);
1091
				    void *data, struct drm_file *file_priv);
1129
extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
1092
extern int drm_mode_gamma_set_ioctl(struct drm_device *dev,
1130
				    void *data, struct drm_file *file_priv);
1093
				    void *data, struct drm_file *file_priv);
1131
extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
1094
extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
-
 
1095
extern enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code);
1132
extern bool drm_detect_hdmi_monitor(struct edid *edid);
1096
extern bool drm_detect_hdmi_monitor(struct edid *edid);
1133
extern bool drm_detect_monitor_audio(struct edid *edid);
1097
extern bool drm_detect_monitor_audio(struct edid *edid);
1134
extern bool drm_rgb_quant_range_selectable(struct edid *edid);
1098
extern bool drm_rgb_quant_range_selectable(struct edid *edid);
1135
extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
1099
extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
1136
				    void *data, struct drm_file *file_priv);
1100
				    void *data, struct drm_file *file_priv);
1137
extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
-
 
1138
				int hdisplay, int vdisplay, int vrefresh,
-
 
1139
				bool reduced, bool interlaced, bool margins);
-
 
1140
extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
-
 
1141
				int hdisplay, int vdisplay, int vrefresh,
-
 
1142
				bool interlaced, int margins);
-
 
1143
extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
-
 
1144
				int hdisplay, int vdisplay, int vrefresh,
-
 
1145
				bool interlaced, int margins, int GTF_M,
-
 
1146
				int GTF_2C, int GTF_K, int GTF_2J);
-
 
1147
extern int drm_add_modes_noedid(struct drm_connector *connector,
1101
extern int drm_add_modes_noedid(struct drm_connector *connector,
1148
				int hdisplay, int vdisplay);
1102
				int hdisplay, int vdisplay);
1149
extern void drm_set_preferred_mode(struct drm_connector *connector,
1103
extern void drm_set_preferred_mode(struct drm_connector *connector,
1150
				   int hpref, int vpref);
1104
				   int hpref, int vpref);
Line 1172... Line 1126...
1172
extern int drm_format_num_planes(uint32_t format);
1126
extern int drm_format_num_planes(uint32_t format);
1173
extern int drm_format_plane_cpp(uint32_t format, int plane);
1127
extern int drm_format_plane_cpp(uint32_t format, int plane);
1174
extern int drm_format_horz_chroma_subsampling(uint32_t format);
1128
extern int drm_format_horz_chroma_subsampling(uint32_t format);
1175
extern int drm_format_vert_chroma_subsampling(uint32_t format);
1129
extern int drm_format_vert_chroma_subsampling(uint32_t format);
1176
extern const char *drm_get_format_name(uint32_t format);
1130
extern const char *drm_get_format_name(uint32_t format);
-
 
1131
extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
-
 
1132
							      unsigned int supported_rotations);
-
 
1133
extern unsigned int drm_rotation_simplify(unsigned int rotation,
-
 
1134
					  unsigned int supported_rotations);
Line 1177... Line 1135...
1177
 
1135
 
-
 
1136
/* Helpers */
-
 
1137
 
-
 
1138
static inline struct drm_plane *drm_plane_find(struct drm_device *dev,
-
 
1139
		uint32_t id)
-
 
1140
{
-
 
1141
	struct drm_mode_object *mo;
-
 
1142
	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE);
-
 
1143
	return mo ? obj_to_plane(mo) : NULL;
-
 
1144
}
1178
/* Helpers */
1145
 
1179
static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
1146
static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev,
1180
	uint32_t id)
1147
	uint32_t id)
1181
{
1148
{
1182
	struct drm_mode_object *mo;
1149
	struct drm_mode_object *mo;
Line 1190... Line 1157...
1190
	struct drm_mode_object *mo;
1157
	struct drm_mode_object *mo;
1191
	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
1158
	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER);
1192
	return mo ? obj_to_encoder(mo) : NULL;
1159
	return mo ? obj_to_encoder(mo) : NULL;
1193
}
1160
}
Line -... Line 1161...
-
 
1161
 
-
 
1162
static inline struct drm_connector *drm_connector_find(struct drm_device *dev,
-
 
1163
		uint32_t id)
-
 
1164
{
-
 
1165
	struct drm_mode_object *mo;
-
 
1166
	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
-
 
1167
	return mo ? obj_to_connector(mo) : NULL;
-
 
1168
}
-
 
1169
 
-
 
1170
static inline struct drm_property *drm_property_find(struct drm_device *dev,
-
 
1171
		uint32_t id)
-
 
1172
{
-
 
1173
	struct drm_mode_object *mo;
-
 
1174
	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY);
-
 
1175
	return mo ? obj_to_property(mo) : NULL;
-
 
1176
}
-
 
1177
 
-
 
1178
static inline struct drm_property_blob *
-
 
1179
drm_property_blob_find(struct drm_device *dev, uint32_t id)
-
 
1180
{
-
 
1181
	struct drm_mode_object *mo;
-
 
1182
	mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_BLOB);
-
 
1183
	return mo ? obj_to_blob(mo) : NULL;
-
 
1184
}
-
 
1185
 
-
 
1186
/* Plane list iterator for legacy (overlay only) planes. */
-
 
1187
#define drm_for_each_legacy_plane(plane, planelist) \
-
 
1188
	list_for_each_entry(plane, planelist, head) \
-
 
1189
		if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1194
 
1190