Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Oct 1997 07:45:33 -0300 (EST)
From:      Joao Carlos Mendes Luis <jonny@coppe.ufrj.br>
To:        multimedia@freebsd.org
Subject:   Proposed patches to fxtv
Message-ID:  <199710051045.HAA11860@gaia.coppe.ufrj.br>

next in thread | raw e-mail | index | archive | help
Hi,

  Here are the patches I have done to fxtv 0.44 to support my changes
to the bt848 driver.  It's just a test patch,, with a not so good interface
so it should be completely redesigned.

  I know nothing about X programming, so please don't flame me for
programming style.  After understanding how the bt848 chip works,
it took me 10 minutes to patch the kernel, and a whole night to
patch fxtv.  :)

  Randall, could you please take a look on this and make any changes you
want ?  I'd like to see support for this integrated in some future version
of fxtv, so that I can (also) work and watch TV at the same time.  :)

					Jonny

--
Joao Carlos Mendes Luis			jonny@gta.ufrj.br
+55 21 290-4698				jonny@coppe.ufrj.br
Universidade Federal do Rio de Janeiro	UFRJ/COPPE/CISI
PGP fingerprint: 29 C0 50 B9 B6 3E 58 F2  83 5F E3 26 BF 0F EA 67

--- org/tvcapture.h	Wed Sep  3 20:25:52 1997
+++ tvcapture.h	Sun Oct  5 06:44:03 1997
@@ -57,9 +57,14 @@
         } TV_INPUT_DEVICE;
 
 typedef enum {
-            TV_INPUT_NTSC,
-            TV_INPUT_PAL,
-            TV_INPUT_AUTO
+            TV_INPUT_AUTO,
+            TV_INPUT_NTSCM,
+            TV_INPUT_NTSCJ,
+            TV_INPUT_PALBDGHI,
+            TV_INPUT_PALM,
+            TV_INPUT_PALN,
+            TV_INPUT_SECAM,
+            TV_INPUT_PALNCOMB
         } TV_INPUT_FORMAT;
 
 typedef enum {
--- org/tv.c	Sun Sep  7 20:48:45 1997
+++ tv.c	Sun Oct  5 07:17:04 1997
@@ -199,6 +199,24 @@
         { TV_FREQ_SET_WEUROPE , "weurope"  },
         { TV_FREQ_SET_JPNBCST , "jpnbcst"  },
     };
+    static const struct {
+	TV_INPUT_FORMAT mode;
+	const char *str;
+    } formats[] = {
+	{ TV_INPUT_AUTO,	"auto"		},
+	{ TV_INPUT_NTSCM,	"ntsc"		},
+	{ TV_INPUT_NTSCM,	"ntscm"		},
+	{ TV_INPUT_NTSCJ,	"ntscj"		},
+	{ TV_INPUT_PALBDGHI,	"palbdghi"	},
+	{ TV_INPUT_PALBDGHI,	"pal"		},
+	{ TV_INPUT_PALM,	"palm"		},
+	{ TV_INPUT_PALN,	"paln"		},
+	{ TV_INPUT_SECAM,	"secam"		},
+	{ TV_INPUT_PALNCOMB,	"palncomb"	},
+	{ TV_INPUT_PALNCOMB,	"rsvd"		},
+	{ 0,			NULL		}
+    };
+
 
     TV_DISK        *dsk = &G_glob.disk;
     TV_DISPLAY     *d = &G_glob.display;
