summaryrefslogtreecommitdiff
path: root/bsd-core
AgeCommit message (Expand)Author
2005-04-26Convert NOMAN to the new preferred spelling NO_MAN to quiet warnings.Eric Anholt
2005-04-26Convert BSD code to mostly use bus_dma, the dma abstraction for dealingEric Anholt
2005-04-24Fix a panic on startup with non-initmapping drivers by assigning theEric Anholt
2005-04-16Use /*- to begin license blocks in BSD code to reduce diffs against FreeBSDEric Anholt
2005-04-13Fix build on FreeBSD-current, thanks to jhb@.Eric Anholt
2005-02-19Merge r1.26 from FreeBSD: Now that mem(4) is a kernel module, we need toEric Anholt
2005-02-14Use fuword32 for DRM_GET_USER_UNCHECKED when available. May help on 64-bitEric Anholt
2005-02-14Use the proper API to get PCI vendor/device number for a dev.Eric Anholt
2005-02-13Fix bad copy'n'pastage of copyrights -- don't disclaim anything for VAEric Anholt
2005-02-13Add the first bits necessary for a port of savage to FreeBSD. More toEric Anholt
2005-02-08Close a race which could allow for privilege escalation by users with DRIEric Anholt
2005-02-07Restore a debugging message to DRM_DEBUG instead of DRM_ERROR.Eric Anholt
2005-02-07Remove some annoying trailing whitespace.Eric Anholt
2005-02-05- Implement drm_initmap, and extend it with the resource number to helpEric Anholt
2005-01-17Add detection of whether the device is AGP by walking the capabilitiesEric Anholt
2004-12-15Use SYSCTL_ADD_OID macro instead of calling function directly.Eric Anholt
2004-11-07Refine the locking of the DRM. Most significant is covering the driverEric Anholt
2004-11-07Don't link in files which no longer exist.Eric Anholt
2004-11-07Now that the memory debug code is gone, and all 3 BSDs have M_ZERO, stopEric Anholt
2004-11-06Add the drm Makefile and update .cvsignores.Eric Anholt
2004-11-06Convert more drivers for bsd-core, moving the ioctl definitions to sharedEric Anholt
2004-11-06Remove some core stuff that ended up being unnecessary.Eric Anholt
2004-11-06Get r128 basically working: Hook up the driver's dma ioctl, use the properEric Anholt
2004-11-06Move the lock/unlock ioctls to a more logical place, in drm_lock.c.Eric Anholt
2004-11-06Connect up r128_ioctls in driver config.Eric Anholt
2004-11-06Hook the debug output up to a sysctl, so you can choose to enable atEric Anholt
2004-11-06Add file missed in last commit: Commit first pieces of port to OpenBSD,Eric Anholt
2004-11-06Commit first pieces of port to OpenBSD, done by Martin Lexa (martin atEric Anholt
2004-11-06Remove the vestiges of the memory-debug code.Eric Anholt
2004-11-06Commit WIP of BSD conversion to core model. Compiles for r128, radeon, butEric Anholt
2004-08-24This patch adds three new ioctl's to the VIA Unichrome/Pro DRM driver:Erdi Chen
2004-08-17Merged drmfntbl-0-0-1Dave Airlie
2004-08-14Remove unused pcigart/sg header stuff from i915 driver.Eric Anholt
2004-08-14Add a "dev" argument to DRIVER_CTX_[CD]TOR. This will be used in anEric Anholt
2004-08-14Hopefully proper fix for corrupted driver name in memcontrol list.Eric Anholt
2004-08-13Enable MTRR usage on AMD64, and use DELAY() instead of rolling our ownEric Anholt
2004-08-03bring over fix from i865-agp branch, it now probes the driver, X hangsDave Airlie
2004-07-29add read/write 16Dave Airlie
2004-07-29change to agp not pci ... still not workingDave Airlie
2004-07-29initial port of i915 to BSD, not finished doesn't work.. no idea why...Dave Airlie
2004-07-06Fix module loading on alpha by not referencing MTRR symbols onEric Anholt
2004-07-06MFC as of 20040705: dev_t -> struct cdev * change.Eric Anholt
2004-05-11Merge from FreeBSD-current. Mostly 64-bit cleanliness fixes, but a fewEric Anholt
2004-05-09Add mach64 DRM module for BSD (untested, but compiles).Eric Anholt
2004-05-09Add .cvsignore files.Eric Anholt
2004-05-09Warning fixes.Eric Anholt
2004-05-09- Link in shared files as necessary and clean them up.Eric Anholt
2004-05-09Catch up with sis's DRM tag change.Eric Anholt
2004-05-09drm_hw_lock_t is now defined in drm.h, remove from here.Eric Anholt
2004-05-09Commit sysfs and drm PCI changes for 2.6 kernelDave Airlie
copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Authors: * Inki Dae <inki.dae@samsung.com> */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <sys/mman.h> #include <linux/stddef.h> #include <xf86drm.h> #include "exynos_drm.h" #include "exynos_drmif.h" /* * Create exynos drm device object. * * @fd: file descriptor to exynos drm driver opened. * * if true, return the device object else NULL. */ struct exynos_device * exynos_device_create(int fd) { struct exynos_device *dev; dev = calloc(sizeof(*dev), 1); if (!dev) { fprintf(stderr, "failed to create device[%s].\n", strerror(errno)); return NULL; } dev->fd = fd; return dev; } /* * Destroy exynos drm device object * * @dev: exynos drm device object. */ void exynos_device_destroy(struct exynos_device *dev) { free(dev); } /* * Create a exynos buffer object to exynos drm device. * * @dev: exynos drm device object. * @size: user-desired size. * flags: user-desired memory type. * user can set one or more types among several types to memory * allocation and cache attribute types. and as default, * EXYNOS_BO_NONCONTIG and EXYNOS-BO_NONCACHABLE types would * be used. * * if true, return a exynos buffer object else NULL. */ struct exynos_bo * exynos_bo_create(struct exynos_device *dev, size_t size, uint32_t flags) { struct exynos_bo *bo; struct drm_exynos_gem_create req = { .size = size, .flags = flags, }; if (size == 0) { fprintf(stderr, "invalid size.\n"); goto fail; } bo = calloc(sizeof(*bo), 1); if (!bo) { fprintf(stderr, "failed to create bo[%s].\n", strerror(errno)); goto err_free_bo; } bo->dev = dev; if (drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_CREATE, &req)){ fprintf(stderr, "failed to create gem object[%s].\n", strerror(errno)); goto err_free_bo; } bo->handle = req.handle; bo->size = size; bo->flags = flags; return bo; err_free_bo: free(bo); fail: return NULL; } /* * Get information to gem region allocated. * * @dev: exynos drm device object. * @handle: gem handle to request gem info. * @size: size to gem object and returned by kernel side. * @flags: gem flags to gem object and returned by kernel side. * * with this function call, you can get flags and size to gem handle * through bo object. * * if true, return 0 else negative. */ int exynos_bo_get_info(struct exynos_device *dev, uint32_t handle, size_t *size, uint32_t *flags) { int ret; struct drm_exynos_gem_info req = { .handle = handle, }; ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_GET, &req); if (ret < 0) { fprintf(stderr, "failed to get gem object information[%s].\n", strerror(errno)); return ret; } *size = req.size; *flags = req.flags; return 0; } /* * Destroy a exynos buffer object. * * @bo: a exynos buffer object to be destroyed. */ void exynos_bo_destroy(struct exynos_bo *bo) { if (!bo) return; if (bo->vaddr) munmap(bo->vaddr, bo->size); if (bo->handle) { struct drm_gem_close req = { .handle = bo->handle, }; drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_CLOSE, &req); } free(bo); } /* * Get a exynos buffer object from a gem global object name. * * @dev: a exynos device object. * @name: a gem global object name exported by another process. * * this interface is used to get a exynos buffer object from a gem * global object name sent by another process for buffer sharing. * * if true, return a exynos buffer object else NULL. * */ struct exynos_bo * exynos_bo_from_name(struct exynos_device *dev, uint32_t name) { struct exynos_bo *bo; struct drm_gem_open req = { .name = name, }; bo = calloc(sizeof(*bo), 1); if (!bo) { fprintf(stderr, "failed to allocate bo[%s].\n", strerror(errno)); return NULL; } if (drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req)) { fprintf(stderr, "failed to open gem object[%s].\n", strerror(errno)); goto err_free_bo; } bo->dev = dev; bo->name = name; bo->handle = req.handle; return bo; err_free_bo: free(bo); return NULL; } /* * Get a gem global object name from a gem object handle. * * @bo: a exynos buffer object including gem handle. * @name: a gem global object name to be got by kernel driver. * * this interface is used to get a gem global object name from a gem object * handle to a buffer that wants to share it with another process. * * if true, return 0 else negative. */ int exynos_bo_get_name(struct exynos_bo *bo, uint32_t *name) { if (!bo->name) { struct drm_gem_flink req = { .handle = bo->handle, }; int ret; ret = drmIoctl(bo->dev->fd, DRM_IOCTL_GEM_FLINK, &req); if (ret) { fprintf(stderr, "failed to get gem global name[%s].\n", strerror(errno)); return ret; } bo->name = req.name; } *name = bo->name; return 0; } uint32_t exynos_bo_handle(struct exynos_bo *bo) { return bo->handle; } /* * Mmap a buffer to user space. * * @bo: a exynos buffer object including a gem object handle to be mmapped * to user space. * * if true, user pointer mmaped else NULL. */ void *exynos_bo_map(struct exynos_bo *bo) { if (!bo->vaddr) { struct exynos_device *dev = bo->dev; struct drm_exynos_gem_mmap req = { .handle = bo->handle, .size = bo->size, }; int ret; ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP, &req); if (ret) { fprintf(stderr, "failed to mmap[%s].\n", strerror(errno)); return NULL; } bo->vaddr = req.mapped; } return bo->vaddr; } /* * Export gem object to dmabuf as file descriptor. * * @dev: a exynos device object. * @handle: gem handle to be exported into dmabuf as file descriptor. * @fd: file descriptor to dmabuf exported from gem handle and * returned by kernel side. * * if true, return 0 else negative. */ int exynos_prime_handle_to_fd(struct exynos_device *dev, uint32_t handle, int *fd) { int ret; struct drm_prime_handle req = { .handle = handle, }; ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req); if (ret) { fprintf(stderr, "failed to mmap[%s].\n", strerror(errno)); return ret; } *fd = req.fd; return 0; } /* * Import file descriptor into gem handle. * * @dev: a exynos device object. * @fd: file descriptor exported into dmabuf. * @handle: gem handle to gem object imported from file descriptor * and returned by kernel side. * * if true, return 0 else negative. */ int exynos_prime_fd_to_handle(struct exynos_device *dev, int fd, uint32_t *handle) { int ret; struct drm_prime_handle req = { .fd = fd, }; ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &req); if (ret) { fprintf(stderr, "failed to mmap[%s].\n", strerror(errno)); return ret; } *handle = req.handle; return 0; } /* * Request Wireless Display connection or disconnection. * * @dev: a exynos device object. * @connect: indicate whether connectoin or disconnection request. * @ext: indicate whether edid data includes extentions data or not. * @edid: a pointer to edid data from Wireless Display device. * * this interface is used to request Virtual Display driver connection or * disconnection. for this, user should get a edid data from the Wireless * Display device and then send that data to kernel driver with connection * request * * if true, return 0 else negative. */ int exynos_vidi_connection(struct exynos_device *dev, uint32_t connect, uint32_t ext, void *edid) { struct drm_exynos_vidi_connection req = { .connection = connect, .extensions = ext, .edid = edid, }; int ret; ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_VIDI_CONNECTION, &req); if (ret) { fprintf(stderr, "failed to request vidi connection[%s].\n", strerror(errno)); return ret; } return 0; }