int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) { drm_via_private_t *dev_priv; unsigned int i; DRM_DEBUG("%s\n", __FUNCTION__); via_init_command_verifier(); dev_priv = DRM(alloc) (sizeof(drm_via_private_t), DRM_MEM_DRIVER); if (dev_priv == NULL) return -ENOMEM; memset(dev_priv, 0, sizeof(drm_via_private_t)); DRM_GETSAREA(); if (!dev_priv->sarea) { DRM_ERROR("could not find sarea!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->fb = drm_core_findmap(dev, init->fb_offset); if (!dev_priv->fb) { DRM_ERROR("could not find framebuffer!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset); if (!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->sarea_priv = (drm_via_sarea_t *) ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); dev_priv->agpAddr = init->agpAddr; for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i])); dev->dev_private = (void *)dev_priv; return 0; }
int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) { drm_via_private_t *dev_priv; DRM_DEBUG("%s\n", __FUNCTION__); via_init_command_verifier(); dev_priv = DRM(alloc) (sizeof(drm_via_private_t), DRM_MEM_DRIVER); if (dev_priv == NULL) return -ENOMEM; memset(dev_priv, 0, sizeof(drm_via_private_t)); DRM_GETSAREA(); if (!dev_priv->sarea) { DRM_ERROR("could not find sarea!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->fb = drm_core_findmap(dev, init->fb_offset); if (!dev_priv->fb) { DRM_ERROR("could not find framebuffer!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset); if (!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->sarea_priv = (drm_via_sarea_t *) ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); dev_priv->agpAddr = init->agpAddr; via_init_futex( dev_priv ); dev_priv->pro_group_a = (dev->pdev->device == 0x3118); dev->dev_private = (void *)dev_priv; return 0; }
int via_final_context(struct drm_device *dev, int context) { int i; drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; for (i = 0; i < MAX_CONTEXT; i++) if (global_ppriv[i].used && (global_ppriv[i].context == context)) break; if (i < MAX_CONTEXT) { set_t *set; ITEM_TYPE item; int retval; DRM_DEBUG("find socket %d, context = %d\n", i, context); /* Video Memory */ set = global_ppriv[i].sets[0]; retval = via_setFirst(set, &item); while (retval) { DRM_DEBUG("free video memory 0x%lx\n", item); via_mmFreeMem((PMemBlock) item); retval = via_setNext(set, &item); } via_setDestroy(set); /* AGP Memory */ set = global_ppriv[i].sets[1]; retval = via_setFirst(set, &item); while (retval) { DRM_DEBUG("free agp memory 0x%lx\n", item); via_mmFreeMem((PMemBlock) item); retval = via_setNext(set, &item); } via_setDestroy(set); global_ppriv[i].used = 0; } via_release_futex(dev_priv, context); #if defined(__linux__) /* Linux specific until context tracking code gets ported to BSD */ /* Last context, perform cleanup */ if (dev->ctx_count == 1 && dev->dev_private) { if (dev->irq) DRM(irq_uninstall) (dev); via_cleanup_futex(dev_priv); via_do_cleanup_map(dev); } #endif return 1; }
static int via_do_init_map(drm_device_t * dev, drm_via_init_t * init) { drm_via_private_t *dev_priv = dev->dev_private; DRM_DEBUG("%s\n", __FUNCTION__); DRM_GETSAREA(); if (!dev_priv->sarea) { DRM_ERROR("could not find sarea!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->fb = drm_core_findmap(dev, init->fb_offset); if (!dev_priv->fb) { DRM_ERROR("could not find framebuffer!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset); if (!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->sarea_priv = (drm_via_sarea_t *) ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); dev_priv->agpAddr = init->agpAddr; via_init_futex( dev_priv ); #ifdef VIA_HAVE_DMABLIT via_init_dmablit( dev ); #endif dev->dev_private = (void *)dev_priv; return 0; }
static int via_do_init_map(struct drm_device *dev, drm_via_init_t *init) { drm_via_private_t *dev_priv = dev->dev_private; DRM_DEBUG("\n"); dev_priv->sarea = drm_legacy_getsarea(dev); if (!dev_priv->sarea) { DRM_ERROR("could not find sarea!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->fb = drm_legacy_findmap(dev, init->fb_offset); if (!dev_priv->fb) { DRM_ERROR("could not find framebuffer!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->mmio = drm_legacy_findmap(dev, init->mmio_offset); if (!dev_priv->mmio) { DRM_ERROR("could not find mmio region!\n"); dev->dev_private = (void *)dev_priv; via_do_cleanup_map(dev); return -EINVAL; } dev_priv->sarea_priv = (drm_via_sarea_t *) ((u8 *) dev_priv->sarea->handle + init->sarea_priv_offset); dev_priv->agpAddr = init->agpAddr; via_init_futex(dev_priv); via_init_dmablit(dev); dev->dev_private = (void *)dev_priv; return 0; }
int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv) { drm_via_init_t *init = data; DRM_DEBUG("\n"); switch (init->func) { case VIA_INIT_MAP: return via_do_init_map(dev, init); case VIA_CLEANUP_MAP: return via_do_cleanup_map(dev); } return -EINVAL; }
int via_final_context(struct drm_device *dev, int context) { drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; via_release_futex(dev_priv, context); if (dev->ctx_count == 1 && dev->dev_private) { DRM_DEBUG("Last Context\n"); drm_irq_uninstall(dev); via_cleanup_futex(dev_priv); via_do_cleanup_map(dev); } return 1; }
int via_final_context(struct drm_device *dev, int context) { drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; via_release_futex(dev_priv, context); /* Linux specific until context tracking code gets ported to BSD */ /* Last context, perform cleanup */ if (dev->ctx_count == 1 && dev->dev_private) { DRM_DEBUG("Last Context\n"); if (dev->irq) drm_irq_uninstall(dev); via_cleanup_futex(dev_priv); via_do_cleanup_map(dev); } return 1; }
int via_map_init(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_via_init_t init; DRM_DEBUG("%s\n", __FUNCTION__); DRM_COPY_FROM_USER_IOCTL(init, (drm_via_init_t *) data, sizeof(init)); switch (init.func) { case VIA_INIT_MAP: return via_do_init_map(dev, &init); case VIA_CLEANUP_MAP: return via_do_cleanup_map(dev); } return -EINVAL; }