~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/media/video/gspca/cpia1.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * cpia CPiA (1) gspca driver
3
3
 *
4
 
 * Copyright (C) 2010 Hans de Goede <hdegoede@redhat.com>
 
4
 * Copyright (C) 2010-2011 Hans de Goede <hdegoede@redhat.com>
5
5
 *
6
6
 * This module is adapted from the in kernel v4l1 cpia driver which is :
7
7
 *
28
28
 
29
29
#define MODULE_NAME "cpia1"
30
30
 
 
31
#include <linux/input.h>
31
32
#include "gspca.h"
32
33
 
33
34
MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
653
654
                break;
654
655
 
655
656
        case CPIA_COMMAND_ReadMCPorts:
656
 
                if (!sd->params.qx3.qx3_detected)
657
 
                        break;
658
657
                /* test button press */
659
 
                sd->params.qx3.button = ((gspca_dev->usb_buf[1] & 0x02) == 0);
 
658
                a = ((gspca_dev->usb_buf[1] & 0x02) == 0);
 
659
                if (a != sd->params.qx3.button) {
 
660
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
 
661
                        input_report_key(gspca_dev->input_dev, KEY_CAMERA, a);
 
662
                        input_sync(gspca_dev->input_dev);
 
663
#endif
 
664
                        sd->params.qx3.button = a;
 
665
                }
660
666
                if (sd->params.qx3.button) {
661
667
                        /* button pressed - unlock the latch */
662
668
                        do_command(gspca_dev, CPIA_COMMAND_WriteMCPort,
1256
1262
static void monitor_exposure(struct gspca_dev *gspca_dev)
1257
1263
{
1258
1264
        struct sd *sd = (struct sd *) gspca_dev;
1259
 
        u8 exp_acc, bcomp, gain, coarseL, cmd[8];
 
1265
        u8 exp_acc, bcomp, cmd[8];
1260
1266
        int ret, light_exp, dark_exp, very_dark_exp;
1261
1267
        int old_exposure, new_exposure, framerate;
1262
1268
        int setfps = 0, setexp = 0, setflicker = 0;
1278
1284
        }
1279
1285
        exp_acc = gspca_dev->usb_buf[0];
1280
1286
        bcomp = gspca_dev->usb_buf[1];
1281
 
        gain = gspca_dev->usb_buf[2];
1282
 
        coarseL = gspca_dev->usb_buf[3];
1283
1287
 
1284
1288
        light_exp = sd->params.colourParams.brightness +
1285
1289
                    TC - 50 + EXP_ACC_LIGHT;
1400
1404
                if ((sd->exposure_status == EXPOSURE_VERY_DARK ||
1401
1405
                     sd->exposure_status == EXPOSURE_DARK) &&
1402
1406
                    sd->exposure_count >= DARK_TIME * framerate &&
1403
 
                    sd->params.sensorFps.divisor < 3) {
 
1407
                    sd->params.sensorFps.divisor < 2) {
1404
1408
 
1405
1409
                        /* dark for too long */
1406
1410
                        ++sd->params.sensorFps.divisor;
1456
1460
                if ((sd->exposure_status == EXPOSURE_VERY_DARK ||
1457
1461
                     sd->exposure_status == EXPOSURE_DARK) &&
1458
1462
                    sd->exposure_count >= DARK_TIME * framerate &&
1459
 
                    sd->params.sensorFps.divisor < 3) {
 
1463
                    sd->params.sensorFps.divisor < 2) {
1460
1464
 
1461
1465
                        /* dark for too long */
1462
1466
                        ++sd->params.sensorFps.divisor;
1738
1742
 
1739
1743
static void sd_stopN(struct gspca_dev *gspca_dev)
1740
1744
{
 
1745
        struct sd *sd = (struct sd *) gspca_dev;
 
1746
 
1741
1747
        command_pause(gspca_dev);
1742
1748
 
1743
1749
        /* save camera state for later open (developers guide ch 3.5.3) */
1748
1754
 
1749
1755
        /* Update the camera status */
1750
1756
        do_command(gspca_dev, CPIA_COMMAND_GetCameraStatus, 0, 0, 0, 0);
 
1757
 
 
1758
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
 
1759
        /* If the last button state is pressed, release it now! */
 
1760
        if (sd->params.qx3.button) {
 
1761
                /* The camera latch will hold the pressed state until we reset
 
1762
                   the latch, so we do not reset sd->params.qx3.button now, to
 
1763
                   avoid a false keypress being reported the next sd_start */
 
1764
                input_report_key(gspca_dev->input_dev, KEY_CAMERA, 0);
 
1765
                input_sync(gspca_dev->input_dev);
 
1766
        }
 
1767
#endif
1751
1768
}
1752
1769
 
1753
1770
/* this function is called at probe and resume time */
1754
1771
static int sd_init(struct gspca_dev *gspca_dev)
1755
1772
{
1756
 
#ifdef GSPCA_DEBUG
1757
1773
        struct sd *sd = (struct sd *) gspca_dev;
1758
 
#endif
1759
1774
        int ret;
1760
1775
 
1761
1776
        /* Start / Stop the camera to make sure we are talking to
1852
1867
 
1853
1868
        /* Update our knowledge of the camera state */
1854
1869
        do_command(gspca_dev, CPIA_COMMAND_GetExposure, 0, 0, 0, 0);
1855
 
        if (sd->params.qx3.qx3_detected)
1856
 
                do_command(gspca_dev, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
 
1870
        do_command(gspca_dev, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
1857
1871
}
1858
1872
 
1859
1873
static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
2085
2099
        .dq_callback = sd_dq_callback,
2086
2100
        .pkt_scan = sd_pkt_scan,
2087
2101
        .querymenu = sd_querymenu,
 
2102
#if defined(CONFIG_INPUT) || defined(CONFIG_INPUT_MODULE)
 
2103
        .other_input = 1,
 
2104
#endif
2088
2105
};
2089
2106
 
2090
2107
/* -- module initialisation -- */