aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/media/davinci_vpfe/dm365_isif.h
blob: 89e814e9c0d7e73a870312972461e9babf7dff77 (plain) (blame)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
 * Copyright (C) 2012 Texas Instruments Inc
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation version 2.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 * Contributors:
 *      Manjunath Hadli <manjunath.hadli@ti.com>
 *      Prabhakar Lad <prabhakar.lad@ti.com>
 */

#ifndef _DAVINCI_VPFE_DM365_ISIF_H
#define _DAVINCI_VPFE_DM365_ISIF_H

#include <linux/platform_device.h>

#include <mach/mux.h>

#include <media/davinci/vpfe_types.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-device.h>

#include "davinci_vpfe_user.h"
#include "dm365_isif_regs.h"
#include "vpfe_video.h"

#define ISIF_CULLING_HCAPT_ODD		0xff
#define ISIF_CULLING_HCAPT_EVEN		0xff
#define ISIF_CULLING_VCAPT		0xff

#define ISIF_CADU_BITS			0x07ff
#define ISIF_CADL_BITS			0x0ffff

enum isif_pixfmt {
	ISIF_PIXFMT_RAW = 0,
	ISIF_PIXFMT_YCBCR_16BIT = 1,
	ISIF_PIXFMT_YCBCR_8BIT = 2,
};

enum isif_frmfmt {
	ISIF_FRMFMT_PROGRESSIVE = 0,
	ISIF_FRMFMT_INTERLACED = 1,
};

/* PIXEL ORDER IN MEMORY from LSB to MSB */
/* only applicable for 8-bit input mode  */
enum isif_pixorder {
	ISIF_PIXORDER_YCBYCR = 0,
	ISIF_PIXORDER_CBYCRY = 1,
};

enum isif_buftype {
	ISIF_BUFTYPE_FLD_INTERLEAVED = 0,
	ISIF_BUFTYPE_FLD_SEPARATED = 1,
};

struct isif_ycbcr_config {
	/* v4l2 pixel format */
	unsigned long v4l2_pix_fmt;
	/* isif pixel format */
	enum isif_pixfmt pix_fmt;
	/* isif frame format */
	enum isif_frmfmt frm_fmt;
	/* isif crop window */
	struct v4l2_rect win;
	/* field polarity */
	enum vpfe_pin_pol fid_pol;
	/* interface VD polarity */
	enum vpfe_pin_pol vd_pol;
	/* interface HD polarity */
	enum vpfe_pin_pol hd_pol;
	/* isif pix order. Only used for ycbcr capture */
	enum isif_pixorder pix_order;
	/* isif buffer type. Only used for ycbcr capture */
	enum isif_buftype buf_type;
};

enum isif_cfa_pattern {
	ISIF_CFA_PAT_MOSAIC = 0,
	ISIF_CFA_PAT_STRIPE = 1,
};

enum isif_data_msb {
	/* MSB b15 */
	ISIF_BIT_MSB_15 = 0,
	/* MSB b14 */
	ISIF_BIT_MSB_14 = 1,
	/* MSB b13 */
	ISIF_BIT_MSB_13 = 2,
	/* MSB b12 */
	ISIF_BIT_MSB_12 = 3,
	/* MSB b11 */
	ISIF_BIT_MSB_11 = 4,
	/* MSB b10 */
	ISIF_BIT_MSB_10 = 5,
	/* MSB b9 */
	ISIF_BIT_MSB_9 = 6,
	/* MSB b8 */
	ISIF_BIT_MSB_8 = 7,
	/* MSB b7 */
	ISIF_BIT_MSB_7 = 8,
};

struct isif_params_raw {
	/* v4l2 pixel format */
	unsigned long v4l2_pix_fmt;
	/* isif pixel format */
	enum isif_pixfmt pix_fmt;
	/* isif frame format */
	enum isif_frmfmt frm_fmt;
	/* video window */
	struct v4l2_rect win;
	/* field polarity */
	enum vpfe_pin_pol fid_pol;
	/* interface VD polarity */
	enum vpfe_pin_pol vd_pol;
	/* interface HD polarity */
	enum vpfe_pin_pol hd_pol;
	/* buffer type. Applicable for interlaced mode */
	enum isif_buftype buf_type;
	/* cfa pattern */
	enum isif_cfa_pattern cfa_pat;
	/* Data MSB position */
	enum isif_data_msb data_msb;
	/* Enable horizontal flip */
	unsigned char horz_flip_en;
	/* Enable image invert vertically */
	unsigned char image_invert_en;
	unsigned char dpcm_predictor;
	struct vpfe_isif_raw_config config_params;
};

enum isif_data_pack {
	ISIF_PACK_16BIT = 0,
	ISIF_PACK_12BIT = 1,
	ISIF_PACK_8BIT = 2,
};

struct isif_gain_values {
	unsigned int cr_gain;
	unsigned int cgr_gain;
	unsigned int cgb_gain;
	unsigned int cb_gain;
	unsigned int offset;
};

struct isif_oper_config {
	struct isif_ycbcr_config ycbcr;
	struct isif_params_raw bayer;
	enum isif_data_pack data_pack;
	struct isif_gain_values isif_gain_params;
	void __iomem *base_addr;
	void __iomem *linear_tbl0_addr;
	void __iomem *linear_tbl1_addr;
};

#define ISIF_PAD_SINK      0
#define ISIF_PAD_SOURCE    1

#define ISIF_PADS_NUM      2

enum isif_input_entity {
	ISIF_INPUT_NONE = 0,
	ISIF_INPUT_PARALLEL = 1,
};

#define ISIF_OUTPUT_NONE	(0)
#define ISIF_OUTPUT_MEMORY	(1 << 0)
#define ISIF_OUTPUT_IPIPEIF	(1 << 1)

struct vpfe_isif_device {
	struct v4l2_subdev		subdev;
	struct media_pad		pads[ISIF_PADS_NUM];
	struct v4l2_mbus_framefmt	formats[ISIF_PADS_NUM];
	enum isif_input_entity		input;
	unsigned int			output;
	struct v4l2_ctrl_handler        ctrls;
	struct v4l2_rect		crop;
	struct isif_oper_config		isif_cfg;
	struct vpfe_video_device	video_out;
};

enum v4l2_field vpfe_isif_get_fid(struct vpfe_device *vpfe_dev);
void vpfe_isif_unregister_entities(struct vpfe_isif_device *isif);
int vpfe_isif_register_entities(struct vpfe_isif_device *isif,
				struct v4l2_device *dev);
int vpfe_isif_init(struct vpfe_isif_device *isif, struct platform_device *pdev);
void vpfe_isif_cleanup(struct vpfe_isif_device *vpfe_isif,
		       struct platform_device *pdev);
void vpfe_isif_vidint1_isr(struct vpfe_isif_device *isif);
void vpfe_isif_buffer_isr(struct vpfe_isif_device *isif);

#endif		/* _DAVINCI_VPFE_DM365_ISIF_H */