int MultiDisplayComposer::setModePolicy_l(int policy) {
    ALOGV("IMDS-Native: MultiDisplayComposer.cpp: setModePolicy_l");
    int ret = 0;
    unsigned int index = 0;
    ALOGI("%s: policy %d, mHdmiPolicy 0x%x, mMipiPolicy 0x%x, mMode: 0x%x",
            __func__, policy, mHdmiPolicy, mMipiPolicy, mMode);
    switch (policy) {
        case MDS_HDMI_ON_NOT_ALLOWED:
        case MDS_HDMI_ON_ALLOWED:
            mHdmiPolicy = policy;
            return setHdmiMode_l();

        case MDS_MIPI_OFF_NOT_ALLOWED:
            mMipiPolicy = policy;
            if (!checkMode(mMode, MDS_MIPI_ON)) {
                drm_mipi_setMode(DRM_MIPI_ON);
            }
            mMode |= MDS_MIPI_ON;
            mMipiOn = true;
            break;
        case MDS_MIPI_OFF_ALLOWED:
            mMipiPolicy = policy;
            if (checkMode(mMode, MDS_MIPI_ON)) {
                drm_mipi_setMode(DRM_MIPI_OFF);
            }
            mMode &= ~MDS_MIPI_ON;
            mMipiOn = false;
            break;
        default:
            return MDS_ERROR;
    }
    broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
    return MDS_NO_ERROR;
}
Beispiel #2
0
int psbMultiDisplayListener::getMode() {
    int mode = MDS_MODE_NONE;
#ifndef USE_MDS_LEGACY
    if (mListener.get() == NULL) return MDS_INIT_VALUE;
#if 0
    mode = mListener->getMode();
#else
    mode = mListener->getDisplayMode(false);
#endif
    if (checkMode(mode, (MDS_VIDEO_ON | MDS_HDMI_CONNECTED)))
        mode = MDS_HDMI_VIDEO_ISPLAYING;
    else if (checkMode(mode, (MDS_VIDEO_ON | MDS_WIDI_ON)))
        mode = MDS_WIDI_VIDEO_ISPLAYING;
    else
        mode = MDS_INIT_VALUE;
#else
    if (mListener == NULL) return MDS_MODE_NONE;
    mode = mListener->getDisplayMode(false);
    if (checkMode(mode, MDS_HDMI_VIDEO_EXT))
        mode = MDS_HDMI_VIDEO_ISPLAYING;
    else if (checkMode(mode,MDS_WIDI_ON))
        mode = MDS_WIDI_VIDEO_ISPLAYING;
    else
        mode = MDS_INIT_VALUE;
#endif
    //ALOGV("mds mode is %d", mode);
    return mode;
}
int MultiDisplayComposer::setMipiMode_l(bool on) {
    ALOGV("IMDS-Native: MultiDisplayComposer.cpp: setMipiMode_l");
    Mutex::Autolock _l(mLock);

    if (mMipiOn == on)
        return MDS_NO_ERROR;

    if (on) {
        drm_mipi_setMode(DRM_MIPI_ON);
        mMode |= MDS_MIPI_ON;
    } else {
        if(!mWidiVideoExt) {
            if (!checkMode(mMode, MDS_HDMI_VIDEO_EXT)) {
                ALOGW("%s: Attempt to turn off Mipi while not in extended video mode.", __func__);
                broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
                return MDS_ERROR;
            }
            if (mMipiPolicy == MDS_MIPI_OFF_ALLOWED) {
                drm_mipi_setMode(DRM_MIPI_OFF);
                mMode &= ~MDS_MIPI_ON;
            }
        } else {
            drm_mipi_setMode(DRM_MIPI_OFF);
            mMode &= ~MDS_MIPI_ON;
        }
    }
    mMipiOn = on;
    ALOGI("Turn on/off mipi, %d", on);
    return MDS_NO_ERROR;
}
Beispiel #4
0
 void Image::setMetadata(const Image& image)
 {
     if (checkMode(mdExif) & amWrite) {
         setExifData(image.exifData());
     }
     if (checkMode(mdIptc) & amWrite) {
         setIptcData(image.iptcData());
     }
     if (checkMode(mdXmp) & amWrite) {
         setXmpPacket(image.xmpPacket());
         setXmpData(image.xmpData());
     }
     if (checkMode(mdComment) & amWrite) {
         setComment(image.comment());
     }
 }
Beispiel #5
0
/** check if a received message should be parsed */
bool BaseCommon_c::checkParseReceived(const IsoName_c& acrc_currentSender) const
{
  return ( checkMode(IsoAgLib::IdentModeImplement) // I'm not the sender
            && ( // one of the following conditions must be true
                   (mc_selectedDataSourceISOName == acrc_currentSender  ) // actual sender equivalent to last
                || (mc_selectedDataSourceISOName.isUnspecified()         ) // last sender has not correctly claimed address member
               )
          );
}
task main()
{
	while(true){
		checkMode();
		drive();
		tread();
		wheel();
	}
}
Beispiel #7
0
 void
 TracLight_c::close_specialized()
 {
   if (checkMode (IsoAgLib::IdentModeTractor))
   { // Tractor to OFF
     getUnregisterPgn()(LIGHTING_COMMAND_PGN);
   }
   else
   { // Implement to OFF
     getUnregisterPgn()(LIGHTING_DATA_PGN);
   }
 }
Beispiel #8
0
/** functions with actions, which must be performed periodically
    -> called periodically by Scheduler_c
    ==> sends base data msg if configured in the needed rates
    possible errors:
      * dependant error in CanIo_c on CAN send problems
    <!--@param ai32_demandedExecEnd optional timestamp, where timeEvent shall return execution to calling function-->
    @see CanPkg_c::getData
    @see CanPkgExt_c::getData
    @see CanIo_c::operator<<
  */
