mtk_drm_fbconsole.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (C) 2015 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __MTK_FB_CONSOLE_H__
  14. #define __MTK_FB_CONSOLE_H__
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define UINT8 unsigned char
  19. #define UINT32 unsigned int
  20. #define INT32 int
  21. #define BYTE unsigned char
  22. #define MFC_CHECK_RET(expr) \
  23. do { \
  24. enum MFC_STATUS ret = (expr); \
  25. ASSERT(!(ret == MFC_STATUS_OK)); \
  26. } while (0)
  27. enum MFC_STATUS {
  28. MFC_STATUS_OK = 0,
  29. MFC_STATUS_INVALID_ARGUMENT = -1,
  30. MFC_STATUS_NOT_IMPLEMENTED = -2,
  31. MFC_STATUS_OUT_OF_MEMORY = -3,
  32. MFC_STATUS_LOCK_FAIL = -4,
  33. MFC_STATUS_FATAL_ERROR = -5,
  34. };
  35. #define MFC_HANDLE void *
  36. struct MFC_CONTEXT {
  37. struct semaphore sem;
  38. UINT8 *fb_addr;
  39. UINT32 fb_width;
  40. UINT32 fb_height;
  41. UINT32 fb_bpp;
  42. UINT32 fg_color;
  43. UINT32 bg_color;
  44. UINT32 screen_color;
  45. UINT32 rows;
  46. UINT32 cols;
  47. UINT32 cursor_row;
  48. UINT32 cursor_col;
  49. UINT32 font_width;
  50. UINT32 font_height;
  51. UINT32 scale;
  52. /*Avoid Kmemleak scan*/
  53. struct file *filp;
  54. };
  55. /* MTK Framebuffer Console API */
  56. enum MFC_STATUS MFC_Open(MFC_HANDLE *handle, void *fb_addr,
  57. unsigned int fb_width, unsigned int fb_height,
  58. unsigned int fb_bpp, unsigned int fg_color,
  59. unsigned int bg_color, struct file *filp);
  60. enum MFC_STATUS MFC_Open_Ex(MFC_HANDLE *handle, void *fb_addr,
  61. unsigned int fb_width, unsigned int fb_height,
  62. unsigned int fb_pitch, unsigned int fb_bpp,
  63. unsigned int fg_color, unsigned int bg_color,
  64. struct file *filp);
  65. enum MFC_STATUS MFC_Close(MFC_HANDLE handle);
  66. enum MFC_STATUS MFC_SetColor(MFC_HANDLE handle, unsigned int fg_color,
  67. unsigned int bg_color);
  68. enum MFC_STATUS MFC_ResetCursor(MFC_HANDLE handle);
  69. enum MFC_STATUS MFC_Print(MFC_HANDLE handle, const char *str);
  70. enum MFC_STATUS MFC_LowMemory_Printf(MFC_HANDLE handle, const char *str,
  71. UINT32 fg_color, UINT32 bg_color);
  72. enum MFC_STATUS MFC_SetMem(MFC_HANDLE handle, const char *str, UINT32 color);
  73. UINT32 MFC_Get_Cursor_Offset(MFC_HANDLE handle);
  74. /* -------- screen logger -------- */
  75. struct screen_logger {
  76. struct list_head list;
  77. char *obj;
  78. char *message;
  79. };
  80. enum message_mode { MESSAGE_REPLACE = 0, MESSAGE_APPEND = 1 };
  81. void screen_logger_init(void);
  82. void screen_logger_add_message(char *obj, enum message_mode mode,
  83. char *message);
  84. void screen_logger_remove_message(const char *obj);
  85. void screen_logger_print(MFC_HANDLE handle);
  86. void screen_logger_empty(void);
  87. void screen_logger_test_case(MFC_HANDLE handle);
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif /* __MTK_FB_CONSOLE_H__ */