summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Elliott2014-04-21 08:01:17 -0500
committerJosh Elliott2014-04-21 08:01:17 -0500
commit39ccf81400996833cad0aa3d3f11b5f5de695392 (patch)
tree21462b9f74042467a924cd8158be2c2f81091aa6
parenta4ee55b8fe723d7e7f16b6c54a42c3730635bde5 (diff)
downloaddual-camera-demo-39ccf81400996833cad0aa3d3f11b5f5de695392.tar.gz
dual-camera-demo-39ccf81400996833cad0aa3d3f11b5f5de695392.tar.xz
dual-camera-demo-39ccf81400996833cad0aa3d3f11b5f5de695392.zip
Camera images now scale to all display resolutions
-rw-r--r--loopback.cpp36
-rw-r--r--loopback.h1
-rw-r--r--mainwindow.cpp28
3 files changed, 44 insertions, 21 deletions
diff --git a/loopback.cpp b/loopback.cpp
index 057271c..09dee73 100644
--- a/loopback.cpp
+++ b/loopback.cpp
@@ -286,16 +286,17 @@ static int fbdev_init_device(struct fbdev_device_info *device)
286 printf("%s di resolution: %dx%d\n",device->name, 286 printf("%s di resolution: %dx%d\n",device->name,
287 device->di.xres, device->di.yres); 287 device->di.xres, device->di.yres);
288 288
289 /* Make sure camera display overlay isnt bigger than actual screen size */ 289 /* Store display resolution so GUI can be configured */
290 if (device->di.xres >= 800) { 290 status.display_xres = device->di.xres;
291 /* Set the input resolution of framebuffer */ 291 status.display_yres = device->di.yres;
292 device->varinfo.xres = 800; 292
293 device->varinfo.yres = 480; 293 /* Set the input resolution of the video framebuffer to be the size
294 } 294 * of the camera image. Later, the output size will be matched to
295 295 * the display to allow for up/down scaling */
296 /* Keep the virtual resolution the same as camera image */ 296 device->varinfo.xres = 800;
297 device->varinfo.yres = 600;
297 device->varinfo.xres_virtual = 800; 298 device->varinfo.xres_virtual = 800;
298 device->varinfo.yres_virtual = 480; 299 device->varinfo.yres_virtual = 600;
299 300
300 device->varinfo.bits_per_pixel = 16; 301 device->varinfo.bits_per_pixel = 16;
301 device->varinfo.nonstd = OMAPFB_COLOR_YUY422; 302 device->varinfo.nonstd = OMAPFB_COLOR_YUY422;
@@ -320,13 +321,11 @@ static int fbdev_init_device(struct fbdev_device_info *device)
320 321
321 device->pi.pos_x = 0; 322 device->pi.pos_x = 0;
322 device->pi.pos_y = 0; 323 device->pi.pos_y = 0;
323 /* Set the the display plane output size. This allows for up/down scaling via DSS */ 324 /* Set the the display plane output size to the detected resolution
324 if (device->varinfo.xres >= 800) { 325 * of the lcd/monitor. This will cause the 800x600 camera image to
325 /* If the display width > 800, keep display at 800 */ 326 * be up/downscaled to fit the screen */
326 device->pi.out_width = 800; 327 device->pi.out_width = device->di.xres;
327 device->pi.out_height = 480; 328 device->pi.out_height = device->di.yres;
328 }
329
330 device->pi.enabled = 1; 329 device->pi.enabled = 1;
331 330
332 if (ioctl(device->fd, OMAPFB_SETUP_PLANE, &device->pi)) { 331 if (ioctl(device->fd, OMAPFB_SETUP_PLANE, &device->pi)) {
@@ -478,13 +477,14 @@ static int display_frame(struct v4l2_device_info *v4l2_device, struct fbdev_devi
478 return -1; 477 return -1;
479 } 478 }
480 479
480 /* Wait for VSYNC */
481 ioctl(fbdev_device->fd, OMAPFB_WAITFORGO);
482
481 /* Copy the contents of the v4l2 capture buffer to framebuffer */ 483 /* Copy the contents of the v4l2 capture buffer to framebuffer */
482 memcpy(fbdev_device->buf_start, 484 memcpy(fbdev_device->buf_start,
483 v4l2_device->buffers[v4l2_device->buf.index].start, 485 v4l2_device->buffers[v4l2_device->buf.index].start,
484 fb_size); 486 fb_size);
485 487
486 ioctl(fbdev_device->fd, OMAPFB_WAITFORGO);
487
488 /* Queue buffer for the v4l2 capture device */ 488 /* Queue buffer for the v4l2 capture device */
489 ret = ioctl(v4l2_device->fd, VIDIOC_QBUF, 489 ret = ioctl(v4l2_device->fd, VIDIOC_QBUF,
490 &v4l2_device->buf); 490 &v4l2_device->buf);
diff --git a/loopback.h b/loopback.h
index d47a4ed..3d6dbea 100644
--- a/loopback.h
+++ b/loopback.h
@@ -5,6 +5,7 @@ struct control {
5 int main_cam; 5 int main_cam;
6 int num_cams; 6 int num_cams;
7 int num_jpeg; 7 int num_jpeg;
8 int display_xres, display_yres;
8 bool pip; 9 bool pip;
9 bool jpeg; 10 bool jpeg;
10 bool exit; 11 bool exit;
diff --git a/mainwindow.cpp b/mainwindow.cpp
index d72d788..92e8646 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -26,15 +26,37 @@ MainWindow::MainWindow(QWidget *parent) :
26 if(init_loopback() < 0) { 26 if(init_loopback() < 0) {
27 /* TODO: make sure exit occurs properly */ 27 /* TODO: make sure exit occurs properly */
28 } 28 }
29 else if(status.num_cams == 1) { 29
30 /* Configure GUI */
31 this->setFixedSize(status.display_xres, status.display_yres);
32 ui->frame->setGeometry(0, 0, status.display_xres, status.display_yres);
33 ui->frame_pip->setGeometry(0, 0, status.display_xres/2, status.display_yres/2);
34 ui->capture->setGeometry(status.display_xres/2 - 210,
35 status.display_yres - 50,
36 91, 41);
37 ui->switch_2->setGeometry(status.display_xres/2 - 100,
38 status.display_yres - 50,
39 91, 41);
40 ui->pip->setGeometry(status.display_xres/2 + 10,
41 status.display_yres - 50,
42 91, 41);
43 ui->exit->setGeometry(status.display_xres/2 + 120,
44 status.display_yres - 50,
45 91, 41);
46
47 if(status.num_cams == 1) {
30 /* Reconfigure GUI to reflect single camera mode */ 48 /* Reconfigure GUI to reflect single camera mode */
31 ui->pip->setHidden(true); 49 ui->pip->setHidden(true);
32 ui->pip->setDisabled(true); 50 ui->pip->setDisabled(true);
33 ui->switch_2->setHidden(true); 51 ui->switch_2->setHidden(true);
34 ui->switch_2->setDisabled(true); 52 ui->switch_2->setDisabled(true);
35 ui->frame_pip->setHidden(true); 53 ui->frame_pip->setHidden(true);
36 ui->capture->setGeometry(300,430,91,41); 54 ui->capture->setGeometry(status.display_xres/2 - 100,
37 ui->exit->setGeometry(410,430,91,41); 55 status.display_yres - 50,
56 91, 41);
57 ui->exit->setGeometry(status.display_xres/2 + 10,
58 status.display_yres - 50,
59 91, 41);
38 } 60 }
39 61
40 /* Start the camera loopback thread */ 62 /* Start the camera loopback thread */