blob: 3bcf1fabc23c648eb8723152d5f21a8b7eeb6aee [file] [log] [blame]
Greg Hackmannfc29df82013-05-22 14:23:10 -07001/*
2 * Copyright (C) 2013 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __VIDEO_ADF_ADF_H
16#define __VIDEO_ADF_ADF_H
17
18#include <linux/idr.h>
19#include <linux/list.h>
20#include <video/adf.h>
21#include "sync.h"
22
23struct adf_event_refcount {
24 struct rb_node node;
25 enum adf_event_type type;
26 int refcount;
27};
28
29void adf_buffer_cleanup(struct adf_buffer *buf);
30void adf_buffer_mapping_cleanup(struct adf_buffer_mapping *mapping,
31 struct adf_buffer *buf);
32void adf_post_cleanup(struct adf_device *dev, struct adf_pending_post *post);
33
34struct adf_attachment_list *adf_attachment_find(struct list_head *list,
35 struct adf_overlay_engine *eng, struct adf_interface *intf);
36int adf_attachment_validate(struct adf_device *dev,
37 struct adf_overlay_engine *eng, struct adf_interface *intf);
38void adf_attachment_free(struct adf_attachment_list *attachment);
39
40struct adf_event_refcount *adf_obj_find_event_refcount(struct adf_obj *obj,
41 enum adf_event_type type);
42
Greg Hackmannfc29df82013-05-22 14:23:10 -070043static inline int adf_obj_check_supports_event(struct adf_obj *obj,
44 enum adf_event_type type)
45{
46 if (!obj->ops || !obj->ops->supports_event)
47 return -EOPNOTSUPP;
48 if (!obj->ops->supports_event(obj, type))
49 return -EINVAL;
50 return 0;
51}
52
53static inline int adf_device_attach_op(struct adf_device *dev,
54 struct adf_overlay_engine *eng, struct adf_interface *intf)
55{
56 if (!dev->ops->attach)
57 return 0;
58
59 return dev->ops->attach(dev, eng, intf);
60}
61
62static inline int adf_device_detach_op(struct adf_device *dev,
63 struct adf_overlay_engine *eng, struct adf_interface *intf)
64{
65 if (!dev->ops->detach)
66 return 0;
67
68 return dev->ops->detach(dev, eng, intf);
69}
70
71#endif /* __VIDEO_ADF_ADF_H */