video.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 <stdio_dev.h>
  21. #define DMA_SIZE16 2
  22. #include <asm/mach-common/bits/ppi.h>
  23. #define NTSC_FRAME_ADDR 0x06000000
  24. #include "video.h"
  25. /* NTSC OUTPUT SIZE 720 * 240 */
  26. #define VERTICAL 2
  27. #define HORIZONTAL 4
  28. int is_vblank_line(const int line)
  29. {
  30. /*
  31. * This array contains a single bit for each line in
  32. * an NTSC frame.
  33. */
  34. if ((line <= 18) || (line >= 264 && line <= 281) || (line == 528))
  35. return true;
  36. return false;
  37. }
  38. int NTSC_framebuffer_init(char *base_address)
  39. {
  40. const int NTSC_frames = 1;
  41. const int NTSC_lines = 525;
  42. char *dest = base_address;
  43. int frame_num, line_num;
  44. for (frame_num = 0; frame_num < NTSC_frames; ++frame_num) {
  45. for (line_num = 1; line_num <= NTSC_lines; ++line_num) {
  46. unsigned int code;
  47. int offset = 0;
  48. int i;
  49. if (is_vblank_line(line_num))
  50. offset++;
  51. if (line_num > 266 || line_num < 3)
  52. offset += 2;
  53. /* Output EAV code */
  54. code = system_code_map[offset].eav;
  55. write_dest_byte((char)(code >> 24) & 0xff);
  56. write_dest_byte((char)(code >> 16) & 0xff);
  57. write_dest_byte((char)(code >> 8) & 0xff);
  58. write_dest_byte((char)(code) & 0xff);
  59. /* Output horizontal blanking */
  60. for (i = 0; i < 67 * 2; ++i) {
  61. write_dest_byte(0x80);
  62. write_dest_byte(0x10);
  63. }
  64. /* Output SAV */
  65. code = system_code_map[offset].sav;
  66. write_dest_byte((char)(code >> 24) & 0xff);
  67. write_dest_byte((char)(code >> 16) & 0xff);
  68. write_dest_byte((char)(code >> 8) & 0xff);
  69. write_dest_byte((char)(code) & 0xff);
  70. /* Output empty horizontal data */
  71. for (i = 0; i < 360 * 2; ++i) {
  72. write_dest_byte(0x80);
  73. write_dest_byte(0x10);
  74. }
  75. }
  76. }
  77. return dest - base_address;
  78. }
  79. void fill_frame(char *Frame, int Value)
  80. {
  81. int *OddPtr32;
  82. int OddLine;
  83. int *EvenPtr32;
  84. int EvenLine;
  85. int i;
  86. int *data;
  87. int m, n;
  88. /* fill odd and even frames */
  89. for (OddLine = 22, EvenLine = 285; OddLine < 263; OddLine++, EvenLine++) {
  90. OddPtr32 = (int *)((Frame + (OddLine * 1716)) + 276);
  91. EvenPtr32 = (int *)((Frame + (EvenLine * 1716)) + 276);
  92. for (i = 0; i < 360; i++, OddPtr32++, EvenPtr32++) {
  93. *OddPtr32 = Value;
  94. *EvenPtr32 = Value;
  95. }
  96. }
  97. for (m = 0; m < VERTICAL; m++) {
  98. data = (int *)u_boot_logo.data;
  99. for (OddLine = (22 + m), EvenLine = (285 + m);
  100. OddLine < (u_boot_logo.height * VERTICAL) + (22 + m);
  101. OddLine += VERTICAL, EvenLine += VERTICAL) {
  102. OddPtr32 = (int *)((Frame + ((OddLine) * 1716)) + 276);
  103. EvenPtr32 =
  104. (int *)((Frame + ((EvenLine) * 1716)) + 276);
  105. for (i = 0; i < u_boot_logo.width / 2; i++) {
  106. /* enlarge one pixel to m x n */
  107. for (n = 0; n < HORIZONTAL; n++) {
  108. *OddPtr32++ = *data;
  109. *EvenPtr32++ = *data;
  110. }
  111. data++;
  112. }
  113. }
  114. }
  115. }
  116. static void video_init(char *NTSCFrame)
  117. {
  118. NTSC_framebuffer_init(NTSCFrame);
  119. fill_frame(NTSCFrame, BLUE);
  120. bfin_write_PPI_CONTROL(0x0082);
  121. bfin_write_PPI_FRAME(0x020D);
  122. bfin_write_DMA0_START_ADDR(NTSCFrame);
  123. bfin_write_DMA0_X_COUNT(0x035A);
  124. bfin_write_DMA0_X_MODIFY(0x0002);
  125. bfin_write_DMA0_Y_COUNT(0x020D);
  126. bfin_write_DMA0_Y_MODIFY(0x0002);
  127. bfin_write_DMA0_CONFIG(0x1015);
  128. bfin_write_PPI_CONTROL(0x0083);
  129. }
  130. void video_stop(void)
  131. {
  132. bfin_write_PPI_CONTROL(0);
  133. bfin_write_DMA0_CONFIG(0);
  134. }
  135. int drv_video_init(void)
  136. {
  137. struct stdio_dev videodev;
  138. video_init((void *)NTSC_FRAME_ADDR);
  139. memset(&videodev, 0, sizeof(videodev));
  140. strcpy(videodev.name, "video");
  141. return stdio_register(&videodev);
  142. }