Exemple #1
0
static int v4l2_select_input_stream(void* user_ptr, int test_num)
{
	v4l2_data* data = (v4l2_data*)user_ptr;
	int i=0;

	if (!open_device(data->device))
	{
		BLTS_DEBUG("Can't open device %s\n", data->device->dev_name);
		return -1;
	}

	while(1)
	{
		errno = 0;
		if(has_input(data->device, i) && !i)
			goto force_testing;
		else if(errno == EINVAL)
			break;
		else if (errno)
			goto err;

		if(!try_input(data->device, i))
		{
			BLTS_DEBUG("Trying to stream from found input %i\n", i);
			close_device(data->device);
			if(-1 == v4l2_run_stream(data, 0))
				goto err;
			if (!open_device(data->device))
			{
				BLTS_DEBUG("Error opening device after streaming\n");
				return -1;
			}
		}
		if(get_input(data->device, &i))
		{
			BLTS_ERROR("Can't get current input device\n");
			goto err;
		}
		i++;
	}

	close_device(data->device);
	return 0;


force_testing:
	BLTS_DEBUG("No input device available, force testing IOCTL\n");
	if(try_input(data->device, 0))
		if(errno != EINVAL)
			goto err;
	if(get_input(data->device, &i))
		if(errno != EINVAL)
			goto err;
	return 0;

err:
	close_device(data->device);
	return -1;
}
Exemple #2
0
int main (int argc, char *const argv[])
{
    parser_result_t *config;
    
    config = try_input(argc, argv);

    run_flags = config->flags;

    memory_load(config);

    cpu_run(config->ninst, config->pc);

    cpu_status();
    if (run_flags & FLAG_WATCHMEM)
        show_interval_memory(config->watch_begin, config->watch_end); 
    return 0;
}