aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2/dsscomp/dsscomp.h
blob: 8634f044ad6daf749b13f39616c29febaa334aec (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
/*
 * linux/drivers/video/omap2/dsscomp/base.c
 *
 * DSS Composition basic operation support
 *
 * Copyright (C) 2011 Texas Instruments, Inc
 * Author: Lajos Molnar <molnar@ti.com>
 *
 * 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.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _DSSCOMP_H
#define _DSSCOMP_H

#include <linux/miscdevice.h>
#include <linux/debugfs.h>

#define MAX_OVERLAYS	5
#define MAX_MANAGERS	3
#define MAX_DISPLAYS	4

#define DEBUG_OVERLAYS		(1 << 0)
#define DEBUG_COMPOSITIONS	(1 << 1)
#define DEBUG_PHASES		(1 << 2)
#define DEBUG_WAITS		(1 << 3)
#define DEBUG_GRALLOC_PHASES	(1 << 4)

/*
 * Utility macros
 */
#define ZERO(c)		memset(&c, 0, sizeof(c))
#define ZEROn(c, n)	memset(c, 0, sizeof(*c) * n)
#define DEV(c)		(c->dev.this_device)

/**
 * DSS Composition Device Driver
 *
 * @dev:   misc device base
 * @dbgfs: debugfs hook
 */
struct dsscomp_dev {
	struct miscdevice dev;
	struct dentry *dbgfs;

	/* cached DSS objects */
	u32 num_ovls;
	struct omap_overlay *ovls[MAX_OVERLAYS];
	u32 num_mgrs;
	struct omap_overlay_manager *mgrs[MAX_MANAGERS];
	u32 num_displays;
	struct omap_dss_device *displays[MAX_DISPLAYS];
};

extern int debug;

enum dsscomp_state {
	DSSCOMP_STATE_ACTIVE		= 0xAC54156E,
	DSSCOMP_STATE_APPLYING		= 0xB554C591,
	DSSCOMP_STATE_APPLIED		= 0xB60504C1,
	DSSCOMP_STATE_PROGRAMMED	= 0xC0520652,
	DSSCOMP_STATE_DISPLAYED		= 0xD15504CA,
};

struct dsscomp_data {
	enum dsscomp_state state;
	/*
	 * :TRICKY: before applying, overlays used in a composition are stored
	 * in ovl_mask and the other masks are empty.  Once composition is
	 * applied, blank is set to see if all overlays are to be disabled on
	 * this composition, any disabled overlays in the composition are set in
	 * ovl_dmask, and ovl_mask is updated to include ALL overlays that are
	 * actually on the display - even if they are not part of the
	 * composition. The reason: we use ovl_mask to see if an overlay is used
	 * or planned to be used on a manager.  We update ovl_mask when
	 * composition is programmed (removing the disabled overlays).
	 */
	bool blank;		/* true if all overlays are to be disabled */
	u32 ovl_mask;		/* overlays used on this frame */
	u32 ovl_dmask;		/* overlays disabled on this frame */
	u32 ix;			/* manager index that this frame is on */
	struct omapdss_ovl_cb cb;
	struct dsscomp_setup_mgr_data frm;
	struct dss2_ovl_info ovls[5];
	void (*extra_cb)(void *data, int status);
	void *extra_cb_data;
	bool must_apply;	/* whether composition must be applied */
};

struct dsscomp_sync_obj {
	int state;
	int fd;
	atomic_t refs;
};

/*
 * Kernel interface
 */
int dsscomp_queue_init(struct dsscomp_dev *cdev);
void dsscomp_queue_exit(void);
void dsscomp_gralloc_init(struct dsscomp_dev *cdev);
void dsscomp_gralloc_exit(void);
int dsscomp_gralloc_queue_ioctl(struct dsscomp_setup_mgr_data *d);
int dsscomp_wait(struct dsscomp_sync_obj *sync, enum dsscomp_wait_phase phase,
								int timeout);

/* basic operation - if not using queues */
int set_dss_ovl_info(struct dss2_ovl_info *oi);
int set_dss_mgr_info(struct dss2_mgr_info *mi);
struct omap_overlay_manager *find_dss_mgr(int display_ix);
void swap_rb_in_ovl_info(struct dss2_ovl_info *oi);
void swap_rb_in_mgr_info(struct dss2_mgr_info *mi);

/*
 * Debug functions
 */
void dump_ovl_info(struct dsscomp_dev *cdev, struct dss2_ovl_info *oi);
void dump_comp_info(struct dsscomp_dev *cdev, struct dsscomp_setup_mgr_data *d,
				const char *phase);

#endif