2019-05-31 17:09:32 +09:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2008-10-17 04:46:07 +09:00
|
|
|
/*
|
2008-10-01 16:51:53 +09:00
|
|
|
* USB Driver for ALi m5602 based webcams
|
|
|
|
*
|
2008-10-17 04:43:16 +09:00
|
|
|
* Copyright (C) 2008 Erik Andrén
|
2008-10-01 16:51:53 +09:00
|
|
|
* Copyright (C) 2007 Ilyes Gouta. Based on the m5603x Linux Driver Project.
|
|
|
|
* Copyright (C) 2005 m5603x Linux Driver Project <m5602@x3ng.com.br>
|
|
|
|
*
|
|
|
|
* Portions of code to USB interface and ALi driver software,
|
|
|
|
* Copyright (c) 2006 Willem Duinker
|
|
|
|
* v4l2 interface modeled after the V4L2 driver
|
|
|
|
* for SN9C10x PC Camera Controllers
|
|
|
|
*/
|
|
|
|
|
2011-08-22 07:56:52 +09:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
#include "m5602_ov9650.h"
|
2009-04-28 03:41:45 +09:00
|
|
|
#include "m5602_ov7660.h"
|
2008-10-01 16:51:53 +09:00
|
|
|
#include "m5602_mt9m111.h"
|
|
|
|
#include "m5602_po1030.h"
|
|
|
|
#include "m5602_s5k83a.h"
|
|
|
|
#include "m5602_s5k4aa.h"
|
|
|
|
|
|
|
|
/* Kernel module parameters */
|
|
|
|
int force_sensor;
|
2012-01-13 08:02:20 +09:00
|
|
|
static bool dump_bridge;
|
|
|
|
bool dump_sensor;
|
2008-10-01 16:51:53 +09:00
|
|
|
|
2011-01-13 17:20:29 +09:00
|
|
|
static const struct usb_device_id m5602_table[] = {
|
2008-10-01 16:51:53 +09:00
|
|
|
{USB_DEVICE(0x0402, 0x5602)},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, m5602_table);
|
|
|
|
|
2016-06-24 21:03:17 +09:00
|
|
|
/* A skeleton used for sending messages to the sensor */
|
|
|
|
static const unsigned char sensor_urb_skeleton[] = {
|
|
|
|
0x23, M5602_XB_GPIO_EN_H, 0x81, 0x06,
|
|
|
|
0x23, M5602_XB_MISC_CTRL, 0x81, 0x80,
|
|
|
|
0x13, M5602_XB_I2C_DEV_ADDR, 0x81, 0x00,
|
|
|
|
0x13, M5602_XB_I2C_REG_ADDR, 0x81, 0x00,
|
|
|
|
0x13, M5602_XB_I2C_DATA, 0x81, 0x00,
|
|
|
|
0x13, M5602_XB_I2C_CTRL, 0x81, 0x11
|
|
|
|
};
|
|
|
|
|
|
|
|
/* A skeleton used for sending messages to the m5602 bridge */
|
|
|
|
static const unsigned char bridge_urb_skeleton[] = {
|
|
|
|
0x13, 0x00, 0x81, 0x00
|
|
|
|
};
|
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
/* Reads a byte from the m5602 */
|
2009-02-02 15:51:20 +09:00
|
|
|
int m5602_read_bridge(struct sd *sd, const u8 address, u8 *i2c_data)
|
2008-10-01 16:51:53 +09:00
|
|
|
{
|
|
|
|
int err;
|
2013-02-05 01:17:55 +09:00
|
|
|
struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
|
2008-10-01 16:51:53 +09:00
|
|
|
struct usb_device *udev = sd->gspca_dev.dev;
|
|
|
|
__u8 *buf = sd->gspca_dev.usb_buf;
|
|
|
|
|
|
|
|
err = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
|
|
|
|
0x04, 0xc0, 0x14,
|
|
|
|
0x8100 + address, buf,
|
|
|
|
1, M5602_URB_MSG_TIMEOUT);
|
|
|
|
*i2c_data = buf[0];
|
|
|
|
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_CONF, "Reading bridge register 0x%x containing 0x%x\n",
|
|
|
|
address, *i2c_data);
|
2008-10-01 16:51:53 +09:00
|
|
|
|
|
|
|
/* usb_control_msg(...) returns the number of bytes sent upon success,
|
2009-01-03 22:55:52 +09:00
|
|
|
mask that and return zero instead*/
|
2008-10-01 16:51:53 +09:00
|
|
|
return (err < 0) ? err : 0;
|
|
|
|
}
|
|
|
|
|
2009-07-17 00:13:03 +09:00
|
|
|
/* Writes a byte to the m5602 */
|
2009-02-02 15:51:20 +09:00
|
|
|
int m5602_write_bridge(struct sd *sd, const u8 address, const u8 i2c_data)
|
2008-10-01 16:51:53 +09:00
|
|
|
{
|
|
|
|
int err;
|
2013-02-05 01:17:55 +09:00
|
|
|
struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
|
2008-10-01 16:51:53 +09:00
|
|
|
struct usb_device *udev = sd->gspca_dev.dev;
|
|
|
|
__u8 *buf = sd->gspca_dev.usb_buf;
|
|
|
|
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_CONF, "Writing bridge register 0x%x with 0x%x\n",
|
|
|
|
address, i2c_data);
|
2008-10-01 16:51:53 +09:00
|
|
|
|
|
|
|
memcpy(buf, bridge_urb_skeleton,
|
|
|
|
sizeof(bridge_urb_skeleton));
|
|
|
|
buf[1] = address;
|
|
|
|
buf[3] = i2c_data;
|
|
|
|
|
|
|
|
err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
|
|
|
|
0x04, 0x40, 0x19,
|
|
|
|
0x0000, buf,
|
|
|
|
4, M5602_URB_MSG_TIMEOUT);
|
|
|
|
|
|
|
|
/* usb_control_msg(...) returns the number of bytes sent upon success,
|
2009-01-03 22:55:52 +09:00
|
|
|
mask that and return zero instead */
|
2008-10-01 16:51:53 +09:00
|
|
|
return (err < 0) ? err : 0;
|
|
|
|
}
|
|
|
|
|
2009-12-12 18:58:01 +09:00
|
|
|
static int m5602_wait_for_i2c(struct sd *sd)
|
2009-04-03 14:45:56 +09:00
|
|
|
{
|
|
|
|
int err;
|
|
|
|
u8 data;
|
2009-01-21 15:43:49 +09:00
|
|
|
|
2009-04-03 14:45:56 +09:00
|
|
|
do {
|
|
|
|
err = m5602_read_bridge(sd, M5602_XB_I2C_STATUS, &data);
|
|
|
|
} while ((data & I2C_BUSY) && !err);
|
2009-01-21 15:43:49 +09:00
|
|
|
return err;
|
2009-04-03 14:45:56 +09:00
|
|
|
}
|
|
|
|
|
2008-11-27 01:15:35 +09:00
|
|
|
int m5602_read_sensor(struct sd *sd, const u8 address,
|
|
|
|
u8 *i2c_data, const u8 len)
|
|
|
|
{
|
|
|
|
int err, i;
|
2013-02-05 01:17:55 +09:00
|
|
|
struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
|
2008-11-27 01:15:35 +09:00
|
|
|
|
2008-11-28 01:41:55 +09:00
|
|
|
if (!len || len > sd->sensor->i2c_regW)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-04-03 14:45:56 +09:00
|
|
|
err = m5602_wait_for_i2c(sd);
|
2008-11-28 01:41:55 +09:00
|
|
|
if (err < 0)
|
2008-12-28 00:28:00 +09:00
|
|
|
return err;
|
2008-11-27 01:15:35 +09:00
|
|
|
|
|
|
|
err = m5602_write_bridge(sd, M5602_XB_I2C_DEV_ADDR,
|
|
|
|
sd->sensor->i2c_slave_id);
|
|
|
|
if (err < 0)
|
2008-12-28 00:28:00 +09:00
|
|
|
return err;
|
2008-11-27 01:15:35 +09:00
|
|
|
|
|
|
|
err = m5602_write_bridge(sd, M5602_XB_I2C_REG_ADDR, address);
|
|
|
|
if (err < 0)
|
2008-12-28 00:28:00 +09:00
|
|
|
return err;
|
2008-11-27 01:15:35 +09:00
|
|
|
|
2009-05-04 03:31:55 +09:00
|
|
|
/* Sensors with registers that are of only
|
|
|
|
one byte width are differently read */
|
|
|
|
|
2009-01-28 16:02:49 +09:00
|
|
|
/* FIXME: This works with the ov9650, but has issues with the po1030 */
|
2008-11-28 01:41:55 +09:00
|
|
|
if (sd->sensor->i2c_regW == 1) {
|
2009-01-28 16:02:49 +09:00
|
|
|
err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 1);
|
2008-11-28 01:41:55 +09:00
|
|
|
if (err < 0)
|
2008-12-28 00:28:00 +09:00
|
|
|
return err;
|
2008-11-28 01:41:55 +09:00
|
|
|
|
|
|
|
err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x08);
|
|
|
|
} else {
|
|
|
|
err = m5602_write_bridge(sd, M5602_XB_I2C_CTRL, 0x18 + len);
|
|
|
|
}
|
2008-11-27 01:15:35 +09:00
|
|
|
|
|
|
|
for (i = 0; (i < len) && !err; i++) {
|
2009-04-03 14:45:56 +09:00
|
|
|
err = m5602_wait_for_i2c(sd);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
2008-11-27 01:15:35 +09:00
|
|
|
err = m5602_read_bridge(sd, M5602_XB_I2C_DATA, &(i2c_data[i]));
|
|
|
|
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_CONF, "Reading sensor register 0x%x containing 0x%x\n",
|
|
|
|
address, *i2c_data);
|
2008-11-27 01:15:35 +09:00
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-11-26 16:01:40 +09:00
|
|
|
int m5602_write_sensor(struct sd *sd, const u8 address,
|
|
|
|
u8 *i2c_data, const u8 len)
|
|
|
|
{
|
|
|
|
int err, i;
|
|
|
|
u8 *p;
|
2013-02-05 01:17:55 +09:00
|
|
|
struct gspca_dev *gspca_dev = (struct gspca_dev *) sd;
|
2008-11-26 16:01:40 +09:00
|
|
|
struct usb_device *udev = sd->gspca_dev.dev;
|
|
|
|
__u8 *buf = sd->gspca_dev.usb_buf;
|
|
|
|
|
|
|
|
/* No sensor with a data width larger than 16 bits has yet been seen */
|
|
|
|
if (len > sd->sensor->i2c_regW || !len)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
memcpy(buf, sensor_urb_skeleton,
|
|
|
|
sizeof(sensor_urb_skeleton));
|
|
|
|
|
|
|
|
buf[11] = sd->sensor->i2c_slave_id;
|
|
|
|
buf[15] = address;
|
|
|
|
|
|
|
|
/* Special case larger sensor writes */
|
|
|
|
p = buf + 16;
|
|
|
|
|
|
|
|
/* Copy a four byte write sequence for each byte to be written to */
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
memcpy(p, sensor_urb_skeleton + 16, 4);
|
|
|
|
p[3] = i2c_data[i];
|
|
|
|
p += 4;
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_CONF, "Writing sensor register 0x%x with 0x%x\n",
|
|
|
|
address, i2c_data[i]);
|
2008-11-26 16:01:40 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy the tailer */
|
|
|
|
memcpy(p, sensor_urb_skeleton + 20, 4);
|
|
|
|
|
|
|
|
/* Set the total length */
|
|
|
|
p[3] = 0x10 + len;
|
|
|
|
|
|
|
|
err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
|
|
|
|
0x04, 0x40, 0x19,
|
|
|
|
0x0000, buf,
|
|
|
|
20 + len * 4, M5602_URB_MSG_TIMEOUT);
|
|
|
|
|
|
|
|
return (err < 0) ? err : 0;
|
|
|
|
}
|
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
/* Dump all the registers of the m5602 bridge,
|
|
|
|
unfortunately this breaks the camera until it's power cycled */
|
|
|
|
static void m5602_dump_bridge(struct sd *sd)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < 0x80; i++) {
|
|
|
|
unsigned char val = 0;
|
|
|
|
m5602_read_bridge(sd, i, &val);
|
2011-08-22 07:56:52 +09:00
|
|
|
pr_info("ALi m5602 address 0x%x contains 0x%x\n", i, val);
|
2008-10-01 16:51:53 +09:00
|
|
|
}
|
2011-08-22 07:56:52 +09:00
|
|
|
pr_info("Warning: The ALi m5602 webcam probably won't work until it's power cycled\n");
|
2008-10-01 16:51:53 +09:00
|
|
|
}
|
|
|
|
|
2008-10-05 16:46:11 +09:00
|
|
|
static int m5602_probe_sensor(struct sd *sd)
|
2008-10-01 16:51:53 +09:00
|
|
|
{
|
|
|
|
/* Try the po1030 */
|
|
|
|
sd->sensor = &po1030;
|
2008-10-04 03:29:02 +09:00
|
|
|
if (!sd->sensor->probe(sd))
|
2008-10-01 16:51:53 +09:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Try the mt9m111 sensor */
|
|
|
|
sd->sensor = &mt9m111;
|
2008-10-04 03:29:02 +09:00
|
|
|
if (!sd->sensor->probe(sd))
|
2008-10-01 16:51:53 +09:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Try the s5k4aa */
|
|
|
|
sd->sensor = &s5k4aa;
|
2008-10-04 03:29:02 +09:00
|
|
|
if (!sd->sensor->probe(sd))
|
2008-10-01 16:51:53 +09:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Try the ov9650 */
|
|
|
|
sd->sensor = &ov9650;
|
2008-10-04 03:29:02 +09:00
|
|
|
if (!sd->sensor->probe(sd))
|
2008-10-01 16:51:53 +09:00
|
|
|
return 0;
|
|
|
|
|
2009-04-28 03:41:45 +09:00
|
|
|
/* Try the ov7660 */
|
|
|
|
sd->sensor = &ov7660;
|
|
|
|
if (!sd->sensor->probe(sd))
|
|
|
|
return 0;
|
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
/* Try the s5k83a */
|
|
|
|
sd->sensor = &s5k83a;
|
2008-10-04 03:29:02 +09:00
|
|
|
if (!sd->sensor->probe(sd))
|
2008-10-01 16:51:53 +09:00
|
|
|
return 0;
|
2008-10-03 21:28:45 +09:00
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
/* More sensor probe function goes here */
|
2011-08-22 07:56:52 +09:00
|
|
|
pr_info("Failed to find a sensor\n");
|
2008-10-01 16:51:53 +09:00
|
|
|
sd->sensor = NULL;
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2008-10-05 16:46:11 +09:00
|
|
|
static int m5602_configure(struct gspca_dev *gspca_dev,
|
|
|
|
const struct usb_device_id *id);
|
|
|
|
|
|
|
|
static int m5602_init(struct gspca_dev *gspca_dev)
|
2008-10-01 16:51:53 +09:00
|
|
|
{
|
|
|
|
struct sd *sd = (struct sd *) gspca_dev;
|
|
|
|
int err;
|
|
|
|
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_CONF, "Initializing ALi m5602 webcam\n");
|
2008-10-01 16:51:53 +09:00
|
|
|
/* Run the init sequence */
|
|
|
|
err = sd->sensor->init(sd);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2013-02-20 02:57:03 +09:00
|
|
|
static int m5602_init_controls(struct gspca_dev *gspca_dev)
|
|
|
|
{
|
|
|
|
struct sd *sd = (struct sd *) gspca_dev;
|
|
|
|
|
|
|
|
if (!sd->sensor->init_controls)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return sd->sensor->init_controls(sd);
|
|
|
|
}
|
|
|
|
|
2008-10-05 16:46:11 +09:00
|
|
|
static int m5602_start_transfer(struct gspca_dev *gspca_dev)
|
2008-10-01 16:51:53 +09:00
|
|
|
{
|
|
|
|
struct sd *sd = (struct sd *) gspca_dev;
|
|
|
|
__u8 *buf = sd->gspca_dev.usb_buf;
|
2008-10-17 04:36:35 +09:00
|
|
|
int err;
|
2008-10-01 16:51:53 +09:00
|
|
|
|
|
|
|
/* Send start command to the camera */
|
|
|
|
const u8 buffer[4] = {0x13, 0xf9, 0x0f, 0x01};
|
2008-11-20 15:41:44 +09:00
|
|
|
|
2008-12-22 05:25:25 +09:00
|
|
|
if (sd->sensor->start)
|
|
|
|
sd->sensor->start(sd);
|
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
memcpy(buf, buffer, sizeof(buffer));
|
2008-10-17 04:36:35 +09:00
|
|
|
err = usb_control_msg(gspca_dev->dev,
|
|
|
|
usb_sndctrlpipe(gspca_dev->dev, 0),
|
|
|
|
0x04, 0x40, 0x19, 0x0000, buf,
|
2008-11-20 15:41:44 +09:00
|
|
|
sizeof(buffer), M5602_URB_MSG_TIMEOUT);
|
2008-10-01 16:51:53 +09:00
|
|
|
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_STREAM, "Transfer started\n");
|
2008-10-17 04:36:35 +09:00
|
|
|
return (err < 0) ? err : 0;
|
2008-10-01 16:51:53 +09:00
|
|
|
}
|
|
|
|
|
2008-10-05 16:46:11 +09:00
|
|
|
static void m5602_urb_complete(struct gspca_dev *gspca_dev,
|
2009-11-13 21:21:03 +09:00
|
|
|
u8 *data, int len)
|
2008-10-01 16:51:53 +09:00
|
|
|
{
|
|
|
|
struct sd *sd = (struct sd *) gspca_dev;
|
|
|
|
|
|
|
|
if (len < 6) {
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_PACK, "Packet is less than 6 bytes\n");
|
2008-10-01 16:51:53 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Frame delimiter: ff xx xx xx ff ff */
|
|
|
|
if (data[0] == 0xff && data[4] == 0xff && data[5] == 0xff &&
|
|
|
|
data[2] != sd->frame_id) {
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_FRAM, "Frame delimiter detected\n");
|
2008-10-01 16:51:53 +09:00
|
|
|
sd->frame_id = data[2];
|
|
|
|
|
|
|
|
/* Remove the extra fluff appended on each header */
|
|
|
|
data += 6;
|
|
|
|
len -= 6;
|
|
|
|
|
|
|
|
/* Complete the last frame (if any) */
|
2009-11-13 21:21:03 +09:00
|
|
|
gspca_frame_add(gspca_dev, LAST_PACKET,
|
|
|
|
NULL, 0);
|
2008-10-03 21:28:45 +09:00
|
|
|
sd->frame_count++;
|
2008-10-01 16:51:53 +09:00
|
|
|
|
|
|
|
/* Create a new frame */
|
2009-11-13 21:21:03 +09:00
|
|
|
gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
|
2008-10-01 16:51:53 +09:00
|
|
|
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_FRAM, "Starting new frame %d\n",
|
|
|
|
sd->frame_count);
|
2008-10-01 16:51:53 +09:00
|
|
|
|
|
|
|
} else {
|
2009-11-13 21:21:03 +09:00
|
|
|
int cur_frame_len;
|
2008-10-01 16:51:53 +09:00
|
|
|
|
2010-06-27 15:08:19 +09:00
|
|
|
cur_frame_len = gspca_dev->image_len;
|
2008-10-01 16:51:53 +09:00
|
|
|
/* Remove urb header */
|
|
|
|
data += 4;
|
|
|
|
len -= 4;
|
|
|
|
|
2018-05-12 23:44:00 +09:00
|
|
|
if (cur_frame_len + len <= gspca_dev->pixfmt.sizeimage) {
|
2017-09-23 04:20:33 +09:00
|
|
|
gspca_dbg(gspca_dev, D_FRAM, "Continuing frame %d copying %d bytes\n",
|
|
|
|
sd->frame_count, len);
|
2008-10-01 16:51:53 +09:00
|
|
|
|
2009-11-13 21:21:03 +09:00
|
|
|
gspca_frame_add(gspca_dev, INTER_PACKET,
|
2008-10-01 16:51:53 +09:00
|
|
|
data, len);
|
2010-06-27 15:08:19 +09:00
|
|
|
} else {
|
2008-10-01 16:51:53 +09:00
|
|
|
/* Add the remaining data up to frame size */
|
2009-11-13 21:21:03 +09:00
|
|
|
gspca_frame_add(gspca_dev, INTER_PACKET, data,
|
2018-05-12 23:44:00 +09:00
|
|
|
gspca_dev->pixfmt.sizeimage - cur_frame_len);
|
2008-10-01 16:51:53 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-05 16:46:11 +09:00
|
|
|
static void m5602_stop_transfer(struct gspca_dev *gspca_dev)
|
2008-10-01 16:51:53 +09:00
|
|
|
{
|
2008-12-29 02:09:21 +09:00
|
|
|
struct sd *sd = (struct sd *) gspca_dev;
|
|
|
|
|
|
|
|
/* Run the sensor specific end transfer sequence */
|
|
|
|
if (sd->sensor->stop)
|
|
|
|
sd->sensor->stop(sd);
|
2008-10-01 16:51:53 +09:00
|
|
|
}
|
|
|
|
|
2013-02-20 02:57:03 +09:00
|
|
|
/* sub-driver description */
|
|
|
|
static const struct sd_desc sd_desc = {
|
2008-10-05 16:46:11 +09:00
|
|
|
.name = MODULE_NAME,
|
|
|
|
.config = m5602_configure,
|
|
|
|
.init = m5602_init,
|
2013-02-20 02:57:03 +09:00
|
|
|
.init_controls = m5602_init_controls,
|
2008-10-05 16:46:11 +09:00
|
|
|
.start = m5602_start_transfer,
|
|
|
|
.stopN = m5602_stop_transfer,
|
|
|
|
.pkt_scan = m5602_urb_complete
|
|
|
|
};
|
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
/* this function is called at probe time */
|
2008-10-05 16:46:11 +09:00
|
|
|
static int m5602_configure(struct gspca_dev *gspca_dev,
|
2008-10-01 16:51:53 +09:00
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
struct sd *sd = (struct sd *) gspca_dev;
|
|
|
|
struct cam *cam;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
cam = &gspca_dev->cam;
|
|
|
|
|
|
|
|
if (dump_bridge)
|
|
|
|
m5602_dump_bridge(sd);
|
|
|
|
|
|
|
|
/* Probe sensor */
|
|
|
|
err = m5602_probe_sensor(sd);
|
|
|
|
if (err)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fail:
|
2017-09-23 03:33:35 +09:00
|
|
|
gspca_err(gspca_dev, "ALi m5602 webcam failed\n");
|
2008-10-01 16:51:53 +09:00
|
|
|
cam->cam_mode = NULL;
|
|
|
|
cam->nmodes = 0;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int m5602_probe(struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
|
|
|
return gspca_dev_probe(intf, id, &sd_desc, sizeof(struct sd),
|
|
|
|
THIS_MODULE);
|
|
|
|
}
|
|
|
|
|
2009-12-12 18:58:01 +09:00
|
|
|
static void m5602_disconnect(struct usb_interface *intf)
|
2009-01-04 00:10:11 +09:00
|
|
|
{
|
|
|
|
struct gspca_dev *gspca_dev = usb_get_intfdata(intf);
|
|
|
|
struct sd *sd = (struct sd *) gspca_dev;
|
|
|
|
|
|
|
|
if (sd->sensor->disconnect)
|
|
|
|
sd->sensor->disconnect(sd);
|
|
|
|
|
|
|
|
gspca_disconnect(intf);
|
|
|
|
}
|
|
|
|
|
2008-10-01 16:51:53 +09:00
|
|
|
static struct usb_driver sd_driver = {
|
|
|
|
.name = MODULE_NAME,
|
|
|
|
.id_table = m5602_table,
|
|
|
|
.probe = m5602_probe,
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = gspca_suspend,
|
|
|
|
.resume = gspca_resume,
|
2012-06-30 18:44:47 +09:00
|
|
|
.reset_resume = gspca_resume,
|
2008-10-01 16:51:53 +09:00
|
|
|
#endif
|
2009-01-04 00:10:11 +09:00
|
|
|
.disconnect = m5602_disconnect
|
2008-10-01 16:51:53 +09:00
|
|
|
};
|
|
|
|
|
2011-11-19 02:46:12 +09:00
|
|
|
module_usb_driver(sd_driver);
|
2008-10-01 16:51:53 +09:00
|
|
|
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
module_param(force_sensor, int, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(force_sensor,
|
[media] gspca: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-19 04:44:16 +09:00
|
|
|
"forces detection of a sensor, 1 = OV9650, 2 = S5K83A, 3 = S5K4AA, 4 = MT9M111, 5 = PO1030, 6 = OV7660");
|
2008-10-01 16:51:53 +09:00
|
|
|
|
|
|
|
module_param(dump_bridge, bool, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(dump_bridge, "Dumps all usb bridge registers at startup");
|
|
|
|
|
|
|
|
module_param(dump_sensor, bool, S_IRUGO | S_IWUSR);
|
[media] gspca: don't break long lines
Due to the 80-cols restrictions, and latter due to checkpatch
warnings, several strings were broken into multiple lines. This
is not considered a good practice anymore, as it makes harder
to grep for strings at the source code.
As we're right now fixing other drivers due to KERN_CONT, we need
to be able to identify what printk strings don't end with a "\n".
It is a way easier to detect those if we don't break long lines.
So, join those continuation lines.
The patch was generated via the script below, and manually
adjusted if needed.
</script>
use Text::Tabs;
while (<>) {
if ($next ne "") {
$c=$_;
if ($c =~ /^\s+\"(.*)/) {
$c2=$1;
$next =~ s/\"\n$//;
$n = expand($next);
$funpos = index($n, '(');
$pos = index($c2, '",');
if ($funpos && $pos > 0) {
$s1 = substr $c2, 0, $pos + 2;
$s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2;
$s2 =~ s/^\s+//;
$s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne "");
print unexpand("$next$s1\n");
print unexpand("$s2\n") if ($s2 ne "");
} else {
print "$next$c2\n";
}
$next="";
next;
} else {
print $next;
}
$next="";
} else {
if (m/\"$/) {
if (!m/\\n\"$/) {
$next=$_;
next;
}
}
}
print $_;
}
</script>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-10-19 04:44:16 +09:00
|
|
|
MODULE_PARM_DESC(dump_sensor, "Dumps all usb sensor registers at startup providing a sensor is found");
|