qtmobility/plugins/multimedia/v4l/radio/v4lradiocontrol.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
   342     }
   342     }
   343 }
   343 }
   344 
   344 
   345 bool V4LRadioControl::isSearching() const
   345 bool V4LRadioControl::isSearching() const
   346 {
   346 {
   347     //TODO
   347     return scanning;
   348     return false;
       
   349 }
   348 }
   350 
   349 
   351 void V4LRadioControl::cancelSearch()
   350 void V4LRadioControl::cancelSearch()
   352 {
   351 {
   353     //TODO
   352     scanning = false;
       
   353     timer->stop();
   354 }
   354 }
   355 
   355 
   356 void V4LRadioControl::searchForward()
   356 void V4LRadioControl::searchForward()
   357 {
   357 {
   358     // Scan up
   358     // Scan up
   359     if(scanning) {
   359     if(scanning) {
   360         scanning = false;
   360         cancelSearch();
   361         return;
   361         return;
   362     }
   362     }
   363     scanning = true;
   363     scanning = true;
   364     forward  = true;
   364     forward  = true;
       
   365     timer->start();
   365 }
   366 }
   366 
   367 
   367 void V4LRadioControl::searchBackward()
   368 void V4LRadioControl::searchBackward()
   368 {
   369 {
   369     // Scan down
   370     // Scan down
   370     if(scanning) {
   371     if(scanning) {
   371         scanning = false;
   372         cancelSearch();
   372         return;
   373         return;
   373     }
   374     }
   374     scanning = true;
   375     scanning = true;
   375     forward  = false;
   376     forward  = false;
   376     timer->start();
   377     timer->start();
   405         emit signalStrengthChanged(sig);
   406         emit signalStrengthChanged(sig);
   406     }
   407     }
   407 
   408 
   408     if(!scanning) return;
   409     if(!scanning) return;
   409 
   410 
       
   411     if (signal > 25) {
       
   412         cancelSearch();
       
   413         return;
       
   414     }
       
   415 
   410     if(forward) {
   416     if(forward) {
   411         setFrequency(currentFreq+step);
   417         setFrequency(currentFreq+step);
   412     } else {
   418     } else {
   413         setFrequency(currentFreq-step);
   419         setFrequency(currentFreq-step);
   414     }
   420     }
   415     emit signalStrengthChanged(signalStrength());
       
   416 }
   421 }
   417 
   422 
   418 bool V4LRadioControl::initRadio()
   423 bool V4LRadioControl::initRadio()
   419 {
   424 {
   420     v4l2_tuner tuner;
   425     v4l2_tuner tuner;
   424 
   429 
   425     low = false;
   430     low = false;
   426     available = false;
   431     available = false;
   427     freqMin = freqMax = currentFreq = 0;
   432     freqMin = freqMax = currentFreq = 0;
   428 
   433 
   429     fd = ::open("/dev/radio", O_RDWR);
   434     fd = ::open("/dev/radio0", O_RDWR);
   430 
   435 
   431     if(fd != -1) {
   436     if(fd != -1) {
   432         // Capabilites
   437         // Capabilites
   433         memset( &cap, 0, sizeof( cap ) );
   438         memset( &cap, 0, sizeof( cap ) );
   434         if(::ioctl(fd, VIDIOC_QUERYCAP, &cap ) >= 0) {
   439         if(::ioctl(fd, VIDIOC_QUERYCAP, &cap ) >= 0) {
   477                 else
   482                 else
   478                     currentFreq = freq.frequency * 62500;
   483                     currentFreq = freq.frequency * 62500;
   479             }
   484             }
   480         }
   485         }
   481 
   486 
   482         qWarning()<<"min="<<freqMin<<", max="<<freqMax<<", current="<<currentFreq;
       
   483 
       
   484         // stereo
   487         // stereo
   485         bool stereo = false;
   488         bool stereo = false;
   486         memset( &tuner, 0, sizeof( tuner ) );
   489         memset( &tuner, 0, sizeof( tuner ) );
   487         if ( ioctl( fd, VIDIOC_G_TUNER, &tuner ) >= 0 ) {
   490         if ( ioctl( fd, VIDIOC_G_TUNER, &tuner ) >= 0 ) {
   488             if((tuner.rxsubchans & V4L2_TUNER_SUB_STEREO) != 0)
   491             if((tuner.rxsubchans & V4L2_TUNER_SUB_STEREO) != 0)