1 /* 2 * linux-5.4/drivers/media/platform/sunxi-vin/vin-tdm/vin_tdm.h 3 * 4 * Copyright (c) 2007-2019 Allwinnertech Co., Ltd. 5 * 6 * Authors: Zheng Zequn <zequnzheng@allwinnertech.com> 7 * 8 * This software is licensed under the terms of the GNU General Public 9 * License version 2, as published by the Free Software Foundation, and 10 * may be copied, distributed, and modified under those terms. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 */ 18 19 #ifndef _VIN_TDM_H_ 20 #define _VIN_TDM_H_ 21 22 #include <linux/kernel.h> 23 #include "tdm_reg.h" 24 #include "../vin-video/vin_core.h" 25 26 #define TDM_BUFS_NUM 5 27 #define TDM_TX_HBLANK 96 28 #define TDM_TX_VBLANK 36 29 30 struct tdm_buffer { 31 void *virt_addr; 32 void *dma_addr; 33 u32 buf_size; 34 u8 empty; 35 }; 36 37 enum tdm_state_t { 38 TDM_USED = 0, 39 TDM_NO_USED, 40 }; 41 42 enum tdm_pad { 43 TDM_PAD_SINK, 44 TDM_PAD_SOURCE, 45 TDM_PAD_NUM, 46 }; 47 48 enum input_bit_width { 49 RAW_8BIT = 8, 50 RAW_10BIT = 10, 51 RAW_12BIT = 12, 52 }; 53 54 struct tdm_format { 55 u32 code; 56 enum input_bit_width input_bit_width; 57 enum input_image_type_sel input_type; 58 }; 59 60 struct tdm_rx_dev { 61 unsigned char id; 62 struct v4l2_subdev subdev; 63 struct media_pad tdm_pads[TDM_PAD_NUM]; 64 struct mutex subdev_lock; 65 struct tdm_format *tdm_fmt; 66 struct v4l2_mbus_framefmt format; 67 u32 stream_cnt; 68 u32 width; 69 u32 heigtht; 70 71 /* Buffer */ 72 u32 buf_size; 73 u32 buf_cnt; 74 struct vin_mm ion_man[TDM_BUFS_NUM]; /* for ion alloc/free manage */ 75 struct tdm_buffer buf[TDM_BUFS_NUM]; 76 }; 77 78 struct tdm_dev { 79 void __iomem *base; 80 unsigned char id; 81 int irq; 82 char is_empty; 83 struct platform_device *pdev; 84 spinlock_t slock; 85 86 struct tdm_rx_dev tdm_rx[TDM_RX_NUM]; 87 bool tdm_rx_buf_en[TDM_RX_NUM]; 88 89 /* Control */ 90 bool configured; 91 enum tdm_state_t state; /* enabling/disabling state */ 92 struct mutex ioctl_lock; /* serialize private ioctl */ 93 u32 stream_cnt; 94 }; 95 96 int sunxi_tdm_platform_register(void); 97 void sunxi_tdm_platform_unregister(void); 98 struct v4l2_subdev *sunxi_tdm_get_subdev(int id, int tdm_rx_num); 99 100 #endif /*_VIN_TDM_H_*/ 101 102