From patchwork Sun Nov 1 17:44:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 56885 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 nA1HijF9026989 for ; Sun, 1 Nov 2009 17:44:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753018AbZKARoT (ORCPT ); Sun, 1 Nov 2009 12:44:19 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753047AbZKARoS (ORCPT ); Sun, 1 Nov 2009 12:44:18 -0500 Received: from ppsw-0.csi.cam.ac.uk ([131.111.8.130]:59758 "EHLO ppsw-0.csi.cam.ac.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752966AbZKARoR (ORCPT ); Sun, 1 Nov 2009 12:44:17 -0500 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Received: from arcturus.eng.cam.ac.uk ([129.169.154.73]:54309) by ppsw-0.csi.cam.ac.uk (smtp.hermes.cam.ac.uk [131.111.8.150]:25) with esmtpsa (PLAIN:jic23) (TLSv1:DHE-RSA-AES256-SHA:256) id 1N4eTS-0005gM-17 (Exim 4.70) (return-path ); Sun, 01 Nov 2009 17:44:18 +0000 Message-ID: <4AEDC90A.7050005@cam.ac.uk> Date: Sun, 01 Nov 2009 17:44:42 +0000 From: Jonathan Cameron User-Agent: Thunderbird 2.0.0.23 (X11/20091029) MIME-Version: 1.0 To: dean_go Zhang CC: linux-arm-kernel@lists.infradead.org, Guennadi Liakhovetski , Linux Media Mailing List Subject: Re: Soc camera:Is there anyone dealing with ov9650chip?Let's talk about soc camera driver. References: <65c69abb0910300528j2bffc2b8i8eb07254725f8de7@mail.gmail.com> In-Reply-To: <65c69abb0910300528j2bffc2b8i8eb07254725f8de7@mail.gmail.com> X-Enigmail-Version: 0.96.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff --git a/drivers/media/video/ov7670.c b/drivers/media/video/ov7670.c index 0e2184e..910a499 100644 --- a/drivers/media/video/ov7670.c +++ b/drivers/media/video/ov7670.c @@ -19,6 +19,8 @@ #include #include +#include +#include MODULE_AUTHOR("Jonathan Corbet "); MODULE_DESCRIPTION("A low-level driver for OmniVision ov7670 sensors"); @@ -745,6 +747,10 @@ static int ov7670_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) struct ov7670_info *info = to_state(sd); unsigned char com7, clkrc = 0; + ret = ov7670_init(sd, 0); + if (ret) + return ret; + ret = ov7670_try_fmt_internal(sd, fmt, &ovfmt, &wsize); if (ret) return ret; @@ -1239,6 +1245,41 @@ static const struct v4l2_subdev_ops ov7670_ops = { }; /* ----------------------------------------------------------------------- */ +static unsigned long ov7670_soc_query_bus_param(struct soc_camera_device *icd) +{ + struct soc_camera_link *icl = to_soc_camera_link(icd); + + unsigned long flags = SOCAM_PCLK_SAMPLE_RISING | SOCAM_MASTER | + SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_HIGH | + SOCAM_DATAWIDTH_8 | SOCAM_DATA_ACTIVE_HIGH; + + return soc_camera_apply_sensor_flags(icl, flags); +} + +/* This device only supports one bus option */ +static int ov7670_soc_set_bus_param(struct soc_camera_device *icd, + unsigned long flags) +{ + return 0; +} + +static struct soc_camera_ops ov7670_soc_ops = { + .set_bus_param = ov7670_soc_set_bus_param, + .query_bus_param = ov7670_soc_query_bus_param, +}; + +#define SETFOURCC(type) .name = (#type), .fourcc = (V4L2_PIX_FMT_ ## type) +static const struct soc_camera_data_format ov7670_soc_fmt_lists[] = { + { + SETFOURCC(YUYV), + .depth = 16, + .colorspace = V4L2_COLORSPACE_JPEG, + }, { + SETFOURCC(RGB565), + .depth = 16, + .colorspace = V4L2_COLORSPACE_SRGB, + }, +}; static int ov7670_probe(struct i2c_client *client, const struct i2c_device_id *id) @@ -1246,7 +1287,16 @@ static int ov7670_probe(struct i2c_client *client, struct v4l2_subdev *sd; struct ov7670_info *info; int ret; + struct soc_camera_device *icd = client->dev.platform_data; + + if (!icd) { + dev_err(&client->dev, "OV7670: missing soc-camera data!\n"); + return -EINVAL; + } + icd->ops = &ov7670_soc_ops; + icd->formats = ov7670_soc_fmt_lists; + icd->num_formats = ARRAY_SIZE(ov7670_soc_fmt_lists); info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL); if (info == NULL) return -ENOMEM;