SF16 FMI tuner

Radek_Sedmak na eurotel.cz Radek_Sedmak na eurotel.cz
Středa Listopad 10 10:44:48 CET 1999


> > Nasiel som rady ake aplikacie na ovladanie tohto tuneru pouzivat, linky na
 > > freshmeate nefunguju, ani na cradio alebo gradio, nevie niekto aktualne
 > > linky?
 > > Dik
 >

1. Prelozit kernel s podporou video4linux a prislusna radiokarta (treba jako
moduly)
2. insmod videodev
3. insmod radio-prislusna karta
4. Zkontrolovat existenci zarizeni /dev/radio kdyz tak vytvorit pomoci MKDEV
5. Program na ovladani jednoduchy prikladam

#include <unistd.h>
#include <fcntl.h>
#include <linux/videodev.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <linux/version.h>


int main(int argc, char *argv[]) {
  int radio_fd;
  int iVol;
  struct video_tuner v;
  struct video_audio va;
  unsigned long xl_freq;
  char temp[128];

  radio_fd=open("/dev/radio0",O_RDONLY);
  if (radio_fd <=0 ) {
    perror("Unable to initialize Radio device\r\n");
    exit(-1);
  }

  if ( argc !=2 ) {
    printf("Usage: radio -f<freq> | <on> | <off> | -v<0..10>\r\n");
    exit(-2);
  }

  if ( strncmp(argv[1],"-f",2)==0x00 ) {
    memset(temp,0x00,128);
    xl_freq=(unsigned long)((atof(&(argv[1][2]))*1000)*16 + 0.5);
    va.volume = 5 * ( 65535/10);
    va.audio=0;
    va.flags=VIDEO_AUDIO_VOLUME;
    v.tuner=0;
    ioctl(radio_fd,VIDIOCSFREQ,&xl_freq);
  }

  if ( strncmp(argv[1],"-v",2)==0x00 ) {
    iVol=atoi(&(argv[1][2]));
    if ( iVol<0 || iVol >10 ) {
      printf("Volume should be in range 0..10\r\n");
      exit(-3);
    }
    va.volume = iVol * ( 65535/10);
    va.audio=0;
    va.flags=VIDEO_AUDIO_VOLUME;
    v.tuner=0;
  }


  if ( strncmp(argv[1],"off",3)==0x00 ) {
    va.volume = 0 * ( 65535/10);
    va.audio=0;
    va.flags=VIDEO_AUDIO_VOLUME;
    v.tuner=0;
  }

  if ( strncmp(argv[1],"on",2)==0x00 ) {
    va.volume = 5 * ( 65535/10);
    va.audio=0;
    va.flags=VIDEO_AUDIO_VOLUME;
    v.tuner=0;
  }


  ioctl(radio_fd,VIDIOCGTUNER,&v);
  ioctl(radio_fd,VIDIOCSAUDIO,&va);


  close(radio_fd);
  return 0;
}


                                                                            Bye
Sam




Další informace o konferenci Linux