22 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
24 #define MODULE_NAME "spca505"
37 #define IntelPCCameraPro 0
44 .sizeimage = 160 * 120 * 3 / 2,
49 .sizeimage = 176 * 144 * 3 / 2,
54 .sizeimage = 320 * 240 * 3 / 2,
59 .sizeimage = 352 * 288 * 3 / 2,
64 .sizeimage = 640 * 480 * 3 / 2,
69 #define SPCA50X_OFFSET_DATA 10
71 #define SPCA50X_REG_USB 0x02
73 #define SPCA50X_USB_CTRL 0x00
74 #define SPCA50X_CUSB_ENABLE 0x01
76 #define SPCA50X_REG_GLOBAL 0x03
77 #define SPCA50X_GMISC0_IDSEL 0x01
78 #define SPCA50X_GLOBAL_MISC0 0x00
80 #define SPCA50X_GLOBAL_MISC1 0x01
81 #define SPCA50X_GLOBAL_MISC3 0x03
82 #define SPCA50X_GMISC3_SAA7113RST 0x20
85 #define SPCA50X_REG_COMPRESS 0x04
90 static const u8 spca505_init_data[][3] = {
127 static const u8 spca505_open_data_ccd[][3] = {
310 #define initial_brightness 0x7f
315 static const u8 spca505b_init_data[][3] = {
375 static const u8 spca505b_open_data_ccd[][3] = {
553 usb_sndctrlpipe(dev, 0),
556 value, index,
NULL, 0, 500);
557 PDEBUG(D_USBO,
"reg write: 0x%02x,0x%02x:0x%02x, %d",
558 req, index, value, ret);
560 pr_err(
"reg write: error %d\n", ret);
572 usb_rcvctrlpipe(gspca_dev->
dev, 0),
584 static int write_vector(
struct gspca_dev *gspca_dev,
587 struct usb_device *dev = gspca_dev->
dev;
590 while (data[i][0] != 0) {
591 ret =
reg_write(dev, data[i][0], data[i][2], data[i][1]);
600 static int sd_config(
struct gspca_dev *gspca_dev,
603 struct sd *
sd = (
struct sd *) gspca_dev;
606 cam = &gspca_dev->
cam;
618 static int sd_init(
struct gspca_dev *gspca_dev)
620 struct sd *sd = (
struct sd *) gspca_dev;
622 if (write_vector(gspca_dev,
625 : spca505_init_data))
630 static void setbrightness(
struct gspca_dev *gspca_dev,
s32 brightness)
632 reg_write(gspca_dev->
dev, 0x05, 0x00, (255 - brightness) >> 6);
633 reg_write(gspca_dev->
dev, 0x05, 0x01, (255 - brightness) << 2);
636 static int sd_start(
struct gspca_dev *gspca_dev)
638 struct sd *sd = (
struct sd *) gspca_dev;
639 struct usb_device *dev = gspca_dev->
dev;
641 static u8 mode_tb[][3] = {
651 write_vector(gspca_dev, spca505b_open_data_ccd);
653 write_vector(gspca_dev, spca505_open_data_ccd);
654 ret =
reg_read(gspca_dev, 0x06, 0x16);
658 "register read failed err: %d",
663 pr_err(
"After vector read returns 0x%04x should be 0x0101\n",
687 static void sd_stopN(
struct gspca_dev *gspca_dev)
694 static void sd_stop0(
struct gspca_dev *gspca_dev)
707 static void sd_pkt_scan(
struct gspca_dev *gspca_dev,
730 struct gspca_dev *gspca_dev =
740 setbrightness(gspca_dev, ctrl->
val);
750 static int sd_init_controls(
struct gspca_dev *gspca_dev)
754 gspca_dev->
vdev.ctrl_handler = hdl;
760 pr_err(
"Could not initialize controls\n");
770 .init_controls = sd_init_controls,
775 .pkt_scan = sd_pkt_scan,
780 {USB_DEVICE(0x041e, 0x401d), .driver_info =
Nxultra},
795 static struct usb_driver sd_driver = {
797 .id_table = device_table,
801 .suspend = gspca_suspend,
802 .resume = gspca_resume,
803 .reset_resume = gspca_resume,