Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Feb 2000 11:24:36 -0800
From:      Tim Pozar <pozar@lns.com>
To:        Thomas Runge <runge@rostock.zgdv.de>
Cc:        multimedia@FreeBSD.ORG
Subject:   Re: API for the bk848 driver
Message-ID:  <20000222112436.A70343@lns.com>
In-Reply-To: <389FC9D5.B2D3E98A@rostock.zgdv.de>; from runge@rostock.zgdv.de on Tue, Feb 08, 2000 at 08:46:29AM %2B0100
References:  <Pine.GSO.4.05.10002021414220.24185-100000@kinkajou.arc.nasa.gov> <Pine.BSF.4.10.10002080007020.296-100000@snuggly.demon.co.uk> <20000207212734.A65913@lns.com> <389FAAA8.EBE87E1@cs.strath.ac.uk> <20000207221041.A66557@lns.com> <389FC9D5.B2D3E98A@rostock.zgdv.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 08, 2000 at 08:46:29AM +0100, Thomas Runge wrote:
> Tim Pozar wrote:
> > I looked at the meteor man page and it describes capturing video
> > but it doesn't address the tuner.  I am looking for info on the
> > radio tuner in cards like the Hauppauge WinTV-radio (model 401).
> 
> Well, there is no book "Programming the FM tuner of TV cards
> using FreeBSD" ;-)
> What we have are the sources. And some programs that already use
> the radio part, like xmradio.
> 
> Look into /sys/dev/bktr, http://vulture.dmem.strath.ac.uk/bt848/ ,
> especially ftp://vulture.dmem.strath.ac.uk/pub/bt848/spec
> and maybe into xmradio: http://www.rostock.zgdv.de/~runge/radio

Thanks for the pointer folks.

The reason for all of this, I have a number of boxes out there that
do MP3 streaming of FM stations and wanted them to start to stream
from a boot and not have to rely on an Xwindows application to open
the tuner and set the frequency.

To that I have this simple program now...

Tim
--
/* 
 *  
 *  TUNERADIO
 *  
 *  Opens the the tuner device (ie. /dev/tuner) sets the frequency,
 *  stereo/mono and AFC modes.  It then sits in a while loop to
 *  keep the device open.
 *
 *  I needed this program to run on remote computers that stream 
 *  MP3 streams out to the net of radio stations.  This program 
 *  assumes the Brooktree 848 card and interface for *BSD.
 *
 *  Copyright (C) 2000 Timothy Pozar pozar@lns.com
 *  
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *  
 *  $Id: tuneradio.c,v 1.2 2000/02/22 19:20:02 pozar Exp $
 *  
 */

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <machine/ioctl_bt848.h>

#define TRUE 1
#define FALSE 0
#define BUF_SIZE 4096

char device[BUF_SIZE] = "/dev/tuner";
int mono = FALSE;
int afc = FALSE;
int frequency = 8850;	/* 8850 = 88.5Mhz */
int devfh;

int main(argc,argv)
int argc;
char *argv[];
{
int gotmask, setmask, gotfreq, setfreq, i;

   /* scan command line arguments, and look for files to work on. */
   for (i = 1; i < argc; i++) {
      switch (argv[i][1]){   /* be case indepenent... */
         case 'A':   /* Run with AFC... */
         case 'a':
            afc = TRUE;
            break;  
         case 'D':   /* dsp file name... */
         case 'd':
            i++;
            strncpy(device,argv[i],BUF_SIZE);
            break;
         case 'F':   /* Frequency in 10 KHz... */
         case 'f':
            i++;
            frequency = atoi(argv[i]);
            if((frequency < 8800) || (frequency > 10800)){
               printf("Frequency %i is out of range of 8800 to 10800\n",frequency);
               exit(1);
            }
            break;
         case 'H':   /* Help... */
         case 'h':
            banner();
            exit(0);
         case 'M':   /* Run in mono... */
         case 'm':
            mono = TRUE;
            break;  
         default:
            printf("I don't know the meaning of the command line argument: \"%s\".\n",argv[i]);
            banner();
            exit(1);
      }
   }

   if((devfh = open(device, O_RDONLY)) == -1){
      perror("opening dsp device");
      exit(1);
   }

   /* What state is the tuner in now? */
   if(ioctl(devfh, RADIO_GETMODE, &gotmask) == -1){
      perror("get dsp mask");
      exit(1);
   }

   setmask = gotmask;

   if(mono)
      setmask |= RADIO_MONO;    
   else
      setmask &= ~RADIO_MONO;

   if(afc)
      setmask |= RADIO_AFC;    
   else
      setmask &= ~RADIO_AFC;

   if(ioctl(devfh, RADIO_SETMODE, &setmask) == -1){
      perror("set mode");
      exit(1);
   }

   if(ioctl(devfh, RADIO_SETFREQ, &frequency) == -1){
      perror("set frequency");
      exit(1);
   }

   while(1){}

   exit(0);
}

banner()
{
   printf("tuneradio: Set \"%s\" frequency, AFC and stereo/mono mode,\n",device);
   printf("           and then keep the tuner open.\n");
   printf("   -a            Sets tuner to run with AFC.  Default is off.\n");
   printf("   -d device     Sets device name for the tuner.  Default is \"%s\".\n",device);
   printf("   -f frequency  Sets tuner frequency (10Khz ie 88.1Mhz = 8810).\n");
   printf("                 Default is \"%i\".\n",frequency);
   printf("   -m            Sets tuner to run in mono.  Default is stereo.\n");
   return;
}


-- 
  Snail: Tim Pozar / LNS / 1978 45th Ave / San Francisco CA 94116 / USA
               POTS: +1 415 665 3790  Radio: KC6GNJ / KAE6247
"It's a damn poor mind that can only think of one way to spell a word."
                        - Andrew Jackson
"What is wanted is not the will to believe, but the will to find out,
    which is the exact opposite."              - Bertrand Russel


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-multimedia" in the body of the message




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