summaryrefslogtreecommitdiff
path: root/include/linux/compdev.h
blob: 83285c61b629ac9fe38d7612618c258224738fce (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
/*
 * Copyright (C) ST-Ericsson SA 2011
 *
 * ST-Ericsson Display overlay compositer device driver
 *
 * Author: Anders Bauer <anders.bauer@stericsson.com>
 * for ST-Ericsson.
 *
 * Modified: Per-Daniel Olsson <per-daniel.olsson@stericsson.com>
 * for ST-Ericsson.
 *
 * License terms: GNU General Public License (GPL), version 2.
 */

#ifndef _COMPDEV_H_
#define _COMPDEV_H_

#if !defined(__KERNEL__) && !defined(_KERNEL)
#include <stdint.h>
#else
#include <linux/types.h>
#include <video/mcde.h>
#endif

#if defined(__KERNEL__) || defined(_KERNEL)
#include <linux/mm_types.h>
#include <linux/bitops.h>
#else
#define BIT(nr)			(1UL << (nr))
#endif

#define COMPDEV_DEFAULT_DEVICE_PREFIX "comp"


enum compdev_fmt {
	COMPDEV_FMT_RGB565,
	COMPDEV_FMT_RGB888,
	COMPDEV_FMT_RGBX8888,
	COMPDEV_FMT_RGBA8888,
	COMPDEV_FMT_YUV422,
	COMPDEV_FMT_YCBCR42XMBN,
	COMPDEV_FMT_YUV420_SP,
	COMPDEV_FMT_YVU420_SP,
	COMPDEV_FMT_YUV420_P,
};

struct compdev_size {
	__u16 width;
	__u16 height;
};

/* Display rotation */
enum compdev_rotation {
	COMPDEV_ROT_0       = 0,
	COMPDEV_ROT_90_CCW  = 90,
	COMPDEV_ROT_180     = 180,
	COMPDEV_ROT_270_CCW = 270,
	COMPDEV_ROT_90_CW   = COMPDEV_ROT_270_CCW,
	COMPDEV_ROT_270_CW  = COMPDEV_ROT_90_CCW,
};

enum compdev_flag {
	COMPDEV_NO_FLAG            = 0x00,
	COMPDEV_OVERLAY_FLAG       = 0x01,
	COMPDEV_FRAMEBUFFER_FLAG   = 0x02,
	COMPDEV_BYPASS_FLAG        = 0x04,
	COMPDEV_EXTERNAL_DISP_FLAG = 0x08,
	COMPDEV_PROTECTED_FLAG     = 0x0F,
};

enum compdev_ptr_type {
	COMPDEV_PTR_PHYSICAL,
	COMPDEV_PTR_HWMEM_BUF_NAME_OFFSET,
};

enum compdev_listener_state {
	COMPDEV_LISTENER_OFF,
	COMPDEV_LISTENER_ON,
};


struct compdev_rect {
	__s16  x;
	__s16  y;
	__u16  width;
	__u16  height;
};

struct compdev_buf {
	enum compdev_ptr_type  type;
	__s32                  hwmem_buf_name;
	__s32                  fd;
	__u32                  offset;
	__u32                  len;
};

struct compdev_img {
	enum compdev_fmt     fmt;
	struct compdev_buf   buf;
	__u16                width;
	__u16                height;
	__u16                pitch;
	__u8                 z_position;
	struct compdev_rect  dst_rect;
	struct compdev_rect  src_rect;
	enum   compdev_rotation  rotation;
	__u32                flags;
};

struct compdev_scene_info {
	enum   compdev_rotation  ovly_rotation;
	enum   compdev_rotation  fb_rotation;
	__u8                     img_count;
};


#define COMPDEV_GET_SIZE_IOC           _IOR('D', 1, struct compdev_size)
#define COMPDEV_POST_BUFFER_IOC        _IOW('D', 2, struct compdev_img)
#define COMPDEV_POST_SCENE_INFO_IOC    _IOW('D', 3, struct compdev_scene_info)
#define COMPDEV_GET_LISTENER_STATE_IOC _IOR('D', 4, enum compdev_listener_state)


#if defined(__KERNEL__) || defined(_KERNEL)

#define MAX_NBR_OF_COMPDEVS 2

struct compdev;
typedef void (*post_buffer_callback)(void *data, struct compdev_img *img);
typedef void (*post_scene_info_callback)(void *data,
		struct compdev_scene_info *s_info);


int compdev_create(struct mcde_display_device *ddev,
		struct mcde_overlay *parent_ovly,
		bool mcde_rotation);
void compdev_destroy(struct mcde_display_device *ddev);

int compdev_get(int dev_idx, struct compdev **dev);
int compdev_put(struct compdev *dev);
int compdev_get_size(struct compdev *dev, struct compdev_size *size);
int compdev_post_buffer(struct compdev *dev, struct compdev_img *img);
int compdev_post_scene_info(struct compdev *dev,
		struct compdev_scene_info *s_info);
int compdev_get_listener_state(struct compdev *dev,
		enum compdev_listener_state *listener_state);

int compdev_register_listener_callbacks(struct compdev *dev, void *data,
		post_buffer_callback pb_cb, post_scene_info_callback si_cb);
int compdev_deregister_callbacks(struct compdev *dev);

#endif /* __KERNEL__ */

#endif /* _COMPDEV_H_ */