Mauro Carvalho Chehab | d56410e | 2006-03-25 09:19:53 -0300 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * zoran - Iomega Buz driver |
| 3 | * |
| 4 | * Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de> |
| 5 | * |
| 6 | * based on |
| 7 | * |
| 8 | * zoran.0.0.3 Copyright (C) 1998 Dave Perks <dperks@ibm.net> |
| 9 | * |
| 10 | * and |
| 11 | * |
| 12 | * bttv - Bt848 frame grabber driver |
| 13 | * Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) |
| 14 | * & Marcus Metzler (mocm@thp.uni-koeln.de) |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or modify |
| 17 | * it under the terms of the GNU General Public License as published by |
| 18 | * the Free Software Foundation; either version 2 of the License, or |
| 19 | * (at your option) any later version. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program; if not, write to the Free Software |
| 28 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 29 | */ |
| 30 | |
| 31 | #ifndef _BUZ_H_ |
| 32 | #define _BUZ_H_ |
| 33 | |
Hans Verkuil | 0ab6e1c | 2009-02-19 16:18:23 -0300 | [diff] [blame] | 34 | #include <media/v4l2-device.h> |
| 35 | |
Hans Verkuil | debff5a | 2010-03-22 05:25:46 -0300 | [diff] [blame] | 36 | #define ZORAN_VIDMODE_PAL 0 |
| 37 | #define ZORAN_VIDMODE_NTSC 1 |
| 38 | #define ZORAN_VIDMODE_SECAM 2 |
| 39 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | struct zoran_requestbuffers { |
| 41 | unsigned long count; /* Number of buffers for MJPEG grabbing */ |
| 42 | unsigned long size; /* Size PER BUFFER in bytes */ |
| 43 | }; |
| 44 | |
| 45 | struct zoran_sync { |
| 46 | unsigned long frame; /* number of buffer that has been free'd */ |
| 47 | unsigned long length; /* number of code bytes in buffer (capture only) */ |
| 48 | unsigned long seq; /* frame sequence number */ |
| 49 | struct timeval timestamp; /* timestamp */ |
| 50 | }; |
| 51 | |
| 52 | struct zoran_status { |
| 53 | int input; /* Input channel, has to be set prior to BUZIOC_G_STATUS */ |
| 54 | int signal; /* Returned: 1 if valid video signal detected */ |
Hans Verkuil | debff5a | 2010-03-22 05:25:46 -0300 | [diff] [blame] | 55 | int norm; /* Returned: ZORAN_VIDMODE_PAL or ZORAN_VIDMODE_NTSC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | int color; /* Returned: 1 if color signal detected */ |
| 57 | }; |
| 58 | |
| 59 | struct zoran_params { |
| 60 | |
| 61 | /* The following parameters can only be queried */ |
| 62 | |
| 63 | int major_version; /* Major version number of driver */ |
| 64 | int minor_version; /* Minor version number of driver */ |
| 65 | |
| 66 | /* Main control parameters */ |
| 67 | |
| 68 | int input; /* Input channel: 0 = Composite, 1 = S-VHS */ |
Hans Verkuil | debff5a | 2010-03-22 05:25:46 -0300 | [diff] [blame] | 69 | int norm; /* Norm: ZORAN_VIDMODE_PAL or ZORAN_VIDMODE_NTSC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | int decimation; /* decimation of captured video, |
| 71 | * enlargement of video played back. |
| 72 | * Valid values are 1, 2, 4 or 0. |
| 73 | * 0 is a special value where the user |
| 74 | * has full control over video scaling */ |
| 75 | |
| 76 | /* The following parameters only have to be set if decimation==0, |
| 77 | * for other values of decimation they provide the data how the image is captured */ |
| 78 | |
| 79 | int HorDcm; /* Horizontal decimation: 1, 2 or 4 */ |
| 80 | int VerDcm; /* Vertical decimation: 1 or 2 */ |
| 81 | int TmpDcm; /* Temporal decimation: 1 or 2, |
| 82 | * if TmpDcm==2 in capture every second frame is dropped, |
| 83 | * in playback every frame is played twice */ |
| 84 | int field_per_buff; /* Number of fields per buffer: 1 or 2 */ |
| 85 | int img_x; /* start of image in x direction */ |
| 86 | int img_y; /* start of image in y direction */ |
| 87 | int img_width; /* image width BEFORE decimation, |
| 88 | * must be a multiple of HorDcm*16 */ |
| 89 | int img_height; /* image height BEFORE decimation, |
| 90 | * must be a multiple of VerDcm*8 */ |
| 91 | |
| 92 | /* --- End of parameters for decimation==0 only --- */ |
| 93 | |
| 94 | /* JPEG control parameters */ |
| 95 | |
| 96 | int quality; /* Measure for quality of compressed images. |
| 97 | * Scales linearly with the size of the compressed images. |
| 98 | * Must be beetween 0 and 100, 100 is a compression |
| 99 | * ratio of 1:4 */ |
| 100 | |
| 101 | int odd_even; /* Which field should come first ??? */ |
| 102 | |
| 103 | int APPn; /* Number of APP segment to be written, must be 0..15 */ |
| 104 | int APP_len; /* Length of data in JPEG APPn segment */ |
| 105 | char APP_data[60]; /* Data in the JPEG APPn segment. */ |
| 106 | |
| 107 | int COM_len; /* Length of data in JPEG COM segment */ |
| 108 | char COM_data[60]; /* Data in JPEG COM segment */ |
| 109 | |
| 110 | unsigned long jpeg_markers; /* Which markers should go into the JPEG output. |
| 111 | * Unless you exactly know what you do, leave them untouched. |
| 112 | * Inluding less markers will make the resulting code |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 113 | * smaller, but there will be fewer applications |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | * which can read it. |
| 115 | * The presence of the APP and COM marker is |
| 116 | * influenced by APP0_len and COM_len ONLY! */ |
| 117 | #define JPEG_MARKER_DHT (1<<3) /* Define Huffman Tables */ |
| 118 | #define JPEG_MARKER_DQT (1<<4) /* Define Quantization Tables */ |
| 119 | #define JPEG_MARKER_DRI (1<<5) /* Define Restart Interval */ |
| 120 | #define JPEG_MARKER_COM (1<<6) /* Comment segment */ |
| 121 | #define JPEG_MARKER_APP (1<<7) /* App segment, driver will allways use APP0 */ |
| 122 | |
| 123 | int VFIFO_FB; /* Flag for enabling Video Fifo Feedback. |
| 124 | * If this flag is turned on and JPEG decompressing |
| 125 | * is going to the screen, the decompress process |
| 126 | * is stopped every time the Video Fifo is full. |
| 127 | * This enables a smooth decompress to the screen |
| 128 | * but the video output signal will get scrambled */ |
| 129 | |
| 130 | /* Misc */ |
| 131 | |
| 132 | char reserved[312]; /* Makes 512 bytes for this structure */ |
| 133 | }; |
| 134 | |
| 135 | /* |
| 136 | Private IOCTL to set up for displaying MJPEG |
| 137 | */ |
Hans Verkuil | debff5a | 2010-03-22 05:25:46 -0300 | [diff] [blame] | 138 | #define BUZIOC_G_PARAMS _IOR ('v', BASE_VIDIOC_PRIVATE+0, struct zoran_params) |
| 139 | #define BUZIOC_S_PARAMS _IOWR('v', BASE_VIDIOC_PRIVATE+1, struct zoran_params) |
| 140 | #define BUZIOC_REQBUFS _IOWR('v', BASE_VIDIOC_PRIVATE+2, struct zoran_requestbuffers) |
| 141 | #define BUZIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOC_PRIVATE+3, int) |
| 142 | #define BUZIOC_QBUF_PLAY _IOW ('v', BASE_VIDIOC_PRIVATE+4, int) |
| 143 | #define BUZIOC_SYNC _IOR ('v', BASE_VIDIOC_PRIVATE+5, struct zoran_sync) |
| 144 | #define BUZIOC_G_STATUS _IOWR('v', BASE_VIDIOC_PRIVATE+6, struct zoran_status) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | |
| 147 | #ifdef __KERNEL__ |
| 148 | |
| 149 | #define MAJOR_VERSION 0 /* driver major version */ |
Hans Verkuil | 3ff4ad8 | 2009-04-01 03:15:52 -0300 | [diff] [blame] | 150 | #define MINOR_VERSION 10 /* driver minor version */ |
| 151 | #define RELEASE_VERSION 0 /* release version */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | #define ZORAN_NAME "ZORAN" /* name of the device */ |
| 154 | |
| 155 | #define ZR_DEVNAME(zr) ((zr)->name) |
| 156 | |
| 157 | #define BUZ_MAX_WIDTH (zr->timing->Wa) |
| 158 | #define BUZ_MAX_HEIGHT (zr->timing->Ha) |
| 159 | #define BUZ_MIN_WIDTH 32 /* never display less than 32 pixels */ |
| 160 | #define BUZ_MIN_HEIGHT 24 /* never display less than 24 rows */ |
| 161 | |
| 162 | #define BUZ_NUM_STAT_COM 4 |
| 163 | #define BUZ_MASK_STAT_COM 3 |
| 164 | |
| 165 | #define BUZ_MAX_FRAME 256 /* Must be a power of 2 */ |
| 166 | #define BUZ_MASK_FRAME 255 /* Must be BUZ_MAX_FRAME-1 */ |
| 167 | |
Martin Samuelsson | fbe60da | 2006-04-27 10:17:00 -0300 | [diff] [blame] | 168 | #define BUZ_MAX_INPUT 16 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
| 170 | #if VIDEO_MAX_FRAME <= 32 |
| 171 | # define V4L_MAX_FRAME 32 |
| 172 | #elif VIDEO_MAX_FRAME <= 64 |
| 173 | # define V4L_MAX_FRAME 64 |
| 174 | #else |
| 175 | # error "Too many video frame buffers to handle" |
| 176 | #endif |
| 177 | #define V4L_MASK_FRAME (V4L_MAX_FRAME - 1) |
| 178 | |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 179 | #define MAX_FRAME (BUZ_MAX_FRAME > VIDEO_MAX_FRAME ? BUZ_MAX_FRAME : VIDEO_MAX_FRAME) |
| 180 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | #include "zr36057.h" |
| 182 | |
| 183 | enum card_type { |
| 184 | UNKNOWN = -1, |
| 185 | |
| 186 | /* Pinnacle/Miro */ |
| 187 | DC10_old, /* DC30 like */ |
| 188 | DC10_new, /* DC10plus like */ |
| 189 | DC10plus, |
| 190 | DC30, |
| 191 | DC30plus, |
| 192 | |
| 193 | /* Linux Media Labs */ |
| 194 | LML33, |
| 195 | LML33R10, |
| 196 | |
| 197 | /* Iomega */ |
| 198 | BUZ, |
| 199 | |
Martin Samuelsson | fbe60da | 2006-04-27 10:17:00 -0300 | [diff] [blame] | 200 | /* AverMedia */ |
| 201 | AVS6EYES, |
| 202 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | /* total number of cards */ |
| 204 | NUM_CARDS |
| 205 | }; |
| 206 | |
| 207 | enum zoran_codec_mode { |
| 208 | BUZ_MODE_IDLE, /* nothing going on */ |
| 209 | BUZ_MODE_MOTION_COMPRESS, /* grabbing frames */ |
| 210 | BUZ_MODE_MOTION_DECOMPRESS, /* playing frames */ |
| 211 | BUZ_MODE_STILL_COMPRESS, /* still frame conversion */ |
| 212 | BUZ_MODE_STILL_DECOMPRESS /* still frame conversion */ |
| 213 | }; |
| 214 | |
| 215 | enum zoran_buffer_state { |
| 216 | BUZ_STATE_USER, /* buffer is owned by application */ |
| 217 | BUZ_STATE_PEND, /* buffer is queued in pend[] ready to feed to I/O */ |
| 218 | BUZ_STATE_DMA, /* buffer is queued in dma[] for I/O */ |
| 219 | BUZ_STATE_DONE /* buffer is ready to return to application */ |
| 220 | }; |
| 221 | |
| 222 | enum zoran_map_mode { |
| 223 | ZORAN_MAP_MODE_RAW, |
| 224 | ZORAN_MAP_MODE_JPG_REC, |
| 225 | #define ZORAN_MAP_MODE_JPG ZORAN_MAP_MODE_JPG_REC |
| 226 | ZORAN_MAP_MODE_JPG_PLAY, |
| 227 | }; |
| 228 | |
| 229 | enum gpio_type { |
Mauro Carvalho Chehab | 6165894 | 2008-02-15 18:41:06 -0300 | [diff] [blame] | 230 | ZR_GPIO_JPEG_SLEEP = 0, |
| 231 | ZR_GPIO_JPEG_RESET, |
| 232 | ZR_GPIO_JPEG_FRAME, |
| 233 | ZR_GPIO_VID_DIR, |
| 234 | ZR_GPIO_VID_EN, |
| 235 | ZR_GPIO_VID_RESET, |
| 236 | ZR_GPIO_CLK_SEL1, |
| 237 | ZR_GPIO_CLK_SEL2, |
| 238 | ZR_GPIO_MAX, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | enum gpcs_type { |
| 242 | GPCS_JPEG_RESET = 0, |
| 243 | GPCS_JPEG_START, |
| 244 | GPCS_MAX, |
| 245 | }; |
| 246 | |
| 247 | struct zoran_format { |
| 248 | char *name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | __u32 fourcc; |
| 250 | int colorspace; |
| 251 | int depth; |
| 252 | __u32 flags; |
Trent Piepho | 603d6f2 | 2007-07-17 18:29:44 -0300 | [diff] [blame] | 253 | __u32 vfespfr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | }; |
| 255 | /* flags */ |
| 256 | #define ZORAN_FORMAT_COMPRESSED 1<<0 |
| 257 | #define ZORAN_FORMAT_OVERLAY 1<<1 |
| 258 | #define ZORAN_FORMAT_CAPTURE 1<<2 |
| 259 | #define ZORAN_FORMAT_PLAYBACK 1<<3 |
| 260 | |
| 261 | /* overlay-settings */ |
| 262 | struct zoran_overlay_settings { |
| 263 | int is_set; |
| 264 | int x, y, width, height; /* position */ |
| 265 | int clipcount; /* position and number of clips */ |
| 266 | const struct zoran_format *format; /* overlay format */ |
| 267 | }; |
| 268 | |
| 269 | /* v4l-capture settings */ |
| 270 | struct zoran_v4l_settings { |
| 271 | int width, height, bytesperline; /* capture size */ |
| 272 | const struct zoran_format *format; /* capture format */ |
| 273 | }; |
| 274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | /* jpg-capture/-playback settings */ |
| 276 | struct zoran_jpg_settings { |
| 277 | int decimation; /* this bit is used to set everything to default */ |
| 278 | int HorDcm, VerDcm, TmpDcm; /* capture decimation settings (TmpDcm=1 means both fields) */ |
| 279 | int field_per_buff, odd_even; /* field-settings (odd_even=1 (+TmpDcm=1) means top-field-first) */ |
| 280 | int img_x, img_y, img_width, img_height; /* crop settings (subframe capture) */ |
| 281 | struct v4l2_jpegcompression jpg_comp; /* JPEG-specific capture settings */ |
| 282 | }; |
| 283 | |
| 284 | struct zoran_mapping { |
| 285 | struct file *file; |
| 286 | int count; |
| 287 | }; |
| 288 | |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 289 | struct zoran_buffer { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | struct zoran_mapping *map; |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 291 | enum zoran_buffer_state state; /* state: unused/pending/dma/done */ |
| 292 | struct zoran_sync bs; /* DONE: info to return to application */ |
| 293 | union { |
| 294 | struct { |
| 295 | __le32 *frag_tab; /* addresses of frag table */ |
| 296 | u32 frag_tab_bus; /* same value cached to save time in ISR */ |
| 297 | } jpg; |
| 298 | struct { |
| 299 | char *fbuffer; /* virtual address of frame buffer */ |
| 300 | unsigned long fbuffer_phys;/* physical address of frame buffer */ |
| 301 | unsigned long fbuffer_bus;/* bus address of frame buffer */ |
| 302 | } v4l; |
| 303 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | }; |
| 305 | |
| 306 | enum zoran_lock_activity { |
| 307 | ZORAN_FREE, /* free for use */ |
| 308 | ZORAN_ACTIVE, /* active but unlocked */ |
| 309 | ZORAN_LOCKED, /* locked */ |
| 310 | }; |
| 311 | |
| 312 | /* buffer collections */ |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 313 | struct zoran_buffer_col { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | enum zoran_lock_activity active; /* feature currently in use? */ |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 315 | unsigned int num_buffers, buffer_size; |
| 316 | struct zoran_buffer buffer[MAX_FRAME]; /* buffers */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | u8 allocated; /* Flag if buffers are allocated */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | u8 need_contiguous; /* Flag if contiguous buffers are needed */ |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 319 | /* only applies to jpg buffers, raw buffers are always contiguous */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | }; |
| 321 | |
| 322 | struct zoran; |
| 323 | |
| 324 | /* zoran_fh contains per-open() settings */ |
| 325 | struct zoran_fh { |
| 326 | struct zoran *zr; |
| 327 | |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 328 | enum zoran_map_mode map_mode; /* Flag which bufferset will map by next mmap() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
| 330 | struct zoran_overlay_settings overlay_settings; |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 331 | u32 *overlay_mask; /* overlay mask */ |
| 332 | enum zoran_lock_activity overlay_active;/* feature currently in use? */ |
| 333 | |
| 334 | struct zoran_buffer_col buffers; /* buffers' info */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
| 336 | struct zoran_v4l_settings v4l_settings; /* structure with a lot of things to play with */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | struct zoran_jpg_settings jpg_settings; /* structure with a lot of things to play with */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | }; |
| 339 | |
| 340 | struct card_info { |
| 341 | enum card_type type; |
| 342 | char name[32]; |
Hans Verkuil | 0ab6e1c | 2009-02-19 16:18:23 -0300 | [diff] [blame] | 343 | const char *i2c_decoder; /* i2c decoder device */ |
Hans Verkuil | 0ab6e1c | 2009-02-19 16:18:23 -0300 | [diff] [blame] | 344 | const unsigned short *addrs_decoder; |
| 345 | const char *i2c_encoder; /* i2c encoder device */ |
Hans Verkuil | 0ab6e1c | 2009-02-19 16:18:23 -0300 | [diff] [blame] | 346 | const unsigned short *addrs_encoder; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | u16 video_vfe, video_codec; /* videocodec types */ |
| 348 | u16 audio_chip; /* audio type */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
| 350 | int inputs; /* number of video inputs */ |
| 351 | struct input { |
| 352 | int muxsel; |
| 353 | char name[32]; |
| 354 | } input[BUZ_MAX_INPUT]; |
| 355 | |
Hans Verkuil | 107063c | 2009-02-18 17:26:06 -0300 | [diff] [blame] | 356 | v4l2_std_id norms; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | struct tvnorm *tvn[3]; /* supported TV norms */ |
| 358 | |
| 359 | u32 jpeg_int; /* JPEG interrupt */ |
| 360 | u32 vsync_int; /* VSYNC interrupt */ |
Mauro Carvalho Chehab | 6165894 | 2008-02-15 18:41:06 -0300 | [diff] [blame] | 361 | s8 gpio[ZR_GPIO_MAX]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | u8 gpcs[GPCS_MAX]; |
| 363 | |
| 364 | struct vfe_polarity vfe_pol; |
Mauro Carvalho Chehab | 6165894 | 2008-02-15 18:41:06 -0300 | [diff] [blame] | 365 | u8 gpio_pol[ZR_GPIO_MAX]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
| 367 | /* is the /GWS line conected? */ |
| 368 | u8 gws_not_connected; |
| 369 | |
Martin Samuelsson | fbe60da | 2006-04-27 10:17:00 -0300 | [diff] [blame] | 370 | /* avs6eyes mux setting */ |
| 371 | u8 input_mux; |
| 372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | void (*init) (struct zoran * zr); |
| 374 | }; |
| 375 | |
| 376 | struct zoran { |
Hans Verkuil | 0ab6e1c | 2009-02-19 16:18:23 -0300 | [diff] [blame] | 377 | struct v4l2_device v4l2_dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | struct video_device *video_dev; |
| 379 | |
| 380 | struct i2c_adapter i2c_adapter; /* */ |
| 381 | struct i2c_algo_bit_data i2c_algo; /* */ |
| 382 | u32 i2cbr; |
| 383 | |
Hans Verkuil | 0ab6e1c | 2009-02-19 16:18:23 -0300 | [diff] [blame] | 384 | struct v4l2_subdev *decoder; /* video decoder sub-device */ |
| 385 | struct v4l2_subdev *encoder; /* video encoder sub-device */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
| 387 | struct videocodec *codec; /* video codec */ |
| 388 | struct videocodec *vfe; /* video front end */ |
| 389 | |
Ingo Molnar | 384c368 | 2006-03-22 03:54:16 -0300 | [diff] [blame] | 390 | struct mutex resource_lock; /* prevent evil stuff */ |
Arnd Bergmann | 0edf2e5 | 2010-10-27 09:30:32 -0300 | [diff] [blame^] | 391 | struct mutex other_lock; /* please merge with above */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | |
Uwe Kleine-König | 421f91d | 2010-06-11 12:17:00 +0200 | [diff] [blame] | 393 | u8 initialized; /* flag if zoran has been correctly initialized */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | int user; /* number of current users */ |
| 395 | struct card_info card; |
| 396 | struct tvnorm *timing; |
| 397 | |
| 398 | unsigned short id; /* number of this device */ |
| 399 | char name[32]; /* name of this device */ |
| 400 | struct pci_dev *pci_dev; /* PCI device */ |
| 401 | unsigned char revision; /* revision of zr36057 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | unsigned char __iomem *zr36057_mem;/* pointer to mapped IO memory */ |
| 403 | |
| 404 | spinlock_t spinlock; /* Spinlock */ |
| 405 | |
| 406 | /* Video for Linux parameters */ |
Hans Verkuil | debff5a | 2010-03-22 05:25:46 -0300 | [diff] [blame] | 407 | int input; /* card's norm and input */ |
Hans Verkuil | 107063c | 2009-02-18 17:26:06 -0300 | [diff] [blame] | 408 | v4l2_std_id norm; |
Hans Verkuil | 7f6adea | 2009-02-19 17:31:17 -0300 | [diff] [blame] | 409 | |
| 410 | /* Current buffer params */ |
| 411 | void *vbuf_base; |
| 412 | int vbuf_height, vbuf_width; |
| 413 | int vbuf_depth; |
| 414 | int vbuf_bytesperline; |
| 415 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | struct zoran_overlay_settings overlay_settings; |
| 417 | u32 *overlay_mask; /* overlay mask */ |
| 418 | enum zoran_lock_activity overlay_active; /* feature currently in use? */ |
| 419 | |
| 420 | wait_queue_head_t v4l_capq; |
| 421 | |
| 422 | int v4l_overlay_active; /* Overlay grab is activated */ |
| 423 | int v4l_memgrab_active; /* Memory grab is activated */ |
| 424 | |
| 425 | int v4l_grab_frame; /* Frame number being currently grabbed */ |
| 426 | #define NO_GRAB_ACTIVE (-1) |
| 427 | unsigned long v4l_grab_seq; /* Number of frames grabbed */ |
| 428 | struct zoran_v4l_settings v4l_settings; /* structure with a lot of things to play with */ |
| 429 | |
| 430 | /* V4L grab queue of frames pending */ |
| 431 | unsigned long v4l_pend_head; |
| 432 | unsigned long v4l_pend_tail; |
| 433 | unsigned long v4l_sync_tail; |
| 434 | int v4l_pend[V4L_MAX_FRAME]; |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 435 | struct zoran_buffer_col v4l_buffers; /* V4L buffers' info */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | |
| 437 | /* Buz MJPEG parameters */ |
| 438 | enum zoran_codec_mode codec_mode; /* status of codec */ |
| 439 | struct zoran_jpg_settings jpg_settings; /* structure with a lot of things to play with */ |
| 440 | |
| 441 | wait_queue_head_t jpg_capq; /* wait here for grab to finish */ |
| 442 | |
| 443 | /* grab queue counts/indices, mask with BUZ_MASK_STAT_COM before using as index */ |
| 444 | /* (dma_head - dma_tail) is number active in DMA, must be <= BUZ_NUM_STAT_COM */ |
| 445 | /* (value & BUZ_MASK_STAT_COM) corresponds to index in stat_com table */ |
| 446 | unsigned long jpg_que_head; /* Index where to put next buffer which is queued */ |
| 447 | unsigned long jpg_dma_head; /* Index of next buffer which goes into stat_com */ |
| 448 | unsigned long jpg_dma_tail; /* Index of last buffer in stat_com */ |
| 449 | unsigned long jpg_que_tail; /* Index of last buffer in queue */ |
| 450 | unsigned long jpg_seq_num; /* count of frames since grab/play started */ |
| 451 | unsigned long jpg_err_seq; /* last seq_num before error */ |
| 452 | unsigned long jpg_err_shift; |
| 453 | unsigned long jpg_queued_num; /* count of frames queued since grab/play started */ |
| 454 | |
| 455 | /* zr36057's code buffer table */ |
Al Viro | 581a7f1 | 2008-05-21 00:32:31 -0300 | [diff] [blame] | 456 | __le32 *stat_com; /* stat_com[i] is indexed by dma_head/tail & BUZ_MASK_STAT_COM */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | |
| 458 | /* (value & BUZ_MASK_FRAME) corresponds to index in pend[] queue */ |
| 459 | int jpg_pend[BUZ_MAX_FRAME]; |
| 460 | |
| 461 | /* array indexed by frame number */ |
Trent Piepho | 1159b7f | 2009-03-10 23:28:16 -0300 | [diff] [blame] | 462 | struct zoran_buffer_col jpg_buffers; /* MJPEG buffers' info */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
| 464 | /* Additional stuff for testing */ |
| 465 | #ifdef CONFIG_PROC_FS |
| 466 | struct proc_dir_entry *zoran_proc; |
| 467 | #else |
| 468 | void *zoran_proc; |
| 469 | #endif |
| 470 | int testing; |
| 471 | int jpeg_error; |
| 472 | int intr_counter_GIRQ1; |
| 473 | int intr_counter_GIRQ0; |
| 474 | int intr_counter_CodRepIRQ; |
| 475 | int intr_counter_JPEGRepIRQ; |
| 476 | int field_counter; |
| 477 | int IRQ1_in; |
| 478 | int IRQ1_out; |
| 479 | int JPEG_in; |
| 480 | int JPEG_out; |
| 481 | int JPEG_0; |
| 482 | int JPEG_1; |
| 483 | int END_event_missed; |
| 484 | int JPEG_missed; |
| 485 | int JPEG_error; |
| 486 | int num_errors; |
| 487 | int JPEG_max_missed; |
| 488 | int JPEG_min_missed; |
| 489 | |
| 490 | u32 last_isr; |
| 491 | unsigned long frame_num; |
| 492 | |
| 493 | wait_queue_head_t test_q; |
| 494 | }; |
| 495 | |
Hans Verkuil | 0ab6e1c | 2009-02-19 16:18:23 -0300 | [diff] [blame] | 496 | static inline struct zoran *to_zoran(struct v4l2_device *v4l2_dev) |
| 497 | { |
| 498 | return container_of(v4l2_dev, struct zoran, v4l2_dev); |
| 499 | } |
| 500 | |
Trent Piepho | 5e098b6 | 2009-01-12 13:09:46 -0300 | [diff] [blame] | 501 | /* There was something called _ALPHA_BUZ that used the PCI address instead of |
| 502 | * the kernel iomapped address for btread/btwrite. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | #define btwrite(dat,adr) writel((dat), zr->zr36057_mem+(adr)) |
| 504 | #define btread(adr) readl(zr->zr36057_mem+(adr)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | #define btand(dat,adr) btwrite((dat) & btread(adr), adr) |
| 507 | #define btor(dat,adr) btwrite((dat) | btread(adr), adr) |
| 508 | #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr) |
| 509 | |
| 510 | #endif /* __kernel__ */ |
| 511 | |
| 512 | #endif |