[Mplayer-cvslog] CVS: main/libvo vo_fbdev.c,1.41,1.42

Szabolcs Berecz szabii at users.sourceforge.net
Sat Jun 2 22:48:18 CEST 2001


Update of /cvsroot/mplayer/main/libvo
In directory usw-pr-cvs1:/tmp/cvs-serv11098

Modified Files:
	vo_fbdev.c 
Log Message:
some little cleanup

Index: vo_fbdev.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_fbdev.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -r1.41 -r1.42
*** vo_fbdev.c	2001/05/24 20:48:45	1.41
--- vo_fbdev.c	2001/06/02 20:48:16	1.42
***************
*** 28,32 ****
  #include "sub.h"
  #include "yuv2rgb.h"
- extern void rgb15to16_mmx(char *s0, char *d0, int count);
  
  LIBVO_EXTERN(fbdev)
--- 28,31 ----
***************
*** 39,42 ****
--- 38,42 ----
  };
  
+ extern void rgb15to16_mmx(char *s0, char *d0, int count);
  extern int verbose;
  
***************
*** 45,52 ****
  ******************************/
  
- /*
-  * read the fb.modes manual page!
-  */
- 
  typedef struct {
  	char *name;
--- 45,48 ----
***************
*** 108,113 ****
  		if (line[line_pos] == '\0' || line[line_pos] == '#') {
  			read_nextline = 1;
- 			if (i == num)
- 				goto out_ok;
  			goto out_eol;
  		}
--- 104,107 ----
***************
*** 118,121 ****
--- 112,118 ----
  			while (line[++line_pos] != c && line[line_pos])
  				/* NOTHING */;
+ 			if (!line[line_pos])
+ 				goto out_eol;
+ 			line[line_pos] = ' ';
  		} else {
  			for (/* NOTHING */; !isspace(line[line_pos]) &&
***************
*** 129,134 ****
  			goto out_eol;
  		}
! 		line[line_pos] = '\0';
! 		line_pos++;
  	}
  out_ok:
--- 126,130 ----
  			goto out_eol;
  		}
! 		line[line_pos++] = '\0';
  	}
  out_ok:
***************
*** 148,157 ****
  	char *endptr;	// strtoul()...
  	int tmp, i;
- 
- #ifdef DEBUG
- 	assert(cfgfile != NULL);
- #endif
  
! 	printf("Reading %s: ", cfgfile);
  
  	if ((fp = fopen(cfgfile, "r")) == NULL) {
--- 144,150 ----
  	char *endptr;	// strtoul()...
  	int tmp, i;
  
! 	if (verbose > 0)
! 		printf("Reading %s: ", cfgfile);
  
  	if ((fp = fopen(cfgfile, "r")) == NULL) {
***************
*** 185,189 ****
  		        if (!(fb_modes = (fb_mode_t *) realloc(fb_modes,
  				sizeof(fb_mode_t) * (nr_modes + 1)))) {
! 			    printf("can't realloc 'fb_modes': %s\n", strerror(errno));
  			    goto err_out;
  		        }
--- 178,183 ----
  		        if (!(fb_modes = (fb_mode_t *) realloc(fb_modes,
  				sizeof(fb_mode_t) * (nr_modes + 1)))) {
! 			    printf("can't realloc 'fb_modes' (nr_modes = %d):"
! 					    " %s\n", nr_modes, strerror(errno));
  			    goto err_out;
  		        }
***************
*** 247,251 ****
  				goto err_out_parse_error;
  		} else if (!strcmp(token[0], "endmode")) {
! 			/* NOTHING for now*/
  		} else if (!strcmp(token[0], "accel")) {
  			if (get_token(1) < 0)
--- 241,245 ----
  				goto err_out_parse_error;
  		} else if (!strcmp(token[0], "endmode")) {
! 			/* FIXME NOTHING for now*/
  		} else if (!strcmp(token[0], "accel")) {
  			if (get_token(1) < 0)
***************
*** 315,319 ****
  		goto err_out_not_valid;
  out:
! 	printf("%d modes\n", nr_modes);
  	free(line);
  	fclose(fp);
--- 309,314 ----
  		goto err_out_not_valid;
  out:
! 	if (verbose > 0)
! 		printf("%d modes\n", nr_modes);
  	free(line);
  	fclose(fp);
***************
*** 333,337 ****
  	return -2;
  err_out_not_valid:
! 	printf("mode is not definied correctly");
  	goto err_out_print_linenum;
  }
--- 328,332 ----
  	return -2;
  err_out_not_valid:
! 	printf("previous mode is not correct");
  	goto err_out_print_linenum;
  }
