Tai Kuo | 95aab3e | 2021-02-08 19:45:10 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
Will McVicker | b030540 | 2022-09-10 00:25:52 +0000 | [diff] [blame] | 3 | #ifndef _HEATMAP_H_ |
| 4 | #define _HEATMAP_H_ |
| 5 | |
Tai Kuo | 95aab3e | 2021-02-08 19:45:10 +0800 | [diff] [blame] | 6 | #include <media/v4l2-device.h> |
| 7 | #include <media/v4l2-ioctl.h> |
| 8 | #include <media/videobuf2-v4l2.h> |
| 9 | |
| 10 | typedef int16_t strength_t; |
| 11 | |
| 12 | struct v4l2_heatmap { |
| 13 | struct device *parent_dev; |
| 14 | /* Can be NULL. Used to get the input device name */ |
| 15 | struct input_dev *input_dev; |
| 16 | struct v4l2_device device; |
| 17 | struct v4l2_pix_format format; |
| 18 | struct video_device vdev; |
| 19 | struct vb2_queue queue; |
| 20 | struct mutex lock; |
| 21 | unsigned int input_index; |
| 22 | |
| 23 | size_t width; |
| 24 | size_t height; |
| 25 | |
| 26 | /* The 'frame' storage is managed by the heatmap module. |
| 27 | * The data inside frame is written inside read_frame(..) |
| 28 | * and is read inside heatmap_read(..). |
| 29 | */ |
| 30 | strength_t *frame; |
| 31 | |
| 32 | struct v4l2_fract timeperframe; |
| 33 | |
| 34 | /* Used to protect access to the buffer queue */ |
| 35 | spinlock_t heatmap_lock; |
| 36 | /* guarded by heatmap_lock */ |
| 37 | struct list_head heatmap_buffer_list; |
| 38 | |
| 39 | /* |
| 40 | * Function read_frame must be provided by the driver. |
| 41 | * This function should write the video frame into the |
| 42 | * 'frame' field of struct v4l2_heatmap. |
| 43 | * It should return 'true' on successful heatmap read |
| 44 | * and 'false' on failure. |
| 45 | */ |
| 46 | bool (*read_frame)(struct v4l2_heatmap *v4l2); |
| 47 | }; |
| 48 | |
| 49 | int heatmap_probe(struct v4l2_heatmap *v4l2); |
| 50 | void heatmap_remove(struct v4l2_heatmap *v4l2); |
| 51 | /** |
| 52 | * Read the heatmap and populate an available buffer with data. |
| 53 | * The timestamp provided to this function will be used as the frame time. |
| 54 | * Designed to be called from interrupt context. |
| 55 | * This function should be called from the driver. Internally, it will call |
| 56 | * read_frame(..) provided by the driver to read the actual data. |
| 57 | */ |
Will McVicker | b030540 | 2022-09-10 00:25:52 +0000 | [diff] [blame] | 58 | void heatmap_read(struct v4l2_heatmap *v4l2, uint64_t timestamp); |
| 59 | |
| 60 | #endif // _HEATMAP_H_ |