Subversion Repositories Kolibri OS

Rev

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

Rev 6082 Rev 6936
Line 83... Line 83...
83
static inline uint64_t I642U64(int64_t val)
83
static inline uint64_t I642U64(int64_t val)
84
{
84
{
85
	return (uint64_t)*((uint64_t *)&val);
85
	return (uint64_t)*((uint64_t *)&val);
86
}
86
}
Line -... Line 87...
-
 
87
 
87
 
88
/*
-
 
89
 * Rotation property bits. DRM_ROTATE_ rotates the image by the
-
 
90
 * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and
-
 
91
 * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation
88
/* rotation property bits */
92
 */
89
#define DRM_ROTATE_MASK 0x0f
93
#define DRM_ROTATE_MASK 0x0f
90
#define DRM_ROTATE_0	0
94
#define DRM_ROTATE_0	0
91
#define DRM_ROTATE_90	1
95
#define DRM_ROTATE_90	1
92
#define DRM_ROTATE_180	2
96
#define DRM_ROTATE_180	2
Line 156... Line 160...
156
	struct drm_device *dev;
160
	struct drm_device *dev;
157
	int id;
161
	int id;
158
	u8 group_data[8];
162
	u8 group_data[8];
159
};
163
};
Line -... Line 164...
-
 
164
 
-
 
165
/**
-
 
166
 * struct drm_framebuffer_funcs - framebuffer hooks
160
 
167
 */
-
 
168
struct drm_framebuffer_funcs {
-
 
169
	/**
-
 
170
	 * @destroy:
-
 
171
	 *
-
 
172
	 * Clean up framebuffer resources, specifically also unreference the
161
struct drm_framebuffer_funcs {
173
	 * backing storage. The core guarantees to call this function for every
-
 
174
	 * framebuffer successfully created by ->fb_create() in
-
 
175
	 * &drm_mode_config_funcs. Drivers must also call
-
 
176
	 * drm_framebuffer_cleanup() to release DRM core resources for this
-
 
177
	 * framebuffer.
162
	/* note: use drm_framebuffer_remove() */
178
	 */
-
 
179
	void (*destroy)(struct drm_framebuffer *framebuffer);
-
 
180
 
-
 
181
	/**
-
 
182
	 * @create_handle:
-
 
183
	 *
-
 
184
	 * Create a buffer handle in the driver-specific buffer manager (either
-
 
185
	 * GEM or TTM) valid for the passed-in struct &drm_file. This is used by
-
 
186
	 * the core to implement the GETFB IOCTL, which returns (for
-
 
187
	 * sufficiently priviledged user) also a native buffer handle. This can
-
 
188
	 * be used for seamless transitions between modesetting clients by
-
 
189
	 * copying the current screen contents to a private buffer and blending
-
 
190
	 * between that and the new contents.
-
 
191
	 *
-
 
192
	 * GEM based drivers should call drm_gem_handle_create() to create the
-
 
193
	 * handle.
-
 
194
	 *
-
 
195
	 * RETURNS:
-
 
196
	 *
-
 
197
	 * 0 on success or a negative error code on failure.
163
	void (*destroy)(struct drm_framebuffer *framebuffer);
198
	 */
164
	int (*create_handle)(struct drm_framebuffer *fb,
199
	int (*create_handle)(struct drm_framebuffer *fb,
165
			     struct drm_file *file_priv,
200
			     struct drm_file *file_priv,
166
			     unsigned int *handle);
201
			     unsigned int *handle);
-
 
202
	/**
-
 
203
	 * @dirty:
167
	/*
204
	 *
-
 
205
	 * Optional callback for the dirty fb IOCTL.
-
 
206
	 *
-
 
207
	 * Userspace can notify the driver via this callback that an area of the
-
 
208
	 * framebuffer has changed and should be flushed to the display
-
 
209
	 * hardware. This can also be used internally, e.g. by the fbdev
168
	 * Optional callback for the dirty fb ioctl.
210
	 * emulation, though that's not the case currently.
169
	 *
211
	 *
170
	 * Userspace can notify the driver via this callback
212
	 * See documentation in drm_mode.h for the struct drm_mode_fb_dirty_cmd
171
	 * that a area of the framebuffer has changed and should
213
	 * for more information as all the semantics and arguments have a one to
172
	 * be flushed to the display hardware.
214
	 * one mapping on this function.
173
	 *
215
	 *
174
	 * See documentation in drm_mode.h for the struct
-
 
-
 
216
	 * RETURNS:
175
	 * drm_mode_fb_dirty_cmd for more information as all
217
	 *
176
	 * the semantics and arguments have a one to one mapping
-
 
177
	 * on this function.
218
	 * 0 on success or a negative error code on failure.
178
	 */
219
	 */
179
	int (*dirty)(struct drm_framebuffer *framebuffer,
220
	int (*dirty)(struct drm_framebuffer *framebuffer,
180
		     struct drm_file *file_priv, unsigned flags,
221
		     struct drm_file *file_priv, unsigned flags,
181
		     unsigned color, struct drm_clip_rect *clips,
222
		     unsigned color, struct drm_clip_rect *clips,
Line 248... Line 289...
248
struct drm_pending_vblank_event;
289
struct drm_pending_vblank_event;
249
struct drm_plane;
290
struct drm_plane;
250
struct drm_bridge;
291
struct drm_bridge;
251
struct drm_atomic_state;
292
struct drm_atomic_state;
Line -... Line 293...
-
 
293
 
-
 
294
struct drm_crtc_helper_funcs;
-
 
295
struct drm_encoder_helper_funcs;
-
 
296
struct drm_connector_helper_funcs;
-
 
297
struct drm_plane_helper_funcs;
252
 
298
 
253
/**
299
/**
254
 * struct drm_crtc_state - mutable CRTC state
300
 * struct drm_crtc_state - mutable CRTC state
255
 * @crtc: backpointer to the CRTC
301
 * @crtc: backpointer to the CRTC
256
 * @enable: whether the CRTC should be enabled, gates all other state
302
 * @enable: whether the CRTC should be enabled, gates all other state
257
 * @active: whether the CRTC is actively displaying (used for DPMS)
303
 * @active: whether the CRTC is actively displaying (used for DPMS)
258
 * @planes_changed: planes on this crtc are updated
304
 * @planes_changed: planes on this crtc are updated
259
 * @mode_changed: crtc_state->mode or crtc_state->enable has been changed
305
 * @mode_changed: crtc_state->mode or crtc_state->enable has been changed
260
 * @active_changed: crtc_state->active has been toggled.
306
 * @active_changed: crtc_state->active has been toggled.
261
 * @connectors_changed: connectors to this crtc have been updated
307
 * @connectors_changed: connectors to this crtc have been updated
-
 
308
 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
262
 * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes
309
 * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors
263
 * @last_vblank_count: for helpers and drivers to capture the vblank of the
310
 * @last_vblank_count: for helpers and drivers to capture the vblank of the
264
 * 	update to ensure framebuffer cleanup isn't done too early
311
 * 	update to ensure framebuffer cleanup isn't done too early
265
 * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
312
 * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings
266
 * @mode: current mode timings
313
 * @mode: current mode timings
Line 291... Line 338...
291
	 * drivers not converted over to atomic helpers should not rely
338
	 * drivers not converted over to atomic helpers should not rely
292
	 * on plane_mask being accurate!
339
	 * on plane_mask being accurate!
293
	 */
340
	 */
294
	u32 plane_mask;
341
	u32 plane_mask;
Line -... Line 342...
-
 
342
 
-
 
343
	u32 connector_mask;
295
 
344
 
296
	/* last_vblank_count: for vblank waits before cleanup */
345
	/* last_vblank_count: for vblank waits before cleanup */
Line 297... Line 346...
297
	u32 last_vblank_count;
346
	u32 last_vblank_count;
298
 
347
 
Line 309... Line 358...
309
	struct drm_atomic_state *state;
358
	struct drm_atomic_state *state;
310
};
359
};
Line 311... Line 360...
311
 
360
 
312
/**
361
/**
313
 * struct drm_crtc_funcs - control CRTCs for a given device
-
 
314
 * @save: save CRTC state
-
 
315
 * @restore: restore CRTC state
-
 
316
 * @reset: reset CRTC after state has been invalidated (e.g. resume)
-
 
317
 * @cursor_set: setup the cursor
-
 
318
 * @cursor_set2: setup the cursor with hotspot, superseeds @cursor_set if set
-
 
319
 * @cursor_move: move the cursor
-
 
320
 * @gamma_set: specify color ramp for CRTC
-
 
321
 * @destroy: deinit and free object
-
 
322
 * @set_property: called when a property is changed
-
 
323
 * @set_config: apply a new CRTC configuration
-
 
324
 * @page_flip: initiate a page flip
-
 
325
 * @atomic_duplicate_state: duplicate the atomic state for this CRTC
-
 
326
 * @atomic_destroy_state: destroy an atomic state for this CRTC
-
 
327
 * @atomic_set_property: set a property on an atomic state for this CRTC
-
 
328
 *    (do not call directly, use drm_atomic_crtc_set_property())
-
 
329
 * @atomic_get_property: get a property on an atomic state for this CRTC
-
 
330
 *    (do not call directly, use drm_atomic_crtc_get_property())
362
 * struct drm_crtc_funcs - control CRTCs for a given device
331
 *
363
 *
332
 * The drm_crtc_funcs structure is the central CRTC management structure
364
 * The drm_crtc_funcs structure is the central CRTC management structure
333
 * in the DRM.  Each CRTC controls one or more connectors (note that the name
365
 * in the DRM.  Each CRTC controls one or more connectors (note that the name
334
 * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
366
 * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc.
Line 337... Line 369...
337
 * Each driver is responsible for filling out this structure at startup time,
369
 * Each driver is responsible for filling out this structure at startup time,
338
 * in addition to providing other modesetting features, like i2c and DDC
370
 * in addition to providing other modesetting features, like i2c and DDC
339
 * bus accessors.
371
 * bus accessors.
340
 */
372
 */
341
struct drm_crtc_funcs {
373
struct drm_crtc_funcs {
-
 
374
	/**
342
	/* Save CRTC state */
375
	 * @reset:
-
 
376
	 *
343
	void (*save)(struct drm_crtc *crtc); /* suspend? */
377
	 * Reset CRTC hardware and software state to off. This function isn't
-
 
378
	 * called by the core directly, only through drm_mode_config_reset().
344
	/* Restore CRTC state */
379
	 * It's not a helper hook only for historical reasons.
-
 
380
	 *
345
	void (*restore)(struct drm_crtc *crtc); /* resume? */
381
	 * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset
346
	/* Reset CRTC state */
382
	 * atomic state using this hook.
-
 
383
	 */
347
	void (*reset)(struct drm_crtc *crtc);
384
	void (*reset)(struct drm_crtc *crtc);
Line -... Line 385...
-
 
385
 
348
 
386
	/**
-
 
387
	 * @cursor_set:
-
 
388
	 *
-
 
389
	 * Update the cursor image. The cursor position is relative to the CRTC
-
 
390
	 * and can be partially or fully outside of the visible area.
-
 
391
	 *
-
 
392
	 * Note that contrary to all other KMS functions the legacy cursor entry
-
 
393
	 * points don't take a framebuffer object, but instead take directly a
-
 
394
	 * raw buffer object id from the driver's buffer manager (which is
-
 
395
	 * either GEM or TTM for current drivers).
-
 
396
	 *
-
 
397
	 * This entry point is deprecated, drivers should instead implement
-
 
398
	 * universal plane support and register a proper cursor plane using
-
 
399
	 * drm_crtc_init_with_planes().
-
 
400
	 *
-
 
401
	 * This callback is optional
-
 
402
	 *
-
 
403
	 * RETURNS:
-
 
404
	 *
-
 
405
	 * 0 on success or a negative error code on failure.
349
	/* cursor controls */
406
	 */
350
	int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
407
	int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv,
-
 
408
			  uint32_t handle, uint32_t width, uint32_t height);
-
 
409
 
-
 
410
	/**
-
 
411
	 * @cursor_set2:
-
 
412
	 *
-
 
413
	 * Update the cursor image, including hotspot information. The hotspot
-
 
414
	 * must not affect the cursor position in CRTC coordinates, but is only
-
 
415
	 * meant as a hint for virtualized display hardware to coordinate the
-
 
416
	 * guests and hosts cursor position. The cursor hotspot is relative to
-
 
417
	 * the cursor image. Otherwise this works exactly like @cursor_set.
-
 
418
	 *
-
 
419
	 * This entry point is deprecated, drivers should instead implement
-
 
420
	 * universal plane support and register a proper cursor plane using
-
 
421
	 * drm_crtc_init_with_planes().
-
 
422
	 *
-
 
423
	 * This callback is optional.
-
 
424
	 *
-
 
425
	 * RETURNS:
-
 
426
	 *
-
 
427
	 * 0 on success or a negative error code on failure.
351
			  uint32_t handle, uint32_t width, uint32_t height);
428
	 */
352
	int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv,
429
	int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv,
353
			   uint32_t handle, uint32_t width, uint32_t height,
430
			   uint32_t handle, uint32_t width, uint32_t height,
-
 
431
			   int32_t hot_x, int32_t hot_y);
-
 
432
 
-
 
433
	/**
-
 
434
	 * @cursor_move:
-
 
435
	 *
-
 
436
	 * Update the cursor position. The cursor does not need to be visible
-
 
437
	 * when this hook is called.
-
 
438
	 *
-
 
439
	 * This entry point is deprecated, drivers should instead implement
-
 
440
	 * universal plane support and register a proper cursor plane using
-
 
441
	 * drm_crtc_init_with_planes().
-
 
442
	 *
-
 
443
	 * This callback is optional.
-
 
444
	 *
-
 
445
	 * RETURNS:
-
 
446
	 *
-
 
447
	 * 0 on success or a negative error code on failure.
354
			   int32_t hot_x, int32_t hot_y);
448
	 */
Line -... Line 449...
-
 
449
	int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
-
 
450
 
-
 
451
	/**
355
	int (*cursor_move)(struct drm_crtc *crtc, int x, int y);
452
	 * @gamma_set:
-
 
453
	 *
-
 
454
	 * Set gamma on the CRTC.
-
 
455
	 *
-
 
456
	 * This callback is optional.
-
 
457
	 *
-
 
458
	 * NOTE:
-
 
459
	 *
-
 
460
	 * Drivers that support gamma tables and also fbdev emulation through
-
 
461
	 * the provided helper library need to take care to fill out the gamma
-
 
462
	 * hooks for both. Currently there's a bit an unfortunate duplication
-
 
463
	 * going on, which should eventually be unified to just one set of
356
 
464
	 * hooks.
357
	/* Set gamma on the CRTC */
465
	 */
-
 
466
	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-
 
467
			  uint32_t start, uint32_t size);
