Ticket #2954: 2954-v2.patch

File 2954-v2.patch, 35.7 KB (added by danielk, 17 years ago)

Updated patch (only tested with a limited driver revs though), first attempt at handling various VBI embedding APIs without requiring backwards compatibility in drivers.

  • libs/libmythtv/cardutil.h

     
    177177
    178178    // V4L info
    179179    static bool         hasV4L2(int videofd);
    180     static bool         GetV4LInfo(int videofd, QString &card,QString &driver);
     180    static bool         GetV4LInfo(int videofd, QString &card, QString &driver,
     181                                   uint32_t &version);
     182    static bool         GetV4LInfo(int videofd, QString &card, QString &driver)
     183        { uint32_t dummy; return GetV4LInfo(videofd, card, driver, dummy); }
    181184    static InputNames   probeV4LInputs(int videofd, bool &ok);
    182185
    183186  private:
  • libs/libmythtv/dbcheck.cpp

     
    1010#include "mythdbcon.h"
    1111
    1212/// This is the DB schema version expected by the running MythTV instance.
    13 const QString currentDatabaseVersion = "1175";
     13const QString currentDatabaseVersion = "1176";
    1414
    1515static bool UpdateDBVersionNumber(const QString &newnumber);
    1616static bool performActualUpdate(const QString updates[], QString version,
     
    28032803            return false;
    28042804    }
    28052805
     2806    if (dbver == "1175")
     2807    {
     2808        QString thequery =
     2809            "SELECT id "
     2810            "FROM recordingprofiles "
     2811            "WHERE profilegroup=2";
     2812
     2813        MSqlQuery query(MSqlQuery::InitCon());
     2814        query.prepare(thequery);
     2815        if (!query.exec())
     2816        {
     2817            QString msg =
     2818                QString("DB Error (Performing database upgrade): \n"
     2819                        "Query was: %1 \nError was: %2 \nnew version: %3")
     2820                .arg(thequery)
     2821                .arg(MythContext::DBErrorMessage(query.lastError()))
     2822                .arg("1176");
     2823            VERBOSE(VB_IMPORTANT, msg);
     2824            return false;
     2825        }
     2826
     2827        MSqlQuery query2(MSqlQuery::InitCon());
     2828        QString in = "(";
     2829        while (query.next())
     2830        {
     2831            uint profile = query.value(0).toUInt();
     2832            QString generic =
     2833                "SELECT value "
     2834                "FROM codecparams "
     2835                "WHERE name='%1' AND profile = '%2'";
     2836            QString wquery = generic.arg("width").arg(profile);
     2837            QString hquery = generic.arg("height").arg(profile);
     2838            int width = 0, height = 0;
     2839            if (query2.exec(wquery) && query2.next())
     2840                width = query2.value(0).toInt();
     2841            if (query2.exec(hquery) && query2.next())
     2842                height = query2.value(0).toInt();
     2843           
     2844            if (width && height && (width == 480) && (height == 480))
     2845                in += QString::number(profile) + ",";
     2846        }
     2847
     2848        thequery = "";
     2849        if (in.length() > 2)
     2850        {
     2851            in.truncate(in.length() - 1);
     2852            thequery =
     2853                "DELETE FROM codecparams "
     2854                "WHERE name in ('width','height') AND"
     2855                "      profile IN " + in + ")";
     2856        }
     2857
     2858        const QString updates[] = {
     2859thequery,
     2860""};
     2861
     2862        if (!performActualUpdate(updates, "1176", dbver))
     2863            return false;
     2864    }
     2865
     2866
    28062867//"ALTER TABLE cardinput DROP COLUMN preference;" in 0.22
    28072868//"ALTER TABLE channel DROP COLUMN atscsrcid;" in 0.22
    28082869//"ALTER TABLE recordedmarkup DROP COLUMN offset;" in 0.22
  • libs/libmythtv/mpegrecorder.h

     
    5555    bool OpenV4L2DeviceAsInput(void);
    5656    bool SetIVTVDeviceOptions(int chanfd);
    5757    bool SetV4L2DeviceOptions(int chanfd);
     58    bool SetVBIOptions(int chanfd);
    5859
    5960    void ResetForNewFile(void);
    6061
    6162    bool deviceIsMpegFile;
    6263    int bufferSize;
    6364
     65    // Config
     66    bool ignore_vbi_bug;
     67
     68    // Driver info
     69    QString  card;
     70    QString  driver;
     71    uint32_t version;
     72    bool     usingv4l2;
     73    bool     has_buggy_vbi;
     74    bool     has_v4l2_vbi;
     75
    6476    // State
    6577    bool recording;
    6678    bool encoding;
  • libs/libmythtv/ivtv_myth.h

     
    1 #define IVTV_IOC_FWAPI          0xFFEE7701 /*just some values i picked for now*/
    2 #define IVTV_IOC_ZCOUNT         0xFFEE7702
    3 #ifdef __FreeBSD__
    4 #define IVTV_IOC_G_CODEC        _IOR  ('V', 73, struct ivtv_ioctl_codec)
    5 #define IVTV_IOC_S_CODEC        _IOWR ('V', 74, struct ivtv_ioctl_codec)
    6 #else
    7 #define IVTV_IOC_G_CODEC        0xFFEE7703
    8 #define IVTV_IOC_S_CODEC        0xFFEE7704
    9 #endif
     1/*
     2    Public ivtv API header
     3    Copyright (C) 2003-2004  Kevin Thayer <nufan_wfk at yahoo.com>
    104
    11 #define IVTV_MBOX_MAX_DATA 16
     5    VBI portions:
     6    Copyright (C) 2004  Hans Verkuil <hverkuil@xs4all.nl>
    127
    13 #define IVTV_SLICED_TELETEXT_B  (1 << 0)
    14 #define IVTV_SLICED_CAPTION_625 (1 << 1)
    15 #define IVTV_SLICED_CAPTION_525 (1 << 2)
    16 #define IVTV_SLICED_WSS_625     (1 << 3)
    17 #define IVTV_SLICED_VPS         (1 << 4)
     8    This program is free software; you can redistribute it and/or modify
     9    it under the terms of the GNU General Public License as published by
     10    the Free Software Foundation; either version 2 of the License, or
     11    (at your option) any later version.
    1812
    19 struct ivtv_sliced_vbi_format {
    20         unsigned long service_set;      /* one or more of the IVTV_SLICED_ defines */
    21         unsigned long packet_size;      /* the size in bytes of the ivtv_sliced_data packet */
    22         unsigned long io_size;          /* maximum number of bytes passed by one read() call */
    23         unsigned long reserved;
    24 };
     13    This program is distributed in the hope that it will be useful,
     14    but WITHOUT ANY WARRANTY; without even the implied warranty of
     15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16    GNU General Public License for more details.
    2517
    26 /* This structure is the same as the proposed v4l2_sliced_data structure */
    27 /* id is one of the VBI_SLICED_ flags. */
    28 struct ivtv_sliced_data {
    29         unsigned long id;
    30         unsigned long line;
    31         unsigned char *data;
    32 };
     18    You should have received a copy of the GNU General Public License
     19    along with this program; if not, write to the Free Software
     20    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     21 */
    3322
    34 /* The four bit VBI data type found in the embedded VBI data of an
    35    MPEG stream has one of the following values: */
    36 #define VBI_TYPE_TELETEXT       0x1     // Teletext (uses lines 6-22 for PAL, 10-21 for NTSC)
    37 #define VBI_TYPE_CC             0x4     // Closed Captions (line 21 NTSC, line 22 PAL)
    38 #define VBI_TYPE_WSS            0x5     // Wide Screen Signal (line 20 NTSC, line 23 PAL)
    39 #define VBI_TYPE_VPS            0x7     // Video Programming System (PAL) (line 16)
     23#ifndef _LINUX_IVTV_H
     24#define _LINUX_IVTV_H
    4025
    41 /* allow direct access to the saa7115 registers for testing */
    42 #define SAA7115_GET_REG         0xFFEE7705
    43 #define SAA7115_SET_REG         0xFFEE7706
     26#define __u32 uint32_t
     27#define __u64 uint64_t
    4428
    45 /* to set audio options */
    46 #define DECODER_SET_AUDIO       0xFFEE7707
    47 #define DECODER_AUDIO_32_KHZ    0
    48 #define DECODER_AUDIO_441_KHZ   1
    49 #define DECODER_AUDIO_48_KHZ    2
     29/* NOTE: the ioctls in this file will eventually be replaced by v4l2 API
     30   ioctls. */
    5031
    51 #define IVTV_IOC_PLAY           0xFFEE7781
    52 #define IVTV_IOC_PAUSE          0xFFEE7782
    53 #define IVTV_IOC_FRAMESYNC      0xFFEE7783
    54 #define IVTV_IOC_GET_TIMING     0xFFEE7784
    55 #define IVTV_IOC_S_SLOW_FAST    0xFFEE7785
    56 #define IVTV_IOC_S_START_DECODE 0xFFEE7786
    57 #define IVTV_IOC_S_STOP_DECODE  0xFFEE7787
    58 #define IVTV_IOC_S_OSD          0xFFEE7788
    59 #define IVTV_IOC_GET_FB         0xFFEE7789
     32/* device ioctls should use the range 29-199 */
     33#define IVTV_IOC_START_DECODE      _IOW ('@', 29, struct ivtv_cfg_start_decode)
     34#define IVTV_IOC_STOP_DECODE       _IOW ('@', 30, struct ivtv_cfg_stop_decode)
     35#define IVTV_IOC_G_SPEED           _IOR ('@', 31, struct ivtv_speed)
     36#define IVTV_IOC_S_SPEED           _IOW ('@', 32, struct ivtv_speed)
     37#define IVTV_IOC_DEC_STEP          _IOW ('@', 33, int)
     38#define IVTV_IOC_DEC_FLUSH         _IOW ('@', 34, int)
     39#define IVTV_IOC_PAUSE_BLACK       _IO  ('@', 35)
     40#define IVTV_IOC_STOP              _IO  ('@', 36)
    6041
    61 #define IVTV_IOC_START_DECODE  _IOW ('@', 29, struct ivtv_cfg_start_decode)
    62 #define IVTV_IOC_STOP_DECODE   _IOW ('@', 30, struct ivtv_cfg_stop_decode)
    63 #define IVTV_IOC_G_SPEED       _IOR ('@', 31, struct ivtv_speed)
    64 #define IVTV_IOC_S_SPEED       _IOW ('@', 32, struct ivtv_speed)
    65 #define IVTV_IOC_DEC_STEP      _IOW ('@', 33, int)
    66 #define IVTV_IOC_DEC_FLUSH     _IOW ('@', 34, int)
    67 #define IVTV_IOC_S_VBI_MODE    _IOWR('@', 35, struct ivtv_sliced_vbi_format)
    68 #define IVTV_IOC_G_VBI_MODE    _IOR ('@', 36, struct ivtv_sliced_vbi_format)
    69 #define IVTV_IOC_S_VBI_EMBED   _IOW ('@', 54, int)
    70 #define IVTV_IOC_G_VBI_EMBED   _IOR ('@', 55, int)
     42#define IVTV_IOC_S_VBI_MODE        _IOWR('@', 35, struct ivtv_sliced_vbi_format) /* old ioctl */
     43#define IVTV_IOC_G_VBI_MODE        _IOR ('@', 36, struct ivtv_sliced_vbi_format) /* old ioctl */
    7144
    72 /* ioctl for MSP_SET_MATRIX will have to be registered */
    73 #define MSP_SET_MATRIX     _IOW('m',17,struct msp_matrix)
     45#define IVTV_IOC_PLAY              _IO  ('@', 37)
     46#define IVTV_IOC_PAUSE             _IO  ('@', 38)
     47#define IVTV_IOC_FRAMESYNC         _IOR ('@', 39, struct ivtv_ioctl_framesync)
     48#define IVTV_IOC_GET_TIMING        _IOR ('@', 40, struct ivtv_ioctl_framesync)
     49#define IVTV_IOC_S_SLOW_FAST       _IOW ('@', 41, struct ivtv_slow_fast)
     50#define IVTV_IOC_GET_FB            _IOR ('@', 44, int)
     51#define IVTV_IOC_S_GOP_END         _IOWR('@', 50, int)
     52#define IVTV_IOC_S_VBI_PASSTHROUGH _IOW ('@', 51, int)
     53#define IVTV_IOC_G_VBI_PASSTHROUGH _IOR ('@', 52, int)
     54#define IVTV_IOC_PASSTHROUGH       _IOW ('@', 53, int)
     55#define IVTV_IOC_S_VBI_EMBED       _IOW ('@', 54, int) /* old ioctl */
     56#define IVTV_IOC_G_VBI_EMBED       _IOR ('@', 55, int) /* old ioctl */
     57#define IVTV_IOC_PAUSE_ENCODE      _IO  ('@', 56)
     58#define IVTV_IOC_RESUME_ENCODE     _IO  ('@', 57)
     59#define IVTV_IOC_DEC_SPLICE        _IOW ('@', 58, int)
     60#define IVTV_IOC_DEC_FAST_STOP     _IOW ('@', 59, int)
     61#define IVTV_IOC_PREP_FRAME_YUV    _IOW ('@', 60, struct ivtvyuv_ioctl_dma_host_to_ivtv_args)
     62#define IVTV_IOC_G_YUV_INTERLACE   _IOR ('@', 61, struct ivtv_ioctl_yuv_interlace)
     63#define IVTV_IOC_S_YUV_INTERLACE   _IOW ('@', 62, struct ivtv_ioctl_yuv_interlace)
     64#define IVTV_IOC_G_PTS             _IOR ('@', 63, u64)
    7465
    75 
    7666/* Custom v4l controls */
    7767#ifndef V4L2_CID_PRIVATE_BASE
    7868#define V4L2_CID_PRIVATE_BASE                   0x08000000
    79 #endif
     69#endif /* V4L2_CID_PRIVATE_BASE */
    8070
    81 #define V4L2_CID_IVTV_FREQ      (V4L2_CID_PRIVATE_BASE)
    82 #define V4L2_CID_IVTV_ENC       (V4L2_CID_PRIVATE_BASE + 1)
    83 #define V4L2_CID_IVTV_BITRATE   (V4L2_CID_PRIVATE_BASE + 2)
    84 #define V4L2_CID_IVTV_MONO      (V4L2_CID_PRIVATE_BASE + 3)
    85 #define V4L2_CID_IVTV_JOINT     (V4L2_CID_PRIVATE_BASE + 4)
    86 #define V4L2_CID_IVTV_EMPHASIS  (V4L2_CID_PRIVATE_BASE + 5)
    87 #define V4L2_CID_IVTV_CRC       (V4L2_CID_PRIVATE_BASE + 6)
    88 #define V4L2_CID_IVTV_COPYRIGHT (V4L2_CID_PRIVATE_BASE + 7)
    89 #define V4L2_CID_IVTV_GEN       (V4L2_CID_PRIVATE_BASE + 8)
     71#define V4L2_CID_IVTV_FREQ      (V4L2_CID_PRIVATE_BASE + 0) /* old control */
     72#define V4L2_CID_IVTV_ENC       (V4L2_CID_PRIVATE_BASE + 1) /* old control */
     73#define V4L2_CID_IVTV_BITRATE   (V4L2_CID_PRIVATE_BASE + 2) /* old control */
     74#define V4L2_CID_IVTV_MONO      (V4L2_CID_PRIVATE_BASE + 3) /* old control */
     75#define V4L2_CID_IVTV_JOINT     (V4L2_CID_PRIVATE_BASE + 4) /* old control */
     76#define V4L2_CID_IVTV_EMPHASIS  (V4L2_CID_PRIVATE_BASE + 5) /* old control */
     77#define V4L2_CID_IVTV_CRC       (V4L2_CID_PRIVATE_BASE + 6) /* old control */
     78#define V4L2_CID_IVTV_COPYRIGHT (V4L2_CID_PRIVATE_BASE + 7) /* old control */
     79#define V4L2_CID_IVTV_GEN       (V4L2_CID_PRIVATE_BASE + 8) /* old control */
    9080
    91 #define IVTV_V4L2_AUDIO_MENUCOUNT 9 /* # of v4l controls */
     81#define V4L2_CID_IVTV_DEC_SMOOTH_FF     (V4L2_CID_PRIVATE_BASE + 9)
     82#define V4L2_CID_IVTV_DEC_FR_MASK       (V4L2_CID_PRIVATE_BASE + 10)
     83#define V4L2_CID_IVTV_DEC_SP_MUTE       (V4L2_CID_PRIVATE_BASE + 11)
     84#define V4L2_CID_IVTV_DEC_FR_FIELD      (V4L2_CID_PRIVATE_BASE + 12)
     85#define V4L2_CID_IVTV_DEC_AUD_SKIP      (V4L2_CID_PRIVATE_BASE + 13)
     86#define V4L2_CID_IVTV_DEC_NUM_BUFFERS   (V4L2_CID_PRIVATE_BASE + 14)
     87#define V4L2_CID_IVTV_DEC_PREBUFFER     (V4L2_CID_PRIVATE_BASE + 15)
    9288
    93 #define IVTV_DEC_PRIVATE_BASE   (V4L2_CID_PRIVATE_BASE + IVTV_V4L2_AUDIO_MENUCOUNT)
    94 
    95 #define V4L2_CID_IVTV_DEC_SMOOTH_FF     (IVTV_DEC_PRIVATE_BASE + 0)
    96 #define V4L2_CID_IVTV_DEC_FR_MASK       (IVTV_DEC_PRIVATE_BASE + 1)
    97 #define V4L2_CID_IVTV_DEC_SP_MUTE       (IVTV_DEC_PRIVATE_BASE + 2)
    98 #define V4L2_CID_IVTV_DEC_FR_FIELD      (IVTV_DEC_PRIVATE_BASE + 3)
    99 #define V4L2_CID_IVTV_DEC_AUD_SKIP      (IVTV_DEC_PRIVATE_BASE + 4)
    100 #define V4L2_CID_IVTV_DEC_NUM_BUFFERS   (IVTV_DEC_PRIVATE_BASE + 5)
    101 #define V4L2_CID_IVTV_DEC_PREBUFFER     (IVTV_DEC_PRIVATE_BASE + 6)
    102 
    103 #define IVTV_V4L2_DEC_MENUCOUNT 7
    104 
    105 struct ivtv_ioctl_fwapi {
    106         uint32_t cmd;
    107         uint32_t result;
    108         int32_t args;
    109         uint32_t data[IVTV_MBOX_MAX_DATA];
    110 };
    111 
    11289struct ivtv_ioctl_framesync {
    113         uint32_t frame;
    114         uint64_t pts;
    115         uint64_t scr;
     90        __u32 frame;
     91        __u64 pts;
     92        __u64 scr;
    11693};
    11794
    11895struct ivtv_speed {
    119         int scale;      /* 1-?? (50 for now) */
    120         int smooth;     /* Smooth mode when in slow/fast mode */
    121         int speed;      /* 0 = slow, 1 = fast */
    122         int direction;  /* 0 = forward, 1 = reverse (not supportd */
    123         int fr_mask;    /* 0 = I, 1 = I,P, 2 = I,P,B    2 = default!*/
    124         int b_per_gop;  /* frames per GOP (reverse only) */
    125         int aud_mute;   /* Mute audio while in slow/fast mode */
    126         int fr_field;   /* 1 = show every field, 0 = show every frame */
    127         int mute;       /* # of audio frames to mute on playback resume */
     96        int scale;              /* 1-?? (50 for now) */
     97        int smooth;             /* Smooth mode when in slow/fast mode */
     98        int speed;              /* 0 = slow, 1 = fast */
     99        int direction;          /* 0 = forward, 1 = reverse (not supportd */
     100        int fr_mask;            /* 0 = I, 1 = I,P, 2 = I,P,B    2 = default! */
     101        int b_per_gop;          /* frames per GOP (reverse only) */
     102        int aud_mute;           /* Mute audio while in slow/fast mode */
     103        int fr_field;           /* 1 = show every field, 0 = show every frame */
     104        int mute;               /* # of audio frames to mute on playback resume */
    128105};
    129106
    130107struct ivtv_slow_fast {
    131         int speed; /* 0 = slow, 1 = fast */
    132         int scale; /* 1-?? (50 for now) */
    133 };     
     108        int speed;              /* 0 = slow, 1 = fast */
     109        int scale;              /* 1-?? (50 for now) */
     110};
    134111
    135112struct ivtv_cfg_start_decode {
    136         uint32_t    gop_offset;        /*Frames in GOP to skip before starting */
    137         uint32_t     muted_audio_frames;/* #of audio frames to mute */
     113        __u32 gop_offset;       /*Frames in GOP to skip before starting */
     114        __u32 muted_audio_frames;       /* #of audio frames to mute */
    138115};
    139116
    140117struct ivtv_cfg_stop_decode {
    141         int             hide_last; /* 1 = show black after stop,
    142                                       0 = show last frame */
    143         uint64_t        pts_stop; /* PTS to stop at */
     118        int hide_last;          /* 1 = show black after stop,
     119                                   0 = show last frame */
     120        __u64 pts_stop; /* PTS to stop at */
    144121};
    145122
    146 
    147 /* For use with IVTV_IOC_G_CODEC and IVTV_IOC_S_CODEC */
    148 struct ivtv_ioctl_codec {
    149         uint32_t aspect;
    150         uint32_t audio_bitmask;
    151         uint32_t bframes;
    152         uint32_t bitrate_mode;
    153         uint32_t bitrate;
    154         uint32_t bitrate_peak;
    155         uint32_t dnr_mode;
    156         uint32_t dnr_spatial;
    157         uint32_t dnr_temporal;
    158         uint32_t dnr_type;
    159         uint32_t framerate;
    160         uint32_t framespergop;
    161         uint32_t gop_closure;
    162         uint32_t pulldown;
    163         uint32_t stream_type;
     123struct ivtv_ioctl_yuv_interlace{
     124        int interlace_mode; /* Takes one of IVTV_YUV_MODE_xxxxxx values */
     125        int threshold; /* If mode is auto then if src_height <= this value treat as progressive otherwise treat as interlaced */
    164126};
     127#define IVTV_YUV_MODE_INTERLACED        0
     128#define IVTV_YUV_MODE_PROGRESSIVE       1
     129#define IVTV_YUV_MODE_AUTO              2
    165130
    166 
    167 struct msp_matrix {
    168     int input;
    169     int output;
    170 };
    171 
    172131/* Framebuffer external API */
    173 /* NOTE: These must *exactly* match the structures and constants in driver/ivtv.h */
    174132
    175133struct ivtvfb_ioctl_state_info {
    176   unsigned long status;
    177   unsigned long alpha;
     134        unsigned long status;
     135        unsigned long alpha;
    178136};
    179137
     138struct ivtvfb_ioctl_colorkey {
     139    int state;
     140    __u32 colorKey;
     141};
     142
    180143struct ivtvfb_ioctl_blt_copy_args {
    181   int x, y, width, height, source_offset, source_stride;
     144        int x, y, width, height, source_offset, source_stride;
    182145};
    183146
    184147struct ivtvfb_ioctl_blt_fill_args {
    185     int rasterop, alpha_mode, alpha_mask, width, height, x, y;
    186     unsigned int destPixelMask, colour;
     148        int rasterop, alpha_mode, alpha_mask, width, height, x, y;
     149        unsigned int destPixelMask, colour;
    187150
    188151};
    189152
    190153struct ivtvfb_ioctl_dma_host_to_ivtv_args {
    191   void* source;
    192   unsigned long dest_offset;
    193   int count;
     154        void *source;
     155        unsigned long dest_offset;
     156        int count;
    194157};
    195158
     159struct ivtvyuv_ioctl_dma_host_to_ivtv_args {
     160        void *y_source;
     161        void *uv_source;
     162        unsigned int yuv_type;
     163        int src_x;
     164        int src_y;
     165        unsigned int src_w;
     166        unsigned int src_h;
     167        int dst_x;
     168        int dst_y;
     169        unsigned int dst_w;
     170        unsigned int dst_h;
     171        int srcBuf_width;
     172        int srcBuf_height;
     173};
     174
    196175struct ivtvfb_ioctl_get_frame_buffer {
    197   void* mem;
    198   int  size;
    199   int  sizex;
    200   int  sizey;
     176        void *mem;
     177        int size;
     178        int sizex;
     179        int sizey;
    201180};
    202181
    203182struct ivtv_osd_coords {
    204   unsigned long offset;
    205   unsigned long max_offset;
    206   int pixel_stride;
    207   int lines;
    208   int x;
    209   int y;
     183        unsigned long offset;
     184        unsigned long max_offset;
     185        int pixel_stride;
     186        int lines;
     187        int x;
     188        int y;
    210189};
    211190
    212191struct rectangle {
    213   int x0;
    214   int y0;
    215   int x1;
    216   int y1;
     192        int x0;
     193        int y0;
     194        int x1;
     195        int y1;
    217196};
    218197
     198struct ivtvfb_ioctl_set_window {
     199        int width;
     200        int height;
     201        int left;
     202        int top;
     203};
     204
     205
     206
     207/* Framebuffer ioctls should use the range 1 - 28 */
    219208#define IVTVFB_IOCTL_GET_STATE          _IOR('@', 1, struct ivtvfb_ioctl_state_info)
    220209#define IVTVFB_IOCTL_SET_STATE          _IOW('@', 2, struct ivtvfb_ioctl_state_info)
    221210#define IVTVFB_IOCTL_PREP_FRAME         _IOW('@', 3, struct ivtvfb_ioctl_dma_host_to_ivtv_args)
     
    224213#define IVTVFB_IOCTL_SET_ACTIVE_BUFFER  _IOW('@', 6, struct ivtv_osd_coords)
    225214#define IVTVFB_IOCTL_GET_FRAME_BUFFER   _IOR('@', 7, struct ivtvfb_ioctl_get_frame_buffer)
    226215#define IVTVFB_IOCTL_BLT_FILL           _IOW('@', 8, struct ivtvfb_ioctl_blt_fill_args)
     216#define IVTVFB_IOCTL_PREP_FRAME_BUF     _IOW('@', 9, struct ivtvfb_ioctl_dma_host_to_ivtv_args)
     217#define IVTVFB_IOCTL_SET_WINDOW         _IOW('@', 11, struct ivtvfb_ioctl_set_window)
     218#define IVTVFB_IOCTL_GET_COLORKEY       _IOW('@', 12, struct ivtvfb_ioctl_colorkey)
     219#define IVTVFB_IOCTL_SET_COLORKEY       _IOW('@', 13, struct ivtvfb_ioctl_colorkey)
    227220
    228221#define IVTVFB_STATUS_ENABLED           (1 << 0)
    229222#define IVTVFB_STATUS_GLOBAL_ALPHA      (1 << 1)
    230223#define IVTVFB_STATUS_LOCAL_ALPHA       (1 << 2)
    231224#define IVTVFB_STATUS_FLICKER_REDUCTION (1 << 3)
    232225
    233 #define IVTV_IOCTL_SET_DEBUG_LEVEL _IOWR('@', 98, int *)
    234 #define IVTV_IOCTL_GET_DEBUG_LEVEL _IOR('@', 99, int *)
     226/********************************************************************/
     227/* Old stuff */
     228
     229#define IVTV_IOC_G_CODEC        _IOR  ('V', 73, struct ivtv_ioctl_codec)
     230#define IVTV_IOC_S_CODEC        _IOWR ('V', 74, struct ivtv_ioctl_codec)
     231
     232#define IVTV_SLICED_TELETEXT_B  (1 << 0)
     233#define IVTV_SLICED_CAPTION_625 (1 << 1)
     234#define IVTV_SLICED_CAPTION_525 (1 << 2)
     235#define IVTV_SLICED_WSS_625     (1 << 3)
     236#define IVTV_SLICED_VPS         (1 << 4)
     237
     238struct ivtv_sliced_vbi_format {
     239        unsigned long service_set;      /* one or more of the IVTV_SLICED_ defines */
     240        unsigned long packet_size;      /* the size in bytes of the ivtv_sliced_data packet */
     241        unsigned long io_size;          /* maximum number of bytes passed by one read() call */
     242        unsigned long reserved;
     243};
     244
     245/* This structure is the same as the proposed v4l2_sliced_data structure */
     246/* id is one of the VBI_SLICED_ flags. */
     247struct ivtv_sliced_data {
     248        unsigned long id;
     249        unsigned long line;
     250        unsigned char *data;
     251};
     252
     253/* The four bit VBI data type found in the embedded VBI data of an
     254   MPEG stream has one of the following values: */
     255#define VBI_TYPE_TELETEXT       0x1     // Teletext (uses lines 6-22 for PAL, 10-21 for NTSC)
     256#define VBI_TYPE_CC             0x4     // Closed Captions (line 21 NTSC, line 22 PAL)
     257#define VBI_TYPE_WSS            0x5     // Wide Screen Signal (line 20 NTSC, line 23 PAL)
     258#define VBI_TYPE_VPS            0x7     // Video Programming System (PAL) (line 16)
     259
     260/* For use with IVTV_IOC_G_CODEC and IVTV_IOC_S_CODEC */
     261struct ivtv_ioctl_codec {
     262        __u32 aspect;
     263        __u32 audio_bitmask;
     264        __u32 bframes;
     265        __u32 bitrate_mode;
     266        __u32 bitrate;
     267        __u32 bitrate_peak;
     268        __u32 dnr_mode;
     269        __u32 dnr_spatial;
     270        __u32 dnr_temporal;
     271        __u32 dnr_type;
     272        __u32 framerate;
     273        __u32 framespergop;
     274        __u32 gop_closure;
     275        __u32 pulldown;
     276        __u32 stream_type;
     277};
     278
     279#endif /* _LINUX_IVTV_H */
  • libs/libmythtv/cardutil.cpp

     
    462462#endif // !USING_V4L
    463463}
    464464
    465 bool CardUtil::GetV4LInfo(int videofd, QString &card, QString &driver)
     465bool CardUtil::GetV4LInfo(
     466    int videofd, QString &card, QString &driver, uint32_t &version)
    466467{
    467468    card = driver = QString::null;
     469    version = 0;
    468470
    469471    if (videofd < 0)
    470472        return false;
     
    477479    {
    478480        card.setAscii((char*)capability.card);
    479481        driver.setAscii((char*)capability.driver);
     482        version = capability.version;
    480483    }
    481484    else // Fallback to V4L1 query
    482485    {
  • libs/libmythtv/mpegrecorder.cpp

     
    3333#include "tv_rec.h"
    3434#include "videodev_myth.h"
    3535#include "util.h"
     36#include "cardutil.h"
    3637
    3738// ivtv header
    3839extern "C" {
     
    7778    // Debugging variables
    7879    deviceIsMpegFile(false),
    7980    bufferSize(4096),
     81    // Config
     82    ignore_vbi_bug(false),
     83    // Driver info
     84    card(QString::null),      driver(QString::null),
     85    version(0),               usingv4l2(false),
     86    has_buggy_vbi(true),      has_v4l2_vbi(false),
    8087    // State
    8188    recording(false),         encoding(false),
    8289    errored(false),
     
    103110    buildbuffer(new unsigned char[kBuildBufferMaxSize + 1]),
    104111    buildbuffersize(0)
    105112{
     113    ignore_vbi_bug = gContext->GetNumSetting("IVTVIgnoreVBIBug", 0);
    106114}
    107115
    108116MpegRecorder::~MpegRecorder()
     
    311319        return false;
    312320    }
    313321
     322    if (CardUtil::GetV4LInfo(chanfd, card, driver, version))
     323    {
     324        usingv4l2     = (version >= KERNEL_VERSION(0, 8, 0));
     325        has_v4l2_vbi  = (version >= KERNEL_VERSION(0, 3, 8));
     326        has_buggy_vbi = (version <  KERNEL_VERSION(0, 10, 0));
     327    }
     328
     329    VERBOSE(VB_IMPORTANT, QString("IVTV VBI usingv4l2(%1) has_v4l2_vbi(%2) "
     330                                  "has_buggy_vbi(%3)")
     331            .arg(usingv4l2).arg(has_v4l2_vbi).arg(has_buggy_vbi));
     332
    314333    struct v4l2_format vfmt;
    315334    bzero(&vfmt, sizeof(vfmt));
    316335
     
    374393                "If you are using an AverMedia M179 card this is normal.");
    375394    }
    376395
    377     if (!SetV4L2DeviceOptions(chanfd) && !SetIVTVDeviceOptions(chanfd))
     396    bool ok = true;
     397    if (usingv4l2)
     398        ok = SetV4L2DeviceOptions(chanfd);
     399    else
     400        ok = SetIVTVDeviceOptions(chanfd);
     401
     402    if (!ok)
    378403        return false;
    379404
     405    SetVBIOptions(chanfd);
     406
    380407    readfd = open(videodevice.ascii(), O_RDWR | O_NONBLOCK);
    381408    if (readfd < 0)
    382409    {
     
    425452
    426453    keyframedist = (ivtvcodec.framerate) ? 12 : keyframedist;
    427454
    428     if (vbimode)
     455    return true;
     456}
     457
     458static int streamtype_ivtv_to_v4l2(int st)
     459{
     460    switch (st)
    429461    {
    430 #ifdef IVTV_IOC_S_VBI_MODE
    431         struct ivtv_sliced_vbi_format vbifmt;
    432         bzero(&vbifmt, sizeof(struct ivtv_sliced_vbi_format));
    433         vbifmt.service_set = (1 == vbimode) ? VBI_TYPE_TELETEXT : VBI_TYPE_CC;
    434 
    435         if (ioctl(chanfd, IVTV_IOC_S_VBI_MODE, &vbifmt) < 0)
    436 #endif // IVTV_IOC_S_VBI_MODE
    437         {
    438 #ifdef V4L2_CAP_SLICED_VBI_CAPTURE
    439             struct v4l2_format vbi_fmt;
    440             bzero(&vbi_fmt, sizeof(struct v4l2_format));
    441             vbi_fmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
    442             vbi_fmt.fmt.sliced.service_set = (1 == vbimode) ?
    443                 V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
    444 
    445             if (ioctl(chanfd, VIDIOC_S_FMT, &vbi_fmt) < 0)
    446 #endif // V4L2_CAP_SLICED_VBI_CAPTURE
    447             {
    448                 VERBOSE(VB_IMPORTANT, "Can't enable VBI recording" + ENO);
    449             }
    450         }
    451 
    452 #ifdef IVTV_IOC_S_VBI_EMBED
    453         int embedon = 1;
    454         if (ioctl(chanfd, IVTV_IOC_S_VBI_EMBED, &embedon) < 0)
    455 #endif // IVTV_IOC_S_VBI_EMBED
    456         {
    457             VERBOSE(VB_IMPORTANT, LOC + "Can't enable VBI recording (2)"+ENO);
    458         }
    459 
    460 #ifdef IVTV_IOC_G_VBI_MODE
    461         ioctl(chanfd, IVTV_IOC_G_VBI_MODE, &vbifmt);
    462 
    463         VERBOSE(VB_RECORD, LOC + QString(
    464                     "VBI service:%1, packet size:%2, io size:%3")
    465                 .arg(vbifmt.service_set).arg(vbifmt.packet_size)
    466                 .arg(vbifmt.io_size));
    467 #endif // IVTV_IOC_G_VBI_MODE
     462        case 0:  return V4L2_MPEG_STREAM_TYPE_MPEG2_PS;
     463        case 1:  return V4L2_MPEG_STREAM_TYPE_MPEG2_TS;
     464        case 2:  return V4L2_MPEG_STREAM_TYPE_MPEG1_VCD;
     465        case 3:  return V4L2_MPEG_STREAM_TYPE_MPEG2_PS;  /* PES A/V    */
     466        case 5:  return V4L2_MPEG_STREAM_TYPE_MPEG2_PS;  /* PES V      */
     467        case 7:  return V4L2_MPEG_STREAM_TYPE_MPEG2_PS;  /* PES A      */
     468        case 10: return V4L2_MPEG_STREAM_TYPE_MPEG2_DVD;
     469        case 11: return V4L2_MPEG_STREAM_TYPE_MPEG1_VCD; /* VCD */
     470        case 12: return V4L2_MPEG_STREAM_TYPE_MPEG2_SVCD;
     471        case 13: return V4L2_MPEG_STREAM_TYPE_MPEG2_DVD; /* DVD-Special 1 */
     472        case 14: return V4L2_MPEG_STREAM_TYPE_MPEG2_DVD; /* DVD-Special 2 */
     473        default: return V4L2_MPEG_STREAM_TYPE_MPEG2_TS;
    468474    }
    469 
    470     return true;
    471475}
    472476
    473477bool MpegRecorder::SetV4L2DeviceOptions(int chanfd)
     
    512516    ext_ctrl[5].value = maxbitrate * 1000;
    513517
    514518    ext_ctrl[6].id    = V4L2_CID_MPEG_STREAM_TYPE;
     519    ext_ctrl[6].value = streamtype_ivtv_to_v4l2(streamtype);
     520    // only PS supported with new API (at least as of 0.8.0)
    515521    ext_ctrl[6].value = V4L2_MPEG_STREAM_TYPE_MPEG2_PS;
    516522
    517523    ctrls.ctrl_class  = V4L2_CTRL_CLASS_MPEG;
     
    552558
    553559    keyframedist = ext_ctrl[0].value;
    554560
    555     // VBI is not yet working as of July 11th, 2006 with IVTV driver.
    556     // V4L2_CID_MPEG_STREAM_VBI_FMT needs to be finished/supported first.
    557     if (vbimode)
     561    return true;
     562}
     563
     564bool MpegRecorder::SetVBIOptions(int chanfd)
     565{
     566    if (!vbimode)
     567        return true;
     568
     569    if (has_buggy_vbi && !ignore_vbi_bug)
    558570    {
    559         struct v4l2_format vbifmt;
    560         bzero(&vbifmt, sizeof(struct v4l2_format));
    561         vbifmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
    562         /* vbifmt.fmt.sliced.service_set = (1==vbimode) ?
    563                                            VBI_TYPE_TELETEXT : VBI_TYPE_CC; */
    564         if (1 == vbimode)
    565             vbifmt.fmt.sliced.service_set |= V4L2_SLICED_VBI_625;
    566         else
    567             vbifmt.fmt.sliced.service_set |= V4L2_SLICED_VBI_525;
     571        VERBOSE(VB_IMPORTANT, LOC_WARN + "Not enabling VBI recording.\n\t\t\t"
     572                "Please upgrade to ivtv 0.10.0 or later for caption support.");
    568573
    569         if (ioctl(chanfd, VIDIOC_S_FMT, &vbifmt) < 0)
     574        return false;
     575    }
     576
     577#ifdef IVTV_IOC_S_VBI_EMBED
     578    if (!has_v4l2_vbi)
     579    {
     580        struct ivtv_sliced_vbi_format vbifmt;
     581        bzero(&vbifmt, sizeof(struct ivtv_sliced_vbi_format));
     582        vbifmt.service_set = (1 == vbimode) ? VBI_TYPE_TELETEXT : VBI_TYPE_CC;
     583
     584        if (ioctl(chanfd, IVTV_IOC_S_VBI_MODE, &vbifmt) < 0)
    570585        {
    571             VERBOSE(VB_IMPORTANT, "Can't enable VBI recording" + ENO);
     586            VERBOSE(VB_IMPORTANT, LOC_WARN +
     587                    "Can't enable VBI recording (3)" + ENO);
     588
     589            return false;
    572590        }
    573591
    574         struct v4l2_ext_control vbi_fmt;
    575         vbi_fmt.id    = V4L2_CID_MPEG_STREAM_VBI_FMT;
    576         vbi_fmt.value = V4L2_MPEG_STREAM_VBI_FMT_IVTV;
    577         ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
    578         ctrls.count      = 1;
    579         ctrls.controls   = &vbi_fmt;
    580         if (ioctl(chanfd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0)
     592        int embedon = 1;
     593        if (ioctl(chanfd, IVTV_IOC_S_VBI_EMBED, &embedon) < 0)
    581594        {
    582             VERBOSE(VB_IMPORTANT, LOC + "Can't enable VBI recording (2)"+ENO);
     595            VERBOSE(VB_IMPORTANT, LOC_WARN +
     596                    "Can't enable VBI recording (4)" + ENO);
     597
     598            return false;
    583599        }
    584600
    585         ioctl(chanfd, VIDIOC_G_FMT, &vbifmt);
     601        if (ioctl(chanfd, IVTV_IOC_G_VBI_MODE, &vbifmt) >= 0)
     602        {
     603            VERBOSE(VB_RECORD, LOC + QString(
     604                        "VBI service:%1, packet size:%2, io size:%3")
     605                    .arg(vbifmt.service_set).arg(vbifmt.packet_size)
     606                    .arg(vbifmt.io_size));
     607        }
    586608
    587         VERBOSE(VB_RECORD, LOC + QString(
    588                 "VBI service:%1, io size:%3")
     609        return true;
     610    }
     611#endif // IVTV_IOC_S_VBI_EMBED
     612
     613    struct v4l2_format vbifmt;
     614    bzero(&vbifmt, sizeof(struct v4l2_format));
     615    vbifmt.type = V4L2_BUF_TYPE_SLICED_VBI_CAPTURE;
     616    vbifmt.fmt.sliced.service_set |= (1 == vbimode) ?
     617        V4L2_SLICED_VBI_625 : V4L2_SLICED_VBI_525;
     618
     619    if (ioctl(chanfd, VIDIOC_S_FMT, &vbifmt) < 0)
     620    {
     621        VERBOSE(VB_IMPORTANT, LOC_WARN +
     622                "Can't enable VBI recording (1)" + ENO);
     623
     624        return false;
     625    }
     626
     627    struct v4l2_ext_control vbi_ctrl;
     628    vbi_ctrl.id       = V4L2_CID_MPEG_STREAM_VBI_FMT;
     629    vbi_ctrl.value    = V4L2_MPEG_STREAM_VBI_FMT_IVTV;
     630
     631    struct v4l2_ext_controls ctrls;
     632    bzero(&ctrls, sizeof(struct v4l2_ext_controls));
     633    ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
     634    ctrls.count      = 1;
     635    ctrls.controls   = &vbi_ctrl;
     636
     637    if (ioctl(chanfd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0)
     638    {
     639        VERBOSE(VB_IMPORTANT, LOC_WARN +
     640                "Can't enable VBI recording (2)" + ENO);
     641
     642        return false;
     643    }
     644
     645    if (ioctl(chanfd, VIDIOC_G_FMT, &vbifmt) >= 0)
     646    {
     647        VERBOSE(VB_RECORD, LOC + QString("VBI service: %1, io size: %2")
    589648                .arg(vbifmt.fmt.sliced.service_set)
    590649                .arg(vbifmt.fmt.sliced.io_size));
    591650    }
  • libs/libmythtv/recordingprofile.cpp

     
    847847    class Width : public SpinBoxSetting, public CodecParamStorage
    848848    {
    849849      public:
    850         Width(const RecordingProfile &parent, int maxwidth = 704,
     850        Width(const RecordingProfile &parent,
     851              uint defaultwidth, uint maxwidth,
    851852              bool transcoding = false) :
    852853            SpinBoxSetting(this, transcoding ? 0 : 160,
    853854                           maxwidth, 16, false,
     
    855856            CodecParamStorage(this, parent, "width")
    856857        {
    857858            setLabel(QObject::tr("Width"));
    858             setValue(480);
    859             if (transcoding)
    860                 setHelpText(QObject::tr("If the width is set to 'Auto', "
    861                             "the width will be calculated based on the height "
    862                             "and the recording's physical aspect ratio."));
     859            setValue(defaultwidth);
     860
     861            QString help = (transcoding) ?
     862                QObject::tr("If the width is set to 'Auto', the width "
     863                            "will be calculated based on the height and "
     864                            "the recording's physical aspect ratio.") :
     865                QObject::tr("Width to use for encoding. "
     866                            "Note: PVR-150 and PVR-500 devices do not "
     867                            "function correctly unless this is set to 720.");
     868
     869            setHelpText(help);
    863870        };
    864871    };
    865872
    866873    class Height: public SpinBoxSetting, public CodecParamStorage
    867874    {
    868875      public:
    869         Height(const RecordingProfile &parent, int maxheight=576,
     876        Height(const RecordingProfile &parent,
     877               uint defaultheight, uint maxheight,
    870878               bool transcoding = false):
    871879            SpinBoxSetting(this, transcoding ? 0 : 160,
    872880                           maxheight, 16, false,
     
    874882            CodecParamStorage(this, parent, "height")
    875883        {
    876884            setLabel(QObject::tr("Height"));
    877             setValue(480);
    878             if (transcoding)
    879                 setHelpText(QObject::tr("If the height is set to 'Auto', "
    880                             "the height will be calculated based on the width "
    881                             "and the recording's physical aspect ratio."));
     885            setValue(defaultheight);
     886
     887            QString help = (transcoding) ?
     888                QObject::tr("If the height is set to 'Auto', the height "
     889                            "will be calculated based on the width and "
     890                            "the recording's physical aspect ratio.") :
     891                QObject::tr("Height to use for encoding. "
     892                            "Note: PVR-150 and PVR-500 devices do not "
     893                            "function correctly unless this is set to "
     894                            "480 or 576 for NTSC and PAL, respectively.");
     895
     896            setHelpText(help);
    882897        };
    883898    };
    884899
     
    894909            labelName = profName + "->" + QObject::tr("Image size");
    895910        setLabel(labelName);
    896911
    897         QString fullsize, halfsize;
    898         int maxwidth, maxheight;
    899         bool transcoding = false;
    900         if (profName.left(11) == "Transcoders") {
    901             maxwidth = 1920;
    902             maxheight = 1088;
    903             transcoding = true;
    904         } else if ((tvFormat.lower() == "ntsc") ||
    905                    (tvFormat.lower() == "ntsc-jp")) {
    906             maxwidth = 720;
    907             maxheight = 480;
    908         } else if (tvFormat.lower() == "atsc") {
    909             maxwidth = 1920;
    910             maxheight = 1088;
    911         } else {
    912             maxwidth = 768;
    913             maxheight = 576;
     912        QSize defaultsize(768, 576), maxsize(768, 576);
     913        bool transcoding = profName.left(11) == "Transcoders";
     914        bool ivtv = profName.left(34) == "MPEG-2 Encoders (PVR-x50, PVR-500)";
     915
     916        if (transcoding)
     917        {
     918            maxsize     = QSize(1920, 1088);
     919            defaultsize = QSize(480, 480);
    914920        }
     921        else if (tvFormat.lower().left(4) == "ntsc")
     922        {
     923            maxsize     = QSize(720, 480);
     924            defaultsize = (ivtv) ? QSize(720, 480) : QSize(480, 480);
     925        }
     926        else if (tvFormat.lower() == "atsc")
     927        {
     928            maxsize     = QSize(1920, 1088);
     929            defaultsize = QSize(1920, 1088);
     930        }
     931        else
     932        {
     933            maxsize     = QSize(768, 576);
     934            defaultsize = (ivtv) ? QSize(720, 576) : QSize(480, 576);
     935        }
    915936
    916         imgSize->addChild(new Width(parent, maxwidth, transcoding));
    917         imgSize->addChild(new Height(parent, maxheight, transcoding));
     937        imgSize->addChild(new Width(parent, defaultsize.width(),
     938                                    maxsize.width(), transcoding));
     939        imgSize->addChild(new Height(parent, defaultsize.height(),
     940                                     maxsize.height(), transcoding));
     941
    918942        addChild(imgSize);
    919943    };
    920944};
     
    10011025{
    10021026    MSqlQuery result(MSqlQuery::InitCon());
    10031027    result.prepare(
    1004         "SELECT cardtype "
     1028        "SELECT cardtype, profilegroups.name "
    10051029        "FROM profilegroups, recordingprofiles "
    10061030        "WHERE profilegroups.id     = recordingprofiles.profilegroup AND "
    10071031        "      recordingprofiles.id = :PROFILEID");
     
    10131037    else if (result.next())
    10141038    {
    10151039        type = result.value(0).toString();
     1040        if (profileName.isEmpty())
     1041            profileName = result.value(1).toString();
    10161042        isEncoder = CardUtil::IsEncoder(type);
    10171043    }
    10181044