Exemple #1
0
bool
EnableRDS(uint32_t aMask)
{
  if (!sRadioEnabled || !sRDSSupported)
    return false;

  if (sMsmFMMode)
    setControl(V4L2_CID_PRIVATE_TAVARUA_RDSGROUP_MASK, aMask);

  if (sRDSEnabled)
    return true;

  int pipefd[2];
  int rc = pipe2(pipefd, O_NONBLOCK);
  if (rc < 0) {
    HAL_LOG("Could not create RDS thread signaling pipes (%d)", rc);
    return false;
  }

  ScopedClose writefd(pipefd[1]);
  ScopedClose readfd(pipefd[0]);

  rc = setControl(V4L2_CID_RDS_RECEPTION, true);
  if (rc < 0) {
    HAL_LOG("Could not enable RDS reception (%d)", rc);
    return false;
  }

  sRDSPipeFD = writefd;

  sRDSEnabled = true;

  rc = pthread_create(&sRDSThread, nullptr,
                      readRDSDataThread, (void*)pipefd[0]);
  if (rc) {
    HAL_LOG("Could not start RDS reception thread (%d)", rc);
    setControl(V4L2_CID_RDS_RECEPTION, false);
    sRDSEnabled = false;
    return false;
  }

  readfd.forget();
  writefd.forget();
  return true;
}
Exemple #2
0
ListBoxItem::ListBoxItem(const std::string& text) : 
	SingleControlContainer("ListBoxItem"), m_Text(text) {
	Ref<Label> label = new Label();
	Ref<Style> style = label->getStyle();
	style->setTextHorizontalAlign(std::string("center"));
	label->setZPos(-0.1f);
	label->setText(text);
	setControl(label.get());
}
Exemple #3
0
void MainWindow::on_actionOpen_triggered()
{
  if (!myLog->open())
  {
    QMessageBox msgBox;
    msgBox.setText(QString(QString::fromLocal8Bit(myLog->error.msg)));
    msgBox.exec();
  }
  setControl();
}
Exemple #4
0
void MainWindow::showEvent(QShowEvent* showEvent)
{
  static const int ALREADY_EXECUTED = 0;
  if (this->userData(ALREADY_EXECUTED) != NULL) return;
  loadControl();
  setControl();
  if (myLog->autoOpen) on_actionOpen_triggered();
  QMainWindow::showEvent(showEvent);
  this->setUserData(ALREADY_EXECUTED, (QObjectUserData*)this);
}
SGMXASScanConfiguration::SGMXASScanConfiguration(QObject *parent)
	: AMGenericContinuousScanConfiguration(parent)
{
	setName("SGM XAS");
	setUserScanName("SGM XAS");
	setAutomaticDirectionAssessment(true);
	setDirection(Increase);

	setControl(0, SGMBeamline::sgm()->energyControlSet()->energy()->toInfo());
	scanAxes_.at(0)->regionAt(0)->setRegionStep(1);
}
Exemple #6
0
void MainWindow::finalizeControl()
{
  SAFE_DELETE(optionDlg);
  SAFE_DELETE(aboutDlg);
  if (myLog != NULL)
  {
    myLog->close();
    setControl();
    SAFE_DELETE(myLog);
  }
}
Exemple #7
0
// ----------------------------------------------------------------------------
// Widget
// ----------------------------------------------------------------------------
Widget::Widget(QWidget *parent) :
  QWidget(parent),
  ui(new Ui::Widget)
{
  ui->setupUi(this);
  db_ = QSqlDatabase::addDatabase("QSQLITE");
  connect(&cs_, SIGNAL(captured(Cookies)), this, SLOT(processCookies(Cookies)), Qt::BlockingQueuedConnection);
  connect(&cs_, SIGNAL(closed()), this, SLOT(processClosed()), Qt::AutoConnection);
  loadControl();
  setControl();
}
Exemple #8
0
int main()
{
	// 1. Initiera (Görs ovan med definitionerna?)
	unsigned int door = DOOR_CLOSED;
	init_irq();

	while(1)
	{
		// Sätt IRQ typ till 0 eftersom vi inte har avbrott
		interrupt_type = NO_IRQ_TYPE;
		
		// Vänta på avbrott, WAI i assembler modulen
		standby();
		
		// Nu har vi avbrott, switcha på interrupt_type som sätts
		// i assemblermodulen för att avgöra vilken typ av avbrott
		switch(interrupt_type)
		{
			// Sensor har gett utslag, öppna dörren
			case SENSOR:
				if(door == DOOR_CLOSED)
					setControl(OPEN_DOOR);
				break;
			// Dörren har stängts
			case DOOR_CLOSED:
				door = DOOR_CLOSED;
				break;
			// Dörren har öppnats, börja räkna ner innan den ska stängas igen
			case DOOR_OPENED:
				door = DOOR_OPENED;
				set_timeout(30);
				break;
			// Timeouten är klar, stäng nu dörren
			case TIME_OUT:
				if(door == DOOR_OPENED)
					setControl(CLOSE_DOOR);
				break;
		}
	}
	return 0;
}
BioXASCarbonFilterFarmView::BioXASCarbonFilterFarmView(BioXASCarbonFilterFarm *control, QWidget *parent) :
	QWidget(parent)
{
	// Initialize class variables.

	filterFarm_ = 0;

	// Create UI elements.

	filterEditor_ = new CLSControlEditor(0);
	filterEditor_->setTitle("Effective filter");

	upstreamActuatorView_ = new BioXASCarbonFilterFarmActuatorView(0);

	downstreamActuatorView_ = new BioXASCarbonFilterFarmActuatorView(0);

	// Create and set layouts.

	QVBoxLayout *upstreamLayout = new QVBoxLayout();
	upstreamLayout->setMargin(0);
	upstreamLayout->addWidget(upstreamActuatorView_);

	QGroupBox *upstreamBox = new QGroupBox();
	upstreamBox->setTitle("Upstream Actuator");
	upstreamBox->setFlat(true);
	upstreamBox->setLayout(upstreamLayout);

	QVBoxLayout *downstreamLayout = new QVBoxLayout();
	downstreamLayout->setMargin(0);
	downstreamLayout->addWidget(downstreamActuatorView_);

	QGroupBox *downstreamBox = new QGroupBox();
	downstreamBox->setTitle("Downstream Actuator");
	downstreamBox->setFlat(true);
	downstreamBox->setLayout(downstreamLayout);

	QHBoxLayout *actuatorsLayout = new QHBoxLayout();
	actuatorsLayout->addWidget(upstreamBox);
	actuatorsLayout->addWidget(downstreamBox);

	QVBoxLayout *layout = new QVBoxLayout();
	layout->setMargin(0);
	layout->addWidget(filterEditor_);
	layout->addLayout(actuatorsLayout);

	setLayout(layout);

	// Current settings.

	setControl(control);
	refresh();
}
Exemple #10
0
MyAxWidget::MyAxWidget(QWidget* parent):
    QAxWidget(parent)
{
//    setAttribute(Qt::WA_TranslucentBackground);
//    setWindowFlags(Qt::SubWindow | Qt::FramelessWindowHint | Qt::Window);
    resize(300,100); //设置控件的大小
    setControl(QString::fromUtf8("{d27cdb6e-ae6d-11cf-96b8-444553540000}")); //注册控件
//    connect(this,SIGNAL(signal( const QString &, int, void *)),this, SLOT(flashAction(const QString &, int, void *)));
//    connect(this,SIGNAL(signal( const QString &, int, void *)),[&](const QString &name, int argc , void * argv){
//        qDebug()<<"name:"<<name;
//    });
    dynamicCall("LoadMovie(long,string)",0,"E:/RemoteDataBase/QiJu/code/trunk/beta/client/Flash/GiftEffect/BearCards.swf"); //调用方法

    //QString str2 = flash->dynamicCall("TotalFrames" ).toString();//获得属性
    //dynamicCall("FrameNum" , 200);//设置属性
//    dynamicCall("WMode", "Transparent");
}
Exemple #11
0
void eQEP::defaultSettings() {
  // Set all options off
  setDecoderControl(0);
  // Enable the eQEP unit
  setControl(EQEP_QEPCTL_PHEN);
  // Set all options off
  setCaptureControl(0);
  // Set all options off
  setPositionCompareControl(0);
  // Default to no interrupts enabled.
  setInterruptEnable(0);
  // Clear all of the interrupts.
  setInterruptClear(EQEP_INT_ENABLE_ALL);
  // Clear all of the sticky bits.
  setStatus(EQEP_QEPSTS_COEF | EQEP_QEPSTS_CDEF | EQEP_QEPSTS_FIMF);
  // Set the Max Position to the maximum possible.
  setMaxPos(-1);
}
Exemple #12
0
void
DisableRDS()
{
  if (!sRadioEnabled || !sRDSEnabled)
    return;

  int rc = setControl(V4L2_CID_RDS_RECEPTION, false);
  if (rc < 0) {
    HAL_LOG("Could not disable RDS reception (%d)", rc);
  }

  sRDSEnabled = false;

  write(sRDSPipeFD, "x", 1);

  pthread_join(sRDSThread, nullptr);

  close(sRDSPipeFD);
}
Exemple #13
0
void FPUFlags::setCurrent (const FPUFlags& flags)
{
  unsigned int newControl = 0;
  unsigned int mask = 0;

  setControl (flags.getMaskNaNs(), newControl, mask,        _EM_INVALID);
  setControl (flags.getMaskDenormals(), newControl, mask,   _EM_DENORMAL);
  setControl (flags.getMaskZeroDivides(), newControl, mask, _EM_ZERODIVIDE);
  setControl (flags.getMaskOverflows(), newControl, mask,   _EM_OVERFLOW);
  setControl (flags.getMaskUnderflows(), newControl, mask,  _EM_UNDERFLOW);
//setControl (flags.getMaskInexacts(), newControl, mask,    _EM_INEXACT);
  setControl (flags.getFlushDenormals(), newControl, mask,  _DN_FLUSH);
  setControl (flags.getInfinitySigned(), newControl, mask,  _IC_AFFINE);

  if (flags.getRounding().is_set ())
  {
    Rounding rounding = flags.getRounding().value ();

    switch (rounding)
    {
    case roundChop: mask |= _MCW_RC; newControl |= _RC_CHOP; break;
    case roundUp:   mask |= _MCW_RC; newControl |= _RC_UP;   break;
    case roundDown: mask |= _MCW_RC; newControl |= _RC_DOWN; break;
    case roundNear: mask |= _MCW_RC; newControl |= _RC_NEAR; break;
    }
  }

  if (flags.getPrecision().is_set ())
  {
    switch (flags.getPrecision().value ())
    {
    case bits64: mask |= _MCW_PC; newControl |= _PC_64; break;
    case bits53: mask |= _MCW_PC; newControl |= _PC_53; break;
    case bits24: mask |= _MCW_PC; newControl |= _PC_24; break;
    }
  }

  unsigned int currentControl;

  errno_t result = _controlfp_s (&currentControl, newControl, mask);

  if (result != 0)
    Throw (std::runtime_error ("error in _controlfp_s"));
}
AMControlMoveButton::AMControlMoveButton(QWidget *parent, AMControl* control, QList<double> stepSizes,  bool directionReversed) :
    QToolButton(parent)
{
	directionReversed_ = directionReversed;

	control_ = 0;
	setControl(control);

	stepSizes_ = stepSizes;
	if(stepSizes_.isEmpty())
		stepSizes_ << 1.0;	// just to make sure we always have at least one, so that stepSizeIndex_ is valid.
	stepSizeIndex_ = 0;

	contextMenu_ = 0;
	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomContextMenuRequested(QPoint)));

	setText(QString::number(currentStepSize()) % (control_ ? control_->units() : QString()));
	connect(this, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
}
Exemple #15
0
AMSlitsView::AMSlitsView(AMSlits *slits, bool showBladeEditors, QWidget *parent) :
	QWidget(parent)
{
	// Initialize class variables.

	slits_ = 0;

	// Create vertical slit view.

	verticalSlitView_ = new AMSlitView(0);

	QVBoxLayout *verticalBoxLayout = new QVBoxLayout();
	verticalBoxLayout->addWidget(verticalSlitView_);

	QGroupBox *verticalBox = new QGroupBox("Vertical slit");
	verticalBox->setLayout(verticalBoxLayout);

	// Create horizontal slit view.

	horizontalSlitView_ = new AMSlitView(0);

	QVBoxLayout *horizontalBoxLayout = new QVBoxLayout();
	horizontalBoxLayout->addWidget(horizontalSlitView_);

	QGroupBox *horizontalBox = new QGroupBox("Horizontal slit");
	horizontalBox->setLayout(horizontalBoxLayout);

	// Create and set main layouts.

	QHBoxLayout *layout = new QHBoxLayout();
	layout->addWidget(verticalBox);
	layout->addWidget(horizontalBox);

	setLayout(layout);

	// Current settings.

	setControl(slits);
	setBladeEditorsShown(showBladeEditors);
	refresh();
}
void ControllerStorageReceiver::setWantControl(bool wantControl, bool fire) {
    HostStorage* hs = (HostStorage*) storage->getHostStorage();
    if (hs == NULL) return;
    ControllerStorage* oldOwner = (ControllerStorage*) hs->getOwner();
    if (wantControl && oldOwner && oldOwner == storage) return;
    if (!wantControl && oldOwner && oldOwner != storage) {
        storage->getSender()->setWantControl(false);
        return;
    }
    ControllerStorage* newOwner = wantControl ? storage : NULL;
    Control c = hs->getHostData().getControl();
    if (c.getX() != 0 || c.getY() != 0) setControl(Control(0, 0), true);
    hs->setOwner(newOwner);
    if (oldOwner && fire) {
        oldOwner->getSender()->setControlling(false);
        oldOwner->getSender()->setWantControl(false);
    }
    if (newOwner) {
        newOwner->getSender()->setControlling(true);
        newOwner->getSender()->setWantControl(true);
    }
}
int NativeScrollViewObject::initialize()
{

	contentViewProxy_ = new NativeScrollViewContentObject(tiObject_, this);
	contentView_ = (bb::cascades::Container*)contentViewProxy_->getNativeHandle();


	scrollView_ = bb::cascades::ScrollView::create();
	nativeContentView_ = bb::cascades::Container::create();

	setControl(scrollView_);

	addChildImpl(contentViewProxy_);

	nativeContentView_->add(contentView_);
    scrollView_->setContent(nativeContentView_);

    scrollViewProperties_ = scrollView_->scrollViewProperties();

    ScrollViewEventHandler *eventHandler_ = new ScrollViewEventHandler(this);

    bb::cascades::LayoutUpdateHandler::create(nativeContentView_).onLayoutFrameChanged(eventHandler_, SLOT(onContainerLayoutChange(QRectF)));


 	TiObject height;
	height.setValue(String::New("UI.SIZE"));
	contentViewProxy_->setHeight(&height);

	TiObject width;
	width.setValue(String::New("UI.SIZE"));
	contentViewProxy_->setWidth(&width);


    contentSize_ = QSize(0,0);
    scrollViewSize_ = QSize(0,0);

    return NATIVE_ERROR_OK;
}
Exemple #18
0
void
LinearTrend::myUpdate(MarControlPtr sender)
{
    MarSystem::myUpdate(sender);

    if (tinSamples_ != inSamples_)
    {
        //std::cout << "*** LinearTrend: inSamples_ = " << inSamples_ << std::endl;
        
        m_coeff.resize( inSamples_ );
        
        if (inSamples_ == 1)
        {
            m_coeff[0] = 1.f;
        }
        else if (inSamples_ > 1)
        {
            float magnitude = (float) (inSamples_ - 1) / 2.f;

            float sum = 0.f;
            for (int i = 0; i < inSamples_; ++i) {
                m_coeff[i] = i - magnitude;
                sum += m_coeff[i] * m_coeff[i];
            }
            for (int i = 0; i < inSamples_; ++i)
                m_coeff[i] = m_coeff[i] / sum;
        }
        
#if 0
        std::cout << "*** linear trend coefficients:" << std::endl;
        for (int i = 0; i < inSamples_; ++i)
            std::cout << " " << m_coeff[i];
        std::cout << std::endl;
#endif
    }

    setControl( "mrs_natural/onSamples", 1 );
}
Exemple #19
0
void PlayerControls::setControl(const nlohmann::json& entry,
                                const std::string& key,
                                const int& player,
                                lwe::EventCondition& condition,
                                const std::list<SDL_GameController*>& controllers,
                                const std::map<SDL_GameController*, int>& controllerToDeviceId)
{
  if (entry[key].is_string())
  {
    setControl(player, controllers, controllerToDeviceId, condition, entry[key].get<std::string>());
  }
  else
  {
    if (entry[key].is_null())
    {
      LOG_ERROR("%s is not present", key);
    }
    else
    {
      LOG_ERROR("%s is not a string", key);
    }
  }
}
Exemple #20
0
void Widget::on_pbOpen_clicked()
{
    int currentIndex = ui->tabOption->currentIndex();
    switch (currentIndex)
    {
    case 0:
        tcpServer.port = ui->leTcpPort->text().toInt();
        netServer = &tcpServer;
        break;
    case 1:
        udpServer.port = ui->leUdpPort->text().toInt();
        netServer = &udpServer;
        break;
    case 2:
        sslServer.port = ui->leSslPort->text().toInt();
        netServer = &sslServer;
        break;
    }

    bool res = netServer->open();
    if (!res)
    {
        QString msg = netServer->error.msg;
        MsgEvent msgEvent(msg + "\r\n", QThread::currentThreadId());
        showMessage(&msgEvent);
        return;
    }
    if (netServer == &udpServer)
    {
        SAFE_DELETE(udpServerThread);
        udpServerThread = new UdpServerThread(this, &udpServer);
        udpServerThread->open();
    }

    setControl();
}
void
DisableFMRadio()
{
  if (!sRadioEnabled)
    return;

  sRadioEnabled = false;

  // Tavarua specific start
  int rc = setControl(V4L2_CID_PRIVATE_TAVARUA_STATE, FM_OFF);
  if (rc < 0) {
    HAL_LOG(("Unable to turn off radio"));
  }
  // Tavarua specific end

  pthread_join(sRadioThread, NULL);

  close(sRadioFD);

  hal::FMRadioOperationInformation info;
  info.operation() = hal::FM_RADIO_OPERATION_DISABLE;
  info.status() = hal::FM_RADIO_OPERATION_STATUS_SUCCESS;
  hal::NotifyFMRadioStatus(info);
}
Exemple #22
0
/* This runs on the main thread but most of the
 * initialization is pushed to the radio thread. */
