diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2016-09-05 08:18:34 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-10-21 15:09:06 -0200 |
commit | 3fc34b7beb89472b61f919ec0f8699e2a3b46d94 (patch) | |
tree | dc62f3cbf48198a145440a642f79cc1360bc5cf1 /drivers/media/i2c | |
parent | df0e40339b48e149f25da9010bc92a39afbf5e66 (diff) | |
download | linux-3fc34b7beb89472b61f919ec0f8699e2a3b46d94.tar.gz linux-3fc34b7beb89472b61f919ec0f8699e2a3b46d94.tar.bz2 linux-3fc34b7beb89472b61f919ec0f8699e2a3b46d94.zip |
[media] smiapp: Obtain frame layout from the frame descriptor
Besides the image data, SMIA++ compliant sensors also provide embedded
data in form of registers used to capture the image. Store this
information for later use in frame descriptor and routing.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/smiapp/smiapp-core.c | 46 | ||||
-rw-r--r-- | drivers/media/i2c/smiapp/smiapp.h | 5 |
2 files changed, 30 insertions, 21 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c index 7ac0d4e0cc89..a7afcea5a5c5 100644 --- a/drivers/media/i2c/smiapp/smiapp-core.c +++ b/drivers/media/i2c/smiapp/smiapp-core.c @@ -68,10 +68,9 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor) struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); u32 fmt_model_type, fmt_model_subtype, ncol_desc, nrow_desc; unsigned int i; - int rval; + int pixel_count = 0; int line_count = 0; - int embedded_start = -1, embedded_end = -1; - int image_start = 0; + int rval; rval = smiapp_read(sensor, SMIAPP_REG_U8_FRAME_FORMAT_MODEL_TYPE, &fmt_model_type); @@ -166,33 +165,40 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor) dev_dbg(&client->dev, "%s pixels: %d %s\n", what, pixels, which); - if (i < ncol_desc) + if (i < ncol_desc) { + if (pixelcode == + SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE) + sensor->visible_pixel_start = pixel_count; + pixel_count += pixels; continue; + } /* Handle row descriptors */ - if (pixelcode - == SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED) { - embedded_start = line_count; - } else { - if (pixelcode == SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE - || pixels >= sensor->limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES] / 2) - image_start = line_count; - if (embedded_start != -1 && embedded_end == -1) - embedded_end = line_count; + switch (pixelcode) { + case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED: + if (sensor->embedded_end) + break; + sensor->embedded_start = line_count; + sensor->embedded_end = line_count + pixels; + break; + case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE: + sensor->image_start = line_count; + break; } line_count += pixels; } - if (embedded_start == -1 || embedded_end == -1) { - embedded_start = 0; - embedded_end = 0; + if (sensor->embedded_end > sensor->image_start) { + dev_dbg(&client->dev, + "adjusting image start line to %u (was %u)\n", + sensor->embedded_end, sensor->image_start); + sensor->image_start = sensor->embedded_end; } - sensor->image_start = image_start; - dev_dbg(&client->dev, "embedded data from lines %d to %d\n", - embedded_start, embedded_end); - dev_dbg(&client->dev, "image data starts at line %d\n", image_start); + sensor->embedded_start, sensor->embedded_end); + dev_dbg(&client->dev, "image data starts at line %d\n", + sensor->image_start); return 0; } diff --git a/drivers/media/i2c/smiapp/smiapp.h b/drivers/media/i2c/smiapp/smiapp.h index f9febe0a056d..d7b52a61af4f 100644 --- a/drivers/media/i2c/smiapp/smiapp.h +++ b/drivers/media/i2c/smiapp/smiapp.h @@ -213,7 +213,10 @@ struct smiapp_sensor { u8 hvflip_inv_mask; /* H/VFLIP inversion due to sensor orientation */ u8 frame_skip; - u16 image_start; /* Offset to first line after metadata lines */ + u16 embedded_start; /* embedded data start line */ + u16 embedded_end; + u16 image_start; /* image data start line */ + u16 visible_pixel_start; /* start pixel of the visible image */ int power_count; |