aboutsummaryrefslogtreecommitdiff
path: root/fmb_player_apl/include/CmdUtil.h
blob: 1fa50232a7fff91e723a678567f331463e9884fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/**
*	@brief 		Common header file for MB86 test program
*	@since		2009/01/08
*	@note		None
*	@attention	None
*	<B><I>COPYRIGHT FUJITSU LIMITED 2009</I></B>
*/

/*
 * 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.
 */

#ifndef __FMB_CMD_H__
#define __FMB_CMD_H__

#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>

#include <fmb_drv.h>

/********************************************************/
/*		Command define			*/
/********************************************************/

#define NG_USAGE	 	 -2
#define NG_PARAM_ERROR	 -3
#define NG_OPTION_ERROR	 -4
#define NG_VERIFY_ERROR  -5

#define NG_ERR_MALLOC	 -10
#define NG_ERR_IOCTL	 -11

#define VERIFY_PARAM	"/v"


#define HEXDEC_CHAR		"x0123456789abcdefABCDEF"

/********************************************************/
/*		Command description			*/
/********************************************************/

enum FMBCmdEnm {
	FMB_CMD_GPARAM,
	FMB_CMD_SPARAM,
	FMB_CMD_SCMD,
	FMB_CMD_SVPARAM,
	FMB_CMD_VCMD,
	FMB_CMD_SAPARAM,
	FMB_CMD_ACMD,
	FMB_CMD_SACK,
	FMB_CMD_RCBUF,
	FMB_CMD_SMSG,
	FMB_CMD_VMSG,
	FMB_CMD_AMSG,
	FMB_CMD_GFACT,
	FMB_CMD_RFACT,
	FMB_CMD_ASYNC,
	FMB_CMD_GLSI,
	FMB_CMD_SLSI,
	FMB_CMD_DLSI,
	FMB_CMD_GPCI,
	FMB_CMD_SPCI,
	FMB_CMD_GDATA,
	FMB_CMD_SDATA,
	FMB_CMD_VER,
	FMB_CMD_STRM,
	FMB_CMD_SLEEP,
	FMB_CMD_LOGSTART,
	FMB_CMD_LOGSTOP,
	FMB_CMD_GOPSTART,
	FMB_CMD_GOPSTOP,
	FMB_CMD_BOOT,
	FMB_CMD_HELP,
	FMB_CMD_WAIT_MODE,
	FMB_CMD_WAIT_SEQEND,
	FMB_CMD_WAIT_SYMSG,
	FMB_CMD_WAIT_SYACK,
	FMB_CMD_WAIT_STRM_SEND,
	FMB_CMD_WAIT_STRM_RCV,
	FMB_CMD_PAUSE,

};
///Kind of stream mode.
enum FMBStremModeEnum{
	FMBEnmRcv,		///<Stream recive
	FMBEnmSend,		///<Stream send
	FMBEnmRcvSend,	///<Stream recive and  send
	FMBEnmNothing,  ///<Stream Nothing
};

/********************************************************/
/*		parameter check information		*/
/********************************************************/

struct param_check {
	unsigned short	short_cnvdata;		/* convert data for short type */
	unsigned long	long_cnvdata;		/* convert data for long type */
	unsigned long	result;			/* parameter check result */
};

/********************************************************/
/*		ioctl control information               		*/
/********************************************************/
///Ioctl interface union.
union cmd_if_union {
	struct fmb_param_info param_info;
	struct fmb_ctl_param_info ctl_param_info;
	struct fmb_lib_cmd_sys_info{
		unsigned short			id;
		unsigned short			sub_id;
		struct fmb_cmd_sys_info cmd_sys_info;
	}lib_cmd_sys_info;
	struct fmb_cmd_video_info cmd_video_info;
	struct fmb_cmd_audio_info cmd_audio_info;
	struct fmb_cmd_ack_sys_info cmd_ack_sys_info;
	struct fmb_cmd_info_reset cmd_info_reset;
	struct fmb_msg_sys_info msg_sys_info;
	struct fmb_msg_video_info msg_video_info;
	struct fmb_msg_audio_info msg_audio_info;
	struct fmb_factor_info factor_info;
	struct fmb_factor_reset factor_reset;
	struct fmb_async_info async_info;
	struct fmb_reg_info reg_info;
	struct fmb_internal_info internal_info;
	struct fmb_pci_reg_info pci_reg_info;
	struct fmb_lib_version_info{
		char				    driver_ver[FMB_DRIVER_VERSION_LENGTH];
		unsigned short			firm_ver[FMB_VERSION_REG_SIZE / 2];
		struct fmb_version_info version_info;
	}lib_version_info;
};
///Ioctl lib private information.
struct ioctl_private_inf {
	enum FMBCmdEnm   cmd_id;						///<Ioctl ID.
	union cmd_if_union cmd_str;
	unsigned short* private_buf;
	unsigned short	private_data;
	unsigned long	private_ldata;
	int				fd;
};

struct ioctl_inf {
	unsigned short	short_cnvdata;		/* convert data for short type */
	unsigned long	long_cnvdata;		/* convert data for long type */
	unsigned long	result;			/* parameter check result */
};

/********************************************************/
/*		function call information		*/
/********************************************************/

typedef int (*FUNCTION)(struct ioctl_private_inf*, int , char**);

struct jump_head_table {
	char*		option_parameter;	/* option parameter string */
	FUNCTION	function_addr;
	unsigned int ioctl_cmd;
};

/********************************************************/
/*		error message information		*/
/********************************************************/

#define MSG_ERR_MALLOC		"malloc()"
#define MSG_ERR_IOCTL		"ioctl()"


/********************************************************/
/*		prototype description			*/
/********************************************************/
unsigned short FmbgetVmode( void );

unsigned short FmbgetVseqend( void );

