# HG changeset patch # User yutaka@localhost.localdomain # Date 1270884562 -32400 # Node ID 39d405bc46b799869e3b37a7fd7ead8ab16b0d72 # Parent c2ce9efe2a52cf743759830f2c5662d735731089 add fb diff -r c2ce9efe2a52 -r 39d405bc46b7 Makefile --- a/Makefile Wed Apr 07 17:47:12 2010 +0900 +++ b/Makefile Sat Apr 10 16:29:22 2010 +0900 @@ -6,7 +6,7 @@ PPECC = g++ PPELIB = -lspe2 SPECC = spu-g++ -SPELIB = +SPELIB = INC = -I include @@ -22,6 +22,9 @@ $(SPETARGET): $(SPEOBJ) $(SPECC) $(SPELIB) $(INC) $(SPESRC) $(TASKSRC) -o $@ +run: + sudo ./$(PPETARGET) + clean: rm -f $(PPETARGET) $(SPETARGET) rm -f ppe/*.o spe/*.o task/*.o diff -r c2ce9efe2a52 -r 39d405bc46b7 include/fb.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/fb.h Sat Apr 10 16:29:22 2010 +0900 @@ -0,0 +1,33 @@ +#ifndef FB_H +#define FB_H + +#define DEVICE_NAME "/dev/fb0" +#define DIV_BYTE 8 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct { + + char *pixels; + int size; + int width; + int height; + int bpp; + int fd; + +} fb_t; + +/* function prototype */ +void send_current_error_msg(const char *ptr); +void send_current_information(const char *ptr); +fb_t get_fbdev_addr(void); + +#endif diff -r c2ce9efe2a52 -r 39d405bc46b7 ppe/Menu.cc --- a/ppe/Menu.cc Wed Apr 07 17:47:12 2010 +0900 +++ b/ppe/Menu.cc Sat Apr 10 16:29:22 2010 +0900 @@ -3,6 +3,7 @@ #include "Menu.h" #include "Sys.h" #include "params.h" +#include "fb.h" //headk_num と send_param_head の値を必ず返さないと、動作しない @@ -10,41 +11,55 @@ menu(int &list_num) { list_num = SPE_NUM; - int all_task_num = SPE_NUM*10; - int task_size = 16*1024; + + fb_t fb = get_fbdev_addr(); + int max_size = MAX_DMA_SIZE - sizeof(task_head_t); + int all_task_num = fb.height; + int line_size = fb.width * fb.bpp / DIV_BYTE; - int in_size = (task_size - sizeof(task_head_t)); - int out_size = (task_size - sizeof(task_head_t)); + // line num per task + int lnpt = max_size / line_size; + int out_size = lnpt * line_size; + int list_length = (all_task_num / list_num) / lnpt; + + int in_size = sizeof(int)*4; + int real_in_size = sizeof(int)*2; task_head_t *list_head = (task_head_t*)allocate(sizeof(task_head_t)*list_num); - int list_length = all_task_num / list_num; + int index = 0; for (int i = 0; i < list_num; i++) { - task_t *tail = entry_head(&list_head[i]); + task_t *head = entry_head(&list_head[i]); for (int j = 0; j < list_length; j++) { - task_t *task = task_allocate(in_size, out_size); + task_t *task = task_allocate(in_size, 0); + task->head->ea_out = (unsigned long long) (unsigned long) &fb.pixels[index*out_size]; + task->head->size_out = out_size; int *in = (int*)task->input; - for (int k = 0; k < in_size / sizeof(int); k++) { - in[k] = k; - } + in[0] = index*out_size; + in[1] = (index+1)*out_size; - int pin_in = 0; + int pin_in = in_size - real_in_size; int pin_out = 0; set_pin(task, pin_in, pin_out); - tail = add_list(tail, task); + head = add_list(head, task); + + index++; } } printf("return run\n"); - + + //munmap(fb.pixels, fb.size); + //close(fb.fd); + return list_head; } diff -r c2ce9efe2a52 -r 39d405bc46b7 ppe/fb.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ppe/fb.cc Sat Apr 10 16:29:22 2010 +0900 @@ -0,0 +1,80 @@ +#include "fb.h" +using namespace std; + +void send_current_error_msg(const char *ptr) +{ + fprintf( stderr , "%s\n" , ptr ); +} + +void send_current_information(const char *ptr) +{ + fprintf( stdout , "%s\n" , ptr ); +} + +fb_t +get_fbdev_addr(void) +{ + int fd_framebuffer ; + struct fb_var_screeninfo vinfo; + struct fb_fix_screeninfo finfo; + long int screensize ; + //long int location; + char *fbptr ; + char tmp[DIV_BYTE*10]; + + //int x , y ; + int xres,yres,vbpp,line_len; + //unsigned short tcolor ; + + /* 読み書き用にファイルを開く */ + fd_framebuffer = open( DEVICE_NAME , O_RDWR); + if ( !fd_framebuffer ) { + send_current_error_msg("Framebuffer device open error !"); + exit(1); + } + send_current_information("The framebuffer device was opened !"); + + /* 固定スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_FSCREENINFO , &finfo ) ) { + send_current_error_msg("Fixed information not gotton !"); + exit(2); + } + + /* 変動スクリーン情報取得 */ + if ( ioctl( fd_framebuffer , FBIOGET_VSCREENINFO , &vinfo ) ) { + send_current_error_msg("Variable information not gotton !"); + exit(3); + } + xres = vinfo.xres ; + yres = vinfo.yres ; + vbpp = vinfo.bits_per_pixel ; + line_len = finfo.line_length ; + sprintf( tmp , "%d(pixel)x%d(line), %dbpp(bits per pixel)",xres,yres,vbpp); + send_current_information( tmp ); + + /* バイト単位でのスクリーンのサイズを計算 */ + screensize = xres * yres * vbpp / DIV_BYTE ; + + /* デバイスをメモリにマップする */ + fbptr = (char *)mmap(0,screensize,PROT_READ | PROT_WRITE,MAP_SHARED,fd_framebuffer,0); + if ( (int)fbptr == -1 ) { + send_current_error_msg("Don't get framebuffer device to memory !"); + exit(4); + } + send_current_information("The framebuffer device was mapped !"); + + printf("fb: 0x%x \n", (unsigned int)fbptr); + + fb_t fb; + fb.pixels = fbptr; + fb.size = screensize; + fb.width = xres; + fb.height = yres; + fb.bpp = vbpp; + fb.fd = fd_framebuffer; + + return fb; + +} + + diff -r c2ce9efe2a52 -r 39d405bc46b7 spe/SpeSentry.cc --- a/spe/SpeSentry.cc Wed Apr 07 17:47:12 2010 +0900 +++ b/spe/SpeSentry.cc Sat Apr 10 16:29:22 2010 +0900 @@ -110,6 +110,10 @@ while(1) { + if ((unsigned long)send_params->head->next_task == 0) { + break; + } + input_buff[cur^1] = allocate(send_params->head->next_task_size); dma_get(input_buff[cur^1], send_params->head->next_task, send_params->head->next_task_size, in_tag[cur^1]); @@ -118,8 +122,8 @@ //printf("hoge"); output_buff[cur] = allocate(send_params->head->size_out); - int size_in = send_params->head->size_in; - int size_out = send_params->head->size_out; + int size_in = send_params->head->size_in - send_params->head->pin_in; + int size_out = send_params->head->size_out - send_params->head->pin_out; //task******************************************** @@ -140,10 +144,6 @@ cur ^= 1; fix_type(send_params,input_buff[cur]); - - if ((unsigned long)send_params->head->next_task == 0) { - break; - } }//while diff -r c2ce9efe2a52 -r 39d405bc46b7 task/Run.cc --- a/task/Run.cc Wed Apr 07 17:47:12 2010 +0900 +++ b/task/Run.cc Sat Apr 10 16:29:22 2010 +0900 @@ -1,30 +1,40 @@ #include #include "Run.h" +typedef struct { + + float red; + float green; + float bule; + float alpha; + +} rgb_t; + +void +set_rgb(rgb_t rgb, int *pixels) +{ + + *pixels = (char)rgb.red | ((char)rgb.green) << 8 | ((char)rgb.bule) << 16 | ((char)rgb.alpha) << 24; + +} + void run(void *in, void *out, int size_in, int size_out) { - //printf("size_in %d\n",size_in); - - for (int i = 0; i < size_in / sizeof(int); i++) { - - int *in_spe = (int*)in; - int *out_spe = (int*)out; - - //printf("in_spe %d\n",in_spe[i]); + int *pixels = (int*)out; + rgb_t rgb; - out_spe[i] = 1; - - for (int j = 2; j < in_spe[i]; j++) { + rgb.red = 0; + rgb.green = 255; + rgb.bule = 255; + rgb.alpha = 1; - if ( in_spe[i] % j == 0) { - out_spe[i] = 0; - break; - } + for (int i = 0; i < size_out; i++) { - } - + set_rgb(rgb, &pixels[i]); + } + }