From patchwork Sun Jul 24 20:07:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 7489 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Sun, 24 Jul 2011 20:07:23 +0000 Received: from casper.infradead.org [85.118.1.10] by localhost.localdomain with IMAP (fetchmail-6.3.17) for (single-drop); Sun, 24 Jul 2011 17:07:28 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Ql4xP-00031q-18; Sun, 24 Jul 2011 20:07:23 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752074Ab1GXUHJ (ORCPT + 1 other); Sun, 24 Jul 2011 16:07:09 -0400 Received: from mail-ey0-f171.google.com ([209.85.215.171]:64170 "EHLO mail-ey0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624Ab1GXUHJ (ORCPT ); Sun, 24 Jul 2011 16:07:09 -0400 Received: by eye22 with SMTP id 22so3148865eye.2 for ; Sun, 24 Jul 2011 13:07:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.34.201 with SMTP id m9mr1493546ebd.100.1311538027239; Sun, 24 Jul 2011 13:07:07 -0700 (PDT) Received: by 10.213.7.79 with HTTP; Sun, 24 Jul 2011 13:07:07 -0700 (PDT) Date: Sun, 24 Jul 2011 16:07:07 -0400 Message-ID: Subject: [PATCH] cx231xx: Provide signal lock status in G_INPUT From: Devin Heitmueller To: Linux Media Mailing List Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The attached patch reports the signal lock statistics to userland, which allows apps to know if there is a signal present even in cases where it cannot rely on G_TUNER since it won't make calls for such if the device lacks a tuner. Devin cx231xx: show real signal status in G_INPUT/ENUM_INPUT ioctl results From: Devin Heitmueller Make use of the signal state registers to properly populate the signal lock registers in the cx231xx driver. This allows applications to know whether there is a signal present even in devices which lack a tuner (since such apps typically won't call G_TUNER if no tuner is present). Signed-off-by: Devin Heitmueller diff --git a/drivers/media/video/cx231xx/cx231xx-video.c b/drivers/media/video/cx231xx/cx231xx-video.c index a69c24d..9ed56b7 100644 --- a/drivers/media/video/cx231xx/cx231xx-video.c +++ b/drivers/media/video/cx231xx/cx231xx-video.c @@ -1179,7 +1179,8 @@ static int vidioc_enum_input(struct file *file, void *priv, { struct cx231xx_fh *fh = priv; struct cx231xx *dev = fh->dev; - unsigned int n; + u32 gen_stat; + unsigned int ret, n; n = i->index; if (n >= MAX_CX231XX_INPUT) @@ -1198,6 +1199,20 @@ static int vidioc_enum_input(struct file *file, void *priv, i->std = dev->vdev->tvnorms; + /* If they are asking about the active input, read signal status */ + if (n == dev->video_input) { + ret = cx231xx_read_i2c_data(dev, VID_BLK_I2C_ADDRESS, + GEN_STAT, 2, &gen_stat, 4); + if (ret > 0) { + if ((gen_stat & FLD_VPRES) == 0x00) { + i->status |= V4L2_IN_ST_NO_SIGNAL; + } + if ((gen_stat & FLD_HLOCK) == 0x00) { + i->status |= V4L2_IN_ST_NO_H_LOCK; + } + } + } + return 0; }