Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 02 Jan 1998 12:00:37 -0800
From:      Amancio Hasty <hasty@rah.star-gate.com>
To:        Wolfram Blase <wbl@informatik.uni-kiel.de>
Cc:        multimedia@freebsd.org
Message-ID:  <199801022000.MAA04614@rah.star-gate.com>

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

Last set of patches.

	Amancio


------- Forwarded Message

Return-Path: fj@schizo.dk.tfs.com
Received: from mailhub (tfs.com [140.145.250.1])
          by rah.star-gate.com (8.8.8/8.8.8) with SMTP id GAA27222
          for <hasty@rah.star-gate.com>; Sun, 30 Nov 1997 06:07:14 -0800 (PST)
          (envelope-from fj@schizo.dk.tfs.com)
Received: from schizo.dk.tfs.com by mailhub (SMI-8.6/SMI-SVR4)
	id GAA18954; Sun, 30 Nov 1997 06:00:25 -0800
Received: (from fj@localhost) by schizo.dk.tfs.com (8.8.7/8.7.3) id PAA29565 
for hasty@rah.star-gate.com; Sun, 30 Nov 1997 15:06:36 +0100 (MET)
From: Flemming Jacobsen <fj@schizo.dk.tfs.com>
Message-Id: <199711301406.PAA29565@schizo.dk.tfs.com>
Subject: bktr radio patches
To: hasty@rah.star-gate.com (Amancio Hasty)
Date: Sun, 30 Nov 1997 15:06:36 +0100 (MET)
X-Mailer: ELM [version 2.4ME+ PL32 (25)]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi Amancio,

This is the patches for radio support in the bktr driver. 
I decided to do a special ioctl for setting the radio frequency, as having
3 magic numbers in application land is fairly stupid. I've made a small
program to tune the radio (instant clock-radio, just add cron :-).
I've not figured out what the program forgets to initialize in the driver,
if you know, please share.

The modifications to the driver should work for both the Philips FM1216 
tuner (which I have) and the FR1216 (for which I have the datasheet).

This is still work in progress. I need to add a couple of ioctl's to help
people writing a radio application.

Are there any extensions to tcl/Tk allowing you to do ioctl's ?

  	Have a nice day
	Flemming

- --------8<---------------8<---------------8<---------------8<-------
/*
** radio.c - Manipulate the radio mode of bt848 based video cards.
**
** This program doesn't fully initialize the card. Start and stop fxtv
**  to do this. Then use this program to set the radio frequency.
**
** Flemming Jacobsen 971130, fj@login.dknet.dk
*/

#include <stdio.h>
#include <errno.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>

#define TUNER
#include <machine/ioctl_bt848.h>

main(int argc, char **argv)
{
  int arg=0;
  int quit=0;
  int tuner;
  double f;

  if((tuner=open("/dev/tuner0",O_RDONLY)) < 0) {
    perror("/dev/tuner0");
    exit(1);
    }

  if(argc>1 && !strcmp(argv[1],"-quit")) {
    quit=1;
    argc--;
    argv++;
    }

  if(argc != 2) {
    fprintf(stderr,"Usage: radio [-quit] <frequency>\n");
    fprintf(stderr,"I.e.   radio 103.2\n");
    exit(1);
    }

  f=atof(argv[1]);

  arg=0;
  if(ioctl(tuner,TVTUNER_SETAFC,&arg)) {
    perror("TVTUNER_SETAFC");
    exit(1);
    }

  arg=(int)(f*100);
  if(ioctl(tuner,RADIO_SETFREQ,&arg)) {
    perror("RADIO_SETFREQ");
    exit(1);
    }

  if(quit)
    exit(0);

  fclose(stdin); fclose(stdout); fclose(stderr);
  select(0,NULL,NULL,NULL,NULL);
}
- --------8<---------------8<---------------8<---------------8<-------
*** pci/brktree_reg.h.orig	Fri Nov 28 17:53:25 1997
- --- pci/brktree_reg.h	Sun Nov 30 13:43:01 1997
***************
*** 311,319 ****
  	char*		name;
  	u_char		type;
  	u_char		pllAddr;
! 	u_char		pllControl;
  	u_char		bandLimits[ 2 ];
