DRM驱动代码分析:gem_prime_import

struct scatterlist、struct sg_table

struct scatterlist {
   
	unsigned long	page_link;
	unsigned int	offset;
	unsigned int	length;
	dma_addr_t	dma_address;
#ifdef CONFIG_NEED_SG_DMA_LENGTH
	unsigned int	dma_length;
#endif
};
struct sg_table {
   
	struct scatterlist *sgl;	/* the list */
	unsigned int nents;		/* number of mapped entries */
	unsigned int orig_nents;	/* original size of list */
};

结构体说明查看wowotech网站的文章《Linux kernel scatterlist API介绍》

struct dma_buf、struct dma_buf_attachment、struct dma_buf_ops

struct dma_buf {
   
	size_t size;
	struct file *file;
	struct list_head attachments;
	const struct dma_buf_ops *ops;
	struct mutex lock;
	unsigned vmapping_counter;
	struct dma_buf_map vmap_ptr;
	const char *exp_name;
	const char *name;
	spinlock_t name_lock;
	struct module *owner;
	struct list_head list_node;
	void *priv;
	struct dma_resv *resv;
	wait_queue_head_t poll;
	struct dma_buf_poll_cb_t {
   
		struct dma_fence_cb cb;
		wait_queue_head_t *poll;
		__poll_t active;
	} cb_in, cb_out;
#ifdef CONFIG_DMABUF_SYSFS_STATS
	struct dma_buf_sysfs_entry {
   
		union {
   
			struct kobject kobj;
			struct work_struct sysfs_add_work;
		};
		struct dma_buf *dmabuf;
	} *sysfs_entry;
#endif
	ANDROID_KABI_RESERVE(1);
	ANDROID_KABI_RESERVE(2);
};

通过dma_buf_export创建dma buf;
通过dma_buf_fd创建文件描述符;
通过dma_buf_put()和get_dma_buf()对dma buf进行引用计数;
通过struct dma_buf_attachment访问设备DMA;



size:buffer的大小,在buffer的生命周期内保持不变。

file:文件指针,用于引用计数。

attachments:dma_buf_attachment列表,表示所有连接的设备。

ops:操作函数

vmapping_counter:vmap的计数

vmap_ptr:虚拟地址

exp_name:exporter名字

name:用户层提供的名字

owner:指向exporter模块

priv:exporter私有数据

struct dma_buf_attachment {
   
	struct dma_buf *dmabuf;
	struct device *dev;
	struct list_head node;
	struct sg_table *sgt;
	enum dma_data_direction dir;
	bool peer2peer;
	const struct dma_buf_atta
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值