Home | History | Annotate | Line # | Download | only in src
      1 #ifndef __NV_STRUCT_H__
      2 #define __NV_STRUCT_H__
      3 
      4 #include "colormapst.h"
      5 #include "xf86Cursor.h"
      6 #include "exa.h"
      7 #include "xf86drm.h"
      8 #include <stdbool.h>
      9 #include <stdint.h>
     10 #include "xf86Crtc.h"
     11 
     12 #if XF86_CRTC_VERSION >= 5
     13 #define NOUVEAU_PIXMAP_SHARING 1
     14 #endif
     15 
     16 #define NV_ARCH_03  0x03
     17 #define NV_ARCH_04  0x04
     18 #define NV_ARCH_10  0x10
     19 #define NV_ARCH_20  0x20
     20 #define NV_ARCH_30  0x30
     21 #define NV_ARCH_40  0x40
     22 #define NV_TESLA    0x50
     23 #define NV_FERMI    0xc0
     24 #define NV_KEPLER   0xe0
     25 #define NV_MAXWELL  0x110
     26 #define NV_PASCAL   0x130
     27 
     28 struct xf86_platform_device;
     29 
     30 /* NV50 */
     31 typedef struct _NVRec *NVPtr;
     32 
     33 typedef struct {
     34 	int fd;
     35 	unsigned long reinitGeneration;
     36 	struct xf86_platform_device *platform_dev;
     37 	unsigned int assigned_crtcs;
     38 	unsigned long fd_wakeup_registered;
     39 	int fd_wakeup_ref;
     40 } NVEntRec, *NVEntPtr;
     41 
     42 NVEntPtr NVEntPriv(ScrnInfoPtr pScrn);
     43 
     44 typedef struct _NVRec {
     45     uint32_t              Architecture;
     46     EntityInfoPtr       pEnt;
     47 	struct pci_device *PciInfo;
     48     Bool                Primary;
     49     Bool		Secondary;
     50 
     51     struct nouveau_bo * scanout;
     52 
     53     enum {
     54 	    UNKNOWN = 0,
     55 	    NONE,
     56 	    EXA,
     57     } AccelMethod;
     58     void (*Flush)(ScrnInfoPtr);
     59 
     60     Bool                HWCursor;
     61     Bool                ShadowFB;
     62     unsigned char *     ShadowPtr;
     63     int                 ShadowPitch;
     64 
     65     ExaDriverPtr	EXADriverPtr;
     66     Bool                exa_force_cp;
     67     Bool		wfb_enabled;
     68     Bool		tiled_scanout;
     69     Bool		glx_vblank;
     70     Bool		has_async_pageflip;
     71     Bool		has_pageflip;
     72     int 		swap_limit;
     73     int 		max_swap_limit;
     74     int 		max_dri_level;
     75 
     76     ScreenBlockHandlerProcPtr BlockHandler;
     77     CreateScreenResourcesProcPtr CreateScreenResources;
     78     CloseScreenProcPtr  CloseScreen;
     79     void		(*VideoTimerCallback)(ScrnInfoPtr, Time);
     80     XF86VideoAdaptorPtr	overlayAdaptor;
     81     XF86VideoAdaptorPtr	blitAdaptor;
     82     XF86VideoAdaptorPtr	textureAdaptor[2];
     83     int			videoKey;
     84     OptionInfoPtr	Options;
     85 
     86     Bool                LockedUp;
     87 
     88     CARD32              currentRop;
     89 
     90 	void *drmmode; /* for KMS */
     91 
     92 	/* DRM interface */
     93 	struct nouveau_device *dev;
     94 	char *drm_device_name;
     95 
     96 	/* GPU context */
     97 	struct nouveau_client *client;
     98 
     99 	struct nouveau_bo *transfer;
    100 	CARD32 transfer_offset;
    101 
    102 	struct nouveau_object *channel;
    103 	struct nouveau_pushbuf *pushbuf;
    104 	struct nouveau_bufctx *bufctx;
    105 	struct nouveau_object *notify0;
    106 	struct nouveau_object *vblank_sem;
    107 	struct nouveau_object *NvNull;
    108 	struct nouveau_object *NvContextSurfaces;
    109 	struct nouveau_object *NvContextBeta1;
    110 	struct nouveau_object *NvContextBeta4;
    111 	struct nouveau_object *NvImagePattern;
    112 	struct nouveau_object *NvRop;
    113 	struct nouveau_object *NvRectangle;
    114 	struct nouveau_object *NvImageBlit;
    115 	struct nouveau_object *NvScaledImage;
    116 	struct nouveau_object *NvClipRectangle;
    117 	struct nouveau_object *NvMemFormat;
    118 	struct nouveau_object *NvImageFromCpu;
    119 	struct nouveau_object *Nv2D;
    120 	struct nouveau_object *Nv3D;
    121 	struct nouveau_object *NvSW;
    122 	struct nouveau_object *NvCOPY;
    123 	struct nouveau_bo *scratch;
    124 
    125 	Bool ce_enabled;
    126 	struct nouveau_object *ce_channel;
    127 	struct nouveau_pushbuf *ce_pushbuf;
    128 	struct nouveau_object *NvCopy;
    129 	Bool (*ce_rect)(struct nouveau_pushbuf *, struct nouveau_object *,
    130 			int, int, int,
    131 			struct nouveau_bo *, uint32_t, int, int, int, int, int,
    132 			struct nouveau_bo *, uint32_t, int, int, int, int, int);
    133 
    134 	/* SYNC extension private */
    135 	void *sync;
    136 
    137 	/* Present extension private */
    138 	void *present;
    139 
    140 	/* Acceleration context */
    141 	PixmapPtr pspix, pmpix, pdpix;
    142 	PicturePtr pspict, pmpict;
    143 	Pixel fg_colour;
    144 
    145 	char *render_node;
    146 } NVRec;
    147 
    148 #define NVPTR(p) ((NVPtr)((p)->driverPrivate))
    149 
    150 typedef struct _NVPortPrivRec {
    151 	short		brightness;
    152 	short		contrast;
    153 	short		saturation;
    154 	short		hue;
    155 	RegionRec	clip;
    156 	CARD32		colorKey;
    157 	Bool		autopaintColorKey;
    158 	Bool		doubleBuffer;
    159 	CARD32		videoStatus;
    160 	int		currentBuffer;
    161 	Time		videoTime;
    162 	int		overlayCRTC;
    163 	Bool		grabbedByV4L;
    164 	Bool		iturbt_709;
    165 	Bool		blitter;
    166 	Bool		texture;
    167 	Bool		bicubic; /* only for texture adapter */
    168 	Bool		SyncToVBlank;
    169 	int             max_image_dim;
    170 	struct nouveau_bo *video_mem;
    171 	int		pitch;
    172 	int		offset;
    173 	struct nouveau_bo *TT_mem_chunk[2];
    174 	int		currentHostBuffer;
    175 } NVPortPrivRec, *NVPortPrivPtr;
    176 
    177 #define GET_OVERLAY_PRIVATE(pNv) \
    178             (NVPortPrivPtr)((pNv)->overlayAdaptor->pPortPrivates[0].ptr)
    179 
    180 #define GET_BLIT_PRIVATE(pNv) \
    181             (NVPortPrivPtr)((pNv)->blitAdaptor->pPortPrivates[0].ptr)
    182 
    183 #define OFF_TIMER       0x01
    184 #define FREE_TIMER      0x02
    185 #define CLIENT_VIDEO_ON 0x04
    186 #define OFF_DELAY       500  /* milliseconds */
    187 #define FREE_DELAY      5000
    188 
    189 #define TIMER_MASK      (OFF_TIMER | FREE_TIMER)
    190 
    191 /* EXA driver-controlled pixmaps */
    192 #define NOUVEAU_CREATE_PIXMAP_ZETA	0x10000000
    193 #define NOUVEAU_CREATE_PIXMAP_TILED	0x20000000
    194 #define NOUVEAU_CREATE_PIXMAP_SCANOUT	0x40000000
    195 
    196 struct nouveau_pixmap {
    197 	struct nouveau_bo *bo;
    198 	Bool shared;
    199 };
    200 
    201 static inline struct nouveau_pixmap *
    202 nouveau_pixmap(PixmapPtr ppix)
    203 {
    204 	return (struct nouveau_pixmap *)exaGetPixmapDriverPrivate(ppix);
    205 }
    206 
    207 static inline struct nouveau_bo *
    208 nouveau_pixmap_bo(PixmapPtr ppix)
    209 {
    210 	struct nouveau_pixmap *nvpix = nouveau_pixmap(ppix);
    211 
    212 	return nvpix ? nvpix->bo : NULL;
    213 }
    214 
    215 static inline uint32_t
    216 nv_pitch_align(NVPtr pNv, uint32_t width, int bpp)
    217 {
    218 	int mask;
    219 
    220 	if (bpp == 15)
    221 	        bpp = 16;
    222 	if (bpp == 24 || bpp == 30)
    223 	        bpp = 8;
    224 
    225 	/* Alignment requirements taken from the Haiku driver */
    226 	if (pNv->Architecture == NV_ARCH_04)
    227 	        mask = 128 / bpp - 1;
    228 	else
    229 	        mask = 512 / bpp - 1;
    230 
    231 	return (width + mask) & ~mask;
    232 }
    233 
    234 /* nv04 cursor max dimensions of 32x32 (A1R5G5B5) */
    235 #define NV04_CURSOR_SIZE 32
    236 /* limit nv10 cursors to 64x64 (ARGB8) (we could go to 64x255) */
    237 #define NV10_CURSOR_SIZE 64
    238 
    239 static inline int nv_cursor_width(NVPtr pNv)
    240 {
    241 	return pNv->dev->chipset >= 0x10 ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE;
    242 }
    243 
    244 #define xFixedToFloat(v) \
    245 	((float)xFixedToInt((v)) + ((float)xFixedFrac(v) / 65536.0))
    246 
    247 #endif /* __NV_STRUCT_H__ */
    248