aboutsummaryrefslogtreecommitdiff
path: root/include/linux/fb_quickdraw_ops.h
blob: 6448e586b6fc532a2d4efb1576c7eaaa311adc5e (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
/* Copyright (c) 2014, Motorola Mobility, LLC.
 *
 * 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.
 *
 */
#ifndef _FB_QUICKDRAW_OPS_H_
#define _FB_QUICKDRAW_OPS_H_

#include <linux/file.h>
#include <linux/rwsem.h>
#include <linux/types.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
#include <linux/kobject.h>

struct fb_quickdraw_buffer {
	struct fb_quickdraw_buffer_data data;
	struct file *file;
	int mem_fd;
	struct rw_semaphore rwsem;
	struct list_head list;
	struct work_struct delete_work;
	struct kobject kobject;
};

struct fb_quickdraw_ops {
	int (*prepare)(void *data, unsigned char panel_state);
	int (*execute)(void *data, struct fb_quickdraw_buffer *buffer,
		int x, int y);
	int (*erase)(void *data, int x1, int y1, int x2, int y2);
	int (*cleanup)(void *data);
	int (*validate_buffer)(void *data,
		struct fb_quickdraw_buffer_data *buffer_data);
	struct fb_quickdraw_buffer *(*alloc_buffer)(void *data,
		struct fb_quickdraw_buffer_data *buffer_data);
	int (*delete_buffer)(void *data, struct fb_quickdraw_buffer *buffer);
	void *data; /* arbitrary data passed back to user */
};

void fb_quickdraw_register_ops(struct fb_quickdraw_ops *ops);
struct fb_quickdraw_buffer *fb_quickdraw_alloc_buffer(
	struct fb_quickdraw_buffer_data *data, size_t size);
int fb_quickdraw_get_buffer(struct fb_quickdraw_buffer *buffer);
int fb_quickdraw_put_buffer(struct fb_quickdraw_buffer *buffer);
int fb_quickdraw_lock_buffer_read(struct fb_quickdraw_buffer *buffer);
int fb_quickdraw_unlock_buffer_read(struct fb_quickdraw_buffer *buffer);

static inline int fb_quickdraw_check_alignment(int value, int align)
{
	return value % align;
}
int fb_quickdraw_correct_alignment(int coord, int align);
void fb_quickdraw_clip_rect(int panel_xres, int panel_yres, int x, int y,
			    int w, int h, struct fb_quickdraw_rect *src_rect,
			    struct fb_quickdraw_rect *dst_rect);

#endif /* _FB_QUICKDRAW_OPS_H_ */