diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-07-23 17:27:37 +0200 |
---|---|---|
committer | Hans Verkuil <hans.verkuil@cisco.com> | 2014-07-23 17:27:37 +0200 |
commit | 79f62a6c9cdb647e10f55eb1c0fe2003988e5626 (patch) | |
tree | fa91d30cd659efcea89dc4028317d6ffb97292d7 | |
parent | 4d94fb69ec108146f711e03b8c34e665a3434e44 (diff) |
v4l2-ctl: upgrade to the latest version of the test pattern generator
Very minor changes only, mostly a file rename, but this makes it easier
to keep things synchronized.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r-- | utils/v4l2-ctl/Android.mk | 2 | ||||
-rw-r--r-- | utils/v4l2-ctl/Makefile.am | 2 | ||||
-rw-r--r-- | utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 10 | ||||
-rw-r--r-- | utils/v4l2-ctl/vivi-colors.h | 45 | ||||
-rw-r--r-- | utils/v4l2-ctl/vivid-tpg-colors.c (renamed from utils/v4l2-ctl/vivi-colors.c) | 39 | ||||
-rw-r--r-- | utils/v4l2-ctl/vivid-tpg-colors.h | 64 | ||||
-rw-r--r-- | utils/v4l2-ctl/vivid-tpg.c (renamed from utils/v4l2-ctl/vivi-tpg.c) | 87 | ||||
-rw-r--r-- | utils/v4l2-ctl/vivid-tpg.h (renamed from utils/v4l2-ctl/vivi-tpg.h) | 52 |
8 files changed, 198 insertions, 103 deletions
diff --git a/utils/v4l2-ctl/Android.mk b/utils/v4l2-ctl/Android.mk index 7cb48677..bbd151a6 100644 --- a/utils/v4l2-ctl/Android.mk +++ b/utils/v4l2-ctl/Android.mk @@ -20,6 +20,6 @@ LOCAL_SRC_FILES := \ v4l2-ctl-io.cpp v4l2-ctl-stds.cpp v4l2-ctl-vidcap.cpp v4l2-ctl-vidout.cpp \ v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp v4l2-ctl-misc.cpp \ v4l2-ctl-streaming.cpp v4l2-ctl-test-patterns.cpp v4l2-ctl-sdr.cpp \ - v4l2-ctl-edid.cpp + v4l2-ctl-edid.cpp vivid-tpg-colors.c vivid-tpg.c include $(BUILD_EXECUTABLE) diff --git a/utils/v4l2-ctl/Makefile.am b/utils/v4l2-ctl/Makefile.am index 060f4187..d1da429e 100644 --- a/utils/v4l2-ctl/Makefile.am +++ b/utils/v4l2-ctl/Makefile.am @@ -8,7 +8,7 @@ ivtv_ctl_LDFLAGS = -lm v4l2_ctl_SOURCES = v4l2-ctl.cpp v4l2-ctl.h v4l2-ctl-common.cpp v4l2-ctl-tuner.cpp \ v4l2-ctl-io.cpp v4l2-ctl-stds.cpp v4l2-ctl-vidcap.cpp v4l2-ctl-vidout.cpp \ v4l2-ctl-overlay.cpp v4l2-ctl-vbi.cpp v4l2-ctl-selection.cpp v4l2-ctl-misc.cpp \ - v4l2-ctl-streaming.cpp v4l2-ctl-sdr.cpp v4l2-ctl-edid.cpp vivi-colors.c vivi-tpg.c + v4l2-ctl-streaming.cpp v4l2-ctl-sdr.cpp v4l2-ctl-edid.cpp vivid-tpg-colors.c vivid-tpg.c v4l2_ctl_LDADD = ../../lib/libv4l2/libv4l2.la ../../lib/libv4lconvert/libv4lconvert.la EXTRA_DIST = Android.mk diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp index 24559e9c..7523deb3 100644 --- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -18,7 +18,7 @@ #include "v4l2-ctl.h" extern "C" { -#include "vivi-tpg.h" +#include "vivid-tpg.h" } static unsigned stream_count; @@ -725,7 +725,7 @@ static int do_setup_out_buffers(int fd, buffers &b, FILE *fin, bool qbuf) planes[j].m.userptr = (unsigned long)b.bufs[i][j]; } if (can_fill) - tpg_fillbuffer(&tpg, NULL, stream_out_std, j, (u8 *)b.bufs[i][j]); + tpg_fillbuffer(&tpg, stream_out_std, j, (u8 *)b.bufs[i][j]); } if (fin) fill_buffer_from_file(b, buf.index, fin); @@ -757,7 +757,7 @@ static int do_setup_out_buffers(int fd, buffers &b, FILE *fin, bool qbuf) } if (!fin || !fill_buffer_from_file(b, buf.index, fin)) if (can_fill) - tpg_fillbuffer(&tpg, NULL, stream_out_std, 0, (u8 *)b.bufs[i][0]); + tpg_fillbuffer(&tpg, stream_out_std, 0, (u8 *)b.bufs[i][0]); } if (qbuf) { if (V4L2_TYPE_IS_OUTPUT(buf.type)) @@ -966,9 +966,9 @@ static int do_handle_out(int fd, buffers &b, FILE *fin, struct v4l2_buffer *cap, if (!fin && stream_out_refresh) { if (b.is_mplane) { for (unsigned j = 0; j < b.num_planes; j++) - tpg_fillbuffer(&tpg, NULL, stream_out_std, j, (u8 *)b.bufs[buf.index][j]); + tpg_fillbuffer(&tpg, stream_out_std, j, (u8 *)b.bufs[buf.index][j]); } else { - tpg_fillbuffer(&tpg, NULL, stream_out_std, 0, (u8 *)b.bufs[buf.index][0]); + tpg_fillbuffer(&tpg, stream_out_std, 0, (u8 *)b.bufs[buf.index][0]); } } diff --git a/utils/v4l2-ctl/vivi-colors.h b/utils/v4l2-ctl/vivi-colors.h deleted file mode 100644 index d9c21bdb..00000000 --- a/utils/v4l2-ctl/vivi-colors.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _VIVI_COLORS_H_ -#define _VIVI_COLORS_H_ - -struct color { - unsigned char r, g, b; -}; - -struct color16 { - int r, g, b; -}; - -enum tpg_color { - TPG_COLOR_CSC_WHITE, - TPG_COLOR_CSC_YELLOW, - TPG_COLOR_CSC_CYAN, - TPG_COLOR_CSC_GREEN, - TPG_COLOR_CSC_MAGENTA, - TPG_COLOR_CSC_RED, - TPG_COLOR_CSC_BLUE, - TPG_COLOR_CSC_BLACK, - TPG_COLOR_75_YELLOW, - TPG_COLOR_75_CYAN, - TPG_COLOR_75_GREEN, - TPG_COLOR_75_MAGENTA, - TPG_COLOR_75_RED, - TPG_COLOR_75_BLUE, - TPG_COLOR_100_WHITE, - TPG_COLOR_100_YELLOW, - TPG_COLOR_100_CYAN, - TPG_COLOR_100_GREEN, - TPG_COLOR_100_MAGENTA, - TPG_COLOR_100_RED, - TPG_COLOR_100_BLUE, - TPG_COLOR_100_BLACK, - TPG_COLOR_TEXTFG, - TPG_COLOR_TEXTBG, - TPG_COLOR_RANDOM, - TPG_COLOR_RAMP, - TPG_COLOR_MAX = TPG_COLOR_RAMP + 256 -}; - -extern const struct color tpg_colors[TPG_COLOR_MAX]; -extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLACK + 1]; - -#endif diff --git a/utils/v4l2-ctl/vivi-colors.c b/utils/v4l2-ctl/vivid-tpg-colors.c index 984ccea9..2adddc0c 100644 --- a/utils/v4l2-ctl/vivi-colors.c +++ b/utils/v4l2-ctl/vivid-tpg-colors.c @@ -1,6 +1,43 @@ +/* + * vivid-color.c - A table that converts colors to various colorspaces + * + * The test pattern generator uses the tpg_colors for its test patterns. + * For testing colorspaces the first 8 colors of that table need to be + * converted to their equivalent in the target colorspace. + * + * The tpg_csc_colors[] table is the result of that conversion and since + * it is precalculated the colorspace conversion is just a simple table + * lookup. + * + * This source also contains the code used to generate the tpg_csc_colors + * table. Run the following command to compile it: + * + * gcc vivid-colors.c -DCOMPILE_APP -o gen-colors -lm + * + * and run the utility. + * + * Note that the converted colors are in the range 0x000-0xff0 (so times 16) + * in order to preserve precision. + * + * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + #include <linux/videodev2.h> -#include "vivi-colors.h" +#include "vivid-tpg-colors.h" /* sRGB colors with range [0-255] */ const struct color tpg_colors[TPG_COLOR_MAX] = { diff --git a/utils/v4l2-ctl/vivid-tpg-colors.h b/utils/v4l2-ctl/vivid-tpg-colors.h new file mode 100644 index 00000000..a2678fbe --- /dev/null +++ b/utils/v4l2-ctl/vivid-tpg-colors.h @@ -0,0 +1,64 @@ +/* + * vivid-color.h - Color definitions for the test pattern generator + * + * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _VIVID_COLORS_H_ +#define _VIVID_COLORS_H_ + +struct color { + unsigned char r, g, b; +}; + +struct color16 { + int r, g, b; +}; + +enum tpg_color { + TPG_COLOR_CSC_WHITE, + TPG_COLOR_CSC_YELLOW, + TPG_COLOR_CSC_CYAN, + TPG_COLOR_CSC_GREEN, + TPG_COLOR_CSC_MAGENTA, + TPG_COLOR_CSC_RED, + TPG_COLOR_CSC_BLUE, + TPG_COLOR_CSC_BLACK, + TPG_COLOR_75_YELLOW, + TPG_COLOR_75_CYAN, + TPG_COLOR_75_GREEN, + TPG_COLOR_75_MAGENTA, + TPG_COLOR_75_RED, + TPG_COLOR_75_BLUE, + TPG_COLOR_100_WHITE, + TPG_COLOR_100_YELLOW, + TPG_COLOR_100_CYAN, + TPG_COLOR_100_GREEN, + TPG_COLOR_100_MAGENTA, + TPG_COLOR_100_RED, + TPG_COLOR_100_BLUE, + TPG_COLOR_100_BLACK, + TPG_COLOR_TEXTFG, + TPG_COLOR_TEXTBG, + TPG_COLOR_RANDOM, + TPG_COLOR_RAMP, + TPG_COLOR_MAX = TPG_COLOR_RAMP + 256 +}; + +extern const struct color tpg_colors[TPG_COLOR_MAX]; +extern const struct color16 tpg_csc_colors[V4L2_COLORSPACE_SRGB + 1][TPG_COLOR_CSC_BLACK + 1]; + +#endif diff --git a/utils/v4l2-ctl/vivi-tpg.c b/utils/v4l2-ctl/vivid-tpg.c index fbf0eb9a..41fc1964 100644 --- a/utils/v4l2-ctl/vivi-tpg.c +++ b/utils/v4l2-ctl/vivid-tpg.c @@ -1,4 +1,26 @@ -#include "vivi-tpg.h" +/* + * vivid-tpg.c - Test Pattern Generator + * + * Note: gen_twopix and tpg_gen_text are based on code from vivi.c. See the + * vivid-core.c source for the copyright information of those functions. + * + * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "vivid-tpg.h" /* Must remain in sync with enum tpg_pattern */ const char * const tpg_pattern_strings[] = { @@ -231,8 +253,11 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc) return true; } -void tpg_s_crop_compose(struct tpg_data *tpg) +void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop, + const struct v4l2_rect *compose) { + tpg->crop = *crop; + tpg->compose = *compose; tpg->scaled_width = (tpg->src_width * tpg->compose.width + tpg->crop.width - 1) / tpg->crop.width; tpg->scaled_width &= ~1; @@ -538,6 +563,8 @@ static void precalculate_color(struct tpg_data *tpg, int k) b >>= 7; break; case V4L2_PIX_FMT_RGB555: + case V4L2_PIX_FMT_XRGB555: + case V4L2_PIX_FMT_ARGB555: case V4L2_PIX_FMT_RGB555X: r >>= 7; g >>= 7; @@ -616,14 +643,13 @@ static void gen_twopix(struct tpg_data *tpg, buf[0][offset] = (r_y << 3) | (g_u >> 3); buf[0][offset + 1] = (g_u << 5) | b_v; break; - case V4L2_PIX_FMT_ARGB555: - buf[0][offset] = (g_u << 5) | b_v; - buf[0][offset + 1] = (alpha & 0x80) | (r_y << 2) | (g_u >> 3); - break; case V4L2_PIX_FMT_RGB555: case V4L2_PIX_FMT_XRGB555: + alpha = 0; + /* fall through */ + case V4L2_PIX_FMT_ARGB555: buf[0][offset] = (g_u << 5) | b_v; - buf[0][offset + 1] = (r_y << 2) | (g_u >> 3); + buf[0][offset + 1] = (alpha & 0x80) | (r_y << 2) | (g_u >> 3); break; case V4L2_PIX_FMT_RGB555X: buf[0][offset] = (alpha & 0x80) | (r_y << 2) | (g_u >> 3); @@ -639,31 +665,25 @@ static void gen_twopix(struct tpg_data *tpg, buf[0][offset + 1] = g_u; buf[0][offset + 2] = r_y; break; - case V4L2_PIX_FMT_ARGB32: - buf[0][offset] = alpha; - buf[0][offset + 1] = r_y; - buf[0][offset + 2] = g_u; - buf[0][offset + 3] = b_v; - break; case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_XRGB32: - buf[0][offset] = 0; + alpha = 0; + /* fall through */ + case V4L2_PIX_FMT_ARGB32: + buf[0][offset] = alpha; buf[0][offset + 1] = r_y; buf[0][offset + 2] = g_u; buf[0][offset + 3] = b_v; break; - case V4L2_PIX_FMT_ABGR32: - buf[0][offset] = b_v; - buf[0][offset + 1] = g_u; - buf[0][offset + 2] = r_y; - buf[0][offset + 3] = alpha; - break; case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_XBGR32: + alpha = 0; + /* fall through */ + case V4L2_PIX_FMT_ABGR32: buf[0][offset] = b_v; buf[0][offset + 1] = g_u; buf[0][offset + 2] = r_y; - buf[0][offset + 3] = 0; + buf[0][offset + 3] = alpha; break; } } @@ -1118,8 +1138,20 @@ static unsigned tpg_calc_buffer_line(struct tpg_data *tpg, unsigned y, } } -void tpg_fillbuffer(struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], - v4l2_std_id std, unsigned p, u8 *vbuf) +void tpg_calc_text_basep(const struct tpg_data *tpg, + u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf) +{ + unsigned stride = tpg->bytesperline[p]; + + basep[p][0] = vbuf; + basep[p][1] = vbuf; + if (tpg->field == V4L2_FIELD_SEQ_TB) + basep[p][1] += tpg->buf_height * stride / 2; + else if (tpg->field == V4L2_FIELD_SEQ_BT) + basep[p][0] += tpg->buf_height * stride / 2; +} + +void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf) { bool is_tv = std; bool is_60hz = is_tv && (std & V4L2_STD_525_60); @@ -1168,15 +1200,6 @@ void tpg_fillbuffer(struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], wss_width = tpg->crop.width; wss_width = wss_width * tpg->scaled_width / tpg->src_width; - if (basep) { - basep[p][0] = vbuf; - basep[p][1] = vbuf; - if (tpg->field == V4L2_FIELD_SEQ_TB) - basep[p][1] += tpg->buf_height * stride / 2; - else if (tpg->field == V4L2_FIELD_SEQ_BT) - basep[p][0] += tpg->buf_height * stride / 2; - } - vbuf += tpg->compose.left * twopixsize / 2; line_offset = tpg->crop.left * tpg->scaled_width / tpg->src_width; line_offset = (line_offset & ~1) * twopixsize / 2; diff --git a/utils/v4l2-ctl/vivi-tpg.h b/utils/v4l2-ctl/vivid-tpg.h index b90b6567..b105bbd9 100644 --- a/utils/v4l2-ctl/vivi-tpg.h +++ b/utils/v4l2-ctl/vivid-tpg.h @@ -1,5 +1,24 @@ -#ifndef _VIVI_TPG_H_ -#define _VIVI_TPG_H_ +/* + * vivid-tpg.h - Test Pattern Generator + * + * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved. + * + * This program is free software; you may redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _VIVID_TPG_H_ +#define _VIVID_TPG_H_ #include <linux/types.h> #include <linux/videodev2.h> @@ -36,7 +55,7 @@ static inline void *vzalloc(unsigned long size) __val = __val < __min ? __min: __val; \ __val > __max ? __max: __val; }) -#include "vivi-colors.h" +#include "vivid-tpg-colors.h" enum tpg_pattern { TPG_PAT_75_COLORBAR, @@ -176,12 +195,14 @@ void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height, u32 field); void tpg_set_font(const u8 *f); -void tpg_gen_text(struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], - int y, int x, char *text); -void tpg_fillbuffer(struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], - v4l2_std_id std, unsigned p, u8 *vbuf); +void tpg_gen_text(struct tpg_data *tpg, + u8 *basep[TPG_MAX_PLANES][2], int y, int x, char *text); +void tpg_calc_text_basep(const struct tpg_data *tpg, + u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf); +void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf); bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc); -void tpg_s_crop_compose(struct tpg_data *tpg); +void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop, + const struct v4l2_rect *compose); static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern) { @@ -316,16 +337,6 @@ static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h) tpg->buf_height = h; } -static inline struct v4l2_rect *tpg_g_crop(struct tpg_data *tpg) -{ - return &tpg->crop; -} - -static inline struct v4l2_rect *tpg_g_compose(struct tpg_data *tpg) -{ - return &tpg->compose; -} - static inline void tpg_s_field(struct tpg_data *tpg, unsigned field) { tpg->field = field; @@ -357,6 +368,11 @@ static inline void tpg_s_video_aspect(struct tpg_data *tpg, tpg->recalc_square_border = true; } +static inline enum tpg_video_aspect tpg_g_video_aspect(const struct tpg_data *tpg) +{ + return tpg->vid_aspect; +} + static inline void tpg_s_pixel_aspect(struct tpg_data *tpg, enum tpg_pixel_aspect pix_aspect) { |