aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-03-18 05:09:10 -0400
committerDave Airlie <airlied@redhat.com>2014-03-18 05:09:10 -0400
commit978c6050165bba52eab7ef3581d447eb215def77 (patch)
treef34ccf67a789fe7e8ec88b054b33a6c2e688fdf7 /include/drm
parent8ad2bc9796994ecba9f4ba2fc9abca27ee9d193d (diff)
parentfc1645ac826c82ebad4402aabbf65595b671ecca (diff)
Merge branch 'drm-docs' of ssh://people.freedesktop.org/~danvet/drm into drm-next
Here's my drm documentation update and driver api polish pull request. Alex reviewed the entire pile, I've applied a little bit of spelling polish in a few places since then and otherwise the Usual Suspects (David, Rob, ...) don't seem up to have another look at it (I've poked them on irc). So I think it's as good as it gets ;-) Note that I've dropped the final imx breaker patch since that's blocked on imx getting sane. Once that's landed I'll ping you to pick up that straggler. * 'drm-docs' of ssh://people.freedesktop.org/~danvet/drm: (34 commits) drm/imx: remove drm_mode_connector_detach_encoder harder drm: kerneldoc polish for drm_crtc.c drm: kerneldoc polish for drm_crtc_helper.c drm: drop error code for drm_helper_resume_force_mode drm/crtc-helper: remove LOCKING from kerneldoc drm: remove return value from drm_helper_mode_fill_fb_struct drm/doc: Fix misplaced </para> drm: remove drm_display_mode->private_size drm: polish function kerneldoc for drm_modes.[hc] drm/modes: drop maxPitch from drm_mode_validate_size drm/modes: drop return value from drm_display_mode_from_videomode drm/modes: remove drm_mode_height/width drm: extract drm_modes.h for drm_crtc.h functions drm: move drm_mode related functions into drm_modes.c drm/doc: Repleace LOCKING kerneldoc sections in drm_modes.c drm/doc: Integrate drm_modes.c kerneldoc drm/kms: rip out drm_mode_connector_detach_encoder drm/doc: Add function reference documentation for drm_mm.c drm/doc: Overview documentation for drm_mm.c drm/mm: Remove MM_UNUSED_TARGET ...
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/drmP.h29
-rw-r--r--include/drm/drm_crtc.h174
-rw-r--r--include/drm/drm_crtc_helper.h6
-rw-r--r--include/drm/drm_mm.h154
-rw-r--r--include/drm/drm_modes.h237
5 files changed, 372 insertions, 228 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 538079030be0..319ec1eb0372 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1056,21 +1056,6 @@ struct drm_minor {
1056 struct drm_mode_group mode_group; 1056 struct drm_mode_group mode_group;
1057}; 1057};
1058 1058
1059/* mode specified on the command line */
1060struct drm_cmdline_mode {
1061 bool specified;
1062 bool refresh_specified;
1063 bool bpp_specified;
1064 int xres, yres;
1065 int bpp;
1066 int refresh;
1067 bool rb;
1068 bool interlace;
1069 bool cvt;
1070 bool margins;
1071 enum drm_connector_force force;
1072};
1073
1074 1059
1075struct drm_pending_vblank_event { 1060struct drm_pending_vblank_event {
1076 struct drm_pending_event base; 1061 struct drm_pending_event base;
@@ -1417,20 +1402,6 @@ extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1417extern void drm_calc_timestamping_constants(struct drm_crtc *crtc, 1402extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
1418 const struct drm_display_mode *mode); 1403 const struct drm_display_mode *mode);
1419 1404
1420extern bool
1421drm_mode_parse_command_line_for_connector(const char *mode_option,
1422 struct drm_connector *connector,
1423 struct drm_cmdline_mode *mode);
1424
1425extern struct drm_display_mode *
1426drm_mode_create_from_cmdline_mode(struct drm_device *dev,
1427 struct drm_cmdline_mode *cmd);
1428
1429extern int drm_display_mode_from_videomode(const struct videomode *vm,
1430 struct drm_display_mode *dmode);
1431extern int of_get_drm_display_mode(struct device_node *np,
1432 struct drm_display_mode *dmode,
1433 int index);
1434 1405
1435/* Modesetting support */ 1406/* Modesetting support */
1436extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc); 1407extern void drm_vblank_pre_modeset(struct drm_device *dev, int crtc);
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index f7646548660d..27f828c9d7f2 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -32,7 +32,6 @@
32#include <linux/fb.h> 32#include <linux/fb.h>
33#include <linux/hdmi.h> 33#include <linux/hdmi.h>
34#include <drm/drm_mode.h> 34#include <drm/drm_mode.h>
35
36#include <drm/drm_fourcc.h> 35#include <drm/drm_fourcc.h>
37 36
38struct drm_device; 37struct drm_device;
@@ -65,130 +64,14 @@ struct drm_object_properties {
65 uint64_t values[DRM_OBJECT_MAX_PROPERTY]; 64 uint64_t values[DRM_OBJECT_MAX_PROPERTY];
66}; 65};
67 66
68/* 67enum drm_connector_force {
69 * Note on terminology: here, for brevity and convenience, we refer to connector 68 DRM_FORCE_UNSPECIFIED,
70 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, 69 DRM_FORCE_OFF,
71 * DVI, etc. And 'screen' refers to the whole of the visible display, which 70 DRM_FORCE_ON, /* force on analog part normally */
72 * may span multiple monitors (and therefore multiple CRTC and connector 71 DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
73 * structures).
74 */
75
76enum drm_mode_status {
77 MODE_OK = 0, /* Mode OK */
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 */
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) /* 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
133
134struct drm_display_mode {
135 /* Header */
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 /* 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;
151 int vdisplay;
152 int vsync_start;
153 int vsync_end;
154 int vtotal;
155 int vscan;
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
183 int vrefresh; /* in Hz */
184 int hsync; /* in kHz */
185 enum hdmi_picture_aspect picture_aspect_ratio;
186}; 72};
187 73
188static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode) 74#include <drm/drm_modes.h>
189{
190 return mode->flags & DRM_MODE_FLAG_3D_MASK;
191}
192 75
193enum drm_connector_status { 76enum drm_connector_status {
194 connector_status_connected = 1, 77 connector_status_connected = 1,
@@ -540,13 +423,6 @@ struct drm_encoder {
540 void *helper_private; 423 void *helper_private;
541}; 424};
542 425
543enum 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 */
548};
549
550/* should we poll this connector for connects and disconnects */ 426/* should we poll this connector for connects and disconnects */
551/* hot plug detectable */ 427/* hot plug detectable */
552#define DRM_CONNECTOR_POLL_HPD (1 << 0) 428#define DRM_CONNECTOR_POLL_HPD (1 << 0)
@@ -1007,34 +883,10 @@ extern struct edid *drm_get_edid(struct drm_connector *connector,
1007 struct i2c_adapter *adapter); 883 struct i2c_adapter *adapter);
1008extern struct edid *drm_edid_duplicate(const struct edid *edid); 884extern struct edid *drm_edid_duplicate(const struct edid *edid);
1009extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); 885extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
1010extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
1011extern void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);
1012extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
1013 const struct drm_display_mode *mode);
1014extern void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
1015extern void drm_mode_config_init(struct drm_device *dev); 886extern void drm_mode_config_init(struct drm_device *dev);
1016extern void drm_mode_config_reset(struct drm_device *dev); 887extern void drm_mode_config_reset(struct drm_device *dev);
1017extern void drm_mode_config_cleanup(struct drm_device *dev); 888extern void drm_mode_config_cleanup(struct drm_device *dev);
1018extern void drm_mode_set_name(struct drm_display_mode *mode); 889
1019extern bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
1020extern bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2);
1021extern int drm_mode_width(const struct drm_display_mode *mode);
1022extern int drm_mode_height(const struct drm_display_mode *mode);
1023
1024/* for us by fb module */
1025extern struct drm_display_mode *drm_mode_create(struct drm_device *dev);
1026extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
1027extern void drm_mode_validate_size(struct drm_device *dev,
1028 struct list_head *mode_list,
1029 int maxX, int maxY, int maxPitch);
1030extern void drm_mode_prune_invalid(struct drm_device *dev,
1031 struct list_head *mode_list, bool verbose);
1032extern void drm_mode_sort(struct list_head *mode_list);
1033extern int drm_mode_hsync(const struct drm_display_mode *mode);
1034extern int drm_mode_vrefresh(const struct drm_display_mode *mode);
1035extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
1036 int adjust_flags);
1037extern void drm_mode_connector_list_update(struct drm_connector *connector);
1038extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, 890extern int drm_mode_connector_update_edid_property(struct drm_connector *connector,
1039 struct edid *edid); 891 struct edid *edid);
1040extern int drm_object_property_set_value(struct drm_mode_object *obj, 892extern int drm_object_property_set_value(struct drm_mode_object *obj,
@@ -1082,8 +934,6 @@ extern const char *drm_get_encoder_name(const struct drm_encoder *encoder);
1082 934
1083extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, 935extern int drm_mode_connector_attach_encoder(struct drm_connector *connector,
1084 struct drm_encoder *encoder); 936 struct drm_encoder *encoder);
1085extern void drm_mode_connector_detach_encoder(struct drm_connector *connector,
1086 struct drm_encoder *encoder);
1087extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, 937extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
1088 int gamma_size); 938 int gamma_size);
1089extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, 939extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
@@ -1138,16 +988,6 @@ extern bool drm_detect_monitor_audio(struct edid *edid);
1138extern bool drm_rgb_quant_range_selectable(struct edid *edid); 988extern bool drm_rgb_quant_range_selectable(struct edid *edid);
1139extern int drm_mode_page_flip_ioctl(struct drm_device *dev, 989extern int drm_mode_page_flip_ioctl(struct drm_device *dev,
1140 void *data, struct drm_file *file_priv); 990 void *data, struct drm_file *file_priv);
1141extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
1142 int hdisplay, int vdisplay, int vrefresh,
1143 bool reduced, bool interlaced, bool margins);
1144extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
1145 int hdisplay, int vdisplay, int vrefresh,
1146 bool interlaced, int margins);
1147extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
1148 int hdisplay, int vdisplay, int vrefresh,
1149 bool interlaced, int margins, int GTF_M,
1150 int GTF_2C, int GTF_K, int GTF_2J);
1151extern int drm_add_modes_noedid(struct drm_connector *connector, 991extern int drm_add_modes_noedid(struct drm_connector *connector,
1152 int hdisplay, int vdisplay); 992 int hdisplay, int vdisplay);
1153extern void drm_set_preferred_mode(struct drm_connector *connector, 993extern void drm_set_preferred_mode(struct drm_connector *connector,
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index b1388b5fe7ac..0bb34ca2ad2b 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -139,8 +139,8 @@ extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode)
139 139
140extern void drm_helper_move_panel_connectors_to_head(struct drm_device *); 140extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
141 141
142extern int drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, 142extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
143 struct drm_mode_fb_cmd2 *mode_cmd); 143 struct drm_mode_fb_cmd2 *mode_cmd);
144 144
145static inline void drm_crtc_helper_add(struct drm_crtc *crtc, 145static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
146 const struct drm_crtc_helper_funcs *funcs) 146 const struct drm_crtc_helper_funcs *funcs)
@@ -160,7 +160,7 @@ static inline void drm_connector_helper_add(struct drm_connector *connector,
160 connector->helper_private = (void *)funcs; 160 connector->helper_private = (void *)funcs;
161} 161}
162 162
163extern int drm_helper_resume_force_mode(struct drm_device *dev); 163extern void drm_helper_resume_force_mode(struct drm_device *dev);
164extern void drm_kms_helper_poll_init(struct drm_device *dev); 164extern void drm_kms_helper_poll_init(struct drm_device *dev);
165extern void drm_kms_helper_poll_fini(struct drm_device *dev); 165extern void drm_kms_helper_poll_fini(struct drm_device *dev);
166extern bool drm_helper_hpd_irq_event(struct drm_device *dev); 166extern bool drm_helper_hpd_irq_event(struct drm_device *dev);
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index cba67865d18f..8b6981ab3fcf 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -85,11 +85,31 @@ struct drm_mm {
85 unsigned long *start, unsigned long *end); 85 unsigned long *start, unsigned long *end);
86}; 86};
87 87
88/**
89 * drm_mm_node_allocated - checks whether a node is allocated
90 * @node: drm_mm_node to check
91 *
92 * Drivers should use this helpers for proper encapusulation of drm_mm
93 * internals.
94 *
95 * Returns:
96 * True if the @node is allocated.
97 */
88static inline bool drm_mm_node_allocated(struct drm_mm_node *node) 98static inline bool drm_mm_node_allocated(struct drm_mm_node *node)
89{ 99{
90 return node->allocated; 100 return node->allocated;
91} 101}
92 102
103/**
104 * drm_mm_initialized - checks whether an allocator is initialized
105 * @mm: drm_mm to check
106 *
107 * Drivers should use this helpers for proper encapusulation of drm_mm
108 * internals.
109 *
110 * Returns:
111 * True if the @mm is initialized.
112 */
93static inline bool drm_mm_initialized(struct drm_mm *mm) 113static inline bool drm_mm_initialized(struct drm_mm *mm)
94{ 114{
95 return mm->hole_stack.next; 115 return mm->hole_stack.next;
@@ -100,6 +120,17 @@ static inline unsigned long __drm_mm_hole_node_start(struct drm_mm_node *hole_no
100 return hole_node->start + hole_node->size; 120 return hole_node->start + hole_node->size;
101} 121}
102 122
123/**
124 * drm_mm_hole_node_start - computes the start of the hole following @node
125 * @hole_node: drm_mm_node which implicitly tracks the following hole
126 *
127 * This is useful for driver-sepific debug dumpers. Otherwise drivers should not
128 * inspect holes themselves. Drivers must check first whether a hole indeed
129 * follows by looking at node->hole_follows.
130 *
131 * Returns:
132 * Start of the subsequent hole.
133 */
103static inline unsigned long drm_mm_hole_node_start(struct drm_mm_node *hole_node) 134static inline unsigned long drm_mm_hole_node_start(struct drm_mm_node *hole_node)
104{ 135{
105 BUG_ON(!hole_node->hole_follows); 136 BUG_ON(!hole_node->hole_follows);
@@ -112,18 +143,49 @@ static inline unsigned long __drm_mm_hole_node_end(struct drm_mm_node *hole_node
112 struct drm_mm_node, node_list)->start; 143 struct drm_mm_node, node_list)->start;
113} 144}
114 145
146/**
147 * drm_mm_hole_node_end - computes the end of the hole following @node
148 * @hole_node: drm_mm_node which implicitly tracks the following hole
149 *
150 * This is useful for driver-sepific debug dumpers. Otherwise drivers should not
151 * inspect holes themselves. Drivers must check first whether a hole indeed
152 * follows by looking at node->hole_follows.
153 *
154 * Returns:
155 * End of the subsequent hole.
156 */
115static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node) 157static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node)
116{ 158{
117 return __drm_mm_hole_node_end(hole_node); 159 return __drm_mm_hole_node_end(hole_node);
118} 160}
119 161
162/**
163 * drm_mm_for_each_node - iterator to walk over all allocated nodes
164 * @entry: drm_mm_node structure to assign to in each iteration step
165 * @mm: drm_mm allocator to walk
166 *
167 * This iterator walks over all nodes in the range allocator. It is implemented
168 * with list_for_each, so not save against removal of elements.
169 */
120#define drm_mm_for_each_node(entry, mm) list_for_each_entry(entry, \ 170#define drm_mm_for_each_node(entry, mm) list_for_each_entry(entry, \
121 &(mm)->head_node.node_list, \ 171 &(mm)->head_node.node_list, \
122 node_list) 172 node_list)
123 173
124/* Note that we need to unroll list_for_each_entry in order to inline 174/**
125 * setting hole_start and hole_end on each iteration and keep the 175 * drm_mm_for_each_hole - iterator to walk over all holes
126 * macro sane. 176 * @entry: drm_mm_node used internally to track progress
177 * @mm: drm_mm allocator to walk
178 * @hole_start: ulong variable to assign the hole start to on each iteration
179 * @hole_end: ulong variable to assign the hole end to on each iteration
180 *
181 * This iterator walks over all holes in the range allocator. It is implemented
182 * with list_for_each, so not save against removal of elements. @entry is used
183 * internally and will not reflect a real drm_mm_node for the very first hole.
184 * Hence users of this iterator may not access it.
185 *
186 * Implementation Note:
187 * We need to inline list_for_each_entry in order to be able to set hole_start
188 * and hole_end on each iteration while keeping the macro sane.
127 */ 189 */
128#define drm_mm_for_each_hole(entry, mm, hole_start, hole_end) \ 190#define drm_mm_for_each_hole(entry, mm, hole_start, hole_end) \
129 for (entry = list_entry((mm)->hole_stack.next, struct drm_mm_node, hole_stack); \ 191 for (entry = list_entry((mm)->hole_stack.next, struct drm_mm_node, hole_stack); \
@@ -136,14 +198,30 @@ static inline unsigned long drm_mm_hole_node_end(struct drm_mm_node *hole_node)
136/* 198/*
137 * Basic range manager support (drm_mm.c) 199 * Basic range manager support (drm_mm.c)
138 */ 200 */
139extern int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node); 201int drm_mm_reserve_node(struct drm_mm *mm, struct drm_mm_node *node);
140 202
141extern int drm_mm_insert_node_generic(struct drm_mm *mm, 203int drm_mm_insert_node_generic(struct drm_mm *mm,
142 struct drm_mm_node *node, 204 struct drm_mm_node *node,
143 unsigned long size, 205 unsigned long size,
144 unsigned alignment, 206 unsigned alignment,
145 unsigned long color, 207 unsigned long color,
146 enum drm_mm_search_flags flags); 208 enum drm_mm_search_flags flags);
209/**
210 * drm_mm_insert_node - search for space and insert @node
211 * @mm: drm_mm to allocate from
212 * @node: preallocate node to insert
213 * @size: size of the allocation
214 * @alignment: alignment of the allocation
215 * @flags: flags to fine-tune the allocation
216 *
217 * This is a simplified version of drm_mm_insert_node_generic() with @color set
218 * to 0.
219 *
220 * The preallocated node must be cleared to 0.
221 *
222 * Returns:
223 * 0 on success, -ENOSPC if there's no suitable hole.
224 */
147static inline int drm_mm_insert_node(struct drm_mm *mm, 225static inline int drm_mm_insert_node(struct drm_mm *mm,
148 struct drm_mm_node *node, 226 struct drm_mm_node *node,
149 unsigned long size, 227 unsigned long size,
@@ -153,14 +231,32 @@ static inline int drm_mm_insert_node(struct drm_mm *mm,
153 return drm_mm_insert_node_generic(mm, node, size, alignment, 0, flags); 231 return drm_mm_insert_node_generic(mm, node, size, alignment, 0, flags);
154} 232}
155 233
156extern int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, 234int drm_mm_insert_node_in_range_generic(struct drm_mm *mm,
157 struct drm_mm_node *node, 235 struct drm_mm_node *node,
158 unsigned long size, 236 unsigned long size,
159 unsigned alignment, 237 unsigned alignment,
160 unsigned long color, 238 unsigned long color,
161 unsigned long start, 239 unsigned long start,
162 unsigned long end, 240 unsigned long end,
163 enum drm_mm_search_flags flags); 241 enum drm_mm_search_flags flags);
242/**
243 * drm_mm_insert_node_in_range - ranged search for space and insert @node
244 * @mm: drm_mm to allocate from
245 * @node: preallocate node to insert
246 * @size: size of the allocation
247 * @alignment: alignment of the allocation
248 * @start: start of the allowed range for this node
249 * @end: end of the allowed range for this node
250 * @flags: flags to fine-tune the allocation
251 *
252 * This is a simplified version of drm_mm_insert_node_in_range_generic() with
253 * @color set to 0.
254 *
255 * The preallocated node must be cleared to 0.
256 *
257 * Returns:
258 * 0 on success, -ENOSPC if there's no suitable hole.
259 */
164static inline int drm_mm_insert_node_in_range(struct drm_mm *mm, 260static inline int drm_mm_insert_node_in_range(struct drm_mm *mm,
165 struct drm_mm_node *node, 261 struct drm_mm_node *node,
166 unsigned long size, 262 unsigned long size,
@@ -173,13 +269,13 @@ static inline int drm_mm_insert_node_in_range(struct drm_mm *mm,
173 0, start, end, flags); 269 0, start, end, flags);
174} 270}
175 271
176extern void drm_mm_remove_node(struct drm_mm_node *node); 272void drm_mm_remove_node(struct drm_mm_node *node);
177extern void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new); 273void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new);
178extern void drm_mm_init(struct drm_mm *mm, 274void drm_mm_init(struct drm_mm *mm,
179 unsigned long start, 275 unsigned long start,
180 unsigned long size); 276 unsigned long size);
181extern void drm_mm_takedown(struct drm_mm *mm); 277void drm_mm_takedown(struct drm_mm *mm);
182extern int drm_mm_clean(struct drm_mm *mm); 278bool drm_mm_clean(struct drm_mm *mm);
183 279
184void drm_mm_init_scan(struct drm_mm *mm, 280void drm_mm_init_scan(struct drm_mm *mm,
185 unsigned long size, 281 unsigned long size,
@@ -191,10 +287,10 @@ void drm_mm_init_scan_with_range(struct drm_mm *mm,
191 unsigned long color, 287 unsigned long color,
192 unsigned long start, 288 unsigned long start,
193 unsigned long end); 289 unsigned long end);
194int drm_mm_scan_add_block(struct drm_mm_node *node); 290bool drm_mm_scan_add_block(struct drm_mm_node *node);
195int drm_mm_scan_remove_block(struct drm_mm_node *node); 291bool drm_mm_scan_remove_block(struct drm_mm_node *node);
196 292
197extern void drm_mm_debug_table(struct drm_mm *mm, const char *prefix); 293void drm_mm_debug_table(struct drm_mm *mm, const char *prefix);
198#ifdef CONFIG_DEBUG_FS 294#ifdef CONFIG_DEBUG_FS
199int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm); 295int drm_mm_dump_table(struct seq_file *m, struct drm_mm *mm);
200#endif 296#endif
diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h
new file mode 100644
index 000000000000..2dbbf9976669
--- /dev/null
+++ b/include/drm/drm_modes.h
@@ -0,0 +1,237 @@
1/*
2 * Copyright © 2006 Keith Packard
3 * Copyright © 2007-2008 Dave Airlie
4 * Copyright © 2007-2008 Intel Corporation
5 * Jesse Barnes <jesse.barnes@intel.com>
6 * Copyright © 2014 Intel Corporation
7 * Daniel Vetter <daniel.vetter@ffwll.ch>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27#ifndef __DRM_MODES_H__
28#define __DRM_MODES_H__
29
30/*
31 * Note on terminology: here, for brevity and convenience, we refer to connector
32 * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS,
33 * DVI, etc. And 'screen' refers to the whole of the visible display, which
34 * may span multiple monitors (and therefore multiple CRTC and connector
35 * structures).
36 */
37
38enum drm_mode_status {
39 MODE_OK = 0, /* Mode OK */
40 MODE_HSYNC, /* hsync out of range */
41 MODE_VSYNC, /* vsync out of range */
42 MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
43 MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
44 MODE_BAD_WIDTH, /* requires an unsupported linepitch */
45 MODE_NOMODE, /* no mode with a matching name */
46 MODE_NO_INTERLACE, /* interlaced mode not supported */
47 MODE_NO_DBLESCAN, /* doublescan mode not supported */
48 MODE_NO_VSCAN, /* multiscan mode not supported */
49 MODE_MEM, /* insufficient video memory */
50 MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
51 MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
52 MODE_MEM_VIRT, /* insufficient video memory given virtual size */
53 MODE_NOCLOCK, /* no fixed clock available */
54 MODE_CLOCK_HIGH, /* clock required is too high */
55 MODE_CLOCK_LOW, /* clock required is too low */
56 MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
57 MODE_BAD_HVALUE, /* horizontal timing was out of range */
58 MODE_BAD_VVALUE, /* vertical timing was out of range */
59 MODE_BAD_VSCAN, /* VScan value out of range */
60 MODE_HSYNC_NARROW, /* horizontal sync too narrow */
61 MODE_HSYNC_WIDE, /* horizontal sync too wide */
62 MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
63 MODE_HBLANK_WIDE, /* horizontal blanking too wide */
64 MODE_VSYNC_NARROW, /* vertical sync too narrow */
65 MODE_VSYNC_WIDE, /* vertical sync too wide */
66 MODE_VBLANK_NARROW, /* vertical blanking too narrow */
67 MODE_VBLANK_WIDE, /* vertical blanking too wide */
68 MODE_PANEL, /* exceeds panel dimensions */
69 MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
70 MODE_ONE_WIDTH, /* only one width is supported */
71 MODE_ONE_HEIGHT, /* only one height is supported */
72 MODE_ONE_SIZE, /* only one resolution is supported */
73 MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
74 MODE_NO_STEREO, /* stereo modes not supported */
75 MODE_UNVERIFIED = -3, /* mode needs to reverified */
76 MODE_BAD = -2, /* unspecified reason */
77 MODE_ERROR = -1 /* error condition */
78};
79
80#define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \
81 DRM_MODE_TYPE_CRTC_C)
82
83#define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \
84 .name = nm, .status = 0, .type = (t), .clock = (c), \
85 .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \
86 .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \
87 .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \
88 .vscan = (vs), .flags = (f), \
89 .base.type = DRM_MODE_OBJECT_MODE
90
91#define CRTC_INTERLACE_HALVE_V (1 << 0) /* halve V values for interlacing */
92#define CRTC_STEREO_DOUBLE (1 << 1) /* adjust timings for stereo modes */
93
94#define DRM_MODE_FLAG_3D_MAX DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF
95
96struct drm_display_mode {
97 /* Header */
98 struct list_head head;
99 struct drm_mode_object base;
100
101 char name[DRM_DISPLAY_MODE_LEN];
102
103 enum drm_mode_status status;
104 unsigned int type;
105
106 /* Proposed mode values */
107 int clock; /* in kHz */
108 int hdisplay;
109 int hsync_start;
110 int hsync_end;
111 int htotal;
112 int hskew;
113 int vdisplay;
114 int vsync_start;
115 int vsync_end;
116 int vtotal;
117 int vscan;
118 unsigned int flags;
119
120 /* Addressable image size (may be 0 for projectors, etc.) */
121 int width_mm;
122 int height_mm;
123
124 /* Actual mode we give to hw */
125 int crtc_clock; /* in KHz */
126 int crtc_hdisplay;
127 int crtc_hblank_start;
128 int crtc_hblank_end;
129 int crtc_hsync_start;
130 int crtc_hsync_end;
131 int crtc_htotal;
132 int crtc_hskew;
133 int crtc_vdisplay;
134 int crtc_vblank_start;
135 int crtc_vblank_end;
136 int crtc_vsync_start;
137 int crtc_vsync_end;
138 int crtc_vtotal;
139
140 /* Driver private mode info */
141 int *private;
142 int private_flags;
143
144 int vrefresh; /* in Hz */
145 int hsync; /* in kHz */
146 enum hdmi_picture_aspect picture_aspect_ratio;
147};
148
149/* mode specified on the command line */
150struct drm_cmdline_mode {
151 bool specified;
152 bool refresh_specified;
153 bool bpp_specified;
154 int xres, yres;
155 int bpp;
156 int refresh;
157 bool rb;
158 bool interlace;
159 bool cvt;
160 bool margins;
161 enum drm_connector_force force;
162};
163
164/**
165 * drm_mode_is_stereo - check for stereo mode flags
166 * @mode: drm_display_mode to check
167 *
168 * Returns:
169 * True if the mode is one of the stereo modes (like side-by-side), false if
170 * not.
171 */
172static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode)
173{
174 return mode->flags & DRM_MODE_FLAG_3D_MASK;
175}
176
177struct drm_connector;
178struct drm_cmdline_mode;
179
180struct drm_display_mode *drm_mode_create(struct drm_device *dev);
181void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode);
182void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode);
183void drm_mode_debug_printmodeline(const struct drm_display_mode *mode);
184
185struct drm_display_mode *drm_cvt_mode(struct drm_device *dev,
186 int hdisplay, int vdisplay, int vrefresh,
187 bool reduced, bool interlaced,
188 bool margins);
189struct drm_display_mode *drm_gtf_mode(struct drm_device *dev,
190 int hdisplay, int vdisplay, int vrefresh,
191 bool interlaced, int margins);
192struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev,
193 int hdisplay, int vdisplay,
194 int vrefresh, bool interlaced,
195 int margins,
196 int GTF_M, int GTF_2C,
197 int GTF_K, int GTF_2J);
198void drm_display_mode_from_videomode(const struct videomode *vm,
199 struct drm_display_mode *dmode);
200int of_get_drm_display_mode(struct device_node *np,
201 struct drm_display_mode *dmode,
202 int index);
203
204void drm_mode_set_name(struct drm_display_mode *mode);
205int drm_mode_hsync(const struct drm_display_mode *mode);
206int drm_mode_vrefresh(const struct drm_display_mode *mode);
207
208void drm_mode_set_crtcinfo(struct drm_display_mode *p,
209 int adjust_flags);
210void drm_mode_copy(struct drm_display_mode *dst,
211 const struct drm_display_mode *src);
212struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev,
213 const struct drm_display_mode *mode);
214bool drm_mode_equal(const struct drm_display_mode *mode1,
215 const struct drm_display_mode *mode2);
216bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
217 const struct drm_display_mode *mode2);
218
219/* for use by the crtc helper probe functions */
220void drm_mode_validate_size(struct drm_device *dev,
221 struct list_head *mode_list,
222 int maxX, int maxY);
223void drm_mode_prune_invalid(struct drm_device *dev,
224 struct list_head *mode_list, bool verbose);
225void drm_mode_sort(struct list_head *mode_list);
226void drm_mode_connector_list_update(struct drm_connector *connector);
227
228/* parsing cmdline modes */
229bool
230drm_mode_parse_command_line_for_connector(const char *mode_option,
231 struct drm_connector *connector,
232 struct drm_cmdline_mode *mode);
233struct drm_display_mode *
234drm_mode_create_from_cmdline_mode(struct drm_device *dev,
235 struct drm_cmdline_mode *cmd);
236
237#endif /* __DRM_MODES_H__ */