Ticket #3486: 3486-v2.patch
File 3486-v2.patch, 50.9 KB (added by , 18 years ago) |
---|
-
libs/libmythtv/videoout_ivtv.h
1 1 #ifndef VIDEOOUT_IVTV_H_ 2 2 #define VIDEOOUT_IVTV_H_ 3 3 4 #include <linux/fb.h> 5 4 6 #include <qstring.h> 5 7 #include <qmutex.h> 6 8 #include <cassert> 7 9 8 10 #include "videooutbase.h" 11 #include "ivtv_myth.h" 9 12 10 13 class NuppelVideoPlayer; 11 14 … … 79 82 80 83 void ShowPip(VideoFrame *frame, NuppelVideoPlayer *pipplayer); 81 84 void SetAlpha(eAlphaState newAlpha); 85 void SetColorKey(int state, int color); 82 86 long long GetFirmwareFramesPlayed(void); 83 87 84 88 int videofd; … … 113 117 bool last_normal; 114 118 int last_mask; 115 119 eAlphaState alphaState; 120 121 bool old_fb_ioctl; 122 bool v4l2_api; 123 int fb_dma_ioctl; 124 bool color_key; 125 bool decoder_flush; 126 struct fb_var_screeninfo ivtvfb_var; 127 struct fb_var_screeninfo ivtvfb_var_old; 116 128 }; 117 129 118 130 #endif -
libs/libmythtv/videodev2_myth.h
1 #ifndef __LINUX_VIDEODEV2_H2 #define __LINUX_VIDEODEV2_H3 1 /* 4 * Video for Linux Two2 * Video for Linux Two header file 5 3 * 6 * Header file for v4l or V4L2 drivers and applications, for 7 * Linux kernels 2.2.x or 2.4.x. 4 * Copyright (C) 1999-2007 the contributors 8 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * Alternatively you can redistribute this file under the terms of the 17 * BSD license as stated below: 18 * 19 * Redistribution and use in source and binary forms, with or without 20 * modification, are permitted provided that the following conditions 21 * are met: 22 * 1. Redistributions of source code must retain the above copyright 23 * notice, this list of conditions and the following disclaimer. 24 * 2. Redistributions in binary form must reproduce the above copyright 25 * notice, this list of conditions and the following disclaimer in 26 * the documentation and/or other materials provided with the 27 * distribution. 28 * 3. The names of its contributors may not be used to endorse or promote 29 * products derived from this software without specific prior written 30 * permission. 31 * 32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 36 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 38 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 39 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 40 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 41 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 42 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 43 * 44 * Header file for v4l or V4L2 drivers and applications 45 * with public API. 46 * All kernel-specific stuff were moved to media/v4l2-dev.h, so 47 * no #if __KERNEL tests are allowed here 48 * 9 49 * See http://linuxtv.org for more info 10 50 * 11 * Author: Bill Dirks <b dirks@pacbell.net>51 * Author: Bill Dirks <bill@thedirks.org> 12 52 * Justin Schoeman 53 * Hans Verkuil <hverkuil@xs4all.nl> 13 54 * et al. 14 55 */ 15 56 #ifndef __LINUX_VIDEODEV2_H 57 #define __LINUX_VIDEODEV2_H 58 #include <sys/time.h> 16 59 #include <sys/types.h> 17 60 18 #define __user19 20 #define OBSOLETE_OWNER 1 /* It will be removed for 2.6.15 */21 #define HAVE_V4L2 122 23 61 /* 24 62 * Common stuff for both V4L1 and V4L2 25 63 * Moved from videodev.h 26 64 */ 27 28 65 #define VIDEO_MAX_FRAME 32 29 66 30 67 #define VID_TYPE_CAPTURE 1 /* Can capture */ … … 54 91 * E N U M S 55 92 */ 56 93 enum v4l2_field { 57 V4L2_FIELD_ANY = 0, /* driver can choose from none, 58 top, bottom, interlaced 59 depending on whatever it thinks 60 is approximate ... */ 61 V4L2_FIELD_NONE = 1, /* this device has no fields ... */ 62 V4L2_FIELD_TOP = 2, /* top field only */ 63 V4L2_FIELD_BOTTOM = 3, /* bottom field only */ 64 V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ 65 V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one 66 buffer, top-bottom order */ 67 V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ 68 V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into 69 separate buffers */ 94 V4L2_FIELD_ANY = 0, /* driver can choose from none, 95 top, bottom, interlaced 96 depending on whatever it thinks 97 is approximate ... */ 98 V4L2_FIELD_NONE = 1, /* this device has no fields ... */ 99 V4L2_FIELD_TOP = 2, /* top field only */ 100 V4L2_FIELD_BOTTOM = 3, /* bottom field only */ 101 V4L2_FIELD_INTERLACED = 4, /* both fields interlaced */ 102 V4L2_FIELD_SEQ_TB = 5, /* both fields sequential into one 103 buffer, top-bottom order */ 104 V4L2_FIELD_SEQ_BT = 6, /* same as above + bottom-top order */ 105 V4L2_FIELD_ALTERNATE = 7, /* both fields alternating into 106 separate buffers */ 107 V4L2_FIELD_INTERLACED_TB = 8, /* both fields interlaced, top field 108 first and the top field is 109 transmitted first */ 110 V4L2_FIELD_INTERLACED_BT = 9, /* both fields interlaced, top field 111 first and the bottom field is 112 transmitted first */ 70 113 }; 71 114 #define V4L2_FIELD_HAS_TOP(field) \ 72 115 ((field) == V4L2_FIELD_TOP ||\ 73 116 (field) == V4L2_FIELD_INTERLACED ||\ 117 (field) == V4L2_FIELD_INTERLACED_TB ||\ 118 (field) == V4L2_FIELD_INTERLACED_BT ||\ 74 119 (field) == V4L2_FIELD_SEQ_TB ||\ 75 120 (field) == V4L2_FIELD_SEQ_BT) 76 121 #define V4L2_FIELD_HAS_BOTTOM(field) \ 77 122 ((field) == V4L2_FIELD_BOTTOM ||\ 78 123 (field) == V4L2_FIELD_INTERLACED ||\ 124 (field) == V4L2_FIELD_INTERLACED_TB ||\ 125 (field) == V4L2_FIELD_INTERLACED_BT ||\ 79 126 (field) == V4L2_FIELD_SEQ_TB ||\ 80 127 (field) == V4L2_FIELD_SEQ_BT) 81 128 #define V4L2_FIELD_HAS_BOTH(field) \ 82 129 ((field) == V4L2_FIELD_INTERLACED ||\ 83 (field) == V4L2_FIELD_SEQ_TB ||\ 130 (field) == V4L2_FIELD_INTERLACED_TB ||\ 131 (field) == V4L2_FIELD_INTERLACED_BT ||\ 132 (field) == V4L2_FIELD_SEQ_TB ||\ 84 133 (field) == V4L2_FIELD_SEQ_BT) 85 134 86 135 enum v4l2_buf_type { 87 V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, 88 V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, 89 V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, 90 V4L2_BUF_TYPE_VBI_CAPTURE = 4, 91 V4L2_BUF_TYPE_VBI_OUTPUT = 5, 136 V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, 137 V4L2_BUF_TYPE_VIDEO_OUTPUT = 2, 138 V4L2_BUF_TYPE_VIDEO_OVERLAY = 3, 139 V4L2_BUF_TYPE_VBI_CAPTURE = 4, 140 V4L2_BUF_TYPE_VBI_OUTPUT = 5, 141 V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, 142 V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, 92 143 #if 1 93 /* Experimental Sliced VBI */ 94 V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6, 95 V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7, 144 /* Experimental */ 145 V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8, 96 146 #endif 97 V4L2_BUF_TYPE_PRIVATE = 0x80,147 V4L2_BUF_TYPE_PRIVATE = 0x80, 98 148 }; 99 149 100 150 enum v4l2_ctrl_type { … … 185 235 #define V4L2_CAP_VIDEO_OVERLAY 0x00000004 /* Can do video overlay */ 186 236 #define V4L2_CAP_VBI_CAPTURE 0x00000010 /* Is a raw VBI capture device */ 187 237 #define V4L2_CAP_VBI_OUTPUT 0x00000020 /* Is a raw VBI output device */ 188 #if 1189 238 #define V4L2_CAP_SLICED_VBI_CAPTURE 0x00000040 /* Is a sliced VBI capture device */ 190 239 #define V4L2_CAP_SLICED_VBI_OUTPUT 0x00000080 /* Is a sliced VBI output device */ 191 #endif192 240 #define V4L2_CAP_RDS_CAPTURE 0x00000100 /* RDS data capture */ 241 #define V4L2_CAP_VIDEO_OUTPUT_OVERLAY 0x00000200 /* Can do video output overlay */ 193 242 194 243 #define V4L2_CAP_TUNER 0x00010000 /* has a tuner */ 195 244 #define V4L2_CAP_AUDIO 0x00020000 /* has audio support */ … … 202 251 /* 203 252 * V I D E O I M A G E F O R M A T 204 253 */ 205 206 254 struct v4l2_pix_format 207 255 { 208 256 __u32 width; … … 243 291 #define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y','U','1','2') /* 12 YUV 4:2:0 */ 244 292 #define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y','Y','U','V') /* 16 YUV 4:2:2 */ 245 293 #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H','I','2','4') /* 8 8-bit color */ 246 #define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:1:1 16x16 macroblocks */ 294 #define V4L2_PIX_FMT_HM12 v4l2_fourcc('H','M','1','2') /* 8 YUV 4:2:0 16x16 macroblocks */ 295 #define V4L2_PIX_FMT_RGB444 v4l2_fourcc('R','4','4','4') /* 16 xxxxrrrr ggggbbbb */ 247 296 248 297 /* see http://www.siliconimaging.com/RGB%20Bayer.htm */ 249 298 #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ … … 276 325 277 326 #define V4L2_FMT_FLAG_COMPRESSED 0x0001 278 327 328 #if 1 329 /* Experimental Frame Size and frame rate enumeration */ 330 /* 331 * F R A M E S I Z E E N U M E R A T I O N 332 */ 333 enum v4l2_frmsizetypes 334 { 335 V4L2_FRMSIZE_TYPE_DISCRETE = 1, 336 V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, 337 V4L2_FRMSIZE_TYPE_STEPWISE = 3, 338 }; 279 339 340 struct v4l2_frmsize_discrete 341 { 342 __u32 width; /* Frame width [pixel] */ 343 __u32 height; /* Frame height [pixel] */ 344 }; 345 346 struct v4l2_frmsize_stepwise 347 { 348 __u32 min_width; /* Minimum frame width [pixel] */ 349 __u32 max_width; /* Maximum frame width [pixel] */ 350 __u32 step_width; /* Frame width step size [pixel] */ 351 __u32 min_height; /* Minimum frame height [pixel] */ 352 __u32 max_height; /* Maximum frame height [pixel] */ 353 __u32 step_height; /* Frame height step size [pixel] */ 354 }; 355 356 struct v4l2_frmsizeenum 357 { 358 __u32 index; /* Frame size number */ 359 __u32 pixel_format; /* Pixel format */ 360 __u32 type; /* Frame size type the device supports. */ 361 362 union { /* Frame size */ 363 struct v4l2_frmsize_discrete discrete; 364 struct v4l2_frmsize_stepwise stepwise; 365 }; 366 367 __u32 reserved[2]; /* Reserved space for future use */ 368 }; 369 280 370 /* 371 * F R A M E R A T E E N U M E R A T I O N 372 */ 373 enum v4l2_frmivaltypes 374 { 375 V4L2_FRMIVAL_TYPE_DISCRETE = 1, 376 V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, 377 V4L2_FRMIVAL_TYPE_STEPWISE = 3, 378 }; 379 380 struct v4l2_frmival_stepwise 381 { 382 struct v4l2_fract min; /* Minimum frame interval [s] */ 383 struct v4l2_fract max; /* Maximum frame interval [s] */ 384 struct v4l2_fract step; /* Frame interval step size [s] */ 385 }; 386 387 struct v4l2_frmivalenum 388 { 389 __u32 index; /* Frame format index */ 390 __u32 pixel_format; /* Pixel format */ 391 __u32 width; /* Frame width */ 392 __u32 height; /* Frame height */ 393 __u32 type; /* Frame interval type the device supports. */ 394 395 union { /* Frame interval */ 396 struct v4l2_fract discrete; 397 struct v4l2_frmival_stepwise stepwise; 398 }; 399 400 __u32 reserved[2]; /* Reserved space for future use */ 401 }; 402 #endif 403 404 /* 281 405 * T I M E C O D E 282 406 */ 283 407 struct v4l2_timecode … … 307 431 /* The above is based on SMPTE timecodes */ 308 432 309 433 310 /*311 * M P E G C O M P R E S S I O N P A R A M E T E R S312 *313 * ### WARNING: This experimental MPEG compression API is obsolete.314 * ### It is replaced by the MPEG controls API.315 * ### This old API will disappear in the near future!316 *317 */318 319 320 enum v4l2_bitrate_mode {321 V4L2_BITRATE_NONE = 0, /* not specified */322 V4L2_BITRATE_CBR, /* constant bitrate */323 V4L2_BITRATE_VBR, /* variable bitrate */324 };325 struct v4l2_bitrate {326 /* rates are specified in kbit/sec */327 enum v4l2_bitrate_mode mode;328 __u32 min;329 __u32 target; /* use this one for CBR */330 __u32 max;331 };332 333 enum v4l2_mpeg_streamtype {334 V4L2_MPEG_SS_1, /* MPEG-1 system stream */335 V4L2_MPEG_PS_2, /* MPEG-2 program stream */336 V4L2_MPEG_TS_2, /* MPEG-2 transport stream */337 V4L2_MPEG_PS_DVD, /* MPEG-2 program stream with DVD header fixups */338 };339 enum v4l2_mpeg_audiotype {340 V4L2_MPEG_AU_2_I, /* MPEG-2 layer 1 */341 V4L2_MPEG_AU_2_II, /* MPEG-2 layer 2 */342 V4L2_MPEG_AU_2_III, /* MPEG-2 layer 3 */343 V4L2_MPEG_AC3, /* AC3 */344 V4L2_MPEG_LPCM, /* LPCM */345 V4L2_MPEG_AUDIO_UNKNOWN = 0xff,346 };347 enum v4l2_mpeg_videotype {348 V4L2_MPEG_VI_1, /* MPEG-1 */349 V4L2_MPEG_VI_2, /* MPEG-2 */350 V4L2_MPEG_VIDEO_UNKNOWN = 0xff,351 };352 enum v4l2_mpeg_aspectratio {353 V4L2_MPEG_ASPECT_SQUARE = 1, /* square pixel */354 V4L2_MPEG_ASPECT_4_3 = 2, /* 4 : 3 */355 V4L2_MPEG_ASPECT_16_9 = 3, /* 16 : 9 */356 V4L2_MPEG_ASPECT_1_221 = 4, /* 1 : 2,21 */357 V4L2_MPEG_ASPECT_UNKNOWN = 0xff,358 };359 360 struct v4l2_mpeg_compression {361 /* general */362 enum v4l2_mpeg_streamtype st_type;363 struct v4l2_bitrate st_bitrate;364 365 /* transport streams */366 __u16 ts_pid_pmt;367 __u16 ts_pid_audio;368 __u16 ts_pid_video;369 __u16 ts_pid_pcr;370 371 /* program stream */372 __u16 ps_size;373 __u16 reserved_1; /* align */374 375 /* audio */376 enum v4l2_mpeg_audiotype au_type;377 struct v4l2_bitrate au_bitrate;378 __u32 au_sample_rate;379 __u8 au_pesid;380 __u8 reserved_2[3]; /* align */381 382 /* video */383 enum v4l2_mpeg_videotype vi_type;384 enum v4l2_mpeg_aspectratio vi_aspect_ratio;385 struct v4l2_bitrate vi_bitrate;386 __u32 vi_frame_rate;387 __u16 vi_frames_per_gop;388 __u16 vi_bframes_count;389 __u8 vi_pesid;390 __u8 reserved_3[3]; /* align */391 392 /* misc flags */393 __u32 closed_gops:1;394 __u32 pulldown:1;395 __u32 reserved_4:30; /* align */396 397 /* I don't expect the above being perfect yet ;) */398 __u32 reserved_5[8];399 };400 401 434 struct v4l2_jpegcompression 402 435 { 403 436 int quality; … … 428 461 * allways use APP0 */ 429 462 }; 430 463 431 432 464 /* 433 465 * M E M O R Y - M A P P I N G B U F F E R S 434 466 */ … … 489 521 #define V4L2_FBUF_CAP_CHROMAKEY 0x0002 490 522 #define V4L2_FBUF_CAP_LIST_CLIPPING 0x0004 491 523 #define V4L2_FBUF_CAP_BITMAP_CLIPPING 0x0008 524 #define V4L2_FBUF_CAP_LOCAL_ALPHA 0x0010 525 #define V4L2_FBUF_CAP_GLOBAL_ALPHA 0x0020 526 #define V4L2_FBUF_CAP_LOCAL_INV_ALPHA 0x0040 527 #define V4L2_FBUF_CAP_GLOBAL_INV_ALPHA 0x0080 492 528 /* Flags for the 'flags' field. */ 493 529 #define V4L2_FBUF_FLAG_PRIMARY 0x0001 494 530 #define V4L2_FBUF_FLAG_OVERLAY 0x0002 495 531 #define V4L2_FBUF_FLAG_CHROMAKEY 0x0004 532 #define V4L2_FBUF_FLAG_LOCAL_ALPHA 0x0008 533 #define V4L2_FBUF_FLAG_GLOBAL_ALPHA 0x0010 534 #define V4L2_FBUF_FLAG_LOCAL_INV_ALPHA 0x0020 535 #define V4L2_FBUF_FLAG_GLOBAL_INV_ALPHA 0x0040 496 536 497 537 struct v4l2_clip 498 538 { 499 539 struct v4l2_rect c; 500 struct v4l2_clip __user*next;540 struct v4l2_clip *next; 501 541 }; 502 542 503 543 struct v4l2_window … … 505 545 struct v4l2_rect w; 506 546 enum v4l2_field field; 507 547 __u32 chromakey; 508 struct v4l2_clip __user*clips;548 struct v4l2_clip *clips; 509 549 __u32 clipcount; 510 void __user *bitmap; 550 void *bitmap; 551 __u8 global_alpha; 511 552 }; 512 553 513 514 554 /* 515 555 * C A P T U R E P A R A M E T E R S 516 556 */ … … 523 563 __u32 readbuffers; /* # of buffers for read */ 524 564 __u32 reserved[4]; 525 565 }; 566 526 567 /* Flags for 'capability' and 'capturemode' fields */ 527 568 #define V4L2_MODE_HIGHQUALITY 0x0001 /* High quality imaging mode */ 528 569 #define V4L2_CAP_TIMEPERFRAME 0x1000 /* timeperframe field is supported */ … … 540 581 /* 541 582 * I N P U T I M A G E C R O P P I N G 542 583 */ 543 544 584 struct v4l2_cropcap { 545 585 enum v4l2_buf_type type; 546 586 struct v4l2_rect bounds; … … 592 632 #define V4L2_STD_ATSC_8_VSB ((v4l2_std_id)0x01000000) 593 633 #define V4L2_STD_ATSC_16_VSB ((v4l2_std_id)0x02000000) 594 634 635 /* FIXME: 636 Although std_id is 64 bits, there is an issue on PPC32 architecture that 637 makes switch(__u64) to break. So, there's a hack on v4l2-common.c rounding 638 this value to 32 bits. 639 As, currently, the max value is for V4L2_STD_ATSC_16_VSB (30 bits wide), 640 it should work fine. However, if needed to add more than two standards, 641 v4l2-common.c should be fixed. 642 */ 643 595 644 /* some merged standards */ 596 645 #define V4L2_STD_MN (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC) 597 646 #define V4L2_STD_B (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B) … … 647 696 __u32 reserved[4]; 648 697 }; 649 698 650 651 699 /* 652 700 * V I D E O I N P U T S 653 701 */ … … 662 710 __u32 status; 663 711 __u32 reserved[4]; 664 712 }; 713 665 714 /* Values for the 'type' field */ 666 715 #define V4L2_INPUT_TYPE_TUNER 1 667 716 #define V4L2_INPUT_TYPE_CAMERA 2 … … 721 770 __s64 value64; 722 771 void *reserved; 723 772 }; 724 } 773 } __attribute__ ((packed)); 725 774 726 775 struct v4l2_ext_controls 727 776 { … … 922 971 V4L2_MPEG_AUDIO_CRC_NONE = 0, 923 972 V4L2_MPEG_AUDIO_CRC_CRC16 = 1, 924 973 }; 974 #define V4L2_CID_MPEG_AUDIO_MUTE (V4L2_CID_MPEG_BASE+109) 925 975 926 976 /* MPEG video */ 927 977 #define V4L2_CID_MPEG_VIDEO_ENCODING (V4L2_CID_MPEG_BASE+200) … … 948 998 #define V4L2_CID_MPEG_VIDEO_BITRATE (V4L2_CID_MPEG_BASE+207) 949 999 #define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (V4L2_CID_MPEG_BASE+208) 950 1000 #define V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (V4L2_CID_MPEG_BASE+209) 1001 #define V4L2_CID_MPEG_VIDEO_MUTE (V4L2_CID_MPEG_BASE+210) 1002 #define V4L2_CID_MPEG_VIDEO_MUTE_YUV (V4L2_CID_MPEG_BASE+211) 951 1003 952 1004 /* MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */ 953 1005 #define V4L2_CID_MPEG_CX2341X_BASE (V4L2_CTRL_CLASS_MPEG | 0x1000) … … 988 1040 #define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+8) 989 1041 #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9) 990 1042 #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) 1043 #define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) 991 1044 992 1045 /* 993 1046 * T U N I N G … … 1060 1113 __u32 mode; 1061 1114 __u32 reserved[2]; 1062 1115 }; 1116 1063 1117 /* Flags for the 'capability' field */ 1064 1118 #define V4L2_AUDCAP_STEREO 0x00001 1065 1119 #define V4L2_AUDCAP_AVL 0x00002 1066 1120 1067 1121 /* Flags for the 'mode' field */ 1068 1122 #define V4L2_AUDMODE_AVL 0x00001 1069 #define V4L2_AUDMODE_32BITS 0x000021070 1123 1071 1124 struct v4l2_audioout 1072 1125 { … … 1078 1131 }; 1079 1132 1080 1133 /* 1134 * M P E G S E R V I C E S 1135 * 1136 * NOTE: EXPERIMENTAL API 1137 */ 1138 #if 1 1139 #define V4L2_ENC_IDX_FRAME_I (0) 1140 #define V4L2_ENC_IDX_FRAME_P (1) 1141 #define V4L2_ENC_IDX_FRAME_B (2) 1142 #define V4L2_ENC_IDX_FRAME_MASK (0xf) 1143 1144 struct v4l2_enc_idx_entry { 1145 __u64 offset; 1146 __u64 pts; 1147 __u32 length; 1148 __u32 flags; 1149 __u32 reserved[2]; 1150 }; 1151 1152 #define V4L2_ENC_IDX_ENTRIES (64) 1153 struct v4l2_enc_idx { 1154 __u32 entries; 1155 __u32 entries_cap; 1156 __u32 reserved[4]; 1157 struct v4l2_enc_idx_entry entry[V4L2_ENC_IDX_ENTRIES]; 1158 }; 1159 1160 1161 #define V4L2_ENC_CMD_START (0) 1162 #define V4L2_ENC_CMD_STOP (1) 1163 #define V4L2_ENC_CMD_PAUSE (2) 1164 #define V4L2_ENC_CMD_RESUME (3) 1165 1166 /* Flags for V4L2_ENC_CMD_STOP */ 1167 #define V4L2_ENC_CMD_STOP_AT_GOP_END (1 << 0) 1168 1169 struct v4l2_encoder_cmd { 1170 __u32 cmd; 1171 __u32 flags; 1172 union { 1173 struct { 1174 __u32 data[8]; 1175 } raw; 1176 }; 1177 }; 1178 1179 #endif 1180 1181 1182 /* 1081 1183 * D A T A S E R V I C E S ( V B I ) 1082 1184 * 1083 1185 * Data services API by Michael Schimek 1084 1186 */ 1085 1187 1086 1188 /* Raw VBI */ 1087 1088 1189 struct v4l2_vbi_format 1089 1190 { 1090 1191 __u32 sampling_rate; /* in 1 Hz */ … … 1101 1202 #define V4L2_VBI_UNSYNC (1<< 0) 1102 1203 #define V4L2_VBI_INTERLACED (1<< 1) 1103 1204 1104 #if 11105 1205 /* Sliced VBI 1106 1206 * 1107 1207 * This implements is a proposal V4L2 API to allow SLICED VBI … … 1142 1242 (equals frame lines 313-336 for 625 line video 1143 1243 standards, 263-286 for 525 line standards) */ 1144 1244 __u16 service_lines[2][24]; 1145 __u32 reserved[4]; /* must be 0 */ 1245 enum v4l2_buf_type type; 1246 __u32 reserved[3]; /* must be 0 */ 1146 1247 }; 1147 1248 1148 1249 struct v4l2_sliced_vbi_data … … 1153 1254 __u32 reserved; /* must be 0 */ 1154 1255 __u8 data[48]; 1155 1256 }; 1156 #endif1157 1257 1158 1258 /* 1159 1259 * A G G R E G A T E S T R U C T U R E S … … 1169 1269 struct v4l2_pix_format pix; // V4L2_BUF_TYPE_VIDEO_CAPTURE 1170 1270 struct v4l2_window win; // V4L2_BUF_TYPE_VIDEO_OVERLAY 1171 1271 struct v4l2_vbi_format vbi; // V4L2_BUF_TYPE_VBI_CAPTURE 1172 #if 11173 1272 struct v4l2_sliced_vbi_format sliced; // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE 1174 #endif1175 1273 __u8 raw_data[200]; // user-defined 1176 1274 } fmt; 1177 1275 }; … … 1190 1288 } parm; 1191 1289 }; 1192 1290 1291 /* 1292 * A D V A N C E D D E B U G G I N G 1293 * 1294 * NOTE: EXPERIMENTAL API 1295 */ 1193 1296 1297 /* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */ 1194 1298 1299 #define V4L2_CHIP_MATCH_HOST 0 /* Match against chip ID on host (0 for the host) */ 1300 #define V4L2_CHIP_MATCH_I2C_DRIVER 1 /* Match against I2C driver ID */ 1301 #define V4L2_CHIP_MATCH_I2C_ADDR 2 /* Match against I2C 7-bit address */ 1302 1303 struct v4l2_register { 1304 __u32 match_type; /* Match type */ 1305 __u32 match_chip; /* Match this chip, meaning determined by match_type */ 1306 __u64 reg; 1307 __u64 val; 1308 }; 1309 1310 /* VIDIOC_G_CHIP_IDENT */ 1311 struct v4l2_chip_ident { 1312 __u32 match_type; /* Match type */ 1313 __u32 match_chip; /* Match this chip, meaning determined by match_type */ 1314 __u32 ident; /* chip identifier as specified in <media/v4l2-chip-ident.h> */ 1315 __u32 revision; /* chip revision, chip specific */ 1316 }; 1317 1195 1318 /* 1196 1319 * I O C T L C O D E S F O R V I D E O D E V I C E S 1197 1320 * … … 1201 1324 #define VIDIOC_ENUM_FMT _IOWR ('V', 2, struct v4l2_fmtdesc) 1202 1325 #define VIDIOC_G_FMT _IOWR ('V', 4, struct v4l2_format) 1203 1326 #define VIDIOC_S_FMT _IOWR ('V', 5, struct v4l2_format) 1204 #define VIDIOC_G_MPEGCOMP _IOR ('V', 6, struct v4l2_mpeg_compression)1205 #define VIDIOC_S_MPEGCOMP _IOW ('V', 7, struct v4l2_mpeg_compression)1206 1327 #define VIDIOC_REQBUFS _IOWR ('V', 8, struct v4l2_requestbuffers) 1207 1328 #define VIDIOC_QUERYBUF _IOWR ('V', 9, struct v4l2_buffer) 1208 1329 #define VIDIOC_G_FBUF _IOR ('V', 10, struct v4l2_framebuffer) … … 1248 1369 #define VIDIOC_ENUMAUDOUT _IOWR ('V', 66, struct v4l2_audioout) 1249 1370 #define VIDIOC_G_PRIORITY _IOR ('V', 67, enum v4l2_priority) 1250 1371 #define VIDIOC_S_PRIORITY _IOW ('V', 68, enum v4l2_priority) 1251 #if 1 1252 #define VIDIOC_G_SLICED_VBI_CAP _IOR ('V', 69, struct v4l2_sliced_vbi_cap) 1253 #endif 1372 #define VIDIOC_G_SLICED_VBI_CAP _IOWR ('V', 69, struct v4l2_sliced_vbi_cap) 1254 1373 #define VIDIOC_LOG_STATUS _IO ('V', 70) 1255 1374 #define VIDIOC_G_EXT_CTRLS _IOWR ('V', 71, struct v4l2_ext_controls) 1256 1375 #define VIDIOC_S_EXT_CTRLS _IOWR ('V', 72, struct v4l2_ext_controls) 1257 1376 #define VIDIOC_TRY_EXT_CTRLS _IOWR ('V', 73, struct v4l2_ext_controls) 1377 #if 1 1378 #define VIDIOC_ENUM_FRAMESIZES _IOWR ('V', 74, struct v4l2_frmsizeenum) 1379 #define VIDIOC_ENUM_FRAMEINTERVALS _IOWR ('V', 75, struct v4l2_frmivalenum) 1380 #define VIDIOC_G_ENC_INDEX _IOR ('V', 76, struct v4l2_enc_idx) 1381 #define VIDIOC_ENCODER_CMD _IOWR ('V', 77, struct v4l2_encoder_cmd) 1382 #define VIDIOC_TRY_ENCODER_CMD _IOWR ('V', 78, struct v4l2_encoder_cmd) 1258 1383 1384 /* Experimental, only implemented if CONFIG_VIDEO_ADV_DEBUG is defined */ 1385 #define VIDIOC_DBG_S_REGISTER _IOW ('V', 79, struct v4l2_register) 1386 #define VIDIOC_DBG_G_REGISTER _IOWR ('V', 80, struct v4l2_register) 1387 1388 #define VIDIOC_G_CHIP_IDENT _IOWR ('V', 81, struct v4l2_chip_ident) 1389 #endif 1390 1391 #ifdef __OLD_VIDIOC_ 1259 1392 /* for compatibility, will go away some day */ 1260 1393 #define VIDIOC_OVERLAY_OLD _IOWR ('V', 14, int) 1261 1394 #define VIDIOC_S_PARM_OLD _IOW ('V', 22, struct v4l2_streamparm) … … 1263 1396 #define VIDIOC_G_AUDIO_OLD _IOWR ('V', 33, struct v4l2_audio) 1264 1397 #define VIDIOC_G_AUDOUT_OLD _IOWR ('V', 49, struct v4l2_audioout) 1265 1398 #define VIDIOC_CROPCAP_OLD _IOR ('V', 58, struct v4l2_cropcap) 1399 #endif 1266 1400 1267 1401 #define BASE_VIDIOC_PRIVATE 192 /* 192-255 are private */ 1268 1402 -
libs/libmythtv/videoout_ivtv.cpp
23 23 #include <iostream> 24 24 using namespace std; 25 25 26 #include <linux/fb.h> 27 26 28 #include "videodev_myth.h" 27 29 #include "videodev2_myth.h" 28 30 29 31 #include "videoout_ivtv.h" 30 32 extern "C" { 31 33 #include <inttypes.h> 32 #ifdef USING_IVTV_HEADER33 #include <linux/ivtv.h>34 #else35 34 #include "ivtv_myth.h" 36 #endif37 35 } 38 36 39 37 #include "libmyth/mythcontext.h" … … 50 48 #define LOC QString("IVD: ") 51 49 #define LOC_ERR QString("IVD Error: ") 52 50 51 /***************************************************************/ 52 /* An extract from linux/video.h which is now required for the */ 53 /* decoder. Included here since we need an up to date version. */ 54 55 /* Decoder commands */ 56 #define VIDEO_CMD_PLAY (0) 57 #define VIDEO_CMD_STOP (1) 58 #define VIDEO_CMD_FREEZE (2) 59 #define VIDEO_CMD_CONTINUE (3) 60 61 /* Flags for VIDEO_CMD_FREEZE */ 62 #define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0) 63 64 /* Flags for VIDEO_CMD_STOP */ 65 #define VIDEO_CMD_STOP_TO_BLACK (1 << 0) 66 #define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1) 67 68 /* The structure must be zeroed before use by the application 69 This ensures it can be extended safely in the future. */ 70 struct video_command { 71 __u32 cmd; 72 __u32 flags; 73 union { 74 struct { 75 __u64 pts; 76 } stop; 77 78 struct { 79 __u32 speed; 80 __u32 format; 81 } play; 82 83 struct { 84 __u32 data[16]; 85 } raw; 86 }; 87 }; 88 89 #define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64) 90 #define VIDEO_COMMAND _IOWR('o', 59, struct video_command) 91 92 /* End of extract from linux/video.h */ 93 /***************************************************************/ 94 95 /* Used by recent ivtv-fb. Replaces the older IVTVFB_IOCTL_PREP_FRAME */ 96 /* Argument list is identical */ 97 #define IVTVFB_IOC_DMA_FRAME _IOW ('V', BASE_VIDIOC_PRIVATE+0, struct ivtvfb_ioctl_dma_host_to_ivtv_args) 98 53 99 /** \class VideoOutputIvtv 54 100 * \brief Implementation of video output for the Hauppage PVR 350 cards. 55 101 */ … … 74 120 75 121 last_normal(true), last_mask(0x2), 76 122 77 alphaState(kAlpha_Solid) 123 alphaState(kAlpha_Solid), old_fb_ioctl(true), 124 v4l2_api(false), fb_dma_ioctl(IVTVFB_IOCTL_PREP_FRAME), 125 color_key(false), decoder_flush(true) 78 126 { 79 127 } 80 128 … … 82 130 { 83 131 Close(); 84 132 85 if (fbfd >= 0)86 {87 ClearOSD();88 SetAlpha(kAlpha_Solid);89 90 close(fbfd);91 }92 93 133 if (osdbuffer) 94 134 delete [] osdbuffer; 95 135 } 96 136 97 137 void VideoOutputIvtv::ClearOSD(void) 98 138 { 139 int ret; 140 99 141 if (fbfd < 0) 100 142 { 101 143 VERBOSE(VB_IMPORTANT, LOC_ERR + "ClearOSD() -- no framebuffer!"); … … 104 146 105 147 VERBOSE(VB_PLAYBACK, LOC + "ClearOSD"); 106 148 107 struct ivtv_osd_coords osdcoords; 108 bzero(&osdcoords, sizeof(osdcoords)); 149 bzero(osdbuf_aligned, osdbufsize); 109 150 110 if (ioctl(fbfd, IVTVFB_IOCTL_GET_ACTIVE_BUFFER, &osdcoords) < 0)111 {112 VERBOSE(VB_IMPORTANT, LOC_ERR +113 "Failed to get active buffer for ClearOSD()" + ENO);114 }115 151 struct ivtvfb_ioctl_dma_host_to_ivtv_args prep; 116 152 bzero(&prep, sizeof(prep)); 117 153 118 154 prep.source = osdbuf_aligned; 119 155 prep.dest_offset = 0; 120 prep.count = osdcoords.max_offset;121 156 122 bzero(osdbuf_aligned, osdbufsize); 157 if (old_fb_ioctl == true) 158 { 159 struct ivtv_osd_coords osdcoords; 160 bzero(&osdcoords, sizeof(osdcoords)); 123 161 124 if (ioctl(fbfd, IVTVFB_IOCTL_PREP_FRAME, &prep) < 0) 125 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to prepare frame" + ENO); 162 if (ioctl(fbfd, IVTVFB_IOCTL_GET_ACTIVE_BUFFER, &osdcoords) < 0) 163 { 164 VERBOSE(VB_IMPORTANT, LOC_ERR + 165 "Failed to get active buffer for ClearOSD()" + ENO); 166 return; 167 } 168 prep.count = osdcoords.max_offset; 169 } 170 else 171 { 172 prep.count = ivtvfb_var.xres_virtual * ivtvfb_var.yres * (ivtvfb_var.bits_per_pixel / 8); 173 } 174 175 if (old_fb_ioctl == false) 176 ioctl(fbfd, FBIOPAN_DISPLAY, &ivtvfb_var); 177 178 if ((ret = ioctl(fbfd, fb_dma_ioctl, &prep)) < 0) 179 { 180 if (errno == EINVAL && fb_dma_ioctl != IVTVFB_IOC_DMA_FRAME) 181 { 182 fb_dma_ioctl = IVTVFB_IOC_DMA_FRAME; 183 ret = ioctl(fbfd, fb_dma_ioctl, &prep); 184 } 185 if (ret < 0) 186 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to prepare frame" + ENO); 187 } 126 188 } 127 189 190 void VideoOutputIvtv::SetColorKey(int state, int color) 191 { 192 if (v4l2_api) 193 { 194 struct v4l2_format alpha_state; 195 struct v4l2_framebuffer framebuffer_state; 196 197 ioctl(videofd, VIDIOC_G_FBUF, &framebuffer_state); 198 alpha_state.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; 199 ioctl(videofd, VIDIOC_G_FMT, &alpha_state); 200 201 if (state) 202 { 203 framebuffer_state.flags |= V4L2_FBUF_FLAG_CHROMAKEY; 204 alpha_state.fmt.win.chromakey = color; 205 } 206 else 207 { 208 framebuffer_state.flags &= ~V4L2_FBUF_FLAG_CHROMAKEY; 209 } 210 211 ioctl(videofd, VIDIOC_S_FBUF, &framebuffer_state); 212 ioctl(videofd, VIDIOC_S_FMT, &alpha_state); 213 } 214 else if (color_key) 215 { 216 struct ivtvfb_ioctl_colorkey ivtvfb_colorkey; 217 // Setup color-key. This helps when X isn't running on the PVR350 218 ivtvfb_colorkey.state = state; 219 ivtvfb_colorkey.colorKey = color; 220 ioctl(fbfd,IVTVFB_IOCTL_SET_COLORKEY, &ivtvfb_colorkey); 221 } 222 } 223 128 224 void VideoOutputIvtv::SetAlpha(eAlphaState newAlphaState) 129 225 { 130 226 if (alphaState == newAlphaState) … … 141 237 VERBOSE(VB_PLAYBACK, LOC + "SetAlpha(Embedded)"); 142 238 #endif 143 239 144 alphaState = newAlphaState;145 146 240 struct ivtvfb_ioctl_state_info fbstate; 147 241 bzero(&fbstate, sizeof(fbstate)); 148 if (ioctl(fbfd, IVTVFB_IOCTL_GET_STATE, &fbstate) < 0)149 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to query alpha state" + ENO);150 242 151 if ( alphaState == kAlpha_Local)243 if (v4l2_api) 152 244 { 153 fbstate.status &= ~IVTVFB_STATUS_GLOBAL_ALPHA; 154 fbstate.status |= IVTVFB_STATUS_LOCAL_ALPHA; 245 struct v4l2_format alpha_state; 246 struct v4l2_framebuffer framebuffer_state; 247 248 ioctl(videofd, VIDIOC_G_FBUF, &framebuffer_state); 249 alpha_state.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY; 250 ioctl(videofd, VIDIOC_G_FMT, &alpha_state); 251 252 if (newAlphaState == kAlpha_Local) 253 { 254 framebuffer_state.flags &= ~V4L2_FBUF_FLAG_GLOBAL_ALPHA; 255 framebuffer_state.flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; 256 } 257 else 258 { 259 framebuffer_state.flags |= V4L2_FBUF_FLAG_GLOBAL_ALPHA; 260 framebuffer_state.flags &= ~V4L2_FBUF_FLAG_LOCAL_ALPHA; 261 } 262 263 if (newAlphaState == kAlpha_Solid) 264 alpha_state.fmt.win.global_alpha = 255; 265 else if (newAlphaState == kAlpha_Clear) 266 alpha_state.fmt.win.global_alpha = 0; 267 else if (newAlphaState == kAlpha_Embedded) 268 alpha_state.fmt.win.global_alpha = gContext->GetNumSetting("PVR350EPGAlphaValue", 164); 269 270 if (ioctl(videofd, VIDIOC_S_FBUF, &framebuffer_state) < 0) 271 VERBOSE(VB_IMPORTANT, LOC_ERR + 272 "Failed to set ivtv alpha mode" + ENO); 273 if (ioctl(videofd, VIDIOC_S_FMT, &alpha_state) < 0) 274 VERBOSE(VB_IMPORTANT, LOC_ERR + 275 "Failed to set ivtv alpha values." + ENO); 155 276 } 156 277 else 157 278 { 158 fbstate.status |= IVTVFB_STATUS_GLOBAL_ALPHA; 159 fbstate.status &= ~IVTVFB_STATUS_LOCAL_ALPHA; 279 if (ioctl(fbfd, IVTVFB_IOCTL_GET_STATE, &fbstate) < 0) 280 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to query alpha state" + ENO); 281 282 if (newAlphaState == kAlpha_Local) 283 { 284 fbstate.status &= ~IVTVFB_STATUS_GLOBAL_ALPHA; 285 fbstate.status |= IVTVFB_STATUS_LOCAL_ALPHA; 286 } 287 else 288 { 289 fbstate.status |= IVTVFB_STATUS_GLOBAL_ALPHA; 290 fbstate.status &= ~IVTVFB_STATUS_LOCAL_ALPHA; 291 } 292 293 if (newAlphaState == kAlpha_Solid) 294 fbstate.alpha = 255; 295 else if (newAlphaState == kAlpha_Clear) 296 fbstate.alpha = 0; 297 else if (newAlphaState == kAlpha_Embedded) 298 fbstate.alpha = gContext->GetNumSetting("PVR350EPGAlphaValue", 164); 299 300 if (ioctl(fbfd, IVTVFB_IOCTL_SET_STATE, &fbstate) < 0) 301 VERBOSE(VB_IMPORTANT, LOC_ERR + 302 "Failed to set ivtv alpha state." + ENO); 160 303 } 161 304 162 if (alphaState == kAlpha_Solid) 163 fbstate.alpha = 255; 164 else if (alphaState == kAlpha_Clear) 165 fbstate.alpha = 0; 166 else if (alphaState == kAlpha_Embedded) 167 fbstate.alpha = gContext->GetNumSetting("PVR350EPGAlphaValue", 164); 305 // If using the new ioctl we need to check the fb mode 306 if (old_fb_ioctl == false) 307 { 308 struct fb_var_screeninfo *tmpfb_var = NULL; 168 309 169 if (ioctl(fbfd, IVTVFB_IOCTL_SET_STATE, &fbstate) < 0) 170 VERBOSE(VB_IMPORTANT, LOC_ERR + 171 "Failed to set ivtv alpha values." + ENO); 310 // If EPG switched on, select old fb mode 311 if (newAlphaState == kAlpha_Embedded) 312 tmpfb_var = &ivtvfb_var_old; 313 // If EPG switched off, select new fb mode 314 else if (newAlphaState != kAlpha_Embedded && alphaState == kAlpha_Embedded) 315 tmpfb_var = &ivtvfb_var; 316 317 // Change fb mode if required 318 if (tmpfb_var) 319 { 320 if ((ivtvfb_var_old.bits_per_pixel != 32) && 321 (ivtvfb_var_old.bits_per_pixel != 8)) 322 { 323 // Hide osd during mode change 324 ioctl(fbfd, FBIOBLANK, VESA_VSYNC_SUSPEND); 325 tmpfb_var->activate = FB_ACTIVATE_NOW; 326 if (ioctl(fbfd, FBIOPUT_VSCREENINFO, tmpfb_var) < 0) 327 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to switch framebuffer settings for EPG" + ENO); 328 329 // Restore osd 330 ioctl(fbfd, FBIOBLANK, VESA_NO_BLANKING); 331 } 332 // Reset display pan 333 ivtvfb_var.xoffset = 0; 334 ivtvfb_var.yoffset = 0; 335 ioctl(fbfd, FBIOPAN_DISPLAY, &ivtvfb_var); 336 } 337 } 338 339 alphaState = newAlphaState; 172 340 } 173 341 174 342 bool VideoOutputIvtv::InputChanged(const QSize &input_size, … … 221 389 { 222 390 int fbno = 0; 223 391 224 if ( ioctl(videofd, IVTV_IOC_GET_FB, &fbno) < 0)392 if (v4l2_api) 225 393 { 226 VERBOSE(VB_IMPORTANT, LOC_ERR + 227 "Framebuffer number query failed." + ENO + 228 "\n\t\t\tDid you load the ivtv-fb Linux kernel module?"); 229 return false; 394 struct v4l2_framebuffer fbuf; 395 396 ioctl(videofd, VIDIOC_G_FBUF, &fbuf); 397 for (fbno = 0; fbno < 10; fbno++) 398 { 399 struct fb_fix_screeninfo si; 400 char buf[10]; 401 402 sprintf(buf, "/dev/fb%d", fbno); 403 fbfd = open(buf, O_RDWR); 404 if (fbfd < 0) 405 continue; 406 ioctl(fbfd, FBIOGET_FSCREENINFO, &si); 407 if (si.smem_start == (unsigned long)fbuf.base) 408 break; 409 close(fbfd); 410 fbfd = -1; 411 } 412 if (fbfd < 0) 413 { 414 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to locate framebuffer" + 415 "\n\t\t\tDid you load the ivtv-fb Linux kernel module?"); 416 return false; 417 } 230 418 } 231 232 if (fbno < 0) 419 else 233 420 { 234 VERBOSE(VB_IMPORTANT, LOC_ERR + 235 "Failed to determine framebuffer number." + 236 "\n\t\t\tDid you load the ivtv-fb Linux kernel module?"); 237 return false; 238 } 421 if (ioctl(videofd, IVTV_IOC_GET_FB, &fbno) < 0) 422 { 423 VERBOSE(VB_IMPORTANT, LOC_ERR + 424 "Framebuffer number query failed." + ENO + 425 "\n\t\t\tDid you load the ivtv-fb Linux kernel module?"); 426 return false; 427 } 239 428 240 QString fbdev = QString("/dev/fb%1").arg(fbno); 241 fbfd = open(fbdev.ascii(), O_RDWR); 242 if (fbfd < 0) 243 { 244 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to open framebuffer " + 429 if (fbno < 0) 430 { 431 VERBOSE(VB_IMPORTANT, LOC_ERR + 432 "Failed to determine framebuffer number." + 433 "\n\t\t\tDid you load the ivtv-fb Linux kernel module?"); 434 return false; 435 } 436 437 QString fbdev = QString("/dev/fb%1").arg(fbno); 438 fbfd = open(fbdev.ascii(), O_RDWR); 439 440 if (fbfd < 0) 441 { 442 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to open framebuffer " + 245 443 QString("'%1'").arg(fbdev) + ENO + 246 444 "\n\t\t\tThis is needed for the OSD."); 247 return false; 445 return false; 446 } 248 447 } 249 448 250 449 struct ivtvfb_ioctl_get_frame_buffer igfb; 251 450 bzero(&igfb, sizeof(igfb)); 252 451 253 452 if (ioctl(fbfd, IVTVFB_IOCTL_GET_FRAME_BUFFER, &igfb) < 0) 254 VERBOSE(VB_IMPORTANT, LOC_ERR + "Getting frame buffer" + ENO); 453 { 454 if (errno == EINVAL) 455 { 456 struct fb_fix_screeninfo ivtvfb_fix; 457 if (ioctl(fbfd, FBIOGET_FSCREENINFO, &ivtvfb_fix) < 0) 458 { 459 VERBOSE(VB_IMPORTANT, LOC_ERR + "Getting frame buffer" + ENO); 460 } 461 else 462 { 463 old_fb_ioctl = false; 464 ioctl(fbfd, FBIOGET_VSCREENINFO, &ivtvfb_var_old); 465 } 466 } 467 else 468 { 469 VERBOSE(VB_IMPORTANT, LOC_ERR + "Getting frame buffer" + ENO); 470 } 471 } 255 472 256 stride = igfb.sizex * 4;257 258 473 long pagesize = sysconf(_SC_PAGE_SIZE); 259 474 long pagemask = ~(pagesize-1); 260 475 osdbuffer = new char[osdbufsize + pagesize]; … … 263 478 264 479 bzero(osdbuf_aligned, osdbufsize); 265 480 266 ClearOSD(); 481 if (old_fb_ioctl == true) 482 { 483 struct ivtv_osd_coords osdcoords; 484 stride = igfb.sizex * 4; 485 bzero(&osdcoords, sizeof(osdcoords)); 486 osdcoords.lines = video_dim.height(); 487 osdcoords.offset = 0; 488 osdcoords.pixel_stride = video_dim.width() * 2; 489 if (ioctl(fbfd, IVTVFB_IOCTL_SET_ACTIVE_BUFFER, &osdcoords) < 0) 490 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting active buffer" + ENO); 491 } 492 else 493 { 494 bzero (&ivtvfb_var, sizeof(ivtvfb_var)); 267 495 268 struct ivtv_osd_coords osdcoords; 269 bzero(&osdcoords, sizeof(osdcoords)); 270 osdcoords.lines = video_dim.height(); 271 osdcoords.offset = 0; 272 osdcoords.pixel_stride = video_dim.width() * 2; 496 // Switch dimensions to match the framebuffer 497 video_dim = QSize(ivtvfb_var_old.xres, ivtvfb_var_old.yres); 273 498 274 if (ioctl(fbfd, IVTVFB_IOCTL_SET_ACTIVE_BUFFER, &osdcoords) < 0) 275 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting active buffer" + ENO); 499 memcpy(&ivtvfb_var,&ivtvfb_var_old,sizeof ivtvfb_var); 276 500 501 // The OSD only supports 32bpp, so only change mode if needed 502 if (ivtvfb_var_old.bits_per_pixel != 32) 503 { 504 ivtvfb_var.xres_virtual = ivtvfb_var.xres; 505 ivtvfb_var.yres_virtual = ivtvfb_var.yres; 506 ivtvfb_var.xoffset = 0; 507 ivtvfb_var.yoffset = 0; 508 ivtvfb_var.bits_per_pixel = 32; 509 ivtvfb_var.nonstd = 0; 510 ivtvfb_var.activate = FB_ACTIVATE_NOW; 511 512 if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &ivtvfb_var) < 0) 513 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting frame buffer" + ENO); 514 } 515 else 516 { 517 ivtvfb_var.xoffset = 0; 518 ivtvfb_var.yoffset = 0; 519 ioctl(fbfd, FBIOPAN_DISPLAY, &ivtvfb_var); 520 } 521 522 stride = ivtvfb_var.xres_virtual * 4; 523 } 524 525 // Setup color-key. This helps when X isn't running on the PVR350 526 SetColorKey (1, 0x00010001); 527 528 ClearOSD(); 529 277 530 SetAlpha(kAlpha_Clear); 278 531 } 279 532 … … 289 542 void VideoOutputIvtv::Close(void) 290 543 { 291 544 VERBOSE(VB_PLAYBACK, LOC + "Close() -- begin"); 545 546 if (fbfd >= 0) 547 { 548 ClearOSD(); 549 SetAlpha(kAlpha_Solid); 550 SetColorKey (0,0); 551 552 if (old_fb_ioctl == false) 553 { 554 ivtvfb_var_old.activate = FB_ACTIVATE_NOW; 555 556 if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &ivtvfb_var_old) < 0) 557 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to restore framebuffer settings" + ENO); 558 } 559 560 close (fbfd); 561 fbfd = -1; 562 } 563 292 564 if (videofd >= 0) 293 565 { 294 566 Stop(true /* hide */); … … 323 595 struct v4l2_capability vcap; 324 596 bzero(&vcap, sizeof(vcap)); 325 597 if (ioctl(videofd, VIDIOC_QUERYCAP, &vcap) < 0) 598 { 326 599 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to query decoder" + ENO); 600 } 327 601 else 602 { 328 603 driver_version = vcap.version; 604 if (driver_version >= 0x000306) 605 color_key = true; 606 if (driver_version >= 0x000A00) 607 decoder_flush = false; 608 if (driver_version >= 0x010000) 609 v4l2_api = true; 610 } 329 611 VERBOSE(VB_PLAYBACK, LOC + "Open() -- end"); 330 612 } 331 613 … … 457 739 458 740 VideoFrame tmpframe; 459 741 init(&tmpframe, FMT_ARGB32, (unsigned char *)osdbuf_aligned, 460 stride, video_dim.height(), 32, 4 *stride * video_dim.height());742 stride, video_dim.height(), 32, stride * video_dim.height()); 461 743 462 744 OSDSurface *surface = NULL; 463 745 if (osd) … … 498 780 { 499 781 if (!clear || pipon) 500 782 { 501 VERBOSE(VB_PLAYBACK, "clearing buffer");502 783 bzero(tmpframe.buf, video_dim.height() * stride); 503 784 // redraw PiP... 504 785 if (pipPlayer) … … 513 794 pipon = (bool) pipPlayer; 514 795 515 796 // If there is an OSD, make sure we draw OSD surface 516 lastcleared &= !osd ;797 lastcleared &= !osdon; 517 798 518 #if 0519 // These optimizations have been disabled until someone with a real PVR-350520 // setup can test them Feb 7th, 2006 -- dtk521 799 // If nothing on OSD surface, just set the alpha to zero 522 if ( lastcleared && drawanyway)800 if (!osdon && !pipon) 523 801 { 802 if (lastcleared == true) 803 return; 804 805 lastcleared = true; 524 806 SetAlpha(kAlpha_Clear); 525 return; 807 808 if (color_key) 809 #ifdef WORDS_BIGENDIAN 810 wmemset((wchar_t *)osdbuf_aligned, 0x01000100, osdbufsize/4); 811 #else 812 wmemset((wchar_t *)osdbuf_aligned, 0x00010001, osdbufsize/4); 813 #endif 526 814 } 527 815 528 816 // If there has been no OSD change and no draw has been forced we're done 529 817 if (ret <= 0 && !drawanyway) 530 818 return; 531 #endif532 819 533 820 // The OSD surface needs to be updated... 534 821 struct ivtvfb_ioctl_dma_host_to_ivtv_args prep; … … 536 823 prep.source = osdbuf_aligned; 537 824 prep.count = video_dim.height() * stride; 538 825 539 if (ioctl(fbfd, IVTVFB_IOCTL_PREP_FRAME, &prep) < 0) 826 // This shouldn't be here. OSD should be rendered correctly to start with 827 #ifdef WORDS_BIGENDIAN 828 int b_index, i_index; 829 unsigned int *osd_int = (unsigned int *)osdbuf_aligned; 830 if (lastcleared != true) 831 { 832 for (b_index = 0, i_index = 0; b_index < prep.count; b_index += 4, i_index ++) 833 { 834 if (osd_int[i_index]) 835 { 836 osd_int[i_index] = 837 ((unsigned char)osdbuf_aligned[b_index+0]) | 838 ((unsigned char)osdbuf_aligned[b_index+1] << 8) | 839 ((unsigned char)osdbuf_aligned[b_index+2] << 16) | 840 ((unsigned char)osdbuf_aligned[b_index+3] << 24); 841 } 842 } 843 } 844 #endif 845 846 if (old_fb_ioctl == false) 847 ioctl(fbfd, FBIOPAN_DISPLAY, &ivtvfb_var); 848 849 if (ioctl(fbfd, fb_dma_ioctl, &prep) < 0) 540 850 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to process frame" + ENO); 541 851 542 SetAlpha(kAlpha_Local); 852 if (lastcleared != true) 853 SetAlpha(kAlpha_Local); 543 854 } 544 855 545 856 /** \fn VideoOutputIvtv::Start(int,int) … … 556 867 start.gop_offset = skip; 557 868 start.muted_audio_frames = mute; 558 869 559 while (ioctl(videofd, IVTV_IOC_START_DECODE, &start) < 0)870 if (v4l2_api) 560 871 { 561 if (errno != EBUSY) 872 struct video_command cmd; 873 memset(&cmd, 0, sizeof(cmd)); 874 cmd.cmd = VIDEO_CMD_PLAY; 875 cmd.play.speed = 1000; 876 ioctl(videofd, VIDEO_COMMAND, &cmd); 877 } 878 else 879 { 880 while (ioctl(videofd, IVTV_IOC_START_DECODE, &start) < 0) 562 881 { 563 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to start decoder" + ENO); 564 break; 882 if (errno != EBUSY) 883 { 884 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to start decoder" + ENO); 885 break; 886 } 565 887 } 566 888 } 567 889 VERBOSE(VB_PLAYBACK, LOC + "Start("<<skip<<" skipped, " … … 579 901 bzero(&stop, sizeof(stop)); 580 902 stop.hide_last = hide; 581 903 582 while (ioctl(videofd, IVTV_IOC_STOP_DECODE, &stop) < 0)904 if (v4l2_api) 583 905 { 584 if (errno != EBUSY) 906 struct video_command cmd; 907 memset(&cmd, 0, sizeof(cmd)); 908 cmd.cmd = VIDEO_CMD_STOP; 909 cmd.flags = VIDEO_CMD_STOP_IMMEDIATELY; 910 if (hide) 911 cmd.flags |= VIDEO_CMD_STOP_TO_BLACK; 912 if (ioctl(videofd, VIDEO_COMMAND, &cmd) < 0) 913 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to stop decoder" + ENO); 914 } 915 else 916 { 917 while (ioctl(videofd, IVTV_IOC_STOP_DECODE, &stop) < 0) 585 918 { 586 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to stop decoder" + ENO); 587 break; 919 if (errno != EBUSY) 920 { 921 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to stop decoder" + ENO); 922 break; 923 } 588 924 } 589 925 } 590 926 … … 599 935 void VideoOutputIvtv::Pause(void) 600 936 { 601 937 VERBOSE(VB_PLAYBACK, LOC + "Pause() -- begin"); 602 while (ioctl(videofd, IVTV_IOC_PAUSE, 0) < 0)938 if (v4l2_api) 603 939 { 604 if (errno != EBUSY) 940 struct video_command cmd; 941 memset(&cmd, 0, sizeof(cmd)); 942 cmd.cmd = VIDEO_CMD_FREEZE; 943 ioctl(videofd, VIDEO_COMMAND, &cmd); 944 } 945 else 946 { 947 while (ioctl(videofd, IVTV_IOC_PAUSE, 0) < 0) 605 948 { 606 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to pause decoder" + ENO); 607 break; 949 if (errno != EBUSY) 950 { 951 VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to pause decoder" + ENO); 952 break; 953 } 608 954 } 609 955 } 610 956 VERBOSE(VB_PLAYBACK, LOC + "Pause() -- end"); … … 660 1006 */ 661 1007 long long VideoOutputIvtv::GetFirmwareFramesPlayed(void) 662 1008 { 663 struct ivtv_ioctl_framesync frameinfo; 664 bzero(&frameinfo, sizeof(frameinfo)); 665 666 if (ioctl(videofd, IVTV_IOC_GET_TIMING, &frameinfo) < 0) 1009 if (v4l2_api) 667 1010 { 668 VERBOSE(VB_IMPORTANT, LOC_ERR + 669 "Fetching frames played from decoder" + ENO); 1011 long long frame; 1012 if (ioctl(videofd, VIDEO_GET_FRAME_COUNT, &frame) < 0) 1013 VERBOSE(VB_IMPORTANT, LOC_ERR + 1014 "Fetching frames played from decoder" + ENO); 1015 return frame; 670 1016 } 671 //cerr<<"<"<<frameinfo.frame<<">"; 672 return frameinfo.frame; 1017 else 1018 { 1019 struct ivtv_ioctl_framesync frameinfo; 1020 bzero(&frameinfo, sizeof(frameinfo)); 1021 1022 if (ioctl(videofd, IVTV_IOC_GET_TIMING, &frameinfo) < 0) 1023 { 1024 VERBOSE(VB_IMPORTANT, LOC_ERR + 1025 "Fetching frames played from decoder" + ENO); 1026 } 1027 //cerr<<"<"<<frameinfo.frame<<">"; 1028 return frameinfo.frame; 1029 } 673 1030 } 674 1031 675 1032 /** \fn VideoOutputIvtv::GetFramesPlayed(void) … … 692 1049 bool VideoOutputIvtv::Play(float speed, bool normal, int mask) 693 1050 { 694 1051 VERBOSE(VB_PLAYBACK, LOC + "Play("<<speed<<", "<<normal<<", "<<mask<<")"); 695 struct ivtv_speed play;696 bzero(&play, sizeof(play));697 play.scale = (speed >= 2.0f) ? (int)roundf(speed) : 1;698 play.scale = (speed <= 0.5f) ? (int)roundf(1.0f / speed) : play.scale;699 play.speed = (speed > 1.0f);700 play.smooth = 0;701 play.direction = 0;702 play.fr_mask = mask;703 play.b_per_gop = 0;704 play.aud_mute = !normal;705 play.fr_field = 0;706 play.mute = 0;707 708 1052 internal_offset = GetFramesPlayed(); 709 1053 frame_at_speed_change = GetFirmwareFramesPlayed(); 710 1054 711 while (ioctl(videofd, IVTV_IOC_S_SPEED, &play) < 0) 1055 if (speed >= 2.0f) 1056 speed = 2.0f; 1057 1058 if (v4l2_api) 712 1059 { 713 if (errno != EBUSY) 1060 struct video_command cmd; 1061 memset(&cmd, 0, sizeof(cmd)); 1062 cmd.cmd = VIDEO_CMD_PLAY; 1063 cmd.play.speed = (__u32)(1000.0f * speed); 1064 ioctl(videofd, VIDEO_COMMAND, &cmd); 1065 } 1066 else 1067 { 1068 struct ivtv_speed play; 1069 bzero(&play, sizeof(play)); 1070 play.scale = (speed >= 2.0f) ? (int)roundf(speed) : 1; 1071 play.scale = (speed <= 0.5f) ? (int)roundf(1.0f / speed) : play.scale; 1072 play.speed = (speed > 1.0f); 1073 play.smooth = 0; 1074 play.direction = 0; 1075 play.fr_mask = mask; 1076 play.b_per_gop = 0; 1077 play.aud_mute = !normal; 1078 play.fr_field = 0; 1079 play.mute = 0; 1080 1081 while (ioctl(videofd, IVTV_IOC_S_SPEED, &play) < 0) 714 1082 { 715 VERBOSE(VB_IMPORTANT, LOC_ERR + 716 "Setting decoder's playback speed" + ENO); 717 break; 1083 if (errno != EBUSY) 1084 { 1085 VERBOSE(VB_IMPORTANT, LOC_ERR + 1086 "Setting decoder's playback speed" + ENO); 1087 break; 1088 } 718 1089 } 719 1090 } 720 1091 … … 731 1102 void VideoOutputIvtv::Flush(void) 732 1103 { 733 1104 VERBOSE(VB_PLAYBACK, LOC + "Flush()"); 734 int arg = 0; 735 736 if (ioctl(videofd, IVTV_IOC_DEC_FLUSH, &arg) < 0) 737 VERBOSE(VB_IMPORTANT, LOC_ERR + "Flushing decoder" + ENO); 1105 if (decoder_flush) 1106 { 1107 int arg = 0; 1108 if (ioctl(videofd, IVTV_IOC_DEC_FLUSH, &arg) < 0) 1109 VERBOSE(VB_IMPORTANT, LOC_ERR + "Flushing decoder" + ENO); 1110 } 738 1111 } 739 1112 740 1113 /** \fn VideoOutputIvtv::Step(void) … … 743 1116 void VideoOutputIvtv::Step(void) 744 1117 { 745 1118 VERBOSE(VB_PLAYBACK, LOC + "Step()"); 746 enum {747 STEP_FRAME = 0,748 STEP_TOP_FIELD = 1,749 STEP_BOT_FIELD = 2,750 };751 1119 752 int arg = STEP_FRAME; 1120 if (v4l2_api) 1121 { 1122 struct video_command cmd; 1123 memset(&cmd, 0, sizeof(cmd)); 1124 cmd.cmd = VIDEO_CMD_PLAY; 1125 cmd.play.speed = 1; 1126 ioctl(videofd, VIDEO_COMMAND, &cmd); 1127 } 1128 else 1129 { 1130 int arg = 0; // STEP_FRAME; 753 1131 754 while (ioctl(videofd, IVTV_IOC_DEC_STEP, &arg) < 0) 755 { 756 if (errno != EBUSY) 1132 while (ioctl(videofd, IVTV_IOC_DEC_STEP, &arg) < 0) 757 1133 { 758 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting Step" + ENO); 759 break; 1134 if (errno != EBUSY) 1135 { 1136 VERBOSE(VB_IMPORTANT, LOC_ERR + "Setting Step" + ENO); 1137 break; 1138 } 760 1139 } 761 1140 } 762 1141 } … … 768 1147 769 1148 if (((kCodec_MPEG1 == myth_codec_id) || 770 1149 (kCodec_MPEG2 == myth_codec_id)) && 771 (video_dim.width() <= 7 68) &&1150 (video_dim.width() <= 720) && 772 1151 (video_dim.height() <= 576)) 773 1152 { 774 1153 list += "ivtv";