summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@maxwell.research.nokia.com>2012-04-26 16:39:44 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-20 15:47:25 (GMT)
commit27b2e76dbca0b84cdae1b23c90fb353e63bb2fbb (patch)
treeeb8361ecfc2eb0be2049ca4f0f14b1eeea947f3e /drivers/media
parent3de886e0e4e1a981442e26edca5a32777299b079 (diff)
downloadlinux-27b2e76dbca0b84cdae1b23c90fb353e63bb2fbb.tar.xz
[media] smiapp: Allow generic quirk registers
Implement more generic quirk registers than just limit and capability registers. This comes with the expense of a little bit more access time so these should be only used when really needed. Signed-off-by: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/smiapp/smiapp-quirk.c46
-rw-r--r--drivers/media/video/smiapp/smiapp-quirk.h10
-rw-r--r--drivers/media/video/smiapp/smiapp-regs.c4
3 files changed, 60 insertions, 0 deletions
diff --git a/drivers/media/video/smiapp/smiapp-quirk.c b/drivers/media/video/smiapp/smiapp-quirk.c
index 81c2be3..55e8795 100644
--- a/drivers/media/video/smiapp/smiapp-quirk.c
+++ b/drivers/media/video/smiapp/smiapp-quirk.c
@@ -81,6 +81,52 @@ int smiapp_replace_limit_at(struct smiapp_sensor *sensor,
return -EINVAL;
}
+bool smiapp_quirk_reg(struct smiapp_sensor *sensor,
+ u32 reg, u32 *val)
+{
+ struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
+ const struct smia_reg *sreg;
+
+ if (!sensor->minfo.quirk)
+ return false;
+
+ sreg = sensor->minfo.quirk->regs;
+
+ if (!sreg)
+ return false;
+
+ while (sreg->type) {
+ u16 type = reg >> 16;
+ u16 reg16 = reg;
+
+ if (sreg->type != type || sreg->reg != reg16) {
+ sreg++;
+ continue;
+ }
+
+ switch ((u8)type) {
+ case SMIA_REG_8BIT:
+ dev_dbg(&client->dev, "quirk: 0x%8.8x: 0x%2.2x\n",
+ reg, sreg->val);
+ break;
+ case SMIA_REG_16BIT:
+ dev_dbg(&client->dev, "quirk: 0x%8.8x: 0x%4.4x\n",
+ reg, sreg->val);
+ break;
+ case SMIA_REG_32BIT:
+ dev_dbg(&client->dev, "quirk: 0x%8.8x: 0x%8.8x\n",
+ reg, sreg->val);
+ break;
+ }
+
+ *val = sreg->val;
+
+ return true;
+ }
+
+ return false;
+}
+
static int jt8ew9_limits(struct smiapp_sensor *sensor)
{
if (sensor->minfo.revision_number_major < 0x03)
diff --git a/drivers/media/video/smiapp/smiapp-quirk.h b/drivers/media/video/smiapp/smiapp-quirk.h
index de82cdf..f4dcaab 100644
--- a/drivers/media/video/smiapp/smiapp-quirk.h
+++ b/drivers/media/video/smiapp/smiapp-quirk.h
@@ -41,6 +41,7 @@ struct smiapp_quirk {
int (*post_poweron)(struct smiapp_sensor *sensor);
int (*pre_streamon)(struct smiapp_sensor *sensor);
int (*post_streamoff)(struct smiapp_sensor *sensor);
+ const struct smia_reg *regs;
unsigned long flags;
};
@@ -55,6 +56,15 @@ struct smiapp_reg_8 {
void smiapp_replace_limit(struct smiapp_sensor *sensor,
u32 limit, u32 val);
+bool smiapp_quirk_reg(struct smiapp_sensor *sensor,
+ u32 reg, u32 *val);
+
+#define SMIAPP_MK_QUIRK_REG(_reg, _val) \
+ { \
+ .type = (_reg >> 16), \
+ .reg = (u16)_reg, \
+ .val = _val, \
+ }
#define smiapp_call_quirk(_sensor, _quirk, ...) \
(_sensor->minfo.quirk && \
diff --git a/drivers/media/video/smiapp/smiapp-regs.c b/drivers/media/video/smiapp/smiapp-regs.c
index 9c430647..b1812b1 100644
--- a/drivers/media/video/smiapp/smiapp-regs.c
+++ b/drivers/media/video/smiapp/smiapp-regs.c
@@ -172,6 +172,9 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val,
&& len != SMIA_REG_32BIT)
return -EINVAL;
+ if (smiapp_quirk_reg(sensor, reg, val))
+ goto found_quirk;
+
if (len == SMIA_REG_8BIT && !only8)
rval = ____smiapp_read(sensor, (u16)reg, len, val);
else
@@ -179,6 +182,7 @@ static int __smiapp_read(struct smiapp_sensor *sensor, u32 reg, u32 *val,
if (rval < 0)
return rval;
+found_quirk:
if (reg & SMIA_REG_FLAG_FLOAT)
*val = float_to_u32_mul_1000000(client, *val);