2008-06-30 15:50:11 -03:00
/*
* SPCA500 chip based cameras initialization data
*
* V4L2 by Jean - Francois Moine < http : //moinejf.free.fr>
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
*
*/
2011-08-21 19:56:57 -03:00
# define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2008-06-30 15:50:11 -03:00
# define MODULE_NAME "spca500"
# include "gspca.h"
# include "jpeg.h"
MODULE_AUTHOR ( " Michel Xhaard <mxhaard@users.sourceforge.net> " ) ;
MODULE_DESCRIPTION ( " GSPCA/SPCA500 USB Camera Driver " ) ;
MODULE_LICENSE ( " GPL " ) ;
2012-06-27 16:48:33 -03:00
# define QUALITY 85
2008-06-30 15:50:11 -03:00
/* specific webcam descriptor */
struct sd {
struct gspca_dev gspca_dev ; /* !! must be the first item */
char subtype ;
# define AgfaCl20 0
# define AiptekPocketDV 1
# define BenqDC1016 2
# define CreativePCCam300 3
# define DLinkDSC350 4
# define Gsmartmini 5
# define IntelPocketPCCamera 6
# define KodakEZ200 7
# define LogitechClickSmart310 8
# define LogitechClickSmart510 9
# define LogitechTraveler 10
# define MustekGsmart300 11
# define Optimedia 12
# define PalmPixDC85 13
# define ToptroIndus 14
2009-03-03 05:33:41 -03:00
2010-06-04 05:26:42 -03:00
u8 jpeg_hdr [ JPEG_HDR_SZ ] ;
2008-06-30 15:50:11 -03:00
} ;
2008-12-29 07:49:41 -03:00
static const struct v4l2_pix_format vga_mode [ ] = {
2008-07-05 11:49:20 -03:00
{ 320 , 240 , V4L2_PIX_FMT_JPEG , V4L2_FIELD_NONE ,
. bytesperline = 320 ,
. sizeimage = 320 * 240 * 3 / 8 + 590 ,
. colorspace = V4L2_COLORSPACE_JPEG ,
. priv = 1 } ,
{ 640 , 480 , V4L2_PIX_FMT_JPEG , V4L2_FIELD_NONE ,
. bytesperline = 640 ,
. sizeimage = 640 * 480 * 3 / 8 + 590 ,
. colorspace = V4L2_COLORSPACE_JPEG ,
. priv = 0 } ,
2008-06-30 15:50:11 -03:00
} ;
2008-12-29 07:49:41 -03:00
static const struct v4l2_pix_format sif_mode [ ] = {
2008-07-05 11:49:20 -03:00
{ 176 , 144 , V4L2_PIX_FMT_JPEG , V4L2_FIELD_NONE ,
. bytesperline = 176 ,
. sizeimage = 176 * 144 * 3 / 8 + 590 ,
. colorspace = V4L2_COLORSPACE_JPEG ,
. priv = 1 } ,
{ 352 , 288 , V4L2_PIX_FMT_JPEG , V4L2_FIELD_NONE ,
. bytesperline = 352 ,
. sizeimage = 352 * 288 * 3 / 8 + 590 ,
. colorspace = V4L2_COLORSPACE_JPEG ,
. priv = 0 } ,
2008-06-30 15:50:11 -03:00
} ;
/* Frame packet header offsets for the spca500 */
# define SPCA500_OFFSET_PADDINGLB 2
# define SPCA500_OFFSET_PADDINGHB 3
# define SPCA500_OFFSET_MODE 4
# define SPCA500_OFFSET_IMGWIDTH 5
# define SPCA500_OFFSET_IMGHEIGHT 6
# define SPCA500_OFFSET_IMGMODE 7
# define SPCA500_OFFSET_QTBLINDEX 8
# define SPCA500_OFFSET_FRAMSEQ 9
# define SPCA500_OFFSET_CDSPINFO 10
# define SPCA500_OFFSET_GPIO 11
# define SPCA500_OFFSET_AUGPIO 12
# define SPCA500_OFFSET_DATA 16
2008-07-04 11:16:16 -03:00
static const __u16 spca500_visual_defaults [ ] [ 3 ] = {
2008-06-30 15:50:11 -03:00
{ 0x00 , 0x0003 , 0x816b } , /* SSI not active sync with vsync,
* hue ( H byte ) = 0 ,
* saturation / hue enable ,
* brightness / contrast enable .
*/
{ 0x00 , 0x0000 , 0x8167 } , /* brightness = 0 */
{ 0x00 , 0x0020 , 0x8168 } , /* contrast = 0 */
{ 0x00 , 0x0003 , 0x816b } , /* SSI not active sync with vsync,
* hue ( H byte ) = 0 , saturation / hue enable ,
* brightness / contrast enable .
* was 0x0003 , now 0x0000 .
*/
{ 0x00 , 0x0000 , 0x816a } , /* hue (L byte) = 0 */
{ 0x00 , 0x0020 , 0x8169 } , /* saturation = 0x20 */
{ 0x00 , 0x0050 , 0x8157 } , /* edge gain high threshold */
{ 0x00 , 0x0030 , 0x8158 } , /* edge gain low threshold */
{ 0x00 , 0x0028 , 0x8159 } , /* edge bandwidth high threshold */
{ 0x00 , 0x000a , 0x815a } , /* edge bandwidth low threshold */
{ 0x00 , 0x0001 , 0x8202 } , /* clock rate compensation = 1/25 sec/frame */
{ 0x0c , 0x0004 , 0x0000 } ,
/* set interface */
2008-07-04 11:16:16 -03:00
{ }
2008-06-30 15:50:11 -03:00
} ;
2008-07-04 11:16:16 -03:00
static const __u16 Clicksmart510_defaults [ ] [ 3 ] = {
2008-06-30 15:50:11 -03:00
{ 0x00 , 0x00 , 0x8211 } ,
{ 0x00 , 0x01 , 0x82c0 } ,
{ 0x00 , 0x10 , 0x82cb } ,
{ 0x00 , 0x0f , 0x800d } ,
{ 0x00 , 0x82 , 0x8225 } ,
{ 0x00 , 0x21 , 0x8228 } ,
{ 0x00 , 0x00 , 0x8203 } ,
{ 0x00 , 0x00 , 0x8204 } ,
{ 0x00 , 0x08 , 0x8205 } ,
{ 0x00 , 0xf8 , 0x8206 } ,
{ 0x00 , 0x28 , 0x8207 } ,
{ 0x00 , 0xa0 , 0x8208 } ,
{ 0x00 , 0x08 , 0x824a } ,
{ 0x00 , 0x08 , 0x8214 } ,
{ 0x00 , 0x80 , 0x82c1 } ,
{ 0x00 , 0x00 , 0x82c2 } ,
{ 0x00 , 0x00 , 0x82ca } ,
{ 0x00 , 0x80 , 0x82c1 } ,
{ 0x00 , 0x04 , 0x82c2 } ,
{ 0x00 , 0x00 , 0x82ca } ,
{ 0x00 , 0xfc , 0x8100 } ,
{ 0x00 , 0xfc , 0x8105 } ,
{ 0x00 , 0x30 , 0x8101 } ,
{ 0x00 , 0x00 , 0x8102 } ,
{ 0x00 , 0x00 , 0x8103 } ,
{ 0x00 , 0x66 , 0x8107 } ,
{ 0x00 , 0x00 , 0x816b } ,
{ 0x00 , 0x00 , 0x8155 } ,
{ 0x00 , 0x01 , 0x8156 } ,
{ 0x00 , 0x60 , 0x8157 } ,
{ 0x00 , 0x40 , 0x8158 } ,
{ 0x00 , 0x0a , 0x8159 } ,
{ 0x00 , 0x06 , 0x815a } ,
{ 0x00 , 0x00 , 0x813f } ,
{ 0x00 , 0x00 , 0x8200 } ,
{ 0x00 , 0x19 , 0x8201 } ,
{ 0x00 , 0x00 , 0x82c1 } ,
{ 0x00 , 0xa0 , 0x82c2 } ,
{ 0x00 , 0x00 , 0x82ca } ,
{ 0x00 , 0x00 , 0x8117 } ,
{ 0x00 , 0x00 , 0x8118 } ,
{ 0x00 , 0x65 , 0x8119 } ,
{ 0x00 , 0x00 , 0x811a } ,
{ 0x00 , 0x00 , 0x811b } ,
{ 0x00 , 0x55 , 0x811c } ,
{ 0x00 , 0x65 , 0x811d } ,
{ 0x00 , 0x55 , 0x811e } ,
{ 0x00 , 0x16 , 0x811f } ,
{ 0x00 , 0x19 , 0x8120 } ,
{ 0x00 , 0x80 , 0x8103 } ,
{ 0x00 , 0x83 , 0x816b } ,
{ 0x00 , 0x25 , 0x8168 } ,
{ 0x00 , 0x01 , 0x820f } ,
{ 0x00 , 0xff , 0x8115 } ,
{ 0x00 , 0x48 , 0x8116 } ,
{ 0x00 , 0x50 , 0x8151 } ,
{ 0x00 , 0x40 , 0x8152 } ,
{ 0x00 , 0x78 , 0x8153 } ,
{ 0x00 , 0x40 , 0x8154 } ,
{ 0x00 , 0x00 , 0x8167 } ,
{ 0x00 , 0x20 , 0x8168 } ,
{ 0x00 , 0x00 , 0x816a } ,
{ 0x00 , 0x03 , 0x816b } ,
{ 0x00 , 0x20 , 0x8169 } ,
{ 0x00 , 0x60 , 0x8157 } ,
{ 0x00 , 0x00 , 0x8190 } ,
{ 0x00 , 0x00 , 0x81a1 } ,
{ 0x00 , 0x00 , 0x81b2 } ,
{ 0x00 , 0x27 , 0x8191 } ,
{ 0x00 , 0x27 , 0x81a2 } ,
{ 0x00 , 0x27 , 0x81b3 } ,
{ 0x00 , 0x4b , 0x8192 } ,
{ 0x00 , 0x4b , 0x81a3 } ,
{ 0x00 , 0x4b , 0x81b4 } ,
{ 0x00 , 0x66 , 0x8193 } ,
{ 0x00 , 0x66 , 0x81a4 } ,
{ 0x00 , 0x66 , 0x81b5 } ,
{ 0x00 , 0x79 , 0x8194 } ,
{ 0x00 , 0x79 , 0x81a5 } ,
{ 0x00 , 0x79 , 0x81b6 } ,
{ 0x00 , 0x8a , 0x8195 } ,
{ 0x00 , 0x8a , 0x81a6 } ,
{ 0x00 , 0x8a , 0x81b7 } ,
{ 0x00 , 0x9b , 0x8196 } ,
{ 0x00 , 0x9b , 0x81a7 } ,
{ 0x00 , 0x9b , 0x81b8 } ,
{ 0x00 , 0xa6 , 0x8197 } ,
{ 0x00 , 0xa6 , 0x81a8 } ,
{ 0x00 , 0xa6 , 0x81b9 } ,
{ 0x00 , 0xb2 , 0x8198 } ,
{ 0x00 , 0xb2 , 0x81a9 } ,
{ 0x00 , 0xb2 , 0x81ba } ,
{ 0x00 , 0xbe , 0x8199 } ,
{ 0x00 , 0xbe , 0x81aa } ,
{ 0x00 , 0xbe , 0x81bb } ,
{ 0x00 , 0xc8 , 0x819a } ,
{ 0x00 , 0xc8 , 0x81ab } ,
{ 0x00 , 0xc8 , 0x81bc } ,
{ 0x00 , 0xd2 , 0x819b } ,
{ 0x00 , 0xd2 , 0x81ac } ,
{ 0x00 , 0xd2 , 0x81bd } ,
{ 0x00 , 0xdb , 0x819c } ,
{ 0x00 , 0xdb , 0x81ad } ,
{ 0x00 , 0xdb , 0x81be } ,
{ 0x00 , 0xe4 , 0x819d } ,
{ 0x00 , 0xe4 , 0x81ae } ,
{ 0x00 , 0xe4 , 0x81bf } ,
{ 0x00 , 0xed , 0x819e } ,
{ 0x00 , 0xed , 0x81af } ,
{ 0x00 , 0xed , 0x81c0 } ,
{ 0x00 , 0xf7 , 0x819f } ,
{ 0x00 , 0xf7 , 0x81b0 } ,
{ 0x00 , 0xf7 , 0x81c1 } ,
{ 0x00 , 0xff , 0x81a0 } ,
{ 0x00 , 0xff , 0x81b1 } ,
{ 0x00 , 0xff , 0x81c2 } ,
{ 0x00 , 0x03 , 0x8156 } ,
{ 0x00 , 0x00 , 0x8211 } ,
{ 0x00 , 0x20 , 0x8168 } ,
{ 0x00 , 0x01 , 0x8202 } ,
{ 0x00 , 0x30 , 0x8101 } ,
{ 0x00 , 0x00 , 0x8111 } ,
{ 0x00 , 0x00 , 0x8112 } ,
{ 0x00 , 0x00 , 0x8113 } ,
{ 0x00 , 0x00 , 0x8114 } ,
{ }
} ;
2008-07-04 11:16:16 -03:00
static const __u8 qtable_creative_pccam [ 2 ] [ 64 ] = {
2008-06-30 15:50:11 -03:00
{ /* Q-table Y-components */
0x05 , 0x03 , 0x03 , 0x05 , 0x07 , 0x0c , 0x0f , 0x12 ,
0x04 , 0x04 , 0x04 , 0x06 , 0x08 , 0x11 , 0x12 , 0x11 ,
0x04 , 0x04 , 0x05 , 0x07 , 0x0c , 0x11 , 0x15 , 0x11 ,
0x04 , 0x05 , 0x07 , 0x09 , 0x0f , 0x1a , 0x18 , 0x13 ,
0x05 , 0x07 , 0x0b , 0x11 , 0x14 , 0x21 , 0x1f , 0x17 ,
0x07 , 0x0b , 0x11 , 0x13 , 0x18 , 0x1f , 0x22 , 0x1c ,
0x0f , 0x13 , 0x17 , 0x1a , 0x1f , 0x24 , 0x24 , 0x1e ,
0x16 , 0x1c , 0x1d , 0x1d , 0x22 , 0x1e , 0x1f , 0x1e } ,
{ /* Q-table C-components */
0x05 , 0x05 , 0x07 , 0x0e , 0x1e , 0x1e , 0x1e , 0x1e ,
0x05 , 0x06 , 0x08 , 0x14 , 0x1e , 0x1e , 0x1e , 0x1e ,
0x07 , 0x08 , 0x11 , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e ,
0x0e , 0x14 , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e ,
0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e ,
0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e ,
0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e ,
0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e , 0x1e }
} ;
2008-07-04 11:16:16 -03:00
static const __u8 qtable_kodak_ez200 [ 2 ] [ 64 ] = {
2008-06-30 15:50:11 -03:00
{ /* Q-table Y-components */
0x02 , 0x01 , 0x01 , 0x02 , 0x02 , 0x04 , 0x05 , 0x06 ,
0x01 , 0x01 , 0x01 , 0x02 , 0x03 , 0x06 , 0x06 , 0x06 ,
0x01 , 0x01 , 0x02 , 0x02 , 0x04 , 0x06 , 0x07 , 0x06 ,
0x01 , 0x02 , 0x02 , 0x03 , 0x05 , 0x09 , 0x08 , 0x06 ,
0x02 , 0x02 , 0x04 , 0x06 , 0x07 , 0x0b , 0x0a , 0x08 ,
0x02 , 0x04 , 0x06 , 0x06 , 0x08 , 0x0a , 0x0b , 0x09 ,
0x05 , 0x06 , 0x08 , 0x09 , 0x0a , 0x0c , 0x0c , 0x0a ,
0x07 , 0x09 , 0x0a , 0x0a , 0x0b , 0x0a , 0x0a , 0x0a } ,
{ /* Q-table C-components */
0x02 , 0x02 , 0x02 , 0x05 , 0x0a , 0x0a , 0x0a , 0x0a ,
0x02 , 0x02 , 0x03 , 0x07 , 0x0a , 0x0a , 0x0a , 0x0a ,
0x02 , 0x03 , 0x06 , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a ,
0x05 , 0x07 , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a ,
0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a ,
0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a ,
0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a ,
0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a , 0x0a }
} ;
2008-07-04 11:16:16 -03:00
static const __u8 qtable_pocketdv [ 2 ] [ 64 ] = {
2008-07-01 10:03:42 -03:00
{ /* Q-table Y-components start registers 0x8800 */
2008-06-30 15:50:11 -03:00
0x06 , 0x04 , 0x04 , 0x06 , 0x0a , 0x10 , 0x14 , 0x18 ,
0x05 , 0x05 , 0x06 , 0x08 , 0x0a , 0x17 , 0x18 , 0x16 ,
0x06 , 0x05 , 0x06 , 0x0a , 0x10 , 0x17 , 0x1c , 0x16 ,
0x06 , 0x07 , 0x09 , 0x0c , 0x14 , 0x23 , 0x20 , 0x19 ,
0x07 , 0x09 , 0x0f , 0x16 , 0x1b , 0x2c , 0x29 , 0x1f ,
0x0a , 0x0e , 0x16 , 0x1a , 0x20 , 0x2a , 0x2d , 0x25 ,
0x14 , 0x1a , 0x1f , 0x23 , 0x29 , 0x30 , 0x30 , 0x28 ,
0x1d , 0x25 , 0x26 , 0x27 , 0x2d , 0x28 , 0x29 , 0x28 ,
} ,
2008-07-01 10:03:42 -03:00
{ /* Q-table C-components start registers 0x8840 */
2008-06-30 15:50:11 -03:00
0x07 , 0x07 , 0x0a , 0x13 , 0x28 , 0x28 , 0x28 , 0x28 ,
0x07 , 0x08 , 0x0a , 0x1a , 0x28 , 0x28 , 0x28 , 0x28 ,
0x0a , 0x0a , 0x16 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 ,
0x13 , 0x1a , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 ,
0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 ,
0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 ,
0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 ,
0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 , 0x28 }
} ;
2008-07-14 09:38:29 -03:00
/* read 'len' bytes to gspca_dev->usb_buf */
static void reg_r ( struct gspca_dev * gspca_dev ,
__u16 index ,
__u16 length )
2008-06-30 15:50:11 -03:00
{
2008-07-14 09:38:29 -03:00
usb_control_msg ( gspca_dev - > dev ,
usb_rcvctrlpipe ( gspca_dev - > dev , 0 ) ,
2008-06-30 15:50:11 -03:00
0 ,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE ,
0 , /* value */
2008-07-14 09:38:29 -03:00
index , gspca_dev - > usb_buf , length , 500 ) ;
2008-06-30 15:50:11 -03:00
}
2008-07-14 09:38:29 -03:00
static int reg_w ( struct gspca_dev * gspca_dev ,
2008-06-30 15:50:11 -03:00
__u16 req , __u16 index , __u16 value )
{
int ret ;
2008-07-04 11:16:16 -03:00
PDEBUG ( D_USBO , " reg write: [0x%02x] = 0x%02x " , index , value ) ;
2008-07-14 09:38:29 -03:00
ret = usb_control_msg ( gspca_dev - > dev ,
usb_sndctrlpipe ( gspca_dev - > dev , 0 ) ,
2008-06-30 15:50:11 -03:00
req ,
2008-07-03 11:09:12 -03:00
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE ,
2008-06-30 15:50:11 -03:00
value , index , NULL , 0 , 500 ) ;
if ( ret < 0 )
2011-08-21 19:56:57 -03:00
pr_err ( " reg write: error %d \n " , ret ) ;
2008-06-30 15:50:11 -03:00
return ret ;
}
/* returns: negative is error, pos or zero is data */
2008-07-14 09:38:29 -03:00
static int reg_r_12 ( struct gspca_dev * gspca_dev ,
2008-06-30 15:50:11 -03:00
__u16 req , /* bRequest */
__u16 index , /* wIndex */
__u16 length ) /* wLength (1 or 2 only) */
{
int ret ;
2008-07-14 09:38:29 -03:00
gspca_dev - > usb_buf [ 1 ] = 0 ;
ret = usb_control_msg ( gspca_dev - > dev ,
usb_rcvctrlpipe ( gspca_dev - > dev , 0 ) ,
2008-06-30 15:50:11 -03:00
req ,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE ,
0 , /* value */
index ,
2008-07-14 09:38:29 -03:00
gspca_dev - > usb_buf , length ,
2008-06-30 15:50:11 -03:00
500 ) ; /* timeout */
if ( ret < 0 ) {
2011-08-21 19:56:57 -03:00
pr_err ( " reg_r_12 err %d \n " , ret ) ;
2010-09-13 05:19:58 -03:00
return ret ;
2008-06-30 15:50:11 -03:00
}
2008-07-14 09:38:29 -03:00
return ( gspca_dev - > usb_buf [ 1 ] < < 8 ) + gspca_dev - > usb_buf [ 0 ] ;
2008-06-30 15:50:11 -03:00
}
/*
* Simple function to wait for a given 8 - bit value to be returned from
* a reg_read call .
* Returns : negative is error or timeout , zero is success .
*/
2008-07-14 09:38:29 -03:00
static int reg_r_wait ( struct gspca_dev * gspca_dev ,
2008-06-30 15:50:11 -03:00
__u16 reg , __u16 index , __u16 value )
{
int ret , cnt = 20 ;
while ( - - cnt > 0 ) {
2008-07-14 09:38:29 -03:00
ret = reg_r_12 ( gspca_dev , reg , index , 1 ) ;
2008-06-30 15:50:11 -03:00
if ( ret = = value )
return 0 ;
msleep ( 50 ) ;
}
return - EIO ;
}
static int write_vector ( struct gspca_dev * gspca_dev ,
2008-07-04 11:16:16 -03:00
const __u16 data [ ] [ 3 ] )
2008-06-30 15:50:11 -03:00
{
int ret , i = 0 ;
while ( data [ i ] [ 0 ] ! = 0 | | data [ i ] [ 1 ] ! = 0 | | data [ i ] [ 2 ] ! = 0 ) {
2008-07-14 09:38:29 -03:00
ret = reg_w ( gspca_dev , data [ i ] [ 0 ] , data [ i ] [ 2 ] , data [ i ] [ 1 ] ) ;
2008-06-30 15:50:11 -03:00
if ( ret < 0 )
return ret ;
i + + ;
}
return 0 ;
}
static int spca50x_setup_qtable ( struct gspca_dev * gspca_dev ,
unsigned int request ,
unsigned int ybase ,
unsigned int cbase ,
2008-07-04 11:16:16 -03:00
const __u8 qtable [ 2 ] [ 64 ] )
2008-06-30 15:50:11 -03:00
{
int i , err ;
/* loop over y components */
for ( i = 0 ; i < 64 ; i + + ) {
2008-07-14 09:38:29 -03:00
err = reg_w ( gspca_dev , request , ybase + i , qtable [ 0 ] [ i ] ) ;
2008-06-30 15:50:11 -03:00
if ( err < 0 )
return err ;
}
/* loop over c components */
for ( i = 0 ; i < 64 ; i + + ) {
2008-07-14 09:38:29 -03:00
err = reg_w ( gspca_dev , request , cbase + i , qtable [ 1 ] [ i ] ) ;
2008-06-30 15:50:11 -03:00
if ( err < 0 )
return err ;
}
return 0 ;
}
static void spca500_ping310 ( struct gspca_dev * gspca_dev )
{
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x0d04 , 2 ) ;
2008-07-04 11:16:16 -03:00
PDEBUG ( D_STREAM , " ClickSmart310 ping 0x0d04 0x%02x 0x%02x " ,
2008-07-14 09:38:29 -03:00
gspca_dev - > usb_buf [ 0 ] , gspca_dev - > usb_buf [ 1 ] ) ;
2008-06-30 15:50:11 -03:00
}
static void spca500_clksmart310_init ( struct gspca_dev * gspca_dev )
{
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x0d05 , 2 ) ;
2008-07-04 11:16:16 -03:00
PDEBUG ( D_STREAM , " ClickSmart310 init 0x0d05 0x%02x 0x%02x " ,
2008-07-14 09:38:29 -03:00
gspca_dev - > usb_buf [ 0 ] , gspca_dev - > usb_buf [ 1 ] ) ;
reg_w ( gspca_dev , 0x00 , 0x8167 , 0x5a ) ;
2008-06-30 15:50:11 -03:00
spca500_ping310 ( gspca_dev ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8168 , 0x22 ) ;
reg_w ( gspca_dev , 0x00 , 0x816a , 0xc0 ) ;
reg_w ( gspca_dev , 0x00 , 0x816b , 0x0b ) ;
reg_w ( gspca_dev , 0x00 , 0x8169 , 0x25 ) ;
reg_w ( gspca_dev , 0x00 , 0x8157 , 0x5b ) ;
reg_w ( gspca_dev , 0x00 , 0x8158 , 0x5b ) ;
reg_w ( gspca_dev , 0x00 , 0x813f , 0x03 ) ;
reg_w ( gspca_dev , 0x00 , 0x8151 , 0x4a ) ;
reg_w ( gspca_dev , 0x00 , 0x8153 , 0x78 ) ;
reg_w ( gspca_dev , 0x00 , 0x0d01 , 0x04 ) ;
2008-06-30 15:50:11 -03:00
/* 00 for adjust shutter */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x0d02 , 0x01 ) ;
reg_w ( gspca_dev , 0x00 , 0x8169 , 0x25 ) ;
reg_w ( gspca_dev , 0x00 , 0x0d01 , 0x02 ) ;
2008-06-30 15:50:11 -03:00
}
static void spca500_setmode ( struct gspca_dev * gspca_dev ,
__u8 xmult , __u8 ymult )
{
int mode ;
/* set x multiplier */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0 , 0x8001 , xmult ) ;
2008-06-30 15:50:11 -03:00
/* set y multiplier */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0 , 0x8002 , ymult ) ;
2008-06-30 15:50:11 -03:00
/* use compressed mode, VGA, with mode specific subsample */
2008-07-05 11:49:20 -03:00
mode = gspca_dev - > cam . cam_mode [ ( int ) gspca_dev - > curr_mode ] . priv ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0 , 0x8003 , mode < < 4 ) ;
2008-06-30 15:50:11 -03:00
}
static int spca500_full_reset ( struct gspca_dev * gspca_dev )
{
int err ;
/* send the reset command */
2008-07-14 09:38:29 -03:00
err = reg_w ( gspca_dev , 0xe0 , 0x0001 , 0x0000 ) ;
2008-06-30 15:50:11 -03:00
if ( err < 0 )
return err ;
/* wait for the reset to complete */
2008-07-14 09:38:29 -03:00
err = reg_r_wait ( gspca_dev , 0x06 , 0x0000 , 0x0000 ) ;
2008-06-30 15:50:11 -03:00
if ( err < 0 )
return err ;
2008-07-14 09:38:29 -03:00
err = reg_w ( gspca_dev , 0xe0 , 0x0000 , 0x0000 ) ;
2008-06-30 15:50:11 -03:00
if ( err < 0 )
return err ;
2008-07-14 09:38:29 -03:00
err = reg_r_wait ( gspca_dev , 0x06 , 0 , 0 ) ;
2008-06-30 15:50:11 -03:00
if ( err < 0 ) {
2013-02-04 13:17:55 -03:00
PERR ( " reg_r_wait() failed " ) ;
2008-06-30 15:50:11 -03:00
return err ;
}
/* all ok */
return 0 ;
}
/* Synchro the Bridge with sensor */
/* Maybe that will work on all spca500 chip */
/* because i only own a clicksmart310 try for that chip */
/* using spca50x_set_packet_size() cause an Ooops here */
/* usb_set_interface from kernel 2.6.x clear all the urb stuff */
/* up-port the same feature as in 2.4.x kernel */
static int spca500_synch310 ( struct gspca_dev * gspca_dev )
{
if ( usb_set_interface ( gspca_dev - > dev , gspca_dev - > iface , 0 ) < 0 ) {
2013-02-04 13:17:55 -03:00
PERR ( " Set packet size: set interface error " ) ;
2008-06-30 15:50:11 -03:00
goto error ;
}
spca500_ping310 ( gspca_dev ) ;
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x0d00 , 1 ) ;
2008-06-30 15:50:11 -03:00
/* need alt setting here */
PDEBUG ( D_PACK , " ClickSmart310 sync alt: %d " , gspca_dev - > alt ) ;
/* Windoze use pipe with altsetting 6 why 7 here */
if ( usb_set_interface ( gspca_dev - > dev ,
gspca_dev - > iface ,
gspca_dev - > alt ) < 0 ) {
2013-02-04 13:17:55 -03:00
PERR ( " Set packet size: set interface error " ) ;
2008-06-30 15:50:11 -03:00
goto error ;
}
return 0 ;
error :
return - EBUSY ;
}
static void spca500_reinit ( struct gspca_dev * gspca_dev )
{
int err ;
__u8 Data ;
tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-11-14 13:09:05 -02:00
/* some unknown command from Aiptek pocket dv and family300 */
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x0d01 , 0x01 ) ;
reg_w ( gspca_dev , 0x00 , 0x0d03 , 0x00 ) ;
reg_w ( gspca_dev , 0x00 , 0x0d02 , 0x01 ) ;
2008-06-30 15:50:11 -03:00
/* enable drop packet */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x850a , 0x0001 ) ;
2008-06-30 15:50:11 -03:00
err = spca50x_setup_qtable ( gspca_dev , 0x00 , 0x8800 , 0x8840 ,
qtable_pocketdv ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca50x_setup_qtable failed on init " ) ;
2008-06-30 15:50:11 -03:00
/* set qtable index */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8880 , 2 ) ;
2008-06-30 15:50:11 -03:00
/* family cam Quicksmart stuff */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x800a , 0x00 ) ;
2011-03-30 22:57:33 -03:00
/* Set agc transfer: synced between frames */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x820f , 0x01 ) ;
2008-06-30 15:50:11 -03:00
/* Init SDRAM - needed for SDRAM access */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x870a , 0x04 ) ;
2008-06-30 15:50:11 -03:00
/*Start init sequence or stream */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0 , 0x8003 , 0x00 ) ;
2008-06-30 15:50:11 -03:00
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
msleep ( 2000 ) ;
2008-07-14 09:38:29 -03:00
if ( reg_r_wait ( gspca_dev , 0 , 0x8000 , 0x44 ) ! = 0 ) {
reg_r ( gspca_dev , 0x816b , 1 ) ;
Data = gspca_dev - > usb_buf [ 0 ] ;
reg_w ( gspca_dev , 0x00 , 0x816b , Data ) ;
}
2008-06-30 15:50:11 -03:00
}
/* this function is called at probe time */
static int sd_config ( struct gspca_dev * gspca_dev ,
const struct usb_device_id * id )
{
struct sd * sd = ( struct sd * ) gspca_dev ;
struct cam * cam ;
2008-07-25 08:53:03 -03:00
2008-06-30 15:50:11 -03:00
cam = & gspca_dev - > cam ;
2008-07-25 08:53:03 -03:00
sd - > subtype = id - > driver_info ;
2008-06-30 15:50:11 -03:00
if ( sd - > subtype ! = LogitechClickSmart310 ) {
cam - > cam_mode = vga_mode ;
2008-11-12 23:18:21 -03:00
cam - > nmodes = ARRAY_SIZE ( vga_mode ) ;
2008-06-30 15:50:11 -03:00
} else {
cam - > cam_mode = sif_mode ;
2008-11-12 23:18:21 -03:00
cam - > nmodes = ARRAY_SIZE ( sif_mode ) ;
2008-06-30 15:50:11 -03:00
}
return 0 ;
}
2008-09-03 17:12:16 -03:00
/* this function is called at probe and resume time */
static int sd_init ( struct gspca_dev * gspca_dev )
2008-06-30 15:50:11 -03:00
{
struct sd * sd = ( struct sd * ) gspca_dev ;
/* initialisation of spca500 based cameras is deferred */
PDEBUG ( D_STREAM , " SPCA500 init " ) ;
if ( sd - > subtype = = LogitechClickSmart310 )
spca500_clksmart310_init ( gspca_dev ) ;
/* else
spca500_initialise ( gspca_dev ) ; */
PDEBUG ( D_STREAM , " SPCA500 init done " ) ;
return 0 ;
}
2008-09-20 06:39:08 -03:00
static int sd_start ( struct gspca_dev * gspca_dev )
2008-06-30 15:50:11 -03:00
{
struct sd * sd = ( struct sd * ) gspca_dev ;
int err ;
__u8 Data ;
__u8 xmult , ymult ;
2009-03-03 05:33:41 -03:00
/* create the JPEG header */
2013-08-30 17:54:23 -03:00
jpeg_define ( sd - > jpeg_hdr , gspca_dev - > pixfmt . height ,
gspca_dev - > pixfmt . width ,
2009-03-03 05:33:41 -03:00
0x22 ) ; /* JPEG 411 */
2012-06-27 16:48:33 -03:00
jpeg_set_qual ( sd - > jpeg_hdr , QUALITY ) ;
2009-03-03 05:33:41 -03:00
2008-06-30 15:50:11 -03:00
if ( sd - > subtype = = LogitechClickSmart310 ) {
xmult = 0x16 ;
ymult = 0x12 ;
} else {
xmult = 0x28 ;
ymult = 0x1e ;
}
/* is there a sensor here ? */
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x8a04 , 1 ) ;
PDEBUG ( D_STREAM , " Spca500 Sensor Address 0x%02x " ,
gspca_dev - > usb_buf [ 0 ] ) ;
PDEBUG ( D_STREAM , " Spca500 curr_mode: %d Xmult: 0x%02x, Ymult: 0x%02x " ,
2008-06-30 15:50:11 -03:00
gspca_dev - > curr_mode , xmult , ymult ) ;
/* setup qtable */
switch ( sd - > subtype ) {
case LogitechClickSmart310 :
spca500_setmode ( gspca_dev , xmult , ymult ) ;
/* enable drop packet */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x850a , 0x0001 ) ;
reg_w ( gspca_dev , 0x00 , 0x8880 , 3 ) ;
2008-06-30 15:50:11 -03:00
err = spca50x_setup_qtable ( gspca_dev ,
0x00 , 0x8800 , 0x8840 ,
qtable_creative_pccam ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca50x_setup_qtable failed " ) ;
2008-06-30 15:50:11 -03:00
/* Init SDRAM - needed for SDRAM access */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x870a , 0x04 ) ;
2008-06-30 15:50:11 -03:00
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
msleep ( 500 ) ;
2008-07-14 09:38:29 -03:00
if ( reg_r_wait ( gspca_dev , 0 , 0x8000 , 0x44 ) ! = 0 )
2013-02-04 13:17:55 -03:00
PERR ( " reg_r_wait() failed " ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x816b , 1 ) ;
Data = gspca_dev - > usb_buf [ 0 ] ;
reg_w ( gspca_dev , 0x00 , 0x816b , Data ) ;
2008-06-30 15:50:11 -03:00
spca500_synch310 ( gspca_dev ) ;
write_vector ( gspca_dev , spca500_visual_defaults ) ;
spca500_setmode ( gspca_dev , xmult , ymult ) ;
/* enable drop packet */
2009-01-15 09:34:55 -03:00
err = reg_w ( gspca_dev , 0x00 , 0x850a , 0x0001 ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " failed to enable drop packet " ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8880 , 3 ) ;
2008-06-30 15:50:11 -03:00
err = spca50x_setup_qtable ( gspca_dev ,
0x00 , 0x8800 , 0x8840 ,
qtable_creative_pccam ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca50x_setup_qtable failed " ) ;
2008-06-30 15:50:11 -03:00
/* Init SDRAM - needed for SDRAM access */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x870a , 0x04 ) ;
2008-06-30 15:50:11 -03:00
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
if ( reg_r_wait ( gspca_dev , 0 , 0x8000 , 0x44 ) ! = 0 )
2013-02-04 13:17:55 -03:00
PERR ( " reg_r_wait() failed " ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x816b , 1 ) ;
Data = gspca_dev - > usb_buf [ 0 ] ;
reg_w ( gspca_dev , 0x00 , 0x816b , Data ) ;
2008-06-30 15:50:11 -03:00
break ;
case CreativePCCam300 : /* Creative PC-CAM 300 640x480 CCD */
case IntelPocketPCCamera : /* FIXME: Temporary fix for
* Intel Pocket PC Camera
* - NWG ( Sat 29 th March 2003 ) */
/* do a full reset */
2008-07-01 10:03:42 -03:00
err = spca500_full_reset ( gspca_dev ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca500_full_reset failed " ) ;
2008-06-30 15:50:11 -03:00
/* enable drop packet */
2008-07-14 09:38:29 -03:00
err = reg_w ( gspca_dev , 0x00 , 0x850a , 0x0001 ) ;
2008-06-30 15:50:11 -03:00
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " failed to enable drop packet " ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8880 , 3 ) ;
2008-06-30 15:50:11 -03:00
err = spca50x_setup_qtable ( gspca_dev ,
0x00 , 0x8800 , 0x8840 ,
qtable_creative_pccam ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca50x_setup_qtable failed " ) ;
2008-06-30 15:50:11 -03:00
spca500_setmode ( gspca_dev , xmult , ymult ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x20 , 0x0001 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
if ( reg_r_wait ( gspca_dev , 0 , 0x8000 , 0x44 ) ! = 0 )
2013-02-04 13:17:55 -03:00
PERR ( " reg_r_wait() failed " ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x816b , 1 ) ;
Data = gspca_dev - > usb_buf [ 0 ] ;
reg_w ( gspca_dev , 0x00 , 0x816b , Data ) ;
2008-06-30 15:50:11 -03:00
2008-07-04 11:16:16 -03:00
/* write_vector(gspca_dev, spca500_visual_defaults); */
2008-06-30 15:50:11 -03:00
break ;
case KodakEZ200 : /* Kodak EZ200 */
/* do a full reset */
err = spca500_full_reset ( gspca_dev ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca500_full_reset failed " ) ;
2008-06-30 15:50:11 -03:00
/* enable drop packet */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x850a , 0x0001 ) ;
reg_w ( gspca_dev , 0x00 , 0x8880 , 0 ) ;
2008-06-30 15:50:11 -03:00
err = spca50x_setup_qtable ( gspca_dev ,
0x00 , 0x8800 , 0x8840 ,
qtable_kodak_ez200 ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca50x_setup_qtable failed " ) ;
2008-06-30 15:50:11 -03:00
spca500_setmode ( gspca_dev , xmult , ymult ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x20 , 0x0001 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
if ( reg_r_wait ( gspca_dev , 0 , 0x8000 , 0x44 ) ! = 0 )
2013-02-04 13:17:55 -03:00
PERR ( " reg_r_wait() failed " ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x816b , 1 ) ;
Data = gspca_dev - > usb_buf [ 0 ] ;
reg_w ( gspca_dev , 0x00 , 0x816b , Data ) ;
2008-06-30 15:50:11 -03:00
2008-07-04 11:16:16 -03:00
/* write_vector(gspca_dev, spca500_visual_defaults); */
2008-06-30 15:50:11 -03:00
break ;
case BenqDC1016 :
case DLinkDSC350 : /* FamilyCam 300 */
case AiptekPocketDV : /* Aiptek PocketDV */
case Gsmartmini : /*Mustek Gsmart Mini */
case MustekGsmart300 : /* Mustek Gsmart 300 */
case PalmPixDC85 :
case Optimedia :
case ToptroIndus :
case AgfaCl20 :
spca500_reinit ( gspca_dev ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x0d01 , 0x01 ) ;
2008-06-30 15:50:11 -03:00
/* enable drop packet */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x850a , 0x0001 ) ;
2008-06-30 15:50:11 -03:00
err = spca50x_setup_qtable ( gspca_dev ,
0x00 , 0x8800 , 0x8840 , qtable_pocketdv ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca50x_setup_qtable failed " ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8880 , 2 ) ;
2008-06-30 15:50:11 -03:00
/* familycam Quicksmart pocketDV stuff */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x800a , 0x00 ) ;
2011-03-30 22:57:33 -03:00
/* Set agc transfer: synced between frames */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x820f , 0x01 ) ;
2008-06-30 15:50:11 -03:00
/* Init SDRAM - needed for SDRAM access */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x870a , 0x04 ) ;
2008-06-30 15:50:11 -03:00
2008-07-01 10:03:42 -03:00
spca500_setmode ( gspca_dev , xmult , ymult ) ;
2008-06-30 15:50:11 -03:00
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_r_wait ( gspca_dev , 0 , 0x8000 , 0x44 ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x816b , 1 ) ;
Data = gspca_dev - > usb_buf [ 0 ] ;
reg_w ( gspca_dev , 0x00 , 0x816b , Data ) ;
2008-06-30 15:50:11 -03:00
break ;
case LogitechTraveler :
case LogitechClickSmart510 :
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x02 , 0x00 , 0x00 ) ;
2008-06-30 15:50:11 -03:00
/* enable drop packet */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x850a , 0x0001 ) ;
2008-06-30 15:50:11 -03:00
err = spca50x_setup_qtable ( gspca_dev ,
0x00 , 0x8800 ,
0x8840 , qtable_creative_pccam ) ;
if ( err < 0 )
2013-02-04 13:17:55 -03:00
PERR ( " spca50x_setup_qtable failed " ) ;
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8880 , 3 ) ;
reg_w ( gspca_dev , 0x00 , 0x800a , 0x00 ) ;
2008-06-30 15:50:11 -03:00
/* Init SDRAM - needed for SDRAM access */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x870a , 0x04 ) ;
2008-06-30 15:50:11 -03:00
spca500_setmode ( gspca_dev , xmult , ymult ) ;
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
reg_r_wait ( gspca_dev , 0 , 0x8000 , 0x44 ) ;
2008-06-30 15:50:11 -03:00
2008-07-14 09:38:29 -03:00
reg_r ( gspca_dev , 0x816b , 1 ) ;
Data = gspca_dev - > usb_buf [ 0 ] ;
reg_w ( gspca_dev , 0x00 , 0x816b , Data ) ;
2008-06-30 15:50:11 -03:00
write_vector ( gspca_dev , Clicksmart510_defaults ) ;
break ;
}
2008-09-20 06:39:08 -03:00
return 0 ;
2008-06-30 15:50:11 -03:00
}
static void sd_stopN ( struct gspca_dev * gspca_dev )
{
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0 , 0x8003 , 0x00 ) ;
2008-06-30 15:50:11 -03:00
/* switch to video camera mode */
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8000 , 0x0004 ) ;
reg_r ( gspca_dev , 0x8000 , 1 ) ;
PDEBUG ( D_STREAM , " stop SPCA500 done reg8000: 0x%2x " ,
gspca_dev - > usb_buf [ 0 ] ) ;
2008-06-30 15:50:11 -03:00
}
static void sd_pkt_scan ( struct gspca_dev * gspca_dev ,
2009-11-13 09:21:03 -03:00
u8 * data , /* isoc packet */
2008-06-30 15:50:11 -03:00
int len ) /* iso packet length */
{
struct sd * sd = ( struct sd * ) gspca_dev ;
int i ;
2008-07-04 11:16:16 -03:00
static __u8 ffd9 [ ] = { 0xff , 0xd9 } ;
2008-06-30 15:50:11 -03:00
/* frames are jpeg 4.1.1 without 0xff escape */
if ( data [ 0 ] = = 0xff ) {
if ( data [ 1 ] ! = 0x01 ) { /* drop packet */
/* gspca_dev->last_packet_type = DISCARD_PACKET; */
return ;
}
2009-11-13 09:21:03 -03:00
gspca_frame_add ( gspca_dev , LAST_PACKET ,
2008-06-30 15:50:11 -03:00
ffd9 , 2 ) ;
/* put the JPEG header in the new frame */
2009-11-13 09:21:03 -03:00
gspca_frame_add ( gspca_dev , FIRST_PACKET ,
2009-03-03 05:33:41 -03:00
sd - > jpeg_hdr , JPEG_HDR_SZ ) ;
2008-06-30 15:50:11 -03:00
data + = SPCA500_OFFSET_DATA ;
len - = SPCA500_OFFSET_DATA ;
} else {
data + = 1 ;
len - = 1 ;
}
/* add 0x00 after 0xff */
2009-04-23 14:33:00 -03:00
i = 0 ;
do {
if ( data [ i ] = = 0xff ) {
2009-11-13 09:21:03 -03:00
gspca_frame_add ( gspca_dev , INTER_PACKET ,
2009-04-23 14:33:00 -03:00
data , i + 1 ) ;
len - = i ;
data + = i ;
* data = 0x00 ;
i = 0 ;
}
i + + ;
} while ( i < len ) ;
2009-11-13 09:21:03 -03:00
gspca_frame_add ( gspca_dev , INTER_PACKET , data , len ) ;
2008-06-30 15:50:11 -03:00
}
2012-05-16 07:29:00 -03:00
static void setbrightness ( struct gspca_dev * gspca_dev , s32 val )
2008-06-30 15:50:11 -03:00
{
2008-07-14 09:38:29 -03:00
reg_w ( gspca_dev , 0x00 , 0x8167 ,
2012-05-16 07:29:00 -03:00
( __u8 ) ( val - 128 ) ) ;
2008-06-30 15:50:11 -03:00
}
2012-05-16 07:29:00 -03:00
static void setcontrast ( struct gspca_dev * gspca_dev , s32 val )
2008-06-30 15:50:11 -03:00
{
2012-05-16 07:29:00 -03:00
reg_w ( gspca_dev , 0x00 , 0x8168 , val ) ;
2008-06-30 15:50:11 -03:00
}
2012-05-16 07:29:00 -03:00
static void setcolors ( struct gspca_dev * gspca_dev , s32 val )
2008-06-30 15:50:11 -03:00
{
2012-05-16 07:29:00 -03:00
reg_w ( gspca_dev , 0x00 , 0x8169 , val ) ;
2008-06-30 15:50:11 -03:00
}
2012-05-16 07:29:00 -03:00
static int sd_s_ctrl ( struct v4l2_ctrl * ctrl )
2008-06-30 15:50:11 -03:00
{
2012-05-16 07:29:00 -03:00
struct gspca_dev * gspca_dev =
container_of ( ctrl - > handler , struct gspca_dev , ctrl_handler ) ;
2008-06-30 15:50:11 -03:00
2012-05-16 07:29:00 -03:00
gspca_dev - > usb_err = 0 ;
2008-06-30 15:50:11 -03:00
2012-05-16 07:29:00 -03:00
if ( ! gspca_dev - > streaming )
return 0 ;
2008-06-30 15:50:11 -03:00
2012-05-16 07:29:00 -03:00
switch ( ctrl - > id ) {
case V4L2_CID_BRIGHTNESS :
setbrightness ( gspca_dev , ctrl - > val ) ;
break ;
case V4L2_CID_CONTRAST :
setcontrast ( gspca_dev , ctrl - > val ) ;
break ;
case V4L2_CID_SATURATION :
setcolors ( gspca_dev , ctrl - > val ) ;
break ;
}
return gspca_dev - > usb_err ;
2008-06-30 15:50:11 -03:00
}
2012-05-16 07:29:00 -03:00
static const struct v4l2_ctrl_ops sd_ctrl_ops = {
. s_ctrl = sd_s_ctrl ,
} ;
2009-03-02 06:40:52 -03:00
2012-05-16 07:29:00 -03:00
static int sd_init_controls ( struct gspca_dev * gspca_dev )
2009-03-02 06:40:52 -03:00
{
2012-05-16 07:29:00 -03:00
struct v4l2_ctrl_handler * hdl = & gspca_dev - > ctrl_handler ;
gspca_dev - > vdev . ctrl_handler = hdl ;
2012-06-27 16:48:33 -03:00
v4l2_ctrl_handler_init ( hdl , 3 ) ;
2012-05-16 07:29:00 -03:00
v4l2_ctrl_new_std ( hdl , & sd_ctrl_ops ,
V4L2_CID_BRIGHTNESS , 0 , 255 , 1 , 127 ) ;
v4l2_ctrl_new_std ( hdl , & sd_ctrl_ops ,
V4L2_CID_CONTRAST , 0 , 63 , 1 , 31 ) ;
v4l2_ctrl_new_std ( hdl , & sd_ctrl_ops ,
V4L2_CID_SATURATION , 0 , 63 , 1 , 31 ) ;
if ( hdl - > error ) {
pr_err ( " Could not initialize controls \n " ) ;
return hdl - > error ;
}
2009-03-02 06:40:52 -03:00
return 0 ;
}
2008-06-30 15:50:11 -03:00
/* sub-driver description */
2010-01-05 12:39:02 -03:00
static const struct sd_desc sd_desc = {
2008-06-30 15:50:11 -03:00
. name = MODULE_NAME ,
. config = sd_config ,
2008-09-03 17:12:16 -03:00
. init = sd_init ,
2012-05-16 07:29:00 -03:00
. init_controls = sd_init_controls ,
2008-06-30 15:50:11 -03:00
. start = sd_start ,
. stopN = sd_stopN ,
. pkt_scan = sd_pkt_scan ,
} ;
/* -- module initialisation -- */
2011-01-13 05:20:29 -03:00
static const struct usb_device_id device_table [ ] = {
2008-07-26 14:30:01 -03:00
{ USB_DEVICE ( 0x040a , 0x0300 ) , . driver_info = KodakEZ200 } ,
{ USB_DEVICE ( 0x041e , 0x400a ) , . driver_info = CreativePCCam300 } ,
{ USB_DEVICE ( 0x046d , 0x0890 ) , . driver_info = LogitechTraveler } ,
{ USB_DEVICE ( 0x046d , 0x0900 ) , . driver_info = LogitechClickSmart310 } ,
{ USB_DEVICE ( 0x046d , 0x0901 ) , . driver_info = LogitechClickSmart510 } ,
{ USB_DEVICE ( 0x04a5 , 0x300c ) , . driver_info = BenqDC1016 } ,
{ USB_DEVICE ( 0x04fc , 0x7333 ) , . driver_info = PalmPixDC85 } ,
{ USB_DEVICE ( 0x055f , 0xc200 ) , . driver_info = MustekGsmart300 } ,
{ USB_DEVICE ( 0x055f , 0xc220 ) , . driver_info = Gsmartmini } ,
{ USB_DEVICE ( 0x06bd , 0x0404 ) , . driver_info = AgfaCl20 } ,
{ USB_DEVICE ( 0x06be , 0x0800 ) , . driver_info = Optimedia } ,
{ USB_DEVICE ( 0x084d , 0x0003 ) , . driver_info = DLinkDSC350 } ,
{ USB_DEVICE ( 0x08ca , 0x0103 ) , . driver_info = AiptekPocketDV } ,
{ USB_DEVICE ( 0x2899 , 0x012c ) , . driver_info = ToptroIndus } ,
{ USB_DEVICE ( 0x8086 , 0x0630 ) , . driver_info = IntelPocketPCCamera } ,
2008-06-30 15:50:11 -03:00
{ }
} ;
MODULE_DEVICE_TABLE ( usb , device_table ) ;
/* -- device connect -- */
static int sd_probe ( struct usb_interface * intf ,
const struct usb_device_id * id )
{
return gspca_dev_probe ( intf , id , & sd_desc , sizeof ( struct sd ) ,
THIS_MODULE ) ;
}
static struct usb_driver sd_driver = {
. name = MODULE_NAME ,
. id_table = device_table ,
. probe = sd_probe ,
. disconnect = gspca_disconnect ,
2008-09-03 16:48:10 -03:00
# ifdef CONFIG_PM
. suspend = gspca_suspend ,
. resume = gspca_resume ,
2012-06-30 06:44:47 -03:00
. reset_resume = gspca_resume ,
2008-09-03 16:48:10 -03:00
# endif
2008-06-30 15:50:11 -03:00
} ;
2011-11-18 09:46:12 -08:00
module_usb_driver ( sd_driver ) ;