29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 #define MODULE_NAME "vicam"
32 #define HEADER_SIZE 64
35 #include <linux/slab.h>
40 #define VICAM_FIRMWARE "vicam/firmware.fw"
59 .sizeimage = 256 * 122,
64 .sizeimage = 256 * 200,
68 .sizeimage = 256 * 240,
73 .sizeimage = 512 * 122,
78 .sizeimage = 512 * 244,
88 usb_sndctrlpipe(gspca_dev->
dev, 0),
91 value, index, data, len, 1000);
93 pr_err(
"control msg req %02X error %d\n", request, ret);
98 static int vicam_set_camera_power(
struct gspca_dev *gspca_dev,
int state)
102 ret = vicam_control_msg(gspca_dev, 0x50, state, 0,
NULL, 0);
107 ret = vicam_control_msg(gspca_dev, 0x55, 1, 0,
NULL, 0);
115 static int vicam_read_frame(
struct gspca_dev *gspca_dev,
u8 *data,
int size)
117 int ret, unscaled_height, act_len = 0;
124 if (gspca_dev->
width == 256)
126 if (gspca_dev->
height <= 122) {
128 unscaled_height = gspca_dev->
height * 2;
130 unscaled_height = gspca_dev->
height;
132 if (unscaled_height <= 200)
134 else if (unscaled_height <= 242)
141 req_data[4] = 255 - expo;
149 req_data[6] = expo & 0xFF;
150 req_data[7] = expo >> 8;
152 req_data[8] = ((244 - unscaled_height) / 2) & ~0x01;
156 ret = vicam_control_msg(gspca_dev, 0x51, 0x80, 0, req_data, 16);
162 usb_rcvbulkpipe(gspca_dev->
dev, 0x81),
163 data, size, &act_len, 10000);
165 if (ret < 0 || act_len != size) {
166 pr_err(
"bulk read fail (%d) len %d/%d\n",
184 struct gspca_dev *gspca_dev = &sd->
gspca_dev;
188 frame_sz = gspca_dev->
cam.cam_mode[gspca_dev->
curr_mode].sizeimage +
192 pr_err(
"Couldn't allocate USB buffer\n");
198 if (gspca_dev->frozen)
201 ret = vicam_read_frame(gspca_dev, buffer, frame_sz);
220 static int sd_config(
struct gspca_dev *gspca_dev,
224 struct sd *sd = (
struct sd *)gspca_dev;
238 static int sd_init(
struct gspca_dev *gspca_dev)
246 &gspca_dev->
dev->dev);
248 pr_err(
"Failed to load \"vicam/firmware.fw\": %d\n", ret);
257 for (rec = (
void *)
fw->data; rec; rec = ihex_next_binrec(rec)) {
259 ret = vicam_control_msg(gspca_dev, 0xff, 0, 0, firmware_buf,
272 static int sd_start(
struct gspca_dev *gspca_dev)
274 struct sd *sd = (
struct sd *)gspca_dev;
277 ret = vicam_set_camera_power(gspca_dev, 1);
290 static void sd_stop0(
struct gspca_dev *gspca_dev)
292 struct sd *
dev = (
struct sd *)gspca_dev;
302 vicam_set_camera_power(gspca_dev, 0);
305 static int sd_init_controls(
struct gspca_dev *gspca_dev)
309 gspca_dev->
vdev.ctrl_handler = hdl;
317 pr_err(
"Could not initialize controls\n");
325 {USB_DEVICE(0x04c1, 0x009d)},
326 {USB_DEVICE(0x0602, 0x1001)},
337 .init_controls = sd_init_controls,
352 static struct usb_driver sd_driver = {
354 .id_table = device_table,
358 .suspend = gspca_suspend,
359 .resume = gspca_resume,
360 .reset_resume = gspca_resume,