diff options
Diffstat (limited to 'snapshot.c')
| -rw-r--r-- | snapshot.c | 48 | 
1 files changed, 28 insertions, 20 deletions
@@ -121,7 +121,7 @@ static int snapshot_capture(struct omap3_isp_device *isp)  	return omap3_isp_snapshot_capture(isp);  } -static void snapshot_process(struct omap3_isp_device *isp, +static bool snapshot_process(struct omap3_isp_device *isp,  			     struct v4l2_video_buffer *buffer)  {  	static struct timespec ts; @@ -131,7 +131,7 @@ static void snapshot_process(struct omap3_isp_device *isp,  	if (buffer->error) {  		printf("warning: error in dequeued buffer, skipping\n"); -		return; +		return false;  	}  	ts.tv_sec = buffer->timestamp.tv_sec - snap.time.tv_sec; @@ -162,15 +162,13 @@ requeue:  	if (ret < 0) {  		printf("error: unable to requeue buffer: %s (%d)\n",  			strerror(-ret), ret); -		return; +		return false;  	} -	if (snap.trigger == SNAPSHOT_TRIGGER_AUTO) { -		if (snap.count < snap.number) -			snapshot_capture(isp); -		else -			events_stop(&events); -	} +	if (snap.trigger == SNAPSHOT_TRIGGER_AUTO) +		events_stop(&events); + +	return false;  }  static int snapshot_init(struct omap3_isp_device *isp) @@ -387,6 +385,7 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu  	struct omap3_isp_operations ops;  	struct timespec start, end;  	int exit_code = EXIT_FAILURE; +	unsigned int i;  	float fps;  	int ret;  	int c; @@ -478,20 +477,27 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu  	if (ret < 0)  		goto cleanup; -	/* Start the ISP. */ -	if (vf.enabled) +	/* Start the viewfinder if needed. */ +	if (vf.enabled) {  		ret = omap3_isp_viewfinder_start(isp); -	else -		ret = snapshot_capture(isp); - -	if (ret < 0) -		goto cleanup; +		if (ret < 0) +			goto cleanup; +	}  	/* Main capture loop. */  	clock_gettime(CLOCK_MONOTONIC, &start); -	if (events_loop(&events)) -		goto cleanup; +	for (i = 0; i < snap.number; ++i) { +		if (!vf.enabled) { +			printf("- snapshot %u\n", i); +			ret = snapshot_capture(isp); +			if (ret < 0) +				goto cleanup; +		} + +		if (events_loop(&events)) +			goto cleanup; +	}  	clock_gettime(CLOCK_MONOTONIC, &end); @@ -507,9 +513,11 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu  		end.tv_nsec += 1000000000;  	} -	fps = vf.count / (end.tv_sec + end.tv_nsec / 1000000000.0); +	fps = (vf.enabled ? vf.count : snap.count) +	    / (end.tv_sec + end.tv_nsec / 1000000000.0); -	printf("%u images processed in %lu.%06lu seconds (%f fps)\n", vf.count, +	printf("%u images processed in %lu.%06lu seconds (%f fps)\n", +	       vf.enabled ? vf.count : snap.count,  	       end.tv_sec, end.tv_nsec / 1000, fps);  	exit_code = EXIT_SUCCESS;  | 