void BaseCommon_c::timeEvent()
{
  checkCreateReceiveFilter();

  // check for different base data types whether the previously
  // sending node stopped sending -> other nodes can now step in
  if (  checkMode(IsoAgLib::IdentModeImplement)
        &&(lastedTimeSinceUpdate() >= getTimeOut( ) )
        && (mc_selectedDataSourceISOName.isSpecified())    )
  { // the previously sending node didn't send the information for 3 seconds -> give other items a chance
    mc_selectedDataSourceISOName.setUnspecified();
  }


  if ( mpc_ident && ( ! mpc_ident->isClaimedAddress() ) )
  { // local isoname for sending is registrated, but it is not yet fully claimed
    // --> nothing to do
    return;
  }

  // check if we are in tractor mode and have a pointer to the sending isoname
  if ( checkMode(IsoAgLib::IdentModeTractor) )
  { // all tractor mode timeEvent() functions have the only target to send messages,
    // now:
    // 1) getISOName() != NULL
    // 2) getSystemMgmtInstance4Comm().existLocalMemberISOName(*getISOName(), true) indicates, that a corresponding
    //    item has already performed its address claim
    // ==> we can directly call sending time event in this case
    timeEventTracMode();
    return;
  }
  else
  { // we are in implement mode
    // call this function also if isoName == NULL, because some functions do settings which are independent from isoName
    timeEventImplMode();
    return;
  }
}
Beispiel #9
0
HomeWindowPrivate::HomeWindowPrivate()
: isVisible(false), window(0), compositorWindow(0), context(0), root(0)
{
    checkMode();
    if (0 == HomeApplication::instance())
        qFatal("HomeWindow: Must create HomeApplication before HomeWindow");

    context = new QQmlContext(HomeApplication::instance()->engine());

    if (isWindow()) {
        window = new QQuickWindow;
        // XXX
        // window->setResizeMode(QQuickView::SizeRootObjectToView);
    } else {
        window = LipstickCompositor::instance();
    }
}
Beispiel #10
0
bool Esp8266::connectAP(String ssid, String password) {

	unsigned long timeout = 20000;
	unsigned long t_start = 0;
	int buf[10];
	char index=0;
 
	if (checkMode()!=WIFI_MODE_AP){
		this->wifiMode = WIFI_MODE_STATION;
	}
	else {
		if (setMode(WIFI_MODE_STATION))
			this->wifiMode = WIFI_MODE_STATION;
		else {
			if (this->isDebug) {
				debugPrintln("set mode to station false!");
			}
			return false;
		}
	}

	clearBuf();
	this->serial->println("AT+CWJAP=\""+ssid+"\",\""+password+"\"");
	t_start = millis();
	while ((millis()-t_start) < timeout) {
		while (available()>0) {
			buf[index] = read();
			if (buf[index]=='K' && buf[(index+9)%10]=='O') {
				return true;
			}
			if (buf[index]=='L' && buf[(index+9)%10]=='I' && buf[(index+8)%10]=='A' && buf[(index+7)%10]=='F') {
				return false;
			}
			index++;
			if (index==10)
				index = 0;
		}
	}
	if (this->isDebug) {
		debugPrintln("connect AP timeout");
	}
	return false;
}
Beispiel #11
0
bool psbMultiDisplayListener::getDecoderOutputResolution(
        int32_t* width, int32_t* height,
        int32_t* offX, int32_t* offY,
        int32_t* bufW, int32_t* bufH) {
#ifndef USE_MDS_LEGACY
    if (mListener.get() == NULL ||
            width == NULL || height == NULL ||
            offX == NULL || offY == NULL ||
            bufW == NULL || bufH == NULL)
        return false;
    // only for WIDI video playback,
    // TODO: HWC doesn't set the bit "MDS_WIDI_ON" rightly now
    int mode = mListener->getDisplayMode(false);
    if (!checkMode(mode, (MDS_VIDEO_ON | MDS_WIDI_ON)))
        return false;
    status_t ret = mListener->getDecoderOutputResolution(0, width, height, offX, offY, bufW, bufH);
    return (ret == NO_ERROR);
#else
    return false;
#endif
}
Beispiel #12
0
  bool TracLight_c::config_base ( IdentItem_c* apc_ident, IsoAgLib::IdentMode_t at_identMode, uint16_t aui16_suppressMask )
  {
    //store old mode to decide to register or unregister to request for pgn
    IsoAgLib::IdentMode_t t_oldMode = getMode();
    //call config for handling which is base data independent
    //if something went wrong leave function before something is configured
    if ( ! BaseCommon_c::config_base ( apc_ident, at_identMode, aui16_suppressMask) ) return false;

    if ( checkMode(IsoAgLib::IdentModeTractor))
    {
      // set Time Period in ms for Scheduler_c
      mt_task.setPeriod( 1000, false );
    }

    // un-/register to PGN
    if (t_oldMode == at_identMode)
      ; // no change, still the same mode
    else if (at_identMode == IsoAgLib::IdentModeTractor) {
      // a change from Implement mode to Tractor mode occured
      getUnregisterPgn()(LIGHTING_DATA_PGN);
      getRegisterPgn()(LIGHTING_COMMAND_PGN);
    } else {
      // a change from Tractor mode to Implement mode occured
      getUnregisterPgn()(LIGHTING_COMMAND_PGN);
      getRegisterPgn()(LIGHTING_DATA_PGN);
    }

    // set configure values
    mb_cmdWait4Response = false;
    mb_changeNeedBeSend = false;

    for (int i = 0; i < 10; i++)
      marr_timeStamp[i] = 0;

    m_index = 0;

    return true;
  };
