2 * Copyright (C) 2013 Freescale Semiconductor, Inc. All Rights Reserved.
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.
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.
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
22 #include <linux/posix_types.h>
25 typedef unsigned long dma_addr_t;
26 typedef unsigned char bool;
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))
35 * @name PXP Pixel Formats
37 * Pixel formats are defined with ASCII FOURCC code. The pixel format codes are
38 * the same used by V4L2 API.
42 /*! @name RGB Formats */
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 */
57 /*! @name YUV Interleaved Formats */
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 */
66 /*! @name YUV Planar Formats */
68 #define PXP_PIX_FMT_GREY fourcc('G', 'R', 'E', 'Y') /*!< 8 Greyscale */
69 #define PXP_PIX_FMT_GY04 fourcc('G', 'Y', '0', '4') /*!< 4 Greyscale */
70 #define PXP_PIX_FMT_YVU410P fourcc('Y', 'V', 'U', '9') /*!< 9 YVU 4:1:0 */
71 #define PXP_PIX_FMT_YUV410P fourcc('Y', 'U', 'V', '9') /*!< 9 YUV 4:1:0 */
72 #define PXP_PIX_FMT_YVU420P fourcc('Y', 'V', '1', '2') /*!< 12 YVU 4:2:0 */
73 #define PXP_PIX_FMT_YUV420P fourcc('I', '4', '2', '0') /*!< 12 YUV 4:2:0 */
74 #define PXP_PIX_FMT_YUV420P2 fourcc('Y', 'U', '1', '2') /*!< 12 YUV 4:2:0 */
75 #define PXP_PIX_FMT_YVU422P fourcc('Y', 'V', '1', '6') /*!< 16 YVU 4:2:2 */
76 #define PXP_PIX_FMT_YUV422P fourcc('4', '2', '2', 'P') /*!< 16 YUV 4:2:2 */
79 #define PXP_LUT_NONE 0x0
80 #define PXP_LUT_INVERT 0x1
81 #define PXP_LUT_BLACK_WHITE 0x2
82 #define PXP_LUT_USE_CMAP 0x4
84 #define NR_PXP_VIRT_CHANNEL 16
86 #define PXP_IOC_MAGIC 'P'
88 #define PXP_IOC_GET_CHAN _IOR(PXP_IOC_MAGIC, 0, struct pxp_mem_desc)
89 #define PXP_IOC_PUT_CHAN _IOW(PXP_IOC_MAGIC, 1, struct pxp_mem_desc)
90 #define PXP_IOC_CONFIG_CHAN _IOW(PXP_IOC_MAGIC, 2, struct pxp_mem_desc)
91 #define PXP_IOC_START_CHAN _IOW(PXP_IOC_MAGIC, 3, struct pxp_mem_desc)
92 #define PXP_IOC_GET_PHYMEM _IOWR(PXP_IOC_MAGIC, 4, struct pxp_mem_desc)
93 #define PXP_IOC_PUT_PHYMEM _IOW(PXP_IOC_MAGIC, 5, struct pxp_mem_desc)
94 #define PXP_IOC_WAIT4CMPLT _IOWR(PXP_IOC_MAGIC, 6, struct pxp_mem_desc)
96 /* Order significant! */
97 enum pxp_channel_status {
99 PXP_CHANNEL_INITIALIZED,
104 int top; /* Upper left coordinate of rectangle */
110 struct pxp_layer_param {
111 unsigned short width;
112 unsigned short height;
113 unsigned short stride; /* aka pitch */
114 unsigned int pixel_fmt;
116 /* layers combining parameters
117 * (these are ignored for S0 and output
118 * layers, and only apply for OL layer)
121 unsigned int color_key_enable;
122 unsigned int color_key;
123 bool global_alpha_enable;
124 unsigned char global_alpha;
125 bool local_alpha_enable;
130 struct pxp_proc_data {
131 /* S0 Transformation Info */
138 /* Source rectangle (srect) defines the sub-rectangle
139 * within S0 to undergo processing.
142 /* Dest rect (drect) defines how to position the processed
143 * source rectangle (after resizing) within the output frame,
144 * whose dimensions are defined in pxp->pxp_conf_state.out_param
148 /* Current S0 configuration */
149 unsigned int bgcolor;
151 /* Output overlay support */
154 /* LUT transformation on Y data */
156 unsigned char *lut_map; /* 256 entries */
157 bool lut_map_updated; /* Map recently changed */
160 struct pxp_config_data {
161 struct pxp_layer_param s0_param;
162 struct pxp_layer_param ol_param[8];
163 struct pxp_layer_param out_param;
164 struct pxp_proc_data proc_data;
167 /* Users don't touch */
171 struct pxp_mem_desc {
173 dma_addr_t phys_addr;
174 unsigned int cpu_addr; /* cpu address to free the dma mem */
175 unsigned int virt_uaddr; /* virtual user space address */