blob: 33a62ad80100f8912e7e56f46a06c147e5203736 [file] [log] [blame]
Jesse Barnes79e53942008-11-07 14:24:08 -08001/*
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 <linux/i2c.h>
David Howells760285e2012-10-02 18:01:07 +010027#include <drm/drmP.h>
28#include <drm/drm_crtc.h>
Jesse Barnes79e53942008-11-07 14:24:08 -080029#include "intel_drv.h"
30
31struct intel_dvo_device {
Chris Wilsonea5b2132010-08-04 13:50:23 +010032 const char *name;
Jesse Barnes79e53942008-11-07 14:24:08 -080033 int type;
34 /* DVOA/B/C output register */
35 u32 dvo_reg;
36 /* GPIO register used for i2c bus to control this device */
37 u32 gpio;
38 int slave_addr;
Jesse Barnes79e53942008-11-07 14:24:08 -080039
40 const struct intel_dvo_dev_ops *dev_ops;
41 void *dev_priv;
Chris Wilsonea5b2132010-08-04 13:50:23 +010042 struct i2c_adapter *i2c_bus;
Jesse Barnes79e53942008-11-07 14:24:08 -080043};
44
45struct intel_dvo_dev_ops {
46 /*
47 * Initialize the device at startup time.
48 * Returns NULL if the device does not exist.
49 */
50 bool (*init)(struct intel_dvo_device *dvo,
Keith Packardf9c10a92009-05-30 12:16:25 -070051 struct i2c_adapter *i2cbus);
Jesse Barnes79e53942008-11-07 14:24:08 -080052
53 /*
54 * Called to allow the output a chance to create properties after the
55 * RandR objects have been created.
56 */
57 void (*create_resources)(struct intel_dvo_device *dvo);
58
59 /*
Daniel Vetterfac32742012-08-12 19:27:12 +020060 * Turn on/off output.
Jesse Barnes79e53942008-11-07 14:24:08 -080061 *
Daniel Vetterfac32742012-08-12 19:27:12 +020062 * Because none of our dvo drivers support an intermediate power levels,
63 * we don't expose this in the interfac.
Jesse Barnes79e53942008-11-07 14:24:08 -080064 */
Daniel Vetterfac32742012-08-12 19:27:12 +020065 void (*dpms)(struct intel_dvo_device *dvo, bool enable);
Jesse Barnes79e53942008-11-07 14:24:08 -080066
67 /*
Jesse Barnes79e53942008-11-07 14:24:08 -080068 * Callback for testing a video mode for a given output.
69 *
70 * This function should only check for cases where a mode can't
71 * be supported on the output specifically, and not represent
72 * generic CRTC limitations.
73 *
74 * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
75 */
76 int (*mode_valid)(struct intel_dvo_device *dvo,
77 struct drm_display_mode *mode);
78
79 /*
80 * Callback to adjust the mode to be set in the CRTC.
81 *
82 * This allows an output to adjust the clock or even the entire set of
83 * timings, which is used for panels with fixed timings or for
84 * buses with clock limitations.
85 */
86 bool (*mode_fixup)(struct intel_dvo_device *dvo,
Laurent Pincharte811f5a2012-07-17 17:56:50 +020087 const struct drm_display_mode *mode,
Jesse Barnes79e53942008-11-07 14:24:08 -080088 struct drm_display_mode *adjusted_mode);
89
90 /*
91 * Callback for preparing mode changes on an output
92 */
93 void (*prepare)(struct intel_dvo_device *dvo);
94
95 /*
96 * Callback for committing mode changes on an output
97 */
98 void (*commit)(struct intel_dvo_device *dvo);
99
100 /*
101 * Callback for setting up a video mode after fixups have been made.
102 *
103 * This is only called while the output is disabled. The dpms callback
104 * must be all that's necessary for the output, to turn the output on
105 * after this function is called.
106 */
107 void (*mode_set)(struct intel_dvo_device *dvo,
108 struct drm_display_mode *mode,
109 struct drm_display_mode *adjusted_mode);
110
111 /*
112 * Probe for a connected output, and return detect_status.
113 */
114 enum drm_connector_status (*detect)(struct intel_dvo_device *dvo);
115
Daniel Vetter732ce742012-07-02 15:09:45 +0200116 /*
117 * Probe the current hw status, returning true if the connected output
118 * is active.
119 */
120 bool (*get_hw_state)(struct intel_dvo_device *dev);
121
Jesse Barnes79e53942008-11-07 14:24:08 -0800122 /**
123 * Query the device for the modes it provides.
124 *
125 * This function may also update MonInfo, mm_width, and mm_height.
126 *
127 * \return singly-linked list of modes or NULL if no modes found.
128 */
129 struct drm_display_mode *(*get_modes)(struct intel_dvo_device *dvo);
130
131 /**
132 * Clean up driver-specific bits of the output
133 */
134 void (*destroy) (struct intel_dvo_device *dvo);
135
136 /**
137 * Debugging hook to dump device registers to log file
138 */
139 void (*dump_regs)(struct intel_dvo_device *dvo);
140};
141
Hannes Eder606df4e2008-12-18 21:22:24 +0100142extern struct intel_dvo_dev_ops sil164_ops;
143extern struct intel_dvo_dev_ops ch7xxx_ops;
144extern struct intel_dvo_dev_ops ivch_ops;
145extern struct intel_dvo_dev_ops tfp410_ops;
146extern struct intel_dvo_dev_ops ch7017_ops;
Thomas Richter7434a252012-07-18 19:22:30 +0200147extern struct intel_dvo_dev_ops ns2501_ops;
Hannes Eder606df4e2008-12-18 21:22:24 +0100148
Jesse Barnes79e53942008-11-07 14:24:08 -0800149#endif /* _INTEL_DVO_H */