byte QUADCALIB_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "quadcalib help")==0) { *handled = TRUE; return PrintHelp(io); } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "quadcalib status")==0)) { *handled = TRUE; return PrintStatus(io); } else if ((UTIL1_strcmp((char*)cmd, "quadcalib tune 0")==0)) { *handled = TRUE; return Tune(io, 0, MOT_GetMotorHandle(MOT_MOTOR_RIGHT)); } else if ((UTIL1_strcmp((char*)cmd, "quadcalib tune 1")==0)) { *handled = TRUE; return Tune(io, 1, MOT_GetMotorHandle(MOT_MOTOR_RIGHT)); } else if ((UTIL1_strcmp((char*)cmd, "quadcalib tune 2")==0)) { *handled = TRUE; return Tune(io, 2, MOT_GetMotorHandle(MOT_MOTOR_LEFT)); } else if ((UTIL1_strcmp((char*)cmd, "quadcalib tune 3")==0)) { *handled = TRUE; return Tune(io, 3, MOT_GetMotorHandle(MOT_MOTOR_LEFT)); } return ERR_OK; }
Tune WinAmpTuneController::getTune(const HWND &hWnd) { Tune tune = Tune(); int position = (int)SendMessage(hWnd, WM_WA_IPC, 0, IPC_GETLISTPOS); if (position != -1) { if (hWnd && SendMessage(hWnd,WM_WA_IPC,0,IPC_ISPLAYING) == 1) { QPair<bool, QString> trackpair(getTrackTitle(hWnd)); if (!trackpair.first) { // getTrackTitle wants us to retry in a few ms... int interval = AntiscrollInterval; if (++antiscrollCounter_ > 10) { antiscrollCounter_ = 0; interval = NormInterval; } setInterval(interval); return Tune(); } antiscrollCounter_ = 0; tune.setName(trackpair.second); tune.setURL(trackpair.second); tune.setTrack(QString::number(position + 1)); tune.setTime(SendMessage(hWnd, WM_WA_IPC, 1, IPC_GETOUTPUTTIME)); } } return tune; }
int main(int argc, char** argv) { DIBSTATUS rc; unsigned int i; DibChannelHdl[0] = DIB_UNSET; DibChannelHdl[1] = DIB_UNSET; DibChannelHdl[2] = DIB_UNSET; DibChannelHdl[3] = DIB_UNSET; /*** Open Driver ***/ rc = Open(Board); /*** Display Board Layout ***/ DisplayLayout(); if (rc == DIBSTATUS_SUCCESS) { /*** Tune Channel Stream 0, Chip 0, HOST DMA ***/ rc = Tune(0, FrequencyStream1, Bandwidth); printf("Press Key to Continue\n"); getchar(); /*** Tune Channel Stream 4, Chip 0, HOST DMA ***/ rc = Tune(4, FrequencyStream2, Bandwidth); printf("Press Key to Continue\n"); getchar(); /*** Tune Channel Stream 5, Chip 0, HOST DMA ***/ rc = Tune(5, FrequencyStream3, Bandwidth); printf("Press Key to Continue\n"); getchar(); for (i=0;i<10;i++) { /*** Monitor Signal Stream 1 ***/ SignalMonitor(0); SignalMonitor(4); SignalMonitor(5); } printf("Press Key to Continue\n"); /*** Add Subchannel 0 on Stream 0 ***/ AddService(0,1); /*** Add Subchannel 0 on Stream 0 ***/ AddService(4,1); /*** Add Subchannel 0 on Stream 0 ***/ AddService(5,2); printf("Press Key to Continue\n"); getchar(); /*** Close Driver ***/ DibClose(pContext); } }
Tune AimpTuneController::getTune() const { HANDLE aFile=OpenFileMapping(FILE_MAP_READ, TRUE, AIMP_REMOTE_CLASS); PAIMPRemoteFileInfo aInfo = (PAIMPRemoteFileInfo)MapViewOfFile(aFile, FILE_MAP_READ, 0, 0, AIMPRemoteAccessMapFileSize); if (aInfo != NULL) { wchar_t *str = (wchar_t *)((char*)aInfo + sizeof(*aInfo)); QString album = QString::fromWCharArray(str, aInfo->AlbumLength); str += aInfo->AlbumLength; QString artist = QString::fromWCharArray(str, aInfo->ArtistLength); str += aInfo->ArtistLength + aInfo->DateLength; QString url = QString::fromWCharArray(str, aInfo->FileNameLength); str += aInfo->FileNameLength + aInfo->GenreLength; QString title = QString::fromWCharArray(str, aInfo->TitleLength); unsigned long trackNumber = aInfo->TrackNumber; unsigned long time = aInfo->Duration; Tune tune = Tune(); if (!url.isEmpty()) { if (!title.isEmpty()) { tune.setName(title); } else { int index = url.replace("/", "\\").lastIndexOf("\\"); if (index > 0) { QString filename = url.right(url.length()-index-1); index = filename.lastIndexOf("."); title = (index > 0) ? filename.left(index) : filename; } else { title = url; } tune.setName(title); } if (trackNumber > 0) { tune.setTrack(QString::number(trackNumber)); } if (time > 0) { tune.setTime((uint)time); } if (!artist.isEmpty()) { tune.setArtist(artist); } if (!album.isEmpty()) { tune.setAlbum(album); } tune.setURL(url); } return tune; } UnmapViewOfFile(aInfo); CloseHandle(aFile); return Tune(); }
/*********************************************************************************** initialize the fm include patch loading and variable inital ************************************************************************************/ RETURN_CODE fm_am_initialize(void) { RETURN_CODE ret = SUCCESS; fm_am_set_parameter_default(); ret |= Initialize(work_mode); ret |= eeprom_get_parameter();//read from flash if((work_mode == fmonly)&&(ret != SUCCESS || fm_freq >10800 || fm_freq < 6400))//check whether the para get from flash is correct { fm_am_set_parameter_default();//if it is incorrect .then load default parameter } #ifdef OPTION__INCLUDE_MODE__AM if((work_mode == am)&&(ret != SUCCESS || am_freq >1720 || am_freq < 520))//check whether the para get from flash is correct { fm_am_set_parameter_default();//if it is incorrect .then load default parameter } #endif ret |= AudioLevel(volume); if(work_mode == fmonly) { ret |= Tune(fm_freq); rds_update_ready_item =0; sis_update_ready_item =0; psd_update_ready_item =0; alert_update_ready_item = 0; } else if(work_mode == am) { ret |=Tune(am_freq); } ret |= set_freq_spacing(); seek_state = SEEK_NULL; item_loop = ITEM_AUTO_ROLL; display_item_str_4ms = 200; #ifdef ATS_EMBED_CODE ATS_RDS_valid_flag = 0; #endif display_refresh_flag = 1; return ret; }
RETURN_CODE fmhd_amhd_initialize(void) { RETURN_CODE ret = SUCCESS; fmhd_amhd_set_parameter_default(); // work_mode = fmhd; ret |= Initialize(work_mode); ret |= eeprom_get_parameter();//read from flash if(work_mode == fmhd) { if(ret != SUCCESS || fmhd_freq >10800 || fmhd_freq < 6400) { fmhd_amhd_set_parameter_default();//if it is incorrect .then load default parameter } ret |= Tune(fmhd_freq); } if(work_mode == amhd) { if(ret != SUCCESS || amhd_freq >1710 || amhd_freq < 520) { fmhd_amhd_set_parameter_default();//if it is incorrect .then load default parameter } ret |= Tune(amhd_freq); } ret |= AudioLevel(volume); ret |= set_freq_spacing(); rds_update_ready_item =0; sis_update_ready_item =0; psd_update_ready_item =0; alert_update_ready_item = 0; ber_running_flag = 0; seek_state = SEEK_NULL; item_loop = ITEM_AUTO_ROLL; display_item_str_4ms = 200; #ifdef ATS_EMBED_CODE ATS_RDS_valid_flag = 1; #endif return ret; }
void AimpTuneController::clearTune() { if (_tuneSent) { _currentTune = Tune(); _tuneSent = false; } }
MT_FE_RET mt_fe_tn_set_freq_TDA18250A(void *dev_handle, U32 freq_KHz, U16 symbol_rate_KSs) { tmErrorCode_t tm_ret; tm_ret = Tune(0, freq_KHz * 1000); return (tm_ret == TM_OK) ? MtFeErr_Ok : MtFeErr_Fail; }
bool DVBChannel::Tune(const DTVMultiplex &tuning) { if (!m_inputid) { LOG(VB_GENERAL, LOG_ERR, LOC + QString("Tune(): Invalid input.")); return false; } return Tune(tuning, false, false); }
bool DTVChannel::TuneMultiplex(uint mplexid, QString inputname) { DTVMultiplex tuning; if (!tuning.FillFromDB(tunerType, mplexid)) return false; CheckOptions(tuning); return Tune(tuning, inputname); }
bool DVBChannel::Tune(const DTVMultiplex &tuning, QString inputname) { int inputid = inputname.isEmpty() ? m_currentInputID : GetInputByName(inputname); if (inputid < 0) { VERBOSE(VB_IMPORTANT, LOC_ERR + QString("Tune(): Invalid input '%1'.") .arg(inputname)); return false; } return Tune(tuning, inputid, false, false); }
CmmbResult CmmbFtChannelTest(int channel) { CmmbResult ret; if (!IsValidCmmbChannel(channel)) return CMMB_E_INVALID_ARG; if (g_cmmbState == CMMB_NONE) return CMMB_E_WRONGSTATE; ret = Tune(channel); return ret; }
byte APP_ParseCommand(const unsigned char *cmd, bool *handled, const CLS1_StdIOType *io) { if (UTIL1_strcmp((char*)cmd, CLS1_CMD_HELP)==0 || UTIL1_strcmp((char*)cmd, "app help")==0) { *handled = TRUE; return PrintHelp(io); } else if ((UTIL1_strcmp((char*)cmd, CLS1_CMD_STATUS)==0) || (UTIL1_strcmp((char*)cmd, "app status")==0)) { *handled = TRUE; return PrintStatus(io); } else if ((UTIL1_strcmp((char*)cmd, "app tune")==0)) { *handled = TRUE; return Tune(io); } return ERR_OK; }
static int Open (vlc_object_t *obj) { access_t *access = (access_t *)obj; access_sys_t *sys = malloc (sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; var_LocationParse (obj, access->psz_location, "dvb-"); dvb_device_t *dev = dvb_open (obj); if (dev == NULL) { free (sys); return VLC_EGENERIC; } sys->dev = dev; sys->signal_poll = 0; access->p_sys = sys; uint64_t freq = var_InheritFrequency (obj); if (freq != 0) { const delsys_t *delsys = GuessSystem (access->psz_access, dev); if (delsys == NULL || Tune (obj, dev, delsys, freq)) { msg_Err (obj, "tuning to %"PRIu64" Hz failed", freq); dialog_Fatal (obj, N_("Digital broadcasting"), N_("The selected digital tuner does not support " "the specified parameters.\n" "Please check the preferences.")); goto error; } } dvb_add_pid (dev, 0); access->pf_block = Read; access->pf_control = Control; if (access->psz_demux == NULL || !access->psz_demux[0]) { free (access->psz_demux); access->psz_demux = strdup ("ts"); } return VLC_SUCCESS; error: Close (obj); access->p_sys = NULL; return VLC_EGENERIC; }
CmmbResult CmmbFtSetChannel(int channel) { if (!IsValidCmmbChannel(channel)) return CMMB_E_INVALID_ARG; if (g_cmmbState == CMMB_NONE) return CMMB_E_WRONGSTATE; // check current channel if (g_curChannel == channel) { return CMMB_S_OK; } CmmbResult errCode; errCode = Tune(channel); if (errCode != CMMB_S_OK) { return errCode; } errCode = StartTs0(); if (errCode != CMMB_S_OK) { return errCode; } errCode = StopTs0(); if (errCode != CMMB_S_OK) { return errCode; } errCode = ParseTs0(); if (errCode != CMMB_S_OK) { return errCode; } g_cmmbState = CMMB_READY; g_curChannel = channel; return CMMB_S_OK; }
static int Open (vlc_object_t *obj) { access_t *access = (access_t *)obj; access_sys_t *sys = malloc (sizeof (*sys)); if (unlikely(sys == NULL)) return VLC_ENOMEM; var_LocationParse (obj, access->psz_location, "dvb-"); dvb_device_t *dev = dvb_open (obj); if (dev == NULL) { free (sys); return VLC_EGENERIC; } sys->dev = dev; sys->signal_poll = 0; sys->pf_setup = NULL; access->p_sys = sys; uint64_t freq = var_InheritFrequency (obj); if (freq != 0) { dtv_delivery_t d = GuessSystem (access->psz_name, dev); if(d != DTV_DELIVERY_NONE) sys->pf_setup = dtv_get_delivery_tuner_setup(d); if (sys->pf_setup == NULL || Tune (obj, dev, sys->pf_setup, freq)) { msg_Err (obj, "tuning to %"PRIu64" Hz failed", freq); vlc_dialog_display_error (obj, N_("Digital broadcasting"), N_("The selected digital tuner does not support " "the specified parameters.\n" "Please check the preferences.")); goto error; } } dvb_add_pid (dev, 0); access->pf_block = Read; access->pf_control = Control; return VLC_SUCCESS; error: Close (obj); access->p_sys = NULL; return VLC_EGENERIC; }
int main(int argc, char** argv) { DIBSTATUS rc; unsigned int i; /*** Open Driver ***/ rc = Open(Board); if (rc == DIBSTATUS_SUCCESS) { /*** Tune Channel ***/ rc = Tune(Frequency, Bandwidth); printf("Press Key to Continue\n"); getchar(); if (rc == DIBSTATUS_SUCCESS) { for (i=0; i<100; i++) { /*** Monitor Signal ***/ SignalMonitor(); } } printf("Press Key to Continue\n"); getchar(); if(StreamType == eSTREAM_TYPE_MPEG_1) { /*** Start Data Reception in Mpeg TS mode ***/ ReceiveDataWithMpegTS (); } else if(StreamType == eSTREAM_TYPE_HOST_DMA) { /*** Start Data Reception in HostDma Mode ***/ ReceiveDataWithHostDma(); } printf("Press Key to Continue\n"); getchar(); /*** Close Driver ***/ DibClose(pContext); } }
bool Frontend::Tune( Activity &act ) { Port *port = act.GetPort( ); if( !port ) return false; Transponder *transponder = act.GetTransponder( ); if( !transponder ) return false; act.SetFrontend( this ); if( !SetPort( port->GetKey( ))) return false; if( !Tune( *transponder )) return false; return true; }
bool FirewireChannel::Retune(void) { LOG(VB_CHANNEL, LOG_INFO, LOC + "Retune()"); if (FirewireDevice::kAVCPowerOff == GetPowerState()) { LOG(VB_GENERAL, LOG_ERR, LOC + "STB is turned off, must be on to retune."); return false; } if (current_channel) { QString freqid = QString::number(current_channel); return Tune(freqid, 0); } return false; }
int CDvbDeviceControl::SignalStatistics(struct SIGNAL_STATISTICS_DATA *d) { HRESULT hr; BOOLEAN present=FALSE,locked=FALSE; LONG strength=0, quality=0; d->quality = 0; d->strength = 0; d->flags = 0x0; hr = BdaGraph.GetSignalStatistics(&present,&locked,&strength,&quality); if(SUCCEEDED(hr)) { if (conf_params.RelockTimeout && lock_time && (!locked || !quality)) { clock_t curr_time = clock(); if ((curr_time-lock_time) >= (conf_params.RelockTimeout*CLOCKS_PER_SEC)) { curr_time = curr_time-lock_time; DebugLog( "Relock attempt after %d sec - %s", curr_time/CLOCKS_PER_SEC, Tune(&tune_data) ? "failed !" : "success." ); } else DebugLog("Wait signal lock %d sec", (curr_time-lock_time)/CLOCKS_PER_SEC); } else lock_time = clock(); d->flags = (locked? 0x10 : 0x00) | (present? 0x0F : 0x00); d->strength = present ? (int)strength : 0; d->strength = (int)strength; d->quality = locked ? (int)quality : 0; d->quality = (int)quality; return AltxDVB_OK; } return AltxDVB_ERR; }
bool DVBChannel::Retune(void) { return Tune(desired_tuning, m_currentInputID, true, true); }
int V4LHelper::Read(char * buf, int size) { CSingleLock lock(m_lock); static bool timeout = false; if (m_frontendHandle <= 0) return -1; // Check the signal once a second if (m_tuningState == DvbTuner::TUNING_STATE_TUNED && SDL_GetTicks() - m_lastSignalCheckTicks > 1000) { uint16_t signal = GetSignal(); uint16_t snr = GetSNR(); if ((signal > 140 || signal == 0) && (snr > 100 || snr == 0)) m_signalOk = true; else m_signalOk = false; // printf("signal=%d snr=%d signalok=%s\n", signal, snr, m_signalOk ? "true" : "false"); m_lastSignalCheckTicks = SDL_GetTicks(); } struct pollfd ufd[2]; int n; ufd[0].fd = m_frontendHandle; ufd[0].events = POLLIN; n = 1; if(m_dvr > 0) { ufd[1].fd = m_dvr; ufd[1].events = POLLIN; n = 2; } // we put one second timeout for video to come out. // if it doesn't then we reopen devices int rc = poll(ufd, n, 1000); if (rc == -1 && errno == EINTR) { return 0; } if (rc < 0) { CLog::Log(LOGERROR, "%s poll failed: %s", __func__, strerror(errno)); return -1; } // if dvr is open and we get a timeout, reopen devices if(m_dvr > 0 && rc == 0) { CLog::Log(LOGWARNING, "V4LHelper::Read DVR timeout. Reopening frontend"); CloseFrontEnd(); CloseDVR(); Sleep(100); OpenFrontEnd(); m_tuningState = DvbTuner::TUNING_STATE_TUNING; Tune(m_frontend_settings); } int bytesRead = 0; struct dvb_frontend_event ev; if (ufd[0].revents) { if (ioctl(m_frontendHandle, FE_GET_EVENT, &ev) < 0) { if (errno == EOVERFLOW) { CLog::Log(LOGWARNING, "Cannot dequeue events fast enough from frontend. Doing nothing"); return 0; } else CLog::Log(LOGERROR, "Cannot dequeue frontend event: %s", strerror(errno)); } else { CLog::Log(LOGINFO, "Got frontend event. status: 0x%02X", (unsigned) ev.status); if (ev.status == (FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC | FE_HAS_LOCK)) { m_tuningState = DvbTuner::TUNING_STATE_TUNED; CloseDVR(); } else if (m_tuningState == DvbTuner::TUNING_STATE_TUNED) m_tuningState = DvbTuner::TUNING_STATE_TUNE_FAILED; } } if (m_dvr > 0 && n == 2 && ufd[1].revents) { ssize_t val = read(m_dvr, buf, size); if (val == -1 && (errno != EAGAIN && errno != EINTR)) { if (errno == EOVERFLOW) { CLog::Log(LOGWARNING, "Cannot read dvr data fast enough. Doing nothing"); return 0; } CLog::Log(LOGERROR, "Error reading from dvr: %d %s", m_dvr, strerror(errno) ); bytesRead = -1; } else if (val > 0) { bytesRead = val; } } if(m_tuningState == DvbTuner::TUNING_STATE_TUNED) { if(m_dvr < 0) { Sleep(100); OpenDVR(); } } return bytesRead; }
bool V4LHelper::Tune(const DvbChannel &channel) { bool bNoAudio = false; bool bNoVideo = false; CSingleLock lock(m_lock); CLog::Log(LOGDEBUG, "V4LHelper::Tune: about to tune into %s", channel.GetServiceName().c_str()); // Sanity check on the requested channel if (channel.GetVideoPid() == 0) { CLog::Log(LOGWARNING, "V4LHelper::Tune: no video pid"); bNoVideo = true; } const std::vector<DvbAudioInfo>& audioInfo = channel.GetAudioPids(); if (audioInfo.size() == 0 || audioInfo[0].pid == 0) { CLog::Log(LOGWARNING, "V4LHelper::Tune: no audio pid"); bNoAudio = true; } if(bNoAudio && bNoVideo) { CLog::Log(LOGERROR, "V4LHelper::Tune: no audio or video pids found. Aborting tune"); m_tuningState = DvbTuner::TUNING_STATE_TUNE_FAILED; return false; } // Open Front End if needed if (m_frontendHandle <= 0) OpenFrontEnd(); // Remove old pids, if they exist bool bBudgetMode = m_nFlags & TUNER_FLAGS_BUDGET; if(!bBudgetMode) RemoveAllPidFilters(); m_signalOk = true; bool bForceTune = m_nFlags & TUNER_FLAGS_FORCE_TUNE; if (m_lastFreq != channel.GetFreq() || bForceTune) { m_tuningState = DvbTuner::TUNING_STATE_TUNING; CloseDVR(); struct dvb_frontend_parameters frontend; memset(&frontend, 0, sizeof(struct dvb_frontend_parameters)); frontend.frequency = atoi(channel.GetFreq().c_str()); if (m_type == DvbTuner::TUNER_TYPE_ATSC) { frontend.u.vsb.modulation = (fe_modulation_t) m_trValue[channel.GetTuningParams()]; } else if (m_type == DvbTuner::TUNER_TYPE_DVBT) { CStdStringArray tuningParams; StringUtils::SplitString(channel.GetTuningParams(), ",", tuningParams); frontend.inversion = (fe_spectral_inversion_t) m_trValue[tuningParams[0]]; frontend.u.ofdm.bandwidth = (fe_bandwidth_t) m_trValue[tuningParams[1]]; frontend.u.ofdm.code_rate_HP = (fe_code_rate_t) m_trValue[tuningParams[2]]; frontend.u.ofdm.code_rate_LP = (fe_code_rate_t) m_trValue[tuningParams[3]]; frontend.u.ofdm.constellation = (fe_modulation_t) m_trValue[tuningParams[4]]; frontend.u.ofdm.transmission_mode = (fe_transmit_mode_t) m_trValue[tuningParams[5]]; frontend.u.ofdm.guard_interval = (fe_guard_interval_t) m_trValue[tuningParams[6]]; frontend.u.ofdm.hierarchy_information = (fe_hierarchy_t) m_trValue[tuningParams[7]]; if (frontend.u.ofdm.code_rate_HP == FEC_NONE) frontend.u.ofdm.code_rate_HP = FEC_AUTO; if (frontend.u.ofdm.code_rate_LP == FEC_NONE) frontend.u.ofdm.code_rate_LP = FEC_AUTO; } else { CLog::Log(LOGERROR, "V4LHelper::Tune: unknown format type. tuning failed."); m_tuningState = DvbTuner::TUNING_STATE_TUNE_FAILED; return false; } CLog::Log(LOGINFO, "V4LHelper::Tune: tuning frontend to freq: %d force tune %d", frontend.frequency, bForceTune); if(!Tune(frontend)) return false; } else { m_tuningState = DvbTuner::TUNING_STATE_TUNING_PROGRAM; } m_lastFreq = channel.GetFreq(); if (m_tuningState == DvbTuner::TUNING_STATE_TUNING_PROGRAM) { m_tuningState = DvbTuner::TUNING_STATE_TUNED; } return true; }
bool DVBChannel::Retune(void) { return Tune(desired_tuning, true, true); }
bool DVBChannel::SetChannelByString(const QString &channum) { QString tmp = QString("SetChannelByString(%1): ").arg(channum); QString loc = LOC + tmp; QString loc_err = LOC_ERR + tmp; VERBOSE(VB_CHANNEL, loc); if (!IsOpen()) { VERBOSE(VB_IMPORTANT, loc_err + "Channel object " "will not open, cannot change channels."); ClearDTVInfo(); return false; } ClearDTVInfo(); QString inputName; if (!CheckChannel(channum, inputName)) { VERBOSE(VB_IMPORTANT, loc_err + "CheckChannel failed.\n\t\t\tPlease verify the channel " "in the 'mythtv-setup' Channel Editor."); return false; } // If CheckChannel filled in the inputName we need to change inputs. if (!inputName.isEmpty() && (nextInputID == m_currentInputID)) nextInputID = GetInputByName(inputName); // Get the input data for the channel int inputid = (nextInputID >= 0) ? nextInputID : m_currentInputID; InputMap::const_iterator it = m_inputs.find(inputid); if (it == m_inputs.end()) return false; uint mplexid_restriction; if (!IsInputAvailable(inputid, mplexid_restriction)) { VERBOSE(VB_IMPORTANT, loc_err + "Input is not available"); return false; } // Get the input data for the channel QString tvformat, modulation, freqtable, freqid, si_std; int finetune; uint64_t frequency; int mpeg_prog_num; uint atsc_major, atsc_minor, mplexid, tsid, netid; if (!ChannelUtil::GetChannelData( (*it)->sourceid, channum, tvformat, modulation, freqtable, freqid, finetune, frequency, si_std, mpeg_prog_num, atsc_major, atsc_minor, tsid, netid, mplexid, m_commfree)) { VERBOSE(VB_IMPORTANT, loc_err + "Unable to find channel in database."); return false; } if (mplexid_restriction && (mplexid != mplexid_restriction)) { VERBOSE(VB_IMPORTANT, loc_err + "Multiplex is not available"); return false; } // Initialize basic the tuning parameters DTVMultiplex tuning; if (!mplexid || !tuning.FillFromDB(tunerType, mplexid)) { VERBOSE(VB_IMPORTANT, loc_err + "Failed to initialize multiplex options"); return false; } SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num); // Try to fix any problems with the multiplex CheckOptions(tuning); if (!Tune(tuning, inputid)) { VERBOSE(VB_IMPORTANT, loc_err + "Tuning to frequency."); ClearDTVInfo(); return false; } QString tmpX = channum; tmpX.detach(); m_curchannelname = tmpX; VERBOSE(VB_CHANNEL, loc + "Tuned to frequency."); m_currentInputID = nextInputID; QString tmpY = m_curchannelname; tmpY.detach(); m_inputs[m_currentInputID]->startChanNum = tmpY; return true; }
bool DTVChannel::SetChannelByString(const QString &channum) { QString loc = LOC + QString("SetChannelByString(%1): ").arg(channum); LOG(VB_CHANNEL, LOG_INFO, loc); ClearDTVInfo(); if (!IsOpen() && !Open()) { LOG(VB_GENERAL, LOG_ERR, loc + "Channel object " "will not open, can not change channels."); return false; } if (m_inputs.size() > 1) { QString inputName; if (!CheckChannel(channum, inputName)) { LOG(VB_GENERAL, LOG_ERR, loc + "CheckChannel failed.\n\t\t\tPlease verify the channel " "in the 'mythtv-setup' Channel Editor."); return false; } // If CheckChannel filled in the inputName then we need to // change inputs and return, since the act of changing // inputs will change the channel as well. if (!inputName.isEmpty()) return SwitchToInput(inputName, channum); } InputMap::const_iterator it = m_inputs.find(m_currentInputID); if (it == m_inputs.end()) return false; uint mplexid_restriction; uint chanid_restriction; if (!IsInputAvailable(m_currentInputID, mplexid_restriction, chanid_restriction)) { LOG(VB_GENERAL, LOG_INFO, loc + QString("Requested channel '%1' is on input '%2' " "which is in a busy input group") .arg(channum).arg(m_currentInputID)); return false; } // Fetch tuning data from the database. QString tvformat, modulation, freqtable, freqid, si_std; int finetune; uint64_t frequency; int mpeg_prog_num; uint atsc_major, atsc_minor, mplexid, chanid, tsid, netid; if (!ChannelUtil::GetChannelData( (*it)->sourceid, chanid, channum, tvformat, modulation, freqtable, freqid, finetune, frequency, si_std, mpeg_prog_num, atsc_major, atsc_minor, tsid, netid, mplexid, m_commfree)) { LOG(VB_GENERAL, LOG_ERR, loc + "Unable to find channel in database."); return false; } if ((mplexid_restriction && (mplexid != mplexid_restriction)) || (chanid_restriction && (chanid != chanid_restriction))) { LOG(VB_GENERAL, LOG_ERR, loc + QString("Requested channel '%1' is not available because " "the tuner is currently in use on another transport.") .arg(channum)); return false; } // If the frequency is zeroed out, don't use it directly. if (frequency == 0) { frequency = (freqid.toULongLong() + finetune) * 1000; mplexid = 0; } bool isFrequency = (frequency > 10000000); bool hasTuneToChan = !(*it)->tuneToChannel.isEmpty() && (*it)->tuneToChannel != "Undefined"; // If we are tuning to a freqid, rather than an actual frequency, // we may need to set the frequency table to use. if (!isFrequency || hasTuneToChan) SetFreqTable(freqtable); // Set NTSC, PAL, ATSC, etc. SetFormat(tvformat); // If a tuneToChannel is set make sure we're still on it if (hasTuneToChan) Tune((*it)->tuneToChannel, 0); // Clear out any old PAT or PMT & save version info uint version = 0; if (genPAT) { version = (genPAT->Version()+1) & 0x1f; delete genPAT; genPAT = NULL; delete genPMT; genPMT = NULL; } bool ok = true; if ((*it)->externalChanger.isEmpty()) { if (IsIPTV()) { int chanid = ChannelUtil::GetChanID((*it)->sourceid, channum); IPTVTuningData tuning = ChannelUtil::GetIPTVTuningData(chanid); if (!Tune(tuning, false)) { LOG(VB_GENERAL, LOG_ERR, loc + "Tuning to IPTV URL"); ClearDTVInfo(); ok = false; } } else if ((*it)->name.contains("composite", Qt::CaseInsensitive) || (*it)->name.contains("s-video", Qt::CaseInsensitive)) { LOG(VB_GENERAL, LOG_WARNING, loc + "You have not set " "an external channel changing" "\n\t\t\tscript for a composite or s-video " "input. Channel changing will do nothing."); } else if (isFrequency && Tune(frequency, "")) { } else if (isFrequency) { // Initialize basic the tuning parameters DTVMultiplex tuning; if (!mplexid || !tuning.FillFromDB(tunerType, mplexid)) { LOG(VB_GENERAL, LOG_ERR, loc + "Failed to initialize multiplex options"); ok = false; } else { // Try to fix any problems with the multiplex CheckOptions(tuning); // Tune to proper multiplex if (!Tune(tuning, (*it)->name)) { LOG(VB_GENERAL, LOG_ERR, loc + "Tuning to frequency."); ClearDTVInfo(); ok = false; } } } else { // ExternalChannel justs wants the channum ok = freqid.isEmpty() && finetune == 0 ? Tune(channum) : Tune(freqid, finetune); } } LOG(VB_CHANNEL, LOG_INFO, loc + ((ok) ? "success" : "failure")); if (!ok) return false; if (atsc_minor || (mpeg_prog_num>=0)) { SetSIStandard(si_std); SetDTVInfo(atsc_major, atsc_minor, netid, tsid, mpeg_prog_num); } else if (IsPIDTuningSupported()) { // We need to pull the pid_cache since there are no tuning tables pid_cache_t pid_cache; int chanid = ChannelUtil::GetChanID((*it)->sourceid, channum); ChannelUtil::GetCachedPids(chanid, pid_cache); if (pid_cache.empty()) { LOG(VB_GENERAL, LOG_ERR, loc + "PID cache is empty"); return false; } // Now we construct the PAT & PMT vector<uint> pnum; pnum.push_back(1); vector<uint> pid; pid.push_back(9999); genPAT = ProgramAssociationTable::Create(0,version,pnum,pid); int pcrpid = -1; vector<uint> pids; vector<uint> types; pid_cache_t::iterator pit = pid_cache.begin(); for (; pit != pid_cache.end(); ++pit) { if (!pit->GetStreamID()) continue; pids.push_back(pit->GetPID()); types.push_back(pit->GetStreamID()); if (pit->IsPCRPID()) pcrpid = pit->GetPID(); if ((pcrpid < 0) && StreamID::IsVideo(pit->GetStreamID())) pcrpid = pit->GetPID(); } if (pcrpid < 0) pcrpid = pid_cache[0].GetPID(); genPMT = ProgramMapTable::Create( pnum.back(), pid.back(), pcrpid, version, pids, types); SetSIStandard("mpeg"); SetDTVInfo(0,0,0,0,-1); } // Set the current channum to the new channel's channum m_curchannelname = channum; // Setup filters & recording picture attributes for framegrabing recorders // now that the new curchannelname has been established. if (m_pParent) m_pParent->SetVideoFiltersForChannel(GetCurrentSourceID(), channum); InitPictureAttributes(); HandleScript(freqid); return ok; }
RETURN_CODE fmhd_amhd_key_process(void) { RETURN_CODE ret = SUCCESS; if(key_flag==1) { key_flag = 0; display_refresh_flag = 1; switch(key_value) { case TUNE_PRESS_KNOBS: item_loop ++; if(item_loop>(sizeof(FMHD_ITEM_STR)/sizeof(FMHD_ITEM_STR[0]))-1) { item_loop = 0; } show_freq(0,0); LCD_Clear(LCD_CLEAR_LINE2); LCD_DisplayStr(FMHD_ITEM_STR[item_loop],0,1); display_item_str_4ms = 500; loop_display_times = 0; break; case DOWN_KEY: case TUNE_DEC_KNOBS: #ifdef OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS if(ber_running_flag == 1) { fmhd_ber_mode --; if(fmhd_ber_mode < HD_P1) { fmhd_ber_mode = HD_PIDS_BLOCK; } } else { #endif //OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS ret |= tune_up_down(0); if(ret == SUCCESS) { fmhd_key_update_display(); } #ifdef OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS } #endif //OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS break; case UP_KEY: case TUNE_INC_KNOBS: #ifdef OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS if(ber_running_flag == 1) { fmhd_ber_mode ++; if(fmhd_ber_mode > HD_PIDS_BLOCK) { fmhd_ber_mode = HD_P1; } } else { #endif //OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS ret |= tune_up_down(1); if(ret == SUCCESS) { fmhd_key_update_display(); } #ifdef OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS } #endif //OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS break; case HDSEEK_KEY: #ifdef OPTION__INCLUDE_MODE__AMHD if(work_mode == amhd) { return SUCCESS;//amhd mode will not support HD station only seeking } #endif if(seek_state == SEEK_NULL) { fmhd_seekonly ^= 1; LCD_Clear(LCD_CLEAR_ALL); LCD_DisplayStr("HD-Only Seek\n",0,0); if(fmhd_seekonly) { LCD_DisplayStr("Enabled\n",0,1); } else { LCD_DisplayStr("Disabled\n",0,1); } display_item_str_4ms = 500; } break; case SEEK_UP_KEY: if(seek_state == SEEK_NULL) { seek_state = SEEK_PROCESS; ret|=SeekStart(1,1,fmhd_seekonly); fmhd_key_update_display(); } break; case SEEK_DOWN_KEY: if(seek_state == SEEK_NULL) { seek_state = SEEK_PROCESS; ret|=SeekStart(0,1,fmhd_seekonly); fmhd_key_update_display(); } break; case PRESET_INC_KEY: case PRESET_DEC_KEY: ret |=pset_operate(key_value); display_item_str_4ms = 2000; break; case PRESET_INC_HOLD_KEY: case PRESET_DEC_HOLD_KEY: ret |=pset_operate(key_value); display_item_str_4ms = 1000; break; #ifdef OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS case DAB_RESCAN_KEY: //iBiquity has requested the push botton be used to start a free-running BER test. The previous 1,000,000 bit sample test is still included in the ATS commands if(ber_running_flag == 1) { display_item_str_4ms = 3000; } else { Test_StartFreeRunningBER_FMHD(); } ber_running_flag ^= 1; break; case DAB_RESCAN_HOLD_KEY: fmhd_split_mode_setting ++; if(fmhd_split_mode_setting > 2) { fmhd_split_mode_setting = 0; } ret |= SetProperty(0xE801, fmhd_split_mode_setting); // Test mode for HD split mode rotates through splits ret |= Tune(MetricsGetFMHDPtr()->FREQUENCY_10KHZ); //Retune to make the property change take effect LCD_Clear(LCD_CLEAR_ALL); LCD_DisplayStr("HD-SplitMode\n",0,0); LCD_DisplayNum(fmhd_split_mode_setting,0,1); display_item_str_4ms = 3000; break; #endif //OPTION__INCLUDE_FRONT_END_TEST_FUNCTIONS default: key_flag = 1;display_refresh_flag = 0; break; } } return ret; }
int main(void) { SystemInit(); /* Basic State Setup----------------------------------------------------*/ Enable_Init(); //Enable LT3763 State_Init(); //LED Show /* Fault Report Intial--------------------------------------------------*/ Fault_Init(); /* IWDG Intial----------------------------------------------------------*/ // IWDG_Configuration(); // /* PWM Intial-----------------------------------------------------------*/ // PWM_Init(); /* UART RS485 Initial---------------------------------------------------*/ UART_Init(); /* ADC Intial-----------------------------------------------------------*/ ADC_exInit(); /* DAC output for Ctrl Pin input of LT3763 for soft start---------------*/ DAC_exInit(); while (1) { // IWDG_ReloadCounter(); //feed WatchDog if (Error == Short) { while(1) { Enable_Off(); State_Short(); } } else if(Error == Vmode) { while(1) { Enable_Off(); State_Vmode(); } } else { State_Toggle(); delay_ms(1000); if (StartUp_Condition() == true && Error == NoWarn) { StartUp(); } else if (ShutDown_Condition() == true && Error == NoWarn) { ShutDown(); } else if (Tune_Condition() == true && Error == NoWarn) { Tune(); } } } }