summaryrefstree
path: root/kernel/drivers/vision/vpu/include/vpu-debug.h
blob: caa9e25cde20641545c92b7792db13f129f1b1a6 (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
/*
 * Samsung Exynos SoC series VPU driver
 *
 * Copyright (c) 2015 Samsung Electronics Co., Ltd
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#ifndef VPU_DEBUG_H_
#define VPU_DEBUG_H_

#include <linux/types.h>
#include <linux/timer.h>

#include "vpu-config.h"

#define DEBUG_SENTENCE_MAX		300
#define DEBUG_MONITORING_PERIOD 	(HZ * 5)

struct vpu_debug_imgdump {
	struct dentry			*file;
	u32				target_graph;
	u32				target_chain;
	u32				target_pu;
	u32				target_index;
	void				*kvaddr;
	void				*cookie;
	size_t				length;
	size_t				offset;
};

struct vpu_debug_monitor {
	struct timer_list		timer;
	u32				time_cnt;
	u32				tick_cnt;
	u32				sched_cnt;
	u32				done_cnt;
};

enum vpu_debug_state {
	VPU_DEBUG_STATE_START
};

struct vpu_debug {
	unsigned long			state;

	struct dentry			*root;
	struct dentry			*logfile;
	struct dentry			*grpfile;
	struct dentry			*buffile;

	/* graph */
	void				*graphmgr_data;
	void				*system_data;

	struct vpu_debug_imgdump	imgdump;
	struct vpu_debug_monitor	monitor;
};

struct vpu_debug_log {
	size_t			dsentence_pos;
	char			dsentence[DEBUG_SENTENCE_MAX];
};

s32 atoi(const char *psz_buf);
int bitmap_scnprintf(char *buf, unsigned int buflen,
        const unsigned long *maskp, int nmaskbits);

int vpu_debug_probe(struct vpu_debug *debug, void *graphmgr_data, void *interface_data);
int vpu_debug_open(struct vpu_debug *debug);
int vpu_debug_close(struct vpu_debug *debug);
int vpu_debug_start(struct vpu_debug *debug);
int vpu_debug_stop(struct vpu_debug *debug);

void vpu_dmsg_concate(struct vpu_debug_log *log, const char *fmt, ...);
char * vpu_dmsg_print(struct vpu_debug_log *log);
int vpu_debug_memdump8(u8 *start, u8 *end);
int vpu_debug_memdump16(u16 *start, u16 *end);
int vpu_debug_memdump32(u32 *start, u32 *end);

#ifdef DBG_HISTORY
#define DLOG_INIT()		struct vpu_debug_log vpu_debug_log = { .dsentence_pos = 0 }
#define DLOG(fmt, ...)		vpu_dmsg_concate(&vpu_debug_log, fmt, ##__VA_ARGS__)
#define DLOG_OUT()		vpu_dmsg_print(&vpu_debug_log)
#else
#define DLOG_INIT()
#define DLOG(fmt, ...)
#define DLOG_OUT()		"FORBIDDEN HISTORY"
#endif

#endif