/* * Copyright (c) 2011 Atmel Corporation * Josh Wu, <josh.wu@atmel.com> * * Based on previous work by Lars Haring, <lars.haring@atmel.com> * and Sedji Gaouaou * Based on the bttv driver for Bt848 with respective copyright holders * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#include<linux/clk.h>#include<linux/completion.h>#include<linux/delay.h>#include<linux/fs.h>#include<linux/init.h>#include<linux/interrupt.h>#include<linux/kernel.h>#include<linux/module.h>#include<linux/of_graph.h>#include<linux/platform_device.h>#include<linux/pm_runtime.h>#include<linux/slab.h>#include<linux/of.h>#include<linux/videodev2.h>#include<media/v4l2-ctrls.h>#include<media/v4l2-device.h>#include<media/v4l2-dev.h>#include<media/v4l2-ioctl.h>#include<media/v4l2-event.h>#include<media/v4l2-fwnode.h>#include<media/videobuf2-dma-contig.h>#include<media/v4l2-image-sizes.h>#include"atmel-isi.h"#define MAX_SUPPORT_WIDTH 2048U#define MAX_SUPPORT_HEIGHT 2048U#define MIN_FRAME_RATE 15#define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE)/* Frame buffer descriptor */structfbd{/* Physical address of the frame buffer */u32fb_address;/* DMA Control Register(only in HISI2) */u32dma_ctrl;/* Physical address of the next fbd */u32next_fbd_address;};staticvoidset_dma_ctrl(structfbd*fb_desc,u32ctrl){fb_desc->dma_ctrl=ctrl;}structisi_dma_desc{structlist_headlist;structfbd*p_fbd;dma_addr_tfbd_phys;};/* Frame buffer data */structframe_buffer{structvb2_v4l2_buffervb;structisi_dma_desc*p_dma_desc;structlist_headlist;};structisi_graph_entity{structdevice_node*node;structv4l2_async_subdevasd;structv4l2_subdev*subdev;};/* * struct isi_format - ISI media bus format information * @fourcc: Fourcc code for this format * @mbus_code: V4L2 media bus format code. * @bpp: Bytes per pixel (when stored in memory) * @swap: Byte swap configuration value * @support: Indicates format supported by subdev * @skip: Skip duplicate format supported by subdev */structisi_format{u32fourcc;u32mbus_code;u8bpp;u32swap;};structatmel_isi{/* Protects the access of variables shared with the ISR */spinlock_tirqlock;structdevice*dev;void__iomem*regs;intsequence;/* Allocate descriptors for dma buffer use */struct