/** * Initialize the AGP resources. * * \return pointer to a drm_agp_head structure. * */ drm_agp_head_t *drm_agp_init(drm_device_t *dev) { drm_agp_head_t *head = NULL; if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) return NULL; memset((void *)head, 0, sizeof(*head)); head->bridge = agp_find_bridge(dev->pdev); if (!head->bridge) { if (!(head->bridge = agp_backend_acquire(dev->pdev))) { drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); return NULL; } agp_copy_info(head->bridge, &head->agp_info); agp_backend_release(head->bridge); } else { agp_copy_info(head->bridge, &head->agp_info); } if (head->agp_info.chipset == NOT_SUPPORTED) { drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); return NULL; } head->memory = NULL; head->cant_use_aperture = head->agp_info.cant_use_aperture; head->page_mask = head->agp_info.page_mask; return head; }
static int agpioc_acquire_wrap(agp_file_private * priv, unsigned long arg) { agp_controller *controller; if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags))) { return -EPERM; } if (agp_fe.current_controller != NULL) { return -EBUSY; } if ((agp_backend_acquire()) == 0) { agp_fe.backend_acquired = TRUE; } else { return -EBUSY; } controller = agp_find_controller_by_pid(priv->my_pid); if (controller != NULL) { agp_controller_make_current(controller); } else { controller = agp_create_controller(priv->my_pid); if (controller == NULL) { agp_fe.backend_acquired = FALSE; agp_backend_release(); return -ENOMEM; } agp_insert_controller(controller); agp_controller_make_current(controller); } set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags); set_bit(AGP_FF_IS_VALID, &priv->access_flags); return 0; }
/** * Acquire the AGP device. * * \param dev DRM device that is to acquire AGP * \return zero on success or a negative number on failure. * * Verifies the AGP device hasn't been acquired before and calls * \c agp_backend_acquire. */ int drm_agp_acquire(drm_device_t *dev) { if (!dev->agp) return -ENODEV; if (dev->agp->acquired) return -EBUSY; if (!(dev->agp->bridge = agp_backend_acquire(dev->pdev))) return -ENODEV; dev->agp->acquired = 1; return 0; }
static int agpioc_acquire_wrap(struct agp_file_private *priv) { int ret; struct agp_controller *controller; DBG(""); if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags))) return -EPERM; if (agp_fe.current_controller != NULL) return -EBUSY; ret = agp_backend_acquire(); if (ret == 0) agp_fe.backend_acquired = TRUE; else return ret; controller = agp_find_controller_by_pid(priv->my_pid); if (controller != NULL) { agp_controller_make_current(controller); } else { controller = agp_create_controller(priv->my_pid); if (controller == NULL) { agp_fe.backend_acquired = FALSE; agp_backend_release(); return -ENOMEM; } agp_insert_controller(controller); agp_controller_make_current(controller); } set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags); set_bit(AGP_FF_IS_VALID, &priv->access_flags); return 0; }