aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/platform/hisi/isp/isp-sr.h
blob: aa5e23a259a81a706ac459b9fca7d194de184e95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2016-2018 Linaro Ltd.
 */

#ifndef HISI_ISP_SR_H
#define HISI_ISP_SR_H

#include <linux/clk.h>
#include <linux/interrupt.h>
#include <media/media-entity.h>
#include <media/v4l2-device.h>
#include <media/v4l2-mediabus.h>
#include <media/v4l2-subdev.h>

#define ISP_SR_PAD_SINK 0
#define ISP_SR_PAD_SRC 1
#define ISP_SR_PADS_NUM 1

#define STREAM_ROUTER_CSIFILTER_A_REG             0x0
#define STREAM_ROUTER_CSIFILTER_B_REG             0x4
#define STREAM_ROUTER_CSIFILTER_C_REG             0x8
#define STREAM_ROUTER_CSIFILTER_GO_REG            0xC
#define STREAM_ROUTER_PRESSURE_START_REG          0x10
#define STREAM_ROUTER_PRESSURE_STOP_REG           0x14
#define STREAM_ROUTER_ID_ROUTER_0_REG             0x18
#define STREAM_ROUTER_ID_ROUTER_1_REG             0x1C
#define STREAM_ROUTER_REFORMAT_0_REG              0x20
#define STREAM_ROUTER_REFORMAT_1_REG              0x28
#define STREAM_ROUTER_REFORMAT_2_REG              0x30
#define STREAM_ROUTER_REFORMAT_3_REG              0x38
#define STREAM_ROUTER_REFORMAT_4_REG              0x40
#define STREAM_ROUTER_REFORMAT_5_REG              0x48
#define STREAM_ROUTER_REFORMAT_6_REG              0x50
#define STREAM_ROUTER_REFORMAT_7_REG              0x58
#define STREAM_ROUTER_REFORMAT_MINSPACE_0_REG     0x24
#define STREAM_ROUTER_REFORMAT_MINSPACE_1_REG     0x2C
#define STREAM_ROUTER_REFORMAT_MINSPACE_2_REG     0x34
#define STREAM_ROUTER_REFORMAT_MINSPACE_3_REG     0x3C
#define STREAM_ROUTER_REFORMAT_MINSPACE_4_REG     0x44
#define STREAM_ROUTER_REFORMAT_MINSPACE_5_REG     0x4C
#define STREAM_ROUTER_REFORMAT_MINSPACE_6_REG     0x54
#define STREAM_ROUTER_REFORMAT_MINSPACE_7_REG     0x5C
#define STREAM_ROUTER_EOL_CNT_REG                 0x60
#define STREAM_ROUTER_DPCM_0_REG                  0x78
#define STREAM_ROUTER_DPCM_1_REG                  0x7C
#define STREAM_ROUTER_DPCM_2_REG                  0x80
#define STREAM_ROUTER_VP_ROUTER_0_REG             0x90
#define STREAM_ROUTER_VP_ROUTER_1_REG             0x94
#define STREAM_ROUTER_VP_ROUTER_2_REG             0x98
#define STREAM_ROUTER_VP_ROUTER_3_REG             0x9C
#define STREAM_ROUTER_PIXFRAG_CONVERT_REG         0xA0

/* Define the union U_ID_ROUTER_1 */
union U_ID_ROUTER_1 {
	/* Define the struct bits */
	struct {
		unsigned int    reserved_0            : 16  ; /* [15..0]  */
		unsigned int    idr_input_stream_6    : 4   ; /* [19..16]  */
		unsigned int    idr_enable_6          : 1   ; /* [20]  */
		unsigned int    reserved_1            : 3   ; /* [23..21]  */
		unsigned int    idr_input_stream_7    : 4   ; /* [27..24]  */
		unsigned int    idr_enable_7          : 1   ; /* [28]  */
		unsigned int    reserved_2            : 3   ; /* [31..29]  */
	} bits;

	/* Define an unsigned member */
	unsigned int    u32;

};

/* Define the union U_REFORMAT */
union U_REFORMAT {
	/* Define the struct bits */
	struct {
		unsigned int    reformat_num_lines    : 13  ; /* [12..0]  */
		unsigned int    reformat_pixel_reorder : 3   ; /* [15..13]  */
		unsigned int    reformat_num_pixels   : 13  ; /* [28..16]  */
		unsigned int    reserved_0            : 2   ; /* [30..29]  */
		unsigned int    reformat_enable       : 1   ; /* [31]  */
	} bits;

	/* Define an unsigned member */
	unsigned int    u32;
};

#define STREAM_ROUTER_REFORMAT_MINSPACE_REG(x)  \
	(STREAM_ROUTER_REFORMAT_MINSPACE_0_REG +\
		(x)*(STREAM_ROUTER_REFORMAT_MINSPACE_1_REG -\
		STREAM_ROUTER_REFORMAT_MINSPACE_0_REG))

#define STREAM_ROUTER_REFORMAT_REG(x)   \
	(STREAM_ROUTER_REFORMAT_0_REG +\
		(x)*(STREAM_ROUTER_REFORMAT_1_REG -\
		STREAM_ROUTER_REFORMAT_0_REG))

struct sr_device {
	struct isp *isp;
	struct v4l2_subdev subdev;
	struct media_pad pads[ISP_SR_PADS_NUM];
	void __iomem *base;
	unsigned int irq_frproc0;
};

int isp_sr_subdev_init(struct isp *isp,
			   struct sr_device *sr,
			   const struct resources *res);

int isp_sr_register_entity(struct sr_device *sr,
			       struct v4l2_device *v4l2_dev);

void isp_sr_unregister_entity(struct sr_device *sr);

#endif /* HISI_ISP_SR_H */