/* * Copyright (C) 2017 Amlogic, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Description: */ #ifndef __TAHOE_H__ #define __TAHOE_H__ #include #include #include #if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 3, 13) #define KV_CLASS_CONST #define KV_CLASS_ATTR_CONST #else #define KV_CLASS_CONST const //kernel 6.6 change the type of parameter to const #define KV_CLASS_ATTR_CONST const //kernel 6.6 change the type of parameter to const #endif /* Traditionally the remove callback returned an int which however is * ignored by the driver core. This led to wrong expectations by driver * authors who thought returning an error code was a valid error * handling strategy. To convert to a callback returning void, new * drivers should implement . */ #if LINUX_VERSION_CODE <= KERNEL_VERSION(6, 11, 0) #define KV_INT_TO_VOID int #define KV_RET_x_TO_VOID(a) (a) #else #define KV_INT_TO_VOID void #define KV_RET_x_TO_VOID(a) #endif #define CHIP_ID 0x0 #define MAX_CHANNEL 1 #ifdef CONFIG_COMPAT struct compat_venc_drv_buffer_t { u32 size; u32 cached; compat_ulong_t phys_addr; compat_ulong_t base; /* kernel logical address in use kernel */ compat_ulong_t virt_addr; /* virtual user space address */ } ; #endif struct venc_drv_buffer_t { u32 size; u32 cached; ulong phys_addr; ulong base; /* kernel logical address in use kernel */ ulong virt_addr; /* virtual user space address */ }; struct venc_drv_common_buffer_t { u32 chnid; u32 size; u32 cached; ulong phys_addr; ulong base; /* kernel logical address in use kernel */ ulong virt_addr; /* virtual user space address */ }; struct venc_bit_firmware_info_t { u32 size; /* size of this structure*/ ulong reg_base_offset; u16 bit_code[512]; }; struct venc_inst_info_t { u32 inst_idx; s32 inst_open_count; /* for output only*/ }; struct venc_drv_intr_info_t { u32 timeout; s32 intr_reason; }; struct venc_drv_context_t { struct fasync_struct *async_queue; ulong interrupt_reason; u32 interrupt_flag; u32 open_count; /*!<< device reference count. Not instance count */ atomic_t request_ready; wait_queue_head_t request_complete; }; /* To track the allocated memory buffer */ struct venc_drv_buffer_pool_t { struct list_head list; struct venc_drv_buffer_t vb; struct file *filp; }; struct tahoe_dma_cfg { int fd; void *dev; void *vaddr; unsigned long paddr; struct dma_buf *dbuf; struct dma_buf_attachment *attach; struct sg_table *sg; enum dma_data_direction dir; }; struct tahoe_dma_buf_pool_t { struct list_head list; struct tahoe_dma_cfg dma_cfg; struct file *filp; }; struct tahoe_dma_buf_info_t { u32 num_planes; int fd[3]; ulong phys_addr[3]; /* phys address for DMA buffer */ }; #define TAHOE_REG_BASE_ADDR 0xFE370000 #define TAHOE_REG_SIZE 0x10000 enum { IOC_NR_GET_REGISTER_INFO = 0, IOC_NR_GET_COMMON_BUF_INFO, IOC_NR_WAIT_INTERRUPT, IOC_NR_GET_FW_BUF_INFO, IOC_NR_ALLOCATE_PHYSICAL_MEMORY, IOC_NR_FLUSH_BUFFER, IOC_NR_CACHE_INV_BUFFER, IOC_NR_FOR_DEBUG, IOC_NR_DMA_MAP, IOC_NR_DMA_UNMAP }; #define VENC_DRV_BUF_LEN struct venc_drv_buffer_t #ifdef CONFIG_COMPAT #define VENC_DRV_BUF_LEN32 struct compat_venc_drv_buffer_t #endif #define VENC_DMA_MAP_LEN struct tahoe_dma_buf_info_t #define TAHOE_MAGIC 'x' #define IOC_GET_REGISTER_INFO _IO(TAHOE_MAGIC, IOC_NR_GET_REGISTER_INFO) #define IOC_GET_COMMON_BUF_INFO _IOR(TAHOE_MAGIC, IOC_NR_GET_COMMON_BUF_INFO, VENC_DRV_BUF_LEN) #define IOC_WAIT_INTERRUPT _IO(TAHOE_MAGIC, IOC_NR_WAIT_INTERRUPT) #define IOC_GET_FW_BUF_INFO _IOR(TAHOE_MAGIC, IOC_NR_GET_FW_BUF_INFO, VENC_DRV_BUF_LEN) #define IOC_ALLOCATE_PHYSICAL_MEMORY _IOWR(TAHOE_MAGIC, IOC_NR_ALLOCATE_PHYSICAL_MEMORY, VENC_DRV_BUF_LEN) #define IOC_FLUSH_BUFFER _IOW(TAHOE_MAGIC, IOC_NR_FLUSH_BUFFER, VENC_DRV_BUF_LEN) #define IOC_CACHE_INV_BUFFER _IOW(TAHOE_MAGIC, IOC_NR_CACHE_INV_BUFFER, VENC_DRV_BUF_LEN) #define IOC_NR_FOR_DEBUG _IOR(TAHOE_MAGIC, IOC_NR_FOR_DEBUG, u32) #define IOC_CONFIG_DMA _IOR(TAHOE_MAGIC, IOC_NR_DMA_MAP, VENC_DMA_MAP_LEN) #define IOC_UNMAP_DMA _IOR(TAHOE_MAGIC, IOC_NR_DMA_UNMAP, VENC_DMA_MAP_LEN) #ifdef CONFIG_COMPAT #define IOC_GET_COMMON_BUF_INFO32 _IOR(TAHOE_MAGIC, IOC_NR_GET_COMMON_BUF_INFO, VENC_DRV_BUF_LEN32) #define IOC_GET_FW_BUF_INFO32 _IOR(TAHOE_MAGIC, IOC_NR_GET_FW_BUF_INFO, VENC_DRV_BUF_LEN32) #define IOC_ALLOCATE_PHYSICAL_MEMORY32 _IOWR(TAHOE_MAGIC, IOC_NR_ALLOCATE_PHYSICAL_MEMORY, VENC_DRV_BUF_LEN32) #define IOC_FLUSH_BUFFER32 _IOW(TAHOE_MAGIC, IOC_NR_FLUSH_BUFFER, VENC_DRV_BUF_LEN32) #define IOC_CACHE_INV_BUFFER32 _IOW(TAHOE_MAGIC, IOC_NR_CACHE_INV_BUFFER, VENC_DRV_BUF_LEN32) #endif #define ReadTahoeRegister(addr) \ readl((void __iomem *)(s_tahoe_register.virt_addr + addr)) #define WriteTahoeRegister(addr, val) \ writel((u32)val, (void __iomem *)(s_tahoe_register.virt_addr + addr)) #endif