]> git.ipfire.org Git - people/ms/u-boot.git/blob - cpu/bf561/video.c
AVR32: Add support for the ATSTK1004 board
[people/ms/u-boot.git] / cpu / bf561 / video.c
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
28 #include <stdarg.h>
29 #include <common.h>
30 #include <config.h>
31 #include <asm/blackfin.h>
32 #include <i2c.h>
33 #include <linux/types.h>
34 #include <devices.h>
35
36 #ifdef CONFIG_VIDEO
37 #define NTSC_FRAME_ADDR 0x06000000
38 #include "video.h"
39
40 /* NTSC OUTPUT SIZE 720 * 240 */
41 #define VERTICAL 2
42 #define HORIZONTAL 4
43
44 int is_vblank_line(const int line)
45 {
46 /*
47 * This array contains a single bit for each line in
48 * an NTSC frame.
49 */
50 if ((line <= 18) || (line >= 264 && line <= 281) || (line == 528))
51 return true;
52
53 return false;
54 }
55
56 int NTSC_framebuffer_init(char *base_address)
57 {
58 const int NTSC_frames = 1;
59 const int NTSC_lines = 525;
60 char *dest = base_address;
61 int frame_num, line_num;
62
63 for (frame_num = 0; frame_num < NTSC_frames; ++frame_num) {
64 for (line_num = 1; line_num <= NTSC_lines; ++line_num) {
65 unsigned int code;
66 int offset = 0;
67 int i;
68
69 if (is_vblank_line(line_num))
70 offset++;
71
72 if (line_num > 266 || line_num < 3)
73 offset += 2;
74
75 /* Output EAV code */
76 code = SystemCodeMap[offset].EAV;
77 write_dest_byte((char)(code >> 24) & 0xff);
78 write_dest_byte((char)(code >> 16) & 0xff);
79 write_dest_byte((char)(code >> 8) & 0xff);
80 write_dest_byte((char)(code) & 0xff);
81
82 /* Output horizontal blanking */
83 for (i = 0; i < 67 * 2; ++i) {
84 write_dest_byte(0x80);
85 write_dest_byte(0x10);
86 }
87
88 /* Output SAV */
89 code = SystemCodeMap[offset].SAV;
90 write_dest_byte((char)(code >> 24) & 0xff);
91 write_dest_byte((char)(code >> 16) & 0xff);
92 write_dest_byte((char)(code >> 8) & 0xff);
93 write_dest_byte((char)(code) & 0xff);
94
95 /* Output empty horizontal data */
96 for (i = 0; i < 360 * 2; ++i) {
97 write_dest_byte(0x80);
98 write_dest_byte(0x10);
99 }
100 }
101 }
102
103 return dest - base_address;
104 }
105
106 void fill_frame(char *Frame, int Value)
107 {
108 int *OddPtr32;
109 int OddLine;
110 int *EvenPtr32;
111 int EvenLine;
112 int i;
113 int *data;
114 int m, n;
115
116 /* fill odd and even frames */
117 for (OddLine = 22, EvenLine = 285; OddLine < 263; OddLine++, EvenLine++) {
118 OddPtr32 = (int *)((Frame + (OddLine * 1716)) + 276);
119 EvenPtr32 = (int *)((Frame + (EvenLine * 1716)) + 276);
120 for (i = 0; i < 360; i++, OddPtr32++, EvenPtr32++) {
121 *OddPtr32 = Value;
122 *EvenPtr32 = Value;
123 }
124 }
125
126 for (m = 0; m < VERTICAL; m++) {
127 data = (int *)u_boot_logo.data;
128 for (OddLine = (22 + m), EvenLine = (285 + m);
129 OddLine < (u_boot_logo.height * VERTICAL) + (22 + m);
130 OddLine += VERTICAL, EvenLine += VERTICAL) {
131 OddPtr32 = (int *)((Frame + ((OddLine) * 1716)) + 276);
132 EvenPtr32 =
133 (int *)((Frame + ((EvenLine) * 1716)) + 276);
134 for (i = 0; i < u_boot_logo.width / 2; i++) {
135 /* enlarge one pixel to m x n */
136 for (n = 0; n < HORIZONTAL; n++) {
137 *OddPtr32++ = *data;
138 *EvenPtr32++ = *data;
139 }
140 data++;
141 }
142 }
143 }
144 }
145
146 void video_putc(const char c)
147 {
148 }
149
150 void video_puts(const char *s)
151 {
152 }
153
154 static int video_init(void)
155 {
156 char *NTSCFrame;
157 NTSCFrame = (char *)NTSC_FRAME_ADDR;
158 NTSC_framebuffer_init(NTSCFrame);
159 fill_frame(NTSCFrame, BLUE);
160
161 *pPPI_CONTROL = 0x0082;
162 *pPPI_FRAME = 0x020D;
163
164 *pDMA0_START_ADDR = NTSCFrame;
165 *pDMA0_X_COUNT = 0x035A;
166 *pDMA0_X_MODIFY = 0x0002;
167 *pDMA0_Y_COUNT = 0x020D;
168 *pDMA0_Y_MODIFY = 0x0002;
169 *pDMA0_CONFIG = 0x1015;
170 *pPPI_CONTROL = 0x0083;
171 return 0;
172 }
173
174 int drv_video_init(void)
175 {
176 int error, devices = 1;
177
178 device_t videodev;
179
180 video_init(); /* Video initialization */
181
182 memset(&videodev, 0, sizeof(videodev));
183
184 strcpy(videodev.name, "video");
185 videodev.ext = DEV_EXT_VIDEO; /* Video extensions */
186 videodev.flags = DEV_FLAGS_OUTPUT; /* Output only */
187 videodev.putc = video_putc; /* 'putc' function */
188 videodev.puts = video_puts; /* 'puts' function */
189
190 error = device_register(&videodev);
191
192 return (error == 0) ? devices : error;
193 }
194 #endif