Merge remote-tracking branch 'h8300/h8300-next'
[deliverable/linux.git] / drivers / media / platform / vsp1 / vsp1_entity.h
CommitLineData
26e0ca22
LP
1/*
2 * vsp1_entity.h -- R-Car VSP1 Base Entity
3 *
8a1edc55 4 * Copyright (C) 2013-2014 Renesas Electronics Corporation
26e0ca22
LP
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>
adb8963f 17#include <linux/spinlock.h>
26e0ca22
LP
18
19#include <media/v4l2-subdev.h>
20
21struct vsp1_device;
5e8dbbf3 22struct vsp1_dl_list;
83dd019d 23struct vsp1_pipeline;
26e0ca22
LP
24
25enum vsp1_entity_type {
629bb6d4 26 VSP1_ENTITY_BRU,
1fd87bf2 27 VSP1_ENTITY_CLU,
5cdf5741
LP
28 VSP1_ENTITY_HSI,
29 VSP1_ENTITY_HST,
26e0ca22 30 VSP1_ENTITY_LIF,
989af883 31 VSP1_ENTITY_LUT,
26e0ca22 32 VSP1_ENTITY_RPF,
a626e64e 33 VSP1_ENTITY_SRU,
26e0ca22
LP
34 VSP1_ENTITY_UDS,
35 VSP1_ENTITY_WPF,
36};
37
a96c5fa4
LP
38#define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
39
d9b45ed3
LP
40/*
41 * struct vsp1_route - Entity routing configuration
42 * @type: Entity type this routing entry is associated with
43 * @index: Entity index this routing entry is associated with
44 * @reg: Output routing configuration register
45 * @inputs: Target node value for each input
44f46198 46 * @output: Target node value for entity output
d9b45ed3
LP
47 *
48 * Each $vsp1_route entry describes routing configuration for the entity
49 * specified by the entry's @type and @index. @reg indicates the register that
50 * holds output routing configuration for the entity, and the @inputs array
44f46198
LP
51 * store the target node value for each input of the entity. The @output field
52 * stores the target node value of the entity output when used as a source for
53 * histogram generation.
d9b45ed3
LP
54 */
55struct vsp1_route {
56 enum vsp1_entity_type type;
57 unsigned int index;
58 unsigned int reg;
a96c5fa4 59 unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
44f46198 60 unsigned int output;
d9b45ed3
LP
61};
62
52434534
LP
63/**
64 * struct vsp1_entity_operations - Entity operations
65 * @destroy: Destroy the entity.
66 * @set_memory: Setup memory buffer access. This operation applies the settings
5e8dbbf3
LP
67 * stored in the rwpf mem field to the display list. Valid for RPF
68 * and WPF only.
7b905f05
LP
69 * @configure: Setup the hardware based on the entity state (pipeline, formats,
70 * selection rectangles, ...)
52434534
LP
71 */
72struct vsp1_entity_operations {
73 void (*destroy)(struct vsp1_entity *);
5e8dbbf3 74 void (*set_memory)(struct vsp1_entity *, struct vsp1_dl_list *dl);
83dd019d 75 void (*configure)(struct vsp1_entity *, struct vsp1_pipeline *,
fc845e52 76 struct vsp1_dl_list *, bool);
52434534
LP
77};
78
26e0ca22
LP
79struct vsp1_entity {
80 struct vsp1_device *vsp1;
81
52434534 82 const struct vsp1_entity_operations *ops;
ef9621bc 83
26e0ca22
LP
84 enum vsp1_entity_type type;
85 unsigned int index;
d9b45ed3 86 const struct vsp1_route *route;
26e0ca22
LP
87
88 struct list_head list_dev;
89 struct list_head list_pipe;
90
91 struct media_pad *pads;
92 unsigned int source_pad;
93
94 struct media_entity *sink;
d9b45ed3 95 unsigned int sink_pad;
26e0ca22
LP
96
97 struct v4l2_subdev subdev;
e790c3cb 98 struct v4l2_subdev_pad_config *config;
26e0ca22
LP
99};
100
101static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
102{
103 return container_of(subdev, struct vsp1_entity, subdev);
104}
105
106int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
823329df 107 const char *name, unsigned int num_pads,
6a8e07b2 108 const struct v4l2_subdev_ops *ops, u32 function);
26e0ca22
LP
109void vsp1_entity_destroy(struct vsp1_entity *entity);
110
111extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
babca007
LP
112
113int vsp1_entity_link_setup(struct media_entity *entity,
114 const struct media_pad *local,
115 const struct media_pad *remote, u32 flags);
26e0ca22 116
e790c3cb
LP
117struct v4l2_subdev_pad_config *
118vsp1_entity_get_pad_config(struct vsp1_entity *entity,
119 struct v4l2_subdev_pad_config *cfg,
120 enum v4l2_subdev_format_whence which);
26e0ca22
LP
121struct v4l2_mbus_framefmt *
122vsp1_entity_get_pad_format(struct vsp1_entity *entity,
f7234138 123 struct v4l2_subdev_pad_config *cfg,
e790c3cb 124 unsigned int pad);
b7e5107e 125struct v4l2_rect *
ccd3d95a
LP
126vsp1_entity_get_pad_selection(struct vsp1_entity *entity,
127 struct v4l2_subdev_pad_config *cfg,
128 unsigned int pad, unsigned int target);
0efdf0f5
LP
129int vsp1_entity_init_cfg(struct v4l2_subdev *subdev,
130 struct v4l2_subdev_pad_config *cfg);
26e0ca22 131
5e8dbbf3
LP
132void vsp1_entity_route_setup(struct vsp1_entity *source,
133 struct vsp1_dl_list *dl);
aa380ea0 134
3f557220
LP
135int vsp1_subdev_get_pad_format(struct v4l2_subdev *subdev,
136 struct v4l2_subdev_pad_config *cfg,
137 struct v4l2_subdev_format *fmt);
6ad9ba9c
LP
138int vsp1_subdev_enum_mbus_code(struct v4l2_subdev *subdev,
139 struct v4l2_subdev_pad_config *cfg,
140 struct v4l2_subdev_mbus_code_enum *code,
141 const unsigned int *codes, unsigned int ncodes);
076e834f
LP
142int vsp1_subdev_enum_frame_size(struct v4l2_subdev *subdev,
143 struct v4l2_subdev_pad_config *cfg,
144 struct v4l2_subdev_frame_size_enum *fse,
145 unsigned int min_w, unsigned int min_h,
146 unsigned int max_w, unsigned int max_h);
3f557220 147
26e0ca22 148#endif /* __VSP1_ENTITY_H__ */
This page took 0.160933 seconds and 5 git commands to generate.