~rockwalrus/ubuntu/quantal/xserver-xorg-video-intel/virtual-crtc

« back to all changes in this revision

Viewing changes to src/virtual_display.c

  • Committer: Nathan Summers
  • Date: 2013-04-09 18:17:30 UTC
  • Revision ID: nsummers@finland-20130409181730-pykjfm9ic51io0cr
Evidently only the patch should be committed, not its results.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
static void
2
 
virtual_crtc_dpms(xf86CrtcPtr intel_crtc, int mode)
3
 
{
4
 
 
5
 
}
6
 
 
7
 
static Bool
8
 
virtual_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
9
 
                          Rotation rotation, int x, int y)
10
 
{
11
 
        return TRUE;
12
 
}
13
 
 
14
 
static void
15
 
virtual_crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
16
 
{
17
 
 
18
 
}
19
 
 
20
 
static void
21
 
virtual_crtc_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
22
 
{
23
 
}
24
 
 
25
 
static void
26
 
virtual_crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
27
 
{
28
 
}
29
 
 
30
 
static void
31
 
virtual_crtc_hide_cursor(xf86CrtcPtr crtc)
32
 
{
33
 
}
34
 
 
35
 
static void
36
 
virtual_crtc_show_cursor(xf86CrtcPtr crtc)
37
 
{
38
 
}
39
 
 
40
 
static void *
41
 
virtual_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
42
 
{
43
 
        return NULL;
44
 
}
45
 
 
46
 
static PixmapPtr
47
 
virtual_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
48
 
{
49
 
        return NULL;
50
 
}
51
 
 
52
 
static void
53
 
virtual_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
54
 
{
55
 
}
56
 
 
57
 
static void
58
 
virtual_crtc_gamma_set(xf86CrtcPtr crtc,
59
 
                       CARD16 *red, CARD16 *green, CARD16 *blue, int size)
60
 
{
61
 
}
62
 
 
63
 
static void
64
 
virtual_crtc_destroy(xf86CrtcPtr crtc)
65
 
{
66
 
        struct intel_crtc *intel_crtc = crtc->driver_private;
67
 
 
68
 
        list_del(&intel_crtc->link);
69
 
        free(intel_crtc);
70
 
 
71
 
        crtc->driver_private = NULL;
72
 
}
73
 
 
74
 
static const xf86CrtcFuncsRec virtual_crtc_funcs = {
75
 
        .dpms = virtual_crtc_dpms,
76
 
        .set_mode_major = virtual_crtc_set_mode_major,
77
 
        .set_cursor_colors = virtual_crtc_set_cursor_colors,
78
 
        .set_cursor_position = virtual_crtc_set_cursor_position,
79
 
        .show_cursor = virtual_crtc_show_cursor,
80
 
        .hide_cursor = virtual_crtc_hide_cursor,
81
 
        .load_cursor_argb = virtual_crtc_load_cursor_argb,
82
 
        .shadow_create = virtual_crtc_shadow_create,
83
 
        .shadow_allocate = virtual_crtc_shadow_allocate,
84
 
        .shadow_destroy = virtual_crtc_shadow_destroy,
85
 
        .gamma_set = virtual_crtc_gamma_set,
86
 
        .destroy = virtual_crtc_destroy,
87
 
};
88
 
 
89
 
static void
90
 
virtual_crtc_init(ScrnInfoPtr scrn, struct intel_mode *mode)
91
 
{
92
 
        xf86CrtcPtr crtc;
93
 
        struct intel_crtc *intel_crtc;
94
 
 
95
 
        intel_crtc = calloc(sizeof(struct intel_crtc), 1);
96
 
        if (intel_crtc == NULL)
97
 
                return;
98
 
 
99
 
        crtc = xf86CrtcCreate(scrn, &virtual_crtc_funcs);
100
 
        if (crtc == NULL) {
101
 
                free(intel_crtc);
102
 
                return;
103
 
        }
104
 
 
105
 
        intel_crtc->mode = mode;
106
 
        intel_crtc->crtc = crtc;
107
 
        crtc->driver_private = intel_crtc;
108
 
        list_add(&intel_crtc->link, &mode->crtcs);
109
 
}
110
 
 
111
 
static xf86OutputStatus
112
 
virtual_output_detect(xf86OutputPtr output)
113
 
{
114
 
        // return XF86OutputStatusConnected;
115
 
        // return XF86OutputStatusDisconnected;
116
 
        return XF86OutputStatusUnknown;
117
 
}
118
 
 
119
 
