Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] tpg: Export the tpg code from vivid as a module

The test pattern generator will be used by other drivers as the virtual
media controller (vimc)

Signed-off-by: Helen Mae Koike Fornazier <helen.koike@collabora.co.uk>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Helen Mae Koike Fornazier and committed by
Mauro Carvalho Chehab
e07d46e7 d1e5d8bd

+43 -17
+1
drivers/media/common/Kconfig
··· 19 19 source "drivers/media/common/b2c2/Kconfig" 20 20 source "drivers/media/common/saa7146/Kconfig" 21 21 source "drivers/media/common/siano/Kconfig" 22 + source "drivers/media/common/v4l2-tpg/Kconfig"
+1 -1
drivers/media/common/Makefile
··· 1 - obj-y += b2c2/ saa7146/ siano/ 1 + obj-y += b2c2/ saa7146/ siano/ v4l2-tpg/ 2 2 obj-$(CONFIG_VIDEO_CX2341X) += cx2341x.o 3 3 obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o 4 4 obj-$(CONFIG_CYPRESS_FIRMWARE) += cypress_firmware.o
+2
drivers/media/common/v4l2-tpg/Kconfig
··· 1 + config VIDEO_V4L2_TPG 2 + tristate
+3
drivers/media/common/v4l2-tpg/Makefile
··· 1 + v4l2-tpg-objs := v4l2-tpg-core.o v4l2-tpg-colors.o 2 + 3 + obj-$(CONFIG_VIDEO_V4L2_TPG) += v4l2-tpg.o
+1
drivers/media/platform/vivid/Kconfig
··· 7 7 select FB_CFB_COPYAREA 8 8 select FB_CFB_IMAGEBLIT 9 9 select VIDEOBUF2_VMALLOC 10 + select VIDEO_V4L2_TPG 10 11 default n 11 12 ---help--- 12 13 Enables a virtual video driver. This driver emulates a webcam,
+1 -1
drivers/media/platform/vivid/Makefile
··· 2 2 vivid-vid-cap.o vivid-vid-out.o vivid-kthread-cap.o vivid-kthread-out.o \ 3 3 vivid-radio-rx.o vivid-radio-tx.o vivid-radio-common.o \ 4 4 vivid-rds-gen.o vivid-sdr-cap.o vivid-vbi-cap.o vivid-vbi-out.o \ 5 - vivid-osd.o vivid-tpg.o vivid-tpg-colors.o 5 + vivid-osd.o 6 6 obj-$(CONFIG_VIDEO_VIVID) += vivid.o
+1 -1
drivers/media/platform/vivid/vivid-core.h
··· 25 25 #include <media/v4l2-device.h> 26 26 #include <media/v4l2-dev.h> 27 27 #include <media/v4l2-ctrls.h> 28 - #include "vivid-tpg.h" 28 + #include <media/v4l2-tpg.h> 29 29 #include "vivid-rds-gen.h" 30 30 #include "vivid-vbi-gen.h" 31 31
+3 -4
drivers/media/platform/vivid/vivid-tpg-colors.c drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c
··· 1 1 /* 2 - * vivid-color.c - A table that converts colors to various colorspaces 2 + * v4l2-tpg-colors.c - A table that converts colors to various colorspaces 3 3 * 4 4 * The test pattern generator uses the tpg_colors for its test patterns. 5 5 * For testing colorspaces the first 8 colors of that table need to be ··· 12 12 * This source also contains the code used to generate the tpg_csc_colors 13 13 * table. Run the following command to compile it: 14 14 * 15 - * gcc vivid-tpg-colors.c -DCOMPILE_APP -o gen-colors -lm 15 + * gcc v4l2-tpg-colors.c -DCOMPILE_APP -o gen-colors -lm 16 16 * 17 17 * and run the utility. 18 18 * ··· 36 36 */ 37 37 38 38 #include <linux/videodev2.h> 39 - 40 - #include "vivid-tpg-colors.h" 39 + #include <media/v4l2-tpg-colors.h> 41 40 42 41 /* sRGB colors with range [0-255] */ 43 42 const struct color tpg_colors[TPG_COLOR_MAX] = {
+3 -3
drivers/media/platform/vivid/vivid-tpg-colors.h include/media/v4l2-tpg-colors.h
··· 1 1 /* 2 - * vivid-color.h - Color definitions for the test pattern generator 2 + * v4l2-tpg-colors.h - Color definitions for the test pattern generator 3 3 * 4 4 * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 5 5 * ··· 17 17 * SOFTWARE. 18 18 */ 19 19 20 - #ifndef _VIVID_COLORS_H_ 21 - #define _VIVID_COLORS_H_ 20 + #ifndef _V4L2_TPG_COLORS_H_ 21 + #define _V4L2_TPG_COLORS_H_ 22 22 23 23 struct color { 24 24 unsigned char r, g, b;
+23 -2
drivers/media/platform/vivid/vivid-tpg.c drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
··· 1 1 /* 2 - * vivid-tpg.c - Test Pattern Generator 2 + * v4l2-tpg-core.c - Test Pattern Generator 3 3 * 4 4 * Note: gen_twopix and tpg_gen_text are based on code from vivi.c. See the 5 5 * vivi.c source for the copyright information of those functions. ··· 20 20 * SOFTWARE. 21 21 */ 22 22 23 - #include "vivid-tpg.h" 23 + #include <linux/module.h> 24 + #include <media/v4l2-tpg.h> 24 25 25 26 /* Must remain in sync with enum tpg_pattern */ 26 27 const char * const tpg_pattern_strings[] = { ··· 49 48 "Noise", 50 49 NULL 51 50 }; 51 + EXPORT_SYMBOL_GPL(tpg_pattern_strings); 52 52 53 53 /* Must remain in sync with enum tpg_aspect */ 54 54 const char * const tpg_aspect_strings[] = { ··· 60 58 "16x9 Anamorphic", 61 59 NULL 62 60 }; 61 + EXPORT_SYMBOL_GPL(tpg_aspect_strings); 63 62 64 63 /* 65 64 * Sine table: sin[0] = 127 * sin(-180 degrees) ··· 96 93 { 97 94 font8x16 = f; 98 95 } 96 + EXPORT_SYMBOL_GPL(tpg_set_font); 99 97 100 98 void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h) 101 99 { ··· 118 114 tpg->colorspace = V4L2_COLORSPACE_SRGB; 119 115 tpg->perc_fill = 100; 120 116 } 117 + EXPORT_SYMBOL_GPL(tpg_init); 121 118 122 119 int tpg_alloc(struct tpg_data *tpg, unsigned max_w) 123 120 { ··· 155 150 } 156 151 return 0; 157 152 } 153 + EXPORT_SYMBOL_GPL(tpg_alloc); 158 154 159 155 void tpg_free(struct tpg_data *tpg) 160 156 { ··· 180 174 tpg->random_line[plane] = NULL; 181 175 } 182 176 } 177 + EXPORT_SYMBOL_GPL(tpg_free); 183 178 184 179 bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) 185 180 { ··· 410 403 } 411 404 return true; 412 405 } 406 + EXPORT_SYMBOL_GPL(tpg_s_fourcc); 413 407 414 408 void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop, 415 409 const struct v4l2_rect *compose) ··· 426 418 tpg->scaled_width = 2; 427 419 tpg->recalc_lines = true; 428 420 } 421 + EXPORT_SYMBOL_GPL(tpg_s_crop_compose); 429 422 430 423 void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height, 431 424 u32 field) ··· 451 442 (2 * tpg->hdownsampling[p]); 452 443 tpg->recalc_square_border = true; 453 444 } 445 + EXPORT_SYMBOL_GPL(tpg_reset_source); 454 446 455 447 static enum tpg_color tpg_get_textbg_color(struct tpg_data *tpg) 456 448 { ··· 1260 1250 return 0; 1261 1251 } 1262 1252 } 1253 + EXPORT_SYMBOL_GPL(tpg_g_interleaved_plane); 1263 1254 1264 1255 /* Return how many pattern lines are used by the current pattern. */ 1265 1256 static unsigned tpg_get_pat_lines(const struct tpg_data *tpg) ··· 1736 1725 } 1737 1726 } 1738 1727 } 1728 + EXPORT_SYMBOL_GPL(tpg_gen_text); 1739 1729 1740 1730 void tpg_update_mv_step(struct tpg_data *tpg) 1741 1731 { ··· 1785 1773 if (factor < 0) 1786 1774 tpg->mv_vert_step = tpg->src_height - tpg->mv_vert_step; 1787 1775 } 1776 + EXPORT_SYMBOL_GPL(tpg_update_mv_step); 1788 1777 1789 1778 /* Map the line number relative to the crop rectangle to a frame line number */ 1790 1779 static unsigned tpg_calc_frameline(const struct tpg_data *tpg, unsigned src_y, ··· 1875 1862 if (p == 0 && tpg->interleaved) 1876 1863 tpg_calc_text_basep(tpg, basep, 1, vbuf); 1877 1864 } 1865 + EXPORT_SYMBOL_GPL(tpg_calc_text_basep); 1878 1866 1879 1867 static int tpg_pattern_avg(const struct tpg_data *tpg, 1880 1868 unsigned pat1, unsigned pat2) ··· 1905 1891 pr_info("tpg quantization: %d/%d\n", tpg->quantization, tpg->real_quantization); 1906 1892 pr_info("tpg RGB range: %d/%d\n", tpg->rgb_range, tpg->real_rgb_range); 1907 1893 } 1894 + EXPORT_SYMBOL_GPL(tpg_log_status); 1908 1895 1909 1896 /* 1910 1897 * This struct contains common parameters used by both the drawing of the ··· 2311 2296 vbuf + buf_line * params.stride); 2312 2297 } 2313 2298 } 2299 + EXPORT_SYMBOL_GPL(tpg_fill_plane_buffer); 2314 2300 2315 2301 void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf) 2316 2302 { ··· 2328 2312 offset += tpg_calc_plane_size(tpg, i); 2329 2313 } 2330 2314 } 2315 + EXPORT_SYMBOL_GPL(tpg_fillbuffer); 2316 + 2317 + MODULE_DESCRIPTION("V4L2 Test Pattern Generator"); 2318 + MODULE_AUTHOR("Hans Verkuil"); 2319 + MODULE_LICENSE("GPL");
+4 -5
drivers/media/platform/vivid/vivid-tpg.h include/media/v4l2-tpg.h
··· 1 1 /* 2 - * vivid-tpg.h - Test Pattern Generator 2 + * v4l2-tpg.h - Test Pattern Generator 3 3 * 4 4 * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. 5 5 * ··· 17 17 * SOFTWARE. 18 18 */ 19 19 20 - #ifndef _VIVID_TPG_H_ 21 - #define _VIVID_TPG_H_ 20 + #ifndef _V4L2_TPG_H_ 21 + #define _V4L2_TPG_H_ 22 22 23 23 #include <linux/types.h> 24 24 #include <linux/errno.h> ··· 26 26 #include <linux/slab.h> 27 27 #include <linux/vmalloc.h> 28 28 #include <linux/videodev2.h> 29 - 30 - #include "vivid-tpg-colors.h" 29 + #include <media/v4l2-tpg-colors.h> 31 30 32 31 enum tpg_pattern { 33 32 TPG_PAT_75_COLORBAR,