# HG changeset patch # User yutaka@localhost.localdomain # Date 1271084299 -32400 # Node ID ec2c1003f9b6fbc3cb84ca0042de8a0ee083fbda # Parent febf899d004332185d866fc2e6a6b42a5c1b19d0 fix mandel diff -r febf899d0043 -r ec2c1003f9b6 include/Menu.h --- a/include/Menu.h Mon Apr 12 00:32:34 2010 +0900 +++ b/include/Menu.h Mon Apr 12 23:58:19 2010 +0900 @@ -3,6 +3,6 @@ #include "params.h" -task_head_t* menu(int &task_num); +task_head_t* menu(int &task_num, int argc, char *argv[]); #endif diff -r febf899d0043 -r ec2c1003f9b6 include/Sys.h --- a/include/Sys.h Mon Apr 12 00:32:34 2010 +0900 +++ b/include/Sys.h Mon Apr 12 23:58:19 2010 +0900 @@ -7,6 +7,7 @@ int size_fix(int size, int fix); void fix_type(task_t *task_t, void *buff); task_t* task_allocate(int in_size, int out_size); +void* get_addr(void *buff, int size); task_t* add_list(task_t *tail, task_t *task); task_t* entry_head(task_head_t *head); diff -r febf899d0043 -r ec2c1003f9b6 ppe/Manager.cc --- a/ppe/Manager.cc Mon Apr 12 00:32:34 2010 +0900 +++ b/ppe/Manager.cc Mon Apr 12 23:58:19 2010 +0900 @@ -157,7 +157,7 @@ if (ppe_flag) { int list_num; - task_head_t *head = menu(list_num); + task_head_t *head = menu(list_num, argc, argv); ppe_run(head, list_num); prog_e = clock(); @@ -184,7 +184,7 @@ int list_num = 0; create_s = clock(); - task_head_t *head = menu(list_num); + task_head_t *head = menu(list_num, argc, argv); create_e = clock(); int tmplist_num = list_num; diff -r febf899d0043 -r ec2c1003f9b6 ppe/Menu.cc --- a/ppe/Menu.cc Mon Apr 12 00:32:34 2010 +0900 +++ b/ppe/Menu.cc Mon Apr 12 23:58:19 2010 +0900 @@ -1,5 +1,6 @@ #include #include +#include #include "Menu.h" #include "Sys.h" #include "params.h" @@ -7,12 +8,27 @@ //headk_num と send_param_head の値を必ず返さないと、動作しない +char *make_color_table(int size) { + + char *color_table = (char*)allocate(size); + + srandom(time(NULL)); + + for (int i = 0; i < size; i++) { + color_table[i] = random() % 256; + } + + return color_table; + +} + task_head_t* -menu(int &list_num) { +menu(int &list_num, int argc, char *argv[]) { list_num = SPE_NUM; fb_t fb = get_fbdev_addr(); + int max_size = MAX_DMA_SIZE - sizeof(task_head_t); int all_line_num = fb.height; int line_size = fb.width * fb.bpp / DIV_BYTE; @@ -22,61 +38,68 @@ int out_size = lnpt * line_size; int list_length = (all_line_num / list_num) / lnpt; - int in_size = sizeof(int)*4; - int real_in_size = sizeof(int)*2; + //color table; + int color_table_size = sizeof(char)*256; + // location, width, height, bpp; + int params_size = sizeof(int)*6; + + int task_in_size = params_size + color_table_size; + int alignment = 16; + int send_in_size = size_fix(task_in_size, alignment); task_head_t *list_head = (task_head_t*)allocate(sizeof(task_head_t)*list_num); task_t **tail = (task_t**)allocate(sizeof(task_t*)*list_num); + char *tmp_color = make_color_table(color_table_size); + + for (int i = 0; i < color_table_size; i++) { + + //printf("tmp_color[%d] %d\n",i, tmp_color[i]); + + } + int index = 0; for (int i = 0; i < list_num; i++) { tail[i] = entry_head(&list_head[i]); } for (int i = 0; i < all_line_num / lnpt; i++) { - task_t *task = task_allocate(in_size, 0); + + //task create + task_t *task = task_allocate(send_in_size, 0); + + //output 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; - + + //input params set + int *in = (int*)get_addr(task->input, 0); in[0] = index*out_size; - in[1] = (index+1)*out_size; + in[1] = fb.width; + in[2] = fb.height; + in[3] = fb.bpp; + in[4] = params_size; + in[5] = color_table_size; + + //input color table set + char *color = (char*)get_addr(task->input, params_size); + for (int j = 0; j < color_table_size; j++) { + color[j] = tmp_color[j]; + } - int pin_in = in_size - real_in_size; + //pin + int pin_in = send_in_size - task_in_size; int pin_out = 0; + set_pin(task, pin_in, pin_out); - set_pin(task, pin_in, pin_out); + //list add tail[i%list_num] = add_list(tail[i%list_num], task); index++; } - -// for (int i = 0; i < list_num; i++) { - -// task_t *head = entry_head(&list_head[i]); - -// for (int j = 0; j < list_length; j++) { - -// 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; - -// in[0] = index*out_size; -// in[1] = (index+1)*out_size; - -// int pin_in = in_size - real_in_size; -// int pin_out = 0; - -// set_pin(task, pin_in, pin_out); -// head = add_list(head, task); - -// index++; - -// } - -// } + + free(tmp_color); printf("return run\n"); diff -r febf899d0043 -r ec2c1003f9b6 ppe/Sys.cc --- a/ppe/Sys.cc Mon Apr 12 00:32:34 2010 +0900 +++ b/ppe/Sys.cc Mon Apr 12 23:58:19 2010 +0900 @@ -67,13 +67,23 @@ } +void* +get_addr(void *buff, int size) +{ + + char* p; + p = (char*)buff; + p = p + size; + + return p; + +} + void fix_type(task_t *task, void *buff) { - char *p; - p = (char*)buff; - p = p + sizeof(task_head_t); + void *p = get_addr(buff, sizeof(task_head_t)); task->head = (task_head_t*)buff; task->input = p; @@ -84,7 +94,7 @@ task_allocate(int in_size, int out_size) { - if (in_size % 16) { + if (in_size % 16 || in_size + sizeof(task_head_t) > MAX_DMA_SIZE ) { printf("allocate in_size is not multiple of 16\n"); } diff -r febf899d0043 -r ec2c1003f9b6 task/Run.cc --- a/task/Run.cc Mon Apr 12 00:32:34 2010 +0900 +++ b/task/Run.cc Mon Apr 12 23:58:19 2010 +0900 @@ -2,6 +2,8 @@ #include #include "Run.h" +#define DIB_BYTE (8); + typedef struct { float red; @@ -11,6 +13,18 @@ } rgb_t; +void* +div(void *buff, int size) +{ + + char* p; + p = (char*)buff; + p = p + size; + + return p; + +} + void mandelbrot(float &za, float &zb, float cx, float cy) { @@ -26,8 +40,7 @@ set_rgb(rgb_t rgb, int *pixels) { - *pixels = (char)rgb.red | ((char)rgb.green) << 8 | ((char)rgb.bule) << 16 | ((char)rgb.alpha) << 24; - //*pixels = 255; + *pixels = ((char)rgb.alpha) << 24 | ((char)rgb.red) << 16 | ((char)rgb.green) << 8 | ((char)rgb.bule); } @@ -36,17 +49,35 @@ { int *pixels = (int*)out; - int *location = (int*)in; + int *params = (int*)in; + + int location = params[0]; + int width = params[1]; + int height = params[2]; + int bpp = params[3]; + int params_size = params[4]; + int color_table_size = params[5]; + + char *color = (char*)div(in,params_size); - for (int l = location[0]; l <= location[0] + size_out; l += 4) { - int x = l / 4 % 1920; - int y = l / 4 / 1920; + //byte単位 + int pixel_size = bpp / DIB_BYTE; + + int center_x = width / 2; + int center_y = height / 2; + int x_move = 200; + float scale = 500.f; + + for (int l = location; l <= location + size_out; l += pixel_size) { + + int x = l / pixel_size % width; + int y = l / pixel_size / width; float a = 0; float b = 0; - float cx = (x - 1200) / 500.f; - float cy = (y - 540) / 500.f; + float cx = (x - (center_x + x_move)) / scale; + float cy = (y - center_y) / scale; int i; for (i = 0; i < 255; i++) { @@ -60,21 +91,12 @@ } rgb_t rgb; - rgb.red = 255 * sin(i); - rgb.green = 255 * sin(i); - rgb.bule = 255 * cos(i); + rgb.red = color[i]; + rgb.green = color[i]; + rgb.bule = color[i]; rgb.alpha = 1; - set_rgb( rgb, &pixels[(l - location[0]) / 4] ); + set_rgb( rgb, &pixels[(l - location) / pixel_size] ); } - - //printf("location[0] %d\n",location[0]); - //printf("location[1] %d\n",location[1]); - - //rgb.red = 0; - //rgb.green = 255; - //rgb.bule = 255; - //rgb.alpha = 1; - }