^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * v4l2-tpg.h - Test Pattern Generator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright 2014 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _V4L2_TPG_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _V4L2_TPG_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/random.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct tpg_rbg_color8 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) unsigned char r, g, b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct tpg_rbg_color16 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) __u16 r, g, b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) enum tpg_color {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) TPG_COLOR_CSC_WHITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) TPG_COLOR_CSC_YELLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) TPG_COLOR_CSC_CYAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) TPG_COLOR_CSC_GREEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) TPG_COLOR_CSC_MAGENTA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) TPG_COLOR_CSC_RED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) TPG_COLOR_CSC_BLUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) TPG_COLOR_CSC_BLACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) TPG_COLOR_75_YELLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) TPG_COLOR_75_CYAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) TPG_COLOR_75_GREEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) TPG_COLOR_75_MAGENTA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) TPG_COLOR_75_RED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) TPG_COLOR_75_BLUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) TPG_COLOR_100_WHITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) TPG_COLOR_100_YELLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) TPG_COLOR_100_CYAN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) TPG_COLOR_100_GREEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) TPG_COLOR_100_MAGENTA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) TPG_COLOR_100_RED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) TPG_COLOR_100_BLUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) TPG_COLOR_100_BLACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) TPG_COLOR_TEXTFG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) TPG_COLOR_TEXTBG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) TPG_COLOR_RANDOM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) TPG_COLOR_RAMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) TPG_COLOR_MAX = TPG_COLOR_RAMP + 256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) extern const struct tpg_rbg_color8 tpg_colors[TPG_COLOR_MAX];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) extern const unsigned short tpg_rec709_to_linear[255 * 16 + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) extern const unsigned short tpg_linear_to_rec709[255 * 16 + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) extern const struct tpg_rbg_color16 tpg_csc_colors[V4L2_COLORSPACE_DCI_P3 + 1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) [V4L2_XFER_FUNC_SMPTE2084 + 1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) [TPG_COLOR_CSC_BLACK + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) enum tpg_pattern {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) TPG_PAT_75_COLORBAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) TPG_PAT_100_COLORBAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) TPG_PAT_CSC_COLORBAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) TPG_PAT_100_HCOLORBAR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) TPG_PAT_100_COLORSQUARES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) TPG_PAT_BLACK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) TPG_PAT_WHITE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) TPG_PAT_RED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) TPG_PAT_GREEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) TPG_PAT_BLUE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) TPG_PAT_CHECKERS_16X16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) TPG_PAT_CHECKERS_2X2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) TPG_PAT_CHECKERS_1X1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) TPG_PAT_COLOR_CHECKERS_2X2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) TPG_PAT_COLOR_CHECKERS_1X1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) TPG_PAT_ALTERNATING_HLINES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) TPG_PAT_ALTERNATING_VLINES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) TPG_PAT_CROSS_1_PIXEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) TPG_PAT_CROSS_2_PIXELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) TPG_PAT_CROSS_10_PIXELS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) TPG_PAT_GRAY_RAMP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /* Must be the last pattern */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) TPG_PAT_NOISE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern const char * const tpg_pattern_strings[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) enum tpg_quality {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) TPG_QUAL_COLOR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) TPG_QUAL_GRAY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) TPG_QUAL_NOISE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) enum tpg_video_aspect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) TPG_VIDEO_ASPECT_IMAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) TPG_VIDEO_ASPECT_4X3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) TPG_VIDEO_ASPECT_14X9_CENTRE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) TPG_VIDEO_ASPECT_16X9_CENTRE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) TPG_VIDEO_ASPECT_16X9_ANAMORPHIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) enum tpg_pixel_aspect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) TPG_PIXEL_ASPECT_SQUARE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) TPG_PIXEL_ASPECT_NTSC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) TPG_PIXEL_ASPECT_PAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) enum tpg_move_mode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) TPG_MOVE_NEG_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) TPG_MOVE_NEG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) TPG_MOVE_NEG_SLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) TPG_MOVE_NONE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) TPG_MOVE_POS_SLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) TPG_MOVE_POS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) TPG_MOVE_POS_FAST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) enum tgp_color_enc {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) TGP_COLOR_ENC_RGB,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) TGP_COLOR_ENC_YCBCR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) TGP_COLOR_ENC_HSV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) TGP_COLOR_ENC_LUMA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) extern const char * const tpg_aspect_strings[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define TPG_MAX_PLANES 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) #define TPG_MAX_PAT_LINES 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct tpg_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* Source frame size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) unsigned src_width, src_height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /* Buffer height */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) unsigned buf_height;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /* Scaled output frame size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) unsigned scaled_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) u32 field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) bool field_alternate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* crop coordinates are frame-based */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct v4l2_rect crop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* compose coordinates are format-based */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct v4l2_rect compose;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* border and square coordinates are frame-based */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct v4l2_rect border;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct v4l2_rect square;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* Color-related fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) enum tpg_quality qual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) unsigned qual_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) u8 alpha_component;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) bool alpha_red_only;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) u8 brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) u8 contrast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) u8 saturation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) s16 hue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) u32 fourcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) enum tgp_color_enc color_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) u32 colorspace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) u32 xfer_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) u32 ycbcr_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) u32 hsv_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * Stores the actual transfer function, i.e. will never be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * V4L2_XFER_FUNC_DEFAULT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) u32 real_xfer_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * Stores the actual Y'CbCr encoding, i.e. will never be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * V4L2_YCBCR_ENC_DEFAULT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) u32 real_hsv_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) u32 real_ycbcr_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) u32 quantization;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * Stores the actual quantization, i.e. will never be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * V4L2_QUANTIZATION_DEFAULT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) u32 real_quantization;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) enum tpg_video_aspect vid_aspect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) enum tpg_pixel_aspect pix_aspect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) unsigned rgb_range;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) unsigned real_rgb_range;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) unsigned buffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) unsigned planes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) bool interleaved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u8 vdownsampling[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) u8 hdownsampling[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * horizontal positions must be ANDed with this value to enforce
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * correct boundaries for packed YUYV values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) unsigned hmask[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /* Used to store the colors in native format, either RGB or YUV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) u8 colors[TPG_COLOR_MAX][3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) u8 textfg[TPG_MAX_PLANES][8], textbg[TPG_MAX_PLANES][8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /* size in bytes for two pixels in each plane */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) unsigned twopixelsize[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) unsigned bytesperline[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) /* Configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) enum tpg_pattern pattern;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) bool hflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) bool vflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) unsigned perc_fill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) bool perc_fill_blank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) bool show_border;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) bool show_square;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) bool insert_sav;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) bool insert_eav;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) /* Test pattern movement */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) enum tpg_move_mode mv_hor_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) int mv_hor_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int mv_hor_step;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) enum tpg_move_mode mv_vert_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int mv_vert_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) int mv_vert_step;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) bool recalc_colors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) bool recalc_lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) bool recalc_square_border;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) /* Used to store TPG_MAX_PAT_LINES lines, each with up to two planes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) unsigned max_line_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) u8 *lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) u8 *downsampled_lines[TPG_MAX_PAT_LINES][TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) u8 *random_line[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) u8 *contrast_line[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) u8 *black_line[TPG_MAX_PLANES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) void tpg_init(struct tpg_data *tpg, unsigned w, unsigned h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) int tpg_alloc(struct tpg_data *tpg, unsigned max_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) void tpg_free(struct tpg_data *tpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) void tpg_reset_source(struct tpg_data *tpg, unsigned width, unsigned height,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) u32 field);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) void tpg_log_status(struct tpg_data *tpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) void tpg_set_font(const u8 *f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) void tpg_gen_text(const struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) u8 *basep[TPG_MAX_PLANES][2], int y, int x, const char *text);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) void tpg_calc_text_basep(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) u8 *basep[TPG_MAX_PLANES][2], unsigned p, u8 *vbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) unsigned tpg_g_interleaved_plane(const struct tpg_data *tpg, unsigned buf_line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) unsigned p, u8 *vbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) unsigned p, u8 *vbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) const struct v4l2_rect *compose);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) const char *tpg_g_color_order(const struct tpg_data *tpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) if (tpg->pattern == pattern)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) tpg->pattern = pattern;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static inline void tpg_s_quality(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) enum tpg_quality qual, unsigned qual_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) if (tpg->qual == qual && tpg->qual_offset == qual_offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) tpg->qual = qual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) tpg->qual_offset = qual_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) static inline enum tpg_quality tpg_g_quality(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) return tpg->qual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static inline void tpg_s_alpha_component(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) u8 alpha_component)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (tpg->alpha_component == alpha_component)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) tpg->alpha_component = alpha_component;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) static inline void tpg_s_alpha_mode(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) bool red_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) if (tpg->alpha_red_only == red_only)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) tpg->alpha_red_only = red_only;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) static inline void tpg_s_brightness(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) u8 brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (tpg->brightness == brightness)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) tpg->brightness = brightness;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) static inline void tpg_s_contrast(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) u8 contrast)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) if (tpg->contrast == contrast)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) tpg->contrast = contrast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) static inline void tpg_s_saturation(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) u8 saturation)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (tpg->saturation == saturation)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) tpg->saturation = saturation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) static inline void tpg_s_hue(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) s16 hue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) hue = clamp_t(s16, hue, -128, 128);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) if (tpg->hue == hue)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) tpg->hue = hue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static inline void tpg_s_rgb_range(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) unsigned rgb_range)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) if (tpg->rgb_range == rgb_range)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) tpg->rgb_range = rgb_range;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) static inline void tpg_s_real_rgb_range(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) unsigned rgb_range)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) if (tpg->real_rgb_range == rgb_range)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) tpg->real_rgb_range = rgb_range;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) static inline void tpg_s_colorspace(struct tpg_data *tpg, u32 colorspace)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (tpg->colorspace == colorspace)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) tpg->colorspace = colorspace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) static inline u32 tpg_g_colorspace(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) return tpg->colorspace;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) static inline void tpg_s_ycbcr_enc(struct tpg_data *tpg, u32 ycbcr_enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if (tpg->ycbcr_enc == ycbcr_enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) tpg->ycbcr_enc = ycbcr_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) static inline u32 tpg_g_ycbcr_enc(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) return tpg->ycbcr_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) static inline void tpg_s_hsv_enc(struct tpg_data *tpg, u32 hsv_enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) if (tpg->hsv_enc == hsv_enc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) tpg->hsv_enc = hsv_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) static inline u32 tpg_g_hsv_enc(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) return tpg->hsv_enc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) static inline void tpg_s_xfer_func(struct tpg_data *tpg, u32 xfer_func)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) if (tpg->xfer_func == xfer_func)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) tpg->xfer_func = xfer_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) static inline u32 tpg_g_xfer_func(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) return tpg->xfer_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) static inline void tpg_s_quantization(struct tpg_data *tpg, u32 quantization)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) if (tpg->quantization == quantization)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) tpg->quantization = quantization;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) tpg->recalc_colors = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static inline u32 tpg_g_quantization(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return tpg->quantization;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) static inline unsigned tpg_g_buffers(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) return tpg->buffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) static inline unsigned tpg_g_planes(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) return tpg->interleaved ? 1 : tpg->planes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static inline bool tpg_g_interleaved(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) return tpg->interleaved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static inline unsigned tpg_g_twopixelsize(const struct tpg_data *tpg, unsigned plane)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) return tpg->twopixelsize[plane];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) static inline unsigned tpg_hdiv(const struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) unsigned plane, unsigned x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) return ((x / tpg->hdownsampling[plane]) & tpg->hmask[plane]) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) tpg->twopixelsize[plane] / 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) static inline unsigned tpg_hscale(const struct tpg_data *tpg, unsigned x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) return (x * tpg->scaled_width) / tpg->src_width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) static inline unsigned tpg_hscale_div(const struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) unsigned plane, unsigned x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) return tpg_hdiv(tpg, plane, tpg_hscale(tpg, x));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) static inline unsigned tpg_g_bytesperline(const struct tpg_data *tpg, unsigned plane)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) return tpg->bytesperline[plane];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) static inline void tpg_s_bytesperline(struct tpg_data *tpg, unsigned plane, unsigned bpl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) unsigned p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) if (tpg->buffers > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) tpg->bytesperline[plane] = bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) for (p = 0; p < tpg_g_planes(tpg); p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) tpg->bytesperline[p] = plane_w / tpg->hdownsampling[p];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (tpg_g_interleaved(tpg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) tpg->bytesperline[1] = tpg->bytesperline[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) static inline unsigned tpg_g_line_width(const struct tpg_data *tpg, unsigned plane)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) unsigned w = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) unsigned p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (tpg->buffers > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) return tpg_g_bytesperline(tpg, plane);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) for (p = 0; p < tpg_g_planes(tpg); p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) unsigned plane_w = tpg_g_bytesperline(tpg, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) w += plane_w / tpg->vdownsampling[p];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) return w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) static inline unsigned tpg_calc_line_width(const struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) unsigned plane, unsigned bpl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) unsigned w = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) unsigned p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) if (tpg->buffers > 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) return bpl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) for (p = 0; p < tpg_g_planes(tpg); p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) unsigned plane_w = bpl * tpg->twopixelsize[p] / tpg->twopixelsize[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) plane_w /= tpg->hdownsampling[p];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) w += plane_w / tpg->vdownsampling[p];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) return w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) static inline unsigned tpg_calc_plane_size(const struct tpg_data *tpg, unsigned plane)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) if (plane >= tpg_g_planes(tpg))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) return tpg_g_bytesperline(tpg, plane) * tpg->buf_height /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) tpg->vdownsampling[plane];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) static inline void tpg_s_buf_height(struct tpg_data *tpg, unsigned h)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) tpg->buf_height = h;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) static inline void tpg_s_field(struct tpg_data *tpg, unsigned field, bool alternate)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) tpg->field = field;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) tpg->field_alternate = alternate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) static inline void tpg_s_perc_fill(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) unsigned perc_fill)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) tpg->perc_fill = perc_fill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) static inline unsigned tpg_g_perc_fill(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) return tpg->perc_fill;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) static inline void tpg_s_perc_fill_blank(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) bool perc_fill_blank)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) tpg->perc_fill_blank = perc_fill_blank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) static inline void tpg_s_video_aspect(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) enum tpg_video_aspect vid_aspect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) if (tpg->vid_aspect == vid_aspect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) tpg->vid_aspect = vid_aspect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) tpg->recalc_square_border = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) static inline enum tpg_video_aspect tpg_g_video_aspect(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) return tpg->vid_aspect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) static inline void tpg_s_pixel_aspect(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) enum tpg_pixel_aspect pix_aspect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) if (tpg->pix_aspect == pix_aspect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) tpg->pix_aspect = pix_aspect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) tpg->recalc_square_border = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) static inline void tpg_s_show_border(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) bool show_border)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) tpg->show_border = show_border;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) static inline void tpg_s_show_square(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) bool show_square)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) tpg->show_square = show_square;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) static inline void tpg_s_insert_sav(struct tpg_data *tpg, bool insert_sav)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) tpg->insert_sav = insert_sav;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) static inline void tpg_s_insert_eav(struct tpg_data *tpg, bool insert_eav)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) tpg->insert_eav = insert_eav;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) void tpg_update_mv_step(struct tpg_data *tpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) static inline void tpg_s_mv_hor_mode(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) enum tpg_move_mode mv_hor_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) tpg->mv_hor_mode = mv_hor_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) tpg_update_mv_step(tpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) static inline void tpg_s_mv_vert_mode(struct tpg_data *tpg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) enum tpg_move_mode mv_vert_mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) tpg->mv_vert_mode = mv_vert_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) tpg_update_mv_step(tpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) static inline void tpg_init_mv_count(struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) tpg->mv_hor_count = tpg->mv_vert_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) static inline void tpg_update_mv_count(struct tpg_data *tpg, bool frame_is_field)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) tpg->mv_hor_count += tpg->mv_hor_step * (frame_is_field ? 1 : 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) tpg->mv_vert_count += tpg->mv_vert_step * (frame_is_field ? 1 : 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) static inline void tpg_s_hflip(struct tpg_data *tpg, bool hflip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) if (tpg->hflip == hflip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) tpg->hflip = hflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) tpg_update_mv_step(tpg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) tpg->recalc_lines = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static inline bool tpg_g_hflip(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) return tpg->hflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) static inline void tpg_s_vflip(struct tpg_data *tpg, bool vflip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) tpg->vflip = vflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) static inline bool tpg_g_vflip(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) return tpg->vflip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) static inline bool tpg_pattern_is_static(const struct tpg_data *tpg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) return tpg->pattern != TPG_PAT_NOISE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) tpg->mv_hor_mode == TPG_MOVE_NONE &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) tpg->mv_vert_mode == TPG_MOVE_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) #endif