aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9m111.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 10:53:23 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:19:20 -0400
commit96c75399544838e1752001c8abdde36dd459cf8f (patch)
treead2dfa46e1f83d3b9b3de07f835618b15b90b0a5 /drivers/media/video/mt9m111.c
parenta4c56fd8892e51d675f7665ddee4fd9d7e5c2cc3 (diff)
V4L/DVB (12536): soc-camera: remove .gain and .exposure struct soc_camera_device members
This makes the soc-camera interface for V4L2 subdevices thinner yet. Handle gain and exposure internally in each driver just like all other controls. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/mt9m111.c')
-rw-r--r--drivers/media/video/mt9m111.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index 186902f9be2e..90da699601ea 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -153,6 +153,7 @@ struct mt9m111 {
153 enum mt9m111_context context; 153 enum mt9m111_context context;
154 struct v4l2_rect rect; 154 struct v4l2_rect rect;
155 u32 pixfmt; 155 u32 pixfmt;
156 unsigned int gain;
156 unsigned char autoexposure; 157 unsigned char autoexposure;
157 unsigned char datawidth; 158 unsigned char datawidth;
158 unsigned int powered:1; 159 unsigned int powered:1;
@@ -513,7 +514,8 @@ static int mt9m111_set_pixfmt(struct i2c_client *client, u32 pixfmt)
513 ret = mt9m111_setfmt_yuv(client); 514 ret = mt9m111_setfmt_yuv(client);
514 break; 515 break;
515 default: 516 default:
516 dev_err(&client->dev, "Pixel format not handled : %x\n", pixfmt); 517 dev_err(&client->dev, "Pixel format not handled : %x\n",
518 pixfmt);
517 ret = -EINVAL; 519 ret = -EINVAL;
518 } 520 }
519 521
@@ -536,9 +538,9 @@ static int mt9m111_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *f)
536 }; 538 };
537 int ret; 539 int ret;
538 540
539 dev_dbg(&client->dev, "%s fmt=%x left=%d, top=%d, width=%d, height=%d\n", 541 dev_dbg(&client->dev,
540 __func__, pix->pixelformat, rect.left, rect.top, rect.width, 542 "%s fmt=%x left=%d, top=%d, width=%d, height=%d\n", __func__,
541 rect.height); 543 pix->pixelformat, rect.left, rect.top, rect.width, rect.height);
542 544
543 ret = mt9m111_make_rect(client, &rect); 545 ret = mt9m111_make_rect(client, &rect);
544 if (!ret) 546 if (!ret)
@@ -672,8 +674,10 @@ static const struct v4l2_queryctrl mt9m111_controls[] = {
672}; 674};
673 675
674static int mt9m111_resume(struct soc_camera_device *icd); 676static int mt9m111_resume(struct soc_camera_device *icd);
677static int mt9m111_suspend(struct soc_camera_device *icd, pm_message_t state);
675 678
676static struct soc_camera_ops mt9m111_ops = { 679static struct soc_camera_ops mt9m111_ops = {
680 .suspend = mt9m111_suspend,
677 .resume = mt9m111_resume, 681 .resume = mt9m111_resume,
678 .query_bus_param = mt9m111_query_bus_param, 682 .query_bus_param = mt9m111_query_bus_param,
679 .set_bus_param = mt9m111_set_bus_param, 683 .set_bus_param = mt9m111_set_bus_param,
@@ -714,13 +718,13 @@ static int mt9m111_get_global_gain(struct i2c_client *client)
714 718
715static int mt9m111_set_global_gain(struct i2c_client *client, int gain) 719static int mt9m111_set_global_gain(struct i2c_client *client, int gain)
716{ 720{
717 struct soc_camera_device *icd = client->dev.platform_data; 721 struct mt9m111 *mt9m111 = to_mt9m111(client);
718 u16 val; 722 u16 val;
719 723
720 if (gain > 63 * 2 * 2) 724 if (gain > 63 * 2 * 2)
721 return -EINVAL; 725 return -EINVAL;
722 726
723 icd->gain = gain; 727 mt9m111->gain = gain;
724 if ((gain >= 64 * 2) && (gain < 63 * 2 * 2)) 728 if ((gain >= 64 * 2) && (gain < 63 * 2 * 2))
725 val = (1 << 10) | (1 << 9) | (gain / 4); 729 val = (1 << 10) | (1 << 9) | (gain / 4);
726 else if ((gain >= 64) && (gain < 64 * 2)) 730 else if ((gain >= 64) && (gain < 64 * 2))
@@ -844,17 +848,26 @@ static int mt9m111_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
844 return ret; 848 return ret;
845} 849}
846 850
851static int mt9m111_suspend(struct soc_camera_device *icd, pm_message_t state)
852{
853 struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd));
854 struct mt9m111 *mt9m111 = to_mt9m111(client);
855
856 mt9m111->gain = mt9m111_get_global_gain(client);
857
858 return 0;
859}
860
847static int mt9m111_restore_state(struct i2c_client *client) 861static int mt9m111_restore_state(struct i2c_client *client)
848{ 862{
849 struct mt9m111 *mt9m111 = to_mt9m111(client); 863 struct mt9m111 *mt9m111 = to_mt9m111(client);
850 struct soc_camera_device *icd = client->dev.platform_data;
851 864
852 mt9m111_set_context(client, mt9m111->context); 865 mt9m111_set_context(client, mt9m111->context);
853 mt9m111_set_pixfmt(client, mt9m111->pixfmt); 866 mt9m111_set_pixfmt(client, mt9m111->pixfmt);
854 mt9m111_setup_rect(client, &mt9m111->rect); 867 mt9m111_setup_rect(client, &mt9m111->rect);
855 mt9m111_set_flip(client, mt9m111->hflip, MT9M111_RMB_MIRROR_COLS); 868 mt9m111_set_flip(client, mt9m111->hflip, MT9M111_RMB_MIRROR_COLS);
856 mt9m111_set_flip(client, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS); 869 mt9m111_set_flip(client, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS);
857 mt9m111_set_global_gain(client, icd->gain); 870 mt9m111_set_global_gain(client, mt9m111->gain);
858 mt9m111_set_autoexposure(client, mt9m111->autoexposure); 871 mt9m111_set_autoexposure(client, mt9m111->autoexposure);
859 mt9m111_set_autowhitebalance(client, mt9m111->autowhitebalance); 872 mt9m111_set_autowhitebalance(client, mt9m111->autowhitebalance);
860 return 0; 873 return 0;