aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drm_crtc.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/drm/drm_crtc.h')
-rw-r--r--include/drm/drm_crtc.h212
1 files changed, 198 insertions, 14 deletions
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 802079809282..63e4fce67288 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -29,9 +29,10 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/idr.h> 31#include <linux/idr.h>
32
33#include <linux/fb.h> 32#include <linux/fb.h>
34 33
34#include <drm/drm_fourcc.h>
35
35struct drm_device; 36struct drm_device;
36struct drm_mode_set; 37struct drm_mode_set;
37struct drm_framebuffer; 38struct drm_framebuffer;
@@ -44,6 +45,7 @@ struct drm_framebuffer;
44#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0 45#define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0
45#define DRM_MODE_OBJECT_FB 0xfbfbfbfb 46#define DRM_MODE_OBJECT_FB 0xfbfbfbfb
46#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb 47#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb
48#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee
47 49
48struct drm_mode_object { 50struct drm_mode_object {
49 uint32_t id; 51 uint32_t id;
@@ -118,7 +120,6 @@ struct drm_display_mode {
118 120
119 char name[DRM_DISPLAY_MODE_LEN]; 121 char name[DRM_DISPLAY_MODE_LEN];
120 122
121 int connector_count;
122 enum drm_mode_status status; 123 enum drm_mode_status status;
123 int type; 124 int type;
124 125
@@ -238,13 +239,15 @@ struct drm_framebuffer {
238 struct list_head head; 239 struct list_head head;
239 struct drm_mode_object base; 240 struct drm_mode_object base;
240 const struct drm_framebuffer_funcs *funcs; 241 const struct drm_framebuffer_funcs *funcs;
241 unsigned int pitch; 242 unsigned int pitches[4];
243 unsigned int offsets[4];
242 unsigned int width; 244 unsigned int width;
243 unsigned int height; 245 unsigned int height;
244 /* depth can be 15 or 16 */ 246 /* depth can be 15 or 16 */
245 unsigned int depth; 247 unsigned int depth;
246 int bits_per_pixel; 248 int bits_per_pixel;
247 int flags; 249 int flags;
250 uint32_t pixel_format; /* fourcc format */
248 struct list_head filp_head; 251 struct list_head filp_head;
249 /* if you are using the helper */ 252 /* if you are using the helper */
250 void *helper_private; 253 void *helper_private;
@@ -278,6 +281,7 @@ struct drm_crtc;
278struct drm_connector; 281struct drm_connector;
279struct drm_encoder; 282struct drm_encoder;
280struct drm_pending_vblank_event; 283struct drm_pending_vblank_event;
284struct drm_plane;
281 285
282/** 286/**
283 * drm_crtc_funcs - control CRTCs for a given device 287 * drm_crtc_funcs - control CRTCs for a given device
@@ -341,10 +345,21 @@ struct drm_crtc_funcs {
341 345
342/** 346/**
343 * drm_crtc - central CRTC control structure 347 * drm_crtc - central CRTC control structure
348 * @dev: parent DRM device
349 * @head: list management
350 * @base: base KMS object for ID tracking etc.
344 * @enabled: is this CRTC enabled? 351 * @enabled: is this CRTC enabled?
352 * @mode: current mode timings
353 * @hwmode: mode timings as programmed to hw regs
345 * @x: x position on screen 354 * @x: x position on screen
346 * @y: y position on screen 355 * @y: y position on screen
347 * @funcs: CRTC control functions 356 * @funcs: CRTC control functions
357 * @gamma_size: size of gamma ramp
358 * @gamma_store: gamma ramp values
359 * @framedur_ns: precise frame timing
360 * @framedur_ns: precise line timing
361 * @pixeldur_ns: precise pixel timing
362 * @helper_private: mid-layer private data
348 * 363 *
349 * Each CRTC may have one or more connectors associated with it. This structure 364 * Each CRTC may have one or more connectors associated with it. This structure
350 * allows the CRTC to be controlled. 365 * allows the CRTC to be controlled.
@@ -423,6 +438,13 @@ struct drm_connector_funcs {
423 void (*force)(struct drm_connector *connector); 438 void (*force)(struct drm_connector *connector);
424}; 439};
425 440
441/**
442 * drm_encoder_funcs - encoder controls
443 * @reset: reset state (e.g. at init or resume time)
444 * @destroy: cleanup and free associated data
445 *
446 * Encoders sit between CRTCs and connectors.
447 */
426struct drm_encoder_funcs { 448struct drm_encoder_funcs {
427 void (*reset)(struct drm_encoder *encoder); 449 void (*reset)(struct drm_encoder *encoder);
428 void (*destroy)(struct drm_encoder *encoder); 450 void (*destroy)(struct drm_encoder *encoder);
@@ -435,6 +457,18 @@ struct drm_encoder_funcs {
435 457
436/** 458/**
437 * drm_encoder - central DRM encoder structure 459 * drm_encoder - central DRM encoder structure
460 * @dev: parent DRM device
461 * @head: list management
462 * @base: base KMS object
463 * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h
464 * @possible_crtcs: bitmask of potential CRTC bindings
465 * @possible_clones: bitmask of potential sibling encoders for cloning
466 * @crtc: currently bound CRTC
467 * @funcs: control functions
468 * @helper_private: mid-layer private data
469 *
470 * CRTCs drive pixels to encoders, which convert them into signals
471 * appropriate for a given connector or set of connectors.
438 */ 472 */
439struct drm_encoder { 473struct drm_encoder {
440 struct drm_device *dev; 474 struct drm_device *dev;
@@ -470,14 +504,37 @@ enum drm_connector_force {
470 504
471/** 505/**
472 * drm_connector - central DRM connector control structure 506 * drm_connector - central DRM connector control structure
473 * @crtc: CRTC this connector is currently connected to, NULL if none 507 * @dev: parent DRM device
508 * @kdev: kernel device for sysfs attributes
509 * @attr: sysfs attributes
510 * @head: list management
511 * @base: base KMS object
512 * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
513 * @connector_type_id: index into connector type enum
474 * @interlace_allowed: can this connector handle interlaced modes? 514 * @interlace_allowed: can this connector handle interlaced modes?
475 * @doublescan_allowed: can this connector handle doublescan? 515 * @doublescan_allowed: can this connector handle doublescan?
476 * @available_modes: modes available on this connector (from get_modes() + user) 516 * @modes: modes available on this connector (from fill_modes() + user)
477 * @initial_x: initial x position for this connector 517 * @status: one of the drm_connector_status enums (connected, not, or unknown)
478 * @initial_y: initial y position for this connector 518 * @probed_modes: list of modes derived directly from the display
479 * @status: connector connected? 519 * @display_info: information about attached display (e.g. from EDID)
480 * @funcs: connector control functions 520 * @funcs: connector control functions
521 * @user_modes: user added mode list
522 * @edid_blob_ptr: DRM property containing EDID if present
523 * @property_ids: property tracking for this connector
524 * @property_values: value pointers or data for properties
525 * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling
526 * @dpms: current dpms state
527 * @helper_private: mid-layer private data
528 * @force: a %DRM_FORCE_<foo> state for forced mode sets
529 * @encoder_ids: valid encoders for this connector
530 * @encoder: encoder driving this connector, if any
531 * @eld: EDID-like data, if present
532 * @dvi_dual: dual link DVI, if found
533 * @max_tmds_clock: max clock rate, if found
534 * @latency_present: AV delay info from ELD, if found
535 * @video_latency: video latency info from ELD, if found
536 * @audio_latency: audio latency info from ELD, if found
537 * @null_edid_counter: track sinks that give us all zeros for the EDID
481 * 538 *
482 * Each connector may be connected to one or more CRTCs, or may be clonable by 539 * Each connector may be connected to one or more CRTCs, or may be clonable by
483 * another connector if they can share a CRTC. Each connector also has a specific 540 * another connector if they can share a CRTC. Each connector also has a specific
@@ -498,7 +555,6 @@ struct drm_connector {
498 bool doublescan_allowed; 555 bool doublescan_allowed;
499 struct list_head modes; /* list of modes on this connector */ 556 struct list_head modes; /* list of modes on this connector */
500 557
501 int initial_x, initial_y;
502 enum drm_connector_status status; 558 enum drm_connector_status status;
503 559
504 /* these are modes added by probing with DDC or the BIOS */ 560 /* these are modes added by probing with DDC or the BIOS */
@@ -522,7 +578,6 @@ struct drm_connector {
522 /* forced on connector */ 578 /* forced on connector */
523 enum drm_connector_force force; 579 enum drm_connector_force force;
524 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; 580 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
525 uint32_t force_encoder_id;
526 struct drm_encoder *encoder; /* currently active encoder */ 581 struct drm_encoder *encoder; /* currently active encoder */
527 582
528 /* EDID bits */ 583 /* EDID bits */
@@ -536,7 +591,71 @@ struct drm_connector {
536}; 591};
537 592
538/** 593/**
539 * struct drm_mode_set 594 * drm_plane_funcs - driver plane control functions
595 * @update_plane: update the plane configuration
596 * @disable_plane: shut down the plane
597 * @destroy: clean up plane resources
598 */
599struct drm_plane_funcs {
600 int (*update_plane)(struct drm_plane *plane,
601 struct drm_crtc *crtc, struct drm_framebuffer *fb,
602 int crtc_x, int crtc_y,
603 unsigned int crtc_w, unsigned int crtc_h,
604 uint32_t src_x, uint32_t src_y,
605 uint32_t src_w, uint32_t src_h);
606 int (*disable_plane)(struct drm_plane *plane);
607 void (*destroy)(struct drm_plane *plane);
608};
609
610/**
611 * drm_plane - central DRM plane control structure
612 * @dev: DRM device this plane belongs to
613 * @head: for list management
614 * @base: base mode object
615 * @possible_crtcs: pipes this plane can be bound to
616 * @format_types: array of formats supported by this plane
617 * @format_count: number of formats supported
618 * @crtc: currently bound CRTC
619 * @fb: currently bound fb
620 * @gamma_size: size of gamma table
621 * @gamma_store: gamma correction table
622 * @enabled: enabled flag
623 * @funcs: helper functions
624 * @helper_private: storage for drver layer
625 */
626struct drm_plane {
627 struct drm_device *dev;
628 struct list_head head;
629
630 struct drm_mode_object base;
631
632 uint32_t possible_crtcs;
633 uint32_t *format_types;
634 uint32_t format_count;
635
636 struct drm_crtc *crtc;
637 struct drm_framebuffer *fb;
638
639 /* CRTC gamma size for reporting to userspace */
640 uint32_t gamma_size;
641 uint16_t *gamma_store;
642
643 bool enabled;
644
645 const struct drm_plane_funcs *funcs;
646 void *helper_private;
647};
648
649/**
650 * drm_mode_set - new values for a CRTC config change
651 * @head: list management
652 * @fb: framebuffer to use for new config
653 * @crtc: CRTC whose configuration we're about to change
654 * @mode: mode timings to use
655 * @x: position of this CRTC relative to @fb
656 * @y: position of this CRTC relative to @fb
657 * @connectors: array of connectors to drive with this CRTC if possible
658 * @num_connectors: size of @connectors array
540 * 659 *
541 * Represents a single crtc the connectors that it drives with what mode 660 * Represents a single crtc the connectors that it drives with what mode
542 * and from which framebuffer it scans out from. 661 * and from which framebuffer it scans out from.
@@ -558,13 +677,33 @@ struct drm_mode_set {
558}; 677};
559 678
560/** 679/**
561 * struct drm_mode_config_funcs - configure CRTCs for a given screen layout 680 * struct drm_mode_config_funcs - basic driver provided mode setting functions
681 * @fb_create: create a new framebuffer object
682 * @output_poll_changed: function to handle output configuration changes
683 *
684 * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that
685 * involve drivers.
562 */ 686 */
563struct drm_mode_config_funcs { 687struct drm_mode_config_funcs {
564 struct drm_framebuffer *(*fb_create)(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd *mode_cmd); 688 struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
689 struct drm_file *file_priv,
690 struct drm_mode_fb_cmd2 *mode_cmd);
565 void (*output_poll_changed)(struct drm_device *dev); 691 void (*output_poll_changed)(struct drm_device *dev);
566}; 692};
567 693
694/**
695 * drm_mode_group - group of mode setting resources for potential sub-grouping
696 * @num_crtcs: CRTC count
697 * @num_encoders: encoder count
698 * @num_connectors: connector count
699 * @id_list: list of KMS object IDs in this group
700 *
701 * Currently this simply tracks the global mode setting state. But in the
702 * future it could allow groups of objects to be set aside into independent
703 * control groups for use by different user level processes (e.g. two X servers
704 * running simultaneously on different heads, each with their own mode
705 * configuration and freedom of mode setting).
706 */
568struct drm_mode_group { 707struct drm_mode_group {
569 uint32_t num_crtcs; 708 uint32_t num_crtcs;
570 uint32_t num_encoders; 709 uint32_t num_encoders;
@@ -576,7 +715,30 @@ struct drm_mode_group {
576 715
577/** 716/**
578 * drm_mode_config - Mode configuration control structure 717 * drm_mode_config - Mode configuration control structure
718 * @mutex: mutex protecting KMS related lists and structures
719 * @idr_mutex: mutex for KMS ID allocation and management
720 * @crtc_idr: main KMS ID tracking object
721 * @num_fb: number of fbs available
722 * @fb_list: list of framebuffers available
723 * @num_connector: number of connectors on this device
724 * @connector_list: list of connector objects
725 * @num_encoder: number of encoders on this device
726 * @encoder_list: list of encoder objects
727 * @num_crtc: number of CRTCs on this device
728 * @crtc_list: list of CRTC objects
729 * @min_width: minimum pixel width on this device
730 * @min_height: minimum pixel height on this device
731 * @max_width: maximum pixel width on this device
732 * @max_height: maximum pixel height on this device
733 * @funcs: core driver provided mode setting functions
734 * @fb_base: base address of the framebuffer
735 * @poll_enabled: track polling status for this device
736 * @output_poll_work: delayed work for polling in process context
737 * @*_property: core property tracking
579 * 738 *
739 * Core mode resource tracking structure. All CRTC, encoders, and connectors
740 * enumerated by the driver are added here, as are global properties. Some
741 * global restrictions are also here, e.g. dimension restrictions.
580 */ 742 */
581struct drm_mode_config { 743struct drm_mode_config {
582 struct mutex mutex; /* protects configuration (mode lists etc.) */ 744 struct mutex mutex; /* protects configuration (mode lists etc.) */
@@ -589,6 +751,8 @@ struct drm_mode_config {
589 struct list_head connector_list; 751 struct list_head connector_list;
590 int num_encoder; 752 int num_encoder;
591 struct list_head encoder_list; 753 struct list_head encoder_list;
754 int num_plane;
755 struct list_head plane_list;
592 756
593 int num_crtc; 757 int num_crtc;
594 struct list_head crtc_list; 758 struct list_head crtc_list;
@@ -641,6 +805,7 @@ struct drm_mode_config {
641#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) 805#define obj_to_fb(x) container_of(x, struct drm_framebuffer, base)
642#define obj_to_property(x) container_of(x, struct drm_property, base) 806#define obj_to_property(x) container_of(x, struct drm_property, base)
643#define obj_to_blob(x) container_of(x, struct drm_property_blob, base) 807#define obj_to_blob(x) container_of(x, struct drm_property_blob, base)
808#define obj_to_plane(x) container_of(x, struct drm_plane, base)
644 809
645 810
646extern void drm_crtc_init(struct drm_device *dev, 811extern void drm_crtc_init(struct drm_device *dev,
@@ -660,6 +825,14 @@ extern void drm_encoder_init(struct drm_device *dev,
660 const struct drm_encoder_funcs *funcs, 825 const struct drm_encoder_funcs *funcs,
661 int encoder_type); 826 int encoder_type);
662 827
828extern int drm_plane_init(struct drm_device *dev,
829 struct drm_plane *plane,
830 unsigned long possible_crtcs,
831 const struct drm_plane_funcs *funcs,
832 const uint32_t *formats, uint32_t format_count,
833 bool priv);
834extern void drm_plane_cleanup(struct drm_plane *plane);
835
663extern void drm_encoder_cleanup(struct drm_encoder *encoder); 836extern void drm_encoder_cleanup(struct drm_encoder *encoder);
664 837
665extern char *drm_get_connector_name(struct drm_connector *connector); 838extern char *drm_get_connector_name(struct drm_connector *connector);
@@ -753,17 +926,25 @@ extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev,
753/* IOCTLs */ 926/* IOCTLs */
754extern int drm_mode_getresources(struct drm_device *dev, 927extern int drm_mode_getresources(struct drm_device *dev,
755 void *data, struct drm_file *file_priv); 928 void *data, struct drm_file *file_priv);
756 929extern int drm_mode_getplane_res(struct drm_device *dev, void *data,
930 struct drm_file *file_priv);
757extern int drm_mode_getcrtc(struct drm_device *dev, 931extern int drm_mode_getcrtc(struct drm_device *dev,
758 void *data, struct drm_file *file_priv); 932 void *data, struct drm_file *file_priv);
759extern int drm_mode_getconnector(struct drm_device *dev, 933extern int drm_mode_getconnector(struct drm_device *dev,
760 void *data, struct drm_file *file_priv); 934 void *data, struct drm_file *file_priv);
761extern int drm_mode_setcrtc(struct drm_device *dev, 935extern int drm_mode_setcrtc(struct drm_device *dev,
762 void *data, struct drm_file *file_priv); 936 void *data, struct drm_file *file_priv);
937extern int drm_mode_getplane(struct drm_device *dev,
938 void *data, struct drm_file *file_priv);
939extern int drm_mode_setplane(struct drm_device *dev,
940 void *data, struct drm_file *file_priv);
763extern int drm_mode_cursor_ioctl(struct drm_device *dev, 941extern int drm_mode_cursor_ioctl(struct drm_device *dev,
764 void *data, struct drm_file *file_priv); 942 void *data, struct drm_file *file_priv);
765extern int drm_mode_addfb(struct drm_device *dev, 943extern int drm_mode_addfb(struct drm_device *dev,
766 void *data, struct drm_file *file_priv); 944 void *data, struct drm_file *file_priv);
945extern int drm_mode_addfb2(struct drm_device *dev,
946 void *data, struct drm_file *file_priv);
947extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
767extern int drm_mode_rmfb(struct drm_device *dev, 948extern int drm_mode_rmfb(struct drm_device *dev,
768 void *data, struct drm_file *file_priv); 949 void *data, struct drm_file *file_priv);
769extern int drm_mode_getfb(struct drm_device *dev, 950extern int drm_mode_getfb(struct drm_device *dev,
@@ -824,4 +1005,7 @@ extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
824 void *data, struct drm_file *file_priv); 1005 void *data, struct drm_file *file_priv);
825extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev, 1006extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
826 void *data, struct drm_file *file_priv); 1007 void *data, struct drm_file *file_priv);
1008
1009extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth,
1010 int *bpp);
827#endif /* __DRM_CRTC_H__ */ 1011#endif /* __DRM_CRTC_H__ */