summaryrefslogtreecommitdiff
path: root/include/linux/ipu-v3-pre.h
blob: f5a26e5eadbf5243f2bc06557fd9b5b478ec3f62 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * Copyright (C) 2014-2015 Freescale Semiconductor, Inc.
 *
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */
#ifndef __LINUX_IPU_V3_PRE_H_
#define __LINUX_IPU_V3_PRE_H_

#define IPU_PRE_MAX_WIDTH	1920
#define IPU_PRE_MAX_BPP		4
#define IPU_PRE_SMALL_LINE	9	/* to workaround errata ERR009624*/

struct ipu_rect {
	int left;
	int top;
	int width;
	int height;
};

struct ipu_pre_context {
	bool repeat;
	bool vflip;
	bool handshake_en;
	bool hsk_abort_en;
	unsigned int hsk_line_num;
	bool sdw_update;
	unsigned int block_size;
	unsigned int interlaced;
	unsigned int prefetch_mode;

	unsigned long cur_buf;
	unsigned long next_buf;

	unsigned int tile_fmt;

	unsigned int read_burst;
	unsigned int prefetch_input_bpp;
	unsigned int prefetch_input_pixel_fmt;
	unsigned int prefetch_shift_offset;
	unsigned int prefetch_shift_width;
	bool shift_bypass;
	bool field_inverse;
	bool tpr_coor_offset_en;
	/* the output of prefetch is
	 * also the input of store
	 */
	struct ipu_rect prefetch_output_size;
	unsigned int prefetch_input_active_width;
	unsigned int prefetch_input_width;
	unsigned int prefetch_input_height;
	unsigned int store_pitch;
	int interlace_offset;

	bool store_en;
	unsigned int write_burst;
	unsigned int store_output_bpp;

	unsigned int sec_buf_off;
	unsigned int trd_buf_off;

	/* return for IPU fb caller */
	unsigned long store_addr;
};

/*
 * In order to workaround the PRE SoC bug recorded by errata ERR009624,
 * the software cannot write the PRE_CTRL register when the PRE writes
 * the PRE_CTRL register automatically to set the ENABLE bit(bit0) to 1
 * in the PRE repeat mode.
 * The software mechanism to set the PRE_CTRL register is different for
 * PRE Y resolution higher than 9 lines and lower or equal to 9 lines.
 * Use this helper to check the Y resolution.
 */
static inline bool ipu_pre_yres_is_small(unsigned int yres)
{
	return yres <= IPU_PRE_SMALL_LINE;
}

#ifdef CONFIG_MXC_IPU_V3_PRE
int ipu_pre_alloc(int ipu_id, ipu_channel_t ipu_ch);
void ipu_pre_free(unsigned int *id);
unsigned long ipu_pre_alloc_double_buffer(unsigned int id, unsigned int size);
void ipu_pre_free_double_buffer(unsigned int id);
int ipu_pre_config(int id, struct ipu_pre_context *config);
int ipu_pre_set_ctrl(unsigned int id, struct ipu_pre_context *config);
int ipu_pre_enable(int id);
void ipu_pre_disable(int id);
int ipu_pre_set_fb_buffer(int id, bool resolve,
			  unsigned long fb_paddr,
			  unsigned int y_res,
			  unsigned int x_crop,
			  unsigned int y_crop,
			  unsigned int sec_buf_off,
			  unsigned int trd_buf_off);
int ipu_pre_sdw_update(int id);
#else
int ipu_pre_alloc(int ipu_id, ipu_channel_t channel)
{
	return -ENODEV;
}

void ipu_pre_free(unsigned int *id)
{
}

unsigned long ipu_pre_alloc_double_buffer(unsigned int id, unsigned int size)
{
	return -ENODEV;
}

void ipu_pre_free_double_buffer(unsigned int id)
{
}

int ipu_pre_config(int id, struct ipu_pre_context *config)
{
	return -ENODEV;
}

int ipu_pre_set_ctrl(unsigned int id, struct ipu_pre_context *config)
{
	return -ENODEV;
}

int ipu_pre_enable(int id)
{
	return -ENODEV;
}

void ipu_pre_disable(int id)
{
	return;
}

int ipu_pre_set_fb_buffer(int id, bool resolve,
			  unsigned long fb_paddr,
			  unsigned int y_res,
			  unsigned int x_crop,
			  unsigned int y_crop,
			  unsigned int sec_buf_off,
			  unsigned int trd_buf_off)
{
	return -ENODEV;
}
int ipu_pre_sdw_update(int id)
{
	return -ENODEV;
}
#endif
#endif /* __LINUX_IPU_V3_PRE_H_ */