Skip to content

Commit

Permalink
[media] mt9t112: mt9t111 format set up differs from mt9t112
Browse files Browse the repository at this point in the history
The original commit, adding the mt9t112 driver said, that mt9t111 and
mt9t112 had identical register layouts. This however doesn't seem to be
the case. At least pixel format selection in the mt9t111 datasheet is
different from the driver implementation. So far only the default YUYV
format has been verified to work with mt9t111. Limit the driver to only
report one supported format with mt9t111 until more formats are
implemented.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Guennadi Liakhovetski authored and Mauro Carvalho Chehab committed Feb 13, 2013
1 parent d6646b8 commit ec34e1d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions drivers/media/i2c/soc_camera/mt9t112.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ struct mt9t112_priv {
struct v4l2_rect frame;
const struct mt9t112_format *format;
int model;
int num_formats;
u32 flags;
/* for flags */
#define INIT_DONE (1 << 0)
Expand Down Expand Up @@ -859,11 +860,11 @@ static int mt9t112_set_params(struct mt9t112_priv *priv,
/*
* get color format
*/
for (i = 0; i < ARRAY_SIZE(mt9t112_cfmts); i++)
for (i = 0; i < priv->num_formats; i++)
if (mt9t112_cfmts[i].code == code)
break;

if (i == ARRAY_SIZE(mt9t112_cfmts))
if (i == priv->num_formats)
return -EINVAL;

priv->frame = *rect;
Expand Down Expand Up @@ -955,14 +956,16 @@ static int mt9t112_s_fmt(struct v4l2_subdev *sd,
static int mt9t112_try_fmt(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *mf)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9t112_priv *priv = to_mt9t112(client);
unsigned int top, left;
int i;

for (i = 0; i < ARRAY_SIZE(mt9t112_cfmts); i++)
for (i = 0; i < priv->num_formats; i++)
if (mt9t112_cfmts[i].code == mf->code)
break;

if (i == ARRAY_SIZE(mt9t112_cfmts)) {
if (i == priv->num_formats) {
mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
mf->colorspace = V4L2_COLORSPACE_JPEG;
} else {
Expand All @@ -979,7 +982,10 @@ static int mt9t112_try_fmt(struct v4l2_subdev *sd,
static int mt9t112_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
enum v4l2_mbus_pixelcode *code)
{
if (index >= ARRAY_SIZE(mt9t112_cfmts))
struct i2c_client *client = v4l2_get_subdevdata(sd);
struct mt9t112_priv *priv = to_mt9t112(client);

if (index >= priv->num_formats)
return -EINVAL;

*code = mt9t112_cfmts[index].code;
Expand Down Expand Up @@ -1056,10 +1062,12 @@ static int mt9t112_camera_probe(struct i2c_client *client)
case 0x2680:
devname = "mt9t111";
priv->model = V4L2_IDENT_MT9T111;
priv->num_formats = 1;
break;
case 0x2682:
devname = "mt9t112";
priv->model = V4L2_IDENT_MT9T112;
priv->num_formats = ARRAY_SIZE(mt9t112_cfmts);
break;
default:
dev_err(&client->dev, "Product ID error %04x\n", chipid);
Expand Down

0 comments on commit ec34e1d

Please sign in to comment.