Commit Graph

197 Commits (e9732865b7c05f2930a0c8b1751aad7929a2f3a7)

Author SHA1 Message Date
Eric Anholt 080a547d4d - Implement drm_initmap, and extend it with the resource number to help
FreeBSD. Add drm_get_resource_{start|len} so linux-specific stuff
    doesn't need to be in shared code.
- Fix mach64 build by using __DECONST to work around passing a const
    pointer to useracc, which is unfortunately not marked const.
- Get rid of a lot of maplist code by not having dev->maplist be a pointer,
    and by sticking the link entries directly in drm_local_map_t rather
    than having a separate structure for the linked list.
- Factor out map uninit and removal into its own routine, rather than
    duplicating in both drm_takedown() and drm_rmmap().
- Hook up more driver functions, and correct FreeBSD-specific bits of
    radeon_cp.c, making radeon work.
- Baby steps towards using bus_space as we should.
2005-02-05 08:00:14 +00:00
Eric Anholt 7d0cb01cbf Add detection of whether the device is AGP by walking the capabilities
list.
2005-01-17 20:24:52 +00:00
Eric Anholt 3e65f52bda Use SYSCTL_ADD_OID macro instead of calling function directly.
Submitted by: reffie@FreeBSD.org
2004-12-15 03:34:09 +00:00
Eric Anholt a1d9e5abaf Refine the locking of the DRM. Most significant is covering the driver
ioctls with dev_lock, which is a major step toward being able to remove
    Giant. Covers some new pieces (dev->unique*) in the core, and avoids
    one call down into system internals with the drm lock held, which is
    usually bad (FreeBSD LOR #23, #27).
2004-11-07 04:11:15 +00:00
Eric Anholt 67f6c5e36a Don't link in files which no longer exist. 2004-11-07 00:30:15 +00:00
Eric Anholt fa3fdbd99c Now that the memory debug code is gone, and all 3 BSDs have M_ZERO, stop
using drm_alloc/drm_free in the core and instead use plain malloc/free.
2004-11-07 00:25:49 +00:00
Eric Anholt d37457b599 Add the drm Makefile and update .cvsignores. 2004-11-06 23:05:46 +00:00
Eric Anholt cb5aaa8987 Convert more drivers for bsd-core, moving the ioctl definitions to shared
code. Remove the "drv" from sisdrv, as it's unnecessary. Use the
    drm_pci functions in i915 instead of per-os implementations of the
    same. Avoid whitespace within fields in drm_pciids.txt (one of the r300
    definitions), since it breaks the bsd pciids script. Tested on sis,
    mga, r128. i915 needs more work.
2004-11-06 23:02:07 +00:00
Eric Anholt 7ddbd38dde Remove some core stuff that ended up being unnecessary. 2004-11-06 21:44:54 +00:00
Eric Anholt 7bdccfd0bb Get r128 basically working: Hook up the driver's dma ioctl, use the proper
offset into the driver ioctl array, and don't make the ctx bitmap
    conditional.
2004-11-06 21:18:49 +00:00
Eric Anholt ae7a171313 Move the lock/unlock ioctls to a more logical place, in drm_lock.c. 2004-11-06 20:27:19 +00:00
Eric Anholt cca29ac9be Connect up r128_ioctls in driver config. 2004-11-06 20:21:55 +00:00
Eric Anholt b2f275b46e Hook the debug output up to a sysctl, so you can choose to enable at
runtime.
2004-11-06 11:50:08 +00:00
Eric Anholt 7adee84064 Add file missed in last commit: Commit first pieces of port to OpenBSD,
done by Martin Lexa (martin at martinlexa dot cz). Now that we've got
    porting for all three major BSDs (and the fourth being very similar to
    FreeBSD), move the mostly-duplication drm_os_* files into drmP.h.
    Remove some cruft from linux heritage and from pieces of the DRM that
    have since been removed.
Note that things are still not quite working for even FreeBSD, but these
    are first steps at cleanup, and just a WIP checkpoint.
2004-11-06 11:19:38 +00:00
Eric Anholt d7510ea413 Commit first pieces of port to OpenBSD, done by Martin Lexa (martin at
martinlexa dot cz). Now that we've got porting for all three major BSDs
    (and the fourth being very similar to FreeBSD), move the
    mostly-duplication drm_os_* files into drmP.h. Remove some cruft from
    linux heritage and from pieces of the DRM that have since been removed.
Note that things are still not quite working for even FreeBSD, but these
    are first steps at cleanup, and just a WIP checkpoint.
2004-11-06 11:16:26 +00:00
Eric Anholt cf259f10aa Remove the vestiges of the memory-debug code. 2004-11-06 02:00:04 +00:00
Eric Anholt c9202c8965 Commit WIP of BSD conversion to core model. Compiles for r128, radeon, but
doesn't run yet. Moves the ioctl definitions for these two drivers back
    to the shared code -- they aren't OS-specific.
2004-11-06 01:41:47 +00:00
Erdi Chen 25e319c1ef This patch adds three new ioctl's to the VIA Unichrome/Pro DRM driver:
DRM_IOCTL_VIA_DMA_INIT DRM_IOCTL_VIA_CMDBUFFER DRM_IOCTL_VIA_FLUSH
The first ioctl sets up an area in AGP memory that will be used as the ring
    buffer. The second ioctl copies a command buffer from user space memory
    to the ring buffer. The third ioctl waits for engine idle until it
    returns.
The motivation for this patch is to avoid the wait for engine idle call
    before each buffer flush in the current DRI driver. With this patch,
    the DRI driver can continue to flush its buffer as long as there is
    free space in the ring buffer.
This patch adds an additional copy operation on the command buffer. This
    buffer copying is necessary to support multiple DRI clients rendering
    simultaneously. Otherwise, more CPU time will be spent in the busy loop
    waiting for engine idle between DRI context switch. Even in the single
    client case, the tradeoff is reasonable in comparision to the kernel
    call to check for free buffer space for the client to render directly
    to the ring buffer.
2004-08-24 01:44:37 +00:00
Dave Airlie 5c9ed83094 Merged drmfntbl-0-0-1 2004-08-17 13:10:05 +00:00
Eric Anholt 740ddb9c5d Remove unused pcigart/sg header stuff from i915 driver. 2004-08-14 00:56:34 +00:00
Eric Anholt dd83f39f03 Add a "dev" argument to DRIVER_CTX_[CD]TOR. This will be used in an
upcoming commit for the SiS driver.
2004-08-14 00:46:15 +00:00
Eric Anholt 2376ec4ef8 Hopefully proper fix for corrupted driver name in memcontrol list.
Reported by: Jung-uk Kim <jkim@niksun.com>
2004-08-14 00:03:32 +00:00
Eric Anholt d78db7c930 Enable MTRR usage on AMD64, and use DELAY() instead of rolling our own
udelay code.
Submitted by: Jung-uk Kim <jkim@niksun.com>
2004-08-13 23:17:17 +00:00
Dave Airlie 6c9715eaf5 bring over fix from i865-agp branch, it now probes the driver, X hangs
box..
2004-08-03 11:26:38 +00:00
Dave Airlie 1cec18a5cd add read/write 16 2004-07-29 13:00:48 +00:00
Dave Airlie b1cf4ca7e5 change to agp not pci ... still not working 2004-07-29 12:49:54 +00:00
Dave Airlie 0b02bf9d45 initial port of i915 to BSD, not finished doesn't work.. no idea why... 2004-07-29 11:09:22 +00:00
Eric Anholt eaccc05b26 Fix module loading on alpha by not referencing MTRR symbols on
!__REALLY_HAVE_MTRR.
2004-07-06 00:25:19 +00:00
Eric Anholt 694291fbd3 MFC as of 20040705: dev_t -> struct cdev * change. 2004-07-06 00:23:42 +00:00
Eric Anholt 853adb8be3 Merge from FreeBSD-current. Mostly 64-bit cleanliness fixes, but a few
driver interface changes from -current.
2004-05-11 04:43:43 +00:00
Eric Anholt c47b611b08 Add mach64 DRM module for BSD (untested, but compiles). 2004-05-09 22:36:19 +00:00
Eric Anholt dfdf8e14d3 Add .cvsignore files. 2004-05-09 22:29:55 +00:00
Eric Anholt 51ed2f5937 Warning fixes. 2004-05-09 22:16:11 +00:00
Eric Anholt d477cc007c - Link in shared files as necessary and clean them up.
- Generate drm_pciids.h automatically.
2004-05-09 22:14:07 +00:00
Eric Anholt c093a03d47 Catch up with sis's DRM tag change. 2004-05-09 22:07:58 +00:00
Eric Anholt 29f2b1c1cf drm_hw_lock_t is now defined in drm.h, remove from here. 2004-05-09 21:56:19 +00:00
Dave Airlie a2f7a9fa5f Commit sysfs and drm PCI changes for 2.6 kernel 2004-05-09 06:45:17 +00:00
Dave Airlie 93bd67ef62 centralise pci ids into one place and use scripts to generate files for
kernel
2004-04-21 12:13:31 +00:00
Eric Anholt fb7b802dda Fix some misuse of NULL where 0 is intended.
Obtained from: FreeBSD CVS
2004-01-06 04:54:25 +00:00
Eric Anholt 9fb6986e83 Don't ioremap the framebuffer area. The ioremapped area wasn't used by
anything, and took up valuable KVA. While I'm in the area, clean up BSD
    MTRR stuff some more.
Suggested by: jonsmirl
2003-12-16 08:57:08 +00:00
Eric Anholt 6e56c39371 Fix a locking nit, and add asserts in some things that should be called
with locks held.
2003-11-12 20:30:51 +00:00
Eric Anholt 1f7598245a Return EBUSY when attempting to addmap a DRM_SHM area with a lock in it if
dev->lock.hw_lock is already set. This fixes the case of two X Servers
    running on the same head on different VTs with interface 1.1, by making
    the 2nd head fail to inizialize like before.
2003-11-06 04:48:06 +00:00
Eric Anholt 2c1172a317 Remove unused variable. 2003-11-06 04:35:08 +00:00
Eric Anholt 66c9e3053f - Tie the DRM to a specific device: setunique no longer succeeds when given
a busid that doesn't correspond to the device the DRM is attached to.
    This is a breaking of backwards-compatibility only for the
    multiple-DRI-head case with X Servers that don't use interface 1.1.
- Move irq_busid to drm_irq.h and make it only return the IRQ for the
    current device. Retains compatibility with previous X Servers, cleans
    up unnecessary code. This means no irq_busid on !__HAVE_IRQ, but can be
    changed if necessary.
- Bump interface version to 1.2. This version when set signifies that the
    control ioctl should ignore the irq number passed in and enable the
    interrupt handler for the attached device. Otherwise it errors out when
    the passed-in irq is not equal to the device's.
- Store the highest version the interface has been set to in the device.
- Fix a recursion on DRM_LOCK in irq_uninstall on FreeBSD. This leaves
    irq_uninstall being done without the lock in some cases, but it was
    racey anyways.
2003-11-05 08:13:52 +00:00
Eric Anholt 8feb046d8c Args for the BSD DRM_PUT_USER_UNCHECKED were swapped. 2003-11-05 02:41:50 +00:00
Eric Anholt e5cad7fced Remove buf_alloc which is unused since the locking commit. 2003-11-05 00:49:35 +00:00
Michel Daenzer 2655ccddf4 Memory layout transition:
the 2D driver initializes MC_FB_LOCATION and related registers sanely
the DRM deduces the layout from these registers
clients use the new SETPARAM ioctl to tell the DRM where they think the
    framebuffer is located in the card's address space
the DRM uses all this information to check client state and fix it up if
    necessary
This is a prerequisite for things like direct rendering with IGP chips and
    video capturing.
2003-11-04 00:46:05 +00:00
Eric Anholt 3f7279cb8e Add a DRM_PUT_USER_UNCHECKED, which will be used by an upcoming radeon
change.
2003-10-27 22:05:38 +00:00
Eric Anholt 2423fedcc8 Don't try to use dev->dma_lock unless dma is initialized (dev->dma != NULL)
in bufs_info sysctl handler. dev->dma and dev->dma_lock existence are
    protected by DRM_LOCK(). Fixes panic on sysctl hw.dri when the device
    is uninitialied (when you aren't in X).
2003-10-24 21:49:28 +00:00
Eric Anholt 451a1d3f69 Move the REALLY_HAVE_AGP endif above the mtrr functions. Broke tdfx module. 2003-10-24 00:59:31 +00:00
Eric Anholt 06cb132e86 - Introduce a new ioctl, DRM_IOCTL_SET_VERSION. This ioctl allows the
server or client to notify the DRM that it expects a certain version of
    the device dependent or device independent interface. If the major
    doesn't match or minor is too large, EINVAL is returned. A major of -1
    means that the requestor doesn't care about that portion of the
    interface. The ioctl returns the actual versions in the same struct.
- Introduce DRM DI interface version 1.1. If the server requests version
    1.1, then the DRM sets the unique itself according to the busid of the
    device it probed, which may then be accessed as normal using getunique.
- Request version 1.1 in libdrm's drmOpenByBusID, allowing the X Server to
    request based on a BusID. Introduce a wrapper for DRM_IOCTL_SET_VERSION
    and bump libdrm minor version.
- Pass the busid in DRIScreenInit if libdrm can handle both a busid and
    name. This allows drmOpenByBusID to be used to find the DRM instead of
    just the driver name, which allows us in the future to tie a DRM more
    strongly to the device it probed to. Introduce a function
    DRICreatePCIBusID which creates a busid in the form pci:oooo:bb:dd.f
    similar to linux's pci_name() function. This matches the format used by
    the DRM in version 1.1. libdrm knows how to match both this format and
    the old PCI🅱️d:f format.
- Use the new DRICreatePCIBusID function in the *_dri.c to request the new,
    more exact busid format.
2003-10-23 02:23:31 +00:00
Eric Anholt 86e6325e5a - Add DRM_GET_PRIV_WITH_RETURN macro. This can be used in shared code to
get the drm_file_t * based on the filp passed in ioctl handlers.
- Use this macro on BSD for simplification and improve its error reporting.
    Make failure to find the drm_file_t * print as an error, not debug.
    This failure may be part of the problem with KDE.
- Make debug and error print macros include the pid on BSD.
2003-10-22 22:08:53 +00:00
Eric Anholt 4e6ddcbb69 Fix warning about static DRM(bufs_info) defined but not used in the
!__HAVE_DMA case.
2003-10-22 21:50:09 +00:00
Eric Anholt ea7b4fdc22 Fix the possibility of sleeping with locks held in sysctls by copying the
data into temporary variables with the lock held then outputting to
    sysctls with the lock released. Rearranged a little extra code to aid
    this. Note that drm_memory_debug.h hasn't had this fix applied, but I
    consider that code to be just about dead anyway.
2003-10-20 05:09:21 +00:00
Eric Anholt 6b0424fdcd Clean up BSD MTRR handling. The NetBSD code is untested, but it's my best
shot.
2003-10-20 00:55:56 +00:00
Eric Anholt 0cf1887139 - SMPng lock the DRM. This is only partial -- there are a few code paths
used by root (the X Server) which are not locked. However, it should
    deal with lost-IRQ issues on -current which I think people have been
    experiencing but I am unable to reproduce (though I understand why they
    would occur, because of a bug of mine). Note that most of the locking
    (DRM_LOCK()/UNLOCK()) is all covered by Giant still, so it doesn't
    matter yet.
- Remove locking on FreeBSD-stable and NetBSD. These are covered by the
    fact that there is no reentrancy of the kernel except by interrupts,
    which are locked using spldrm()/splx() instead.
2003-10-19 23:35:58 +00:00
Eric Anholt 59fbe01fea Clean up extra zeroing of dev->dma, and use calloc to take advantage of
M_ZERO.
2003-10-19 22:29:08 +00:00
Eric Anholt 2950f9e682 - Move IRQ functions from drm_dma.h to new drm_irq.h and disentangle them
from __HAVE_DMA. This will be useful for adding vblank sync support to
    sis and tdfx. Rename dma_service to irq_handler, which is more
    accurately what it is.
- Fix the #if _HAVE_DMA_IRQ in radeon, r128, mga, i810, i830, gamma to have
    the right number of underscores. This may have been a problem in the
    case that the server died without doing its DRM_IOCTL_CONTROL to
    uninit.
2003-10-17 05:13:48 +00:00
Eric Anholt ff58476011 - Converted Linux drivers to initialize DRM instances based on PCI IDs, not
just a single instance. Moved the PCI ID lists from <card>_drv.c in BSD
    to <card>.h. The PCI ID lists include a driver private field, which may
    be used by drivers for chip family or other information. Based on work
    by jonsmirl.
- Make tdfx_drv.c and tdfx.h match other drivers.
- Fixed up linking of sis shared files.
Tested with Radeon and SiS on Linux and FreeBSD, including a Linux setup
    with
2 SiS cards in a machine, but only one head being used (with DRI)
2003-10-17 03:14:39 +00:00
Eric Anholt 9fbfb7ca6a Some code cleanups done while working on locking. Reduces always-true
tests, excessive indenation, convoluted handling of errors, or code
    duplication.
2003-10-03 08:08:10 +00:00
Eric Anholt 929536172c Stylistic preparation for SMPng locking work: DRM_LOCK/DRM_UNLOCK have side
effects, so make them look like functions (add parenthesis).
2003-10-03 07:02:51 +00:00
Eric Anholt e187d665e4 Add an MIT-style copyright, assigned to myself, to these files. I think
I've touched enough of the code here, and there was no previous
    copyright. Do some drive-by style fixes while I'm here.
2003-10-02 20:52:44 +00:00
Eric Anholt 89dd7be3dd Axe more old gamma DMA infrastructure. 2003-10-02 07:02:34 +00:00
Eric Anholt a6b84f73e1 Mostly whitespace cleanups and style(9) fixes focused on "if(" -> "if ("
Change some nearby memset()s to bzero()s or to calloc allocations to
    take advantage of M_ZERO). Reverse some error tests to reduce high
    levels of indentation. Move the sg_cleanup() call out of the maplist
    loop in DRM(takedown)-- I can't see any need for it to be inside.
2003-10-02 04:48:54 +00:00
Eric Anholt 4dee75ff58 Wrap sys/endian.h usage with __FreeBSD_version >= 480000.
Obtained from: i865-agp-0-1-branch
2003-10-02 04:12:34 +00:00
Eric Anholt 4a55e75e97 Allow the DRM to attach to a "drmsub" device. This will be provided by the
i810 AGP module, working around the limitation of one driver per
    device.
Obtained from: i865-0-1-branch
2003-10-02 04:07:03 +00:00
Eric Anholt 8fe6a0d6c9 MTRR issue with SMP and -stable seems to be resolved. Re-enable MTRRs on
4.x
2003-10-02 03:51:49 +00:00
Keith Whitwell 6fc41e25e5 Use spldrm/splx around tsleep() in DRM_WAIT_ON 2003-09-09 07:45:12 +00:00
Eric Anholt 6f563cd513 Fix for older -stable.
Obtained from: FreeBSD CVS
2003-09-07 23:27:04 +00:00
Eric Anholt f634f68759 These files were missed in the SiS DRM commit. 2003-08-29 20:54:26 +00:00
Eric Anholt fabc64dd57 Port the SiS DRM to FreeBSD. This includes the ability for the DRM to
allocate framebuffer memory without sisfb, and a new ioctl to be used
    by the X Server which tells the DRM what region of framebuffer memory
    to allocate from. Also fixes a possibility to panic the kernel I
    believe. Tested on linux with sisfb and FreeBSD (without sisfb) with
    new DRI only.
2003-08-29 19:24:36 +00:00
Eric Anholt a7aebb6dac Add DRM(calloc), which is convenient, used by the new sis code, and takes
advantage of M_ZERO on BSDs.
2003-08-29 19:16:13 +00:00
Eric Anholt db78129116 Update radeon PCI IDs. 2003-08-29 19:08:06 +00:00
Eric Anholt bd3bc9f23d This PCI header has been living in dev/pci/ for a while now. 2003-08-29 19:07:27 +00:00
Eric Anholt 963ad33cb6 Fix the debug build. 2003-08-19 02:22:57 +00:00
Eric Anholt ad78a613a4 - Remove $FreeBSD$ tags as they weren't too useful and merges are now being
done through perforce.
- Add copyright headers to drm_os_*bsd.h, still need to research the other
    copyright-less files better.
2003-08-19 00:41:00 +00:00
Eric Anholt 02675a470e Merge from FreeBSD r1.11: We have memset in the kernel, no need to define
it to bzero (which it was always used for).
2003-08-12 21:18:05 +00:00
Michel Daenzer 4b60cae90e IRQ code cleanup suggested by Linus Torvalds
i830 build fix
2003-07-29 10:11:48 +00:00
Eric Anholt 983db58a26 Fix FreeBSD build after IRQ changes. 2003-07-26 03:18:34 +00:00
Michel Daenzer bef7017749 Compile fixes for recent 2.5/2.6 Linux kernels. I hope this doesn't break
the i830 driver or the BSDs. :)
2003-07-25 10:50:39 +00:00
Michel Daenzer e5d3c7f260 Support AGP bridges where the AGP aperture can't be accessed directly by
the CPU (David Mosberger, Benjamin Herrenschmidt, myself, Paul
    Mackerras, Jeff Wiedemeier)
