File Index
Files and directories
Sign in
FILE

nouveau_nvif.c

File preview with syntax highlighting.

linux-6.19.14/drivers/gpu/drm/nouveau/nouveau_nvif.c C
  1/*
  2 * Copyright 2014 Red Hat Inc.
  3 *
  4 * Permission is hereby granted, free of charge, to any person obtaining a
  5 * copy of this software and associated documentation files (the "Software"),
  6 * to deal in the Software without restriction, including without limitation
  7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8 * and/or sell copies of the Software, and to permit persons to whom the
  9 * Software is furnished to do so, subject to the following conditions:
 10 *
 11 * The above copyright notice and this permission notice shall be included in
 12 * all copies or substantial portions of the Software.
 13 *
 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 20 * OTHER DEALINGS IN THE SOFTWARE.
 21 *
 22 * Authors: Ben Skeggs <bskeggs@redhat.com>
 23 */
 24
 25/*******************************************************************************
 26 * NVIF client driver - NVKM directly linked
 27 ******************************************************************************/
 28
 29#include <core/client.h>
 30#include <core/ioctl.h>
 31
 32#include <nvif/client.h>
 33#include <nvif/driver.h>
 34#include <nvif/event.h>
 35#include <nvif/ioctl.h>
 36
 37#include "nouveau_drv.h"
 38
 39static void
 40nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
 41{
 42	iounmap(ptr);
 43}
 44
 45static void __iomem *
 46nvkm_client_map(void *priv, u64 handle, u32 size)
 47{
 48	return ioremap(handle, size);
 49}
 50
 51static int
 52nvkm_client_ioctl(void *priv, void *data, u32 size, void **hack)
 53{
 54	return nvkm_ioctl(priv, data, size, hack);
 55}
 56
 57static int
 58nvkm_client_resume(void *priv)
 59{
 60	struct nvkm_client *client = priv;
 61	return nvkm_object_init(&client->object);
 62}
 63
 64static int
 65nvkm_client_suspend(void *priv, bool runtime)
 66{
 67	struct nvkm_client *client = priv;
 68	enum nvkm_suspend_state state;
 69
 70	if (runtime)
 71		state = NVKM_RUNTIME_SUSPEND;
 72	else
 73		state = NVKM_SUSPEND;
 74	return nvkm_object_fini(&client->object, state);
 75}
 76
 77static int
 78nvkm_client_event(u64 token, void *repv, u32 repc)
 79{
 80	struct nvif_object *object = (void *)(unsigned long)token;
 81	struct nvif_event *event = container_of(object, typeof(*event), object);
 82
 83	if (event->func(event, repv, repc) == NVIF_EVENT_KEEP)
 84		return NVKM_EVENT_KEEP;
 85
 86	return NVKM_EVENT_DROP;
 87}
 88
 89static int
 90nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
 91			const char *dbg, void **ppriv)
 92{
 93	return nvkm_client_new(name, device, cfg, dbg, nvkm_client_event,
 94			       (struct nvkm_client **)ppriv);
 95}
 96
 97const struct nvif_driver
 98nvif_driver_nvkm = {
 99	.name = "nvkm",
100	.init = nvkm_client_driver_init,
101	.suspend = nvkm_client_suspend,
102	.resume = nvkm_client_resume,
103	.ioctl = nvkm_client_ioctl,
104	.map = nvkm_client_map,
105	.unmap = nvkm_client_unmap,
106};
~/ Read-only file preview.