0002-video-improve-UEFI-experience-on-DM_VIDEO.patch 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. From 3e1e14e0b14539ca42db40488c7b1067eb01dea4 Mon Sep 17 00:00:00 2001
  2. From: Andre Przywara <andre.przywara@arm.com>
  3. Date: Mon, 10 Jan 2022 00:56:31 +0000
  4. Subject: [PATCH 1/3] video: Add cursor support for video consoles
  5. So far the video console is completely lacking any cursor, which makes
  6. typing and correcting quite irritating.
  7. Add a simple cursor display by writing a SPACE glyph in the background
  8. colour to the next character position on the screen. Any typed character
  9. will naturally overwrite it, so we need to only explicitly clear it if
  10. the next character will appear somewhere else (newline, backspace).
  11. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
  12. Reviewed-by: Simon Glass <sjg@chromium.org>
  13. Tested-by: Simon Glass <sjg@chromium.org>
  14. Link: https://lore.kernel.org/r/20220110005638.21599-2-andre.przywara@arm.com
  15. [Alper: Rebase for console_set_font(), reword for CONFIG_VIDEO]
  16. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
  17. ---
  18. drivers/video/console_core.c | 1 +
  19. drivers/video/vidconsole-uclass.c | 42 +++++++++++++++++++++++++++++++
  20. include/video_console.h | 1 +
  21. 3 files changed, 44 insertions(+)
  22. diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
  23. index 939363653f6c..6b531718276f 100644
  24. --- a/drivers/video/console_core.c
  25. +++ b/drivers/video/console_core.c
  26. @@ -30,6 +30,7 @@ static int console_set_font(struct udevice *dev, struct video_fontdata *fontdata
  27. debug("height: %d\n", fontdata->height);
  28. priv->fontdata = fontdata;
  29. + vc_priv->cursor_visible = true;
  30. vc_priv->x_charsize = fontdata->width;
  31. vc_priv->y_charsize = fontdata->height;
  32. if (vid_priv->rot % 2) {
  33. diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
  34. index 80e7adf6a1a4..8b2ef51f1b3b 100644
  35. --- a/drivers/video/vidconsole-uclass.c
  36. +++ b/drivers/video/vidconsole-uclass.c
  37. @@ -57,6 +57,26 @@ int vidconsole_entry_start(struct udevice *dev)
  38. return ops->entry_start(dev);
  39. }
  40. +static void draw_cursor(struct udevice *dev, bool state)
  41. +{
  42. + struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
  43. + struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent);
  44. + u32 tmp;
  45. +
  46. + if (!priv->cursor_visible)
  47. + return;
  48. +
  49. + if (state) {
  50. + tmp = vid_priv->colour_bg;
  51. + vid_priv->colour_bg = vid_priv->colour_fg;
  52. + }
  53. +
  54. + vidconsole_putc_xy(dev, priv->xcur_frac, priv->ycur, ' ');
  55. +
  56. + if (state)
  57. + vid_priv->colour_bg = tmp;
  58. +}
  59. +
  60. /* Move backwards one space */
  61. static int vidconsole_back(struct udevice *dev)
  62. {
  63. @@ -64,6 +84,8 @@ static int vidconsole_back(struct udevice *dev)
  64. struct vidconsole_ops *ops = vidconsole_get_ops(dev);
  65. int ret;
  66. + draw_cursor(dev, false);
  67. +
  68. if (ops->backspace) {
  69. ret = ops->backspace(dev);
  70. if (ret != -ENOSYS)
  71. @@ -90,6 +112,8 @@ static void vidconsole_newline(struct udevice *dev)
  72. const int rows = CONFIG_VAL(CONSOLE_SCROLL_LINES);
  73. int i, ret;
  74. + draw_cursor(dev, false);
  75. +
  76. priv->xcur_frac = priv->xstart_frac;
  77. priv->ycur += priv->y_charsize;
  78. @@ -284,6 +308,14 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
  79. break;
  80. }
  81. + case 'l':
  82. + draw_cursor(dev, false);
  83. + priv->cursor_visible = 0;
  84. + break;
  85. + case 'h':
  86. + priv->cursor_visible = 1;
  87. + draw_cursor(dev, true);
  88. + break;
  89. case 'J': {
  90. int mode;
  91. @@ -458,6 +490,11 @@ int vidconsole_put_char(struct udevice *dev, char ch)
  92. struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
  93. int cp, ret;
  94. + /*
  95. + * We don't need to clear the cursor since we are going to overwrite
  96. + * that character anyway.
  97. + */
  98. +
  99. if (priv->escape) {
  100. vidconsole_escape_char(dev, ch);
  101. return 0;
  102. @@ -472,6 +509,7 @@ int vidconsole_put_char(struct udevice *dev, char ch)
  103. /* beep */
  104. break;
  105. case '\r':
  106. + draw_cursor(dev, false);
  107. priv->xcur_frac = priv->xstart_frac;
  108. break;
  109. case '\n':
  110. @@ -479,6 +517,7 @@ int vidconsole_put_char(struct udevice *dev, char ch)
  111. vidconsole_entry_start(dev);
  112. break;
  113. case '\t': /* Tab (8 chars alignment) */
  114. + draw_cursor(dev, false);
  115. priv->xcur_frac = ((priv->xcur_frac / priv->tab_width_frac)
  116. + 1) * priv->tab_width_frac;
  117. @@ -503,6 +542,8 @@ int vidconsole_put_char(struct udevice *dev, char ch)
  118. break;
  119. }
  120. + draw_cursor(dev, true);
  121. +
  122. return 0;
  123. }
  124. @@ -723,6 +764,7 @@ static int vidconsole_pre_probe(struct udevice *dev)
  125. struct video_priv *vid_priv = dev_get_uclass_priv(vid);
  126. priv->xsize_frac = VID_TO_POS(vid_priv->xsize);
  127. + priv->cursor_visible = false;
  128. return 0;
  129. }
  130. diff --git a/include/video_console.h b/include/video_console.h
  131. index 8b5928dc5ebb..00c5ecb664b9 100644
  132. --- a/include/video_console.h
  133. +++ b/include/video_console.h
  134. @@ -66,6 +66,7 @@ struct vidconsole_priv {
  135. int escape_len;
  136. int row_saved;
  137. int col_saved;
  138. + bool cursor_visible;
  139. char escape_buf[32];
  140. char utf8_buf[5];
  141. };
  142. base-commit: 475aa8345a78396d39b42f96eccecd37ebe24e99
  143. --
  144. 2.45.2
  145. From 0dd4fb08993b01d36e491705b24063834dcb618e Mon Sep 17 00:00:00 2001
  146. From: Andre Przywara <andre.przywara@arm.com>
  147. Date: Mon, 10 Jan 2022 00:56:36 +0000
  148. Subject: [PATCH 2/3] efi-selftest: Add international characters test
  149. UEFI relies entirely on unicode output, which actual fonts displayed on
  150. the screen might not be ready for.
  151. Add a test displaying some international characters, to reveal missing
  152. glyphs, especially in our builtin fonts.
  153. This would be needed to be manually checked on the screen for
  154. correctness.
  155. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
  156. Link: https://lore.kernel.org/r/20220110005638.21599-7-andre.przywara@arm.com
  157. ---
  158. lib/efi_selftest/efi_selftest_textoutput.c | 5 +++++
  159. 1 file changed, 5 insertions(+)
  160. diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c
  161. index a3023c82567c..2f8d8d323c2b 100644
  162. --- a/lib/efi_selftest/efi_selftest_textoutput.c
  163. +++ b/lib/efi_selftest/efi_selftest_textoutput.c
  164. @@ -154,6 +154,11 @@ static int execute(void)
  165. efi_st_printf("Unicode not handled properly\n");
  166. return EFI_ST_FAILURE;
  167. }
  168. + ret = con_out->output_string(con_out, L"Österreich Edelweiß Smørrebrød Smörgås Niño René >Ἑλλάς<\n");
  169. + if (ret != EFI_ST_SUCCESS) {
  170. + efi_st_error("OutputString failed for international chars\n");
  171. + return EFI_ST_FAILURE;
  172. + }
  173. efi_st_printf("\n");
  174. ret = con_out->output_string(con_out, text);
  175. if (ret != EFI_ST_SUCCESS) {
  176. --
  177. 2.45.2
  178. From 13101947807bec7ceaf3231d94e943b9b29a7369 Mon Sep 17 00:00:00 2001
  179. From: Andre Przywara <andre.przywara@arm.com>
  180. Date: Mon, 10 Jan 2022 00:56:37 +0000
  181. Subject: [PATCH 3/3] efi_selftest: Add box drawing character selftest
  182. UEFI applications rely on Unicode output capability, and might use that
  183. for drawing pseudo-graphical interfaces using Unicode defined box
  184. drawing characters.
  185. Add a simple test to display the most basic box characters, which would
  186. need to be checked manually on the screen for correctness.
  187. To facilitate this, add a three second delay after the output at this
  188. point.
  189. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
  190. Link: https://lore.kernel.org/r/20220110005638.21599-8-andre.przywara@arm.com
  191. ---
  192. lib/efi_selftest/efi_selftest_textoutput.c | 11 +++++++++++
  193. 1 file changed, 11 insertions(+)
  194. diff --git a/lib/efi_selftest/efi_selftest_textoutput.c b/lib/efi_selftest/efi_selftest_textoutput.c
  195. index 2f8d8d323c2b..02209a5bf224 100644
  196. --- a/lib/efi_selftest/efi_selftest_textoutput.c
  197. +++ b/lib/efi_selftest/efi_selftest_textoutput.c
  198. @@ -159,6 +159,17 @@ static int execute(void)
  199. efi_st_error("OutputString failed for international chars\n");
  200. return EFI_ST_FAILURE;
  201. }
  202. + ret = con_out->output_string(con_out, L"┌─┬─┐\n");
  203. + ret |= con_out->output_string(con_out, L"│ │ │\n");
  204. + ret |= con_out->output_string(con_out, L"├─┼─┤\n");
  205. + ret |= con_out->output_string(con_out, L"│ │ │\n");
  206. + ret |= con_out->output_string(con_out, L"└─┴─┘\n");
  207. + if (ret != EFI_ST_SUCCESS) {
  208. + efi_st_error("OutputString failed for box drawing chars\n");
  209. + return EFI_ST_FAILURE;
  210. + }
  211. + con_out->output_string(con_out, L"waiting for admiration...\n");
  212. + EFI_CALL(systab.boottime->stall(3000000));
  213. efi_st_printf("\n");
  214. ret = con_out->output_string(con_out, text);
  215. if (ret != EFI_ST_SUCCESS) {
  216. --
  217. 2.45.2