1 #ifndef LYNXDRV_H_ 2 #define LYNXDRV_H_ 3 4 5 6 #define FB_ACCEL_SMI 0xab 7 /* please use revision id to distinguish sm750le and sm750*/ 8 #define SPC_SM750 0 9 10 #define MB(x) ((x)<<20) 11 #define MHZ(x) ((x) * 1000000) 12 /* align should be 2,4,8,16 */ 13 #define PADDING(align, data) (((data)+(align)-1)&(~((align) -1))) 14 extern int smi_indent; 15 16 17 struct lynx_accel{ 18 /* base virtual address of DPR registers */ 19 volatile unsigned char __iomem * dprBase; 20 /* base virtual address of de data port */ 21 volatile unsigned char __iomem * dpPortBase; 22 23 /* function fointers */ 24 void (*de_init)(struct lynx_accel *); 25 26 int (*de_wait)(void);/* see if hardware ready to work */ 27 28 int (*de_fillrect)(struct lynx_accel *, u32, u32, u32, u32, 29 u32, u32, u32, u32, u32); 30 31 int (*de_copyarea)(struct lynx_accel *, u32, u32, u32, u32, 32 u32, u32, u32, u32, 33 u32, u32, u32, u32); 34 35 int (*de_imageblit)(struct lynx_accel *, const char *, u32, u32, u32, u32, 36 u32, u32, u32, u32, 37 u32, u32, u32, u32); 38 39 }; 40 41 /* lynx_share stands for a presentation of two frame buffer 42 that use one smi adaptor , it is similar to a basic class of C++ 43 */ 44 struct lynx_share{ 45 /* common members */ 46 u16 devid; 47 u8 revid; 48 struct pci_dev *pdev; 49 struct fb_info *fbinfo[2]; 50 struct lynx_accel accel; 51 int accel_off; 52 int dual; 53 int mtrr_off; 54 struct{ 55 int vram; 56 }mtrr; 57 /* all smi graphic adaptor got below attributes */ 58 unsigned long vidmem_start; 59 unsigned long vidreg_start; 60 __u32 vidmem_size; 61 __u32 vidreg_size; 62 void __iomem *pvReg; 63 unsigned char __iomem *pvMem; 64 /* locks*/ 65 spinlock_t slock; 66 /* function pointers */ 67 void (*suspend)(struct lynx_share*); 68 void (*resume)(struct lynx_share*); 69 }; 70 71 struct lynx_cursor{ 72 /* cursor width ,height and size */ 73 int w; 74 int h; 75 int size; 76 /* hardware limitation */ 77 int maxW; 78 int maxH; 79 /* base virtual address and offset of cursor image */ 80 char __iomem *vstart; 81 int offset; 82 /* mmio addr of hw cursor */ 83 volatile char __iomem * mmio; 84 /* the lynx_share of this adaptor */ 85 struct lynx_share *share; 86 /* proc_routines */ 87 void (*enable)(struct lynx_cursor *); 88 void (*disable)(struct lynx_cursor *); 89 void (*setSize)(struct lynx_cursor *, int, int); 90 void (*setPos)(struct lynx_cursor *, int, int); 91 void (*setColor)(struct lynx_cursor *, u32, u32); 92 void (*setData)(struct lynx_cursor *, u16, const u8*, const u8*); 93 }; 94 95 struct lynxfb_crtc{ 96 unsigned char __iomem *vCursor; /* virtual address of cursor */ 97 unsigned char __iomem *vScreen; /* virtual address of on_screen */ 98 int oCursor; /* cursor address offset in vidmem */ 99 int oScreen; /* onscreen address offset in vidmem */ 100 int channel;/* which channel this crtc stands for*/ 101 resource_size_t vidmem_size;/* this view's video memory max size */ 102 103 /* below attributes belong to info->fix, their value depends on specific adaptor*/ 104 u16 line_pad;/* padding information:0,1,2,4,8,16,... */ 105 u16 xpanstep; 106 u16 ypanstep; 107 u16 ywrapstep; 108 109 void *priv; 110 111 int(*proc_setMode)(struct lynxfb_crtc*, 112 struct fb_var_screeninfo*, 113 struct fb_fix_screeninfo*); 114 115 int(*proc_checkMode)(struct lynxfb_crtc*, struct fb_var_screeninfo*); 116 int(*proc_setColReg)(struct lynxfb_crtc*, ushort, ushort, ushort, ushort); 117 void (*clear)(struct lynxfb_crtc*); 118 /* pan display */ 119 int (*proc_panDisplay)(struct lynxfb_crtc *, 120 const struct fb_var_screeninfo *, 121 const struct fb_info *); 122 /* cursor information */ 123 struct lynx_cursor cursor; 124 }; 125 126 struct lynxfb_output{ 127 int dpms; 128 int paths; 129 /* which paths(s) this output stands for,for sm750: 130 paths=1:means output for panel paths 131 paths=2:means output for crt paths 132 paths=3:means output for both panel and crt paths 133 */ 134 135 int *channel; 136 /* which channel these outputs linked with,for sm750: 137 *channel=0 means primary channel 138 *channel=1 means secondary channel 139 output->channel ==> &crtc->channel 140 */ 141 void *priv; 142 143 int(*proc_setMode)(struct lynxfb_output*, 144 struct fb_var_screeninfo*, 145 struct fb_fix_screeninfo*); 146 147 int(*proc_checkMode)(struct lynxfb_output*, struct fb_var_screeninfo*); 148 int(*proc_setBLANK)(struct lynxfb_output*, int); 149 void (*clear)(struct lynxfb_output*); 150 }; 151 152 struct lynxfb_par{ 153 /* either 0 or 1 for dual head adaptor,0 is the older one registered */ 154 int index; 155 unsigned int pseudo_palette[256]; 156 struct lynxfb_crtc crtc; 157 struct lynxfb_output output; 158 struct fb_info *info; 159 struct lynx_share *share; 160 }; 161 162 #ifndef offsetof 163 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 164 #endif 165 166 167 #define PS_TO_HZ(ps) \ 168 ({ \ 169 unsigned long long hz = 1000*1000*1000*1000ULL; \ 170 do_div(hz, ps); \ 171 (unsigned long)hz;}) 172 173 static inline unsigned long ps_to_hz(unsigned int psvalue) 174 { 175 unsigned long long numerator=1000*1000*1000*1000ULL; 176 /* 10^12 / picosecond period gives frequency in Hz */ 177 do_div(numerator, psvalue); 178 return (unsigned long)numerator; 179 } 180 181 182 #endif 183