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