PageRenderTime 34ms CodeModel.GetById 19ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/video/omap2/dsscomp/dsscomp.h

https://bitbucket.org/wisechild/galaxy-nexus
C++ Header | 208 lines | 136 code | 24 blank | 48 comment | 10 complexity | 7fe3c696f4fe548533ba945a6edbb2f5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1/*
  2 * linux/drivers/video/omap2/dsscomp/base.c
  3 *
  4 * DSS Composition basic operation support
  5 *
  6 * Copyright (C) 2011 Texas Instruments, Inc
  7 * Author: Lajos Molnar <molnar@ti.com>
  8 *
  9 * This program is free software; you can redistribute it and/or modify it
 10 * under the terms of the GNU General Public License version 2 as published by
 11 * the Free Software Foundation.
 12 *
 13 * This program is distributed in the hope that it will be useful, but WITHOUT
 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 15 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 16 * more details.
 17 *
 18 * You should have received a copy of the GNU General Public License along with
 19 * this program.  If not, see <http://www.gnu.org/licenses/>.
 20 */
 21
 22#ifndef _DSSCOMP_H
 23#define _DSSCOMP_H
 24
 25#include <linux/miscdevice.h>
 26#include <linux/debugfs.h>
 27#include <linux/seq_file.h>
 28#ifdef CONFIG_DSSCOMP_DEBUG_LOG
 29#include <linux/hrtimer.h>
 30#endif
 31
 32#define MAX_OVERLAYS	5
 33#define MAX_MANAGERS	3
 34#define MAX_DISPLAYS	4
 35
 36#define DEBUG_OVERLAYS		(1 << 0)
 37#define DEBUG_COMPOSITIONS	(1 << 1)
 38#define DEBUG_PHASES		(1 << 2)
 39#define DEBUG_WAITS		(1 << 3)
 40#define DEBUG_GRALLOC_PHASES	(1 << 4)
 41
 42/*
 43 * Utility macros
 44 */
 45#define ZERO(c)		memset(&c, 0, sizeof(c))
 46#define ZEROn(c, n)	memset(c, 0, sizeof(*c) * n)
 47#define DEV(c)		(c->dev.this_device)
 48
 49/**
 50 * DSS Composition Device Driver
 51 *
 52 * @dev:   misc device base
 53 * @dbgfs: debugfs hook
 54 */
 55struct dsscomp_dev {
 56	struct miscdevice dev;
 57	struct dentry *dbgfs;
 58
 59	/* cached DSS objects */
 60	u32 num_ovls;
 61	struct omap_overlay *ovls[MAX_OVERLAYS];
 62	u32 num_mgrs;
 63	struct omap_overlay_manager *mgrs[MAX_MANAGERS];
 64	u32 num_displays;
 65	struct omap_dss_device *displays[MAX_DISPLAYS];
 66	struct notifier_block state_notifiers[MAX_DISPLAYS];
 67};
 68
 69extern int debug;
 70
 71#ifdef CONFIG_DEBUG_FS
 72extern struct mutex dbg_mtx;
 73extern struct list_head dbg_comps;
 74#define DO_IF_DEBUG_FS(cmd) {	\
 75	mutex_lock(&dbg_mtx);	\
 76	cmd;			\
 77	mutex_unlock(&dbg_mtx);	\
 78}
 79#else
 80#define DO_IF_DEBUG_FS(cmd)
 81#endif
 82
 83enum dsscomp_state {
 84	DSSCOMP_STATE_ACTIVE		= 0xAC54156E,
 85	DSSCOMP_STATE_APPLYING		= 0xB554C591,
 86	DSSCOMP_STATE_APPLIED		= 0xB60504C1,
 87	DSSCOMP_STATE_PROGRAMMED	= 0xC0520652,
 88	DSSCOMP_STATE_DISPLAYED		= 0xD15504CA,
 89};
 90
 91struct dsscomp_data {
 92	enum dsscomp_state state;
 93	/*
 94	 * :TRICKY: before applying, overlays used in a composition are stored
 95	 * in ovl_mask and the other masks are empty.  Once composition is
 96	 * applied, blank is set to see if all overlays are to be disabled on
 97	 * this composition, any disabled overlays in the composition are set in
 98	 * ovl_dmask, and ovl_mask is updated to include ALL overlays that are
 99	 * actually on the display - even if they are not part of the
100	 * composition. The reason: we use ovl_mask to see if an overlay is used
101	 * or planned to be used on a manager.  We update ovl_mask when
102	 * composition is programmed (removing the disabled overlays).
103	 */
104	bool blank;		/* true if all overlays are to be disabled */
105	u32 ovl_mask;		/* overlays used on this frame */
106	u32 ovl_dmask;		/* overlays disabled on this frame */
107	u32 ix;			/* manager index that this frame is on */
108	struct dsscomp_setup_mgr_data frm;
109	struct dss2_ovl_info ovls[5];
110	void (*extra_cb)(void *data, int status);
111	void *extra_cb_data;
112	bool must_apply;	/* whether composition must be applied */
113
114#ifdef CONFIG_DEBUG_FS
115	struct list_head dbg_q;
116	u32 dbg_used;
117	struct {
118		u32 t, state;
119	} dbg_log[8];
120#endif
121};
122
123struct dsscomp_sync_obj {
124	int state;
125	int fd;
126	atomic_t refs;
127};
128
129/*
130 * Kernel interface
131 */
132int dsscomp_queue_init(struct dsscomp_dev *cdev);
133void dsscomp_queue_exit(void);
134void dsscomp_gralloc_init(struct dsscomp_dev *cdev);
135void dsscomp_gralloc_exit(void);
136int dsscomp_gralloc_queue_ioctl(struct dsscomp_setup_dispc_data *d);
137int dsscomp_wait(struct dsscomp_sync_obj *sync, enum dsscomp_wait_phase phase,
138								int timeout);
139int dsscomp_state_notifier(struct notifier_block *nb,
140						unsigned long arg, void *ptr);
141
142/* basic operation - if not using queues */
143int set_dss_ovl_info(struct dss2_ovl_info *oi);
144int set_dss_mgr_info(struct dss2_mgr_info *mi, struct omapdss_ovl_cb *cb);
145struct omap_overlay_manager *find_dss_mgr(int display_ix);
146void swap_rb_in_ovl_info(struct dss2_ovl_info *oi);
147void swap_rb_in_mgr_info(struct dss2_mgr_info *mi);
148
149/*
150 * Debug functions
151 */
152void dump_ovl_info(struct dsscomp_dev *cdev, struct dss2_ovl_info *oi);
153void dump_comp_info(struct dsscomp_dev *cdev, struct dsscomp_setup_mgr_data *d,
154				const char *phase);
155void dump_total_comp_info(struct dsscomp_dev *cdev,
156				struct dsscomp_setup_dispc_data *d,
157				const char *phase);
158const char *dsscomp_get_color_name(enum omap_color_mode m);
159
160void dsscomp_dbg_comps(struct seq_file *s);
161void dsscomp_dbg_gralloc(struct seq_file *s);
162
163#define log_state_str(s) (\
164	(s) == DSSCOMP_STATE_ACTIVE		? "ACTIVE"	: \
165	(s) == DSSCOMP_STATE_APPLYING		? "APPLY'N"	: \
166	(s) == DSSCOMP_STATE_APPLIED		? "APPLIED"	: \
167	(s) == DSSCOMP_STATE_PROGRAMMED		? "PROGR'D"	: \
168	(s) == DSSCOMP_STATE_DISPLAYED		? "DISPL'D"	: "INVALID")
169
170#define log_status_str(ev) ( \
171	((ev) & DSS_COMPLETION_CHANGED)		? "CHANGED"	: \
172	(ev) == DSS_COMPLETION_DISPLAYED	? "DISPLAYED"	: \
173	(ev) == DSS_COMPLETION_PROGRAMMED	? "PROGRAMMED"	: \
174	(ev) == DSS_COMPLETION_TORN		? "TORN"	: \
175	(ev) == DSS_COMPLETION_RELEASED		? "RELEASED"	: \
176	((ev) & DSS_COMPLETION_RELEASED)	? "ECLIPSED"	: "???")
177
178#ifdef CONFIG_DSSCOMP_DEBUG_LOG
179extern struct dbg_event_t {
180	u32 ms, a1, a2, ix;
181	void *data;
182	const char *fmt;
183} dbg_events[128];
184extern u32 dbg_event_ix;
185
186void dsscomp_dbg_events(struct seq_file *s);
187#endif
188
189static inline
190void __log_event(u32 ix, u32 ms, void *data, const char *fmt, u32 a1, u32 a2)
191{
192#ifdef CONFIG_DSSCOMP_DEBUG_LOG
193	if (!ms)
194		ms = ktime_to_ms(ktime_get());
195	dbg_events[dbg_event_ix].ms = ms;
196	dbg_events[dbg_event_ix].data = data;
197	dbg_events[dbg_event_ix].fmt = fmt;
198	dbg_events[dbg_event_ix].a1 = a1;
199	dbg_events[dbg_event_ix].a2 = a2;
200	dbg_events[dbg_event_ix].ix = ix;
201	dbg_event_ix = (dbg_event_ix + 1) % ARRAY_SIZE(dbg_events);
202#endif
203}
204
205#define log_event(ix, ms, data, fmt, a1, a2) \
206	DO_IF_DEBUG_FS(__log_event(ix, ms, data, fmt, a1, a2))
207
208#endif