]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/media/platform/vsp1/vsp1_entity.h
[media] v4l: vsp1: Implement and use the subdev pad::init_cfg configuration
[karo-tx-linux.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 #include <linux/spinlock.h>
18
19 #include <media/v4l2-subdev.h>
20
21 struct vsp1_device;
22
23 enum vsp1_entity_type {
24         VSP1_ENTITY_BRU,
25         VSP1_ENTITY_HSI,
26         VSP1_ENTITY_HST,
27         VSP1_ENTITY_LIF,
28         VSP1_ENTITY_LUT,
29         VSP1_ENTITY_RPF,
30         VSP1_ENTITY_SRU,
31         VSP1_ENTITY_UDS,
32         VSP1_ENTITY_WPF,
33 };
34
35 #define VSP1_ENTITY_MAX_INPUTS          5       /* For the BRU */
36
37 /*
38  * struct vsp1_route - Entity routing configuration
39  * @type: Entity type this routing entry is associated with
40  * @index: Entity index this routing entry is associated with
41  * @reg: Output routing configuration register
42  * @inputs: Target node value for each input
43  *
44  * Each $vsp1_route entry describes routing configuration for the entity
45  * specified by the entry's @type and @index. @reg indicates the register that
46  * holds output routing configuration for the entity, and the @inputs array
47  * store the target node value for each input of the entity.
48  */
49 struct vsp1_route {
50         enum vsp1_entity_type type;
51         unsigned int index;
52         unsigned int reg;
53         unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
54 };
55
56 /**
57  * struct vsp1_entity_operations - Entity operations
58  * @destroy:    Destroy the entity.
59  * @set_memory: Setup memory buffer access. This operation applies the settings
60  *              stored in the rwpf mem field to the hardware. Valid for RPF and
61  *              WPF only.
62  */
63 struct vsp1_entity_operations {
64         void (*destroy)(struct vsp1_entity *);
65         void (*set_memory)(struct vsp1_entity *);
66 };
67
68 struct vsp1_entity {
69         struct vsp1_device *vsp1;
70
71         const struct vsp1_entity_operations *ops;
72
73         enum vsp1_entity_type type;
74         unsigned int index;
75         const struct vsp1_route *route;
76
77         struct list_head list_dev;
78         struct list_head list_pipe;
79
80         struct media_pad *pads;
81         unsigned int source_pad;
82
83         struct media_entity *sink;
84         unsigned int sink_pad;
85
86         struct v4l2_subdev subdev;
87         struct v4l2_mbus_framefmt *formats;
88 };
89
90 static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
91 {
92         return container_of(subdev, struct vsp1_entity, subdev);
93 }
94
95 int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
96                      const char *name, unsigned int num_pads,
97                      const struct v4l2_subdev_ops *ops);
98 void vsp1_entity_destroy(struct vsp1_entity *entity);
99
100 extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
101
102 int vsp1_entity_link_setup(struct media_entity *entity,
103                            const struct media_pad *local,
104                            const struct media_pad *remote, u32 flags);
105
106 struct v4l2_mbus_framefmt *
107 vsp1_entity_get_pad_format(struct vsp1_entity *entity,
108                            struct v4l2_subdev_pad_config *cfg,
109                            unsigned int pad, u32 which);
110 int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
111                          struct v4l2_subdev_pad_config *cfg);
112
113 void vsp1_entity_route_setup(struct vsp1_entity *source);
114
115 void vsp1_mod_write(struct vsp1_entity *e, u32 reg, u32 data);
116
117 #endif /* __VSP1_ENTITY_H__ */