media: smiapp: Obtain frame descriptor from CCS limits
Obtain the frame descriptor from the CCS limits, instead of reading them directly from the frame descriptor registers. 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
3e158e1f1e
commit
fd9065812c
@ -228,34 +228,29 @@ out_err:
|
|||||||
static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
|
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;
|
u8 fmt_model_type, fmt_model_subtype, ncol_desc, nrow_desc;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int pixel_count = 0;
|
int pixel_count = 0;
|
||||||
int line_count = 0;
|
int line_count = 0;
|
||||||
int rval;
|
|
||||||
|
|
||||||
rval = smiapp_read(sensor, SMIAPP_REG_U8_FRAME_FORMAT_MODEL_TYPE,
|
fmt_model_type = CCS_LIM(sensor, FRAME_FORMAT_MODEL_TYPE);
|
||||||
&fmt_model_type);
|
fmt_model_subtype = CCS_LIM(sensor, FRAME_FORMAT_MODEL_SUBTYPE);
|
||||||
if (rval)
|
|
||||||
return rval;
|
|
||||||
|
|
||||||
rval = smiapp_read(sensor, SMIAPP_REG_U8_FRAME_FORMAT_MODEL_SUBTYPE,
|
|
||||||
&fmt_model_subtype);
|
|
||||||
if (rval)
|
|
||||||
return rval;
|
|
||||||
|
|
||||||
ncol_desc = (fmt_model_subtype
|
ncol_desc = (fmt_model_subtype
|
||||||
& SMIAPP_FRAME_FORMAT_MODEL_SUBTYPE_NCOLS_MASK)
|
& CCS_FRAME_FORMAT_MODEL_SUBTYPE_COLUMNS_MASK)
|
||||||
>> SMIAPP_FRAME_FORMAT_MODEL_SUBTYPE_NCOLS_SHIFT;
|
>> CCS_FRAME_FORMAT_MODEL_SUBTYPE_COLUMNS_SHIFT;
|
||||||
nrow_desc = fmt_model_subtype
|
nrow_desc = fmt_model_subtype
|
||||||
& SMIAPP_FRAME_FORMAT_MODEL_SUBTYPE_NROWS_MASK;
|
& CCS_FRAME_FORMAT_MODEL_SUBTYPE_ROWS_MASK;
|
||||||
|
|
||||||
dev_dbg(&client->dev, "format_model_type %s\n",
|
dev_dbg(&client->dev, "format_model_type %s\n",
|
||||||
fmt_model_type == SMIAPP_FRAME_FORMAT_MODEL_TYPE_2BYTE
|
fmt_model_type == CCS_FRAME_FORMAT_MODEL_TYPE_2_BYTE
|
||||||
? "2 byte" :
|
? "2 byte" :
|
||||||
fmt_model_type == SMIAPP_FRAME_FORMAT_MODEL_TYPE_4BYTE
|
fmt_model_type == CCS_FRAME_FORMAT_MODEL_TYPE_4_BYTE
|
||||||
? "4 byte" : "is simply bad");
|
? "4 byte" : "is simply bad");
|
||||||
|
|
||||||
|
dev_dbg(&client->dev, "%u column and %u row descriptors\n",
|
||||||
|
ncol_desc, nrow_desc);
|
||||||
|
|
||||||
for (i = 0; i < ncol_desc + nrow_desc; i++) {
|
for (i = 0; i < ncol_desc + nrow_desc; i++) {
|
||||||
u32 desc;
|
u32 desc;
|
||||||
u32 pixelcode;
|
u32 pixelcode;
|
||||||
@ -264,29 +259,24 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
|
|||||||
char *what;
|
char *what;
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
|
||||||
if (fmt_model_type == SMIAPP_FRAME_FORMAT_MODEL_TYPE_2BYTE) {
|
if (fmt_model_type == CCS_FRAME_FORMAT_MODEL_TYPE_2_BYTE) {
|
||||||
reg = SMIAPP_REG_U16_FRAME_FORMAT_DESCRIPTOR_2(i);
|
desc = CCS_LIM_AT(sensor, FRAME_FORMAT_DESCRIPTOR, i);
|
||||||
rval = smiapp_read(sensor, reg, &desc);
|
|
||||||
if (rval)
|
|
||||||
return rval;
|
|
||||||
|
|
||||||
pixelcode =
|
pixelcode =
|
||||||
(desc
|
(desc
|
||||||
& SMIAPP_FRAME_FORMAT_DESC_2_PIXELCODE_MASK)
|
& CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_MASK)
|
||||||
>> SMIAPP_FRAME_FORMAT_DESC_2_PIXELCODE_SHIFT;
|
>> CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_SHIFT;
|
||||||
pixels = desc & SMIAPP_FRAME_FORMAT_DESC_2_PIXELS_MASK;
|
pixels = desc & CCS_FRAME_FORMAT_DESCRIPTOR_PIXELS_MASK;
|
||||||
} else if (fmt_model_type
|
} else if (fmt_model_type
|
||||||
== SMIAPP_FRAME_FORMAT_MODEL_TYPE_4BYTE) {
|
== CCS_FRAME_FORMAT_MODEL_TYPE_4_BYTE) {
|
||||||
reg = SMIAPP_REG_U32_FRAME_FORMAT_DESCRIPTOR_4(i);
|
desc = CCS_LIM_AT(sensor, FRAME_FORMAT_DESCRIPTOR_4, i);
|
||||||
rval = smiapp_read(sensor, reg, &desc);
|
|
||||||
if (rval)
|
|
||||||
return rval;
|
|
||||||
|
|
||||||
pixelcode =
|
pixelcode =
|
||||||
(desc
|
(desc
|
||||||
& SMIAPP_FRAME_FORMAT_DESC_4_PIXELCODE_MASK)
|
& CCS_FRAME_FORMAT_DESCRIPTOR_4_PCODE_MASK)
|
||||||
>> SMIAPP_FRAME_FORMAT_DESC_4_PIXELCODE_SHIFT;
|
>> CCS_FRAME_FORMAT_DESCRIPTOR_4_PCODE_SHIFT;
|
||||||
pixels = desc & SMIAPP_FRAME_FORMAT_DESC_4_PIXELS_MASK;
|
pixels = desc &
|
||||||
|
CCS_FRAME_FORMAT_DESCRIPTOR_4_PIXELS_MASK;
|
||||||
} else {
|
} else {
|
||||||
dev_dbg(&client->dev,
|
dev_dbg(&client->dev,
|
||||||
"invalid frame format model type %d\n",
|
"invalid frame format model type %d\n",
|
||||||
@ -300,19 +290,19 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
|
|||||||
which = "rows";
|
which = "rows";
|
||||||
|
|
||||||
switch (pixelcode) {
|
switch (pixelcode) {
|
||||||
case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED:
|
case CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_EMBEDDED:
|
||||||
what = "embedded";
|
what = "embedded";
|
||||||
break;
|
break;
|
||||||
case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_DUMMY:
|
case CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_DUMMY_PIXEL:
|
||||||
what = "dummy";
|
what = "dummy";
|
||||||
break;
|
break;
|
||||||
case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_BLACK:
|
case CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_BLACK_PIXEL:
|
||||||
what = "black";
|
what = "black";
|
||||||
break;
|
break;
|
||||||
case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_DARK:
|
case CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_DARK_PIXEL:
|
||||||
what = "dark";
|
what = "dark";
|
||||||
break;
|
break;
|
||||||
case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE:
|
case CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_VISIBLE_PIXEL:
|
||||||
what = "visible";
|
what = "visible";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -326,7 +316,7 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
|
|||||||
|
|
||||||
if (i < ncol_desc) {
|
if (i < ncol_desc) {
|
||||||
if (pixelcode ==
|
if (pixelcode ==
|
||||||
SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE)
|
CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_VISIBLE_PIXEL)
|
||||||
sensor->visible_pixel_start = pixel_count;
|
sensor->visible_pixel_start = pixel_count;
|
||||||
pixel_count += pixels;
|
pixel_count += pixels;
|
||||||
continue;
|
continue;
|
||||||
@ -334,13 +324,13 @@ static int smiapp_read_frame_fmt(struct smiapp_sensor *sensor)
|
|||||||
|
|
||||||
/* Handle row descriptors */
|
/* Handle row descriptors */
|
||||||
switch (pixelcode) {
|
switch (pixelcode) {
|
||||||
case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_EMBEDDED:
|
case CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_EMBEDDED:
|
||||||
if (sensor->embedded_end)
|
if (sensor->embedded_end)
|
||||||
break;
|
break;
|
||||||
sensor->embedded_start = line_count;
|
sensor->embedded_start = line_count;
|
||||||
sensor->embedded_end = line_count + pixels;
|
sensor->embedded_end = line_count + pixels;
|
||||||
break;
|
break;
|
||||||
case SMIAPP_FRAME_FORMAT_DESC_PIXELCODE_VISIBLE:
|
case CCS_FRAME_FORMAT_DESCRIPTOR_PCODE_VISIBLE_PIXEL:
|
||||||
sensor->image_start = line_count;
|
sensor->image_start = line_count;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user