12fa91d15SJani Nikula========================= 22fa91d15SJani NikulaKernel Mode Setting (KMS) 32fa91d15SJani Nikula========================= 42fa91d15SJani Nikula 52fa91d15SJani NikulaDrivers must initialize the mode setting core by calling 62fa91d15SJani Nikula:c:func:`drm_mode_config_init()` on the DRM device. The function 72fa91d15SJani Nikulainitializes the :c:type:`struct drm_device <drm_device>` 82fa91d15SJani Nikulamode_config field and never fails. Once done, mode configuration must 92fa91d15SJani Nikulabe setup by initializing the following fields. 102fa91d15SJani Nikula 112fa91d15SJani Nikula- int min_width, min_height; int max_width, max_height; 122fa91d15SJani Nikula Minimum and maximum width and height of the frame buffers in pixel 132fa91d15SJani Nikula units. 142fa91d15SJani Nikula 152fa91d15SJani Nikula- struct drm_mode_config_funcs \*funcs; 162fa91d15SJani Nikula Mode setting functions. 172fa91d15SJani Nikula 18311b62d9SDaniel VetterKMS Data Structures 19311b62d9SDaniel Vetter=================== 202fa91d15SJani Nikula 21311b62d9SDaniel Vetter.. kernel-doc:: include/drm/drm_crtc.h 222fa91d15SJani Nikula :internal: 232fa91d15SJani Nikula 24311b62d9SDaniel VetterKMS API Functions 25311b62d9SDaniel Vetter================= 26311b62d9SDaniel Vetter 27311b62d9SDaniel Vetter.. kernel-doc:: drivers/gpu/drm/drm_crtc.c 282fa91d15SJani Nikula :export: 292fa91d15SJani Nikula 302fa91d15SJani NikulaAtomic Mode Setting Function Reference 31311b62d9SDaniel Vetter====================================== 322fa91d15SJani Nikula 332fa91d15SJani Nikula.. kernel-doc:: drivers/gpu/drm/drm_atomic.c 342fa91d15SJani Nikula :export: 352fa91d15SJani Nikula 365d070be6SDaniel Vetter.. kernel-doc:: include/drm/drm_atomic.h 372fa91d15SJani Nikula :internal: 382fa91d15SJani Nikula 392fa91d15SJani NikulaFrame Buffer Abstraction 40311b62d9SDaniel Vetter======================== 412fa91d15SJani Nikula 42750fb8c4SDaniel Vetter.. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c 43750fb8c4SDaniel Vetter :doc: overview 442fa91d15SJani Nikula 457520a277SDaniel VetterFrame Buffer Functions Reference 467520a277SDaniel Vetter-------------------------------- 477520a277SDaniel Vetter 487520a277SDaniel Vetter.. kernel-doc:: drivers/gpu/drm/drm_framebuffer.c 497520a277SDaniel Vetter :export: 507520a277SDaniel Vetter 517520a277SDaniel Vetter.. kernel-doc:: include/drm/drm_framebuffer.h 527520a277SDaniel Vetter :internal: 537520a277SDaniel Vetter 542fa91d15SJani NikulaDRM Format Handling 55311b62d9SDaniel Vetter=================== 562fa91d15SJani Nikula 572fa91d15SJani Nikula.. kernel-doc:: drivers/gpu/drm/drm_fourcc.c 582fa91d15SJani Nikula :export: 592fa91d15SJani Nikula 602fa91d15SJani NikulaDumb Buffer Objects 61311b62d9SDaniel Vetter=================== 622fa91d15SJani Nikula 632fa91d15SJani NikulaThe KMS API doesn't standardize backing storage object creation and 642fa91d15SJani Nikulaleaves it to driver-specific ioctls. Furthermore actually creating a 652fa91d15SJani Nikulabuffer object even for GEM-based drivers is done through a 662fa91d15SJani Nikuladriver-specific ioctl - GEM only has a common userspace interface for 672fa91d15SJani Nikulasharing and destroying objects. While not an issue for full-fledged 682fa91d15SJani Nikulagraphics stacks that include device-specific userspace components (in 692fa91d15SJani Nikulalibdrm for instance), this limit makes DRM-based early boot graphics 702fa91d15SJani Nikulaunnecessarily complex. 712fa91d15SJani Nikula 722fa91d15SJani NikulaDumb objects partly alleviate the problem by providing a standard API to 732fa91d15SJani Nikulacreate dumb buffers suitable for scanout, which can then be used to 742fa91d15SJani Nikulacreate KMS frame buffers. 752fa91d15SJani Nikula 762fa91d15SJani NikulaTo support dumb objects drivers must implement the dumb_create, 772fa91d15SJani Nikuladumb_destroy and dumb_map_offset operations. 782fa91d15SJani Nikula 792fa91d15SJani Nikula- int (\*dumb_create)(struct drm_file \*file_priv, struct 802fa91d15SJani Nikula drm_device \*dev, struct drm_mode_create_dumb \*args); 812fa91d15SJani Nikula The dumb_create operation creates a driver object (GEM or TTM 822fa91d15SJani Nikula handle) suitable for scanout based on the width, height and depth 832fa91d15SJani Nikula from the struct :c:type:`struct drm_mode_create_dumb 842fa91d15SJani Nikula <drm_mode_create_dumb>` argument. It fills the argument's 852fa91d15SJani Nikula handle, pitch and size fields with a handle for the newly created 862fa91d15SJani Nikula object and its line pitch and size in bytes. 872fa91d15SJani Nikula 882fa91d15SJani Nikula- int (\*dumb_destroy)(struct drm_file \*file_priv, struct 892fa91d15SJani Nikula drm_device \*dev, uint32_t handle); 902fa91d15SJani Nikula The dumb_destroy operation destroys a dumb object created by 912fa91d15SJani Nikula dumb_create. 922fa91d15SJani Nikula 932fa91d15SJani Nikula- int (\*dumb_map_offset)(struct drm_file \*file_priv, struct 942fa91d15SJani Nikula drm_device \*dev, uint32_t handle, uint64_t \*offset); 952fa91d15SJani Nikula The dumb_map_offset operation associates an mmap fake offset with 962fa91d15SJani Nikula the object given by the handle and returns it. Drivers must use the 972fa91d15SJani Nikula :c:func:`drm_gem_create_mmap_offset()` function to associate 982fa91d15SJani Nikula the fake offset as described in ?. 992fa91d15SJani Nikula 1002fa91d15SJani NikulaNote that dumb objects may not be used for gpu acceleration, as has been 1012fa91d15SJani Nikulaattempted on some ARM embedded platforms. Such drivers really must have 1022fa91d15SJani Nikulaa hardware-specific ioctl to allocate suitable buffer objects. 1032fa91d15SJani Nikula 104311b62d9SDaniel VetterDisplay Modes Function Reference 105311b62d9SDaniel Vetter================================ 1062fa91d15SJani Nikula 107311b62d9SDaniel Vetter.. kernel-doc:: include/drm/drm_modes.h 108311b62d9SDaniel Vetter :internal: 109311b62d9SDaniel Vetter 110311b62d9SDaniel Vetter.. kernel-doc:: drivers/gpu/drm/drm_modes.c 111311b62d9SDaniel Vetter :export: 1122fa91d15SJani Nikula 113*ae2a6da8SDaniel VetterConnector Abstraction 114*ae2a6da8SDaniel Vetter===================== 115*ae2a6da8SDaniel Vetter 116*ae2a6da8SDaniel Vetter.. kernel-doc:: drivers/gpu/drm/drm_connector.c 117*ae2a6da8SDaniel Vetter :doc: overview 118*ae2a6da8SDaniel Vetter 119*ae2a6da8SDaniel VetterConnector Functions Reference 120*ae2a6da8SDaniel Vetter----------------------------- 12152217195SDaniel Vetter 12252217195SDaniel Vetter.. kernel-doc:: include/drm/drm_connector.h 12352217195SDaniel Vetter :internal: 12452217195SDaniel Vetter 12552217195SDaniel Vetter.. kernel-doc:: drivers/gpu/drm/drm_connector.c 12652217195SDaniel Vetter :export: 12752217195SDaniel Vetter 1282fa91d15SJani NikulaKMS Initialization and Cleanup 1292fa91d15SJani Nikula============================== 1302fa91d15SJani Nikula 1312fa91d15SJani NikulaA KMS device is abstracted and exposed as a set of planes, CRTCs, 1322fa91d15SJani Nikulaencoders and connectors. KMS drivers must thus create and initialize all 1332fa91d15SJani Nikulathose objects at load time after initializing mode setting. 1342fa91d15SJani Nikula 1352fa91d15SJani NikulaCRTCs (:c:type:`struct drm_crtc <drm_crtc>`) 1362fa91d15SJani Nikula-------------------------------------------- 1372fa91d15SJani Nikula 1382fa91d15SJani NikulaA CRTC is an abstraction representing a part of the chip that contains a 1392fa91d15SJani Nikulapointer to a scanout buffer. Therefore, the number of CRTCs available 1402fa91d15SJani Nikuladetermines how many independent scanout buffers can be active at any 1412fa91d15SJani Nikulagiven time. The CRTC structure contains several fields to support this: 1422fa91d15SJani Nikulaa pointer to some video memory (abstracted as a frame buffer object), a 1432fa91d15SJani Nikuladisplay mode, and an (x, y) offset into the video memory to support 1442fa91d15SJani Nikulapanning or configurations where one piece of video memory spans multiple 1452fa91d15SJani NikulaCRTCs. 1462fa91d15SJani Nikula 1472fa91d15SJani NikulaCRTC Initialization 1482fa91d15SJani Nikula~~~~~~~~~~~~~~~~~~~ 1492fa91d15SJani Nikula 1502fa91d15SJani NikulaA KMS device must create and register at least one struct 1512fa91d15SJani Nikula:c:type:`struct drm_crtc <drm_crtc>` instance. The instance is 1522fa91d15SJani Nikulaallocated and zeroed by the driver, possibly as part of a larger 1532fa91d15SJani Nikulastructure, and registered with a call to :c:func:`drm_crtc_init()` 1542fa91d15SJani Nikulawith a pointer to CRTC functions. 1552fa91d15SJani Nikula 1562fa91d15SJani NikulaPlanes (:c:type:`struct drm_plane <drm_plane>`) 1572fa91d15SJani Nikula----------------------------------------------- 1582fa91d15SJani Nikula 1592fa91d15SJani NikulaA plane represents an image source that can be blended with or overlayed 1602fa91d15SJani Nikulaon top of a CRTC during the scanout process. Planes are associated with 1612fa91d15SJani Nikulaa frame buffer to crop a portion of the image memory (source) and 1622fa91d15SJani Nikulaoptionally scale it to a destination size. The result is then blended 1632fa91d15SJani Nikulawith or overlayed on top of a CRTC. 1642fa91d15SJani Nikula 1652fa91d15SJani NikulaThe DRM core recognizes three types of planes: 1662fa91d15SJani Nikula 1672fa91d15SJani Nikula- DRM_PLANE_TYPE_PRIMARY represents a "main" plane for a CRTC. 1682fa91d15SJani Nikula Primary planes are the planes operated upon by CRTC modesetting and 1692fa91d15SJani Nikula flipping operations described in the page_flip hook in 1702fa91d15SJani Nikula :c:type:`struct drm_crtc_funcs <drm_crtc_funcs>`. 1712fa91d15SJani Nikula- DRM_PLANE_TYPE_CURSOR represents a "cursor" plane for a CRTC. 1722fa91d15SJani Nikula Cursor planes are the planes operated upon by the 1732fa91d15SJani Nikula DRM_IOCTL_MODE_CURSOR and DRM_IOCTL_MODE_CURSOR2 ioctls. 1742fa91d15SJani Nikula- DRM_PLANE_TYPE_OVERLAY represents all non-primary, non-cursor 1752fa91d15SJani Nikula planes. Some drivers refer to these types of planes as "sprites" 1762fa91d15SJani Nikula internally. 1772fa91d15SJani Nikula 1782fa91d15SJani NikulaFor compatibility with legacy userspace, only overlay planes are made 1792fa91d15SJani Nikulaavailable to userspace by default. Userspace clients may set the 1802fa91d15SJani NikulaDRM_CLIENT_CAP_UNIVERSAL_PLANES client capability bit to indicate 1812fa91d15SJani Nikulathat they wish to receive a universal plane list containing all plane 1822fa91d15SJani Nikulatypes. 1832fa91d15SJani Nikula 1842fa91d15SJani NikulaPlane Initialization 1852fa91d15SJani Nikula~~~~~~~~~~~~~~~~~~~~ 1862fa91d15SJani Nikula 1872fa91d15SJani NikulaTo create a plane, a KMS drivers allocates and zeroes an instances of 1882fa91d15SJani Nikula:c:type:`struct drm_plane <drm_plane>` (possibly as part of a 1892fa91d15SJani Nikulalarger structure) and registers it with a call to 1902fa91d15SJani Nikula:c:func:`drm_universal_plane_init()`. The function takes a 1912fa91d15SJani Nikulabitmask of the CRTCs that can be associated with the plane, a pointer to 1922fa91d15SJani Nikulathe plane functions, a list of format supported formats, and the type of 1932fa91d15SJani Nikulaplane (primary, cursor, or overlay) being initialized. 1942fa91d15SJani Nikula 1952fa91d15SJani NikulaCursor and overlay planes are optional. All drivers should provide one 1962fa91d15SJani Nikulaprimary plane per CRTC (although this requirement may change in the 1972fa91d15SJani Nikulafuture); drivers that do not wish to provide special handling for 1982fa91d15SJani Nikulaprimary planes may make use of the helper functions described in ? to 1992fa91d15SJani Nikulacreate and register a primary plane with standard capabilities. 2002fa91d15SJani Nikula 2012fa91d15SJani NikulaEncoders (:c:type:`struct drm_encoder <drm_encoder>`) 2022fa91d15SJani Nikula----------------------------------------------------- 2032fa91d15SJani Nikula 2042fa91d15SJani NikulaAn encoder takes pixel data from a CRTC and converts it to a format 2052fa91d15SJani Nikulasuitable for any attached connectors. On some devices, it may be 2062fa91d15SJani Nikulapossible to have a CRTC send data to more than one encoder. In that 2072fa91d15SJani Nikulacase, both encoders would receive data from the same scanout buffer, 2082fa91d15SJani Nikularesulting in a "cloned" display configuration across the connectors 2092fa91d15SJani Nikulaattached to each encoder. 2102fa91d15SJani Nikula 2112fa91d15SJani NikulaEncoder Initialization 2122fa91d15SJani Nikula~~~~~~~~~~~~~~~~~~~~~~ 2132fa91d15SJani Nikula 2142fa91d15SJani NikulaAs for CRTCs, a KMS driver must create, initialize and register at least 2152fa91d15SJani Nikulaone :c:type:`struct drm_encoder <drm_encoder>` instance. The 2162fa91d15SJani Nikulainstance is allocated and zeroed by the driver, possibly as part of a 2172fa91d15SJani Nikulalarger structure. 2182fa91d15SJani Nikula 2192fa91d15SJani NikulaDrivers must initialize the :c:type:`struct drm_encoder 2202fa91d15SJani Nikula<drm_encoder>` possible_crtcs and possible_clones fields before 2212fa91d15SJani Nikularegistering the encoder. Both fields are bitmasks of respectively the 2222fa91d15SJani NikulaCRTCs that the encoder can be connected to, and sibling encoders 2232fa91d15SJani Nikulacandidate for cloning. 2242fa91d15SJani Nikula 2252fa91d15SJani NikulaAfter being initialized, the encoder must be registered with a call to 2262fa91d15SJani Nikula:c:func:`drm_encoder_init()`. The function takes a pointer to the 2272fa91d15SJani Nikulaencoder functions and an encoder type. Supported types are 2282fa91d15SJani Nikula 2292fa91d15SJani Nikula- DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A 2302fa91d15SJani Nikula- DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort 2312fa91d15SJani Nikula- DRM_MODE_ENCODER_LVDS for display panels 2322fa91d15SJani Nikula- DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video, 2332fa91d15SJani Nikula Component, SCART) 2342fa91d15SJani Nikula- DRM_MODE_ENCODER_VIRTUAL for virtual machine displays 2352fa91d15SJani Nikula 2362fa91d15SJani NikulaEncoders must be attached to a CRTC to be used. DRM drivers leave 2372fa91d15SJani Nikulaencoders unattached at initialization time. Applications (or the fbdev 2382fa91d15SJani Nikulacompatibility layer when implemented) are responsible for attaching the 2392fa91d15SJani Nikulaencoders they want to use to a CRTC. 2402fa91d15SJani Nikula 2412fa91d15SJani NikulaCleanup 2422fa91d15SJani Nikula------- 2432fa91d15SJani Nikula 2442fa91d15SJani NikulaThe DRM core manages its objects' lifetime. When an object is not needed 2452fa91d15SJani Nikulaanymore the core calls its destroy function, which must clean up and 2462fa91d15SJani Nikulafree every resource allocated for the object. Every 2472fa91d15SJani Nikula:c:func:`drm_\*_init()` call must be matched with a corresponding 2482fa91d15SJani Nikula:c:func:`drm_\*_cleanup()` call to cleanup CRTCs 2492fa91d15SJani Nikula(:c:func:`drm_crtc_cleanup()`), planes 2502fa91d15SJani Nikula(:c:func:`drm_plane_cleanup()`), encoders 2512fa91d15SJani Nikula(:c:func:`drm_encoder_cleanup()`) and connectors 2522fa91d15SJani Nikula(:c:func:`drm_connector_cleanup()`). Furthermore, connectors that 2532fa91d15SJani Nikulahave been added to sysfs must be removed by a call to 2542fa91d15SJani Nikula:c:func:`drm_connector_unregister()` before calling 2552fa91d15SJani Nikula:c:func:`drm_connector_cleanup()`. 2562fa91d15SJani Nikula 2572fa91d15SJani NikulaConnectors state change detection must be cleanup up with a call to 2582fa91d15SJani Nikula:c:func:`drm_kms_helper_poll_fini()`. 2592fa91d15SJani Nikula 2602fa91d15SJani NikulaOutput discovery and initialization example 2612fa91d15SJani Nikula------------------------------------------- 2622fa91d15SJani Nikula 2632fa91d15SJani Nikula:: 2642fa91d15SJani Nikula 2652fa91d15SJani Nikula void intel_crt_init(struct drm_device *dev) 2662fa91d15SJani Nikula { 2672fa91d15SJani Nikula struct drm_connector *connector; 2682fa91d15SJani Nikula struct intel_output *intel_output; 2692fa91d15SJani Nikula 2702fa91d15SJani Nikula intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); 2712fa91d15SJani Nikula if (!intel_output) 2722fa91d15SJani Nikula return; 2732fa91d15SJani Nikula 2742fa91d15SJani Nikula connector = &intel_output->base; 2752fa91d15SJani Nikula drm_connector_init(dev, &intel_output->base, 2762fa91d15SJani Nikula &intel_crt_connector_funcs, DRM_MODE_CONNECTOR_VGA); 2772fa91d15SJani Nikula 2782fa91d15SJani Nikula drm_encoder_init(dev, &intel_output->enc, &intel_crt_enc_funcs, 2792fa91d15SJani Nikula DRM_MODE_ENCODER_DAC); 2802fa91d15SJani Nikula 2812fa91d15SJani Nikula drm_mode_connector_attach_encoder(&intel_output->base, 2822fa91d15SJani Nikula &intel_output->enc); 2832fa91d15SJani Nikula 2842fa91d15SJani Nikula /* Set up the DDC bus. */ 2852fa91d15SJani Nikula intel_output->ddc_bus = intel_i2c_create(dev, GPIOA, "CRTDDC_A"); 2862fa91d15SJani Nikula if (!intel_output->ddc_bus) { 2872fa91d15SJani Nikula dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " 2882fa91d15SJani Nikula "failed.\n"); 2892fa91d15SJani Nikula return; 2902fa91d15SJani Nikula } 2912fa91d15SJani Nikula 2922fa91d15SJani Nikula intel_output->type = INTEL_OUTPUT_ANALOG; 2932fa91d15SJani Nikula connector->interlace_allowed = 0; 2942fa91d15SJani Nikula connector->doublescan_allowed = 0; 2952fa91d15SJani Nikula 2962fa91d15SJani Nikula drm_encoder_helper_add(&intel_output->enc, &intel_crt_helper_funcs); 2972fa91d15SJani Nikula drm_connector_helper_add(connector, &intel_crt_connector_helper_funcs); 2982fa91d15SJani Nikula 2992fa91d15SJani Nikula drm_connector_register(connector); 3002fa91d15SJani Nikula } 3012fa91d15SJani Nikula 3022fa91d15SJani NikulaIn the example above (taken from the i915 driver), a CRTC, connector and 3032fa91d15SJani Nikulaencoder combination is created. A device-specific i2c bus is also 3042fa91d15SJani Nikulacreated for fetching EDID data and performing monitor detection. Once 3052fa91d15SJani Nikulathe process is complete, the new connector is registered with sysfs to 3062fa91d15SJani Nikulamake its properties available to applications. 3072fa91d15SJani Nikula 3082fa91d15SJani NikulaKMS Locking 309311b62d9SDaniel Vetter=========== 3102fa91d15SJani Nikula 3112fa91d15SJani Nikula.. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c 3122fa91d15SJani Nikula :doc: kms locking 3132fa91d15SJani Nikula 3142fa91d15SJani Nikula.. kernel-doc:: include/drm/drm_modeset_lock.h 3152fa91d15SJani Nikula :internal: 3162fa91d15SJani Nikula 3172fa91d15SJani Nikula.. kernel-doc:: drivers/gpu/drm/drm_modeset_lock.c 3182fa91d15SJani Nikula :export: 3192fa91d15SJani Nikula 3202fa91d15SJani NikulaKMS Properties 3212fa91d15SJani Nikula============== 3222fa91d15SJani Nikula 3232fa91d15SJani NikulaDrivers may need to expose additional parameters to applications than 3242fa91d15SJani Nikulathose described in the previous sections. KMS supports attaching 3252fa91d15SJani Nikulaproperties to CRTCs, connectors and planes and offers a userspace API to 3262fa91d15SJani Nikulalist, get and set the property values. 3272fa91d15SJani Nikula 3282fa91d15SJani NikulaProperties are identified by a name that uniquely defines the property 3292fa91d15SJani Nikulapurpose, and store an associated value. For all property types except 3302fa91d15SJani Nikulablob properties the value is a 64-bit unsigned integer. 3312fa91d15SJani Nikula 3322fa91d15SJani NikulaKMS differentiates between properties and property instances. Drivers 3332fa91d15SJani Nikulafirst create properties and then create and associate individual 3342fa91d15SJani Nikulainstances of those properties to objects. A property can be instantiated 3352fa91d15SJani Nikulamultiple times and associated with different objects. Values are stored 3362fa91d15SJani Nikulain property instances, and all other property information are stored in 3372fa91d15SJani Nikulathe property and shared between all instances of the property. 3382fa91d15SJani Nikula 3392fa91d15SJani NikulaEvery property is created with a type that influences how the KMS core 3402fa91d15SJani Nikulahandles the property. Supported property types are 3412fa91d15SJani Nikula 3422fa91d15SJani NikulaDRM_MODE_PROP_RANGE 3432fa91d15SJani Nikula Range properties report their minimum and maximum admissible values. 3442fa91d15SJani Nikula The KMS core verifies that values set by application fit in that 3452fa91d15SJani Nikula range. 3462fa91d15SJani Nikula 3472fa91d15SJani NikulaDRM_MODE_PROP_ENUM 3482fa91d15SJani Nikula Enumerated properties take a numerical value that ranges from 0 to 3492fa91d15SJani Nikula the number of enumerated values defined by the property minus one, 3502fa91d15SJani Nikula and associate a free-formed string name to each value. Applications 3512fa91d15SJani Nikula can retrieve the list of defined value-name pairs and use the 3522fa91d15SJani Nikula numerical value to get and set property instance values. 3532fa91d15SJani Nikula 3542fa91d15SJani NikulaDRM_MODE_PROP_BITMASK 3552fa91d15SJani Nikula Bitmask properties are enumeration properties that additionally 3562fa91d15SJani Nikula restrict all enumerated values to the 0..63 range. Bitmask property 3572fa91d15SJani Nikula instance values combine one or more of the enumerated bits defined 3582fa91d15SJani Nikula by the property. 3592fa91d15SJani Nikula 3602fa91d15SJani NikulaDRM_MODE_PROP_BLOB 3612fa91d15SJani Nikula Blob properties store a binary blob without any format restriction. 3622fa91d15SJani Nikula The binary blobs are created as KMS standalone objects, and blob 3632fa91d15SJani Nikula property instance values store the ID of their associated blob 3642fa91d15SJani Nikula object. 3652fa91d15SJani Nikula 3662fa91d15SJani Nikula Blob properties are only used for the connector EDID property and 3672fa91d15SJani Nikula cannot be created by drivers. 3682fa91d15SJani Nikula 3692fa91d15SJani NikulaTo create a property drivers call one of the following functions 3702fa91d15SJani Nikuladepending on the property type. All property creation functions take 3712fa91d15SJani Nikulaproperty flags and name, as well as type-specific arguments. 3722fa91d15SJani Nikula 3732fa91d15SJani Nikula- struct drm_property \*drm_property_create_range(struct 3742fa91d15SJani Nikula drm_device \*dev, int flags, const char \*name, uint64_t min, 3752fa91d15SJani Nikula uint64_t max); 3762fa91d15SJani Nikula Create a range property with the given minimum and maximum values. 3772fa91d15SJani Nikula 3782fa91d15SJani Nikula- struct drm_property \*drm_property_create_enum(struct drm_device 3792fa91d15SJani Nikula \*dev, int flags, const char \*name, const struct 3802fa91d15SJani Nikula drm_prop_enum_list \*props, int num_values); 3812fa91d15SJani Nikula Create an enumerated property. The ``props`` argument points to an 3822fa91d15SJani Nikula array of ``num_values`` value-name pairs. 3832fa91d15SJani Nikula 3842fa91d15SJani Nikula- struct drm_property \*drm_property_create_bitmask(struct 3852fa91d15SJani Nikula drm_device \*dev, int flags, const char \*name, const struct 3862fa91d15SJani Nikula drm_prop_enum_list \*props, int num_values); 3872fa91d15SJani Nikula Create a bitmask property. The ``props`` argument points to an array 3882fa91d15SJani Nikula of ``num_values`` value-name pairs. 3892fa91d15SJani Nikula 3902fa91d15SJani NikulaProperties can additionally be created as immutable, in which case they 3912fa91d15SJani Nikulawill be read-only for applications but can be modified by the driver. To 3922fa91d15SJani Nikulacreate an immutable property drivers must set the 3932fa91d15SJani NikulaDRM_MODE_PROP_IMMUTABLE flag at property creation time. 3942fa91d15SJani Nikula 3952fa91d15SJani NikulaWhen no array of value-name pairs is readily available at property 3962fa91d15SJani Nikulacreation time for enumerated or range properties, drivers can create the 3972fa91d15SJani Nikulaproperty using the :c:func:`drm_property_create()` function and 3982fa91d15SJani Nikulamanually add enumeration value-name pairs by calling the 3992fa91d15SJani Nikula:c:func:`drm_property_add_enum()` function. Care must be taken to 4002fa91d15SJani Nikulaproperly specify the property type through the ``flags`` argument. 4012fa91d15SJani Nikula 4022fa91d15SJani NikulaAfter creating properties drivers can attach property instances to CRTC, 4032fa91d15SJani Nikulaconnector and plane objects by calling the 4042fa91d15SJani Nikula:c:func:`drm_object_attach_property()`. The function takes a 4052fa91d15SJani Nikulapointer to the target object, a pointer to the previously created 4062fa91d15SJani Nikulaproperty and an initial instance value. 4072fa91d15SJani Nikula 40852a9fcdaSDaniel VetterBlending and Z-Position properties 40952a9fcdaSDaniel Vetter---------------------------------- 41052a9fcdaSDaniel Vetter 41152a9fcdaSDaniel Vetter.. kernel-doc:: drivers/gpu/drm/drm_blend.c 41252a9fcdaSDaniel Vetter :export: 41352a9fcdaSDaniel Vetter 4142fa91d15SJani NikulaExisting KMS Properties 4152fa91d15SJani Nikula----------------------- 4162fa91d15SJani Nikula 4172fa91d15SJani NikulaThe following table gives description of drm properties exposed by 4182fa91d15SJani Nikulavarious modules/drivers. 4192fa91d15SJani Nikula 4202fa91d15SJani Nikula.. csv-table:: 4212fa91d15SJani Nikula :header-rows: 1 4222fa91d15SJani Nikula :file: kms-properties.csv 4232fa91d15SJani Nikula 4242fa91d15SJani NikulaVertical Blanking 4252fa91d15SJani Nikula================= 4262fa91d15SJani Nikula 4272fa91d15SJani NikulaVertical blanking plays a major role in graphics rendering. To achieve 4282fa91d15SJani Nikulatear-free display, users must synchronize page flips and/or rendering to 4292fa91d15SJani Nikulavertical blanking. The DRM API offers ioctls to perform page flips 4302fa91d15SJani Nikulasynchronized to vertical blanking and wait for vertical blanking. 4312fa91d15SJani Nikula 4322fa91d15SJani NikulaThe DRM core handles most of the vertical blanking management logic, 4332fa91d15SJani Nikulawhich involves filtering out spurious interrupts, keeping race-free 4342fa91d15SJani Nikulablanking counters, coping with counter wrap-around and resets and 4352fa91d15SJani Nikulakeeping use counts. It relies on the driver to generate vertical 4362fa91d15SJani Nikulablanking interrupts and optionally provide a hardware vertical blanking 4372fa91d15SJani Nikulacounter. Drivers must implement the following operations. 4382fa91d15SJani Nikula 4392fa91d15SJani Nikula- int (\*enable_vblank) (struct drm_device \*dev, int crtc); void 4402fa91d15SJani Nikula (\*disable_vblank) (struct drm_device \*dev, int crtc); 4412fa91d15SJani Nikula Enable or disable vertical blanking interrupts for the given CRTC. 4422fa91d15SJani Nikula 4432fa91d15SJani Nikula- u32 (\*get_vblank_counter) (struct drm_device \*dev, int crtc); 4442fa91d15SJani Nikula Retrieve the value of the vertical blanking counter for the given 4452fa91d15SJani Nikula CRTC. If the hardware maintains a vertical blanking counter its value 4462fa91d15SJani Nikula should be returned. Otherwise drivers can use the 4472fa91d15SJani Nikula :c:func:`drm_vblank_count()` helper function to handle this 4482fa91d15SJani Nikula operation. 4492fa91d15SJani Nikula 4502fa91d15SJani NikulaDrivers must initialize the vertical blanking handling core with a call 4512fa91d15SJani Nikulato :c:func:`drm_vblank_init()` in their load operation. 4522fa91d15SJani Nikula 4532fa91d15SJani NikulaVertical blanking interrupts can be enabled by the DRM core or by 4542fa91d15SJani Nikuladrivers themselves (for instance to handle page flipping operations). 4552fa91d15SJani NikulaThe DRM core maintains a vertical blanking use count to ensure that the 4562fa91d15SJani Nikulainterrupts are not disabled while a user still needs them. To increment 4572fa91d15SJani Nikulathe use count, drivers call :c:func:`drm_vblank_get()`. Upon 4582fa91d15SJani Nikulareturn vertical blanking interrupts are guaranteed to be enabled. 4592fa91d15SJani Nikula 4602fa91d15SJani NikulaTo decrement the use count drivers call 4612fa91d15SJani Nikula:c:func:`drm_vblank_put()`. Only when the use count drops to zero 4622fa91d15SJani Nikulawill the DRM core disable the vertical blanking interrupts after a delay 4632fa91d15SJani Nikulaby scheduling a timer. The delay is accessible through the 4642fa91d15SJani Nikulavblankoffdelay module parameter or the ``drm_vblank_offdelay`` global 4652fa91d15SJani Nikulavariable and expressed in milliseconds. Its default value is 5000 ms. 4662fa91d15SJani NikulaZero means never disable, and a negative value means disable 4672fa91d15SJani Nikulaimmediately. Drivers may override the behaviour by setting the 4682fa91d15SJani Nikula:c:type:`struct drm_device <drm_device>` 4692fa91d15SJani Nikulavblank_disable_immediate flag, which when set causes vblank interrupts 4702fa91d15SJani Nikulato be disabled immediately regardless of the drm_vblank_offdelay 4712fa91d15SJani Nikulavalue. The flag should only be set if there's a properly working 4722fa91d15SJani Nikulahardware vblank counter present. 4732fa91d15SJani Nikula 4742fa91d15SJani NikulaWhen a vertical blanking interrupt occurs drivers only need to call the 4752fa91d15SJani Nikula:c:func:`drm_handle_vblank()` function to account for the 4762fa91d15SJani Nikulainterrupt. 4772fa91d15SJani Nikula 4782fa91d15SJani NikulaResources allocated by :c:func:`drm_vblank_init()` must be freed 4792fa91d15SJani Nikulawith a call to :c:func:`drm_vblank_cleanup()` in the driver unload 4802fa91d15SJani Nikulaoperation handler. 4812fa91d15SJani Nikula 4822fa91d15SJani NikulaVertical Blanking and Interrupt Handling Functions Reference 4832fa91d15SJani Nikula------------------------------------------------------------ 4842fa91d15SJani Nikula 4852fa91d15SJani Nikula.. kernel-doc:: drivers/gpu/drm/drm_irq.c 4862fa91d15SJani Nikula :export: 4872fa91d15SJani Nikula 48834a67dd7SDaniel Vetter.. kernel-doc:: include/drm/drm_irq.h 48934a67dd7SDaniel Vetter :internal: 490