summaryrefslogtreecommitdiff
path: root/drivers/video/adf/adf.h
blob: 3bcf1fabc23c648eb8723152d5f21a8b7eeb6aee (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
/*
 * Copyright (C) 2013 Google, Inc.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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 __VIDEO_ADF_ADF_H
#define __VIDEO_ADF_ADF_H

#include <linux/idr.h>
#include <linux/list.h>
#include <video/adf.h>
#include "sync.h"

struct adf_event_refcount {
	struct rb_node node;
	enum adf_event_type type;
	int refcount;
};

void adf_buffer_cleanup(struct adf_buffer *buf);
void adf_buffer_mapping_cleanup(struct adf_buffer_mapping *mapping,
		struct adf_buffer *buf);
void adf_post_cleanup(struct adf_device *dev, struct adf_pending_post *post);

struct adf_attachment_list *adf_attachment_find(struct list_head *list,
		struct adf_overlay_engine *eng, struct adf_interface *intf);
int adf_attachment_validate(struct adf_device *dev,
		struct adf_overlay_engine *eng, struct adf_interface *intf);
void adf_attachment_free(struct adf_attachment_list *attachment);

struct adf_event_refcount *adf_obj_find_event_refcount(struct adf_obj *obj,
		enum adf_event_type type);

static inline int adf_obj_check_supports_event(struct adf_obj *obj,
		enum adf_event_type type)
{
	if (!obj->ops || !obj->ops->supports_event)
		return -EOPNOTSUPP;
	if (!obj->ops->supports_event(obj, type))
		return -EINVAL;
	return 0;
}

static inline int adf_device_attach_op(struct adf_device *dev,
		struct adf_overlay_engine *eng, struct adf_interface *intf)
{
	if (!dev->ops->attach)
		return 0;

	return dev->ops->attach(dev, eng, intf);
}

static inline int adf_device_detach_op(struct adf_device *dev,
		struct adf_overlay_engine *eng, struct adf_interface *intf)
{
	if (!dev->ops->detach)
		return 0;

	return dev->ops->detach(dev, eng, intf);
}

#endif /* __VIDEO_ADF_ADF_H */