diff options
author | Guennadi Liakhovetski <g.liakhovetski@pengutronix.de> | 2008-03-07 19:57:18 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:07:49 -0400 |
commit | ad5f2e859d76dccb7eb1aa942171b1a32211efc2 (patch) | |
tree | 1716d5c82322d55886de36dddd9535b90dd57630 /drivers/media/video/soc_camera.c | |
parent | 1c659689fe9959c017bfaaa8301243f7d99f1a46 (diff) |
V4L/DVB (7336): soc-camera: streamline hardware parameter negotiation
Improve hardware parameter negotiation between the camera host driver and
camera drivers. Parameters like horizontal and vertical synchronisation,
pixel clock polarity shall be set depending on capabilities of the
parties.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/soc_camera.c')
-rw-r--r-- | drivers/media/video/soc_camera.c | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 322f837bcfea..bd8677cb1cab 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -75,12 +75,13 @@ static int soc_camera_try_fmt_cap(struct file *file, void *priv, | |||
75 | return -EINVAL; | 75 | return -EINVAL; |
76 | } | 76 | } |
77 | 77 | ||
78 | /* limit to host capabilities */ | 78 | /* test physical bus parameters */ |
79 | ret = ici->try_fmt_cap(ici, f); | 79 | ret = ici->try_bus_param(icd, f->fmt.pix.pixelformat); |
80 | if (ret) | ||
81 | return ret; | ||
80 | 82 | ||
81 | /* limit to sensor capabilities */ | 83 | /* limit format to hardware capabilities */ |
82 | if (!ret) | 84 | ret = ici->try_fmt_cap(icd, f); |
83 | ret = icd->ops->try_fmt_cap(icd, f); | ||
84 | 85 | ||
85 | /* calculate missing fields */ | 86 | /* calculate missing fields */ |
86 | f->fmt.pix.field = field; | 87 | f->fmt.pix.field = field; |
@@ -344,8 +345,8 @@ static int soc_camera_s_fmt_cap(struct file *file, void *priv, | |||
344 | if (!data_fmt) | 345 | if (!data_fmt) |
345 | return -EINVAL; | 346 | return -EINVAL; |
346 | 347 | ||
347 | /* cached_datawidth may be further adjusted by the ici */ | 348 | /* buswidth may be further adjusted by the ici */ |
348 | icd->cached_datawidth = data_fmt->depth; | 349 | icd->buswidth = data_fmt->depth; |
349 | 350 | ||
350 | ret = soc_camera_try_fmt_cap(file, icf, f); | 351 | ret = soc_camera_try_fmt_cap(file, icf, f); |
351 | if (ret < 0) | 352 | if (ret < 0) |
@@ -355,22 +356,23 @@ static int soc_camera_s_fmt_cap(struct file *file, void *priv, | |||
355 | rect.top = icd->y_current; | 356 | rect.top = icd->y_current; |
356 | rect.width = f->fmt.pix.width; | 357 | rect.width = f->fmt.pix.width; |
357 | rect.height = f->fmt.pix.height; | 358 | rect.height = f->fmt.pix.height; |
358 | ret = ici->set_capture_format(icd, f->fmt.pix.pixelformat, &rect); | 359 | ret = ici->set_fmt_cap(icd, f->fmt.pix.pixelformat, &rect); |
360 | if (ret < 0) | ||
361 | return ret; | ||
359 | 362 | ||
360 | if (!ret) { | 363 | icd->current_fmt = data_fmt; |
361 | icd->current_fmt = data_fmt; | 364 | icd->width = rect.width; |
362 | icd->width = rect.width; | 365 | icd->height = rect.height; |
363 | icd->height = rect.height; | 366 | icf->vb_vidq.field = f->fmt.pix.field; |
364 | icf->vb_vidq.field = f->fmt.pix.field; | 367 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != f->type) |
365 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != f->type) | 368 | dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n", |
366 | dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n", | 369 | f->type); |
367 | f->type); | ||
368 | |||
369 | dev_dbg(&icd->dev, "set width: %d height: %d\n", | ||
370 | icd->width, icd->height); | ||
371 | } | ||
372 | 370 | ||
373 | return ret; | 371 | dev_dbg(&icd->dev, "set width: %d height: %d\n", |
372 | icd->width, icd->height); | ||
373 | |||
374 | /* set physical bus parameters */ | ||
375 | return ici->set_bus_param(icd, f->fmt.pix.pixelformat); | ||
374 | } | 376 | } |
375 | 377 | ||
376 | static int soc_camera_enum_fmt_cap(struct file *file, void *priv, | 378 | static int soc_camera_enum_fmt_cap(struct file *file, void *priv, |
@@ -577,7 +579,7 @@ static int soc_camera_s_crop(struct file *file, void *fh, | |||
577 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 579 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
578 | return -EINVAL; | 580 | return -EINVAL; |
579 | 581 | ||
580 | ret = ici->set_capture_format(icd, 0, &a->c); | 582 | ret = ici->set_fmt_cap(icd, 0, &a->c); |
581 | if (!ret) { | 583 | if (!ret) { |
582 | icd->width = a->c.width; | 584 | icd->width = a->c.width; |
583 | icd->height = a->c.height; | 585 | icd->height = a->c.height; |
@@ -860,9 +862,6 @@ int soc_camera_device_register(struct soc_camera_device *icd) | |||
860 | 862 | ||
861 | icd->dev.release = dummy_release; | 863 | icd->dev.release = dummy_release; |
862 | 864 | ||
863 | if (icd->ops->get_datawidth) | ||
864 | icd->cached_datawidth = icd->ops->get_datawidth(icd); | ||
865 | |||
866 | return scan_add_device(icd); | 865 | return scan_add_device(icd); |
867 | } | 866 | } |
868 | EXPORT_SYMBOL(soc_camera_device_register); | 867 | EXPORT_SYMBOL(soc_camera_device_register); |