Example #1
0
static htsmsg_t *
hts_settings_load_one(const char *filename)
{
  ssize_t n;
  char *mem;
  fb_file *fp;
  htsmsg_t *r = NULL;

  /* Open */
  if (!(fp = fb_open(filename, 1, 0))) return NULL;
  
  /* Load data */
  mem    = malloc(fb_size(fp)+1);
  n      = fb_read(fp, mem, fb_size(fp));
  if (n >= 0) mem[n] = 0;

  /* Decode */
  if(n == fb_size(fp))
    r = htsmsg_json_deserialize(mem);

  /* Close */
  fb_close(fp);
  free(mem);

  return r;
}
Example #2
0
int
main(int argc, char **argv)
{
    struct vfont *vfp;

    bu_setprogname(argv[0]);

    if (!get_args(argc, argv)) {
        fputs(usage, stderr);
        bu_exit(1, NULL);
    }

    if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == NULL) {
        fprintf(stderr, "fblabel:  Unable to open framebuffer %s\n", framebuffer);
        bu_exit(12, NULL);
    }

    if (clear) {
        fb_clear(fbp, PIXEL_NULL);
    }

    if ((vfp = vfont_get(font1)) == VFONT_NULL) {
        fprintf(stderr, "fblabel:  Can't get font \"%s\"\n",
                font1 == NULL ? "(null)" : font1);
        bu_exit(1, NULL);
    }

    do_line(vfp, textstring);

    fb_close(fbp);
    vfont_free(vfp);

    return 0;
}
Example #3
0
int main(int argc, const char *argv[])
{
	int ret;
	char ch;
	
	srand(time(NULL));
	ret = fb_open();
	key_init();	
	draw_back();
	draw_grid();
	signal(SIGALRM, sig_handler);
	alarm(1);

	while (1) {
		ch = getchar();
		switch (ch) {
			case 'a':
				if(canleft(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_x--;
				}
				break;
			case 'd':
				if(canright(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_x++;
				}
				break;	
			case 's':
				if(candown(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_y++;
				}
				break;
			case 'w':
				if(canchange(pos_x,pos_y,cur_type,arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					type_chg(&cur_type);
				}
				break;
			default :
				break;
		}
		draw_type(pos_x, pos_y, cur_type, COLOR);
		draw_grid();
		if(!candown(pos_x, pos_y, cur_type, arr)) {
			draw_flag(pos_x, pos_y, cur_type, arr);
			if(gameover(arr)) {
				exit(0);
			}
			deleteone(arr);
			pos_x = XNUM/2; pos_y = 0;
			cur_type = rand()%14;
		}
	}

	fb_close();

	return 0;
}
static void
Stretch_Fatal(const char *str)
{
    if (src_fbp != FB_NULL && fb_close(src_fbp) == -1) {
	Message("Error closing input frame buffer");
	src_fbp = FB_NULL;
    }

    if (dst_fbp != FB_NULL && fb_close(dst_fbp) == -1) {
	Message("Error closing output frame buffer");
	src_fbp = FB_NULL;
    }

    Fatal(FB_NULL, "%s", str);
    /* NOT REACHED */
}
Example #5
0
File: test.c Project: hongbochen/fb
int main()
{
	FBDEV fbdev;
	memset(&fbdev,0,sizeof(FBDEV));
	strcpy(fbdev.dev,"/dev/fb0");	

	if(0 == fb_open(&fbdev)){
		printf("Open fail!!\n");
		return -1;
	}
	
	//打印frame buffer 所占内存的开始地址 
	pmem_start(&fbdev);
	//打印FB_TYPE
	p_type(&fbdev);
	//打印可见清晰度
	p_visible_res(&fbdev);
	//打印虚拟分辨率
	p_virt_res(&fbdev);
	//打印虚拟到可见的偏移量
	p_offset(&fbdev);
	//打印每个像素的位数
	p_bpp(&fbdev);
	//打印R,G,B和透明度
	p_rgbt(&fbdev);
	//打印在内存中的高度和宽度
	p_hw(&fbdev);

	fb_close(&fbdev);

	return 0;
}
Example #6
0
/*
 * destory mainstatus
 */
int maindeal_mainstatus_destory(struct mainstatus *status)
{
	//int kill(pid_t pid, int sig);
	if(status->mp3_pid != 0){
		kill(status->mp3_pid, SIGINT);
	}

	//pid_t waitpid(pid_t pid, int *status, int options);
	waitpid(status->mp3_pid, NULL, 0);
	
	//int fb_screen_destory(FB_SCREEN *screenp);
	fb_screen_destory(&status->screen);

	//int fb_close(FB *fbp);
	fb_close(&status->fb);
	
	//int fb_font_close(FB_FONT *ffp);
	fb_font_close(&status->font);

	/* umount U disk */
#ifndef _DEBUG_VIR	
	if(udisk_umount(status->udisk_path) < 0){
		fprintf(stderr, "%s: udisk_umount() failed\n", __func__);
		return -1;
	}
#endif
	return 0;
}
Example #7
0
// TODO: this could do with being more efficient
int fb_stat ( const char *path, struct filebundle_stat *st )
{
  int ret = 1;
  fb_dir *dir;
  fb_file *fp;

  if (*path == '/') {
    struct stat _st;
    if (!lstat(path, &_st)) {
      st->type   = FB_DIRECT;
      st->is_dir = S_ISDIR(_st.st_mode) ? 1 : 0;
      st->size   = _st.st_size;
      ret        = 0;
    }
  } else if ((dir = fb_opendir(path))) {
    st->type   = dir->type;
    st->is_dir = 1;
    st->size   = 0;
    ret = 0;
    fb_closedir(dir);
  } else if ((fp = fb_open(path, 0, 0))) {
    st->type   = fp->type;
    st->is_dir = 0;
    st->size   = fp->size;
    ret = 0;
    fb_close(fp);
  }
  return ret;
}
Example #8
0
void fb_cleanup(void)
{
    Debug("fb_cleanup()\n");
    if (saved_fb)
	fb_restore();
    if (fb)
	fb_unmap();
    if (fb_fd != -1) {
	if (saved_cmap.len) {
	    fb_cmap = saved_cmap;
	    RESTORE_AND_FREE_COMPONENT(red);
	    RESTORE_AND_FREE_COMPONENT(green);
	    RESTORE_AND_FREE_COMPONENT(blue);
	    if (fb_cmap.transp)
		RESTORE_AND_FREE_COMPONENT(transp);
	    fb_set_cmap();
	}
	//fb_var = saved_var;
	memcpy(&fb_var, &saved_var, sizeof(struct fb_var_screeninfo));
	fb_set_var();
	fb_get_var();
	/* FIXME: compare fb_var with saved_var */
	fb_get_fix();
	/* FIXME: compare fb_fix with saved_fix */
	fb_close();
    }
}
Example #9
0
int main()
{
    info_t fb;
    fb_init(&fb);
    mouse_test(&fb);
    fb_close(&fb);
    return 0;
}
Example #10
0
int load_565rle_image(char *fn)
{
    struct FB fb;
    struct stat s;
    unsigned short *data, *bits, *ptr;
    unsigned count, max;
    int fd;

    if (vt_set_mode(1))
        return -1;

    fd = open(fn, O_RDONLY);
    if (fd < 0) {
        ERROR("cannot open '%s'\n", fn);
        goto fail_restore_text;
    }

    if (fstat(fd, &s) < 0) {
        goto fail_close_file;
    }

    data = mmap(0, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
    if (data == MAP_FAILED)
        goto fail_close_file;

    if (fb_open(&fb))
        goto fail_unmap_data;

    max = fb_width(&fb) * fb_height(&fb);
    ptr = data;
    count = s.st_size;
    bits = fb.bits;
    while (count > 3) {
        unsigned n = ptr[0];
        if (n > max)
            break;
        android_memset16(bits, ptr[1], n << 1);
        bits += n;
        max -= n;
        ptr += 2;
        count -= 4;
    }

    munmap(data, s.st_size);
    fb_update(&fb);
    fb_close(&fb);
    close(fd);
    unlink(fn);
    return 0;

fail_unmap_data:
    munmap(data, s.st_size);
fail_close_file:
    close(fd);
fail_restore_text:
    vt_set_mode(0);
    return -1;
}
Example #11
0
int
main(int argc, char **argv)
{
    register int i;
    struct timeval tv;

    if ( !get_args( argc, argv ) )  {
	(void)fputs(usage, stderr);
	bu_exit( 1, NULL );
    }

    if ( fps > 0.0 ) {
	tv.tv_sec = (long) (1.0 / fps);
	tv.tv_usec = (long) (((1.0 / fps) - tv.tv_sec) * 1000000);
    }

    if ( (fbp = fb_open( NULL, size, size)) == FBIO_NULL )  {
	fprintf(stderr, "fbcmrot:  fb_open failed\n");
	return	1;
    }

    local_inp = &cm1;
    local_outp = &cm2;
    fb_rmap( fbp, local_inp );

    while (1)  {
	register int from;
	ColorMap *tp;

	/* Build color map for current value */
	for ( i=0, from = increment; i < 256; i++, from++ ) {
	    if ( from < 0 )
		from += 256;
	    else if ( from > 255 )
		from -= 256;
	    local_outp->cm_red[i]   = local_inp->cm_red[from];
	    local_outp->cm_green[i] = local_inp->cm_green[from];
	    local_outp->cm_blue[i]  = local_inp->cm_blue[from];
	}

	fb_wmap( fbp, local_outp );
	tp = local_outp;
	local_outp = local_inp;
	local_inp = tp;

	if ( fps > 0.0 )  {
	    fd_set readfds;

	    FD_ZERO(&readfds);
	    FD_SET(fileno(stdin), &readfds);
	    select(fileno(stdin)+1, &readfds, (fd_set *)0, (fd_set *)0, &tv);
	}
	if ( onestep )
	    break;
    }
    fb_close( fbp );
    return	0;
}
Example #12
0
static void closeFramebuffer(void)
{
  if (fb)
    {
      fb_close(fb);
      fb_delete(fb);
      fb= 0;
    }
}
Example #13
0
File: lgt.c Project: kanzure/brlcad
void
close_Output_Device(int frame)
{
    if ((movie.m_noframes > 1 && movie.m_fullscreen) ||
	(frame == movie.m_endframe)) {
	(void) fb_close(fbiop);
	fbiop = FBIO_NULL;
    }
    return;
}
Example #14
0
/*
  Foo - clean up before return from rasterizer
*/
static int
Foo(int code)				/* returns status code */
{
    if ( debug ) fprintf(stderr, "Foo(%d)\n", code);
    fb_close( fbp );		/* release framebuffer */

    FreeUp();			/* deallocate descriptors */

    return code;
}
Example #15
0
/*
 * Called by Tcl when the object is destroyed.
 */
HIDDEN void
fbo_deleteProc(ClientData clientData)
{
    struct fb_obj *fbop = (struct fb_obj *)clientData;

    /* close framebuffer */
    fb_close(fbop->fbo_fbs.fbs_fbp);

    bu_vls_free(&fbop->fbo_name);
    BU_LIST_DEQUEUE(&fbop->l);
    bu_free((genptr_t)fbop, "fbo_deleteProc: fbop");
}
Example #16
0
/*
 *			D O _ F B
 */
void
do_fb(void)
{
    FBIO	*fbp;

    if ( (fbp = fb_open( framebuffer, 0, 0 )) == FBIO_NULL ) {
	bu_exit( 2, "Unable to open framebuffer\n" );
    }
    if ( fb_wmap( fbp, &map ) < 0 )
	fprintf( stderr, "fbgammamod: unable to write color map\n");
    fb_close(fbp);
}
Example #17
0
int main()
{
	DeviceFB *pDeviceFb = fb_open("/dev/fb0");
	if (pDeviceFb)
	{
		printf("w:%d h:%d bpp:%d\n",
			pDeviceFb->vinfo.xres,
			pDeviceFb->vinfo.yres,
			pDeviceFb->vinfo.bits_per_pixel);
			
		fb_close(pDeviceFb);
	}
	return 0;
}
Example #18
0
int
closFbDevice()
{
    int ret;
    notify("Closing frame buffer", NOTIFY_APPEND);
    if (fb_close(fbiop) == -1)
	ret = 0;
    else {
	ret = 1;
	fbiop = FBIO_NULL;
    }
    notify(NULL, NOTIFY_DELETE);
    return ret;
}
Example #19
0
File: eluosi.c Project: yumm007/C
int main(void)
{
   int ret, c;

   ret = fb_open();
   if (ret != 0) {
	fprintf(stderr, "fb_open() error.\n");
		exit(1);
   }
   
	init_board();

   fb_close();
   return 0;
}
int
main(int argc, char **argv)
{
    fb *fbp;
    FILE *fp;
    int fbsize = 512;
    int i;

    while (argc > 1) {
	if (BU_STR_EQUAL(argv[1], "-H")) {
	    fbsize = 1024;
	} else if (argv[1][0] == '-') {
	    if ( (!BU_STR_EQUAL(argv[1], "-?")) && (!BU_STR_EQUAL(argv[1], "-h")) )
		fprintf(stderr, "fb-cmap: unknown flag %s\n", argv[1]);
	    bu_exit(1, "%s", usage);
	} else
	    break;	/* must be a filename */
	argc--;
	argv++;
    }

    if (argc > 1) {
	if ((fp = fopen(argv[1], "wb")) == NULL) {
	    fprintf(stderr, "fb-cmap: can't open \"%s\"\n", argv[1]);
	    bu_exit(2, "%s", usage);
	}
    } else {
	fp = stdout;
	if (isatty(fileno(fp)))
	    fprintf(stderr, "%s       Program continues running:\n", usage);
    }

    if ((fbp = fb_open(NULL, fbsize, fbsize)) == FB_NULL)
	bu_exit(2, "Unable to open framebuffer\n");

    i = fb_rmap(fbp, &cm);
    fb_close(fbp);
    if (i < 0) {
	bu_exit(3, "fb-cmap: can't read colormap\n");
    }

    for (i = 0; i <= 255; i++) {
	fprintf(fp, "%d\t%04x %04x %04x\n", i,
		cm.cm_red[i], cm.cm_green[i], cm.cm_blue[i]);
    }

    return 0;
}
Example #21
0
int main(int argc, const char *argv[])
{
	system("clear");
	int ret,ch;
	ret = fb_open();	
	//draw_element(100, 100, 0x75);
	//draw_element(150, 100, PINK);
	//exit(1);

	struct termios tc, old_tc;
	tcgetattr(0, &tc);//0是输入
	tcgetattr(0, &old_tc);//用于下面恢复
	tc.c_lflag &= (~ICANON);//启动食品模式
	tc.c_lflag &= (~ECHO);//ECHO 使用回显  &~(ECHO) 取消回显
	tcsetattr(0, TCSANOW, &tc);//TCSANOW 立刻生效

	init();
	init_current_block();
	draw_picture(ROW_CANVAS, 0x1a, IS_DRAW);

	signal(SIGALRM, sig_handler);
	alarm(1);

	while (1) {
		ch = getchar();
		if (ch == 'q') {//exit
			break;
		}
		if (ch =='w') {
			change();
		}
		if (ch =='a') {
			left();
		}
		if (ch =='s') {
			down();
		}
		if (ch =='d') {
			right();
		}
	}

	tcsetattr(0, TCSANOW, &old_tc);
	fb_close();

	return 0;
}
int fb_off_all()
{
    int fp, i;

    for (i = 0; i < TOTAL_FB_NUM; i++) {
        fp = fb_open(i);
        if (fp < 0)
            return -1;

        if (ioctl(fp, FBIOBLANK, FB_BLANK_POWERDOWN) < 0)
            ALOGE("%s:: FBIOBLANK failed", __func__);

        fb_off(fp);
        fb_close(fp);
    }

    return 0;
}
Example #23
0
int main(int argc, char* argv[]) {
    framebuffer_t* fb;
    img32_t* img;
    
    // check for proper usage
    if(argc == 1) {
	fprintf(stderr, "Usage: %s lena.ppm\n", argv[0]);
	return EX_USAGE;
    }
    
    // initialize the framebuffer (with single buffering)
    fprintf(stderr, "Starting up...\n");
    if((fb = fb_open(0x11e, 0, 0)) == NULL) {
	perror("fb_open");
	return EX_UNAVAILABLE;
    }

    // clear the screen in a shade of blue
    cls(fb, 0x00007F);

    // pause
    getc(stdin);

    // load the image
    img = read_ppm(argv[1]);
    
    // clear the screen in a shade of red
    cls(fb, 0x7F0000);

    // display the image centered
    blit(fb, img, fb->info.vi_width / 2 - img->w / 2, fb->info.vi_height / 2 - img->h / 2);
    
    // free the image
    free(img);

    // pause for dramatic effect...
    getc(stdin);
    
    // tidy up
    fprintf(stderr, "Shutting down...\n");
    fb_close(fb);
    return EX_OK;
}
Example #24
0
int
main(int argc, char **argv)
{
    int	x, y;
    int	xin, yin;		/* number of sceen output lines */

    height = width = 512;		/* Defaults */

    if ( !get_args( argc, argv ) )  {
	(void)fputs(usage, stderr);
	bu_exit( 1, NULL );
    }

    /* Open Display Device */
    if ((fbp = fb_open(framebuffer, width, height )) == NULL ) {
	fprintf( stderr, "fb_open failed\n");
	bu_exit( 1, NULL );
    }

    /* determine "reasonable" behavior */
    xin = fb_getwidth(fbp) - scr_xoff;
    if ( xin < 0 ) xin = 0;
    if ( xin > width ) xin = width;
    yin = fb_getheight(fbp) - scr_yoff;
    if ( yin < 0 ) yin = 0;
    if ( yin > height ) yin = height;

    for ( y = scr_yoff; y < scr_yoff + yin; y++ )  {
	if ( inverse ) {
	    (void)fb_read( fbp, scr_xoff, fb_getheight(fbp)-1-y, inbuf, xin );
	} else {
	    (void)fb_read( fbp, scr_xoff, y, inbuf, xin );
	}
	for ( x = 0; x < xin; x++ ) {
	    obuf[x] = (((int)inbuf[3*x+RED]) + ((int)inbuf[3*x+GRN])
		       + ((int)inbuf[3*x+BLU])) / 3;
	}
	fwrite( &obuf[0], sizeof( char ), xin, outfp );
    }

    fb_close( fbp );
    bu_exit( 0, NULL );
}
Example #25
0
int main(int argc, char **argv)
{
	struct fb fb;
	uint32_t word;

	void *mem;
	int fd;	

	char *p;

	uint32_t i;

	int rv;

	if (argc != 3)
		return -1;
	
	word = strtoul(argv[2], &p, 16);	
	if (*p != '\0') {
		fprintf(stderr, "Invalid value.\n");
		exit(EXIT_FAILURE);
	}
	
	rv = fb_open(argv[1], &fb);
	if (rv) {
		fprintf(stderr, "Failed to open framebuffer device.\n");
		exit(EXIT_FAILURE);
	}

	fprintf(stderr, "Word: 0x%x, Bpp_byte: 0x%u.\n", word, fb.bpp_byte);
	
	mem = fb.mem;

	for (i = 0; i < fb.mem_size; i += fb.bpp_byte) {
		memcpy(mem, &word, fb.bpp_byte);
		mem += fb.bpp_byte;
	}
	
	fb_close(&fb);

	return 0;
}
Example #26
0
File: main.c Project: yumm007/C
int main(void)
{
     int ret;

     ret = fb_open();
     if (ret != 0) {
	  fprintf(stderr, "fb_open() error.\n");
	  exit(1);
     }
	 
	 //srand(getpid());
	 //r = rand() % 10;
	 //printf("x=%d, y=%d, rand=%d\n",xres(),yres(),r);		

	 clear(0,yres());
	 move();

     fb_close();
     return 0;
}
Example #27
0
int main(int argc, char **argv)
{
	struct fb fb;

	int rv;

	if (argc != 2)
		return -1;
	
	rv = fb_open(argv[1], &fb);
	if (rv) {
		exit(EXIT_FAILURE);
	}

	display_h_color_bar(fb.mem, fb.w, fb.h, fb.bpp);
	
	fb_close(&fb);

	return 0;
}
Example #28
0
int
main(int argc, char **argv)
{
    int	n;

    if ( argc > 1 ) {
	if ( (fp = fopen(argv[1], "r")) == NULL ) {
	    fprintf( stderr, "%s", Usage );
	    bu_exit(1, "pixhist3d: can't open \"%s\"\n", argv[1] );
	}
    } else
	fp = stdin;

    if ( isatty(fileno(fp)) ) {
	bu_exit(2, "%s", Usage );
    }

    if ( (fbp = fb_open( NULL, 512, 512 )) == NULL )  {
	bu_exit(12, "fb_open failed\n");
    }

    while ( (n = fread(&ibuf[0], sizeof(*ibuf), sizeof(ibuf), fp)) > 0 ) {
	register unsigned char *bp;
	register int i;

	bp = &ibuf[0];
	for ( i = n/3; i > 0; i--, bp += 3 )  {
	    rxb[ bp[RED] ][ bp[BLU] ]++;
	    rxg[ bp[RED] ][ bp[GRN] ]++;
	    bxg[ bp[BLU] ][ bp[GRN] ]++;
	}
    }

    disp_array( rxg, 0, 0 );
    disp_array( rxb, 256, 0 );
    disp_array( bxg, 0, 256 );

    fb_close( fbp );
    return 0;
}
Example #29
0
int main(void)
{
	int ret;

	ret = fb_open();
	if (ret != 0) {
		fprintf(stderr, "fb_open() error.\n");
		exit(1);
	}

	init();

	while (1) {
		move();
		change_dir();
		usleep(30000);
	}

	fb_close();

	return 0;
}
Example #30
0
int main(int argc, const char *argv[])
{
    FBDEV fbdev;
    MOUSE mouse;
    int err;


    /*open fb*/
    err = fb_init(&fbdev, NULL);
    if(FALSE == err)
    {
        return -1;
    };

    thr_mouse(NULL, &fbdev, &mouse);

    /*destroy*/
    fb_close(&fbdev);
    mouse_close(&mouse);

    return 0;
}