~ubuntu-branches/ubuntu/karmic/xserver-xorg-video-intel/karmic-proposed

« back to all changes in this revision

Viewing changes to src/i830_memory.c

  • Committer: Bazaar Package Importer
  • Author(s): Brice Goglin
  • Date: 2009-09-23 01:03:49 UTC
  • mfrom: (1.3.4 upstream) (1.2.9 sid)
  • mto: (1.5.3 squeeze)
  • mto: This revision was merged to the branch mainline in revision 102.
  • Revision ID: james.westby@ubuntu.com-20090923010349-dyyejg48nm80lh8u
Tags: 2:2.8.99.902-1
* New upstream release candidate.
  + Fix crash on server regen, closes: #543326.

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
#include "i810_reg.h"
89
89
#include "i915_drm.h"
90
90
 
91
 
#define ALIGN(i,m)    (((i) + (m) - 1) & ~((m) - 1))
92
 
 
93
91
/* Our hardware status area is just a single page */
94
92
#define HWSTATUS_PAGE_SIZE GTT_PAGE_SIZE
95
93
#define PWRCTX_SIZE GTT_PAGE_SIZE
1136
1134
 
1137
1135
    flags |= DISABLE_REUSE;
1138
1136
 
1139
 
    /* Try to allocate one big blob for our cursor memory.  This works
1140
 
     * around a limitation in the FreeBSD AGP driver that allows only one
1141
 
     * physical allocation larger than a page, and could allow us
1142
 
     * to pack the cursors smaller.
1143
 
     */
1144
 
    size = xf86_config->num_crtc * (HWCURSOR_SIZE + HWCURSOR_SIZE_ARGB);
 
1137
    if (!pI830->use_drm_mode) {
 
1138
        /* Try to allocate one big blob for our cursor memory.  This works
 
1139
         * around a limitation in the FreeBSD AGP driver that allows only one
 
1140
         * physical allocation larger than a page, and could allow us
 
1141
         * to pack the cursors smaller.
 
1142
         */
 
1143
        size = xf86_config->num_crtc * (HWCURSOR_SIZE + HWCURSOR_SIZE_ARGB);
1145
1144
 
1146
 
    pI830->cursor_mem = i830_allocate_memory(pScrn, "HW cursors",
1147
 
                                             size, PITCH_NONE, GTT_PAGE_SIZE,
1148
 
                                             flags, TILE_NONE);
1149
 
    if (pI830->cursor_mem != NULL)
1150
 
        return TRUE;
 
1145
        pI830->cursor_mem = i830_allocate_memory(pScrn, "HW cursors",
 
1146
                                                 size, PITCH_NONE, GTT_PAGE_SIZE,
 
1147
                                                 flags, TILE_NONE);
 
1148
        if (pI830->cursor_mem != NULL)
 
1149
            return TRUE;
 
1150
    }
1151
1151
 
1152
1152
    /*
1153
1153
     * Allocate four separate buffers when the kernel doesn't support
1156
1156
     */
1157
1157
    for (i = 0; i < xf86_config->num_crtc; i++)
1158
1158
    {
1159
 
        pI830->cursor_mem_classic[i] = i830_allocate_memory (pScrn, 
1160
 
                                                             "Core cursor",
1161
 
                                                             HWCURSOR_SIZE,
1162
 
                                                             PITCH_NONE,
1163
 
                                                             GTT_PAGE_SIZE,
1164
 
                                                             flags,
1165
 
                                                             TILE_NONE);
1166
 
        if (!pI830->cursor_mem_classic[i])
1167
 
            return FALSE;
 
1159
        if (!pI830->use_drm_mode) {
 
1160
            pI830->cursor_mem_classic[i] = i830_allocate_memory (pScrn,
 
1161
                                                                 "Core cursor",
 
1162
                                                                 HWCURSOR_SIZE,
 
1163
                                                                 PITCH_NONE,
 
1164
                                                                 GTT_PAGE_SIZE,
 
1165
                                                                 flags,
 
1166
                                                                 TILE_NONE);
 
1167
            if (!pI830->cursor_mem_classic[i])
 
1168
                return FALSE;
 
1169
        }
1168
1170
        pI830->cursor_mem_argb[i] = i830_allocate_memory (pScrn, "ARGB cursor",
1169
1171
                                                          HWCURSOR_SIZE_ARGB,
1170
1172
                                                          PITCH_NONE,
1577
1579
                FatalError("Couldn't bind memory for BO %s\n", mem->name);
1578
1580
        }
1579
1581
    }
1580
 
    if (!pI830->use_drm_mode)
 
1582
    if (pI830->use_drm_mode) {
 
1583
        int     i;
 
1584
        xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 
1585
        for (i = 0; i < xf86_config->num_crtc; i++)
 
1586
            drmmode_crtc_set_cursor_bo(xf86_config->crtc[i], pI830->cursor_mem_argb[i]->bo);
 
1587
    } else
1581
1588
        i830_update_cursor_offsets(pScrn);
1582
1589
    i830_set_max_gtt_map_size(pScrn);
1583
1590
 
 
1591
    if (pI830->front_buffer)
 
1592
        pScrn->fbOffset = pI830->front_buffer->offset;
 
1593
 
1584
1594
    return TRUE;
1585
1595
}
1586
1596
 
1649
1659
                               i830_memory **buffer, unsigned long size,
1650
1660
                               int flags)
1651
1661
{
 
1662
    I830Ptr pI830 = I830PTR(pScrn);
 
1663
 
1652
1664
    *buffer = i830_allocate_memory(pScrn, name, size, PITCH_NONE,
1653
1665
                                   GTT_PAGE_SIZE, flags, TILE_NONE);
1654
1666
 
1658
1670
        return FALSE;
1659
1671
    }
1660
1672
 
1661
 
    if (!i830_bind_memory(pScrn, *buffer))
1662
 
        return FALSE;
 
1673
    if (pI830->use_drm_mode && (*buffer)->bo) {
 
1674
        if (drm_intel_bo_pin((*buffer)->bo, GTT_PAGE_SIZE)) {
 
1675
            i830_free_memory(pScrn, *buffer);
 
1676
            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
1677
                       "Failed to bind XvMC buffer bo!\n");
 
1678
            return FALSE;
 
1679
        }
 
1680
 
 
1681
        (*buffer)->offset = (*buffer)->bo->offset;
 
1682
    }
1663
1683
 
1664
1684
    return TRUE;
1665
1685
}
 
1686
 
 
1687
void
 
1688
i830_free_xvmc_buffer(ScrnInfoPtr pScrn, i830_memory *buffer)
 
1689
{
 
1690
    I830Ptr pI830 = I830PTR(pScrn);
 
1691
 
 
1692
    if (pI830->use_drm_mode && buffer->bo)
 
1693
        drm_intel_bo_unpin(buffer->bo);
 
1694
 
 
1695
    i830_free_memory(pScrn, buffer);
 
1696
}
 
1697
 
1666
1698
#endif
1667
1699
 
1668
1700
void