video.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * video commands
  4. *
  5. * Copyright 2022 Google LLC
  6. * Written by Simon Glass <sjg@chromium.org>
  7. */
  8. #include <common.h>
  9. #include <command.h>
  10. #include <dm.h>
  11. #include <video.h>
  12. #include <video_console.h>
  13. static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
  14. char *const argv[])
  15. {
  16. unsigned int col, row;
  17. struct udevice *dev;
  18. if (argc != 3)
  19. return CMD_RET_USAGE;
  20. if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
  21. return CMD_RET_FAILURE;
  22. col = dectoul(argv[1], NULL);
  23. row = dectoul(argv[2], NULL);
  24. vidconsole_position_cursor(dev, col, row);
  25. return 0;
  26. }
  27. static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc,
  28. char *const argv[])
  29. {
  30. struct udevice *dev;
  31. int ret;
  32. if (argc != 2)
  33. return CMD_RET_USAGE;
  34. if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
  35. return CMD_RET_FAILURE;
  36. ret = vidconsole_put_string(dev, argv[1]);
  37. if (!ret)
  38. ret = video_sync(dev->parent, false);
  39. return ret ? CMD_RET_FAILURE : 0;
  40. }
  41. U_BOOT_CMD(
  42. setcurs, 3, 1, do_video_setcursor,
  43. "set cursor position within screen",
  44. " <col> <row> in character"
  45. );
  46. U_BOOT_CMD(
  47. lcdputs, 2, 1, do_video_puts,
  48. "print string on video framebuffer",
  49. " <string>"
  50. );