aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-10 04:55:35 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-11-10 04:55:35 -0500
commiteb84f976c88d72cbcbe756df38d1f19be3db77d6 (patch)
treedb3ff3b5edc305a0352b69327b914ef3a92e05a5 /include
parent69f627f56fac212c1e49cd0d285e3f8cd264dd0c (diff)
parentcc7096fb6d1dfbdac5e7e2675c046fd40646cc66 (diff)
Merge remote-tracking branch 'airlied/drm-next' into HEAD
Backmerge drm-next so that I can keep merging patches. Specifically I want: - atomic stuff, yay! - eld parsing patch from Jani. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'include')
-rw-r--r--include/drm/drmP.h8
-rw-r--r--include/drm/drm_atomic.h67
-rw-r--r--include/drm/drm_atomic_helper.h97
-rw-r--r--include/drm/drm_crtc.h246
-rw-r--r--include/drm/drm_crtc_helper.h13
-rw-r--r--include/drm/drm_dp_helper.h21
-rw-r--r--include/drm/drm_dp_mst_helper.h2
-rw-r--r--include/drm/drm_edid.h102
-rw-r--r--include/drm/drm_modeset_lock.h1
-rw-r--r--include/drm/drm_plane_helper.h39
10 files changed, 539 insertions, 57 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 53ed87698a74..d7ebd7b207e3 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -125,8 +125,8 @@ struct dma_buf_attachment;
125extern __printf(2, 3) 125extern __printf(2, 3)
126void drm_ut_debug_printk(const char *function_name, 126void drm_ut_debug_printk(const char *function_name,
127 const char *format, ...); 127 const char *format, ...);
128extern __printf(2, 3) 128extern __printf(1, 2)
129void drm_err(const char *func, const char *format, ...); 129void drm_err(const char *format, ...);
130 130
131/***********************************************************************/ 131/***********************************************************************/
132/** \name DRM template customization defaults */ 132/** \name DRM template customization defaults */
@@ -155,7 +155,7 @@ void drm_err(const char *func, const char *format, ...);
155 * \param arg arguments 155 * \param arg arguments
156 */ 156 */
157#define DRM_ERROR(fmt, ...) \ 157#define DRM_ERROR(fmt, ...) \
158 drm_err(__func__, fmt, ##__VA_ARGS__) 158 drm_err(fmt, ##__VA_ARGS__)
159 159
160/** 160/**
161 * Rate limited error output. Like DRM_ERROR() but won't flood the log. 161 * Rate limited error output. Like DRM_ERROR() but won't flood the log.
@@ -170,7 +170,7 @@ void drm_err(const char *func, const char *format, ...);
170 DEFAULT_RATELIMIT_BURST); \ 170 DEFAULT_RATELIMIT_BURST); \
171 \ 171 \
172 if (__ratelimit(&_rs)) \ 172 if (__ratelimit(&_rs)) \
173 drm_err(__func__, fmt, ##__VA_ARGS__); \ 173 drm_err(fmt, ##__VA_ARGS__); \
174}) 174})
175 175
176#define DRM_INFO(fmt, ...) \ 176#define DRM_INFO(fmt, ...) \
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
new file mode 100644
index 000000000000..9d919168bc11
--- /dev/null
+++ b/include/drm/drm_atomic.h
@@ -0,0 +1,67 @@
1/*
2 * Copyright (C) 2014 Red Hat
3 * Copyright (C) 2014 Intel Corp.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Rob Clark <robdclark@gmail.com>
25 * Daniel Vetter <daniel.vetter@ffwll.ch>
26 */
27
28#ifndef DRM_ATOMIC_H_
29#define DRM_ATOMIC_H_
30
31struct drm_atomic_state * __must_check
32drm_atomic_state_alloc(struct drm_device *dev);
33void drm_atomic_state_clear(struct drm_atomic_state *state);
34void drm_atomic_state_free(struct drm_atomic_state *state);
35
36struct drm_crtc_state * __must_check
37drm_atomic_get_crtc_state(struct drm_atomic_state *state,
38 struct drm_crtc *crtc);
39struct drm_plane_state * __must_check
40drm_atomic_get_plane_state(struct drm_atomic_state *state,
41 struct drm_plane *plane);
42struct drm_connector_state * __must_check
43drm_atomic_get_connector_state(struct drm_atomic_state *state,
44 struct drm_connector *connector);
45
46int __must_check
47drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
48 struct drm_crtc *crtc);
49void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
50 struct drm_framebuffer *fb);
51int __must_check
52drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
53 struct drm_crtc *crtc);
54int __must_check
55drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
56 struct drm_crtc *crtc);
57int
58drm_atomic_connectors_for_crtc(struct drm_atomic_state *state,
59 struct drm_crtc *crtc);
60
61void drm_atomic_legacy_backoff(struct drm_atomic_state *state);
62
63int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
64int __must_check drm_atomic_commit(struct drm_atomic_state *state);
65int __must_check drm_atomic_async_commit(struct drm_atomic_state *state);
66
67#endif /* DRM_ATOMIC_H_ */
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
new file mode 100644
index 000000000000..67e3c4645ae0
--- /dev/null
+++ b/include/drm/drm_atomic_helper.h
@@ -0,0 +1,97 @@
1/*
2 * Copyright (C) 2014 Red Hat
3 * Copyright (C) 2014 Intel Corp.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Rob Clark <robdclark@gmail.com>
25 * Daniel Vetter <daniel.vetter@ffwll.ch>
26 */
27
28#ifndef DRM_ATOMIC_HELPER_H_
29#define DRM_ATOMIC_HELPER_H_
30
31int drm_atomic_helper_check(struct drm_device *dev,
32 struct drm_atomic_state *state);
33int drm_atomic_helper_commit(struct drm_device *dev,
34 struct drm_atomic_state *state,
35 bool async);
36
37void drm_atomic_helper_commit_pre_planes(struct drm_device *dev,
38 struct drm_atomic_state *state);
39void drm_atomic_helper_commit_post_planes(struct drm_device *dev,
40 struct drm_atomic_state *old_state);
41
42int drm_atomic_helper_prepare_planes(struct drm_device *dev,
43 struct drm_atomic_state *state);
44void drm_atomic_helper_commit_planes(struct drm_device *dev,
45 struct drm_atomic_state *state);
46void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
47 struct drm_atomic_state *old_state);
48
49void drm_atomic_helper_swap_state(struct drm_device *dev,
50 struct drm_atomic_state *state);
51
52/* implementations for legacy interfaces */
53int drm_atomic_helper_update_plane(struct drm_plane *plane,
54 struct drm_crtc *crtc,
55 struct drm_framebuffer *fb,
56 int crtc_x, int crtc_y,
57 unsigned int crtc_w, unsigned int crtc_h,
58 uint32_t src_x, uint32_t src_y,
59 uint32_t src_w, uint32_t src_h);
60int drm_atomic_helper_disable_plane(struct drm_plane *plane);
61int drm_atomic_helper_set_config(struct drm_mode_set *set);
62
63int drm_atomic_helper_crtc_set_property(struct drm_crtc *crtc,
64 struct drm_property *property,
65 uint64_t val);
66int drm_atomic_helper_plane_set_property(struct drm_plane *plane,
67 struct drm_property *property,
68 uint64_t val);
69int drm_atomic_helper_connector_set_property(struct drm_connector *connector,
70 struct drm_property *property,
71 uint64_t val);
72int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
73 struct drm_framebuffer *fb,
74 struct drm_pending_vblank_event *event,
75 uint32_t flags);
76
77/* default implementations for state handling */
78void drm_atomic_helper_crtc_reset(struct drm_crtc *crtc);
79struct drm_crtc_state *
80drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc);
81void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
82 struct drm_crtc_state *state);
83
84void drm_atomic_helper_plane_reset(struct drm_plane *plane);
85struct drm_plane_state *
86drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane);
87void drm_atomic_helper_plane_destroy_state(struct drm_plane *plane,
88 struct drm_plane_state *state);
89
90void drm_atomic_helper_connector_reset(struct drm_connector *connector);
91struct drm_connector_state *
92drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
93void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
94 struct drm_connector_state *state);
95
96
97#endif /* DRM_ATOMIC_HELPER_H_ */
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c40070a92d6b..bc1cc3ce05c4 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -42,6 +42,7 @@ struct drm_object_properties;
42struct drm_file; 42struct drm_file;
43struct drm_clip_rect; 43struct drm_clip_rect;
44struct device_node; 44struct device_node;
45struct fence;
45 46
46#define DRM_MODE_OBJECT_CRTC 0xcccccccc 47#define DRM_MODE_OBJECT_CRTC 0xcccccccc
47#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 48#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
@@ -142,8 +143,8 @@ struct drm_framebuffer_funcs {
142 int (*create_handle)(struct drm_framebuffer *fb, 143 int (*create_handle)(struct drm_framebuffer *fb,
143 struct drm_file *file_priv, 144 struct drm_file *file_priv,
144 unsigned int *handle); 145 unsigned int *handle);
145 /** 146 /*
146 * Optinal callback for the dirty fb ioctl. 147 * Optional callback for the dirty fb ioctl.
147 * 148 *
148 * Userspace can notify the driver via this callback 149 * Userspace can notify the driver via this callback
149 * that a area of the framebuffer has changed and should 150 * that a area of the framebuffer has changed and should
@@ -224,19 +225,57 @@ struct drm_encoder;
224struct drm_pending_vblank_event; 225struct drm_pending_vblank_event;
225struct drm_plane; 226struct drm_plane;
226struct drm_bridge; 227struct drm_bridge;
228struct drm_atomic_state;
229
230/**
231 * struct drm_crtc_state - mutable CRTC state
232 * @enable: whether the CRTC should be enabled, gates all other state
233 * @mode_changed: for use by helpers and drivers when computing state updates
234 * @last_vblank_count: for helpers and drivers to capture the vblank of the
235 * update to ensure framebuffer cleanup isn't done too early
236 * @planes_changed: for use by helpers and drivers when computing state updates
237 * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
238 * @mode: current mode timings
239 * @event: optional pointer to a DRM event to signal upon completion of the
240 * state update
241 * @state: backpointer to global drm_atomic_state
242 */
243struct drm_crtc_state {
244 bool enable;
245
246 /* computed state bits used by helpers and drivers */
247 bool planes_changed : 1;
248 bool mode_changed : 1;
249
250 /* last_vblank_count: for vblank waits before cleanup */
251 u32 last_vblank_count;
252
253 /* adjusted_mode: for use by helpers and drivers */
254 struct drm_display_mode adjusted_mode;
255
256 struct drm_display_mode mode;
257
258 struct drm_pending_vblank_event *event;
259
260 struct drm_atomic_state *state;
261};
227 262
228/** 263/**
229 * drm_crtc_funcs - control CRTCs for a given device 264 * struct drm_crtc_funcs - control CRTCs for a given device
230 * @save: save CRTC state 265 * @save: save CRTC state
231 * @restore: restore CRTC state 266 * @restore: restore CRTC state
232 * @reset: reset CRTC after state has been invalidated (e.g. resume) 267 * @reset: reset CRTC after state has been invalidated (e.g. resume)
233 * @cursor_set: setup the cursor 268 * @cursor_set: setup the cursor
269 * @cursor_set2: setup the cursor with hotspot, superseeds @cursor_set if set
234 * @cursor_move: move the cursor 270 * @cursor_move: move the cursor
235 * @gamma_set: specify color ramp for CRTC 271 * @gamma_set: specify color ramp for CRTC
236 * @destroy: deinit and free object 272 * @destroy: deinit and free object
237 * @set_property: called when a property is changed 273 * @set_property: called when a property is changed
238 * @set_config: apply a new CRTC configuration 274 * @set_config: apply a new CRTC configuration
239 * @page_flip: initiate a page flip 275 * @page_flip: initiate a page flip
276 * @atomic_duplicate_state: duplicate the atomic state for this CRTC
277 * @atomic_destroy_state: destroy an atomic state for this CRTC
278 * @atomic_set_property: set a property on an atomic state for this CRTC
240 * 279 *
241 * The drm_crtc_funcs structure is the central CRTC management structure 280 * The drm_crtc_funcs structure is the central CRTC management structure
242 * in the DRM. Each CRTC controls one or more connectors (note that the name 281 * in the DRM. Each CRTC controls one or more connectors (note that the name
@@ -287,16 +326,28 @@ struct drm_crtc_funcs {
287 326
288 int (*set_property)(struct drm_crtc *crtc, 327 int (*set_property)(struct drm_crtc *crtc,
289 struct drm_property *property, uint64_t val); 328 struct drm_property *property, uint64_t val);
329
330 /* atomic update handling */
331 struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc);
332 void (*atomic_destroy_state)(struct drm_crtc *crtc,
333 struct drm_crtc_state *state);
334 int (*atomic_set_property)(struct drm_crtc *crtc,
335 struct drm_crtc_state *state,
336 struct drm_property *property,
337 uint64_t val);
290}; 338};
291 339
292/** 340/**
293 * drm_crtc - central CRTC control structure 341 * struct drm_crtc - central CRTC control structure
294 * @dev: parent DRM device 342 * @dev: parent DRM device
343 * @port: OF node used by drm_of_find_possible_crtcs()
295 * @head: list management 344 * @head: list management
296 * @mutex: per-CRTC locking 345 * @mutex: per-CRTC locking
297 * @base: base KMS object for ID tracking etc. 346 * @base: base KMS object for ID tracking etc.
298 * @primary: primary plane for this CRTC 347 * @primary: primary plane for this CRTC
299 * @cursor: cursor plane for this CRTC 348 * @cursor: cursor plane for this CRTC
349 * @cursor_x: current x position of the cursor, used for universal cursor planes
350 * @cursor_y: current y position of the cursor, used for universal cursor planes
300 * @enabled: is this CRTC enabled? 351 * @enabled: is this CRTC enabled?
301 * @mode: current mode timings 352 * @mode: current mode timings
302 * @hwmode: mode timings as programmed to hw regs 353 * @hwmode: mode timings as programmed to hw regs
@@ -309,10 +360,13 @@ struct drm_crtc_funcs {
309 * @gamma_size: size of gamma ramp 360 * @gamma_size: size of gamma ramp
310 * @gamma_store: gamma ramp values 361 * @gamma_store: gamma ramp values
311 * @framedur_ns: precise frame timing 362 * @framedur_ns: precise frame timing
312 * @framedur_ns: precise line timing 363 * @linedur_ns: precise line timing
313 * @pixeldur_ns: precise pixel timing 364 * @pixeldur_ns: precise pixel timing
314 * @helper_private: mid-layer private data 365 * @helper_private: mid-layer private data
315 * @properties: property tracking for this CRTC 366 * @properties: property tracking for this CRTC
367 * @state: current atomic state for this CRTC
368 * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for
369 * legacy ioctls
316 * 370 *
317 * Each CRTC may have one or more connectors associated with it. This structure 371 * Each CRTC may have one or more connectors associated with it. This structure
318 * allows the CRTC to be controlled. 372 * allows the CRTC to be controlled.
@@ -322,7 +376,7 @@ struct drm_crtc {
322 struct device_node *port; 376 struct device_node *port;
323 struct list_head head; 377 struct list_head head;
324 378
325 /** 379 /*
326 * crtc mutex 380 * crtc mutex
327 * 381 *
328 * This provides a read lock for the overall crtc state (mode, dpms 382 * This provides a read lock for the overall crtc state (mode, dpms
@@ -368,6 +422,8 @@ struct drm_crtc {
368 422
369 struct drm_object_properties properties; 423 struct drm_object_properties properties;
370 424
425 struct drm_crtc_state *state;
426
371 /* 427 /*
372 * For legacy crtc ioctls so that atomic drivers can get at the locking 428 * For legacy crtc ioctls so that atomic drivers can get at the locking
373 * acquire context. 429 * acquire context.
@@ -375,9 +431,22 @@ struct drm_crtc {
375 struct drm_modeset_acquire_ctx *acquire_ctx; 431 struct drm_modeset_acquire_ctx *acquire_ctx;
376}; 432};
377 433
434/**
435 * struct drm_connector_state - mutable connector state
436 * @crtc: CRTC to connect connector to, NULL if disabled
437 * @best_encoder: can be used by helpers and drivers to select the encoder
438 * @state: backpointer to global drm_atomic_state
439 */
440struct drm_connector_state {
441 struct drm_crtc *crtc;
442
443 struct drm_encoder *best_encoder;
444
445 struct drm_atomic_state *state;
446};
378 447
379/** 448/**
380 * drm_connector_funcs - control connectors on a given device 449 * struct drm_connector_funcs - control connectors on a given device
381 * @dpms: set power state (see drm_crtc_funcs above) 450 * @dpms: set power state (see drm_crtc_funcs above)
382 * @save: save connector state 451 * @save: save connector state
383 * @restore: restore connector state 452 * @restore: restore connector state
@@ -387,6 +456,9 @@ struct drm_crtc {
387 * @set_property: property for this connector may need an update 456 * @set_property: property for this connector may need an update
388 * @destroy: make object go away 457 * @destroy: make object go away
389 * @force: notify the driver that the connector is forced on 458 * @force: notify the driver that the connector is forced on
459 * @atomic_duplicate_state: duplicate the atomic state for this connector
460 * @atomic_destroy_state: destroy an atomic state for this connector
461 * @atomic_set_property: set a property on an atomic state for this connector
390 * 462 *
391 * Each CRTC may have one or more connectors attached to it. The functions 463 * Each CRTC may have one or more connectors attached to it. The functions
392 * below allow the core DRM code to control connectors, enumerate available modes, 464 * below allow the core DRM code to control connectors, enumerate available modes,
@@ -411,10 +483,19 @@ struct drm_connector_funcs {
411 uint64_t val); 483 uint64_t val);
412 void (*destroy)(struct drm_connector *connector); 484 void (*destroy)(struct drm_connector *connector);
413 void (*force)(struct drm_connector *connector); 485 void (*force)(struct drm_connector *connector);
486
487 /* atomic update handling */
488 struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
489 void (*atomic_destroy_state)(struct drm_connector *connector,
490 struct drm_connector_state *state);
491 int (*atomic_set_property)(struct drm_connector *connector,
492 struct drm_connector_state *state,
493 struct drm_property *property,
494 uint64_t val);
414}; 495};
415 496
416/** 497/**
417 * drm_encoder_funcs - encoder controls 498 * struct drm_encoder_funcs - encoder controls
418 * @reset: reset state (e.g. at init or resume time) 499 * @reset: reset state (e.g. at init or resume time)
419 * @destroy: cleanup and free associated data 500 * @destroy: cleanup and free associated data
420 * 501 *
@@ -428,7 +509,7 @@ struct drm_encoder_funcs {
428#define DRM_CONNECTOR_MAX_ENCODER 3 509#define DRM_CONNECTOR_MAX_ENCODER 3
429 510
430/** 511/**
431 * drm_encoder - central DRM encoder structure 512 * struct drm_encoder - central DRM encoder structure
432 * @dev: parent DRM device 513 * @dev: parent DRM device
433 * @head: list management 514 * @head: list management
434 * @base: base KMS object 515 * @base: base KMS object
@@ -472,7 +553,7 @@ struct drm_encoder {
472#define MAX_ELD_BYTES 128 553#define MAX_ELD_BYTES 128
473 554
474/** 555/**
475 * drm_connector - central DRM connector control structure 556 * struct drm_connector - central DRM connector control structure
476 * @dev: parent DRM device 557 * @dev: parent DRM device
477 * @kdev: kernel device for sysfs attributes 558 * @kdev: kernel device for sysfs attributes
478 * @attr: sysfs attributes 559 * @attr: sysfs attributes
@@ -483,6 +564,7 @@ struct drm_encoder {
483 * @connector_type_id: index into connector type enum 564 * @connector_type_id: index into connector type enum
484 * @interlace_allowed: can this connector handle interlaced modes? 565 * @interlace_allowed: can this connector handle interlaced modes?
485 * @doublescan_allowed: can this connector handle doublescan? 566 * @doublescan_allowed: can this connector handle doublescan?
567 * @stereo_allowed: can this connector handle stereo modes?
486 * @modes: modes available on this connector (from fill_modes() + user) 568 * @modes: modes available on this connector (from fill_modes() + user)
487 * @status: one of the drm_connector_status enums (connected, not, or unknown) 569 * @status: one of the drm_connector_status enums (connected, not, or unknown)
488 * @probed_modes: list of modes derived directly from the display 570 * @probed_modes: list of modes derived directly from the display
@@ -490,10 +572,13 @@ struct drm_encoder {
490 * @funcs: connector control functions 572 * @funcs: connector control functions
491 * @edid_blob_ptr: DRM property containing EDID if present 573 * @edid_blob_ptr: DRM property containing EDID if present
492 * @properties: property tracking for this connector 574 * @properties: property tracking for this connector
575 * @path_blob_ptr: DRM blob property data for the DP MST path property
493 * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling 576 * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling
494 * @dpms: current dpms state 577 * @dpms: current dpms state
495 * @helper_private: mid-layer private data 578 * @helper_private: mid-layer private data
579 * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
496 * @force: a %DRM_FORCE_<foo> state for forced mode sets 580 * @force: a %DRM_FORCE_<foo> state for forced mode sets
581 * @override_edid: has the EDID been overwritten through debugfs for testing?
497 * @encoder_ids: valid encoders for this connector 582 * @encoder_ids: valid encoders for this connector
498 * @encoder: encoder driving this connector, if any 583 * @encoder: encoder driving this connector, if any
499 * @eld: EDID-like data, if present 584 * @eld: EDID-like data, if present
@@ -503,6 +588,9 @@ struct drm_encoder {
503 * @video_latency: video latency info from ELD, if found 588 * @video_latency: video latency info from ELD, if found
504 * @audio_latency: audio latency info from ELD, if found 589 * @audio_latency: audio latency info from ELD, if found
505 * @null_edid_counter: track sinks that give us all zeros for the EDID 590 * @null_edid_counter: track sinks that give us all zeros for the EDID
591 * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
592 * @debugfs_entry: debugfs directory for this connector
593 * @state: current atomic state for this connector
506 * 594 *
507 * Each connector may be connected to one or more CRTCs, or may be clonable by 595 * Each connector may be connected to one or more CRTCs, or may be clonable by
508 * another connector if they can share a CRTC. Each connector also has a specific 596 * another connector if they can share a CRTC. Each connector also has a specific
@@ -563,14 +651,54 @@ struct drm_connector {
563 unsigned bad_edid_counter; 651 unsigned bad_edid_counter;
564 652
565 struct dentry *debugfs_entry; 653 struct dentry *debugfs_entry;
654
655 struct drm_connector_state *state;
656};
657
658/**
659 * struct drm_plane_state - mutable plane state
660 * @crtc: currently bound CRTC, NULL if disabled
661 * @fb: currently bound framebuffer
662 * @fence: optional fence to wait for before scanning out @fb
663 * @crtc_x: left position of visible portion of plane on crtc
664 * @crtc_y: upper position of visible portion of plane on crtc
665 * @crtc_w: width of visible portion of plane on crtc
666 * @crtc_h: height of visible portion of plane on crtc
667 * @src_x: left position of visible portion of plane within
668 * plane (in 16.16)
669 * @src_y: upper position of visible portion of plane within
670 * plane (in 16.16)
671 * @src_w: width of visible portion of plane (in 16.16)
672 * @src_h: height of visible portion of plane (in 16.16)
673 * @state: backpointer to global drm_atomic_state
674 */
675struct drm_plane_state {
676 struct drm_crtc *crtc;
677 struct drm_framebuffer *fb;
678 struct fence *fence;
679
680 /* Signed dest location allows it to be partially off screen */
681 int32_t crtc_x, crtc_y;
682 uint32_t crtc_w, crtc_h;
683
684 /* Source values are 16.16 fixed point */
685 uint32_t src_x, src_y;
686 uint32_t src_h, src_w;
687
688 struct drm_atomic_state *state;
566}; 689};
567 690
691
568/** 692/**
569 * drm_plane_funcs - driver plane control functions 693 * struct drm_plane_funcs - driver plane control functions
570 * @update_plane: update the plane configuration 694 * @update_plane: update the plane configuration
571 * @disable_plane: shut down the plane 695 * @disable_plane: shut down the plane
572 * @destroy: clean up plane resources 696 * @destroy: clean up plane resources
697 * @reset: reset plane after state has been invalidated (e.g. resume)
573 * @set_property: called when a property is changed 698 * @set_property: called when a property is changed
699 * @atomic_duplicate_state: duplicate the atomic state for this plane
700 * @atomic_destroy_state: destroy an atomic state for this plane
701 * @atomic_set_property: set a property on an atomic state for this plane
574 */ 702 */
575struct drm_plane_funcs { 703struct drm_plane_funcs {
576 int (*update_plane)(struct drm_plane *plane, 704 int (*update_plane)(struct drm_plane *plane,
@@ -585,6 +713,15 @@ struct drm_plane_funcs {
585 713
586 int (*set_property)(struct drm_plane *plane, 714 int (*set_property)(struct drm_plane *plane,
587 struct drm_property *property, uint64_t val); 715 struct drm_property *property, uint64_t val);
716
717 /* atomic update handling */
718 struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
719 void (*atomic_destroy_state)(struct drm_plane *plane,
720 struct drm_plane_state *state);
721 int (*atomic_set_property)(struct drm_plane *plane,
722 struct drm_plane_state *state,
723 struct drm_property *property,
724 uint64_t val);
588}; 725};
589 726
590enum drm_plane_type { 727enum drm_plane_type {
@@ -594,7 +731,7 @@ enum drm_plane_type {
594}; 731};
595 732
596/** 733/**
597 * drm_plane - central DRM plane control structure 734 * struct drm_plane - central DRM plane control structure
598 * @dev: DRM device this plane belongs to 735 * @dev: DRM device this plane belongs to
599 * @head: for list management 736 * @head: for list management
600 * @base: base mode object 737 * @base: base mode object
@@ -603,9 +740,12 @@ enum drm_plane_type {
603 * @format_count: number of formats supported 740 * @format_count: number of formats supported
604 * @crtc: currently bound CRTC 741 * @crtc: currently bound CRTC
605 * @fb: currently bound fb 742 * @fb: currently bound fb
743 * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by
744 * drm_mode_set_config_internal() to implement correct refcounting.
606 * @funcs: helper functions 745 * @funcs: helper functions
607 * @properties: property tracking for this plane 746 * @properties: property tracking for this plane
608 * @type: type of plane (overlay, primary, cursor) 747 * @type: type of plane (overlay, primary, cursor)
748 * @state: current atomic state for this plane
609 */ 749 */
610struct drm_plane { 750struct drm_plane {
611 struct drm_device *dev; 751 struct drm_device *dev;
@@ -620,8 +760,6 @@ struct drm_plane {
620 struct drm_crtc *crtc; 760 struct drm_crtc *crtc;
621 struct drm_framebuffer *fb; 761 struct drm_framebuffer *fb;
622 762
623 /* Temporary tracking of the old fb while a modeset is ongoing. Used
624 * by drm_mode_set_config_internal to implement correct refcounting. */
625 struct drm_framebuffer *old_fb; 763 struct drm_framebuffer *old_fb;
626 764
627 const struct drm_plane_funcs *funcs; 765 const struct drm_plane_funcs *funcs;
@@ -629,10 +767,14 @@ struct drm_plane {
629 struct drm_object_properties properties; 767 struct drm_object_properties properties;
630 768
631 enum drm_plane_type type; 769 enum drm_plane_type type;
770
771 void *helper_private;
772
773 struct drm_plane_state *state;
632}; 774};
633 775
634/** 776/**
635 * drm_bridge_funcs - drm_bridge control functions 777 * struct drm_bridge_funcs - drm_bridge control functions
636 * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge 778 * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge
637 * @disable: Called right before encoder prepare, disables the bridge 779 * @disable: Called right before encoder prepare, disables the bridge
638 * @post_disable: Called right after encoder prepare, for lockstepped disable 780 * @post_disable: Called right after encoder prepare, for lockstepped disable
@@ -656,7 +798,7 @@ struct drm_bridge_funcs {
656}; 798};
657 799
658/** 800/**
659 * drm_bridge - central DRM bridge control structure 801 * struct drm_bridge - central DRM bridge control structure
660 * @dev: DRM device this bridge belongs to 802 * @dev: DRM device this bridge belongs to
661 * @head: list management 803 * @head: list management
662 * @base: base mode object 804 * @base: base mode object
@@ -674,8 +816,33 @@ struct drm_bridge {
674}; 816};
675 817
676/** 818/**
677 * drm_mode_set - new values for a CRTC config change 819 * struct struct drm_atomic_state - the global state object for atomic updates
678 * @head: list management 820 * @dev: parent DRM device
821 * @flags: state flags like async update
822 * @planes: pointer to array of plane pointers
823 * @plane_states: pointer to array of plane states pointers
824 * @crtcs: pointer to array of CRTC pointers
825 * @crtc_states: pointer to array of CRTC states pointers
826 * @connectors: pointer to array of connector pointers
827 * @connector_states: pointer to array of connector states pointers
828 * @acquire_ctx: acquire context for this atomic modeset state update
829 */
830struct drm_atomic_state {
831 struct drm_device *dev;
832 uint32_t flags;
833 struct drm_plane **planes;
834 struct drm_plane_state **plane_states;
835 struct drm_crtc **crtcs;
836 struct drm_crtc_state **crtc_states;
837 struct drm_connector **connectors;
838 struct drm_connector_state **connector_states;
839
840 struct drm_modeset_acquire_ctx *acquire_ctx;
841};
842
843
844/**
845 * struct drm_mode_set - new values for a CRTC config change
679 * @fb: framebuffer to use for new config 846 * @fb: framebuffer to use for new config
680 * @crtc: CRTC whose configuration we're about to change 847 * @crtc: CRTC whose configuration we're about to change
681 * @mode: mode timings to use 848 * @mode: mode timings to use
@@ -705,6 +872,9 @@ struct drm_mode_set {
705 * struct drm_mode_config_funcs - basic driver provided mode setting functions 872 * struct drm_mode_config_funcs - basic driver provided mode setting functions
706 * @fb_create: create a new framebuffer object 873 * @fb_create: create a new framebuffer object
707 * @output_poll_changed: function to handle output configuration changes 874 * @output_poll_changed: function to handle output configuration changes
875 * @atomic_check: check whether a give atomic state update is possible
876 * @atomic_commit: commit an atomic state update previously verified with
877 * atomic_check()
708 * 878 *
709 * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that 879 * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
710 * involve drivers. 880 * involve drivers.
@@ -714,13 +884,20 @@ struct drm_mode_config_funcs {
714 struct drm_file *file_priv, 884 struct drm_file *file_priv,
715 struct drm_mode_fb_cmd2 *mode_cmd); 885 struct drm_mode_fb_cmd2 *mode_cmd);
716 void (*output_poll_changed)(struct drm_device *dev); 886 void (*output_poll_changed)(struct drm_device *dev);
887
888 int (*atomic_check)(struct drm_device *dev,
889 struct drm_atomic_state *a);
890 int (*atomic_commit)(struct drm_device *dev,
891 struct drm_atomic_state *a,
892 bool async);
717}; 893};
718 894
719/** 895/**
720 * drm_mode_group - group of mode setting resources for potential sub-grouping 896 * struct drm_mode_group - group of mode setting resources for potential sub-grouping
721 * @num_crtcs: CRTC count 897 * @num_crtcs: CRTC count
722 * @num_encoders: encoder count 898 * @num_encoders: encoder count
723 * @num_connectors: connector count 899 * @num_connectors: connector count
900 * @num_bridges: bridge count
724 * @id_list: list of KMS object IDs in this group 901 * @id_list: list of KMS object IDs in this group
725 * 902 *
726 * Currently this simply tracks the global mode setting state. But in the 903 * Currently this simply tracks the global mode setting state. But in the
@@ -740,10 +917,14 @@ struct drm_mode_group {
740}; 917};
741 918
742/** 919/**
743 * drm_mode_config - Mode configuration control structure 920 * struct drm_mode_config - Mode configuration control structure
744 * @mutex: mutex protecting KMS related lists and structures 921 * @mutex: mutex protecting KMS related lists and structures
922 * @connection_mutex: ww mutex protecting connector state and routing
923 * @acquire_ctx: global implicit acquire context used by atomic drivers for
924 * legacy ioctls
745 * @idr_mutex: mutex for KMS ID allocation and management 925 * @idr_mutex: mutex for KMS ID allocation and management
746 * @crtc_idr: main KMS ID tracking object 926 * @crtc_idr: main KMS ID tracking object
927 * @fb_lock: mutex to protect fb state and lists
747 * @num_fb: number of fbs available 928 * @num_fb: number of fbs available
748 * @fb_list: list of framebuffers available 929 * @fb_list: list of framebuffers available
749 * @num_connector: number of connectors on this device 930 * @num_connector: number of connectors on this device
@@ -752,17 +933,28 @@ struct drm_mode_group {
752 * @bridge_list: list of bridge objects 933 * @bridge_list: list of bridge objects
753 * @num_encoder: number of encoders on this device 934 * @num_encoder: number of encoders on this device
754 * @encoder_list: list of encoder objects 935 * @encoder_list: list of encoder objects
936 * @num_overlay_plane: number of overlay planes on this device
937 * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device
938 * @plane_list: list of plane objects
755 * @num_crtc: number of CRTCs on this device 939 * @num_crtc: number of CRTCs on this device
756 * @crtc_list: list of CRTC objects 940 * @crtc_list: list of CRTC objects
941 * @property_list: list of property objects
757 * @min_width: minimum pixel width on this device 942 * @min_width: minimum pixel width on this device
758 * @min_height: minimum pixel height on this device 943 * @min_height: minimum pixel height on this device
759 * @max_width: maximum pixel width on this device 944 * @max_width: maximum pixel width on this device
760 * @max_height: maximum pixel height on this device 945 * @max_height: maximum pixel height on this device
761 * @funcs: core driver provided mode setting functions 946 * @funcs: core driver provided mode setting functions
762 * @fb_base: base address of the framebuffer 947 * @fb_base: base address of the framebuffer
763 * @poll_enabled: track polling status for this device 948 * @poll_enabled: track polling support for this device
949 * @poll_running: track polling status for this device
764 * @output_poll_work: delayed work for polling in process context 950 * @output_poll_work: delayed work for polling in process context
951 * @property_blob_list: list of all the blob property objects
765 * @*_property: core property tracking 952 * @*_property: core property tracking
953 * @preferred_depth: preferred RBG pixel depth, used by fb helpers
954 * @prefer_shadow: hint to userspace to prefer shadow-fb rendering
955 * @async_page_flip: does this device support async flips on the primary plane?
956 * @cursor_width: hint to userspace for max cursor width
957 * @cursor_height: hint to userspace for max cursor height
766 * 958 *
767 * Core mode resource tracking structure. All CRTC, encoders, and connectors 959 * Core mode resource tracking structure. All CRTC, encoders, and connectors
768 * enumerated by the driver are added here, as are global properties. Some 960 * enumerated by the driver are added here, as are global properties. Some
@@ -776,14 +968,7 @@ struct drm_mode_config {
776 struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ 968 struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */
777 /* this is limited to one for now */ 969 /* this is limited to one for now */
778 970
779 971 struct mutex fb_lock; /* proctects global and per-file fb lists */
780 /**
781 * fb_lock - mutex to protect fb state
782 *
783 * Besides the global fb list his also protects the fbs list in the
784 * file_priv
785 */
786 struct mutex fb_lock;
787 int num_fb; 972 int num_fb;
788 struct list_head fb_list; 973 struct list_head fb_list;
789 974
@@ -880,9 +1065,6 @@ extern int drm_crtc_init_with_planes(struct drm_device *dev,
880 struct drm_plane *primary, 1065 struct drm_plane *primary,
881 struct drm_plane *cursor, 1066 struct drm_plane *cursor,
882 const struct drm_crtc_funcs *funcs); 1067 const struct drm_crtc_funcs *funcs);
883extern int drm_crtc_init(struct drm_device *dev,
884 struct drm_crtc *crtc,
885 const struct drm_crtc_funcs *funcs);
886extern void drm_crtc_cleanup(struct drm_crtc *crtc); 1068extern void drm_crtc_cleanup(struct drm_crtc *crtc);
887extern unsigned int drm_crtc_index(struct drm_crtc *crtc); 1069extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
888 1070
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index a3d75fefd010..7adbb65ea8ae 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -68,6 +68,7 @@ struct drm_crtc_helper_funcs {
68 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, 68 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
69 struct drm_display_mode *adjusted_mode, int x, int y, 69 struct drm_display_mode *adjusted_mode, int x, int y,
70 struct drm_framebuffer *old_fb); 70 struct drm_framebuffer *old_fb);
71 void (*mode_set_nofb)(struct drm_crtc *crtc);
71 72
72 /* Move the crtc on the current fb to the given position *optional* */ 73 /* Move the crtc on the current fb to the given position *optional* */
73 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y, 74 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
@@ -81,6 +82,12 @@ struct drm_crtc_helper_funcs {
81 82
82 /* disable crtc when not in use - more explicit than dpms off */ 83 /* disable crtc when not in use - more explicit than dpms off */
83 void (*disable)(struct drm_crtc *crtc); 84 void (*disable)(struct drm_crtc *crtc);
85
86 /* atomic helpers */
87 int (*atomic_check)(struct drm_crtc *crtc,
88 struct drm_crtc_state *state);
89 void (*atomic_begin)(struct drm_crtc *crtc);
90 void (*atomic_flush)(struct drm_crtc *crtc);
84}; 91};
85 92
86/** 93/**
@@ -161,6 +168,12 @@ static inline void drm_connector_helper_add(struct drm_connector *connector,
161 168
162extern void drm_helper_resume_force_mode(struct drm_device *dev); 169extern void drm_helper_resume_force_mode(struct drm_device *dev);
163 170
171int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
172 struct drm_display_mode *adjusted_mode, int x, int y,
173 struct drm_framebuffer *old_fb);
174int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
175 struct drm_framebuffer *old_fb);
176
164/* drm_probe_helper.c */ 177/* drm_probe_helper.c */
165extern int drm_helper_probe_single_connector_modes(struct drm_connector 178extern int drm_helper_probe_single_connector_modes(struct drm_connector
166 *connector, uint32_t maxX, 179 *connector, uint32_t maxX,
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 8edeed00c082..11f8c84f98ce 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -405,26 +405,6 @@
405#define MODE_I2C_READ 4 405#define MODE_I2C_READ 4
406#define MODE_I2C_STOP 8 406#define MODE_I2C_STOP 8
407 407
408/**
409 * struct i2c_algo_dp_aux_data - driver interface structure for i2c over dp
410 * aux algorithm
411 * @running: set by the algo indicating whether an i2c is ongoing or whether
412 * the i2c bus is quiescent
413 * @address: i2c target address for the currently ongoing transfer
414 * @aux_ch: driver callback to transfer a single byte of the i2c payload
415 */
416struct i2c_algo_dp_aux_data {
417 bool running;
418 u16 address;
419 int (*aux_ch) (struct i2c_adapter *adapter,
420 int mode, uint8_t write_byte,
421 uint8_t *read_byte);
422};
423
424int
425i2c_dp_aux_add_bus(struct i2c_adapter *adapter);
426
427
428#define DP_LINK_STATUS_SIZE 6 408#define DP_LINK_STATUS_SIZE 6
429bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE], 409bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
430 int lane_count); 410 int lane_count);
@@ -551,6 +531,7 @@ struct drm_dp_aux {
551 struct mutex hw_mutex; 531 struct mutex hw_mutex;
552 ssize_t (*transfer)(struct drm_dp_aux *aux, 532 ssize_t (*transfer)(struct drm_dp_aux *aux,
553 struct drm_dp_aux_msg *msg); 533 struct drm_dp_aux_msg *msg);
534 unsigned i2c_nack_count, i2c_defer_count;
554}; 535};
555 536
556ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, 537ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index 338fc1053835..05e85ee10e74 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -28,7 +28,7 @@
28struct drm_dp_mst_branch; 28struct drm_dp_mst_branch;
29 29
30/** 30/**
31 * struct drm_dp_vcpi - Virtual Channel Payload Identifer 31 * struct drm_dp_vcpi - Virtual Channel Payload Identifier
32 * @vcpi: Virtual channel ID. 32 * @vcpi: Virtual channel ID.
33 * @pbn: Payload Bandwidth Number for this channel 33 * @pbn: Payload Bandwidth Number for this channel
34 * @aligned_pbn: PBN aligned with slot size 34 * @aligned_pbn: PBN aligned with slot size
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index b96031d947a0..c2f1bfa22010 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -207,6 +207,61 @@ struct detailed_timing {
207#define DRM_EDID_HDMI_DC_30 (1 << 4) 207#define DRM_EDID_HDMI_DC_30 (1 << 4)
208#define DRM_EDID_HDMI_DC_Y444 (1 << 3) 208#define DRM_EDID_HDMI_DC_Y444 (1 << 3)
209 209
210/* ELD Header Block */
211#define DRM_ELD_HEADER_BLOCK_SIZE 4
212
213#define DRM_ELD_VER 0
214# define DRM_ELD_VER_SHIFT 3
215# define DRM_ELD_VER_MASK (0x1f << 3)
216
217#define DRM_ELD_BASELINE_ELD_LEN 2 /* in dwords! */
218
219/* ELD Baseline Block for ELD_Ver == 2 */
220#define DRM_ELD_CEA_EDID_VER_MNL 4
221# define DRM_ELD_CEA_EDID_VER_SHIFT 5
222# define DRM_ELD_CEA_EDID_VER_MASK (7 << 5)
223# define DRM_ELD_CEA_EDID_VER_NONE (0 << 5)
224# define DRM_ELD_CEA_EDID_VER_CEA861 (1 << 5)
225# define DRM_ELD_CEA_EDID_VER_CEA861A (2 << 5)
226# define DRM_ELD_CEA_EDID_VER_CEA861BCD (3 << 5)
227# define DRM_ELD_MNL_SHIFT 0
228# define DRM_ELD_MNL_MASK (0x1f << 0)
229
230#define DRM_ELD_SAD_COUNT_CONN_TYPE 5
231# define DRM_ELD_SAD_COUNT_SHIFT 4
232# define DRM_ELD_SAD_COUNT_MASK (0xf << 4)
233# define DRM_ELD_CONN_TYPE_SHIFT 2
234# define DRM_ELD_CONN_TYPE_MASK (3 << 2)
235# define DRM_ELD_CONN_TYPE_HDMI (0 << 2)
236# define DRM_ELD_CONN_TYPE_DP (1 << 2)
237# define DRM_ELD_SUPPORTS_AI (1 << 1)
238# define DRM_ELD_SUPPORTS_HDCP (1 << 0)
239
240#define DRM_ELD_AUD_SYNCH_DELAY 6 /* in units of 2 ms */
241# define DRM_ELD_AUD_SYNCH_DELAY_MAX 0xfa /* 500 ms */
242
243#define DRM_ELD_SPEAKER 7
244# define DRM_ELD_SPEAKER_RLRC (1 << 6)
245# define DRM_ELD_SPEAKER_FLRC (1 << 5)
246# define DRM_ELD_SPEAKER_RC (1 << 4)
247# define DRM_ELD_SPEAKER_RLR (1 << 3)
248# define DRM_ELD_SPEAKER_FC (1 << 2)
249# define DRM_ELD_SPEAKER_LFE (1 << 1)
250# define DRM_ELD_SPEAKER_FLR (1 << 0)
251
252#define DRM_ELD_PORT_ID 8 /* offsets 8..15 inclusive */
253# define DRM_ELD_PORT_ID_LEN 8
254
255#define DRM_ELD_MANUFACTURER_NAME0 16
256#define DRM_ELD_MANUFACTURER_NAME1 17
257
258#define DRM_ELD_PRODUCT_CODE0 18
259#define DRM_ELD_PRODUCT_CODE1 19
260
261#define DRM_ELD_MONITOR_NAME_STRING 20 /* offsets 20..(20+mnl-1) inclusive */
262
263#define DRM_ELD_CEA_SAD(mnl, sad) (20 + (mnl) + 3 * (sad))
264
210struct edid { 265struct edid {
211 u8 header[8]; 266 u8 header[8];
212 /* Vendor & product info */ 267 /* Vendor & product info */
@@ -279,4 +334,51 @@ int
279drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, 334drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
280 const struct drm_display_mode *mode); 335 const struct drm_display_mode *mode);
281 336
337/**
338 * drm_eld_mnl - Get ELD monitor name length in bytes.
339 * @eld: pointer to an eld memory structure with mnl set
340 */
341static inline int drm_eld_mnl(const uint8_t *eld)
342{
343 return (eld[DRM_ELD_CEA_EDID_VER_MNL] & DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;
344}
345
346/**
347 * drm_eld_sad_count - Get ELD SAD count.
348 * @eld: pointer to an eld memory structure with sad_count set
349 */
350static inline int drm_eld_sad_count(const uint8_t *eld)
351{
352 return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_SAD_COUNT_MASK) >>
353 DRM_ELD_SAD_COUNT_SHIFT;
354}
355
356/**
357 * drm_eld_calc_baseline_block_size - Calculate baseline block size in bytes
358 * @eld: pointer to an eld memory structure with mnl and sad_count set
359 *
360 * This is a helper for determining the payload size of the baseline block, in
361 * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block.
362 */
363static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
364{
365 return DRM_ELD_MONITOR_NAME_STRING - DRM_ELD_HEADER_BLOCK_SIZE +
366 drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3;
367}
368
369/**
370 * drm_eld_size - Get ELD size in bytes
371 * @eld: pointer to a complete eld memory structure
372 *
373 * The returned value does not include the vendor block. It's vendor specific,
374 * and comprises of the remaining bytes in the ELD memory buffer after
375 * drm_eld_size() bytes of header and baseline block.
376 *
377 * The returned value is guaranteed to be a multiple of 4.
378 */
379static inline int drm_eld_size(const uint8_t *eld)
380{
381 return DRM_ELD_HEADER_BLOCK_SIZE + eld[DRM_ELD_BASELINE_ELD_LEN] * 4;
382}
383
282#endif /* __DRM_EDID_H__ */ 384#endif /* __DRM_EDID_H__ */
diff --git a/include/drm/drm_modeset_lock.h b/include/drm/drm_modeset_lock.h
index 75a5c45e21c7..28931a23d96c 100644
--- a/include/drm/drm_modeset_lock.h
+++ b/include/drm/drm_modeset_lock.h
@@ -33,6 +33,7 @@ struct drm_modeset_lock;
33 * @ww_ctx: base acquire ctx 33 * @ww_ctx: base acquire ctx
34 * @contended: used internally for -EDEADLK handling 34 * @contended: used internally for -EDEADLK handling
35 * @locked: list of held locks 35 * @locked: list of held locks
36 * @trylock_only: trylock mode used in atomic contexts/panic notifiers
36 * 37 *
37 * Each thread competing for a set of locks must use one acquire 38 * Each thread competing for a set of locks must use one acquire
38 * ctx. And if any lock fxn returns -EDEADLK, it must backoff and 39 * ctx. And if any lock fxn returns -EDEADLK, it must backoff and
diff --git a/include/drm/drm_plane_helper.h b/include/drm/drm_plane_helper.h
index 52e6870534b2..c48f14d88690 100644
--- a/include/drm/drm_plane_helper.h
+++ b/include/drm/drm_plane_helper.h
@@ -25,6 +25,7 @@
25#define DRM_PLANE_HELPER_H 25#define DRM_PLANE_HELPER_H
26 26
27#include <drm/drm_rect.h> 27#include <drm/drm_rect.h>
28#include <drm/drm_crtc.h>
28 29
29/* 30/*
30 * Drivers that don't allow primary plane scaling may pass this macro in place 31 * Drivers that don't allow primary plane scaling may pass this macro in place
@@ -42,6 +43,32 @@
42 * planes. 43 * planes.
43 */ 44 */
44 45
46extern int drm_crtc_init(struct drm_device *dev,
47 struct drm_crtc *crtc,
48 const struct drm_crtc_funcs *funcs);
49
50/**
51 * drm_plane_helper_funcs - helper operations for CRTCs
52 *
53 * The helper operations are called by the mid-layer CRTC helper.
54 */
55struct drm_plane_helper_funcs {
56 int (*prepare_fb)(struct drm_plane *plane,
57 struct drm_framebuffer *fb);
58 void (*cleanup_fb)(struct drm_plane *plane,
59 struct drm_framebuffer *fb);
60
61 int (*atomic_check)(struct drm_plane *plane,
62 struct drm_plane_state *state);
63 void (*atomic_update)(struct drm_plane *plane);
64};
65
66static inline void drm_plane_helper_add(struct drm_plane *plane,
67 const struct drm_plane_helper_funcs *funcs)
68{
69 plane->helper_private = (void *)funcs;
70}
71
45extern int drm_plane_helper_check_update(struct drm_plane *plane, 72extern int drm_plane_helper_check_update(struct drm_plane *plane,
46 struct drm_crtc *crtc, 73 struct drm_crtc *crtc,
47 struct drm_framebuffer *fb, 74 struct drm_framebuffer *fb,
@@ -68,4 +95,16 @@ extern struct drm_plane *drm_primary_helper_create_plane(struct drm_device *dev,
68 int num_formats); 95 int num_formats);
69 96
70 97
98int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
99 struct drm_framebuffer *fb,
100 int crtc_x, int crtc_y,
101 unsigned int crtc_w, unsigned int crtc_h,
102 uint32_t src_x, uint32_t src_y,
103 uint32_t src_w, uint32_t src_h);
104int drm_plane_helper_disable(struct drm_plane *plane);
105
106/* For use by drm_crtc_helper.c */
107int drm_plane_helper_commit(struct drm_plane *plane,
108 struct drm_plane_state *plane_state,
109 struct drm_framebuffer *old_fb);
71#endif 110#endif