From patchwork Fri Sep 3 01:09:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Walls X-Patchwork-Id: 151781 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o831A5Q8029357 for ; Fri, 3 Sep 2010 01:10:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752045Ab0ICBJ5 (ORCPT ); Thu, 2 Sep 2010 21:09:57 -0400 Received: from proofpoint-cluster.metrocast.net ([65.175.128.136]:24801 "EHLO proofpoint-cluster.metrocast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750773Ab0ICBJ5 (ORCPT ); Thu, 2 Sep 2010 21:09:57 -0400 Received: from [192.168.1.7] (d-216-36-24-245.cpe.metrocast.net [216.36.24.245]) (authenticated bits=0) by pear.metrocast.net (8.13.8/8.13.8) with ESMTP id o8319nJl002388; Fri, 3 Sep 2010 01:09:49 GMT Subject: [PATCH] gspca_cpia1: Add lamp control for Intel Play QX3 microscope From: Andy Walls To: linux-media@vger.kernel.org Cc: Hans de Goede Date: Thu, 02 Sep 2010 21:09:42 -0400 Message-ID: <1283476182.17527.4.camel@morgan.silverblock.net> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.0.10011, 1.0.148, 0.0.0000 definitions=2010-09-02_15:2010-09-02, 2010-09-02, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=5.0.0-1005130000 definitions=main-1009020207 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 03 Sep 2010 01:10:06 +0000 (UTC) diff -r a4c762698bcb -r 0d251a2976b4 linux/drivers/media/video/gspca/cpia1.c --- a/linux/drivers/media/video/gspca/cpia1.c Wed Aug 25 16:13:54 2010 -0300 +++ b/linux/drivers/media/video/gspca/cpia1.c Thu Sep 02 21:03:52 2010 -0400 @@ -333,8 +333,8 @@ } format; struct { /* Intel QX3 specific data */ u8 qx3_detected; /* a QX3 is present */ - u8 toplight; /* top light lit , R/W */ - u8 bottomlight; /* bottom light lit, R/W */ + u8 toplamp; /* top lamp lit , R/W */ + u8 bottomlamp; /* bottom lamp lit, R/W */ u8 button; /* snapshot button pressed (R/O) */ u8 cradled; /* microscope is in cradle (R/O) */ } qx3; @@ -373,6 +373,8 @@ static int sd_getfreq(struct gspca_dev *gspca_dev, __s32 *val); static int sd_setcomptarget(struct gspca_dev *gspca_dev, __s32 val); static int sd_getcomptarget(struct gspca_dev *gspca_dev, __s32 *val); +static int sd_setlamps(struct gspca_dev *gspca_dev, __s32 val); +static int sd_getlamps(struct gspca_dev *gspca_dev, __s32 *val); static const struct ctrl sd_ctrls[] = { { @@ -447,6 +449,20 @@ .set = sd_setcomptarget, .get = sd_getcomptarget, }, + { + { +#define V4L2_CID_LAMPS (V4L2_CID_PRIVATE_BASE+1) + .id = V4L2_CID_LAMPS, + .type = V4L2_CTRL_TYPE_MENU, + .name = "Lamps", + .minimum = 0, + .maximum = 3, + .step = 1, + .default_value = 0, + }, + .set = sd_setlamps, + .get = sd_getlamps, + }, }; static const struct v4l2_pix_format mode[] = { @@ -766,8 +782,8 @@ params->compressionTarget.targetQ = 5; /* From windows driver */ params->qx3.qx3_detected = 0; - params->qx3.toplight = 0; - params->qx3.bottomlight = 0; + params->qx3.toplamp = 0; + params->qx3.bottomlamp = 0; params->qx3.button = 0; params->qx3.cradled = 0; } @@ -1059,17 +1075,16 @@ 0, sd->params.streamStartLine, 0, 0); } -#if 0 /* Currently unused */ /* keep */ -static int command_setlights(struct gspca_dev *gspca_dev) +static int command_setlamps(struct gspca_dev *gspca_dev) { struct sd *sd = (struct sd *) gspca_dev; - int ret, p1, p2; + int ret, p; if (!sd->params.qx3.qx3_detected) return 0; - p1 = (sd->params.qx3.bottomlight == 0) << 1; - p2 = (sd->params.qx3.toplight == 0) << 3; + p = (sd->params.qx3.toplamp == 0) ? 0x8 : 0; + p |= (sd->params.qx3.bottomlamp == 0) ? 0x2 : 0; ret = do_command(gspca_dev, CPIA_COMMAND_WriteVCReg, 0x90, 0x8F, 0x50, 0); @@ -1077,9 +1092,8 @@ return ret; return do_command(gspca_dev, CPIA_COMMAND_WriteMCPort, 2, 0, - p1 | p2 | 0xE0, 0); + p | 0xE0, 0); } -#endif static int set_flicker(struct gspca_dev *gspca_dev, int on, int apply) { @@ -1932,6 +1946,27 @@ return 0; } +static int sd_setlamps(struct gspca_dev *gspca_dev, __s32 val) +{ + struct sd *sd = (struct sd *) gspca_dev; + + sd->params.qx3.toplamp = (val & 0x2) ? 1 : 0; + sd->params.qx3.bottomlamp = (val & 0x1) ? 1 : 0; + + if (sd->params.qx3.qx3_detected) + return command_setlamps(gspca_dev); + + return 0; +} + +static int sd_getlamps(struct gspca_dev *gspca_dev, __s32 *val) +{ + struct sd *sd = (struct sd *) gspca_dev; + + *val = (sd->params.qx3.toplamp << 1) | (sd->params.qx3.bottomlamp << 0); + return 0; +} + static int sd_querymenu(struct gspca_dev *gspca_dev, struct v4l2_querymenu *menu) { @@ -1959,6 +1994,22 @@ return 0; } break; + case V4L2_CID_LAMPS: + switch (menu->index) { + case 0: + strcpy((char *) menu->name, "Off"); + return 0; + case 1: + strcpy((char *) menu->name, "Bottom"); + return 0; + case 2: + strcpy((char *) menu->name, "Top"); + return 0; + case 3: + strcpy((char *) menu->name, "Both"); + return 0; + } + break; } return -EINVAL; }