***************
*** 385,407 ****
  
  	/* find first working mode */
! 	for (i = nr_modes - 1; i; i--, best++) {
  		if (in_range(hfreq, hsf(best)) && in_range(vfreq, vsf(best)) &&
  				in_range(dotclock, dcf(best)))
  			break;
- 		if (verbose > 1)
- 			printf(FBDEV "can't set %dx%d\n", best->xres, best->yres);
- 	}
  
! 	if (!i)
  		return NULL;
! 	if (i == 1)
  		return best;
  
! 	for (curr = best + 1; i; i--, curr++) {
! 		if (!in_range(hfreq, hsf(curr)))
! 			continue;
! 		if (!in_range(vfreq, vsf(curr)))
! 			continue;
! 		if (!in_range(dotclock, dcf(curr)))
  			continue;
  		if (verbose > 1)
--- 380,400 ----
  
  	/* find first working mode */
! 	for (i = 0; i < nr_modes; i++, best++)
  		if (in_range(hfreq, hsf(best)) && in_range(vfreq, vsf(best)) &&
  				in_range(dotclock, dcf(best)))
  			break;
  
! 	if (i == nr_modes)
  		return NULL;
! 	if (i == nr_modes - 1)
  		return best;
  
! 	if (verbose > 1)
! 		printf(FBDEV "%dx%d\n", best->xres, best->yres);
! 
! 	for (curr = best + 1; i < nr_modes; i++, curr++) {
! 		if (!in_range(hfreq, hsf(curr)) ||
! 		    !in_range(vfreq, vsf(curr)) ||
! 		    !in_range(dotclock, dcf(curr)))
  			continue;
  		if (verbose > 1)
***************
*** 439,442 ****
--- 432,436 ----
  	p->red.msb_right = p->green.msb_right = p->blue.msb_right = 0;
  	p->transp.offset = p->transp.length = 0;
+ 	p->blue.offset = 0;
  	switch (bpp) {
  		case 32:
***************
*** 449,453 ****
  			p->green.length = 8;
  			p->blue.length = 8;
- 			p->blue.offset = 0;
  			break;
  		case 16:
--- 443,446 ----
***************
*** 457,461 ****
  			p->green.offset = 5;
  			p->blue.length = 5;
- 			p->blue.offset = 0;
  			break;
  		case 15:
--- 450,453 ----
***************
*** 465,469 ****
  			p->green.offset = 5;
  			p->blue.length = 5;
- 			p->blue.offset = 0;
  			break;
  	}
--- 457,460 ----
***************
*** 493,497 ****
  	char *endptr = s;	// to start the loop
  	range_t *r = NULL;
! 	int i, j;
  
  	if (!s)
--- 484,488 ----
  	char *endptr = s;	// to start the loop
  	range_t *r = NULL;
! 	int i;
  
  	if (!s)
***************
*** 529,538 ****
  		r[i].min = tmp_min;
  		r[i].max = tmp_max;
  		s = endptr + 1;
  	}
- 	/* check if we have negative numbers... */
- 	for (j = 0; j < i; j++)
- 		if (r[j].min < 0 || r[j].max < 0)
- 			goto out_err;
  	r[i].min = r[i].max = -1;
  	return r;
--- 520,527 ----
  		r[i].min = tmp_min;
  		r[i].max = tmp_max;
+ 		if (r[i].min < 0 || r[i].max < 0)
+ 			goto out_err;
  		s = endptr + 1;
  	}
  	r[i].min = r[i].max = -1;
  	return r;
