404

[ Avaa Bypassed ]




Upload:

Command:

botdev@52.15.57.203: ~ $
#ifndef __DRM_GEM_H__
#define __DRM_GEM_H__

/*
 * GEM Graphics Execution Manager Driver Interfaces
 *
 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
 * Copyright (c) 2009-2010, Code Aurora Forum.
 * All rights reserved.
 * Copyright © 2014 Intel Corporation
 *   Daniel Vetter <daniel.vetter@ffwll.ch>
 *
 * Author: Rickard E. (Rik) Faith <faith@valinux.com>
 * Author: Gareth Hughes <gareth@valinux.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell 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
 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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.
 */

#include <linux/kref.h>

#include <drm/drm_vma_manager.h>

/**
 * struct drm_gem_object - GEM buffer object
 *
 * This structure defines the generic parts for GEM buffer objects, which are
 * mostly around handling mmap and userspace handles.
 *
 * Buffer objects are often abbreviated to BO.
 */
struct drm_gem_object {
	/**
	 * @refcount:
	 *
	 * Reference count of this object
	 *
	 * Please use drm_gem_object_get() to acquire and drm_gem_object_put()
	 * or drm_gem_object_put_unlocked() to release a reference to a GEM
	 * buffer object.
	 */
	struct kref refcount;

	/**
	 * @handle_count:
	 *
	 * This is the GEM file_priv handle count of this object.
	 *
	 * Each handle also holds a reference. Note that when the handle_count
	 * drops to 0 any global names (e.g. the id in the flink namespace) will
	 * be cleared.
	 *
	 * Protected by &drm_device.object_name_lock.
	 */
	unsigned handle_count;

	/**
	 * @dev: DRM dev this object belongs to.
	 */
	struct drm_device *dev;

	/**
	 * @filp:
	 *
	 * SHMEM file node used as backing storage for swappable buffer objects.
	 * GEM also supports driver private objects with driver-specific backing
	 * storage (contiguous CMA memory, special reserved blocks). In this
	 * case @filp is NULL.
	 */
	struct file *filp;

	/**
	 * @vma_node:
	 *
	 * Mapping info for this object to support mmap. Drivers are supposed to
	 * allocate the mmap offset using drm_gem_create_mmap_offset(). The
	 * offset itself can be retrieved using drm_vma_node_offset_addr().
	 *
	 * Memory mapping itself is handled by drm_gem_mmap(), which also checks
	 * that userspace is allowed to access the object.
	 */
	struct drm_vma_offset_node vma_node;

	/**
	 * @size:
	 *
	 * Size of the object, in bytes.  Immutable over the object's
	 * lifetime.
	 */
	size_t size;

	/**
	 * @name:
	 *
	 * Global name for this object, starts at 1. 0 means unnamed.
	 * Access is covered by &drm_device.object_name_lock. This is used by
	 * the GEM_FLINK and GEM_OPEN ioctls.
	 */
	int name;

	/**
	 * @read_domains:
	 *
	 * Read memory domains. These monitor which caches contain read/write data
	 * related to the object. When transitioning from one set of domains
	 * to another, the driver is called to ensure that caches are suitably
	 * flushed and invalidated.
	 */
	uint32_t read_domains;

	/**
	 * @write_domain: Corresponding unique write memory domain.
	 */
	uint32_t write_domain;

	/**
	 * @dma_buf:
	 *
	 * dma-buf associated with this GEM object.
	 *
	 * Pointer to the dma-buf associated with this gem object (either
	 * through importing or exporting). We break the resulting reference
	 * loop when the last gem handle for this object is released.
	 *
	 * Protected by &drm_device.object_name_lock.
	 */
	struct dma_buf *dma_buf;

	/**
	 * @import_attach:
	 *
	 * dma-buf attachment backing this object.
	 *
	 * Any foreign dma_buf imported as a gem object has this set to the
	 * attachment point for the device. This is invariant over the lifetime
	 * of a gem object.
	 *
	 * The &drm_driver.gem_free_object callback is responsible for cleaning
	 * up the dma_buf attachment and references acquired at import time.
	 *
	 * Note that the drm gem/prime core does not depend upon drivers setting
	 * this field any more. So for drivers where this doesn't make sense
	 * (e.g. virtual devices or a displaylink behind an usb bus) they can
	 * simply leave it as NULL.
	 */
	struct dma_buf_attachment *import_attach;
};

