From patchwork Thu Feb 19 15:20:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 7992 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1JFIKrh002436 for ; Thu, 19 Feb 2009 15:20:52 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751667AbZBSPUv (ORCPT ); Thu, 19 Feb 2009 10:20:51 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752124AbZBSPUv (ORCPT ); Thu, 19 Feb 2009 10:20:51 -0500 Received: from mail.gmx.net ([213.165.64.20]:37892 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751667AbZBSPUv (ORCPT ); Thu, 19 Feb 2009 10:20:51 -0500 Received: (qmail invoked by alias); 19 Feb 2009 15:20:47 -0000 Received: from p57BD2B28.dip0.t-ipconnect.de (EHLO axis700.grange) [87.189.43.40] by mail.gmx.net (mp051) with SMTP; 19 Feb 2009 16:20:47 +0100 X-Authenticated: #20450766 X-Provags-ID: V01U2FsdGVkX18ldVQfOpYl1d6+AyWwki1XdjBwIETKuWVSxmfcXi wjOcwkp/U+z9F9 Received: from lyakh (helo=localhost) by axis700.grange with local-esmtp (Exim 4.63) (envelope-from ) id 1LaAhs-0002DL-Vg; Thu, 19 Feb 2009 16:20:56 +0100 Date: Thu, 19 Feb 2009 16:20:56 +0100 (CET) From: Guennadi Liakhovetski To: Linux Media Mailing List cc: morimoto.kuninori@renesas.com Subject: [PATCH 2/2] soc-camera: configure drivers with a default format on open In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-FuHaFi: 0.42 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently soc-camera doesn't set up any image format without an explicit S_FMT. It seems this should be supported, since, for example, capture-example.c from v4l2-apps by default doesn't issue an S_FMT. This patch configures a default image format on open(). Signed-off-by: Guennadi Liakhovetski --- Morimoto-san, please, have a look how far these two patches take you, I lost the track of the problems a bit:-) Does capture-example work for you now without the "-f"? drivers/media/video/soc_camera.c | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 9939b04..4e88c7f 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -30,6 +30,10 @@ #include #include +/* Default to VGA resolution */ +#define DEFAULT_WIDTH 640 +#define DEFAULT_HEIGHT 480 + static LIST_HEAD(hosts); static LIST_HEAD(devices); static DEFINE_MUTEX(list_lock); @@ -297,6 +301,15 @@ static int soc_camera_open(struct file *file) /* Now we really have to activate the camera */ if (icd->use_count == 1) { + struct v4l2_format f = { + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, + .fmt.pix = { + .width = DEFAULT_WIDTH, + .height = DEFAULT_HEIGHT, + .field = V4L2_FIELD_ANY, + }, + }; + ret = soc_camera_init_user_formats(icd); if (ret < 0) goto eiufmt; @@ -305,6 +318,18 @@ static int soc_camera_open(struct file *file) 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 = ici->ops->set_fmt(icd, &f); + if (!ret) { + icd->width = f.fmt.pix.width; + icd->height = f.fmt.pix.height; + icf->vb_vidq.field = f.fmt.pix.field; + ici->ops->set_bus_param(icd, f.fmt.pix.pixelformat); + } } mutex_unlock(&icd->video_lock); @@ -444,8 +469,8 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, goto unlock; } - icd->width = f->fmt.pix.width; - icd->height = f->fmt.pix.height; + icd->width = pix->width; + icd->height = pix->height; icf->vb_vidq.field = pix->field; if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n", @@ -642,8 +667,8 @@ static int soc_camera_cropcap(struct file *file, void *fh, a->bounds.height = icd->height_max; a->defrect.left = icd->x_min; a->defrect.top = icd->y_min; - a->defrect.width = 640; - a->defrect.height = 480; + a->defrect.width = DEFAULT_WIDTH; + a->defrect.height = DEFAULT_HEIGHT; a->pixelaspect.numerator = 1; a->pixelaspect.denominator = 1;