***************
*** 561,567 ****
  static fb_mode_t *fb_mode = NULL;
  
  /* vo_fbdev related variables */
- static int fb_preinit_done = 0;
- static int fb_works = 0;
  static int fb_dev_fd;
  static size_t fb_size;
--- 550,559 ----
  static fb_mode_t *fb_mode = NULL;
  
+ /* vt related variables */
+ int vt_fd;
+ FILE *vt_fp;
+ int vt_doit = 1;
+ 
  /* vo_fbdev related variables */
  static int fb_dev_fd;
  static size_t fb_size;
***************
*** 577,581 ****
  static int fb_bpp;		// 32: 32  24: 24  16: 16  15: 15
  static int fb_bpp_we_want;	// 32: 32  24: 24  16: 16  15: 15
! static int fb_screen_width;
  static void (*draw_alpha_p)(int w, int h, unsigned char *src,
  		unsigned char *srca, int stride, unsigned char *dst,
--- 569,575 ----
  static int fb_bpp;		// 32: 32  24: 24  16: 16  15: 15
  static int fb_bpp_we_want;	// 32: 32  24: 24  16: 16  15: 15
! static int fb_line_len;
! static int fb_xres;
! static int fb_yres;
  static void (*draw_alpha_p)(int w, int h, unsigned char *src,
  		unsigned char *srca, int stride, unsigned char *dst,
***************
*** 587,590 ****
--- 581,586 ----
  static int out_width;
  static int out_height;
+ static int first_row;
+ static int last_row;
  static uint32_t pixel_format;
  static int fs;
***************
*** 664,667 ****
--- 660,669 ----
  static int fb_preinit(void)
  {
+ 	static int fb_preinit_done = 0;
+ 	static int fb_works = 0;
+ 
+ 	if (fb_preinit_done)
+ 		return fb_works;
+ 
  	if (!fb_dev_name && !(fb_dev_name = getenv("FRAMEBUFFER")))
  		fb_dev_name = "/dev/fb0";
***************
*** 697,701 ****
  	fb_preinit_done = 1;
  	fb_works = 1;
! 	return 0;
  err_out_fd:
  	close(fb_dev_fd);
--- 699,703 ----
  	fb_preinit_done = 1;
  	fb_works = 1;
! 	return 1;
  err_out_fd:
  	close(fb_dev_fd);
***************
*** 703,707 ****
  err_out:
  	fb_preinit_done = 1;
! 	return 1;
  }
  
--- 705,710 ----
  err_out:
  	fb_preinit_done = 1;
! 	fb_works = 0;
! 	return 0;
  }
  
***************
*** 767,806 ****
  			printf(FBDEV "accel: %u\n", fb_finfo.accel);
  		}
  	}
  }
  
  static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
  		uint32_t d_height, uint32_t fullscreen, char *title,
  		uint32_t format)
  {
- #define FS	(fullscreen & 0x01)
- #define VM	(fullscreen & 0x02)
- #define ZOOM	(fullscreen & 0x04)
- #define FLIP	(fullscreen & 0x08)
- 
  	struct fb_cmap *cmap;
  
! 	fs = FS;
! 	if (!fb_preinit_done)
! 		if (fb_preinit())
! 			return 1;
! 	if (!fb_works)
! 		return 1;
  
! 	flip = FLIP;
  
! 	if (ZOOM) {
  		printf(FBDEV "-zoom is not supported\n");
  		return 1;
  	}
! 	if (fb_mode_name && !VM) {
! 		printf(FBDEV "-fbmode can be used only with -vm"
! 				" (is it the right behaviour?)\n");
  		return 1;
  	}
! 	if (VM)
! 		if (parse_fbmode_cfg(fb_mode_cfgfile) < 0)
  			return 1;
! 	if (d_width && (fs || VM)) {
  		out_width = d_width;
  		out_height = d_height;
--- 770,827 ----
  			printf(FBDEV "accel: %u\n", fb_finfo.accel);
  		}
+ 		printf(FBDEV "fb_bpp: %d\n", fb_bpp);
+ 		printf(FBDEV "fb_real_bpp: %d\n", fb_real_bpp);
+ 		printf(FBDEV "fb_pixel_size: %d bytes\n", fb_pixel_size);
+ 		printf(FBDEV "other:\n");
+ 		printf(FBDEV "in_width: %d\n", in_width);
+ 		printf(FBDEV "in_height: %d\n", in_height);
+ 		printf(FBDEV "out_width: %d\n", out_width);
+ 		printf(FBDEV "out_height: %d\n", out_height);
+ 		printf(FBDEV "first_row: %d\n", first_row);
+ 		printf(FBDEV "last_row: %d\n", last_row);
+ 		if (verbose > 1)
+ 			printf(FBDEV "draw_alpha_p:%dbpp = %p\n", fb_bpp, draw_alpha_p);
  	}
  }
  
