1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2013 Texas Instruments Inc.
4  *
5  * David Griego, <dagriego@biglakesoftware.com>
6  * Dale Farnsworth, <dale@farnsworth.org>
7  * Archit Taneja, <archit@ti.com>
8  */
9 #ifndef TI_CSC_H
10 #define TI_CSC_H
11 
12 /* VPE color space converter regs */
13 #define CSC_CSC00		0x00
14 #define CSC_A0_MASK		0x1fff
15 #define CSC_A0_SHIFT		0
16 #define CSC_B0_MASK		0x1fff
17 #define CSC_B0_SHIFT		16
18 
19 #define CSC_CSC01		0x04
20 #define CSC_C0_MASK		0x1fff
21 #define CSC_C0_SHIFT		0
22 #define CSC_A1_MASK		0x1fff
23 #define CSC_A1_SHIFT		16
24 
25 #define CSC_CSC02		0x08
26 #define CSC_B1_MASK		0x1fff
27 #define CSC_B1_SHIFT		0
28 #define CSC_C1_MASK		0x1fff
29 #define CSC_C1_SHIFT		16
30 
31 #define CSC_CSC03		0x0c
32 #define CSC_A2_MASK		0x1fff
33 #define CSC_A2_SHIFT		0
34 #define CSC_B2_MASK		0x1fff
35 #define CSC_B2_SHIFT		16
36 
37 #define CSC_CSC04		0x10
38 #define CSC_C2_MASK		0x1fff
39 #define CSC_C2_SHIFT		0
40 #define CSC_D0_MASK		0x0fff
41 #define CSC_D0_SHIFT		16
42 
43 #define CSC_CSC05		0x14
44 #define CSC_D1_MASK		0x0fff
45 #define CSC_D1_SHIFT		0
46 #define CSC_D2_MASK		0x0fff
47 #define CSC_D2_SHIFT		16
48 
49 #define CSC_BYPASS		(1 << 28)
50 
51 struct csc_data {
52 	void __iomem		*base;
53 	struct resource		*res;
54 
55 	struct platform_device	*pdev;
56 };
57 
58 void csc_dump_regs(struct csc_data *csc);
59 void csc_set_coeff_bypass(struct csc_data *csc, u32 *csc_reg5);
60 void csc_set_coeff(struct csc_data *csc, u32 *csc_reg0,
61 		   struct v4l2_format *src_fmt, struct v4l2_format *dst_fmt);
62 
63 struct csc_data *csc_create(struct platform_device *pdev, const char *res_name);
64 
65 #endif
66