diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-11-22 21:26:49 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-11-22 21:26:49 +0000 |
commit | efaaf8fdb0ae277917aee89ce3717ef1fa793fa0 (patch) | |
tree | 1b5628ae32f72b00560a9f3eb1394e984b21d2e0 /sys/dev | |
parent | e352ee055ffd21c59021f5da76de929ac5cd366e (diff) |
Move the drm drivers over from:
vga1 at pci0
inteldrm0 at vga1
to
vga1 at pci0
inteldrm0 at vga1
drm0 at inteldrm0
i.e. a similar scheme to audio(4) where the interface attaches on top of
the wildly different drivers. This helps to clean up the code a lot
(more is coming) and help me start to move drm to being essentially bus
independent, which will help in the future.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 29 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_drv.c | 78 | ||||
-rw-r--r-- | sys/dev/pci/drm/files.drm | 50 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915_drv.c | 58 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915_drv.h | 7 | ||||
-rw-r--r-- | sys/dev/pci/drm/mach64_drv.c | 33 | ||||
-rw-r--r-- | sys/dev/pci/drm/mach64_drv.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/mga_drv.c | 40 | ||||
-rw-r--r-- | sys/dev/pci/drm/mga_drv.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_drv.c | 31 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_drv.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_state.c | 9 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon_drv.c | 30 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon_drv.h | 2 | ||||
-rw-r--r-- | sys/dev/pci/drm/savage_drv.c | 29 | ||||
-rw-r--r-- | sys/dev/pci/drm/savage_drv.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/drm/sis_drv.c | 28 | ||||
-rw-r--r-- | sys/dev/pci/drm/sis_drv.h | 7 | ||||
-rw-r--r-- | sys/dev/pci/drm/tdfx_drv.c | 17 | ||||
-rw-r--r-- | sys/dev/pci/vga_pci.c | 10 |
20 files changed, 245 insertions, 225 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 54c5da04555..9f7deb67352 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -132,7 +132,6 @@ #define DRM_LOCK() rw_enter_write(&dev->dev_lock) #define DRM_UNLOCK() rw_exit_write(&dev->dev_lock) #define DRM_MAXUNITS 8 -extern struct drm_device *drm_units[]; /* Deal with netbsd code where only the print statements differ */ #define printk printf @@ -151,13 +150,10 @@ enum { #define DRM_AGP_MEM struct agp_memory_info /* D_CLONE only supports one device, this will be fixed eventually */ +#define drm_get_device_from_kdev(_kdev) drm_cd.cd_devs[0] +#if 0 #define drm_get_device_from_kdev(_kdev) \ - drm_units[0] - -#if 0 /* D_CLONE only supports on device for now */ -#define drm_get_device_from_kdev(_kdev) \ - (minor(kdev) < DRM_MAXUNITS) ? \ - drm_units[minor(kdev)] : NULL + (minor(_kdev) < drm_cd.cd_ndevs) ? drm_cd.cd_devs[minor(_kdev)] : NULL #endif @@ -209,7 +205,7 @@ typedef u_int8_t u8; #define DRM_VERIFYAREA_READ( uaddr, size ) \ (!uvm_map_checkprot(&(curproc->p_vmspace->vm_map), \ - (vaddr_t)uaddr, (vaddr_t)uaddr+size, UVM_PROT_READ)) + (vaddr_t)uaddr, (vaddr_t)uaddr+size, UVM_PROT_READ)) #define DRM_COPY_TO_USER(user, kern, size) \ copyout(kern, user, size) @@ -251,7 +247,7 @@ DRM_SPINUNLOCK(&dev->irq_lock) printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \ DRM_CURRENTPID, __func__ , ## arg) -#define DRM_INFO(fmt, arg...) printf("%s: " fmt, drm_units[0]->device.dv_xname, ## arg) +#define DRM_INFO(fmt, arg...) printf("%s: " fmt, dev_priv->dev.dv_xname, ## arg) #undef DRM_DEBUG #define DRM_DEBUG(fmt, arg...) do { \ @@ -268,6 +264,7 @@ typedef struct drm_pci_id_list } drm_pci_id_list_t; struct drm_file; +struct drm_device; #define DRM_AUTH 0x1 #define DRM_MASTER 0x2 @@ -575,13 +572,19 @@ struct drm_device { RB_HEAD(drawable_tree, bsd_drm_drawable_info) drw_head; }; +struct drm_attach_args { + const struct drm_driver_info *driver; + struct pci_attach_args *pa; + struct vga_pci_softc *vga; +}; + extern int drm_debug_flag; /* Device setup support (drm_drv.c) */ -int drm_probe(struct pci_attach_args *, drm_pci_id_list_t * ); -void drm_attach(struct device *, struct device *, struct pci_attach_args *); -int drm_detach(struct device *, int ); -int drm_activate(struct device *, enum devact); +int drm_pciprobe(struct pci_attach_args *, drm_pci_id_list_t * ); +struct device *drm_attach_mi(const struct drm_driver_info *, + struct pci_attach_args *pa, struct device *, + struct device *); dev_type_ioctl(drmioctl); dev_type_open(drmopen); dev_type_close(drmclose); diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index 0e9fecb33b4..f44cfb50e0c 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -49,25 +49,39 @@ int drm_debug_flag = 0; int drm_firstopen(struct drm_device *); int drm_lastclose(struct drm_device *); +void drm_attach(struct device *, struct device *, void *); +int drm_probe(struct device *, void *, void *); +int drm_detach(struct device *, int); +int drm_activate(struct device *, enum devact); +int drmprint(void *, const char *); + +struct device * +drm_attach_mi(const struct drm_driver_info *driver, struct pci_attach_args *pa, + struct device *vga, struct device *dev) +{ + struct drm_attach_args arg; + arg.driver = driver; + arg.pa = pa; + arg.vga = (struct vga_pci_softc *)vga; -struct drm_device *drm_units[DRM_MAXUNITS]; + printf("\n"); + return (config_found(dev, &arg, drmprint)); +} -static int init_units = 1; +int +drmprint(void *aux, const char *pnp) +{ + if (pnp != NULL) + printf("drm at %s\n", pnp); + return (UNCONF); +} int -drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist) +drm_pciprobe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist) { - int unit; 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; - id_entry = drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), idlist); if (id_entry != NULL) @@ -76,32 +90,27 @@ drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist) return 0; } -void -drm_attach(struct device *parent, struct device *kdev, - struct pci_attach_args *pa) +int +drm_probe(struct device *parent, void *match, void *aux) { - int unit; - struct drm_device *dev; - - if (init_units) { - for (unit=0; unit<DRM_MAXUNITS; unit++) - drm_units[unit] = NULL; - init_units = 0; - } + struct drm_attach_args *da = aux; + return (da->driver != NULL ? 1 : 0); +} - for (unit=0; unit<DRM_MAXUNITS; unit++) - if (drm_units[unit] == NULL) - break; - if (unit == DRM_MAXUNITS) - return; +void +drm_attach(struct device *parent, struct device *self, void *aux) +{ + struct drm_device *dev = (struct drm_device *)self; + struct drm_attach_args *da = aux; + struct pci_attach_args *pa = da->pa; - dev = drm_units[unit] = (struct drm_device*)kdev; - dev->unit = unit; + dev->dev_private = parent; + dev->driver = da->driver; + dev->vga_softc = da->vga; /* needed for pci_mapreg_* */ memcpy(&dev->pa, pa, sizeof(dev->pa)); - dev->vga_softc = (struct vga_pci_softc *)parent; dev->irq = pa->pa_intrline; dev->pci_domain = 0; @@ -200,6 +209,15 @@ drm_activate(struct device *self, enum devact act) return (0); } +struct cfattach drm_ca = { + sizeof(struct drm_device), drm_probe, drm_attach, + drm_detach, drm_activate +}; + +struct cfdriver drm_cd = { + 0, "drm", DV_DULL +}; + drm_pci_id_list_t * drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist) { diff --git a/sys/dev/pci/drm/files.drm b/sys/dev/pci/drm/files.drm index 07ac131f421..4252dff4cd8 100644 --- a/sys/dev/pci/drm/files.drm +++ b/sys/dev/pci/drm/files.drm @@ -1,39 +1,41 @@ # $NetBSD: files.drm,v 1.2 2007/03/28 11:29:37 jmcneill Exp $ -# $OpenBSD: files.drm,v 1.6 2008/11/17 00:40:04 oga Exp $ +# $OpenBSD: files.drm,v 1.7 2008/11/22 21:26:48 oga Exp $ # direct rendering modules -define drmbase -file dev/pci/drm/drm_agpsupport.c drmbase -file dev/pci/drm/drm_auth.c drmbase -file dev/pci/drm/drm_bufs.c drmbase -file dev/pci/drm/drm_context.c drmbase -file dev/pci/drm/drm_dma.c drmbase -file dev/pci/drm/drm_drawable.c drmbase -file dev/pci/drm/drm_drv.c drmbase needs-flag -file dev/pci/drm/drm_ioctl.c drmbase -file dev/pci/drm/drm_irq.c drmbase -file dev/pci/drm/drm_lock.c drmbase -file dev/pci/drm/drm_memory.c drmbase -file dev/pci/drm/drm_pci.c drmbase -file dev/pci/drm/drm_scatter.c drmbase -file dev/pci/drm/drm_vm.c drmbase +define drmbase {} +device drm: drmbase +attach drm at drmbase +file dev/pci/drm/drm_agpsupport.c drm +file dev/pci/drm/drm_auth.c drm +file dev/pci/drm/drm_bufs.c drm +file dev/pci/drm/drm_context.c drm +file dev/pci/drm/drm_dma.c drm +file dev/pci/drm/drm_drawable.c drm +file dev/pci/drm/drm_drv.c drm needs-flag +file dev/pci/drm/drm_ioctl.c drm +file dev/pci/drm/drm_irq.c drm +file dev/pci/drm/drm_lock.c drm +file dev/pci/drm/drm_memory.c drm +file dev/pci/drm/drm_pci.c drm +file dev/pci/drm/drm_scatter.c drm +file dev/pci/drm/drm_vm.c drm device inteldrm: drmbase -attach inteldrm at drm +attach inteldrm at drmdev file dev/pci/drm/i915_drv.c inteldrm file dev/pci/drm/i915_dma.c inteldrm file dev/pci/drm/i915_irq.c inteldrm file dev/pci/drm/i915_mem.c inteldrm device machdrm: drmbase -attach machdrm at drm +attach machdrm at drmdev file dev/pci/drm/mach64_dma.c machdrm file dev/pci/drm/mach64_drv.c machdrm file dev/pci/drm/mach64_irq.c machdrm file dev/pci/drm/mach64_state.c machdrm device mgadrm: drmbase -attach mgadrm at drm +attach mgadrm at drmdev file dev/pci/drm/mga_dma.c mgadrm file dev/pci/drm/mga_drv.c mgadrm file dev/pci/drm/mga_irq.c mgadrm @@ -41,7 +43,7 @@ file dev/pci/drm/mga_state.c mgadrm file dev/pci/drm/mga_warp.c mgadrm device ragedrm: drmbase -attach ragedrm at drm +attach ragedrm at drmdev file dev/pci/drm/ati_pcigart.c ragedrm | radeondrm file dev/pci/drm/r128_cce.c ragedrm file dev/pci/drm/r128_drv.c ragedrm @@ -49,7 +51,7 @@ file dev/pci/drm/r128_irq.c ragedrm file dev/pci/drm/r128_state.c ragedrm device radeondrm: drmbase -attach radeondrm at drm +attach radeondrm at drmdev file dev/pci/drm/r300_cmdbuf.c radeondrm file dev/pci/drm/radeon_cp.c radeondrm file dev/pci/drm/radeon_drv.c radeondrm @@ -58,17 +60,17 @@ file dev/pci/drm/radeon_mem.c radeondrm file dev/pci/drm/radeon_state.c radeondrm device savagedrm: drmbase -attach savagedrm at drm +attach savagedrm at drmdev file dev/pci/drm/savage_bci.c savagedrm file dev/pci/drm/savage_drv.c savagedrm file dev/pci/drm/savage_state.c savagedrm device sisdrm: drmbase -attach sisdrm at drm +attach sisdrm at drmdev file dev/pci/drm/sis_drv.c sisdrm file dev/pci/drm/sis_ds.c sisdrm file dev/pci/drm/sis_mm.c sisdrm device tdfxdrm: drmbase -attach tdfxdrm at drm +attach tdfxdrm at drmdev file dev/pci/drm/tdfx_drv.c tdfxdrm diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c index e1bd5be9af2..4ed73f84fd5 100644 --- a/sys/dev/pci/drm/i915_drv.c +++ b/sys/dev/pci/drm/i915_drv.c @@ -117,72 +117,74 @@ static const struct drm_driver_info inteldrm_driver = { int inteldrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, inteldrm_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, inteldrm_pciidlist); } void inteldrm_attach(struct device *parent, struct device *self, void *aux) { + struct drm_i915_private *dev_priv = (struct drm_i915_private *)self; struct pci_attach_args *pa = aux; - struct drm_i915_private *dev_priv; - struct drm_device *dev = (struct drm_device *)self; + struct vga_pci_bar *bar; drm_pci_id_list_t *id_entry; - unsigned long base, size; - int ret = 0, mmio_bar = IS_I9XX(dev_priv) ? 0 : 1; - - dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); - if (dev_priv == NULL) - return; - - dev->dev_private = (void *)dev_priv; + int mmio_bar; id_entry = drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), inteldrm_pciidlist); dev_priv->flags = id_entry->driver_private; + mmio_bar = IS_I9XX(dev_priv) ? 0 : 1; + /* Add register map (needed for suspend/resume) */ - base = drm_get_resource_start(dev, mmio_bar); - size = drm_get_resource_len(dev, mmio_bar); + bar = vga_pci_bar_info((struct vga_pci_softc *)parent, mmio_bar); + if (bar == NULL) { + printf(": can't get BAR info\n"); + return; + } - dev_priv->regs = vga_pci_bar_map(dev->vga_softc, base, size, 0); - if (dev_priv->regs == NULL) + dev_priv->regs = vga_pci_bar_map((struct vga_pci_softc *)parent, + bar->addr, bar->size, 0); + if (dev_priv->regs == NULL) { + printf(": can't map mmio space\n"); return; + } /* Init HWS */ if (!I915_NEED_GFX_HWS(dev_priv)) { - ret = i915_init_phys_hws(dev_priv, dev->pa.pa_dmat); - if (ret != 0) + if (i915_init_phys_hws(dev_priv, pa->pa_dmat) != 0) { + printf(": couldn't initialize hardware status page\n"); return; + } } mtx_init(&dev_priv->user_irq_lock, IPL_BIO); - dev->driver = &inteldrm_driver; - - drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&inteldrm_driver, pa, parent, self); } int inteldrm_detach(struct device *self, int flags) { - struct drm_device *dev = (struct drm_device *)self; - struct drm_i915_private *dev_priv = dev->dev_private; + struct drm_i915_private *dev_priv = (struct drm_i915_private *)self; - i915_free_hws(dev_priv, dev->pa.pa_dmat); + if (dev_priv->drmdev != NULL) { + config_detach(dev_priv->drmdev, flags); + dev_priv->drmdev = NULL; + } + + i915_free_hws(dev_priv, dev_priv->dmat); if (dev_priv->regs != NULL) vga_pci_bar_unmap(dev_priv->regs); DRM_SPINUNINIT(&dev_priv->user_irq_lock); - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - - return (drm_detach(self, flags)); + return (0); } struct cfattach inteldrm_ca = { - sizeof(struct drm_device), inteldrm_probe, inteldrm_attach, - inteldrm_detach, drm_activate + sizeof(struct drm_i915_private), inteldrm_probe, inteldrm_attach, + inteldrm_detach }; struct cfdriver inteldrm_cd = { diff --git a/sys/dev/pci/drm/i915_drv.h b/sys/dev/pci/drm/i915_drv.h index f4ff3e7407d..e0951b7a6da 100644 --- a/sys/dev/pci/drm/i915_drv.h +++ b/sys/dev/pci/drm/i915_drv.h @@ -77,12 +77,15 @@ struct mem_block { }; typedef struct drm_i915_private { - struct vga_pci_bar *regs; + struct device dev; + struct device *drmdev; + bus_dma_tag_t dmat; + + struct vga_pci_bar *regs; drm_local_map_t *sarea; drm_i915_sarea_t *sarea_priv; drm_i915_ring_buffer_t ring; - drm_dma_handle_t *status_page_dmah; void *hw_status_page; dma_addr_t dma_status_page; diff --git a/sys/dev/pci/drm/mach64_drv.c b/sys/dev/pci/drm/mach64_drv.c index 0a4467f48bc..ef10d6545d3 100644 --- a/sys/dev/pci/drm/mach64_drv.c +++ b/sys/dev/pci/drm/mach64_drv.c @@ -67,7 +67,7 @@ static drm_pci_id_list_t mach64_pciidlist[] = { {0, 0, 0} }; -static const struct drm_driver_info mach64_driver = { +static const struct drm_driver_info machdrm_driver = { .buf_priv_size = 1, /* No dev_priv */ .ioctl = machdrm_ioctl, .lastclose = mach64_driver_lastclose, @@ -94,41 +94,34 @@ static const struct drm_driver_info mach64_driver = { int machdrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, mach64_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, mach64_pciidlist); } void machdrm_attach(struct device *parent, struct device *self, void *aux) { - struct pci_attach_args *pa = aux; - struct drm_device *dev = (struct drm_device *)self; - drm_mach64_private_t *dev_priv; + drm_mach64_private_t *dev_priv = (drm_mach64_private_t *)self; + struct pci_attach_args *pa = aux; - dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); - if (dev_priv == NULL) - return; - dev->dev_private = (void *)dev_priv; - - dev->driver = &mach64_driver; - - return drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&machdrm_driver, pa, parent, self); } int machdrm_detach(struct device *self, int flags) { - struct drm_device *dev = (struct drm_device *)self; - drm_mach64_private_t *dev_priv = dev->dev_private; + drm_mach64_private_t *dev_priv = (drm_mach64_private_t *)self; - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = NULL; + if (dev_priv->drmdev != NULL) { + config_detach(dev_priv->drmdev, flags); + dev_priv->drmdev = NULL; + } - return (drm_detach(self, flags)); + return (0); } struct cfattach machdrm_ca = { - sizeof(struct drm_device), machdrm_probe, machdrm_attach, - machdrm_detach, drm_activate + sizeof(drm_mach64_private_t), machdrm_probe, machdrm_attach, + machdrm_detach }; struct cfdriver machdrm_cd = { diff --git a/sys/dev/pci/drm/mach64_drv.h b/sys/dev/pci/drm/mach64_drv.h index 53f3a607f2f..65ae81ffe17 100644 --- a/sys/dev/pci/drm/mach64_drv.h +++ b/sys/dev/pci/drm/mach64_drv.h @@ -73,6 +73,9 @@ typedef struct drm_mach64_descriptor_ring { } drm_mach64_descriptor_ring_t; typedef struct drm_mach64_private { + struct device dev; + struct device *drmdev; + drm_mach64_sarea_t *sarea_priv; int is_pci; diff --git a/sys/dev/pci/drm/mga_drv.c b/sys/dev/pci/drm/mga_drv.c index ec4c9ce66a9..188c5961804 100644 --- a/sys/dev/pci/drm/mga_drv.c +++ b/sys/dev/pci/drm/mga_drv.c @@ -131,51 +131,51 @@ static const struct drm_driver_info mga_driver = { int mgadrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, mgadrm_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, mgadrm_pciidlist); } void mgadrm_attach(struct device *parent, struct device *self, void *aux) { + drm_mga_private_t *dev_priv = (drm_mga_private_t *)self; struct pci_attach_args *pa = aux; - struct drm_device *dev = (struct drm_device *)self; - drm_mga_private_t *dev_priv; + struct vga_pci_bar *bar; drm_pci_id_list_t *id_entry; - dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); - if (!dev_priv) - return; - - dev->dev_private = (void *)dev_priv; - dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT; id_entry = drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), mgadrm_pciidlist); dev_priv->chipset = id_entry->driver_private; - dev_priv->mmio_base = drm_get_resource_start(dev, 1); - dev_priv->mmio_size = drm_get_resource_len(dev, 1); + bar = vga_pci_bar_info((struct vga_pci_softc *)parent, 1); + if (bar == NULL) { + printf(": couldn't get BAR info\n"); + return; + } + + dev_priv->mmio_base = bar->base; + dev_priv->mmio_size = bar->maxsize; - dev->driver = &mga_driver; - return drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&mga_driver, pa, parent, self); } int mgadrm_detach(struct device *self, int flags) { - struct drm_device *dev = (struct drm_device *)self; - drm_mga_private_t *dev_priv = dev->dev_private; + drm_mga_private_t *dev_priv = (drm_mga_private_t *)self; - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = NULL; + if (dev_priv->drmdev != NULL) { + config_detach(dev_priv->drmdev, flags); + dev_priv->drmdev = NULL; + } - return (drm_detach(self, flags)); + return (0); } struct cfattach mgadrm_ca = { - sizeof(struct drm_device), mgadrm_probe, mgadrm_attach, - mgadrm_detach, drm_activate + sizeof(drm_mga_private_t), mgadrm_probe, mgadrm_attach, + mgadrm_detach }; struct cfdriver mgadrm_cd = { diff --git a/sys/dev/pci/drm/mga_drv.h b/sys/dev/pci/drm/mga_drv.h index 59f770c28e8..e2cb57e92fe 100644 --- a/sys/dev/pci/drm/mga_drv.h +++ b/sys/dev/pci/drm/mga_drv.h @@ -75,6 +75,9 @@ typedef struct { } drm_mga_buf_priv_t; typedef struct drm_mga_private { + struct device dev; + struct device *drmdev; + drm_mga_primary_buffer_t prim; drm_mga_sarea_t *sarea_priv; diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c index aa0911303a8..35dd1ba0828 100644 --- a/sys/dev/pci/drm/r128_drv.c +++ b/sys/dev/pci/drm/r128_drv.c @@ -110,41 +110,34 @@ static const struct drm_driver_info ragedrm_driver = { int ragedrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, ragedrm_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, ragedrm_pciidlist); } void ragedrm_attach(struct device *parent, struct device *self, void *aux) { - struct pci_attach_args *pa = aux; - struct drm_device *dev = (struct drm_device *)self; - drm_r128_private_t *dev_priv; + drm_r128_private_t *dev_priv = (drm_r128_private_t *)self; + struct pci_attach_args *pa = aux; - dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); - if (dev_priv == NULL) - return; - dev->dev_private = (void *)dev_priv; - - dev->driver = &ragedrm_driver; - return drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&ragedrm_driver, pa, parent, self); } int ragedrm_detach(struct device *self, int flags) { - struct drm_device *dev = (struct drm_device *)self; - drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_private_t *dev_priv = (drm_r128_private_t *)self; - drm_free(dev_priv, sizeof(*dev_priv), - DRM_MEM_DRIVER); - dev->dev_private = NULL; + if (dev_priv->drmdev != NULL) { + config_detach(dev_priv->drmdev, flags); + dev_priv->drmdev = NULL; + } - return (drm_detach(self, flags)); + return (0); } struct cfattach ragedrm_ca = { - sizeof(struct drm_device), ragedrm_probe, ragedrm_attach, - ragedrm_detach, drm_activate + sizeof(drm_r128_private_t), ragedrm_probe, ragedrm_attach, + ragedrm_detach }; struct cfdriver ragedrm_cd = { diff --git a/sys/dev/pci/drm/r128_drv.h b/sys/dev/pci/drm/r128_drv.h index 96f71d4aec4..2c2c2e6a3e8 100644 --- a/sys/dev/pci/drm/r128_drv.h +++ b/sys/dev/pci/drm/r128_drv.h @@ -76,6 +76,9 @@ typedef struct drm_r128_ring_buffer { } drm_r128_ring_buffer_t; typedef struct drm_r128_private { + struct device dev; + struct device *drmdev; + drm_r128_ring_buffer_t ring; drm_r128_sarea_t *sarea_priv; diff --git a/sys/dev/pci/drm/r128_state.c b/sys/dev/pci/drm/r128_state.c index 47657c6f79c..a79f44ae467 100644 --- a/sys/dev/pci/drm/r128_state.c +++ b/sys/dev/pci/drm/r128_state.c @@ -336,7 +336,8 @@ static void r128_cce_performance_boxes(drm_r128_private_t * dev_priv) * CCE command dispatch functions */ -static void r128_print_dirty(const char *msg, unsigned int flags) +static void r128_print_dirty(drm_r128_private_t *dev_priv, const char *msg, + unsigned int flags) { DRM_INFO("%s: (0x%x) %s%s%s%s%s%s%s%s%s\n", msg, @@ -580,7 +581,8 @@ static void r128_cce_dispatch_vertex(struct drm_device * dev, struct drm_buf * b DRM_DEBUG("buf=%d nbox=%d\n", buf->idx, sarea_priv->nbox); if (0) - r128_print_dirty("dispatch_vertex", sarea_priv->dirty); + r128_print_dirty(dev_priv, "dispatch_vertex", + sarea_priv->dirty); if (buf->used) { buf_priv->dispatched = 1; @@ -708,7 +710,8 @@ static void r128_cce_dispatch_indices(struct drm_device * dev, DRM_DEBUG("indices: s=%d e=%d c=%d\n", start, end, count); if (0) - r128_print_dirty("dispatch_indices", sarea_priv->dirty); + r128_print_dirty(dev_priv, "dispatch_indices", + sarea_priv->dirty); if (start != end) { buf_priv->dispatched = 1; diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c index eea48415803..5444317555a 100644 --- a/sys/dev/pci/drm/radeon_drv.c +++ b/sys/dev/pci/drm/radeon_drv.c @@ -507,23 +507,16 @@ static const struct drm_driver_info radeondrm_driver = { int radeondrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, radeondrm_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, radeondrm_pciidlist); } void radeondrm_attach(struct device *parent, struct device *self, void *aux) { + drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)self; struct pci_attach_args *pa = aux; - struct drm_device *dev = (struct drm_device *)self; - drm_radeon_private_t *dev_priv; drm_pci_id_list_t *id_entry; - dev_priv = drm_calloc(1, sizeof(drm_radeon_private_t), DRM_MEM_DRIVER); - if (dev_priv == NULL) - return; - - dev->dev_private = (void *)dev_priv; - id_entry = drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), radeondrm_pciidlist); dev_priv->flags = id_entry->driver_private; @@ -561,26 +554,27 @@ radeondrm_attach(struct device *parent, struct device *self, void *aux) ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI")))); - dev->driver = &radeondrm_driver; - return drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&radeondrm_driver, pa, parent, self); } int radeondrm_detach(struct device *self, int flags) { - struct drm_device *dev = (struct drm_device *)self; - drm_radeon_private_t *dev_priv = dev->dev_private; + drm_radeon_private_t *dev_priv = (drm_radeon_private_t *)self; DRM_DEBUG("\n"); - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = NULL; - return (drm_detach(self, flags)); + if (dev_priv->drmdev != NULL) { + config_detach(dev_priv->drmdev, flags); + dev_priv->drmdev = NULL; + } + + return (0); } struct cfattach radeondrm_ca = { - sizeof (struct drm_device), radeondrm_probe, radeondrm_attach, - radeondrm_detach, drm_activate + sizeof (drm_radeon_private_t), radeondrm_probe, radeondrm_attach, + radeondrm_detach }; struct cfdriver radeondrm_cd = { diff --git a/sys/dev/pci/drm/radeon_drv.h b/sys/dev/pci/drm/radeon_drv.h index 4fffaac7f49..47376719aff 100644 --- a/sys/dev/pci/drm/radeon_drv.h +++ b/sys/dev/pci/drm/radeon_drv.h @@ -221,6 +221,8 @@ struct radeon_virt_surface { #define RADEON_PURGE_EMITED (1 < 1) typedef struct drm_radeon_private { + struct device dev; + struct device *drmdev; drm_radeon_ring_buffer_t ring; drm_radeon_sarea_t *sarea_priv; diff --git a/sys/dev/pci/drm/savage_drv.c b/sys/dev/pci/drm/savage_drv.c index e26e8eebd8e..72d75ba5c6f 100644 --- a/sys/dev/pci/drm/savage_drv.c +++ b/sys/dev/pci/drm/savage_drv.c @@ -84,46 +84,39 @@ static const struct drm_driver_info savagedrm_driver = { int savagedrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, savagedrm_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, savagedrm_pciidlist); } void savagedrm_attach(struct device *parent, struct device *self, void *aux) { + drm_savage_private_t *dev_priv = (drm_savage_private_t *)self; struct pci_attach_args *pa = aux; - struct drm_device *dev = (struct drm_device *)self; drm_pci_id_list_t *id_entry; - drm_savage_private_t *dev_priv; - - dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); - if (dev_priv == NULL) - return; - - dev->dev_private = (void *)dev_priv; id_entry = drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), savagedrm_pciidlist); dev_priv->chipset = (enum savage_family)id_entry->driver_private; - dev->driver = &savagedrm_driver; - return drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&savagedrm_driver, pa, parent, self); } int savagedrm_detach(struct device *self, int flags) { - struct drm_device *dev = (struct drm_device *)self; - drm_savage_private_t *dev_priv = dev->dev_private; + drm_savage_private_t *dev_priv = (drm_savage_private_t *)self; - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = NULL; + if (dev_priv->drmdev != NULL) { + config_detach(dev_priv->drmdev, flags); + dev_priv->drmdev = NULL; + } - return (drm_detach(self, flags)); + return (0); } struct cfattach savagedrm_ca = { - sizeof(struct drm_device), savagedrm_probe, savagedrm_attach, - savagedrm_detach, drm_activate + sizeof(drm_savage_private_t), savagedrm_probe, savagedrm_attach, + savagedrm_detach }; struct cfdriver savagedrm_cd = { diff --git a/sys/dev/pci/drm/savage_drv.h b/sys/dev/pci/drm/savage_drv.h index 574ce2231cb..045575f1901 100644 --- a/sys/dev/pci/drm/savage_drv.h +++ b/sys/dev/pci/drm/savage_drv.h @@ -122,6 +122,9 @@ enum savage_family { #define SAVAGE_IS_AGP 1 typedef struct drm_savage_private { + struct device dev; + struct device *drmdev; + drm_savage_sarea_t *sarea_priv; drm_savage_buf_priv_t head, tail; diff --git a/sys/dev/pci/drm/sis_drv.c b/sys/dev/pci/drm/sis_drv.c index f847a80ef19..91d8c2fda9b 100644 --- a/sys/dev/pci/drm/sis_drv.c +++ b/sys/dev/pci/drm/sis_drv.c @@ -65,38 +65,34 @@ static const struct drm_driver_info sis_driver = { int sisdrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, sis_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, sis_pciidlist); } void sisdrm_attach(struct device *parent, struct device *self, void *aux) { - struct pci_attach_args *pa = aux; - struct drm_device *dev = (struct drm_device *)self; - drm_sis_private_t *dev_priv = dev->dev_private; + drm_sis_private_t *dev_priv = (drm_sis_private_t *)self; + struct pci_attach_args *pa = aux; - dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = dev_priv; - - dev->driver = &sis_driver; - return drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&sis_driver, pa, parent, self); } int sisdrm_detach(struct device *self, int flags) { - struct drm_device *dev = (struct drm_device *)self; - drm_sis_private_t *dev_priv = dev->dev_private; + drm_sis_private_t *dev_priv = (drm_sis_private_t *)self; - drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); - dev->dev_private = NULL; + if (dev_priv->drmdev != NULL) { + config_detach(dev_priv->drmdev, flags); + dev_priv->drmdev = NULL; + } - return (drm_detach(self, flags)); + return (0); } struct cfattach sisdrm_ca = { - sizeof(struct drm_device), sisdrm_probe, sisdrm_attach, - sisdrm_detach, drm_activate + sizeof(drm_sis_private_t), sisdrm_probe, sisdrm_attach, + sisdrm_detach }; struct cfdriver sisdrm_cd = { diff --git a/sys/dev/pci/drm/sis_drv.h b/sys/dev/pci/drm/sis_drv.h index f1fe9c7cf94..7b6b16a9dba 100644 --- a/sys/dev/pci/drm/sis_drv.h +++ b/sys/dev/pci/drm/sis_drv.h @@ -75,8 +75,11 @@ extern void sis_lastclose(struct drm_device *dev); #include "sis_ds.h" typedef struct drm_sis_private { - memHeap_t *AGPHeap; - memHeap_t *FBHeap; + struct device dev; + struct device *drmdev; + + memHeap_t *AGPHeap; + memHeap_t *FBHeap; } drm_sis_private_t; extern int sis_init_context(struct drm_device * dev, int context); diff --git a/sys/dev/pci/drm/tdfx_drv.c b/sys/dev/pci/drm/tdfx_drv.c index 660eac5ac42..708639f989a 100644 --- a/sys/dev/pci/drm/tdfx_drv.c +++ b/sys/dev/pci/drm/tdfx_drv.c @@ -35,6 +35,11 @@ #include "tdfx_drv.h" #include "drmP.h" +struct tdfxdrm_softc { + struct device dev; + struct device *drmdev; +}; + int tdfxdrm_probe(struct device *, void *, void *); void tdfxdrm_attach(struct device *, struct device *, void *); @@ -64,22 +69,20 @@ static const struct drm_driver_info tdfxdrm_driver = { int tdfxdrm_probe(struct device *parent, void *match, void *aux) { - return drm_probe((struct pci_attach_args *)aux, tdfxdrm_pciidlist); + return drm_pciprobe((struct pci_attach_args *)aux, tdfxdrm_pciidlist); } void tdfxdrm_attach(struct device *parent, struct device *self, void *aux) { - struct pci_attach_args *pa = aux; - struct drm_device *dev = (struct drm_device *)self; + struct tdfxdrm_softc *dev_priv = (struct tdfxdrm_softc *)self; + struct pci_attach_args *pa = aux; - dev->driver = &tdfxdrm_driver; - return drm_attach(parent, self, pa); + dev_priv->drmdev = drm_attach_mi(&tdfxdrm_driver, pa, parent, self); } struct cfattach tdfxdrm_ca = { - sizeof(struct drm_device), tdfxdrm_probe, tdfxdrm_attach, - drm_detach, drm_activate + sizeof(struct tdfxdrm_softc), tdfxdrm_probe, tdfxdrm_attach, }; struct cfdriver tdfxdrm_cd = { diff --git a/sys/dev/pci/vga_pci.c b/sys/dev/pci/vga_pci.c index bcd4d6b8b8c..5defbbda363 100644 --- a/sys/dev/pci/vga_pci.c +++ b/sys/dev/pci/vga_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vga_pci.c,v 1.38 2008/11/09 15:11:19 oga Exp $ */ +/* $OpenBSD: vga_pci.c,v 1.39 2008/11/22 21:26:48 oga Exp $ */ /* $NetBSD: vga_pci.c,v 1.3 1998/06/08 06:55:58 thorpej Exp $ */ /* @@ -96,7 +96,7 @@ #endif #include "intagp.h" -#include "drmbase.h" +#include "drm.h" int vga_pci_match(struct device *, void *, void *); void vga_pci_attach(struct device *, struct device *, void *); @@ -107,7 +107,7 @@ void vga_pci_bar_init(struct vga_pci_softc *, struct pci_attach_args *); int intagpsubmatch(struct device *, void *, void *); int intagp_print(void *, const char *); #endif -#if NDRMBASE > 0 +#if NDRM > 0 int drmsubmatch(struct device *, void *, void *); int vga_drm_print(void *, const char *); #endif @@ -188,7 +188,7 @@ vga_pci_attach(struct device *parent, struct device *self, void *aux) } #endif -#if NDRMBASE > 0 +#if NDRM > 0 config_found_sm(self, aux, NULL, drmsubmatch); #endif } @@ -215,7 +215,7 @@ intagp_print(void *vaa, const char *pnp) } #endif -#if NDRMBASE > 0 +#if NDRM > 0 int drmsubmatch(struct device *parent, void *match, void *aux) { |