2008-09-03 17:12:14 -03:00
/*
* Pixart PAC207BCA / PAC73xx common functions
*
* Copyright ( C ) 2008 Hans de Goede < j . w . r . degoede @ hhs . nl >
* Copyright ( C ) 2005 Thomas Kaiser thomas @ kaiser - linux . li
* Copyleft ( C ) 2005 Michel Xhaard mxhaard @ magic . fr
*
* 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
* ( at your option ) 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
*
*/
2008-09-03 17:12:17 -03:00
/* We calculate the autogain at the end of the transfer of a frame, at this
moment a frame with the old settings is being transmitted , and a frame is
being captured with the old settings . So if we adjust the autogain we must
ignore atleast the 2 next frames for the new settings to come into effect
before doing any other adjustments */
# define PAC_AUTOGAIN_IGNORE_FRAMES 3
2008-09-03 17:12:14 -03:00
static const unsigned char pac_sof_marker [ 5 ] =
{ 0xff , 0xff , 0x00 , 0xff , 0x96 } ;
static unsigned char * pac_find_sof ( struct gspca_dev * gspca_dev ,
unsigned char * m , int len )
{
struct sd * sd = ( struct sd * ) gspca_dev ;
int i ;
/* Search for the SOF marker (fixed part) in the header */
for ( i = 0 ; i < len ; i + + ) {
if ( m [ i ] = = pac_sof_marker [ sd - > sof_read ] ) {
sd - > sof_read + + ;
if ( sd - > sof_read = = sizeof ( pac_sof_marker ) ) {
2008-09-03 17:12:17 -03:00
PDEBUG ( D_FRAM ,
2008-09-03 17:12:14 -03:00
" SOF found, bytes to analyze: %u. "
" Frame starts at byte #%u " ,
len , i + 1 ) ;
sd - > sof_read = 0 ;
return m + i + 1 ;
}
} else {
sd - > sof_read = 0 ;
}
}
return NULL ;
}