/* Returns -errno to shared code */
#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
-ret = 0; \
+ret = 0; \
while ( ret == 0 ) { \
DRM_UNLOCK(); \
DRM_SPINLOCK(&dev->irq_lock); \
{
if (dev->driver.device_is_agp != NULL) {
int ret;
-
- /* device_is_agp returns a tristate, 0 = not AGP, 1 = definitely
+ /*
+ * device_is_agp returns a tristate, 0 = not AGP, 1 = definitely
* AGP, 2 = fall back to PCI capability
*/
ret = (*dev->driver.device_is_agp)(dev);
if (!dev->agp || !dev->agp->acquired)
return EINVAL;
- kern = &dev->agp->info;
+ kern = &dev->agp->info;
#ifndef DRM_NO_AGP
agp_get_info(dev->agp->agpdev, kern);
#endif
info->agp_version_major = 1;
info->agp_version_minor = 0;
- info->mode = kern->ai_mode;
- info->aperture_base = kern->ai_aperture_base;
- info->aperture_size = kern->ai_aperture_size;
- info->memory_allowed = kern->ai_memory_allowed;
- info->memory_used = kern->ai_memory_used;
- info->id_vendor = kern->ai_devid & 0xffff;
- info->id_device = kern->ai_devid >> 16;
+ info->mode = kern->ai_mode;
+ info->aperture_base = kern->ai_aperture_base;
+ info->aperture_size = kern->ai_aperture_size;
+ info->memory_allowed = kern->ai_memory_allowed;
+ info->memory_used = kern->ai_memory_used;
+ info->id_vendor = kern->ai_devid & 0xffff;
+ info->id_device = kern->ai_devid >> 16;
return 0;
}
if (err != 0)
return err;
- *(drm_agp_info_t *) data = info;
+ *(drm_agp_info_t *)data = info;
return 0;
}
return ENOMEM;
pages = (request->size + PAGE_SIZE - 1) / PAGE_SIZE;
- type = (u_int32_t) request->type;
+ type = (u_int32_t)request->type;
DRM_UNLOCK();
handle = drm_agp_allocate_memory(pages, type);
struct drm_agp_mem *entry;
TAILQ_FOREACH(entry, &dev->agp->memory, link) {
- if (entry->handle == handle) return entry;
+ if (entry->handle == handle)
+ return entry;
}
return NULL;
}
drm_agp_buffer_t request;
int retcode;
- request = *(drm_agp_buffer_t *) data;
+ request = *(drm_agp_buffer_t *)data;
DRM_LOCK();
retcode = drm_agp_free(dev, &request);
int order;
unsigned long tmp;
- for ( order = 0, tmp = size ; tmp >>= 1 ; ++order );
+ for (order = 0, tmp = size; tmp >>= 1; ++order)
+ ;
- if ( size & ~(1 << order) )
+ if (size & ~(1 << order))
++order;
return order;
DRM_DEBUG("offset = 0x%08lx, size = 0x%08lx, type = %d\n", offset,
size, type);
- /* Check if this is just another version of a kernel-allocated map, and
+ /*
+ * Check if this is just another version of a kernel-allocated map, and
* just hand that back if so.
*/
if (type == _DRM_REGISTERS || type == _DRM_FRAME_BUFFER ||
* initialization necessary.
*/
map = drm_calloc(1, sizeof(*map), DRM_MEM_MAPS);
- if ( !map ) {
+ if (map == NULL) {
DRM_LOCK();
return ENOMEM;
}
return ENOMEM;
}
- switch ( map->type ) {
+ switch (map->type) {
case _DRM_REGISTERS:
map->handle = drm_ioremap(dev, map);
- if (!map->handle) {
+ if (map->handle == NULL) {
DRM_LOCK();
return EINVAL;
}
#endif
break;
case _DRM_SCATTER_GATHER:
- if (!dev->sg) {
+ if (dev->sg == NULL) {
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
DRM_LOCK();
return EINVAL;
}
map->handle = map->dmah->vaddr;
map->offset = map->dmah->busaddr;
- if (map->type == _DRM_SHM &&
- map->flags & _DRM_CONTAINS_LOCK) {
+ if (map->type == _DRM_SHM && map->flags & _DRM_CONTAINS_LOCK) {
DRM_LOCK();
/* Prevent a 2nd X Server from creating a 2nd lock */
if (dev->lock.hw_lock != NULL) {
request->size = map->size;
request->type = map->type;
request->flags = map->flags;
- request->mtrr = map->mtrr;
+ request->mtrr = map->mtrr;
request->handle = map->handle;
request->handle = (void *)map->mm->start;
int i;
if (entry->seg_count) {
- for (i = 0; i < entry->seg_count; i++) {
+ for (i = 0; i < entry->seg_count; i++)
drm_pci_free(dev, entry->seglist[i]);
- }
drm_free(entry->seglist, entry->seg_count *
sizeof(*entry->seglist), DRM_MEM_BUFS);
byte_count = 0;
agp_offset = dev->agp->base + request->agp_start;
- DRM_DEBUG( "count: %d\n", count );
- DRM_DEBUG( "order: %d\n", order );
- DRM_DEBUG( "size: %d\n", size );
- DRM_DEBUG( "agp_offset: 0x%lx\n", agp_offset );
- DRM_DEBUG( "alignment: %d\n", alignment );
- DRM_DEBUG( "page_order: %d\n", page_order );
- DRM_DEBUG( "total: %d\n", total );
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: 0x%lx\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
/* Make sure buffers are located in AGP memory that we own */
entry->buflist = drm_calloc(count, sizeof(*entry->buflist),
DRM_MEM_BUFS);
- if ( !entry->buflist ) {
+ if (entry->buflist == NULL)
return ENOMEM;
- }
entry->buf_size = size;
entry->page_order = page_order;
offset = 0;
- while ( entry->buf_count < count ) {
+ while (entry->buf_count < count) {
buf = &entry->buflist[entry->buf_count];
buf->idx = dma->buf_count + entry->buf_count;
buf->total = alignment;
byte_count += PAGE_SIZE << page_order;
}
- DRM_DEBUG( "byte_count: %d\n", byte_count );
+ DRM_DEBUG("byte_count: %d\n", byte_count);
/* OpenBSD lacks realloc in kernel */
temp_buflist = drm_realloc(dma->buflist,
}
dma->buflist = temp_buflist;
- for ( i = 0 ; i < entry->buf_count ; i++ ) {
+ for (i = 0; i < entry->buf_count; i++)
dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
dma->buf_count += entry->buf_count;
dma->byte_count += byte_count;
- DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count );
- DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count );
+ DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
+ DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
request->count = entry->buf_count;
request->size = size;
order = drm_order(request->size);
size = 1 << order;
- DRM_DEBUG( "count=%d, size=%d (%d), order=%d\n",
- request->count, request->size, size, order );
+ DRM_DEBUG("count=%d, size=%d (%d), order=%d\n",
+ request->count, request->size, size, order);
alignment = (request->flags & _DRM_PAGE_ALIGN)
? round_page(size) : size;
memcpy(temp_pagelist, dma->pagelist, dma->page_count *
sizeof(*dma->pagelist));
- DRM_DEBUG( "pagelist: %d entries\n",
- dma->page_count + (count << page_order) );
+ DRM_DEBUG("pagelist: %d entries\n",
+ dma->page_count + (count << page_order));
entry->buf_size = size;
entry->page_order = page_order;
byte_count = 0;
page_count = 0;
- while ( entry->buf_count < count ) {
+ while (entry->buf_count < count) {
drm_dma_handle_t *dmah = drm_pci_alloc(dev, size, alignment,
0xfffffffful);
if (dmah == NULL) {
}
entry->seglist[entry->seg_count++] = dmah;
- for ( i = 0 ; i < (1 << page_order) ; i++ ) {
- DRM_DEBUG( "page %d @ %p\n",
+ for (i = 0; i < (1 << page_order); i++) {
+ DRM_DEBUG("page %d @ %p\n",
dma->page_count + page_count,
- (char *)dmah->vaddr + PAGE_SIZE * i );
+ (char *)dmah->vaddr + PAGE_SIZE * i);
temp_pagelist[dma->page_count + page_count++] =
(long)dmah->vaddr + PAGE_SIZE * i;
}
- for ( offset = 0 ;
- offset + size <= total && entry->buf_count < count ;
- offset += alignment, ++entry->buf_count ) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
- buf->offset = (dma->byte_count + byte_count + offset);
+ for (offset = 0;
+ offset + size <= total && entry->buf_count < count;
+ offset += alignment, ++entry->buf_count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+ buf->offset = (dma->byte_count + byte_count + offset);
buf->address = ((char *)dmah->vaddr + offset);
buf->bus_address = dmah->busaddr + offset;
- buf->next = NULL;
+ buf->next = NULL;
buf->pending = 0;
- buf->file_priv = NULL;
+ buf->file_priv = NULL;
buf->dev_priv_size = dev->driver.buf_priv_size;
buf->dev_private = drm_calloc(1, buf->dev_priv_size,
DRM_MEM_BUFS);
if (buf->dev_private == NULL) {
- /* Set count correctly so we free the proper amount. */
+ /* Set count so we free the proper amount. */
entry->buf_count = count;
entry->seg_count = count;
drm_cleanup_buf_error(dev, entry);
return ENOMEM;
}
- DRM_DEBUG( "buffer %d @ %p\n",
- entry->buf_count, buf->address );
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
}
byte_count += PAGE_SIZE << page_order;
}
- temp_buflist = drm_realloc( dma->buflist,
+ temp_buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM);
if (temp_buflist == NULL) {
}
dma->buflist = temp_buflist;
- for ( i = 0 ; i < entry->buf_count ; i++ ) {
+ for (i = 0; i < entry->buf_count; i++)
dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
/* No allocations failed, so now we can replace the orginal pagelist
* with the new one.
byte_count = 0;
agp_offset = request->agp_start;
- DRM_DEBUG( "count: %d\n", count );
- DRM_DEBUG( "order: %d\n", order );
- DRM_DEBUG( "size: %d\n", size );
- DRM_DEBUG( "agp_offset: %ld\n", agp_offset );
- DRM_DEBUG( "alignment: %d\n", alignment );
- DRM_DEBUG( "page_order: %d\n", page_order );
- DRM_DEBUG( "total: %d\n", total );
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
entry = &dma->bufs[order];
offset = 0;
- while ( entry->buf_count < count ) {
+ while (entry->buf_count < count) {
buf = &entry->buflist[entry->buf_count];
buf->idx = dma->buf_count + entry->buf_count;
buf->total = alignment;
return ENOMEM;
}
- DRM_DEBUG( "buffer %d @ %p\n",
- entry->buf_count, buf->address );
+ DRM_DEBUG("buffer %d @ %p\n", entry->buf_count, buf->address);
offset += alignment;
entry->buf_count++;
byte_count += PAGE_SIZE << page_order;
}
- DRM_DEBUG( "byte_count: %d\n", byte_count );
+ DRM_DEBUG("byte_count: %d\n", byte_count);
temp_buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
}
dma->buflist = temp_buflist;
- for ( i = 0 ; i < entry->buf_count ; i++ ) {
+ for (i = 0; i < entry->buf_count; i++)
dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
dma->buf_count += entry->buf_count;
dma->byte_count += byte_count;
- DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count );
- DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count );
+ DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
+ DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
request->count = entry->buf_count;
request->size = size;
++dev->buf_use; /* Can't allocate more after this call */
DRM_SPINUNLOCK(&dev->dma_lock);
- for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) {
- if ( dma->bufs[i].buf_count ) ++count;
+ for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
+ if (dma->bufs[i].buf_count)
+ ++count;
}
- DRM_DEBUG( "count = %d\n", count );
+ DRM_DEBUG("count = %d\n", count);
- if ( request->count >= count ) {
- for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) {
- if ( dma->bufs[i].buf_count ) {
+ if (request->count >= count) {
+ for (i = 0, count = 0; i < DRM_MAX_ORDER + 1; i++) {
+ if (dma->bufs[i].buf_count) {
drm_buf_desc_t from;
from.count = dma->bufs[i].buf_count;
from.size = dma->bufs[i].buf_size;
from.low_mark = dma->bufs[i].freelist.low_mark;
- from.high_mark = dma->bufs[i].freelist.high_mark;
+ from.high_mark =
+ dma->bufs[i].freelist.high_mark;
- if (DRM_COPY_TO_USER(&request->list[count], &from,
- sizeof(drm_buf_desc_t)) != 0) {
+ if (DRM_COPY_TO_USER(&request->list[count],
+ &from, sizeof(drm_buf_desc_t)) != 0) {
retcode = EFAULT;
break;
}
- DRM_DEBUG( "%d %d %d %d %d\n",
- i,
+ DRM_DEBUG("%d %d %d %d %d\n", i,
dma->bufs[i].buf_count,
dma->bufs[i].buf_size,
dma->bufs[i].freelist.low_mark,
- dma->bufs[i].freelist.high_mark );
+ dma->bufs[i].freelist.high_mark);
++count;
}
}
drm_buf_desc_t *request = data;
int order;
- DRM_DEBUG( "%d, %d, %d\n",
- request->size, request->low_mark, request->high_mark );
+ DRM_DEBUG("%d, %d, %d\n", request->size, request->low_mark,
+ request->high_mark);
order = drm_order(request->size);
drm_buf_t *buf;
int retcode = 0;
- DRM_DEBUG( "%d\n", request->count );
+ DRM_DEBUG("%d\n", request->count);
DRM_SPINLOCK(&dev->dma_lock);
- for ( i = 0 ; i < request->count ; i++ ) {
+ for (i = 0; i < request->count; i++) {
if (DRM_COPY_FROM_USER(&idx, &request->list[i], sizeof(idx))) {
retcode = EFAULT;
break;
}
- if ( idx < 0 || idx >= dma->buf_count ) {
- DRM_ERROR( "Index %d (of %d max)\n",
- idx, dma->buf_count - 1 );
+ if (idx < 0 || idx >= dma->buf_count) {
+ DRM_ERROR("Index %d (of %d max)\n", idx,
+ dma->buf_count - 1);
retcode = EINVAL;
break;
}
buf = dma->buflist[idx];
- if ( buf->file_priv != file_priv ) {
+ if (buf->file_priv != file_priv) {
DRM_ERROR("Process %d freeing buffer not owned\n",
DRM_CURRENTPID);
retcode = EINVAL;
request->virtual = (void *)vaddr;
- for ( i = 0 ; i < dma->buf_count ; i++ ) {
+ for (i = 0; i < dma->buf_count; i++) {
if (DRM_COPY_TO_USER(&request->list[i].idx,
&dma->buflist[i]->idx, sizeof(request->list[0].idx))) {
retcode = EFAULT;
done:
request->count = dma->buf_count;
- DRM_DEBUG( "%d buffers, retcode = %d\n", request->count, retcode );
+ DRM_DEBUG("%d buffers, retcode = %d\n", request->count, retcode);
return retcode;
}
return -1;
DRM_LOCK();
- bit = find_first_zero_bit( dev->ctx_bitmap, DRM_MAX_CTXBITMAP );
+ bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
if (bit >= DRM_MAX_CTXBITMAP) {
DRM_UNLOCK();
return -1;
DRM_LOCK();
dev->ctx_bitmap = drm_calloc(1, PAGE_SIZE, DRM_MEM_CTXBITMAP);
- if ( dev->ctx_bitmap == NULL ) {
+ if (dev->ctx_bitmap == NULL) {
DRM_UNLOCK();
return ENOMEM;
}
dev->max_context = -1;
DRM_UNLOCK();
- for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
temp = drm_ctxbitmap_next(dev);
- DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp );
+ DRM_DEBUG("drm_ctxbitmap_init : %d\n", temp);
}
return 0;
drm_ctx_t ctx;
int i;
- if ( res->count >= DRM_RESERVED_CONTEXTS ) {
+ if (res->count >= DRM_RESERVED_CONTEXTS) {
bzero(&ctx, sizeof(ctx));
- for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
ctx.handle = i;
- if ( DRM_COPY_TO_USER( &res->contexts[i],
- &ctx, sizeof(ctx) ) )
+ if (DRM_COPY_TO_USER(&res->contexts[i],
+ &ctx, sizeof(ctx)))
return EFAULT;
}
}
drm_ctx_t *ctx = data;
ctx->handle = drm_ctxbitmap_next(dev);
- if ( ctx->handle == DRM_KERNEL_CONTEXT ) {
+ if (ctx->handle == DRM_KERNEL_CONTEXT) {
/* Skip kernel's context and get a new one. */
ctx->handle = drm_ctxbitmap_next(dev);
}
- DRM_DEBUG( "%d\n", ctx->handle );
- if ( ctx->handle == -1 ) {
- DRM_DEBUG( "Not enough free contexts.\n" );
+ DRM_DEBUG("%d\n", ctx->handle);
+ if (ctx->handle == -1) {
+ DRM_DEBUG("Not enough free contexts.\n");
/* Should this return -EBUSY instead? */
return ENOMEM;
}
{
drm_ctx_t *ctx = data;
- DRM_DEBUG( "%d\n", ctx->handle );
- if ( ctx->handle != DRM_KERNEL_CONTEXT ) {
+ DRM_DEBUG("%d\n", ctx->handle);
+ if (ctx->handle != DRM_KERNEL_CONTEXT) {
if (dev->driver.context_dtor) {
DRM_LOCK();
dev->driver.context_dtor(dev, ctx->handle);
for (i = 0; i <= DRM_MAX_ORDER; i++) {
if (dma->bufs[i].seg_count) {
DRM_DEBUG("order %d: buf_count = %d,"
- " seg_count = %d\n",
- i,
- dma->bufs[i].buf_count,
+ " seg_count = %d\n", i, dma->bufs[i].buf_count,
dma->bufs[i].seg_count);
for (j = 0; j < dma->bufs[i].seg_count; j++) {
drm_pci_free(dev, dma->bufs[i].seglist[j]);
void
drm_free_buffer(struct drm_device *dev, drm_buf_t *buf)
{
- if (!buf) return;
+ if (buf == NULL)
+ return;
buf->pending = 0;
buf->file_priv= NULL;
drm_device_dma_t *dma = dev->dma;
int i;
- if (!dma) return;
+ if (dma == NULL)
+ return;
for (i = 0; i < dma->buf_count; i++) {
if (dma->buflist[i]->file_priv == file_priv) {
switch (dma->buflist[i]->list) {
drm_drawable_compare);
struct bsd_drm_drawable_info {
- struct drm_drawable_info info;
- unsigned int handle;
- RB_ENTRY(bsd_drm_drawable_info) tree;
+ struct drm_drawable_info info;
+ unsigned int handle;
+ RB_ENTRY(bsd_drm_drawable_info) tree;
};
int
struct drm_clip_rect *rects;
DRM_SPINUNLOCK(&dev->drw_lock);
- rects = drm_calloc(update->num,
- sizeof(*info->rects), DRM_MEM_DRAWABLE);
+ rects = drm_calloc(update->num, sizeof(*info->rects),
+ DRM_MEM_DRAWABLE);
DRM_SPINLOCK(&dev->drw_lock);
if (rects == NULL) {
ret = ENOMEM;
return;
RB_REMOVE(drawable_tree, &dev->drw_head, draw);
DRM_SPINUNLOCK(&dev->drw_lock);
- drm_free(draw->info.rects,
- sizeof(*draw->info.rects) * draw->info.num_rects, DRM_MEM_DRAWABLE);
+ drm_free(draw->info.rects, sizeof(*draw->info.rects) *
+ draw->info.num_rects, DRM_MEM_DRAWABLE);
drm_free(draw, sizeof(*draw), DRM_MEM_DRAWABLE);
DRM_SPINLOCK(&dev->drw_lock);
}
struct bsd_drm_drawable_info *draw, *nxt;
DRM_SPINLOCK(&dev->drw_lock);
-
for (draw = RB_MIN(drawable_tree, &dev->drw_head); draw != NULL;
draw = nxt) {
nxt = RB_NEXT(drawable_tree, &dev->drw_head, draw);
drm_drawable_free(dev, draw);
-
}
DRM_SPINUNLOCK(&dev->drw_lock);
-
}
*/
#include <sys/limits.h>
+#include <sys/ttycom.h> /* for TIOCSGRP */
+
#include "drmP.h"
#include "drm.h"
#include "drm_sarea.h"
-#include <sys/ttycom.h> /* for TIOCSGRP */
#ifdef DRM_DEBUG_DEFAULT_ON
int drm_debug_flag = 1;
DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid,
+ DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion, DRM_MASTER|DRM_ROOT_ONLY),
-
- DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-
- DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_SET_VERSION, drm_setversion,
+ DRM_MASTER|DRM_ROOT_ONLY),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_SET_UNIQUE, drm_setunique,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_BLOCK, drm_noop,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_UNBLOCK, drm_noop,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AUTH_MAGIC, drm_authmagic,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_ADD_MAP, drm_addmap_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_RM_MAP, drm_rmmap_ioctl, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_SET_SAREA_CTX, drm_noop,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_GET_SAREA_CTX, drm_noop, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_ADD_CTX, drm_addctx,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_RM_CTX, drm_rmctx,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_MOD_CTX, drm_noop,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_GET_CTX, drm_getctx, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_SWITCH_CTX, drm_noop,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_NEW_CTX, drm_noop,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_RES_CTX, drm_resctx, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_ADD_DRAW, drm_adddraw,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_RM_DRAW, drm_rmdraw,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_LOCK, drm_lock, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_UNLOCK, drm_unlock, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_ADD_BUFS, drm_addbufs_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_MARK_BUFS, drm_markbufs, DRM_AUTH|DRM_MASTER),
DRM_IOCTL_DEF(DRM_IOCTL_INFO_BUFS, drm_infobufs, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_MAP_BUFS, drm_mapbufs, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_FREE_BUFS, drm_freebufs, DRM_AUTH),
DRM_IOCTL_DEF(DRM_IOCTL_DMA, drm_dma, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_CONTROL, drm_control,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AGP_ACQUIRE, drm_agp_acquire_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AGP_RELEASE, drm_agp_release_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AGP_ENABLE, drm_agp_enable_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_AGP_INFO, drm_agp_info_ioctl, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
-
- DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
- DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AGP_ALLOC, drm_agp_alloc_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AGP_FREE, drm_agp_free_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AGP_BIND, drm_agp_bind_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_AGP_UNBIND, drm_agp_unbind_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+
+ DRM_IOCTL_DEF(DRM_IOCTL_SG_ALLOC, drm_sg_alloc_ioctl,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_SG_FREE, drm_sg_free,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank, 0),
DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_modeset_ctl, 0),
- DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
+ DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw,
+ DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
};
struct drm_device *drm_units[DRM_MAXUNITS];
drm_pci_id_list_t *id_entry;
/* first make sure there is place for the device */
- for(unit=0; unit<DRM_MAXUNITS; unit++)
- if(drm_units[unit] == NULL) break;
- if(unit == DRM_MAXUNITS) return 0;
+ for (unit=0; unit<DRM_MAXUNITS; unit++)
+ if (drm_units[unit] == NULL)
+ break;
+ if (unit == DRM_MAXUNITS)
+ return 0;
id_entry = drm_find_description(PCI_VENDOR(pa->pa_id),
PCI_PRODUCT(pa->pa_id), idlist);
- if (id_entry != NULL) {
+ if (id_entry != NULL)
return 1;
- }
return 0;
}
struct drm_device *dev;
drm_pci_id_list_t *id_entry;
- if(init_units) {
- for(unit=0; unit<DRM_MAXUNITS;unit++)
+ if (init_units) {
+ for (unit=0; unit<DRM_MAXUNITS; unit++)
drm_units[unit] = NULL;
init_units = 0;
}
- for(unit=0; unit<DRM_MAXUNITS; unit++)
- if(drm_units[unit] == NULL) break;
- if(unit == DRM_MAXUNITS) return;
+ for (unit=0; unit<DRM_MAXUNITS; unit++)
+ if (drm_units[unit] == NULL)
+ break;
+ if (unit == DRM_MAXUNITS)
+ return;
dev = drm_units[unit] = (struct drm_device*)kdev;
dev->unit = unit;
for (i = 0; idlist[i].vendor != 0; i++) {
if ((idlist[i].vendor == vendor) &&
- (idlist[i].device == device)) {
+ (idlist[i].device == device))
return &idlist[i];
- }
}
return NULL;
}
dev->types[4] = _DRM_STAT_LOCKS;
dev->types[5] = _DRM_STAT_UNLOCKS;
- for ( i = 0 ; i < DRM_ARRAY_SIZE(dev->counts) ; i++ )
- atomic_set( &dev->counts[i], 0 );
+ for (i = 0; i < DRM_ARRAY_SIZE(dev->counts); i++)
+ atomic_set(&dev->counts[i], 0);
dev->magicid = 1;
SPLAY_INIT(&dev->magiclist);
dev->buf_pgid = 0;
- DRM_DEBUG( "\n" );
+ DRM_DEBUG("\n");
return 0;
}
DRM_SPINLOCK_ASSERT(&dev->dev_lock);
- DRM_DEBUG( "\n" );
+ DRM_DEBUG("\n");
if (dev->driver.lastclose != NULL)
dev->driver.lastclose(dev);
if (dev->irq_enabled)
drm_irq_uninstall(dev);
- if ( dev->unique ) {
+ if (dev->unique != NULL) {
drm_free(dev->unique, dev->unique_len + 1, DRM_MEM_DRIVER);
dev->unique = NULL;
dev->unique_len = 0;
}
drm_drawable_free_all(dev);
- /* Clear pid list */
+ /* Clear pid list */
while ((pt = SPLAY_ROOT(&dev->magiclist)) != NULL) {
SPLAY_REMOVE(drm_magic_tree, &dev->magiclist, pt);
drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
}
/* Clear AGP information */
- if ( dev->agp ) {
+ if (dev->agp != NULL) {
struct drm_agp_mem *entry;
/* Remove AGP resources, but leave dev->agp intact until
* drm_unload is called.
*/
while ((entry = TAILQ_FIRST(&dev->agp->memory)) != NULL) {
- if ( entry->bound )
+ if (entry->bound)
drm_agp_unbind_memory(entry->handle);
drm_agp_free_memory(entry->handle);
TAILQ_REMOVE(&dev->agp->memory, entry, link);
}
drm_dma_takedown(dev);
- if ( dev->lock.hw_lock ) {
+ if (dev->lock.hw_lock != NULL) {
dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.file_priv = NULL;
DRM_WAKEUP_INT((void *)&dev->lock.lock_queue);
{
int retcode;
- DRM_DEBUG( "\n" );
+ DRM_DEBUG("\n");
dev->irq = dev->pa.pa_intrline;
dev->pci_domain = 0;
DRM_ERROR("Cannot allocate memory for context bitmap.\n");
goto error;
}
- printf(", %d.%d.%d %s\n",
- dev->driver.major,
- dev->driver.minor,
- dev->driver.patchlevel,
- dev->driver.date);
+ printf(", %d.%d.%d %s\n", dev->driver.major, dev->driver.minor,
+ dev->driver.patchlevel, dev->driver.date);
return 0;
drm_unload(struct drm_device *dev)
{
- DRM_DEBUG( "\n" );
+ DRM_DEBUG("\n");
drm_ctxbitmap_cleanup(dev);
drm_lastclose(dev);
DRM_UNLOCK();
- if ( dev->agp ) {
+ if (dev->agp != NULL) {
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
dev->agp = NULL;
}
drm_version_t *version = data;
int len;
-#define DRM_COPY( name, value ) \
+#define DRM_COPY(name, value) \
len = strlen( value ); \
if ( len > name##_len ) len = name##_len; \
name##_len = strlen( value ); \
return EFAULT; \
}
- version->version_major = dev->driver.major;
- version->version_minor = dev->driver.minor;
- version->version_patchlevel = dev->driver.patchlevel;
+ version->version_major = dev->driver.major;
+ version->version_minor = dev->driver.minor;
+ version->version_patchlevel = dev->driver.patchlevel;
DRM_COPY(version->name, dev->driver.name);
DRM_COPY(version->date, dev->driver.date);
if (dev == NULL)
return (ENXIO);
- DRM_DEBUG( "open_count = %d\n", dev->open_count );
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
retcode = drm_open_helper(kdev, flags, fmt, p, dev);
- if ( !retcode ) {
- atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
+ if (retcode == 0) {
+ atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
DRM_LOCK();
- if ( !dev->open_count++ )
+ if (dev->open_count++ == 0)
retcode = drm_firstopen(dev);
DRM_UNLOCK();
}
struct drm_file *file_priv;
int retcode = 0;
- DRM_DEBUG( "open_count = %d\n", dev->open_count );
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
DRM_LOCK();
* Begin inline drm_release
*/
- DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
+ DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
DRM_CURRENTPID, (long)&dev->device, dev->open_count);
if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
drm_lock_free(&dev->lock,
_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
-
- /* FIXME: may require heavy-handed reset of
- hardware at this point, possibly
- processed via a callback to the X
- server. */
} else if (dev->driver.reclaim_buffers_locked != NULL &&
dev->lock.hw_lock != NULL) {
/* The lock is required to reclaim buffers */
for (;;) {
- if ( !dev->lock.hw_lock ) {
+ if (dev->lock.hw_lock == NULL) {
/* Device has been unregistered */
retcode = EINTR;
break;
if (drm_lock_take(&dev->lock, DRM_KERNEL_CONTEXT)) {
dev->lock.file_priv = file_priv;
dev->lock.lock_time = jiffies;
- atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
+ atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
break; /* Got lock */
}
/* Contention */
*/
done:
- atomic_inc( &dev->counts[_DRM_STAT_CLOSES] );
+ atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
if (--dev->open_count == 0) {
retcode = drm_lastclose(dev);
}
return EINVAL;
}
- atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
+ atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
++file_priv->ioctl_count;
- DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
+ DRM_DEBUG("pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
DRM_CURRENTPID, cmd, nr, (long)&dev->device,
- file_priv->authenticated );
+ file_priv->authenticated);
switch (cmd) {
case FIONBIO:
func = ioctl->func;
if (func == NULL) {
- DRM_DEBUG( "no function\n" );
+ DRM_DEBUG("no function\n");
return EINVAL;
}
DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
priv = drm_calloc(1, sizeof(*priv), DRM_MEM_FILES);
- if (priv == NULL) {
+ if (priv == NULL)
return (ENOMEM);
- }
+
priv->uid = DRM_UID(p);
priv->pid = DRM_PID(p);
priv->kdev = kdev;
domain = bus >> 8;
bus &= 0xff;
- if ((domain != dev->pci_domain) ||
- (bus != dev->pci_bus) ||
- (slot != dev->pci_slot) ||
- (func != dev->pci_func)) {
+ if ((domain != dev->pci_domain) || (bus != dev->pci_bus) ||
+ (slot != dev->pci_slot) || (func != dev->pci_func)) {
drm_free(busid, u->unique_len + 1, DRM_MEM_DRIVER);
return EINVAL;
}
}
TAILQ_FOREACH(mapinlist, &dev->maplist, link) {
- if (i==idx) {
+ if (i == idx) {
map->offset = mapinlist->offset;
map->size = mapinlist->size;
map->type = mapinlist->type;
idx = client->idx;
DRM_LOCK();
TAILQ_FOREACH(pt, &dev->files, link) {
- if (i==idx)
- {
+ if (i==idx) {
client->auth = pt->authenticated;
client->pid = pt->pid;
client->uid = pt->uid;
for (i = 0; i < dev->counters; i++) {
if (dev->types[i] == _DRM_STAT_LOCK)
- stats->data[i].value
- = (dev->lock.hw_lock
+ stats->data[i].value = (dev->lock.hw_lock
? dev->lock.hw_lock->lock : 0);
else
stats->data[i].value = atomic_read(&dev->counts[i]);
sv->drm_dd_minor = dev->driver.minor;
if (ver.drm_di_major != -1) {
- if (ver.drm_di_major != DRM_IF_MAJOR ||
- ver.drm_di_minor < 0 || ver.drm_di_minor > DRM_IF_MINOR) {
+ if (ver.drm_di_major != DRM_IF_MAJOR || ver.drm_di_minor < 0 ||
+ ver.drm_di_minor > DRM_IF_MINOR) {
return EINVAL;
}
- if_version = DRM_IF_VERSION(ver.drm_di_major,
- ver.drm_dd_minor);
+ if_version = DRM_IF_VERSION(ver.drm_di_major, ver.drm_dd_minor);
dev->if_version = DRM_MAX(if_version, dev->if_version);
if (ver.drm_di_minor >= 1) {
/*
#include "drm.h"
irqreturn_t drm_irq_handler_wrap(DRM_IRQ_ARGS);
-void vblank_disable(void *);
+void drm_locked_task(void *, void *);
void drm_update_vblank_count(struct drm_device *, int);
-void drm_locked_task(void *context, void *pending);
+void vblank_disable(void *);
int
drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv)
irq->irq = dev->irq;
- DRM_DEBUG("%d:%d:%d => IRQ %d\n",
- irq->busnum, irq->devnum, irq->funcnum, irq->irq);
+ DRM_DEBUG("%d:%d:%d => IRQ %d\n", irq->busnum, irq->devnum,
+ irq->funcnum, irq->irq);
return 0;
}
if (dev->irq == 0 || dev->dev_private == NULL)
return EINVAL;
- DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
+ DRM_DEBUG("irq=%d\n", dev->irq);
DRM_LOCK();
if (dev->irq_enabled) {
mtx_init(&dev->irq_lock, IPL_BIO);
- /* Before installing handler */
+ /* Before installing handler */
dev->driver.irq_preinstall(dev);
DRM_UNLOCK();
- /* Install handler */
+ /* Install handler */
if (pci_intr_map(&dev->pa, &ih) != 0) {
retcode = ENOENT;
goto err;
}
istr = pci_intr_string(dev->pa.pa_pc, ih);
dev->irqh = pci_intr_establish(dev->pa.pa_pc, ih, IPL_BIO,
- drm_irq_handler_wrap, dev,
- dev->device.dv_xname);
+ drm_irq_handler_wrap, dev, dev->device.dv_xname);
if (!dev->irqh) {
retcode = ENOENT;
goto err;
}
DRM_DEBUG("%s: interrupting at %s\n", dev->device.dv_xname, istr);
- /* After installing handler */
+ /* After installing handler */
DRM_LOCK();
dev->driver.irq_postinstall(dev);
DRM_UNLOCK();
dev->irq_enabled = 0;
- DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
+ DRM_DEBUG("irq=%d\n", dev->irq);
dev->driver.irq_uninstall(dev);
drm_control_t *ctl = data;
int err;
- switch ( ctl->func ) {
+ switch (ctl->func) {
case DRM_INST_HANDLER:
/* Handle drivers whose DRM used to require IRQ setup but the
* no longer does.
goto out;
}
- /* If interrupts are enabled/disabled between calls to this ioctl then
+ /*
+ * If interrupts are enabled/disabled between calls to this ioctl then
* it can get nasty. So just grab a reference so that the interrupts
* keep going through the modeset
*/
drm_vbl_send_signals(struct drm_device *dev, int crtc)
{
drm_vbl_sig_t *vbl_sig;
- unsigned int vbl_seq = atomic_read( &dev->vbl_received );
+ unsigned int vbl_seq = atomic_read(&dev->vbl_received);
struct proc *p;
vbl_sig = TAILQ_FIRST(&dev->vbl_sig_list);
while (vbl_sig != NULL) {
drm_vbl_sig_t *next = TAILQ_NEXT(vbl_sig, link);
- if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) {
+ if ((vbl_seq - vbl_sig->sequence) <= (1<<23)) {
p = pfind(vbl_sig->pid);
if (p != NULL)
psignal(p, vbl_sig->signo);
do {
old = *lock;
- if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT;
- else new = context | _DRM_LOCK_HELD;
+ if (old & _DRM_LOCK_HELD)
+ new = old | _DRM_LOCK_CONT;
+ else
+ new = context | _DRM_LOCK_HELD;
} while (!atomic_cmpset_int(lock, old, new));
if (_DRM_LOCKING_CONTEXT(old) == context) {
/* This takes a lock forcibly and hands it to context. Should ONLY be used
inside *_unlock to give lock to kernel before calling *_dma_schedule. */
int
-drm_lock_transfer(struct drm_lock_data *lock_data,
- unsigned int context)
+drm_lock_transfer(struct drm_lock_data *lock_data, unsigned int context)
{
volatile unsigned int *lock = &lock_data->hw_lock->lock;
unsigned int old, new;
}
int
-drm_lock_free(struct drm_lock_data *lock_data,
- unsigned int context)
+drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
{
volatile unsigned int *lock = &lock_data->hw_lock->lock;
unsigned int old, new;
}
goto done;
} else {
- for (i = 0 ; i < DRM_MAX_PCI_RESOURCE; ++i) {
+ for (i = 0; i < DRM_MAX_PCI_RESOURCE; ++i) {
bar = vga_pci_bar_info(dev->vga_softc, i);
if (bar == NULL)
continue;
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-/**
- * \file drm_pci.h
- * \brief PCI consistent, DMA-accessible memory allocation.
- *
- * \author Eric Anholt <anholt@FreeBSD.org>
- */
-
#include "drmP.h"
-/**********************************************************************/
-/** \name PCI memory */
-/*@{*/
-
-/**
- * \brief Allocate a physically contiguous DMA-accessible consistent
+/*
+ * Allocate a physically contiguous DMA-accessible consistent
* memory block.
*/
drm_dma_handle_t *
size, align, ret);
goto destroy;
}
- if(nsegs != 1) {
+ if (nsegs != 1) {
DRM_ERROR("bus_dmamem_alloc(%zd) returned %d segments\n",
size, nsegs);
goto free;
}
-/**
- * \brief Free a DMA-accessible consistent memory block.
+/*
+ * Free a DMA-accessible consistent memory block.
*/
void
drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah)
drm_free(dmah, sizeof(*dmah), DRM_MEM_DMA);
}
-
-/*@}*/
*
*/
-/** @file drm_scatter.c
+/*
* Allocation of memory for scatter-gather mappings by the graphics chip.
*
* The memory allocated here is then made into an aperture in the card
#include "drmP.h"
struct drm_sg_dmamem *drm_sg_dmamem_alloc(struct drm_device *, size_t);
-void drm_sg_dmamem_free(struct drm_sg_dmamem *);
+void drm_sg_dmamem_free(struct drm_sg_dmamem *);
void
drm_sg_cleanup(drm_sg_mem_t *entry)
unsigned long pages;
int i;
- if ( dev->sg )
+ if (dev->sg != NULL)
return EINVAL;
entry = drm_calloc(1, sizeof(*entry), DRM_MEM_SGLISTS);
- if ( !entry )
+ if (entry == NULL)
return ENOMEM;
pages = round_page(request->size) / PAGE_SIZE;
- DRM_DEBUG( "sg size=%ld pages=%ld\n", request->size, pages );
+ DRM_DEBUG("sg size=%ld pages=%ld\n", request->size, pages);
entry->pages = pages;
entry->busaddr = drm_calloc(pages, sizeof(*entry->busaddr),
DRM_MEM_SGLISTS);
- if ( !entry->busaddr ) {
+ if (entry->busaddr == NULL) {
drm_sg_cleanup(entry);
return ENOMEM;
}
for (i = 0; i < pages; i++)
entry->busaddr[i] = entry->mem->sg_map->dm_segs[i].ds_addr;
- DRM_DEBUG( "sg alloc handle = %08lx\n", entry->handle );
+ DRM_DEBUG("sg alloc handle = %08lx\n", entry->handle);
entry->virtual = (void *)entry->handle;
request->handle = entry->handle;
drm_scatter_gather_t *request = data;
int ret;
- DRM_DEBUG( "%s\n", __FUNCTION__ );
+ DRM_DEBUG("\n");
ret = drm_sg_alloc(dev, request);
return ret;
dev->sg = NULL;
DRM_UNLOCK();
- if ( !entry || entry->handle != request->handle )
+ if (entry == NULL || entry->handle != request->handle)
return EINVAL;
- DRM_DEBUG( "sg free virtual = 0x%lx\n", entry->handle );
+ DRM_DEBUG("sg free virtual = 0x%lx\n", entry->handle);
drm_sg_cleanup(entry);
goto segsfree;
if ((ret = bus_dmamem_alloc(dev->pa.pa_dmat, size, PAGE_SIZE, 0,
- dsd->sg_segs, pages, &dsd->sg_nsegs, BUS_DMA_NOWAIT)) != 0) {
- printf("alloc failed, value= %d\n",ret);
+ dsd->sg_segs, pages, &dsd->sg_nsegs, BUS_DMA_NOWAIT)) != 0)
goto destroy;
- }
if (bus_dmamem_map(dev->pa.pa_dmat, dsd->sg_segs, dsd->sg_nsegs, size,
&dsd->sg_kva, BUS_DMA_NOWAIT) != 0)