2003-05-16 23:41:27 +00:00
Eric Anholt 87ed795ff3 Fix a typo: On takedown the mtrr operation is MEMRANGE_SET_REMOVE, not
_UPDATE.
2003-04-28 23:18:43 +00:00
Eric Anholt 22b9b720d5 Use real endian conversion functions. 2003-04-27 00:43:14 +00:00
Eric Anholt 9828bd24c8 Fix formatting of hw.dri sysctl. 2003-04-26 23:55:30 +00:00
Eric Anholt 766a1da2e5 Remove the map argument from DRM_*MEMORYBARRIER. Not all of the uses of
DRM_*MEMORYBARRIER we had were related to an MMIO space. This means
    arch-specific code on the BSDs, unfortunately. Also add
    DRM_MEMORYBARRIER() and change the DRM_READMEMORYBARRIER()s that used
    to be read/write barriers to it.
2003-04-26 23:32:00 +00:00
Eric Anholt a172ee2a18 MFL: Don't install irq handler unless the driver has been initialized. 2003-04-26 23:04:22 +00:00
Eric Anholt ce514e08aa Add PCI DMA memory functions and make addbufs_pci and associated code use
it. To do this we need to save the bus address along with the virtual
    address in the seglist. Also fix some error handling and a few bits of
    whitespace.
