1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #ifndef __IA_CSS_TPG_H
17 #define __IA_CSS_TPG_H
18 
19 /* @file
20  * This file contains support for the test pattern generator (TPG)
21  */
22 
23 /* Enumerate the TPG IDs.
24  */
25 enum ia_css_tpg_id {
26 	IA_CSS_TPG_ID0,
27 	IA_CSS_TPG_ID1,
28 	IA_CSS_TPG_ID2
29 };
30 
31 /**
32  * Maximum number of TPG IDs.
33  *
34  * Make sure the value of this define gets changed to reflect the correct
35  * number of ia_css_tpg_id enum if you add/delete an item in the enum.
36  */
37 #define N_CSS_TPG_IDS (IA_CSS_TPG_ID2 + 1)
38 
39 /* Enumerate the TPG modes.
40  */
41 enum ia_css_tpg_mode {
42 	IA_CSS_TPG_MODE_RAMP,
43 	IA_CSS_TPG_MODE_CHECKERBOARD,
44 	IA_CSS_TPG_MODE_FRAME_BASED_COLOR,
45 	IA_CSS_TPG_MODE_MONO
46 };
47 
48 /* @brief Configure the test pattern generator.
49  *
50  * Configure the Test Pattern Generator, the way these values are used to
51  * generate the pattern can be seen in the HRT extension for the test pattern
52  * generator:
53  * devices/test_pat_gen/hrt/include/test_pat_gen.h: hrt_calc_tpg_data().
54  *
55  * This interface is deprecated, it is not portable -> move to input system API
56  *
57 @code
58 unsigned int test_pattern_value(unsigned int x, unsigned int y)
59 {
60  unsigned int x_val, y_val;
61  if (x_delta > 0) (x_val = (x << x_delta) & x_mask;
62  else (x_val = (x >> -x_delta) & x_mask;
63  if (y_delta > 0) (y_val = (y << y_delta) & y_mask;
64  else (y_val = (y >> -y_delta) & x_mask;
65  return (x_val + y_val) & xy_mask;
66 }
67 @endcode
68  */
69 struct ia_css_tpg_config {
70 	enum ia_css_tpg_id   id;
71 	enum ia_css_tpg_mode mode;
72 	unsigned int         x_mask;
73 	int                  x_delta;
74 	unsigned int         y_mask;
75 	int                  y_delta;
76 	unsigned int         xy_mask;
77 };
78 
79 #endif /* __IA_CSS_TPG_H */
80