From patchwork Sat Nov 7 20:45:17 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: 58365 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 nA7KjUeY015706 for ; Sat, 7 Nov 2009 20:45:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751290AbZKGUpR (ORCPT ); Sat, 7 Nov 2009 15:45:17 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751658AbZKGUpR (ORCPT ); Sat, 7 Nov 2009 15:45:17 -0500 Received: from mail02a.mail.t-online.hu ([84.2.40.7]:55574 "EHLO mail02a.mail.t-online.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750996AbZKGUpQ (ORCPT ); Sat, 7 Nov 2009 15:45:16 -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 mail02a.mail.t-online.hu (Postfix) with ESMTPSA id 992C6256634; Sat, 7 Nov 2009 21:45:01 +0100 (CET) Message-ID: <4AF5DC5D.8050809@freemail.hu> Date: Sat, 07 Nov 2009 21:45:17 +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: Jean-Francois Moine , V4L Mailing List Subject: [PATCH] gspca pac7302: add edge detect control X-DCC-mail.t-online.hu-Metrics: mail02a.mail.t-online.hu 32721; Body=2 Fuz1=2 Fuz2=2 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-07 21:25:15.000000000 +0100 +++ c/linux/drivers/media/video/gspca/pac7302.c 2009-11-07 22:38:32.000000000 +0100 @@ -56,6 +56,7 @@ -----+------------+--------------------------------------------------- 0 | 0x0f..0x20 | setcolors() 0 | 0xa2..0xab | setbrightcont() + 0 | 0x55 | setedgedetect() 0 | 0xc5 | setredbalance() 0 | 0xc6 | setwhitebalance() 0 | 0xc7 | setbluebalance() @@ -89,6 +90,7 @@ struct sd { unsigned char autogain; __u8 hflip; __u8 vflip; + unsigned char edge_detect; u8 sof_read; u8 autogain_ignore_frames; @@ -119,6 +121,11 @@ static int sd_setgain(struct gspca_dev * static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val); static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val); static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val); +static int sd_setedgedetect(struct gspca_dev *gspca_dev, __s32 val); +static int sd_getedgedetect(struct gspca_dev *gspca_dev, __s32 *val); + +#define V4L2_CID_PRIVATE_EDGE_DETECT (V4L2_CID_PRIVATE_BASE+0) + static struct ctrl sd_ctrls[] = { /* This control is pac7302 only */ @@ -286,6 +293,21 @@ static struct ctrl sd_ctrls[] = { .set = sd_setvflip, .get = sd_getvflip, }, + { + { + .id = V4L2_CID_PRIVATE_EDGE_DETECT, + .type = V4L2_CTRL_TYPE_BOOLEAN, + .name = "Edge Detect", + .minimum = 0, + .maximum = 1, + .step = 1, +#define EDGE_DETECT_DEF 0 + .default_value = EDGE_DETECT_DEF, + }, + .set = sd_setedgedetect, + .get = sd_getedgedetect, + }, + }; static const struct v4l2_pix_format vga_mode[] = { @@ -572,6 +594,7 @@ static int sd_config(struct gspca_dev *g sd->autogain = AUTOGAIN_DEF; sd->hflip = HFLIP_DEF; sd->vflip = VFLIP_DEF; + sd->edge_detect = EDGE_DETECT_DEF; return 0; } @@ -740,6 +763,23 @@ static int sethvflip(struct gspca_dev *g return ret; } +static int setedgedetect(struct gspca_dev *gspca_dev) +{ + struct sd *sd = (struct sd *) gspca_dev; + int ret; + __u8 data; + + ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ + data = sd->edge_detect ? 0x04 : 0x00; + if (0 <= ret) + ret = reg_w(gspca_dev, 0x55, data); + + if (0 <= ret) + ret = reg_w(gspca_dev, 0xdc, 0x01); + + return ret; +} + /* this function is called at probe and resume time for pac7302 */ static int sd_init(struct gspca_dev *gspca_dev) { @@ -772,6 +812,8 @@ static int sd_start(struct gspca_dev *gs setexposure(gspca_dev); if (0 <= ret) sethvflip(gspca_dev); + if (0 <= ret) + ret = setedgedetect(gspca_dev); /* only resolution 640x480 is supported for pac7302 */ @@ -1164,6 +1206,24 @@ static int sd_getvflip(struct gspca_dev return 0; } +static int sd_setedgedetect(struct gspca_dev *gspca_dev, __s32 val) +{ + struct sd *sd = (struct sd *) gspca_dev; + + sd->edge_detect = val; + if (gspca_dev->streaming) + setedgedetect(gspca_dev); + return 0; +} + +static int sd_getedgedetect(struct gspca_dev *gspca_dev, __s32 *val) +{ + struct sd *sd = (struct sd *) gspca_dev; + + *val = sd->edge_detect; + return 0; +} + /* sub-driver description for pac7302 */ static struct sd_desc sd_desc = { .name = MODULE_NAME,