splash.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com>
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., http://www.fsf.org/about/contact/
  20. *
  21. */
  22. #include <common.h>
  23. #include <splash.h>
  24. #include <lcd.h>
  25. static struct splash_location default_splash_locations[] = {
  26. {
  27. .name = "sf",
  28. .storage = SPLASH_STORAGE_SF,
  29. .flags = SPLASH_STORAGE_RAW,
  30. .offset = 0x0,
  31. },
  32. {
  33. .name = "mmc_fs",
  34. .storage = SPLASH_STORAGE_MMC,
  35. .flags = SPLASH_STORAGE_FS,
  36. .devpart = "0:1",
  37. },
  38. {
  39. .name = "usb_fs",
  40. .storage = SPLASH_STORAGE_USB,
  41. .flags = SPLASH_STORAGE_FS,
  42. .devpart = "0:1",
  43. },
  44. {
  45. .name = "sata_fs",
  46. .storage = SPLASH_STORAGE_SATA,
  47. .flags = SPLASH_STORAGE_FS,
  48. .devpart = "0:1",
  49. },
  50. };
  51. __weak int splash_screen_prepare(void)
  52. {
  53. return splash_source_load(default_splash_locations,
  54. ARRAY_SIZE(default_splash_locations));
  55. }
  56. #ifdef CONFIG_SPLASH_SCREEN_ALIGN
  57. void splash_get_pos(int *x, int *y)
  58. {
  59. char *s = env_get("splashpos");
  60. if (!s)
  61. return;
  62. if (s[0] == 'm')
  63. *x = BMP_ALIGN_CENTER;
  64. else
  65. *x = simple_strtol(s, NULL, 0);
  66. s = strchr(s + 1, ',');
  67. if (s != NULL) {
  68. if (s[1] == 'm')
  69. *y = BMP_ALIGN_CENTER;
  70. else
  71. *y = simple_strtol(s + 1, NULL, 0);
  72. }
  73. }
  74. #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
  75. /*
  76. * Common function to show a splash image if env("splashimage") is set.
  77. * Is used for both dm_video and lcd video stacks. For additional
  78. * details please refer to doc/README.splashprepare.
  79. */
  80. #if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_CMD_BMP)
  81. int splash_display(void)
  82. {
  83. ulong addr;
  84. char *s;
  85. int x = 0, y = 0, ret;
  86. s = env_get("splashimage");
  87. if (!s)
  88. return -EINVAL;
  89. addr = simple_strtoul(s, NULL, 16);
  90. ret = splash_screen_prepare();
  91. if (ret)
  92. return ret;
  93. splash_get_pos(&x, &y);
  94. return bmp_display(addr, x, y);
  95. }
  96. #endif