Linux Audio

Check our new training course

Embedded Linux training

Mar 10-20, 2025, special US time zones
Register
Loading...
v4.6
  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/notify.h>
 31#include <core/ioctl.h>
 32
 33#include <nvif/client.h>
 34#include <nvif/driver.h>
 35#include <nvif/notify.h>
 36#include <nvif/event.h>
 37#include <nvif/ioctl.h>
 38
 39#include "nouveau_drm.h"
 40#include "nouveau_usif.h"
 41
 42static void
 43nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
 44{
 45	iounmap(ptr);
 46}
 47
 48static void __iomem *
 49nvkm_client_map(void *priv, u64 handle, u32 size)
 50{
 51	return ioremap(handle, size);
 52}
 53
 54static int
 55nvkm_client_ioctl(void *priv, bool super, void *data, u32 size, void **hack)
 56{
 57	return nvkm_ioctl(priv, super, data, size, hack);
 58}
 59
 60static int
 61nvkm_client_resume(void *priv)
 62{
 63	return nvkm_client_init(priv);
 
 64}
 65
 66static int
 67nvkm_client_suspend(void *priv)
 68{
 69	return nvkm_client_fini(priv, true);
 70}
 71
 72static void
 73nvkm_client_driver_fini(void *priv)
 74{
 75	struct nvkm_client *client = priv;
 76	nvkm_client_del(&client);
 77}
 78
 79static int
 80nvkm_client_ntfy(const void *header, u32 length, const void *data, u32 size)
 81{
 82	const union {
 83		struct nvif_notify_req_v0 v0;
 84	} *args = header;
 85	u8 route;
 86
 87	if (length == sizeof(args->v0) && args->v0.version == 0) {
 88		route = args->v0.route;
 89	} else {
 90		WARN_ON(1);
 91		return NVKM_NOTIFY_DROP;
 92	}
 93
 94	switch (route) {
 95	case NVDRM_NOTIFY_NVIF:
 96		return nvif_notify(header, length, data, size);
 97	case NVDRM_NOTIFY_USIF:
 98		return usif_notify(header, length, data, size);
 99	default:
100		WARN_ON(1);
101		break;
102	}
103
104	return NVKM_NOTIFY_DROP;
105}
106
107static int
108nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
109			const char *dbg, void **ppriv)
110{
111	struct nvkm_client *client;
112	int ret;
113
114	ret = nvkm_client_new(name, device, cfg, dbg, &client);
115	*ppriv = client;
116	if (ret)
117		return ret;
118
119	client->ntfy = nvkm_client_ntfy;
120	return 0;
121}
122
123const struct nvif_driver
124nvif_driver_nvkm = {
125	.name = "nvkm",
126	.init = nvkm_client_driver_init,
127	.fini = nvkm_client_driver_fini,
128	.suspend = nvkm_client_suspend,
129	.resume = nvkm_client_resume,
130	.ioctl = nvkm_client_ioctl,
131	.map = nvkm_client_map,
132	.unmap = nvkm_client_unmap,
133	.keep = false,
134};
v6.2
  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#include "nouveau_usif.h"
 39
 40static void
 41nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
 42{
 43	iounmap(ptr);
 44}
 45
 46static void __iomem *
 47nvkm_client_map(void *priv, u64 handle, u32 size)
 48{
 49	return ioremap(handle, size);
 50}
 51
 52static int
 53nvkm_client_ioctl(void *priv, void *data, u32 size, void **hack)
 54{
 55	return nvkm_ioctl(priv, data, size, hack);
 56}
 57
 58static int
 59nvkm_client_resume(void *priv)
 60{
 61	struct nvkm_client *client = priv;
 62	return nvkm_object_init(&client->object);
 63}
 64
 65static int
 66nvkm_client_suspend(void *priv)
 67{
 
 
 
 
 
 
 68	struct nvkm_client *client = priv;
 69	return nvkm_object_fini(&client->object, true);
 70}
 71
 72static int
 73nvkm_client_event(u64 token, void *repv, u32 repc)
 74{
 75	struct nvif_object *object = (void *)(unsigned long)token;
 76	struct nvif_event *event = container_of(object, typeof(*event), object);
 77
 78	if (event->func(event, repv, repc) == NVIF_EVENT_KEEP)
 79		return NVKM_EVENT_KEEP;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 80
 81	return NVKM_EVENT_DROP;
 82}
 83
 84static int
 85nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
 86			const char *dbg, void **ppriv)
 87{
 88	return nvkm_client_new(name, device, cfg, dbg, nvkm_client_event,
 89			       (struct nvkm_client **)ppriv);
 
 
 
 
 
 
 
 
 90}
 91
 92const struct nvif_driver
 93nvif_driver_nvkm = {
 94	.name = "nvkm",
 95	.init = nvkm_client_driver_init,
 
 96	.suspend = nvkm_client_suspend,
 97	.resume = nvkm_client_resume,
 98	.ioctl = nvkm_client_ioctl,
 99	.map = nvkm_client_map,
100	.unmap = nvkm_client_unmap,
101	.keep = false,
102};