/* Setting DE emphasis time constant 50us(Europe,Japan,Australia) or 75us(USA) */ int Si47xx_dev_DE_set(u8 de_tc) { int ret = 0; debug("Si47xx_dev_DE_set called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { dev_err(Si47xx_dev->dev, "Si47xx_dev_DE_set called when DS is invalid"); ret = -1; } else { switch (de_tc) { case DE_TIME_CONSTANT_50: si47xx_set_property(FM_DEEMPHASIS, FM_DEEMPH_50US); break; case DE_TIME_CONSTANT_75: si47xx_set_property(FM_DEEMPHASIS, FM_DEEMPH_75US); break; default: ret = -1; } if (ret < 0) dev_err(Si47xx_dev->dev, "%s failed %d\n", __func__, ret); } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si47xx_dev_sys_config2_set(struct sys_config2 *sys_conf2) { int ret = 0; debug("Si47xx_dev_sys_config2_set called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { dev_err(Si47xx_dev->dev, "Si47xx_dev_sys_config2_set called when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_SEEK_TUNE_RSSI_THRESHOLD, sys_conf2->rssi_th); Si47xx_dev_band_set(sys_conf2->fm_band); si47xx_set_property(FM_SEEK_FREQ_SPACING, sys_conf2->fm_chan_spac); Si47xx_dev->settings.curr_rssi_th = sys_conf2->rssi_th; Si47xx_dev->settings.band = sys_conf2->fm_band; Si47xx_dev->settings.channel_spacing = sys_conf2->fm_chan_spac; } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si4709_dev_ch_spacing_set(int ch_spacing) { int ret = 0; u16 prev_ch_spacing = 0; debug("Si4709_dev_ch_spacing_set called"); mutex_lock(&(Si4709_dev.lock)); prev_ch_spacing = Si4709_dev.settings.channel_spacing; if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_ch_spacing_set called " "when DS is invalid"); ret = -1; } else { switch (ch_spacing) { case CHAN_SPACING_200_kHz: si47xx_set_property(FM_SEEK_FREQ_SPACING, 20); Si4709_dev.settings.channel_spacing = CHAN_SPACING_200_kHz; break; case CHAN_SPACING_100_kHz: si47xx_set_property(FM_SEEK_FREQ_SPACING, 10); Si4709_dev.settings.channel_spacing = CHAN_SPACING_100_kHz; break; case CHAN_SPACING_50_kHz: si47xx_set_property(FM_SEEK_FREQ_SPACING, 5); Si4709_dev.settings.channel_spacing = CHAN_SPACING_50_kHz; break; default: ret = -1; } if (ret == 0) { if (ret < 0) { debug("Si4709_dev_ch_spacing_set " "i2c_write 1 failed"); Si4709_dev.settings.channel_spacing = prev_ch_spacing; } } } mutex_unlock(&(Si4709_dev.lock)); return ret; }
int Si4709_dev_volume_set(u8 volume) { int ret = 0; u16 sysconfig2 = 0; debug("Si4709_dev_volume_set called"); mutex_lock(&(Si4709_dev.lock)); if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_volume_set called when DS is invalid"); ret = -1; } else { si47xx_set_property(RX_VOLUME, rx_vol[volume] & RX_VOLUME_MASK); if (ret < 0) { debug("Si4709_dev_volume_set i2c_write failed"); Si4709_dev.registers[SYSCONFIG2] = sysconfig2; } } mutex_unlock(&(Si4709_dev.lock)); return ret; }
int Si4709_dev_MUTE_ON(void) { int ret = 0; u16 powercfg = 0; debug("Si4709_dev_MUTE_ON called"); mutex_lock(&(Si4709_dev.lock)); powercfg = Si4709_dev.registers[POWERCFG]; if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_MUTE_ON called when DS is invalid"); ret = -1; } else { si47xx_set_property(RX_HARD_MUTE, RX_HARD_MUTE_RMUTE_MASK | RX_HARD_MUTE_LMUTE_MASK); if (ret < 0) debug("Si4709_dev_MUTE_ON i2c_write failed"); } mutex_unlock(&(Si4709_dev.lock)); return ret; }
int Si4709_dev_sys_config3_set(struct sys_config3 *sys_conf3) { int ret = 0; u16 register_bak = 0; debug("Si4709_dev_sys_config3_set called"); mutex_lock(&(Si4709_dev.lock)); if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_sys_config3_set called " "when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_SEEK_TUNE_SNR_THRESHOLD, sys_conf3->sksnr); Si4709_dev.settings.curr_snr = sys_conf3->sksnr; if (ret < 0) { debug("Si4709_dev_sys_config3_set i2c_write 1 failed"); Si4709_dev.registers[SYSCONFIG3] = register_bak; } } mutex_unlock(&(Si4709_dev.lock)); return ret; }
int Si4709_dev_RDS_DISABLE(void) { int ret = 0; debug("Si4709_dev_RDS_DISABLE called"); mutex_lock(&(Si4709_dev.lock)); if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_RDS_DISABLE called when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_RDS_CONFIG, 0); if (ret < 0) debug("Si4709_dev_RDS_DISABLE i2c_write failed"); #ifdef RDS_INTERRUPT_ON_ALWAYS else Si4709_RDS_flag = NO_WAIT; #endif } mutex_unlock(&(Si4709_dev.lock)); return ret; }
int Si47xx_dev_STEREO_SET(void) { int ret = 0; debug("Si47xx_dev_STEREO_SET called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { debug("Si47xx_dev_STEREO_SET called when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_BLEND_MONO_THRESHOLD, 30); si47xx_set_property(FM_BLEND_STEREO_THRESHOLD, 49); } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si47xx_dev_DSMUTE_OFF(void) { int ret = 0; debug("Si47xx_dev_DSMUTE_OFF called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { debug("Si47xx_dev_DSMUTE_OFF called when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_SOFT_MUTE_RATE, 64); si47xx_set_property(FM_SOFT_MUTE_MAX_ATTENUATION, 16); si47xx_set_property(FM_SOFT_MUTE_SNR_THRESHOLD, 4); } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
/* Setting DE emphasis time constant 50us(Europe,Japan,Australia) or 75us(USA) */ int Si4709_dev_DE_set(u8 de_tc) { u16 sysconfig1 = 0; int ret = 0; debug("Si4709_dev_DE_set called"); mutex_lock(&(Si4709_dev.lock)); sysconfig1 = Si4709_dev.registers[SYSCONFIG1]; if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_DE_set called when DS is invalid"); ret = -1; } else { switch (de_tc) { case DE_TIME_CONSTANT_50: si47xx_set_property(FM_DEEMPHASIS, FM_DEEMPH_50US); break; case DE_TIME_CONSTANT_75: si47xx_set_property(FM_DEEMPHASIS, FM_DEEMPH_75US); break; default: ret = -1; } if (0 == ret) { if (ret < 0) debug("Si4709_dev_DE_set i2c_write failed"); } } mutex_unlock(&(Si4709_dev.lock)); return ret; }
int Si47xx_dev_MUTE_OFF(void) { int ret = 0; debug("Si47xx_dev_MUTE_OFF called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { debug("Si47xx_dev_MUTE_OFF called when DS is invalid"); ret = -1; } else { si47xx_set_property(RX_HARD_MUTE, 0); } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si47xx_dev_seek_SNR_th_set(u8 seek_SNR) { int ret = 0; debug("Si47xx_dev_seek_SNR_th_set called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { dev_err(Si47xx_dev->dev, "Si47xx_dev_seek_SNR_th_set called " "when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_SEEK_TUNE_SNR_THRESHOLD, seek_SNR); Si47xx_dev->settings.curr_snr = seek_SNR; } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si47xx_dev_RSSI_seek_th_set(u8 seek_th) { int ret = 0; debug("Si47xx_dev_RSSI_seek_th_set called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { debug("Si47xx_dev_RSSI_seek_th_set called " "when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_SEEK_TUNE_RSSI_THRESHOLD, seek_th); Si47xx_dev->settings.curr_rssi_th = seek_th; } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si47xx_dev_sys_config3_set(struct sys_config3 *sys_conf3) { int ret = 0; debug("Si47xx_dev_sys_config3_set called"); mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { dev_err(Si47xx_dev->dev, "Si47xx_dev_sys_config3_set called " "when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_SEEK_TUNE_SNR_THRESHOLD, sys_conf3->sksnr); Si47xx_dev->settings.curr_snr = sys_conf3->sksnr; } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si47xx_dev_volume_set(u8 volume) { int ret = 0; debug("Si47xx_dev_volume_set called"); if (volume >= SI47XX_VOLUME_NUM) return -EINVAL; mutex_lock(&(Si47xx_dev->lock)); if (Si47xx_dev->valid == eFALSE) { dev_err(Si47xx_dev->dev, "Si47xx_dev_volume_set called when DS is invalid"); ret = -1; } else { si47xx_set_property(RX_VOLUME, pSi47xxdata->rx_vol[volume] & RX_VOLUME_MASK); Si47xx_dev->vol_idx = volume; } mutex_unlock(&(Si47xx_dev->lock)); return ret; }
int Si4709_dev_seek_SNR_th_set(u8 seek_SNR) { int ret = 0; debug("Si4709_dev_seek_SNR_th_set called"); mutex_lock(&(Si4709_dev.lock)); if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_seek_SNR_th_set called " "when DS is invalid"); ret = -1; } else { si47xx_set_property(FM_SEEK_TUNE_SNR_THRESHOLD, seek_SNR); Si4709_dev.settings.curr_snr = seek_SNR; if (ret < 0) debug("Si4709_dev_seek_SNR_th_set i2c_write 1 failed"); } mutex_unlock(&(Si4709_dev.lock)); return ret; }
/*=================================================================== coSpkUpdate(): Update Speaker ===================================================================*/ void coSpkUpdate() { byte value; // left channel set to minimum value value = DEV_SPK_MSK_VOL; // case both left and right channel: init at minus infinitive // which considered as mute so turn on mute //if ((AppDevice.spk.preVol[DEV_SPK_LEFT_CN] < DEV_SPK_MIN_VOL) && // (AppDevice.spk.preVol[DEV_SPK_RIGHT_CN] < DEV_SPK_MIN_VOL)) // value |= SI471X_MUTE_ON; // left channel if (AppDevice.spk.preVol[DEV_SPK_LEFT_CN] > DEV_SPK_MIN_VOL) value = LSB((DEV_SPK_MAX_VOL_BOUND - AppDevice.spk.preVol[DEV_SPK_LEFT_CN])/DEV_SPK_RES_VOL) & DEV_SPK_MSK_VOL; //DeviationValueCounted = (DeviationValueThatSet * (DEV_SPK_MSK_VOL - value)) / DEV_SPK_MSK_VOL; DeviationValueCounted = DeviationValueThatSet - (DeviationValueThatSet/DEV_SPK_MSK_VOL)*value; if(FePoweredUp) si47xx_set_property(TX_AUDIO_DEVIATION, DeviationValueCounted); // case mute //if (AppDeviceSpkpreMute == TRUE) // value |= SI471X_MUTE_ON; //SET VALUE TO SI471X! //CPTDATH = value; // right channel set to minimum value value = 0x1F; if (AppDevice.spk.preVol[DEV_SPK_RIGHT_CN] > DEV_SPK_MIN_VOL) value = LSB((DEV_SPK_MAX_VOL_BOUND - AppDevice.spk.preVol[DEV_SPK_RIGHT_CN])/DEV_SPK_RES_VOL) & 0x1F; }
int Si4709_dev_band_set(int band) { int ret = 0; u16 sysconfig2 = 0; u16 prev_band = 0; u32 prev_bottom_of_band = 0; debug("Si4709_dev_band_set called"); prev_band = Si4709_dev.settings.band; prev_bottom_of_band = Si4709_dev.settings.bottom_of_band; if (Si4709_dev.valid == eFALSE) { debug("Si4709_dev_band_set called when DS is invalid"); ret = -1; } else { switch (band) { case BAND_87500_108000_kHz: si47xx_set_property(FM_SEEK_BAND_BOTTOM, 8750); si47xx_set_property(FM_SEEK_BAND_TOP, 10800); Si4709_dev.settings.band = BAND_87500_108000_kHz; Si4709_dev.settings.bottom_of_band = FREQ_87500_kHz; break; case BAND_76000_108000_kHz: si47xx_set_property(FM_SEEK_BAND_BOTTOM, 7600); si47xx_set_property(FM_SEEK_BAND_TOP, 10800); Si4709_dev.settings.band = BAND_76000_108000_kHz; Si4709_dev.settings.bottom_of_band = FREQ_76000_kHz; break; case BAND_76000_90000_kHz: si47xx_set_property(FM_SEEK_BAND_BOTTOM, 7600); si47xx_set_property(FM_SEEK_BAND_TOP, 9000); Si4709_dev.settings.band = BAND_76000_90000_kHz; Si4709_dev.settings.bottom_of_band = FREQ_76000_kHz; break; default: ret = -1; } } return ret; }
/*=================================================================== IEP3_HID(): Prepare Data to send from SI4711 to PC through IEP3 HID ===================================================================*/ void HID_ACCESS() { #ifdef _HID_ if ( (PCCommand == PCTransfer) && !(PCRequest&RequestDone) ) { switch (PCRequest) { case(RequestSi4711Reset): //bReportOut: // +-----------+-----------+ // | PCCommand | PCRequest | // +-----------+-----------+ si47xxReset(); break; case(RequestCpuId): // +-----------+-----------+--------------+----------+-------------+----------+---------------+ // | PCCommand | PCRequest | REV_MINOR[2] | STR_SIZE | REV_MAJOR[] | STR_SIZE | DEVICE_NAME[] | // +-----------+-----------+--------------+----------+-------------+----------+---------------+ Xdata.InEp3.HidReport.bReportItem[2] = (0xFF00 & REVISION_MAJOR) >> 8; Xdata.InEp3.HidReport.bReportItem[3] = 0x00FF & REVISION_MAJOR; Xdata.InEp3.HidReport.bReportItem[4] = sizeof(REVISION_MINOR); AppDevice.dummy.bData[0] = 0; for(AppDevice.dummy.bData[0] = 0; AppDevice.dummy.bData[0] < sizeof(REVISION_MINOR); AppDevice.dummy.bData[0]++) Xdata.InEp3.HidReport.bReportItem[5 + AppDevice.dummy.bData[0]] = REVISION_MINOR[AppDevice.dummy.bData[0]]; Xdata.InEp3.HidReport.bReportItem[5 + AppDevice.dummy.bData[0]] = sizeof(DEVICE_NAME); AppDevice.dummy.bData[1] = AppDevice.dummy.bData[0] + 5 + 1; for(AppDevice.dummy.bData[0] = 0; AppDevice.dummy.bData[0] < sizeof(DEVICE_NAME); AppDevice.dummy.bData[0]++) Xdata.InEp3.HidReport.bReportItem[AppDevice.dummy.bData[1] + AppDevice.dummy.bData[0]] = DEVICE_NAME[AppDevice.dummy.bData[0]]; break; case(RequestSi4711PowerStatus): // +-----------+-----------+-------------+----------------+ // | PCCommand | PCRequest | IsPoweredUp | IsTransmitting | // +-----------+-----------+-------------+----------------+ Xdata.InEp3.HidReport.bReportItem[2] = FePoweredUp; Xdata.InEp3.HidReport.bReportItem[3] = TxPoweredUp; break; case(RequestSi4711PowerUp): if(FePoweredUp) { PCCommand |= PCRequestError; break; } else { FePoweredUp=TRUE; } //bReportOut: // +-----------+-----------+---------+-----------+ // | PCCommand | PCRequest | IsError | ErrorCode | // +-----------+-----------+---------+-----------+ buff_ret = SI4711_COMM_ERR; Xdata.InEp3.HidReport.bReportItem[3] = 1; si47xxPowerUp(); if(!(buff_response[0] & CTS)) { Xdata.InEp3.HidReport.bReportItem[2] = buff_ret; break; } buff_ret = SI4711_COMM_ERR; Xdata.InEp3.HidReport.bReportItem[3] = 2; si47xxFMTX_hardware_cfg(); Xdata.InEp3.HidReport.bReportItem[2] = buff_ret; FELed = LED_ON; break; case(RequestSi4711PowerDown): if(!FePoweredUp) { PCCommand |= PCRequestError; break; } //bReportOut: // +-----------+-----------+---------+-----------+ // | PCCommand | PCRequest | IsError | ErrorCode | // +-----------+-----------+---------+-----------+ buff_ret = SI4711_COMM_ERR; si47xxPowerDown(); if(buff_ret != SI4711_OK || !(buff_response[0] & CTS)) { Xdata.InEp3.HidReport.bReportItem[2] = buff_ret; si47xxReset(); //force! } break; case(RequestSi4711AudioEnable): if(!FePoweredUp) { PCCommand |= PCRequestError; break; } buff_ret = SI4711_COMM_ERR; si47xxSetAudio(TRUE); Xdata.InEp3.HidReport.bReportItem[2] = buff_ret; break; case(RequestSi4711AudioDisable): if(!FePoweredUp) { PCCommand |= PCRequestError; break; } buff_ret = SI4711_COMM_ERR; si47xxSetAudio(FALSE); Xdata.InEp3.HidReport.bReportItem[2] = buff_ret; break; case(RequestEepromSectionRead): //bReportOut: // +-----------+-----------+---------+-------+ // | PCCommand | PCRequest | Offset | bytes | // +-----------+-----------+---------+-------+ if(Xdata.OutEp4.HidOReport.bReportOut[4] > 32) { PCCommand |= PCRequestError; break; } AppDevice.dummy.wData[0] = MAKE_WORD(Xdata.OutEp4.HidOReport.bReportOut[2], Xdata.OutEp4.HidOReport.bReportOut[3]); if(AppDevice.dummy.wData[0] + Xdata.OutEp4.HidOReport.bReportOut[4] > 0x2000) { PCCommand |= PCRequestError; break; } i2cFlag = I2C_READ | I2C_START | I2C_STOP | I2C_WORD_ADDR_TYPE; SET_I2C(EEPROM_I2C_ADDR, AppDevice.dummy.wData[0], &Xdata.InEp3.HidReport.bReportItem[3], Xdata.OutEp4.HidOReport.bReportOut[4], i2cFlag); Xdata.InEp3.HidReport.bReportItem[2] = devRomFunction(ROM_I2C_ACCESS); //bReportItem: // +-----------+-----------+--------+---------+- ... -+---------+ // | PCCommand | PCRequest | status | data[0] | ... | data[n] | // +-----------+-----------+--------+---------+- ... -+---------+ break; case(RequestEepromSectionWrite): //bReportOut: // +-----------+-----------+---------+-------+---------+- ... -+---------+ // | PCCommand | PCRequest | Offset | bytes | data[0] | ... | data[n] | // +-----------+-----------+---------+-------+---------+- ... -+---------+ if(Xdata.OutEp4.HidOReport.bReportOut[4] > 32) { PCCommand |= PCRequestError; break; } AppDevice.dummy.wData[0] = MAKE_WORD(Xdata.OutEp4.HidOReport.bReportOut[2], Xdata.OutEp4.HidOReport.bReportOut[3]); if(AppDevice.dummy.wData[0] + Xdata.OutEp4.HidOReport.bReportOut[4] > 0x2000) { PCCommand |= PCRequestError; break; } i2cFlag = I2C_WRITE | I2C_START | I2C_STOP | I2C_WORD_ADDR_TYPE; SET_I2C(EEPROM_I2C_ADDR, AppDevice.dummy.wData[0], &Xdata.OutEp4.HidOReport.bReportOut[5], Xdata.OutEp4.HidOReport.bReportOut[4], i2cFlag); Xdata.InEp3.HidReport.bReportItem[2] = devRomFunction(ROM_I2C_ACCESS); //bReportItem: // +-----------+-----------+--------+ // | PCCommand | PCRequest | status | // +-----------+-----------+--------+ break; case(RequestSi4711SetProp): if(!FePoweredUp) { PCCommand |= PCRequestError; break; } //bReportOut: // +-----------+-----------+---------+ // | PCCommand | PCRequest | IsError | // +-----------+-----------+---------+ //reversal order here AppDevice.dummy.wData[0] = MAKE_WORD(Xdata.OutEp4.HidOReport.bReportOut[2], Xdata.OutEp4.HidOReport.bReportOut[3]); //must set other way if(AppDevice.dummy.wData[0] == REFCLK_PRESCALE || AppDevice.dummy.wData[0] == REFCLK_FREQ || AppDevice.dummy.wData[0] == DIGITAL_INPUT_FORMAT || AppDevice.dummy.wData[0] == DIGITAL_INPUT_SAMPLE_RATE || AppDevice.dummy.wData[0] == GPO_IEN) { Xdata.InEp3.HidReport.bReportItem[2] = SI4711_BAD_ARG; PCCommand |= PCRequestError; break; } AppDevice.dummy.wData[1] = MAKE_WORD(Xdata.OutEp4.HidOReport.bReportOut[4], Xdata.OutEp4.HidOReport.bReportOut[5]); buff_ret = SI4711_COMM_ERR; Xdata.InEp3.HidReport.bReportItem[6] = si47xx_set_property(AppDevice.dummy.wData[0], AppDevice.dummy.wData[1]); Xdata.InEp3.HidReport.bReportItem[7] = buff_response[0]; Xdata.InEp3.HidReport.bReportItem[8] = buff_ret; Xdata.InEp3.HidReport.bReportItem[2] = Xdata.OutEp4.HidOReport.bReportOut[2]; Xdata.InEp3.HidReport.bReportItem[3] = Xdata.OutEp4.HidOReport.bReportOut[3]; Xdata.InEp3.HidReport.bReportItem[4] = Xdata.OutEp4.HidOReport.bReportOut[4]; Xdata.InEp3.HidReport.bReportItem[5] = Xdata.OutEp4.HidOReport.bReportOut[5]; // hack for set volume if(AppDevice.dummy.wData[0] == TX_AUDIO_DEVIATION) { DeviationValueThatSet = AppDevice.dummy.wData[1]; coSpkUpdate(); } //bReportOut: // +-----------+-----------+---------+------------+------+------+ // | PCCommand | PCRequest | IsError | IsErrorGet | ValH | ValL | // +-----------+-----------+---------+------------+------+------+ #ifndef _PROP_RECHECK_ //re-check out property! AppDevice.dummy.wData[1] = 0; break; #endif case(RequestSi4711GetProp): if(!FePoweredUp) { PCCommand |= PCRequestError; break; } //bReportOut: // +-----------+-----------+---------+ // | PCCommand | PCRequest | IsError | // +-----------+-----------+---------+ AppDevice.dummy.wData[0] = MAKE_WORD(Xdata.OutEp4.HidOReport.bReportOut[2], Xdata.OutEp4.HidOReport.bReportOut[3]); AppDevice.dummy.wData[1] = 0; buff_ret = SI4711_COMM_ERR; Xdata.InEp3.HidReport.bReportItem[6] = si47xx_get_property(AppDevice.dummy.wData[0], &AppDevice.dummy.wData[1]); Xdata.InEp3.HidReport.bReportItem[7] = buff_response[0]; Xdata.InEp3.HidReport.bReportItem[8] = buff_ret; Xdata.InEp3.HidReport.bReportItem[2] = Xdata.OutEp4.HidOReport.bReportOut[2]; Xdata.InEp3.HidReport.bReportItem[3] = Xdata.OutEp4.HidOReport.bReportOut[3]; Xdata.InEp3.HidReport.bReportItem[4] = MSB(AppDevice.dummy.wData[1]); Xdata.InEp3.HidReport.bReportItem[5] = LSB(AppDevice.dummy.wData[1]); break; case(RequestSi4711Access): if(!FePoweredUp) { PCCommand |= PCRequestError; break; } Xdata.InEp3.HidReport.bReportItem[2] = 0; Xdata.InEp3.HidReport.bReportItem[3] = 0; Xdata.InEp3.HidReport.bReportItem[4] = 0; if(Xdata.OutEp4.HidOReport.bReportOut[2] < 1) { PCCommand |= PCRequestError; Xdata.InEp3.HidReport.bReportItem[2] = FALSE; Xdata.InEp3.HidReport.bReportItem[3] = SI4711_BAD_ARG; break; } //bReportOut: // +-----------+-----------+---------+---------+--------+- ... -+--------+ // | PCCommand | PCRequest | ArgsLen | Command | Arg[1] | ... | Arg[7] | // +-----------+-----------+---------+---------+--------+- ... -+--------+ //bReportItem: // +-----------+-----------+-------------+------------+---------+---------+---------+ ... -+----------+ // | PCCommand | PCRequest | WriteStatus | ReadStatus | RespLen | Status | Resp[1] | ... | Resp[15] | // +-----------+-----------+-------------+------------+---------+---------+---------+ ... -+----------+ //do it other way! if(Xdata.OutEp4.HidOReport.bReportOut[3] == POWER_UP || Xdata.OutEp4.HidOReport.bReportOut[3] == POWER_DOWN || Xdata.OutEp4.HidOReport.bReportOut[3] == TX_ASQ_STATUS || Xdata.OutEp4.HidOReport.bReportOut[3] == TX_TUNE_STATUS || Xdata.OutEp4.HidOReport.bReportOut[3] == SET_PROPERTY || Xdata.OutEp4.HidOReport.bReportOut[3] == GET_PROPERTY ) { Xdata.InEp3.HidReport.bReportItem[2] = FALSE; Xdata.InEp3.HidReport.bReportItem[3] = SI4711_BAD_ARG; break; } /* Write command */ Xdata.InEp3.HidReport.bReportItem[4] = 16; // RespLen buff_ret = SI4711_COMM_ERR; Xdata.InEp3.HidReport.bReportItem[2] = si47xx_command(Xdata.OutEp4.HidOReport.bReportOut[2], &Xdata.OutEp4.HidOReport.bReportOut[3], Xdata.InEp3.HidReport.bReportItem[4], &Xdata.InEp3.HidReport.bReportItem[5]); Xdata.InEp3.HidReport.bReportItem[3] = buff_ret; /* Set specific delay, depends on what command sent. */ if(Xdata.OutEp4.HidOReport.bReportOut[3] == TX_TUNE_POWER) { if(Xdata.OutEp4.HidOReport.bReportOut[6] >= 88) { TxPoweredUp = TRUE; } else { // TXLed = LED_OFF; TxPoweredUp = FALSE; ASQLOWLed = LED_OFF; ASQHILed = LED_OFF; ASQOVRMLed = LED_OFF; } } Xdata.InEp3.HidReport.bReportItem[21] = AppDevice.spk.preVol[DEV_SPK_LEFT_CN]; Xdata.InEp3.HidReport.bReportItem[22] = AppDevice.spk.preVol[DEV_SPK_RIGHT_CN]; Xdata.InEp3.HidReport.bReportItem[23] = MSB(DeviationValueCounted); Xdata.InEp3.HidReport.bReportItem[24] = LSB(DeviationValueCounted); break; case(RequestSi4711AsqStatus): if(!FePoweredUp || !TxPoweredUp) { PCCommand |= PCRequestError; break; } //bReportOut: // +-----------+-----------+---------+---------+------+------+-------+ // | PCCommand | PCRequest | IsError | overmod | iall | ialh | level | // +-----------+-----------+---------+---------+------+------+-------+ Xdata.InEp3.HidReport.bReportItem[2] = 0x00; Xdata.InEp3.HidReport.bReportItem[3] = asq_overmod; Xdata.InEp3.HidReport.bReportItem[4] = asq_iall; Xdata.InEp3.HidReport.bReportItem[5] = asq_ialh; Xdata.InEp3.HidReport.bReportItem[6] = asq_level; break; case(RequestSi4711TuneStatus): if(!FePoweredUp) { PCCommand |= PCRequestError; break; } //bReportOut: // +-----------+-----------+---------+---------+---------+-------+--------+-----+ // | PCCommand | PCRequest | IsError | FREQ[m] | FREQ[l] | power | antcap | rnl | // +-----------+-----------+---------+---------+---------+-------+--------+-----+ Xdata.InEp3.HidReport.bReportItem[2] = 0x00; Xdata.InEp3.HidReport.bReportItem[3] = MSB(TxFreq); Xdata.InEp3.HidReport.bReportItem[4] = LSB(TxFreq); Xdata.InEp3.HidReport.bReportItem[5] = TxPower; Xdata.InEp3.HidReport.bReportItem[6] = TxAntCap; Xdata.InEp3.HidReport.bReportItem[7] = TxRnl; break; default: PCCommand |= PCRequestError; break; } // send data to PC through USP HID PCRequest |= RequestDone; Xdata.InEp3.HidReport.bReportItem[0] = PCCommand; Xdata.InEp3.HidReport.bReportItem[1] = PCRequest; while (!(IEPDCNTX3&0x80)); IEPDCNTX3 = sizeof(Xdata.InEp3.HidReport); } #endif }
int Si47xx_dev_powerup(void) { int ret = 0; u32 value = 100; debug("Si47xx_dev_powerup called"); if (!(RADIO_ON == Si47xx_dev->state.power_state)) { ret = powerup(); if (ret < 0) { dev_err(Si47xx_dev->dev, "%s failed %d\n", __func__, ret); } else if (Si47xx_dev->valid_client_state == eFALSE) { dev_err(Si47xx_dev->dev, "Si47xx_dev_powerup called " "when DS(state, client) is invalid"); ret = -1; } else { /* initial settings */ #ifdef CONFIG_RADIO_USE_MI2S si47xx_set_property(DIGITAL_OUTPUT_SAMPLE_RATE, 0xBB80); //44100 si47xx_set_property(DIGITAL_OUTPUT_FORMAT, 0x0000); //I2S, 16bit, Riging edge #endif #ifdef _ENABLE_RDS_ si47xx_set_property(FM_RDS_CONFIG, 1); si47xx_set_property(GPO_IEN, GPO_IEN_STCIEN_MASK | GPO_IEN_STCREP_MASK); si47xx_set_property(GPO_IEN, GPO_IEN_STCIEN_MASK | GPO_IEN_RDSIEN_MASK | GPO_IEN_STCREP_MASK); si47xx_set_property(FM_RDS_INTERRUPT_SOURCE, FM_RDS_INTERRUPT_SOURCE_RECV_MASK); si47xx_set_property(FM_RDS_CONFIG, FM_RDS_CONFIG_RDSEN_MASK | (3 << FM_RDS_CONFIG_BLETHA_SHFT) | (3 << FM_RDS_CONFIG_BLETHB_SHFT) | (3 << FM_RDS_CONFIG_BLETHC_SHFT) | (3 << FM_RDS_CONFIG_BLETHD_SHFT)); #endif /*VNVS:18-NOV'09 : Setting DE-Time Constant as 50us(Europe,Japan,Australia)*/ si47xx_set_property(FM_DEEMPHASIS, FM_DEEMPH_50US); /* SYSCONFIG2_BITSET_SEEKTH( */ /* &Si47xx_dev->registers[SYSCONFIG2],2); */ /*VNVS:18-NOV'09 : modified for detecting more stations of good quality*/ si47xx_set_property(FM_SEEK_TUNE_RSSI_THRESHOLD, TUNE_RSSI_THRESHOLD); si47xx_set_property(FM_SEEK_BAND_BOTTOM, 8750); si47xx_set_property(FM_SEEK_BAND_TOP, 10800); Si47xx_dev->settings.band = BAND_87500_108000_kHz; Si47xx_dev->settings.bottom_of_band = FREQ_87500_kHz; si47xx_set_property(FM_SEEK_FREQ_SPACING, CHAN_SPACING_100_kHz); Si47xx_dev->settings.channel_spacing = CHAN_SPACING_100_kHz; /* SYSCONFIG3_BITSET_SKSNR( */ /* &Si47xx_dev->registers[SYSCONFIG3],3); */ /*VNVS:18-NOV'09 : modified for detecting more stations of good quality*/ si47xx_set_property(FM_SEEK_TUNE_SNR_THRESHOLD, TUNE_SNR_THRESHOLD); Si47xx_dev->settings.timeout_RDS = msecs_to_jiffies(value); Si47xx_dev->settings.curr_snr = TUNE_SNR_THRESHOLD; Si47xx_dev->settings.curr_rssi_th = TUNE_RSSI_THRESHOLD; Si47xx_dev->valid = eTRUE; Si47xx_dev_STEREO_SET(); #ifdef RDS_INTERRUPT_ON_ALWAYS /*Initialising read and write indices */ RDS_Buffer_Index_read = 0; RDS_Buffer_Index_write = 0; RDS_Data_Available = 0; RDS_Data_Lost = 0; RDS_Groups_Available_till_now = 0; #endif } } else debug("Device already Powered-ON"); ret = request_irq(si47xx_irq, Si47xx_isr, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, "Si47xx", NULL); si47xx_set_property(0xff00, 0); /* tune initial frequency to remove tunestatus func err * sometimes occur tunestatus func err when execute tunestatus function * before to complete tune_freq. * so run tune_freq just after to complete booting sequence*/ ret = tune_freq(Si47xx_dev->settings.bottom_of_band); return ret; }
int Si4709_dev_powerup(void) { int ret = 0; u32 value = 100; debug("Si4709_dev_powerup called"); if (!(RADIO_ON == Si4709_dev.state.power_state)) { ret = powerup(); if (ret < 0) { debug("powerup failed"); } else if (Si4709_dev.valid_client_state == eFALSE) { debug("Si4709_dev_powerup called " "when DS(state, client) is invalid"); ret = -1; } else { /* initial settings */ #ifdef _ENABLE_RDS_ si47xx_set_property(FM_RDS_CONFIG, 1); si47xx_set_property(GPO_IEN, GPO_IEN_STCIEN_MASK | GPO_IEN_STCREP_MASK); si47xx_set_property(GPO_IEN, GPO_IEN_STCIEN_MASK | GPO_IEN_RDSIEN_MASK | GPO_IEN_STCREP_MASK); si47xx_set_property(FM_RDS_INTERRUPT_SOURCE, FM_RDS_INTERRUPT_SOURCE_RECV_MASK); si47xx_set_property(FM_RDS_CONFIG, FM_RDS_CONFIG_RDSEN_MASK | (3 << FM_RDS_CONFIG_BLETHA_SHFT) | (3 << FM_RDS_CONFIG_BLETHB_SHFT) | (3 << FM_RDS_CONFIG_BLETHC_SHFT) | (3 << FM_RDS_CONFIG_BLETHD_SHFT)); #endif /*VNVS:18-NOV'09 : Setting DE-Time Constant as 50us(Europe,Japan,Australia)*/ si47xx_set_property(FM_DEEMPHASIS, FM_DEEMPH_50US); /* SYSCONFIG2_BITSET_SEEKTH( */ /* &Si4709_dev.registers[SYSCONFIG2],2); */ /*VNVS:18-NOV'09 : modified for detecting more stations of good quality*/ si47xx_set_property(FM_SEEK_TUNE_RSSI_THRESHOLD, TUNE_RSSI_THRESHOLD); si47xx_set_property(FM_SEEK_BAND_BOTTOM, 8750); si47xx_set_property(FM_SEEK_BAND_TOP, 10800); Si4709_dev.settings.band = BAND_87500_108000_kHz; Si4709_dev.settings.bottom_of_band = FREQ_87500_kHz; si47xx_set_property(FM_SEEK_FREQ_SPACING, CHAN_SPACING_100_kHz); Si4709_dev.settings.channel_spacing = CHAN_SPACING_100_kHz; /* SYSCONFIG3_BITSET_SKSNR( */ /* &Si4709_dev.registers[SYSCONFIG3],3); */ /*VNVS:18-NOV'09 : modified for detecting more stations of good quality*/ si47xx_set_property(FM_SEEK_TUNE_SNR_THRESHOLD, TUNE_SNR_THRESHOLD); Si4709_dev.settings.timeout_RDS = msecs_to_jiffies(value); Si4709_dev.settings.curr_snr = TUNE_SNR_THRESHOLD; Si4709_dev.settings.curr_rssi_th = TUNE_RSSI_THRESHOLD; Si4709_dev_STEREO_SET(); /*this will write all the above registers */ if (ret < 0) debug("Si4709_dev_powerup i2c_write 1 failed"); else { Si4709_dev.valid = eTRUE; #ifdef RDS_INTERRUPT_ON_ALWAYS /*Initialising read and write indices */ RDS_Buffer_Index_read = 0; RDS_Buffer_Index_write = 0; RDS_Data_Available = 0; RDS_Data_Lost = 0; RDS_Groups_Available_till_now = 0; #endif } } } else debug("Device already Powered-ON"); enable_irq(Si4709_dev_irq); si47xx_set_property(0xff00, 0); return ret; }