static Bool
120
 
virtual_output_mode_valid(xf86OutputPtr output, DisplayModePtr pModes)
121
 
{
122
 
        return MODE_OK;
123
 
}
124
 
 
125
 
static DisplayModePtr
126
 
virtual_output_get_modes(xf86OutputPtr output)
127
 
{
128
 
        DisplayModePtr i, m, p = NULL;
129
 
        int max_x = 1920, max_y = 1200;
130
 
        float max_vrefresh = 60.0;
131
 
 
132
 
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,6,99,0,0)
133
 
        m = xf86GetDefaultModes();
134
 
#else
135
 
        m = xf86GetDefaultModes(0,0);
136
 
#endif
137
 
 
138
 
        xf86ValidateModesSize(output->scrn, m, max_x, max_y, 0);
139
 
 
140
 
        for (i = m; i; i = i->next) {
141
 
                if (xf86ModeVRefresh(i) > max_vrefresh)
142
 
                        i->status = MODE_VSYNC;
143
 
                if (p && i->HDisplay >= p->HDisplay &&
144
 
                    i->VDisplay >= p->VDisplay &&
145
 
                    xf86ModeVRefresh(i) >= xf86ModeVRefresh(p))
146
 
                        i->status = MODE_VSYNC;
147
 
        }
148
 
 
149
 
        xf86PruneInvalidModes(output->scrn, &m, FALSE);
150
 
 
151
 
        return m;
152
 
}
153
 
 
154
 
static void
155
 
virtual_output_destroy(xf86OutputPtr output)
156
 
{
157
 
        struct intel_output *intel_output = output->driver_private;
158
 
 
159
 
        list_del(&intel_output->link);
160
 
        free(intel_output);
161
 
 
162
 
        output->driver_private = NULL;
163
 
}
164
 
 
165
 
static void
166
 
virtual_output_dpms(xf86OutputPtr output, int dpms)
167
 
{
168
 
}
169
 
 
170
 
static void
171
 
virtual_output_create_resources(xf86OutputPtr output)
172
 
{
173
 
}
174
 
 
175
 
static Bool
176
 
virtual_output_set_property(xf86OutputPtr output, Atom property,
177
 
                            RRPropertyValuePtr value)
178
 
{
179
 
        return TRUE;
180
 
}
181
 
 
182
 
static Bool
183
 
virtual_output_get_property(xf86OutputPtr output, Atom property)
184
 
{
185
 
        return FALSE;
186
 
}
187
 
 
188
 
static const xf86OutputFuncsRec virtual_output_funcs = {
189
 
        .create_resources = virtual_output_create_resources,
190
 
#ifdef RANDR_12_INTERFACE
191
 
        .set_property = virtual_output_set_property,
192
 
        .get_property = virtual_output_get_property,
193
 
#endif
194
 
        .dpms = virtual_output_dpms,
195
 
        .detect = virtual_output_detect,
196
 
        .mode_valid = virtual_output_mode_valid,
197
 
 
198
 
        .get_modes = virtual_output_get_modes,
199
 
        .destroy = virtual_output_destroy
200
 
};
201
 
 
202
 
static void
203
 
virtual_output_init(ScrnInfoPtr scrn, struct intel_mode *mode)
204
 
{
205
 
        xf86OutputPtr output;
206
 
        struct intel_output *intel_output;
207
 
        char name[32] = "VIRTUAL";
208
 
 
209
 
        output = xf86OutputCreate (scrn, &virtual_output_funcs, name);
210
 
        if (!output) {
211
 
                return;
212
 
        }
213
 
 
214
 
        intel_output = calloc(sizeof(struct intel_output), 1);
215
 
        if (!intel_output) {
216
 
                xf86OutputDestroy(output);
217
 
                return;
218
 
        }
219
 
 
220
 
        output->subpixel_order = SubPixelHorizontalRGB;
221
 
        output->possible_crtcs = (1 << mode->mode_res->count_crtcs);
222
 
        output->driver_private = intel_output;
223
 
        intel_output->output = output;
224
 
        intel_output->mode = mode;
225
 
 
226
 
        list_add(&intel_output->link, &mode->outputs);
227
 
}
228
 
 
229
 
static Bool
230
 
is_virtual(struct intel_mode *mode, int i)
231
 
{
232
 
    return i >= mode->mode_res->count_crtcs;
233
 
}