summaryrefslogtreecommitdiff
path: root/radeon_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'radeon_device.c')
-rw-r--r--radeon_device.c211
1 files changed, 0 insertions, 211 deletions
diff --git a/radeon_device.c b/radeon_device.c
deleted file mode 100644
index d677c62..0000000
--- a/radeon_device.c
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright © 2010 Jerome Glisse <glisse@freedesktop.org>
- *
- * This file is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-#include "radeon_device.h"
-#include "r600_winsys.h"
-
-#pragma pack(1)
-struct ib_reloc_gem {
- uint32_t handle;
- uint32_t read_domain;
- uint32_t write_domain;
- uint32_t flags;
-};
-#pragma pack()
-#define RELOC_SIZE (sizeof(struct ib_reloc_gem) / sizeof(uint32_t))
-
-u32 radeon_ib_reloc(struct radeon_ib *ib, struct radeon_bo *bo, u32 d)
-{
- struct ib_reloc_gem *reloc;
- int i;
-
- for (i = 0; i < ib->crelocs; i++) {
- reloc = (struct ib_reloc_gem*)&ib->relocs[i * RELOC_SIZE];
- if (reloc->handle == bo->handle) {
- reloc->read_domain |= d;
- return (i * RELOC_SIZE);
- }
- }
- if (ib->crelocs >= ib->nrelocs)
- return 0xFFFFFFFFUL;
- i = ib->crelocs++;
- reloc = (struct ib_reloc_gem*)&ib->relocs[i * RELOC_SIZE];
- reloc->handle = bo->handle;
- reloc->read_domain = d;
- reloc->write_domain = 0;
- reloc->flags = 0;
- return (i * RELOC_SIZE);
-}
-
-int radeon_ib_get(struct radeon_device *rdev, struct radeon_ib **ib)
-{
- struct radeon_ib *lib;
-
- lib = malloc(sizeof(struct radeon_ib));
- if (lib == NULL)
- return -ENOMEM;
- memset(lib, sizeof(*lib), 0);
- lib->ptr = malloc(64 * 1024);
- if (lib->ptr == NULL) {
- free(lib);
- return -ENOMEM;
- }
- lib->cpkts = 0;
- lib->length_dw = 64 * 1024 / 4;
- lib->relocs = malloc(64 * 1024);
- if (lib->relocs == NULL) {
- free(lib->ptr);
- free(lib);
- return -ENOMEM;
- }
- lib->nrelocs = 64 * 1024 / RELOC_SIZE;
- lib->crelocs = 0;
- *ib = lib;
- return 0;
-}
-
-void radeon_ib_free(struct radeon_ib *ib)
-{
- if (ib == NULL)
- return;
- free(ib->ptr);
- free(ib->relocs);
- free(ib);
-}
-
-int radeon_ib_schedule(struct radeon_device *rdev, struct radeon_ib *ib)
-{
- struct drm_radeon_cs drmib;
- struct drm_radeon_cs_chunk chunks[2];
- uint64_t chunk_array[2];
- int r = 0;
-
-#if 0
- for (r = 0; r < ib->cpkts; r++) {
- printf("0x%08X\n", ib->ptr[r]);
- }
-#endif
- drmib.num_chunks = 2;
- drmib.chunks = (uint64_t)(uintptr_t)chunk_array;
- chunks[0].chunk_id = RADEON_CHUNK_ID_IB;
- chunks[0].length_dw = ib->cpkts;
- chunks[0].chunk_data = (uint64_t)(uintptr_t)ib->ptr;
- chunks[1].chunk_id = RADEON_CHUNK_ID_RELOCS;
- chunks[1].length_dw = ib->crelocs * 4;
- chunks[1].chunk_data = (uint64_t)(uintptr_t)ib->relocs;
- chunk_array[0] = (uint64_t)(uintptr_t)&chunks[0];
- chunk_array[1] = (uint64_t)(uintptr_t)&chunks[1];
-#if 1
- r = drmCommandWriteRead(rdev->fd, DRM_RADEON_CS, &drmib,
- sizeof(struct drm_radeon_cs));
-#endif
- return r;
-}
-
-int radeon_device_init(struct radeon_device **rdev, struct radeon_bo_manager *bom, int fd)
-{
- struct radeon_device *dev;
- int r;
-
- *rdev = NULL;
- dev = kmalloc(sizeof(*dev), GFP_KERNEL);
- if (dev == NULL)
- return -ENOMEM;
- memset(dev, 0, sizeof(struct radeon_device));
- dev->fd = fd;
- dev->bom = bom;
- r = r600_atoms_init(dev);
- if (r)
- return r;
- *rdev = dev;
- return r;
-}
-
-void radeon_device_release(struct radeon_device *rdev)
-{
- r600_atoms_release(rdev);
- memset(rdev, 0, sizeof(struct radeon_device));
- kfree(rdev);
-}
-
-void kref_set(struct kref *kref, int num)
-{
- kref->refcount = num;
-}
-
-/**
- * kref_init - initialize object.
- * @kref: object in question.
- */
-void kref_init(struct kref *kref)
-{
- kref_set(kref, 1);
-}
-
-/**
- * kref_get - increment refcount for object.
- * @kref: object.
- */
-void kref_get(struct kref *kref)
-{
- kref->refcount++;
-}
-
-/**
- * kref_put - decrement refcount for object.
- * @kref: object.
- * @release: pointer to the function that will clean up the object when the
- * last reference to the object is released.
- * This pointer is required, and it is not acceptable to pass kfree
- * in as this function.
- *
- * Decrement the refcount, and if 0, call release().
- * Return 1 if the object was removed, otherwise return 0. Beware, if this
- * function returns 0, you still can not count on the kref from remaining in
- * memory. Only use the return value if you want to see if the kref is now
- * gone, not present.
- */
-int kref_put(struct kref *kref, void (*release)(struct kref *kref))
-{
- kref->refcount--;
- if (!kref->refcount) {
- release(kref);
- return 1;
- }
- return 0;
-}
-
-u64 crc_64(void *d, size_t len)
-{
- u8 *data = (uint8_t*)d;
- u64 div = 0x42F0E1EBA9EA3693;
- u64 crc = 0xFFFFFFFFFFFFFFFF;
- u8 t;
- int i, j;
-
- for (j = 0; j < len; j++) {
- t = data[j];
- for (i = 0; i < 8; i++) {
- if ((t >> 7) ^ (crc >> 63)) {
- crc = (crc << 1) ^ div;
- } else {
- crc = (crc << 1);
- }
- t = (t << 1) & 0xFF;
- }
- }
- return crc;
-}