#include <linux/delay.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_graph.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-rect.h>
#include "am437x-vpfe.h"
#define VPFE_MODULE_NAME …
#define VPFE_VERSION …
static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(…) …;
#define vpfe_dbg(level, dev, fmt, arg...) …
#define vpfe_info(dev, fmt, arg...) …
#define vpfe_err(dev, fmt, arg...) …
struct vpfe_standard { … };
static const struct vpfe_standard vpfe_standards[] = …;
static struct vpfe_fmt formats[VPFE_NUM_FORMATS] = …;
static int __subdev_get_format(struct vpfe_device *vpfe,
struct v4l2_mbus_framefmt *fmt);
static int vpfe_calc_format_size(struct vpfe_device *vpfe,
const struct vpfe_fmt *fmt,
struct v4l2_format *f);
static struct vpfe_fmt *find_format_by_code(struct vpfe_device *vpfe,
unsigned int code)
{ … }
static struct vpfe_fmt *find_format_by_pix(struct vpfe_device *vpfe,
unsigned int pixelformat)
{ … }
static unsigned int __get_bytesperpixel(struct vpfe_device *vpfe,
const struct vpfe_fmt *fmt)
{ … }
static char *print_fourcc(u32 fmt)
{ … }
static inline u32 vpfe_reg_read(struct vpfe_ccdc *ccdc, u32 offset)
{ … }
static inline void vpfe_reg_write(struct vpfe_ccdc *ccdc, u32 val, u32 offset)
{ … }
static inline struct vpfe_device *to_vpfe(struct vpfe_ccdc *ccdc)
{ … }
static inline
struct vpfe_cap_buffer *to_vpfe_buffer(struct vb2_v4l2_buffer *vb)
{ … }
static inline void vpfe_pcr_enable(struct vpfe_ccdc *ccdc, int flag)
{ … }
static void vpfe_config_enable(struct vpfe_ccdc *ccdc, int flag)
{ … }
static void vpfe_ccdc_setwin(struct vpfe_ccdc *ccdc,
struct v4l2_rect *image_win,
enum ccdc_frmfmt frm_fmt,
int bpp)
{ … }
static void vpfe_reg_dump(struct vpfe_ccdc *ccdc)
{ … }
static int
vpfe_ccdc_validate_param(struct vpfe_ccdc *ccdc,
struct vpfe_ccdc_config_params_raw *ccdcparam)
{ … }
static void
vpfe_ccdc_update_raw_params(struct vpfe_ccdc *ccdc,
struct vpfe_ccdc_config_params_raw *raw_params)
{ … }
static void vpfe_ccdc_restore_defaults(struct vpfe_ccdc *ccdc)
{ … }
static int vpfe_ccdc_close(struct vpfe_ccdc *ccdc, struct device *dev)
{ … }
static int vpfe_ccdc_set_params(struct vpfe_ccdc *ccdc, void __user *params)
{ … }
static void vpfe_ccdc_config_ycbcr(struct vpfe_ccdc *ccdc)
{ … }
static void
vpfe_ccdc_config_black_clamp(struct vpfe_ccdc *ccdc,
struct vpfe_ccdc_black_clamp *bclamp)
{ … }
static void
vpfe_ccdc_config_black_compense(struct vpfe_ccdc *ccdc,
struct vpfe_ccdc_black_compensation *bcomp)
{ … }
static void vpfe_ccdc_config_raw(struct vpfe_ccdc *ccdc)
{ … }
static inline int
vpfe_ccdc_set_buftype(struct vpfe_ccdc *ccdc,
enum ccdc_buftype buf_type)
{ … }
static inline enum ccdc_buftype vpfe_ccdc_get_buftype(struct vpfe_ccdc *ccdc)
{ … }
static int vpfe_ccdc_set_pixel_format(struct vpfe_ccdc *ccdc, u32 pixfmt)
{ … }
static u32 vpfe_ccdc_get_pixel_format(struct vpfe_ccdc *ccdc)
{ … }
static int
vpfe_ccdc_set_image_window(struct vpfe_ccdc *ccdc,
struct v4l2_rect *win, unsigned int bpp)
{ … }
static inline void
vpfe_ccdc_get_image_window(struct vpfe_ccdc *ccdc,
struct v4l2_rect *win)
{ … }
static inline unsigned int vpfe_ccdc_get_line_length(struct vpfe_ccdc *ccdc)
{ … }
static inline int
vpfe_ccdc_set_frame_format(struct vpfe_ccdc *ccdc,
enum ccdc_frmfmt frm_fmt)
{ … }
static inline enum ccdc_frmfmt
vpfe_ccdc_get_frame_format(struct vpfe_ccdc *ccdc)
{ … }
static inline int vpfe_ccdc_getfid(struct vpfe_ccdc *ccdc)
{ … }
static inline void vpfe_set_sdr_addr(struct vpfe_ccdc *ccdc, unsigned long addr)
{ … }
static int vpfe_ccdc_set_hw_if_params(struct vpfe_ccdc *ccdc,
struct vpfe_hw_if_param *params)
{ … }
static void vpfe_clear_intr(struct vpfe_ccdc *ccdc, int vdint)
{ … }
static void vpfe_ccdc_config_defaults(struct vpfe_ccdc *ccdc)
{ … }
static int vpfe_get_ccdc_image_format(struct vpfe_device *vpfe,
struct v4l2_format *f)
{ … }
static int vpfe_config_ccdc_image_format(struct vpfe_device *vpfe)
{ … }
static int vpfe_config_image_format(struct vpfe_device *vpfe,
v4l2_std_id std_id)
{ … }
static int vpfe_initialize_device(struct vpfe_device *vpfe)
{ … }
static int vpfe_release(struct file *file)
{ … }
static int vpfe_open(struct file *file)
{ … }
static void vpfe_schedule_next_buffer(struct vpfe_device *vpfe)
{ … }
static inline void vpfe_schedule_bottom_field(struct vpfe_device *vpfe)
{ … }
static inline void vpfe_process_buffer_complete(struct vpfe_device *vpfe)
{ … }
static void vpfe_handle_interlaced_irq(struct vpfe_device *vpfe,
enum v4l2_field field)
{ … }
static irqreturn_t vpfe_isr(int irq, void *dev)
{ … }
static inline void vpfe_detach_irq(struct vpfe_device *vpfe)
{ … }
static inline void vpfe_attach_irq(struct vpfe_device *vpfe)
{ … }
static int vpfe_querycap(struct file *file, void *priv,
struct v4l2_capability *cap)
{ … }
static int __subdev_get_format(struct vpfe_device *vpfe,
struct v4l2_mbus_framefmt *fmt)
{ … }
static int __subdev_set_format(struct vpfe_device *vpfe,
struct v4l2_mbus_framefmt *fmt)
{ … }
static int vpfe_calc_format_size(struct vpfe_device *vpfe,
const struct vpfe_fmt *fmt,
struct v4l2_format *f)
{ … }
static int vpfe_g_fmt(struct file *file, void *priv,
struct v4l2_format *fmt)
{ … }
static int vpfe_enum_fmt(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{ … }
static int vpfe_try_fmt(struct file *file, void *priv,
struct v4l2_format *f)
{ … }
static int vpfe_s_fmt(struct file *file, void *priv,
struct v4l2_format *fmt)
{ … }
static int vpfe_enum_size(struct file *file, void *priv,
struct v4l2_frmsizeenum *fsize)
{ … }
static int
vpfe_get_subdev_input_index(struct vpfe_device *vpfe,
int *subdev_index,
int *subdev_input_index,
int app_input_index)
{ … }
static int vpfe_get_app_input_index(struct vpfe_device *vpfe,
int *app_input_index)
{ … }
static int vpfe_enum_input(struct file *file, void *priv,
struct v4l2_input *inp)
{ … }
static int vpfe_g_input(struct file *file, void *priv, unsigned int *index)
{ … }
static int vpfe_set_input(struct vpfe_device *vpfe, unsigned int index)
{ … }
static int vpfe_s_input(struct file *file, void *priv, unsigned int index)
{ … }
static int vpfe_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
{ … }
static int vpfe_s_std(struct file *file, void *priv, v4l2_std_id std_id)
{ … }
static int vpfe_g_std(struct file *file, void *priv, v4l2_std_id *std_id)
{ … }
static void vpfe_calculate_offsets(struct vpfe_device *vpfe)
{ … }
static int vpfe_queue_setup(struct vb2_queue *vq,
unsigned int *nbuffers, unsigned int *nplanes,
unsigned int sizes[], struct device *alloc_devs[])
{ … }
static int vpfe_buffer_prepare(struct vb2_buffer *vb)
{ … }
static void vpfe_buffer_queue(struct vb2_buffer *vb)
{ … }
static void vpfe_return_all_buffers(struct vpfe_device *vpfe,
enum vb2_buffer_state state)
{ … }
static int vpfe_start_streaming(struct vb2_queue *vq, unsigned int count)
{ … }
static void vpfe_stop_streaming(struct vb2_queue *vq)
{ … }
static int vpfe_g_pixelaspect(struct file *file, void *priv,
int type, struct v4l2_fract *f)
{ … }
static int
vpfe_g_selection(struct file *file, void *fh, struct v4l2_selection *s)
{ … }
static int
vpfe_s_selection(struct file *file, void *fh, struct v4l2_selection *s)
{ … }
static long vpfe_ioctl_default(struct file *file, void *priv,
bool valid_prio, unsigned int cmd, void *param)
{ … }
static const struct vb2_ops vpfe_video_qops = …;
static const struct v4l2_file_operations vpfe_fops = …;
static const struct v4l2_ioctl_ops vpfe_ioctl_ops = …;
static int
vpfe_async_bound(struct v4l2_async_notifier *notifier,
struct v4l2_subdev *subdev,
struct v4l2_async_connection *asd)
{ … }
static int vpfe_probe_complete(struct vpfe_device *vpfe)
{ … }
static int vpfe_async_complete(struct v4l2_async_notifier *notifier)
{ … }
static const struct v4l2_async_notifier_operations vpfe_async_ops = …;
static struct vpfe_config *
vpfe_get_pdata(struct vpfe_device *vpfe)
{ … }
static int vpfe_probe(struct platform_device *pdev)
{ … }
static void vpfe_remove(struct platform_device *pdev)
{ … }
#ifdef CONFIG_PM_SLEEP
static void vpfe_save_context(struct vpfe_ccdc *ccdc)
{ … }
static int vpfe_suspend(struct device *dev)
{ … }
static void vpfe_restore_context(struct vpfe_ccdc *ccdc)
{ … }
static int vpfe_resume(struct device *dev)
{ … }
#endif
static SIMPLE_DEV_PM_OPS(vpfe_pm_ops, vpfe_suspend, vpfe_resume);
static const struct of_device_id vpfe_of_match[] = …;
MODULE_DEVICE_TABLE(of, vpfe_of_match);
static struct platform_driver vpfe_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_VERSION(…);