Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Laurent Pinchart and committed by
Mauro Carvalho Chehab
1c542ba8 d281c1f1

+11 -9
+11 -3
drivers/media/video/mt9p031.c
··· 99 99 #define MT9P031_TEST_PATTERN_RED 0xa2 100 100 #define MT9P031_TEST_PATTERN_BLUE 0xa3 101 101 102 + enum mt9p031_model { 103 + MT9P031_MODEL_COLOR, 104 + MT9P031_MODEL_MONOCHROME, 105 + }; 106 + 102 107 struct mt9p031 { 103 108 struct v4l2_subdev subdev; 104 109 struct media_pad pad; ··· 114 109 struct mutex power_lock; /* lock to protect power_count */ 115 110 int power_count; 116 111 112 + enum mt9p031_model model; 117 113 struct aptina_pll pll; 118 114 119 115 /* Registers cache */ ··· 770 764 771 765 format = v4l2_subdev_get_try_format(fh, 0); 772 766 773 - if (mt9p031->pdata->version == MT9P031_MONOCHROME_VERSION) 767 + if (mt9p031->model == MT9P031_MODEL_MONOCHROME) 774 768 format->code = V4L2_MBUS_FMT_Y12_1X12; 775 769 else 776 770 format->code = V4L2_MBUS_FMT_SGRBG12_1X12; ··· 848 842 mt9p031->pdata = pdata; 849 843 mt9p031->output_control = MT9P031_OUTPUT_CONTROL_DEF; 850 844 mt9p031->mode2 = MT9P031_READ_MODE_2_ROW_BLC; 845 + mt9p031->model = did->driver_data; 851 846 852 847 v4l2_ctrl_handler_init(&mt9p031->ctrls, ARRAY_SIZE(mt9p031_ctrls) + 4); 853 848 ··· 889 882 mt9p031->crop.left = MT9P031_COLUMN_START_DEF; 890 883 mt9p031->crop.top = MT9P031_ROW_START_DEF; 891 884 892 - if (mt9p031->pdata->version == MT9P031_MONOCHROME_VERSION) 885 + if (mt9p031->model == MT9P031_MODEL_MONOCHROME) 893 886 mt9p031->format.code = V4L2_MBUS_FMT_Y12_1X12; 894 887 else 895 888 mt9p031->format.code = V4L2_MBUS_FMT_SGRBG12_1X12; ··· 925 918 } 926 919 927 920 static const struct i2c_device_id mt9p031_id[] = { 928 - { "mt9p031", 0 }, 921 + { "mt9p031", MT9P031_MODEL_COLOR }, 922 + { "mt9p031m", MT9P031_MODEL_MONOCHROME }, 929 923 { } 930 924 }; 931 925 MODULE_DEVICE_TABLE(i2c, mt9p031_id);
-6
include/media/mt9p031.h
··· 3 3 4 4 struct v4l2_subdev; 5 5 6 - enum { 7 - MT9P031_COLOR_VERSION, 8 - MT9P031_MONOCHROME_VERSION, 9 - }; 10 - 11 6 struct mt9p031_platform_data { 12 7 int (*set_xclk)(struct v4l2_subdev *subdev, int hz); 13 8 int (*reset)(struct v4l2_subdev *subdev, int active); 14 9 int ext_freq; /* input frequency to the mt9p031 for PLL dividers */ 15 10 int target_freq; /* frequency target for the PLL */ 16 - int version; /* MT9P031_COLOR_VERSION or MT9P031_MONOCHROME_VERSION */ 17 11 }; 18 12 19 13 #endif