diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-06-08 13:32:59 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-06-08 19:27:33 +0100 |
commit | 715d466ad44e82b740f5454c41db944863420596 (patch) | |
tree | ae6a6095189629050aa8151899eed151da1513f1 /src/sna/sna_video.c | |
parent | a62db5b050dee10246c02c72385358acb5e72b56 (diff) |
sna/dri: valgrindify
Lots of scary warnings found by valgrind.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna_video.c')
-rw-r--r-- | src/sna/sna_video.c | 178 |
1 files changed, 0 insertions, 178 deletions
diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index b6cbda22..8839ab74 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -514,184 +514,6 @@ sna_video_copy_data(struct sna *sna, return TRUE; } -static void sna_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box) -{ - if (crtc->enabled) { - crtc_box->x1 = crtc->x; - crtc_box->x2 = - crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation); - crtc_box->y1 = crtc->y; - crtc_box->y2 = - crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation); - } else - crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0; -} - -static void sna_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b) -{ - dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1; - dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2; - dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1; - dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2; - if (dest->x1 >= dest->x2 || dest->y1 >= dest->y2) - dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0; -} - -static int sna_box_area(BoxPtr box) -{ - return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1); -} - -/* - * Return the crtc covering 'box'. If two crtcs cover a portion of - * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc - * with greater coverage - */ - -xf86CrtcPtr -sna_covering_crtc(ScrnInfoPtr scrn, - BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret) -{ - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - xf86CrtcPtr crtc, best_crtc; - int coverage, best_coverage; - int c; - BoxRec crtc_box, cover_box; - - DBG(("%s for box=(%d, %d), (%d, %d)\n", - __FUNCTION__, box->x1, box->y1, box->x2, box->y2)); - - best_crtc = NULL; - best_coverage = 0; - crtc_box_ret->x1 = 0; - crtc_box_ret->x2 = 0; - crtc_box_ret->y1 = 0; - crtc_box_ret->y2 = 0; - for (c = 0; c < xf86_config->num_crtc; c++) { - crtc = xf86_config->crtc[c]; - - /* If the CRTC is off, treat it as not covering */ - if (!sna_crtc_on(crtc)) { - DBG(("%s: crtc %d off, skipping\n", __FUNCTION__, c)); - continue; - } - - sna_crtc_box(crtc, &crtc_box); - sna_box_intersect(&cover_box, &crtc_box, box); - coverage = sna_box_area(&cover_box); - if (coverage && crtc == desired) { - DBG(("%s: box is on desired crtc [%p]\n", - __FUNCTION__, crtc)); - *crtc_box_ret = crtc_box; - return crtc; - } - if (coverage > best_coverage) { - *crtc_box_ret = crtc_box; - best_crtc = crtc; - best_coverage = coverage; - } - } - DBG(("%s: best crtc = %p\n", __FUNCTION__, best_crtc)); - return best_crtc; -} - -bool -sna_wait_for_scanline(struct sna *sna, PixmapPtr pixmap, - xf86CrtcPtr crtc, RegionPtr clip) -{ - pixman_box16_t box, crtc_box; - int pipe, event; - Bool full_height; - int y1, y2; - uint32_t *b; - - /* XXX no wait for scanline support on SNB? */ - if (sna->kgem.gen >= 60) - return false; - - if (!pixmap_is_scanout(pixmap)) - return false; - - if (crtc == NULL) { - if (clip) { - crtc_box = *REGION_EXTENTS(NULL, clip); - } else { - crtc_box.x1 = 0; /* XXX drawable offsets? */ - crtc_box.y1 = 0; - crtc_box.x2 = pixmap->drawable.width; - crtc_box.y2 = pixmap->drawable.height; - } - crtc = sna_covering_crtc(sna->scrn, &crtc_box, NULL, &crtc_box); - } - - if (crtc == NULL) - return false; - - if (clip) { - box = *REGION_EXTENTS(unused, clip); - - if (crtc->transform_in_use) - pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, &box); - - /* We could presume the clip was correctly computed... */ - sna_crtc_box(crtc, &crtc_box); - sna_box_intersect(&box, &crtc_box, &box); - - /* - * Make sure we don't wait for a scanline that will - * never occur - */ - y1 = (crtc_box.y1 <= box.y1) ? box.y1 - crtc_box.y1 : 0; - y2 = (box.y2 <= crtc_box.y2) ? - box.y2 - crtc_box.y1 : crtc_box.y2 - crtc_box.y1; - if (y2 <= y1) - return false; - - full_height = FALSE; - if (y1 == 0 && y2 == (crtc_box.y2 - crtc_box.y1)) - full_height = TRUE; - } else { - sna_crtc_box(crtc, &crtc_box); - y1 = crtc_box.y1; - y2 = crtc_box.y2; - full_height = TRUE; - } - - /* - * Pre-965 doesn't have SVBLANK, so we need a bit - * of extra time for the blitter to start up and - * do its job for a full height blit - */ - if (sna_crtc_to_pipe(crtc) == 0) { - pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA; - event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW; - if (full_height) - event = MI_WAIT_FOR_PIPEA_SVBLANK; - } else { - pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB; - event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW; - if (full_height) - event = MI_WAIT_FOR_PIPEB_SVBLANK; - } - - if (crtc->mode.Flags & V_INTERLACE) { - /* DSL count field lines */ - y1 /= 2; - y2 /= 2; - } - - b = kgem_get_batch(&sna->kgem, 5); - /* The documentation says that the LOAD_SCAN_LINES command - * always comes in pairs. Don't ask me why. */ - b[0] = MI_LOAD_SCAN_LINES_INCL | pipe; - b[1] = (y1 << 16) | (y2-1); - b[2] = MI_LOAD_SCAN_LINES_INCL | pipe; - b[3] = (y1 << 16) | (y2-1); - b[4] = MI_WAIT_FOR_EVENT | event; - kgem_advance_batch(&sna->kgem, 5); - return true; -} - void sna_video_init(struct sna *sna, ScreenPtr screen) { XF86VideoAdaptorPtr *adaptors, *newAdaptors; |