gfxlib.c
来自「Ibmstb02500 miniboot 源码」· C语言 代码 · 共 572 行 · 第 1/2 页
C
572 行
{ 0xff, 0x66, 0x33, 0x33 }, // 136 { 0xff, 0x66, 0x33, 0x00 }, // 137 { 0xff, 0x66, 0x00, 0xff }, // 138 { 0xff, 0x66, 0x00, 0xcc }, // 139 { 0xff, 0x66, 0x00, 0x99 }, // 140 { 0xff, 0x66, 0x00, 0x66 }, // 141 { 0xff, 0x66, 0x00, 0x33 }, // 142 { 0xff, 0x66, 0x00, 0x00 }, // 143 { 0xff, 0x33, 0xff, 0xff }, // 144 { 0xff, 0x33, 0xff, 0xcc }, // 145 { 0xff, 0x33, 0xff, 0x99 }, // 146 { 0xff, 0x33, 0xff, 0x66 }, // 147 { 0xff, 0x33, 0xff, 0x33 }, // 148 { 0xff, 0x33, 0xff, 0x00 }, // 149 { 0xff, 0x33, 0xcc, 0xff }, // 150 { 0xff, 0x33, 0xcc, 0xcc }, // 151 { 0xff, 0x33, 0xcc, 0x99 }, // 152 { 0xff, 0x33, 0xcc, 0x66 }, // 153 { 0xff, 0x33, 0xcc, 0x33 }, // 154 { 0xff, 0x33, 0xcc, 0x00 }, // 155 { 0xff, 0x33, 0x99, 0xff }, // 156 { 0xff, 0x33, 0x99, 0xcc }, // 157 { 0xff, 0x33, 0x99, 0x99 }, // 158 { 0xff, 0x33, 0x99, 0x66 }, // 159 { 0xff, 0x33, 0x99, 0x33 }, // 160 { 0xff, 0x33, 0x99, 0x00 }, // 161 { 0xff, 0x33, 0x66, 0xff }, // 162 { 0xff, 0x33, 0x66, 0xcc }, // 163 { 0xff, 0x33, 0x66, 0x99 }, // 164 { 0xff, 0x33, 0x66, 0x66 }, // 165 { 0xff, 0x33, 0x66, 0x33 }, // 166 { 0xff, 0x33, 0x66, 0x00 }, // 167 { 0xff, 0x33, 0x33, 0xff }, // 168 { 0xff, 0x33, 0x33, 0xcc }, // 169 { 0xff, 0x33, 0x33, 0x99 }, // 170 { 0xff, 0x33, 0x33, 0x66 }, // 171 { 0xff, 0x33, 0x33, 0x33 }, // 172 { 0xff, 0x33, 0x33, 0x00 }, // 173 { 0xff, 0x33, 0x00, 0xff }, // 174 { 0xff, 0x33, 0x00, 0xcc }, // 175 { 0xff, 0x33, 0x00, 0x99 }, // 176 { 0xff, 0x33, 0x00, 0x66 }, // 177 { 0xff, 0x33, 0x00, 0x33 }, // 178 { 0xff, 0x33, 0x00, 0x00 }, // 179 { 0xff, 0x00, 0xff, 0xff }, // 180 { 0xff, 0x00, 0xff, 0xcc }, // 181 { 0xff, 0x00, 0xff, 0x99 }, // 182 { 0xff, 0x00, 0xff, 0x66 }, // 183 { 0xff, 0x00, 0xff, 0x33 }, // 184 { 0xff, 0x00, 0xff, 0x00 }, // 185 { 0xff, 0x00, 0xcc, 0xff }, // 186 { 0xff, 0x00, 0xcc, 0xcc }, // 187 { 0xff, 0x00, 0xcc, 0x99 }, // 188 { 0xff, 0x00, 0xcc, 0x66 }, // 189 { 0xff, 0x00, 0xcc, 0x33 }, // 190 { 0xff, 0x00, 0xcc, 0x00 }, // 191 { 0xff, 0x00, 0x99, 0xff }, // 192 { 0xff, 0x00, 0x99, 0xcc }, // 193 { 0xff, 0x00, 0x99, 0x99 }, // 194 { 0xff, 0x00, 0x99, 0x66 }, // 195 { 0xff, 0x00, 0x99, 0x33 }, // 196 { 0xff, 0x00, 0x99, 0x00 }, // 197 { 0xff, 0x00, 0x66, 0xff }, // 198 { 0xff, 0x00, 0x66, 0xcc }, // 199 { 0xff, 0x00, 0x66, 0x99 }, // 200 { 0xff, 0x00, 0x66, 0x66 }, // 201 { 0xff, 0x00, 0x66, 0x33 }, // 202 { 0xff, 0x00, 0x66, 0x00 }, // 203 { 0xff, 0x00, 0x33, 0xff }, // 204 { 0xff, 0x00, 0x33, 0xcc }, // 205 { 0xff, 0x00, 0x33, 0x99 }, // 206 { 0xff, 0x00, 0x33, 0x66 }, // 207 { 0xff, 0x00, 0x33, 0x33 }, // 208 { 0xff, 0x00, 0x33, 0x00 }, // 209 { 0xff, 0x00, 0x00, 0xff }, // 210 { 0xff, 0x00, 0x00, 0xcc }, // 211 { 0xff, 0x00, 0x00, 0x99 }, // 212 { 0xff, 0x00, 0x00, 0x66 }, // 213 { 0xff, 0x00, 0x00, 0x33 }, // 214 { 0xff, 0x00, 0x00, 0x00 }, // 215 // from 216 to 248, 32 level grey scale { 0xff, 0x00, 0x00, 0x00 }, // 216 { 0xff, 0x08, 0x08, 0x08 }, // 217 { 0xff, 0x10, 0x10, 0x10 }, // 218 { 0xff, 0x18, 0x18, 0x18 }, // 219 { 0xff, 0x20, 0x20, 0x20 }, // 220 { 0xff, 0x28, 0x28, 0x28 }, // 221 { 0xff, 0x30, 0x30, 0x30 }, // 222 { 0xff, 0x38, 0x38, 0x38 }, // 223 { 0xff, 0x40, 0x40, 0x40 }, // 224 { 0xff, 0x48, 0x48, 0x48 }, // 225 { 0xff, 0x50, 0x50, 0x50 }, // 226 { 0xff, 0x58, 0x58, 0x58 }, // 227 { 0xff, 0x60, 0x60, 0x60 }, // 228 { 0xff, 0x68, 0x68, 0x68 }, // 229 { 0xff, 0x70, 0x70, 0x70 }, // 230 { 0xff, 0x78, 0x78, 0x78 }, // 231 { 0xff, 0x80, 0x80, 0x80 }, // 232 { 0xff, 0x88, 0x88, 0x88 }, // 233 { 0xff, 0x90, 0x90, 0x90 }, // 234 { 0xff, 0x98, 0x98, 0x98 }, // 235 { 0xff, 0xa0, 0xa0, 0xa0 }, // 236 { 0xff, 0xa8, 0xa8, 0xa8 }, // 237 { 0xff, 0xb0, 0xb0, 0xb0 }, // 238 { 0xff, 0xb8, 0xb8, 0xb8 }, // 239 { 0xff, 0xc0, 0xc0, 0xc0 }, // 240 { 0xff, 0xc8, 0xc8, 0xc8 }, // 241 { 0xff, 0xd0, 0xd0, 0xd0 }, // 242 { 0xff, 0xd8, 0xd8, 0xd8 }, // 243 { 0xff, 0xe0, 0xe0, 0xe0 }, // 244 { 0xff, 0xe8, 0xe8, 0xe8 }, // 245 { 0xff, 0xf0, 0xf0, 0xf0 }, // 246 { 0xff, 0xf8, 0xf8, 0xf8 }, // 247 { 0xff, 0xff, 0xff, 0xff }, // 248 // from 249 to 255, 7 color rainbow { 0xff, 0x00, 0x00, 0xff }, // 249 { 0xff, 0x00, 0xff, 0x00 }, // 250 { 0xff, 0x00, 0xff, 0xff }, // 251 { 0xff, 0xff, 0x00, 0x00 }, // 252 { 0xff, 0xff, 0x00, 0xff }, // 253 { 0xff, 0xff, 0xff, 0x00 }, // 254 { 0xff, 0xff, 0xff, 0xff } // 255 }};// the actually location of datastatic struct pallas_osd_control_block *osdcb = (struct pallas_osd_control_block *)VIDEO_RAM_ADDRESS; static unsigned char *video_buffer = (unsigned char *)(VIDEO_RAM_ADDRESS+2048); // 512 byte align is enough#define DCR_DISP_CNTL (0x0151) // display control register#define DCR_CURSOR_GRAPHIC_CNTL (0x015a) // cursor and graphics control#define DCR_STILL_BKGND_CNTL (0x015c) // still and background control#define DCR_OSD_BASE_ADDR_INDEX (0x016d) // On-Screen-Display base address index#define DCR_OSD_BASE_ADDR_DATA (0x016e) // On-Screen-Display base address#define DCR_CURSOR_POSITION (0x017a) // cursor position#define DENC0_CR1 0x131#define DENC1_CR1 0x2e1#define DENCMUX 0x2f3#define VID_DCR_BASE 0x140#define VID_CHIP_CTRL VID_DCR_BASE + 0x00#define VID_DISP_MODE VID_DCR_BASE + 0x14#define VID_DISP_DLY VID_DCR_BASE + 0x15#define VID_DISP_BOR VID_DCR_BASE + 0x18#define VID_PTS_CTRL VID_DCR_BASE + 0x1fchar *bios_tv_fmt_str[NUMBER_TV_FMT] = { "NTSC", "PAL/B/G", "PAL_M", "PAL_N", "NTSC_BAR", "PAL_BAR"};static void init_gfx_hardware(){ MT_DCR(DCR_CURSOR_GRAPHIC_CNTL, 0x01ff01ff); // inhibit all layer MT_DCR(DCR_OSD_BASE_ADDR_INDEX, 0x04); // gfx control block MT_DCR(DCR_OSD_BASE_ADDR_DATA, (unsigned long)osdcb); MT_DCR(DCR_OSD_BASE_ADDR_INDEX, 0x05); // gfx buffer address MT_DCR(DCR_OSD_BASE_ADDR_DATA, (unsigned long)video_buffer); MT_DCR(DCR_CURSOR_GRAPHIC_CNTL, 0x01fff8ff); // enable the gfx layer MT_DCR(DCR_DISP_CNTL, 0xffff0100); // enable osd}static void init_denc(int fmt){ unsigned long reg0, reg1, reg_mux; /*-------------------------------------------------------------------------+ | Set up the video decoder part which is needed for internal denc. +-------------------------------------------------------------------------*/ MT_DCR(VID_CHIP_CTRL, 0); MT_DCR(VID_DISP_BOR, 0); MT_DCR(VID_PTS_CTRL, 32); MT_DCR(VID_DISP_DLY, 0x00004714); reg0 = MF_DCR(DENC0_CR1); reg1 = MF_DCR(DENC1_CR1); reg_mux = MF_DCR(DENCMUX); /*Program the output format of the DENCs. For Entry 5 of the table, denc0 outputs RGB,CVBS; denc1 outputs Y/C select the ports of the dencs. denc0-VP/MP, denc1-MP.*/ MT_DCR(DENC0_CR1, reg0 & 0xFFF3FFFF); MT_DCR(DENC1_CR1, reg1 & 0xFFF3FFFF); // check for pallas 1 compatibility if(ppcMfpvr() == PALLAS_PVR1) { MT_DCR(DENCMUX, reg_mux | 0x23000000); // Pallas PBA } else { MT_DCR(DENCMUX, reg_mux | 0x26000000); // Pallas PBB } switch(fmt) { case TV_FMT_PAL_N: MT_DCR(DENC0_CR1, 0x85100040); MT_DCR(DENC1_CR1, 0x85100040); MT_DCR(VID_DISP_MODE, 0x0088E6C0); // clip Y Cb Cr break; case TV_FMT_PAL_M: MT_DCR(DENC0_CR1, 0x82100040); MT_DCR(DENC1_CR1, 0x82100040); MT_DCR(VID_DISP_MODE, 0x0088E6C0); // clip Y Cb Cr break; case TV_FMT_PAL: // DENC_MODE_PAL: MT_DCR(DENC0_CR1, 0x81100040); MT_DCR(DENC1_CR1, 0x81100040); MT_DCR(VID_DISP_MODE, 0x0088E6C0); // clip Y Cb Cr break; case TV_FMT_NTSC_BAR: MT_DCR(DENC0_CR1, 0x80100020); MT_DCR(DENC1_CR1, 0x80100020); MT_DCR(VID_DISP_MODE, 0x0088E2C0); // Clip Y Cb Cr case TV_FMT_PAL_BAR: // DENC_MODE_PAL: MT_DCR(DENC0_CR1, 0x81100020); MT_DCR(DENC1_CR1, 0x81100020); MT_DCR(VID_DISP_MODE, 0x0088E6C0); // clip Y Cb Cr break; case TV_FMT_NTSC: default: // SECAM is not supported yet MT_DCR(DENC0_CR1, 0x80100040); MT_DCR(DENC1_CR1, 0x80100040); MT_DCR(VID_DISP_MODE, 0x0088E2C0); // Clip Y Cb Cr break; }}int init_graphics(){ if(!confdata.enable_boot_logo || confdata.video_width > BOOTLOGO_MAXWIDTH || confdata.video_height > BOOTLOGO_MAXHEIGHT || confdata.video_left > BOOTLOGO_MAXWIDTH/2 || confdata.video_upper > BOOTLOGO_MAXHEIGHT/2 ) { // confdata is not ok or video is disabled return -1; } boot_logo_buffer.base = (unsigned long)video_buffer; boot_logo_buffer.xsize = (unsigned int)confdata.video_width; boot_logo_buffer.ysize = (unsigned int)confdata.video_height; boot_logo_buffer.line_size = (unsigned int)(confdata.video_width+3) & 0xfffffffc; memset(video_buffer, 0, boot_logo_buffer.line_size*boot_logo_buffer.ysize); osdcb_data.a_displayBufferHOffset = osdcb_data.gsb_alphaWindowHOffset = confdata.video_left; osdcb_data.a_displayBufferVOffset = osdcb_data.gsb_alphaWindowVOffset = confdata.video_upper; osdcb_data.a_displayBufferHSize = osdcb_data.gsb_alphaWindowHSize = boot_logo_buffer.xsize; osdcb_data.a_displayBufferVSize = osdcb_data.gsb_alphaWindowVSize = boot_logo_buffer.ysize; memcpy(osdcb, &osdcb_data, sizeof(osdcb_data)); init_gfx_hardware(); init_denc((int)confdata.video_format); #ifdef DEBUG { int i, j; s1printf("Fill screen with color bar\n"); for(i=0; i<boot_logo_buffer.ysize; i++) for(j=0; j<boot_logo_buffer.xsize; j++) { *(video_buffer + i*boot_logo_buffer.line_size + j) = (i/2)&0xff; } } #endif return 0;}int gfx_set_palette(unsigned char *pal, unsigned int start, int count){ unsigned int i; if(start > 255) return -1; if(start + count > 256) count = 256-start; for(i=0; i<count; i++) { osdcb->pal[i+start].r = pal[i*3]; osdcb->pal[i+start].g = pal[i*3+1]; osdcb->pal[i+start].b = pal[i*3+2]; } return i;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?