Copy the vivid-tpg* sources from the kernel
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 3 Sep 2014 09:24:33 +0000 (11:24 +0200)
committerHans Verkuil <hans.verkuil@cisco.com>
Wed, 3 Sep 2014 12:27:34 +0000 (14:27 +0200)
This keeps the test pattern generator in v4l-utils in sync with the
tpg in the vivid kernel driver.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Makefile.am
utils/v4l2-ctl/vivid-tpg.h.patch [new file with mode: 0644]

index cc48c2d..06a2a5d 100644 (file)
@@ -38,6 +38,9 @@ sync-with-kernel:
        cp -a $(KERNEL_DIR)/usr/include/linux/dvb/dmx.h $(top_srcdir)/include/linux/dvb
        cp -a $(KERNEL_DIR)/usr/include/linux/dvb/audio.h $(top_srcdir)/include/linux/dvb
        cp -a $(KERNEL_DIR)/usr/include/linux/dvb/video.h $(top_srcdir)/include/linux/dvb
+       cp -a $(KERNEL_DIR)/drivers/media/platform/vivid/vivid-tpg.[ch] $(top_srcdir)/utils/v4l2-ctl
+       cp -a $(KERNEL_DIR)/drivers/media/platform/vivid/vivid-tpg-colors.[ch] $(top_srcdir)/utils/v4l2-ctl
+       patch -p1 <$(top_srcdir)/utils/v4l2-ctl/vivid-tpg.h.patch
 
        $(MAKE) -C utils/keytable $@
        $(MAKE) -C utils/xc3028-firmware $@
diff --git a/utils/v4l2-ctl/vivid-tpg.h.patch b/utils/v4l2-ctl/vivid-tpg.h.patch
new file mode 100644 (file)
index 0000000..f200203
--- /dev/null
@@ -0,0 +1,55 @@
+diff --git b/utils/v4l2-ctl/vivid-tpg.h a/utils/v4l2-ctl/vivid-tpg.h
+index 51ef7d1..76c373a 100644
+--- b/utils/v4l2-ctl/vivid-tpg.h
++++ a/utils/v4l2-ctl/vivid-tpg.h
+@@ -20,13 +20,46 @@
+ #ifndef _VIVID_TPG_H_
+ #define _VIVID_TPG_H_
+-#include <linux/version.h>
+ #include <linux/types.h>
+-#include <linux/errno.h>
+-#include <linux/random.h>
+-#include <linux/slab.h>
+ #include <linux/videodev2.h>
++#include <stdbool.h>
++#include <stdlib.h>
++#include <string.h>
++#include <errno.h>
++
++typedef __u32 u32;
++typedef __u16 u16;
++typedef __s16 s16;
++typedef __u8 u8;
++typedef __s8 s8;
++
++#define __packed __attribute__((packed))
++
++static inline void vfree(void *p)
++{
++      free(p);
++}
++
++static inline void *vzalloc(unsigned long size)
++{
++      return calloc(1, size);
++}
++
++#define clamp(val, min, max) ({                       \
++      typeof(val) __val = (val);              \
++      typeof(min) __min = (min);              \
++      typeof(max) __max = (max);              \
++      (void) (&__val == &__min);              \
++      (void) (&__val == &__max);              \
++      __val = __val < __min ? __min: __val;   \
++      __val > __max ? __max: __val; })
++
++static inline u32 prandom_u32_max(u32 ep_ro)
++{
++      return rand() % ep_ro;
++}
++
+ #include "vivid-tpg-colors.h"
+ enum tpg_pattern {