From patchwork Wed Mar 30 07:40:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 673442 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2U7eBol003007 for ; Wed, 30 Mar 2011 07:40:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753672Ab1C3Hkz (ORCPT ); Wed, 30 Mar 2011 03:40:55 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:65008 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752641Ab1C3Hky (ORCPT ); Wed, 30 Mar 2011 03:40:54 -0400 Received: from axis700.grange (pD9EB8E2E.dip0.t-ipconnect.de [217.235.142.46]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0LaYX5-1PhLa60ejf-00m8Z6; Wed, 30 Mar 2011 09:40:53 +0200 Received: by axis700.grange (Postfix, from userid 1000) id D47EE189B86; Wed, 30 Mar 2011 09:40:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id D17C7189B85; Wed, 30 Mar 2011 09:40:52 +0200 (CEST) Date: Wed, 30 Mar 2011 09:40:52 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Paolo Santinelli cc: Linux Media Mailing List Subject: [PATCH 1/2] V4L: soc-camera: add a livecrop host operation In-Reply-To: Message-ID: References: MIME-Version: 1.0 X-Provags-ID: V02:K0:WDNLhhLOceF2b+st1ixl8uUFtoqm+6+KjQcXHXu7WYW 8F5UpN0/Ef1SraWMtgAKVp2Qz8ftNVqvGGnXY8XZMZzYRVShzH f6CT7jVWi1ZhmNNn0LLCEYjYvybB5JK+8ZR+A9WA2R/s99XcJl wtp7PvT7eH5zLgowV1T4Mz0nB278ZCcRoZd3M6iUgQ5H4yYqZf K+9V8pIpR0GHQ4SFfbXTbPMBPt/r45fBVMmqgEYB+g= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 30 Mar 2011 07:40:57 +0000 (UTC) diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 2f0fd2f..11f0f1e 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -41,6 +41,11 @@ #define DEFAULT_WIDTH 640 #define DEFAULT_HEIGHT 480 +#define is_streaming(ici, icd) \ + (((ici)->ops->init_videobuf) ? \ + (icd)->vb_vidq.streaming : \ + vb2_is_streaming(&(icd)->vb2_vidq)) + static LIST_HEAD(hosts); static LIST_HEAD(devices); static DEFINE_MUTEX(list_lock); /* Protects the list of hosts */ @@ -626,7 +631,7 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, if (icd->streamer && icd->streamer != file) return -EBUSY; - if (icd->vb_vidq.bufs[0]) { + if (is_streaming(to_soc_camera_host(icd->dev.parent), icd)) { dev_err(&icd->dev, "S_FMT denied: queue initialised\n"); return -EBUSY; } @@ -867,14 +872,17 @@ static int soc_camera_s_crop(struct file *file, void *fh, if (ret < 0) { dev_err(&icd->dev, "S_CROP denied: getting current crop failed\n"); - } else if (icd->vb_vidq.bufs[0] && - (a->c.width != current_crop.c.width || - a->c.height != current_crop.c.height)) { + } else if ((a->c.width == current_crop.c.width && + a->c.height == current_crop.c.height) || + !is_streaming(ici, icd)) { + /* same size or not streaming - use .set_crop() */ + ret = ici->ops->set_crop(icd, a); + } else if (ici->ops->set_livecrop) { + ret = ici->ops->set_livecrop(icd, a); + } else { dev_err(&icd->dev, "S_CROP denied: queue initialised and sizes differ\n"); ret = -EBUSY; - } else { - ret = ici->ops->set_crop(icd, a); } return ret; diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h index f80b537..844cd09 100644 --- a/include/media/soc_camera.h +++ b/include/media/soc_camera.h @@ -80,6 +80,11 @@ struct soc_camera_host_ops { int (*cropcap)(struct soc_camera_device *, struct v4l2_cropcap *); int (*get_crop)(struct soc_camera_device *, struct v4l2_crop *); int (*set_crop)(struct soc_camera_device *, struct v4l2_crop *); + /* + * The difference to .set_crop() is, that .set_livecrop is not allowed + * to change the output sizes + */ + int (*set_livecrop)(struct soc_camera_device *, struct v4l2_crop *); int (*set_fmt)(struct soc_camera_device *, struct v4l2_format *); int (*try_fmt)(struct soc_camera_device *, struct v4l2_format *); void (*init_videobuf)(struct videobuf_queue *,