| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
/* |
| 3 |
* Copyright (C) 2013 - 2025 Intel Corporation |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef IPU7_ISYS_VIDEO_H |
| 7 |
#define IPU7_ISYS_VIDEO_H |
| 8 |
|
| 9 |
#include <linux/atomic.h> |
| 10 |
#include <linux/completion.h> |
| 11 |
#include <linux/container_of.h> |
| 12 |
#include <linux/list.h> |
| 13 |
#include <linux/mutex.h> |
| 14 |
|
| 15 |
#include <media/media-entity.h> |
| 16 |
#include <media/v4l2-dev.h> |
| 17 |
|
| 18 |
#include "ipu7-isys-queue.h" |
| 19 |
|
| 20 |
#define IPU_INSYS_OUTPUT_PINS 11U |
| 21 |
#define IPU_ISYS_MAX_PARALLEL_SOF 2U |
| 22 |
|
| 23 |
struct file; |
| 24 |
struct ipu7_isys; |
| 25 |
struct ipu7_isys_csi2; |
| 26 |
struct ipu7_insys_stream_cfg; |
| 27 |
struct ipu7_isys_subdev; |
| 28 |
|
| 29 |
struct ipu7_isys_pixelformat { |
| 30 |
u32 pixelformat; |
| 31 |
u32 bpp; |
| 32 |
u32 bpp_packed; |
| 33 |
u32 code; |
| 34 |
u32 css_pixelformat; |
| 35 |
}; |
| 36 |
|
| 37 |
struct sequence_info { |
| 38 |
unsigned int sequence; |
| 39 |
u64 timestamp; |
| 40 |
}; |
| 41 |
|
| 42 |
struct output_pin_data { |
| 43 |
void (*pin_ready)(struct ipu7_isys_stream *stream, |
| 44 |
struct ipu7_insys_resp *info); |
| 45 |
struct ipu7_isys_queue *aq; |
| 46 |
}; |
| 47 |
|
| 48 |
/* |
| 49 |
* Align with firmware stream. Each stream represents a CSI virtual channel. |
| 50 |
* May map to multiple video devices |
| 51 |
*/ |
| 52 |
struct ipu7_isys_stream { |
| 53 |
struct mutex mutex; |
| 54 |
struct media_entity *source_entity; |
| 55 |
atomic_t sequence; |
| 56 |
atomic_t buf_id; |
| 57 |
unsigned int seq_index; |
| 58 |
struct sequence_info seq[IPU_ISYS_MAX_PARALLEL_SOF]; |
| 59 |
int stream_source; |
| 60 |
int stream_handle; |
| 61 |
unsigned int nr_output_pins; |
| 62 |
struct ipu7_isys_subdev *asd; |
| 63 |
|
| 64 |
int nr_queues; /* Number of capture queues */ |
| 65 |
int nr_streaming; |
| 66 |
int streaming; |
| 67 |
struct list_head queues; |
| 68 |
struct completion stream_open_completion; |
| 69 |
struct completion stream_close_completion; |
| 70 |
struct completion stream_start_completion; |
| 71 |
struct completion stream_stop_completion; |
| 72 |
struct ipu7_isys *isys; |
| 73 |
|
| 74 |
struct output_pin_data output_pins[IPU_INSYS_OUTPUT_PINS]; |
| 75 |
int error; |
| 76 |
u8 vc; |
| 77 |
}; |
| 78 |
|
| 79 |
struct ipu7_isys_video { |
| 80 |
struct ipu7_isys_queue aq; |
| 81 |
/* Serialise access to other fields in the struct. */ |
| 82 |
struct mutex mutex; |
| 83 |
struct media_pad pad; |
| 84 |
struct video_device vdev; |
| 85 |
struct v4l2_pix_format pix_fmt; |
| 86 |
struct ipu7_isys *isys; |
| 87 |
struct ipu7_isys_csi2 *csi2; |
| 88 |
struct ipu7_isys_stream *stream; |
| 89 |
unsigned int streaming; |
| 90 |
u8 vc; |
| 91 |
u8 dt; |
| 92 |
}; |
| 93 |
|
| 94 |
#define ipu7_isys_queue_to_video(__aq) \ |
| 95 |
container_of(__aq, struct ipu7_isys_video, aq) |
| 96 |
|
| 97 |
extern const struct ipu7_isys_pixelformat ipu7_isys_pfmts[]; |
| 98 |
|
| 99 |
const struct ipu7_isys_pixelformat *ipu7_isys_get_isys_format(u32 pixelformat); |
| 100 |
int ipu7_isys_video_prepare_stream(struct ipu7_isys_video *av, |
| 101 |
struct media_entity *source_entity, |
| 102 |
int nr_queues); |
| 103 |
int ipu7_isys_video_set_streaming(struct ipu7_isys_video *av, int state, |
| 104 |
struct ipu7_isys_buffer_list *bl); |
| 105 |
int ipu7_isys_fw_open(struct ipu7_isys *isys); |
| 106 |
void ipu7_isys_fw_close(struct ipu7_isys *isys); |
| 107 |
int ipu7_isys_setup_video(struct ipu7_isys_video *av, |
| 108 |
struct media_entity **source_entity, int *nr_queues); |
| 109 |
int ipu7_isys_video_init(struct ipu7_isys_video *av); |
| 110 |
void ipu7_isys_video_cleanup(struct ipu7_isys_video *av); |
| 111 |
void ipu7_isys_put_stream(struct ipu7_isys_stream *stream); |
| 112 |
struct ipu7_isys_stream * |
| 113 |
ipu7_isys_query_stream_by_handle(struct ipu7_isys *isys, |
| 114 |
u8 stream_handle); |
| 115 |
struct ipu7_isys_stream * |
| 116 |
ipu7_isys_query_stream_by_source(struct ipu7_isys *isys, int source, u8 vc); |
| 117 |
#endif /* IPU7_ISYS_VIDEO_H */ |