Example #1
0
void OSD::init()
{
    uint8_t x;

    detect_mode();

    spi->take_spi_right(&spi_dev_max7456);

    cs->reset(); //select chip
    //read black level register

    spi->write(MAX7456_OSDBL_reg_read);//black level read register
    uint8_t osdbl_r = spi->read();

    spi->write(MAX7456_VM0_reg);
    spi->write(MAX7456_RESET | video_mode);
    delay_us(100);
    //set black level
    uint8_t osdbl_w = (osdbl_r & 0xef); //Set bit 4 to zero 11101111
    spi->write(MAX7456_OSDBL_reg); //black level write register
    spi->write(osdbl_w);

    // set all rows to same charactor white level, 90%
    for (x = 0; x < MAX7456_screen_rows; x++)
    {
        spi->write(x + 0x10);
        spi->write(MAX7456_WHITE_level_120);
    }

    // define sync (auto,int,ext) and
    // making sure the Max7456 is enabled
    control(1);

    spi->release_spi_right();
}
Example #2
0
static int globusf_read(BIO *b, char *out, int outl)
{
  int ret = 0;

  ret = readb(b, out, outl);

  if (ret >= 4) {
    if (mode == UNKNOWN)
      mode = detect_mode((unsigned char*)out);

    if (mode == GSI) {
      if (expected == 0) {
        expected = ((((((unsigned char)out[0] << 8) + 
                       (unsigned char)out[1]) << 8) + 
                     (unsigned char)out[2]) << 8) + 
          (unsigned char)out[3];
        memmove(out, out + 4, ret - 4);
        ret -= 4;
      }
      expected -= ret;

      if (ret == 0) {
        // implies only size was read.  Better reread.
        ret = readb(b, out, outl);

        if (ret > 0) {
          expected -= ret;
        }
      }
    }
  }
  else if (ret > 0) {
    if ((mode == GSI) && (expected > 0))
      expected -= ret;
  }

  return ret;
}
Example #3
0
void initgraph(int* device, int* mode, char const* /*pathtodriver*/, 
			   int size_width, int size_height)
{
    int index;
    static WNDCLASS wcApp;

    gdi_error_code = grOk;

    if (wcApp.lpszClassName == NULL) { 
	wcApp.lpszClassName = "BGIlibrary";
	wcApp.hInstance = 0;
	wcApp.lpfnWndProc = WndProc;
	wcApp.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcApp.hIcon = 0;
	wcApp.lpszMenuName = 0;
	wcApp.hbrBackground = (HBRUSH__ *) GetStockObject(BLACK_BRUSH);
	wcApp.style = CS_SAVEBITS;
	wcApp.cbClsExtra = 0;
	wcApp.cbWndExtra = 0;
	
	if (!RegisterClass(&wcApp)) { 
	    gdi_error_code = GetLastError();
	    return;
	}
	
	pPalette = (NPLOGPALETTE)LocalAlloc(LMEM_FIXED,
	    sizeof(LOGPALETTE)+sizeof(PALETTEENTRY)*PALETTE_SIZE);
	
	pPalette->palVersion = 0x300;
	pPalette->palNumEntries = PALETTE_SIZE;
	memset(pPalette->palPalEntry, 0, sizeof(PALETTEENTRY)*PALETTE_SIZE); 
	for (index = 0; index < BG; index++) {
	    pPalette->palPalEntry[index].peFlags = PC_EXPLICIT;
	    pPalette->palPalEntry[index].peRed = index;
	    pPalette->palPalEntry[PALETTE_SIZE-BG+index].peFlags = PC_EXPLICIT;
	    pPalette->palPalEntry[PALETTE_SIZE-BG+index].peRed = 
		PALETTE_SIZE-BG+index;
	}		
	hBackgroundBrush = CreateSolidBrush(PALETTEINDEX(BG));
	hBrush[EMPTY_FILL] = (HBRUSH__*) GetStockObject(NULL_BRUSH);
	hBrush[SOLID_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, SolidBrushBitmap));
	hBrush[LINE_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, LineBrushBitmap));
	hBrush[LTSLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, LtslashBrushBitmap));
	hBrush[SLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, SlashBrushBitmap));
	hBrush[BKSLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, BkslashBrushBitmap));
	hBrush[LTBKSLASH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, LtbkslashBrushBitmap));
	hBrush[HATCH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, HatchBrushBitmap));
	hBrush[XHATCH_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, XhatchBrushBitmap));
	hBrush[INTERLEAVE_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, InterleaveBrushBitmap));
	hBrush[WIDE_DOT_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, WidedotBrushBitmap));
	hBrush[CLOSE_DOT_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, ClosedotBrushBitmap));
	hBrush[USER_FILL] = 
	    CreatePatternBrush(CreateBitmap(8, 8, 1, 1, SolidBrushBitmap));
    }
    memcpy(BGIpalette, BGIcolor, sizeof BGIpalette);
    current_palette.size = MAXCOLORS+1;
    for (index = 10; index <= MAXCOLORS; index++) {
	pPalette->palPalEntry[index] = BGIcolor[0];
    }
    for (index = 0; index <= MAXCOLORS; index++) {
	current_palette.colors[index] = index;
	pPalette->palPalEntry[index+BG] = BGIcolor[index];
    }
    hPalette = CreatePalette(pPalette);
    detect_mode(device, mode);
    set_defaults();

	if (size_width) window_width=size_width;
	if (size_height) window_height=size_height;

    hWnd = CreateWindow("BGIlibrary", "Windows BGI", 
			WS_OVERLAPPEDWINDOW,
		        0, 0, window_width+BORDER_WIDTH, 
			window_height+BORDER_HEIGHT,
			(HWND)NULL,  (HMENU)NULL,
	    		0, NULL);
    if (hWnd == NULL) { 
	gdi_error_code = GetLastError();
	return;
    }
    ShowWindow(hWnd, *mode == VGAMAX ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL);
    UpdateWindow(hWnd);
}
Example #4
0
int main(int argc, char *argv[]) {
	int nb_threads = atoi(argv[3]);
	int blocksize = atoi(argv[2]);
	int index;
	char filename[6];
	char* mode = argv[1];
	int i = 0;
	double latency, throughput;
	double  avg_latency = 0, avg_throughput = 0, total_throughput = 0;	
	ThreadData thread[nb_threads];
	ThreadData empty_loop;
	pthread_t empty_loop_id;	
	int random_int;
	int re;
	
	srand(time(NULL));	
	random_int = rand()%(MAX_SIZE-blocksize);
	
	/* Fill the buffer where read and write buffer is to be tested */
  	 fill_io_buffer();
    	
	/* Detect mode betweem Sequential, Random */
	index = detect_mode(mode);
	printf("\nBLOCKSIZE : %d B\n",blocksize);
	printf("THREADS   : %d",nb_threads);
	printf("\n=======================================\n\n");

	/* Calculating empty loop_size latency*/
	empty_loop.blocksize = blocksize/nb_threads;
	empty_loop.diff = 0;
	pthread_create(&empty_loop_id,NULL,loop_time,(void *) argv);
	pthread_join(empty_loop_id, NULL);

	/* Creating threads */		
	for(i=0; i < nb_threads; i++){

		thread[i].blocksize = blocksize/nb_threads;
		thread[i].random_int = random_int;
		thread[i].diff = 0;

		/* Determining thread to be created (Sequential, Random) */
		switch(index){	
		case 0:
			re = pthread_create(&(thread[i].thread_id),NULL,read_write_seq_memory,(void *)(&thread[i]));
			break;
		case 1:
			re = pthread_create(&(thread[i].thread_id),NULL,read_write_ran_memory,(void *)(&thread[i]));
			break;

		default:
			return 0;
			break;
		}
		if(re == -1){
			printf("Error creating thread %d",i+1);
		}
		else{
			printf("Thread %d/%d created.\n",i+1,nb_threads);
		}
	}
	
	printf("---------------------------------------\n\n");
	
	/* Wait for all the threads to complete */
	for(i=0; i < nb_threads; i++){
		pthread_join(thread[i].thread_id, NULL);	
	}
	sleep(2);

	/* Calculating and printing  throughput and latency for each thread */
	for(i=0; i < nb_threads; i++){
		latency = ((thread[i].diff)-empty_loop.diff); //We substract the empty loop latency
		throughput = ((thread[i].blocksize/1000000.0)/(latency));
		avg_latency +=latency;	
		total_throughput += throughput;
		printf("Thread      : %d\n", i+1);
		printf("Blocksize   : %d B\n", thread[i].blocksize);
		printf("Latency     : %.5f ms\n",(latency*1000));
		printf("Throughput  : %.2f MB/s\n\n",throughput);
	}

	/* Calculating average throughput and latency */
	avg_latency /= nb_threads;
	avg_throughput = total_throughput/nb_threads;	
	printf("---------------------------------------\n");
	printf("Average latency     : %.5f ms\n", (avg_latency*1000));
	printf("Average throughput  : %.5f ms\n", avg_throughput);
	printf("Total throughput    : %.2f MB/s", total_throughput);
	printf("\n---------------------------------------\n");

	return 0;
}
Example #5
0
int main(int argc, char *argv[]) {
	int nb_threads = atoi(argv[3]);
	int blocksize = atoi(argv[2]);
	int index;
	char filename[6];
	char* mode = argv[1];
	int i = 0;
	double latency, throughput;
	double  avg_latency = 0, avg_throughput = 0, total_throughput = 0;	
	ThreadData thread[nb_threads];
	ThreadData empty_loop;
	pthread_t empty_loop_id;	
	int random_int;
	int re;
		
	srand(time(NULL));	
	random_int = rand()%(MAX_SIZE-blocksize);
	
	
	/* Detect mode betweem Write/Sequential, Write/Random, Read/Sequential, Read/Random */
	index = detect_mode(mode);
	printf("\nBLOCKSIZE : %d B\n",blocksize);
	printf("THREADS   : %d",nb_threads);
	printf("\n=======================================\n\n");

	/* Creating blocksize if needed */
	for(i=0; i < nb_threads; i++){
		if(index ==2 || index == 3){
			snprintf(filename,sizeof(filename),"temp%d",i);	
			create_big_file(filename);
		}
		else{	
			snprintf(filename,sizeof(filename),"temp%d",i);
		}
	}
	sleep(1);

	/* Calculating empty loop_size latency*/
	if(blocksize != 1){
		empty_loop.blocksize = blocksize/nb_threads;
	}
	else{
		empty_loop.blocksize = blocksize;
	}
	empty_loop.diff = 0;
	pthread_create(&empty_loop_id,NULL,loop_time,(void *) argv);
	pthread_join(empty_loop_id, NULL);

	/* Creating threads */		
	for(i=0; i < nb_threads; i++){
		/* Updating thread[i] structure */
		snprintf(filename,sizeof(filename),"temp%d",i);
		strncpy(thread[i].filename,filename,sizeof(filename));
		if(blocksize != 1){
			thread[i].blocksize = blocksize/nb_threads;
		}
		else{
			thread[i].blocksize = blocksize;
		}
		thread[i].random_int = random_int;
		thread[i].diff = 0;
		
		/* Determining thread to be created (Write, Sequential, Sequential, Random) */
		switch(index){	
		case 0:
			re = pthread_create(&(thread[i].thread_id),NULL,write_seq_file,(void *)(&thread[i]));
			break;
		case 1:
			re = pthread_create(&(thread[i].thread_id),NULL,write_ran_file,(void *)(&thread[i]));
			break;
		case 2:
			re = pthread_create(&(thread[i].thread_id),NULL,read_seq_file,(void *)(&thread[i]));
			break;
		case 3:
			re = pthread_create(&(thread[i].thread_id),NULL,read_ran_file,(void *)(&thread[i]));
			break;		
		default:
			return 0;
			break;
		}
		if(re == -1){
			printf("Error creating thread %d",i+1);
		}
		else{
			printf("Thread %d/%d created.\n",i+1,nb_threads);
		}
	}
	
	printf("---------------------------------------\n\n");
	
	/* Wait for all the threads to complete */
	for(i=0; i < nb_threads; i++){
		pthread_join(thread[i].thread_id, NULL);
	}
	sleep(1);

	/* Calculating and printing  throughput and latency for each thread */
	for(i=0; i < nb_threads; i++){
		latency = ((thread[i].diff)-empty_loop.diff); //We substract the empty loop latency
		throughput = (thread[i].blocksize/1000000.0)/latency;
		avg_latency +=latency;	
		total_throughput += throughput;
		printf("Thread      : %d\n", i+1);
		printf("Blocksize   : %d B\n", thread[i].blocksize);
		printf("Latency     : %.5f ms\n",(latency*1000));
		printf("Throughput  : %.2f MB/s\n\n",throughput);
	}

	/* Calculating average throughput and latency */
	avg_latency /= nb_threads;
	avg_throughput = total_throughput/nb_threads;	
	printf("---------------------------------------\n");
	printf("Average latency     : %.5f ms\n", (avg_latency*1000));
	printf("Average throughput  : %.5f MB/s\n", avg_throughput);
	printf("Total throughput    : %.2f MB/s", total_throughput);
	printf("\n---------------------------------------\n");

	return 0;
}