uvesafb.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #ifndef _UVESAFB_H
  2. #define _UVESAFB_H
  3. struct v86_regs {
  4. __u32 ebx;
  5. __u32 ecx;
  6. __u32 edx;
  7. __u32 esi;
  8. __u32 edi;
  9. __u32 ebp;
  10. __u32 eax;
  11. __u32 eip;
  12. __u32 eflags;
  13. __u32 esp;
  14. __u16 cs;
  15. __u16 ss;
  16. __u16 es;
  17. __u16 ds;
  18. __u16 fs;
  19. __u16 gs;
  20. };
  21. /* Task flags */
  22. #define TF_VBEIB 0x01
  23. #define TF_BUF_ESDI 0x02
  24. #define TF_BUF_ESBX 0x04
  25. #define TF_BUF_RET 0x08
  26. #define TF_EXIT 0x10
  27. struct uvesafb_task {
  28. __u8 flags;
  29. int buf_len;
  30. struct v86_regs regs;
  31. };
  32. /* Constants for the capabilities field
  33. * in vbe_ib */
  34. #define VBE_CAP_CAN_SWITCH_DAC 0x01
  35. #define VBE_CAP_VGACOMPAT 0x02
  36. /* The VBE Info Block */
  37. struct vbe_ib {
  38. char vbe_signature[4];
  39. __u16 vbe_version;
  40. __u32 oem_string_ptr;
  41. __u32 capabilities;
  42. __u32 mode_list_ptr;
  43. __u16 total_memory;
  44. __u16 oem_software_rev;
  45. __u32 oem_vendor_name_ptr;
  46. __u32 oem_product_name_ptr;
  47. __u32 oem_product_rev_ptr;
  48. __u8 reserved[222];
  49. char oem_data[256];
  50. char misc_data[512];
  51. } __attribute__ ((packed));
  52. #ifdef __KERNEL__
  53. /* VBE CRTC Info Block */
  54. struct vbe_crtc_ib {
  55. u16 horiz_total;
  56. u16 horiz_start;
  57. u16 horiz_end;
  58. u16 vert_total;
  59. u16 vert_start;
  60. u16 vert_end;
  61. u8 flags;
  62. u32 pixel_clock;
  63. u16 refresh_rate;
  64. u8 reserved[40];
  65. } __attribute__ ((packed));
  66. #define VBE_MODE_VGACOMPAT 0x20
  67. #define VBE_MODE_COLOR 0x08
  68. #define VBE_MODE_SUPPORTEDHW 0x01
  69. #define VBE_MODE_GRAPHICS 0x10
  70. #define VBE_MODE_LFB 0x80
  71. #define VBE_MODE_MASK (VBE_MODE_COLOR | VBE_MODE_SUPPORTEDHW | \
  72. VBE_MODE_GRAPHICS | VBE_MODE_LFB)
  73. /* VBE Mode Info Block */
  74. struct vbe_mode_ib {
  75. /* for all VBE revisions */
  76. u16 mode_attr;
  77. u8 winA_attr;
  78. u8 winB_attr;
  79. u16 win_granularity;
  80. u16 win_size;
  81. u16 winA_seg;
  82. u16 winB_seg;
  83. u32 win_func_ptr;
  84. u16 bytes_per_scan_line;
  85. /* for VBE 1.2+ */
  86. u16 x_res;
  87. u16 y_res;
  88. u8 x_char_size;
  89. u8 y_char_size;
  90. u8 planes;
  91. u8 bits_per_pixel;
  92. u8 banks;
  93. u8 memory_model;
  94. u8 bank_size;
  95. u8 image_pages;
  96. u8 reserved1;
  97. /* Direct color fields for direct/6 and YUV/7 memory models. */
  98. /* Offsets are bit positions of lsb in the mask. */
  99. u8 red_len;
  100. u8 red_off;
  101. u8 green_len;
  102. u8 green_off;
  103. u8 blue_len;
  104. u8 blue_off;
  105. u8 rsvd_len;
  106. u8 rsvd_off;
  107. u8 direct_color_info; /* direct color mode attributes */
  108. /* for VBE 2.0+ */
  109. u32 phys_base_ptr;
  110. u8 reserved2[6];
  111. /* for VBE 3.0+ */
  112. u16 lin_bytes_per_scan_line;
  113. u8 bnk_image_pages;
  114. u8 lin_image_pages;
  115. u8 lin_red_len;
  116. u8 lin_red_off;
  117. u8 lin_green_len;
  118. u8 lin_green_off;
  119. u8 lin_blue_len;
  120. u8 lin_blue_off;
  121. u8 lin_rsvd_len;
  122. u8 lin_rsvd_off;
  123. u32 max_pixel_clock;
  124. u16 mode_id;
  125. u8 depth;
  126. } __attribute__ ((packed));
  127. #define UVESAFB_DEFAULT_MODE "640x480-16"
  128. /* How long to wait for a reply from userspace [ms] */
  129. #define UVESAFB_TIMEOUT 5000
  130. /* Max number of concurrent tasks */
  131. #define UVESAFB_TASKS_MAX 16
  132. #define dac_reg (0x3c8)
  133. #define dac_val (0x3c9)
  134. struct uvesafb_pal_entry {
  135. u_char blue, green, red, pad;
  136. } __attribute__ ((packed));
  137. struct uvesafb_ktask {
  138. struct uvesafb_task t;
  139. void *buf;
  140. struct completion *done;
  141. u32 ack;
  142. };
  143. static int uvesafb_exec(struct uvesafb_ktask *tsk);
  144. #define UVESAFB_EXACT_RES 1
  145. #define UVESAFB_EXACT_DEPTH 2
  146. struct uvesafb_par {
  147. struct vbe_ib vbe_ib; /* VBE Info Block */
  148. struct vbe_mode_ib *vbe_modes; /* list of supported VBE modes */
  149. int vbe_modes_cnt;
  150. u8 nocrtc;
  151. u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
  152. u8 pmi_setpal; /* PMI for palette changes */
  153. u16 *pmi_base; /* protected mode interface location */
  154. void *pmi_start;
  155. void *pmi_pal;
  156. u8 *vbe_state_orig; /*
  157. * original hardware state, before the
  158. * driver was loaded
  159. */
  160. u8 *vbe_state_saved; /* state saved by fb_save_state */
  161. int vbe_state_size;
  162. atomic_t ref_count;
  163. int mode_idx;
  164. struct vbe_crtc_ib crtc;
  165. };
  166. #endif /* __KERNEL__ */
  167. #endif /* _UVESAFB_H */