13d0407baSopenharmony_ci/* 23d0407baSopenharmony_ci * Copyright © 2012 Red Hat 33d0407baSopenharmony_ci * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 43d0407baSopenharmony_ci * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 53d0407baSopenharmony_ci * Copyright (c) 2009-2010, Code Aurora Forum. 63d0407baSopenharmony_ci * 73d0407baSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 83d0407baSopenharmony_ci * copy of this software and associated documentation files (the "Software"), 93d0407baSopenharmony_ci * to deal in the Software without restriction, including without limitation 103d0407baSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 113d0407baSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 123d0407baSopenharmony_ci * Software is furnished to do so, subject to the following conditions: 133d0407baSopenharmony_ci * 143d0407baSopenharmony_ci * The above copyright notice and this permission notice (including the next 153d0407baSopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 163d0407baSopenharmony_ci * Software. 173d0407baSopenharmony_ci * 183d0407baSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 193d0407baSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 203d0407baSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 213d0407baSopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 223d0407baSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 233d0407baSopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 243d0407baSopenharmony_ci * IN THE SOFTWARE. 253d0407baSopenharmony_ci * 263d0407baSopenharmony_ci * Authors: 273d0407baSopenharmony_ci * Dave Airlie <airlied@redhat.com> 283d0407baSopenharmony_ci * Rob Clark <rob.clark@linaro.org> 293d0407baSopenharmony_ci * 303d0407baSopenharmony_ci */ 313d0407baSopenharmony_ci 323d0407baSopenharmony_ci#ifndef __DRM_PRIME_H__ 333d0407baSopenharmony_ci#define __DRM_PRIME_H__ 343d0407baSopenharmony_ci 353d0407baSopenharmony_ci#include <linux/mutex.h> 363d0407baSopenharmony_ci#include <linux/rbtree.h> 373d0407baSopenharmony_ci#include <linux/scatterlist.h> 383d0407baSopenharmony_ci 393d0407baSopenharmony_ci/** 403d0407baSopenharmony_ci * struct drm_prime_file_private - per-file tracking for PRIME 413d0407baSopenharmony_ci * 423d0407baSopenharmony_ci * This just contains the internal &struct dma_buf and handle caches for each 433d0407baSopenharmony_ci * &struct drm_file used by the PRIME core code. 443d0407baSopenharmony_ci */ 453d0407baSopenharmony_cistruct drm_prime_file_private { 463d0407baSopenharmony_ci /* private: */ 473d0407baSopenharmony_ci struct mutex lock; 483d0407baSopenharmony_ci struct rb_root dmabufs; 493d0407baSopenharmony_ci struct rb_root handles; 503d0407baSopenharmony_ci}; 513d0407baSopenharmony_ci 523d0407baSopenharmony_cistruct device; 533d0407baSopenharmony_ci 543d0407baSopenharmony_cistruct dma_buf_export_info; 553d0407baSopenharmony_cistruct dma_buf; 563d0407baSopenharmony_cistruct dma_buf_attachment; 573d0407baSopenharmony_ci 583d0407baSopenharmony_cienum dma_data_direction; 593d0407baSopenharmony_ci 603d0407baSopenharmony_cistruct drm_device; 613d0407baSopenharmony_cistruct drm_gem_object; 623d0407baSopenharmony_cistruct drm_file; 633d0407baSopenharmony_ci 643d0407baSopenharmony_ci/* core prime functions */ 653d0407baSopenharmony_cistruct dma_buf *drm_gem_dmabuf_export(struct drm_device *dev, struct dma_buf_export_info *exp_info); 663d0407baSopenharmony_civoid drm_gem_dmabuf_release(struct dma_buf *dma_buf); 673d0407baSopenharmony_ci 683d0407baSopenharmony_ciint drm_gem_prime_fd_to_handle(struct drm_device *dev, struct drm_file *file_priv, int prime_fd, uint32_t *handle); 693d0407baSopenharmony_ciint drm_gem_prime_handle_to_fd(struct drm_device *dev, struct drm_file *file_priv, uint32_t handle, uint32_t flags, 703d0407baSopenharmony_ci int *prime_fd); 713d0407baSopenharmony_ci 723d0407baSopenharmony_ci/* helper functions for exporting */ 733d0407baSopenharmony_ciint drm_gem_map_attach(struct dma_buf *dma_buf, struct dma_buf_attachment *attach); 743d0407baSopenharmony_civoid drm_gem_map_detach(struct dma_buf *dma_buf, struct dma_buf_attachment *attach); 753d0407baSopenharmony_cistruct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, enum dma_data_direction dir); 763d0407baSopenharmony_civoid drm_gem_unmap_dma_buf(struct dma_buf_attachment *attach, struct sg_table *sgt, enum dma_data_direction dir); 773d0407baSopenharmony_civoid *drm_gem_dmabuf_vmap(struct dma_buf *dma_buf); 783d0407baSopenharmony_civoid drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void *vaddr); 793d0407baSopenharmony_ci 803d0407baSopenharmony_ciint drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma); 813d0407baSopenharmony_ciint drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma); 823d0407baSopenharmony_ci 833d0407baSopenharmony_cistruct sg_table *drm_prime_pages_to_sg(struct drm_device *dev, struct page **pages, unsigned int nr_pages); 843d0407baSopenharmony_cistruct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj, int flags); 853d0407baSopenharmony_ci 863d0407baSopenharmony_ciunsigned long drm_prime_get_contiguous_size(struct sg_table *sgt); 873d0407baSopenharmony_ci 883d0407baSopenharmony_ci/* helper functions for importing */ 893d0407baSopenharmony_cistruct drm_gem_object *drm_gem_prime_import_dev(struct drm_device *dev, struct dma_buf *dma_buf, 903d0407baSopenharmony_ci struct device *attach_dev); 913d0407baSopenharmony_cistruct drm_gem_object *drm_gem_prime_import(struct drm_device *dev, struct dma_buf *dma_buf); 923d0407baSopenharmony_ci 933d0407baSopenharmony_civoid drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg); 943d0407baSopenharmony_ci 953d0407baSopenharmony_ciint drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, struct page **pages, dma_addr_t *addrs, int max_pages); 963d0407baSopenharmony_ci 973d0407baSopenharmony_ciint drm_gem_dmabuf_get_uuid(struct dma_buf *dma_buf, uuid_t *uuid); 983d0407baSopenharmony_ci 993d0407baSopenharmony_ci#endif /* __DRM_PRIME_H__ */ 100