Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2014 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Ben Skeggs <bskeggs@redhat.com>
0023  */
0024 
0025 /*******************************************************************************
0026  * NVIF client driver - NVKM directly linked
0027  ******************************************************************************/
0028 
0029 #include <core/client.h>
0030 #include <core/notify.h>
0031 #include <core/ioctl.h>
0032 
0033 #include <nvif/client.h>
0034 #include <nvif/driver.h>
0035 #include <nvif/notify.h>
0036 #include <nvif/event.h>
0037 #include <nvif/ioctl.h>
0038 
0039 #include "nouveau_drv.h"
0040 #include "nouveau_usif.h"
0041 
0042 static void
0043 nvkm_client_unmap(void *priv, void __iomem *ptr, u32 size)
0044 {
0045     iounmap(ptr);
0046 }
0047 
0048 static void __iomem *
0049 nvkm_client_map(void *priv, u64 handle, u32 size)
0050 {
0051     return ioremap(handle, size);
0052 }
0053 
0054 static int
0055 nvkm_client_ioctl(void *priv, void *data, u32 size, void **hack)
0056 {
0057     return nvkm_ioctl(priv, data, size, hack);
0058 }
0059 
0060 static int
0061 nvkm_client_resume(void *priv)
0062 {
0063     struct nvkm_client *client = priv;
0064     return nvkm_object_init(&client->object);
0065 }
0066 
0067 static int
0068 nvkm_client_suspend(void *priv)
0069 {
0070     struct nvkm_client *client = priv;
0071     return nvkm_object_fini(&client->object, true);
0072 }
0073 
0074 static int
0075 nvkm_client_driver_init(const char *name, u64 device, const char *cfg,
0076             const char *dbg, void **ppriv)
0077 {
0078     return nvkm_client_new(name, device, cfg, dbg, nvif_notify, (struct nvkm_client **)ppriv);
0079 }
0080 
0081 const struct nvif_driver
0082 nvif_driver_nvkm = {
0083     .name = "nvkm",
0084     .init = nvkm_client_driver_init,
0085     .suspend = nvkm_client_suspend,
0086     .resume = nvkm_client_resume,
0087     .ioctl = nvkm_client_ioctl,
0088     .map = nvkm_client_map,
0089     .unmap = nvkm_client_unmap,
0090     .keep = false,
0091 };