Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
[firefly-linux-kernel-4.4.55.git] / drivers / media / platform / vsp1 / vsp1_entity.h
1 /*
2  * vsp1_entity.h  --  R-Car VSP1 Base Entity
3  *
4  * Copyright (C) 2013-2014 Renesas Electronics Corporation
5  *
6  * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com)
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  */
13 #ifndef __VSP1_ENTITY_H__
14 #define __VSP1_ENTITY_H__
15
16 #include <linux/list.h>
17
18 #include <media/v4l2-subdev.h>
19
20 struct vsp1_device;
21
22 enum vsp1_entity_type {
23         VSP1_ENTITY_BRU,
24         VSP1_ENTITY_HSI,
25         VSP1_ENTITY_HST,
26         VSP1_ENTITY_LIF,
27         VSP1_ENTITY_LUT,
28         VSP1_ENTITY_RPF,
29         VSP1_ENTITY_SRU,
30         VSP1_ENTITY_UDS,
31         VSP1_ENTITY_WPF,
32 };
33
34 /*
35  * struct vsp1_route - Entity routing configuration
36  * @type: Entity type this routing entry is associated with
37  * @index: Entity index this routing entry is associated with
38  * @reg: Output routing configuration register
39  * @inputs: Target node value for each input
40  *
41  * Each $vsp1_route entry describes routing configuration for the entity
42  * specified by the entry's @type and @index. @reg indicates the register that
43  * holds output routing configuration for the entity, and the @inputs array
44  * store the target node value for each input of the entity.
45  */
46 struct vsp1_route {
47         enum vsp1_entity_type type;
48         unsigned int index;
49         unsigned int reg;
50         unsigned int inputs[4];
51 };
52
53 struct vsp1_entity {
54         struct vsp1_device *vsp1;
55
56         enum vsp1_entity_type type;
57         unsigned int index;
58         const struct vsp1_route *route;
59
60         struct list_head list_dev;
61         struct list_head list_pipe;
62
63         struct media_pad *pads;
64         unsigned int source_pad;
65
66         struct media_entity *sink;
67         unsigned int sink_pad;
68
69         struct v4l2_subdev subdev;
70         struct v4l2_mbus_framefmt *formats;
71 };
72
73 static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
74 {
75         return container_of(subdev, struct vsp1_entity, subdev);
76 }
77
78 int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
79                      unsigned int num_pads);
80 void vsp1_entity_destroy(struct vsp1_entity *entity);
81
82 extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
83 extern const struct media_entity_operations vsp1_media_ops;
84
85 struct v4l2_mbus_framefmt *
86 vsp1_entity_get_pad_format(struct vsp1_entity *entity,
87                            struct v4l2_subdev_fh *fh,
88                            unsigned int pad, u32 which);
89 void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
90                               struct v4l2_subdev_fh *fh);
91
92 #endif /* __VSP1_ENTITY_H__ */