Пример #1
0
void
parse_showconfig_args(int argc, char *argv[])
{
	struct mic_info *miclist;
	int longidx;
	int c;

	while ((c = getopt_long(argc, argv, "hv", showconfig_longopts, &longidx)) != -1) {
		switch(c) {
		case 'h':
			micctrl_help(showconfig_help);
			exit(0);

		case 'v':
			bump_display_level();
			break;

		default:
			ARGERROR_EXIT(showconfig_help);
		}
	}

	miclist = create_miclist(&mpssenv, argc, argv, optind, NULL);
	display_config(miclist);
}
Пример #2
0
/*****************************************************************************
 Prototype    : display_create
 Description  : create display module
 Input        : const DisplayAttrs *attrs  
 Output       : None
 Return Value : 
 Calls        : 
 Called By    : 
 
  History        :
  1.Date         : 2012/8/28
    Author       : Sun
    Modification : Created function

*****************************************************************************/
DisplayHanlde display_create(const DisplayAttrs *attrs)
{
	if( !attrs || 
		attrs->chanId > DISPLAY_MAX_CHAN_ID || 
		attrs->mode >= DISPLAY_MODE_MAX)
		return NULL;

	DisplayHanlde hDisplay;

	hDisplay = calloc(1, sizeof(struct DisplayObj));
	if(!hDisplay) {
		ERR("alloc mem failed");
		return NULL;
	}

	/* disable osd first */
	display_osd_disable();
	
	Int32 err = display_dev_open(hDisplay, attrs->chanId);
	err |= display_config(hDisplay, attrs);
	if(err)
		goto exit;

	err = display_buf_alloc(hDisplay);
	if(err)
		goto exit;

	return hDisplay;

exit:
	display_delete(hDisplay);
	return NULL;
}
Пример #3
0
bool
NativeStateMir::create_window(WindowProperties const& properties)
{
    static const char *win_name("glmark2 "GLMARK_VERSION);

    if (!mir_connection_is_valid(mir_connection_)) {
        Log::error("Cannot create a Mir surface without a valid connection "
                   "to the Mir display server!\n");
        return false;
    }

    /* Recreate an existing window only if it has actually been resized */
    if (mir_surface_) {
        if (properties_.fullscreen != properties.fullscreen ||
            (properties.fullscreen == false &&
             (properties_.width != properties.width ||
              properties_.height != properties.height)))
        {
            mir_surface_release_sync(mir_surface_);
            mir_surface_ = 0;
        }
        else
        {
            return true;
        }
    }

    uint32_t output_id = mir_display_output_id_invalid;

    properties_ = properties;

    if (properties_.fullscreen) {
        DisplayConfiguration display_config(mir_connection_);
        if (!display_config.is_valid()) {
            Log::error("Couldn't get display configuration from the Mir display server!\n");
            return false;
        }

        const MirDisplayOutput* active_output = find_active_output(display_config);
        if (active_output == NULL) {
            Log::error("Couldn't find an active output in the Mir display server!\n");
            return false;
        }

        const MirDisplayMode* current_mode =
            &active_output->modes[active_output->current_mode];

        properties_.width = current_mode->horizontal_resolution;
        properties_.height = current_mode->vertical_resolution;
        output_id = active_output->output_id;

        Log::debug("Making Mir surface fullscreen on output %u (%ux%u)\n",
                   output_id, properties_.width, properties_.height);
    }

    MirPixelFormat surface_format = find_best_surface_format(mir_connection_);
    if (surface_format == mir_pixel_format_invalid) {
        Log::error("Couldn't find a pixel format to use for the Mir surface!\n");
        return false;
    }

    Log::debug("Using pixel format %u for the Mir surface\n", surface_format);

    MirSurfaceParameters surface_parameters = {
        win_name,
        properties_.width, properties_.height,
        surface_format,
        mir_buffer_usage_hardware,
        output_id
    };

    mir_surface_ = mir_connection_create_surface_sync(mir_connection_,
                                                      &surface_parameters);

    if (!mir_surface_ || !mir_surface_is_valid(mir_surface_)) {
        Log::error("Failed to create Mir surface!\n");
        return false;
    }

    return true;
}
Пример #4
0
/******************************************************************************
 *
 * main(argc, argv) --
 *
 *   Program entry point.
 *
 ******************************************************************************/
