blob: b4cb8f34cd87811ac2168dcb67f52467a6abe9a0 [file] [log] [blame]
Hans Verkuil63881df2014-08-25 08:02:14 -03001/*
Helen Mae Koike Fornaziere07d46e2016-04-08 17:28:58 -03002 * v4l2-tpg.h - Test Pattern Generator
Hans Verkuil63881df2014-08-25 08:02:14 -03003 *
4 * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
5 *
6 * This program is free software; you may redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
14 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
15 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 */
19
Helen Mae Koike Fornaziere07d46e2016-04-08 17:28:58 -030020#ifndef _V4L2_TPG_H_
21#define _V4L2_TPG_H_
Hans Verkuil63881df2014-08-25 08:02:14 -030022
Hans Verkuil63881df2014-08-25 08:02:14 -030023#include <linux/types.h>
24#include <linux/errno.h>
25#include <linux/random.h>
26#include <linux/slab.h>
Hans Verkuil5754d0d2014-09-03 04:29:00 -030027#include <linux/vmalloc.h>
Hans Verkuil63881df2014-08-25 08:02:14 -030028#include <linux/videodev2.h>
Helen Mae Koike Fornaziere07d46e2016-04-08 17:28:58 -030029#include <media/v4l2-tpg-colors.h>
Hans Verkuil63881df2014-08-25 08:02:14 -030030
31enum tpg_pattern {
32 TPG_PAT_75_COLORBAR,
33 TPG_PAT_100_COLORBAR,
34 TPG_PAT_CSC_COLORBAR,
35 TPG_PAT_100_HCOLORBAR,
36 TPG_PAT_100_COLORSQUARES,
37 TPG_PAT_BLACK,
38 TPG_PAT_WHITE,
39 TPG_PAT_RED,
40 TPG_PAT_GREEN,
41 TPG_PAT_BLUE,
42 TPG_PAT_CHECKERS_16X16,
Hans Verkuil1a05d312015-03-07 12:49:57 -030043 TPG_PAT_CHECKERS_2X2,
Hans Verkuil63881df2014-08-25 08:02:14 -030044 TPG_PAT_CHECKERS_1X1,
Hans Verkuil1a05d312015-03-07 12:49:57 -030045 TPG_PAT_COLOR_CHECKERS_2X2,
46 TPG_PAT_COLOR_CHECKERS_1X1,
Hans Verkuil63881df2014-08-25 08:02:14 -030047 TPG_PAT_ALTERNATING_HLINES,
48 TPG_PAT_ALTERNATING_VLINES,
49 TPG_PAT_CROSS_1_PIXEL,
50 TPG_PAT_CROSS_2_PIXELS,
51 TPG_PAT_CROSS_10_PIXELS,
52 TPG_PAT_GRAY_RAMP,
53
54 /* Must be the last pattern */
55 TPG_PAT_NOISE,
56};
57
58extern const char * const tpg_pattern_strings[];
59
60enum tpg_quality {
61 TPG_QUAL_COLOR,
62 TPG_QUAL_GRAY,
63 TPG_QUAL_NOISE
64};
65
66enum tpg_video_aspect {
67 TPG_VIDEO_ASPECT_IMAGE,
68 TPG_VIDEO_ASPECT_4X3,
69 TPG_VIDEO_ASPECT_14X9_CENTRE,
70 TPG_VIDEO_ASPECT_16X9_CENTRE,
71 TPG_VIDEO_ASPECT_16X9_ANAMORPHIC,
72};
73
74enum tpg_pixel_aspect {
75 TPG_PIXEL_ASPECT_SQUARE,
76 TPG_PIXEL_ASPECT_NTSC,
77 TPG_PIXEL_ASPECT_PAL,
78};
79
80enum tpg_move_mode {
81 TPG_MOVE_NEG_FAST,
82 TPG_MOVE_NEG,
83 TPG_MOVE_NEG_SLOW,
84 TPG_MOVE_NONE,
85 TPG_MOVE_POS_SLOW,
86 TPG_MOVE_POS,
87 TPG_MOVE_POS_FAST,
88};
89
Ricardo Ribalda Delgado646895e2016-07-15 06:09:47 -030090enum tgp_color_enc {
91 TGP_COLOR_ENC_RGB,
92 TGP_COLOR_ENC_YCBCR,
93};
94
Hans Verkuil63881df2014-08-25 08:02:14 -030095extern const char * const tpg_aspect_strings[];
96
Hans Verkuilba01f672015-03-07 13:57:27 -030097#define TPG_MAX_PLANES 3
Hans Verkuil63881df2014-08-25 08:02:14 -030098#define TPG_MAX_PAT_LINES 8
99
100struct tpg_data {
101 /* Source frame size */
102 unsigned src_width, src_height;
103 /* Buffer height */
104 unsigned buf_height;
105 /* Scaled output frame size */
106 unsigned scaled_width;
107 u32 field;
Hans Verkuil43047f62015-03-07 12:38:42 -0300108 bool field_alternate;
Hans Verkuil63881df2014-08-25 08:02:14 -0300109 /* crop coordinates are frame-based */
110 struct v4l2_rect crop;
111 /* compose coordinates are format-based */
112 struct v4l2_rect compose;
113 /* border and square coordinates are frame-based */
114 struct v4l2_rect border;
115 struct v4l2_rect square;
116
117 /* Color-related fields */
118 enum tpg_quality qual;
119 unsigned qual_offset;
120 u8 alpha_component;
121 bool alpha_red_only;
122 u8 brightness;
123 u8 contrast;
124 u8 saturation;
125 s16 hue;
126 u32 fourcc;
Ricardo Ribalda Delgado646895e2016-07-15 06:09:47 -0300127 enum tgp_color_enc color_enc;
Hans Verkuil63881df2014-08-25 08:02:14 -0300128 u32 colorspace;
Hans Verkuilca5316d2015-04-28 09:41:37 -0300129 u32 xfer_func;
Hans Verkuil481b97a2014-11-17 10:14:32 -0300130 u32 ycbcr_enc;
131 /*
Hans Verkuilca5316d2015-04-28 09:41:37 -0300132 * Stores the actual transfer function, i.e. will never be
133 * V4L2_XFER_FUNC_DEFAULT.
134 */
135 u32 real_xfer_func;
136 /*
Hans Verkuil481b97a2014-11-17 10:14:32 -0300137 * Stores the actual Y'CbCr encoding, i.e. will never be
138 * V4L2_YCBCR_ENC_DEFAULT.
139 */
140 u32 real_ycbcr_enc;
141 u32 quantization;
142 /*
143 * Stores the actual quantization, i.e. will never be
144 * V4L2_QUANTIZATION_DEFAULT.
145 */
146 u32 real_quantization;
Hans Verkuil63881df2014-08-25 08:02:14 -0300147 enum tpg_video_aspect vid_aspect;
148 enum tpg_pixel_aspect pix_aspect;
149 unsigned rgb_range;
150 unsigned real_rgb_range;
Hans Verkuil06d1f0c2015-03-07 13:01:53 -0300151 unsigned buffers;
Hans Verkuil63881df2014-08-25 08:02:14 -0300152 unsigned planes;
Hans Verkuil02aa7692015-03-14 08:01:50 -0300153 bool interleaved;
Hans Verkuilba01f672015-03-07 13:57:27 -0300154 u8 vdownsampling[TPG_MAX_PLANES];
155 u8 hdownsampling[TPG_MAX_PLANES];
Hans Verkuil9991def2015-03-08 05:53:10 -0300156 /*
157 * horizontal positions must be ANDed with this value to enforce
158 * correct boundaries for packed YUYV values.
159 */
160 unsigned hmask[TPG_MAX_PLANES];
Hans Verkuil63881df2014-08-25 08:02:14 -0300161 /* Used to store the colors in native format, either RGB or YUV */
162 u8 colors[TPG_COLOR_MAX][3];
163 u8 textfg[TPG_MAX_PLANES][8], textbg[TPG_MAX_PLANES][8];
164 /* size in bytes for two pixels in each plane */
165 unsigned twopixelsize[TPG_MAX_PLANES];
166 unsigned bytesperline[TPG_MAX_PLANES];
167
168 /* Configuration */
169 enum tpg_pattern pattern;
170 bool hflip;
171 bool vflip;
172 unsigned perc_fill;
173 bool perc_fill_blank;
174 bool show_border;
175 bool show_square;
176 bool insert_sav;
177 bool insert_eav;
178
179 /* Test pattern movement */
180 enum tpg_move_mode mv_hor_mode;
181 int mv_hor_count;
182 int mv_hor_step;
183 enum tpg_move_mode mv_vert_mode;
184 int mv_vert_count;
185 int mv_vert_step;
186
187 bool recalc_colors;
188 bool recalc_lines;
189 bool recalc_square_border;
190
191 /* Used to store TPG_MAX_PAT_LINES lines, each with up to two planes */
192 unsigned max_line_width;
193 u8 *lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES];
Hans Verkuil5d7c5392015-03-07 14:06:43 -0300194 u8 *downsampled_lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES];
Hans Verkuil63881df2014-08-25 08:02:14 -0300195 u8 *random_line[TPG_MAX_PLANES];
196 u8 *contrast_line[TPG_MAX_PLANES];
197 u8 *black_line[TPG_MAX_PLANES];
198};
199
200void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h);
201int tpg_alloc(struct tpg_data *tpg, unsigned max_w);
202void tpg_free(struct tpg_data *tpg);
203void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height,
204 u32 field);
Hans Verkuil84b76d72015-04-24 11:16:22 -0300205void tpg_log_status(struct tpg_data *tpg);
Hans Verkuil63881df2014-08-25 08:02:14 -0300206
207void tpg_set_font(const u8 *f);
Hans Verkuildfff0482015-03-09 11:04:02 -0300208void tpg_gen_text(const struct tpg_data *tpg,
Hans Verkuil63881df2014-08-25 08:02:14 -0300209 u8 *basep[TPG_MAX_PLANES][2], int y, int x, char *text);
210void tpg_calc_text_basep(struct tpg_data *tpg,
211 u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf);
Hans Verkuil02aa7692015-03-14 08:01:50 -0300212unsigned tpg_g_interleaved_plane(const struct tpg_data *tpg, unsigned buf_line);
Hans Verkuildfff0482015-03-09 11:04:02 -0300213void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std,
214 unsigned p, u8 *vbuf);
215void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std,
216 unsigned p, u8 *vbuf);
Hans Verkuil63881df2014-08-25 08:02:14 -0300217bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc);
218void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
219 const struct v4l2_rect *compose);
220
221static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern)
222{
223 if (tpg->pattern == pattern)
224 return;
225 tpg->pattern = pattern;
226 tpg->recalc_colors = true;
227}
228
229static inline void tpg_s_quality(struct tpg_data *tpg,
230 enum tpg_quality qual, unsigned qual_offset)
231{
232 if (tpg->qual == qual && tpg->qual_offset == qual_offset)
233 return;
234 tpg->qual = qual;
235 tpg->qual_offset = qual_offset;
236 tpg->recalc_colors = true;
237}
238
239static inline enum tpg_quality tpg_g_quality(const struct tpg_data *tpg)
240{
241 return tpg->qual;
242}
243
244static inline void tpg_s_alpha_component(struct tpg_data *tpg,
245 u8 alpha_component)
246{
247 if (tpg->alpha_component == alpha_component)
248 return;
249 tpg->alpha_component = alpha_component;
250 tpg->recalc_colors = true;
251}
252
253static inline void tpg_s_alpha_mode(struct tpg_data *tpg,
254 bool red_only)
255{
256 if (tpg->alpha_red_only == red_only)
257 return;
258 tpg->alpha_red_only = red_only;
259 tpg->recalc_colors = true;
260}
261
262static inline void tpg_s_brightness(struct tpg_data *tpg,
263 u8 brightness)
264{
265 if (tpg->brightness == brightness)
266 return;
267 tpg->brightness = brightness;
268 tpg->recalc_colors = true;
269}
270
271static inline void tpg_s_contrast(struct tpg_data *tpg,
272 u8 contrast)
273{
274 if (tpg->contrast == contrast)
275 return;
276 tpg->contrast = contrast;
277 tpg->recalc_colors = true;
278}
279
280static inline void tpg_s_saturation(struct tpg_data *tpg,
281 u8 saturation)
282{
283 if (tpg->saturation == saturation)
284 return;
285 tpg->saturation = saturation;
286 tpg->recalc_colors = true;
287}
288
289static inline void tpg_s_hue(struct tpg_data *tpg,
290 s16 hue)
291{
292 if (tpg->hue == hue)
293 return;
294 tpg->hue = hue;
295 tpg->recalc_colors = true;
296}
297
298static inline void tpg_s_rgb_range(struct tpg_data *tpg,
299 unsigned rgb_range)
300{
301 if (tpg->rgb_range == rgb_range)
302 return;
303 tpg->rgb_range = rgb_range;
304 tpg->recalc_colors = true;
305}
306
307static inline void tpg_s_real_rgb_range(struct tpg_data *tpg,
308 unsigned rgb_range)
309{
310 if (tpg->real_rgb_range == rgb_range)
311 return;
312 tpg->real_rgb_range = rgb_range;
313 tpg->recalc_colors = true;
314}
315
316static inline void tpg_s_colorspace(struct tpg_data *tpg, u32 colorspace)
317{
318 if (tpg->colorspace == colorspace)
319 return;
320 tpg->colorspace = colorspace;
321 tpg->recalc_colors = true;
322}
323
324static inline u32 tpg_g_colorspace(const struct tpg_data *tpg)
325{
326 return tpg->colorspace;
327}
328
Hans Verkuil481b97a2014-11-17 10:14:32 -0300329static inline void tpg_s_ycbcr_enc(struct tpg_data *tpg, u32 ycbcr_enc)
330{
331 if (tpg->ycbcr_enc == ycbcr_enc)
332 return;
333 tpg->ycbcr_enc = ycbcr_enc;
334 tpg->recalc_colors = true;
335}
336
337static inline u32 tpg_g_ycbcr_enc(const struct tpg_data *tpg)
338{
339 return tpg->ycbcr_enc;
340}
341
Hans Verkuilca5316d2015-04-28 09:41:37 -0300342static inline void tpg_s_xfer_func(struct tpg_data *tpg, u32 xfer_func)
343{
344 if (tpg->xfer_func == xfer_func)
345 return;
346 tpg->xfer_func = xfer_func;
347 tpg->recalc_colors = true;
348}
349
350static inline u32 tpg_g_xfer_func(const struct tpg_data *tpg)
351{
352 return tpg->xfer_func;
353}
354
Hans Verkuil481b97a2014-11-17 10:14:32 -0300355static inline void tpg_s_quantization(struct tpg_data *tpg, u32 quantization)
356{
357 if (tpg->quantization == quantization)
358 return;
359 tpg->quantization = quantization;
360 tpg->recalc_colors = true;
361}
362
363static inline u32 tpg_g_quantization(const struct tpg_data *tpg)
364{
365 return tpg->quantization;
366}
367
Hans Verkuil06d1f0c2015-03-07 13:01:53 -0300368static inline unsigned tpg_g_buffers(const struct tpg_data *tpg)
369{
370 return tpg->buffers;
371}
372
Hans Verkuil63881df2014-08-25 08:02:14 -0300373static inline unsigned tpg_g_planes(const struct tpg_data *tpg)
374{
Hans Verkuil02aa7692015-03-14 08:01:50 -0300375 return tpg->interleaved ? 1 : tpg->planes;
376}
377
378static inline bool tpg_g_interleaved(const struct tpg_data *tpg)
379{
380 return tpg->interleaved;
Hans Verkuil63881df2014-08-25 08:02:14 -0300381}
382
383static inline unsigned tpg_g_twopixelsize(const struct tpg_data *tpg, unsigned plane)
384{
385 return tpg->twopixelsize[plane];
386}
387
Hans Verkuil9991def2015-03-08 05:53:10 -0300388static inline unsigned tpg_hdiv(const struct tpg_data *tpg,
389 unsigned plane, unsigned x)
390{
391 return ((x / tpg->hdownsampling[plane]) & tpg->hmask[plane]) *
392 tpg->twopixelsize[plane] / 2;
393}
394
395static inline unsigned tpg_hscale(const struct tpg_data *tpg, unsigned x)
396{
397 return (x * tpg->scaled_width) / tpg->src_width;
398}
399
400static inline unsigned tpg_hscale_div(const struct tpg_data *tpg,
401 unsigned plane, unsigned x)
402{
403 return tpg_hdiv(tpg, plane, tpg_hscale(tpg, x));
404}
405
Hans Verkuil63881df2014-08-25 08:02:14 -0300406static inline unsigned tpg_g_bytesperline(const struct tpg_data *tpg, unsigned plane)
407{
408 return tpg->bytesperline[plane];
409}
410
411static inline void tpg_s_bytesperline(struct tpg_data *tpg, unsigned plane, unsigned bpl)
412{
Hans Verkuil4db22042015-03-07 13:39:01 -0300413 unsigned p;
414
415 if (tpg->buffers > 1) {
416 tpg->bytesperline[plane] = bpl;
417 return;
418 }
419
Hans Verkuil02aa7692015-03-14 08:01:50 -0300420 for (p = 0; p < tpg_g_planes(tpg); p++) {
Hans Verkuil4db22042015-03-07 13:39:01 -0300421 unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0];
422
Hans Verkuilba01f672015-03-07 13:57:27 -0300423 tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p];
Hans Verkuil4db22042015-03-07 13:39:01 -0300424 }
Hans Verkuil3541e342016-01-22 13:13:25 -0200425 if (tpg_g_interleaved(tpg))
426 tpg->bytesperline[1] = tpg->bytesperline[0];
Hans Verkuil4db22042015-03-07 13:39:01 -0300427}
428
Hans Verkuilba01f672015-03-07 13:57:27 -0300429
Hans Verkuil4db22042015-03-07 13:39:01 -0300430static inline unsigned tpg_g_line_width(const struct tpg_data *tpg, unsigned plane)
431{
432 unsigned w = 0;
433 unsigned p;
434
435 if (tpg->buffers > 1)
436 return tpg_g_bytesperline(tpg, plane);
Hans Verkuil02aa7692015-03-14 08:01:50 -0300437 for (p = 0; p < tpg_g_planes(tpg); p++) {
Hans Verkuil4db22042015-03-07 13:39:01 -0300438 unsigned plane_w = tpg_g_bytesperline(tpg, p);
439
Hans Verkuilba01f672015-03-07 13:57:27 -0300440 w += plane_w / tpg->vdownsampling[p];
Hans Verkuil4db22042015-03-07 13:39:01 -0300441 }
442 return w;
443}
444
445static inline unsigned tpg_calc_line_width(const struct tpg_data *tpg,
446 unsigned plane, unsigned bpl)
447{
448 unsigned w = 0;
449 unsigned p;
450
451 if (tpg->buffers > 1)
452 return bpl;
Hans Verkuil02aa7692015-03-14 08:01:50 -0300453 for (p = 0; p < tpg_g_planes(tpg); p++) {
Hans Verkuil4db22042015-03-07 13:39:01 -0300454 unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0];
455
Hans Verkuilba01f672015-03-07 13:57:27 -0300456 plane_w /= tpg->hdownsampling[p];
457 w += plane_w / tpg->vdownsampling[p];
Hans Verkuil4db22042015-03-07 13:39:01 -0300458 }
459 return w;
460}
461
462static inline unsigned tpg_calc_plane_size(const struct tpg_data *tpg, unsigned plane)
463{
Hans Verkuil02aa7692015-03-14 08:01:50 -0300464 if (plane >= tpg_g_planes(tpg))
Hans Verkuil4db22042015-03-07 13:39:01 -0300465 return 0;
466
Hans Verkuilba01f672015-03-07 13:57:27 -0300467 return tpg_g_bytesperline(tpg, plane) * tpg->buf_height /
468 tpg->vdownsampling[plane];
Hans Verkuil63881df2014-08-25 08:02:14 -0300469}
470
471static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h)
472{
473 tpg->buf_height = h;
474}
475
Hans Verkuil43047f62015-03-07 12:38:42 -0300476static inline void tpg_s_field(struct tpg_data *tpg, unsigned field, bool alternate)
Hans Verkuil63881df2014-08-25 08:02:14 -0300477{
478 tpg->field = field;
Hans Verkuil43047f62015-03-07 12:38:42 -0300479 tpg->field_alternate = alternate;
Hans Verkuil63881df2014-08-25 08:02:14 -0300480}
481
482static inline void tpg_s_perc_fill(struct tpg_data *tpg,
483 unsigned perc_fill)
484{
485 tpg->perc_fill = perc_fill;
486}
487
488static inline unsigned tpg_g_perc_fill(const struct tpg_data *tpg)
489{
490 return tpg->perc_fill;
491}
492
493static inline void tpg_s_perc_fill_blank(struct tpg_data *tpg,
494 bool perc_fill_blank)
495{
496 tpg->perc_fill_blank = perc_fill_blank;
497}
498
499static inline void tpg_s_video_aspect(struct tpg_data *tpg,
500 enum tpg_video_aspect vid_aspect)
501{
502 if (tpg->vid_aspect == vid_aspect)
503 return;
504 tpg->vid_aspect = vid_aspect;
505 tpg->recalc_square_border = true;
506}
507
508static inline enum tpg_video_aspect tpg_g_video_aspect(const struct tpg_data *tpg)
509{
510 return tpg->vid_aspect;
511}
512
513static inline void tpg_s_pixel_aspect(struct tpg_data *tpg,
514 enum tpg_pixel_aspect pix_aspect)
515{
516 if (tpg->pix_aspect == pix_aspect)
517 return;
518 tpg->pix_aspect = pix_aspect;
519 tpg->recalc_square_border = true;
520}
521
522static inline void tpg_s_show_border(struct tpg_data *tpg,
523 bool show_border)
524{
525 tpg->show_border = show_border;
526}
527
528static inline void tpg_s_show_square(struct tpg_data *tpg,
529 bool show_square)
530{
531 tpg->show_square = show_square;
532}
533
534static inline void tpg_s_insert_sav(struct tpg_data *tpg, bool insert_sav)
535{
536 tpg->insert_sav = insert_sav;
537}
538
539static inline void tpg_s_insert_eav(struct tpg_data *tpg, bool insert_eav)
540{
541 tpg->insert_eav = insert_eav;
542}
543
544void tpg_update_mv_step(struct tpg_data *tpg);
545
546static inline void tpg_s_mv_hor_mode(struct tpg_data *tpg,
547 enum tpg_move_mode mv_hor_mode)
548{
549 tpg->mv_hor_mode = mv_hor_mode;
550 tpg_update_mv_step(tpg);
551}
552
553static inline void tpg_s_mv_vert_mode(struct tpg_data *tpg,
554 enum tpg_move_mode mv_vert_mode)
555{
556 tpg->mv_vert_mode = mv_vert_mode;
557 tpg_update_mv_step(tpg);
558}
559
560static inline void tpg_init_mv_count(struct tpg_data *tpg)
561{
562 tpg->mv_hor_count = tpg->mv_vert_count = 0;
563}
564
565static inline void tpg_update_mv_count(struct tpg_data *tpg, bool frame_is_field)
566{
567 tpg->mv_hor_count += tpg->mv_hor_step * (frame_is_field ? 1 : 2);
568 tpg->mv_vert_count += tpg->mv_vert_step * (frame_is_field ? 1 : 2);
569}
570
571static inline void tpg_s_hflip(struct tpg_data *tpg, bool hflip)
572{
573 if (tpg->hflip == hflip)
574 return;
575 tpg->hflip = hflip;
576 tpg_update_mv_step(tpg);
577 tpg->recalc_lines = true;
578}
579
580static inline bool tpg_g_hflip(const struct tpg_data *tpg)
581{
582 return tpg->hflip;
583}
584
585static inline void tpg_s_vflip(struct tpg_data *tpg, bool vflip)
586{
587 tpg->vflip = vflip;
588}
589
590static inline bool tpg_g_vflip(const struct tpg_data *tpg)
591{
592 return tpg->vflip;
593}
594
595static inline bool tpg_pattern_is_static(const struct tpg_data *tpg)
596{
597 return tpg->pattern != TPG_PAT_NOISE &&
598 tpg->mv_hor_mode == TPG_MOVE_NONE &&
599 tpg->mv_vert_mode == TPG_MOVE_NONE;
600}
601
602#endif