Ticket #2954: 2954-v4.patch
| File 2954-v4.patch, 35.5 KB (added by , 19 years ago) |
|---|
-
libs/libmythtv/cardutil.h
173 173 174 174 // V4L info 175 175 static bool hasV4L2(int videofd); 176 static bool GetV4LInfo(int videofd, QString &card,QString &driver); 176 static bool GetV4LInfo(int videofd, QString &card, QString &driver, 177 uint32_t &version); 178 static bool GetV4LInfo(int videofd, QString &card, QString &driver) 179 { uint32_t dummy; return GetV4LInfo(videofd, card, driver, dummy); } 177 180 static InputNames probeV4LInputs(int videofd, bool &ok); 178 181 179 182 private: -
libs/libmythtv/mpegrecorder.h
55 55 bool OpenV4L2DeviceAsInput(void); 56 56 bool SetIVTVDeviceOptions(int chanfd); 57 57 bool SetV4L2DeviceOptions(int chanfd); 58 bool SetVBIOptions(int chanfd); 58 59 59 60 void ResetForNewFile(void); 60 61 61 62 bool deviceIsMpegFile; 62 63 int bufferSize; 63 64 65 // Driver info 66 QString card; 67 QString driver; 68 uint32_t version; 69 bool usingv4l2; 70 bool has_buggy_vbi; 71 bool has_v4l2_vbi; 72 64 73 // State 65 74 bool recording; 66 75 bool encoding; -
libs/libmythtv/ivtv_myth.h
1 #define IVTV_IOC_FWAPI 0xFFEE7701 /*just some values i picked for now*/ 2 #define IVTV_IOC_ZCOUNT 0xFFEE7702 3 #ifdef __FreeBSD__ 4 #define IVTV_IOC_G_CODEC _IOR ('V', 73, struct ivtv_ioctl_codec) 5 #define IVTV_IOC_S_CODEC _IOWR ('V', 74, struct ivtv_ioctl_codec) 6 #else 7 #define IVTV_IOC_G_CODEC 0xFFEE7703 8 #define IVTV_IOC_S_CODEC 0xFFEE7704 9 #endif 1 /* 2 Public ivtv API header 3 Copyright (C) 2003-2004 Kevin Thayer <nufan_wfk at yahoo.com> 10 4 11 #define IVTV_MBOX_MAX_DATA 16 5 VBI portions: 6 Copyright (C) 2004 Hans Verkuil <hverkuil@xs4all.nl> 12 7 13 #define IVTV_SLICED_TELETEXT_B (1 << 0) 14 #define IVTV_SLICED_CAPTION_625 (1 << 1) 15 #define IVTV_SLICED_CAPTION_525 (1 << 2) 16 #define IVTV_SLICED_WSS_625 (1 << 3) 17 #define IVTV_SLICED_VPS (1 << 4) 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 18 12 19 struct ivtv_sliced_vbi_format { 20 unsigned long service_set; /* one or more of the IVTV_SLICED_ defines */ 21 unsigned long packet_size; /* the size in bytes of the ivtv_sliced_data packet */ 22 unsigned long io_size; /* maximum number of bytes passed by one read() call */ 23 unsigned long reserved; 24 }; 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 25 17 26 /* This structure is the same as the proposed v4l2_sliced_data structure */ 27 /* id is one of the VBI_SLICED_ flags. */ 28 struct ivtv_sliced_data { 29 unsigned long id; 30 unsigned long line; 31 unsigned char *data; 32 }; 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 33 22 34 /* The four bit VBI data type found in the embedded VBI data of an 35 MPEG stream has one of the following values: */ 36 #define VBI_TYPE_TELETEXT 0x1 // Teletext (uses lines 6-22 for PAL, 10-21 for NTSC) 37 #define VBI_TYPE_CC 0x4 // Closed Captions (line 21 NTSC, line 22 PAL) 38 #define VBI_TYPE_WSS 0x5 // Wide Screen Signal (line 20 NTSC, line 23 PAL) 39 #define VBI_TYPE_VPS 0x7 // Video Programming System (PAL) (line 16) 23 #ifndef _LINUX_IVTV_H 24 #define _LINUX_IVTV_H 40 25 41 /* allow direct access to the saa7115 registers for testing */ 42 #define SAA7115_GET_REG 0xFFEE7705 43 #define SAA7115_SET_REG 0xFFEE7706 26 #define __u32 uint32_t 27 #define __u64 uint64_t 44 28 45 /* to set audio options */ 46 #define DECODER_SET_AUDIO 0xFFEE7707 47 #define DECODER_AUDIO_32_KHZ 0 48 #define DECODER_AUDIO_441_KHZ 1 49 #define DECODER_AUDIO_48_KHZ 2 29 /* NOTE: the ioctls in this file will eventually be replaced by v4l2 API 30 ioctls. */ 50 31 51 #define IVTV_IOC_PLAY 0xFFEE7781 52 #define IVTV_IOC_PAUSE 0xFFEE7782 53 #define IVTV_IOC_FRAMESYNC 0xFFEE7783 54 #define IVTV_IOC_GET_TIMING 0xFFEE7784 55 #define IVTV_IOC_S_SLOW_FAST 0xFFEE7785 56 #define IVTV_IOC_S_START_DECODE 0xFFEE7786 57 #define IVTV_IOC_S_STOP_DECODE 0xFFEE7787 58 #define IVTV_IOC_S_OSD 0xFFEE7788 59 #define IVTV_IOC_GET_FB 0xFFEE7789 32 /* device ioctls should use the range 29-199 */ 33 #define IVTV_IOC_START_DECODE _IOW ('@', 29, struct ivtv_cfg_start_decode) 34 #define IVTV_IOC_STOP_DECODE _IOW ('@', 30, struct ivtv_cfg_stop_decode) 35 #define IVTV_IOC_G_SPEED _IOR ('@', 31, struct ivtv_speed) 36 #define IVTV_IOC_S_SPEED _IOW ('@', 32, struct ivtv_speed) 37 #define IVTV_IOC_DEC_STEP _IOW ('@', 33, int) 38 #define IVTV_IOC_DEC_FLUSH _IOW ('@', 34, int) 39 #define IVTV_IOC_PAUSE_BLACK _IO ('@', 35) 40 #define IVTV_IOC_STOP _IO ('@', 36) 41 #define IVTV_IOC_PLAY _IO ('@', 37) 42 #define IVTV_IOC_PAUSE _IO ('@', 38) 43 #define IVTV_IOC_FRAMESYNC _IOR ('@', 39, struct ivtv_ioctl_framesync) 44 #define IVTV_IOC_GET_TIMING _IOR ('@', 40, struct ivtv_ioctl_framesync) 45 #define IVTV_IOC_S_SLOW_FAST _IOW ('@', 41, struct ivtv_slow_fast) 46 #define IVTV_IOC_GET_FB _IOR ('@', 44, int) 47 #define IVTV_IOC_S_GOP_END _IOWR('@', 50, int) 48 #define IVTV_IOC_S_VBI_PASSTHROUGH _IOW ('@', 51, int) 49 #define IVTV_IOC_G_VBI_PASSTHROUGH _IOR ('@', 52, int) 50 #define IVTV_IOC_PASSTHROUGH _IOW ('@', 53, int) 51 #define IVTV_IOC_PAUSE_ENCODE _IO ('@', 56) 52 #define IVTV_IOC_RESUME_ENCODE _IO ('@', 57) 53 #define IVTV_IOC_DEC_SPLICE _IOW ('@', 58, int) 54 #define IVTV_IOC_DEC_FAST_STOP _IOW ('@', 59, int) 55 #define IVTV_IOC_PREP_FRAME_YUV _IOW ('@', 60, struct ivtvyuv_ioctl_dma_host_to_ivtv_args) 56 #define IVTV_IOC_G_YUV_INTERLACE _IOR ('@', 61, struct ivtv_ioctl_yuv_interlace) 57 #define IVTV_IOC_S_YUV_INTERLACE _IOW ('@', 62, struct ivtv_ioctl_yuv_interlace) 58 #define IVTV_IOC_G_PTS _IOR ('@', 63, u64) 60 59 61 #define IVTV_IOC_START_DECODE _IOW ('@', 29, struct ivtv_cfg_start_decode)62 #define IVTV_IOC_STOP_DECODE _IOW ('@', 30, struct ivtv_cfg_stop_decode)63 #define IVTV_IOC_G_SPEED _IOR ('@', 31, struct ivtv_speed)64 #define IVTV_IOC_S_SPEED _IOW ('@', 32, struct ivtv_speed)65 #define IVTV_IOC_DEC_STEP _IOW ('@', 33, int)66 #define IVTV_IOC_DEC_FLUSH _IOW ('@', 34, int)67 #define IVTV_IOC_S_VBI_MODE _IOWR('@', 35, struct ivtv_sliced_vbi_format)68 #define IVTV_IOC_G_VBI_MODE _IOR ('@', 36, struct ivtv_sliced_vbi_format)69 #define IVTV_IOC_S_VBI_EMBED _IOW ('@', 54, int)70 #define IVTV_IOC_G_VBI_EMBED _IOR ('@', 55, int)71 72 /* ioctl for MSP_SET_MATRIX will have to be registered */73 #define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix)74 75 76 60 /* Custom v4l controls */ 77 61 #ifndef V4L2_CID_PRIVATE_BASE 78 62 #define V4L2_CID_PRIVATE_BASE 0x08000000 79 #endif 63 #endif /* V4L2_CID_PRIVATE_BASE */ 80 64 81 #define V4L2_CID_IVTV_FREQ (V4L2_CID_PRIVATE_BASE )82 #define V4L2_CID_IVTV_ENC (V4L2_CID_PRIVATE_BASE + 1) 83 #define V4L2_CID_IVTV_BITRATE (V4L2_CID_PRIVATE_BASE + 2) 84 #define V4L2_CID_IVTV_MONO (V4L2_CID_PRIVATE_BASE + 3) 85 #define V4L2_CID_IVTV_JOINT (V4L2_CID_PRIVATE_BASE + 4) 86 #define V4L2_CID_IVTV_EMPHASIS (V4L2_CID_PRIVATE_BASE + 5) 87 #define V4L2_CID_IVTV_CRC (V4L2_CID_PRIVATE_BASE + 6) 88 #define V4L2_CID_IVTV_COPYRIGHT (V4L2_CID_PRIVATE_BASE + 7) 89 #define V4L2_CID_IVTV_GEN (V4L2_CID_PRIVATE_BASE + 8) 65 #define V4L2_CID_IVTV_FREQ (V4L2_CID_PRIVATE_BASE + 0) /* old control */ 66 #define V4L2_CID_IVTV_ENC (V4L2_CID_PRIVATE_BASE + 1) /* old control */ 67 #define V4L2_CID_IVTV_BITRATE (V4L2_CID_PRIVATE_BASE + 2) /* old control */ 68 #define V4L2_CID_IVTV_MONO (V4L2_CID_PRIVATE_BASE + 3) /* old control */ 69 #define V4L2_CID_IVTV_JOINT (V4L2_CID_PRIVATE_BASE + 4) /* old control */ 70 #define V4L2_CID_IVTV_EMPHASIS (V4L2_CID_PRIVATE_BASE + 5) /* old control */ 71 #define V4L2_CID_IVTV_CRC (V4L2_CID_PRIVATE_BASE + 6) /* old control */ 72 #define V4L2_CID_IVTV_COPYRIGHT (V4L2_CID_PRIVATE_BASE + 7) /* old control */ 73 #define V4L2_CID_IVTV_GEN (V4L2_CID_PRIVATE_BASE + 8) /* old control */ 90 74 91 #define IVTV_V4L2_AUDIO_MENUCOUNT 9 /* # of v4l controls */ 75 #define V4L2_CID_IVTV_DEC_SMOOTH_FF (V4L2_CID_PRIVATE_BASE + 9) 76 #define V4L2_CID_IVTV_DEC_FR_MASK (V4L2_CID_PRIVATE_BASE + 10) 77 #define V4L2_CID_IVTV_DEC_SP_MUTE (V4L2_CID_PRIVATE_BASE + 11) 78 #define V4L2_CID_IVTV_DEC_FR_FIELD (V4L2_CID_PRIVATE_BASE + 12) 79 #define V4L2_CID_IVTV_DEC_AUD_SKIP (V4L2_CID_PRIVATE_BASE + 13) 80 #define V4L2_CID_IVTV_DEC_NUM_BUFFERS (V4L2_CID_PRIVATE_BASE + 14) 81 #define V4L2_CID_IVTV_DEC_PREBUFFER (V4L2_CID_PRIVATE_BASE + 15) 92 82 93 #define IVTV_DEC_PRIVATE_BASE (V4L2_CID_PRIVATE_BASE + IVTV_V4L2_AUDIO_MENUCOUNT)94 95 #define V4L2_CID_IVTV_DEC_SMOOTH_FF (IVTV_DEC_PRIVATE_BASE + 0)96 #define V4L2_CID_IVTV_DEC_FR_MASK (IVTV_DEC_PRIVATE_BASE + 1)97 #define V4L2_CID_IVTV_DEC_SP_MUTE (IVTV_DEC_PRIVATE_BASE + 2)98 #define V4L2_CID_IVTV_DEC_FR_FIELD (IVTV_DEC_PRIVATE_BASE + 3)99 #define V4L2_CID_IVTV_DEC_AUD_SKIP (IVTV_DEC_PRIVATE_BASE + 4)100 #define V4L2_CID_IVTV_DEC_NUM_BUFFERS (IVTV_DEC_PRIVATE_BASE + 5)101 #define V4L2_CID_IVTV_DEC_PREBUFFER (IVTV_DEC_PRIVATE_BASE + 6)102 103 #define IVTV_V4L2_DEC_MENUCOUNT 7104 105 struct ivtv_ioctl_fwapi {106 uint32_t cmd;107 uint32_t result;108 int32_t args;109 uint32_t data[IVTV_MBOX_MAX_DATA];110 };111 112 83 struct ivtv_ioctl_framesync { 113 uint32_tframe;114 uint64_tpts;115 uint64_tscr;84 __u32 frame; 85 __u64 pts; 86 __u64 scr; 116 87 }; 117 88 118 89 struct ivtv_speed { 119 int scale; /* 1-?? (50 for now) */120 int smooth; /* Smooth mode when in slow/fast mode */121 int speed; /* 0 = slow, 1 = fast */122 int direction; /* 0 = forward, 1 = reverse (not supportd */123 int fr_mask; /* 0 = I, 1 = I,P, 2 = I,P,B 2 = default!*/124 int b_per_gop; /* frames per GOP (reverse only) */125 int aud_mute; /* Mute audio while in slow/fast mode */126 int fr_field; /* 1 = show every field, 0 = show every frame */127 int mute; /* # of audio frames to mute on playback resume */90 int scale; /* 1-?? (50 for now) */ 91 int smooth; /* Smooth mode when in slow/fast mode */ 92 int speed; /* 0 = slow, 1 = fast */ 93 int direction; /* 0 = forward, 1 = reverse (not supportd */ 94 int fr_mask; /* 0 = I, 1 = I,P, 2 = I,P,B 2 = default! */ 95 int b_per_gop; /* frames per GOP (reverse only) */ 96 int aud_mute; /* Mute audio while in slow/fast mode */ 97 int fr_field; /* 1 = show every field, 0 = show every frame */ 98 int mute; /* # of audio frames to mute on playback resume */ 128 99 }; 129 100 130 101 struct ivtv_slow_fast { 131 int speed; /* 0 = slow, 1 = fast */132 int scale; /* 1-?? (50 for now) */133 }; 102 int speed; /* 0 = slow, 1 = fast */ 103 int scale; /* 1-?? (50 for now) */ 104 }; 134 105 135 106 struct ivtv_cfg_start_decode { 136 uint32_tgop_offset; /*Frames in GOP to skip before starting */137 uint32_t muted_audio_frames;/* #of audio frames to mute */107 __u32 gop_offset; /*Frames in GOP to skip before starting */ 108 __u32 muted_audio_frames; /* #of audio frames to mute */ 138 109 }; 139 110 140 111 struct ivtv_cfg_stop_decode { 141 int hide_last;/* 1 = show black after stop,142 0 = show last frame */143 uint64_t pts_stop;/* PTS to stop at */112 int hide_last; /* 1 = show black after stop, 113 0 = show last frame */ 114 __u64 pts_stop; /* PTS to stop at */ 144 115 }; 145 116 146 147 /* For use with IVTV_IOC_G_CODEC and IVTV_IOC_S_CODEC */ 148 struct ivtv_ioctl_codec { 149 uint32_t aspect; 150 uint32_t audio_bitmask; 151 uint32_t bframes; 152 uint32_t bitrate_mode; 153 uint32_t bitrate; 154 uint32_t bitrate_peak; 155 uint32_t dnr_mode; 156 uint32_t dnr_spatial; 157 uint32_t dnr_temporal; 158 uint32_t dnr_type; 159 uint32_t framerate; 160 uint32_t framespergop; 161 uint32_t gop_closure; 162 uint32_t pulldown; 163 uint32_t stream_type; 117 struct ivtv_ioctl_yuv_interlace{ 118 int interlace_mode; /* Takes one of IVTV_YUV_MODE_xxxxxx values */ 119 int threshold; /* If mode is auto then if src_height <= this value treat as progressive otherwise treat as interlaced */ 164 120 }; 121 #define IVTV_YUV_MODE_INTERLACED 0 122 #define IVTV_YUV_MODE_PROGRESSIVE 1 123 #define IVTV_YUV_MODE_AUTO 2 165 124 166 167 struct msp_matrix {168 int input;169 int output;170 };171 172 125 /* Framebuffer external API */ 173 /* NOTE: These must *exactly* match the structures and constants in driver/ivtv.h */174 126 175 127 struct ivtvfb_ioctl_state_info { 176 unsigned long status;177 unsigned long alpha;128 unsigned long status; 129 unsigned long alpha; 178 130 }; 179 131 132 struct ivtvfb_ioctl_colorkey { 133 int state; 134 __u32 colorKey; 135 }; 136 180 137 struct ivtvfb_ioctl_blt_copy_args { 181 int x, y, width, height, source_offset, source_stride;138 int x, y, width, height, source_offset, source_stride; 182 139 }; 183 140 184 141 struct ivtvfb_ioctl_blt_fill_args { 185 int rasterop, alpha_mode, alpha_mask, width, height, x, y;186 unsigned int destPixelMask, colour;142 int rasterop, alpha_mode, alpha_mask, width, height, x, y; 143 unsigned int destPixelMask, colour; 187 144 188 145 }; 189 146 190 147 struct ivtvfb_ioctl_dma_host_to_ivtv_args { 191 void*source;192 unsigned long dest_offset;193 int count;148 void *source; 149 unsigned long dest_offset; 150 int count; 194 151 }; 195 152 153 struct ivtvyuv_ioctl_dma_host_to_ivtv_args { 154 void *y_source; 155 void *uv_source; 156 unsigned int yuv_type; 157 int src_x; 158 int src_y; 159 unsigned int src_w; 160 unsigned int src_h; 161 int dst_x; 162 int dst_y; 163 unsigned int dst_w; 164 unsigned int dst_h; 165 int srcBuf_width; 166 int srcBuf_height; 167 }; 168 196 169 struct ivtvfb_ioctl_get_frame_buffer { 197 void*mem;198 intsize;199 intsizex;200 intsizey;170 void *mem; 171 int size; 172 int sizex; 173 int sizey; 201 174 }; 202 175 203 176 struct ivtv_osd_coords { 204 unsigned long offset;205 unsigned long max_offset;206 int pixel_stride;207 int lines;208 int x;209 int y;177 unsigned long offset; 178 unsigned long max_offset; 179 int pixel_stride; 180 int lines; 181 int x; 182 int y; 210 183 }; 211 184 212 185 struct rectangle { 213 int x0;214 int y0;215 int x1;216 int y1;186 int x0; 187 int y0; 188 int x1; 189 int y1; 217 190 }; 218 191 192 struct ivtvfb_ioctl_set_window { 193 int width; 194 int height; 195 int left; 196 int top; 197 }; 198 199 200 201 /* Framebuffer ioctls should use the range 1 - 28 */ 219 202 #define IVTVFB_IOCTL_GET_STATE _IOR('@', 1, struct ivtvfb_ioctl_state_info) 220 203 #define IVTVFB_IOCTL_SET_STATE _IOW('@', 2, struct ivtvfb_ioctl_state_info) 221 204 #define IVTVFB_IOCTL_PREP_FRAME _IOW('@', 3, struct ivtvfb_ioctl_dma_host_to_ivtv_args) … … 224 207 #define IVTVFB_IOCTL_SET_ACTIVE_BUFFER _IOW('@', 6, struct ivtv_osd_coords) 225 208 #define IVTVFB_IOCTL_GET_FRAME_BUFFER _IOR('@', 7, struct ivtvfb_ioctl_get_frame_buffer) 226 209 #define IVTVFB_IOCTL_BLT_FILL _IOW('@', 8, struct ivtvfb_ioctl_blt_fill_args) 210 #define IVTVFB_IOCTL_PREP_FRAME_BUF _IOW('@', 9, struct ivtvfb_ioctl_dma_host_to_ivtv_args) 211 #define IVTVFB_IOCTL_SET_WINDOW _IOW('@', 11, struct ivtvfb_ioctl_set_window) 212 #define IVTVFB_IOCTL_GET_COLORKEY _IOW('@', 12, struct ivtvfb_ioctl_colorkey) 213 #define IVTVFB_IOCTL_SET_COLORKEY _IOW('@', 13, struct ivtvfb_ioctl_colorkey) 227 214 228 215 #define IVTVFB_STATUS_ENABLED (1 << 0) 229 216 #define IVTVFB_STATUS_GLOBAL_ALPHA (1 << 1) 230 217 #define IVTVFB_STATUS_LOCAL_ALPHA (1 << 2) 231 218 #define IVTVFB_STATUS_FLICKER_REDUCTION (1 << 3) 232 219 233 #define IVTV_IOCTL_SET_DEBUG_LEVEL _IOWR('@', 98, int *) 234 #define IVTV_IOCTL_GET_DEBUG_LEVEL _IOR('@', 99, int *) 220 /********************************************************************/ 221 /* Old stuff */ 222 223 /* Good for versions 0.2.0 through 0.7.x */ 224 #define IVTV_IOC_G_CODEC _IOR ('@', 48, struct ivtv_ioctl_codec) 225 #define IVTV_IOC_S_CODEC _IOW ('@', 49, struct ivtv_ioctl_codec) 226 227 /* For use with IVTV_IOC_G_CODEC and IVTV_IOC_S_CODEC */ 228 struct ivtv_ioctl_codec { 229 __u32 aspect; 230 __u32 audio_bitmask; 231 __u32 bframes; 232 __u32 bitrate_mode; 233 __u32 bitrate; 234 __u32 bitrate_peak; 235 __u32 dnr_mode; 236 __u32 dnr_spatial; 237 __u32 dnr_temporal; 238 __u32 dnr_type; 239 __u32 framerate; 240 __u32 framespergop; 241 __u32 gop_closure; 242 __u32 pulldown; 243 __u32 stream_type; 244 }; 245 246 /********************************************************************/ 247 248 /* Good for versions 0.2.0 through 0.3.x */ 249 #define IVTV_IOC_S_VBI_MODE _IOWR('@', 35, struct ivtv_sliced_vbi_format) 250 #define IVTV_IOC_G_VBI_MODE _IOR ('@', 36, struct ivtv_sliced_vbi_format) 251 252 /* Good for version 0.2.0 through 0.3.7 */ 253 #define IVTV_IOC_S_VBI_EMBED _IOW ('@', 54, int) 254 #define IVTV_IOC_G_VBI_EMBED _IOR ('@', 55, int) 255 256 /* Good for version 0.2.0 through 0.3.7 */ 257 struct ivtv_sliced_vbi_format { 258 unsigned long service_set; /* one or more of the IVTV_SLICED_ defines */ 259 unsigned long packet_size; /* the size in bytes of the ivtv_sliced_data packet */ 260 unsigned long io_size; /* maximum number of bytes passed by one read() call */ 261 unsigned long reserved; 262 }; 263 264 /* Good for version 0.2.0 through 0.3.7 */ 265 struct ivtv_sliced_data { 266 unsigned long id; 267 unsigned long line; 268 unsigned char *data; 269 }; 270 271 /* Good for version 0.2.0 through 0.3.7 for IVTV_IOC_G_VBI_MODE */ 272 /* Good for version 0.3.8 through 0.7.x for IVTV_IOC_S_VBI_PASSTHROUGH */ 273 #define VBI_TYPE_TELETEXT 0x1 // Teletext (uses lines 6-22 for PAL, 10-21 for NTSC) 274 #define VBI_TYPE_CC 0x4 // Closed Captions (line 21 NTSC, line 22 PAL) 275 #define VBI_TYPE_WSS 0x5 // Wide Screen Signal (line 20 NTSC, line 23 PAL) 276 #define VBI_TYPE_VPS 0x7 // Video Programming System (PAL) (line 16) 277 278 #endif /* _LINUX_IVTV_H */ -
libs/libmythtv/cardutil.cpp
483 483 #endif // !USING_V4L 484 484 } 485 485 486 bool CardUtil::GetV4LInfo(int videofd, QString &card, QString &driver) 486 bool CardUtil::GetV4LInfo( 487 int videofd, QString &card, QString &driver, uint32_t &version) 487 488 { 488 489 card = driver = QString::null; 490 version = 0; 489 491 490 492 if (videofd < 0) 491 493 return false; … … 498 500 { 499 501 card.setAscii((char*)capability.card); 500 502 driver.setAscii((char*)capability.driver); 503 version = capability.version; 501 504 } 502 505 else // Fallback to V4L1 query 503 506 { -
libs/libmythtv/mpegrecorder.cpp
33 33 #include "tv_rec.h" 34 34 #include "videodev_myth.h" 35 35 #include "util.h" 36 #include "cardutil.h" 36 37 37 38 // ivtv header 38 39 extern "C" { … … 77 78 // Debugging variables 78 79 deviceIsMpegFile(false), 79 80 bufferSize(4096), 81 // Driver info 82 card(QString::null), driver(QString::null), 83 version(0), usingv4l2(false), 84 has_buggy_vbi(true), has_v4l2_vbi(false), 80 85 // State 81 86 recording(false), encoding(false), 82 87 errored(false), … … 311 316 return false; 312 317 } 313 318 319 if (CardUtil::GetV4LInfo(chanfd, card, driver, version)) 320 { 321 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 322 usingv4l2 = (version >= KERNEL_VERSION(0, 8, 0)); 323 has_v4l2_vbi = (version >= KERNEL_VERSION(0, 3, 8)); 324 has_buggy_vbi = (version < KERNEL_VERSION(0, 10, 0)); 325 } 326 327 VERBOSE(VB_IMPORTANT, QString("IVTV VBI usingv4l2(%1) has_v4l2_vbi(%2) " 328 "has_buggy_vbi(%3)") 329 .arg(usingv4l2).arg(has_v4l2_vbi).arg(has_buggy_vbi)); 330 314 331 struct v4l2_format vfmt; 315 332 bzero(&vfmt, sizeof(vfmt)); 316 333 … … 374 391 "If you are using an AverMedia M179 card this is normal."); 375 392 } 376 393 377 if (!SetV4L2DeviceOptions(chanfd) && !SetIVTVDeviceOptions(chanfd)) 394 bool ok = true; 395 if (usingv4l2) 396 ok = SetV4L2DeviceOptions(chanfd); 397 else 398 { 399 ok = SetIVTVDeviceOptions(chanfd); 400 if (!ok) 401 usingv4l2 = ok = SetV4L2DeviceOptions(chanfd); 402 } 403 404 if (!ok) 378 405 return false; 379 406 407 SetVBIOptions(chanfd); 408 380 409 readfd = open(videodevice.ascii(), O_RDWR | O_NONBLOCK); 381 410 if (readfd < 0) 382 411 { … … 425 454 426 455 keyframedist = (ivtvcodec.framerate) ? 12 : keyframedist; 427 456 428 if (vbimode) 457 return true; 458 } 459 460 static int streamtype_ivtv_to_v4l2(int st) 461 { 462 switch (st) 429 463 { 430 #ifdef IVTV_IOC_S_VBI_MODE 431 struct ivtv_sliced_vbi_format vbifmt; 432 bzero(&vbifmt, sizeof(struct ivtv_sliced_vbi_format)); 433 vbifmt.service_set = (1 == vbimode) ? VBI_TYPE_TELETEXT : VBI_TYPE_CC; 434 435 if (ioctl(chanfd, IVTV_IOC_S_VBI_MODE, &vbifmt) < 0) 436 #endif // IVTV_IOC_S_VBI_MODE 437 { 438 #ifdef V4L2_CAP_SLICED_VBI_CAPTURE 439 struct v4l2_format vbi_fmt; 440 bzero(&vbi_fmt, sizeof(struct v4l2_format)); 441 vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; 442 vbi_fmt.fmt.sliced.service_set = (1 == vbimode) ? 443 V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; 444 445 if (ioctl(chanfd, VIDIOC_S_FMT, &vbi_fmt) < 0) 446 #endif // V4L2_CAP_SLICED_VBI_CAPTURE 447 { 448 VERBOSE(VB_IMPORTANT, "Can't enable VBI recording" + ENO); 449 } 450 } 451 452 #ifdef IVTV_IOC_S_VBI_EMBED 453 int embedon = 1; 454 if (ioctl(chanfd, IVTV_IOC_S_VBI_EMBED, &embedon) < 0) 455 #endif // IVTV_IOC_S_VBI_EMBED 456 { 457 VERBOSE(VB_IMPORTANT, LOC + "Can't enable VBI recording (2)"+ENO); 458 } 459 460 #ifdef IVTV_IOC_G_VBI_MODE 461 ioctl(chanfd, IVTV_IOC_G_VBI_MODE, &vbifmt); 462 463 VERBOSE(VB_RECORD, LOC + QString( 464 "VBI service:%1, packet size:%2, io size:%3") 465 .arg(vbifmt.service_set).arg(vbifmt.packet_size) 466 .arg(vbifmt.io_size)); 467 #endif // IVTV_IOC_G_VBI_MODE 464 case 0: return V4L2_MPEG_STREAM_TYPE_MPEG2_PS; 465 case 1: return V4L2_MPEG_STREAM_TYPE_MPEG2_TS; 466 case 2: return V4L2_MPEG_STREAM_TYPE_MPEG1_VCD; 467 case 3: return V4L2_MPEG_STREAM_TYPE_MPEG2_PS; /* PES A/V */ 468 case 5: return V4L2_MPEG_STREAM_TYPE_MPEG2_PS; /* PES V */ 469 case 7: return V4L2_MPEG_STREAM_TYPE_MPEG2_PS; /* PES A */ 470 case 10: return V4L2_MPEG_STREAM_TYPE_MPEG2_DVD; 471 case 11: return V4L2_MPEG_STREAM_TYPE_MPEG1_VCD; /* VCD */ 472 case 12: return V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD; 473 case 13: return V4L2_MPEG_STREAM_TYPE_MPEG2_DVD; /* DVD-Special 1 */ 474 case 14: return V4L2_MPEG_STREAM_TYPE_MPEG2_DVD; /* DVD-Special 2 */ 475 default: return V4L2_MPEG_STREAM_TYPE_MPEG2_TS; 468 476 } 469 470 return true;471 477 } 472 478 473 479 bool MpegRecorder::SetV4L2DeviceOptions(int chanfd) 474 480 { 475 static const int kNumControls = 7;481 static const uint kNumControls = 7; 476 482 struct v4l2_ext_controls ctrls; 477 483 struct v4l2_ext_control ext_ctrl[kNumControls]; 484 QString control_description[kNumControls] = 485 { 486 "Audio Sampling Frequency", 487 "Video Aspect ratio", 488 "Audio Encoding", 489 "Audio L2 Bitrate", 490 "Video Average Bitrate", 491 "Video Peak Bitrate", 492 "MPEG Stream type", 493 }; 478 494 479 495 // Set controls 480 496 bzero(&ctrls, sizeof(struct v4l2_ext_controls)); … … 512 528 ext_ctrl[5].value = maxbitrate * 1000; 513 529 514 530 ext_ctrl[6].id = V4L2_CID_MPEG_STREAM_TYPE; 515 ext_ctrl[6].value = V4L2_MPEG_STREAM_TYPE_MPEG2_PS; 531 ext_ctrl[6].value = streamtype_ivtv_to_v4l2(streamtype); 532 // only PS supported with new API (at least as of 0.8.0) 533 //ext_ctrl[6].value = V4L2_MPEG_STREAM_TYPE_MPEG2_PS; 516 534 517 ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;518 ctrls.count = kNumControls;519 ctrls.controls = ext_ctrl;535 for (uint i = 0; i < kNumControls; i++) 536 { 537 int value = ext_ctrl[i].value; 520 538 521 if (ioctl(chanfd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0) 522 { 523 if (ctrls.error_idx >= ctrls.count) 539 ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; 540 ctrls.count = 1; 541 ctrls.controls = ext_ctrl + i; 542 543 if (ioctl(chanfd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0) 524 544 { 525 545 VERBOSE(VB_IMPORTANT, LOC_ERR + 526 "Could not set MPEG controls" + ENO); 546 QString("Could not set %1 to %2") 547 .arg(control_description[i]).arg(value) + ENO); 527 548 } 528 else529 {530 VERBOSE(VB_IMPORTANT, LOC_ERR +531 QString("Could not set MPEG controls %1 through %2.")532 .arg(ctrls.error_idx)533 .arg(ext_ctrl[ctrls.error_idx].value) + ENO);534 }535 return false;536 549 } 537 550 538 551 // Get controls … … 552 565 553 566 keyframedist = ext_ctrl[0].value; 554 567 555 // VBI is not yet working as of July 11th, 2006 with IVTV driver. 556 // V4L2_CID_MPEG_STREAM_VBI_FMT needs to be finished/supported first. 557 if (vbimode) 568 return true; 569 } 570 571 bool MpegRecorder::SetVBIOptions(int chanfd) 572 { 573 if (!vbimode) 574 return true; 575 576 if (has_buggy_vbi) 558 577 { 578 VERBOSE(VB_IMPORTANT, LOC_WARN + "VBI recording with broken drivers." 579 "\n\t\t\tUpgrade to ivtv 0.10.0 if you experience problems."); 580 } 581 582 /****************************************************************/ 583 /** First tell driver which services we want to capture. **/ 584 585 #ifdef IVTV_IOC_S_VBI_EMBED 586 // used for ivtv driver versions 0.2.0-3.7.0 587 if (!has_v4l2_vbi) 588 { 589 struct ivtv_sliced_vbi_format vbifmt; 590 bzero(&vbifmt, sizeof(struct ivtv_sliced_vbi_format)); 591 vbifmt.service_set = (1 == vbimode) ? VBI_TYPE_TELETEXT : VBI_TYPE_CC; 592 593 if (ioctl(chanfd, IVTV_IOC_S_VBI_MODE, &vbifmt) < 0) 594 { 595 VERBOSE(VB_IMPORTANT, LOC_WARN + 596 "Can't enable VBI recording (1)" + ENO); 597 598 return false; 599 } 600 601 if (ioctl(chanfd, IVTV_IOC_G_VBI_MODE, &vbifmt) >= 0) 602 { 603 VERBOSE(VB_RECORD, LOC + QString( 604 "VBI service:%1, packet size:%2, io size:%3") 605 .arg(vbifmt.service_set).arg(vbifmt.packet_size) 606 .arg(vbifmt.io_size)); 607 } 608 } 609 #endif // IVTV_IOC_S_VBI_EMBED 610 611 #ifdef IVTV_IOC_S_VBI_PASSTHROUGH 612 // used for ivtv driver versions 0.3.8-0.7.x 613 if (has_v4l2_vbi) 614 { 615 int embedon = (1 == vbimode) ? VBI_TYPE_TELETEXT : VBI_TYPE_CC; 616 617 if (ioctl(chanfd, IVTV_IOC_S_VBI_PASSTHROUGH, &embedon) < 0) 618 { 619 VERBOSE(VB_IMPORTANT, LOC_WARN + 620 "Can't enable VBI recording (2)" + ENO); 621 622 return false; 623 } 624 } 625 #endif // IVTV_IOC_S_VBI_PASSTHROUGH 626 627 #ifdef V4L2_CAP_SLICED_VBI_CAPTURE 628 // valid for ivtv driver versions 0.3.8+ 629 if (has_v4l2_vbi) 630 { 559 631 struct v4l2_format vbifmt; 560 632 bzero(&vbifmt, sizeof(struct v4l2_format)); 561 633 vbifmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE; 562 /* vbifmt.fmt.sliced.service_set = (1==vbimode) ? 563 VBI_TYPE_TELETEXT : VBI_TYPE_CC; */ 564 if (1 == vbimode) 565 vbifmt.fmt.sliced.service_set |= V4L2_SLICED_VBI_625; 566 else 567 vbifmt.fmt.sliced.service_set |= V4L2_SLICED_VBI_525; 634 vbifmt.fmt.sliced.service_set |= (1 == vbimode) ? 635 V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525; 568 636 569 637 if (ioctl(chanfd, VIDIOC_S_FMT, &vbifmt) < 0) 570 638 { 571 VERBOSE(VB_IMPORTANT, "Can't enable VBI recording" + ENO); 639 VERBOSE(VB_IMPORTANT, LOC_WARN + 640 "Can't enable VBI recording (3)" + ENO); 641 642 return false; 572 643 } 573 644 574 struct v4l2_ext_control vbi_fmt; 575 vbi_fmt.id = V4L2_CID_MPEG_STREAM_VBI_FMT; 576 vbi_fmt.value = V4L2_MPEG_STREAM_VBI_FMT_IVTV; 645 if (ioctl(chanfd, VIDIOC_G_FMT, &vbifmt) >= 0) 646 { 647 VERBOSE(VB_RECORD, LOC + QString("VBI service: %1, io size: %2") 648 .arg(vbifmt.fmt.sliced.service_set) 649 .arg(vbifmt.fmt.sliced.io_size)); 650 } 651 } 652 #endif // V4L2_CAP_SLICED_VBI_CAPTURE 653 654 /****************************************************************/ 655 /** Second, tell driver to embed the captions in the stream. **/ 656 657 #ifdef IVTV_IOC_S_VBI_EMBED 658 // used for ivtv driver versions 0.2.0-0.7.x 659 if (!usingv4l2) 660 { 661 int embedon = 1; 662 if (ioctl(chanfd, IVTV_IOC_S_VBI_EMBED, &embedon) < 0) 663 { 664 VERBOSE(VB_IMPORTANT, LOC_WARN + 665 "Can't enable VBI recording (4)" + ENO); 666 667 return false; 668 } 669 } 670 #endif // IVTV_IOC_S_VBI_EMBED 671 672 #ifdef V4L2_CAP_SLICED_VBI_CAPTURE 673 // used for ivtv driver versions 0.8.0+ 674 if (usingv4l2) 675 { 676 struct v4l2_ext_control vbi_ctrl; 677 vbi_ctrl.id = V4L2_CID_MPEG_STREAM_VBI_FMT; 678 vbi_ctrl.value = V4L2_MPEG_STREAM_VBI_FMT_IVTV; 679 680 struct v4l2_ext_controls ctrls; 681 bzero(&ctrls, sizeof(struct v4l2_ext_controls)); 577 682 ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG; 578 683 ctrls.count = 1; 579 ctrls.controls = &vbi_fmt; 684 ctrls.controls = &vbi_ctrl; 685 580 686 if (ioctl(chanfd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0) 581 687 { 582 VERBOSE(VB_IMPORTANT, LOC + "Can't enable VBI recording (2)"+ENO); 688 VERBOSE(VB_IMPORTANT, LOC_WARN + 689 "Can't enable VBI recording (5)" + ENO); 690 691 return false; 583 692 } 584 585 ioctl(chanfd, VIDIOC_G_FMT, &vbifmt);586 587 VERBOSE(VB_RECORD, LOC + QString(588 "VBI service:%1, io size:%3")589 .arg(vbifmt.fmt.sliced.service_set)590 .arg(vbifmt.fmt.sliced.io_size));591 693 } 694 #endif // V4L2_CAP_SLICED_VBI_CAPTURE 592 695 593 696 return true; 594 697 } -
libs/libmythtv/recordingprofile.cpp
847 847 class Width : public SpinBoxSetting, public CodecParamStorage 848 848 { 849 849 public: 850 Width(const RecordingProfile &parent, int maxwidth = 704, 850 Width(const RecordingProfile &parent, 851 uint defaultwidth, uint maxwidth, 851 852 bool transcoding = false) : 852 853 SpinBoxSetting(this, transcoding ? 0 : 160, 853 854 maxwidth, 16, false, … … 855 856 CodecParamStorage(this, parent, "width") 856 857 { 857 858 setLabel(QObject::tr("Width")); 858 setValue(480); 859 if (transcoding) 860 setHelpText(QObject::tr("If the width is set to 'Auto', " 861 "the width will be calculated based on the height " 862 "and the recording's physical aspect ratio.")); 859 setValue(defaultwidth); 860 861 QString help = (transcoding) ? 862 QObject::tr("If the width is set to 'Auto', the width " 863 "will be calculated based on the height and " 864 "the recording's physical aspect ratio.") : 865 QObject::tr("Width to use for encoding. " 866 "Note: PVR-150 and PVR-500 devices do not " 867 "function correctly unless this is set to 720."); 868 869 setHelpText(help); 863 870 }; 864 871 }; 865 872 866 873 class Height: public SpinBoxSetting, public CodecParamStorage 867 874 { 868 875 public: 869 Height(const RecordingProfile &parent, int maxheight=576, 876 Height(const RecordingProfile &parent, 877 uint defaultheight, uint maxheight, 870 878 bool transcoding = false): 871 879 SpinBoxSetting(this, transcoding ? 0 : 160, 872 880 maxheight, 16, false, … … 874 882 CodecParamStorage(this, parent, "height") 875 883 { 876 884 setLabel(QObject::tr("Height")); 877 setValue(480); 878 if (transcoding) 879 setHelpText(QObject::tr("If the height is set to 'Auto', " 880 "the height will be calculated based on the width " 881 "and the recording's physical aspect ratio.")); 885 setValue(defaultheight); 886 887 QString help = (transcoding) ? 888 QObject::tr("If the height is set to 'Auto', the height " 889 "will be calculated based on the width and " 890 "the recording's physical aspect ratio.") : 891 QObject::tr("Height to use for encoding. " 892 "Note: PVR-150 and PVR-500 devices do not " 893 "function correctly unless this is set to " 894 "480 or 576 for NTSC and PAL, respectively."); 895 896 setHelpText(help); 882 897 }; 883 898 }; 884 899 … … 894 909 labelName = profName + "->" + QObject::tr("Image size"); 895 910 setLabel(labelName); 896 911 897 QString fullsize, halfsize; 898 int maxwidth, maxheight; 899 bool transcoding = false; 900 if (profName.left(11) == "Transcoders") { 901 maxwidth = 1920; 902 maxheight = 1088; 903 transcoding = true; 904 } else if ((tvFormat.lower() == "ntsc") || 905 (tvFormat.lower() == "ntsc-jp")) { 906 maxwidth = 720; 907 maxheight = 480; 908 } else if (tvFormat.lower() == "atsc") { 909 maxwidth = 1920; 910 maxheight = 1088; 911 } else { 912 maxwidth = 768; 913 maxheight = 576; 912 QSize defaultsize(768, 576), maxsize(768, 576); 913 bool transcoding = profName.left(11) == "Transcoders"; 914 bool ivtv = profName.left(34) == "MPEG-2 Encoders (PVR-x50, PVR-500)"; 915 916 if (transcoding) 917 { 918 maxsize = QSize(1920, 1088); 919 defaultsize = QSize(480, 480); 914 920 } 921 else if (tvFormat.lower().left(4) == "ntsc") 922 { 923 maxsize = QSize(720, 480); 924 defaultsize = (ivtv) ? QSize(720, 480) : QSize(480, 480); 925 } 926 else if (tvFormat.lower() == "atsc") 927 { 928 maxsize = QSize(1920, 1088); 929 defaultsize = QSize(1920, 1088); 930 } 931 else 932 { 933 maxsize = QSize(768, 576); 934 defaultsize = (ivtv) ? QSize(720, 576) : QSize(480, 576); 935 } 915 936 916 imgSize->addChild(new Width(parent, maxwidth, transcoding)); 917 imgSize->addChild(new Height(parent, maxheight, transcoding)); 937 imgSize->addChild(new Width(parent, defaultsize.width(), 938 maxsize.width(), transcoding)); 939 imgSize->addChild(new Height(parent, defaultsize.height(), 940 maxsize.height(), transcoding)); 941 918 942 addChild(imgSize); 919 943 }; 920 944 }; … … 1001 1025 { 1002 1026 MSqlQuery result(MSqlQuery::InitCon()); 1003 1027 result.prepare( 1004 "SELECT cardtype "1028 "SELECT cardtype, profilegroups.name " 1005 1029 "FROM profilegroups, recordingprofiles " 1006 1030 "WHERE profilegroups.id = recordingprofiles.profilegroup AND " 1007 1031 " recordingprofiles.id = :PROFILEID"); … … 1013 1037 else if (result.next()) 1014 1038 { 1015 1039 type = result.value(0).toString(); 1040 if (profileName.isEmpty()) 1041 profileName = result.value(1).toString(); 1016 1042 isEncoder = CardUtil::IsEncoder(type); 1017 1043 } 1018 1044
