sm750.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #ifndef LYNXDRV_H_
  2. #define LYNXDRV_H_
  3. #define FB_ACCEL_SMI 0xab
  4. #define MHZ(x) ((x) * 1000000)
  5. #define DEFAULT_SM750_CHIP_CLOCK 290
  6. #define DEFAULT_SM750LE_CHIP_CLOCK 333
  7. #ifndef SM750LE_REVISION_ID
  8. #define SM750LE_REVISION_ID ((unsigned char)0xfe)
  9. #endif
  10. enum sm750_pnltype {
  11. sm750_24TFT = 0, /* 24bit tft */
  12. sm750_dualTFT = 2, /* dual 18 bit tft */
  13. sm750_doubleTFT = 1, /* 36 bit double pixel tft */
  14. };
  15. /* vga channel is not concerned */
  16. enum sm750_dataflow {
  17. sm750_simul_pri, /* primary => all head */
  18. sm750_simul_sec, /* secondary => all head */
  19. sm750_dual_normal, /* primary => panel head and secondary => crt */
  20. sm750_dual_swap, /* primary => crt head and secondary => panel */
  21. };
  22. enum sm750_channel {
  23. sm750_primary = 0,
  24. /* enum value equal to the register filed data */
  25. sm750_secondary = 1,
  26. };
  27. enum sm750_path {
  28. sm750_panel = 1,
  29. sm750_crt = 2,
  30. sm750_pnc = 3, /* panel and crt */
  31. };
  32. struct init_status {
  33. ushort powerMode;
  34. /* below three clocks are in unit of MHZ*/
  35. ushort chip_clk;
  36. ushort mem_clk;
  37. ushort master_clk;
  38. ushort setAllEngOff;
  39. ushort resetMemory;
  40. };
  41. struct lynx_accel {
  42. /* base virtual address of DPR registers */
  43. volatile unsigned char __iomem *dprBase;
  44. /* base virtual address of de data port */
  45. volatile unsigned char __iomem *dpPortBase;
  46. /* function pointers */
  47. void (*de_init)(struct lynx_accel *);
  48. int (*de_wait)(void);/* see if hardware ready to work */
  49. int (*de_fillrect)(struct lynx_accel *, u32, u32, u32, u32,
  50. u32, u32, u32, u32, u32);
  51. int (*de_copyarea)(struct lynx_accel *, u32, u32, u32, u32,
  52. u32, u32, u32, u32,
  53. u32, u32, u32, u32);
  54. int (*de_imageblit)(struct lynx_accel *, const char *, u32, u32, u32, u32,
  55. u32, u32, u32, u32,
  56. u32, u32, u32, u32);
  57. };
  58. struct sm750_dev {
  59. /* common members */
  60. u16 devid;
  61. u8 revid;
  62. struct pci_dev *pdev;
  63. struct fb_info *fbinfo[2];
  64. struct lynx_accel accel;
  65. int accel_off;
  66. int fb_count;
  67. int mtrr_off;
  68. struct{
  69. int vram;
  70. } mtrr;
  71. /* all smi graphic adaptor got below attributes */
  72. unsigned long vidmem_start;
  73. unsigned long vidreg_start;
  74. __u32 vidmem_size;
  75. __u32 vidreg_size;
  76. void __iomem *pvReg;
  77. unsigned char __iomem *pvMem;
  78. /* locks*/
  79. spinlock_t slock;
  80. struct init_status initParm;
  81. enum sm750_pnltype pnltype;
  82. enum sm750_dataflow dataflow;
  83. int nocrt;
  84. /*
  85. * 0: no hardware cursor
  86. * 1: primary crtc hw cursor enabled,
  87. * 2: secondary crtc hw cursor enabled
  88. * 3: both ctrc hw cursor enabled
  89. */
  90. int hwCursor;
  91. };
  92. struct lynx_cursor {
  93. /* cursor width ,height and size */
  94. int w;
  95. int h;
  96. int size;
  97. /* hardware limitation */
  98. int maxW;
  99. int maxH;
  100. /* base virtual address and offset of cursor image */
  101. char __iomem *vstart;
  102. int offset;
  103. /* mmio addr of hw cursor */
  104. volatile char __iomem *mmio;
  105. };
  106. struct lynxfb_crtc {
  107. unsigned char __iomem *vCursor; /* virtual address of cursor */
  108. unsigned char __iomem *vScreen; /* virtual address of on_screen */
  109. int oCursor; /* cursor address offset in vidmem */
  110. int oScreen; /* onscreen address offset in vidmem */
  111. int channel;/* which channel this crtc stands for*/
  112. resource_size_t vidmem_size;/* this view's video memory max size */
  113. /* below attributes belong to info->fix, their value depends on specific adaptor*/
  114. u16 line_pad;/* padding information:0,1,2,4,8,16,... */
  115. u16 xpanstep;
  116. u16 ypanstep;
  117. u16 ywrapstep;
  118. void *priv;
  119. /* cursor information */
  120. struct lynx_cursor cursor;
  121. };
  122. struct lynxfb_output {
  123. int dpms;
  124. int paths;
  125. /* which paths(s) this output stands for,for sm750:
  126. * paths=1:means output for panel paths
  127. * paths=2:means output for crt paths
  128. * paths=3:means output for both panel and crt paths
  129. */
  130. int *channel;
  131. /* which channel these outputs linked with,for sm750:
  132. * *channel=0 means primary channel
  133. * *channel=1 means secondary channel
  134. * output->channel ==> &crtc->channel
  135. */
  136. void *priv;
  137. int (*proc_setBLANK)(struct lynxfb_output*, int);
  138. };
  139. struct lynxfb_par {
  140. /* either 0 or 1 for dual head adaptor,0 is the older one registered */
  141. int index;
  142. unsigned int pseudo_palette[256];
  143. struct lynxfb_crtc crtc;
  144. struct lynxfb_output output;
  145. struct fb_info *info;
  146. struct sm750_dev *dev;
  147. };
  148. static inline unsigned long ps_to_hz(unsigned int psvalue)
  149. {
  150. unsigned long long numerator = 1000*1000*1000*1000ULL;
  151. /* 10^12 / picosecond period gives frequency in Hz */
  152. do_div(numerator, psvalue);
  153. return (unsigned long)numerator;
  154. }
  155. int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
  156. int hw_sm750_inithw(struct sm750_dev*, struct pci_dev *);
  157. void hw_sm750_initAccel(struct sm750_dev *);
  158. int hw_sm750_deWait(void);
  159. int hw_sm750le_deWait(void);
  160. int hw_sm750_output_setMode(struct lynxfb_output*, struct fb_var_screeninfo*,
  161. struct fb_fix_screeninfo*);
  162. int hw_sm750_crtc_checkMode(struct lynxfb_crtc*, struct fb_var_screeninfo*);
  163. int hw_sm750_crtc_setMode(struct lynxfb_crtc*, struct fb_var_screeninfo*,
  164. struct fb_fix_screeninfo*);
  165. int hw_sm750_setColReg(struct lynxfb_crtc*, ushort, ushort, ushort, ushort);
  166. int hw_sm750_setBLANK(struct lynxfb_output*, int);
  167. int hw_sm750le_setBLANK(struct lynxfb_output*, int);
  168. int hw_sm750_pan_display(struct lynxfb_crtc *crtc,
  169. const struct fb_var_screeninfo *var,
  170. const struct fb_info *info);
  171. #endif