drivers/gpu/drm/vmwgfx/vmwgfx_va.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vmwgfx/vmwgfx_va.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vmwgfx/vmwgfx_va.c
Extension
.c
Size
5386 bytes
Lines
171
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct vmw_stream {
	struct vmw_simple_resource sres;
	u32 stream_id;
};

/**
 * vmw_stream - Typecast a struct vmw_resource to a struct vmw_stream.
 * @res: Pointer to the struct vmw_resource.
 *
 * Returns: Returns a pointer to the struct vmw_stream.
 */
static struct vmw_stream *
vmw_stream(struct vmw_resource *res)
{
	return container_of(res, struct vmw_stream, sres.res);
}

/***************************************************************************
 * Simple resource callbacks for struct vmw_stream
 **************************************************************************/
static void vmw_stream_hw_destroy(struct vmw_resource *res)
{
	struct vmw_private *dev_priv = res->dev_priv;
	struct vmw_stream *stream = vmw_stream(res);
	int ret;

	ret = vmw_overlay_unref(dev_priv, stream->stream_id);
	WARN_ON_ONCE(ret != 0);
}

static int vmw_stream_init(struct vmw_resource *res, void *data)
{
	struct vmw_stream *stream = vmw_stream(res);

	return vmw_overlay_claim(res->dev_priv, &stream->stream_id);
}

static void vmw_stream_set_arg_handle(void *data, u32 handle)
{
	struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data;

	arg->stream_id = handle;
}

static const struct vmw_simple_resource_func va_stream_func = {
	.res_func = {
		.res_type = vmw_res_stream,
		.needs_guest_memory = false,
		.may_evict = false,
		.type_name = "overlay stream",
		.domain = VMW_BO_DOMAIN_SYS,
		.busy_domain = VMW_BO_DOMAIN_SYS,
		.create = NULL,
		.destroy = NULL,
		.bind = NULL,
		.unbind = NULL
	},
	.ttm_res_type = VMW_RES_STREAM,
	.size = sizeof(struct vmw_stream),
	.init = vmw_stream_init,
	.hw_destroy = vmw_stream_hw_destroy,
	.set_arg_handle = vmw_stream_set_arg_handle,
};

/***************************************************************************
 * End simple resource callbacks for struct vmw_stream
 **************************************************************************/

/**
 * vmw_stream_unref_ioctl - Ioctl to unreference a user-space handle to
 * a struct vmw_stream.
 * @dev: Pointer to the drm device.
 * @data: The ioctl argument
 * @file_priv: Pointer to a struct drm_file identifying the caller.
 *
 * Return:
 *   0 if successful.
 *   Negative error value on failure.
 */
int vmw_stream_unref_ioctl(struct drm_device *dev, void *data,
			   struct drm_file *file_priv)
{
	struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data;

	return ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile,
					 arg->stream_id);
}

/**
 * vmw_stream_claim_ioctl - Ioctl to claim a struct vmw_stream overlay.

Annotation

Implementation Notes