unsigned short FmbgetSbody( void );

int FmbCreateArgment(char* keybuff,char** argvStr);

int FmbgetArg(char* sarchchar , int argc, char** argv);

int FmbgetArgOwn(char* sarchchar , int argc, char** argv);

void FmbErrPrint(char* comment , char* file , int line);

void FmbErrPrintUsr(char* comment , char* file , int line);

int FmbIoctlmain( int argc, char** argv);

void FmbUsageMainPrint(void);

void FmbStartCommandPrint(enum FMBCmdEnm   command_id);

void FmbEndCommandPrint(enum FMBCmdEnm   command_id);

struct SceTableType* FmbCeateCommandScenario(char* cmdbuff);

/********************************************************/
/*		Utility description			*/
/********************************************************/

///Boolean type
typedef enum BoolEnum{
	FALSE,
	TRUE
} BOOL;

/**
*	@brief		The number of indices of the array is returned.
*	@param[in]	array	Target array.
*	@return		Number of array elements.
*	@note		None
*	@attention	None
*/
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))

//It rounds up below the decimal point, and it converts it into the integer type.
unsigned int RoundUpDouble(double value);

//The character string is converted into the integer of the sign none.
//The value of the minus is returned for an invalid character string.
int StrToUnsignedInt(char *str);

__off64_t StrToOff64(char *str);


//It exclusive enters.
void EnterEx(void);

//It comes off exclusion.
void ExitEx(void);

void fprintOut( FILE *stream,const char *formatPtr, ...);
void gprintOut( const char *formatPtr, ...);
void printOut( const char *formatPtr, ...);
void vfprintOut (FILE *stream, __const char *formatPtr,_G_va_list arg_list);

BOOL StartLogFile(char* filepath ,char* att);

BOOL StopLogFile(void);

BOOL StartGopFile(char* filepath ,char* att);

BOOL StopGopFile(void);


/********************************************************/
/*		Debug description			*/
/********************************************************/

///Debug module property
struct DbgInfo{
	BOOL	isFuncTrace;
	BOOL	isRecvTrace;
	BOOL	isRecvDumpTrace;
	BOOL	isFmbLog;
	BOOL	isFmbLogCmd;
	BOOL	isSceTrace;
	BOOL	isScrLog;
	BOOL	isMessageFilterOn;
	BOOL	isAV_SYNC_Exit;
	BOOL	isFmbLogEvent;
	BOOL	isScrEventLog;
	BOOL	isTS_PSIZE_Exit;
	BOOL	isNotRecMessages;
};

extern struct DbgInfo	g_dbg;

void TraceFunc(	BOOL		isIn,
		const char	*fileName,
		const char	*funcName);

void InitDbg(char	*dbgOption);

/**
*	@brief		The result of the function that sets the error code in errno is inspected.
*	@param[in]	isOk	TRUE:No problem		FALSE:Log and abnormal end.
*	@param[in]	comment	Comment for logging.
*	@return		None
*	@note		None
*	@attention	None
*/
#define ASSERT_SYS(isOk, comment)	\
	do{\
		if(!(isOk)){\
			fprintf(stderr, "ERR:%s(%d)",__FILE__, __LINE__);\
			err(1, (comment));\
		}\
	}while(0)

/**
*	@brief		Inspection processing for program contradiction check.
*	@param[in]	isOk	TRUE:No problem		FALSE:Log and abnormal end.
*	@param[in]	comment	Comment for logging.
*	@return		None
*	@note		None
*	@attention	None
*/
#define ASSERT_USR(isOk, comment)	\
	do{\
		if(!(isOk)){\
			fprintf(stderr, "ERR:%s(%d):", __FILE__, __LINE__);\
			fprintf(stderr, "%s\n", (comment));\
			exit(1);\
		}\
	}while(0)


/**
*	@brief		The function trace is output to the standard error output.
*	@param[in]	isIn		TRUE:Function in.	FALSE:Function out.
*	@return		None
*	@note		None
*	@attention	None
*/
#define FMB_FUNC(isIn)		\
	do{\
		if(g_dbg.isFuncTrace){\
			TraceFunc((isIn), __FILE__, __func__);\
		}\
	}while(0)

void TraceRecv(int num, char *format, ...);
void LogFmb(char *format, ...);
void TraceSce(char *format, ...);
void TraceRecvDump(int num, char *head, unsigned short rcvs[], int size);
void LogScr(char *format, ...);

void InitFuncTraceMain();
void InitFuncTraceRecv(int num);
void InitFuncTraceRecvStream(int num);
void InitFuncTraceSendStream(int num);
void InitFuncTraceBoot(int num);

void SetFuncTraceCallDepth(int num, int callDepthMain, int callDepthRecv,
						   int callDepthRecSt, int callDepthSndSt,  int callDepthBoot);
void LogFmbEvent(int evnt[], int num);
void LogScrEvent(char *format, ...);
void LogFmbCmd(char *format, ...);

/********************************************************/
/*		prototype description			*/
/********************************************************/

int get_field_param(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int set_field_param(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int send_cmd_sys(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int set_video_param(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int send_cmd_video(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int set_audio_param(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int send_cmd_audio(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_sys_cmd_ack(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int reset_cmd_info(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_msg_sys(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_msg_video(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_msg_audio(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_factor(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int reset_factor(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_async_info(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_lsi_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int set_lsi_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int dump_lsi_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_pci_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int set_pci_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_drv_internal_info(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int set_drv_internal_info(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_i2c_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int set_i2c_reg(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int get_version_info(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int strm_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int sleep_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int logstart_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int logstop_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int gopstart_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int gopstop_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int boot_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);
int help_command(struct ioctl_private_inf* pri_inf, int argc, char** argv);

#endif /* ndef __FMB_CMD_H__ */