1 /* 2 * Copyright © 2006 Eric Anholt 3 * 4 * Permission to use, copy, modify, distribute, and sell this software and its 5 * documentation for any purpose is hereby granted without fee, provided that 6 * the above copyright notice appear in all copies and that both that copyright 7 * notice and this permission notice appear in supporting documentation, and 8 * that the name of the copyright holders not be used in advertising or 9 * publicity pertaining to distribution of the software without specific, 10 * written prior permission. The copyright holders make no representations 11 * about the suitability of this software for any purpose. It is provided "as 12 * is" without express or implied warranty. 13 * 14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20 * OF THIS SOFTWARE. 21 */ 22 23 #ifndef _INTEL_DVO_H 24 #define _INTEL_DVO_H 25 26 #include <sys/cdefs.h> 27 __FBSDID("$FreeBSD: stable/12/sys/dev/drm2/i915/dvo.h 338285 2018-08-24 00:02:00Z imp $"); 28 29 #include <sys/types.h> 30 #include <sys/bus.h> 31 #include <dev/iicbus/iic.h> 32 #include <dev/iicbus/iiconf.h> 33 #include <dev/drm2/drmP.h> 34 #include <dev/drm2/drm_crtc.h> 35 #include "intel_drv.h" 36 37 struct intel_dvo_device { 38 const char *name; 39 int type; 40 /* DVOA/B/C output register */ 41 u32 dvo_reg; 42 /* GPIO register used for i2c bus to control this device */ 43 u32 gpio; 44 int slave_addr; 45 46 const struct intel_dvo_dev_ops *dev_ops; 47 void *dev_priv; 48 device_t i2c_bus; 49 }; 50 51 struct intel_dvo_dev_ops { 52 /* 53 * Initialize the device at startup time. 54 * Returns NULL if the device does not exist. 55 */ 56 bool (*init)(struct intel_dvo_device *dvo, 57 device_t i2cbus); 58 59 /* 60 * Called to allow the output a chance to create properties after the 61 * RandR objects have been created. 62 */ 63 void (*create_resources)(struct intel_dvo_device *dvo); 64 65 /* 66 * Turn on/off output. 67 * 68 * Because none of our dvo drivers support an intermediate power levels, 69 * we don't expose this in the interfac. 70 */ 71 void (*dpms)(struct intel_dvo_device *dvo, bool enable); 72 73 /* 74 * Callback for testing a video mode for a given output. 75 * 76 * This function should only check for cases where a mode can't 77 * be supported on the output specifically, and not represent 78 * generic CRTC limitations. 79 * 80 * \return MODE_OK if the mode is valid, or another MODE_* otherwise. 81 */ 82 int (*mode_valid)(struct intel_dvo_device *dvo, 83 struct drm_display_mode *mode); 84 85 /* 86 * Callback to adjust the mode to be set in the CRTC. 87 * 88 * This allows an output to adjust the clock or even the entire set of 89 * timings, which is used for panels with fixed timings or for 90 * buses with clock limitations. 91 */ 92 bool (*mode_fixup)(struct intel_dvo_device *dvo, 93 const struct drm_display_mode *mode, 94 struct drm_display_mode *adjusted_mode); 95 96 /* 97 * Callback for preparing mode changes on an output 98 */ 99 void (*prepare)(struct intel_dvo_device *dvo); 100 101 /* 102 * Callback for committing mode changes on an output 103 */ 104 void (*commit)(struct intel_dvo_device *dvo); 105 106 /* 107 * Callback for setting up a video mode after fixups have been made. 108 * 109 * This is only called while the output is disabled. The dpms callback 110 * must be all that's necessary for the output, to turn the output on 111 * after this function is called. 112 */ 113 void (*mode_set)(struct intel_dvo_device *dvo, 114 struct drm_display_mode *mode, 115 struct drm_display_mode *adjusted_mode); 116 117 /* 118 * Probe for a connected output, and return detect_status. 119 */ 120 enum drm_connector_status (*detect)(struct intel_dvo_device *dvo); 121 122 /* 123 * Probe the current hw status, returning true if the connected output 124 * is active. 125 */ 126 bool (*get_hw_state)(struct intel_dvo_device *dev); 127 128 /** 129 * Query the device for the modes it provides. 130 * 131 * This function may also update MonInfo, mm_width, and mm_height. 132 * 133 * \return singly-linked list of modes or NULL if no modes found. 134 */ 135 struct drm_display_mode *(*get_modes)(struct intel_dvo_device *dvo); 136 137 /** 138 * Clean up driver-specific bits of the output 139 */ 140 void (*destroy) (struct intel_dvo_device *dvo); 141 142 /** 143 * Debugging hook to dump device registers to log file 144 */ 145 void (*dump_regs)(struct intel_dvo_device *dvo); 146 }; 147 148 extern struct intel_dvo_dev_ops sil164_ops; 149 extern struct intel_dvo_dev_ops ch7xxx_ops; 150 extern struct intel_dvo_dev_ops ivch_ops; 151 extern struct intel_dvo_dev_ops tfp410_ops; 152 extern struct intel_dvo_dev_ops ch7017_ops; 153 extern struct intel_dvo_dev_ops ns2501_ops; 154 155 #endif /* _INTEL_DVO_H */ 156