update to 3.5.4 [release 3.5.4-1mamba;Fri Sep 19 2014]

This commit is contained in:
Silvan Calarco 2024-01-05 22:36:57 +01:00
parent 7c194d4e3e
commit 26794f3c80
3 changed files with 86 additions and 911 deletions

View File

@ -1,883 +0,0 @@
diff -Nru gambas2-2.10.0.orig/gb.v4l/src/CWebcam.c gambas2-2.10.0/gb.v4l/src/CWebcam.c
--- gambas2-2.10.0.orig/gb.v4l/src/CWebcam.c 2008-12-29 14:16:29.000000000 +0100
+++ gambas2-2.10.0/gb.v4l/src/CWebcam.c 2009-02-20 03:26:27.000000000 +0100
@@ -90,6 +90,15 @@
/***********************************************************************************
+ V4l2 interface
+
+************************************************************************************/
+
+#include "video_device2.c"
+
+
+/***********************************************************************************
+
Camera setup
************************************************************************************/
@@ -426,7 +435,11 @@
char *buf;
int w,h;
- buf=(char*)vd_get_image(DEVICE);
+ if (DEVICE->v4l_version == 2)
+ buf=(char*)vd_get_image2(DEVICE);
+ else
+ buf=(char*)vd_get_image(DEVICE);
+
if (!buf) return -1;
w=DEVICE->vmmap.width;
h=DEVICE->vmmap.height;
@@ -638,28 +651,39 @@
struct video_tuner vtuner;
VIDEO_STREAM *str;
- mydev=open (GB.FileName(STRING(Device),LENGTH(Device)),O_RDWR);
+ mydev=open (GB.FileName(STRING(Device),LENGTH(Device)),O_RDWR | O_NONBLOCK, 0);
if (mydev==-1)
{
GB.Error("Unable to open device");
return;
}
+
DEVICE=vd_setup(DEF_WIDTH,DEF_HEIGHT,DEF_DEPTH,mydev);
- if (!vd_setup_capture_mode(DEVICE))
+ if (!init_device2(DEVICE) )
{
- close(mydev);
- GB.Free(POINTER(&DEVICE));
- GB.Error("Unable to setup capture mode");
- return;
+ DEVICE->v4l_version=2;
+ vd_get_capabilities(DEVICE);
+ start_capturing (mydev);
}
+ else
+ {
+ DEVICE->v4l_version=1;
+ if (!vd_setup_capture_mode(DEVICE))
+ {
+ close(mydev);
+ GB.Free(POINTER(&DEVICE));
+ GB.Error("Unable to setup capture mode");
+ return;
+ }
- vd_setup_video_source(DEVICE,IN_DEFAULT,NORM_DEFAULT);
+ vd_setup_video_source(DEVICE,IN_DEFAULT,NORM_DEFAULT);
+ if (vd_ioctl (DEVICE, VIDIOCGTUNER, &vtuner)) DEVICE->Freq2=1;
+
+ }
GB.Alloc(POINTER(&THIS->device),sizeof(char)*(LENGTH(Device)+1));
strcpy(THIS->device,STRING(Device));
- if (vd_ioctl (DEVICE, VIDIOCGTUNER, &vtuner)) DEVICE->Freq2=1;
-
THIS->stream.desc=&VideoStream;
str=(VIDEO_STREAM*)POINTER(&THIS->stream);
str->handle=(void*)THIS;
@@ -673,6 +697,10 @@
if (DEVICE)
{
+ if (DEVICE->v4l_version == 2) {
+ stop_capturing(DEVICE->dev);
+ uninit_device2();
+ }
vd_close(DEVICE);
GB.Free(POINTER(&DEVICE));
}
@@ -707,27 +735,40 @@
whiteness=DEVICE->videopict.whiteness;
if (THIS->membuf) GB.Free(POINTER(&THIS->membuf));
+ stop_capturing (DEVICE->dev);
+ uninit_device2();
+ close(DEVICE->dev);
vd_close(DEVICE);
GB.Free(POINTER(&DEVICE));
- mydev=open(THIS->device,O_RDWR);
+ mydev=open(THIS->device,O_RDWR | O_NONBLOCK,0 );
if (mydev==-1)
{
GB.Error("Unable to open device");
return;
}
+
DEVICE=vd_setup(w,h,DEF_DEPTH,mydev);
- if (!vd_setup_capture_mode(DEVICE))
+ if (!init_device2(DEVICE) )
{
- close(mydev);
- GB.Free(POINTER(&DEVICE));
- GB.Error("Unable to setup capture mode");
- return;
+ DEVICE->v4l_version=2;
+ vd_get_capabilities(DEVICE);
+ start_capturing (mydev);
+ }
+ else
+ {
+ DEVICE->v4l_version=1;
+ if (!vd_setup_capture_mode(DEVICE))
+ {
+ close(mydev);
+ GB.Free(POINTER(&DEVICE));
+ GB.Error("Unable to setup capture mode");
+ return;
+ }
+
+ vd_setup_video_source(DEVICE,channel,norm);
}
-
- vd_setup_video_source(DEVICE,channel,norm);
-
DEVICE->videopict.hue=hue;
DEVICE->videopict.contrast=contrast;
DEVICE->videopict.brightness=brightness;
@@ -795,7 +836,12 @@
char *buf;
int w,h;
- buf=(char*)vd_get_image(DEVICE);
+ if (DEVICE->v4l_version == 2)
+ {
+ buf=(char*)vd_get_image2(DEVICE);
+ } else {
+ buf=(char*)vd_get_image(DEVICE);
+ }
if (!buf)
{
GB.Error("Unable to get image");
@@ -819,7 +865,11 @@
char *buf;
int w,h;
- buf=(char*)vd_get_image(DEVICE);
+ if (DEVICE->v4l_version == 2)
+ buf=(char*)vd_get_image2(DEVICE);
+ else
+ buf=(char*)vd_get_image(DEVICE);
+
if (!buf)
{
GB.Error("Unable to get image");
@@ -827,8 +877,8 @@
return;
}
- w=DEVICE->vmmap.width;
- h=DEVICE->vmmap.height;
+ w=DEVICE->width;
+ h=DEVICE->height;
vd_image_done(DEVICE);
GB.Picture.Create(&ret,(void*)buf,w,h,GB_IMAGE_BGR);
@@ -902,7 +952,12 @@
GB.Error("Unable to open file for writting");
return;
}
- buf=(char*)vd_get_image(DEVICE);
+ if (DEVICE->v4l_version == 2) {
+ buf=(char*)vd_get_image2(DEVICE);
+ } else {
+ buf=(char*)vd_get_image(DEVICE);
+ }
+
if (!buf)
{
fclose(fd);
@@ -910,8 +965,8 @@
return;
}
- w=DEVICE->vmmap.width;
- h=DEVICE->vmmap.height;
+ w=DEVICE->width;
+ h=DEVICE->height;
switch(format)
{
diff -Nru gambas2-2.10.0.orig/gb.v4l/src/CWebcam.h gambas2-2.10.0/gb.v4l/src/CWebcam.h
--- gambas2-2.10.0.orig/gb.v4l/src/CWebcam.h 2008-12-29 14:16:29.000000000 +0100
+++ gambas2-2.10.0/gb.v4l/src/CWebcam.h 2009-02-20 03:03:27.000000000 +0100
@@ -72,6 +73,7 @@
unsigned char *frame_buffer; // not the video memory, but one image
int dev; // fd of the physical device
int Freq2;
+ int v4l_version;
} video_device_t;
diff -Nru gambas2-2.10.0.orig/gb.v4l/src/video_device2.c gambas2-2.10.0/gb.v4l/src/video_device2.c
--- gambas2-2.10.0.orig/gb.v4l/src/video_device2.c 1970-01-01 01:00:00.000000000 +0100
+++ gambas2-2.10.0/gb.v4l/src/video_device2.c 2009-02-20 03:40:19.000000000 +0100
@@ -0,0 +1,663 @@
+/*
+ * V4L2 video capture example
+ *
+ * This program can be used and distributed without restrictions.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <getopt.h> /* getopt_long() */
+
+#include <fcntl.h> /* low-level i/o */
+#include <unistd.h>
+#include <errno.h>
+#include <malloc.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+
+#include <asm/types.h> /* for videodev2.h */
+
+#include <linux/videodev2.h>
+#include <libv4lconvert.h>
+
+#define MEMCLEAR(x) memset (&(x), 0, sizeof (x))
+
+typedef enum {
+ IO_METHOD_READ,
+ IO_METHOD_MMAP,
+ IO_METHOD_USERPTR,
+} io_method;
+
+struct buffer {
+ void * start;
+ size_t length;
+};
+
+static io_method io = IO_METHOD_MMAP;
+struct buffer * buffers = NULL;
+unsigned char * bufferRGB = NULL;
+static unsigned int n_buffers = 0;
+
+#define CLIP(color) (unsigned char)(((color)>0xFF)?0xff:(((color)<0)?0:(color)))
+
+void v4lconvert_yuyv_to_bgr24(const unsigned char *src, unsigned char *dest,
+ int width, int height)
+{
+ int j;
+
+ while (--height >= 0) {
+ for (j = 0; j < width; j += 2) {
+ int u = src[1];
+ int v = src[3];
+ int u1 = (((u - 128) << 7) + (u - 128)) >> 6;
+ int rg = (((u - 128) << 1) + (u - 128) +
+ ((v - 128) << 2) + ((v - 128) << 1)) >> 3;
+ int v1 = (((v - 128) << 1) + (v - 128)) >> 1;
+
+ *dest++ = CLIP(src[0] + u1);
+ *dest++ = CLIP(src[0] - rg);
+ *dest++ = CLIP(src[0] + v1);
+
+ *dest++ = CLIP(src[2] + u1);
+ *dest++ = CLIP(src[2] - rg);
+ *dest++ = CLIP(src[2] + v1);
+ src += 4;
+ }
+ }
+}
+
+
+
+void v4lconvert_yuyv_to_rgb24(const unsigned char *src, unsigned char *dest,
+ int width, int height)
+{
+ int j;
+
+ while (--height >= 0) {
+ for (j = 0; j < width; j += 2) {
+ int u = src[1];
+ int v = src[3];
+ int u1 = (((u - 128) << 7) + (u - 128)) >> 6;
+ int rg = (((u - 128) << 1) + (u - 128) +
+ ((v - 128) << 2) + ((v - 128) << 1)) >> 3;
+ int v1 = (((v - 128) << 1) + (v - 128)) >> 1;
+
+ *dest++ = CLIP(src[0] + v1);
+ *dest++ = CLIP(src[0] - rg);
+ *dest++ = CLIP(src[0] + u1);
+
+ *dest++ = CLIP(src[2] + v1);
+ *dest++ = CLIP(src[2] - rg);
+ *dest++ = CLIP(src[2] + u1);
+ src += 4;
+ }
+ }
+}
+
+int convert_yuv_to_rgb_pixel(int y, int u, int v)
+{
+ unsigned int pixel32 = 0;
+ unsigned char *pixel = (unsigned char *)&pixel32;
+ int r, g, b;
+
+ r = y + (1.370705 * (v-128));
+ g = y - (0.698001 * (v-128)) - (0.337633 * (u-128));
+ b = y + (1.732446 * (u-128));
+
+ if(r > 255) r = 255;
+ if(g > 255) g = 255;
+ if(b > 255) b = 255;
+ if(r < 0) r = 0;
+ if(g < 0) g = 0;
+ if(b < 0) b = 0;
+
+ pixel[0] = r * 220 / 256;
+ pixel[1] = g * 220 / 256;
+ pixel[2] = b * 220 / 256;
+
+ return pixel32;
+}
+
+int convert_yuv_to_rgb_buffer(const unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
+{
+ unsigned int in, out = 0;
+ unsigned int pixel_16;
+ unsigned char pixel_24[3];
+ unsigned int pixel32;
+ int y0, u, y1, v;
+
+ for(in = 0; in < width * height * 2; in += 4) {
+ pixel_16 =
+ yuv[in + 3] << 24 |
+ yuv[in + 2] << 16 |
+ yuv[in + 1] << 8 |
+ yuv[in + 0];
+
+ y0 = (pixel_16 & 0x000000ff);
+ u = (pixel_16 & 0x0000ff00) >> 8;
+ y1 = (pixel_16 & 0x00ff0000) >> 16;
+ v = (pixel_16 & 0xff000000) >> 24;
+
+ pixel32 = convert_yuv_to_rgb_pixel(y0, u, v);
+ pixel_24[0] = (pixel32 & 0x000000ff);
+ pixel_24[1] = (pixel32 & 0x0000ff00) >> 8;
+ pixel_24[2] = (pixel32 & 0x00ff0000) >> 16;
+
+ rgb[out++] = pixel_24[0];
+ rgb[out++] = pixel_24[1];
+ rgb[out++] = pixel_24[2];
+
+ pixel32 = convert_yuv_to_rgb_pixel(y1, u, v);
+ pixel_24[0] = (pixel32 & 0x000000ff);
+ pixel_24[1] = (pixel32 & 0x0000ff00) >> 8;
+ pixel_24[2] = (pixel32 & 0x00ff0000) >> 16;
+
+ rgb[out++] = pixel_24[0];
+ rgb[out++] = pixel_24[1];
+ rgb[out++] = pixel_24[2];
+ }
+
+ return 0;
+}
+
+static void
+errno_exit (const char * s)
+{
+ fprintf (stderr, "%s error %d, %s\n",
+ s, errno, strerror (errno));
+
+ exit (EXIT_FAILURE);
+}
+
+static int
+xioctl (int fd,
+ int request,
+ void * arg)
+{
+ int r;
+
+ do r = ioctl (fd, request, arg);
+ while (-1 == r && EINTR == errno);
+
+ return r;
+}
+
+static void
+process_image (int width, int height, const void *p)
+{
+ if(bufferRGB == NULL)
+ return;
+
+ v4lconvert_yuyv_to_bgr24(p, bufferRGB, width, height);
+}
+
+static int
+read_frame (int width, int height, int fd)
+{
+ struct v4l2_buffer buf;
+ unsigned int i;
+
+ switch (io) {
+ case IO_METHOD_READ:
+ if (-1 == read (fd, buffers[0].start, buffers[0].length)) {
+ switch (errno) {
+ case EAGAIN:
+ return 0;
+
+ case EIO:
+ /* Could ignore EIO, see spec. */
+
+ /* fall through */
+
+ default:
+ errno_exit ("read");
+ }
+ }
+
+ process_image (width, height, buffers[0].start);
+
+ break;
+
+ case IO_METHOD_MMAP:
+ MEMCLEAR (buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+
+ if (-1 == xioctl (fd, VIDIOC_DQBUF, &buf)) {
+ switch (errno) {
+ case EAGAIN:
+ return 0;
+
+ case EIO:
+ /* Could ignore EIO, see spec. */
+
+ /* fall through */
+
+ default:
+ errno_exit ("VIDIOC_DQBUF");
+ }
+ }
+
+ assert (buf.index < n_buffers);
+
+ process_image (width, height, buffers[buf.index].start);
+
+ if (-1 == xioctl (fd, VIDIOC_QBUF, &buf))
+ errno_exit ("VIDIOC_QBUF");
+
+ break;
+
+ case IO_METHOD_USERPTR:
+ MEMCLEAR (buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_USERPTR;
+
+ if (-1 == xioctl (fd, VIDIOC_DQBUF, &buf)) {
+ switch (errno) {
+ case EAGAIN:
+ return 0;
+
+ case EIO:
+ /* Could ignore EIO, see spec. */
+
+ /* fall through */
+
+ default:
+ errno_exit ("VIDIOC_DQBUF");
+ }
+ }
+
+ for (i = 0; i < n_buffers; ++i)
+ if (buf.m.userptr == (unsigned long) buffers[i].start
+ && buf.length == buffers[i].length)
+ break;
+
+ assert (i < n_buffers);
+
+ process_image (width, height, (void *) buf.m.userptr);
+
+ if (-1 == xioctl (fd, VIDIOC_QBUF, &buf))
+ errno_exit ("VIDIOC_QBUF");
+
+ break;
+ }
+
+ return 1;
+}
+
+unsigned char *
+vd_get_image2 (video_device_t *vd)
+{
+ for (;;) {
+ fd_set fds;
+ struct timeval tv;
+ int r;
+
+ FD_ZERO (&fds);
+ FD_SET (vd->dev, &fds);
+
+ /* Timeout. */
+ tv.tv_sec = 2;
+ tv.tv_usec = 0;
+
+ r = select (vd->dev + 1, &fds, NULL, NULL, &tv);
+
+ if (-1 == r) {
+ if (EINTR == errno)
+ continue;
+
+ errno_exit ("select");
+ }
+
+ if (0 == r) {
+ fprintf (stderr, "select timeout\n");
+ exit (EXIT_FAILURE);
+ }
+ if (read_frame (vd->width, vd->height, vd->dev))
+ return bufferRGB;
+
+ /* EAGAIN - continue select loop. */
+ }
+ return NULL;
+}
+
+static void
+stop_capturing (int fd)
+{
+ enum v4l2_buf_type type;
+
+ switch (io) {
+ case IO_METHOD_READ:
+ /* Nothing to do. */
+ break;
+
+ case IO_METHOD_MMAP:
+ case IO_METHOD_USERPTR:
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (-1 == xioctl (fd, VIDIOC_STREAMOFF, &type))
+ errno_exit ("VIDIOC_STREAMOFF");
+
+ break;
+ }
+}
+
+static void
+start_capturing (int fd)
+{
+ unsigned int i;
+ enum v4l2_buf_type type;
+
+ switch (io) {
+ case IO_METHOD_READ:
+ /* Nothing to do. */
+ break;
+
+ case IO_METHOD_MMAP:
+ for (i = 0; i < n_buffers; ++i) {
+ struct v4l2_buffer buf;
+
+ MEMCLEAR (buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = i;
+
+ if (-1 == xioctl (fd, VIDIOC_QBUF, &buf))
+ errno_exit ("VIDIOC_QBUF");
+ }
+
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (-1 == xioctl (fd, VIDIOC_STREAMON, &type))
+ errno_exit ("VIDIOC_STREAMON");
+
+ break;
+
+ case IO_METHOD_USERPTR:
+ for (i = 0; i < n_buffers; ++i) {
+ struct v4l2_buffer buf;
+
+ MEMCLEAR (buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_USERPTR;
+ buf.index = i;
+ buf.m.userptr = (unsigned long) buffers[i].start;
+ buf.length = buffers[i].length;
+
+ if (-1 == xioctl (fd, VIDIOC_QBUF, &buf))
+ errno_exit ("VIDIOC_QBUF");
+ }
+
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (-1 == xioctl (fd, VIDIOC_STREAMON, &type))
+ errno_exit ("VIDIOC_STREAMON");
+
+ break;
+ }
+}
+
+static void
+uninit_device2 (void)
+{
+ unsigned int i;
+
+ switch (io) {
+ case IO_METHOD_READ:
+ free (buffers[0].start);
+ break;
+
+ case IO_METHOD_MMAP:
+ for (i = 0; i < n_buffers; ++i)
+ if (-1 == munmap (buffers[i].start, buffers[i].length))
+ return;
+ break;
+
+ case IO_METHOD_USERPTR:
+ for (i = 0; i < n_buffers; ++i)
+ free (buffers[i].start);
+ break;
+ }
+
+ free (buffers);
+ free (bufferRGB);
+}
+
+static void
+init_read (unsigned int buffer_size)
+{
+ buffers = calloc (1, sizeof (*buffers));
+
+ if (!buffers) {
+ fprintf (stderr, "Out of memory\n");
+ exit (EXIT_FAILURE);
+ }
+
+ buffers[0].length = buffer_size;
+ buffers[0].start = malloc (buffer_size);
+
+ if (!buffers[0].start) {
+ fprintf (stderr, "Out of memory\n");
+ exit (EXIT_FAILURE);
+ }
+}
+
+static void
+init_mmap (int fd)
+{
+ struct v4l2_requestbuffers req;
+
+ MEMCLEAR (req);
+
+ req.count = 4;
+ req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ req.memory = V4L2_MEMORY_MMAP;
+
+ if (-1 == xioctl (fd, VIDIOC_REQBUFS, &req)) {
+ if (EINVAL == errno) {
+ fprintf (stderr, "Device does not support "
+ "memory mapping\n");
+ exit (EXIT_FAILURE);
+ } else {
+ errno_exit ("VIDIOC_REQBUFS");
+ }
+ }
+
+ if (req.count < 2) {
+ fprintf (stderr, "Insufficient buffer memory on device\n");
+ exit (EXIT_FAILURE);
+ }
+
+ buffers = calloc (req.count, sizeof (*buffers));
+
+ if (!buffers) {
+ fprintf (stderr, "Out of memory\n");
+ exit (EXIT_FAILURE);
+ }
+
+ for (n_buffers = 0; n_buffers < req.count; ++n_buffers) {
+ struct v4l2_buffer buf;
+
+ MEMCLEAR (buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = n_buffers;
+
+ if (-1 == xioctl (fd, VIDIOC_QUERYBUF, &buf))
+ errno_exit ("VIDIOC_QUERYBUF");
+
+ buffers[n_buffers].length = buf.length;
+ buffers[n_buffers].start =
+ mmap (NULL /* start anywhere */,
+ buf.length,
+ PROT_READ | PROT_WRITE /* required */,
+ MAP_SHARED /* recommended */,
+ fd, buf.m.offset);
+
+ if (MAP_FAILED == buffers[n_buffers].start)
+ errno_exit ("mmap");
+ }
+}
+
+static void
+init_userp (unsigned int buffer_size, int fd)
+{
+ struct v4l2_requestbuffers req;
+ unsigned int page_size;
+
+ page_size = getpagesize ();
+ buffer_size = (buffer_size + page_size - 1) & ~(page_size - 1);
+
+ MEMCLEAR (req);
+
+ req.count = 4;
+ req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ req.memory = V4L2_MEMORY_USERPTR;
+
+ if (-1 == xioctl (fd, VIDIOC_REQBUFS, &req)) {
+ if (EINVAL == errno) {
+ fprintf (stderr, "Device does not support "
+ "user pointer i/o\n");
+ exit (EXIT_FAILURE);
+ } else {
+ errno_exit ("VIDIOC_REQBUFS");
+ }
+ }
+
+ buffers = calloc (4, sizeof (*buffers));
+
+ if (!buffers) {
+ fprintf (stderr, "Out of memory\n");
+ exit (EXIT_FAILURE);
+ }
+
+ for (n_buffers = 0; n_buffers < 4; ++n_buffers) {
+ buffers[n_buffers].length = buffer_size;
+ buffers[n_buffers].start = memalign (/* boundary */ page_size,
+ buffer_size);
+
+ if (!buffers[n_buffers].start) {
+ fprintf (stderr, "Out of memory\n");
+ exit (EXIT_FAILURE);
+ }
+ }
+}
+
+int
+init_device2 (video_device_t *vd)
+{
+ struct v4l2_capability cap;
+ struct v4l2_cropcap cropcap;
+ struct v4l2_crop crop;
+ struct v4l2_format fmt;
+ unsigned int min;
+
+ if (-1 == xioctl (vd->dev, VIDIOC_QUERYCAP, &cap)) {
+ if (EINVAL == errno) {
+ fprintf (stderr, "Device is no V4L2 device\n");
+ return 1;
+ } else {
+ errno_exit ("VIDIOC_QUERYCAP");
+ }
+ }
+
+ if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ fprintf (stderr, "Device is no video capture device\n");
+ return 2;
+ }
+
+ switch (io) {
+ case IO_METHOD_READ:
+ if (!(cap.capabilities & V4L2_CAP_READWRITE)) {
+ fprintf (stderr, "Device does not support read i/o\n");
+ return 3;
+ }
+
+ break;
+
+ case IO_METHOD_MMAP:
+ case IO_METHOD_USERPTR:
+ if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
+ fprintf (stderr, "Device does not support streaming i/o\n");
+ return 4;
+ }
+
+ break;
+ }
+
+
+ /* Select video input, video standard and tune here. */
+
+
+ MEMCLEAR (cropcap);
+
+ cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (0 == xioctl (vd->dev, VIDIOC_CROPCAP, &cropcap)) {
+ crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ crop.c = cropcap.defrect; /* reset to default */
+
+ if (-1 == xioctl (vd->dev, VIDIOC_S_CROP, &crop)) {
+ switch (errno) {
+ case EINVAL:
+ /* Cropping not supported. */
+ break;
+ default:
+ /* Errors ignored. */
+ break;
+ }
+ }
+ } else {
+ /* Errors ignored. */
+ }
+
+
+ MEMCLEAR (fmt);
+
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.width = vd->width;
+ fmt.fmt.pix.height = vd->height;
+ fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
+ fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
+
+ if (-1 == xioctl (vd->dev, VIDIOC_S_FMT, &fmt))
+ return 1;
+
+ bufferRGB = malloc(vd->width*vd->height*vd->depth);
+ /* Note VIDIOC_S_FMT may change width and height. */
+
+ /* Buggy driver paranoia. */
+ min = fmt.fmt.pix.width * 2;
+ if (fmt.fmt.pix.bytesperline < min)
+ fmt.fmt.pix.bytesperline = min;
+ min = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height;
+ if (fmt.fmt.pix.sizeimage < min)
+ fmt.fmt.pix.sizeimage = min;
+
+ switch (io) {
+ case IO_METHOD_READ:
+ init_read (fmt.fmt.pix.sizeimage);
+ break;
+
+ case IO_METHOD_MMAP:
+ init_mmap (vd->dev);
+ break;
+
+ case IO_METHOD_USERPTR:
+ init_userp (fmt.fmt.pix.sizeimage,vd->dev);
+ break;
+ }
+
+ return 0;
+}

View File

@ -0,0 +1,45 @@
--- gambas3-3.5.4/gb.jit/configure.ac.orig 2014-09-20 12:56:11.194690422 +0200
+++ gambas3-3.5.4/gb.jit/configure.ac 2014-09-20 12:56:18.108690753 +0200
@@ -25,7 +25,7 @@
GB_COMPONENT(
jit, JIT, gb.jit, [src],
- [GB_FIND(llvm/AutoUpgrade.h llvm-c/Core.h, /usr/lib/llvm* /usr/local/lib /usr/local /usr/lib /usr `$LLVM_CONFIG --prefix`, include)],
+ [GB_FIND(llvm/IR/AutoUpgrade.h llvm-c/Core.h, /usr/lib/llvm* /usr/local/lib /usr/local /usr/lib /usr `$LLVM_CONFIG --prefix`, include)],
[GB_FIND(libLLVM-$LLVM_VERSION.$SHLIBEXT, /usr/lib/llvm* /usr/local /usr `$LLVM_CONFIG --prefix`, lib)],
[$C_LIB `$LLVM_CONFIG --ldflags` -lLLVM-$LLVM_VERSION],
[-I../../main/gbx -I../../main/share -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS])
--- gambas3-3.5.4/gb.jit/src/jit.h.in 2014-09-20 12:45:48.639660707 +0200
+++ gambas3-3.5.4/gb.jit/src/jit.h 2014-09-20 12:48:35.516668616 +0200
@@ -34,6 +34,7 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Verifier.h"
#else
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
@@ -42,7 +43,11 @@
#include "llvm/Intrinsics.h"
#include "llvm/Instructions.h"
#endif
+#if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
+#include "llvm/IR/Verifier.h"
+#else
#include "llvm/Analysis/Verifier.h"
+#endif
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
@@ -57,7 +62,11 @@
#include "llvm/Support/IRBuilder.h"
#endif
#include "llvm/Support/DynamicLibrary.h"
+#if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5)
+#include "llvm/IR/CFG.h"
+#else
#include "llvm/Support/CFG.h"
+#endif
#include "llvm/PassManager.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"

View File

@ -1,8 +1,8 @@
%define with_v4l 1 %define with_v4l 1
Name: gambas3 Name: gambas3
Version: 3.5.0 Version: 3.5.4
Release: 2mamba Release: 1mamba
Summary: A development environment based on a BASIC interpreter with object extensions Summary: A development environment based on a BASIC interpreter with object extensions
Group: Applications/Development Group: Applications/Development
Vendor: openmamba Vendor: openmamba
@ -10,10 +10,29 @@ Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it> Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: http://gambas.sourceforge.net/ URL: http://gambas.sourceforge.net/
Source: http://download.sourceforge.net/sourceforge/gambas/gambas3-%{version}.tar.bz2 Source: http://download.sourceforge.net/sourceforge/gambas/gambas3-%{version}.tar.bz2
Patch0: gambas2-2.10.0-v4l2.patch Patch0: gambas3-3.5.4-llvm-3.5.patch
License: GPL License: GPL
## AUTOBUILDREQ-BEGIN ## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel BuildRequires: glibc-devel
BuildRequires: libGL-devel
BuildRequires: libGLU-devel
BuildRequires: libICE-devel
BuildRequires: libSDL-devel
BuildRequires: libSDL_mixer-devel
BuildRequires: libSDL_ttf-devel
BuildRequires: libSM-devel
BuildRequires: libX11-devel
BuildRequires: libXau-devel
BuildRequires: libXcursor-devel
BuildRequires: libXdmcp-devel
BuildRequires: libXext-devel
BuildRequires: libXfixes-devel
BuildRequires: libXi-devel
BuildRequires: libXinerama-devel
BuildRequires: libXmu-devel
BuildRequires: libXrender-devel
BuildRequires: libXt-devel
BuildRequires: libXtst-devel
BuildRequires: libatk-devel BuildRequires: libatk-devel
BuildRequires: libbzip2-devel BuildRequires: libbzip2-devel
BuildRequires: libcairo-devel BuildRequires: libcairo-devel
@ -29,30 +48,31 @@ BuildRequires: libfreetype-devel
BuildRequires: libgcc BuildRequires: libgcc
BuildRequires: libgcrypt-devel BuildRequires: libgcrypt-devel
BuildRequires: libgdk-pixbuf-devel BuildRequires: libgdk-pixbuf-devel
BuildRequires: libGL-devel
BuildRequires: libglew-devel BuildRequires: libglew-devel
BuildRequires: libglib-devel BuildRequires: libglib-devel
BuildRequires: libGLU-devel
BuildRequires: libgmime-devel BuildRequires: libgmime-devel
BuildRequires: libgmp-devel
BuildRequires: libgnome-keyring-devel BuildRequires: libgnome-keyring-devel
BuildRequires: libgpg-error-devel BuildRequires: libgpg-error-devel
BuildRequires: libgraphite2-devel BuildRequires: libgraphite2-devel
BuildRequires: libgsl-devel BuildRequires: libgsl-devel
BuildRequires: libgss-devel BuildRequires: libgss-devel
BuildRequires: libgst-plugins-base-devel
BuildRequires: libgst-plugins-base010-devel BuildRequires: libgst-plugins-base010-devel
BuildRequires: libgstreamer-devel
BuildRequires: libgstreamer010-devel BuildRequires: libgstreamer010-devel
BuildRequires: libgtk2-devel BuildRequires: libgtk2-devel
BuildRequires: libgtkglext-devel BuildRequires: libgtkglext-devel
BuildRequires: libharfbuzz-devel BuildRequires: libharfbuzz-devel
BuildRequires: libICE-devel
BuildRequires: libidn-devel BuildRequires: libidn-devel
BuildRequires: libimlib2-devel BuildRequires: libimlib2-devel
BuildRequires: libjbig-devel BuildRequires: libjbig-devel
BuildRequires: libjpeg-devel BuildRequires: libjpeg-devel
BuildRequires: liblcms2-devel BuildRequires: liblcms2-devel
BuildRequires: libllvm-devel
BuildRequires: libltdl-devel BuildRequires: libltdl-devel
BuildRequires: liblzma-devel BuildRequires: liblzma-devel
BuildRequires: libmysql5-devel BuildRequires: libmysql-devel
BuildRequires: libncurses-devel BuildRequires: libncurses-devel
BuildRequires: libodbc-devel BuildRequires: libodbc-devel
BuildRequires: libopenjpeg1-devel BuildRequires: libopenjpeg1-devel
@ -62,47 +82,31 @@ BuildRequires: libpango-devel
BuildRequires: libpangox-devel BuildRequires: libpangox-devel
BuildRequires: libpcre-devel BuildRequires: libpcre-devel
BuildRequires: libpng-devel BuildRequires: libpng-devel
BuildRequires: libpng15-devel
BuildRequires: libpoppler-devel BuildRequires: libpoppler-devel
BuildRequires: libpostgresql-devel BuildRequires: libpostgresql-devel
BuildRequires: libpthread-stubs-devel
BuildRequires: libqt4-devel
BuildRequires: libqt-mobility-devel BuildRequires: libqt-mobility-devel
BuildRequires: libqt4-devel
BuildRequires: librsvg-devel BuildRequires: librsvg-devel
BuildRequires: librtmp-devel BuildRequires: librtmp-devel
BuildRequires: libsasl-devel BuildRequires: libsasl-devel
BuildRequires: libSDL-devel
BuildRequires: libSDL_mixer-devel
BuildRequires: libSDL_ttf-devel
BuildRequires: libselinux-devel BuildRequires: libselinux-devel
BuildRequires: libSM-devel BuildRequires: libsqlite-devel
%if "%{stage1}" != "1" %if "%{stage1}" != "1"
BuildRequires: libsqlite2-devel BuildRequires: libsqlite2-devel
%endif %endif
BuildRequires: libsqlite-devel
BuildRequires: libssh2-devel BuildRequires: libssh2-devel
BuildRequires: libstdc++6-devel BuildRequires: libstdc++6-devel
BuildRequires: libtiff-devel BuildRequires: libtiff-devel
BuildRequires: libts-devel BuildRequires: libts-devel
BuildRequires: libuuid-devel BuildRequires: libuuid-devel
BuildRequires: libv4l-devel BuildRequires: libv4l-devel
BuildRequires: libX11-devel
BuildRequires: libXau-devel
BuildRequires: libxcb-devel BuildRequires: libxcb-devel
BuildRequires: libXcursor-devel
BuildRequires: libXdmcp-devel
BuildRequires: libXext-devel
BuildRequires: libXfixes-devel
BuildRequires: libXi-devel
BuildRequires: libXinerama-devel
BuildRequires: libxml2-devel BuildRequires: libxml2-devel
BuildRequires: libXmu-devel
BuildRequires: libXrender-devel
BuildRequires: libxslt-devel BuildRequires: libxslt-devel
BuildRequires: libXt-devel
BuildRequires: libXtst-devel
BuildRequires: libz-devel BuildRequires: libz-devel
BuildRequires: llvm-devel
## AUTOBUILDREQ-END ## AUTOBUILDREQ-END
BuildRequires: libllvm-devel >= 3.5.0-2mamba
BuildRequires: libSDL_gfx-devel >= 2.0.13 BuildRequires: libSDL_gfx-devel >= 2.0.13
BuildRequires: libsmpeg-devel >= 0.4.5 BuildRequires: libsmpeg-devel >= 0.4.5
BuildRequires: pkgconfig >= 0.9 BuildRequires: pkgconfig >= 0.9
@ -814,6 +818,8 @@ This component provides the Gambas WEB component.
%prep %prep
%setup -q %setup -q
#-D -T #-D -T
#:<< _EOF
%patch0 -p1
%build %build
#:<< _EOF #:<< _EOF
@ -1206,7 +1212,8 @@ install -D -m0644 app/desktop/gambas3.svg %{buildroot}%{_datadir}/pixmaps/gambas
%files gb-sdl %files gb-sdl
%defattr(-,root,root) %defattr(-,root,root)
%dir %{_datadir}/%{name}/gb.sdl %dir %{_datadir}/%{name}/gb.sdl
%{_datadir}/%{name}/gb.sdl/DejaVuSans.ttf %{_datadir}/%{name}/gb.sdl/_default.bdf
%{_datadir}/%{name}/gb.sdl/README
%{_datadir}/%{name}/gb.sdl/LICENSE %{_datadir}/%{name}/gb.sdl/LICENSE
%{_datadir}/%{name}/info/gb.sdl.info %{_datadir}/%{name}/info/gb.sdl.info
%{_datadir}/%{name}/info/gb.sdl.list %{_datadir}/%{name}/info/gb.sdl.list
@ -1254,6 +1261,12 @@ install -D -m0644 app/desktop/gambas3.svg %{buildroot}%{_datadir}/pixmaps/gambas
%{_libdir}/%{name}/gb.libxml.* %{_libdir}/%{name}/gb.libxml.*
%changelog %changelog
* Fri Sep 19 2014 Silvan Calarco <silvan.calarco@mambasoft.it> 3.5.4-1mamba
- update to 3.5.4
* Fri Sep 19 2014 Automatic Build System <autodist@mambasoft.it> 3.5.0-3mamba
- rebuilt by autoport with build requirements: libllvm-devel>=3.5.0-2mamba
* Mon Mar 03 2014 Silvan Calarco <silvan.calarco@mambasoft.it> 3.5.0-2mamba * Mon Mar 03 2014 Silvan Calarco <silvan.calarco@mambasoft.it> 3.5.0-2mamba
- rebuilt with libpoppler 0.24.5 - rebuilt with libpoppler 0.24.5