aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-03-09 08:42:52 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-05-14 12:32:22 -0400
commit1c542ba85461f4f4f456eeee4fa7e90a3d138c6a (patch)
tree987d4a258766c779fe124b9d76268166e407f8ab
parentd281c1f1443b36890c35de71d9fdaa5cd3899003 (diff)
[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: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/mt9p031.c14
-rw-r--r--include/media/mt9p031.h6
2 files changed, 11 insertions, 9 deletions
diff --git a/drivers/media/video/mt9p031.c b/drivers/media/video/mt9p031.c
index c81eaf4fbe01..5b8a3968035d 100644
--- a/drivers/media/video/mt9p031.c
+++ b/drivers/media/video/mt9p031.c
@@ -99,6 +99,11 @@
99#define MT9P031_TEST_PATTERN_RED 0xa2 99#define MT9P031_TEST_PATTERN_RED 0xa2
100#define MT9P031_TEST_PATTERN_BLUE 0xa3 100#define MT9P031_TEST_PATTERN_BLUE 0xa3
101 101
102enum mt9p031_model {
103 MT9P031_MODEL_COLOR,
104 MT9P031_MODEL_MONOCHROME,
105};
106
102struct mt9p031 { 107struct mt9p031 {
103 struct v4l2_subdev subdev; 108 struct v4l2_subdev subdev;
104 struct media_pad pad; 109 struct media_pad pad;
@@ -109,6 +114,7 @@ struct mt9p031 {
109 struct mutex power_lock; /* lock to protect power_count */ 114 struct mutex power_lock; /* lock to protect power_count */
110 int power_count; 115 int power_count;
111 116
117 enum mt9p031_model model;
112 struct aptina_pll pll; 118 struct aptina_pll pll;
113 119
114 /* Registers cache */ 120 /* Registers cache */
@@ -764,7 +770,7 @@ static int mt9p031_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
764 770
765 format = v4l2_subdev_get_try_format(fh, 0); 771 format = v4l2_subdev_get_try_format(fh, 0);
766 772
767 if (mt9p031->pdata->version == MT9P031_MONOCHROME_VERSION) 773 if (mt9p031->model == MT9P031_MODEL_MONOCHROME)
768 format->code = V4L2_MBUS_FMT_Y12_1X12; 774 format->code = V4L2_MBUS_FMT_Y12_1X12;
769 else 775 else
770 format->code = V4L2_MBUS_FMT_SGRBG12_1X12; 776 format->code = V4L2_MBUS_FMT_SGRBG12_1X12;
@@ -842,6 +848,7 @@ static int mt9p031_probe(struct i2c_client *client,
842 mt9p031->pdata = pdata; 848 mt9p031->pdata = pdata;
843 mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; 849 mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF;
844 mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; 850 mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC;
851 mt9p031->model = did->driver_data;
845 852
846 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4); 853 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4);
847 854
@@ -882,7 +889,7 @@ static int mt9p031_probe(struct i2c_client *client,
882 mt9p031->crop.left = MT9P031_COLUMN_START_DEF; 889 mt9p031->crop.left = MT9P031_COLUMN_START_DEF;
883 mt9p031->crop.top = MT9P031_ROW_START_DEF; 890 mt9p031->crop.top = MT9P031_ROW_START_DEF;
884 891
885 if (mt9p031->pdata->version == MT9P031_MONOCHROME_VERSION) 892 if (mt9p031->model == MT9P031_MODEL_MONOCHROME)
886 mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12; 893 mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12;
887 else 894 else
888 mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12; 895 mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12;
@@ -918,7 +925,8 @@ static int mt9p031_remove(struct i2c_client *client)
918} 925}
919 926
920static const struct i2c_device_id mt9p031_id[] = { 927static const struct i2c_device_id mt9p031_id[] = {
921 { "mt9p031", 0 }, 928 { "mt9p031", MT9P031_MODEL_COLOR },
929 { "mt9p031m", MT9P031_MODEL_MONOCHROME },
922 { } 930 { }
923}; 931};
924MODULE_DEVICE_TABLE(i2c, mt9p031_id); 932MODULE_DEVICE_TABLE(i2c, mt9p031_id);
diff --git a/include/media/mt9p031.h b/include/media/mt9p031.h
index 96448c7a318b..5b5090fb9c28 100644
--- a/include/media/mt9p031.h
+++ b/include/media/mt9p031.h
@@ -3,17 +3,11 @@
3 3
4struct v4l2_subdev; 4struct v4l2_subdev;
5 5
6enum {
7 MT9P031_COLOR_VERSION,
8 MT9P031_MONOCHROME_VERSION,
9};
10
11struct mt9p031_platform_data { 6struct mt9p031_platform_data {
12 int (*set_xclk)(struct v4l2_subdev *subdev, int hz); 7 int (*set_xclk)(struct v4l2_subdev *subdev, int hz);
13 int (*reset)(struct v4l2_subdev *subdev, int active); 8 int (*reset)(struct v4l2_subdev *subdev, int active);
14 int ext_freq; /* input frequency to the mt9p031 for PLL dividers */ 9 int ext_freq; /* input frequency to the mt9p031 for PLL dividers */
15 int target_freq; /* frequency target for the PLL */ 10 int target_freq; /* frequency target for the PLL */
16 int version; /* MT9P031_COLOR_VERSION or MT9P031_MONOCHROME_VERSION */
17}; 11};
18 12
19#endif 13#endif