1--- utils/common/v4l2-tpg.h.bak	2016-04-22 09:22:11.168936563 +0200
2+++ utils/common/v4l2-tpg.h	2016-04-22 09:23:07.337262639 +0200
3@@ -20,12 +20,56 @@
4 #ifndef _V4L2_TPG_H_
5 #define _V4L2_TPG_H_
6
7-#include <linux/types.h>
8-#include <linux/errno.h>
9-#include <linux/random.h>
10-#include <linux/slab.h>
11-#include <linux/vmalloc.h>
12 #include <linux/videodev2.h>
13+
14+#include <stdbool.h>
15+#include <stdlib.h>
16+#include <stdio.h>
17+#include <string.h>
18+#include <errno.h>
19+
20+typedef __u32 u32;
21+typedef __u16 u16;
22+typedef __s16 s16;
23+typedef __u8 u8;
24+typedef __s8 s8;
25+
26+#define __packed __attribute__((packed))
27+#define pr_info printf
28+#define noinline
29+
30+#ifndef min
31+#define min(a,b)	((a) < (b) ? (a) : (b))
32+#define max(a,b)	((a) > (b) ? (a) : (b))
33+#endif /* !min */
34+#define min3(x, y, z) min((typeof(x))min(x, y), z)
35+#define max3(x, y, z) max((typeof(x))max(x, y), z)
36+#define array_size(a, b) ((a) * (b))
37+#define array3_size(a, b, c) ((a) * (b) * (c))
38+
39+static inline void vfree(void *p)
40+{
41+	free(p);
42+}
43+
44+static inline void *vzalloc(unsigned long size)
45+{
46+	return calloc(1, size);
47+}
48+
49+#define clamp(val, min, max) ({			\
50+	typeof(val) __val = (val);		\
51+	typeof(min) __min = (min);		\
52+	typeof(max) __max = (max);		\
53+	(void) (&__val == &__min);		\
54+	(void) (&__val == &__max);		\
55+	__val = __val < __min ? __min: __val;	\
56+	__val > __max ? __max: __val; })
57+
58+static inline u32 prandom_u32_max(u32 ep_ro)
59+{
60+	return rand() % ep_ro;
61+}
62
63 enum tpg_pattern {
64 	TPG_PAT_75_COLORBAR,
65--- ../media-git/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c	2016-04-21 08:15:35.439610205 +0200
66+++ utils/common/v4l2-tpg-core.c	2016-04-22 09:29:50.955939090 +0200
67@@ -20,7 +18,6 @@
68  */
69
70-#include <linux/module.h>
71-#include <media/tpg/v4l2-tpg.h>
72+#include "v4l2-tpg-colors.h"
73
74 /* Must remain in sync with enum tpg_pattern */
75 const char * const tpg_pattern_strings[] = {
76@@ -49,7 +45,6 @@
77 	"Noise",
78 	NULL
79 };
80-EXPORT_SYMBOL_GPL(tpg_pattern_strings);
81
82 /* Must remain in sync with enum tpg_aspect */
83 const char * const tpg_aspect_strings[] = {
84@@ -60,7 +55,6 @@
85 	"16x9 Anamorphic",
86 	NULL
87 };
88-EXPORT_SYMBOL_GPL(tpg_aspect_strings);
89
90 /*
91  * Sine table: sin[0] = 127 * sin(-180 degrees)
92@@ -96,7 +90,6 @@
93 {
94 	font8x16 = f;
95 }
96-EXPORT_SYMBOL_GPL(tpg_set_font);
97
98 void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h)
99 {
100@@ -118,7 +111,6 @@
101 	tpg->colorspace = V4L2_COLORSPACE_SRGB;
102 	tpg->perc_fill = 100;
103 }
104-EXPORT_SYMBOL_GPL(tpg_init);
105
106 int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
107 {
108@@ -155,7 +147,6 @@
109 	}
110 	return 0;
111 }
112-EXPORT_SYMBOL_GPL(tpg_alloc);
113
114 void tpg_free(struct tpg_data *tpg)
115 {
116@@ -180,7 +171,6 @@
117 		tpg->random_line[plane] = NULL;
118 	}
119 }
120-EXPORT_SYMBOL_GPL(tpg_free);
121
122 bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
123 {
124@@ -410,7 +400,6 @@
125 	}
126 	return true;
127 }
128-EXPORT_SYMBOL_GPL(tpg_s_fourcc);
129
130 void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
131 		const struct v4l2_rect *compose)
132@@ -426,7 +415,6 @@
133 		tpg->scaled_width = 2;
134 	tpg->recalc_lines = true;
135 }
136-EXPORT_SYMBOL_GPL(tpg_s_crop_compose);
137
138 void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height,
139 		       u32 field)
140@@ -451,7 +439,6 @@
141 				       (2 * tpg->hdownsampling[p]);
142 	tpg->recalc_square_border = true;
143 }
144-EXPORT_SYMBOL_GPL(tpg_reset_source);
145
146 static enum tpg_color tpg_get_textbg_color(struct tpg_data *tpg)
147 {
148@@ -1260,7 +1247,6 @@
149 		return 0;
150 	}
151 }
152-EXPORT_SYMBOL_GPL(tpg_g_interleaved_plane);
153
154 /* Return how many pattern lines are used by the current pattern. */
155 static unsigned tpg_get_pat_lines(const struct tpg_data *tpg)
156@@ -1736,7 +1722,6 @@
157 		}
158 	}
159 }
160-EXPORT_SYMBOL_GPL(tpg_gen_text);
161
162 void tpg_update_mv_step(struct tpg_data *tpg)
163 {
164@@ -1785,7 +1770,6 @@
165 	if (factor < 0)
166 		tpg->mv_vert_step = tpg->src_height - tpg->mv_vert_step;
167 }
168-EXPORT_SYMBOL_GPL(tpg_update_mv_step);
169
170 /* Map the line number relative to the crop rectangle to a frame line number */
171 static unsigned tpg_calc_frameline(const struct tpg_data *tpg, unsigned src_y,
172@@ -1875,7 +1859,6 @@
173 	if (p == 0 && tpg->interleaved)
174 		tpg_calc_text_basep(tpg, basep, 1, vbuf);
175 }
176-EXPORT_SYMBOL_GPL(tpg_calc_text_basep);
177
178 static int tpg_pattern_avg(const struct tpg_data *tpg,
179 			   unsigned pat1, unsigned pat2)
180@@ -1905,7 +1888,6 @@
181 	pr_info("tpg quantization: %d/%d\n", tpg->quantization, tpg->real_quantization);
182 	pr_info("tpg RGB range: %d/%d\n", tpg->rgb_range, tpg->real_rgb_range);
183 }
184-EXPORT_SYMBOL_GPL(tpg_log_status);
185
186 /*
187  * This struct contains common parameters used by both the drawing of the
188@@ -2311,7 +2293,6 @@
189 				vbuf + buf_line * params.stride);
190 	}
191 }
192-EXPORT_SYMBOL_GPL(tpg_fill_plane_buffer);
193
194 void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf)
195 {
196@@ -2328,8 +2309,3 @@
197 		offset += tpg_calc_plane_size(tpg, i);
198 	}
199 }
200-EXPORT_SYMBOL_GPL(tpg_fillbuffer);
201-
202-MODULE_DESCRIPTION("V4L2 Test Pattern Generator");
203-MODULE_AUTHOR("Hans Verkuil");
204-MODULE_LICENSE("GPL");
205--- ../media-git/drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c	2016-04-21 08:15:35.439610205 +0200
206+++ utils/common/v4l2-tpg-colors.c	2016-04-22 09:26:24.638509385 +0200
207@@ -36,7 +34,7 @@
208  */
209
210 #include <linux/videodev2.h>
211-#include <media/tpg/v4l2-tpg.h>
212+#include "v4l2-tpg-colors.h"
213
214 /* sRGB colors with range [0-255] */
215 const struct color tpg_colors[TPG_COLOR_MAX] = {
216