1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* vcamera.h
3  *
4  * Copyright (c) 2015,2016 Marcus Meissner <marcus@jet.franken.de>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef __VCAMERA_H__
23 #define __VCAMERA_H__
24 
25 #undef FUZZ_PTP
26 
27 #include <stdio.h>
28 
29 typedef struct ptpcontainer {
30 	unsigned int size;
31 	unsigned int type;
32 	unsigned int code;
33 	unsigned int seqnr;
34 	unsigned int nparams;
35 	unsigned int params[6];
36 } ptpcontainer;
37 
38 typedef enum vcameratype {
39 	GENERIC_PTP,
40 	NIKON_D750
41 } vcameratype;
42 
43 typedef struct vcamera {
44 	int (*init)(struct vcamera*);
45 	int (*exit)(struct vcamera*);
46 	int (*open)(struct vcamera*, const char*port);
47 	int (*close)(struct vcamera*);
48 
49 	int (*read)(struct vcamera*,  int ep, unsigned char *data, int bytes);
50 	int (*readint)(struct vcamera*,  unsigned char *data, int bytes, int timeout);
51 	int (*write)(struct vcamera*, int ep, const unsigned char *data, int bytes);
52 
53 	unsigned short	vendor, product;	/* for generic fuzzing */
54 
55 	vcameratype	type;
56 	unsigned char	*inbulk;
57 	int		nrinbulk;
58 	unsigned char	*outbulk;
59 	int		nroutbulk;
60 
61 	unsigned int	seqnr;
62 
63 	unsigned int	session;
64 	ptpcontainer	ptpcmd;
65 
66 	int		exposurebias;
67 	unsigned int	shutterspeed;
68 	unsigned int	fnumber;
69 
70 	int		fuzzmode;
71 #define FUZZMODE_PROTOCOL	0
72 #define FUZZMODE_NORMAL		1
73 	FILE*		fuzzf;
74 	unsigned int	fuzzpending;
75 } vcamera;
76 
77 vcamera *vcamera_new(vcameratype);
78 
79 #endif
80