From owner-p4-projects@FreeBSD.ORG Thu Jun 14 23:20:15 2012 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 754241065672; Thu, 14 Jun 2012 23:20:14 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (unknown [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2D44E106566C for ; Thu, 14 Jun 2012 23:20:14 +0000 (UTC) (envelope-from brooks@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [69.147.83.45]) by mx1.freebsd.org (Postfix) with ESMTP id 162F18FC12 for ; Thu, 14 Jun 2012 23:20:14 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id q5ENKDfx060042 for ; Thu, 14 Jun 2012 23:20:13 GMT (envelope-from brooks@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id q5ENKDe2060037 for perforce@freebsd.org; Thu, 14 Jun 2012 23:20:13 GMT (envelope-from brooks@freebsd.org) Date: Thu, 14 Jun 2012 23:20:13 GMT Message-Id: <201206142320.q5ENKDe2060037@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to brooks@freebsd.org using -f From: Brooks Davis To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 212871 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 23:20:15 -0000 http://p4web.freebsd.org/@@212871?ac=10 Change 212871 by brooks@brooks_ecr_current on 2012/06/14 23:20:11 Really remove the code that is now in libde4tc. Affected files ... .. //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#5 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/ctsrd/pictview/pictview.c#5 (text+ko) ==== @@ -42,390 +42,15 @@ #include -#if DIKE -// endian.h not available in Linux? -// #include -#include -#define PNG_DEBUG 3 -#include - -// file descriptors for MTL control and display regions -static int ctrlfd; -static int dispfd; -static int textfd; -static int fademode=0; -volatile static u_int32_t *pfbp; -volatile static u_int16_t *tfbp; -volatile static u_int32_t *mtlctrl; -// frame buffer dimensions -static const int fb_height = 480; -static const int fb_width = 800; - -// fade timing (for crude timing loop) -static const int fb_cross_fade_time = 500; - -// number of lines in the line pattern -static const int num_lines_pattern = 600; -#endif - // send keyboard output to stdout by default static int kbdfd = 0; u_int32_t *fb_buf; -#if DIKE - - -/***************************************************************************** - * hack around endian issue - * TODO: replace with endian library call (but not present in Linux?) - *****************************************************************************/ - -u_int32_t -endian_swap(u_int32_t lend) -{ - u_int32_t bend; - bend = lend & 0xff; - bend = bend<<8; - lend = lend>>8; - - bend |= lend & 0xff; - bend = bend<<8; - lend = lend>>8; - - bend |= lend & 0xff; - bend = bend<<8; - lend = lend>>8; - - bend |= lend & 0xff; - return bend; -} - - - -/***************************************************************************** - * sample touch input - *****************************************************************************/ - -static int touch_x0=0; -static int touch_y0=0; -static int touch_x1=0; -static int touch_y1=0; -static int touch_gesture=0; -static int touch_count=0; -volatile static int touch_tmp=0; - -void -multitouch_pole(void) -{ - /* - int j; - for(j=3; j<8; j++) - touch_tmp += pfbp[j]; // provoke cache line flush - */ - int t_x0 = endian_swap(mtlctrl[3]); - if(t_x0>=0) { // new touch info available - touch_x0 = t_x0; - touch_y0 = endian_swap(mtlctrl[4]); - touch_x1 = endian_swap(mtlctrl[5]); - touch_y1 = endian_swap(mtlctrl[6]); - // note that this final read dequeues - touch_gesture = endian_swap(mtlctrl[7]); - touch_count = touch_gesture>>8; - if(touch_count<0) touch_count=0; // hack - touch_gesture &= 0xff; - } - // else - // t_x0 = mtlctrl[7]; // clear any -1s from FIFO? -} - - -// filter out short lived touch releases -void -multitouch_filter(void) -{ - int j; - multitouch_pole(); - for(j=30000; (j>0) && (touch_count==0); j--) - multitouch_pole(); -} - -// wait for touch release -void -multitouch_release_event(void) -{ - do { - // multitouch_filter(); - multitouch_pole(); - } while(touch_count!=0); -} - - -/***************************************************************************** - * frame buffer routines - * TODO: put in seperate library - *****************************************************************************/ - -void -fb_init(void) -{ - ctrlfd = open("/dev/mtl_reg0", O_RDWR | O_NONBLOCK); - if(ctrlfd < 0) - err(1, "open mtl_reg0"); - - mtlctrl = mmap(NULL, 0x20, PROT_READ | PROT_WRITE, MAP_SHARED, ctrlfd, 0); - if (mtlctrl == MAP_FAILED) - err(1, "mmap mtl_reg0"); - - dispfd = open("/dev/mtl_pixel0", O_RDWR | O_NONBLOCK); - if(dispfd < 0) - err(1, "open mtl_pixel0"); - pfbp = mmap(NULL, 0x177000, PROT_READ | PROT_WRITE, MAP_SHARED, dispfd, 0); - if (pfbp == MAP_FAILED) - err(1, "mmap mtl_pixel0"); - - textfd = open("/dev/mtl_text0", O_RDWR | O_NONBLOCK); - if(textfd < 0) - err(1, "open mtl_text0"); - tfbp = mmap(NULL, 100*40*2, PROT_READ | PROT_WRITE, MAP_SHARED, textfd, 0); - if (tfbp == MAP_FAILED) - err(1, "mmap mtl_text0"); -} - - -inline u_int32_t -fb_colour(int r, int g, int b) -{ - return ((r&0xff)<<8) | ((g&0xff)<<16) | ((b&0xff)<<24); -} - - -inline void -fb_putpixel(int px, int py, int colour) -{ - pfbp[px+py*fb_width] = colour; -} - - -void -fb_fill(int col) -{ - int addr; - for(addr=0; addr<(fb_height*fb_width); addr++) - pfbp[addr] = col; -} - - -void -fb_blend(int blend_text_bg, int blend_text_fg, int blend_pixel, int wash) -{ - mtlctrl[0] = - ((blend_text_bg & 0xff)<<24) | - ((blend_text_fg & 0xff)<<16) | - ((blend_pixel & 0xff)<<8) | - // to avoid a red screen colour wash "attack" indicator from being - // removed, preserve the "wash" value: - //wash; - mtlctrl[0] & 0xff; - // to try the dark red "attack" indicator: - //4; -} - - -void -fb_text_cursor(int x, int y) -{ - mtlctrl[1] = ((y&0xff)<<24) | ((x)<<16); -} - - -// fade the pixel framebuffer to black using the MTL hardware alpha blending -void -fb_fade2off(void) -{ - int b,t; - if(fademode==0) - fb_blend(255,255,255,0); - else - for(b=0; b<256; b++) - for(t=fb_cross_fade_time; t>0; t--) - fb_blend(b,b,255,0); - fademode=0; -} - - -// fade the pixel framebuffer from black using the MTL hardware alpha blending -void -fb_fade2on(void) -{ - int b,t; - if(fademode==1) - fb_blend(0,0,255,0); - else - for(b=0; b<256; b++) - for(t=fb_cross_fade_time; t>0; t--) - fb_blend(255-b,255-b,255,0); - fademode=1; -} - - -void -fb_fade2text(int textbg_alpha) -{ - int b, t; - if(fademode==2) - fb_blend(255,255,0,0); - else - for(b=0; b<256; b++) - for(t=fb_cross_fade_time; t>0; t--) - fb_blend((b>1; - y=dxabs>>1; - px=x1; - py=y1; - - if((x1==x2) && (y1==y2)) - fb_putpixel(x1,y1,colour); - else if (dxabs>=dyabs) { /* the line is more horizontal than vertical */ - for(i=0;i=dxabs) { - y-=dxabs; - py+=sdy; - } - px+=sdx; - fb_putpixel(px,py,colour); - } - } else { /* the line is more vertical than horizontal */ - for(i=0;i=dyabs) { - x-=dyabs; - px+=sdx; - } - py+=sdy; - fb_putpixel(px,py,colour); - } - } -} - -/***************************************************************************** - * some test pattern generators, etc. - *****************************************************************************/ - -/* -void line_pattern() -{ - int x0buf[num_lines_pattern]; - int y0buf[num_lines_pattern]; - int x1buf[num_lines_pattern]; - int y1buf[num_lines_pattern]; - int j; - int x0=10; - int y0=10; - int dx0=3; - int dy0=3; - int x1=200; - int y1=200; - int dx1=2; - int dy1=-2; - const int on_colour = 0xffffffff; // white - const int off_colour = 0xff<<24; // blue - for(j=0; j=num_lines_pattern) j=0; - x0=x0+dx0; if((x0>=fb_width) || (x0<0)) { x0=x0-2*dx0; dx0=-dx0; } - y0=y0+dy0; if((y0>=fb_height) || (y0<0)) { y0=y0-2*dy0; dy0=-dy0; } - x1=x1+dx1; if((x1>=fb_width) || (x1<0)) { x1=x1-2*dx1; dx1=-dx1; } - y1=y1+dy1; if((y1>=fb_height) || (y1<0)) { y1=y1-2*dy1; dy1=-dy1; } - // fb_refresh(); - } -} -*/ - - /* -void -stripy_pixels_fast() -{ - // write stripes to pixel buffer - u_int32_t fb[fb_height][fb_width]; - int x,y,r,g,b; - for(y=0; y>1); - fb_putpixel(x,y,fb_colour(r,g,b)); - } - } -} -*/ - - -/* -void -flash_colours() -{ - int j, r, g, b; - for(j=0; j<8; j++) { - r = (j & 0x1)==0 ? 0 : 0xff; - g = (j & 0x2)==0 ? 0 : 0xff; - b = (j & 0x4)==0 ? 0 : 0xff; - fb_fill(fb_colour(r,g,b)); - } -} -*/ -#endif /* DIKE */ - - -void pen_drawing_clear_screen(void) { int x0,y0; @@ -490,113 +115,6 @@ } -#if DIKE -/***************************************************************************** - * PNG image loader - *****************************************************************************/ - -void -read_png_file(char* file_name, u_int32_t* imgbuf, int maxwidth, int maxheight) -{ - unsigned char header[8]; // 8 is the maximum size that can be checked - size_t tmp; - int x,y; - - int width, height, rowbytes; - png_byte colour_type; - png_byte bit_depth; - - png_structp png_ptr; - png_infop info_ptr; - int number_of_passes; - png_bytep * row_pointers; - int bppx; // bytes per pixel - - /* open file and test for it being a png */ - FILE *fp = fopen(file_name, "rb"); - if (!fp) - err(1,"fopen - failed to read from %s",file_name); - tmp=fread(header, 1, 8, fp); - if (png_sig_cmp(header, 0, 8)) - err(1,"file $s not PNG", file_name); - - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) - err(1,"png_create_read_struct failed"); - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - err(1,"png_create_info_struct failed"); - - if (setjmp(png_jmpbuf(png_ptr))) - err(1,"Error during init_io"); - - png_init_io(png_ptr, fp); - png_set_sig_bytes(png_ptr, 8); - - png_read_info(png_ptr, info_ptr); - - width = png_get_image_width(png_ptr, info_ptr); - height = png_get_image_height(png_ptr, info_ptr); - colour_type = png_get_color_type(png_ptr, info_ptr); - bit_depth = png_get_bit_depth(png_ptr, info_ptr); - - //printf("image=%s, width=%1d, height=%1d, colour_type=%1d, bit_depth=%1d\n", - // file_name, width, height, colour_type, bit_depth); - - if((colour_type != PNG_COLOR_TYPE_RGB) && (colour_type != 6)) - err(1,"colour type is not RGB - panic!"); - if(bit_depth != 8) - err(1,"bit depth is not 8 - panic!"); - - number_of_passes = png_set_interlace_handling(png_ptr); - png_read_update_info(png_ptr, info_ptr); - - /* read file */ - if (setjmp(png_jmpbuf(png_ptr))) - err(1,"Error during read_image"); - - row_pointers = (png_bytep*) malloc(sizeof(png_bytep) * height); - - if (bit_depth == 16) - rowbytes = width*8; - else - rowbytes = width*4; - - for (y=0; ymaxheight) height=maxheight; - if(width>maxwidth) width=maxwidth; - - bppx = 3; - if(colour_type==6) - bppx = 4; - for (y=0; y