• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/utils/common/v4l2-tpg-colors.c b/utils/common/v4l2-tpg-colors.c
2index a4341205..b4e257c2 100644
3--- a/utils/common/v4l2-tpg-colors.c
4+++ b/utils/common/v4l2-tpg-colors.c
5@@ -24,7 +24,7 @@
6  */
7
8 #include <linux/videodev2.h>
9-#include <media/tpg/v4l2-tpg.h>
10+#include "v4l2-tpg-colors.h"
11
12 /* sRGB colors with range [0-255] */
13 const struct tpg_rbg_color8 tpg_colors[TPG_COLOR_MAX] = {
14diff --git a/utils/common/v4l2-tpg-core.c b/utils/common/v4l2-tpg-core.c
15index 630a75e0..44972222 100644
16--- a/utils/common/v4l2-tpg-core.c
17+++ b/utils/common/v4l2-tpg-core.c
18@@ -8,8 +8,8 @@
19  * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
20  */
21
22-#include <linux/module.h>
23-#include <media/tpg/v4l2-tpg.h>
24+#include "compiler.h"
25+#include "v4l2-tpg-colors.h"
26
27 /* Must remain in sync with enum tpg_pattern */
28 const char * const tpg_pattern_strings[] = {
29@@ -37,7 +36,6 @@ const char * const tpg_pattern_strings[] = {
30 	"Noise",
31 	NULL
32 };
33-EXPORT_SYMBOL_GPL(tpg_pattern_strings);
34
35 /* Must remain in sync with enum tpg_aspect */
36 const char * const tpg_aspect_strings[] = {
37@@ -48,7 +46,6 @@ const char * const tpg_aspect_strings[] = {
38 	"16x9 Anamorphic",
39 	NULL
40 };
41-EXPORT_SYMBOL_GPL(tpg_aspect_strings);
42
43 /*
44  * Sine table: sin[0] = 127 * sin(-180 degrees)
45@@ -84,7 +81,6 @@ void tpg_set_font(const u8 *f)
46 {
47 	font8x16 = f;
48 }
49-EXPORT_SYMBOL_GPL(tpg_set_font);
50
51 void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h)
52 {
53@@ -107,7 +103,6 @@ void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h)
54 	tpg->perc_fill = 100;
55 	tpg->hsv_enc = V4L2_HSV_ENC_180;
56 }
57-EXPORT_SYMBOL_GPL(tpg_init);
58
59 int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
60 {
61@@ -149,7 +144,6 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
62 	}
63 	return 0;
64 }
65-EXPORT_SYMBOL_GPL(tpg_alloc);
66
67 void tpg_free(struct tpg_data *tpg)
68 {
69@@ -174,7 +168,6 @@ void tpg_free(struct tpg_data *tpg)
70 		tpg->random_line[plane] = NULL;
71 	}
72 }
73-EXPORT_SYMBOL_GPL(tpg_free);
74
75 bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
76 {
77@@ -466,7 +459,6 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
78 	}
79 	return true;
80 }
81-EXPORT_SYMBOL_GPL(tpg_s_fourcc);
82
83 void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
84 		const struct v4l2_rect *compose)
85@@ -482,7 +474,6 @@ void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
86 		tpg->scaled_width = 2;
87 	tpg->recalc_lines = true;
88 }
89-EXPORT_SYMBOL_GPL(tpg_s_crop_compose);
90
91 void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height,
92 		       u32 field)
93@@ -507,7 +498,6 @@ void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height,
94 				       (2 * tpg->hdownsampling[p]);
95 	tpg->recalc_square_border = true;
96 }
97-EXPORT_SYMBOL_GPL(tpg_reset_source);
98
99 static enum tpg_color tpg_get_textbg_color(struct tpg_data *tpg)
100 {
101@@ -1528,7 +1518,6 @@ unsigned tpg_g_interleaved_plane(const struct tpg_data *tpg, unsigned buf_line)
102 		return 0;
103 	}
104 }
105-EXPORT_SYMBOL_GPL(tpg_g_interleaved_plane);
106
107 /* Return how many pattern lines are used by the current pattern. */
108 static unsigned tpg_get_pat_lines(const struct tpg_data *tpg)
109@@ -2006,7 +1995,6 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],
110 		}
111 	}
112 }
113-EXPORT_SYMBOL_GPL(tpg_gen_text);
114
115 const char *tpg_g_color_order(const struct tpg_data *tpg)
116 {
117@@ -2030,7 +2018,6 @@ const char *tpg_g_color_order(const struct tpg_data *tpg)
118 		return NULL;
119 	}
120 }
121-EXPORT_SYMBOL_GPL(tpg_g_color_order);
122
123 void tpg_update_mv_step(struct tpg_data *tpg)
124 {
125@@ -2079,7 +2066,6 @@ void tpg_update_mv_step(struct tpg_data *tpg)
126 	if (factor < 0)
127 		tpg->mv_vert_step = tpg->src_height - tpg->mv_vert_step;
128 }
129-EXPORT_SYMBOL_GPL(tpg_update_mv_step);
130
131 /* Map the line number relative to the crop rectangle to a frame line number */
132 static unsigned tpg_calc_frameline(const struct tpg_data *tpg, unsigned src_y,
133@@ -2171,7 +2157,6 @@ void tpg_calc_text_basep(struct tpg_data *tpg,
134 	if (p == 0 && tpg->interleaved)
135 		tpg_calc_text_basep(tpg, basep, 1, vbuf);
136 }
137-EXPORT_SYMBOL_GPL(tpg_calc_text_basep);
138
139 static int tpg_pattern_avg(const struct tpg_data *tpg,
140 			   unsigned pat1, unsigned pat2)
141@@ -2223,7 +2208,6 @@ void tpg_log_status(struct tpg_data *tpg)
142 	pr_info("tpg quantization: %d/%d\n", tpg->quantization, tpg->real_quantization);
143 	pr_info("tpg RGB range: %d/%d\n", tpg->rgb_range, tpg->real_rgb_range);
144 }
145-EXPORT_SYMBOL_GPL(tpg_log_status);
146
147 /*
148  * This struct contains common parameters used by both the drawing of the
149@@ -2629,7 +2613,6 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std,
150 				vbuf + buf_line * params.stride);
151 	}
152 }
153-EXPORT_SYMBOL_GPL(tpg_fill_plane_buffer);
154
155 void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf)
156 {
157@@ -2646,8 +2629,3 @@ void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf)
158 		offset += tpg_calc_plane_size(tpg, i);
159 	}
160 }
161-EXPORT_SYMBOL_GPL(tpg_fillbuffer);
162-
163-MODULE_DESCRIPTION("V4L2 Test Pattern Generator");
164-MODULE_AUTHOR("Hans Verkuil");
165-MODULE_LICENSE("GPL");
166diff --git a/utils/common/v4l2-tpg.h b/utils/common/v4l2-tpg.h
167index 0b0ddb87..91da74ec 100644
168--- a/utils/common/v4l2-tpg.h
169+++ b/utils/common/v4l2-tpg.h
170@@ -8,13 +8,65 @@
171 #ifndef _V4L2_TPG_H_
172 #define _V4L2_TPG_H_
173
174-#include <linux/types.h>
175-#include <linux/errno.h>
176-#include <linux/random.h>
177-#include <linux/slab.h>
178-#include <linux/vmalloc.h>
179 #include <linux/videodev2.h>
180
181+#include <stdbool.h>
182+#include <stdlib.h>
183+#include <stdio.h>
184+#include <string.h>
185+#include <errno.h>
186+
187+typedef __u32 u32;
188+typedef __u16 u16;
189+typedef __s16 s16;
190+typedef __u8 u8;
191+typedef __s8 s8;
192+
193+#ifndef __packed
194+#define __packed __attribute__((packed))
195+#endif
196+#define pr_info printf
197+#define noinline
198+
199+#define tpg_min(a,b)	((a) < (b) ? (a) : (b))
200+#define tpg_max(a,b)	((a) > (b) ? (a) : (b))
201+#define min3(x, y, z) tpg_min((typeof(x))tpg_min(x, y), z)
202+#define max3(x, y, z) tpg_max((typeof(x))tpg_max(x, y), z)
203+#define array_size(a, b) ((a) * (b))
204+#define array3_size(a, b, c) ((a) * (b) * (c))
205+
206+static inline void vfree(void *p)
207+{
208+	free(p);
209+}
210+
211+static inline void *vzalloc(unsigned long size)
212+{
213+	return calloc(1, size);
214+}
215+
216+#define clamp(val, min, max) ({			\
217+	typeof(val) __val = (val);		\
218+	typeof(min) __min = (min);		\
219+	typeof(max) __max = (max);		\
220+	(void) (&__val == &__min);		\
221+	(void) (&__val == &__max);		\
222+	__val = __val < __min ? __min: __val;	\
223+	__val > __max ? __max: __val; })
224+
225+#define clamp_t(type, val, min, max) clamp((type)val, (type)min, (type)max)
226+
227+static inline u32 get_random_u32_below(u32 ep_ro)
228+{
229+	return rand() % ep_ro;
230+}
231+
232+static inline u32 get_random_u8(void)
233+{
234+	return get_random_u32_below(256);
235+}
236+
237+
238 struct tpg_rbg_color8 {
239 	unsigned char r, g, b;
240 };
241