18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright © 2006 Keith Packard 38c2ecf20Sopenharmony_ci * Copyright © 2007-2008 Dave Airlie 48c2ecf20Sopenharmony_ci * Copyright © 2007-2008 Intel Corporation 58c2ecf20Sopenharmony_ci * Jesse Barnes <jesse.barnes@intel.com> 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 88c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 98c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 108c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 118c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 128c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 158c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 188c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 198c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 208c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 218c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 228c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 238c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci#ifndef __DRM_CRTC_H__ 268c2ecf20Sopenharmony_ci#define __DRM_CRTC_H__ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include <linux/i2c.h> 298c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 308c2ecf20Sopenharmony_ci#include <linux/types.h> 318c2ecf20Sopenharmony_ci#include <linux/fb.h> 328c2ecf20Sopenharmony_ci#include <linux/hdmi.h> 338c2ecf20Sopenharmony_ci#include <linux/media-bus-format.h> 348c2ecf20Sopenharmony_ci#include <uapi/drm/drm_mode.h> 358c2ecf20Sopenharmony_ci#include <uapi/drm/drm_fourcc.h> 368c2ecf20Sopenharmony_ci#include <drm/drm_modeset_lock.h> 378c2ecf20Sopenharmony_ci#include <drm/drm_rect.h> 388c2ecf20Sopenharmony_ci#include <drm/drm_mode_object.h> 398c2ecf20Sopenharmony_ci#include <drm/drm_framebuffer.h> 408c2ecf20Sopenharmony_ci#include <drm/drm_modes.h> 418c2ecf20Sopenharmony_ci#include <drm/drm_connector.h> 428c2ecf20Sopenharmony_ci#include <drm/drm_device.h> 438c2ecf20Sopenharmony_ci#include <drm/drm_property.h> 448c2ecf20Sopenharmony_ci#include <drm/drm_edid.h> 458c2ecf20Sopenharmony_ci#include <drm/drm_plane.h> 468c2ecf20Sopenharmony_ci#include <drm/drm_blend.h> 478c2ecf20Sopenharmony_ci#include <drm/drm_color_mgmt.h> 488c2ecf20Sopenharmony_ci#include <drm/drm_debugfs_crc.h> 498c2ecf20Sopenharmony_ci#include <drm/drm_mode_config.h> 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistruct drm_device; 528c2ecf20Sopenharmony_cistruct drm_mode_set; 538c2ecf20Sopenharmony_cistruct drm_file; 548c2ecf20Sopenharmony_cistruct drm_clip_rect; 558c2ecf20Sopenharmony_cistruct drm_printer; 568c2ecf20Sopenharmony_cistruct drm_self_refresh_data; 578c2ecf20Sopenharmony_cistruct device_node; 588c2ecf20Sopenharmony_cistruct dma_fence; 598c2ecf20Sopenharmony_cistruct edid; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic inline int64_t U642I64(uint64_t val) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci return (int64_t)*((int64_t *)&val); 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_cistatic inline uint64_t I642U64(int64_t val) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci return (uint64_t)*((uint64_t *)&val); 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct drm_crtc; 718c2ecf20Sopenharmony_cistruct drm_pending_vblank_event; 728c2ecf20Sopenharmony_cistruct drm_plane; 738c2ecf20Sopenharmony_cistruct drm_bridge; 748c2ecf20Sopenharmony_cistruct drm_atomic_state; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistruct drm_crtc_helper_funcs; 778c2ecf20Sopenharmony_cistruct drm_plane_helper_funcs; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/** 808c2ecf20Sopenharmony_ci * struct drm_crtc_state - mutable CRTC state 818c2ecf20Sopenharmony_ci * 828c2ecf20Sopenharmony_ci * Note that the distinction between @enable and @active is rather subtle: 838c2ecf20Sopenharmony_ci * Flipping @active while @enable is set without changing anything else may 848c2ecf20Sopenharmony_ci * never return in a failure from the &drm_mode_config_funcs.atomic_check 858c2ecf20Sopenharmony_ci * callback. Userspace assumes that a DPMS On will always succeed. In other 868c2ecf20Sopenharmony_ci * words: @enable controls resource assignment, @active controls the actual 878c2ecf20Sopenharmony_ci * hardware state. 888c2ecf20Sopenharmony_ci * 898c2ecf20Sopenharmony_ci * The three booleans active_changed, connectors_changed and mode_changed are 908c2ecf20Sopenharmony_ci * intended to indicate whether a full modeset is needed, rather than strictly 918c2ecf20Sopenharmony_ci * describing what has changed in a commit. See also: 928c2ecf20Sopenharmony_ci * drm_atomic_crtc_needs_modeset() 938c2ecf20Sopenharmony_ci * 948c2ecf20Sopenharmony_ci * WARNING: Transitional helpers (like drm_helper_crtc_mode_set() or 958c2ecf20Sopenharmony_ci * drm_helper_crtc_mode_set_base()) do not maintain many of the derived control 968c2ecf20Sopenharmony_ci * state like @plane_mask so drivers not converted over to atomic helpers should 978c2ecf20Sopenharmony_ci * not rely on these being accurate! 988c2ecf20Sopenharmony_ci */ 998c2ecf20Sopenharmony_cistruct drm_crtc_state { 1008c2ecf20Sopenharmony_ci /** @crtc: backpointer to the CRTC */ 1018c2ecf20Sopenharmony_ci struct drm_crtc *crtc; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci /** 1048c2ecf20Sopenharmony_ci * @enable: Whether the CRTC should be enabled, gates all other state. 1058c2ecf20Sopenharmony_ci * This controls reservations of shared resources. Actual hardware state 1068c2ecf20Sopenharmony_ci * is controlled by @active. 1078c2ecf20Sopenharmony_ci */ 1088c2ecf20Sopenharmony_ci bool enable; 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci /** 1118c2ecf20Sopenharmony_ci * @active: Whether the CRTC is actively displaying (used for DPMS). 1128c2ecf20Sopenharmony_ci * Implies that @enable is set. The driver must not release any shared 1138c2ecf20Sopenharmony_ci * resources if @active is set to false but @enable still true, because 1148c2ecf20Sopenharmony_ci * userspace expects that a DPMS ON always succeeds. 1158c2ecf20Sopenharmony_ci * 1168c2ecf20Sopenharmony_ci * Hence drivers must not consult @active in their various 1178c2ecf20Sopenharmony_ci * &drm_mode_config_funcs.atomic_check callback to reject an atomic 1188c2ecf20Sopenharmony_ci * commit. They can consult it to aid in the computation of derived 1198c2ecf20Sopenharmony_ci * hardware state, since even in the DPMS OFF state the display hardware 1208c2ecf20Sopenharmony_ci * should be as much powered down as when the CRTC is completely 1218c2ecf20Sopenharmony_ci * disabled through setting @enable to false. 1228c2ecf20Sopenharmony_ci */ 1238c2ecf20Sopenharmony_ci bool active; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci /** 1268c2ecf20Sopenharmony_ci * @planes_changed: Planes on this crtc are updated. Used by the atomic 1278c2ecf20Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. 1288c2ecf20Sopenharmony_ci */ 1298c2ecf20Sopenharmony_ci bool planes_changed : 1; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci /** 1328c2ecf20Sopenharmony_ci * @mode_changed: @mode or @enable has been changed. Used by the atomic 1338c2ecf20Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. See also 1348c2ecf20Sopenharmony_ci * drm_atomic_crtc_needs_modeset(). 1358c2ecf20Sopenharmony_ci * 1368c2ecf20Sopenharmony_ci * Drivers are supposed to set this for any CRTC state changes that 1378c2ecf20Sopenharmony_ci * require a full modeset. They can also reset it to false if e.g. a 1388c2ecf20Sopenharmony_ci * @mode change can be done without a full modeset by only changing 1398c2ecf20Sopenharmony_ci * scaler settings. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci bool mode_changed : 1; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci /** 1448c2ecf20Sopenharmony_ci * @active_changed: @active has been toggled. Used by the atomic 1458c2ecf20Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. See also 1468c2ecf20Sopenharmony_ci * drm_atomic_crtc_needs_modeset(). 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_ci bool active_changed : 1; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci /** 1518c2ecf20Sopenharmony_ci * @connectors_changed: Connectors to this crtc have been updated, 1528c2ecf20Sopenharmony_ci * either in their state or routing. Used by the atomic 1538c2ecf20Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. See also 1548c2ecf20Sopenharmony_ci * drm_atomic_crtc_needs_modeset(). 1558c2ecf20Sopenharmony_ci * 1568c2ecf20Sopenharmony_ci * Drivers are supposed to set this as-needed from their own atomic 1578c2ecf20Sopenharmony_ci * check code, e.g. from &drm_encoder_helper_funcs.atomic_check 1588c2ecf20Sopenharmony_ci */ 1598c2ecf20Sopenharmony_ci bool connectors_changed : 1; 1608c2ecf20Sopenharmony_ci /** 1618c2ecf20Sopenharmony_ci * @zpos_changed: zpos values of planes on this crtc have been updated. 1628c2ecf20Sopenharmony_ci * Used by the atomic helpers and drivers to steer the atomic commit 1638c2ecf20Sopenharmony_ci * control flow. 1648c2ecf20Sopenharmony_ci */ 1658c2ecf20Sopenharmony_ci bool zpos_changed : 1; 1668c2ecf20Sopenharmony_ci /** 1678c2ecf20Sopenharmony_ci * @color_mgmt_changed: Color management properties have changed 1688c2ecf20Sopenharmony_ci * (@gamma_lut, @degamma_lut or @ctm). Used by the atomic helpers and 1698c2ecf20Sopenharmony_ci * drivers to steer the atomic commit control flow. 1708c2ecf20Sopenharmony_ci */ 1718c2ecf20Sopenharmony_ci bool color_mgmt_changed : 1; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci /** 1748c2ecf20Sopenharmony_ci * @no_vblank: 1758c2ecf20Sopenharmony_ci * 1768c2ecf20Sopenharmony_ci * Reflects the ability of a CRTC to send VBLANK events. This state 1778c2ecf20Sopenharmony_ci * usually depends on the pipeline configuration. If set to true, DRM 1788c2ecf20Sopenharmony_ci * atomic helpers will send out a fake VBLANK event during display 1798c2ecf20Sopenharmony_ci * updates after all hardware changes have been committed. This is 1808c2ecf20Sopenharmony_ci * implemented in drm_atomic_helper_fake_vblank(). 1818c2ecf20Sopenharmony_ci * 1828c2ecf20Sopenharmony_ci * One usage is for drivers and/or hardware without support for VBLANK 1838c2ecf20Sopenharmony_ci * interrupts. Such drivers typically do not initialize vblanking 1848c2ecf20Sopenharmony_ci * (i.e., call drm_vblank_init() with the number of CRTCs). For CRTCs 1858c2ecf20Sopenharmony_ci * without initialized vblanking, this field is set to true in 1868c2ecf20Sopenharmony_ci * drm_atomic_helper_check_modeset(), and a fake VBLANK event will be 1878c2ecf20Sopenharmony_ci * send out on each update of the display pipeline by 1888c2ecf20Sopenharmony_ci * drm_atomic_helper_fake_vblank(). 1898c2ecf20Sopenharmony_ci * 1908c2ecf20Sopenharmony_ci * Another usage is CRTCs feeding a writeback connector operating in 1918c2ecf20Sopenharmony_ci * oneshot mode. In this case the fake VBLANK event is only generated 1928c2ecf20Sopenharmony_ci * when a job is queued to the writeback connector, and we want the 1938c2ecf20Sopenharmony_ci * core to fake VBLANK events when this part of the pipeline hasn't 1948c2ecf20Sopenharmony_ci * changed but others had or when the CRTC and connectors are being 1958c2ecf20Sopenharmony_ci * disabled. 1968c2ecf20Sopenharmony_ci * 1978c2ecf20Sopenharmony_ci * __drm_atomic_helper_crtc_duplicate_state() will not reset the value 1988c2ecf20Sopenharmony_ci * from the current state, the CRTC driver is then responsible for 1998c2ecf20Sopenharmony_ci * updating this field when needed. 2008c2ecf20Sopenharmony_ci * 2018c2ecf20Sopenharmony_ci * Note that the combination of &drm_crtc_state.event == NULL and 2028c2ecf20Sopenharmony_ci * &drm_crtc_state.no_blank == true is valid and usually used when the 2038c2ecf20Sopenharmony_ci * writeback connector attached to the CRTC has a new job queued. In 2048c2ecf20Sopenharmony_ci * this case the driver will send the VBLANK event on its own when the 2058c2ecf20Sopenharmony_ci * writeback job is complete. 2068c2ecf20Sopenharmony_ci */ 2078c2ecf20Sopenharmony_ci bool no_vblank : 1; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci /** 2108c2ecf20Sopenharmony_ci * @plane_mask: Bitmask of drm_plane_mask(plane) of planes attached to 2118c2ecf20Sopenharmony_ci * this CRTC. 2128c2ecf20Sopenharmony_ci */ 2138c2ecf20Sopenharmony_ci u32 plane_mask; 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci /** 2168c2ecf20Sopenharmony_ci * @connector_mask: Bitmask of drm_connector_mask(connector) of 2178c2ecf20Sopenharmony_ci * connectors attached to this CRTC. 2188c2ecf20Sopenharmony_ci */ 2198c2ecf20Sopenharmony_ci u32 connector_mask; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci /** 2228c2ecf20Sopenharmony_ci * @encoder_mask: Bitmask of drm_encoder_mask(encoder) of encoders 2238c2ecf20Sopenharmony_ci * attached to this CRTC. 2248c2ecf20Sopenharmony_ci */ 2258c2ecf20Sopenharmony_ci u32 encoder_mask; 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci /** 2288c2ecf20Sopenharmony_ci * @adjusted_mode: 2298c2ecf20Sopenharmony_ci * 2308c2ecf20Sopenharmony_ci * Internal display timings which can be used by the driver to handle 2318c2ecf20Sopenharmony_ci * differences between the mode requested by userspace in @mode and what 2328c2ecf20Sopenharmony_ci * is actually programmed into the hardware. 2338c2ecf20Sopenharmony_ci * 2348c2ecf20Sopenharmony_ci * For drivers using &drm_bridge, this stores hardware display timings 2358c2ecf20Sopenharmony_ci * used between the CRTC and the first bridge. For other drivers, the 2368c2ecf20Sopenharmony_ci * meaning of the adjusted_mode field is purely driver implementation 2378c2ecf20Sopenharmony_ci * defined information, and will usually be used to store the hardware 2388c2ecf20Sopenharmony_ci * display timings used between the CRTC and encoder blocks. 2398c2ecf20Sopenharmony_ci */ 2408c2ecf20Sopenharmony_ci struct drm_display_mode adjusted_mode; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci /** 2438c2ecf20Sopenharmony_ci * @mode: 2448c2ecf20Sopenharmony_ci * 2458c2ecf20Sopenharmony_ci * Display timings requested by userspace. The driver should try to 2468c2ecf20Sopenharmony_ci * match the refresh rate as close as possible (but note that it's 2478c2ecf20Sopenharmony_ci * undefined what exactly is close enough, e.g. some of the HDMI modes 2488c2ecf20Sopenharmony_ci * only differ in less than 1% of the refresh rate). The active width 2498c2ecf20Sopenharmony_ci * and height as observed by userspace for positioning planes must match 2508c2ecf20Sopenharmony_ci * exactly. 2518c2ecf20Sopenharmony_ci * 2528c2ecf20Sopenharmony_ci * For external connectors where the sink isn't fixed (like with a 2538c2ecf20Sopenharmony_ci * built-in panel), this mode here should match the physical mode on the 2548c2ecf20Sopenharmony_ci * wire to the last details (i.e. including sync polarities and 2558c2ecf20Sopenharmony_ci * everything). 2568c2ecf20Sopenharmony_ci */ 2578c2ecf20Sopenharmony_ci struct drm_display_mode mode; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci /** 2608c2ecf20Sopenharmony_ci * @mode_blob: &drm_property_blob for @mode, for exposing the mode to 2618c2ecf20Sopenharmony_ci * atomic userspace. 2628c2ecf20Sopenharmony_ci */ 2638c2ecf20Sopenharmony_ci struct drm_property_blob *mode_blob; 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci /** 2668c2ecf20Sopenharmony_ci * @degamma_lut: 2678c2ecf20Sopenharmony_ci * 2688c2ecf20Sopenharmony_ci * Lookup table for converting framebuffer pixel data before apply the 2698c2ecf20Sopenharmony_ci * color conversion matrix @ctm. See drm_crtc_enable_color_mgmt(). The 2708c2ecf20Sopenharmony_ci * blob (if not NULL) is an array of &struct drm_color_lut. 2718c2ecf20Sopenharmony_ci */ 2728c2ecf20Sopenharmony_ci struct drm_property_blob *degamma_lut; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci /** 2758c2ecf20Sopenharmony_ci * @ctm: 2768c2ecf20Sopenharmony_ci * 2778c2ecf20Sopenharmony_ci * Color transformation matrix. See drm_crtc_enable_color_mgmt(). The 2788c2ecf20Sopenharmony_ci * blob (if not NULL) is a &struct drm_color_ctm. 2798c2ecf20Sopenharmony_ci */ 2808c2ecf20Sopenharmony_ci struct drm_property_blob *ctm; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci /** 2838c2ecf20Sopenharmony_ci * @gamma_lut: 2848c2ecf20Sopenharmony_ci * 2858c2ecf20Sopenharmony_ci * Lookup table for converting pixel data after the color conversion 2868c2ecf20Sopenharmony_ci * matrix @ctm. See drm_crtc_enable_color_mgmt(). The blob (if not 2878c2ecf20Sopenharmony_ci * NULL) is an array of &struct drm_color_lut. 2888c2ecf20Sopenharmony_ci */ 2898c2ecf20Sopenharmony_ci struct drm_property_blob *gamma_lut; 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci /** 2928c2ecf20Sopenharmony_ci * @target_vblank: 2938c2ecf20Sopenharmony_ci * 2948c2ecf20Sopenharmony_ci * Target vertical blank period when a page flip 2958c2ecf20Sopenharmony_ci * should take effect. 2968c2ecf20Sopenharmony_ci */ 2978c2ecf20Sopenharmony_ci u32 target_vblank; 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci /** 3008c2ecf20Sopenharmony_ci * @async_flip: 3018c2ecf20Sopenharmony_ci * 3028c2ecf20Sopenharmony_ci * This is set when DRM_MODE_PAGE_FLIP_ASYNC is set in the legacy 3038c2ecf20Sopenharmony_ci * PAGE_FLIP IOCTL. It's not wired up for the atomic IOCTL itself yet. 3048c2ecf20Sopenharmony_ci */ 3058c2ecf20Sopenharmony_ci bool async_flip; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci /** 3088c2ecf20Sopenharmony_ci * @vrr_enabled: 3098c2ecf20Sopenharmony_ci * 3108c2ecf20Sopenharmony_ci * Indicates if variable refresh rate should be enabled for the CRTC. 3118c2ecf20Sopenharmony_ci * Support for the requested vrr state will depend on driver and 3128c2ecf20Sopenharmony_ci * hardware capabiltiy - lacking support is not treated as failure. 3138c2ecf20Sopenharmony_ci */ 3148c2ecf20Sopenharmony_ci bool vrr_enabled; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci /** 3178c2ecf20Sopenharmony_ci * @self_refresh_active: 3188c2ecf20Sopenharmony_ci * 3198c2ecf20Sopenharmony_ci * Used by the self refresh helpers to denote when a self refresh 3208c2ecf20Sopenharmony_ci * transition is occurring. This will be set on enable/disable callbacks 3218c2ecf20Sopenharmony_ci * when self refresh is being enabled or disabled. In some cases, it may 3228c2ecf20Sopenharmony_ci * not be desirable to fully shut off the crtc during self refresh. 3238c2ecf20Sopenharmony_ci * CRTC's can inspect this flag and determine the best course of action. 3248c2ecf20Sopenharmony_ci */ 3258c2ecf20Sopenharmony_ci bool self_refresh_active; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci /** 3288c2ecf20Sopenharmony_ci * @event: 3298c2ecf20Sopenharmony_ci * 3308c2ecf20Sopenharmony_ci * Optional pointer to a DRM event to signal upon completion of the 3318c2ecf20Sopenharmony_ci * state update. The driver must send out the event when the atomic 3328c2ecf20Sopenharmony_ci * commit operation completes. There are two cases: 3338c2ecf20Sopenharmony_ci * 3348c2ecf20Sopenharmony_ci * - The event is for a CRTC which is being disabled through this 3358c2ecf20Sopenharmony_ci * atomic commit. In that case the event can be send out any time 3368c2ecf20Sopenharmony_ci * after the hardware has stopped scanning out the current 3378c2ecf20Sopenharmony_ci * framebuffers. It should contain the timestamp and counter for the 3388c2ecf20Sopenharmony_ci * last vblank before the display pipeline was shut off. The simplest 3398c2ecf20Sopenharmony_ci * way to achieve that is calling drm_crtc_send_vblank_event() 3408c2ecf20Sopenharmony_ci * somewhen after drm_crtc_vblank_off() has been called. 3418c2ecf20Sopenharmony_ci * 3428c2ecf20Sopenharmony_ci * - For a CRTC which is enabled at the end of the commit (even when it 3438c2ecf20Sopenharmony_ci * undergoes an full modeset) the vblank timestamp and counter must 3448c2ecf20Sopenharmony_ci * be for the vblank right before the first frame that scans out the 3458c2ecf20Sopenharmony_ci * new set of buffers. Again the event can only be sent out after the 3468c2ecf20Sopenharmony_ci * hardware has stopped scanning out the old buffers. 3478c2ecf20Sopenharmony_ci * 3488c2ecf20Sopenharmony_ci * - Events for disabled CRTCs are not allowed, and drivers can ignore 3498c2ecf20Sopenharmony_ci * that case. 3508c2ecf20Sopenharmony_ci * 3518c2ecf20Sopenharmony_ci * For very simple hardware without VBLANK interrupt, enabling 3528c2ecf20Sopenharmony_ci * &struct drm_crtc_state.no_vblank makes DRM's atomic commit helpers 3538c2ecf20Sopenharmony_ci * send a fake VBLANK event at the end of the display update after all 3548c2ecf20Sopenharmony_ci * hardware changes have been applied. See 3558c2ecf20Sopenharmony_ci * drm_atomic_helper_fake_vblank(). 3568c2ecf20Sopenharmony_ci * 3578c2ecf20Sopenharmony_ci * For more complex hardware this 3588c2ecf20Sopenharmony_ci * can be handled by the drm_crtc_send_vblank_event() function, 3598c2ecf20Sopenharmony_ci * which the driver should call on the provided event upon completion of 3608c2ecf20Sopenharmony_ci * the atomic commit. Note that if the driver supports vblank signalling 3618c2ecf20Sopenharmony_ci * and timestamping the vblank counters and timestamps must agree with 3628c2ecf20Sopenharmony_ci * the ones returned from page flip events. With the current vblank 3638c2ecf20Sopenharmony_ci * helper infrastructure this can be achieved by holding a vblank 3648c2ecf20Sopenharmony_ci * reference while the page flip is pending, acquired through 3658c2ecf20Sopenharmony_ci * drm_crtc_vblank_get() and released with drm_crtc_vblank_put(). 3668c2ecf20Sopenharmony_ci * Drivers are free to implement their own vblank counter and timestamp 3678c2ecf20Sopenharmony_ci * tracking though, e.g. if they have accurate timestamp registers in 3688c2ecf20Sopenharmony_ci * hardware. 3698c2ecf20Sopenharmony_ci * 3708c2ecf20Sopenharmony_ci * For hardware which supports some means to synchronize vblank 3718c2ecf20Sopenharmony_ci * interrupt delivery with committing display state there's also 3728c2ecf20Sopenharmony_ci * drm_crtc_arm_vblank_event(). See the documentation of that function 3738c2ecf20Sopenharmony_ci * for a detailed discussion of the constraints it needs to be used 3748c2ecf20Sopenharmony_ci * safely. 3758c2ecf20Sopenharmony_ci * 3768c2ecf20Sopenharmony_ci * If the device can't notify of flip completion in a race-free way 3778c2ecf20Sopenharmony_ci * at all, then the event should be armed just after the page flip is 3788c2ecf20Sopenharmony_ci * committed. In the worst case the driver will send the event to 3798c2ecf20Sopenharmony_ci * userspace one frame too late. This doesn't allow for a real atomic 3808c2ecf20Sopenharmony_ci * update, but it should avoid tearing. 3818c2ecf20Sopenharmony_ci */ 3828c2ecf20Sopenharmony_ci struct drm_pending_vblank_event *event; 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci /** 3858c2ecf20Sopenharmony_ci * @commit: 3868c2ecf20Sopenharmony_ci * 3878c2ecf20Sopenharmony_ci * This tracks how the commit for this update proceeds through the 3888c2ecf20Sopenharmony_ci * various phases. This is never cleared, except when we destroy the 3898c2ecf20Sopenharmony_ci * state, so that subsequent commits can synchronize with previous ones. 3908c2ecf20Sopenharmony_ci */ 3918c2ecf20Sopenharmony_ci struct drm_crtc_commit *commit; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci /** @state: backpointer to global drm_atomic_state */ 3948c2ecf20Sopenharmony_ci struct drm_atomic_state *state; 3958c2ecf20Sopenharmony_ci}; 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci/** 3988c2ecf20Sopenharmony_ci * struct drm_crtc_funcs - control CRTCs for a given device 3998c2ecf20Sopenharmony_ci * 4008c2ecf20Sopenharmony_ci * The drm_crtc_funcs structure is the central CRTC management structure 4018c2ecf20Sopenharmony_ci * in the DRM. Each CRTC controls one or more connectors (note that the name 4028c2ecf20Sopenharmony_ci * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. 4038c2ecf20Sopenharmony_ci * connectors, not just CRTs). 4048c2ecf20Sopenharmony_ci * 4058c2ecf20Sopenharmony_ci * Each driver is responsible for filling out this structure at startup time, 4068c2ecf20Sopenharmony_ci * in addition to providing other modesetting features, like i2c and DDC 4078c2ecf20Sopenharmony_ci * bus accessors. 4088c2ecf20Sopenharmony_ci */ 4098c2ecf20Sopenharmony_cistruct drm_crtc_funcs { 4108c2ecf20Sopenharmony_ci /** 4118c2ecf20Sopenharmony_ci * @reset: 4128c2ecf20Sopenharmony_ci * 4138c2ecf20Sopenharmony_ci * Reset CRTC hardware and software state to off. This function isn't 4148c2ecf20Sopenharmony_ci * called by the core directly, only through drm_mode_config_reset(). 4158c2ecf20Sopenharmony_ci * It's not a helper hook only for historical reasons. 4168c2ecf20Sopenharmony_ci * 4178c2ecf20Sopenharmony_ci * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset 4188c2ecf20Sopenharmony_ci * atomic state using this hook. 4198c2ecf20Sopenharmony_ci */ 4208c2ecf20Sopenharmony_ci void (*reset)(struct drm_crtc *crtc); 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci /** 4238c2ecf20Sopenharmony_ci * @cursor_set: 4248c2ecf20Sopenharmony_ci * 4258c2ecf20Sopenharmony_ci * Update the cursor image. The cursor position is relative to the CRTC 4268c2ecf20Sopenharmony_ci * and can be partially or fully outside of the visible area. 4278c2ecf20Sopenharmony_ci * 4288c2ecf20Sopenharmony_ci * Note that contrary to all other KMS functions the legacy cursor entry 4298c2ecf20Sopenharmony_ci * points don't take a framebuffer object, but instead take directly a 4308c2ecf20Sopenharmony_ci * raw buffer object id from the driver's buffer manager (which is 4318c2ecf20Sopenharmony_ci * either GEM or TTM for current drivers). 4328c2ecf20Sopenharmony_ci * 4338c2ecf20Sopenharmony_ci * This entry point is deprecated, drivers should instead implement 4348c2ecf20Sopenharmony_ci * universal plane support and register a proper cursor plane using 4358c2ecf20Sopenharmony_ci * drm_crtc_init_with_planes(). 4368c2ecf20Sopenharmony_ci * 4378c2ecf20Sopenharmony_ci * This callback is optional 4388c2ecf20Sopenharmony_ci * 4398c2ecf20Sopenharmony_ci * RETURNS: 4408c2ecf20Sopenharmony_ci * 4418c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. 4428c2ecf20Sopenharmony_ci */ 4438c2ecf20Sopenharmony_ci int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, 4448c2ecf20Sopenharmony_ci uint32_t handle, uint32_t width, uint32_t height); 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci /** 4478c2ecf20Sopenharmony_ci * @cursor_set2: 4488c2ecf20Sopenharmony_ci * 4498c2ecf20Sopenharmony_ci * Update the cursor image, including hotspot information. The hotspot 4508c2ecf20Sopenharmony_ci * must not affect the cursor position in CRTC coordinates, but is only 4518c2ecf20Sopenharmony_ci * meant as a hint for virtualized display hardware to coordinate the 4528c2ecf20Sopenharmony_ci * guests and hosts cursor position. The cursor hotspot is relative to 4538c2ecf20Sopenharmony_ci * the cursor image. Otherwise this works exactly like @cursor_set. 4548c2ecf20Sopenharmony_ci * 4558c2ecf20Sopenharmony_ci * This entry point is deprecated, drivers should instead implement 4568c2ecf20Sopenharmony_ci * universal plane support and register a proper cursor plane using 4578c2ecf20Sopenharmony_ci * drm_crtc_init_with_planes(). 4588c2ecf20Sopenharmony_ci * 4598c2ecf20Sopenharmony_ci * This callback is optional. 4608c2ecf20Sopenharmony_ci * 4618c2ecf20Sopenharmony_ci * RETURNS: 4628c2ecf20Sopenharmony_ci * 4638c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. 4648c2ecf20Sopenharmony_ci */ 4658c2ecf20Sopenharmony_ci int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, 4668c2ecf20Sopenharmony_ci uint32_t handle, uint32_t width, uint32_t height, 4678c2ecf20Sopenharmony_ci int32_t hot_x, int32_t hot_y); 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci /** 4708c2ecf20Sopenharmony_ci * @cursor_move: 4718c2ecf20Sopenharmony_ci * 4728c2ecf20Sopenharmony_ci * Update the cursor position. The cursor does not need to be visible 4738c2ecf20Sopenharmony_ci * when this hook is called. 4748c2ecf20Sopenharmony_ci * 4758c2ecf20Sopenharmony_ci * This entry point is deprecated, drivers should instead implement 4768c2ecf20Sopenharmony_ci * universal plane support and register a proper cursor plane using 4778c2ecf20Sopenharmony_ci * drm_crtc_init_with_planes(). 4788c2ecf20Sopenharmony_ci * 4798c2ecf20Sopenharmony_ci * This callback is optional. 4808c2ecf20Sopenharmony_ci * 4818c2ecf20Sopenharmony_ci * RETURNS: 4828c2ecf20Sopenharmony_ci * 4838c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. 4848c2ecf20Sopenharmony_ci */ 4858c2ecf20Sopenharmony_ci int (*cursor_move)(struct drm_crtc *crtc, int x, int y); 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci /** 4888c2ecf20Sopenharmony_ci * @gamma_set: 4898c2ecf20Sopenharmony_ci * 4908c2ecf20Sopenharmony_ci * Set gamma on the CRTC. 4918c2ecf20Sopenharmony_ci * 4928c2ecf20Sopenharmony_ci * This callback is optional. 4938c2ecf20Sopenharmony_ci * 4948c2ecf20Sopenharmony_ci * Atomic drivers who want to support gamma tables should implement the 4958c2ecf20Sopenharmony_ci * atomic color management support, enabled by calling 4968c2ecf20Sopenharmony_ci * drm_crtc_enable_color_mgmt(), which then supports the legacy gamma 4978c2ecf20Sopenharmony_ci * interface through the drm_atomic_helper_legacy_gamma_set() 4988c2ecf20Sopenharmony_ci * compatibility implementation. 4998c2ecf20Sopenharmony_ci */ 5008c2ecf20Sopenharmony_ci int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 5018c2ecf20Sopenharmony_ci uint32_t size, 5028c2ecf20Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ci /** 5058c2ecf20Sopenharmony_ci * @destroy: 5068c2ecf20Sopenharmony_ci * 5078c2ecf20Sopenharmony_ci * Clean up CRTC resources. This is only called at driver unload time 5088c2ecf20Sopenharmony_ci * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged 5098c2ecf20Sopenharmony_ci * in DRM. 5108c2ecf20Sopenharmony_ci */ 5118c2ecf20Sopenharmony_ci void (*destroy)(struct drm_crtc *crtc); 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci /** 5148c2ecf20Sopenharmony_ci * @set_config: 5158c2ecf20Sopenharmony_ci * 5168c2ecf20Sopenharmony_ci * This is the main legacy entry point to change the modeset state on a 5178c2ecf20Sopenharmony_ci * CRTC. All the details of the desired configuration are passed in a 5188c2ecf20Sopenharmony_ci * &struct drm_mode_set - see there for details. 5198c2ecf20Sopenharmony_ci * 5208c2ecf20Sopenharmony_ci * Drivers implementing atomic modeset should use 5218c2ecf20Sopenharmony_ci * drm_atomic_helper_set_config() to implement this hook. 5228c2ecf20Sopenharmony_ci * 5238c2ecf20Sopenharmony_ci * RETURNS: 5248c2ecf20Sopenharmony_ci * 5258c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. 5268c2ecf20Sopenharmony_ci */ 5278c2ecf20Sopenharmony_ci int (*set_config)(struct drm_mode_set *set, 5288c2ecf20Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci /** 5318c2ecf20Sopenharmony_ci * @page_flip: 5328c2ecf20Sopenharmony_ci * 5338c2ecf20Sopenharmony_ci * Legacy entry point to schedule a flip to the given framebuffer. 5348c2ecf20Sopenharmony_ci * 5358c2ecf20Sopenharmony_ci * Page flipping is a synchronization mechanism that replaces the frame 5368c2ecf20Sopenharmony_ci * buffer being scanned out by the CRTC with a new frame buffer during 5378c2ecf20Sopenharmony_ci * vertical blanking, avoiding tearing (except when requested otherwise 5388c2ecf20Sopenharmony_ci * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application 5398c2ecf20Sopenharmony_ci * requests a page flip the DRM core verifies that the new frame buffer 5408c2ecf20Sopenharmony_ci * is large enough to be scanned out by the CRTC in the currently 5418c2ecf20Sopenharmony_ci * configured mode and then calls this hook with a pointer to the new 5428c2ecf20Sopenharmony_ci * frame buffer. 5438c2ecf20Sopenharmony_ci * 5448c2ecf20Sopenharmony_ci * The driver must wait for any pending rendering to the new framebuffer 5458c2ecf20Sopenharmony_ci * to complete before executing the flip. It should also wait for any 5468c2ecf20Sopenharmony_ci * pending rendering from other drivers if the underlying buffer is a 5478c2ecf20Sopenharmony_ci * shared dma-buf. 5488c2ecf20Sopenharmony_ci * 5498c2ecf20Sopenharmony_ci * An application can request to be notified when the page flip has 5508c2ecf20Sopenharmony_ci * completed. The drm core will supply a &struct drm_event in the event 5518c2ecf20Sopenharmony_ci * parameter in this case. This can be handled by the 5528c2ecf20Sopenharmony_ci * drm_crtc_send_vblank_event() function, which the driver should call on 5538c2ecf20Sopenharmony_ci * the provided event upon completion of the flip. Note that if 5548c2ecf20Sopenharmony_ci * the driver supports vblank signalling and timestamping the vblank 5558c2ecf20Sopenharmony_ci * counters and timestamps must agree with the ones returned from page 5568c2ecf20Sopenharmony_ci * flip events. With the current vblank helper infrastructure this can 5578c2ecf20Sopenharmony_ci * be achieved by holding a vblank reference while the page flip is 5588c2ecf20Sopenharmony_ci * pending, acquired through drm_crtc_vblank_get() and released with 5598c2ecf20Sopenharmony_ci * drm_crtc_vblank_put(). Drivers are free to implement their own vblank 5608c2ecf20Sopenharmony_ci * counter and timestamp tracking though, e.g. if they have accurate 5618c2ecf20Sopenharmony_ci * timestamp registers in hardware. 5628c2ecf20Sopenharmony_ci * 5638c2ecf20Sopenharmony_ci * This callback is optional. 5648c2ecf20Sopenharmony_ci * 5658c2ecf20Sopenharmony_ci * NOTE: 5668c2ecf20Sopenharmony_ci * 5678c2ecf20Sopenharmony_ci * Very early versions of the KMS ABI mandated that the driver must 5688c2ecf20Sopenharmony_ci * block (but not reject) any rendering to the old framebuffer until the 5698c2ecf20Sopenharmony_ci * flip operation has completed and the old framebuffer is no longer 5708c2ecf20Sopenharmony_ci * visible. This requirement has been lifted, and userspace is instead 5718c2ecf20Sopenharmony_ci * expected to request delivery of an event and wait with recycling old 5728c2ecf20Sopenharmony_ci * buffers until such has been received. 5738c2ecf20Sopenharmony_ci * 5748c2ecf20Sopenharmony_ci * RETURNS: 5758c2ecf20Sopenharmony_ci * 5768c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. Note that if a 5778c2ecf20Sopenharmony_ci * page flip operation is already pending the callback should return 5788c2ecf20Sopenharmony_ci * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode 5798c2ecf20Sopenharmony_ci * or just runtime disabled through DPMS respectively the new atomic 5808c2ecf20Sopenharmony_ci * "ACTIVE" state) should result in an -EINVAL error code. Note that 5818c2ecf20Sopenharmony_ci * drm_atomic_helper_page_flip() checks this already for atomic drivers. 5828c2ecf20Sopenharmony_ci */ 5838c2ecf20Sopenharmony_ci int (*page_flip)(struct drm_crtc *crtc, 5848c2ecf20Sopenharmony_ci struct drm_framebuffer *fb, 5858c2ecf20Sopenharmony_ci struct drm_pending_vblank_event *event, 5868c2ecf20Sopenharmony_ci uint32_t flags, 5878c2ecf20Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_ci /** 5908c2ecf20Sopenharmony_ci * @page_flip_target: 5918c2ecf20Sopenharmony_ci * 5928c2ecf20Sopenharmony_ci * Same as @page_flip but with an additional parameter specifying the 5938c2ecf20Sopenharmony_ci * absolute target vertical blank period (as reported by 5948c2ecf20Sopenharmony_ci * drm_crtc_vblank_count()) when the flip should take effect. 5958c2ecf20Sopenharmony_ci * 5968c2ecf20Sopenharmony_ci * Note that the core code calls drm_crtc_vblank_get before this entry 5978c2ecf20Sopenharmony_ci * point, and will call drm_crtc_vblank_put if this entry point returns 5988c2ecf20Sopenharmony_ci * any non-0 error code. It's the driver's responsibility to call 5998c2ecf20Sopenharmony_ci * drm_crtc_vblank_put after this entry point returns 0, typically when 6008c2ecf20Sopenharmony_ci * the flip completes. 6018c2ecf20Sopenharmony_ci */ 6028c2ecf20Sopenharmony_ci int (*page_flip_target)(struct drm_crtc *crtc, 6038c2ecf20Sopenharmony_ci struct drm_framebuffer *fb, 6048c2ecf20Sopenharmony_ci struct drm_pending_vblank_event *event, 6058c2ecf20Sopenharmony_ci uint32_t flags, uint32_t target, 6068c2ecf20Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci /** 6098c2ecf20Sopenharmony_ci * @set_property: 6108c2ecf20Sopenharmony_ci * 6118c2ecf20Sopenharmony_ci * This is the legacy entry point to update a property attached to the 6128c2ecf20Sopenharmony_ci * CRTC. 6138c2ecf20Sopenharmony_ci * 6148c2ecf20Sopenharmony_ci * This callback is optional if the driver does not support any legacy 6158c2ecf20Sopenharmony_ci * driver-private properties. For atomic drivers it is not used because 6168c2ecf20Sopenharmony_ci * property handling is done entirely in the DRM core. 6178c2ecf20Sopenharmony_ci * 6188c2ecf20Sopenharmony_ci * RETURNS: 6198c2ecf20Sopenharmony_ci * 6208c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. 6218c2ecf20Sopenharmony_ci */ 6228c2ecf20Sopenharmony_ci int (*set_property)(struct drm_crtc *crtc, 6238c2ecf20Sopenharmony_ci struct drm_property *property, uint64_t val); 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci /** 6268c2ecf20Sopenharmony_ci * @atomic_duplicate_state: 6278c2ecf20Sopenharmony_ci * 6288c2ecf20Sopenharmony_ci * Duplicate the current atomic state for this CRTC and return it. 6298c2ecf20Sopenharmony_ci * The core and helpers guarantee that any atomic state duplicated with 6308c2ecf20Sopenharmony_ci * this hook and still owned by the caller (i.e. not transferred to the 6318c2ecf20Sopenharmony_ci * driver by calling &drm_mode_config_funcs.atomic_commit) will be 6328c2ecf20Sopenharmony_ci * cleaned up by calling the @atomic_destroy_state hook in this 6338c2ecf20Sopenharmony_ci * structure. 6348c2ecf20Sopenharmony_ci * 6358c2ecf20Sopenharmony_ci * This callback is mandatory for atomic drivers. 6368c2ecf20Sopenharmony_ci * 6378c2ecf20Sopenharmony_ci * Atomic drivers which don't subclass &struct drm_crtc_state should use 6388c2ecf20Sopenharmony_ci * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the 6398c2ecf20Sopenharmony_ci * state structure to extend it with driver-private state should use 6408c2ecf20Sopenharmony_ci * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is 6418c2ecf20Sopenharmony_ci * duplicated in a consistent fashion across drivers. 6428c2ecf20Sopenharmony_ci * 6438c2ecf20Sopenharmony_ci * It is an error to call this hook before &drm_crtc.state has been 6448c2ecf20Sopenharmony_ci * initialized correctly. 6458c2ecf20Sopenharmony_ci * 6468c2ecf20Sopenharmony_ci * NOTE: 6478c2ecf20Sopenharmony_ci * 6488c2ecf20Sopenharmony_ci * If the duplicate state references refcounted resources this hook must 6498c2ecf20Sopenharmony_ci * acquire a reference for each of them. The driver must release these 6508c2ecf20Sopenharmony_ci * references again in @atomic_destroy_state. 6518c2ecf20Sopenharmony_ci * 6528c2ecf20Sopenharmony_ci * RETURNS: 6538c2ecf20Sopenharmony_ci * 6548c2ecf20Sopenharmony_ci * Duplicated atomic state or NULL when the allocation failed. 6558c2ecf20Sopenharmony_ci */ 6568c2ecf20Sopenharmony_ci struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci /** 6598c2ecf20Sopenharmony_ci * @atomic_destroy_state: 6608c2ecf20Sopenharmony_ci * 6618c2ecf20Sopenharmony_ci * Destroy a state duplicated with @atomic_duplicate_state and release 6628c2ecf20Sopenharmony_ci * or unreference all resources it references 6638c2ecf20Sopenharmony_ci * 6648c2ecf20Sopenharmony_ci * This callback is mandatory for atomic drivers. 6658c2ecf20Sopenharmony_ci */ 6668c2ecf20Sopenharmony_ci void (*atomic_destroy_state)(struct drm_crtc *crtc, 6678c2ecf20Sopenharmony_ci struct drm_crtc_state *state); 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci /** 6708c2ecf20Sopenharmony_ci * @atomic_set_property: 6718c2ecf20Sopenharmony_ci * 6728c2ecf20Sopenharmony_ci * Decode a driver-private property value and store the decoded value 6738c2ecf20Sopenharmony_ci * into the passed-in state structure. Since the atomic core decodes all 6748c2ecf20Sopenharmony_ci * standardized properties (even for extensions beyond the core set of 6758c2ecf20Sopenharmony_ci * properties which might not be implemented by all drivers) this 6768c2ecf20Sopenharmony_ci * requires drivers to subclass the state structure. 6778c2ecf20Sopenharmony_ci * 6788c2ecf20Sopenharmony_ci * Such driver-private properties should really only be implemented for 6798c2ecf20Sopenharmony_ci * truly hardware/vendor specific state. Instead it is preferred to 6808c2ecf20Sopenharmony_ci * standardize atomic extension and decode the properties used to expose 6818c2ecf20Sopenharmony_ci * such an extension in the core. 6828c2ecf20Sopenharmony_ci * 6838c2ecf20Sopenharmony_ci * Do not call this function directly, use 6848c2ecf20Sopenharmony_ci * drm_atomic_crtc_set_property() instead. 6858c2ecf20Sopenharmony_ci * 6868c2ecf20Sopenharmony_ci * This callback is optional if the driver does not support any 6878c2ecf20Sopenharmony_ci * driver-private atomic properties. 6888c2ecf20Sopenharmony_ci * 6898c2ecf20Sopenharmony_ci * NOTE: 6908c2ecf20Sopenharmony_ci * 6918c2ecf20Sopenharmony_ci * This function is called in the state assembly phase of atomic 6928c2ecf20Sopenharmony_ci * modesets, which can be aborted for any reason (including on 6938c2ecf20Sopenharmony_ci * userspace's request to just check whether a configuration would be 6948c2ecf20Sopenharmony_ci * possible). Drivers MUST NOT touch any persistent state (hardware or 6958c2ecf20Sopenharmony_ci * software) or data structures except the passed in @state parameter. 6968c2ecf20Sopenharmony_ci * 6978c2ecf20Sopenharmony_ci * Also since userspace controls in which order properties are set this 6988c2ecf20Sopenharmony_ci * function must not do any input validation (since the state update is 6998c2ecf20Sopenharmony_ci * incomplete and hence likely inconsistent). Instead any such input 7008c2ecf20Sopenharmony_ci * validation must be done in the various atomic_check callbacks. 7018c2ecf20Sopenharmony_ci * 7028c2ecf20Sopenharmony_ci * RETURNS: 7038c2ecf20Sopenharmony_ci * 7048c2ecf20Sopenharmony_ci * 0 if the property has been found, -EINVAL if the property isn't 7058c2ecf20Sopenharmony_ci * implemented by the driver (which should never happen, the core only 7068c2ecf20Sopenharmony_ci * asks for properties attached to this CRTC). No other validation is 7078c2ecf20Sopenharmony_ci * allowed by the driver. The core already checks that the property 7088c2ecf20Sopenharmony_ci * value is within the range (integer, valid enum value, ...) the driver 7098c2ecf20Sopenharmony_ci * set when registering the property. 7108c2ecf20Sopenharmony_ci */ 7118c2ecf20Sopenharmony_ci int (*atomic_set_property)(struct drm_crtc *crtc, 7128c2ecf20Sopenharmony_ci struct drm_crtc_state *state, 7138c2ecf20Sopenharmony_ci struct drm_property *property, 7148c2ecf20Sopenharmony_ci uint64_t val); 7158c2ecf20Sopenharmony_ci /** 7168c2ecf20Sopenharmony_ci * @atomic_get_property: 7178c2ecf20Sopenharmony_ci * 7188c2ecf20Sopenharmony_ci * Reads out the decoded driver-private property. This is used to 7198c2ecf20Sopenharmony_ci * implement the GETCRTC IOCTL. 7208c2ecf20Sopenharmony_ci * 7218c2ecf20Sopenharmony_ci * Do not call this function directly, use 7228c2ecf20Sopenharmony_ci * drm_atomic_crtc_get_property() instead. 7238c2ecf20Sopenharmony_ci * 7248c2ecf20Sopenharmony_ci * This callback is optional if the driver does not support any 7258c2ecf20Sopenharmony_ci * driver-private atomic properties. 7268c2ecf20Sopenharmony_ci * 7278c2ecf20Sopenharmony_ci * RETURNS: 7288c2ecf20Sopenharmony_ci * 7298c2ecf20Sopenharmony_ci * 0 on success, -EINVAL if the property isn't implemented by the 7308c2ecf20Sopenharmony_ci * driver (which should never happen, the core only asks for 7318c2ecf20Sopenharmony_ci * properties attached to this CRTC). 7328c2ecf20Sopenharmony_ci */ 7338c2ecf20Sopenharmony_ci int (*atomic_get_property)(struct drm_crtc *crtc, 7348c2ecf20Sopenharmony_ci const struct drm_crtc_state *state, 7358c2ecf20Sopenharmony_ci struct drm_property *property, 7368c2ecf20Sopenharmony_ci uint64_t *val); 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_ci /** 7398c2ecf20Sopenharmony_ci * @late_register: 7408c2ecf20Sopenharmony_ci * 7418c2ecf20Sopenharmony_ci * This optional hook can be used to register additional userspace 7428c2ecf20Sopenharmony_ci * interfaces attached to the crtc like debugfs interfaces. 7438c2ecf20Sopenharmony_ci * It is called late in the driver load sequence from drm_dev_register(). 7448c2ecf20Sopenharmony_ci * Everything added from this callback should be unregistered in 7458c2ecf20Sopenharmony_ci * the early_unregister callback. 7468c2ecf20Sopenharmony_ci * 7478c2ecf20Sopenharmony_ci * Returns: 7488c2ecf20Sopenharmony_ci * 7498c2ecf20Sopenharmony_ci * 0 on success, or a negative error code on failure. 7508c2ecf20Sopenharmony_ci */ 7518c2ecf20Sopenharmony_ci int (*late_register)(struct drm_crtc *crtc); 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_ci /** 7548c2ecf20Sopenharmony_ci * @early_unregister: 7558c2ecf20Sopenharmony_ci * 7568c2ecf20Sopenharmony_ci * This optional hook should be used to unregister the additional 7578c2ecf20Sopenharmony_ci * userspace interfaces attached to the crtc from 7588c2ecf20Sopenharmony_ci * @late_register. It is called from drm_dev_unregister(), 7598c2ecf20Sopenharmony_ci * early in the driver unload sequence to disable userspace access 7608c2ecf20Sopenharmony_ci * before data structures are torndown. 7618c2ecf20Sopenharmony_ci */ 7628c2ecf20Sopenharmony_ci void (*early_unregister)(struct drm_crtc *crtc); 7638c2ecf20Sopenharmony_ci 7648c2ecf20Sopenharmony_ci /** 7658c2ecf20Sopenharmony_ci * @set_crc_source: 7668c2ecf20Sopenharmony_ci * 7678c2ecf20Sopenharmony_ci * Changes the source of CRC checksums of frames at the request of 7688c2ecf20Sopenharmony_ci * userspace, typically for testing purposes. The sources available are 7698c2ecf20Sopenharmony_ci * specific of each driver and a %NULL value indicates that CRC 7708c2ecf20Sopenharmony_ci * generation is to be switched off. 7718c2ecf20Sopenharmony_ci * 7728c2ecf20Sopenharmony_ci * When CRC generation is enabled, the driver should call 7738c2ecf20Sopenharmony_ci * drm_crtc_add_crc_entry() at each frame, providing any information 7748c2ecf20Sopenharmony_ci * that characterizes the frame contents in the crcN arguments, as 7758c2ecf20Sopenharmony_ci * provided from the configured source. Drivers must accept an "auto" 7768c2ecf20Sopenharmony_ci * source name that will select a default source for this CRTC. 7778c2ecf20Sopenharmony_ci * 7788c2ecf20Sopenharmony_ci * This may trigger an atomic modeset commit if necessary, to enable CRC 7798c2ecf20Sopenharmony_ci * generation. 7808c2ecf20Sopenharmony_ci * 7818c2ecf20Sopenharmony_ci * Note that "auto" can depend upon the current modeset configuration, 7828c2ecf20Sopenharmony_ci * e.g. it could pick an encoder or output specific CRC sampling point. 7838c2ecf20Sopenharmony_ci * 7848c2ecf20Sopenharmony_ci * This callback is optional if the driver does not support any CRC 7858c2ecf20Sopenharmony_ci * generation functionality. 7868c2ecf20Sopenharmony_ci * 7878c2ecf20Sopenharmony_ci * RETURNS: 7888c2ecf20Sopenharmony_ci * 7898c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. 7908c2ecf20Sopenharmony_ci */ 7918c2ecf20Sopenharmony_ci int (*set_crc_source)(struct drm_crtc *crtc, const char *source); 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci /** 7948c2ecf20Sopenharmony_ci * @verify_crc_source: 7958c2ecf20Sopenharmony_ci * 7968c2ecf20Sopenharmony_ci * verifies the source of CRC checksums of frames before setting the 7978c2ecf20Sopenharmony_ci * source for CRC and during crc open. Source parameter can be NULL 7988c2ecf20Sopenharmony_ci * while disabling crc source. 7998c2ecf20Sopenharmony_ci * 8008c2ecf20Sopenharmony_ci * This callback is optional if the driver does not support any CRC 8018c2ecf20Sopenharmony_ci * generation functionality. 8028c2ecf20Sopenharmony_ci * 8038c2ecf20Sopenharmony_ci * RETURNS: 8048c2ecf20Sopenharmony_ci * 8058c2ecf20Sopenharmony_ci * 0 on success or a negative error code on failure. 8068c2ecf20Sopenharmony_ci */ 8078c2ecf20Sopenharmony_ci int (*verify_crc_source)(struct drm_crtc *crtc, const char *source, 8088c2ecf20Sopenharmony_ci size_t *values_cnt); 8098c2ecf20Sopenharmony_ci /** 8108c2ecf20Sopenharmony_ci * @get_crc_sources: 8118c2ecf20Sopenharmony_ci * 8128c2ecf20Sopenharmony_ci * Driver callback for getting a list of all the available sources for 8138c2ecf20Sopenharmony_ci * CRC generation. This callback depends upon verify_crc_source, So 8148c2ecf20Sopenharmony_ci * verify_crc_source callback should be implemented before implementing 8158c2ecf20Sopenharmony_ci * this. Driver can pass full list of available crc sources, this 8168c2ecf20Sopenharmony_ci * callback does the verification on each crc-source before passing it 8178c2ecf20Sopenharmony_ci * to userspace. 8188c2ecf20Sopenharmony_ci * 8198c2ecf20Sopenharmony_ci * This callback is optional if the driver does not support exporting of 8208c2ecf20Sopenharmony_ci * possible CRC sources list. 8218c2ecf20Sopenharmony_ci * 8228c2ecf20Sopenharmony_ci * RETURNS: 8238c2ecf20Sopenharmony_ci * 8248c2ecf20Sopenharmony_ci * a constant character pointer to the list of all the available CRC 8258c2ecf20Sopenharmony_ci * sources. On failure driver should return NULL. count should be 8268c2ecf20Sopenharmony_ci * updated with number of sources in list. if zero we don't process any 8278c2ecf20Sopenharmony_ci * source from the list. 8288c2ecf20Sopenharmony_ci */ 8298c2ecf20Sopenharmony_ci const char *const *(*get_crc_sources)(struct drm_crtc *crtc, 8308c2ecf20Sopenharmony_ci size_t *count); 8318c2ecf20Sopenharmony_ci 8328c2ecf20Sopenharmony_ci /** 8338c2ecf20Sopenharmony_ci * @atomic_print_state: 8348c2ecf20Sopenharmony_ci * 8358c2ecf20Sopenharmony_ci * If driver subclasses &struct drm_crtc_state, it should implement 8368c2ecf20Sopenharmony_ci * this optional hook for printing additional driver specific state. 8378c2ecf20Sopenharmony_ci * 8388c2ecf20Sopenharmony_ci * Do not call this directly, use drm_atomic_crtc_print_state() 8398c2ecf20Sopenharmony_ci * instead. 8408c2ecf20Sopenharmony_ci */ 8418c2ecf20Sopenharmony_ci void (*atomic_print_state)(struct drm_printer *p, 8428c2ecf20Sopenharmony_ci const struct drm_crtc_state *state); 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci /** 8458c2ecf20Sopenharmony_ci * @get_vblank_counter: 8468c2ecf20Sopenharmony_ci * 8478c2ecf20Sopenharmony_ci * Driver callback for fetching a raw hardware vblank counter for the 8488c2ecf20Sopenharmony_ci * CRTC. It's meant to be used by new drivers as the replacement of 8498c2ecf20Sopenharmony_ci * &drm_driver.get_vblank_counter hook. 8508c2ecf20Sopenharmony_ci * 8518c2ecf20Sopenharmony_ci * This callback is optional. If a device doesn't have a hardware 8528c2ecf20Sopenharmony_ci * counter, the driver can simply leave the hook as NULL. The DRM core 8538c2ecf20Sopenharmony_ci * will account for missed vblank events while interrupts where disabled 8548c2ecf20Sopenharmony_ci * based on system timestamps. 8558c2ecf20Sopenharmony_ci * 8568c2ecf20Sopenharmony_ci * Wraparound handling and loss of events due to modesetting is dealt 8578c2ecf20Sopenharmony_ci * with in the DRM core code, as long as drivers call 8588c2ecf20Sopenharmony_ci * drm_crtc_vblank_off() and drm_crtc_vblank_on() when disabling or 8598c2ecf20Sopenharmony_ci * enabling a CRTC. 8608c2ecf20Sopenharmony_ci * 8618c2ecf20Sopenharmony_ci * See also &drm_device.vblank_disable_immediate and 8628c2ecf20Sopenharmony_ci * &drm_device.max_vblank_count. 8638c2ecf20Sopenharmony_ci * 8648c2ecf20Sopenharmony_ci * Returns: 8658c2ecf20Sopenharmony_ci * 8668c2ecf20Sopenharmony_ci * Raw vblank counter value. 8678c2ecf20Sopenharmony_ci */ 8688c2ecf20Sopenharmony_ci u32 (*get_vblank_counter)(struct drm_crtc *crtc); 8698c2ecf20Sopenharmony_ci 8708c2ecf20Sopenharmony_ci /** 8718c2ecf20Sopenharmony_ci * @enable_vblank: 8728c2ecf20Sopenharmony_ci * 8738c2ecf20Sopenharmony_ci * Enable vblank interrupts for the CRTC. It's meant to be used by 8748c2ecf20Sopenharmony_ci * new drivers as the replacement of &drm_driver.enable_vblank hook. 8758c2ecf20Sopenharmony_ci * 8768c2ecf20Sopenharmony_ci * Returns: 8778c2ecf20Sopenharmony_ci * 8788c2ecf20Sopenharmony_ci * Zero on success, appropriate errno if the vblank interrupt cannot 8798c2ecf20Sopenharmony_ci * be enabled. 8808c2ecf20Sopenharmony_ci */ 8818c2ecf20Sopenharmony_ci int (*enable_vblank)(struct drm_crtc *crtc); 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ci /** 8848c2ecf20Sopenharmony_ci * @disable_vblank: 8858c2ecf20Sopenharmony_ci * 8868c2ecf20Sopenharmony_ci * Disable vblank interrupts for the CRTC. It's meant to be used by 8878c2ecf20Sopenharmony_ci * new drivers as the replacement of &drm_driver.disable_vblank hook. 8888c2ecf20Sopenharmony_ci */ 8898c2ecf20Sopenharmony_ci void (*disable_vblank)(struct drm_crtc *crtc); 8908c2ecf20Sopenharmony_ci 8918c2ecf20Sopenharmony_ci /** 8928c2ecf20Sopenharmony_ci * @get_vblank_timestamp: 8938c2ecf20Sopenharmony_ci * 8948c2ecf20Sopenharmony_ci * Called by drm_get_last_vbltimestamp(). Should return a precise 8958c2ecf20Sopenharmony_ci * timestamp when the most recent vblank interval ended or will end. 8968c2ecf20Sopenharmony_ci * 8978c2ecf20Sopenharmony_ci * Specifically, the timestamp in @vblank_time should correspond as 8988c2ecf20Sopenharmony_ci * closely as possible to the time when the first video scanline of 8998c2ecf20Sopenharmony_ci * the video frame after the end of vblank will start scanning out, 9008c2ecf20Sopenharmony_ci * the time immediately after end of the vblank interval. If the 9018c2ecf20Sopenharmony_ci * @crtc is currently inside vblank, this will be a time in the future. 9028c2ecf20Sopenharmony_ci * If the @crtc is currently scanning out a frame, this will be the 9038c2ecf20Sopenharmony_ci * past start time of the current scanout. This is meant to adhere 9048c2ecf20Sopenharmony_ci * to the OpenML OML_sync_control extension specification. 9058c2ecf20Sopenharmony_ci * 9068c2ecf20Sopenharmony_ci * Parameters: 9078c2ecf20Sopenharmony_ci * 9088c2ecf20Sopenharmony_ci * crtc: 9098c2ecf20Sopenharmony_ci * CRTC for which timestamp should be returned. 9108c2ecf20Sopenharmony_ci * max_error: 9118c2ecf20Sopenharmony_ci * Maximum allowable timestamp error in nanoseconds. 9128c2ecf20Sopenharmony_ci * Implementation should strive to provide timestamp 9138c2ecf20Sopenharmony_ci * with an error of at most max_error nanoseconds. 9148c2ecf20Sopenharmony_ci * Returns true upper bound on error for timestamp. 9158c2ecf20Sopenharmony_ci * vblank_time: 9168c2ecf20Sopenharmony_ci * Target location for returned vblank timestamp. 9178c2ecf20Sopenharmony_ci * in_vblank_irq: 9188c2ecf20Sopenharmony_ci * True when called from drm_crtc_handle_vblank(). Some drivers 9198c2ecf20Sopenharmony_ci * need to apply some workarounds for gpu-specific vblank irq quirks 9208c2ecf20Sopenharmony_ci * if flag is set. 9218c2ecf20Sopenharmony_ci * 9228c2ecf20Sopenharmony_ci * Returns: 9238c2ecf20Sopenharmony_ci * 9248c2ecf20Sopenharmony_ci * True on success, false on failure, which means the core should 9258c2ecf20Sopenharmony_ci * fallback to a simple timestamp taken in drm_crtc_handle_vblank(). 9268c2ecf20Sopenharmony_ci */ 9278c2ecf20Sopenharmony_ci bool (*get_vblank_timestamp)(struct drm_crtc *crtc, 9288c2ecf20Sopenharmony_ci int *max_error, 9298c2ecf20Sopenharmony_ci ktime_t *vblank_time, 9308c2ecf20Sopenharmony_ci bool in_vblank_irq); 9318c2ecf20Sopenharmony_ci}; 9328c2ecf20Sopenharmony_ci 9338c2ecf20Sopenharmony_ci/** 9348c2ecf20Sopenharmony_ci * struct drm_crtc - central CRTC control structure 9358c2ecf20Sopenharmony_ci * 9368c2ecf20Sopenharmony_ci * Each CRTC may have one or more connectors associated with it. This structure 9378c2ecf20Sopenharmony_ci * allows the CRTC to be controlled. 9388c2ecf20Sopenharmony_ci */ 9398c2ecf20Sopenharmony_cistruct drm_crtc { 9408c2ecf20Sopenharmony_ci /** @dev: parent DRM device */ 9418c2ecf20Sopenharmony_ci struct drm_device *dev; 9428c2ecf20Sopenharmony_ci /** @port: OF node used by drm_of_find_possible_crtcs(). */ 9438c2ecf20Sopenharmony_ci struct device_node *port; 9448c2ecf20Sopenharmony_ci /** 9458c2ecf20Sopenharmony_ci * @head: 9468c2ecf20Sopenharmony_ci * 9478c2ecf20Sopenharmony_ci * List of all CRTCs on @dev, linked from &drm_mode_config.crtc_list. 9488c2ecf20Sopenharmony_ci * Invariant over the lifetime of @dev and therefore does not need 9498c2ecf20Sopenharmony_ci * locking. 9508c2ecf20Sopenharmony_ci */ 9518c2ecf20Sopenharmony_ci struct list_head head; 9528c2ecf20Sopenharmony_ci 9538c2ecf20Sopenharmony_ci /** @name: human readable name, can be overwritten by the driver */ 9548c2ecf20Sopenharmony_ci char *name; 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_ci /** 9578c2ecf20Sopenharmony_ci * @mutex: 9588c2ecf20Sopenharmony_ci * 9598c2ecf20Sopenharmony_ci * This provides a read lock for the overall CRTC state (mode, dpms 9608c2ecf20Sopenharmony_ci * state, ...) and a write lock for everything which can be update 9618c2ecf20Sopenharmony_ci * without a full modeset (fb, cursor data, CRTC properties ...). A full 9628c2ecf20Sopenharmony_ci * modeset also need to grab &drm_mode_config.connection_mutex. 9638c2ecf20Sopenharmony_ci * 9648c2ecf20Sopenharmony_ci * For atomic drivers specifically this protects @state. 9658c2ecf20Sopenharmony_ci */ 9668c2ecf20Sopenharmony_ci struct drm_modeset_lock mutex; 9678c2ecf20Sopenharmony_ci 9688c2ecf20Sopenharmony_ci /** @base: base KMS object for ID tracking etc. */ 9698c2ecf20Sopenharmony_ci struct drm_mode_object base; 9708c2ecf20Sopenharmony_ci 9718c2ecf20Sopenharmony_ci /** 9728c2ecf20Sopenharmony_ci * @primary: 9738c2ecf20Sopenharmony_ci * Primary plane for this CRTC. Note that this is only 9748c2ecf20Sopenharmony_ci * relevant for legacy IOCTL, it specifies the plane implicitly used by 9758c2ecf20Sopenharmony_ci * the SETCRTC and PAGE_FLIP IOCTLs. It does not have any significance 9768c2ecf20Sopenharmony_ci * beyond that. 9778c2ecf20Sopenharmony_ci */ 9788c2ecf20Sopenharmony_ci struct drm_plane *primary; 9798c2ecf20Sopenharmony_ci 9808c2ecf20Sopenharmony_ci /** 9818c2ecf20Sopenharmony_ci * @cursor: 9828c2ecf20Sopenharmony_ci * Cursor plane for this CRTC. Note that this is only relevant for 9838c2ecf20Sopenharmony_ci * legacy IOCTL, it specifies the plane implicitly used by the SETCURSOR 9848c2ecf20Sopenharmony_ci * and SETCURSOR2 IOCTLs. It does not have any significance 9858c2ecf20Sopenharmony_ci * beyond that. 9868c2ecf20Sopenharmony_ci */ 9878c2ecf20Sopenharmony_ci struct drm_plane *cursor; 9888c2ecf20Sopenharmony_ci 9898c2ecf20Sopenharmony_ci /** 9908c2ecf20Sopenharmony_ci * @index: Position inside the mode_config.list, can be used as an array 9918c2ecf20Sopenharmony_ci * index. It is invariant over the lifetime of the CRTC. 9928c2ecf20Sopenharmony_ci */ 9938c2ecf20Sopenharmony_ci unsigned index; 9948c2ecf20Sopenharmony_ci 9958c2ecf20Sopenharmony_ci /** 9968c2ecf20Sopenharmony_ci * @cursor_x: Current x position of the cursor, used for universal 9978c2ecf20Sopenharmony_ci * cursor planes because the SETCURSOR IOCTL only can update the 9988c2ecf20Sopenharmony_ci * framebuffer without supplying the coordinates. Drivers should not use 9998c2ecf20Sopenharmony_ci * this directly, atomic drivers should look at &drm_plane_state.crtc_x 10008c2ecf20Sopenharmony_ci * of the cursor plane instead. 10018c2ecf20Sopenharmony_ci */ 10028c2ecf20Sopenharmony_ci int cursor_x; 10038c2ecf20Sopenharmony_ci /** 10048c2ecf20Sopenharmony_ci * @cursor_y: Current y position of the cursor, used for universal 10058c2ecf20Sopenharmony_ci * cursor planes because the SETCURSOR IOCTL only can update the 10068c2ecf20Sopenharmony_ci * framebuffer without supplying the coordinates. Drivers should not use 10078c2ecf20Sopenharmony_ci * this directly, atomic drivers should look at &drm_plane_state.crtc_y 10088c2ecf20Sopenharmony_ci * of the cursor plane instead. 10098c2ecf20Sopenharmony_ci */ 10108c2ecf20Sopenharmony_ci int cursor_y; 10118c2ecf20Sopenharmony_ci 10128c2ecf20Sopenharmony_ci /** 10138c2ecf20Sopenharmony_ci * @enabled: 10148c2ecf20Sopenharmony_ci * 10158c2ecf20Sopenharmony_ci * Is this CRTC enabled? Should only be used by legacy drivers, atomic 10168c2ecf20Sopenharmony_ci * drivers should instead consult &drm_crtc_state.enable and 10178c2ecf20Sopenharmony_ci * &drm_crtc_state.active. Atomic drivers can update this by calling 10188c2ecf20Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 10198c2ecf20Sopenharmony_ci */ 10208c2ecf20Sopenharmony_ci bool enabled; 10218c2ecf20Sopenharmony_ci 10228c2ecf20Sopenharmony_ci /** 10238c2ecf20Sopenharmony_ci * @mode: 10248c2ecf20Sopenharmony_ci * 10258c2ecf20Sopenharmony_ci * Current mode timings. Should only be used by legacy drivers, atomic 10268c2ecf20Sopenharmony_ci * drivers should instead consult &drm_crtc_state.mode. Atomic drivers 10278c2ecf20Sopenharmony_ci * can update this by calling 10288c2ecf20Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 10298c2ecf20Sopenharmony_ci */ 10308c2ecf20Sopenharmony_ci struct drm_display_mode mode; 10318c2ecf20Sopenharmony_ci 10328c2ecf20Sopenharmony_ci /** 10338c2ecf20Sopenharmony_ci * @hwmode: 10348c2ecf20Sopenharmony_ci * 10358c2ecf20Sopenharmony_ci * Programmed mode in hw, after adjustments for encoders, crtc, panel 10368c2ecf20Sopenharmony_ci * scaling etc. Should only be used by legacy drivers, for high 10378c2ecf20Sopenharmony_ci * precision vblank timestamps in 10388c2ecf20Sopenharmony_ci * drm_crtc_vblank_helper_get_vblank_timestamp(). 10398c2ecf20Sopenharmony_ci * 10408c2ecf20Sopenharmony_ci * Note that atomic drivers should not use this, but instead use 10418c2ecf20Sopenharmony_ci * &drm_crtc_state.adjusted_mode. And for high-precision timestamps 10428c2ecf20Sopenharmony_ci * drm_crtc_vblank_helper_get_vblank_timestamp() used 10438c2ecf20Sopenharmony_ci * &drm_vblank_crtc.hwmode, 10448c2ecf20Sopenharmony_ci * which is filled out by calling drm_calc_timestamping_constants(). 10458c2ecf20Sopenharmony_ci */ 10468c2ecf20Sopenharmony_ci struct drm_display_mode hwmode; 10478c2ecf20Sopenharmony_ci 10488c2ecf20Sopenharmony_ci /** 10498c2ecf20Sopenharmony_ci * @x: 10508c2ecf20Sopenharmony_ci * x position on screen. Should only be used by legacy drivers, atomic 10518c2ecf20Sopenharmony_ci * drivers should look at &drm_plane_state.crtc_x of the primary plane 10528c2ecf20Sopenharmony_ci * instead. Updated by calling 10538c2ecf20Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 10548c2ecf20Sopenharmony_ci */ 10558c2ecf20Sopenharmony_ci int x; 10568c2ecf20Sopenharmony_ci /** 10578c2ecf20Sopenharmony_ci * @y: 10588c2ecf20Sopenharmony_ci * y position on screen. Should only be used by legacy drivers, atomic 10598c2ecf20Sopenharmony_ci * drivers should look at &drm_plane_state.crtc_y of the primary plane 10608c2ecf20Sopenharmony_ci * instead. Updated by calling 10618c2ecf20Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 10628c2ecf20Sopenharmony_ci */ 10638c2ecf20Sopenharmony_ci int y; 10648c2ecf20Sopenharmony_ci 10658c2ecf20Sopenharmony_ci /** @funcs: CRTC control functions */ 10668c2ecf20Sopenharmony_ci const struct drm_crtc_funcs *funcs; 10678c2ecf20Sopenharmony_ci 10688c2ecf20Sopenharmony_ci /** 10698c2ecf20Sopenharmony_ci * @gamma_size: Size of legacy gamma ramp reported to userspace. Set up 10708c2ecf20Sopenharmony_ci * by calling drm_mode_crtc_set_gamma_size(). 10718c2ecf20Sopenharmony_ci */ 10728c2ecf20Sopenharmony_ci uint32_t gamma_size; 10738c2ecf20Sopenharmony_ci 10748c2ecf20Sopenharmony_ci /** 10758c2ecf20Sopenharmony_ci * @gamma_store: Gamma ramp values used by the legacy SETGAMMA and 10768c2ecf20Sopenharmony_ci * GETGAMMA IOCTls. Set up by calling drm_mode_crtc_set_gamma_size(). 10778c2ecf20Sopenharmony_ci */ 10788c2ecf20Sopenharmony_ci uint16_t *gamma_store; 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_ci /** @helper_private: mid-layer private data */ 10818c2ecf20Sopenharmony_ci const struct drm_crtc_helper_funcs *helper_private; 10828c2ecf20Sopenharmony_ci 10838c2ecf20Sopenharmony_ci /** @properties: property tracking for this CRTC */ 10848c2ecf20Sopenharmony_ci struct drm_object_properties properties; 10858c2ecf20Sopenharmony_ci 10868c2ecf20Sopenharmony_ci /** 10878c2ecf20Sopenharmony_ci * @state: 10888c2ecf20Sopenharmony_ci * 10898c2ecf20Sopenharmony_ci * Current atomic state for this CRTC. 10908c2ecf20Sopenharmony_ci * 10918c2ecf20Sopenharmony_ci * This is protected by @mutex. Note that nonblocking atomic commits 10928c2ecf20Sopenharmony_ci * access the current CRTC state without taking locks. Either by going 10938c2ecf20Sopenharmony_ci * through the &struct drm_atomic_state pointers, see 10948c2ecf20Sopenharmony_ci * for_each_oldnew_crtc_in_state(), for_each_old_crtc_in_state() and 10958c2ecf20Sopenharmony_ci * for_each_new_crtc_in_state(). Or through careful ordering of atomic 10968c2ecf20Sopenharmony_ci * commit operations as implemented in the atomic helpers, see 10978c2ecf20Sopenharmony_ci * &struct drm_crtc_commit. 10988c2ecf20Sopenharmony_ci */ 10998c2ecf20Sopenharmony_ci struct drm_crtc_state *state; 11008c2ecf20Sopenharmony_ci 11018c2ecf20Sopenharmony_ci /** 11028c2ecf20Sopenharmony_ci * @commit_list: 11038c2ecf20Sopenharmony_ci * 11048c2ecf20Sopenharmony_ci * List of &drm_crtc_commit structures tracking pending commits. 11058c2ecf20Sopenharmony_ci * Protected by @commit_lock. This list holds its own full reference, 11068c2ecf20Sopenharmony_ci * as does the ongoing commit. 11078c2ecf20Sopenharmony_ci * 11088c2ecf20Sopenharmony_ci * "Note that the commit for a state change is also tracked in 11098c2ecf20Sopenharmony_ci * &drm_crtc_state.commit. For accessing the immediately preceding 11108c2ecf20Sopenharmony_ci * commit in an atomic update it is recommended to just use that 11118c2ecf20Sopenharmony_ci * pointer in the old CRTC state, since accessing that doesn't need 11128c2ecf20Sopenharmony_ci * any locking or list-walking. @commit_list should only be used to 11138c2ecf20Sopenharmony_ci * stall for framebuffer cleanup that's signalled through 11148c2ecf20Sopenharmony_ci * &drm_crtc_commit.cleanup_done." 11158c2ecf20Sopenharmony_ci */ 11168c2ecf20Sopenharmony_ci struct list_head commit_list; 11178c2ecf20Sopenharmony_ci 11188c2ecf20Sopenharmony_ci /** 11198c2ecf20Sopenharmony_ci * @commit_lock: 11208c2ecf20Sopenharmony_ci * 11218c2ecf20Sopenharmony_ci * Spinlock to protect @commit_list. 11228c2ecf20Sopenharmony_ci */ 11238c2ecf20Sopenharmony_ci spinlock_t commit_lock; 11248c2ecf20Sopenharmony_ci 11258c2ecf20Sopenharmony_ci#ifdef CONFIG_DEBUG_FS 11268c2ecf20Sopenharmony_ci /** 11278c2ecf20Sopenharmony_ci * @debugfs_entry: 11288c2ecf20Sopenharmony_ci * 11298c2ecf20Sopenharmony_ci * Debugfs directory for this CRTC. 11308c2ecf20Sopenharmony_ci */ 11318c2ecf20Sopenharmony_ci struct dentry *debugfs_entry; 11328c2ecf20Sopenharmony_ci#endif 11338c2ecf20Sopenharmony_ci 11348c2ecf20Sopenharmony_ci /** 11358c2ecf20Sopenharmony_ci * @crc: 11368c2ecf20Sopenharmony_ci * 11378c2ecf20Sopenharmony_ci * Configuration settings of CRC capture. 11388c2ecf20Sopenharmony_ci */ 11398c2ecf20Sopenharmony_ci struct drm_crtc_crc crc; 11408c2ecf20Sopenharmony_ci 11418c2ecf20Sopenharmony_ci /** 11428c2ecf20Sopenharmony_ci * @fence_context: 11438c2ecf20Sopenharmony_ci * 11448c2ecf20Sopenharmony_ci * timeline context used for fence operations. 11458c2ecf20Sopenharmony_ci */ 11468c2ecf20Sopenharmony_ci unsigned int fence_context; 11478c2ecf20Sopenharmony_ci 11488c2ecf20Sopenharmony_ci /** 11498c2ecf20Sopenharmony_ci * @fence_lock: 11508c2ecf20Sopenharmony_ci * 11518c2ecf20Sopenharmony_ci * spinlock to protect the fences in the fence_context. 11528c2ecf20Sopenharmony_ci */ 11538c2ecf20Sopenharmony_ci spinlock_t fence_lock; 11548c2ecf20Sopenharmony_ci /** 11558c2ecf20Sopenharmony_ci * @fence_seqno: 11568c2ecf20Sopenharmony_ci * 11578c2ecf20Sopenharmony_ci * Seqno variable used as monotonic counter for the fences 11588c2ecf20Sopenharmony_ci * created on the CRTC's timeline. 11598c2ecf20Sopenharmony_ci */ 11608c2ecf20Sopenharmony_ci unsigned long fence_seqno; 11618c2ecf20Sopenharmony_ci 11628c2ecf20Sopenharmony_ci /** 11638c2ecf20Sopenharmony_ci * @timeline_name: 11648c2ecf20Sopenharmony_ci * 11658c2ecf20Sopenharmony_ci * The name of the CRTC's fence timeline. 11668c2ecf20Sopenharmony_ci */ 11678c2ecf20Sopenharmony_ci char timeline_name[32]; 11688c2ecf20Sopenharmony_ci 11698c2ecf20Sopenharmony_ci /** 11708c2ecf20Sopenharmony_ci * @self_refresh_data: Holds the state for the self refresh helpers 11718c2ecf20Sopenharmony_ci * 11728c2ecf20Sopenharmony_ci * Initialized via drm_self_refresh_helper_init(). 11738c2ecf20Sopenharmony_ci */ 11748c2ecf20Sopenharmony_ci struct drm_self_refresh_data *self_refresh_data; 11758c2ecf20Sopenharmony_ci}; 11768c2ecf20Sopenharmony_ci 11778c2ecf20Sopenharmony_ci/** 11788c2ecf20Sopenharmony_ci * struct drm_mode_set - new values for a CRTC config change 11798c2ecf20Sopenharmony_ci * @fb: framebuffer to use for new config 11808c2ecf20Sopenharmony_ci * @crtc: CRTC whose configuration we're about to change 11818c2ecf20Sopenharmony_ci * @mode: mode timings to use 11828c2ecf20Sopenharmony_ci * @x: position of this CRTC relative to @fb 11838c2ecf20Sopenharmony_ci * @y: position of this CRTC relative to @fb 11848c2ecf20Sopenharmony_ci * @connectors: array of connectors to drive with this CRTC if possible 11858c2ecf20Sopenharmony_ci * @num_connectors: size of @connectors array 11868c2ecf20Sopenharmony_ci * 11878c2ecf20Sopenharmony_ci * This represents a modeset configuration for the legacy SETCRTC ioctl and is 11888c2ecf20Sopenharmony_ci * also used internally. Atomic drivers instead use &drm_atomic_state. 11898c2ecf20Sopenharmony_ci */ 11908c2ecf20Sopenharmony_cistruct drm_mode_set { 11918c2ecf20Sopenharmony_ci struct drm_framebuffer *fb; 11928c2ecf20Sopenharmony_ci struct drm_crtc *crtc; 11938c2ecf20Sopenharmony_ci struct drm_display_mode *mode; 11948c2ecf20Sopenharmony_ci 11958c2ecf20Sopenharmony_ci uint32_t x; 11968c2ecf20Sopenharmony_ci uint32_t y; 11978c2ecf20Sopenharmony_ci 11988c2ecf20Sopenharmony_ci struct drm_connector **connectors; 11998c2ecf20Sopenharmony_ci size_t num_connectors; 12008c2ecf20Sopenharmony_ci}; 12018c2ecf20Sopenharmony_ci 12028c2ecf20Sopenharmony_ci#define obj_to_crtc(x) container_of(x, struct drm_crtc, base) 12038c2ecf20Sopenharmony_ci 12048c2ecf20Sopenharmony_ci__printf(6, 7) 12058c2ecf20Sopenharmony_ciint drm_crtc_init_with_planes(struct drm_device *dev, 12068c2ecf20Sopenharmony_ci struct drm_crtc *crtc, 12078c2ecf20Sopenharmony_ci struct drm_plane *primary, 12088c2ecf20Sopenharmony_ci struct drm_plane *cursor, 12098c2ecf20Sopenharmony_ci const struct drm_crtc_funcs *funcs, 12108c2ecf20Sopenharmony_ci const char *name, ...); 12118c2ecf20Sopenharmony_civoid drm_crtc_cleanup(struct drm_crtc *crtc); 12128c2ecf20Sopenharmony_ci 12138c2ecf20Sopenharmony_ci/** 12148c2ecf20Sopenharmony_ci * drm_crtc_index - find the index of a registered CRTC 12158c2ecf20Sopenharmony_ci * @crtc: CRTC to find index for 12168c2ecf20Sopenharmony_ci * 12178c2ecf20Sopenharmony_ci * Given a registered CRTC, return the index of that CRTC within a DRM 12188c2ecf20Sopenharmony_ci * device's list of CRTCs. 12198c2ecf20Sopenharmony_ci */ 12208c2ecf20Sopenharmony_cistatic inline unsigned int drm_crtc_index(const struct drm_crtc *crtc) 12218c2ecf20Sopenharmony_ci{ 12228c2ecf20Sopenharmony_ci return crtc->index; 12238c2ecf20Sopenharmony_ci} 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_ci/** 12268c2ecf20Sopenharmony_ci * drm_crtc_mask - find the mask of a registered CRTC 12278c2ecf20Sopenharmony_ci * @crtc: CRTC to find mask for 12288c2ecf20Sopenharmony_ci * 12298c2ecf20Sopenharmony_ci * Given a registered CRTC, return the mask bit of that CRTC for the 12308c2ecf20Sopenharmony_ci * &drm_encoder.possible_crtcs and &drm_plane.possible_crtcs fields. 12318c2ecf20Sopenharmony_ci */ 12328c2ecf20Sopenharmony_cistatic inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc) 12338c2ecf20Sopenharmony_ci{ 12348c2ecf20Sopenharmony_ci return 1 << drm_crtc_index(crtc); 12358c2ecf20Sopenharmony_ci} 12368c2ecf20Sopenharmony_ci 12378c2ecf20Sopenharmony_ciint drm_mode_set_config_internal(struct drm_mode_set *set); 12388c2ecf20Sopenharmony_cistruct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); 12398c2ecf20Sopenharmony_ci 12408c2ecf20Sopenharmony_ci/** 12418c2ecf20Sopenharmony_ci * drm_crtc_find - look up a CRTC object from its ID 12428c2ecf20Sopenharmony_ci * @dev: DRM device 12438c2ecf20Sopenharmony_ci * @file_priv: drm file to check for lease against. 12448c2ecf20Sopenharmony_ci * @id: &drm_mode_object ID 12458c2ecf20Sopenharmony_ci * 12468c2ecf20Sopenharmony_ci * This can be used to look up a CRTC from its userspace ID. Only used by 12478c2ecf20Sopenharmony_ci * drivers for legacy IOCTLs and interface, nowadays extensions to the KMS 12488c2ecf20Sopenharmony_ci * userspace interface should be done using &drm_property. 12498c2ecf20Sopenharmony_ci */ 12508c2ecf20Sopenharmony_cistatic inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, 12518c2ecf20Sopenharmony_ci struct drm_file *file_priv, 12528c2ecf20Sopenharmony_ci uint32_t id) 12538c2ecf20Sopenharmony_ci{ 12548c2ecf20Sopenharmony_ci struct drm_mode_object *mo; 12558c2ecf20Sopenharmony_ci mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CRTC); 12568c2ecf20Sopenharmony_ci return mo ? obj_to_crtc(mo) : NULL; 12578c2ecf20Sopenharmony_ci} 12588c2ecf20Sopenharmony_ci 12598c2ecf20Sopenharmony_ci/** 12608c2ecf20Sopenharmony_ci * drm_for_each_crtc - iterate over all CRTCs 12618c2ecf20Sopenharmony_ci * @crtc: a &struct drm_crtc as the loop cursor 12628c2ecf20Sopenharmony_ci * @dev: the &struct drm_device 12638c2ecf20Sopenharmony_ci * 12648c2ecf20Sopenharmony_ci * Iterate over all CRTCs of @dev. 12658c2ecf20Sopenharmony_ci */ 12668c2ecf20Sopenharmony_ci#define drm_for_each_crtc(crtc, dev) \ 12678c2ecf20Sopenharmony_ci list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) 12688c2ecf20Sopenharmony_ci 12698c2ecf20Sopenharmony_ci#endif /* __DRM_CRTC_H__ */ 1270