int main(int argc, char *argv[])
{
	int sock, res, i;

	/*
	 * Initialize the global parameters
	 */
	global_options.sndhistory       = SNDHISTORY;
	global_options.local_port       = PORT;
	global_options.nworkers         = NWORKERS;
	global_options.nverifiers       = NVERIFIERS;
	global_options.verbose          = 0;
	global_options.keep             = 0;
	global_options.whitelist_server = WLSERVER;
	global_options.whitelist_port   = WLPORT;
	global_options.verify_server    = VFYSERVER;
	global_options.verify_port      = VFYPORT;
	global_options.verify_prog      = VERIFY_PROG;
	global_options.verify_thresh    = VERIFY_THRESH;
	global_options.device           = DEVICE;
	global_options.mode             = MODE_DEFAULT;

	/*
	 * Parse the command line options
	 */
	parse_command_line(argc, argv);

	/*
	 * Initialization
	 */
	set_log_level(global_options.verbose);
	display_config();

	LOG(1, "Creating listening socket...\n");
	sock = listen_on(global_options.local_port);
	LOG(1, "Socket %d now listening.\n", sock);

	/*
	 * Create the other threads
	 */
	pthread_barrier_init(&ginit_barrier, NULL,  2);

	wrk_threads = malloc(sizeof(pthread_t) * global_options.nworkers);
	if (wrk_threads == NULL) {
		fprintf(stderr, "Couldn't allocate space for workers\n");
		abort();
	}

	vfy_threads = malloc(sizeof(pthread_t) * global_options.nverifiers);
	if (vfy_threads == NULL) {
		fprintf(stderr, "Couldn't allocate space for verifiers\n");
		abort();
	}

	if (need_sound()) {
		LOG(1, "Creating sound thread...\n");
		pthread_create(&snd_thread, NULL, snd_thread_fn, NULL);
		
		/*
		 * Need to wait for the sound thread to finish initialization; he sets
		 * some global values that the other threads depend on for their own
		 * initialization.
		 */
		pthread_barrier_wait(&ginit_barrier);
	}

	if (need_whitelist()) {
		LOG(1, "Creating whitelist thread...\n");
		pthread_create(&whl_thread, NULL, whl_thread_fn, NULL);
	}

	LOG(1, "Creating %d worker threads...\n", global_options.nworkers);
	for (i = 0; i < global_options.nworkers; i++)
		pthread_create(&wrk_threads[i], NULL, wrk_thread_fn, NULL);

	/*
	 * Create worker threads based on the server's mode of operaiton
	 */
	LOG(1, "Creating %d %s verification threads...\n",
		global_options.nverifiers,
	        global_options.mode == MODE_REMOTE_VERIFY ? "remote" : "local");

	if (global_options.mode == MODE_REMOTE_VERIFY) {
		for (i = 0; i < global_options.nverifiers; i++)
			pthread_create(&vfy_threads[i], NULL, vfy_thread_remote_fn, NULL);

	} else {
		for (i = 0; i < global_options.nverifiers; i++)
			pthread_create(&vfy_threads[i], NULL, vfy_thread_fn, NULL);
	}

	/*
	 * Turn in to the main thread
	 */
	res = mainloop(sock);

	close(sock);
	return res;
}
Пример #5
0
extern "C" int main(int argc , char** argv)
{
	int preview_width = 640;
	int preview_height = 480;

	V4l2 * camera = new V4l2(NULL, preview_width, preview_height);
	camera->v4l2_config(preview_width, preview_height, V4l2_YUV422P);

	display_cfg * disconf = NULL;

	int ret = display_open(&disconf);
	if(ret != 0)
	{
		printf("display_open is error %d\n", ret);
	}
	
	disconf->bpp = 16;
	disconf->format = FORMAT_PLANAR_422;
	disconf->screen_width = 320;
	disconf->screen_height = 480;
	disconf->screen_pos_x = 0;
	disconf->screen_pos_y = 0;
	disconf->step = 640;
	disconf->height = 480;

    ret = display_config(disconf);
	if( ret != 0 )
	{
		display_close(&disconf);
		printf("overlay2 config error... close");
	}

	unsigned char * src[3] = {0};
	while(1)
	{
		if(!camera->getNextFrameAsYuv422(src))
		{
			printf("getNextFrameAsYuv422 is error\n");

			goto  camera_stop;
			break;
		}

		ret = copy_to_overlay(disconf, src);
		if(ret != 0)
		{
			printf("copy_to_overlay is error %d\n", ret);
			
			goto camera_stop;
			break;
		}
	
	};

camera_stop:
	
		delete camera;
		display_close(&disconf);

		return 0;
};
Пример #6
0
void loop()
{
	int value;

	// display menu to user
	display_menu();

	// wait for user to enter something
	while( !Serial.available() ) {
		delay(20);
	}

	// get character from user
	value = Serial.read();

	switch( value ) {

		case 'c' :
			// display all config
			display_config();
			break;

		case 'f' :
			// set frame rate
			set_frame_rate();
			break;

		case 'i' :
			// display image
			display_image();
			break;

		case 'I' :
			// display image continuously
			display_image_continuously();
			break;

		case 'm' :
			// display motion
			display_motion();
			break;

		case 'r' :
			// set resolution
			set_resolution();
			break;

		case 's' :
			// set shutter speed
			set_shutter_speed();
			break;

		case 'z' :
			// clear and reset everything
			flowSensor.clear_motion();
			break;

		default:
			Serial.println("unrecognised command");
			Serial.println();
			break;
	}
}