video.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * BF533-STAMP splash driver
  3. *
  4. * Copyright (c) 2006-2008 Analog Devices Inc.
  5. * (C) Copyright 2000
  6. * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
  7. * (C) Copyright 2002
  8. * Wolfgang Denk, wd@denx.de
  9. *
  10. * Licensed under the GPL-2 or later.
  11. */
  12. #include <stdarg.h>
  13. #include <common.h>
  14. #include <config.h>
  15. #include <malloc.h>
  16. #include <asm/blackfin.h>
  17. #include <asm/mach-common/bits/dma.h>
  18. #include <i2c.h>
  19. #include <linux/types.h>
  20. #include <devices.h>
  21. int gunzip(void *, int, unsigned char *, unsigned long *);
  22. #define DMA_SIZE16 2
  23. #include <asm/mach-common/bits/ppi.h>
  24. #define NTSC_FRAME_ADDR 0x06000000
  25. #include "video.h"
  26. /* NTSC OUTPUT SIZE 720 * 240 */
  27. #define VERTICAL 2
  28. #define HORIZONTAL 4
  29. int is_vblank_line(const int line)
  30. {
  31. /*
  32. * This array contains a single bit for each line in
  33. * an NTSC frame.
  34. */
  35. if ((line <= 18) || (line >= 264 && line <= 281) || (line == 528))
  36. return true;
  37. return false;
  38. }
  39. int NTSC_framebuffer_init(char *base_address)
  40. {
  41. const int NTSC_frames = 1;
  42. const int NTSC_lines = 525;
  43. char *dest = base_address;
  44. int frame_num, line_num;
  45. for (frame_num = 0; frame_num < NTSC_frames; ++frame_num) {
  46. for (line_num = 1; line_num <= NTSC_lines; ++line_num) {
  47. unsigned int code;
  48. int offset = 0;
  49. int i;
  50. if (is_vblank_line(line_num))
  51. offset++;
  52. if (line_num > 266 || line_num < 3)
  53. offset += 2;
  54. /* Output EAV code */
  55. code = system_code_map[offset].eav;
  56. write_dest_byte((char)(code >> 24) & 0xff);
  57. write_dest_byte((char)(code >> 16) & 0xff);
  58. write_dest_byte((char)(code >> 8) & 0xff);
  59. write_dest_byte((char)(code) & 0xff);
  60. /* Output horizontal blanking */
  61. for (i = 0; i < 67 * 2; ++i) {
  62. write_dest_byte(0x80);
  63. write_dest_byte(0x10);
  64. }
  65. /* Output SAV */
  66. code = system_code_map[offset].sav;
  67. write_dest_byte((char)(code >> 24) & 0xff);
  68. write_dest_byte((char)(code >> 16) & 0xff);
  69. write_dest_byte((char)(code >> 8) & 0xff);
  70. write_dest_byte((char)(code) & 0xff);
  71. /* Output empty horizontal data */
  72. for (i = 0; i < 360 * 2; ++i) {
  73. write_dest_byte(0x80);
  74. write_dest_byte(0x10);
  75. }
  76. }
  77. }
  78. return dest - base_address;
  79. }
  80. void fill_frame(char *Frame, int Value)
  81. {
  82. int *OddPtr32;
  83. int OddLine;
  84. int *EvenPtr32;
  85. int EvenLine;
  86. int i;
  87. int *data;
  88. int m, n;
  89. /* fill odd and even frames */
  90. for (OddLine = 22, EvenLine = 285; OddLine < 263; OddLine++, EvenLine++) {
  91. OddPtr32 = (int *)((Frame + (OddLine * 1716)) + 276);
  92. EvenPtr32 = (int *)((Frame + (EvenLine * 1716)) + 276);
  93. for (i = 0; i < 360; i++, OddPtr32++, EvenPtr32++) {
  94. *OddPtr32 = Value;
  95. *EvenPtr32 = Value;
  96. }
  97. }
  98. for (m = 0; m < VERTICAL; m++) {
  99. data = (int *)u_boot_logo.data;
  100. for (OddLine = (22 + m), EvenLine = (285 + m);
  101. OddLine < (u_boot_logo.height * VERTICAL) + (22 + m);
  102. OddLine += VERTICAL, EvenLine += VERTICAL) {
  103. OddPtr32 = (int *)((Frame + ((OddLine) * 1716)) + 276);
  104. EvenPtr32 =
  105. (int *)((Frame + ((EvenLine) * 1716)) + 276);
  106. for (i = 0; i < u_boot_logo.width / 2; i++) {
  107. /* enlarge one pixel to m x n */
  108. for (n = 0; n < HORIZONTAL; n++) {
  109. *OddPtr32++ = *data;
  110. *EvenPtr32++ = *data;
  111. }
  112. data++;
  113. }
  114. }
  115. }
  116. }
  117. static void video_init(char *NTSCFrame)
  118. {
  119. NTSC_framebuffer_init(NTSCFrame);
  120. fill_frame(NTSCFrame, BLUE);
  121. bfin_write_PPI_CONTROL(0x0082);
  122. bfin_write_PPI_FRAME(0x020D);
  123. bfin_write_DMA0_START_ADDR(NTSCFrame);
  124. bfin_write_DMA0_X_COUNT(0x035A);
  125. bfin_write_DMA0_X_MODIFY(0x0002);
  126. bfin_write_DMA0_Y_COUNT(0x020D);
  127. bfin_write_DMA0_Y_MODIFY(0x0002);
  128. bfin_write_DMA0_CONFIG(0x1015);
  129. bfin_write_PPI_CONTROL(0x0083);
  130. }
  131. int drv_video_init(void)
  132. {
  133. device_t videodev;
  134. video_init((void *)NTSC_FRAME_ADDR);
  135. memset(&videodev, 0, sizeof(videodev));
  136. strcpy(videodev.name, "video");
  137. videodev.ext = DEV_EXT_VIDEO;
  138. videodev.flags = DEV_FLAGS_SYSTEM;
  139. return device_register(&videodev);
  140. }