358
	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
468
 
-
 
469
	/**
-
 
470
	 * @destroy:
-
 
471
	 *
-
 
472
	 * Clean up plane resources. This is only called at driver unload time
-
 
473
	 * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged
359
			  uint32_t start, uint32_t size);
474
	 * in DRM.
Line -... Line 475...
-
 
475
	 */
-
 
476
	void (*destroy)(struct drm_crtc *crtc);
-
 
477
 
-
 
478
	/**
-
 
479
	 * @set_config:
-
 
480
	 *
-
 
481
	 * This is the main legacy entry point to change the modeset state on a
-
 
482
	 * CRTC. All the details of the desired configuration are passed in a
-
 
483
	 * struct &drm_mode_set - see there for details.
-
 
484
	 *
-
 
485
	 * Drivers implementing atomic modeset should use
-
 
486
	 * drm_atomic_helper_set_config() to implement this hook.
-
 
487
	 *
-
 
488
	 * RETURNS:
360
	/* Object destroy routine */
489
	 *
Line 361... Line 490...
361
	void (*destroy)(struct drm_crtc *crtc);
490
	 * 0 on success or a negative error code on failure.
-
 
491
	 */
-
 
492
	int (*set_config)(struct drm_mode_set *set);
-
 
493
 
-
 
494
	/**
362
 
495
	 * @page_flip:
-
 
496
	 *
-
 
497
	 * Legacy entry point to schedule a flip to the given framebuffer.
-
 
498
	 *
-
 
499
	 * Page flipping is a synchronization mechanism that replaces the frame
363
	int (*set_config)(struct drm_mode_set *set);
500
	 * buffer being scanned out by the CRTC with a new frame buffer during
-
 
501
	 * vertical blanking, avoiding tearing (except when requested otherwise
-
 
502
	 * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application
-
 
503
	 * requests a page flip the DRM core verifies that the new frame buffer
-
 
504
	 * is large enough to be scanned out by the CRTC in the currently
-
 
505
	 * configured mode and then calls the CRTC ->page_flip() operation with a
-
 
506
	 * pointer to the new frame buffer.
-
 
507
	 *
-
 
508
	 * The driver must wait for any pending rendering to the new framebuffer
-
 
509
	 * to complete before executing the flip. It should also wait for any
-
 
510
	 * pending rendering from other drivers if the underlying buffer is a
364
 
511
	 * shared dma-buf.
-
 
512
	 *
-
 
513
	 * An application can request to be notified when the page flip has
-
 
514
	 * completed. The drm core will supply a struct &drm_event in the event
-
 
515
	 * parameter in this case. This can be handled by the
365
	/*
516
	 * drm_crtc_send_vblank_event() function, which the driver should call on
-
 
517
	 * the provided event upon completion of the flip. Note that if
-
 
518
	 * the driver supports vblank signalling and timestamping the vblank
-
 
519
	 * counters and timestamps must agree with the ones returned from page
-
 
520
	 * flip events. With the current vblank helper infrastructure this can
-
 
521
	 * be achieved by holding a vblank reference while the page flip is
-
 
522
	 * pending, acquired through drm_crtc_vblank_get() and released with
-
 
523
	 * drm_crtc_vblank_put(). Drivers are free to implement their own vblank
-
 
524
	 * counter and timestamp tracking though, e.g. if they have accurate
-
 
525
	 * timestamp registers in hardware.
-
 
526
	 *
-
 
527
	 * FIXME:
-
 
528
	 *
366
	 * Flip to the given framebuffer.  This implements the page
529
	 * Up to that point drivers need to manage events themselves and can use
367
	 * flip ioctl described in drm_mode.h, specifically, the
530
	 * even->base.list freely for that. Specifically they need to ensure
-
 
531
	 * that they don't send out page flip (or vblank) events for which the
-
 
532
	 * corresponding drm file has been closed already. The drm core
-
 
533
	 * unfortunately does not (yet) take care of that. Therefore drivers
-
 
534
	 * currently must clean up and release pending events in their
-
 
535
	 * ->preclose driver function.
-
 
536
	 *
-
 
537
	 * This callback is optional.
-
 
538
	 *
-
 
539
	 * NOTE:
-
 
540
	 *
-
 
541
	 * Very early versions of the KMS ABI mandated that the driver must
368
	 * implementation must return immediately and block all
542
	 * block (but not reject) any rendering to the old framebuffer until the
-
 
543
	 * flip operation has completed and the old framebuffer is no longer
-
 
544
	 * visible. This requirement has been lifted, and userspace is instead
-
 
545
	 * expected to request delivery of an event and wait with recycling old
-
 
546
	 * buffers until such has been received.
-
 
547
	 *
-
 
548
	 * RETURNS:
-
 
549
	 *
-
 
550
	 * 0 on success or a negative error code on failure. Note that if a
-
 
551
	 * ->page_flip() operation is already pending the callback should return
369
	 * rendering to the current fb until the flip has completed.
552
	 * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode
370
	 * If userspace set the event flag in the ioctl, the event
553
	 * or just runtime disabled through DPMS respectively the new atomic
371
	 * argument will point to an event to send back when the flip
554
	 * "ACTIVE" state) should result in an -EINVAL error code. Note that
372
	 * completes, otherwise it will be NULL.
555
	 * drm_atomic_helper_page_flip() checks this already for atomic drivers.
373
	 */
556
	 */
Line -... Line 557...
-
 
557
	int (*page_flip)(struct drm_crtc *crtc,
-
 
558
			 struct drm_framebuffer *fb,
-
 
559
			 struct drm_pending_vblank_event *event,
-
 
560
			 uint32_t flags);
-
 
561
 
-
 
562
	/**
-
 
563
	 * @set_property:
-
 
564
	 *
-
 
565
	 * This is the legacy entry point to update a property attached to the
-
 
566
	 * CRTC.
-
 
567
	 *
-
 
568
	 * Drivers implementing atomic modeset should use
-
 
569
	 * drm_atomic_helper_crtc_set_property() to implement this hook.
-
 
570
	 *
-
 
571
	 * This callback is optional if the driver does not support any legacy
-
 
572
	 * driver-private properties.
374
	int (*page_flip)(struct drm_crtc *crtc,
573
	 *
375
			 struct drm_framebuffer *fb,
574
	 * RETURNS:
Line -... Line 575...
-
 
575
	 *
376
			 struct drm_pending_vblank_event *event,
576
	 * 0 on success or a negative error code on failure.
-
 
577
	 */
-
 
578
	int (*set_property)(struct drm_crtc *crtc,
-
 
579
			    struct drm_property *property, uint64_t val);
-
 
580
 
-
 
581
	/**
-
 
582
	 * @atomic_duplicate_state:
-
 
583
	 *
-
 
584
	 * Duplicate the current atomic state for this CRTC and return it.
-
 
585
	 * The core and helpers gurantee that any atomic state duplicated with
-
 
586
	 * this hook and still owned by the caller (i.e. not transferred to the
-
 
587
	 * driver by calling ->atomic_commit() from struct
-
 
588
	 * &drm_mode_config_funcs) will be cleaned up by calling the
-
 
589
	 * @atomic_destroy_state hook in this structure.
-
 
590
	 *
-
 
591
	 * Atomic drivers which don't subclass struct &drm_crtc should use
-
 
592
	 * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the
-
 
593
	 * state structure to extend it with driver-private state should use
-
 
594
	 * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is
-
 
595
	 * duplicated in a consistent fashion across drivers.
-
 
596
	 *
-
 
597
	 * It is an error to call this hook before crtc->state has been
-
 
598
	 * initialized correctly.
-
 
599
	 *
-
 
600
	 * NOTE:
-
 
601
	 *
-
 
602
	 * If the duplicate state references refcounted resources this hook must
-
 
603
	 * acquire a reference for each of them. The driver must release these
377
			 uint32_t flags);
604
	 * references again in @atomic_destroy_state.
-
 
605
	 *
-
 
606
	 * RETURNS:
-
 
607
	 *
-
 
608
	 * Duplicated atomic state or NULL when the allocation failed.
-
 
609
	 */
-
 
610
	struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc);
-
 
611
 
378
 
612
	/**
379
	int (*set_property)(struct drm_crtc *crtc,
613
	 * @atomic_destroy_state:
-
 
614
	 *
-
 
615
	 * Destroy a state duplicated with @atomic_duplicate_state and release
-
 
616
	 * or unreference all resources it references
-
 
617
	 */
