/* * Function : libaroma_ctl_list * Return Value: LIBAROMA_CONTROLP * Descriptions: create list scroll control */ LIBAROMA_CONTROLP libaroma_ctl_list( LIBAROMA_WINDOWP win, word id, int x, int y, int w, int h, int horizontal_padding, int vertical_padding, word bg_color, byte flags ){ /* allocating internal data */ LIBAROMA_CTL_SCROLLP mi = (LIBAROMA_CTL_SCROLLP) calloc(sizeof(LIBAROMA_CTL_SCROLL),1); if (!mi){ ALOGW("libaroma_ctl_list cannot allocating memory for list control"); return NULL; } mi->vpad = libaroma_window_measure_point(vertical_padding); mi->hpad = libaroma_window_measure_point(horizontal_padding); mi->h = mi->vpad*2; mi->flags = flags; libaroma_mutex_init(mi->mutex); libaroma_mutex_init(mi->imutex); /* create scroll control */ LIBAROMA_CONTROLP ctl = libaroma_ctl_scroll( win, id, x, y, w, h, bg_color, flags ); /* set scroll client */ libaroma_ctl_scroll_set_client( ctl, (voidp) mi, &_libaroma_ctl_list_handler ); /* set initial height */ libaroma_ctl_scroll_set_height(ctl, mi->h); return ctl; } /* End of libaroma_ctl_list */
/* * Function : LINUXFBDR_init * Return Value: byte * Descriptions: init framebuffer */ byte LINUXFBDR_init(LIBAROMA_FBP me) { ALOGV("LINUXFBDR initialized internal data"); /* allocating internal data */ LINUXFBDR_INTERNALP mi = (LINUXFBDR_INTERNALP) calloc(sizeof(LINUXFBDR_INTERNAL),1); if (!mi) { ALOGE("LINUXFBDR calloc internal data - memory error"); return 0; } /* set internal address */ me->internal = (voidp) mi; /* set release callback */ me->release = &LINUXFBDR_release; /* init mutex & cond */ libaroma_mutex_init(mi->mutex); /* open framebuffer device */ mi->fb = open(LINUXFBDR_DEVICE, O_RDWR, 0); if (mi->fb < 1) { /* if not works, try non android standard device path */ mi->fb = open(LINUXFBDR_DEVICE_NON_ANDROID, O_RDWR, 0); } if (mi->fb < 1) { /* cannot find device */ ALOGE("LINUXFBDR no framebuffer device"); goto error; /* exit if error */ } /* get framebuffer var & fix data */ ioctl(mi->fb, FBIOGET_FSCREENINFO, &mi->fix); /* fix info */ ioctl(mi->fb, FBIOGET_VSCREENINFO, &mi->var); /* var info */ /* dump info */ LINUXFBDR_dump(mi); /* set libaroma framebuffer instance values */ me->w = mi->var.xres; /* width */ me->h = mi->var.yres; /* height */ me->sz = me->w*me->h; /* width x height */ if (QCOMFB_init(me)){ /* qcom fb */ me->start_post = &QCOMFB_start_post; me->end_post = &QCOMFB_end_post; me->post = &QCOMFB_post; me->snapshoot = NULL; ALOGI("using qcom framebuffer driver"); } else{ /* it's not qcom */ ALOGI("not using qcom framebuffer driver"); if ((mi->var.bits_per_pixel != 32) && (mi->var.bits_per_pixel != 16)) { /* non 32/16bit colorspace is not supported */ ALOGE("LINUXFBDR bits_per_pixel=%i not supported", mi->var.bits_per_pixel); goto error; } /* init features - double buffer, vsync */ LINUXFBDR_init_features(me); /* set internal useful data */ mi->line = mi->fix.line_length; /* line memory size */ mi->depth = mi->var.bits_per_pixel; /* color depth */ mi->pixsz = mi->depth >> 3; /* pixel size per byte */ mi->fb_sz = (mi->var.xres_virtual * mi->var.yres_virtual * mi->pixsz); if (mi->fix.smem_len<(dword) mi->fb_sz){ /* smem_len is invalid */ ALOGE("LINUXFBDR smem_len(%i) < fb_sz(%i)", mi->fix.smem_len, mi->fb_sz); goto error; } /* map buffer */ ALOGV("LINUXFBDR mmap Framebuffer Memory"); mi->buffer = (voidp) mmap( 0, mi->fix.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, mi->fb, 0 ); if (!mi->buffer) { ALOGE("LINUXFBDR mmap framebuffer memory error"); goto error; } /* swap buffer now */ LINUXFBDR_flush(me); if (mi->pixsz == 2) { /* not 32bit depth */ mi->is32 = 0; /* init colorspace */ LINUXFBDR_init_16bit(me); } else { mi->is32 = 1; /* init colorspace */ LINUXFBDR_init_32bit(me); } } /* set config */ me->config = &LINUXFBDR_config; /* set dpi */ LINUXFBDP_set_dpi(me); /* ok */ goto ok; /* return */ error: free(mi); return 0; ok: return 1; } /* End of LINUXFBDR_init */
/* * Function : SDLFBDR_init * Return Value: byte * Descriptions: init framebuffer */ byte SDLFBDR_init(LIBAROMA_FBP me) { ALOGV("SDLFBDR initialized internal data"); /* allocating internal data */ SDLFBDR_INTERNALP mi = (SDLFBDR_INTERNALP) calloc(sizeof(SDLFBDR_INTERNAL),1); if (!mi) { ALOGE("SDLFBDR calloc internal data - memory error"); return 0; } if(SDL_Init(SDL_INIT_VIDEO) < 0) { ALOGE("Couldn't init SDL: %s", SDL_GetError()); return 0; } /* set internal address */ me->internal = (voidp) mi; /* set release callback */ me->release = &SDLFBDR_release; /* init mutex & cond */ libaroma_mutex_init(mi->mutex); mi->window = SDL_SetVideoMode(360, 600, 16, SDL_HWSURFACE); if(!mi->window) mi->window = SDL_SetVideoMode (360, 600, 16, SDL_SWSURFACE); if(!mi->window) { ALOGE("SDLFBDR could not create SDL surface"); goto error; } /* set libaroma framebuffer instance values */ me->w = mi->window->w; /* width */ me->h = mi->window->h; /* height */ me->sz = me->w * me->h; /* width x height */ /* set internal useful data */ mi->buffer = mi->window->pixels; mi->depth = mi->window->format->BitsPerPixel; mi->pixsz = mi->depth >> 3; mi->line = me->w * mi->pixsz; mi->fb_sz = (me->w * me->h * mi->pixsz); /* swap buffer now */ SDLFBDR_flush(me); mi->stride = mi->line - (me->w * mi->pixsz); me->start_post = &SDLFBDR_start_post; me->end_post = &SDLFBDR_end_post; me->post = &SDLFBDR_post; me->snapshoot = NULL; /* ok */ goto ok; /* return */ error: free(mi); return 0; ok: return 1; } /* End of SDLFBDR_init */
/* * Function : Framebuffer Driver Initializer * */ byte QNXGF_init(LIBAROMA_FBP me) { /* Allocating Internal Data */ ALOGV("QNXGF Initialized Internal Data"); QNXGF_INTERNALP mi = (QNXGF_INTERNALP) calloc(sizeof(QNXGF_INTERNAL),1); if (!mi) { ALOGE("QNXGF malloc internal data - Memory Error"); return 0; } libaroma_mutex_init(___qnxfbmutex); /* Set Internal Address */ me->internal = (voidp) mi; me->release = &QNXGF_release; me->double_buffer = 0; // 1; /************************* Init of Init QNX GF ******************************/ /* Device Attach */ if (gf_dev_attach( &mi->gdev, GF_DEVICE_INDEX(0), &mi->gdev_info ) != GF_ERR_OK) { ALOGE("QNXGF gf_dev_attach failed"); goto error; } /* Display Attach */ if (gf_display_attach( &mi->display, mi->gdev, 0, &mi->display_info ) != GF_ERR_OK) { ALOGE("QNXGF gf_display_attach failed"); gf_dev_detach(mi->gdev); goto error; } /* Layer Attach */ if (gf_layer_attach( &mi->layer, mi->display, 0, 0 ) != GF_ERR_OK) { ALOGE("QNXGF gf_layer_attach failed"); gf_display_detach(mi->display); gf_dev_detach(mi->gdev); goto error; } /* Create Surface */ if (gf_surface_create_layer( &mi->surface, &mi->layer, 1, 0, mi->display_info.xres, mi->display_info.yres, GF_FORMAT_PKLE_RGB565, NULL, 0 ) != GF_ERR_OK) { ALOGE("QNXGF gf_surface_create_layer failed"); gf_layer_detach(mi->layer); gf_display_detach(mi->display); gf_dev_detach(mi->gdev); goto error; } /* Set Surface */ gf_layer_set_surfaces(mi->layer, &mi->surface, 1); /* Create Context */ if (gf_context_create(&mi->context) != GF_ERR_OK) { ALOGE("QNXGF gf_context_create failed"); gf_surface_free(mi->surface); gf_layer_detach(mi->layer); gf_display_detach(mi->display); gf_dev_detach(mi->gdev); goto error; } /* Context Set Layer */ if (gf_context_set_surface(mi->context, mi->surface) != GF_ERR_OK) { ALOGE("QNXGF gf_context_set_surface failed"); gf_context_free(mi->context); gf_surface_free(mi->surface); gf_layer_detach(mi->layer); gf_display_detach(mi->display); gf_dev_detach(mi->gdev); goto error; } /* if (gf_display_set_dpms(mi->display,GF_DPMS_ON) != GF_ERR_OK) { ALOGI("QNXGF gf_display_set_dpms failed"); } else{ ALOGI("QNXGF gf_display_set_dpms OK"); } */ /************************* End of Init QNX GF *******************************/ /* Set AROMA Core Framebuffer Instance Values */ me->w = mi->display_info.xres; /* Width */ me->h = mi->display_info.yres; /* Height */ me->sz = me->w * me->h; /* Width x Height */ /* Set Callbacks */ me->start_post = &QNXGF_start_post; me->post = &QNXGF_post; me->end_post = &QNXGF_end_post; me->snapshoot = NULL; /* DUMP INFO */ QNXGF_dump(mi); /* Fixed DPI */ me->dpi = 160; /* OK */ goto ok; /* Return */ error: free(mi); return 0; ok: return 1; }