! 	u_char		bandAddrs[ 3 ];
  };
  
  /* description of the card */
- --- 311,322 ----
  	char*		name;
  	u_char		type;
  	u_char		pllAddr;
! 	u_char		pllControl[ 4 ];	/* See bandAddrs-comment */
  	u_char		bandLimits[ 2 ];
! 	u_char		bandAddrs[ 4 ];		/* 3 first for the 3 TV 
! 						** bands. Last for radio 
! 						** band (0x00=NoRadio).
! 						*/
  };
  
  /* description of the card */
*** pci/brooktree848.c.orig	Thu Nov 27 22:32:22 1997
- --- pci/brooktree848.c	Sat Nov 29 13:16:45 1997
***************
*** 570,575 ****
- --- 570,584 ----
  				 TSA552x_CB_RSA |	\
  				 TSA552x_CB_RSB)
  
+ #define TSA552x_RADIO		(TSA552x_CB_MSB |       \
+ 				 TSA552x_CB_T0)
+ 
+ /* Add RADIO_OFFSET to the "frequency" to indicate that we want to tune	*/
+ /* the radio (if present) not the TV tuner.				*/
+ /* 20000 is equivalent to 20000MHz/16 = 1.25GHz - this area is unused.	*/
+ #define RADIO_OFFSET		20000
+ 
+ 
  /* sync detect threshold */
  #if 0
  #define SYNC_LEVEL		(BT848_ADC_RESERVED |	\
***************
*** 2174,2179 ****
- --- 2183,2233 ----
              }   
              break;
  
+ 	/* Ioctl's for running the tuner device in radio mode		*/
+ #if 0
+ 	case RADIO_SETMODE:	/* XXX  Todo: implement me ...		*/
+ 	    break;
+ 	case RADIO_GETFREQ;	/* XXX  Todo: implement me ...		*/
+ 	    break;
+ #endif
+ 	case RADIO_SETFREQ:
+ 	    /* The argument to this ioctl is NOT freq*16. It is
+ 	    ** freq*100.
+ 	    */
+ 
+ 	    /* The radio in my stereo and the linear regression function
+ 	    ** in my HP48 have reached the conclusion that in order to
+ 	    ** set the radio tuner of the FM1216 to f MHz, the value to
+ 	    ** enter into the PLL is: f*20-407
+ 	    ** If anyone has the exact values from the spec. sheet
+ 	    ** please forward them  -- fj@login.dknet.dk
+ 	    */
+ 	    temp=(int)*(unsigned long *)arg/5-407  +RADIO_OFFSET;
+ 
+ #ifdef BKTR_RADIO_DEBUG
+   printf("bktr%d: arg=%d temp=%d\n",unit,(int)*(unsigned long *)arg,temp);
+ #endif
+ 
+ #ifndef BKTR_RADIO_NOFREQCHECK
+ 	    /* According to the spec. sheet the band: 87.5MHz-108MHz	*/
+ 	    /* is supported.						*/
+ 	    if(temp<1343+RADIO_OFFSET || temp>1753+RADIO_OFFSET) {
+ 	      printf("bktr%d: Radio frequency out of range\n",unit);
+ 	      return(EINVAL);
+ 	      }
+ #endif
+ 	    temp_mute( bktr, TRUE );
+ 	    temp = tv_freq( bktr, temp );
+ 	    temp_mute( bktr, FALSE );
+ #ifdef BKTR_RADIO_DEBUG
+   if(temp)
+     printf("bktr%d: tv_freq returned: %d\n",unit,temp);
+ #endif
+ 	    if ( temp < 0 )
+ 		    return( EINVAL );
+ 	    *(unsigned long *)arg = temp;
+ 	    break;
+ 
  	default:
  		return common_ioctl( bktr, bt848, cmd, arg );
  	}
