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_DEV_H__
24 #define __INTEL_DVO_DEV_H__
25 
26 #include "i915_reg_defs.h"
27 
28 #include "intel_display_limits.h"
29 
30 enum drm_connector_status;
31 struct drm_display_mode;
32 struct i2c_adapter;
33 
34 struct intel_dvo_device {
35 	const char *name;
36 	int type;
37 	/* DVOA/B/C */
38 	enum port port;
39 	/* GPIO register used for i2c bus to control this device */
40 	u32 gpio;
41 	int slave_addr;
42 
43 	const struct intel_dvo_dev_ops *dev_ops;
44 	void *dev_priv;
45 	struct i2c_adapter *i2c_bus;
46 };
47 
48 struct intel_dvo_dev_ops {
49 	/*
50 	 * Initialize the device at startup time.
51 	 * Returns NULL if the device does not exist.
52 	 */
53 	bool (*init)(struct intel_dvo_device *dvo,
54 		     struct i2c_adapter *i2cbus);
55 
56 	/*
57 	 * Called to allow the output a chance to create properties after the
58 	 * RandR objects have been created.
59 	 */
60 	void (*create_resources)(struct intel_dvo_device *dvo);
61 
62 	/*
63 	 * Turn on/off output.
64 	 *
65 	 * Because none of our dvo drivers support an intermediate power levels,
66 	 * we don't expose this in the interfac.
67 	 */
68 	void (*dpms)(struct intel_dvo_device *dvo, bool enable);
69 
70 	/*
71 	 * Callback for testing a video mode for a given output.
72 	 *
73 	 * This function should only check for cases where a mode can't
74 	 * be supported on the output specifically, and not represent
75 	 * generic CRTC limitations.
76 	 *
77 	 * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
78 	 */
79 	enum drm_mode_status (*mode_valid)(struct intel_dvo_device *dvo,
80 					   struct drm_display_mode *mode);
81 
82 	/*
83 	 * Callback for preparing mode changes on an output
84 	 */
85 	void (*prepare)(struct intel_dvo_device *dvo);
86 
87 	/*
88 	 * Callback for committing mode changes on an output
89 	 */
90 	void (*commit)(struct intel_dvo_device *dvo);
91 
92 	/*
93 	 * Callback for setting up a video mode after fixups have been made.
94 	 *
95 	 * This is only called while the output is disabled.  The dpms callback
96 	 * must be all that's necessary for the output, to turn the output on
97 	 * after this function is called.
98 	 */
99 	void (*mode_set)(struct intel_dvo_device *dvo,
100 			 const struct drm_display_mode *mode,
101 			 const struct drm_display_mode *adjusted_mode);
102 
103 	/*
104 	 * Probe for a connected output, and return detect_status.
105 	 */
106 	enum drm_connector_status (*detect)(struct intel_dvo_device *dvo);
107 
108 	/*
109 	 * Probe the current hw status, returning true if the connected output
110 	 * is active.
111 	 */
112 	bool (*get_hw_state)(struct intel_dvo_device *dev);
113 
114 	/**
115 	 * Query the device for the modes it provides.
116 	 *
117 	 * This function may also update MonInfo, mm_width, and mm_height.
118 	 *
119 	 * \return singly-linked list of modes or NULL if no modes found.
120 	 */
121 	struct drm_display_mode *(*get_modes)(struct intel_dvo_device *dvo);
122 
123 	/**
124 	 * Clean up driver-specific bits of the output
125 	 */
126 	void (*destroy) (struct intel_dvo_device *dvo);
127 
128 	/**
129 	 * Debugging hook to dump device registers to log file
130 	 */
131 	void (*dump_regs)(struct intel_dvo_device *dvo);
132 };
133 
134 extern const struct intel_dvo_dev_ops sil164_ops;
135 extern const struct intel_dvo_dev_ops ch7xxx_ops;
136 extern const struct intel_dvo_dev_ops ivch_ops;
137 extern const struct intel_dvo_dev_ops tfp410_ops;
138 extern const struct intel_dvo_dev_ops ch7017_ops;
139 extern const struct intel_dvo_dev_ops ns2501_ops;
140 
141 #endif /* __INTEL_DVO_DEV_H__ */
142