void
EnableFMRadio(const hal::FMRadioSettings& aInfo)
{
  if (sRadioEnabled) {
    HAL_LOG("Radio already enabled!");
    return;
  }

  hal::FMRadioOperationInformation info;
  info.operation() = hal::FM_RADIO_OPERATION_ENABLE;
  info.status() = hal::FM_RADIO_OPERATION_STATUS_FAIL;

  mozilla::ScopedClose fd(open("/dev/radio0", O_RDWR));
  if (fd < 0) {
    HAL_LOG("Unable to open radio device");
    hal::NotifyFMRadioStatus(info);
    return;
  }

  struct v4l2_capability cap;
  int rc = ioctl(fd, VIDIOC_QUERYCAP, &cap);
  if (rc < 0) {
    HAL_LOG("Unable to query radio device");
    hal::NotifyFMRadioStatus(info);
    return;
  }

  sMsmFMMode = !strcmp((char *)cap.driver, "radio-tavarua") ||
      !strcmp((char *)cap.driver, "radio-iris");
  HAL_LOG("Radio: %s (%s)\n", cap.driver, cap.card);

  if (!(cap.capabilities & V4L2_CAP_RADIO)) {
    HAL_LOG("/dev/radio0 isn't a radio");
    hal::NotifyFMRadioStatus(info);
    return;
  }

  if (!(cap.capabilities & V4L2_CAP_TUNER)) {
    HAL_LOG("/dev/radio0 doesn't support the tuner interface");
    hal::NotifyFMRadioStatus(info);
    return;
  }

  sRDSSupported = cap.capabilities & V4L2_CAP_RDS_CAPTURE;
  sRadioSettings = aInfo;

  if (sMsmFMMode) {
    sRadioFD = fd.forget();
    sMsmFMVersion = cap.version;
    if (pthread_create(&sRadioThread, nullptr, runMsmFMRadio, nullptr)) {
      HAL_LOG("Couldn't create radio thread");
      hal::NotifyFMRadioStatus(info);
    }
    return;
  }

  struct v4l2_tuner tuner = {0};
  tuner.type = V4L2_TUNER_RADIO;
  tuner.rangelow = (aInfo.lowerLimit() * 10000) / 625;
  tuner.rangehigh = (aInfo.upperLimit() * 10000) / 625;
  tuner.audmode = V4L2_TUNER_MODE_STEREO;
  rc = ioctl(fd, VIDIOC_S_TUNER, &tuner);
  if (rc < 0) {
    HAL_LOG("Unable to adjust band limits");
  }

  int emphasis;
  switch (aInfo.preEmphasis()) {
  case 0:
    emphasis = V4L2_DEEMPHASIS_DISABLED;
    break;
  case 50:
    emphasis = V4L2_DEEMPHASIS_50_uS;
    break;
  case 75:
    emphasis = V4L2_DEEMPHASIS_75_uS;
    break;
  default:
    MOZ_CRASH("Invalid preemphasis setting");
    break;
  }
  rc = setControl(V4L2_CID_TUNE_DEEMPHASIS, emphasis);
  if (rc < 0) {
    HAL_LOG("Unable to configure deemphasis");
  }

  sRadioFD = fd.forget();
  sRadioEnabled = true;

  info.status() = hal::FM_RADIO_OPERATION_STATUS_SUCCESS;
  hal::NotifyFMRadioStatus(info);
}
Exemple #23
0
/*!
    Creates a QAxObject that wraps the COM object \a c. \a parent is
    propagated to the QObject constructor.

    \sa setControl()
*/
QAxObject::QAxObject(const QString &c, QObject *parent)
    : QObject(parent)
{
    setControl(c);
}
int NativeDateTimePickerObject::initialize()
{
    dateTimePicker_ = bb::cascades::DateTimePicker::create();
    setControl(dateTimePicker_);
    return NATIVE_ERROR_OK;
}
Exemple #25
0
/**
 * Disables the watchdog timer
**/
void eQEP::disableWatchdogTimer() {
  setControl(
    getControl() & ~EQEP_QEPCTL_WDE);
}
Exemple #26
0
void SignalSlotForm::on_lwSlotList_currentRowChanged(int currentRow)
{
  Q_UNUSED(currentRow)
  setControl();
}
Exemple #27
0
void SignalSlotForm::on_lwSlotList_clicked(const QModelIndex &index)
{
  Q_UNUSED(index)
  setControl();
}
void AMControlMoveButton::onControlDestroyed()
{
	setControl(0);
}
/* Runs on the radio thread */
static void
initTavaruaRadio(hal::FMRadioSettings &aInfo)
{
  mozilla::ScopedClose fd(sRadioFD);
  char version[64];
  int rc;
  snprintf(version, sizeof(version), "%d", sTavaruaVersion);
  property_set("hw.fm.version", version);

  /* Set the mode for soc downloader */
  property_set("hw.fm.mode", "normal");
  /* start fm_dl service */
  property_set("ctl.start", "fm_dl");

  /*
   * Fix bug 800263. Wait until the FM radio chips initialization is done
   * then set other properties, or the system will hang and reboot. This
   * work around is from codeaurora
   * (git://codeaurora.org/platform/frameworks/base.git).
   */
  for (int i = 0; i < 4; ++i) {
    sleep(1);
    char value[PROPERTY_VALUE_MAX];
    property_get("hw.fm.init", value, "0");
    if (!strcmp(value, "1")) {
      break;
    }
  }

  rc = setControl(V4L2_CID_PRIVATE_TAVARUA_STATE, FM_RECV);
  if (rc < 0) {
    HAL_LOG(("Unable to turn on radio |%s|", strerror(errno)));
    return;
  }

  int preEmphasis = aInfo.preEmphasis() <= 50;
  rc = setControl(V4L2_CID_PRIVATE_TAVARUA_EMPHASIS, preEmphasis);
  if (rc) {
    HAL_LOG(("Unable to configure preemphasis"));
    return;
  }

  rc = setControl(V4L2_CID_PRIVATE_TAVARUA_RDS_STD, 0);
  if (rc) {
    HAL_LOG(("Unable to configure RDS"));
    return;
  }

  int spacing;
  switch (aInfo.spaceType()) {
  case 50:
    spacing = FM_CH_SPACE_50KHZ;
    break;
  case 100:
    spacing = FM_CH_SPACE_100KHZ;
    break;
  case 200:
    spacing = FM_CH_SPACE_200KHZ;
    break;
  default:
    HAL_LOG(("Unsupported space value - %d", aInfo.spaceType()));
    return;
  }

  rc = setControl(V4L2_CID_PRIVATE_TAVARUA_SPACING, spacing);
  if (rc) {
    HAL_LOG(("Unable to configure spacing"));
    return;
  }

  /*
   * Frequency conversions
   *
   * HAL uses units of 1k for frequencies
   * V4L2 uses units of 62.5kHz
   * Multiplying by (10000 / 625) converts from HAL units to V4L2.
   */

  struct v4l2_tuner tuner = {0};
  tuner.rangelow = (aInfo.lowerLimit() * 10000) / 625;
  tuner.rangehigh = (aInfo.upperLimit() * 10000) / 625;
  rc = ioctl(fd, VIDIOC_S_TUNER, &tuner);
  if (rc < 0) {
    HAL_LOG(("Unable to adjust band limits"));
    return;
  }

  rc = setControl(V4L2_CID_PRIVATE_TAVARUA_REGION, TAVARUA_REGION_OTHER);
  if (rc < 0) {
    HAL_LOG(("Unable to configure region"));
    return;
  }

  // Some devices do not support analog audio routing. This should be
  // indicated by the 'ro.moz.fm.noAnalog' property at build time.
  char propval[PROPERTY_VALUE_MAX];
  property_get("ro.moz.fm.noAnalog", propval, "");
  bool noAnalog = !strcmp(propval, "true");

  rc = setControl(V4L2_CID_PRIVATE_TAVARUA_SET_AUDIO_PATH,
                  noAnalog ? FM_DIGITAL_PATH : FM_ANALOG_PATH);
  if (rc < 0) {
    HAL_LOG(("Unable to set audio path"));
    return;
  }

  if (!noAnalog) {
    /* Set the mode for soc downloader */
    property_set("hw.fm.mode", "config_dac");
    /* Use analog mode FM */
    property_set("hw.fm.isAnalog", "true");
    /* start fm_dl service */
    property_set("ctl.start", "fm_dl");

    for (int i = 0; i < 4; ++i) {
      sleep(1);
      char value[PROPERTY_VALUE_MAX];
      property_get("hw.fm.init", value, "0");
      if (!strcmp(value, "1")) {
        break;
      }
    }
  }

  fd.forget();
  sRadioEnabled = true;
}
Exemple #30
0
void Widget::showEvent(QShowEvent* showEvent)
{
    loadControl();
    setControl();
    QWidget::showEvent(showEvent);
}