diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2009-03-13 05:08:20 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:21 -0400 |
commit | 09e231b35173313cd92e27532e5028f2042dcee4 (patch) | |
tree | 3ecda063aa52f954d2f797921bdce131d7f1cc28 /drivers/media/video/mt9v022.c | |
parent | 1cd3c0fa927084549005fc22e54d99684b314f14 (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/mt9v022.c')
-rw-r--r-- | drivers/media/video/mt9v022.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c index 6eb4b3a818d7..3871d4a2d8ff 100644 --- a/drivers/media/video/mt9v022.c +++ b/drivers/media/video/mt9v022.c | |||
@@ -340,32 +340,11 @@ static unsigned long mt9v022_query_bus_param(struct soc_camera_device *icd) | |||
340 | width_flag; | 340 | width_flag; |
341 | } | 341 | } |
342 | 342 | ||
343 | static int mt9v022_set_fmt(struct soc_camera_device *icd, | 343 | static int mt9v022_set_crop(struct soc_camera_device *icd, |
344 | __u32 pixfmt, struct v4l2_rect *rect) | 344 | struct v4l2_rect *rect) |
345 | { | 345 | { |
346 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
347 | int ret; | 346 | int ret; |
348 | 347 | ||
349 | /* The caller provides a supported format, as verified per call to | ||
350 | * icd->try_fmt(), datawidth is from our supported format list */ | ||
351 | switch (pixfmt) { | ||
352 | case V4L2_PIX_FMT_GREY: | ||
353 | case V4L2_PIX_FMT_Y16: | ||
354 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATM) | ||
355 | return -EINVAL; | ||
356 | break; | ||
357 | case V4L2_PIX_FMT_SBGGR8: | ||
358 | case V4L2_PIX_FMT_SBGGR16: | ||
359 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC) | ||
360 | return -EINVAL; | ||
361 | break; | ||
362 | case 0: | ||
363 | /* No format change, only geometry */ | ||
364 | break; | ||
365 | default: | ||
366 | return -EINVAL; | ||
367 | } | ||
368 | |||
369 | /* Like in example app. Contradicts the datasheet though */ | 348 | /* Like in example app. Contradicts the datasheet though */ |
370 | ret = reg_read(icd, MT9V022_AEC_AGC_ENABLE); | 349 | ret = reg_read(icd, MT9V022_AEC_AGC_ENABLE); |
371 | if (ret >= 0) { | 350 | if (ret >= 0) { |
@@ -403,6 +382,42 @@ static int mt9v022_set_fmt(struct soc_camera_device *icd, | |||
403 | return 0; | 382 | return 0; |
404 | } | 383 | } |
405 | 384 | ||
385 | static int mt9v022_set_fmt(struct soc_camera_device *icd, | ||
386 | struct v4l2_format *f) | ||
387 | { | ||
388 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
389 | struct v4l2_pix_format *pix = &f->fmt.pix; | ||
390 | struct v4l2_rect rect = { | ||
391 | .left = icd->x_current, | ||
392 | .top = icd->y_current, | ||
393 | .width = pix->width, | ||
394 | .height = pix->height, | ||
395 | }; | ||
396 | |||
397 | /* The caller provides a supported format, as verified per call to | ||
398 | * icd->try_fmt(), datawidth is from our supported format list */ | ||
399 | switch (pix->pixelformat) { | ||
400 | case V4L2_PIX_FMT_GREY: | ||
401 | case V4L2_PIX_FMT_Y16: | ||
402 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATM) | ||
403 | return -EINVAL; | ||
404 | break; | ||
405 | case V4L2_PIX_FMT_SBGGR8: | ||
406 | case V4L2_PIX_FMT_SBGGR16: | ||
407 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC) | ||
408 | return -EINVAL; | ||
409 | break; | ||
410 | case 0: | ||
411 | /* No format change, only geometry */ | ||
412 | break; | ||
413 | default: | ||
414 | return -EINVAL; | ||
415 | } | ||
416 | |||
417 | /* No support for scaling on this camera, just crop. */ | ||
418 | return mt9v022_set_crop(icd, &rect); | ||
419 | } | ||
420 | |||
406 | static int mt9v022_try_fmt(struct soc_camera_device *icd, | 421 | static int mt9v022_try_fmt(struct soc_camera_device *icd, |
407 | struct v4l2_format *f) | 422 | struct v4l2_format *f) |
408 | { | 423 | { |
@@ -544,6 +559,7 @@ static struct soc_camera_ops mt9v022_ops = { | |||
544 | .release = mt9v022_release, | 559 | .release = mt9v022_release, |
545 | .start_capture = mt9v022_start_capture, | 560 | .start_capture = mt9v022_start_capture, |
546 | .stop_capture = mt9v022_stop_capture, | 561 | .stop_capture = mt9v022_stop_capture, |
562 | .set_crop = mt9v022_set_crop, | ||
547 | .set_fmt = mt9v022_set_fmt, | 563 | .set_fmt = mt9v022_set_fmt, |
548 | .try_fmt = mt9v022_try_fmt, | 564 | .try_fmt = mt9v022_try_fmt, |
549 | .set_bus_param = mt9v022_set_bus_param, | 565 | .set_bus_param = mt9v022_set_bus_param, |