bt8xx.h revision 1.1 1 /* $NetBSD: bt8xx.h,v 1.1 2000/05/07 00:17:13 wiz Exp $ */
2
3 /* This file is merged from ioctl_meteor.h and ioctl_bt848.h from FreeBSD. */
4 /* The copyright below only applies to the ioctl_meteor.h part of this file. */
5 /*
6 * Copyright (c) 1995 Mark Tinguely and Jim Lowe
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by Mark Tinguely and Jim Lowe
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35 /*
36 * ioctl constants for Matrox Meteor Capture card.
37 */
38
39
40 #ifndef KERNEL
41 #include <sys/types.h>
42 #endif
43 #include <sys/ioccom.h>
44
45 struct meteor_capframe {
46 short command; /* see below for valid METEORCAPFRM commands */
47 short lowat; /* start transfer if < this number */
48 short hiwat; /* stop transfer if > this number */
49 } ;
50
51 /* structure for METEOR[GS]ETGEO - get/set geometry */
52 struct meteor_geomet {
53 u_short rows;
54 u_short columns;
55 u_short frames;
56 u_long oformat;
57 } ;
58
59 /* structure for METEORGCOUNT-get count of frames, fifo errors and dma errors */
60 struct meteor_counts {
61 u_long fifo_errors; /* count of fifo errors since open */
62 u_long dma_errors; /* count of dma errors since open */
63 u_long frames_captured; /* count of frames captured since open */
64 u_long even_fields_captured; /* count of even fields captured */
65 u_long odd_fields_captured; /* count of odd fields captured */
66 } ;
67
68 /* structure for getting and setting direct transfers to vram */
69 struct meteor_video {
70 u_long addr; /* Address of location to dma to */
71 u_long width; /* Width of memory area */
72 u_long banksize; /* Size of Vram bank */
73 u_long ramsize; /* Size of Vram */
74 };
75
76 #define METEORCAPTUR _IOW('x', 1, int) /* capture a frame */
77 #define METEORCAPFRM _IOW('x', 2, struct meteor_capframe) /* sync capture */
78 #define METEORSETGEO _IOW('x', 3, struct meteor_geomet) /* set geometry */
79 #define METEORGETGEO _IOR('x', 4, struct meteor_geomet) /* get geometry */
80 #define METEORSTATUS _IOR('x', 5, unsigned short) /* get status */
81 #define METEORSHUE _IOW('x', 6, signed char) /* set hue */
82 #define METEORGHUE _IOR('x', 6, signed char) /* get hue */
83 #define METEORSFMT _IOW('x', 7, unsigned long) /* set format */
84 #define METEORGFMT _IOR('x', 7, unsigned long) /* get format */
85 #define METEORSINPUT _IOW('x', 8, unsigned long) /* set input dev */
86 #define METEORGINPUT _IOR('x', 8, unsigned long) /* get input dev */
87 #define METEORSCHCV _IOW('x', 9, unsigned char) /* set uv gain */
88 #define METEORGCHCV _IOR('x', 9, unsigned char) /* get uv gain */
89 #define METEORSCOUNT _IOW('x',10, struct meteor_counts)
90 #define METEORGCOUNT _IOR('x',10, struct meteor_counts)
91 #define METEORSFPS _IOW('x',11, unsigned short) /* set fps */
92 #define METEORGFPS _IOR('x',11, unsigned short) /* get fps */
93 #define METEORSSIGNAL _IOW('x', 12, unsigned int) /* set signal */
94 #define METEORGSIGNAL _IOR('x', 12, unsigned int) /* get signal */
95 #define METEORSVIDEO _IOW('x', 13, struct meteor_video) /* set video */
96 #define METEORGVIDEO _IOR('x', 13, struct meteor_video) /* get video */
97 #define METEORSBRIG _IOW('x', 14, unsigned char) /* set brightness */
98 #define METEORGBRIG _IOR('x', 14, unsigned char) /* get brightness */
99 #define METEORSCSAT _IOW('x', 15, unsigned char) /* set chroma sat */
100 #define METEORGCSAT _IOR('x', 15, unsigned char) /* get uv saturation */
101 #define METEORSCONT _IOW('x', 16, unsigned char) /* set contrast */
102 #define METEORGCONT _IOR('x', 16, unsigned char) /* get contrast */
103 #define METEORSBT254 _IOW('x', 17, unsigned short) /* set Bt254 reg */
104 #define METEORGBT254 _IOR('x', 17, unsigned short) /* get Bt254 reg */
105 #define METEORSHWS _IOW('x', 18, unsigned char) /* set hor start reg */
106 #define METEORGHWS _IOR('x', 18, unsigned char) /* get hor start reg */
107 #define METEORSVWS _IOW('x', 19, unsigned char) /* set vert start reg */
108 #define METEORGVWS _IOR('x', 19, unsigned char) /* get vert start reg */
109 #define METEORSTS _IOW('x', 20, unsigned char) /* set time stamp */
110 #define METEORGTS _IOR('x', 20, unsigned char) /* get time stamp */
111
112 #define METEOR_STATUS_ID_MASK 0xf000 /* ID of 7196 */
113 #define METEOR_STATUS_DIR 0x0800 /* Direction of Expansion port YUV */
114 #define METEOR_STATUS_OEF 0x0200 /* Field detected: Even/Odd */
115 #define METEOR_STATUS_SVP 0x0100 /* State of VRAM Port:inactive/active */
116 #define METEOR_STATUS_STTC 0x0080 /* Time Constant: TV/VCR */
117 #define METEOR_STATUS_HCLK 0x0040 /* Horiz PLL: locked/unlocked */
118 #define METEOR_STATUS_FIDT 0x0020 /* Field detect: 50/60hz */
119 #define METEOR_STATUS_ALTD 0x0002 /* Line alt: no line alt/line alt */
120 #define METEOR_STATUS_CODE 0x0001 /* Colour info: no colour/colour */
121
122 /* METEORCAPTUR capture options */
123 #define METEOR_CAP_SINGLE 0x0001 /* capture one frame */
124 #define METEOR_CAP_CONTINOUS 0x0002 /* continuously capture */
125 #define METEOR_CAP_STOP_CONT 0x0004 /* stop the continuous capture */
126
127 /* METEORCAPFRM capture commands */
128 #define METEOR_CAP_N_FRAMES 0x0001 /* capture N frames */
129 #define METEOR_CAP_STOP_FRAMES 0x0002 /* stop capture N frames */
130 #define METEOR_HALT_N_FRAMES 0x0003 /* halt of capture N frames */
131 #define METEOR_CONT_N_FRAMES 0x0004 /* continue after above halt */
132
133 /* valid video input formats: */
134 #define METEOR_FMT_NTSC 0x00100 /* NTSC -- initialized default */
135 #define METEOR_FMT_PAL 0x00200 /* PAL */
136 #define METEOR_FMT_SECAM 0x00400 /* SECAM */
137 #define METEOR_FMT_AUTOMODE 0x00800 /* auto-mode */
138 #define METEOR_INPUT_DEV0 0x01000 /* camera input 0 -- default */
139 #define METEOR_INPUT_DEV_RCA METEOR_INPUT_DEV0
140 #define METEOR_INPUT_DEV1 0x02000 /* camera input 1 */
141 #define METEOR_INPUT_DEV2 0x04000 /* camera input 2 */
142 #define METEOR_INPUT_DEV3 0x08000 /* camera input 3 */
143 #define METEOR_INPUT_DEV_RGB 0x0a000 /* for rgb version of meteor */
144 #define METEOR_INPUT_DEV_SVIDEO 0x06000 /* S-video input port */
145
146 /* valid video output formats: */
147 #define METEOR_GEO_RGB16 0x0010000 /* packed -- initialized default */
148 #define METEOR_GEO_RGB24 0x0020000 /* RBG 24 bits packed */
149 /* internally stored in 32 bits */
150 #define METEOR_GEO_YUV_PACKED 0x0040000 /* 4-2-2 YUV 16 bits packed */
151 #define METEOR_GEO_YUV_PLANAR 0x0080000 /* 4-2-2 YUV 16 bits planer */
152 #define METEOR_GEO_YUV_PLANER METEOR_GEO_YUV_PLANAR
153 #define METEOR_GEO_UNSIGNED 0x0400000 /* unsigned uv outputs */
154 #define METEOR_GEO_EVEN_ONLY 0x1000000 /* set for even only field capture */
155 #define METEOR_GEO_ODD_ONLY 0x2000000 /* set for odd only field capture */
156 #define METEOR_GEO_FIELD_MASK 0x3000000
157 #define METEOR_GEO_YUV_422 0x4000000 /* 4-2-2 YUV in Y-U-V combined */
158 #define METEOR_GEO_OUTPUT_MASK 0x40f0000
159 #define METEOR_GEO_YUV_12 0x10000000 /* YUV 12 format */
160 #define METEOR_GEO_YUV_9 0x40000000 /* YUV 9 format */
161
162 #define METEOR_FIELD_MODE 0x80000000 /* Field cap or Frame cap */
163
164 #define METEOR_SIG_MODE_MASK 0xffff0000
165 #define METEOR_SIG_FRAME 0x00000000 /* signal every frame */
166 #define METEOR_SIG_FIELD 0x00010000 /* signal every field */
167
168 /* following structure is used to coordinate the synchronous */
169
170 struct meteor_mem {
171 /* kernel write only */
172 int frame_size; /* row*columns*depth */
173 unsigned num_bufs; /* number of frames in buffer (1-32) */
174 /* user and kernel change these */
175 int lowat; /* kernel starts capture if < this number */
176 int hiwat; /* kernel stops capture if > this number.
177 hiwat <= numbufs */
178 unsigned active; /* bit mask of active frame buffers
179 kernel sets, user clears */
180 int num_active_bufs; /* count of active frame buffer
181 kernel increments, user decrements */
182
183 /* reference to mmapped data */
184 caddr_t buf; /* The real space (virtual addr) */
185 } ;
186
187 /*
188 * extensions to ioctl_meteor.h for the bt848 cards
189 *
190 * FreeBSD: src/sys/i386/include/ioctl_bt848.h,v 1.24 1999/08/28 00:44:16 peter Exp
191 */
192
193
194 /*
195 * frequency sets
196 */
197 #define CHNLSET_NABCST 1
198 #define CHNLSET_CABLEIRC 2
199 #define CHNLSET_CABLEHRC 3
200 #define CHNLSET_WEUROPE 4
201 #define CHNLSET_JPNBCST 5
202 #define CHNLSET_JPNCABLE 6
203 #define CHNLSET_XUSSR 7
204 #define CHNLSET_AUSTRALIA 8
205 #define CHNLSET_FRANCE 9
206 #define CHNLSET_MIN CHNLSET_NABCST
207 #define CHNLSET_MAX CHNLSET_FRANCE
208
209
210 /*
211 * constants for various tuner registers
212 */
213 #define BT848_HUEMIN (-90)
214 #define BT848_HUEMAX 90
215 #define BT848_HUECENTER 0
216 #define BT848_HUERANGE 179.3
217 #define BT848_HUEREGMIN (-128)
218 #define BT848_HUEREGMAX 127
219 #define BT848_HUESTEPS 256
220
221 #define BT848_BRIGHTMIN (-50)
222 #define BT848_BRIGHTMAX 50
223 #define BT848_BRIGHTCENTER 0
224 #define BT848_BRIGHTRANGE 99.6
225 #define BT848_BRIGHTREGMIN (-128)
226 #define BT848_BRIGHTREGMAX 127
227 #define BT848_BRIGHTSTEPS 256
228
229 #define BT848_CONTRASTMIN 0
230 #define BT848_CONTRASTMAX 237
231 #define BT848_CONTRASTCENTER 100
232 #define BT848_CONTRASTRANGE 236.57
233 #define BT848_CONTRASTREGMIN 0
234 #define BT848_CONTRASTREGMAX 511
235 #define BT848_CONTRASTSTEPS 512
236
237 #define BT848_CHROMAMIN 0
238 #define BT848_CHROMAMAX 284
239 #define BT848_CHROMACENTER 100
240 #define BT848_CHROMARANGE 283.89
241 #define BT848_CHROMAREGMIN 0
242 #define BT848_CHROMAREGMAX 511
243 #define BT848_CHROMASTEPS 512
244
245 #define BT848_SATUMIN 0
246 #define BT848_SATUMAX 202
247 #define BT848_SATUCENTER 100
248 #define BT848_SATURANGE 201.18
249 #define BT848_SATUREGMIN 0
250 #define BT848_SATUREGMAX 511
251 #define BT848_SATUSTEPS 512
252
253 #define BT848_SATVMIN 0
254 #define BT848_SATVMAX 284
255 #define BT848_SATVCENTER 100
256 #define BT848_SATVRANGE 283.89
257 #define BT848_SATVREGMIN 0
258 #define BT848_SATVREGMAX 511
259 #define BT848_SATVSTEPS 512
260
261
262 /*
263 * audio stuff
264 */
265 #define AUDIO_TUNER 0x00 /* command for the audio routine */
266 #define AUDIO_EXTERN 0x01 /* don't confuse them with bit */
267 #define AUDIO_INTERN 0x02 /* settings */
268 #define AUDIO_MUTE 0x80
269 #define AUDIO_UNMUTE 0x81
270
271
272 /*
273 * EEProm stuff
274 */
275 struct eeProm {
276 short offset;
277 short count;
278 u_char bytes[ 256 ];
279 };
280
281
282 /*
283 * XXX: this is a hack, should be in ioctl_meteor.h
284 * here to avoid touching that file for now...
285 */
286 #define TVTUNER_SETCHNL _IOW('x', 32, unsigned int) /* set channel */
287 #define TVTUNER_GETCHNL _IOR('x', 32, unsigned int) /* get channel */
288 #define TVTUNER_SETTYPE _IOW('x', 33, unsigned int) /* set tuner type */
289 #define TVTUNER_GETTYPE _IOR('x', 33, unsigned int) /* get tuner type */
290 #define TVTUNER_GETSTATUS _IOR('x', 34, unsigned int) /* get tuner status */
291 #define TVTUNER_SETFREQ _IOW('x', 35, unsigned int) /* set frequency */
292 #define TVTUNER_GETFREQ _IOR('x', 36, unsigned int) /* get frequency */
293
294
295 #define BT848_SHUE _IOW('x', 37, int) /* set hue */
296 #define BT848_GHUE _IOR('x', 37, int) /* get hue */
297 #define BT848_SBRIG _IOW('x', 38, int) /* set brightness */
298 #define BT848_GBRIG _IOR('x', 38, int) /* get brightness */
299 #define BT848_SCSAT _IOW('x', 39, int) /* set chroma sat */
300 #define BT848_GCSAT _IOR('x', 39, int) /* get UV saturation */
301 #define BT848_SCONT _IOW('x', 40, int) /* set contrast */
302 #define BT848_GCONT _IOR('x', 40, int) /* get contrast */
303 #define BT848_SVSAT _IOW('x', 41, int) /* set chroma V sat */
304 #define BT848_GVSAT _IOR('x', 41, int) /* get V saturation */
305 #define BT848_SUSAT _IOW('x', 42, int) /* set chroma U sat */
306 #define BT848_GUSAT _IOR('x', 42, int) /* get U saturation */
307
308 #define BT848_SCBARS _IOR('x', 43, int) /* set colorbar */
309 #define BT848_CCBARS _IOR('x', 44, int) /* clear colorbar */
310
311
312 #define BT848_SAUDIO _IOW('x', 46, int) /* set audio channel */
313 #define BT848_GAUDIO _IOR('x', 47, int) /* get audio channel */
314 #define BT848_SBTSC _IOW('x', 48, int) /* set audio channel */
315
316 #define BT848_GSTATUS _IOR('x', 49, unsigned int) /* reap status */
317
318 #define BT848_WEEPROM _IOWR('x', 50, struct eeProm) /* write to EEProm */
319 #define BT848_REEPROM _IOWR('x', 51, struct eeProm) /* read from EEProm */
320
321 #define BT848_SIGNATURE _IOWR('x', 52, struct eeProm) /* read card sig */
322
323 #define TVTUNER_SETAFC _IOW('x', 53, int) /* turn AFC on/off */
324 #define TVTUNER_GETAFC _IOR('x', 54, int) /* query AFC on/off */
325 #define BT848_SLNOTCH _IOW('x', 55, int) /* set luma notch */
326 #define BT848_GLNOTCH _IOR('x', 56, int) /* get luma notch */
327
328 /* Read/Write the BT848's I2C bus directly
329 * b7-b0: data (read/write)
330 * b15-b8: internal peripheral register (write)
331 * b23-b16: i2c addr (write)
332 * b31-b24: 1 = write, 0 = read
333 */
334 #define BT848_I2CWR _IOWR('x', 57, u_long) /* i2c read-write */
335
336 /* Support for radio tuner */
337 #define RADIO_SETMODE _IOW('x', 58, unsigned int) /* set radio modes */
338 #define RADIO_GETMODE _IOR('x', 58, unsigned char) /* get radio modes */
339 #define RADIO_AFC 0x01 /* These modes will probably not */
340 #define RADIO_MONO 0x02 /* work on the FRxxxx. It does */
341 #define RADIO_MUTE 0x08 /* work on the FMxxxx. */
342 #define RADIO_SETFREQ _IOW('x', 59, unsigned int) /* set frequency */
343 #define RADIO_GETFREQ _IOR('x', 59, unsigned int) /* set frequency */
344 /* Argument is frequency*100MHz */
345
346 /*
347 * XXX: more bad magic,
348 * we need to fix the METEORGINPUT to return something public
349 * duplicate them here for now...
350 */
351 #define METEOR_DEV0 0x00001000
352 #define METEOR_DEV1 0x00002000
353 #define METEOR_DEV2 0x00004000
354 #define METEOR_DEV3 0x00008000
355 #define METEOR_DEV_SVIDEO 0x00006000
356 /*
357 * right now I don't know were to put these, but as they are suppose to be
358 * a part of a common video capture interface, these should be relocated to
359 * another place. Probably most of the METEOR_xxx defines need to be
360 * renamed and moved to a common header
361 */
362
363 typedef enum { METEOR_PIXTYPE_RGB, METEOR_PIXTYPE_YUV,
364 METEOR_PIXTYPE_YUV_PACKED,
365 METEOR_PIXTYPE_YUV_12 } METEOR_PIXTYPE;
366
367
368 struct meteor_pixfmt {
369 u_int index; /* Index in supported pixfmt list */
370 METEOR_PIXTYPE type; /* What's the board gonna feed us */
371 u_int Bpp; /* Bytes per pixel */
372 u_long masks[3]; /* R,G,B or Y,U,V masks, respectively */
373 unsigned swap_bytes :1; /* Bytes swapped within shorts */
374 unsigned swap_shorts:1; /* Shorts swapped within longs */
375 };
376
377
378 struct bktr_clip {
379 int x_min;
380 int x_max;
381 int y_min;
382 int y_max;
383 };
384
385 #define BT848_MAX_CLIP_NODE 100
386 struct _bktr_clip {
387 struct bktr_clip x[BT848_MAX_CLIP_NODE];
388 };
389
390 /*
391 * I'm using METEOR_xxx just because that will be common to other interface
392 * and less of a surprise
393 */
394 #define METEORSACTPIXFMT _IOW('x', 64, int )
395 #define METEORGACTPIXFMT _IOR('x', 64, int )
396 #define METEORGSUPPIXFMT _IOWR('x', 65, struct meteor_pixfmt)
397
398 /* set clip list */
399 #define BT848SCLIP _IOW('x', 66, struct _bktr_clip )
400 #define BT848GCLIP _IOR('x', 66, struct _bktr_clip )
401
402
403 /* set input format */
404 #define BT848SFMT _IOW('x', 67, unsigned long )
405 #define BT848GFMT _IOR('x', 67, unsigned long )
406
407 /* set clear-buffer-on-start */
408 #define BT848SCBUF _IOW('x', 68, int)
409 #define BT848GCBUF _IOR('x', 68, int)
410
411 /* set capture area */
412 /* The capture area is the area of the video image which is grabbed */
413 /* Usually the capture area is 640x480 (768x576 PAL) pixels */
414 /* This area is then scaled to the dimensions the user requires */
415 /* using the METEORGEO ioctl */
416 /* However, the capture area could be 400x300 pixels from the top right */
417 /* corner of the video image */
418 struct bktr_capture_area {
419 int x_offset;
420 int y_offset;
421 int x_size;
422 int y_size;
423 };
424 #define BT848_SCAPAREA _IOW('x', 69, struct bktr_capture_area)
425 #define BT848_GCAPAREA _IOR('x', 69, struct bktr_capture_area)
426
427
428 /* Get channel Set */
429 #define BT848_MAX_CHNLSET_NAME_LEN 16
430 struct bktr_chnlset {
431 short index;
432 short max_channel;
433 char name[BT848_MAX_CHNLSET_NAME_LEN];
434 };
435 #define TVTUNER_GETCHNLSET _IOWR('x', 70, struct bktr_chnlset)
436
437
438
439 /* Infra Red Remote Control */
440 struct bktr_remote {
441 unsigned char data[3];
442 };
443 #define REMOTE_GETKEY _IOR('x', 71, struct bktr_remote)/*read the remote */
444 /*control receiver*/
445 /*returns raw data*/
446
447
448 /*
449 * Direct access to GPIO pins. You must add BKTR_GPIO_ACCESS to your kernel
450 * configuration file to use these
451 */
452 #define BT848_GPIO_SET_EN _IOW('x', 72, int) /* set gpio_out_en */
453 #define BT848_GPIO_GET_EN _IOR('x', 73, int) /* get gpio_out_en */
454 #define BT848_GPIO_SET_DATA _IOW('x', 74, int) /* set gpio_data */
455 #define BT848_GPIO_GET_DATA _IOR('x', 75, int) /* get gpio_data */
456
457
458
459 /* XXX - Copied from /sys/pci/brktree_reg.h */
460 #define BT848_IFORM_FORMAT (0x7<<0)
461 # define BT848_IFORM_F_RSVD (0x7)
462 # define BT848_IFORM_F_SECAM (0x6)
463 # define BT848_IFORM_F_PALN (0x5)
464 # define BT848_IFORM_F_PALM (0x4)
465 # define BT848_IFORM_F_PALBDGHI (0x3)
466 # define BT848_IFORM_F_NTSCJ (0x2)
467 # define BT848_IFORM_F_NTSCM (0x1)
468 # define BT848_IFORM_F_AUTO (0x0)
469
470
471
472