From patchwork Mon May 9 19:53:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Ringel X-Patchwork-Id: 6573 Return-path: Envelope-to: mchehab@gaivota Delivery-date: Mon, 09 May 2011 21:55:02 +0200 Received: from mchehab by gaivota with local (Exim 4.73) (envelope-from ) id 1QJWXm-0001kX-Nt for mchehab@gaivota; Mon, 09 May 2011 21:55:02 +0200 Received: from casper.infradead.org [85.118.1.10] by gaivota with IMAP (fetchmail-6.3.19) for (single-drop); Mon, 09 May 2011 21:55:02 +0200 (CEST) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1QJWXY-0001qS-Vd; Mon, 09 May 2011 19:54:49 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754135Ab1EITyf (ORCPT + 1 other); Mon, 9 May 2011 15:54:35 -0400 Received: from mail-in-03.arcor-online.net ([151.189.21.43]:57255 "EHLO mail-in-03.arcor-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754433Ab1EITyM (ORCPT ); Mon, 9 May 2011 15:54:12 -0400 Received: from mail-in-15-z2.arcor-online.net (mail-in-15-z2.arcor-online.net [151.189.8.32]) by mx.arcor.de (Postfix) with ESMTP id 19C3BD7D82; Mon, 9 May 2011 21:54:11 +0200 (CEST) Received: from mail-in-14.arcor-online.net (mail-in-14.arcor-online.net [151.189.21.54]) by mail-in-15-z2.arcor-online.net (Postfix) with ESMTP id 0A59933E0C8; Mon, 9 May 2011 21:54:11 +0200 (CEST) Received: from localhost.localdomain (dslb-178-000-053-073.pools.arcor-ip.net [178.0.53.73]) (Authenticated sender: stefan.ringel@arcor.de) by mail-in-14.arcor-online.net (Postfix) with ESMTPA id ACACD9C609; Mon, 9 May 2011 21:54:10 +0200 (CEST) X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-14.arcor-online.net ACACD9C609 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arcor.de; s=mail-in; t=1304970851; bh=kF39lXern9LEp8TqwnU3ZsMIuv3fzU3ZA0OGfWIVhzI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=oyWJtJa8/ZvgsngYFk66UbGWKdcZ+sS/mRpLKzCNfVqbtE/ahXw196fFZnC3V6mq8 I5sxjD6jXJiUNk9Y8/a5GTjPT7DKJrW+DH9CWgHv+fkReYGmNTYAE5h4E1tOkCJ7Wj 1RBYm6PFswFMoEZ+JzTKdqlBPBn5uo8LJdoX/gGg= From: stefan.ringel@arcor.de To: linux-media@vger.kernel.org Cc: mchehab@redhat.com, d.belimov@gmail.com, Stefan Ringel Subject: [PATCH 04/16] tm6000: vitual input enums Date: Mon, 9 May 2011 21:53:52 +0200 Message-Id: <1304970844-20955-4-git-send-email-stefan.ringel@arcor.de> X-Mailer: git-send-email 1.7.4.2 In-Reply-To: <1304970844-20955-1-git-send-email-stefan.ringel@arcor.de> References: <1304970844-20955-1-git-send-email-stefan.ringel@arcor.de> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: Mauro Carvalho Chehab From: Stefan Ringel vitual input enums Signed-off-by: Stefan Ringel --- drivers/staging/tm6000/tm6000-video.c | 100 +++++++++++++++++++-------------- 1 files changed, 57 insertions(+), 43 deletions(-) diff --git a/drivers/staging/tm6000/tm6000-video.c b/drivers/staging/tm6000/tm6000-video.c index e1a7eb2..8b3bf7e 100644 --- a/drivers/staging/tm6000/tm6000-video.c +++ b/drivers/staging/tm6000/tm6000-video.c @@ -1083,35 +1083,37 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *norm) return 0; } +static const char *iname [] = { + [TM6000_INPUT_TV] = "Television", + [TM6000_INPUT_COMPOSITE1] = "Composite 1", + [TM6000_INPUT_COMPOSITE2] = "Composite 2", + [TM6000_INPUT_SVIDEO] = "S-Video", +}; + static int vidioc_enum_input(struct file *file, void *priv, - struct v4l2_input *inp) + struct v4l2_input *i) { struct tm6000_fh *fh = priv; struct tm6000_core *dev = fh->dev; + unsigned int n; - switch (inp->index) { - case TM6000_INPUT_TV: - inp->type = V4L2_INPUT_TYPE_TUNER; - strcpy(inp->name, "Television"); - break; - case TM6000_INPUT_COMPOSITE: - if (dev->caps.has_input_comp) { - inp->type = V4L2_INPUT_TYPE_CAMERA; - strcpy(inp->name, "Composite"); - } else - return -EINVAL; - break; - case TM6000_INPUT_SVIDEO: - if (dev->caps.has_input_svid) { - inp->type = V4L2_INPUT_TYPE_CAMERA; - strcpy(inp->name, "S-Video"); - } else - return -EINVAL; - break; - default: + n = i->index; + if (n >= 3) return -EINVAL; - } - inp->std = TM6000_STD; + + if (!dev->vinput[n].type) + return -EINVAL; + + i->index = n; + + if (dev->vinput[n].type == TM6000_INPUT_TV) + i->type = V4L2_INPUT_TYPE_TUNER; + else + i->type = V4L2_INPUT_TYPE_CAMERA; + + strcpy(i->name, iname[dev->vinput[n].type]); + + i->std = TM6000_STD; return 0; } @@ -1125,33 +1127,21 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) return 0; } + static int vidioc_s_input(struct file *file, void *priv, unsigned int i) { struct tm6000_fh *fh = priv; struct tm6000_core *dev = fh->dev; int rc = 0; - char buf[1]; - switch (i) { - case TM6000_INPUT_TV: - dev->input = i; - *buf = 0; - break; - case TM6000_INPUT_COMPOSITE: - case TM6000_INPUT_SVIDEO: - dev->input = i; - *buf = 1; - break; - default: + if (i >= 3) + return -EINVAL; + if (!dev->vinput[i].type) return -EINVAL; - } - rc = tm6000_read_write_usb(dev, USB_DIR_OUT | USB_TYPE_VENDOR, - REQ_03_SET_GET_MCU_PIN, 0x03, 1, buf, 1); - if (!rc) { - dev->input = i; - rc = vidioc_s_std(file, priv, &dev->vfd->current_norm); - } + dev->input = i; + + rc = vidioc_s_std(file, priv, &dev->vfd->current_norm); return rc; } @@ -1379,9 +1369,15 @@ static int radio_s_tuner(struct file *file, void *priv, static int radio_enum_input(struct file *file, void *priv, struct v4l2_input *i) { + struct tm6000_fh *fh = priv; + struct tm6000_core *dev = fh->dev; + if (i->index != 0) return -EINVAL; + if (!dev->rinput.type) + return -EINVAL; + strcpy(i->name, "Radio"); i->type = V4L2_INPUT_TYPE_TUNER; @@ -1390,7 +1386,14 @@ static int radio_enum_input(struct file *file, void *priv, static int radio_g_input(struct file *filp, void *priv, unsigned int *i) { - *i = 0; + struct tm6000_fh *fh = priv; + struct tm6000_core *dev = fh->dev; + + if (dev->input !=5) + return -EINVAL; + + *i = dev->input -5; + return 0; } @@ -1410,6 +1413,17 @@ static int radio_s_audio(struct file *file, void *priv, static int radio_s_input(struct file *filp, void *priv, unsigned int i) { + struct tm6000_fh *fh = priv; + struct tm6000_core *dev = fh->dev; + + if (i) + return -EINVAL; + + if (!dev->rinput.type) + return -EINVAL; + + dev->input = i + 5; + return 0; }