Ticket #3486: 3486-v2.patch

File 3486-v2.patch, 50.9 KB (added by ian@…, 18 years ago)

Reworked patch to include PVR350 decoder support for linux kernels >= 2.6.22

  • libs/libmythtv/videoout_ivtv.h

     
    11#ifndef VIDEOOUT_IVTV_H_
    22#define VIDEOOUT_IVTV_H_
    33
     4#include <linux/fb.h>
     5
    46#include <qstring.h>
    57#include <qmutex.h>
    68#include <cassert>
    79
    810#include "videooutbase.h"
     11#include "ivtv_myth.h"
    912
    1013class NuppelVideoPlayer;
    1114
     
    7982
    8083    void ShowPip(VideoFrame *frame, NuppelVideoPlayer *pipplayer);
    8184    void SetAlpha(eAlphaState newAlpha);
     85    void SetColorKey(int state, int color);
    8286    long long GetFirmwareFramesPlayed(void);
    8387
    8488    int videofd;
     
    113117    bool last_normal;
    114118    int last_mask;
    115119    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;
    116128};
    117129
    118130#endif
  • libs/libmythtv/videodev2_myth.h

     
    1 #ifndef __LINUX_VIDEODEV2_H
    2 #define __LINUX_VIDEODEV2_H
    31/*
    4  *      Video for Linux Two
     2 *  Video for Linux Two header file
    53 *
    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
    85 *
     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 *
    949 *      See http://linuxtv.org for more info
    1050 *
    11  *      Author: Bill Dirks <bdirks@pacbell.net>
     51 *      Author: Bill Dirks <bill@thedirks.org>
    1252 *              Justin Schoeman
     53 *              Hans Verkuil <hverkuil@xs4all.nl>
    1354 *              et al.
    1455 */
    15 
     56#ifndef __LINUX_VIDEODEV2_H
     57#define __LINUX_VIDEODEV2_H
     58#include <sys/time.h>
    1659#include <sys/types.h>
    1760
    18 #define __user
    19 
    20 #define OBSOLETE_OWNER 1 /* It will be removed for 2.6.15 */
    21 #define HAVE_V4L2 1
    22 
    2361/*
    2462 * Common stuff for both V4L1 and V4L2
    2563 * Moved from videodev.h
    2664 */
    27 
    2865#define VIDEO_MAX_FRAME               32
    2966
    3067#define VID_TYPE_CAPTURE        1       /* Can capture */
     
    5491 *      E N U M S
    5592 */
    5693enum 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 */
    70113};
    71114#define V4L2_FIELD_HAS_TOP(field)       \
    72115        ((field) == V4L2_FIELD_TOP      ||\
    73116         (field) == V4L2_FIELD_INTERLACED ||\
     117         (field) == V4L2_FIELD_INTERLACED_TB ||\
     118         (field) == V4L2_FIELD_INTERLACED_BT ||\
    74119         (field) == V4L2_FIELD_SEQ_TB   ||\
    75120         (field) == V4L2_FIELD_SEQ_BT)
    76121#define V4L2_FIELD_HAS_BOTTOM(field)    \
    77122        ((field) == V4L2_FIELD_BOTTOM   ||\
    78123         (field) == V4L2_FIELD_INTERLACED ||\
     124         (field) == V4L2_FIELD_INTERLACED_TB ||\
     125         (field) == V4L2_FIELD_INTERLACED_BT ||\
    79126         (field) == V4L2_FIELD_SEQ_TB   ||\
    80127         (field) == V4L2_FIELD_SEQ_BT)
    81128#define V4L2_FIELD_HAS_BOTH(field)      \
    82129        ((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 ||\
    84133         (field) == V4L2_FIELD_SEQ_BT)
    85134
    86135enum 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,
    92143#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,
    96146#endif
    97         V4L2_BUF_TYPE_PRIVATE            = 0x80,
     147        V4L2_BUF_TYPE_PRIVATE              = 0x80,
    98148};
    99149
    100150enum v4l2_ctrl_type {
     
    185235#define V4L2_CAP_VIDEO_OVERLAY          0x00000004  /* Can do video overlay */
    186236#define V4L2_CAP_VBI_CAPTURE            0x00000010  /* Is a raw VBI capture device */
    187237#define V4L2_CAP_VBI_OUTPUT             0x00000020  /* Is a raw VBI output device */
    188 #if 1
    189238#define V4L2_CAP_SLICED_VBI_CAPTURE     0x00000040  /* Is a sliced VBI capture device */
    190239#define V4L2_CAP_SLICED_VBI_OUTPUT      0x00000080  /* Is a sliced VBI output device */
    191 #endif
    192240#define V4L2_CAP_RDS_CAPTURE            0x00000100  /* RDS data capture */
     241#define V4L2_CAP_VIDEO_OUTPUT_OVERLAY   0x00000200  /* Can do video output overlay */
    193242
    194243#define V4L2_CAP_TUNER                  0x00010000  /* has a tuner */
    195244#define V4L2_CAP_AUDIO                  0x00020000  /* has audio support */
     
    202251/*
    203252 *      V I D E O   I M A G E   F O R M A T
    204253 */
    205 
    206254struct v4l2_pix_format
    207255{
    208256        __u32                   width;
     
    243291#define V4L2_PIX_FMT_YUV420  v4l2_fourcc('Y','U','1','2') /* 12  YUV 4:2:0     */
    244292#define V4L2_PIX_FMT_YYUV    v4l2_fourcc('Y','Y','U','V') /* 16  YUV 4:2:2     */
    245293#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 */
    247296
    248297/* see http://www.siliconimaging.com/RGB%20Bayer.htm */
    249298#define V4L2_PIX_FMT_SBGGR8  v4l2_fourcc('B','A','8','1') /*  8  BGBG.. GRGR.. */
     
    276325
    277326#define V4L2_FMT_FLAG_COMPRESSED 0x0001
    278327
     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 */
     333enum v4l2_frmsizetypes
     334{
     335        V4L2_FRMSIZE_TYPE_DISCRETE      = 1,
     336        V4L2_FRMSIZE_TYPE_CONTINUOUS    = 2,
     337        V4L2_FRMSIZE_TYPE_STEPWISE      = 3,
     338};
    279339
     340struct v4l2_frmsize_discrete
     341{
     342        __u32                   width;          /* Frame width [pixel] */
     343        __u32                   height;         /* Frame height [pixel] */
     344};
     345
     346struct 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
     356struct 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
    280370/*
     371 *      F R A M E   R A T E   E N U M E R A T I O N
     372 */
     373enum v4l2_frmivaltypes
     374{
     375        V4L2_FRMIVAL_TYPE_DISCRETE      = 1,
     376        V4L2_FRMIVAL_TYPE_CONTINUOUS    = 2,
     377        V4L2_FRMIVAL_TYPE_STEPWISE      = 3,
     378};
     379
     380struct 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
     387struct 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/*
    281405 *      T I M E C O D E
    282406 */
    283407struct v4l2_timecode
     
    307431/* The above is based on SMPTE timecodes */
    308432
    309433
    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 S
    312  *
    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 
    401434struct v4l2_jpegcompression
    402435{
    403436        int quality;
     
    428461                                        * allways use APP0 */
    429462};
    430463
    431 
    432464/*
    433465 *      M E M O R Y - M A P P I N G   B U F F E R S
    434466 */
     
    489521#define V4L2_FBUF_CAP_CHROMAKEY         0x0002
    490522#define V4L2_FBUF_CAP_LIST_CLIPPING     0x0004
    491523#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
    492528/*  Flags for the 'flags' field. */
    493529#define V4L2_FBUF_FLAG_PRIMARY          0x0001
    494530#define V4L2_FBUF_FLAG_OVERLAY          0x0002
    495531#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
    496536
    497537struct v4l2_clip
    498538{
    499539        struct v4l2_rect        c;
    500         struct v4l2_clip        __user *next;
     540        struct v4l2_clip        *next;
    501541};
    502542
    503543struct v4l2_window
     
    505545        struct v4l2_rect        w;
    506546        enum v4l2_field         field;
    507547        __u32                   chromakey;
    508         struct v4l2_clip        __user *clips;
     548        struct v4l2_clip        *clips;
    509549        __u32                   clipcount;
    510         void                    __user *bitmap;
     550        void                    *bitmap;
     551        __u8                    global_alpha;
    511552};
    512553
    513 
    514554/*
    515555 *      C A P T U R E   P A R A M E T E R S
    516556 */
     
    523563        __u32              readbuffers;   /*  # of buffers for read */
    524564        __u32              reserved[4];
    525565};
     566
    526567/*  Flags for 'capability' and 'capturemode' fields */
    527568#define V4L2_MODE_HIGHQUALITY   0x0001  /*  High quality imaging mode */
    528569#define V4L2_CAP_TIMEPERFRAME   0x1000  /*  timeperframe field is supported */
     
    540581/*
    541582 *      I N P U T   I M A G E   C R O P P I N G
    542583 */
    543 
    544584struct v4l2_cropcap {
    545585        enum v4l2_buf_type      type;
    546586        struct v4l2_rect        bounds;
     
    592632#define V4L2_STD_ATSC_8_VSB     ((v4l2_std_id)0x01000000)
    593633#define V4L2_STD_ATSC_16_VSB    ((v4l2_std_id)0x02000000)
    594634
     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
    595644/* some merged standards */
    596645#define V4L2_STD_MN     (V4L2_STD_PAL_M|V4L2_STD_PAL_N|V4L2_STD_PAL_Nc|V4L2_STD_NTSC)
    597646#define V4L2_STD_B      (V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_SECAM_B)
     
    647696        __u32                reserved[4];
    648697};
    649698
    650 
    651699/*
    652700 *      V I D E O   I N P U T S
    653701 */
     
    662710        __u32        status;
    663711        __u32        reserved[4];
    664712};
     713
    665714/*  Values for the 'type' field */
    666715#define V4L2_INPUT_TYPE_TUNER           1
    667716#define V4L2_INPUT_TYPE_CAMERA          2
     
    721770                __s64 value64;
    722771                void *reserved;
    723772        };
    724 }  __attribute__ ((packed));
     773} __attribute__ ((packed));
    725774
    726775struct v4l2_ext_controls
    727776{
     
    922971        V4L2_MPEG_AUDIO_CRC_NONE  = 0,
    923972        V4L2_MPEG_AUDIO_CRC_CRC16 = 1,
    924973};
     974#define V4L2_CID_MPEG_AUDIO_MUTE                (V4L2_CID_MPEG_BASE+109)
    925975
    926976/*  MPEG video */
    927977#define V4L2_CID_MPEG_VIDEO_ENCODING            (V4L2_CID_MPEG_BASE+200)
     
    948998#define V4L2_CID_MPEG_VIDEO_BITRATE             (V4L2_CID_MPEG_BASE+207)
    949999#define V4L2_CID_MPEG_VIDEO_BITRATE_PEAK        (V4L2_CID_MPEG_BASE+208)
    9501000#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)
    9511003
    9521004/*  MPEG-class control IDs specific to the CX2584x driver as defined by V4L2 */
    9531005#define V4L2_CID_MPEG_CX2341X_BASE                              (V4L2_CTRL_CLASS_MPEG | 0x1000)
     
    9881040#define V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP      (V4L2_CID_MPEG_CX2341X_BASE+8)
    9891041#define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (V4L2_CID_MPEG_CX2341X_BASE+9)
    9901042#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)
    9911044
    9921045/*
    9931046 *      T U N I N G
     
    10601113        __u32   mode;
    10611114        __u32   reserved[2];
    10621115};
     1116
    10631117/*  Flags for the 'capability' field */
    10641118#define V4L2_AUDCAP_STEREO              0x00001
    10651119#define V4L2_AUDCAP_AVL                 0x00002
    10661120
    10671121/*  Flags for the 'mode' field */
    10681122#define V4L2_AUDMODE_AVL                0x00001
    1069 #define V4L2_AUDMODE_32BITS             0x00002
    10701123
    10711124struct v4l2_audioout
    10721125{
     
    10781131};
    10791132
    10801133/*
     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
     1144struct 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)
     1153struct 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
     1169struct 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/*
    10811183 *      D A T A   S E R V I C E S   ( V B I )
    10821184 *
    10831185 *      Data services API by Michael Schimek
    10841186 */
    10851187
    10861188/* Raw VBI */
    1087 
    10881189struct v4l2_vbi_format
    10891190{
    10901191        __u32   sampling_rate;          /* in 1 Hz */
     
    11011202#define V4L2_VBI_UNSYNC         (1<< 0)
    11021203#define V4L2_VBI_INTERLACED     (1<< 1)
    11031204
    1104 #if 1
    11051205/* Sliced VBI
    11061206 *
    11071207 *    This implements is a proposal V4L2 API to allow SLICED VBI
     
    11421242                                 (equals frame lines 313-336 for 625 line video
    11431243                                  standards, 263-286 for 525 line standards) */
    11441244        __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 */
    11461247};
    11471248
    11481249struct v4l2_sliced_vbi_data
     
    11531254        __u32   reserved;       /* must be 0 */
    11541255        __u8    data[48];
    11551256};
    1156 #endif
    11571257
    11581258/*
    11591259 *      A G G R E G A T E   S T R U C T U R E S
     
    11691269                struct v4l2_pix_format          pix;     // V4L2_BUF_TYPE_VIDEO_CAPTURE
    11701270                struct v4l2_window              win;     // V4L2_BUF_TYPE_VIDEO_OVERLAY
    11711271                struct v4l2_vbi_format          vbi;     // V4L2_BUF_TYPE_VBI_CAPTURE
    1172 #if 1
    11731272                struct v4l2_sliced_vbi_format   sliced;  // V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
    1174 #endif
    11751273                __u8    raw_data[200];                   // user-defined
    11761274        } fmt;
    11771275};
     
    11901288        } parm;
    11911289};
    11921290
     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 */
    11931296
     1297/* VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER */
    11941298
     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
     1303struct 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 */
     1311struct 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
    11951318/*
    11961319 *      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
    11971320 *
     
    12011324#define VIDIOC_ENUM_FMT         _IOWR ('V',  2, struct v4l2_fmtdesc)
    12021325#define VIDIOC_G_FMT            _IOWR ('V',  4, struct v4l2_format)
    12031326#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)
    12061327#define VIDIOC_REQBUFS          _IOWR ('V',  8, struct v4l2_requestbuffers)
    12071328#define VIDIOC_QUERYBUF         _IOWR ('V',  9, struct v4l2_buffer)
    12081329#define VIDIOC_G_FBUF           _IOR  ('V', 10, struct v4l2_framebuffer)
     
    12481369#define VIDIOC_ENUMAUDOUT       _IOWR ('V', 66, struct v4l2_audioout)
    12491370#define VIDIOC_G_PRIORITY       _IOR  ('V', 67, enum v4l2_priority)
    12501371#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)
    12541373#define VIDIOC_LOG_STATUS       _IO   ('V', 70)
    12551374#define VIDIOC_G_EXT_CTRLS      _IOWR ('V', 71, struct v4l2_ext_controls)
    12561375#define VIDIOC_S_EXT_CTRLS      _IOWR ('V', 72, struct v4l2_ext_controls)
    12571376#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)
    12581383
     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_
    12591392/* for compatibility, will go away some day */
    12601393#define VIDIOC_OVERLAY_OLD      _IOWR ('V', 14, int)
    12611394#define VIDIOC_S_PARM_OLD       _IOW  ('V', 22, struct v4l2_streamparm)
     
    12631396#define VIDIOC_G_AUDIO_OLD      _IOWR ('V', 33, struct v4l2_audio)
    12641397#define VIDIOC_G_AUDOUT_OLD     _IOWR ('V', 49, struct v4l2_audioout)
    12651398#define VIDIOC_CROPCAP_OLD      _IOR  ('V', 58, struct v4l2_cropcap)
     1399#endif
    12661400
    12671401#define BASE_VIDIOC_PRIVATE     192             /* 192-255 are private */
    12681402
  • libs/libmythtv/videoout_ivtv.cpp

     
    2323#include <iostream>
    2424using namespace std;
    2525
     26#include <linux/fb.h>
     27
    2628#include "videodev_myth.h"
    2729#include "videodev2_myth.h"
    2830
    2931#include "videoout_ivtv.h"
    3032extern "C" {
    3133#include <inttypes.h>
    32 #ifdef USING_IVTV_HEADER
    33 #include <linux/ivtv.h>
    34 #else
    3534#include "ivtv_myth.h"
    36 #endif
    3735}
    3836
    3937#include "libmyth/mythcontext.h"
     
    5048#define LOC QString("IVD: ")
    5149#define LOC_ERR QString("IVD Error: ")
    5250
     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. */
     70struct 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
    5399/** \class  VideoOutputIvtv
    54100 *  \brief  Implementation of video output for the Hauppage PVR 350 cards.
    55101 */
     
    74120
    75121    last_normal(true),        last_mask(0x2),
    76122
    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)
    78126{
    79127}
    80128
     
    82130{
    83131    Close();
    84132
    85     if (fbfd >= 0)
    86     {
    87         ClearOSD();
    88         SetAlpha(kAlpha_Solid);
    89 
    90         close(fbfd);
    91     }
    92 
    93133    if (osdbuffer)
    94134        delete [] osdbuffer;
    95135}
    96136
    97137void VideoOutputIvtv::ClearOSD(void)
    98138{
     139    int ret;
     140
    99141    if (fbfd < 0)
    100142    {
    101143        VERBOSE(VB_IMPORTANT, LOC_ERR + "ClearOSD() -- no framebuffer!");
     
    104146
    105147    VERBOSE(VB_PLAYBACK, LOC + "ClearOSD");
    106148
    107     struct ivtv_osd_coords osdcoords;
    108     bzero(&osdcoords, sizeof(osdcoords));
     149    bzero(osdbuf_aligned, osdbufsize);
    109150
    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     }
    115151    struct ivtvfb_ioctl_dma_host_to_ivtv_args prep;
    116152    bzero(&prep, sizeof(prep));
    117153
    118154    prep.source = osdbuf_aligned;
    119155    prep.dest_offset = 0;
    120     prep.count = osdcoords.max_offset;
    121156
    122     bzero(osdbuf_aligned, osdbufsize);
     157    if (old_fb_ioctl == true)
     158    {
     159        struct ivtv_osd_coords osdcoords;
     160        bzero(&osdcoords, sizeof(osdcoords));
    123161
    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    }
    126188}
    127189
     190void 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
    128224void VideoOutputIvtv::SetAlpha(eAlphaState newAlphaState)
    129225{
    130226    if (alphaState == newAlphaState)
     
    141237        VERBOSE(VB_PLAYBACK, LOC + "SetAlpha(Embedded)");
    142238#endif
    143239
    144     alphaState = newAlphaState;
    145 
    146240    struct ivtvfb_ioctl_state_info fbstate;
    147241    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);
    150242
    151     if (alphaState == kAlpha_Local)
     243    if (v4l2_api)
    152244    {
    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);
    155276    }
    156277    else
    157278    {
    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);
    160303    }
    161304
    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;
    168309
    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;
    172340}
    173341
    174342bool VideoOutputIvtv::InputChanged(const QSize &input_size,
     
    221389    {
    222390        int fbno = 0;
    223391
    224         if (ioctl(videofd, IVTV_IOC_GET_FB, &fbno) < 0)
     392        if (v4l2_api)
    225393        {
    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            }
    230418        }
    231 
    232         if (fbno < 0)
     419        else
    233420        {
    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            }
    239428
    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 " +
    245443                    QString("'%1'").arg(fbdev) + ENO +
    246444                    "\n\t\t\tThis is needed for the OSD.");
    247             return false;
     445                return false;
     446            }
    248447        }
    249448
    250449        struct ivtvfb_ioctl_get_frame_buffer igfb;
    251450        bzero(&igfb, sizeof(igfb));
    252451
    253452        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        }
    255472
    256         stride = igfb.sizex * 4;
    257 
    258473        long pagesize = sysconf(_SC_PAGE_SIZE);
    259474        long pagemask = ~(pagesize-1);
    260475        osdbuffer = new char[osdbufsize + pagesize];
     
    263478
    264479        bzero(osdbuf_aligned, osdbufsize);
    265480
    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));
    267495
    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);
    273498
    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);
    276500
     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
    277530        SetAlpha(kAlpha_Clear);
    278531    }
    279532
     
    289542void VideoOutputIvtv::Close(void)
    290543{
    291544    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
    292564    if (videofd >= 0)
    293565    {
    294566        Stop(true /* hide */);
     
    323595    struct v4l2_capability vcap;
    324596    bzero(&vcap, sizeof(vcap));
    325597    if (ioctl(videofd, VIDIOC_QUERYCAP, &vcap) < 0)
     598    {
    326599        VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to query decoder" + ENO);
     600    }
    327601    else
     602    {
    328603        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    }
    329611    VERBOSE(VB_PLAYBACK, LOC + "Open() -- end");
    330612}
    331613
     
    457739
    458740    VideoFrame tmpframe;
    459741    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());
    461743
    462744    OSDSurface *surface = NULL;
    463745    if (osd)
     
    498780    {
    499781        if (!clear || pipon)
    500782        {
    501             VERBOSE(VB_PLAYBACK, "clearing buffer");
    502783            bzero(tmpframe.buf, video_dim.height() * stride);
    503784            // redraw PiP...
    504785            if (pipPlayer)
     
    513794    pipon = (bool) pipPlayer;
    514795
    515796    // If there is an OSD, make sure we draw OSD surface
    516     lastcleared &= !osd;
     797    lastcleared &= !osdon;
    517798
    518 #if 0
    519 // These optimizations have been disabled until someone with a real PVR-350
    520 // setup can test them Feb 7th, 2006 -- dtk
    521799    // If nothing on OSD surface, just set the alpha to zero
    522     if (lastcleared && drawanyway)
     800    if (!osdon && !pipon)
    523801    {
     802        if (lastcleared == true)
     803            return;
     804
     805        lastcleared = true;
    524806        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
    526814    }
    527815
    528816    // If there has been no OSD change and no draw has been forced we're done
    529817    if (ret <= 0 && !drawanyway)
    530818        return;
    531 #endif
    532819
    533820    // The OSD surface needs to be updated...
    534821    struct ivtvfb_ioctl_dma_host_to_ivtv_args prep;
     
    536823    prep.source = osdbuf_aligned;
    537824    prep.count  = video_dim.height() * stride;
    538825
    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)
    540850        VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to process frame" + ENO);
    541851
    542     SetAlpha(kAlpha_Local);
     852    if (lastcleared != true)
     853        SetAlpha(kAlpha_Local);
    543854}
    544855
    545856/** \fn VideoOutputIvtv::Start(int,int)
     
    556867    start.gop_offset = skip;
    557868    start.muted_audio_frames = mute;
    558869
    559     while (ioctl(videofd, IVTV_IOC_START_DECODE, &start) < 0)
     870    if (v4l2_api)
    560871    {
    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)
    562881        {
    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            }
    565887        }
    566888    }
    567889    VERBOSE(VB_PLAYBACK, LOC + "Start("<<skip<<" skipped, "
     
    579901    bzero(&stop, sizeof(stop));
    580902    stop.hide_last = hide;
    581903
    582     while (ioctl(videofd, IVTV_IOC_STOP_DECODE, &stop) < 0)
     904    if (v4l2_api)
    583905    {
    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)
    585918        {
    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            }
    588924        }
    589925    }
    590926
     
    599935void VideoOutputIvtv::Pause(void)
    600936{
    601937    VERBOSE(VB_PLAYBACK, LOC + "Pause() -- begin");
    602     while (ioctl(videofd, IVTV_IOC_PAUSE, 0) < 0)
     938    if (v4l2_api)
    603939    {
    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)
    605948        {
    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            }
    608954        }
    609955    }
    610956    VERBOSE(VB_PLAYBACK, LOC + "Pause() -- end");
     
    6601006 */
    6611007long long VideoOutputIvtv::GetFirmwareFramesPlayed(void)
    6621008{
    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)
    6671010    {
    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;
    6701016    }
    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    }
    6731030}
    6741031
    6751032/** \fn VideoOutputIvtv::GetFramesPlayed(void)
     
    6921049bool VideoOutputIvtv::Play(float speed, bool normal, int mask)
    6931050{
    6941051    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 
    7081052    internal_offset = GetFramesPlayed();
    7091053    frame_at_speed_change = GetFirmwareFramesPlayed();
    7101054
    711     while (ioctl(videofd, IVTV_IOC_S_SPEED, &play) < 0)
     1055    if (speed >= 2.0f)
     1056        speed = 2.0f;
     1057
     1058    if (v4l2_api)
    7121059    {
    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)
    7141082        {
    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            }
    7181089        }
    7191090    }
    7201091
     
    7311102void VideoOutputIvtv::Flush(void)
    7321103{
    7331104    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    }
    7381111}
    7391112
    7401113/** \fn VideoOutputIvtv::Step(void)
     
    7431116void VideoOutputIvtv::Step(void)
    7441117{
    7451118    VERBOSE(VB_PLAYBACK, LOC + "Step()");
    746     enum {
    747         STEP_FRAME     = 0,
    748         STEP_TOP_FIELD = 1,
    749         STEP_BOT_FIELD = 2,
    750     };
    7511119
    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;
    7531131
    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)
    7571133        {
    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            }
    7601139        }
    7611140    }
    7621141}
     
    7681147
    7691148    if (((kCodec_MPEG1 == myth_codec_id) ||
    7701149         (kCodec_MPEG2 == myth_codec_id)) &&
    771         (video_dim.width() <= 768) &&
     1150        (video_dim.width() <= 720) &&
    7721151        (video_dim.height() <= 576))
    7731152    {
    7741153        list += "ivtv";