aboutsummaryrefslogtreecommitdiffstats
path: root/src/tuner_e4k.c
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2013-11-04 21:53:41 +0100
committerSteve Markgraf <steve@steve-m.de>2013-11-04 21:53:41 +0100
commit015c78a4ca21a26c2b20e070c482918a08bacc06 (patch)
tree3268be77aebcd49a35633018a0f0e97a95c2df1a /src/tuner_e4k.c
parentaefd8b7d58c4735b19110b5f54de289e8dd931f5 (diff)
remove e4k-specific I2C functions from library
Signed-off-by: Steve Markgraf <steve@steve-m.de>
Diffstat (limited to 'src/tuner_e4k.c')
-rw-r--r--src/tuner_e4k.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/tuner_e4k.c b/src/tuner_e4k.c
index 47fe4fe..aff5534 100644
--- a/src/tuner_e4k.c
+++ b/src/tuner_e4k.c
@@ -29,6 +29,7 @@
#include <reg_field.h>
#include <tuner_e4k.h>
+#include <rtlsdr_i2c.h>
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
@@ -55,17 +56,19 @@ static const uint8_t width2mask[] = {
/***********************************************************************
* Register Access */
-#if 0
/*! \brief Write a register of the tuner chip
* \param[in] e4k reference to the tuner
* \param[in] reg number of the register
* \param[in] val value to be written
* \returns 0 on success, negative in case of error
*/
-int e4k_reg_write(struct e4k_state *e4k, uint8_t reg, uint8_t val)
+static int e4k_reg_write(struct e4k_state *e4k, uint8_t reg, uint8_t val)
{
- /* FIXME */
- return 0;
+ uint8_t data[2];
+ data[0] = reg;
+ data[1] = val;
+
+ return rtlsdr_i2c_write_fn(e4k->rtl_dev, e4k->i2c_addr, data, 2);
}
/*! \brief Read a register of the tuner chip
@@ -73,12 +76,18 @@ int e4k_reg_write(struct e4k_state *e4k, uint8_t reg, uint8_t val)
* \param[in] reg number of the register
* \returns positive 8bit register contents on success, negative in case of error
*/
-int e4k_reg_read(struct e4k_state *e4k, uint8_t reg)
+static int e4k_reg_read(struct e4k_state *e4k, uint8_t reg)
{
- /* FIXME */
- return 0;
+ uint8_t data = reg;
+
+ if (rtlsdr_i2c_write_fn(e4k->rtl_dev, e4k->i2c_addr, &data, 1) < 1)
+ return -1;
+
+ if (rtlsdr_i2c_read_fn(e4k->rtl_dev, e4k->i2c_addr, &data, 1) < 1)
+ return -1;
+
+ return data;
}
-#endif
/*! \brief Set or clear some (masked) bits inside a register
* \param[in] e4k reference to the tuner