Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 1 | /* |
| 2 | * vsp1_entity.h -- R-Car VSP1 Base Entity |
| 3 | * |
Laurent Pinchart | 8a1edc5 | 2014-02-06 14:42:31 -0300 | [diff] [blame] | 4 | * Copyright (C) 2013-2014 Renesas Electronics Corporation |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 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> |
Laurent Pinchart | adb8963 | 2015-04-13 11:43:40 -0300 | [diff] [blame] | 17 | #include <linux/spinlock.h> |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 18 | |
| 19 | #include <media/v4l2-subdev.h> |
| 20 | |
| 21 | struct vsp1_device; |
| 22 | |
| 23 | enum vsp1_entity_type { |
Laurent Pinchart | 629bb6d | 2013-07-10 18:03:46 -0300 | [diff] [blame] | 24 | VSP1_ENTITY_BRU, |
Laurent Pinchart | 5cdf574 | 2013-07-10 17:30:14 -0300 | [diff] [blame] | 25 | VSP1_ENTITY_HSI, |
| 26 | VSP1_ENTITY_HST, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 27 | VSP1_ENTITY_LIF, |
Laurent Pinchart | 989af88 | 2013-07-10 12:03:30 -0300 | [diff] [blame] | 28 | VSP1_ENTITY_LUT, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 29 | VSP1_ENTITY_RPF, |
Laurent Pinchart | a626e64 | 2013-07-10 12:03:30 -0300 | [diff] [blame] | 30 | VSP1_ENTITY_SRU, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 31 | VSP1_ENTITY_UDS, |
| 32 | VSP1_ENTITY_WPF, |
| 33 | }; |
| 34 | |
Laurent Pinchart | a96c5fa | 2015-08-03 09:46:26 -0300 | [diff] [blame^] | 35 | #define VSP1_ENTITY_MAX_INPUTS 5 /* For the BRU */ |
| 36 | |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 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; |
Laurent Pinchart | a96c5fa | 2015-08-03 09:46:26 -0300 | [diff] [blame^] | 53 | unsigned int inputs[VSP1_ENTITY_MAX_INPUTS]; |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 54 | }; |
| 55 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 56 | struct vsp1_entity { |
| 57 | struct vsp1_device *vsp1; |
| 58 | |
| 59 | enum vsp1_entity_type type; |
| 60 | unsigned int index; |
Laurent Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 61 | const struct vsp1_route *route; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 62 | |
| 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 Pinchart | d9b45ed | 2013-07-10 18:37:27 -0300 | [diff] [blame] | 70 | unsigned int sink_pad; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 71 | |
| 72 | struct v4l2_subdev subdev; |
| 73 | struct v4l2_mbus_framefmt *formats; |
Laurent Pinchart | 1499be6 | 2014-05-28 12:49:13 -0300 | [diff] [blame] | 74 | |
Laurent Pinchart | adb8963 | 2015-04-13 11:43:40 -0300 | [diff] [blame] | 75 | spinlock_t lock; /* Protects the streaming field */ |
Laurent Pinchart | 960de2c | 2014-05-31 10:40:51 -0300 | [diff] [blame] | 76 | bool streaming; |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | static inline struct vsp1_entity *to_vsp1_entity(struct v4l2_subdev *subdev) |
| 80 | { |
| 81 | return container_of(subdev, struct vsp1_entity, subdev); |
| 82 | } |
| 83 | |
| 84 | int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, |
| 85 | unsigned int num_pads); |
| 86 | void vsp1_entity_destroy(struct vsp1_entity *entity); |
| 87 | |
| 88 | extern const struct v4l2_subdev_internal_ops vsp1_subdev_internal_ops; |
| 89 | extern const struct media_entity_operations vsp1_media_ops; |
| 90 | |
| 91 | struct v4l2_mbus_framefmt * |
| 92 | vsp1_entity_get_pad_format(struct vsp1_entity *entity, |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 93 | struct v4l2_subdev_pad_config *cfg, |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 94 | unsigned int pad, u32 which); |
| 95 | void vsp1_entity_init_formats(struct v4l2_subdev *subdev, |
Hans Verkuil | f723413 | 2015-03-04 01:47:54 -0800 | [diff] [blame] | 96 | struct v4l2_subdev_pad_config *cfg); |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 97 | |
Laurent Pinchart | 960de2c | 2014-05-31 10:40:51 -0300 | [diff] [blame] | 98 | bool vsp1_entity_is_streaming(struct vsp1_entity *entity); |
| 99 | int vsp1_entity_set_streaming(struct vsp1_entity *entity, bool streaming); |
| 100 | |
Laurent Pinchart | 665b693 | 2015-08-02 18:58:31 -0300 | [diff] [blame] | 101 | void vsp1_entity_route_setup(struct vsp1_entity *source); |
| 102 | |
Laurent Pinchart | 26e0ca2 | 2013-06-04 11:22:30 -0300 | [diff] [blame] | 103 | #endif /* __VSP1_ENTITY_H__ */ |