int load_565rle_image_onfb(struct fb_info *info, char *filename, int start_x, int start_y) { int fd, err = 0; unsigned count, max; unsigned short *data, *bits, *ptr; if( info == NULL ) { info = registered_fb[0]; } if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); return -ENOENT; } count = (unsigned)sys_lseek(fd, (off_t)0, 2); if (count == 0) { sys_close(fd); err = -EIO; goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if ((unsigned)sys_read(fd, (char *)data, count) != count) { err = -EIO; goto err_logo_free_data; } max = fb_width(info) * fb_height(info); ptr = data; bits = (unsigned short *)(info->screen_base+(fb_width(info)*start_y)*2); while (count > 3) { unsigned n = ptr[0]; if (n > max) break; memset16(bits, ptr[1], n << 1); bits += n; max -= n; ptr += 2; count -= 4; } err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
bool_t __lcd_fill_rect_bm(struct RectBitmap *dst_bitmap, struct Rectangle *Target, struct Rectangle *Focus, u32 Color0,u32 Color1,u32 Mode) { u32 y; u16 pixel; u16 *dst_offset; if(Mode != CN_FILLRECT_MODE_N) return false; if(dst_bitmap->PixelFormat != CN_SYS_PF_RGB565) return false; pixel = GK_ConvertRGB24ToPF(CN_SYS_PF_RGB565,Color0); dst_offset = (u16*)((ptu32_t)dst_bitmap->bm_bits + Focus->top * dst_bitmap->linebytes); dst_offset += Focus->left; for(y = Focus->top; y < Focus->bottom; y++) { memset16(dst_offset,pixel,(Focus->right-Focus->left)); dst_offset += dst_bitmap->linebytes >> 1; } return true; }
void * memset(void *v, int c, unsigned _n) { char *p; unsigned n0; unsigned n = _n; if (n == 0) return 0; p = v; while (n > 0 && ((uintptr_t)p & 7)) { *p++ = c; n--; } if(n >= 16 && ((uintptr_t)p & 3) == 0) { n0 = (n/16)*16; memset16((uint32_t*)p,c,n0); n -= n0; p += n0; } while (n > 0) { *p++ = c; n--; } return v; }
int load_image_display(void) { struct fb_info *info; unsigned max; unsigned short *bits, *ptr; printk(KERN_WARNING "%s: \n", __FUNCTION__); info = registered_fb[0]; if( !info ) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __FUNCTION__); return -ENODEV; } max = fb_width(info) * fb_height(info); ptr = data; //bits = (unsigned short *)(info->screen_base) + (info->var.xres *info->var.yoffset * (info->var.bits_per_pixel/8)); bits = (unsigned short *)(info->screen_base) ; while (count > 3) { unsigned n = ptr[0]; if (n > max) break; memset16(bits, ptr[1], n << 1); bits += n; max -= n; ptr += 2; count -= 4; } return 0; }
// init backrounds - if palette == 1 init only palette - do nothing else, otherwise zero out palette void init_flowers_bg3(u16 palette) { int ii, loop; u16 *moo; u16 *srcmoo; if (palette) { for (ii = 0; ii < 256; ii++) { pal_bg_mem[ii] = map_tilesPal[ii]; } } else { memset16(pal_bg_mem, 0, 256); // life background bg_init(&bg2, 3, TB, MAP, BG_AFF_256 | BG_AFF_WRAP); bg_set_pos(&bg2, 0, 0); moo = (u16*)tl_mem[TB]; srcmoo = (u16*)map_tilesData; for(loop = 0; loop < map_tilesLen/2; loop++) { //load tile image data moo[loop] = srcmoo[loop]; } // bg3 bg_init(&bg3, 2, TB, 16, BG_AFF_256 | BG_AFF_WRAP); bg_set_pos(&bg3, 0, 0); srcmoo = (u16*)wtf_map; for (ii = 0; ii < 32*32/2; ii++) { bg3.map[ii] = srcmoo[ii]; } } }
void clear_scr(void) { int istate = get_intr_state(); disable_intr(); memset16(vmem, VMEM_CHAR(' ', LTGRAY, BLACK), WIDTH * HEIGHT); start_line = 0; set_start_line(0); set_cursor(0, 0); set_intr_state(istate); }
void __attribute__ ((long_call)) resetArm9() { int i, reg; for(i=0; i<4; i++) { DMA_CR(i) = 0;//Reset DMA. DMA_SRC(i) = 0; DMA_DEST(i) = 0; TIMER_CR(i) = 0;//Reset timers. TIMER_DATA(i) = 0; if(DSi_mode) { for(reg=0; reg<0x1c; reg+=4)*((u32*)(0x04004104 + ((i*0x1c)+reg))) = 0;//Reset NDMA. } } VRAM_CR = (VRAM_CR & 0xffff0000) | 0x00008080;//This is from bootloader. //This DMA gfx reset code is from bootloader boot.c. dmaFillWords( 0, (void*)0x04000000, 0x56); //clear main display registers dmaFillWords( 0, (void*)0x04001000, 0x56); //clear sub display registers REG_DISPSTAT = 0; REG_DISPCNT = 0; REG_DISPCNT_SUB = 0; for(i=0; i<7; i++)//Clear VRAM. { if(i==2)continue; ((vu8*)0x04000240)[i] = 0x80; } VRAM_H_CR = 0x80; VRAM_I_CR = 0x80; memset16((void*)0x6800000, 0, 0xa4000); for(i=0; i<7; i++)//Reset VRAM. { if(i==2)continue; ((vu8*)0x04000240)[i] = 0; } VRAM_H_CR = 0; VRAM_I_CR = 0; memset((void*)0x05000000, 0, 0x800);//Clear palettes. memset((void*)0x07000000, 0, 0x800);//Clear OAM. memset(SPRITE_GFX, 0, 128 * 1024); memset(SPRITE_GFX_SUB, 0, 128 * 1024); REG_POWERCNT = 0x820f; WRAM_CR = 0x03; REG_EXMEMCNT = 0xE880; }
void cls() { unsigned blank; int i; blank = 0x20 | (attrib << 8); for(i = 0; i < ROWS/*25*/; i++) memset16 (textmemptr + i * COLS, blank, COLS); csr_x = 0; csr_y = 0; move_csr(); }
void clears() { int i; uint16_t buf = 0; buf = 0x20 | (attribut << 8); for(i=0;i<HEIGHT;i++) { memset16(videoptr + i * WIDTH, buf, WIDTH); } cx = cy = 0; move_cursor(); }
/************************************************************************** * Write blanks to the entire buffer of the selected console. * console - The address of the selected console. **************************************************************************/ void video_clrscr( console_t *console ) { u32int flags; disable_and_save_interrupts(flags); memset16((u16int *)(console->vid_buffer ), BLANK, crt_width*crt_height*2); console->cursor_x = 0; console->cursor_y = 0; // Update the cursor position only for current console. if( console==get_console_addr(0) ) video_move_cursor( console->cursor_x, console->cursor_y); restore_interrupts(flags); }
void terminal_initialize() { uint16_t vga_entry; terminal_row = 0; terminal_column = 0; move_csr(); terminal_color = make_color(COLOR_WHITE, COLOR_BLACK); terminal_buffer = (uint16_t *) VGA_BUFFER; vga_entry = make_vgaentry(FILLCHAR, terminal_color); memset16(terminal_buffer, vga_entry, VGA_WIDTH * VGA_HEIGHT); VGA_BUFFER_SIZE = VGA_WIDTH * VGA_HEIGHT; }
void scroll(void) { unsigned blank, temp; blank = 0x20 | (attrib << 8); if(csr_y >= ROWS/*25*/) { temp = csr_y - ROWS/*25*/ + 1; memcpy ((unsigned char *)textmemptr, (const unsigned char *)textmemptr + temp * COLS, (ROWS/*25*/ - temp) * COLS * 2); memset16 (textmemptr + (ROWS/*25*/ - temp) * COLS, blank, COLS); csr_y = ROWS/*25*/ - 1; } }
void scroll_scr(void) { int new_line, istate = get_intr_state(); disable_intr(); if(++start_line > VIRT_HEIGHT - HEIGHT) { /* The bottom of the visible range reached the end of our text buffer. * Copy the rest of the lines to the top and reset start_line. */ memcpy(vmem, vmem + start_line * WIDTH, (HEIGHT - 1) * WIDTH * 2); start_line = 0; } /* clear the next line that will be revealed by scrolling */ new_line = start_line + HEIGHT - 1; memset16(vmem + new_line * WIDTH, VMEM_CHAR(' ', LTGRAY, BLACK), WIDTH); set_start_line(start_line); set_intr_state(istate); }
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ int load_565rle_image(char *filename, bool bf_supported) { struct fb_info *info; int fd, count, err = 0; unsigned max; unsigned short *data, *bits, *ptr; #ifndef CONFIG_FRAMEBUFFER_CONSOLE struct module *owner; #endif int pad; info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } #ifndef CONFIG_FRAMEBUFFER_CONSOLE owner = info->fbops->owner; if (!try_module_get(owner)) return -ENODEV; if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) { module_put(owner); return -ENODEV; } #endif fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); return -ENOENT; } count = sys_lseek(fd, (off_t)0, 2); if (count <= 0) { err = -EIO; goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if (sys_read(fd, (char *)data, count) != count) { err = -EIO; goto err_logo_free_data; } max = fb_width(info) * fb_height(info); ptr = data; if (bf_supported && (info->node == 1 || info->node == 2)) { err = -EPERM; pr_err("%s:%d no info->creen_base on fb%d!\n", __func__, __LINE__, info->node); goto err_logo_free_data; } if (info->screen_base) { bits = (unsigned short *)(info->screen_base); while (count > 3) { unsigned n = ptr[0]; if (n > max) break; if (info->var.bits_per_pixel >= 24) { pad = memset16_rgb8888(bits, ptr[1], n << 1, info); bits += n << 1; bits += pad; } else { memset16(bits, ptr[1], n << 1); bits += n; } max -= n; ptr += 2; count -= 4; } } err = 0; err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
void lcd_init_device(void) { if(!_lcd_enabled()) { lcd_display_on(true); enable_venc(true); /* Set LCD values in Video Encoder */ IO_VID_ENC_VMOD &= 0x8800; /* Clear all values */ IO_VID_ENC_VMOD |= (VENC_VMOD_DACPD | VENC_VMOD_VMD | VENC_VMOD_ITLC | VENC_VMOD_VDMD(2)); /* set mode to RGB666 parallel 16 bit */ IO_VID_ENC_VDCTL &= 0x8FE8; /* Clear all values */ IO_VID_ENC_VDCTL |= (VENC_VDCTL_VCLKP | VENC_VDCTL_DOMD(2)), IO_VID_ENC_VDPRO = VENC_VDPRO_PFLTR; IO_VID_ENC_SYNCTL &= 0xE000; /* Clear all values */ IO_VID_ENC_SYNCTL |= (VENC_SYNCTL_VPL | VENC_SYNCTL_HPL); IO_VID_ENC_HSDLY = 0; IO_VID_ENC_HSPLS = 0x12; IO_VID_ENC_HSTART = 0x1B; IO_VID_ENC_HVALID = 0x140; IO_VID_ENC_HINT = 0x168; IO_VID_ENC_VSDLY = 0; IO_VID_ENC_VSPLS = 3; IO_VID_ENC_VSTART = 5; IO_VID_ENC_VVALID = 0xF0; IO_VID_ENC_VINT = 0x118; IO_VID_ENC_RGBCTL &= 0x088; /* Clear all values */ IO_VID_ENC_RGBCTL |= VENC_RGBCTL_DFLTR; IO_VID_ENC_RGBCLP = VENC_RGBCLP_UCLIP(0xFF); IO_VID_ENC_LCDOUT &= 0xFE00; /* Clear all values */ IO_VID_ENC_LCDOUT |= (VENC_LCDOUT_OEE | VENC_LCDOUT_FIDS); IO_VID_ENC_DCLKCTL &= 0xC0C0; /* Clear all values */ IO_VID_ENC_DCLKCTL |= VENC_DCLKCTL_DCKEC; IO_VID_ENC_DCLKPTN0 = 1; DM320_REG(0x0864) = 0; /* ???? */ } else lcd_on = true; /* Based on lcd-mr500.c from Catalin Patulea */ /* Clear the Frame */ memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT); IO_OSD_MODE = 0x00ff; IO_OSD_VIDWINMD = 0x0002; IO_OSD_OSDWINMD0 = 0x2001; IO_OSD_OSDWINMD1 = 0x0002; IO_OSD_ATRMD = 0x0000; IO_OSD_RECTCUR = 0x0000; unsigned int addr; IO_OSD_OSDWIN0OFST = (LCD_WIDTH*16) / 256; addr = ((unsigned int)FRAME-CONFIG_SDRAM_START) / 32; IO_OSD_OSDWINADH = addr >> 16; IO_OSD_OSDWIN0ADL = addr & 0xFFFF; #ifndef ZEN_VISION IO_OSD_BASEPX = 26; IO_OSD_BASEPY = 5; #else IO_OSD_BASEPX = 80; IO_OSD_BASEPY = 0; #endif IO_OSD_OSDWIN0XP = 0; IO_OSD_OSDWIN0YP = 0; IO_OSD_OSDWIN0XL = LCD_WIDTH; IO_OSD_OSDWIN0YL = LCD_HEIGHT; IO_VID_ENC_VDCTL |= VENC_VDCTL_VCLKE; /* Enable VCLK */ IO_VID_ENC_VMOD |= VENC_VMOD_VENC; /* Enable video encoder */ IO_VID_ENC_SYNCTL |= VENC_SYNCTL_SYE; /* Enable sync output */ IO_VID_ENC_VDCTL &= ~VENC_VDCTL_DOMD(3); /* Normal digital data output */ }
int load_888rle_image(char *filename) { struct fb_info *info; int fd, count, err = 0; unsigned max; unsigned short *data, *ptr; char *bits; printk(KERN_INFO "%s: load_888rle_image filename: %s\n", __func__, filename); info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); return -ENOENT; } count = sys_lseek(fd, (off_t)0, 2); if (count <= 0) { err = -EIO; goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if (sys_read(fd, (char *)data, count) != count) { printk(KERN_WARNING "%s: Can not read data\n", __func__); err = -EIO; goto err_logo_free_data; } max = fb_width(info) * fb_height(info); ptr = data; bits = (char *)(info->screen_base); while (count > 3) { unsigned n = ptr[0]; if (n > max) break; if (info->var.bits_per_pixel/8 == 4) memset32(bits, ptr[1], n << 1); else memset16(bits, ptr[1], n << 1); bits += info->var.bits_per_pixel/8*n; max -= n; ptr += 2; count -= 4; } err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
MusicEngine::MusicEngine() { memset16(buffer, 0, 17); }
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ int load_565rle_image(char *filename) { struct fb_info *info; int fd, count, err = 0; unsigned max; #ifdef CONFIG_PANTECH_FB_24BPP_RGB888 IBUF_TYPE *data, *bits, *ptr; #else unsigned short *data, *bits, *ptr; #endif info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); return -ENOENT; } count = sys_lseek(fd, (off_t)0, 2); if (count <= 0) { err = -EIO; goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if (sys_read(fd, (char *)data, count) != count) { err = -EIO; goto err_logo_free_data; } max = fb_width(info) * fb_height(info); ptr = data; #ifdef CONFIG_PANTECH_FB_24BPP_RGB888 bits = (IBUF_TYPE *)(info->screen_base); #else bits = (unsigned short *)(info->screen_base); #endif while (count > 3) { unsigned n = ptr[0]; if (n > max) break; #ifdef CONFIG_PANTECH_FB_24BPP_RGB888 memset32((unsigned int *)bits, ptr[1], n << 2); #else memset16(bits, ptr[1], n << 1); #endif bits += n; max -= n; ptr += 2; count -= 4; } err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
/* Clear the current viewport */ void lcd_clear_viewport(void) { fb_data *dst, *dst_end; int x, y, width, height; int len, step; x = current_vp->x; y = current_vp->y; width = current_vp->width; height = current_vp->height; #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; /* clip image in viewport in screen */ if (x < 0) { width += x; x = 0; } if (y < 0) { height += y; y = 0; } if (x + width > LCD_WIDTH) width = LCD_WIDTH - x; if (y + height > LCD_HEIGHT) height = LCD_HEIGHT - y; #endif len = STRIDE_MAIN(width, height); step = STRIDE_MAIN(ROW_INC, COL_INC); dst = FBADDR(x, y); dst_end = FBADDR(x + width - 1 , y + height - 1); if (current_vp->drawmode & DRMODE_INVERSEVID) { do { memset16(dst, current_vp->fg_pattern, len); dst += step; } while (dst <= dst_end); } else { if (!lcd_backdrop) { do { memset16(dst, current_vp->bg_pattern, len); dst += step; } while (dst <= dst_end); } else { do { memcpy(dst, (void *)((long)dst + lcd_backdrop_offset), len * sizeof(fb_data)); dst += step; } while (dst <= dst_end); } } if (current_vp == &default_vp) lcd_scroll_stop(); else lcd_scroll_stop_viewport(current_vp); }
void drawHLineEx(uint16 x, uint16 y, uint16 lineLen, COLOR color) { memset16(&Pix(x, y), color, lineLen); }
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ int load_565rle_image(char *filename) { struct fb_info *info; int fd, count, err = 0; unsigned max; unsigned short *data, *bits, *ptr; info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); return -ENOENT; } count = sys_lseek(fd, (off_t)0, 2); if (count <= 0) { err = -EIO; goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if (sys_read(fd, (char *)data, count) != count) { err = -EIO; goto err_logo_free_data; } max = fb_width(info) * fb_height(info); ptr = data; if (info->node == 1 || info->node == 2) { err = -EPERM; pr_err("%s:%d no info->creen_base on fb%d!\n", __func__, __LINE__, info->node); goto err_logo_free_data; } bits = (unsigned short *)(info->screen_base); while (count > 3) { unsigned n = ptr[0]; if (n > max) break; memset16(bits, ptr[1], n << 1); bits += n; max -= n; ptr += 2; count -= 4; } err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ int load_565rle_image(char *filename) { struct fb_info *info; int fd, err = 0; unsigned count, max, width, stride, line_pos = 0; unsigned short *data, *ptr; unsigned char *bits; info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } if (!info->screen_base) { printk(KERN_WARNING "Framebuffer memory not allocated\n"); return -ENOMEM; } fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); return -ENOENT; } count = sys_lseek(fd, (off_t)0, 2); if (count <= 0) { err = -EIO; goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if (sys_read(fd, (char *)data, count) != count) { err = -EIO; goto err_logo_free_data; } width = fb_width(info); stride = fb_linewidth(info); max = width * fb_height(info); ptr = data; bits = (unsigned char *)(info->screen_base); while (count > 3) { int n = ptr[0]; if (n > max) break; max -= n; while (n > 0) { unsigned int j = (line_pos + n > width ? width-line_pos : n); if (fb_depth(info) == 2) memset16(bits, ptr[1], j << 1); else { unsigned int widepixel = ptr[1]; /* * Format is RGBA, but fb is big * endian so we should make widepixel * as ABGR. */ widepixel = /* red : f800 -> 000000f8 */ (widepixel & 0xf800) >> 8 | /* green : 07e0 -> 0000fc00 */ (widepixel & 0x07e0) << 5 | /* blue : 001f -> 00f80000 */ (widepixel & 0x001f) << 19; memset32(bits, widepixel, j << 2); } bits += j * fb_depth(info); line_pos += j; n -= j; if (line_pos == width) { bits += (stride-width) * fb_depth(info); line_pos = 0; } } ptr += 2; count -= 4; } err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
int sky_lcdc_display_loadingbar(int ratio) { struct fb_info *info; int err = 0; #ifdef CONFIG_PANTECH_FB_24BPP_RGB888 IBUF_TYPE *load_bar; unsigned int i; IBUF_TYPE BAR_COLOR = 0xFFFF; #else unsigned short *load_bar; unsigned short i; unsigned short BAR_COLOR = 0xFFFF; #endif #if defined(CONFIG_MACH_MSM8X55_MINI) const unsigned short ST_X=100, ST_Y=738; const unsigned short SCREEN_WIDTH = 608; const unsigned short BAR_WIDTH =418; #elif defined(CONFIG_MACH_MSM8X55_LASER2) const unsigned short ST_X=40, ST_Y=738; const unsigned short SCREEN_WIDTH = 480; const unsigned short BAR_WIDTH = 400; #else const unsigned short ST_X=100, ST_Y=738; const unsigned short SCREEN_WIDTH = 480; const unsigned short BAR_WIDTH = 441; #endif const unsigned short BAR_HEIGHT = 17; int cr = 0; if (ratio > 100) ratio = 100; cr = (int)(ratio * BAR_WIDTH/100 ); info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n",__FUNCTION__); return -ENODEV; } #ifdef CONFIG_PANTECH_FB_24BPP_RGB888 //#ifdef CONFIG_MACH_MSM8X55_MINI // load_bar = (IBUF_TYPE *)(info->screen_base) + (SCREEN_WIDTH * ST_Y + ST_X); //#endif load_bar = (IBUF_TYPE *)(info->screen_base) + SCREEN_WIDTH * ST_Y + ST_X; #else load_bar = (unsigned short *)(info->screen_base) + SCREEN_WIDTH * ST_Y + ST_X; #endif for (i=0 ; i<BAR_HEIGHT; i++) { BAR_COLOR = loading_progress_t[i]; #ifdef CONFIG_PANTECH_FB_24BPP_RGB888 memset32((unsigned int *)load_bar, BAR_COLOR, cr<<2); #else memset16(load_bar, BAR_COLOR, cr<<1); #endif load_bar = load_bar + SCREEN_WIDTH; } return err; }
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ int load_565rle_image(char *filename) { struct fb_info *info; int fd, err = 0; unsigned count, max; unsigned short *data, *bits, *ptr; printk("LUYA!!!!1 load_565rle_image\n"); info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } printk("LUYA!!!!2 load_565rle_image\n"); fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); return -ENOENT; } max = fb_width(info) * fb_height(info)*2; printk("LUYA!!!!max=%d\n",max); count = (unsigned)sys_lseek(fd, (off_t)0, 2); printk("LUYA!!!!count=%d\n",count); if (count == 0) { sys_close(fd); err = -EIO; goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if ((unsigned)sys_read(fd, (char *)data, count) != count) { err = -EIO; goto err_logo_free_data; } ptr = data+27; bits = (unsigned short *)(info->screen_base); while (max > 0) { // unsigned n = ptr[0]; // if (n > max) // break; memset16(bits, ptr[0], 1 << 1); bits += 1; max -= 1; ptr += 1; // count -= 1; } err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */ static int load_565rle_image(char *filename) { struct fb_info *info; int fd, err = 0; unsigned max, width, stride, line_pos = 0; unsigned short *data, *ptr; unsigned char *bits; signed count; info = registered_fb[0]; if (!info) { printk(KERN_ERR "%s: Can not access framebuffer\n", __func__); return -ENODEV; } fd = sys_open(filename, O_RDONLY, 0); if (fd < 0) { printk(KERN_ERR "%s: Can not open %s\n", __func__, filename); return -ENOENT; } count = sys_lseek(fd, (off_t)0, 2); if (count <= 0) { err = -EIO; printk(KERN_ERR "%s: sys_lseek failed %s\n", __func__, filename); goto err_logo_close_file; } sys_lseek(fd, (off_t)0, 0); data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_ERR "%s: Can not alloc data\n", __func__); err = -ENOMEM; goto err_logo_close_file; } if (sys_read(fd, (char *)data, count) != count) { err = -EIO; printk(KERN_ERR "%s: sys_read failed %s\n", __func__, filename); goto err_logo_free_data; } width = fb_width(info); stride = fb_linewidth(info); max = width * fb_height(info); ptr = data; bits = (unsigned char *)(info->screen_base); while (count > 3) { int n = ptr[0]; if (n > max) break; max -= n; while (n > 0) { unsigned int j = (line_pos+n > width ? width-line_pos : n); if (fb_depth(info) == 2) { memset16(bits, ptr[1], j << 1); } else { /* Should probably add check for framebuffer * format here*/ unsigned int widepixel = ptr[1]; widepixel = (widepixel & 0xf800) << (19-11) | (widepixel & 0x07e0) << (10-5) | (widepixel & 0x001f) << (3-0) | 0xff000000; /* Set alpha channel*/ memset32(bits, widepixel, j << 2); } bits += j * fb_depth(info); line_pos += j; n -= j; if (line_pos == width) { bits += (stride-width) * fb_depth(info); line_pos = 0; } } ptr += 2; count -= 4; } err_logo_free_data: kfree(data); err_logo_close_file: sys_close(fd); return err; }
/*MTD-MM-CL-DrawLogo-00+[*/ int fih_load_565rle_image(char *filename) { struct fb_info *info = NULL; struct file *filp = NULL; unsigned short *ptr = NULL; unsigned char *bits = NULL; unsigned char *data = NULL; unsigned max = 0; int bits_count = 0, count = 0, err = 0; mm_segment_t old_fs = get_fs(); set_fs (get_ds()); printk(KERN_INFO "[DISPLAY] %s\n", __func__); info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } filp = filp_open(filename, O_RDONLY, 0); if (IS_ERR(filp)) { printk(KERN_ERR "%s: Can not open %s\n", __func__, filename); err = -ENOENT; goto error2; } count = filp->f_dentry->d_inode->i_size; data = kmalloc(count, GFP_KERNEL); if (!data) { printk(KERN_ERR "%s: Can not alloc data\n", __func__); err = -ENOMEM;; goto error1; } if (filp->f_op->read(filp, data, count, &filp->f_pos) < 0) { printk(KERN_ERR "%s: read file error?\n", __func__); err = -EIO; goto error1; } max = fb_width(info) * fb_height(info); ptr = (unsigned short *)data; bits = (unsigned char *)(info->screen_base); while (count > 3) { unsigned n = ptr[0]; if (n > max) break; bits_count = n; #if defined(CONFIG_FB_MSM_DEFAULT_DEPTH_RGBA8888) while (bits_count--) { *bits++ = (ptr[1] & 0xF800) >> 8; *bits++ = (ptr[1] & 0x7E0) >> 3; *bits++ = (ptr[1] & 0x1F) << 3; *bits++ = 0xFF; } #else memset16(bits, ptr[1], n << 1); bits += n; #endif max -= n; ptr += 2; count -= 4; } error1: filp_close(filp, NULL); kfree(data); error2: set_fs(old_fs); return err; }
/** * @brief Ìî³äÕûÌåÆÁÄ» * @param [in] color ÑÕÉ« £¬16É« * @return * @date 2013/8/8 * @note * @code * @endcode * @pre * @see */ void LCDFbClear(unsigned short color){ memset16(&Pix(0,0),color,800*600); }
void videoInit() { // Blank screen for faster loading REG_DISPCNT = DCNT_BLANK; // Completely clear VRAM memset16(vid_mem, 0x0000, 49152); // BACKGROUND SETUP // // Set background 0 control register // -Render this BG on bottom // -Tile indexing starts in charblock 0 // -Screen-entry indexing starts in charblock 3 / screenblock 24 // -4 bits per pixel // -512 x 512 pixels - 32 x 32 tiles - 1 x 1 screenblocks REG_BG0CNT = BG_PRIO(3) | BG_CBB(0) | BG_SBB(24) | BG_4BPP | BG_REG_32x32; // Set background 2 control register - Bottom text screen // -Render this BG on top // -Tile indexing starts in charblock 0 // -Screen-entry indexing starts in charblock 3 / screenblock 29 // -4 bits per pixel // -256 x 256 pixels - 32 x 32 tiles - 1 x 1 screenblocks REG_BG2CNT = BG_PRIO(1) | BG_CBB(0) | BG_SBB(29) | BG_4BPP | BG_REG_32x32; // Set background 3 control register - Top Text Screen // -Render this BG on top // -Tile indexing starts in charblock 0 // -Screen-entry indexing starts in charblock 3 / screenblock 28 // -4 bits per pixel // -256 x 256 pixels - 32 x 32 tiles - 1 x 1 screenblocks REG_BG3CNT = BG_PRIO(0) | BG_CBB(0) | BG_SBB(28) | BG_4BPP | BG_REG_32x32; // Load background palette memcpy16(&pal_bg_mem[0], g_bgPal, g_bgPalLen >> 1); // Load background tiles // Load Font tiles memcpy16(&tile_mem[0][g_galaxulonFont_TilesPos], g_galaxulonFont_Tiles, g_galaxulonFont_TilesLen >> 1); // Load other BG tiles memcpy16(&tile_mem[0][g_blankBG_TilesPos], g_blankBG_Tiles, g_blankBG_TilesLen >> 1); memcpy16(&tile_mem[0][g_assertTile_TilesPos], g_assertTile_Tiles, g_assertTile_TilesLen >> 1); memcpy16(&tile_mem[0][g_demo_starsTilesPos], g_demo_starsTiles, g_demo_starsTilesLen >> 1); // Clear Background screenmaps - set the four background screenblocks memset32(&se_mem[24], 0x00000000, (SBB_SIZE/4)); // OAM SETUP // // Load OAM palette memcpy16(pal_obj_mem, g_spritePal, g_spritePalLen >> 1); // Load OAM tiles // Init Player sprite memcpy16(&tile_mem_obj[0][g_playerSpriteTilesPos], g_playerSpriteTiles, g_playerSpriteTilesLen >> 1); // Init bullet sprites memcpy16(&tile_mem_obj[0][g_bulletSpriteTilesPos], g_bulletSpriteTiles, g_bulletSpriteTilesLen >> 1); memcpy16(&tile_mem_obj[0][g_missileSpriteTilesPos], g_missileSpriteTiles, g_missileSpriteTilesLen >> 1); // Init display sprites memcpy16(&tile_mem_obj[0][g_bullet_selection1TilesPos], g_bullet_selection1Tiles, g_bullet_selection1TilesLen >> 1); memcpy16(&tile_mem_obj[0][g_bullet_selection2TilesPos], g_bullet_selection2Tiles, g_bullet_selection2TilesLen >> 1); // Init enemy sprites memcpy16(&tile_mem_obj[0][g_jellyfishTilesPos], g_jellyfishTiles, g_jellyfishTilesLen >> 1); memcpy16(&tile_mem_obj[0][g_mineTilesPos], g_mineTiles, g_mineTilesLen >> 1); memcpy16(&tile_mem_obj[0][g_sharkTilesPos], g_sharkTiles, g_sharkTilesLen >> 1); memcpy16(&tile_mem_obj[0][g_squidTilesPos], g_squidTiles, g_squidTilesLen >> 1); memcpy16(&tile_mem_obj[0][g_crabTilesPos], g_crabTiles, g_crabTilesLen >> 1); // Init upgrade sprites memcpy16(&tile_mem_obj[0][g_extraLife_TilesPos], g_extraLife_Tiles, g_extraLife_TilesLen >> 1); memcpy16(&tile_mem_obj[0][g_extraBomb_TilesPos], g_extraBomb_Tiles, g_extraBomb_TilesLen >> 1); memcpy16(&tile_mem_obj[0][g_primaryFireUp_TilesPos], g_primaryFireUp_Tiles, g_primaryFireUp_TilesLen >> 1); memcpy16(&tile_mem_obj[0][g_secondFireUp_TilesPos], g_secondFireUp_Tiles, g_secondFireUp_TilesLen >> 1); memcpy16(&tile_mem_obj[0][g_shield_TilesPos], g_shield_Tiles, g_shield_TilesLen >> 1); // Load Title screen logo memcpy16(&tile_mem_obj[0][g_galaxulon_titleTilesPos1], g_galaxulon_titleTiles, g_galaxulon_titleTilesLen >> 1); // Clear OAM oam_init(oam_mem, 128); // Setup Display Control Register // -Video mode 0 - tiled // -BG 0, BG 2, and BG 3 enabled // -Enable sprites // -1D sprite-mapping mode REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ_1D | DCNT_BG0 | DCNT_BG2 | DCNT_BG3 | DCNT_OBJ; }
/*MTD-MM-CL-DrawLogo-00+[*/ int fih_load_565rle_image(char *filename) { struct fb_info *info; int count, err = 0; unsigned max; unsigned short *bits, *ptr; unsigned char *data; struct file *filp=NULL; struct inode *inode = NULL; mm_segment_t old_fs = get_fs(); set_fs (KERNEL_DS); info = registered_fb[0]; if (!info) { printk(KERN_WARNING "%s: Can not access framebuffer\n", __func__); return -ENODEV; } filp = filp_open(filename, O_RDONLY, 0); if (IS_ERR(filp)) { printk(KERN_WARNING "%s: Can not open %s\n", __func__, filename); err=-ENOENT; goto error2; } inode = filp->f_dentry->d_inode; count = inode->i_size; data = kmalloc(count, GFP_KERNEL); if(data==NULL) { printk(KERN_WARNING "%s: Can not alloc data\n", __func__); err = -ENOMEM;; goto error1; } if(filp->f_op->read(filp, data, count, &filp->f_pos)<0) { printk(KERN_WARNING"%s:read file error?\n", __func__); err = -EIO; } max = fb_width(info) * fb_height(info); ptr = (unsigned short *)data; bits = (unsigned short *)(info->screen_base); while (count > 3) { unsigned n = ptr[0]; if (n > max) break; memset16(bits, ptr[1], n << 1); bits += n; max -= n; ptr += 2; count -= 4; } error1: filp_close(filp,NULL); kfree(data); error2: set_fs (old_fs); return err; }
/* Fill a rectangular area */ void lcd_fillrect(int x, int y, int width, int height) { unsigned bits = 0; enum fill_opt fillopt = OPT_NONE; fb_data *dst, *dst_end; int len, step; /******************** In viewport clipping **********************/ /* nothing to draw? */ if ((width <= 0) || (height <= 0) || (x >= current_vp->width) || (y >= current_vp->height) || (x + width <= 0) || (y + height <= 0)) return; if (x < 0) { width += x; x = 0; } if (y < 0) { height += y; y = 0; } if (x + width > current_vp->width) width = current_vp->width - x; if (y + height > current_vp->height) height = current_vp->height - y; /* adjust for viewport */ x += current_vp->x; y += current_vp->y; #if defined(HAVE_VIEWPORT_CLIP) /********************* Viewport on screen clipping ********************/ /* nothing to draw? */ if ((x >= LCD_WIDTH) || (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0)) return; /* clip image in viewport in screen */ if (x < 0) { width += x; x = 0; } if (y < 0) { height += y; y = 0; } if (x + width > LCD_WIDTH) width = LCD_WIDTH - x; if (y + height > LCD_HEIGHT) height = LCD_HEIGHT - y; #endif /* drawmode and optimisation */ if (current_vp->drawmode & DRMODE_INVERSEVID) { if (current_vp->drawmode & DRMODE_BG) { if (!lcd_backdrop) { fillopt = OPT_SET; bits = current_vp->bg_pattern; } else fillopt = OPT_COPY; } } else { if (current_vp->drawmode & DRMODE_FG) { fillopt = OPT_SET; bits = current_vp->fg_pattern; } } if (fillopt == OPT_NONE && current_vp->drawmode != DRMODE_COMPLEMENT) return; dst = FBADDR(x, y); dst_end = FBADDR(x + width - 1, y + height - 1); len = STRIDE_MAIN(width, height); step = STRIDE_MAIN(ROW_INC, COL_INC); do { switch (fillopt) { case OPT_SET: memset16(dst, bits, len); break; case OPT_COPY: memcpy(dst, (void *)((long)dst + lcd_backdrop_offset), len * sizeof(fb_data)); break; case OPT_NONE: /* DRMODE_COMPLEMENT */ { fb_data *start = dst; fb_data *end = start + len; do *start = ~(*start); while (++start < end); break; } } dst += step; } while (dst <= dst_end); }