Commit 1c542ba8 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

[media] mt9p031: Identify color/mono models using I2C device name

Instead of passing a color/monochrome flag through platform data, rely
on the I2C device name to identify the chip model.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d281c1f1
...@@ -99,6 +99,11 @@ ...@@ -99,6 +99,11 @@
#define MT9P031_TEST_PATTERN_RED 0xa2 #define MT9P031_TEST_PATTERN_RED 0xa2
#define MT9P031_TEST_PATTERN_BLUE 0xa3 #define MT9P031_TEST_PATTERN_BLUE 0xa3
enum mt9p031_model {
MT9P031_MODEL_COLOR,
MT9P031_MODEL_MONOCHROME,
};
struct mt9p031 { struct mt9p031 {
struct v4l2_subdev subdev; struct v4l2_subdev subdev;
struct media_pad pad; struct media_pad pad;
...@@ -109,6 +114,7 @@ struct mt9p031 { ...@@ -109,6 +114,7 @@ struct mt9p031 {
struct mutex power_lock; /* lock to protect power_count */ struct mutex power_lock; /* lock to protect power_count */
int power_count; int power_count;
enum mt9p031_model model;
struct aptina_pll pll; struct aptina_pll pll;
/* Registers cache */ /* Registers cache */
...@@ -764,7 +770,7 @@ static int mt9p031_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh) ...@@ -764,7 +770,7 @@ static int mt9p031_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
format = v4l2_subdev_get_try_format(fh, 0); format = v4l2_subdev_get_try_format(fh, 0);
if (mt9p031->pdata->version == MT9P031_MONOCHROME_VERSION) if (mt9p031->model == MT9P031_MODEL_MONOCHROME)
format->code = V4L2_MBUS_FMT_Y12_1X12; format->code = V4L2_MBUS_FMT_Y12_1X12;
else else
format->code = V4L2_MBUS_FMT_SGRBG12_1X12; format->code = V4L2_MBUS_FMT_SGRBG12_1X12;
...@@ -842,6 +848,7 @@ static int mt9p031_probe(struct i2c_client *client, ...@@ -842,6 +848,7 @@ static int mt9p031_probe(struct i2c_client *client,
mt9p031->pdata = pdata; mt9p031->pdata = pdata;
mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF;
mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC;
mt9p031->model = did->driver_data;
v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4); v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4);
...@@ -882,7 +889,7 @@ static int mt9p031_probe(struct i2c_client *client, ...@@ -882,7 +889,7 @@ static int mt9p031_probe(struct i2c_client *client,
mt9p031->crop.left = MT9P031_COLUMN_START_DEF; mt9p031->crop.left = MT9P031_COLUMN_START_DEF;
mt9p031->crop.top = MT9P031_ROW_START_DEF; mt9p031->crop.top = MT9P031_ROW_START_DEF;
if (mt9p031->pdata->version == MT9P031_MONOCHROME_VERSION) if (mt9p031->model == MT9P031_MODEL_MONOCHROME)
mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12; mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12;
else else
mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12; mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
...@@ -918,7 +925,8 @@ static int mt9p031_remove(struct i2c_client *client) ...@@ -918,7 +925,8 @@ static int mt9p031_remove(struct i2c_client *client)
} }
static const struct i2c_device_id mt9p031_id[] = { static const struct i2c_device_id mt9p031_id[] = {
{ "mt9p031", 0 }, { "mt9p031", MT9P031_MODEL_COLOR },
{ "mt9p031m", MT9P031_MODEL_MONOCHROME },
{ } { }
}; };
MODULE_DEVICE_TABLE(i2c, mt9p031_id); MODULE_DEVICE_TABLE(i2c, mt9p031_id);
......
...@@ -3,17 +3,11 @@ ...@@ -3,17 +3,11 @@
struct v4l2_subdev; struct v4l2_subdev;
enum {
MT9P031_COLOR_VERSION,
MT9P031_MONOCHROME_VERSION,
};
struct mt9p031_platform_data { struct mt9p031_platform_data {
int (*set_xclk)(struct v4l2_subdev *subdev, int hz); int (*set_xclk)(struct v4l2_subdev *subdev, int hz);
int (*reset)(struct v4l2_subdev *subdev, int active); int (*reset)(struct v4l2_subdev *subdev, int active);
int ext_freq; /* input frequency to the mt9p031 for PLL dividers */ int ext_freq; /* input frequency to the mt9p031 for PLL dividers */
int target_freq; /* frequency target for the PLL */ int target_freq; /* frequency target for the PLL */
int version; /* MT9P031_COLOR_VERSION or MT9P031_MONOCHROME_VERSION */
}; };
#endif #endif
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