aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/mt9m111.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-03-13 05:08:20 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:21 -0400
commit09e231b35173313cd92e27532e5028f2042dcee4 (patch)
tree3ecda063aa52f954d2f797921bdce131d7f1cc28 /drivers/media/video/mt9m111.c
parent1cd3c0fa927084549005fc22e54d99684b314f14 (diff)
V4L/DVB (11024): soc-camera: separate S_FMT and S_CROP operations
As host and camera drivers become more complex, differences between S_FMT and S_CROP functionality grow, this patch separates them. 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.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index 7e6be36f0855..cdd1ddb51388 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -152,7 +152,7 @@ struct mt9m111 {
152 struct soc_camera_device icd; 152 struct soc_camera_device icd;
153 int model; /* V4L2_IDENT_MT9M11x* codes from v4l2-chip-ident.h */ 153 int model; /* V4L2_IDENT_MT9M11x* codes from v4l2-chip-ident.h */
154 enum mt9m111_context context; 154 enum mt9m111_context context;
155 unsigned int left, top, width, height; 155 struct v4l2_rect rect;
156 u32 pixfmt; 156 u32 pixfmt;
157 unsigned char autoexposure; 157 unsigned char autoexposure;
158 unsigned char datawidth; 158 unsigned char datawidth;
@@ -249,12 +249,13 @@ static int mt9m111_set_context(struct soc_camera_device *icd,
249 return reg_write(CONTEXT_CONTROL, valA); 249 return reg_write(CONTEXT_CONTROL, valA);
250} 250}
251 251
252static int mt9m111_setup_rect(struct soc_camera_device *icd) 252static int mt9m111_setup_rect(struct soc_camera_device *icd,
253 struct v4l2_rect *rect)
253{ 254{
254 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); 255 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
255 int ret, is_raw_format; 256 int ret, is_raw_format;
256 int width = mt9m111->width; 257 int width = rect->width;
257 int height = mt9m111->height; 258 int height = rect->height;
258 259
259 if ((mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR8) 260 if ((mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR8)
260 || (mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR16)) 261 || (mt9m111->pixfmt == V4L2_PIX_FMT_SBGGR16))
@@ -262,9 +263,9 @@ static int mt9m111_setup_rect(struct soc_camera_device *icd)
262 else 263 else
263 is_raw_format = 0; 264 is_raw_format = 0;
264 265
265 ret = reg_write(COLUMN_START, mt9m111->left); 266 ret = reg_write(COLUMN_START, rect->left);
266 if (!ret) 267 if (!ret)
267 ret = reg_write(ROW_START, mt9m111->top); 268 ret = reg_write(ROW_START, rect->top);
268 269
269 if (is_raw_format) { 270 if (is_raw_format) {
270 if (!ret) 271 if (!ret)
@@ -436,6 +437,22 @@ static int mt9m111_set_bus_param(struct soc_camera_device *icd, unsigned long f)
436 return 0; 437 return 0;
437} 438}
438 439
440static int mt9m111_set_crop(struct soc_camera_device *icd,
441 struct v4l2_rect *rect)
442{
443 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
444 int ret;
445
446 dev_dbg(&icd->dev, "%s left=%d, top=%d, width=%d, height=%d\n",
447 __func__, rect->left, rect->top, rect->width,
448 rect->height);
449
450 ret = mt9m111_setup_rect(icd, rect);
451 if (!ret)
452 mt9m111->rect = *rect;
453 return ret;
454}
455
439static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt) 456static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt)
440{ 457{
441 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); 458 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
@@ -486,23 +503,27 @@ static int mt9m111_set_pixfmt(struct soc_camera_device *icd, u32 pixfmt)
486} 503}
487 504
488static int mt9m111_set_fmt(struct soc_camera_device *icd, 505static int mt9m111_set_fmt(struct soc_camera_device *icd,
489 __u32 pixfmt, struct v4l2_rect *rect) 506 struct v4l2_format *f)
490{ 507{
491 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd); 508 struct mt9m111 *mt9m111 = container_of(icd, struct mt9m111, icd);
509 struct v4l2_pix_format *pix = &f->fmt.pix;
510 struct v4l2_rect rect = {
511 .left = mt9m111->rect.left,
512 .top = mt9m111->rect.top,
513 .width = pix->width,
514 .height = pix->height,
515 };
492 int ret; 516 int ret;
493 517
494 mt9m111->left = rect->left;
495 mt9m111->top = rect->top;
496 mt9m111->width = rect->width;
497 mt9m111->height = rect->height;
498
499 dev_dbg(&icd->dev, "%s fmt=%x left=%d, top=%d, width=%d, height=%d\n", 518 dev_dbg(&icd->dev, "%s fmt=%x left=%d, top=%d, width=%d, height=%d\n",
500 __func__, pixfmt, mt9m111->left, mt9m111->top, mt9m111->width, 519 __func__, pix->pixelformat, rect.left, rect.top, rect.width,
501 mt9m111->height); 520 rect.height);
502 521
503 ret = mt9m111_setup_rect(icd); 522 ret = mt9m111_setup_rect(icd, &rect);
523 if (!ret)
524 ret = mt9m111_set_pixfmt(icd, pix->pixelformat);
504 if (!ret) 525 if (!ret)
505 ret = mt9m111_set_pixfmt(icd, pixfmt); 526 mt9m111->rect = rect;
506 return ret; 527 return ret;
507} 528}
508 529
@@ -633,6 +654,7 @@ static struct soc_camera_ops mt9m111_ops = {
633 .release = mt9m111_release, 654 .release = mt9m111_release,
634 .start_capture = mt9m111_start_capture, 655 .start_capture = mt9m111_start_capture,
635 .stop_capture = mt9m111_stop_capture, 656 .stop_capture = mt9m111_stop_capture,
657 .set_crop = mt9m111_set_crop,
636 .set_fmt = mt9m111_set_fmt, 658 .set_fmt = mt9m111_set_fmt,
637 .try_fmt = mt9m111_try_fmt, 659 .try_fmt = mt9m111_try_fmt,
638 .query_bus_param = mt9m111_query_bus_param, 660 .query_bus_param = mt9m111_query_bus_param,
@@ -817,7 +839,7 @@ static int mt9m111_restore_state(struct soc_camera_device *icd)
817 839
818 mt9m111_set_context(icd, mt9m111->context); 840 mt9m111_set_context(icd, mt9m111->context);
819 mt9m111_set_pixfmt(icd, mt9m111->pixfmt); 841 mt9m111_set_pixfmt(icd, mt9m111->pixfmt);
820 mt9m111_setup_rect(icd); 842 mt9m111_setup_rect(icd, &mt9m111->rect);
821 mt9m111_set_flip(icd, mt9m111->hflip, MT9M111_RMB_MIRROR_COLS); 843 mt9m111_set_flip(icd, mt9m111->hflip, MT9M111_RMB_MIRROR_COLS);
822 mt9m111_set_flip(icd, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS); 844 mt9m111_set_flip(icd, mt9m111->vflip, MT9M111_RMB_MIRROR_ROWS);
823 mt9m111_set_global_gain(icd, icd->gain); 845 mt9m111_set_global_gain(icd, icd->gain);