From patchwork Sat Oct 31 23:14:51 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: 56805 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 n9VNEwQG029394 for ; Sat, 31 Oct 2009 23:14:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933368AbZJaXOw (ORCPT ); Sat, 31 Oct 2009 19:14:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S933367AbZJaXOw (ORCPT ); Sat, 31 Oct 2009 19:14:52 -0400 Received: from mail02d.mail.t-online.hu ([84.2.42.7]:52396 "EHLO mail02d.mail.t-online.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933364AbZJaXOv (ORCPT ); Sat, 31 Oct 2009 19:14:51 -0400 X-Authuid: nmarci Received: from [192.168.1.64] (dsl5402C4D0.pool.t-online.hu [84.2.196.208]) (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 D2407758673; Sun, 1 Nov 2009 00:14:46 +0100 (CET) Message-ID: <4AECC4EB.7070504@freemail.hu> Date: Sun, 01 Nov 2009 00:14:51 +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 , Hans de Goede , V4L Mailing List CC: Thomas Kaiser , Theodore Kilgore , Kyle Guinn Subject: [PATCH 09/21] gspca pac7302/pac7311: separate dq_callback X-DCC-mail.t-online.hu-Metrics: mail02d.mail.t-online.hu 32721; Body=6 Fuz1=6 Fuz2=6 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org diff -uprN i/drivers/media/video/gspca/pac7311.c j/drivers/media/video/gspca/pac7311.c --- i/drivers/media/video/gspca/pac7311.c 2009-10-30 17:59:39.000000000 +0100 +++ j/drivers/media/video/gspca/pac7311.c 2009-10-30 18:00:55.000000000 +0100 @@ -820,7 +820,7 @@ static void pac7311_sd_stop0(struct gspc /* Include pac common sof detection functions */ #include "pac_common.h" -static void do_autogain(struct gspca_dev *gspca_dev) +static void pac7302_do_autogain(struct gspca_dev *gspca_dev) { struct sd *sd = (struct sd *) gspca_dev; int avg_lum = atomic_read(&sd->avg_lum); @@ -829,22 +829,36 @@ static void do_autogain(struct gspca_dev if (avg_lum == -1) return; - if (sd->sensor == SENSOR_PAC7302) { - desired_lum = 270 + sd->brightness * 4; - /* Hack hack, with the 7202 the first exposure step is - pretty large, so if we're about to make the first - exposure increase make the deadzone large to avoid - oscilating */ - if (desired_lum > avg_lum && sd->gain == GAIN_DEF && - sd->exposure > EXPOSURE_DEF && - sd->exposure < 42) - deadzone = 90; - else - deadzone = 30; - } else { - desired_lum = 200; - deadzone = 20; - } + desired_lum = 270 + sd->brightness * 4; + /* Hack hack, with the 7202 the first exposure step is + pretty large, so if we're about to make the first + exposure increase make the deadzone large to avoid + oscilating */ + if (desired_lum > avg_lum && sd->gain == GAIN_DEF && + sd->exposure > EXPOSURE_DEF && + sd->exposure < 42) + deadzone = 90; + else + deadzone = 30; + + if (sd->autogain_ignore_frames > 0) + sd->autogain_ignore_frames--; + else if (gspca_auto_gain_n_exposure(gspca_dev, avg_lum, desired_lum, + deadzone, GAIN_KNEE, EXPOSURE_KNEE)) + sd->autogain_ignore_frames = PAC_AUTOGAIN_IGNORE_FRAMES; +} + +static void pac7311_do_autogain(struct gspca_dev *gspca_dev) +{ + struct sd *sd = (struct sd *) gspca_dev; + int avg_lum = atomic_read(&sd->avg_lum); + int desired_lum, deadzone; + + if (avg_lum == -1) + return; + + desired_lum = 200; + deadzone = 20; if (sd->autogain_ignore_frames > 0) sd->autogain_ignore_frames--; @@ -1180,7 +1194,7 @@ static struct sd_desc pac7302_sd_desc = .stopN = pac7302_sd_stopN, .stop0 = pac7302_sd_stop0, .pkt_scan = pac7302_sd_pkt_scan, - .dq_callback = do_autogain, + .dq_callback = pac7302_do_autogain, }; /* sub-driver description for pac7311 */ @@ -1194,7 +1208,7 @@ static struct sd_desc pac7311_sd_desc = .stopN = pac7311_sd_stopN, .stop0 = pac7311_sd_stop0, .pkt_scan = pac7311_sd_pkt_scan, - .dq_callback = do_autogain, + .dq_callback = pac7311_do_autogain, }; /* -- module initialisation -- */