void CFrontend::secSetTone(const fe_sec_tone_mode_t toneMode, const uint32_t ms) { if (slave || info.type != FE_QPSK) return; if (currentToneMode == toneMode) return; if (config.diseqcType == DISEQC_UNICABLE) { /* this is too ugly for words. the "currentToneMode" is the only place where the global "highband" state is saved. So we need to fake it for unicable and still set the tone on... */ currentToneMode = toneMode; /* need to know polarization for unicable */ fop(ioctl, FE_SET_TONE, SEC_TONE_OFF); /* tone must be off except for the time of sending commands */ return; } printf("[fe%d] tone %s\n", fenumber, toneMode == SEC_TONE_ON ? "on" : "off"); FE_TIMER_INIT(); FE_TIMER_START(); if (fop(ioctl, FE_SET_TONE, toneMode) == 0) { currentToneMode = toneMode; FE_TIMER_STOP("FE_SET_TONE took"); usleep(1000 * ms); } }
void CVideo::setPig(int x, int y, int w, int h, bool /*aspect*/) { /* the aspect parameter is intended for maintaining correct aspect of the PIG... => not yet implemented */ /* all values zero -> reset ("hide_pig()") */ if (x + y + w + h == 0) { setZoom(-1); return; } SCALEINFO s; memset(&s, 0, sizeof(s)); s.src.hori_size = 720; s.src.vert_size = 576; s.des.hori_off = x; s.des.vert_off = y; s.des.hori_size = w; s.des.vert_size = h; DBG("setPig src: %d:%d:%d:%d dst: %d:%d:%d:%d", s.src.hori_off,s.src.vert_off,s.src.hori_size,s.src.vert_size, s.des.hori_off,s.des.vert_off,s.des.hori_size,s.des.vert_size); fop(ioctl, VIDEO_SET_DISPLAY_FORMAT, VID_DISPMODE_SCALE); fop(ioctl, MPEG_VID_SCALE_ON); fop(ioctl, MPEG_VID_SET_SCALE_POS, &s); }
void CFrontend::setFrontend(const dvb_frontend_parameters *feparams) { dvb_frontend_event event; if (fd == -1) return; errno = 0; while ((errno == 0) || (errno == EOVERFLOW)) quiet_fop(ioctl, FE_GET_EVENT, &event); #if HAVE_DVB_API_VERSION < 3 dvb_frontend_parameters feparams2; memcpy(&feparams2, feparams, sizeof(dvb_frontend_parameters)); /* the dreambox cable driver likes to get the frequency in kHz */ if (info.type == FE_QAM) { feparams2.Frequency /= 1000; DBG("cable box: setting frequency to %d khz\n", feparams2.Frequency); } if (auto_fec) { if (info.type == FE_QPSK) feparams2.u.qpsk.FEC_inner = FEC_AUTO; if (info.type == FE_QAM) feparams2.u.qam.FEC_inner = FEC_AUTO; } fop(ioctl, FE_SET_FRONTEND, &feparams2); #else fop(ioctl, FE_SET_FRONTEND, feparams); #endif }
void CFrontend::setFrontend(const dvb_frontend_parameters *feparams) { dvb_frontend_event event; if (fd == -1) return; if (errno != 0) errno = 0; while ((errno == 0) || (errno == EOVERFLOW)) quiet_fop(ioctl, FE_GET_EVENT, &event); #ifdef HAVE_DREAMBOX_HARDWARE dvb_frontend_parameters feparams2; memcpy(&feparams2, feparams, sizeof(dvb_frontend_parameters)); /* the dreambox cable driver likes to get the frequency in kHz */ if (info.type == FE_QAM) { feparams2.Frequency /= 1000; DBG("cable box: setting frequency to %d khz\n", feparams2.Frequency); } fop(ioctl, FE_SET_FRONTEND, &feparams2); #else fop(ioctl, FE_SET_FRONTEND, feparams); #endif }
int cVideo::Start(void * /*PcrChannel*/, unsigned short /*PcrPid*/, unsigned short /*VideoPid*/, void * /*hChannel*/) { lt_debug("%s playstate=%d\n", __FUNCTION__, playstate); if (playstate == VIDEO_PLAYING) return 0; if (playstate == VIDEO_FREEZED) /* in theory better, but not in practice :-) */ fop(ioctl, MPEG_VID_CONTINUE); playstate = VIDEO_PLAYING; fop(ioctl, MPEG_VID_PLAY); return fop(ioctl, MPEG_VID_SYNC_ON, VID_SYNC_AUD); }
int CVideo::start(void) { #ifdef HAVE_TRIPLEDRAGON if (playstate == VIDEO_PLAYING) return 0; playstate = VIDEO_PLAYING; fop(ioctl, MPEG_VID_PLAY); return fop(ioctl, MPEG_VID_SYNC_ON, VID_SYNC_AUD); #else return fop(ioctl, VIDEO_PLAY); #endif }
int cVideo::Stop(bool blank) { lt_debug("%s(%d)\n", __FUNCTION__, blank); if (blank) { playstate = VIDEO_STOPPED; fop(ioctl, MPEG_VID_STOP); return setBlank(1); } playstate = VIDEO_FREEZED; return fop(ioctl, MPEG_VID_FREEZE); }
void cVideo::Standby(unsigned int bOn) { lt_debug("%s(%d)\n", __FUNCTION__, bOn); if (bOn) { setBlank(1); fop(ioctl, MPEG_VID_SET_OUTFMT, VID_OUTFMT_DISABLE_DACS); } else fop(ioctl, MPEG_VID_SET_OUTFMT, outputformat); routeVideo(bOn); video_standby = bOn; }
int cVideo::setBlank(int) { lt_debug("%s\n", __FUNCTION__); /* The TripleDragon has no VIDEO_SET_BLANK ioctl. instead, you write a black still-MPEG Iframe into the decoder. The original software uses different files for 4:3 and 16:9 and for PAL and NTSC. I optimized that a little bit */ int index = 0; /* default PAL */ int ret = 0; VIDEOINFO v; BUFINFO buf; pthread_mutex_lock(&stillp_mutex); memset(&v, 0, sizeof(v)); ioctl(fd, MPEG_VID_GET_V_INFO, &v); if ((v.v_size % 240) == 0) /* NTSC */ { lt_info("%s NTSC format detected", __FUNCTION__); index = 1; } if (blank_data[index] == NULL) /* no MPEG found */ { ret = -1; goto out; } /* hack: this might work only on those two still-MPEG files! I diff'ed the 4:3 and the 16:9 still mpeg from the original soft and spotted the single bit difference, so there is no need to keep two different MPEGs in memory If we would read them from disk all the time it would be slower and it might wake up the drive occasionally */ if (v.pel_aspect_ratio == VID_DISPSIZE_4x3) ((char *)blank_data[index])[7] &= ~0x10; // clear the bit else ((char *)blank_data[index])[7] |= 0x10; // set the bit //WARN("blank[7] == 0x%02x", ((char *)blank_data[index])[7]); buf.ulLen = blank_size[index]; buf.ulStartAdrOff = (int)blank_data[index]; fop(ioctl, MPEG_VID_STILLP_WRITE, &buf); ret = fop(ioctl, MPEG_VID_SELECT_SOURCE, VID_SOURCE_DEMUX); out: pthread_mutex_unlock(&stillp_mutex); return ret; }
void CFrontend::sendToneBurst(const fe_sec_mini_cmd_t burst, const uint32_t ms) { if (slave || info.type != FE_QPSK) return; if (fop(ioctl, FE_DISEQC_SEND_BURST, burst) == 0) usleep(1000 * ms); }
//never used uint32_t CFrontend::getUncorrectedBlocks(void) const { uint32_t blocks = 0; fop(ioctl, FE_READ_UNCORRECTED_BLOCKS, &blocks); return blocks; }
uint16_t CFrontend::getSignalStrength(void) const { uint16_t strength = 0; fop(ioctl, FE_READ_SIGNAL_STRENGTH, &strength); return strength; }
uint32_t CFrontend::getDiseqcReply(const int timeout_ms) const { struct dvb_diseqc_slave_reply reply; reply.timeout = timeout_ms; TIMER_START(); if (fop(ioctl, FE_DISEQC_RECV_SLAVE_REPLY, &reply) < 0) return 0; TIMER_STOP(); /* timeout */ if (reply.msg_len == 0) return 1; switch (reply.msg[0]) { case 0xe4: /* ok */ return 0; case 0xe5: /* invalid address or unknown command */ return 1; case 0xe6: /* parity error */ return 1; case 0xe7: /* contention flag mismatch */ return 1; default: /* unexpected reply */ return 0; } }
int CAudio::setVolume(unsigned char volume, int forcetype) { if (settings.volume_type == CControld::TYPE_OST || forcetype == (int)CControld::TYPE_OST) { unsigned int v = map_volume(volume, false); struct audio_mixer mixer; mixer.volume_left = v; mixer.volume_right = v; return fop(ioctl, AUDIO_SET_MIXER, &mixer); } #ifdef HAVE_DBOX_HARDWARE else if (settings.volume_type == CControld::TYPE_AVS || forcetype == (int)CControld::TYPE_AVS) { int fd; int i = map_volume(volume, true); if ((fd = open(AVS_DEVICE, O_RDWR)) < 0) perror("[controld] " AVS_DEVICE); else { if (ioctl(fd, AVSIOSVOL, &i) < 0) perror("[controld] AVSIOSVOL"); close(fd); return 0; } } #else printf("CAudio::setVolume: volume_type != TYPE_OST not supported on dreambox!\n"); #endif return -1; }
void CFrontend::sendDiseqcCommand(const struct dvb_diseqc_master_cmd *cmd, const uint32_t ms) { TIMER_START(); #if HAVE_DVB_API_VERSION >= 3 if (fop(ioctl, FE_DISEQC_SEND_MASTER_CMD, cmd) == 0) #else secCmdSequence sequence; secCommand command; sequence.miniCommand = SEC_MINI_NONE; sequence.continuousTone = currentToneMode; sequence.voltage = currentTransponder.polarization; command.type = SEC_CMDTYPE_DISEQC_RAW; command.u.diseqc.cmdtype = cmd->msg[0]; command.u.diseqc.addr = cmd->msg[1]; command.u.diseqc.cmd = cmd->msg[2]; command.u.diseqc.numParams = cmd->msg_len - 3; for (int i=0; i < (cmd->msg_len - 3); i++) command.u.diseqc.params[i] = cmd->msg[3 + i]; sequence.commands = &command; sequence.numCommands = 1; if (fop_sec(ioctl, SEC_SEND_SEQUENCE, sequence) == 0) #endif usleep(1000 * ms); TIMER_STOP(); }
int CVideo::stop(void) { #ifdef HAVE_TRIPLEDRAGON playstate = VIDEO_STOPPED; #endif return fop(ioctl, VIDEO_STOP); }
int CAudio::setVolume(const unsigned char volume, int forcetype) { int avsfd; int v = (int)map_volume(volume, false); if (settings.volume_type == CControld::TYPE_OST || forcetype == (int)CControld::TYPE_OST) { AUDVOL vol; vol.frontleft = v; vol.frontright = v; vol.rearleft = v; vol.rearright = v; vol.center = v; vol.lfe = v; return fop(ioctl, MPEG_AUD_SET_VOL, &vol); } else if (settings.volume_type == CControld::TYPE_AVS || forcetype == (int)CControld::TYPE_AVS) { if ((avsfd = open(AVS_DEVICE, O_RDWR)) < 0) perror("[controld] " AVS_DEVICE); else { if (ioctl(avsfd, IOC_AVS_SET_VOLUME, v)) perror("[controld] IOC_AVS_SET_VOLUME"); close(avsfd); return 0; } } fprintf(stderr, "CAudio::setVolume: invalid settings.volume_type = %d\n", settings.volume_type); return -1; }
int cVideo::SetVideoSystem(int video_system, bool remember) { lt_info("%s(%d, %d)\n", __FUNCTION__, video_system, remember); if (video_system > VID_DISPFMT_SECAM || video_system < 0) video_system = VID_DISPFMT_PAL; return fop(ioctl, MPEG_VID_SET_DISPFMT, video_system); }
bool CFrontend::Open(bool init) { if(!standby) return false; char filename[128]; snprintf(filename, sizeof(filename), "/dev/dvb/adapter%d/frontend%d", adapter, fenumber); DBG("[fe%d] open %s\n", fenumber, filename); if (fd < 0) { if ((fd = open(filename, O_RDWR | O_NONBLOCK | O_CLOEXEC)) < 0) { ERROR(filename); return false; } fop(ioctl, FE_GET_INFO, &info); INFO("[fe%d] %s fd %d type %d", fenumber, filename, fd, info.type); } //FIXME if (fenumber > 1) info.type = FE_QAM; if (init) Init(); currentTransponder.TP_id = 0; standby = false; return true; }
static void save_document_in_background(Context* context, Document* document, bool mark_as_saved) { base::UniquePtr<FileOp> fop(fop_to_save_document(context, document)); if (!fop) return; SaveFileJob job(fop); job.showProgressWindow(); if (fop->has_error()) { Console console; console.printf(fop->error.c_str()); // We don't know if the file was saved correctly or not. So mark // it as it should be saved again. document->impossibleToBackToSavedState(); } // If the job was cancelled, mark the document as modified. else if (fop_is_stop(fop)) { document->impossibleToBackToSavedState(); } else { App::instance()->getRecentFiles()->addRecentFile(document->filename().c_str()); if (mark_as_saved) document->markAsSaved(); StatusBar::instance() ->setStatusText(2000, "File %s, saved.", document->name().c_str()); } }
uint32_t CFrontend::getBitErrorRate(void) const { uint32_t ber; fop(ioctl, FE_READ_BER, &ber); return ber; }
FILE *op_text(char *name) { char buf[LN_buf+1]; sprt(buf,sys.home,"\\text\\",name,NULL); /* return fopen(buf,"a+");*/ return fop(buf); }
fe_status_t CFrontend::getStatus(void) const { fe_status_t status; fop(ioctl, FE_READ_STATUS, &status); return status; }
uint16_t CFrontend::getSignalNoiseRatio(void) const { uint16_t snr; fop(ioctl, FE_READ_SNR, &snr); return snr; }
void SaveFileBaseCommand::saveDocumentInBackground( const Context* context, Doc* document, const std::string& filename, const bool markAsSaved) { if (!m_aniDir.empty()) { switch (convert_string_to_anidir(m_aniDir)) { case AniDir::REVERSE: m_selFrames = m_selFrames.makeReverse(); break; case AniDir::PING_PONG: m_selFrames = m_selFrames.makePingPong(); break; } } FileOpROI roi(document, m_slice, m_frameTag, m_selFrames, m_adjustFramesByFrameTag); std::unique_ptr<FileOp> fop( FileOp::createSaveDocumentOperation( context, roi, filename, m_filenameFormat)); if (!fop) return; SaveFileJob job(fop.get()); job.showProgressWindow(); if (fop->hasError()) { Console console; console.printf(fop->error().c_str()); // We don't know if the file was saved correctly or not. So mark // it as it should be saved again. document->impossibleToBackToSavedState(); } // If the job was cancelled, mark the document as modified. else if (fop->isStop()) { document->impossibleToBackToSavedState(); } else if (context->isUIAvailable()) { App::instance()->recentFiles()->addRecentFile(filename); if (markAsSaved) { document->markAsSaved(); document->setFilename(filename); document->incrementVersion(); } #ifdef ENABLE_UI StatusBar::instance() ->setStatusText(2000, "File <%s> saved.", base::get_file_name(filename).c_str()); #endif } }
int CVideo::setCroppingMode(video_displayformat_t format) { #ifdef HAVE_TRIPLEDRAGON croppingMode = format; #endif const char *format_string[] = { "panscan", "letterbox", "center_cutout", "unknown" }; DBG("setting cropping mode to %s", format_string[format]); return fop(ioctl, VIDEO_SET_DISPLAY_FORMAT, format); }
uint32_t CFrontend::getBitErrorRate(void) const { uint32_t ber = 0; fop(ioctl, FE_READ_BER, &ber); if (ber > 100000000) /* azbox minime driver has useless values around 500.000.000 */ ber = 0; return ber; }
void OpenFileCommand::onExecute(Context* context) { Console console; // interactive if (context->isUiAvailable() && m_filename.empty()) { std::string exts = get_readable_extensions(); // Add backslash as show_file_selector() expected a filename as // initial path (and the file part is removed from the path). if (!m_folder.empty() && !base::is_path_separator(m_folder[m_folder.size()-1])) m_folder.push_back(base::path_separator); m_filename = app::show_file_selector("Open", m_folder, exts, FileSelectorType::Open); } if (!m_filename.empty()) { base::UniquePtr<FileOp> fop(fop_to_load_document(context, m_filename.c_str(), FILE_LOAD_SEQUENCE_ASK)); bool unrecent = false; if (fop) { if (fop->has_error()) { console.printf(fop->error.c_str()); unrecent = true; } else { OpenFileJob task(fop); task.showProgressWindow(); // Post-load processing, it is called from the GUI because may require user intervention. fop_post_load(fop); // Show any error if (fop->has_error()) console.printf(fop->error.c_str()); Document* document = fop->document; if (document) { App::instance()->getRecentFiles()->addRecentFile(fop->filename.c_str()); document->setContext(context); } else if (!fop_is_stop(fop)) unrecent = true; } // The file was not found or was loaded loaded with errors, // so we can remove it from the recent-file list if (unrecent) { App::instance()->getRecentFiles()->removeRecentFile(m_filename.c_str()); } } else { // Do nothing (the user cancelled or something like that) } } }
int CVideo::getBlank(void) { struct video_status status; fop(ioctl, VIDEO_GET_STATUS, &status); #if HAVE_DVB_API_VERSION < 3 return status.videoBlank; #else return status.video_blank; #endif }
video_play_state_t CVideo::getPlayState(void) { struct video_status status; fop(ioctl, VIDEO_GET_STATUS, &status); #if HAVE_DVB_API_VERSION < 3 return status.playState; #else return status.play_state; #endif }