Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:51

0001 /*
0002  * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
0003  * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining a
0006  * copy of this software and associated documentation files (the "Software"),
0007  * to deal in the Software without restriction, including without limitation
0008  * the rights to use, copy, modify, merge, publish, distribute, sub license,
0009  * and/or sell copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following conditions:
0011  *
0012  * The above copyright notice and this permission notice (including the
0013  * next paragraph) shall be included in all copies or substantial portions
0014  * of the Software.
0015  *
0016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0018  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
0019  * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
0020  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0021  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0022  * DEALINGS IN THE SOFTWARE.
0023  */
0024 #ifndef _VIA_DRM_H_
0025 #define _VIA_DRM_H_
0026 
0027 #include "drm.h"
0028 
0029 #if defined(__cplusplus)
0030 extern "C" {
0031 #endif
0032 
0033 /* WARNING: These defines must be the same as what the Xserver uses.
0034  * if you change them, you must change the defines in the Xserver.
0035  */
0036 
0037 #ifndef _VIA_DEFINES_
0038 #define _VIA_DEFINES_
0039 
0040 #include "via_drmclient.h"
0041 
0042 #define VIA_NR_SAREA_CLIPRECTS      8
0043 #define VIA_NR_XVMC_PORTS               10
0044 #define VIA_NR_XVMC_LOCKS               5
0045 #define VIA_MAX_CACHELINE_SIZE          64
0046 #define XVMCLOCKPTR(saPriv,lockNo)                  \
0047     ((__volatile__ struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
0048                       (VIA_MAX_CACHELINE_SIZE - 1)) &   \
0049                      ~(VIA_MAX_CACHELINE_SIZE - 1)) +   \
0050                     VIA_MAX_CACHELINE_SIZE*(lockNo)))
0051 
0052 /* Each region is a minimum of 64k, and there are at most 64 of them.
0053  */
0054 #define VIA_NR_TEX_REGIONS 64
0055 #define VIA_LOG_MIN_TEX_REGION_SIZE 16
0056 #endif
0057 
0058 #define VIA_UPLOAD_TEX0IMAGE  0x1   /* handled clientside */
0059 #define VIA_UPLOAD_TEX1IMAGE  0x2   /* handled clientside */
0060 #define VIA_UPLOAD_CTX        0x4
0061 #define VIA_UPLOAD_BUFFERS    0x8
0062 #define VIA_UPLOAD_TEX0       0x10
0063 #define VIA_UPLOAD_TEX1       0x20
0064 #define VIA_UPLOAD_CLIPRECTS  0x40
0065 #define VIA_UPLOAD_ALL        0xff
0066 
0067 /* VIA specific ioctls */
0068 #define DRM_VIA_ALLOCMEM    0x00
0069 #define DRM_VIA_FREEMEM         0x01
0070 #define DRM_VIA_AGP_INIT    0x02
0071 #define DRM_VIA_FB_INIT         0x03
0072 #define DRM_VIA_MAP_INIT    0x04
0073 #define DRM_VIA_DEC_FUTEX       0x05
0074 #define NOT_USED
0075 #define DRM_VIA_DMA_INIT    0x07
0076 #define DRM_VIA_CMDBUFFER   0x08
0077 #define DRM_VIA_FLUSH           0x09
0078 #define DRM_VIA_PCICMD          0x0a
0079 #define DRM_VIA_CMDBUF_SIZE 0x0b
0080 #define NOT_USED
0081 #define DRM_VIA_WAIT_IRQ        0x0d
0082 #define DRM_VIA_DMA_BLIT        0x0e
0083 #define DRM_VIA_BLIT_SYNC       0x0f
0084 
0085 #define DRM_IOCTL_VIA_ALLOCMEM    DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
0086 #define DRM_IOCTL_VIA_FREEMEM     DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
0087 #define DRM_IOCTL_VIA_AGP_INIT    DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
0088 #define DRM_IOCTL_VIA_FB_INIT     DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
0089 #define DRM_IOCTL_VIA_MAP_INIT    DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
0090 #define DRM_IOCTL_VIA_DEC_FUTEX   DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
0091 #define DRM_IOCTL_VIA_DMA_INIT    DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
0092 #define DRM_IOCTL_VIA_CMDBUFFER   DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
0093 #define DRM_IOCTL_VIA_FLUSH   DRM_IO(  DRM_COMMAND_BASE + DRM_VIA_FLUSH)
0094 #define DRM_IOCTL_VIA_PCICMD      DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
0095 #define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
0096                         drm_via_cmdbuf_size_t)
0097 #define DRM_IOCTL_VIA_WAIT_IRQ    DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
0098 #define DRM_IOCTL_VIA_DMA_BLIT    DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
0099 #define DRM_IOCTL_VIA_BLIT_SYNC   DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
0100 
0101 /* Indices into buf.Setup where various bits of state are mirrored per
0102  * context and per buffer.  These can be fired at the card as a unit,
0103  * or in a piecewise fashion as required.
0104  */
0105 
0106 #define VIA_TEX_SETUP_SIZE 8
0107 
0108 /* Flags for clear ioctl
0109  */
0110 #define VIA_FRONT   0x1
0111 #define VIA_BACK    0x2
0112 #define VIA_DEPTH   0x4
0113 #define VIA_STENCIL 0x8
0114 #define VIA_MEM_VIDEO   0   /* matches drm constant */
0115 #define VIA_MEM_AGP     1   /* matches drm constant */
0116 #define VIA_MEM_SYSTEM  2
0117 #define VIA_MEM_MIXED   3
0118 #define VIA_MEM_UNKNOWN 4
0119 
0120 typedef struct {
0121     __u32 offset;
0122     __u32 size;
0123 } drm_via_agp_t;
0124 
0125 typedef struct {
0126     __u32 offset;
0127     __u32 size;
0128 } drm_via_fb_t;
0129 
0130 typedef struct {
0131     __u32 context;
0132     __u32 type;
0133     __u32 size;
0134     unsigned long index;
0135     unsigned long offset;
0136 } drm_via_mem_t;
0137 
0138 typedef struct _drm_via_init {
0139     enum {
0140         VIA_INIT_MAP = 0x01,
0141         VIA_CLEANUP_MAP = 0x02
0142     } func;
0143 
0144     unsigned long sarea_priv_offset;
0145     unsigned long fb_offset;
0146     unsigned long mmio_offset;
0147     unsigned long agpAddr;
0148 } drm_via_init_t;
0149 
0150 typedef struct _drm_via_futex {
0151     enum {
0152         VIA_FUTEX_WAIT = 0x00,
0153         VIA_FUTEX_WAKE = 0X01
0154     } func;
0155     __u32 ms;
0156     __u32 lock;
0157     __u32 val;
0158 } drm_via_futex_t;
0159 
0160 typedef struct _drm_via_dma_init {
0161     enum {
0162         VIA_INIT_DMA = 0x01,
0163         VIA_CLEANUP_DMA = 0x02,
0164         VIA_DMA_INITIALIZED = 0x03
0165     } func;
0166 
0167     unsigned long offset;
0168     unsigned long size;
0169     unsigned long reg_pause_addr;
0170 } drm_via_dma_init_t;
0171 
0172 typedef struct _drm_via_cmdbuffer {
0173     char *buf;
0174     unsigned long size;
0175 } drm_via_cmdbuffer_t;
0176 
0177 /* Warning: If you change the SAREA structure you must change the Xserver
0178  * structure as well */
0179 
0180 typedef struct _drm_via_tex_region {
0181     unsigned char next, prev;   /* indices to form a circular LRU  */
0182     unsigned char inUse;    /* owned by a client, or free? */
0183     int age;        /* tracked by clients to update local LRU's */
0184 } drm_via_tex_region_t;
0185 
0186 typedef struct _drm_via_sarea {
0187     unsigned int dirty;
0188     unsigned int nbox;
0189     struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
0190     drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
0191     int texAge;     /* last time texture was uploaded */
0192     int ctxOwner;       /* last context to upload state */
0193     int vertexPrim;
0194 
0195     /*
0196      * Below is for XvMC.
0197      * We want the lock integers alone on, and aligned to, a cache line.
0198      * Therefore this somewhat strange construct.
0199      */
0200 
0201     char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
0202 
0203     unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
0204     unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
0205     unsigned int XvMCCtxNoGrabbed;  /* Last context to hold decoder */
0206 
0207     /* Used by the 3d driver only at this point, for pageflipping:
0208      */
0209     unsigned int pfCurrentOffset;
0210 } drm_via_sarea_t;
0211 
0212 typedef struct _drm_via_cmdbuf_size {
0213     enum {
0214         VIA_CMDBUF_SPACE = 0x01,
0215         VIA_CMDBUF_LAG = 0x02
0216     } func;
0217     int wait;
0218     __u32 size;
0219 } drm_via_cmdbuf_size_t;
0220 
0221 typedef enum {
0222     VIA_IRQ_ABSOLUTE = 0x0,
0223     VIA_IRQ_RELATIVE = 0x1,
0224     VIA_IRQ_SIGNAL = 0x10000000,
0225     VIA_IRQ_FORCE_SEQUENCE = 0x20000000
0226 } via_irq_seq_type_t;
0227 
0228 #define VIA_IRQ_FLAGS_MASK 0xF0000000
0229 
0230 enum drm_via_irqs {
0231     drm_via_irq_hqv0 = 0,
0232     drm_via_irq_hqv1,
0233     drm_via_irq_dma0_dd,
0234     drm_via_irq_dma0_td,
0235     drm_via_irq_dma1_dd,
0236     drm_via_irq_dma1_td,
0237     drm_via_irq_num
0238 };
0239 
0240 struct drm_via_wait_irq_request {
0241     unsigned irq;
0242     via_irq_seq_type_t type;
0243     __u32 sequence;
0244     __u32 signal;
0245 };
0246 
0247 typedef union drm_via_irqwait {
0248     struct drm_via_wait_irq_request request;
0249     struct drm_wait_vblank_reply reply;
0250 } drm_via_irqwait_t;
0251 
0252 typedef struct drm_via_blitsync {
0253     __u32 sync_handle;
0254     unsigned engine;
0255 } drm_via_blitsync_t;
0256 
0257 /* - * Below,"flags" is currently unused but will be used for possible future
0258  * extensions like kernel space bounce buffers for bad alignments and
0259  * blit engine busy-wait polling for better latency in the absence of
0260  * interrupts.
0261  */
0262 
0263 typedef struct drm_via_dmablit {
0264     __u32 num_lines;
0265     __u32 line_length;
0266 
0267     __u32 fb_addr;
0268     __u32 fb_stride;
0269 
0270     unsigned char *mem_addr;
0271     __u32 mem_stride;
0272 
0273     __u32 flags;
0274     int to_fb;
0275 
0276     drm_via_blitsync_t sync;
0277 } drm_via_dmablit_t;
0278 
0279 #if defined(__cplusplus)
0280 }
0281 #endif
0282 
0283 #endif              /* _VIA_DRM_H_ */