+ static void vt_set_textarea(int u, int l)
+ {
+ 	/* how can I determine the font height?
+ 	 * just use 16 for now
+ 	 */
+ 	int urow = ((u + 15) / 16) + 1;
+ 	int lrow = l / 16;
+ 
+ 	if (verbose > 1)
+ 		printf(FBDEV "vt_set_textarea(%d,%d): %d,%d\n", u, l, urow, lrow);
+ 	fprintf(vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0);
+ 	fflush(vt_fp);
+ }
+ 
  static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width,
  		uint32_t d_height, uint32_t fullscreen, char *title,
  		uint32_t format)
  {
  	struct fb_cmap *cmap;
+ 	int vm = fullscreen & 0x02;
+ 	int zoom = fullscreen & 0x04;
  
! 	fs = fullscreen & 0x01;
! 	flip = fullscreen & 0x08;
  
! 	if (!fb_preinit())
! 		return 1;
  
! 	if (zoom) {
  		printf(FBDEV "-zoom is not supported\n");
  		return 1;
  	}
! 	if (fb_mode_name && !vm) {
! 		printf(FBDEV "-fbmode can only be used with -vm\n");
  		return 1;
  	}
! 	if (vm && (parse_fbmode_cfg(fb_mode_cfgfile) < 0))
  			return 1;
! 	if (d_width && (fs || vm)) {
  		out_width = d_width;
  		out_height = d_height;
***************
*** 819,823 ****
  		}
  		fb_mode2fb_vinfo(fb_mode, &fb_vinfo);
! 	} else if (VM) {
  		monitor_hfreq = str2range(monitor_hfreq_str);
  		monitor_vfreq = str2range(monitor_vfreq_str);
--- 840,844 ----
  		}
  		fb_mode2fb_vinfo(fb_mode, &fb_vinfo);
! 	} else if (vm) {
  		monitor_hfreq = str2range(monitor_hfreq_str);
  		monitor_vfreq = str2range(monitor_vfreq_str);
***************
*** 847,850 ****
--- 868,916 ----
  		return 1;
  	}
