#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/list.h>
#include <linux/pci.h>
#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/videodev2.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <media/v4l2-image-sizes.h>
#include <media/i2c/ov7670.h>
#include <media/videobuf2-dma-sg.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/pm_qos.h>
#include <linux/via-core.h>
#include <linux/via_i2c.h>
#ifdef CONFIG_X86
#include <asm/olpc.h>
#else
#define machine_is_olpc …
#endif
#include "via-camera.h"
MODULE_ALIAS(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
static bool flip_image;
module_param(flip_image, bool, 0444);
MODULE_PARM_DESC(…) …;
static bool override_serial;
module_param(override_serial, bool, 0444);
MODULE_PARM_DESC(…) …;
enum viacam_opstate { … };
struct via_camera { … };
struct via_buffer { … };
static struct via_camera *via_cam_info;
#define CF_DMA_ACTIVE …
#define CF_CONFIG_NEEDED …
#define sensor_call(cam, optype, func, args...) …
#define cam_err(cam, fmt, arg...) …
#define cam_warn(cam, fmt, arg...) …
#define cam_dbg(cam, fmt, arg...) …
static struct via_format { … } via_formats[] = …;
#define N_VIA_FMTS …
static struct via_format *via_find_format(u32 pixelformat)
{ … }
static int via_sensor_power_setup(struct via_camera *cam)
{ … }
static void via_sensor_power_up(struct via_camera *cam)
{ … }
static void via_sensor_power_down(struct via_camera *cam)
{ … }
static void via_sensor_power_release(struct via_camera *cam)
{ … }
static int viacam_set_flip(struct via_camera *cam)
{ … }
static int viacam_configure_sensor(struct via_camera *cam)
{ … }
static inline void viacam_write_reg(struct via_camera *cam,
int reg, int value)
{ … }
static inline int viacam_read_reg(struct via_camera *cam, int reg)
{ … }
static inline void viacam_write_reg_mask(struct via_camera *cam,
int reg, int value, int mask)
{ … }
static irqreturn_t viacam_quick_irq(int irq, void *data)
{ … }
static struct via_buffer *viacam_next_buffer(struct via_camera *cam)
{ … }
static irqreturn_t viacam_irq(int irq, void *data)
{ … }
static void viacam_int_enable(struct via_camera *cam)
{ … }
static void viacam_int_disable(struct via_camera *cam)
{ … }
static int viacam_ctlr_cbufs(struct via_camera *cam)
{ … }
static void viacam_set_scale(struct via_camera *cam)
{ … }
static void viacam_ctlr_image(struct via_camera *cam)
{ … }
static int viacam_config_controller(struct via_camera *cam)
{ … }
static void viacam_start_engine(struct via_camera *cam)
{ … }
static void viacam_stop_engine(struct via_camera *cam)
{ … }
static struct via_buffer *vb2_to_via_buffer(struct vb2_buffer *vb)
{ … }
static void viacam_vb2_queue(struct vb2_buffer *vb)
{ … }
static int viacam_vb2_prepare(struct vb2_buffer *vb)
{ … }
static int viacam_vb2_queue_setup(struct vb2_queue *vq,
unsigned int *nbufs,
unsigned int *num_planes, unsigned int sizes[],
struct device *alloc_devs[])
{ … }
static int viacam_vb2_start_streaming(struct vb2_queue *vq, unsigned int count)
{ … }
static void viacam_vb2_stop_streaming(struct vb2_queue *vq)
{ … }
static const struct vb2_ops viacam_vb2_ops = …;
static int viacam_open(struct file *filp)
{ … }
static int viacam_release(struct file *filp)
{ … }
static const struct v4l2_file_operations viacam_fops = …;
static int viacam_enum_input(struct file *filp, void *priv,
struct v4l2_input *input)
{ … }
static int viacam_g_input(struct file *filp, void *priv, unsigned int *i)
{ … }
static int viacam_s_input(struct file *filp, void *priv, unsigned int i)
{ … }
static const struct v4l2_pix_format viacam_def_pix_format = …;
static const u32 via_def_mbus_code = …;
static int viacam_enum_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_fmtdesc *fmt)
{ … }
static void viacam_fmt_pre(struct v4l2_pix_format *userfmt,
struct v4l2_pix_format *sensorfmt)
{ … }
static void viacam_fmt_post(struct v4l2_pix_format *userfmt,
struct v4l2_pix_format *sensorfmt)
{ … }
static int viacam_do_try_fmt(struct via_camera *cam,
struct v4l2_pix_format *upix, struct v4l2_pix_format *spix)
{ … }
static int viacam_try_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *fmt)
{ … }
static int viacam_g_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *fmt)
{ … }
static int viacam_s_fmt_vid_cap(struct file *filp, void *priv,
struct v4l2_format *fmt)
{ … }
static int viacam_querycap(struct file *filp, void *priv,
struct v4l2_capability *cap)
{ … }
static int viacam_g_parm(struct file *filp, void *priv,
struct v4l2_streamparm *parm)
{ … }
static int viacam_s_parm(struct file *filp, void *priv,
struct v4l2_streamparm *parm)
{ … }
static int viacam_enum_framesizes(struct file *filp, void *priv,
struct v4l2_frmsizeenum *sizes)
{ … }
static int viacam_enum_frameintervals(struct file *filp, void *priv,
struct v4l2_frmivalenum *interval)
{ … }
static const struct v4l2_ioctl_ops viacam_ioctl_ops = …;
#ifdef CONFIG_PM
static int viacam_suspend(void *priv)
{ … }
static int viacam_resume(void *priv)
{ … }
static struct viafb_pm_hooks viacam_pm_hooks = …;
#endif
static const struct video_device viacam_v4l_template = …;
#define VIACAM_SERIAL_DEVFN …
#define VIACAM_SERIAL_CREG …
#define VIACAM_SERIAL_BIT …
static bool viacam_serial_is_enabled(void)
{ … }
static struct ov7670_config sensor_cfg = …;
static int viacam_probe(struct platform_device *pdev)
{ … }
static void viacam_remove(struct platform_device *pdev)
{ … }
static struct platform_driver viacam_driver = …;
module_platform_driver(…) …;