From patchwork Sun Nov 8 12:32:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?TsODwqltZXRoIE3Dg8KhcnRvbg==?= X-Patchwork-Id: 58521 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 nA8CWjCM006371 for ; Sun, 8 Nov 2009 12:32:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753127AbZKHMci (ORCPT ); Sun, 8 Nov 2009 07:32:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754001AbZKHMci (ORCPT ); Sun, 8 Nov 2009 07:32:38 -0500 Received: from mail02d.mail.t-online.hu ([84.2.42.7]:52758 "EHLO mail02d.mail.t-online.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752968AbZKHMch (ORCPT ); Sun, 8 Nov 2009 07:32:37 -0500 Received: from [192.168.1.64] (dsl5402C46E.pool.t-online.hu [84.2.196.110]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail02d.mail.t-online.hu (Postfix) with ESMTPSA id 74960758598; Sun, 8 Nov 2009 13:32:25 +0100 (CET) Message-ID: <4AF6BA67.1090700@freemail.hu> Date: Sun, 08 Nov 2009 13:32:39 +0100 From: =?UTF-8?B?TsOpbWV0aCBNw6FydG9u?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; hu-HU; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16 MIME-Version: 1.0 To: Hans de Goede , Jean-Francois Moine , V4L Mailing List Subject: [PATCH 2/2] gspca pac7302: add debug register write interface X-DCC-mail.t-online.hu-Metrics: mail02d.mail.t-online.hu 32721; Body=3 Fuz1=3 Fuz2=3 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff -upr b/linux/drivers/media/video/gspca/pac7302.c c/linux/drivers/media/video/gspca/pac7302.c --- b/linux/drivers/media/video/gspca/pac7302.c 2009-11-08 11:39:00.000000000 +0100 +++ c/linux/drivers/media/video/gspca/pac7302.c 2009-11-08 11:59:00.000000000 +0100 @@ -53,6 +53,7 @@ #define MODULE_NAME "pac7302" +#include #include "gspca.h" MODULE_AUTHOR("Thomas Kaiser thomas@kaiser-linux.li"); @@ -982,6 +983,55 @@ static int sd_getvflip(struct gspca_dev return 0; } +#ifdef CONFIG_VIDEO_ADV_DEBUG +static int sd_dbg_s_register(struct gspca_dev *gspca_dev, + struct v4l2_dbg_register *reg) +{ + int ret = -EINVAL; + __u8 index; + __u8 value; + + /* reg->reg: bit0..15: reserved for register index (wIndex is 16bit + long on the USB bus) + */ + if (reg->match.type == V4L2_CHIP_MATCH_HOST && + reg->match.addr == 0 && + (reg->reg < 0x000000ff) && + (reg->val <= 0x000000ff) + ) { + /* Currently writing to page 0 is only supported. */ + /* reg_w() only supports 8bit index */ + index = reg->reg & 0x000000ff; + value = reg->val & 0x000000ff; + + /* Note that there shall be no access to other page + by any other function between the page swith and + the actual register write */ + ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ + if (0 <= ret) + ret = reg_w(gspca_dev, index, value); + + if (0 <= ret) + ret = reg_w(gspca_dev, 0xdc, 0x01); + } + return ret; +} + +static int sd_chip_ident(struct gspca_dev *gspca_dev, + struct v4l2_dbg_chip_ident *chip) +{ + int ret = -EINVAL; + + if (chip->match.type == V4L2_CHIP_MATCH_HOST && + chip->match.addr == 0) { + chip->revision = 0; + chip->ident = V4L2_IDENT_UNKNOWN; + ret = 0; + } + return ret; +} +#endif + /* sub-driver description for pac7302 */ static struct sd_desc sd_desc = { .name = MODULE_NAME, @@ -994,6 +1044,10 @@ static struct sd_desc sd_desc = { .stop0 = sd_stop0, .pkt_scan = sd_pkt_scan, .dq_callback = do_autogain, +#ifdef CONFIG_VIDEO_ADV_DEBUG + .set_register = sd_dbg_s_register, + .get_chip_ident = sd_chip_ident, +#endif }; /* -- module initialisation -- */