video.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * (C) Copyright 2000
  3. * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it
  4. * (C) Copyright 2002
  5. * Wolfgang Denk, wd@denx.de
  6. * (C) Copyright 2006
  7. * Aubrey Li, aubrey.li@analog.com
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. #include <stdarg.h>
  28. #include <common.h>
  29. #include <config.h>
  30. #include <asm/blackfin.h>
  31. #include <i2c.h>
  32. #include <linux/types.h>
  33. #include <devices.h>
  34. #ifdef CONFIG_VIDEO
  35. #define NTSC_FRAME_ADDR 0x06000000
  36. #include "video.h"
  37. /* NTSC OUTPUT SIZE 720 * 240 */
  38. #define VERTICAL 2
  39. #define HORIZONTAL 4
  40. int is_vblank_line(const int line)
  41. {
  42. /*
  43. * This array contains a single bit for each line in
  44. * an NTSC frame.
  45. */
  46. if ((line <= 18) || (line >= 264 && line <= 281) || (line == 528))
  47. return true;
  48. return false;
  49. }
  50. int NTSC_framebuffer_init(char *base_address)
  51. {
  52. const int NTSC_frames = 1;
  53. const int NTSC_lines = 525;
  54. char *dest = base_address;
  55. int frame_num, line_num;
  56. for (frame_num = 0; frame_num < NTSC_frames; ++frame_num) {
  57. for (line_num = 1; line_num <= NTSC_lines; ++line_num) {
  58. unsigned int code;
  59. int offset = 0;
  60. int i;
  61. if (is_vblank_line(line_num))
  62. offset++;
  63. if (line_num > 266 || line_num < 3)
  64. offset += 2;
  65. /* Output EAV code */
  66. code = SystemCodeMap[offset].EAV;
  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 horizontal blanking */
  72. for (i = 0; i < 67 * 2; ++i) {
  73. write_dest_byte(0x80);
  74. write_dest_byte(0x10);
  75. }
  76. /* Output SAV */
  77. code = SystemCodeMap[offset].SAV;
  78. write_dest_byte((char)(code >> 24) & 0xff);
  79. write_dest_byte((char)(code >> 16) & 0xff);
  80. write_dest_byte((char)(code >> 8) & 0xff);
  81. write_dest_byte((char)(code) & 0xff);
  82. /* Output empty horizontal data */
  83. for (i = 0; i < 360 * 2; ++i) {
  84. write_dest_byte(0x80);
  85. write_dest_byte(0x10);
  86. }
  87. }
  88. }
  89. return dest - base_address;
  90. }
  91. void fill_frame(char *Frame, int Value)
  92. {
  93. int *OddPtr32;
  94. int OddLine;
  95. int *EvenPtr32;
  96. int EvenLine;
  97. int i;
  98. int *data;
  99. int m, n;
  100. /* fill odd and even frames */
  101. for (OddLine = 22, EvenLine = 285; OddLine < 263; OddLine++, EvenLine++) {
  102. OddPtr32 = (int *)((Frame + (OddLine * 1716)) + 276);
  103. EvenPtr32 = (int *)((Frame + (EvenLine * 1716)) + 276);
  104. for (i = 0; i < 360; i++, OddPtr32++, EvenPtr32++) {
  105. *OddPtr32 = Value;
  106. *EvenPtr32 = Value;
  107. }
  108. }
  109. for (m = 0; m < VERTICAL; m++) {
  110. data = (int *)u_boot_logo.data;
  111. for (OddLine = (22 + m), EvenLine = (285 + m);
  112. OddLine < (u_boot_logo.height * VERTICAL) + (22 + m);
  113. OddLine += VERTICAL, EvenLine += VERTICAL) {
  114. OddPtr32 = (int *)((Frame + ((OddLine) * 1716)) + 276);
  115. EvenPtr32 =
  116. (int *)((Frame + ((EvenLine) * 1716)) + 276);
  117. for (i = 0; i < u_boot_logo.width / 2; i++) {
  118. /* enlarge one pixel to m x n */
  119. for (n = 0; n < HORIZONTAL; n++) {
  120. *OddPtr32++ = *data;
  121. *EvenPtr32++ = *data;
  122. }
  123. data++;
  124. }
  125. }
  126. }
  127. }
  128. void video_putc(const char c)
  129. {
  130. }
  131. void video_puts(const char *s)
  132. {
  133. }
  134. static int video_init(void)
  135. {
  136. char *NTSCFrame;
  137. NTSCFrame = (char *)NTSC_FRAME_ADDR;
  138. NTSC_framebuffer_init(NTSCFrame);
  139. fill_frame(NTSCFrame, BLUE);
  140. *pPPI_CONTROL = 0x0082;
  141. *pPPI_FRAME = 0x020D;
  142. *pDMA0_START_ADDR = NTSCFrame;
  143. *pDMA0_X_COUNT = 0x035A;
  144. *pDMA0_X_MODIFY = 0x0002;
  145. *pDMA0_Y_COUNT = 0x020D;
  146. *pDMA0_Y_MODIFY = 0x0002;
  147. *pDMA0_CONFIG = 0x1015;
  148. *pPPI_CONTROL = 0x0083;
  149. return 0;
  150. }
  151. int drv_video_init(void)
  152. {
  153. int error, devices = 1;
  154. device_t videodev;
  155. video_init(); /* Video initialization */
  156. memset(&videodev, 0, sizeof(videodev));
  157. strcpy(videodev.name, "video");
  158. videodev.ext = DEV_EXT_VIDEO; /* Video extensions */
  159. videodev.flags = DEV_FLAGS_OUTPUT; /* Output only */
  160. videodev.putc = video_putc; /* 'putc' function */
  161. videodev.puts = video_puts; /* 'puts' function */
  162. error = device_register(&videodev);
  163. return (error == 0) ? devices : error;
  164. }
  165. #endif