~ubuntu-branches/ubuntu/oneiric/xserver-xorg-video-ati/oneiric

« back to all changes in this revision

Viewing changes to src/modes/xf86DiDGA.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker
  • Date: 2010-07-08 16:45:59 UTC
  • mfrom: (1.1.34 upstream) (0.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100708164559-t1gwcpobj4n39lhf
Tags: 1:6.13.1-1ubuntu1
* Merge from Debian Unstable. Remainning Ubuntu changes:
  + debian/control:
    - Add quilt to build-depends for Ubuntu patches
  + debian/patches/100_radeon-6.9.0-bgnr-enable.patch:
    - Smooth plymouth transition enablement patch
  + debian/rules:
    - Add xsfbs patchsys
    - Drop /etc/modprobe.d/radeon-kms.conf install.
  + debian/xserver-xorg-video-ati.{pre,post}inst.in:
    - Clean existing /etc/modprobe.d/radeon-kms.conf on install.
      At best this does nothing (KMS is the default for our kernel)
      and at worst it makes it harder to disable KMS.
* Add debian/gbp.conf pointing to Ubuntu branch to make git-buildpackage
  less narky.
* Drop 102-no-xv-rn50.patch and 103_new_pci_ids.patch from previous
  Ubuntu releases, they are upstream now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    if (!num)
62
62
        return FALSE;
63
63
    
64
 
    modes = xalloc(num * sizeof(DGAModeRec));
 
64
    modes = malloc(num * sizeof(DGAModeRec));
65
65
    if (!modes)
66
66
        return FALSE;
67
67
    
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)
105
104
            break;
106
105
    }
107
 
    if (xf86_config->dga_modes)
108
 
        xfree (xf86_config->dga_modes);
 
106
    free(xf86_config->dga_modes);
109
107
    xf86_config->dga_nmode = num;
110
108
    xf86_config->dga_modes = modes;
111
109
    return TRUE;
149
147
}
150
148
 
151
149
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
150
xf86_dga_open_framebuffer(ScrnInfoPtr scrn,
228
151
                          char **name,
229
152
                          unsigned char **mem, int *size, int *offset, int *flags)
230
153
{
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;
 
154
    return FALSE;
239
155
}
240
156
 
241
157
static void
249
165
   xf86_dga_set_mode,
250
166
   xf86_dga_set_viewport,
251
167
   xf86_dga_get_viewport,
252
 
   xf86_dga_sync,
253
 
   xf86_dga_fill_rect,
254
 
   xf86_dga_blit_rect,
 
168
   NULL,
 
169
   NULL,
 
170
   NULL,
255
171
   NULL
256
172
};
257
173
 
258
174
Bool
259
175
xf86DiDGAReInit (ScreenPtr pScreen)
260
176
{
 
177
    return TRUE;
 
178
}
 
179
 
 
180
Bool
 
181
_xf86_di_dga_reinit_internal (ScreenPtr pScreen)
 
182
{
261
183
    ScrnInfoPtr         scrn = xf86Screens[pScreen->myNum];
262
184
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
263
185
    
 
186
    if (!DGAAvailable(pScreen->myNum))
 
187
        return TRUE;
 
188
 
264
189
    if (!xf86_dga_get_modes (pScreen))
265
190
        return FALSE;
266
191
    
270
195
Bool
271
196
xf86DiDGAInit (ScreenPtr pScreen, unsigned long dga_address)
272
197
{
 
198
    return TRUE;
 
199
}
 
200
 
 
201
Bool
 
202
_xf86_di_dga_init_internal (ScreenPtr pScreen)
 
203
{
273
204
    ScrnInfoPtr         scrn = xf86Screens[pScreen->myNum];
274
205
    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
275
206
 
276
207
    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;
 
208
    xf86_config->dga_address = 0;
 
209
    xf86_config->dga_width = 0;
 
210
    xf86_config->dga_height = 0;
 
211
    xf86_config->dga_stride = 0;
281
212
    
282
213
    if (!xf86_dga_get_modes (pScreen))
283
214
        return FALSE;