~ubuntu-branches/ubuntu/trusty/xserver-xorg-video-nv/trusty

« back to all changes in this revision

Viewing changes to compat/modes/xf86DiDGA.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2010-06-08 18:22:37 UTC
  • mfrom: (1.1.19 upstream) (14.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100608182237-d8duvizd661d0raj
Tags: 1:2.1.17-3ubuntu1
* Merge from Debian unstable.  Remaining Ubuntu changes:
  + debian/patches/100_fedora-panel-fix.patch:
    - Don't discard EDID blocks just because their input type bit
    disagrees with the hardware connection sensing; this usually
    just means the block is lying. (cf. LP: 188549).
* 105_gf7025_gf7050.patch:
  + Drop, these cards are supported by new upstream version.
* 0001-Move-the-logic-for-matching-devices-out-of-probe-rou.patch:
* 0002-Run-the-parsing-script-to-generate-an-initial-list-o.patch:
  + Drop.  These patches are annoying to update, and their task can be 
    handled better in the new X server's autoconfiguration paths.

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        mode = modes + num++;
73
73
 
74
74
        mode->mode = display_mode;
75
 
        mode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
76
 
        mode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
 
75
        mode->flags = DGA_CONCURRENT_ACCESS;
77
76
        if (display_mode->Flags & V_DBLSCAN)
78
77
            mode->flags |= DGA_DOUBLESCAN;
79
78
        if (display_mode->Flags & V_INTERLACE)
91
90
        mode->yViewportStep = 1;
92
91
        mode->viewportFlags = DGA_FLIP_RETRACE;
93
92
        mode->offset = 0;
94
 
        mode->address = (unsigned char *) xf86_config->dga_address;
95
 
        mode->bytesPerScanline = xf86_config->dga_stride;
96
 
        mode->imageWidth = xf86_config->dga_width;
97
 
        mode->imageHeight = xf86_config->dga_height;
 
93
        mode->address = 0;
 
94
        mode->imageWidth = mode->viewportWidth;
 
95
        mode->imageHeight = mode->viewportHeight;
 
96
        mode->bytesPerScanline = (mode->imageWidth * scrn->bitsPerPixel) >> 3;
98
97
        mode->pixmapWidth = mode->imageWidth;
99
98
        mode->pixmapHeight = mode->imageHeight;
100
 
        mode->maxViewportX = mode->imageWidth - mode->viewportWidth;
101
 
        mode->maxViewportY = mode->imageHeight - mode->viewportHeight;
 
99
        mode->maxViewportX = 0;
 
100
        mode->maxViewportY = 0;
102
101
 
103
102
        display_mode = display_mode->next;
104
103
        if (display_mode == scrn->modes)
149
148
}
150
149
 
151
150
static Bool
152
 
xf86_dga_get_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr *ppDrawable, GCPtr *ppGC)
153
 
{
154
 
    ScreenPtr           pScreen = scrn->pScreen;
155
 
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
156
 
    PixmapPtr           pPixmap;
157
 
    GCPtr               pGC;
158
 
    
159
 
    pPixmap = GetScratchPixmapHeader (pScreen, xf86_config->dga_width, xf86_config->dga_height,
160
 
                                      scrn->depth, scrn->bitsPerPixel, xf86_config->dga_stride, 
161
 
                                      (char *) scrn->memPhysBase + scrn->fbOffset);
162
 
    if (!pPixmap)
163
 
        return FALSE;
164
 
    pGC  = GetScratchGC (scrn->depth, pScreen);
165
 
    if (!pGC)
166
 
    {
167
 
        FreeScratchPixmapHeader (pPixmap);
168
 
        return FALSE;
169
 
    }
170
 
    *ppDrawable = &pPixmap->drawable;
171
 
    *ppGC = pGC;
172
 
    return TRUE;
173
 
}
174
 
 
175
 
static void
176
 
xf86_dga_release_drawable_and_gc (ScrnInfoPtr scrn, DrawablePtr pDrawable, GCPtr pGC)
177
 
{
178
 
    FreeScratchGC (pGC);
179
 
    FreeScratchPixmapHeader ((PixmapPtr) pDrawable);
180
 
}
181
 
 
182
 
static void
183
 
xf86_dga_fill_rect(ScrnInfoPtr scrn, int x, int y, int w, int h, unsigned long color)
184
 
{
185
 
    GCPtr               pGC;
186
 
    DrawablePtr         pDrawable;
187
 
    XID                 vals[1];
188
 
    xRectangle          r;
189
 
 
190
 
    if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC))
