From patchwork Tue Nov 3 16:33:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: p.wiesner@gmx.net X-Patchwork-Id: 57330 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 nA3GWDWI027832 for ; Tue, 3 Nov 2009 16:33:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753803AbZKCQdX (ORCPT ); Tue, 3 Nov 2009 11:33:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753811AbZKCQdX (ORCPT ); Tue, 3 Nov 2009 11:33:23 -0500 Received: from mail.gmx.net ([213.165.64.20]:47735 "HELO mail.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753642AbZKCQdW (ORCPT ); Tue, 3 Nov 2009 11:33:22 -0500 Received: (qmail 24955 invoked by uid 0); 3 Nov 2009 16:33:25 -0000 Received: from 217.6.246.34 by www043.gmx.net with HTTP; Tue, 03 Nov 2009 17:33:23 +0100 (CET) Date: Tue, 03 Nov 2009 17:33:23 +0100 From: p.wiesner@gmx.net Message-ID: <20091103163323.46300@gmx.net> MIME-Version: 1.0 Subject: [PATCH] Adding multiple input support to soc-camera and tw9910 To: linux-media@vger.kernel.org X-Authenticated: #486415 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX1+Mnc8Vjq2MPdNwKsd5TIzS2xHGTczwDSMxKu+t+v eO6Hz+LHLHW2KEIkccAz9xoHx7+vsSAM2pYw== X-GMX-UID: ZG3DfnRaTXsuWXwIZmQ5rulCRzdyMsP3 X-FuHaFi: 0.44 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff -r 43878f8dbfb0 -r a5254e7d306a linux/drivers/media/video/soc_camera.c --- a/linux/drivers/media/video/soc_camera.c Sun Nov 01 07:17:46 2009 -0200 +++ b/linux/drivers/media/video/soc_camera.c Tue Nov 03 17:17:49 2009 +0100 @@ -119,11 +119,10 @@ struct soc_camera_device *icd = icf->icd; int ret = 0; - if (inp->index != 0) - return -EINVAL; - if (icd->ops->enum_input) ret = icd->ops->enum_input(icd, inp); + else if (inp->index != 0) + return -EINVAL; else { /* default is camera */ inp->type = V4L2_INPUT_TYPE_CAMERA; @@ -136,17 +135,30 @@ static int soc_camera_g_input(struct file *file, void *priv, unsigned int *i) { - *i = 0; + struct soc_camera_file *icf = file->private_data; + struct soc_camera_device *icd = icf->icd; + int ret = 0; - return 0; + if (icd->ops->g_input) + ret = icd->ops->g_input(icd, i); + else + *i = 0; + + return ret; } static int soc_camera_s_input(struct file *file, void *priv, unsigned int i) { - if (i > 0) + struct soc_camera_file *icf = file->private_data; + struct soc_camera_device *icd = icf->icd; + int ret = 0; + + if (icd->ops->s_input) + ret = icd->ops->s_input(icd, i); + else if (i > 0) return -EINVAL; - return 0; + return ret; } static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) diff -r 43878f8dbfb0 -r a5254e7d306a linux/drivers/media/video/tw9910.c --- a/linux/drivers/media/video/tw9910.c Sun Nov 01 07:17:46 2009 -0200 +++ b/linux/drivers/media/video/tw9910.c Tue Nov 03 17:17:49 2009 +0100 @@ -566,9 +566,47 @@ static int tw9910_enum_input(struct soc_camera_device *icd, struct v4l2_input *inp) { - inp->type = V4L2_INPUT_TYPE_TUNER; - inp->std = V4L2_STD_UNKNOWN; - strcpy(inp->name, "Video"); + switch (inp->index) { + case 0: + strcpy(inp->name, "Video Input 1"); + break; + case 1: + strcpy(inp->name, "Video Input 2"); + break; + case 2: + strcpy(inp->name, "Video Input 3"); + break; + case 3: + strcpy(inp->name, "Video Input 4"); + break; + default: + return -EINVAL; + } + + inp->type = V4L2_INPUT_TYPE_CAMERA; + inp->std = V4L2_STD_625_50 | V4L2_STD_525_60; + + return 0; +} + +static int tw9910_g_input(struct soc_camera_device *icd, unsigned int *i) +{ + struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); + + *i = (i2c_smbus_read_byte_data(client, INFORM) & 0x0C) >> 2; + + if (*i < 0) + return -EINVAL; + + return 0; +} + +static int tw9910_s_input(struct soc_camera_device *icd, unsigned int i) +{ + struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); + + if (tw9910_mask_set(client, INFORM, 0x0C, i << 2)) + return -EINVAL; return 0; } @@ -906,6 +944,8 @@ .set_bus_param = tw9910_set_bus_param, .query_bus_param = tw9910_query_bus_param, .enum_input = tw9910_enum_input, + .g_input = tw9910_g_input, + .s_input = tw9910_s_input, }; static struct v4l2_subdev_core_ops tw9910_subdev_core_ops = { diff -r 43878f8dbfb0 -r a5254e7d306a linux/include/media/soc_camera.h --- a/linux/include/media/soc_camera.h Sun Nov 01 07:17:46 2009 -0200 +++ b/linux/include/media/soc_camera.h Tue Nov 03 17:17:49 2009 +0100 @@ -197,6 +197,8 @@ unsigned long (*query_bus_param)(struct soc_camera_device *); int (*set_bus_param)(struct soc_camera_device *, unsigned long); int (*enum_input)(struct soc_camera_device *, struct v4l2_input *); + int (*g_input)(struct soc_camera_device *, unsigned int *); + int (*s_input)(struct soc_camera_device *, unsigned int); const struct v4l2_queryctrl *controls; int num_controls; };