summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-03-13 10:08:20 +0100
committerGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-03-13 10:08:20 +0100
commita00a0b74b7fe24e815f70f49ac8b8cc073cdad80 (patch)
treef16012aa64f3de3532962c5d7e6d3024d3a341aa /linux/drivers
parentedd96a81211ebded1ed720e24e5f81ffec94c455 (diff)
downloadmediapointer-dvb-s2-a00a0b74b7fe24e815f70f49ac8b8cc073cdad80.tar.gz
mediapointer-dvb-s2-a00a0b74b7fe24e815f70f49ac8b8cc073cdad80.tar.bz2
soc-camera: configure drivers with a default format at probe time
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Currently soc-camera doesn't set up any image format without an explicit S_FMT. According to the API this should be supported, for example, capture-example.c from v4l2-apps by default doesn't issue an S_FMT. This patch moves negotiating of available host-camera format translations to probe() time, and restores the state from the last close() on the next open(). This is needed for some drivers, which power down or reset hardware after the last user closes the interface. This patch also has a nice side-effect of avoiding multiple allocation anf freeing of format translation tables. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> --- drivers/media/video/soc_camera.c | 39 ++++++++++++++++++++++--------------- include/media/soc_camera.h | 1 + 2 files changed, 24 insertions(+), 16 deletions(-)
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/video/soc_camera.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/linux/drivers/media/video/soc_camera.c b/linux/drivers/media/video/soc_camera.c
index 10d8ecad1..da6d224eb 100644
--- a/linux/drivers/media/video/soc_camera.c
+++ b/linux/drivers/media/video/soc_camera.c
@@ -287,7 +287,9 @@ static int soc_camera_set_fmt(struct soc_camera_file *icf,
icd->width = pix->width;
icd->height = pix->height;
- icf->vb_vidq.field = pix->field;
+ icf->vb_vidq.field =
+ icd->field = pix->field;
+
if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n",
f->type);
@@ -340,27 +342,24 @@ static int soc_camera_open(struct file *file)
/* Now we really have to activate the camera */
if (icd->use_count == 1) {
+ /* Restore parameters before the last close() per V4L2 API */
struct v4l2_format f = {
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
.fmt.pix = {
- .width = DEFAULT_WIDTH,
- .height = DEFAULT_HEIGHT,
- .field = V4L2_FIELD_ANY,
+ .width = icd->width,
+ .height = icd->height,
+ .field = icd->field,
+ .pixelformat = icd->current_fmt->fourcc,
+ .colorspace = icd->current_fmt->colorspace,
},
};
- ret = soc_camera_init_user_formats(icd);
- if (ret < 0)
- goto eiufmt;
ret = ici->ops->add(icd);
if (ret < 0) {
dev_err(&icd->dev, "Couldn't activate the camera: %d\n", ret);
goto eiciadd;
}
- f.fmt.pix.pixelformat = icd->current_fmt->fourcc;
- f.fmt.pix.colorspace = icd->current_fmt->colorspace;
-
/* Try to configure with default parameters */
ret = soc_camera_set_fmt(icf, &f);
if (ret < 0)
@@ -383,8 +382,6 @@ static int soc_camera_open(struct file *file)
esfmt:
ici->ops->remove(icd);
eiciadd:
- soc_camera_free_user_formats(icd);
-eiufmt:
icd->use_count--;
mutex_unlock(&icd->video_lock);
module_put(ici->ops->owner);
@@ -404,10 +401,9 @@ static int soc_camera_close(struct file *file)
mutex_lock(&icd->video_lock);
icd->use_count--;
- if (!icd->use_count) {
+ if (!icd->use_count)
ici->ops->remove(icd);
- soc_camera_free_user_formats(icd);
- }
+
mutex_unlock(&icd->video_lock);
module_put(icd->ops->owner);
@@ -875,9 +871,18 @@ static int soc_camera_probe(struct device *dev)
qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE);
icd->exposure = qctrl ? qctrl->default_value :
(unsigned short)~0;
+
+ ret = soc_camera_init_user_formats(icd);
+ if (ret < 0)
+ goto eiufmt;
+
+ icd->height = DEFAULT_HEIGHT;
+ icd->width = DEFAULT_WIDTH;
+ icd->field = V4L2_FIELD_ANY;
}
- ici->ops->remove(icd);
+eiufmt:
+ ici->ops->remove(icd);
eiadd:
mutex_unlock(&icd->video_lock);
module_put(ici->ops->owner);
@@ -896,6 +901,8 @@ static int soc_camera_remove(struct device *dev)
if (icd->ops->remove)
icd->ops->remove(icd);
+ soc_camera_free_user_formats(icd);
+
return 0;
}