Commit 3fc34b7b authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarSebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent df0e4033
...@@ -68,10 +68,9 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor) ...@@ -68,10 +68,9 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd); struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
u32 fmt_model_type, fmt_model_subtype, ncol_desc, nrow_desc; u32 fmt_model_type, fmt_model_subtype, ncol_desc, nrow_desc;
unsigned int i; unsigned int i;
int rval; int pixel_count = 0;
int line_count = 0; int line_count = 0;
int embedded_start = -1, embedded_end = -1; int rval;
int image_start = 0;
rval = smiapp_read(sensor, SMIAPP_REG_U8_FRAME_FORMAT_MODEL_TYPE, rval = smiapp_read(sensor, SMIAPP_REG_U8_FRAME_FORMAT_MODEL_TYPE,
&fmt_model_type); &fmt_model_type);
...@@ -166,33 +165,40 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor) ...@@ -166,33 +165,40 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
dev_dbg(&client->dev, "%s pixels: %d %s\n", dev_dbg(&client->dev, "%s pixels: %d %s\n",
what, pixels, which); 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; continue;
}
/* Handle row descriptors */ /* Handle row descriptors */
if (pixelcode switch (pixelcode) {
== SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED) { case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED:
embedded_start = line_count; if (sensor->embedded_end)
} else { break;
if (pixelcode == SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE sensor->embedded_start = line_count;
|| pixels >= sensor->limits[SMIAPP_LIMIT_MIN_FRAME_LENGTH_LINES] / 2) sensor->embedded_end = line_count + pixels;
image_start = line_count; break;
if (embedded_start != -1 && embedded_end == -1) case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE:
embedded_end = line_count; sensor->image_start = line_count;
break;
} }
line_count += pixels; line_count += pixels;
} }
if (embedded_start == -1 || embedded_end == -1) { if (sensor->embedded_end > sensor->image_start) {
embedded_start = 0; dev_dbg(&client->dev,
embedded_end = 0; "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", dev_dbg(&client->dev, "embedded data from lines %d to %d\n",
embedded_start, embedded_end); sensor->embedded_start, sensor->embedded_end);
dev_dbg(&client->dev, "image data starts at line %d\n", image_start); dev_dbg(&client->dev, "image data starts at line %d\n",
sensor->image_start);
return 0; return 0;
} }
......
...@@ -213,7 +213,10 @@ struct smiapp_sensor { ...@@ -213,7 +213,10 @@ struct smiapp_sensor {
u8 hvflip_inv_mask; /* H/VFLIP inversion due to sensor orientation */ u8 hvflip_inv_mask; /* H/VFLIP inversion due to sensor orientation */
u8 frame_skip; 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; int power_count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment