1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Pixart PAC207BCA / PAC73xx common functions
5 * Copyright (C) 2008 Hans de Goede <j.w.r.degoede@hhs.nl>
6 * Copyright (C) 2005 Thomas Kaiser thomas@kaiser-linux.li
7 * Copyleft (C) 2005 Michel Xhaard mxhaard@magic.fr
9 * V4L2 by Jean-Francois Moine <http://moinejf.free.fr>
12 /* We calculate the autogain at the end of the transfer of a frame, at this
13 moment a frame with the old settings is being captured and transmitted. So
14 if we adjust the gain or exposure we must ignore at least the next frame for
15 the new settings to come into effect before doing any other adjustments. */
16 #define PAC_AUTOGAIN_IGNORE_FRAMES 2
18 static const unsigned char pac_sof_marker
[5] =
19 { 0xff, 0xff, 0x00, 0xff, 0x96 };
22 The following state machine finds the SOF marker sequence
23 0xff, 0xff, 0x00, 0xff, 0x96 in a byte stream.
26 | 0: START |<---------------\
30 +----------+ otherwise |
31 | 1 |--------------->*
38 | | 2 |--------------->*
45 | | |--------------->*
46 | +----------+ otherwise ^
52 +----------+ otherwise
60 static unsigned char *pac_find_sof(struct gspca_dev
*gspca_dev
, u8
*sof_read
,
61 unsigned char *m
, int len
)
65 /* Search for the SOF marker (fixed part) in the header */
66 for (i
= 0; i
< len
; i
++) {
84 /* stay in this state */
100 gspca_dbg(gspca_dev
, D_FRAM
,
101 "SOF found, bytes to analyze: %u - Frame starts at byte #%u\n",