@@ -218,10 +236,12 @@
     if ( !App_res.driver_defaults ) {
 
         /*  Input format  */
-        input_format = TV_INPUT_NTSC;
-        if (( strcmp( App_res.input_format, "pal" ) == 0 ) ||
-            ( strcmp( App_res.input_format, "PAL" ) == 0 ))
-            input_format = TV_INPUT_PAL;
+        input_format = TV_INPUT_NTSCM;
+	for ( i = 0 ; formats[i].str == NULL ; ++i ) {
+	  if ( strcasecmp( App_res.input_format, formats[i].str ) == 0 ) {
+	    input_format = formats[i].mode;
+	  }
+	}
 
         TVCAPTURESetInputFormat( c, input_format );
         dsk->video.geom.w = c->width_max  / 2;
--- org/tvcapture.c	Sun Sep  7 18:47:06 1997
+++ tvcapture.c	Sun Oct  5 06:45:30 1997
@@ -382,27 +382,38 @@
     TV_INT32 larg;
 
     switch ( format ) {
-        case TV_INPUT_NTSC : larg = METEOR_FMT_NTSC;  break;
-        case TV_INPUT_PAL  : larg = METEOR_FMT_PAL ;  break;
+        case TV_INPUT_AUTO	: larg = BT848_IFORM_F_AUTO    ;  break;
+        case TV_INPUT_NTSCM	: larg = BT848_IFORM_F_NTSCM   ;  break;
+        case TV_INPUT_NTSCJ	: larg = BT848_IFORM_F_NTSCJ   ;  break;
+        case TV_INPUT_PALBDGHI	: larg = BT848_IFORM_F_PALBDGHI;  break;
+        case TV_INPUT_PALM	: larg = BT848_IFORM_F_PALM    ;  break;
+        case TV_INPUT_PALN	: larg = BT848_IFORM_F_PALN    ;  break;
+        case TV_INPUT_SECAM	: larg = BT848_IFORM_F_SECAM   ;  break;
+        case TV_INPUT_PALNCOMB	: larg = BT848_IFORM_F_RSVD    ;  break;
         default :
             fprintf( stderr, 
                "TVCAPTURESetInputFormat: Unsupported format %d\n", format );
             exit(1);
     }
-    if ( ioctl( c->fd, METEORSFMT, &larg ) < 0 ) {
-        DO_IOCTL_SERR( "METEORSFMT", larg );
+    if ( ioctl( c->fd, BT848SFMT, &larg ) < 0 ) {
+        DO_IOCTL_SERR( "BT848SFMT", larg );
         return;
     }
 
     /*  Update max capture size based on driver format  */
     /*  FIXME: These belong in the driver/driver include file  */
     switch ( format ) {
-        case TV_INPUT_NTSC :
+        case TV_INPUT_NTSCM:
+        case TV_INPUT_NTSCJ:
+        case TV_INPUT_PALM:
             c->width_max  = 640;
             c->height_max = 480;
             c->fps_max    =  30;
             break;
-        case TV_INPUT_PAL  :
+        case TV_INPUT_PALBDGHI:
+        case TV_INPUT_PALN:
+        case TV_INPUT_SECAM:
+        case TV_INPUT_PALNCOMB:
             c->width_max  = 768;
             c->height_max = 576;
             c->fps_max    =  25;
@@ -611,14 +622,19 @@
     }
 
     /*  INPUT FORMAT  */
-    if ( ioctl( c->fd, METEORGFMT, &larg ) < 0 ) {
-        DO_IOCTL_GERR( "METEORGFMT" );
+    if ( ioctl( c->fd, BT848GFMT, &larg ) < 0 ) {
+        DO_IOCTL_GERR( "BT848GFMT" );
         return False;
     }
     switch ( larg ) {
-        case METEOR_FMT_NTSC     : s->input_fmt = TV_INPUT_NTSC;  break;
-        case METEOR_FMT_PAL      : s->input_fmt = TV_INPUT_PAL ;  break;
-        case METEOR_FMT_AUTOMODE : s->input_fmt = TV_INPUT_AUTO;  break;
+        case BT848_IFORM_F_AUTO    : s->input_fmt = TV_INPUT_AUTO    ;  break;
+        case BT848_IFORM_F_NTSCM   : s->input_fmt = TV_INPUT_NTSCM   ;  break;
+        case BT848_IFORM_F_NTSCJ   : s->input_fmt = TV_INPUT_NTSCJ   ;  break;
+        case BT848_IFORM_F_PALBDGHI: s->input_fmt = TV_INPUT_PALBDGHI;  break;
+        case BT848_IFORM_F_PALM    : s->input_fmt = TV_INPUT_PALM    ;  break;
+        case BT848_IFORM_F_PALN    : s->input_fmt = TV_INPUT_PALN    ;  break;
+        case BT848_IFORM_F_SECAM   : s->input_fmt = TV_INPUT_SECAM   ;  break;
+        case BT848_IFORM_F_RSVD    : s->input_fmt = TV_INPUT_PALNCOMB;  break;
         default :
              fprintf( stderr, "TVCAPTUREQueryDriverState(): Bad FMT %d\n",
                       larg );
@@ -1084,7 +1100,7 @@
         exit(1);
     }
 
-    c->input_format  = METEOR_FMT_NTSC;
+    c->input_format  = BT848_IFORM_F_NTSCM;
     c->input_dev     = METEOR_INPUT_DEV0;
     c->bpp_format    = METEOR_GEO_RGB16;
     c->cap_mode      = TV_CAPTURE_CONTINUOUS;
@@ -1118,12 +1134,13 @@
     c->height_min = 2;
     c->height_res = 2;
     switch ( c->input_format ) {
-        case METEOR_FMT_NTSC :
+        case BT848_IFORM_F_NTSCM :
+        case BT848_IFORM_F_NTSCJ :
+        case BT848_IFORM_F_PALM  :
             c->width_max  = 640;
             c->height_max = 480;
             c->fps_max    =  30;
             break;
-        case METEOR_FMT_PAL  :
         default              :
             c->width_max  = 768;
             c->height_max = 576;
--- org/tvmenu.h	Sun Sep  7 12:35:58 1997
+++ tvmenu.h	Sun Oct  5 06:53:40 1997
@@ -50,6 +50,14 @@
     TV_MENUITEM_INPUT_SVHS,
     TV_MENUITEM_TMODE_ANTENNA,
     TV_MENUITEM_TMODE_CABLE,
+    TV_MENUITEM_FORMAT_AUTO,
+    TV_MENUITEM_FORMAT_NTSCM,
+    TV_MENUITEM_FORMAT_NTSCJ,
+    TV_MENUITEM_FORMAT_PALBDGHI,
+    TV_MENUITEM_FORMAT_PALM,
+    TV_MENUITEM_FORMAT_PALN,
+    TV_MENUITEM_FORMAT_SECAM,
+    TV_MENUITEM_FORMAT_PALNCOMB,
     TV_MENUITEM_OPTIONS_ASPECT,
     TV_MENUITEM_OPTIONS_AFC,
     TV_MENUITEM_OPTIONS_SAVE,
@@ -83,6 +91,8 @@
 Widget TVTOOLSGetVolumeScrollbar( void );
 
 void TVMENUSetSelectedInputDevice( TV_INPUT_DEVICE dev );
+
+void TVMENUSetSelectedInputFormat( TV_INPUT_FORMAT fmt );
 
 void TVMENUSetSelectedAfcMode( TV_BOOL afc );
 
--- org/app_rsrc.h	Sun Sep  7 21:02:27 1997
+++ app_rsrc.h	Sun Oct  5 07:02:43 1997
@@ -423,6 +423,17 @@
    "*menuBox*inputMenu*tmodeCable.label:      Cable",
    "*menuBox*inputMenu*appearanceCmd.label:   Appearance...",
 
+   "*menuBox*formatMenu.label:                Format",
+   "*menuBox*formatMenu.menu.label:           Format",
+   "*menuBox*formatMenu*autoFmt.label:        Auto",
+   "*menuBox*formatMenu*ntscmFmt.label:       NTSC/M",
+   "*menuBox*formatMenu*ntscjFmt.label:       NTSC/J",
+   "*menuBox*formatMenu*palbdghiFmt.label:    PAL/BDGHI",
+   "*menuBox*formatMenu*palmFmt.label:        PAL/M",
+   "*menuBox*formatMenu*palnFmt.label:        PAL/N",
+   "*menuBox*formatMenu*secamFmt.label:       SECAM",
+   "*menuBox*formatMenu*palncombFmt.label:    PAL/N Comb",
+
    "*menuBox*optionsMenu.label:               Options",
    "*menuBox*optionsMenu.menu.label:          Options",
    "*menuBox*optionsMenu*aspectLockCmd.label: Aspect Lock",
--- org/tvmenu.c	Sun Sep  7 12:44:15 1997
+++ tvmenu.c	Sun Oct  5 07:08:23 1997
@@ -62,6 +62,7 @@
 typedef enum {
     TV_MENU_FILE = 0,
     TV_MENU_INPUT,
+    TV_MENU_FORMAT,
     TV_MENU_OPTIONS,
     TV_MENU_HELP,
        TV_NUM_MENUS
@@ -97,7 +98,7 @@
 
 static XT_CB QuitCB, FreezeCB, MuteCB, ZoomCB, InputCB, AfcCB, TModeCB, 
              ChanUpDnCB, AppearCB, AspectCB, AboutCB, ImgSavCB, ImgSavAsCB, 
-             AudSavAsCB, VidSavAsCB;
+             AudSavAsCB, VidSavAsCB, FormatCB;
 
 /*      ******************** Private variables            ************** */
 
@@ -112,6 +113,7 @@
 static TV_MENU_DEF Menu_def[] = {
     { TV_MENU_FILE   , "fileMenu"    },
     { TV_MENU_INPUT  , "inputMenu"   },
+    { TV_MENU_FORMAT , "formatMenu"  },
     { TV_MENU_OPTIONS, "optionsMenu" },
     { TV_MENU_HELP   , "helpMenu"    }
 };
@@ -137,6 +139,14 @@
    { TVMI( INPUT,TMODE_CABLE        ), "tmodeCable"    , WC_mcmd , TModeCB   },
    { TV_MENU_INPUT, -1               , "line"          , WC_mline, NULL      },
    { TVMI( INPUT,INPUT_APPEARANCE   ), "appearanceCmd" , WC_mcmd , AppearCB  },
+   { TVMI( FORMAT,FORMAT_AUTO       ), "autoFmt"       , WC_mcmd , FormatCB  },
+   { TVMI( FORMAT,FORMAT_NTSCM      ), "ntscmFmt"      , WC_mcmd , FormatCB  },
+   { TVMI( FORMAT,FORMAT_NTSCJ      ), "ntscjFmt"      , WC_mcmd , FormatCB  },
+   { TVMI( FORMAT,FORMAT_PALBDGHI   ), "palbdghiFmt"   , WC_mcmd , FormatCB  },
+   { TVMI( FORMAT,FORMAT_PALM       ), "palmFmt"       , WC_mcmd , FormatCB  },
+   { TVMI( FORMAT,FORMAT_PALN       ), "palnFmt"       , WC_mcmd , FormatCB  },
+   { TVMI( FORMAT,FORMAT_SECAM      ), "secamFmt"      , WC_mcmd , FormatCB  },
+   { TVMI( FORMAT,FORMAT_PALNCOMB   ), "palncombFmt"   , WC_mcmd , FormatCB  },
    { TVMI( OPTIONS,OPTIONS_ASPECT   ), "aspectLockCmd" , WC_mcmd , AspectCB  },
    { TVMI( OPTIONS,OPTIONS_AFC      ), "setAfcCmd",      WC_mcmd , AfcCB     },
    { TV_MENU_OPTIONS, -1             , "line"          , WC_mline, NULL      },
@@ -285,6 +295,57 @@
 }
 
 
+/*  FormatCB - Change the input format to that selected  */
+static void FormatCB( Widget w, XtPointer cl, XtPointer cb )
+{
+    static struct {
+      TV_MENUITEM_KEY key;
+      TV_INPUT_FORMAT fmt;
+    } menuitem[] = {
+      { TV_MENUITEM_FORMAT_AUTO,	TV_INPUT_AUTO	},
+      { TV_MENUITEM_FORMAT_NTSCM,	TV_INPUT_NTSCM	},
+      { TV_MENUITEM_FORMAT_NTSCJ,	TV_INPUT_NTSCJ	},
+      { TV_MENUITEM_FORMAT_PALBDGHI,	TV_INPUT_PALBDGHI },
+      { TV_MENUITEM_FORMAT_PALM,	TV_INPUT_PALM	},
+      { TV_MENUITEM_FORMAT_PALN,	TV_INPUT_PALN	},
+      { TV_MENUITEM_FORMAT_SECAM,	TV_INPUT_SECAM	},
+      { TV_MENUITEM_FORMAT_PALNCOMB,	TV_INPUT_PALNCOMB },
+      { -1, -1 }
+    };
+    int i;
+
+    TV_DISPLAY      *d = &G_glob.display;
+    TV_CAPTURE      *c = &G_glob.capture;
+    TV_BOOL          on;
+    TV_INPUT_FORMAT  fmt;
+
+    fmt = -1;
+    for ( i = 0 ; menuitem[i].key != -1 ; ++i ) {
+      if ( w == LookupMenuItemByKey( menuitem[i].key )->wgt ) {
+	fmt = menuitem[i].fmt;
+	break;
+      }
+    }
+
+    if ( fmt == -1 ) {
+        fprintf( stderr, "Unknown input format widget: %s\n", XtName( w ) );
+        return;
+    }
+
+    on = d->enabled && c->contin_on;
+
+    /*  Update input device setting  */
+    if ( on )
+        TVSCREENStopVideo( False );
+    TVCAPTURESetInputFormat( c, fmt );
+    if ( on )
+        TVSCREENStartVideo( False );
+
+    /*  Update which menu item is selected  */
+    TVMENUSetSelectedInputFormat( fmt );
+}
+
+
 /*  AfcCB - Change the AFC mode */
 static void AfcCB( Widget w, XtPointer cl, XtPointer cb )
 {
@@ -694,6 +755,39 @@
     pix = ( dev == TV_DEVICE_SVHS  ) ? Select_pixmap : Unselect_pixmap;
     XtVaSetValues( svhs->wgt , XtNleftBitmap, pix,
                                NULL );
+}
+
+void TVMENUSetSelectedInputFormat( TV_INPUT_FORMAT fmt )
+{
+    /*  This struct is EQUAL to FormatCB, maybe it should be a global.	*/
+    static struct {
+      TV_MENUITEM_KEY key;
+      TV_INPUT_FORMAT fmt;
+    } menu[] = {
+      { TV_MENUITEM_FORMAT_AUTO,	TV_INPUT_AUTO	},
+      { TV_MENUITEM_FORMAT_NTSCM,	TV_INPUT_NTSCM	},
+      { TV_MENUITEM_FORMAT_NTSCJ,	TV_INPUT_NTSCJ	},
+      { TV_MENUITEM_FORMAT_PALBDGHI,	TV_INPUT_PALBDGHI },
+      { TV_MENUITEM_FORMAT_PALM,	TV_INPUT_PALM	},
+      { TV_MENUITEM_FORMAT_PALN,	TV_INPUT_PALN	},
+      { TV_MENUITEM_FORMAT_SECAM,	TV_INPUT_SECAM	},
+      { TV_MENUITEM_FORMAT_PALNCOMB,	TV_INPUT_PALNCOMB },
+      { -1, -1 }
+    };
+    TV_MENUITEM_DEF *mi;
+    Pixmap           pix;
+    int i;
+
+    if ( Select_pixmap == None )
+        TVMENULoadRadioPixmaps();
+
+    for ( i = 0 ; menu[i].key != -1 ; ++i ) {
+      mi = LookupMenuItemByKey( menu[i].key );
+      assert( mi != NULL );
+      assert( mi->wgt != NULL );
+      pix = ( fmt == menu[i].fmt ) ? Select_pixmap : Unselect_pixmap;
+      XtVaSetValues( mi->wgt, XtNleftBitmap, pix, NULL);
+    }
 }
 
 void TVMENUSetSelectedTunerMode( TV_TUNER_MODE mode )



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199710051045.HAA11860>