^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright (c) 2016 Intel Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Permission to use, copy, modify, distribute, and sell this software and its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * documentation for any purpose is hereby granted without fee, provided that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * the above copyright notice appear in all copies and that both that copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * notice and this permission notice appear in supporting documentation, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * that the name of the copyright holders not be used in advertising or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * publicity pertaining to distribution of the software without specific,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * written prior permission. The copyright holders make no representations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * about the suitability of this software for any purpose. It is provided "as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * is" without express or implied warranty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * OF THIS SOFTWARE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #ifndef __DRM_ENCODER_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define __DRM_ENCODER_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <drm/drm_crtc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <drm/drm_mode.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <drm/drm_mode_object.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <drm/drm_util.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct drm_encoder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * struct drm_encoder_funcs - encoder controls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * Encoders sit between CRTCs and connectors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct drm_encoder_funcs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * @reset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * Reset encoder hardware and software state to off. This function isn't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * called by the core directly, only through drm_mode_config_reset().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * It's not a helper hook only for historical reasons.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) void (*reset)(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @destroy:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * Clean up encoder resources. This is only called at driver unload time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * through drm_mode_config_cleanup() since an encoder cannot be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * hotplugged in DRM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) void (*destroy)(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) * @late_register:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * This optional hook can be used to register additional userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * interfaces attached to the encoder like debugfs interfaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * It is called late in the driver load sequence from drm_dev_register().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * Everything added from this callback should be unregistered in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * the early_unregister callback.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * 0 on success, or a negative error code on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int (*late_register)(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * @early_unregister:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * This optional hook should be used to unregister the additional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * userspace interfaces attached to the encoder from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * @late_register. It is called from drm_dev_unregister(),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * early in the driver unload sequence to disable userspace access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * before data structures are torndown.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) void (*early_unregister)(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * struct drm_encoder - central DRM encoder structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * @dev: parent DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * @head: list management
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * @base: base KMS object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * @name: human readable name, can be overwritten by the driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * @bridge: bridge associated to the encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @funcs: control functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * @helper_private: mid-layer private data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * CRTCs drive pixels to encoders, which convert them into signals
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) * appropriate for a given connector or set of connectors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct drm_encoder {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct drm_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct list_head head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct drm_mode_object base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * @encoder_type:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * One of the DRM_MODE_ENCODER_<foo> types in drm_mode.h. The following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * encoder types are defined thus far:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * - DRM_MODE_ENCODER_DAC for VGA and analog on DVI-I/DVI-A.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * - DRM_MODE_ENCODER_TMDS for DVI, HDMI and (embedded) DisplayPort.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * - DRM_MODE_ENCODER_LVDS for display panels, or in general any panel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * with a proprietary parallel connector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) * - DRM_MODE_ENCODER_TVDAC for TV output (Composite, S-Video,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) * Component, SCART).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * - DRM_MODE_ENCODER_VIRTUAL for virtual machine displays
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * - DRM_MODE_ENCODER_DSI for panels connected using the DSI serial bus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * - DRM_MODE_ENCODER_DPI for panels connected using the DPI parallel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * bus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * - DRM_MODE_ENCODER_DPMST for special fake encoders used to allow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * mutliple DP MST streams to share one physical encoder.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int encoder_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * @index: Position inside the mode_config.list, can be used as an array
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * index. It is invariant over the lifetime of the encoder.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) unsigned index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * @possible_crtcs: Bitmask of potential CRTC bindings, using
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * drm_crtc_index() as the index into the bitfield. The driver must set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * the bits for all &drm_crtc objects this encoder can be connected to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * before calling drm_dev_register().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) * You will get a WARN if you get this wrong in the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) * Note that since CRTC objects can't be hotplugged the assigned indices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * are stable and hence known before registering all objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) uint32_t possible_crtcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * @possible_clones: Bitmask of potential sibling encoders for cloning,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * using drm_encoder_index() as the index into the bitfield. The driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * must set the bits for all &drm_encoder objects which can clone a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * &drm_crtc together with this encoder before calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * drm_dev_register(). Drivers should set the bit representing the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * encoder itself, too. Cloning bits should be set such that when two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * encoders can be used in a cloned configuration, they both should have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) * each another bits set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * As an exception to the above rule if the driver doesn't implement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * any cloning it can leave @possible_clones set to 0. The core will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * automagically fix this up by setting the bit for the encoder itself.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * You will get a WARN if you get this wrong in the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * Note that since encoder objects can't be hotplugged the assigned indices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * are stable and hence known before registering all objects.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) uint32_t possible_clones;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * @crtc: Currently bound CRTC, only really meaningful for non-atomic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * drivers. Atomic drivers should instead check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * &drm_connector_state.crtc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct drm_crtc *crtc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * @bridge_chain: Bridges attached to this encoder. Drivers shall not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * access this field directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct list_head bridge_chain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) const struct drm_encoder_funcs *funcs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) const struct drm_encoder_helper_funcs *helper_private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) #define obj_to_encoder(x) container_of(x, struct drm_encoder, base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) __printf(5, 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int drm_encoder_init(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) const struct drm_encoder_funcs *funcs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) int encoder_type, const char *name, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * drm_encoder_index - find the index of a registered encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * @encoder: encoder to find index for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * Given a registered encoder, return the index of that encoder within a DRM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * device's list of encoders.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static inline unsigned int drm_encoder_index(const struct drm_encoder *encoder)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return encoder->index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * drm_encoder_mask - find the mask of a registered encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * @encoder: encoder to find mask for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) * Given a registered encoder, return the mask bit of that encoder for an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) * encoder's possible_clones field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static inline u32 drm_encoder_mask(const struct drm_encoder *encoder)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) return 1 << drm_encoder_index(encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * drm_encoder_crtc_ok - can a given crtc drive a given encoder?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * @encoder: encoder to test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) * @crtc: crtc to test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) * Returns false if @encoder can't be driven by @crtc, true otherwise.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct drm_crtc *crtc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) return !!(encoder->possible_crtcs & drm_crtc_mask(crtc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) * drm_encoder_find - find a &drm_encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * @dev: DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * @file_priv: drm file to check for lease against.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * @id: encoder id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * Returns the encoder with @id, NULL if it doesn't exist. Simple wrapper around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * drm_mode_object_find().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct drm_file *file_priv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) uint32_t id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct drm_mode_object *mo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_ENCODER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return mo ? obj_to_encoder(mo) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) void drm_encoder_cleanup(struct drm_encoder *encoder);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * drm_for_each_encoder_mask - iterate over encoders specified by bitmask
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * @encoder: the loop cursor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) * @dev: the DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) * @encoder_mask: bitmask of encoder indices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) * Iterate over all encoders specified by bitmask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) for_each_if ((encoder_mask) & drm_encoder_mask(encoder))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * drm_for_each_encoder - iterate over all encoders
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * @encoder: the loop cursor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) * @dev: the DRM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) * Iterate over all encoders of @dev.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #define drm_for_each_encoder(encoder, dev) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) #endif