Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 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 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 | * OTHER DEALINGS IN THE SOFTWARE. |
| 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> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 32 | #include <linux/fb.h> |
| 33 | |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 34 | #include <drm/drm_fourcc.h> |
| 35 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 36 | struct drm_device; |
| 37 | struct drm_mode_set; |
| 38 | struct drm_framebuffer; |
| 39 | |
| 40 | |
| 41 | #define DRM_MODE_OBJECT_CRTC 0xcccccccc |
| 42 | #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 |
| 43 | #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0 |
| 44 | #define DRM_MODE_OBJECT_MODE 0xdededede |
| 45 | #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0 |
| 46 | #define DRM_MODE_OBJECT_FB 0xfbfbfbfb |
| 47 | #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 48 | #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 49 | |
| 50 | struct drm_mode_object { |
| 51 | uint32_t id; |
| 52 | uint32_t type; |
| 53 | }; |
| 54 | |
| 55 | /* |
| 56 | * Note on terminology: here, for brevity and convenience, we refer to connector |
| 57 | * control chips as 'CRTCs'. They can control any type of connector, VGA, LVDS, |
| 58 | * DVI, etc. And 'screen' refers to the whole of the visible display, which |
| 59 | * may span multiple monitors (and therefore multiple CRTC and connector |
| 60 | * structures). |
| 61 | */ |
| 62 | |
| 63 | enum drm_mode_status { |
| 64 | MODE_OK = 0, /* Mode OK */ |
| 65 | MODE_HSYNC, /* hsync out of range */ |
| 66 | MODE_VSYNC, /* vsync out of range */ |
| 67 | MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ |
| 68 | MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ |
| 69 | MODE_BAD_WIDTH, /* requires an unsupported linepitch */ |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 70 | MODE_NOMODE, /* no mode with a matching name */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 71 | MODE_NO_INTERLACE, /* interlaced mode not supported */ |
| 72 | MODE_NO_DBLESCAN, /* doublescan mode not supported */ |
| 73 | MODE_NO_VSCAN, /* multiscan mode not supported */ |
| 74 | MODE_MEM, /* insufficient video memory */ |
| 75 | MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ |
| 76 | MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ |
| 77 | MODE_MEM_VIRT, /* insufficient video memory given virtual size */ |
| 78 | MODE_NOCLOCK, /* no fixed clock available */ |
| 79 | MODE_CLOCK_HIGH, /* clock required is too high */ |
| 80 | MODE_CLOCK_LOW, /* clock required is too low */ |
| 81 | MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ |
| 82 | MODE_BAD_HVALUE, /* horizontal timing was out of range */ |
| 83 | MODE_BAD_VVALUE, /* vertical timing was out of range */ |
| 84 | MODE_BAD_VSCAN, /* VScan value out of range */ |
| 85 | MODE_HSYNC_NARROW, /* horizontal sync too narrow */ |
| 86 | MODE_HSYNC_WIDE, /* horizontal sync too wide */ |
| 87 | MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ |
| 88 | MODE_HBLANK_WIDE, /* horizontal blanking too wide */ |
| 89 | MODE_VSYNC_NARROW, /* vertical sync too narrow */ |
| 90 | MODE_VSYNC_WIDE, /* vertical sync too wide */ |
| 91 | MODE_VBLANK_NARROW, /* vertical blanking too narrow */ |
| 92 | MODE_VBLANK_WIDE, /* vertical blanking too wide */ |
| 93 | MODE_PANEL, /* exceeds panel dimensions */ |
| 94 | MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ |
| 95 | MODE_ONE_WIDTH, /* only one width is supported */ |
| 96 | MODE_ONE_HEIGHT, /* only one height is supported */ |
| 97 | MODE_ONE_SIZE, /* only one resolution is supported */ |
| 98 | MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ |
| 99 | MODE_UNVERIFIED = -3, /* mode needs to reverified */ |
| 100 | MODE_BAD = -2, /* unspecified reason */ |
| 101 | MODE_ERROR = -1 /* error condition */ |
| 102 | }; |
| 103 | |
| 104 | #define DRM_MODE_TYPE_CLOCK_CRTC_C (DRM_MODE_TYPE_CLOCK_C | \ |
| 105 | DRM_MODE_TYPE_CRTC_C) |
| 106 | |
| 107 | #define DRM_MODE(nm, t, c, hd, hss, hse, ht, hsk, vd, vss, vse, vt, vs, f) \ |
| 108 | .name = nm, .status = 0, .type = (t), .clock = (c), \ |
| 109 | .hdisplay = (hd), .hsync_start = (hss), .hsync_end = (hse), \ |
| 110 | .htotal = (ht), .hskew = (hsk), .vdisplay = (vd), \ |
| 111 | .vsync_start = (vss), .vsync_end = (vse), .vtotal = (vt), \ |
| 112 | .vscan = (vs), .flags = (f), .vrefresh = 0 |
| 113 | |
| 114 | #define CRTC_INTERLACE_HALVE_V 0x1 /* halve V values for interlacing */ |
| 115 | |
| 116 | struct drm_display_mode { |
| 117 | /* Header */ |
| 118 | struct list_head head; |
| 119 | struct drm_mode_object base; |
| 120 | |
| 121 | char name[DRM_DISPLAY_MODE_LEN]; |
| 122 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 123 | enum drm_mode_status status; |
| 124 | int type; |
| 125 | |
| 126 | /* Proposed mode values */ |
Adam Jackson | 7ac96a9 | 2009-12-03 17:44:37 -0500 | [diff] [blame] | 127 | int clock; /* in kHz */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 128 | int hdisplay; |
| 129 | int hsync_start; |
| 130 | int hsync_end; |
| 131 | int htotal; |
| 132 | int hskew; |
| 133 | int vdisplay; |
| 134 | int vsync_start; |
| 135 | int vsync_end; |
| 136 | int vtotal; |
| 137 | int vscan; |
| 138 | unsigned int flags; |
| 139 | |
| 140 | /* Addressable image size (may be 0 for projectors, etc.) */ |
| 141 | int width_mm; |
| 142 | int height_mm; |
| 143 | |
| 144 | /* Actual mode we give to hw */ |
| 145 | int clock_index; |
| 146 | int synth_clock; |
| 147 | int crtc_hdisplay; |
| 148 | int crtc_hblank_start; |
| 149 | int crtc_hblank_end; |
| 150 | int crtc_hsync_start; |
| 151 | int crtc_hsync_end; |
| 152 | int crtc_htotal; |
| 153 | int crtc_hskew; |
| 154 | int crtc_vdisplay; |
| 155 | int crtc_vblank_start; |
| 156 | int crtc_vblank_end; |
| 157 | int crtc_vsync_start; |
| 158 | int crtc_vsync_end; |
| 159 | int crtc_vtotal; |
| 160 | int crtc_hadjusted; |
| 161 | int crtc_vadjusted; |
| 162 | |
| 163 | /* Driver private mode info */ |
| 164 | int private_size; |
| 165 | int *private; |
| 166 | int private_flags; |
| 167 | |
Adam Jackson | 7ac96a9 | 2009-12-03 17:44:37 -0500 | [diff] [blame] | 168 | int vrefresh; /* in Hz */ |
| 169 | int hsync; /* in kHz */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | enum drm_connector_status { |
| 173 | connector_status_connected = 1, |
| 174 | connector_status_disconnected = 2, |
| 175 | connector_status_unknown = 3, |
| 176 | }; |
| 177 | |
| 178 | enum subpixel_order { |
| 179 | SubPixelUnknown = 0, |
| 180 | SubPixelHorizontalRGB, |
| 181 | SubPixelHorizontalBGR, |
| 182 | SubPixelVerticalRGB, |
| 183 | SubPixelVerticalBGR, |
| 184 | SubPixelNone, |
| 185 | }; |
| 186 | |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 187 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) |
| 188 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) |
| 189 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 190 | /* |
| 191 | * Describes a given display (e.g. CRT or flat panel) and its limitations. |
| 192 | */ |
| 193 | struct drm_display_info { |
| 194 | char name[DRM_DISPLAY_INFO_LEN]; |
Adam Jackson | fb43964 | 2010-08-03 14:38:16 -0400 | [diff] [blame] | 195 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 196 | /* Physical size */ |
| 197 | unsigned int width_mm; |
| 198 | unsigned int height_mm; |
| 199 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 200 | /* Clock limits FIXME: storage format */ |
| 201 | unsigned int min_vfreq, max_vfreq; |
| 202 | unsigned int min_hfreq, max_hfreq; |
| 203 | unsigned int pixel_clock; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 204 | unsigned int bpc; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 205 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 206 | enum subpixel_order subpixel_order; |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 207 | u32 color_formats; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 208 | |
Jesse Barnes | ebec9a7 | 2011-08-03 09:22:54 -0700 | [diff] [blame] | 209 | u8 cea_rev; |
| 210 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 211 | char *raw_edid; /* if any */ |
| 212 | }; |
| 213 | |
| 214 | struct drm_framebuffer_funcs { |
| 215 | void (*destroy)(struct drm_framebuffer *framebuffer); |
| 216 | int (*create_handle)(struct drm_framebuffer *fb, |
| 217 | struct drm_file *file_priv, |
| 218 | unsigned int *handle); |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 219 | /** |
| 220 | * Optinal callback for the dirty fb ioctl. |
| 221 | * |
| 222 | * Userspace can notify the driver via this callback |
| 223 | * that a area of the framebuffer has changed and should |
| 224 | * be flushed to the display hardware. |
| 225 | * |
| 226 | * See documentation in drm_mode.h for the struct |
| 227 | * drm_mode_fb_dirty_cmd for more information as all |
| 228 | * the semantics and arguments have a one to one mapping |
| 229 | * on this function. |
| 230 | */ |
Thomas Hellstrom | 02b0016 | 2010-10-05 12:43:02 +0200 | [diff] [blame] | 231 | int (*dirty)(struct drm_framebuffer *framebuffer, |
| 232 | struct drm_file *file_priv, unsigned flags, |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 233 | unsigned color, struct drm_clip_rect *clips, |
| 234 | unsigned num_clips); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 235 | }; |
| 236 | |
| 237 | struct drm_framebuffer { |
| 238 | struct drm_device *dev; |
| 239 | struct list_head head; |
| 240 | struct drm_mode_object base; |
| 241 | const struct drm_framebuffer_funcs *funcs; |
Ville Syrjälä | 01f2c77 | 2011-12-20 00:06:49 +0200 | [diff] [blame] | 242 | unsigned int pitches[4]; |
| 243 | unsigned int offsets[4]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 244 | unsigned int width; |
| 245 | unsigned int height; |
| 246 | /* depth can be 15 or 16 */ |
| 247 | unsigned int depth; |
| 248 | int bits_per_pixel; |
| 249 | int flags; |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 250 | uint32_t pixel_format; /* fourcc format */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 251 | struct list_head filp_head; |
Dave Airlie | 785b93e | 2009-08-28 15:46:53 +1000 | [diff] [blame] | 252 | /* if you are using the helper */ |
| 253 | void *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 254 | }; |
| 255 | |
| 256 | struct drm_property_blob { |
| 257 | struct drm_mode_object base; |
| 258 | struct list_head head; |
| 259 | unsigned int length; |
| 260 | void *data; |
| 261 | }; |
| 262 | |
| 263 | struct drm_property_enum { |
| 264 | uint64_t value; |
| 265 | struct list_head head; |
| 266 | char name[DRM_PROP_NAME_LEN]; |
| 267 | }; |
| 268 | |
| 269 | struct drm_property { |
| 270 | struct list_head head; |
| 271 | struct drm_mode_object base; |
| 272 | uint32_t flags; |
| 273 | char name[DRM_PROP_NAME_LEN]; |
| 274 | uint32_t num_values; |
| 275 | uint64_t *values; |
| 276 | |
| 277 | struct list_head enum_blob_list; |
| 278 | }; |
| 279 | |
| 280 | struct drm_crtc; |
| 281 | struct drm_connector; |
| 282 | struct drm_encoder; |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 283 | struct drm_pending_vblank_event; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 284 | struct drm_plane; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 285 | |
| 286 | /** |
| 287 | * drm_crtc_funcs - control CRTCs for a given device |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 288 | * @reset: reset CRTC after state has been invalidate (e.g. resume) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 289 | * @dpms: control display power levels |
| 290 | * @save: save CRTC state |
| 291 | * @resore: restore CRTC state |
| 292 | * @lock: lock the CRTC |
| 293 | * @unlock: unlock the CRTC |
| 294 | * @shadow_allocate: allocate shadow pixmap |
| 295 | * @shadow_create: create shadow pixmap for rotation support |
| 296 | * @shadow_destroy: free shadow pixmap |
| 297 | * @mode_fixup: fixup proposed mode |
| 298 | * @mode_set: set the desired mode on the CRTC |
| 299 | * @gamma_set: specify color ramp for CRTC |
| 300 | * @destroy: deinit and free object. |
| 301 | * |
| 302 | * The drm_crtc_funcs structure is the central CRTC management structure |
| 303 | * in the DRM. Each CRTC controls one or more connectors (note that the name |
| 304 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. |
| 305 | * connectors, not just CRTs). |
| 306 | * |
| 307 | * Each driver is responsible for filling out this structure at startup time, |
| 308 | * in addition to providing other modesetting features, like i2c and DDC |
| 309 | * bus accessors. |
| 310 | */ |
| 311 | struct drm_crtc_funcs { |
| 312 | /* Save CRTC state */ |
| 313 | void (*save)(struct drm_crtc *crtc); /* suspend? */ |
| 314 | /* Restore CRTC state */ |
| 315 | void (*restore)(struct drm_crtc *crtc); /* resume? */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 316 | /* Reset CRTC state */ |
| 317 | void (*reset)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 318 | |
| 319 | /* cursor controls */ |
| 320 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 321 | uint32_t handle, uint32_t width, uint32_t height); |
| 322 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
| 323 | |
| 324 | /* Set gamma on the CRTC */ |
| 325 | void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, |
James Simmons | 7203425 | 2010-08-03 01:33:19 +0100 | [diff] [blame] | 326 | uint32_t start, uint32_t size); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 327 | /* Object destroy routine */ |
| 328 | void (*destroy)(struct drm_crtc *crtc); |
| 329 | |
| 330 | int (*set_config)(struct drm_mode_set *set); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 331 | |
| 332 | /* |
| 333 | * Flip to the given framebuffer. This implements the page |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 334 | * flip ioctl described in drm_mode.h, specifically, the |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 335 | * implementation must return immediately and block all |
| 336 | * rendering to the current fb until the flip has completed. |
| 337 | * If userspace set the event flag in the ioctl, the event |
| 338 | * argument will point to an event to send back when the flip |
| 339 | * completes, otherwise it will be NULL. |
| 340 | */ |
| 341 | int (*page_flip)(struct drm_crtc *crtc, |
| 342 | struct drm_framebuffer *fb, |
| 343 | struct drm_pending_vblank_event *event); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | /** |
| 347 | * drm_crtc - central CRTC control structure |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 348 | * @dev: parent DRM device |
| 349 | * @head: list management |
| 350 | * @base: base KMS object for ID tracking etc. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 351 | * @enabled: is this CRTC enabled? |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 352 | * @mode: current mode timings |
| 353 | * @hwmode: mode timings as programmed to hw regs |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 354 | * @x: x position on screen |
| 355 | * @y: y position on screen |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 356 | * @funcs: CRTC control functions |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 357 | * @gamma_size: size of gamma ramp |
| 358 | * @gamma_store: gamma ramp values |
| 359 | * @framedur_ns: precise frame timing |
| 360 | * @framedur_ns: precise line timing |
| 361 | * @pixeldur_ns: precise pixel timing |
| 362 | * @helper_private: mid-layer private data |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 363 | * |
| 364 | * Each CRTC may have one or more connectors associated with it. This structure |
| 365 | * allows the CRTC to be controlled. |
| 366 | */ |
| 367 | struct drm_crtc { |
| 368 | struct drm_device *dev; |
| 369 | struct list_head head; |
| 370 | |
| 371 | struct drm_mode_object base; |
| 372 | |
| 373 | /* framebuffer the connector is currently bound to */ |
| 374 | struct drm_framebuffer *fb; |
| 375 | |
| 376 | bool enabled; |
| 377 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 378 | /* Requested mode from modesetting. */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 379 | struct drm_display_mode mode; |
| 380 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 381 | /* Programmed mode in hw, after adjustments for encoders, |
| 382 | * crtc, panel scaling etc. Needed for timestamping etc. |
| 383 | */ |
| 384 | struct drm_display_mode hwmode; |
| 385 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 386 | int x, y; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 387 | const struct drm_crtc_funcs *funcs; |
| 388 | |
| 389 | /* CRTC gamma size for reporting to userspace */ |
| 390 | uint32_t gamma_size; |
| 391 | uint16_t *gamma_store; |
| 392 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 393 | /* Constants needed for precise vblank and swap timestamping. */ |
| 394 | s64 framedur_ns, linedur_ns, pixeldur_ns; |
| 395 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 396 | /* if you are using the helper */ |
| 397 | void *helper_private; |
| 398 | }; |
| 399 | |
| 400 | |
| 401 | /** |
| 402 | * drm_connector_funcs - control connectors on a given device |
| 403 | * @dpms: set power state (see drm_crtc_funcs above) |
| 404 | * @save: save connector state |
| 405 | * @restore: restore connector state |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 406 | * @reset: reset connector after state has been invalidate (e.g. resume) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 407 | * @mode_valid: is this mode valid on the given connector? |
| 408 | * @mode_fixup: try to fixup proposed mode for this connector |
| 409 | * @mode_set: set this mode |
| 410 | * @detect: is this connector active? |
| 411 | * @get_modes: get mode list for this connector |
| 412 | * @set_property: property for this connector may need update |
| 413 | * @destroy: make object go away |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 414 | * @force: notify the driver the connector is forced on |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 415 | * |
| 416 | * Each CRTC may have one or more connectors attached to it. The functions |
| 417 | * below allow the core DRM code to control connectors, enumerate available modes, |
| 418 | * etc. |
| 419 | */ |
| 420 | struct drm_connector_funcs { |
| 421 | void (*dpms)(struct drm_connector *connector, int mode); |
| 422 | void (*save)(struct drm_connector *connector); |
| 423 | void (*restore)(struct drm_connector *connector); |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 424 | void (*reset)(struct drm_connector *connector); |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 425 | |
| 426 | /* Check to see if anything is attached to the connector. |
| 427 | * @force is set to false whilst polling, true when checking the |
| 428 | * connector due to user request. @force can be used by the driver |
| 429 | * to avoid expensive, destructive operations during automated |
| 430 | * probing. |
| 431 | */ |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 432 | enum drm_connector_status (*detect)(struct drm_connector *connector, |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 433 | bool force); |
Jesse Barnes | 40a518d | 2009-01-12 12:05:32 -0800 | [diff] [blame] | 434 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 435 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, |
| 436 | uint64_t val); |
| 437 | void (*destroy)(struct drm_connector *connector); |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 438 | void (*force)(struct drm_connector *connector); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 439 | }; |
| 440 | |
Jesse Barnes | 6c3db92 | 2011-11-07 12:03:16 -0800 | [diff] [blame] | 441 | /** |
| 442 | * drm_encoder_funcs - encoder controls |
| 443 | * @reset: reset state (e.g. at init or resume time) |
| 444 | * @destroy: cleanup and free associated data |
| 445 | * |
| 446 | * Encoders sit between CRTCs and connectors. |
| 447 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 448 | struct drm_encoder_funcs { |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 449 | void (*reset)(struct drm_encoder *encoder); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 450 | void (*destroy)(struct drm_encoder *encoder); |
| 451 | }; |
| 452 | |
| 453 | #define DRM_CONNECTOR_MAX_UMODES 16 |
| 454 | #define DRM_CONNECTOR_MAX_PROPERTY 16 |
| 455 | #define DRM_CONNECTOR_LEN 32 |
| 456 | #define DRM_CONNECTOR_MAX_ENCODER 2 |
| 457 | |
| 458 | /** |
| 459 | * drm_encoder - central DRM encoder structure |
Jesse Barnes | db3e449 | 2011-11-07 12:03:17 -0800 | [diff] [blame] | 460 | * @dev: parent DRM device |
| 461 | * @head: list management |
| 462 | * @base: base KMS object |
| 463 | * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h |
| 464 | * @possible_crtcs: bitmask of potential CRTC bindings |
| 465 | * @possible_clones: bitmask of potential sibling encoders for cloning |
| 466 | * @crtc: currently bound CRTC |
| 467 | * @funcs: control functions |
| 468 | * @helper_private: mid-layer private data |
| 469 | * |
| 470 | * CRTCs drive pixels to encoders, which convert them into signals |
| 471 | * appropriate for a given connector or set of connectors. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 472 | */ |
| 473 | struct drm_encoder { |
| 474 | struct drm_device *dev; |
| 475 | struct list_head head; |
| 476 | |
| 477 | struct drm_mode_object base; |
| 478 | int encoder_type; |
| 479 | uint32_t possible_crtcs; |
| 480 | uint32_t possible_clones; |
| 481 | |
| 482 | struct drm_crtc *crtc; |
| 483 | const struct drm_encoder_funcs *funcs; |
| 484 | void *helper_private; |
| 485 | }; |
| 486 | |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 487 | enum drm_connector_force { |
| 488 | DRM_FORCE_UNSPECIFIED, |
| 489 | DRM_FORCE_OFF, |
| 490 | DRM_FORCE_ON, /* force on analog part normally */ |
| 491 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ |
| 492 | }; |
| 493 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 494 | /* should we poll this connector for connects and disconnects */ |
| 495 | /* hot plug detectable */ |
| 496 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) |
| 497 | /* poll for connections */ |
| 498 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) |
| 499 | /* can cleanly poll for disconnections without flickering the screen */ |
| 500 | /* DACs should rarely do this without a lot of testing */ |
| 501 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) |
| 502 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 503 | #define MAX_ELD_BYTES 128 |
| 504 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 505 | /** |
| 506 | * drm_connector - central DRM connector control structure |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 507 | * @dev: parent DRM device |
| 508 | * @kdev: kernel device for sysfs attributes |
| 509 | * @attr: sysfs attributes |
| 510 | * @head: list management |
| 511 | * @base: base KMS object |
| 512 | * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h |
| 513 | * @connector_type_id: index into connector type enum |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 514 | * @interlace_allowed: can this connector handle interlaced modes? |
| 515 | * @doublescan_allowed: can this connector handle doublescan? |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 516 | * @modes: modes available on this connector (from fill_modes() + user) |
| 517 | * @status: one of the drm_connector_status enums (connected, not, or unknown) |
| 518 | * @probed_modes: list of modes derived directly from the display |
| 519 | * @display_info: information about attached display (e.g. from EDID) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 520 | * @funcs: connector control functions |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 521 | * @user_modes: user added mode list |
| 522 | * @edid_blob_ptr: DRM property containing EDID if present |
| 523 | * @property_ids: property tracking for this connector |
| 524 | * @property_values: value pointers or data for properties |
| 525 | * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling |
| 526 | * @dpms: current dpms state |
| 527 | * @helper_private: mid-layer private data |
| 528 | * @force: a %DRM_FORCE_<foo> state for forced mode sets |
| 529 | * @encoder_ids: valid encoders for this connector |
| 530 | * @encoder: encoder driving this connector, if any |
| 531 | * @eld: EDID-like data, if present |
| 532 | * @dvi_dual: dual link DVI, if found |
| 533 | * @max_tmds_clock: max clock rate, if found |
| 534 | * @latency_present: AV delay info from ELD, if found |
| 535 | * @video_latency: video latency info from ELD, if found |
| 536 | * @audio_latency: audio latency info from ELD, if found |
| 537 | * @null_edid_counter: track sinks that give us all zeros for the EDID |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 538 | * |
| 539 | * Each connector may be connected to one or more CRTCs, or may be clonable by |
| 540 | * another connector if they can share a CRTC. Each connector also has a specific |
| 541 | * position in the broader display (referred to as a 'screen' though it could |
| 542 | * span multiple monitors). |
| 543 | */ |
| 544 | struct drm_connector { |
| 545 | struct drm_device *dev; |
| 546 | struct device kdev; |
| 547 | struct device_attribute *attr; |
| 548 | struct list_head head; |
| 549 | |
| 550 | struct drm_mode_object base; |
| 551 | |
| 552 | int connector_type; |
| 553 | int connector_type_id; |
| 554 | bool interlace_allowed; |
| 555 | bool doublescan_allowed; |
| 556 | struct list_head modes; /* list of modes on this connector */ |
| 557 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 558 | enum drm_connector_status status; |
| 559 | |
| 560 | /* these are modes added by probing with DDC or the BIOS */ |
| 561 | struct list_head probed_modes; |
| 562 | |
| 563 | struct drm_display_info display_info; |
| 564 | const struct drm_connector_funcs *funcs; |
| 565 | |
| 566 | struct list_head user_modes; |
| 567 | struct drm_property_blob *edid_blob_ptr; |
| 568 | u32 property_ids[DRM_CONNECTOR_MAX_PROPERTY]; |
| 569 | uint64_t property_values[DRM_CONNECTOR_MAX_PROPERTY]; |
| 570 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 571 | uint8_t polled; /* DRM_CONNECTOR_POLL_* */ |
| 572 | |
Keith Packard | c9fb15f | 2009-05-30 20:42:28 -0700 | [diff] [blame] | 573 | /* requested DPMS state */ |
| 574 | int dpms; |
| 575 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 576 | void *helper_private; |
| 577 | |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 578 | /* forced on connector */ |
| 579 | enum drm_connector_force force; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 580 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 581 | struct drm_encoder *encoder; /* currently active encoder */ |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 582 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 583 | /* EDID bits */ |
| 584 | uint8_t eld[MAX_ELD_BYTES]; |
| 585 | bool dvi_dual; |
| 586 | int max_tmds_clock; /* in MHz */ |
| 587 | bool latency_present[2]; |
| 588 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ |
| 589 | int audio_latency[2]; |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 590 | int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 591 | }; |
| 592 | |
| 593 | /** |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 594 | * drm_plane_funcs - driver plane control functions |
| 595 | * @update_plane: update the plane configuration |
| 596 | * @disable_plane: shut down the plane |
| 597 | * @destroy: clean up plane resources |
| 598 | */ |
| 599 | struct drm_plane_funcs { |
| 600 | int (*update_plane)(struct drm_plane *plane, |
| 601 | struct drm_crtc *crtc, struct drm_framebuffer *fb, |
| 602 | int crtc_x, int crtc_y, |
| 603 | unsigned int crtc_w, unsigned int crtc_h, |
| 604 | uint32_t src_x, uint32_t src_y, |
| 605 | uint32_t src_w, uint32_t src_h); |
| 606 | int (*disable_plane)(struct drm_plane *plane); |
| 607 | void (*destroy)(struct drm_plane *plane); |
| 608 | }; |
| 609 | |
| 610 | /** |
| 611 | * drm_plane - central DRM plane control structure |
| 612 | * @dev: DRM device this plane belongs to |
| 613 | * @head: for list management |
| 614 | * @base: base mode object |
| 615 | * @possible_crtcs: pipes this plane can be bound to |
| 616 | * @format_types: array of formats supported by this plane |
| 617 | * @format_count: number of formats supported |
| 618 | * @crtc: currently bound CRTC |
| 619 | * @fb: currently bound fb |
| 620 | * @gamma_size: size of gamma table |
| 621 | * @gamma_store: gamma correction table |
| 622 | * @enabled: enabled flag |
| 623 | * @funcs: helper functions |
| 624 | * @helper_private: storage for drver layer |
| 625 | */ |
| 626 | struct drm_plane { |
| 627 | struct drm_device *dev; |
| 628 | struct list_head head; |
| 629 | |
| 630 | struct drm_mode_object base; |
| 631 | |
| 632 | uint32_t possible_crtcs; |
| 633 | uint32_t *format_types; |
| 634 | uint32_t format_count; |
| 635 | |
| 636 | struct drm_crtc *crtc; |
| 637 | struct drm_framebuffer *fb; |
| 638 | |
| 639 | /* CRTC gamma size for reporting to userspace */ |
| 640 | uint32_t gamma_size; |
| 641 | uint16_t *gamma_store; |
| 642 | |
| 643 | bool enabled; |
| 644 | |
| 645 | const struct drm_plane_funcs *funcs; |
| 646 | void *helper_private; |
| 647 | }; |
| 648 | |
| 649 | /** |
Jesse Barnes | ef27351 | 2011-11-07 12:03:19 -0800 | [diff] [blame] | 650 | * drm_mode_set - new values for a CRTC config change |
| 651 | * @head: list management |
| 652 | * @fb: framebuffer to use for new config |
| 653 | * @crtc: CRTC whose configuration we're about to change |
| 654 | * @mode: mode timings to use |
| 655 | * @x: position of this CRTC relative to @fb |
| 656 | * @y: position of this CRTC relative to @fb |
| 657 | * @connectors: array of connectors to drive with this CRTC if possible |
| 658 | * @num_connectors: size of @connectors array |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 659 | * |
| 660 | * Represents a single crtc the connectors that it drives with what mode |
| 661 | * and from which framebuffer it scans out from. |
| 662 | * |
| 663 | * This is used to set modes. |
| 664 | */ |
| 665 | struct drm_mode_set { |
| 666 | struct list_head head; |
| 667 | |
| 668 | struct drm_framebuffer *fb; |
| 669 | struct drm_crtc *crtc; |
| 670 | struct drm_display_mode *mode; |
| 671 | |
| 672 | uint32_t x; |
| 673 | uint32_t y; |
| 674 | |
| 675 | struct drm_connector **connectors; |
| 676 | size_t num_connectors; |
| 677 | }; |
| 678 | |
| 679 | /** |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 680 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
| 681 | * @fb_create: create a new framebuffer object |
| 682 | * @output_poll_changed: function to handle output configuration changes |
| 683 | * |
| 684 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that |
| 685 | * involve drivers. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 686 | */ |
| 687 | struct drm_mode_config_funcs { |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 688 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
| 689 | struct drm_file *file_priv, |
| 690 | struct drm_mode_fb_cmd2 *mode_cmd); |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 691 | void (*output_poll_changed)(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 692 | }; |
| 693 | |
Jesse Barnes | c1aaca2 | 2011-11-07 12:03:21 -0800 | [diff] [blame] | 694 | /** |
| 695 | * drm_mode_group - group of mode setting resources for potential sub-grouping |
| 696 | * @num_crtcs: CRTC count |
| 697 | * @num_encoders: encoder count |
| 698 | * @num_connectors: connector count |
| 699 | * @id_list: list of KMS object IDs in this group |
| 700 | * |
| 701 | * Currently this simply tracks the global mode setting state. But in the |
| 702 | * future it could allow groups of objects to be set aside into independent |
| 703 | * control groups for use by different user level processes (e.g. two X servers |
| 704 | * running simultaneously on different heads, each with their own mode |
| 705 | * configuration and freedom of mode setting). |
| 706 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 707 | struct drm_mode_group { |
| 708 | uint32_t num_crtcs; |
| 709 | uint32_t num_encoders; |
| 710 | uint32_t num_connectors; |
| 711 | |
| 712 | /* list of object IDs for this group */ |
| 713 | uint32_t *id_list; |
| 714 | }; |
| 715 | |
| 716 | /** |
| 717 | * drm_mode_config - Mode configuration control structure |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 718 | * @mutex: mutex protecting KMS related lists and structures |
| 719 | * @idr_mutex: mutex for KMS ID allocation and management |
| 720 | * @crtc_idr: main KMS ID tracking object |
| 721 | * @num_fb: number of fbs available |
| 722 | * @fb_list: list of framebuffers available |
| 723 | * @num_connector: number of connectors on this device |
| 724 | * @connector_list: list of connector objects |
| 725 | * @num_encoder: number of encoders on this device |
| 726 | * @encoder_list: list of encoder objects |
| 727 | * @num_crtc: number of CRTCs on this device |
| 728 | * @crtc_list: list of CRTC objects |
| 729 | * @min_width: minimum pixel width on this device |
| 730 | * @min_height: minimum pixel height on this device |
| 731 | * @max_width: maximum pixel width on this device |
| 732 | * @max_height: maximum pixel height on this device |
| 733 | * @funcs: core driver provided mode setting functions |
| 734 | * @fb_base: base address of the framebuffer |
| 735 | * @poll_enabled: track polling status for this device |
| 736 | * @output_poll_work: delayed work for polling in process context |
| 737 | * @*_property: core property tracking |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 738 | * |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 739 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
| 740 | * enumerated by the driver are added here, as are global properties. Some |
| 741 | * global restrictions are also here, e.g. dimension restrictions. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 742 | */ |
| 743 | struct drm_mode_config { |
Jesse Barnes | ad2563c | 2009-01-19 17:21:45 +1000 | [diff] [blame] | 744 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
| 745 | struct mutex idr_mutex; /* for IDR management */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 746 | struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
| 747 | /* this is limited to one for now */ |
| 748 | int num_fb; |
| 749 | struct list_head fb_list; |
| 750 | int num_connector; |
| 751 | struct list_head connector_list; |
| 752 | int num_encoder; |
| 753 | struct list_head encoder_list; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 754 | int num_plane; |
| 755 | struct list_head plane_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 756 | |
| 757 | int num_crtc; |
| 758 | struct list_head crtc_list; |
| 759 | |
| 760 | struct list_head property_list; |
| 761 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 762 | int min_width, min_height; |
| 763 | int max_width, max_height; |
| 764 | struct drm_mode_config_funcs *funcs; |
Benjamin Herrenschmidt | d883f7f | 2009-02-02 16:55:45 +1100 | [diff] [blame] | 765 | resource_size_t fb_base; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 766 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 767 | /* output poll support */ |
| 768 | bool poll_enabled; |
Tejun Heo | 991ea75 | 2010-07-20 22:09:02 +0200 | [diff] [blame] | 769 | struct delayed_work output_poll_work; |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 770 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 771 | /* pointers to standard properties */ |
| 772 | struct list_head property_blob_list; |
| 773 | struct drm_property *edid_property; |
| 774 | struct drm_property *dpms_property; |
| 775 | |
| 776 | /* DVI-I properties */ |
| 777 | struct drm_property *dvi_i_subconnector_property; |
| 778 | struct drm_property *dvi_i_select_subconnector_property; |
| 779 | |
| 780 | /* TV properties */ |
| 781 | struct drm_property *tv_subconnector_property; |
| 782 | struct drm_property *tv_select_subconnector_property; |
| 783 | struct drm_property *tv_mode_property; |
| 784 | struct drm_property *tv_left_margin_property; |
| 785 | struct drm_property *tv_right_margin_property; |
| 786 | struct drm_property *tv_top_margin_property; |
| 787 | struct drm_property *tv_bottom_margin_property; |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 788 | struct drm_property *tv_brightness_property; |
| 789 | struct drm_property *tv_contrast_property; |
| 790 | struct drm_property *tv_flicker_reduction_property; |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 791 | struct drm_property *tv_overscan_property; |
| 792 | struct drm_property *tv_saturation_property; |
| 793 | struct drm_property *tv_hue_property; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 794 | |
| 795 | /* Optional properties */ |
| 796 | struct drm_property *scaling_mode_property; |
| 797 | struct drm_property *dithering_mode_property; |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 798 | struct drm_property *dirty_info_property; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 799 | }; |
| 800 | |
| 801 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) |
| 802 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) |
| 803 | #define obj_to_encoder(x) container_of(x, struct drm_encoder, base) |
| 804 | #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) |
| 805 | #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) |
| 806 | #define obj_to_property(x) container_of(x, struct drm_property, base) |
| 807 | #define obj_to_blob(x) container_of(x, struct drm_property_blob, base) |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 808 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 809 | |
| 810 | |
| 811 | extern void drm_crtc_init(struct drm_device *dev, |
| 812 | struct drm_crtc *crtc, |
| 813 | const struct drm_crtc_funcs *funcs); |
| 814 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
| 815 | |
| 816 | extern void drm_connector_init(struct drm_device *dev, |
| 817 | struct drm_connector *connector, |
| 818 | const struct drm_connector_funcs *funcs, |
| 819 | int connector_type); |
| 820 | |
| 821 | extern void drm_connector_cleanup(struct drm_connector *connector); |
| 822 | |
| 823 | extern void drm_encoder_init(struct drm_device *dev, |
| 824 | struct drm_encoder *encoder, |
| 825 | const struct drm_encoder_funcs *funcs, |
| 826 | int encoder_type); |
| 827 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 828 | extern int drm_plane_init(struct drm_device *dev, |
| 829 | struct drm_plane *plane, |
| 830 | unsigned long possible_crtcs, |
| 831 | const struct drm_plane_funcs *funcs, |
Ville Syrjälä | 22cd7c6 | 2011-12-20 00:06:46 +0200 | [diff] [blame] | 832 | const uint32_t *formats, uint32_t format_count); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 833 | extern void drm_plane_cleanup(struct drm_plane *plane); |
| 834 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 835 | extern void drm_encoder_cleanup(struct drm_encoder *encoder); |
| 836 | |
| 837 | extern char *drm_get_connector_name(struct drm_connector *connector); |
| 838 | extern char *drm_get_dpms_name(int val); |
| 839 | extern char *drm_get_dvi_i_subconnector_name(int val); |
| 840 | extern char *drm_get_dvi_i_select_name(int val); |
| 841 | extern char *drm_get_tv_subconnector_name(int val); |
| 842 | extern char *drm_get_tv_select_name(int val); |
Kristian Høgsberg | ea39f83 | 2009-02-12 14:37:56 -0500 | [diff] [blame] | 843 | extern void drm_fb_release(struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 844 | extern int drm_mode_group_init_legacy_group(struct drm_device *dev, struct drm_mode_group *group); |
| 845 | extern struct edid *drm_get_edid(struct drm_connector *connector, |
| 846 | struct i2c_adapter *adapter); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 847 | extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); |
| 848 | extern void drm_mode_probed_add(struct drm_connector *connector, struct drm_display_mode *mode); |
| 849 | extern void drm_mode_remove(struct drm_connector *connector, struct drm_display_mode *mode); |
| 850 | extern struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 851 | const struct drm_display_mode *mode); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 852 | extern void drm_mode_debug_printmodeline(struct drm_display_mode *mode); |
| 853 | extern void drm_mode_config_init(struct drm_device *dev); |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 854 | extern void drm_mode_config_reset(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 855 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
| 856 | extern void drm_mode_set_name(struct drm_display_mode *mode); |
| 857 | extern bool drm_mode_equal(struct drm_display_mode *mode1, struct drm_display_mode *mode2); |
| 858 | extern int drm_mode_width(struct drm_display_mode *mode); |
| 859 | extern int drm_mode_height(struct drm_display_mode *mode); |
| 860 | |
| 861 | /* for us by fb module */ |
| 862 | extern int drm_mode_attachmode_crtc(struct drm_device *dev, |
| 863 | struct drm_crtc *crtc, |
| 864 | struct drm_display_mode *mode); |
| 865 | extern int drm_mode_detachmode_crtc(struct drm_device *dev, struct drm_display_mode *mode); |
| 866 | |
| 867 | extern struct drm_display_mode *drm_mode_create(struct drm_device *dev); |
| 868 | extern void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode); |
| 869 | extern void drm_mode_list_concat(struct list_head *head, |
| 870 | struct list_head *new); |
| 871 | extern void drm_mode_validate_size(struct drm_device *dev, |
| 872 | struct list_head *mode_list, |
| 873 | int maxX, int maxY, int maxPitch); |
| 874 | extern void drm_mode_prune_invalid(struct drm_device *dev, |
| 875 | struct list_head *mode_list, bool verbose); |
| 876 | extern void drm_mode_sort(struct list_head *mode_list); |
Chris Wilson | b1f559e | 2011-01-26 09:49:47 +0000 | [diff] [blame] | 877 | extern int drm_mode_hsync(const struct drm_display_mode *mode); |
| 878 | extern int drm_mode_vrefresh(const struct drm_display_mode *mode); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 879 | extern void drm_mode_set_crtcinfo(struct drm_display_mode *p, |
| 880 | int adjust_flags); |
| 881 | extern void drm_mode_connector_list_update(struct drm_connector *connector); |
| 882 | extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
| 883 | struct edid *edid); |
| 884 | extern int drm_connector_property_set_value(struct drm_connector *connector, |
| 885 | struct drm_property *property, |
| 886 | uint64_t value); |
| 887 | extern int drm_connector_property_get_value(struct drm_connector *connector, |
| 888 | struct drm_property *property, |
| 889 | uint64_t *value); |
| 890 | extern struct drm_display_mode *drm_crtc_mode_create(struct drm_device *dev); |
| 891 | extern void drm_framebuffer_set_object(struct drm_device *dev, |
| 892 | unsigned long handle); |
| 893 | extern int drm_framebuffer_init(struct drm_device *dev, |
| 894 | struct drm_framebuffer *fb, |
| 895 | const struct drm_framebuffer_funcs *funcs); |
| 896 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); |
| 897 | extern int drmfb_probe(struct drm_device *dev, struct drm_crtc *crtc); |
| 898 | extern int drmfb_remove(struct drm_device *dev, struct drm_framebuffer *fb); |
| 899 | extern void drm_crtc_probe_connector_modes(struct drm_device *dev, int maxX, int maxY); |
| 900 | extern bool drm_crtc_in_use(struct drm_crtc *crtc); |
| 901 | |
| 902 | extern int drm_connector_attach_property(struct drm_connector *connector, |
| 903 | struct drm_property *property, uint64_t init_val); |
| 904 | extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
| 905 | const char *name, int num_values); |
| 906 | extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); |
| 907 | extern int drm_property_add_enum(struct drm_property *property, int index, |
| 908 | uint64_t value, const char *name); |
| 909 | extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); |
| 910 | extern int drm_mode_create_tv_properties(struct drm_device *dev, int num_formats, |
| 911 | char *formats[]); |
| 912 | extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); |
| 913 | extern int drm_mode_create_dithering_property(struct drm_device *dev); |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 914 | extern int drm_mode_create_dirty_info_property(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 915 | extern char *drm_get_encoder_name(struct drm_encoder *encoder); |
| 916 | |
| 917 | extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, |
| 918 | struct drm_encoder *encoder); |
| 919 | extern void drm_mode_connector_detach_encoder(struct drm_connector *connector, |
| 920 | struct drm_encoder *encoder); |
| 921 | extern bool drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
| 922 | int gamma_size); |
Daniel Vetter | 7a9c906 | 2009-09-15 22:57:31 +0200 | [diff] [blame] | 923 | extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
| 924 | uint32_t id, uint32_t type); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 925 | /* IOCTLs */ |
| 926 | extern int drm_mode_getresources(struct drm_device *dev, |
| 927 | void *data, struct drm_file *file_priv); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 928 | extern int drm_mode_getplane_res(struct drm_device *dev, void *data, |
| 929 | struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 930 | extern int drm_mode_getcrtc(struct drm_device *dev, |
| 931 | void *data, struct drm_file *file_priv); |
| 932 | extern int drm_mode_getconnector(struct drm_device *dev, |
| 933 | void *data, struct drm_file *file_priv); |
| 934 | extern int drm_mode_setcrtc(struct drm_device *dev, |
| 935 | void *data, struct drm_file *file_priv); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 936 | extern int drm_mode_getplane(struct drm_device *dev, |
| 937 | void *data, struct drm_file *file_priv); |
| 938 | extern int drm_mode_setplane(struct drm_device *dev, |
| 939 | void *data, struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 940 | extern int drm_mode_cursor_ioctl(struct drm_device *dev, |
| 941 | void *data, struct drm_file *file_priv); |
| 942 | extern int drm_mode_addfb(struct drm_device *dev, |
| 943 | void *data, struct drm_file *file_priv); |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 944 | extern int drm_mode_addfb2(struct drm_device *dev, |
| 945 | void *data, struct drm_file *file_priv); |
| 946 | extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 947 | extern int drm_mode_rmfb(struct drm_device *dev, |
| 948 | void *data, struct drm_file *file_priv); |
| 949 | extern int drm_mode_getfb(struct drm_device *dev, |
| 950 | void *data, struct drm_file *file_priv); |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 951 | extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
| 952 | void *data, struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 953 | extern int drm_mode_addmode_ioctl(struct drm_device *dev, |
| 954 | void *data, struct drm_file *file_priv); |
| 955 | extern int drm_mode_rmmode_ioctl(struct drm_device *dev, |
| 956 | void *data, struct drm_file *file_priv); |
| 957 | extern int drm_mode_attachmode_ioctl(struct drm_device *dev, |
| 958 | void *data, struct drm_file *file_priv); |
| 959 | extern int drm_mode_detachmode_ioctl(struct drm_device *dev, |
| 960 | void *data, struct drm_file *file_priv); |
| 961 | |
| 962 | extern int drm_mode_getproperty_ioctl(struct drm_device *dev, |
| 963 | void *data, struct drm_file *file_priv); |
| 964 | extern int drm_mode_getblob_ioctl(struct drm_device *dev, |
| 965 | void *data, struct drm_file *file_priv); |
| 966 | extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev, |
| 967 | void *data, struct drm_file *file_priv); |
| 968 | extern int drm_mode_hotplug_ioctl(struct drm_device *dev, |
| 969 | void *data, struct drm_file *file_priv); |
| 970 | extern int drm_mode_replacefb(struct drm_device *dev, |
| 971 | void *data, struct drm_file *file_priv); |
| 972 | extern int drm_mode_getencoder(struct drm_device *dev, |
| 973 | void *data, struct drm_file *file_priv); |
| 974 | extern int drm_mode_gamma_get_ioctl(struct drm_device *dev, |
| 975 | void *data, struct drm_file *file_priv); |
| 976 | extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, |
| 977 | void *data, struct drm_file *file_priv); |
Ben Skeggs | eccaca2 | 2011-03-30 05:03:47 +0000 | [diff] [blame] | 978 | extern u8 *drm_find_cea_extension(struct edid *edid); |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 979 | extern bool drm_detect_hdmi_monitor(struct edid *edid); |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 980 | extern bool drm_detect_monitor_audio(struct edid *edid); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 981 | extern int drm_mode_page_flip_ioctl(struct drm_device *dev, |
| 982 | void *data, struct drm_file *file_priv); |
Zhao Yakui | d782c3f | 2009-06-22 13:17:08 +0800 | [diff] [blame] | 983 | extern struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, |
| 984 | int hdisplay, int vdisplay, int vrefresh, |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 985 | bool reduced, bool interlaced, bool margins); |
Zhao Yakui | 26bbdad | 2009-06-22 13:17:09 +0800 | [diff] [blame] | 986 | extern struct drm_display_mode *drm_gtf_mode(struct drm_device *dev, |
| 987 | int hdisplay, int vdisplay, int vrefresh, |
| 988 | bool interlaced, int margins); |
Adam Jackson | 7a37435 | 2010-03-29 21:43:30 +0000 | [diff] [blame] | 989 | extern struct drm_display_mode *drm_gtf_mode_complex(struct drm_device *dev, |
| 990 | int hdisplay, int vdisplay, int vrefresh, |
| 991 | bool interlaced, int margins, int GTF_M, |
| 992 | int GTF_2C, int GTF_K, int GTF_2J); |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 993 | extern int drm_add_modes_noedid(struct drm_connector *connector, |
| 994 | int hdisplay, int vdisplay); |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 995 | |
Thomas Reim | 051963d | 2011-07-29 14:28:57 +0000 | [diff] [blame] | 996 | extern int drm_edid_header_is_valid(const u8 *raw_edid); |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 997 | extern bool drm_edid_is_valid(struct edid *edid); |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 998 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
| 999 | int hsize, int vsize, int fresh); |
Dave Airlie | ff72145b | 2011-02-07 12:16:14 +1000 | [diff] [blame] | 1000 | |
| 1001 | extern int drm_mode_create_dumb_ioctl(struct drm_device *dev, |
| 1002 | void *data, struct drm_file *file_priv); |
| 1003 | extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev, |
| 1004 | void *data, struct drm_file *file_priv); |
| 1005 | extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev, |
| 1006 | void *data, struct drm_file *file_priv); |
Dave Airlie | 248dbc2 | 2011-11-29 20:02:54 +0000 | [diff] [blame] | 1007 | |
| 1008 | extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, |
| 1009 | int *bpp); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1010 | #endif /* __DRM_CRTC_H__ */ |