[PATCH 1/8] media: adv748x: add a device-specific wrapper for register block read

Alex Riesen
2020-01-13T14:15:21Z

Some of the devices I2C-accessible registers (for instance, cs_data for
stereo channel information or tmds_params for TMDS channel information)
located in adjacent cells. According to manufacturers information, these
registers can be read using block transactions.

Signed-off-by: Alexander Riesen <alexander.riesen@cetitec.com>
---
drivers/media/i2c/adv748x/adv748x-core.c | 15 +++++++++++++++
drivers/media/i2c/adv748x/adv748x.h | 2 ++
2 files changed, 17 insertions(+)

diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 23e02ff27b17..bc49aa93793c 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -97,6 +97,21 @@ static const struct adv748x_register_map adv748x_default_addresses[] = {
[ADV748X_PAGE_TXA] = { "txa", 0x4a },
};

+int adv748x_read_block(struct adv748x_state *state, u8 client_page, u8 reg,
+ void *val, size_t reg_count)
+{
+ struct i2c_client *client = state->i2c_clients[client_page];
+ int err;
+
+ err = regmap_bulk_read(state->regmap[client_page], reg, val, reg_count);
+ if (err) {
+ adv_err(state, "error reading %02x, %02x-%02lx: %d\n",
+ client->addr, reg, reg + reg_count - 1, err);
+ return err;
+ }
+ return 0;
+}
+
static int adv748x_read_check(struct adv748x_state *state,
int client_page, u8 reg)
{
diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
index 5042f9e94aee..db6346a06351 100644
--- a/drivers/media/i2c/adv748x/adv748x.h
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -387,6 +387,8 @@ struct adv748x_state {
/* Register handling */

int adv748x_read(struct adv748x_state *state, u8 addr, u8 reg);
+int adv748x_read_block(struct adv748x_state *state, u8 page, u8 reg,
+ void *val, size_t reg_count);
int adv748x_write(struct adv748x_state *state, u8 page, u8 reg, u8 value);
int adv748x_write_block(struct adv748x_state *state, int client_page,
unsigned int init_reg, const void *val,
--
2.24.1.508.g91d2dafee0