aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c/soc_camera/mt9t112.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-24 20:35:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-24 20:35:10 -0500
commit21fbd5809ad126b949206d78e0a0e07ec872ea11 (patch)
treea824045df99fc1f0690095a925cceb50207e332b /drivers/media/i2c/soc_camera/mt9t112.c
parentd9978ec5680059d727b39d6c706777c6973587f2 (diff)
parented72d37a33fdf43dc47787fe220532cdec9da528 (diff)
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab: - Some cleanups at V4L2 documentation - new drivers: ts2020 frontend, ov9650 sensor, s5c73m3 sensor, sh-mobile veu mem2mem driver, radio-ma901, davinci_vpfe staging driver - Lots of missing MAINTAINERS entries added - several em28xx driver improvements, including its conversion to videobuf2 - several fixups on drivers to make them to better comply with the API - DVB core: add support for DVBv5 stats, allowing the implementation of statistics for new standards like ISDB - mb86a20s: add statistics to the driver - lots of new board additions, cleanups, and driver improvements. * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (596 commits) [media] media: Add 0x3009 USB PID to ttusb2 driver (fixed diff) [media] rtl28xxu: Add USB IDs for Compro VideoMate U620F [media] em28xx: add usb id for terratec h5 rev. 3 [media] media: rc: gpio-ir-recv: add support for device tree parsing [media] mceusb: move check earlier to make smatch happy [media] radio-si470x doc: add info about v4l2-ctl and sox+alsa [media] staging: media: Remove unnecessary OOM messages [media] sh_vou: Use vou_dev instead of vou_file wherever possible [media] sh_vou: Use video_drvdata() [media] drivers/media/platform/soc_camera/pxa_camera.c: use devm_ functions [media] mt9t112: mt9t111 format set up differs from mt9t112 [media] sh-mobile-ceu-camera: fix SHARPNESS control default Revert "[media] fc0011: Return early, if the frequency is already tuned" [media] cx18/ivtv: fix regression: remove __init from a non-init function [media] em28xx: fix analog streaming with USB bulk transfers [media] stv0900: remove unnecessary null pointer check [media] fc0011: Return early, if the frequency is already tuned [media] fc0011: Add some sanity checks and cleanups [media] fc0011: Fix xin value clamping Revert "[media] [PATH,1/2] mxl5007 move reset to attach" ...
Diffstat (limited to 'drivers/media/i2c/soc_camera/mt9t112.c')
-rw-r--r--drivers/media/i2c/soc_camera/mt9t112.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/drivers/media/i2c/soc_camera/mt9t112.c b/drivers/media/i2c/soc_camera/mt9t112.c
index de7cd836b0a2..188e29b03273 100644
--- a/drivers/media/i2c/soc_camera/mt9t112.c
+++ b/drivers/media/i2c/soc_camera/mt9t112.c
@@ -92,6 +92,7 @@ struct mt9t112_priv {
92 struct v4l2_rect frame; 92 struct v4l2_rect frame;
93 const struct mt9t112_format *format; 93 const struct mt9t112_format *format;
94 int model; 94 int model;
95 int num_formats;
95 u32 flags; 96 u32 flags;
96/* for flags */ 97/* for flags */
97#define INIT_DONE (1 << 0) 98#define INIT_DONE (1 << 0)
@@ -779,9 +780,9 @@ static int mt9t112_s_register(struct v4l2_subdev *sd,
779static int mt9t112_s_power(struct v4l2_subdev *sd, int on) 780static int mt9t112_s_power(struct v4l2_subdev *sd, int on)
780{ 781{
781 struct i2c_client *client = v4l2_get_subdevdata(sd); 782 struct i2c_client *client = v4l2_get_subdevdata(sd);
782 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 783 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
783 784
784 return soc_camera_set_power(&client->dev, icl, on); 785 return soc_camera_set_power(&client->dev, ssdd, on);
785} 786}
786 787
787static struct v4l2_subdev_core_ops mt9t112_subdev_core_ops = { 788static struct v4l2_subdev_core_ops mt9t112_subdev_core_ops = {
@@ -859,11 +860,11 @@ static int mt9t112_set_params(struct mt9t112_priv *priv,
859 /* 860 /*
860 * get color format 861 * get color format
861 */ 862 */
862 for (i = 0; i < ARRAY_SIZE(mt9t112_cfmts); i++) 863 for (i = 0; i < priv->num_formats; i++)
863 if (mt9t112_cfmts[i].code == code) 864 if (mt9t112_cfmts[i].code == code)
864 break; 865 break;
865 866
866 if (i == ARRAY_SIZE(mt9t112_cfmts)) 867 if (i == priv->num_formats)
867 return -EINVAL; 868 return -EINVAL;
868 869
869 priv->frame = *rect; 870 priv->frame = *rect;
@@ -955,14 +956,16 @@ static int mt9t112_s_fmt(struct v4l2_subdev *sd,
955static int mt9t112_try_fmt(struct v4l2_subdev *sd, 956static int mt9t112_try_fmt(struct v4l2_subdev *sd,
956 struct v4l2_mbus_framefmt *mf) 957 struct v4l2_mbus_framefmt *mf)
957{ 958{
959 struct i2c_client *client = v4l2_get_subdevdata(sd);
960 struct mt9t112_priv *priv = to_mt9t112(client);
958 unsigned int top, left; 961 unsigned int top, left;
959 int i; 962 int i;
960 963
961 for (i = 0; i < ARRAY_SIZE(mt9t112_cfmts); i++) 964 for (i = 0; i < priv->num_formats; i++)
962 if (mt9t112_cfmts[i].code == mf->code) 965 if (mt9t112_cfmts[i].code == mf->code)
963 break; 966 break;
964 967
965 if (i == ARRAY_SIZE(mt9t112_cfmts)) { 968 if (i == priv->num_formats) {
966 mf->code = V4L2_MBUS_FMT_UYVY8_2X8; 969 mf->code = V4L2_MBUS_FMT_UYVY8_2X8;
967 mf->colorspace = V4L2_COLORSPACE_JPEG; 970 mf->colorspace = V4L2_COLORSPACE_JPEG;
968 } else { 971 } else {
@@ -979,7 +982,10 @@ static int mt9t112_try_fmt(struct v4l2_subdev *sd,
979static int mt9t112_enum_fmt(struct v4l2_subdev *sd, unsigned int index, 982static int mt9t112_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
980 enum v4l2_mbus_pixelcode *code) 983 enum v4l2_mbus_pixelcode *code)
981{ 984{
982 if (index >= ARRAY_SIZE(mt9t112_cfmts)) 985 struct i2c_client *client = v4l2_get_subdevdata(sd);
986 struct mt9t112_priv *priv = to_mt9t112(client);
987
988 if (index >= priv->num_formats)
983 return -EINVAL; 989 return -EINVAL;
984 990
985 *code = mt9t112_cfmts[index].code; 991 *code = mt9t112_cfmts[index].code;
@@ -991,13 +997,13 @@ static int mt9t112_g_mbus_config(struct v4l2_subdev *sd,
991 struct v4l2_mbus_config *cfg) 997 struct v4l2_mbus_config *cfg)
992{ 998{
993 struct i2c_client *client = v4l2_get_subdevdata(sd); 999 struct i2c_client *client = v4l2_get_subdevdata(sd);
994 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 1000 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
995 1001
996 cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_VSYNC_ACTIVE_HIGH | 1002 cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_VSYNC_ACTIVE_HIGH |
997 V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_HIGH | 1003 V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_DATA_ACTIVE_HIGH |
998 V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING; 1004 V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING;
999 cfg->type = V4L2_MBUS_PARALLEL; 1005 cfg->type = V4L2_MBUS_PARALLEL;
1000 cfg->flags = soc_camera_apply_board_flags(icl, cfg); 1006 cfg->flags = soc_camera_apply_board_flags(ssdd, cfg);
1001 1007
1002 return 0; 1008 return 0;
1003} 1009}
@@ -1006,10 +1012,10 @@ static int mt9t112_s_mbus_config(struct v4l2_subdev *sd,
1006 const struct v4l2_mbus_config *cfg) 1012 const struct v4l2_mbus_config *cfg)
1007{ 1013{
1008 struct i2c_client *client = v4l2_get_subdevdata(sd); 1014 struct i2c_client *client = v4l2_get_subdevdata(sd);
1009 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 1015 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
1010 struct mt9t112_priv *priv = to_mt9t112(client); 1016 struct mt9t112_priv *priv = to_mt9t112(client);
1011 1017
1012 if (soc_camera_apply_board_flags(icl, cfg) & V4L2_MBUS_PCLK_SAMPLE_RISING) 1018 if (soc_camera_apply_board_flags(ssdd, cfg) & V4L2_MBUS_PCLK_SAMPLE_RISING)
1013 priv->flags |= PCLK_RISING; 1019 priv->flags |= PCLK_RISING;
1014 1020
1015 return 0; 1021 return 0;
@@ -1056,10 +1062,12 @@ static int mt9t112_camera_probe(struct i2c_client *client)
1056 case 0x2680: 1062 case 0x2680:
1057 devname = "mt9t111"; 1063 devname = "mt9t111";
1058 priv->model = V4L2_IDENT_MT9T111; 1064 priv->model = V4L2_IDENT_MT9T111;
1065 priv->num_formats = 1;
1059 break; 1066 break;
1060 case 0x2682: 1067 case 0x2682:
1061 devname = "mt9t112"; 1068 devname = "mt9t112";
1062 priv->model = V4L2_IDENT_MT9T112; 1069 priv->model = V4L2_IDENT_MT9T112;
1070 priv->num_formats = ARRAY_SIZE(mt9t112_cfmts);
1063 break; 1071 break;
1064 default: 1072 default:
1065 dev_err(&client->dev, "Product ID error %04x\n", chipid); 1073 dev_err(&client->dev, "Product ID error %04x\n", chipid);
@@ -1078,7 +1086,7 @@ static int mt9t112_probe(struct i2c_client *client,
1078 const struct i2c_device_id *did) 1086 const struct i2c_device_id *did)
1079{ 1087{
1080 struct mt9t112_priv *priv; 1088 struct mt9t112_priv *priv;
1081 struct soc_camera_link *icl = soc_camera_i2c_to_link(client); 1089 struct soc_camera_subdev_desc *ssdd = soc_camera_i2c_to_desc(client);
1082 struct v4l2_rect rect = { 1090 struct v4l2_rect rect = {
1083 .width = VGA_WIDTH, 1091 .width = VGA_WIDTH,
1084 .height = VGA_HEIGHT, 1092 .height = VGA_HEIGHT,
@@ -1087,24 +1095,22 @@ static int mt9t112_probe(struct i2c_client *client,
1087 }; 1095 };
1088 int ret; 1096 int ret;
1089 1097
1090 if (!icl || !icl->priv) { 1098 if (!ssdd || !ssdd->drv_priv) {
1091 dev_err(&client->dev, "mt9t112: missing platform data!\n"); 1099 dev_err(&client->dev, "mt9t112: missing platform data!\n");
1092 return -EINVAL; 1100 return -EINVAL;
1093 } 1101 }
1094 1102
1095 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1103 priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
1096 if (!priv) 1104 if (!priv)
1097 return -ENOMEM; 1105 return -ENOMEM;
1098 1106
1099 priv->info = icl->priv; 1107 priv->info = ssdd->drv_priv;
1100 1108
1101 v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops); 1109 v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
1102 1110
1103 ret = mt9t112_camera_probe(client); 1111 ret = mt9t112_camera_probe(client);
1104 if (ret) { 1112 if (ret)
1105 kfree(priv);
1106 return ret; 1113 return ret;
1107 }
1108 1114
1109 /* Cannot fail: using the default supported pixel code */ 1115 /* Cannot fail: using the default supported pixel code */
1110 mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8); 1116 mt9t112_set_params(priv, &rect, V4L2_MBUS_FMT_UYVY8_2X8);
@@ -1114,9 +1120,6 @@ static int mt9t112_probe(struct i2c_client *client,
1114 1120
1115static int mt9t112_remove(struct i2c_client *client) 1121static int mt9t112_remove(struct i2c_client *client)
1116{ 1122{
1117 struct mt9t112_priv *priv = to_mt9t112(client);
1118
1119 kfree(priv);
1120 return 0; 1123 return 0;
1121} 1124}
1122 1125