+ 
+ 	fb_pixel_size = fb_vinfo.bits_per_pixel / 8;
+ 	fb_real_bpp = fb_vinfo.red.length + fb_vinfo.green.length +
+ 		fb_vinfo.blue.length;
+ 	fb_bpp = (fb_pixel_size == 4) ? 32 : fb_real_bpp;
+ 	if (fb_bpp_we_want != fb_bpp)
+ 		printf(FBDEV "requested %d bpp, got %d bpp)!!!\n",
+ 				fb_bpp_we_want, fb_bpp);
+ 
+ 	switch (fb_bpp) {
+ 	case 32:
+ 		draw_alpha_p = vo_draw_alpha_rgb32;
+ 		break;
+ 	case 24:
+ 		draw_alpha_p = vo_draw_alpha_rgb24;
+ 		break;
+ 	case 16:
+ 		draw_alpha_p = vo_draw_alpha_rgb16;
+ 		break;
+ 	case 15:
+ 		draw_alpha_p = vo_draw_alpha_rgb15;
+ 		break;
+ 	}
+ 
+ 	if (flip & ((((pixel_format & 0xff) + 7) / 8) != fb_pixel_size)) {
+ 		printf(FBDEV "Flipped output with depth conversion is not "
+ 				"supported\n");
+ 		return 1;
+ 	}
+ 
+ 	fb_xres = fb_vinfo.xres;
+ 	fb_yres = fb_vinfo.yres;
+ 
+ 	if (vm || fs) {
+ 		out_width = fb_xres;
+ 		out_height = fb_yres;
+ 	}
+ 	if (out_width < in_width || out_height < in_height) {
+ 		printf(FBDEV "screensize is smaller than video size\n");
+ 		return 1;
+ 	}
+ 
+ 	first_row = (out_height - in_height) / 2;
+ 	last_row = (out_height + in_height) / 2;
+ 
  	if (ioctl(fb_dev_fd, FBIOGET_FSCREENINFO, &fb_finfo)) {
  		printf(FBDEV "Can't get FSCREENINFO: %s\n", strerror(errno));
***************
*** 889,909 ****
  	}
  
! 	if (VM || fs) {
! 		out_width = fb_vinfo.xres;
! 		out_height = fb_vinfo.yres;
! 	}
! 	if (out_width < in_width || out_height < in_height) {
! 		printf(FBDEV "screensize is smaller than video size\n");
! 		return 1;
! 	}
! 
! 	fb_pixel_size = fb_vinfo.bits_per_pixel / 8;
! 	fb_real_bpp = fb_vinfo.red.length + fb_vinfo.green.length +
! 		fb_vinfo.blue.length;
! 	fb_bpp = (fb_pixel_size == 4) ? 32 : fb_real_bpp;
! 	if (fb_bpp_we_want != fb_bpp)
! 		printf(FBDEV "requested %d bpp, got %d bpp)!!!\n",
! 				fb_bpp_we_want, fb_bpp);
! 	fb_screen_width = fb_finfo.line_length;
  	fb_size = fb_finfo.smem_len;
  	if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
--- 955,959 ----
  	}
  
