/** * Copy from a source image into a destination image of the specified * format and check the result. * * If \a strict_layout_qualifiers is false, uniform layout qualifiers * will be omitted where allowed by the spec. If \a * strict_access_qualifiers is false, the "readonly" and "writeonly" * qualifiers will be omitted. If \a strict_binding is false, the * image will be bound as READ_WRITE, otherwise only the required * access type will be used. */ static bool run_test(const struct image_format_info *format, bool strict_layout_qualifiers, bool strict_access_qualifiers, bool strict_binding) { const struct grid_info grid = grid_info(GL_FRAGMENT_SHADER, image_base_internal_format(format), W, H); const struct image_info img = image_info(GL_TEXTURE_2D, format->format, W, H); GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(img, ""), test_hunk(strict_layout_qualifiers, strict_access_qualifiers), hunk("SRC_IMAGE_Q uniform IMAGE_BARE_T src_img;\n" "DST_IMAGE_Q uniform IMAGE_BARE_T dst_img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " imageStore(dst_img, IMAGE_ADDR(idx)," " imageLoad(src_img, IMAGE_ADDR(idx)));\n" " return x;\n" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(img, 0, strict_binding) && init_image(img, 1, strict_binding) && set_uniform_int(prog, "src_img", 0) && set_uniform_int(prog, "dst_img", 1) && draw_grid(grid, prog) && check(grid, img); glDeleteProgram(prog); return ret; }
static bool run_test(const struct image_target_info *target, const struct image_extent size) { const struct grid_info grid = { GL_FRAGMENT_SHADER_BIT, get_image_format(GL_RGBA32F), image_optimal_extent(size) }; const struct image_info img = { target, grid.format, size, image_format_epsilon(grid.format) }; GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(img, ""), hunk("readonly uniform IMAGE_T src_img;\n" "writeonly uniform IMAGE_T dst_img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " imageStore(dst_img, IMAGE_ADDR(idx)," " imageLoad(src_img, IMAGE_ADDR(idx)));\n" " return x;\n" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(img, 0) && init_image(img, 1) && set_uniform_int(prog, "src_img", 0) && set_uniform_int(prog, "dst_img", 1) && draw_grid(grid, prog) && check(img); glDeleteProgram(prog); return ret; }
static bool run_test(GLbitfield shaders) { const struct grid_info grid = { shaders, get_image_format(GL_R32UI), { W, H, 1, 1 } }; const struct image_info img = image_info_for_grid(grid); GLuint prog = generate_program( grid, GL_VERTEX_SHADER, generate_source(grid, img, GL_VERTEX_SHADER), GL_TESS_CONTROL_SHADER, generate_source(grid, img, GL_TESS_CONTROL_SHADER), GL_TESS_EVALUATION_SHADER, generate_source(grid, img, GL_TESS_EVALUATION_SHADER), GL_GEOMETRY_SHADER, generate_source(grid, img, GL_GEOMETRY_SHADER), GL_FRAGMENT_SHADER, generate_source(grid, img, GL_FRAGMENT_SHADER), GL_COMPUTE_SHADER, generate_source(grid, img, GL_COMPUTE_SHADER)); bool ret = prog && init_fb(grid) && init_images(img) && bind_images(grid, prog) && draw_grid(grid, prog) && check(grid, img); glDeleteProgram(prog); return ret; }
int hdmi_test(struct test_Parameters *test_para) { test_words_show("HDMI test",Bcolor); /*if(init_tvout_pic() < 0)*/ /*{*/ /*draw_decision_pic(FAIL);*/ /*return False;*/ /*}*/ #ifdef H350 if(audio_init(SAMPLINGRATE, O_WRONLY) < 0) return False; if(init_fb(test_para->hdmi_info.buffer_size) < 0) { draw_decision_pic(FAIL); return False; } if (test_hdmi_loop(test_para) != True) { draw_decision_pic(FAIL); return False; } deinit_audio(); deinit_fb(test_para->hdmi_info.buffer_size); #endif /*deinit_tvout_pic();*/ return decision_loop(); }
/* main function */ int main(int argc, char *argv[]) { if (argc < 2) argv[1] = "test.jpg"; fb_info fb_inf; if (init_fb(&fb_inf) < 0){ fprintf(stderr, "Error initial framebuffer\n"); return 1; } display_jpeg(argv[1], fb_inf); #if 0 /* Test mouse */ //test_mouse(fb_inf); if (init_ft("mao.ttf", 0) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } display_string("显示文字", 432, 400, fb_inf, 0xFF0000); #endif munmap(fb_inf.fbmem, fb_inf.w * fb_inf.h * fb_inf.bpp / 8); return 0; }
void set_ttm() { int i, max_pnl=PNL_NUM; if(ttm.set_pnl_num) max_pnl = ttm.pnl_num; for(i=0; i<max_pnl; i++) { init_evt(&ttm.evt[i], i); init_fb(&ttm.fb[i], i); } for(i=0; i<ttm.arg.ap.num; i++) { int pnl = select_pnl(ttm.arg.ap.data[i]); ttm.evt[pnl].act = 1; // if panel supports multi-ap, replace default ap for ts_test switch(pnl) { case 0: ttm.evt[0].num = ttm.arg.ap.data[i]; ttm.evt[0].dev[EVT_NUM_POS] = '0' + ttm.evt[0].num; break; case 1: case 2: default: break; } } }
void init_rdp(struct rdp_core* dp) { memset(dp->dpc_regs, 0, DPC_REGS_COUNT*sizeof(uint32_t)); memset(dp->dps_regs, 0, DPS_REGS_COUNT*sizeof(uint32_t)); init_fb(&dp->fb); }
static bool run_test(const struct image_op_info *op, unsigned w, unsigned h, bool (*check)(const struct grid_info grid, const struct image_info img, unsigned w, unsigned h), const char *body) { const struct grid_info grid = grid_info(GL_FRAGMENT_SHADER, GL_R32UI, W, H); const struct image_info img = image_info_for_grid(grid); GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(img, ""), hunk("uniform IMAGE_T img;\n"), hunk(op->hunk), hunk(body), NULL)); bool ret = prog && init_fb(grid) && init_image(img) && set_uniform_int(prog, "img", 0) && draw_grid(set_grid_size(grid, w, h), prog) && check(grid, img, w, h); glDeleteProgram(prog); return ret; }
/* main */ int main(int argc, char *argv[]) { fb_info fb_inf; pthread_t p_tcp; if (argc != 2) { printf("Usage: ./appname 192.168.1.***\n"); exit(1); } if (init_fb(&fb_inf) < 0) { fprintf(stderr, "Error initial framebuffer\b") ; return -1; } if (init_ft("mao.ttf", 150) < 0) { fprintf(stderr, "Error initial font\b"); exit(1); } pthread_create(&p_tcp, NULL, pro_thread_tcp, argv[1]); mouse_work(fb_inf, X_START, Y_START); munmap(fb_inf.fbmem, fb_inf.w * fb_inf.h * fb_inf.bpp / 8); return 0; }
int main(int argc, char **argv) { if(argc > 1) { int i=1; while(i < argc) { if(*argv[i] == '-') { switch(*(argv[i] + 1)) { case 'h': print_usage(argv); exit(0); break; case 'k': i++; strcpy(KBD_DEVICE, argv[i]); break; case 't': i++; strcpy(TOUCH_DEVICE, argv[i]); break; } } i++; } } printf("Initializing framebuffer device " FB_DEVICE "...\n"); init_fb(); /* printf("Initializing keyboard device %s ...\n", KBD_DEVICE); init_kbd(); printf("Initializing touch device %s ...\n", TOUCH_DEVICE); init_touch(); */ printf("Initializing VNC server:\n"); printf(" width: %d\n", (int)scrinfo.xres); printf(" height: %d\n", (int)scrinfo.yres); printf(" bpp: %d\n", (int)scrinfo.bits_per_pixel); printf(" port: %d\n", (int)VNC_PORT); init_fb_server(argc, argv); /* Implement our own event loop to detect changes in the framebuffer. */ while (1) { while (vncscr->clientHead == NULL) rfbProcessEvents(vncscr, 100000); rfbProcessEvents(vncscr, 100000); update_screen(); } printf("Cleaning up...\n"); cleanup_fb(); /* cleanup_kdb(); cleanup_touch();*/ }
uint32_t kmain(unsigned long magic, multiboot_info_t *mboot) { if (magic != MULTIBOOT_BOOTLOADER_MAGIC) { return 0xD15EA5E; } // Intialize framebuffer init_fb(); kprintf("\nKernel loading linear address = %x", loader); kprintf("\nGrub magic = %x", magic); if (mboot->flags & (1 << 2)) { kprintf("\nGrub cmdline = %s", (const char*)mboot->cmdline); } uint32_t availableMemory = 0; multiboot_memory_map_t *mmap = (multiboot_memory_map_t*) mboot->mmap_addr; while (mmap < (multiboot_memory_map_t*)(mboot->mmap_addr + mboot->mmap_length)) { kprintf("\n memmap type=%x size=%xkb start_addr=%x end_addr=%x", mmap->type, mmap->len/1024, (uint32_t) mmap->addr, (uint32_t) mmap->addr + mmap->len); if (mmap->type == MULTIBOOT_MEMORY_AVAILABLE) { availableMemory += mmap->len; } mmap = (multiboot_memory_map_t*) ((uint32_t)mmap + mmap->size + sizeof(uint32_t)); } kprintf("\nAvailable Physical Memory = %x kB", availableMemory); // Initialize descriptor tables init_descriptor_tables(); // Initialize timer at 100hz init_timer(100); // Initialize keyboard init_keyboard(); // Initialize paging init_paging(availableMemory); // Enable interrupts __asm__("sti"); kprintf("\n> "); // Dummy interrupts to test ISRs //__asm__("int $0x03"); //__asm__("int $0x04"); // Test page fault //uint32_t *ptr = (uint32_t*) 0xDEADFA11; //uint32_t do_page_fault = *ptr; // 0xBADA55 now set on eax/rax register from C return 0xBADA55; }
static bool run_test(const struct image_qualifier_info *qual, const struct image_stage_info *stage_w, const struct image_stage_info *stage_r, unsigned l) { const struct grid_info grid = { stage_w->bit | stage_r->bit, get_image_format(GL_RGBA32UI), { l, l, 1, 1 } }; const struct image_info img = image_info_for_grid(grid); GLuint prog = generate_program( grid, /* * Write (11, 22, 33, 44) to some location on the * image from the write stage. */ stage_w->stage, concat(qualifier_hunk(qual), image_hunk(img, ""), hunk("IMAGE_Q uniform IMAGE_T img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " imageStore(img, idx, DATA_T(11, 22, 33, 44));" " return x;" "}\n"), NULL), /* * The same location will read back the expected value * if image access is coherent, as the shader inputs * of the read stage are dependent on the outputs of * the write stage and consequently they are * guaranteed to be executed sequentially. */ stage_r->stage, concat(qualifier_hunk(qual), image_hunk(img, ""), hunk("IMAGE_Q uniform IMAGE_T img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " DATA_T v = imageLoad(img, idx);" " if (v == DATA_T(11, 22, 33, 44))" " return GRID_T(33, 33, 33, 33);" " else" " return GRID_T(77, 77, 77, 77);" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(img) && set_uniform_int(prog, "img", 0) && draw_grid(grid, prog) && (check(grid, img) || qual->control_test); glDeleteProgram(prog); return ret; }
int main(int argc, const char *argv[]) { fb_info fb; if(init_fb(&fb) < 0) { perror("init_fb"); exit(1); } mouse_test(&fb); return 0; }
/* main function */ int main(int argc, char *argv[]) { fb_info fb_inf; /* initialize device fb */ if (init_fb(&fb_inf) < 0) { printf("Error init_fb\n"); exit(1); } rain("loading.jpg", fb_inf); return 0; }
int main(int argc, char *argv[]) { int i = 0, ret = 0; int num_buf; if (!argv[1]) { printf("/dev/fbN parameter missing\n"); return -ENODEV; } if ((num_buf = init_fb(argv[1])) < 0) { printf("Could not initialize dev %s\n", argv[1]); return -1; } ret = movie(num_buf, WAIT_FOR_VSYNC); close(fd); return ret; }
static bool run_test(const struct image_qualifier_info *qual) { const struct grid_info grid = grid_info(GL_FRAGMENT_SHADER, GL_R32UI, W, H); const struct image_info img = image_info(GL_TEXTURE_1D, GL_R32UI, W, H); GLuint prog = generate_program( grid, /** * Write to consecutive locations of an image using a * the value read from a fixed location of a different * image uniform which aliases the first image. If * the implementation incorrectly coalesces repeated * loads from the fixed location the results of the * test will be altered. */ GL_FRAGMENT_SHADER, concat(qualifier_hunk(qual), image_hunk(img, ""), hunk("IMAGE_Q IMAGE_UNIFORM_T src_img;\n" "IMAGE_Q IMAGE_UNIFORM_T dst_img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " int i;\n" "\n" " for (i = 0; i < N / 2; ++i) {\n" " imageStore(dst_img, 2 * i," " imageLoad(src_img, W) + 1u);\n" " imageStore(dst_img, 2 * i + 1," " imageLoad(src_img, W) - 1u);\n" " }\n" "\n" " return x;\n" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(img) && set_uniform_int(prog, "src_img", 0) && set_uniform_int(prog, "dst_img", 0) && draw_grid(set_grid_size(grid, 1, 1), prog) && (check(img) || qual->control_test); glDeleteProgram(prog); return ret; }
int main(int argc ,char *argv[]) { int i,k; init_fb(); /*for(i =0;i < w*h ;i++) { fbmem[i] = 31 << 11 | 63 << 5 | 31; }*/ for(i = 0 ; i < 100; i++) { for(k = 0; k < 100; k++) { fbmem[i * 1024 + k ] = 63 << 5; } } return 0; }
int display_jpeg_zoom(char * filename1, fb_info fb_inf) { fb_info jpeg_inf; fb_info zoom_inf; int xres; int yres; int x = 235; int x_x = 747; if (init_fb(&zoom_inf) < 0) { fprintf(stderr, "Error initial framebuffer\b") ; return -1; } u8_t *buf24 = decode_jpeg(filename1, &jpeg_inf); for(zoom_inf.w = 40; zoom_inf.w <= 512; zoom_inf.w = zoom_inf.w + 2) { u8_t *scale_buf = scale24(buf24, zoom_inf, jpeg_inf); u32_t *buf32 = rgb24to32(scale_buf, zoom_inf); for(yres = 0; yres < zoom_inf.h; yres++) { for(xres = 1; xres < zoom_inf.w; xres++) { fb_pixel(fb_inf, x + xres, yres, buf32[xres + yres * zoom_inf.w]); fb_pixel(fb_inf, x_x + xres, yres, buf32[xres + yres * zoom_inf.w]); } } free(scale_buf); free(buf32); x = x - 1; x_x = x_x - 1; } free(buf24); return 0; }
/** * Test skeleton: Init image to \a init_value, run the provided shader * \a op and check that the resulting image pixels equal \a * check_value. */ static bool run_test(uint32_t init_value, uint32_t check_value, const char *op) { const struct grid_info grid = grid_info(GL_FRAGMENT_SHADER, GL_R32UI, W, H); const struct image_info img = image_info_for_grid(grid); GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(img, ""), hunk("uniform IMAGE_T img;\n"), hunk(op), NULL)); bool ret = prog && init_fb(grid) && init_image(img, init_value) && set_uniform_int(prog, "img", 0) && draw_grid(grid, prog) && check(img, check_value); glDeleteProgram(prog); return ret; }
int fb_test(void) { printf("Framebuffer Test\n"); fb_info fb_inf; if(init_fb(&fb_inf) < 0) return -1; printf("Framebuffer Test fb_pixel\n"); /* point test */ // point_t p, p2; p.x = 640; p.y = 400; fb_pixel(fb_inf, 640, 400, 0xFFFFFFFF); /* line test*/ // p.x = 0; p.y = 200; // p2.x = 1280, p2.y = 200; fb_pixel_row(fb_inf, 0, 200, 1280, 0xFF0000); munmap(fb_inf.fbmem, fb_inf.w * fb_inf.h * fb_inf.bpp / 8); return 0; }
int main(void) { int vmode = -1; exception_init(); dsp_reset(); irq_initialize(); irq_bw_enable(BW_PI_IRQ_RESET); irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic /* external ohci */ irq_hw_enable(IRQ_OHCI0); /* internal ohci */ //irq_hw_enable(IRQ_OHCI1); ipc_initialize(); ipc_slowping(); gecko_init(); input_init(); init_fb(vmode); VIDEO_Init(vmode); VIDEO_SetFrameBuffer(get_xfb()); VISetupEncoder(); u32 version = ipc_getvers(); u16 mini_version_major = version >> 16 & 0xFFFF; u16 mini_version_minor = version & 0xFFFF; printf("Mini version: %d.%0d\n", mini_version_major, mini_version_minor); if (version < MINIMUM_MINI_VERSION) { printf("Sorry, this version of MINI (armboot.bin)\n" "is too old, please update to at least %d.%0d.\n", (MINIMUM_MINI_VERSION >> 16), (MINIMUM_MINI_VERSION & 0xFFFF)); for (;;) ; // better ideas welcome! }
/** * If \a layered is false, bind an individual layer of a texture to an * image unit, read its contents and write back a different value to * the same location. If \a layered is true or the texture has a * single layer, the whole texture will be read and written back. * * For textures with a single layer, the arguments \a layered and \a * layer which are passed to the same arguments of * glBindImageTexture() should have no effect as required by the spec. */ static bool run_test(const struct image_target_info *target, bool layered, unsigned layer) { const struct image_info real_img = image_info( target->target, GL_RGBA32F, W, H); const unsigned slices = (layered ? 1 : image_num_layers(real_img)); /* * "Slice" of the image that will be bound to the pipeline. */ const struct image_info slice_img = image_info( (layered ? target->target : image_layer_target(target)), GL_RGBA32F, W, H / slices); /* * Grid with as many elements as the slice. */ const struct grid_info grid = grid_info( GL_FRAGMENT_SHADER, GL_RGBA32F, W, H / slices); GLuint prog = generate_program( grid, GL_FRAGMENT_SHADER, concat(image_hunk(slice_img, ""), hunk("IMAGE_UNIFORM_T img;\n" "\n" "GRID_T op(ivec2 idx, GRID_T x) {\n" " GRID_T v = imageLoad(img, IMAGE_ADDR(idx));\n" " imageStore(img, IMAGE_ADDR(idx), DATA_T(33));\n" " return v;\n" "}\n"), NULL)); bool ret = prog && init_fb(grid) && init_image(real_img, layered, layer) && set_uniform_int(prog, "img", 0) && draw_grid(grid, prog) && check(grid, real_img, (slices == 1 ? 0 : layer)); glDeleteProgram(prog); return ret; }
/* main */ int main(int argc, char *argv[]) { fb_info fb_inf1; if (init_fb(&fb_inf1) < 0) { fprintf(stderr, "Error initial framebuffer\b") ; return -1; } //fb_inf.fbmem - map start address while(1) { *((u32_t *)fb_inf1.fbmem) = 0x000000ff; sleep(3); *((u32_t *)fb_inf1.fbmem) = 0x0000ff00; sleep(3); *((u32_t *)fb_inf1.fbmem) = 0x00ff0000; sleep(3); } munmap(fb_inf1.fbmem, fb_inf1.w * fb_inf1.h * fb_inf1.bpp / 8); return 0; }
/* main */ int main(int argc, char *argv[]) { pthread_t p_clock; pthread_t p_keyboard; pthread_t p_display_pic; pthread_t p_tcp_recv_frame; // pthread_t p_display_jpegs; fb_info fb_inf; if (init_fb(&fb_inf) < 0) { fprintf(stderr, "Error initial framebuffer\b") ; return -1; } pthread_create(&p_display_jpegs, NULL, pro_thread_display_jpegs, &fb_inf); pthread_create(&p_clock, NULL, pro_thread_clock, &fb_inf); pthread_create(&p_keyboard, NULL, pro_thread_keyboard, NULL); pthread_create(&p_tcp_recv_frame, NULL, pro_thread_tcp, NULL); again: pthread_create(&p_display_pic, NULL, pro_thread_display_pic, &fb_inf); while (1) { if (keyboard_display_pic_flag == 2) { pthread_cancel(p_display_pic); keyboard_display_pic_flag = 0; goto again; } usleep(1); } return 0; }
int main () { assert (restart_gl_log ()); assert (start_gl ()); /* set up framebuffer with texture attachment */ assert (init_fb ()); init_ss_quad (); /* load the post-processing effect shaders */ GLuint post_sp = create_programme_from_files (POST_VS, POST_FS); /* load a mesh to draw in the main scene */ load_sphere (); GLuint sphere_sp = create_programme_from_files (SPHERE_VS, SPHERE_FS); GLint sphere_P_loc = glGetUniformLocation (sphere_sp, "P"); GLint sphere_V_loc = glGetUniformLocation (sphere_sp, "V"); assert (sphere_P_loc > -1); assert (sphere_V_loc > -1); /* set up view and projection matrices for sphere shader */ mat4 P = perspective ( 67.0f, (float)g_gl_width / (float)g_gl_height, 0.1f, 100.0f); mat4 V = look_at ( vec3 (0.0f, 0.0f, 5.0f), vec3 (0.0f, 0.0f, 0.0f), vec3 (0.0f, 1.0f, 0.0f)); glUseProgram (sphere_sp); glUniformMatrix4fv (sphere_P_loc, 1, GL_FALSE, P.m); glUniformMatrix4fv (sphere_V_loc, 1, GL_FALSE, V.m); glViewport (0, 0, g_gl_width, g_gl_height); while (!glfwWindowShouldClose (g_window)) { _update_fps_counter (g_window); /* bind the 'render to a texture' framebuffer for main scene */ glFlush (); glFinish (); glActiveTexture (GL_TEXTURE0); glBindTexture (GL_TEXTURE_2D, 0); glBindFramebuffer (GL_FRAMEBUFFER, g_fb); /* clear the framebuffer's colour and depth buffers */ glClearColor (0.2, 0.2, 0.2, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // render an obj or something glUseProgram (sphere_sp); glBindVertexArray (g_sphere_vao); glDrawArrays (GL_TRIANGLES, 0, g_sphere_point_count); /* bind default framebuffer for post-processing effects. sample texture from previous pass */ glFlush (); glFinish (); glBindFramebuffer (GL_FRAMEBUFFER, 0); // clear the framebuffer's colour and depth buffers // glClearColor (0.0, 0.0, 0.0, 1.0); // glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // use our post-processing shader for the screen-space quad glUseProgram (post_sp); // bind the quad's VAO glBindVertexArray (g_ss_quad_vao); // activate the first texture slot and put texture from previous pass in it glActiveTexture (GL_TEXTURE0); glBindTexture (GL_TEXTURE_2D, g_fb_tex); // draw the quad that covers the screen area glDrawArrays (GL_TRIANGLES, 0, 6); // flip drawn framebuffer onto the display glfwSwapBuffers (g_window); glfwPollEvents (); if (GLFW_PRESS == glfwGetKey (g_window, GLFW_KEY_ESCAPE)) { glfwSetWindowShouldClose (g_window, 1); } } return 0; }
int main( int argc, char **argv ) { int dispDev, csiDev; int chunkMem; chunk_block_t priBlk0, priBlk1; gp_disp_res_t panelRes; gp_bitmap_t priBitmap; UINT16 *data; fd_set fds; struct timeval tv; int r, bufnum; struct v4l2_buffer buf; struct v4l2_format fmt; struct v4l2_queryctrl qc; struct v4l2_input in; spRect_t dstRect={0,0,0,0}; spRect_t srcRect={0,0,0,0}; spBitmap_t dst; spBitmap_t src; /* Opening the device dispDev */ dispDev = open("/dev/disp0",O_RDWR); printf("dispDev = %d\n", dispDev); ioctl(dispDev, DISPIO_SET_INITIAL, 0); ioctl(dispDev, DISPIO_GET_PANEL_RESOLUTION, &panelRes); dstRect.width = panelRes.width; dstRect.height=panelRes.height; srcRect.width=NTSC_WIDTH; srcRect.height=NTSC_HEIGHT; /* Opening /dev/chunkmem */ chunkMem = open("/dev/chunkmem", O_RDWR); /* Allocate primary frame buffer */ priBlk0.size = (NTSC_WIDTH) * (NTSC_HEIGHT) * getBpp(SP_BITMAP_YCbYCr); priBlk1.size = (panelRes.width) * (panelRes.height) *getBpp(SP_BITMAP_YCbYCr); ioctl(chunkMem, CHUNK_MEM_ALLOC, (unsigned long)&priBlk0); ioctl(chunkMem, CHUNK_MEM_ALLOC, (unsigned long)&priBlk1); dst.width = panelRes.width; dst.height = panelRes.height; dst.bpl = panelRes.width * getBpp(SP_BITMAP_YCbYCr); dst.pData = priBlk1.addr; dst.type = SP_BITMAP_YCbYCr; src.width = NTSC_WIDTH; src.height =NTSC_HEIGHT; src.bpl = NTSC_WIDTH *getBpp(SP_BITMAP_YCbYCr); src.pData = priBlk0.addr; src.type = SP_BITMAP_YCbYCr; //gp2dScale(&dst, dstRect, &src, srcRect); /* Set primary layer bitmap */ priBitmap.width = panelRes.width; priBitmap.height = panelRes.height; priBitmap.bpl = panelRes.width*getBpp(SP_BITMAP_YCbYCr); priBitmap.type = SP_BITMAP_YCbYCr; priBitmap.pData = priBlk1.addr; ioctl(dispDev, DISPIO_SET_PRI_BITMAP, &priBitmap); /* Fill primary bitmap data */ #if 0 data = (UINT16*) priBlk0.addr; init_fb(data, 0x0000, 0x001f, 0x0513, 0xffff); data = (UINT16*) priBlk1.addr; init_fb(data, 0xffff, 0x0513, 0x001f, 0x0000); #endif ioctl(dispDev, DISPIO_SET_PRI_ENABLE, 1); ioctl(dispDev, DISPIO_SET_UPDATE, 0); csiDev = open("/dev/csi0",O_RDWR); in.index = 0; ioctl(csiDev, VIDIOC_ENUMINPUT, &in); printf("name=%s\n", in.name); CLEAR(fmt); fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; fmt.fmt.pix.width = NTSC_WIDTH; fmt.fmt.pix.height = NTSC_HEIGHT; ioctl(csiDev, VIDIOC_TRY_FMT, &fmt); CLEAR(qc); qc.id = V4L2_CID_BRIGHTNESS; ioctl(csiDev, VIDIOC_QUERYCTRL, &qc); printf("max=%d\n", qc.maximum); init_userp(csiDev, 1); CLEAR(buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_USERPTR; buf.index = 0; buf.m.userptr = (unsigned long)priBlk0.addr; ioctl(csiDev, VIDIOC_QBUF, &buf); // buf.index = 1; // buf.m.userptr = (unsigned long)priBlk1.addr; // ioctl(csiDev, VIDIOC_QBUF, &buf); // buf.index = 2; // buf.m.userptr = (unsigned long)priBlk2.addr; // ioctl(csiDev, VIDIOC_QBUF, &buf); FD_ZERO (&fds); FD_SET (csiDev, &fds); tv.tv_sec = 2; tv.tv_usec = 0; ioctl(csiDev, VIDIOC_STREAMON, NULL); while(1) { r = select(csiDev+1, &fds, NULL, NULL, NULL);//&tv); gp2dScale(&dst, dstRect, &src, srcRect); CLEAR (buf); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_USERPTR; ioctl(csiDev, VIDIOC_DQBUF, &buf); ioctl(csiDev, VIDIOC_QBUF, &buf); /* ioctl(csiDev, 3, &bufnum); if( bufnum==0 ) priBitmap.pData = priBlk0.addr; else if(bufnum==1) priBitmap.pData = priBlk1.addr; else priBitmap.pData = priBlk2.addr; ioctl(dispDev, DISPIO_SET_PRI_BITMAP, &priBitmap); ioctl(dispDev, DISPIO_SET_PRI_ENABLE, 1); ioctl(dispDev, DISPIO_SET_UPDATE, 0); ioctl(dispDev, DISPIO_WAIT_FRAME_END, 0);*/ /* r = select(csiDev+1, &fds, NULL, NULL, &tv); priBitmap.pData = priBlk1.addr; ioctl(dispDev, DISPIO_SET_PRI_BITMAP, &priBitmap); ioctl(dispDev, DISPIO_SET_PRI_ENABLE, 1); ioctl(dispDev, DISPIO_SET_UPDATE, 0); r = select(csiDev+1, &fds, NULL, NULL, &tv); priBitmap.pData = priBlk2.addr; ioctl(dispDev, DISPIO_SET_PRI_BITMAP, &priBitmap); ioctl(dispDev, DISPIO_SET_PRI_ENABLE, 1); ioctl(dispDev, DISPIO_SET_UPDATE, 0);*/ } // close(dispDev); // ioctl(chunkMem, CHUNK_MEM_FREE, (unsigned long)&priBlk); // close(chunkMem); return 0; /* int i, ret; int fdcsi; struct v4l2_queryctrl qc; printf("csi test!\n"); fdcsi = open("/dev/csi0", O_RDWR); // init_userp(fdcsi, 0x2000); close(fdcsi); return 0;*/ }
/* Initialize BOGL. */ int bogl_init (void) { unsigned long bogl_frame_offset, bogl_frame_len; struct fb_var_screeninfo fb_var; struct vt_stat vts; assert (status < 2); visible = 1; fb = open ("/dev/fb0", O_RDWR); if (fb < 0) fb = open ("/dev/fb/0", O_RDWR); if (fb < 0) { return bogl_fail ("opening /dev/fb0: %s", strerror (errno)); } tty = open ("/dev/tty0", O_RDWR); if (tty < 0) tty = open ("/dev/vc/0", O_RDWR); if (tty < 0) { return bogl_fail ("opening /dev/tty0: %s", strerror (errno)); } if (-1 == ioctl (tty, VT_GETSTATE, &vts)) { return bogl_fail ("can't get VT state: %s", strerror (errno)); } tty_no = vts.v_active; if (-1 == ioctl (fb, FBIOGET_FSCREENINFO, &fb_fix) || -1 == ioctl (fb, FBIOGET_VSCREENINFO, &fb_var)) { return bogl_fail ("reading screen info: %s", strerror (errno)); } bogl_xres = fb_var.xres; bogl_yres = fb_var.yres; bogl_bpp = fb_var.bits_per_pixel; bogl_line_len = fb_fix.line_length; type = fb_fix.type; visual = fb_fix.visual; /* Some broken framebuffers (2.4.x virgefb, 2.5 is OK) don't provide line_length. */ if (bogl_line_len == 0) bogl_line_len = fb_var.xres * fb_var.bits_per_pixel / 8; if (!draw_enable ()) { return bogl_fail ("don't know screen type %d", type); } if (ioctl (tty, VT_GETMODE, &mode) == -1) { return bogl_fail ("can't get VT mode: %s", strerror (errno)); } mode.mode = VT_PROCESS; mode.relsig = SIGUSR2; mode.acqsig = SIGUSR2; signal (SIGUSR2, vt_switch); if (-1 == ioctl (tty, VT_SETMODE, &mode)) { return bogl_fail ("can't set VT mode: %s", strerror (errno)); } if (-1 == ioctl (tty, KDSETMODE, KD_GRAPHICS)) { return bogl_fail ("setting graphics mode: %s", strerror (errno)); } if (!init_fb()) { bogl_fail ("EXPLODE\n"); return 0; } bogl_frame_offset = fb_fix.smem_start & ~PAGE_MASK; bogl_frame_len = ((bogl_frame_offset + fb_fix.smem_len + ~PAGE_MASK) & PAGE_MASK); bogl_frame_mapped = mmap (NULL, bogl_frame_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0); if (bogl_frame_mapped == NULL || bogl_frame_mapped == (char *) -1) return bogl_fail ("mmaping /dev/fb0: %s", strerror (errno)); bogl_frame = bogl_frame_mapped + bogl_frame_offset; kbd_init (); if (visual == FB_VISUAL_PSEUDOCOLOR || visual == FB_VISUAL_STATIC_PSEUDOCOLOR) { static struct fb_cmap cmap; cmap.start = 0; cmap.len = 16; cmap.red = saved_red; cmap.green = saved_green; cmap.blue = saved_blue; cmap.transp = NULL; ioctl (fb, FBIOGETCMAP, &cmap); } if (!status) atexit (bogl_done); status = 2; return 1; }
int button_click(fb_info fb_inf) { int mfd; mouse_open(NULL, &mfd); /* highlight ico */ fb_info jpeg_inf; fb_info b_inf; if (init_fb(&b_inf) < 0) { printf("Error init_fb\n"); exit(1); } u8_t *buf24 = decode_jpeg("mainframel.jpg", &jpeg_inf); u8_t * scale_buf = scale24(buf24, b_inf, jpeg_inf); u32_t *buf32 = rgb24to32(scale_buf, b_inf); /* initialize font */ if (init_ft("x.ttf", 45) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } int m_x = fb_inf.w / 2; int m_y = fb_inf.h / 2; fb_drawcursor(fb_inf, m_x, m_y); u8_t buf[8]; mouse_event_t mevent; ico fkey[9]; fkey[0].x = 34; fkey[0].y = 34; fkey[1].x = 34; fkey[1].y = 178; fkey[2].x = 34; fkey[2].y = 322; fkey[3].x = 34; fkey[3].y = 510; fkey[4].x = 34; fkey[4].y = 660; fkey[5].x = 262; fkey[5].y = 46; fkey[6].x = 265; fkey[6].y = 180; fkey[7].x = 469; fkey[7].y = 46; fkey[8].x = 823; fkey[8].y = 595; char *discription[9] = {"图片", "音乐", "电子书", "设置", "时间", "幻灯", "浏览", "关于", "退出"}; int door2 = 1; /* loading ... */ display_jpeg("loading.jpg", fb_inf); display_string("loading", 200, 450, fb_inf, 0x00ff55e3); /* initialize font */ if (init_ft("x.ttf", 84) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } int c = 3; /* loading time */ while (c) { int i; for (i=0; i<3; i++) { display_string(".", 550 + i *100, 450, fb_inf, 0x00ff0000); usleep(200000); } for (i=0; i<3; i++) { display_string(".", 550 + i *100, 450, fb_inf, 0x00ffff55); usleep(200000); } c--; } /* landing mainfframe */ /* initialize font */ if (init_ft("x.ttf", 32) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } display_jpeg("mainframe.jpg", fb_inf); while (1) { int n = read(mfd, buf, 8); if (n != -1) { mouse_parse(buf,&mevent); fb_restorecursor(fb_inf, m_x, m_y); m_x += mevent.x; m_y += mevent.y; int k = 1; if (m_x>0 && m_x<1024 && m_y>0 && m_y<752) { fb_drawcursor(fb_inf, m_x, m_y); int i; for (i=0; i<9; i++) if (m_x > fkey[i].x && m_x < fkey[i].x + 100 && m_y > fkey[i].y && m_y < fkey[i].y + 100 ) { display_string(discription[i], fkey[i].x + 120, fkey[i].y + 50, fb_inf, 0x00ff0000); int m, n; for (m=fkey[i].y; m< fkey[i].y + 120; m++ ) for (n=fkey[i].x - 20; n< fkey[i].x + 100; n++ ) fb_pixel(b_inf, n, m, buf32[n + m * b_inf.w]); k = 0; /* interface for effect */ if (mevent.button == 1) /* if left button down ,when the cursor is being on the taiji ico occur */ { if (i == 5) { /* initialize font */ if (init_ft("x.ttf", 64) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } char *f2[7] = {"虽","然", "哥", "不", "在", "江", "湖"}; char *f3[12] = {"但", "江", "湖", "仍", "有", "哥", "的", "传", "说", ".", ".", ".",}; fb_info fbinf; if (init_fb(&fbinf) < 0) { printf("Error init_fb\n"); exit(1); } jpgdsp_door( "oba.jpg", fbinf ); int i; for (i=0; i<7; i++) { display_string(f2[i], 240 + i*80, 400, fb_inf, 0x00fffb55); usleep(100000); } for (i=0; i<12; i++) { display_string(f3[i], 100 + i*80, 570, fb_inf, 0x00fffb55); usleep(100000); } sleep(2); /* recover font */ if (init_ft("x.ttf", 32) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } /* interface for you */ fbb(); /* write here */ mevent.button = 0; /* Avoid play again */ display_jpeg("mainframe.jpg", fb_inf);/* back to mainframe */ } if (i == 7 && door2) { display_jpeg("show.jpg", fb_inf); sleep(5); display_jpeg("show_us.jpg", fb_inf); sleep(5); door2 = 0; display_jpeg("mainframe.jpg", fb_inf); } if (i == 8) { /* initialize font */ if (init_ft("x.ttf", 64) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } // move1("log-out.jpg", fb_inf); display_jpeg("log-out.jpg", fb_inf); int i; char *f1[5] = {"待","续", ".", ".", "."}; for (i=0; i<5; i++) { display_string(f1[i], 300 + i *100, 400, fb_inf, 0x00ff0000); usleep(100000); } int j = 4; /* replay ... tree times */ while (j) { for (i=2; i<5; i++) { display_string(f1[i], 300 + i *100, 400, fb_inf, 0x00ffff55); usleep(200000); } for (i=2; i<5; i++) { display_string(f1[i], 300 + i *100, 400, fb_inf, 0x00ff0000); usleep(200000); } j--; } /* initialize font */ if (init_ft("x.ttf", 32) != 0){ fprintf(stderr, "Error initial font\n") ; return 1; } display_string("雁留声工作室", 800, 720, fb_inf, 0x0055ffff); exit(1); } } } } else { m_x -= mevent.x; m_y -= mevent.y; } if (k) { display_jpeg("mainframe.jpg", fb_inf); mevent.button = 0; } } } free(buf24); free(scale_buf); free(buf32); return 0; }
int avout_test(struct test_Parameters *test_para) { int avout_loop = 1; extern unsigned char *fb; int i = 0; test_words_show("Av out test",Bcolor); #ifdef H350 set_volume(100); /*if(init_tvout_pic() < 0)*/ /*{*/ /*draw_decision_pic(FAIL);*/ /*return False;*/ /*}*/ if(audio_init(SAMPLINGRATE, O_WRONLY) < 0) return False; if(init_fb(test_para->avout_info.buffer_size) < 0) { draw_decision_pic(FAIL); return False; } if(init_av_dev() < 0) { draw_decision_pic(FAIL); return False; } test_words_show("Please plug in AV cable!",Bcolor); while(avout_loop) { if(get_av_out_mode() == SET_ON) { /*if(False == set_lcd_control_mode(AVOUT_PAL_MODE))*/ /*return False;*/ avout_switch(SET_ON); for(i = 0; i < 3; i++) { draw_color_bar((unsigned int *)fb,i,test_para->avout_info.width,test_para->avout_info.height); sleep(2); } audio_sound_out(TEST_SOUND); /*sdl_draw_a_pic(test_back_show,NULL,NULL);*/ /*sdl_flip_screen();*/ /*set_lcd_control_mode(LCD_MODE);*/ avout_switch(SET_OFF); avout_loop = 0; } /*if(press_B_to_quit() < 0)*/ /*{*/ /*deinit_av_dev();*/ /*deinit_tvout_pic();*/ /*draw_decision_pic(FAIL);*/ /*return False;*/ /*}*/ usleep(200*1000); } deinit_audio(); deinit_av_dev(); deinit_fb(test_para->avout_info.buffer_size); /*deinit_tvout_pic();*/ #endif return decision_loop(); }
int main () { assert (restart_gl_log ()); assert (start_gl ()); /* set up framebuffer with texture attachment */ assert (init_fb ()); /* load the picking shaders */ g_pick_sp = create_programme_from_files (PICK_VS, PICK_FS); g_pick_unique_id_loc = glGetUniformLocation (g_pick_sp, "unique_id"); g_pick_P_loc = glGetUniformLocation (g_pick_sp, "P"); g_pick_V_loc = glGetUniformLocation (g_pick_sp, "V"); g_pick_M_loc = glGetUniformLocation (g_pick_sp, "M"); assert (g_pick_P_loc > -1); assert (g_pick_V_loc > -1); assert (g_pick_M_loc > -1); /* load a mesh to draw in the main scene */ load_sphere (); GLuint sphere_sp = create_programme_from_files (SPHERE_VS, SPHERE_FS); GLint sphere_P_loc = glGetUniformLocation (sphere_sp, "P"); GLint sphere_V_loc = glGetUniformLocation (sphere_sp, "V"); GLint sphere_M_loc = glGetUniformLocation (sphere_sp, "M"); assert (sphere_P_loc > -1); assert (sphere_V_loc > -1); assert (sphere_M_loc > -1); /* set up view and projection matrices for sphere shader */ mat4 P = perspective ( 67.0f, (float)g_gl_width / (float)g_gl_height, 0.1f, 100.0f); mat4 V = look_at ( vec3 (0.0f, 0.0f, 5.0f), vec3 (0.0f, 0.0f, 0.0f), vec3 (0.0f, 1.0f, 0.0f)); glUseProgram (sphere_sp); glUniformMatrix4fv (sphere_P_loc, 1, GL_FALSE, P.m); glUniformMatrix4fv (sphere_V_loc, 1, GL_FALSE, V.m); glViewport (0, 0, g_gl_width, g_gl_height); while (!glfwWindowShouldClose (g_window)) { _update_fps_counter (g_window); /* bind the 'render to a texture' framebuffer for main scene */ glBindFramebuffer (GL_FRAMEBUFFER, 0); /* clear the framebuffer's colour and depth buffers */ glClearColor (0.2, 0.2, 0.2, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // render an obj or something glUseProgram (sphere_sp); glBindVertexArray (g_sphere_vao); // model matrices for all 3 spheres mat4 Ms[3]; // first sphere Ms[0] = identity_mat4 (); glUniformMatrix4fv (sphere_M_loc, 1, GL_FALSE, Ms[0].m); glDrawArrays (GL_TRIANGLES, 0, g_sphere_point_count); // 2nd sphere Ms[1] = translate (identity_mat4 (), vec3 (1.0, -1.0, -4.0)); glUniformMatrix4fv (sphere_M_loc, 1, GL_FALSE, Ms[1].m); glDrawArrays (GL_TRIANGLES, 0, g_sphere_point_count); // 3rd sphere Ms[2] = translate (identity_mat4 (), vec3 (-0.50, 2.0, -2.0)); glUniformMatrix4fv (sphere_M_loc, 1, GL_FALSE, Ms[2].m); glDrawArrays (GL_TRIANGLES, 0, g_sphere_point_count); /* bind framebuffer for pick */ draw_picker_colours (P, V, Ms); // flip drawn framebuffer onto the display glfwSwapBuffers (g_window); glfwPollEvents (); if (GLFW_PRESS == glfwGetKey (g_window, GLFW_KEY_ESCAPE)) { glfwSetWindowShouldClose (g_window, 1); } debug_colours = glfwGetKey (g_window, GLFW_KEY_SPACE); if (glfwGetMouseButton (g_window, 0)) { glBindFramebuffer (GL_FRAMEBUFFER, g_fb); double xpos, ypos; glfwGetCursorPos (g_window, &xpos, &ypos); int mx = (int)xpos; int my = (int)ypos; unsigned char data[4] = {0, 0, 0, 0}; glReadPixels ( mx, g_gl_height - my, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &data); int id = decode_id ((int)data[0], (int)data[1], (int)data[2]); int mid = -1; if (id == 255) { mid = 0; } if (id == 65280) { mid = 1; } if (id == 16711680) { mid = 2; } printf ("%i,%i,%i means -> id was %i, and monkey number is %i\n", data[0], data[1], data[2], id, mid); glBindFramebuffer (GL_FRAMEBUFFER, 0); } } return 0; }