video.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * video.h
  3. *
  4. * Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _VIDEO_H_
  20. #define _VIDEO_H_
  21. #include <common.h>
  22. #include <pci.h>
  23. #include <device.h>
  24. #define TEXT_HEIGHT 25
  25. #define TEXT_WIDTH 80
  26. #define VGA_AC_INDEX 0x3C0
  27. #define VGA_AC_WRITE 0x3C0
  28. #define VGA_AC_READ 0x3C1
  29. #define VGA_MISC_WRITE 0x3C2
  30. #define VGA_SEQ_INDEX 0x3C4
  31. #define VGA_SEQ_DATA 0x3C5
  32. #define VGA_DAC_READ_INDEX 0x3C7
  33. #define VGA_DEC_WRITE_INDEX 0x3C8
  34. #define VGA_DAC_DATA 0x3C9
  35. #define VGA_MISC_READ 0x3CC
  36. #define VGA_MISC_WRITE 0x3C2
  37. #define VGA_CRTC_INDEX 0x3D4
  38. #define VGA_CRTC_DATA 0x3D5
  39. #define VGA_GC_INDEX 0x3CE
  40. #define VGA_GC_DATA 0x3CF
  41. typedef struct video_device video_device_t;
  42. typedef dword_t (*video_init_proc_t)(list_entry_t *video_devices);
  43. typedef dword_t (*video_cleanup_proc_t)(void);
  44. typedef dword_t (*video_control_proc_t)(
  45. video_device_t *device,
  46. dword_t control_code,
  47. const void *in_buffer,
  48. size_t in_length,
  49. void *out_buffer,
  50. size_t out_length
  51. );
  52. typedef struct
  53. {
  54. video_init_proc_t init_proc;
  55. video_cleanup_proc_t cleanup_proc;
  56. video_control_proc_t control_proc;
  57. } video_driver_t;
  58. struct video_device
  59. {
  60. device_t header;
  61. list_entry_t list;
  62. pci_device_t *pci_device;
  63. video_driver_t *driver;
  64. video_mode_t current_mode;
  65. };
  66. dword_t video_default_control(
  67. video_device_t *device,
  68. dword_t control_code,
  69. const void *in_buffer,
  70. size_t in_length,
  71. void *out_buffer,
  72. size_t out_length
  73. );
  74. dword_t register_video_driver(video_driver_t *driver);
  75. dword_t unregister_video_driver(video_driver_t *driver);
  76. void video_init();
  77. #endif