Beispiel #13
0
bool psbMultiDisplayListener::getDecoderOutputResolution(int32_t* width, int32_t* height) {
#ifndef USE_MDS_LEGACY
    if (mListener.get() == NULL ||
            width == NULL || height == NULL)
        return false;
    // only for WIDI video playback,
    // TODO: HWC doesn't set the bit "MDS_WIDI_ON" rightly now
#if 0
    int mode = mListener->getMode();
#else
    int mode = mListener->getDisplayMode(false);
#endif
    if (!checkMode(mode, (MDS_VIDEO_ON | MDS_WIDI_ON)))
        return false;
#if 0
    return mListener->getDecoderOutputResolution(width, height);
#else
    return mListener->getDecoderOutputResolution(-1, width, height);
#endif
#else
    return false;
#endif
}
Beispiel #14
0
bool HomeWindowPrivate::isCompositor()
{
    if (mode == Unknown) checkMode();
    return mode == Compositor;
}
//#pragma code highPriorityInterruptAddress=0x0008
//void high_interrupt(void)
//{
//    _asm GOTO highPriorityIsr _endasm
//}
//
//#pragma code
void main(void){
  


  //Default
  TRISD = 0x00;         //set port D signals to output
  menu_ref_1=1;
  menu_ref_2=0;
  
  
  /*zone of disgust*/
  
  values[MAXSPEED]=100;        //Max speed
  values[PIDGAINS]=100;        //PID Gains
  values[MAXYAW]=100;        //Max Yaw
  values[IRSAMPE]=10;         //ir_samp_e;
  values[IRSAMPR]=20;         //ir_samp_r;
  values[IRRAW]=60;         //ir_raw
  values[IRAVG]=10;         //ir_avg;
  
  /*****************/
  
  setupSerial();
  Lcd_Init();
  ADC_setup();
  Button_Setup();
  welcome();
  LCD_disp(menu_ref_1, menu_ref_2);

  RUN=0;
  while(1){

  
//NORMAL OPERATION  
    while(RUN==0){
        
        
        if(PORTDbits.RD0 == 0)
        {
            mode_button = 1;
        }
        
        if(PORTDbits.RD1 == 0)
        {
            motor_button = 1;
        }
        
        


        if (mode_button==1){                  //Mode change sequence
                checkMode(menu);
                menu_ref_2=0;         //Default menu ref, should only be SPEED
                delayms(200);
                mode_button=0;
                LCD_disp(menu_ref_1, menu_ref_2);
        }

        delayms(200);       //Used to prevent double tapping
        //possibly new function
        switchChannels(0);
        joy_x = doADC();
        switchChannels(1);
        joy_y = doADC();   
                         
      
        if(menu_ref_1==MANUAL)   //IF IN MANUAL
        {
            
           
            if(joy_x<=LEFT){      //User pushes right joystick left
                if(values[menu_ref_2]>0){
                    values[menu_ref_2]=values[menu_ref_2]-5;          //decrement value by 5%
                    GLOBAL_MAX_SPEED = values[menu_ref_2];
                    sendMaxSpeed();
                }
                
                LCD_disp(menu_ref_1, menu_ref_2);
                delayms(200);     //Delay to prevent flickering, and also to prevent 100-0 increments

            }
            else if (joy_x>=RIGHT){     //User pushes right joystick right
                if(values[menu_ref_2]<100){
                
                    values[menu_ref_2]=values[menu_ref_2]+5;          //increment value by 5%
                    GLOBAL_MAX_SPEED = values[menu_ref_2];
                    sendMaxSpeed();
                }
                
                LCD_disp(menu_ref_1, menu_ref_2);
                delayms(200);
            }   
        }  

        else if(menu_ref_1==FACTORY){            //IF IN FACTORY MODE
            if (joy_y>=UP){            //User pushes left joystick UP  
                //Circular selection
                if(menu_ref_2==0){
                  menu_ref_2=4;
                }
                else{
                  menu_ref_2--;             //switched the order of this to prevent overflow
                }
                LCD_disp(menu_ref_1, menu_ref_2);
                delayms(250);               //Arbitrary delay of 250 milliseconds
            }
            else if (joy_y<=DOWN){      //User pushes left joystick DOWN
                menu_ref_2++;
                //Circular selection
                if(menu_ref_2>=7){
                  menu_ref_2=1;
                }
                LCD_disp(menu_ref_1, menu_ref_2);
                delayms(250);
                

            }
            else if (joy_x<=LEFT){      //User pushes right joystick left
                
                if(values[menu_ref_2]>0){
                    values[menu_ref_2]=values[menu_ref_2]-5;          //decrement value by 5%
                }
                
                LCD_disp(menu_ref_1, menu_ref_2);
                delayms(255);
                delayms(200);

            }
            else if (joy_x>=RIGHT){     //User pushes right joystick right
                
                if(values[menu_ref_2]<100){
                    values[menu_ref_2]=values[menu_ref_2]+5;          //decrement value by 5%
                }
                
                LCD_disp(menu_ref_1, menu_ref_2);
                delayms(255);
                delayms(200);

            }            
        }  
        
        //All other menu_ref_1's do not have values displayed       
        
        if (motor_button==1){
            motor_button=0;
            RUN=1;
            
        }
        //send here
    }
    
    /*Menu on setup*/
    if (RUN==1){
        on_setup();
        GLOBAL_RUN = RUN;
        sendRun();
        //MOTOR ON GOES AFTER
        motor_button=0;
    }
      
      /*MOTOR ON BEHAVIOUR*/
    while(RUN==1){
        if(PORTDbits.RD1 == 0)
        {
            motor_button = 1;
        }
        if (motor_button==1){      //At interrupt, stop motor and return to menu
            motor_button=0;
            RUN=0;
            GLOBAL_RUN = RUN;
            sendRun();
            
        }
        switchChannels(0);
        //GLOBAL_VELOCITY = doADC();    GLOBAL_VELOCITY = doADC() //Get joystick values
        joy_y = doADC();
        GLOBAL_VELOCITY = joy_y;
        
        switchChannels(1);
        joy_x = doADC();
        GLOBAL_OMEGA = joy_x;
        
        sendVelocity();
        sendOmega();
        
        //send command here
    }
      
      /*MOTOR OFF MESSAGE*/ 
    RUN=0;
      //MOTOR OFF FUNCTION GOES BEFORE MESSAGE
    LCD_title(t5);         //"Whoa!"
      
    delays(2);    //safety delay    

    LCD_disp(menu_ref_1, menu_ref_2); //Return to normal display
      
      
  }
  
  
  
}
Beispiel #16
0
bool HomeWindowPrivate::isWindow()
{
    if (mode == Unknown) checkMode();
    return mode == Window;
}
int MultiDisplayComposer::setHdmiMode_l() {
    ALOGV("IMDS-Native: MultiDisplayComposer.cpp: setHdmiMode_l");
    ALOGV("Entering %s, current mode = %#x", __func__, mMode);
    MDSHDMITiming timing;
    memset(&timing, 0, sizeof(MDSHDMITiming));

    // Common case, update video status
    if (mVideo.isPlaying) {
        mMode |= MDS_VIDEO_PLAYING;
    } else {
        mMode &= ~MDS_VIDEO_PLAYING;
    }
    // Common case, check HDMI connect status
    int connectStatus = getHdmiPlug_l();
#if !defined(DVI_SUPPORTED)
    if (connectStatus == DRM_DVI_CONNECTED) {
        ALOGE("%s: DVI is connected but is not supported for now.", __func__);
        broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
        mConnectStatus = connectStatus;
        return MDS_ERROR;
    }
#endif
    // Common case, turn on MIPI if necessary
    if (connectStatus == DRM_HDMI_DISCONNECTED ||
        mHdmiPolicy == MDS_HDMI_ON_NOT_ALLOWED ||
        mVideo.isPlaying == false) {
        mMipiPolicy = MDS_MIPI_OFF_NOT_ALLOWED;
        if (!checkMode(mMode, MDS_MIPI_ON)) {
            ALOGI("Turn on MIPI.");
            drm_mipi_setMode(DRM_MIPI_ON);
            mMode |= MDS_MIPI_ON;
            mMipiOn = true;
        }
    }
    // Common case, HDMI is disconnected
    if (connectStatus == DRM_HDMI_DISCONNECTED) {
        ALOGI("HDMI is disconnected.");
        if (!checkMode(mMode, MDS_HDMI_CONNECTED)) {
            ALOGW("HDMI is already in disconnected state.");
            broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
            mConnectStatus = connectStatus;
            return MDS_NO_ERROR;
        }

        ALOGV("Notify HDMI audio driver hot unplug event.");
        drm_hdmi_notify_audio_hotplug(false);
        drm_hdcp_disable_hdcp(false);
        mMode &= ~MDS_HDMI_CONNECTED;
        mMode &= ~MDS_HDMI_ON;
        mMode &= ~MDS_HDCP_ON;
        mMode &= ~MDS_HDMI_CLONE;
        mMode &= ~MDS_HDMI_VIDEO_EXT;
        mMode &= ~MDS_OVERLAY_OFF;
        broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
        drm_hdmi_onHdmiDisconnected();
        mConnectStatus = connectStatus;
        return MDS_NO_ERROR;
    }

    ALOGI("HDMI is connected.");
    bool notify_audio_hotplug = (mMode & MDS_HDMI_CONNECTED) == 0;
    mMode |= MDS_HDMI_CONNECTED;

    // Common case, check HDMI policy
    if (mHdmiPolicy == MDS_HDMI_ON_NOT_ALLOWED) {
        ALOGI("HDMI on is not allowed. Turning off HDMI...");
        if (mConnectStatus != connectStatus &&
               notify_audio_hotplug && mDrmInit) {
            // Do not need to notify HDMI audio driver about hotplug during startup.
            ALOGV("Notify HDMI audio drvier hot plug event.");
            drm_hdmi_notify_audio_hotplug(true);
            mConnectStatus = connectStatus;
        }
        if (!checkMode(mMode, MDS_HDMI_ON)) {
            ALOGW("HDMI is already in off state.");
            broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
            return MDS_NO_ERROR;
        }
        if (checkMode(mMode, MDS_HDCP_ON)) {
            drm_hdcp_disable_hdcp(true);
        }
        mMode &= ~MDS_HDCP_ON;
        mMode &= ~MDS_HDMI_ON;
        mMode &= ~MDS_HDMI_CLONE;
        mMode &= ~MDS_HDMI_VIDEO_EXT;
        broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
        drm_hdmi_setHdmiVideoOff();
        return MDS_NO_ERROR;
    }
    mConnectStatus = connectStatus;

    if (mVideo.isPlaying && checkMode(mMode, MDS_HDMI_VIDEO_EXT)) {
        ALOGW("HDMI is already in Video Extended mode.");
        broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
        return MDS_NO_ERROR;
    } else if (!mVideo.isPlaying && checkMode(mMode, MDS_HDMI_CLONE)) {
        ALOGW("HDMI is already in cloned state.");
        broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
        return MDS_NO_ERROR;
    }
    // Common case, turn off overlay temporarily during mode transition.
    // Make sure overlay is turned on when this function exits.
    // Transition mode starts with standalone local mipi mode (no cloned, no video extended).
    int transitionalMode = mMode;
    transitionalMode &= ~MDS_HDMI_CLONE;
    transitionalMode &= ~MDS_HDMI_VIDEO_EXT;
    transitionalMode |= MDS_OVERLAY_OFF;
    broadcastMessage_l(MDS_MODE_CHANGE, &transitionalMode, sizeof(transitionalMode));

    //Before HDMI mode change, disalbe HDCP
    if (checkMode(mMode, MDS_HDCP_ON)) {
        ALOGV("Turning off HDCP before mode change");
        drm_hdcp_disable_hdcp(true);
        mMode &= ~MDS_HDCP_ON;
    }

    // Common case, notify HWC to set HDMI timing if need
    if (mVideo.isPlaying) {
        // disable dynamic mode setting for presentation mode
        if (isHdmiTimingDynamicSettingEnable_l()) {
            ALOGI("Video is in playing state. Mode = %#x", mMode);
            timing.width = mVideo.displayW;
            timing.height = mVideo.displayH;
            timing.refresh = mVideo.frameRate;
            timing.interlace = 0;
            timing.ratio = 0;
            drm_hdmi_getTiming(DRM_HDMI_VIDEO_EXT, &timing);
            setHdmiTiming_l((void*)&timing, sizeof(MDSHDMITiming));
        }
    } else {
        ALOGV("Video is not in playing state. Mode = %#x", mMode);
        drm_hdmi_getTiming(DRM_HDMI_CLONE, &timing);
        setHdmiTiming_l((void*)&timing, sizeof(MDSHDMITiming));
    }
    // Common case, turn on HDCP
    if (drm_hdcp_enable_hdcp() == false) {
        ALOGE("Fail to enable HDCP.");
        // Continue mode setting as it may be recovered, unless HDCP is not supported.
        // If HDCP is not supported, user will have to unplug the cable to restore video to phone.
    } else {
        ALOGV("Turning on HDCP...");
        mMode |= MDS_HDCP_ON;
    }
    // Common case, prolong overlay off time
    mMode |= MDS_OVERLAY_OFF;
    if (mVideo.isPlaying) {
        mMode |= MDS_HDMI_VIDEO_EXT;
        mMode &= ~MDS_HDMI_CLONE;
        mMipiPolicy = MDS_MIPI_OFF_ALLOWED;
    } else {
        mMode &= ~MDS_HDMI_VIDEO_EXT;
        mMode |= MDS_HDMI_CLONE;
    }
    broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));

    // Common case, turn on HDMI if need
    if (!checkMode(mMode, MDS_HDMI_ON)) {
        ALOGI("Turn on HDMI...");
        if (!drm_hdmi_setHdmiVideoOn()) {
            ALOGI("Fail to turn on HDMI.");
        }
        mMode |= MDS_HDMI_ON;
        broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));
    }

    // Common case, notify HWC to turn on Overlay if need
    if (checkMode(mMode, MDS_HDMI_VIDEO_EXT)) {
        //Enable overlay lastly
        mMode &= ~MDS_OVERLAY_OFF;
    }
    broadcastMessage_l(MDS_MODE_CHANGE, &mMode, sizeof(mMode));

    // Common case, notify audio driver if need
    if (notify_audio_hotplug && mDrmInit) {
        // Do not need to notify HDMI audio driver about hotplug during startup.
        ALOGV("Notify HDMI audio drvier hot plug event.");
        drm_hdmi_notify_audio_hotplug(true);
    }

    ALOGV("Leaving %s, new mode is %#x", __func__, mMode);
    return MDS_NO_ERROR;
}
Beispiel #18
0
 /** send light update; there is a difference between implement and tractor mode
     @see  TracLight_c::processMsgRequestPGN
     @see  CanIo_c::operator<<
   */
 void TracLight_c::sendMessage()
 {
   bool const b_isTractor = checkMode(IsoAgLib::IdentModeTractor);
   return (void)(b_isTractor ? sendLightingCommand() : sendLightingData());
 }
