live
     !�ÃÀÆ      !File not found.
     #ˆÊÉ„/6ïÈÀÆ 6!    #/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (c) 2009-2013, NVIDIA Corporation. All rights reserved.
 */

#ifndef __LINUX_HOST1X_H
#define __LINUX_HOST1X_H

#include <linux/device.h>
#include <linux/dma-direction.h>
#include <linux/dma-fence.h>
#include <linux/spinlock.h>
#include <linux/types.h>

enum host1x_class {
	HOST1X_CLASS_HOST1X = 0x1,
	HOST1X_CLASS_GR2D = 0x51,
	HOST1X_CLASS_GR2D_SB = 0x52,
	HOST1X_CLASS_VIC = 0x5D,
	HOST1X_CLASS_GR3D = 0x60,
	HOST1X_CLASS_NVDEC = 0xF0,
	HOST1X_CLASS_NVDEC1 = 0xF5,
};

struct host1x;
struct host1x_client;
struct iommu_group;

u64 host1x_get_dma_mask(struct host1x *host1x);

/**
 * struct host1x_bo_cache - host1x buffer object cache
 * @mappings: list of mappings
 * @lock: synchronizes accesses to the list of mappings
 *
 * Note that entries are not periodically evicted from this cache and instead need to be
 * explicitly released. This is used primarily for DRM/KMS where the cache's reference is
 * released when the last reference to a buffer object represented by a mapping in this
 * cache is dropped.
 */
struct host1x_bo_cache {
	struct list_head mappings;
	struct mutex lock;
};

static inline void host1x_bo_cache_init(struct host1x_bo_cache *cache)
{
	INIT_LIST_HEAD(&cache->mappings);
	mutex_init(&cache->lock);
}

static inline void host1x_bo_cache_destroy(struct host1x_bo_cache *cache)
{
	/* XXX warn if not empty? */
	mutex_destroy(&cache->lock);
}

/**
 * struct host1x_client_ops - host1x client operations
 * @early_init: host1x client early initialization code
 * @init: host1x client initialization code
 * @exit: host1x client tear down code
 * @late_exit: host1x client late tear down code
 * @suspend: host1x client suspend code
 * @resume: host1x client resume code
 */
struct host1x_client_ops {
	int (*early_init)(struct host1x_client *client);
	int (*init)(struct host1x_client *client);
	int (*exit)(struct host1x_client *client);
	int (*late_exit)(struct host1x_client *client);
	int (*suspend)(struct host1x_client *client);
	int (*resume)(struct host1x_client *client);
};

/**
 * struct host1x_client - host1x client structure
 * @list: list node for the host1x client
 * @host: pointer to struct device representing the host1x controller
 * @dev: pointer to struct device backing this host1x client
 * @group: IOMMU group that this client is a member of
 * @ops: host1x client operations
 * @class: host1x class represented by this client
 * @channel: host1x channel associated with this client
 * @syncpts: array of syncpoints requested for this client
 * @num_syncpts: number of syncpoints requested for this client
 * @parent: pointer to parent structure
 * @usecount: reference count for this structure
 * @lock: mutex for mutually exclusive concurrency
 * @cache: host1x buffer object cache
 */
struct host1x_client {
	struct list_head list;
	struct device *host;
	struct device *dev;
	struct iommu_group *group;

	const struct host1x_client_ops *ops;

	enum host1x_class class;
	struct host1x_channel *channel;

	struct host1x_syncpt **syncpts;
	unsigned int num_syncpts;

	struct host1x_client *parent;
	unsigned int usecount;
	struct mutex lock;

	struct host1x_bo_cache cache;
};

/*
 * host1x buffer objects
 */

struct host1x_bo;
struct sg_table;

struct host1x_bo_mapping {
	struct kref ref;
	struct dma_buf_attachment *attach;
	enum dma_data_direction direction;
	struct list_head list;
	struct host1x_bo *bo;
	struct sg_table *sgt;
	unsigned int chunks;
	struct device *dev;
	dma_addr_t phys;
	size_t size;

	struct host1x_bo_cache *cache;
	struct list_head entry;
};

static inline struct host1x_bo_mapping *to_host1x_bo_mapping(struct kref *ref)
{
	return container_of(ref, struct host1x_bo_mapping, ref);
}

struct host1x_bo_ops {
	struct host1x_bo *(*get)(struct host1x_bo *bo);
	void (*put)(struct host1x_bo *bo);
	struct host1x_bo_mapping *(*pin)(struct device *dev, struct host1x_bo *bo,
					 enum dma_data_direction dir);
	void (*unpin)(struct host1x_bo_mapping *map);
	void *(*mmap)(struct h