blob: 8ae29b4ede8bf26d332fa2270087395c19dc9e84 [file] [log] [blame]
Lily Zhang824e4de2009-11-01 11:14:53 +08001/*
2 * Copyright (C) 2010-2011 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 */
19#ifndef _PXP_DMA
20#define _PXP_DMA
21
22#include <linux/types.h>
23
24#ifndef __KERNEL__
25typedef unsigned long dma_addr_t;
26typedef unsigned char bool;
27#endif
28
29/* PXP Pixel format definitions */
30/* Four-character-code (FOURCC) */
31#define fourcc(a, b, c, d)\
32 (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
33
34/*!
35 * @name PXP Pixel Formats
36 *
37 * Pixel formats are defined with ASCII FOURCC code. The pixel format codes are
38 * the same used by V4L2 API.
39 */
40
41/*! @} */
42/*! @name RGB Formats */
43/*! @{ */
44#define PXP_PIX_FMT_RGB332 fourcc('R', 'G', 'B', '1') /*!< 8 RGB-3-3-2 */
45#define PXP_PIX_FMT_RGB555 fourcc('R', 'G', 'B', 'O') /*!< 16 RGB-5-5-5 */
46#define PXP_PIX_FMT_RGB565 fourcc('R', 'G', 'B', 'P') /*!< 1 6 RGB-5-6-5 */
47#define PXP_PIX_FMT_RGB666 fourcc('R', 'G', 'B', '6') /*!< 18 RGB-6-6-6 */
48#define PXP_PIX_FMT_BGR666 fourcc('B', 'G', 'R', '6') /*!< 18 BGR-6-6-6 */
49#define PXP_PIX_FMT_BGR24 fourcc('B', 'G', 'R', '3') /*!< 24 BGR-8-8-8 */
50#define PXP_PIX_FMT_RGB24 fourcc('R', 'G', 'B', '3') /*!< 24 RGB-8-8-8 */
51#define PXP_PIX_FMT_BGR32 fourcc('B', 'G', 'R', '4') /*!< 32 BGR-8-8-8-8 */
52#define PXP_PIX_FMT_BGRA32 fourcc('B', 'G', 'R', 'A') /*!< 32 BGR-8-8-8-8 */
53#define PXP_PIX_FMT_RGB32 fourcc('R', 'G', 'B', '4') /*!< 32 RGB-8-8-8-8 */
54#define PXP_PIX_FMT_RGBA32 fourcc('R', 'G', 'B', 'A') /*!< 32 RGB-8-8-8-8 */
55#define PXP_PIX_FMT_ABGR32 fourcc('A', 'B', 'G', 'R') /*!< 32 ABGR-8-8-8-8 */
56/*! @} */
57/*! @name YUV Interleaved Formats */
58/*! @{ */
59#define PXP_PIX_FMT_YUYV fourcc('Y', 'U', 'Y', 'V') /*!< 16 YUV 4:2:2 */
60#define PXP_PIX_FMT_UYVY fourcc('U', 'Y', 'V', 'Y') /*!< 16 YUV 4:2:2 */
61#define PXP_PIX_FMT_Y41P fourcc('Y', '4', '1', 'P') /*!< 12 YUV 4:1:1 */
62#define PXP_PIX_FMT_YUV444 fourcc('Y', '4', '4', '4') /*!< 24 YUV 4:4:4 */
63/* two planes -- one Y, one Cb + Cr interleaved */
64#define PXP_PIX_FMT_NV12 fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
65/*! @} */
66/*! @name YUV Planar Formats */
67/*! @{ */
68#define PXP_PIX_FMT_GREY fourcc('G', 'R', 'E', 'Y') /*!< 8 Greyscale */
69#define PXP_PIX_FMT_YVU410P fourcc('Y', 'V', 'U', '9') /*!< 9 YVU 4:1:0 */
70#define PXP_PIX_FMT_YUV410P fourcc('Y', 'U', 'V', '9') /*!< 9 YUV 4:1:0 */
71#define PXP_PIX_FMT_YVU420P fourcc('Y', 'V', '1', '2') /*!< 12 YVU 4:2:0 */
72#define PXP_PIX_FMT_YUV420P fourcc('I', '4', '2', '0') /*!< 12 YUV 4:2:0 */
73#define PXP_PIX_FMT_YUV420P2 fourcc('Y', 'U', '1', '2') /*!< 12 YUV 4:2:0 */
74#define PXP_PIX_FMT_YVU422P fourcc('Y', 'V', '1', '6') /*!< 16 YVU 4:2:2 */
75#define PXP_PIX_FMT_YUV422P fourcc('4', '2', '2', 'P') /*!< 16 YUV 4:2:2 */
76/*! @} */
77
78#define PXP_LUT_NONE 0x0
79#define PXP_LUT_INVERT 0x1
80#define PXP_LUT_BLACK_WHITE 0x2
Danny Nold1e80a2f2011-08-11 20:07:59 -050081#define PXP_LUT_USE_CMAP 0x4
Lily Zhang824e4de2009-11-01 11:14:53 +080082
83#define NR_PXP_VIRT_CHANNEL 16
84
85#define PXP_IOC_MAGIC 'P'
86
87#define PXP_IOC_GET_CHAN _IOR(PXP_IOC_MAGIC, 0, struct pxp_mem_desc)
88#define PXP_IOC_PUT_CHAN _IOW(PXP_IOC_MAGIC, 1, struct pxp_mem_desc)
89#define PXP_IOC_CONFIG_CHAN _IOW(PXP_IOC_MAGIC, 2, struct pxp_mem_desc)
90#define PXP_IOC_START_CHAN _IOW(PXP_IOC_MAGIC, 3, struct pxp_mem_desc)
91#define PXP_IOC_GET_PHYMEM _IOWR(PXP_IOC_MAGIC, 4, struct pxp_mem_desc)
92#define PXP_IOC_PUT_PHYMEM _IOW(PXP_IOC_MAGIC, 5, struct pxp_mem_desc)
93#define PXP_IOC_WAIT4CMPLT _IOWR(PXP_IOC_MAGIC, 6, struct pxp_mem_desc)
94
95/* Order significant! */
96enum pxp_channel_status {
97 PXP_CHANNEL_FREE,
98 PXP_CHANNEL_INITIALIZED,
99 PXP_CHANNEL_READY,
100};
101
102struct rect {
103 int top; /* Upper left coordinate of rectangle */
104 int left;
105 int width;
106 int height;
107};
108
109struct pxp_layer_param {
110 unsigned short width;
111 unsigned short height;
112 unsigned int pixel_fmt;
113
114 /* layers combining parameters
115 * (these are ignored for S0 and output
116 * layers, and only apply for OL layer)
117 */
118 bool combine_enable;
119 __u32 color_key_enable;
120 __u32 color_key;
121 bool global_alpha_enable;
122 __u8 global_alpha;
123 bool local_alpha_enable;
124
125 dma_addr_t paddr;
126};
127
128struct pxp_proc_data {
129 /* S0 Transformation Info */
130 int scaling;
131 int hflip;
132 int vflip;
133 int rotate;
134 int yuv;
135
136 /* Source rectangle (srect) defines the sub-rectangle
137 * within S0 to undergo processing.
138 */
139 struct rect srect;
140 /* Dest rect (drect) defines how to position the processed
141 * source rectangle (after resizing) within the output frame,
142 * whose dimensions are defined in pxp->pxp_conf_state.out_param
143 */
144 struct rect drect;
145
146 /* Current S0 configuration */
147 __u32 bgcolor;
148
149 /* Output overlay support */
150 int overlay_state;
151
152 /* LUT transformation on Y data */
153 int lut_transform;
Danny Nold91b51af2011-09-16 11:53:34 -0500154 __u8 *lut_map; /* 256 entries */
Danny Nold1e80a2f2011-08-11 20:07:59 -0500155 bool lut_map_updated; /* Map recently changed */
Lily Zhang824e4de2009-11-01 11:14:53 +0800156};
157
158struct pxp_config_data {
159 struct pxp_layer_param s0_param;
160 struct pxp_layer_param ol_param[8];
161 struct pxp_layer_param out_param;
162 struct pxp_proc_data proc_data;
163 int layer_nr;
164
165 /* Users don't touch */
166 int chan_id;
167};
168
169struct pxp_mem_desc {
170 __u32 size;
171 dma_addr_t phys_addr;
172 __u32 cpu_addr; /* cpu address to free the dma mem */
173 __u32 virt_uaddr; /* virtual user space address */
174};
175
176#ifdef __KERNEL__
177
178struct pxp_tx_desc {
179 struct dma_async_tx_descriptor txd;
180 struct list_head tx_list;
181 struct list_head list;
182 int len;
183 union {
184 struct pxp_layer_param s0_param;
185 struct pxp_layer_param out_param;
186 struct pxp_layer_param ol_param;
187 } layer_param;
188 struct pxp_proc_data proc_data;
189
190 u32 hist_status; /* Histogram output status */
191
192 struct pxp_tx_desc *next;
193};
194
195struct pxp_channel {
196 struct dma_chan dma_chan;
197 dma_cookie_t completed; /* last completed cookie */
198 enum pxp_channel_status status;
199 void *client; /* Only one client per channel */
200 unsigned int n_tx_desc;
201 struct pxp_tx_desc *desc; /* allocated tx-descriptors */
202 struct list_head active_list; /* active tx-descriptors */
203 struct list_head free_list; /* free tx-descriptors */
204 struct list_head queue; /* queued tx-descriptors */
205 struct list_head list; /* track queued channel number */
206 spinlock_t lock; /* protects sg[0,1], queue */
207 struct mutex chan_mutex; /* protects status, cookie, free_list */
208 int active_buffer;
209 unsigned int eof_irq;
210 char eof_name[16]; /* EOF IRQ name for request_irq() */
211};
212
213struct pxp_irq_info {
214 wait_queue_head_t waitq;
215 int irq_pending;
216 int hist_status;
217};
218
219#define to_tx_desc(tx) container_of(tx, struct pxp_tx_desc, txd)
220#define to_pxp_channel(d) container_of(d, struct pxp_channel, dma_chan)
221
222void pxp_txd_ack(struct dma_async_tx_descriptor *txd,
223 struct pxp_channel *pxp_chan);
224#endif
225
226#endif