-
 
618
	void (*atomic_destroy_state)(struct drm_crtc *crtc,
-
 
619
				     struct drm_crtc_state *state);
-
 
620
 
-
 
621
	/**
-
 
622
	 * @atomic_set_property:
-
 
623
	 *
-
 
624
	 * Decode a driver-private property value and store the decoded value
-
 
625
	 * into the passed-in state structure. Since the atomic core decodes all
-
 
626
	 * standardized properties (even for extensions beyond the core set of
-
 
627
	 * properties which might not be implemented by all drivers) this
-
 
628
	 * requires drivers to subclass the state structure.
-
 
629
	 *
-
 
630
	 * Such driver-private properties should really only be implemented for
-
 
631
	 * truly hardware/vendor specific state. Instead it is preferred to
-
 
632
	 * standardize atomic extension and decode the properties used to expose
-
 
633
	 * such an extension in the core.
-
 
634
	 *
-
 
635
	 * Do not call this function directly, use
-
 
636
	 * drm_atomic_crtc_set_property() instead.
-
 
637
	 *
-
 
638
	 * This callback is optional if the driver does not support any
-
 
639
	 * driver-private atomic properties.
-
 
640
	 *
-
 
641
	 * NOTE:
-
 
642
	 *
-
 
643
	 * This function is called in the state assembly phase of atomic
-
 
644
	 * modesets, which can be aborted for any reason (including on
-
 
645
	 * userspace's request to just check whether a configuration would be
-
 
646
	 * possible). Drivers MUST NOT touch any persistent state (hardware or
-
 
647
	 * software) or data structures except the passed in @state parameter.
-
 
648
	 *
-
 
649
	 * Also since userspace controls in which order properties are set this
-
 
650
	 * function must not do any input validation (since the state update is
-
 
651
	 * incomplete and hence likely inconsistent). Instead any such input
-
 
652
	 * validation must be done in the various atomic_check callbacks.
-
 
653
	 *
-
 
654
	 * RETURNS:
-
 
655
	 *
-
 
656
	 * 0 if the property has been found, -EINVAL if the property isn't
380
			    struct drm_property *property, uint64_t val);
657
	 * implemented by the driver (which should never happen, the core only
381
 
658
	 * asks for properties attached to this CRTC). No other validation is
382
	/* atomic update handling */
659
	 * allowed by the driver. The core already checks that the property
383
	struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc);
660
	 * value is within the range (integer, valid enum value, ...) the driver
-
 
661
	 * set when registering the property.
-
 
662
	 */
-
 
663
	int (*atomic_set_property)(struct drm_crtc *crtc,
-
 
664
				   struct drm_crtc_state *state,
-
 
665
				   struct drm_property *property,
-
 
666
				   uint64_t val);
-
 
667
	/**
-
 
668
	 * @atomic_get_property:
-
 
669
	 *
-
 
670
	 * Reads out the decoded driver-private property. This is used to
-
 
671
	 * implement the GETCRTC IOCTL.
-
 
672
	 *
-
 
673
	 * Do not call this function directly, use
-
 
674
	 * drm_atomic_crtc_get_property() instead.
-
 
675
	 *
-
 
676
	 * This callback is optional if the driver does not support any
-
 
677
	 * driver-private atomic properties.
-
 
678
	 *
384
	void (*atomic_destroy_state)(struct drm_crtc *crtc,
679
	 * RETURNS:
385
				     struct drm_crtc_state *state);
680
	 *
386
	int (*atomic_set_property)(struct drm_crtc *crtc,
681
	 * 0 on success, -EINVAL if the property isn't implemented by the
387
				   struct drm_crtc_state *state,
682
	 * driver (which should never happen, the core only asks for
388
				   struct drm_property *property,
683
	 * properties attached to this CRTC).
Line 414... Line 709...
414
 * @gamma_store: gamma ramp values
709
 * @gamma_store: gamma ramp values
415
 * @helper_private: mid-layer private data
710
 * @helper_private: mid-layer private data
416
 * @properties: property tracking for this CRTC
711
 * @properties: property tracking for this CRTC
417
 * @state: current atomic state for this CRTC
712
 * @state: current atomic state for this CRTC
418
 * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for
713
 * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for
419
 * 	legacy ioctls
714
 * 	legacy IOCTLs
420
 *
715
 *
421
 * Each CRTC may have one or more connectors associated with it.  This structure
716
 * Each CRTC may have one or more connectors associated with it.  This structure
422
 * allows the CRTC to be controlled.
717
 * allows the CRTC to be controlled.
423
 */
718
 */
