uvesafb.h 3.7 KB

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