1/* SPDX-License-Identifier: GPL-2.0+ */ 2/* 3 * Copyright 2021-2022 Bootlin 4 * Author: Paul Kocialkowski <paul.kocialkowski@bootlin.com> 5 */ 6 7#ifndef _SUN6I_ISP_CAPTURE_H_ 8#define _SUN6I_ISP_CAPTURE_H_ 9 10#include <media/v4l2-device.h> 11 12#define SUN6I_ISP_CAPTURE_NAME "sun6i-isp-capture" 13 14#define SUN6I_ISP_CAPTURE_WIDTH_MIN 16 15#define SUN6I_ISP_CAPTURE_WIDTH_MAX 3264 16#define SUN6I_ISP_CAPTURE_HEIGHT_MIN 16 17#define SUN6I_ISP_CAPTURE_HEIGHT_MAX 2448 18 19struct sun6i_isp_device; 20 21struct sun6i_isp_capture_format { 22 u32 pixelformat; 23 u8 output_format; 24}; 25 26#undef current 27struct sun6i_isp_capture_state { 28 struct list_head queue; 29 spinlock_t lock; /* Queue and buffers lock. */ 30 31 struct sun6i_isp_buffer *pending; 32 struct sun6i_isp_buffer *current; 33 struct sun6i_isp_buffer *complete; 34 35 unsigned int sequence; 36 bool streaming; 37}; 38 39struct sun6i_isp_capture { 40 struct sun6i_isp_capture_state state; 41 42 struct video_device video_dev; 43 struct vb2_queue queue; 44 struct mutex lock; /* Queue lock. */ 45 struct media_pad pad; 46 47 struct v4l2_format format; 48}; 49 50/* Helpers */ 51 52void sun6i_isp_capture_dimensions(struct sun6i_isp_device *isp_dev, 53 unsigned int *width, unsigned int *height); 54void sun6i_isp_capture_format(struct sun6i_isp_device *isp_dev, 55 u32 *pixelformat); 56 57/* Format */ 58 59const struct sun6i_isp_capture_format * 60sun6i_isp_capture_format_find(u32 pixelformat); 61 62/* Capture */ 63 64void sun6i_isp_capture_configure(struct sun6i_isp_device *isp_dev); 65 66/* State */ 67 68void sun6i_isp_capture_state_update(struct sun6i_isp_device *isp_dev, 69 bool *update); 70void sun6i_isp_capture_state_complete(struct sun6i_isp_device *isp_dev); 71void sun6i_isp_capture_finish(struct sun6i_isp_device *isp_dev); 72 73/* Capture */ 74 75int sun6i_isp_capture_setup(struct sun6i_isp_device *isp_dev); 76void sun6i_isp_capture_cleanup(struct sun6i_isp_device *isp_dev); 77 78#endif 79