aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/platform/msm/wfd/wfd-util.h
blob: a04e16a66131d012de551ba9fd81deceb4e71b2b (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
/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * 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.
 *
 */

#include <linux/debugfs.h>
#include <linux/ktime.h>
#include <linux/list.h>
#include <linux/mutex.h>

#ifndef _WFD_UTIL_H_
#define _WFD_UTIL_H_

/*#define DEBUG_WFD*/

#define WFD_TAG "wfd: "
#define WFD_MSG_INFO(fmt...) pr_info(WFD_TAG fmt)
#define WFD_MSG_WARN(fmt...) pr_warning(WFD_TAG fmt)
#define WFD_MSG_ERR(fmt...) pr_err(WFD_TAG fmt)
#define WFD_MSG_CRIT(fmt...) pr_crit(WFD_TAG fmt)
#define WFD_MSG_DBG(fmt...) pr_debug(WFD_TAG fmt)


struct wfd_stats_encode_sample {
	ktime_t encode_start_ts;
	struct list_head list;
};

struct wfd_stats {
	struct mutex mutex;

	/* Output Buffers */
	uint32_t v4l2_buf_count;

	/* Input Buffers */
	uint32_t mdp_buf_count;
	uint32_t vsg_buf_count;
	uint32_t enc_buf_count;

	/* Other */
	uint32_t frames_encoded;
	uint32_t mdp_updates;

	uint32_t enc_avg_latency;
	uint32_t enc_cumulative_latency;
	uint32_t enc_latency_samples;
	struct list_head enc_queue;

	/* Debugfs entries */
	struct dentry *d_parent;
	struct dentry *d_v4l2_buf_count;
	struct dentry *d_mdp_buf_count;
	struct dentry *d_vsg_buf_count;
	struct dentry *d_enc_buf_count;
	struct dentry *d_frames_encoded;
	struct dentry *d_mdp_updates;
	struct dentry *d_enc_avg_latency;
};

enum wfd_stats_event {
	WFD_STAT_EVENT_CLIENT_QUEUE,
	WFD_STAT_EVENT_CLIENT_DEQUEUE,

	WFD_STAT_EVENT_MDP_QUEUE,
	WFD_STAT_EVENT_MDP_DEQUEUE,

	WFD_STAT_EVENT_VSG_QUEUE,
	WFD_STAT_EVENT_VSG_DEQUEUE,

	WFD_STAT_EVENT_ENC_QUEUE,
	WFD_STAT_EVENT_ENC_DEQUEUE,
};

int wfd_stats_setup(void);
int wfd_stats_init(struct wfd_stats *, int device);
int wfd_stats_update(struct wfd_stats *, enum wfd_stats_event);
int wfd_stats_deinit(struct wfd_stats *);
void wfd_stats_teardown(void);
#endif