From patchwork Sun Jul 19 04:10:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Johnson X-Patchwork-Id: 36219 X-Patchwork-Delegate: dougsland@redhat.com 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 n6J4BB0X019932 for ; Sun, 19 Jul 2009 04:11:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750736AbZGSEK4 (ORCPT ); Sun, 19 Jul 2009 00:10:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750806AbZGSEK4 (ORCPT ); Sun, 19 Jul 2009 00:10:56 -0400 Received: from qw-out-2122.google.com ([74.125.92.25]:61883 "EHLO qw-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbZGSEKz (ORCPT ); Sun, 19 Jul 2009 00:10:55 -0400 Received: by qw-out-2122.google.com with SMTP id 8so596625qwh.37 for ; Sat, 18 Jul 2009 21:10:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=KqLFqzoPmvnfpeFljtUQZk9G86h1pvnQSZRqKegyA/Q=; b=NPs7JLvo8+NlcxK7VIwoynOIQVnxb9It1Hm8aeGh2a4Ssh2pN6heCNxmKVgPTIwLrw IrJyqxf/2MydsufMI7WpL430s5vPkiUYGLf7UeumymB5ZKtAeLveApFhaRzViZxcjet/ Z59bloS2/rr3UzXYXCcLZMHuTH4oTnOQQTA8w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=b94MYl/K8tdt1y8mUwe0wKvv5nUlLI2QsMK4hTTZrV44ku+arkDJ0dCLmyZyKwVJJ8 lydx93JEBeDOQIG+iWfpjJ+w70pUDOH15Pzoc6LzSZq3+ncRs4093lBz2IUioW0wB403 gKiZg4nnpIOazchlSEllDLdu/0C7MMwHhoE+g= Received: by 10.224.80.135 with SMTP id t7mr1802358qak.375.1247976654661; Sat, 18 Jul 2009 21:10:54 -0700 (PDT) Received: from ubuntu.sys76.lan (c-24-11-127-139.hsd1.mi.comcast.net [24.11.127.139]) by mx.google.com with ESMTPS id 6sm4719867qwk.4.2009.07.18.21.10.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 18 Jul 2009 21:10:54 -0700 (PDT) Received: from bjohnson by ubuntu.sys76.lan with local (Exim 4.69) (envelope-from ) id 1MSNjg-0004UQ-Ru; Sun, 19 Jul 2009 00:10:52 -0400 From: Brian Johnson To: linux-media@vger.kernel.org Cc: Jean-Francois Moine , Mauro Carvalho Chehab , Brian Johnson Subject: [PATCH 1/2] gspca: add support for v4l2 debugging ioctls Date: Sun, 19 Jul 2009 00:10:51 -0400 Message-Id: <1247976652-17031-2-git-send-email-brijohn@gmail.com> X-Mailer: git-send-email 1.5.6.3 In-Reply-To: <1247976652-17031-1-git-send-email-brijohn@gmail.com> References: <1247976652-17031-1-git-send-email-brijohn@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch adds support for dbg_g_chip_ident, dbg_g_register, and dbg_s_register to the gspca core module. Signed-off-by: Brian Johnson --- drivers/media/video/gspca/gspca.c | 73 +++++++++++++++++++++++++++++++++++++ drivers/media/video/gspca/gspca.h | 9 +++++ 2 files changed, 82 insertions(+), 0 deletions(-) diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c index 1e89600..b8561df 100644 --- a/drivers/media/video/gspca/gspca.c +++ b/drivers/media/video/gspca/gspca.c @@ -727,6 +727,74 @@ static int gspca_get_mode(struct gspca_dev *gspca_dev, return -EINVAL; } +#ifdef CONFIG_VIDEO_ADV_DEBUG +static int vidioc_g_register(struct file *file, void *priv, + struct v4l2_dbg_register *reg) +{ + int ret; + struct gspca_dev *gspca_dev = priv; + + if (!gspca_dev->sd_desc->get_chip_ident) + return -EINVAL; + + if (!gspca_dev->sd_desc->get_register) + return -EINVAL; + + if (mutex_lock_interruptible(&gspca_dev->usb_lock)) + return -ERESTARTSYS; + if (gspca_dev->present) + ret = gspca_dev->sd_desc->get_register(gspca_dev, reg); + else + ret = -ENODEV; + mutex_unlock(&gspca_dev->usb_lock); + + return ret; +} + +static int vidioc_s_register(struct file *file, void *priv, + struct v4l2_dbg_register *reg) +{ + int ret; + struct gspca_dev *gspca_dev = priv; + + if (!gspca_dev->sd_desc->get_chip_ident) + return -EINVAL; + + if (!gspca_dev->sd_desc->set_register) + return -EINVAL; + + if (mutex_lock_interruptible(&gspca_dev->usb_lock)) + return -ERESTARTSYS; + if (gspca_dev->present) + ret = gspca_dev->sd_desc->set_register(gspca_dev, reg); + else + ret = -ENODEV; + mutex_unlock(&gspca_dev->usb_lock); + + return ret; +} +#endif + +static int vidioc_g_chip_ident(struct file *file, void *priv, + struct v4l2_dbg_chip_ident *chip) +{ + int ret; + struct gspca_dev *gspca_dev = priv; + + if (!gspca_dev->sd_desc->get_chip_ident) + return -EINVAL; + + if (mutex_lock_interruptible(&gspca_dev->usb_lock)) + return -ERESTARTSYS; + if (gspca_dev->present) + ret = gspca_dev->sd_desc->get_chip_ident(gspca_dev, chip); + else + ret = -ENODEV; + mutex_unlock(&gspca_dev->usb_lock); + + return ret; +} + static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *fmtdesc) { @@ -1883,6 +1951,11 @@ static const struct v4l2_ioctl_ops dev_ioctl_ops = { .vidioc_s_parm = vidioc_s_parm, .vidioc_s_std = vidioc_s_std, .vidioc_enum_framesizes = vidioc_enum_framesizes, +#ifdef CONFIG_VIDEO_ADV_DEBUG + .vidioc_g_register = vidioc_g_register, + .vidioc_s_register = vidioc_s_register, +#endif + .vidioc_g_chip_ident = vidioc_g_chip_ident, #ifdef CONFIG_VIDEO_V4L1_COMPAT .vidiocgmbuf = vidiocgmbuf, #endif diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h index bd1faff..46c4eff 100644 --- a/drivers/media/video/gspca/gspca.h +++ b/drivers/media/video/gspca/gspca.h @@ -69,6 +69,10 @@ typedef void (*cam_v_op) (struct gspca_dev *); typedef int (*cam_cf_op) (struct gspca_dev *, const struct usb_device_id *); typedef int (*cam_jpg_op) (struct gspca_dev *, struct v4l2_jpegcompression *); +typedef int (*cam_reg_op) (struct gspca_dev *, + struct v4l2_dbg_register *); +typedef int (*cam_ident_op) (struct gspca_dev *, + struct v4l2_dbg_chip_ident *); typedef int (*cam_streamparm_op) (struct gspca_dev *, struct v4l2_streamparm *); typedef int (*cam_qmnu_op) (struct gspca_dev *, @@ -105,6 +109,11 @@ struct sd_desc { cam_qmnu_op querymenu; cam_streamparm_op get_streamparm; cam_streamparm_op set_streamparm; +#ifdef CONFIG_VIDEO_ADV_DEBUG + cam_reg_op set_register; + cam_reg_op get_register; +#endif + cam_ident_op get_chip_ident; }; /* packet types when moving from iso buf to frame buf */