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 I2C_VID_H
24#define I2C_VID_H
25#include <randrstr.h>
26
27typedef struct _I830I2CVidOutputRec {
28    /**
29     * Initialize the device at startup time.
30     * Returns NULL if the device does not exist.
31     */
32    void *(*init)(I2CBusPtr b, I2CSlaveAddr addr);
33
34    /**
35     * Called to allow the output a chance to create properties after the
36     * RandR objects have been created.
37     */
38    void
39    (*create_resources)(I2CDevPtr d);
40
41    /**
42     * Turns the output on/off, or sets intermediate power levels if available.
43     *
44     * Unsupported intermediate modes drop to the lower power setting.  If the
45     * mode is DPMSModeOff, the output must be disabled, as the DPLL may be
46     * disabled afterwards.
47     */
48    void (*dpms)(I2CDevPtr d, int mode);
49
50    /**
51     * Saves the output's state for restoration on VT switch.
52     */
53    void (*save)(I2CDevPtr d);
54
55    /**
56     * Restore's the output's state at VT switch.
57     */
58    void (*restore)(I2CDevPtr d);
59
60    /**
61     * Callback for testing a video mode for a given output.
62     *
63     * This function should only check for cases where a mode can't be supported
64     * on the output specifically, and not represent generic CRTC limitations.
65     *
66     * \return MODE_OK if the mode is valid, or another MODE_* otherwise.
67     */
68    int (*mode_valid)(I2CDevPtr d, DisplayModePtr mode);
69
70    /**
71     * Callback to adjust the mode to be set in the CRTC.
72     *
73     * This allows an output to adjust the clock or even the entire set of
74     * timings, which is used for panels with fixed timings or for
75     * buses with clock limitations.
76     */
77    Bool (*mode_fixup)(I2CDevPtr d, DisplayModePtr mode, DisplayModePtr adjusted_mode);
78
79    /**
80     * Callback for preparing mode changes on an output
81     */
82    void (*prepare)(I2CDevPtr d);
83
84    /**
85     * Callback for committing mode changes on an output
86     */
87    void (*commit)(I2CDevPtr d);
88
89    /**
90     * Callback for setting up a video mode after fixups have been made.
91     *
92     * This is only called while the output is disabled.  The dpms callback
93     * must be all that's necessary for the output, to turn the output on
94     * after this function is called.
95     */
96    void (*mode_set)(I2CDevPtr d, DisplayModePtr mode, DisplayModePtr adjusted_mode);
97
98    /**
99     * Probe for a connected output, and return detect_status.
100     */
101    xf86OutputStatus (*detect)(I2CDevPtr d);
102
103    /**
104     * Query the device for the modes it provides.
105     *
106     * This function may also update MonInfo, mm_width, and mm_height.
107     *
108     * \return singly-linked list of modes or NULL if no modes found.
109     */
110    DisplayModePtr
111    (*get_modes)(I2CDevPtr d);
112
113#ifdef RANDR_12_INTERFACE
114    /**
115     * Callback when an output's property has changed.
116     */
117    Bool
118    (*set_property)(I2CDevPtr d, Atom property, RRPropertyValuePtr value);
119#endif
120
121    /**
122     * Clean up driver-specific bits of the output
123     */
124    void (*destroy) (I2CDevPtr d);
125
126    /**
127     * Debugging hook to dump device registers to log file
128     */
129    void (*dump_regs)(I2CDevPtr d);
130} I830I2CVidOutputRec, *I830I2CVidOutputPtr;
131
132#endif
133