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