/**
 * DEFINE_DRM_GEM_FOPS() - macro to generate file operations for GEM drivers
 * @name: name for the generated structure
 *
 * This macro autogenerates a suitable &struct file_operations for GEM based
 * drivers, which can be assigned to &drm_driver.fops. Note that this structure
 * cannot be shared between drivers, because it contains a reference to the
 * current module using THIS_MODULE.
 *
 * Note that the declaration is already marked as static - if you need a
 * non-static version of this you're probably doing it wrong and will break the
 * THIS_MODULE reference by accident.
 */
#define DEFINE_DRM_GEM_FOPS(name) \
	static const struct file_operations name = {\
		.owner		= THIS_MODULE,\
		.open		= drm_open,\
		.release	= drm_release,\
		.unlocked_ioctl	= drm_ioctl,\
		.compat_ioctl	= drm_compat_ioctl,\
		.poll		= drm_poll,\
		.read		= drm_read,\
		.llseek		= noop_llseek,\
		.mmap		= drm_gem_mmap,\
	}

void drm_gem_object_release(struct drm_gem_object *obj);
void drm_gem_object_free(struct kref *kref);
int drm_gem_object_init(struct drm_device *dev,
			struct drm_gem_object *obj, size_t size);
void drm_gem_private_object_init(struct drm_device *dev,
				 struct drm_gem_object *obj, size_t size);
void drm_gem_vm_open(struct vm_area_struct *vma);
void drm_gem_vm_close(struct vm_area_struct *vma);
int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned long obj_size,
		     struct vm_area_struct *vma);
int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);

/**
 * drm_gem_object_get - acquire a GEM buffer object reference
 * @obj: GEM buffer object
 *
 * This function acquires an additional reference to @obj. It is illegal to
 * call this without already holding a reference. No locks required.
 */
static inline void drm_gem_object_get(struct drm_gem_object *obj)
{
	kref_get(&obj->refcount);
}

/**
 * __drm_gem_object_put - raw function to release a GEM buffer object reference
 * @obj: GEM buffer object
 *
 * This function is meant to be used by drivers which are not encumbered with
 * &drm_device.struct_mutex legacy locking and which are using the
 * gem_free_object_unlocked callback. It avoids all the locking checks and
 * locking overhead of drm_gem_object_put() and drm_gem_object_put_unlocked().
 *
 * Drivers should never call this directly in their code. Instead they should
 * wrap it up into a ``driver_gem_object_put(struct driver_gem_object *obj)``
 * wrapper function, and use that. Shared code should never call this, to
 * avoid breaking drivers by accident which still depend upon
 * &drm_device.struct_mutex locking.
 */
static inline void
__drm_gem_object_put(struct drm_gem_object *obj)
{
	kref_put(&obj->refcount, drm_gem_object_free);
}

void drm_gem_object_put_unlocked(struct drm_gem_object *obj);
void drm_gem_object_put(struct drm_gem_object *obj);

/**
 * drm_gem_object_reference - acquire a GEM buffer object reference
 * @obj: GEM buffer object
 *
 * This is a compatibility alias for drm_gem_object_get() and should not be
 * used by new code.
 */
static inline void drm_gem_object_reference(struct drm_gem_object *obj)
{
	drm_gem_object_get(obj);
}

/**
 * __drm_gem_object_unreference - raw function to release a GEM buffer object
 *                                reference
 * @obj: GEM buffer object
 *
 * This is a compatibility alias for __drm_gem_object_put() and should not be
 * used by new code.
 */
static inline void __drm_gem_object_unreference(struct drm_gem_object *obj)
{
	__drm_gem_object_put(obj);
}

/**
 * drm_gem_object_unreference_unlocked - release a GEM buffer object reference
 * @obj: GEM buffer object
 *
 * This is a compatibility alias for drm_gem_object_put_unlocked() and should
 * not be used by new code.
 */
static inline void
drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
{
	drm_gem_object_put_unlocked(obj);
}

/**
 * drm_gem_object_unreference - release a GEM buffer object reference
 * @obj: GEM buffer object
 *
 * This is a compatibility alias for drm_gem_object_put() and should not be
 * used by new code.
 */
static inline void drm_gem_object_unreference(struct drm_gem_object *obj)
{
	drm_gem_object_put(obj);
}

int drm_gem_handle_create(struct drm_file *file_priv,
			  struct drm_gem_object *obj,
			  u32 *handlep);
int drm_gem_handle_delete(struct drm_file *filp, u32 handle);


