mirror of https://gitee.com/openkylin/linux.git
media: ccs: Use static data read-only registers
Access read-only registers from CCS static data. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
2538d32210
commit
1b398012ce
|
@ -198,11 +198,67 @@ static int __ccs_read_addr(struct ccs_sensor *sensor, u32 reg, u32 *val,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int __ccs_read_data(struct ccs_reg *regs, size_t num_regs,
|
||||
u32 reg, u32 *val)
|
||||
{
|
||||
unsigned int width = ccs_reg_width(reg);
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < num_regs; i++, regs++) {
|
||||
uint8_t *data;
|
||||
|
||||
if (regs->addr + regs->len < CCS_REG_ADDR(reg) + width)
|
||||
continue;
|
||||
|
||||
if (regs->addr > CCS_REG_ADDR(reg))
|
||||
break;
|
||||
|
||||
data = ®s->value[CCS_REG_ADDR(reg) - regs->addr];
|
||||
|
||||
switch (width) {
|
||||
case sizeof(uint8_t):
|
||||
*val = *data;
|
||||
break;
|
||||
case sizeof(uint16_t):
|
||||
*val = get_unaligned_be16(data);
|
||||
break;
|
||||
case sizeof(uint32_t):
|
||||
*val = get_unaligned_be32(data);
|
||||
break;
|
||||
default:
|
||||
WARN_ON(1);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int ccs_read_data(struct ccs_sensor *sensor, u32 reg, u32 *val)
|
||||
{
|
||||
if (!__ccs_read_data(sensor->sdata.sensor_read_only_regs,
|
||||
sensor->sdata.num_sensor_read_only_regs,
|
||||
reg, val))
|
||||
return 0;
|
||||
|
||||
return __ccs_read_data(sensor->mdata.module_read_only_regs,
|
||||
sensor->mdata.num_module_read_only_regs,
|
||||
reg, val);
|
||||
}
|
||||
|
||||
static int ccs_read_addr_raw(struct ccs_sensor *sensor, u32 reg, u32 *val,
|
||||
bool force8, bool quirk, bool conv)
|
||||
bool force8, bool quirk, bool conv, bool data)
|
||||
{
|
||||
int rval;
|
||||
|
||||
if (data) {
|
||||
rval = ccs_read_data(sensor, reg, val);
|
||||
if (!rval)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (quirk) {
|
||||
*val = 0;
|
||||
rval = ccs_call_quirk(sensor, reg_access, false, ®, val);
|
||||
|
@ -223,17 +279,17 @@ static int ccs_read_addr_raw(struct ccs_sensor *sensor, u32 reg, u32 *val,
|
|||
|
||||
int ccs_read_addr(struct ccs_sensor *sensor, u32 reg, u32 *val)
|
||||
{
|
||||
return ccs_read_addr_raw(sensor, reg, val, false, true, true);
|
||||
return ccs_read_addr_raw(sensor, reg, val, false, true, true, true);
|
||||
}
|
||||
|
||||
int ccs_read_addr_8only(struct ccs_sensor *sensor, u32 reg, u32 *val)
|
||||
{
|
||||
return ccs_read_addr_raw(sensor, reg, val, true, true, true);
|
||||
return ccs_read_addr_raw(sensor, reg, val, true, true, true, true);
|
||||
}
|
||||
|
||||
int ccs_read_addr_noconv(struct ccs_sensor *sensor, u32 reg, u32 *val)
|
||||
{
|
||||
return ccs_read_addr_raw(sensor, reg, val, false, true, false);
|
||||
return ccs_read_addr_raw(sensor, reg, val, false, true, false, true);
|
||||
}
|
||||
|
||||
static int ccs_write_retry(struct i2c_client *client, struct i2c_msg *msg)
|
||||
|
|
Loading…
Reference in New Issue