Home | History | Annotate | Line # | Download | only in core
      1 /*	$NetBSD: client.h,v 1.7 2021/12/19 10:51:56 riastradh Exp $	*/
      2 
      3 /* SPDX-License-Identifier: MIT */
      4 #ifndef __NVKM_CLIENT_H__
      5 #define __NVKM_CLIENT_H__
      6 #define nvkm_client(p) container_of((p), struct nvkm_client, object)
      7 #include <core/object.h>
      8 
      9 struct nvkm_client {
     10 	struct nvkm_object object;
     11 	char name[32];
     12 	u64 device;
     13 	u32 debug;
     14 
     15 	struct nvkm_client_notify *notify[32];
     16 #ifdef __NetBSD__
     17 	rb_tree_t objtree;
     18 #else
     19 	struct rb_root objroot;
     20 #endif
     21 
     22 	bool super;
     23 	void *data;
     24 	int (*ntfy)(const void *, u32, const void *, u32);
     25 
     26 	struct list_head umem;
     27 #ifdef __NetBSD__
     28 	bus_space_tag_t mmiot;
     29 	bus_space_handle_t mmioh;
     30 	bus_addr_t mmioaddr;
     31 	bus_size_t mmiosz;
     32 #endif
     33 	spinlock_t lock;
     34 };
     35 
     36 int  nvkm_client_new(const char *name, u64 device, const char *cfg,
     37 		     const char *dbg,
     38 		     int (*)(const void *, u32, const void *, u32),
     39 		     struct nvkm_client **);
     40 struct nvkm_client *nvkm_client_search(struct nvkm_client *, u64 handle);
     41 
     42 int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
     43 			   void *data, u32 size);
     44 int nvkm_client_notify_del(struct nvkm_client *, int index);
     45 int nvkm_client_notify_get(struct nvkm_client *, int index);
     46 int nvkm_client_notify_put(struct nvkm_client *, int index);
     47 
     48 /* logging for client-facing objects */
     49 #define nvif_printk(o,l,p,f,a...) do {                                         \
     50 	const struct nvkm_object *_object = (o);                               \
     51 	const struct nvkm_client *_client = _object->client;                   \
     52 	if (_client->debug == NV_DBG_##l || _client->debug > NV_DBG_##l)       \
     53 		printk(KERN_##p "nouveau: %s:%08x:%08x: "f, _client->name,     \
     54 		       _object->handle, _object->oclass, ##a);                 \
     55 } while(0)
     56 #define nvif_fatal(o,f,a...) nvif_printk((o), FATAL, CRIT, f, ##a)
     57 #define nvif_error(o,f,a...) nvif_printk((o), ERROR,  ERR, f, ##a)
     58 #define nvif_debug(o,f,a...) nvif_printk((o), DEBUG, INFO, f, ##a)
     59 #define nvif_trace(o,f,a...) nvif_printk((o), TRACE, INFO, f, ##a)
     60 #define nvif_info(o,f,a...)  nvif_printk((o),  INFO, INFO, f, ##a)
     61 #define nvif_ioctl(o,f,a...) nvif_trace((o), "ioctl: "f, ##a)
     62 #endif
     63