linux/drivers/gpu/drm/nouveau/core/include/subdev/timer.h
<<
>>
Prefs
   1#ifndef __NOUVEAU_TIMER_H__
   2#define __NOUVEAU_TIMER_H__
   3
   4#include <core/subdev.h>
   5#include <core/device.h>
   6
   7struct nouveau_alarm {
   8        struct list_head head;
   9        u64 timestamp;
  10        void (*func)(struct nouveau_alarm *);
  11};
  12
  13static inline void
  14nouveau_alarm_init(struct nouveau_alarm *alarm,
  15                   void (*func)(struct nouveau_alarm *))
  16{
  17        INIT_LIST_HEAD(&alarm->head);
  18        alarm->func = func;
  19}
  20
  21bool nouveau_timer_wait_eq(void *, u64 nsec, u32 addr, u32 mask, u32 data);
  22bool nouveau_timer_wait_ne(void *, u64 nsec, u32 addr, u32 mask, u32 data);
  23bool nouveau_timer_wait_cb(void *, u64 nsec, bool (*func)(void *), void *data);
  24void nouveau_timer_alarm(void *, u32 nsec, struct nouveau_alarm *);
  25void nouveau_timer_alarm_cancel(void *, struct nouveau_alarm *);
  26
  27#define NV_WAIT_DEFAULT 2000000000ULL
  28#define nv_wait(o,a,m,v)                                                       \
  29        nouveau_timer_wait_eq((o), NV_WAIT_DEFAULT, (a), (m), (v))
  30#define nv_wait_ne(o,a,m,v)                                                    \
  31        nouveau_timer_wait_ne((o), NV_WAIT_DEFAULT, (a), (m), (v))
  32#define nv_wait_cb(o,c,d)                                                      \
  33        nouveau_timer_wait_cb((o), NV_WAIT_DEFAULT, (c), (d))
  34
  35struct nouveau_timer {
  36        struct nouveau_subdev base;
  37        u64  (*read)(struct nouveau_timer *);
  38        void (*alarm)(struct nouveau_timer *, u64 time, struct nouveau_alarm *);
  39        void (*alarm_cancel)(struct nouveau_timer *, struct nouveau_alarm *);
  40};
  41
  42static inline struct nouveau_timer *
  43nouveau_timer(void *obj)
  44{
  45        return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_TIMER];
  46}
  47
  48#define nouveau_timer_create(p,e,o,d)                                          \
  49        nouveau_subdev_create_((p), (e), (o), 0, "PTIMER", "timer",            \
  50                               sizeof(**d), (void **)d)
  51#define nouveau_timer_destroy(p)                                               \
  52        nouveau_subdev_destroy(&(p)->base)
  53#define nouveau_timer_init(p)                                                  \
  54        nouveau_subdev_init(&(p)->base)
  55#define nouveau_timer_fini(p,s)                                                \
  56        nouveau_subdev_fini(&(p)->base, (s))
  57
  58int nouveau_timer_create_(struct nouveau_object *, struct nouveau_engine *,
  59                          struct nouveau_oclass *, int size, void **);
  60
  61extern struct nouveau_oclass nv04_timer_oclass;
  62
  63#endif
  64