1 /* 2 * tvcapture.h 3 * 4 * API for determining basic capabilities of the video card on an 5 * X server screen. 6 * 7 * (C) 1997 Randall Hopper 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions are 11 * met: 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 2. 13 * Redistributions in binary form must reproduce the above copyright notice, 14 * this list of conditions and the following disclaimer in the documentation 15 * and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 */ 30 31 #ifndef __TVCAPTURE_H 32 #define __TVCAPTURE_H 33 34 #include <X11/Intrinsic.h> 35 #ifdef __NetBSD__ 36 # include <dev/ic/bt8xx.h> 37 #endif 38 #ifdef __FreeBSD__ 39 #include <osreldate.h> 40 #if __FreeBSD_version > 500000 41 #include <dev/bktr/ioctl_meteor.h> 42 #else 43 #include <machine/ioctl_meteor.h> 44 #endif 45 #endif 46 #include "tvtypes.h" 47 48 #define TV_CHAN_MIN 1 49 #define TV_CHAN_MAX 99 50 #define TV_MAX_CHANNELS ( TV_CHAN_MAX - TV_CHAN_MIN + 1 ) 51 52 /* scaling factor for tuner frequencies expressed as ints */ 53 /* FIXME: From brooktree.c. Should be defined in ioctl_bt848.h */ 54 #define FREQFACTOR 16 55 56 typedef enum { 57 TV_FIELD_SUPPRESS, 58 TV_FIELD_DISPLAY, 59 TV_FIELD_DISK 60 } TV_FIELD_TARGET; 61 62 typedef enum { 63 TV_CAPTURE_SINGLE, 64 TV_CAPTURE_CONTINUOUS 65 } TV_CAPTURE_MODE; 66 67 typedef enum { 68 TV_DEVICE_TUNER, 69 TV_DEVICE_VIDEO, 70 TV_DEVICE_SVIDEO, 71 TV_DEVICE_CSVIDEO, 72 TV_DEVICE_DEV3, 73 TV_NUM_INPUT_DEVICES 74 } TV_INPUT_DEVICE; 75 76 typedef enum { 77 TV_AUDIO_INPUT_AUTO, 78 TV_AUDIO_INPUT_TUNER, 79 TV_AUDIO_INPUT_EXTERN, 80 TV_AUDIO_INPUT_INTERN 81 } TV_AUDIO_INPUT_DEVICE; 82 83 typedef enum { 84 TV_INPUT_AUTO, 85 TV_INPUT_NTSCM, 86 TV_INPUT_NTSCJ, 87 TV_INPUT_PALBDGHI, 88 TV_INPUT_PALM, 89 TV_INPUT_PALN, 90 TV_INPUT_SECAM, 91 TV_INPUT_PALNCOMB 92 } TV_INPUT_FORMAT; 93 94 typedef int TV_FREQ_SET; 95 96 typedef enum { 97 TV_PARAM_HUE, 98 TV_PARAM_BRIGHT, 99 TV_PARAM_CONTRAST, 100 TV_PARAM_SATU, 101 TV_PARAM_SATV, 102 } TV_DRIVER_PARAM; 103 104 typedef enum { 105 TV_PIXELTYPE_RGB, 106 TV_PIXELTYPE_YUV 107 } TV_PIXELTYPE; 108 109 typedef struct { 110 TV_INPUT_DEVICE input_dev; 111 TV_INPUT_FORMAT input_fmt; 112 TV_AUDIO_INPUT_DEVICE audio_input_dev; 113 TV_BOOL audio_mute; 114 115 double brightness; 116 double contrast; 117 double hue; 118 double sat_u; 119 double sat_v; 120 TV_UINT32 signal; 121 TV_FREQ_SET tuner_freq_set; 122 TV_BOOL tuner_chan_active; 123 TV_UINT32 tuner_chan; 124 double tuner_freq; 125 TV_UINT32 fps; 126 struct { 127 long frames_captured; 128 } stats; 129 130 } TV_DRIVER_STATE; 131 132 typedef enum { 133 TV_FRAME_PLANAR, /* E.g. YYYYY..UUUUU...VVVVV */ 134 TV_FRAME_PACKED /* E.g. YVUVYVUV... */ 135 } TV_FRAME_PACKING; 136 137 typedef struct { 138 TV_INT32 index; /* Drvr hdlr for pix fmt */ 139 TV_PIXELTYPE type; /* RGB, YUV */ 140 141 /* RGB-only attributes */ 142 TV_UINT32 Bpp; /* Bytes per pixel */ 143 TV_UINT32 mask[3]; /* Pixel masks */ 144 unsigned swap_bytes :1; /* Bytes in shorts swapped */ 145 unsigned swap_shorts :1; /* Shorts in longs swapped */ 146 147 /* YUV-only attributes */ 148 TV_UINT32 samp_size[3]; /* [YUV] Bits per sample */ 149 TV_UINT32 samp_int_h[3]; /* [YUV] Horiz samp interval */ 150 TV_UINT32 samp_int_v[3]; /* [YUV] Vert samp interval */ 151 TV_FRAME_PACKING frame_packing; /* Order YUV data is stored */ 152 char comp_order[30]; /* "YUYV", "YVU", etc. */ 153 unsigned order_t_to_b :1; /* Scanline order TtoB;BtoT */ 154 unsigned order_l_to_r :1; /* Column order RtoL;LtoR */ 155 unsigned y_trans :1; /* LSb Y = transparency? */ 156 157 } TV_PIXEL_GEOM; 158 159 typedef struct { 160 TV_INT8 *buf; /* Pixel data */ 161 TV_GEOM geom; /* Dimensional geometry */ 162 TV_PIXEL_GEOM pix_geom; /* Pixel geometry */ 163 } TV_IMAGE; 164 165 typedef struct { 166 167 int fd; 168 int tfd; 169 TV_UINT8 *drv_buf; 170 171 TV_INT32 input_format; 172 TV_INT32 input_dev; 173 TV_AUDIO_INPUT_DEVICE audio_input_dev; 174 175 TV_UINT32 fps; 176 TV_INT32 bpp_format; 177 TV_CAPTURE_MODE cap_mode; 178 TV_TRANSFER_MODE xfer_mode; 179 TV_PIXEL_GEOM *pix_geom_list; 180 TV_UINT32 pix_geom_list_len; 181 TV_UINT32 pix_geom_idx; 182 TV_BOOL tuner_chan_active; /* FIXME: this is a hack */ 183 184 TV_FIELD_TARGET field_targ[2]; 185 double brightness; 186 double contrast; 187 double hue; 188 double sat_u; 189 double sat_v; 190 TV_UINT32 addr; 191 TV_GEOM geom; 192 193 void (*frame_done_cb)( TV_IMAGE *img ); 194 TV_BOOL frame_cb_enabled; 195 196 TV_INT32 width_min , width_max , width_res; 197 TV_INT32 height_min, height_max, height_res; 198 TV_UINT32 fps_max; 199 200 TV_BOOL contin_on; 201 202 } TV_CAPTURE; 203 204 205 #ifdef __cplusplus 206 extern "C" { 207 #endif 208 209 void TVCAPTUREInit( TV_CAPTURE *c ); 210 211 /* Primary capture parameters */ 212 void TVCAPTURESetCaptureMode ( TV_CAPTURE *c, TV_CAPTURE_MODE cap_mode ); 213 void TVCAPTURESetTransferMode( TV_CAPTURE *c, TV_TRANSFER_MODE xfer_mode ); 214 void TVCAPTURESetRegionGeom ( TV_CAPTURE *c, TV_GEOM *reg_geom ); 215 void TVCAPTURESetPixelGeom ( TV_CAPTURE *c, TV_PIXEL_GEOM *pix_geom ); 216 217 /* Capture control */ 218 TV_BOOL TVCAPTUREValidRegionGeom( TV_CAPTURE *c, TV_GEOM *reg_geom ); 219 TV_BOOL TVCAPTUREConfigure( TV_CAPTURE *c, char **fail_reason ); 220 void TVCAPTUREStart ( TV_CAPTURE *c ); 221 void TVCAPTUREStop ( TV_CAPTURE *c ); 222 223 /* Secondary capture parameters */ 224 void TVCAPTURESetBrightness ( TV_CAPTURE *c, double brightness ); 225 void TVCAPTURESetContrast ( TV_CAPTURE *c, double contrast ); 226 void TVCAPTURESetHue ( TV_CAPTURE *c, double hue ); 227 void TVCAPTURESetSatU ( TV_CAPTURE *c, double sat_u ); 228 void TVCAPTURESetSatV ( TV_CAPTURE *c, double sat_v ); 229 void TVCAPTURESetInputFormat ( TV_CAPTURE *c, TV_INPUT_FORMAT format ); 230 void TVCAPTURESetInputDevice ( TV_CAPTURE *c, TV_INPUT_DEVICE dev ); 231 void TVCAPTURESetAudioInputDevice( TV_CAPTURE *c, TV_AUDIO_INPUT_DEVICE dev ); 232 void TVCAPTURESetTunerFreqSet( TV_CAPTURE *c, TV_FREQ_SET set ); 233 void TVCAPTURESetTunerChannel( TV_CAPTURE *c, TV_INT32 chan_num ); 234 void TVCAPTURESetTunerFreq ( TV_CAPTURE *c, double freq ); 235 char *TVCAPTUREGetTunerFreqSetName( TV_CAPTURE *c, TV_FREQ_SET set ); 236 void TVCAPTURESetAfc ( TV_CAPTURE *c, TV_BOOL afc ); 237 void TVCAPTURESetAudioMute ( TV_CAPTURE *c, TV_BOOL mute ); 238 void TVCAPTURESetColorbars ( TV_CAPTURE *c, TV_BOOL colorbars ); 239 void TVCAPTURESetFPS ( TV_CAPTURE *c, TV_UINT32 fps ); 240 241 void TVCAPTURESetAppearanceParam( TV_CAPTURE *c, TV_DRIVER_PARAM p, 242 double val ); 243 244 TV_BOOL TVCAPTUREQueryDriverState( TV_CAPTURE *c, TV_DRIVER_STATE *s ); 245 void TVCAPTUREQueryParamLimits( TV_CAPTURE *c, TV_DRIVER_PARAM p, 246 double lim[2] ); 247 248 void TVCAPTUREGetNumPixFmts( TV_CAPTURE *c, TV_UINT32 *num ); 249 void TVCAPTUREGetNthPixFmt ( TV_CAPTURE *c, TV_UINT32 index, 250 TV_PIXEL_GEOM *geom ); 251 252 void TVCAPTUREGetPixFmtByPixGeom( TV_CAPTURE *c, TV_PIXEL_GEOM *geom, 253 TV_INT32 *index ); 254 255 void TVCAPTUREGetFPSMax( TV_CAPTURE *c, TV_UINT32 *fps_max ); 256 257 /* Utility */ 258 void TVCAPTURESetFrameDoneCBEnabled( TV_CAPTURE *c, TV_BOOL enable ); 259 void TVCAPTUREWorkProc(); 260 261 void TVCAPTUREClearPendingFrames(); 262 TV_BOOL TVCAPTUREGetPendingFrame( TV_IMAGE **img ); 263 264 #ifdef __cplusplus 265 } /* Close 'extern "C"' */ 266 #endif 267 268 #endif 269