162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright © 2006 Keith Packard 362306a36Sopenharmony_ci * Copyright © 2007-2008 Dave Airlie 462306a36Sopenharmony_ci * Copyright © 2007-2008 Intel Corporation 562306a36Sopenharmony_ci * Jesse Barnes <jesse.barnes@intel.com> 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 862306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 962306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 1062306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1162306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 1262306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 1562306a36Sopenharmony_ci * all copies or substantial portions of the Software. 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1862306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1962306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2062306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 2162306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2262306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2362306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 2462306a36Sopenharmony_ci */ 2562306a36Sopenharmony_ci#ifndef __DRM_CRTC_H__ 2662306a36Sopenharmony_ci#define __DRM_CRTC_H__ 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#include <linux/spinlock.h> 2962306a36Sopenharmony_ci#include <linux/types.h> 3062306a36Sopenharmony_ci#include <drm/drm_modeset_lock.h> 3162306a36Sopenharmony_ci#include <drm/drm_mode_object.h> 3262306a36Sopenharmony_ci#include <drm/drm_modes.h> 3362306a36Sopenharmony_ci#include <drm/drm_device.h> 3462306a36Sopenharmony_ci#include <drm/drm_plane.h> 3562306a36Sopenharmony_ci#include <drm/drm_debugfs_crc.h> 3662306a36Sopenharmony_ci#include <drm/drm_mode_config.h> 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_cistruct drm_connector; 3962306a36Sopenharmony_cistruct drm_device; 4062306a36Sopenharmony_cistruct drm_framebuffer; 4162306a36Sopenharmony_cistruct drm_mode_set; 4262306a36Sopenharmony_cistruct drm_file; 4362306a36Sopenharmony_cistruct drm_printer; 4462306a36Sopenharmony_cistruct drm_self_refresh_data; 4562306a36Sopenharmony_cistruct device_node; 4662306a36Sopenharmony_cistruct edid; 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic inline int64_t U642I64(uint64_t val) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci return (int64_t)*((int64_t *)&val); 5162306a36Sopenharmony_ci} 5262306a36Sopenharmony_cistatic inline uint64_t I642U64(int64_t val) 5362306a36Sopenharmony_ci{ 5462306a36Sopenharmony_ci return (uint64_t)*((uint64_t *)&val); 5562306a36Sopenharmony_ci} 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_cistruct drm_crtc; 5862306a36Sopenharmony_cistruct drm_pending_vblank_event; 5962306a36Sopenharmony_cistruct drm_plane; 6062306a36Sopenharmony_cistruct drm_bridge; 6162306a36Sopenharmony_cistruct drm_atomic_state; 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_cistruct drm_crtc_helper_funcs; 6462306a36Sopenharmony_cistruct drm_plane_helper_funcs; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci/** 6762306a36Sopenharmony_ci * struct drm_crtc_state - mutable CRTC state 6862306a36Sopenharmony_ci * 6962306a36Sopenharmony_ci * Note that the distinction between @enable and @active is rather subtle: 7062306a36Sopenharmony_ci * Flipping @active while @enable is set without changing anything else may 7162306a36Sopenharmony_ci * never return in a failure from the &drm_mode_config_funcs.atomic_check 7262306a36Sopenharmony_ci * callback. Userspace assumes that a DPMS On will always succeed. In other 7362306a36Sopenharmony_ci * words: @enable controls resource assignment, @active controls the actual 7462306a36Sopenharmony_ci * hardware state. 7562306a36Sopenharmony_ci * 7662306a36Sopenharmony_ci * The three booleans active_changed, connectors_changed and mode_changed are 7762306a36Sopenharmony_ci * intended to indicate whether a full modeset is needed, rather than strictly 7862306a36Sopenharmony_ci * describing what has changed in a commit. See also: 7962306a36Sopenharmony_ci * drm_atomic_crtc_needs_modeset() 8062306a36Sopenharmony_ci */ 8162306a36Sopenharmony_cistruct drm_crtc_state { 8262306a36Sopenharmony_ci /** @crtc: backpointer to the CRTC */ 8362306a36Sopenharmony_ci struct drm_crtc *crtc; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci /** 8662306a36Sopenharmony_ci * @enable: Whether the CRTC should be enabled, gates all other state. 8762306a36Sopenharmony_ci * This controls reservations of shared resources. Actual hardware state 8862306a36Sopenharmony_ci * is controlled by @active. 8962306a36Sopenharmony_ci */ 9062306a36Sopenharmony_ci bool enable; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci /** 9362306a36Sopenharmony_ci * @active: Whether the CRTC is actively displaying (used for DPMS). 9462306a36Sopenharmony_ci * Implies that @enable is set. The driver must not release any shared 9562306a36Sopenharmony_ci * resources if @active is set to false but @enable still true, because 9662306a36Sopenharmony_ci * userspace expects that a DPMS ON always succeeds. 9762306a36Sopenharmony_ci * 9862306a36Sopenharmony_ci * Hence drivers must not consult @active in their various 9962306a36Sopenharmony_ci * &drm_mode_config_funcs.atomic_check callback to reject an atomic 10062306a36Sopenharmony_ci * commit. They can consult it to aid in the computation of derived 10162306a36Sopenharmony_ci * hardware state, since even in the DPMS OFF state the display hardware 10262306a36Sopenharmony_ci * should be as much powered down as when the CRTC is completely 10362306a36Sopenharmony_ci * disabled through setting @enable to false. 10462306a36Sopenharmony_ci */ 10562306a36Sopenharmony_ci bool active; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci /** 10862306a36Sopenharmony_ci * @planes_changed: Planes on this crtc are updated. Used by the atomic 10962306a36Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. 11062306a36Sopenharmony_ci */ 11162306a36Sopenharmony_ci bool planes_changed : 1; 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci /** 11462306a36Sopenharmony_ci * @mode_changed: @mode or @enable has been changed. Used by the atomic 11562306a36Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. See also 11662306a36Sopenharmony_ci * drm_atomic_crtc_needs_modeset(). 11762306a36Sopenharmony_ci * 11862306a36Sopenharmony_ci * Drivers are supposed to set this for any CRTC state changes that 11962306a36Sopenharmony_ci * require a full modeset. They can also reset it to false if e.g. a 12062306a36Sopenharmony_ci * @mode change can be done without a full modeset by only changing 12162306a36Sopenharmony_ci * scaler settings. 12262306a36Sopenharmony_ci */ 12362306a36Sopenharmony_ci bool mode_changed : 1; 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci /** 12662306a36Sopenharmony_ci * @active_changed: @active has been toggled. Used by the atomic 12762306a36Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. See also 12862306a36Sopenharmony_ci * drm_atomic_crtc_needs_modeset(). 12962306a36Sopenharmony_ci */ 13062306a36Sopenharmony_ci bool active_changed : 1; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci /** 13362306a36Sopenharmony_ci * @connectors_changed: Connectors to this crtc have been updated, 13462306a36Sopenharmony_ci * either in their state or routing. Used by the atomic 13562306a36Sopenharmony_ci * helpers and drivers to steer the atomic commit control flow. See also 13662306a36Sopenharmony_ci * drm_atomic_crtc_needs_modeset(). 13762306a36Sopenharmony_ci * 13862306a36Sopenharmony_ci * Drivers are supposed to set this as-needed from their own atomic 13962306a36Sopenharmony_ci * check code, e.g. from &drm_encoder_helper_funcs.atomic_check 14062306a36Sopenharmony_ci */ 14162306a36Sopenharmony_ci bool connectors_changed : 1; 14262306a36Sopenharmony_ci /** 14362306a36Sopenharmony_ci * @zpos_changed: zpos values of planes on this crtc have been updated. 14462306a36Sopenharmony_ci * Used by the atomic helpers and drivers to steer the atomic commit 14562306a36Sopenharmony_ci * control flow. 14662306a36Sopenharmony_ci */ 14762306a36Sopenharmony_ci bool zpos_changed : 1; 14862306a36Sopenharmony_ci /** 14962306a36Sopenharmony_ci * @color_mgmt_changed: Color management properties have changed 15062306a36Sopenharmony_ci * (@gamma_lut, @degamma_lut or @ctm). Used by the atomic helpers and 15162306a36Sopenharmony_ci * drivers to steer the atomic commit control flow. 15262306a36Sopenharmony_ci */ 15362306a36Sopenharmony_ci bool color_mgmt_changed : 1; 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci /** 15662306a36Sopenharmony_ci * @no_vblank: 15762306a36Sopenharmony_ci * 15862306a36Sopenharmony_ci * Reflects the ability of a CRTC to send VBLANK events. This state 15962306a36Sopenharmony_ci * usually depends on the pipeline configuration. If set to true, DRM 16062306a36Sopenharmony_ci * atomic helpers will send out a fake VBLANK event during display 16162306a36Sopenharmony_ci * updates after all hardware changes have been committed. This is 16262306a36Sopenharmony_ci * implemented in drm_atomic_helper_fake_vblank(). 16362306a36Sopenharmony_ci * 16462306a36Sopenharmony_ci * One usage is for drivers and/or hardware without support for VBLANK 16562306a36Sopenharmony_ci * interrupts. Such drivers typically do not initialize vblanking 16662306a36Sopenharmony_ci * (i.e., call drm_vblank_init() with the number of CRTCs). For CRTCs 16762306a36Sopenharmony_ci * without initialized vblanking, this field is set to true in 16862306a36Sopenharmony_ci * drm_atomic_helper_check_modeset(), and a fake VBLANK event will be 16962306a36Sopenharmony_ci * send out on each update of the display pipeline by 17062306a36Sopenharmony_ci * drm_atomic_helper_fake_vblank(). 17162306a36Sopenharmony_ci * 17262306a36Sopenharmony_ci * Another usage is CRTCs feeding a writeback connector operating in 17362306a36Sopenharmony_ci * oneshot mode. In this case the fake VBLANK event is only generated 17462306a36Sopenharmony_ci * when a job is queued to the writeback connector, and we want the 17562306a36Sopenharmony_ci * core to fake VBLANK events when this part of the pipeline hasn't 17662306a36Sopenharmony_ci * changed but others had or when the CRTC and connectors are being 17762306a36Sopenharmony_ci * disabled. 17862306a36Sopenharmony_ci * 17962306a36Sopenharmony_ci * __drm_atomic_helper_crtc_duplicate_state() will not reset the value 18062306a36Sopenharmony_ci * from the current state, the CRTC driver is then responsible for 18162306a36Sopenharmony_ci * updating this field when needed. 18262306a36Sopenharmony_ci * 18362306a36Sopenharmony_ci * Note that the combination of &drm_crtc_state.event == NULL and 18462306a36Sopenharmony_ci * &drm_crtc_state.no_blank == true is valid and usually used when the 18562306a36Sopenharmony_ci * writeback connector attached to the CRTC has a new job queued. In 18662306a36Sopenharmony_ci * this case the driver will send the VBLANK event on its own when the 18762306a36Sopenharmony_ci * writeback job is complete. 18862306a36Sopenharmony_ci */ 18962306a36Sopenharmony_ci bool no_vblank : 1; 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ci /** 19262306a36Sopenharmony_ci * @plane_mask: Bitmask of drm_plane_mask(plane) of planes attached to 19362306a36Sopenharmony_ci * this CRTC. 19462306a36Sopenharmony_ci */ 19562306a36Sopenharmony_ci u32 plane_mask; 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ci /** 19862306a36Sopenharmony_ci * @connector_mask: Bitmask of drm_connector_mask(connector) of 19962306a36Sopenharmony_ci * connectors attached to this CRTC. 20062306a36Sopenharmony_ci */ 20162306a36Sopenharmony_ci u32 connector_mask; 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci /** 20462306a36Sopenharmony_ci * @encoder_mask: Bitmask of drm_encoder_mask(encoder) of encoders 20562306a36Sopenharmony_ci * attached to this CRTC. 20662306a36Sopenharmony_ci */ 20762306a36Sopenharmony_ci u32 encoder_mask; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci /** 21062306a36Sopenharmony_ci * @adjusted_mode: 21162306a36Sopenharmony_ci * 21262306a36Sopenharmony_ci * Internal display timings which can be used by the driver to handle 21362306a36Sopenharmony_ci * differences between the mode requested by userspace in @mode and what 21462306a36Sopenharmony_ci * is actually programmed into the hardware. 21562306a36Sopenharmony_ci * 21662306a36Sopenharmony_ci * For drivers using &drm_bridge, this stores hardware display timings 21762306a36Sopenharmony_ci * used between the CRTC and the first bridge. For other drivers, the 21862306a36Sopenharmony_ci * meaning of the adjusted_mode field is purely driver implementation 21962306a36Sopenharmony_ci * defined information, and will usually be used to store the hardware 22062306a36Sopenharmony_ci * display timings used between the CRTC and encoder blocks. 22162306a36Sopenharmony_ci */ 22262306a36Sopenharmony_ci struct drm_display_mode adjusted_mode; 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci /** 22562306a36Sopenharmony_ci * @mode: 22662306a36Sopenharmony_ci * 22762306a36Sopenharmony_ci * Display timings requested by userspace. The driver should try to 22862306a36Sopenharmony_ci * match the refresh rate as close as possible (but note that it's 22962306a36Sopenharmony_ci * undefined what exactly is close enough, e.g. some of the HDMI modes 23062306a36Sopenharmony_ci * only differ in less than 1% of the refresh rate). The active width 23162306a36Sopenharmony_ci * and height as observed by userspace for positioning planes must match 23262306a36Sopenharmony_ci * exactly. 23362306a36Sopenharmony_ci * 23462306a36Sopenharmony_ci * For external connectors where the sink isn't fixed (like with a 23562306a36Sopenharmony_ci * built-in panel), this mode here should match the physical mode on the 23662306a36Sopenharmony_ci * wire to the last details (i.e. including sync polarities and 23762306a36Sopenharmony_ci * everything). 23862306a36Sopenharmony_ci */ 23962306a36Sopenharmony_ci struct drm_display_mode mode; 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci /** 24262306a36Sopenharmony_ci * @mode_blob: &drm_property_blob for @mode, for exposing the mode to 24362306a36Sopenharmony_ci * atomic userspace. 24462306a36Sopenharmony_ci */ 24562306a36Sopenharmony_ci struct drm_property_blob *mode_blob; 24662306a36Sopenharmony_ci 24762306a36Sopenharmony_ci /** 24862306a36Sopenharmony_ci * @degamma_lut: 24962306a36Sopenharmony_ci * 25062306a36Sopenharmony_ci * Lookup table for converting framebuffer pixel data before apply the 25162306a36Sopenharmony_ci * color conversion matrix @ctm. See drm_crtc_enable_color_mgmt(). The 25262306a36Sopenharmony_ci * blob (if not NULL) is an array of &struct drm_color_lut. 25362306a36Sopenharmony_ci */ 25462306a36Sopenharmony_ci struct drm_property_blob *degamma_lut; 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci /** 25762306a36Sopenharmony_ci * @ctm: 25862306a36Sopenharmony_ci * 25962306a36Sopenharmony_ci * Color transformation matrix. See drm_crtc_enable_color_mgmt(). The 26062306a36Sopenharmony_ci * blob (if not NULL) is a &struct drm_color_ctm. 26162306a36Sopenharmony_ci */ 26262306a36Sopenharmony_ci struct drm_property_blob *ctm; 26362306a36Sopenharmony_ci 26462306a36Sopenharmony_ci /** 26562306a36Sopenharmony_ci * @gamma_lut: 26662306a36Sopenharmony_ci * 26762306a36Sopenharmony_ci * Lookup table for converting pixel data after the color conversion 26862306a36Sopenharmony_ci * matrix @ctm. See drm_crtc_enable_color_mgmt(). The blob (if not 26962306a36Sopenharmony_ci * NULL) is an array of &struct drm_color_lut. 27062306a36Sopenharmony_ci * 27162306a36Sopenharmony_ci * Note that for mostly historical reasons stemming from Xorg heritage, 27262306a36Sopenharmony_ci * this is also used to store the color map (also sometimes color lut, 27362306a36Sopenharmony_ci * CLUT or color palette) for indexed formats like DRM_FORMAT_C8. 27462306a36Sopenharmony_ci */ 27562306a36Sopenharmony_ci struct drm_property_blob *gamma_lut; 27662306a36Sopenharmony_ci 27762306a36Sopenharmony_ci /** 27862306a36Sopenharmony_ci * @target_vblank: 27962306a36Sopenharmony_ci * 28062306a36Sopenharmony_ci * Target vertical blank period when a page flip 28162306a36Sopenharmony_ci * should take effect. 28262306a36Sopenharmony_ci */ 28362306a36Sopenharmony_ci u32 target_vblank; 28462306a36Sopenharmony_ci 28562306a36Sopenharmony_ci /** 28662306a36Sopenharmony_ci * @async_flip: 28762306a36Sopenharmony_ci * 28862306a36Sopenharmony_ci * This is set when DRM_MODE_PAGE_FLIP_ASYNC is set in the legacy 28962306a36Sopenharmony_ci * PAGE_FLIP IOCTL. It's not wired up for the atomic IOCTL itself yet. 29062306a36Sopenharmony_ci */ 29162306a36Sopenharmony_ci bool async_flip; 29262306a36Sopenharmony_ci 29362306a36Sopenharmony_ci /** 29462306a36Sopenharmony_ci * @vrr_enabled: 29562306a36Sopenharmony_ci * 29662306a36Sopenharmony_ci * Indicates if variable refresh rate should be enabled for the CRTC. 29762306a36Sopenharmony_ci * Support for the requested vrr state will depend on driver and 29862306a36Sopenharmony_ci * hardware capabiltiy - lacking support is not treated as failure. 29962306a36Sopenharmony_ci */ 30062306a36Sopenharmony_ci bool vrr_enabled; 30162306a36Sopenharmony_ci 30262306a36Sopenharmony_ci /** 30362306a36Sopenharmony_ci * @self_refresh_active: 30462306a36Sopenharmony_ci * 30562306a36Sopenharmony_ci * Used by the self refresh helpers to denote when a self refresh 30662306a36Sopenharmony_ci * transition is occurring. This will be set on enable/disable callbacks 30762306a36Sopenharmony_ci * when self refresh is being enabled or disabled. In some cases, it may 30862306a36Sopenharmony_ci * not be desirable to fully shut off the crtc during self refresh. 30962306a36Sopenharmony_ci * CRTC's can inspect this flag and determine the best course of action. 31062306a36Sopenharmony_ci */ 31162306a36Sopenharmony_ci bool self_refresh_active; 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci /** 31462306a36Sopenharmony_ci * @scaling_filter: 31562306a36Sopenharmony_ci * 31662306a36Sopenharmony_ci * Scaling filter to be applied 31762306a36Sopenharmony_ci */ 31862306a36Sopenharmony_ci enum drm_scaling_filter scaling_filter; 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_ci /** 32162306a36Sopenharmony_ci * @event: 32262306a36Sopenharmony_ci * 32362306a36Sopenharmony_ci * Optional pointer to a DRM event to signal upon completion of the 32462306a36Sopenharmony_ci * state update. The driver must send out the event when the atomic 32562306a36Sopenharmony_ci * commit operation completes. There are two cases: 32662306a36Sopenharmony_ci * 32762306a36Sopenharmony_ci * - The event is for a CRTC which is being disabled through this 32862306a36Sopenharmony_ci * atomic commit. In that case the event can be send out any time 32962306a36Sopenharmony_ci * after the hardware has stopped scanning out the current 33062306a36Sopenharmony_ci * framebuffers. It should contain the timestamp and counter for the 33162306a36Sopenharmony_ci * last vblank before the display pipeline was shut off. The simplest 33262306a36Sopenharmony_ci * way to achieve that is calling drm_crtc_send_vblank_event() 33362306a36Sopenharmony_ci * somewhen after drm_crtc_vblank_off() has been called. 33462306a36Sopenharmony_ci * 33562306a36Sopenharmony_ci * - For a CRTC which is enabled at the end of the commit (even when it 33662306a36Sopenharmony_ci * undergoes an full modeset) the vblank timestamp and counter must 33762306a36Sopenharmony_ci * be for the vblank right before the first frame that scans out the 33862306a36Sopenharmony_ci * new set of buffers. Again the event can only be sent out after the 33962306a36Sopenharmony_ci * hardware has stopped scanning out the old buffers. 34062306a36Sopenharmony_ci * 34162306a36Sopenharmony_ci * - Events for disabled CRTCs are not allowed, and drivers can ignore 34262306a36Sopenharmony_ci * that case. 34362306a36Sopenharmony_ci * 34462306a36Sopenharmony_ci * For very simple hardware without VBLANK interrupt, enabling 34562306a36Sopenharmony_ci * &struct drm_crtc_state.no_vblank makes DRM's atomic commit helpers 34662306a36Sopenharmony_ci * send a fake VBLANK event at the end of the display update after all 34762306a36Sopenharmony_ci * hardware changes have been applied. See 34862306a36Sopenharmony_ci * drm_atomic_helper_fake_vblank(). 34962306a36Sopenharmony_ci * 35062306a36Sopenharmony_ci * For more complex hardware this 35162306a36Sopenharmony_ci * can be handled by the drm_crtc_send_vblank_event() function, 35262306a36Sopenharmony_ci * which the driver should call on the provided event upon completion of 35362306a36Sopenharmony_ci * the atomic commit. Note that if the driver supports vblank signalling 35462306a36Sopenharmony_ci * and timestamping the vblank counters and timestamps must agree with 35562306a36Sopenharmony_ci * the ones returned from page flip events. With the current vblank 35662306a36Sopenharmony_ci * helper infrastructure this can be achieved by holding a vblank 35762306a36Sopenharmony_ci * reference while the page flip is pending, acquired through 35862306a36Sopenharmony_ci * drm_crtc_vblank_get() and released with drm_crtc_vblank_put(). 35962306a36Sopenharmony_ci * Drivers are free to implement their own vblank counter and timestamp 36062306a36Sopenharmony_ci * tracking though, e.g. if they have accurate timestamp registers in 36162306a36Sopenharmony_ci * hardware. 36262306a36Sopenharmony_ci * 36362306a36Sopenharmony_ci * For hardware which supports some means to synchronize vblank 36462306a36Sopenharmony_ci * interrupt delivery with committing display state there's also 36562306a36Sopenharmony_ci * drm_crtc_arm_vblank_event(). See the documentation of that function 36662306a36Sopenharmony_ci * for a detailed discussion of the constraints it needs to be used 36762306a36Sopenharmony_ci * safely. 36862306a36Sopenharmony_ci * 36962306a36Sopenharmony_ci * If the device can't notify of flip completion in a race-free way 37062306a36Sopenharmony_ci * at all, then the event should be armed just after the page flip is 37162306a36Sopenharmony_ci * committed. In the worst case the driver will send the event to 37262306a36Sopenharmony_ci * userspace one frame too late. This doesn't allow for a real atomic 37362306a36Sopenharmony_ci * update, but it should avoid tearing. 37462306a36Sopenharmony_ci */ 37562306a36Sopenharmony_ci struct drm_pending_vblank_event *event; 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_ci /** 37862306a36Sopenharmony_ci * @commit: 37962306a36Sopenharmony_ci * 38062306a36Sopenharmony_ci * This tracks how the commit for this update proceeds through the 38162306a36Sopenharmony_ci * various phases. This is never cleared, except when we destroy the 38262306a36Sopenharmony_ci * state, so that subsequent commits can synchronize with previous ones. 38362306a36Sopenharmony_ci */ 38462306a36Sopenharmony_ci struct drm_crtc_commit *commit; 38562306a36Sopenharmony_ci 38662306a36Sopenharmony_ci /** @state: backpointer to global drm_atomic_state */ 38762306a36Sopenharmony_ci struct drm_atomic_state *state; 38862306a36Sopenharmony_ci}; 38962306a36Sopenharmony_ci 39062306a36Sopenharmony_ci/** 39162306a36Sopenharmony_ci * struct drm_crtc_funcs - control CRTCs for a given device 39262306a36Sopenharmony_ci * 39362306a36Sopenharmony_ci * The drm_crtc_funcs structure is the central CRTC management structure 39462306a36Sopenharmony_ci * in the DRM. Each CRTC controls one or more connectors (note that the name 39562306a36Sopenharmony_ci * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. 39662306a36Sopenharmony_ci * connectors, not just CRTs). 39762306a36Sopenharmony_ci * 39862306a36Sopenharmony_ci * Each driver is responsible for filling out this structure at startup time, 39962306a36Sopenharmony_ci * in addition to providing other modesetting features, like i2c and DDC 40062306a36Sopenharmony_ci * bus accessors. 40162306a36Sopenharmony_ci */ 40262306a36Sopenharmony_cistruct drm_crtc_funcs { 40362306a36Sopenharmony_ci /** 40462306a36Sopenharmony_ci * @reset: 40562306a36Sopenharmony_ci * 40662306a36Sopenharmony_ci * Reset CRTC hardware and software state to off. This function isn't 40762306a36Sopenharmony_ci * called by the core directly, only through drm_mode_config_reset(). 40862306a36Sopenharmony_ci * It's not a helper hook only for historical reasons. 40962306a36Sopenharmony_ci * 41062306a36Sopenharmony_ci * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset 41162306a36Sopenharmony_ci * atomic state using this hook. 41262306a36Sopenharmony_ci */ 41362306a36Sopenharmony_ci void (*reset)(struct drm_crtc *crtc); 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_ci /** 41662306a36Sopenharmony_ci * @cursor_set: 41762306a36Sopenharmony_ci * 41862306a36Sopenharmony_ci * Update the cursor image. The cursor position is relative to the CRTC 41962306a36Sopenharmony_ci * and can be partially or fully outside of the visible area. 42062306a36Sopenharmony_ci * 42162306a36Sopenharmony_ci * Note that contrary to all other KMS functions the legacy cursor entry 42262306a36Sopenharmony_ci * points don't take a framebuffer object, but instead take directly a 42362306a36Sopenharmony_ci * raw buffer object id from the driver's buffer manager (which is 42462306a36Sopenharmony_ci * either GEM or TTM for current drivers). 42562306a36Sopenharmony_ci * 42662306a36Sopenharmony_ci * This entry point is deprecated, drivers should instead implement 42762306a36Sopenharmony_ci * universal plane support and register a proper cursor plane using 42862306a36Sopenharmony_ci * drm_crtc_init_with_planes(). 42962306a36Sopenharmony_ci * 43062306a36Sopenharmony_ci * This callback is optional 43162306a36Sopenharmony_ci * 43262306a36Sopenharmony_ci * RETURNS: 43362306a36Sopenharmony_ci * 43462306a36Sopenharmony_ci * 0 on success or a negative error code on failure. 43562306a36Sopenharmony_ci */ 43662306a36Sopenharmony_ci int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, 43762306a36Sopenharmony_ci uint32_t handle, uint32_t width, uint32_t height); 43862306a36Sopenharmony_ci 43962306a36Sopenharmony_ci /** 44062306a36Sopenharmony_ci * @cursor_set2: 44162306a36Sopenharmony_ci * 44262306a36Sopenharmony_ci * Update the cursor image, including hotspot information. The hotspot 44362306a36Sopenharmony_ci * must not affect the cursor position in CRTC coordinates, but is only 44462306a36Sopenharmony_ci * meant as a hint for virtualized display hardware to coordinate the 44562306a36Sopenharmony_ci * guests and hosts cursor position. The cursor hotspot is relative to 44662306a36Sopenharmony_ci * the cursor image. Otherwise this works exactly like @cursor_set. 44762306a36Sopenharmony_ci * 44862306a36Sopenharmony_ci * This entry point is deprecated, drivers should instead implement 44962306a36Sopenharmony_ci * universal plane support and register a proper cursor plane using 45062306a36Sopenharmony_ci * drm_crtc_init_with_planes(). 45162306a36Sopenharmony_ci * 45262306a36Sopenharmony_ci * This callback is optional. 45362306a36Sopenharmony_ci * 45462306a36Sopenharmony_ci * RETURNS: 45562306a36Sopenharmony_ci * 45662306a36Sopenharmony_ci * 0 on success or a negative error code on failure. 45762306a36Sopenharmony_ci */ 45862306a36Sopenharmony_ci int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, 45962306a36Sopenharmony_ci uint32_t handle, uint32_t width, uint32_t height, 46062306a36Sopenharmony_ci int32_t hot_x, int32_t hot_y); 46162306a36Sopenharmony_ci 46262306a36Sopenharmony_ci /** 46362306a36Sopenharmony_ci * @cursor_move: 46462306a36Sopenharmony_ci * 46562306a36Sopenharmony_ci * Update the cursor position. The cursor does not need to be visible 46662306a36Sopenharmony_ci * when this hook is called. 46762306a36Sopenharmony_ci * 46862306a36Sopenharmony_ci * This entry point is deprecated, drivers should instead implement 46962306a36Sopenharmony_ci * universal plane support and register a proper cursor plane using 47062306a36Sopenharmony_ci * drm_crtc_init_with_planes(). 47162306a36Sopenharmony_ci * 47262306a36Sopenharmony_ci * This callback is optional. 47362306a36Sopenharmony_ci * 47462306a36Sopenharmony_ci * RETURNS: 47562306a36Sopenharmony_ci * 47662306a36Sopenharmony_ci * 0 on success or a negative error code on failure. 47762306a36Sopenharmony_ci */ 47862306a36Sopenharmony_ci int (*cursor_move)(struct drm_crtc *crtc, int x, int y); 47962306a36Sopenharmony_ci 48062306a36Sopenharmony_ci /** 48162306a36Sopenharmony_ci * @gamma_set: 48262306a36Sopenharmony_ci * 48362306a36Sopenharmony_ci * Set gamma on the CRTC. 48462306a36Sopenharmony_ci * 48562306a36Sopenharmony_ci * This callback is optional. 48662306a36Sopenharmony_ci * 48762306a36Sopenharmony_ci * Atomic drivers who want to support gamma tables should implement the 48862306a36Sopenharmony_ci * atomic color management support, enabled by calling 48962306a36Sopenharmony_ci * drm_crtc_enable_color_mgmt(), which then supports the legacy gamma 49062306a36Sopenharmony_ci * interface through the drm_atomic_helper_legacy_gamma_set() 49162306a36Sopenharmony_ci * compatibility implementation. 49262306a36Sopenharmony_ci */ 49362306a36Sopenharmony_ci int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 49462306a36Sopenharmony_ci uint32_t size, 49562306a36Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 49662306a36Sopenharmony_ci 49762306a36Sopenharmony_ci /** 49862306a36Sopenharmony_ci * @destroy: 49962306a36Sopenharmony_ci * 50062306a36Sopenharmony_ci * Clean up CRTC resources. This is only called at driver unload time 50162306a36Sopenharmony_ci * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged 50262306a36Sopenharmony_ci * in DRM. 50362306a36Sopenharmony_ci */ 50462306a36Sopenharmony_ci void (*destroy)(struct drm_crtc *crtc); 50562306a36Sopenharmony_ci 50662306a36Sopenharmony_ci /** 50762306a36Sopenharmony_ci * @set_config: 50862306a36Sopenharmony_ci * 50962306a36Sopenharmony_ci * This is the main legacy entry point to change the modeset state on a 51062306a36Sopenharmony_ci * CRTC. All the details of the desired configuration are passed in a 51162306a36Sopenharmony_ci * &struct drm_mode_set - see there for details. 51262306a36Sopenharmony_ci * 51362306a36Sopenharmony_ci * Drivers implementing atomic modeset should use 51462306a36Sopenharmony_ci * drm_atomic_helper_set_config() to implement this hook. 51562306a36Sopenharmony_ci * 51662306a36Sopenharmony_ci * RETURNS: 51762306a36Sopenharmony_ci * 51862306a36Sopenharmony_ci * 0 on success or a negative error code on failure. 51962306a36Sopenharmony_ci */ 52062306a36Sopenharmony_ci int (*set_config)(struct drm_mode_set *set, 52162306a36Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 52262306a36Sopenharmony_ci 52362306a36Sopenharmony_ci /** 52462306a36Sopenharmony_ci * @page_flip: 52562306a36Sopenharmony_ci * 52662306a36Sopenharmony_ci * Legacy entry point to schedule a flip to the given framebuffer. 52762306a36Sopenharmony_ci * 52862306a36Sopenharmony_ci * Page flipping is a synchronization mechanism that replaces the frame 52962306a36Sopenharmony_ci * buffer being scanned out by the CRTC with a new frame buffer during 53062306a36Sopenharmony_ci * vertical blanking, avoiding tearing (except when requested otherwise 53162306a36Sopenharmony_ci * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application 53262306a36Sopenharmony_ci * requests a page flip the DRM core verifies that the new frame buffer 53362306a36Sopenharmony_ci * is large enough to be scanned out by the CRTC in the currently 53462306a36Sopenharmony_ci * configured mode and then calls this hook with a pointer to the new 53562306a36Sopenharmony_ci * frame buffer. 53662306a36Sopenharmony_ci * 53762306a36Sopenharmony_ci * The driver must wait for any pending rendering to the new framebuffer 53862306a36Sopenharmony_ci * to complete before executing the flip. It should also wait for any 53962306a36Sopenharmony_ci * pending rendering from other drivers if the underlying buffer is a 54062306a36Sopenharmony_ci * shared dma-buf. 54162306a36Sopenharmony_ci * 54262306a36Sopenharmony_ci * An application can request to be notified when the page flip has 54362306a36Sopenharmony_ci * completed. The drm core will supply a &struct drm_event in the event 54462306a36Sopenharmony_ci * parameter in this case. This can be handled by the 54562306a36Sopenharmony_ci * drm_crtc_send_vblank_event() function, which the driver should call on 54662306a36Sopenharmony_ci * the provided event upon completion of the flip. Note that if 54762306a36Sopenharmony_ci * the driver supports vblank signalling and timestamping the vblank 54862306a36Sopenharmony_ci * counters and timestamps must agree with the ones returned from page 54962306a36Sopenharmony_ci * flip events. With the current vblank helper infrastructure this can 55062306a36Sopenharmony_ci * be achieved by holding a vblank reference while the page flip is 55162306a36Sopenharmony_ci * pending, acquired through drm_crtc_vblank_get() and released with 55262306a36Sopenharmony_ci * drm_crtc_vblank_put(). Drivers are free to implement their own vblank 55362306a36Sopenharmony_ci * counter and timestamp tracking though, e.g. if they have accurate 55462306a36Sopenharmony_ci * timestamp registers in hardware. 55562306a36Sopenharmony_ci * 55662306a36Sopenharmony_ci * This callback is optional. 55762306a36Sopenharmony_ci * 55862306a36Sopenharmony_ci * NOTE: 55962306a36Sopenharmony_ci * 56062306a36Sopenharmony_ci * Very early versions of the KMS ABI mandated that the driver must 56162306a36Sopenharmony_ci * block (but not reject) any rendering to the old framebuffer until the 56262306a36Sopenharmony_ci * flip operation has completed and the old framebuffer is no longer 56362306a36Sopenharmony_ci * visible. This requirement has been lifted, and userspace is instead 56462306a36Sopenharmony_ci * expected to request delivery of an event and wait with recycling old 56562306a36Sopenharmony_ci * buffers until such has been received. 56662306a36Sopenharmony_ci * 56762306a36Sopenharmony_ci * RETURNS: 56862306a36Sopenharmony_ci * 56962306a36Sopenharmony_ci * 0 on success or a negative error code on failure. Note that if a 57062306a36Sopenharmony_ci * page flip operation is already pending the callback should return 57162306a36Sopenharmony_ci * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode 57262306a36Sopenharmony_ci * or just runtime disabled through DPMS respectively the new atomic 57362306a36Sopenharmony_ci * "ACTIVE" state) should result in an -EINVAL error code. Note that 57462306a36Sopenharmony_ci * drm_atomic_helper_page_flip() checks this already for atomic drivers. 57562306a36Sopenharmony_ci */ 57662306a36Sopenharmony_ci int (*page_flip)(struct drm_crtc *crtc, 57762306a36Sopenharmony_ci struct drm_framebuffer *fb, 57862306a36Sopenharmony_ci struct drm_pending_vblank_event *event, 57962306a36Sopenharmony_ci uint32_t flags, 58062306a36Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 58162306a36Sopenharmony_ci 58262306a36Sopenharmony_ci /** 58362306a36Sopenharmony_ci * @page_flip_target: 58462306a36Sopenharmony_ci * 58562306a36Sopenharmony_ci * Same as @page_flip but with an additional parameter specifying the 58662306a36Sopenharmony_ci * absolute target vertical blank period (as reported by 58762306a36Sopenharmony_ci * drm_crtc_vblank_count()) when the flip should take effect. 58862306a36Sopenharmony_ci * 58962306a36Sopenharmony_ci * Note that the core code calls drm_crtc_vblank_get before this entry 59062306a36Sopenharmony_ci * point, and will call drm_crtc_vblank_put if this entry point returns 59162306a36Sopenharmony_ci * any non-0 error code. It's the driver's responsibility to call 59262306a36Sopenharmony_ci * drm_crtc_vblank_put after this entry point returns 0, typically when 59362306a36Sopenharmony_ci * the flip completes. 59462306a36Sopenharmony_ci */ 59562306a36Sopenharmony_ci int (*page_flip_target)(struct drm_crtc *crtc, 59662306a36Sopenharmony_ci struct drm_framebuffer *fb, 59762306a36Sopenharmony_ci struct drm_pending_vblank_event *event, 59862306a36Sopenharmony_ci uint32_t flags, uint32_t target, 59962306a36Sopenharmony_ci struct drm_modeset_acquire_ctx *ctx); 60062306a36Sopenharmony_ci 60162306a36Sopenharmony_ci /** 60262306a36Sopenharmony_ci * @set_property: 60362306a36Sopenharmony_ci * 60462306a36Sopenharmony_ci * This is the legacy entry point to update a property attached to the 60562306a36Sopenharmony_ci * CRTC. 60662306a36Sopenharmony_ci * 60762306a36Sopenharmony_ci * This callback is optional if the driver does not support any legacy 60862306a36Sopenharmony_ci * driver-private properties. For atomic drivers it is not used because 60962306a36Sopenharmony_ci * property handling is done entirely in the DRM core. 61062306a36Sopenharmony_ci * 61162306a36Sopenharmony_ci * RETURNS: 61262306a36Sopenharmony_ci * 61362306a36Sopenharmony_ci * 0 on success or a negative error code on failure. 61462306a36Sopenharmony_ci */ 61562306a36Sopenharmony_ci int (*set_property)(struct drm_crtc *crtc, 61662306a36Sopenharmony_ci struct drm_property *property, uint64_t val); 61762306a36Sopenharmony_ci 61862306a36Sopenharmony_ci /** 61962306a36Sopenharmony_ci * @atomic_duplicate_state: 62062306a36Sopenharmony_ci * 62162306a36Sopenharmony_ci * Duplicate the current atomic state for this CRTC and return it. 62262306a36Sopenharmony_ci * The core and helpers guarantee that any atomic state duplicated with 62362306a36Sopenharmony_ci * this hook and still owned by the caller (i.e. not transferred to the 62462306a36Sopenharmony_ci * driver by calling &drm_mode_config_funcs.atomic_commit) will be 62562306a36Sopenharmony_ci * cleaned up by calling the @atomic_destroy_state hook in this 62662306a36Sopenharmony_ci * structure. 62762306a36Sopenharmony_ci * 62862306a36Sopenharmony_ci * This callback is mandatory for atomic drivers. 62962306a36Sopenharmony_ci * 63062306a36Sopenharmony_ci * Atomic drivers which don't subclass &struct drm_crtc_state should use 63162306a36Sopenharmony_ci * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the 63262306a36Sopenharmony_ci * state structure to extend it with driver-private state should use 63362306a36Sopenharmony_ci * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is 63462306a36Sopenharmony_ci * duplicated in a consistent fashion across drivers. 63562306a36Sopenharmony_ci * 63662306a36Sopenharmony_ci * It is an error to call this hook before &drm_crtc.state has been 63762306a36Sopenharmony_ci * initialized correctly. 63862306a36Sopenharmony_ci * 63962306a36Sopenharmony_ci * NOTE: 64062306a36Sopenharmony_ci * 64162306a36Sopenharmony_ci * If the duplicate state references refcounted resources this hook must 64262306a36Sopenharmony_ci * acquire a reference for each of them. The driver must release these 64362306a36Sopenharmony_ci * references again in @atomic_destroy_state. 64462306a36Sopenharmony_ci * 64562306a36Sopenharmony_ci * RETURNS: 64662306a36Sopenharmony_ci * 64762306a36Sopenharmony_ci * Duplicated atomic state or NULL when the allocation failed. 64862306a36Sopenharmony_ci */ 64962306a36Sopenharmony_ci struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); 65062306a36Sopenharmony_ci 65162306a36Sopenharmony_ci /** 65262306a36Sopenharmony_ci * @atomic_destroy_state: 65362306a36Sopenharmony_ci * 65462306a36Sopenharmony_ci * Destroy a state duplicated with @atomic_duplicate_state and release 65562306a36Sopenharmony_ci * or unreference all resources it references 65662306a36Sopenharmony_ci * 65762306a36Sopenharmony_ci * This callback is mandatory for atomic drivers. 65862306a36Sopenharmony_ci */ 65962306a36Sopenharmony_ci void (*atomic_destroy_state)(struct drm_crtc *crtc, 66062306a36Sopenharmony_ci struct drm_crtc_state *state); 66162306a36Sopenharmony_ci 66262306a36Sopenharmony_ci /** 66362306a36Sopenharmony_ci * @atomic_set_property: 66462306a36Sopenharmony_ci * 66562306a36Sopenharmony_ci * Decode a driver-private property value and store the decoded value 66662306a36Sopenharmony_ci * into the passed-in state structure. Since the atomic core decodes all 66762306a36Sopenharmony_ci * standardized properties (even for extensions beyond the core set of 66862306a36Sopenharmony_ci * properties which might not be implemented by all drivers) this 66962306a36Sopenharmony_ci * requires drivers to subclass the state structure. 67062306a36Sopenharmony_ci * 67162306a36Sopenharmony_ci * Such driver-private properties should really only be implemented for 67262306a36Sopenharmony_ci * truly hardware/vendor specific state. Instead it is preferred to 67362306a36Sopenharmony_ci * standardize atomic extension and decode the properties used to expose 67462306a36Sopenharmony_ci * such an extension in the core. 67562306a36Sopenharmony_ci * 67662306a36Sopenharmony_ci * Do not call this function directly, use 67762306a36Sopenharmony_ci * drm_atomic_crtc_set_property() instead. 67862306a36Sopenharmony_ci * 67962306a36Sopenharmony_ci * This callback is optional if the driver does not support any 68062306a36Sopenharmony_ci * driver-private atomic properties. 68162306a36Sopenharmony_ci * 68262306a36Sopenharmony_ci * NOTE: 68362306a36Sopenharmony_ci * 68462306a36Sopenharmony_ci * This function is called in the state assembly phase of atomic 68562306a36Sopenharmony_ci * modesets, which can be aborted for any reason (including on 68662306a36Sopenharmony_ci * userspace's request to just check whether a configuration would be 68762306a36Sopenharmony_ci * possible). Drivers MUST NOT touch any persistent state (hardware or 68862306a36Sopenharmony_ci * software) or data structures except the passed in @state parameter. 68962306a36Sopenharmony_ci * 69062306a36Sopenharmony_ci * Also since userspace controls in which order properties are set this 69162306a36Sopenharmony_ci * function must not do any input validation (since the state update is 69262306a36Sopenharmony_ci * incomplete and hence likely inconsistent). Instead any such input 69362306a36Sopenharmony_ci * validation must be done in the various atomic_check callbacks. 69462306a36Sopenharmony_ci * 69562306a36Sopenharmony_ci * RETURNS: 69662306a36Sopenharmony_ci * 69762306a36Sopenharmony_ci * 0 if the property has been found, -EINVAL if the property isn't 69862306a36Sopenharmony_ci * implemented by the driver (which should never happen, the core only 69962306a36Sopenharmony_ci * asks for properties attached to this CRTC). No other validation is 70062306a36Sopenharmony_ci * allowed by the driver. The core already checks that the property 70162306a36Sopenharmony_ci * value is within the range (integer, valid enum value, ...) the driver 70262306a36Sopenharmony_ci * set when registering the property. 70362306a36Sopenharmony_ci */ 70462306a36Sopenharmony_ci int (*atomic_set_property)(struct drm_crtc *crtc, 70562306a36Sopenharmony_ci struct drm_crtc_state *state, 70662306a36Sopenharmony_ci struct drm_property *property, 70762306a36Sopenharmony_ci uint64_t val); 70862306a36Sopenharmony_ci /** 70962306a36Sopenharmony_ci * @atomic_get_property: 71062306a36Sopenharmony_ci * 71162306a36Sopenharmony_ci * Reads out the decoded driver-private property. This is used to 71262306a36Sopenharmony_ci * implement the GETCRTC IOCTL. 71362306a36Sopenharmony_ci * 71462306a36Sopenharmony_ci * Do not call this function directly, use 71562306a36Sopenharmony_ci * drm_atomic_crtc_get_property() instead. 71662306a36Sopenharmony_ci * 71762306a36Sopenharmony_ci * This callback is optional if the driver does not support any 71862306a36Sopenharmony_ci * driver-private atomic properties. 71962306a36Sopenharmony_ci * 72062306a36Sopenharmony_ci * RETURNS: 72162306a36Sopenharmony_ci * 72262306a36Sopenharmony_ci * 0 on success, -EINVAL if the property isn't implemented by the 72362306a36Sopenharmony_ci * driver (which should never happen, the core only asks for 72462306a36Sopenharmony_ci * properties attached to this CRTC). 72562306a36Sopenharmony_ci */ 72662306a36Sopenharmony_ci int (*atomic_get_property)(struct drm_crtc *crtc, 72762306a36Sopenharmony_ci const struct drm_crtc_state *state, 72862306a36Sopenharmony_ci struct drm_property *property, 72962306a36Sopenharmony_ci uint64_t *val); 73062306a36Sopenharmony_ci 73162306a36Sopenharmony_ci /** 73262306a36Sopenharmony_ci * @late_register: 73362306a36Sopenharmony_ci * 73462306a36Sopenharmony_ci * This optional hook can be used to register additional userspace 73562306a36Sopenharmony_ci * interfaces attached to the crtc like debugfs interfaces. 73662306a36Sopenharmony_ci * It is called late in the driver load sequence from drm_dev_register(). 73762306a36Sopenharmony_ci * Everything added from this callback should be unregistered in 73862306a36Sopenharmony_ci * the early_unregister callback. 73962306a36Sopenharmony_ci * 74062306a36Sopenharmony_ci * Returns: 74162306a36Sopenharmony_ci * 74262306a36Sopenharmony_ci * 0 on success, or a negative error code on failure. 74362306a36Sopenharmony_ci */ 74462306a36Sopenharmony_ci int (*late_register)(struct drm_crtc *crtc); 74562306a36Sopenharmony_ci 74662306a36Sopenharmony_ci /** 74762306a36Sopenharmony_ci * @early_unregister: 74862306a36Sopenharmony_ci * 74962306a36Sopenharmony_ci * This optional hook should be used to unregister the additional 75062306a36Sopenharmony_ci * userspace interfaces attached to the crtc from 75162306a36Sopenharmony_ci * @late_register. It is called from drm_dev_unregister(), 75262306a36Sopenharmony_ci * early in the driver unload sequence to disable userspace access 75362306a36Sopenharmony_ci * before data structures are torndown. 75462306a36Sopenharmony_ci */ 75562306a36Sopenharmony_ci void (*early_unregister)(struct drm_crtc *crtc); 75662306a36Sopenharmony_ci 75762306a36Sopenharmony_ci /** 75862306a36Sopenharmony_ci * @set_crc_source: 75962306a36Sopenharmony_ci * 76062306a36Sopenharmony_ci * Changes the source of CRC checksums of frames at the request of 76162306a36Sopenharmony_ci * userspace, typically for testing purposes. The sources available are 76262306a36Sopenharmony_ci * specific of each driver and a %NULL value indicates that CRC 76362306a36Sopenharmony_ci * generation is to be switched off. 76462306a36Sopenharmony_ci * 76562306a36Sopenharmony_ci * When CRC generation is enabled, the driver should call 76662306a36Sopenharmony_ci * drm_crtc_add_crc_entry() at each frame, providing any information 76762306a36Sopenharmony_ci * that characterizes the frame contents in the crcN arguments, as 76862306a36Sopenharmony_ci * provided from the configured source. Drivers must accept an "auto" 76962306a36Sopenharmony_ci * source name that will select a default source for this CRTC. 77062306a36Sopenharmony_ci * 77162306a36Sopenharmony_ci * This may trigger an atomic modeset commit if necessary, to enable CRC 77262306a36Sopenharmony_ci * generation. 77362306a36Sopenharmony_ci * 77462306a36Sopenharmony_ci * Note that "auto" can depend upon the current modeset configuration, 77562306a36Sopenharmony_ci * e.g. it could pick an encoder or output specific CRC sampling point. 77662306a36Sopenharmony_ci * 77762306a36Sopenharmony_ci * This callback is optional if the driver does not support any CRC 77862306a36Sopenharmony_ci * generation functionality. 77962306a36Sopenharmony_ci * 78062306a36Sopenharmony_ci * RETURNS: 78162306a36Sopenharmony_ci * 78262306a36Sopenharmony_ci * 0 on success or a negative error code on failure. 78362306a36Sopenharmony_ci */ 78462306a36Sopenharmony_ci int (*set_crc_source)(struct drm_crtc *crtc, const char *source); 78562306a36Sopenharmony_ci 78662306a36Sopenharmony_ci /** 78762306a36Sopenharmony_ci * @verify_crc_source: 78862306a36Sopenharmony_ci * 78962306a36Sopenharmony_ci * verifies the source of CRC checksums of frames before setting the 79062306a36Sopenharmony_ci * source for CRC and during crc open. Source parameter can be NULL 79162306a36Sopenharmony_ci * while disabling crc source. 79262306a36Sopenharmony_ci * 79362306a36Sopenharmony_ci * This callback is optional if the driver does not support any CRC 79462306a36Sopenharmony_ci * generation functionality. 79562306a36Sopenharmony_ci * 79662306a36Sopenharmony_ci * RETURNS: 79762306a36Sopenharmony_ci * 79862306a36Sopenharmony_ci * 0 on success or a negative error code on failure. 79962306a36Sopenharmony_ci */ 80062306a36Sopenharmony_ci int (*verify_crc_source)(struct drm_crtc *crtc, const char *source, 80162306a36Sopenharmony_ci size_t *values_cnt); 80262306a36Sopenharmony_ci /** 80362306a36Sopenharmony_ci * @get_crc_sources: 80462306a36Sopenharmony_ci * 80562306a36Sopenharmony_ci * Driver callback for getting a list of all the available sources for 80662306a36Sopenharmony_ci * CRC generation. This callback depends upon verify_crc_source, So 80762306a36Sopenharmony_ci * verify_crc_source callback should be implemented before implementing 80862306a36Sopenharmony_ci * this. Driver can pass full list of available crc sources, this 80962306a36Sopenharmony_ci * callback does the verification on each crc-source before passing it 81062306a36Sopenharmony_ci * to userspace. 81162306a36Sopenharmony_ci * 81262306a36Sopenharmony_ci * This callback is optional if the driver does not support exporting of 81362306a36Sopenharmony_ci * possible CRC sources list. 81462306a36Sopenharmony_ci * 81562306a36Sopenharmony_ci * RETURNS: 81662306a36Sopenharmony_ci * 81762306a36Sopenharmony_ci * a constant character pointer to the list of all the available CRC 81862306a36Sopenharmony_ci * sources. On failure driver should return NULL. count should be 81962306a36Sopenharmony_ci * updated with number of sources in list. if zero we don't process any 82062306a36Sopenharmony_ci * source from the list. 82162306a36Sopenharmony_ci */ 82262306a36Sopenharmony_ci const char *const *(*get_crc_sources)(struct drm_crtc *crtc, 82362306a36Sopenharmony_ci size_t *count); 82462306a36Sopenharmony_ci 82562306a36Sopenharmony_ci /** 82662306a36Sopenharmony_ci * @atomic_print_state: 82762306a36Sopenharmony_ci * 82862306a36Sopenharmony_ci * If driver subclasses &struct drm_crtc_state, it should implement 82962306a36Sopenharmony_ci * this optional hook for printing additional driver specific state. 83062306a36Sopenharmony_ci * 83162306a36Sopenharmony_ci * Do not call this directly, use drm_atomic_crtc_print_state() 83262306a36Sopenharmony_ci * instead. 83362306a36Sopenharmony_ci */ 83462306a36Sopenharmony_ci void (*atomic_print_state)(struct drm_printer *p, 83562306a36Sopenharmony_ci const struct drm_crtc_state *state); 83662306a36Sopenharmony_ci 83762306a36Sopenharmony_ci /** 83862306a36Sopenharmony_ci * @get_vblank_counter: 83962306a36Sopenharmony_ci * 84062306a36Sopenharmony_ci * Driver callback for fetching a raw hardware vblank counter for the 84162306a36Sopenharmony_ci * CRTC. It's meant to be used by new drivers as the replacement of 84262306a36Sopenharmony_ci * &drm_driver.get_vblank_counter hook. 84362306a36Sopenharmony_ci * 84462306a36Sopenharmony_ci * This callback is optional. If a device doesn't have a hardware 84562306a36Sopenharmony_ci * counter, the driver can simply leave the hook as NULL. The DRM core 84662306a36Sopenharmony_ci * will account for missed vblank events while interrupts where disabled 84762306a36Sopenharmony_ci * based on system timestamps. 84862306a36Sopenharmony_ci * 84962306a36Sopenharmony_ci * Wraparound handling and loss of events due to modesetting is dealt 85062306a36Sopenharmony_ci * with in the DRM core code, as long as drivers call 85162306a36Sopenharmony_ci * drm_crtc_vblank_off() and drm_crtc_vblank_on() when disabling or 85262306a36Sopenharmony_ci * enabling a CRTC. 85362306a36Sopenharmony_ci * 85462306a36Sopenharmony_ci * See also &drm_device.vblank_disable_immediate and 85562306a36Sopenharmony_ci * &drm_device.max_vblank_count. 85662306a36Sopenharmony_ci * 85762306a36Sopenharmony_ci * Returns: 85862306a36Sopenharmony_ci * 85962306a36Sopenharmony_ci * Raw vblank counter value. 86062306a36Sopenharmony_ci */ 86162306a36Sopenharmony_ci u32 (*get_vblank_counter)(struct drm_crtc *crtc); 86262306a36Sopenharmony_ci 86362306a36Sopenharmony_ci /** 86462306a36Sopenharmony_ci * @enable_vblank: 86562306a36Sopenharmony_ci * 86662306a36Sopenharmony_ci * Enable vblank interrupts for the CRTC. It's meant to be used by 86762306a36Sopenharmony_ci * new drivers as the replacement of &drm_driver.enable_vblank hook. 86862306a36Sopenharmony_ci * 86962306a36Sopenharmony_ci * Returns: 87062306a36Sopenharmony_ci * 87162306a36Sopenharmony_ci * Zero on success, appropriate errno if the vblank interrupt cannot 87262306a36Sopenharmony_ci * be enabled. 87362306a36Sopenharmony_ci */ 87462306a36Sopenharmony_ci int (*enable_vblank)(struct drm_crtc *crtc); 87562306a36Sopenharmony_ci 87662306a36Sopenharmony_ci /** 87762306a36Sopenharmony_ci * @disable_vblank: 87862306a36Sopenharmony_ci * 87962306a36Sopenharmony_ci * Disable vblank interrupts for the CRTC. It's meant to be used by 88062306a36Sopenharmony_ci * new drivers as the replacement of &drm_driver.disable_vblank hook. 88162306a36Sopenharmony_ci */ 88262306a36Sopenharmony_ci void (*disable_vblank)(struct drm_crtc *crtc); 88362306a36Sopenharmony_ci 88462306a36Sopenharmony_ci /** 88562306a36Sopenharmony_ci * @get_vblank_timestamp: 88662306a36Sopenharmony_ci * 88762306a36Sopenharmony_ci * Called by drm_get_last_vbltimestamp(). Should return a precise 88862306a36Sopenharmony_ci * timestamp when the most recent vblank interval ended or will end. 88962306a36Sopenharmony_ci * 89062306a36Sopenharmony_ci * Specifically, the timestamp in @vblank_time should correspond as 89162306a36Sopenharmony_ci * closely as possible to the time when the first video scanline of 89262306a36Sopenharmony_ci * the video frame after the end of vblank will start scanning out, 89362306a36Sopenharmony_ci * the time immediately after end of the vblank interval. If the 89462306a36Sopenharmony_ci * @crtc is currently inside vblank, this will be a time in the future. 89562306a36Sopenharmony_ci * If the @crtc is currently scanning out a frame, this will be the 89662306a36Sopenharmony_ci * past start time of the current scanout. This is meant to adhere 89762306a36Sopenharmony_ci * to the OpenML OML_sync_control extension specification. 89862306a36Sopenharmony_ci * 89962306a36Sopenharmony_ci * Parameters: 90062306a36Sopenharmony_ci * 90162306a36Sopenharmony_ci * crtc: 90262306a36Sopenharmony_ci * CRTC for which timestamp should be returned. 90362306a36Sopenharmony_ci * max_error: 90462306a36Sopenharmony_ci * Maximum allowable timestamp error in nanoseconds. 90562306a36Sopenharmony_ci * Implementation should strive to provide timestamp 90662306a36Sopenharmony_ci * with an error of at most max_error nanoseconds. 90762306a36Sopenharmony_ci * Returns true upper bound on error for timestamp. 90862306a36Sopenharmony_ci * vblank_time: 90962306a36Sopenharmony_ci * Target location for returned vblank timestamp. 91062306a36Sopenharmony_ci * in_vblank_irq: 91162306a36Sopenharmony_ci * True when called from drm_crtc_handle_vblank(). Some drivers 91262306a36Sopenharmony_ci * need to apply some workarounds for gpu-specific vblank irq quirks 91362306a36Sopenharmony_ci * if flag is set. 91462306a36Sopenharmony_ci * 91562306a36Sopenharmony_ci * Returns: 91662306a36Sopenharmony_ci * 91762306a36Sopenharmony_ci * True on success, false on failure, which means the core should 91862306a36Sopenharmony_ci * fallback to a simple timestamp taken in drm_crtc_handle_vblank(). 91962306a36Sopenharmony_ci */ 92062306a36Sopenharmony_ci bool (*get_vblank_timestamp)(struct drm_crtc *crtc, 92162306a36Sopenharmony_ci int *max_error, 92262306a36Sopenharmony_ci ktime_t *vblank_time, 92362306a36Sopenharmony_ci bool in_vblank_irq); 92462306a36Sopenharmony_ci}; 92562306a36Sopenharmony_ci 92662306a36Sopenharmony_ci/** 92762306a36Sopenharmony_ci * struct drm_crtc - central CRTC control structure 92862306a36Sopenharmony_ci * 92962306a36Sopenharmony_ci * Each CRTC may have one or more connectors associated with it. This structure 93062306a36Sopenharmony_ci * allows the CRTC to be controlled. 93162306a36Sopenharmony_ci */ 93262306a36Sopenharmony_cistruct drm_crtc { 93362306a36Sopenharmony_ci /** @dev: parent DRM device */ 93462306a36Sopenharmony_ci struct drm_device *dev; 93562306a36Sopenharmony_ci /** @port: OF node used by drm_of_find_possible_crtcs(). */ 93662306a36Sopenharmony_ci struct device_node *port; 93762306a36Sopenharmony_ci /** 93862306a36Sopenharmony_ci * @head: 93962306a36Sopenharmony_ci * 94062306a36Sopenharmony_ci * List of all CRTCs on @dev, linked from &drm_mode_config.crtc_list. 94162306a36Sopenharmony_ci * Invariant over the lifetime of @dev and therefore does not need 94262306a36Sopenharmony_ci * locking. 94362306a36Sopenharmony_ci */ 94462306a36Sopenharmony_ci struct list_head head; 94562306a36Sopenharmony_ci 94662306a36Sopenharmony_ci /** @name: human readable name, can be overwritten by the driver */ 94762306a36Sopenharmony_ci char *name; 94862306a36Sopenharmony_ci 94962306a36Sopenharmony_ci /** 95062306a36Sopenharmony_ci * @mutex: 95162306a36Sopenharmony_ci * 95262306a36Sopenharmony_ci * This provides a read lock for the overall CRTC state (mode, dpms 95362306a36Sopenharmony_ci * state, ...) and a write lock for everything which can be update 95462306a36Sopenharmony_ci * without a full modeset (fb, cursor data, CRTC properties ...). A full 95562306a36Sopenharmony_ci * modeset also need to grab &drm_mode_config.connection_mutex. 95662306a36Sopenharmony_ci * 95762306a36Sopenharmony_ci * For atomic drivers specifically this protects @state. 95862306a36Sopenharmony_ci */ 95962306a36Sopenharmony_ci struct drm_modeset_lock mutex; 96062306a36Sopenharmony_ci 96162306a36Sopenharmony_ci /** @base: base KMS object for ID tracking etc. */ 96262306a36Sopenharmony_ci struct drm_mode_object base; 96362306a36Sopenharmony_ci 96462306a36Sopenharmony_ci /** 96562306a36Sopenharmony_ci * @primary: 96662306a36Sopenharmony_ci * Primary plane for this CRTC. Note that this is only 96762306a36Sopenharmony_ci * relevant for legacy IOCTL, it specifies the plane implicitly used by 96862306a36Sopenharmony_ci * the SETCRTC and PAGE_FLIP IOCTLs. It does not have any significance 96962306a36Sopenharmony_ci * beyond that. 97062306a36Sopenharmony_ci */ 97162306a36Sopenharmony_ci struct drm_plane *primary; 97262306a36Sopenharmony_ci 97362306a36Sopenharmony_ci /** 97462306a36Sopenharmony_ci * @cursor: 97562306a36Sopenharmony_ci * Cursor plane for this CRTC. Note that this is only relevant for 97662306a36Sopenharmony_ci * legacy IOCTL, it specifies the plane implicitly used by the SETCURSOR 97762306a36Sopenharmony_ci * and SETCURSOR2 IOCTLs. It does not have any significance 97862306a36Sopenharmony_ci * beyond that. 97962306a36Sopenharmony_ci */ 98062306a36Sopenharmony_ci struct drm_plane *cursor; 98162306a36Sopenharmony_ci 98262306a36Sopenharmony_ci /** 98362306a36Sopenharmony_ci * @index: Position inside the mode_config.list, can be used as an array 98462306a36Sopenharmony_ci * index. It is invariant over the lifetime of the CRTC. 98562306a36Sopenharmony_ci */ 98662306a36Sopenharmony_ci unsigned index; 98762306a36Sopenharmony_ci 98862306a36Sopenharmony_ci /** 98962306a36Sopenharmony_ci * @cursor_x: Current x position of the cursor, used for universal 99062306a36Sopenharmony_ci * cursor planes because the SETCURSOR IOCTL only can update the 99162306a36Sopenharmony_ci * framebuffer without supplying the coordinates. Drivers should not use 99262306a36Sopenharmony_ci * this directly, atomic drivers should look at &drm_plane_state.crtc_x 99362306a36Sopenharmony_ci * of the cursor plane instead. 99462306a36Sopenharmony_ci */ 99562306a36Sopenharmony_ci int cursor_x; 99662306a36Sopenharmony_ci /** 99762306a36Sopenharmony_ci * @cursor_y: Current y position of the cursor, used for universal 99862306a36Sopenharmony_ci * cursor planes because the SETCURSOR IOCTL only can update the 99962306a36Sopenharmony_ci * framebuffer without supplying the coordinates. Drivers should not use 100062306a36Sopenharmony_ci * this directly, atomic drivers should look at &drm_plane_state.crtc_y 100162306a36Sopenharmony_ci * of the cursor plane instead. 100262306a36Sopenharmony_ci */ 100362306a36Sopenharmony_ci int cursor_y; 100462306a36Sopenharmony_ci 100562306a36Sopenharmony_ci /** 100662306a36Sopenharmony_ci * @enabled: 100762306a36Sopenharmony_ci * 100862306a36Sopenharmony_ci * Is this CRTC enabled? Should only be used by legacy drivers, atomic 100962306a36Sopenharmony_ci * drivers should instead consult &drm_crtc_state.enable and 101062306a36Sopenharmony_ci * &drm_crtc_state.active. Atomic drivers can update this by calling 101162306a36Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 101262306a36Sopenharmony_ci */ 101362306a36Sopenharmony_ci bool enabled; 101462306a36Sopenharmony_ci 101562306a36Sopenharmony_ci /** 101662306a36Sopenharmony_ci * @mode: 101762306a36Sopenharmony_ci * 101862306a36Sopenharmony_ci * Current mode timings. Should only be used by legacy drivers, atomic 101962306a36Sopenharmony_ci * drivers should instead consult &drm_crtc_state.mode. Atomic drivers 102062306a36Sopenharmony_ci * can update this by calling 102162306a36Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 102262306a36Sopenharmony_ci */ 102362306a36Sopenharmony_ci struct drm_display_mode mode; 102462306a36Sopenharmony_ci 102562306a36Sopenharmony_ci /** 102662306a36Sopenharmony_ci * @hwmode: 102762306a36Sopenharmony_ci * 102862306a36Sopenharmony_ci * Programmed mode in hw, after adjustments for encoders, crtc, panel 102962306a36Sopenharmony_ci * scaling etc. Should only be used by legacy drivers, for high 103062306a36Sopenharmony_ci * precision vblank timestamps in 103162306a36Sopenharmony_ci * drm_crtc_vblank_helper_get_vblank_timestamp(). 103262306a36Sopenharmony_ci * 103362306a36Sopenharmony_ci * Note that atomic drivers should not use this, but instead use 103462306a36Sopenharmony_ci * &drm_crtc_state.adjusted_mode. And for high-precision timestamps 103562306a36Sopenharmony_ci * drm_crtc_vblank_helper_get_vblank_timestamp() used 103662306a36Sopenharmony_ci * &drm_vblank_crtc.hwmode, 103762306a36Sopenharmony_ci * which is filled out by calling drm_calc_timestamping_constants(). 103862306a36Sopenharmony_ci */ 103962306a36Sopenharmony_ci struct drm_display_mode hwmode; 104062306a36Sopenharmony_ci 104162306a36Sopenharmony_ci /** 104262306a36Sopenharmony_ci * @x: 104362306a36Sopenharmony_ci * x position on screen. Should only be used by legacy drivers, atomic 104462306a36Sopenharmony_ci * drivers should look at &drm_plane_state.crtc_x of the primary plane 104562306a36Sopenharmony_ci * instead. Updated by calling 104662306a36Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 104762306a36Sopenharmony_ci */ 104862306a36Sopenharmony_ci int x; 104962306a36Sopenharmony_ci /** 105062306a36Sopenharmony_ci * @y: 105162306a36Sopenharmony_ci * y position on screen. Should only be used by legacy drivers, atomic 105262306a36Sopenharmony_ci * drivers should look at &drm_plane_state.crtc_y of the primary plane 105362306a36Sopenharmony_ci * instead. Updated by calling 105462306a36Sopenharmony_ci * drm_atomic_helper_update_legacy_modeset_state(). 105562306a36Sopenharmony_ci */ 105662306a36Sopenharmony_ci int y; 105762306a36Sopenharmony_ci 105862306a36Sopenharmony_ci /** @funcs: CRTC control functions */ 105962306a36Sopenharmony_ci const struct drm_crtc_funcs *funcs; 106062306a36Sopenharmony_ci 106162306a36Sopenharmony_ci /** 106262306a36Sopenharmony_ci * @gamma_size: Size of legacy gamma ramp reported to userspace. Set up 106362306a36Sopenharmony_ci * by calling drm_mode_crtc_set_gamma_size(). 106462306a36Sopenharmony_ci * 106562306a36Sopenharmony_ci * Note that atomic drivers need to instead use 106662306a36Sopenharmony_ci * &drm_crtc_state.gamma_lut. See drm_crtc_enable_color_mgmt(). 106762306a36Sopenharmony_ci */ 106862306a36Sopenharmony_ci uint32_t gamma_size; 106962306a36Sopenharmony_ci 107062306a36Sopenharmony_ci /** 107162306a36Sopenharmony_ci * @gamma_store: Gamma ramp values used by the legacy SETGAMMA and 107262306a36Sopenharmony_ci * GETGAMMA IOCTls. Set up by calling drm_mode_crtc_set_gamma_size(). 107362306a36Sopenharmony_ci * 107462306a36Sopenharmony_ci * Note that atomic drivers need to instead use 107562306a36Sopenharmony_ci * &drm_crtc_state.gamma_lut. See drm_crtc_enable_color_mgmt(). 107662306a36Sopenharmony_ci */ 107762306a36Sopenharmony_ci uint16_t *gamma_store; 107862306a36Sopenharmony_ci 107962306a36Sopenharmony_ci /** @helper_private: mid-layer private data */ 108062306a36Sopenharmony_ci const struct drm_crtc_helper_funcs *helper_private; 108162306a36Sopenharmony_ci 108262306a36Sopenharmony_ci /** @properties: property tracking for this CRTC */ 108362306a36Sopenharmony_ci struct drm_object_properties properties; 108462306a36Sopenharmony_ci 108562306a36Sopenharmony_ci /** 108662306a36Sopenharmony_ci * @scaling_filter_property: property to apply a particular filter while 108762306a36Sopenharmony_ci * scaling. 108862306a36Sopenharmony_ci */ 108962306a36Sopenharmony_ci struct drm_property *scaling_filter_property; 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_ci /** 109262306a36Sopenharmony_ci * @state: 109362306a36Sopenharmony_ci * 109462306a36Sopenharmony_ci * Current atomic state for this CRTC. 109562306a36Sopenharmony_ci * 109662306a36Sopenharmony_ci * This is protected by @mutex. Note that nonblocking atomic commits 109762306a36Sopenharmony_ci * access the current CRTC state without taking locks. Either by going 109862306a36Sopenharmony_ci * through the &struct drm_atomic_state pointers, see 109962306a36Sopenharmony_ci * for_each_oldnew_crtc_in_state(), for_each_old_crtc_in_state() and 110062306a36Sopenharmony_ci * for_each_new_crtc_in_state(). Or through careful ordering of atomic 110162306a36Sopenharmony_ci * commit operations as implemented in the atomic helpers, see 110262306a36Sopenharmony_ci * &struct drm_crtc_commit. 110362306a36Sopenharmony_ci */ 110462306a36Sopenharmony_ci struct drm_crtc_state *state; 110562306a36Sopenharmony_ci 110662306a36Sopenharmony_ci /** 110762306a36Sopenharmony_ci * @commit_list: 110862306a36Sopenharmony_ci * 110962306a36Sopenharmony_ci * List of &drm_crtc_commit structures tracking pending commits. 111062306a36Sopenharmony_ci * Protected by @commit_lock. This list holds its own full reference, 111162306a36Sopenharmony_ci * as does the ongoing commit. 111262306a36Sopenharmony_ci * 111362306a36Sopenharmony_ci * "Note that the commit for a state change is also tracked in 111462306a36Sopenharmony_ci * &drm_crtc_state.commit. For accessing the immediately preceding 111562306a36Sopenharmony_ci * commit in an atomic update it is recommended to just use that 111662306a36Sopenharmony_ci * pointer in the old CRTC state, since accessing that doesn't need 111762306a36Sopenharmony_ci * any locking or list-walking. @commit_list should only be used to 111862306a36Sopenharmony_ci * stall for framebuffer cleanup that's signalled through 111962306a36Sopenharmony_ci * &drm_crtc_commit.cleanup_done." 112062306a36Sopenharmony_ci */ 112162306a36Sopenharmony_ci struct list_head commit_list; 112262306a36Sopenharmony_ci 112362306a36Sopenharmony_ci /** 112462306a36Sopenharmony_ci * @commit_lock: 112562306a36Sopenharmony_ci * 112662306a36Sopenharmony_ci * Spinlock to protect @commit_list. 112762306a36Sopenharmony_ci */ 112862306a36Sopenharmony_ci spinlock_t commit_lock; 112962306a36Sopenharmony_ci 113062306a36Sopenharmony_ci /** 113162306a36Sopenharmony_ci * @debugfs_entry: 113262306a36Sopenharmony_ci * 113362306a36Sopenharmony_ci * Debugfs directory for this CRTC. 113462306a36Sopenharmony_ci */ 113562306a36Sopenharmony_ci struct dentry *debugfs_entry; 113662306a36Sopenharmony_ci 113762306a36Sopenharmony_ci /** 113862306a36Sopenharmony_ci * @crc: 113962306a36Sopenharmony_ci * 114062306a36Sopenharmony_ci * Configuration settings of CRC capture. 114162306a36Sopenharmony_ci */ 114262306a36Sopenharmony_ci struct drm_crtc_crc crc; 114362306a36Sopenharmony_ci 114462306a36Sopenharmony_ci /** 114562306a36Sopenharmony_ci * @fence_context: 114662306a36Sopenharmony_ci * 114762306a36Sopenharmony_ci * timeline context used for fence operations. 114862306a36Sopenharmony_ci */ 114962306a36Sopenharmony_ci unsigned int fence_context; 115062306a36Sopenharmony_ci 115162306a36Sopenharmony_ci /** 115262306a36Sopenharmony_ci * @fence_lock: 115362306a36Sopenharmony_ci * 115462306a36Sopenharmony_ci * spinlock to protect the fences in the fence_context. 115562306a36Sopenharmony_ci */ 115662306a36Sopenharmony_ci spinlock_t fence_lock; 115762306a36Sopenharmony_ci /** 115862306a36Sopenharmony_ci * @fence_seqno: 115962306a36Sopenharmony_ci * 116062306a36Sopenharmony_ci * Seqno variable used as monotonic counter for the fences 116162306a36Sopenharmony_ci * created on the CRTC's timeline. 116262306a36Sopenharmony_ci */ 116362306a36Sopenharmony_ci unsigned long fence_seqno; 116462306a36Sopenharmony_ci 116562306a36Sopenharmony_ci /** 116662306a36Sopenharmony_ci * @timeline_name: 116762306a36Sopenharmony_ci * 116862306a36Sopenharmony_ci * The name of the CRTC's fence timeline. 116962306a36Sopenharmony_ci */ 117062306a36Sopenharmony_ci char timeline_name[32]; 117162306a36Sopenharmony_ci 117262306a36Sopenharmony_ci /** 117362306a36Sopenharmony_ci * @self_refresh_data: Holds the state for the self refresh helpers 117462306a36Sopenharmony_ci * 117562306a36Sopenharmony_ci * Initialized via drm_self_refresh_helper_init(). 117662306a36Sopenharmony_ci */ 117762306a36Sopenharmony_ci struct drm_self_refresh_data *self_refresh_data; 117862306a36Sopenharmony_ci}; 117962306a36Sopenharmony_ci 118062306a36Sopenharmony_ci/** 118162306a36Sopenharmony_ci * struct drm_mode_set - new values for a CRTC config change 118262306a36Sopenharmony_ci * @fb: framebuffer to use for new config 118362306a36Sopenharmony_ci * @crtc: CRTC whose configuration we're about to change 118462306a36Sopenharmony_ci * @mode: mode timings to use 118562306a36Sopenharmony_ci * @x: position of this CRTC relative to @fb 118662306a36Sopenharmony_ci * @y: position of this CRTC relative to @fb 118762306a36Sopenharmony_ci * @connectors: array of connectors to drive with this CRTC if possible 118862306a36Sopenharmony_ci * @num_connectors: size of @connectors array 118962306a36Sopenharmony_ci * 119062306a36Sopenharmony_ci * This represents a modeset configuration for the legacy SETCRTC ioctl and is 119162306a36Sopenharmony_ci * also used internally. Atomic drivers instead use &drm_atomic_state. 119262306a36Sopenharmony_ci */ 119362306a36Sopenharmony_cistruct drm_mode_set { 119462306a36Sopenharmony_ci struct drm_framebuffer *fb; 119562306a36Sopenharmony_ci struct drm_crtc *crtc; 119662306a36Sopenharmony_ci struct drm_display_mode *mode; 119762306a36Sopenharmony_ci 119862306a36Sopenharmony_ci uint32_t x; 119962306a36Sopenharmony_ci uint32_t y; 120062306a36Sopenharmony_ci 120162306a36Sopenharmony_ci struct drm_connector **connectors; 120262306a36Sopenharmony_ci size_t num_connectors; 120362306a36Sopenharmony_ci}; 120462306a36Sopenharmony_ci 120562306a36Sopenharmony_ci#define obj_to_crtc(x) container_of(x, struct drm_crtc, base) 120662306a36Sopenharmony_ci 120762306a36Sopenharmony_ci__printf(6, 7) 120862306a36Sopenharmony_ciint drm_crtc_init_with_planes(struct drm_device *dev, 120962306a36Sopenharmony_ci struct drm_crtc *crtc, 121062306a36Sopenharmony_ci struct drm_plane *primary, 121162306a36Sopenharmony_ci struct drm_plane *cursor, 121262306a36Sopenharmony_ci const struct drm_crtc_funcs *funcs, 121362306a36Sopenharmony_ci const char *name, ...); 121462306a36Sopenharmony_ci 121562306a36Sopenharmony_ci__printf(6, 7) 121662306a36Sopenharmony_ciint drmm_crtc_init_with_planes(struct drm_device *dev, 121762306a36Sopenharmony_ci struct drm_crtc *crtc, 121862306a36Sopenharmony_ci struct drm_plane *primary, 121962306a36Sopenharmony_ci struct drm_plane *cursor, 122062306a36Sopenharmony_ci const struct drm_crtc_funcs *funcs, 122162306a36Sopenharmony_ci const char *name, ...); 122262306a36Sopenharmony_ci 122362306a36Sopenharmony_civoid drm_crtc_cleanup(struct drm_crtc *crtc); 122462306a36Sopenharmony_ci 122562306a36Sopenharmony_ci__printf(7, 8) 122662306a36Sopenharmony_civoid *__drmm_crtc_alloc_with_planes(struct drm_device *dev, 122762306a36Sopenharmony_ci size_t size, size_t offset, 122862306a36Sopenharmony_ci struct drm_plane *primary, 122962306a36Sopenharmony_ci struct drm_plane *cursor, 123062306a36Sopenharmony_ci const struct drm_crtc_funcs *funcs, 123162306a36Sopenharmony_ci const char *name, ...); 123262306a36Sopenharmony_ci 123362306a36Sopenharmony_ci/** 123462306a36Sopenharmony_ci * drmm_crtc_alloc_with_planes - Allocate and initialize a new CRTC object with 123562306a36Sopenharmony_ci * specified primary and cursor planes. 123662306a36Sopenharmony_ci * @dev: DRM device 123762306a36Sopenharmony_ci * @type: the type of the struct which contains struct &drm_crtc 123862306a36Sopenharmony_ci * @member: the name of the &drm_crtc within @type. 123962306a36Sopenharmony_ci * @primary: Primary plane for CRTC 124062306a36Sopenharmony_ci * @cursor: Cursor plane for CRTC 124162306a36Sopenharmony_ci * @funcs: callbacks for the new CRTC 124262306a36Sopenharmony_ci * @name: printf style format string for the CRTC name, or NULL for default name 124362306a36Sopenharmony_ci * 124462306a36Sopenharmony_ci * Allocates and initializes a new crtc object. Cleanup is automatically 124562306a36Sopenharmony_ci * handled through registering drmm_crtc_cleanup() with drmm_add_action(). 124662306a36Sopenharmony_ci * 124762306a36Sopenharmony_ci * The @drm_crtc_funcs.destroy hook must be NULL. 124862306a36Sopenharmony_ci * 124962306a36Sopenharmony_ci * Returns: 125062306a36Sopenharmony_ci * Pointer to new crtc, or ERR_PTR on failure. 125162306a36Sopenharmony_ci */ 125262306a36Sopenharmony_ci#define drmm_crtc_alloc_with_planes(dev, type, member, primary, cursor, funcs, name, ...) \ 125362306a36Sopenharmony_ci ((type *)__drmm_crtc_alloc_with_planes(dev, sizeof(type), \ 125462306a36Sopenharmony_ci offsetof(type, member), \ 125562306a36Sopenharmony_ci primary, cursor, funcs, \ 125662306a36Sopenharmony_ci name, ##__VA_ARGS__)) 125762306a36Sopenharmony_ci 125862306a36Sopenharmony_ci/** 125962306a36Sopenharmony_ci * drm_crtc_index - find the index of a registered CRTC 126062306a36Sopenharmony_ci * @crtc: CRTC to find index for 126162306a36Sopenharmony_ci * 126262306a36Sopenharmony_ci * Given a registered CRTC, return the index of that CRTC within a DRM 126362306a36Sopenharmony_ci * device's list of CRTCs. 126462306a36Sopenharmony_ci */ 126562306a36Sopenharmony_cistatic inline unsigned int drm_crtc_index(const struct drm_crtc *crtc) 126662306a36Sopenharmony_ci{ 126762306a36Sopenharmony_ci return crtc->index; 126862306a36Sopenharmony_ci} 126962306a36Sopenharmony_ci 127062306a36Sopenharmony_ci/** 127162306a36Sopenharmony_ci * drm_crtc_mask - find the mask of a registered CRTC 127262306a36Sopenharmony_ci * @crtc: CRTC to find mask for 127362306a36Sopenharmony_ci * 127462306a36Sopenharmony_ci * Given a registered CRTC, return the mask bit of that CRTC for the 127562306a36Sopenharmony_ci * &drm_encoder.possible_crtcs and &drm_plane.possible_crtcs fields. 127662306a36Sopenharmony_ci */ 127762306a36Sopenharmony_cistatic inline uint32_t drm_crtc_mask(const struct drm_crtc *crtc) 127862306a36Sopenharmony_ci{ 127962306a36Sopenharmony_ci return 1 << drm_crtc_index(crtc); 128062306a36Sopenharmony_ci} 128162306a36Sopenharmony_ci 128262306a36Sopenharmony_ciint drm_mode_set_config_internal(struct drm_mode_set *set); 128362306a36Sopenharmony_cistruct drm_crtc *drm_crtc_from_index(struct drm_device *dev, int idx); 128462306a36Sopenharmony_ci 128562306a36Sopenharmony_ci/** 128662306a36Sopenharmony_ci * drm_crtc_find - look up a CRTC object from its ID 128762306a36Sopenharmony_ci * @dev: DRM device 128862306a36Sopenharmony_ci * @file_priv: drm file to check for lease against. 128962306a36Sopenharmony_ci * @id: &drm_mode_object ID 129062306a36Sopenharmony_ci * 129162306a36Sopenharmony_ci * This can be used to look up a CRTC from its userspace ID. Only used by 129262306a36Sopenharmony_ci * drivers for legacy IOCTLs and interface, nowadays extensions to the KMS 129362306a36Sopenharmony_ci * userspace interface should be done using &drm_property. 129462306a36Sopenharmony_ci */ 129562306a36Sopenharmony_cistatic inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, 129662306a36Sopenharmony_ci struct drm_file *file_priv, 129762306a36Sopenharmony_ci uint32_t id) 129862306a36Sopenharmony_ci{ 129962306a36Sopenharmony_ci struct drm_mode_object *mo; 130062306a36Sopenharmony_ci mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CRTC); 130162306a36Sopenharmony_ci return mo ? obj_to_crtc(mo) : NULL; 130262306a36Sopenharmony_ci} 130362306a36Sopenharmony_ci 130462306a36Sopenharmony_ci/** 130562306a36Sopenharmony_ci * drm_for_each_crtc - iterate over all CRTCs 130662306a36Sopenharmony_ci * @crtc: a &struct drm_crtc as the loop cursor 130762306a36Sopenharmony_ci * @dev: the &struct drm_device 130862306a36Sopenharmony_ci * 130962306a36Sopenharmony_ci * Iterate over all CRTCs of @dev. 131062306a36Sopenharmony_ci */ 131162306a36Sopenharmony_ci#define drm_for_each_crtc(crtc, dev) \ 131262306a36Sopenharmony_ci list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) 131362306a36Sopenharmony_ci 131462306a36Sopenharmony_ci/** 131562306a36Sopenharmony_ci * drm_for_each_crtc_reverse - iterate over all CRTCs in reverse order 131662306a36Sopenharmony_ci * @crtc: a &struct drm_crtc as the loop cursor 131762306a36Sopenharmony_ci * @dev: the &struct drm_device 131862306a36Sopenharmony_ci * 131962306a36Sopenharmony_ci * Iterate over all CRTCs of @dev. 132062306a36Sopenharmony_ci */ 132162306a36Sopenharmony_ci#define drm_for_each_crtc_reverse(crtc, dev) \ 132262306a36Sopenharmony_ci list_for_each_entry_reverse(crtc, &(dev)->mode_config.crtc_list, head) 132362306a36Sopenharmony_ci 132462306a36Sopenharmony_ciint drm_crtc_create_scaling_filter_property(struct drm_crtc *crtc, 132562306a36Sopenharmony_ci unsigned int supported_filters); 132662306a36Sopenharmony_ci 132762306a36Sopenharmony_ci#endif /* __DRM_CRTC_H__ */ 1328