2003-04-26 22:52:39 +00:00
Eric Anholt a79adaab72 Missed files in the last commit: Remove memory debugging sysctl unless
MEMORY_DEBUG is set.
2003-04-26 22:21:37 +00:00
Eric Anholt 8621ae310b Move the memory functions with debugging info to drm_memory_debug.h, and
remove a couple of dead functions.
2003-04-26 22:18:39 +00:00
Eric Anholt 79a0c5757e Remove #if 0'ed code. 2003-04-26 21:57:43 +00:00
Eric Anholt e60eb69bc0 Replace the C atomic_cmpset_int compatibility function for -stable with the
real i386 atomic_cmpset_int from -current. FreeBSD-stable won't ever
    have DRM support for non-i386.
2003-04-26 06:53:22 +00:00
Eric Anholt acb5d6b273 Disable MTRRs on FreeBSD-stable. Without this, it hangs on boot in the MTRR
setting for AGP cards on SMP machines.
2003-04-26 06:39:55 +00:00
Eric Anholt 77ee73f8cd Merge from FreeBSD-current. 2003-04-25 02:27:21 +00:00
Eric Anholt 58650c3a9d Clean up the DRM_COPY_TO_USER()ing of DRM(infobufs), making it more
legible.
2003-04-25 00:02:14 +00:00
Eric Anholt 781828b26e Clean up the style of the linux-compat code and use ioctl() directly rather
than reimplementing it.
2003-04-24 23:57:29 +00:00
Eric Anholt a147df879b Remove more gamma DMA infrastructure. Most of this code was copied straight
from linux, so it could be added back if some driver needed it in the
    future.
2003-04-24 19:09:55 +00:00
Eric Anholt 01178567eb Remove more gamma DMA code. This isn't all of it, but it's a major portion. 2003-04-24 06:19:54 +00:00
Eric Anholt c6d2af70cb Move some common code from addbufs_<type> to addbufs. Make buf_alloc be
protected by the count_lock and make it non-atomic.
2003-04-24 05:56:44 +00:00
Eric Anholt af3bfdef26 Remove the ioctl_count variable from the device. A reference is held to the
fp throughout the ioctl syscall, so the device can't be closed out from
    under us.
2003-04-24 05:14:05 +00:00
Eric Anholt bcd527ee71 Remove a bunch of dead code and fix spelling of a couple of comments. 2003-04-24 04:50:07 +00:00