Beispiel #19
0
static struct ir_remote * read_config_recursive(FILE *f, const char *name, int depth)
{
	char buf[LINE_LEN+1], *key, *val, *val2;
        int len,argc;
	struct ir_remote *top_rem=NULL,*rem=NULL;
        struct void_array codes_list,raw_codes,signals;
	struct ir_ncode raw_code={NULL,0,0,NULL};
	struct ir_ncode name_code={NULL,0,0,NULL};
	struct ir_ncode *code;
	int mode=ID_none;

	line=0;
	parse_error=0;
	LOGPRINTF(2, "parsing '%s'", name);

	while(fgets(buf,LINE_LEN,f)!=NULL)
	{
		line++;
		len=strlen(buf);
		if(len==LINE_LEN && buf[len-1]!='\n')
		{
			logprintf(LOG_ERR,"line %d too long in config file",
				  line);
			parse_error=1;
			break;
		}

		if(len>0)
		{
			len--;
			if(buf[len]=='\n') buf[len]=0;
		}
		if(len>0)
		{
			len--;
			if(buf[len]=='\r') buf[len]=0;
		}
                /* ignore comments */
                if(buf[0]=='#'){
			continue;
                }
		key=strtok(buf, whitespace);
		/* ignore empty lines */
		if(key==NULL) continue;
		val=strtok(NULL, whitespace);
		if(val!=NULL){
			val2=strtok(NULL, whitespace);
			LOGPRINTF(3,"\"%s\" \"%s\"",key,val);
			if (strcasecmp("include",key)==0){
                                FILE* childFile;
				const char *childName;
				const char *fullPath;
				char result[FILENAME_MAX+1];


				if (depth > MAX_INCLUDES) {
					logprintf(LOG_ERR,"error opening child file defined at %s:%d",name,line);
					logprintf(LOG_ERR,"too many files included");
					parse_error=-1;
					break;
				}

				childName = lirc_parse_include(val);
				if (!childName){
					logprintf(LOG_ERR,"error parsing child file value defined at line %d:",line);
					logprintf(LOG_ERR,"invalid quoting");
					parse_error=-1;
					break;
				}

				fullPath = lirc_parse_relative(result, sizeof(result), childName, name);
				if (!fullPath) {
					logprintf(LOG_ERR,"error composing relative file path defined at line %d:",line);
					logprintf(LOG_ERR,"resulting path too long");
					parse_error=-1;
					break;
				}

				childFile = fopen(fullPath, "r");
				if (childFile == NULL){
					logprintf(LOG_ERR,"error opening child file '%s' defined at line %d:",fullPath, line);
					logprintf(LOG_ERR,"ignoring this child file for now.");
				}
				else{
					int save_line = line;

					if (!top_rem){
						/* create first remote */
						LOGPRINTF(2,"creating first remote");
						rem = read_config_recursive(childFile, fullPath, depth + 1);
						if(rem != (void *) -1 && rem != NULL) {
							top_rem = rem;
						} else {
							rem = NULL;
						}
					}else{
						/* create new remote */
						LOGPRINTF(2,"creating next remote");
						rem->next=read_config_recursive(childFile, fullPath, depth + 1);
						if(rem->next != (void *) -1 && rem->next != NULL) {
							rem=rem->next;
						} else {
							rem->next = NULL;
						}
					}
					fclose(childFile);
					line = save_line;
				}
			}else if (strcasecmp("begin",key)==0){
				if (strcasecmp("codes", val)==0){
                                        /* init codes mode */
					LOGPRINTF(2,"    begin codes");
					if (!checkMode(mode, ID_remote,
						       "begin codes")) break;
					if (rem->codes){
						logprintf(LOG_ERR,"error in configfile line %d:",line);
						logprintf(LOG_ERR,"codes are already defined");
						parse_error=1;
						break;
					}

                                        init_void_array(&codes_list,30, sizeof(struct ir_ncode));
                                        mode=ID_codes;
                                }else if(strcasecmp("raw_codes",val)==0){
                                        /* init raw_codes mode */
					LOGPRINTF(2,"    begin raw_codes");
					if(!checkMode(mode, ID_remote,
						  "begin raw_codes")) break;
					if (rem->codes){
						logprintf(LOG_ERR,"error in configfile line %d:",line);
						logprintf(LOG_ERR,"codes are already defined");
						parse_error=1;
						break;
					}
					set_protocol(rem, RAW_CODES);
					raw_code.code=0;
                                        init_void_array(&raw_codes,30, sizeof(struct ir_ncode));
                                        mode=ID_raw_codes;
                                }else if(strcasecmp("remote",val)==0){
					/* create new remote */
					LOGPRINTF(1,"parsing remote");
					if(!checkMode(mode, ID_none,
						  "begin remote")) break;
                                        mode=ID_remote;
                                        if (!top_rem){
                                                /* create first remote */
						LOGPRINTF(2,"creating first remote");
                                                rem=top_rem=s_malloc(sizeof(struct ir_remote));
                                        }else{
                                                /* create new remote */
						LOGPRINTF(2,"creating next remote");
                                                rem->next=s_malloc(sizeof(struct ir_remote));;
                                                rem=rem->next;
                                        }
				}else if(mode==ID_codes){
					code=defineCode(key, val, &name_code);
					while(!parse_error && val2!=NULL)
					{
						struct ir_code_node *node;

						if(val2[0]=='#') break; /* comment */
						node=defineNode(code, val2);
						val2=strtok(NULL, whitespace);
					}
					code->current=NULL;
					add_void_array(&codes_list, code);
                                }else{
                                        logprintf(LOG_ERR,"error in configfile line %d:",line);
					logprintf(LOG_ERR,"unknown section \"%s\"",val);
                                        parse_error=1;
                                }
				if(!parse_error && val2!=NULL)
				{
					logprintf(LOG_WARNING,"garbage after "
						  "'%s' token in line %d ignored",
						  val,line);
				}
                        }else if (strcasecmp("end",key)==0){

				if (strcasecmp("codes", val)==0){
					/* end Codes mode */
					LOGPRINTF(2,"    end codes");
                                        if (!checkMode(mode, ID_codes,
						       "end codes")) break;
                                        rem->codes=get_void_array(&codes_list);
                                        mode=ID_remote;     /* switch back */

                                }else if(strcasecmp("raw_codes",val)==0){
                                        /* end raw codes mode */
					LOGPRINTF(2,"    end raw_codes");

					if(mode==ID_raw_name){
						raw_code.signals=get_void_array(&signals);
						raw_code.length=signals.nr_items;
						if(raw_code.length%2==0)
						{
							logprintf(LOG_ERR,"error in configfile line %d:",line);
							logprintf(LOG_ERR,"bad signal length");
							parse_error=1;
						}
						if(!add_void_array(&raw_codes, &raw_code))
							break;
						mode=ID_raw_codes;
					}
                                        if(!checkMode(mode,ID_raw_codes,
						      "end raw_codes")) break;
					rem->codes=get_void_array(&raw_codes);
					mode=ID_remote;     /* switch back */
                                }else if(strcasecmp("remote",val)==0){
                                        /* end remote mode */
					LOGPRINTF(2,"end remote");
					/* print_remote(rem); */
                                        if (!checkMode(mode,ID_remote,
                                                  "end remote")) break;
					if(!sanityChecks(rem)) {
                                                parse_error=1;
                                                break;
					}

#                                       ifdef DYNCODES
					if(rem->dyncodes_name==NULL)
					{
						rem->dyncodes_name=s_strdup("unknown");
					}
					rem->dyncodes[0].name=rem->dyncodes_name;
					rem->dyncodes[1].name=rem->dyncodes_name;
#                                       endif
					/* not really necessary because we
					   clear the alloced memory */
                                        rem->next=NULL;
					rem->last_code=NULL;
                                        mode=ID_none;     /* switch back */
				}else if(mode==ID_codes){
					code=defineCode(key, val, &name_code);
					while(!parse_error && val2!=NULL)
					{
						struct ir_code_node *node;

						if(val2[0]=='#') break; /* comment */
						node=defineNode(code, val2);
						val2=strtok(NULL, whitespace);
					}
					code->current=NULL;
					add_void_array(&codes_list, code);
                                }else{
                                        logprintf(LOG_ERR,"error in configfile line %d:",line);
					logprintf(LOG_ERR,"unknown section %s",val);
                                        parse_error=1;
                                }
				if(!parse_error && val2!=NULL)
				{
					logprintf(LOG_WARNING,"garbage after '%s'"
						  " token in line %d ignored",
						  val,line);
				}
                        } else {
				switch (mode){
				case ID_remote:
					argc=defineRemote(key, val, val2, rem);
					if(!parse_error && ((argc==1 && val2!=NULL) || 
					   (argc==2 && val2!=NULL && strtok(NULL, whitespace)!=NULL)))
					{
						logprintf(LOG_WARNING,"garbage after '%s'"
							  " token in line %d ignored",
							  key,line);
					}
					break;
				case ID_codes:
					code=defineCode(key, val, &name_code);
					while(!parse_error && val2!=NULL)
					{
						struct ir_code_node *node;

						if(val2[0]=='#') break; /* comment */
						node=defineNode(code, val2);
						val2=strtok(NULL, whitespace);
					}
					code->current=NULL;
					add_void_array(&codes_list, code);
					break;
				case ID_raw_codes:
				case ID_raw_name:
					if(strcasecmp("name",key)==0){
						LOGPRINTF(3,"Button: \"%s\"",val);
						if(mode==ID_raw_name)
						{
                                                        raw_code.signals=get_void_array(&signals);
							raw_code.length=signals.nr_items;
							if(raw_code.length%2==0)
							{
								logprintf(LOG_ERR,"error in configfile line %d:",line);
								logprintf(LOG_ERR,"bad signal length");
								parse_error=1;
							}
							if(!add_void_array(&raw_codes, &raw_code))
								break;
						}
						if(!(raw_code.name=s_strdup(val))){
							break;
						}
						raw_code.code++;
						init_void_array(&signals,50,sizeof(lirc_t));
						mode=ID_raw_name;
						if(!parse_error && val2!=NULL)
						{
							logprintf(LOG_WARNING,"garbage after '%s'"
								  " token in line %d ignored",
								  key,line);
						}
					}else{
						if(mode==ID_raw_codes)
						{
							logprintf(LOG_ERR,"no name for signal defined at line %d",line);
							parse_error=1;
							break;
						}
						if(!addSignal(&signals, key)) break;
						if(!addSignal(&signals, val)) break;
						if (val2){
							if (!addSignal(&signals, val2)){
								break;
							}
						}
						while ((val=strtok(NULL, whitespace))){
							if (!addSignal(&signals, val)) break;
						}
					}
					break;
				}
			}
		}else if(mode==ID_raw_name){
                        if(!addSignal(&signals, key)){
				break;
			}
		}else{
                        logprintf(LOG_ERR,"error in configfile line %d", line);
			parse_error=1;
			break;
                }
                if (parse_error){
                        break;
                }
        }
	if(mode!=ID_none)
	{
		switch(mode)
		{
		case ID_raw_name:
			if(raw_code.name!=NULL)
			{
				free(raw_code.name);
				if(get_void_array(&signals)!=NULL)
					free(get_void_array(&signals));
			}
		case ID_raw_codes:
			rem->codes=get_void_array(&raw_codes);
			break;
		case ID_codes:
			rem->codes=get_void_array(&codes_list);
			break;
		}
		if(!parse_error)
		{
			logprintf(LOG_ERR,"unexpected end of file");
			parse_error=1;
		}
	}
        if (parse_error){
		static int print_error = 1;

		if(print_error) {
			logprintf(LOG_ERR, "reading of file '%s' failed",
				  name);
			print_error = 0;
		}
		free_config(top_rem);
		if(depth == 0) print_error = 1;
                return((void *) -1);
        }
	/* kick reverse flag */
	/* handle RC6 flag to be backwards compatible: previous RC-6
	   config files did not set rc6_mask */
	rem=top_rem;
	while(rem!=NULL)
	{
		if((!is_raw(rem)) && rem->flags&REVERSE)
		{
			struct ir_ncode *codes;

			if(has_pre(rem))
			{
				rem->pre_data=reverse(rem->pre_data,
						      rem->pre_data_bits);
			}
			if(has_post(rem))
			{
				rem->post_data=reverse(rem->post_data,
						       rem->post_data_bits);
			}
			codes=rem->codes;
			while(codes->name!=NULL)
			{
				codes->code=reverse(codes->code,rem->bits);
				codes++;
			}
			 rem->flags=rem->flags&(~REVERSE);
			 rem->flags=rem->flags|COMPAT_REVERSE;
			/* don't delete the flag because we still need
			   it to remain compatible with older versions
			*/
		}
		if(rem->flags&RC6 && rem->rc6_mask==0 && rem->toggle_bit>0)
		{
			int all_bits=bit_count(rem);

			rem->rc6_mask=((ir_code) 1)<<(all_bits-rem->toggle_bit);
		}
		if(rem->toggle_bit > 0)
		{
			int all_bits=bit_count(rem);

			if(has_toggle_bit_mask(rem))
			{
				logprintf(LOG_WARNING,
					  "%s uses both toggle_bit and "
					  "toggle_bit_mask", rem->name);
			}
			else
			{
				rem->toggle_bit_mask=((ir_code) 1)<<(all_bits-rem->toggle_bit);
			}
			rem->toggle_bit = 0;
		}
		if(has_toggle_bit_mask(rem))
		{
			if(!is_raw(rem) && rem->codes)
			{
				rem->toggle_bit_mask_state = (rem->codes->code & rem->toggle_bit_mask);
				if(rem->toggle_bit_mask_state)
				{
					/* start with state set to 0 for backwards compatibility */
					rem->toggle_bit_mask_state ^= rem->toggle_bit_mask;
				}
			}
		}
		if(is_serial(rem))
		{
			lirc_t base;

			if(rem->baud>0)
			{
				base=1000000/rem->baud;
				if(rem->pzero==0 && rem->szero==0)
				{
					rem->pzero=base;
				}
				if(rem->pone==0 && rem->sone==0)
				{
					rem->sone=base;
				}
			}
			if(rem->bits_in_byte==0)
			{
				rem->bits_in_byte=8;
			}
		}
		if(rem->min_code_repeat>0)
		{
			if(!has_repeat(rem) ||
			   rem->min_code_repeat>rem->min_repeat)
			{
				logprintf(LOG_WARNING,
					  "invalid min_code_repeat value");
				rem->min_code_repeat = 0;
			}
		}
		calculate_signal_lengths(rem);
		rem=rem->next;
	}