! 	fb_line_len = fb_finfo.line_length;
  	fb_size = fb_finfo.smem_len;
  	if ((frame_buffer = (uint8_t *) mmap(0, fb_size, PROT_READ | PROT_WRITE,
***************
*** 913,947 ****
  	}
  	L123123875 = frame_buffer + (out_width - in_width) * fb_pixel_size /
! 		2 + (out_height - in_height) * fb_screen_width / 2;
  
  	if (verbose > 0) {
- 		printf(FBDEV "other:\n");
  		if (verbose > 1) {
  			printf(FBDEV "frame_buffer @ %p\n", frame_buffer);
  			printf(FBDEV "L123123875 @ %p\n", L123123875);
  		}
! 		printf(FBDEV "fb_bpp: %d\n", fb_bpp);
! 		printf(FBDEV "fb_real_bpp: %d\n", fb_real_bpp);
! 		printf(FBDEV "fb_pixel_size: %d bytes\n", fb_pixel_size);
! 		printf(FBDEV "pixel per line: %d\n", fb_screen_width / fb_pixel_size);
  	}
  
- 	switch (fb_bpp) {
- 	case 32:
- 		draw_alpha_p = vo_draw_alpha_rgb32;
- 		break;
- 	case 24:
- 		draw_alpha_p = vo_draw_alpha_rgb24;
- 		break;
- 	case 16:
- 		draw_alpha_p = vo_draw_alpha_rgb16;
- 		break;
- 	case 15:
- 		draw_alpha_p = vo_draw_alpha_rgb15;
- 		break;
- 	}
- 	if (verbose > 1)
- 		printf(FBDEV "draw_alpha_p:%dbpp = %p\n", fb_bpp, draw_alpha_p);
- 
  	if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) {
  		printf(FBDEV "Can't malloc next_frame: %s\n", strerror(errno));
--- 963,976 ----
  	}
  	L123123875 = frame_buffer + (out_width - in_width) * fb_pixel_size /
! 		2 + (out_height - in_height) * fb_line_len / 2;
  
  	if (verbose > 0) {
  		if (verbose > 1) {
  			printf(FBDEV "frame_buffer @ %p\n", frame_buffer);
  			printf(FBDEV "L123123875 @ %p\n", L123123875);
  		}
! 		printf(FBDEV "pixel per line: %d\n", fb_line_len / fb_pixel_size);
  	}
  
  	if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) {
  		printf(FBDEV "Can't malloc next_frame: %s\n", strerror(errno));
***************
*** 949,959 ****
  	}
  
! 	if (flip & (((pixel_format & 0xff) + 7) / 8) != fb_pixel_size) {
! 		printf(FBDEV "Flipped output with depth conversion is not "
! 				"supported\n");
! 		return 1;
  	}
  	if (format == IMGFMT_YV12)
  		yuv2rgb_init(fb_bpp, MODE_RGB);
  	return 0;
  }
--- 978,999 ----
  	}
  
! 	if (vt_doit && (vt_fd = open("/dev/tty", O_WRONLY)) == -1) {
! 		printf(FBDEV "can't open /dev/tty: %s\n", strerror(errno));
! 		vt_doit = 0;
  	}
+ 	if (vt_doit && !(vt_fp = fdopen(vt_fd, "w"))) {
+ 		printf(FBDEV "can't fdopen /dev/tty: %s\n", strerror(errno));
+ 		vt_doit = 0;
+ 	}
+ 
+ 	if (vt_doit)
+ 		vt_set_textarea(last_row, fb_yres);
+ 
+ 	if (fs || vm)
+ 		memset(frame_buffer, '\0', fb_line_len * fb_yres);
+ 
  	if (format == IMGFMT_YV12)
  		yuv2rgb_init(fb_bpp, MODE_RGB);
+ 
  	return 0;
  }
***************
*** 963,970 ****
  	int ret = 0x4; /* osd/sub is supported on every bpp */
  
! 	if (!fb_preinit_done)
! 		if (fb_preinit())
! 			return 0;
! 	if (!fb_works)
  		return 0;
  
--- 1003,1007 ----
  	int ret = 0x4; /* osd/sub is supported on every bpp */
  
! 	if (!fb_preinit())
  		return 0;
  
***************
*** 1060,1064 ****
  		memcpy(L123123875 + out_offset, next_frame + in_offset,
  				in_width * fb_pixel_size);
! 		out_offset += fb_screen_width;
  		in_offset += in_width * fb_pixel_size;
  	}
--- 1097,1101 ----
  		memcpy(L123123875 + out_offset, next_frame + in_offset,
  				in_width * fb_pixel_size);
! 		out_offset += fb_line_len;
  		in_offset += in_width * fb_pixel_size;
  	}
***************
*** 1088,1091 ****
--- 1125,1130 ----
  	if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo))
  		printf(FBDEV "Can't reset original fb_var_screeninfo: %s\n", strerror(errno));
+ 	if (vt_doit)
+ 		vt_set_textarea(0, fb_orig_vinfo.yres);
  	close(fb_dev_fd);
  	munmap(frame_buffer, fb_size);


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list