***************
*** 3480,3552 ****
  	{ "<none>",				/* the 'name' */
  	   TTYPE_XXX,				/* input type */
  	   0x00,				/* PLL write address */
! 	   0x00,				/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x00, 0x00, 0x00 } },		/* the band-switch values */
  
  	/* TEMIC_NTSC */
  	{ "Temic NTSC",				/* the 'name' */
  	   TTYPE_NTSC,				/* input type */
  	   TEMIC_NTSC_WADDR,			/* PLL write address */
! 	   TSA552x_SCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01 } },		/* the band-switch values */
  
  	/* TEMIC_PAL */
  	{ "Temic PAL",				/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   TEMIC_PALI_WADDR,			/* PLL write address */
! 	   TSA552x_SCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01 } },		/* the band-switch values */
  
  	/* TEMIC_SECAM */
  	{ "Temic SECAM",			/* the 'name' */
  	   TTYPE_SECAM,				/* input type */
  	   0x00,				/* PLL write address */
! 	   TSA552x_SCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01 } },		/* the band-switch values */
  
  	/* PHILIPS_NTSC */
  	{ "Philips NTSC",			/* the 'name' */
  	   TTYPE_NTSC,				/* input type */
  	   PHILIPS_NTSC_WADDR,			/* PLL write address */
! 	   TSA552x_SCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30 } },		/* the band-switch values */
  
  	/* PHILIPS_PAL */
  	{ "Philips PAL",			/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   PHILIPS_PAL_WADDR,			/* PLL write address */
! 	   TSA552x_FCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30 } },		/* the band-switch values */
  
  	/* PHILIPS_SECAM */
  	{ "Philips SECAM",			/* the 'name' */
  	   TTYPE_SECAM,				/* input type */
  	   0x00,				/* PLL write address */
! 	   TSA552x_SCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30 } },		/* the band-switch values */
  
  	/* TEMIC_PAL I */
  	{ "Temic PAL I",			/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   TEMIC_PALI_WADDR,			/* PLL write address */
! 	   TSA552x_SCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01 } },		/* the band-switch values */
  
  	/* PHILIPS_PAL */
  	{ "Philips PAL I",			/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   0x00,				/* PLL write address */
! 	   TSA552x_SCONTROL,			/* control byte for PLL */
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30 } },		/* the band-switch values */
  };
  
  
- --- 3534,3639 ----
  	{ "<none>",				/* the 'name' */
  	   TTYPE_XXX,				/* input type */
  	   0x00,				/* PLL write address */
! 	   { 0x00,				/* control byte for PLL */
! 	     0x00,
! 	     0x00,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x00, 0x00, 0x00, 0x00 } },	/* the band-switch values */
  
  	/* TEMIC_NTSC */
  	{ "Temic NTSC",				/* the 'name' */
  	   TTYPE_NTSC,				/* input type */
  	   TEMIC_NTSC_WADDR,			/* PLL write address */
! 	   { TSA552x_SCONTROL,			/* control byte for PLL */
! 	     TSA552x_SCONTROL,
! 	     TSA552x_SCONTROL,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01, 0x00 } },	/* the band-switch values */
  
  	/* TEMIC_PAL */
  	{ "Temic PAL",				/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   TEMIC_PALI_WADDR,			/* PLL write address */
! 	   { TSA552x_SCONTROL,			/* control byte for PLL */
! 	     TSA552x_SCONTROL,
! 	     TSA552x_SCONTROL,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01, 0x00 } },	/* the band-switch values */
  
  	/* TEMIC_SECAM */
  	{ "Temic SECAM",			/* the 'name' */
  	   TTYPE_SECAM,				/* input type */
  	   0x00,				/* PLL write address */
! 	   { TSA552x_SCONTROL,			/* control byte for PLL */
! 	     TSA552x_SCONTROL,
! 	     TSA552x_SCONTROL,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01, 0x00 } },	/* the band-switch values */
  
  	/* PHILIPS_NTSC */
  	{ "Philips NTSC",			/* the 'name' */
  	   TTYPE_NTSC,				/* input type */
  	   PHILIPS_NTSC_WADDR,			/* PLL write address */
! 	   { TSA552x_SCONTROL,			/* control byte for PLL */
! 	     TSA552x_SCONTROL,
! 	     TSA552x_SCONTROL,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30, 0x00 } },	/* the band-switch values */
  
  	/* PHILIPS_PAL */
  	{ "Philips PAL",			/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   PHILIPS_PAL_WADDR,			/* PLL write address */
! 	   { TSA552x_FCONTROL,			/* control byte for PLL */
! 	     TSA552x_FCONTROL,
! 	     TSA552x_FCONTROL,
! 	     TSA552x_RADIO },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30, 0xa5 } },	/* the band-switch values */
! 	   					/* Radio: (for FM1216)
! 						** 0xa4 sets radiomode
! 						**    bit0 - AFC
! 						**    bit1 - Mono
! 						**    bit3 - Mute
! 						*/
  
  	/* PHILIPS_SECAM */
  	{ "Philips SECAM",			/* the 'name' */
  	   TTYPE_SECAM,				/* input type */
  	   0x00,				/* PLL write address */
! 	   { TSA552x_SCONTROL,			/* control byte for PLL */
! 	     TSA552x_SCONTROL,
! 	     TSA552x_SCONTROL,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30, 0x00 } },	/* the band-switch values */
  
  	/* TEMIC_PAL I */
  	{ "Temic PAL I",			/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   TEMIC_PALI_WADDR,			/* PLL write address */
! 	   { TSA552x_SCONTROL,			/* control byte for PLL */
! 	     TSA552x_SCONTROL,
! 	     TSA552x_SCONTROL,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0x02, 0x04, 0x01, 0x00 } },	/* the band-switch values */
  
  	/* PHILIPS_PAL */
  	{ "Philips PAL I",			/* the 'name' */
  	   TTYPE_PAL,				/* input type */
  	   0x00,				/* PLL write address */
! 	   { TSA552x_SCONTROL,			/* control byte for PLL */
! 	     TSA552x_SCONTROL,
! 	     TSA552x_SCONTROL,
! 	     0x00 },
  	   { 0x00, 0x00 },			/* band-switch crosspoints */
! 	   { 0xa0, 0x90, 0x30, 0x00 } },	/* the band-switch values */
  };
  
  