	top_rem = sort_by_bit_count(top_rem);
#       if defined(DEBUG) && !defined(DAEMONIZE)
        /*fprint_remotes(stderr, top_rem);*/
#       endif
        return (top_rem);
}
struct ir_remote * read_config(FILE *f)
{
	char buf[LINE_LEN+1], *key, *val, *val2;
        int len,argc;
	struct ir_remote *top_rem=NULL,*rem=NULL;
        struct void_array codes_list,raw_codes,signals;
	struct ir_ncode raw_code={NULL,0,0,NULL};
	struct ir_ncode name_code={NULL,0,0,NULL};
	int mode=ID_none;

	line=0;
	parse_error=0;

	while(fgets(buf,LINE_LEN,f)!=NULL)
	{
		line++;
		len=strlen(buf);
		if(len==LINE_LEN && buf[len-1]!='\n')
		{
			logprintf(LOG_ERR,"line %d too long in config file",
				  line);
			parse_error=1;
			break;
		}

                /* ignore comments */
		len--;
		if(buf[len]=='\n') buf[len]=0;
                if(buf[0]=='#'){
			continue;
                }
		key=strtok(buf," \t");
		/* ignore empty lines */
		if(key==NULL) continue;
		val=strtok(NULL, " \t");
		if(val!=NULL){
			val2=strtok(NULL, " \t");
			LOGPRINTF(3,"\"%s\" \"%s\"",key,val);
                        if (strcasecmp("begin",key)==0){
				if (strcasecmp("codes", val)==0){
                                        /* init codes mode */
					LOGPRINTF(2,"    begin codes");
					if (!checkMode(mode, ID_remote,
						       "begin codes")) break;
					if (rem->codes){
						logprintf(LOG_ERR,"error in configfile line %d:",line);
						logprintf(LOG_ERR,"codes are already defined");
						parse_error=1;
						break;
					}
					
                                        init_void_array(&codes_list,30, sizeof(struct ir_ncode));
                                        mode=ID_codes;
                                }else if(strcasecmp("raw_codes",val)==0){
                                        /* init raw_codes mode */
					LOGPRINTF(2,"    begin raw_codes");
					if(!checkMode(mode, ID_remote,
						  "begin raw_codes")) break;
					if (rem->codes){
						logprintf(LOG_ERR,"error in configfile line %d:",line);
						logprintf(LOG_ERR,"codes are already defined");
						parse_error=1;
						break;
					}
					rem->flags|=RAW_CODES;
					raw_code.code=0;
                                        init_void_array(&raw_codes,30, sizeof(struct ir_ncode));
                                        mode=ID_raw_codes;
                                }else if(strcasecmp("remote",val)==0){
					/* create new remote */
					LOGPRINTF(1,"parsing remote");
					if(!checkMode(mode, ID_none,
						  "begin remote")) break;
                                        mode=ID_remote;
                                        if (!top_rem){
                                                /* create first remote */
						LOGPRINTF(2,"creating first remote");
                                                rem=top_rem=s_malloc(sizeof(struct ir_remote));
                                        }else{
                                                /* create new remote */
						LOGPRINTF(2,"creating next remote");
                                                rem->next=s_malloc(sizeof(struct ir_remote));;
                                                rem=rem->next;
                                        }
                                }else{
                                        logprintf(LOG_ERR,"error in configfile line %d:",line);
					logprintf(LOG_ERR,"unknown section \"%s\"",val);
                                        parse_error=1;
                                }
				if(!parse_error && val2!=NULL)
				{
					logprintf(LOG_WARNING,"garbage after "
						  "'%s' token in line %d ignored",
						  val,line);
				}
                        }else if (strcasecmp("end",key)==0){

				if (strcasecmp("codes", val)==0){
					/* end Codes mode */
					LOGPRINTF(2,"    end codes");
                                        if (!checkMode(mode, ID_codes,
						       "end codes")) break;
                                        rem->codes=get_void_array(&codes_list);
                                        mode=ID_remote;     /* switch back */

                                }else if(strcasecmp("raw_codes",val)==0){
                                        /* end raw codes mode */
					LOGPRINTF(2,"    end raw_codes");
					
					if(mode==ID_raw_name){
						raw_code.signals=get_void_array(&signals);
						raw_code.length=signals.nr_items;
						if(raw_code.length%2==0)
						{
							logprintf(LOG_ERR,"error in configfile line %d:",line);
							logprintf(LOG_ERR,"bad signal length",val);
							parse_error=1;
						}
						if(!add_void_array(&raw_codes, &raw_code))
							break;
						mode=ID_raw_codes;
					}
                                        if(!checkMode(mode,ID_raw_codes,
						      "end raw_codes")) break;
					rem->codes=get_void_array(&raw_codes);
					mode=ID_remote;     /* switch back */
                                }else if(strcasecmp("remote",val)==0){
                                        /* end remote mode */
					LOGPRINTF(2,"end remote");
					/* print_remote(rem); */
                                        if (!checkMode(mode,ID_remote,
                                                  "end remote")) break;
                                        if (!rem->name){
                                                logprintf(LOG_ERR,"you must specify a remote name");
                                                parse_error=1;
                                                break;
                                        }

					/* not really necessary because we
					   clear the alloced memory */
                                        rem->next=NULL;
					rem->last_code=NULL;
                                        mode=ID_none;     /* switch back */
					if(has_repeat_gap(rem) && 
					   is_const(rem))
					{
						logprintf(LOG_WARNING,"repeat_gap will be ignored if CONST_LENGTH flag is set");
					}
                                }else{
                                        logprintf(LOG_ERR,"error in configfile line %d:",line);
					logprintf(LOG_ERR,"unknown section %s",val);
                                        parse_error=1;
                                }
				if(!parse_error && val2!=NULL)
				{
					logprintf(LOG_WARNING,"garbage after '%s'"
						  " token in line %d ignored",
						  val,line);
				}
                        } else {
				switch (mode){
				case ID_remote:
					argc=defineRemote(key, val, val2, rem);
					if(!parse_error && ((argc==1 && val2!=NULL) || 
					   (argc==2 && val2!=NULL && strtok(NULL," \t")!=NULL)))
					{
						logprintf(LOG_WARNING,"garbage after '%s'"
							  " token in line %d ignored",
							  key,line);
					}
					break;
				case ID_codes:
					add_void_array(&codes_list, defineCode(key, val, &name_code));
					if(!parse_error && val2!=NULL)
					{
						logprintf(LOG_WARNING,"garbage after '%s'"
							  " code in line %d ignored",
							  key,line);
					}
					break;
				case ID_raw_codes:
				case ID_raw_name:
					if(strcasecmp("name",key)==0){
						LOGPRINTF(3,"Button: \"%s\"",val);
						if(mode==ID_raw_name)
						{
                                                        raw_code.signals=get_void_array(&signals);
							raw_code.length=signals.nr_items;
							if(raw_code.length%2==0)
							{
								logprintf(LOG_ERR,"error in configfile line %d:",line);
								logprintf(LOG_ERR,"bad signal length",val);
								parse_error=1;
							}
							if(!add_void_array(&raw_codes, &raw_code))
								break;
						}
						if(!(raw_code.name=s_strdup(val))){
							break;
						}
						raw_code.code++;
						init_void_array(&signals,50,sizeof(lirc_t));
						mode=ID_raw_name;
						if(!parse_error && val2!=NULL)
						{
							logprintf(LOG_WARNING,"garbage after '%s'"
								  " token in line %d ignored",
								  key,line);
						}
					}else{
						if(mode==ID_raw_codes)
						{
							logprintf(LOG_ERR,"no name for signal defined at line %d",line);
							parse_error=1;
							break;
						}
						if(!addSignal(&signals, key)) break;
						if(!addSignal(&signals, val)) break;
						if (val2){
							if (!addSignal(&signals, val2)){
								break;
							}
						}
						while ((val=strtok(NULL," \t"))){
							if (!addSignal(&signals, val)) break;
						}
					}
					break;
				}
			}
		}else if(mode==ID_raw_name){
                        if(!addSignal(&signals, key)){
				break;
			}
		}else{
                        logprintf(LOG_ERR,"error in configfile line %d", line);
			parse_error=1;
			break;
                }
                if (parse_error){
                        break;
                }
        }
	if(mode!=ID_none)
	{
		switch(mode)
		{
		case ID_raw_name:
			if(raw_code.name!=NULL)
			{
				free(raw_code.name);
				if(get_void_array(&signals)!=NULL)
					free(get_void_array(&signals));
			}
		case ID_raw_codes:
			rem->codes=get_void_array(&raw_codes);
			break;
		case ID_codes:
			rem->codes=get_void_array(&codes_list);
			break;
		}
		if(!parse_error)
		{
			logprintf(LOG_ERR,"unexpected end of file");
			parse_error=1;
		}
	}
        if (parse_error){
		free_config(top_rem);
                return((void *) -1);
        }
	/* kick reverse flag */
	rem=top_rem;
	while(rem!=NULL)
	{
		if((!is_raw(rem)) && rem->flags&REVERSE)
		{
			struct ir_ncode *codes;
			
			if(has_pre(rem))
			{
				rem->pre_data=reverse(rem->pre_data,
						      rem->pre_data_bits);
			}
			if(has_post(rem))
			{
				rem->post_data=reverse(rem->post_data,
						       rem->post_data_bits);
			}
			codes=rem->codes;
			while(codes->name!=NULL)
			{
				codes->code=reverse(codes->code,rem->bits);
				codes++;
			}
			/* rem->flags=rem->flags&(~REVERSE); */
			/* don't delete the flag because we still need
			   it to remain compatible with older versions
			*/
		}
		rem=rem->next;
	}

#       if defined(DEBUG) && !defined(DAEMONIZE)
        /*fprint_remotes(stderr, top_rem);*/
#       endif
        return (top_rem);
}