mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-12-24 18:08:27 +01:00
lib: enable standby mode of e4k and r820t on exit
Since the R820T is a power hog and gets quite hot, this makes sense, especially when being battery- powered. Signed-off-by: Steve Markgraf <steve@steve-m.de>
This commit is contained in:
parent
3087e7acde
commit
84f0a9084b
@ -199,6 +199,7 @@ struct e4k_state {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int e4k_init(struct e4k_state *e4k);
|
int e4k_init(struct e4k_state *e4k);
|
||||||
|
int e4k_standby(struct e4k_state *e4k, int enable);
|
||||||
int e4k_if_gain_set(struct e4k_state *e4k, uint8_t stage, int8_t value);
|
int e4k_if_gain_set(struct e4k_state *e4k, uint8_t stage, int8_t value);
|
||||||
int e4k_mixer_gain_set(struct e4k_state *e4k, int8_t value);
|
int e4k_mixer_gain_set(struct e4k_state *e4k, int8_t value);
|
||||||
int e4k_commonmode_set(struct e4k_state *e4k, int8_t value);
|
int e4k_commonmode_set(struct e4k_state *e4k, int8_t value);
|
||||||
|
@ -101,7 +101,10 @@ int e4000_init(void *dev) {
|
|||||||
devt->e4k_s.rtl_dev = dev;
|
devt->e4k_s.rtl_dev = dev;
|
||||||
return e4k_init(&devt->e4k_s);
|
return e4k_init(&devt->e4k_s);
|
||||||
}
|
}
|
||||||
int e4000_exit(void *dev) { return 0; }
|
int e4000_exit(void *dev) {
|
||||||
|
rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev;
|
||||||
|
return e4k_standby(&devt->e4k_s, 1);
|
||||||
|
}
|
||||||
int e4000_set_freq(void *dev, uint32_t freq) {
|
int e4000_set_freq(void *dev, uint32_t freq) {
|
||||||
rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev;
|
rtlsdr_dev_t* devt = (rtlsdr_dev_t*)dev;
|
||||||
return e4k_tune_freq(&devt->e4k_s, freq);
|
return e4k_tune_freq(&devt->e4k_s, freq);
|
||||||
@ -177,7 +180,7 @@ int r820t_init(void *dev) {
|
|||||||
r820t_SetStandardMode(dev, DVB_T_6M);
|
r820t_SetStandardMode(dev, DVB_T_6M);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
int r820t_exit(void *dev) { return 0; }
|
int r820t_exit(void *dev) { return r820t_SetStandby(dev, 0); }
|
||||||
int r820t_set_freq(void *dev, uint32_t freq) { return r820t_SetRfFreqHz(dev, freq); }
|
int r820t_set_freq(void *dev, uint32_t freq) { return r820t_SetRfFreqHz(dev, freq); }
|
||||||
int r820t_set_bw(void *dev, int bw) { return 0; }
|
int r820t_set_bw(void *dev, int bw) { return 0; }
|
||||||
int r820t_set_gain(void *dev, int gain) { return R828_SetRfGain(dev, gain); }
|
int r820t_set_gain(void *dev, int gain) { return R828_SetRfGain(dev, gain); }
|
||||||
@ -360,7 +363,8 @@ uint8_t rtlsdr_i2c_read_reg(rtlsdr_dev_t *dev, uint8_t i2c_addr, uint8_t reg)
|
|||||||
/* TODO clean this up again */
|
/* TODO clean this up again */
|
||||||
int e4k_reg_write(struct e4k_state *e4k, uint8_t reg, uint8_t val)
|
int e4k_reg_write(struct e4k_state *e4k, uint8_t reg, uint8_t val)
|
||||||
{
|
{
|
||||||
return rtlsdr_i2c_write_reg((rtlsdr_dev_t*)e4k->rtl_dev, e4k->i2c_addr, reg, val);}
|
return rtlsdr_i2c_write_reg((rtlsdr_dev_t*)e4k->rtl_dev, e4k->i2c_addr, reg, val);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t e4k_reg_read(struct e4k_state *e4k, uint8_t reg)
|
uint8_t e4k_reg_read(struct e4k_state *e4k, uint8_t reg)
|
||||||
{
|
{
|
||||||
|
@ -880,6 +880,19 @@ int e4k_dc_offset_gen_table(struct e4k_state *e4k)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* Standby */
|
||||||
|
|
||||||
|
/*! \brief Enable/disable standby mode
|
||||||
|
*/
|
||||||
|
int e4k_standby(struct e4k_state *e4k, int enable)
|
||||||
|
{
|
||||||
|
e4k_reg_set_mask(e4k, E4K_REG_MASTER1, E4K_MASTER1_NORM_STBY,
|
||||||
|
enable ? 0 : E4K_MASTER1_NORM_STBY);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Initialization */
|
* Initialization */
|
||||||
|
|
||||||
|
@ -2896,7 +2896,7 @@ R828_ErrCode R828_Standby(void *pTuner, R828_LoopThrough_Type R828_LoopSwitch)
|
|||||||
return RT_Fail;
|
return RT_Fail;
|
||||||
|
|
||||||
R828_I2C.RegAddr = 0x0F;
|
R828_I2C.RegAddr = 0x0F;
|
||||||
R828_I2C.Data = 0x78;
|
R828_I2C.Data = 0x68; /* was 0x78, which turns off CLK_Out */
|
||||||
if(I2C_Write(pTuner, &R828_I2C) != RT_Success)
|
if(I2C_Write(pTuner, &R828_I2C) != RT_Success)
|
||||||
return RT_Fail;
|
return RT_Fail;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user