Permalink
Browse files

Move ioctls and some other userland interface stuff to a separate file.

  • Loading branch information...
1 parent e6e794c commit 319035bdfa3a2d8f757fd2269768d449f642dd51 @koriakin koriakin committed Sep 11, 2010
View
@@ -7,8 +7,8 @@ pscnv-y := nouveau_drv.o nouveau_state.o \
nv50_gpio.o nv50_grctx.o \
nv50_display.o nv50_crtc.o nv50_cursor.o nv50_calc.o nv50_dac.o \
nv50_sor.o \
- pscnv_mm.o pscnv_mem.o pscnv_vm.o pscnv_gem.o \
- pscnv_ramht.o pscnv_chan.o pscnv_engine.o pscnv_sysram.o pscnv_fifo.o \
+ pscnv_mm.o pscnv_mem.o pscnv_vm.o pscnv_gem.o pscnv_ioctl.o \
+ pscnv_ramht.o pscnv_chan.o pscnv_sysram.o \
nv50_vram.o nv50_vm.o nv50_chan.o nv50_fifo.o nv50_graph.o \
nvc0_vram.o nvc0_vm.o nvc0_chan.o
View
@@ -32,9 +32,7 @@
#include "drm_crtc_helper.h"
#include "nouveau_drv.h"
#include "pscnv_gem.h"
-#include "pscnv_chan.h"
-#include "pscnv_fifo.h"
-#include "pscnv_engine.h"
+#include "pscnv_vm.h"
#if 0
#include "nouveau_hw.h"
#include "nouveau_fb.h"
@@ -485,39 +483,3 @@ module_exit(nouveau_exit);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL and additional rights");
-
-#ifdef PSCNV_KAPI_DRM_IOCTL_DEF_DRV
-struct drm_ioctl_desc nouveau_ioctls[] = {
- DRM_IOCTL_DEF_DRV(PSCNV_GETPARAM, pscnv_ioctl_getparam, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_GEM_NEW, pscnv_ioctl_gem_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_GEM_INFO, pscnv_ioctl_gem_info, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_NEW, pscnv_ioctl_vspace_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_FREE, pscnv_ioctl_vspace_free, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_MAP, pscnv_ioctl_vspace_map, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_UNMAP, pscnv_ioctl_vspace_unmap, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_CHAN_NEW, pscnv_ioctl_chan_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_CHAN_FREE, pscnv_ioctl_chan_free, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_OBJ_VDMA_NEW, pscnv_ioctl_obj_vdma_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_FIFO_INIT, pscnv_ioctl_fifo_init, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_OBJ_ENG_NEW, pscnv_ioctl_obj_eng_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF_DRV(PSCNV_FIFO_INIT_IB, pscnv_ioctl_fifo_init_ib, DRM_UNLOCKED),
-};
-#else
-struct drm_ioctl_desc nouveau_ioctls[] = {
- DRM_IOCTL_DEF(DRM_PSCNV_GETPARAM, pscnv_ioctl_getparam, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_GEM_NEW, pscnv_ioctl_gem_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_GEM_INFO, pscnv_ioctl_gem_info, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_NEW, pscnv_ioctl_vspace_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_FREE, pscnv_ioctl_vspace_free, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_MAP, pscnv_ioctl_vspace_map, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_UNMAP, pscnv_ioctl_vspace_unmap, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_CHAN_NEW, pscnv_ioctl_chan_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_CHAN_FREE, pscnv_ioctl_chan_free, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_OBJ_VDMA_NEW, pscnv_ioctl_obj_vdma_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_FIFO_INIT, pscnv_ioctl_fifo_init, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_OBJ_ENG_NEW, pscnv_ioctl_obj_eng_new, DRM_UNLOCKED),
- DRM_IOCTL_DEF(DRM_PSCNV_FIFO_INIT_IB, pscnv_ioctl_fifo_init_ib, DRM_UNLOCKED),
-};
-#endif
-
-int nouveau_max_ioctl = DRM_ARRAY_SIZE(nouveau_ioctls);
View
@@ -468,8 +468,6 @@ extern int nouveau_load(struct drm_device *, unsigned long flags);
extern int nouveau_firstopen(struct drm_device *);
extern void nouveau_lastclose(struct drm_device *);
extern int nouveau_unload(struct drm_device *);
-extern int pscnv_ioctl_getparam(struct drm_device *, void *data,
- struct drm_file *);
extern bool nouveau_wait_until(struct drm_device *, uint64_t timeout,
uint32_t reg, uint32_t mask, uint32_t val);
//extern bool nouveau_wait_for_idle(struct drm_device *);
View
@@ -40,6 +40,7 @@
#include "pscnv_vm.h"
#include "pscnv_chan.h"
#include "pscnv_fifo.h"
+#include "pscnv_ioctl.h"
static void nouveau_stub_takedown(struct drm_device *dev) {}
static int nouveau_stub_init(struct drm_device *dev) { return 0; }
@@ -611,55 +612,6 @@ int nouveau_unload(struct drm_device *dev)
return 0;
}
-int pscnv_ioctl_getparam(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct drm_pscnv_getparam *getparam = data;
-
- NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
-
- switch (getparam->param) {
- case PSCNV_GETPARAM_CHIPSET_ID:
- getparam->value = dev_priv->chipset;
- break;
- case PSCNV_GETPARAM_PCI_VENDOR:
- getparam->value = dev->pci_vendor;
- break;
- case PSCNV_GETPARAM_PCI_DEVICE:
- getparam->value = dev->pci_device;
- break;
- case PSCNV_GETPARAM_BUS_TYPE:
- if (drm_device_is_agp(dev))
- getparam->value = NV_AGP;
- else if (drm_device_is_pcie(dev))
- getparam->value = NV_PCIE;
- else
- getparam->value = NV_PCI;
- break;
- case PSCNV_GETPARAM_PTIMER_TIME:
- getparam->value = nv04_timer_read(dev);
- break;
- case PSCNV_GETPARAM_FB_SIZE:
- getparam->value = dev_priv->vram_size;
- break;
- case PSCNV_GETPARAM_GRAPH_UNITS:
- /* NV40 and NV50 versions are quite different, but register
- * address is the same. User is supposed to know the card
- * family anyway... */
- if (dev_priv->card_type >= NV_40 && dev_priv->card_type < NV_C0) {
- getparam->value = nv_rd32(dev, NV40_PMC_GRAPH_UNITS);
- break;
- }
- /* FALLTHRU */
- default:
- NV_ERROR(dev, "unknown parameter %lld\n", getparam->param);
- return -EINVAL;
- }
-
- return 0;
-}
-
/* Wait until (value(reg) & mask) == val, up until timeout has hit */
bool nouveau_wait_until(struct drm_device *dev, uint64_t timeout,
uint32_t reg, uint32_t mask, uint32_t val)
View
@@ -27,8 +27,8 @@
#include "drm.h"
#include "drmP.h"
#include "nouveau_drv.h"
-#include "pscnv_fifo.h"
#include "pscnv_chan.h"
+#include "pscnv_fifo.h"
#include "nv50_vm.h"
struct nv50_fifo_engine {
View
@@ -32,8 +32,7 @@
#include "pscnv_ramht.h"
#include "pscnv_chan.h"
#include "pscnv_fifo.h"
-#include "nv50_chan.h"
-
+#include "pscnv_ioctl.h"
static int pscnv_chan_bind (struct pscnv_chan *ch, int fake) {
struct drm_nouveau_private *dev_priv = ch->dev->dev_private;
@@ -134,106 +133,6 @@ void pscnv_chan_ref_free(struct kref *ref) {
kfree(ch);
}
-/* needs vm_mutex held */
-struct pscnv_chan *
-pscnv_get_chan(struct drm_device *dev, struct drm_file *file_priv, int cid)
-{
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- unsigned long flags;
- spin_lock_irqsave(&dev_priv->chan->ch_lock, flags);
-
- if (cid < 128 && cid >= 0 && dev_priv->chan->chans[cid] && dev_priv->chan->chans[cid]->filp == file_priv) {
- struct pscnv_chan *res = dev_priv->chan->chans[cid];
- pscnv_chan_ref(res);
- spin_unlock_irqrestore(&dev_priv->chan->ch_lock, flags);
- return res;
- }
- spin_unlock_irqrestore(&dev_priv->chan->ch_lock, flags);
- return 0;
-}
-
-int pscnv_ioctl_chan_new(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_pscnv_chan_new *req = data;
- struct pscnv_vspace *vs;
- struct pscnv_chan *ch;
-
- NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
-
- vs = pscnv_get_vspace(dev, file_priv, req->vid);
- if (!vs)
- return -ENOENT;
-
- ch = pscnv_chan_new(dev, vs, 0);
- if (!ch) {
- pscnv_vspace_unref(vs);
- return -ENOMEM;
- }
- pscnv_vspace_unref(vs);
-
- req->cid = ch->cid;
- req->map_handle = 0xc0000000 | ch->cid << 16;
-
- ch->filp = file_priv;
-
- return 0;
-}
-
-int pscnv_ioctl_chan_free(struct drm_device *dev, void *data,
- struct drm_file *file_priv)
-{
- struct drm_pscnv_chan_free *req = data;
- struct pscnv_chan *ch;
-
- NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
-
- ch = pscnv_get_chan(dev, file_priv, req->cid);
- if (!ch)
- return -ENOENT;
-
- ch->filp = 0;
- pscnv_chan_unref(ch);
- pscnv_chan_unref(ch);
-
- return 0;
-}
-
-int pscnv_ioctl_obj_vdma_new(struct drm_device *dev, void *data,
- struct drm_file *file_priv) {
- struct drm_pscnv_obj_vdma_new *req = data;
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct pscnv_chan *ch;
- int ret;
- uint32_t oclass, inst;
-
- NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
-
- if (dev_priv->card_type != NV_50)
- return -ENOSYS;
-
- oclass = req->oclass;
-
- if (oclass != 2 && oclass != 3 && oclass != 0x3d)
- return -EINVAL;
-
- ch = pscnv_get_chan(dev, file_priv, req->cid);
- if (!ch)
- return -ENOENT;
-
- inst = nv50_chan_dmaobj_new(ch, 0x7fc00000 | oclass, req->start, req->size);
- if (!inst) {
- pscnv_chan_unref(ch);
- return -ENOMEM;
- }
-
- ret = pscnv_ramht_insert (&ch->ramht, req->handle, inst >> 4);
-
- pscnv_chan_unref(ch);
-
- return ret;
-}
-
static void pscnv_chan_vm_open(struct vm_area_struct *vma) {
struct pscnv_chan *ch = vma->vm_private_data;
pscnv_chan_ref(ch);
@@ -281,20 +180,6 @@ int pscnv_chan_mmap(struct file *filp, struct vm_area_struct *vma)
return -EINVAL;
}
-void pscnv_chan_cleanup(struct drm_device *dev, struct drm_file *file_priv) {
- int cid;
- struct pscnv_chan *ch;
-
- for (cid = 0; cid < 128; cid++) {
- ch = pscnv_get_chan(dev, file_priv, cid);
- if (!ch)
- continue;
- ch->filp = 0;
- pscnv_chan_unref(ch);
- pscnv_chan_unref(ch);
- }
-}
-
int pscnv_chan_handle_lookup(struct drm_device *dev, uint32_t handle) {
struct drm_nouveau_private *dev_priv = dev->dev_private;
unsigned long flags;
View
@@ -72,18 +72,9 @@ static inline void pscnv_chan_unref(struct pscnv_chan *ch) {
kref_put(&ch->ref, pscnv_chan_ref_free);
}
-extern void pscnv_chan_cleanup(struct drm_device *dev, struct drm_file *file_priv);
extern int pscnv_chan_mmap(struct file *filp, struct vm_area_struct *vma);
-struct pscnv_chan *pscnv_get_chan(struct drm_device *dev, struct drm_file *file_priv, int cid);
extern int pscnv_chan_handle_lookup(struct drm_device *dev, uint32_t handle);
-int pscnv_ioctl_chan_new(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-int pscnv_ioctl_chan_free(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-int pscnv_ioctl_obj_vdma_new(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
-
int nv50_chan_init(struct drm_device *dev);
int nvc0_chan_init(struct drm_device *dev);
View
@@ -1,49 +0,0 @@
-#include "drm.h"
-#include "drmP.h"
-#include "nouveau_drv.h"
-#include "pscnv_engine.h"
-#include "pscnv_chan.h"
-
-int pscnv_ioctl_obj_eng_new(struct drm_device *dev, void *data,
- struct drm_file *file_priv) {
- struct drm_pscnv_obj_eng_new *req = data;
- struct drm_nouveau_private *dev_priv = dev->dev_private;
- struct pscnv_chan *ch;
- int ret;
- int i;
- uint32_t oclass = req->oclass;
-
- NOUVEAU_CHECK_INITIALISED_WITH_RETURN;
-
- for (i = 0; i < PSCNV_ENGINES_NUM; i++)
- if (dev_priv->engines[i]) {
- uint32_t *pclass = dev_priv->engines[i]->oclasses;
- if (!pclass)
- continue;
- while (*pclass) {
- if (*pclass == oclass)
- goto found;
- pclass++;
- }
- }
- return -ENODEV;
-
-found:
- ch = pscnv_get_chan(dev, file_priv, req->cid);
- if (!ch)
- return -ENOENT;
-
- if (!ch->engdata[i]) {
- ret = dev_priv->engines[i]->chan_alloc(dev_priv->engines[i], ch);
- if (ret) {
- pscnv_chan_unref(ch);
- return ret;
- }
- }
-
- ret = dev_priv->engines[i]->chan_obj_new(dev_priv->engines[i], ch, req->handle, oclass, req->flags);
-
- pscnv_chan_unref(ch);
- return ret;
-}
-
@@ -23,7 +23,5 @@ int nv50_graph_init(struct drm_device *dev);
#define PSCNV_ENGINES_NUM 16
-int pscnv_ioctl_obj_eng_new(struct drm_device *dev, void *data,
- struct drm_file *file_priv);
#endif
Oops, something went wrong.

0 comments on commit 319035b

Please sign in to comment.