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