void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
int drm_gem_create_mmap_offset_size(struct drm_gem_object *obj, size_t size);

struct page **drm_gem_get_pages(struct drm_gem_object *obj);
void drm_gem_put_pages(struct drm_gem_object *obj, struct page **pages,
		bool dirty, bool accessed);

struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp, u32 handle);
int drm_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
			    u32 handle, u64 *offset);
int drm_gem_dumb_destroy(struct drm_file *file,
			 struct drm_device *dev,
			 uint32_t handle);

#endif /* __DRM_GEM_H__ */

Filemanager

Name Type Size Permission Actions
bridge Folder 0755
i2c Folder 0755
tinydrm Folder 0755
ttm Folder 0755
amd_asic_type.h File 1.54 KB 0644
ati_pcigart.h File 731 B 0644
drmP.h File 10.84 KB 0644
drm_agpsupport.h File 3.81 KB 0644
drm_atomic.h File 30.49 KB 0644
drm_atomic_helper.h File 10.7 KB 0644
drm_auth.h File 3.4 KB 0644
drm_blend.h File 2.05 KB 0644
drm_bridge.h File 10.06 KB 0644
drm_cache.h File 2.81 KB 0644
drm_color_mgmt.h File 1.55 KB 0644
drm_connector.h File 34.96 KB 0644
drm_crtc.h File 32.42 KB 0644
drm_crtc_helper.h File 3.27 KB 0644
drm_debugfs.h File 3.36 KB 0644
drm_debugfs_crc.h File 2.66 KB 0644
drm_device.h File 5.58 KB 0644
drm_displayid.h File 3.24 KB 0644
drm_dp_dual_mode_helper.h File 4.43 KB 0644
drm_dp_helper.h File 44.09 KB 0644
drm_dp_mst_helper.h File 16.83 KB 0644
drm_drv.h File 20.51 KB 0644
drm_edid.h File 15.33 KB 0644
drm_encoder.h File 7.99 KB 0644
drm_encoder_slave.h File 6.46 KB 0644
drm_fb_cma_helper.h File 1.38 KB 0644
drm_fb_helper.h File 14.95 KB 0644
drm_file.h File 10.59 KB 0644
drm_fixed.h File 4.71 KB 0644
drm_flip_work.h File 3.01 KB 0644
drm_fourcc.h File 2.85 KB 0644
drm_framebuffer.h File 9.86 KB 0644
drm_gem.h File 9.83 KB 0644
drm_gem_cma_helper.h File 3.41 KB 0644
drm_gem_framebuffer_helper.h File 1.17 KB 0644
drm_global.h File 1.94 KB 0644
drm_hashtab.h File 3.01 KB 0644
drm_ioctl.h File 6.26 KB 0644
drm_irq.h File 1.29 KB 0644
drm_lease.h File 1.43 KB 0644
drm_legacy.h File 6.77 KB 0644
drm_mipi_dsi.h File 10.08 KB 0644
drm_mm.h File 16.48 KB 0644
drm_mode_config.h File 25.93 KB 0644
drm_mode_object.h File 5.77 KB 0644
drm_modes.h File 17.8 KB 0644
drm_modeset_helper.h File 1.57 KB 0644
drm_modeset_helper_vtables.h File 48.62 KB 0644
drm_modeset_lock.h File 4.02 KB 0644
drm_of.h File 3.17 KB 0644
drm_os_linux.h File 2.04 KB 0644
drm_panel.h File 7.03 KB 0644
drm_pci.h File 2.45 KB 0644
drm_pciids.h File 66.48 KB 0644
drm_plane.h File 20.38 KB 0644
drm_plane_helper.h File 3.2 KB 0644
drm_prime.h File 3.06 KB 0644
drm_print.h File 3.58 KB 0644
drm_property.h File 12.03 KB 0644
drm_rect.h File 5.87 KB 0644
drm_scdc_helper.h File 4.34 KB 0644
drm_simple_kms_helper.h File 3.99 KB 0644
drm_syncobj.h File 4.13 KB 0644
drm_sysfs.h File 287 B 0644
drm_vblank.h File 7.23 KB 0644
drm_vma_manager.h File 7.65 KB 0644
gma_drm.h File 1.01 KB 0644
i915_component.h File 4.11 KB 0644
i915_drm.h File 3.47 KB 0644
i915_pciids.h File 15.55 KB 0644
intel-gtt.h File 987 B 0644
intel_lpe_audio.h File 1.72 KB 0644