blob: 360a2e668ac2591bbe429e8539bf9bd3f8cce12a [file] [log] [blame]
Laurent Pinchart26e0ca22013-06-04 11:22:30 -03001/*
2 * vsp1_entity.h -- R-Car VSP1 Base Entity
3 *
Laurent Pinchart8a1edc52014-02-06 14:42:31 -03004 * Copyright (C) 2013-2014 Renesas Electronics Corporation
Laurent Pinchart26e0ca22013-06-04 11:22:30 -03005 *
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>
Laurent Pinchartadb89632015-04-13 11:43:40 -030017#include <linux/spinlock.h>
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030018
19#include <media/v4l2-subdev.h>
20
21struct vsp1_device;
22
23enum vsp1_entity_type {
Laurent Pinchart629bb6d2013-07-10 18:03:46 -030024 VSP1_ENTITY_BRU,
Laurent Pinchart5cdf5742013-07-10 17:30:14 -030025 VSP1_ENTITY_HSI,
26 VSP1_ENTITY_HST,
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030027 VSP1_ENTITY_LIF,
Laurent Pinchart989af882013-07-10 12:03:30 -030028 VSP1_ENTITY_LUT,
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030029 VSP1_ENTITY_RPF,
Laurent Pincharta626e642013-07-10 12:03:30 -030030 VSP1_ENTITY_SRU,
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030031 VSP1_ENTITY_UDS,
32 VSP1_ENTITY_WPF,
33};
34
Laurent Pincharta96c5fa2015-08-03 09:46:26 -030035#define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */
36
Laurent Pinchartd9b45ed2013-07-10 18:37:27 -030037/*
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 */
49struct vsp1_route {
50 enum vsp1_entity_type type;
51 unsigned int index;
52 unsigned int reg;
Laurent Pincharta96c5fa2015-08-03 09:46:26 -030053 unsigned int inputs[VSP1_ENTITY_MAX_INPUTS];
Laurent Pinchartd9b45ed2013-07-10 18:37:27 -030054};
55
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030056struct vsp1_entity {
57 struct vsp1_device *vsp1;
58
59 enum vsp1_entity_type type;
60 unsigned int index;
Laurent Pinchartd9b45ed2013-07-10 18:37:27 -030061 const struct vsp1_route *route;
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030062
63 struct list_head list_dev;
64 struct list_head list_pipe;
65
66 struct media_pad *pads;
67 unsigned int source_pad;
68
69 struct media_entity *sink;
Laurent Pinchartd9b45ed2013-07-10 18:37:27 -030070 unsigned int sink_pad;
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030071
72 struct v4l2_subdev subdev;
73 struct v4l2_mbus_framefmt *formats;
Laurent Pinchart1499be62014-05-28 12:49:13 -030074
Laurent Pinchartadb89632015-04-13 11:43:40 -030075 spinlock_t lock; /* Protects the streaming field */
Laurent Pinchart960de2c2014-05-31 10:40:51 -030076 bool streaming;
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030077};
78
79static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev)
80{
81 return container_of(subdev, struct vsp1_entity, subdev);
82}
83
84int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
85 unsigned int num_pads);
86void vsp1_entity_destroy(struct vsp1_entity *entity);
87
88extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops;
89extern const struct media_entity_operations vsp1_media_ops;
90
91struct v4l2_mbus_framefmt *
92vsp1_entity_get_pad_format(struct vsp1_entity *entity,
Hans Verkuilf7234132015-03-04 01:47:54 -080093 struct v4l2_subdev_pad_config *cfg,
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030094 unsigned int pad, u32 which);
95void vsp1_entity_init_formats(struct v4l2_subdev *subdev,
Hans Verkuilf7234132015-03-04 01:47:54 -080096 struct v4l2_subdev_pad_config *cfg);
Laurent Pinchart26e0ca22013-06-04 11:22:30 -030097
Laurent Pinchart960de2c2014-05-31 10:40:51 -030098bool vsp1_entity_is_streaming(struct vsp1_entity *entity);
99int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming);
100
Laurent Pinchart665b6932015-08-02 18:58:31 -0300101void vsp1_entity_route_setup(struct vsp1_entity *source);
102
Laurent Pinchart26e0ca22013-06-04 11:22:30 -0300103#endif /* __VSP1_ENTITY_H__ */