424
struct drm_crtc {
719
struct drm_crtc {
425
	struct drm_device *dev;
720
	struct drm_device *dev;
426
	struct device_node *port;
721
	struct device_node *port;
427
	struct list_head head;
722
	struct list_head head;
Line -... Line 723...
-
 
723
 
-
 
724
	char *name;
428
 
725
 
429
	/*
726
	/*
430
	 * crtc mutex
727
	 * crtc mutex
431
	 *
728
	 *
432
	 * This provides a read lock for the overall crtc state (mode, dpms
729
	 * This provides a read lock for the overall crtc state (mode, dpms
Line 461... Line 758...
461
	/* CRTC gamma size for reporting to userspace */
758
	/* CRTC gamma size for reporting to userspace */
462
	uint32_t gamma_size;
759
	uint32_t gamma_size;
463
	uint16_t *gamma_store;
760
	uint16_t *gamma_store;
Line 464... Line 761...
464
 
761
 
465
	/* if you are using the helper */
762
	/* if you are using the helper */
Line 466... Line 763...
466
	const void *helper_private;
763
	const struct drm_crtc_helper_funcs *helper_private;
Line 467... Line 764...
467
 
764
 
Line 468... Line 765...
468
	struct drm_object_properties properties;
765
	struct drm_object_properties properties;
469
 
766
 
470
	struct drm_crtc_state *state;
767
	struct drm_crtc_state *state;
471
 
768
 
472
	/*
769
	/*
473
	 * For legacy crtc ioctls so that atomic drivers can get at the locking
770
	 * For legacy crtc IOCTLs so that atomic drivers can get at the locking
Line 493... Line 790...
493
	struct drm_atomic_state *state;
790
	struct drm_atomic_state *state;
494
};
791
};
Line 495... Line 792...
495
 
792
 
496
/**
793
/**
497
 * struct drm_connector_funcs - control connectors on a given device
-
 
498
 * @dpms: set power state
-
 
499
 * @save: save connector state
-
 
500
 * @restore: restore connector state
-
 
501
 * @reset: reset connector after state has been invalidated (e.g. resume)
-
 
502
 * @detect: is this connector active?
-
 
503
 * @fill_modes: fill mode list for this connector
-
 
504
 * @set_property: property for this connector may need an update
-
 
505
 * @destroy: make object go away
-
 
506
 * @force: notify the driver that the connector is forced on
-
 
507
 * @atomic_duplicate_state: duplicate the atomic state for this connector
-
 
508
 * @atomic_destroy_state: destroy an atomic state for this connector
-
 
509
 * @atomic_set_property: set a property on an atomic state for this connector
-
 
510
 *    (do not call directly, use drm_atomic_connector_set_property())
-
 
511
 * @atomic_get_property: get a property on an atomic state for this connector
-
 
512
 *    (do not call directly, use drm_atomic_connector_get_property())
794
 * struct drm_connector_funcs - control connectors on a given device
513
 *
795
 *
514
 * Each CRTC may have one or more connectors attached to it.  The functions
796
 * Each CRTC may have one or more connectors attached to it.  The functions
515
 * below allow the core DRM code to control connectors, enumerate available modes,
797
 * below allow the core DRM code to control connectors, enumerate available modes,
516
 * etc.
798
 * etc.
517
 */
799
 */
-
 
800
struct drm_connector_funcs {
-
 
801
	/**
-
 
802
	 * @dpms:
-
 
803
	 *
-
 
804
	 * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
-
 
805
	 * is exposed as a standard property on the connector, but diverted to
-
 
806
	 * this callback in the drm core. Note that atomic drivers don't
-
 
807
	 * implement the 4 level DPMS support on the connector any more, but
-
 
808
	 * instead only have an on/off "ACTIVE" property on the CRTC object.
-
 
809
	 *
-
 
810
	 * Drivers implementing atomic modeset should use
-
 
811
	 * drm_atomic_helper_connector_dpms() to implement this hook.
-
 
812
	 *
-
 
813
	 * RETURNS:
-
 
814
	 *
-
 
815
	 * 0 on success or a negative error code on failure.
518
struct drm_connector_funcs {
816
	 */
-
 
817
	int (*dpms)(struct drm_connector *connector, int mode);
-
 
818
 
-
 
819
	/**
-
 
820
	 * @reset:
-
 
821
	 *
-
 
822
	 * Reset connector hardware and software state to off. This function isn't
519
	int (*dpms)(struct drm_connector *connector, int mode);
823
	 * called by the core directly, only through drm_mode_config_reset().
-
 
824
	 * It's not a helper hook only for historical reasons.
520
	void (*save)(struct drm_connector *connector);
825
	 *
-
 
826
	 * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
-
 
827
	 * atomic state using this hook.
521
	void (*restore)(struct drm_connector *connector);
828
	 */
Line -... Line 829...
-
 
829
	void (*reset)(struct drm_connector *connector);
-
 
830
 
-
 
831
	/**
522
	void (*reset)(struct drm_connector *connector);
832
	 * @detect:
523
 
833
	 *
524
	/* Check to see if anything is attached to the connector.
834
	 * Check to see if anything is attached to the connector. The parameter
525
	 * @force is set to false whilst polling, true when checking the
835
	 * force is set to false whilst polling, true when checking the
-
 
836
	 * connector due to a user request. force can be used by the driver to
-
 
837
	 * avoid expensive, destructive operations during automated probing.
-
 
838
	 *
-
 
839
	 * FIXME:
-
 
840
	 *
-
 
841
	 * Note that this hook is only called by the probe helper. It's not in
-
 
842
	 * the helper library vtable purely for historical reasons. The only DRM
526
	 * connector due to user request. @force can be used by the driver
843
	 * core	entry point to probe connector state is @fill_modes.
-
 
844
	 *
-
 
845
	 * RETURNS:
527
	 * to avoid expensive, destructive operations during automated
846
	 *
528
	 * probing.
847
	 * drm_connector_status indicating the connector's status.
529
	 */
848
	 */
-
 
849
	enum drm_connector_status (*detect)(struct drm_connector *connector,
-
 
850
					    bool force);
-
 
851
 
-
 
852
	/**
-
 
853
	 * @force:
-
 
854
	 *
-
 
855
	 * This function is called to update internal encoder state when the
-
 
856
	 * connector is forced to a certain state by userspace, either through
-
 
857
	 * the sysfs interfaces or on the kernel cmdline. In that case the
-
 
858
	 * @detect callback isn't called.
-
 
859
	 *
-
 
860
	 * FIXME:
-
 
861
	 *
-
 
862
	 * Note that this hook is only called by the probe helper. It's not in
-
 
863
	 * the helper library vtable purely for historical reasons. The only DRM
-
 
864
	 * core	entry point to probe connector state is @fill_modes.
-
 
865
	 */
-
 
866
	void (*force)(struct drm_connector *connector);
-
 
867
 
-
 
868
	/**
-
 
869
	 * @fill_modes:
-
 
870
	 *
-
 
871
	 * Entry point for output detection and basic mode validation. The
-
 
872
	 * driver should reprobe the output if needed (e.g. when hotplug
-
 
873
	 * handling is unreliable), add all detected modes to connector->modes
-
 
874
	 * and filter out any the device can't support in any configuration. It
-
 
875
	 * also needs to filter out any modes wider or higher than the
-
 
876
	 * parameters max_width and max_height indicate.
-
 
877
	 *
-
 
878
	 * The drivers must also prune any modes no longer valid from
-
 
879
	 * connector->modes. Furthermore it must update connector->status and
-
 
880
	 * connector->edid.  If no EDID has been received for this output
-
 
881
	 * connector->edid must be NULL.
-
 
882
	 *
-
 
883
	 * Drivers using the probe helpers should use
-
 
884
	 * drm_helper_probe_single_connector_modes() or
-
 
885
	 * drm_helper_probe_single_connector_modes_nomerge() to implement this
-
 
886
	 * function.
-
 
887
	 *
-
 
888
	 * RETURNS:
-
 
889
	 *
530
	enum drm_connector_status (*detect)(struct drm_connector *connector,
890
	 * The number of modes detected and filled into connector->modes.
-
 
891
	 */
-
 
892
	int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
-
 
893
 
-
 
894
	/**
-
 
895
	 * @set_property:
-
 
896
	 *
-
 
897
	 * This is the legacy entry point to update a property attached to the
-
 
898
	 * connector.
-
 
899
	 *
-
 
900
	 * Drivers implementing atomic modeset should use
-
 
901
	 * drm_atomic_helper_connector_set_property() to implement this hook.
-
 
902
	 *
-
 
903
	 * This callback is optional if the driver does not support any legacy
-
 
904
	 * driver-private properties.
-
 
905
	 *
-
 
906
	 * RETURNS:
-
 
907
	 *
531
					    bool force);
908
	 * 0 on success or a negative error code on failure.
532
	int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
909
	 */
-
 
910
	int (*set_property)(struct drm_connector *connector, struct drm_property *property,
-
 
911
			     uint64_t val);
-
 
912
 
-
 
913
	/**
-
 
914
	 * @destroy:
-
 
915
	 *
-
 
916
	 * Clean up connector resources. This is called at driver unload time
-
 
917
	 * through drm_mode_config_cleanup(). It can also be called at runtime
-
 
918
	 * when a connector is being hot-unplugged for drivers that support
533
	int (*set_property)(struct drm_connector *connector, struct drm_property *property,
919
	 * connector hotplugging (e.g. DisplayPort MST).
534
			     uint64_t val);
-
 
Line -... Line 920...
-
 
920
	 */
535
	void (*destroy)(struct drm_connector *connector);
921
	void (*destroy)(struct drm_connector *connector);
-
 
922
 
-
 
923
	/**
-
 
924
	 * @atomic_duplicate_state:
-
 
925
	 *
-
 
926
	 * Duplicate the current atomic state for this connector and return it.
-
 
927
	 * The core and helpers gurantee that any atomic state duplicated with
-
 
928
	 * this hook and still owned by the caller (i.e. not transferred to the
-
 
929
	 * driver by calling ->atomic_commit() from struct
-
 
930
	 * &drm_mode_config_funcs) will be cleaned up by calling the
-
 
931
	 * @atomic_destroy_state hook in this structure.
-
 
932
	 *
-
 
933
	 * Atomic drivers which don't subclass struct &drm_connector_state should use
-
 
934
	 * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
-
 
935
	 * state structure to extend it with driver-private state should use
-
 
936
	 * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
-
 
937
	 * duplicated in a consistent fashion across drivers.
-
 
938
	 *
-
 
939
	 * It is an error to call this hook before connector->state has been
-
 
940
	 * initialized correctly.
-
 
941
	 *
-
 
942
	 * NOTE:
-
 
943
	 *
-
 
944
	 * If the duplicate state references refcounted resources this hook must
-
 
945
	 * acquire a reference for each of them. The driver must release these
-
 
946
	 * references again in @atomic_destroy_state.
-
 
947
	 *
-
 
948
	 * RETURNS:
536
	void (*force)(struct drm_connector *connector);
949
	 *
-
 
950
	 * Duplicated atomic state or NULL when the allocation failed.
-
 
951
	 */
-
 
952
	struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
-
 
953
 
-
 
954
	/**
-
 
955
	 * @atomic_destroy_state:
-
 
956
	 *
537
 
957
	 * Destroy a state duplicated with @atomic_duplicate_state and release
538
	/* atomic update handling */
958
	 * or unreference all resources it references
-
 
959
	 */
-
 
960
	void (*atomic_destroy_state)(struct drm_connector *connector,
-
 
961
				     struct drm_connector_state *state);
-
 
962
 
-
 
963
	/**
-
 
964
	 * @atomic_set_property:
-
 
965
	 *
-
 
966
	 * Decode a driver-private property value and store the decoded value
-
 
967
	 * into the passed-in state structure. Since the atomic core decodes all
-
 
968
	 * standardized properties (even for extensions beyond the core set of
-
 
969
	 * properties which might not be implemented by all drivers) this
-
 
970
	 * requires drivers to subclass the state structure.
-
 
971
	 *
-
 
972
	 * Such driver-private properties should really only be implemented for
-
 
973
	 * truly hardware/vendor specific state. Instead it is preferred to
-
 
974
	 * standardize atomic extension and decode the properties used to expose
-
 
975
	 * such an extension in the core.
-
 
976
	 *
-
 
977
	 * Do not call this function directly, use
-
 
978
	 * drm_atomic_connector_set_property() instead.
-
 
979
	 *
-
 
980
	 * This callback is optional if the driver does not support any
-
 
981
	 * driver-private atomic properties.
-
 
982
	 *
-
 
983
	 * NOTE:
-
 
984
	 *
-
 
985
	 * This function is called in the state assembly phase of atomic
-
 
986
	 * modesets, which can be aborted for any reason (including on
-
 
987
	 * userspace's request to just check whether a configuration would be
-
 
988
	 * possible). Drivers MUST NOT touch any persistent state (hardware or
-
 
989
	 * software) or data structures except the passed in @state parameter.
-
 
990
	 *
-
 
991
	 * Also since userspace controls in which order properties are set this
-
 
992
	 * function must not do any input validation (since the state update is
-
 
993
	 * incomplete and hence likely inconsistent). Instead any such input
-
 
994
	 * validation must be done in the various atomic_check callbacks.
-
 
995
	 *
-
 
996
	 * RETURNS:
-
 
997
	 *
-
 
998
	 * 0 if the property has been found, -EINVAL if the property isn't
-
 
999
	 * implemented by the driver (which shouldn't ever happen, the core only
-
 
1000
	 * asks for properties attached to this connector). No other validation
-
 
1001
	 * is allowed by the driver. The core already checks that the property
539
	struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
1002
	 * value is within the range (integer, valid enum value, ...) the driver
540
	void (*atomic_destroy_state)(struct drm_connector *connector,
1003
	 * set when registering the property.
541
				     struct drm_connector_state *state);
1004
	 */
542
	int (*atomic_set_property)(struct drm_connector *connector,
1005
	int (*atomic_set_property)(struct drm_connector *connector,
-
 
1006
				   struct drm_connector_state *state,
-
 
1007
				   struct drm_property *property,
-
 
1008
				   uint64_t val);
-
 
1009
 
-
 
1010
	/**
-
 
1011
	 * @atomic_get_property:
-
 
1012
	 *
-
 
1013
	 * Reads out the decoded driver-private property. This is used to
-
 
1014
	 * implement the GETCONNECTOR IOCTL.
-
 
1015
	 *
-
 
1016
	 * Do not call this function directly, use
-
 
1017
	 * drm_atomic_connector_get_property() instead.
-
 
1018
	 *
-
 
1019
	 * This callback is optional if the driver does not support any
-
 
1020
	 * driver-private atomic properties.
-
 
1021
	 *
-
 
1022
	 * RETURNS:
-
 
1023
	 *
-
 
1024
	 * 0 on success, -EINVAL if the property isn't implemented by the
543
				   struct drm_connector_state *state,
1025
	 * driver (which shouldn't ever happen, the core only asks for
544
				   struct drm_property *property,
1026
	 * properties attached to this connector).
545
				   uint64_t val);
1027
	 */
546
	int (*atomic_get_property)(struct drm_connector *connector,
1028
	int (*atomic_get_property)(struct drm_connector *connector,
547
				   const struct drm_connector_state *state,
1029
				   const struct drm_connector_state *state,
Line 548... Line 1030...
548
				   struct drm_property *property,
1030
				   struct drm_property *property,
549
				   uint64_t *val);
1031
				   uint64_t *val);
550
};
-
 
551
 
-
 
552
/**
1032
};
553
 * struct drm_encoder_funcs - encoder controls
1033
 
554
 * @reset: reset state (e.g. at init or resume time)
1034
/**
555
 * @destroy: cleanup and free associated data
1035
 * struct drm_encoder_funcs - encoder controls
-
 
1036
 *
-
 
1037
 * Encoders sit between CRTCs and connectors.
-
 
1038
 */
-
 
1039
struct drm_encoder_funcs {
-
 
1040
	/**
-
 
1041
	 * @reset:
-
 
1042
	 *
556
 *
1043
	 * Reset encoder hardware and software state to off. This function isn't
-
 
1044
	 * called by the core directly, only through drm_mode_config_reset().
-
 
1045
	 * It's not a helper hook only for historical reasons.
-
 
1046
	 */
-
 
1047
	void (*reset)(struct drm_encoder *encoder);
-
 
1048
 
-
 
1049
	/**
-
 
1050
	 * @destroy:
-
 
1051
	 *
557
 * Encoders sit between CRTCs and connectors.
1052
	 * Clean up encoder resources. This is only called at driver unload time
558
 */
1053
	 * through drm_mode_config_cleanup() since an encoder cannot be
Line 559... Line 1054...
559
struct drm_encoder_funcs {
1054
	 * hotplugged in DRM.
Line 591... Line 1086...
591
	uint32_t possible_clones;
1086
	uint32_t possible_clones;
Line 592... Line 1087...
592
 
1087
 
593
	struct drm_crtc *crtc;
1088
	struct drm_crtc *crtc;
594
	struct drm_bridge *bridge;
1089
	struct drm_bridge *bridge;
595
	const struct drm_encoder_funcs *funcs;
1090
	const struct drm_encoder_funcs *funcs;
596
	const void *helper_private;
1091
	const struct drm_encoder_helper_funcs *helper_private;
Line 597... Line 1092...
597
};
1092
};
598
 
1093
 
599
/* should we poll this connector for connects and disconnects */
1094
/* should we poll this connector for connects and disconnects */
Line 669... Line 1164...
669
	struct list_head head;
1164
	struct list_head head;
Line 670... Line 1165...
670
 
1165
 
Line 671... Line 1166...
671
	struct drm_mode_object base;
1166
	struct drm_mode_object base;
-
 
1167
 
672
 
1168
	char *name;
673
	char *name;
1169
	int connector_id;
674
	int connector_type;
1170
	int connector_type;
675
	int connector_type_id;
1171
	int connector_type_id;
676
	bool interlace_allowed;
1172
	bool interlace_allowed;
Line 696... Line 1192...
696
	uint8_t polled; /* DRM_CONNECTOR_POLL_* */
1192
	uint8_t polled; /* DRM_CONNECTOR_POLL_* */
Line 697... Line 1193...
697
 
1193
 
698
	/* requested DPMS state */
1194
	/* requested DPMS state */
Line 699... Line 1195...
699
	int dpms;
1195
	int dpms;
Line 700... Line 1196...
700
 
1196
 
701
	const void *helper_private;
1197
	const struct drm_connector_helper_funcs *helper_private;
702
 
1198
 
703
	/* forced on connector */
1199
	/* forced on connector */
Line 776... Line 1272...
776
};
1272
};
Line 777... Line 1273...
777
 
1273
 
778
 
1274
 
779
/**
-
 
780
 * struct drm_plane_funcs - driver plane control functions
-
 
781
 * @update_plane: update the plane configuration
-
 
782
 * @disable_plane: shut down the plane
-
 
783
 * @destroy: clean up plane resources
-
 
784
 * @reset: reset plane after state has been invalidated (e.g. resume)
-
 
785
 * @set_property: called when a property is changed
-
 
786
 * @atomic_duplicate_state: duplicate the atomic state for this plane
-
 
787
 * @atomic_destroy_state: destroy an atomic state for this plane
-
 
788
 * @atomic_set_property: set a property on an atomic state for this plane
-
 
789
 *    (do not call directly, use drm_atomic_plane_set_property())
-
 
790
 * @atomic_get_property: get a property on an atomic state for this plane
1275
/**
791
 *    (do not call directly, use drm_atomic_plane_get_property())
1276
 * struct drm_plane_funcs - driver plane control functions
-
 
1277
 */
-
 
1278
struct drm_plane_funcs {
-
 
1279
	/**
-
 
1280
	 * @update_plane:
-
 
1281
	 *
-
 
1282
	 * This is the legacy entry point to enable and configure the plane for
-
 
1283
	 * the given CRTC and framebuffer. It is never called to disable the
-
 
1284
	 * plane, i.e. the passed-in crtc and fb paramters are never NULL.
-
 
1285
	 *
-
 
1286
	 * The source rectangle in frame buffer memory coordinates is given by
-
 
1287
	 * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point
-
 
1288
	 * values). Devices that don't support subpixel plane coordinates can
-
 
1289
	 * ignore the fractional part.
-
 
1290
	 *
-
 
1291
	 * The destination rectangle in CRTC coordinates is given by the
-
 
1292
	 * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values).
-
 
1293
	 * Devices scale the source rectangle to the destination rectangle. If
-
 
1294
	 * scaling is not supported, and the source rectangle size doesn't match
-
 
1295
	 * the destination rectangle size, the driver must return a
-
 
1296
	 * -EINVAL error.
-
 
1297
	 *
-
 
1298
	 * Drivers implementing atomic modeset should use
-
 
1299
	 * drm_atomic_helper_update_plane() to implement this hook.
-
 
1300
	 *
-
 
1301
	 * RETURNS:
-
 
1302
	 *
792
 */
1303
	 * 0 on success or a negative error code on failure.
793
struct drm_plane_funcs {
1304
	 */
794
	int (*update_plane)(struct drm_plane *plane,
1305
	int (*update_plane)(struct drm_plane *plane,
795
			    struct drm_crtc *crtc, struct drm_framebuffer *fb,
1306
			    struct drm_crtc *crtc, struct drm_framebuffer *fb,
796
			    int crtc_x, int crtc_y,
1307
			    int crtc_x, int crtc_y,
797
			    unsigned int crtc_w, unsigned int crtc_h,
1308
			    unsigned int crtc_w, unsigned int crtc_h,
-
 
1309
			    uint32_t src_x, uint32_t src_y,
-
 
1310
			    uint32_t src_w, uint32_t src_h);
-
 
1311
 
-
 
1312
	/**
-
 
1313
	 * @disable_plane:
-
 
1314
	 *
-
 
1315
	 * This is the legacy entry point to disable the plane. The DRM core
-
 
1316
	 * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call
-
 
1317
	 * with the frame buffer ID set to 0.  Disabled planes must not be
-
 
1318
	 * processed by the CRTC.
-
 
1319
	 *
-
 
1320
	 * Drivers implementing atomic modeset should use
-
 
1321
	 * drm_atomic_helper_disable_plane() to implement this hook.
-
 
1322
	 *
-
 
1323
	 * RETURNS:
-
 
1324
	 *
798
			    uint32_t src_x, uint32_t src_y,
1325
	 * 0 on success or a negative error code on failure.
-
 
1326
	 */
-
 
1327
	int (*disable_plane)(struct drm_plane *plane);
-
 
1328
 
-
 
1329
	/**
-
 
1330
	 * @destroy:
-
 
1331
	 *
-
 
1332
	 * Clean up plane resources. This is only called at driver unload time
-
 
1333
	 * through drm_mode_config_cleanup() since a plane cannot be hotplugged
799
			    uint32_t src_w, uint32_t src_h);
1334
	 * in DRM.
-
 
1335
	 */
-
 
1336
	void (*destroy)(struct drm_plane *plane);
-
 
1337
 
-
 
1338
	/**
-
 
1339
	 * @reset:
-
 
1340
	 *
-
 
1341
	 * Reset plane hardware and software state to off. This function isn't
-
 
1342
	 * called by the core directly, only through drm_mode_config_reset().
-
 
1343
	 * It's not a helper hook only for historical reasons.
-
 
1344
	 *
-
 
1345
	 * Atomic drivers can use drm_atomic_helper_plane_reset() to reset
800
	int (*disable_plane)(struct drm_plane *plane);
1346
	 * atomic state using this hook.
Line -... Line 1347...
-
 
1347
	 */
-
 
1348
	void (*reset)(struct drm_plane *plane);
-
 
1349
 
-
 
1350
	/**
-
 
1351
	 * @set_property:
-
 
1352
	 *
-
 
1353
	 * This is the legacy entry point to update a property attached to the
-
 
1354
	 * plane.
-
 
1355
	 *
-
 
1356
	 * Drivers implementing atomic modeset should use
-
 
1357
	 * drm_atomic_helper_plane_set_property() to implement this hook.
-
 
1358
	 *
-
 
1359
	 * This callback is optional if the driver does not support any legacy
-
 
1360
	 * driver-private properties.
-
 
1361
	 *
-
 
1362
	 * RETURNS:
801
	void (*destroy)(struct drm_plane *plane);
1363
	 *
802
	void (*reset)(struct drm_plane *plane);
1364
	 * 0 on success or a negative error code on failure.
Line -... Line 1365...
-
 
1365
	 */
803
 
1366
	int (*set_property)(struct drm_plane *plane,
-
 
1367
			    struct drm_property *property, uint64_t val);
-
 
1368
 
-
 
1369
	/**
-
 
1370
	 * @atomic_duplicate_state:
-
 
1371
	 *
-
 
1372
	 * Duplicate the current atomic state for this plane and return it.
-
 
1373
	 * The core and helpers gurantee that any atomic state duplicated with
-
 
1374
	 * this hook and still owned by the caller (i.e. not transferred to the
-
 
1375
	 * driver by calling ->atomic_commit() from struct
-
 
1376
	 * &drm_mode_config_funcs) will be cleaned up by calling the
-
 
1377
	 * @atomic_destroy_state hook in this structure.
-
 
1378
	 *
-
 
1379
	 * Atomic drivers which don't subclass struct &drm_plane_state should use
-
 
1380
	 * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the
-
 
1381
	 * state structure to extend it with driver-private state should use
-
 
1382
	 * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is
-
 
1383
	 * duplicated in a consistent fashion across drivers.
-
 
1384
	 *
-
 
1385
	 * It is an error to call this hook before plane->state has been
-
 
1386
	 * initialized correctly.
-
 
1387
	 *
-
 
1388
	 * NOTE:
-
 
1389
	 *
-
 
1390
	 * If the duplicate state references refcounted resources this hook must
-
 
1391
	 * acquire a reference for each of them. The driver must release these
-
 
1392
	 * references again in @atomic_destroy_state.
-
 
1393
	 *
804
	int (*set_property)(struct drm_plane *plane,
1394
	 * RETURNS:
-
 
1395
	 *
-
 
1396
	 * Duplicated atomic state or NULL when the allocation failed.
-
 
1397
	 */
-
 
1398
	struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
-
 
1399
 
-
 
1400
	/**
-
 
1401
	 * @atomic_destroy_state:
805
			    struct drm_property *property, uint64_t val);
1402
	 *
806
 
1403
	 * Destroy a state duplicated with @atomic_duplicate_state and release
-
 
1404
	 * or unreference all resources it references
-
 
1405
	 */
-
 
1406
	void (*atomic_destroy_state)(struct drm_plane *plane,
-
 
1407
				     struct drm_plane_state *state);
-
 
1408
 
-
 
1409
	/**
-
 
1410
	 * @atomic_set_property:
-
 
1411
	 *
-
 
1412
	 * Decode a driver-private property value and store the decoded value
-
 
1413
	 * into the passed-in state structure. Since the atomic core decodes all
-
 
1414
	 * standardized properties (even for extensions beyond the core set of
-
 
1415
	 * properties which might not be implemented by all drivers) this
-
 
1416
	 * requires drivers to subclass the state structure.
-
 
1417
	 *
-
 
1418
	 * Such driver-private properties should really only be implemented for
-
 
1419
	 * truly hardware/vendor specific state. Instead it is preferred to
-
 
1420
	 * standardize atomic extension and decode the properties used to expose
-
 
1421
	 * such an extension in the core.
-
 
1422
	 *
-
 
1423
	 * Do not call this function directly, use
-
 
1424
	 * drm_atomic_plane_set_property() instead.
-
 
1425
	 *
-
 
1426
	 * This callback is optional if the driver does not support any
-
 
1427
	 * driver-private atomic properties.
-
 
1428
	 *
-
 
1429
	 * NOTE:
-
 
1430
	 *
-
 
1431
	 * This function is called in the state assembly phase of atomic
-
 
1432
	 * modesets, which can be aborted for any reason (including on
-
 
1433
	 * userspace's request to just check whether a configuration would be
-
 
1434
	 * possible). Drivers MUST NOT touch any persistent state (hardware or
-
 
1435
	 * software) or data structures except the passed in @state parameter.
-
 
1436
	 *
-
 
1437
	 * Also since userspace controls in which order properties are set this
-
 
1438
	 * function must not do any input validation (since the state update is
-
 
1439
	 * incomplete and hence likely inconsistent). Instead any such input
-
 
1440
	 * validation must be done in the various atomic_check callbacks.
-
 
1441
	 *
-
 
1442
	 * RETURNS:
-
 
1443
	 *
-
 
1444
	 * 0 if the property has been found, -EINVAL if the property isn't
-
 
1445
	 * implemented by the driver (which shouldn't ever happen, the core only
-
 
1446
	 * asks for properties attached to this plane). No other validation is
807
	/* atomic update handling */
1447
	 * allowed by the driver. The core already checks that the property
808
	struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane);
1448
	 * value is within the range (integer, valid enum value, ...) the driver
809
	void (*atomic_destroy_state)(struct drm_plane *plane,
1449
	 * set when registering the property.
810
				     struct drm_plane_state *state);
1450
	 */
-
 
1451
	int (*atomic_set_property)(struct drm_plane *plane,
-
 
1452
				   struct drm_plane_state *state,
-
 
1453
				   struct drm_property *property,
-
 
1454
				   uint64_t val);
-
 
1455
 
-
 
1456
	/**
-
 
1457
	 * @atomic_get_property:
-
 
1458
	 *
-
 
1459
	 * Reads out the decoded driver-private property. This is used to
-
 
1460
	 * implement the GETPLANE IOCTL.
-
 
1461
	 *
-
 
1462
	 * Do not call this function directly, use
-
 
1463
	 * drm_atomic_plane_get_property() instead.
-
 
1464
	 *
-
 
1465
	 * This callback is optional if the driver does not support any
-
 
1466
	 * driver-private atomic properties.
-
 
1467
	 *
-
 
1468
	 * RETURNS:
-
 
1469
	 *
811
	int (*atomic_set_property)(struct drm_plane *plane,
1470
	 * 0 on success, -EINVAL if the property isn't implemented by the
812
				   struct drm_plane_state *state,
1471
	 * driver (which should never happen, the core only asks for
813
				   struct drm_property *property,
1472
	 * properties attached to this plane).
814
				   uint64_t val);
1473
	 */
815
	int (*atomic_get_property)(struct drm_plane *plane,
1474
	int (*atomic_get_property)(struct drm_plane *plane,
Line 822... Line 1481...
822
	DRM_PLANE_TYPE_OVERLAY,
1481
	DRM_PLANE_TYPE_OVERLAY,
823
	DRM_PLANE_TYPE_PRIMARY,
1482
	DRM_PLANE_TYPE_PRIMARY,
824
	DRM_PLANE_TYPE_CURSOR,
1483
	DRM_PLANE_TYPE_CURSOR,
825
};
1484
};
Line -... Line 1485...
-
 
1485
 
826
 
1486
 
827
/**
1487
/**
828
 * struct drm_plane - central DRM plane control structure
1488
 * struct drm_plane - central DRM plane control structure
829
 * @dev: DRM device this plane belongs to
1489
 * @dev: DRM device this plane belongs to
830
 * @head: for list management
1490
 * @head: for list management
Line 844... Line 1504...
844
 */
1504
 */
845
struct drm_plane {
1505
struct drm_plane {
846
	struct drm_device *dev;
1506
	struct drm_device *dev;
847
	struct list_head head;
1507
	struct list_head head;
Line -... Line 1508...
-
 
1508
 
-
 
1509
	char *name;
848
 
1510
 
Line 849... Line 1511...
849
	struct drm_modeset_lock mutex;
1511
	struct drm_modeset_lock mutex;
Line 850... Line 1512...
850
 
1512
 
Line 864... Line 1526...
864
 
1526
 
Line 865... Line 1527...
865
	struct drm_object_properties properties;
1527
	struct drm_object_properties properties;
Line 866... Line 1528...
866
 
1528
 
Line 867... Line 1529...
867
	enum drm_plane_type type;
1529
	enum drm_plane_type type;
868
 
1530
 
Line 869... Line 1531...
869
	const void *helper_private;
1531
	const struct drm_plane_helper_funcs *helper_private;
870
 
1532
 
871
	struct drm_plane_state *state;
1533
	struct drm_plane_state *state;
872
};
-
 
873
 
-
 
874
/**
-
 
875
 * struct drm_bridge_funcs - drm_bridge control functions
-
 
876
 * @attach: Called during drm_bridge_attach
-
 
877
 * @mode_fixup: Try to fixup (or reject entirely) proposed mode for this bridge
-
 
878
 * @disable: Called right before encoder prepare, disables the bridge
1534
};
879
 * @post_disable: Called right after encoder prepare, for lockstepped disable
1535
 
880
 * @mode_set: Set this mode to the bridge
1536
/**
-
 
1537
 * struct drm_bridge_funcs - drm_bridge control functions
-
 
1538
 * @attach: Called during drm_bridge_attach
-
 
1539
 */
-
 
1540
struct drm_bridge_funcs {
-
 
1541
	int (*attach)(struct drm_bridge *bridge);
-
 
1542
 
-
 
1543
	/**
-
 
1544
	 * @mode_fixup:
-
 
1545
	 *
-
 
1546
	 * This callback is used to validate and adjust a mode. The paramater
-
 
1547
	 * mode is the display mode that should be fed to the next element in
-
 
1548
	 * the display chain, either the final &drm_connector or the next
-
 
1549
	 * &drm_bridge. The parameter adjusted_mode is the input mode the bridge
-
 
1550
	 * requires. It can be modified by this callback and does not need to
-
 
1551
	 * match mode.
-
 
1552
	 *
-
 
1553
	 * This is the only hook that allows a bridge to reject a modeset. If
-
 
1554
	 * this function passes all other callbacks must succeed for this
-
 
1555
	 * configuration.
-
 
1556
	 *
-
 
1557
	 * NOTE:
-
 
1558
	 *
-
 
1559
	 * This function is called in the check phase of atomic modesets, which
-
 
1560
	 * can be aborted for any reason (including on userspace's request to
-
 
1561
	 * just check whether a configuration would be possible). Drivers MUST
-
 
1562
	 * NOT touch any persistent state (hardware or software) or data
-
 
1563
	 * structures except the passed in @state parameter.
-
 
1564
	 *
881
 * @pre_enable: Called right before encoder commit, for lockstepped commit
1565
	 * RETURNS:
882
 * @enable: Called right after encoder commit, enables the bridge
1566
	 *
883
 */
1567
	 * True if an acceptable configuration is possible, false if the modeset
-
 
1568
	 * operation should be rejected.
-
 
1569
	 */
-
 
1570
	bool (*mode_fixup)(struct drm_bridge *bridge,
-
 
1571
			   const struct drm_display_mode *mode,
-
 
1572
			   struct drm_display_mode *adjusted_mode);
-
 
1573
	/**
-
 
1574
	 * @disable:
-
 
1575
	 *
-
 
1576
	 * This callback should disable the bridge. It is called right before
-
 
1577
	 * the preceding element in the display pipe is disabled. If the
-
 
1578
	 * preceding element is a bridge this means it's called before that
-
 
1579
	 * bridge's ->disable() function. If the preceding element is a
-
 
1580
	 * &drm_encoder it's called right before the encoder's ->disable(),
884
struct drm_bridge_funcs {
1581
	 * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs.
-
 
1582
	 *
-
 
1583
	 * The bridge can assume that the display pipe (i.e. clocks and timing
-
 
1584
	 * signals) feeding it is still running when this callback is called.
-
 
1585
	 */
-
 
1586
	void (*disable)(struct drm_bridge *bridge);
-
 
1587
 
-
 
1588
	/**
-
 
1589
	 * @post_disable:
-
 
1590
	 *
-
 
1591
	 * This callback should disable the bridge. It is called right after
-
 
1592
	 * the preceding element in the display pipe is disabled. If the
-
 
1593
	 * preceding element is a bridge this means it's called after that
-
 
1594
	 * bridge's ->post_disable() function. If the preceding element is a
-
 
1595
	 * &drm_encoder it's called right after the encoder's ->disable(),
-
 
1596
	 * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs.
885
	int (*attach)(struct drm_bridge *bridge);
1597
	 *
-
 
1598
	 * The bridge must assume that the display pipe (i.e. clocks and timing
-
 
1599
	 * singals) feeding it is no longer running when this callback is
-
 
1600
	 * called.
-
 
1601
	 */
-
 
1602
	void (*post_disable)(struct drm_bridge *bridge);
-
 
1603
 
-
 
1604
	/**
-
 
1605
	 * @mode_set:
-
 
1606
	 *
886
	bool (*mode_fixup)(struct drm_bridge *bridge,
1607
	 * This callback should set the given mode on the bridge. It is called
887
			   const struct drm_display_mode *mode,
1608
	 * after the ->mode_set() callback for the preceding element in the
888
			   struct drm_display_mode *adjusted_mode);
1609
	 * display pipeline has been called already. The display pipe (i.e.
-
 
1610
	 * clocks and timing signals) is off when this function is called.
-
 
1611
	 */
-
 
1612
	void (*mode_set)(struct drm_bridge *bridge,
-
 
1613
			 struct drm_display_mode *mode,
-
 
1614
			 struct drm_display_mode *adjusted_mode);
-
 
1615
	/**
-
 
1616
	 * @pre_enable:
-
 
1617
	 *
-
 
1618
	 * This callback should enable the bridge. It is called right before
-
 
1619
	 * the preceding element in the display pipe is enabled. If the
-
 
1620
	 * preceding element is a bridge this means it's called before that
-
 
1621
	 * bridge's ->pre_enable() function. If the preceding element is a
-
 
1622
	 * &drm_encoder it's called right before the encoder's ->enable(),
-
 
1623
	 * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs.
-
 
1624
	 *
889
	void (*disable)(struct drm_bridge *bridge);
1625
	 * The display pipe (i.e. clocks and timing signals) feeding this bridge
-
 
1626
	 * will not yet be running when this callback is called. The bridge must
-
 
1627
	 * not enable the display link feeding the next bridge in the chain (if
-
 
1628
	 * there is one) when this callback is called.
-
 
1629
	 */
-
 
1630
	void (*pre_enable)(struct drm_bridge *bridge);
-
 
1631
 
-
 
1632
	/**
-
 
1633
	 * @enable:
-
 
1634
	 *
-
 
1635
	 * This callback should enable the bridge. It is called right after
-
 
1636
	 * the preceding element in the display pipe is enabled. If the
-
 
1637
	 * preceding element is a bridge this means it's called after that
-
 
1638
	 * bridge's ->enable() function. If the preceding element is a
-
 
1639
	 * &drm_encoder it's called right after the encoder's ->enable(),
-
 
1640
	 * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs.
-
 
1641
	 *
890
	void (*post_disable)(struct drm_bridge *bridge);
1642
	 * The bridge can assume that the display pipe (i.e. clocks and timing
891
	void (*mode_set)(struct drm_bridge *bridge,
1643
	 * signals) feeding it is running when this callback is called. This
Line 892... Line 1644...
892
			 struct drm_display_mode *mode,
1644
	 * callback must enable the display link feeding the next bridge in the
893
			 struct drm_display_mode *adjusted_mode);
1645
	 * chain if there is one.
Line 920... Line 1672...
920
 
1672
 
921
/**
1673
/**
922
 * struct drm_atomic_state - the global state object for atomic updates
1674
 * struct drm_atomic_state - the global state object for atomic updates
923
 * @dev: parent DRM device
1675
 * @dev: parent DRM device
924
 * @allow_modeset: allow full modeset
1676
 * @allow_modeset: allow full modeset
925
 * @legacy_cursor_update: hint to enforce legacy cursor ioctl semantics
1677
 * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics
926
 * @planes: pointer to array of plane pointers
1678
 * @planes: pointer to array of plane pointers
927
 * @plane_states: pointer to array of plane states pointers
1679
 * @plane_states: pointer to array of plane states pointers
928
 * @crtcs: pointer to array of CRTC pointers
1680
 * @crtcs: pointer to array of CRTC pointers
929
 * @crtc_states: pointer to array of CRTC states pointers
1681
 * @crtc_states: pointer to array of CRTC states pointers
Line 975... Line 1727...
975
	size_t num_connectors;
1727
	size_t num_connectors;
976
};
1728
};
Line 977... Line 1729...
977
 
1729
 
978
/**
1730
/**
979
 * struct drm_mode_config_funcs - basic driver provided mode setting functions
-
 
980
 * @fb_create: create a new framebuffer object
-
 
981
 * @output_poll_changed: function to handle output configuration changes
-
 
982
 * @atomic_check: check whether a given atomic state update is possible
-
 
983
 * @atomic_commit: commit an atomic state update previously verified with
-
 
984
 * 	atomic_check()
-
 
985
 * @atomic_state_alloc: allocate a new atomic state
-
 
986
 * @atomic_state_clear: clear the atomic state
-
 
987
 * @atomic_state_free: free the atomic state
1731
 * struct drm_mode_config_funcs - basic driver provided mode setting functions
988
 *
1732
 *
989
 * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
1733
 * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
990
 * involve drivers.
1734
 * involve drivers.
991
 */
1735
 */
-
 
1736
struct drm_mode_config_funcs {
-
 
1737
	/**
-
 
1738
	 * @fb_create:
-
 
1739
	 *
-
 
1740
	 * Create a new framebuffer object. The core does basic checks on the
-
 
1741
	 * requested metadata, but most of that is left to the driver. See
-
 
1742
	 * struct &drm_mode_fb_cmd2 for details.
-
 
1743
	 *
-
 
1744
	 * If the parameters are deemed valid and the backing storage objects in
-
 
1745
	 * the underlying memory manager all exist, then the driver allocates
-
 
1746
	 * a new &drm_framebuffer structure, subclassed to contain
-
 
1747
	 * driver-specific information (like the internal native buffer object
-
 
1748
	 * references). It also needs to fill out all relevant metadata, which
-
 
1749
	 * should be done by calling drm_helper_mode_fill_fb_struct().
-
 
1750
	 *
-
 
1751
	 * The initialization is finalized by calling drm_framebuffer_init(),
-
 
1752
	 * which registers the framebuffer and makes it accessible to other
-
 
1753
	 * threads.
-
 
1754
	 *
-
 
1755
	 * RETURNS:
-
 
1756
	 *
-
 
1757
	 * A new framebuffer with an initial reference count of 1 or a negative
-
 
1758
	 * error code encoded with ERR_PTR().
992
struct drm_mode_config_funcs {
1759
	 */
993
	struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
1760
	struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
994
					     struct drm_file *file_priv,
1761
					     struct drm_file *file_priv,
-
 
1762
					     const struct drm_mode_fb_cmd2 *mode_cmd);
-
 
1763
 
-
 
1764
	/**
-
 
1765
	 * @output_poll_changed:
-
 
1766
	 *
-
 
1767
	 * Callback used by helpers to inform the driver of output configuration
-
 
1768
	 * changes.
-
 
1769
	 *
-
 
1770
	 * Drivers implementing fbdev emulation with the helpers can call
-
 
1771
	 * drm_fb_helper_hotplug_changed from this hook to inform the fbdev
-
 
1772
	 * helper of output changes.
-
 
1773
	 *
-
 
1774
	 * FIXME:
-
 
1775
	 *
-
 
1776
	 * Except that there's no vtable for device-level helper callbacks
-
 
1777
	 * there's no reason this is a core function.
995
					     struct drm_mode_fb_cmd2 *mode_cmd);
1778
	 */
Line -... Line 1779...
-
 
1779
	void (*output_poll_changed)(struct drm_device *dev);
-
 
1780
 
-
 
1781
	/**
-
 
1782
	 * @atomic_check:
-
 
1783
	 *
-
 
1784
	 * This is the only hook to validate an atomic modeset update. This
-
 
1785
	 * function must reject any modeset and state changes which the hardware
-
 
1786
	 * or driver doesn't support. This includes but is of course not limited
-
 
1787
	 * to:
-
 
1788
	 *
-
 
1789
	 *  - Checking that the modes, framebuffers, scaling and placement
-
 
1790
	 *    requirements and so on are within the limits of the hardware.
-
 
1791
	 *
-
 
1792
	 *  - Checking that any hidden shared resources are not oversubscribed.
-
 
1793
	 *    This can be shared PLLs, shared lanes, overall memory bandwidth,
-
 
1794
	 *    display fifo space (where shared between planes or maybe even
-
 
1795
	 *    CRTCs).
-
 
1796
	 *
-
 
1797
	 *  - Checking that virtualized resources exported to userspace are not
-
 
1798
	 *    oversubscribed. For various reasons it can make sense to expose
-
 
1799
	 *    more planes, crtcs or encoders than which are physically there. One
-
 
1800
	 *    example is dual-pipe operations (which generally should be hidden
-
 
1801
	 *    from userspace if when lockstepped in hardware, exposed otherwise),
-
 
1802
	 *    where a plane might need 1 hardware plane (if it's just on one
-
 
1803
	 *    pipe), 2 hardware planes (when it spans both pipes) or maybe even
-
 
1804
	 *    shared a hardware plane with a 2nd plane (if there's a compatible
-
 
1805
	 *    plane requested on the area handled by the other pipe).
-
 
1806
	 *
-
 
1807
	 *  - Check that any transitional state is possible and that if
-
 
1808
	 *    requested, the update can indeed be done in the vblank period
-
 
1809
	 *    without temporarily disabling some functions.
-
 
1810
	 *
-
 
1811
	 *  - Check any other constraints the driver or hardware might have.
-
 
1812
	 *
-
 
1813
	 *  - This callback also needs to correctly fill out the &drm_crtc_state
-
 
1814
	 *    in this update to make sure that drm_atomic_crtc_needs_modeset()
-
 
1815
	 *    reflects the nature of the possible update and returns true if and
-
 
1816
	 *    only if the update cannot be applied without tearing within one
-
 
1817
	 *    vblank on that CRTC. The core uses that information to reject
-
 
1818
	 *    updates which require a full modeset (i.e. blanking the screen, or
-
 
1819
	 *    at least pausing updates for a substantial amount of time) if
-
 
1820
	 *    userspace has disallowed that in its request.
-
 
1821
	 *
-
 
1822
	 *  - The driver also does not need to repeat basic input validation
-
 
1823
	 *    like done for the corresponding legacy entry points. The core does
-
 
1824
	 *    that before calling this hook.
-
 
1825
	 *
-
 
1826
	 * See the documentation of @atomic_commit for an exhaustive list of
-
 
1827
	 * error conditions which don't have to be checked at the
-
 
1828
	 * ->atomic_check() stage?
-
 
1829
	 *
-
 
1830
	 * See the documentation for struct &drm_atomic_state for how exactly
-
 
1831
	 * an atomic modeset update is described.
-
 
1832
	 *
-
 
1833
	 * Drivers using the atomic helpers can implement this hook using
-
 
1834
	 * drm_atomic_helper_check(), or one of the exported sub-functions of
-
 
1835
	 * it.
-
 
1836
	 *
-
 
1837
	 * RETURNS:
-
 
1838
	 *
-
 
1839
	 * 0 on success or one of the below negative error codes:
-
 
1840
	 *
-
 
1841
	 *  - -EINVAL, if any of the above constraints are violated.
-
 
1842
	 *
-
 
1843
	 *  - -EDEADLK, when returned from an attempt to acquire an additional
-
 
1844
	 *    &drm_modeset_lock through drm_modeset_lock().
-
 
1845
	 *
-
 
1846
	 *  - -ENOMEM, if allocating additional state sub-structures failed due
-
 
1847
	 *    to lack of memory.
-
 
1848
	 *
-
 
1849
	 *  - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
-
 
1850
	 *    This can either be due to a pending signal, or because the driver
-
 
1851
	 *    needs to completely bail out to recover from an exceptional
-
 
1852
	 *    situation like a GPU hang. From a userspace point all errors are
996
	void (*output_poll_changed)(struct drm_device *dev);
1853
	 *    treated equally.
997
 
1854
	 */
-
 
1855
	int (*atomic_check)(struct drm_device *dev,
-
 
1856
			    struct drm_atomic_state *state);
-
 
1857
 
-
 
1858
	/**
-
 
1859
	 * @atomic_commit:
-
 
1860
	 *
-
 
1861
	 * This is the only hook to commit an atomic modeset update. The core
-
 
1862
	 * guarantees that @atomic_check has been called successfully before
-
 
1863
	 * calling this function, and that nothing has been changed in the
-
 
1864
	 * interim.
-
 
1865
	 *
-
 
1866
	 * See the documentation for struct &drm_atomic_state for how exactly
-
 
1867
	 * an atomic modeset update is described.
-
 
1868
	 *
-
 
1869
	 * Drivers using the atomic helpers can implement this hook using
-
 
1870
	 * drm_atomic_helper_commit(), or one of the exported sub-functions of
-
 
1871
	 * it.
-
 
1872
	 *
-
 
1873
	 * Asynchronous commits (as indicated with the async parameter) must
-
 
1874
	 * do any preparatory work which might result in an unsuccessful commit
-
 
1875
	 * in the context of this callback. The only exceptions are hardware
-
 
1876
	 * errors resulting in -EIO. But even in that case the driver must
-
 
1877
	 * ensure that the display pipe is at least running, to avoid
-
 
1878
	 * compositors crashing when pageflips don't work. Anything else,
-
 
1879
	 * specifically committing the update to the hardware, should be done
-
 
1880
	 * without blocking the caller. For updates which do not require a
-
 
1881
	 * modeset this must be guaranteed.
-
 
1882
	 *
-
 
1883
	 * The driver must wait for any pending rendering to the new
-
 
1884
	 * framebuffers to complete before executing the flip. It should also
-
 
1885
	 * wait for any pending rendering from other drivers if the underlying
-
 
1886
	 * buffer is a shared dma-buf. Asynchronous commits must not wait for
-
 
1887
	 * rendering in the context of this callback.
-
 
1888
	 *
-
 
1889
	 * An application can request to be notified when the atomic commit has
-
 
1890
	 * completed. These events are per-CRTC and can be distinguished by the
-
 
1891
	 * CRTC index supplied in &drm_event to userspace.
-
 
1892
	 *
-
 
1893
	 * The drm core will supply a struct &drm_event in the event
-
 
1894
	 * member of each CRTC's &drm_crtc_state structure. This can be handled by the
-
 
1895
	 * drm_crtc_send_vblank_event() function, which the driver should call on
-
 
1896
	 * the provided event upon completion of the atomic commit. Note that if
-
 
1897
	 * the driver supports vblank signalling and timestamping the vblank
-
 
1898
	 * counters and timestamps must agree with the ones returned from page
-
 
1899
	 * flip events. With the current vblank helper infrastructure this can
-
 
1900
	 * be achieved by holding a vblank reference while the page flip is
-
 
1901
	 * pending, acquired through drm_crtc_vblank_get() and released with
-
 
1902
	 * drm_crtc_vblank_put(). Drivers are free to implement their own vblank
-
 
1903
	 * counter and timestamp tracking though, e.g. if they have accurate
-
 
1904
	 * timestamp registers in hardware.
-
 
1905
	 *
-
 
1906
	 * NOTE:
-
 
1907
	 *
-
 
1908
	 * Drivers are not allowed to shut down any display pipe successfully
-
 
1909
	 * enabled through an atomic commit on their own. Doing so can result in
-
 
1910
	 * compositors crashing if a page flip is suddenly rejected because the
-
 
1911
	 * pipe is off.
-
 
1912
	 *
-
 
1913
	 * RETURNS:
-
 
1914
	 *
-
 
1915
	 * 0 on success or one of the below negative error codes:
-
 
1916
	 *
-
 
1917
	 *  - -EBUSY, if an asynchronous updated is requested and there is
-
 
1918
	 *    an earlier updated pending. Drivers are allowed to support a queue
-
 
1919
	 *    of outstanding updates, but currently no driver supports that.
-
 
1920
	 *    Note that drivers must wait for preceding updates to complete if a
-
 
1921
	 *    synchronous update is requested, they are not allowed to fail the
-
 
1922
	 *    commit in that case.
-
 
1923
	 *
-
 
1924
	 *  - -ENOMEM, if the driver failed to allocate memory. Specifically
-
 
1925
	 *    this can happen when trying to pin framebuffers, which must only
-
 
1926
	 *    be done when committing the state.
-
 
1927
	 *
-
 
1928
	 *  - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate
-
 
1929
	 *    that the driver has run out of vram, iommu space or similar GPU
-
 
1930
	 *    address space needed for framebuffer.
-
 
1931
	 *
-
 
1932
	 *  - -EIO, if the hardware completely died.
-
 
1933
	 *
-
 
1934
	 *  - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted.
-
 
1935
	 *    This can either be due to a pending signal, or because the driver
-
 
1936
	 *    needs to completely bail out to recover from an exceptional
-
 
1937
	 *    situation like a GPU hang. From a userspace point of view all errors are
-
 
1938
	 *    treated equally.
-
 
1939
	 *
-
 
1940
	 * This list is exhaustive. Specifically this hook is not allowed to
-
 
1941
	 * return -EINVAL (any invalid requests should be caught in
-
 
1942
	 * @atomic_check) or -EDEADLK (this function must not acquire
998
	int (*atomic_check)(struct drm_device *dev,
1943
	 * additional modeset locks).
999
			    struct drm_atomic_state *a);
1944
	 */
1000
	int (*atomic_commit)(struct drm_device *dev,
1945
	int (*atomic_commit)(struct drm_device *dev,
-
 
1946
			     struct drm_atomic_state *state,
-
 
1947
			     bool async);
-
 
1948
 
-
 
1949
	/**
-
 
1950
	 * @atomic_state_alloc:
-
 
1951
	 *
-
 
1952
	 * This optional hook can be used by drivers that want to subclass struct
-
 
1953
	 * &drm_atomic_state to be able to track their own driver-private global
-
 
1954
	 * state easily. If this hook is implemented, drivers must also
-
 
1955
	 * implement @atomic_state_clear and @atomic_state_free.
-
 
1956
	 *
-
 
1957
	 * RETURNS:
-
 
1958
	 *
1001
			     struct drm_atomic_state *a,
1959
	 * A new &drm_atomic_state on success or NULL on failure.
-
 
1960
	 */
-
 
1961
	struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev);
-
 
1962
 
-
 
1963
	/**
-
 
1964
	 * @atomic_state_clear:
-
 
1965
	 *
-
 
1966
	 * This hook must clear any driver private state duplicated into the
-
 
1967
	 * passed-in &drm_atomic_state. This hook is called when the caller
-
 
1968
	 * encountered a &drm_modeset_lock deadlock and needs to drop all
-
 
1969
	 * already acquired locks as part of the deadlock avoidance dance
-
 
1970
	 * implemented in drm_modeset_lock_backoff().
-
 
1971
	 *
-
 
1972
	 * Any duplicated state must be invalidated since a concurrent atomic
-
 
1973
	 * update might change it, and the drm atomic interfaces always apply
-
 
1974
	 * updates as relative changes to the current state.
-
 
1975
	 *
-
 
1976
	 * Drivers that implement this must call drm_atomic_state_default_clear()
1002
			     bool async);
1977
	 * to clear common state.
-
 
1978
	 */
-
 
1979
	void (*atomic_state_clear)(struct drm_atomic_state *state);
-
 
1980
 
-
 
1981
	/**
-
 
1982
	 * @atomic_state_free:
-
 
1983
	 *
-
 
1984
	 * This hook needs driver private resources and the &drm_atomic_state
-
 
1985
	 * itself. Note that the core first calls drm_atomic_state_clear() to
-
 
1986
	 * avoid code duplicate between the clear and free hooks.
-
 
1987
	 *
-
 
1988
	 * Drivers that implement this must call drm_atomic_state_default_free()
1003
	struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev);
1989
	 * to release common resources.
1004
	void (*atomic_state_clear)(struct drm_atomic_state *state);
1990
	 */
Line 1005... Line 1991...
1005
	void (*atomic_state_free)(struct drm_atomic_state *state);
1991
	void (*atomic_state_free)(struct drm_atomic_state *state);
1006
};
1992
};
1007
 
1993
 
1008
/**
1994
/**
1009
 * struct drm_mode_config - Mode configuration control structure
1995
 * struct drm_mode_config - Mode configuration control structure
1010
 * @mutex: mutex protecting KMS related lists and structures
1996
 * @mutex: mutex protecting KMS related lists and structures
1011
 * @connection_mutex: ww mutex protecting connector state and routing
1997
 * @connection_mutex: ww mutex protecting connector state and routing
1012
 * @acquire_ctx: global implicit acquire context used by atomic drivers for
1998
 * @acquire_ctx: global implicit acquire context used by atomic drivers for
1013
 * 	legacy ioctls
1999
 * 	legacy IOCTLs
1014
 * @idr_mutex: mutex for KMS ID allocation and management
2000
 * @idr_mutex: mutex for KMS ID allocation and management
1015
 * @crtc_idr: main KMS ID tracking object
2001
 * @crtc_idr: main KMS ID tracking object
Line 1060... Line 2046...
1060
	struct mutex fb_lock; /* proctects global and per-file fb lists */
2046
	struct mutex fb_lock; /* proctects global and per-file fb lists */
1061
	int num_fb;
2047
	int num_fb;
1062
	struct list_head fb_list;
2048
	struct list_head fb_list;
Line 1063... Line 2049...
1063
 
2049
 
-
 
2050
	int num_connector;
1064
	int num_connector;
2051
	struct ida connector_ida;
1065
	struct list_head connector_list;
2052
	struct list_head connector_list;
1066
	int num_encoder;
2053
	int num_encoder;
Line 1067... Line 2054...
1067
	struct list_head encoder_list;
2054
	struct list_head encoder_list;
Line 1164... Line 2151...
1164
 *
2151
 *
1165
 * Iterate over all planes specified by bitmask.
2152
 * Iterate over all planes specified by bitmask.
1166
 */
2153
 */
1167
#define drm_for_each_plane_mask(plane, dev, plane_mask) \
2154
#define drm_for_each_plane_mask(plane, dev, plane_mask) \
1168
	list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
2155
	list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
1169
		if ((plane_mask) & (1 << drm_plane_index(plane)))
2156
		for_each_if ((plane_mask) & (1 << drm_plane_index(plane)))
Line 1170... Line 2157...
1170
 
2157
 
1171
 
2158
 
1172
#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
2159
#define obj_to_crtc(x) container_of(x, struct drm_crtc, base)
Line 1181... Line 2168...
1181
struct drm_prop_enum_list {
2168
struct drm_prop_enum_list {
1182
	int type;
2169
	int type;
1183
	char *name;
2170
	char *name;
1184
};
2171
};
Line -... Line 2172...
-
 
2172
 
1185
 
2173
extern __printf(6, 7)
1186
extern int drm_crtc_init_with_planes(struct drm_device *dev,
2174
int drm_crtc_init_with_planes(struct drm_device *dev,
1187
				     struct drm_crtc *crtc,
2175
				     struct drm_crtc *crtc,
1188
				     struct drm_plane *primary,
2176
				     struct drm_plane *primary,
1189
				     struct drm_plane *cursor,
2177
				     struct drm_plane *cursor,
-
 
2178
			      const struct drm_crtc_funcs *funcs,
1190
				     const struct drm_crtc_funcs *funcs);
2179
			      const char *name, ...);
1191
extern void drm_crtc_cleanup(struct drm_crtc *crtc);
2180
extern void drm_crtc_cleanup(struct drm_crtc *crtc);
Line 1192... Line 2181...
1192
extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
2181
extern unsigned int drm_crtc_index(struct drm_crtc *crtc);
1193
 
2182
 
Line 1211... Line 2200...
1211
			      int connector_type);
2200
			      int connector_type);
1212
int drm_connector_register(struct drm_connector *connector);
2201
int drm_connector_register(struct drm_connector *connector);
1213
void drm_connector_unregister(struct drm_connector *connector);
2202
void drm_connector_unregister(struct drm_connector *connector);
Line 1214... Line 2203...
1214
 
2203
 
1215
extern void drm_connector_cleanup(struct drm_connector *connector);
2204
extern void drm_connector_cleanup(struct drm_connector *connector);
-
 
2205
static inline unsigned drm_connector_index(struct drm_connector *connector)
-
 
2206
{
-
 
2207
	return connector->connector_id;
-
 
2208
}
1216
extern unsigned int drm_connector_index(struct drm_connector *connector);
2209
 
1217
/* helper to unplug all connectors from sysfs for device */
2210
/* helper to unplug all connectors from sysfs for device */
Line 1218... Line 2211...
1218
extern void drm_connector_unplug_all(struct drm_device *dev);
2211
extern void drm_connector_unplug_all(struct drm_device *dev);
1219
 
2212
 
Line 1231... Line 2224...
1231
			struct drm_display_mode *mode,
2224
			struct drm_display_mode *mode,
1232
			struct drm_display_mode *adjusted_mode);