***************
*** 4032,4046 ****
  	 * XXX FIXME: get the cross-over points from the tuner struct
  	 */
  	if ( frequency < (160 * FREQFACTOR) )
! 		band = tuner->bandAddrs[ 0 ];
  	else if ( frequency < (454 * FREQFACTOR) )
! 		band = tuner->bandAddrs[ 1 ];
  	else
! 		band = tuner->bandAddrs[ 2 ];
  
  	/* set the address of the PLL */
! 	addr = tuner->pllAddr;
! 	control = tuner->pllControl;
  
  	/*
  	 * N = 16 * { fRF(pc) + fIF(pc) }
- --- 4119,4141 ----
  	 * XXX FIXME: get the cross-over points from the tuner struct
  	 */
  	if ( frequency < (160 * FREQFACTOR) )
! 		N=0;
  	else if ( frequency < (454 * FREQFACTOR) )
! 		N=1;
  	else
! 		N=2;
! 	
! 	if(frequency > RADIO_OFFSET) {
! 		N=3;
! 		frequency -= RADIO_OFFSET;
! 		}
  
  	/* set the address of the PLL */
! 	addr    = tuner->pllAddr;
! 	control = tuner->pllControl[ N ];
! 	band    = tuner->bandAddrs[ N ];
! 	if(!(band && control))			/* Don't try to set un-	*/
! 	  return(-1);				/* supported modes.	*/
  
  	/*
  	 * N = 16 * { fRF(pc) + fIF(pc) }
*** i386/include/ioctl_bt848.h.orig	Fri Nov 28 17:42:28 1997
- --- i386/include/ioctl_bt848.h	Sun Nov 30 13:40:18 1997
***************
*** 210,212 ****
- --- 210,216 ----
   */
  #define BT848_I2CWR     _IOWR('x', 57, u_long)    /* i2c read-write */
  
+ /* Support for radio tuner */
+ #define RADIO_SETMODE	 _IOW('x', 58, unsigned int)  /* set radio modes */
+ #define RADIO_SETFREQ    _IOW('x', 59, unsigned int)  /* set frequency   */
+ #define RADIO_GETFREQ    _IOR('x', 59, unsigned int)  /* set frequency   */
- --------8<---------------8<---------------8<---------------8<-------

- -- 
Flemming Jacobsen               It'll probably say something like "Does not
TRW Financial Systems, Inc.     compute" or "Inoperative parameters". That's
Email: fj@tfs.com               what it says when it doesn't know and doesn't
Phone: +45 4330 4050            want to admit it.  -- Terry Pratchett: Wings

------- End of Forwarded Message






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