static void host_really_activate(AIO_SLOT *slot) { AIO_SLOT *saved_slot = cur_slot; HOST_SLOT *hs = (HOST_SLOT *)slot; log_write(LL_MSG, "Activating new host connection"); slot->type = TYPE_HOST_ACTIVE_SLOT; s_host_slot = slot; write_active_file(); perform_action("host_activate"); /* Allocate the framebuffer or extend its dimensions if necessary */ if (!alloc_framebuffer(hs->fb_width, hs->fb_height)) { aio_close(1); return; } /* Set default desktop geometry for new client connections */ g_screen_info.width = hs->fb_width; g_screen_info.height = hs->fb_height; /* If requested, open file to save this session and write the header */ fbs_open_file(hs->fb_width, hs->fb_height); cur_slot = slot; /* Reset zlib streams in the Tight decoder */ reset_tight_streams(); /* Request initial screen contents */ log_write(LL_DETAIL, "Requesting full framebuffer update"); request_update(0); aio_setread(rf_host_msg, NULL, 1); /* Notify clients about desktop geometry change */ aio_walk_slots(fn_host_pass_newfbsize, TYPE_CL_SLOT); cur_slot = saved_slot; }
//----------------------------------------------------------------------------- // // Initialise the chip and the frame buffer driver. // //----------------------------------------------------------------------------- int __init rubyfb_init(void) { int i; ///// TESTING int j; ///// TESTING fb_info.FrameBufferAddress = alloc_framebuffer(); if (!fb_info.FrameBufferAddress) { printk ("rubyfb_init: Failed to allocate memory for the framebuffer.\n"); return -EINVAL; } // Clear the allocated memory memset(fb_info.FrameBufferAddress, 0, RUBY_PHYSICAL_MEM_SIZE); // Tell the lower levels what our addresses are ruby_set_addresses(fb_info.FrameBufferAddress, fb_info.FrameBufferDmaAddress); ruby_init_display(); strcpy(fb_info.gen.info.modename, "ruby"); fb_info.gen.info.changevar = NULL; fb_info.gen.info.node = -1; fb_info.gen.info.fbops = &ruby_ops; fb_info.gen.info.disp = &disp; fb_info.gen.info.switch_con = &fbgen_switch; fb_info.gen.info.updatevar = &fbgen_update_var; fb_info.gen.info.blank = &fbgen_blank; strcpy(fb_info.gen.info.fontname, default_fontname); fb_info.gen.parsize = 0; fb_info.gen.info.flags = FBINFO_FLAG_DEFAULT; fb_info.gen.fbhw = &ruby_hwswitch; fb_info.gen.fbhw->detect(); fbgen_get_var(&disp.var, -1, &fb_info.gen.info); disp.var.activate = FB_ACTIVATE_NOW; fbgen_do_set_var(&disp.var, 1, &fb_info.gen); fbgen_set_disp(-1, &fb_info.gen); fbgen_install_cmap(0, &fb_info.gen); if (register_framebuffer(&fb_info.gen.info) < 0) { printk("Failed to register the %s framebuffer device.\n", fb_info.gen.info.modename); free_framebuffer(); return -EINVAL; } if (periodic_flush_enable) { init_timer(&fb_info.ruby_timer); fb_info.ruby_timer.function = ruby_flush; fb_info.ruby_timer.data = 0; fb_info.ruby_timer.expires = (unsigned long) jiffies + HZ + 100; add_timer(&fb_info.ruby_timer); } ///////////////////////////// ////// Display Logo ////// /////////////////////////// ///// ruby_display_logo(); printk("fb%d: %s framebuffer device installed.\n", GET_FB_IDX(fb_info.gen.info.node), fb_info.gen.info.modename); printk("Display %s features %d x %d at %d bpp.\n", fb_info.gen.info.modename, RUBY_DISPLAY_WIDTH, RUBY_DISPLAY_HEIGHT, RUBY_DISPLAY_BPP); return 0; }
static void rf_host_fbupdate_recthdr(void) { HOST_SLOT *hs = (HOST_SLOT *)cur_slot; #ifdef CHROMIUM CARD32 *g_framebuffer; CARD16 g_fb_width, g_fb_height; g_framebuffer = GetFrameBuffer(&g_fb_width, &g_fb_height); #endif cur_rect.x = buf_get_CARD16(cur_slot->readbuf); cur_rect.y = buf_get_CARD16(&cur_slot->readbuf[2]); cur_rect.w = buf_get_CARD16(&cur_slot->readbuf[4]); cur_rect.h = buf_get_CARD16(&cur_slot->readbuf[6]); cur_rect.enc = buf_get_CARD32(&cur_slot->readbuf[8]); fbs_spool_data(cur_slot->readbuf, 12); /* Handle LastRect "encoding" first */ if (cur_rect.enc == RFB_ENCODING_LASTRECT) { log_write(LL_DEBUG, "LastRect marker received from the host"); cur_rect.x = cur_rect.y = 0; rect_count = 1; fbupdate_rect_done(); return; } /* Ignore zero-size rectangles */ if (cur_rect.h == 0 || cur_rect.w == 0) { log_write(LL_WARN, "Zero-size rectangle %dx%d at %d,%d (ignoring)", (int)cur_rect.w, (int)cur_rect.h, (int)cur_rect.x, (int)cur_rect.y); fbupdate_rect_done(); return; } /* Handle NewFBSize "encoding", as a special case */ if (cur_rect.enc == RFB_ENCODING_NEWFBSIZE) { log_write(LL_INFO, "New host desktop geometry: %dx%d", (int)cur_rect.w, (int)cur_rect.h); g_screen_info.width = hs->fb_width = cur_rect.w; g_screen_info.height = hs->fb_height = cur_rect.h; /* Reallocate the framebuffer if necessary */ if (!alloc_framebuffer(hs->fb_width, hs->fb_height)) { aio_close(1); return; } cur_rect.x = cur_rect.y = 0; /* NewFBSize is always the last rectangle regardless of rect_count */ rect_count = 1; fbupdate_rect_done(); return; } /* Prevent overflow of the framebuffer */ if (cur_rect.x >= g_fb_width || cur_rect.x + cur_rect.w > g_fb_width || cur_rect.y >= g_fb_height || cur_rect.y + cur_rect.h > g_fb_height) { log_write(LL_ERROR, "Rectangle out of framebuffer bounds: %dx%d at %d,%d", (int)cur_rect.w, (int)cur_rect.h, (int)cur_rect.x, (int)cur_rect.y); aio_close(0); return; } /* Ok, now the rectangle seems correct */ log_write(LL_DEBUG, "Receiving rectangle %dx%d at %d,%d", (int)cur_rect.w, (int)cur_rect.h, (int)cur_rect.x, (int)cur_rect.y); switch(cur_rect.enc) { case RFB_ENCODING_RAW: log_write(LL_DEBUG, "Receiving raw data, expecting %d byte(s)", cur_rect.w * cur_rect.h * sizeof(CARD32)); rect_cur_row = 0; aio_setread(rf_host_fbupdate_raw, PIXEL_ADDR(g_framebuffer, g_fb_width, g_fb_height, cur_rect.x, cur_rect.y), cur_rect.w * sizeof(CARD32)); break; case RFB_ENCODING_COPYRECT: log_write(LL_DEBUG, "Receiving CopyRect instruction"); aio_setread(rf_host_copyrect, NULL, 4); break; case RFB_ENCODING_HEXTILE: log_write(LL_DEBUG, "Receiving Hextile-encoded data"); setread_decode_hextile(&cur_rect); break; case RFB_ENCODING_TIGHT: log_write(LL_DEBUG, "Receiving Tight-encoded data"); setread_decode_tight(&cur_rect); break; default: log_write(LL_ERROR, "Unknown encoding: 0x%08lX", (unsigned long)cur_rect.enc); aio_close(0); } }