2225
			struct drm_display_mode *adjusted_mode);
1233
void drm_bridge_pre_enable(struct drm_bridge *bridge);
2226
void drm_bridge_pre_enable(struct drm_bridge *bridge);
1234
void drm_bridge_enable(struct drm_bridge *bridge);
2227
void drm_bridge_enable(struct drm_bridge *bridge);
Line -... Line 2228...
-
 
2228
 
1235
 
2229
extern __printf(5, 6)
1236
extern int drm_encoder_init(struct drm_device *dev,
2230
int drm_encoder_init(struct drm_device *dev,
1237
			    struct drm_encoder *encoder,
2231
			    struct drm_encoder *encoder,
1238
			    const struct drm_encoder_funcs *funcs,
2232
			    const struct drm_encoder_funcs *funcs,
Line 1239... Line 2233...
1239
			    int encoder_type);
2233
		     int encoder_type, const char *name, ...);
1240
 
2234
 
1241
/**
2235
/**
1242
 * drm_encoder_crtc_ok - can a given crtc drive a given encoder?
2236
 * drm_encoder_crtc_ok - can a given crtc drive a given encoder?
Line 1249... Line 2243...
1249
				       struct drm_crtc *crtc)
2243
				       struct drm_crtc *crtc)
1250
{
2244
{
1251
	return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
2245
	return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
1252
}
2246
}
Line -... Line 2247...
-
 
2247
 
1253
 
2248
extern __printf(8, 9)
1254
extern int drm_universal_plane_init(struct drm_device *dev,
2249
int drm_universal_plane_init(struct drm_device *dev,
1255
				    struct drm_plane *plane,
2250
				    struct drm_plane *plane,
1256
				    unsigned long possible_crtcs,
2251
				    unsigned long possible_crtcs,
1257
				    const struct drm_plane_funcs *funcs,
2252
				    const struct drm_plane_funcs *funcs,
1258
				    const uint32_t *formats,
2253
				    const uint32_t *formats,
1259
				    unsigned int format_count,
2254
				    unsigned int format_count,
-
 
2255
			     enum drm_plane_type type,
1260
				    enum drm_plane_type type);
2256
			     const char *name, ...);
1261
extern int drm_plane_init(struct drm_device *dev,
2257
extern int drm_plane_init(struct drm_device *dev,
1262
			  struct drm_plane *plane,
2258
			  struct drm_plane *plane,
1263
			  unsigned long possible_crtcs,
2259
			  unsigned long possible_crtcs,
1264
			  const struct drm_plane_funcs *funcs,
2260
			  const struct drm_plane_funcs *funcs,
Line 1541... Line 2537...
1541
}
2537
}
Line 1542... Line 2538...
1542
 
2538
 
1543
/* Plane list iterator for legacy (overlay only) planes. */
2539
/* Plane list iterator for legacy (overlay only) planes. */
1544
#define drm_for_each_legacy_plane(plane, dev) \
2540
#define drm_for_each_legacy_plane(plane, dev) \
1545
	list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
2541
	list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \
Line 1546... Line 2542...
1546
		if (plane->type == DRM_PLANE_TYPE_OVERLAY)
2542
		for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY)
1547
 
2543
 
Line 1548... Line 2544...
1548
#define drm_for_each_plane(plane, dev) \
2544
#define drm_for_each_plane(plane, dev) \