191
 
        return;
192
 
    vals[0] = color;
193
 
    ChangeGC (pGC, GCForeground, vals);
194
 
    ValidateGC (pDrawable, pGC);
195
 
    r.x = x;
196
 
    r.y = y;
197
 
    r.width = w;
198
 
    r.height = h;
199
 
    pGC->ops->PolyFillRect (pDrawable, pGC, 1, &r);
200
 
    xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC);
201
 
}
202
 
 
203
 
static void
204
 
xf86_dga_sync(ScrnInfoPtr scrn)
205
 
{
206
 
    ScreenPtr   pScreen = scrn->pScreen;
207
 
    WindowPtr   pRoot = WindowTable [pScreen->myNum];
208
 
    char        buffer[4];
209
 
 
210
 
    pScreen->GetImage (&pRoot->drawable, 0, 0, 1, 1, ZPixmap, ~0L, buffer);
211
 
}
212
 
 
213
 
static void
214
 
xf86_dga_blit_rect(ScrnInfoPtr scrn, int srcx, int srcy, int w, int h, int dstx, int dsty)
215
 
{
216
 
    DrawablePtr pDrawable;
217
 
    GCPtr       pGC;
218
 
 
219
 
    if (!xf86_dga_get_drawable_and_gc (scrn, &pDrawable, &pGC))
220
 
        return;
221
 
    ValidateGC (pDrawable, pGC);
222
 
    pGC->ops->CopyArea (pDrawable, pDrawable, pGC, srcx, srcy, w, h, dstx, dsty);
223
 
    xf86_dga_release_drawable_and_gc (scrn, pDrawable, pGC);
224
 
}
225
 
 
226
 
static Bool
227
151
xf86_dga_open_framebuffer(ScrnInfoPtr scrn,
228
152
                          char **name,
229
153
                          unsigned char **mem, int *size, int *offset, int *flags)
230
154
{
231
 
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
232
 
    
233
 
    *size = xf86_config->dga_stride * xf86_config->dga_height;
234
 
    *mem = (unsigned char *) (xf86_config->dga_address);
235
 
    *offset = 0;
236
 
    *flags = DGA_NEED_ROOT;
237
 
 
238
 
    return TRUE;
 
155
    return FALSE;
239
156
}
240
157
 
241
158
static void
249
166
   xf86_dga_set_mode,
250
167
   xf86_dga_set_viewport,
251
168
   xf86_dga_get_viewport,
252
 
   xf86_dga_sync,
253
 
   xf86_dga_fill_rect,
254
 
   xf86_dga_blit_rect,
 
169
   NULL,
 
170
   NULL,
 
171
   NULL,
255
172
   NULL
256
173
};
257
174
 
258
175
Bool
259
176
xf86DiDGAReInit (ScreenPtr pScreen)
260
177
{
 
178
    return TRUE;
 
179
}
 
180
 
 
181
Bool
 
182
_xf86_di_dga_reinit_internal (ScreenPtr pScreen)
 
183
{
261
184
    ScrnInfoPtr         scrn = xf86Screens[pScreen->myNum];
262
185
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
263
186
    
 
187
    if (!DGAAvailable(pScreen->myNum))
 
188
        return TRUE;
 
189
 
264
190
    if (!xf86_dga_get_modes (pScreen))
265
191
        return FALSE;
266
192
    
270
196
Bool
271
197
xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address)
272
198
{
 
199
    return TRUE;
 
200
}
 
201
 
 
202
Bool
 
203
_xf86_di_dga_init_internal (ScreenPtr pScreen)
 
204
{
273
205
    ScrnInfoPtr         scrn = xf86Screens[pScreen->myNum];
274
206
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
275
207
 
276
208
    xf86_config->dga_flags = 0;
277
 
    xf86_config->dga_address = dga_address;
278
 
    xf86_config->dga_width = scrn->virtualX;
279
 
    xf86_config->dga_height = scrn->virtualY;
280
 
    xf86_config->dga_stride = scrn->displayWidth * scrn->bitsPerPixel >> 3;
 
209
    xf86_config->dga_address = 0;
 
210
    xf86_config->dga_width = 0;
 
211
    xf86_config->dga_height = 0;
 
212
    xf86_config->dga_stride = 0;
281
213
    
282
214
    if (!xf86_dga_get_modes (pScreen))
283
215
        return FALSE;