#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/wait.h>
#include <linux/list.h>
#include <linux/dma-mapping.h>
#include <linux/delay.h>
#include <linux/vmalloc.h>
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/videodev2.h>
#include <linux/pm_runtime.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <media/videobuf2-vmalloc.h>
#include <media/videobuf2-dma-contig.h>
#include <media/videobuf2-dma-sg.h>
#include "mcam-core.h"
#ifdef MCAM_MODE_VMALLOC
static bool alloc_bufs_at_read;
module_param(alloc_bufs_at_read, bool, 0444);
MODULE_PARM_DESC(…) …;
static int n_dma_bufs = …;
module_param(n_dma_bufs, uint, 0644);
MODULE_PARM_DESC(…) …;
static int dma_buf_size = …;
module_param(dma_buf_size, uint, 0444);
MODULE_PARM_DESC(…) …;
#else
static const bool alloc_bufs_at_read;
static const int n_dma_bufs = 3;
#endif
static bool flip;
module_param(flip, bool, 0444);
MODULE_PARM_DESC(…) …;
static int buffer_mode = …;
module_param(buffer_mode, int, 0444);
MODULE_PARM_DESC(…) …;
#define CF_BUF0_VALID …
#define CF_BUF1_VALID …
#define CF_BUF2_VALID …
#define CF_DMA_ACTIVE …
#define CF_CONFIG_NEEDED …
#define CF_SINGLE_BUFFER …
#define CF_SG_RESTART …
#define CF_FRAME_SOF0 …
#define CF_FRAME_SOF1 …
#define CF_FRAME_SOF2 …
#define sensor_call(cam, o, f, args...) …
#define notifier_to_mcam(notifier) …
static struct mcam_format_struct { … } mcam_formats[] = …;
#define N_MCAM_FMTS …
static struct mcam_format_struct *mcam_find_format(u32 pixelformat)
{ … }
static const struct v4l2_pix_format mcam_def_pix_format = …;
static const u32 mcam_def_mbus_code = …;
struct mcam_dma_desc { … };
struct mcam_vb_buffer { … };
static inline struct mcam_vb_buffer *vb_to_mvb(struct vb2_v4l2_buffer *vb)
{ … }
static void mcam_buffer_done(struct mcam_camera *cam, int frame,
struct vb2_v4l2_buffer *vbuf)
{ … }
#define cam_err(cam, fmt, arg...) …
#define cam_warn(cam, fmt, arg...) …
#define cam_dbg(cam, fmt, arg...) …
static void mcam_reset_buffers(struct mcam_camera *cam)
{ … }
static inline int mcam_needs_config(struct mcam_camera *cam)
{ … }
static void mcam_set_config_needed(struct mcam_camera *cam, int needed)
{ … }
static void mcam_ctlr_start(struct mcam_camera *cam)
{ … }
static void mcam_ctlr_stop(struct mcam_camera *cam)
{ … }
static void mcam_enable_mipi(struct mcam_camera *mcam)
{ … }
static void mcam_disable_mipi(struct mcam_camera *mcam)
{ … }
static bool mcam_fmt_is_planar(__u32 pfmt)
{ … }
static void mcam_write_yuv_bases(struct mcam_camera *cam,
unsigned frame, dma_addr_t base)
{ … }
#ifdef MCAM_MODE_VMALLOC
static int mcam_alloc_dma_bufs(struct mcam_camera *cam, int loadtime)
{ … }
static void mcam_free_dma_bufs(struct mcam_camera *cam)
{ … }
static void mcam_ctlr_dma_vmalloc(struct mcam_camera *cam)
{ … }
static void mcam_frame_work(struct work_struct *t)
{ … }
static int mcam_check_dma_buffers(struct mcam_camera *cam)
{ … }
static void mcam_vmalloc_done(struct mcam_camera *cam, int frame)
{ … }
#else
static inline int mcam_alloc_dma_bufs(struct mcam_camera *cam, int loadtime)
{
return 0;
}
static inline void mcam_free_dma_bufs(struct mcam_camera *cam)
{
return;
}
static inline int mcam_check_dma_buffers(struct mcam_camera *cam)
{
return 0;
}
#endif
#ifdef MCAM_MODE_DMA_CONTIG
static void mcam_set_contig_buffer(struct mcam_camera *cam, int frame)
{ … }
static void mcam_ctlr_dma_contig(struct mcam_camera *cam)
{ … }
static void mcam_dma_contig_done(struct mcam_camera *cam, int frame)
{ … }
#endif
#ifdef MCAM_MODE_DMA_SG
static void mcam_sg_next_buffer(struct mcam_camera *cam)
{ … }
static void mcam_ctlr_dma_sg(struct mcam_camera *cam)
{ … }
static void mcam_dma_sg_done(struct mcam_camera *cam, int frame)
{ … }
static void mcam_sg_restart(struct mcam_camera *cam)
{ … }
#else
static inline void mcam_sg_restart(struct mcam_camera *cam)
{
return;
}
#endif
static void mcam_ctlr_image(struct mcam_camera *cam)
{ … }
static int mcam_ctlr_configure(struct mcam_camera *cam)
{ … }
static void mcam_ctlr_irq_enable(struct mcam_camera *cam)
{ … }
static void mcam_ctlr_irq_disable(struct mcam_camera *cam)
{ … }
static void mcam_ctlr_stop_dma(struct mcam_camera *cam)
{ … }
static int mcam_ctlr_power_up(struct mcam_camera *cam)
{ … }
static void mcam_ctlr_power_down(struct mcam_camera *cam)
{ … }
static int mclk_prepare(struct clk_hw *hw)
{ … }
static void mclk_unprepare(struct clk_hw *hw)
{ … }
static int mclk_enable(struct clk_hw *hw)
{ … }
static void mclk_disable(struct clk_hw *hw)
{ … }
static unsigned long mclk_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{ … }
static const struct clk_ops mclk_ops = …;
static int __mcam_cam_reset(struct mcam_camera *cam)
{ … }
static int mcam_cam_init(struct mcam_camera *cam)
{ … }
static int mcam_cam_set_flip(struct mcam_camera *cam)
{ … }
static int mcam_cam_configure(struct mcam_camera *cam)
{ … }
static int mcam_read_setup(struct mcam_camera *cam)
{ … }
static int mcam_vb_queue_setup(struct vb2_queue *vq,
unsigned int *nbufs,
unsigned int *num_planes, unsigned int sizes[],
struct device *alloc_devs[])
{ … }
static void mcam_vb_buf_queue(struct vb2_buffer *vb)
{ … }
static void mcam_vb_requeue_bufs(struct vb2_queue *vq,
enum vb2_buffer_state state)
{ … }
static int mcam_vb_start_streaming(struct vb2_queue *vq, unsigned int count)
{ … }
static void mcam_vb_stop_streaming(struct vb2_queue *vq)
{ … }
static const struct vb2_ops mcam_vb2_ops = …;
#ifdef MCAM_MODE_DMA_SG
static int mcam_vb_sg_buf_init(struct vb2_buffer *vb)
{ … }
static int mcam_vb_sg_buf_prepare(struct vb2_buffer *vb)
{ … }
static void mcam_vb_sg_buf_cleanup(struct vb2_buffer *vb)
{ … }
static const struct vb2_ops mcam_vb2_sg_ops = …;
#endif
static int mcam_setup_vb2(struct mcam_camera *cam)
{ … }
static int mcam_vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{ … }
static int mcam_vidioc_enum_fmt_vid_cap(struct file *filp,
void *priv, struct v4l2_fmtdesc *fmt)
{ … }
static int mcam_vidioc_try_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *fmt)
{ … }
static int mcam_vidioc_s_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *fmt)
{ … }
static int mcam_vidioc_g_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *f)
{ … }
static int mcam_vidioc_enum_input(struct file *filp, void *priv,
struct v4l2_input *input)
{ … }
static int mcam_vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
{ … }
static int mcam_vidioc_s_input(struct file *filp, void *priv, unsigned int i)
{ … }
static int mcam_vidioc_g_parm(struct file *filp, void *priv,
struct v4l2_streamparm *a)
{ … }
static int mcam_vidioc_s_parm(struct file *filp, void *priv,
struct v4l2_streamparm *a)
{ … }
static int mcam_vidioc_enum_framesizes(struct file *filp, void *priv,
struct v4l2_frmsizeenum *sizes)
{ … }
static int mcam_vidioc_enum_frameintervals(struct file *filp, void *priv,
struct v4l2_frmivalenum *interval)
{ … }
#ifdef CONFIG_VIDEO_ADV_DEBUG
static int mcam_vidioc_g_register(struct file *file, void *priv,
struct v4l2_dbg_register *reg)
{ … }
static int mcam_vidioc_s_register(struct file *file, void *priv,
const struct v4l2_dbg_register *reg)
{ … }
#endif
static const struct v4l2_ioctl_ops mcam_v4l_ioctl_ops = …;
static int mcam_v4l_open(struct file *filp)
{ … }
static int mcam_v4l_release(struct file *filp)
{ … }
static const struct v4l2_file_operations mcam_v4l_fops = …;
static const struct video_device mcam_v4l_template = …;
static void mcam_frame_complete(struct mcam_camera *cam, int frame)
{ … }
int mccic_irq(struct mcam_camera *cam, unsigned int irqs)
{ … }
EXPORT_SYMBOL_GPL(…);
static int mccic_notify_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *subdev, struct v4l2_async_connection *asd)
{ … }
static void mccic_notify_unbind(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *subdev, struct v4l2_async_connection *asd)
{ … }
static int mccic_notify_complete(struct v4l2_async_notifier *notifier)
{ … }
static const struct v4l2_async_notifier_operations mccic_notify_ops = …;
int mccic_register(struct mcam_camera *cam)
{ … }
EXPORT_SYMBOL_GPL(…);
void mccic_shutdown(struct mcam_camera *cam)
{ … }
EXPORT_SYMBOL_GPL(…);
void mccic_suspend(struct mcam_camera *cam)
{ … }
EXPORT_SYMBOL_GPL(…);
int mccic_resume(struct mcam_camera *cam)
{ … }
EXPORT_SYMBOL_GPL(…);
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;